mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 03:15:50 +00:00
recursive function definitions; combine model-building functionality
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
6fa2338edc
commit
7c6540e18f
19 changed files with 129 additions and 173 deletions
|
@ -29,7 +29,6 @@ Revision History:
|
|||
|
||||
proto_model::proto_model(ast_manager & m, simplifier & s, params_ref const & p):
|
||||
model_core(m),
|
||||
m_asts(m),
|
||||
m_simplifier(s),
|
||||
m_afid(m.mk_family_id(symbol("array"))) {
|
||||
register_factory(alloc(basic_factory, m));
|
||||
|
@ -39,45 +38,11 @@ proto_model::proto_model(ast_manager & m, simplifier & s, params_ref const & p):
|
|||
m_model_partial = model_params(p).partial();
|
||||
}
|
||||
|
||||
void proto_model::reset_finterp() {
|
||||
decl2finterp::iterator it = m_finterp.begin();
|
||||
decl2finterp::iterator end = m_finterp.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->m_value);
|
||||
}
|
||||
}
|
||||
|
||||
proto_model::~proto_model() {
|
||||
reset_finterp();
|
||||
}
|
||||
|
||||
void proto_model::register_decl(func_decl * d, expr * v) {
|
||||
SASSERT(d->get_arity() == 0);
|
||||
if (m_interp.contains(d)) {
|
||||
DEBUG_CODE({
|
||||
expr * old_v = 0;
|
||||
m_interp.find(d, old_v);
|
||||
SASSERT(old_v == v);
|
||||
});
|
||||
return;
|
||||
}
|
||||
SASSERT(!m_interp.contains(d));
|
||||
m_decls.push_back(d);
|
||||
m_asts.push_back(d);
|
||||
m_asts.push_back(v);
|
||||
m_interp.insert(d, v);
|
||||
m_const_decls.push_back(d);
|
||||
}
|
||||
|
||||
void proto_model::register_decl(func_decl * d, func_interp * fi, bool aux) {
|
||||
SASSERT(d->get_arity() > 0);
|
||||
SASSERT(!m_finterp.contains(d));
|
||||
m_decls.push_back(d);
|
||||
m_asts.push_back(d);
|
||||
m_finterp.insert(d, fi);
|
||||
m_func_decls.push_back(d);
|
||||
if (aux)
|
||||
m_aux_decls.insert(d);
|
||||
void proto_model::register_aux_decl(func_decl * d, func_interp * fi) {
|
||||
model_core::register_decl(d, fi);
|
||||
m_aux_decls.insert(d);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -486,6 +451,7 @@ void proto_model::cleanup() {
|
|||
m_finterp.find(faux, fi);
|
||||
SASSERT(fi != 0);
|
||||
m_finterp.erase(faux);
|
||||
m_manager.dec_ref(faux);
|
||||
dealloc(fi);
|
||||
}
|
||||
}
|
||||
|
@ -666,20 +632,16 @@ model * proto_model::mk_model() {
|
|||
decl2finterp::iterator end2 = m_finterp.end();
|
||||
for (; it2 != end2; ++it2) {
|
||||
m->register_decl(it2->m_key, it2->m_value);
|
||||
m_manager.dec_ref(it2->m_key);
|
||||
}
|
||||
|
||||
m_finterp.reset(); // m took the ownership of the func_interp's
|
||||
|
||||
unsigned sz = get_num_uninterpreted_sorts();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
sort * s = get_uninterpreted_sort(i);
|
||||
TRACE("proto_model", tout << "copying uninterpreted sorts...\n" << mk_pp(s, m_manager) << "\n";);
|
||||
ptr_buffer<expr> buf;
|
||||
obj_hashtable<expr> const & u = get_known_universe(s);
|
||||
obj_hashtable<expr>::iterator it = u.begin();
|
||||
obj_hashtable<expr>::iterator end = u.end();
|
||||
for (; it != end; ++it) {
|
||||
buf.push_back(*it);
|
||||
}
|
||||
ptr_vector<expr> const& buf = get_universe(s);
|
||||
m->register_usort(s, buf.size(), buf.c_ptr());
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ Revision History:
|
|||
#include"params.h"
|
||||
|
||||
class proto_model : public model_core {
|
||||
ast_ref_vector m_asts;
|
||||
plugin_manager<value_factory> m_factories;
|
||||
user_sort_factory * m_user_sort_factory;
|
||||
simplifier & m_simplifier;
|
||||
|
@ -48,8 +47,6 @@ class proto_model : public model_core {
|
|||
|
||||
bool m_model_partial;
|
||||
|
||||
void reset_finterp();
|
||||
|
||||
expr * mk_some_interp_for(func_decl * d);
|
||||
|
||||
// Invariant: m_decls subset m_func_decls union m_const_decls union union m_value_decls
|
||||
|
@ -63,7 +60,7 @@ class proto_model : public model_core {
|
|||
|
||||
public:
|
||||
proto_model(ast_manager & m, simplifier & s, params_ref const & p = params_ref());
|
||||
virtual ~proto_model();
|
||||
virtual ~proto_model() {}
|
||||
|
||||
void register_factory(value_factory * f) { m_factories.register_plugin(f); }
|
||||
|
||||
|
@ -73,7 +70,7 @@ public:
|
|||
|
||||
value_factory * get_factory(family_id fid);
|
||||
|
||||
expr * get_some_value(sort * s);
|
||||
virtual expr * get_some_value(sort * s);
|
||||
|
||||
bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2);
|
||||
|
||||
|
@ -84,8 +81,7 @@ public:
|
|||
//
|
||||
// Primitives for building models
|
||||
//
|
||||
void register_decl(func_decl * d, expr * v);
|
||||
void register_decl(func_decl * f, func_interp * fi, bool aux = false);
|
||||
void register_aux_decl(func_decl * f, func_interp * fi);
|
||||
void reregister_decl(func_decl * f, func_interp * new_fi, func_decl * f_aux);
|
||||
void compress();
|
||||
void cleanup();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue