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

feat: Implement frame-related asserted exprs and TraitDecreases #5542

Merged
merged 10 commits into from
Jun 7, 2024

Conversation

alex-chew
Copy link
Contributor

@alex-chew alex-chew commented Jun 7, 2024

Description

This PR implements GetAssertedExpr for the following five proof obligation description types:

  • Modifiable
  • ModifyFrameSubset
  • ReadFrameSubset
  • TraitFrame
  • TraitDecreases

How has this been tested?

This PR adds integration tests for each of the implemented asserted expressions.

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

@alex-chew alex-chew requested a review from atomb June 7, 2024 09:30
@alex-chew alex-chew marked this pull request as ready for review June 7, 2024 21:42
atomb
atomb previously approved these changes Jun 7, 2024
Copy link
Member

@atomb atomb left a comment

Choose a reason for hiding this comment

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

I like the thoroughness of the tests! One comment wasn't super clear to me, but otherwise I think it looks good.

/// Builds an expression that represents whether (the relevant subset of) the given `supersetFrames`
/// permit read/modification access to all objects, arrays, and/or sets of objects/arrays in the `subsetFrames`.
/// </summary>
public static Expression MakeDafnyMultiFrameCheck(List<FrameExpression> supersetFrames, List<FrameExpression> subsetFrames) {
Copy link
Member

Choose a reason for hiding this comment

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

The detail required in methods like these make me very much want to share this code with the Boogie translation eventually (i.e., have the Boogie generator work by constructing this expression and then translating it). But that's a task for another day.

@@ -0,0 +1,8 @@
modify-frame-subset.dfy(15,2): Error: modify statement might violate context's modifies clause
Asserted expression: (s[0] == s[3] || s[0] in {s[4]} || s[0] in {s[5]}) && (forall obj: C | obj in {s[1]} :: obj == s[3] || obj in {s[4]}) && forall obj: C | obj in {s[2]} :: obj == s[3] || obj in {s[5]}
Copy link
Member

Choose a reason for hiding this comment

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

I think things like this are going to be super useful! With more complicated code, constructing the equivalent of this expression in your head can really be a pain.

@@ -786,10 +822,16 @@ private record ReadsCheckDelayer(ExpressionTranslator etran, Function selfCallsA
}
if (wfOptions.DoReadsChecks) {
// check that the callee reads only what the caller is already allowed to read
var s = new Substituter(null, new Dictionary<IVariable, Expression>(), e.GetTypeArgumentSubstitutions());

// substitute actual args for parameter is frames for the description expression...
Copy link
Member

Choose a reason for hiding this comment

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

Not critical, but this comment isn't super clear to me. Maybe it could be reworded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, there was a typo (and generally unclear wording). I've fixed this in the latest commit.

@alex-chew alex-chew requested a review from atomb June 7, 2024 22:30
atomb
atomb previously approved these changes Jun 7, 2024
@alex-chew alex-chew enabled auto-merge (squash) June 7, 2024 22:37
@alex-chew alex-chew merged commit f75ae71 into master Jun 7, 2024
21 checks passed
@alex-chew alex-chew deleted the alexchew/frame-podesc-exprs branch June 7, 2024 23:45
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.

None yet

2 participants