Unification: a Multidisciplinary Survey
Total Page:16
File Type:pdf, Size:1020Kb
Unification: A Multidisciplinary Survey KEVIN KNIGHT Computer Science Department, Carnegie-Mellon University, Pittsburgh, Pennsylvania 15213-3890 The unification problem and several variants are presented. Various algorithms and data structures are discussed. Research on unification arising in several areas of computer science is surveyed, these areas include theorem proving, logic programming, and natural language processing. Sections of the paper include examples that highlight particular uses of unification and the special problems encountered. Other topics covered are resolution, higher order logic, the occur check, infinite terms, feature structures, equational theories, inheritance, parallel algorithms, generalization, lattices, and other applications of unification. The paper is intended for readers with a general computer science background-no specific knowledge of any of the above topics is assumed. Categories and Subject Descriptors: E.l [Data Structures]: Graphs; F.2.2 [Analysis of Algorithms and Problem Complexity]: Nonnumerical Algorithms and Problems- Computations on discrete structures, Pattern matching; Ll.3 [Algebraic Manipulation]: Languages and Systems; 1.2.3 [Artificial Intelligence]: Deduction and Theorem Proving; 1.2.7 [Artificial Intelligence]: Natural Language Processing General Terms: Algorithms Additional Key Words and Phrases: Artificial intelligence, computational complexity, equational theories, feature structures, generalization, higher order logic, inheritance, lattices, logic programming, natural language processing, occur check, parallel algorithms, Prolog, resolution, theorem proving, type inference, unification INTRODUCTION lem, Unification and Computational Com- plexity, and Unification: Data Structures The unification problem has been studied and Algorithms introduce unification. Def- in a number of fields of computer science, initions are made, basic research is re- including theorem proving, logic program- viewed, and two unification algorithms, ming, natural language processing, compu- along with the data structures they require, tational complexity, and computability are presented. Next, there are four sections theory. Often, researchers in a particular on applications of unification. These appli- field have been unaware of work outside cations are theorem proving, logic pro- their specialty. As a result, the problem has gramming, higher order logic, and natural been formulated and studied in a variety of language processing. The section Unifica- ways, and there is a need for a general tion and Feature Structures is placed before presentation. In this paper, I will elucidate the section on natural language processing the relationships among the various con- and is required for understanding that sec- ceptions of unification. tion. Following are four sections covering The sections are organized as follows. various topics of interest. Unification and The three sections The Unification Prob- Equational Theories presents abstract Permission to copy without fee all or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission. 0 1989 ACM 0360-0300/89/0300-0093 $1.50 ACM Computing Surveys, Vol. 21, No. 1, March 1989 94 l Kevin Knight CONTENTS conclusion gives an abstract of some gen- eral properties of unification and projects research trends into the future. Dividing this paper into sections was a INTRODUCTION difficult task. Some research involving 1. THE UNIFICATION PROBLEM unification straddles two fields. Take, for 2. UNIFICATION AND COMPUTATIONAL example, higher order logic and theorem COMPLEXITY 3. UNIFICATION: DATA STRUCTURES AND proving-should this work be classified as ALGORITHMS Unification and Higher Order Logic or 4. UNIFICATION AND THEOREM PROVING Unification and Theorem Proving? Or 4.1 The Resolution Rule consider ideas from logic programming put 4.2 Research to work in natural language processing-is 5. UNIFICATION AND LOGIC PROGRAMMING it Unification and Logic Programming or 5.1 Example of Unification in Prolog Unification and Natural Language Pro- 5.2 Research cessing? Likewise, some researchers work 6. UNIFICATION AND HIGHER ORDER in multiple fields, making their work hard LOGIC 6.1 Example of Second-Order Unification to classify. Finally, it is sometimes difficult 6.2 Research to define the boundary between two disci- 7. UNIFICATION AND FEATURE plines; for example, logic programming STRUCTURES grew out of classical theorem proving, and 8. UNIFICATION AND NATURAL LANGUAGE the origin of a particular contribution to PROCESSING 8.1 Parsing with a Unification-Based Grammar unification is not always clear. I have pro- 8.2 Research vided a balanced classification, giving cross 9. UNIFICATION AND EQUATIONAL references when useful. THEORIES Finally, the literature on unification is 9.1 Unification as Equation Solving enormous. I present all of the major results, 9.2 Research 10. PARALLEL ALGORITHMS FOR if not the methods used to reach them. UNIFICATION 11. UNIFICATION, GENERALIZATION, AND LATTICES 1. THE UNIFICATION PROBLEM 12. OTHER APPLICATIONS OF UNIFICATION Abstractly, the unification problem is the 12.1 Type Inference following: Given two descriptions x and y, 12.2 Programming Languages can we find an object z that fits both 12.3 Machine Learning descriptions? 13. CONCLUSION 13.1 Some Properties of Unification The unification problem is most often 13.2 Trends in Unification Research stated in the following context: Given two ACKNOWLEDGMENTS terms of logic built up from function sym- REFERENCES bols, variables, and constants, is there a substitution of terms for variables that will make the two terms identical? As an ex- ample consider the two terms f(x, y) and work on unification as equation solving. f(g(y, a), h(a)). They are said to be unifi- Parallel Algorithms for Unification reviews able, since replacing x by g(h(a), a) and y recent literature on unification and paral- by h(u) will make both terms look like lelism. Unification, Generalization, and f(g(h(a), a), h(u)). The nature of such Lattices discusses unification and its dual unifying substitutions, as well as the means operation, generalization, in another ab- of computing them, makes up the study of stract setting. Finally, in Other Applica- unification. tions of Unification, research that connects In order to ensure the consistency, con- unification to research in abstract data ciseness, and independence of the various types, programming languages, and ma- sections of this paper, I introduce a few chine learning is briefly surveyed. The formal definitions: ACM Computing Surveys, Vol. 21, No. 1, March 1989 Unification: A Multidisciplinary Survey l 95 Definition 1.1 s and t, and u(s) is called a unification of s A variable symbol is one of (x, y, z, . .). and t. A constant symbol is one of (a, b, c, . .). A function symbol is one of ( f, g, h, . .I. Definition 1.5 A unifier u of terms s and t is called a most Definition 1.2 general unifier (MGU) of s and t if for any other unifier 0, there is a substitution 7 A term is either a variable symbol, a con- such that 7u = 8. Consider, for example, the stant symbol, or a function symbol followed two terms f(x) and fig(y)). The MGU is by a series of terms, separated by commas, enclosed in parentheses. Sample terms are (X t g(y)], but there are many non-MGU unifiers such as (x t g(a), y t a), Intui- a, x7 fix, Y), fi&, Y), hiz)). Terms are tively, the MGU of two terms is the sim- denoted by the symbols (s, t, u, . .).’ plest of all their unifiers. Definition 1.3 Definition 1.6 A substitution is first a function from vari- Two terms s and tare said to match if there ables into terms. Substitutions are denoted is a substitution u such that u(s) = t. by the symbols {a, 7, 0, . .). A substitution Matching is an important variant of u in which a(x) is g(h(a), a) and a(y) is unification. h(a) can be written as a set of bindings enclosed in curly braces; that is, (X t g(h(a), a), y t h(a)]. This set of bindings Definition 1.7 is usually finite. A substitution is also a Two terms s and t are infinitely unifiable if function from terms to terms via its appli- there is a substitution, possibly containing cation. The application of substitution u infinitely long terms, that is a unifier of s to term t is also written u(t) and denotes and t. For example, x and f(x) are not the term in which each variable xi in t is unifiable, but they are infinitely unifi- replaced by a(s). able under the substitution u = (X t Substitutions can be composed: a0 (t) de- fififi . )))I, since 4x1 and dfix)) are notes the term t after the application of the both equal to f (f (f ( . ))). An infinitely substitutions of 19followed by the applica- long term is essentially one whose string tion of the substitutions of u. The substi- representation (to be discussed in the next tution a0 is a new substitution built from section) requires an infinite number of old substitutions u and (3 by (1) modifying symbols-for a formal discussion, see 0 by applying u to its terms, then (2) adding Courcelle [ 19831. variable-term pairs in u not found in 8. These general definitions will be used Composition of substitutions is associative, often throughout the paper. Concepts spe- that is, (&3)7(s) = a(&)(s) but is not in cific to particular areas of study will be general commutative, that is, ad(s) # &is). defined in their respective sections. Definition 1.4 2. UNIFICATION AND COMPUTATIONAL Two terms s and t are unifiable if there COMPLEXITY exists a substitution u such that u(s) = In his 1930 thesis, Herbrand [1971] pre- u(t).