summaryrefslogtreecommitdiff
path: root/Test/test2/Passification.bpl
blob: e13d3e497d5112929e87ae2cde5b1be0699898c1 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// VC generation tests: passification

procedure good0(x: int) returns (y: int, z: int)
  ensures z == 4 || z == 4+x;
{
var t: int;
A:
  t := y;
  z := 3;
  goto B, C;
B:
  z := z + x;
  goto D;
C:
  goto D;
D:
  z := z + 1;
  y := t;
  return;
}

procedure good1(x: int) returns (y: int, z: int)
  ensures z == x + 4;
{
var t: int;
A:
  t := y;
  z := 3;
  z := z + x;
  z := z + 1;
  y := t;
  return;
}

procedure bad0(x: int) returns (y: int, z: int)
  ensures y == 4;  // ERROR: postcondition violation
{
var t: int;
A:
  t := z;
  z := 3;
  z := z + 1;
  y := t;
  return;
}

procedure Loop()
{
start:
  goto start;
}

procedure UnreachableBlock()
{
start:
  return;
notReached:
  goto start;
reallyNeverReached:
  goto reallyNeverReached;
}

procedure Loop0() returns (z: int)
  ensures 10 <= z;
{
var x: int;
A:
  goto B, C;
B:
  assume x < 10;
  x := x + 1;
  goto A;
C:
  assume !(x < 10);
  z := x;
  return;
}

const unique A0: name;
const unique A1: name;
const unique A2: name;

procedure Array0() returns (z: int)
  ensures z >= 5;
{
var a: [name,name]int;
L0:
  a[A0,A2] := 5;
  a[A0,A1] := 20;
  assert a[A0,A1] == 20;
  goto L1,L2;
L1:
  a[A0,A2] := 18;
  assert a[A0,A2] == 18;
  goto L2;
L2:
  assert a[A0,A1] == 20;
  z := a[A0,A2];
  return;
}

procedure Array1(o0: ref, o1: ref) returns (z: int)
  ensures z >= 5;
{
var a: [ref,name]int;
L0:
  a[o1,A0] := 5;
  a[o0,A0] := 20;
  assert a[o0,A0] == 20;
  goto L1,L2;
L1:
  a[o1,A0] := 18;
  assert a[o1,A0] == 18;
  goto L2;
L2:
  assert a[o0,A0] == 20;  // ERROR: assertion failure
  z := a[o1,A0];
  return;
}

procedure Array2(o0: ref, o1: ref) returns (z: int)
  ensures z >= 5;
{
var a: [ref,name]int;
L0:
  assume o1 != o0;
  a[o1,A0] := 5;
  a[o0,A0] := 20;
  assert a[o0,A0] == 20;
  goto L1,L2;
L1:
  a[o1,A0] := 18;
  assert a[o1,A0] == 18;
  goto L2;
L2:
  assert a[o0,A0] == 20;
  z := a[o1,A0];
  return;
}

procedure P()
{
var t: int;
L0:
  t := 0;
  goto L1, L2;
L1:
  t := 1;
  goto L2;
L2:
  assert t == 1;  // ERROR: assert failure
  return;
}

procedure Q()
{
var t: int;
L0:
  t := 0;
  goto L1, L2;
L1:
  t := 1;
  goto L2;
L2:
  assert t == 0;  // ERROR: assert failure
  return;
}

type name, ref;