Chapter 2 Integers and Mathematical Induction Discrete Mathematical

  • Slides: 51
Download presentation
Chapter 2: Integers and Mathematical Induction Discrete Mathematical Structures: Theory and Applications

Chapter 2: Integers and Mathematical Induction Discrete Mathematical Structures: Theory and Applications

Learning Objectives q Learn about the basic properties of integers q Become aware how

Learning Objectives q Learn about the basic properties of integers q Become aware how integers are represented in computer memory q Explore how addition and subtraction operations are performed on binary numbers q Learn how the principle of mathematical induction is used to solve problems Discrete Mathematical Structures: Theory and Applications 2

Learning Objectives q Learn about loop invariants and how they are used to prove

Learning Objectives q Learn about loop invariants and how they are used to prove the correctness of loops q Explore various properties of prime numbers q Learn about linear Diophantine equations and how to solve them Discrete Mathematical Structures: Theory and Applications 3

Integers q Properties of Integers Discrete Mathematical Structures: Theory and Applications 4

Integers q Properties of Integers Discrete Mathematical Structures: Theory and Applications 4

Integers Discrete Mathematical Structures: Theory and Applications 5

Integers Discrete Mathematical Structures: Theory and Applications 5

Integers Discrete Mathematical Structures: Theory and Applications 6

Integers Discrete Mathematical Structures: Theory and Applications 6

Integers Discrete Mathematical Structures: Theory and Applications 7

Integers Discrete Mathematical Structures: Theory and Applications 7

Integers Discrete Mathematical Structures: Theory and Applications 8

Integers Discrete Mathematical Structures: Theory and Applications 8

Integers Discrete Mathematical Structures: Theory and Applications 9

Integers Discrete Mathematical Structures: Theory and Applications 9

Integers q The div and mod operators qdiv q a div b = the

Integers q The div and mod operators qdiv q a div b = the quotient of a and b obtained by dividing a on b. q. Examples: q 8 div 5 = 1 q 13 div 3 = 4 qmod qa mod b = the remainder of a and b obtained by dividing a on b q 8 mod 5 = 3 q 13 mod 3 = 1 Discrete Mathematical Structures: Theory and Applications 10

Integers Discrete Mathematical Structures: Theory and Applications 11

Integers Discrete Mathematical Structures: Theory and Applications 11

Integers Discrete Mathematical Structures: Theory and Applications 12

Integers Discrete Mathematical Structures: Theory and Applications 12

Integers Discrete Mathematical Structures: Theory and Applications 13

Integers Discrete Mathematical Structures: Theory and Applications 13

Integers Discrete Mathematical Structures: Theory and Applications 14

Integers Discrete Mathematical Structures: Theory and Applications 14

Integers q Relatively Prime Number Discrete Mathematical Structures: Theory and Applications 15

Integers q Relatively Prime Number Discrete Mathematical Structures: Theory and Applications 15

Integers q Least Common Multiples Discrete Mathematical Structures: Theory and Applications 16

Integers q Least Common Multiples Discrete Mathematical Structures: Theory and Applications 16

Representation of Integers in Computer q Electrical signals are used inside the computer to

Representation of Integers in Computer q Electrical signals are used inside the computer to process information q. Two types of signals q. Analog q. Continuous wave forms used to represent such things as sound q. Examples: audio tapes, older television signals, etc. q. Digital q. Represent information with a sequence of 0 s and 1 s q. Examples: compact discs, newer digital HDTV signals Discrete Mathematical Structures: Theory and Applications 17

Representation of Integers in Computers q Digital Signals q 0 s and 1 s

Representation of Integers in Computers q Digital Signals q 0 s and 1 s – 0 s represent low voltage, 1 s high voltage q. Digital signals are more reliable carriers of information than analog signals q. Can be copied from one device to another with exact precision q. Machine language is a sequence of 0 s and 1 s q. The digit 0 or 1 is called a binary digit , or bit q. A sequence of 0 s and 1 s is sometimes referred to as binary code Discrete Mathematical Structures: Theory and Applications 18

Representation of Integers in Computers q Decimal System or Base-10 q The digits that

Representation of Integers in Computers q Decimal System or Base-10 q The digits that are used to represent numbers in base 10 are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 q Binary System or Base-2 q Computer memory stores numbers in machine language, i. e. , as a sequence of 0 s and 1 s q Octal System or Base-8 q Digits that are used to represent numbers in base 8 are 0, 1, 2, 3, 4, 5, 6, and 7 q Hexadecimal System or Base-16 q Digits and letters that are used to represent numbers in base 16 are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A , B , C , D , E , and F Discrete Mathematical Structures: Theory and Applications 19

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 20

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 20

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 21

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 21

Representation of Integers in Computers q Two’s Complements and Operations on Binary Numbers q.

Representation of Integers in Computers q Two’s Complements and Operations on Binary Numbers q. In computer memory, integers are represented as binary numbers in fixed-length bit strings, such as 8, 16, 32 and 64 q. Assume that integers are represented as 8 -bit fixed-length strings q. Sign bit is the MSB (Most Significant Bit) q. Leftmost bit (MSB) = 0, number is positive q. Leftmost bit (MSB) = 1, number is negative Discrete Mathematical Structures: Theory and Applications 22

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 23

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 23

Representation of Integers in Computers q One’s Complements and Operations on Binary Numbers Discrete

Representation of Integers in Computers q One’s Complements and Operations on Binary Numbers Discrete Mathematical Structures: Theory and Applications 24

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 25

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 25

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 26

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 26

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 27

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 27

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 28

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 28

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 29

Representation of Integers in Computers Discrete Mathematical Structures: Theory and Applications 29

Mathematical Deduction Discrete Mathematical Structures: Theory and Applications 30

Mathematical Deduction Discrete Mathematical Structures: Theory and Applications 30

Mathematical Deduction q Proof of a mathematical statement by the principle of mathematical induction

Mathematical Deduction q Proof of a mathematical statement by the principle of mathematical induction consists of three steps: Discrete Mathematical Structures: Theory and Applications 31

Mathematical Deduction q Assume that when a domino is knocked over, the next domino

Mathematical Deduction q Assume that when a domino is knocked over, the next domino is knocked over by it q Show that if the first domino is knocked over, then all the dominoes will be knocked over Discrete Mathematical Structures: Theory and Applications 32

Mathematical Deduction q Let P(n) denote the statement that then nth domino is knocked

Mathematical Deduction q Let P(n) denote the statement that then nth domino is knocked over q Show that P(1) is true q Assume some P(k) is true, i. e. the kth domino is knocked over for some q Prove that P(k+1) is true, i. e. Discrete Mathematical Structures: Theory and Applications 33

Mathematical Deduction q Assume that when a staircase is climbed, the next staircase is

Mathematical Deduction q Assume that when a staircase is climbed, the next staircase is also climbed q Show that if the first staircase is climbed then all staircases can be climbed q Let P(n) denote the statement that then nth staircase is climbed q It is given that the first staircase is climbed, so P(1) is true Discrete Mathematical Structures: Theory and Applications 34

Mathematical Deduction q Suppose some P(k) is true, i. e. the kth staircase is

Mathematical Deduction q Suppose some P(k) is true, i. e. the kth staircase is climbed for some q By the assumption, because the kth staircase was climbed, the k+1 st staircase was climbed q Therefore, P(k) is true, so Discrete Mathematical Structures: Theory and Applications 35

Mathematical Deduction Discrete Mathematical Structures: Theory and Applications 36

Mathematical Deduction Discrete Mathematical Structures: Theory and Applications 36

Mathematical Deduction q Preconditions and Postconditions q. User of algorithm need not be concerned

Mathematical Deduction q Preconditions and Postconditions q. User of algorithm need not be concerned with how the algorithm is implemented q. He or she must know how to use the algorithm and what the algorithm does q. Precondition q. Assertion (set of statements) that remains true before algorithm executes q. Postcondition q. Assertion that is true after algorithm executes Discrete Mathematical Structures: Theory and Applications 37

Mathematical Deduction q Loop Invariant q Set of statements that remains true each time

Mathematical Deduction q Loop Invariant q Set of statements that remains true each time the loop body is executed q Example: the syntax of a while loop is: while boolean. Expression do loop. Body q The boolean. Expression is evaluated. If the boolean. Expression evaluates to true , the loop. Body executes. After executing the loop. Body , the boolean. Expression is evaluated again. Then the loop. Body continues to execute as long as the boolean. Expression evaluates to true. Discrete Mathematical Structures: Theory and Applications 38

Mathematical Deduction q Loop Invariant Example (continued) q. The boolean. Expression is either true

Mathematical Deduction q Loop Invariant Example (continued) q. The boolean. Expression is either true or false. It is a statement. q. Let q denote the boolean. Expression Discrete Mathematical Structures: Theory and Applications 39

Mathematical Deduction q We can associate a predicate, P(n). The predicate P(n) is such

Mathematical Deduction q We can associate a predicate, P(n). The predicate P(n) is such that: Discrete Mathematical Structures: Theory and Applications 40

Prime Numbers q For any positive integer n > 1, the integers 1 and

Prime Numbers q For any positive integer n > 1, the integers 1 and n are called the trivial positive divisors of n q An integer n > 1 is a prime integer if and only if n has only trivial positive divisors q An integer n > 1 is a composite integer if and only if n has a nontrivial positive divisor Discrete Mathematical Structures: Theory and Applications 41

Prime Numbers Discrete Mathematical Structures: Theory and Applications 42

Prime Numbers Discrete Mathematical Structures: Theory and Applications 42

Prime Numbers Discrete Mathematical Structures: Theory and Applications 43

Prime Numbers Discrete Mathematical Structures: Theory and Applications 43

Prime Numbers Example: Consider the integer 131. Observe that 2 does not divide 131.

Prime Numbers Example: Consider the integer 131. Observe that 2 does not divide 131. We now find all odd primes p such that p 2 131. These primes are 3, 5, 7, and 11. Now none of 3, 5, 7, and 11 divides 131. Hence, 131 is a prime. Discrete Mathematical Structures: Theory and Applications 44

Prime Numbers Discrete Mathematical Structures: Theory and Applications 45

Prime Numbers Discrete Mathematical Structures: Theory and Applications 45

Prime Numbers q Factoring a Positive Integer q. The standard factorization of n Discrete

Prime Numbers q Factoring a Positive Integer q. The standard factorization of n Discrete Mathematical Structures: Theory and Applications 46

Prime Numbers q Fermat’s Factoring Method Discrete Mathematical Structures: Theory and Applications 47

Prime Numbers q Fermat’s Factoring Method Discrete Mathematical Structures: Theory and Applications 47

Prime Numbers q Fermat’s Factoring Method Discrete Mathematical Structures: Theory and Applications 48

Prime Numbers q Fermat’s Factoring Method Discrete Mathematical Structures: Theory and Applications 48

Linear Diophantine Equations q Diophantine equation: Algebraic equation in one or more unknowns with

Linear Diophantine Equations q Diophantine equation: Algebraic equation in one or more unknowns with integer coefficients for which integer solutions are sought q Such an equation may have no solution, a finite number of solutions, or an infinite number of solutions q The famous equation xn +yn = zn of Fermat’s Last Theorem is also a Diophantine equation Discrete Mathematical Structures: Theory and Applications 49

Linear Diophantine Equations Discrete Mathematical Structures: Theory and Applications 50

Linear Diophantine Equations Discrete Mathematical Structures: Theory and Applications 50

Linear Diophantine Equations Discrete Mathematical Structures: Theory and Applications 51

Linear Diophantine Equations Discrete Mathematical Structures: Theory and Applications 51