arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.06360cs.PL
收藏

Pyrosome:模块化元理论的验证编译

Pyrosome: Verified Compilation for Modular Metatheory

Dustin Jamner, Gabriel Kammer, Ritam Nag, Adam Chlipala

AI总结:

Pyrosome 是一个 Coq 实现的模块化元理论框架,通过归纳等价保持实现可扩展的验证编译,支持特性扩展和编译器垂直组合,并展示了从 System F 到 CPS 及闭包转换的多遍编译案例。

摘要:

我们提出 Pyrosome,一个用于模块化语言元理论的通用框架,它体现了一种可扩展语义和编译的新方法,并在 Coq 中实现。常见的语义推理技术往往与其所支持的语言和编译器的具体结构绑定。在 Pyrosome 中,验证编译器是完全可扩展的,这意味着扩展一种语言(即使增加一种新的效应)只需定义并验证新特性的编译,而所有其他情况则复用旧的正确性定理。其新颖的关键思想是一种归纳形式的等价保持表述,该表述支持向源语言、目标语言和编译器添加新规则。Pyrosome 定义了形式化的、深度嵌入的编程语言概念,其语义由依值排序的等式理论给出,因此所有编译器正确性证明都归结为类型检查和等式推理。除了特性扩展,我们还支持框架中任何编译器的垂直组合。作为案例研究,我们提出了一个从带简单引用的 System F 出发,经过 CPS 变换和闭包转换的多遍编译器。具体来说,我们演示了如何通过从简单类型 lambda 演算的编译器开始,逐步添加自然数、单元类型、递归函数和全局堆,然后扩展带有类型环境的判断并添加类型抽象,来增量构建这样的编译器,同时复用原始定理。我们还提出了简单类型 CPS 遍的线性版本,并将一个小型命令式语言编译到简单类型目标,以展示 Pyrosome 如何处理子结构类型和命令式特性。

英文摘要:

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. In Pyrosome, verified compilers are fully extensible, meaning that to extend a language (even with a new kind of effect) 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. 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑