Formal verification with Dafny provides strong correctness guarantees, but verification failures often require users to determine where helper assertions are needed and to manually write the assertions necessary for verification to succeed. This proof-engineering burden is difficult, time-consuming, and a barrier to the adoption of verification-aware languages. We present DAISY (Dafny Assertion Inference SYstem), a tool for fault-guided assertion inference in Dafny. Given a Dafny program and a target method, DAISY localizes likely assertion sites using verifier diagnostics, LLM-based localization, or their combination. It then annotates the program with assertion placeholders, retrieves relevant in-context examples, generates candidate assertions with an LLM, and validates candidates by running the Dafny verifier. To evaluate DAISY, we extend DafnyBench with verification-failing variants created by removing helper assertions from verified programs. The resulting benchmark distinguishes between programs with one missing assertion, two missing assertions, and all assertions removed, allowing us to evaluate DAISY on increasingly difficult proof failures. On this benchmark, DAISY verifies 86% of programs with a single missing assertion and 36% of programs with two missing assertions. These results show that fault-guided LLM assertion inference can repair many Dafny verification failures. They also show that successful repairs often differ from the original assertions, reducing proof-engineering effort without reconstructing the original proof.
Figures & tables
Fig. 1: Overview of DAISY : localizing assertion locations, generating candidates, and validating them with Dafny.
Error type
Origin
Loc.
Assertion, Related, LHSValue, Calc, Constructed
Laurel [ 16 ]
B
Postcondition, AssertBy, Forall
Laurel [ 16 ]
E
LoopInvariants
DAISY
E
TimeOut, SubsetConstraints, ElementNotInDomain
DAISY
B
TABLE I: Error types and insertion strategies for DiagFL and DiagFL+. DiagFL uses only the rows marked with Laurel . DiagFL+ extends DiagFL and also uses the rows marked DAISY . B : insert before the diagnostic line l (i.e., at position l−1 ). E : insert at the end of the enclosing block.
Model
# Prompts
Input (M)
Output (K)
Cost ($)
DiagFL+
448
1.0
108
1.6
LLMFL
896
1.6
109
2.1
ExLLMFL
896
2.2
109
2.8
BothFL
896
2.2
109
2.8
FullResponse (1)
448
1.1
185
2.0
FullResponse (10)
4480
11.0
1850
20
TABLE II: Cost estimates for all evaluated configurations using Claude Haiku 4.5. Input/Output tokens are in millions (M) and thousands (K), respectively, considering Claude Haiku 4.5 base price
Model
Localization
Benchmarks
w/o-1
w/o-2
w/o-all
Combined
Haiku
DiagFL
52.5%
6.5%
10.7%
31.0%
DiagFL+
57.6%
3.3%
10.7%
32.4%
LLMFL
49.2%
9.8%
21.4%
31.2%
ExLLMFL
53.4%
9.8%
17.9%
33.3%
BothFL
67.4%
14.1%
21.4%
42.6%
TABLE III: Verification success rate across benchmark categories using the best retrieval strategy, MixEmb 0.25 .
Fig. 2: Assertion insertion-position classification across localization strategies on the combined dataset of 448 Dafny programs using the haiku model.
Example Selection
w/o-1
w/o-2
w/o-all
Combined
NoEx
59.3%
20.7%
14.3%
40.6%
Random
59.7%
20.7%
17.9%
41.1%
TF–IDF
70.3%
23.9%
28.6%
48.7%
CodeEmb
69.9%
23.9%
21.4%
48.0%
MixEmb 0.25
71.6%
26.1%
25.0%
50.0%
MixEmb 0.50
68.2%
28.3%
25.0%
49.1%
TABLE IV: Verification success rate for example-selection strategies using ExactFL fault localization and the haiku model.