The Rust programming language provides a powerful type system that checks linearity and borrowing, allowing code to safely manipulate memory without garbage collection and making Rust ideal for developing low-level, high-assurance systems. For such systems, formal verification can be useful to prove functional correctness properties beyond type safety. This paper presents Verus, an SMT-based tool for formally verifying Rust programs. With Verus, programmers express proofs and specifications using the Rust language, allowing proofs to take advantage of Rust's linear types and borrow checking. We show how this allows proofs to manipulate linearly typed permissions that let Rust code safely manipulate memory, pointers, and concurrent resources. Verus organizes proofs and specifications using a novel mode system that distinguishes specifications, which are not checked for linearity and borrowing, from executable code and proofs, which are checked for linearity and borrowing. We formalize Verus' linearity, borrowing, and modes in a small lambda calculus, for which we prove type safety and termination of specifications and proofs. We demonstrate Verus on a series of examples, including pointer-manipulating code (an xor-based doubly linked list), code with interior mutability, and concurrent code.
翻译:鲁斯特编程语言提供了一种强大的类型系统,可以检查线性与借入,允许代码安全操作内存而不收集垃圾,并使鲁斯特为开发低级别、高保障系统而理想地设计鲁斯特。对于这些系统,正式的核查可以证明功能性正确性,而超出了类型安全性。本文展示了Verus,一个基于SMT的正式核查鲁斯特程序的工具。通过Verus,程序员使用鲁斯特语言提供证据和规格,允许证据利用鲁斯特线性类型和借阅检查。我们展示了这如何允许证据操作线性打印许可,使鲁斯特代码安全操作内存、指针和并行资源。Verus组织证据和规格,使用新式模式系统来区分规格,不检查线性与借用,从可执行的代码和证据中检查线性。我们用鲁斯特语言将线性、借出和模式正式化,用于利用鲁斯特线性类型定义和借阅。我们证明规格和证据的种类安全性终止和终止。我们用一系列例子展示了Verus,包括点代码和同步性内置代码。</s>