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
|
// Examples from the Boogie2 language report
type C, D;
var x : int;
var y : int;
var z : int;
var a : [int]int;
var b : [int][C, D]int;
procedure P(i:int, j:int, m:C, n:D) returns () modifies x, y, a, b; {
var x1 : int;
var y1 : int;
x := x+1;
a[i] := 12;
assert a[i] == 12;
x1 := x;
y1 := y;
x, y := y, x;
assert x == y1 && y == x1;
assert x == x1; // error
x, a[i] := x+1, x;
assert x == y1+1 && a[i] == y1;
b[i][m, n] := 17;
b[i][m, n], x := a[x], y;
assert b[i][m, n] == a[y1+1];
assert false; // error
}
procedure Q() returns () modifies x, y, z; {
x, y, z := 1, 2, 3;
x, y, z := y, z, x;
x, y, z := y, z, x;
x, y, z := y, z, x;
assert x == 1 && y == 2 && z == 3;
x, y, z := y+1, z+1, x+1;
x, y, z := y+1, z+1, x+1;
x, y, z := y+1, z+1, x+1;
assert x == 4 && y == 5 && z == 6;
assert a[x] == a[y]; // error
}
|