Beruflich Dokumente
Kultur Dokumente
Andrzej Szalas
Contents
1 Introduction to logics 3
2 Tableaux and SAT 26
3 Resolution 43
4 First-order logic 67
5 Tableaux: FOL 91
6 Resolution: FOL 119
7 Deductive databases 150
8 Sequent (Gentzen) calculus 170
9 Sample exams 187
1
Some remarks
2
Lecture 1
Introduction to logics
3
LECTURE 1. INTRODUCTION TO LOGICS 4
1.1 Exercise
Let high temp, highp ressure, signal on be propositional
variables. Let M1 be a model, such that:
1.1 Solution
1
In M1 :
1a
In M1 :
1b
In M1 :
2
In M2 :
2a
In M2 :
2b
In M2 :
1.2 Exercise
Using the truth table method prove that:
1
There is only one variable in (1.1). A suitable truth table
is:
p ¬p p → ¬p (p → ¬p) → ¬p
T F F T
F T T T
2
There are two variables in (1.2). A suitable truth table
is:
p q p ∨ q ¬p ¬p ∨ q (p ∨ q) ∧ (¬p ∨ q) (1.2)
T T T F T T T
T F T F F F T
F T T T T T T
F F F T T F T
LECTURE 1. INTRODUCTION TO LOGICS 9
3
There are three variables in (1.3). A suitable truth table
is:
(p → q)
(p ∨ r)
p q r p→q r→q ∧ p∨r (1.3)
→q
(r → q)
T T T T T T T T T
T T F T T T T T T
T F T F F F T F T
T F F F T F T F T
F T T T T T T T T
F T F T T T F T T
F F T T F F T F T
F F F T T T F T T
LECTURE 1. INTRODUCTION TO LOGICS 10
4
There are three variables in (1.4). A suitable truth table
is:
p→ (p → q)
p q r q∧r (q ∧ r) p → q p → r ∧ (1.4)
(p → r)
T T T T T T T T T
T T F F F T F F T
T F T F F F T F T
T F F F F F F F T
F T T T T T T T T
F T F F T T T T T
F F T F T T T T T
F F F F T T T T T
LECTURE 1. INTRODUCTION TO LOGICS 11
1.3 Exercise
Translate the following sentence into propositional logic:1
1.3 Solution
Simplifying a bit, we have the following atomic sentences:2
• “I looked around”;
asked ∧ told
∧
told → (looked ∧ ¬chair).
2
That is, sentences not involving connectives.
LECTURE 1. INTRODUCTION TO LOGICS 13
1.4 Solution
1
We have atomic sentences like “move small objects”,
“move medium objects”, “move large objects”, . . .
We denote these sentences by small, medium, large,
f irst, second, third, green, red, blue.
It is important to see that sentences as
“large objects are blue”
mean that whenever we move a large object then it is
blue, so should be translated into implication like:
large → blue.
2
The assumption that each object can be moved to at
most one container is translated into:
“John works.”
“John does not read books and he does not
watch TV and he cooks.”
1.5 Solution
1
First we translate claims of L. We have atomic sentences:
• “John works”;
• “John reads books”;
• “John watches TV”;
• “John cooks”.
2
Observe that, by (1.22), we know that John does not
work. Therefore, by (1.24), he does not watch tv either.
Now (1.23) and (1.25) reduce to:
¬cooks (1.28)
cooks, (1.29)
1.6 Exercise
Translate the following sentence into propositional logic:3
3
After Sherlock Holmes.
LECTURE 1. INTRODUCTION TO LOGICS 20
1.6 Solution
We first have to find out what, in fact, Holmes said. The
meaning is more or less the following:
burden → ¬sentiment
∧
burden → ¬caprice.
LECTURE 1. INTRODUCTION TO LOGICS 22
1.7 Exercise
Verify whether the following sentence is valid:
1.7 Solution
The above sentence looks a bit strange but it actually is
a tautology. To see it, lets translate it into propositional
logic. We have two atomic sentences:
• “I’ll go to a cinema”;
1.8 Exercise
Verify the following reasoning:
1.8 Solution
To verify the reasoning we first translate it into logic. We
have two atomic sentences:
26
LECTURE 2. TABLEAUX AND SAT 27
2.1 Exercise
Using tableaux transform the following formula into the
disjunctive normal form:
(p ∨ q) → (p ∧ q). (2.1)
(a1 ∧ a2 ∧ . . . ∧ ak ) ∨ . . . ∨ (c1 ∧ c2 ∧ . . . ∧ cm ),
2.1 Solution
We construct a tableau for (2.1):
(p ∨ q) → (p ∧ q)
. & (→)
¬(p ∨ q) p∧q
(¬∨) ↓ ↓ (∧)
¬p, ¬q p, q
Recall that a tableau represents disjunction of conjunc-
tions of literals in leaves. Therefore, the above tableau
represents:
2.2 Solution
We construct a tableau for (2.3):
(p ∨ q) ∧ (¬p ∨ ¬q)
↓ (∧)
p ∨ q, ¬p ∨ ¬q
. & (∨)
p, ¬p ∨ ¬q q, ¬p ∨ ¬q
. & (∨) . & (∨)
p, ¬p p, ¬q q, ¬p q, ¬q
| {z } | {z }
closed closed
The formula is satisfiable since the tableau has open
leaves. Each open leaf provides a satisfying valuation:
• p, ¬q: p = T and q = F;
• q, ¬p: p = F and q = T.
Note that checking satisfiability requires only one sat-
isfying valuation, so one can interrupt constructing the
tableau after obtaining the first open leaf.
LECTURE 2. TABLEAUX AND SAT 31
1. (p ∨ q) → p. (2.4)
2. (p ∨ q) → (p ∧ r). (2.5)
3. (p → q) ∨ (q → p). (2.6)
4. (p ∨ q) → (p ∨ q ∨ ¬r) ∧ (r ∨ p ∨ q) (2.7)
LECTURE 2. TABLEAUX AND SAT 32
2.3 Solution
1
We construct a tableau for negated (2.4):
¬[(p ∨ q) → p]
↓ (¬ →)
p ∨ q, ¬p
. & (∨)
p, ¬p q, ¬p
| {z }
closed
The above tableau is not closed. The leaf containing q, ¬p
provides a counterexample for (2.4): q = T and p = F.
Indeed, in such a case:
(p ∨ q) → p ↔
(F ∨ T) → F ↔
| →
T {z F} .
F
LECTURE 2. TABLEAUX AND SAT 33
2
We construct a tableau for negated (2.5):
¬[(p ∨ q) → (p ∧ r)]
↓ (¬ →)
p ∨ q, ¬(p ∧ r)
. & (¬∧)
p ∨ q, ¬p p ∨ q, ¬r
. & (∨) . & (∨)
p, ¬p q, ¬p p, ¬r q, ¬r
| {z }
closed
The above tableau is not closed. All open leaves provide
counterexamples for (2.5).
3
We construct a tableau for the negation of (2.6):
¬ (p → q) ∨ (q → p)
↓ (¬∨)
¬(p → q), ¬(q → p)
↓ (¬ →)
p, ¬q, ¬(q → p)
↓ (¬ →)
p, ¬q, q, ¬p
| {z }
closed
The tableau is closed, so formula (2.6) is a tautology.
4
We construct a tableau for the negation (2.7):
¬ (p ∨ q) → (p ∨ q ∨ ¬r) ∧ (r ∨ p ∨ q)
↓ (¬ →)
p ∨ q, ¬ (p ∨ q ∨ ¬r) ∧ (r ∨ p ∨ q)
. & (¬∧)
p ∨ q, ¬(p ∨ q ∨ ¬r) p ∨ q, ¬(r ∨ p ∨ q)
↓ (¬∨) ↓ (¬∨)
p ∨ q, ¬p, ¬q, ¬¬r p ∨ q, ¬r, ¬p, ¬q
. & (∨) . & (∨)
p, ¬p, ¬q, ¬¬r q, ¬p, ¬q, ¬¬r p, ¬r, ¬p, ¬q q, ¬r, ¬p, ¬q
| {z } | {z } | {z } | {z }
closed closed closed closed
The tableau is closed, so (2.7) is a tautology.
LECTURE 2. TABLEAUX AND SAT 35
2.4 Exercise
Consider the following relationships among concepts:
2.4 Solution
We have the following concepts:1 person (p), child (c),
adult (a) and human (h).
Lets first translate relationships among concepts into propo-
sitional formulas:
c→p (2.8)
a→p (2.9)
c→h (2.10)
a → h. (2.11)
1
In brackets we give their abbreviations used later on.
LECTURE 2. TABLEAUX AND SAT 37
1
We have to verify whether p → h follows from (2.8)–
(2.11), so construct a tableau:
¬ [(c → p) ∧ (a → p) ∧ (c → h) ∧ (a → h)] → (p → h)
↓ (¬ →)
(c → p) ∧ (a → p) ∧ (c → h) ∧ (a → h), ¬(p → h)
↓ (∧)
c → p, (a → p) ∧ (c → h) ∧ (a → h), ¬(p → h)
↓ (∧)
c → p, a → p, (c → h) ∧ (a → h), ¬(p → h)
↓ (∧)
c → p, a → p, c → h, (a → h), ¬(p → h)
↓ (¬ →)
c → p, a → p, c → h, a → h, p, ¬h
. (→) &
¬c, a → p, c → h, a → h, p, ¬h ...
↓ (→) &
¬c, a → p, c → h, a → h, p, ¬h ...
↓ (→) &
¬c, ¬a, c → h, a → h, p, ¬h ...
↓ (→) &
¬c, ¬a, ¬c, a → h, p, ¬h ...
↓ (→) &
¬c, ¬a, ¬c, ¬a, p, ¬h ...
2
We have to verify whether h → p follows from (2.8)–
(2.11), so have to construct a tableau for:
¬ [(c → p)∧(a → p)∧(c → h)∧(a → h)] → (p → h) .
2.5 Exercise
Consider the following relationships among concepts:
2.5 Solution
We have concepts good scientific paper (g), paper con-
taining outstanding results (o), paper published in a very
good scientific journal (j) and publication (p).
Translating our specification into propositional formulas
results in:
g ↔ (o ∨ j) (2.12)
o→p (2.13)
j → p. (2.14)
1
The first question is expressed by g → p. We then have to
verify whether (2.12)–(2.14) imply g → p. We construct
a tableau showing that this indeed is the case:
h i
¬ g ↔ (o ∨ j) ∧ (o → p) ∧ (j → p) → (g → p)
↓ (¬ →)
g ↔ (o ∨ j) ∧ (o → p) ∧ (j → p) ∧ ¬(g → p)
↓ (∧)
g ↔ (o ∨ j), o → p ∧ (j → p) ∧ ¬(g → p)
↓ (∧)
g ↔ (o ∨ j), o → p, (j → p) ∧ ¬(g → p)
↓ (∧)
g ↔ (o ∨ j), o → p, j → p, ¬(g → p)
↓ (∧)
g ↔ (o ∨ j), o → p, j → p, g, ¬p
. & (→)
g ↔ (o ∨ j), ¬o, j → p, g, ¬p g ↔ (o ∨ j), p, j → p, g, ¬p
| {z }
↓ (→) & closed
g ↔ (o ∨ j), ¬o, ¬j, g, ¬p g ↔ (o ∨ j), ¬o, p, g, ¬p
| {z }
↓ (↔) closed
¬g ∨ o ∨ j, g ∨ ¬(o ∨ j), ¬o, ¬j, g, ¬p
↓ (∨) &
¬g, g∨¬(o∨j),¬o,¬j, g,¬p o∨j, g∨¬(o∨j), ¬o, ¬j, g, ¬p
| {z }
closed . (∨) ↓
o, g∨¬(o∨j), ¬o, ¬j, g, ¬p j, g∨¬(o∨j), ¬o, ¬j, g, ¬p
| {z } | {z }
closed closed
LECTURE 2. TABLEAUX AND SAT 42
2
The second question is expressed by p → g. We have to
verify whether (2.12)–(2.14) imply p → g. We construct
a tableau showing that this is not the case:
h i
¬ g ↔ (o ∨ j) ∧ (o → p) ∧ (j → p) → (p → g)
↓ (¬ →)
g ↔ (o ∨ j) ∧ (o → p) ∧ (j → p) ∧ ¬(p → g)
↓ (∧)
g ↔ (o ∨ j), o → p ∧ (j → p) ∧ ¬(p → g)
↓ (∧)
g ↔ (o ∨ j), o → p, (j → p) ∧ ¬(p → g)
↓ (∧)
g ↔ (o ∨ j), o → p, j → p, ¬(p → g)
↓ (∧)
g ↔ (o ∨ j), o → p, j → p, p, ¬g
. & (→)
g ↔ (o ∨ j), ¬o, j → p, p, ¬g ...
↓ (→) &
g ↔ (o ∨ j), ¬o, ¬j, p, ¬g ...
↓ (↔)
¬g ∨ o ∨ j, g ∨ ¬(o ∨ j), ¬o, ¬j, p, ¬g
. (∨) &
¬g, g∨¬(o∨j),¬o,¬j, p,¬g ...
. (∨) &
... ¬g, ¬(o ∨ j), ¬o, ¬j, p, ¬g
↓ (¬∨)
¬g, ¬o, ¬j, ¬o, ¬j, p, ¬g
The above open leaf gives a valuation satisfying (2.12)–
(2.14) and falsifying p → g: g = F, o = F, j = F, p = T.
Lecture 3
Resolution
43
LECTURE 3. RESOLUTION 44
3.1 Exercise
Transform into an equivalent set of clauses:
¬ (¬p ↔ r) → [(q ∧ r) ∨ p] . (3.1)
LECTURE 3. RESOLUTION 45
3.1 Solution
We first transform (3.1) into the conjunctive normal form:
¬ (¬p ↔ r) → [(q ∧ r) ∨ p] ↔
(¬p ↔ r) ∧ ¬[(q ∧ r) ∨ p] ↔
(¬¬p ∨ r) ∧ (¬p ∨ ¬r) ∧ ¬[(q ∧ r) ∨ p] ↔
(p ∨ r) ∧ (¬p ∨ ¬r) ∧ ¬[(q ∧ r) ∨ p] ↔
(p ∨ r) ∧ (¬p ∨ ¬r) ∧ ¬(q ∧ r) ∧ ¬p ↔
(p ∨ r) ∧ (¬p ∨ ¬r) ∧ (¬q ∨ ¬r) ∧ ¬p.
p∨r
¬p ∨ ¬r
¬q ∨ ¬r
¬p.
LECTURE 3. RESOLUTION 46
3.2 Solution
First, we negate (3.2) and transform it into a conjunctive
normal form:
h i
¬ (p ∨ q) → (p ∨ q ∨ ¬r) ∧ (r ∨ p ∨ q) ↔
(p ∨ q) ∧ ¬ (p ∨ q ∨ ¬r) ∧ (r ∨ p ∨ q) ↔
(p ∨ q) ∧ [¬(p ∨ q ∨ ¬r) ∨ ¬(r ∨ p ∨ q)] ↔
(p ∨ q) ∧ [(¬p ∧ ¬q ∧ ¬¬r) ∨ (¬r ∧ ¬p ∧ ¬q)] ↔
(p ∨ q) ∧ [(¬p ∧ ¬q ∧ r) ∨ (¬r ∧ ¬p ∧ ¬q)] ↔
(p ∨ q) ∧ [((¬p ∧ ¬q ∧ r) ∨ ¬r)∧
((¬p ∧ ¬q ∧ r) ∨ (¬p ∧ ¬q))] ↔
(p ∨ q) ∧ [((¬p ∧ ¬q ∧ r) ∨ ¬r)∧
((¬p ∧ ¬q ∧ r) ∨ ¬p)∧
((¬p ∧ ¬q ∧ r) ∨ ¬q)] ↔
(p ∨ q) ∧ (¬p ∨ ¬r) ∧ (¬q ∨ ¬r) ∧ (r ∨ ¬r)∧
(¬p ∨ ¬p) ∧ (¬q ∨ ¬p) ∧ (r ∨ ¬p)∧
(¬p ∨ ¬q) ∧ (¬q ∨ ¬q) ∧ (r ∨ ¬q).
LECTURE 3. RESOLUTION 48
1. p∨q
2. ¬p ∨ ¬r
3. ¬q ∨ ¬r
4. r ∨ ¬r
5. ¬p ∨ ¬p
6. ¬q ∨ ¬p
7. r ∨ ¬p
8. ¬p ∨ ¬q
9. ¬q ∨ ¬q
10. r ∨ ¬q.
A proof by resolution:
11. ¬p – (fctr): 5
12. ¬q – (fctr): 9
13. q – (res): 1, 11
14. ∅ – (res): 12, 13
LECTURE 3. RESOLUTION 49
3.3 Exercise
Using resolution check whether the following formula is
a tautology:
(p ∨ q) → q → (p ∨ (p ∧ q)) . (3.3)
LECTURE 3. RESOLUTION 50
3.3 Solution
We first transform negated (3.3) into conjunctive normal
form:
¬ (p ∨ q) → q → (p ∨ (p ∧ q)) ↔
(p ∨ q) ∧ ¬ q → (p ∨ (p ∧ q)) ↔
(p ∨ q) ∧ q ∧ ¬(p ∨ (p ∧ q)) ↔
(p ∨ q) ∧ q ∧ ¬p ∧ ¬(p ∧ q) ↔
(p ∨ q) ∧ q ∧ ¬p ∧ (¬p ∨ ¬q).
3.4 Exercise
Using resolution check whether the following formula is
satisfiable:
3.4 Solution
Formula (3.4) is in conjunctive normal form and consists
of the following clauses:
1 p∨q
2 ¬p ∨ q
3 p ∨ ¬q
4 ¬p ∨ ¬q.
3.5 Solution
The translation given by (1.5)–(1.19) (on page 14) im-
plied medium. The same translation is recalled as for-
mulas (3.5)–(3.19) (on page 54), so to apply resolution
we first transform (3.5)–(3.19) into the following set of
clauses:
1. small ∨ medium ∨ large
2. ¬small ∨ f irst
3. ¬medium ∨ second
4. ¬large ∨ third
5. ¬small ∨ green
6. ¬medium ∨ red
7. ¬large ∨ blue
8. second ∨ third
9. ¬blue
10. ¬f irst ∨ ¬second
11. ¬f irst ∨ ¬third
12. ¬second ∨ ¬f irst
13. ¬second ∨ ¬third
14. ¬third ∨ ¬f irst
15. ¬third ∨ ¬second.
16. ¬medium
LECTURE 3. RESOLUTION 56
Proof by resolution:
¬works; (3.20)
books ∨ tv ∨ ¬cooks. (3.21)
¬works → ¬tv; (3.22)
books ∨ tv ∨ cooks. (3.23)
LECTURE 3. RESOLUTION 58
3.6 Solution
We add negated conclusion ¬books to formulas (3.20)–
(3.23) we obtain the following set of clauses:
1. ¬works
2. books ∨ tv ∨ ¬cooks
3. works ∨ ¬tv
4. books ∨ tv ∨ cooks
5. ¬books.
Proof by resolution:
6. ¬tv – (res): 1, 3
7. books ∨ ¬cooks – (res): 2, 6
8. books ∨ cooks – (res): 4, 6
9. books ∨ books – (res): 7, 8
10. books – (fctr): 9
11. ∅ – (res): 5, 10
LECTURE 3. RESOLUTION 59
3.7 Solution
We have to negate (3.24) and transform into the clausal
form:
h i
¬ ¬ b ∨ (b → l) → ¬l ↔
¬ b ∨ (b → l) ∧ ¬¬l ↔
¬b ∧ ¬(b → l) ∧ ¬¬l ↔
¬b ∧ b ∧ ¬l ∧ ¬¬l ↔
¬b ∧ b ∧ ¬l ∧ l.
We have clauses:
1. ¬b
2. b
3. ¬l
4. l.
Proof by resolution:
4. ∅ – (res): 1, 2.
LECTURE 3. RESOLUTION 61
3.8 Exercise
Using resolution solve Exercise 2.5 (page 39). That is,
we have to verify whether formulas:
g ↔ (o ∨ j) (3.25)
o→p (3.26)
j→p (3.27)
imply:
1. g → p;
2. p → g.
LECTURE 3. RESOLUTION 62
3.8 Solution
First, we transform formulas (3.25)–(3.27) into clauses:
1. ¬g ∨ o ∨ j – obtained from g ↔ (o ∨ j)
2. ¬o ∨ g – obtained from g ↔ (o ∨ j)
3. ¬j ∨ g – obtained from g ↔ (o ∨ j)
4. ¬o ∨ p – obtained from o→p
5. ¬j ∨ p – obtained from j → p.
1
We first verify whether the obtained set of clauses implies
g → p, so negate conclusion:
¬(g → p) ↔ (g ∧ ¬p).
2
Below we shall use another optimization. Namely, we
shall remove subsumed clauses. A clause C subsumes a
clause D if every literal in C occurs also in D. In such
a cease we have that C → D and so clause D can be
removed.
No we verify whether the obtained set of clauses implies
p → g, so negate conclusion:
¬(p → g) ↔ (p ∧ ¬g).
Therefore we add clauses:
60 . p
70 . ¬g
and use resolution:
80 . ¬o – (res): 2, 7’
90 . ¬j – (res): 3, 7’.
3.9 Solution
In the sentences we have concepts:1 meat (m), fish food
(f ), animal food (a), milk products (mp), vegetarian (vt),
vegan (v).
We have the following concept inclusions (represented by
implications):
(¬m ∧ ¬f ) → vt (3.28)
v → (¬a ∧ ¬mp) (3.29)
m→a (3.30)
f → a. (3.31)
(¬m ∧ ¬f ) → vt ↔ ¬(¬m ∧ ¬f ) ∨ vt
↔ ¬¬m ∨ ¬¬f ∨ vt
↔ m ∨ f ∨ vt
v → (¬a ∧ ¬mp) ↔ ¬v ∨ (¬a ∧ ¬mp)
↔ (¬v ∨ ¬a) ∧ (¬v ∨ ¬mp)
m→a ↔ ¬m ∨ a
f →a ↔ ¬f ∨ a.
1
In brackets we give their abbreviations used later on.
LECTURE 3. RESOLUTION 66
1. m ∨ f ∨ vt
2. ¬v ∨ ¬a
3. ¬v ∨ ¬mp
4. ¬m ∨ a
5. ¬f ∨ a
6. v
7. ¬vt.
Proof by resolution:
8. m∨f – (res): 1, 7
9. ¬a – (res): 2, 6
10. ¬m – (res): 4, 9
11. ¬f – (res): 5, 9
12. f – (res): 8, 10
13. ∅ – (res): 11, 12.
First-order logic
67
LECTURE 4. FIRST-ORDER LOGIC 68
4.1 Exercise
Translate the following sentences into first-order logic:
4.1 Solution
Note that the sentences are in Aristotelian forms. Possi-
ble translations are given below.
2 ∃x[employee(x) ∧ on holidays(x)].
3 ∀x[employee(x) → ¬unemployed(x)].
4.2 Exercise
Translate the following sentences into first-order logic:
4.2 Solution
Concepts occurring in sentences are time and/or location
dependent. So, we have the following concepts (vocabu-
lary):
4.3 Exercise
Translate the following formulas into natural language:
4.3 Solution
(4.1) Four-wheels cars with strong engines are fast.
4.4 Exercise
Negate formulas obtained in Exercise 4.2 (page 70), sim-
plify them by moving negation inside and translate them
into natural language.
That is, we have to negate the following formulas consid-
ered in Exercise 4.2:
1. ∀t∃p travel(t, p) ∧ ¬f ar f rom(p, my city) ;
2. ∃t∃p travel(t, p) ∧ ¬f ar f rom(p, my city) ;
3. ∃t∀p (f avorite(p)∧¬f ar f rom(p, my city)) →
travel(t, p) .
LECTURE 4. FIRST-ORDER LOGIC 75
4.4 Solution
1
¬∀t∃p travel(t, p) ∧ ¬f ar f rom(p, my city) ↔
∃t¬∃p travel(t, p) ∧ ¬f ar f rom(p, my city) ↔
∃t∀p¬ travel(t, p) ∧ ¬f ar f rom(p, my city) ↔
∃t∀p ¬travel(t, p) ∨ ¬¬f ar f rom(p, my city) ↔
∃t∀p ¬travel(t, p) ∨ f ar f rom(p, my city) .
2
¬∃t∃p travel(t, p) ∧ ¬f ar f rom(p, my city) ↔
∀t¬∃p travel(t, p) ∧ ¬f ar f rom(p, my city) ↔
∀t∀p¬ travel(t, p) ∧ ¬f ar f rom(p, my city) ↔
∀t∀p ¬travel(t, p) ∨ ¬¬f ar f rom(p, my city) ↔
∀t∀p ¬travel(t, p) ∨ f ar f rom(p, my city) .
3
¬∃t∀p (f avorite(p) ∧ ¬f ar f rom(p, my city))
→ travel(t, p) ↔
∀t¬∀p (f avorite(p) ∧ ¬f ar f rom(p, my city))
→ travel(t, p) ↔
∀t∃p¬ (f avorite(p) ∧ ¬f ar f rom(p, my city))
→ travel(t, p) ↔
∀t∃p f avorite(p) ∧ ¬f ar f rom(p, my city)
∧ ¬travel(t, p) .
4.5 Solution
1
We first translate sentences into first-order formulas:
∀x[(animal(x)∧in room(x)) → (dog(x)∨cat(x))]; (4.5)
∃x[animal(x) ∧ in room(x) ∧ (dog(x) ∨ cat(x))]. (4.6)
The reasoning is formalized as:
(4.5) → (4.6). (4.7)
In such exercises a good idea is to start with constructing
a counterexample.
Consider a situation when there are no animals in the
considered room. In this case formula (4.5) is true, since:
∀x[(animal(x) ∧ in room(x)) → (dog(x)∨cat(x))],
| {z }
false
so no matter what value of implication conclusion is, the
whole implication is true.
On the other hand, formula (4.6) is false, since we have:
∃x[animal(x) ∧ in room(x) ∧(dog(x)∨cat(x))],
| {z }
false
so the whole conjunction under ∃x is false.
The reasoning expressed by (4.7) reduces in this case to
T → F which is F. Therefore the reasoning, in general,
is incorrect.
LECTURE 4. FIRST-ORDER LOGIC 79
2
The additional assumption can be translated into:
By (4.5), we have:
4.6 Solution
1
2
We start with constructing a counterexample. Consider
a place, say p. By (a), there is q such that move(p, q)
is true. By (c) we conclude move(q, q) (when x = p and
y = z = q). We cannot obtain any other conclusions, so
try to construct a counterexample:
In such a case, formulas (a) and (c) are true but it is not
the case that from every place there is a move to itself
(there is no move from p to p).
LECTURE 4. FIRST-ORDER LOGIC 83
3
Attempts to construct a counterexample fail, so lets try
to prove that the conclusion is correct.
Take arbitrary place p. By (a) there is a place q such
that there is a move from p to q (i.e., move(p, q)) is true.
Therefore, by (b), there is a move from q to p. The
formula under quantifiers in (c) holds for every x, y, z so,
in particular, for x = q, y = z = p. That is, we have:
4.7 Solution
1
2
Again, attempts to construct a counterexample fail, so
we try to prove that the conclusion is correct.
Take arbitrary place p. By (a’) there is a place q such that
there is a move from q to p (i.e., move(q, p)) is true. The
formula under quantifiers in (c) holds for every x, y, z so,
as before, we have (4.14) and we conclude that move(p, p)
must be true. Since p was arbitrarily chosen, we have that
∀p(move(p, p)), meaning that from every place there is
a move to itself.
LECTURE 4. FIRST-ORDER LOGIC 86
4.8 Solution
1
A natural translation is:
2
Assumung (4.15)–(4.19) we can conclude that blue(a) is
true. By (4.19) we have that a is not green so, by (4.15),
it must be red or blue. By (4.18), a is to the right of
b where, by (4.19), b is green. Contraposing (4.16), we
have that a is not to the left of b. Therefore, by (4.17),
a cannot be red. So it has to be blue.
LECTURE 4. FIRST-ORDER LOGIC 88
4.9 Solution
1
Attempts to construct a counterexample fail, so we try
to prove that 1 holds.
We proceed using the reduction to absurdity method.
Suppose that (4.23) does not follow from the conjunc-
tion of (4.20)–(4.22). This means that (4.20)–(4.22) hold
while there is a domain element a such that R(a, a) holds.
From R(a, a) and (4.20) we deduce that ∀yR(a, y) holds.
Using(4.21) we deduce ∀yR(y, a). This contradicts (4.22)
because, for x = a, (4.22) implies ∃y[¬R(y, a)] being
equivalent to ¬∀yR(y, a).
The assumption that (4.23) is not true leads to contra-
diction. Therefore (4.23) follows form the conjunction of
(4.20)–(4.22).
LECTURE 4. FIRST-ORDER LOGIC 90
2
We construct a counterexample. That is, we assume
that (4.20), (4.22) and (4.23) are true and (4.21) is false.
Observe that (4.21) is false when there are elements a, b
in the domain such that R(a, b) is true and R(b, a) is
false. Now, to satisfy (4.22), we have to add a domain
element, say c, such that ¬R(c, b) is true. This gives
rise to a counterexample: we assume that the domain
is {a, b, c}, and that R(x, y) is true only for x = a, y =
b. In particular, ∀x[¬R(x, x)] holds, so (4.23) is true.
This, in turn, makes (4.20) true since the antecedent of
implication is always false.
Therefore, in the constructed example formulas (4.20),
(4.22) and (4.23) are true and (4.21) is false. Hence, (4.21)
does not follow from the conjunction of (4.20), (4.22) and
(4.23).
Lecture 5
Tableaux: FOL
91
LECTURE 5. TABLEAUX: FOL 92
5.1 Exercise
Consider the following statement concerning a barber
(actually the only barber in town):1
5.1 Solution
The translation of the considered statement is:
5.2 Exercise
Using tableaux check whether the following formula is
satisfiable:
where a is a constant.
LECTURE 5. TABLEAUX: FOL 95
5.2 Solution
We construct a tableau for (5.2):
∀xR(x, a) ∧ ∀z[¬R(z, z)]
↓ (∧)
∀xR(x, a), ∀z[¬R(z, z)]
↓ (∀x with x = a)
R(a, a), ∀z[¬R(z, z)]
↓ (∀z with z = a)
R(a, a), ¬R(a, a)
↓ (∀x with x = b)
R(a, b), ∃yR(b, y)
↓ (∃y with y = c)
R(a, b), R(b, c)
5.3 Solution
We construct a tableau for the negation of (5.4):
h i
¬ ∀x∃y[R(x, y)]∧∀x∀y[R(x, y)→∀zR(x, z)] → ∀x∀yR(x, y)
↓ (¬ →)
∀x∃y[R(x, y)] ∧ ∀x∀y[R(x, y) → ∀zR(x, z)], ¬∀x∀yR(x, y)
↓ (¬∀x with x = a)
∀x∃y[R(x, y)] ∧ ∀x∀y[R(x, y) → ∀zR(x, z)], ¬∀yR(a, y)
↓ (¬∀y with y = b)
∀x∃y[R(x, y)] ∧ ∀x∀y[R(x, y) → ∀zR(x, z)], ¬R(a, b)
↓ (∀x with x = a)
∃y[R(a, y)] ∧ ∀x∀y[R(x, y) → ∀zR(x, z)], ¬R(a, b)
↓ (∃y with y = c)
R(a, c) ∧ ∀x∀y[R(x, y) → ∀zR(x, z)], ¬R(a, b)
↓ (∧)
R(a, c), ∀x∀y[R(x, y) → ∀zR(x, z)], ¬R(a, b)
↓ (∀x with x = a)
R(a, c), ∀y[R(a, y) → ∀zR(a, z)], ¬R(a, b)
↓ (∀y with y = c)
R(a, c), R(a, c) → ∀zR(a, z), ¬R(a, b)
. & (→)
R(a, c), ¬R(a, c), ¬R(a, b) R(a, c), ∀zR(a, z), ¬R(a, b)
↓ (∀z with z = b)
| {z }
closed
R(a, c), R(a, b), ¬R(a, b)
| {z }
closed
implies:
where a is a constant.
LECTURE 5. TABLEAUX: FOL 100
5.4 Solution
We construct a tableau for ¬[(5.5) → (5.6)]:
¬ ∀x∃y∃z[P (x, y, z)∨¬∃z∃u(¬P (x, z, u))] → ∃x∃yP (a, x, y)
↓ (¬ →)
∀x∃y∃z[P (x, y, z) ∨ ¬∃z∃u(¬P (x, z, u))], ¬∃x∃yP (a, x, y)
↓ (∀x with x = a)
∃y∃z[P (a, y, z) ∨ ¬∃z∃u(¬P (a, z, u))], ¬∃x∃yP (a, x, y)
↓ (∃y with y = b)
∃z[P (a, b, z) ∨ ¬∃z∃u(¬P (a, z, u))], ¬∃x∃yP (a, x, y)
↓ (∃z with z = c)
P (a, b, c) ∨ ¬∃z∃u(¬P (a, z, u)), ¬∃x∃yP (a, x, y)
↓ (¬∃x with x = b)
P (a, b, c) ∨ ¬∃z∃u(¬P (a, z, u)), ¬∃yP (a, b, y)
↓ (¬∃y with y = c)
P (a, b, c) ∨ ¬∃z∃u(¬P (a, z, u)), ¬P (a, b, c)
. & (∨)
P (a, b, c), ¬P (a, b, c) ¬∃z∃u(¬P (a, z, u)), ¬P (a, b, c)
↓ (¬∃z with z = b)
| {z }
closed
¬∃u(¬P (a, b, u)), ¬P (a, b, c)
↓ (¬∃u with u = c)
¬¬P (a, b, c), ¬P (a, b, c)
↓ (¬¬)
P (a, b, c), ¬P (a, b, c)
| {z }
closed
5.5 Solution
We verify whether:
For the tableau to better fit the page we shall use the
following abbreviations:
• child is denoted by C;
• parent is denoted by P ;
• person is denoted by S.
LECTURE 5. TABLEAUX: FOL 103
The tableau:
¬ ∀x[C(x) ↔ ∃y(P (y, x))] ∧ ∀x∀y[P (x,y) → (S(x) ∧ S(y))]
→ ∀x[C(x) → S(x)]
↓ (¬ →)
∀x[C(x) ↔ ∃y(P (y, x))] ∧ ∀x∀y[P (x, y) → (S(x) ∧ S(y))],
¬∀x[C(x) → S(x)]
↓ (∧)
∀x[C(x) ↔ ∃y(P (y, x))], ∀x∀y[P (x, y) → (S(x) ∧ S(y))],
¬∀x[C(x) → S(x)]
↓ (¬∀x with x = a)
∀x[C(x) ↔ ∃y(P (y, x))], ∀x∀y[P (x, y) → (S(x) ∧ S(y))],
¬(C(a) → S(a))
↓ (¬ →)
∀x[C(x) ↔ ∃y(P (y, x))], ∀x∀y[P (x, y) → (S(x) ∧ S(y))],
C(a), ¬S(a)
↓ (∀x with x = a)
C(a) ↔ ∃y(P (y, a)), ∀x∀y[P (x, y) → (S(x) ∧ S(y))],
C(a), ¬S(a)
↓ (↔)
¬C(a)∨∃y(P (y, a)), C(a)∨¬∃y(P (y, a)),
∀x∀y[P (x, y) → (S(x) ∧ S(y))], C(a), ¬S(a)
. (∨)
¬C(a), C(a)∨¬∃y(P (y, a)), |
∀x∀y[P (x, y) → (S(x)∧S(y))], C(a), ¬S(a) |
↓
| {z }
closed
∃y(P (y, a)), C(a)∨¬∃y(P (y, a)),
∀x∀y[P (x, y) → (S(x) ∧ S(y))], C(a), ¬S(a)
. & (∨)
(∗) (∗∗)
LECTURE 5. TABLEAUX: FOL 104
5.6 Exercise
Let the following taxonomy, reflecting a particular situ-
ation, be given:
5.6 Solution
Let B and R denote “brown” and “red”, respectively.
We have to verify:
5.7 Solution
For the tableau to better fit the page we shall use the
following abbreviations:
• animal is denoted by a;
• in room is denoted by i;
• dog is denoted by d;
• cat is denoted by c.
5.8 Solution
We have to show that:
[(5.13)∧(5.14)∧(5.15)∧(5.16)∧(5.17)] → blue(a). (5.18)
• red is denoted by R;
• green is denoted by G;
• blue is denoted by B;
• lef t is denoted by l;
• right is denoted by H.
h
¬ ∀x[R(x) ∨ G(x) ∨ B(x)] ∧ ∀x∀y[L(x, y) → ¬H(x, y)]∧
∀x∀y[(R(x) ∧ G(y)) → L(x, y)]∧i
H(a, b) ∧ G(b) ∧ ¬G(a) → B(a)
↓ (¬ →)
∀x[R(x) ∨ G(x) ∨ B(x)] ∧ ∀x∀y[L(x, y) → ¬H(x, y)]∧
∀x∀y[(R(x) ∧ G(y)) → L(x, y)]∧
H(a, b) ∧ G(b) ∧ ¬G(a), ¬B(a)
↓ (∀x with x = a)
R(a) ∨ G(a) ∨ B(a) ∧ ∀x∀y[L(x, y) → ¬H(x, y)]∧
∀x∀y[(R(x) ∧ G(y)) → L(x, y)]∧
H(a, b) ∧ G(b) ∧ ¬G(a), ¬B(a)
↓ (∧)
R(a) ∨ G(a) ∨ B(a), ∀x∀y[L(x, y) → ¬H(x, y)]∧
∀x∀y[(R(x) ∧ G(y)) → L(x, y)]∧
H(a, b) ∧ G(b) ∧ ¬G(a), ¬B(a)
↓ (∧)
R(a) ∨ G(a) ∨ B(a), ∀x∀y[L(x, y) → ¬H(x, y)],
∀x∀y[(R(x) ∧ G(y)) → L(x, y)]∧
H(a, b) ∧ G(b) ∧ ¬G(a), ¬B(a)
↓ (∧)
R(a) ∨ G(a) ∨ B(a), ∀x∀y[L(x, y) → ¬H(x, y)],
∀x∀y[(R(x) ∧ G(y)) → L(x, y)],
H(a, b) ∧ G(b) ∧ ¬G(a), ¬B(a)
↓ (∧)
R(a) ∨ G(a) ∨ B(a), ∀x∀y[L(x, y) → ¬H(x, y)],
∀x∀y[(R(x) ∧ G(y)) → L(x, y)],
H(a, b), G(b) ∧ ¬G(a), ¬B(a)
↓ (∧)
LECTURE 5. TABLEAUX: FOL 114
↓ (∧)
R(a) ∨ G(a) ∨ B(a), ∀x∀y[L(x, y) → ¬H(x, y)],
∀x∀y[(R(x) ∧ G(y)) → L(x, y)],
H(a, b), G(b), ¬G(a), ¬B(a)
. & (∨)
R(a), ∀x∀y[L(x, y) → ¬H(x, y)], (∗)
∀x∀y[(R(x) ∧ G(y)) → L(x, y)],
H(a, b), G(b), ¬G(a), ¬B(a)
↓ (∀x with x = a)
R(a), ∀y[L(a, y) → ¬H(a, y)],
∀x∀y[(R(x) ∧ G(y)) → L(x, y)],
H(a, b), G(b), ¬G(a), ¬B(a)
↓ (∀y with y = b)
R(a), L(a, b) → ¬H(a, b), ∀x∀y[(R(x) ∧ G(y)) → L(x, y)],
H(a, b), G(b), ¬G(a), ¬B(a)
& (→)
| ¬H(a, b), ∀x∀y[(R(x) ∧ G(y)) → L(x, y)],
| H(a, b), G(b), ¬G(a), ¬B(a)
|
| {z }
closed
↓
R(a), ¬L(a, b), ∀x∀y[(R(x) ∧ G(y)) → L(x, y)],
H(a, b), G(b), ¬G(a), ¬B(a)
↓ (∀x with x = a)
R(a), ¬L(a, b), ∀y[(R(a) ∧ G(y)) → L(a, y)],
H(a, b), G(b), ¬G(a), ¬B(a)
↓ (∀y with y = b)
R(a), ¬L(a, b), (R(a) ∧ G(b)) → L(a, b),
H(a, b), G(b), ¬G(a), ¬B(a)
. & (→)
(∗∗) (∗ ∗ ∗)
LECTURE 5. TABLEAUX: FOL 115
∀x[R(x, x) → ∀yR(x, y)]∧
∀x∀y[R(x, y) → R(y, x)]∧ → ∀x[¬R(x, x)]. (5.19)
∀x∃y[¬R(y, x)]
LECTURE 5. TABLEAUX: FOL 117
5.9 Solution
We construct a tableau for the negation of (5.19):
¬ [∀x[R(x, x) → ∀yR(x, y)] ∧ ∀x∀y[R(x, y) → R(y, x)]∧
∀x∃y[¬R(y, x)]] → ∀x[¬R(x, x)]
↓ (¬ →)
∀x[R(x, x) → ∀yR(x, y)] ∧ ∀x∀y[R(x, y) → R(y, x)]∧
∀x∃y[¬R(y, x)], ¬∀x[¬R(x, x)]
↓ (∧)
∀x[R(x, x) → ∀yR(x, y)], ∀x∀y[R(x, y) → R(y, x)]∧
∀x∃y[¬R(y, x)], ¬∀x[¬R(x, x)]
↓ (∧)
∀x[R(x, x) → ∀yR(x, y)], ∀x∀y[R(x, y) → R(y, x)],
∀x∃y[¬R(y, x)], ¬∀x[¬R(x, x)]
↓ (¬∀x with x = a)
∀x[R(x, x) → ∀yR(x, y)], ∀x∀y[R(x, y) → R(y, x)],
∀x∃y[¬R(y, x)], ¬¬R(a, a)
↓ (¬¬)
∀x[R(x, x) → ∀yR(x, y)], ∀x∀y[R(x, y) → R(y, x)],
∀x∃y[¬R(y, x)], R(a, a)
↓ (∀x with x = a)
∀x[R(x, x) → ∀yR(x, y)], ∀x∀y[R(x, y) → R(y, x)],
∃y[¬R(y, a)], R(a, a)
↓ (∃y with y = b)
∀x[R(x, x) → ∀yR(x, y)], ∀x∀y[R(x, y) → R(y, x)],
¬R(b, a), R(a, a)
↓ (∀x with x = a)
R(a, a) → ∀yR(a, y), ∀x∀y[R(x, y) → R(y, x)],
¬R(b, a), R(a, a)
& (→)
| (∗)
↓
¬R(a, a), ∀x∀y[R(x, y) → R(y, x)],¬R(b, a), R(a, a)
| {z }
closed
LECTURE 5. TABLEAUX: FOL 118
Resolution: FOL
119
LECTURE 6. RESOLUTION: FOL 120
6.1 Exercise
Transform the following formula into an equisatisfiable
set of clauses:1
¬∀x∃y ∀z(R(x, y, z) → ∀u(S(x, u) ∨ T (y, z, u)))
(6.1)
∧∃vS(x, y, v) .
1
Formulas A and B are equisatisfiable when A is satisfiable iff
B is satisfiable.
LECTURE 6. RESOLUTION: FOL 121
LECTURE 6. RESOLUTION: FOL 122
6.1 Solution
We first transform (6.1) into the prenex normal form:
¬∀x∃y ∀z(R(x, y, z) → ∀u(S(x, u) ∨ T (y, z, u)))
↔
∧∃vS(x, y, v)
∃x¬∃y ∀z(R(x, y, z) → ∀u(S(x, u) ∨ T (y, z, u)))
↔
∧∃vS(x, y, v)
∃x∀y¬ ∀z(R(x, y, z) → ∀u(S(x, u) ∨ T (y, z, u)))
↔
∧∃vS(x, y, v)
∃x∀y ¬∀z(R(x, y, z) → ∀u(S(x, u) ∨ T (y, z, u)))
↔
∨¬∃vS(x, y, v)
∃x∀y ∃z¬(R(x, y, z) → ∀u(S(x, u) ∨ T (y, z, u)))
↔
∨∀v¬S(x, y, v)
∃x∀y ∃z(R(x, y, z) ∧ ¬∀u(S(x, u) ∨ T(y, z, u)))
↔
∨∀v¬S(x, y, v)
∃x∀y ∃z(R(x, y, z) ∧ ∃u¬(S(x, u) ∨ T(y, z, u)))
↔
∨∀v¬S(x, y, v)
∃x∀y∃z (R(x, y, z) ∧ ∃u¬(S(x, u) ∨ T(y, z, u)))
↔
∨∀v¬S(x, y, v)
∃x∀y∃z∀v (R(x, y, z) ∧ ∃u¬(S(x, u) ∨ T (y, z, u))) ↔
∨¬S(x, y, v)
∃x∀y∃z∀v ∃u(R(x, y, z) ∧ ¬(S(x, u) ∨ T (y, z, u))) ↔
∨¬S(x, y, v)
∃x∀y∃z∀v∃u (R(x, y, z) ∧ ¬(S(x, u) ∨ T (y, z, u)))
∨¬S(x, y, v) .
LECTURE 6. RESOLUTION: FOL 123
6.2 Exercise
Unify the following literals:
6.2 Solution
1
Expression trees are:
P P
| |
x f g f u v
| |
x y z z
P P
| |
f f g f f g
| | | |
z f y z z f y z
| |
z z
2
Expression trees are:
P P
| |
x f v f x v
| |
x z
6.3 Exercise
Using resolution solve Exercise 5.1 (page 92). That is,
we have to chect the satisfiability of:
6.3 Solution
We transform (6.2) into a set of clauses:
1. ¬shaves(barber, x1 ) ∨ ¬shaves(x1 , x1 )
2. shaves(barber, x2 ) ∨ shaves(x2 , x2 )
3. ¬shaves(barber, barber)
– (fctr): 1 with x1 = barber
4. shaves(barber, barber)
– (fctr): 2 with x2 = barber
5. ∅ – (res): 3, 4.
LECTURE 6. RESOLUTION: FOL 131
where a is a constant.
LECTURE 6. RESOLUTION: FOL 132
LECTURE 6. RESOLUTION: FOL 133
6.4 Solution
We transform negated (6.3) into the prenex normal form:
¬∀x∃y∃z (P (x, y, z) ∨ ¬∃z∃u(¬P (x, z, u)))
↔
→ ∃x∃yP (f (a), x, y)
∃x¬∃y∃z (P (x, y, z) ∨ ¬∃z∃u(¬P (x, z, u)))
↔
→ ∃x∃yP (f (a), x, y)
∃x∀y¬∃z (P (x, y, z) ∨ ¬∃z∃u(¬P (x, z, u)))
↔
→ ∃x∃yP (f (a), x, y)
∃x∀y∀z¬ (P (x, y, z) ∨ ¬∃z∃u(¬P (x, z, u)))
↔
→ ∃x∃yP (f (a), x, y)
∃x∀y∀z (P (x, y, z) ∨ ¬∃z∃u(¬P (x, z, u)))
↔
∧¬∃x∃yP (f (a), x, y)
∃x∀y∀z (P (x, y, z) ∨ ∀z¬∃u(¬P (x, z, u)))
↔
∧∀x¬∃yP (f (a), x, y)
∃x∀y∀z (P (x, y, z) ∨ ∀z∀u¬(¬P (x, z, u)))
↔
∧∀x∀y¬P (f (a), x, y)
∃x∀y∀z (P (x, y, z) ∨ ∀z 0 ∀uP (x, z; , u))
↔
∧∀x0 ∀y 0 ¬P (f (a), x0 , y 0 )
∃x∀y∀z (P (x, y, z) ∨ ∀z 0 ∀uP (x, z 0 , u))
↔
∧∀x0 ∀y 0 ¬P (f (a), x0 , y 0 )
∃x∀y∀z∀z 0 ∀u (P (x, y, z) ∨ P (x, z 0 , u))
↔
∧∀x0 ∀y 0 ¬P (f (a), x0 , y 0 )
∃x∀y∀z∀z 0 ∀u∀x0 ∀y 0 (P (x, y, z) ∨ P (x, z 0 , u))
↔
∧¬P (f (a), x0 , y 0 ) .
LECTURE 6. RESOLUTION: FOL 134
∧¬P (f (a), x0 , y 0 ) .
1. P (b, y1 , z) ∨ P (b, z1 , u)
2. ¬P (f (a), x2 , y2 ).
6.5 Solution
We first negate formula (6.4):
nh i
¬ ∀yQ(b, y) ∧ ∀x∀y[Q(x, y) → Q(s(x), s(y))] →
o
∃z[Q(b, z) ∧ Q(z, s(s(b)))] ↔
h i
∀yQ(b, y) ∧ ∀x∀y[Q(x, y) → Q(s(x), s(y))] ∧
h ¬∃z[Q(b, z) ∧ Q(z, s(s(b)))]
i ↔
∀yQ(b, y) ∧ ∀x∀y[Q(x, y) → Q(s(x), s(y))] ∧
∀z¬[Q(b, z) ∧ Q(z, s(s(b)))].
1. Q(b, y1 );
2. ¬Q(x2 , y2 ) ∨ Q(s(x2 ), s(y2 ));
3. ¬Q(b, z3 ) ∨ ¬Q(z3 , s(s(b))).
Proof by resolution:
6.6 Solution
We have to prove that implication (6.7) indeed holds, so
we negate it:
¬ ∀x[child(x) ↔ ∃y(parent(y, x))]∧
∀x∀y[parent(x, y) → (person(x) ∧ person(y))]
→ ∀x[child(x) → person(x)] ↔
∀x[child(x) ↔ ∃y(parent(y, x))]∧
∀x∀y[parent(x, y) → (person(x) ∧ person(y))]∧
¬∀x[child(x) → person(x)] ↔
∀x[(¬child(x) ∨ ∃y(parent(y, x)))∧
(¬∃y(parent(y, x)) ∨ child(x))]∧
∀x∀y[¬parent(x, y) ∨ (person(x) ∧ person(y))]∧
∃x¬[child(x) → person(x)] ↔
∀x∃y[(¬child(x) ∨ parent(y, x))∧
(∀y(¬parent(y, x)) ∨ child(x))]∧
∀x∀y[(¬parent(x, y) ∨ person(x))∧
(¬parent(x, y) ∨ person(y))]∧
∃x[child(x) ∧ ¬person(x)].
LECTURE 6. RESOLUTION: FOL 139
Proof by resolution:
6.7 Solution
We first transform negated (6.8) into the conjunctive nor-
mal form:
¬ ∀x[(animal(x)∧in room(x)) → (dog(x)∨cat(x))]
→ ∃x[animal(x)∧in room(x)∧(dog(x)∨cat(x))] ↔
∀x[(animal(x)∧in room(x)) → (dog(x)∨cat(x))]
∧¬∃x[animal(x)∧in room(x)∧(dog(x)∨cat(x))] ↔
∀x[¬(animal(x)∧in room(x)) ∨ dog(x)∨cat(x)]
∧∀x¬[animal(x)∧in room(x)∧(dog(x)∨cat(x))] ↔
∀x[¬animal(x) ∨ ¬in room(x) ∨ dog(x) ∨ cat(x)]
∧∀x[¬animal(x) ∨ ¬in room(x) ∨ ¬(dog(x)∨cat(x))] ↔
∀x[¬animal(x) ∨ ¬in room(x) ∨ dog(x) ∨ cat(x)]
∧∀x[¬animal(x)∨¬in room(x)∨(¬dog(x)∧¬cat(x))] ↔
∀x[¬animal(x) ∨ ¬in room(x) ∨ dog(x) ∨ cat(x)]
∧∀x[(¬animal(x)∨¬in room(x)∨¬dog(x))
∧ (¬animal(x)∨¬in room(x) ∨ ¬cat(x))].
6.8 Solution
We negate the claim and obtain formulas:
Proof by resolution:
6.9 Solution
We transform the negated (6.22) into the clausal form:
Resolution proof:
6.10 Solution
We transform negated (6.23) into clausal form:
Resolution proof:
Deductive databases
150
LECTURE 7. DEDUCTIVE DATABASES 151
7.1 Exercise
Translate the following rule into a first-order formula:
brother(X, Y ) :− male(X),
parent(Z, X), (7.1)
parent(Z, Y ).
LECTURE 7. DEDUCTIVE DATABASES 152
7.1 Solution
In rule (7.1) variable Z occurs only in the rule’s body, so
it is existentially quantified. The body is translated into:
h
∀x∀y ∃z[male(x) ∧ parent(z, x) ∧ parent(z, y)]
i (7.4)
→ brother(x, y) .
LECTURE 7. DEDUCTIVE DATABASES 153
7.2 Exercise
Transform the following formulas into Datalog rules:
1.
∀x∀y (mother(x, y) ∨ f ather(x, y))
(7.5)
→ parent(x, y) ;
2.
∀x∀y [¬(parent(x, y)
→ ¬male(y))] (7.6)
→ son(y) ;
3.
∀x∀y mother(x, y) (7.7)
→ (parent(x, y) ∧ f emale(x)) .
4.
∀y∀z ∃x(parent(y, x) ∧ parent(x,
z))] (7.8)
→ grandparent(y, z) .
LECTURE 7. DEDUCTIVE DATABASES 154
7.2 Solution
1
First note that, according to our convention, universal
quantifiers in (7.5) can be removed:
mother(x, y) → parent(x, y) ∧
(7.10)
f ather(x, y) → parent(x, y).
parent(X, Y ) :− mother(X, Y ).
(7.11)
parent(X, Y ) :− f ather(X, Y ).
LECTURE 7. DEDUCTIVE DATABASES 155
2
As before, we remove universal quantifiers from (7.6):
[¬(parent(x, y) → ¬male(y))] → son(y). (7.12)
Using the implication law we obtain the following formula
equivalent to (7.12):
[parent(x, y) ∧ ¬¬male(y)] → son(y). (7.13)
We remove double negation:
[parent(x, y) ∧ male(y)] → son(y). (7.14)
and obtain the following Datalog rule:
son(Y ) :− parent(x, y), male(y). (7.15)
3
As before, we remove universal quantifiers from (7.7):
mother(x, y) → (parent(x, y) ∧ f emale(x)). (7.16)
Now we use tautology p → (q∧r) ↔ [(p → r)∧(p → r)]
according to which (7.16) is equivalent to:
mother(x, y) → parent(x, y) ∧
(7.17)
mother(x, y) → f emale(x).
Now it is easy to see that (7.17) is equivalent to the fol-
lowing Datalog rules:
parent(X, Y ) :− mother(X, Y ).
(7.18)
f emale(X) :− mother(X, Y ).
LECTURE 7. DEDUCTIVE DATABASES 156
4
First we remove universal quantifiers from (7.8):
1
Note that this is not Skolemization. We simply use the fact
that variables appearing in rule’s body and not appearing in its
head are implicitly existentially quantified in the body.
LECTURE 7. DEDUCTIVE DATABASES 157
7.3 Solution
1
The database contains relations:
Example:
2
Every object has unique (exactly one) size and unique
velocity:
→ (s = s0 ∧ v = v 0 ) .
3
An integrity constraint concerning the precedence rela-
tion between objects:
4(a)
Select all bikes which are directly between two large cars
(recall that ‘ ’ is an anonymous “don’t care” variable):
4(b)
Select all medium cars which precede (not necessarily
directly) a fast large car.
We first define the precedence relation:
c
' $
b
a
d
& %
4
Directly or not.
LECTURE 7. DEDUCTIVE DATABASES 163
7.4 Solution
1
The database contains relations:
Example:
2
The relation of containment is antisymmetric:
3
Another integrity constraint concerning the relation of
region containment:
∀x[¬d cont(x, x)].
4(a)
Select all small regions directly contained in a large circle:
answer(R) :− region(R, , ‘small’, ),
region(R1, ‘circle’, ‘large’, ),
d cont(R, R1).
Now answer(X) provides all required regions.
4(b)
Select all small objects contained in a big green square.
We first define:
contained(R1, R2) :− d cont(R1, R2).
contained(R1, R2) :− d cont(R1, R3), (7.22)
contained(R3, R2).
The required query can be formulated as:
answer(R) :− region(R, , ‘small’, ),
region(R1, ‘square’, ‘big’, ‘green’),
contained(R, R1).
LECTURE 7. DEDUCTIVE DATABASES 165
S2 L
i1
S1 S3 S4 S5
i
L2 S6
7.5 Solution
1
The database contains relations:
Example:
2
Each landmark is close to exactly one road segment:
∀x∃y close(x, y) ∧ ∀z(close(x, z) → z = y) . (7.23)
3
Another integrity constraint concerning relationships in
the database:
∀x∀y∀z∀y 0 ∀z 0 [(segment(x, y, z) ∧ segment(x, y 0 , z 0 ))
→ (y = y 0 ∧ z = z 0 )]
4(a)
Select all all landmarks close to roads which are of high
km
quality with average speed greater than 65 h
:
4(b)
Select all landmarks which are accessible by a road trip
from a given landmark.
We first define accessibility among road segments (acc)
and accessibility among landmarks (accessible):
answer(N ) :− accessible(‘HugeStatue’, N ).
Lecture 8
Sequent (Gentzen)
calculus
170
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
171
8.1 Exercise
Using Gentzen system solve Exercise 2.2, i.e., check whether
the following formula is satisfiable:
8.1 Solution
To check satisfiability we use the “inverted” sequent:
• p ⇒ q gives p = T and q = F;
• q ⇒ p gives q = T and p = F.
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
173
1. (p ∨ q) → p. (8.2)
2. (p ∨ q) → (p ∧ r). (8.3)
3. (p → q) ∨ (q → p). (8.4)
4. (p ∨ q) → (p ∨ q ∨ ¬r) ∧ (r ∨ p ∨ q) (8.5)
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
174
8.2 Solution
1
We construct a proof tree for (8.2):
(→ r) ∅ ⇒ (p ∨ q) → p
(∨l) p∨q ⇒p
p⇒p q⇒p
| {z }
axiom
2
We construct a proof tree for (8.3):
(→ r) ∅ ⇒ (p ∨ q) → (p ∧ r)
(∨l) p∨q ⇒p∧r
3
We construct a proof tree for (8.4):
(∨r) ∅ ⇒ (p → q) ∨ (q → p)
(→ r) ∅ ⇒ p → q, q → p
(→ r) p ⇒ q, q → p
p, q ⇒ q, p
| {z }
axom
4
We construct a proof tree for (8.5):
(→ r) ∅ ⇒ (p ∨ q) → (p ∨ q ∨ ¬r) ∧ (r ∨ p ∨ q)
(∧r) p ∨ q ⇒ (p ∨ q ∨ ¬r) ∧ (r ∨ p ∨ q)
p ∨ q ⇒ p ∨ q ∨ ¬r p∨q ⇒r∨p∨q
(∨r) (∨r)
p ∨ q ⇒ p, q ∨ ¬r p ∨ q ⇒ r, p ∨ q
(∨r) (∨r)
p ∨ q ⇒ p, q, ¬r p ∨ q ⇒ r, p, q
(∨l) (∨l)
p ⇒ p, q, ¬r q ⇒ p, q, ¬r p ⇒ r, p, q q ⇒ r, p, q
| {z } | {z } | {z } | {z }
axiom axiom axiom axiom
8.3 Exercise
Derive rules for the connective “exclusive or” ∨ defined
by:
8.3 Solution
Derivation of rule ( ∨ l):
(def ) A, B ∨ C, D ⇒ E
The rule:
( ∨ l) A, B ∨ C, D ⇒ E
A, B, D ⇒ C, E A, C, D ⇒ B, E
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
180
(def ) A ⇒ B, C ∨ D, E
(∨r) A ⇒ B, C ∨ D, E A ⇒ B, ¬C ∨ ¬D, E
(∨r) A ⇒ B, C, D, E (¬r) A ⇒ B, ¬C, ¬D, E
(¬r) A, C ⇒ B, ¬D, E
A, C, D ⇒ B, E
The rule:
( ∨ r) A ⇒ B, C ∨ D, E
A ⇒ B, C, D, E A, C, D ⇒ B, E
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
181
8.4 Exercise
Using rules derived in Exercise 8.3, verify whether:
1. (p ∨ q) → (p ∨ q);
2. (p ∨ q) → (p ∨ q).
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
182
8.4 Solution
1
(→ r) ∅ ⇒ (p ∨ q) → (p ∨ q)
(∨r) p ∨ q ⇒ p ∨ q
( ∨ l) p ∨ q ⇒ p, q
p ⇒ q, p, q q ⇒ p, p, q
| {z } | {z }
axiom axiom
All leaves are axioms, so formula (p ∨ q) → (p ∨ q) is
a tautology.
(→ r) ∅ ⇒ (p ∨ q) → (p ∨ q)
( ∨r) p ∨ q ⇒ p∨q
∀x∃y[R(x, y)] ∧ ∀x∀y[R(x, y) → ∀zR(x, z)]
(8.7)
→ ∀x∀yR(x, y).
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
184
8.5 Solution
A proof:
∅ ⇒ ∀x∃y[R(x, y)] ∧ ∀x∀y[R(x, y) → ∀zR(x, z)]
(→ r) → ∀x∀yR(x, y)
∀x∃y[R(x, y)] ∧ ∀x∀y[R(x, y) → ∀zR(x, z)] ⇒
∀x∀yR(x, y)
(∧l)
∀x∃y[R(x, y)], ∀x∀y[R(x, y) → ∀zR(x, z)] ⇒ ∀x∀yR(x, y)
(∀x r)
(∀y r) ∀x∃y[R(x, y)], ∀x∀y[R(x, y) → ∀zR(x, z)] ⇒ ∀yR(a, y)
(∀x l) ∀x∃y[R(x, y)], ∀x∀y[R(x, y) → ∀zR(x, z)] ⇒ R(a, b)
∃y[R(a, y)], ∀x∀y[R(x, y) → ∀zR(x, z)] ⇒ R(a, b)
(∃y l)
R(a, c), ∀x∀y[R(x, y) → ∀zR(x, z)] ⇒ R(a, b)
(∀x l)
R(a, c), ∀y[R(a, y) → ∀zR(a, z)] ⇒ R(a, b)
(∀y l)
(→ l) R(a, c), R(a, c) → ∀zR(a, z) ⇒ R(a, b)
R(a, c) ⇒ R(a, c), R(a, b) (∀z l) R(a, c), ∀zR(a, z) ⇒ R(a, b)
| {z }
axiom R(a, c), R(a, b) ⇒ R(a, b)
| {z }
axiom
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
185
implies:
where a is a constant.
(The same implication is considered in Exercise 5.4,
page 99).
LECTURE 8. SEQUENT (GENTZEN) CALCULUS
186
8.6 Solution
∅ ⇒ ∀x∃y∃z[P (x, y, z) ∨ ¬∃z∃u(¬P (x, z, u))]
→ ∃x∃yP (a, x, y)
(→ r)
(∀x l) ∀x∃y∃z[P (x, y, z) ∨ ¬∃z∃u(¬P (x, z, u))] ⇒ ∃x∃yP (a, x, y)
(∃y l) ∃y∃z[P (a, y, z) ∨ ¬∃z∃u(¬P (a, z, u))] ⇒ ∃x∃yP (a, x, y)
∃z[P (a, b, z) ∨ ¬∃z∃u(¬P (a, z, u))] ⇒ ∃x∃yP (a, x, y)
(∃z l)
P (a, b, c) ∨ ¬∃z∃u(¬P (a, z, u)) ⇒ ∃x∃yP (a, x, y)
(∃x r)
P (a, b, c) ∨ ¬∃z∃u(¬P (a, z, u)) ⇒ ∃yP (a, b, y)
(∃y r)
(∨l) P (a, b, c) ∨ ¬∃z∃u(¬P (a, z, u)) ⇒ P (a, b, c)
P (a, b, c) ⇒ P (a, b, c) (¬l) ¬∃z∃u(¬P (a, z, u)) ⇒ P (a, b, c)
| {z }
axiom (∃z r) ∅ ⇒ P (a, b, c), ∃z∃u(¬P (a, z, u))
∅ ⇒ P (a, b, c), ∃u(¬P (a, b, u))
(∃u r)
∅ ⇒ P (a, b, c), ¬P (a, b, c)
(¬r)
P (a, b, c) ⇒ P (a, b, c)
| {z }
axiom
Sample exams
Exam rules
1. You can use your own copies of compendium ex-
tracted from lectures as well as an English-Swedish
dictionary.
187
LECTURE 9. SAMPLE EXAMS 188
Note: exercises for the first two exams are solved while
for the third one are intentionally left unsolved.
LECTURE 9. SAMPLE EXAMS 189
9.1 Solution
1(a)
(→ r) ∅ ⇒ p ∧ (¬q ∨ r) → ¬(¬p ∧ q) ∨ r
(∨r) p, ¬q ∨ r ⇒ ¬(¬p ∧ q) ∨ r
(¬r) p, ¬q ∨ r ⇒ ¬(¬p ∧ q), r
(∧l) p, ¬q ∨ r, ¬p ∧ q ⇒ r
(¬l) p, ¬q ∨ r, ¬p, q ⇒ r
p, ¬q ∨ r, q ⇒ r, p
| {z }
axiom
LECTURE 9. SAMPLE EXAMS 191
1(b)
We first negate formula (9.1):
h i
¬ p ∧ (¬q ∨ r) → ¬(¬p ∧ q) ∨ r ↔
p ∧ (¬q ∨ r) ∧ ¬ ¬(¬p ∧ q) ∨ r ↔
p ∧ (¬q ∨ r) ∧ ¬¬(¬p ∧ q) ∧ ¬r ↔
p ∧ (¬q ∨ r) ∧ ¬p ∧ q ∧ ¬r. (9.3)
1. p
2. ¬q ∨ r
3. ¬p
4. q
5. ¬r
Proof by resolution:
6. ¬q (res) : 5, 2
7. ∅ (res) : 6, 4
LECTURE 9. SAMPLE EXAMS 192
2(a)
We construct a tableau for the negated formula (9.2):
¬ ∃x∀y∀z R(x, y, z)∧S(x) ∧ T (y) →∃x R(x, a, b)∧T (a)
↓ (¬ →)
∃x∀y∀z R(x, y, z)∧S(x) ∧ T (y) , ¬∃x R(x, a, b)∧T (a)
↓ (∃x with x = c)
∀y∀z R(c, y, z) ∧ S(c) ∧ T (y) , ¬∃x R(x, a, b)∧T (a)
↓ (¬∃x with x = c)
∀y∀z R(c, y, z) ∧ S(c) ∧ T (y) , ¬ R(c, a, b) ∧ T (a)
↓ (∀y with y = a)
∀z R(c, a, z) ∧ S(c) ∧ T (a) , ¬ R(c, a, b) ∧ T (a)
↓ (∀z with z = b)
R(c, a, b) ∧ S(c) ∧ T (a), ¬ R(c, a, b) ∧ T (a)
↓ (∧)
R(c, a, b), S(c) ∧ T (a), ¬ R(c, a, b) ∧ T (a)
↓ (∧)
R(c, a, b), S(c), T (a), ¬ R(c, a, b) ∧ T (a)
. & (¬∧)
R(c, a, b), S(c), T (a),¬R(c, a, b) R(c, a, b), S(c), T (a),¬T (a)
| {z } | {z }
closed closed
2(b)
We first negate the formula:
h i
¬ ∃x∀y∀z R(x, y, z)∧S(x)∧T (y) → ∃x R(x, a, b)∧T (a) ↔
∃x∀y∀z R(x, y, z)∧S(x)∧T (y) ∧¬∃x R(x, a, b)∧T (a) ↔
∃x∀y∀z R(x, y, z)∧S(x)∧T (y) ∧∀x¬ R(x, a, b)∧T (a) ↔
∃x∀y∀z R(x, y, z)∧S(x)∧T (y) ∧∀x ¬R(x, a, b)∨¬T (a) .
1. R(c, y1 , z1 )
2. S(c)
3. T (y3 )
4. ¬R(x4 , a, b) ∨ ¬T (a)
A proof by resolution:
9.2 Solution
1
A possible translation:
small ∨ medium
red ∨ green ∨ blue
small → (blue ∨ red)
(9.4)
medium → (green ∨ blue)
shipment → red
¬shipment → (¬blue ∧ ¬green).
2
Observe that for shipment red boxes are chosen. For
non-shipment neither blue nor green boxes are chosen, so
only red boxes remain. Therefore no matter whether for
shipment or not, red boxes are chosen.
We have only small or medium boxes. The chosen boxes
are red, which excludes medium boxes, (if a box is red
then it is neither blue nor green). So one can chose only
boxes being both small and red.
LECTURE 9. SAMPLE EXAMS 196
3
We use resolution. We first show that the set of formulas
(9.4) implies red. We first transform (9.4) into a set of
clauses:
1. small ∨ medium
2. red ∨ green ∨ blue
3. ¬small ∨ blue ∨ red
4. ¬medium ∨ green ∨ blue (9.5)
5. ¬shipment ∨ red
6. shipment ∨ ¬blue
7. shipment ∨ ¬green.
Now we negate formula:
[1. ∧ 2. ∧ 3. ∧ 4. ∧ 5. ∧ 6. ∧ 7.] → red
and obtain:
[1. ∧ 2. ∧ 3. ∧ 4. ∧ 5. ∧ 6. ∧ 7.] ∧ ¬red.
Therefore, we consider clauses (1) – (7) together with
8. ¬red
A possible proof by resolution:
9. ¬shipment – (res): 5, 8
10. ¬blue – (res): 6, 9
11. ¬green – (res): 7, 9
12. green ∨ blue – (res): 2, 8
13. green – (res): 10, 12
14. ∅ – (res): 11, 13.
LECTURE 9. SAMPLE EXAMS 197
red → ¬green
red → ¬blue
green → ¬blue
green → ¬red
blue → ¬green
blue → ¬red.
9.3 Solution
1
2
The transitivity of R is expressed by:
∀x∀y∀z[(R(x, y) ∧ R(y, z)) → R(x, z)].
3
We have to show that the conjunction of formulas:
∀x∀y∀z[(R(x, y) ∧ R(x, z)) → R(y, z)]
∀x∀y[R(x, y) → F (x, y)]
∀x[F (x, x)]
∀x∀y∀z[(R(x,
h y) ∧ R(y, z)) → R(x, z)]
i
∀x∀y R(x, y) ∨ ∃z[R(x, z) ∧ R(z, y)]
A proof by resolution:
9.4 Solution
1
The database contains relations:
Example:
2
The relation of road intersection is symmetric:
3
Another integrity constraint concerning the relation of
road intersection:
∀x[¬intersects(x, x)].
4(a)
Select all streets longer than 700m and wider than 3m,
intersecting the street named “Kungsgatan” (recall that
‘ ’ is an anonymous “don’t care” variable):
4(b)
Select streets accessible by car from a given street, assum-
ing that it is impossible to drive through closed streets.
We first define:
accessible(Id1, Id2) :− street(Id1, , , , C1),
street(Id2, , , , C2),
C1 6= T rue, C2 6= T rue,
intersects(Id1, Id2).
accessible(Id1, Id2) :− street(Id1, , , , C1),
street(Id2, , , , C2),
C1 6= T rue, C2 6= T rue,
intersects(Id1, Id3),
accessible(Id3, Id2).
9.5 Solution
1(a)
We construct a tableau for the negated formula (9.7):
¬ (¬p ∨ ¬q) ∧ (p ∨ ¬q) ∧ r → ¬q ∧ r
↓ (¬ →)
(¬p ∨ ¬q) ∧ (p ∨ ¬q) ∧ r, ¬ ¬q ∧ r
↓ (∧)
(¬p ∨ ¬q), (p ∨ ¬q) ∧ r, ¬ ¬q ∧ r
↓ (∧)
(¬p ∨ ¬q), (p ∨ ¬q), r, ¬ ¬q ∧ r
. & (¬∧)
(¬p ∨ ¬q), (p ∨ ¬q), r, ¬¬q (¬p ∨ ¬q), (p ∨ ¬q), r, ¬r
↓ (¬¬)
| {z }
closed
(¬p ∨ ¬q), (p ∨ ¬q), r, q
↓ & (∨)
¬p, (p ∨ ¬q), r, q ¬q, (p ∨ ¬q), r, q
. & (∨)
| {z }
closed
¬p, p, r, q ¬p, ¬q, r, q
| {z } | {z }
closed closed
1(b)
We first negate formula (9.7):
¬{ (¬p ∨ ¬q) ∧ (p ∨ ¬q) ∧ r → ¬q ∧ r } ↔
(¬p ∨ ¬q) ∧ (p ∨ ¬q) ∧ r ∧ ¬ ¬q ∧ r ↔
(¬p ∨ ¬q) ∧ (p ∨ ¬q) ∧ r ∧ (q ∨ ¬r). (9.9)
1. ¬p ∨ ¬q
2. p ∨ ¬q
3. r
4. q ∨ ¬r.
5. q – (res): 3, 4
6. p – (res): 2, 5
7. ¬p – (res): 1, 5
8. ∅ – (res): 6, 7.
LECTURE 9. SAMPLE EXAMS 210
2(a)
∅ ⇒ ∀x P (x, x, x) ∧ ¬∃x∃y∃z P (x,y, z) ∧ ¬P(z, x, a)
(→ r) → ∃z P (a, z, a)
∀x P (x, x, x) ∧ ¬∃x∃y∃z P (x, y, z) ∧ ¬P (z, x, a) ⇒
(∧l) ∃z P (a, z, a)
∀x P (x, x, x) , ¬∃x∃y∃z P (x,y, z) ∧ ¬P(z, x, a) ⇒
(¬l) ∃z P (a, z, a)
∀x
P (x, x, ⇒
x)
(∀x l) ∃z P (a, z, a) , ∃x∃y∃z P (x, y, z) ∧ ¬P (z, x, a)
P (a, a, a) ⇒
(∃z r) ∃z P (a, z, a) , ∃x∃y∃z P (x, y, z) ∧ ¬P (z, x, a)
P (a, a, a) ⇒ P (a, a, a), ∃x∃y∃z P (x, y, z) ∧ ¬P (z, x, a)
| {z }
axiom
LECTURE 9. SAMPLE EXAMS 211
2(b)
We first negate the formula:
¬{∀x P (x, x, x) ∧¬∃x∃y∃z P (x, y, z)∧¬P (z, x, a) →
∃z P (a, z, a) } ↔
∀x P (x, x, x) ∧ ¬∃x∃y∃z P (x, y, z)∧ ¬P (z, x, a) ∧
¬∃z P (a, z, a) ↔
∀x P (x, x, x) ∧ ∀x∀y∀z ¬P (x, y, z)
∨ P (z, x, a)
∧
∀z ¬P (a, z, a) .
1. P (x1 , x1 , x1 )
2. ¬P (x2 , y2 , z2 ) ∨ P (z2 , x2 , a)
3. ¬P (a, z3 , a)
A proof by resolution:
4. ∅ – (res): 1, 3 with x1 = z3 = a.
LECTURE 9. SAMPLE EXAMS 212
9.6 Solution
1
A possible translation:
2
The chosen road should be comfortable. Therefore it can-
not be medium since medium roads are not comfortable.
The chosen road cannot be short since short roads are
crowded and crowded roads are not comfortable.
Therefore the only road that can be chosen if the long
one.
3
To prove our hypothesis, we also need the translation of
assumptions provided in point 2 of Exercise:
f ast → ¬crowded
(9.11)
crowded → ¬comf ortable
LECTURE 9. SAMPLE EXAMS 214
(a) ∀x∀y∀z[(R(x,
y) ∧ R(x, z)) → R(y, z)]
(b) ∀x∀y R(x, y) → ∃u[R(u, x) ∧ R(u, y)]
(c) ∀x∀y[R(x, y) → R(y, x)].
9.7 Solution
1
To check whether (c) holds assume that for arbitrarily
chosen elements s and t we have that R(s, t) holds. To
prove (c), we have to show that given assumptions (a)
and (b), R(t, s) holds, too.
2
To apply resolution we negate the implication:
((a)∧ (b))→ (c):
¬{∀x∀y∀z[(R(x,
y) ∧ R(x, z)) → R(y, z)]∧
∀x∀y R(x, y) → ∃u[R(u, x) ∧ R(u, y)] →
∀x∀y[R(x, y) → R(y, x)]} ↔
∀x∀y∀z[(R(x,
y) ∧ R(x, z)) → R(y, z)]∧
∀x∀y R(x, y) → ∃u[R(u, x) ∧ R(u, y)] ∧
¬∀x∀y[R(x, y) → R(y, x)] ↔
∀x∀y∀z[(R(x,
y) ∧ R(x, z)) → R(y, z)]∧
∀x∀y R(x, y) → ∃u[R(u, x) ∧ R(u, y)] ∧
∃x∃y[R(x, y) ∧ ¬R(y, x)].
A proof by resolution:
p p1 p2 ... pk−1 pk q.
9.8 Solution
1
The database contains relations:
• ref ers to(id1, id2), where id1, id2 are paper iden-
tifiers.
Example:
2
The relation of road intersection is irreflexive:
3
Relation is transitive:
∀x∀y∀z[ x y ∧ y z → x z].
4(a)
Select all pairs p1 , p2 of papers both (co-)authored by
‘J.Smith’ such that p1 p2 (recall that ‘ ’ is an anony-
mous “don’t care” variable):
4(b)
Select all pairs p1 , p2 of papers both (co-)authored by
‘J.Smith’ such that p1 p2 .
We need to define the relation p1 p2 (we give it the
name indirectly ref ):