一句话:提出 Flux,将逻辑精化与 Rust 所有权结合,实现指针程序的易用类型验证与液态推断。
Flux 让逻辑精化与 Rust 所有权机制协同,对底层指针程序做易用的类型验证。其精化类型系统用纯值索引可变位置,借所有权在泛型构造器中抽象子结构推理并支持强更新,还基于 Stacked Borrows 证明良借用良类型程序不会卡住。Flux 作为 Rust 编译器插件实现,利用类型与精化分解,通过 liquid inference 合成循环注解和容器的量化不变式。在向量基准及安全沙箱库片段上,相比 Prusti,规约行数减半、验证时间快一个数量级,注解开销从最高 24%(平均 14%)降到零。
We introduce Flux, which shows how logical refinements can work hand in glove with Rust's ownership mechanisms to yield ergonomic type-based verification of low-level pointer manipulating programs. First, we design a novel refined type system for Rust that indexes mutable locations, with pure (immutable) values that can appear in refinements, and then exploits Rust's ownership mechanisms to abstract sub-structural reasoning about locations within Rust's polymorphic type constructors, while supporting strong updates. We formalize the crucial dependency upon Rust's strong aliasing guarantees by exploiting the Stacked Borrows aliasing model to prove that "well-borrowed evaluations of well-typed programs do not get stuck". Second, we implement our type system in Flux, a plug-in to the Rust compiler that exploits the factoring of complex invariants into types and refinements to efficiently synthesize loop annotations-including complex quantified invariants describing the contents of containers-via liquid inference. Third, we evaluate Flux with a benchmark suite of vector manipulating programs and parts of a previously verified secure sandboxing library to demonstrate the advantages of refinement types over program logics as implemented in the state-of-the-art Prusti verifier. While Prusti's more expressive program logic can, in general, verify deep functional correctness specifications, for the lightweight but ubiquitous and important verification use-cases covered by our benchmarks, liquid typing makes verification ergonomic by slashing specification lines by a factor of two, verification time by an order of magnitude, and annotation overhead from up to 24% of code size (average 14%), to nothing at all.
@article{paperbot1959,
title = {Flux: Liquid Types for Rust},
author = {Nico Lehmann and Adam T. Geller and Niki Vazou and Ranjit Jhala},
journal = {Proceedings of the ACM on Programming Languages},
volume = {7},
number = {PLDI},
year = {2023},
doi = {10.1145/3591283}
}