Bottom-up β-reduction : uplinks and λ-DAGs ( extended version )

If we represent aλ-calculus term as a DAG rather than a tree, we can efficiently represent the sharing that arises from β-reduction, thus avoiding combinatorial explosion in space. By adding uplinks from a child to its parents, we can efficiently implement β-reduction in a bottom-up manner, thus avoiding combinatorial explosion in time required to search the term in a top-down fashion. We present an algorithm for performingβ-reduction onλ-terms represented as uplinked DAGs; describe its proof of correctness; discuss its relation to alternate techniques such as Lamping graphs, explicit-substitution calculi and director strings; and present some timings of an implementation. Besides being both fast and parsimonious of space, the algorithm is particularly suited to applications such as compilers, theorem provers, and type-manipulation systems that may need to examine terms in-between reductions— .e., the “readback” problem for our representation is trivial. Like Lamping graphs, and unlike director strings or the suspension λ calculus, the algorithm functions by side-effecting the term containing the redex; the representation is not a “persistent” one. The algorithm additionally has the charm of being quite simple; a complete implementation of the data structure and algorithm is 180 lines of SML. ∗Visiting faculty at BRICS, Department of Computer Science, University of Århus.

[1]  A. Church The calculi of lambda-conversion , 1941 .

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

[3]  Richard Kennaway,et al.  Director strings as combinators , 1988, TOPL.

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

[5]  Robin Milner,et al.  Definition of standard ML , 1990 .

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

[7]  Richard Kelsey,et al.  A correspondence between continuation passing style and static single assignment form , 1995, IR '95.

[8]  Andrew W. Appel,et al.  A type-based compiler for standard ML , 1995, PLDI '95.

[9]  Zhong Shao,et al.  Implementing typed intermediate languages , 1998, ICFP '98.

[10]  ShaoZhong,et al.  Implementing typed intermediate languages , 1998 .

[11]  Gopalan Nadathur,et al.  A Notation for Lambda Terms: A Generalization of Environments , 1998, Theor. Comput. Sci..

[12]  Ron Dinishak The optimal implementation of functional programming languages , 2000, SOEN.

[13]  Jørgen Iversen Type Checking Semantic Functions in ASDF , 2004 .

[14]  Philipp Gerhardy A Quantitative Version of Kirk's Fixed Point Theorem for Asymptotic Contractions , 2004 .

[15]  Peter Lee,et al.  TIL: a type-directed, optimizing compiler for ML , 2004, SIGP.

[16]  Peter D. Mosses,et al.  An Action Environment , 2004, LDTA@ETAPS.

[17]  Christian Kirkegaard,et al.  A Runtime System for XML Transformations in Java , 2004, XSym.

[18]  Anders Møller,et al.  The Design Space of Type Checkers for XML Transformation Languages , 2004, ICDT.

[19]  Peter D. Mosses,et al.  Constructive Action Semantics for Core ML , 2005, IEE Proc. Softw..

[20]  Philipp Gerhardy,et al.  Strongly uniform bounds from semi-constructive proofs , 2004, Ann. Pure Appl. Log..