blob: c874a1c1bb4c34c22eab321687207e6d352d09ca (
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
|
procedure TestTimeouts0(in: [int]int, len: int) returns (out: [int]int)
requires in[0] == 0 && (forall i: int :: 0 <= i ==> in[i + 1] == in[i] + 1);
requires 0 < len;
ensures (forall j: int :: 0 <= j && j < len ==> out[j] == j);
{
var i : int;
i := 0;
out[i] := 0;
while (i < len)
invariant 0 <= i && i <= len;
invariant out[0] == 0 && (forall j: int :: 0 <= j && j < i ==> out[j + 1] == out[j] + 1);
{
out[i + 1] := out[i] + 1;
i := i + 1;
}
i := 0;
while (i < len)
invariant 0 <= i && i <= len;
invariant (forall j: int :: 0 <= j && j < i ==> out[j] == in[j]);
{
i := i + 1;
}
}
procedure TestTimeouts1(in: [int]int, len: int) returns (out: [int]int);
requires in[0] == 0 && (forall i: int :: 0 <= i ==> in[i + 1] == in[i] + 1);
requires 0 < len;
ensures (forall j: int :: 0 <= j && j < len ==> out[j] == j);
implementation {:timeLimit 8} TestTimeouts1(in: [int]int, len: int) returns (out: [int]int)
{
var i : int;
i := 0;
out[i] := 0;
while (i < len)
invariant 0 <= i && i <= len;
invariant out[0] == 0 && (forall j: int :: 0 <= j && j < i ==> out[j + 1] == out[j] + 1);
{
out[i + 1] := out[i] + 1;
i := i + 1;
}
i := 0;
while (i < len)
invariant 0 <= i && i <= len;
invariant (forall j: int :: 0 <= j && j < i ==> out[j] == in[j]);
{
i := i + 1;
}
}
procedure TestTimeouts2(in: [int]int, len: int) returns (out: [int]int);
requires in[0] == 0 && (forall i: int :: 0 <= i ==> in[i + 1] == in[i] + 1);
requires 0 < len;
ensures (forall j: int :: 0 <= j && j < len ==> out[j] == j);
implementation {:timeLimit 2} TestTimeouts2(in: [int]int, len: int) returns (out: [int]int)
{
var i : int;
i := 0;
out[i] := 0;
while (i < len)
invariant 0 <= i && i <= len;
invariant out[0] == 0 && (forall j: int :: 0 <= j && j < i ==> out[j + 1] == out[j] + 1);
{
out[i + 1] := out[i] + 1;
i := i + 1;
}
i := 0;
while (i < len)
invariant 0 <= i && i <= len;
invariant (forall j: int :: 0 <= j && j < i ==> out[j] == in[j]);
{
i := i + 1;
}
}
|