Skip to content

Implement a proof-by-contradiction attribute#5001

Merged
atomb merged 6 commits into
dafny-lang:masterfrom
atomb:issue-4778
Jan 31, 2024
Merged

Implement a proof-by-contradiction attribute#5001
atomb merged 6 commits into
dafny-lang:masterfrom
atomb:issue-4778

Conversation

@atomb

@atomb atomb commented Jan 22, 2024

Copy link
Copy Markdown
Member

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

@MikaelMayer MikaelMayer left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@atomb atomb requested a review from MikaelMayer January 30, 2024 18:51

@MikaelMayer MikaelMayer left a comment

Copy link
Copy Markdown
Member

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

atomb commented Jan 30, 2024

Copy link
Copy Markdown
Member Author

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
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