blob: c74e9320af1cbf9327d80429430172581ec59924 (
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
|
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;
}
}
|