Learning from Mutants: Teaching Small Language Models to Synthesise Loop Invariants
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have proven promising for synthesising loop invariants, a long-standing obstacle to automated program verification. Yet, frontier LLMs are typically accessible only through third-party APIs, hampering reproducibility and local deployment. Small language models (SLMs) sidestep these obstacles but require task-specific fine-tuning, for which high-quality training data is needed. We present a failure-driven data curation method for fine-tuning language models to synthesise loop invariants. Inspired by mutation testing, our approach applies semantic mutation operators to ground-truth invariants, producing semantic mutants that induce verification failure. Each mutant is paired with verifier feedback and its ground-truth counterpart, yielding training examples for feedback-guided invariant refinement. Whereas the vast space of mutants is a long-standing burden in mutation testing, it becomes an asset when generating training data, multiplying the examples obtainable from a fixed set of verified programs. We implement our approach for Dafny, augmenting an existing synthetic dataset of verified programs, and introduce a framework that iteratively refines candidate invariants using verifier feedback. On 472 DafnyBench programs, our best-performing fine-tuned Gemma-4-E4B configuration verifies 50.8% of programs zero-shot, compared to 8.1% for the base model, a 6.3× improvement. Higher-order mutants prove more effective as training data than first-order mutants, and adding mutation-based examples to direct synthesis examples, in which invariants are removed rather than mutated, improves performance under iterative refinement. Our approach also transfers to Qwen3.5-4B, whose zero-shot verification rate rises from 9.3% to 53.6%.
Key facts. No citing papers in the map yet (data through 24 Nov 2026). Builds on 33 of its 73 references that are in the map. Submitted 14 Nov 2026.
Builds on
33 of 73 references.
References · 33
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 15,591
- 2023QLoRA: Efficient Finetuning of Quantized LLMscited by 3,620
- 2026Gemma 4 Technical Reportcited by 464
- 2025Small Language Models are the Future of Agentic AIcited by 299
- 2024A Comprehensive Survey of Small Language Models in the Era of Large Language Models: Techniques, Enhancements, Applications, Collaboration with LLMs, and Trustworthinesscited by 134
- 2023Baldur: Whole-Proof Generation and Repair with Large Language Modelscited by 133
- 2021Break-It-Fix-It: Unsupervised Learning for Program Repaircited by 72
- 2023Can Large Language Models Transform Natural Language Intent into Formal Method Postconditions?cited by 72
- 2024DafnyBench: A Benchmark for Formal Software Verificationcited by 66
- 2024SpecGen: Automated Generation of Formal Program Specifications via Large Language Modelscited by 61
- 2021Self-Supervised Bug Detection and Repaircited by 60
- 2023Lemur: Integrating Large Language Models in Automated Program Verificationcited by 59
21 more
- 2023Finding Inductive Loop Invariants using Large Language Modelscited by 41
- 2023Can ChatGPT support software verification?cited by 16
- 2024Laurel: Unblocking Automated Verification with Large Language Modelscited by 15
- 2026DafnyPro: LLM-Assisted Automated Verification for Dafny Programscited by 15
- 2024Open LLMs are Necessary for Current Private Adaptations and Outperform their Closed Alternativescited by 14
- 2024dafny-annotator: AI-Assisted Verification of Dafny Programscited by 13
- 2024Learn from Failure: Fine-Tuning LLMs with Trial-and-Error Data for Intuitionistic Propositional Logic Provingcited by 12
- 2024Leveraging Large Language Models to Boost Dafny's Developers Productivitycited by 11
- 2024Specify What? Enhancing Neural Specification Synthesis by Symbolic Methodscited by 9
- 2025ATLAS: Automated Toolkit for Large-Scale Verified Code Synthesiscited by 8
- 2025Quokka: Accelerating Program Verification with LLMs via Invariant Synthesiscited by 7
- 2026AxDafny: Agentic Verified Code Generation in Dafnycited by 5
- 2019A Counterexample-guided Approach to Finding Numerical Invariantscited by 4
- 2025Specification-Guided Repair of Arithmetic Errors in Dafny Programs using LLMscited by 4
- 2025Does Model Size Matter? A Comparison of Small and Large Language Models for Requirements Classificationcited by 4
- 2018Invariant Generation for Multi-Path Loops with Polynomial Assignmentscited by 3
- 2019SymInfer: Inferring Program Invariants using Symbolic Statescited by 3
- 2026Formal Disco: Scalable Open-Ended Generation of Formally Verified Programscited by 3
- 2014Inferring Loop Invariants by Mutation, Dynamic Analysis, and Static Checkingcited by 2
- 2026Evaluating LLM-Generated ACSL Annotations for Formal Verificationcited by 2
- 2026Not All Invariants Are Equal: Curating Training Data to Accelerate Program Verification with SLMscited by 1
Built on by
Not cited yet.