§General Recursive Definitions and Structural Induction §1

§General Recursive Definitions and Structural Induction
§1: Recursively Defined Sequences
• Example: (Page 2 Example 3:) The sequence a1 , a2 , a3 , ... can be defined recursively
as follows:
(1) For all integers k ≥ 2, ak = ak−1 + 1
(2) a1 = 1.
Find a1 , a2 , a3 , a4 , a5 .
Solution:
a1 = 1
a2 = a1 + 1 = 1 + 1 = 2
a3 = a2 + 1 = 2 + 1 = 3
a4 = a3 + 1 = 3 + 1 = 4
a5 = a4 + 1 = 4 + 1 = 5.
Note: it seems that the formula here is an = n. We would need to prove this by
induction.
• Example: (Page 2 Example 4:) Let b0 , b1 , b2 , ... be the sequence defined recursively
as follows: for all integers k ≥ 1, bk = bk−1 + 2, where b0 = 1.
Find b0 , b1 , b2 , b3 , b4 , b5 .
Solution:
b0 = 1
b1 = b0 + 2 = 1 + 2 = 3
b2 = b1 + 2 = 3 + 2 = 5
b3 = b2 + 2 = 5 + 2 = 7
b4 = b3 + 2 = 7 + 2 = 9
b5 = b4 + 2 = 9 + 1 = 11
Note: it seems that the formula here is bn = 2n + 1. We would need to prove this by
induction.
1
• Example: (Page 2 Example 5:) The sequence c0 , c1 , c2 , ... can be defined recursively
as follows:
(1) For all integers k ≥ 2, ck = ck−1 + ck−2 recurrence relation
(2) c0 = 1, c1 = 3
Find c0 , c1 , c2 , c3 , c4 , c5 .
Solution:
c0 = 1
c1 = 3
c2 = c1 + c0 = 1 + 3 = 4
c3 = c2 + c1 = 4 + 3 = 7
c4 = c3 + c2 = 7 + 4 = 11
c5 = c4 + c3 = 11 + 7 = 18.
2
§2: Recursively Defined Sets
• Example: (Page 5, example 6:) Consider the set S of all strings in a’s and b’s. S is
defined recursively as follows:
1. I. Base: ε is in S.
2. II. Recursion: If s ∈ S, then
(a) sa ∈ S and (b) sb ∈ S,
where sa and sb are the concatenations of s with a and b respectively. (Note:
thus the concatenation of x and y is found by writing down x and then y: the
concatenation is xy.)
3. III. Restriction: Nothing is in S other than objects defined in I and II above.
Derive the fact that ab ∈ S.
Solution:
– (1) By I, ε ∈ S.
– (2) By (1) and II(a), εa ∈ S. But εa is the concatenation of the null string and
a, which equals a. So a ∈ S.
– (3) By (2) and II(b), ab ∈ S
3
§3: Solving Recurrence Relations by Iteration.
• Example: (Page 6 example 3:) Recall the sequence a1 , a2 , a3 , ... (this is example
3 on page 2 of this handout), which was defined as follows: For all integers k ≥ 2,
ak = ak−1 + 1, and a1 = 1.
1. Conjecture a formula for an , n ∈ N (i.e., find the closed form).
2. Prove your conjecture using induction.
Solution: This was actually another problem earlier in this handout. It seemed there
that the formula should be an = n. Let’s prove this by induction:
– Base case: a1 = 1, which was the given initial condition.
– Inductive hypothesis: Suppose ak = k.
– Inductive step: WTS: ak+1 = k + 1.
Proof: ak+1 = ak + 1 by the recurrence relation, which in turn = (k) + 1 by the
inductive hypothesis.
• Example: (Page 6 example 4:) Let b0 , b1 , b2 , ... be the sequence defined recursively
as follows: For all integers k ≥ 1, bk = bk−1 + 2, where b0 = 1.
1. Conjecture a formula for bn , n ∈ N ∪ {0} (i.e., find the closed form).
2. Prove your conjecture using induction.
Solution: This was actually another problem earlier in this handout. It seemed there
that the formula should be bn = 2n + 1. Let’s prove this by induction:
– Base case: b0 = 2 · 0 + 1 = 1, which was the given initial condition.
– Inductive hypothesis: Suppose bk = 2 · k + 1.
– Inductive step: WTS: bk+1 = 2 · (k + 1) + 1.
Proof: bk+1 = bk + 2 by the recurrence relation. Thus by the inductive hypothesis, bk+1 = bk + 2 = (2 · k + 1) + 2 = 2k + 3 = 2 · (k + 1) + 1
4
• Example: (Page 6 example 5:) Ak = (1.055)Ak−1 , A0 = 1000. Use iteration to guess
an explicit formula for the sequence. Then find A20
1. Conjecture a formula for An , n ∈ N ∪ {0} (i.e., find the closed form).
2. Prove your conjecture using induction.
Solution:
A0 = 1000, A1 = 1000(1.055), A2 = (1000·1.055)1.055 = 1000(1.055)2 , A3 = [(1000(1.055)2 ]1.055 =
1000(1.055)3 .... Thus our guess is An = 1000(1.055)n .
Let’s prove this by induction:
– Base case: A0 = 1000(1.055)0 = 1000, which was the initial condition.
– Inductive hypothesis: Suppose Ak = 1000(1.055)k .
– Inductive step: WTS: Ak+1 = 1000(1.055)k+1 .
Proof: Ak+1 = 1.055Ak by the recurrence relation. Thus by the inductive
hypothesis Ak+1 = 1.055 · 1000(1.055)k = 1000(1.055)k+1 .
5