Chapter09 6pp
Chapter09 6pp
Chapter 9 1 Chapter 9 4
♦ Resolution
Chapter 9 2 Chapter 9 5
Every instantiation of a universally quantified sentence is entailed by it: Suppose the KB contains just the following:
∀v α ∀ x King(x) ∧ Greedy(x) ⇒ Evil(x)
Subst({v/g}, α) King(John)
Greedy(John)
for any variable v and ground term g
Brother(Richard, John)
E.g., ∀ x King(x) ∧ Greedy(x) ⇒ Evil(x) yields Instantiating the universal sentence in all possible ways, we have
King(John) ∧ Greedy(John) ⇒ Evil(John) King(John) ∧ Greedy(John) ⇒ Evil(John)
King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard) King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard)
King(F ather(John)) ∧ Greedy(F ather(John)) ⇒ Evil(F ather(John)) King(John)
..
Greedy(John)
Brother(Richard, John)
The new KB is propositionalized: proposition symbols are
King(John), Greedy(John), Evil(John), King(Richard) etc.
Chapter 9 3 Chapter 9 6
Reduction contd. Unification
Claim: a ground sentence∗ is entailed by new KB iff entailed by original KB We can get the inference immediately if we can find a substitution θ
such that King(x) and Greedy(x) match King(John) and Greedy(y)
Claim: every FOL KB can be propositionalized so as to preserve entailment
θ = {x/John, y/John} works
Idea: propositionalize KB and query, apply resolution, return result
Unify(α, β) = θ if αθ = βθ
Problem: with function symbols, there are infinitely many ground terms,
e.g., F ather(F ather(F ather(John)))
Theorem: Herbrand (1930). If a sentence α is entailed by an FOL KB, p q θ
it is entailed by a finite subset of the propositional KB Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y, OJ)
Idea: For n = 0 to ∞ do Knows(John, x) Knows(y, M other(y))
create a propositional KB by instantiating with depth-n terms Knows(John, x) Knows(x, OJ)
see if α is entailed by this KB
Problem: works if α is entailed, loops if α is not entailed
Theorem: Turing (1936), Church (1936), entailment in FOL is semidecidable
Chapter 9 7 Chapter 9 10
Chapter 9 8 Chapter 9 11
Unification Unification
We can get the inference immediately if we can find a substitution θ We can get the inference immediately if we can find a substitution θ
such that King(x) and Greedy(x) match King(John) and Greedy(y) such that King(x) and Greedy(x) match King(John) and Greedy(y)
θ = {x/John, y/John} works θ = {x/John, y/John} works
Unify(α, β) = θ if αθ = βθ Unify(α, β) = θ if αθ = βθ
p q θ p q θ
Knows(John, x) Knows(John, Jane) Knows(John, x) Knows(John, Jane) {x/Jane}
Knows(John, x) Knows(y, OJ) Knows(John, x) Knows(y, OJ) {x/OJ, y/John}
Knows(John, x) Knows(y, M other(y)) Knows(John, x) Knows(y, M other(y)) {y/John, x/M other(John)}
Knows(John, x) Knows(x, OJ) Knows(John, x) Knows(x, OJ)
Chapter 9 9 Chapter 9 12
Unification Example knowledge base contd.
We can get the inference immediately if we can find a substitution θ . . . it is a crime for an American to sell weapons to hostile nations:
such that King(x) and Greedy(x) match King(John) and Greedy(y)
θ = {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, M other(y)) {y/John, x/M other(John)}
Knows(John, x) Knows(x, OJ) f ail
Standardizing apart eliminates overlap of variables, e.g., Knows(z17, OJ)
Chapter 9 13 Chapter 9 16
Chapter 9 14 Chapter 9 17
Chapter 9 15 Chapter 9 18
Example knowledge base contd. Forward chaining algorithm
. . . it is a crime for an American to sell weapons to hostile nations:
function FOL-FC-Ask(KB, α) returns a substitution or false
American(x)∧W eapon(y)∧Sells(x, y, z)∧Hostile(z) ⇒ Criminal(x)
repeat until new is empty
Nono . . . has some missiles, i.e., ∃ x Owns(N ono, x) ∧ M issile(x):
new ← { }
Owns(N ono, M1) and M issile(M1) for each sentence r in KB do
. . . all of its missiles were sold to it by Colonel West ( p 1 ∧ . . . ∧ p n ⇒ q) ← Standardize-Apart(r)
M issile(x) ∧ Owns(N ono, x) ⇒ Sells(W est, x, N ono) for each θ such that (p 1 ∧ . . . ∧ p n )θ = (p ′1 ∧ . . . ∧ p ′n )θ
Missiles are weapons: for some p ′1, . . . , p ′n in KB
q ′ ← Subst(θ, q )
if q ′ is not a renaming of a sentence already in KB or new then do
add q ′ to new
φ ← Unify(q ′, α)
if φ is not fail then return φ
add new to KB
return false
Chapter 9 19 Chapter 9 22
Chapter 9 20 Chapter 9 23
Chapter 9 21 Chapter 9 24
Forward chaining proof Backward chaining example
Criminal(West) Criminal(West)
Chapter 9 25 Chapter 9 28
Chapter 9 26 Chapter 9 29
Chapter 9 27 Chapter 9 30
Backward chaining example Backward chaining example
Chapter 9 31 Chapter 9 34
Criminal(West) {x/West, y/M1} Depth-first recursive proof search: space is linear in size of proof
Incomplete due to infinite loops
⇒ fix by checking current goal against every goal on stack
Inefficient due to repeated subgoals (both success and failure)
American(West) Weapon(y) Sells(West,M1,z)
Sells(x,y,z) Hostile(Nono)
Hostile(z) ⇒ fix using caching of previous results (extra space!)
{}
Widely used (without improvements!) for logic programming
Missile(y)
{ y/M1 }
Chapter 9 32 Chapter 9 35
Criminal(West) {x/West, y/M1, z/Nono} Sound bite: computation as inference on logical KBs
Logic programming Ordinary programming
1. Identify problem Identify problem
2. Assemble information Assemble information
3. Tea break Figure out solution
American(West) Weapon(y) Sells(West,M1,z) Hostile(z) 4. Encode information in KB Program solution
{} { z/Nono } 5. Encode problem instance as facts Encode problem instance as data
6. Ask queries Apply program to data
7. Find false facts Debug procedural errors
Missile(y) Missile(M1) Owns(Nono,M1)
Should be easier to debug Capital(N ewY ork, U S) than x := x + 2 !
{ y/M1 }
Chapter 9 33 Chapter 9 36
Prolog systems Conversion to CNF
Basis: backward chaining with Horn clauses + bells & whistles Everyone who loves all animals is loved by someone:
Widely used in Europe, Japan (basis of 5th Generation project) ∀ x [∀ y Animal(y) ⇒ Loves(x, y)] ⇒ [∃ y Loves(y, x)]
Compilation techniques ⇒ approaching a billion LIPS
1. Eliminate biconditionals and implications
Program = set of clauses = head :- literal1, . . . literaln.
∀ x [¬∀ y ¬Animal(y) ∨ Loves(x, y)] ∨ [∃ y Loves(y, x)]
criminal(X) :- american(X), weapon(Y), sells(X,Y,Z), hostile(Z).
2. Move ¬ inwards: ¬∀ x, p ≡ ∃ x ¬p, ¬∃ x, p ≡ ∀ x ¬p:
Depth-first, left-to-right backward chaining
Built-in predicates for arithmetic etc., e.g., X is Y*Z+3 ∀ x [∃ y ¬(¬Animal(y) ∨ Loves(x, y))] ∨ [∃ y Loves(y, x)]
Closed-world assumption (“negation as failure”) ∀ x [∃ y ¬¬Animal(y) ∧ ¬Loves(x, y)] ∨ [∃ y Loves(y, x)]
e.g., given alive(X) :- not dead(X). ∀ x [∃ y Animal(y) ∧ ¬Loves(x, y)] ∨ [∃ y Loves(y, x)]
alive(joe) succeeds if dead(joe) fails
Chapter 9 37 Chapter 9 40
Chapter 9 38 Chapter 9 41
>
>
>
L
ℓ1 ∨ · · · ∨ ℓk , m1 ∨ · · · ∨ mn
American(West) American(West) Weapon(y) Sells(West,y,z) Hostile(z)
>
>
>
L
>
>
L
>
L
For example,
¬Rich(x) ∨ U nhappy(x) Missile(x) Owns(Nono,x) Sells(West,x,Nono) Sells(West,M1,z) Hostile(z)
>
>
>
L
Rich(Ken)
Missile(M1) Missile(M1) Owns(Nono,M1) Hostile(Nono)
>
>
L
U nhappy(Ken)
Owns(Nono,M1) Owns(Nono,M1) Hostile(Nono)
>
L
with θ = {x/Ken}
Enemy(x,America) Hostile(x) Hostile(Nono)
Apply resolution steps to CN F (KB ∧ ¬α); complete for FOL
>
L
Enemy(Nono,America) Enemy(Nono,America)
Chapter 9 39 Chapter 9 42