# Compositional Loop Invariant Inference for Multiphase Programs via Structured Neurosymbolic Reasoning

DevFeed: [Compositional Loop Invariant Inference for Multiphase Programs via Structured Neurosymbolic Reasoning](<https://devfeed.tech/articles/compositional-loop-invariant-inference-for-multiphase-programs-via-structured-neurosymbolic-reasoning-120827.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2611.07882>)

Author: Mingxiu Wang, Jiawei Wang, Shuangxiang Kan, Angela Huo, Yuekang Li, Xi Zheng, Xiao Cheng

Published: 2026-11-06T05:00:00Z

Content type: article

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [Automated reasoning](<https://devfeed.tech/topics/automated-reasoning.md>), [llm-reasoning](<https://devfeed.tech/topics/llm-reasoning.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [branch](<https://devfeed.tech/tags/branch.md>), [candidate](<https://devfeed.tech/tags/candidate.md>), [clover](<https://devfeed.tech/tags/clover.md>), [conditional](<https://devfeed.tech/tags/conditional.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [execution](<https://devfeed.tech/tags/execution.md>), [generate](<https://devfeed.tech/tags/generate.md>), [generation](<https://devfeed.tech/tags/generation.md>), [independent](<https://devfeed.tech/tags/independent.md>), [inference](<https://devfeed.tech/tags/inference.md>), [invariant](<https://devfeed.tech/tags/invariant.md>), [invariants](<https://devfeed.tech/tags/invariants.md>), [linear](<https://devfeed.tech/tags/linear.md>), [llm](<https://devfeed.tech/tags/llm.md>), [loops](<https://devfeed.tech/tags/loops.md>), [reasoning](<https://devfeed.tech/tags/reasoning.md>), [sequence](<https://devfeed.tech/tags/sequence.md>), [smt](<https://devfeed.tech/tags/smt.md>), [structure](<https://devfeed.tech/tags/structure.md>), [structured](<https://devfeed.tech/tags/structured.md>)

## AI overview

CLOVER infers loop invariants for multiphase programs by splitting a loop into symbolic branch sequences and generating a candidate sub-invariant for each execution scenario. If SMT verification finds a counterexample, it traces the failure to the responsible sequence and repairs only that sub-invariant. On the reported benchmarks, CLOVER solved 35 of 54 multiphase programs, compared with 29 for the best LLM-based baseline and 22 for the best traditional method; it also solved 355 of 366 linear and nonlinear programs overall.

## Source excerpt

arXiv:2611.07882v1 Announce Type: new 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.