@@ -64,17 +64,30 @@ namespace recfun {
64
64
m_decl = m.mk_func_decl (s, arity, domain, range, info);
65
65
}
66
66
67
+ bool def::contains_def (util& u, expr * e) {
68
+ struct def_find_p : public i_expr_pred {
69
+ util& u;
70
+ def_find_p (util& u): u(u) {}
71
+ bool operator ()(expr* a) override { return is_app (a) && u.is_defined (to_app (a)->get_decl ()); }
72
+ };
73
+ def_find_p p (u);
74
+ check_pred cp (p, m, false );
75
+ return cp (e);
76
+ }
77
+
67
78
// does `e` contain any `ite` construct?
68
- bool def::contains_ite (expr * e) {
79
+ bool def::contains_ite (util& u, expr * e) {
69
80
struct ite_find_p : public i_expr_pred {
70
81
ast_manager & m;
71
- ite_find_p (ast_manager & m) : m(m) {}
72
- bool operator ()(expr * e) override { return m.is_ite (e); }
82
+ def& d;
83
+ util& u;
84
+ ite_find_p (ast_manager & m, def& d, util& u) : m(m), d(d), u(u) {}
85
+ bool operator ()(expr * e) override { return m.is_ite (e) && d.contains_def (u, e); }
73
86
};
74
87
// ignore ites under quantifiers.
75
88
// this is redundant as the code
76
89
// that unfolds ites uses quantifier-free portion.
77
- ite_find_p p (m);
90
+ ite_find_p p (m, * this , u );
78
91
check_pred cp (p, m, false );
79
92
return cp (e);
80
93
}
@@ -189,7 +202,8 @@ namespace recfun {
189
202
190
203
191
204
// Compute a set of cases, given the RHS
192
- void def::compute_cases (replace& subst,
205
+ void def::compute_cases (util& u,
206
+ replace& subst,
193
207
is_immediate_pred & is_i,
194
208
unsigned n_vars, var *const * vars, expr* rhs)
195
209
{
@@ -209,7 +223,7 @@ namespace recfun {
209
223
expr_ref_vector conditions (m);
210
224
211
225
// is the function a macro (unconditional body)?
212
- if (n_vars == 0 || !contains_ite (rhs)) {
226
+ if (n_vars == 0 || !contains_ite (u, rhs)) {
213
227
// constant function or trivial control flow, only one (dummy) case
214
228
add_case (name, 0 , conditions, rhs);
215
229
return ;
@@ -248,7 +262,7 @@ namespace recfun {
248
262
else if (is_app (e)) {
249
263
// explore arguments
250
264
for (expr * arg : *to_app (e)) {
251
- if (contains_ite (arg)) {
265
+ if (contains_ite (u, arg)) {
252
266
stack.push_back (arg);
253
267
}
254
268
}
@@ -361,7 +375,7 @@ namespace recfun {
361
375
SASSERT (n_vars == d->get_arity ());
362
376
363
377
is_imm_pred is_i (*u);
364
- d->compute_cases (r, is_i, n_vars, vars, rhs);
378
+ d->compute_cases (*u, r, is_i, n_vars, vars, rhs);
365
379
}
366
380
367
381
namespace decl {
0 commit comments