一句话:提出两项改进,显著提升基于 Farkas 引理的仿射程序线性不变式生成的扩展性。
不变式生成用于程序形式分析。本文针对无给定目标性质的仿射程序,生成紧致线性不变式。已知唯一可靠且完备的刻画基于 Farkas 引理,但原有方法受非线性约束或组合爆炸影响,难以扩展。作者在 Sankaranarayanan 等 SAS 2004 的实用方法上提出两项独立改进:按程序位置单独生成不变式,从而支持并行处理并进一步减少组合爆炸;在 CNF 到 DNF 展开中采用分段包含测试,以提前发现更多局部包含关系。作者证明新方法保持原方法的精度,并在含非平凡线性不变式的代表性基准上实现数个数量级的运行时加速,即使在串行汇总所有位置的场景下亦然。
Invariant generation is a classical problem to automatically generate invariants to aid the formal analysis of programs. In this work, we consider the problem of generating tight linear-invariants over affine programs (i.e., programs with affine guards and updates) without a prescribed goal property. In the literature, the only known sound and complete characterization to solve this problem is via Farkas’ Lemma (FL), and has been implemented through either quantifier elimination or reasonable heuristics. Although FL-based approaches can generate highly accurate linear invariants from the completeness of FL, the main bottleneck to applying these approaches is the scalability issue caused by either non-linear constraints or combinatorial explosion. We base our approach on the only practical FL-based approach [Sankaranarayanan et al. , SAS 2004] that applies FL with reasonable heuristics, and develop two novel and independent improvements to leverage the scalability. The first improvement is the novel idea to generate invariants at one program location in a single invariant-generation process, so that the invariants for each location are generated separately rather than together in a single computation. This idea naturally leads to a parallel processing that divides the invariant-generation task for all program locations by assigning the locations separately to multiple processors. Moreover, the idea enables us to develop detailed technical improvements to further reduce the combinatorial explosion in the original work [Sankaranarayanan et al. , SAS 2004]. The second improvement is a segmented subsumption testing in the CNF-to-DNF expansion that allows discovering more local subsumptions in advance. We formally prove that our approach has the same accuracy as the original work and thus does not incur accuracy loss on the generated invariants. Moreover, experimental results on representative benchmarks involving non-trivial linear invariants demonstrate that our approach improves the runtime of the original work by several orders of magnitude, even in the non-parallel scenario that sums up the execution time for all program locations. Hence, our approach constitutes the first significant improvement in FL-based approaches for linear invariant generation after almost two decades.
@article{paperbot1467,
title = {Scalable linear invariant generation with Farkas’ lemma},
author = {Hongming Liu and Hongfei Fu and Zhiyong Yu and Jiaxin Song and Guoqiang Li},
journal = {Proceedings of the ACM on Programming Languages},
volume = {6},
number = {OOPSLA2},
year = {2022},
doi = {10.1145/3563295}
}