Information Technology Reference
In-Depth Information
substitution of values for the variables that makes the atoms identical. Here are some
examples:
A query such as likes(john,Y) unifies with likes(john,pizza) in the first
clause of the program, for Y=pizza .
A query such as likes(paul,pizza) unifies with likes(paul,X) in the fourth
clause of the program, for X=pizza .
A query such as likes(jane,Y) unifies with likes(X,icecream) in the last
clause of the program, for X=jane and Y=icecream .
In all three cases, the given queries would eventually succeed.
Note that both the query and the head of a clause from the program may contain
variables. In fact, unification is not concerned with where the atoms come from, which
one is from the query and which one is from the program.
As further examples, the following pairs of atoms will unify:
p(b,X,b) and p(Y,a,b) for X=a and Y=b
p(X,b,X) and p(a,b,Y) for X=a and Y=a
p(b,X,b) and p(Y,Z,b) for X=_G12 , Y=b , and Z=_G12
(In this case, the substitution that unifies the two atoms is not unique in that, for
example, X=c , Y=b , and Z=c also unifies the two atoms.)
p(X,Z,X,Z) and p(Y,W,a,Y) for X=a , Z=a , Y=a and W=a
(In this case, the unifying substitution is unique.)
Here are some examples of pairs of atoms that do not unify:
p(b,X,b) and p(b,Y)
(The two terms cannot be made identical, since the predicates have different
numbers of arguments.)
p(b,X,b) and p(Y,a,a)
(The last arguments are constants that clash.)
p(X,b,X) and p(a,a,b)
(The two occurrences of X are required to match different constants.)
p(X,b,X,a) and p(Y,Z,Z,Y)
(The two occurrences of X force the Y and Z to be equal, but they must also match
a and b , respectively.)
 
Search WWH ::




Custom Search