summaryrefslogtreecommitdiff
path: root/Test/aitest9/VarMapFixpoint.bpl
blob: 6a051ed9dc0e192315c27197aa20eb4a541b31be (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
// RUN: %boogie "%s" -infer:j > "%t"
// RUN: %diff "%s.expect" "%t"
procedure main()
{
  var x: int, y: int, z: int;

  start:
    x := 2;
    y := 6;
    goto LoopHead;

  LoopHead:
    assert y < 10;  // error: the loop body sets y to an arbitrary value
    goto LoopBody, LoopEnd;

  LoopBody:
    havoc y;
    goto LoopHead;

  LoopEnd:
    return;
}

procedure SimpleWhile5() returns (returnValue: int)
{
  var i: int;

  start:
    returnValue := 1;
    havoc i;
    goto LoopHead;

  LoopHead:
    goto LoopBody, LoopEnd;

  LoopBody:
    // here, we would simply like to "assume 1 <= i", but the interval domain doesn't interpret
    // assume commands, so we start a loop
    i := 1;
    goto IncLoopHead;

  IncLoopHead:
    goto IncI, IncDone;

  IncI:
    i := i + 1;
    goto IncLoopHead;

  IncDone:
    // now we have 1 <= i
    assert 1 <= i;

    returnValue := returnValue * i;
    i := i - 1;
    goto LoopHead;

  LoopEnd:
    assert returnValue >= 1;
    return;
}