| OCR Text |
Show A Semantic Unification Algorithm Input: Two terms p(s 1, ... ,sn) and p(t 1, ... ,tn), and EON. Output: A failure report or a set of equations t1 = {x1 = m1, x2 = m2, ... , xP = mP} where x. are variables and m. are terms. I I begin I <- {t1 = s1, ... ,tn = sn}; Repeatedly attempt any of the following transformations, if no transformation applies, stop with success. 1. Eliminate any equations of the form x = x. 2. If x and y are distinct variables, x = y is in I and x has other occurrences in I, then replace these occurrences of x by occurrences of y. 3. Replace t = x by x = t if x is a variable and t is not. 4. If x is a variable and t 1 and t 2 are not, replace x = t 1 and x = t 2 by x = t 1 and t 1 = t 2. 5. If an equation is of the form g(t'1, ... ,t' P) = g'(s' 1, ... ,s' q) case a. g is a constructor, and g = g', end. replace the equation by {t' 1 = s'1, ... ,t' P = s' q}; case b. both terms g(t'1, ... ,t'P) and g'(s '1, ... ,s'q) have subterms that are reducible, replace the equation by Reduce(g(t' 1, ... ,t' P)) = Reduce(g'(s'1, ... ,s' q)); case c. g(t' 1 , ... ,t' P) is reducible but g'(s' 1, ... ,s' q) is not, replace the equation by g'(s' 1 , ... ,s' ) = One Step Reduction(g(t'1, ... ,t' )); q - - p case d. g'(s' 1, ... ,s' q) is reducible but g(t' 1 , ... ,t' P) is not, replace the equation by g(t'1, ... ,t' ) = One Step Reduction(g'(s'1, ... ,s' )); p - - q case e. none of the above applies, stop with failure. Figure 18: A semantic unification algorithm 114 |