The call-by-need lambda calculus

Plotkin (1975) showed that the lambda calculus is a good model of the evaluation process for call-by-name functional programs. Reducing programs to constants or lambda abstractions according to the leftmost-outermost strategy exactly mirrors execution on an abstract machine like Landin's SECD machine. The machine-based evaluator returns a constant or the token closure if and only if the standard reduction sequence starting at the same program will end in the same constant or in some lambda abstraction. However, the calculus does not capture the sharing of the evaluation of arguments that lazy implementations use to speed up the execution. More precisely, a lazy implementation evaluates procedure arguments only when needed and then only once. All other references to the formal procedure parameter re-use the value of the first argument evaluation. The mismatch between the operational semantics of the lambda calculus and the actual behavior of the prototypical implementation is a major obstacle for compiler writers. Unlike implementors of the leftmost-outermost strategy or of a call-by-value language, implementors of lazy systems cannot easily explain the behavior of their evaluator in terms of source level syntax. Hence, they often cannot explain why a certain syntactic transformation ‘works’ and why another doesn't. In this paper we develop an equational characterization of the most popular lazy implementation technique – traditionally called ‘call-by-need’ – and prove it correct with respect to the original lambda calculus. The theory is a strictly smaller theory than Plotkin's call-by-name lambda calculus. Immediate applications of the theory concern the correctness proofs of a number of implementation strategies, e.g. the call-by-need continuation passing transformation and the realization of sharing via assignments. Some of this material first appeared in a paper presented at the 1995 ACM Conference on the Principles of Programming Languages. The paper was a joint effort with Maraist, Odersky and Wadler, who had independently developed a different equational characterization of call-by-need. We contrast our work with that of Maraist et al. in the body of this paper where appropriate.

[1]  Martín Abadi,et al.  The geometry of optimal lambda reduction , 1992, POPL '92.

[2]  R. J. M. Hughes,et al.  Super-combinators a new implementation method for applicative languages , 1982, LFP '82.

[3]  Peter Henderson,et al.  A lazy evaluator , 1976, POPL.

[4]  Nobuko Yoshida,et al.  Optimal reduction in weak-λ-calculus with shared environments , 1993, FPCA '93.

[5]  Daniel P. Friedman,et al.  CONS Should Not Evaluate its Arguments , 1976, ICALP.

[6]  Simon L. Peyton Jones,et al.  The spineless tagless G-machine , 1989, FPCA.

[7]  John Lamping An algorithm for optimal lambda calculus reduction , 1989, POPL '90.

[8]  Matthias Felleisen,et al.  A Syntactic Theory of Sequential State , 1989, Theor. Comput. Sci..

[9]  Matthias Felleisen,et al.  Abstract models of memory management , 1995, FPCA '95.

[10]  Peter Lee,et al.  Call-by-need and continuation-passing style , 1994, LISP Symb. Comput..

[11]  Vinod Kathail,et al.  Optimal interpreters for lambda-calculus based functional languages , 1990 .

[12]  C.-H. Luke Ong The Lazy Lambda Calculus : an investigation into the foundations of functional programming , 1988 .

[13]  Matthias Felleisen,et al.  A call-by-need lambda calculus , 1995, POPL '95.

[14]  Gérard P. Huet,et al.  Confluent Reductions: Abstract Properties and Applications to Term Rewriting Systems , 1980, J. ACM.

[15]  S. Purushothaman Iyer,et al.  An Adequate Operational Semantics for Sharing in Lazy Evaluation , 1992, ESOP.

[16]  V. van Oostrom,et al.  Confluence for Abstract and Higher-Order Rewriting , 1994 .

[17]  Henk Barendregt,et al.  The Lambda Calculus: Its Syntax and Semantics , 1985 .

[18]  Zena M. Ariola,et al.  Cyclic lambda graph rewriting , 1994, Proceedings Ninth Annual IEEE Symposium on Logic in Computer Science.

[19]  Pierre Lescanne,et al.  From λσ to λν: a journey through calculi of explicit substitutions , 1994, POPL '94.

[20]  C. J. Bloo,et al.  Preservation of strong normalisation in named lambda calculi with explicit substitution and garbage collection , 1995 .

[21]  Robert Hieb,et al.  The Revised Report on the Syntactic Theories of Sequential Control and State , 1992, Theor. Comput. Sci..

[22]  Matthias Felleisen,et al.  Parameter-passing and the lambda calculus , 1991, POPL '91.

[23]  Martín Abadi,et al.  Explicit substitutions , 1989, POPL '90.

[24]  John Field,et al.  On laziness and optimality in lambda interpreters: tools for specification and analysis , 1989, POPL '90.

[25]  Luc Maranget,et al.  Optimal derivations in weak lambda-calculi and in orthogonal term rewriting systems , 1991, POPL '91.

[26]  John Launchbury,et al.  A natural semantics for lazy evaluation , 1993, POPL '93.

[27]  Zena M. Ariola,et al.  Lambda Calculus with Explicit Recursion , 1997, Inf. Comput..

[28]  Zena M. Ariola,et al.  Properties of a First-Order Functional Language with Sharing , 1995, Theor. Comput. Sci..

[29]  Simon Peyton Jones,et al.  The Implementation of Functional Programming Languages (Prentice-hall International Series in Computer Science) , 1987 .

[30]  Gordon D. Plotkin,et al.  Call-by-Name, Call-by-Value and the lambda-Calculus , 1975, Theor. Comput. Sci..

[31]  D. A. Turner,et al.  A new implementation technique for applicative languages , 1979, Softw. Pract. Exp..