NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

VeriEquivBench: An Equivalence Score for Ground-Truth-Free Evaluation of Formally Verifiable Code

Lingfei Zeng, Fengdi Che, Xuhan Huang, Fei Ye, Xu Xu, Binhang Yuan, Jie Fu

TL;DR

This paper introduces VeriEquivBench, a benchmark of 2,389 complex algorithmic problems designed to evaluate how well LLMs can co-generate code and formal specifications. By replacing human-written ground truths with a novel, automated equivalence score that checks bidirectional alignment via the Dafny verifier, it provides a scalable, reliable way to test formal reasoning. The results reveal a massive performance gap: even top-tier models like Claude-4-sonnet fail to solve these complex tasks, highlighting that formally verifiable code generation remains an open frontier.

What Problem Does This Paper Address?

Large Language Models (LLMs) are great at writing code, but ensuring that code is actually correct remains a massive hurdle. While unit tests help, they don't offer provable guarantees. Enter formal verification, where models co-generate code alongside mathematical descriptions of what the code should do (specifications) in languages like Dafny.

However, evaluating these systems has been bottlenecked by a reliance on human-annotated "ground-truth" specifications. This manual process is incredibly labor-intensive, limiting existing benchmarks to a few hundred simple problems. Worse, human experts make mistakes—previous studies found that up to 28% of "ground-truth" specifications contain errors or ambiguities. Furthermore, standard verification is unidirectional: a model can pass verification using a trivial or weak specification that doesn't actually capture the code's real behavior.

Methods

To eliminate the need for flawed human ground truths, the authors propose a two-step, automated evaluation pipeline centered around a novel equivalence score:

  1. Bidirectional Formal Verification: Instead of just checking if the code satisfies the specification, the framework uses the Dafny verifier to check for mutual equivalence. It verifies both directions of implication: does the code fall within the specification, and does the specification tightly describe the code for any input?
  2. Natural Language Alignment: To ensure the formal specification matches the user's original intent, the framework translates the generated specification back into natural language and uses an LLM judge (like Claude-4) to verify semantic equivalence against the original prompt.

Additionally, the authors developed a structured tag-composition pipeline that mixes domains, data structures, and algorithm classes to automatically synthesize entirely novel, contamination-free coding problems.

Figure 1: An end-to-end verifiable coding agent first generates both the implementation and its formal specification, and uses the Dafny verifier to prove their mutual equivalence. It then interacts with the user to validate that the formalized intent matches the desired behaviour. The specification-to-code implication can be verified directly by submitting the generated Dafny program to the verifier. To establish the reverse implication, a verification script is constructed from the generated Dafny program to prove that the code does not exhibit behaviours beyond those described by the specification. Together, these two directions of implication establish mutual equivalence, ensuring both the soundness and completeness of the solution.The verified formal specification is subsequently translated back into natural language, enabling the user to confirm that it faithfully captures their original intent.

Datasets

The paper introduces VeriEquivBench, which scales evaluation to 2,389 complex algorithmic problems pairing natural language queries with formally annotated code. It consists of two main subsets:

  • LeetCode-transformed dataset: 2,174 classic algorithmic problems successfully ported to Dafny.
  • TagComp: 215 entirely synthetic, highly complex problems generated via the tag-composition pipeline to prevent data contamination.

Compared to older benchmarks like DafnySynthesis (average Cyclomatic Complexity of 2.44), VeriEquivBench features significantly more intricate control flows, boasting an average complexity score of 5.63.

Key Insights and Ideas

  • Ground-Truth-Free Evaluation Works: By leveraging bidirectional implication, the framework proves that you don't need a human-written golden standard to rigorously evaluate code and specification quality.
  • The "Co-generation" Bottleneck: LLMs are often capable of generating code or specifications in isolation, but they consistently fail when forced to generate them together in a mutually consistent, verifiable manner.
  • Specification Hacking: Without bidirectional checking, models easily cheat by writing weak post-conditions (e.g., simply asserting that an index is within bounds) rather than fully defining the algorithm's correctness.

Key Results

The benchmark exposes a dramatic capability collapse in state-of-the-art LLMs when moving from simple tasks to complex algorithmic reasoning:

  • On the simpler CloverBench, models like Claude-4-sonnet achieve a 75.81% success rate. However, on VeriEquivBench's TagComp dataset, all tested models failed completely (0% success rate) under the pass@4 metric for exact matching.
  • While Claude-4-sonnet was the best at generating syntactically correct Dafny code (73.79%), it struggled to produce valid proofs.
  • GPT achieved the highest mutual-equivalence rate, but at a meager 2.65%, and qualitative analysis showed it often did so by generating oversimplified "stub" functions rather than solving the actual problem.

Limitations and Future Work

The primary limitation stems from the strictness of the Dafny verifier itself. Dafny often requires highly specific loop invariants or intermediate proof steps (like lemmas) to verify globally quantified claims. Models frequently generate conceptually correct logic that fails verification simply because it lacks these subtle, language-specific hints.

The authors also noted that standard Reinforcement Learning (RL) baselines showed minimal improvement on these tasks, indicating that current self-evolving or RL training paradigms are insufficient for deep formal reasoning and require more sophisticated exploration strategies.

Summary updated

BibTeX
@inproceedings{zeng2026veriequivbench,
  author = {Lingfei Zeng and Fengdi Che and Xuhan Huang and Fei Ye and Xu Xu and Binhang Yuan and Jie Fu},
  title = {{VeriEquivBench: An Equivalence Score for Ground-Truth-Free Evaluation of Formally Verifiable Code}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=tRRHVUwP2B},
}
Figure