Not All Invariants Are Equal: Curating Training Data to Accelerate Program Verification with SLMs
Abstract
Lay Summary
Proving that software is mathematically free of bugs is one of computing's hardest problems; it underpins the reliability of critical systems. The main bottleneck is finding "loop invariants," logical facts that stay true every time a loop repeats and are needed to prove the code correct. AI models can guess these, but it remains hard even for frontier models. The usual fix is bigger models. We asked instead: what if the bottleneck is the quality of the examples we teach from? Existing training data comes from automated verification tools that produce correct but bloated examples. It is like learning math from complex solutions that are right but never simplified: you learn the mess instead of the idea. Our pipeline, WONDA, first strips the clutter, then uses a language model to rewrite each example into a compact and more elegant form, with every rewrite formally verified. This produced consistent gains across almost every model we trained: a 4B model outperforms one 20 times larger and rivals even bigger models, and a 14B model matches a top frontier model in end-to-end verification time. This shows that better training data, not just bigger models, can make trustworthy software verification faster and more accessible.