Compositional Loop Invariant Inference for Multiphase Programs via Structured Neurosymbolic Reasoning
Mingxiu Wang, Jiawei Wang, Shuangxiang Kan, Angela Huo, Yuekang Li, Xi Zheng, Xiao Cheng
Abstract
Loop invariants are essential for deductive program verification, yet automatically inferring them for multiphase programs, whose loops contain conditional branches that induce multiple execution phases with distinct behaviors, remains an open problem. Existing LLM-based methods either reason about loops as a whole or use explicit branch information to generate atomic assertions jointly across branches, without maintaining complete candidate sub-invariants for independent generation and targeted repair. We present CLOVER, a structured neurosymbolic reasoning framework for multiphase invariant inference built on two interlinked mechanisms. First, compositional inference: CLOVER statically decomposes a loop into symbolic loop branch sequences, conjunctions of the loop guard and branch conditions that characterize distinct execution scenarios, and guides the LLM to generate candidate sub-invariants for each one independently, so that each LLM query focuses on a single execution scenario rather than the entire loop. Second, counterexample-guided localized refinement: when SMT verification rejects a composed disjunctive invariant, CLOVER traces the counterexample back through the branch structure to identify which specific loop branch sequence caused the failure and repairs only that sub-invariant, preserving all correct components. Both mechanisms are unified by a shared symbolic structure derived from the loop's branch semantics, which guides what the LLM generates, how candidates are composed, and where refinement is directed. We evaluate CLOVER on 316 linear arithmetic, 50 nonlinear arithmetic, and 54 multiphase benchmarks. CLOVER solves 35 of 54 multiphase benchmarks, outperforming the best LLM-based baseline (29) by 20.7\% and the best traditional method (22) by 59.1\%. On linear/nonlinear benchmarks, CLOVER remains competitive, solving 355 of 366 programs overall.
Create a lesson
Metadata
- Comments
- 12 pages, 6 figures
Related papers
Agentic Root Cause Reasoning and Localization of Unsoundness in Static Call Graph Analysis
Shared title terminologycs.SEMohammad Rafieian, Michael Hicks, Shiyi Wei
Admitted Is Not Effective: Lessons from a Notary-Gated Retrospective Loop in an Agentic Pipeline
Shared title terminologycs.SELo Gullstrand Heander, Emma Söderberg, Christofer Rydenfält
Right Verdict, Right Reason? An Execution-Grounded Study of Whether LLM Vulnerability Detectors Understand Vulnerabilities
Shared title terminologycs.SELeizhen Zhang, Sheng Chen
Formally Verified Semidefinite Programming
Shared title terminologycs.SEPerry Hart
Trace2ST: Recovering PLC Structured Text from I/O Traces with LLM Generation and Verification
Shared title terminologycs.SEHsi Chang, Irfan Khan
Where LLM Agents Get Stuck Debugging Databases: Access More Than Reasoning
Shared title terminologycs.SEGustavo Pinto