3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 17:45:32 +00:00

remove incorrect and inefficient default model conversion

This commit is contained in:
Nikolaj Bjorner 2021-07-15 18:47:25 +02:00
parent 0e066fef1f
commit c7a7d40a8f
8 changed files with 6 additions and 90 deletions

View file

@ -139,68 +139,6 @@ void generic_model_converter::set_env(ast_pp_util* visitor) {
}
}
struct min_app_idx_proc {
unsigned m_min;
obj_map<func_decl, unsigned>& m_idxs;
min_app_idx_proc(obj_map<func_decl, unsigned>& idxs) : m_min(UINT_MAX), m_idxs(idxs) {}
void operator()(app * n) {
unsigned idx;
if (m_idxs.find(n->get_decl(), idx)) {
m_min = std::min(m_min, idx);
}
}
void operator()(var * n) {}
void operator()(quantifier * n) {}
};
void generic_model_converter::operator()(expr_ref& fml) {
min_app_idx_proc min_proc(m_first_idx);
for_each_expr(min_proc, fml);
unsigned min_idx = min_proc.m_min;
if (min_idx == UINT_MAX) return;
expr_ref_vector fmls(m);
fmls.push_back(fml);
for (unsigned i = m_entries.size(); i-- > min_idx;) {
entry const& e = m_entries[i];
if (e.m_instruction != instruction::ADD) {
continue;
}
unsigned arity = e.m_f->get_arity();
if (arity == 0) {
fmls.push_back(simplify_def(e));
}
else {
expr_ref_vector args(m);
sort_ref_vector sorts(m);
svector<symbol> names;
for (unsigned i = 0; i < arity; ++i) {
sorts.push_back(e.m_f->get_domain(i));
names.push_back(symbol(i));
args.push_back(m.mk_var(i, sorts.back()));
}
// TBD: check if order is correct with respect to quantifier binding ordering
expr_ref lhs(m.mk_app(e.m_f, arity, args.data()), m);
expr_ref body(m.mk_eq(lhs, e.m_def), m);
fmls.push_back(m.mk_forall(arity, sorts.data(), names.data(), body));
}
if (m_first_idx[e.m_f] == i) {
m_first_idx.remove(e.m_f);
}
}
unsigned j = min_idx;
for (unsigned i = min_idx; i < m_entries.size(); ++i) {
entry& e = m_entries[i];
if (e.m_instruction == instruction::HIDE) {
if (i != j) {
m_entries[j] = e;
}
++j;
}
}
m_entries.shrink(j);
fml = mk_and(fmls);
}
void generic_model_converter::get_units(obj_map<expr, bool>& units) {
th_rewriter rw(m);
expr_safe_replace rep(m);

View file

@ -54,6 +54,8 @@ public:
void operator()(model_ref & md) override;
void operator()(expr_ref& fml) override { UNREACHABLE(); }
void cancel() override {}
void display(std::ostream & out) override;
@ -64,8 +66,6 @@ public:
void set_env(ast_pp_util* visitor) override;
void operator()(expr_ref& fml) override;
void get_units(obj_map<expr, bool>& units) override;
};

View file

@ -169,10 +169,6 @@ void horn_subsume_model_converter::add_default_false_interpretation(expr* e, mod
}
void horn_subsume_model_converter::operator()(expr_ref& fml) {
NOT_IMPLEMENTED_YET();
}
void horn_subsume_model_converter::operator()(model_ref& mr) {
func_decl_ref pred(m);

View file

@ -72,8 +72,6 @@ public:
void operator()(model_ref& _m) override;
void operator()(expr_ref& fml) override;
model_converter * translate(ast_translation & translator) override;
ast_manager& get_manager() { return m; }

View file

@ -76,6 +76,8 @@ public:
virtual void operator()(model_ref & m) = 0;
virtual void operator()(labels_vec & r) {}
virtual void operator()(expr_ref& fml) { UNREACHABLE(); }
virtual model_converter * translate(ast_translation & translator) = 0;
@ -86,7 +88,6 @@ public:
The operator has as side effect of adding definitions as assertions to the
formula and removing these definitions from the model converter.
*/
virtual void operator()(expr_ref& formula) { UNREACHABLE(); }
virtual void get_units(obj_map<expr, bool>& fmls) { UNREACHABLE(); }
};