More About Induction Reading: EC 2.4 Peter J. Haas INFO 150 Fall - - PowerPoint PPT Presentation

more about induction
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

More About Induction

Reading: EC 2.4 Peter J. Haas INFO 150 Fall Semester 2019

Lecture 9 1/ 15

slide-2
SLIDE 2

More About Induction Overview Sums as Recursive Sequences Proving Properties of a Recursive Sequence Closed-Form Sequences General Inductive Proofs Fundamental Theorem of Arithmetic

Lecture 9 2/ 15

slide-3
SLIDE 3

Overview

Goal

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

slide-4
SLIDE 4

Sums as Recursive Sequences

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

slide-5
SLIDE 5

Sums as Recursive Sequences

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 =

  • 1 + 2 + · · · + (m − 1)
  • + 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

slide-6
SLIDE 6

Sums as Recursive Sequences

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 =

  • 1 + 2 + · · · + (m − 1)
  • + 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

slide-7
SLIDE 7

Sums as Recursive Sequences, Continued

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

slide-8
SLIDE 8

Sums as Recursive Sequences, Continued

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) =

  • 1 + 3 + 5 + · · · + (2n − 3)
  • + (2n − 1)

= sn−1 + (2n − 1) I So sn = sn−1 + (2n − 1) is recurrence relation (with s1 = 1)

Lecture 9 5/ 15

slide-9
SLIDE 9

Sums as Recursive Sequences, Continued

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) =

  • 1 + 3 + 5 + · · · + (2n − 3)
  • + (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

  • it

(

Itt )

slide-10
SLIDE 10

Example: Finding a Closed Form for a Sum

Example: Show that Pn

i=1 2 3i = 1 − 1 3n for every positive integer n

  • 1. Let sn = Pn

i=1 2 3i : will show that sn = 1 − 1 3n

  • 2. Recurrence relation: sn = sn−1 + 2

3n with s1 = 2 3

  • 3. s1 = 1 − 1

31 = 2 3 X

  • 4. Fix m ≥ 2 & assume that statements up to sm−1 = 1 −

1 3m−1 have been checked

  • 5. Consider sm:

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

slide-11
SLIDE 11

Example: Finding a Closed Form for a Sum

Example: Show that Pn

i=1 2 3i = 1 − 1 3n for every positive integer n

  • 1. Let sn = Pn

i=1 2 3i : will show that sn = 1 − 1 3n

  • 2. Recurrence relation: sn = sn−1 + 2

3n with s1 = 2 3

  • 3. s1 = 1 − 1

31 = 2 3 X

  • 4. Fix m ≥ 2 & assume that statements up to sm−1 = 1 −

1 3m−1 have been checked

  • 5. Consider sm:

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

slide-12
SLIDE 12

Another Example

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

that

the

closed formula

is correct for .gs ,

. . . ,sm . ,

3

.

sni-sm.tt/m-D=cm-Dkcm-iH-ilt4m-l

by induction hyp

.

=

2cm

  • I )

"

the

  • It

4th

  • I

=

Llm

'
  • 2mW

)t5m

  • 2

=

2Mt

  • 4mt2t5m
  • 2

=

Lm

"

tm

=

m(

2Mt

1)

slide-13
SLIDE 13

Proving Properties of a Recursive Sequence

Key idea: You can prove properties of a sequence even if you can’t find a closed form

Lecture 9 8/ 15

slide-14
SLIDE 14

Proving Properties of a Recursive Sequence

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

  • 1. Calculate: a1 = 5, a2 = 10, a3 = 25, a4 = 60
  • 2. We see that a3 < 33 and a4 < 34
  • 3. Fix m ≥ 5 such that inequalities up to am−1 < 3m−1 have been checked
  • 4. Consider am and show that am < 3m:

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

slide-15
SLIDE 15

Proving Properties of a Recursive Sequence

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

  • 1. Calculate: a1 = 5, a2 = 10, a3 = 25, a4 = 60
  • 2. We see that a3 < 33 and a4 < 34
  • 3. Fix m ≥ 5 such that inequalities up to am−1 < 3m−1 have been checked
  • 4. Consider am and show that am < 3m:

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

I

because

n

=3 For ay

,

need to

use

induction

  • n

as

.

This

is

not

proven C and

is false

)

slide-16
SLIDE 16

Fibonacci Numbers

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)

  • 1. By inspection, P(1) is true, since F3 = 2
  • 2. Fix m ≥ 2 and assume that P(1), P(2), . . . , P(m − 1) have been checked; i.e.,

F3, F6, . . . , F3(m−1) are all even

  • 3. Consider P(m):

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

  • 4. that F3(m−1) is even has been checked & 2F3m−2 is clearly even
  • 5. F3m = F3(m−1) + 2F3m−2 is the sum of two even numbers, and hence is evenX

Lecture 9 9/ 15

slide-17
SLIDE 17

Another Fibonacci Example

Prove: P(n): “Pn

i=1(Fi)2 = (Fn)(Fn+1)”

  • 1. (F1)2 = (F1)(F2) is true, since 12 = 1 · 1, so P(1) is true
  • 2. Fix a positive integer m and assume that P(1), P(2), . . . , P(m − 1) have been

checked to be true

  • 3. Consider P(m):

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

slide-18
SLIDE 18

Exercise

Prove: P(n): “Fn < 2n for all positive integers n”

Lecture 9 11/ 15

F-

  • I

,

IT

  • I

, E- 2,4=3

,

.
  • n

I

.

f

  • I

22

'

,

File

I

so

Ph ) and PCD

are

true

r

.

Pick

m

>

3

and

assume

that

put

. . .

,

Plm

  • Dare

true

3

.

Fm

=

Fm

. it

Fm

,

<

I

  • '

t

In

since

Plm

  • i ) and

Plm

  • up

are

assumed

true

<

zm

"

+2M

"

since

zm

  • 2

a

zm

  • '

m

  • I

=

2

  • 2

=

In

slide-19
SLIDE 19

Closed-Form Sequences

Prove: D(n): “n3 + 2n is divisible by 3 for all positive integers n”

  • 1. 13 + 2 · 1 = 3 which is divisible by 3, so D(1) holds
  • 2. Fix m such that D(1), . . . , D(m − 1) have been checked to be true
  • 3. In particular, by D(m − 1), we know that (m − 1)3 + 2(m − 1) is divisible by 3
  • 4. So there exists an integer K such that (m − 1)3 + 2(m − 1) = 3K, i.e.,

m3 − 3m2 + 5m − 3 = 3K

  • 5. Consider D(m):

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)

  • 6. Thus m3 + 2m = 3 · (integer), so that m3 + 2m is divisible by 3

Question: Can you prove the result non-inductively, using the Division Theorem?

Lecture 9 12/ 15

slide-20
SLIDE 20

General Inductive Proofs

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”

  • 1. T(1) is true: with one team, 0 games need to be played
  • 2. Fix m ≥ 2 and assume that T(1), . . . , T(m − 1) have been checked
  • 3. After one game has been played, one team has been eliminated, so there are

m − 1 teams left

  • 4. By T(m − 1), we need m − 2 games to determine the champion
  • 5. So we need the first game plus m − 2 additional games, for a total of m − 1

games, and T(m) is true X

Lecture 9 13/ 15

slide-21
SLIDE 21

Card Shuffling

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

slide-22
SLIDE 22

Card Shuffling

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

  • 1. P(0) is obviously true (spade is the wrong-way card before any shuffle)
  • 2. Fix m ≥ 1 and assume that P(0), . . . , P(m − 1) have been checked
  • 3. Case 1 (stack is cut): No cards flipped , so still one wrong-way card
  • 4. Case 2 (entire stack turned over): prior wrong-way card is still the wrong way
  • 5. Case 3 (top two cards flipped as one):

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

slide-23
SLIDE 23

Fundamental Theorem of Arithmetic

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

slide-24
SLIDE 24

Fundamental Theorem of Arithmetic

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

  • 1. P(2) is trivially true: list is (2)
  • 2. Assume P(2), . . . , P(m − 1) are true
  • 3. Case A (m is prime): list for P(m) is (m)
  • 4. Case B (m is not prime):

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

slide-25
SLIDE 25

Fundamental Theorem of Arithmetic

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

  • 1. P(2) is trivially true: list is (2)
  • 2. Assume P(2), . . . , P(m − 1) are true
  • 3. Case A (m is prime): list for P(m) is (m)
  • 4. Case B (m is not prime):

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