sound and complete inference rules in fol - uoacgi.di.uoa.gr/~ys02/siteai2008/resolution2spp.pdf ·...
TRANSCRIPT
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Sound and Complete Inference Rules in FOL
An inference rule i is called sound if
KB |= α whenever KB `i α
An inference rule i is called complete if
KB `i α whenever KB |= α
Generalised Modus-Ponens (equivalently, forward or backwardchaining) is sound and complete for Horn KBs but incompletefor general first-order logic.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example
Let us consider the following formulas:
PhD(x) ⇒ HighlyQualified(x)
¬PhD(x) ⇒ EarlyEarnings(x)
HighlyQualified(x) ⇒ Rich(x)
EarlyEarnings(x) ⇒ Rich(x)
From the above we should be able to infer Rich(Me), but GMPwon’t do it!
Is there a complete inference procedure for FOL?
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
The Resolution Inference Rule
Basic propositional version:α ∨ β, ¬β ∨ γ
α ∨ γor equivalently
¬α ⇒ β, β ⇒ γ
¬α ⇒ γ
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
The Resolution Inference Rule - FOL version
p1 ∨ · · · ∨ pj · · · ∨ pm, q1 ∨ · · · ∨ qk · · · ∨ qn
SUBST (σ, (p1 ∨ · · · ∨ pj−1 ∨ pj+1 ∨ · · · ∨ pm ∨ q1 · · · ∨ qk−1 ∨ qk+1 · · · ∨ qn))
where UNIFY (pj ,¬qk) = σ.
Note: σ is the most general unifier (MGU) of pj and q′k. The literals pj andqk are called complementary literals because each one unifies with thenegation of the other. The resulting disjunction is called a resolvent.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Examples
¬Rich(x) ∨ Unhappy(x), Rich(Me)Unhappy(Me)
with MGU σ = {x/Me}
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Examples (cont’d)
PhD(x) ⇒ HighlyQualified(x)
¬PhD(x) ⇒ EarlyEarnings(x)
HighlyQualified(x) ⇒ Rich(x)
EarlyEarnings(x) ⇒ Rich(x)
Let us try resolution to infer Rich(Me)!
The standard way of showing that KB ` φ by resolution is to add¬φ to the KB and show that we can reach the empty clause byrepeated application of the resolution rule.
In our case, we add ¬Rich(Me).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Examples (cont’d)
Let us first write all our formulas as disjunctions:
¬PhD(x) ∨HighlyQualified(x)
PhD(x) ∨ EarlyEarnings(x)
¬HighlyQualified(x) ∨Rich(x)
¬EarlyEarnings(x) ∨Rich(x)
¬Rich(Me)
Now we can apply resolution repeatedly.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Examples (cont’d)
From
¬Rich(Me)
and
¬HighlyQualified(z) ∨Rich(z)
with MGU σ = {z/Me}, we infer
¬HighlyQualified(Me).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Examples (cont’d)
From
¬Rich(Me)
and
¬EarlyEarnings(w) ∨Rich(w)
using MGU σ = {w/Me}, we infer
¬EarlyEarnings(Me).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Examples (cont’d)
From
¬PhD(x) ∨HighlyQualified(x)
and
PhD(y) ∨ EarlyEarnings(y)
with MGU σ = {x/y}, we infer
HighlyQualified(y) ∨ EarlyEarnings(y).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Examples (cont’d)
From
HighlyQualified(v) ∨ EarlyEarnings(v)
and
¬EarlyEarnings(Me)
using MGU σ = {v/Me}, we infer
HighlyQualified(Me).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Examples (cont’d)
From
HighlyQualified(Me)
and
¬HighlyQualified(Me)
using MGU σ = {}, we infer the empty clause. Thus we havereached a contradiction!
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Conjunctive Normal Form
To be able to do resolution, the given formulas have to be inconjunctive normal form.
Definition. A literal is an atomic formula or the negation of anatomic formula. An atomic formula is also called a positiveliteral, and the negation of an atomic formula is called a negativeliteral. A clause is a disjunction of literals. There is a specialclause called empty which is equivalent to false.
Definition. A FOL formula is in conjunctive normal form(CNF) if it is a conjunction of disjunctions of literals (equivalentlyif it is a set of clauses).
Proposition. Every FOL formula is equivalent to a formula inCNF.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Conversion to CNF
1. Eliminate equivalences and implications using the laws:
(φ ⇔ ψ) ≡ (φ ⇒ ψ ∧ ψ ⇒ φ)
φ ⇒ ψ ≡ ¬φ ∨ ψ
2. Move ¬ inwards using the equivalences
¬(φ ∨ ψ) ≡ ¬φ ∧ ¬ψ
¬(φ ∧ ψ) ≡ ¬φ ∨ ¬ψ
¬(∀x)φ ≡ (∃x)¬φ
¬(∃x)φ ≡ (∀x)¬φ
¬¬φ ≡ φ
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Conversion to CNF (cont’d)
3. Rename variables so that each quantifier has a uniquevariable.
3. Eliminate existential quantifiers.
If an existential quantifier does not occur in the scope of auniversal quantifier, we simply drop the quantifier and replaceall occurences of the quantifier variable by a new constantcalled a Skolem constant.
If an existential quantifier ∃x is within the scope of universalquantifiers ∀y1, . . . , ∀yn, we drop the quantifier and replace alloccurences of the quantifier variable x by the term f(y1, . . . , yn)where f is a new function symbol called a Skolem function.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Conversion to CNF (cont’d)
5. Drop all universal quantifiers.
6. Distribute ∧ over ∨ using the equivalence
(φ ∧ ψ) ∨ θ ≡ (φ ∨ θ) ∧ (ψ ∨ θ)
7. Flatten nested conjunctions or disjunctions. Then, writeeach disjunction on a separate line and standardize variablesapart (i.e., make sure disjunctions use different variables).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example
Let us convert to CNF the following sentence:
(∀x)((∀y)P (x, y) ⇒ ¬(∀y)(Q(x, y) ⇒ R(x, y)))
1. Eliminate implications:
(∀x)(¬(∀y)P (x, y) ∨ ¬(∀y)(¬Q(x, y) ∨R(x, y)))
2. Move ¬ inwards:
(∀x)((∃y)¬P (x, y) ∨ (∃y)(Q(x, y) ∧ ¬R(x, y)))
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example (cont’d)
3. Rename variables:
(∀x)((∃y)¬P (x, y) ∨ (∃z)(Q(x, z) ∧ ¬R(x, z)))
4. Skolemize:
(∀x)(¬P (x, F1(x)) ∨ (Q(x, F2(x)) ∧ ¬R(x, F2(x))))
5. Drop universal quantifiers:
¬P (x, F1(x)) ∨ (Q(x, F2(x)) ∧ ¬R(x, F2(x)))
6. Distribute ∧ over ∨:
(¬P (x, F1(x)) ∨Q(x, F2(x))) ∧ (¬P (x, F1(x)) ∨ ¬R(x, F2(x)))
7. Final form:
¬P (x, F1(x)) ∨Q(x, F2(x))
¬P (x, F1(x)) ∨ ¬R(x, F2(x))
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Resolution: Soundness and Refutation-Completeness
Theorem. (Soundness)Let KB be a knowledge base. If φ can be proved from KB usingresolution then KB |= φ.
Theorem. (Refutation-completeness)If a set ∆ of clauses is unsatisfiable then resolution will derive theempty clause from ∆.
Note: The above theorem holds only if ∆ does not involve equality.
Methodology: If we are asked to prove KB |= α then we negate α
and show that KB ∧ ¬α is unsatisfiable using resolution.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 1
The crime example we saw in a previous lecture:
The law says that it is a crime for an American to sellweapons to hostile nations. The country Nono, an enemyof America, has some missiles, and all of its missiles weresold to it by Colonel West, who is an American.
Use resolution to conclude that West is a criminal.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 1: Formalization in FOL
• “... it is a crime for an American to sell weapons to hostile nations”:
(∀x, y, z) (American(x) ∧Weapon(y) ∧Nation(z)∧Hostile(z) ∧ Sells(x, y, z) ⇒ Criminal(x))
• “Nono ... has some missiles”:
(∃x) (Owns(Nono, x) ∧Missile(x))
• “All of its missiles were sold to it by Colonel West”:
(∀x) (Owns(Nono, x) ∧Missile(x) ⇒ Sells(West, x,Nono))
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 1: Formalization in FOL (cont’d)
• Missiles are weapons:
(∀x) (Missile(x) ⇒ Weapon(x))
• An enemy of America is a “hostile nation”:
(∀x) (Enemy(x,America) ⇒ Hostile(x))
• “West, who is an American”: American(West)
• “The country Nono ...”: Nation(Nono)
• “Nono, an enemy of America ...”:
Enemy(Nono, America), Nation(America)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 1: CNF form
• “... it is a crime for an American to sell weapons to hostilenations”:
¬American(x) ∨ ¬Weapon(y) ∨ ¬Sells(x, y, z)∨¬Hostile(z) ∨ Criminal(x)
• “Nono ... has some missiles”:
Owns(Nono, M1), Missile(M1)
• “All of its missiles were sold to it by Colonel West”:
¬Missile(x) ∨ ¬Owns(Nono, x) ∨ Sells(West, x,Nono)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 1: CNF form (cont’d)
• Missiles are weapons:
¬Missile(x) ∨Weapon(x)
• An enemy of America is a “hostile nation”:
¬Enemy(x,America) ∨Hostile(x)
• “West, who is an American”:
American(West)
• “The country Nono ...”:
Nation(Nono)
• “Nono, an enemy of America ...”:
Enemy(Nono, America), Nation(America)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 1: Proof
American(West)
Missile(M1)
Missile(M1)
Owns(Nono,M1)
Enemy(Nono,America) Enemy(Nono,America)
Criminal(x)Hostile(z)LSells(x,y,z)LWeapon(y)LAmerican(x) > > > >
Weapon(x)Missile(x)L >
Sells(West,x,Nono)Missile(x) Owns(Nono,x)L> >
Hostile(x)Enemy(x,America)L >
Sells(West,y,z)LWeapon(y)LAmerican(West)L > > Hostile(z)L>
Sells(West,y,z)LWeapon(y)L > Hostile(z)L>
Sells(West,y,z)L> Hostile(z)L>L Missile(y)
Hostile(z)L>L Sells(West,M1,z)
> > L Hostile(Nono)L Owns(Nono,M1)L Missile(M1)
> L Hostile(Nono)L Owns(Nono,M1)
L Hostile(Nono)
Criminal(West)L
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 2
Let us assume that we know the following:
Everyone who loves all animals is loved by someone.Anyone who kills an animal is loved by no one.Jack loves all animals.Either Jack or Curiosity killed the cat, who is named Tuna.
From the above facts, can we prove that Curiosity killed Tuna?
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 2: Formalization in FOL
• Everyone who loves animals is loved by someone.
(∀x)((∀y)(Animal(y) ⇒ Loves(x, y)) ⇒ (∃y)Loves(y, x) )
• Anyone who kills an animal is loved by no one.
(∀x)((∃y)(Animal(y) ∧Kills(x, y)) ⇒ (∀z)¬Loves(z, x))
• Jack loves all animals.
(∀x)(Animal(x) ⇒ Loves(Jack, x))
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 2: Formalization in FOL
• Either Jack or Curiosity killed the cat ...
Kills(Jack, Tuna) ∨Kills(Curiosity, Tuna)
• ... who is named Tuna.
Cat(Tuna)
We will also need the formula
(∀x)(Cat(x) ⇒ Animal(x))
which is background knowledge.
The negation of the formula to be proved is:
¬Kills(Curiosity, Tuna)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 2: Proof
Kills(Curiosity,Tuna)LAnimal(x)>Cat(x)L
Animal(Tuna) Kills(Jack,Tuna)
>Kills(Jack,Tuna} Kills(Curiosity,Tuna)
Animal(F(x)) Loves(G(x),x)>
Loves(G(x),x)Loves(x, F(x))L >
Kills(x,z)LAnimal(z)LLoves(y,x)L >>
Loves(G(Jack),Jack)Animal(F(Jack))L >
L Kills(x,Tuna)>Loves(y,x)L > Loves(Jack,x)Animal (x)L
L Loves(y,Jack)
Loves(G(Jack),Jack)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Resolution, Validity and Unsatisfiability
Questions:
• How do we use resolution to prove that the following formula isvalid?
Happy(John) ∨ ¬Happy(John)
• How do we use resolution to prove that the following formula isunsatisfiable?
Happy(John) ∧ ¬Happy(John)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Fill-in-the-Blank Questions
So far we have used resolution to see that something follows from aKB. We can also use resolution to answer questions about factsthat follow from a KB. In the previous example, we can useresolution to find the answer to the question: Who killed Tuna?This can be expressed using a free variable and writing thefill-in-the-blank query Kills(x, Tuna).
Definition. An answer literal for a fill-in-the-blank query φ is anatomic formula of the form Ans(v1, . . . , vn) where the variablesv1, . . . , vn are the free variables in φ.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Fill-in-the-Blank Questions (cont’d)
To answer the fill-in-the-blank query φ we form the disjunction
Ans(v1, . . . , vn) ∨ ¬φ
and convert it to CNF.
Then we use resolution and terminate our search when we reach aclause containing only answer literals (instead of terminating whenwe reach the empty clause).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Fill-in-the-Blank Questions (cont’d)
For fill-in-the-blank questions, we can have:
• Termination with a clause which is a single answerliteral Ans(c1, . . . , cn). In this case, the constants c1, . . . , cn
gives us an answer to the query. There might be more answersdepending on whether there are more resolution refutations ofAns(v1, . . . , vn) ∨ ¬φ. We can go on looking for more answersbut we can never be sure that we have found them all(incompleteness of resolution).
• Termination with a clause which is a disjunction ofmore than one answer literals. In this case, one of theanswer literals contains the answer but we cannot say whichone for sure.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 1
KB:
Father(Art, John)
Father(Bob, Kim)
(∀x)(∀y)(Father(x, y) ⇒ Parent(x, y))
Query: Who is John’s parent?
To answer the query, we use resolution on the following set ofclauses:
Father(Art, John)
Father(Bob, Kim)
¬Father(x, y) ∨ Parent(x, y)
Ans(z) ∨ ¬Parent(z, John)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 1 (cont’d)
From
Father(Art, John)
and
¬Father(x, y) ∨ Parent(x, y)
with MGU {x/Art, y/John}, we have
Parent(Art, John)
which in turn resolves with
Ans(z) ∨ ¬Parent(z, John)
with MGU {z/Art}, to give
Ans(Art).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 2
KB:
Father(Art, John) ∨ Father(Bob, John)
(∀x)(∀y)(Father(x, y) ⇒ Parent(x, y))
Query: Who is John’s parent?
To answer the query, we use resolution on the following set ofclauses:
Father(Art, John) ∨ Father(Bob, John)
¬Father(x, y) ∨ Parent(x, y)
Ans(z) ∨ ¬Parent(z, John)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 2 (cont’d)
From
Father(Art, John) ∨ Father(Bob, John)
and
¬Father(x, y) ∨ Parent(x, y)
with MGU {x/Art, y/John}, we have
Parent(Art, John) ∨ Father(Bob, John)
which in turn resolves with
¬Father(x, y) ∨ Parent(x, y)
with MGU {x/Bob, y/John}, to give
Parent(Art, John) ∨ Parent(Bob, John).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example 2 (cont’d)
From
Parent(Art, John) ∨ Parent(Bob, John)
and
Ans(z) ∨ ¬Parent(z, John)
with MGU {z/Art}, we have
Ans(Art) ∨ Parent(Bob, John)
which in turn resolves with
Ans(z) ∨ ¬Parent(z, John)
with MGU {z/Bob}, to give
Ans(Art) ∨Ans(Bob).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Dealing with Equality
If we want to use equality in our resolution proofs, we can do it intwo ways:
• Add appropriate formulas that axiomatize equality in ourKB. What are these formulas?
• Use special inference rules that take equality into account.
• Use equational unification (a special kind of unification thattakes equality into account).
The same is true for other special predicates such as arithmeticones <, ≤ etc.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Axioms for Equality
• Reflective: (∀x) x = x
• Symmetric: (∀x)(∀y)(x = y ⇒ y = x)
• Transitive: (∀x)(∀y)(∀z)(x = y ∧ y = z ⇒ x = z)
• Substitution of equals:
(∀x)(∀y)(x = y ⇒ (P1(x) ⇔ P1(y)))
(∀x)(∀y)(x = y ⇒ (P2(x) ⇔ P2(y)))
· · ·(∀w)(∀x)(∀y)(∀z)(w = y ∧ x = z ⇒ (F1(w, x) = F1(y, z)))
(∀w)(∀x)(∀y)(∀z)(w = y ∧ x = z ⇒ (F2(w, x) = F2(y, z)))
· · ·
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Inference Rules for Equality: Demodulation
For any terms x, y and z where UNIFY (x, z) = θ and mn[z] is aliteral containing the term z:
x = y, m1 ∨ · · · ∨mn[z]m1 ∨ · · · ∨mn[SUBST (θ, y)]
Examples:
• From TheThief = John and Arrested(TheThief) with MGU{}, we can conclude Arrested(John).
• From S(S(0)) = 2 and P (2) ∨Q(S(S(w))) with MGU {w/0},we can conclude P (2) ∨Q(2).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Inference Rules for Equality: Paramodulation
For any terms x, y and z where UNIFY (x, z) = θ and mn[z] is aliteral containing the term z:
l1 ∨ · · · lk ∨ x = y, m1 ∨ · · · ∨mn[z]SUBST (θ, l1 ∨ · · · ∨ lk ∨m1 ∨ · · · ∨mn[y])
Example: From P (v) ∨ F (A, v) = F (B, v) and Q(B) ∨R(F (A,C))with MGU {v/C}, we can conclude P (C) ∨Q(B) ∨R(F (B,C)).
Paramodulation is more general than demodulation and results in arefutation complete inference procedure for FOL with equality.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Resolution and Prolog
• Prolog is based on a specific form of resolution calledSLD-resolution (Linear resolution with a Selection functionfor Definite clauses).
• The Prolog interpreter does resolution at each step ofproducing a new set of goals from a given set of goals and aclause in the Prolog program.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Horn Clauses
Let us revisit the definition of Horn clauses.
Definition. A Horn clause is a disjunction of literals of whichat most one is positive.
In other words, a Horn clause is a formula in one of the followingthree forms:
q
¬p1 ∨ ¬p2 ∨ . . . ∨ ¬pn ∨ q (or p1 ∧ p2 ∧ . . . ∧ pn ⇒ q)
¬p1 ∨ ¬p2 ∨ . . . ∨ ¬pn
where p1, . . . , pn, q are atomic formulas.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Horn Clauses in Prolog
Horn clauses of the first kind are called facts.
Horn clauses of the second kind are called rules.
If a Horn clause has exactly one positive literal, it is called adefinite clause.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Horn Clauses in Prolog (cont’d)
Facts and rules (i.e., definite clauses) are of the form
q
and
¬p1 ∨ ¬p2 ∨ . . . ∨ ¬pn ∨ q (or p1 ∧ p2 ∧ . . . ∧ pn ⇒ q)
respectively. They are used to write Prolog programs usingProlog’s notation as follows:
q.
q:- p1, p2, ..., pn.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Horn Clauses in Prolog (cont’d)
Horn clauses of the form
¬p1 ∨ ¬p2 ∨ . . . ∨ ¬pn
i.e., consisting of only negative literals can be used as queries inProlog using Prolog’s notation as follows:
?-p1, p2, ..., pn.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Example
predecessor(X, Z) :- %pr1
parent(X, Z).
predecessor(X, Z) :- %pr2
parent(X, Y),
predecessor(Y, Z).
parent(pam, bob). parent(bob, ann).
parent(tom, bob). parent(bob, pat).
parent(tom, liz). parent(pat, jim).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Proof Tree for predecessor(pam,bob)
predecessor(pam, bob)
parent(pam, bob)
by rule pr1
MGU{X/pam, Y/bob}
yes
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Resolution and Prolog (cont’d)
The Prolog interpreter resolves a query with a fact or rule at eachstep of its operation.
In the previous slide, we want to prove the goal
?− predecessor(pam, bob).
When Prolog uses the rule pr1 to arrive at the new goal
?− parent(pam, bob),
this is equivalent to performing resolution of
¬predecessor(pam, bob)
with Horn clause
¬parent(X,Y ) ∨ predecessor(X,Y )
to produce
¬parent(pam, bob).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Resolution and Prolog (cont’d)
In the next step, the new goal
?− parent(pam, bob)
is unified with the fact
parent(pam, bob)
in the database and Prolog answers yes to the original query.
This is equivalent to performing resolution of
¬parent(pam, bob)
with
parent(pam, bob)
to arrive at the empty clause.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Resolution and Prolog (cont’d)
Thus we see that predecessor(pam, bob) logically follows fromthe Prolog program (viewed as a KB in FOL) thus Prologcorrectly gives the answer yes.
Exercise: Explain the proof trees on the following slides usingresolution.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Proof Tree for predecessor(pam,ann)
predecessor(pam, ann)
parent(pam, ann)
by rule pr1
parent(pam, Y) predecessor(Y, ann)
by rule pr2
no
MGU{X/pam, Z/ann}
,
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Proof Tree for predecessor(pam,ann) (cont’d)
by fact parent(pam, bob)
predecessor(pam, ann)
parent(pam, ann)
by rule pr1
parent(pam, Y) predecessor(Y, ann)
by rule pr2
no
predecessor(bob, ann)
MGU{X/bob}
parent(bob, ann)
by rule pr1
yes
MGU{X/bob, Z/ann}
MGU{X/pam, Z/ann}
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Computational Complexity and Resolution
Resolution proofs can in general be exponentially long as thefollowing theorem demonstrates.
Theorem (Haken, 1985). There is a sequence of PL formulasp1, p2, p3, . . ., each a tautology, such that the number of symbols of¬pn when converted to CNF is O(n3), but the shortest resolutionrefutation of it contains at least cn symbols (for a fixed c > 1).
There are various strategies that can be applied to make resolutionmore efficient in practice (unit preference, set of support,input resolution, subsumption).
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Other Normal Forms: DNF
Definition. A FOL formula is in disjunctive normal form(DNF) if it is a disjunction of conjunctions of literals.
Proposition. Every FOL formula is equivalent to a formula inDNF.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Other Normal Forms: PNF
Definition. A FOL formula is in prenex normal form (PNF) ifall its quantifiers appear at the front of the formula.
Proposition. Every FOL formula is equivalent to a formula inPNF.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Conversion to Prenex Normal Form
• Steps 1 and 2 of conversion to CNF.
• Move quantifiers to the front of the formula using theequivalences
(∀x)(φ ∧ ψ) ≡ (∀x)φ ∧ ψ
(∀x)(φ ∨ ψ) ≡ (∀x)φ ∨ ψ
(∃x)(φ ∧ ψ) ≡ (∃x)φ ∧ ψ
(∃x)(φ ∨ ψ) ≡ (∃x)φ ∨ ψ
The above equivalences hold only if x does not appear free in ψ.
Step 1 and 2 are not necessary if we introduce equivalences for therest of the connectives.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
A Brief History of Reasoning
450b.c. Stoic and Megarian PL, truth tables,
schools inference (modus ponens)
322b.c. Aristotle “syllogisms” (inference rules), quantifiers
1847 Boole PL (again)
1879 Frege FOL
1921/22 Post/Wittgenstein proof by truth tables
1930 Godel ∃ complete algorithm for proofs in FOL
1930 Herbrand complete algorithm for proofs in FOL
(reduce to propositional)
1931 Godel ¬∃ complete algorithm for arithmetic proofs
1960 Davis/Putnam “practical” algorithm for PL resolution
1965 Robinson resolution
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Soundnes and Completeness of FOL Inference
Theorem. (Godel, 1930)KB |= φ iff KB ` φ.
Theorem. Checking entailment (equivalently: validity orunsatisfiability or provability) of a FOL formula is a recursivelyenumerable problem.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Informal Definitions
A yes/no problem P is called recursive or decidable if there is analgorithm that, given input x, outputs “yes” and terminateswhenever x ∈ P , and “no” and terminates when x 6∈ P .
A yes/no problem P is called recursively enumerable orsemi-decidable if there is an algorithm that, given input x,outputs “yes” and terminates whenever x ∈ P but computes forever when x 6∈ P .
The above algorithm is not a very useful because, if it has notterminated, we cannot know for sure whether we have waited longenough to get an answer.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Godel’s Incompleteness Theorem
Theorem. (Godel, 1930)For any set A of true sentences of number theory, and, in particular,any set of basic axioms, there are other true sentences ofnumber arithmetic that cannot be proved from A.
Sad conclusion: We can never prove all the theorems ofmathematics within any given system of axioms.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Soundness and Completeness (cont’d)
Theorem. (Herbrand, 1930)If a finite set ∆ of clauses is unsatisfiable then the Herbrand base of∆ is unsatisfiable.
Theorem. (Robinson, 1965)Soundness of Resolution. If there is a resolution refutation of aclause φ from a set of clauses KB then KB |= φ.
Theorem. (Robinson, 1965)Completeness of Resolution. If a set of clauses KB isunsatisfiable then there is a resolution refutation of the emptyclause from KB.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Soundness and Completeness (cont’d)
Question: How can we use a refutation-complete proof procedure(e.g., resolution) to determine whether a sentence φ is entailed by aset of sentences KB?
Answer: We can negate φ, add it to KB and then use resolution.But we will not know whether KB |= φ until resolution finds acontradiction and returns.
While resolution has not returned, we do not know whether thesystem has gone into a loop or the proof is about to pop out!!!
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Some Good News
There are many interesting subsets of FOL that are decidable:
• Monadic logic (only unary predicates).
• Horn clauses
• ...
Many practical problems can be encoded in these subsets!
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Knowledge-Based Agents
function KB-Agent(percept) returns an action
static KB, a knowledge-baset, a counter, initially 0, indicating time
Tell(KB,Make-Percept-Sentence(percept, t))action ← Ask(KB,Make-Action-Query(t))Tell(KB,Make-Action-Sentence(action, t))t ← t + 1return action
Using the FOL machinery we presented, how can we implementknowledge-based agents?
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Logical Reasoning Systems
• Logic programming languages (most notably Prolog).Prolog was developed in 1972 by Alain Colmerauer and it is based on the
idea of backward chaining. Prolog’s motto (after Kowalski) is:
Algorithm = Logic + Control
Logic programming and Prolog was the basis of much exciting research and
development in logic programming in the 70’s and 80’s.
Logic programming and its extensions is still a very lively area of research
that has been applied in many areas (databases, natural language processing,
expert systems etc.). Of particular, importance is constraint logic
programming (CLP) that integrates logic programming with CSPs. CLP has
been used with success recently in many combinatorial optimisation
applications (e.g., scheduling, planning, etc.)
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Logical Reasoning Systems (cont’d)
• Production systems based on the idea of forward-chaining (wherethe conclusion of an implication is interpreted as an action to beexecuted).
Production systems were used a lot in early AI work (particularly inrule-based expert systems).
There are various implemented production systems such as OPS-5 orCLIPS.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Logical Reasoning Systems (cont’d)
• Theorem provers are more powerful tools than Prolog since they candeal with full first-order logic.
Examples: OTTER, PTTP, etc.
Theorem provers have come up with novel mathematical results (latticetheory, a formal proof of Godel’s incompleteness theorem, Robbinsalgebra).
They are also used in verification and synthesis of both hardware andsoftware because both domains can be given correct axiomatizations.
Teqnht NohmosÔnh M. Koumpar�khc'
&
$
%
Readings
• AIMA, Chapter 9.
• M. Genesereth and N. Nilsson. “Logical Foundations ofArtificial Intelligence”, Chapter 4.
This chapter gives a more formal treatment with detailedproofs of the theorems we presented.
• The book “Mechanizing Proof: Computing, Risk and Trust” byDonald MacKenzie (MIT Press, 2001) is an interestinghistorical and sociological account of automated theoremproving. Read this book for fun when you have time!