Skip to main content Accesibility Help
×
×
Home

Using types as search keys in function libraries

  • Mikael Rittri (a1)
Abstract

A method is proposed to search for an identifier in a functional program library by using its Hindley–Milner type as a key. This can be seen as an approximation of using the specification as a key.

Functions that only differ in their argument order or currying are essentially the same, which is expressed by a congruence relation on types. During a library search, congruent types are identified. If a programmer is not satisfied with the type of a found value, he can use a conversion function (like curry), which must exist between congruent types, to convert the value into the type of his choice.

Types are congruent if they are isomorphic in all cartesian closed categories. To put it more simply, types are congruent if they are equal under an arithmetical interpretation, with cartesian product as multiplication and function space as exponentiation. This congruence relation is characterized by seven equational axioms. There is a simple term-rewriting algorithm to decide congruence, using which a search system has been implemented for the functional language Lazy ML, with good performance.

The congruence relation can also be used as a basis for other search strategies, e.g. searching for identifiers of a more general type, modulo congruence or allowing free type variables in queries.

Copyright
References
Hide All
Augustsson, L. and Johnsson, T. 1988. Lazy ML User's Manual. Dept. of Comp. Sci., Chalmers Univ. of Tech., S-412 96 Göteborg, Sweden.
Augustsson, L. and Johnsson, T. 1989. The Chalmers Lazy-ML compiler. The Computer Journal, 32(2).
Bruce, K. B. and Longo, G. 1985. Provable isomorphisms and domain equations in models of typed languages (preliminary version). In 17th ACM Symp. on the Theory of Computing, Providence.
Damas, L. and Milner, R. 1982. Principal type-schemes for functional programs. In 9th ACM Symp. on Principles of Programming Languages.
Dezani-Ciancaglini, M. 1976. Characterization of normal forms possessing an inverse in the λβη-calculus. Theoretical Comp. Sci., 2:323–37.
Goldblatt, R. 1979. Topoi: The Categorial Analysis of Logic. Volume 98 of Studies in Logic and the Foundation of Mathematics. North-Holland, Amsterdam.
Gonnet, G. H. 1984. Determining the equivalence of expressions in random polynomial time. In 16th ACM Symp. on the Theory of Computing,Washington DC.
Gurevič, R. 1989. Equational theory of positive numbers with exponentiation is not finitely axiomatizable. To appear in Ann. of Pure and Appl. Logic.
Harper, R. and Mitchell, K. 1986. Introduction to Standard ML. Technical report, LFCS, Dept. of Comp. Sci., Univ. of Edinburgh.
Henson, C. W. and Rubel, L. A. 1984. Some applications of Nevanlinna theory to mathematical logic: Identities of exponential functions. Trans. of Am. Math. Soc., 282(1): 132 (Mar.).
Huet, G. 1985. Cartesian closed categories and lambda calculus. In Cousineau, G., Curien, P.-L. and Robinet, B. (editors), Combinators and Functional Programming Languages. Volume 242 of Lecture Notes in Computer Science, Springer-Verlag.
Jeanrond, H. J. 1980. Deciding unique termination of permutative rewriting systems: Choose your term algebra carefully. In Bibel, W. and Kowalski, R. (editors), 5th Conf. on Automated Deduction, Les Arcs, France. Volume 87 of Lecture Notes in Computer Science, Springer-Verlag.
Kirchner, C. 1984. Standardization of equational unification: Abstract and examples. Internal Report 84-R-074, Centre de Recherche en Informatique, Nancy, France, E-mail:
Kirchner, C. 1985. Méthodes et outils de conception systématique d'algorithmes d'unification dans les théories équationelles. PhD thesis, Université de Nancy I, France. E-mail:
Lambek, J. 1980. From lambda calculus to cartesian closed categories. In Seldin, J. P. and Hindley, J. (editors), To H. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pp. 376402. Academic Press.
Lang, B. 1978. Matching with multiplication and exponentiation (May). Author's current address: INRIA, Domaine de Voluceau, Rocquencourt, B.P. 105, F-78153 Le Chesnay Cedex, France. E-mail:
Longo, G., Asperti, A. and Di Cosmo, R. 1989. Coherence and valid isomorphism in closed categories. In Pitt, D. H. et al. (editors), Category Theory and Computer Science, Manchester, UK. Volume 389 of Lecture Notes in Computer Science, Springer-Verlag.
Macintyre, A. 1981. The laws of exponentiation. In Berline, C. et al. (editors), Model Theory and Arithmetic. Volume 890 of Lecture Notes in Mathematics, pp. 185–97. Springer-Verlag.
Martin, C. F. 1972. Axiomatic bases for equational theories of natural numbers. Notices of Am. Math. Soc., 19(7): A-778779, Abstract 698-E1.
Martin, C. F. 1973. Equational Theories of Natural Numbers and Transfinite Ordinals. PhD thesis, Univ. of California, Berkeley, CA 94720, USA. The relevant results appear also in Martin (1972).
Martin, W. A. 1971. Determining the equivalence of algebraic expressions by hash coding. JACM, 18(4): 549–58 (Oct.).
Narendran, P., Pfenning, F. and Statman, R. 1989. On the unification problem for cartesian closed categories. Addresses: P. Narendran, State Univ. of New York at Albany, USA. F. Pfenning and R. Statman Carnegie Mellon Univ., Pittsburgh, USA. E-mail: , ,
Peterson, G. E. and Stickel, M. E. 1981. Complete sets of reductions for some equational theories. JACM, 28(2): 233–64 (Apr.).
Plotkin, G. D. 1980. Domains. Lecture notes, Univ. of Edinburgh, UK.
Rittri, M. 1989. lmlseek – a program to search for identifiers in LML programs by type (July).
PMG Memo 69, Dept. of Comp. Sci., Chalmers Univ. of Tech., S-412 96 Göteborg, Sweden. Email:
Rittri, M. 1990 a. Retrieving library identifiers via equational matching of types. In Stickel, M. E. (editor), 10th Int. Conf. on Automated Deduction, Kaiserslautern, W. Germany. Volume 449 of Lecture Notes in Artificial Intelligence, Springer-Verlag. This is a condensed version of Rittri (1990 b), Part C.
Rittri, M. 1990 b. Searching Program Libraries by Type and Proving Compiler Correctness by Bisimulation. PhD thesis, Dept. of Comp. Sci., Chalmers Univ. of Tech. and Univ. of Göteborg, S-412 96 Göteborg, Sweden. E-mail:
Runciman, C. and Toyn, I. 1989. Retrieving re-usable software components by polymorphic type. In 4th Int. Conf. on Functional Programming Languages and Computer Architecture,London, UK.,ACM Press, Addison-Wesley.
Schmidt-Schauss, M. 1989. Unification in a combination of arbitrary disjoint equational theories. J. of Symbolic Computation, 8: 5199.
Schwartz, J. T. 1980. Fast probabilistic algorithms for verification of polynomial identities. JACM, 27(4): 701–17 (Oct.).
Siekmann, J. H. 1989. Unification theory. J. of Symbolic Computation, 7, 207–74.
Solov'ev, S. V. 1983. The category of finite sets and cartesian closed categories. J. of Soviet Mathematics, 22(3): 13871400. This is an American Mathematical Society translation of the Russian original in Zapiski Nauchnykh Seminarov Leningradskogo Otdeleniya Matematicheskogo Instituta im. V. A. Steklova AN SSSR, Vol. 105, 1981. pp. 174–94.
Turner, D. A. 1985. Miranda: A non-strict functional language with polymorphic types. In Jouannaud, J.-P. (editor), Functional Programming Languages and Computer Architecture, Nancy, France. Volume 201 of Lecture Notes in Computer Science, pp. 116, Springer-Verlag.
Uddeborg, G. O. 1988. A functional parser generator. Licentiate thesis, Dept. of Comp. Sci., Chalmers Univ. of Tech., S-412 96 Göteborg, Sweden. Also as PMG Report 43 (without source code).
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

Using types as search keys in function libraries

  • Mikael Rittri (a1)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *