summaryrefslogtreecommitdiff
path: root/Test/z3api/bar6.bpl
blob: b0f727671fb6d90f598d25390a27b87fb1e91766 (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
var M: [int]int;

procedure {:inline 1} bar(y: int) returns (b: bool)
modifies M;
{
  if (b) {
    M[y] := M[y] + 1;
  } else {
    M[y] := M[y] - 1;
  }
}

procedure {:inline 1} foo(x: int, y: int) 
modifies M;
{
  var b: bool;

  call b := bar(y);
  if (b) {
    M[x] := M[x] + 1;
  } else {
    M[x] := M[x] - 1;
  }
}

procedure main(x: int, y: int) returns (b: bool)
requires x != y;
requires M[x] == M[y];
ensures !b ==> M[x] == M[y]+1;
ensures b ==> M[x]+1 == M[y];
modifies M;
{
  call foo(x, y);
  assert M[x] == M[y];
  call b := bar(y);
}