summaryrefslogtreecommitdiff
path: root/Test/civl/ghost.bpl
blob: 74d16acf266fdae52769df2fa6f0069eb15d7dfd (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
// RUN: %boogie -noinfer -typeEncoding:m -useArrayTheory "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
var {:layer 0} x: int;

procedure {:yields} {:layer 0,1} Incr();
ensures {:right} |{ A: x := x + 1; return true; }|;

procedure ghost(y: int) returns (z: int)
requires y == 1;
ensures z == 2;
{
  z := y + 1;
}

procedure {:yields} {:layer 1,2} Incr2() 
ensures {:right} |{ A: x := x + 2; return true; }|;
{
  var {:ghost} a: int;
  var {:ghost} b: int;

  yield;
  call a := ghost(1);
  assert {:layer 1} a == 2;
  par Incr() | Incr();
  yield;
}

procedure ghost_0() returns (z: int)
ensures z == x;
{
  z := x;
}

procedure {:yields} {:layer 1,2} Incr2_0() 
ensures {:right} |{ A: x := x + 2; return true; }|;
{
  var {:ghost} a: int;
  var {:ghost} b: int;

  yield;
  call a := ghost_0();
  par Incr() | Incr();
  call b := ghost_0();
  assert {:layer 1} b == a + 2;
  yield;
}