blob: 434d1f146914829ab30b43ba32f46a9ca1f310ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
type X;
const nil: X;
var l: X;
var x: int;
procedure Allocate() returns ({:linear "tid"} xls: X);
ensures xls != nil;
procedure {:entrypoint} main()
{
var {:linear "tid"} tid: X;
var val: int;
while (*)
{
call tid := Allocate();
havoc val;
async call foo(tid, val);
}
}
procedure foo({:linear "tid"} tid': X, val: int)
requires tid' != nil;
{
var {:linear "tid"} tid: X;
tid := tid';
assume l == nil;
l := tid;
call tid := Yield(tid);
x := val;
call tid := Yield(tid);
assert x == val;
call tid := Yield(tid);
l := nil;
}
procedure Yield({:linear "tid"} tid': X) returns ({:linear "tid"} tid: X)
requires tid' != nil;
ensures tid == tid';
ensures old(l) == tid ==> old(l) == l && old(x) == x;
{
tid := tid';
yield;
assert tid != nil;
assert (old(l) == tid ==> old(l) == l && old(x) == x);
}
|