Skip to content

Commit

Permalink
Fix: Opaque functions with frame condition supported as follow-up of #…
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelMayer committed May 5, 2023
1 parent 3099624 commit f27d8e2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Source/DafnyCore/Verifier/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4010,6 +4010,11 @@ void AddFrameAxiom(Function f) {
// This is the general case
Bpl.Expr prevH = null;
Bpl.BoundVariable prevHVar = null;
Bpl.Expr reveal = null;
Bpl.BoundVariable revealVar = null;
if (f.IsOpaque) {
revealVar = BplBoundVar("$reveal", Bpl.Type.Bool, out reveal);
}
if (f is TwoStateFunction) {
// The previous-heap argument is the same for both function arguments. That is,
// the frame axiom says nothing about functions invoked with different previous heaps.
Expand Down Expand Up @@ -4050,6 +4055,11 @@ void AddFrameAxiom(Function f) {
f0args.Add(s); f1args.Add(s); // but don't add to f0argsCanCall or f1argsCanCall
}

if (reveal != null) {
bvars.Add(revealVar);
f0args.Add(reveal); f1args.Add(reveal);
}

if (prevH != null) {
bvars.Add(prevHVar);
f0args.Add(prevH); f1args.Add(prevH); f0argsCanCall.Add(prevH); f1argsCanCall.Add(prevH);
Expand Down
10 changes: 10 additions & 0 deletions Test/git-issues/git-issue-3955.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,14 @@ datatype B = B(
{
a.Valid()
}
}

class C {
var a: A
constructor()
opaque twostate predicate Valid()
reads this`a, a
{
a.Valid() && old(a.Valid())
}
}
2 changes: 1 addition & 1 deletion Test/git-issues/git-issue-3955.dfy.expect
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

Dafny program verifier finished with TODO verified, TODO errors
Dafny program verifier finished with 3 verified, 0 errors
1 change: 1 addition & 0 deletions docs/dev/news/3955.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Opaque functions with frame condition supported as follow-up of #3779

0 comments on commit f27d8e2

Please sign in to comment.