Logic in Computer Science Transparency No Chapter 3 Propositional Logic 3.6. Propositional Resolution 3.7. Natural Deduction
Logic in Computer Science Ch 3. Propositional Logic Transparency No Propositional Resolution (another Propositinal calculus) a single rule of inference: P => Q, Q => R P => R Using propositional resolution alone (without axiom schemata or other rules of inference), it is possible to build a theorem prover that is sound and complete for All propositional Calculus. The search space using propositional resolution is much smaller than for standard propositional calculus (like H). works only on expressions in clausal form. General procedure to convert wffs into clausal forms introduced before.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Clausal Form revisited A literal is either an atomic sentence or a negation of an atomic sentence. p ~p A clause is either a literal or a disjunction of literals. p ~p p \/ q \/ r Clauses are usually written as sets of literals. { p}, { ~p}, { p,q,r } A database in clausal form is a set of clauses. {{~p,q},{r,~q}}
Logic in Computer Science Ch 3. Propositional Logic Transparency No Empty Sets The empty clause {} is unsatisfiable. Why: It is equivalent to an empty disjunction. The empty database {} is valid. Why: It is equivalent to an empty conjunction. What about a database consisting of an empty clause {{}}?
Logic in Computer Science Ch 3. Propositional Logic Transparency No Conversion to Clausal Form Implications out: P1 -> P2 ---> ~P1 \/ P2 P1 P2 ---> (~P1 \/ P2) /\ (P1 \/ ~P2) Negations in: ~~P ---> P ~(P1 /\ P2) ---> ~P1 \/ ~P2 ~(P1 \/ P2) ---> ~P1 /\ ~P2 Disjunctions in: P1 \/ (P2 /\ P3) ---> (P1 \/ P2) /\ (P1\/ P3) Operators out: P1 \/ P2 ---> {P1,P2} P1 /\ P2 ---> {P1}, {P2}
Logic in Computer Science Ch 3. Propositional Logic Transparency No Examples Example 1: (g & (r -> f)) I (g & (~r | f)) N D O { g}, {~r,f} Example 2: ~(g & (r -> f)) I ~(g & (~r | f)) N (~g | ~(~r | f)) (~g | (~~r & ~f)) (~g | (r & ~f)) D (~g | r) & (~g | ~f) O {~g, r}, {~g, ~f}
Logic in Computer Science Ch 3. Propositional Logic Transparency No Propositional Resolution General form: {p1,..., r,...,pm} {q1,...,~r,...,qn} {p1,...,pm,q1,...,qn} Example: {Office, Home} {~Home,Sick} {Office,Sick}
Logic in Computer Science Ch 3. Propositional Logic Transparency No Issues Collapse: {~p,q} {p,q} {q} Multiple Conclusions: {p,q} {~p,~q} {p,~p} {q,~q} Single Application Only: {p,q} {~p,~q} {} NO!
Logic in Computer Science Ch 3. Propositional Logic Transparency No Modus Ponens: p => q {~p,q} p {p} q {q} Modus Tollens: p => q {~p,q} ~q {~q} ~p {~p} Special Cases of Propositional Resolution Chaining: p => q {-p,q} q => r {-q,r} p => r {-p,r}
Logic in Computer Science Ch 3. Propositional Logic Transparency No Unsatisfiability Example: 1. {p,q} premise 2. {~p,q} premise 3. {p,~q} premise 4. {~p,~q} premise 5. {q} 1,2 6. {~q} 3,4 7. {} 5,6
Logic in Computer Science Ch 3. Propositional Logic Transparency No True or False Questions Theorem: T |= A iff T U {~A} is unsatisfiable. Application: To determine whether a set T of sentences logically implies a sentence A, rewrite T U {~s} in clausal form and try to derive the empty clause.
Logic in Computer Science Ch 3. Propositional Logic Transparency No True or False Example {p -> q, q -> r} |= p -> r ? p -> q ==> {~p,q} q -> r ==> {~q,r} ~(p -> r) ==> {p}, {~r} 1. {~p,q} premise 2. {~q,r} premise 3. {p} negated goal 4. {~r} negated goal 5. {q} 1,3 6. {r} 2,5 7. {} 4,6
Logic in Computer Science Ch 3. Propositional Logic Transparency No True or False Example {p -> q,m -> p \/ q} |= m -> q? p -> q ==> {~p,q} m -> p \/ q ==> {~m,p,q} ~ (m -> q) ==> {m}, {~q} 1. {~p,q} premise 2. {~m,p,q} premise 3. {m} negated goal 4. {~q} negated goal 5. {p,q} 2,3 6. {q} 1,5 7. {} 4,6
Logic in Computer Science Ch 3. Propositional Logic Transparency No Incompleteness? Theorem: Propositional Resolution is not generatively complete. I.e., the statement: “If T |= A then there is a proof of A from T using Propositional Resolution only.” is not true. Pf: Show that {} |= p => (q => p) using propositional resolution. Note since there are no premises, there are no conclusions that can be generated. QED However it can be show that Propositional Resolution is refutation complete. Namely, if T is unsatisfiable, then there is a resolution proof of {} (contradiction) from T. Hence T |= A iff T U {~A} is unsatisfiable iff there is a resolution proof of {} from T U {~A}.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Resolution proof of {} |= p->(q->p) I ~(p -> (q -> p)) : ~A N ~(~p \/ (~q \/ p)) (~~p /\ ~(~q \/ p)) (~~p /\ (~~q /\ ~p)) (p /\ (q /\ ~p)) D O {p}, {q}, {~p} 1. {p} negated goal 2. {q} negated goal 3. {~p} negated goal 4. {} 1,3
Logic in Computer Science Ch 3. Propositional Logic Transparency No Resolution Provability Definition: A sentence A is provable from a set of sentences T by propositional resolution (written T |- r A) iff there is a derivation of the empty clause from the clausal form of T U {~A} using resolution rule only. Soundness and Completeness of Resolution: Soundness Theorem: Proposition resolution is sound. T |- r A => T |= A Completeness Theorem: Our proof system is complete. T |= A => T |- r A
Logic in Computer Science Ch 3. Propositional Logic Transparency No Termination Two finger method: 1. {P,Q} Premise 2. {~P,Q} Premise 3. {P,~Q} Premise 4. {~P,~Q} Premise 5. {Q} 1,2 6. {P} 1,3 7. {Q,~Q} 1,4; 2,3 8. {P,~P} 1,4; 2,3 9. {~P} 2,4 10. {~Q} 3,4 11. {} 6,9 Theorem: There is a resolution derivation of a conclusion from a set of premises if and only if there is a derivation using the two finger method. Theorem: Propositional resolution using the two-finger method always terminates. Proof: There are only finitely many clauses that can be constructed from a finite set of logical constants.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Soundness of |- r. Let T |- rr A means there is a resolution proof of A with all premises from T. Lemma: T |- rr A implies T |= A. pf: Let D1,D2,…Dn be a resolution proof of A. Then either A \in T and hence T |= A, or A is obtained by resolution, i.e., there is Di = {L, L1,…,Ls}, Dj = {~L, M1,…,Mt} with A = {L1,…Ls,M1,…Mt}. By Ind. Hyp. T|= Di and T|= Dj, from which T|= A by soundness of resolution. Soundness of |- r. pf: T |- r A means T, ~A |- rr {} => T,~A |= false => T U{~A} is unsatisfiable => T|= ~A.
Logic in Computer Science Ch 3. Propositional Logic Transparency No The algorithm // principle: systemic exploring all possible pairs of clauses // the order: 21, 31,32, 41,42,43, 51,52,53,54, …. input: T, A; output T |- r A ? Let DB = the set of all clausal forms obtained from T U {~A}. Let List = [ ].add( DB.removeFirst()); While(! DB.isEmpty()){ Clause C = DB.removeFirst(); ForEach( D in List ) { let Result = AllResolvents(C,D); for each E in Result { if E = { } return true; if( E not in List U DB ) DB.add( E); }} List.add(C). } return false;
Logic in Computer Science Ch 3. Propositional Logic Transparency No Termination The algorithm must terminates. pf: Since List and DB contains only distinct clauses and there are at most 2^ ( 2 x #atoms ) clauses that can be generated by resolutions, where #atoms is the number of distinct atoms in T U {~A}. notes: the number can be reduced to 3^(#atoms) if we disallow the generation of any clause containing complementary literals, like { p, q, ~q, r, ~r}.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Completeness Let T be a finite set of clauses. if T is unsatifiable, then there is a resolution deduction of {} from T. Pf: if T contains {}, then we are done. Otherwise, the proof is by induction on the number of excess literals e = def S { #literals(C) – 1 | C in T}. if e = 0, then T is unsat iff there are two complementary unit clause {L} {~L} in C, => T |- r {}. if e > 0 => there is a clause C = L \/ C’. Let T1 = T – {C} U {C’}; T2 = T-{C} U {{L}}. Since T is unsat, bothe T1 and T2 must be unsat. => by ind hyp. There is a resolution proof R1 (R2) of {} from T1 (T2). If R1 does not use C’, then R1 is also a proof of {} from T, and we are done. Other we can construct a proof of L from R1 by replacing every occurrence of C’ in R1 by C. now by joining such proof to occurrence of L in R2,we obtains a proof of {} from T.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Example T={ p \/ q, ~p\/~q, p\/~q, ~p \/ q }. e = 8 – 4 = 4. Let C = p \/ q and L = p => C’ =q. T1= { p, ~p\/~q, p\/~q, ~p \/ q }. T2= { q, ~p\/~q, p\/~q, ~p \/ q }. empty deduction of {} inT2: q ~p\/~q p\/~q ~q {} empty deduction of {} in T1: p ~p\/~q p\/~q ~p\/q q ~q {} empty deduction of p inT: q \/ p ~p\/~q p\/~q ~q {} \/ p empty deduction of p inT: q \/ p ~p\/~q p\/~q ~q {} \/ p
Logic in Computer Science Ch 3. Propositional Logic Transparency No linear transformation of wff into wff in cnf Problem with CNF : it requires exponential growth-up in space to transform a wff into equivalent wff in cnf. Example: (p 1 /\ ~p 1 )\/(p 2 /\ ~p 2 )\/ …\/ (p n /\ ~p n ) The resulting cnf: (p 1 \/ p 2 …\/p n ) /\ … /\(~p 1 \/… \/~p n ) contains 2 n clauses, each of size O(n). Question: Is it possible to get an equivalent one in cnf whose size is in O(n) ? Ans: yes ! but need the additional introduction of logical variables to denote the subformulas of the given wff.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Example Given A = ((p->q) /\ (~q \/ ~r)) ~p We use 7 vars to denote intermediate subformulas of A T 0 = (s0 s1 s2) T 1 = (s1 s1 /\ s4) T 2 = (s2 ~p) T 3 = (s3 p -> q) T 4 = (s4 s5 \/ s6) T 5 = (s5 ~q) T 6 = (s6 ~r) Then A is in some sense equivalent to s 0 /\ /\ k=0..6 T k /\ ~~ \/ -> ~ p q p qr s0 s1 s2 s3 s4 s5 s6
Logic in Computer Science Ch 3. Propositional Logic Transparency No Each T k can be transformed into an equivalent set of clauses as follows: T k is s ~t : [ = (s ~t) /\ (~t s) ] the result is (s \/ t) /\ (~s \/ ~t) T k is s u /\ v : [ = (s u) /\ ( s v) /\ (u /\ v ) s ] the result is (~s \/ u) /\ (~s \/ v) /\ (~u \/ ~v \/ s). T k is s u \/ v : [ = (s (u\/v)) /\ ( u s ) /\ (v s) ] the result is (~s \/ u \/ v) /\ (~u \/s ) /\ (~v \/ s). T k is s (u v) : [ = (s (~u\/ v)) /\ ( ~u s ) /\ (v s) ] the result is (~s \/ ~u \/ v) /\ (u \/s ) /\ (~v \/ s). T k is s u v : the result is ? (left as an exercise)
Logic in Computer Science Ch 3. Propositional Logic Transparency No Theorem Let A be any wff and let f(A) denote the cnf obtained from previous procedure with A as the given formula. The we have: for any interpretation : 1. If I |= f(A), then I |= A, and 2. if I |= A, then let I’ be the interpretation such that I(s i ) = I(A i ) for all subformula Ai of A where si is the vaiable use to denote Ai. we then have I’ |= f(A). Corollary: A is satisfiable iff f(A) is satisfiable. It is easy to construct a model of A from any model of f(A).
Logic in Computer Science Ch 3. Propositional Logic Transparency No 1. is a simple corollary of the following lemma: Lemma: For each subformula B of A, let S B denote the var (sk) introduced in previous procedure to represent B if B is not atomic and S B is B if B is atomic. Then for every model I of f(A) and for every subformula B of A, we have I |= B iff I|= S B. Pf: By structural Ind. on B. Case 1. B is a var p. Then S B = B = p and I |= B iff I |= S B. Case 2. B is ~C. Note that I |= S B ~S C. Then I |= B iff I |/= C iff (I.H.) I |/= S C iff I |/= S B. Case 3. B is C \/ D. Then I |= S B S C \/ S D, and I |= B iff I |= C \/ D iff I |= C or I |= D iff(i.h.) I |= S C or I |= S D iff I |= S C \/ S D iff I |= S B. The case that B is C/\D or C D or C D is similar to Case3.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Problems with Hilbert Style calculus Problems with Hilbert Style calculus: 1.The rule MP: A, A B // B is hard to use. To prove B via MP we have to prove A and A B for some A, but such A in general has nothing to do with B and is hard to choose. Ex: How to prove |- A A ? 2.The definition of proof does not allow the use of indirect proof and hence the user must either construct more sophisticated one or resort to more derived rules or meta theorems. Ex: p q, q r |- p r.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Problem: {P -> Q, Q -> R} |- P -> R Direct proof : ( Without Deduction Theorem: ) 1. P -> Q Premise 2. Q -> R Premise 3. (Q -> R) -> (P -> (Q -> R)) Ax1 4. (P -> (Q -> R)) MP:2,3 5. (P -> (Q -> R)) -> ((P -> Q) -> (P -> R)) Ax2 6. ((P -> Q) -> (P -> R)) MP:4,5 7. (P -> R) MP:1,6 (Indirect proof) With Deduction Theorem: Instead of show {P -> Q, Q -> R } |- P -> R, we prove that { P Q, Q R, P } |- R. 1. P -> Q Premise 2. Q -> R Premise 3. P Premise 4. Q MP:1,3 5. R MP:2,4
Logic in Computer Science Ch 3. Propositional Logic Transparency No Natural Deduction Another form of deduction. more goal driven; more like human reasoning allow the embedding of lemma proofs inside a proof. EX: Consider the proof of {p q, q r} |- p r. 1. `p q -- premise 2. q r -- premise 3.1 assume p -- assumption 3.2 q -- MP 3.3 r -- MP 3 p r -- note: 3 depends on 1&2 but not 3.1,3.2. A : B A B
Logic in Computer Science Ch 3. Propositional Logic Transparency No Rules in Natural Deduction The are two types of rules: 1. A 1,…,An (n ≥ 0) // B -- same as in Hilbert style calculus. 2. A 1, A 2,… A n ; [C 1 … D 1 ], … [C m … D m ] // B (m,n ≥ 0) Here [C k … D k ] means there is a subproof of D k with C k as the additional assumption. Ex [type 2]: (A\/B), [A … C], [B … C] // C note: type 2 rule is more popularly written vertically as follows: A B : : C C A\/B C
Logic in Computer Science Ch 3. Propositional Logic Transparency No Examples Inference rules : 1. I : [A … B] // A B if there is a subproof of B with A as an additional assumption, then infer A B. 2. e : A, A B // B (i.e., MP) Show that |- C C (i.e., there is a proof of C C). pf: 1.1 C -- assumption 1. C C -- I on 1.1 (where A = B = C) Hence |- C C.
Logic in Computer Science Ch 3. Propositional Logic Transparency No More Examples: |- A (B A). pf: 1.1 A-- assumption B -- assumption A B A -- I 1. A (B A).
Logic in Computer Science Ch 3. Propositional Logic Transparency No |- (A (B C) ) ((A B) (A C)) pf: A (B C) assumption (A B) ass. A ass. B C 3+1 B 3+2 C 5+5 A C I (A B) (A C) I (A (B C)) ((A B) (A C)). I
Logic in Computer Science Ch 3. Propositional Logic Transparency No rules for negation and falsity ~I : [A … F] // ~A ~e : A, ~A // F FI : no such rule Fe : F // A ~~e: ~~A // A Show useful derived rules: 1. A |- ~~A pf: A -- premise ~A -- assumption F -- ~e ~~A -- ~I
Logic in Computer Science Ch 3. Propositional Logic Transparency No A B, ~B |- ~A. pf: A --ass. A B -- premise B -- MP ~B -- premise F -- ~e ~A -- ~I 3. (PBC; proof by contradiction) [~A … F] // A pf: [ ~A … F ] ~~A -- ~I A -- ~~e. 4. |- (~B ~A) (A B) pf: ~B ~A A ~(~A)rule1 on 2 ~~B rule2 on 1 B ~~e A B (~B ~A) (A B)
Logic in Computer Science Ch 3. Propositional Logic Transparency No Rules for conjunction and disjunction /\I : A, B // (A /\ B) /\e : (A/\B) // A ; (A/\B) // B \/I : A // (A\/B) ; B // (A\/B) \/e : (A\/B), [A … C], [B … C] // C. or (A\/B), A --> C, B C) // C Ex: (A/\ B) |- (A \/ B) pf: A/\B -- premise A -- /\e A\/B -- \/I.
Logic in Computer Science Ch 3. Propositional Logic Transparency No Show that |- (A \/ ~A ) 1.pf: ~(A \/ ~A) 2. A 3. A \/ ~A \/I 4. A (A \/ ~A) 5. ~A 6. A \/ ~A \/I 7. ~A A \/ ~A 8. ~~A MT 1,7 9. ~A MT 1,4 10. F ~e 8,9 11. (A \/ ~A). PBC
Logic in Computer Science Ch 3. Propositional Logic Transparency No Soundness and completeness The system ND = (/\I + /\e + \/I + \/e + I + e + ~I + ~e + FI + ~~e) is sound and complete. pf: completeness: Since ND include MP and can derive all axioms (A1~A3), it subsume H0 and hence is complete. (i.e., |- H0 is a subset of |- ND ). Soundness can be proved by structural induction on the proof witnessing |- ND.