Dafny is a verification-aware programming language that has native support for recording specifications and is equipped with a static program verifier. By blending sophisticated automated reasoning with familiar programming idioms and tools, Dafny empowers developers to write provably correct code (w.r.t. specifications). It also compiles Dafny code to familiar development environments such as C#, Java, JavaScript, Go and Python (with more to come) so Dafny can integrate with your existing workflow. Dafny makes rigorous verification an integral part of development, thus reducing costly late-stage bugs that may be missed by testing.
In addition to a verification engine to check implementation against specifications, the Dafny ecosystem includes several compilers, plugins for common software development IDEs, a LSP-based Language Server, a code formatter, a reference manual, tutorials, power user tips, books, the experiences of professors teaching Dafny, and the accumulating expertise of industrial projects using Dafny.
Dafny has support for common programming concepts such as
- mathematical and bounded integers and reals, bit-vectors, classes, iterators, arrays, tuples, generic types, refinement and inheritance,
- inductive datatypes that can have methods and are suitable for pattern matching,
- lazily unbounded datatypes,
- subset types, such as for bounded integers,
- lambda expressions and functional programming idioms,
- and immutable and mutable data structures.
Dafny also offers an extensive toolbox for mathematical proofs about software, including
- bounded and unbounded quantifiers,
- calculational proofs and the ability to use and prove lemmas,
- pre- and post-conditions, termination conditions, loop invariants, and read/write specifications.