一句话:提出 Coq 中可扩展语义与编译的通用框架 Pyrosome,以归纳式等价保持支持语言特性与编译器增量扩展和垂直组合。
现有语义推理技术常与特定语言或编译器结构绑定:上下文等价难以直接使用,逻辑关系和迁移系统方法通常全局固定效应概念;模块化迁移系统适合命令式代码,却不利于函数式代码,限制了语义的扩展与组合。Pyrosome 是 Coq 中面向模块化语言元理论的通用框架,采用可扩展语义与编译,核心是等价保持的归纳式公式,允许向源语言、目标语言和编译器添加新规则;语言被深度嵌入为依赖排序等式理论,因此编译器正确性证明归结为类型检查与等式推理。框架支持特性扩展、任意编译器的垂直组合,并因要求编译器支持开放程序而保证可与适当类型的目标代码链接。作者以 System F 加简单引用、CPS 翻译和闭包转换构建多遍编译器,并展示线性 CPS 与小型命令式语言编译。
We present Pyrosome, a generic framework for modular language metatheory that embodies a novel approach to extensible semantics and compilation, implemented in Coq. Common techniques for semantic reasoning are often tied to the specific structures of the languages and compilers that they support. Contextual equivalence is difficult to work with directly, and both logical relations and transition system-based approaches typically fix a specific notion of effect globally. While modular transition systems have been effective in imperative settings, they are suboptimal for functional code. These limitations restrict the extension and composition of semantics in these systems. In Pyrosome, verified compilers are fully extensible, meaning that to extend a language simply requires defining and verifying the compilation of the new feature, reusing the old correctness theorem for all other cases. The novel enabling idea is an inductive formulation of equivalence preservation that supports the addition of new rules to the source language, target language, and compiler. Pyrosome defines a formal, deeply embedded notion of programming languages with semantics given by dependently sorted equational theories, so all compiler-correctness proofs boil down to type-checking and equational reasoning. We support vertical composition of any compilers expressed in our framework in addition to feature extension. Since our design requires compilers to support open programs, our correctness guarantees support linking with any target code of the appropriate type. As a case study, we present a multipass compiler from System F with simple references, through CPS translation and closure conversion. Specifically, we demonstrate how we can build such a compiler incrementally by starting with a compiler for simply typed lambda-calculus and adding natural numbers, the unit type, recursive functions, and a global heap, then extending judgments with a type environment and adding type abstraction, all while reusing the original theorems. We also present a linear version of the simply typed CPS pass and compile a small imperative language to the simply typed target to show how Pyrosome handles substructural typing and imperative features.
@article{paperbot2937,
title = {Pyrosome: Verified Compilation for Modular Metatheory},
author = {Dustin Jamner and Gabriel Kammer and Ritam Nag and Adam Chlipala},
journal = {Proceedings of the ACM on Programming Languages},
volume = {9},
number = {OOPSLA2},
year = {2025},
doi = {10.1145/3763052}
}