Professional Documents
Culture Documents
Soleymani
2
FOL to PL
FOL to PL conversion
First order inference by converting the knowledge base to PL
and using propositional inference.
3
Universal instantiation (UI)
Every instantiation of a universally quantified sentence is
entailed by it:
∀𝑣 𝛼
𝑆𝑢𝑏𝑠𝑡( 𝑣 𝑔 , 𝛼)
4
Existential instantiation (EI)
For any sentence 𝛼, variable 𝑣, and a new constant symbol 𝑘:
∃𝑣 𝛼
𝑆𝑢𝑏𝑠𝑡( 𝑣 𝑘 , 𝛼)
Solution:
Theorem (Herbrand, 1930): If a sentence 𝛼 is entailed by an FOL KB,
it can be entailed by a finite subset of its propositionalized KB
for 𝑛 = 0 to ∞ do
Generate all instantiations with depth 𝑛 nested symbols
if 𝛼 is entailed by this 𝐾𝐵 then return 𝑡𝑟𝑢𝑒
7
Propositionalization (Cont.)
Problem: When procedure go on and on, we will not know
whether it is stuck in a loop or the proof is just about to pop
out
8
Propositionalization is inefficient
Generates lots of irrelevant sentences
Example:
𝐾𝑖𝑛𝑔 𝑅𝑖𝑐ℎ𝑎𝑟𝑑 𝐺𝑟𝑒𝑒𝑑𝑦 𝑅𝑖𝑐ℎ𝑎𝑟𝑑 𝐸𝑣𝑖𝑙 𝑅𝑖𝑐ℎ𝑎𝑟𝑑 is irrelevant.
KB
Query
𝑥 𝐾𝑖𝑛𝑔 𝑥 𝐺𝑟𝑒𝑒𝑑𝑦 𝑥 𝐸𝑣𝑖𝑙 𝑥
𝐾𝑖𝑛𝑔 𝐽𝑜ℎ𝑛 𝐸𝑣𝑖𝑙(𝑥)
𝐺𝑟𝑒𝑒𝑑𝑦 𝐽𝑜ℎ𝑛
𝐵𝑟𝑜𝑡ℎ𝑒𝑟 𝑅𝑖𝑐ℎ𝑎𝑟𝑑, 𝐽𝑜ℎ𝑛
9
Lifting & Unification
Lifting: raising inference rules or algorithms from ground
(variable-free) PL to FOL.
E.g., generalized Modus Ponens
10
Unification: Simple example
Example: Infer immediately when finding a substitution θ such
that 𝐾𝑖𝑛𝑔(𝑥) and 𝐺𝑟𝑒𝑒𝑑𝑦(𝑥) match 𝐾𝑖𝑛𝑔(𝐽𝑜ℎ𝑛) and
𝐺𝑟𝑒𝑒𝑑𝑦(𝑦)
KB
Query
𝑥 𝐾𝑖𝑛𝑔 𝑥 𝐺𝑟𝑒𝑒𝑑𝑦 𝑥 𝐸𝑣𝑖𝑙 𝑥
𝐾𝑖𝑛𝑔 𝐽𝑜ℎ𝑛 𝐸𝑣𝑖𝑙(𝑥)
∀𝑦 𝐺𝑟𝑒𝑒𝑑𝑦 𝑦
𝐵𝑟𝑜𝑡ℎ𝑒𝑟 𝑅𝑖𝑐ℎ𝑎𝑟𝑑, 𝐽𝑜ℎ𝑛
11
Unification: examples
𝑝 𝑞 𝜃
12
Unification: examples
𝑝 𝑞 𝜃
13
Unification: complications
Complications
Two sentences using the same variable name
Standardizing apart: renaming the variables causing name clashes in
one of sentences
More than one unifier
Most General Unifier (MGU)
𝑝 𝑞 𝜃
14
Unification (MGU)
𝑈𝑁𝐼𝐹𝑌( 𝐾𝑛𝑜𝑤𝑠 𝐽𝑜ℎ𝑛, 𝑥 , 𝐾𝑛𝑜𝑤𝑠 𝑦, 𝑧 )
𝜃1 = {𝑦/𝐽𝑜ℎ𝑛, 𝑥/𝑧 }
𝜃2 = {𝑦/𝐽𝑜ℎ𝑛, 𝑥/𝐽𝑜ℎ𝑛, 𝑧/𝐽𝑜ℎ𝑛}
𝜃1 is more general
15
Generalized Modus Ponens (GMP)
For atomic sentences 𝑝𝑖 , 𝑝𝑖′ , 𝑞 & 𝑆𝑢𝑏𝑠𝑡 𝜃, 𝑝𝑖′ = 𝑆𝑢𝑏𝑠𝑡 𝜃, 𝑝𝑖 for
all 𝑖
16
𝑝1′ , 𝑝2′ , … , 𝑝𝑛′ , (𝑝1 ∧ 𝑝2 ∧ … ∧ 𝑝𝑛 ⇒ 𝑞)
GMP is sound 𝑆𝑢𝑏𝑠𝑡(𝜃, 𝑞)
𝑝1′ ∧ … ∧ 𝑝𝑛
′
1)
𝑆𝑢𝑏𝑠𝑡 𝜃, 𝑝1′ ∧ …∧ 𝑆𝑢𝑏𝑠𝑡(𝜃, 𝑝𝑛
′)
𝑝1 ∧ 𝑝2 ∧ … ∧ 𝑝𝑛 ⇒ 𝑞
2)
𝑆𝑢𝑏𝑠𝑡 𝜃, 𝑝1 ∧ … ∧ 𝑆𝑢𝑏𝑠𝑡 𝜃, 𝑝𝑛 ⇒ 𝑆𝑢𝑏𝑠𝑡(𝜃, 𝑞)
17
Unification algorithm
function UNIFY(𝑥, 𝑦, 𝜃) returns a substitution to make 𝑥 and 𝑦 identical
inputs: 𝑥, a variable, a constant, list, or compound expression
𝑦, a variable, a constant, list, or compound expression
𝜃, the substitution built up so far (optional, defaults to empty)
19
KB of definite clauses
Definite clause: disjunctions of literals of which exactly
one is positive.
Atomic: 𝑃1 , 𝑃2 , …
Implication: 𝑃1 ∧ 𝑃2 ∧ … ∧ 𝑃𝑘 ⇒ 𝑃𝑘+1
20
KB of first order definite clauses: Example
“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.”
21
KB of first order definite clauses: Example
“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.”
22
KB of first order definite clauses: Example
“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.”
𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
23
KB of first order definite clauses: Example
“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.”
𝑥 𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥)
24
KB of first order definite clauses: Example
“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.”
25
KB of first order definite clauses: Example
“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.”
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡)
26
KB of first order definite clauses: Example
“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.”
𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥) 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
28
FC algorithm
function FOL_FC_ASK(𝐾𝐵, 𝛼) returns a substitution or 𝑓𝑎𝑙𝑠𝑒
inputs: 𝐾𝐵, a set of first-order definite clauses
𝛼, the query, an atomic sentence
Known facts
1) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
30
FC: example
FC reaches a fix point for Datalog KBs after finite number of iterations
33
More efficient FC
Heuristics for matching rules against known facts
E.g., conjunct ordering
34
Backward Chaining (BC)
Works backward from the goal, chaining through rules to
find known facts supporting the proof
AND-OR search
OR: any rule 𝑙ℎ𝑠 ⇒ 𝑔𝑜𝑎𝑙 in KB can be used to prove the goal
AND: all conjuncts in 𝑙ℎ𝑠 must be proved.
35
BC algorithm
(depth-first recursive proof search)
function FOL_BC_ASK(𝐾𝐵, 𝑞𝑢𝑒𝑟𝑦) returns a generator of substitutions
return FOL_BC_OR(𝐾𝐵, 𝑞𝑢𝑒𝑟𝑦, {})
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
37
Backward chaining example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
38
Backward chaining example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
39
Backward chaining example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
40
Backward chaining example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
41
Backward chaining example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
42
Backward chaining example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
43
Backward chaining example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
44
Backward chaining example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
45
Properties of BC
Space is linear in the size of the proof
46
Resolution algorithm
General theorem proving
47
Resolution
PL resolution: 𝑙𝑖 and 𝑚𝑗 are complement
𝑙1 ∨ 𝑙2 ∨ ⋯ ∨ 𝑙𝑘 , 𝑚1 ∨ 𝑚2 ∨ ⋯ ∨ 𝑚𝑛
𝑙1 ∨ … ∨ 𝑙𝑖−1 ∨ 𝑙𝑖+1 ∨ ⋯ ∨ 𝑙𝑘 ∨ 𝑚1 ∨ … ∨ 𝑚𝑗−1 ∨ 𝑚𝑗+1 ∨ ⋯ ∨ 𝑚𝑛
𝑙1 ∨ 𝑙2 ∨ ⋯ ∨ 𝑙𝑘 , 𝑚1 ∨ 𝑚2 ∨ ⋯ ∨ 𝑚𝑛
SUBST(𝜃, 𝑙1 ∨ … ∨ 𝑙𝑖−1 ∨ 𝑙𝑖+1 ∨ ⋯ ∨ 𝑙𝑘 ∨ 𝑚1 ∨ … ∨ 𝑚𝑗−1 ∨ 𝑚𝑗+1 ∨ ⋯ ∨ 𝑚𝑛 )
Example:
𝑅𝑖𝑐ℎ 𝑥 ∨ 𝑈𝑛ℎ𝑎𝑝𝑝𝑦 𝑥 , 𝑅𝑖𝑐ℎ(𝐾𝑒𝑛) 𝜃 = {𝑥/𝐾𝑒𝑛}
𝑈𝑛ℎ𝑎𝑝𝑝𝑦(𝐾𝑒𝑛)
48
Converting FOL sentence to CNF
Example:“everyone who loves all animals is loved by someone”
𝑥 [∀𝑦 𝐴𝑛𝑖𝑚𝑎𝑙(𝑦) ⇒ 𝐿𝑜𝑣𝑒𝑠(𝑥, 𝑦)] [𝑦 𝐿𝑜𝑣𝑒𝑠(𝑦, 𝑥)]
1) Eliminate implications (𝑃 ⇒ 𝑄 ≡ ¬𝑃 ∨ 𝑄)
𝑥 [¬∀𝑦 ¬𝐴𝑛𝑖𝑚𝑎𝑙 𝑦 𝐿𝑜𝑣𝑒𝑠(𝑥, 𝑦)] [𝑦 𝐿𝑜𝑣𝑒𝑠(𝑦, 𝑥)]
49
Converting FOL sentence to CNF
4) Skolemize: a more general form of existential instantiation.
Each existentially quantified variable is replaced by a Skolem function of the
enclosing universally quantified variables.
6) Distribute over :
[𝐴𝑛𝑖𝑚𝑎𝑙(𝐹(𝑥)) ∨ 𝐿𝑜𝑣𝑒𝑠(𝐺(𝑥), 𝑥)] ∧ [¬𝐿𝑜𝑣𝑒𝑠(𝑥, 𝐹(𝑥)) ∨ 𝐿𝑜𝑣𝑒𝑠(𝐺(𝑥), 𝑥)]
50
Properties of resolution
Resolution
Complete when used in combination with factoring
51
Resolution: definite clauses example
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∧ 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∧ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∧ 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) 𝐸𝑛𝑒𝑚𝑦(𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎) 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
Convert to CNF
1) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
2) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1 ∧ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑀1
3) 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑊𝑒𝑠𝑡
4) ¬ 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∨ ¬𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ∨ 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
5) ¬𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 ∨ ¬𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 ∨ ¬𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 ∨ ¬𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ∨ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
6) ¬𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ∨ 𝑊𝑒𝑎𝑝𝑜𝑛 𝑥
7) ¬𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ∨ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
52
Resolution: definite clauses example
𝐾𝐵 ¬𝛼
53
Resolution: general example
Every one who loves all animals is loved by someone.
𝑥 [∀𝑦 𝐴𝑛𝑖𝑚𝑎𝑙(𝑦) ⇒ 𝐿𝑜𝑣𝑒𝑠(𝑥, 𝑦)] [𝑦 𝐿𝑜𝑣𝑒𝑠(𝑦, 𝑥)]
Anyone who kills an animal is loved by no one.
𝑥 [∃𝑧 𝐴𝑛𝑖𝑚𝑎𝑙(𝑧) ∧ 𝐾𝑖𝑙𝑙𝑠(𝑥, 𝑧)] [∀𝑦 ¬𝐿𝑜𝑣𝑒𝑠(𝑦, 𝑥)]
Jack loves all animals.
𝑥 𝐴𝑛𝑖𝑚𝑎𝑙(𝑥) 𝐿𝑜𝑣𝑒𝑠(𝐽𝑎𝑐𝑘, 𝑥)
Either Jack or Curiosity killed the cat, who is named Tuna.
𝐾𝑖𝑙𝑙𝑠 𝐽𝑎𝑐𝑘, 𝑇𝑢𝑛𝑎 ∨ 𝐾𝑖𝑙𝑙𝑠(𝐶𝑢𝑟𝑖𝑜𝑠𝑖𝑡𝑦, 𝑇𝑢𝑛𝑎)
𝐶𝑎𝑡(𝑇𝑢𝑛𝑎)
Query: Did Curiosity kill the cat?
𝐾𝑖𝑙𝑙𝑠(𝐶𝑢𝑟𝑖𝑜𝑠𝑖𝑡𝑦, 𝑇𝑢𝑛𝑎)
54
Resolution: general example
CNF (𝐾𝐵 ∧ ¬𝛼):
𝐴𝑛𝑖𝑚𝑎𝑙(𝐹(𝑥)) ∨ 𝐿𝑜𝑣𝑒𝑠(𝐺(𝑥), 𝑥)
¬𝐿𝑜𝑣𝑒𝑠(𝑥, 𝐹(𝑥)) ∨ 𝐿𝑜𝑣𝑒𝑠(𝐺(𝑥), 𝑥)
¬𝐿𝑜𝑣𝑒𝑠(𝑦, 𝑥) ∨ ¬𝐴𝑛𝑖𝑚𝑎𝑙(𝑧) ∨ ¬𝐾𝑖𝑙𝑙𝑠(𝑥, 𝑧)
¬𝐴𝑛𝑖𝑚𝑎𝑙(𝑥) ∨ 𝐿𝑜𝑣𝑒𝑠(𝐽𝑎𝑐𝑘, 𝑥)
𝐾𝑖𝑙𝑙𝑠 𝐽𝑎𝑐𝑘, 𝑇𝑢𝑛𝑎 ∨ 𝐾𝑖𝑙𝑙𝑠(𝐶𝑢𝑟𝑖𝑜𝑠𝑖𝑡𝑦, 𝑇𝑢𝑛𝑎)
𝐶𝑎𝑡(𝑇𝑢𝑛𝑎)
¬ 𝐾𝑖𝑙𝑙𝑠(𝐶𝑢𝑟𝑖𝑜𝑠𝑖𝑡𝑦, 𝑇𝑢𝑛𝑎)
55
Resolution: general example
56
Prolog (Programming in logic)
Basis: backward chaining with Horn clauses
Depth-first, left-to-right BC
57
Prolog: Example
Appending two lists to produce a third:
append([],Y,Y).
append([X|L],Y,[X|Z]) :- append(L,Y,Z).
query: append(A,B,[1,2]) ?
58
Summary
Lifting and unification
59