一句话:将线性类型与SMT验证结合并集成到Dafny,可显著减少内存推理的证明量与验证时间。
在SMT后端验证语言中推理内存别名与变异十分困难,通常需要手动指定堆不变量并由求解器进行大量别名推理。本文提出一种混合方法,将线性类型与基于SMT的验证结合,并把线性类型集成到Dafny中。其核心思想是把内存推理从验证条件中分离,由线性类型承担部分推理,同时利用SMT查询的表达力扩展线性类型系统的灵活性,支持线性与非线性数据以新颖方式混合封装。作者形式化扩展核心,证明可靠性并给出线性类型检查算法。评估方面,将约24K行已验证存储系统移植到扩展Dafny:91%代码使用线性类型,其余9%仍用SMT堆推理;结果证明行数减少28%,整体验证时间缩短30%,并改善了开发者体验。
Reasoning about memory aliasing and mutation in software verification is a hard problem. This is especially true for systems using SMT-based automated theorem provers. Memory reasoning in SMT verification typically requires a nontrivial amount of manual effort to specify heap invariants, as well as extensive alias reasoning from the SMT solver. In this paper, we present a hybrid approach that combines linear types with SMT-based verification for memory reasoning. We integrate linear types into Dafny, a verification language with an SMT backend, and show that the two approaches complement each other. By separating memory reasoning from verification conditions, linear types reduce the SMT solving time. At the same time, the expressiveness of SMT queries extends the flexibility of the linear type system. In particular, it allows our linear type system to easily and correctly mix linear and nonlinear data in novel ways, encapsulating linear data inside nonlinear data and vice-versa. We formalize the core of our extensions, prove soundness, and provide algorithms for linear type checking. We evaluate our approach by converting the implementation of a verified storage system (about 24K lines of code and proof) written in Dafny, to use our extended Dafny. The resulting system uses linear types for 91% of the code and SMT-based heap reasoning for the remaining 9%. We show that the converted system has 28% fewer lines of proofs and 30% shorter verification time overall. We discuss the development overhead in the original system due to SMT-based heap reasoning and highlight the improved developer experience when using linear types.
@article{paperbot1517,
title = {Linear types for large-scale systems verification},
author = {Jialin Li and Andrea Lattuada and Yi Zhou and Jonathan Cameron and Jon Howell and Bryan Parno and Chris Hawblitzel},
journal = {Proceedings of the ACM on Programming Languages},
volume = {6},
number = {OOPSLA1},
year = {2022},
doi = {10.1145/3527313}
}