dafny(1)

๐Ÿ“ฆ version 2.3.0, in debian bookworm, ubuntu jammy, ubuntu noble

okay so bestie, this is the dafny(1) manual page โ€” the Dafny compiler, and we're about to go through every single option together. No cap. ๐Ÿ’–

โœจ NAME โœจ

dafny โ€” compiler for the Dafny programming language. ๐Ÿ’…


โœจ SYNOPSIS โœจ

dafny [options] file.dfy ...

โœจ DESCRIPTION โœจ

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


โœจ OPTIONS โœจ

dafny accepts a number of different types of options. Let's get into it, fr fr. ๐Ÿ‘‘

๐ŸŒธ File macros ๐ŸŒธ

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

  • @FILE@ โ€” Expands to the last filename specified on the command line. ๐Ÿ“
  • @PREFIX@ โ€” Expands to the concatenation of strings given by /logPrefix options. ๐Ÿงต
  • @TIME@ โ€” Expands to the current time. โฐ

๐ŸŒˆ General options ๐ŸŒˆ

  • /env:n โ€” Control printing of command-line arguments. Accepted values for n are:
    • 0 โ€” Suppress printing of command-line arguments. ๐Ÿคซ
    • 1 โ€” (default) Print command-line arguments during BPL print and prover log. ๐Ÿ“
    • 2 โ€” Print command-line arguments during BPL print and prover log, and also to standard output. ๐Ÿ“ข
  • /noLogo โ€” Suppress printing of the version number and copyright message. ๐Ÿšซ
  • /wait โ€” Wait for a carriage return from the keyboard before exiting. โŒจ๏ธ
  • /xml:file โ€” Also produce output in XML format to file. ๐Ÿ“„

๐Ÿ’œ Dafny options ๐Ÿ’œ

Multiple .dfy files supplied on the command line are concatenated into one Dafny program. ๐Ÿงฉ

  • /allowGlobals โ€” 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 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. ๐Ÿ‘‘
  • /autoReqPrint:file โ€” Print requirements automatically generated by autoReq to the specified file. ๐Ÿ–จ๏ธ
  • /compile:n โ€” Enable or disable compilation. Accepted values for n are:
    • 0 โ€” Do not compile. ๐Ÿšซ
    • 1 โ€” (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. ๐Ÿ—๏ธ
  • /dafnycc โ€” Disable features not supported by DafnyCC. ๐Ÿšซ
  • /dafnyVerify:n โ€” Control how far compilation proceeds. Accepted values for n are:
    • 0 โ€” Stop after typechecking. ๐Ÿ›‘
    • 1 โ€” Typecheck, verify, and compile. โœ…
  • /dprelude:file โ€” Choose Dafny prelude file. ๐Ÿ“œ
  • /dprint:file โ€” Print Dafny program to the specified file after parsing. Specify /dprint:- to print to standard output. ๐Ÿ–จ๏ธ
  • /induction:n โ€” Control when Dafny performs induction. Accepted values for n are:
    • 0 โ€” Never do induction, not even when attributes request it. ๐Ÿ™…โ€โ™€๏ธ
    • 1 โ€” Apply induction only when attributes request it. ๐Ÿ™‹โ€โ™€๏ธ
    • 2 โ€” Apply induction as requested by attributes and also for heuristically chosen quantifiers. ๐Ÿค–
    • 3 โ€” (default) Apply induction as requested by attributes, for heuristically chosen quantifiers, and for ghost methods. ๐Ÿ‘ป
  • /inductionHeuristic:n โ€” 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. ๐Ÿง 
  • /noAutoReq โ€” Ignore autoReq attributes. ๐Ÿšซ
  • /noCheating:n โ€” Control how strict dafny is about unproven constructs. Accepted values for n are:
    • 0 โ€” (default) Allow assume statements and free invariants. ๐Ÿ˜‡
    • 1 โ€” Treat all assumptions as assertions, and drop free. ๐Ÿ˜ˆ
  • /noIncludes โ€” Ignore include directives. ๐Ÿšซ
  • /noNLarith โ€” Reduce Z3's knowledge of nonlinear arithmetic (multiplication and division). This results in more manual work but also tends to produce more predictable behavior. ๐Ÿงฎ
  • /printMode:mode โ€” Control printing. Accepted values for mode are:
    • Everything โ€” (default) Print everything. ๐ŸŒ
    • NoIncludes โ€” Disable printing of "{:verify false} methods incorporated via the include mechanism, as well as datatypes and fields included from other files. ๐Ÿšซ
    • NoGhost โ€” Like NoIncludes, but also disable printing of functions ghost methods, and proof statements in implementation methods. ๐Ÿ‘ป
  • /rprint:file โ€” Print Dafny program to the specified file after resolving it. Specify /rprint:- to print to standard output. ๐Ÿ–จ๏ธ
  • /spillTargetCode:n โ€” Control whether or not dafny emits intermediate C# code. Accepted values for n are:
    • 0 โ€” (default) Don't save intermediate C# code. ๐Ÿšซ
    • 1 โ€” Save intermediate C# code as a .cs file. ๐Ÿ’พ

๐Ÿฆ‹ Boogie options ๐Ÿฆ‹

Multiple .bpl files supplied on the command line are concatenated into one Boogie program. ๐Ÿงฉ

  • /enhancedErrorMessages:n โ€” Control printing of enhanced error messages. Accepted values for n are:
    • 0 โ€” (default) Do not print enhanced error messages. ๐Ÿšซ
    • 1 โ€” Print Z3 error model enhanced error messages. ๐Ÿ“
  • /loopUnroll:n โ€” Unroll loops, following up to n back edges (and then some). ๐Ÿ”„
  • /mv:file โ€” Save the model in BVD format to the specified file. ๐Ÿ’พ
  • /noResolve โ€” Parse only. ๐Ÿ“–
  • /noTypecheck โ€” Parse and resolve only. ๐Ÿ“–
  • /overlookTypeErrors โ€” Skip any implementation with resolution or type checking errors. โญ๏ธ
  • /pretty:n โ€” Control pretty-printing of Boogie code. Accepted values for n are:
    • 0 โ€” Print each Boogie statement on one line. ๐Ÿ“
    • 1 โ€” (default) Pretty-print with some line breaks. This is slower but easier to read. ๐Ÿ“–
  • /print:file โ€” Print Boogie program to the specified file after parsing it. Specify /print:- to print to standard output. ๐Ÿ–จ๏ธ
  • /printCFG:prefix โ€” Print the control flow graph of each implementation in dot(1) format to files named prefix.procedurename.dot. ๐Ÿ“Š
  • /printDesugared โ€” With /print, desugar calls. ๐Ÿฌ
  • /printModel:n โ€” Control printing of Z3's error model. Accepted values for n are:
    • 0 โ€” (default) Do not print Z3's error model. ๐Ÿšซ
    • 1 โ€” Print Z3's error model. ๐Ÿ“
    • 2 โ€” Print Z3's error model and reverse mappings. ๐Ÿ”„
    • 3 โ€” Print Z3's error model in a more human-readable way. ๐Ÿ‘€
  • /printUnstructured โ€” With /print, desugar all structured statements. ๐Ÿฌ
  • /printWithUniqueIds โ€” Print augmented information that uniquely identifies variables. ๐Ÿ†”
  • /proc:p โ€” Limit which procedures to check. ๐Ÿ”
  • /soundLoopUnrolling โ€” Enable sound loop unrolling. ๐Ÿ”Š
  • /useBaseNameForFileName โ€” When parsing, use the base name of the file for tokens instead of the path supplied on the command line. ๐Ÿ“‚

๐Ÿงš Inference options ๐Ÿงš

  • /checkInfer โ€” Instrument inferred invariants as asserts to be checked by the theorem prover. ๐Ÿงช
  • /contractInfer โ€” Perform procedure contract inference. ๐Ÿ“œ
  • /infer[:domains] โ€” Use abstract interpretation to infer invariants. domains may be any of the following:
    • c โ€” constant propagation. ๐Ÿ”ข
    • d โ€” dynamic type. ๐Ÿท๏ธ
    • i โ€” intervals. ๐Ÿ“
    • j โ€” stronger intervals (cannot be combined with other domains). ๐Ÿ’ช
    • n โ€” nullness. ๐Ÿ•ณ๏ธ
    • p โ€” polyhedra for linear inequalities. ๐Ÿ“
    • t โ€” trivial bottom/top lattice (cannot be combined with other domains). ๐Ÿ”๏ธ
    • You may also specify the following options as pseudo-domains:
      • s โ€” debug statistics. ๐Ÿ“Š
      • 0...9 โ€” number of iterations before applying a widen (default: 0). ๐Ÿ”
    • The default is /infer:i. With /infer (and no domains), all domains will be used. โœจ
  • /instrumentInfer:flag โ€” Control when inferred invariants are instrumented. Accepted values for flag are:
    • h โ€” (default) Instrument inferred invariants only at the beginning of loop headers. ๐Ÿ”
    • e โ€” Instrument inferred invariants at the beginning and end of every block. This mode is intended for use in debugging abstract domains. ๐Ÿ›
  • /noinfer โ€” Turn off the default inference, and override any previous /infer flags. ๐Ÿšซ
  • /printInstrumented โ€” Print Boogie program after it has been instrumented with invariants. ๐Ÿ–จ๏ธ

๐ŸŒŸ Debugging and tracing options ๐ŸŒŸ

  • /break โ€” Launch and break into the debugger. ๐Ÿ›
  • /log[:method] โ€” Print debug output during translation. ๐Ÿ“
  • /trace โ€” Blurt out various debug trace information. Implies /tracePOs. ๐Ÿ—ฃ๏ธ
  • /tracePOs โ€” Output information about the number of proof obligations. ๐Ÿ”ข
  • /traceTimes โ€” Output timing information at certain points in the pipeline. โฑ๏ธ

๐Ÿ”ฅ Verification condition generation options ๐Ÿ”ฅ

  • /alwaysAssumeFreeLoopInvariants โ€” 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). ๐Ÿ†“
  • /causalImplies โ€” Translate Boogie's A ==> B into prover's A ==> A && B. ๐Ÿ”„
  • /coalesceBlocks:n โ€” Control when to coalesce blocks. Accepted values for n are:
    • 0 โ€” Do not coalesce blocks. ๐Ÿšซ
    • 1 โ€” (default) Coalesce blocks. ๐Ÿงฉ
  • /fixedPointEngine:engine โ€” Use the specified fixed point engine for inference. โš™๏ธ
  • /inferLeastForUnsat:prefix โ€” 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. ๐Ÿ”
  • /inline:strategy โ€” Use the specified inlining strategy for procedures with the :inline attribute. Accepted strategies are none, assume (the default), assert, and spec. ๐Ÿ“ฅ
  • /lazyInline:1 โ€” Use the lazy inlining algorithm. ๐Ÿฆฅ
  • /liveVariableAnalysis:n โ€” Control when and how to perform live variable analysis. Accepted values for n are:
    • 0 โ€” Do not perform live variable analysis. ๐Ÿšซ
    • 1 โ€” (default) Perform live variable analysis. โœ…
  • 2 โ€” Perform interprocedural live variable analysis. ๐Ÿง โœจ
  • /monomorphize โ€” Do not abstract map types in the encoding. โš ๏ธ Heads up bestie: this is experimental, and it will not do the right thing if the program uses polymorphism. Like, it'll just be wrong.
  • /noVerify โ€” Skip verification condition generation and invocation of the theorem prover. Basically we're skipping the whole proof part, no thoughts, no theorem prover, just vibes. ๐Ÿ’…
  • /printInlined โ€” Print the implementation after inlining calls to procedures with the :inline attribute.
  • /recursionBound:n โ€” Set the recursion bound for stratified inlining to n. By default, n is 500.
  • /reflectAdd โ€” In the verification condition, generate an auxiliary symbol, elsewhere defined to be +, instead of +. Yes it really says + twice, iconic, moving on. ๐ŸŽ€
  • /removeEmptyBlocks:n โ€” Control whether to remove empty blocks during verification condition generation. Accepted values for n are:
    • 0 โ€” Do not remove empty blocks.
    • 1 โ€” (default) Remove empty blocks.
  • /smoke โ€” Run the soundness smoke test: try to stick assert false; in some places in the BPL and see if we can still prove it. Yes it's as chaotic as it sounds. ๐Ÿ”ฅ
  • /smokeTimeout:n โ€” Set the timeout, in seconds, for a single theorem prover invocation during the smoke test. By default, n is 10.
  • /stratifiedInline:1 โ€” Use the stratified inlining algorithm.
  • /subsumption:n โ€” Control when subsumption is applied to asserted conditions. Accepted values for n are:
    • 0 โ€” Never apply subsumption.
    • 1 โ€” Do not apply subsumption for quantifiers.
    • 2 โ€” (default) Always apply subsumption.
  • /traceVerify โ€” Print debug output during verification condition generation.
  • /typeEncoding:method โ€” Control how to encode types when sending the verification condition to the theorem prover. Allowed methods are:
    • a โ€” arguments
    • m โ€” monomorphic
    • n โ€” none (unsound) ๐Ÿ’€ yeah, unsound, do not
    • p โ€” (default) predicates
  • /vc:variety โ€” Specify the verification condition variety. Accepted varieties are:
    • b โ€” flat block
    • d โ€” (default) DAG
    • doomed โ€” doomed ๐Ÿซ 
    • l โ€” local
    • m โ€” nested block reach
    • n โ€” nested block
    • r โ€” flat block reach
    • s โ€” structured
  • /verifySeparately โ€” Verify each input program separately.
  • /verifySnapshots:n โ€” Control verification result caching. Accepted values for n are:
    • 0 โ€” (default) Do not use any verification result caching.
    • 1 โ€” Verify several program snapshots (named filename.v0.bpl to filename.vN.bpl) using basic verification result caching.
    • 2 โ€” Use more advanced verification result caching.

โœจ Verification condition splitting โœจ

  • /vcsCores:n โ€” Try to verify n verification conditions at once. Defaults to 1.
  • /vcsDumpSplits โ€” For the *n*th split, dump split.n.dot and split.n.bpl. Note that this affects error reporting.
  • /vcsFinalAssertTimeout:n โ€” Set the timeout, in seconds, for the single last assertion in keep-going mode. By default, n is 30.
  • /vcsKeepGoingTimeout:n โ€” 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.
  • /vcsLoad:f โ€” 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. ๐Ÿงฎ
  • /vcsMaxCost:f โ€” 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.
  • /vcsMaxKeepGoingSplits:n โ€” 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).
  • /vcsMaxSplits:n โ€” 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.

  • /vcsPathJoinMult:f โ€” 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.
  • /vcsPathSplitMult:f โ€” 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 A โ‰ฅ f ร— (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 ๐Ÿ’œ

  • /errorLimit:n โ€” Limit the number of errors produced for each procedure. By default, n is 5, but some provers may only support 1.
  • /errorTrace:n โ€” Control whether or not trace labels appear in the error output. Accepted values for n are:
    • 0 โ€” Print no trace labels in the error output.
    • 1 โ€” (default) Print useful trace labels in error output.
    • 2 โ€” Print all trace labels in error output.
  • /logPrefix:prefix โ€” Define the expansion of the macro @PREFIX@.
  • /p:key[:value], /proverOpt:key[:value] โ€” Provide a prover-specific option.
  • /platform:ptype,location โ€” Set the platform type and location. ptype may be v11, v2, or cli1, and location should be the platform libraries directory.
  • /prover:p โ€” Use theorem prover p. p may be a full path to a prover DLL, or it may be one of the following standard provers:
    • ContractInference
    • Simplify โ€” This implies /vc:n and /vcBrackets:1.
    • SMTLib (default) โ€” Use the SMTLib2 format, and call Z3.
    • Z3 โ€” Z3 with the Simplify format.
    • Z3api โ€” Z3 with the managed (CLI) API.
  • /proverLog:file โ€” 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.

  • /proverLogAppend โ€” Append (do not overwrite) the specified prover log file.
  • /proverMemorylimit:n โ€” Limit the prover to n megabytes of virtual memory before forcing it to restart. n defaults to 100.
  • /proverShutdownLimitn โ€” Set the time, in seconds, between closing the stream to the prover and killing the prover process. n defaults to 0. (Yep, that flag name is exactly as written, no typo from me, we keep it real. ๐Ÿ™ˆ)
  • /proverWarnings:n โ€” Control warning output from the prover. Accepted values for n are:
    • 0 โ€” (default) Don't print warning output from the prover.
    • 1 โ€” Print warnings to standard output.
    • 2 โ€” Print warnings to standard error.
  • /restartProver โ€” Restart the prover after each query.
  • /timeLimit:n โ€” Limit the number of seconds spent trying to verify each procedure.
  • /vcBrackets:n โ€” Control whether or not odd-charactered identifier names will be bracketed with pipe characters ('|'). Accepted values for n are:
    • 0 โ€” (default) Do not bracket odd-charactered identifier names.
    • 1 โ€” Bracket odd-charactered identifier names.

๐Ÿฆ‹ Prover options (CVC4) ๐Ÿฆ‹

  • /cvc4exe:path โ€” Set the path to the CVC4 executable.

๐ŸŒธ Prover options (Simplify) ๐ŸŒธ

  • /simplifyMatchDepth:n โ€” Set Simplify's matching depth limit.

โญ Prover options (Z3) โญ

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

๐ŸŒˆ SEE ALSO ๐ŸŒˆ


Dafny is copyright ยฉ 2003-2015 Microsoft Corporation and licensed under the Microsoft Public License https://msdn.microsoft.com/en-us/library/ff647676.aspx.

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


And that's a wrap, bestie ๐Ÿซถ this whole page is dafny(1), version 1.9.5, dated 2015-05-11. Go forth and verify, you absolute main character. ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from