Induction: One Step At A Time
description
Transcript of Induction: One Step At A Time
![Page 1: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/1.jpg)
Induction: One Step At A Time
Great Theoretical Ideas In Computer Science
Steven Rudich
CS 15-251 Spring 2005
Lecture 1 Jan 11, 2005 Carnegie Mellon University
![Page 2: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/2.jpg)
Today we will
talk about
INDUCTION
![Page 3: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/3.jpg)
Induction is the primary way we:
1.Prove theorems
2.Construct and define objects
![Page 4: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/4.jpg)
Let’s start with dominoes
![Page 5: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/5.jpg)
Domino Principle: Line up any number of dominos in a row; knock the first one over and
they will all fall.
![Page 6: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/6.jpg)
n dominoes numbered 1 to n
Fk ´ The kth domino falls
If we set them all up in a row then we know that each one is set up to knock over the next one:
For all 1 ≤ k < n:Fk ) Fk+1
![Page 7: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/7.jpg)
n dominoes numbered 1 to n
Fk ´ The kth domino falls
For all 1 ≤ k < n:Fk ) Fk+1
F1 ) F2 ) F3 ) …
F1 ) All Dominoes Fall
![Page 8: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/8.jpg)
Computer Scientists don’t start numbering things at 1, they start at 0.
YOU will spend a career doing this, so GET USED TO IT NOW.
![Page 9: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/9.jpg)
n dominoes numbered 0 to n-1
Fk ´ The kth domino falls
For all 0 ≤ k < n-1:Fk ) Fk+1
F0 ) F1 ) F2 ) …
F0 ) All Dominoes Fall
![Page 10: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/10.jpg)
Standard Notation/Abbreviation“for all” is written “8”
Example:
For all k>0, P(k)is equivalent to
8 k>0, P(k)
![Page 11: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/11.jpg)
n dominoes numbered 0 to n-1
Fk ´ The kth domino falls
8 k, 0 ≤ k < n-1:Fk ) Fk+1
F0 ) F1 ) F2 ) …
F0 ) All Dominoes Fall
![Page 12: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/12.jpg)
The Natural Numbers
= { 0, 1, 2, 3, . . .}
![Page 13: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/13.jpg)
The Natural Numbers
= { 0, 1, 2, 3, . . .}
One domino for each natural number:
0 1 2 3 4 5 ….
![Page 14: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/14.jpg)
The Infinite Domino Principle Fk ´ The kth domino falls
Suppose F0
Suppose for each natural number k,Fk ) Fk+1
Then All Dominoes Fall!
F0 ) F1 ) F2 ) …
![Page 15: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/15.jpg)
The Infinite Domino Principle Fk ´ The kth domino falls
Suppose F0
Suppose for each natural number k,Fk ) Fk+1
Then All Dominoes Fall!
Proof: If they do not all fall, there must be a least numbered domino d>0 that did not fall. Hence, Fd-1 and not Fd . Fd-1 ) Fd. Hence, domino d fell and did not fall. Contradiction.
![Page 16: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/16.jpg)
Mathematical Induction: statements proved instead of
dominoes fallen
Infinite sequence of statements: S0, S1, …Fk ´ Sk proved
Infinite sequence ofdominoes.Fk ´ domino k falls
Establish 1) F0
2) 8 k, Fk ) Fk+1
Conclude that Fk is true for all k
![Page 17: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/17.jpg)
Inductive Proof / ReasoningTo Prove k, Sk
Establish “Base Case”: S0
Establish “Domino Property”: k, Sk ) Sk+1
Assume hypothetically that Sk for any particular k;
Conclude that Sk+1
k, Sk ) Sk+1
![Page 18: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/18.jpg)
Inductive Proof / ReasoningTo Prove k, Sk
“Induction Hypothesis” Sk
Use I.H. to show Sk+1
k, Sk ) Sk+1
Establish “Base Case”: S0
Establish “Domino Property”: k, Sk ) Sk+1
![Page 19: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/19.jpg)
Inductive Proof / ReasoningTo Prove k¸b, Sk
Establish “Base Case”: Sb
Establish “Domino Property”: k¸b, Sk ) Sk+1
Assume k¸ b
Assume “Inductive Hypothesis”: Sk
Prove that Sk+1 follows
![Page 20: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/20.jpg)
Theorem?
The sum of the first n odd numbers is n2.
![Page 21: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/21.jpg)
Theorem? The sum of the first n odd numbers is n2.
CHECK IT OUT ON SMALL VALUES:1 = 11+3 = 41+3+5 = 91+3+5+7 = 16
![Page 22: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/22.jpg)
Theorem: The sum of the first n odd numbers is n2. The kth odd number is expressed by the formula (2k – 1), when k>0.
![Page 23: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/23.jpg)
Sn “The sum of the first n odd numbers is n2.” Equivalently, Sn is the statement that:1· k· n (2k-1)=1 + 3 + 5 + (2k-1) + . . +(2n-1)= n2
![Page 24: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/24.jpg)
Sn “The sum of the first n odd numbers is n2.”
“1 + 3 + 5 + (2k-1) + . . +(2n-1)= n2”
Trying to establish that: 8n¸1 Sn
Base case: S1 is true
The sum of the first 1 odd numbers is 1.
![Page 25: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/25.jpg)
Sn “The sum of the first n odd numbers is n2.”
“1 + 3 + 5 + (2k-1) + . . +(2n-1)= n2”
Trying to establish that: 8n¸1 Sn
Assume “Induction Hypothesis”: Sk (for any particular k¸ 1) 1+3+5+…+ (2k-1) = k2
![Page 26: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/26.jpg)
Sn “The sum of the first n odd numbers is n2.”
“1 + 3 + 5 + (2k-1) + . . +(2n-1)= n2”
Trying to establish that: 8n¸1 Sn
Assume “Induction Hypothesis”: Sk (for any particular k¸ 1) 1+3+5+…+ (2k-1) = k2
Add (2k+1) to both sides.1+3+5+…+ (2k-1)+(2k+1) = k2 +(2k+1) Sum of first k+1 odd numbers = (k+1)2
CONCLUSE: Sk+1
![Page 27: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/27.jpg)
Sn “The sum of the first n odd numbers is n2.”
“1 + 3 + 5 + (2k-1) + . . +(2n-1)= n2”
Trying to establish that: 8n¸1 Sn
Established base case: S1
Established domino property: 8 k¸ 1 Sk ) Sk+1
By induction of n, we conclude that:8n¸1 Sn
![Page 28: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/28.jpg)
THEOREM:
The sum of the first n odd numbers is n2.
![Page 29: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/29.jpg)
Theorem?
The sum of the first n numbers is ½n(n+1).
![Page 30: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/30.jpg)
Theorem? The sum of the first n numbers is ½n(n+1).
Try it out on small numbers!
1 = 1 = =½ 1(1+1).
1+2 = 3 =½ 2(2+1).
1+2+3 = 6 =½ 3(3+1).
1+2+3+4 = 10=½ 4(4+1).
![Page 31: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/31.jpg)
Theorem? The sum of the first n numbers is ½n(n+1).
= 0 = =½ 0(0+1).
1 = 1 = =½ 1(1+1).
1+2 = 3 =½ 2(2+1).
1+2+3 = 6 =½ 3(3+1).
1+2+3+4 = 10=½ 4(4+1).
![Page 32: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/32.jpg)
Notation:
0= 0
n= 1 + 2 + 3 + . . . + n-1 + n
Let Sn ´
“n =n(n+1)/2”
![Page 33: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/33.jpg)
Sn ´ “n =n(n+1)/2”Use induction to prove k¸0, Sk
Establish “Base Case”: S0. 0=The sum of the first 0 numbers = 0. Setting n=0 the formula gives 0(0+1)/2 = 0.
Establish “Domino Property”: k¸0, Sk ) Sk+1
“Inductive Hypothesis” Sk: k =k(k+1)/2
k+1 = k + (k+1)
= k(k+1)/2 + (k+1) [Using I.H.]
= (k+1)(k+2)/2 [which proves Sk+1]
![Page 34: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/34.jpg)
THEOREM:
The sum of the first n numbers is ½n(n+1).
![Page 35: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/35.jpg)
A natural number n>1 is prime if it has no divisors besides 1 and itself.
N.B. 1 is not considered prime.
![Page 36: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/36.jpg)
Easy theorem:Every natural number>1 can be factored into primes.
N.B.:It is much more subtle to argue for the existence of a unique prime factorization
![Page 37: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/37.jpg)
Easy theorem:Every natural number>1 can be factored into primes.Sn “n can be factored into primes”
S2 is true because 2 is prime.
![Page 38: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/38.jpg)
Every natural number>1 can be factored into primes. Base case: 2
Assume 2,3,…..,k-1 all can be factored into primes.Show k can be factored into primes.
![Page 39: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/39.jpg)
Assume 2,3,…..,k-1 all can be factored into primes.Show k can be factored into primes.
If k is prime, we are done.If not, k= ab where 1<a,b<k, hence a and b can be factored into primes. Thus, k is the product of the factors of a and the factors of b.
![Page 40: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/40.jpg)
This illustrates a technical point
about using and defining
mathematical induction.
![Page 41: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/41.jpg)
All Previous InductionTo Prove k, Sk
Establish “Base Case”: S0
Establish that k, Sk ) Sk+1
Let k be any natural number.Induction Hypothesis:
Assume j<k, Sj
Derive Sk
![Page 42: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/42.jpg)
“Strong” InductionTo Prove k, Sk
Establish “Base Case”: S0
Establish that k, Sk ) Sk+1
Let k be any natural number.
Assume j<k, Sj
Prove Sk
![Page 43: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/43.jpg)
Least Counter-Example Induction to Prove k, Sk
Establish “Base Case”: S0
Establish that k, Sk ) Sk+1
Assume that Sk is the least counter-example.Derive the existence of a smaller counter-example
![Page 44: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/44.jpg)
All numbers > 1 has a prime factorization.
Let n be the least counter-example. n
must not be prime – so n = ab. If both a and b
had prime factorizations, then n
would. Thus either a or b is a smaller counter-
example.
![Page 45: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/45.jpg)
Inductive reasoning is the high level idea:
“Standard” Induction
“Least Counter-example”“All Previous” Induction
all just different packaging.
![Page 46: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/46.jpg)
“All Previous” InductionCan Be Repackaged As
Standard Induction
Establish “Base Case”: S0
Establish that k, Sk ) Sk+1
Let k be any natural number.
Assume j<k, Sj
Prove Sk
Define Ti = j· i, Sj
Establish “Base Case”: T0
Establish that k, Tk ) Tk+1
Let k be any natural number.Assume Tk-1
Prove Tk
![Page 47: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/47.jpg)
Induction is also how we can define and
construct our world.
![Page 48: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/48.jpg)
So many things, from buildings to
computers, are built up stage by stage, module by module, each depending on the previous stages.
![Page 49: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/49.jpg)
Well, almost always
![Page 50: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/50.jpg)
Inductive Definition Of Functions
Stage 0, Initial Condition, or Base Case: Declare the value of the function on some
subset of the domain.
Inductive Rules Define new values of the function in terms of previously defined values of the function
F(x) is defined if and only if it is implied by finite iteration of the rules.
![Page 51: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/51.jpg)
Inductive Definition Of Functions
Stage 0, Initial Condition, or Base Case: Declare the value of the function on some
subset of the domain.
Inductive Rules Define new values of the function in terms of previously defined values of the function
If there is an x such that F(x) has more than one value – then the whole inductive definition is said to be inconsistent.
![Page 52: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/52.jpg)
Inductive Definition Recurrence Relation for F(X)
Initial Condition, or Base Case:F(0) = 1
Inductive RuleFor n>0, F(n) = F(n-1) + F(n-1)
n 0 1 2 3 4 5 6 7
F(n) 1
![Page 53: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/53.jpg)
Inductive Definition Recurrence Relation for F(X)
Initial Condition, or Base Case:F(0) = 1
Inductive RuleFor n>0, F(n) = F(n-1) + F(n-1)
n 0 1 2 3 4 5 6 7
F(n) 1 2
![Page 54: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/54.jpg)
Inductive Definition Recurrence Relation for F(X)
Initial Condition, or Base Case:F(0) = 1
Inductive RuleFor n>0, F(n) = F(n-1) + F(n-1)
n 0 1 2 3 4 5 6 7
F(n) 1 2 4
![Page 55: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/55.jpg)
Inductive Definition Recurrence Relation for F(X)
Initial Condition, or Base Case:F(0) = 1
Inductive RuleFor n>0, F(n) = F(n-1) + F(n-1)
n 0 1 2 3 4 5 6 7
F(n) 1 2 4 816
32
64
128
![Page 56: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/56.jpg)
Inductive Definition Recurrence Relation for F(X) = 2X
Initial Condition, or Base Case:F(0) = 1
Inductive RuleFor n>0, F(n) = F(n-1) + F(n-1)
n 0 1 2 3 4 5 6 7
F(n) 1 2 4 816
32
64
128
![Page 57: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/57.jpg)
Inductive Definition Recurrence Relation
Initial Condition, or Base Case:F(1) = 1
Inductive RuleFor n>1, F(n) = F(n/2) + F(n/2)
n 0 1 2 3 4 5 6 7
F(n) 1
![Page 58: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/58.jpg)
Inductive Definition Recurrence Relation
Initial Condition, or Base Case:F(1) = 1
Inductive RuleFor n>1, F(n) = F(n/2) + F(n/2)
n 0 1 2 3 4 5 6 7
F(n) 1 2
![Page 59: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/59.jpg)
Inductive Definition Recurrence Relation
Initial Condition, or Base Case:F(1) = 1
Inductive RuleFor n>1, F(n) = F(n/2) + F(n/2)
n 0 1 2 3 4 5 6 7
F(n) 1 2 4
![Page 60: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/60.jpg)
Inductive Definition Recurrence Relation
Initial Condition, or Base Case:F(1) = 1
Inductive RuleFor n>1, F(n) = F(n/2) + F(n/2)
n 0 1 2 3 4 5 6 7
F(n) % 1 2 % 4 % % %
![Page 61: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/61.jpg)
Inductive Definition Recurrence Relation
F(X) = X for X a whole power of 2. Initial Condition, or Base Case:F(1) = 1
Inductive RuleFor n>1, F(n) = F(n/2) + F(n/2)
n 0 1 2 3 4 5 6 7
F(n) % 1 2 % 4 % % %
![Page 62: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/62.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2
3
![Page 63: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/63.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0 0
1 1
2 2
3 3
![Page 64: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/64.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0 0 1
1 1 2
2 2 3
3 3 4
![Page 65: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/65.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0 0 1 2
1 1 2 3
2 2 3 4
3 3 4 5
![Page 66: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/66.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0 0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7 8
2 2 3 4 5 6 7 8 9
3 3 4 5 6 7 8 910
![Page 67: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/67.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
X+Y 0 1 2 3 4 5 6 7
0 0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7 8
2 2 3 4 5 6 7 8 9
3 3 4 5 6 7 8 910
![Page 68: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/68.jpg)
Definition of P:
8x2 P(X,0) = X8x,y2, y>0, P(x,y) = P(x,y-1)
+ 1
Any inductive definition with a finite number of base cases,
can be translated into a program. The program simply calculates from the base cases
on up.
![Page 69: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/69.jpg)
Definition of P:
8x2{0,1,2,3} P(X,0) = X8x,y2, y>0, P(x,y) = P(x,y-1)
+ 1
What would be the bottom up implementation of P?
![Page 70: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/70.jpg)
For k = 0 to 3 P(k,0)=k
For j = 1 to 7For k = 0 to 3
P(k,j) = P(k,j-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0 0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7 8
2 2 3 4 5 6 7 8 9
3 3 4 5 6 7 8 910
Bottom-Up Program for P
![Page 71: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/71.jpg)
Suppose we wanted to know P(2,3) in
particular, but we had not yet done any
calculation.
![Page 72: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/72.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 ?
3
![Page 73: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/73.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 ? ?
3
![Page 74: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/74.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 ? ? ?
3
![Page 75: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/75.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 ? ? ? ?
3
![Page 76: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/76.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 2 ? ? ?
3
![Page 77: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/77.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 2 3 ? ?
3
![Page 78: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/78.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 2 3 4 ?
3
![Page 79: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/79.jpg)
Base Case: 8x2 P(X,0) = XInductive Rule:
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 2 3 4 5
3
![Page 80: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/80.jpg)
Procedure P(x,y):If y=0 return x
Otherwise return P(x,y-1)+1;
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 2 3 4 5
3
Top Down
![Page 81: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/81.jpg)
Procedure P(x,y):If y=0 return x
Otherwise return P(x,y-1)+1;
P(x,y)
0 1 2 3 4 5 6 7
0
1
2 2 3 4 5
3
RecursiveProgramming
![Page 82: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/82.jpg)
Top-Down, Recursive Program:Procedure P(x,y):
If y=0 return x Otherwise return P(x,y-1)+1;
Inductive Definition:8x2 P(X,0) = X
8x,y2, y>0, P(x,y) = P(x,y-1) + 1
Bottom-Up, Iterative Program:For k = 0 to 3
P(k,0)=kFor j = 1 to 7
For k = 0 to 3 P(k,j) = P(k,j-1) + 1
![Page 83: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/83.jpg)
Leonardo Fibonacci
In 1202, Fibonacci proposed a problem about the growth of rabbit populations.
![Page 84: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/84.jpg)
Leonardo Fibonacci
In 1202, Fibonacci proposed a problem about the growth of rabbit populations.
![Page 85: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/85.jpg)
Leonardo Fibonacci
In 1202, Fibonacci proposed a problem about the growth of rabbit populations.
![Page 86: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/86.jpg)
The rabbit reproduction model•A rabbit lives forever•The population starts as a single newborn pair•Every month, each productive pair begets a new pair which will become productive after 2 months old
Fn= # of rabbit pairs at the beginning of the nth month
month 1 2 3 4 5 6 7
rabbits
1 1 2 3 5 813
![Page 87: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/87.jpg)
The rabbit reproduction model•A rabbit lives forever•The population starts as a single newborn pair•Every month, each productive pair begets a new pair which will become productive after 2 months old
Fn= # of rabbit pairs at the beginning of the nth month
month 1 2 3 4 5 6 7
rabbits
1 1 2 3 5 813
![Page 88: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/88.jpg)
The rabbit reproduction model•A rabbit lives forever•The population starts as a single newborn pair•Every month, each productive pair begets a new pair which will become productive after 2 months old
Fn= # of rabbit pairs at the beginning of the nth month
month 1 2 3 4 5 6 7
rabbits
1 1 2 3 5 813
![Page 89: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/89.jpg)
The rabbit reproduction model•A rabbit lives forever•The population starts as a single newborn pair•Every month, each productive pair begets a new pair which will become productive after 2 months old
Fn= # of rabbit pairs at the beginning of the nth month
month 1 2 3 4 5 6 7
rabbits
1 1 2 3 5 813
![Page 90: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/90.jpg)
The rabbit reproduction model•A rabbit lives forever•The population starts as a single newborn pair•Every month, each productive pair begets a new pair which will become productive after 2 months old
Fn= # of rabbit pairs at the beginning of the nth month
month 1 2 3 4 5 6 7
rabbits
1 1 2 3 5 813
![Page 91: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/91.jpg)
The rabbit reproduction model•A rabbit lives forever•The population starts as a single newborn pair•Every month, each productive pair begets a new pair which will become productive after 2 months old
Fn= # of rabbit pairs at the beginning of the nth month
month 1 2 3 4 5 6 7
rabbits
1 1 2 3 5 813
![Page 92: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/92.jpg)
The rabbit reproduction model•A rabbit lives forever•The population starts as a single newborn pair•Every month, each productive pair begets a new pair which will become productive after 2 months old
Fn= # of rabbit pairs at the beginning of the nth month
month 1 2 3 4 5 6 7
rabbits
1 1 2 3 5 813
![Page 93: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/93.jpg)
Inductive Definition or Recurrence Relation for the
Fibonacci Numbers Stage 0, Initial Condition, or Base Case:Fib(1) = 1; Fib (2) = 1
Inductive RuleFor n>3, Fib(n) = Fib(n-1) + Fib(n-2)
n 0 1 2 3 4 5 6 7
Fib(n) % 1 1 2 3 5 813
![Page 94: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/94.jpg)
Inductive Definition or Recurrence Relation for the
Fibonacci Numbers Stage 0, Initial Condition, or Base Case:Fib(0) = 0; Fib (1) = 1
Inductive RuleFor n>1, Fib(n) = Fib(n-1) + Fib(n-2)
n 0 1 2 3 4 5 6 7
Fib(n) 0 1 1 2 3 5 813
![Page 95: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/95.jpg)
Top-Down, Recursive Program:Procedure Fib(k)
If k=0 return 0If k=1 return 1 Otherwise return Fib(k-1)+Fib(k-
2);
Inductive Definition: Fib(0)=0, Fib(1)=1, k>1, Fib(k)=Fib(k-1)+Fib(k-2)
Bottom-Up, Iterative Program:Fib(0) = 0; Fib(1) =1;Input x;For k= 2 to x do Fib(x)=Fiib(x-1)+Fib(x-2);Return Fib(k);
![Page 96: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/96.jpg)
What is a closed form formula for Fib(n) ????
Stage 0, Initial Condition, or Base Case:Fib(0) = 0; Fib (1) = 1
Inductive RuleFor n>1, Fib(n) = Fib(n-1) + Fib(n-2)
n 0 1 2 3 4 5 6 7
Fib(n) 0 1 1 2 3 5 813
![Page 97: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/97.jpg)
Leonhard Euler (1765) J. P. M. Binet (1843)
August de Moivre (1730)
Fibn =³ p5+ 12
´ n¡
³ p5+ 12
´ ¡ n
p5
![Page 98: Induction: One Step At A Time](https://reader036.fdocuments.us/reader036/viewer/2022062409/56814dd6550346895dbb3b49/html5/thumbnails/98.jpg)
Study Bee
Inductive ProofStandard FormAll Previous FormLeast-Counter Example
FormInvariant Form
Inductive DefinitionBottom-Up ProgrammingTop-Down ProgrammingRecurrence RelationsSolving a Recurrence