@@ -77,50 +77,50 @@ namespace {
77
77
};
78
78
// rewrite all occurrences of (as const arr c) to (as const arr v) where v = m_eval(c)
79
79
struct app_const_arr_rewriter : public default_rewriter_cfg {
80
- ast_manager &m;
81
- array_util m_arr;
82
- datatype_util m_dt_util;
83
- model_evaluator m_eval;
84
- expr_ref val;
85
-
86
- app_const_arr_rewriter (ast_manager& man, model& mdl): m(man), m_arr(m), m_dt_util(m), m_eval(mdl), val(m) {
87
- m_eval.set_model_completion (false );
80
+ ast_manager &m;
81
+ array_util m_arr;
82
+ datatype_util m_dt_util;
83
+ model_evaluator m_eval;
84
+ expr_ref val;
85
+
86
+ app_const_arr_rewriter (ast_manager& man, model& mdl): m(man), m_arr(m), m_dt_util(m), m_eval(mdl), val(m) {
87
+ m_eval.set_model_completion (false );
88
+ }
89
+ br_status reduce_app (func_decl *f, unsigned num, expr *const *args,
90
+ expr_ref &result, proof_ref &result_pr) {
91
+ if (m_arr.is_const (f) && !m.is_value (args[0 ])) {
92
+ val = m_eval (args[0 ]);
93
+ SASSERT (m.is_value (val));
94
+ result = m_arr.mk_const_array (f->get_range (), val);
95
+ return BR_DONE;
88
96
}
89
- br_status reduce_app (func_decl *f, unsigned num, expr *const *args,
90
- expr_ref &result, proof_ref &result_pr) {
91
- if (m_arr.is_const (f) && !m.is_value (args[0 ])) {
92
- val = m_eval (args[0 ]);
93
- SASSERT (m.is_value (val));
94
- result = m_arr.mk_const_array (f->get_range (), val);
95
- return BR_DONE;
97
+ if (m_dt_util.is_constructor (f)) {
98
+ // cons(head(x), tail(x)) --> x
99
+ ptr_vector<func_decl> const *accessors =
100
+ m_dt_util.get_constructor_accessors (f);
101
+
102
+ SASSERT (num == accessors->size ());
103
+ // -- all accessors must have exactly one argument
104
+ if (any_of (*accessors, [&](const func_decl* acc) { return acc->get_arity () != 1 ; })) {
105
+ return BR_FAILED;
96
106
}
97
- if (m_dt_util.is_constructor (f)) {
98
- // cons(head(x), tail(x)) --> x
99
- ptr_vector<func_decl> const *accessors =
100
- m_dt_util.get_constructor_accessors (f);
101
-
102
- SASSERT (num == accessors->size ());
103
- // -- all accessors must have exactly one argument
104
- if (any_of (*accessors, [&](const func_decl* acc) { return acc->get_arity () != 1 ; })) {
105
- return BR_FAILED;
107
+
108
+ if (num >= 1 && is_app (args[0 ]) && to_app (args[0 ])->get_decl () == accessors->get (0 )) {
109
+ bool is_all = true ;
110
+ expr* t = to_app (args[0 ])->get_arg (0 );
111
+ for (unsigned i = 1 ; i < num && is_all; ++i) {
112
+ is_all &= (is_app (args[i]) &&
113
+ to_app (args[i])->get_decl () == accessors->get (i) &&
114
+ to_app (args[i])->get_arg (0 ) == t);
106
115
}
107
-
108
- if (num >= 1 && is_app (args[0 ]) && to_app (args[0 ])->get_decl () == accessors->get (0 )) {
109
- bool is_all = true ;
110
- expr* t = to_app (args[0 ])->get_arg (0 );
111
- for (unsigned i = 1 ; i < num && is_all; ++i) {
112
- is_all &= (is_app (args[i]) &&
113
- to_app (args[i])->get_decl () == accessors->get (i) &&
114
- to_app (args[i])->get_arg (0 ) == t);
115
- }
116
- if (is_all) {
117
- result = t;
118
- return BR_DONE;
119
- }
116
+ if (is_all) {
117
+ result = t;
118
+ return BR_DONE;
120
119
}
121
120
}
122
- return BR_FAILED;
123
121
}
122
+ return BR_FAILED;
123
+ }
124
124
};
125
125
}
126
126
0 commit comments