Retrieving library identifiers via equational matching of types

  • Mikael Rittri
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 449)


In functional programming environments, one can use types as search keys in program libraries, if one disregards trivial differences in argument order or currying. A way to do this is to identify types that are isomorphic in every Cartesian closed category; simpler put, types should be identified if they are equal under an arithmetic interpretation, with Cartesian product as multiplication and function space as exponentiation. When the type system is polymorphic, one may also want to retrieve identifiers of types more general than the query. This paper describes a method to do both, that is, an algorithm for pattern matching modulo canonical CCC-isomorphism. The algorithm returns a finite complete set of matchers. An implementation shows that satisfactory speed can be achieved for library search.


Function Symbol Equational Theory Library Search Regular Form Irreducible Form 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    L. Augustsson and T. Johnsson. The Chalmers Lazy-ML compiler. The Computer Journal, 32(2), 1989.Google Scholar
  2. [2]
    F. Fages and G. Huet. Complete sets of unifiers and matchers in equational theories. Theoretical Comp. Sci., 43:189–200, 1986.Google Scholar
  3. [3]
    P. Hancock. A type-checker. In S.L. Peyton Jones, The Implementation of Functional Programming Languages, chapter 9. Prentice-Hall, 1987.Google Scholar
  4. [4]
    J.M. Hullot. Associative commutative pattern matching. In Sixth Int. Joint Conf. on Artificial Intelligence, Tokyo, 1979.Google Scholar
  5. [5]
    B. Lang. Matching with multiplication and exponentiation, May 1978. Author's current address: INRIA, Domaine de Voluceau, Rocquencourt, B.P. 105, F-78153 Le Chesnay Cedex, France. E-mail: lang@inria.frGoogle Scholar
  6. [6]
    G. Longo, A. Asperti, and R. Di Cosmo. Coherence and valid isomorphism in closed categories. In D.H. Pitt et al., eds., Category Theory and Computer Science, Manchester, 1989. LNCS 389, Springer-Verlag.Google Scholar
  7. [7]
    C.F. Martin. Equational Theories of Natural Numbers and Transfinite Ordinals. PhD thesis 1973. University of California, Berkeley, CA 94720, USA. See also Notices of the Am. Math. Soc., 19(7):A-778-779, Abstract 698-E1, 1972.Google Scholar
  8. [8]
    R. Milner. A theory of type polymorphism in programming. J. of Comp. and System Sci., 17(3):348–375, 1978.Google Scholar
  9. [9]
    P. Narendran, F. Pfenning, and R. Statman. On the unification problem for Cartesian closed categories, 1989. Addresses: P. Narendran, State Univ. of New York at Albany, USA. F. Pfenning and R. Statman, Carnegie Mellon Univ., Pittsburgh, USA. E-mail:,, statman@c.cs.cmu.eduGoogle Scholar
  10. [10]
    G.E. Peterson and M.E. Stickel. Complete sets of reductions for some equational theories. JACM, 28(2):233–264, April 1981.Google Scholar
  11. [11]
    P.W. Purdom, Jr. and C.A. Brown. Fast many-to-one matching algorithms. In J.-P. Jouannaud, ed., Rewriting Techniques and Applications, Dijon, France, 1985. LNCS 202, Springer-Verlag.Google Scholar
  12. [12]
    C. Reade. Elements of Functional Programming. Addison-Wesley, 1989.Google Scholar
  13. [13]
    M. Rittri. Using types as search keys in function libraries. In Fourth Int. Conf. on Functional Programming Languages and Computer Architecture, London, 1989. ACM Press, Addison-Wesley. (Part B of [14] is a revised version.)Google Scholar
  14. [14]
    M. Rittri. Searching Program Libraries by Type and Proving Compiler Correctness by Bisimulation. PhD thesis, 1990. Dept. of Comp. Sci., Chalmers U. of Tech. and U. of Göteborg, S-412 96 Göteborg, Sweden. E-mail: rittri@cs.chalmers.seGoogle Scholar
  15. [15]
    C. Runciman and I. Toyn. Retrieving re-usable software components by polymorphic type. In Fourth Int. Conf. on Functional Programming Languages and Computer Architecture, London, 1989. ACM Press, Addison-Wesley.Google Scholar
  16. [16]
    M. Schmidt-Schauß. Unification in a combination of arbitrary disjoint equational theories. J. of Symbolic Computation, 8:51–99, 1989.Google Scholar
  17. [17]
    J.H. Siekmann. Unification theory. J. of Symbolic Computation, 7:207–274, 1989.Google Scholar
  18. [18]
    S.V. Solov'ev. The category of finite sets and Cartesian closed categories. J. of Soviet Math., 22(3):1387–1400, 1983.Google Scholar
  19. [19]
    M.E. Stickel. A unification algorithm for associative-commutative functions. JACM, 28(3):423–434, July 1981.Google Scholar
  20. [20]
    E. Tidén. First-Order Unification in Combinations of Equational Theories. PhD thesis, 1986. Dept. of Num. Anal. and Comp. Sci., The R. Inst. of Technol., Stockholm, Sweden.Google Scholar
  21. [21]
    D.A. Turner. Miranda: A non-strict functional language with polymorphic types. In J.-P. Jouannaud, ed., Functional Programming Languages and Computer Architecture, Nancy, France, 1985. LNCS 201, pages 1–16, Springer-Verlag.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1990

Authors and Affiliations

  • Mikael Rittri
    • 1
  1. 1.Programmeringsmetodikgruppen, Inst. för InformationsbehandlingChalmers Tekniska Högskola och Göteborgs UniversitetGöteborgSweden

Personalised recommendations