paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Closure conversion is safe for space

闭包转换对空间是安全的
ICFP 3(ICFP)2019匹配度 1/10 · 该论文是编译器形式化验证方向,研究闭包转换的语义保持与时空安全,使用 Coq 机械化证明;但它不涉及 LLM/Agent、ML 系统静态分析、浮点程序分析或贝叶斯程序分析,也不属于“用 LLM 改进形式化验证”的交叉方向。引用 20 inbox
Zoe Paraskevopoulou, Andrew W. Appel
crossref: 2026-09-10

AI 速览

一句话:首次形式化证明平坦环境闭包转换保持语义并对时间与空间安全,且计入垃圾回收。

本文形式化证明 CPS λ 演算中平坦环境闭包转换的正确性:保持语义,并保持程序执行所需的时间和空间。作者给出转换前后代码的代价模型,用带 profiling 的语义跟踪时间与空间资源,并计入垃圾回收。为证明资源保持,他们建立与垃圾回收兼容的二元逻辑关系,刻画程序的功能正确性与资源消耗不变量。基于此,论文证明终止源程序的语义、时间与空间安全,以及发散源程序的发散保持与空间安全。这是首个闭包转换空间安全性的形式化证明,结果在 Coq 中机器化,并用于 CertiCoq 编译器从 Gallina 经 CompCert Clight 到汇编的流水线。

问题
闭包转换是编译器常用变换,但其是否保持源程序的时间与空间消耗、尤其是空间安全,此前缺乏形式化证明。
方法
作者为转换前后代码定义带 profiling 的代价语义(计入垃圾回收),并建立与垃圾回收兼容的二元逻辑关系来证明语义保持与资源消耗不变量。
评估
在 Coq 中机器化验证,覆盖终止与发散程序,并作为 CertiCoq 从 Gallina 经 CompCert Clight 到汇编的编译流水线的一部分。
原文摘要(Abstract)

We formally prove that closure conversion with flat environments for CPS lambda calculus is correct (preserves semantics) and safe for time and space, meaning that produced code preserves the time and space required for the execution of the source program. We give a cost model to pre- and post-closure-conversion code by formalizing profiling semantics that keep track of the time and space resources needed for the execution of a program, taking garbage collection into account. To show preservation of time and space we set up a general, "garbage-collection compatible", binary logical relation that establishes invariants on resource consumption of the related programs, along with functional correctness. Using this framework, we show semantics preservation and space and time safety for terminating source programs, and divergence preservation and space safety for diverging source programs. We formally prove that closure conversion with flat environments for CPS lambda calculus is correct (preserves semantics) and safe for time and space, meaning that produced code preserves the time and space required for the execution of the source program. We give a cost model to pre- and post-closure-conversion code by formalizing profiling semantics that keep track of the time and space resources needed for the execution of a program, taking garbage collection into account. To show preservation of time and space we set up a general, "garbage-collection compatible", binary logical relation that establishes invariants on resource consumption of the related programs, along with functional correctness. Using this framework, we show semantics preservation and space and time safety for terminating source programs, and divergence preservation and space safety for diverging source programs. This is the first formal proof of space-safety of a closure-conversion transformation. The transformation and the proof are parts of the CertiCoq compiler pipeline from Coq (Gallina) through CompCert Clight to assembly language. Our results are mechanized in the Coq proof assistant.

链接与引用

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

BibTeX
@article{paperbot590,
  title = {Closure conversion is safe for space},
  author = {Zoe Paraskevopoulou and Andrew W. Appel},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {3},
  number = {ICFP},
  year = {2019},
  doi = {10.1145/3341687}
}