Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3....

19
Exercises for Logic Propositional Logic Rosella Gennari http://www.inf.unibz.it/ ~ gennari [email protected] Computer Science Free University of Bozen-Bolzano November 15, 2014

Transcript of Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3....

Page 1: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

Exercises for Logic

Propositional Logic

Rosella Gennarihttp://www.inf.unibz.it/~gennari

[email protected]

Computer Science

Free University of Bozen-Bolzano

November 15, 2014

Page 2: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

Disclaimer. The course exercises are meant as complementary material for thestudents of the course of Logic at the Free University of Bozen-Bolzano.

Page 3: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

Contents

1 Formulae: Trees and Strings 2

1.1 Generation of Strings . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2 Generation of Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Formalisation 3

2.1 Asimovland Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.2 Program specification (Homework) . . . . . . . . . . . . . . . . . . 3

2.3 Chemical reactions (Homework) . . . . . . . . . . . . . . . . . . . . 3

3 Subformulae 3

4 Truth tables 4

4.1 Formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

4.2 Chemical reactions (Homework) . . . . . . . . . . . . . . . . . . . . 4

5 Validity and Satisfiability of a Formula via Interpretations andTruth Tables 4

5.1 Formulae and Interpretations . . . . . . . . . . . . . . . . . . . . . 4

5.2 Semantic Arguments and Truth Tables for Decisions . . . . . . . . . 4

6 Equivalence 5

6.1 Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

6.2 Biimplication and Equivalence . . . . . . . . . . . . . . . . . . . . . 6

7 Normal Forms 6

7.1 Normal Form Transformation Procedures . . . . . . . . . . . . . . . 6

7.1.1 Implication-free Normal Form . . . . . . . . . . . . . . . . . 6

7.1.2 Negated Normal Form . . . . . . . . . . . . . . . . . . . . . 6

7.1.3 Conjunctive Normal Form . . . . . . . . . . . . . . . . . . . 7

7.1.4 Disjunctive Normal Form . . . . . . . . . . . . . . . . . . . . 7

7.2 Normal Form Transformation Exercises . . . . . . . . . . . . . . . . 7

7.2.1 NNF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

7.2.2 CNF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2

Page 4: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

1

7.2.3 DNF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

8 Validity and Satisfiability of a Formula via Tableaux 8

8.1 Tableaux for Decisions . . . . . . . . . . . . . . . . . . . . . . . . . 8

8.2 Tableaux for Constructing Models . . . . . . . . . . . . . . . . . . . 8

8.3 Opitmisations for Tableaux . . . . . . . . . . . . . . . . . . . . . . 9

8.3.1 Selection Heuristics . . . . . . . . . . . . . . . . . . . . . . . 9

8.3.2 Preprocessing Strategies . . . . . . . . . . . . . . . . . . . . 10

9 Satisfiability of a Set of Formulae via Tableaux 11

9.1 Satisfiability of a Set of Formulae and Satisfiability of a Formula . . 11

9.2 Satisfiability of a Set of Formulae via Tableaux . . . . . . . . . . . . 11

9.3 Verifying Set Satisfiability with Tableaux . . . . . . . . . . . . . . . 11

10 Entailment via Tableaux 12

10.1 Duality of Satisfiability and Entailment via Negation . . . . . . . . 12

10.2 Entailment and Validity . . . . . . . . . . . . . . . . . . . . . . . . 12

10.3 Entailment via Tableaux . . . . . . . . . . . . . . . . . . . . . . . . 12

10.4 Verifying Entailment with Tableaux . . . . . . . . . . . . . . . . . . 12

11 Entailment 13

11.1 Entailment: From Truth Tables to Formulae . . . . . . . . . . . . . 13

11.2 Entailment via Interpretations . . . . . . . . . . . . . . . . . . . . . 13

12 Formalisation and Reasoning 14

12.1 Entailment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

12.2 Set Satisfiability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

13 Boolean Circuits 16

13.1 From Circuits to Formulae . . . . . . . . . . . . . . . . . . . . . . . 16

13.2 From Formulae to Circuits . . . . . . . . . . . . . . . . . . . . . . . 16

13.3 Equivalent Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Page 5: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

1 FORMULAE: TREES AND STRINGS 2

1 Formulae: Trees and Strings

1.1 Generation of Strings

Consider the formula trees in Figure 1. For each of them, (1) specify their atoms,(2) generate the formulae of the associated trees using Algorithm 2.7 of your text-book.

�� ��p ∨

�� ��¬

��

>

p

�� ��¬

��

�� ��p p ¬

��p

��p ∨

��¬

��

p

q

Figure 1: Parsing Trees.

1.2 Generation of Trees

Let P be a set of atoms and L(P ) be the set of propositional formulas over P .The parenthesis depth of an occurence of a connective s ∈ {¬,∨,∧,→,↔} in anL(P ) formula is the number of left parentheses preceding s minus the number ofright parentheses preceding s.

Compute the parenthesis depth of ∨ and ¬ in the following formulas: (p ∨ q);(p ∨ (¬q)).Now, the main connective of a formula is the connective with parenthesis depthequal to 1.

Consider the following formulas:

1. ((¬p) ∨ (¬(¬q)));

2. ((p ∧ (¬q)) ∨ (¬p)).

Find their main connective. Can you think of an algorithm for generating thetrees associated to the above formulas? (Hint: use the above definition of mainconnective).

Page 6: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

2 FORMALISATION 3

2 Formalisation

2.1 Asimovland Exercise

Consider the following situation.

The satellite of Asimovland is inhabited by exactly two robots, Al andBob. The robots are subject to the following laws:

1. a robot protects the other robot if and only if the former robotdoes not harm the latter one (hint : careful with “a robot”);

2. it is necessary that Al protects itself for Bob to harm Al;

3. it is sufficient that Bob protects itself for Al to harm itself;

4. Bob does not protect Al.

Formalise the laws in a propositional language, by first rewriting them into state-ments with only “if-then”, “and”, “or”, “it is not the case that”.

2.2 Program specification (Homework)

Consider the following program and its informal specifications (in italics):

if x > 0 then y:=1 else y:=2; Sfi; z:=y;

// In case x ≤ 0 then y = 2. If the Sprogram terminates then z = 2. //

Formalise the two specifications in a suitable propositional language.

2.3 Chemical reactions (Homework)

Under certain conditions, the following chemical reactions are possible:

HCl +NaOH → NaCl +H2O,C +O2 → CO2,CO2 +H2O → H2CO3.

Formalise the above set of chemical reactions in a suitable propositional language.

3 Subformulae

Consider the trees in 1.2. For each of them, list the subformulae of the associatedformula.

Page 7: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

4 TRUTH TABLES 4

4 Truth tables

4.1 Formulae

Build the truth tables of the following formulae:

1. (¬(¬p));

2. (p ∧ (q ∧ ¬p));

3. ((p→ q)→ (¬q → ¬q)).

4.2 Chemical reactions (Homework)

Consider the set of propositional formulae formalising Exercise 2.3. Using truthtables, check whether the set augmented with the negation of the propositionalformula for H2CO3 is satisfiable.

5 Validity and Satisfiability of a Formula via In-

terpretations and Truth Tables

5.1 Formulae and Interpretations

– Find an interpretation and a formula such that the formula is true under thatinterpretation (or: the interpretation satisfies the formula; the interpretationis a model for the formula).

– Find an interpretation and a formula such that the formula is not true underthat interpretation (or: the interpretation does not satisfy the formula; theinterpretation is a counter-model for the formula)).

– Find a formula that cannot be true under any interpretation (or: no inter-pretation can satisfy the formula).

5.2 Semantic Arguments and Truth Tables for Decisions

Consider the following problems.

– Which of the following formulae is a tautology (true under all interpretationsfor its atoms)?

Page 8: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

6 EQUIVALENCE 5

– Which is (only) satisfiable (true under at least one interpretation for itsatoms)?

– Which is falsifiable (false under at least one interpretation for its atoms)?

– Which is unsatisfiable (false under all interpretations for its atoms)?

Decide on them by means of a semantic argument, that is, arguing about thedefinition of interpretation of a formula, or by means of truth tables.

1. p→ p;

2. p→ (q → p);

3. ¬¬p→ p;

4. ¬¬p↔ p;

5. (p→ q)↔ (¬p ∨ q).

6 Equivalence

6.1 Equivalence

Use Definition 2.26 of equivalence “≡” of your textbook in order to prove thefollowing equivalences:

1. p ∨ > ≡ >;

2. p ∨ ⊥ ≡ p;

3. p ∧ > ≡ p;

4. p ∧ ⊥ ≡ ⊥;

5. p ∨ ¬p ≡ >;

6. p ∧ ¬p ≡ ⊥;

7. ¬¬p ≡ p;

8. p→ q ≡ ¬p ∨ q;

9. p→ q ≡ ¬q → ¬p;

Page 9: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

7 NORMAL FORMS 6

10. ¬(p ∨ q) ≡ ¬p ∧ ¬q;

11. ¬(p ∧ q) ≡ ¬p ∨ ¬q.

Then use Substitution Theorem 2.34 of your textbook in order to generalise themto arbitrary propositional formulae.

6.2 Biimplication and Equivalence

Prove that the following formulae are valid building only the necessary rows oftheir truth table: ((

p ∧ (q ∨ r))↔((p ∧ q) ∨ (p ∧ r)

))((p ∨ (q ∧ r)

)↔((p ∨ q) ∧ (p ∨ r)

))Then use the above, Theorem 2.29 concerning biimplication and equivalence andthe Substitution Theorem 2.34 of your textbook in order to justify the followingequivalences: (

φ ∧ (ψ ∨ χ))≡((φ ∧ ψ) ∨ (φ ∧ χ)

)(φ ∨ (ψ ∧ χ)

)≡((φ ∨ ψ) ∧ (φ ∨ χ)

)7 Normal Forms

7.1 Normal Form Transformation Procedures

Consider a generic formula φ of a propositional language over P . Consider Theo-rem 4.3 of your textbook, Ben Ari, 3rd edition, and tackle what follows.

7.1.1 Implication-free Normal Form

Discuss a deterministic procedure for transforming φ into an equivalent formulawithout the → and ↔ symbols, and based on the following equivalences: ψ1 →ψ2 ≡ ¬ψ1 ∨ ψ2; ψ1 ↔ ψ2 ≡ (¬ψ1 ∨ ψ2) ∧ (¬ψ2 ∨ ψ1).

7.1.2 Negated Normal Form

Discuss a deterministic procedure for transforming φ into an equivalent formula innegated normal form (NNF), and based on the following equivalences: ¬(ψ1∨ψ2) ≡¬ψ1 ∧ ¬ψ2; ¬(ψ1 ∧ ψ2) ≡ ¬ψ1 ∨ ¬ψ2.

Page 10: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

7 NORMAL FORMS 7

7.1.3 Conjunctive Normal Form

Discuss a deterministic procedure for transforming φ into an equivalent formulain conjunctive normal form (CNF), and based on the following equivalences: ψ1 ∨(ψ2 ∧ ψ3) ≡ (ψ1 ∨ ψ2) ∧ (ψ1 ∨ ψ3); (ψ2 ∧ ψ3) ∨ ψ1 ≡ (ψ2 ∨ ψ1) ∧ (ψ3 ∨ ψ1).

7.1.4 Disjunctive Normal Form

Discuss a deterministic procedure for transforming φ into an equivalent formula indisjunctive normal form (DNF), starting from the CNF transformation procedure.

7.2 Normal Form Transformation Exercises

7.2.1 NNF

Transform the following formulae into NNF: ¬(¬p ∧ ¬q); ¬(¬p ∨ ¬q).

7.2.2 CNF

Transform the following formula into CNF: (p ∧ q) ∨ ¬(p ∨ q).Resolution. First transform into NNF, obtaining (p ∧ q) ∨ (¬p ∧ ¬q). Then startthe CNF procedure, scanning and distributing from left to right. Hereby go themain steps:

1. (p ∨ (¬p ∧ ¬q)) ∧ (q ∨ (¬p ∧ ¬q));

2. (p ∨ ¬p) ∧ (p ∨ ¬q) ∧ (q ∨ ¬p) ∧ (q ∨ ¬q).

More generally, if we consider the formula

(p1 ∧ q1) ∨ · · · ∨ (pn−1 ∧ qn−1) ∨ (pn ∧ qn)

with n distinct disjuncts, its CNF obtained as above will be of the form

(p1 ∨ · · · ∨ pn−1 ∨ pn) ∧ (p1 ∨ · · · ∨ pn−1 ∨ qn) ∧ · · · ∧ (q1 ∨ · · · ∨ qn−1 ∨ qn)

with 2n distinct conjuncts, each of which contains either pi or qi for each i = 1 . . . n.

7.2.3 DNF

Transform the following formula into DNF: (p ∨ q) ∧ ¬(p ∧ q).

Page 11: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

8 VALIDITY AND SATISFIABILITY OF A FORMULA VIA TABLEAUX 8

8 Validity and Satisfiability of a Formula via Tableaux

Note. Note that we follow Algorithm 2.64 of the course textbook for building atableau, with the following minor devations in labelling nodes of the tableau:

– consider node l and a formulae φ labelling l;

– in the texbook,

if a rule is applied to φ then φ is removed from the set U(l) ofusable formulae, and not repeated as label of the freshly creatednodes,

else, for signifying that a rule may still be applied to it, φ is repeatedas label of the freshly created nodes;

– we, instead, proceed as follows:

if a rule is applied to φ then φ is enclosed in square brackets orcrossed out;

else, for signifying that a rule may still be applied to it, φ is notenclosed in square brackets nor crossed out;

– such a trick allows us to avoid repeating formulae to which a rule may stillbe applied along branches.

8.1 Tableaux for Decisions

Consider the following problem. Which of the following formulae is a tautology(true under all interpretations for its atoms, valid)? Decide on it with the tableauprocedure.

1. p→ (p ∨ q);

2. (p→ q)→ (¬q → ¬p);

3. (q → p)→ p;

4. (⊥ ∧ ¬¬q) ∨ q.

8.2 Tableaux for Constructing Models

Use the tableau procedure and: (1) prove that the following formulae are satisfi-able; (2) build a model for each of them.

Page 12: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

8 VALIDITY AND SATISFIABILITY OF A FORMULA VIA TABLEAUX 9

1. ¬(p→ (p ∧ q));

2. (p ∨ (p ∧ q));

3. (⊥ ∧ ¬¬q) ∨ q.

Resolution of 1:

[¬(p→ (p ∧ q))]

p ¬→-rule[¬(p ∧ q)] ¬→-rule

¬p ¬∧-ruleclosed

¬q ¬∧-rule

The tableau has an open branch and thus the formula is satisfiable, A model isthe interpretation I with I(p) = 1 and I(q) = 0, obtained from the open (right)branch.

Resolution of 3:

[(⊥ ∧ ¬¬q) ∨ q]

[⊥ ∧ ¬¬q] ∨-rule

⊥ ∧-rule¬¬q ∧-rule

q ∨-rule

The tableau has an open branch and thus the formula is satisfiable, A model is theinterpretation I with I(q) = 1, obtained from the open (right) branch.

8.3 Opitmisations for Tableaux

8.3.1 Selection Heuristics

Consider the following formula: ¬((p ∧ q) → (q ∧ p)). Build two tableau for it:one in which you apply a β rule before an α one; the other in which you do thevice-versa.

Resolution. Applying first a β rule before an α one, we get the following tableau.

Page 13: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

8 VALIDITY AND SATISFIABILITY OF A FORMULA VIA TABLEAUX 10

[¬(p ∧ q → q ∧ p)]

[p ∧ q] ¬→-rule[¬(q ∧ p)] ¬→-rule

¬p ¬∧-rule

p ∧-ruleq ∧-rule

¬q ¬∧-rule

p ∧-ruleq ∧-rule

Applying first an α rule before a β one, we get the following tableau.

[¬(p ∧ q → q ∧ p)]

[p ∧ q] ¬→-rule[¬(q ∧ p)] ¬→-rule

p ∧-ruleq ∧-rule

¬q ¬∧-ruleclosed

¬p ¬∧-ruleclosed

The latter tableau is built with the following optimisation heuristics: choosing firstnodes with α formulae, and then nodes with β formulae. In this manner, the sameformulae are not repeated in different branches; rather, they occur as left labelsabove all those branching nodes.

8.3.2 Preprocessing Strategies

Consider the following problem. Which of the following formulae is a tautology(true under all interpretations for its atoms, valid)? Consider the equivalencesin Ex. 6.1 from 1–7. Use these for pre-processing the following formulae intoequivalent ones so as to reduce their length (as strings). Then apply the tableauprocedure to decide on the above problem.

1. (> ∨ ¬¬q) ∨ (q ∧ ¬q);

2. (p→ q) ∧ (q ∧ ¬q).

Page 14: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

9 SATISFIABILITY OF A SET OF FORMULAE VIA TABLEAUX 11

9 Satisfiability of a Set of Formulae via Tableaux

9.1 Satisfiability of a Set of Formulae and Satisfiability ofa Formula

Deciding on the satisfiability of {φ1, . . . , φn} is equivalent to deciding on the sat-isfiability of

∧ni=1 φi, with n ≥ 2. Prove it.

9.2 Satisfiability of a Set of Formulae via Tableaux

The equivalence in Exercise 9.1 and Corollary 2.68 of your textbook allow us touse tableaux for deciding on the satisfiability of a finite set of formulae.

Consider any {φ1, . . . , φn} ⊆ PL(P). Build a tableau for∧n

i=1 φi with the tableauprocedure in your textbook. If the tableau has an open branch, then {φ1, . . . , φn}is satisfiable, and the open branch defines a model for the set; else the set isunsatisfiable.

9.3 Verifying Set Satisfiability with Tableaux

Let us prove that the set {p ∨ q,¬p} is satisfiable by building a tableau with anopen branch for the formula (p ∨ q) ∧ ¬p.

(p ∨ q) ∧ ¬p

p ∨ q¬p

pclosed

q

The rigth-more branch gives the interpretation I(q) = T and I(p) = F that satisfiesthe set.

Note 1. In general, to save space, we can silently apply the ∧-rule when buildinga tableau for Θ = {φ1, . . . , φn}, and write all the formulae of Θ one below theother, left labelling the root. With such expedient, the previous tableau would beshortened as follows.

p ∨ q¬p

pclosed

q

Page 15: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

10 ENTAILMENT VIA TABLEAUX 12

10 Entailment via Tableaux

10.1 Duality of Satisfiability and Entailment via Negation

Having ¬ in the language, entailment and set (un)satisfiability are complementaryproblems in the following sense: Θ |= φ iff Θ ∪ {(¬φ)} is unsatisfiable. Prove itwith the semantic argument—reasoning on the definition of interpretation.

10.2 Entailment and Validity

Deciding on {φ1, . . . , φn} |= φ is equivalent to deciding on the unsatisfiability of∧ni=1 φi ∧ (¬φ). Prove it using the above result and Exercise 9.2.

10.3 Entailment via Tableaux

The equivalence in Exercise 10.2 and Corollary 2.68 of your textbook allow us touse tableaux for deciding on entailment from a finite set of formulae.

Consider any {φ1, . . . , φn} ∪ {φ} ⊆ PL(P). Build a tableau for∧n

i=1 φi ∧ (¬φ)with the tableau procedure in your textbook. If all the branches of the tableauare closed, then {φ1, . . . , φn} |= φ; else {φ1, . . . , φn} 6|= φ, and an open branch ofthe tableau defines a model of {φ1, . . . , φn} that does not satisfy φ.

10.4 Verifying Entailment with Tableaux

Let us prove p ∧ q |= p by building a tableau for (p ∧ q) ∧ ¬p with only closedbranches.

(p ∧ q) ∧ ¬p

p ∧ q¬p

pclosed

Note 2. With the expedient in Note 1, the previous tableau can be shortened asfollows.

Page 16: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

11 ENTAILMENT 13

p ∧ q¬p

pclosed

11 Entailment

11.1 Entailment: From Truth Tables to Formulae

Let P = {p, q, r}. Let φ, ψ, θ, χ be formulae of PL(P) with the following truthtable:

p q r φ ψ θ χ

1 1 1 1 0 0 11 1 0 0 0 0 01 0 1 1 1 1 01 0 0 1 0 0 10 1 1 0 0 1 00 1 0 1 1 1 10 0 1 1 0 1 00 0 0 1 1 0 0

1. Is {(φ↔ ¬ψ), θ, χ} satisfiable? Explain your answer.

2. Determine whether {φ, ψ, θ} |= χ.

3. Determine whether |= (φ ∨ ψ ∨ θ ∨ χ).

11.2 Entailment via Interpretations

Prove or refute (i.e., show a counterexample) each of the following assertions usinginterpretations (i.e., Θ |= φ iff every model of Θ is a model of φ) or truth tables:

1. Θ ∪ {¬φ} is unsatisfiable iff Θ |= φ.

2. if Θ |= φ ∧ φ′ and then Θ |= φ (Θ |= φ′);

3. if Θ |= φ ∨ φ′ then Θ |= φ;

4. if Θ |= φ then Θ |= φ ∨ φ′.

Page 17: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

12 FORMALISATION AND REASONING 14

12 Formalisation and Reasoning

12.1 Entailment

1. Consider the following argument.

If Paul lives in Dublin, he lives in Ireland. Paul lives in Dublin. There-fore Paul live in Ireland.

(i) Formalise the argument using a minimal propositional language; (ii) use thesemantic argument (e.g., use interpretations), truth tables and tableau in order todecide on the entailment.

2. (Homework) Consider the following argument.

If Spain reached the World Cup finals, then either Ireland did not slipup or Denmark played very well. If Spain reached the World Cup finalsthen Ireland slipped up. Denmark did not play very well. Therefore,Spain reached the World Cup finals if and only if Ireland slipped up.

(i) Formalise the argument as an entailment using a minimal propositional lan-guage; (ii) use the semantic argument (e.g., use interpretations), truth tables ortableaux in order to decide on the entailment.

3. (Homework) Suppose you are given the following set of statements:

1. If the movie “Asterix” is not worth seeing then it was not made in Britain.

2. “Asterix” is worth seeing only if critic Chris reviews it.

3. The movie “Asterix” was not reviewed by Chris.

4. Therefore “Asterix” was not made in Britain.

Use the semantic argument (e.g., use interpretations), truth tables or tableaux inorder to decide on the entailment.

4. Consider the following situation.

The satellite of Asimovland is inhabited by exactly two robots, Al andBob. The robots are subject to the following laws:

Page 18: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

12 FORMALISATION AND REASONING 15

1. a robot protects the other robot if and only if the former robotdoes not harm the latter one (hint : careful with “a robot”);

2. if Bob harms Al then Al protects itself;

3. if Bob protects itself then Al protects itself.

4. Therefore Bob does not protect Al.

(i) Formalise the laws and entailed sentence (“Bob does not protect Al”) using asuitable propositional language. (ii) Use the semantic argument (e.g., use inter-pretations), truth tables or tableaux to decide on the resulting entailment. (iii)Could you formalise the laws in a propositional language if you did not know thenumber of inhabitants?

12.2 Set Satisfiability

1. (Homework) Consider the following situation.

(1) If Paul lives in Dublin, he lives in Ireland. (2) Paul lives in Dublin.(3) Paul lives in Ireland.

(i) Formalise (1), (2) and (3) using a minimal propositional language; (ii) build atruth table or use interpretations to decide on the satisfiability of the resulting setof formulae.

2. Suppose that an island is inhabited by exactly two persons, Angelo and Roberto.Given this, consider the following argument.

(1) If Angelo shaves an inhabitant then this shaves Roberto. (2) More-over, if Roberto shaves an inhabitant then this does not shave Angelo.(3) Roberto shaves himself.

(i) Formalise (1), (2) and (3) using a suitable propositional language and (ii) builda truth table or use interpretations to decide on the satisfiability of the resulting setof formulae. (iii) Could you formalise (1), (2) and (3) in a propositional languageif you did not know the number of inhabitants? Try using a first order language.

Page 19: Exercises for Logic - unibz · Consider the set of propositional formulae formalising Exercise 2.3. Using truth tables, check whether the set augmented with the negation of the propositional

13 BOOLEAN CIRCUITS 16

13 Boolean Circuits

13.1 From Circuits to Formulae

Define a propositional language (i.e., atoms) and formulae associated to the Booleancircuits in the below figure. Then compute the related truth table.

76 Chapter 2 The Logic of Compound Statements

Exercise Set 2.4Give the output signals for the circuits in 1–4 if the input signalsare as indicated.

1. P

Q

ROR

NOT

input signals: P = 1 and Q = 1

2.OR

NOT

P

RQ AND

input signals: P = 1 and Q = 0

3. P

Q

R

ORNOTAND

S

input signals: P = 1, Q = 0, R = 0

4. P

Q

RNOT

OROR

AND

S

input signals: P = 0, Q = 0, R = 0

In 5–8, write an input/output table for the circuit in the refer-enced exercise.

5. Exercise 1 6. Exercise 2

7. Exercise 3 8. Exercise 4

In 9–12, find the Boolean expression that corresponds to the cir-cuit in the referenced exercise.

9. Exercise 1 10. Exercise 2

11. Exercise 3 12. Exercise 4

Construct circuits for the Boolean expressions in 13–17.

13. !P " Q 14. !(P " Q)

15. P " (!P # !Q) 16. (P # Q) " !R

17. (P # !Q) " (!P # R)

For each of the tables in 18–21, construct (a) a Boolean expres-sion having the given table as its truth table and (b) a circuithaving the given table as its input/output table.

18.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 0

0 0 1 0

0 0 0 0

19.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 1

0 1 1 0

0 1 0 1

0 0 1 0

0 0 0 0

20.P Q R S

1 1 1 1

1 1 0 0

1 0 1 1

1 0 0 0

0 1 1 0

0 1 0 0

0 0 1 0

0 0 0 1

21.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 1

0 0 1 0

0 0 0 0

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

76 Chapter 2 The Logic of Compound Statements

Exercise Set 2.4Give the output signals for the circuits in 1–4 if the input signalsare as indicated.

1. P

Q

ROR

NOT

input signals: P = 1 and Q = 1

2.OR

NOT

P

RQ AND

input signals: P = 1 and Q = 0

3. P

Q

R

ORNOTAND

S

input signals: P = 1, Q = 0, R = 0

4. P

Q

RNOT

OROR

AND

S

input signals: P = 0, Q = 0, R = 0

In 5–8, write an input/output table for the circuit in the refer-enced exercise.

5. Exercise 1 6. Exercise 2

7. Exercise 3 8. Exercise 4

In 9–12, find the Boolean expression that corresponds to the cir-cuit in the referenced exercise.

9. Exercise 1 10. Exercise 2

11. Exercise 3 12. Exercise 4

Construct circuits for the Boolean expressions in 13–17.

13. !P " Q 14. !(P " Q)

15. P " (!P # !Q) 16. (P # Q) " !R

17. (P # !Q) " (!P # R)

For each of the tables in 18–21, construct (a) a Boolean expres-sion having the given table as its truth table and (b) a circuithaving the given table as its input/output table.

18.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 0

0 0 1 0

0 0 0 0

19.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 1

0 1 1 0

0 1 0 1

0 0 1 0

0 0 0 0

20.P Q R S

1 1 1 1

1 1 0 0

1 0 1 1

1 0 0 0

0 1 1 0

0 1 0 0

0 0 1 0

0 0 0 1

21.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 1

0 0 1 0

0 0 0 0

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

76 Chapter 2 The Logic of Compound Statements

Exercise Set 2.4Give the output signals for the circuits in 1–4 if the input signalsare as indicated.

1. P

Q

ROR

NOT

input signals: P = 1 and Q = 1

2.OR

NOT

P

RQ AND

input signals: P = 1 and Q = 0

3. P

Q

R

ORNOTAND

S

input signals: P = 1, Q = 0, R = 0

4. P

Q

RNOT

OROR

AND

S

input signals: P = 0, Q = 0, R = 0

In 5–8, write an input/output table for the circuit in the refer-enced exercise.

5. Exercise 1 6. Exercise 2

7. Exercise 3 8. Exercise 4

In 9–12, find the Boolean expression that corresponds to the cir-cuit in the referenced exercise.

9. Exercise 1 10. Exercise 2

11. Exercise 3 12. Exercise 4

Construct circuits for the Boolean expressions in 13–17.

13. !P " Q 14. !(P " Q)

15. P " (!P # !Q) 16. (P # Q) " !R

17. (P # !Q) " (!P # R)

For each of the tables in 18–21, construct (a) a Boolean expres-sion having the given table as its truth table and (b) a circuithaving the given table as its input/output table.

18.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 0

0 0 1 0

0 0 0 0

19.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 1

0 1 1 0

0 1 0 1

0 0 1 0

0 0 0 0

20.P Q R S

1 1 1 1

1 1 0 0

1 0 1 1

1 0 0 0

0 1 1 0

0 1 0 0

0 0 1 0

0 0 0 1

21.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 1

0 0 1 0

0 0 0 0

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

76 Chapter 2 The Logic of Compound Statements

Exercise Set 2.4Give the output signals for the circuits in 1–4 if the input signalsare as indicated.

1. P

Q

ROR

NOT

input signals: P = 1 and Q = 1

2.OR

NOT

P

RQ AND

input signals: P = 1 and Q = 0

3. P

Q

R

ORNOTAND

S

input signals: P = 1, Q = 0, R = 0

4. P

Q

RNOT

OROR

AND

S

input signals: P = 0, Q = 0, R = 0

In 5–8, write an input/output table for the circuit in the refer-enced exercise.

5. Exercise 1 6. Exercise 2

7. Exercise 3 8. Exercise 4

In 9–12, find the Boolean expression that corresponds to the cir-cuit in the referenced exercise.

9. Exercise 1 10. Exercise 2

11. Exercise 3 12. Exercise 4

Construct circuits for the Boolean expressions in 13–17.

13. !P " Q 14. !(P " Q)

15. P " (!P # !Q) 16. (P # Q) " !R

17. (P # !Q) " (!P # R)

For each of the tables in 18–21, construct (a) a Boolean expres-sion having the given table as its truth table and (b) a circuithaving the given table as its input/output table.

18.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 0

0 0 1 0

0 0 0 0

19.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 1

0 1 1 0

0 1 0 1

0 0 1 0

0 0 0 0

20.P Q R S

1 1 1 1

1 1 0 0

1 0 1 1

1 0 0 0

0 1 1 0

0 1 0 0

0 0 1 0

0 0 0 1

21.P Q R S

1 1 1 0

1 1 0 1

1 0 1 0

1 0 0 0

0 1 1 1

0 1 0 1

0 0 1 0

0 0 0 0

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

13.2 From Formulae to Circuits

Find the Boolean circuits associated to the following formulae: ¬p ∨ q; ¬(p ∨ q).

13.3 Equivalent Circuits

Show that the circuits below are associated to equivalent formulae using thetableau procedure to decide on the equivalence.

2.4 Application: Digital Logic Circuits 77

22. Design a circuit to take input signals P, Q, and R and out-put a 1 if, and only if, P and Q have the same value and Qand R have opposite values.

23. Design a circuit to take input signals P , Q, and R and out-put a 1 if, and only if, all three of P, Q, and R have thesame value.

24. The lights in a classroom are controlled by two switches:one at the back and one at the front of the room. Movingeither switch to the opposite position turns the lights off ifthey are on and on if they are off. Assume the lights havebeen installed so that when both switches are in the downposition, the lights are off. Design a circuit to control theswitches.

25. An alarm system has three different control panels in threedifferent locations. To enable the system, switches in atleast two of the panels must be in the on position. If fewerthan two are in the on position, the system is disabled.Design a circuit to control the switches.

Use the properties listed in Theorem 2.1.1 to show that eachpair of circuits in 26–29 have the same input/output table. (Findthe Boolean expressions for the circuits and show that they arelogically equivalent when regarded as statement forms.)

26. a. P

Q ORAND

b. P

QOR

AND

27. a. P

Q

AND

AND

NOT

NOT

b. P

QNOTOR

28. a. P

Q

NOT

NOT

NOT

AND

AND

AND

OR

b. P

Q NOTOR

29. a. P

QAND

AND ORNOT

ANDNOT

b. P

QOR

For the circuits corresponding to the Boolean expressions ineach of 30 and 31 there is an equivalent circuit with at mosttwo logic gates. Find such a circuit.

30. (P ! Q) " (#P ! Q) " (#P ! #Q)

31. (#P ! #Q) " (#P ! Q) " (P ! #Q)

32. The Boolean expression for the circuit in Example 2.4.5 is

(P ! Q ! R) " (P ! #Q ! R) " (P ! #Q ! #R)

(a disjunctive normal form). Find a circuit with at mostthree logic gates that is equivalent to this circuit.

33. a. Show that for the Sheffer stroke |,P ! Q $ (P | Q) | (P | Q).

b. Use the results of Example 2.4.7 and part (a) above towrite P ! (#Q " R) using only Sheffer strokes.

34. Show that the following logical equivalences hold for thePeirce arrow %, where P % Q $ #(P " Q).

a. #P $ P % Pb. P " Q $ (P % Q) % (P % Q)

c. P ! Q $ (P % P) % (Q % Q)

d.H Write P & Q using Peirce arrows only.e. Write P ' Q using Peirce arrows only.

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.