-
Notifications
You must be signed in to change notification settings - Fork 254
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]: Alert users to obviously contradictory preconditions #3089
Comments
You mean, better not require
I hear you. I think it's not too much of a problem. I've seen a lot of C# warnings that I know are always heuristics. And industrial-level users would always test their code, to ensure that methods can be called statically |
Heh, that would be more correct :-) The example I was actually thinking of was
Sounds good! Happy to take on part of the hacking if you think there's a reasonable decomposition of effort for this one, too.
Makes sense! |
What is the feature you would like to see in a future version of Dafny?
Pulling out the discussion in the comments section of #3076 into its own issue:
I was recently bitten by a super-silly precondition of mine, essentially of the form
requires x < x
for somex: int
, and only much later did I realise I had, somewhere, tied myself in a knot[1]. By this point, the contradiction was in a totally different module that I had paged out of my mind, so it took awhile to find. It would be nice if Dafny could expose up impossible preconditions so the user knows that they're not inadvertently introducing anexfalso
style hole in their proofs. It'd be fine if this was only a warning, indicating the presence of such a precondition or that a proof transitively involves such a precondition (via arequire
d predicate or lemma, for instance.)@MikaelMayer replied thus:
This seems like a problem, indeed - most of the type proving false would not be possible, presumably, so in the typical case we'd be giving the solver an unnecessary workout.
To this end, Mikael proposed a subset of the feature, where straightforward contradictory syntactic patterns could be caught cheaply:
I suspect something like this would have caught my particular issue (technically my "reflexive inequality" involved an array access, akin to
a[i] < a[i]
, but presumably it's no more complex to pull in an array axiom or two?)I might suggest two points of discussion:
Another potential pitfall that would be nice to have a story around would be for "obvious contradictions" between preconditions: for instance, if I
require a[i] == b[i]
, I better not alsorequire a != b
, or some such thing. In terms of implementation this could well be orthogonal to a localised syntax-driven check. By the same token, I could also imagine at some level all preconditions get ANDed together into some (in this case contradictory) formula. This could still abut complexity issues, of course.There could be a concern that users might expect the precondition contradiction checker to be smarter than it is, and rely on it for more complicated cases than it knows about. For instance, suppose that array indexing equality was not part of the hardcoded syntactic checks (as it isn't listed in the above set of expressions): I might conclude that the issue in my project was elsewhere from the
requires a[i] < a[i]
case, since I might assume that Dafny catches precondition contradictions in general. I don't know how often users trip over things like this.Thanks!
Nathan
[1]: power dafny user lesson 1: if your code is consistently passing the verifier and you're starting to think, "boy, am I ever good at writing correct programs", be wary ;-)
The text was updated successfully, but these errors were encountered: