Abstract
Large language models (LLMs) are increasingly integrated in software development, but ensuring correctness in LLM-generated code remains challenging and often requires costly manual review. Verifiable code generation—jointly generating code, specifications, and proofs of code-specification alignment—offers a promising path to address this limitation. Yet, there exists a significant gap in evaluation: current benchmarks often focus on only individual components. We introduce Verina (Verifiable Code Generation Arena), a high-quality benchmark enabling a comprehensive and modular evaluation of code, specification, and proof generation. Verina consists of 189 manually curated coding tasks in Lean 4. Our evaluation reveals significant challenges, especially in proof generation: while the best model, OpenAI o4-mini, achieves a 61.4% code correctness rate, its proof success rate is a mere 3.6%.
Introduction
While Large Language Models (LLMs) have revolutionized programming, they remain probabilistic "black boxes" capable of producing functional code that contains subtle bugs or security vulnerabilities. The "Holy Grail" of software engineering is formal verification, where code is mathematically proven to meet a formal specification. If an LLM could generate the code, the specification, and the proof together, we could automate the creation of "guaranteed correct" software. However, existing benchmarks are fragmented, focusing on isolated tasks. VERINA addresses this by providing a rigorous, modular framework to evaluate the entire end-to-end pipeline.
The VERINA Benchmark
VERINA is implemented in Lean 4, a modern general-purpose programming language and theorem prover. The dataset consists of 189 manually curated tasks divided into two subsets:
- VERINA-A: 100 tasks translated and verified from existing verification datasets (MBPP-DFY-50 and CloverBench).
- VERINA-B: 89 more complex, "from-scratch" problems adapted from formal verification coursework.
Each task includes a natural language description, reference implementation, formal specification, proof, and a test suite with 100% line coverage.
Modular Evaluation Methodology
VERINA evaluates three core tasks independently and in combination:
- CodeGen: Code correctness is measured using standard unit tests (pass@k).
- ProofGen: Proofs are evaluated directly by the Lean compiler; a proof is correct if it successfully checks against the code and specification.
- SpecGen: Evaluating generated specifications is complex, as they must be both "sound" (not too loose) and "complete" (not too restrictive).
To assess specification quality, the authors developed a multi-stage evaluator. It first attempts to prove the relationship using an LLM-based theorem prover. If that fails, it falls back to property-based testing (using the Plausible tactic in Lean) to search for counterexamples.
Key Results and Insights
The evaluation of state-of-the-art models reveals a massive "proof gap." While top-tier models like OpenAI’s o4-mini are proficient at writing code (61.4% correctness), they struggle immensely with formal proofs (3.6% success rate in a single trial).
Task Combinations and Context
VERINA also explores how providing ground-truth context affects performance. For instance, providing a ground-truth formal specification significantly improves code generation. Conversely, providing code as context for specification generation often introduces noise, leading to over-constrained or lower-quality specs.
The Power of Iterative Refinement
Closed-loop systems that allow models to see Lean compiler error messages show promise. With 64 rounds of iterative refinement, success rates for proofs on easier tasks jumped from ~7% to ~20%, though this remains computationally expensive. Specialized provers like Goedel Prover V2 32B performed better on proofs (11.2%) but still lagged significantly behind human-level verification capabilities.
Conclusion
VERINA highlights that while LLMs are becoming capable coders, they are still nascent theorem provers. The significant drop-off in performance between translated problems (VERINA-A) and complex, original problems (VERINA-B) underscores the need for better reasoning capabilities in formal logic. By providing a comprehensive benchmark, VERINA aims to catalyze progress toward fully verifiable, automated software development.
Summary updated