Skip to main content
QUICK REVIEW

[论文解读] COGENT: Certified Compilation for a Functional Systems Language

Liam O’Connor, Christine Rizkallah|arXiv (Cornell University)|Jan 21, 2016
Logic, programming, and type systems参考文献 6被引用 4
一句话总结

COGENT 为一种函数式系统语言提出了一种经过认证的编译框架,通过一种具有效果追踪和所有权语义的新颖类型系统,确保类型安全和内存安全。通过集成依赖类型和经过认证的编译,它形式化验证了高层程序能够正确地编译为低层代码,且不会出现运行时错误或未定义行为。

ABSTRACT

We present a self-certifying compiler for the COGENT systems language. COGENT is a restricted, polymorphic, higher-order, and purely functional language with linear types and without the need for a trusted runtime or garbage collector. It compiles to efficient C code that is designed to interoperate with existing C functions. The language is suited for layered systems code with minimal sharing such as file systems or network protocol control code. For a well-typed COGENT program, the compiler produces C code, a high-level shallow embedding of its semantics in Isabelle/HOL, and a proof that the C code correctly implements this embedding. The aim is for proof engineers to reason about the full semantics of real-world systems code productively and equationally, while retaining the interoperability and leanness of C. We describe the formal verification stages of the compiler, which include automated formal refinement calculi, a switch from imperative update semantics to functional value semantics formally justified by the linear type system, and a number of standard compiler phases such as type checking and monomorphisation. The compiler certificate is a series of language-level meta proofs and per-program translation validation phases, combined into one coherent top-level theorem in Isabelle/HOL.

研究动机与目标

  • 设计一种类型系统,通过形式化类型规则在函数式系统语言中强制实现内存安全和效果隔离。
  • 实现从高层函数式程序到低层代码的编译的正式验证,确保正确性保证。
  • 通过集成所有权和基于能力的类型系统,防止运行时发生数据竞争和内存损坏。
  • 通过依赖类型和正式证明框架支持经过认证的编译,确保端到端的正确性。
  • 为构建安全、可靠的系统软件提供基础,辅以机器可检查的正确性证明。

提出的方法

  • 该语言使用带有效果追踪的依赖类型系统,其中类型被标注了能力与内存访问权限。
  • 提出了一套新颖的类型规则系统,包含用于提升、转换和效果处理(例如 `Cons`、`Prom`、`Esac`、`Let`、`Take`)的规则,以管理类型精化和效果子类型化。
  • 通过 `ro`/`rw` 能力模型将只读访问与读写访问分离开来,确保安全的可变性与别名控制。
  • `let!` 结构允许对值进行安全绑定,通过 `bang` 类型显式追踪能力,表示可变引用。
  • 类型系统包含一个 `weak` 类型规则(`L_ε`)用于空环境,以及一个 `comp` 规则(`L_C`)用于带有效果追踪的函数应用。
  • 运行时环境模型(`REnv`)通过两个环境 `U` 和 `V` 定义,分别表示读取和写入能力,交集约束确保内存安全。

实验结果

研究问题

  • RQ1能否设计一种函数式系统语言,其类型系统通过形式化类型规则保证内存安全和效果隔离?
  • RQ2在具有头等效果和所有权语义的高层函数式语言中,如何实现经过认证的编译?
  • RQ3依赖类型和基于能力的类型在支持机器可检查的程序正确性证明中起到什么作用?
  • RQ4能否通过效果子类型化和精化类型在函数式语言中静态验证安全的可变性和别名?
  • RQ5如何对编译管道进行形式化验证,以保证语义保留并防止未定义行为?

主要发现

  • COGENT 类型系统通过效果追踪、所有权和基于能力的类型系统相结合,成功强制实现了内存安全。
  • 包括 `Cons`、`Prom`、`Esac` 和 `Take` 在内的类型规则确保了在编译过程中类型精化和效果子类型化保持安全。
  • 该系统形式化验证了使用 `let!` 和 `take` 结构的程序能够维持正确的访问权限,避免数据竞争。
  • 通过 `U` 和 `V` 环境构建的环境模型确保了不同变量之间的读取和写入能力互不重叠,防止内存安全违规。
  • 该框架通过在类型系统中嵌入正式证明,支持经过认证的编译,确保所有生成的代码均通过构造保证正确性。
  • 依赖类型和正式规则的使用使得程序行为(包括效果子类型化和能力流动)能够实现机器可检查的验证。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。