Quokka: Accelerating Program Verification with LLMs via Invariant Synthesis

Anjiang Wei, Tianran Sun, Tarun Suresh, Haoze Wu, Ke Wang, Alex Aiken

TL;DR

Quokka is a new framework that uses Large Language Models (LLMs) to automatically discover "loop invariants"—the mathematical keys needed to prove that software is safe and correct. By ditching the complex "repair" logic of previous tools in favor of a simple, parallel validation strategy, Quokka achieves state-of-the-art performance and significant verification speedups across a massive new benchmark of complex C programs.

What Problem Does This Paper Address?

Formal program verification is the process of mathematically proving that a piece of code behaves exactly as intended. It is essential for safety-critical systems like flight controllers or medical devices. The "Achilles' heel" of this field is the loop invariant: a logical condition that remains true before, during, and after every iteration of a loop.

Finding these invariants is a 40-year-old challenge that is "undecidable" in the general case, meaning there is no single algorithm that can always find them. While researchers have recently turned to LLMs for help, previous attempts suffered from two main issues:

  1. Unsoundness: Some tools checked if an LLM's guess was "likely" right based on test runs, which isn't a formal proof.
  2. Over-complexity: Other tools treated LLM output as "noisy" and broken, building massive, slow frameworks to "repair" or "reassemble" the LLM's guesses.

Methods

The authors introduce Quokka, which takes a refreshingly simple approach: Just ask the LLM and verify it immediately.

Instead of trying to fix a bad invariant, Quokka uses a "prove-then-use" strategy. When an LLM proposes a candidate invariant $q$, Quokka launches two parallel queries to a formal verifier (specifically UAutomizer):

  • Query A: Is $q$ actually a correct invariant? (Does it hold for all possible executions?)
  • Query B: If we assume $q$ is true, can we now prove the final program assertion?

If both are true, the program is verified. This design allows for massive parallelism and eliminates the need for complex backtracking or recursive repair loops. To boost performance, the team also employed Supervised Fine-Tuning (SFT) using LoRA and Best-of-N sampling, where the model generates multiple candidates and the system selects the one that leads to the fastest proof.

Datasets

The researchers moved away from small, toy examples to create a much more rigorous testing ground:

  • Evaluation Benchmark: 866 instances derived from SV-COMP (the premier software verification competition). These programs are significantly more complex than those in prior studies, featuring multiple loops, pointers, and recursive functions.
  • Training Dataset: 3,589 synthetic C programs. These were generated by prompting GPT-4o with "seed" programs and then using UAutomizer to extract ground-truth invariants from the successful proofs.

Key Insights and Ideas

  • Simplicity is a Feature: As LLMs become more capable (moving from GPT-4 to the "GPT-5" series referenced in the paper), they don't need a "harness" to fix their mistakes. A simple "validate and discard" approach is faster and more robust than complex symbolic repair algorithms.
  • The "Triviality" Trap: A major failure mode for LLMs isn't just being "wrong"—it's being "lazy." The authors found that in 38% of timeout cases, the LLM simply repeated the final assertion as the invariant. While technically correct, this provides no "decomposition benefit" to the solver, failing to make the proof any easier.
  • Parallelism Matters: By checking the correctness of the invariant and its utility in proving the goal at the same time, Quokka significantly reduces the "wall-clock" time required for verification.

Key Results

Quokka consistently outperformed all prior LLM-based verifiers (like LEMUR and Clause2Inv) across various metrics:

  • State-of-the-Art: Using "GPT-5.2" with Best-of-8 sampling, Quokka solved significantly more instances than the UAutomizer baseline and did so faster.
  • Speedup: Under a 60-second timeout, the strongest models solved up to 21 additional "hard" instances that the base solver couldn't handle alone.
  • Model Scaling: The paper demonstrates a clear hierarchy in reasoning capability, with the GPT-5 series and Claude 3.5/4 models significantly outperforming smaller models like Llama-3-8B in generating "strong" (useful) invariants.
  • Fine-Tuning Gains: Even a modest fine-tuning on synthetic data improved the Qwen2.5-7B model's success rate, suggesting that domain-specific training helps LLMs understand the rigid syntax of formal logic.

Limitations and Future Work

Despite the success, the authors note several hurdles:

  • The "Hardest" Problems: For extremely difficult programs (those requiring 500s+ timeouts), the incremental benefit of the LLM diminished. The models struggle to decompose the most complex logical chains.
  • Algebraic Reformulation: LLMs often provide an invariant that is just a "trivial algebraic variant" of the target assertion. Future work is needed to encourage LLMs to find simpler intermediate properties rather than just restating the goal.
  • Resource Contention: While Best-of-N sampling helps, it eventually plateaus (around N=8) because the computational cost of running so many parallel verifier queries begins to outweigh the benefits.

Overall, Quokka demonstrates that as LLMs get smarter, the best way to use them in formal methods is to get out of their way and let a fast, parallel verifier do the talking.

Summary updated

BibTeX
@inproceedings{wei2026quokka,
  author = {Anjiang Wei and Tianran Sun and Tarun Suresh and Haoze Wu and Ke Wang and Alex Aiken},
  title = {{Quokka: Accelerating Program Verification with LLMs via Invariant Synthesis}},
  booktitle = {COLM},
  year = {2026},
  url = {https://openreview.net/forum?id=YvyAcGrpcJ},
}
Figure