@@ -24,12 +24,9 @@ static bool expr_eq(const exprt &expr1, const exprt &expr2)
24
24
// / To obtain the min value for the quantifier variable of the specified
25
25
// / forall/exists operator. The min variable is in the form of "!(var_expr >
26
26
// / constant)".
27
- static exprt
27
+ static optionalt<constant_exprt>
28
28
get_quantifier_var_min (const exprt &var_expr, const exprt &quantifier_expr)
29
29
{
30
- PRECONDITION (quantifier_expr.id () == ID_or || quantifier_expr.id () == ID_and);
31
-
32
- exprt res = false_exprt ();
33
30
if (quantifier_expr.id ()==ID_or)
34
31
{
35
32
/* *
@@ -45,11 +42,11 @@ get_quantifier_var_min(const exprt &var_expr, const exprt &quantifier_expr)
45
42
continue ;
46
43
if (expr_eq (var_expr, y.op0 ()) && y.op1 ().id ()==ID_constant)
47
44
{
48
- return y.op1 ();
45
+ return to_constant_expr ( y.op1 () );
49
46
}
50
47
}
51
48
}
52
- else
49
+ else if (quantifier_expr. id () == ID_and)
53
50
{
54
51
/* *
55
52
* The min variable
@@ -61,20 +58,19 @@ get_quantifier_var_min(const exprt &var_expr, const exprt &quantifier_expr)
61
58
continue ;
62
59
if (expr_eq (var_expr, x.op0 ()) && x.op1 ().id ()==ID_constant)
63
60
{
64
- return x.op1 ();
61
+ return to_constant_expr ( x.op1 () );
65
62
}
66
63
}
67
64
}
68
- return res;
65
+
66
+ return {};
69
67
}
70
68
71
69
// / To obtain the max value for the quantifier variable of the specified
72
70
// / forall/exists operator.
73
- static exprt
71
+ static optionalt<constant_exprt>
74
72
get_quantifier_var_max (const exprt &var_expr, const exprt &quantifier_expr)
75
73
{
76
- PRECONDITION (quantifier_expr.id () == ID_or || quantifier_expr.id () == ID_and);
77
- exprt res = false_exprt ();
78
74
if (quantifier_expr.id ()==ID_or)
79
75
{
80
76
/* *
@@ -97,8 +93,7 @@ get_quantifier_var_max(const exprt &var_expr, const exprt &quantifier_expr)
97
93
* maximum index as specified in the original code.
98
94
**/
99
95
over_i-=1 ;
100
- res=from_integer (over_i, x.op1 ().type ());
101
- return res;
96
+ return from_integer (over_i, x.op1 ().type ());
102
97
}
103
98
}
104
99
}
@@ -120,12 +115,12 @@ get_quantifier_var_max(const exprt &var_expr, const exprt &quantifier_expr)
120
115
const constant_exprt &over_expr = to_constant_expr (y.op1 ());
121
116
mp_integer over_i = numeric_cast_v<mp_integer>(over_expr);
122
117
over_i-=1 ;
123
- res=from_integer (over_i, y.op1 ().type ());
124
- return res;
118
+ return from_integer (over_i, y.op1 ().type ());
125
119
}
126
120
}
127
121
}
128
- return res;
122
+
123
+ return {};
129
124
}
130
125
131
126
static optionalt<exprt>
@@ -145,14 +140,14 @@ instantiate_quantifier(const quantifier_exprt &expr, const namespacet &ns)
145
140
return re;
146
141
}
147
142
148
- const exprt min_i = get_quantifier_var_min (var_expr, re);
149
- const exprt max_i = get_quantifier_var_max (var_expr, re);
143
+ const auto min_i = get_quantifier_var_min (var_expr, re);
144
+ const auto max_i = get_quantifier_var_max (var_expr, re);
150
145
151
- if (min_i.is_false () || max_i.is_false ())
146
+ if (! min_i.has_value () || ! max_i.has_value ())
152
147
return nullopt;
153
148
154
- mp_integer lb = numeric_cast_v<mp_integer>(to_constant_expr ( min_i));
155
- mp_integer ub = numeric_cast_v<mp_integer>(to_constant_expr ( max_i));
149
+ mp_integer lb = numeric_cast_v<mp_integer>(min_i. value ( ));
150
+ mp_integer ub = numeric_cast_v<mp_integer>(max_i. value ( ));
156
151
157
152
if (lb>ub)
158
153
return nullopt;
0 commit comments