paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Deriving efficient program transformations from rewrite rules

从重写规则推导高效程序变换
ICFP 5(ICFP)2021匹配度 3/10 · 该论文属于 Coq 中的程序变换与形式化证明工程,与用户关注的“AI→PL 用 LLM/Agent 改进静态分析/形式化验证”仅有间接的 PL/形式化背景重合,未涉及 LLM、Agent、浮点或贝叶斯程序分析,因此匹配度偏低。引用 6 inbox
John M. Li, Andrew W. Appel
crossref: 2026-09-10

AI 速览

一句话:提出在 Coq 中从重写规则与辅助数据结构规约半自动推导高效程序变换及其正确性证明的系统。

优化编译器常通过变量绑定映射、延迟替换、出现计数等辅助数据结构,在一次遍历中执行大量级联重写;这些变换由简单重写规则描述,但高效实现与正确性证明因数据结构交互而难以编写。本文提出一个系统,可从重写规则及辅助数据结构规约出发,半自动地同时推导高效程序变换与其正确性证明。系统用依赖类型保证用户填充的证明义务被正确完成,并在 Coq 中实现。作者用其生成 uncurrying、inlining、死代码消除、case 表达式与记录投影的静态求值等优化遍。小规模基准上生成实现有时快于手写版本,最多慢 40%,且某些情况下编写与证明所需代码显著更少。

问题
如何降低实现高效、可证明正确的编译器优化变换的难度,使其既能利用辅助数据结构做级联重写,又能保证正确性。
方法
从重写规则和辅助数据结构规约出发,在 Coq 中用依赖类型半自动推导变换实现与正确性证明,用户只需填充少量证明义务。
评估
在 uncurrying、inlining、死代码消除、case 表达式与记录投影静态求值等优化遍上实现,并在小规模基准上与手写实现比较性能和代码量。
原文摘要(Abstract)

An efficient optimizing compiler can perform many cascading rewrites in a single pass, using auxiliary data structures such as variable binding maps, delayed substitutions, and occurrence counts. Such optimizers often perform transformations according to relatively simple rewrite rules, but the subtle interactions between the data structures needed for efficiency make them tricky to write and trickier to prove correct. We present a system for semi-automatically deriving both an efficient program transformation and its correctness proof from a list of rewrite rules and specifications of the auxiliary data structures it requires. Dependent types ensure that the holes left behind by our system (for the user to fill in) are filled in correctly, allowing the user low-level control over the implementation without having to worry about getting it wrong. We implemented our system in Coq (though it could be implemented in other logics as well), and used it to write optimization passes that perform uncurrying, inlining, dead code elimination, and static evaluation of case expressions and record projections. The generated implementations are sometimes faster, and at most 40% slower, than hand-written counterparts on a small set of benchmarks; in some cases, they require significantly less code to write and prove correct.

链接与引用

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

BibTeX
@article{paperbot1124,
  title = {Deriving efficient program transformations from rewrite rules},
  author = {John M. Li and Andrew W. Appel},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {5},
  number = {ICFP},
  year = {2021},
  doi = {10.1145/3473579}
}