fol
fol
Slides are mostly adapted from AIMA and MIT Open Courseware,
and Milos Hauskrecht (U. Pittsburgh)
First-order logic
• First-order logic (like natural language) assumes the
world contains
– Objects: people, houses, numbers, colors, baseball games,
wars, …
– Relations: red, round, prime, brother of, bigger than, part
of, comes between, …
– Functions: father of, best friend, one more than, plus,
• (relations in which there is only one value for a given input)
8
FOL Motivation
9
Atomic sentences
• E.g., Brother(KingJohn,RichardTheLionheart)
• > (Length(LeftLegOf(Richard)), Length(LeftLegOf(KingJohn)))
11
Complex sentences
E.g.
Sibling(KingJohn,Richard) Sibling(Richard,KingJohn)
>(1,2) ≤ (1,2)
>(1,2) >(1,2)
12
Quantifiers
Universal quantification, (pronounced as “For all”)
x Cat(x) Mammal(x)
All cats are mammals
• x P is true in a model m
iff P is true with x being each possible object in the model
• x P is true in a model m
iff P is true with x being some possible object in the model
13
Interpretation
19
Semantics
21
Semantics
22
Universal quantification
<variables> <sentence>
x P is true in a model m
iff P is true with x being each possible object in the model
Existential quantification
<variables> <sentence>
x Crown(x) OnHead(x,John)
x P is true in a model m
iff P is true with x being some possible object in the model
Properties of quantifiers
x y is the same as y x, and can be written as x,y
x y is the same as y x , and can be written as x,y
Properties of quantifiers
x P = x P
x P = x P
x P = x P
x P = x P
28
Equality
Writing FOL
Writing FOL
31
Using FOL
The kinship domain:
• Brothers are siblings
x,y Brother(x,y) Sibling(x,y)
• One's mother is one's female parent
m,c Mother(c) = m (Female(m) Parent(m,c))
• “Sibling” is symmetric
x,y Sibling(x,y) Sibling(y,x)
• One's husband is one's male spouse
w,h Husband(h,w) (Male(m) Spouse(h,w))
• Sibling is another child of one’s parents
x,y Sibling(x,y) [(x = y) m,f (m = f) Parent(m,x)
Parent(f,x) Parent(m,y) Parent(f,y)]
32
Inference in
First Order Logic
Artificial Intelligence
Slides are mostly adapted from AIMA and MIT Open Courseware,
Milos Hauskrecht (U. Pittsburgh)
and Max Welling (UC Irvine)
33
Logical Inference
34
Inference Rules
38
Variable Substitutions
θ= SUBST(θ, α)
41
Universal elimination
• Every instantiation of a universally quantified sentence is entailed by it:
v α
Subst({v/g}, α)
for any variable v and ground term g
.
.
{x/Ben}
42
Existential elimination
• For any sentence α, variable v, and constant symbol k that does not
appear elsewhere in the knowledge base:
v α
Subst({v/k}, α)
Crown(C1) OnHead(C1,John)
α
v Subst({g/v}, α)
44
Example Proof
• Instantiating the universal sentence in all possible ways (there are only two ground
terms: John and Richard) , we have:
King(John) Greedy(John) Evil(John)
King(Richard) Greedy(Richard) Evil(Richard)
King(John)
Greedy(John)
Brother(Richard,John)
Reduction contd.
• Every FOL KB can be propositionalized so as to preserve
entailment
– A ground sentence is entailed by new KB iff entailed by original KB
Reduction contd.
Idea: For n = 0 to ∞ do
create a propositional KB by instantiating with depth-n terms
see if α is entailed by this KB
• E.g., from:
x King(x) Greedy(x) Evil(x)
King(John)
y Greedy(y)
Brother(Richard,John)
Subst(θ,q)
Example: x King(x) Greedy(x) Evil(x)
p1' is King(John) p1 is King(x)
p2' is Greedy(y) p2 is Greedy(x)
θ is {x/John, y/John} q is Evil(x)
Subst(θ,q) is Evil(John)
Unification
57
Unification
59
Unification
• 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)
θ = {x/John,y/John} works
• Unify(α,β) = θ if αθ = βθ
p q θ
Knows(John,x) Knows(John,Jane) {x/Jane}}
Knows(John,x) Knows(y, Elizabeth) {x/ Elizabeth,y/John}}
Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)}}
Knows(John,x) Knows(x, Elizabeth) {fail}
Unification
• Backward-chaining
– Works backwards from a query to try to construct a proof
– Can suffer from repeated states and incompleteness
– Useful for query-driven inference
SUBST(COMPOSE(θ1, θ2), p) =
SUBST(θ2, SUBST(θ1, p))
72
Resolution in
First Order Logic
Artificial Intelligence
Slides are mostly adapted from AIMA and MIT Open Courseware
Clausal Form
86
Example
94
More examples
95
Substitutions
97
Unification
98
Unification Algorithm
100
Unify-var subroutine
101
Examples
102
Proving Validity
105
Example
106
Example
107
Green’s Trick
108
Equality
109
Proof Example
110
The Clauses
111
The Query
112
The Proof
113
Hat of D
114