Exercises Booklet
Exercises Booklet
1 Introduction 3
2 Propositional Logic 5
2.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Truth Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Propositional Formalization . . . . . . . . . . . . . . . . . . . . . 10
2.3.1 Formalizing Simple Sentences . . . . . . . . . . . . . . . . 10
2.3.2 Formalizing Problems . . . . . . . . . . . . . . . . . . . . 17
2.4 Normal Form Reduction . . . . . . . . . . . . . . . . . . . . . . . 28
4 Modal Logic 55
4.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.2 Satisfiability and Validity . . . . . . . . . . . . . . . . . . . . . . 63
4.3 Modal Logic Formalization . . . . . . . . . . . . . . . . . . . . . . 76
1
Mathematics is the only
instructional material that can
be presented in an entirely
undogmatic way.
The Mathematical
Intelligencer, v. 5, no. 2, 1983
Chapter 1 M AX D EHN
Introduction
Symbol Difficulty
Trivial
Easy
Medium
Difficult
Very difficult
3
When you have eliminated the
impossible, what ever remains,
however improbable must be
the truth.
Propositional Logic
Exercise 2.1. -
Which of the following are well formed propositional formulas?
1. ∨pq
2. (¬(p → (q ∧ p)))
3. (¬(p → (q = p)))
4. (¬(♦(q ∨ p)))
5. (p ∧ ¬q) ∨ (q → r)
6. p¬r
Solution.
5
Propositional Logic
Exercise 2.2. -
Let’s consider the interpretation v where v(p) = F, v(q) = T, v(r) = T.
Does v satisfy the following propositional formulas?
1. (p → ¬q) ∨ ¬(r ∧ q)
3. ¬(¬p → ¬q) ∧ r
4. ¬(¬p → q ∧ ¬r)
Solution.
Exercise 2.3. -
Compute the truth table of (F ∨ G) ∧ ¬(F ∧ G).
Solution.
F G F ∨G F ∧G ¬(F ∧ G) (F ∨ G) ∧ ¬(F ∧ G)
T T T T F F
T F T F T T
F T T F T T
F F F F T F
6
2.2 Truth Tables
Exercise 2.4. -
Use the truth tables method to determine whether (p → q) ∨ (p → ¬q) is valid.
Solution.
p q p→q ¬q p → ¬q (p → q) ∨ (p → ¬q)
T T T F F T
T F F T T T
F T T F T T
F F T T T T
Exercise 2.5. -
Use the truth tables method to determine whether (¬p∨q)∧(q → ¬r∧¬p)∧(p∨r)
(denoted with ϕ) is satisfiable.
Solution.
p q r ¬p ∨ q ¬r ∧ ¬p q → ¬r ∧ ¬p (p ∨ r) ϕ
T T T T F F T F
T T F T F F T F
T F T F F T T F
T F F F F T T F
F T T T F F T F
F T F T T T F F
F F T T F T T T
F F F T T T F F
There exists an interpretation satisfying ϕ, thus ϕ is satisfiable.
7
Propositional Logic
Exercise 2.6. -
Use the truth tables method to determine whether the formula ϕ : p∧¬q → p∧q
is a logical consequence of the formula ψ : ¬p.
Solution.
p q ¬p p ∧ ¬q p∧q p ∧ ¬q → p ∧ q
T T F F T T
T F F T F F ψ |= ϕ since each
F T T F F T
F F T F F T
Exercise 2.7. -
Use the truth tables method to determine whether p → (q ∧ ¬q) and ¬p are
logically equivalent.
Solution.
p q q ∧ ¬q p → (q ∧ ¬q) ¬p
T T F F F
T F F F F The two formulas are equivalent since
F T F T T
F F F T T
for every possible interpretation they evaluate to tha same truth value.
Exercise 2.8.
Compute the truth tables for the following propositional formulas:
8
2.2 Truth Tables
• (p → p) → p
• p → (p → p)
• p∨q →p∧q
• p ∨ (q ∧ r) → (p ∧ r) ∨ q
• p → (q → p)
• (p ∧ ¬q) ∨ ¬(p ↔ q)
Exercise 2.9.
Use the truth table method to verify whether the following formulas are valid,
satisfiable or unsatisfiable:
• (p → q) ∧ ¬q → ¬p
• (p → q) → (p → ¬q)
• (p ∨ q → r) ∨ p ∨ q
• (p ∨ q) ∧ (p → r ∧ q) ∧ (q → ¬r ∧ p)
• (p ∨ q) ∧ (¬q ∧ ¬p)
• (p → q) ∧ (p → ¬q)
• (p → (q ∨ r)) ∨ (r → ¬p)
9
Propositional Logic
Exercise 2.10.
Use the truth table method to verify whether the following logical consequences
and equivalences are correct:
• (p → q) |= ¬p → ¬q
• (p → q) ∧ ¬q |= ¬p
• p → q ∧ r |= (p → q) → r
• p ∨ (¬q ∧ r) |= q ∨ ¬r → p
• ¬(p ∧ q) ≡ ¬p ∨ ¬q
• (p ∨ q) ∧ (¬p → ¬q) ≡ q
• (p ∧ q) ∨ r ≡ (p → ¬q) → r
• (p ∨ q) ∧ (¬p → ¬q) ≡ p
• ((p → q) → q) → q ≡ p → q
Exercise 2.11. -
Let’s consider a propositional language where
10
2.3 Propositional Formalization
1. “if Paola is happy and paints a picture then Renzo isn’t happy”
Solution.
1. p ∧ q → ¬r
2. p → q
Exercise 2.12. -
Let’s consider a propositional language where
• q means “x is odd”.
11
Propositional Logic
Exercise 2.13. -
Let A =“Aldo is Italian” and B =“Bob is English”.
Formalize the following sentences:
5. “Either Aldo is Italian and Bob is English, or neither Aldo is Italian nor
Bob is English”
Solution.
1. ¬A
2. A ∧ B
3. A → ¬B
Exercise 2.14.
Angelo, Bruno and Carlo are three students that took the Logic exam. Let’s
consider a propositional language where
12
2.3 Propositional Formalization
3. “Only one, among Aldo, Bruno and Carlo, passed the exam”
5. “At least two among Aldo, Bruno and Carlo passed the exam”
6. “At most two among Aldo, Bruno and Carlo passed the exam”
7. “Exactly two, among Aldo, Bruno and Carlo passed the exam”
Exercise 2.15. -
Let’s consider a propositional langiage where
1. “If Davide comes to the party then Bruno and Carlo come too”
2. “Carlo comes to the party only if Angelo and Bruno do not come”
3. “Davide comes to the party if and only if Carlo comes and Angelo doesn’t
come”
4. “If Davide comes to the party, then, if Carlo doesn’t come then Angelo
comes”
5. “Carlo comes to the party provided that Davide doesn’t come, but, if
Davide comes, then Bruno doesn’t come”
13
Propositional Logic
7. “Angelo, Bruno and Carlo come to the party if and only if Davide doesn’t
come, but, if neither Angelo nor Bruno come, then Davide comes only if
Carlo comes”
Solution.
1. D → B ∧ C
2. C → ¬A ∧ ¬B
3. D ↔ (C ∧ ¬A)
4. D → (¬C → A)
5. (¬D → C) ∧ (D → ¬B)
6. A → (¬B ∧ ¬C → D)
Exercise 2.16.
Let’s consider a propositional langiage where
2. “Either Carlo comes to the party, or Bruno and Davide don’t come”
14
2.3 Propositional Formalization
3. “If Angelo and Bruno come to the party, then Carlo comes provided that
Davide doesn’t come”
4. “Carlo comes to the party if Bruno and Angelo don’t come, or if Davide
comes”
5. “If Angelo comes to the party then Bruno or Carlo come too, but if Angelo
doesn’t come to the party, then Carlo and Davide come”
Exercise 2.17. -
Socrate says:
Exercise 2.18. -
Socrate says:
15
Propositional Logic
Exercise 2.19.
Socrate says:
Exercise 2.20.
Socrate says:
Exercise 2.21.
Formalize the following arguments and verify whether they are correct:
• “If Carlo won the competition, then either Mario came second or Sergio
came third. Sergio didn’t come third. Thus, if Mario didn’t come second,
then Carlo didn’t win the competition.”
16
2.3 Propositional Formalization
• “If Carlo won the competition, then either Mario came second or Sergio
came third. Mario didn’t come second. Thus, if Carlo won the competi-
tion, then Sergio didn’t come third.”
• “If Carlo won the competition, then Mario came second and Sergio came
third. Mario didn’t come second. Thus Carlo didn’t win the competition.”
• “If Carlo won the competition, then, if Mario came second then Sergio
came third. Mario didn’t come second. Thus, either Carlo won or Sergio
arrived third”
• “If you play and you study you’ll pass the exams, while if you play and
don’t study you won’t pass. Thus, if you play, either you study and you’ll
pass the exams, or you don’t study and you won’t pass.”
Exercise 2.22. -
Aladdin finds two trunks A and B in a cave. He knows that each of them either
contains a treasure or a fatal trap.
Aladdin knows that either both the inscriptions are true, or they are both false.
Can Aladdin choose a trunk being sure that he will find a treasure?
If this is the case, which trunk should he open?
17
Propositional Logic
+ Obviously ¬a =“Trunk a contains a trap” (and similarly for ¬b), since each
trunk either contains a treasure or a trap (exclusive or).
• Thus Aladdin can open trunk B, being sure that it contains a treasure.
Exercise 2.23.
Suppose we know that:
• “if Paolo is thin, then Carlo is not blonde or Roberta is not tall”
• “Carlo is blonde”
18
2.3 Propositional Formalization
Exercise 2.24. -
Three boxes are presented to you. One contains gold, the other two are empty.
Each box has imprinted on it a clue as to its contents; the clues are:
Only one message is true; the other two are false. Which box has the gold?
Formalize the puzzle in Propositional Logic and find the solution using a truth
table.
Solution. Let Bi with i ∈ {1, 2, 3} stand for “gold is in the i-th box”. We can
formalize the statements of the problem as follows:
B1 B2 B3 (2.1) (2.3)
T T T F T
T T F F T
T F T F T
T F F T T
F T T F F
F T F T F
F F T T F
F F F F F
19
Propositional Logic
The only assignment I that verifies both (2.1) and (2.3) is the one with I(B1 ) =
T and I(B2 ) = I(B3 ) = F , which implies that the gold is in the first box.
Exercise 2.25. -
Kyle, Neal, and Grant find themselves trapped in a dark and cold dungeon
(HOW they arrived there is another story). After a quick search the boys find
three doors, the first one red, the second one blue, and the third one green.
Behind one of the doors is a path to freedom. Behind the other two doors,
however, is an evil fire-breathing dragon. Opening a door to the dragon means
almost certain death.
On each door there is an inscription:
Given the fact that at LEAST ONE of the three statements on the three doors
is true and at LEAST ONE of them is false, which door would lead the boys to
safety?
Solution.
Language
20
2.3 Propositional Formalization
Axioms
1. “behind one of the door is a path to freedom, behind the other two doors
is an evil dragon”
r ∨ ¬b (2.5)
¬r ∨ b (2.6)
Solution
Exercise 2.26. -
21
Propositional Logic
• The guardian of the gold street: “This road will bring you straight to
the center. Moreover, if the stones take you to the center, then also the
marble takes you to the center.”
• The guardian of the marble street: “Neither the gold nor the stones will
take you to the center.”
• The guardian of the stone street: “Follow the gold and you’ll reach the
center, follow the marble and you will be lost.”
Given that you know that all the guardians are liars, can you choose a road
being sure that it will lead you to the center of the labyrinth? If this is the case,
which road you choose?
Provide a propositional language and a set of axioms that formalize the prob-
lem and show whether you can choose a road being sure it will lead to the
center.
Solution.
Language
Axioms
¬g ∨ (s ∧ ¬m)
22
2.3 Propositional Formalization
g∨s
¬g ∨ m
Solution
g m s 2.7 2.8 2.9 2.7 ∧ 2.8 ∧ 2.9
1 1 1 0 1 1 0
1 1 0 0 1 1 0
1 0 1 1 1 0 0
1 0 0 0 1 0 0
0 1 1 1 1 1 1
0 1 0 1 0 1 0
0 0 1 1 1 1 1
0 0 0 1 0 1 0
Exercise 2.27. -
Consider the finite set of binary strings
( )
(000000), (100000), (110000), (111000), (111100), (111110),
(111111), (011111), (001111), (000111), (000011), (000001)
Explain how it is possible to represent such a set in a propositional formula
and find the most compact representation.
Solution.
23
Propositional Logic
5 k 5 k 5
! !!
_ ^ ^ ^ ^
¬bi ∧ bi ∨ bi ∧ ¬bi (2.10)
k=0 i=0 i=k+1 i=0 i=k+1
Exercise 2.28. -
Provide a propositional language and a set of axioms that formalize the graph
coloring problem of a graph with at most n nodes, with connection degree
≤ m, and with less then k + 1 colors.
• connection degree of a graph: max among all the degree of its nodes
Solution.
Language
24
2.3 Propositional Formalization
Axioms
Wk
1. for each 1 ≤ i ≤ n, c=1 coloric
“each node has at least one color”
Exercise 2.29.
Anna and Barbara carpool to work. On any day, either Anna drives Barbara
or Barbara drives Anna. In the former case, Anna is the driver and Barbara
is the passenger; in the latter case Barbara is the driver and Anna is the pas-
senger.
Formalize the problem using the following propositions:
25
Propositional Logic
Exercise 2.30. -
Define a propositional language which allows to describe the state of a traffic
light on different instants.
With the language defined above provide a (set of) formulas which expresses
the following facts:
2. the traffic light switches from green to orange, from orange to red, and
from red to green;
Solution.
Language
Axioms
2. “the traffic light switches from green to orange, from orange to red, and
from red to green”
(gk−1 → (gk ∨ ok )) ∧ (ok−1 → (ok ∨ rk )) ∧ (rk−1 → (rk ∨ gk ))
3. “it can keep the same color over at most 3 successive states”
(gk−3 ∧ gk−2 ∧ gk−1 → ¬gk ) ∧ (rk−3 ∧ rk−2 ∧ rk−1 → ¬rk ) ∧ (ok−3 ∧ ok−2 ∧
ok−1 → ¬ok )
26
2.3 Propositional Formalization
Exercise 2.31. -
Sudoku is a placement puzzle. The aim of the puzzle is to enter a numeral from
1 through 9 in each cell of a grid, most frequently a 9 × 9 grid made up of 3 × 3
subgrids (called "regions"), starting with various numerals given in some cells
(the "givens"). Each row, column and region must contain only one instance of
each numeral. Its grid layout is like the one shown in the following schema
Solution.
in(n, r, c)
which means that the number n has been inserted in the cross between row r
and column c.
Axioms
9 9 9
!!
^ ^ _
in(n, r, c)
r=1 n=1 c=1
27
Propositional Logic
9 9 9
!!
^ ^ _
in(n, r, c)
c=1 n=1 r=1
9 3 3
!!
^ _ _
for any 0 ≤ k, h ≤ 2 in(n, 3 ∗ k + r, 3 ∗ h + c)
n=1 r=1 c=1
Exercise 2.32. -
Reduce to Negative Normal Form (NNF) the formula
¬(¬p ∨ q) ∨ (r → ¬s)
Solution.
28
2.4 Normal Form Reduction
Exercise 2.33. -
Reduce to NNF the formula
(¬p → q) → (q → ¬r)
Solution.
1. ¬(¬p → q) ∨ (q → ¬r)
Exercise 2.34. -
Reduce to Conjunctive Normal Form (CNF) the formula
¬(¬p ∨ q) ∨ (r → ¬s)
Solution.
Exercise 2.35. -
Reduce to CNF the formula
(¬p → q) → (q → ¬r)
29
Propositional Logic
Solution.
1. ¬(¬p → q) ∨ (q → ¬r)
Exercise 2.36.
Reduce to CNF the following formulas:
• p → (q ∧ r)
• (p ∨ q) → r
• ¬(¬p ∨ q) ∨ (r → ¬s)
• p ∨ (¬q ∧ (r → ¬p))
• ¬((((a → b)) → a) → a)
• ¬(a ∨ (a → b))
30
Mathematics as a science,
commenced when first
someone, probably a Greek,
proved propositions about
"any" things or about "some"
things, without specifications
of definite particular things.
Chapter 3
A LFRED N ORTH W HITEHEAD
Exercise 3.1. -
Non Logical symbols:
Say whether the following strings of symbols are well formed FOL formulas or
terms:
1. q(a)
2. p(y)
3. p(g(b))
4. ¬r(x, a)
5. q(x, p(a), b)
31
First Order Logic
Solution.
Exercise 3.2. -
Non Logical symbols:
Say whether the following strings of symbols are well formed FOL formulas or
terms:
3. ∀x.¬p(x);
4. ¬r(p(a), x);
5. ∃a.r(a, a);
7. ∃x.p(r(a, x));
8. ∀r(x, a);
Solution.
32
3.1 Basic Concepts
Exercise 3.3. -
Non Logical symbols:
Say whether the following strings of symbols are well formed FOL formulas or
terms:
1. a → p(b);
4. ¬y ∨ p(y);
5. ¬¬p(a);
6. ¬∀x.¬p(x);
Solution.
Exercise 3.4. -
Find free variables in the following formulas:
1. p(x) ∧ ¬r(y, a)
2. ∃x.r(x, y)
4. ∀x∃y.r(x, f (y))
33
First Order Logic
Solution.
1. x,y free
2. y free
3. x free
4. no free variables
5. x,y free
Exercise 3.5. -
Find free variables in the following formulas:
Solution.
1. no free variables
2. y free
3. x free
4. no free variables
5. u free
34
3.2 FOL Formalization
Exercise 3.6. -
What is the meaning of the followinf FOL formulas?
2. ∃x.bought(F rank, x)
5. ∀x∃y.bought(x, y)
6. ∃x∀y.bought(x, y)
Solution.
Exercise 3.7.
Which of the following formulas is a formalization of the sentence:
"There is a computer which is not used by any student"
35
First Order Logic
Exercise 3.8. -
Define an appropriate language and formalize the following sentences using
FOL formulas.
7. Bill is a student.
Solution.
1. ∀x.(Student(x) → Smart(x))
2. ∃x.Student(x)
3. ∃x.(Student(x) ∧ Smart(x))
36
3.2 FOL Formalization
7. Student(Bill)
Exercise 3.9. -
Define an appropriate language and formalize the following sentences using
FOL formulas.
Solution.
37
First Order Logic
Exercise 3.10.
Define an appropriate language and formalize the following sentences in FOL:
38
3.2 FOL Formalization
Exercise 3.11.
Define an appropriate language and formalize the following sentences in FOL:
• if Bob loves everyone that Mary loves, and Bob loves David, then Mary
doesn’t love David.
Exercise 3.12. -
Define an appropriate language and formalize the following sentences in FOL:
3. "Everything is on something."
Solution.
Language Constants: A, B, C, D, E, F ;
Predicates: On2 , Above2 , F ree1 , Red1 , Green1 .
39
First Order Logic
Axioms
3. "Everything is on something."
φ3 : ∀x∃y.On(x, y)
Exercise 3.13. -
Language Constants: A, B, C, D, E, F ;
Predicates: On2 , Above2 , F ree1 , Red1 , Green1 .
40
3.2 FOL Formalization
• I1 (F ree) = {hb1 i, hb5 i}, I1 (Green) = {hb4 i}, I1 (Red) = {hb1 i, hb5 i}
b1
b4 b5
b3 b2
table
• I2 (A) = hat, I2 (B) = Joe, I2 (C) = bike, I2 (D) = Jill, I2 (E) = case,
I2 (F ) = ground
• I2 (On) = {hhat, Joei, hJoe, bikei, hbike, groundi, hJill, casei, hcase, groundi}
• I2 (Above) = {hhat, Joei, hhat, bikei, hhat, groundi, hJoe, bikei, hJoe, groundi,
hbike, groundi, hJill, casei, hJill, groundi, hcase, groundi}
Solution.
• I2 |= φ1 ∧ φ2 ∧ ¬φ3 ∧ φ4 ∧ ¬φ5 ∧ φ6 ∧ φ7
41
First Order Logic
Exercise 3.14. -
Consider the following sentences:
Solution.
2. ∃x.¬l(x)
It’s sufficient to find an interpretation I for which the logical consequence does
not hold:
Exercise 3.15.
Let ∆ = {1, 3, 5, 15} and I be an interpretation on ∆ interpreting the predicate
symbols E 1 as ’being even’, M 2 as ’being a multiple of’ and L2 as ’being less
then’, and s.t. I(a) = 1, I(b) = 3, I(c) = 5, I(d) = 15.
Determine whether I satisfies the following formulas:
42
3.2 FOL Formalization
1. ∃y.E(y)
2. ∀x.¬E(x)
3. ∀x.M (x, a)
4. ∀x.M (x, b)
5. ∃x.M (x, d)
6. ∃x.L(x, a)
8. ∀x∃y.L(x, y)
9. ∀x∃y.M (x, y)
Exercise 3.16. -
Provide a FOL language and a set of axioms that formalize the graph color-
ing problem of a graph with at most n nodes, with connection degree ≤ m,
and with less then k + 1 colors.
• connection degree of a graph: max among all the degree of its nodes
Solution.
43
First Order Logic
Language
• A unary function color, where color(x) is the color associated to the node
x
Axioms
Exercise 3.17. -
Let {c1 , .., ck } be a non empty and finite set of colors. A partially colored di-
rected graph is a structure hN, R, Ci where
• R is a binary relation on N
• C associates colors to nodes (not all the nodes are necessarily colored,.
and each node has at most one color)
Provide a first order language and a set of axioms that formalize partially
colored graphs. Show that every model of this theory correspond to a partially
colored graph, and vice-versa. For each of the following properties, write a
formula which is true in all and only the graphs that satisfies the property:
44
3.2 FOL Formalization
3. starting from a red node one can reach in at most 4 steps a green node
5. the graph is composed of |C| disjoint non empty subgraphs, one for each
color
Solution.
Language
• a binary predicate color, where color(n, x) means that node n has color x
Axioms
3. "starting from a red node one can reach in at most 4 steps a green node"
∀n(color(n, red) →
(∃n1 .(edge(n, n1 ) ∧ color(n1 , green)) ∨
∃n1 , n2 .(edge(n, n1 ) ∧ edge(n1 , n2 ) ∧ color(n2 , green)) ∨
∃n1 , n2 , n3 .(edge(n, n1 ) ∧ edge(n1 , n2 ) ∧ edge(n2 , n3 ) ∧ color(n3 , green)) ∨
∃n1 , n2 , n3 , n4 .(edge(n, n1 ) ∧ edge(n1 , n2 ) ∧ edge(n2 , n3 ) ∧ edge(n3 , n4 ) ∧ color(n4 , green))
))
45
First Order Logic
∀x∃n.color(n, x)
5. "the graph is composed of |C| disjoint non empty subgraphs, one for each
color"
∀x∃n.color(n, x) ∧
∀n∃x.color(n, x) ∧
∀n∀x.(color(n, x) → ¬∃y.(y 6= x ∧ color(n, y))) ∧
∀n∀m∀x.(n 6= m ∧ color(n, x) ∧ color(m, x) →
|N | i−1
_ ^
(edge(n, m) (∃n1 , .., ni .(edge(n, n1 ) edge(xj , xj + 1) ∧ edge(ni , m)))))
i=1 j=1
Exercise 3.18. -
Minesweeper is a single-player computer game invented by Robert Donner in
1989. The object of the game is to clear a minefield without detonating a mine.
The game screen consists of a rectangular field of squares. Each square can
be cleared, or uncovered, by clicking on it. If a square that contains a mine
is clicked, the game is over. If the square does not contain a mine, one of
two things can happen: (1) A number between 1 and 8 appears indicating the
amount of adjacent (including diagonally-adjacent) squares containing mines,
or (2) no number appears; in which case there are no mines in the adjacent
cells. An example of game situation is provided in the following figure:
Provide a first order language that allows to formalize the knowledge of a
player in a game state. In such a language you should be able to formalize the
following knowledge:
2. if a cell contains the number 1, then there is exactly one mine in the
adjacent cells.
46
3.2 FOL Formalization
Suggestion: define the predicate Adj(x, y) to formalize the fact that two cells x
and y are adjacent
Solution.
Language
1. A unary predicate mine, where mine(x) means that the cell xcontains a
mine
2. A binary predicate adj, where adj(x, y) means that the cell x is adjacent
to the cell y
Axioms
47
First Order Logic
2. If a cell contains the number 1, then there is exactly one mine in the
adjacent cells.
a. contains((2, 2), 1)
we can deduce:
f. mine((1, 1)) ∨ mine((1, 2)) ∨ mine((1, 3)) ∨ mine((2, 1)) ∨ mine((2, 2)) ∨
mine((2, 3)) ∨ mine((3, 1)) ∨ mine((3, 2)) ∨ mine((3, 3)) from e.
Exercise 3.19. -
Formalize in first order logic the train connections in Italy. Provide a language
that allows to express the fact that a town is directly connected (no intermedi-
ate train stops) with another town, by a type of train (e.g., intercity, regional,
interregional). Formalize the following facts by means of axioms:
48
3.2 FOL Formalization
Constants RM, FI, BO, VR, TN, . . . are identifiers of the towns of Roma, Firenze,
Bologna, Verona, Trento, . . . . and InterCity, Regional, . . . are the identifiers of
the type of trains
49
First Order Logic
Specific axioms The axioms that formalizes the specific situation described
in the exercise are the following:
Exercise 3.20. -
The game of Draughts is played on a standard Chess board 64 black and white
chequered squares. Each player has 12 pieces (men) normally in the form of
fat round counters. One player has black men and the other has white men.
When starting, each player’s men are placed on the 12 black squares nearest to
that player (see Figure 3.20). The white squares are not used at all in the game
50
3.2 FOL Formalization
- the men only move diagonally and so stay on the black squares throughout.
Black always plays first.
Players take turns to move a man of their own colour. There are fundamentally
4 types of move: the ordinary move of a man, the ordinary move of a king, the
capturing move of a man and the capturing move of a king.
An ordinary move of a man is its transfer diagonally forward left or right
from one square to an immediately neighbouring vacant square. When a man
reaches the farthest row forward (the king-row or crownhead) it becomes a
king: another piece of the same shade is placed on top of the piece in order to
distinguish it from an ordinary man.
An ordinary move of a king is from one square diagonally forward or back-
ward,left or right, to an immediately neighbouring vacant square.
Whenever a piece (man or king) has an opponent’s piece adjacent to it and the
square immediately beyond the opponent’s piece is vacant, the opponent’s piece
can be captured. If the player has the opportunity to capture one or more of
the opponent’s pieces, then the player must do so. A piece is taken by simply
hopping over it into the vacant square beyond and removing it from the board.
Unlike an ordinary move, a capturing move can consist of several such hops
- if a piece takes an opponent’s piece and the new position allows it to take
another piece, then it must do so straight away.
Kings are allowed to move and capture diagonally forwards and backwards
and are consequently more powerful and valuable than ordinary men. How-
ever, ordinary men can capture Kings.
The game is won by the player who first manages to take all his opponent’s
pieces or renders them unable to move.
For each of the following conditions on Draughts game write the correspond-
51
First Order Logic
3. White squares are always empty (always: in each instant of the game).
4. In each instant of the game, black squares are either empty or contain a
piece.
5. At the beginning of the game (instant zero) there are 12 white and 12
black men on the board.
6. Whenever a black man captures a white man, in the next instant of the
game there is a white man less (and vice-versa).
Solution.
Language Predicates:
52
3.2 FOL Formalization
Functions:
Axioms
4. "In each instant of the game, black squares are either empty or contain
a piece."
5. "At the beginning of the game (instant zero) there are 12 white and 12
black men on the board."
6. "Whenever a black man captures a white man, in the next instant of the
game there is a white man less (and vice-versa)."
53
First Order Logic
54
"The rule is jam tomorrow and
jam yesterday but never jam
to-day" the Queen said.
"It must come sometimes to
"jam to-day,""Alice objected.
"No it can’t," said the Queen.
"It’s jam every other day;
to-day isn’t any other day, you
know."
"I don’t understand you," said
Chapter 4 Alice. "It’s dreadfully
confusing."
Exercise 4.1. -
Say whether the following strings of symbols are well formed modal formulas
on P = {p, q}
1. → p
2. p → p
3. p → p
4. ♦q ∧ ⊥♦
5. p → ♦p
6. ♦>
7. p → ♦p
Solution.
55
Modal Logic
Exercise 4.2. -
Say whether the following strings of symbols are well formed modal formulas
on P = {p, q}
1. ♦q
2. ♦q
3. ♦p → ♦p
4. (> ∧ p) → q
Solution.
Exercise 4.3. -
Let the kripke frame F = (W, R) given by
F = ({1, 2, 3, 4}, {(1, 2), (1, 3), (2, 4), (3, 4)})
Solution.
1 4
2
56
4.1 Basic Concepts
Exercise 4.4. -
Let the kripke frame F = (W, R) given by
F = ({1, 2, 3, 4}, {(1, 2), (1, 3), (2, 4), (3, 4)})
Solution.
1 4
2
Exercise 4.5.
Suppose M1 = ((W, R), I) is the Kripke model depicted by:
p p
M1
3 4
1 2
p,q
Exercise 4.6. -
Consider the following model M = ((W, R), I) for the basic modal language of
P = {p}:
57
Modal Logic
W = {1, 2, 3}, R = {(1, 2), (2, 2), (2, 3)}, I(p) = {1, 2}.
Draw it as a labelled graph and then verify which of the following holds:
1. M, 1 |= p
2. M, 2 |= ♦p
3. M, 3 |= p
4. M, 1 |= p
5. M, 1 |= ♦p
6. M, 1 |= ♦¬p
7. M, 2 |= ♦¬p
8. M, 2 |= (p → p) → ♦(p → p)
9. M, 3 |= (p → p) → ♦(p → p)
Solution.
1 2 3
p p
Exercise 4.7. -
Determine whether the following formulas are valid in the lowermost worlds
of the two Kripke models below:
1. p
2. q
3. p ∧ q
4. ⊥
58
4.1 Basic Concepts
p p
4 5 4 5
p 2 3 q p 2 3 q
1 1
M1 M2
Solution.
1. M1 , 1 2 p and M2 , 1 2 p
2. M1 , 1 2 q and M2 , 1 |= q
3. M1 , 1 2 p ∧ q and M2 , 1 2 p ∧ q
Exercise 4.8.
Determine in which worlds, of the two Kripke models below, are valid the fol-
lowing formulas:
1. p
2. q
3. p ∧ q
4. ⊥
59
Modal Logic
p p
4 5 4 5
p 2 3 q p 2 3 q
1 1
M1 M2
Exercise 4.9.
Consider the following model M2 = ((W2 , R2 ), I2 ) for the basic modal lan-
guage of P = {p}:
W2 = {1, 2}, R2 = {(1, 2), (2, 1)}, I(p) = {2}.
Draw it as a labelled graph and then verify which of the following holds:
1. M2 , 1 |= p ∧ ¬p
2. M2 , 1 |= p → p
3. M2 , 2 |= p ∧ ♦¬p
4. M2 , 1 |= p ∨ ♦¬p
5. M2 , 1 |= p
6. M2 , 1 |= p
7. M2 , 1 |= ♦p
8. M2 , 2 |= ♦p
9. M2 , 2 |= ♦¬p
10. M2 , 1 |= ♦¬p → ¬p
11. M2 , 2 |= ♦¬p → ¬p
60
4.2 Satisfiability and Validity
Exercise 4.10.
Consider the following model M3 = ((W3 , R3 ), I3 ) for the basic modal lan-
guage of P = {p, q}:
W3 = {1, 2, 3, 4}, R2 = {(1, 2), (2, 3), (3, 1), (3, 4), (4, 2)}, I(p) = {1, 3}, I(q) =
{1, 2}.
Draw it as a labelled graph and then verify which of the following holds:
1. M3 , 1 |= q
2. M3 , 1 |= ¬(p → q)
4. M3 , 1 |= ♦p
5. M3 , 1 |= ♦p ∧ ♦q
6. M3 , 1 |= ♦p ∨ ♦q
7. M3 , 3 |= ♦(p ∨ ¬q)
8. M3 , 3 |= ♦p ∧ ♦¬q
Exercise 4.11. -
Is ♦p ∧ ♦¬p satisfiable?
61
Modal Logic
Solution.
1 2
p p
Exercise 4.12. -
Is ♦p ∧ ¬p satisfiable?
Solution.
M, w |= ♦p ∧ ¬p
iff M, w |= ♦p and M, w |= ¬p
iff for some world v ∈ W , (w, v) ∈ R and M, v |= p, and M, w |= ¬p
iff for some world v ∈ W , (w, v) ∈ R and M, v |= p, and for every world
u ∈ W , (w, u) ∈ R implies M, u |= ¬p
iff for some world v ∈ W , (w, v) ∈ R and v ∈ I(p), and for every world
u ∈ W , (w, u) ∈ R implies u ∈
/ I(p)
iff for some world v ∈ W , (w, v) ∈ R and v ∈ I(p), and (w, v) ∈ R implies
v∈
/ I(p)
iff for some world v ∈ W , (w, v) ∈ R and v ∈ I(p) and v ∈
/ I(p)
Exercise 4.13. -
Consider the simple Kripke model below:
62
4.2 Satisfiability and Validity
p q q
1 2
p
4 3
1. ♦p ∨ ♦♦p
2. p → ¬p
4. ♦q
Solution.
1. M, 2 2 ♦p ∨ ♦♦p,
thus M 2 ♦p ∨ ♦♦p
2. M, 1 |= p → ¬p,
M, 2 |= p → ¬p,
M, 3 |= p → ¬p, and M, 4 |= p → ¬p
thus M |= p → ¬p
4. M, 2 2 ♦q,
thus M 2 ♦q
Exercise 4.14. -
Prove that ♦p ↔ ¬¬p is valid in any Kripke model.
63
Modal Logic
arbitrary world in M.
M, w |= ¬¬p
iff not M, w |= ¬p
iff not for every v, w, v ∈ R implies M, w |= ¬p
iff for some v, w, v ∈ R and not M, w |= ¬p
iff for some v, w, v ∈ R and M, w |= ¬¬p
iff for some v, w, v ∈ R and M, w |= p
iff M, w |= ♦p
Exercise 4.15.
Prove that the following facts hold:
1. |= p ∧ (p → q) → q (modus ponens)
2. if |= p then |= p (necessitation)
Exercise 4.16. -
Prove that p → ♦p (D) is not valid in the class of all frames.
Solution. We need to find a model and a world in the model which falsify the
formula.
p p
M1
3 4
1 2
p,q
M1 , 4 2 p → ♦p
64
4.2 Satisfiability and Validity
Exercise 4.17.
Prove that the following formulae are not valid in the class of all frames.
1. p → p
2. p → ♦p
3. p → p
4. ♦p → ♦p
Exercise 4.18. -
For each of the following formulas, show that it is valid (i.e., true in all models)
or find a counterexample
1. A ∧ ♦B → ♦(A ∧ B)
2. A → ♦A
1. A ∧ ♦B → ♦(A ∧ B)
M, w |= A ∧ ♦B ⇔ M, w |= A and M, w |= ♦B
⇔ for all w0 with wRw0 , M, w0 |= A and
there is a w0 with wRw0 , and M, w0 |= B
⇒ there is a w0 with wRw0 , and M, w0 |= B and M, w0 |= A
⇔ there is a w0 with wRw0 , and M, w0 |= A ∧ B
⇔ M, w |= ♦A ∧ B
65
Modal Logic
2. A → ♦A
Counterexample:
1 2
A
M, 1 2 A → ♦A
2 4
A B
1
3 5
A B
Exercise 4.19. -
For each of the following formulas, either prove that it is valid or find a Kripke
model hW, R, Ii and a w ∈ W that does not satisfy it.
1. ♦A → A
3. A → A
Solution.
1. ♦A → A
Counterexample:
66
4.2 Satisfiability and Validity
1
A
3 4
3. A → A
Counterexample:
1 2 3
A A
Exercise 4.20. -
For each of the following formulas either prove that it is valid or find a counter-
example. Note that if your attempts to produce a falsifying model always end
in incoherent pictures, it may be because the formula is valid.
1. ♦A → ♦♦A
3. ¬♦A → ♦♦¬A
Solution.
1. Countermodel:
67
Modal Logic
M, w 2 ♦A → ♦♦A.
3. Countermodel:
M, w 2 ¬♦A → ♦♦¬A.
Exercise 4.21. -
For each of the following formulas, either prove that it is valid or find a Kripke
model hW, R, Ii and a w ∈ W that does not satisfy it.
1. ♦A → A
68
4.2 Satisfiability and Validity
Solution.
1. ♦A → A
Counterexample:
M
A A
w1 w2
M, w1 2 ♦A → A.
two cases:
• case 1: M, w 2 ♦A → B
• case 2: M, w |= ♦A → B
then we have two cases:
– case 2.1: M, w 2 ♦A
M, w 2 ♦A =⇒ M, w 2 A
=⇒ M, w |= A → B
=⇒ M, w |= (♦A → B) → (A → B)
– case 2.2: M, w |= ♦A
M, w |= ♦A =⇒ since M, w |= ♦A → B, M, w |= B
=⇒ by def of →, M, w |= A → B
=⇒ M, w |= (♦A → B) → (A → B)
69
Modal Logic
Exercise 4.22. -
For each of the following formulas, either prove that it is valid or find a Kripke
model hW, R, Ii and a w ∈ W that does not satisfy it.
1. A → A
3. ♦A → ♦A
Solution.
1. Countermodel:
M
A A
w1 w2
M, w1 2 A → A.
2. We prove that for all models M and for all worlds w, M, w |= (¬♦A ∧
♦B) → ♦(¬A ∧ B).
3. Countermodel:
M A
w3
A
w1 w2
A
w4
70
4.2 Satisfiability and Validity
M, w1 2 ♦A → ♦A
4. A → A
Counterexample:
1 2 3
A A
Exercise 4.23. -
Prove that the modal logic formula
φ → φ
M = ((W, R), I). We need to show that for every world v ∈ W and for every
formula φ,
M, v |= φ → φ
1. M, v 2 φ
Then by def. of →, M, v |= φ → φ
2. M, v |= φ
Then by def. of
for every u ∈ W , if (v, u) ∈ R then M, u |= φ.
R is reflexive, hence (v, v) ∈ R.
Therefore M, v |= φ.
So, M, v |= φ → φ.
71
Modal Logic
Exercise 4.24. -
Prove that if, for every formula φ, the modal logic formula
φ → φ
if M, w |= φ then M, w |= φ.
CONTRADICTION!
Exercise 4.25. -
Show that in the frame F = (W, R) if R is an equivalence relation then the
schema φ → ♦φ is valid
Solution. We need to prove that for any model M and any world w, M, w |=
φ → ♦φ.
Consider two cases:
72
4.2 Satisfiability and Validity
• case 1: M, w 2 φ
M, w 2 φ =⇒ by def of →, M, w |= φ → ♦φ
• case 2: M, w |= φ
since R is an equivalence relation, it is simmetric, then we have that
for all w0 , wRw0 → w0 Rw
Exercise 4.26.
Show that if a frame hW, Ri satisfy the schema φ → φ then R is transitive.
Exercise 4.27.
Let F = (W, R) be a frame.
Prove that the following statements are equivalent:
1 R is transitive
73
Modal Logic
Exercise 4.28. -
Provide a modal language and a set of axioms that formalize the graph col-
oring problem of a graph with at most n nodes, with connection degree ≤ m,
and with less then k + 1 colors.
• connection degree of a graph: max among all the degree of its nodes
Solution.
Axioms
3. "Each node does not have the same color as an accessible nodes:
k
^
(Ci → ¬Ci )
i=1
74
4.3 Modal Logic Formalization
Exercise 4.29. -
Show how it is possible to represent the railways connections in a country by
means of a Kripke frame. First, select the schema you have to impose to capture
the following fact: “if there is a direct train connection to go from a to b, then
there is also a train connection in the opposite direction
“if there is a direct train connection to go from a to b, then there is also a train
connection in the opposite direction”
φ → ♦φ
75
Modal Logic
RM → ¬F I
RM → ¬♦TN
RM → ♦♦♦TN
RivaDelGarda → ⊥
76