Predicate Logic Exercise
Predicate Logic Exercise
Winter 2007
Assignment 3 Solutions to Selected Problems
Solution:
Using resolution-refutation procedure: First we convert the KB into clause form (note that KB1 and
KB4 each become two separate clauses):
KB1.1: ¬A \/ ¬C \/ E
KB1.2: ¬B \/ ¬C \/ E
KB2: ¬D \/ ¬F \/ A
KB3: E \/ D
KB4.1: B
KB4.2: C
KB5: F
Now: using distributivity, we get a conjunction of two clauses: (¬A \/ ¬C \/ E) /\ (¬B \/ ¬C \/ E). These
can then just be divided into two independent clauses KB1.1 and KB1.2, above.
1
To perform resolution-refutation we start with ¬A and applying resolution at each step, try to arrive at
the empty clause:
¬D \/ ¬ F KB3: E \/ D
¬F \/ ¬E KB5: F
¬E KB1.2: ¬B \/ ¬C \/ E
¬B \/ ¬C KB4.1: B
¬C KB4.2: C
⌧ (empty clause)
Since empty clause (contradiction) was reached by starting with ¬A, then we can conclude that A entails
from the knowledgebase KB.
2
2. Translation to First-Order Predicate Logic:
Solution:
We will use the following predicates for this problem. Others used are clear from context:
(a) Some students took history in Fall 04: ∃x [ student(x) /\ takes(x, hist, fall04) ] Note: this one can
be written as
(b) Not everyone who took sociology, passed it: existential if
negation is moved
¬∀x∀t [ ( student(x) /\ takes(x, soc, t) ) => passes(x, soc, t) ] inside.
(c) Every student who passes both history and sociology, takes anthropology:
∀x∀t [ ( student(x) /\ takes(x, hist, t) /\ takes(x, soc, t) ) => takes(x, anthro, t) ]
(d) Only one student failed (did not pass) both history and sociology:
Note: this one can be
∃x∃t [ student(x) /\ ¬ passes(x, soc, t) /\ ¬ passes(x, hist, t) ) /\ written in several other
∀y∀t ( ( student(y) /\ ¬passes(x, soc, t) /\ ¬passes(x, hist, t) ) => (y = x) ] ways.
(e) There is a person who cooks for all those who do not cook for themselves:
∃x [ person(x) /\ ∀y [ person(y) /\ ¬cooks(y, y) => cooks(x, y) ] ]
(g) There is a broker who sells stocks to people who do not own any stocks:
∃x [ broker(x) /\ ∀y∀s [ person(y) /\ stock(t) /\ ¬own(y, s) => ( ∃t stock(t) /\ sells(x, y, t) ) ] ]
(h) There is a barber who shaves all men in town who do not shave themselves: Note that here we need
∀x [ investor(x) /\ ∃y ( broker(y) /\ buys(x, goog, y) ) => smart(x) to distinguish between
some stock that is sold
(t) and all stocks (s) not
owned by y.
3
3. Resolution-Refutation Problem:
Solution:
1. ¬food(x) \/ likes(john, x)
2. food(apple)
3. food(chicken)
4. ¬eats(x, y) \/ killed-by(x, y) \/ food(y)
5a. eats(bill, peanuts)
5b. alive(bill)
6. ¬killed-by(x,y) \/ ¬alive(x)
7. ¬eats(bill, x) \/ eats(sue, x)
Since we arrived at the empty clause, the original goal likes(john, peanuts) is proved.
4
(d) What food does sue eat? ( i.e., ∃x food(x) /\ eats(sue, x)? ). Negating this goal results in:
¬ (∃x food(x) /\ eats(sue, x)). Conversion to clause form results in: ¬food(x) \/ ¬eats(sue, x) .
This will be the starting goal for resolution-refutation.
After this point the rest of the derivation becomes exactly the same as part (c) above
(after the 2nd resolution step):
(e) The new axioms, replacing eats(bill, peanuts) /\ alive(bill), are as follows:
∀x (¬∃y eats(x, y) ) => dead(x) (if people don't eat anything then they'll die)
∀x dead(x) => ¬alive(x)
alive(bill)
Translating the first statement above to clause form will be done as follows:
Note that the elimination of the existential quantifier (within the scope of ∀x) has resulted in the
creation of a Skolem function (of x), sk(x), representing a specific but unknown object.
Translating to everything into clausal form, the full revised knowledge base becomes:
1. ¬food(x) \/ likes(john, x)
2. food(apple)
3. food(chicken)
4. ¬eats(x, y) \/ killed-by(x, y) \/ food(y)
5. ¬killed-by(x, y) \/ ¬alive(x)
6a. eats(x, sk(x)) \/ dead(x) (where sk is a Skolem function)
6b. alive(bill)
6c. ¬dead(x) \/ ¬alive(x)
7. ¬killed-by(x,y) \/ ¬alive(x)
8. ¬eats(bill, x) \/ eats(sue, x)
5
Now, we use resolution to again (as in part d) ask what sue eats (this time we don't know that bill eats
peanuts):
What food does sue eat? ( i.e., ∃z food(z) /\ eats(sue, z)? ). Negating this goal results in:
¬ (∃z food(z) /\ eats(sue, z)). Conversion to clause form results in: ¬food(z) \/ ¬eats(sue, z) . [Note: this
time variable name z was used instead of x, just to distinguish different occurrence of variables in the
proof below].
6
3. Backward Chaining and AND/OR Graphs:
Solution:
The knowledge base and the query to be answered are depicted below:
In effect, the query is asking the system to provide answers (binding for the variable w) to the question:
"which blocks are above the block B?"
We show the solution in stages. The query above(w,B) can unify with the head of two rules in the KB (4,
and 5). These represent alternative (OR) branches in the proof tree. Success along either of these
alternatives will result in an answer for the query (a constructive proof). In the case of rule 5, we get an
AND branch. This means that success along this branch will require success along both subtrees
corresponding to the two conjuncts on the left-hand-side of rule 5.
7
The success along the right branch of the OR node (which itself is and AND branch) is shown below:
Note that the left subtree of the AND branch (with root on(w,z)) can unify with KB facts 1, 2, and 3, each
resulting in a successful proof of this node with its own bindings for variables w and z. Selecting any of
these successful branches will result in the corresponding bindings to propagate to the right subtree of the
AND node. In this case, selecting the branches corresponding to the substitutions {w=A,z=C} and
{w=D,z=B} will eventually result in failure in the right subtree of the AND node (not shown here). In the
above figure, we have only shown the right subtree given the selection of the substitution {w=E,z=D} in
the left subtree.