0% found this document useful (0 votes)
14 views

Predicate Logic Exercise

Predicate logic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Predicate Logic Exercise

Predicate logic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

CSC 380/480 – Foundations of Artificial Intelligence

Winter 2007
Assignment 3 Solutions to Selected Problems

1. Suppose we have a knowledge base KB containing the following 4 sentences:


KB1: (A \/ B) /\ C => E
KB2 D /\ F => A
KB3: E \/ D
KB4: B /\ C
KB5: F
Want to derive sentence A (i.e., show that A is entailed by the knowledge base KB).

Solution:

Using forward chaining and rules of inference:

1. C KB4 and AND-Elimination Note that this is not the


2. B (again) KB4 and AND-Elimination only possible derivation.
3. A∨B Step 2, using OR-Introduction (introducing A) There are rules that can
4. (A ∨ B) ∧ C Step 3, Step 1, and AND-Introduction be used at various steps
5. E Step 4, KB1, and Modus Ponens
eventually leading to A.
6. D Step 5, KB3, and Resolution
7. D∧F Step 6, KB5, and AND-Introduction
8. A Step 7, KB2, and Modus Ponens

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

Details of converting KB1 to clause form:

(A \/ B) /\ C => E ¬ [ (A \/ B) /\ C ] \/ E ¬(A \/ B) \/ ¬C \/ E (¬A /\ ¬B) \/ (¬C \/ E)

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:

¬A resolve with KB2: ¬D \/ ¬F \/ A

¬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.

Again, there are other possible derivations here. Also, some


choices of clauses selected in intermediate steps, may not
lead to success. I such cases, other possible clauses must
be tried until no other options are available.

2
2. Translation to First-Order Predicate Logic:

Solution:

We will use the following predicates for this problem. Others used are clear from context:

• takes(x, c, t) student x takes course c during term s


• passes(x, c, t) student x passes course c during term s
• buys(x, y, z) x buys y from z
• fools(x, y) x cooks for y

(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:

(a) The knowledge base in first order logic:

∀x food(x) => likes(john, x)


food(apple)
food(chicken)
∀x ∀y [ eats(x, y) /\ ¬killed-by(x, y) => food(y) ] Note: This can also be written as:
eats(bill, peanuts) /\ alive(bill)
∀x ∀y [ killed-by(x, y) => ~alive(x) ] ∀x [ (∃y killed-by(x, y) ) => ~alive(x) ]
∀x eats(bill, x) => eats(sue, x) The translation into clause form will still
be the same as below.
(b) Translation to clausal form

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)

(c) Prove that john likes peanuts:

resolve with subgoal (resolvant)


________________________________________________________________________
¬likes(john, peanuts)
(1) ¬food(peanuts)
(4) ¬eats(x, peanuts) \/ killed-by(x, peanuts)
(5a) killed-by(bill, peanuts)
(6) ¬alive(bill)
(5b) ⌧ (empty clause)

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.

resolve with subgoal (resolvant)


________________________________________________________________________
¬food(x) \/ ¬eats(sue, x)
(7) ¬eats(bill, x) \/ ¬food(x)
(5a) ¬food(peanuts) (with substitution { x = peanuts }

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:

∀x (¬∃y eats(x, y) ) => dead(x) ∀x ¬ (¬∃y eats(x, y) ) \/ dead(x)


∀x ∃y eats(x, y) \/ dead(x)
∀x eats(x, sk1(x)) \/ dead(x)
eats(x, sk(x)) \/ dead(x)

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].

resolve with subgoal (resolvant)


________________________________________________________________________
¬eats(sue, z) \/ ¬food(z)
(8) ¬eats(bill,z) \/ ¬food(z)
(6a) ¬food(sk(bill)) \/ dead(bill) ( with z = sk(bill) )
(6c) ¬food(sk(bill)) \/ ¬alive(bill)
(6b) ¬food(sk(bill))
(4) ¬eats(x, sk(bill)) \/ killed-by(x, sk(bill))
(5) ¬eats(x, sk(bill)) \/ ¬alive(z)
(6b) ¬eats(bill, sk(bill))
(6a) dead(bill)
(6c) ¬alive(bill)
(6b) ⌧ (empty clause)

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.

The successful proof along the left OR branch is shown below:

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.

You might also like