Not All Invariants Are Equal: Curating Training Data to Accelerate Program Verification with SLMs

1Hebrew University of Jerusalem, Israel
2Amherst College, USA
3VMware Research by Broadcom, USA

Wonda Pipeline

We introduce Wonda, a rigorous data curation pipeline that transforms raw verifier output into high-quality training invariants for loop invariant generation task through AST normalization, LLM-driven simplification, and formal quality grading.

Wonda pipeline diagram: verification query, direct verification, AST normalization, LLM simplification, syntax validation, and V1/V2 correctness and sufficiency checks produce qualifying invariants.

Abstract

The synthesis of inductive loop invariants remains a critical bottleneck in automated program verification. While Large Language Models (LLMs) show promise in mitigating this issue, they often fail on complex programs, producing invariants that are invalid or computationally ineffective. Although fine-tuning is a natural strategy to address these limitations, obtaining high-quality training data remains an open challenge. We first formalize the properties required for a high-quality training invariant, and then present Wonda, a rigorous data curation pipeline that extracts such invariants from raw verifier output via AST-based normalization followed by LLM-driven semantic rewriting and augmentation with provable quality guarantees. Fine-tuning Small Language Models (SLMs) on Wonda-curated data yields consistent gains across the Qwen3, Llama-3.1, and Mistral families: the 4B and 8B Qwen3 models nearly double invariant correctness and double speedup rates, while Llama-3.1-8B triples both. On the challenging InvBench suite, the same 4B model outperforms an off-the-shelf model 20× its size and matches the end-to-end verification time of GPT-OSS-120B, while a 14B Qwen3 model matches that of the frontier model GPT-5.2, all without test-time compute overhead.

Why Not Raw Verifier Output?

Example of a raw verbose invariant generated by UAutomizer: 3084 characters, 75 conjuncts, 11 disjuncts

UAutomizer-generated invariants are often correct but verbose, cluttered, and poor training targets.

Fine-tuning on invariants produced by symbolic verifiers such as UAutomizer is a natural way to specialize language models for invariant synthesis. In practice, however, this strategy often fails on hard benchmarks. Raw UAutomizer outputs tend to be syntactically noisy, verifier-specific, and pedagogically weak: they enumerate many disjuncts instead of exposing compact structure that a model can learn to reproduce.

We argue that data quality, rather than model scale alone, is the key bottleneck. Wonda addresses this by curating verifier output into training invariants that are correct, useful for verification, and compact enough to serve as effective supervision.

What Makes a Good Training Invariant?

We formalize four properties that a high-quality training invariant should satisfy:

  • Non-degeneracy: exclude trivial formulas (TRUE, FALSE).
  • Correctness: the invariant holds at the loop location on all relevant executions.
  • Usefulness: using the invariant speeds up verification relative to the baseline verifier.
  • Compactness: a succinct syntactic form that is easier for a model to learn and generalize from.

Wonda’s grading function G ∈ {0, 1, 2, 3} scores each candidate using formal V1 (correctness) and V2 (sufficiency) checks. Only candidates with G ≥ 2 enter the training set.

Example: Simplifying Verbose Invariants

The figures below show concrete V0 → V1 → V2 transformations produced by Wonda. AST normalization removes syntactic noise; LLM simplification rewrites verbose disjunctive forms into compact closed-form expressions that are easier to learn.

Main Results

Table 3. Main results on the Hard instances (n = 123). Results shown as mean ± std. across three runs. Rvalid/correct/speedup: indicator rates (%); S̄>1: mean speedup among accelerated instances; VBP: Virtual Best Performance in seconds (verifier-only baseline VBP: 193s); Solved: baseline timeouts (of 20) resolved per run. Bold indicates best per model scale.
Model Rvalid (%) Rcorrect (%) Rspeedup (%) >1 (×) VBP ↓ (s) VBPE2E ↓ (s) Solved
GPT-5.2 94.0 ± 1.7 72.4 ± 2.2 37.1 ± 1.2 10.7 ± 0.4 155.6 ± 3.0 163.4 ± 3.0 3, 2, 3
GPT-OSS-120B 92.1 ± 1.2 58.0 ± 1.2 27.4 ± 2.9 7.0 ± 1.4 165.8 ± 5.6 167.6 ± 5.7 3, 2, 1
Qwen3-80B 97.8 ± 0.5 38.8 ± 1.7 21.4 ± 1.2 9.5 ± 1.0 169.5 ± 2.1 169.7 ± 2.1 4, 3, 3
Qwen3-14B 96.5 ± 0.5 36.3 ± 1.9 13.6 ± 2.0 7.6 ± 0.9 183.2 ± 1.2 183.6 ± 1.1 1, 2, 1
Qwen3-14B-V2 (Ours) 100.0 ± 0.0 43.4 ± 4.9 18.4 ± 4.2 16.0 ± 3.3 162.1 ± 8.3 162.9 ± 8.1 4, 4, 2
Qwen3-8B (Base) 89.4 ± 7.8 23.8 ± 3.1 10.8 ± 0.5 8.5 ± 5.2 181.6 ± 4.3 181.7 ± 4.2 0, 0, 3
Qwen3-8B-V2 (Ours) 100.0 ± 0.0 42.8 ± 4.6 21.7 ± 1.7 10.7 ± 2.3 166.5 ± 4.3 166.7 ± 4.3 2, 1, 4
Qwen3-4B (Base) 99.2 ± 0.0 22.8 ± 2.2 11.1 ± 0.9 8.9 ± 2.5 185.6 ± 2.4 185.7 ± 2.4 1, 0, 1
Qwen3-4B-V2 (Ours) 100.0 ± 0.0 44.4 ± 2.3 24.7 ± 1.2 12.4 ± 2.2 165.5 ± 3.2 165.7 ± 3.2 3, 2, 2
Qwen3-0.6B (Base) 88.3 ± 0.5 28.5 ± 2.8 12.2 ± 2.2 5.3 ± 3.3 182.9 ± 5.7 183.0 ± 5.7 2, 0, 1
Qwen3-0.6B-V2 (Ours) 99.7 ± 0.5 27.9 ± 0.5 14.1 ± 2.5 8.5 ± 3.1 174.0 ± 5.6 174.1 ± 5.6 2, 2, 1
Llama3.1-8B (Base) 96.2 ± 1.2 14.9 ± 1.7 5.4 ± 2.0 3.7 ± 1.4 186.3 ± 5.1 186.4 ± 5.1 1, 0, 2
Llama3.1-8B-V2 (Ours) 99.7 ± 0.5 45.5 ± 1.4 18.4 ± 2.5 11.3 ± 2.1 168.9 ± 7.6 169.2 ± 7.5 3, 2, 4
Mistral-7B (Base) 93.8 ± 0.9 18.4 ± 2.0 7.3 ± 1.4 6.7 ± 3.6 186.7 ± 1.5 186.9 ± 1.5 0, 0, 0
Mistral-7B-V2 (Ours) 99.5 ± 0.9 31.4 ± 0.5 16.0 ± 0.5 17.0 ± 0.9 169.0 ± 4.3 169.4 ± 4.3 2, 1, 4

Highlights

  • Wonda V2 fine-tuning roughly doubles correctness and speedup rates for Qwen3-4B/8B.
  • Llama3.1-8B-V2 triples both vs. base.
  • Qwen3-14B-V2 matches GPT-5.2 on end-to-end VBP.
  • Qwen3-4B/8B-V2 match GPT-OSS-120B on end-to-end VBP.
  • Qwen3-4B-V2 outperforms a model 20× its size and matches GPT-OSS-120B on VBPE2E.

WONDA Pipeline Ablation

Table 4. WONDA ablation study on the hard split (n = 123; mean ± std. over three runs). V0: raw UAutomizer invariants; V1: AST-normalized; V2: full pipeline. Bold indicates best per model family.
Model Rvalid (%) Rcorrect (%) Rspeedup (%) >1 (×) VBP ↓ (s) VBPE2E ↓ (s)
Qwen3-8B (Base) 89.4 ± 7.8 23.8 ± 3.1 10.8 ± 0.5 8.5 ± 5.2 181.6 ± 4.3 181.7 ± 4.2
Qwen3-8B-V0 88.1 ± 3.9 29.9 ± 3.4 11.5 ± 1.9 9.4 ± 2.6 180.0 ± 2.7 180.6 ± 2.7
Qwen3-8B-V1 97.0 ± 0.9 30.1 ± 0.8 13.0 ± 2.2 9.1 ± 1.9 175.3 ± 3.2 175.5 ± 3.2
Qwen3-8B-V2 (Ours) 100.0 ± 0.0 42.8 ± 4.6 21.7 ± 1.7 10.7 ± 2.3 166.5 ± 4.3 166.7 ± 4.3
Qwen3-4B (Base) 99.2 ± 0.0 22.8 ± 2.2 11.1 ± 0.9 8.9 ± 2.5 185.6 ± 2.4 185.7 ± 2.4
Qwen3-4B-V0 81.3 ± 0.8 29.3 ± 3.5 13.6 ± 1.9 10.1 ± 1.5 177.5 ± 1.5 177.7 ± 1.5
Qwen3-4B-V1 97.6 ± 1.4 33.1 ± 2.3 12.7 ± 2.3 11.4 ± 2.9 174.2 ± 4.7 174.4 ± 4.7
Qwen3-4B-V2 (Ours) 100.0 ± 0.0 44.4 ± 2.3 24.7 ± 1.2 12.4 ± 2.2 165.5 ± 3.2 165.7 ± 3.2
Qwen3-0.6B (Base) 88.3 ± 0.5 28.5 ± 2.8 12.2 ± 2.2 5.3 ± 3.3 182.9 ± 5.7 183.0 ± 5.7
Qwen3-0.6B-V0 85.9 ± 2.6 18.7 ± 0.8 8.9 ± 0.8 11.7 ± 9.4 178.0 ± 2.7 178.1 ± 2.7
Qwen3-0.6B-V1 97.6 ± 1.4 23.3 ± 1.2 9.8 ± 2.2 15.3 ± 0.9 174.4 ± 4.4 174.5 ± 4.4
Qwen3-0.6B-V2 (Ours) 99.7 ± 0.5 27.9 ± 0.5 14.1 ± 2.5 8.5 ± 3.1 174.0 ± 5.6 174.1 ± 5.6
Llama3.1-8B (Base) 96.2 ± 1.2 14.9 ± 1.7 5.4 ± 2.0 3.7 ± 1.4 186.3 ± 5.1 186.4 ± 5.1
Llama3.1-8B-V0 88.9 ± 0.5 31.2 ± 2.0 14.9 ± 0.9 9.3 ± 3.1 175.0 ± 2.5 175.4 ± 2.5
Llama3.1-8B-V1 99.7 ± 0.5 36.3 ± 5.4 14.1 ± 3.7 15.3 ± 3.4 170.0 ± 3.5 170.4 ± 3.5
Llama3.1-8B-V2 (Ours) 99.7 ± 0.5 45.5 ± 1.4 18.4 ± 2.5 11.3 ± 2.1 168.9 ± 7.6 169.2 ± 7.5
Mistral-7B (Base) 93.8 ± 0.9 18.4 ± 2.0 7.3 ± 1.4 6.7 ± 3.6 186.7 ± 1.5 186.9 ± 1.5
Mistral-7B-V0 68.8 ± 2.0 17.1 ± 4.3 6.5 ± 2.8 16.8 ± 2.3 179.1 ± 7.7 179.4 ± 7.7
Mistral-7B-V1 95.9 ± 1.6 24.9 ± 0.9 10.0 ± 3.8 14.3 ± 2.8 175.4 ± 6.4 175.9 ± 6.2
Mistral-7B-V2 (Ours) 99.5 ± 0.9 31.4 ± 0.5 16.0 ± 0.5 17.0 ± 0.9 169.0 ± 4.3 169.4 ± 4.3

Highlights

  • V0 → V1 → V2 traces raw UAutomizer output, AST normalization, and the full WONDA pipeline on Qwen3-4B/8B, Llama-3.1-8B, and Mistral-7B.
  • V0 fine-tuning often lowers Rvalid (e.g., Qwen3-4B and Mistral-7B).
  • V1 restores syntactic validity but yields only modest gains over base.
  • V2 nearly doubles correctness and speedup rates on Qwen3-4B/8B; Llama-3.1-8B-V2 reaches the highest Rcorrect in the table (45.5%), and Mistral-7B recovers from the V0 drop.
  • Only the full WONDA pipeline consistently delivers both syntactic reliability and meaningful verification speedup.

BibTeX

@inproceedings{pinto2026not,
  title={Not All Invariants Are Equal: Curating Training Data to Accelerate Program Verification with {SLM}s},
  author={Ido Pinto and Yizhak Yisrael Elboher and Haoze Wu and Nina Narodytska and Guy Katz},
  booktitle={Forty-third International Conference on Machine Learning},
  year={2026},
  url={https://openreview.net/forum?id=fS28SOioQd}
}