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 ensures in spec fns #744

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Support for ensures in spec fns #744

wants to merge 4 commits into from

Conversation

jonhnet
Copy link
Collaborator

@jonhnet jonhnet commented Aug 13, 2023

A common pattern in our Dafny predicates is to build up a definition recursively, then use an ensures to export its meaning under a more-powerful quantifier. For example, with receipts we recursively construct a sequence of values where each is related to the one before it by some predicate; users want to know this relation is true ∀ entry pairs in the receipt.

In Dafny, a single 'ensures' line expressing the fact acts as the proof (because it's the necessary inductive property to complete the proof) as well as broadcasting the result via trigger to anyone who mentions the definition name: exactly the automation we want. The absence of this feature has led to a bunch of tedium in porting Dafny specs into Verus.

Ultimately completing the feature requires:

  • The ability to use the ensures as an induction hypothesis (not yet supported in this PR)
  • Appropriate interaction with recommends (which we want to just treat as requires, in practice)
  • The present PR disallows return statements inside spec fns to keep the implementation easy, but that's an unnecessary restriction

@jonhnet
Copy link
Collaborator Author

jonhnet commented Aug 13, 2023

This PR includes tests of stuff that works plus three ignored tests for stuff that doesn't, most conspicuously test_spec_fn_ensures_induction. Handing off to Chris for now.

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.

1 participant