1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

29
1 Proof Strategies Proof Strategies CS/APMA 202 CS/APMA 202 Rosen section 3.1 Rosen section 3.1 Aaron Bloomfield Aaron Bloomfield

Transcript of 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

Page 1: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

11

Proof StrategiesProof Strategies

CS/APMA 202CS/APMA 202

Rosen section 3.1Rosen section 3.1

Aaron BloomfieldAaron Bloomfield

Page 2: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

22

Proof Strategies: What’s ImportantProof Strategies: What’s Important

Forward and backward reasoningForward and backward reasoning

Leveraging proof by casesLeveraging proof by cases

Adapting existing proofsAdapting existing proofs

Conjecture and proofConjecture and proof

Conjecture and counterexamplesConjecture and counterexamples

Open problems: 3x + 1Open problems: 3x + 1

The halting problemThe halting problem

Page 3: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

33

Forward reasoningForward reasoning

One example: modus ponens / direct proofOne example: modus ponens / direct proof

Given an antecedent p and a implication Given an antecedent p and a implication p→qp→q Show that conclusion q is trueShow that conclusion q is true

Often hard to see where the proof should Often hard to see where the proof should leadlead In that case, do a backward reasoning to In that case, do a backward reasoning to

determine the forward reasoningdetermine the forward reasoning

Page 4: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

44

Backward reasoningBackward reasoning

Start with the conclusion of the theoremStart with the conclusion of the theorem

Find an antecedent that yields the given Find an antecedent that yields the given conclusionconclusion

In other words, given conclusion q and In other words, given conclusion q and implication p→q, find an antecedent p that implication p→q, find an antecedent p that allows the conditional to be trueallows the conditional to be true Will often only be one such antecedentWill often only be one such antecedent

Page 5: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

55

Backward reasoningBackward reasoning

Is not the same as modus badus!Is not the same as modus badus!

Modus badus:Modus badus: Given p→q and q, show p via the converse Given p→q and q, show p via the converse

q→pq→p

Backward reasoningBackward reasoning Given p→q and q, find a p that p→q is trueGiven p→q and q, find a p that p→q is true

Or show that no such p can existOr show that no such p can exist It can be any p!It can be any p!

Page 6: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

66

Backward reasoningBackward reasoning

Is not the same as modus tonens!Is not the same as modus tonens!

Modus tonens:Modus tonens: Given p→q and ¬q, show ¬p via the Given p→q and ¬q, show ¬p via the

contrapositive ¬q→¬pcontrapositive ¬q→¬p

Backward reasoningBackward reasoning Given p→q and q, find a p that p→q is trueGiven p→q and q, find a p that p→q is true

Or show that no such p can existOr show that no such p can exist It can be any p!It can be any p!

Page 7: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

0 0 0 ?0 0 ? 0 0 0 0

1 0 1 0

0 1 1 0 0

What to prove?

1414. Suppose five ones and four zeros are arranged around . Suppose five ones and four zeros are arranged around a circle. Between any two equal bits you insert a 0 and a circle. Between any two equal bits you insert a 0 and between any two unequal bits you insert a 1 to produce between any two unequal bits you insert a 1 to produce nine new bits. Then you erase the nine original bits. nine new bits. Then you erase the nine original bits. Show that when you iterate this procedure you can Show that when you iterate this procedure you can never get nine zeros. (Hint: work backwards.)never get nine zeros. (Hint: work backwards.)

1 0 1 1 1 1 0 0 0

Backward reasoningBackward reasoning

Page 8: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

88

Backward reasoningBackward reasoning

In order to create 9 0’s, the previous step In order to create 9 0’s, the previous step had to have all 0’s or all 1’shad to have all 0’s or all 1’sConsider two cases for the second-to-last Consider two cases for the second-to-last step:step: There were 9 0’sThere were 9 0’s

The only previous step for this case is 9 0’s (this The only previous step for this case is 9 0’s (this case) or 9 1’s (other case)case) or 9 1’s (other case)

There can’t be any other ways to get 9 0’sThere can’t be any other ways to get 9 0’s

There were 9 1’sThere were 9 1’sThen every bit needed to be different than the bit Then every bit needed to be different than the bit next to itnext to it

Not possible with an odd number of bits!Not possible with an odd number of bits!

Page 9: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

99

Forwards vs. Backwards reasoningForwards vs. Backwards reasoning

Example 1 (Rosen, p. 215): Prove thatExample 1 (Rosen, p. 215): Prove thatwhen when aa≠≠bb, , aa>0, and >0, and bb>0>0

abba

2

0)(

02

42

4

2

2

2

2

22

22

22

2

ba

baba

abbaba

abbaba

abba

abba

Page 10: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

1010

Forwards vs. Backwards reasoningForwards vs. Backwards reasoning

Backwards reasoning:Backwards reasoning: Because (Because (aa--bb))22>0 when >0 when aa≠≠bb, ,

it follows that the inequality is trueit follows that the inequality is true

Forwards reasoning:Forwards reasoning: Given ,Given ,

we can show that is we can show that is equivalent to (equivalent to (aa--bb))22>0>0

((aa--bb))22>0 is always true >0 is always true when when aa≠≠bb

abba

2

0)(

...2

2

ba

abba

Page 11: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

1111

Leveraging proof by casesLeveraging proof by cases

““When there is no obvious way to begin a When there is no obvious way to begin a proof, but when extra information in each proof, but when extra information in each case helps move the proof forward”case helps move the proof forward”

Try to reduce the number of casesTry to reduce the number of cases

What to avoidWhat to avoid Make sure you get ALL the casesMake sure you get ALL the cases

Page 12: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

CasesCases32.32. Prove that Prove that n/2n/2 * * n/2n/2 = = nn22/4/4 for all integer n. for all integer n.

Consider two cases:Consider two cases:

Even(n): easyEven(n): easy

422

44

222

2

22

nnn

nn

nnn

Let n = 2k+1

(2k+1)/2 * (2k+1)/2 = (2k+1)2/4

k+½ * k+½ = (4k2+4k+1)/4

(k)*(k+1) = k2+k+¼

k2+k = k2+k+¼

k2+k = k2+k

Odd(n): trickierOdd(n): trickier

Page 13: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

13

Quick surveyQuick survey

How are we doing so far?How are we doing so far?

a)a) Very wellVery well

b)b) With some review, I’ll be goodWith some review, I’ll be good

c)c) Not reallyNot really

d)d) Not at allNot at all

Page 14: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

1414

An optical illusionAn optical illusion

Page 15: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

1515

Another optical illusionAnother optical illusion

Page 16: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

1616

DefinitionsDefinitions

Theorem: a statement that can be shown Theorem: a statement that can be shown to be trueto be true Or something that is widely believed to be trueOr something that is widely believed to be true

Conjecture: a statement whose truth value Conjecture: a statement whose truth value is unknownis unknown

Page 17: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

1717

Conjecture and counterexamplesConjecture and counterexamples

You can prove an existential quantifier by You can prove an existential quantifier by an examplean exampleYou can disprove an universal quantifier You can disprove an universal quantifier by exampleby example

You You cannotcannot prove an universal quantifier prove an universal quantifier by exampleby exampleYou You cannotcannot disprove an existential disprove an existential quantifier by examplequantifier by example

Page 18: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

1818

Proof by counterexampleProof by counterexample

15. Prove or disprove that 15. Prove or disprove that nn22-79-79nn+1601 is a +1601 is a prime whenever n is a positive integerprime whenever n is a positive integer

How to disprove?How to disprove? Find a single example that shows this to be Find a single example that shows this to be

falsefalse Let Let nn = 1601 = 1601 Then Then nn2 2 = (1601)= (1601)22-79(1601)+1601 = 1523*1601-79(1601)+1601 = 1523*1601

Page 19: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

Proof by exampleProof by example

What to prove?

ppZZ (p > 0 (p > 0 prime(p) prime(p) prime(p+2) prime(p+2) prime(p+4) )prime(p+4) )

Or:Or:

ppZZ++ (prime(p) (prime(p) prime(p+2) prime(p+2) prime(p+4) )prime(p+4) )

25.25. Prove or disprove that there are three Prove or disprove that there are three consecutive odd positive integers that are primes, consecutive odd positive integers that are primes, that is, odd primes of the form that is, odd primes of the form pp, , pp+2, +2, pp+4.+4.

Constructive existence proof: 3, 5, 7Constructive existence proof: 3, 5, 7

Page 20: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

Proof by exampleProof by example47.47.Prove that if you have an eight gallon jug of water Prove that if you have an eight gallon jug of water

and two empty jugs with capacities of five gallons and two empty jugs with capacities of five gallons and three gallons, then you can measure four gallons and three gallons, then you can measure four gallons by successively pouring some of or all of the water in by successively pouring some of or all of the water in a jug into another jug.a jug into another jug.

Show that there exists a sequence of steps that yields Show that there exists a sequence of steps that yields 4 gallons in one of the jugs4 gallons in one of the jugs

Constructive proof: (8,0,0) (3,5,0) (3,2,3) (6,2,0)

(6,0,2) (1,5,2) (1,4,3)8, 5, 3

Page 21: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

2222

Open problemsOpen problems

Fermat’s last theoremFermat’s last theorem xxnn+y+ynn=z=znn has no solutions in integers when has no solutions in integers when xyzxyz≠0 and ≠0 and nn>2>2 Finally proven!Finally proven!

Goldbach’s ConjectureGoldbach’s Conjecture Every integer Every integer nn (for (for nn>2) is the sum of 2 primes>2) is the sum of 2 primes Shown for all Shown for all nn up to 4*10 up to 4*101414

Thought to be trueThought to be true

Twin prime conjectureTwin prime conjecture There are an infinitely many number of primes that differ by 2There are an infinitely many number of primes that differ by 2 Biggest twin prime: 318,032,361*2Biggest twin prime: 318,032,361*2107,001107,001±1±1

That number has 32,220 digits!That number has 32,220 digits! Thought to be trueThought to be true

Page 22: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

2323

Open problemsOpen problems

33xx+1 conjecture+1 conjecture Let f(x) return Let f(x) return xx/2 if /2 if xx is even, and 3 is even, and 3xx+1 if +1 if xx is odd is odd

Shown for all numbersShown for all numbersup to 5.6*10up to 5.6*101313

11/2)2(

22/4)4(

42/8)8(

82/16)16(

1615*3)5(

52/10)10(

102/20)20(

202/40)40(

40113*3)13(

f

f

f

f

f

f

f

f

f

Page 23: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

2424

The Halting problemThe Halting problem

Is it possible to write a function that will tell if any Is it possible to write a function that will tell if any program will halt with any given input?program will halt with any given input?

Consider H(P,I)Consider H(P,I) Returns “halts” or “loops forever”Returns “halts” or “loops forever”

Note that P and I are both bit stringsNote that P and I are both bit strings

Now consider function K:Now consider function K:functionfunction K (s) K (s)

ifif H (s, s) = “loops forever” H (s, s) = “loops forever” then halt then halt

elseelse loop foreverloop forever

We then call K(K)We then call K(K)

Page 24: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

2525

The Halting problemThe Halting problem

Function K:Function K:functionfunction K (s) K (s)

ifif H (s, s) = “loops forever” H (s, s) = “loops forever” then halt then halt

elseelse loop foreverloop forever

We call K(K)We call K(K) Note that this calls H(K,K), which in turn calls K(K)Note that this calls H(K,K), which in turn calls K(K) If H(K,K) returns “halt”, then K loops foreverIf H(K,K) returns “halt”, then K loops forever

But H(K,K) stated that K halts!But H(K,K) stated that K halts! If H(K,K) returns “loops forever”, then K haltsIf H(K,K) returns “loops forever”, then K halts

But H(K,K) stated that K loops forever!But H(K,K) stated that K loops forever!

Both cases reached contradictionsBoth cases reached contradictions

Page 25: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

2626

Adapting existing proofsAdapting existing proofs

Look at existing proofsLook at existing proofs To use as a “template” for your proofsTo use as a “template” for your proofs To build upon for your proofsTo build upon for your proofs

Page 26: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

2727

ReuseReuse

49.49. Show that the problem of determining whether Show that the problem of determining whether a program with a given input ever prints the digit a program with a given input ever prints the digit 1 is unsolvable.1 is unsolvable.

• Leverage off the halting problem, which is known Leverage off the halting problem, which is known to be unsolvable (undecidable). to be unsolvable (undecidable).

• Assume the ‘print 1’ statement occurs just before Assume the ‘print 1’ statement occurs just before a halt statement. a halt statement.

• Since we can’t know if program execution will Since we can’t know if program execution will ever reach the halt statement, we can’t know if it ever reach the halt statement, we can’t know if it will reach the ‘print 1’ statement.will reach the ‘print 1’ statement.

Page 27: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

28

Quick surveyQuick survey

I felt I understood the material in this I felt I understood the material in this slide set…slide set…

a)a) Very wellVery well

b)b) With some review, I’ll be goodWith some review, I’ll be good

c)c) Not reallyNot really

d)d) Not at allNot at all

Page 28: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

29

Quick surveyQuick survey

The pace of the lecture for this The pace of the lecture for this slide set was…slide set was…

a)a) FastFast

b)b) About rightAbout right

c)c) A little slowA little slow

d)d) Too slowToo slow

Page 29: 1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.

30

Quick surveyQuick survey

How interesting was the material in How interesting was the material in this slide set? Be honest!this slide set? Be honest!

a)a) Wow! That was SOOOOOO cool!Wow! That was SOOOOOO cool!

b)b) Somewhat interestingSomewhat interesting

c)c) Rather bortingRather borting

d)d) ZzzzzzzzzzzZzzzzzzzzzz