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