TL;DR
AxDafny (referred to as DafnyProver in the title) is an agentic framework that uses iterative verifier feedback to jointly synthesize executable code and formal proof artifacts in the Dafny programming language. By leveraging a "proposer-reviewer-memory" loop, it achieves a 92.7% success rate on the DafnyBench proof-hinting task and introduces a challenging new competition-style benchmark, LCB-Pro-Dafny, to push the boundaries of verified program synthesis.
What Problem Does This Paper Address?
While Large Language Models (LLMs) have become remarkably good at writing code, ensuring that code is actually correct remains a challenge. Most coding agents rely on unit tests, which can miss edge cases. Formal verification offers a more robust alternative: a verifier mathematically proves that a program satisfies its specification.
However, formal verification is notoriously difficult for both humans and AI. In a language like Dafny, a model can't just write the implementation; it must also generate "proof artifacts"—loop invariants, assertions, and termination arguments—to help the verifier connect the code to the logic. Existing benchmarks either focus on simple tasks or only ask models to fill in missing proof hints for existing code. This paper tackles the harder problem of joint synthesis: generating both the program and the proof from scratch for complex, competition-style problems.
Methods
The authors introduce AxDafny, an agentic architecture designed for an iterative "generate–check–repair" loop. It consists of three main components:
- Proposer: An LLM (like Gemini-3.1-Pro or GPT-5.5) that generates the initial Dafny code and subsequent repairs.
- Reviewer System: A multi-stage filter that performs deterministic checks (ensuring the model didn't "cheat" by weakening the specification or using
assumestatements), runs the actualdafny verifytool, and uses an LLM-as-judge to catch semantic tricks. - Memory Module: A "scratchpad" that maintains a rolling summary of lessons learned from previous failed attempts. This prevents the agent from repeating the same mistakes across its 20-iteration budget.
A key technical detail is the use of the --counterexamples flag in Dafny, which provides the proposer with concrete values that break the current implementation, offering a much richer feedback signal than a simple "pass/fail."
Datasets
The study utilizes two primary benchmarks:
- DafnyBench: An established benchmark for "proof-hint synthesis," where the implementation is provided, and the model must restore missing invariants and assertions.
- LCB-Pro-Dafny (New): Introduced in this paper, this benchmark translates 250 competition-style problems from LiveCodeBench-Pro into Dafny. It includes 100 easy, 100 medium, and 50 hard problems, each with a natural-language description and a formal specification. Unlike previous benchmarks, this requires end-to-end synthesis of both code and proofs.
Key Insights and Ideas
- Verification $\neq$ Performance: One of the most striking findings is that a program can be "verified" (mathematically correct) but still fail in a real-world coding competition. Because Dafny specifications usually focus on functional correctness rather than asymptotic complexity, the agent often produces verified code that is too slow (Time Limit Exceeded) or uses too much memory.
- The Power of Iteration: The agentic loop is significantly more effective for end-to-end synthesis than for simple proof-hinting. On LCB-Pro-Dafny, the iterative process improved success rates from 11.6% (single-shot) to 56.4%.
- Data Scarcity is a Bottleneck: The authors highlight a massive data gap: there are over 3,000 times more Python files on GitHub than Dafny files. This makes the high performance of AxDafny even more impressive, as the underlying models have had far less exposure to the language.
Key Results
- SOTA on DafnyBench: AxDafny (using Gemini-3.1-Pro) achieved 92.7% verification success, outperforming the previous state-of-the-art (DafnyPro) by 6.5 percentage points, notably without needing a specialized library of proof hints.
- LCB-Pro-Dafny Performance: The framework verified 56.4% of tasks overall (75% of Easy, 52% of Medium, and 28% of Hard). This represents a nearly 5x improvement over a non-agentic GPT-5.5 baseline.
- Execution vs. Proof: When verified solutions were compiled to Python and run against standard test suites, many failed due to resource limits (TLE/MLE). For example, on the medium split, 52 tasks were verified, but only 6 passed the original runtime tests.
Limitations and Future Work
The primary limitation is the "Complexity Gap." Current formal specifications don't typically include constraints on time or space complexity. Future work could involve integrating "Resource-Aware" verification to ensure that generated code is not just correct, but also efficient.
Additionally, the authors note that while the agent is highly effective, the "Hard" split of LCB-Pro-Dafny remains far from solved (28% success), suggesting that even with verifier feedback, complex algorithmic reasoning remains a significant hurdle for current LLMs. Finally, the reliance on compiling Dafny to Python introduces its own overhead; native execution or better runtime compatibility layers could close the performance gap.
Summary updated