-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
924804b
commit e41ab2b
Showing
2 changed files
with
32 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
field balance: Int | ||
field amount: Int | ||
|
||
predicate is_balance(addr: Ref) | ||
{ | ||
acc(addr.balance) | ||
} | ||
|
||
method deposit(coin1: Ref) | ||
requires acc(coin1.amount) | ||
ensures acc(coin1.amount) | ||
|
||
method failing_assertion(x: Ref, coin: Ref) | ||
requires is_balance(x) | ||
&& acc(coin.amount) | ||
{ | ||
// inserting this allows Carbon to verify the assertion | ||
// var b : Int | ||
// b := unfolding is_balance(x) in x.balance | ||
|
||
// this should be completely unrelated, however without this line the assertion succeeds | ||
deposit(coin) | ||
|
||
// fails in carbon but succeeds in silicon | ||
assert (unfolding is_balance(x) in x.balance) == old(unfolding is_balance(x) in x.balance) | ||
} |