More About Induction
Reading: EC 2.4 Peter J. Haas INFO 150 Fall Semester 2019
Lecture 9 1/ 15
More About Induction Reading: EC 2.4 Peter J. Haas INFO 150 Fall - - PowerPoint PPT Presentation
More About Induction Reading: EC 2.4 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 9 1/ 15 More About Induction Overview Sums as Recursive Sequences Proving Properties of a Recursive Sequence Closed-Form Sequences General Inductive
Lecture 9 1/ 15
Lecture 9 2/ 15
I Connect induction on recursive sequences and sums I Illustrate fancier applications of induction I Use induction in a variety of settings
Lecture 9 3/ 15
Recall: with a1 = 1 and ak = ak−1 + (2k − 1), prove that an = n2 I Inductive step to show that am = m2: am = am−1 + (2m − 1) = (m − 1)2 + (2m − 1) using am−1 = (m − 1)2 = m2 − 2m + 1 + 2m − 1 = m2
Lecture 9 4/ 15
Recall: with a1 = 1 and ak = ak−1 + (2k − 1), prove that an = n2 I Inductive step to show that am = m2: am = am−1 + (2m − 1) = (m − 1)2 + (2m − 1) using am−1 = (m − 1)2 = m2 − 2m + 1 + 2m − 1 = m2 Recall: Prove that Pn
i=1 i = n(n+1) 2
I Inductive step to show S(m): 1 + 2 + · · · + m =
= (m − 1)m 2 + m using S(m − 1) = m2 − m 2 + 2m 2 = m2 + m 2 = m(m + 1) 2
Lecture 9 4/ 15
Recall: with a1 = 1 and ak = ak−1 + (2k − 1), prove that an = n2 I Inductive step to show that am = m2: am = am−1 + (2m − 1) = (m − 1)2 + (2m − 1) using am−1 = (m − 1)2 = m2 − 2m + 1 + 2m − 1 = m2 Recall: Prove that Pn
i=1 i = n(n+1) 2
I Inductive step to show S(m): 1 + 2 + · · · + m =
= (m − 1)m 2 + m using S(m − 1) = m2 − m 2 + 2m 2 = m2 + m 2 = m(m + 1) 2 Both proofs have a common structure I First step: Establish relationship between am and am−1 [or S(m) and S(m − 1)] I Second step: use that information
Lecture 9 4/ 15
Key idea: sums are recursive by nature I Sum of 101 numbers = (sum of 100 numbers) + (final number) I Will write sn instead of an to emphasize that given sequence is defined by a sum
Lecture 9 5/ 15
Key idea: sums are recursive by nature I Sum of 101 numbers = (sum of 100 numbers) + (final number) I Will write sn instead of an to emphasize that given sequence is defined by a sum Example I Consider sn = Pn
i=1(2i − 1) = 1 + 3 + 5 + · · · + (2n − 1)
I E.g., s5 = 1 + 3 + 5 + 7 + 9 (five terms) I Find a recursive description of sn I sn = sum of first (n − 1) terms plus nth term: sn =
n
X
i=1
(2i − 1) = 1 + 3 + 5 + · · · + (2n − 1) =
= sn−1 + (2n − 1) I So sn = sn−1 + (2n − 1) is recurrence relation (with s1 = 1)
Lecture 9 5/ 15
Key idea: sums are recursive by nature I Sum of 101 numbers = (sum of 100 numbers) + (final number) I Will write sn instead of an to emphasize that given sequence is defined by a sum Example I Consider sn = Pn
i=1(2i − 1) = 1 + 3 + 5 + · · · + (2n − 1)
I E.g., s5 = 1 + 3 + 5 + 7 + 9 (five terms) I Find a recursive description of sn I sn = sum of first (n − 1) terms plus nth term: sn =
n
X
i=1
(2i − 1) = 1 + 3 + 5 + · · · + (2n − 1) =
= sn−1 + (2n − 1) I So sn = sn−1 + (2n − 1) is recurrence relation (with s1 = 1) Example: What is the recursive form of sn = Pn
i=1(2i + 1)? Lecture 9 5/ 15
921
(
Itt )
Example: Show that Pn
i=1 2 3i = 1 − 1 3n for every positive integer n
i=1 2 3i : will show that sn = 1 − 1 3n
3n with s1 = 2 3
31 = 2 3 X
1 3m−1 have been checked
sm = sm−1 + 2 3m from recurrence relation = ⇣ 1 − 1 3m−1 ⌘ + 2 3m since sm−1 = 1 − 1 3m−1 = 1 − 3 3m + 2 3m = 1 − 1 3m X
Lecture 9 6/ 15
Example: Show that Pn
i=1 2 3i = 1 − 1 3n for every positive integer n
i=1 2 3i : will show that sn = 1 − 1 3n
3n with s1 = 2 3
31 = 2 3 X
1 3m−1 have been checked
sm = sm−1 + 2 3m from recurrence relation = ⇣ 1 − 1 3m−1 ⌘ + 2 3m since sm−1 = 1 − 1 3m−1 = 1 − 3 3m + 2 3m = 1 − 1 3m X Moral: Finding nice formulas for sums is a special case of finding closed formulas for recurrence relations
Lecture 9 6/ 15
Exercise: Show that Pn
i=1(4i − 1) = n(2n + 1) Lecture 9 7/ 15
she
4in )
I
.Si
'
;
Cti
.Me
4.1-1=3
=
1.
Chitti
)
2.
Assume
the
is correct for .gs ,
. . . ,sm . ,3
.by induction hyp
.=
2cm
"
the
4th
=
Llm
')t5m
=
2Mt
=
Lm
"
tm
=
m(
2Mt
1)
✓
Key idea: You can prove properties of a sequence even if you can’t find a closed form
Lecture 9 8/ 15
Key idea: You can prove properties of a sequence even if you can’t find a closed form Example: For an = 2an−1 + an−2 with a1 = 5, a2 = 10, show that an < 3n for n ≥ 3
am = 2am−1 + am−2 by recurrence relation < 2 · 3m−1 + am−2 since am−1 < 3m−1 is true < 2 · 3m−1 + 3m−2 since am−2 < 3m−2 is true < 2 · 3m−1 + 3m−1 since 3m−2 < 3m−1 = 3 · 3m−1 = 3mX
Lecture 9 8/ 15
Key idea: You can prove properties of a sequence even if you can’t find a closed form Example: For an = 2an−1 + an−2 with a1 = 5, a2 = 10, show that an < 3n for n ≥ 3
am = 2am−1 + am−2 by recurrence relation < 2 · 3m−1 + am−2 since am−1 < 3m−1 is true < 2 · 3m−1 + 3m−2 since am−2 < 3m−2 is true < 2 · 3m−1 + 3m−1 since 3m−2 < 3m−1 = 3 · 3m−1 = 3mX Observations I We checked initially for n = 3 instead of n = 1 (why?) I We checked both n = 3 and n = 4 before inductive step—what if we only checked n = 3? I Moral: It is not always sufficient to check only one initial statement
Lecture 9 8/ 15
n
=3 For ay
,
need to
use
induction
as
.This
is
not
proven C and
is false
Recall definition I Fn = Fn−1 + Fn−2 with F1 = 1, F2 = 1 I Sequence looks like 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, . . . Prove: P(n) : “F3n is always even” (i.e., Fk is even if k is divisible by 3)
F3, F6, . . . , F3(m−1) are all even
F3m = F3m−1 + F3m−2 by recurrence relation for F3m = (F3m−2 + F3m−3) + F3m−2 by recurrence relation for F3m−1 = F3(m−1) + 2F3m−2 rearranging terms and simplifying
Lecture 9 9/ 15
Prove: P(n): “Pn
i=1(Fi)2 = (Fn)(Fn+1)”
checked to be true
m
X
i=1
(Fi)2 = (F1)2 + (F2)2 + · · · + (Fm)2 = (F1)2 + (F2)2 + · · · + (Fm−1)2 + (Fm)2 = m−1 X
i=1
(Fi)2 ! + (Fm)2 = (Fm−1)(Fm) + (Fm)2 by P(m − 1) = (Fm)(Fm + Fm−1) = (Fm)(Fm+1) X by recurrence relation for Fm+1
Lecture 9 10/ 15
Prove: P(n): “Fn < 2n for all positive integers n”
Lecture 9 11/ 15
,
IT
, E- 2,4=3
,
.I
.22
'
,
I
so
Ph ) and PCD
are
r
.m
>
3
and
assume
,
Plm
true
3
.Fm
. itFm
,
<
t
since
Plm
are
true
<
zm
"
"
since
zm
a
zm
m
=
2
=
Prove: D(n): “n3 + 2n is divisible by 3 for all positive integers n”
m3 − 3m2 + 5m − 3 = 3K
m3 + 2m = (m3 − 3m2 + 5m − 3) + (3m2 − 3m + 3) = (3K) + (3m2 − 3m + 3) by simplified version of D(m − 1) = 3 · (K + m2 − m + 1)
Question: Can you prove the result non-inductively, using the Division Theorem?
Lecture 9 12/ 15
Key idea: Inductive proofs apply to any situation with a sequence of statements about the positive integers, even if there is no “formula” involved Prove: T(n) : “In a single-elimination basketball tournament with n teams, there must be n − 1 games played to determine a champion”
m − 1 teams left
games, and T(m) is true X
Lecture 9 13/ 15
Four aces: I Three possible shuffles: cut stack, top two cards can be turned over as one, entire stack can be turned over I Initially, spade is facing wrong way Example I Define P(n) : “After n shuffles, there will still be exactly one wrong-way card” I Prove P(n) is true for all n ≥ 0
Lecture 9 14/ 15 s D C H
Four aces: I Three possible shuffles: cut stack, top two cards can be turned over as one, entire stack can be turned over I Initially, spade is facing wrong way Example I Define P(n) : “After n shuffles, there will still be exactly one wrong-way card” I Prove P(n) is true for all n ≥ 0 Proof
5.1 Case A (wrong-way was among top two cards): other top card is now wrong way 5.2 Case B (wrong-way was among bottom two cards): other bottom card is now wrong way X
Lecture 9 14/ 15 s D C H
Fundamental Theorem of Arithmetic Every integer greater than 1 can be expressed as the product of a (unique) list of prime numbers. Notes I P(n): “n can be written as the product of a list of prime numbers”, n ≥ 2 I P(4) is true since 4 is the product of the numbers in list (2, 2) I Similarly, P(5) list is (5); P(6) list is (2, 3); and P(18) list is (2, 3, 3)
Lecture 9 15/ 15
Fundamental Theorem of Arithmetic Every integer greater than 1 can be expressed as the product of a (unique) list of prime numbers. Notes I P(n): “n can be written as the product of a list of prime numbers”, n ≥ 2 I P(4) is true since 4 is the product of the numbers in list (2, 2) I Similarly, P(5) list is (5); P(6) list is (2, 3); and P(18) list is (2, 3, 3) Proof of P(n) for n > 1
4.1 By definition of “prime”, m = a × b with 2 ≤ a, b ≤ m − 1 4.2 Let La be list for P(a) (exists because P(a) has been checked) 4.3 Let Lb be list for P(b) (exists because P(b) has been checked) 4.4 Then take the list for P(m) as the combination of La and Lb X
Lecture 9 15/ 15
Fundamental Theorem of Arithmetic Every integer greater than 1 can be expressed as the product of a (unique) list of prime numbers. Notes I P(n): “n can be written as the product of a list of prime numbers”, n ≥ 2 I P(4) is true since 4 is the product of the numbers in list (2, 2) I Similarly, P(5) list is (5); P(6) list is (2, 3); and P(18) list is (2, 3, 3) Proof of P(n) for n > 1
4.1 By definition of “prime”, m = a × b with 2 ≤ a, b ≤ m − 1 4.2 Let La be list for P(a) (exists because P(a) has been checked) 4.3 Let Lb be list for P(b) (exists because P(b) has been checked) 4.4 Then take the list for P(m) as the combination of La and Lb X Example for Case B: m = 48 = 6 · 8; P(6) list is (2, 3); P(8) list is (2, 2, 2); so P(48) list is (2, 3) + (2, 2, 2) = (2, 2, 2, 2, 3)
Lecture 9 15/ 15