Dafny
A programming language with built-in specifications and proofs, compiled to mainstream languages after verification.
What do you want to prove about your Dafny code?
Where proofs can attach
Toolchains that verify Dafny directly, and those that verify what it compiles to. A proof about compiled code also relies on the compiler that produced it.
- Your codeDafny verification language
- Generated code
- Machine code Proofs here are about the binary itself
Verify Dafny directly
Ranked by stage, feature coverage and trust.
| Toolchain | Stage | Trust | Effort | Feature coverage |
|---|---|---|---|---|
| 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. | Stage 1 · Usable | 1/5 | Auto-active | 6/10full, 3 partial |
Verify the compiled code
These prove facts about what the compiler produced, not about your source.
| Toolchain | Stage | Trust | Effort | Path |
|---|---|---|---|---|
| Gobra Add specifications as comments to Go code; Gobra translates it to the Viper verifier, which proves memory safety, race freedom and your contracts. | Stage 1 · Usable | 0/5 | Auto-active | Go (Dafny compiler (Go backend), trusted) |
| KeY Write JML specifications for sequential Java code; KeY's prover, mostly automatic with interactive steps when needed, proves the code meets them. | Stage 1 · Usable | 0/5 | Interactive | Java (Dafny compiler (Java backend), trusted) |
| s2n-bignum Prove hand-written x86-64 or Arm64 assembly correct in HOL Light, on the exact bytes of the built object file; used for AWS's cryptography code. | Stage 1 · Usable | 4/5 | Interactive | Go (Dafny compiler (Go backend), trusted) → x86-64 (gc (the Go compiler), trusted) |
| Islaris Prove Arm or RISC-V machine code correct in Rocq, against the full official Sail ISA models, using Isla symbolic execution and an Iris separation logic. | Stage 0 · Research | 2/5 | Interactive | Go (Dafny compiler (Go backend), trusted) → AArch64 (gc (the Go compiler), trusted) |
| LNSym Prove Armv8 (AArch64) machine code correct in Lean 4 by symbolic simulation over a hand-written model; aimed at AWS-LC cryptographic routines. | Stage 0 · Research | 2/5 | Interactive | Go (Dafny compiler (Go backend), trusted) → AArch64 (gc (the Go compiler), trusted) |
Feature coverage
Which language features each toolchain handles. Hover or focus a mark for the note and source. Toolchains on compiled code are shown for common features only.
| Feature | Dafny | Gobra via Go | KeY via Java | s2n-bignum via x86-64 | Islaris via AArch64 | LNSym via AArch64 |
|---|---|---|---|---|---|---|
| Common features | ||||||
| Machine integersFixed-width integer arithmetic, overflow and bit operations. | Dafny, 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 | Gobra, Machine integers: Partial.Without --overflow (the default) Gobra treats bounded integers as mathematical integers, so it neither checks overflow nor models wrap-around. The tutorial also says support for some integer types such as rune is very limited. Source | KeY, Machine integers: Partial.Three settings exist. The default treats Java integers as unbounded mathematical integers, which KeY marks as unsound. "Java semantics" models overflow exactly, and "checking overflow" proves that no overflow happens. Source | s2n-bignum, Machine integers: Unknown. | Islaris, Machine integers: Unknown. | LNSym, Machine integers: Unknown. |
| Floating pointIEEE 754 floating-point arithmetic, including rounding and NaNs. | Dafny, 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 | Gobra, Floating point: Partial.Basic float32/float64 arithmetic appears in the regression tests; how closely IEEE 754 is modeled is not documented. Source | KeY, Floating point: Supported.Supported; needs an installed SMT solver with floating-point support. Source | s2n-bignum, Floating point: Unknown. | Islaris, Floating point: Unknown. | LNSym, Floating point: Unknown. |
| Heap and pointersDynamically allocated memory, pointers or references, and aliasing. | Dafny, Heap and pointers: Supported.Classes, references and dynamic allocation, with reads and modifies frames. Source | Gobra, Heap and pointers: Supported.Pointers and heap access use permissions (acc predicates), including fractional and quantified permissions. Source | KeY, Heap and pointers: Supported.Objects and references with an explicit heap model. Source | s2n-bignum, Heap and pointers: Unknown. | Islaris, Heap and pointers: Unknown. | LNSym, Heap and pointers: Unknown. |
| Arrays and buffersIndexed memory such as arrays, slices, vectors and byte buffers. | Dafny, Arrays and buffers: Supported.One- and multi-dimensional arrays and sequences. Source | Gobra, Arrays and buffers: Supported.Arrays and slices are supported. Source | KeY, Arrays and buffers: Supported.Including multi-dimensional arrays, ArrayStoreException and out-of-bounds behavior. Source | s2n-bignum, Arrays and buffers: Unknown. | Islaris, Arrays and buffers: Unknown. | LNSym, Arrays and buffers: Unknown. |
| LoopsUnbounded loops, which need invariants or bounds to verify. | Dafny, Loops: Supported.Loop invariants and decreases clauses. Source | Gobra, Loops: Supported.Loop invariants; decreases clauses for termination. Source | KeY, Loops: Supported.Loop invariants; for-each loops are rewritten to indexed or iterator loops. Source | s2n-bignum, Loops: Unknown. | Islaris, Loops: Unknown. | LNSym, Loops: Unknown. |
| RecursionFunctions that call themselves, directly or through others. | Dafny, Recursion: Supported. Source | Gobra, Recursion: Supported. Source | KeY, Recursion: Supported.Recursive methods with measured_by clauses for termination. Source | s2n-bignum, Recursion: Unknown. | Islaris, Recursion: Unknown. | LNSym, Recursion: Unknown. |
| Higher-order codeFunction pointers, closures and callbacks. | Dafny, Higher-order code: Supported.Function values (arrow types) with requires and reads clauses. Source | Gobra, Higher-order code: Supported.Closures are specified with specification types and proved to satisfy them. Source | KeY, Higher-order code: Partial.Lambdas and method references are partly supported (turned into classes); lambdas in field initializers and anonymous classes are not. Source | s2n-bignum, Higher-order code: Unknown. | Islaris, Higher-order code: Unknown. | LNSym, Higher-order code: Unknown. |
| Threads and shared memoryConcurrent threads with locks, atomics or message passing. | Dafny, Threads and shared memory: Not supported.Dafny is a sequential language. Source | Gobra, Threads and shared memory: Supported.Goroutines, channels and sync.Mutex, with permissions passed between goroutines. Source | KeY, Threads and shared memory: Not supported.Multithreading is not supported. Source | s2n-bignum, Threads and shared memory: Unknown. | Islaris, Threads and shared memory: Unknown. | LNSym, Threads and shared memory: Unknown. |
| I/O and system callsFiles, network, system calls and foreign-function calls. | Dafny, 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 | Gobra, I/O and system calls: Partial.Some packages (for example net, fmt, time) have trusted specification stubs; other I/O needs hand-written specifications. Source | KeY, I/O and system calls: Not supported.KeY has no model of the JVM runtime or I/O; library methods, including I/O, need stub classes with hand-written contracts. Source | s2n-bignum, I/O and system calls: Unknown. | Islaris, I/O and system calls: Unknown. | LNSym, I/O and system calls: Unknown. |
| Standard librarySpecifications or models for the language's standard library. | Dafny, Standard library: Partial.Dafny ships standard libraries (enabled with --standard-libraries), and the language has built-in sets, sequences, multisets and maps. Source | Gobra, Standard library: Partial.Specification stubs exist for a few packages (bytes, encoding/binary, errors, fmt, net, strconv, strings, sync, time); they are assumed, not verified. Source | KeY, Standard library: Partial.Library classes must be on KeY's classpath, usually as stubs with contracts; KeY reports an error otherwise. Source | s2n-bignum, Standard library: Unknown. | Islaris, Standard library: Unknown. | LNSym, Standard library: Unknown. |
Supported Partial Not supported Unknown
Formal semantics of Dafny
Models that proofs about Dafny can be stated against. See formal semanticsFormal semantics. A precise, mathematical definition of what programs in a language do..
None in the index yet.
Compilers from Dafny
What each compilation step preserves, and whether it is proved.
| To | Via | Assurance | What does not carry over |
|---|---|---|---|
| Go | Dafny compiler (Go backend) | trusted | Specifications and proofs are erased. |
| Java | Dafny compiler (Java backend) | trusted | Specifications and proofs are erased. |