Presentation is loading. Please wait.

Presentation is loading. Please wait.

CPSC 121: Models of Computation 2012 Summer Term 2

Similar presentations


Presentation on theme: "CPSC 121: Models of Computation 2012 Summer Term 2"— Presentation transcript:

1 CPSC 121: Models of Computation 2012 Summer Term 2
Proof Techniques (Part B) Steve Wolfman, based on notes by Patrice Belleville and others 2011W1: TODO: MUST hand out sheet summarizing strategies and where they apply. Want a few more strategies and a different format from Dave’s sheet.

2 Learning Goals: In-Class
By the end of this unit, you should be able to: Devise and attempt multiple different, appropriate proof strategies—including all those listed in the “pre-class” learning goals plus use of logical equivalences, rules of inference, universal modus ponens/tollens, and predicate logic premises—for a given theorem. For theorems requiring only simple insights beyond strategic choices or for which the insight is given/hinted, additionally prove the theorem. Discuss point of learning goals.

3 Outline More Proof Strategies Strategies Summary
Using Logical Equivalences Using Predicate Logic Premises Proof by contradiction Strategies Summary Problems and Discussion Next Lecture Notes 2011W1: TODO for future reference: maybe swap LEs and Pred Log Premises, since we use an LE when proving the sample proof in Pred Log Premises??

4 Using Logical Equivalences
Every logical equivalence that we’ve learned applies to predicate logic statements. For example, to prove ~x  D, P(x), you can prove x  D, ~P(x) and then convert it back with generalized De Morgan’s. To prove x  D, P(x)  Q(x), you can prove x  D, ~Q(x)  ~P(x) and convert it back using the contrapositive rule. 2011W1: Also point out that we just DID this with universal De Morgan’s in the previous proof. In other words, Epp’s “proof by contrapositive” is direct proof after applying a logical equivalence rule.

5 Worked Problem: Even Squares
Theorem: If the square of an integer n is even, then n is even. Problem: prove the theorem. This is a tricky problem, unless you try some different approaches. An approach that may work with conditional statements is to try the contrapositive (which is logically equivalent to the original conditional).

6 Worked Problem: Even Squares
Theorem: If the square of an integer n is even, then n is even. Approach: (1) Prove the contrapostive: If an integer n is odd, then its square is also odd. (2) Transform the result back into our theorem. We now focus on proving the contrapositive.

7 Worked Problem: Even Squares (part 1)
Theorem: If an integer n is odd, then its square is also odd. Proof: Without loss of generality, let n be an integer. Assume n is odd. We know (from Epp’s definition of “odd”) that n = 2k + 1 for some integer k. n2 = (2k + 1)2 = 4k2 + 4k + 1 = 2(2k2 + 2k) + 1

8 Worked Problem: Even Squares (part 2)
We know 2k2 + 2k is an integer (since k is an integer and multiplication and addition are “closed over the integers”). n2 is 2q+1 for some integer q; so, n2 is odd. Thus, if an integer n is odd, its square is odd. The contrapositive of this statement is also true: if the square of an integer n is even, then n is even. QED TODO (2011W1): this silde is very texty and has a 2.5 line parenthetical. Fix? Reduce OTHER texty slides?

9 Outline More Proof Strategies Strategies Summary
Using Logical Equivalences Using Predicate Logic Premises Proof by contradiction Strategies Summary Problems and Discussion Next Lecture Notes

10 Using Predicate Logic Premises: Universals
What can you say if you know (rather than needing to prove) x  D, P(x)? If you know x  D, P(x): You can say P(d) is true for any particular d in D of your choice, for an arbitrary d, or for every d. This is basically the opposite of how we go about proving a universal.

11 Using Predicate Logic Premises: Existentials
What can you say if you know (rather than needing to prove) y  D, Q(y)? If you know y  D, Q(y): Do you know Q(d) is true for every d in D? Do you know Q(d) is true for a particular d of your choice? What do you know? This is basically the opposite of how we go about proving a existential.

12 Using Predicate Logic Premises
What can you say if you know (rather than needing to prove) x  D, P(x) or y  D, Q(y)? If you know x  D, P(x), you can say for any d in D that P(d) is true. You can say P(d) is true for any particular d in D or for an arbitrary one. If you know y  D, Q(y), you can say that for some d in D, Q(d) is true, but you don’t know which one. So, assume nothing more about e than that it’s from D. This is basically the opposite of how we go about proving the statements.

13 Problem: Anti-Symmetric Generally Faster?
Let an algorithm be “generally faster” than another algorithm exactly when it’s faster for all problem sizes n greater than some minimum i. Assume that if one algorithm is faster than another algorithm for any particular n, then the other algorithm is not faster than the first algorithm for that n. Problem: Prove that if one algorithm is generally faster than another, then the other is not generally faster than the first. Prove: Aa, Ab, GF(a,b) -> ~GF(b,a) Given: An, Aa, Ab, F(a,b,n) -> ~F(b,a,n). GF(a,b) = Ei, An, n >= I -> F(a,b,n). WLOG a,b. (2) Assume GF(a,b): Ei1, An1, n1 >= i1 -> F(a,b,n1) Prove: ~Ei2, An2, n2 >= i2 -> F(a,b,n2) which is = to Ai2, En2, n2 >= i2 ^ ~F(a,b,n2). WLOG i2 Pick a convenient n2 = ??? Prove n2 >= i2. (Just pick it large enough.) Prove ~F(a,b,n2). How can we do this? Do our assumptions help? As long as n2 = max(i1, i2), then we know from (2) that F(a,b,n2). PICK n2 large enough! We know from (1) that if F(a,b,n2) then ~F(b,a,n2). QED

14 How Shall We Start Our Strategy?
Witness Inequality proof Antecedent assumption WLOG I have no idea Prove: Aa, Ab, GF(a,b) -> ~GF(b,a) Given: An, Aa, Ab, F(a,b,n) -> ~F(b,a,n). GF(a,b) = Ei, An, n >= I -> F(a,b,n). WLOG a,b. (2) Assume GF(a,b): Ei1, An1, n1 >= i1 -> F(a,b,n1) Prove: ~Ei2, An2, n2 >= i2 -> F(a,b,n2) which is = to Ai2, En2, n2 >= i2 ^ ~F(a,b,n2). WLOG i2 Pick a convenient n2 = ??? Prove n2 >= i2. (Just pick it large enough.) Prove ~F(a,b,n2). How can we do this? Do our assumptions help? As long as n2 = max(i1, i2), then we know from (2) that F(a,b,n2). PICK n2 large enough! We know from (1) that if F(a,b,n2) then ~F(b,a,n2). QED

15 Problem: Anti-Symmetric Generally Faster?
Theorem: If one algorithm is generally faster than another, then the other is not generally faster than the first. WLOG, let a and b be algorithms. Assume a is generally faster than b. Based on the definition of generally faster, then: there is an i such that a is faster than b for all n > i. We now need to prove that b is not generally faster than a, that is that there is no i2 such that b is faster than a for all n2 > i2. Should we prove the negation or try something else? TODO (2011W1): REDUCE complexity of the proof example here.. By the time we get to the end, students have forgotten the beginning! TODO (2011W1): EITHER: do the whole thing on one slide as overview and zoom in on pieces (other projector) OR, do the whole thing by hand while working through strategies/premises/assumptions on the slides. TOO MUCH TEXT! Prove: Aa, Ab, GF(a,b) -> ~GF(b,a) Given: An, Aa, Ab, F(a,b,n) -> ~F(b,a,n). GF(a,b) = Ei, An, n >= I -> F(a,b,n). WLOG a,b. (2) Assume GF(a,b): Ei1, An1, n1 >= i1 -> F(a,b,n1) Prove: ~Ei2, An2, n2 >= i2 -> F(a,b,n2) which is = to Ai2, En2, n2 >= i2 ^ ~F(a,b,n2). WLOG i2 Pick a convenient n2 = ??? Prove n2 >= i2. (Just pick it large enough.) Prove ~F(a,b,n2). How can we do this? Do our assumptions help? As long as n2 = max(i1, i2), then we know from (2) that F(a,b,n2). PICK n2 large enough! We know from (1) that if F(a,b,n2) then ~F(b,a,n2). QED I renamed the variables so I wouldn’t get confused!

16 Problem: Anti-Symmetric Generally Faster?
WLOG, let a and b be algorithms. Assume a is generally faster than b. Based on the definition of generally faster, then: there is an i such that a is faster than b for all n > i. We now need to prove that b is not generally faster than a, that is that there is no i2 such that b is faster than a for all n2 > i2. Instead, we’ll prove the equivalent statement that for all i2, there is an n2 > i2 such that b is not faster than a for problem size n2. Prove: Aa, Ab, GF(a,b) -> ~GF(b,a) Given: An, Aa, Ab, F(a,b,n) -> ~F(b,a,n). GF(a,b) = Ei, An, n >= I -> F(a,b,n). WLOG a,b. (2) Assume GF(a,b): Ei1, An1, n1 >= i1 -> F(a,b,n1) Prove: ~Ei2, An2, n2 >= i2 -> F(a,b,n2) which is = to Ai2, En2, n2 >= i2 ^ ~F(a,b,n2). WLOG i2 Pick a convenient n2 = ??? Prove n2 >= i2. (Just pick it large enough.) Prove ~F(a,b,n2). How can we do this? Do our assumptions help? As long as n2 = max(i1, i2), then we know from (2) that F(a,b,n2). PICK n2 large enough! We know from (1) that if F(a,b,n2) then ~F(b,a,n2). QED

17 How Shall We Continue? Witness Inequality proof Antecedent assumption
WLOG I have no idea Prove: Aa, Ab, GF(a,b) -> ~GF(b,a) Given: An, Aa, Ab, F(a,b,n) -> ~F(b,a,n). GF(a,b) = Ei, An, n >= I -> F(a,b,n). WLOG a,b. (2) Assume GF(a,b): Ei1, An1, n1 >= i1 -> F(a,b,n1) Prove: ~Ei2, An2, n2 >= i2 -> F(a,b,n2) which is = to Ai2, En2, n2 >= i2 ^ ~F(a,b,n2). WLOG i2 Pick a convenient n2 = ??? Prove n2 >= i2. (Just pick it large enough.) Prove ~F(a,b,n2). How can we do this? Do our assumptions help? As long as n2 = max(i1, i2), then we know from (2) that F(a,b,n2). PICK n2 large enough! We know from (1) that if F(a,b,n2) then ~F(b,a,n2). QED

18 Problem: Anti-Symmetric Generally Faster?
Continuing: WLOG, let i2 be a positive integer. Let n2 = ??. (NOTE FOR LATER, better be > i2!) We now need to prove that b is not faster than a for problem size n2. Does our assumption that a is generally faster than b help? Under what conditions? Prove: Aa, Ab, GF(a,b) -> ~GF(b,a) Given: An, Aa, Ab, F(a,b,n) -> ~F(b,a,n). GF(a,b) = Ei, An, n >= I -> F(a,b,n). WLOG a,b. (2) Assume GF(a,b): Ei1, An1, n1 >= i1 -> F(a,b,n1) Prove: ~Ei2, An2, n2 >= i2 -> F(a,b,n2) which is = to Ai2, En2, n2 >= i2 ^ ~F(a,b,n2). WLOG i2 Pick a convenient n2 = ??? Prove n2 >= i2. (Just pick it large enough.) Prove ~F(a,b,n2). How can we do this? Do our assumptions help? As long as n2 = max(i1, i2), then we know from (2) that F(a,b,n2). PICK n2 large enough! We know from (1) that if F(a,b,n2) then ~F(b,a,n2). QED It’s common in scratch work to build up “NOTES FOR LATER” and handle them at the end.

19 Problem: Anti-Symmetric Generally Faster?
Finishing the proof: (NOTE FOR LATER, n2 better be > i as well!) Based on our assumption and since n2 > i, a is faster than b for problem size n2. Based on our initial assumption about “faster”, we know that since a is faster than b for problem size n2, b is not faster than a for problem size n2. QED! Prove: Aa, Ab, GF(a,b) -> ~GF(b,a) Given: An, Aa, Ab, F(a,b,n) -> ~F(b,a,n). GF(a,b) = Ei, An, n >= I -> F(a,b,n). WLOG a,b. (2) Assume GF(a,b): Ei1, An1, n1 >= i1 -> F(a,b,n1) Prove: ~Ei2, An2, n2 >= i2 -> F(a,b,n2) which is = to Ai2, En2, n2 >= i2 ^ ~F(a,b,n2). WLOG i2 Pick a convenient n2 = ??? Prove n2 >= i2. (Just pick it large enough.) Prove ~F(a,b,n2). How can we do this? Do our assumptions help? As long as n2 = max(i1, i2), then we know from (2) that F(a,b,n2). PICK n2 large enough! We know from (1) that if F(a,b,n2) then ~F(b,a,n2). QED (Note: we assumed nothing about i (the existential) but that it’s a positive integer, but we picked n (the universal) to be whatever we want!)

20 Crucial Steps and Where They Came From??

21 Outline More Proof Strategies Strategies Summary
Using Logical Equivalences Using Predicate Logic Premises Proof by contradiction Strategies Summary Problems and Discussion Next Lecture Notes

22 A New Proof Strategy “Proof by Contradiction”
To prove p: Assume ~p. Derive a contradiction. You have then shown that there was something wrong (impossible) about assuming ~p; so, p must be true. Can you use this in predicate logic proofs? Of course you can, just like every other prop logic technique!

23 Example in Dialogue: Prove that Achilles is not Omnipotent
Achilles: I am omnipotent you know. Tortoise: Can you lift a mountain with your mind, no matter how big? Achilles: Of course! Tortoise: Can you make a mountain out of nothing, no matter how big? Achilles: Certainly! Tortoise: Can you make a mountain so big that even you cannot lift it? Achilles: See if I invite you over for dinner again. I stole the characters from Gödel, Escher, Bach. I stole the story from some sci-fi novel.

24 Side Note: Really a New Proof Strategy?
“Assume ~p and derive a contradiction” is the same “assume ~p and prove F”. That’s antecedent assumption! What have we proven? ~p  F What’s that logically equivalent to?

25 Partly Worked Problem: 2 is Irrational
Note: a rational number can be expressed as a/b for some a  Z, b  Z+ with no common factor except 1. Theorem: The 2 is an irrational number. Problem: prove the theorem. This is a tricky problem to even start with. We know from the definition that we want to show 2 cannot be represented as a/b with the constraints given, but where does that get us? Let’s try contradiction, instead.

26 Partly Worked Problem: 2 is Irrational
Theorem: The 2 is an irrational number. Opening steps: (1) Assume for contradiction that 2 is rational. (2) Using our knowledge of rationals, we know 2 = a/b, where a  Z, b  Z+, and a and b have no common factor except 1. [But, we know nothing more about a and b!] Next, play around with the formula 2 = a/b and see where it takes you!

27 Promising Strategies? We know that 2 = a/b.
Which of these feels like the most promising strategy? Solve for a. Solve for b. Square both sides to ditch the radical. Assume 2 is rational. None of these is promising.

28 Proof Scratchwork a = b2 b = a/2 2 = a2/b2 a2 = 2b2 b2 = a2/2 b is a positive integer a and b have no common factors 2011W1: Best to develop on the fly in class, not to just throw up this slide!! Plus, blast from the past: If the square of an integer is even, the integer is even.

29 Finishing the Proof Assume for contradiction that 2 is rational. Then, 2 = a/b for a  Z, b  Z+, where a and b have no common factor except 1. So, a2 = 2b2, and a2 is even. Since a2 is even, a is even (prev. proof!!). a = 2k for some integer k. b2 = a2/2 = (2k)2/2 = 2k2. b2 is even and so is b. Then, b and a share the factor 2. CONTRADICTION! QED (2 is irrational.) Notice: even with proofs, we can break them down into simpler pieces. When we use our previous proof this way, we call it a “lemma”.

30 Outline More Proof Strategies Strategies Summary
Using Logical Equivalences Using Predicate Logic Premises Proof by contradiction Strategies Summary Problems and Discussion Next Lecture Notes

31 Strategies for Predicate Logic Proofs (1 of 2)
Have lots of strategies on hand, and switch strategies when you get stuck: Try using WLOG, exhaustion, or witness approaches to strip the quantifiers Try antecedent assumption on conditionals Try contradiction on the whole statement or as part of other strategies

32 Strategies for Predicate Logic Proofs (2 of 2)
Work forward, playing around with what you can prove from the premises Work backward, considering what you’d need to reach the conclusion Play with the form of both premises and conclusions using logical equivalences Finally, disproving something is just proving its negation.

33 Outline More Proof Strategies Strategies Summary
Using Logical Equivalences Using Predicate Logic Premises Proof by contradiction Strategies Summary Problems and Discussion Next Lecture Notes

34 Problem: Aliens Attack
Aliens hold the Earth hostage and demand that we help them get started proving: x  D, y  E, z  F, (P(x)  Q(x,y))  R(x,z). Problem: Propose four different, promising solution strategies that are each as complete as possible (given the available information) and could be used to address this theorem. This is why a Computer Scientist is always kept on hand at Area 51. That and the “use a computer virus to take out their shields” thing.

35 Problem: Generally Faster than Itself?
Let an algorithm be “generally faster” than another algorithm exactly when it’s faster for all n greater than some minimum i. Assume that no algorithm is faster than itself for any particular n. Problem: Prove that no algorithm is generally faster than itself.

36 Worked Problem: Generally Faster than Itself?
Problem: Prove that no algorithm is generally faster than itself. Let’s roughly translate to predicate logic: “~a that is generally faster than itself”. We don’t have a technique for a ~ on the outside, but we could: (1) disprove a that is generally faster than itself, (2) use proof by contradiction (and assume a that is generally faster than itself), or (3) use De Morgan’s to move the negation inward.

37 Worked Problem: Generally Faster than Itself?
Let’s try: use De Morgan’s to move the negation inward. Using De Morgan’s, “~a that is generally faster than itself” becomes “a ~(a is generally faster than itself)” Now, “consider an arbitrary algorithm a”. We’re down to proving “~(a is generally faster than itself)”.

38 Worked Problem: Generally Faster than Itself?
We’re down to proving “~(a is generally faster than itself)”. From the problem statement: Let an algorithm be “generally faster” than another algorithm exactly when it’s faster for all n greater than some minimum i. Let’s translate to predicate logic: GF(a1, a2) = iN, nN, n > i  Faster(a1, a2, n) GF(a,a) = i  N, n  N, n > i  Faster(a, a, n)

39 Worked Problem: Generally Faster than Itself?
We’re down to proving “~(a is generally faster than itself)”. GF(a,a) = i  N, n  N, n > i  Faster(a, a, n) ~GF(a,a) = ~iN, nN, n > i  Faster(a, a, n) Let’s move the negation inward:  i  N, n  N, ~(n > i  Faster(a, a, n))  i  N, n  N, ~(~(n > i)  Faster(a, a, n))  i  N, n  N, n > i  ~Faster(a, a, n)

40 Worked Problem: Generally Faster than Itself?
We’re down to proving “~(a is generally faster than itself)”. i  N, n  N, n > i  ~Faster(a, a, n) In other words: “for any minimum i, there is a larger number n such that a is not faster than itself for problem size n”.

41 Worked Problem: Generally Faster than Itself?
We now need to prove: “for any minimum i, there is a larger number n such that a is not faster than itself for problem size n.” i  N, n  N, n > i  ~Faster(a, a, n) Consider an arbitrary (positive integer) i. Let n = ??. (Must be > i; so, at least i+1.) So, we need to prove: “a is not faster than itself for problem size ?? (for an arbitrary positive integer i)”

42 Worked Problem: Generally Faster than Itself?
From the problem statement: “Assume that no algorithm is faster than itself for any particular n.” That’s equivalent to: “for every algorithm and n, the algorithm is not faster than itself for problem size n”. By universal instantiation on this premise, a is not faster than itself for problem size ?? (where i is an arbitrary positive integer), whatever ?? might be. So, we just pick ?? = i + 1 to make it larger than i. And.. we’re done!

43 Worked Problem, Short Version: Generally Faster than Itself?
The definition of “generally faster” requires us to pick a “minimum i” after which the first algorithm is always faster than the second for each problem size. Consider an arbitrary algorithm a. Let i be an arbitrary positive integer. We pick a larger value n = i + 1. We know from the premise that a is not faster than itself for any problem size; so, it is not faster than itself for n. Thus, a is not generally faster than itself. QED

44 Worked Problem, Short Version, Different Approach: Generally Faster than Itself?
Assume for contradiction that some algorithm a is generally faster than itself. Then, by the definition of “generally faster”, for all n larger than some minimum i, a is faster than itself. Thus, for any number n1 larger than i (like, n1 = i + 1). a is faster than itself for n1. But, we also assumed that no algorithm (including a) is faster than itself for any particular problem size (including n1). This is a contradiction! QED

45 Outline More Proof Strategies Strategies Summary
Using Logical Equivalences Using Predicate Logic Premises Proof by contradiction Strategies Summary Problems and Discussion Next Lecture Notes

46 Learning Goals: In-Class
By the start of class, you should be able to: Devise and attempt multiple different, appropriate proof strategies—including all those listed in the “pre-class” learning goals plus use of logical equivalences, rules of inference, universal modus ponens/tollens, and predicate premises—for a given theorem. For theorems requiring only simple insights beyond strategic choices or for which the insight is given/hinted, additionally prove the theorem. Discuss point of learning goals.

47 Next Learning Goals: Pre-Class
We are mostly departing from the readings for next class to talk about a new kind of circuit on our way to a full computer: sequential circuits. The pre-class goals are to be able to: Trace the operation of a deterministic finite-state automaton (represented as a diagram) on an input, including indicating whether the DFA accepts or rejects the input. Deduce the language accepted by a simple DFA after working through multiple example inputs.

48 Next Lecture Prerequisites
See the “Sequential Circuits” readings at the bottom of the “Readings and Equipment” area of the website. Complete the open-book, untimed quiz on Vista that was due before class.

49 (on your own or if we have time)
More problems to solve... (on your own or if we have time)

50 Problem: Generally, Transitively Faster?
Continue with our previous assumptions about faster/generally faster. Assume that our faster predicate is transitive (Faster(a1, a2, n) and Faster(a2, a3, n) implies Faster(a1, a3, n)). Problem: Prove that if one algorithm is generally faster than a second, and if the second algorithm is generally faster than a third, then the first algorithm is also generally faster than the third.

51 More More Practice: A Representation for Every Number
Prove that any non-negative integer can be represented using a finite number of bits as an unsigned binary number. (Don’t) Prove that with a finite number of bits, we can represent any non-negative integer as an unsigned binary number. (What’s different between these two? Why can’t we prove the second? How would we disprove it?)


Download ppt "CPSC 121: Models of Computation 2012 Summer Term 2"

Similar presentations


Ads by Google