Lune

OOPSLA2022Top-tier venue

Scalable linear invariant generation with Farkas' lemma

Hongming Liu, Hongfei Fu, Zhiyong Yu, Jiaxin Song, Guoqiang Li

Abstract

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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

5 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Polynomial Invariant Generation for Floating-Point Programs cites Polynomial invariant generation for non-deterministic recursive programs
  • Polynomial Invariant Generation for Floating-Point Programs cites Polynomial reachability witnesses via Stellensätze
  • Array-Carrying Symbolic Execution for Function Contract Generation cites Polynomial invariant generation for non-deterministic recursive programs
  • Array-Carrying Symbolic Execution for Function Contract Generation cites Polynomial reachability witnesses via Stellensätze
  • Parallel Abstract Interpretation for Polynomial Programs with Range Bound Assertions cites Polynomial invariant generation for non-deterministic recursive programs
  • Asparagus: Automated Synthesis of Parametric Gas Upper-Bounds for Smart Contracts cites Polynomial invariant generation for non-deterministic recursive programs
  • Asparagus: Automated Synthesis of Parametric Gas Upper-Bounds for Smart Contracts cites Polynomial reachability witnesses via Stellensätze
  • Demystifying Template-Based Invariant Generation for Bit-Vector Programs cites Polynomial invariant generation for non-deterministic recursive programs
  • Demystifying Template-Based Invariant Generation for Bit-Vector Programs cites Interval counterexamples for loop invariant learning
  • Demystifying Template-Based Invariant Generation for Bit-Vector Programs cites Templates and recurrences: better together
  • Polynomial reachability witnesses via Stellensätze cites Polynomial invariant generation for non-deterministic recursive programs
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers5

  1. Asparagus: Automated Synthesis of Parametric Gas Upper-Bounds for Smart ContractsZhuo Cai, Soroush Farokhnia, Amir Kafshdar Goharshady, S. HitarthOOPSLA 2023 · 16 citations
  2. Demystifying Template-Based Invariant Generation for Bit-Vector ProgramsPeisen Yao, Jingyu Ke, Jiahui Sun, Hongfei Fu et al.ASE 2023 · 3 citations
  3. Polynomial Invariant Generation for Floating-Point ProgramsXuran Cai, Liqian Chen, Hongfei FuCAV 2026
  4. Array-Carrying Symbolic Execution for Function Contract GenerationWeijie Lu, Jingyu Ke, Hongfei Fu, Zhouyue Sun et al.FM 2026
  5. Parallel Abstract Interpretation for Polynomial Programs with Range Bound AssertionsS. Akshay, Supratik Chakraborty, Soroush Farokhnia, Amir Goharshady et al.CAV 2026

Builds on7

  1. Polynomial invariant generation for non-deterministic recursive programsKrishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, Ehsan Kafshdar GoharshadyPLDI 2020 · 46 citations
  2. Templates and recurrences: better togetherJason Breck, John Cyphert, Zachary Kincaid, Thomas W. RepsPLDI 2020 · 30 citations
  3. Polynomial reachability witnesses via StellensätzeAli Asadi, Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady et al.PLDI 2021 · 28 citations
  4. Interval counterexamples for loop invariant learningRongchen Xu, Fei He, Bow-Yaw WangFSE 2020 · 19 citations
  5. Learning fast and precise numerical analysisJingxuan He, Gagandeep Singh, Markus Püschel, Martin T. VechevPLDI 2020 · 18 citations

Related papers

  1. Affine Loop Invariant Generation via Matrix AlgebraYucheng Ji, Hongfei Fu, Bin Fang, Haibo ChenCAV 2022 · 10 citations
  2. Simple Linear Loops: Algebraic Invariants and ApplicationsRida Ait El Manssour, George Kenison, Mahsa Shirmohammadi, Anton VaronkaPOPL 2025 · 2 citations
  3. Solvable Polynomial Ideals: The Ideal Reflection for Program AnalysisJohn Cyphert, Zachary KincaidPOPL 2024 · 11 citations
  4. Can Large Language Models Reason about Program Invariants?Kexin Pei, David Bieber, Kensen Shi, Charles Sutton et al.ICML 2023 · 128 citations
  5. Clause2Inv: A Generate-Combine-Check Framework for Loop Invariant InferenceWeining Cao, Guangyuan Wu, Tangzhi Xu, Yuan Yao et al.ISSTA 2025 · 2 citations
Dusk over the sea between two cliffs drawn in fine vertical lines