Inference in First-Order Logic (FOL)
Inference in First-Order Logic (FOL)
Inference in First-Order Logic (FOL)
Outline
• Reducing first-order inference to propositional
inference
• Unification
• Generalized Modus Ponens
• Forward chaining
• Backward chaining
• Resolution
Universal instantiation (UI)
• Every instantiation of a universally quantified sentence is entailed by it:
v α
Subst({v/g}, α)
v α
Subst({v/k}, α)
Idea: For n = 0 to ∞ do
create a propositional KB by instantiating with depth-$n$ terms
see if α is entailed by this KB
• E.g., from:
•
x King(x) Greedy(x) Evil(x)
King(John)
y Greedy(y)
Brother(Richard,John)
θ = {x/John,y/John} works
• Unify(α,β) = θ if αθ = βθ
p q θ
Knows(John,x) Knows(John,Jane)
Knows(John,x) Knows(y,OJ)
Knows(John,x) Knows(y,Mother(y))
Knows(John,x) Knows(x,OJ)
θ = {x/John,y/John} works
• Unify(α,β) = θ if αθ = βθ
p q θ
Knows(John,x) Knows(John,Jane) {x/Jane}}
Knows(John,x) Knows(y,OJ)
Knows(John,x) Knows(y,Mother(y))
Knows(John,x) Knows(x,OJ)
θ = {x/John,y/John} works
• Unify(α,β) = θ if αθ = βθ
p q θ
Knows(John,x) Knows(John,Jane) {x/Jane}}
Knows(John,x) Knows(y,OJ) {x/OJ,y/John}}
Knows(John,x) Knows(y,Mother(y))
Knows(John,x) Knows(x,OJ)
θ = {x/John,y/John} works
• Unify(α,β) = θ if αθ = βθ
• p q θ
Knows(John,x) Knows(John,Jane) {x/Jane}}
Knows(John,x) Knows(y,OJ) {x/OJ,y/John}}
Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)}}
Knows(John,x) Knows(x,OJ)
θ = {x/John,y/John} works
• Unify(α,β) = θ if αθ = βθ
p q θ
Knows(John,x) Knows(John,Jane) {x/Jane}}
Knows(John,x) Knows(y,OJ) {x/OJ,y/John}}
Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)}}
Knows(John,x) Knows(x,OJ) {fail}
Missile(x) Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America) Hostile(x)
West, who is American …
American(West)
The country Nono, an enemy of America …
Enemy(Nono,America)
Forward chaining algorithm
Forward chaining proof
Forward chaining proof
Forward chaining proof
Properties of forward chaining
• Sound and complete for first-order definite clauses
• query: append(A,B,[1,2]) ?
A=[1,2] B=[]
Resolution: brief summary
• Full first-order version: Generic Representation of Unification
(l1 ··· li-1 li+1 ··· lk m1 ··· mj-1 mj+1 ··· mn)θ
where Unify(li, mj) = θ.
• The two clauses are assumed to be standardized apart so that they share no
variables.
• For example,
Rich(x) Unhappy(x)
Rich(Ken)
Unhappy(Ken)
with θ = {x/Ken}
Example Problem 1
KB:
Everyone who loves all animals is loved by
someone.
Anyone who kills animals is loved by no-one.
Jack loves all animals.
Either Curiosity or Jack killed the cat, who is
named Tuna.
Query: Did Curiosity kill the cat?
Inference Procedure:
1.Express sentences in FOL.
2.Eliminate existential quantifiers.
3.Convert to CNF form and negated query.
Conversion to FOL
Conversion to CNF
• Everyone who loves all animals is loved by someone:
x [y Animal(y) Loves(x,y)] [y Loves(y,x)]
Missile(x) Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America) Hostile(x)
West, who is American …
American(West)
The country Nono, an enemy of America …
Enemy(Nono,America)
Resolution proof: definite clauses
Example Problem 2
• Consider the following axioms:
1. All hounds howl at night.
2. Anyone who has any cats will not have any
mice.
3. Light sleepers do not have anything which
howls at night.
4. John has either a cat or a hound.
• Prove that If John is a light sleeper, then John
does not have any mice.
FOL Conversion
1. ∀ x (HOUND(x) → HOWL(x))
2. ∀ x ∀ y (HAVE (x,y) ∧ CAT (y) → ¬ ∃ z
(HAVE(x,z) ∧ MOUSE (z)))
3. ∀ x (LS(x) → ¬ ∃ y (HAVE (x,y) ∧ HOWL(y)))
4. ∃ x (HAVE (John,x) ∧ (CAT(x) ∨
HOUND(x)))
5. LS(John) → ¬ ∃ z (HAVE(John,z) ∧
MOUSE(z))
1. ∀ x (HOUND(x) → HOWL(x))
¬ HOUND(x) ∨ HOWL(x)
2. ∀ x ∀ y (HAVE (x,y) ∧ CAT (y) → ¬ ∃ z (HAVE(x,z) ∧ MOUSE (z)))
∀ x ∀ y (HAVE (x,y) ∧ CAT (y) → ∀ z ¬ (HAVE(x,z) ∧ MOUSE (z)))
5. ¬ [LS(John) → ¬ ∃ z (HAVE(John,z) ∧
MOUSE(z))] (negated conclusion)
¬ [¬ LS (John) ∨ ¬ ∃ z (HAVE (John, z) ∧ MOUSE(z))]
LS(John) ∧ ∃ z (HAVE(John, z) ∧ MOUSE(z)))
LS(John) ∧ HAVE(John,b) ∧ MOUSE(b)
1. ¬ HOUND(x) ∨ HOWL(x)
2. ¬ HAVE(x,y) ∨ ¬ CAT(y) ∨ ¬ HAVE(x,z) ∨
¬ MOUSE(z)
3. ¬ LS(x) ∨ ¬ HAVE(x,y) ∨ ¬ HOWL(y)
4. (i) HAVE(John,a)
(ii) CAT(a) ∨ HOUND(a)
5. (i) LS(John)
(ii) HAVE(John,b)
(iii) MOUSE(b)
CAT(a) ∨
[1.,4.(b):] 6.
HOWL(a)
¬ HAVE(x,y) ∨ ¬
[2,5.(c):] 7. CAT(y) ∨ ¬
HAVE(x,b)
¬ HAVE(John,y) ∨
[7,5.(b):] 8.
¬ CAT(y)
¬ HAVE(John,a) ∨
[6,8:] 9.
HOWL(a)
[4.(a),9:] 10. HOWL(a)
¬ LS(x) ∨ ¬
[3,10:] 11.
HAVE(x,a)
[4.(a),11:] 12. ¬ LS(John)
[5.(a),12:] 13. □