Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Analysis of Algorithms

Similar presentations


Presentation on theme: "Advanced Analysis of Algorithms"— Presentation transcript:

1

2 Advanced Analysis of Algorithms
By Dr. Muhammad Safyan

3 Lecture No 4. Mathematical Induction
Lecture No Mathematical Induction (Proving, Validation and Verification etc.)

4 Today Covered In this lecture, we will cover the following
What is Mathematical Induction? Why is Mathematical Induction Valid ? Proving problems using Induction Proving hard problems using Induction Strong Mathematical Induction Proving Problems using Strong Induction Conclusion

5 What is Mathematical Induction?
Mathematical induction is a powerful, yet straight-forward method of proving statements whose domain is a subset of the set of integers. Usually, a statement that is proven by induction is based on the set of natural numbers. This statement can often be thought of as a function of a number n, where n = 1, 2, 3,. . . Proof by induction involves three main steps Proving the base of induction Forming the induction hypothesis Proving that the induction hypothesis holds true for all numbers in the domain.

6 What is Mathematical Induction?
Let P(n) be the predicate defined for any positive integers n, and let n0 be a fixed integer. Suppose the following two statements are true P(n0) is true. For any positive integers k, k  n0, if P(k) is true then P(k+1)is true. If both of the above statements are true then the statement:  n  N, such that n  n0, P(n) is also true

7 Steps in Proving by Induction
Claim: P(n) is true for all n  Z+, for n  n0 Basis Show formula is true when n = n0 Inductive hypothesis Assume formula is true for an arbitrary n = k where, k  Z+ and k  n0 To Prove Claim Show that formula is then true for k+1 Note: In fact we have to prove P(n0) and P(k)  P(k+1)

8 Mathematical Way of Expressing Induction
Basis step. Show that proposition P(1) is true. Inductive step. Show that for every positive integer n, the implication P(n)  P(n+1) is true. P(n) for a fixed n is called inductive hypothesis. [P(1)   n, (P(n)  P(n+1))]   n, P(n)

9 Well Ordering and Modus Ponens Principal
Definition (Well-Ordering Principle) The Well-ordering Principle is the following statement   “every nonempty set of positive integers contains a least element”  In a mathematical way we can define this Principle as: there is a in S such that a  b for all b in S i.e.  a  S, such that a  b,  b  S And we say that set S is well-ordered with respect to . Modus Ponens Principal p  q p Hence, q

10 Why Mathematical Induction is Valid?
Let us suppose that P(1) is true, and that n (P(n)  P(n+1)) is also true. Claim: n P(n) is true Assume proposition  n, P(n) is false, i. e, there are some positive integers for which P(n) is false. Let S be the set of those n’s. By well-ordering property, S has a least element, suppose, k. As 1S, so 1< k, so k-1 is a positive Since k-1 < k, hence k-1 S. So P(k-1) is true. By modus ponens, P((k-1) + 1) = P(k) is true. Contradiction, hence n, P(n)

11 Another Reason for Validity?
Basis Step First suppose that we have a proof of P(0). Inductive Hypothesis  k > 0, P(k)  P(k + 1) How it is proved  n > 0? P(0)  P(1) P(1)  P(2) P(2)  P(3) . . . Iterating gives a proof of  n, P(n). This is another way of proving validity of mathematical Induction.

12 Proof by Induction Example 1 Prove that n2  n + 100  n  11 Solution
Let P(n)  n2  n  n  11 P(11)  112   121  111, true Suppose predicate is true for n = k, i.e. P(k)  k2  k + 100, true k  11 Now it can be proved that P(k+1)  (k+1)2  (k+1) + 100, k2 + 2k +1  k  k2 + k  100 (by 1 and 2) Hence P(k)  P(K+1)

13 Validity of Proof Example 1 Prove that n2  n + 100  n  11 Solution
Initially, base case Solution set = {11} By, P(k)  P(K+1)  P(11)  P(12), taking k = 11 Solution set = {11, 12} Similarly, P(12)  P(13), taking k = 12 Solution set = {11, 12, 13} And, P(13)  P(14), taking k = 13 Solution set = {11, 12, 13, 14} And so on

14 Another Easy Example Reasoning of Proof Example 2
Use Mathematical Induction to prove that sum of the first n odd positive integers is n2. Proof Let P(n) denote the proposition that Basis step : P(1) is true , since 1 = 12 Inductive step : Let P(k) is true for a positive integer k, i.e., …+(2k-1) = k2 Note that: …+(2k-1)+(2k+1) = k2+2k+1= (k+1)2 ∴ P(k+1) true, by induction, P(n) is true for all n  Z+ Another Proof

15 Proving Inequalities Reasoning of Proof Example 3
Use mathematical Induction to prove that the inequality n < 2n for all n  Z+ Proof Let P(n) be the proposition that n < 2n Basis step : P(1) is true since 1 < 21 . Inductive step : Assume that P(n) is true for a positive integer n = k, i.e., k < 2k. Now consider for P(k+1) : Since, k + 1 < 2k + 1  2k + 2k = 2.2k = 2k + 1 ∴ P(k+1) is true. It proves that P(n) is true for all n  Z+.

16 Example 4: Harmonic Numbers
The harmonic numbers Hk, k = 1, 2, 3, …, are defined by Use mathematical induction to show that whenever n is a nonnegative integer. Proof Let P(n) be the proposition that Basis step : P(0) is true, since, Inductive step Assume that P(k) is true for some k,

17 Example 4: Harmonic Numbers
Now consider ∴P(k+1) is true. Hence the statement is true for all n  Z+.

18 Strong Mathematical Induction
Induction Examples (4/4) 3.3 Mathematical Induction Strong Mathematical Induction

19 Strong Mathematical Induction
Induction Examples (4/4) 3.3 Mathematical Induction Let P(n) be a predicate defined for integers n, and a and b are fixed integers with a ≤ b. Suppose the following statements are true: 1. P(a), P(a + 1), … , P(b) are all true (basis step) 2. 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 P(n) is true for all integers n ≥ a.

20 Example 1: Divisibility by a Prime
Induction Examples (4/4) 3.3 Mathematical Induction Theorem: For any integer n ≥ 2, n is divisible by a prime. Proof (by strong mathematical induction): Basis step: The statement is true for n = 2. This is because 2 | 2 and 2 is a prime number. Inductive step: Assume the statement is true for all i with 2 ≤ i <k (inductive hypothesis) ; To show that it is true for k .

21 Example 1: Divisibility by a Prime
Induction Examples (4/4) 3.3 Mathematical Induction We know that  i  Z, with 2 ≤ i < k, P(i), i.e. i is divisible by a prime number. (1) Now we show P(k), i.e., k is divisible by a prime. Take two cases: Case 1: k is prime. Then k is divisible by itself. And nothing to prove Case 2: k is composite. Then k = a·b, where 2 ≤ a <k and 2 ≤ b <k Based on (1), p|a for some prime p. (2) Based on Case 2, a|k (3) By transitivity, p|a and a|k  p|k Thus, P(n) is true by strong induction.

22 Any Amount Limited Coins: More Steps in Basis
Statement Show that any amount in cents ≥ 8 cents can be obtained using 3 cents and 5 cents coins only. Proof We have to prove that, amount = 3.m + 5.n, m  0, n  0 Basis Step This time check for a five particular values: 8 = 9 = 3.3 10 = 2.5 11 = 12 = 4.3 Now we generalize it?

23 Any Amount Limited Coins : More Steps in Basis
Let P(n) be the statement that: “n cents can be obtained using 3 and 5 cents”. Inductive Hypothesis We want to show that P(k) is true  P(k+1),  k ≥ 8 There are two cases now Case 1 P(k) is true and k cents contain at least one 5 coin. Case 2 P(k) true, k cents do not contain any coin of 5 cent.

24 Any Amount Limited Coins : More Steps in Basis
Case 1 P(k) is true and k cents contain at least one 5 coin. Since P(k) is true k  8 Hence k can be expressed as k = 3.m + 5.n m  0 and n  1 k + 1= 3.m + 5.n + 1 k + 1= 3.m + 5.(n - 1) k + 1= 3.(m + 2) + 5.(n - 1), m  2 and n  0 Hence the statement is true for n = k + 1

25 Any Amount Limited Coins : More Steps in Basis
Case 2 P(k) is true and k cents do not contain any coin of 5 cent. for k  8 Hence k can be expressed as k = 3.m m  3 k + 1= 3.(m – 3) k + 1= 3.(m – 3) + 2.5 k + 1= 3.m’ + 5.n m’  0 and n = 2 Hence the statement is true for n = k + 1 Hence P(k + 1) is true

26 Postage Ticket: Again More Steps in Basis
Prove that postage ticket of amount  12 cents can be formed using only 4 cent and 5 cent stamps. Proof Let P(n)  n cents can be formed using only 4 and 5 cent P(n)  n = 4s + 5t s  0, and t  0  n  12 Basis : P(12) is true, since 12 = 4  3; P(13) is true, since 13 = 4   1; P(14) is true, since 14 = 4   2; P(15) is true, since 15 = 5  3; Inductive : Assume P(12), P(13), …, P(k) are true. Now prove for P(k + 1) Suppose k-3 = 4  s + 5  t. Then k +1 = 4  (s + 1) + 5  t. true for n = k + 1. By Strong Induction, P(n) is true if n  Z and n 12. (k-3  12)

27 Proving a Property of a Sequence
Induction Examples (4/4) 3.3 Mathematical Induction Proposition: Suppose a0, a1, a2, … is defined as follows: a0 = 1, a1 = 2, a2 = 3, ak = ak-1 + ak-2 + ak-3 for all integers k ≥ 3. Then an ≤ 2n for all integers n≥ P(n) Proof (by strong induction) Basis step: The statement is true for n = 0: a0 = 1 ≤ 1 = 20 P(0) for n = 1: a1 = 2 ≤ 2 = P(1) for n = 2: a2 = 3 ≤ 4 = P(2)

28 Proving a Property of a Sequence
Induction Examples (4/4) 3.3 Mathematical Induction Inductive step: For any k > 2, assume P(i) is true for all i with 0 ≤ i < k, i.e., ai ≤ 2i for all 0 ≤ i < k (1) Show that P(k) is true: ak ≤ 2k (2) Now consider ak = ak-1 + ak-2 + ak-3 ≤ 2k-1 + 2k-2 + 2k-3 based on (1) ≤ … + 2k-3 + 2k-2 + 2k-1 = 2k - 1 ≤ 2k Thus, P(n) is true by strong mathematical induction. Hence it proves the result


Download ppt "Advanced Analysis of Algorithms"

Similar presentations


Ads by Google