paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Folding left and right matters: Direct style, accumulators, and continuations

左折叠与右折叠事关紧要:直接风格、累加器与续延
JFP vol.332023匹配度 1/10 · 该论文属于函数式编程与程序推导领域,讨论左右折叠等价性、累加器与定界CPS的互推导,与用户关注的静态分析、LLM/Agent、浮点程序分析、贝叶斯程序分析均无直接关系。引用 5 inbox
OLIVIER DANVY
crossref: 2026-09-10

AI 速览

一句话:用左右折叠等价性统一互推导直接风格、累加器与定界 CPS,并厘清其成立条件及列表 fold 参数顺序的影响。

论文研究左右折叠在 Peano 数与列表上的等价性,并用 Ohori 和 Sasano 的轻量融合与不动点提升,最小化地互推导三类程序:直接风格结构递归函数、带累加器的结构尾递归函数,以及定界续延传递风格(delimited CPS)的结构尾递归函数。论文给出等价成立的条件:Peano 数原始迭代下无条件成立;原始递归下模归纳步参数的左置换性;列表迭代或递归下若两个 fold 同类型也模左置换性。文章还回顾列表 fold 自 1980 年代以来归纳步参数交换的历史,指出不交换参数时 Bird 与 Wadler 的第二对偶定理更能体现 re-bracketing,而这是递归程序尾递归化的关键。

问题
如何最小化地互推导直接风格、累加器与定界 CPS 三类递归程序,并确定左右折叠等价在 Peano 数和列表上成立所需的条件。
方法
利用 Ohori 与 Sasano 的 lightweight fusion by fixed-point promotion,基于 fold-left 与 fold-right 的等价性进行程序互推导,并分析归纳步参数的左置换性、类型一致性等条件;同时附历史回顾。
评估
以 Peano 数和列表上的 fold 为案例做条件分析与推导;通过重审 Bird-Wadler 对偶定理及列表 fold 参数顺序的历史,说明 re-bracketing 与尾递归化的关系。
原文摘要(Abstract)

Abstract The equivalence of folding left and right over Peano numbers and lists makes it possible to minimalistically inter-derive (1) structurally recursive functions in direct style, (2) structurally tail-recursive functions that use an accumulator, and (3) structurally tail-recursive functions in delimited continuation-passing style, using Ohori and Sasano’s lightweight fusion by fixed-point promotion. When the fold-left and the fold-right functions account for primitive iteration for Peano numbers, this equivalence is unconditional. When they account for primitive recursion for Peano numbers, this equivalence is modulo left permutativity of their induction-step parameter – a property which is more general than associativity and commutativity. And when they account for primitive iteration or for primitive recursion over lists, this equivalence is modulo left permutativity of their induction-step parameter if these two fold functions have the same type. Since the 1980s, however, the two fold functions for lists do not have the same type: the arguments for their induction-step parameter are swapped, a re-ordering that complicated Bird and Wadler’s duality theorems and whose history is reviewed in an appendix. Without this re-ordering, Bird and Wadler’s second duality theorem more visibly accounts for “re-bracketing,” which is a key step to make recursive programs tail recursive in the general area of program development, from Cooper in the 1960s and onwards.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot2147,
  title = {Folding left and right matters: Direct style, accumulators, and continuations},
  author = {OLIVIER DANVY},
  journal = {Journal of Functional Programming},
  volume = {33},
  year = {2023},
  doi = {10.1017/s0956796822000156}
}