Download presentation
Presentation is loading. Please wait.
1
CPSC 121: Models of Computation 2013W2
Proof (First Visit) Steve Wolfman, based on notes by Patrice Belleville, Meghan Allen and others TODO (future terms): update term OLD THOUGHTS: This is a two-part problem: Which are there more of, Beatles or provinces in Canada? Which are there more of, positive integers or positive even integers? Unexpected hanging problem (see note about origin below.. Switch to origin phrasing): eh = exercise will happen on some day before the end of the week (stated at end of day Tuesday) es = exercise day will be a surprise ew/et/ef = exercise happens on Wednesday/Thursday/Friday sw/st/sf = exercise is a surprise on Wednesday/Thursday/Friday rw/rt/rf = exercise is “refutable” on Wednesday/Thursday/Friday Premises: eh and es eh = ew v et v ef es = sw v st v sf sf = ef ^ rf st = et ^ rt sw = ew ^ rw rf = ~ew ^ ~et -> ~ef rt = ~ew -> ~et rw = ~ew Poundstone, Labyrinths of Reason, p111: It dates to a wartime (1943 or 1944) radio announcement of the Swedish Broadcasting Company: 'A civil defense exercise will be held this week. In order to make sure that the civil defense units are properly prepared, no one will know in advance on what day this exercise will take place.' Swedish mathematician Lennart Exbom recognized the subtle contradiction and mentioned it to his class at Ostermalms College. This work is licensed under a Creative Commons Attribution 3.0 Unported License.
2
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
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. OLD THOUGHTS: Problem: Prove that the form I filled out for my vaccinations is self-contradictory (said to sign that I had been informed by the nurse yadda-yadda and also to complete the form before arriving at the vaccination). Temporal? Problem: reduction to Boolean Sat (planning?) Problem: Discuss point of learning goals.
4
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. Discuss point of learning goals.
5
Where We Are in The Big Stories
Theory Hardware 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.) How do we build devices to compute? Now: Taking a bit of a vacation in lecture!
6
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: (cond [c d] [a b] Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). (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.) But first, prove these handy “lemmas”: p (q r) (p q) (p r) p (q r) q (p r)
7
NOT a Quiz Note ~p ~(p v q)
This is valid by generalization (p p v q). This is valid because anytime ~p is true, ~(p v q) is also true. This is invalid by generalization (p p v q). This is invalid because when p = F and q = T, ~p is true but ~(p v q) is false. None of these. [2011W1] We often address this on the assignment, but if we don’t, we MUST address it in class. Another good (bad) example is: p ^ q -> r Therefore, p -> r This does NOT follow. Yes, this sort of reasoning works sometimes, but we’re not interested in reasoning that works sometimes in a proof. We want reasoning that is guaranteed to work.
8
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! [2013W2] For subexpression, saying “draw a box around this part of the expression, now remove what’s in the box and replace it with something equivalent” has worked well this term.
9
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
10
Adapted from MathWorld: http://mathworld.wolfram.com/Proof.html
What is Proof? A rigorous formal argument that unequivocally demonstrates the truth of a proposition, given the truth of the proof’s premises. that! Adapted from MathWorld:
11
Adapted from MathWorld: http://mathworld.wolfram.com/Proof.html
What is Proof? A rigorous formal argument that unequivocally demonstrates the truth of a proposition (conclusion), given the truth of the proof’s premises. that! Adapted from MathWorld:
12
Problem: Meaning of Proof
Let’s say you prove the following: Premise 1 Premise 2 ⁞ Premise n Conclusion Can one of the premises be false? No, proofs may not use false premises No, the proof shows that the premises are true Yes, but then the conclusion is false Yes, but then we know nothing about the conclusion Yes, but we still know the conclusion is true [2013W2] This has been confusing in the past; trying to rephrase to make it more positive. Was: What does this mean? Premises 1 to n are true Conclusion is true Premises 1 to n can be true Conclusion can be true None of the above
13
Tasting Powerful Proof: Some Things We Might Prove
We can build a “light that changes state when a switch is flipped” 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 NAND 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 2nd and the remainder when dividing the 1st by the 2nd. Is there any fair way to run elections? Are there problems that no program can solve? TODO (future terms): double check, especially NAND vs. NOR In my version of the slides (2009W1), we DEFINITELY did the 3-way switch, the combo circuit/TT, the NAND gates, the mergsort, and the halting problem (last). We didn’t at all do the GCD (but it’s in the book). We talked through but didn’t come anywhere near proving Arrow’s Impossibility Theorem (fair ways to run elections). Meanwhile...
14
What Is a Propositional Logic Proof?
An argument in which: each line is a propositional logic statement, each statement is a premise or follows unequivocally by a previously established rule of inference from the truth of previous statements, and the last statement is the conclusion. Talk about prop logic proof as some form of argument that shows that a propositional logic statement (the conclusion) necessarily follows from a list (of zero or more) propositional logic statements (the premises). A very constrained form of proof, but a good starting point. Interesting proofs will usually come in less structured packages than propositional logic proofs.
15
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
16
Prop Logic Proof Problem
To prove: ~(q r) (u q) s ~s ~p___ ~p This is a typical prop logic proof. Not as exciting as some of the cool stuff we’ll get to... But at the heart of all our proofs.
17
“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) s Premise 3. ~s ~p Premise [STEP A: near the start] [STEP B: in the middle] [STEP C: near the end] [STEP D: last step] Here’s the “prove your own adventure”. All answers are correct... Some are probably more promising than others. (I’ve listed them later in the order I tend to attack them. In particular, you can’t really do step C until you’ve done step D, but D is so natural that it hardly counts.) IMPORTANT to mention at some point: There are generally MANY ways to prove any particular theorem. We’ll develop one (and make no mistakes/reach no dead ends in the process!); that doesn’t mean there aren’t other ones that are equally good or correct!
18
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? ~p is the proof’s conclusion ~p is the end of the last premise every proof ends with ~p None of these but some other reason None of these because we don’t want it there The answer is a. Trivial for students. Go quickly! (2010W2 results are 75% a on the first run.)
19
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? ~s ~p is the last premise ~s ~p is the only premise that mentions ~s ~s ~p is the only premise that mentions p None of these but some other reason None of these b/c we don’t want it there The answer is c, or at least that’s the core reasoning of the answer.
20
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? ~(q r) is the first premise ~(q r) is a useless premise We can’t work directly with a premise with a negation “on the outside” Neither the conclusion nor another premise mentions r None of these The answer is d, but students argue for c. Might want to be prepared with an argument for how you CAN work with a negation on the outside. (E.g., consider that we will later show ~(u ^ q), where having the negation on the outside is GREAT!) Give an example like “x -> (q v r)”. Can we work with the “negation on the outside”?
21
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? (u q) s is the only premise left (u q) s is the only premise that mentions u (u q) s is the only premise that mentions s without a negation We have no rule to get directly from one side of a biconditional to the other None of these The answer is d.
22
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 This is INCREDIBLY UNBELIEVABLY important. Students GOT this by the second midterm in 2009W1.. Would have been great to get it by the first And, if you don’t know that what you’re trying to prove follows... switch from proving to disproving and back now and then.
23
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? (u q) s because the simple part is on the right (u q) s because the other direction can’t establish ~s s (u q) because the simple part is on the left s (u q) because the other direction can’t establish ~s None of these The answer is d. Important notion for solving these kinds of proofs!
24
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). [new for 2011W1]
25
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”? Here’s where the “negation on the outside” step comes into play.
26
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? Here’s where the “negation on the outside” step comes into play.
27
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?
28
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! VERY VERY IMPORTANT SLIDE!!!! Worth going back over how we got here at this point.
29
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
30
Limitations of Truth Tables
Why not just use truth tables to prove propositional logic theorems? No reason; truth tables are enough. Truth tables scale poorly to large problems. Rules of inference and equivalence rules can prove theorems that cannot be proven with truth tables. Truth tables require insight to use, while rules of inference can be applied mechanically. [2011W1] TTs are only universal if we allow making the TT of something like a <-> b to prove a logical equivelance or a -> b to prove that a proof is valid (where a is the AND of the premises and b is the conclusion) or equivalent approaches where we build multiple truth tables/output columns. So.. See next exercise.. [2010W2] Students get the right answer quickly. Don’t linger. The answer is b. C is not true. TTs are universal for propositional logic. D is CERTAINLY not true. TTs are completely mechanical.
31
Limitations of Logical Equivalences
Why not use logical equivalences to prove that the conclusions follow from the premises? No reason; logical equivalences are enough. Logical equivalences scale poorly to large problems. Rules of inference and truth tables can prove theorems that cannot be proven with logical equivalences. Logical equivalences require insight to use, while rules of inference can be applied mechanically. [2011W1] So, just like with TTs, we can calc whether a -> b = T in order to verify a proof. So, there’s not really much distinction from this perspective! Oops! [older notes] Log Equivs can ONLY prove that things are equivalent to each other. You CANNOT prove that one thing follows from another using log equivs alone (e.g., the proof we just did!). (OK, actually you could say “any statement I prove that is log equiv to the conj of the premises and contains as conjuncts the premises entails whatever additional conjuncts I’ve added”, but that’s a mouthful of a “proof technique”!) The answer is then c.
32
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
33
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, such as (a ~a). There is no way for them to be simultaneously true.
34
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. From: and an old CPSC 121 assignment (2007W2).
35
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. [2011W1] Ask this, get the split answer. THEN, define the problem in logic and ask it again later on. From: and an old CPSC 121 assignment (2007W2). You may think this is easy.. Students have CONSISTENTLY been tripped up by this term to term. Plus, they later get negations of conditionals wrong in proofs by contradiction. Sad fact
36
Defining the Problem Does it make sense to use the definition “w = women” for a propositional logic variable w? Yes, in this problem. Yes, but not in this problem. No, not in this problem. No, not in any problem. [2013W2] switched from the question about “which set of definitions make sense” to one that focuses on why a nonsensical definition isn’t a good choice. (Obviously, that needs to come from discussion! “women” is neither true nor false; it’s not a proposition!) [2011W1] Maybe skip and develop by hand with the students. From: and an old CPSC 121 assignment (2007W2).
37
Translating the Statements
Which of these is an accurate translation of one of the statements? w m (w m) (m w) o (w ~m) ~o ~w From: and an old CPSC 121 assignment (2007W2). They’re all accurate translations. The first two happen to be the same statement.
38
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.
39
Problem: Now, Explore! Critique the argument by either:
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? Showing that it is an invalid argument. How do we show an argument is invalid? (Remember the quiz!) From: and an old CPSC 121 assignment (2007W2). For (2): we find any ONE assignment of values to variables that makes the premises true but the conclusion false. (Same as invalidating a conditional.)
40
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
41
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). Discuss point of learning goals.
42
Next Lecture Prerequisites
Review (Epp 4th 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 online quiz. update to current lecture.
43
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: (cond [c d] [a b] Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). First, prove these handy “lemmas”: p (q r) (p q) (p r) p (q r) q (p r)
44
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: p (q r) (p q) (p r) p (q r) q (p r) In prop logic: ~(a b) premise (a b) (~a ((c d) (~c e))) premise … (c d) (~c ((a b) (~a e))) target conclusion We’ll use our “heuristics” to work forward and backward until we solve the problem. Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
45
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise … (c d) “subgoal” (~c ((a b) (~a e))) “subgoal” (c d) (~c ((a b) (~a e))) by CONJ on 4, 5 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! Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). 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!) Lemmas: p (q r) (p q) (p r) p (q r) q (p r)
46
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise … (c d) “subgoal” (~c (a b)) (~c (~a e))) “subgoal” (~c ((a b) (~a e))) Lemma 1 on 5 (c d) (~c ((a b) (~a e))) by CONJ on 4, 6 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). Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). Lemmas: p (q r) (p q) (p r) p (q r) q (p r)
47
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) “subgoal” (~c (a b)) (~c (~a e))) by CONJ on 5, 6 (~c ((a b) (~a e))) Lemma 1 on 7 (c d) (~c ((a b) (~a e))) by CONJ on 4, 8 Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). Now, we can attack those two pieces separately (which feels like it might be the wrong approach to me… but worth a try!) Lemmas: p (q r) (p q) (p r) p (q r) q (p r)
48
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) “subgoal” (~c (a b)) (~c (~a e))) by CONJ on 6, 7 (~c ((a b) (~a e))) Lemma 1 on 8 (c d) (~c ((a b) (~a e))) by CONJ on 5, 9 Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). 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.) Lemmas: p (q r) (p q) (p r) p (q r) q (p r)
49
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) “subgoal” (~c (a b)) (~c (~a e))) by CONJ on 7, 8 (~c ((a b) (~a e))) Lemma 1 on 9 (c d) (~c ((a b) (~a e))) by CONJ on 6, 10 Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). Let’s try the other premise. Lemmas: p (q r) (p q) (p r) p (q r) q (p r)
50
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) “subgoal” (~c (a b)) (~c (~a e))) by CONJ on 8, 9 (~c ((a b) (~a e))) Lemma 1 on 10 (c d) (~c ((a b) (~a e))) by CONJ on 7, 11 Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). Continuing with that premise… Hey! We can use our Lemma again! Lemmas: p (q r) (p q) (p r) p (q r) q (p r)
51
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) “subgoal” (~c (a b)) (~c (~a e))) by CONJ on 9, 10 (~c ((a b) (~a e))) Lemma 1 on 11 (c d) (~c ((a b) (~a e))) by CONJ on 8, 12 Continuing with that premise… Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). Lemmas: p (q r) (p q) (p r) p (q r) q (p r)
52
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 ~a (c d) by SPEC on 6 … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) “subgoal” (~c (a b)) (~c (~a e))) by CONJ on 10, 11 (~c ((a b) (~a e))) Lemma 1 on 12 (c d) (~c ((a b) (~a e))) by CONJ on 9, 13 Continuing with that premise… Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). Lemma 2: p (q r) q (p r)
53
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 ~a (c d) by SPEC on 6 ~a (~c e) by SPEC on 6 … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) “subgoal” (~c (a b)) (~c (~a e))) by CONJ on 11, 12 (~c ((a b) (~a e))) Lemma 1 on 13 (c d) (~c ((a b) (~a e))) by CONJ on 10, 14 Continuing with that premise… AHA!! Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). We treated connecting these as its own problem and came up with Lemma 2! Lemma 2: p (q r) q (p r)
54
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 ~a (c d) by SPEC on 6 ~a (~c e) by SPEC on 6 … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) by Lemma 2 on 8 (~c (a b)) (~c (~a e))) by CONJ on 11, 12 (~c ((a b) (~a e))) Lemma 1 on 13 (c d) (~c ((a b) (~a e))) by CONJ on 10, 14 Lemma 2 lets us connect these directly! Now what. Let’s pause, remind ourselves what our (sub)goals are, and look at what we have. Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). Lemma 2: p (q r) q (p r)
55
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 ~a (c d) by SPEC on 6 ~a (~c e) by SPEC on 6 … (c d) “subgoal” ~c (a b) “subgoal” ~c (~a e) by Lemma 2 on 8 (~c (a b)) (~c (~a e))) by CONJ on 11, 12 (~c ((a b) (~a e))) Lemma 1 on 13 (c d) (~c ((a b) (~a e))) by CONJ on 10, 14 Hmm.. Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). How do we do something with this? Again, we treated this as a separate problem: Lemma 2: p (q r) q (p r)
56
Motivating Problem: Changing cond Branches
Subproblem: a b premise … ~c (a b) “subgoal” 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! Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). Now we do our usual. Get rid of , work backward, work forward…
57
Motivating Problem: Changing cond Branches
Subproblem: a b premise ~a b by IMP on 1 … c ~a b “subgoal” c (a b) by IMP on 4 ~c (a b) by IMP on 5 Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). That’s about as far as dumping can take us. But, look at step 2 and step 4. What’s the difference?
58
Motivating Problem: Changing cond Branches
Subproblem: a b premise ~a b by IMP on 1 c ~a b by GEN on 2 c (a b) by IMP on 3 ~c (a b) by IMP on 4 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?) Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
59
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 ~a (c d) by SPEC on 6 ~a (~c e) by SPEC on 6 … (c d) “subgoal” c (a b) “subgoal” ~c (a b) by IMP on 11 ~c (~a e) by Lemma 2 on 8 (~c (a b)) (~c (~a e))) by CONJ on 12, 13 (~c ((a b) (~a e))) Lemma 1 on 14 (c d) (~c ((a b) (~a e))) by CONJ on 10, 15 Patching in “step 4” of the previous proof. Can it get us back to step 4 of this proof? Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
60
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 ~a (c d) by SPEC on 6 ~a (~c e) by SPEC on 6 … (c d) “subgoal” c (a b) by GEN on 4 ~c (a b) by IMP on 11 ~c (~a e) by Lemma 2 on 8 (~c (a b)) (~c (~a e))) by CONJ on 12, 13 (~c ((a b) (~a e))) Lemma 1 on 14 (c d) (~c ((a b) (~a e))) by CONJ on 10, 15 Sure! In one step! Now what? Only one subgoal left. How does it connect to the top of the proof? Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
61
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 ~a (c d) by SPEC on 6 ~a (~c e) by SPEC on 6 … (c d) “subgoal” c (a b) by GEN on 4 ~c (a b) by IMP on 11 ~c (~a e) by Lemma 2 on 8 (~c (a b)) (~c (~a e))) by CONJ on 12, 13 (~c ((a b) (~a e))) Lemma 1 on 14 (c d) (~c ((a b) (~a e))) by CONJ on 10, 15 Hmm… That works if a is false. Can we make a false? What if a is true? Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
62
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 5 ~a (c d) by SPEC on 6 ~a (~c e) by SPEC on 6 … (c d) “subgoal” c (a b) by GEN on 4 ~c (a b) by IMP on 11 ~c (~a e) by Lemma 2 on 8 (~c (a b)) (~c (~a e))) by CONJ on 12, 13 (~c ((a b) (~a e))) Lemma 1 on 14 (c d) (~c ((a b) (~a e))) by CONJ on 10, 15 I looked around for a way to establish ~a but couldn’t. So, I checked what happens if a is true. If a is true, then c isn’t. If c’s not true, then c d is true. Let’s put that in logic! Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
63
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 ~a ~c d by GEN on 3 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 6 ~a (c d) by SPEC on 7 ~a (~c e) by SPEC on 7 … (c d) “subgoal” c (a b) by GEN on 5 ~c (a b) by IMP on 12 ~c (~a e) by Lemma 2 on 9 (~c (a b)) (~c (~a e))) by CONJ on 13, 14 (~c ((a b) (~a e))) Lemma 1 on 15 (c d) (~c ((a b) (~a e))) by CONJ on 11, 16 We need to “fabricate” a d. The rest will be just IMP applications. Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
64
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 ~a ~c d by GEN on 3 ~a (c d) by IMP on 4 a (c d) by IMP on 5 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 8 ~a (c d) by SPEC on 9 ~a (~c e) by SPEC on 9 … (c d) “subgoal” c (a b) by GEN on 7 ~c (a b) by IMP on 14 ~c (~a e) by Lemma 2 on 11 (~c (a b)) (~c (~a e))) by CONJ on 15, 16 (~c ((a b) (~a e))) Lemma 1 on 17 (c d) (~c ((a b) (~a e))) by CONJ on 13, 18 Now, we put these together, and we’re done! Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
65
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise ~a ~c by DM on 1 ~a ~c d by GEN on 3 ~a (c d) by IMP on 4 a (c d) by IMP on 5 a b by SPEC on 2 ~a ((c d) (~c e)) by SPEC on 2 (~a (c d)) (~a (~c e)) by Lemma 1 on 8 ~a (c d) by SPEC on 9 (~a a) (c d) by CASE on 10, 6 T (c d) by NEG on 11 (c d) by M.PON on 12, T ~a (~c e) by SPEC on 9 c (a b) by GEN on 7 ~c (a b) by IMP on 15 ~c (~a e) by Lemma 2 on 14 (~c (a b)) (~c (~a e))) by CONJ on 16, 17 (~c ((a b) (~a e))) Lemma 1 on 18 (c d) (~c ((a b) (~a e))) by CONJ on 13, 19 (At step 13, no need to separately establish T. T is a “tautology”; it’s always true!) Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c). QED!! Whew!
66
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise … … (c d) (~c ((a b) (~a e))) by CONJ on 13, 19 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.” Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
67
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise … … (c d) (~c ((a b) (~a e))) by CONJ on 13, 19 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. Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
68
Motivating Problem: Changing cond Branches
In prop logic: ~(a c) premise (a b) (~a ((c d) (~c e))) premise … … (c d) (~c ((a b) (~a e))) by CONJ on 13, 19 Exercise: For expressions a, b, and c that evaluate to Booleans (with no side effects), 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. Just this proof is actually enough to prove both “directions”, i.e., that the two are equivalent given ~(a ^ c).
69
(on your own or if we have time)
More problems to solve... (on your own or if we have time)
70
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?
71
Problem: Automating Proof
Given: p q p ~q r (r ~p) s ~p ~r Problem: What’s everything you can prove? Yuck. TODO: figure out all ramifications, decide how to address this, figure out if answer is complete/correct. Point is: Get a bunch of practice. Point out that proposition logic proof is an automatable task (and in what sense that’s true). ~p v q P v ~q v r (r ^ ~p) v s v ~p ~r P v ~q S v ~p S v ~q
72
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.
73
Problem: Canonical Form
Problem: Prove that any propositional logic statement can be expressed in disjunctive normal form.
74
Mystery #1 Theorem: p q q (r s) ~r (~t u) p t u
Yes, it’s valid. Note: We have proven NOTHING about whether u is true “in the abstract”; only that it follows from the premises. Is this argument valid or invalid? Is whatever u means true?
75
Mystery #2 Theorem: p p r p (q ~r) ~q ~s s
Ack! We proved ~s. What happened? Perhaps the theorem is false. Perhaps premises are contradictory (and so we can conclude anything by the paradox of material implication!) Which one is it? No, it’s not valid. There’s nothing here that lets us establish the truth of s, only its falsehood. To PROVE the argument invalid, make the premises true and conclusion false: s = F, p = T, r = T, q = T. (But proving ~s is a good exercise.) Note: We have proven NOTHING about whether s is true “in the abstract”; only that it does not follow from the premises. Is this argument valid or invalid? Is whatever s means true?
76
Mystery #3 Theorem: q p m q (r m) m q p
Ack! We proved ~s. What happened? Perhaps the theorem is false. Perhaps premises are contradictory (and so we can conclude anything by the paradox of material implication!) Which one is it? No, it’s not valid: q = T, p = F, m = T, r = T. However, we also cannot prove ~p. (p = T, q = T, r = T, m = T.) Note: We have proven NOTHING about whether p is true “in the abstract”; only that it does not follow from the premises. Is this argument valid or invalid? Is whatever p means true?
77
Practice Problem (for you!)
Prove (with truth tables) that hypothetical syllogism is a valid rule of inference: p q q r p r
78
Practice Problem (for you!)
Prove (with truth tables) whether this is a valid rule of inference: q p q p
79
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.
80
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)?
81
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?
82
Problem: Equivalent Java Programs
Problem: How many valid Java programs are there that do exactly the same thing? To move to extra problems??
83
Resources: Statements
From the Java language specification, a standard statement is one that can be:
84
Resources: Statements
From the Java language specification, a standard statement is one that can be:
85
What’s a “Block”? Back to the Java Language Specification:
86
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).
87
What’s an “EmptyStatement”
Back to the Java Language Specification:
88
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?
89
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”)?
90
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 = p2/q2 and p2 = 2q2 p2 is divisible by 2; so p is divisible by 2. There’s some integer k such that p = 2k. q2 = p2/2 = (2k)2/2 = 2k2; so q2 and q are divisible by 2. p and q do share the factor 2, a contradiction! √2 is irrational. QED
91
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? Looking to get, among other things, that equivalences are valid in both directions, but deduction rules in only one. Clicker question: Assume that some logical equivalence rule of the form A B and some deduction rule of the form C D are both true. Which of the following is false? B A D C A C B D C D None of these, because they are all true.
92
Problem: Evens and Integers
Problem: Which are there more of, (a) positive even integers, (b) positive integers, or (c) neither?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.