Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Structures Chapter 2 Part B Mathematical Induction

Similar presentations


Presentation on theme: "Discrete Structures Chapter 2 Part B Mathematical Induction"— Presentation transcript:

1 Discrete Structures Chapter 2 Part B Mathematical Induction
Nurul Amelina Nasharuddin Multimedia Department

2 Mathematical Induction
Use to verify a property of a sequence Used to check the conclusions about the outcomes of processes that occur repeatedly and according to definite patterns

3 Mathematical Induction
Eg: Any whole number of cents of at least 8 cents can be obtained using 3 cents and 5 cents coins Formally: For all integers n  8, P(n) is true where P(n) = “n cents can be obtained using 3 cents and 5 cents coins” (1) If k cents is obtained using at least one 5 cents coin, then replace the coin with two 3 cents coins = (k+1) cents (2) If k cents is obtained without using a 5 cents coin, then replace at least three 3 cents coins with two 5 cents coins = (k+1) cents To show that P(n) is true for all integers n  8, (1) show P(8) is true (2) show that the truth of P(k+1) follows necessarily from the truth of P(k) for each k  8

4 Principle of Mathematical Induction
Let P(n) be a predicate that is defined for integers n and let a be some integer. If the following two premises are true: P(a) is a true k  a, P(k)  P(k + 1) then the following conclusion is true as well P(n) is true for all n  a

5 Method of Proof by Mathematical Induction
Consider a statement of the form, “For all integers n  a, a property P(n) is true” To prove such statement, perform these 2 steps: Step 1 (basis step): Show that when n = a, statement is true Step 2 (inductive step): Show that for all integers k  a, if the property is true for n = k then it is true for n = k+1. To perform this step, Suppose that the property is true for n = k, where k  a [This supposition is called the induction hypothesis] Then Show that the property is true for n = k+1

6 Coins Proofing P(n): n cents can be obtained using 3c and 5c coins.” P(n) is true for all integers n  8. Proof: Step 1: The property is true for n = 8 because 8c = 3c + 5c. Step 2: Suppose kc can be obtained using 3c and 5c for some integer k  8. [Induction hypothesis]. We must show that (k+1)c can be obtained using 3c and 5c. (1) In case there is a 5c coin among the kc, replace it by two 3c coins = (k+1) cents (2) In case there is no 5c coin, replace three 3c coins by two 5c coins = (k+1) cents Thus in either case (k+1)c can be obtained using 3c and 5c coins (PROVED!!)

7 Applications of Mathematical Induction
Show that … + n = (n * (n + 1)) / 2 Sum of geometric series: r0 + r1 + … + rn = (rn+1 – 1) / (r – 1)

8 Sum of the First n Integers
Show that … + n = (n * (n + 1)) / 2 for all integers n  1 P(n): … + n = (n * (n + 1)) / 2 Step 1: Show that the property is true for n=1 (LHS) 1 = (1 * (1 + 1)) /2 = 1 (RHS) The property true for n=1 Step 2 : Show that for all integers k  1, if the property is true for n = k then it is true for n = k+1 Suppose … + k = (k * (k + 1)) / 2, for some integer k  1 (induction hypothesis)

9 Sum of the First n Integers (2)
We must show that … + (k+1) = (k+1)((k + 1)+1) /2, or equivalently that … + (k+1) = (k+1)(k + 2) /2 (show that LHS equals the RHS) … + (k+1) = … + k +(k+1) = (k * (k + 1)) / 2 + (k+1) (by substitution from the inductive hypothesis) = (k * (k + 1)) / 2 + 2(k + 1) / 2 = [(k+1)(k+2)] / 2 LHS = RHS Consequently, by the Principle of Mathematical Induction, P(n) is true for all n  1

10 Sum of a Geometric Sequence
For any real number r except 1, and any integer n  0, P(n): Step 1: Show that the property is true for n=0: (LHS) (RHS) The property true for n=0

11 Sum of a Geometric Sequence (2)
Step 2 : Show that for all integers k  0, if the property is true for n = k then it is true for n = k+1 Suppose , for k  0 (induction hypothesis) We must show that the property is true for (show that LHS equals the RHS) LHS = RHS Consequently, the theorem is true

12 Proving the Divisibility Property
For all integers n  1, 22n – 1 is divisible by 3 P(n): 22n – 1 is divisible by 3 Step 1: Show that the property is true for n=1 22(1) – 1 = 22 – 1 = 3 is divisible by 3 The property true for n=1 Step 2 : Show that for all integers k  1, if the property is true for n = k then it is true for n = k+1 Suppose 22k – 1 is divisible by 3, for some integer k  1 (induction hypothesis)

13 Proving the Divisibility Property (2)
By definition of divisibility, this means that 22k – 1 = 3r, for some integer r. We must show that the 22(k+1) – 1 is divisible by 3. 22(k+1) – 1 = 22k+2 – 1 = 22k . 22 – 1 = 22k . 4 – 1 = 22k . (3 + 1) – 1 = 22k k – 1 = 22k r = 3(22k + r) 22k + r is an integer because it is a sum of products of integers. Consequently, the theorem is true

14 Proving an Inequality For all integers n  3, 2n + 1  2n
P(n): 2n + 1  2n Step 1: Show that the property is true for n=3 2n + 1 = 2(3) + 1 = 7  2n = 23 = 8 The property true for n=3 Step 2 : Show that for all integers k  3, if the property is true for n = k then it is true for n = k+1 Suppose 2k + 1  2k, for some integer k  3 (induction hypothesis)

15 Proving an Inequality (2)
We must show that 2(k+1) + 1  2(k+1) or equivalently, 2k+3  2k+1 2k+3 = (2k+1) +2  2k + 2 2k+3 = (2k+1) +2  2k + 2k 2  2k for all integers k 2k + 3  2(2k) = 2k+1 Consequently, the 2n + 1  2n for all integers n  3

16 Proving a Property of A Sequence
Define a sequence a1, a2, a3, …, as follows a1 = 2 ak = 5ak-1 Write the first four sequence a1 = 2 a2 = 5a1 = 5.2 = 10 a3 = 5a2 = 5.10 = 50 a4 = 5a3 = 5.50 = 250 Proof an = 2 . 5n-1 for all integers n  1 Step 1: Show that the property is true for n=1 = = 2 = a1 The property true for n=1

17 Proving a Property of A Sequence (2)
Step 2 : Show that for all integers k  1, if the property is true for n = k then it is true for n = k+1 Suppose ak = 2 . 5k-1 for all integers k  1(induction hypothesis) We must show that ak+1 = 2 . 5(k+1)-1 = 2 . 5k ak+1 = 5a(k+1)-1 = 5ak = 5 . (2 . 5k-1) = 2 . (5 . 5k-1) = 2 . 5k Consequently, the an = 2 . 5n-1 for all integers n  1

18 Exercises Show that 22n – 1 is divisible by 3
Show that for n > 2: 2n + 1 < 2n Show that xn – yn is divisible by x – y Show that n3 – n is divisible by 6 On the outside rim of a circular disk the integers from 1 to 30 are painted in random. Show that there must be three successive integers whose sum is at least 45

19 Principle of Strong Mathematical Induction
Basis step may contains proofs for several initial values In inductive step the truth of the predicate P(n) is assumed for all values through k-1, then the truth of P(k) is proved. Let P(n) be a predicate that is defined for integers n and let a and b be fixed integers with a  b. Suppose the following two premises are true: P(a), P(a+1), P(a+2), …, and P(b) are true (basis step) For any integer k  b, if P(i) is true for all integers i with a  i  k, then P(k) is true (inductive step) then the following conclusion is true as well P(n) is true for all n  a

20 Applying Strong Mathematical Induction
Prove that any integer greater than 1 is divisible by a prime number P(n): n is divisible by a prime number where n  2 Step 1: Show that the property is true for n=2 The property is true for n=2 because 2 is a prime number and 2 is divisible by 2 Step 2: Show that for all integers k  2, if the property true for all i with 2  i  k, then it is true for k For all integers i with 2  i  k, i is divisible by a prime number. (induction hypothesis)

21 Applying Strong Mathematical Induction (2)
Either k is a prime or not. If k is a prime, k is divisible by a prime number, namely itself. If k is not a prime, then k = ab, where a and b are integers with 2  a  k and 2  b  k. By inductive hypothesis, a is divisible by a prime number p, and so by transitivity of divisibility (pg151), k is also divisible by p.  Hence regardless of whether k is a prime or not, k is divisible by a prime number

22 Divisibility (pg 148) Integer n is divisible by an integer d, when
k  Z, n = d * k, for some integer k Notation: d | n Synonymous statements: n is a multiple of d d is a factor of n d is a divisor of n d divides n Eg: If a and b are integers, is 3a + 3b divisible by 3? Yes. By distributive law, 3a + 3b = 3(a+b) and a+b is an integer because it is a sum of 2 integers

23 Divisibility (pg 148) Divisibility is transitive: for all integers a, b, c, if a divides b and b divides c, then a divides c We need to show a | c or in other words c = a*k (k is some integer) a | b or b = a*r; and b | c or c = b*s (r and s are some integers) c = b*s =(a*r)*s =a(rs) Let k = rs, therefore a divides c by definition of divisibility

24 Exercises Prove or provide counterexample:
For integers a, b, c: (a | b)  (a | bc) For integers a, b, c: (a | (b + c))  (a | b  a | c) If 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * m = 151 * 150 * 149 * 148 * 147 * 146 * 145 * 144 * 143, does 151 | m? Show that an integer is divisible by 9 iff the sum of its digits is divisible by 9. Prove the same for divisibility by 3. Show that an integer is divisible by 11 iff the alternate sum of its digits is divisible by 11

25 Fundamental Theorem of Arithmetic (pg 153)
Given any integer n  1, the standard factored form of n, is an expression of the form where k is a positive integer; p1, p2, …, pk are prime numbers; e1, e2, …, ek are positive integers; and p1  p2  pk Eg: Write 3300 in standard factored form 3300= 2(1650) =22(825) =2231(275) = (11) =

26 Fundamental Theorem of Arithmetic (pg 153)
Number of positive divisors of n are (e1 + 1)(e2 + 1)…(ek + 1) Eg: 29, 338, 848,000 = ∴ 29,338,848,000 has (8 + 1)(5 + 1)(3 + 1)(3 + 1)(1 + 1) = (9) (6) (4) (4) (2) = 1728 positive divisors.

27 The Division Algorithm (pg 190)
For an integer a and a positive integer d, then there exists integers q and r such that a = dq + r and 0  r  d In quotient-remainder theorem, q=quotient and r=remainder Eg: Find the q and r of the division of 32 by 9 The q represents how many number 9’s contained in 32 The r is the number left over when all possible groups of 9 are subtracted 32 – 9 = 23  9, and 23 – 9 = 14  9, and 14 – 9 = 5  9 This shows that 3 groups of 9 can be subtracted from 32 with 5 leftover. Thus, q=3 and r=5

28 The Greatest Common Divisor The Euclidean Algorithm (pg 192)
gcd of 2 integers a and b is the largest integers that divides both a and b (gcd of 12 and 30 is 6) Euclidean algorithm: An efficient way to compute the gcd for 2 integers Let a and b be integers that are not 0. The gcd(a, b) is that integer d with the following properties: d is a common divisor for both a and b or d|a and d|b For all integers c, if c|a and c|b, then c  d.

29 The Greatest Common Divisor The Euclidean Algorithm (pg 192)
Lemma 1: if r is a positive integer, then gcd(r, 0) = r Lemma 2: if a = bq + r, then gcd(a, b) = gcd(b, r) So if a, b are 2 positive integers, division algorithm is apply as a = q1b + r1, 0  r1  b b = q2r1 + r2, 0  r2  r1 r1 = q3r2 + r3, 0  r3  r2 ri = qi+2ri+1 + ri+2, 0  ri+2 + ri+1 ... rk-3 = qk-1rk-2 + rk-1, 0 < rk-1 < rk-2 rk-2 = qkrk-1 + rk, 0 < rk < rk-1 rk-1 = qk+1rk Then, rk , the last nonzero remainder , equals gcd(a, b)

30 Examples Using Euclidean algo, find gcd(330, 156) 330 = 156*2 + 18
156 = 18*8 +12 18 = 12*1 + 6 12 = 6*2 gcd(330, 156) = 6 Find gcd(250, 111)

31 Least Common Multiple For a, b, c  Z+, c is called a common multiple of a, b if c is a multiple of both a and b. Furthermore, c is the least common multiple of a, b if it is the smallest of all positive integers. We denote c by lcm(a, b).

32 Examples Eg: 12 = 34 lcm(3, 4) = lcm (4, 3) = 12
Eg: lcm(6, 15) = 30 not 90 For all n  Z+, we find that lcm(1, n) = lcm(n, 1) = n. When a, n  Z+, we have lcm(a, na) = na. If a, m, n  Z+ with m ≤ n, then lcm(am, an) = an. [And gcd(am, an) = am].

33 Least Common Multiple Theorem: Let a, b, c  Z+, with c = lcm(a, b). If d is a common multiple of a and b, then c|d. Theorem: For all a, b  Z+, ab = lcm(a, b)  gcd(a, b). Eg: gcd(250, 111) = 1. As a result we find that lcm(250, 111) = (250)(111) / 1 = 27,750 Eg: For all a, b  Z+, if a, b are relatively prime, then lcm(a, b) = ab. Eg: gcd(456, 624) = 24. lcm(456, 624) = (456)(624) / 24 = 11,856.

34 GCD and LCM If m, n  Z+, let and
with each pi prime and 0 ≤ ei and 0 ≤ fi for all 1 ≤ i ≤ t. Then if ai = min{ei, fi}, the minimum (or smaller) of ei and, fi and bi = max { ei, fi }, the maximum (or larger) of ei and fi, for all 1 ≤ i ≤ t, we have

35 GCD and LCM Eg: Let m = 491,891,400 = 23 33 52 72 111 132 and
Then with p1 = 2, p2 = 3, p3 = 5, p4 = 7, p5 = 11, p6 = 13, and p7 = 17, we find a1 = 2, a2 = 2, a3 = 0 (the exponent of 5 in the prime factorization of n must be 0, because 5 does not appear in the prime factorization), a4 = 1, a5 = 1, a6 = 2, and a7 = 0. So gcd(m, n) = = 468,468. We also have lcm(m, n) = = 1,195,787,993,400.

36 Correctness of Algorithms
Assertions Pre-condition is a predicate describing initial state before an algorithm is executed Post-condition is a predicate describing final state after an algorithm is executed Loop guard Loop is defined as correct with respect to its pre- and post- conditions, if whenever the algorithm variables satisfy the pre-conditions and the loop is executed, then the algorithm satisfies the post-conditions as well

37 Loop Invariant Theorem
Let a while loop with guard G be given together with its pre- and post- conditions. Let predicate I(n) describing loop invariant be given. If the following 4 properties hold, then the loop is correct: Basis Property: I(0) is true before the first iteration of the loop Inductive Property: If G and I(k) is true, then I(k + 1) is true Eventual Falsity of the Guard: After finite number of iterations, G becomes false Correctness of the Post-condition: If N is the least number of iterations after which G becomes false and I(N) is true, then post-conditions are true as well

38 Correctness of Some Algorithms
Product Algorithm: pre-conditions: m  0, i = 0, product = 0 while (i < m) { product += x; i++; } post-condition: product = m * x

39 Correctness of Some Algorithms
Division Algorithm pre-conditions: a  0, d > 0, r = a, q = 0 while (r  d) { r -= d; q++; } post-conditions: a = q * d + r, 0  r < d

40 Correctness of Some Algorithms
Euclidean Algorithm pre-conditions: a > b  0, r = b while (b > 0) { r = a mod b; a = b; b = r; } post-condition: a = gcd(a, b)


Download ppt "Discrete Structures Chapter 2 Part B Mathematical Induction"

Similar presentations


Ads by Google