Skip to content
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

Implement a proof-by-contradiction attribute #5001

Merged
merged 6 commits into from
Jan 31, 2024
Merged

Conversation

atomb
Copy link
Member

@atomb atomb commented Jan 22, 2024

Description

Allows a particular assertion to be marked as an intentional proof by contradiction, preventing --warn-contradictory-assumptions from flagging it.

Fixes #4778

How has this been tested?

Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4778.dfy

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Allows a particular assertion to be marked as an intentional proof by
contradiction, preventing `--warn-contradictory-assumptions` from
flagging it.

Fixes dafny-lang#4778
@atomb atomb marked this pull request as ready for review January 25, 2024 00:03
Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting and useful. Could you perhaps do two things:

  • When you report "proved by contradictory assumptions", could you also mention this {:contradiction} attribute so that it's easy to discover?
  • Add one more line in docs/dev/news about that new attribute
  • Add a line about the documentation of this new attributes in docs/DafnyRef/Attributes.md

@keyboardDrummer
Copy link
Member

Could you document the attribute in the help of the --warn-contradictory-assumptions option?

Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! This is a good answer to the problem of being able to assert intermediate steps when the hypotheses already contradict.
I note that it won't help for preconditions in lemmas though, correct?

@atomb
Copy link
Member Author

atomb commented Jan 30, 2024

Looks great! This is a good answer to the problem of being able to assert intermediate steps when the hypotheses already contradict. I note that it won't help for preconditions in lemmas though, correct?

Are you thinking of the use case of trying to show that A and B are inconsistent using a lemma? So you'd write something like:

lemma L():
  requires A
  requires B
  ensures false
{}

If that's what you mean, then no, this PR doesn't support that use case. Perhaps it would be possible to allow the same attribute on an ensures clause, though, which would allow that.

@atomb atomb enabled auto-merge (squash) January 30, 2024 21:34
@atomb atomb merged commit 8221c9d into dafny-lang:master Jan 31, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable finer-grained control of redundant- and contradictory-assumption warnings
3 participants