RefinedRust

A Type System for High-Assurance Verification of Rust Programs

Lennard Gäher, Michael Sammler, Ralf Jung, Robbert Krebbers, Derek Dreyer.

Paper Appendix Git repository Artifact

Rust is a modern systems programming language whose ownership-based type system statically guarantees memory safety, making it particularly well-suited to the domain of safety-critical systems. In recent years, a wellspring of automated deductive verification tools have emerged for establishing functional correctness of Rust code. However, none of the previous tools produce foundational proofs (machine-checkable in a general-purpose proof assistant), and all of them are restricted to the safe fragment of Rust. This is a problem because the vast majority of Rust programs make use of unsafe code at critical points, such as in the implementation of widely-used APIs.

We propose RefinedRust, a refinement type system---proven sound in the Coq proof assistant---with the goal of establishing foundational semi-automated functional correctness verification of both safe and unsafe Rust code. We have developed a prototype verification tool implementing RefinedRust. Our tool translates Rust code (with user annotations) into a model of Rust embedded in Coq, and then checks its adherence to the RefinedRust type system using separation logic automation in Coq. All proofs generated by RefinedRust are checked by the Coq proof assistant, so the automation and type system do not have to be trusted. We evaluate the effectiveness of RefinedRust by verifying a variant of Rust's Vec implementation that involves intricate reasoning about unsafe pointer-manipulating code.

This paper was realized using Iris.