Verus:使用线性Ghost类型的Rust程序(扩展版)
Verus: Verifying Rust Programs using Linear Ghost Types (extended version)
摘要:
Rust程序设计语言提供了一个强大的类型系统,可以检查线性和借用,允许代码安全地操作内存而无需垃圾回收,使Rust成为开发低级别,高保证系统的理想选择。对于这样的系统,形式化验证可以用来证明类型安全之外的功能正确性。本文介绍了Verus,一个基于SMT的正式验证Rust程序的工具。通过Verus,程序员可以使用Rust语言表达证明和规范,允许证明利用Rust的线性类型和借用检查。我们展示了如何证明操作线性类型的权限,让Rust代码安全地操作内存,指针和并发资源。Verus使用一种新颖的模式系统来组织证明和规范,该模式系统将未检查线性和借用的规范与检查线性和借用的可执行代码和证明区分开来。我们形式化Verus的线性,借用,和模式在一个小的λ演算,我们证明类型安全和终止的规格和证明。我们展示了一系列的例子,包括指针操作代码(一个基于XOR的双向链表),代码内部可变性,并发代码Verus。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。