Scroll to navigation

dafny(1) Dafny dafny(1)


dafny - compiler for the Dafny programming language


dafny [options] file.dfy ...


dafny is a compiler for Microsoft Research's Dafny programming language, an imperative language with built-in specification constructs. The integrated static analyzer can verify functional correctness as part of the compilation process.


dafny accepts a number of different types of options.

File macros

A number of dafny options accept a file argument, which may contain the following macros:

Expands to the last filename specified on the command line.
Expands to the concatenation of strings given by /logPrefix options.
Expands to the current time.

General options

Control printing of command-line arguments. Accepted values for n are:
Suppress printing of command-line arguments.
(default) Print command-line arguments during BPL print and prover log.
Print command-line arguments during BPL print and prover log, and also to standard output.
Suppress printing of the version number and copyright message.
Wait for a carriage return from the keyboard before exiting.
Also produce output in XML format to file.

Dafny options

Multiple .dfy files supplied on the command line are concatenated into one Dafny program.

Allow the implicit class _default to contain fields, instance functions, and instance methods. These class members are declared at module scope, outside of explicit classes. This command-line option is provided to simplify a a transition from the behavior in the language prior to version 1.9.3, from which point onward all functions and methods declared at the module scope are implicitly static and field declarations are not allowed at the module scope.
Print requirements automatically generated by autoReq to the specified file.
Enable or disable compilation. Accepted values for n are:
Do not compile.
(default) Compile Dafny to CLI assembly. The output file name shares the base name of the last .dfy file on the command line. If the program has a Main method, the output will have the extension .exe; otherwise, it will be a .dll.
Disable features not supported by DafnyCC.
Control how far compilation proceeds. Accepted values for n are:
Stop after typechecking.
Typecheck, verify, and compile.
Choose Dafny prelude file.
Print Dafny program to the specified file after parsing. Specify /dprint:- to print to standard output.
Control when Dafny performs induction. Accepted values for n are:
Never do induction, not even when attributes request it.
Apply induction only when attributes request it.
Apply induction as requested by attributes and also for heuristically chosen quantifiers.
(default) Apply induction as requested by attributes, for heuristically chosen quantifiers, and for ghost methods.
Control how discriminating the induction heuristic is. /inductionHeuristic:0 is the least discriminating (that is, it leans toward applying induction most often); increasing n up to 6, the default, increases dafny's reluctance to apply induction.
Ignore autoReq attributes.
Control how strict dafny is about unproven constructs. Accepted values for n are:
(default) Allow assume statements and free invariants.
Treat all assumptions as assertions, and drop free.
Ignore include directives.
Reduce Z3's knowledge of nonlinear arithmetic (multiplication and division). This results in more manual work but also tends to produce more predictable behavior.
Control printing. Accepted values for mode are:
(default) Print everything.
Disable printing of "{:verify false} methods incorporated via the include mechanism, as well as datatypes and fields included from other files.
Like NoIncludes, but also disable printing of functions ghost methods, and proof statements in implementation methods.
Print Dafny program to the specified file after resolving it. Specify /rprint:- to print to standard output.
Control whether or not dafny emits intermediate C# code. Accepted values for n are:
(default) Don't save intermediate C# code.
Save intermediate C# code as a .cs file.

Boogie options

Multiple .bpl files supplied on the command line are concatenated into one Boogie program.

Control printing of enhanced error messages. Accepted values for n are:
(default) Do not print enhanced error messages.
Print Z3 error model enhanced error messages.
Unroll loops, following up to n back edges (and then some).
Save the model in BVD format to the specified file.
Parse only.
Parse and resolve only.
Skip any implementation with resolution or type checking errors.
Control pretty-printing of Boogie code. Accepted values for n are:
Print each Boogie statement on one line.
(default) Pretty-print with some line breaks. This is slower but easier to read.
Print Boogie program to the specified file after parsing it. Specify /print:- to print to standard output.
Print the control flow graph of each implementation in dot(1) format to files named
With /print, desugar calls.
Control printing of Z3's error model. Accepted values for n are:
(default) Do not print Z3's error model.
Print Z3's error model.
Print Z3's error model and reverse mappings.
Print Z3's error model in a more human-readable way.
With /print, desugar all structured statements.
Print augmented information that uniquely identifies variables.
Limit which procedures to check.
Enable sound loop unrolling.
When parsing, use the base name of the file for tokens instead of the path supplied on the command line.

Inference options

Instrument inferred invariants as asserts to be checked by the theorem prover.
Perform procedure contract inference.
Use abstract interpretation to infer invariants. domains may be any of the following:
constant propagation
dynamic type
stronger intervals (cannot be combined with other domains)
polyhedra for linear inequalities
trivial bottom/top lattice (cannot be combined with other domains)
You may also specify the following options as pseudo-domains:
debug statistics
number of iterations before applying a widen (default: 0)
The default is /infer:i. With /infer (and no domains), all domains will be used.
Control when inferred invariants are instrumented. Accepted values for flag are:
(default) Instrument inferred invariants only at the beginning of loop headers.
Instrument inferred invariants at the beginning and end of every block. This mode is intended for use in debugging abstract domains.
Turn off the default inference, and override any previous /infer flags.
Print Boogie program after it has been instrumented with invariants.

Debugging and tracing options

Launch and break into the debugger.
Print debug output during translation.
Blurt out various debug trace information. Implies /tracePOs.
Output information about the number of proof obligations.
Output timing information at certain points in the pipeline.

Verification condition generation options

Include free loop invariants as assumptions in checking contexts. Usually, a free loop invariant (or assume statement in that position) is ignored in checking contexts (like other free things).
Translate Boogie's A ==> B into prover's A ==> A && B.
Control when to coalesce blocks. Accepted values for n are:
Do not coalesce blocks.
(default) Coalesce blocks.
Use the specified fixed point engine for inference.
Infer the least number of constants (whose names are prefixed by prefix) that need to be set to true for the program to be correct. Implies /stratifiedInline:1.
Use the specified inlining strategy for procedures with the :inline attribute. Accepted strategies are none, assume (the default), assert, and spec.
Use the lazy inlining algorithm.
Control when and how to perform live variable analysis. Accepted values for n are:
Do not perform live variable analysis.
(default) Perform live variable analysis.
Perform interprocedural live variable analysis.
Do not abstract map types in the encoding. This is an experimental feature which will not do the right thing if the program uses polymorphism.
Skip verification condition generation and invocation of the theorem prover.
Print the implementation after inlining calls to procedures with the :inline attribute.
Set the recursion bound for stratified inlining to n. By default, n is 500.
In the verification condition, generate an auxiliary symbol, elsewhere defined to be +, instead of +.
Control whether to remove empty blocks during verification condition generation. Accepted values for n are:
Do not remove empty blocks.
(default) Remove empty blocks.
Run the soundness smoke test: try to stick assert false; in some places in the BPL and see if we can still prove it.
Set the timeout, in seconds, for a single theorem prover invocation during the smoke test. By default, n is 10.
Use the stratified inlining algorithm.
Control when subsumption is applied to asserted conditions. Accepted values for n are:
Never apply subsumption.
Do not apply subsumption for quantifiers.
(default) Always apply subsumption.
Print debug output during verification condition generation.
Control how to encode types when sending the verification condition to the the theorem prover. Allowed methods are:
none (unsound)
(default) predicates
Specify the verification condition variety. Accepted varieties are:
flat block
(default) DAG
nested block reach
nested block
flat block reach
Verify each input program separately.
Control verification result caching. Accepted values for n are:
(default) Do not use any verification result caching.
Verify several program snapshots (named filename.v0.bpl to filename.vN.bpl) using basic verification result caching.
Use more advanced verification result caching.

Verification condition splitting

Try to verify n verification conditions at once. Defaults to 1.
For the nth split, dump and split.n.bpl. Note that this affects error reporting.
Set the timeout, in seconds, for the single last assertion in keep-going mode. By default, n is 30.
Set the timeout, in seconds, for a single theorem prover invocation in keep-going mode, except for the final single-assertion case. By default, n is 1.
Like /vcsCores:n, where n is the machine's processor count multiplied by f and rounded to the nearest integer. f must be in the range [0.0, 3.0]. This will never set n less than 1.
Verification conditions will not be split unless the cost of a verification condition exceeds f. f defaults to 2000.0. This does not apply in the keep-going mode after the first round of splitting.
If n is set to more than 1, this activates keep-going mode, where after the first round of splitting, verification conditions that time out are split into n pieces and retried until either proving them is successful or there is only one assertion on a single path and it times out. (In such a case, dafny reports an error for that assertion). By default, n is 1 (that is, keep-going mode is disabled).
Set the maximal number of verification conditions generated per method. In keep-going mode, this only applies to the first round. By default, n is 1.
/vcsPathCostMult:f1, /vcsAssumeMult:f2
Controls the cost of a block. Block cost is computed according to the formula

(assert-cost + f2 × assume-cost) × (1 + f1 × entering-paths)
where f1 defaults to 1.0 and f2 defaults to 0.01. The cost of a single assertion or assumption is always 1.0.
Sets a scale factor which dafny will multiply by the number of paths in a block if more than one path join at a block. This is intended to reflect the fact that the prover will learn something on one path before proceeding to the next. By default, f is 0.8.
If the best path split of a verification condition of cost A is into verification conditions of cost B and C, then the split is applied if Af × (B + C). Otherwise, assertion splitting will be applied. By default, f is 0.5 (that is, always do path splitting if possible). Increase f to do less path splitting and more assertion splitting.

Prover options

Limit the number of errors produced for each procedure. By default, n is 5, but some provers may only support 1.
Control whether or not trace labels appear in the error output. Accepted values for n are:
Print no trace labels in the error output.
(default) Print useful trace labels in error output.
Print all trace labels in error output.
Define the expansion of the macro @PREFIX@.
/p:key[:value], /proverOpt:key[:value]
Provide a prover-specific option.
Set the platform type and location. ptype may be v11, v2, or cli1, and location should be the platform libraries directory.
Use theorem prover p. p may be a full path to a prover DLL, or it may be one of the following standard provers:
This implies /vc:n and /vcBrackets:1.
(default) Use the SMTLib2 format, and call Z3.
Z3 with the Simplify format.
Z3 with the managed (CLI) API.
Log input for the theorem prover.
In addition to the standard file name macros, file can use the @PROC@ macro, which causes dafny to generate one prover log file per verification condition, expanding @PROC@ to the name of the procedure that the verification condition is for.
Append (do not overwrite) the specified prover log file.
Limit the prover to n megabytes of virtual memory before forcing it to restart. n defaults to 100.
Set the time, in seconds, between closing the stream to the prover and killing the prover process. n defaults to 0.
Control warning output from the prover. Accepted values for n are:
(default) Don't print warning output from the prover.
Print warnings to standard output.
Print warnings to standard error.
Restart the prover after each query.
Limit the number of seconds spent trying to verify each procedure.
Control whether or not odd-charactered identifier names will be bracketed with pipe characters ('|'). Accepted values for n are:
(default) Do not bracket odd-charactered identifier names.
Bracket odd-charactered identifier names.

Prover options (CVC4)

Set the path to the CVC4 executable.

Prover options (Simplify)

Set Simplify's matching depth limit.

Prover options (Z3)

Use Z3's native array theory, as opposed to axioms. Implies /monomorphize.
Output a model in SMTLib2 format.
Set the path to the Z3 executable. On Debian systems, this defaults to /usr/bin/z3.
Configure use of LETs in Z3. Accepted values for n are:
Do not use LETs.
Use only LET TERM.
(default) Use any LET.
Report multiple counterexamples for each error.
Set an additional Z3 option.
Generate a multi-sorted verification condition that makes use of Z3 types.




Dafny is copyright © 2003-2015 Microsoft Corporation and licensed under the Microsoft Public License <>.

This manual page is copyright © 2013, 2015 Benjamin Barenblat and licensed under the Apache License, Version 2.0.

2015-05-11 1.9.5