Predicate Logic (Resolution)

Download Report

Transcript Predicate Logic (Resolution)

First Order Logic Resolution
Dr. Rogelio Dávila Pérez
Profesor-Investigador
División de Posgrado
Universidad Autónoma de Guadalajara
[email protected]
Unification
We can represent any substitution by a set of ordered pairs:
s = { t1/v1, t2/v2, …, tn/vn}
where: ti/vi means that the term i substitutes variable i
throughout the expression.
e.g.
s1 = {b/x, a/y, a/z}
Note:
- every occurrence of a variable should be substituted by the
same term.
- no variable can be replaced by a term that contains the same
variable.
Def. To denote a substitution instance of an expression E, using a
substitution s, we write: Es.
Unification
Def. Finding substitutions of terms for variables to make two or
more expressions identical is called unification.
e.g.
{p(g(x,f(y)),a), p(g(b,f(z)),y)} ==> p(g(b,f(a)),a)
Def. A substitution instance of an expression is obtained by
substituting terms for variables in that expression.
Def. A ground instance of an expression is one in which there are
no variables (and consequently, no quantifiers).
Def. An instance of an expression which results from changing just
the names of the variables in it, is called an alphabetic variant
of the original.
e.g.
x.p(x,f(x,b)) ==> z.p(z,f(z,b))
Unification
Def. A composition of two substitutions s1 and s2 is written s1s2,
and it is accomplished following the steps:
- apply s2 to the elements of s1.
- add any pairs of s2 having variables not occurring in s1.
e.g.
s1={g(x,y)/z}, s2={a/x, b/y, c/w, d/z}
s1s2 ==> {g(a,b)/z, a/x, b/y, c/w}
s2s1 ==> {a/x, b/y, c/w, d/z} = s2
Some properties of composition are:
1. (Es1)s2=E(s1s2)
2.
s1(s2s3)=(s1s2)s3
Unification
Def. We say that a set {Ei} of expressions is unifiable if there exists
a substitution s that makes: E1s=E2s=…=Ens.
Def. If a substitution g has the property that if s is a unifier of {Ei}
yielding {Ei} s, then there exists a substitution s’ such that
{Ei} s={Ei} gs’, then g is called the most general unifier mgu.
For the unify procedure presented next, it is assumed that its
arguments are two lists of expressions. e.g.
g(r(x,f(z)),y) ==> [g, [r, x, [f, z ]], y]
g(r(a, y), u) ==> [g, [r, a, y], u]
Unification Algorithm
Procedure UNIFIY (E1, E2)
If either E1 or E2 is an atom
{ if E1 and E2 are identical, return NIL
if E1 is a variable, do:
{ if E1 occurs in E2, return FAIL
return {E2/E1}
}
if E2 is a variable, return {E1/E2}
return FAIL
}
F1  the first element of E1
T1  the rest of E1
F2  the first element of E2
T2  the rest of E2
Z1  UNIFY(F1, F2)
If Z1 = FAIL, return FAIL
G1  result of applying Z1 to T1
G2  result of applying Z1 to T2
Z2  UNIFY(G1, G2)
If Z2 = FAIL, return FAIL
Return the composition of Z1 and Z2
________________________
Procedure taken from Nilsson N.J.
“Principles of Artificial Intelligence”,
Tioga Publishing, California 1980.
Clausal Form
Conjunctive normal form: any formula of the predicate calculus
can be transformed into a conjunctive normal form.
Def. A formula is said to be in conjunctive normal form if it
consists in the conjunction of clauses.
A1  A2  …  An where Ai is a clause.
Def. A formula is said to be a clause if it consists in a disjunction of
literals. A clause has the following form:
L1 v L2 v … v Lm where Li is a literal.
Def. A literal is an atomic formula or the negation of an atomic
formula.
Def. A formula is said to be in clausal form if it can be expressed as a set
of clauses:
{C1 , … , Cn,}
where Ci is a clause
Transforming to Clausal Form
1. Eliminate implication symbols (), using the identity:
    ~ v 
2. Introduce negation: reduce scopes of negation symbols by
repeatedly applying the De Morgan rules and the quantifier
identities:
(i) ~( v )  ~  ~
(ii) ~(  )  ~ v ~
 x. ~(x)
(iv) ~x. (x)  x. ~(x)
(iii) ~x. (x)
Transforming to Clausal Form
3. Transform into prenex normal form:
Def. A formula is in prenex normal form if it consists in a list of
quantifiers called prefix, followed by a quantifier-free formula
called the matrix.
Procedure
(i) Standardize variables: re-name variables.
(ii) Eliminate existential quantifiers: replace all existential
quantifier’s variables by skolem functions of all the
universal quantified variables which are over the scope of
the existential quantifier.
(iii) Move all quantifiers to the left: there remain only universal
quantifiers.
Transforming to Clausal Form
4. Put matrix in conjunctive normal form by repeatedly using the
distributive laws:
(i)  v (  )  ( v )  ( v )
(ii)   ( v )  (  ) v (  )
5. Eliminate universal quantifiers.
6. Eliminate conjunction () symbols separating in clauses.
7. Rename variables.
Predicate logic resolution

Example:
x. (p(x)  {y. [p(y)  p(f(x,y))]  ~y. [q(x,y)p(y)]})
===> gets transformed into the following clauses:
c1:
~p(x1) v ~p(y) v p(f(x1,y))
c2:
~p(x2) v q(x2, g(x2))
c3:
~p(x3) v ~p(g(x3))
Resolution Refutation Systems
We can use production systems to show that a given formula,
called the goal, is a theorem derivable from a set of formulas
(they provide the state description).

These production systems are called theorem proving systems
or deduction systems.

Resolution Refutation Systems are based in the following
principle:

 =  if and only if,   {~} =
Resolution Refutation Systems
Resolution refutation procedure
In general a resolution refutation proving that an arbitrary wff

fallows from a set of wffs ,  |= , proceeds as follows:
1. Convert the wffs in  to clausal form.
2. Negate the formula
 to be proved and convert the resulting
formula, ~ , into to clausal form.
3. Combine the clauses resulting form steps 1 and 2 into a single
set, .
4. Iteratively apply resolution to the clauses in  and add the
results to  either until there are no more resolvents that can
be added or until the empty clause is produced.
Resolution Refutation Systems
Def. Resolution Rule:
p v q1 v q 2 v … v q n
~p v r1 v r2 v … v rm
-------------------------------------------------
q1 v … v qn v r1 v … v rm
e.g.
1. Whoever can read is a literate. Dolphins are not literate.Some dolphins
are intelligent. Hence, some who are intelligent can not read.
2. (c1) p(x,f(a)) v p(x,f(y)) v q(y)
(c2) ~p(z,f(a)) v ~q(z)
Resolution Refutation Systems
Example:
1.
2.
3.
4.
5.
Tiger and savages animals are fierce or destructives.
If there is something destructive in the room, then something in the
room will get damaged.
Tim is a tiger.
Tim is a savage animal.
Tim is in the room but it is not fierce.
Prove using resolution that something in the room will get damaged.
Predicate logic resolution
Important results

Completeness of resolution refutation: the empty clause will be
produced by the resolution refutation procedure if  |= ,
thus we say that predicate calculus resolution is refutation
complete.

Decidability of predicate calculus resolution refutation: We say
that resolution refutation in predicate calculus is
semi-decidable as it terminates by generating the empty
clause if  |=
, but it may never terminate if  | .
Predicate logic resolution

Simplification strategies
Sometimes a set of clauses can be simplified by elimination of certain
clauses or elimination of certain literals in the clauses.
Elimination of tautologies
Any clause containing a literal and its negation may be eliminated. E.g.
p(x) v q(y) v ~ q(y) ==> T
Procedural attachment
Sometimes it is possible to evaluate the truth values of literals:
 v F ==> 
e.g.
p(x) V q(y) V ( 3 >7) ==> p(x) V q(y)
since we already know that 3>7 is false.
Predicate logic resolution
Elimination by subsumption
Def. A clause {Li} subsumes a clause {Mi} if there exists a substitution
s such that {Li}s is a subset of {Mi}. e.g.
p(x) subsumes p(y) v q(z)
p(x) subsumes p(a)
p(x) subsumes p(a) v q(z)
p(x) v q(a) subsumes p(f(a)) v q(a) v r(y)
A clause in an unsatisfiable set that is subsumed by another clause in
the set can be eliminated without affecting the unsatisfiability of the rest
of the set.
Predicate logic resolution
Extracting answers from Resolution Refutations
Many applications of theorem-proving systems involve proving formulas
containing existentially quantified variables and finding values or instances for
these variables. To get an answer the proof method has to be constructive.
E.g.
“If Fido goes wherever John goes and if John is at school, where is Fido?”
To answer this question first we must have to proof of the goal:
z. at(fido,z)
Next: we must extract the answer to the question from this refutation tree. In
order to do that we proceed as follows:
(a) append to each clause arising from the negation of the goal wff its own
negation.
(b) Following the structure of the refutation tree, perform the same resolutions
as before until some clause is obtained at the root.
(c) Use the clause at the root as an answer statement.
Predicate logic resolution
Extracting the answer involves converting a refutation tree (with NIL at the
root) to a proof tree with some statement at the root that can be used
as an answer. The conversion involves converting every clause arising
from the negation of the goal into a tautology. Another example:
For all x, y, there exists a z, such that if
parent(x,y) & parent(y,z)  grandfather(x,z)
And, everyone has a parent: x.y.parent(x,y)
Question: “Do there exists individuals x and y such that x is the
grandparent of y.” it can be expressed as: x.y.g(x, y)
Predicate logic resolution
Universally quantified variables in goals
A problem when a universal quantified variable appears on the goal is that
after the goal is negated we have an existencially quantified variable
which is Skolemized and a function is introduced. What is the
meaning of this Skolem function and how it has to be interpreted
when extracting the answer?
Steps:
1.
A resolution-refutation tree is found by some search process. The
unification subsets of the clauses of the tree are marked.
2.
New variables are substituted for any Skolem functions occurring in
the clauses that result from the negation of the goal wff.
3.
The clauses resulting from the negation of the goal wff are converted
into tautologies by appending to them their own negations.
Predicate logic resolution
4.
5.
A modified proof tree is produced modeling the structure of the
original refutation tree. Each resolution in the modified tree uses a
unification set determined by the unification set used by the
corresponding resolution in the refutation tree.
The clause at the root of the modified tree is the answer statement
extracted by these process.
It can be shown [Luckham and Nilsson, 1971] that in the answer-extracting
process it is correct to replace any Skolem functions in the clauses
coming from the negation of the goal wff with new variables.
_____________________
Luckham, D.C., and Nilsson, N. J. 1971. Extracting information from
resolution proof trees. Artificial Intelligence, 2(1), 27-54.