dafny(1)
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/logPrefixoptions. ๐งต@TIME@โ Expands to the current time. โฐ
๐ General options ๐
/env:nโ Control printing of command-line arguments. Accepted values fornare: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 tofile. ๐
๐ Dafny options ๐
Multiple .dfy files supplied on the command line are concatenated into one Dafny program. ๐งฉ
/allowGlobalsโ Allow the implicit class_defaultto 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 version1.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 specifiedfile. ๐จ๏ธ/compile:nโ Enable or disable compilation. Accepted values fornare:0โ Do not compile. ๐ซ1โ (default) Compile Dafny to CLI assembly. The output file name shares the base name of the last.dfyfile on the command line. If the program has aMainmethod, 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 fornare:0โ Stop after typechecking. ๐1โ Typecheck, verify, and compile. โ
/dprelude:fileโ Choose Dafny prelude file. ๐/dprint:fileโ Print Dafny program to the specifiedfileafter parsing. Specify/dprint:-to print to standard output. ๐จ๏ธ/induction:nโ Control when Dafny performs induction. Accepted values fornare: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:0is the least discriminating (that is, it leans toward applying induction most often); increasingnup to6, 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 fornare: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 formodeare: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โ LikeNoIncludes, but also disable printing of functions ghost methods, and proof statements in implementation methods. ๐ป
/rprint:fileโ Print Dafny program to the specifiedfileafter resolving it. Specify/rprint:-to print to standard output. ๐จ๏ธ/spillTargetCode:nโ Control whether or not dafny emits intermediate C# code. Accepted values fornare:0โ (default) Don't save intermediate C# code. ๐ซ1โ Save intermediate C# code as a.csfile. ๐พ
๐ฆ 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 fornare:0โ (default) Do not print enhanced error messages. ๐ซ1โ Print Z3 error model enhanced error messages. ๐
/loopUnroll:nโ Unroll loops, following up tonback edges (and then some). ๐/mv:fileโ Save the model in BVD format to the specifiedfile. ๐พ/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 fornare: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 specifiedfileafter parsing it. Specify/print:-to print to standard output. ๐จ๏ธ/printCFG:prefixโ Print the control flow graph of each implementation indot(1)format to files namedprefix.procedurename.dot. ๐/printDesugaredโ With/print, desugar calls. ๐ฌ/printModel:nโ Control printing of Z3's error model. Accepted values fornare: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.domainsmay 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 forflagare: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/inferflags. ๐ซ/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'sA ==> Binto prover'sA ==> A && B. ๐/coalesceBlocks:nโ Control when to coalesce blocks. Accepted values fornare: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 byprefix) 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:inlineattribute. Accepted strategies arenone,assume(the default),assert, andspec. ๐ฅ/lazyInline:1โ Use the lazy inlining algorithm. ๐ฆฅ/liveVariableAnalysis:nโ Control when and how to perform live variable analysis. Accepted values fornare: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:inlineattribute./recursionBound:nโ Set the recursion bound for stratified inlining to n. By default, n is500./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 stickassert 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 is10./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โ argumentsmโ monomorphicnโ none (unsound) ๐ yeah, unsound, do notpโ (default) predicates
/vc:varietyโ Specify the verification condition variety. Accepted varieties are:bโ flat blockdโ (default) DAGdoomedโ doomed ๐ซlโ localmโ nested block reachnโ nested blockrโ flat block reachsโ 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 (namedfilename.v0.bpltofilename.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 to1./vcsDumpSplitsโ For the *n*th split, dumpsplit.n.dotandsplit.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 is30./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 is1./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 than1. ๐งฎ/vcsMaxCost:fโ Verification conditions will not be split unless the cost of a verification condition exceeds f. f defaults to2000.0. This does not apply in the keep-going mode after the first round of splitting./vcsMaxKeepGoingSplits:nโ If n is set to more than1, 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 is1(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 is1./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 is0.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 is0.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 is5, but some provers may only support1./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 bev11,v2, orcli1, 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:ContractInferenceSimplifyโ This implies/vc:nand/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 to100./proverShutdownLimitnโ Set the time, in seconds, between closing the stream to the prover and killing the prover process. n defaults to0. (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 ๐
๐ COPYRIGHT ๐
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
- debian bookworm: dafny 2.3.0+dfsg-0.1 ยท MIT
- ubuntu jammy: dafny 2.3.0+dfsg-0.1 ยท MIT
- ubuntu noble: dafny 2.3.0+dfsg-0.1 ยท MIT
- ยฉ 2013, 2015 Benjamin Barenblat
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms