Formal Verification & AI
AI System Automates Assertion Writing to Speed Up Dafny Code Verification
Researchers introduce DAISY, a tool that uses large language models and fault diagnosis to generate missing assertions needed to verify Dafny programs automatically.
Formal program verification with Dafny can catch subtle bugs before code runs, but the process demands significant manual effort. When verification fails, developers must identify where assertions are needed and write them by hand—a tedious task that slows adoption of verification-aware languages.
A team of researchers has tackled this bottleneck with DAISY (Dafny Assertion Inference SYstem), an automated tool that locates missing assertions and generates candidate repairs using large language models (LLMs).
How DAISY Works#
The system operates in three main phases:
- Localization: DAISY identifies where assertions are likely needed by combining verifier error messages with LLM-guided diagnosis.
- Generation: It places assertion placeholders in the code, retrieves similar examples from the codebase, and uses an LLM to propose candidate assertions.
- Validation: Each candidate is tested by running the Dafny verifier to confirm it actually fixes the proof.
This fault-guided approach tightens the search space, making LLM suggestions more targeted and practical than generating assertions from scratch.
Evaluation Results#
To measure DAISY's effectiveness, researchers extended DafnyBench by deliberately removing assertions from verified programs—creating benchmarks with one missing assertion, two missing, and all assertions stripped away. This mirrors real failure scenarios at varying difficulty levels.
Results were encouraging:
- 86% of programs with a single missing assertion were successfully verified after DAISY repaired them
- 36% of programs with two missing assertions were repaired
Notably, successful repairs often differ from the original assertions, suggesting DAISY finds alternative valid proofs rather than reconstructing the original one.
Impact#
These findings indicate that LLM-based assertion inference can substantially reduce the proof-engineering burden, removing a significant friction point in formal verification workflows. By automating what is often the most tedious part of verification-aware development, DAISY could widen adoption of tools like Dafny among developers who want strong correctness guarantees without the manual assertion overhead.

