arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.22908cs.PLcs.LO
收藏

纯 $\lambda$-演算中的循环图与记忆化

Cyclic Graphs and Memoization in Pure $λ$-Calculus

Figure AI Inc.(Figure AI公司)

Bo Yang

AI总结:

本文提出纯 $\lambda$-演算无需扩展即可实现图归约和自动记忆化,通过制表法定义新操作语义,实现有限状态项的循环图表示,并开发了解释器自动进行动态规划。

摘要:

$\lambda$-演算通常需要添加递归构造、\texttt{letrec}、$\mu$-绑定器或内置 $Y$ 用于图归约,而共享记忆化或动态规划函数的重复工作通常需要不纯的缓存。我们证明不需要任何扩展。我们将制表法(求解最小不动点方程的标准方法)应用于弱头归约;这为纯 $\lambda$-演算定义了一种新的操作语义,保持每个项的标准惰性含义。一个达到有限多个不同状态的项会呈现为有限图,可能是循环的;演算保持纯性,且图是可靠的且与归约顺序无关。我们将此操作语义实现为一个 $\lambda$-演算解释器。它自动进行动态规划,无需记忆化表即可共享重复子问题。它创建和转换循环图,无需添加递归构造。并且它判定无产出循环,在有限时间内为 $\Omega$ 返回 $\bot$。求值器返回的是图,因此 $\lambda$-演算成为图计算的领域特定语言:动态规划的记忆表、博弈搜索的换位表、图可达性和指针分析的访问集都是基于状态标识的制表,且均无需手动编写。编译是另一个此类问题:我们编写了一个自举编译器,编译其自身源码,全部作为纯 $\lambda$-项。

英文摘要:

Purely functional programming makes immutability and non-strict evaluation its defaults; we push further, making interning and memoization the defaults of computation. In prior operational semantics for the pure $λ$-calculus, representing and transforming cyclic and infinite data 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 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, each solved in finitely many steps, comes out as a finite graph, possibly cyclic; the calculus stays pure, and the graph is faithful 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 in finite time that some terms have no weak head normal form, returning $\bot$ for $Ω$. 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 derived-fact table of Datalog 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑