mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
prepare symbols to be more abstract, update mbi, delay initialize some modules
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
74d3493d74
commit
78a1736bd2
25 changed files with 286 additions and 357 deletions
|
@ -762,7 +762,7 @@ namespace datatype {
|
|||
}
|
||||
|
||||
bool util::is_declared(sort* s) const {
|
||||
return m_plugin->is_declared(s);
|
||||
return plugin().is_declared(s);
|
||||
}
|
||||
|
||||
void util::compute_datatype_size_functions(svector<symbol> const& names) {
|
||||
|
@ -918,7 +918,7 @@ namespace datatype {
|
|||
}
|
||||
|
||||
def const& util::get_def(sort* s) const {
|
||||
return m_plugin->get_def(s);
|
||||
return plugin().get_def(s);
|
||||
}
|
||||
|
||||
void util::get_subsorts(sort* s, ptr_vector<sort>& sorts) const {
|
||||
|
@ -933,13 +933,25 @@ namespace datatype {
|
|||
|
||||
util::util(ast_manager & m):
|
||||
m(m),
|
||||
m_family_id(m.mk_family_id("datatype")),
|
||||
m_family_id(null_family_id),
|
||||
m_plugin(nullptr),
|
||||
m_asts(m),
|
||||
m_start(0) {
|
||||
m_plugin = dynamic_cast<decl::plugin*>(m.get_plugin(m_family_id));
|
||||
SASSERT(m_plugin);
|
||||
}
|
||||
|
||||
|
||||
decl::plugin& util::plugin() const {
|
||||
if (!m_plugin) m_plugin = dynamic_cast<decl::plugin*>(m.get_plugin(fid()));
|
||||
SASSERT(m_plugin);
|
||||
return *m_plugin;
|
||||
}
|
||||
|
||||
family_id util::fid() const {
|
||||
if (m_family_id == null_family_id) m_family_id = m.get_family_id("datatype");
|
||||
return m_family_id;
|
||||
}
|
||||
|
||||
|
||||
util::~util() {
|
||||
std::for_each(m_vectors.begin(), m_vectors.end(), delete_proc<ptr_vector<func_decl> >());
|
||||
}
|
||||
|
@ -994,7 +1006,7 @@ namespace datatype {
|
|||
SASSERT(is_constructor(con));
|
||||
sort * datatype = con->get_range();
|
||||
parameter ps[1] = { parameter(con)};
|
||||
return m.mk_func_decl(m_family_id, OP_DT_IS, 1, ps, 1, &datatype);
|
||||
return m.mk_func_decl(fid(), OP_DT_IS, 1, ps, 1, &datatype);
|
||||
}
|
||||
|
||||
func_decl * util::get_constructor_recognizer(func_decl * con) {
|
||||
|
@ -1011,7 +1023,7 @@ namespace datatype {
|
|||
}
|
||||
}
|
||||
parameter ps[2] = { parameter(con), parameter(r) };
|
||||
d = m.mk_func_decl(m_family_id, OP_DT_RECOGNISER, 2, ps, 1, &datatype);
|
||||
d = m.mk_func_decl(fid(), OP_DT_RECOGNISER, 2, ps, 1, &datatype);
|
||||
SASSERT(d);
|
||||
m_asts.push_back(con);
|
||||
m_asts.push_back(d);
|
||||
|
@ -1226,7 +1238,7 @@ namespace datatype {
|
|||
while (!todo.empty()) {
|
||||
sort* s = todo.back();
|
||||
todo.pop_back();
|
||||
defs.push_back(&m_plugin->get_def(s->get_name()));
|
||||
defs.push_back(&plugin().get_def(s->get_name()));
|
||||
def const& d = get_def(s);
|
||||
for (constructor* c : d) {
|
||||
for (accessor* a : *c) {
|
||||
|
@ -1281,7 +1293,7 @@ namespace datatype {
|
|||
mk_constructor_decl(symbol("nil"), symbol("is_nil"), 0, nullptr),
|
||||
mk_constructor_decl(symbol("cons"), symbol("is_cons"), 2, head_tail)
|
||||
};
|
||||
decl::plugin& p = *get_plugin();
|
||||
decl::plugin& p = plugin();
|
||||
|
||||
sort_ref_vector sorts(m);
|
||||
datatype_decl * decl = mk_datatype_decl(*this, name, 0, nullptr, 2, constrs);
|
||||
|
@ -1313,7 +1325,7 @@ namespace datatype {
|
|||
auto * p = mk_constructor_decl(symbol("pair"), symbol("is-pair"), 2, accd);
|
||||
auto* dt = mk_datatype_decl(*this, symbol("pair"), 0, nullptr, 1, &p);
|
||||
sort_ref_vector sorts(m);
|
||||
VERIFY(get_plugin()->mk_datatypes(1, &dt, 0, nullptr, sorts));
|
||||
VERIFY(plugin().mk_datatypes(1, &dt, 0, nullptr, sorts));
|
||||
del_datatype_decl(dt);
|
||||
sort* s = sorts.get(0);
|
||||
ptr_vector<func_decl> const& cnstrs = *get_datatype_constructors(s);
|
||||
|
@ -1335,7 +1347,7 @@ namespace datatype {
|
|||
auto* tuple = mk_constructor_decl(name, test, accd.size(), accd.c_ptr());
|
||||
auto* dt = mk_datatype_decl(*this, name, 0, nullptr, 1, &tuple);
|
||||
sort_ref_vector sorts(m);
|
||||
VERIFY(get_plugin()->mk_datatypes(1, &dt, 0, nullptr, sorts));
|
||||
VERIFY(plugin().mk_datatypes(1, &dt, 0, nullptr, sorts));
|
||||
del_datatype_decl(dt);
|
||||
sort* s = sorts.get(0);
|
||||
ptr_vector<func_decl> const& cnstrs = *get_datatype_constructors(s);
|
||||
|
@ -1349,8 +1361,8 @@ namespace datatype {
|
|||
}
|
||||
|
||||
datatype_decl * mk_datatype_decl(datatype_util& u, symbol const & n, unsigned num_params, sort*const* params, unsigned num_constructors, constructor_decl * const * cs) {
|
||||
datatype::decl::plugin* p = u.get_plugin();
|
||||
datatype::def* d = p->mk(n, num_params, params);
|
||||
datatype::decl::plugin& p = u.plugin();
|
||||
datatype::def* d = p.mk(n, num_params, params);
|
||||
for (unsigned i = 0; i < num_constructors; ++i) {
|
||||
d->add(cs[i]);
|
||||
}
|
||||
|
|
|
@ -290,9 +290,11 @@ namespace datatype {
|
|||
|
||||
class util {
|
||||
ast_manager & m;
|
||||
family_id m_family_id;
|
||||
mutable family_id m_family_id;
|
||||
mutable decl::plugin* m_plugin;
|
||||
typedef std::pair<func_decl*, unsigned> cnstr_depth;
|
||||
|
||||
family_id fid() const;
|
||||
|
||||
obj_map<sort, ptr_vector<func_decl> *> m_datatype2constructors;
|
||||
obj_map<sort, cnstr_depth> m_datatype2nonrec_constructor;
|
||||
|
@ -320,7 +322,7 @@ namespace datatype {
|
|||
bool is_well_founded(unsigned num_types, sort* const* sorts);
|
||||
bool is_covariant(unsigned num_types, sort* const* sorts) const;
|
||||
bool is_covariant(ast_mark& mark, ptr_vector<sort>& subsorts, sort* s) const;
|
||||
def& get_def(symbol const& s) { return m_plugin->get_def(s); }
|
||||
def& get_def(symbol const& s) { return plugin().get_def(s); }
|
||||
void get_subsorts(sort* s, ptr_vector<sort>& sorts) const;
|
||||
|
||||
public:
|
||||
|
@ -328,23 +330,23 @@ namespace datatype {
|
|||
~util();
|
||||
ast_manager & get_manager() const { return m; }
|
||||
// sort * mk_datatype_sort(symbol const& name, unsigned n, sort* const* params);
|
||||
bool is_datatype(sort const* s) const { return is_sort_of(s, m_family_id, DATATYPE_SORT); }
|
||||
bool is_datatype(sort const* s) const { return is_sort_of(s, fid(), DATATYPE_SORT); }
|
||||
bool is_enum_sort(sort* s);
|
||||
bool is_recursive(sort * ty);
|
||||
bool is_constructor(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_CONSTRUCTOR); }
|
||||
bool is_constructor(func_decl * f) const { return is_decl_of(f, fid(), OP_DT_CONSTRUCTOR); }
|
||||
bool is_recognizer(func_decl * f) const { return is_recognizer0(f) || is_is(f); }
|
||||
bool is_recognizer0(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_RECOGNISER); }
|
||||
bool is_is(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_IS); }
|
||||
bool is_accessor(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_ACCESSOR); }
|
||||
bool is_update_field(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_UPDATE_FIELD); }
|
||||
bool is_constructor(app * f) const { return is_app_of(f, m_family_id, OP_DT_CONSTRUCTOR); }
|
||||
bool is_recognizer0(func_decl * f) const { return is_decl_of(f, fid(), OP_DT_RECOGNISER); }
|
||||
bool is_is(func_decl * f) const { return is_decl_of(f, fid(), OP_DT_IS); }
|
||||
bool is_accessor(func_decl * f) const { return is_decl_of(f, fid(), OP_DT_ACCESSOR); }
|
||||
bool is_update_field(func_decl * f) const { return is_decl_of(f, fid(), OP_DT_UPDATE_FIELD); }
|
||||
bool is_constructor(app * f) const { return is_app_of(f, fid(), OP_DT_CONSTRUCTOR); }
|
||||
bool is_constructor(expr* e) const { return is_app(e) && is_constructor(to_app(e)); }
|
||||
bool is_recognizer0(app * f) const { return is_app_of(f, m_family_id, OP_DT_RECOGNISER);}
|
||||
bool is_is(app * f) const { return is_app_of(f, m_family_id, OP_DT_IS);}
|
||||
bool is_recognizer0(app * f) const { return is_app_of(f, fid(), OP_DT_RECOGNISER);}
|
||||
bool is_is(app * f) const { return is_app_of(f, fid(), OP_DT_IS);}
|
||||
bool is_is(expr * e) const { return is_app(e) && is_is(to_app(e)); }
|
||||
bool is_recognizer(app * f) const { return is_recognizer0(f) || is_is(f); }
|
||||
bool is_accessor(app * f) const { return is_app_of(f, m_family_id, OP_DT_ACCESSOR); }
|
||||
bool is_update_field(app * f) const { return is_app_of(f, m_family_id, OP_DT_UPDATE_FIELD); }
|
||||
bool is_accessor(app * f) const { return is_app_of(f, fid(), OP_DT_ACCESSOR); }
|
||||
bool is_update_field(app * f) const { return is_app_of(f, fid(), OP_DT_UPDATE_FIELD); }
|
||||
app* mk_is(func_decl * c, expr *f);
|
||||
ptr_vector<func_decl> const * get_datatype_constructors(sort * ty);
|
||||
unsigned get_datatype_num_constructors(sort * ty);
|
||||
|
@ -357,8 +359,9 @@ namespace datatype {
|
|||
func_decl * get_accessor_constructor(func_decl * accessor);
|
||||
func_decl * get_recognizer_constructor(func_decl * recognizer) const;
|
||||
func_decl * get_update_accessor(func_decl * update) const;
|
||||
bool has_nested_arrays() const { return m_plugin->has_nested_arrays(); }
|
||||
family_id get_family_id() const { return m_family_id; }
|
||||
bool has_nested_arrays() const { return plugin().has_nested_arrays(); }
|
||||
family_id get_family_id() const { return fid(); }
|
||||
decl::plugin& plugin() const;
|
||||
bool are_siblings(sort * s1, sort * s2);
|
||||
bool is_func_decl(op_kind k, unsigned num_params, parameter const* params, func_decl* f);
|
||||
bool is_constructor_of(unsigned num_params, parameter const* params, func_decl* f);
|
||||
|
@ -369,7 +372,6 @@ namespace datatype {
|
|||
sort_ref_vector datatype_params(sort * s) const;
|
||||
unsigned get_constructor_idx(func_decl * f) const;
|
||||
unsigned get_recognizer_constructor_idx(func_decl * f) const;
|
||||
decl::plugin* get_plugin() { return m_plugin; }
|
||||
void get_defs(sort* s, ptr_vector<def>& defs);
|
||||
def const& get_def(sort* s) const;
|
||||
sort_ref mk_list_datatype(sort* elem, symbol const& name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue