-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --solver-option flag and move others around #3943
Conversation
Thank you, @atomb! I have made a PR to this PR's branch that should make Re: |
Thanks!
I think, for As for |
Make Test Generation work with a custom Z3 version
@@ -10,9 +10,16 @@ namespace Microsoft.Dafny; | |||
public class GenerateTestsCommand : ICommandSpec { | |||
public IEnumerable<Option> Options => | |||
new Option[] { | |||
// IMPORTANT: Before adding new options, make sure they are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems frail. Why not make the code more robust instead of adding this comment? Why doesn't CopyForProcedure
use the DafnyOptions clone constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging this one line PR to Boogie would allow using the DafnyOption's clone constructor and indeed make the code more robust.
The problem is that the ProcsToCheck
field of DafnyOptions
(inherited from Boogie's CommadLineOptions
) does not have a setter. The clone constructor copies the field anyway using reflection but ProcsToCheck
is a list, so the constructor copies the reference and one cannot modify the 'copied' list without modifying the original. The best solution would be to add a setter, like I do in the PR to Boogie above.
@@ -8,9 +8,15 @@ namespace Microsoft.Dafny; | |||
public class DeadCodeCommand : ICommandSpec { | |||
public IEnumerable<Option> Options => | |||
new Option[] { | |||
// IMPORTANT: Before adding new options, make sure they are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems frail. Why not make the code more robust instead of adding this comment? Why doesn't CopyForProcedure use the DafnyOptions clone constructor?
@@ -21,6 +27,8 @@ public class DeadCodeCommand : ICommandSpec { | |||
} | |||
|
|||
public void PostProcess(DafnyOptions dafnyOptions, Options options, InvocationContext context) { | |||
// IMPORTANT: Before adding new default options, make sure they are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems frail. Why not make the code more robust instead of adding this comment? Why doesn't CopyForProcedure use the DafnyOptions clone constructor?
"Can be used to specify a custom SMT solver to use for verifying Dafny proofs.") { | ||
}; | ||
public static readonly Option<IList<string>> SolverOption = new("--solver-option", | ||
"Specify an option to control how the solver works.") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line doesn't tell me how to use this. Could you mention that these arguments are passed directly to the solver CLI; that the default solver is Z3 with a link to its CLI documentation; and that Dafny is already configuring some options, so not all of options might be usable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a --solver-option-help
flag that describes what all the options are, and expanded the help text for --solver-option
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
|
||
public static readonly Option<bool> IsolateAssertions = new("--isolate-assertions", @"Verify each assertion in isolation."); | ||
|
||
public static readonly Option<FileInfo> SolverPath = new("--solver-path", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would set SolverPath
, SolverOption
and SolverPlugin
(which I still think should be named BoogiePlugin) to hidden, since using them requires looking up additional documentation outside of Dafny. If there are particular Z3 options that we think users are likely to get a benefit front, I suggest we expose them as first class Dafny options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, my goal with #3938 is to expose more control over the verification process in a friendly way. But this allows expert users to get that control immediately, if they know they could benefit from it. And it allows us to conveniently experiment with various options to help decide which might be worth exposing in a nicer way.
I agree that SolverOption
should be hidden, and I've made it that way. I'm less convinced about the two Path
options, which I think will be used more frequently.
As far as the name of SolverPlugin
, Boogie plugins can only control how it interfaces with the solver. It doesn't provide any mechanism for them to do anything else. So I still prefer --solver-plugin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
The line breaks in the previous version were preserved in the output, leading to awkwardly-displayed text.
This explains the valid arguments to `--solver-option`.
Adds a
--solver-option
flag to correspond to the old (Boogie)/proverOpt
flag. In the process, this also refactors a few things:CommonOptionBag
toBoogieOptionBag
.--solver-option
,--solver-path
,--solver-plugin
,--solver-log
, and--resource-limit
available to thegenerate-tests
andfind-dead-code
commands.Includes some refactoring to DafnyTestGenerator, thanks to @Dargones, to make it easier to support arbitrary options there.
Addresses #3468 but doesn't entirely resolve it.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.