Sie sind auf Seite 1von 47

Logical Representations and

Resolution

An Example - Facts in English


(1) Marcus was a man.
(2) Marcus was a Pompeian.
(3) All Pompeians were Romans.
(4) Caesar was a ruler.
(5) All Romans were either loyal to Caesar or hated him.
(6) Everyone is loyal to someone.
(7) People only try to assassinate rulers they are not loyal to.
(8) Marcus tried to assassinate Caesar.

An Example - Facts in FOPC


(1) Marcus was a man.
man(Marcus)
(2) Marcus was a Pompeian.
Pompeian(Marcus)
(3) All Pompeians were Romans.
x Pompeian(x) Roman(x)
(4) Caesar was a ruler.
ruler(Caesar)
(5) All Romans were either loyal to Caesar or hated him.
x Roman(x) loyalto(x, Caesar) hate(x, Caesar)
(6) Everyone is loyal to someone.
x y loyalto(x, y)
(7) People only try to assassinate rulers they are not loyal to.
x y person(x) ruler(y) tryassassinate(x, y) loyalto(x, y)
(8) Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)

An Example -Question Answering


(1) Marcus was a man.
man(Marcus)
(2) Marcus was a Pompeian.
Pompeian(Marcus)
(3) All Pompeians were Romans.
x Pompeian(x) Roman(x)
(4) Caesar was a ruler.
ruler(Caesar)
(5) All Romans were either loyal to Caesar or hated him.
x Roman(x) loyalto(x, Caesar) hate(x, Caesar)
(6) Everyone is loyal to someone.
x y loyalto(x, y)
(7) People only try to assassinate rulers they are not loyal to.
x y person(x) ruler(y) tryassassinate(x, y) loyalto(x, y)
(8) Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)
Was Marcus loyal to Caesar?

Reasoning Backward
(1) man(Marcus)
(2) Pompeian(Marcus)
(3) x Pompeian(x) Roman(x)
(4) ruler(Caesar)
(5) x Roman(x) loyalto(x, Caesar) hate(x, Caesar)
(6) x y loyalto(x, y)
(7) x y person(x) ruler(y) tryassassinate(x, y) loyalto(x, y)
(8) tryassassinate(Marcus, Caesar)

loyalto(Marcus, Caesar)
(Marcus/x) (Caesar/y)
person(Marcus)

ruler(Caesar)

tryassassinate(Marcus, Caesar)

Reasoning Backward
(1) man(Marcus)
(2) Pompeian(Marcus)
(3) x Pompeian(x) Roman(x)
(4) ruler(Caesar)
(5) x Roman(x) loyalto(x, Caesar) hate(x, Caesar)
(6) x y loyalto(x, y)
(7) x y person(x) ruler(y) tryassassinate(x, y) loyalto(x, y)
(8) tryassassinate(Marcus, Caesar)
(9) x man(x) person(x)
loyalto(Marcus, Caesar)
(Marcus/x) (Caesar/y)
person(Marcus)
(Marcus/x)
Man(Marcus)

ruler(Caesar)

tryassassinate(Marcus, Caesar)

Functions and Predicates


(1) Marcus was a man.
man(Marcus)
(2) Marcus was a Pompeian.
Pompeian(Marcus)
(3) Marcus was born in 40 A.D.
born(Marcus, 40)
(4) All men are mortal.
x man(x) mortal(x)
(5, 6) AllPompeians died when the volcano erupted in 79 A.D.
erupted(volcano, 79) x Pompeian(x) died(x,79)
(7) No mortal lives longer than 150 years.
x t1 t2 mortal(x) born(x, t1) gt(t2-t1, 150) dead(x,t2)
(8) It is now 2004.
now = 2004
Is Marcus alive?

Functions and Predicates


(1) man(Marcus)
(2) Pompeian(Marcus)
(3) born(Marcus, 40)
(4) x man(x) mortal(x)
(5) erupted(volcano, 79)
(6) x Pompeian(x) died(x,79)
(7) x t2 t2 mortal(x) born(x, t1) gt(t2-t1, 150) dead(x,t2)
(8) now = 2004

alive(Marcus, now)

Functions and Predicates - Filling in the Blanks


(1) man(Marcus)
(2) Pompeian(Marcus)
(3) born(Marcus, 40)
(4) x man(x) mortal(x)
(5) erupted(volcano, 79)
(6) x Pompeian(x) died(x,79)
(7) x t2 t2 mortal(x) born(x, t1) gt(t2-t1, 150) dead(x,t2)
(8) now = 2004
(9a) x t alive(x, t) dead(x, t)
(9b) x t dead(x,t) alive(x, t)
(10) x t2 t2 died(x, t1) gt(t2, t1) dead(x, t2)

alive(Marcus, now)

Showing that Marcus is Not Alive

(10)(Marcus/x)(now/t2)
died(Marcus, t1)

alive(Marcus, now)
(9a) (Marcus/x) (now/t)
dead(Marcus, now)
(7) (Marcus/x)(now/t2)

gt(now, t1)

mortal(Marcus) born(Marcus, t1) gt(now-t1,150)

(5) (Marcus/x)
(4) (Marcus/x)
(79/t1)
Pompeian(Marcus) gt(now, 79)
man(Marcus)
(2)

subst
T

(3) (40/t1)

born(Marcus, 40) gt(now-40,150)

(1)

gt(2004, 79)
eval
T

subst

subst
T

gt(2004-40,150)
eval
T

A Harder One
Given:
x [Roman(x) know(x, Marcus)]
[hate(x, Caesar) (y (z hate(y, z)) thinkcrazy(x, y))]
Roman(Isaac)
hate(Isaac, Caesar)
hate(Paulus, Marcus)
thinkcrazy(Isaac, Paulus)
Prove:
know(Isaac, Marcus)

Clause Form Simplifies the Process


The basic idea: Replace assertions of arbitrary form by
assertions written in a single normal form. We will use clause
form.
A clause is a formula in conjunctive normal with no instances
of .
x [Roman(x) know(x, Marcus)]
[hate(x, Caesar) (y (z hate(y, z)) thinkcrazy(x, y))]
Roman(x) know(x, Marcus) hate(x, Caesar) hate(y, z)
thinkcrazy(x, z)

Conversion to Clause Form - Step 1


1. Eliminate , using the fact that

a b is equivalent to
a b

x [Roman(x) know(x, Marcus)]


[hate(x, Caesar) (y (z hate(y, z)) thinkcrazy(x, y))]
x [Roman(x) know(x, Marcus)]
[hate(x, Caesar) (y (z hate(y, z)) thinkcrazy(x, y))]

Conversion to Clause Form - Step 2


2. Reduce the scope of each to a single term, using:
(p) = p
deMorgans laws
x P(x) x P(x)
x P(x) x P(x)
x [Roman(x) know(x, Marcus)]
[hate(x, Caesar) (y (z hate(y, z)) thinkcrazy(x, y))]
x [ Roman(x) know(x, Marcus)]
[hate(x, Caesar) (y z hate(y, z) thinkcrazy(x, y))]

Conversion to Clause Form - Step 3


3. Standardize variables so that each quantifier binds a unique
variable.

x P(x) x Q(x)
x P(x) y Q(y)

Conversion to Clause Form - Step 4


4. Move all quantifiers to the left without changing their relative
order.

x [ Roman(x) know(x, Marcus)]


[hate(x, Caesar) (y z hate(y, z) thinkcrazy(x, y))]
x y z [ Roman(x) know(x, Marcus)]
[hate(x, Caesar) ( hate(y, z) thinkcrazy(x, y))]

At this point, we have prenex normal form.

Conversion to Clause Form - Step 5


5. Eliminate existential quantifiers through the use of Skolem
functions and constants.
x Roman(x)

Roman(S1)

x z father-of(x, z)

x father-of(x, S2(x))

Conversion to Clause Form - Step 6


6. Drop the prefix since all remaining quantifiers are universal.

x y z [ Roman(x) know(x, Marcus)]


[hate(x, Caesar) ( hate(y, z) thinkcrazy(x, y))]
[ Roman(x) know(x, Marcus)]
[hate(x, Caesar) ( hate(y, z) thinkcrazy(x, y))]

Conversion to Clause Form - Step 7


7. Convert the matrix into a conjunction of disjuncts by using:
Associative properties of and .
[ Roman(x) know(x, Marcus)]
[hate(x, Caesar) ( hate(y, z) thinkcrazy(x, y))]
Roman(x) know(x, Marcus)
hate(x, Caesar) ( hate(y, z) thinkcrazy(x, y))

Distributivity of and .
(P(x) Q(x)) T(x)
(P(x) T(x)) (Q(x)) T(x))

Conversion to Clause Form - Step 8


8. Create a separate clause for each conjunct.
(P(x) T(x)) (Q(x)) T(x))
(P(x) T(x))
(Q(x)) T(x))

Conversion to Clause Form - Step 9


9. Standardize apart the variables.
(P(x) T(x))
(Q(x)) T(x))
(P(x) T(x))
(Q(y)) T(y))

Resolution
Suppose we know:
winter summer
winter
summer
summer
nil
winter summer
winter cold
summer cold

Resolution - Proof by Contradiction


To prove P, assert P. Resolve with the KB. If a contradition
results, P must be false. So P must be true.

Propositional Resolution
To prove that P follows from the assertions in some KB:
1. Convert all the propositions of the KB to clause form.
2. Negate P and convert it to clause form. Add it to the set of clauses
obtained in step 1.
3. Repeat until either a contradiction is found or no progress can be
made:
1. Select two clauses. Call them the parent clauses.
2. Resolve them together. The resulting clause, called the
resolvent, will be the disjunction of all the literals of both of the
parent clauses with the following exception: If there are any
pairs of literals L and L such that one of the parent clauses
contains L and the other contains L, then select one such pair
and eliminate both L and L from the resolvent.
3. If the resolvent is the empty clause, then a contradiction has
been found. If it is not, then add it to the set of clauses
available to the procedure.

Propositional Resolution - An Example


P
(P Q) R
(S T) Q

P
P Q R
S Q
T Q
T

(1)
(2)
(3)
(4)
(5)

Prove R:
P Q R

R
P Q

T Q

P
Q

T
nil

Propositional Resolution Only Select One


Pair to Resolve
PQ
P Q R

(1)
(2)

Prove R:
P Q R

R
P Q

PQ
nil

But is R entailed by the two facts we have been given?

Resolution in FOPC
To find a contradiction, we must show that the KB, augmented with
P, is unsatisfiable.
Herbrands theorem tells us:
1. To show that a set of clauses S is unsatisfiable, it is necessary to
consider only interpretations over a particular set called the
Herbrand universe of S, which is the set of all ground terms
constructable from the following:
1. The function symbols in S, if any.
2. The constant symbols in S, if any. If none, then the constant
symbol A.
2. A set of clauses S is unsatisfiable iff a finite subset of ground
instances (in which all bound variables have had a value
substituted for them) of S is unsatisfiable.
Resolution is an algorithm that finds contradictions without
enumerating most of the Herbrand universe.

Unification
In propositional logic, it is easy to identify complementary
literals such as P and P.
But in FOPC, what should we do about:
hate(x, y)
hate(Marcus, Caesar)
Or:

hate(Marcus, Caesar)
hate(Paulus, Caesar)

Or:

P(x, x)
P(Marcus, Caesar)

The FOPC Resolution Algorithm


To prove that P follows from the assertions in some KB:
1. Convert all the propositions of the KB to clause form.
2. Negate P and convert it to clause form. Add it to the set of clauses
obtained in step 1.
3. Repeat until either a contradiction is found, no progress can be
made, or a predetermined amount of effort has been expended:
1. Select two clauses. Call them the parent clauses.
2. Resolve them together. The resulting clause, called the
resolvent, will be the disjunction of all the literals of both of the
parent clauses with appropriate substitutions performed, and
with the following exception: If there are any pairs of
complementary literals that can be unified, then select one such
pair, L and L, and eliminate both from the resolvent.
3. If the resolvent is the empty clause, then a contradiction has
been found. If it is not, then add it to the set of clauses
available to the procedure.

Heuristics to Aid the Resolution Procedure


Only resolve pairs of clauses that contain complementary
literals.
P(x) Q(x)
Eliminate certain clauses as soon as they are generated:
Tautologies
Clauses that are subsumed by other clauses.
Set of support strategy: whenever possible resolve with a
clause that is part of the statement we are trying to prove.
Unit preference strategy: whenever possible, resolve with
clauses that have a single literal.

Using Resolution
Painter(Leonardo)
Composer(Palistrina)
Country(Italy)
Lived-In(Leonardo, Italy)
In(Italy,Europe)
Climate(Europe, moderate)
Painter(Rubens)
Lived-In(Rubens, Europe)
x,y In(x, y) Climate(y, moderate) Climate(x, moderate)
In(x, y) Climate(y, moderate) Climate(x, moderate)
?Painter(x) Lived-In(x,y) Climate(y, moderate)

Resolution
?Painter(x) Lived-In(x,y) Climate(y, moderate)
1. Painter(Leonardo)
2. Composer(Palistrina)
3. Country(Italy)
4. Lived-In(Leonardo, Italy)
5. In(Italy,Europe)
6. Climate(Europe, moderate)
7. Painter(Rubens)
8. Lived-In(Rubens, Europe)
9. Painter(Sargent)
10. In(x, y)
Climate(y, moderate)
Climate(x, moderate)

( x,y Painter(x) Lived-In(x,y)


Climate(y, moderate))
Painter(x) Lived-In(x,y)
Climate(y, moderate)
Resolving with 1 (Leonardo/x):
Lived-In(Leonardo,y)
Climate(y, moderate)
Resolving with 4 (Italy/y):
Climate(Italy, moderate)
Now what?

Resolution
?Painter(x) Lived-In(x,y) Climate(y, moderate)
1. Painter(Leonardo)
2. Composer(Palistrina)
3. Country(Italy)
4. Lived-In(Leonardo, Italy)
5. In(Italy,Europe)
6. Climate(Europe, moderate)
7. Painter(Rubens)
8. Lived-In(Rubens, Europe)
9. Painter(Sargent)
10. In(x, y)
Climate(y, moderate)
Climate(x, moderate)

Climate(Italy, moderate)
Resolving 5 and 10 (Italy/x, Europe/y):
Climate(Europe, moderate)
Climate(Italy, moderate)
Resolving with 6:
Climate(Italy, moderate)
Resolving with *:
nil

So we have learned that the initial substitution of Leonardo/x in Painter(x) found


one value that is provably true. We can also succeed with the substitution
Rubens/x.

A Reminder About Standardizing Variables


Apart
Consider:
1. father(x, y) woman(x)
{father(x, y) woman(x)}
2. mother(x, y) woman(x)
{mother(x, y) woman(x)}
3. mother(Chris, Mary)
4. father(Chris, Bill) {introduced in an attempt to prove father(Chris,
Bill) }
1
2
* father(x, y) mother(x, y)
Chris/x, Mary/y
father(Chris, Mary)

Back to Marcus
(1) man(Marcus)
(2) Pompeian(Marcus)
(3) x Pompeian(x) Roman(x)
(4) ruler(Caesar)
(5) x Roman(x) loyalto(x, Caesar) hate(x, Caesar)
(6) x y loyalto(x, y)
(7) x y man(x) ruler(y) tryassassinate(x, y) loyalto(x, y)
(8) tryassassinate(Marcus, Caesar)
(1) man(Marcus)
(2) Pompeian(Marcus)
(3) Pompeian(x1) Roman(x1)
(4) ruler(Caesar)
(5) Roman(x2) loyalto(x2, Caesar) hate(x2, Caesar)
(6) loyalto(x3, S1(x3))
(7) man(x4) ruler(y1) tryassassinate(x4, y1) loyalto(x4, y1)
(8) tryassassinate(Marcus, Caesar)

Proving Marcus Not Loyal to Caesar


loyalto(M, C)

man(x4) ruler(y1) tryassassinate(x4, y1) loyalto(x4, y1)


(M/x4)(C/y1)

man(M) ruler(C) tryassassinate(M,C)

ruler(C) tryassassinate(M,C)

tryassassinate(M,C)
nil

ruler(C)

tryassassinate(M,C)

man(M)

Does Isaac Know Marcus?


Given:
1. x [Roman(x) know(x, Marcus)]
[hate(x, Caesar) (y (z hate(y, z)) thinkcrazy(x, y))]
Roman(x) know(x, Marcus) hate(x, Caesar)
hate(y, z) thinkcrazy(x, y)
2. Roman(Isaac)
3. hate(Isaac, Caesar)
4. hate(Paulus, Marcus)
5. thinkcrazy(Isaac, Paulus)
Prove:
know(Isaac, Marcus)

* know(Isaac, Marcus)

Does Marcus Hate Caesar?


Try to prove hate(M, C):
Hate(M, C)

Try to Prove that Marcus Does Not Hate Caesar


Try to prove hate(M, C):
Hate(M, C)

Try (Again) to Prove that Marcus Does Not Hate


Caesar
(1) man(Marcus)
(2) Pompeian(Marcus)
(3) Pompeian(x1) Roman(x1)
(4) ruler(Caesar)
(5) Roman(x2) loyalto(x2, Caesar) hate(x2, Caesar)
(6) loyalto(x3, S1(x3))
(7) man(x4) ruler(y1) tryassassinate(x4, y1) loyalto(x4, y1)
(8) tryassassinate(Marcus, Caesar)
(9) persecute(x5, y2) hate(y2, x5)
persecute(x, y) hate(y, x)
(10) hate(x6, y3) persecute(y3, x6)
hate(x, y) persecute(y, x)

Now try to prove hate(M, C):


Hate(M, C)

A Winnie Example

"And if anyone knows anything about anything," said Bear to


himself,
"It's Owl who knows something about something," he said,
"Or my name
is not Winnie-the-Pooh," he said. "Which it is," he added.
"So there you are."

When Does Resolution Work?


Resolution is sound and refutation-complete.
If there is a contradiction, resolution will eventually find it if
resolvents are chosen systematically.
But:
It may take exponential time.
Satisfiability is semi-decidable: if a set of clauses is satisfiable,
resolution will never find a conflict and it may not notice that it
is failing to do so.

Satisfiability is Semi Decidable


Suppose we want to know whether P(x) is true. There are
three possibilities:
(1) P(x) is entailed by KB and thus P(x) KB is
unsatisfiable.
(2) P(x) is entailed by KB and thus P(x) KB is
unsatisfiable.
(3)

Horn Clauses
A Horn Clause is a clause in which at most one literal is
positive.
A(x) B(x) C(x)

becomes

A(x) B(x) C(x)

a Horn clause

Deciding entailment with Horn clauses can be done in time


that is linear in the size of the KB by using either backward or
forward chaining.

Question Answering
When did Marcus die?
died(Marcus, ??)
Marcus must have died sometime, so we could try to prove:
x died(Marcus, x) by adding to the KB:
x died(Marcus, x). Converting to clause form:
x died(Marcus, x)

When Did Marcus Die?


died(Marcus, x)

Pompeian(x1) died(x1,79)
(Marcus/x1)(79/x)
Pompeian(Marcus)
nil

But how do we retrieve the answer 79?

Pompeian(Marcus)

When Did Marcus Die?


died(Marcus, x) died(Marcus, x)

Pompeian(x1) died(x1,79)
(Marcus/x1)(79/x)

Pompeian(Marcus) died(Marcus, 79)

Pompeian(Marcus)

died(Marcus, 79)

The underlined literal will get carried along and collect all the
substitutions. We stop when we generate a clause that contains
only it.

Das könnte Ihnen auch gefallen