[论文解读] Rust Distilled: An Expressive Tower of Languages
本文提出了 Oxide,一种用于 Rust 的形式化语义,其结构为一系列表达能力逐步增强的语言层级,采用基于区域的线性能力与幽灵区域来建模所有权和借用。该形式化语义支持对内存安全性的精确推理,并为验证 Rust 程序、编译器优化以及语言扩展提供了基础。
Rust represents a major advancement in production programming languages because of its success in bridging the gap between high-level application programming and low-level systems programming. At the heart of its design lies a novel approach to ownership that remains highly programmable. In this talk, we will describe our ongoing work on designing a formal semantics for Rust that captures ownership and borrowing without the details of lifetime analysis. This semantics models a high-level understanding of ownership and as a result is close to source-level Rust (but with full type annotations) which differs from the recent RustBelt effort that essentially models MIR, a CPS-style IR used in the Rust compiler. Further, while RustBelt aims to verify the safety of unsafe code in Rust's standard library, we model standard library APIs as primitives, which is sufficient to reason about their behavior. This yields a simpler model of Rust and its type system that we think researchers will find easier to use as a starting point for investigating Rust extensions. Unlike RustBelt, we aim to prove type soundness using progress and preservation instead of a Kripke logical relation. Finally, our semantics is a family of languages of increasing expressive power, where subsequent levels have features that are impossible to define in previous levels. Following Felleisen, expressive power is defined in terms of observational equivalence. Separating the language into different levels of expressive power should provide a framework for future work on Rust verification and compiler optimization.
研究动机与目标
- 为 Rust 提供一种形式化且可组合的语义,以一种对研究人员和学习者都易于理解的方式捕捉所有权和借用的本质。
- 通过将语义划分为表达能力逐步增强的层级,来应对 Rust 类型系统和借用检查器的复杂性。
- 通过提供严谨的基础,支持未来在形式化验证、编译器优化和语言扩展方面的工作。
- 通过形式化链接和类型系统,支持 Rust 与其他语言之间的安全互操作。
- 通过将底层推理建立在形式化模型之上,为制定安全的不安全代码指南提供依据。
提出的方法
- 使用基于区域的线性能力来建模 Rust 的所有权和借用,其中每个区域代表对某个值的访问能力。
- 引入‘幽灵区域’以在借用期间跟踪别名关系,其与物理内存位置相分离。
- 采用带仪器的运行时语义,通过维护区域上下文来证明进展性和保持性。
- 设计一系列语言(Oxide 0, 1 等),其中每一级在前一级的基础上增加无法在前序层级中表达的表达能力,基于观察等价性。
- 在 Scala 中实现了一个原型类型检查器,并开始在 Coq 中进行形式化证明开发。
- 计划设计一个擦除过程以移除幽灵区域信息,并证明仪器化语义与擦除后语义之间的操作对应性。
实验结果
研究问题
- RQ1如何构建 Rust 的形式化语义,使其反映表达能力逐步增强的层级,同时保持观察等价性?
- RQ2基于区域的线性能力结合幽灵区域,是否能无需手动传递能力即可准确建模 Rust 的所有权和借用?
- RQ3如何利用语言层级支持对 Rust 程序及其验证的模块化推理?
- RQ4在同时建模物理区域与幽灵区域的形式化语义中,可以建立哪些关于类型安全与内存安全的正式保证?
- RQ5此类语义如何作为安全语言扩展与与其他语言互操作的基础?
主要发现
- Oxide 使用基于区域的能力与幽灵区域来建模所有权和借用,支持自动跟踪别名关系与能力传递。
- 该语义被组织为语言层级,每一级均增加前序层级无法表达的功能,通过观察等价性支持 Felleisen 提出的表达能力概念。
- 正在为 Oxide 0 开发进展性和保持性证明,其采用跟踪区域上下文与别名关系的仪器化语义。
- 已实现一个 Scala 原型类型检查器,并启动了 Coq 形式化,支持实验与未来证明开发。
- 该框架支持未来在安全互操作性、语言扩展(例如用于安全多方计算)以及形式化不安全代码指南方面的工作。
- 计划设计一个擦除过程以移除幽灵区域信息,并将证明仪器化语义与擦除后语义之间的操作对应性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。