-
Notifications
You must be signed in to change notification settings - Fork 271
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
Improve assertion failure wording #3216
Comments
Thanks for using Dafny and for this positive feedback !
The challenge of modeling programs using SMT solvers is that, when using quantifiers, z3 comes up with a counter-example it cannot disprove is not correct. That's where it says "unknown" and returns a counter-example, and Dafny says "assertion might not hold". Everything that is not proven in Dafny is indeed reported indistinguishably as an error.
It's not possible in general to "run" counter-examples, because it can involve ghost code that is either not compiled, or cannot be compiled at all (e.g. when using frames to model the heap, we can't take a screenshot of the heap). Also, Dafny models functions with two unrollings maximum when proving them, which means that the third recursive call is uninterpreted, so it's not always helpful to have a counter-example that says that a function's value on the third recursive call is not what would be computed in practice. But otherwise, I like the idea of being able to test if counter-examples make sense, either by running them or verifying them independently if possible.
I agree that "could not prove assertion" seems better, like postconditions, I had been thinking about it also. Previously, the message stated "assertion violation" which had proven to be awfully confusing for some users. |
Ok I don't follow fully (total noob here) but if I'm understanding you directly the issue is when you have something like:
Then it can fail to prove it, and give a counter-example of say I had a look at the code, and it seems like this bit is where the prover results are translated to Dafny's messages: ProverInterface.Outcome.Valid => GutterVerificationStatus.Verified,
ProverInterface.Outcome.Invalid => GutterVerificationStatus.Error,
ProverInterface.Outcome.Undetermined => GutterVerificationStatus.Inconclusive,
ProverInterface.Outcome.TimeOut => GutterVerificationStatus.Error,
ProverInterface.Outcome.OutOfMemory => GutterVerificationStatus.Error,
ProverInterface.Outcome.OutOfResource => GutterVerificationStatus.Error,
ProverInterface.Outcome.Bounded => GutterVerificationStatus.Error, And then here it converts it to a message:
Where
Are you saying that none of the In which case what is the practical difference between |
When Boogie says invalid, it means that it has a counter-example for the model Dafny sent it. Dafny provides the guarantee that if Boogie says valid, then the Dafny code is valid. I'm not an expert in this domain, @RustanLeino could answer better, Once we will get a better debugging experience in VSCode, users would be able to browse the actual counter-example, see where there is a mismatch with Dafny, and potentially give more fuel or write things differently |
Ah ok I think I understand. In that case can I suggest:
Would you accept a PR for that? |
|
This PR fixes #3216 It completely replaces the wording ".... might not hold" by "could not prove..."
Dafny version
3.10.0
Code to produce this issue
Command to run and resulting output
What happened?
I've done some formal verification of SystemVerilog using SVA and Synopsys's VC_Static tool. With that tool you write properties, click "Prove" and then wait. The possible states of a property are:
A counter-example is only available in the Falsified case.
This all makes intuitive sense to me.
Dafny doesn't seem to do it in the same way. Proven is the same, but all other three states result in the error
assertion might not hold
which by any reasonable interpretation means it has been falsified.Even worse, you can press F7 to generate a counter-example even for the inconclusive case where the example actually satisfies the assertion!
Could Dafny not distinguish Falsified and Inconclusive? If not I think the error should at least be reworded to
could not prove assertion
which I think is what it is actually trying to say. (Similarly for postconditions etc.)For the counter-examples it should be trivial to determine if the generated counter-example passes or fails the assertion and give a message like
this example disproves the assertion
orthis example passes the assertion but Dafny cannot reason about it
(or whatever a passing counter-example is supposed to mean).Hope this isn't too negative. My overall experience of Dafny so far has been very positive, mainly because of the excellent VSCode extension and amazing documentation.
What type of operating system are you experiencing the problem on?
Windows
The text was updated successfully, but these errors were encountered: