Lecture FOL Inference
Lecture FOL Inference
Lecture FOL Inference
First-Order Logic
Inference Rules for FOL
• Inference rules for PL apply to FOL as well. For example, Modus Ponens, And-
Introduction, And-Elimination, etc.
• New sound inference rules for use with quantifiers:
– Universal Elimination
If (Ax)P(x) is true, then P(c) is true, where c is a constant in the domain of x. For
example, from (Ax)eats(Ziggy, x) we can infer eats(Ziggy, IceCream).
• The variable symbol can be replaced by any ground term, i.e., any constant symbol or
function symbol applied to ground terms only.
– Existential Introduction
If P(c) is true, then (Ex)P(x) is inferred.
• For example, from eats(Ziggy, IceCream) we can infer (Ex)eats(Ziggy, x).
• All instances of the given constant symbol are replaced by the new variable symbol. Note
that the variable symbol cannot already exist anywhere in the expression.
– Existential Elimination
From (Ex)P(x) infer P(c).
• For example, from (Ex)eats(Ziggy, x) infer eats(Ziggy, Cheese).
• Note that the variable is replaced by a brand new constant that does not occur in this or
any other sentence in the Knowledge Base. In other words, we don't want to accidentally
draw other inferences about it by introducing the constant. All we know is there must be
some constant that makes this true, so we can introduce a brand new one to stand in for
that (unknown) constant.
Universal instantiation (UI)
• All Greedy kings are evil.
• E.g., x King(x) Greedy(x) Evil(x)
• We can infer any of the following
King(John) Greedy(John) Evil(John)
King(Richard) Greedy(Richard) Evil(Richard)
King(Father(John)) Greedy(Father(John)) Evil(Father(John))
.
.. Every instantiation of a universally quantified sentence is obtained by
substituting a ground term g for the variable.
v
Subst({v/g}, )
for any variable v and ground term g in
• Logic
• x: (J(x) P(x) C(x)) Predicates: J(x): x got a good job
• C(Ankit) C(x): x attends classes
P(x): x does projects
• J(Ankit)
(l1 ··· li-1 li+1 ··· lk m1 ··· mj-1 mj+1 ··· mn)
KB = union(KB, resolvent)
return "success"
Converting FOL sentences to clause form
• Every FOL sentence can be converted to a logically equivalent
sentence that is in a "normal form" called clause form
• Steps to convert a sentence to clause form:
1. Eliminate all <=> connectives by replacing each instance of the form (P
<=> Q) by expression ((P => Q) ^ (Q => P))
2. Eliminate all => connectives by replacing each instance of the form (P
=> Q) by (~P v Q)
3. Reduce the scope of each negation symbol to a single predicate by
applying equivalences such as converting
– ~~P to P
– ~(P v Q) to ~P ^ ~Q
– ~(P ^ Q) to ~P v ~Q
– ~(Ax)P to (Ex)~P
– ~(Ex)P to (Ax)~P
Converting FOL sentences to clause form…
4. Standardize variables: rename all variables so that each quantifier has its
own unique variable name. For example, convert (Ax)P(x) to (Ay)P(y)
if there is another place where variable x is already used.
5. Eliminate existential quantification by introducing Skolem functions.
For example, convert (Ex)P(x) to P(c) where c is a brand new constant
symbol that is not used in any other sentence. c is called a Skolem
constant. More generally, if the existential quantifier is within the scope
of a universal quantified variable, then introduce a Skolem function that
depends on the universally quantified variable.
• For example, (Ax)(Ey)P(x,y) is converted to (Ax)P(x, f(x)). f is called
a Skolem function, and must be a brand new function name that does not
occur in any other sentence in the entire KB.
• Example: (Ax)(Ey)loves(x,y) is converted to (Ax)loves(x,f(x)) where in
this case f(x) specifies the person that x loves.
• (If we knew that everyone loved their mother, then f could stand for the mother-
of function.)
Converting FOL sentences to clause form…
6. Remove universal quantification symbols by first moving them all
to the left end and making the scope of each the entire sentence, and
then just dropping the "prefix" part. E.g., convert (Ax)P(x) to P(x)
Examples:
• 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))))
4. Standardize variables
(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ (Ez)(Q(x,z) ^ ~P(z))))
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))
Conversion to CNF
• Everyone who loves all animals is loved by someone:
x [y Animal(y) Loves(x,y)] [y Loves(y,x)]
▪ Distribute over :
[Animal(F(x)) Loves(G(x),x)] [Loves(x,F(x)) Loves(G(x),x)]
Resolution proof: definite clauses
13 maart 2024 69 AI 1
We need answers to the following questions
G D
{}
R1: K(J,T) C
{a/J,b/T}
R2: AL(J) A(T) B
{x/J}
R3: D(y) O(J,y) A(T) A1
{y/D}
R4: O(J,D), A(T) A2
{}
R5: A(T) F
{z/T}
R6: C(T) A
{}
R7: FALSE