A self-applicable partial evaluator for the lambda calculus: correctness and pragmatics

We describe theoretical and a few practical aspects of an implemented self-applicable partial evaluator for the untyped lambda calculus with constants, conditionals, and a fixed point operator. The purpose of this paper is first to announce the existence of (and to describe) a partial evaluator that is both higher-order and self-applicable; second to describe a surprisingly simple solution to the central problem of binding time analysis, and third to prove that the partial evaluator yields correct answers. While λ-mix (the name of our system) seems to have been the first higher-order self-applicable partial evaluator to run on a computer, it was developed mainly for research purposes. Two recently developed systems are much more powerful for practical use, but also much more complex: Similix[3,5] and Schism[7]. Our partial evaluator is surprisingly simple, completely automatic, and has been implemented in a side effect-free subset of Scheme. It has been used to compile, generate compilers and generate a compiler generator.

[1]  Neil D. Jones,et al.  Compiler Generation by Partial Evaluation: A Case Study , 1991, Struct. Program..

[2]  R. Schooler,et al.  PARTIAL EVALUATION AS A MEANS OF LANGUAGE EXTENSIBILITY , 1984 .

[3]  Lawrence C. Paulson A semantics-directed compiler generator , 1982, POPL '82.

[4]  Anders Bondorf,et al.  Automatic Autoprojection of Recursive Equations with Global Variables and Abstract Data Types , 1991, Sci. Comput. Program..

[5]  Neil D. Jones,et al.  Mix: A self-applicable partial evaluator for experiments in compiler generation , 1989, LISP Symb. Comput..

[6]  Mitchell Wand Semantics-directed machine architecture , 1982, POPL '82.

[7]  Valentin F. Turchin,et al.  The Use of Metasystem Transition in Theorem Proving and Program Optimization , 1980, ICALP.

[8]  Neil D. Jones,et al.  A partial evaluator for the untyped lambda-calculus , 1991, Journal of Functional Programming.

[9]  Olivier Danvy,et al.  Partial Evaluation of Pattern Matching in Strings , 1989, Inf. Process. Lett..

[10]  Peter Sestoft,et al.  Replacing function parameters by global variables , 1989, FPCA.

[11]  Peter Sestoft,et al.  An experiment in partial evaluation: the generation of a compiler generator , 1985, SIGP.

[12]  Anders Bondorf,et al.  Automatic Autoprojection of Higher Order Recursive Equations , 1990, Sci. Comput. Program..

[13]  Carsten K. Gomard Partial type inference for untyped functional programs , 1990, LISP and Functional Programming.

[14]  Andrew W. Appel Semantics-directed code generation , 1985, POPL '85.

[15]  William L. Scherlis,et al.  Compilers and staging transformations , 1986, POPL '86.

[16]  Mitchell Wand A semantic prototyping system , 1984, SIGPLAN '84.

[17]  Flemming Nielson,et al.  Automatic binding time analysis for a typed λ-calculus , 1988, POPL '88.

[18]  Andrei P. Ershov,et al.  Correctness of Mixed Computation in Algol-Like Programs , 1977, MFCS.

[19]  A. P. Ershov,et al.  A Formal Type System for Comparing Partial Evaluators , 1988 .

[20]  David A. Schmidt Detecting global variables in denotational specifications , 1985, TOPL.

[21]  Andrei P. Ershov,et al.  On the Essence of Compilation , 1977, Formal Description of Programming Concepts.

[22]  Anders Bondorf,et al.  A Self-Applicable Partial Evaluator for Term Rewriting Systems , 1989, TAPSOFT, Vol.2.

[23]  Simon L. Peyton Jones,et al.  The Implementation of Functional Programming Languages , 1987 .

[24]  Erik Sandewall,et al.  A Partial Evaluator, and its Use as a Programming Tool , 1976, Artif. Intell..

[25]  Dale Miller,et al.  Deriving Mixed Evaluation from Standard Evaluation for a Simple Functional Language , 1989, MPC.

[26]  Charles Consel,et al.  New Insights into Partial Evaluation: the SCHISM Experiment , 1988, ESOP.

[27]  Pierre Weis,et al.  Le systeme sam : metacompilation tres efficace a l'aide d'operateurs semantiques , 1987 .

[28]  Uwe F. Pleban Compiler prototyping using formal semantics , 1984, SIGPLAN '84.