# Dafny

> Write programs in Dafny with specifications; the verifier proves them through Boogie and Z3, then Dafny compiles the code to C#, Java, Go, JavaScript or Python.

- Kind: toolchain
- Verifies: Dafny (Dafny programs are verified, then translated to another language (see the Dafny target's compilation edges).)
- Effort: Auto-active — You write specifications and hints; a solver does the proving.
- Stage: 1 (Usable)
- Trust: Checker partial, Semantics partial, Frontend strong, Binary gap weak, Escape hatches partial
- Licence: open-source, MIT
- Latest release: 4.11.0 (2025-08-25) https://github.com/dafny-lang/dafny/releases/tag/v4.11.0
- Latest commit: 2026-11-26 https://github.com/dafny-lang/dafny/commits/master
- Links: [homepage](https://dafny.org/), [repo](https://github.com/dafny-lang/dafny), [docs](https://dafny.org/latest/DafnyRef/DafnyRef), [paper](https://doi.org/10.1007/978-3-642-17511-4_20), [tutorial](https://dafny.org/latest/OnlineTutorial/guide)

## Use it if
- You are writing new code and can write it in Dafny rather than your production language.
- You want automatic proofs of functional correctness and termination with a short learning curve.
- You want to ship the verified logic as a library in C#, Java, Go, JavaScript or Python.

## Look elsewhere if
- You need to verify existing code in another language; Dafny only verifies Dafny code.
- You need concurrency; Dafny is a sequential language.
- You need the proof checked by a small proof kernel; Dafny trusts Boogie and Z3, and the compilers are not verified.

## How it works (pipeline)

| Step | Component | Assurance | Note |
|---|---|---|---|
| frontend | Dafny parser and resolver | trusted | The same parser and type checker are used for verification and for compilation. |
| translation | Dafny-to-Boogie translator, then Boogie's verification-condition generator | trusted |  |
| checker | Z3 (`z3`) | trusted |  |
| compiler | Dafny code generators (C#, Java, Go, JavaScript, Python; C++ and Rust are limited or in development) and the target language's own compiler | trusted | Specifications and ghost code are erased. Neither the Dafny code generators nor the target compilers are verified. |

## Trust

| Axis | Level | Summary | Note |
|---|---|---|---|
| Checker | Partial (amber) | Boogie and the Z3 SMT solver decide; no proof certificates. |  [source](https://dafny.org/latest/DafnyRef/DafnyRef) |
| Semantics | Partial (amber) | Dafny's meaning is defined by its translation to Boogie; no published validation of it. | The reference manual describes the language in prose; the Boogie encoding inside the tool is what the proofs are about. [source](https://dafny.org/latest/DafnyRef/DafnyRef) |
| Frontend | Strong (green) | The verifier and the compilers share one Dafny parser and resolver. |  [source](https://dafny.org/latest/DafnyRef/DafnyRef#sec-dafny-commands) |
| Binary gap | Weak (red) | Dafny's code generators and the target compilers (C#, Java, Go, ...) are not verified. | AWS wrote its own Dafny-to-Java compiler for readable output in its authorization engine; it is not verified either. [source](https://cdn.amazon.science/bb/40/22ac44f84f6d8eb625ac9666a00f/formally-verified-cloud-scale-authorization.pdf) |
| Escape hatches | Partial (amber) | assume, {:axiom}, {:extern} and {:verify false} exist; dafny audit lists them. | dafny audit is described as under development; it is a separate command, not part of the normal verification output. [source](https://dafny.org/latest/DafnyRef/DafnyRef#sec-dafny-audit) |

## What it can prove

| Property | Support |
|---|---|
| No undefined behavior | Supported — The verifier proves the absence of runtime errors such as out-of-bounds indexing, null dereference and division by zero. ([source](https://dafny.org/latest/DafnyRef/DafnyRef)) |
| Functional correctness | Supported — Pre- and postconditions, frames (reads and modifies clauses), invariants and lemmas. ([source](https://dafny.org/latest/DafnyRef/DafnyRef)) |
| Equivalence | Partial — No dedicated equivalence checker. Module refinement lets one module refine another, and you can prove two Dafny functions equal by hand. In the AWS authorization-engine rewrite, sameness with the old Java engine was checked by differential and shadow testing, not proved. ([source](https://cdn.amazon.science/bb/40/22ac44f84f6d8eb625ac9666a00f/formally-verified-cloud-scale-authorization.pdf)) |
| Information flow | Not supported — No built-in information-flow or constant-time checking. |
| Concurrency | Not supported — Dafny is a sequential language. ([source](https://dafny.org/latest/DafnyRef/DafnyRef)) |
| Termination and liveness | Supported — Loops and recursion need decreases clauses (often inferred). A method can opt out with decreases *, and dafny audit reports such methods. ([source](https://dafny.org/latest/DafnyRef/DafnyRef#sec-dafny-audit)) |

## Common features

| Feature | Support |
|---|---|
| Machine integers | Supported — int is unbounded. Fixed-width integers are written as newtypes with range constraints (so overflow must be proved absent) or as bit-vector types (bv8, bv32, ...). ([source](https://dafny.org/latest/DafnyRef/DafnyRef#sec-numeric-types)) |
| Floating point | Partial — IEEE 754 fp32 and fp64 types were added on the main branch in late 2025 and are in the nightly builds, but not in the latest stable release (4.11.0). The stable release only has mathematical reals. ([source](https://dafny.org/dafny/DafnyRef/DafnyRef#sec-floating-point-type)) |
| Heap and pointers | Supported — Classes, references and dynamic allocation, with reads and modifies frames. ([source](https://dafny.org/latest/DafnyRef/DafnyRef)) |
| Arrays and buffers | Supported — One- and multi-dimensional arrays and sequences. ([source](https://dafny.org/latest/DafnyRef/DafnyRef#sec-array-type)) |
| Loops | Supported — Loop invariants and decreases clauses. ([source](https://dafny.org/latest/DafnyRef/DafnyRef)) |
| Recursion | Supported ([source](https://dafny.org/latest/DafnyRef/DafnyRef)) |
| Higher-order code | Supported — Function values (arrow types) with requires and reads clauses. ([source](https://dafny.org/latest/DafnyRef/DafnyRef#sec-arrow-types)) |
| Threads and shared memory | Not supported — Dafny is a sequential language. ([source](https://dafny.org/latest/DafnyRef/DafnyRef)) |
| I/O and system calls | Partial — print is built in. Other I/O is code written in the target language and declared with {:extern}; Dafny assumes its specifications. The standard library's FileIO module relies on such target-language code. ([source](https://github.com/dafny-lang/dafny/blob/master/Source/DafnyStandardLibraries/README.md)) |
| Standard library | Partial — Dafny ships standard libraries (enabled with --standard-libraries), and the language has built-in sets, sequences, multisets and maps. ([source](https://dafny.org/latest/DafnyRef/DafnyRef#sec-dafny-standard-libraries)) |

## Stage

**Stage 1: Usable.**

| Stage | Criterion | Met | Evidence / note |
|---|---|---|---|
| 0 | Publicly available | yes | [evidence](https://github.com/dafny-lang/dafny) |
| 0 | At least one published verification uses it | yes | [evidence](https://cdn.amazon.science/bb/40/22ac44f84f6d8eb625ac9666a00f/formally-verified-cloud-scale-authorization.pdf) Formally Verified Cloud-Scale Authorization (ICSE 2025). |
| 1 | Released or updated in the last 12 months | yes | [evidence](https://github.com/dafny-lang/dafny/commits/master) Latest release: 4.11.0, 2025-08-25. Latest commit: 2026-11-26. |
| 1 | Installs and runs on current platforms | yes | [evidence](https://github.com/dafny-lang/dafny/releases/tag/v4.11.0) Stable release 4.11.0 (August 2025) for Linux, macOS and Windows; nightly builds of the main branch are also published on the releases page. |
| 1 | User documentation or tutorial | yes | [evidence](https://dafny.org/latest/DafnyRef/DafnyRef) |
| 1 | Used by a group other than its authors | yes | [evidence](https://github.com/Consensys/evm-dafny) Consensys wrote a formal model and interpreter of the Ethereum Virtual Machine in Dafny. |
| 2 | Verified code in production at two or more independent organizations | no | 1 recorded: Amazon Web Services. |
| 2 | Checker axis is not red | yes |  |
| 2 | Semantics axis is not red | yes |  |
| 2 | Public channel for soundness bugs | yes | [evidence](https://github.com/dafny-lang/dafny/issues?q=label%3Alogic) Public GitHub issues; the 'logic' label marks inconsistencies in Dafny's logic. |

Missing for Stage 2: Verified code in production at two or more independent organizations.

## In production
- Amazon Web Services: AWS authorization engine (invoked about a billion times per second) rewritten in Dafny and deployed in 2024. ([source](https://cdn.amazon.science/bb/40/22ac44f84f6d8eb625ac9666a00f/formally-verified-cloud-scale-authorization.pdf))

## Projects
- [AWS authorization engine (AuthV2)](https://cdn.amazon.science/bb/40/22ac44f84f6d8eb625ac9666a00f/formally-verified-cloud-scale-authorization.pdf)
- [Consensys EVM model in Dafny](https://github.com/Consensys/evm-dafny)

## Sources
- [Dafny Reference Manual (stable)](https://dafny.org/latest/DafnyRef/DafnyRef)
- [Dafny Reference Manual (development version)](https://dafny.org/dafny/DafnyRef/DafnyRef)
- [Add fp64 type support with IEEE 754 semantics](https://github.com/dafny-lang/dafny/pull/6323)
- [Dafny nightly builds](https://github.com/dafny-lang/dafny/releases/tag/nightly)
- [Dafny: An Automatic Program Verifier for Functional Correctness (LPAR 2010)](https://doi.org/10.1007/978-3-642-17511-4_20)

---
Last checked 2026-11-26. Data: [JSON](/toolchains/dafny-verifier.json) · Page: [HTML](/toolchains/dafny-verifier/) · Methodology v0.1: [/methodology/](/methodology/) · Corrections: [/contribute/](/contribute/)
