paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Story of Your Lazy Function’s Life: A Bidirectional Demand Semantics for Mechanized Cost Analysis of Lazy Programs

你的惰性函数的一生:面向惰性程序机械化成本分析的双向需求语义
ICFP 8(ICFP)2024匹配度 2/10 · 该论文属于程序语言形式语义与机械化成本分析,研究惰性求值程序的成本推理,并未涉及 LLM/Agent、静态分析×AI、浮点程序分析或贝叶斯程序分析。仅在“形式化验证/程序分析”这一宽泛方法层面与用户兴趣有弱关联,因此匹配度较低。引用 5 inbox
Li-yao Xia, Laura Israel, Maite Kramarz, Nicholas Coltharp, Koen Claessen, Stephanie Weirich, Yao Li
dblp: 2026-09-10crossref: 2026-09-10arxiv: 2026-09-10

AI 速览

一句话:提出双向需求语义,无需特殊程序逻辑即可外延推理惰性程序成本,并在 Rocq 中机化验证摊销与持久性。

惰性求值能提升函数式程序的组合性与潜在性能,但其计算成本分析颇具挑战:已有工作要么手动标注共享,要么依赖分离逻辑推理可变单元堆。本文提出双向需求语义,无需特殊程序逻辑即可外延推理惰性程序的计算成本。作者将语义用于插入排序、选择排序、Okasaki 银行家队列和隐式队列等案例,并在 Rocq(原 Coq)中形式化证明银行家队列与隐式队列兼具摊销复杂度与持久性。文章还提出反向物理学家方法——经典物理学家方法的变体,使基于需求语义的摊销与持久性推理可机械化、模块化且可组合。

问题
惰性求值的计算成本难以分析:现有方法要么要求手动标注共享,要么依赖分离逻辑推理可变堆。
方法
提出双向需求语义,支持不依赖特殊程序逻辑的惰性程序成本外延推理,并引入反向物理学家方法以支持摊销与持久性推理。
评估
在插入排序、选择排序、Okasaki 银行家队列和隐式队列等案例上应用,并用 Rocq 形式化证明后两者的摊销性与持久性。
原文摘要(Abstract)

Lazy evaluation is a powerful tool that enables better compositionality and potentially better performance in functional programming, but it is challenging to analyze its computation cost. Existing works either require manually annotating sharing, or rely on separation logic to reason about heaps of mutable cells. In this paper, we propose a bidirectional demand semantics that allows for extrinsic reasoning about the computation cost of lazy programs without relying on special program logics. To show the effectiveness of our approach, we apply the demand semantics to a variety of case studies including insertion sort, selection sort, Okasaki’s banker’s queue, and the implicit queue. We formally prove that the banker’s queue and the implicit queue are both amortized and persistent using the Rocq Prover (formerly known as Coq). We also propose the reverse physicist’s method, a novel variant of the classical physicist’s method, which enables mechanized, modular and compositional reasoning about amortization and persistence with the demand semantics.

链接与引用

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

BibTeX
@article{abs-2406-14787,
  title = {Story of Your Lazy Function’s Life: A Bidirectional Demand Semantics for Mechanized Cost Analysis of Lazy Programs},
  author = {Li-yao Xia and Laura Israel and Maite Kramarz and Nicholas Coltharp and Koen Claessen and Stephanie Weirich and Yao Li},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {ICFP},
  year = {2024},
  doi = {10.1145/3674626}
}