Scalable linear invariant generation with Farkas' lemma
Hongming Liu, Hongfei Fu, Zhiyong Yu, Jiaxin Song, Guoqiang Li
摘要
Invariant generation is the classical problem to automatically generate invariants to aid the formal analysis of programs. In this work, we consider the linear-invariant-generation problem over affine programs (i.e., programs with affine guards and updates). 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 apply these approaches is the scalability issue caused by either non-linear constraints or combinatorial explosion. It has long been an unresolved problem to improve the scalability of FL-based approaches. In this work, we address this issue with novel algorithmic improvements. In detail, 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 only 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 mulitple 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 to discover more local subsumptions in advance. We formally prove that our approach has the same accuracy as the original work, 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 if in the non-parallel scenario that sums up the execution time for all program locations. Thus, our approach constitutes the first significant improvement in FL-based approaches for linear invariant generation after almost two decades.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 5 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Polynomial Invariant Generation for Floating-Point Programs 引用了 Polynomial invariant generation for non-deterministic recursive programs
- Polynomial Invariant Generation for Floating-Point Programs 引用了 Polynomial reachability witnesses via Stellensätze
- Array-Carrying Symbolic Execution for Function Contract Generation 引用了 Polynomial invariant generation for non-deterministic recursive programs
- Array-Carrying Symbolic Execution for Function Contract Generation 引用了 Polynomial reachability witnesses via Stellensätze
- Parallel Abstract Interpretation for Polynomial Programs with Range Bound Assertions 引用了 Polynomial invariant generation for non-deterministic recursive programs
- Asparagus: Automated Synthesis of Parametric Gas Upper-Bounds for Smart Contracts 引用了 Polynomial invariant generation for non-deterministic recursive programs
- Asparagus: Automated Synthesis of Parametric Gas Upper-Bounds for Smart Contracts 引用了 Polynomial reachability witnesses via Stellensätze
- Demystifying Template-Based Invariant Generation for Bit-Vector Programs 引用了 Polynomial invariant generation for non-deterministic recursive programs
- Demystifying Template-Based Invariant Generation for Bit-Vector Programs 引用了 Interval counterexamples for loop invariant learning
- Demystifying Template-Based Invariant Generation for Bit-Vector Programs 引用了 Templates and recurrences: better together
- Polynomial reachability witnesses via Stellensätze 引用了 Polynomial invariant generation for non-deterministic recursive programs
引用它的顶会 Paper5
- Asparagus: Automated Synthesis of Parametric Gas Upper-Bounds for Smart ContractsZhuo Cai, Soroush Farokhnia, Amir Kafshdar Goharshady, S. HitarthOOPSLA 2023 · 16 次引用
- Demystifying Template-Based Invariant Generation for Bit-Vector ProgramsPeisen Yao, Jingyu Ke, Jiahui Sun, Hongfei Fu 等ASE 2023 · 3 次引用
- Polynomial Invariant Generation for Floating-Point ProgramsXuran Cai, Liqian Chen, Hongfei FuCAV 2026
- Array-Carrying Symbolic Execution for Function Contract GenerationWeijie Lu, Jingyu Ke, Hongfei Fu, Zhouyue Sun 等FM 2026
- Parallel Abstract Interpretation for Polynomial Programs with Range Bound AssertionsS. Akshay, Supratik Chakraborty, Soroush Farokhnia, Amir Goharshady 等CAV 2026
它引用的 Paper7
- Polynomial invariant generation for non-deterministic recursive programsKrishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, Ehsan Kafshdar GoharshadyPLDI 2020 · 46 次引用
- Templates and recurrences: better togetherJason Breck, John Cyphert, Zachary Kincaid, Thomas W. RepsPLDI 2020 · 30 次引用
- Polynomial reachability witnesses via StellensätzeAli Asadi, Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady 等PLDI 2021 · 28 次引用
- Interval counterexamples for loop invariant learningRongchen Xu, Fei He, Bow-Yaw WangFSE 2020 · 19 次引用
- Learning fast and precise numerical analysisJingxuan He, Gagandeep Singh, Markus Püschel, Martin T. VechevPLDI 2020 · 18 次引用
相关 Paper
- Affine Loop Invariant Generation via Matrix AlgebraYucheng Ji, Hongfei Fu, Bin Fang, Haibo ChenCAV 2022 · 10 次引用
- Simple Linear Loops: Algebraic Invariants and ApplicationsRida Ait El Manssour, George Kenison, Mahsa Shirmohammadi, Anton VaronkaPOPL 2025 · 2 次引用
- Solvable Polynomial Ideals: The Ideal Reflection for Program AnalysisJohn Cyphert, Zachary KincaidPOPL 2024 · 11 次引用
- Can Large Language Models Reason about Program Invariants?Kexin Pei, David Bieber, Kensen Shi, Charles Sutton 等ICML 2023 · 128 次引用
- Clause2Inv: A Generate-Combine-Check Framework for Loop Invariant InferenceWeining Cao, Guangyuan Wu, Tangzhi Xu, Yuan Yao 等ISSTA 2025 · 2 次引用
