Verified VCG and Verified Compiler for Dafny
Paper in proceeding, 2026

Dafny is a verification-aware programming language that comes with a compiler and static program verifier. However, neither the compiler nor the verifier is proved correct; in fact, soundness bugs have been found in both tools. This paper shows that the aforementioned Dafny tools can be developed with foundational correctness guarantees. We present a functional big-step semantics for an imperative subset of Dafny and, based on this semantics, a verified verification condition generator (VCG) and a verified compiler for Dafny. The subset of Dafny we have formalized includes mutually recursive method calls, while loops, and arrays - -these language features are significant enough to cover challenging examples such as McCarthy's 91 function and array-based programs that are used when teaching Dafny. The verified VCG allows one to prove functional correctness of annotated Dafny programs, while the verified compiler can be used to compile verified Dafny programs to CakeML programs. From there, one can obtain executable machine code via the (already verified) CakeML compiler, all while provably maintaining the functional correctness guarantees that were proved for the source-level Dafny programs. Our work has been mechanized in the HOL4 theorem prover.

verified compilation

verified verification condition generator

interactive theorem proving

CakeML

Dafny

Author

Daniel Nezamabadi

Swiss Federal Institute of Technology in Zürich (ETH)

Magnus Myreen

Chalmers, Computer Science and Engineering (Chalmers), Formal methods

University of Gothenburg

Yong Kiam Tan

Nanyang Technological University

Agency for Science, Technology and Research (A*STAR)

Cpp 2026 Proceedings of the 15th ACM SIGPLAN International Conference on Certified Programs and Proofs Co Located with Popl 2026

171-186
9798400723414 (ISBN)

15th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2026
Rennes, France,

The next 700 verified compilers

Swedish Research Council (VR) (2021-05165), 2022-01-01 -- 2025-12-31.

Subject Categories (SSIF 2025)

Computer Sciences

Embedded Systems

Computer Systems

DOI

10.1145/3779031.3779092

More information

Latest update

1/28/2026