Affine Loop Invariant Generation via Matrix Algebra
Yucheng Ji, Hongfei Fu, Bin Fang, Haibo Chen
摘要
Abstract Loop invariant generation, which automates the generation of assertions that always hold at the entry of a while loop, has many important applications in program analysis and formal verification. In this work, we target an important category of while loops, namely affine while loops, that are unnested while loops with affine loop guards and variable updates. Such a class of loops widely exists in many programs yet still lacks a general but efficient approach to invariant generation. We propose a novel matrix-algebra approach to automatically synthesizing affine inductive invariants in the form of an affine inequality. The main novelty of our approach is that (i) the approach is general in the sense that it theoretically addresses all the cases of affine invariant generation over an affine while loop, and (ii) it can be efficiently automated through matrix-algebra (such as eigenvalue, matrix inverse) methods. The details of our approach are as follows. First, for the case where the loop guard is a tautology (i.e., ‘true’), we show that the eigenvalues and their eigenvectors of the matrices derived from the variable updates of the loop body encompass all meaningful affine inductive invariants. Second, for the more general case where the loop guard is a conjunction of affine inequalities, our approach completely addresses the invariant-generation problem by first establishing through matrix inverse the relationship between the invariants and a key parameter in the application of Farkas’ lemma, then solving the feasible domain of the key parameter from the inductive conditions, and finally illustrating that a finite number of values suffices for the key parameter w.r.t a tightness condition for the invariants to be generated. Experimental results show that compared with previous approaches, our approach generates much more accurate affine inductive invariants over affine while loops from existing and new benchmarks within a few seconds, demonstrating the generality and efficiency of our approach.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 3 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Array-Carrying Symbolic Execution for Function Contract Generation 引用了 Polynomial invariant generation for non-deterministic recursive programs
- Array-Carrying Symbolic Execution for Function Contract Generation 引用了 LLM-Generated Invariants for Bounded Model Checking Without Loop Unrolling
- Array-Carrying Symbolic Execution for Function Contract Generation 引用了 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
- LLM-Generated Invariants for Bounded Model Checking Without Loop Unrolling 引用了 Polynomial invariant generation for non-deterministic recursive programs
- Polynomial reachability witnesses via Stellensätze 引用了 Polynomial invariant generation for non-deterministic recursive programs
引用它的顶会 Paper3
- LLM-Generated Invariants for Bounded Model Checking Without Loop UnrollingMuhammad A. A. Pirzada, Giles Reger, Ahmed Bhayat, Lucas C. CordeiroASE 2024 · 7 次引用
- Demystifying Template-Based Invariant Generation for Bit-Vector ProgramsPeisen Yao, Jingyu Ke, Jiahui Sun, Hongfei Fu 等ASE 2023 · 3 次引用
- Array-Carrying Symbolic Execution for Function Contract GenerationWeijie Lu, Jingyu Ke, Hongfei Fu, Zhouyue Sun 等FM 2026
它引用的 Paper10
- 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 次引用
- What's decidable about linear loops?Toghrul Karimov, Engel Lefaucheux, Joël Ouaknine, David Purser 等POPL 2022 · 19 次引用
相关 Paper
- Scalable linear invariant generation with Farkas' lemmaHongming Liu, Hongfei Fu, Zhiyong Yu, Jiaxin Song 等OOPSLA 2022 · 15 次引用
- 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 次引用
- Clause2Inv: A Generate-Combine-Check Framework for Loop Invariant InferenceWeining Cao, Guangyuan Wu, Tangzhi Xu, Yuan Yao 等ISSTA 2025 · 2 次引用
- Multi-phase invariant synthesisDaniel Riley, Grigory FedyukovichFSE 2022 · 13 次引用
