First-Order Logic (FOL) : Aka. Predicate Calculus
First-Order Logic (FOL) : Aka. Predicate Calculus
Adapted from:
Tuomas Sandholm
Carnegie Mellon University
Computer Science Department
Backward chaining
Generalized Modus Ponens
Forward chaining
Fall 2014, CSE 814 Overview of Predicate Logic & 8
Automated Reasoning
Example of forward chaining
Forward chaining: Start with the hypotheses; repeatedly use GMP to derive
new sentences until the conclusion is derived.
Example:
Given: All cats like fish, cats eat everything they like, and Ziggy is a cat.
Therefore: Ziggy eats fish
Hypotheses in Horn FOL:
1. cat(x) => likes(x, Fish)
2. (cat(x) ^ likes(x,y)) => eats(x,y)
3. cat(Ziggy)
Conclusion in Horn FOL: eats(Ziggy,Fish)
FC GMP Proof:
4. Use GMP with 1, 3, and [x/Ziggy] to derive: likes(Ziggy,Fish)
5. Use GMP with 3, 4, 2 and [y/Fish, x/Ziggy] to
derive eats(Ziggy, Fish)
Conclusion:
likes(Ziggy, Robin)
R: likes(Ziggy, Sebastian)
likes(Ziggy, Mickey)
q: likes(Ziggy, Robin) bird(Robin)
Conclusion:
likes(Ziggy, Robin)
g likes(Ziggy, Robin)
W’ cat(Ziggy)
rodent(Robin)
H’ cat(x) ^ fish(y) => likes(x, y)
cat(x) ^ rodent(y) => likes(x, y) cat(Ziggy)
cat(x) ^ bird(y) => likes(x, y) bird(Robin)
g cat(Ziggy)
G’ True cat(Ziggy)
fish(Robin) bird(Robin)
Fall 2014, CSE 814 Overview of Predicate Logic & 18
Automated Reasoning
3rd call to (BC) infer
H cat(x) ^ fish(y) => likes(x, y) G True
cat(x) ^ rodent(y) => likes(x, y) fish(Robin)
cat(x) ^ bird(y) => likes(x, y)
flies(x) ^ feathers(x) => bird(x) W
cat(Ziggy) cat(Ziggy)
fish(Sebastian) rodent(Robin)
rodent(Mickey) cat(Ziggy)
flies(Robin) bird(Robin)
feathers(Robin)
g fish(Robin)
H’
And so on …
• Example
– From P(x, f(a)) v P(x, f(y)) v Q(y,x) and
~P(z, w) v ~Q(z,w)
with substitution [x/z, w/f(a)]:
– Infer:
P(z, f(y)) v Q(y,z) v ~Q(z,f(a))
return "success"
• Goal: IWin
Heads v Tails
YouLose
~Tails v YouLose
IWin
~YouLose v IWin
~IWin v YouLose
Fall 2014, CSE 814 Overview of Predicate Logic & 28
Automated Reasoning
Problems yet to be addressed
• Resolution rule requires sentences in clause form:
P1 v P2 v ... v Pn,
where each Pi is a literal (negated or nonnegated
predicate applied to functions, constants, or variables).
• Resolution strategy
– How to pick which pair of sentences to resolve?
– How to pick which pair of literals to unify?
~P(f(y,h(y))) V ~p(g(w))
~p(g(w))
[v/f(y,h(y)]
False
P(v) [v/g(w)]
S(x1)
[x1/x3]
1. S(x1) v M(x1))
L(x3, Snow)
[x4/Snow,
x3/Ellen]
3. ~S(x3) v L(x3, Snow)
~L(Tony, x4)
[x4/Snow,
x3/Ellen]
7. L(Tony, Snow)
S(x1)
[x1/x3]
1. S(x1) v M(x1))
L(x3, Snow)
[x4/Snow,
x3/Ellen]
3. ~S(x3) v L(x3, Snow)
~L(Tony, x4)
[x4/Snow,
x3/Ellen]
To find a witness:
use the substitutions to rewrite original 7. L(Tony, Snow)
(unnegated) goal:
M(Ellen) ^
M(x7) ^ ~S(x7) M(x1) ^ ~S(x1) M(x3) ^ ~S(x3)
~S(Ellen)