From d8e97ee67e5737d47752e3e3c4529e25f3597f67 Mon Sep 17 00:00:00 2001 From: Aaron Tomb Date: Fri, 17 Feb 2023 12:04:07 -0800 Subject: [PATCH 1/4] Add several new-style command-line options * `--error-limit` is available everywhere * `--solver-log` is available for `verify` and `measure-complexity` * `--solver-plugin` is available for `verify` and `measure-complexity` * `--resource-limit` is available for `verify` and `measure-complexity` * `--isolate-assertions` and `--format` are also available for `verify` with `--format` renamed `--log-format` --- Source/DafnyCore/Options/CommonOptionBag.cs | 32 +++++++++++++++++++ Source/DafnyCore/Options/ICommandSpec.cs | 6 ++++ .../Commands/MeasureComplexityCommand.cs | 14 -------- Test/cli/errorLimit.dfy | 11 +++++++ Test/cli/errorLimit.dfy.expect | 4 +++ Test/cli/solverLog.dfy | 7 ++++ Test/cli/solverLog.dfy.expect | 2 ++ Test/logger/CSVLogger.dfy | 2 +- Test/logger/TextLogger.dfy | 2 +- Test/logger/TextLoggerBatch.dfy | 2 +- Test/logger/VerificationLogger.dfy | 2 +- 11 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 Test/cli/errorLimit.dfy create mode 100644 Test/cli/errorLimit.dfy.expect create mode 100644 Test/cli/solverLog.dfy create mode 100644 Test/cli/solverLog.dfy.expect diff --git a/Source/DafnyCore/Options/CommonOptionBag.cs b/Source/DafnyCore/Options/CommonOptionBag.cs index c388afcaacc..c2a973e10a6 100644 --- a/Source/DafnyCore/Options/CommonOptionBag.cs +++ b/Source/DafnyCore/Options/CommonOptionBag.cs @@ -2,11 +2,15 @@ using System.CommandLine; using System.IO; using System.Linq; +using Microsoft.Boogie; namespace Microsoft.Dafny; public class CommonOptionBag { + public static readonly Option ErrorLimit = + new("--error-limit", "Set the maximum number of errors to report (0 for unlimited)."); + public static readonly Option ManualLemmaInduction = new("--manual-lemma-induction", "Turn off automatic induction for lemmas."); @@ -45,6 +49,21 @@ datatype with a single non-ghost constructor that has a single "Allow variables to be read before they are assigned, but only if they have an auto-initializable type or if they are ghost and have a nonempty type.") { }; + public static readonly Option IsolateAssertions = new("--isolate-assertions", @"Verify each assertion in isolation."); + + public static readonly Option> VerificationLogFormat = new("--log-format", $@" +Logs verification results using the given test result format. The currently supported formats are `trx`, `csv`, and `text`. These are: the XML-based format commonly used for test results for .NET languages, a custom CSV schema, and a textual format meant for human consumption. You can provide configuration using the same string format as when using the --logger option for dotnet test, such as: --format ""trx;LogFileName=<...>""); + +The `trx` and `csv` formats automatically choose an output file name by default, and print the name of this file to the console. The `text` format prints its output to the console by default, but can send output to a file given the `LogFileName` option. + +The `text` format also includes a more detailed breakdown of what assertions appear in each assertion batch. When combined with the {CommonOptionBag.IsolateAssertions.Name} option, it will provide approximate time and resource use costs for each assertion, allowing identification of especially expensive assertions.".TrimStart()) { + ArgumentHelpName = "configuration" + }; + + public static readonly Option SolverResourceLimit = new("--resource-limit", @"Specify the maximum resource limit (rlimit) value to pass to Z3. Multiplied by 1000 before sending to Z3."); + public static readonly Option SolverPlugin = new("--solver-plugin", @"Specify a plugin to use to solve verification conditions (instead of an external Z3 process)."); + public static readonly Option SolverLog = new("--solver-log", @"Specify a file to use to log the SMT-Lib text sent to the solver."); + public static readonly Option> Libraries = new("--library", @" The contents of this file and any files it includes can be referenced from other files as if they were included. @@ -163,6 +182,7 @@ static CommonOptionBag() { DafnyOptions.RegisterLegacyBinding(WarnMissingConstructorParenthesis, (options, value) => { options.DisallowConstructorCaseWithoutParentheses = value; }); DafnyOptions.RegisterLegacyBinding(WarningAsErrors, (options, value) => { options.WarningsAsErrors = value; }); + DafnyOptions.RegisterLegacyBinding(ErrorLimit, (options, value) => { options.ErrorLimit = value; }); DafnyOptions.RegisterLegacyBinding(VerifyIncludedFiles, (options, value) => { options.VerifyAllModules = value; }); @@ -196,6 +216,18 @@ static CommonOptionBag() { DafnyOptions.RegisterLegacyBinding(Verbose, (o, v) => o.CompileVerbose = v); DafnyOptions.RegisterLegacyBinding(DisableNonLinearArithmetic, (o, v) => o.DisableNLarith = v); + + DafnyOptions.RegisterLegacyBinding(VerificationLogFormat, (o, v) => o.VerificationLoggerConfigs = v); + DafnyOptions.RegisterLegacyBinding(IsolateAssertions, (o, v) => o.VcsSplitOnEveryAssert = v); + DafnyOptions.RegisterLegacyBinding(SolverResourceLimit, (o, v) => o.ResourceLimit = v); + DafnyOptions.RegisterLegacyBinding(SolverPlugin, (o, v) => { + if (v is not null) { + o.ProverDllName = v; + o.TheProverFactory = ProverFactory.Load(o.ProverDllName); + } + }); + DafnyOptions.RegisterLegacyBinding(SolverLog, (o, v) => o.ProverLogFilePath = v); + DafnyOptions.RegisterLegacyBinding(EnforceDeterminism, (options, value) => { options.ForbidNondeterminism = value; options.DefiniteAssignmentLevel = 4; diff --git a/Source/DafnyCore/Options/ICommandSpec.cs b/Source/DafnyCore/Options/ICommandSpec.cs index 9fa9a0c2ca4..cd850a6c50e 100644 --- a/Source/DafnyCore/Options/ICommandSpec.cs +++ b/Source/DafnyCore/Options/ICommandSpec.cs @@ -32,7 +32,12 @@ static ICommandSpec() { CommonOptionBag.ManualLemmaInduction, CommonOptionBag.SolverPath, CommonOptionBag.DisableNonLinearArithmetic, + CommonOptionBag.IsolateAssertions, BoogieOptionBag.BoogieArguments, + CommonOptionBag.VerificationLogFormat, + CommonOptionBag.SolverResourceLimit, + CommonOptionBag.SolverPlugin, + CommonOptionBag.SolverLog, }.ToList(); public static IReadOnlyList