mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
hide new datatype plugin
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
09386e43e3
commit
a3dba5b2f9
24 changed files with 211 additions and 191 deletions
|
@ -88,8 +88,8 @@ expr * datatype_factory::get_almost_fresh_value(sort * s) {
|
|||
// Traverse constructors, and try to invoke get_fresh_value of one of the arguments (if the argument is not a sibling datatype of s).
|
||||
// If the argumet is a sibling datatype of s, then
|
||||
// use get_last_fresh_value.
|
||||
ptr_vector<func_decl> const * constructors = m_util.get_datatype_constructors(s);
|
||||
for (func_decl * constructor : *constructors) {
|
||||
ptr_vector<func_decl> const & constructors = m_util.get_datatype_constructors(s);
|
||||
for (func_decl * constructor : constructors) {
|
||||
expr_ref_vector args(m_manager);
|
||||
bool found_fresh_arg = false;
|
||||
bool recursive = false;
|
||||
|
@ -151,8 +151,8 @@ expr * datatype_factory::get_fresh_value(sort * s) {
|
|||
// Traverse constructors, and try to invoke get_fresh_value of one of the
|
||||
// arguments (if the argument is not a sibling datatype of s).
|
||||
// Two datatypes are siblings if they were defined together in the same mutually recursive definition.
|
||||
ptr_vector<func_decl> const * constructors = m_util.get_datatype_constructors(s);
|
||||
for (func_decl * constructor : *constructors) {
|
||||
ptr_vector<func_decl> const & constructors = m_util.get_datatype_constructors(s);
|
||||
for (func_decl * constructor : constructors) {
|
||||
expr_ref_vector args(m_manager);
|
||||
bool found_fresh_arg = false;
|
||||
unsigned num = constructor->get_arity();
|
||||
|
@ -189,8 +189,8 @@ expr * datatype_factory::get_fresh_value(sort * s) {
|
|||
while(true) {
|
||||
++num_iterations;
|
||||
TRACE("datatype_factory", tout << mk_pp(get_last_fresh_value(s), m_manager) << "\n";);
|
||||
ptr_vector<func_decl> const * constructors = m_util.get_datatype_constructors(s);
|
||||
for (func_decl * constructor : *constructors) {
|
||||
ptr_vector<func_decl> const & constructors = m_util.get_datatype_constructors(s);
|
||||
for (func_decl * constructor : constructors) {
|
||||
expr_ref_vector args(m_manager);
|
||||
bool found_sibling = false;
|
||||
unsigned num = constructor->get_arity();
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace smt {
|
|||
// simple
|
||||
}
|
||||
else if (data.is_datatype(s)) {
|
||||
ptr_vector<func_decl> const& cs = *data.get_datatype_constructors(s);
|
||||
ptr_vector<func_decl> const& cs = data.get_datatype_constructors(s);
|
||||
for (unsigned i = 0; i < cs.size(); ++i) {
|
||||
func_decl* f = cs[i];
|
||||
for (unsigned j = 0; j < f->get_arity(); ++j) {
|
||||
|
|
|
@ -97,12 +97,9 @@ namespace smt {
|
|||
SASSERT(m_util.is_datatype(get_manager().get_sort(n->get_owner())));
|
||||
ast_manager & m = get_manager();
|
||||
ptr_vector<expr> args;
|
||||
ptr_vector<func_decl> const * accessors = m_util.get_constructor_accessors(c);
|
||||
SASSERT(c->get_arity() == accessors->size());
|
||||
ptr_vector<func_decl>::const_iterator it = accessors->begin();
|
||||
ptr_vector<func_decl>::const_iterator end = accessors->end();
|
||||
for (; it != end; ++it) {
|
||||
func_decl * d = *it;
|
||||
ptr_vector<func_decl> const & accessors = m_util.get_constructor_accessors(c);
|
||||
SASSERT(c->get_arity() == accessors.size());
|
||||
for (func_decl * d : accessors) {
|
||||
SASSERT(d->get_arity() == 1);
|
||||
expr * acc = m.mk_app(d, n->get_owner());
|
||||
args.push_back(acc);
|
||||
|
@ -123,15 +120,14 @@ namespace smt {
|
|||
SASSERT(is_constructor(n));
|
||||
ast_manager & m = get_manager();
|
||||
func_decl * d = n->get_decl();
|
||||
ptr_vector<func_decl> const * accessors = m_util.get_constructor_accessors(d);
|
||||
SASSERT(n->get_num_args() == accessors->size());
|
||||
ptr_vector<func_decl>::const_iterator it = accessors->begin();
|
||||
ptr_vector<func_decl>::const_iterator end = accessors->end();
|
||||
for (unsigned i = 0; it != end; ++it, ++i) {
|
||||
func_decl * acc = *it;
|
||||
ptr_vector<func_decl> const & accessors = m_util.get_constructor_accessors(d);
|
||||
SASSERT(n->get_num_args() == accessors.size());
|
||||
unsigned i = 0;
|
||||
for (func_decl * acc : accessors) {
|
||||
app * acc_app = m.mk_app(acc, n->get_owner());
|
||||
enode * arg = n->get_arg(i);
|
||||
assert_eq_axiom(arg, acc_app, null_literal);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,15 +168,12 @@ namespace smt {
|
|||
func_decl * acc = to_func_decl(upd->get_parameter(0).get_ast());
|
||||
func_decl * con = m_util.get_accessor_constructor(acc);
|
||||
func_decl * rec = m_util.get_constructor_recognizer(con);
|
||||
ptr_vector<func_decl> const * accessors = m_util.get_constructor_accessors(con);
|
||||
ptr_vector<func_decl>::const_iterator it = accessors->begin();
|
||||
ptr_vector<func_decl>::const_iterator end = accessors->end();
|
||||
ptr_vector<func_decl> const & accessors = m_util.get_constructor_accessors(con);
|
||||
app_ref rec_app(m.mk_app(rec, arg1), m);
|
||||
ctx.internalize(rec_app, false);
|
||||
literal is_con(ctx.get_bool_var(rec_app));
|
||||
for (; it != end; ++it) {
|
||||
for (func_decl* acc1 : accessors) {
|
||||
enode* arg;
|
||||
func_decl * acc1 = *it;
|
||||
if (acc1 == acc) {
|
||||
arg = n->get_arg(1);
|
||||
}
|
||||
|
@ -215,7 +208,7 @@ namespace smt {
|
|||
ast_manager & m = get_manager();
|
||||
sort * s = m.get_sort(n->get_owner());
|
||||
if (m_util.get_datatype_num_constructors(s) == 1) {
|
||||
func_decl * c = m_util.get_datatype_constructors(s)->get(0);
|
||||
func_decl * c = m_util.get_datatype_constructors(s)[0];
|
||||
assert_is_constructor_axiom(n, c, null_literal);
|
||||
}
|
||||
else {
|
||||
|
@ -716,8 +709,8 @@ namespace smt {
|
|||
enode * r = d->m_recognizers[unassigned_idx];
|
||||
literal consequent;
|
||||
if (!r) {
|
||||
ptr_vector<func_decl> const * constructors = m_util.get_datatype_constructors(dt);
|
||||
func_decl * rec = m_util.get_constructor_recognizer(constructors->get(unassigned_idx));
|
||||
ptr_vector<func_decl> const & constructors = m_util.get_datatype_constructors(dt);
|
||||
func_decl * rec = m_util.get_constructor_recognizer(constructors[unassigned_idx]);
|
||||
app * rec_app = get_manager().mk_app(rec, n->get_owner());
|
||||
ctx.internalize(rec_app, false);
|
||||
consequent = literal(ctx.get_bool_var(rec_app));
|
||||
|
@ -781,9 +774,9 @@ namespace smt {
|
|||
for (unsigned idx = 0; it != end; ++it, ++idx) {
|
||||
enode * curr = *it;
|
||||
if (curr == 0) {
|
||||
ptr_vector<func_decl> const * constructors = m_util.get_datatype_constructors(s);
|
||||
ptr_vector<func_decl> const & constructors = m_util.get_datatype_constructors(s);
|
||||
// found empty slot...
|
||||
r = m_util.get_constructor_recognizer(constructors->get(idx));
|
||||
r = m_util.get_constructor_recognizer(constructors[idx]);
|
||||
break;
|
||||
}
|
||||
else if (!ctx.is_relevant(curr)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue