L6-FirstOrderLogic 2023
L6-FirstOrderLogic 2023
Tjitze Rienstra
Chapters 8 and 9
Outline
1. First-order logic
• Syntax
• Semantics
2. Example: wumpus world in FOL
3. Inference in FOL:
• Reduction to propositional logic
• Resolution
• Forward chaining
• Backward chaining
Chapters 8, 9 2
A simple knowledge-based agent
function KB-AGENT(percept) returns an action
static: KB, a knowledge base
t, a counter, initially 0, indicating time
TELL(KB, MAKE-PERCEPT-SENTENCE(percept, t))
action ← ASK(KB, MAKE-ACTION-QUERY(t))
TELL(KB, MAKE-ACTION-SENTENCE(action, t))
t←t+1
return action
Knowledge base = set of sentences in a formal language
+
Inference = derive new sentences from old ones
Chapters 8, 9 3
A simple knowledge-based agent
function KB-AGENT(percept) returns an action
static: KB, a knowledge base
t, a counter, initially 0, indicating time
TELL(KB, MAKE-PERCEPT-SENTENCE(percept, t))
action ← ASK(KB, MAKE-ACTION-QUERY(t))
TELL(KB, MAKE-ACTION-SENTENCE(action, t))
t←t+1
return action
Knowledge base = set of sentences in a formal language
+
Inference = derive new sentences from old ones
Formal language examples:
• Propositional Logic (last lecture)
• First Order Logic (today)
Chapters 8, 9 4
1. First-order logic:
Syntax and Semantics
Chapters 8, 9 5
First-order logic
Whereas propositional logic assumes world contains facts, first-order logic (like natural
language) assumes the world contains
• Objects: people, houses, numbers, theories, Ronald McDonald, colors, baseball games,
wars, centuries, …
• Relations:
• unary (a.k.a. properties): red, round, bogus, prime, multistoried, …
• n-ary: brother of, bigger than, inside, part of, has color, occurred after, owns, comes
between, …
• Functions: father of, best friend, third inning of, one more than, end of, …
Chapters 8, 9 6
Syntax of FOL: Basic elements
Chapters 8, 9 7
Syntax of FOL: Terms and atomic sentences
Term = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡
or 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒
or 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛(𝑡𝑒𝑟𝑚1 , … , 𝑡𝑒𝑟𝑚𝑛 )
E.g., 𝐽𝑜ℎ𝑛, 𝐽𝑜ℎ𝑛𝑠𝐿𝑒𝑓𝑡𝐿𝑒𝑔, 𝐿𝑒𝑓𝑡𝐿𝑒𝑔𝑂𝑓 𝐽𝑜ℎ𝑛
Chapters 8, 9 8
Syntax of FOL: Complex sentences
Complex sentences are made from atomic sentences
using logical connectives and quantifiers
¬𝑆, 𝑆1 𝑆2 , 𝑆1 𝑆2 , 𝑆1 𝑆2 , 𝑆1 𝑆2 ,
𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠 S, 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠 S,
E.g.
𝑆𝑖𝑏𝑙𝑖𝑛𝑔(𝐽𝑜ℎ𝑛, 𝑅𝑖𝑐ℎ𝑎𝑟𝑑) 𝑆𝑖𝑏𝑙𝑖𝑛𝑔(𝑅𝑖𝑐ℎ𝑎𝑟𝑑, 𝐽𝑜ℎ𝑛)
> 1, 2 ≤ 1, 2
< 1, 2 > (1, 2)
𝑥 𝐴𝑡 𝑥, 𝐵𝑒𝑟𝑘𝑒𝑙𝑒𝑦 ⇒ 𝑆𝑚𝑎𝑟𝑡 𝑥
REMEMBER! Operator precedence: , =, , , ,
Chapters 8, 9 9
Semantics of FOL: models
REMEBER? To define semantics of propositional logic we need to
define the models (i.e. possible worlds).
Chapters 8, 9 10
Semantics of FOL: models
REMEBER? To define semantics of propositional logic we need to
define the models (i.e. possible worlds).
Chapters 8, 9 11
Models for FOL: Example
object
binary relation crown
function
unary relation
on head
person brother
person
brother king
R $
J
left leg left leg
Is this enough to
specify semantics?
Chapters 8, 9 12
Semantics of FOL
We also need an interpretation of the model.
Chapters 8, 9 13
Example: Intended Interpretation
object
binary relation crown
function
unary relation
on head
person brother
person
brother king
R $
J
left leg left leg
Chapters 8, 9 14
Example: Intended Interpretation
object
binary relation crown Crown
function
Brother
unary relation
on head OnHead
Person → person brother
person
brother king King
John
Richard →
R $
J LeftLeg
left leg left leg
𝐵𝑟𝑜𝑡ℎ𝑒𝑟(𝑅𝑖𝑐ℎ𝑎𝑟𝑑, 𝐽𝑜ℎ𝑛)
is true
Chapters 8, 9 15
Example: Another Interpretation
object
binary relation crown King
function Richard
Brother
unary relation
on head OnHead
Crown → person brother
person
brother king Person
R $
J LeftLeg
left leg left leg
Chapters 8, 9 17
Note: semantics of quantifiers
Universal quantifier: 𝑥 𝑆 is true in a model 𝑚 iff
sentence 𝑆 is true with 𝑥 being each possible object in
the model
Existential quantifier: 𝑥 𝑆 is true in a model 𝑚 iff
sentence 𝑆 is true with 𝑥 being some possible object
in the model
Chapters 8, 9 18
Properties of quantifiers
𝑥 𝑦 is the same as 𝑦 𝑥 and as 𝑥, 𝑦, 𝑦, 𝑥
𝑥 𝑦 is the same as 𝑦 𝑥 and as 𝑥, 𝑦, 𝑦, 𝑥
𝑥 𝑦 is not the same as 𝑦 𝑥
𝑥 𝑦 𝐿𝑜𝑣𝑒𝑠(𝑥, 𝑦)
“There is a person who loves everyone in the world”
𝑦 𝑥 𝐿𝑜𝑣𝑒𝑠(𝑥, 𝑦)
“Everyone in the world is loved by at least one person”
Chapters 8, 9 20
Knowledge base for the wumpus world
Percepts:
𝑃𝑒𝑟𝑐𝑒𝑝𝑡 𝑆𝑡𝑒𝑛𝑐ℎ, 𝐵𝑟𝑒𝑒𝑧𝑒, 𝐺𝑙𝑖𝑡𝑡𝑒𝑟, 𝑁𝑜𝑛𝑒, 𝑁𝑜𝑛𝑒 , 5
Actions:
𝑇𝑢𝑟𝑛 𝑅𝑖𝑔ℎ𝑡 , 𝑇𝑢𝑟𝑛 𝐿𝑒𝑓𝑡 , 𝐹𝑜𝑟𝑤𝑎𝑟𝑑, 𝑆ℎ𝑜𝑜𝑡, 𝐺𝑟𝑎𝑏, 𝐶𝑙𝑖𝑚𝑏
Perception (reasoning about percepts):
𝑠, 𝑔, 𝑤, 𝑐, 𝑡 𝑃𝑒𝑟𝑐𝑒𝑝𝑡 𝑠, 𝐵𝑟𝑒𝑒𝑧𝑒, 𝑔, 𝑤, 𝑐 , 𝑡 ⇒ 𝐵𝑟𝑒𝑒𝑧𝑒(𝑡)
𝑠, 𝑔, 𝑤, 𝑐, 𝑡 𝑃𝑒𝑟𝑐𝑒𝑝𝑡 𝑠, 𝑁𝑜𝑛𝑒, 𝑔, 𝑤, 𝑐 , 𝑡 ⇒ 𝐵𝑟𝑒𝑒𝑧𝑒(𝑡)
s, 𝑏, 𝑤, 𝑐, 𝑡 𝑃𝑒𝑟𝑐𝑒𝑝𝑡 𝑠, 𝑏, 𝐺𝑙𝑖𝑡𝑡𝑒𝑟, 𝑤, 𝑐 , 𝑡 ⇒ 𝐺𝑙𝑖𝑡𝑡𝑒𝑟(𝑡)
s, 𝑏, 𝑤, 𝑐, 𝑡 𝑃𝑒𝑟𝑐𝑒𝑝𝑡 𝑠, 𝑏, 𝑁𝑜𝑛𝑒, 𝑤, 𝑐 , 𝑡 ⇒ 𝐺𝑙𝑖𝑡𝑡𝑒𝑟 𝑡
Reflex behavior:
𝑡 𝐺𝑙𝑖𝑡𝑡𝑒𝑟 𝑡 ⇒ 𝐵𝑒𝑠𝑡𝐴𝑐𝑡𝑖𝑜𝑛(𝐺𝑟𝑎𝑏, 𝑡)
Chapters 8, 9 21
Knowledge base for the wumpus world
REPRESENTING THE ENVIRONMENT
Squares: lists of coordinates
e.g [1,2] (= 𝐶𝑜𝑛𝑠(1, 𝐶𝑜𝑛𝑠(2, 𝑁𝑖𝑙)), syntactic sugar)
Adjacency of squares:
∀𝑥, 𝑦, 𝑎, 𝑏 𝐴𝑑𝑗𝑎𝑐𝑒𝑛𝑡 𝑥, 𝑦 , 𝑎, 𝑏 ⇔ 𝑥 = 𝑎 ∧ 𝑦 = 𝑏 − 1 ∨ 𝑦 = 𝑏 + 1 ∨
𝑦 =𝑏 ∧ 𝑥 = 𝑎−1∨𝑥 =𝑎+1
Agent’s location: 𝐴𝑡(𝐴𝑔𝑒𝑛𝑡, 𝑠, 𝑡)
Wumpus’ location: 𝐴𝑡(𝑊𝑢𝑚𝑝𝑢𝑠, [1,3], 𝑡)
Chapters 8, 9 24
Inference
Model checking
• Enumeration of models
Propositionalization
• Transform FOL KB to propositional logic KB
Chapters 8, 9 25
Model Checking by Enumeration
Consider all possible models for constant symbols: 𝑅, 𝐽
R J R J R J R J R J R J
Chapters 8, 9 26
Universal instantiation (UI)
Every instantiation of a universally quantified sentence is
entailed by it:
𝑣
𝑆𝑈𝐵𝑆𝑇( 𝑣/𝑔 , )
for any variable 𝑣 and ground term 𝑔
Ground term = term without variables
Chapters 8, 9 27
Existential instantiation (EI)
For any sentence , variable 𝑣, and constant symbol 𝑘 that does not
appear elsewhere in the knowledge base:
𝑣
𝑆𝑈𝐵𝑆𝑇( 𝑣/𝑘 , )
E.g., 𝑥 𝐶𝑟𝑜𝑤𝑛 𝑥 𝑂𝑛𝐻𝑒𝑎𝑑 𝑥, 𝐽𝑜ℎ𝑛 yields
𝐶𝑟𝑜𝑤𝑛 𝐶1 𝑂𝑛𝐻𝑒𝑎𝑑(𝐶1 , 𝐽𝑜ℎ𝑛)
provided 𝐶1 is a new constant symbol, called a Skolem constant
Chapters 8, 9 28
Propositionalization
UI can be applied several times to add new sentences;
the new KB is logically equivalent to the old
Chapters 8, 9 29
Generalized Modus Ponens (GMP)
Chapters 8, 9 31
Unification
How do we find the necessary substitutions?
E.g. we can get the inference immediately if we can find a substitution
𝜃 such that 𝐾𝑖𝑛𝑔(𝑥) and 𝐺𝑟𝑒𝑒𝑑𝑦(𝑥) match 𝐾𝑖𝑛𝑔(𝐽𝑜ℎ𝑛) and
𝐺𝑟𝑒𝑒𝑑𝑦 𝑦 , i.e. 𝜃 = {𝑥/𝐽𝑜ℎ𝑛, 𝑦/𝐽𝑜ℎ𝑛}
𝑈𝑁𝐼𝐹𝑌 𝛼, 𝛽 = 𝜃 if 𝛼𝜃 = 𝛽𝜃 → algorithm that finds substitutions
𝑝 𝑞 𝜃
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝐽𝑎𝑛𝑒) {𝑥/𝐽𝑎𝑛𝑒}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑂𝐽)
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑀𝑜𝑡ℎ𝑒𝑟(𝑦))
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑥, 𝑂𝐽)
Chapters 8, 9 32
Unification
How do we find the necessary substitutions?
E.g. we can get the inference immediately if we can find a substitution
𝜃 such that 𝐾𝑖𝑛𝑔(𝑥) and 𝐺𝑟𝑒𝑒𝑑𝑦(𝑥) match 𝐾𝑖𝑛𝑔(𝐽𝑜ℎ𝑛) and
𝐺𝑟𝑒𝑒𝑑𝑦(𝑦), i.e. 𝜃 = {𝑥/𝐽𝑜ℎ𝑛, 𝑦/𝐽𝑜ℎ𝑛}
𝑈𝑁𝐼𝐹𝑌 𝛼, 𝛽 = 𝜃 if 𝛼𝜃 = 𝛽𝜃 → algorithm that finds substitutions
𝑝 𝑞 𝜃
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝐽𝑎𝑛𝑒) {𝑥/𝐽𝑎𝑛𝑒}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑂𝐽) {𝑥/𝑂𝐽, 𝑦/𝐽𝑜ℎ𝑛}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑀𝑜𝑡ℎ𝑒𝑟(𝑦))
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑥, 𝑂𝐽)
Chapters 8, 9 33
Unification
How do we find the necessary substitutions?
E.g. we can get the inference immediately if we can find a substitution
𝜃 such that 𝐾𝑖𝑛𝑔(𝑥) and 𝐺𝑟𝑒𝑒𝑑𝑦(𝑥) match 𝐾𝑖𝑛𝑔(𝐽𝑜ℎ𝑛) and
𝐺𝑟𝑒𝑒𝑑𝑦(𝑦), i.e. 𝜃 = {𝑥/𝐽𝑜ℎ𝑛, 𝑦/𝐽𝑜ℎ𝑛}
𝑈𝑁𝐼𝐹𝑌 𝛼, 𝛽 = 𝜃 if 𝛼𝜃 = 𝛽𝜃 → algorithm that finds substitutions
𝑝 𝑞 𝜃
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝐽𝑎𝑛𝑒) {𝑥/𝐽𝑎𝑛𝑒}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑂𝐽) {𝑥/𝑂𝐽, 𝑦/𝐽𝑜ℎ𝑛}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑀𝑜𝑡ℎ𝑒𝑟(𝑦)) {𝑦/𝐽𝑜ℎ𝑛, 𝑥/𝑀𝑜𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛)}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑥, 𝑂𝐽)
Chapters 8, 9 34
Unification
How do we find the necessary substitutions?
E.g. we can get the inference immediately if we can find a substitution
𝜃 such that 𝐾𝑖𝑛𝑔(𝑥) and 𝐺𝑟𝑒𝑒𝑑𝑦(𝑥) match 𝐾𝑖𝑛𝑔(𝐽𝑜ℎ𝑛) and
𝐺𝑟𝑒𝑒𝑑𝑦(𝑦), i.e. 𝜃 = {𝑥/𝐽𝑜ℎ𝑛, 𝑦/𝐽𝑜ℎ𝑛}
𝑈𝑁𝐼𝐹𝑌 𝛼, 𝛽 = 𝜃 if 𝛼𝜃 = 𝛽𝜃 → algorithm that finds substitutions
𝑝 𝑞 𝜃
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝐽𝑎𝑛𝑒) {𝑥/𝐽𝑎𝑛𝑒}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑂𝐽) {𝑥/𝑂𝐽, 𝑦/𝐽𝑜ℎ𝑛}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑀𝑜𝑡ℎ𝑒𝑟(𝑦)) {𝑦/𝐽𝑜ℎ𝑛, 𝑥/𝑀𝑜𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛)}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑥, 𝑂𝐽) 𝑓𝑎𝑖𝑙
Chapters 8, 9 35
Unification
How do we find the necessary substitutions?
E.g. we can get the inference immediately if we can find a substitution
𝜃 such that 𝐾𝑖𝑛𝑔(𝑥) and 𝐺𝑟𝑒𝑒𝑑𝑦(𝑥) match 𝐾𝑖𝑛𝑔(𝐽𝑜ℎ𝑛) and
𝐺𝑟𝑒𝑒𝑑𝑦(𝑦), i.e. 𝜃 = {𝑥/𝐽𝑜ℎ𝑛, 𝑦/𝐽𝑜ℎ𝑛}
𝑈𝑁𝐼𝐹𝑌 𝛼, 𝛽 = 𝜃 if 𝛼𝜃 = 𝛽𝜃 → algorithm that finds substitutions
𝑝 𝑞 𝜃
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝐽𝑎𝑛𝑒) {𝑥/𝐽𝑎𝑛𝑒}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑂𝐽) {𝑥/𝑂𝐽, 𝑦/𝐽𝑜ℎ𝑛}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑦, 𝑀𝑜𝑡ℎ𝑒𝑟(𝑦)) {𝑦/𝐽𝑜ℎ𝑛, 𝑥/𝑀𝑜𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛)}
𝐾𝑛𝑜𝑤𝑠(𝐽𝑜ℎ𝑛, 𝑥) 𝐾𝑛𝑜𝑤𝑠(𝑥, 𝑂𝐽) 𝑓𝑎𝑖𝑙
Standardizing apart eliminates overlap of variables, e.g.,
𝐾𝑛𝑜𝑤𝑠(𝑥1 , 𝑂𝐽) instead of 𝐾𝑛𝑜𝑤𝑠(𝑥, 𝑂𝐽) in last row
Chapters 8, 9 36
Resolution in FOL
Full first-order version:
𝑙1 … 𝑙𝑘 , 𝑚1 … 𝑚𝑛
𝑙1 … 𝑙𝑖−1 𝑙𝑖+1 … 𝑙𝑘 𝑚1 … 𝑚𝑗−1 𝑚𝑗+1 … 𝑚𝑛 𝜃
where UNIFY 𝑙𝑖 , 𝑚𝑗 = 𝜃.
For example,
𝑅𝑖𝑐ℎ 𝑥 𝑈𝑛ℎ𝑎𝑝𝑝𝑦 𝑥 , 𝑅𝑖𝑐ℎ 𝐾𝑒𝑛
𝑈𝑛ℎ𝑎𝑝𝑝𝑦 𝐾𝑒𝑛
with 𝜃 = {𝑥/𝐾𝑒𝑛}
Apply resolution steps to 𝐶𝑁𝐹 𝐾𝐵 ; complete for FOL
Chapters 8, 9 37
Conversion to CNF in FOL
Everyone who loves all animals is loved by someone:
𝑥 𝑦 𝐴𝑛𝑖𝑚𝑎𝑙 𝑦 ⇒ 𝐿𝑜𝑣𝑒𝑠 𝑥, 𝑦 ⇒ [𝑦 𝐿𝑜𝑣𝑒𝑠 𝑦, 𝑥 ]
1. Eliminate biconditionals and implications:
𝑥 𝑦 𝐴𝑛𝑖𝑚𝑎𝑙 𝑦 𝐿𝑜𝑣𝑒𝑠 𝑥, 𝑦 ⇒ [𝑦 𝐿𝑜𝑣𝑒𝑠 𝑦, 𝑥 ]
𝑥 𝑦 𝐴𝑛𝑖𝑚𝑎𝑙 𝑦 𝐿𝑜𝑣𝑒𝑠 𝑥, 𝑦 [𝑦 𝐿𝑜𝑣𝑒𝑠 𝑦, 𝑥 ]
2. Move inwards: 𝑥, 𝑝 𝑥 𝑝, 𝑥, 𝑝 𝑥 𝑝:
𝑥 𝑦 𝐴𝑛𝑖𝑚𝑎𝑙 𝑦 𝐿𝑜𝑣𝑒𝑠 𝑥, 𝑦 [𝑦 𝐿𝑜𝑣𝑒𝑠 𝑦, 𝑥 ]
𝑥 𝑦 𝐴𝑛𝑖𝑚𝑎𝑙 𝑦 𝐿𝑜𝑣𝑒𝑠 𝑥, 𝑦 [𝑦 𝐿𝑜𝑣𝑒𝑠 𝑦, 𝑥 ]
𝑥 𝑦 𝐴𝑛𝑖𝑚𝑎𝑙 𝑦 𝐿𝑜𝑣𝑒𝑠 𝑥, 𝑦 [𝑦 𝐿𝑜𝑣𝑒𝑠 𝑦, 𝑥 ]
3. Standardize variables: each quantifier should use a different
one
𝑥 𝑦 𝐴𝑛𝑖𝑚𝑎𝑙 𝑦 𝐿𝑜𝑣𝑒𝑠 𝑥, 𝑦 [𝑧 𝐿𝑜𝑣𝑒𝑠 𝑧, 𝑥 ]
Chapters 8, 9 38
Conversion to CNF in FOL
4. Skolemize: a more general form of existential instantiation.
Each existential variable is replaced by a Skolem function of
the enclosing universally quantified variables:
𝑥 𝐴𝑛𝑖𝑚𝑎𝑙 𝐹 𝑥 𝐿𝑜𝑣𝑒𝑠 𝑥, 𝐹 𝑥 𝐿𝑜𝑣𝑒𝑠 𝐺 𝑥 , 𝑥
6. Distribute over :
𝐴𝑛𝑖𝑚𝑎𝑙 𝐹 𝑥 𝐿𝑜𝑣𝑒𝑠 𝐺 𝑥 , 𝑥
[𝐿𝑜𝑣𝑒𝑠 𝑥, 𝐹 𝑥 𝐿𝑜𝑣𝑒𝑠 𝐺 𝑥 , 𝑥 ]
Chapters 8, 9 39
Example knowledge base
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.
Prove that Colonel West is a criminal
Chapters 8, 9 40
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
Chapters 8, 9 41
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Chapters 8, 9 42
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles
Chapters 8, 9 43
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
Chapters 8, 9 44
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
Chapters 8, 9 45
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Chapters 8, 9 46
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Missiles are weapons:
Chapters 8, 9 47
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Missiles are weapons:
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
Chapters 8, 9 48
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Missiles are weapons:
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
An enemy of America counts as “hostile”:
Chapters 8, 9 49
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Missiles are weapons:
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
An enemy of America counts as “hostile”:
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
Chapters 8, 9 50
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Missiles are weapons:
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
An enemy of America counts as “hostile”:
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
West, who is American …
Chapters 8, 9 51
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Missiles are weapons:
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
An enemy of America counts as “hostile”:
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
West, who is American …
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡)
Chapters 8, 9 52
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Missiles are weapons:
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
An enemy of America counts as “hostile”:
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
West, who is American …
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡)
The country Nono, an enemy of America …
Chapters 8, 9 53
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
Nono … has some missiles, i.e., 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑥):
𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 ) and 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 ) (existential instantiation)
… all of its missiles were sold to it by Colonel West
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
Missiles are weapons:
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
An enemy of America counts as “hostile”:
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
West, who is American …
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡)
The country Nono, an enemy of America …
𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Chapters 8, 9 54
Example knowledge base contd.
• 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑥
(𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 )𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
• 𝑂𝑤𝑛𝑠(𝑁𝑜𝑛𝑜, 𝑀1 )
• 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
• 𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠 𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜
𝑥 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
• 𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥)
• 𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥)
• 𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡)
• 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Chapters 8, 9 55
Resolution example
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥) 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙 𝑊𝑒𝑠𝑡
Chapters 8, 9 56
Forward chaining
Similar to forward chaining for propositional logic
Idea: start with the atomic sentences in the knowledge base and apply
Modus Ponens in the forward direction, adding new atomic sentences,
until no further inferences can be made.
Chapters 8, 9 58
Forward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Chapters 8, 9 59
Forward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Chapters 8, 9 60
Forward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Criminal(West)
Chapters 8, 9 61
Properties of forward chaining
Sound and complete for first-order definite clauses
May not terminate in general if is not entailed (because of
function symbols)
This is unavoidable: entailment with definite clauses is
semidecidable
Matching = finding all possible unifiers such that the premise
of a rule unifies with a suitable set of facts in the KB. →
Matching can be expensive!
Chapters 8, 9 62
Backward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Chapters 8, 9 63
Backward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Criminal(West)
Chapters 8, 9 64
Backward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Criminal(West) {x/West}
Chapters 8, 9 65
Backward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Criminal(West) {x/West}
Chapters 8, 9 66
Backward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Criminal(West) {x/West}
Missile(y)
Chapters 8, 9 67
Backward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
Missile(y)
{y/M1}
Chapters 8, 9 68
Backward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
{y/M1}
Chapters 8, 9 69
Backward chaining proof tree
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛 𝑥 𝑊𝑒𝑎𝑝𝑜𝑛 𝑦 𝑆𝑒𝑙𝑙𝑠 𝑥, 𝑦, 𝑧 𝐻𝑜𝑠𝑡𝑖𝑙𝑒 𝑧 ⇒ 𝐶𝑟𝑖𝑚𝑖𝑛𝑎𝑙(𝑥)
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑥 ⇒ 𝑆𝑒𝑙𝑙𝑠(𝑊𝑒𝑠𝑡, 𝑥, 𝑁𝑜𝑛𝑜)
𝐸𝑛𝑒𝑚𝑦 𝑥, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎 ⇒ 𝐻𝑜𝑠𝑡𝑖𝑙𝑒(𝑥) 𝑂𝑤𝑛𝑠 𝑁𝑜𝑛𝑜, 𝑀1
𝑀𝑖𝑠𝑠𝑖𝑙𝑒 𝑥 ⇒ 𝑊𝑒𝑎𝑝𝑜𝑛(𝑥) 𝑀𝑖𝑠𝑠𝑖𝑙𝑒(𝑀1 )
𝐴𝑚𝑒𝑟𝑖𝑐𝑎𝑛(𝑊𝑒𝑠𝑡) 𝐸𝑛𝑒𝑚𝑦(𝑁𝑜𝑛𝑜, 𝐴𝑚𝑒𝑟𝑖𝑐𝑎)
{y/M1} {} {} {}
Chapters 8, 9 70
Properties of backward chaining
Chapters 8, 9 71
Summary
• First-order logic:
• objects and relations are semantic primitives
• syntax: constants, functions, predicates, equality, quantifiers
• Increased expressive power: sufficient to define wumpus world
• Can use inference rules (universal instantiation and existential
instantiation) to propositionalize the inference problem → slow!
• The use of unification to identify appropriate substitutions for variables
is more efficient!
• Modus Ponens + unification = generalized Modus Ponens. Forward-
chaining and backward-chaining algorithms apply this rule to sets of
definite clauses.
• GMP is complete for definite clauses.
• Backward chaining is used in logic programming systems.
• The generalized resolution inference rule provides a complete proof
system for first-order logic, using knowledge bases in CNF.
Chapters 8, 9 72