Memoization in Type-Directed Partial Evaluation

We use a code generator--type-directed partial evaluation-- to verify conversions between isomorphic types, or more precisely to verify that a composite function is the identity function at some complicated type. A typed functional language such as ML provides a natural support to express the functions and type-directed partial evaluation provides a convenient setting to obtain the normal form of their composition. However, off-the-shelf type-directed partial evaluation turns out to yield gigantic normal forms.We identify that this gigantism is due to redundancies, and that these redundancies originate in the handling of sums, which uses delimited continuations. We successfully eliminate these redundancies by extending type-directed partial evaluation with memoization capabilities. The result only works for pure functional programs, but it provides an unexpected use of code generation and it yields orders-of-magnitude improvements both in time and in space for type isomorphisms.

[1]  Olivier Danvy,et al.  Lambda-Lifting in Quadratic Time , 2002, J. Funct. Log. Program..

[2]  Roberto Di Cosmo,et al.  Deciding type isomorphisms in a type-assignment framework , 1993, Journal of Functional Programming.

[3]  Sophia Mã ¶ ller Partial Evaluation Practice And Theory Diku 1998 International Summer School Copenhagen Denmark June 29 July 10 1998 , 1998 .

[4]  Olivier Danvy,et al.  Type-directed partial evaluation , 1995, POPL '96.

[5]  Thierry Coquand,et al.  Intuitionistic model constructions and normalization proofs , 1997, Mathematical Structures in Computer Science.

[6]  Jeffrey D. Ullman Elements of ML programming - ML 97 edition , 1998 .

[7]  Mikael Rittri,et al.  Using types as search keys in function libraries , 1989, Journal of Functional Programming.

[8]  Olivier Danvy,et al.  Tutorial notes on partial evaluation , 1993, POPL '93.

[9]  Alex Wilkie On Exponentiation - A Solution to Tarski's High School Algebra Problem , 2001 .

[10]  Ulrich Kohlenbach,et al.  Mann iterates of directionally nonexpansive mappings in hyperbolic spaces , 2002 .

[11]  Christian N. S. Pedersen,et al.  Comparative Methods for Gene Structure Prediction in Homologous Sequences , 2002, WABI.

[12]  David Delahaye,et al.  Recherche dans une bibliothèque de preuves Coq en utilisant le type et modulo isomorphismes , 1997 .

[13]  Olivier Danvy Online Type-Directed Partial Evaluation , 1998, Fuji International Symposium on Functional and Logic Programming.

[14]  Peter Thiemann,et al.  Two Flavors of Offline Partial Evaluation , 1998, ASIAN.

[15]  Martin Hofmann,et al.  Categorical Reconstruction of a Reduction Free Normalization Proof , 1995, Category Theory and Computer Science.

[16]  Martin Hofmann,et al.  Reduction-free normalisation for a polymorphic system , 1996, Proceedings 11th Annual IEEE Symposium on Logic in Computer Science.

[17]  Bernd Grobauer,et al.  The Second Futamura Projection for Type-Directed Partial Evaluation , 1999 .

[18]  Olivier Danvy,et al.  Language Support for Program Generation Reasoning, Implementation, and Applications , 2001 .

[19]  J. Girard,et al.  Proofs and types , 1989 .

[20]  Bernd Grobauer,et al.  Topics in Semantics-based Program Manipulation , 2001 .

[21]  Roberto Di Cosmo,et al.  Provable isomorphisms of types , 1992, Mathematical Structures in Computer Science.

[22]  DONALD MICHIE,et al.  “Memo” Functions and Machine Learning , 1968, Nature.

[23]  Colin Runciman,et al.  Retrieving Reusable Software Components by Polymorphic Type , 1991, J. Funct. Program..

[24]  Bernd Grobauer,et al.  The second Futamura projection for type-directed partial evaluation , 1999 .

[25]  Yoshihiko Futamura,et al.  Essence of Generalized Partial Computation , 1991, Theor. Comput. Sci..

[26]  Jeffrey D. Ullman Elements of ML programming , 1994 .

[27]  Rasmus Pagh,et al.  Simulating Uniform Hashing in Constant Time and Optimal Space , 2002 .

[28]  Olivier Danvy,et al.  Semantics-Based Compiling: A Case Study in Type-Directed Partial Evaluation , 1996, PLILP.

[29]  Christopher League Review of Isomorphisms of Types:: from λ-calculus to information retrieval and language design by Roberto Di Cosmo (Birkhauser, 1995) , 1997, SIGA.

[30]  Mikael Rittri,et al.  Retrieving Library Identifiers via Equational Matching of Types , 1990, CADE.

[31]  S. Solov′ev The category of finite sets and Cartesian closed categories , 1983 .

[32]  Peter Sestoft,et al.  Partial evaluation and automatic program generation , 1993, Prentice Hall international series in computer science.

[33]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[34]  Roberto Di Cosmo Review of Isomorphisms of Types:: from λ-calculus to information retrieval and language design , 1997 .

[35]  Roberto Di Cosmo,et al.  Remarks on isomorphisms in typed lambda calculi with empty and sum types , 2002, Proceedings 17th Annual IEEE Symposium on Logic in Computer Science.

[36]  Lawrence C. Paulson,et al.  ML for the working programmer (2. ed.) , 1996 .

[37]  Martin Hofmann,et al.  Normalization by evaluation for typed lambda calculus with coproducts , 2001, Proceedings 16th Annual IEEE Symposium on Logic in Computer Science.

[38]  John Hughes,et al.  Lazy Memo-functions , 1985, FPCA.

[39]  Olivier Danvy,et al.  Memoization in Type-Directed Partial Evaluation , 2002 .

[40]  Olivier Danvy,et al.  On obtaining Knuth, Morris, and Pratt's string matcher by partial evaluation , 2002, ASIA-PEPM '02.

[41]  Ulrich Berger,et al.  An inverse of the evaluation functional for typed lambda -calculus , 1991, [1991] Proceedings Sixth Annual IEEE Symposium on Logic in Computer Science.

[42]  Andrzej Filinski,et al.  Normalization by Evaluation for the Computational Lambda-Calculus , 2001, TLCA.

[43]  Colin Runciman,et al.  Retrieving re-usable software components by polymorphic type , 1989, Journal of Functional Programming.

[44]  Ulrich Berger,et al.  Program Extraction from Normalization Proofs , 2006, Stud Logica.

[45]  Peter Thiemann,et al.  Implementing Memoization for Partial Evaluation , 1996, PLILP.

[46]  Roberto Di Cosmo,et al.  Type isomorphisms in a type-assignment framework , 1992, POPL '92.

[47]  Gilles Barthe,et al.  Type Isomorphisms and Proof Reuse in Dependent Type Theory , 2001, FoSSaCS.

[48]  Roberto Di Cosmo,et al.  Isomorphisms of Types , 1995, Progress in Theoretical Computer Science.

[49]  Margarita V. Korovina,et al.  Fixed points on abstract structures without the equality test , 2002, FICS.

[50]  Andrzej Filinski,et al.  A Semantic Account of Type-Directed Partial Evaluation , 1999, PPDP.

[51]  Olivier Danvy,et al.  Normalization by evaluation with typed abstract syntax , 2001, J. Funct. Program..

[52]  Frank D. Valencia,et al.  On the Expressive Power of Concurrent Constraint Programming Languages , 2002 .

[53]  R. Gurevič Equational theory of positive numbers with exponentiation , 1985 .

[54]  Olivier Danvy,et al.  Strong Normalization by Type-Directed Partial Evaluation and Run-Time Code Generation , 1998, Types in Compilation.

[55]  Morten Rhiger,et al.  Higher-Order Program Generation , 2001 .

[56]  Paulo Oliva,et al.  Proof Mining: A Systematic Way of Analysing Proofs in Mathematics , 2002 .

[57]  Alfred Tarski,et al.  An extended arithmetic of ordinal numbers , 1969 .

[58]  Antonio di Nola,et al.  Compact representations of BL-algebras , 2003, Arch. Math. Log..

[59]  Chris Reade,et al.  ML for the Working Programmer (2nd edition) by L. C. Paulson, Cambridge University Press, 1996. A Practical Course in Functional Programming Using Standard ML by R. Bosworth, McGraw Hill, 1996. , 1997, Journal of Functional Programming.

[60]  Helmut Schwichtenberg,et al.  Normalisation by Evaluation , 1998, Prospects for Hardware Foundations.