COP 5021 Lecture -*- Outline -*- * Calculational Style Proofs Based on Edsger W. Dijkstra and Carel S. Scholten. Predicate Calculus and program semantics, chapter 4. Springer-Verlag, NY, 1990. David Gries. "Teaching calculation and discrimination: A more effective curriculum." Communications of the ACM, 34(3):44-55, March 1991. http://dx.doi.org/10.1145/102868.102870 Ralph-Johan Back and Joakim von Wright. Refinement Calculus: A Systematic Introduction, section 4.2. Graduate Texts in Computer Science. Springer-Verlag, Berlin, 1998. ** proof formats with equality ------------------------------------------ CALCULATIONAL STYLE PROOFS Why? General Format A == {hint why A == B} B == {hint why B == C} C This establishes that A == C because it shows (A == B) /\ (B == C) If C is true, then this proves A ------------------------------------------ ... to prove theorems by hand, but carefully (not skipping steps, get feedback) to better communicate and motivate reasons to readers Note that we don't say "by transitivitity" (as we assume the reader knows that) *** proof formats with implication ------------------------------------------ STANDARD PROOF OUTLINES To show: A ==> D A ==> {hint why A ==> B} B == {hint why B == C} C ==> {hint why C ==> D} D Another way: D <== {hint why D <== C} C == {hint why C == B} B <== {hint why B <== A} A ------------------------------------------ Q: What's the logical formula that these are equivalent to? (A ==> B) /\ (B == C) /\ (C ==> D) We would use the second one when D is more complex than A as it is useful to "reduce" from more complex to simpler formulas. ** rules and strategies *** rules ------------------------------------------ SOME INFORMAL RULES A. Don't use two reasons in one hint, use two steps instead B. Substituting equals for equals is always okay C. Be careful with substitution when you only know an implication ------------------------------------------ *** strategies ------------------------------------------ SOME STRATEGIES, HINTS A. Start from the more complex side. B. Use lemmas to isolate parts of a proof. C. Avoid proof by contradiction, if possible. D. Look at the proof afterwards to see if it can be simplified, or clarified ------------------------------------------ ** practice ------------------------------------------ PRACTICE For the following: give a proof or find a counterexample. P <==> P <==> P <==> !P P <== Q <==> P \/ !Q <==> P P ==> Q <==> P \/ Q <==> Q X ==> X \/ Y absorption: X \/ (X /\ Y) <==> X currying: P ==> (Q ==> R) <==> (P /\ Q ==> R) golden rule: P /\ Q <==> P <==> Q <==> P \/ Q (P ==> Q) \/ (Q ==> P) conjunction distributes over implication: P /\ (Q ==> R) <==> P /\ Q ==> P /\ R disjunction distributes over discrepancy: P \/ (Q <=!=> R) <==> P \/ Q <=!=> P \/ R (P <==> P \/ Q) /\ (P \/ Q <==> P) <==> P <==> Q ------------------------------------------ The first 2 are not valid. For counterexamples: take P as true in the first formula take P as false in the second formula