Clause2Inv: A Generate-Combine-Check Framework for Loop Invariant Inference
Weining Cao, Guangyuan Wu, Tangzhi Xu, Yuan Yao, Hengfeng Wei, Taolue Chen, Xiaoxing Ma
Abstract
Loop invariant inference is a fundamental, yet challenging, problem in program verification. Recent work adopts the guess-and-check framework, where candidate loop invariants are iteratively generated in the guess step and verified in the check step. A major challenge of this general framework is to produce high-quality candidate invariants in each iteration so that the inference procedure can converge quickly. Empirically, we observe that existing approaches may struggle with guessing the complete invariant due to the complexity of logical connectives, but usually, all the clauses of the correct loop invariant have already appeared in the previous guesses. This motivates us to refine the guess-and-check framework, resulting in a generatecombine-check framework, where the loop invariant inference task is divided into clause generation and clause combination. Specifically, we propose a novel loop invariant inference approach Clause2Inv under the new framework, which consists of an LLM-based clause generator and a counterexample-driven clause combinator. As the clause generator, Clause2Inv leverages LLMs to generate a multitude of clauses; as the clause combinator, Clause2Inv leverages counterexamples from the previous rounds to convert generated clauses into invariants. Our experiments show that Clause2Inv significantly outperforms existing loop invariant inference approaches. For example, Clause2Inv solved 312 (out of 316) linear invariant inference tasks and 44 (out of 50) nonlinear invariant inference tasks, which is at least 93 and 16 more than the existing baselines, respectively. By design, the generate-combine-check framework is flexible to accommodate various existing approaches which are currently under the guess-and-check framework by splitting the guessed candidate invariants into clauses. The evaluation shows that our approach can, with minor adaptation, improve existing loop invariant inference approaches in both effectiveness and efficiency. For example, Code2Inv which solved 210 linear problems with an average solving time of 137.6 seconds can be improved to solve 252 problems with an average solving time of 17.8 seconds.
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.
6 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- MALICE: Memory-aware Loop Invariants Generation on Symbolic Execution Traces cites CLN2INV: Learning Loop Invariants with Continuous Logic Networks
- Ranking LLM-Generated Loop Invariants for Program Verification cites CLN2INV: Learning Loop Invariants with Continuous Logic Networks
- I3DP: Neuro-Symbolic Inductive Invariant Inference for Distributed Protocols cites Ranking LLM-Generated Loop Invariants for Program Verification
Cited by top-tier papers6
- Verification Modulo Tested Library ContractsAbhishek Uppar, Omar Muhammad, Sumanth Prabhu S, Deepak D'Souza et al.PLDI 2026 · 1 citation
- MALICE: Memory-aware Loop Invariants Generation on Symbolic Execution TracesTong Chen, Siyu Liu, Hongyi Zhong, liao zhang et al.ICML 2026
- LLM-Guided Loop Bound Generation for Program Termination VerificationZan Gong, Biting Huang, Fei HeICML 2026
- I3DP: Neuro-Symbolic Inductive Invariant Inference for Distributed ProtocolsWeining Cao, Guangyuan Wu, Yuan Yao, Hengfeng Wei et al.SOSP 2026
- Can LLM Aid in Solving Constraints with Inductive Definitions?Weizhi Feng, Shidong Shen, Jiaxiang Liu, Taolue Chen et al.FM 2026
Builds on9
- CLN2INV: Learning Loop Invariants with Continuous Logic NetworksGabriel Ryan, Justin Wong, Jianan Yao, Ronghui Gu et al.ICLR 2020 · 72 citations
- Ranking LLM-Generated Loop Invariants for Program VerificationSaikat Chakraborty, Shuvendu K. Lahiri, Sarah Fakhoury, Akash Lal et al.EMNLP Findings 2023 · 36 citations
- Global Guidance for Local Generalization in Model CheckingHari Govind Vediramana Krishnan, Yuting Chen, Sharon Shoham, Arie GurfinkelCAV 2020 · 26 citations
- Interval counterexamples for loop invariant learningRongchen Xu, Fei He, Bow-Yaw WangFSE 2020 · 19 citations
- Multi-phase invariant synthesisDaniel Riley, Grigory FedyukovichFSE 2022 · 13 citations
Related papers
- LLM Meets Bounded Model Checking: Neuro-symbolic Loop Invariant InferenceGuangyuan Wu, Weining Cao, Yuan Yao, Hengfeng Wei et al.ASE 2024 · 9 citations
- Loop Invariant Inference through SMT Solving Enhanced Reinforcement LearningShiwen Yu, Ting Wang, Ji WangISSTA 2023 · 11 citations
- Steering Tree-of-Thought Reasoning via Deductive VerificationHaoliang Cheng, Enyi Tang, Shuoxiao Zhang, Jiahe Mao et al.ISSTA 2026
- ExVerus: Verus Proof Repair via Counterexample ReasoningJun Yang, Yuechun Sun, Yi Wu, Rodrigo Caridad et al.ICML 2026 · 3 citations
- Demystifying Template-Based Invariant Generation for Bit-Vector ProgramsPeisen Yao, Jingyu Ke, Jiahui Sun, Hongfei Fu et al.ASE 2023 · 3 citations
