CPSC 121: Models of Computation Unit 7: Proof Techniques (part 1) - - PowerPoint PPT Presentation

cpsc 121 models of computation
SMART_READER_LITE
LIVE PREVIEW

CPSC 121: Models of Computation Unit 7: Proof Techniques (part 1) - - PowerPoint PPT Presentation

CPSC 121: Models of Computation Unit 7: Proof Techniques (part 1) CPSC 121 2011W T2 1 Unit 7: Proof Techniques (part 1) th at Assignment #3 due Thursday February 16 17:00. Online quiz #8 very tentatively due Thursday st at 19:00 March 1


slide-1
SLIDE 1

CPSC 121 – 2011W T2 1

CPSC 121: Models of Computation

Unit 7: Proof Techniques (part 1)

slide-2
SLIDE 2

CPSC 121 – 2011W T2 2

Unit 7: Proof Techniques (part 1)

Assignment #3 due Thursday February 16

th at

17:00. Online quiz #8 very tentatively due Thursday March 1

st at 19:00

 Epp, 4 th edition: 12.2, pages 791 to 795.  Epp, 3 rd edition: 12.2, pages 745 to 747, 752 to 754  Rosen, 6 th edition: 12.2 pages 796 to 798, 12.3  Rosen, 7 th edition: 13.2 pages 858 to 861, 13.3

slide-3
SLIDE 3

CPSC 121 – 2011W T2 3

Unit 7: Proof Techniques (part 1)

By the start of class, you should be able to, for each proof strategy below:

 Identify the form of statement the strategy can prove.  Sketch the structure of a proof that uses the strategy.

Strategies:

 constructive/non-constructive proofs of existence  generalizing from the generic particular  direct proof (antecedent assumption)  indirect proofs by contrapositive and contradiction  proof by cases.

slide-4
SLIDE 4

CPSC 121 – 2011W T2 4

Unit 7: Proof Techniques (part 1)

Quiz 7 feedback:

 Reasonably well done, although a bit hard to tell

because of a board in Blackboard.

 We only have statistics for the graded attempts (44

  • ut of 675 as of 23:38 last night) instead of all of

them.

 We will do a lot more examples in class.

slide-5
SLIDE 5

CPSC 121 – 2011W T2 5

Unit 7: Proof Techniques (part 1)

Open-ended question: when should you switch strategies?

 When you are stuck.  When the proof is going around in circles.  When the proof is getting too messy.  When it is taking too long.  Through experience (how do you get that?)

Monitor yourself

slide-6
SLIDE 6

CPSC 121 – 2011W T2 6

Unit 7: Proof Techniques (part 1)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

CPSC 121: the BIG questions:

 How can we convince ourselves that an algorithm

does what it's supposed to do?

 We need to prove its correctness.

 How do we determine whether or not one algorithm

is better than another one?

 Sometimes, we need a proof to convince someone that

the number of steps of our algorithm is what we claim it is.

slide-7
SLIDE 7

CPSC 121 – 2011W T2 7

Unit 7: Proof Techniques (part 1)

By the end of this unit, you should be able to:

 Devise and attempt multiple different, appropriate

proof strategie for a given theorem, including

 all those listed in the "pre-class" learning goals  logical equivalences,  rules of inference,  universal modus ponens/tollens,

 For theorems requiring only simple insights beyond

strategic choices or for which the insight is given/hinted, additionally prove the theorem.

slide-8
SLIDE 8

CPSC 121 – 2011W T2 8

Unit 7: Proof Techniques (part 1)

Unit Summary

 Techniques for direct proofs.

 Existential quantifiers.  Universal quantifiers.

 Dealing with multiple quantifiers.  Indirect proofs: contrapositive and contradiction  Additional Examples

More general term than in Epp.

slide-9
SLIDE 9

CPSC 121 – 2011W T2 9

Unit 7: Proof Techniques (part 1)

Direct Proofs (antecedent assumption)

 Assume the premises hold.  Move one step at a time towards the conclusion.  There are two general forms of statements:

 Those that start with an existential quantifier.  Those that start with a universal quantifier.

 We use different techniques for them.

slide-10
SLIDE 10

CPSC 121 – 2011W T2 10

Unit 7: Proof Techniques (part 1)

Form 1: x D, P(x) ∃ ∈ To prove this statement is true, we must

Find a value of x (a “witness”) for which P(x) holds.

So the proof will look like this:

Choose x = <some value in D> Verify that the x we chose satisfies the predicate.

Example: there is a prime number x such that 3x+2 is not prime.

slide-11
SLIDE 11

CPSC 121 – 2011W T2 11

Unit 7: Proof Techniques (part 1)

How do we translate There is a prime number x such that 3x+2 is not prime into predicate logic?

a) ∀x Z ∈

+, Prime(x) ~Prime(3

x+2)

b) ∃x Z ∈

+, Prime(x) ~Prime(3

x+2)

c) ∀x Z ∈

+, Prime(x) → ~Prime(3x+2)

d) ∃x Z ∈

+, Prime(x) → ~Prime(3x+2)

e) ∀x P, ~Prime(3 ∈

x+2) where P is the set of all

primes f) None of the above.

slide-12
SLIDE 12

CPSC 121 – 2011W T2 12

Unit 7: Proof Techniques (part 1)

So the proof goes as follows:

Proof:

Choose x = It is prime because its only factors are 1 and Now 3

x+2 =

and Hence 3

x+2 is not prime.

QED.

slide-13
SLIDE 13

CPSC 121 – 2011W T2 13

Unit 7: Proof Techniques (part 1)

Unit Summary

 Techniques for direct proofs.

 Existential quantifiers.  Universal quantifiers.

 Dealing with multiple quantifiers.  Indirect proofs: contrapositive and contradiction  Additional Examples

slide-14
SLIDE 14

CPSC 121 – 2011W T2 14

Unit 7: Proof Techniques (part 1)

Form 2: x D, P(x) ∀ ∈ To prove this statement is true, we must

Show that P(x) holds no matter how we choose x.

So the proof will look like this:

Consider an unspecified element x of D Verify that the predicate P holds for this x.

 Note: the only assumption we can make about x is the

fact that it belongs to D. So we can only use properties common to all elements of D.

slide-15
SLIDE 15

CPSC 121 – 2011W T2 15

Unit 7: Proof Techniques (part 1)

Example: every Racket function is at least 12 characters long. The proof goes as follows:

Proof:

Consider an unspecified Racket function f This function Therefore f is at least 12 characters long.

slide-16
SLIDE 16

CPSC 121 – 2011W T2 16

Unit 7: Proof Techniques (part 1)

Terminology: the following statements all mean the same thing:

 Consider an unspecified element x of D  Without loss of generality consider a valid element x

  • f D.

 Suppose x is a particular but arbitrarily chosen

element of D.

slide-17
SLIDE 17

CPSC 121 – 2011W T2 17

Unit 7: Proof Techniques (part 1)

Another example:

Prove that if a, b are positive integers, then gcd(a,b) = gcd(b, a mod b)

 gcd(x,y) is the greatest common divisor of x and y.  x mod y is the remainder after you divide x by y. For

instance 17 mod 5 = 2.

Why is this theorem useful?

 Racket supports rational numbers.  It simplifies x/y by dividing x and y by their gcd.

slide-18
SLIDE 18

CPSC 121 – 2011W T2 18

Unit 7: Proof Techniques (part 1)

Form 2*: x D, P(x) → Q(x) ∀ ∈ This is a special case of form 2

 The textbook calls this (and only this) a direct proof.  The proof looks like this:

Proof:

Consider an unspecified element x of D. Assume that P(x) is true. Use this and properties of the element of D to verify that the predicate Q holds for this x.

slide-19
SLIDE 19

CPSC 121 – 2011W T2 19

Unit 7: Proof Techniques (part 1)

Why is the line Assume that P(x) is true valid?

a) Because these are the only cases where Q(x) matters. b) Because P(x) is preceded by a universal quantifier. c) Because we know that P(x) is true. d) Both (a) and (c) e) Both (b) and (c)

slide-20
SLIDE 20

CPSC 121 – 2011W T2 20

Unit 7: Proof Techniques (part 1)

Example: prove that

∀n N, n ∈ ≥ 1024 → 10n ≤ nlog

2 n

Proof:

Consider an unspecified natural number n. Assume that n ≥ 1024. Then ...

slide-21
SLIDE 21

CPSC 121 – 2011W T2 21

Unit 7: Proof Techniques (part 1)

Other interesting techniques for direct proofs ☺

 Proof by intimidation  Proof by lack of space (Fermat's favorite!)  Proof by authority  Proof by never-ending revision

For the full list, see:

http://school.maths.uwa.edu.au/~berwin/humour/invali d.proofs.html

slide-22
SLIDE 22

CPSC 121 – 2011W T2 22

Unit 7: Proof Techniques (part 1)

Unit Summary

 Techniques for direct proofs.

 Existential quantifiers.  Universal quantifiers.

 Dealing with multiple quantifiers.  Indirect proofs: contrapositive and contradiction  Additional Examples

slide-23
SLIDE 23

CPSC 121 – 2011W T2 23

Unit 7: Proof Techniques (part 1)

How do we deal with theorems that involve multiple quantifiers?

 Start the proof from the outermost quantifier.  Work our way inwards.

Example:

 for every positive integer n, there is a prime p that is

larger than n.

 Written using predicate logic:

slide-24
SLIDE 24

CPSC 121 – 2011W T2 24

Unit 7: Proof Techniques (part 1)

The proof goes as follows:

Proof:

Consider an unspecified positive integer n Choose p as follows: Now prove that p > n and that p is prime.

∀n Z ∈

+

∀n Z ∈

+

∃p Z ∈

+

∃p Z ∈

+

slide-25
SLIDE 25

CPSC 121 – 2011W T2 25

Unit 7: Proof Techniques (part 1)

Details (part 1)

 How do we choose p?

 First we compute x = n! + 1 (where n! = 1∙2∙3∙ ∙∙∙ ∙(n-1)∙n).  By the fundamental theorem of arithmetic, x can be

written as a product of primes: x = p

1∙p 2∙ ∙∙∙ p t  We use any one of these as p (say p 1).  The integer p is a prime by definition.

slide-26
SLIDE 26

CPSC 121 – 2011W T2 26

Unit 7: Proof Techniques (part 1)

Details (part 2).

 Now we need to prove that p > n.  Which of the following should we prove?

a) ∀i Z ∈

+, i ≤ n → i divides n!

b) ∃i Z ∈

+, i ≤ n i does not divide x

∧ c) ∀i Z ∈

+, i ≤ p → i does not divide x

d) ∀i Z ∈

+, i ≤ n → i does not divide x

e) None of the above.

slide-27
SLIDE 27

CPSC 121 – 2011W T2 27

Unit 7: Proof Techniques (part 1)

Details (part 3).

 Now the proof:

Pick an unspecified integer 2 ≤ i ≤ n. Observe that Since is an integer, but 1/i is not an integer, this means that x/i is not an integer. Hence i does not divide x. x i =n!1 i =n! i 1 i =1⋅2⋯i−1⋅i1⋯n1 i 1⋅2⋯i−1⋅i1⋯n

slide-28
SLIDE 28

CPSC 121 – 2011W T2 28

Unit 7: Proof Techniques (part 1)

Another example: every even square can be written as the sum of two consecutive odd integers.

∀x Z ∈

+, Even(x) Square(x) → SumOfTwoConsOdd(x)

How do we define:

 Square(x):  SumOfTwoConsOdd(x):

slide-29
SLIDE 29

CPSC 121 – 2011W T2 29

Unit 7: Proof Techniques (part 1)

The proof goes as follows:

Proof:

Consider an unspecified integer x Assume that x is an even square.

Hint: for every positive integer n, if n2 is even, then n is even.

Therefore x can be written as the sum of two consecutive

  • dd integers.
slide-30
SLIDE 30

CPSC 121 – 2011W T2 30

Unit 7: Proof Techniques (part 1)

Unit Summary

 Techniques for direct proofs.

 Existential quantifiers.  Universal quantifiers.

 Dealing with multiple quantifiers.  Indirect proofs: contrapositive and contradiction  Additional Examples

slide-31
SLIDE 31

CPSC 121 – 2011W T2 31

Unit 7: Proof Techniques (part 1)

Consider the following theorem:

If the square of a positive integer n is even, then n is even.

How can we prove this?

 Let's try a direct proof.

Consider an unspecified integer n. Assume that n2 is even. So n2 = 2k for some (positive) integer k. Hence . Then what? n=2k

slide-32
SLIDE 32

CPSC 121 – 2011W T2 32

Unit 7: Proof Techniques (part 1)

Consider instead the following theorem:

If a positive integer n is odd, then its square is odd.

We can prove this easily:

Consider an unspecified positive integer n. Assume that n is odd. Hence n = 2k+1 for some integer k. Then n2 = (2k+1)2 = 4k2 + 4k + 1 = 2(2k2+2k)+1 Therefore n2 is odd.

slide-33
SLIDE 33

CPSC 121 – 2011W T2 33

Unit 7: Proof Techniques (part 1)

What is the relationship between

If the square of a positive integer n is even, then n is even.

and

If a positive integer n is odd, then its square is odd.

? They are and hence

slide-34
SLIDE 34

CPSC 121 – 2011W T2 34

Unit 7: Proof Techniques (part 1)

Another proof technique: proofs by contradiction. To prove:

Premise 1 ... Premise n ∴ Conclusion We assume Premise 1, ..., Premise n, ~Conclusion and then derive a contradiction (p ^ ~p, x is odd ^ x is even, x < 5 ^ x > 10, etc). We then conclude that Conclusion is true.

slide-35
SLIDE 35

CPSC 121 – 2011W T2 35

Unit 7: Proof Techniques (part 1)

Why are proofs by contradiction a valid proof technique?

 We proved

Premise 1 ^ ... ^ Premise n ^ ~Conclusion → F

 This is only true if

Premise 1 ^ ... ^ Premise n ^ ~Conclusion ≡ F

 If

Premise 1 ^ ... ^ Premise n ≡ F then Premise 1 ^ ... ^ Premise n → Conclusion is true.

slide-36
SLIDE 36

CPSC 121 – 2011W T2 36

Unit 7: Proof Techniques (part 1)

Why are proofs by contradiction a valid proof technique?

 Otherwise

Premise 1 ^ ... ^ Premise n ≡ T but Premise 1 ^ ... ^ Premise n ^ ~Conclusion ≡ F therefore ~Conclusion ≡ F which means that Conclusion ≡ T and so Premise 1 ^ ... ^ Premise n → Conclusion is true.

slide-37
SLIDE 37

CPSC 121 – 2011W T2 37

Unit 7: Proof Techniques (part 1)

Example: Not every CPSC 121 student got an above average grade

  • n midterm 1.

 What are:  The premise(s)?  The negated conclusion?  Let us prove this theorem together.

slide-38
SLIDE 38

CPSC 121 – 2011W T2 38

Unit 7: Proof Techniques (part 1)

Example: A group of CPSC 121 students show up in a room for a

  • tutorial. The TA is late, and so the students start talking to

each other. If every student has talked to at least one

  • ther student, then two of the students talked to exactly

the same number of people. What are

 the premise(s)?  the negated conclusion?

Prove the theorem!

slide-39
SLIDE 39

CPSC 121 – 2011W T2 39

Unit 7: Proof Techniques (part 1)

Another example: Prove that for all real numbers x and y, if x is a rational number, and y is an irrational number, then x+y is irrational. What are

 the premise(s)?  the negated conclusion?

Prove the theorem!

slide-40
SLIDE 40

CPSC 121 – 2011W T2 40

Unit 7: Proof Techniques (part 1)

How should you tackle a proof?

 Try the simpler methods first:  Witness proofs (if applicable).  Generalizing from the generic particular.  Indirect proof using the contrapositive.  Proof by contradiction.  If you don't know if the theorem is true:  Alternate between trying to prove and disprove it.  Use a failed attempt at one to help with the other.

slide-41
SLIDE 41

CPSC 121 – 2011W T2 41

How should you tackle a proof?

How should you tackle a proof (continued)?

 If you get stuck, try looking backwards from the

conclusion you want.

 But don't forget the argument must eventually be written

from the premises to the conclusion (not the other way around).

 Try to derive all new facts you can derive from the

premises without worrying about whether or not they will help.

 If you are really stuck, ask for help!

slide-42
SLIDE 42

CPSC 121 – 2011W T2 42

Unit 7: Proof Techniques (part 1)

Unit Summary

 Techniques for direct proofs.

 Existential quantifiers.  Universal quantifiers.

 Dealing with multiple quantifiers.  Indirect proofs: contrapositive and contradiction  Additional Examples

slide-43
SLIDE 43

CPSC 121 – 2011W T2 43

Unit 7: Proof Techniques (part 1)

Additional theorems you might wish to prove:

 Prove that for every positive integer x, either is

an integer, or it is irrational.

 Prove that any circuit consisting of NOT, OR, AND

and XOR gates can be implemented using only NOR gates.

 x

slide-44
SLIDE 44

CPSC 121 – 2011W T2 44

Unit 7: Proof Techniques (part 1)

Additional theorems you might wish to prove:

 Prove that if a, b and c are integers, and a2+b2=c2,

then at least one of a and b is even. Hint: use a proof by contradiction, and show that 4 divides both c2 and c2-2.

 Prove that there is a positive integer c such that

x + y ≤ c ∙ max{ x, y } for every pair of positive integers x and y.