-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Substitute for heap labels in TrSplitExpr (#2300)
This PR fixes two things related to heap labels. One gave rise to unsound verification, and the other to malformed Boogie code. Fixes #2299
- Loading branch information
1 parent
0757504
commit 448433a
Showing
6 changed files
with
185 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// RUN: %dafny_0 /compile:0 "%s" > "%t" | ||
// RUN: %diff "%s.expect" "%t" | ||
|
||
class Twostate { | ||
var z: int | ||
|
||
twostate predicate Increase() | ||
reads this | ||
{ | ||
old(z) <= z | ||
} | ||
|
||
twostate predicate NoChange() | ||
reads this | ||
{ | ||
unchanged(this) | ||
} | ||
|
||
static twostate predicate IsFresh(new c: Twostate) | ||
{ | ||
fresh(c) | ||
} | ||
|
||
twostate predicate All(new c: Twostate) | ||
reads this | ||
{ | ||
Increase() && NoChange() && IsFresh(c) | ||
} | ||
|
||
method Test0() | ||
modifies this | ||
{ | ||
z := z + 1; | ||
label L: | ||
z := z - 1; | ||
// the following line was once translated incorrectly without the @L | ||
assert Increase@L(); // error: does not hold | ||
assert false; | ||
} | ||
|
||
method Test1() | ||
modifies this | ||
{ | ||
z := z + 1; | ||
label L: | ||
z := z - 1; | ||
// the following line was once translated incorrectly without the @L | ||
assert NoChange@L(); // error: does not hold | ||
} | ||
|
||
method Test2() | ||
modifies this | ||
{ | ||
z := z + 1; | ||
label L: | ||
z := z - 1; | ||
// the following line was once translated incorrectly without the @L | ||
assert IsFresh@L(this); // error: does not hold | ||
} | ||
|
||
method Test3() | ||
{ | ||
var c := new Twostate; | ||
label L: | ||
if * { | ||
// the following line was once translated incorrectly without the @L | ||
assert IsFresh@L(c); // error: does not hold | ||
} else { | ||
assert IsFresh(c); | ||
} | ||
} | ||
|
||
method Test4() | ||
modifies this | ||
{ | ||
var c := new Twostate; | ||
z := z + 1; | ||
label L: | ||
z := z - 1; | ||
// the following line was once translated incorrectly without the @L | ||
assert All@L(c); // error: does not hold | ||
} | ||
|
||
method Test5(k: nat) | ||
modifies this | ||
{ | ||
z := z + k; | ||
label L: | ||
var c := new Twostate; | ||
|
||
assert Increase@L(); | ||
assert NoChange@L(); | ||
assert IsFresh@L(c); | ||
|
||
assert Increase(); | ||
if k == 0 { | ||
assert NoChange(); | ||
} | ||
assert IsFresh(c); | ||
} | ||
|
||
method Test6() | ||
modifies this | ||
{ | ||
z := z + 1; | ||
var c := new Twostate; | ||
label L: | ||
z := z - 1; | ||
|
||
assert Increase(); | ||
assert NoChange(); | ||
assert IsFresh(c); | ||
} | ||
|
||
method Test7() | ||
modifies this | ||
{ | ||
z := z + 1; | ||
label L: | ||
var c := new Twostate; | ||
assert All@L(c); | ||
} | ||
|
||
method FreeHeapAtVariables() | ||
modifies this | ||
{ | ||
z := z + 1; | ||
label L: | ||
z := z - 1; | ||
ghost var x; | ||
// regression: the following line once led to malformed Boogie | ||
x := var u :| u == Increase@L(); !u; | ||
assert x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
git-issue-2299.dfy(37,11): Error: assertion might not hold | ||
git-issue-2299.dfy(10,11): Related location | ||
git-issue-2299.dfy(48,11): Error: assertion might not hold | ||
git-issue-2299.dfy(16,4): Related location | ||
git-issue-2299.dfy(58,11): Error: assertion might not hold | ||
git-issue-2299.dfy(21,4): Related location | ||
git-issue-2299.dfy(67,13): Error: assertion might not hold | ||
git-issue-2299.dfy(21,4): Related location | ||
git-issue-2299.dfy(81,11): Error: assertion might not hold | ||
git-issue-2299.dfy(27,4): Related location | ||
git-issue-2299.dfy(10,11): Related location | ||
git-issue-2299.dfy(81,11): Error: assertion might not hold | ||
git-issue-2299.dfy(27,18): Related location | ||
git-issue-2299.dfy(16,4): Related location | ||
git-issue-2299.dfy(81,11): Error: assertion might not hold | ||
git-issue-2299.dfy(27,32): Related location | ||
git-issue-2299.dfy(21,4): Related location | ||
|
||
Dafny program verifier finished with 7 verified, 7 errors |