blob: 675b3842214fa0c1db32fb86bf315133e16290f1 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
// RUN: %boogie -noinfer -typeEncoding:m -useArrayTheory "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function {:builtin "MapConst"} mapconstbool(bool) : [int]bool;
function {:builtin "MapConst"} MapConstBool(bool) : [int]bool;
function {:inline} {:linear "tid"} TidCollector(x: int) : [int]bool
{
MapConstBool(false)[x := true]
}
function {:inline} {:linear "1"} SetCollector1(x: [int]bool) : [int]bool
{
x
}
function {:inline} {:linear "2"} SetCollector2(x: [int]bool) : [int]bool
{
x
}
var {:layer 0,1} g: int;
var {:layer 0,1} h: int;
procedure {:yields} {:layer 0,1} SetG(val:int);
ensures {:atomic} |{A: g := val; return true; }|;
procedure {:yields} {:layer 0,1} SetH(val:int);
ensures {:atomic} |{A: h := val; return true; }|;
procedure {:yields} {:layer 1} Yield({:linear "1"} x: [int]bool)
requires {:layer 1} x == mapconstbool(true) && g == 0;
ensures {:layer 1} x == mapconstbool(true) && g == 0;
{
yield;
assert {:layer 1} x == mapconstbool(true) && g == 0;
}
procedure {:yields} {:layer 1} Allocate() returns ({:linear "tid"} xl: int)
ensures {:layer 1} xl != 0;
{
yield;
call xl := AllocateLow();
yield;
}
procedure {:yields} {:layer 0,1} AllocateLow() returns ({:linear "tid"} xls: int);
ensures {:atomic} |{ A: assume xls != 0; return true; }|;
procedure {:yields} {:layer 1} A({:linear_in "tid"} tid_in: int, {:linear_in "1"} x: [int]bool, {:linear_in "2"} y: [int]bool) returns ({:linear "tid"} tid_out: int)
requires {:layer 1} x == mapconstbool(true);
requires {:layer 1} y == mapconstbool(true);
{
var {:linear "tid"} tid_child: int;
tid_out := tid_in;
yield;
call SetG(0);
par tid_child := Allocate() | Yield(x);
async call B(tid_child, x);
yield;
assert {:layer 1} x == mapconstbool(true);
assert {:layer 1} g == 0;
call SetH(0);
yield;
assert {:layer 1} h == 0 && y == mapconstbool(true);
yield;
call tid_child := Allocate();
async call C(tid_child, y);
yield;
}
procedure {:yields} {:layer 1} B({:linear_in "tid"} tid_in: int, {:linear_in "1"} x_in: [int]bool)
requires {:layer 1} x_in != mapconstbool(false);
{
var {:linear "tid"} tid_out: int;
var {:linear "1"} x: [int]bool;
tid_out := tid_in;
x := x_in;
yield;
call SetG(1);
yield;
}
procedure {:yields} {:layer 1} C({:linear_in "tid"} tid_in: int, {:linear_in "2"} y_in: [int]bool)
requires {:layer 1} y_in != mapconstbool(false);
{
var {:linear "tid"} tid_out: int;
var {:linear "2"} y: [int]bool;
tid_out := tid_in;
y := y_in;
yield;
call SetH(1);
yield;
}
|