Solution 1-Logics

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Logic in Computer Science (COMP118) Tutorial Problems 1 1.

Let p1 denote the proposition: Toms house is red; p2 denote the proposition: Jims house is red; p3 denote the proposition: Marys house is red. Translate into propositional logic: Toms house is red or Jims house is red; If Jims house is red, then Toms house is red and Marys house is red; Toms house is not red; Jims house is red if, and only if, Toms house is not red; Neither Jims nor Marys house is red. Let P1 , P2 , . . . , P5 be the translations into propositional logic of the ve sentences above. For each Pi , 1 i 5: give an interpretation I such that I (Pi ) = 1 and give an interpretation J such that J (Pi ) = 0. 2. Give a denition of satisable formulas. 3. Which of the following formulas are satisable? Check this (a) using truth tables and (b) using the tableau algorithm. (p (p q )); ((p q ) r); ((p q ) (q p)); ((p q ) (p q ));

(((p q ) p) q ). (Hint: We do not have tableau rules for . Thus, has to be replaced by its denition before the tableau rules can be applied.) 4. Call a propositional formula P positive if it does not contain the symbol . Give an inductive denition of positive formulas. Show that every positive formula is satisable. Solution for 1. P1 = (p1 p2 ). Let I (p1 ) = 1 and I (p2 ) = 1. Then I (P1 ) = 1. Let J (p1 ) = 0 and J (p2 ) = 0. Then J (P1 ) = 0. P2 = (p2 (p1 p3 )). Let I (p1 ) = 1 and I (p2 ) = 1 and I (p3 ) = 1. Then I (P2 ) = 1. Let J (p1 ) = 1 and J (p2 ) = 0 and J (p3 ) = 0. Then J (P2 ) = 0. P3 = p1 . Let I (p1 ) = 0. Then I (P3 ) = 1. Let J (p1 ) = 1. Then J (P3 ) = 0. P4 = (p2 p1 ). Let I (p2 ) = 1 and I (p1 ) = 0. Then I (P4 ) = 1. Let J (p1 ) = 1 and J (p2 ) = 1. Then J (P4 ) = 0. P5 = (p2 p3 ). Let I (p2 ) = 0 and I (p3 ) = 0. Then I (P5 ) = 1. Let J (p2 ) = 1 and J (p3 ) = 1. Then J (P5 ) = 0. Solution for 3. For P1 = (p (p q )) we have the following truth table: p 1 1 0 0 q p p (p q ) (p q ) P1 1 0 1 1 0 0 0 0 1 1 0 0 1 1 0 1 0 0 0 1 0 0 1 0

It follows that I (P1 ) = 0 for all interpretations I . Hence P1 is not satisable. Using the tableau algorithm, we set S0 = {P1 }.

An application of = to S0 gives S1 = S0 {p, (p q )} An application of = to S1 gives S2 = S1 {p, q } S2 contains the clash {p, p}. Since we obtained a tableau path with a clash and we only applied nonbranching rules, it follows that P1 is not satisable. Note that we applied only non-branching rules. Nevertheless, there are of course more tableau paths starting with S0 = {P1 }. Namely, An application of = to S0 gives S1 = S0 {p, (p q )} An application of = to S1 gives S2 = S1 {p} An application of = to S2 gives S3 = S2 {p, q } S3 contains a clash (actually two). Thus, again we obtain that P1 is not satisable. This type of nondeterminism of the algorithm (caused by dierent orders in which the rules are applied) is called dont care non-determinism: it does not depend on which rule we apply rst whether we obtain a clash or not. For P2 = ((p q ) r) we have the following truth table:

p 1 1 1 1 0 0 0 0

q 1 1 0 0 1 1 0 0

r p r (p q ) (p q ) P2 1 1 0 1 0 0 0 1 1 1 0 0 1 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 0 1 1 0 0

It follows that I (P2 ) = 1 for at least one interpretation I . Thus, P2 is satisable. Using the tableau algorithm, we set S0 = {P2 }. An application of = to S0 gives S1 = S0 {(p q ), r} An application of = to S1 gives S2 = S1 {p, q } An application of = to S2 gives S3 = S2 {p} S3 is complete and contains no clash. Thus, P2 is satisable. First we unfold the abbreviation for and obtain P3 = ((p q ) (q p)). We obtain the following truth table: p 1 1 0 0 q p q (p q ) (q p) (q p) P3 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 0

It follows that I (P3 ) = 1 for at least one interpretation I . Hence P3 is satisable. Using the tableau algorithm, we set S0 = {P3 }. An application of = to S0 gives S1 = S0 {(p q ), (q p)} An application of = to S1 gives S2 = S1 {q, p} An application of = to S2 gives S3 = S2 {q } No rule is applicable to S3 = {P3 , (pq ), (q p), q, p, q }. S3 does not contain a clash. Thus, P3 is satisable. First we unfold the abbreviation for and obtain P4 = ((p q ) (p q )). We obtain the following truth table: p 1 1 0 0 q p (p q ) (p q ) P4 1 0 1 0 0 0 0 0 1 0 1 1 1 0 0 0 1 1 0 0

It follows that I (P4 ) = 0 for all interpretations I . Hence P4 is not satisable. Using the tableau algorithm, we set S0 = {P4 }. An application of = to S0 gives S1 = S0 {(p q ), (p q )} S1 contains a clash. Thus, P4 is not satisable. We set P5 = (((p q ) p) q ) and obtain the truth table:

p 1 1 0 0

q (p q ) (p q ) ((p q ) p) P4 1 1 0 0 0 0 0 1 1 0 1 0 1 0 0 0 0 1 0 0

It follows that I (P5 ) = 0 for all interpretations I . Hence P5 is not satisable. Using the tableau algorithm, we set S0 = {P5 }. An application of = to S0 gives S1 = S0 {((p q ) p), q } An application of = to S1 gives S2 = S1 {((p q ), p} An appication of = to S2 gives S3 = S2 {p} which contains the clash {p, p}. The other application of = to S2 gives S4 = S3 {q } which contains the clash {q, q }. Thus, all complete tableaus starting with {P5 } contain a clash. Hence P5 is not satisable. Solution for 4. A denition of positive formulas is as follows: all atomic formulas are positive formulas; if P and Q are positive formulas, then (P Q) is a positive formula;

if P and Q are positive formulas, then (P Q) is a positive formula; Nothing else is a positive formula. Every positive formula is satisable: Let P be a positive formula. We set I (p) = 1 for every atomic formula p and show by induction over the construction of positive formulas Q that I (Q) = 1. For atomic formulas this follows from the denition. Assume Q = (Q1 Q2 ). By induction hypothesis, I (Q1 ) = 1 and I (Q2 ) = 1. Thus I (Q) = 1. Assume Q = (Q1 Q2 ). By induction hypothesis, I (Q1 ) = 1 and I (Q2 ) = 1. Thus I (Q) = 1.

You might also like