Chapters 8 & 9 First-Order Logic: Dr. Daisy Tang
Chapters 8 & 9 First-Order Logic: Dr. Daisy Tang
Chapters 8 & 9 First-Order Logic: Dr. Daisy Tang
First-Order Logic
In which we notice that the world is blessed with objects, some of which are
related to other objects, and in which we endeavor to reason about them.
Outline
Why FOL?
Syntax and semantics of FOL
Using FOL
Wumpus world in FOL
Inference in FOL
Two binary
relations
Three unary
relations
One unary
function
a
b d
c e
For example:
Brother(KingJohn,RichardTheLionheart)
Length(LeftLegOf(Richard))
Married(Father(Richard), Mother(John))
Practice:
Male and female are disjoint categories
A sibling is another child of one’s parents
Reflex behavior:
t Glitter(t) BestAction(Grab, t)
breezy or not smelly, the agent can deduce where the pits
are and where the wumpus is
AsHighAs(Everest, Everest)
AsHighAs(Kilimanjaro, Everest)
AsHighAs(Kilimajaro, Everest) and AsHighAs(BenNevis,
Everest)
E.g., from:
x King(x) Greedy(x) Evil(x)
King(John)
y Greedy(y)
Brother(Richard,John)
Theorem:
If a sentence is entailed by the original, first-order KB, then
there is a proof involving just a finite subset of the
propositionalized KB
First instantiation with constant symbols
Then terms with depth 1 (Father(John))
Then terms with depth 2 …
Until the sentence is entailed
Propositionalization approach is
rather inefficient
A First-Order Inference Rule
If there is some substitution θ that makes the premise of the
implication identical to sentences already in the KB, then we
assert the conclusion of the implication, after applying θ
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)
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)
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)
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)
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}
Criminal(x): x is a criminal
Missile(x): x is a missile
Consider a rule:
Owns(Nono, x)Missile(x) Sells(West, x, Nono)
We find all the objects owned by Nono in
constant time per object;
Then, for each object, we check whether it’s a
missile.
If more objects and very few missiles
inefficient
Conjunct ordering problem: NP-hard
Heuristics?
Diff(R, B) Diff(R, G)
Diff(G, R) Diff(G, B)
Diff(B, R) Diff(B, G)
Modification:
At iteration t, we check a rule only if its premise includes a
conjunct pi that unifies with a fact pi’ newly inferred at
iteration t-1
Many real systems operate in an “update” mode wherein
forward chaining occurs in response to each new fact that is
TOLD to the system
Solution?
http://www.cs.toronto.edu/~sheila/384/w11/simple
-prolog-examples.html