Sunteți pe pagina 1din 17

Example Problem

John likes all kinds of food.


Apples are food.
Chicken is food.
Anything anyone eats and isn’t
killed by is food.
Bill eats peanuts, and is still alive.
Sue eats everything that Bill eats.
Example Problem
John likes all kinds of ∀x food (x) ⇒ eats(John, x)
food
Apples are food. food(apples)
Chicken is food. food(chicken)
Anything anyone eats and ∀x,y eats(x,y) ∧¬killed(x) ⇒
isn’t killed by is food. food(y)
Bill eats peanuts, and is eats(Bill,Peanuts) ∧
still alive. ¬killed(Bill)
Sue eats everything that ∀x eats (Bill,x) ⇒ eats(Sue,x)
Bill eats.
Answer Questions (by
Proof)
Does John eat peanuts?
1) eats(Bill,Peanuts) ∧¬killed(Bill)
2) ∀x,y eats(x,y) ∧¬killed(x) ⇒ food(y)
SUBST({x/Bill,y/Peanuts}), universal elimination, and modus
ponens to derive food(peanuts)
3) ∀x food (x) ⇒ eats(John, x)
SUBST({x/Peanuts}) and use (2, universal elimination, and
modus ponens to derive eats(John,peanuts)

Derived Proof by Forward Chaining


The proof steps could have been longer – if we had tried other derivations
For example, many possibilities for substitution and universal elimination

Need search strategies to perform this task efficiently


Pictorial View: Forward
Chaining
eats(John, Peanuts)
eats(John, apples)
∀x food (x) ⇒ eats(John, x) eats(John, chicken)

food(Peanuts)
∀x,y eats(x,y) ∧¬killed(x) ⇒ food(y)

¬ killed(Bill) food(chicken)
food(apples) eats(Bill,Peanuts)
More Efficient Forward
Chaining
Checking all rules will take too much
time.

Check only rules that include a


conjunct that unifies a newly created
fact during the previous iteration.
 Incremental Forward Chaining
Forward Chaining
• Data Driven
• not directed at finding particular information –
can generate irrelevant conclusions
• Strategy
• match rules that contain recently added literals
• Forward chaining may not terminate
• Especially if desired conclusion is not entailed
(Incomplete)
Backward Chaining
Start at the goal, chain through inference
rules to find known facts that support the
proof.
 Uses Modus Ponens backwards
 Designed to answer questions posed to a

In reality,knowledge
the base
eats(John, y) Yes, y/peanuts
algorithm would
include all appropriatefood (y) Yes, y/peanuts
rules.
eats(x,y) ¬killed(x)
Yes, x/Bill, y/peanuts Yes, x/Bill
Backward Chaining
• Depth First recursive proof
• space is linear in size of proof.
• Incomplete
• infinite loops
• Can be inefficient
• repeated subgoals
FOL to CNF
Resolution requires that FOL
sentences be represented in
Conjunctive Normal Form (CNF)
 Everyone who loves all animals is loved
by someone.
 FOL: ∀x[∀y Animal ( y ) ⇒ Loves( x, y )] ⇒ [∃y Loves( y, x )]
 CNF:
[ Animal ( F ( x )) ∨ Loves(G ( x ), x )] ∧ [¬Loves( x, F ( x )) ∨ Loves(G ( x ), x )]
Resolution
Resolution
 a single inference rule
 provides a complete inference
algorithm when coupled with any
complete search algorithm.

P(x) ∨Q(x) , ¬ Q(x) ∨R(x)


P(x) ∨R(x)
Resolution
Implicative Form Conjunctive normal
form
∀x food (x) ⇒ eats(John, x) ¬ food (x) ∨eats(John, x)
food(apples) food(apples)
food(chicken) food(chicken)
∀x,y eats(x,y) ∧¬killed(x) ⇒ ¬ eats(x,y) ∨killed(x) ∨food(y)
food(y)
eats(Bill,Peanuts) ∧¬killed(Bill) eats(Bill,Peanuts)

¬killed(Bill)
∀x eats (Bill,x) ⇒ eats(Sue,x) ¬ eats (Bill,x) ∨eats(Sue,x)
Forward & Backward Chaining Resolution
Resolution Proof

¬ eats(x,y) ∨killed(x) ∨food(y) eats(Bill,Peanuts)

{x/Bill, y/peanuts}

killed(Bill) ∨food(peanuts) ¬killed(Bill)

¬ food (x) ∨eats(John, x) food(peanuts)


{x/peanuts}

eats(John, peanuts)  True


Resolution uses unification
Unification: takes two atomic
expressions p and q, and generates a
substitution that makes p and q look
the same.
UNIFY(p,q) = θ where SUBST(θ ,p) =
SUBST(θ ,q)
x,y – implicitly
p
knows(John, x) q
knows(John,Jane) {x / θ
Jane} universally quantified

knows(John, x) knows(y, Jack) {x / Jack, y / John}

knows(John, x) knows(y,mother(y)) {y / John, x / mother(John)}

knows(John, x) knows(x, Jack) fail P & Q cannot share x


Generalized Resolution
p1 ∨ .... p j ∨ .... pm
q1 ∨ .... qk ∨ .... qn
SUBST (θ , ( p1 ∨ .... p j −1 ∨ p j +1.... pm ∨ q1 ∨ .... qk −1 ∨ qk +1.... qn ))

Problem with Resolution: It is incomplete


Example: cannot prove p ∨¬ p from an empty KB

However, Resolution refutation, i.e.,


proof by contradiction has been proven to be complete
(KB ∧¬p ⇒ False) ⇔ (KB ⇒ p)
Resolution Refutation
If S is an unsatisfiable set of
clauses, then the application of a
finite number of resolution steps to
S will yield a contradiction.
Resolution
Implicative Form Conjunctive normal
form
∀x food (x) ⇒ eats(John, x) ¬ food (x) ∨eats(John, x)
food(apples) food(apples)
food(chicken) food(chicken)
∀x,y eats(x,y) ∧¬killed(x) ⇒ ¬ eats(x,y) ∨killed(x) ∨food(y)
food(y)
eats(Bill,Peanuts) ∧¬killed(Bill) eats(Bill,Peanuts)

¬killed(Bill)
∀x eats (Bill,x) ⇒ eats(Sue,x) ¬ eats (Bill,x) ∨eats(Sue,x)
Forward & Backward Chaining Resolution
Resolution refutation proof
Start with: ¬ eats(John, peanuts)

¬ food (x) ∨eats(John, x) ¬ eats(John,Peanuts)

{x/Peanuts}

¬ food(peanuts) ¬ eats(x,y) ∨killed(x) ∨food(y)

{y/Peanuts}

¬killed(Bill) ¬ eats(x,Peanuts) ∨killed(x)


{x/Bill}
Conclusion:¬ eats(John, peanuts)
eats(Bill, peanuts) ¬ eats(Bill,Peanuts) is false. Therefore,
eats(John, peanuts) must be True.
 False

S-ar putea să vă placă și