summaryrefslogtreecommitdiff
path: root/Test/test2/Lambda.bpl
blob: 477d0f36eff7b988c1f0f08aa6e5ac3b8a3ee6ab (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
procedure foo()
{
  var a: [int]int;
  var c:int,b:bool;
  a := (lambda y:int :: if b then y + c else 7);
  assume b;
  assert a[3] == c+3;
}

procedure bar()
{
  assert (lambda x:int :: x > 0)[10];
  
}

type t1;

procedure baz()
{
  var m:[int,t1]int;
  var t:t1, t2:t1;

  m := (lambda i:int, tt:t1 :: if tt == t then i else 12);
  assert m[1,t] == 1;
  assert t == t2 || m[1,t2] == 12;
  assert  m[12,t2] == 12;
  
}


procedure fail()
{
  var m:[int,t1]int;
  var t:t1, t2:t1;

  m := (lambda i:int, tt:t1 :: if tt == t then i else 12);
  assert m[1,t2] == 12;
  assert m[1,t] == 2;
}

type set = [int]bool;
function union(a:set, b:set) : set;
axiom (forall a,b:set :: union(a,b) == (lambda x:int :: a[x] || b[x]));

function diff(a:set, b:set) : set {(lambda x:int :: a[x] && !b[x]) }

procedure a()
{
  var a:set, b:set;
  assume a[1];
  assume b[2];
  assert union(a,b)[1];
  assert union(a,b)[2];
  assume !b[1];
  assert diff(a,b)[1];
  assert !diff(a,b)[2];
}

procedure nestedLambda()
{
  var a: [int][int]int;

  a := (lambda x: int :: (lambda y: int :: x+y));
}