Verified VCG and Verified Compiler for Dafny

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Nezamabadi, Daniel, Myreen, Magnus O., Tan, Yong Kiam
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911303698743296
author Nezamabadi, Daniel
Myreen, Magnus O.
Tan, Yong Kiam
author_facet Nezamabadi, Daniel
Myreen, Magnus O.
Tan, Yong Kiam
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2512_05262
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Verified VCG and Verified Compiler for Dafny
Nezamabadi, Daniel
Myreen, Magnus O.
Tan, Yong Kiam
Programming Languages
Logic in Computer Science
D.2.4; D.3.1; D.3.4; F.3.1; F.3.2
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.
title Verified VCG and Verified Compiler for Dafny
topic Programming Languages
Logic in Computer Science
D.2.4; D.3.1; D.3.4; F.3.1; F.3.2
url https://arxiv.org/abs/2512.05262