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

Haoyu Zhao, Ziran Yang, Jiawei Li, Deyuan He, Zenan Li, Chi Jin, Venugopal V. Veeravalli, Aarti Gupta, Sanjeev Arora · DOI

TL;DR

ALGOVERI is a new benchmark that evaluates how well Large Language Models (LLMs) can generate "vericoded" programs—code accompanied by formal specifications and machine-checkable proofs. By testing 77 classical algorithms across three different verification languages (Dafny, Verus, and Lean), the researchers reveal a massive "intelligence gap": while models can handle high-level automation, they struggle significantly when faced with low-level systems constraints or explicit mathematical reasoning.

What Problem Does This Paper Address?

While LLMs are increasingly used for rapid prototyping, their code often contains subtle, dangerous bugs. Formal verification offers a solution by requiring code to satisfy a mathematical specification, producing a proof that a computer can verify. This paradigm is called "vericoding."

However, evaluating vericoding is currently a mess. Existing benchmarks usually focus on a single language (like Lean or Dafny) and use different sets of tasks. This makes it impossible to tell if a model is "smarter" in one language or if the tasks in that language were just easier. Furthermore, many benchmarks focus on trivial "Leetcoding" problems that don't require the complex, global reasoning needed for real-world software (like maintaining the balance of a Red-Black Tree).

Methods

The authors introduce ALGOVERI, a benchmark consisting of 77 "textbook" algorithms and data structures (e.g., BFS, Bellman-Ford, Segment Trees).

The core innovation is strict parallel alignment: every problem has an identical functional contract (pre-conditions and post-conditions) across three distinct verification systems:

  1. Dafny: An SMT-based language that uses high-level abstractions.
  2. Verus: A system for verifying Rust code, which introduces low-level memory and type constraints.
  3. Lean: An Interactive Theorem Prover (ITP) that requires explicit, step-by-step proof construction.

The evaluation uses a multi-turn refinement pipeline. A model gets 15 rounds to see compiler/verifier error messages and fix its code. Finally, a "Semantic Validator" (an LLM judge) checks if the model actually implemented the intended algorithm or "cheated" by using shortcuts like assume statements or implementing a simpler, incorrect version of the task.

Datasets

  • ALGOVERI (New): 77 complex algorithmic problems, each formalized in Dafny, Verus, and Lean.
  • The paper compares ALGOVERI against existing benchmarks like CLEVER, DafnyBench, and VeriCoding, noting that ALGOVERI is the first to enforce strict alignment across multiple languages while focusing on high-complexity global invariants.

Key Insights and Ideas

  • The "Complexity Cliff": Models perform reasonably well on basic data structures and sorting, but their performance collapses on graph algorithms and tasks requiring "ghost state" (auxiliary variables used only for the proof).
  • Language-Specific Barriers:
    • Dafny allows models to focus on logic because it handles syntax and memory automatically.
  • Verus creates a "syntax barrier." Models get stuck fighting with Rust macros and explicit type casting before they even get to the logic.
  • Lean creates a "search barrier." Models often hallucinate mathematical lemmas or fail to navigate the massive library of tactics required to build a proof.
  • Depth vs. Width: Frontier models (like Gemini-3 Flash) effectively use "depth" (iterative repair) to improve. In Dafny, Gemini tripled its success rate over 15 rounds. Conversely, open-source models (like GPT-OSS) "saturate" early; they don't learn from error messages and are better off just trying many different versions in parallel ("width").

Key Results

The results show that vericoding is far from solved:

  • Gemini-3 Flash achieved the highest scores but still only reached 40.3% success in Dafny, 24.7% in Verus, and a meager 7.8% in Lean.
  • The Fidelity Gap: There is a significant drop (approx. 15% for Gemini in Dafny) between code that "compiles and verifies" and code that is actually semantically correct. Models often try to "game" the verifier by implementing degenerate versions of algorithms.
  • Automation Trade-off: The study quantifies the gap between SMT-based automation (Dafny/Verus) and ITP-based manual proof (Lean), showing that Lean is significantly harder for current AI, despite offering a higher standard of mathematical assurance.

Limitations and Future Work

The authors acknowledge that while Dafny is easier for models, it relies on a large "Trusted Computing Base" (the SMT solver itself could have bugs). Lean is more secure but currently too difficult for LLMs to navigate.

Future work should focus on:

  1. Retrieval-Augmented Reasoning: Helping models find the right lemmas in Lean without hallucinating.
  2. Improving Open Models: Closing the "intelligence gap" so open-source models can actually benefit from iterative compiler feedback.
  3. Scaling: Moving beyond textbook algorithms to large-scale, distributed systems verification.

Summary updated

BibTeX
@inproceedings{zhao2026algoveri,
  author = {Haoyu Zhao and Ziran Yang and Jiawei Li and Deyuan He and Zenan Li and Chi Jin and Venugopal V. 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