DafnyBench: A Benchmark for Formal Software Verification
Chloe Loughridge, Qinyi Sun, Seth Ahrenbach, Federico Cassano, Chuyue Sun, Ying Sheng, Anish Mudide, Md Rakib Hossain Misu, Nada Amin, Max Tegmark
TL;DR
DafnyBench presents the largest ML-driven benchmark for formal software verification, focusing on auto-generating verification hints to drive the Dafny verifier across 782 ground-truth programs totaling about $53{,}000$ lines of code. The study empirically evaluates multiple LLMs, finding Claude 3 Opus as the top performer with around $67.8\%$ success, while showing that error-message feedback yields diminishing returns and that verification difficulty grows with program size and hint quantity. The work highlights the potential of LLM-assisted verifiers and auto-synthesized proofs, while acknowledging limitations such as data contamination and the scope of evaluation. These insights point to a path toward broader benchmarks, improved LLM-in-the-loop verifiers, and automated synthesis workflows that could substantially lower the cost and increase the adoption of formal verification in software development.
Abstract
We introduce DafnyBench, the largest benchmark of its kind for training and evaluating machine learning systems for formal software verification. We test the ability of LLMs such as GPT-4 and Claude 3 to auto-generate enough hints for the Dafny formal verification engine to successfully verify over 750 programs with about 53,000 lines of code. The best model and prompting scheme achieved 68% success rate, and we quantify how this rate improves when retrying with error message feedback and how it deteriorates with the amount of required code and hints. We hope that DafnyBench will enable rapid improvements from this baseline as LLMs and verification techniques grow in quality.
