summaryrefslogtreecommitdiff
path: root/Test/linear/f1.bpl
blob: cf786143296ca3dbe2f035e836585bb49f3718e3 (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
// RUN: %boogie -noinfer -typeEncoding:m -useArrayTheory -doModSetAnalysis "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
function {:builtin "MapConst"} mapconstbool(bool) : [int]bool;
const {:existential true} b0: bool;
const {:existential true} b1: bool;
const {:existential true} b2: bool;
const {:existential true} b3: bool;
const {:existential true} b4: bool;
const {:existential true} b5: bool;
const {:existential true} b6: bool;
const {:existential true} b7: bool;
const {:existential true} b8: bool;

axiom(b0);
axiom(b1);
axiom(b2);
axiom(b3);
axiom(b4);
axiom(b5);
axiom(!b6);
axiom(!b7);
axiom(b8);

procedure main({:linear_in "1"} x_in: [int]bool) 
  requires b0 ==> x_in == mapconstbool(true);
  requires b1 ==> x_in != mapconstbool(false);
{
   var {:linear "1"} x: [int] bool;
   x := x_in;

   call foo(x);
   
   assert b6 ==> x == mapconstbool(true);
   assert b7 ==> x != mapconstbool(false);
   assert b8 ==> x == mapconstbool(false);
}

procedure foo({:linear_in "1"} x_in: [int]bool)
  requires b2 ==> x_in == mapconstbool(true);
  requires b3 ==> x_in != mapconstbool(false);
{
   var {:linear "1"} x: [int] bool;
   x := x_in;

   assert b4 ==> x == mapconstbool(true);
   assert b5 ==> x != mapconstbool(false);

}