Natural Deduction Formal Methods in Verification of Computer Systems Jeremy Johnson
Outline 1. An example 1. Validity by truth table 2. Validity by proof 2. What s a proof 1. Proof checker 3. Rules of natural deduction 4. Provable equivalence 5. Soundness and Completeness
An Example If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station. If it is raining and Jane does not have here umbrella with her, then she will get wet. Jane is not wet. It is raining. Therefore, Jane has her umbrella with her.
An Example If the train arrives late and there are no taxis at the station, then John is late for his meeting. John is not late for his meeting. The train did arrive late. Therefore, there were taxis at the station. p = the train arrives late q = there are taxis at the station r = John is late for his meeting. p q r, r, p q [a sequent]
An Example p = it is raining q = Jane has her umbrella r = Jane gets wet. p q r, r, p q If it is raining and Jane does not have here umbrella with her, then she will get wet. Jane is not wet. It is raining. Therefore, Jane has her umbrella with her.
Validity by Truth Table p q r, r, p q p q r q r p q (p q) r F F F T T F T F F T T F F T F T F F T F T F T T F F F T T F F T T T F T F T T F T T T T F F T F T T T T F F F T
Proof By applying rules of inference to a set of formulas, called premises, we derive additional formulas and may infer a conclusion from the premises A sequent is φ 1,,φ n ψ Premises φ 1,,φ n Conclusion ψ The sequent is valid if a proof for it can be found
Proof A proof is a sequence of formulas that are either premises or follow from the application of a rule to previous formulas Each formula must be labeled by it s justification, i.e. the rule that was applied along with pointers to the formulas that the rule was applied to It is relatively straightforward to check to see if a proof is valid
Validity by Deduction p q r, r, p q 1 p q r premise 2 r premise 3 p premise 4 q assumption 5 p q i 3,4 6 r e 1,5 7 e 6,2 8 q i 4-7 9 q e 8
Rules of Natural Deduction Natural deduction uses a set of rules formally introduced by Gentzen in 1934 The rules follow a natural way of reasoning about Introduction rules Introduce logical operators from premises Elimination rules Eliminate logical operators from premise producing a conclusion without the operator
Conjunction Rules Introduction Rule φ ψ φ ψ i Elimination Rule φ ψ φ e1 φ ψ ψ e2
Implication Rules Introduction Rule φ ψ φ ψ i Assume φ and show ψ Elimination Rule (Modus Ponens) φ φ ψ ψ e
Disjunction Rules Introduction Rule φ φ ψ i1 ψ φ ψ i2 Elimination Rule (proof by case analysis) φ ψ φ χ χ ψ χ e
Negation Rules Introduce the symbol ( = bottom) to encode a contradiction Bottom elimination φ e. Elimination Rule can prove anything φ φ e
Negation Rules Introduction Rule φ φ i Double negation φ leads to a contradiction φ φ e
Proof by Contradiction Derived Rule φ φ PBC Assume φ and derive a a contradiction Derived rules can be used like the basic rules and serve as a short cut (macro) Sometimes used as a negation elimination rule instead of double negation
Law of the Excluded Middle p p [derived rule LEM] 1 (p p) assumption 2 p Assumption 3 (p p) i 1 3,4 4 e 3,1 5 p i 2-4 6 p p i 2 3,4 7 e 6,1 8 (p p) i 1-7 9 p p e 8
ProofLab The ProofLab tool from the Logic and Proofs course from the CMU online learning initiative allows you to experiment with natural deduction proofs
ProofLab
Provable Equivalence φ and ψ are provably equivalent, φ ψ, iff the sequents φ ψ and ψ φ are both valid Alternatively φ ψ iff the sequent φ ψ ψ φ is valid A valid sequent with no premises is a tautology
De Morgan s Law (P Q) P Q 1 (P Q) premise 2 P assumption 3 P Q i1 2 4 e 1,3 5 P i 2-4 6 Q assumption 7 P Q i2 6 8 e 1,7 9 Q i 6-8 10 P Q i 5,9
De Morgan s Law (P Q) P Q 1 P Q premise 2 P e1 1 3 Q e2 1 4 P Q assumption 5 P assumption 6 e 2,5 7 Q i2 6 8 e 3,7 9 e 4,5-6, 7-8 10 (P Q) i 4-9
Semantic Entailment If for all valuations (assignments of variables to truth values) for which all φ 1,,φ n evaluate to true, ψ also evaluates to true then the semantic entailment relation φ 1,,φ n ψ holds
Soundness and Completeness φ 1,,φ n ψ holds iff φ 1,,φ n ψ is valid In particular, ψ, a tautology, ψ is valid. I.E. ψ is a tautology iff ψ is provable Soundness you can not prove things that are not true in the truth table sense Completeness you can prove anything that is true in the truth table sense
Proof Outline For soundness show, using a truth table, that each rule of inference implies the conclusion is true when the assumptions are true and use induction on the length of the proof to chain together inferences For completeness 1. Reduce to proving tautologies 2. Provide a proof for a sequent for each entry in the truth table for the conclusion using induction on the formula in the conclusion 3. Construct proof from the proofs for each row
Illustrate Inductive Proof Prove if p q r p (q r) valid then p q r p (q r) 1 p q r premise 2 p assumption 3 q assumption 4 p q i 2,3 5 r e 1,5 6 q r i 3-5 7 p (q r) i 2-6
Smaller Proof Remove last line 1 p q r premise 2 p assumption 3 q assumption 4 p q i 2,3 5 r e 1,5 6 q r i 3-5
Inductive Hypothesis Remove last line and change assumption to premise to obtain proof of p q r, p q r 1 p q r premise 2 p premise 3 q assumption 4 p q i 2,3 5 r e 1,5 6 q r i 3-5 By induction p q r, p q r
Inductive Step p q r, p q r and correctness of i Implies p q r p (q r) φ ψ φ ψ i ϕ ψ ϕ ψ F F T F T T T F F T T T
Proof of Soundness Use induction on the length of the proof Base case. When the proof has length 1, premise and conclusion are the same. Clearly the conclusion is T when the premise is T Look at the rule in the last line of the proof Obtain proofs for the premises and use induction hypothesis to show entailment for premises Use correctness of rule and truth of premises to deduce truth of conclusion
Correctness of Rules of Inference φ ψ φ χ χ ψ χ e ϕ ψ χ ϕ χ ψ χ ϕ ψ F F F T T F F F T T T F F T F T F T F T T T T T T F F F T T T F T T T T T T F F F T T T T T T T
Correctness of Rules of Inference φ φ i φ φ e ϕ ϕ ϕ F F T T T F F ϕ ϕ ϕ F T F T F T
Induction for Implication Elimination Given a proof of length k for the sequent φ 1,,φ n ψ and assume the rule at step k is e and the premise Then we obtain proofs for (replace open assumptions by premises) φ 1,,φ n η 1 η 2 φ 1,,φ n, η 1 ψ φ 1,,φ n, η 2 ψ
Inductive Step Since the proofs are shorter by induction φ 1,,φ n η 1 η 2 φ 1,,φ n, η 1 ψ φ 1,,φ n, η 2 ψ By correctness of the e rule, we conclude φ 1,,φ n ψ A similar proof must be carried out for each of the rules of inference
Proof of Completeness 1. Reduce to tautologies φ 1,,φ n ψ is equivalent to ϕ = φ 1 (φ 2 (φ n ψ) ) This follows from (A B) C A (B C) 2. Prove p, 1, p n ϕ for each row in the truth table for ϕ 3. Combine the proofs in (2) using case analysis and the LEM to obtain a proof for the tautology ϕ
Key Lemma for Proof of Completeness Proposition. Let ϕ be a boolean formula with propositional atoms p 1,,p n. Let l be any row in the truth table for ϕ. Let p i be p i if the entry for p i is T and p i if the entry if F. Then p, 1, p n ϕ is provable if ϕ in row l is T p, 1, p n ϕ is provable if ϕ in row l is T
Proof of Lemma Use structural induction on the formula ϕ Base case. ϕ is a propositional atom. In this case the proofs of p p and p p are trivial. For boolean operators assume proofs for the operands and then construct a proof from them for each of the operators,, and. This is shown for. The other cases are similar.
Inductive Step for Implication To prove p, 1, p n ϕ 1 ϕ 2 For each entry in the truth table for ϕ 1 ϕ 2 Assume proofs for p, 1, p n ϕ 1 [ ϕ 1 ] and p, 1, p n ϕ 2 [ ϕ 2 ] Prove ϕ 1 ϕ 2 ϕ 1 ϕ 2 [ϕ 1 F, ϕ 2 F, ϕ 1 ϕ 2 T] ϕ 1 ϕ 2 ϕ 1 ϕ 2 [ϕ 1 F, ϕ 2 T, ϕ 1 ϕ 2 T] ϕ 1 ϕ 2 (ϕ 1 ϕ 2 ) [ϕ 1 T, ϕ 2 F, ϕ 1 ϕ 2 F] ϕ 1 ϕ 2 ϕ 1 ϕ 2 [ϕ 1 T, ϕ 2 T, ϕ 1 ϕ 2 T]
Inductive Step for Implication ϕ 1 ϕ 2 ϕ 1 ϕ 2 1 ϕ 1 ϕ 2 premise 2 ϕ 1 e 1 1 3 ϕ 1 assumption 4 e 2,3 5 ϕ 2 e 4 6 ϕ 1 ϕ 2 i 3-5
Inductive Step for Implication ϕ 1 ϕ 2 ϕ 1 ϕ 2 1 ϕ 1 ϕ 2 premise 2 ϕ 1 e 1 1 3 ϕ 1 assumption 4 e 2,3 5 ϕ 2 e 4 6 ϕ 1 ϕ 2 i 3-5
Inductive Step for Implication ϕ 1 ϕ 2 ϕ 1 ϕ 2 1 ϕ 1 ϕ 2 premise 2 ϕ 2 e 2 1 3 ϕ 1 ϕ 2 i 3-5 ϕ 1 ϕ 2 (ϕ 1 ϕ 2 ) 1 ϕ 1 ϕ 2 premise 2 ϕ 1 e 1 1 3 ϕ 2 e 2 1 4 (ϕ 1 ϕ 2 ) assumption 5 ϕ 2 e 4,2 6 e 3,5 7 (ϕ 1 ϕ 2 ) i 4-6
Combining Proofs Combine proofs for ϕ = φ 1 (φ 2 (φ n ψ) ) 1 p 1 p 1 LEM 2 p 1 assumption p1 assumption 3 p 2 p 2 LEM p 2 p 2 LEM 4 p 2 p 2 p 2 p 2 5 6 ϕ ϕ ϕ ϕ 7 ϕ e ϕ e 8 ϕ e