Document

advertisement
ARTIFICIAL INTELLIGENCE
[INTELLIGENT AGENTS PARADIGM]
UNIFICATION
AND ITS ALGORITHM
Professor Janis Grundspenkis
Riga Technical University
Faculty of Computer Science and Information Technology
Institute of Applied Computer Systems
Department of Systems Theory and Design
E-mail: Janis.Grundspenkis@rtu.lv
Unification and Its Algorithm
Modus Ponens can also be applied to
expressions containing variables.
Example:
“All boxers have broken noses and
Lewis is a boxer”
X[boxer(X)  broken nose(X)]
boxer(lewis)
Unification and Its Algorithm
Because the X is universally quantified,
it is possible to substitute any value in
the domain for X:
boxer(lewis)  broken nose (lewis)
Using Modus Ponens the conclusion is
infered:
broken nose(lewis)
Unification and Its Algorithm
Universal instantiation states that if any
universally quantified variable in a true
sentence is replaced by any
appropriate term from the domain, the
result is a true sentence.
For example, if c is from the domain of
X,
Xp(X) allows to infer p(c).
any predicate
Unification and Its Algorithm
To apply inference rules, an inference
system (inference engine) must be
able to determine when two
expressions are the same or match.
In propositional calculus two
expressions match if and only if they
are syntactically identical.
Unification and Its Algorithm
In predicate calculus a decision
process based on universal
instantiation is needed for
determining the variable
substitutions under which two or
more expressions can be made
identical.
Unification and Its Algorithm
The process of finding substitutions
that make two or more expressions
identical is called unification.
Unification is an algorithm for
determining the substitutions
needed to make two predicate
calculus expressions match.
Unification and Its Algorithm
Unification and inference rules
allow to make inferences on a set
of logical assertions.
To do this, the knowledge base must
be expressed in an appropriate
form.
Unification and Its Algorithm
Requirements of this form:
• All variables must be universally
quantified. This allows full freedom
in computing substitutions.
• Existentially quantified variables
may be eliminated by replacing them
with the constants that make the
sentence true.
• Thus all quantifiers can be dropped.
Unification and Its Algorithm
The process of eliminating existentially
quantified variables is complicated
because the value of these
substitutions may depend on the value
of other variables in the expression.
For example, in the sentence:
X Y father(X, Y)
the value of the existentially quantified
variable Y depends on the value of X.
Unification and Its Algorithm
SKOLEMIZATION
Skolemization replaces each
existentially quantified variable with a
function that returns the appropriate
constant as a function of some or all
of the other variables in the sentence.
Unification and Its Algorithm
SKOLEMIZATION (continued)
In the previous example, Y could be
replaced by a Skolem function f(X)
because Y depends on X:
X father (X, f(X)),
which indicates that each X has a father
(the f of that X).
Unification and Its Algorithm
SKOLEMIZATION (continued)
Example:
“Everyone has brain”
X person(X)  Y brain(Y) 
has(X, Y)
If Y is replaced with a constant b the
result will be
X person(X)  brain(b)  has(X, b)
which says that everyone has the same
brain.
Unification and Its Algorithm
SKOLEMIZATION (continued)
In fact, it is needed to say that brain they
have is not necessarily shared:
X person(X)  brain(f(X)) 
has(X, f(X))
where f is a Skolem function name that
does not appear elsewhere in the
knowledge base.
Unification and Its Algorithm
SKOLEMIZATION (continued)
In general, the existentially quantified variable
is replaced by a term that consists of a
Skolem function applied to all the
variables universally quantified outside the
existential quantifier in question.
Skolemization eliminates all existentially
quantified variables, so now universal
quantifiers can be dropped, because any
variable must be universally quantified.
Unification and Its Algorithm
Unification is complicated because a
variable may be replaced by any
term, including other variables and
function expressions of arbitrary
complexity, that may themselves
contain variables.
For example, father(lewis) may be
substituted for X in boxer(X) to infer
that Lewis father has a broken nose.
Unification and Its Algorithm
SUBSTITUTIONS
The notation X/Y indicates that the
variable X is substituted for the
variable Y in the original
expression.
The notation { } denotes the empty
substitution.
Unification and Its Algorithm
SUBSTITUTIONS (continued)
To keep track of substitutions they are
denoted as follows:
{V1  c; V2  V3; V4  f(...) }
Vi (i = 1, 2, 3, 4, ...) are variables
c is the constant
f(...) is a function
A variable is said to be bound to the
value substituted for it.
Unification and Its Algorithm
SUBSTITUTIONS (continued)
Rules for substitutions
• A constant may be systematically
substituted for a variable.
• Any constant is considered a
“ground instance” and may not be
replaced.
• Two different constants can not be
substituted for one variable.
Unification and Its Algorithm
SUBSTITUTIONS (continued)
! If a variable is bound to a constant, that
variable may not be given a new
bindings.
A variable may be replaced by a variable.
A variable may be replaced by a function
expression, as long as the function
expression does not contain that variable.
Unification and Its Algorithm
SUBSTITUTIONS (continued)
!A variable can not be replaced by
a term containing that variable.
For example:
X, cannot be replaced by p(X),
because it creates an infinite
expression: p(p(p(p(...X...)))).
Unification and Its Algorithm
SUBSTITUTIONS (continued)
In general, a problem solving
process will require multiple
inferences and, consequently,
multiple successive unifications.
Logic problem solvers must
maintain consistency of variable
substitutions.
Unification and Its Algorithm
SUBSTITUTIONS (continued)
Any substitutions must be made
consistently across all occurrences of
the variable in both expressions being
matched.
If a variable V1 is substituted for a
variable V2 and later V1 is replaced by
a constant c, then V2 must also reflect
this binding.
Unification and Its Algorithm
SUBSTITUTIONS (continued)
For example:
p(X, Y)  q(X, Y)
p(a, Z)
The substitution is {X  a; Y  Z}
Unification and Its Algorithm
SUBSTITUTIONS (continued)
Modus Ponens
p(a, Z)  q(a, Z)
p(a, Z)
__________________
q(a, Z)
q(W, b)  s(W, b)
The substitution is { W  a; Z  b }
Unification and Its Algorithm
SUBSTITUTIONS (continued)
Modus Ponens
q(a, b)  s(a, b)
q(a, b)
____________________
s(a, b)
Unification and Its Algorithm
SUBSTITUTIONS (continued)
If S and S1 are two substitution sets,
then the composition SS1 of S
and S1 is obtained by applying S
to the elements of S1 and adding
the result to S.
Unification and Its Algorithm
SUBSTITUTIONS (continued)
For example, the sequence of substitutions
S = {Y/X, U/V}, S1 = {W/Y},
S2 = {a/W, f(b) / U}
is equivalent to the single substitution
{a/X, f(b)/V}.
This is produced by composing SS1 to yield
SS1= {W/X, U/V} and then composing
SS1S2 = {a/X; f(b)/V}.
Unification and Its Algorithm
UNIFICATION ALGORITHM
unify((boxer X(father X)), (boxer lewis Y))
The function will attempt to recursively unify
the first elements of each expression and
apply substitutions to the rest.
1. unify(boxer, boxer)
2. return { }
3. unify((X(father X)), (lewis Y))
4. unify(X, lewis)
Unification and Its Algorithm
UNIFICATION ALGORITHM
(continued)
5. return { lewis/X }
6. unify((father lewis), (Y))
7. return { father lewis/Y }
8. unify((), ())
9. return {}
The complete set of substitutions is
{lewis/X, father lewis/Y}
Download