Inference in Fol
Inference in Fol
Inference in Fol
Philipp Koehn
5 March 2024
● Propositional logic
● Inference algorithms
– forward chaining
– backward chaining
– resolution (for full propositional logic)
● Unification
● Logic programming
● Resolution
reduction to
propositional inference
∀v α
S UBST({v/g}, α)
● Universal Instantiation
– can be applied several times to add new sentences
– the new KB is logically equivalent to the old
● Existential Instantiation
– can be applied once to replace the existential sentence
– the new KB is not equivalent to the old
– but is satisfiable iff the old KB was satisfiable
unification
● U NIFY(α, β) = θ if αθ = βθ
p q θ
Knows(John, x) Knows(John, Jane)
Knows(John, x) Knows(y, M ary)
Knows(John, x) Knows(y, M other(y))
Knows(John, x) Knows(x, M ary)
● U NIFY(α, β) = θ if αθ = βθ
p q θ
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y, M ary)
Knows(John, x) Knows(y, M other(y))
Knows(John, x) Knows(x, M ary)
● U NIFY(α, β) = θ if αθ = βθ
p q θ
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y, M ary) {x/M ary, y/John}
Knows(John, x) Knows(y, M other(y))
Knows(John, x) Knows(x, M ary)
● U NIFY(α, β) = θ if αθ = βθ
p q θ
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y, M ary) {x/M ary, y/John}
Knows(John, x) Knows(y, M other(y)) {y/John, x/M other(John)}
Knows(John, x) Knows(x, M ary)
● U NIFY(α, β) = θ if αθ = βθ
p q θ
Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y, M ary) {x/M ary, y/John}
Knows(John, x) Knows(y, M other(y)) {y/John, x/M other(John)}
Knows(John, x) Knows(x, M ary) f ail
forward chaining
● The law says that it is a crime for an American to sell weapons to hostile nations.
The country Nono, an enemy of America, has some missiles, and all of its
missiles were sold to it by Colonel West, who is American.
backward chaining
logic programming
resolution
`1 ∨ ⋯ ∨ `k , m1 ∨ ⋯ ∨ m n
(`1 ∨ ⋯ ∨ `i−1 ∨ `i+1 ∨ ⋯ ∨ `k ∨ m1 ∨ ⋯ ∨ mj−1 ∨ mj+1 ∨ ⋯ ∨ mn)θ
● For example,
¬Rich(x) ∨ U nhappy(x) Rich(Ken)
U nhappy(Ken)
with θ = {x/Ken}
6. Distribute ∧ over ∨:
[Animal(F (x)) ∨ Loves(G(x), x)] ∧ [¬Loves(x, F (x)) ∨ Loves(G(x), x)]
● Rules
– American(x) ∧ W eapon(y) ∧ Sells(x, y, z) ∧ Hostile(z) Ô⇒ Criminal(x)
– M issile(M1) and Owns(N ono, M1)
– M issile(x) ∧ Owns(N ono, x) Ô⇒ Sells(W est, x, N ono)
– M issile(x) ⇒ W eapon(x)
– Enemy(x, America) Ô⇒ Hostile(x)
– American(W est)
– Enemy(N ono, America)
● Converted to CNF
– ¬American(x) ∨ ¬W eapon(y) ∨ ¬Sells(x, y, z) ∨ ¬Hostile(z) ∨ Criminal(x)
– M issile(M1) and Owns(N ono, M1)
– ¬M issile(x) ∨ ¬Owns(N ono, x) ∨ Sells(W est, x, N ono)
– ¬M issile(x) ∨ W eapon(x)
– ¬Enemy(x, America) ∨ Hostile(x)
– American(W est)
– Enemy(N ono, America)
● Query: ¬Criminal(W est)