Presentation is loading. Please wait.

Presentation is loading. Please wait.

Snick  snack CPSC 121: Models of Computation 2012 Summer Term 2 Proof (First Visit) Steve Wolfman, based on notes by Patrice Belleville, Meghan Allen.

Similar presentations


Presentation on theme: "Snick  snack CPSC 121: Models of Computation 2012 Summer Term 2 Proof (First Visit) Steve Wolfman, based on notes by Patrice Belleville, Meghan Allen."— Presentation transcript:

1 snick  snack CPSC 121: Models of Computation 2012 Summer Term 2 Proof (First Visit) Steve Wolfman, based on notes by Patrice Belleville, Meghan Allen and others 1 This work is licensed under a Creative Commons Attribution 3.0 Unported License.Creative Commons Attribution 3.0 Unported License

2 Announcements Slide Lab A (12:30-2:30) is too full; please do not attend if you are not registered for it! Thoughts on labs –“functions” everywhere: MUXes and priority chain –the simplified ALU –lab leaping ahead soon on “memory” and “events” –no new lab material Friday the 13 th 2

3 Outline Prereqs, Learning Goals, and Quiz Notes Prelude: What Is Proof? Problems and Discussion –“Prove Your Own Adventure” –Why rules of inference? (advantages + tradeoffs) –Onnagata, Explore and Critique Next Lecture Notes 3

4 Learning Goals: Pre-Class By the start of class, you should be able to: –Use truth tables to establish or refute the validity of a rule of inference. –Given a rule of inference and propositional logic statements that correspond to the rule’s premises, apply the rule to infer a new statement implied by the original statements. 4

5 Learning Goals: In-Class By the end of this unit, you should be able to: –Explore the consequences of a set of propositional logic statements by application of equivalence and inference rules, especially in order to massage statements into a desired form. –Critique a propositional logic proof; that is, determine whether or not is valid (and explain why) and judge the applicability of its result to a specific context. –Devise and attempt multiple different, appropriate strategies for proving a propositional logic statement follows from a list of premises. 5

6 Where We Are in The Big Stories Theory How do we model computational systems? Now: Continuing to build the foundation for our proofs. (We’ll get to the level of proof we really need starting with the next unit.) Hardware How do we build devices to compute? Now: Taking a bit of a vacation in lecture! 6

7 Motivating Problem: Changing cond Branches Assuming that a and c cannot both be true and that this function produces true: ;; Boolean Boolean Boolean Boolean -> Boolean (define (rearrange-cond? a b c d) (cond [a b] [c d] [else e])) Prove that the following function also produces true: ;; Boolean Boolean Boolean Boolean -> Boolean (define (rearrange-cond? a b c d) (cond [c d] [a b] [else e])) 7 But first, prove these handy “lemmas”: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) (Reality check: you must be able to do formal proofs. But, as with using equivalence laws to reorganize code, in practice you’ll often reason using proof techniques but without a formal proof.)

8 Quiz 4 Notes (1 of 4) Why do we want “valid” rules? Consider.. p q  p  q Can q be false when p and q  p are both true? a.Yes b.No c.Not enough information d.I don’t know 8

9 Quiz 4 Notes (2 of 4) “Degenerate” cases: p  ~p  cup_for_canucks Can cup_for_canucks be false when (p  ~p) is true? a.Yes b.No c.Not enough information d.I don’t know 9

10 Quiz 4 Notes (3 of 4) a  b b  c  a  c To apply this to: p  (q  r) q  s..what must we replace b with? a.p b.q c.(q  r) d.Something else e.We cannot apply it 10 Next set of quiz notes will come much later!

11 NOT a Quiz Note ~p  ~(p v q) a.This is valid by generalization (p  p v q). b.This is valid because anytime ~p is true, ~(p v q) is also true. c.This is invalid by generalization (p  p v q). d.This is invalid because when p = F and q = T, ~p is true but ~(p v q) is false. e.None of these. 11

12 What does this mean? We can always substitute something equivalent for a subexpression of a logical expression. We cannot always apply a rule of inference to just a part of a logical statement. Therefore, we will only apply rules of inference to complete statements, no matter what! 12

13 Outline Prereqs, Learning Goals, and Quiz Notes Prelude: What Is Proof? Problems and Discussion –“Prove Your Own Adventure” –Why rules of inference? (advantages + tradeoffs) –Onnagata, Explore and Critique Next Lecture Notes 13

14 What is Proof? A rigorous formal argument that unequivocally demonstrates the truth of a proposition, given the truth of the proof’s premises. Adapted from MathWorld: http://mathworld.wolfram.com/Proof.htmlhttp://mathworld.wolfram.com/Proof.html 14

15 What is Proof? A rigorous formal argument that unequivocally demonstrates the truth of a proposition (conclusion), given the truth of the proof’s premises. Adapted from MathWorld: http://mathworld.wolfram.com/Proof.htmlhttp://mathworld.wolfram.com/Proof.html 15

16 Problem: Meaning of Proof Let’s say you prove the following: Premise 1 Premise 2 Premise n  Conclusion What does this mean? a.Premises 1 to n are true b.Conclusion is true c.Premises 1 to n can be true d.Conclusion can be true e.None of the above 16

17 Tasting Powerful Proof: Some Things We Might Prove We can build a “three-way switch” system with any number of switches. We can build a combinational circuit matching any truth table. We can build any digital logic circuit using nothing but NOR gates. We can sort a list by breaking it in half, and then sorting and merging the halves. We can find the GCD of two numbers by finding the GCD of the 2 nd and the remainder when dividing the 1 st by the 2 nd. Is there any fair way to run elections? Are there problems that no program can solve? Meanwhile... 17

18 What Is a Propositional Logic Proof? An argument in which (1) each line is a propositional logic statement, (2) each statement is a premise or follows unequivocally by a previously established rule of inference from the truth of previous statements, and (3) the last statement is the conclusion. A very constrained form of proof, but a good starting point. Interesting proofs will usually come in less structured packages than propositional logic proofs. 18

19 Outline Prereqs, Learning Goals, and Quiz Notes Prelude: What Is Proof? Problems and Discussion –“Prove Your Own Adventure” –Why rules of inference? (advantages + tradeoffs) –Onnagata, Explore and Critique Next Lecture Notes 19

20 Prop Logic Proof Problem To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 20

21 “Prove Your Own Adventure” To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p Which step is the easiest to fill in? 1. ~(q  r)Premise 2. (u  q)  sPremise 3. ~s  ~pPremise [STEP A: near the start] [STEP B: in the middle] [STEP C: near the end] [STEP D: last step] 21

22 D: Last Step To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise... ~q  ~r De Morgan’s (1) ~q Specialization (?)... ((u  q)  s)  Bicond (2) (s  (u  q))... ~s ~p Modus ponens (3,?) Why do we want to put ~p at the end? a.~p is the proof’s conclusion b.~p is the end of the last premise c.every proof ends with ~p d.None of these but some other reason e.None of these because we don’t want it there 22

23 C: Near the End To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise... ~q  ~r De Morgan’s (1) ~q Specialization (?)... ((u  q)  s)  Bicond (2) (s  (u  q))... ~s ~p Modus ponens (3,?) Why do we want to put the blue line/justification at the end? a.~s  ~p is the last premise b.~s  ~p is the only premise that mentions ~s c.~s  ~p is the only premise that mentions p d.None of these but some other reason e.None of these b/c we don’t want it there 23

24 A: Near the Start To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise... ~q  ~r De Morgan’s (1) ~q Specialization (?)... ((u  q)  s)  Bicond (2) (s  (u  q))... ~s ~p Modus ponens (3,?) Why do we want the blue lines/justifications? a.~(q  r) is the first premise b.~(q  r) is a useless premise c.We can’t work directly with a premise with a negation “on the outside” d.Neither the conclusion nor another premise mentions r e.None of these 24

25 B: In the Middle To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise... ~q  ~r De Morgan’s (1) ~q Specialization (?)... ((u  q)  s)  Bicond (2) (s  (u  q))... ~s ~p Modus ponens (3,?) Why do we want the blue line/justification? a.(u  q)  s is the only premise left b.(u  q)  s is the only premise that mentions u c.(u  q)  s is the only premise that mentions s without a negation d.We have no rule to get directly from one side of a biconditional to the other e.None of these 25

26 D: Last Step To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise... ~q  ~r De Morgan’s (1) ~q Specialization (?)... ((u  q)  s)  Bicond (2) (s  (u  q))... ~s ~p Modus ponens (3,?) 26

27 Why put the blue line at the end? a.~p is the proof’s conclusion b.~p is the end of the last premise c.every proof ends with ~p d.None of these but some other reason e.None of these because we don’t want it there 27

28 C: Near the End To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise... ~q  ~r De Morgan’s (1) ~q Specialization (?)... ((u  q)  s)  Bicond (2) (s  (u  q))... ~s ~p Modus ponens (3,?) 28

29 Why put the blue line and justification in? a.~s  ~p is the last premise b.~s  ~p is the only premise that mentions ~s c.~s  ~p is the only premise that mentions p d.None of these but some other reason e.None of these b/c we don’t want it there 29

30 A: Near the Start To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise... ~q  ~r De Morgan’s (1) ~q Specialization (?)... ((u  q)  s)  Bicond (2) (s  (u  q))... ~s ~p Modus ponens (3,?) 30

31 Why put the blue lines and justifications in? a.~(q  r) is the first premise b.~(q  r) is a useless premise c.We can’t work directly with a premise with a negation “on the outside” d.Neither the conclusion nor another premise mentions r e.None of these 31

32 B: In the Middle To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise... ~q  ~r De Morgan’s (1) ~q Specialization (?)... ((u  q)  s)  Bicond (2) (s  (u  q))... ~s ~p Modus ponens (3,?) 32

33 Why put the blue line and justification in? a.(u  q)  s is the only premise left b.(u  q)  s is the only premise that mentions u c.(u  q)  s is the only premise that mentions s without a negation d.We have no rule to get directly from one side of a biconditional to the other e.None of these 33

34 Prop Logic Proof Strategies Work backwards from the end Play with alternate forms of premises Identify and eliminate irrelevant information Identify and focus on critical information Alter statements’ forms so they’re easier to work with “Step back” from the problem frequently to think about assumptions you might have wrong or other approaches you could take And, if you don’t know that what you’re trying to prove follows... switch from proving to disproving and back now and then. 34

35 Continuing From There To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise 4. ~q  ~r De Morgan’s (1) 5. ~q Specialization (4) 6. ((u  q)  s)  Bicond (2) (s  (u  q)) 7. ?????? Specialization (6)... ~s ~p Modus ponens (3,?) Which direction of  goes in step 7? a.(u  q)  s because the simple part is on the right b.(u  q)  s because the other direction can’t establish ~s c.s  (u  q) because the simple part is on the left d.s  (u  q) because the other direction can’t establish ~s e.None of these 35

36 Continuing From There To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise 4. ~q  ~r De Morgan’s (1) 5. ~q Specialization (4) 6. ((u  q)  s)  Bicond (2) (s  (u  q)) 7. ?????? Specialization (6)... ~s ~p Modus ponens (3,?) 36

37 Which direction of  goes in step 7? a.(u  q)  s because the simple part is on the right b.(u  q)  s because the other direction can’t establish ~s c.s  (u  q) because the simple part is on the left d.s  (u  q) because the other direction can’t establish ~s e.None of these 37

38 Aside: What does it mean to “work backward”? Take the conclusion of the proof. Use a rule in reverse to generate something closer to a statement you already have (like a premise). 38

39 Finishing Up (1 of 3) To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise 4. ~q  ~r De Morgan’s (1) 5. ~q Specialization (4) 6. ((u  q)  s)  Bicond (2) (s  (u  q)) 7. s  (u  q) Specialization (6) 8. ???? ???? 9. ~(u  q) ???? 10. ~s Modus tollens (7, 9) 11. ~p Modus ponens (3,10) We know we needed ~(u  q) on line 9 because that’s what we created line 7 for! Side Note: Can we work directly with a statement with a negation “on the outside”? 39

40 Finishing Up (1 of 3) To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise 4. ~q  ~r De Morgan’s (1) 5. ~q Specialization (4) 6. ((u  q)  s)  Bicond (2) (s  (u  q)) 7. s  (u  q) Specialization (6) 8. ???? ???? 9. ~(u  q) ???? 10. ~s Modus tollens (7, 9) 11. ~p Modus ponens (3,10) We know we needed ~(u  q) on line 9 because that’s what we created line 7 for! Now, how do we get ~(u  q)? Working forward is tricky. Let’s work backward. What is ~(u  q) equivalent to? 40

41 Finishing Up (2 of 3) To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise 4. ~q  ~r De Morgan’s (1) 5. ~q Specialization (4) 6. ((u  q)  s)  Bicond (2) (s  (u  q)) 7. s  (u  q) Specialization (6) 8. ~u  ~q ???? 9. ~(u  q) De Morgan’s (8) 10. ~s Modus tollens (7, 9) 11. ~p Modus ponens (3,10) All that’s left is to get to ~u  ~q. How do we do it? 41

42 Finishing Up (3 of 3) To prove: ~(q  r) (u  q)  s ~s  ~p___  ~p 1. ~(q  r) Premise 2. (u  q)  s Premise 3. ~s  ~p Premise 4. ~q  ~r De Morgan’s (1) 5. ~q Specialization (4) 6. ((u  q)  s)  Bicond (2) (s  (u  q)) 7. s  (u  q) Specialization (6) 8. ~u  ~q Generalization (5) 9. ~(u  q) De Morgan’s (8) 10. ~s Modus tollens (7, 9) 11. ~p Modus ponens (3,10) As usual in our slides, we made no mistakes and reached no dead ends. That’s not the way things really go on difficult proofs! Mistakes and dead ends are part of the discovery process! So, step back now and then and reconsider your assumptions and approach! 42

43 Outline Prereqs, Learning Goals, and Quiz Notes Prelude: What Is Proof? Problems and Discussion –“Prove Your Own Adventure” –Why rules of inference? (advantages + tradeoffs) –Onnagata, Explore and Critique Next Lecture Notes 43

44 Limitations of Truth Tables Why not just use truth tables to prove propositional logic theorems? a.No reason; truth tables are enough. b.Truth tables scale poorly to large problems. c.Rules of inference and equivalence rules can prove theorems that cannot be proven with truth tables. d.Truth tables require insight to use, while rules of inference can be applied mechanically. 44

45 Limitations of Logical Equivalences Why not use logical equivalences to prove that the conclusions follow from the premises? a.No reason; logical equivalences are enough. b.Logical equivalences scale poorly to large problems. c.Rules of inference and truth tables can prove theorems that cannot be proven with logical equivalences. d.Logical equivalences require insight to use, while rules of inference can be applied mechanically. 45

46 Outline Prereqs, Learning Goals, and Quiz Notes Prelude: What Is Proof? Problems and Discussion –“Prove Your Own Adventure” –Why rules of inference? (advantages + tradeoffs) –Onnagata: Explore and Critique Next Lecture Notes 46

47 Preparatory Comments When we apply logic to a domain, we give interpretations for the logical symbols. That interpretation is where we can argue things like “meaning”, “values”, and “moral right”. Within the logical context, we argue purely on the basis of structure and irrefutable manipulations of that structure. And… statements contradict each other when, taken together, they are logically equivalent to F. There is no way for them to be simultaneously true. 47

48 Problem: Onnagata Problem: Critique the following argument. Premise 1: If women are too close to femininity to portray women then men must be too close to masculinity to play men, and vice versa. Premise 2: And yet, if the onnagata are correct, women are too close to femininity to portray women and yet men are not too close to masculinity to play men. Conclusion: Therefore, the onnagata are incorrect, and women are not too close to femininity to portray women. 48

49 Quiz 4 Notes (4 of 4) Approaches: Use our model! Prove with a truth table Trace the argument Build a new argument and see where it leads Assume the opposite of the conclusion and see what happens Question the premises 49

50 Contradictory Premises? Do premises #1 and #2 contradict each other (i.e., is (premise1  premise2) logically equivalent to F)? a. Yes b. No c. Not enough information to tell. 50

51 Defining the Problem Which definitions should we use? a. w = women, m = men, f = femininity, m = masculinity, o = onnagata, c = correct b. w = women are too close to femininity, m = men are too close to masculinity, pw = women portray women, pm = men portray men, o = onnagata are correct c. w = women are too close to femininity to portray women, m = men are too close to masculinity to portray men, o = onnagata are correct d. None of these, but another set of definitions works well. e. None of these, and this problem cannot be modeled well with propositional logic. 51

52 Translating the Statements Which of these is not an accurate translation of one of the statements? a.w  m b.(w  m)  (m  w) c.o  (w  ~m) d.~o  ~w e.All of these are accurate translations. 52

53 Contradictory Premises? So premises #1 and #2 are w  m and o  (w  ~m). Do premises #1 and #2 contradict each other (i.e., is (premise1  premise2) logically equivalent to F)? a. Yes b. No c. Not enough information to tell. 53

54 Problem: Now, Explore! Critique the argument by either: (1) Proving it correct (and commenting on how good the propositional logic model’s fit to the context is). How do we prove prop logic statements? (2) Showing that it is an invalid argument. How do we show an argument is invalid? (Remember the quiz!) 54

55 Outline Prereqs, Learning Goals, and Quiz Notes Prelude: What Is Proof? Problems and Discussion –“Prove Your Own Adventure” –Why rules of inference? (advantages + tradeoffs) –Onnagata, Explore and Critique Next Lecture Notes 55

56 Next Lecture Learning Goals: Pre-Class By the start of class, you should be able to: –Evaluate the truth of statements that include predicates applied to particular values. –Show predicate logic statements are true by enumerating examples (i.e., all examples in the domain for a universal or one for an existential). –Show predicate logic statements are false by enumerating counterexamples (i.e., one counterexample for universals or all in the domain for existentials). –Translate between statements in formal predicate logic notation and equivalent statements in closely matching informal language (i.e., informal statements with clear and explicitly stated quantifiers). 56

57 Next Lecture Prerequisites Review (Epp 4 th ed) Chapter 2 and be able to solve any Chapter 2 exercise. Read Sections 3.1 and 3.3 (skipping the “Negation” sections in 3.3) Complete the open-book, untimed quiz on Vista. 57

58 Motivating Problem: Changing cond Branches Assuming that a and c cannot both be true and that this function produces true: ;; Boolean Boolean Boolean Boolean -> Boolean (define (rearrange-cond? a b c d) (cond [a b] [c d] [else e])) Prove that the following function also produces true: ;; Boolean Boolean Boolean Boolean -> Boolean (define (rearrange-cond? a b c d) (cond [c d] [a b] [else e])) 58 First, prove these handy “lemmas”: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r)

59 Motivating Problem: Changing cond Branches Assuming that a and c cannot both be true, and that this function produces true: ;; Boolean Boolean Boolean Boolean -> Boolean (define (rearrange-cond? a b c d) (cond [a b] [c d] [else e])) We leave the lemmas as an exercise: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) In prop logic: 1.~(a  b)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.… 4.(c  d)  (~c  ((a  b)  (~a  e)))target conclusion 59 We’ll use our “heuristics” to work forward and backward until we solve the problem.

60 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.… 4.(c  d)“subgoal” 5.(~c  ((a  b)  (~a  e)))“subgoal” 6.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 4, 5 60 Lemmas: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) We start by working backward; how de we prove x  y? Well, one way is to prove x and also prove y. We’ll break those into two separate subproblems! Side note: we’ll use the two statements you proved as exercises as “lemmas”: rules we proved for use in this proof. (Want to use them on an assignment / exam? Prove them there!)

61 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.… 4.(c  d)“subgoal” 5.(~c  (a  b))  (~c  (~a  e)))“subgoal” 6.(~c  ((a  b)  (~a  e)))Lemma 1 on 5 7.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 4, 6 61 Lemmas: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) The second of these subgoals is still huge. We decided to break it into two pieces (and that’s why we went off and proved Lemma 1).

62 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.… 4.(c  d)“subgoal” 5.~c  (a  b) “subgoal” 6.~c  (~a  e)“subgoal” 7.(~c  (a  b))  (~c  (~a  e)))by CONJ on 5, 6 8.(~c  ((a  b)  (~a  e)))Lemma 1 on 7 9.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 4, 8 62 Lemmas: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) Now, we can attack those two pieces separately (which feels like it might be the wrong approach to me… but worth a try!)

63 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.… 5.(c  d)“subgoal” 6.~c  (a  b) “subgoal” 7.~c  (~a  e)“subgoal” 8.(~c  (a  b))  (~c  (~a  e)))by CONJ on 6, 7 9.(~c  ((a  b)  (~a  e)))Lemma 1 on 8 10.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 5, 9 63 Lemmas: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) I’m out of ideas at the end. I switch to the beginning and play around with premises. (Foreshadowing: I didn’t figure out what to do with this premise until near the end.)

64 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.… 6.(c  d)“subgoal” 7.~c  (a  b) “subgoal” 8.~c  (~a  e)“subgoal” 9.(~c  (a  b))  (~c  (~a  e)))by CONJ on 7, 8 10.(~c  ((a  b)  (~a  e)))Lemma 1 on 9 11.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 6, 10 64 Lemmas: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) Let’s try the other premise.

65 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.… 7.(c  d)“subgoal” 8.~c  (a  b) “subgoal” 9.~c  (~a  e)“subgoal” 10.(~c  (a  b))  (~c  (~a  e)))by CONJ on 8, 9 11.(~c  ((a  b)  (~a  e)))Lemma 1 on 10 12.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 7, 11 65 Lemmas: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) Continuing with that premise… Hey! We can use our Lemma again!

66 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.… 8.(c  d)“subgoal” 9.~c  (a  b) “subgoal” 10.~c  (~a  e)“subgoal” 11.(~c  (a  b))  (~c  (~a  e)))by CONJ on 9, 10 12.(~c  ((a  b)  (~a  e)))Lemma 1 on 11 13.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 8, 12 66 Lemmas: 1.p  (q  r)  (p  q)  (p  r) 2.p  (q  r)  q  (p  r) Continuing with that premise…

67 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.~a  (c  d) by SPEC on 6 8.… 9.(c  d)“subgoal” 10.~c  (a  b) “subgoal” 11.~c  (~a  e)“subgoal” 12.(~c  (a  b))  (~c  (~a  e)))by CONJ on 10, 11 13.(~c  ((a  b)  (~a  e)))Lemma 1 on 12 14.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 9, 13 67 Lemma 2: p  (q  r)  q  (p  r) Continuing with that premise…

68 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.~a  (c  d) by SPEC on 6 8.~a  (~c  e) by SPEC on 6 9.… 10.(c  d)“subgoal” 11.~c  (a  b) “subgoal” 12.~c  (~a  e)“subgoal” 13.(~c  (a  b))  (~c  (~a  e)))by CONJ on 11, 12 14.(~c  ((a  b)  (~a  e)))Lemma 1 on 13 15.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 10, 14 68 AHA!! Lemma 2: p  (q  r)  q  (p  r) Continuing with that premise… We treated connecting these as its own problem and came up with Lemma 2!

69 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.~a  (c  d) by SPEC on 6 8.~a  (~c  e) by SPEC on 6 9.… 10.(c  d)“subgoal” 11.~c  (a  b) “subgoal” 12.~c  (~a  e)by Lemma 2 on 8 13.(~c  (a  b))  (~c  (~a  e)))by CONJ on 11, 12 14.(~c  ((a  b)  (~a  e)))Lemma 1 on 13 15.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 10, 14 69 Lemma 2: p  (q  r)  q  (p  r) Lemma 2 let’s us connect these directly! Now what. Let’s pause, remind ourselves what our (sub)goals are, and look at what we have.

70 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.~a  (c  d) by SPEC on 6 8.~a  (~c  e) by SPEC on 6 9.… 10.(c  d)“subgoal” 11.~c  (a  b) “subgoal” 12.~c  (~a  e)by Lemma 2 on 8 13.(~c  (a  b))  (~c  (~a  e)))by CONJ on 11, 12 14.(~c  ((a  b)  (~a  e)))Lemma 1 on 13 15.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 10, 14 70 Hmm.. Lemma 2: p  (q  r)  q  (p  r) How do we do something with this? Again, we treated this as a separate problem:

71 Motivating Problem: Changing cond Branches Subproblem: 1. a  b premise 2.… 3.~c  (a  b) “subgoal” 71 Now we do our usual. Get rid of , work backward, work forward… This time, we’ll show you what we did. We broke out the goal and starting point and turned them into a whole other proof problem!

72 Motivating Problem: Changing cond Branches Subproblem: 1. a  b premise 2.~a  bby IMP on 1 3.… 4.c  ~a  b “subgoal” 5.c  (a  b) by IMP on 4 6.~c  (a  b) by IMP on 5 72 That’s about as far as dumping  can take us. But, look at step 2 and step 4. What’s the difference?

73 Motivating Problem: Changing cond Branches Subproblem: 1. a  b premise 2.~a  bby IMP on 1 3.c  ~a  b by GEN on 2 4.c  (a  b) by IMP on 3 5.~c  (a  b) by IMP on 4 73 Great! We can always OR on something else. We did it! Let’s patch it back into the original proof. But… could we have done it more easily? Question your solutions! (Hint: check out line 4. How can you get there?)

74 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.~a  (c  d) by SPEC on 6 8.~a  (~c  e) by SPEC on 6 9.… 10.(c  d)“subgoal” 11.c  (a  b) “subgoal” 12.~c  (a  b) by IMP on 11 13.~c  (~a  e)by Lemma 2 on 8 14.(~c  (a  b))  (~c  (~a  e)))by CONJ on 12, 13 15.(~c  ((a  b)  (~a  e)))Lemma 1 on 14 16.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 10, 15 74 Patching in “step 4” of the previous proof. Can it get us back to step 4 of this proof?

75 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.~a  (c  d) by SPEC on 6 8.~a  (~c  e) by SPEC on 6 9.… 10.(c  d)“subgoal” 11.c  (a  b) by GEN on 4 12.~c  (a  b) by IMP on 11 13.~c  (~a  e)by Lemma 2 on 8 14.(~c  (a  b))  (~c  (~a  e)))by CONJ on 12, 13 15.(~c  ((a  b)  (~a  e)))Lemma 1 on 14 16.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 10, 15 75 Sure! In one step! Now what? Only one subgoal left. How does it connect to the top of the proof?

76 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.~a  (c  d) by SPEC on 6 8.~a  (~c  e) by SPEC on 6 9.… 10.(c  d)“subgoal” 11.c  (a  b) by GEN on 4 12.~c  (a  b) by IMP on 11 13.~c  (~a  e)by Lemma 2 on 8 14.(~c  (a  b))  (~c  (~a  e)))by CONJ on 12, 13 15.(~c  ((a  b)  (~a  e)))Lemma 1 on 14 16.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 10, 15 76 Hmm… That works if a is false. Can we make a false? What if a is true?

77 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.a  bby SPEC on 2 5.~a  ((c  d)  (~c  e))by SPEC on 2 6.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 5 7.~a  (c  d) by SPEC on 6 8.~a  (~c  e) by SPEC on 6 9.… 10.(c  d)“subgoal” 11.c  (a  b) by GEN on 4 12.~c  (a  b) by IMP on 11 13.~c  (~a  e)by Lemma 2 on 8 14.(~c  (a  b))  (~c  (~a  e)))by CONJ on 12, 13 15.(~c  ((a  b)  (~a  e)))Lemma 1 on 14 16.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 10, 15 77 If a is true, then c isn’t. If c’s not true, then c  d is true. Let’s put that in logic! I looked around for a way to establish ~a but couldn’t. So, I checked what happens if a is true.

78 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.~a  ~c  dby GEN on 3 5.a  bby SPEC on 2 6.~a  ((c  d)  (~c  e))by SPEC on 2 7.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 6 8.~a  (c  d) by SPEC on 7 9.~a  (~c  e) by SPEC on 7 10.… 11.(c  d)“subgoal” 12.c  (a  b) by GEN on 5 13.~c  (a  b) by IMP on 12 14.~c  (~a  e)by Lemma 2 on 9 15.(~c  (a  b))  (~c  (~a  e)))by CONJ on 13, 14 16.(~c  ((a  b)  (~a  e)))Lemma 1 on 15 17.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 11, 16 78 We need to “fabricate” a d. The rest will be just IMP applications.

79 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.~a  ~c  dby GEN on 3 5.~a  (c  d)by IMP on 4 6.a  (c  d)by IMP on 5 7.a  bby SPEC on 2 8.~a  ((c  d)  (~c  e))by SPEC on 2 9.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 8 10.~a  (c  d) by SPEC on 9 11.~a  (~c  e) by SPEC on 9 12.… 13.(c  d)“subgoal” 14.c  (a  b) by GEN on 7 15.~c  (a  b) by IMP on 14 16.~c  (~a  e)by Lemma 2 on 11 17.(~c  (a  b))  (~c  (~a  e)))by CONJ on 15, 16 18.(~c  ((a  b)  (~a  e)))Lemma 1 on 17 19.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 13, 18 79 Now, we put these together, and we’re done!

80 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise 3.~a  ~cby DM on 1 4.~a  ~c  dby GEN on 3 5.~a  (c  d)by IMP on 4 6.a  (c  d)by IMP on 5 7.a  bby SPEC on 2 8.~a  ((c  d)  (~c  e))by SPEC on 2 9.(~a  (c  d))  (~a  (~c  e))by Lemma 1 on 8 10.~a  (c  d) by SPEC on 9 11.(~a  a)  (c  d) by CASE on 10, 6 12.T  (c  d) by NEG on 11 13.(c  d)by M.PON on 12, T 14.~a  (~c  e) by SPEC on 9 15.c  (a  b) by GEN on 7 16.~c  (a  b) by IMP on 15 17.~c  (~a  e)by Lemma 2 on 14 18.(~c  (a  b))  (~c  (~a  e)))by CONJ on 16, 17 19.(~c  ((a  b)  (~a  e)))Lemma 1 on 18 20.(c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 13, 19 80 (At step 14, no need to separately establish T. T is a “tautology”; it’s always true!) QED!! Whew!

81 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise … 20. (c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 13, 19 81 So, what did that prove? Technically: that if the conditions on the cond branches are mutually exclusive (cannot both be true at the same time) and if the result of the original version was true, then the version with switched cond branches will also be true. In fact, if you go back and think carefully about the proof, we can conclude something much bigger without too much more work: “If two conditions on neighboring cond branches are mutually exclusive (and have no ‘side effects’), we can switch those branches without changing the meaning of the program.”

82 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise … 20. (c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 13, 19 82 For reference: fruitless directions I tried include changing a  b to ~a  b, attempting to form the negation of c  d, and a bunch of other false starts… all of which helped me build pieces I needed for my final strategy! You should have lots of scratchwork if you do a problem this large.

83 Motivating Problem: Changing cond Branches In prop logic: 1.~(a  c)premise 2.(a  b)  (~a  ((c  d)  (~c  e)))premise … 20. (c  d)  (~c  ((a  b)  (~a  e)))by CONJ on 13, 19 83 Exercise: We can translate code like: (if a b c) To logic like this instead of our usual: (a  b)  (~a  c) Prove that they’re equivalent. Then, figure out how a cond would similarly translate. Finally, go back and redo some of our proofs (like the one we just did) with the new representation.

84 snick  snack More problems to solve... (on your own or if we have time) 84

85 Problem: Who put the cat in the piano? Hercule Poirot has been asked by Lord Martin to find out who closed the lid of his piano after dumping the cat inside. Poirot interrogates two of the servants, Akilna and Eiluj. One and only one of them put the cat in the piano. Plus, one always lies and one never lies. Akilna says: –Eiluj did it. –Urquhart paid her $50 to help him study. Eiluj says: –I did not put the cat in the piano. –Urquhart gave me less than $60 to help him study. Problem: Whodunit? 85

86 Problem: Automating Proof Given: p  q p  ~q  r (r  ~p)  s  ~p ~r Problem: What’s everything you can prove? 86

87 Problem: Canonical Form A common form for propositional logic expressions, called “disjunctive normal form” or “sum of products form”, looks like this: (a  ~b  d)  (~c)  (~a  ~d)  (b  c  d  e) ... In other words, each clause is built up of simple propositions or their negations, ANDed together, and all the clauses are ORed together. 87

88 Problem: Canonical Form Problem: Prove that any propositional logic statement can be expressed in disjunctive normal form. 88

89 Mystery #1 Theorem: p  q q  (r  s) ~r  (~t  u) p  t  u Is this argument valid or invalid? Is whatever u means true? 89

90 Mystery #2 Theorem: p p  r p  (q  ~r) ~q  ~s  s Is this argument valid or invalid? Is whatever s means true? 90

91 Mystery #3 Theorem: q p  m q  (r  m) m  q  p Is this argument valid or invalid? Is whatever p means true? 91

92 Practice Problem (for you!) Prove (with truth tables) that hypothetical syllogism is a valid rule of inference: p  q q  r  p  r 92

93 Practice Problem (for you!) Prove (with truth tables) whether this is a valid rule of inference: q p  q  p 93

94 Practice Problem (for you!) Are the following arguments valid? This apple is green. If an apple is green, it is sour.  This apple is sour. Sam is not barking. If Sam is barking, then Sam is a dog.  Sam is not a dog. 94

95 Practice Problem (for you!) Are the following arguments valid? This shirt is comfortable. If a shirt is comfortable, it’s chartreuse.  This shirt is chartreuse. It’s not cold. If it’s January, it’s cold.  It’s not January. Is valid (as a term) the same as true or correct (as English ideas)? 95

96 More Practice Meghan is rich. If Meghan is rich, she will pay your tuition.  Meghan will pay your tuition. Is this argument valid? Should you bother sending in a check for your tuition, or is Meghan going to do it? 96

97 Problem: Equivalent Java Programs Problem: How many valid Java programs are there that do exactly the same thing? 97

98 Resources: Statements From the Java language specification, a standard statement is one that can be: http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.5 98

99 Resources: Statements From the Java language specification, a standard statement is one that can be: http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.5 99

100 What’s a “ Block ”? Back to the Java Language Specification: http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.2 100

101 What’s a “ Block ”? A block is a sequence of statements, local class declarations and local variable declaration statements within braces. … A block is executed by executing each of the local variable declaration statements and other statements in order from first to last (left to right). 101

102 What’s an “ EmptyStatement ” Back to the Java Language Specification: http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.6 102

103 Problem: Validity of Arguments Problem: If an argument is valid, does that mean its conclusion is true? If an argument is invalid, does that mean its conclusion is false? 103

104 Problem: Proofs and Contradiction Problem: Imagine I assume premises x, y, and z and prove F. What can I conclude (besides “false is true if x, y, and z are true”)? 104

105 Proof Critique Theorem: √2 is irrational Proof: Assume √2 is rational, then... There’s some integers p and q such that √2 = p/q, and p and q share no factors. 2 = (p/q) 2 = p 2 /q 2 and p 2 = 2q 2 p 2 is divisible by 2; so p is divisible by 2. There’s some integer k such that p = 2k. q 2 = p 2 /2 = (2k) 2 /2 = 2k 2 ; so q 2 and q are divisible by 2. p and q do share the factor 2, a contradiction! √2 is irrational. QED 105

106 Problem: Comparing Deduction and Equivalence Rules Problem: How are logical equivalence rules and deduction rules similar and different, in form, function, and the means by which we establish their truth? 106

107 Problem: Evens and Integers Problem: Which are there more of, (a) positive even integers, (b) positive integers, or (c) neither? 107


Download ppt "Snick  snack CPSC 121: Models of Computation 2012 Summer Term 2 Proof (First Visit) Steve Wolfman, based on notes by Patrice Belleville, Meghan Allen."

Similar presentations


Ads by Google