0% found this document useful (0 votes)
103 views25 pages

Advanced Algorithms Analysis and Design: by Dr. Nazir Ahmad Zafar

This document discusses mathematical induction, which is a method for proving statements about natural numbers. It covers: 1) The basic steps of mathematical induction, including proving the base case, forming the induction hypothesis, and proving the induction step. 2) Examples of using induction to prove statements like inequalities and sums. 3) Strong mathematical induction, which involves proving a statement is true for all natural numbers greater than or equal to some fixed number b, rather than just 1.

Uploaded by

aamir ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views25 pages

Advanced Algorithms Analysis and Design: by Dr. Nazir Ahmad Zafar

This document discusses mathematical induction, which is a method for proving statements about natural numbers. It covers: 1) The basic steps of mathematical induction, including proving the base case, forming the induction hypothesis, and proving the induction step. 2) Examples of using induction to prove statements like inequalities and sums. 3) Strong mathematical induction, which involves proving a statement is true for all natural numbers greater than or equal to some fixed number b, rather than just 1.

Uploaded by

aamir ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Advanced Algorithms Analysis

and Design

By

Dr. Nazir Ahmad Zafar

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Lecture No 4

Mathematical Induction

(Proving, Validation and Verification etc.)

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


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

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


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.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
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
1. P(n0) is true.
2. 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

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Steps in Proving by Induction
Claim: P(n) is true for all n  Z+, for n  n0
1. Basis
– Show formula is true when n = n0
2. Inductive hypothesis
– Assume formula is true for an arbitrary n = k
where, k  Z+ and k  n0
3. To Prove Claim
– Show that formula is then true for k+1
Note: In fact we have to prove
1) P(n0) and
2) P(k)  P(k+1)
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
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)

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


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
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
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)

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


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.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Proof by Induction
Example 1
• Prove that n2  n + 100  n  11
Solution
Let P(n)  n2  n + 100  n  11
1. P(11)  112  11 + 100  121  111, true
2. Suppose predicate is true for n = k, i.e.
P(k)  k2  k + 100, true k  11
3. Now it can be proved that
P(k+1)  (k+1)2  (k+1) + 100,
 k2 + 2k +1  k +1 + 100  k2 + k  100 (by 1 and 2)
Hence P(k)  P(K+1)
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
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

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Another Easy Example
Example 2 Reasoning of Proof
Use Mathematical Induction to prove that sum of the
first n odd positive integers is n2.
Proof
n
• Let P(n) denote the proposition that  (2i  1)  n 2
i 1
• Basis step : P(1) is true , since 1 = 1 2

• Inductive step : Let P(k) is true for a positive integer k,


i.e., 1+3+5+…+(2k-1) = k2
• Note that: 1+3+5+…+(2k-1)+(2k+1) = k2+2k+1= (k+1)2
∴ P(k+1) true, by induction, P(n) is true for all n  Z+
n n
Another Proof  ( 2i  1)  2  i  n  n ( n  1)  n n 2

i 1 i 1

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Proving Inequalities
Example 3 Reasoning of Proof
• 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+.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Example 4: Harmonic Numbers
The harmonic numbers Hk, k = 1, 2, 3, …, are
defined by H  1  1  1  ...  1
k
2 3 k
n
Use mathematical induction to show that H 2n  1 
2
whenever n is a nonnegative integer.
Proof
Let P(n) be the proposition that H 2n  1  n / 2
Basis step :
P(0) is true, since, H 20  H1  1  1  0 / 2  1
Inductive step
Assume that P(k) is true for some k, H 2k  1  k / 2
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Example 4: Harmonic Numbers
Now consider
1 1 1 1 1 1
H 2k 1  1   k  k  k    k 1
2 3 2 2 1 2  2 2  2k  2k
1 1 1
 H 2k  k  k    k 1
2 1 2  2 2
k 1 1 1
 (1  )  k  k    k 1
2 2 1 2  2 2
k 1 1 1
 (1  )  k  k  k
2 2 2 k
2 2 k
2  2k
k 2k k 1 k 1
 (1  )  k k  1   1
2 2 2 2 2 2
∴P(k+1) is true.
Hence the statement is true for all n  Z+.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Induction Examples (4/4) 3.3 Mathematical Inducti

Strong Mathematical Induction

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


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

• 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.

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Example
Induction 1: (4/4)
Examples Divisibility by a Prime 3.3 Mathematical Inducti
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 .

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Example
Induction 1: (4/4)
Examples Divisibility by a Prime 3.3 Mathematical Inducti
• 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.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Example 2: Another Example in Number Theory
If n  Z, n >1, then n can be written as product of primes.

Proof :
Let P(n)  n can be written as the product of primes.
Basis : P(2) is true, since 2 is the first prime number
Inductive : Assume that the statement is true for n = k, i.e.
P(2), P(3), …, P(k) can be written as product of primes.
Prove that: true for n = k, i.e. P(k + 1) is product of
primes.
Case 1 : k + 1 is prime, then nothing to prove
Case 2 : k + 1 is composite, then
k + 1 = xy, where 2  x  y < k+1
Inductive hypothesis, a and b are product of primes.
Hence
Dr Nazir A. Zafar P(k+1) can be written as product of primes.
Advanced Algorithms Analysis and Design
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 = 1.3 + 1.5
9 = 3.3
10 = 2.5
11 = 2.3 + 1.5
12 = 4.3
Now we generalize it?
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
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.

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


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) + 1 + 5
k + 1= 3.(m + 2) + 5.(n - 1), m  2 and n  0

Hence the statement is true for n = k + 1

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


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) + 9 + 1
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

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design

You might also like