AlgoVeri: An Aligned Benchmark for Verified Code Generation on Classical Algorithms

Haoyu Zhao, Ziran Yang, Jiawei Li, Mike He, Zenan Li, Chi Jin, Venugopal Veeravalli, Aarti Gupta, Sanjeev Arora

Introduction: The Promise of Vericoding

Large Language Models (LLMs) are increasingly deployed for code generation, yet they remain prone to hallucinating subtle bugs that easily bypass standard unit tests. Formal verification offers a robust alternative: instead of merely executing code against test cases, developers write mathematical specifications and generate machine-checkable proofs that the code satisfies these constraints. This paradigm is known as vericoding.

Despite recent AI advancements in vericoding, evaluating model capabilities remains highly fragmented. Existing benchmarks typically focus on a single verification language or employ disparate problem sets for different tools. Consequently, if a model fails in Lean but succeeds in Dafny, it is impossible to determine whether the failure stems from the problem's inherent difficulty or the language's restrictive environment. To address this gap, researchers introduce AlgoVeri, a strictly aligned benchmark designed to evaluate vericoding across distinct verification paradigms using identical algorithmic challenges.

The AlgoVeri Benchmark

AlgoVeri standardizes the evaluation of vericoding by formalizing 77 classical "textbook" algorithms—ranging from basic data structures like Stacks and Queues to complex graph algorithms like Bellman-Ford and Red-Black Trees. Crucially, these algorithms are implemented with identical functional contracts across three distinct verification languages:

  • Dafny: A high-level language relying on SMT (Satisfiability Modulo Theories) automation.
  • Verus: A systems-level, Rust-based verification tool with strict memory management constraints.
  • Lean: An interactive theorem prover requiring explicit proof construction.

By enforcing uniform specifications, AlgoVeri isolates the impact of language design and verification paradigms on LLM performance.

Evaluation Methodology: Prove, Repair, and Validate

To accurately assess model capabilities, AlgoVeri employs a multi-turn "prove-and-repair" pipeline:

  1. Iterative Refinement: Models are not restricted to zero-shot generation. They receive up to 15 rounds of feedback from the compiler and verifier, allowing them to iteratively fix syntax and logic errors.
  2. Semantic Validation: Passing a verifier does not guarantee the model implemented the requested algorithm; it might use "spec gaming" (e.g., using assume(false) to bypass checks) or implement a simpler, unintended solution. To combat this, AlgoVeri utilizes an LLM Judge as a semantic validator to ensure the generated code faithfully executes the target algorithm.

Key Findings: The Complexity Cliff and Language Hierarchy

The benchmark reveals a massive "complexity cliff" in current LLM capabilities. While models demonstrate surprising proficiency with basic data structures, their performance collapses on complex tasks like graph algorithms. These require "ghost state"—auxiliary variables used exclusively for proofs—which current LLMs struggle to conceptualize.

Furthermore, AlgoVeri exposes a clear difficulty gradient tied to language design:

  • Dafny (40.3% success for Gemini-3 Flash): The most accessible paradigm. Its high-level abstractions and SMT automation allow models to focus primarily on logical correctness.
  • Verus (24.7% success): Introduces a significant "syntax barrier." Models frequently become trapped by Rust's strict memory management and systems-level constraints.
  • Lean (7.8% success): Presents a severe "search barrier." The requirement for explicit proof construction often leads models to hallucinate non-existent mathematical lemmas.

Test-Time Compute and the Fidelity Gap

Beyond aggregate metrics, AlgoVeri uncovers a sharp divergence in how models utilize test-time compute during iterative repair. Frontier models, such as Gemini-3 Flash, effectively leverage compiler feedback as a reward signal, continuously improving over 15 rounds and tripling their pass rates in Dafny. Conversely, open-weight models like GPT-OSS-120B (which achieved only 13.5% in Dafny under a single-pass budget) saturate early, typically failing to improve after the third or fourth round of feedback.

The study also highlights a critical fidelity gap of approximately 15%. In these cases, models successfully verified a program that did not actually follow the prompt's instructions (e.g., implementing a basic Union-Find when path compression was explicitly required), underscoring the necessity of AlgoVeri's semantic validation.

Conclusion and Future Directions

AlgoVeri demonstrates that vericoding is far from a solved problem. While SMT-based tools like Dafny and Verus yield higher success rates, they rely on a large Trusted Computing Base, meaning bugs in the verifier itself could theoretically validate incorrect code. Lean offers higher trustworthiness but remains largely intractable for current LLMs.

The authors suggest a future shift toward heterogeneous verification: leveraging high-level SMT automation for rapid prototyping while reserving interactive provers like Lean for critical, kernel-level logic. Additionally, future models will require vastly improved retrieval mechanisms to navigate the extensive lemma libraries demanded by interactive theorem provers.

Summary updated

BibTeX
@inproceedings{zhao2026algoveri,
  author = {Haoyu Zhao and Ziran Yang and Jiawei Li and Mike He and Zenan Li and Chi Jin and Venugopal Veeravalli and Aarti Gupta and Sanjeev Arora},
  title = {{AlgoVeri: An Aligned Benchmark for Verified Code Generation on Classical Algorithms}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=mnUgulPmNU},
}
Figure