summaryrefslogtreecommitdiff
path: root/Test/og/FlanaganQadeer.bpl
blob: 5985b6d6efb7182a24a44adb7ec1e1d9a678f3b3 (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} {:yields} main()
{
    var {:linear "tid"} tid: X;
    var val: int;

    while (*) 
    {
        call tid := Allocate();
        havoc val;
        async call foo(tid, val);
    }
}

procedure {:yields} {:stable} 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 {:yields} 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);
}