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

Support for labelled assertions and requires in functions #3804

Closed
MikaelMayer opened this issue Mar 27, 2023 · 0 comments · Fixed by #3838
Closed

Support for labelled assertions and requires in functions #3804

MikaelMayer opened this issue Mar 27, 2023 · 0 comments · Fixed by #3838
Assignees
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny

Comments

@MikaelMayer
Copy link
Member

Summary

There are labelled assertions in statements, but not in expressions. Similarly, it's not possible to reveal "labelled requires" in functions.

Background and Motivation

We often see a conversion from method to functions to ease reasoning.
However, labelling assertion is not possible in expressions. In the following example:

predicate P(x: int)

function test(): (i: int)
  ensures P(i)
  requires rule: forall i | i % 2 == 0 :: P(i)
{
  assert rule2: forall i | i % 4 == 0 :: P(i) by {
    reveal rule;
  }
  assert P(12) by {
    reveal rule;
  }
  12
}

assert rule2: is not permitted, and if removed, reveal rule; is not permitted either.
It ought to be available.

Proposed Feature

  • Labelled assertions in expressions
  • Support for revealing labelled requires in functions

Alternatives

Not having labelled assertions is not a problem for small codebases, but bigger codebases start to have this issue.
The workaround for not having labelled assertions is to have non-labelled assertions, but as functions grow, verification can become not durable. Not only that, but to figure out what assertions actually speed up proof, one absolutely needs to isolate assertions so that they don't interfere with other mechanisms.
Another workaround is to convert a function to a method, but it's not always possible, especially if the function was called by other functions.

@MikaelMayer MikaelMayer added the kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny label Mar 27, 2023
@MikaelMayer MikaelMayer self-assigned this Apr 4, 2023
MikaelMayer added a commit that referenced this issue Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant