cpsc 121 models of computation
play

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


  1. CPSC 121: Models of Computation Unit 7: Proof Techniques (part 1) CPSC 121 – 2011W T2 1

  2. 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  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 CPSC 121 – 2011W T2 2

  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. CPSC 121 – 2011W T2 3

  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 out of 675 as of 23:38 last night) instead of all of them.  We will do a lot more examples in class. CPSC 121 – 2011W T2 4

  5. Unit 7: Proof Techniques (part 1) Open-ended question: when should you switch strategies? Monitor yourself  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?) CPSC 121 – 2011W T2 5

  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. ? ? ? ? ? ? CPSC 121 – 2011W T2 6

  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. CPSC 121 – 2011W T2 7

  8. Unit 7: Proof Techniques (part 1) Unit Summary  Techniques for direct proofs.  Existential quantifiers. More general term than in Epp.  Universal quantifiers.  Dealing with multiple quantifiers.  Indirect proofs: contrapositive and contradiction  Additional Examples CPSC 121 – 2011W T2 8

  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. CPSC 121 – 2011W T2 9

  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 3 x +2 is not prime. CPSC 121 – 2011W T2 10

  11. Unit 7: Proof Techniques (part 1) How do we translate There is a prime number x such that 3 x +2 is not prime into predicate logic? + , Prime(x) ~Prime(3 x +2) a) ∀ x ∈ Z ∧ b) ∃ x ∈ + , Prime(x) ~Prime(3 ∧ x +2) Z c) ∀ x ∈ + , Prime(x) → ~Prime(3 x +2) Z + , Prime(x) → ~Prime(3 x +2) d) ∃ x ∈ Z e) ∀ x ∈ x +2) where P is the set of all P, ~Prime(3 primes f) None of the above. CPSC 121 – 2011W T2 11

  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 x +2 = Now 3 and x +2 is not prime. Hence 3 QED. CPSC 121 – 2011W T2 12

  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 CPSC 121 – 2011W T2 13

  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. CPSC 121 – 2011W T2 14

  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. CPSC 121 – 2011W T2 15

  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 of D.  Suppose x is a particular but arbitrarily chosen element of D. CPSC 121 – 2011W T2 16

  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. CPSC 121 – 2011W T2 17

  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. CPSC 121 – 2011W T2 18

  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) CPSC 121 – 2011W T2 19

  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 ... CPSC 121 – 2011W T2 20

  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 CPSC 121 – 2011W T2 21

  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 CPSC 121 – 2011W T2 22

  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: CPSC 121 – 2011W T2 23

  24. Unit 7: Proof Techniques (part 1) The proof goes as follows: Proof: Consider an unspecified positive integer n Choose p as follows: + + ∀ n ∀ n ∈ ∈ Z Z ∃ p ∃ p ∈ ∈ + + Z Z Now prove that p > n and that p is prime. CPSC 121 – 2011W T2 24

  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. CPSC 121 – 2011W T2 25

  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? + , i ≤ n → i divides n! a) ∀ i ∈ Z b) ∃ i ∈ + , i ≤ n i does not divide x ∧ Z c) ∀ i ∈ + , i ≤ p → i does not divide x Z d) ∀ i ∈ + , i ≤ n → i does not divide x Z e) None of the above. CPSC 121 – 2011W T2 26

  27. Unit 7: Proof Techniques (part 1) Details (part 3).  Now the proof: Pick an unspecified integer 2 ≤ i ≤ n. Observe that i = n!  1 x = n! i  1 i = 1 ⋅ 2 ⋯ i − 1 ⋅ i  1 ⋯ n  1 i i 1 ⋅ 2 ⋯ i − 1 ⋅ i  1 ⋯ n 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. CPSC 121 – 2011W T2 27

Recommend


More recommend