chapter 1: introduction mathematical proofs mathematical induction cs 340 page 1

9
Chapter 1: Introduction •Mathematical Proofs •Mathematical Induction CS 340 Page 1

Upload: maryann-bond

Post on 29-Dec-2015

233 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

Chapter 1: Introduction

• Mathematical Proofs• Mathematical Induction

CS 340 Page 1

Page 2: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

CS 340 Page 2

Math Review: Mathematical ProofsHow do you prove that something is true about a set of values?

• Show that it’s true for the first few values in the set?

• Show that it’s true for every value in the set?• But what if the set is infinite?

• But what if it’s only true for those first few values?

• Show that it’s true for several randomly chosen values in the set?• But what if it’s only true for those randomly chosen values?

Prove that n n n! for all positive values for n.

Well, 1 = 11 1! = 1 and 4 = 22 2! = 2 and 27 = 33 3! = 6 and 256 = 44 4! = 24 and ...

Prove that 1,000,000 n 2 for all positive values for n.

Well, it’s true for 12 and 22 and 32 and 42 and 52 and 62 and 72 and 82 and ... (… it stops being true at 1001!)

Prove that every positive number n equals the sum of its smaller positive factors.

Well, it’s true for 6 = 1+2+3 and 28 = 1+2+4+7+14 and 496 = 1+2+4+8+16+31+62+124+248 and ... (… there are only seven values that work!)

Page 3: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

CS 340 Page 3

Mathematical InductionOne way to successfully prove a theorem about a set of values is by means of mathematical induction.

Step One: Prove A Base CaseFormally demonstrate that the theorem is true for some small n-value n0Step Two: Assume An Inductive HypothesisAssume that the theorem is true for all n-values up to and including k, where k n0Step Three: Prove For n = k + 1Using the inductive hypothesis, prove the theorem for the n-value k+1

Page 4: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

CS 340 Page 4

An Intuitive ExampleProve that for any value n ≥ 8, it is possible to produce n cents of postage from 3¢ and 5¢ stamps.

Looking at a table of stamp combinations, this appears to be true… # of five-cent stamps

0 1 2 3 4 5

# of three-

cent stamps

0 0¢ 5¢ 10¢ 15¢ 20¢ 25¢

1 3¢ 8¢ 13¢ 18¢ 23¢ 28¢

2 6¢ 11¢ 16¢ 21¢ 26¢ 31¢

3 9¢ 14¢ 19¢ 24¢ 29¢ 34¢

4 12¢ 17¢ 22¢ 27¢ 32¢ 37¢

5 15¢ 20¢ 25¢ 30¢ 35¢ 40¢

Page 5: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

CS 340 Page 5

Proving ItThe strategy here will be to prove that there’s a way to produce n + 1 cents of postage by using the solution for n - 2 cents, plus one 3¢ stamp.

There is a pitfall with this approach: If n + 1 is 8, 9, or 10,then n - 2 will be less than 8 and might not have a solution.Step One: Prove The Base Cases: n=8, n=9, and n =108¢ = 3¢ + 5¢; 9¢ = 3¢ + 3¢ + 3¢; 10¢ = 5¢ + 5¢Step Two: Assume The Inductive HypothesisAssume that combinations of 3¢ and 5¢ stamps can be found to make n¢ of postage for all n-values from 8 to k, where k 10 (i.e., n0 = 10)Step Three: Prove For n = k + 1Since k ≥ 10, k – 2 ≥ 8, so the inductive hypothesis tells us that there is a combination of 3¢ and 5¢ stamps that makes (k – 2)¢ of postage; add one 3¢ stamp to that and you’ll have a combination totaling (k+1)¢

Page 6: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

CS 340 Page 6

Theorem A: i = 1,n i = ½n (n + 1) for all n 1.Proof (by induction):

Step One (Prove for a base case):For n = 1, i = 1,1 i = 1 = ½(1)(1 + 1).

Step Two (Inductive hypothesis): Assume that it’s been proven for n-values up through k:

i = 1,k i = ½k(k + 1).

Step Three (Prove for the next value):Prove for n = k + 1:

i = 1,k+1 i = (k + 1) + i = 1,k i (by commutative law of +)

= (k + 1) + ½k(k + 1) (by inductive hypothesis)

= ½(2)(k + 1) + ½k(k + 1) (since 1 = ½ * 2)= ½(k + 1)(k + 2) (by distributive law of *

over +)= ½(k + 1)((k + 1) + 1). (by associative law

of +)

Formal Induction Example

Page 7: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

CS 340 Page 7

To prove that i = 1,n i = ½n (n + 1) for all n 1, we started by proving that it was true for n = 1.Once we accomplished that, we proved that if it had been proven true for some arbitrary value k, then it must be true for the next value: k + 1.In essence, this last proof causes the truth of the theorem to “cascade” through all remaining values.

Why Does Induction Work?

TRUEFOR

n = 1:1 =

½(1)(2)

Letting k = 1

TRUEFOR

n = 2:1 + 2 =½(2)(3)

Letting k = 2

TRUEFOR

n = 3:1+2+3 =½(3)(4)

Letting k = 3

Proof that if it’s true for n = k, then it’s also true for

n = k + 1

TRUEFOR

n = 4:1+2+3+4 =

½(4)(5)

Letting k = 4

TRUEFOR

n = 5 :1+2+3+4+5 =½(5)(6)

And so on...

Page 8: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

CS 340 Page 8

Theorem B: i = 1,n i 3 = ( i = 1,n i )2 for all n 1.

Proof (by induction):Step One (Prove for a base case):

For n = 1, i = 1,1 i 3 = 1 = ( i = 1,1 i )2.Step Two (Inductive hypothesis):

Assume that it’s been proven for n-values through k: i = 1,k i 3 = ( i = 1,k i )2.

Step Three (Prove for the next value):Prove for n = k + 1:

( i = 1,k+1 i)2 = ((k + 1) + i = 1,k i )2 (by commutative law of +)

= (k + 1)2 + 2(k + 1)( i = 1,k i ) + ( i = 1,k i )2

(by distrib. & commut. laws)

= (k + 1)2 + 2(k + 1)(½k(k + 1)) + ( i = 1,k i )2

(by Theorem A)

= (k + 1)2 + 2(k + 1)(½k(k + 1)) + i = 1,k i 3

(by inductive hypothesis)

= (k + 1)3 + i = 1,k i 3 (by distrib. & commut. laws)

= i = 1,k+1 i 3. (by commutative law of +)

Formal Induction Example #2

Page 9: Chapter 1: Introduction Mathematical Proofs Mathematical Induction CS 340 Page 1

CS 340 Page 9

What’s Wrong With This Induction?Theorem Z: For any group of n students, all n will get

the same grade in CS 340.Proof (by induction):

Step One (Prove for a base case):For n = 1, the group consists of a single student, so the entire group obviously will get the same grade in CS 340.

Step Two (Inductive hypothesis):Assume that it’s been proven for n-values through k:

Any group of k students will get the same CS 340 grade.

Step Three (Prove for the next value):Prove for n = k + 1:Given a group of k + 1 students, remove one student. The resulting group of k students will, by the inductive hypothesis, get the same grade in CS 340.Reinsert the student that was removed and then remove a different student. The resulting group of k people will also receive the same grade in CS 340.Thus, since all of the unremoved students will get the same grade as the second removed student and the same grade as the first removed student, all k + 1 students will have to receive the same grade in CS 340!