Lecture 2 [1in] Soundness and completeness of propositional logic
Transcript
Lecture 2 [1in] Soundness and completeness of propositional logic
Lecture 2 Soundness and completeness of propositional logic August 31, 2005 Overview I Review of natural deduction. I Soundness and completeness. I Semantics of propositional formulas. I Soundness proof. I Completeness proof. Propositional formulas Grammar: ::= p j (:) j ( ^ ) j ( _ ) j ( ! ) Precedence rules: Example: : > _; ^ > ! p ^ (q _ : r ! q ) (p ^ ((q _ (:r )) ! q)) Natural deduction 1 ; : : : ; n ` Formula can be proved from formulas 1 ; : : : ; . n Rules for reasoning about formulas. I Introduction rules: Connective in the conclusion. Construct a complex formula. I .. . ! Elimination rules: Connective in a premise. Extract information from proved formulas. xxx ! !-e !-i Basic rules Introduction ^ _ ^ _ _ . . . ? :: -i1 ! : ^ xxx -i _ _ ! ^ Elimination ^ -e1 ^ -e2 -i2 -i ^ _ . . . xxx xxx xxx ! ! ! . . . ? : no rule : -i _ . . . : ? : xxx ? ? :: :: -e -e -e -e -e Proof p ! q ; r ! a ` (p _ r ) ! (q _ s ) 1: p_r assumption 2: p assumption 3: p 4: q 5: q_s !-e : 2 3 _-i1 : 4 6: r assumption 7: r 8: s 9: q_s 10: q_s !q premise ; !s premise !-e : 6 7 _-i2 : 8 _-e : 2 9 ; Proof p ! q ; r ! a ` (p _ r ) ! (q _ s ) 1: p_r assumption 2: p assumption 3: p 4: q 5: q_s !-e : 2 3 _-i1 : 4 6: r assumption 7: r 8: s 9: q_s 10: q_s !q premise ; !s premise !-e : 6 7 _-i2 : 8 _-e : 2 9 ; Reasoning vs. reality Reasoning: argument based on observations and derivational rules. Reality: reality. How does reasoning relate to reality? I Soundness: reasoning derives only true statements. Trivial solution: reasoning that derives nothing. I Completeness: reasoning derives all true statements. Trivial solution: reasoning that derives everything. Soundness, completeness, and auto mechanics Reality: the fan belt is broken. Mechanic's diagnosis: Complete Replace the fan belt and the engine Replace the car Replace the engine Sound Replace the fan belt I don’t know Semantics What is a true formula? A formula is either true T or false F. The meaning depends on the meaning of the subterms. Examples: I [ p ] = T and [ q ] = F implies [ p ^ q ] = F I [ p] = T implies [ :p] = F I [ p] = T and [ q] = F implies [ p ^ :q] = T Truth tables The value of a formula for all possible inputs. Basic connectives: > xxx ? xxx : xxx T F T T F F T F T F F T _ T T T F T F T T F F xxxxxx Other tables dene other functions. T T F F T F T F T F T F ^ T F F F ! T F T T Meaning of a formula Begin with the meanings of atoms. Compute the value bottom-up. Example: (p ! q) ^ (p ! r ) p q r p ! q p ! r (p ! q ) ^ ( p ! r ) T T T T F F F F I I T T F F T T F F T F T F T F T F Tautology: Always true. Contradiction: always false. Semantic entailment 1 ; : : : j= n true when 1 ; : : : are true. n 1. Compute truth tables of the 1 ; : : : . n 2. Collect lines where 1 ; : : : are all true. n 3. Evaluate in these cases. Example q ^ r j= (p ! q ) ^ (p ! r ) p q r q ^ r p ! q p ! r (p ! q ) ^ (p ! r ) T T T T F F F F T T F F T T F F T F T F T F T F T F F F T F F F Thus, q ^ r j= (p ! q) ^ (p ! r ) Example q ^ r j= (p ! q ) ^ (p ! r ) p q r q ^ r p ! q p ! r (p ! q ) ^ (p ! r ) T T T T F F F F T T F F T T F F T F T F T F T F T F F F T F F F T T T T T T Thus, q ^ r j= (p ! q) ^ (p ! r ) Soundness and completeness Relate provability to semantic entailment. I Soundness: 1 ; : : : ; ` implies that 1 ; : : : ; j= . n I n Completeness: 1 ; : : : ; j= implies that 1 ; : : : ; ` . n n Soundness Let 1 ; : : : ; and be propositional logic formulas. Then, if 1 ; : : : ; ` , then 1 ; : : : ; j= . Theorem: n n n Proof idea: each proof step is justied by truth tables. Proof: inductive denition I : premise is a proof of ` , where 2 . I Let: prove ` prove ; ` For any rule R : i i j j j 1 .. . 1 Then : : : xxx 1 proves ` . n ::: n m 1 ; : : : ; ; 1 ; : : : ; ; R m .. . n Base case Given: ` Show: j= Proof of ` : : premise Show: j= Evaluate for truth table lines where are all T. is a premise, so 2 . Thus is T. Induction case Given: ` Show: j= ` must have a proof 1 ; : : : ; ; 1 ; : : : ; ; R , for R : m n 1 .. . .. . n ::: 1 : : : xxx 1 m Induction hypothesis: I proves ` implies j= . I proves ; ` implies ; j= : i j i j i j j Proceed by cases on the possible rules. j n Rule: ^ -i Given: ` ^ , show: j= ^ . Proof of ` ^ : 1 ; 2 ; ^-i xxx ^ ^-i 1 proves ` , 2 proves ` By induction: j= , j= Evaluate ^ when [ ] = [ ] = T: Thus, j= ^ . T T ^ T Rule: ^ -i Given: ` ^ , show: j= ^ . Proof of ` ^ : 1 ; 2 ; ^-i xxx ^ ^-i 1 proves ` , 2 proves ` By induction: j= , j= Evaluate ^ when [ ] = [ ] = T: Thus, j= ^ . T T ^ T Rule: ^ -i Given: ` ^ , show: j= ^ . Proof of ` ^ : 1 ; 2 ; ^-i xxx ^ ^-i 1 proves ` , 2 proves ` By induction: j= , j= Evaluate ^ when [ ] = [ ] = T: Thus, j= ^ . T T ^ T : Rule: -e Given: ` ?, show: j= ?. Proof of ` ?: 1 ; 2 ; :-e xxx : ? :-e 1 proves ` , 2 proves ` : By induction: j= , j= : Truth table for : : F T T F never all T. Thus, trivially: j= ? NB: Truth table for ?: ? F : Rule: -e Given: ` ?, show: j= ?. Proof of ` ?: 1 ; 2 ; :-e xxx : ? :-e 1 proves ` , 2 proves ` : By induction: j= , j= : Truth table for : : F T T F never all T. Thus, trivially: j= ? NB: Truth table for ?: ? F : Rule: -e Given: ` ?, show: j= ?. Proof of ` ?: 1 ; 2 ; :-e xxx : ? :-e 1 proves ` , 2 proves ` : By induction: j= , j= : Truth table for : : F T T F never all T. Thus, trivially: j= ? NB: Truth table for ?: ? F Rule: ? -e Given: ` , show: j= . Proof of ` : ; :-e proves ` ?. ? ?-e By induction: j= ?. Truth table for ?: ? F never all T. Thus, trivially: j= Rule: ? -e Given: ` , show: j= . Proof of ` : ; :-e proves ` ?. ? ?-e By induction: j= ?. Truth table for ?: ? F never all T. Thus, trivially: j= Rule: ? -e Given: ` , show: j= . Proof of ` : ; :-e proves ` ?. ? ?-e By induction: j= ?. Truth table for ?: ? F never all T. Thus, trivially: j= ! Rule -i Given: ` ! , show: j= ! . .. . Proof of ` ! : ; !-i xxx !-i ! proves ; ` By induction: ; j= . Show: when all true, so is ! . T T T F ! T F xxx F T F F ! T T Potential problem when [ ] = T and [ ] = F. But, by induction, if all true and [ ] = T, then [ ] = T. Thus, j= ! . ! Rule -i Given: ` ! , show: j= ! . .. . Proof of ` ! : ; !-i xxx !-i ! proves ; ` By induction: ; j= . Show: when all true, so is ! . T T T F ! T F xxx F T F F ! T T Potential problem when [ ] = T and [ ] = F. But, by induction, if all true and [ ] = T, then [ ] = T. Thus, j= ! . ! Rule -i Given: ` ! , show: j= ! . .. . Proof of ` ! : ; !-i xxx !-i ! proves ; ` By induction: ; j= . Show: when all true, so is ! . T T T F ! T F xxx F T F F ! T T Potential problem when [ ] = T and [ ] = F. But, by induction, if all true and [ ] = T, then [ ] = T. Thus, j= ! . Completeness Theorem: Let 1 ; : : : ; and be propositional logic formulas. Then, if 1 ; : : : ; j= , then 1 ; : : : ; ` . n n n Proof idea: construct a proof from a truth table. Completeness proof structure 1. Eliminate premises: 1 ; 2 ; : : : ; j= implies j= 1 ! (2 ! : : : ! ( ! )). n n 2. Show provability: j= 1 ! (2 ! : : : ! ( ! )) implies ` 1 ! (2 ! : : : ! ( ! )). n n 3. Reintroduce premises: ` 1 ! (2 ! : : : ! ( ! )) implies 1 ; 2 ; : : : ; ` . n n Eliminating premises If 1 ; 2 ; : : : ; j= , then j= 1 ! (2 ! : : : ! ( ! )). Theorem: n n Proof: By induction on n. Base case: n = 0. Clearly j= implies j= . Induction case: We showed ; j= implies j= ! . Thus, 1 ; 2 ; : : : ; j= implies 1 ; : : : n n 1 j= ! . By induction, j= 1 ! (2 ! : : : ! ( ! )) n n Showing provability Theorem: I Let be a formula such that p1 ; p2 ; : : : ; p are its only propositional atoms. I Let ` be any line in 's truth table. I For any atom or formula , let ` () be if the truth table entry in line ` for is T, and : if the truth table entry for is F. n Then, ` (p1 ); ` (p2 ); : : : ; ` (p ) ` ` () is provable. n Example A truth table line: (p ^ r ) ! ( q ^ s ) p q r s p ^ r q ^ s ( p ^ r ) ! (q ^ s ) T F T T T F F Constructed sequent: p ; :q ; r ; s ` :((p ^ r ) ! (q ^ s )) Another truth table line: p q r s p ^ r q ^ s ( p ^ r ) ! (q ^ s ) F T F T F T T Constructed sequent: :p; q; :r ; s ` (p ^ r ) ! (q ^ s ) Proof Induction on the structure of . Base case: p. Truth table: p p T F T F ` (p ) ` ` (p ) is p ` p , or :p ` :p : I Proof of p ` p : 1: p premise 2: p 1 I Proof of :p ` :p : 1: :p premise 2: :p 1 Thus, ` (p) ` ` (p). Negation Possible truth table lines: : : F T T F If [ ] = F and [ : ] = T: xxxShow ` (p1 ); ` (p2 ); : : : ; ` (p ) ` : n By induction, since [ ] = F: ` (p1 ); ` (p2 ); : : : ; ` (p ) ` : n Negation, continued If [ ] = T and [ : ] = F: xxxShow ` (p1 ); ` (p2 ); : : : ; ` (p ) ` :: n By induction, since [ ] = T: ` (p1 ); ` (p2 ); : : : ; ` (p ) ` n To prove ` (p1 ); ` (p2 ); : : : ; ` (p ) ` :: : First prove ` (p1 ); ` (p2 ); : : : ; ` (p ) ` . Use :-i. n n Implication 1 ! 2 Proof strategy: I Consider possible truth values of 1 ! 2 . I Use induction to nd proofs of ` (1 ) and ` (2 ). I Construct a proof of ` (1 ! 2 ). 1 2 1 ! 2 T T F F Four lines, so four cases. T F T F T F T T Use of the induction hypothesis 1 2 1 ! 2 T T F F T F T F T F T T Consider 1 , 2 : I Propositional atoms of 1 : a1 ; : : : ; a . I Propositional atoms of 2 : b1 ; : : : ; b . Atoms of 1 ! 2 = fa1 ; : : : ; a g [ fb1 ; : : : ; b g. x y x y Thus, a truth table line for 1 ! 2 also gives meaning to 1 and 2 . Using the induction hypothesis For a truth table line ` for 1 ! 2 , by induction: ` (a1 ); : : : ; ` (a ) ` ` (1 ) ` (b1 ); : : : ; ` (b ) ` ` (2 ) Our goal: x y ` (a1 ); : : : ; ` (a ); ` (b1 ); : : : ; ` (b ) ` ` (1 ! 2 ) x y Proof structure: I Proof of ` (a1 ); : : : ; ` (a ) ` ` (1 ). I Proof of ` (b1 ); : : : ; ` (b ) ` ` (2 ). I ` (1 ) ^ ` (2 ) : ^-i I Derive ` (1 ! 2 ) from ` (1 ) ^ ` (2 ). x y Cases I 1 is T, 2 is T, and is T: Show 1 ^ 2 implies 1 ! 2 . I 1 is T, 2 is F, and is F: Show 1 ^ :2 implies :(1 ! 2 ). I 1 is F, 2 is T, and is T: Show :1 ^ 2 implies 1 ! 2 . I 1 is F, 2 is F, and is T: Show :1 ^ :2 implies 1 ! 2 . Conjunction and disjunction similar. Combining sequents We have a \complete" collection of sequents: ` (p1 ); ` (p2 ); : : : ; ` (p ) ` ` () n Note: j= implies 8`:` () = . We want to prove: ` Proof idea: Use the Law of the Excluded Middle. Example (p ^ q) ! q Constructed sequents: p ; q ` (p ^ q ) ! q p ; :q ` (p ^ q ) ! q :p; q ` (p ^ q) ! q :p; :q ` (p ^ q) ! q Consider p; q ` (p ^ q) ! q and p; :q ` (p ^ q) ! q. Proof of p ` (p ^ q) ! q: q _ :q 1: LEM 2: 3 4: 5 6: q proof of :q assumption p ; q ` (p ^ q ) ! q assumption p ; :q ` (p ^ q ) ! q (p ^ q ) ! q _-e : 1 5 proof of Proof idea Goal: Reduce ` (p1 ); ` (p2 ); : : : ; ` (p ) ` to ` . n Proof by induction on n. Find pairs of sequents that only dier in ` (p ). n Use LEM to prove a single sequent without ` (p ) in the premise. n Reintroducing premises Theorem: If ` 1 ! (2 ! : : : ! ( ! )), then ` . 1 ; 2 ; : : : ; n n Proof idea: Convert ` 1 ! (2 ! : : : ! ( ! )) to 1 ` 2 ! : : : ! ( ! ), and proceed by induction. n n Problem: Theorem not general enough. Restatement: If ` 1 ! (2 ! : : : ! ( ! )), then ; 1 ; 2 ; : : : ; ` . n n Proof Given a proof of: ` 1 ! (2 ! : : : ! ( ! )) n Prove: ; 1 ` 2 ! : : : ! ( ! ) n Proof of ` 1 ! (2 ! : : : ! ( ! )) 1 : premise 2 ! : : : ! ( ! ) : !-e By induction, ; 1 ; 2 ; : : : ; ` . I I I n n n Take = ; to prove the original theorem. Summary Soundness: Show that the deduction rules are justied by truth tables. Completeness: 1. Eliminate premises: 1 ; 2 ; : : : ; j= implies j= 1 ! (2 ! : : : ! ( ! )). n n 2. Show provability: j= 1 ! (2 ! : : : ! ( ! )) implies ` 1 ! (2 ! : : : ! ( ! )). n n 3. Reintroduce premises: ` 1 ! (2 ! : : : ! ( ! )) implies 1 ; 2 ; : : : ; ` . Conclusion: can freely use either natural deduction or truth tables. n n