你的惰性函数生命的故事:面向惰性程序机械化成本分析的双向需求语义
Story of Your Lazy Function's Life: A Bidirectional Demand Semantics for Mechanized Cost Analysis of Lazy Programs
AI总结:
提出双向需求语义与逆向物理学家方法,无需特殊程序逻辑即可对惰性程序计算成本及摊还持久性进行机械化、模块化推理,并用Rocq Prover完成多个数据结构的形式化证明。
摘要:
惰性求值是一个强大的工具,它能够在函数式编程中实现更好的组合性以及潜在的性能提升,但分析其计算成本具有挑战性。现有工作要么需要手动标注共享,要么依赖分离逻辑来推理可变单元格堆。在本文中,我们提出了一种双向需求语义,允许对惰性程序的计算成本进行外部推理,而无需依赖特殊的程序逻辑。为了展示我们方法的有效性,我们将需求语义应用于多种案例研究,包括插入排序、选择排序、Okasaki的银行家队列以及隐式队列。我们使用Rocq Prover(前身为Coq)形式化地证明了银行家队列和隐式队列既是摊还的又是持久的。我们还提出了逆向物理学家方法,这是经典物理学家方法的一种新颖变体,它支持基于需求语义对摊还和持久性进行机械化、模块化和组合化的推理。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。