summaryrefslogtreecommitdiff
path: root/Test/test2/LambdaOldExpressions.bpl
blob: 24ce498db21c754651826e1d69d4c75127897eff (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
// RUN: %boogie -noinfer "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
var b: bool;


procedure p0();
  requires b;
  modifies b;
  ensures (lambda x: bool :: {:MyAttr "put an attr here", !b} old(b))[true];
  ensures !(lambda x: bool :: {:AnotherAttr "yes, why not", b} {:ABC b, b, old(b)} b)[true];

implementation p0()
{
    b := !b;
    assert (lambda x: bool :: old(b))[true];
    assert !(lambda x: bool :: b)[true];
}


procedure p1();
  requires !b;
  modifies b;
  ensures (lambda x: bool :: old(b))[true];  // error

implementation p1()
{
    b := !b;
    assert !(lambda x: bool :: old(b))[true];
}


procedure p2();
  requires b;
  modifies b;
  ensures (lambda x: bool :: old(b) != b)[true];

implementation p2()
{
    b := !b;
    assert (lambda x: bool :: old(b) != b)[true];
}


procedure p3();
  requires b;
  modifies b;
  ensures (lambda x: int :: old(old(b)) != b)[15];

implementation p3()
{
    b := !b;
    assert (lambda x: int :: old(old(b)) != b)[15];
}

// Note that variables (inside and outside old expressions) mentioned
// in attributes (even if they are not mentioned in the body of the
// lambda) are also picked up by the auto-generated lambda functions,
// so that the attributes can be copied to the function and axiom.
var h: int;
procedure TestAttributeParameters()
  ensures (lambda x: int :: {:MyAttribute old(h), h} x < 100)[23];
{
}