Lecture FOL Inference

Download as pdf or txt
Download as pdf or txt
You are on page 1of 76

Inference in

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 

• Universal instantiation can be applied to many times to produce many different


consequences.
Existential instantiation (EI)
• For any sentence , variable v, and constant symbol k that
does not appear elsewhere in the knowledge base:
v 
Subst({v/k}, )
• E.g., x Crown(x)  OnHead(x,John) yields:
Crown(C1)  OnHead(C1,John)
provided C1 is a new constant symbol, called a Skolem
constant
• Existential instantiation can be applied only once, and then
existentially quantified sentence can be discarded.
EI versus UI
• UI can be applied several times to add new
sentences; the new KB is logically equivalent to
the old.
• EI can be applied once to replace the existential
sentence; the new KB is not equivalent to the old
but is satisfiable if the old KB was satisfiable.
Reduction to propositional inference
• Suppose the KB contains just the following:
x King(x)  Greedy(x)  Evil(x)
King(John)
Greedy(John)
Brother(Richard,John)

• Instantiating the universal sentence in all possible ways, we have:


King(John)  Greedy(John)  Evil(John)
King(Richard)  Greedy(Richard)  Evil(Richard)
King(John)
Greedy(John)
Brother(Richard,John)

• The new KB is propositionalized: proposition symbols are


John, Richard and also King(John), Greedy(John), Evil(John), King(Richard),
etc.
Problems with propositionalization
• Propositionalization seems to generate lots of
irrelevant sentences.
– E.g., from:
x King(x)  Greedy(x)  Evil(x)
King(John)
y Greedy(y)
Brother(Richard,John)

• It seems obvious that Evil(John), but


propositionalization produces lots of facts such as
Greedy(Richard) that are irrelevant.
– With p k-ary predicates and n constants, there are p·nk instantiations!
Lifting and Unification
• Instead of translating the knowledge base to
PL, we can redefine the inference rules into
FOL.
– Lifting; they only make those substitutions that are required
to allow particular inferences to proceed.
– E.g. generalised Modus Ponens
• To introduce substitutions different logical expressions have to be
look identical
– Unification
Unification
• Unification is a method of determining if two expressions are possible to be
unified, that is, made identical using suitable substitutions for their variables.
• UNIFY(p, q) accepts 2 atomic sentences as inputs and returns a substitution
which renders them equivalent.
• UNIFY(p,q) = 
• Where SUBST(, p) = SUBST(, q),  is called a unifier
• Example:
– UNIFY(brother(x,y), brother(joy,Deep))= {x/joy, y/Deep)

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)
Knows(John,x) Knows(y,OJ)
Knows(John,x) Knows(y,Mother(y))
Knows(John,x) Knows(x,OJ)

• Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)


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,OJ)
Knows(John,x) Knows(y,Mother(y))
Knows(John,x) Knows(x,OJ)

• Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)


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,OJ) {x/OJ,y/John}
Knows(John,x) Knows(y,Mother(y))
Knows(John,x) Knows(x,OJ)

• Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)


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,OJ) {x/OJ,y/John}
Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)}}
Knows(John,x) Knows(x,OJ)

• Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)


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,OJ) {x/OJ,y/John}
Knows(John,x) Knows(y,Mother(y)) {y/John,x/Mother(John)}}
Knows(John,x) Knows(x,OJ) {fail}

• Standardizing apart eliminates overlap of variables, e.g., Knows(z17,OJ)


Unification
• To unify Knows(John,x) and Knows(y,z),
 = {y/John, x/z } or  = {y/John, x/John, z/John}

• The first unifier is more general than the second.


• There is a single most general unifier (MGU) that
is unique up to renaming of variables.
MGU = { y/John, x/z }
The unification algorithm
The unification algorithm
Generalized Modus Ponens (GMP)
This rule basically combines the three rules of natural deduction:
1. Universal elimination, 2. introduction, and 3. modus ponens
p1', p2', … , pn', ( p1  p2  …  pn q)
where pi' = pi for all i
SUBST( , q)

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)
q is Evil(John)

• GMP used with KB of definite clauses (exactly one


positive literal).
• All variables assumed universally quantified.
Soundness of GMP
• Need to show that
p1', …, pn', (p1  …  pn  q) |= q

provided that pi' = pi for all I

• LEMMA: For any sentence p, we have p |= p by UI


1. (p1  …  pn  q) |= (p1  …  pn  q) = (p1  …  pn  q)
2. p1', …, pn' |= p1'  …  pn' |= p1'  …  pn'
3. From 1 and 2, q follows by ordinary Modus Ponens.
Example
Students who get a good job either do projects or attend classes.
“Ankit did not attend every class”. “Ankit got a job”.

• 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)

1. x: (J(x)  P(x)  C(x)) hypothesis


2. J(Ankit)  P(Ankit)  C(Ankit) – universal instantiation
3. J(Ankit) – hypothesis
4. P(Ankit)  C(Ankit) modus ponens using 2 and 3
5. C(Ankit) – hypothesis
6. P(Ankit) - disjunctive syllogism using 4 and 5
Therefore Ankit must have done projects
Example knowledge base
• The law says that it is a crime for an
American to sell weapons to hostile nations.
The country Nono, an enemy of America,
has some missiles, and all of its missiles
were sold to it by Colonel West, who is
American.

• Prove that Col. West is a criminal


Example knowledge base contd.
... it is a crime for an American to sell weapons to
hostile nations:
Example knowledge base contd.
... it is a crime for an American to sell weapons to
hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Example knowledge base contd.
... it is a crime for an American to sell weapons to
hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles
Example knowledge base contd.
... it is a crime for an American to sell weapons to
hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
Example knowledge base contd.
... it is a crime for an American to sell weapons to
hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Example knowledge base contd.
... it is a crime for an American to sell weapons to
hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Example knowledge base contd.
... it is a crime for an American to sell weapons to
hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Missiles are weapons:
Example knowledge base contd.
... it is a crime for an American to sell weapons to hostile
nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Missiles are weapons:
Missile(x)  Weapon(x)
Example knowledge base contd.
... it is a crime for an American to sell weapons to hostile
nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Missiles are weapons:
Missile(x)  Weapon(x)
An enemy of America counts as "hostile“:
Example knowledge base contd.
... it is a crime for an American to sell weapons to hostile
nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Missiles are weapons:
Missile(x)  Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America)  Hostile(x)
Example knowledge base contd.
... it is a crime for an American to sell weapons to hostile
nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Missiles are weapons:
Missile(x)  Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America)  Hostile(x)
West, who is American …
Example knowledge base contd.
... it is a crime for an American to sell weapons to hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x)  Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Missiles are weapons:
Missile(x)  Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America)  Hostile(x)
West, who is American …
American(West)
Example knowledge base contd.
... it is a crime for an American to sell weapons to hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x)  Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Missiles are weapons:
Missile(x)  Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America)  Hostile(x)
West, who is American …
American(West)
The country Nono, an enemy of America …
Example knowledge base contd.
... it is a crime for an American to sell weapons to hostile nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
Nono … has some missiles, i.e., x Owns(Nono,x)  Missile(x):
Owns(Nono,M1) and Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
Missiles are weapons:
Missile(x)  Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America)  Hostile(x)
West, who is American …
American(West)
The country Nono, an enemy of America …
Enemy(Nono,America)
Forward chaining algorithm
• Forward chaining begins with atomic sentences in the knowledge base
and proceeds to apply inference rules to derive new information until
an endpoint or a goal is achieved.
• A forward-chaining algorithm
– Begin with facts that are known.
– Proceed to trigger all the inference rules whose premises are satisfied
– and then add the new data derived from them to the known facts,
– repeating the process till the goal is achieved or the problem is solved.
Forward chaining algorithm
Forward chaining example
Forward chaining example
Forward chaining example
Properties of forward chaining
• Sound and complete for first-order definite clauses.
– Cfr. Propositional logic proof.

• Datalog = first-order definite clauses + no functions (e.g.


crime KB)
– FC terminates for Datalog in finite number of iterations

• May not terminate in general DF clauses with functions if


 is not entailed
– This is unavoidable: entailment with definite clauses is semidecidable
Efficiency of forward chaining
• Incremental forward chaining: no need to match a rule on iteration
k if a premise wasn't added on iteration k-1
– match each rule whose premise contains a newly added positive literal.

• Matching itself can be expensive:


• Database indexing allows O(1) retrieval of known facts
– e.g., query Missile(x) retrieves Missile(M1)

• Matching conjunctive premises against known facts is NP-hard.


(Pattern matching)

• Forward chaining is widely used in deductive databases


Hard matching example
Diff(wa,nt)  Diff(wa,sa)  Diff(nt,q) 
Diff(nt,sa)  Diff(q,nsw)  Diff(q,sa) 
Diff(nsw,v)  Diff(nsw,sa)  Diff(v,sa) 
Colorable()

Diff(Red,Blue) Diff (Red,Green)


Diff(Green,Red) Diff(Green,Blue)
Diff(Blue,Red) Diff(Blue,Green)

• Colorable() is inferred iff the CSP has a solution


• CSPs include 3SAT as a special case, hence matching is NP-hard

Backward chaining example
• These algorithms work backward from the goal, chaining
(linking and traversing) through rules while fining pre-
established facts that support the proof.
– Ask whether the KB contains the clause of the farm lhs
= rhs, where
• lhs is s a list of conjuncts
– Example: American(west) is a clause with lhs is
the empty list
– Now, prove a query that contains variables with the
substitution.
• Is a kind of or/and search- conjuncts and disjuncts
Backward chaining example

• It is a kind of or/and search- conjuncts and


disjuncts
– The or part because the goal query can be
proved by any rule in the KB
– And part because all the conjuncts in the lhs of
a clause must be proved.
Backward chaining example
• Step 1: Start with query
• Step 2: Check if it can be derived by given
rules and facts. Apply rules that infer the
query.
• Recursion over pre-conditions done
Backward chaining algorithm

SUBST(COMPOSE(1, 2), p) = SUBST(2, SUBST(1, p))


Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining example
Properties of backward chaining

• Depth-first recursive proof search: space is linear


in size of proof.
• Incomplete due to infinite loops
– fix by checking current goal against every goal on stack
• Inefficient due to repeated subgoals (both success
and failure)
– fix using caching of previous results (extra space!!)
• Widely used for logic programming
Resolution: brief summary
• Full first-order version:
l1  ···  lk, m1  ···  mn

(l1  ···  li-1  li+1  ···  lk  m1  ···  mj-1  mj+1  ···  mn)

where Unify(li, mj) = .


• The two clauses are assumed to be standardized apart so that they share no variables.

• For example,
Rich(x)  Unhappy(x)
Rich(Ken)
Unhappy(Ken)
with  = {x/Ken}

• Apply resolution steps to CNF(KB  ); complete for FOL


Resolution refutation
• Given a consistent set of axioms KB and goal sentence Q,
show that KB |= Q
• Proof by contradiction: Add Q to KB and try to prove
false.
i.e., (KB |- Q) (KB  Q |- False)
• Resolution is refutation complete: it can establish that a
given sentence Q is entailed by KB, but can’t (in general) be
used to generate all logical consequences of a set of sentences
• Also, it cannot be used to prove that Q is not entailed by KB.
• Resolution won’t always give an answer since entailment is
only semidecidable
– And you can’t just run two proofs in parallel, one trying to
prove Q and the other trying to prove Q, since KB might
not entail either one
Resolution Procedure…
(aka Resolution Refutation Procedure)
• Resolution procedure is a sound and complete inference
procedure for FOL
• Resolution Rule for FOL:
– Given sentences
P1  ...  Pn
Q1  ...  Qm
– in conjunctive normal form:
• each Pi and Qi is a literal, i.e., a positive or negated predicate symbol with its terms,
– if Pj and Qk unify with substitution list θ, then derive the resolvent sentence:
subst(θ, P1 ...  Pj-1  Pj+1 ... Pn  Q1  …Qk-1  Qk+1 ...  Qm)
– Example
• from clause P(x, f(a))  P(x, f(y))  Q(y)
• and clause P(z, f(a))  Q(z)
• derive resolvent P(z, f(y))  Q(y)  Q(z)
• using θ = {x/z}
Resolution Algorithm
procedure resolution-refutation(KB, Q)
;; KB is a set of consistent, true FOL sentences
;; Q is a goal sentence that we want to derive
;; return success if KB |- Q, and failure otherwise
KB = union(KB, ~Q)
while false not in KB do
pick 2 sentences, S1 and S2, in KB that contain
literals that unify (if none, return "failure“)

resolvent = resolution-rule(S1, S2)

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)

7. Distribute "and" over "or" to get a conjunction of disjunctions called


conjunctive normal form.
• convert (P ^ Q) v R to (P v R) ^ (Q v R)
• convert (P v Q) v R to (P v Q v R)

8. Split each conjunct into a separate clause, which is just a disjunction


("or") of negated and nonnegated predicates, called literals

9. Standardize variables apart again so that each clause contains


variable names that do not occur in any other clause
Converting FOL sentences to clause form…

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))))

3. Reduce scope of negation


(Ax)(~P(x) v ((Ay)(~P(y) v P(f(x,y))) ^ (Ey)(Q(x,y) ^ ~P(y))))
Converting FOL sentences to clause form…

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)))
Converting FOL sentences to clause form…

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))
Conversion to CNF
• Everyone who loves all animals is loved by someone:
x [y Animal(y)  Loves(x,y)]  [y Loves(y,x)]

• Eliminate biconditionals and implications


x [y Animal(y)  Loves(x,y)]  [y Loves(y,x)]
• Move  inwards: x p  x p,  x p  x p
x [y (Animal(y)  Loves(x,y))]  [y Loves(y,x)]
x [y Animal(y)  Loves(x,y)]  [y Loves(y,x)]
x [y Animal(y)  Loves(x,y)]  [y Loves(y,x)]
Conversion to CNF contd.
▪ Standardize variables: each quantifier should use a different one:
x [y Animal(y)  Loves(x,y)]  [z Loves(z,x)]

▪ Skolemize: a more general form of existential instantiation.Each existential


variable is replaced by a Skolem function of the enclosing universally
quantified variables:
x [Animal(F(x))  Loves(x,F(x))]  Loves(G(x),x)

▪ Drop universal quantifiers:


[Animal(F(x))  Loves(x,F(x))]  Loves(G(x),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

• How to convert FOL sentences to conjunctive normal


form (a.k.a. CNF, clause form): normalization and
skolemization
• How to unify two argument lists, i.e., how to find
their most general unifier (mgu) : unification
• How to determine which two clauses in KB should
be resolved next (among all resolvable pairs of
clauses) : resolution (search) strategy
An example
(x)(P(x) → ((y)(P(y) → P(f(x,y)))  (y)(Q(x,y) → P(y))))
2. Eliminate →
(x)(P(x)  ((y)(P(y)  P(f(x,y)))  (y)(Q(x,y) 
P(y))))
3. Reduce scope of negation
(x)(P(x)  ((y)(P(y)  P(f(x,y))) (y)(Q(x,y)  P(y))))
4. Standardize variables
(x)(P(x)  ((y)(P(y)  P(f(x,y))) (z)(Q(x,z)  P(z))))
5. Eliminate existential quantification
(x)(P(x) ((y)(P(y)  P(f(x,y))) (Q(x,g(x))  P(g(x)))))
6. Drop universal quantification symbols
(P(x)  ((P(y)  P(f(x,y))) (Q(x,g(x))  P(g(x)))))
Example
7. Convert to conjunction of disjunctions
(P(x)  P(y)  P(f(x,y)))  (P(x)  Q(x,g(x))) 
(P(x)  P(g(x)))
8. Create separate clauses
P(x)  P(y)  P(f(x,y))
P(x)  Q(x,g(x))
P(x)  P(g(x))
9. Standardize variables
P(x)  P(y)  P(f(x,y))
P(z)  Q(z,g(z))
P(w)  P(g(w))
Resolution: Practice example
Did Curiosity kill the cat
• Jack owns a dog. Every dog owner is an animal lover. No animal lover
kills an animal. Either Jack or Curiosity killed the cat, who is named
Tuna. Did Curiosity kill the cat?
• These can be represented as follows:
A. (x) Dog(x)  Owns(Jack,x)
B. (x) ((y) Dog(y)  Owns(x, y)) → AnimalLover(x)
C. (x) AnimalLover(x) → ((y) Animal(y) → Kills(x,y))
D. Kills(Jack,Tuna)  Kills(Curiosity,Tuna)
E. Cat(Tuna)
F. (x) Cat(x) → Animal(x)
G. Kills(Curiosity, Tuna)
GOAL
• Convert to clause form
D is a skolem constant
A1. (Dog(D))
A2. (Owns(Jack,D))
B. (Dog(y), Owns(x, y), AnimalLover(x))
C. (AnimalLover(a), Animal(b), Kills(a,b))
D. (Kills(Jack,Tuna), Kills(Curiosity,Tuna))
E. Cat(Tuna)
F. (Cat(z), Animal(z))
• Add the negation of query:
G: (Kills(Curiosity, Tuna))
• The resolution refutation proof
R1: G, D, {} (Kills(Jack, Tuna))
R2: R1, C, {a/Jack, b/Tuna} (~AnimalLover(Jack),
~Animal(Tuna))
R3: R2, B, {x/Jack} (~Dog(y), ~Owns(Jack, y),
~Animal(Tuna))
R4: R3, A1, {y/D} (~Owns(Jack, D),
~Animal(Tuna))
R5: R4, A2, {} (~Animal(Tuna))
R6: R5, F, {z/Tuna} (~Cat(Tuna))
R7: R6, E, {} FALSE
• The proof tree

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy