Dafny
Also known as Dafny verifier
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.
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
From your code to an accepted proof. Each step either has to be trusted or is checked by something else.
- Input Dafny code
- Front end 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 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.
Verified or checked: outside the trusted base Validated per run or by tests Trusted without proof
- Dafny: Dafny programs are verified, then translated to another language (see the Dafny target's compilation edges).
Trust
What a proof from this toolchain relies on: the trusted computing baseTrusted computing base (TCB). Everything that must be correct for a proof to mean what it says., one part at a time. How these are rated.
- Checker What has the final word on a proof?Partial
Boogie and the Z3 SMT solver decide; no proof certificates.
- Semantics Is the tool's model of the language the real language?Partial
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.
- Frontend How does your source get into the model?Strong
The verifier and the compilers share one Dafny parser and resolver.
- Binary gap Does the proof cover what actually runs?Weak
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.
- Escape hatches Can a proof silently rest on unchecked assumptions?Partial
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.
What it can prove
Kinds of guarantees, not how easy they are to get.
| Feature | Support | Notes |
|---|---|---|
| No undefined behavior Memory safety and absence of runtime errors: no out-of-bounds access, use-after-free, overflow traps, panics or undefined behavior on any input allowed by the precondition. | SupportedSupported.The verifier proves the absence of runtime errors such as out-of-bounds indexing, null dereference and division by zero. Source | The verifier proves the absence of runtime errors such as out-of-bounds indexing, null dereference and division by zero. source |
| Functional correctness The code meets a written specification of its results, for example “returns the sorted list” or “implements this RFC”. | SupportedSupported.Pre- and postconditions, frames (reads and modifies clauses), invariants and lemmas. Source | Pre- and postconditions, frames (reads and modifies clauses), invariants and lemmas. source |
| Equivalence Two programs (an optimized and a reference version, or code before and after a change) are proved to behave the same, or one refines the other. | PartialPartial.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 | 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 |
| Information flow Secrets do not influence public outputs, timing or memory access patterns (constant-time code, non-interference). | Not supportedNot supported.No built-in information-flow or constant-time checking. | No built-in information-flow or constant-time checking. |
| Concurrency Correctness of code with threads or shared memory: absence of data races, deadlock freedom, linearizability of concurrent data structures. | Not supportedNot supported.Dafny is a sequential language. Source | Dafny is a sequential language. source |
| Termination and liveness Every run finishes, or the system keeps making progress (liveness). | SupportedSupported.Loops and recursion need decreases clauses (often inferred). A method can opt out with decreases *, and dafny audit reports such methods. Source | Loops and recursion need decreases clauses (often inferred). A method can opt out with decreases *, and dafny audit reports such methods. source |
Language coverage
Which parts of Dafny it handles. Hover or focus a mark for details.
Common features
| Feature | Support | Notes |
|---|---|---|
| Machine integers Fixed-width integer arithmetic, overflow and bit operations. | SupportedSupported.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 | 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 |
| Floating point IEEE 754 floating-point arithmetic, including rounding and NaNs. | PartialPartial.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 | 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 |
| Heap and pointers Dynamically allocated memory, pointers or references, and aliasing. | SupportedSupported.Classes, references and dynamic allocation, with reads and modifies frames. Source | Classes, references and dynamic allocation, with reads and modifies frames. source |
| Arrays and buffers Indexed memory such as arrays, slices, vectors and byte buffers. | SupportedSupported.One- and multi-dimensional arrays and sequences. Source | One- and multi-dimensional arrays and sequences. source |
| Loops Unbounded loops, which need invariants or bounds to verify. | SupportedSupported.Loop invariants and decreases clauses. Source | Loop invariants and decreases clauses. source |
| Recursion Functions that call themselves, directly or through others. | SupportedSupported. Source | source |
| Higher-order code Function pointers, closures and callbacks. | SupportedSupported.Function values (arrow types) with requires and reads clauses. Source | Function values (arrow types) with requires and reads clauses. source |
| Threads and shared memory Concurrent threads with locks, atomics or message passing. | Not supportedNot supported.Dafny is a sequential language. Source | Dafny is a sequential language. source |
| I/O and system calls Files, network, system calls and foreign-function calls. | PartialPartial.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 | 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 |
| Standard library Specifications or models for the language's standard library. | PartialPartial.Dafny ships standard libraries (enabled with --standard-libraries), and the language has built-in sets, sequences, multisets and maps. Source | Dafny ships standard libraries (enabled with --standard-libraries), and the language has built-in sets, sequences, multisets and maps. source |
Stage
Computed from the evidence below; see the criteria. 1criterion is missing for Stage 2.
- Met: Released or updated in the last 12 months Latest release: 4.11.0, 2025-08-25. Latest commit: 2026-11-26. evidence
- Met: Installs and runs on current platforms 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. evidence
- Met: User documentation or tutorial evidence
- Met: Used by a group other than its authors Consensys wrote a formal model and interpreter of the Ethereum Virtual Machine in Dafny. evidence
- Not met: Verified code in production at two or more independent organizations 1 recorded: Amazon Web Services.
- Met: Checker axis is not red
- Met: Semantics axis is not red
- Met: Public channel for soundness bugs Public GitHub issues; the 'logic' label marks inconsistencies in Dafny's logic. evidence
In use
Verified code in production, and notable verification projects.
In production
- Amazon Web Services AWS authorization engine (invoked about a billion times per second) rewritten in Dafny and deployed in 2024. source
Facts and sources
- Effort
- Auto-active: You write specifications and hints; a solver does the proving.
- Licence
- Open source, MIT
- Maintained by
- Dafny developers (github.com/dafny-lang)
- Latest release
- 4.11.0 (25 Aug 2025) source
- Last checked
- 26 Nov 2026
Further sources
- Dafny Reference Manual (stable) · accessed 26 Nov 2026
- Dafny Reference Manual (development version) · accessed 26 Nov 2026
- Add fp64 type support with IEEE 754 semantics · accessed 26 Nov 2026
- Dafny nightly builds · accessed 26 Nov 2026
- Dafny: An Automatic Program Verifier for Functional Correctness (LPAR 2010) · accessed 26 Nov 2026