CS 540 Lecture Notes - First-Order Logic
CS 540 Lecture Notes - First-Order Logic
Dyer
Proof:
To prove eats(Ziggy, Fish), first see if this is known from one of the axioms directly.
Here it is not known, so see if there is a Horn clause that has the consequent (i.e., right-
hand side) of the implication matching the goal. Here,
Proof:
1. Goal matches RHS of Horn clause (2), so try and prove new sub-goals cat(Ziggy)
and likes(Ziggy, Fish) that correspond to the LHS of (2)
2. cat(Ziggy) matches axiom (3), so we've "solved" that sub-goal
3. likes(Ziggy, Fish) matches the RHS of (1), so try and prove cat(Ziggy)
4. cat(Ziggy) matches (as it did earlier) axiom (3), so we've solved this sub-goal
5. There are no unsolved sub-goals, so we're done. Yes, Ziggy eats fish.
Unification
Unification is a "pattern matching" procedure that takes two atomic sentences, called literals, as input,
and returns "failure" if they do not match and a substitution list, Theta, if they do match. That is,
unify(p,q) = Theta means subst(Theta, p) = subst(Theta, q) for two atomic sentences p and q.
Theta is called the most general unifier (mgu)
All variables in the given two literals are implicitly universally quantified
To make literals match, replace (universally-quantified) variables by terms
Unification algorithm
procedure unify(p, q, theta)
Scan p and q left-to-right and find the first corresponding
terms where p and q "disagree" ; where p and q not equal
If there is no disagreement, return theta ; success
Let r and s be the terms in p and q, respectively,
where disagreement first occurs
If variable(r) then
theta = union(theta, {r/s})
unify(subst(theta, p), subst(theta, q), theta)
else if variable(s) then
theta = union(theta, {s/r})
unify(subst(theta, p), subst(theta, q), theta)
else return "failure"
end
Examples
Literal 1 Literal 2 Result of Unify
parents(x, father(x),
parents(Bill, father(Bill), y) {x/Bill, y/mother(Bill)}
mother(Bill))
parents(x, father(x), {x/Bill, y/Bill,
parents(Bill, father(y), z)
mother(Bill)) z/mother(Bill)}
parents(x, father(x), parents(Bill, father(y),
Failure
mother(Jane)) mother(y))
Unify is a linear time algorithm that returns the most general unifier (mgu), i.e., a shortest length
substitution list that makes the two literals match. (In general, there is not a unique minimum length
substitution list, but unify returns one of those of minimum length.)
A variable can never be replaced by a term containing that variable. For example, x/f(x) is illegal.
This "occurs check" should be done in the above pseudo-code before making the recursive calls.
Goal: IWin
Proof:
Sentence 1 Sentence 2 Resolvent
~IWin ~Heads v IWin ~Heads
~Heads Heads v Tails Tails
Tails ~Tails v YouLose YouLose
YouLose ~YouLose v IWin IWin
IWin ~IWin False
Resolution rule of inference is only applicable with sentences that are in the form P1 v P2 v ... v Pn,
where each Pi is a negated or un-negated predicate and contains functions, constants, and universally
quantified variables, so can we convert every FOL sentence into this form?
How to pick which pair of sentences to resolve?
How to pick which pair of literals, one from each sentence, to unify?
Example
Convert the sentence (Ax)(P(x) => ((Ay)(P(y) => P(f(x,y))) ^ ~(Ay)(Q(x,y) => P(y))))
1. Eliminate <=>
Nothing to do here.
2. Eliminate =>
(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ ~(Ay)(~Q(x,y) v P(y))))
3. Reduce scope of negation
(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ (Ey)(Q(x,y) ^ ~P(y))))
4. Standardize variables
(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ (Ez)(Q(x,z) ^ ~P(z))))
5. Eliminate existential quantification
(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ (Q(x,g(x)) ^ ~P(g(x)))))
6. Drop universal quantification symbols
(~P(x) v ((~P(y) v P(f(x,y))) ^ (Q(x,g(x)) ^ ~P(g(x)))))
7. Convert to conjunction of disjunctions
(~P(x) v ~P(y) v P(f(x,y))) ^ (~P(x) v Q(x,g(x))) ^ (~P(x) v ~P(g(x)))
8. Create separate clauses
~P(x) v ~P(y) v P(f(x,y))
~P(x) v Q(x,g(x))
~P(x) v ~P(g(x))
9. Standardize variables
~P(x) v ~P(y) v P(f(x,y))
~P(z) v Q(z,g(z))
~P(w) v ~P(g(w))
Problem Statement
Tony, Shi-Kuo and Ellen belong to the Hoofers Club. Every member of the Hoofers Club is either a
skier or a mountain climber or both. No mountain climber likes rain, and all skiers like snow. Ellen
dislikes whatever Tony likes and likes whatever Tony dislikes. Tony likes rain and snow.
Query
Is there a member of the Hoofers Club who is a mountain climber but not a skier?
Let S(x) mean x is a skier, M(x) mean x is a mountain climber, and L(x,y) mean x likes y, where the
domain of the first variable is Hoofers Club members, and the domain of the second variable is snow
and rain. We can now translate the above English sentences into the following FOL wffs:
1. S(x1) v M(x1)
2. ~M(x2) v ~L(x2, Rain)
3. ~S(x3) v L(x3, Snow)
4. ~L(Tony, x4) v ~L(Ellen, x4)
5. L(Tony, x5) v L(Ellen, x5)
6. L(Tony, Rain)
7. L(Tony, Snow)
8. Negation of the Query: ~M(x7) v S(x7)
Resolution Refutation Proof
Answer Extraction
Ellen!