Hostname: page-component-7479d7b7d-qlrfm Total loading time: 0 Render date: 2024-07-13T20:03:52.072Z Has data issue: false hasContentIssue false

Using types as search keys in function libraries

Published online by Cambridge University Press:  07 November 2008

Mikael Rittri
Affiliation:
Department of Computer Sciences, Chalmers University of Technology and University of Göteborg, Sweden
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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.

Type
Article
Copyright
Copyright © Cambridge University Press 1991

References

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.Google Scholar
Augustsson, L. and Johnsson, T. 1989. The Chalmers Lazy-ML compiler. The Computer Journal, 32(2).CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Damas, L. and Milner, R. 1982. Principal type-schemes for functional programs. In 9th ACM Symp. on Principles of Programming Languages.CrossRefGoogle Scholar
Dezani-Ciancaglini, M. 1976. Characterization of normal forms possessing an inverse in the λβη-calculus. Theoretical Comp. Sci., 2:323–37.CrossRefGoogle Scholar
Goldblatt, R. 1979. Topoi: The Categorial Analysis of Logic. Volume 98 of Studies in Logic and the Foundation of Mathematics. North-Holland, Amsterdam.Google Scholar
Gonnet, G. H. 1984. Determining the equivalence of expressions in random polynomial time. In 16th ACM Symp. on the Theory of Computing,Washington DC.CrossRefGoogle Scholar
Gurevič, R. 1989. Equational theory of positive numbers with exponentiation is not finitely axiomatizable. To appear in Ann. of Pure and Appl. Logic.Google Scholar
Harper, R. and Mitchell, K. 1986. Introduction to Standard ML. Technical report, LFCS, Dept. of Comp. Sci., Univ. of Edinburgh.Google Scholar
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.).Google Scholar
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.Google Scholar
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.Google Scholar
Kirchner, C. 1984. Standardization of equational unification: Abstract and examples. Internal Report 84-R-074, Centre de Recherche en Informatique, Nancy, France, E-mail: Google Scholar
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: Google Scholar
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.Google Scholar
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: Google Scholar
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.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Martin, C. F. 1972. Axiomatic bases for equational theories of natural numbers. Notices of Am. Math. Soc., 19(7): A-778779, Abstract 698-E1.Google Scholar
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).Google Scholar
Martin, W. A. 1971. Determining the equivalence of algebraic expressions by hash coding. JACM, 18(4): 549–58 (Oct.).CrossRefGoogle Scholar
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: , , Google Scholar
Peterson, G. E. and Stickel, M. E. 1981. Complete sets of reductions for some equational theories. JACM, 28(2): 233–64 (Apr.).CrossRefGoogle Scholar
Plotkin, G. D. 1980. Domains. Lecture notes, Univ. of Edinburgh, UK.Google Scholar
Rittri, M. 1989. lmlseek – a program to search for identifiers in LML programs by type (July).Google Scholar
PMG Memo 69, Dept. of Comp. Sci., Chalmers Univ. of Tech., S-412 96 Göteborg, Sweden. Email: Google Scholar
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.Google Scholar
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: Google Scholar
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.CrossRefGoogle Scholar
Schmidt-Schauss, M. 1989. Unification in a combination of arbitrary disjoint equational theories. J. of Symbolic Computation, 8: 5199.CrossRefGoogle Scholar
Schwartz, J. T. 1980. Fast probabilistic algorithms for verification of polynomial identities. JACM, 27(4): 701–17 (Oct.).CrossRefGoogle Scholar
Siekmann, J. H. 1989. Unification theory. J. of Symbolic Computation, 7, 207–74.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
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).Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.