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

Aeneas:通过函数转换进行Rust验证

Aeneas: Rust Verification by Functional Translation

Son Ho, Jonathan Protzenko

摘要:

我们提出了Aeneas,一个新的基于轻量级功能翻译的Rust程序验证工具链。我们利用Rust丰富的基于区域的类型系统来消除许多Rust程序的内存推理,只要它们不依赖于内部可变性或不安全的代码。这样做,我们减轻了证明工程师基于内存推理的负担,使他们能够专注于代码的功能属性。我们的第一个贡献是一个新的方法来借用和控制别名。我们为LLBC提出了一个纯粹的函数语义,LLBC是一个低级借用演算,它捕获了Rust程序的一个大子集。我们的语义是基于值的,这意味着没有内存、地址或指针算术的概念。我们的语义也是以所有权为中心的,这意味着我们通过基于贷款的语义标准而不是通过基于语法类型的生命周期纪律来执行借款的合理性。我们声称我们的语义抓住了借用机制的本质,而不是它在Rust编译器中的当前实现。我们的第二个贡献是从LLBC到一个纯粹的微积分的翻译。这允许用户通过他们选择的定理证明器来推理原始的Rust程序。为了解决众所周知的终止借用的技术困难,我们依赖于一种新的方法,在这种方法中,我们在存在函数调用的情况下近似借用图。这反过来又允许我们使用一种称为向后函数的新技术设备来执行翻译。我们在Rust和OCaml的混合中实现我们的工具链。我们的评估表明,程序员的验证生产力的显着收益。Rust不遗余力地加强对别名的静态控制;当已经有这么多“免费”的东西时,证明工程师不应该浪费任何时间在内存推理上!

英文摘要:

We present Aeneas, a new verification toolchain for Rust programs based on a lightweight functional translation. We leverage Rust's rich region-based type system to eliminate memory reasoning for many Rust programs, as long as they do not rely on interior mutability or unsafe code. Doing so, we relieve the proof engineer of the burden of memory-based reasoning, allowing them to instead focus on functional properties of their code. Our first contribution is a new approach to borrows and controlled aliasing. We propose a pure, functional semantics for LLBC, a Low-Level Borrow Calculus that captures a large subset of Rust programs. Our semantics is value-based, meaning there is no notion of memory, addresses or pointer arithmetic. Our semantics is also ownership-centric, meaning that we enforce soundness of borrows via a semantic criterion based on loans rather than through a syntactic type-based lifetime discipline. We claim that our semantics captures the essence of the borrow mechanism rather than its current implementation in the Rust compiler. Our second contribution is a translation from LLBC to a pure lambda-calculus. This allows the user to reason about the original Rust program through the theorem prover of their choice. To deal with the well-known technical difficulty of terminating a borrow, we rely on a novel approach, in which we approximate the borrow graph in the presence of function calls. This in turn allows us to perform the translation using a new technical device called backward functions. We implement our toolchain in a mixture of Rust and OCaml. Our evaluation shows significant gains of verification productivity for the programmer. Rust goes to great lengths to enforce static control of aliasing; the proof engineer should not waste any time on memory reasoning when so much already comes "for free"!

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

↑