Search papers, labs, and topics across Lattice.
This paper introduces a new operational semantics for pure $位$-calculus that utilizes tabling for weak-head reduction, eliminating the need for additional recursion constructs or impure caching mechanisms. By allowing terms to be represented as finite, potentially cyclic graphs, the approach retains the standard lazy evaluation semantics while enabling automatic dynamic programming and efficient handling of repeated subproblems. The authors implemented this semantics in a $位$-calculus interpreter that can compile its own source, demonstrating the versatility of pure $位$-calculus as a domain-specific language for graph computation without manual memoization.
A pure $位$-calculus can automatically perform dynamic programming and compile its own source while representing computations as cyclic graphs, all without requiring impure constructs.
$位$-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.