Ch8 LogicalRepresentationAndReasoning
Ch8 LogicalRepresentationAndReasoning
Ch8 LogicalRepresentationAndReasoning
Resolution
Boolean Logic
Conjunctive normal form
Resolution
Conjunctive Normal Form
A literal is a variable or a negated variable.
A clause is either a single literal or the disjunction of two or
more literals.
P, P P, and P Q R S are clauses.
(R S ) and P Q are not clauses.
P (R Q).
Suppose we know:
winter summer
winter
summer
summer
nil
winter summer
winter cold
summer cold
Resolution
To prove ST from A:
C1 = R1 R2 Rj Q
C2 = S1 S2 Sk Q.
R1 R2 Rj S1 S2 Sk
Resolution Generating nil
Consider:
Q Q
nil
Add:
R R
Resolution An Example
P P Q R R
P Q R
S Q
T Q P Q P
T
R
T Q Q
T T
nil
Resolution Only Select One Pair to Resolve
PQ (1)
P Q R (2)
Prove R:
P Q R R
P Q PQ
? nil
(7) People only try to assassinate rulers they are not loyal to.
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) ruler(Caesar) tryassassinate(Marcus, Caesar)
(Marcus/x)
man(Marcus)
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 t1 t2 mortal(x) born(x, t1) gt(t2-t1, 150) dead(x,t2)
(8) now = 2007
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 = 2007
(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
alive(Marcus, now)
(9a) (Marcus/x) (now/t)
dead(Marcus, now)
(10)(Marcus/x)(now/t2) (7) (Marcus/x)(now/t2)
T 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)
Prenex Normal Form
A sentence in first-order logic is in prenex normal form iff it
is of the form:
becomes:
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) Roman(S1)
Distributivity of and .
(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 in FOL
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 FOL, what should we do about:
x,y (hate(x, y))
hate(Marcus, Caesar)
Example:
g(x) g(g(x))
g(g(x)) g(g(g(x)))
x and f(a) unify and yield the substitution f(a)/x. Applying it:
f(f(a)), f(a)
a, a
Without the occur check, f(f(a)) and a will unify, yielding the
substitution f(f(a))/a. To apply it, we must replace all as in the
remaining terms. But that process never terminates.
Most General Unifiers (MGUs)
Suppose we are trying to prove x,y (A(x, y) B(x, y))
Using the fact z (A(John, z))
Unifying A(x, y) with A(John, z) yields John/x, z/y. Applying it:
z (B(John, z))
But we could also have matched with the substitution John/x,
John/y, and been left trying to prove B(John, John), which
would be harder.
The algorithm we have presented always returns the most
general unifier. The MGU is unique up to variable name
substitution.
Unification Examples
Inputs Result Substitution
Add: Mortal(Marcus)
Marcus/x
Man(Marcus) Man(Marcus)
nil
FOL Resolution the Algorithm
resolve-FOL(A, ST) =
Construct L, the list of clauses from A.
Rename all variables in ST so that they do not conflict with any variables in L.
Negate ST, convert the result to clause form, and add the resulting clauses to L.
Until either nil is generated or no progress is being made do:
Choose from L two (parent) clauses that contain a pair CL of complementary
literals.
Resolve the parent clauses together to produce a resolvent:
Initially, let the resolvent be the disjunction of all of the literals in both parent
clauses
except for the two literals in CL.
Apply to all of the literals in the resolvent the substitution that was
constructed when
the literals in CL were unified.
Rename all of the variables in the resolvent so that they do not conflict with
any of the
variables in L.
If the resolvent is not nil and is not already in L, add it to L.
If nil was generated, a contradiction has been found. Return success. ST must be true.
If nil was not generated and there was nothing left to do, return failure. ST may or may
not be true. But no proof of ST has been found.
Heuristics to Aid the Resolution Procedure
Only resolve pairs of clauses that contain complementary
literals.
P(x) Q(x)
True
P Q R T W
PQ R T
P Q
PQ
PQW
Subsumption in FOL
Clause A subsumes clause B iff B must be true in any
interpretation in which A is true. (A is more general than B.)
True
x (P(x))
P(Marcus)
x(P(x))
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))
Leonardo/x
Lived-In(Leonardo, Italy) Lived-In(Leonardo,y1) Climate(y1, moderate)
Italy/y1
Climate(Italy, moderate)
Using Resolution
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)
Leonardo/x
Lived-In(Leonardo, Italy) Lived-In(Leonardo,y1) Climate(y1, moderate)
Italy/y1
In(x, y) Climate(y, moderate)Climate(x, moderate) Climate(Italy, moderate)
Italy/x
In(Italy,Europe) In(Italy, y2) Climate(y2, moderate)
Europe/y2
Climate(Europe, moderate) Climate(Europe, moderate)
Answering Questions
A Question: Name a painter who lived in a moderate climate.
Leonardo/x
Painter(Leonardo) Lived-In(Leonardo,y1) Climate(y1, moderate)
Lived-In(Leonardo, Italy)
Italy/y1
Europe/y2
Climate(Europe, moderate) Painter(Leonardo) Climate(Europe, moderate)
Painter(Leonardo)
A Reminder About Standardizing Variables Apart
Prove father(Chris, Bill) given:
father(x, y) woman(x) (1)
{father(x, y) woman(x)}
mother(x, y) woman(x) (2)
{mother(x, y) woman(x)}
mother(Chris, Mary) (3)
Add: father(Chris, Bill)
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)
tryassassinate(M,C) tryassassinate(M,C)
nil
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