CSE 311: Foundations of Computing Strong Induction Fibonacci

CSE 311: Foundations of Computing
Fall 2014
Lecture 16: Recursively Defined Sets
Strong Induction
0
∀
0 ∧
∴∀
1.
2.
3.
4.
5.
Fibonacci Numbers
=0
=1
=
1 ∧
2 ∧ ⋯∧
+1
( )
By induction we will show that ( ) is true for every ≥ 0
Base Case: Prove (0)
Inductive Hypothesis:
Assume that for some arbitrary integer ≥ 0, ( ) is true
for every from 0 to
Inductive Step:
Prove that ( + 1) is true using the Inductive Hypothesis
(that ( ) is true for all values ≤ )
Conclusion: Result follows by induction
Bounding the Fibonacci Numbers
f0 = 0; f1 = 1; fn = fn-1 + fn-2 for all
Theorem: 2n/2-1 ≤ fn < 2n for all
+
→
for all
≥2
≥2
≥2
Proof:
1. Let P(n) be “2n/2-1 ≤ fn < 2n. By (strong) induction we prove P(n) for all n ≥ 2.
2. Base Case: P(2) is true: f2=1, 22/2-1=20=1 ≤ f2, 22=4>f2
3. Ind.Hyp: Assume 2j/2-1 ≤ fj < 2j for all integers j with 2 ≤ j ≤ k for some
arbitrary integer k ≥ 2.
4.
Ind. Step:
Goal: Show 2(k+1)/2-1 ≤ fk+1 < 2k+1
f0 = 0; f1 = 1; fn = fn-1 + fn-2 for all
Theorem: 2n/2-1 ≤ fn < 2n for all
≥2
≥2
Proof:
1. Let P(n) be “2n/2-1 ≤ fn < 2n. By (strong) induction we prove P(n) for all n ≥ 2.
2. Base Case: P(2) is true: f2=1, 22/2-1=20=1 ≤ f2, 22=4>f2
3. Ind.Hyp: Assume 2j/2-1 ≤ fj < 2j for all integers j with 2 ≤ j ≤ k for for some
arbitrary integer k ≥ 2.
4.
Ind. Step: Goal: Show 2(k+1)/2-1 ≤ fk+1 < 2k+1
Case k=2: P(3) is true: f3=f2+f1=1+1=2, 23/2-1=21/2 ≤ 2 = f3, 23=8 > f3
Case k≥3:
fk+1 = fk + fk-1 ≥ 2k/2-1 + 2(k-1)/2 – 1 by I.H. since k-1 ≥ 2
> 2(k-1)/2-1 + 2(k-1)/2 – 1 = 2·2(k-1)/2-1 = 2(k+1)/2 – 1
fk+1 = fk + fk-1 < 2k + 2(k-1) by I.H. since k-1 ≥ 2
< 2k + 2k = 2·2k = 2k+1
Recursive Definition of Sets
Recursive definition
– Basis step: 0 ∈ '
– Recursive step: if ( ∈ ', then ( + 2 ∈ '
– Exclusion rule: Every element in ' follows from
basis steps and a finite number of recursive
steps
Running time of Euclid’s algorithm
Theorem: Suppose that Euclid’s algorithm takes
for gcd( , ) with > , then ≥ !
Set "
"
"
!
!
= ," =
"%
"
then Euclid’s algorithm computes
=# " +"
=# "
+"
⋮
each quotient #& ≥ 1
" ≥1
=# " +"
=# "
Recursive Definitions of Sets
Basis:
Recursive:
6 ∈ '; 15 ∈ ';
if (, - ∈ ', then ( + - ∈ ';
Basis:
1, 1, 0 ∈ ', 0, 1, 1 ∈';
Recursive:
if (, -, . ∈ ', / ∈ ℝ, then α(, /-, /. ∈ '
if [(1, -1, .1], [(2, -2, .2] ∈ '
then [(1 + (2, -1 + -2, .1 + .2] ∈ '
Powers of 3:
steps
Recursive Definitions of Sets: General Form
Strings
Recursive definition
– Basis step: Some specific elements are in '
– Recursive step: Given some existing named
elements in ' some new objects constructed
from these named elements are also in '.
– Exclusion rule: Every element in ' follows from
basis steps and a finite number of recursive
steps
• An alphabet Σ is any finite set of characters
Palindromes
All Binary Strings with no 1’s before 0’s
Palindromes are strings that are the same
backwards and forwards
Basis:
ℇ is a palindrome and any
∈ Σ is a palindrome
Recursive step:
If 5 is a palindrome then 5 is a palindrome for
every ∈ Σ
• The set Σ* of strings over the alphabet Σ is
defined by
– Basis: ℇ ∈ Σ* (ℇ is the empty string)
– Recursive: if 4 ∈ Σ*, ∈ Σ, then 4 ∈ Σ*
Function Definitions on Recursively Defined Sets
Length:
len (ℇ) = 0;
len (4 ) = 1 + len(4); for 4 ∈ Σ ∗ ,
Reversal:
ℇ8 = ℇ
4 8 = 4 8 for 4 ∈ Σ*,
∈Σ
∈Σ
Concatenation:
( • ℇ = ( for ( ∈ Σ*
( • 4 = (( • 4) for (, 4 ∈ Σ*,
∈Σ