Cyclic Graphs and Memoization in Pure $λ$-Calculus

2026-06-22Programming Languages

Programming LanguagesLogic in Computer Science
AI summary

The authors show that the pure lambda calculus can handle recursion and sharing without needing extra constructs like letrec or special recursion operators. They do this by using a technique called tabling during reduction, which creates a finite graph that represents repeated computations efficiently and correctly. Their approach keeps the system pure, automatically shares repeated work, and can detect infinite loops in finite time. They also demonstrate this by making an interpreter that can compile itself as a pure lambda term.

lambda calculustablingweak-head reductionlazy evaluationgraph reductionmemoizationdynamic programmingoperational semanticsY combinatorfixpoint
Authors
Bo Yang
Abstract
$λ$-calculus normally requires an added recursion construct, a \texttt{letrec}, a $μ$-binder, or a built-in $Y$ for graph reduction, and sharing the repeated work of a memoized or dynamic-programming function normally requires an impure cache. We show that no extension is needed. We apply tabling, the standard method for solving a least-fixpoint equation, to weak-head reduction; this defines a new operational semantics for the pure $λ$-calculus that keeps each term's standard lazy meaning. A term that reaches finitely many distinct states comes out as a finite graph, possibly cyclic; the calculus stays pure, and the graph is sound and independent of reduction order. We implemented this operational semantics as a $λ$-calculus interpreter. It does dynamic programming automatically, sharing repeated subproblems with no memoization table. It creates and transforms cyclic graphs with no added recursion construct. And it decides an unproductive loop, returning $\bot$ for $Ω$ in finite time. What the evaluator returns is a graph, so the $λ$-calculus becomes a DSL for graph computation: the memo table of dynamic programming, the transposition table of game search, and the visited set of graph reachability and points-to analysis are all tabling on state identity, and none of them is written by hand. Compilation is one more such problem: we write a bootstrap compiler that compiles its own source, all as a pure $λ$-term.