-
Notifications
You must be signed in to change notification settings - Fork 256
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
[Feature request]: Generate explicit assertions #2987
Comments
Thanks for the write-up. Looks great! I feel your For the sake of reducing scope, do you think we could split that WP-based assertion moving to a different issue? Also, in your
|
I think that in the "Invariant generation" example it would be better to generate the invariant according to WP rules, so you would get |
Done as of today. I moved both "if" and "invariant" to this other issue:
Yeah that's a very interesting and clever remark. I changed my example here: |
Now that we're actively working on this, I'm adding a list of assertion types so we can keep track of which are implemented:
|
### Description Adds a first pass of proof obligation description expressions, towards resolving #2987. It also adds a new hidden option, `--show-proof-obligation-expressions`, which adds to each (supported) failed proof obligation error message an equivalent Dafny assertion. This option is used to automate tests for the newly added proof obligation description expressions, but this PR does not backfill tests for existing PODesc expressions. By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license. --------- Co-authored-by: Aaron Tomb <[email protected]>
What is the feature you would like to see in a future version of Dafny?
When the Dafny verifier fails, it's sometimes obvious what is failing, sometimes it's not. It would be good to provide a code action to explicit the assertion that is failing.
Consider the following simple case:
Dafny throws a "potential division by zero". If we add a suitable assertion, in VSCode IDE it becomes obvious thanks to the green check mark that now the division passes, and the assertion took ownership of the error.
Although this is one of the simplest cases, consider the following more complex cases:
Function preconditions
In the example above, the only error is "function precondition might not hold", and what is failing is given only in the command line. It would be good to be able to have a code action to insert the failing precondition, like this:
Decreases clause generation
Similarly, when Dafny complains that "Cannot prove termination", it's not obvious to new users what needs to be asserted. For example:
![image](https://user-images.githubusercontent.com/3601079/200001052-98bae85f-6f52-48c4-a307-ab9c36a58628.png)
![image](https://user-images.githubusercontent.com/3601079/200001268-684caecb-4848-4d70-8b35-7658790aeeaa.png)
With a suitable code action, we could simply automatically add the missing assertion:
Assign such that assertion generation
"to be compilable, the value of a let-such-that expression must be uniquely determined"
![image](https://user-images.githubusercontent.com/3601079/200001906-4093a965-dacc-421d-a5ac-1524c3e0c784.png)
![image](https://user-images.githubusercontent.com/3601079/200001964-c6c61d2c-587b-4142-8b6a-0ed4f6ace851.png)
We could insert the appropriate assertion as well:
Similarly, for the existential aspect of it
![image](https://user-images.githubusercontent.com/3601079/200002163-b669f363-ca65-46d7-9639-5f055fc2fff4.png)
![image](https://user-images.githubusercontent.com/3601079/200002375-707cf07f-c0ac-492b-9ebe-997519926254.png)
we could insert the appropriate assertion as well:
Subset type constraint
In the following code:
This issue is related to #2153
The text was updated successfully, but these errors were encountered: