blob: 4520a0321b0a80e32e2d8f9a8df4485fa1f74aaf (
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
|
const N: int;
axiom 0 <= N;
procedure P(K: int)
requires 0 <= K;
{
var b: bool, x, k: int;
if (!b) {
b := !b;
}
x := if b then 13 else 10;
k := K;
while (k != 0) {
x := x + k;
k := k - 1;
}
assert 13 <= x;
}
procedure Thresholds0()
{
var i: int;
i := 0;
while (i < 200)
{
i := i + 1;
}
assert i == 200;
}
procedure Thresholds1()
{
var i: int;
i := 0;
while (i <= 199)
{
i := i + 1;
}
assert i == 200;
}
procedure Thresholds2()
{
var i: int;
i := 100;
while (0 < i)
{
i := i - 1;
}
assert i == 0;
}
procedure Thresholds3()
{
var i: int;
i := 0;
while (i < 200)
{
i := i + 1;
}
assert i == 199; // error
}
procedure Thresholds4()
{
var i: int;
i := 0;
while (i + 3 < 203)
{
i := i + 1;
}
assert i * 2 == 400; // error: this would hold in an execution, but /infer:j is too weak to infer invariant i<=200
}
procedure UnaryNegation0() returns (x: int) // this was once buggy
{
x := -1;
loop_head:
x := x;
goto loop_head, after_loop;
after_loop:
assert x == -1;
}
procedure UnaryNegation1() returns (x: int) // this was once buggy
{
x := -1;
loop_head:
x := x;
goto loop_head, after_loop;
after_loop:
assert x == 1; // error
}
|