| OCR Text |
Show We now illu strate general semantic unification by examples. The function t erms front(add (c , add(a , remove(add (b, newq))))) front ( remove(add(a , add(b, newq)})) 116 are semantically unifiable given the assumption that the equations of Example 10 are co nt ained in EON. Th is is because both terms can be reduced to the atom a. As another example, assume t hat we have the following equations filter(P, []) = [] filter (P, A~L ) = i f P( A) t hen A ~ fi lte r (P, L) else f ilter (P, L). Applying the semantic unif ic ation algo rithm to the following two t erms p(X, filter(odd, [2,5,9])) p(bad, First ~ Rest), we get the unifier ~ = {X = bad, First = 5, Rest = filter(odd, [9])}. The function term filter (odd, [ 9]) is the result of reducing filter (odd, [ 2, 5, 9]) twice. The reductions were driven by the pattern First ~ Rest . This assumes that the function odd is either defined in EON or is a primitive. 6.2.2 Complete Unification Algorithms and Prolog with Equality The notion of semantic unification discussed above is a special case of general unification in the presence of an equational theory. Such a form of general unification is called E-unification, and the corresponding unifiers are called E-unifiers. An equational theory, denoted by =E, can be described by a set of equations. In E-unification, a substitution ~ is an E-unifier of two terms A and B, iff ~(A) =E ~(B). The most general unifier is now no longer necessarily unique. We are typically interested in complete unification algorithms. Infer-mally, given two terms A and B, a complete unification algorithm with respect to an equational theory produces a set of unifiers ~ of A and 8, which is a sub-set of the set of all unifiers of A and 8, such that for every unifier u of A and 8 |