summaryrefslogtreecommitdiff
path: root/Test/test2/FormulaTerm.bpl
blob: 41c2f44105b466da7f9de91b36cbf5920f41e080 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// RUN: %boogie -noinfer "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// Test formula-term distinction in Simplify

procedure plus(x: int, y: int) returns (z: int);
  ensures z == x + y;

implementation plus(x: int, y: int) returns (z: int)
{
start:
  assume z == 3;
  return;  // ERROR: postcondition possibly violated
}

implementation plus(x: int, y: int) returns (z: int)
{
start:
  z := x + y;
  return;
}

implementation plus(x: int, y: int) returns (z: int)
{
start:
  z := x + y;
  z := 0 + z;
  return;
}

procedure plus2(x: int, y: int) returns (z: int)
  ensures z == x + y;
{
start:
  z := x + y;
  return;
}

procedure or(x: int, y: int, a: int, b: int) returns (z: int)
  requires a == b;
{
var t: bool;
start:
  t := (x < y || x > y || x == y || x != y) && a >= b && a <= b;
  assert (x < y || x > y || x == y || x != y) && a >= b && a <= b;
  assert t;
  return;
}

procedure less(x: int, y: int) returns (z: bool);
  requires x < y;
  ensures z == (x < y);

implementation less(x: int, y: int) returns (z: bool)
{
start:
  z := x < y;
  return;
}

implementation less(x: int, y: int) returns (z: bool)
{
start:
  goto yes, no;
yes:
  assume x < y;
  z := true;
  return;
no:
  assume !(x < y);
  z := false;
  return;
}

implementation less(x: int, y: int) returns (z: bool)
{
start:
  goto yes, no;
yes:
  assume x < y;
  z := true;
  return;
no:
  assume x >= y;
  z := false;
  return;
}

procedure LESS(x: int, y: int) returns (z: bool);
  requires x < y;
  ensures z <==> (x < y);

implementation LESS(x: int, y: int) returns (z: bool)
{
start:
  z := x < y;
  return;
}

implementation LESS(x: int, y: int) returns (z: bool)
{
start:
  goto yes, no;
yes:
  assume x < y;
  z := true;
  return;
no:
  assume !(x < y);
  z := false;
  return;
}

implementation LESS(x: int, y: int) returns (z: bool)
{
start:
  goto yes, no;
yes:
  assume x < y;
  z := true;
  return;
no:
  assume x >= y;
  z := false;
  return;
}

procedure Assignments()
{
  var b: bool;
  var c: bool;
  var d: bool;
  var x: bool, y: bool;

  entry:
    b := c || d;
    b := c && d;
    x := c <==> d;
    y := c ==> d;
    assert x ==> y;
    return;
}