cse 20: discrete mathematics 1. for computer science...

8
CSE 20: Discrete Mathematics for Computer Science Prof. Miles Jones Today’s Topics: 1. Strong vs regular indiction 2. Strong induction examples: ! Divisibility by a prime ! Recursion sequence: product of fractions 2 1. Strong induction examples DIVISIBILITY BY A PRIME 3 Strong vs regular induction ! Prove: n1 P(n) ! Base case: P(1) ! Regular induction: P(n)!P(n+1) ! Strong induction: (P(1)P(n))!P(n+1) ! Can use more assumptions to prove P(n+1) 4 P(1) P(2) P(3) P(n) P(n+1) P(1) P(2) P(3) P(n) P(n+1)

Upload: truongthuy

Post on 26-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE 20: Discrete Mathematics 1. for Computer Science ...cseweb.ucsd.edu/classes/fa15/cse20-a/milesslides/19 - Strong... · CSE 20: Discrete Mathematics ... Strong induction examples:

CSE 20: Discrete Mathematics for Computer ScienceProf. Miles Jones

Today’s Topics:1. Strong vs regular indiction 2. Strong induction examples:

! Divisibility by a prime ! Recursion sequence: product of fractions

2

1. Strong induction examples

DIVISIBILITY BY A PRIME

3

Strong vs regular induction! Prove: ∀n≥1 P(n) ! Base case: P(1) ! Regular induction: P(n)!P(n+1)

! Strong induction: (P(1)∧…∧P(n))!P(n+1) ! Can use more assumptions to prove P(n+1)

4

P(1) P(2) P(3) P(n) P(n+1) … …

P(1) P(2) P(3) P(n) P(n+1) … …

Page 2: CSE 20: Discrete Mathematics 1. for Computer Science ...cseweb.ucsd.edu/classes/fa15/cse20-a/milesslides/19 - Strong... · CSE 20: Discrete Mathematics ... Strong induction examples:

Example for the power of strong induction! Theorem: For all prices p >= 8 cents, the price p

can be paid using only 5-cent and 3-cent coins

! Proof: ! Base case: 8=3+5, 9=3+3+3, 10=5+5 ! Assume it holds for all prices 1..p-1, prove for price p

when p≥11 ! Proof: since p-3≥8 we can use the inductive hypothesis

for p-3. To get price p simply add another 3-cent coin.

! Much easier than standard induction!

5

Example for the power of strong induction

! Proof: ! Base case: 8=3+5, 9=3+3+3, 10=5+5 ! Assume it holds for all prices 1..p-1, prove for price p

when p≥11 ! Proof: since p-3≥8 we can use the inductive hypothesis

for p-3. To get price p simply add another 3-cent coin.

! This doesn’t give us an algorithm to make the change. ! This gives us the corollary:

! All prices p>10 can be made with at least one three cent coin.

6

2. Strong induction examples

DIVISIBILITY BY A PRIME

7

Definitions and properties for this proof! Definitions:

! n is prime if ! n is composite if n=ab for some 1<a,b<n

! Prime or Composite exclusivity: ! All integers greater than 1 are either prime or

composite (exclusive or—can’t be both).

! Definition of divisible: ! n is divisible by d iff n = dk for some integer k.

! 2 is prime (you may assume this; it also follows from the definition).

8

, : 1 1a b N n ab a b∀ ∈ = → = ∨ =

Page 3: CSE 20: Discrete Mathematics 1. for Computer Science ...cseweb.ucsd.edu/classes/fa15/cse20-a/milesslides/19 - Strong... · CSE 20: Discrete Mathematics ... Strong induction examples:

Definitions and properties for this proof (cont.)! Goes without saying at this point: ! The set of Integers is closed under addition

and multiplication ! Use algebra as needed

9

Thm: For all integers n greater than 1, n is divisible by a prime number.Proof (by strong mathematical induction): Basis step: Show the theorem holds for n = ________. Inductive step: Assume [or “Suppose”] that

WTS that

So the inductive step holds, completing the proof.

10

Thm: For all integers n greater than 1, n is divisible by a prime number.Proof (by strong mathematical induction): Basis step: Show the theorem holds for n = ________. Inductive step: Assume [or “Suppose”] that

WTS that

So the inductive step holds, completing the proof.

11

A. 0 B. 1 C. 2 D. 3 E. Other/none/more

than one

Thm: For all integers n greater than 1, n is divisible by a prime number.Proof (by strong mathematical induction): Basis step: Show the theorem holds for n = _2______. Inductive step: Assume [or “Suppose”] that

WTS that

So the inductive step holds, completing the proof.

12

A. For some integer n>1, n is divisible by a prime number.

B. For some integer n>1, k is divisible by a prime number, for all integers k where 2≤k≤n.

C. Other/none/more than one

Page 4: CSE 20: Discrete Mathematics 1. for Computer Science ...cseweb.ucsd.edu/classes/fa15/cse20-a/milesslides/19 - Strong... · CSE 20: Discrete Mathematics ... Strong induction examples:

Thm: For all integers n greater than 1, n is divisible by a prime number.Proof (by strong mathematical induction): Basis step: Show the theorem holds for n = _2______. Inductive step: Assume [or “Suppose”] that

WTS that

So the inductive step holds, completing the proof.

13

A. n+1 is divisible by a prime number.

B. k+1 is divisible by a prime number.

C. Other/none/more than one

Thm: For all integers n greater than 1, n is divisible by a prime number.

Proof (by strong mathematical induction): Basis step: Show the theorem holds for n=2. Inductive step: Assume that for some n≥2, all integers 2≤k≤n are divisible by a prime. WTS that n+1 is divisible by a prime.

Proof by cases: ! Case 1: n+1 is prime. n+1 divides itself so we are done. ! Case 2: n+1 is composite. Then n+1=ab with 1<a,b<n+1. By the induction hypothesis, since a≤n there exists a prime p which divides a. So p|a and a|n+1. We’ve already seen that this Implies that p|n+1 (in exam – give full details!)

So the inductive step holds, completing the proof.

14

2. Strong induction examples

RECURSION SEQUENCE: PRODUCT OF FRACTIONS

15

Definitions and properties for this proof! Product less than one:

! Algebra, etc., as usual

16

Page 5: CSE 20: Discrete Mathematics 1. for Computer Science ...cseweb.ucsd.edu/classes/fa15/cse20-a/milesslides/19 - Strong... · CSE 20: Discrete Mathematics ... Strong induction examples:

Definition of the sequence:d

1 = 9/10

d2 = 10/11

dk = (d

k-1)(d

k-2) for all integers k≥3

Thm: For all integers n>0, 0<d

n<1.

Proof (by strong mathematical induction): Basis step: Show the theorem holds for n = ________. Inductive step: Assume [or “Suppose”] that

WTS that

So the inductive step holds, completing the proof.

17

Definition of the sequence:d

1 = 9/10

d2 = 10/11

dk = (d

k-1)(d

k-2) for all integers k≥3

Thm: For all integers n>0, 0<d

n<1.

Proof (by strong mathematical induction): Basis step: Show the theorem holds for n = ________. Inductive step: Assume [or “Suppose”] that

WTS that

So the inductive step holds, completing the proof.

18

A. 0 B. 1 C. 2 D. 3 E. Other/none/more

than one

Definition of the sequence:d

1 = 9/10

d2 = 10/11

dk = (d

k-1)(d

k-2) for all integers k≥3

Thm: For all integers n>0, 0<d

n<1.

Proof (by strong mathematical induction): Basis step: Show the theorem holds for n = _1,2_____. Inductive step: Assume [or “Suppose”] that

WTS that

So the inductive step holds, completing the proof.

19

A. For some int n>0, 0<dn<1. B. For some int n>1, 0<dk<1, for all

integers k where 1≤k≤n. C. Other/none/more than one

Definition of the sequence:d

1 = 9/10

d2 = 10/11

dk = (d

k-1)(d

k-2) for all integers k≥3

Thm: For all integers n>0, 0<d

n<1.

Proof (by strong mathematical induction): Basis step: Show the theorem holds for n = _1,2_____. Inductive step: Assume [or “Suppose”] that

WTS that

So the inductive step holds, completing the proof.

20

A. For some int n>0, 0<dn<1. B. For some int n>1, 0<dk<1, for all

integers k where 1≤k≤n. C. 0<dn+1<1 D. Other/none/more than one

Page 6: CSE 20: Discrete Mathematics 1. for Computer Science ...cseweb.ucsd.edu/classes/fa15/cse20-a/milesslides/19 - Strong... · CSE 20: Discrete Mathematics ... Strong induction examples:

Definition of the sequence:d

1 = 9/10

d2 = 10/11

dk = (d

k-1)(d

k-2) for all integers k≥3

Thm: For all integers n>0, 0<d

n<1.

Proof (by strong mathematical induction): Basis step: Show the theorem holds for n=1,2. Inductive step: Assume [or “Suppose”] that the theorem holds for n≥2. WTS that 0<dn+1<1.

By definition, dn+1=dn dn-1. By the inductive hypothesis, 0<dn-1<1 and 0<dn<1. Hence, 0<dn+1<1.

So the inductive step holds, completing the proof.

21

3. Fibonacci numbersVerifying a solution

22

Fibonacci numbers! 1,1,2,3,5,8,13,21,…

! Rule: F1=1, F2=1, Fn=Fn-2+Fn-1.

! Question: can we derive an expression for the n-th term?

! YES!

23

1 1 5 1 1 52 25 5

n n

nF! " ! "+ −

= −$ % $ %$ % $ %& ' & '

Fibonacci numbers! Rule: F1=1, F2=1, Fn=Fn-2+Fn-1. ! We will prove an upper bound:

! Proof by strong induction. ! Base case:

24

A. n=1 B. n=2 C. n=1 and n=2 D. n=1 and n=2 and n=3 E. Other

1 5,2

nnF r r +≤ =

Page 7: CSE 20: Discrete Mathematics 1. for Computer Science ...cseweb.ucsd.edu/classes/fa15/cse20-a/milesslides/19 - Strong... · CSE 20: Discrete Mathematics ... Strong induction examples:

Fibonacci numbers! Rule: F1=1, F2=1, Fn=Fn-2+Fn-1. ! We will prove an upper bound:

! Proof by strong induction. ! Base case:

25

A. n=1 B. n=2 C. n=1 and n=2 D. n=1 and n=2 and n=3 E. Other

1 5,2

nnF r r +≤ =

Fibonacci numbers! Rule: F1=1, F2=1, Fn=Fn-2+Fn-1. ! We will prove an upper bound:

! Proof by strong induction. ! Base case: n=1, n=2. Verify by direct

calculation

26

1 1F r= ≤ 22 1F r= ≤

1 5,2

nnF r r +≤ =

Fibonacci numbers! Rule: F1=1, F2=1, Fn=Fn-2+Fn-1.

! Theorem:

! Base cases: n=1,n=2

! Inductive step: Assume

27

A. Fn=Fn-1+Fn-2 B. Fn=rn for some n

C. Fk ≤rk for 1≤k≤n-1

D. Other

1 5,2

nnF r r +≤ =

Fibonacci numbers! Rule: F1=1, F2=1, Fn=Fn-2+Fn-1.

! Theorem:

! Base cases: n=1,n=2

! Inductive step: show…

28

A. Fn=Fn-1+Fn-2 B. Fn≤Fn-1+Fn-2 C. Fn=rn

D. Fn ≤rn

E. Other

1 5,2

nnF r r +≤ =

Page 8: CSE 20: Discrete Mathematics 1. for Computer Science ...cseweb.ucsd.edu/classes/fa15/cse20-a/milesslides/19 - Strong... · CSE 20: Discrete Mathematics ... Strong induction examples:

Fibonacci numbers! Rule: F1=1, F2=1, Fn=Fn-2+Fn-1.

! Theorem:

! Base cases: n=1,n=2

! Inductive step: show…

29

A. Fn=Fn-1+Fn-2 B. Fn≤Fn-1+Fn-2 C. Fn=rn

D. Fn ≤rn

E. Other

1 5,2

nnF r r +≤ =

Fibonacci numbers! Inductive step: need to show ,

! What can we use? ! Definition of Fn: ! Inductive hypothesis:

! That is, we need to show that

30

1 21 2,n n

n nF r F r− −− −≤ ≤

1 52,nnF r r +≤ =

2 1n n nF F F− −= +

2 1n n nr r r− −+ ≤

Fibonacci numbers! Finishing the inductive step. ! Need to show:

! Simplifying, need to show:

! Choice of actually satisfied (this is why we chose it!)

QED

31

2 1n n nr r r− −+ ≤

21 r r+ ≤

1 52r += 21 r r+ =

Fibonacci numbers - recap! Recursive definition of a sequence ! Base case: verify for n=1, n=2 ! Inductive step:

! Formulated what needed to be shown as an algebraic inequality, using the definition of Fn and the inductive hypothesis

! Simplified algebraic inequality ! Proved the simplified version

32