summaryrefslogtreecommitdiff
path: root/Test/og/new1.bpl
blob: 537a5f4bd47e20ac93a283d58d7e65eb841ef226 (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
// RUN: %boogie -noinfer -typeEncoding:m -useArrayTheory "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function {:builtin "MapConst"} mapconstbool(x:bool): [int]bool;

var {:phase 1} g:int;

function {:inline} {:linear "Perm"} SetCollectorPerm(x: [int]bool) : [int]bool
{
  x
}

procedure Allocate_Perm({:linear_in "Perm"} Permissions: [int]bool) returns ({:linear "Perm"} xls: [int]bool);
requires Permissions == mapconstbool(true);
ensures xls == mapconstbool(true);

procedure {:yields} {:phase 1} PB({:linear_in "Perm"} permVar_in:[int]bool)
requires {:phase 1} permVar_in[0] && g == 0;
{
  var {:linear "Perm"} permVar_out: [int]bool;
  permVar_out := permVar_in;

  yield;
  assert {:phase 1} permVar_out[0];
  assert {:phase 1} g == 0;

  call IncrG();

  yield;
  assert {:phase 1} permVar_out[0];
  assert {:phase 1} g == 1;
}

procedure {:yields} {:phase 1} Main({:linear_in "Perm"} Permissions: [int]bool)
requires {:phase 0,1} Permissions == mapconstbool(true);
{
  var {:linear "Perm"} permVar_out: [int]bool;

  call permVar_out := Allocate_Perm(Permissions);
  yield;
  call SetG(0);
  async call PB(permVar_out);
  yield;
}

procedure {:yields} {:phase 0,1} SetG(val:int);
ensures {:atomic} |{A: g := val; return true; }|;

procedure {:yields} {:phase 0,1} IncrG();
ensures {:atomic} |{A: g := g + 1; return true; }|;