Average case analysis of unification algorithms

  • Luc Albert
  • Rafael Casas
  • François Fages
  • A. Torrecillas
  • Paul Zimmermann
Logic Programming
Part of the Lecture Notes in Computer Science book series (LNCS, volume 480)


Unification in first-order languages is a central operation in symbolic computation and logic programming. Many unification algorithms have been proposed in the past, however there is no consensus on which algorithm is the best to use in practice. While Paterson and Wegman's linear unification algorithm has the lowest time complexity in the worst case, it requires an important overhead to be implemented. This is true also, although less importantly, for Martelli and Montanari's algorithm [MM82], and Robinson's algorithm [Rob71] is finally retained in many applications despite its exponential worst-case time complexity. There are many explanations for that situation: one important argument is that in practice unification subproblems are not independent, and linear unification algorithms do not perform well on sequences of unify-deunify operations [MU86]. In this paper we present average case complexity theoretic arguments. We first show that the family of unifiable pairs of binary trees is exponentially negligible with respect to the family of arbitrary pairs of binary trees formed over l binary function symbols, c constants and v variables. We analyze the different reasons for failure and get asymptotical and numerical evaluations. We then extend the previous results of [DL89] to these families of trees, we show that a slight modification of Herbrand-Robinson's algorithm has a constant average cost on random pairs of trees. On the other hand, we show that various variants of Martelli and Montanari's algorithm all have a linear average cost on random pairs of trees. The point is that failures by clash are not sufficient to lead to a constant average cost, an efficient occur check (i.e. without a complete traversal of subterms) is necessary. In the last section we extend the results on the probability of the occur check in presence of an unbounded number of variables.


unification algorithms average case complexity generating functions 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

VII. Bibliography

  1. [AHU74]
    A.V. Aho, J.E. Hopcroft and J.D. Ullman. The design and analysis of computer algorithms. Addison Wesley Pub. Comp. 1974.Google Scholar
  2. [AF88]
    L. Albert and F. Fages. Average case complexity analysis of the RETE pattern match algorithm. Proceedings of the 15 th International Colloquium on Automata, Languages and Programming, Lecture Notes in Computer Science 317, Tampere, Finland, pages 18–37. Springer Verlag, July 1988.Google Scholar
  3. [Alb89b]
    L. Albert. Average case complexity analysis of RETE pattern match algorithm and average size of join in Databases. Proceedings of the 9 th conference on Foundations of Software Technology and Theoretical Computer Science, Lecture Notes in Computer Science 405, Bangalore, India, pages 223–241. Springer Verlag, December 1989.Google Scholar
  4. [Alb90]
    L. Albert. Quelques analyses de complexité en moyenne sur les algorithmes de multi-filtrage, d'unification et de requête multiple. PhD. Thesis N. 1379. Université Paris XI, 1990.Google Scholar
  5. [ACDT90]
    L. Albert, R. Casas, J. Diaz and A. Torrecillas. On unification over unrestricted pairs of trees. Submitted to Mathematical Foundations of Computer Science '90, Bratislava, Czechoslovakia, August 1990. Report de Recerca LSI-89-26, universitat politecnica de catalunya, 1989. In Alcom workshop on probabilistic algorithms and average case analysis, Computer Technology Institute, Patras, Greece, March 4–7 1990.Google Scholar
  6. [BJSS88]
    A. Boudet, J.P. Jouannaud and M. Schmidt-Schauss. Unification in Boolean rings and Abelian groups. LICS'88. 1988.Google Scholar
  7. [CAML89]
    Formel Project. The CAML reference manual. INRIA, 1989.Google Scholar
  8. [CB83]
    A. Corbin and M. Bidoit. A rehabilitation of Robinson's unification algorithm. In Information processing 83, R.E.A. Mason, pages 909–914. North Holland 1983.Google Scholar
  9. [CDS89]
    R. Casas, J. Diaz and J.M. Steyaert. Average case analysis of Robinson's unification algorithm with two different variables. Information proceedings letters, 31, pages 227–232, June 1989.CrossRefGoogle Scholar
  10. [CL73]
    C.L. Chang and R.C. Lee. Symbolic Logic and Mechanical Theorem Proving. Academic Press, New-York. 1973.Google Scholar
  11. [Col78]
    A. Colmerauer. Les grammaires de métamorphose. Natural Language Communication with Computer, Lectures Notes in Computer Science. Springer-Verlag. 1978.Google Scholar
  12. [Col82]
    A. Colmerauer. Prolog II, manuel de référence et modèle théorique. Rapport interne, Groupe d'Intelligence Artificielle, Université d'Aix-Marseille II. March 1982.Google Scholar
  13. [Col84]
    A. Colmerauer. Equations and inequations on finite and infinite trees. Proceedings of the International Conference on Fith Generation Computer Systems. 1984.Google Scholar
  14. [Cou83]
    B. Courcelle. Fundamental properties of infinite trees. Theoretical Computer Science. 1983Google Scholar
  15. [DL89]
    N. Dershowitz and N. Lindenstrauss. Average time analyses related to logic programming. In 6th International Conference on Logic Programming, pages 369–381. Lisboa 1989.Google Scholar
  16. [DKM84]
    C. Dwork, P.C. Kanellakis and J.C. Mitchell. On the sequential nature of unification. Journal of logic programming 1, pages 35–50. 1984.CrossRefGoogle Scholar
  17. [EG88]
    G. Escalada-Imaz and M. Ghallab. A practically efficient and almost linear unification algorithm. Artificial Intelligence, volume 36, number 2, pages 249–263. Sept. 1988.CrossRefMathSciNetGoogle Scholar
  18. [Fag83]
    F. Fages. Formes canoniques dans les algèbres booléennes, et application à la démonstration automatique en logique de premier ordre. Thèse de l'Université de Paris VI. 1983.Google Scholar
  19. [Fag84]
    F. Fages. Associative-commutative unification. 7th CADE, Napa Valley. 1984.Google Scholar
  20. [FH86]
    F. Fages and G. Huet. Complete sets of unifiers and matchers in equational theories. Theoretical Computer Science. July 1986.Google Scholar
  21. [Fla88]
    P. Flajolet. Mathematical methods in the analysis of algorithms and data structures. In Trends in theoretical computer science, E. Borger, Computer science press, ch. 6, pages 225–304. Rockville, Maryland, 1988. (Lecture Notes for a Graduate Course in Computer Science, Udine, 1984).Google Scholar
  22. [FO90]
    P. Flajolet and A. Odlyzko. Singularity Analysis of Generating Functions. In SIAM Journal of Disc. Math., vol. 3, N. 2, pages 216–240, 1990.CrossRefGoogle Scholar
  23. [FSZ89b]
    P. Flajolet, B. Salvy and P. Zimmermann. Lambda-upsilon-omega: The 1989 Cookbook. Inria Research Report 1073, Institut National de Recherche en Informatique et Automatique, August 1989.Google Scholar
  24. [FV87]
    P. Flajolet and J. Vitter. Average Case Analysis of Algorithms and Data Structures. In a Handbook of Theoretical Computer Science, North-Holland, 1987.Google Scholar
  25. [Her30]
    J. Herbrand. Recherches sur la théorie de la démonstration. Thèse de l'Université de Paris. 1930. In Ecrits logiques de Jacques Herbrand. Paris, PUF, 1968.Google Scholar
  26. [HO80]
    G. Huet and D. Oppen. Equations and Rewrite Rules: a Survey. In Formal Languages: Perspectives and Open Problems, Ed. Book R., Academic Press. 1980.Google Scholar
  27. [Hue75]
    G. Huet. A Unification Algorithm for Typed Lambda Calculus. Theoretical Computer Science, 1.1, pages 27–57. 1975CrossRefGoogle Scholar
  28. [Hue76]
    G. Huet. Résolution d'équations dans les langages d'ordre 1,2,...,ω. Thèse d'état de l'Université Paris VII. 1976.Google Scholar
  29. [Jaf84]
    J. Jaffar. Efficient unification over infinite terms. New Generation Computing, 2, pages 207–219. 1984.Google Scholar
  30. [KB70]
    D. Knuth and P. Bendix. Simple Word Problems in Universal Algebras. In Computational Problems in Abstract Algebra, Ed. Leech J., Pergamon Press, pages 263–297. 1970.Google Scholar
  31. [Kow74]
    R.A. Kowalski. Predicate Logic as Programming Language. Proceedings IFIP 74, North Holland, pages 569–574. 1974.Google Scholar
  32. [LMM86]
    J.L. Lassez, M.J. Maher and K. Marriott. Unification revisited. In Foundations of deductive databases and Logic Programming, J. Minker. 1986. IBM Research Report RC12355, 1986.Google Scholar
  33. [CGG+88]
    B.W. Char, K.O. Geddes, G.H. Gonnet, M.B. Monagan and S.M. Watt. MAPLE: Reference Manual. University of Waterloo, 1988. 5th edition.Google Scholar
  34. [Mai90]
    H.G. Mairson. Deciding ML typability is complete for deterministic exponential time. POPL, San Francisco. January 1990.Google Scholar
  35. [Mil78]
    R. Milner. A Theory of Type Polymorphism in Programming. JCSS 17, pages 348–375. 1978.Google Scholar
  36. [MM76]
    A. Martelli and U. Montanari. Unification in Linear Time and Space: a Structured Presentation. Internal Report B76-16, IEI, Pisa. July 1976.Google Scholar
  37. [MM82]
    A. Martelli and U. Montanari. An efficient unification algorithm. In ACM Transactions on Programming Languages and Systems, volume 4, number 2, pages 258–282. April 1982.CrossRefGoogle Scholar
  38. [MU86]
    H. Mannila and E. Ukkonen. On the complexity of unification sequences. Logic programming. 1986.Google Scholar
  39. [Plo72]
    G. Plotkin. Building-in Equational Theories. Machine Intelligence 7, pages 73–90. 1972.Google Scholar
  40. [PW78]
    M.S. Paterson and M.N. Wegman. Linear unification. In Journal of computer and system sciences 16, pages 158–167. 1978.CrossRefGoogle Scholar
  41. [Rob65]
    J.A. Robinson. A machine-oriented logic based on the resolution principle. In Journal of the Association for Computing Machinery, volume 12, number 1, pages 23–41. Jan. 1965.Google Scholar
  42. [Rob71]
    J.A. Robinson. Computational Logic: the Unification Computation. Machine Intelligence 6, Eds B. Meltzer and D. Michie American Elsevier, New-York. 1971.Google Scholar
  43. [SS86]
    L. Sterling and E. Shapiro. The Art of Prolog: Advanced Programming Techniques. MIT Press Series in Logic Programming, 1986.Google Scholar
  44. [Sti75]
    M.E. Stickel. A Complete Unification Algorithm for Associative-Commutative Functions. 4th International Joint Conference on Artificial Intelligence, Tbilisi. 1975.Google Scholar
  45. [TvL84]
    R.E. Tarjan and J. van Leeuwen. Worst-case analysis of set union algorithms. In Journal of the association for computing machinery, volume 31, number 2, pages 245–281. April 1984.MathSciNetGoogle Scholar
  46. [VZ75]
    M. Venturini-Zilli. Complexity of the Unification Algorithm for First-Order Expressions. Calcolo XII, Fasc. IV, pages 361–372. 1975.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1991

Authors and Affiliations

  • Luc Albert
    • 1
  • Rafael Casas
    • 2
  • François Fages
    • 3
  • A. Torrecillas
    • 2
  • Paul Zimmermann
    • 1
  1. 1.Domaine de Voluceau, RocquencourtInstitut National de Recherche en Informatique et AutomatiqueLe Chesnay Cedex France
  2. 2.Department of Llenguatges i Sistemes InformàticsUniversitat Politècnica de Catalunya, Pau Gargallo 5Barcelona
  3. 3.LIENS URA 1327 CNRSParisFrance

Personalised recommendations