3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

fix #2468, adding assignment phase heuristic

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-08-10 15:24:42 -07:00
parent 42e21458ba
commit 9fa9aa09ff
19 changed files with 268 additions and 79 deletions

View file

@ -210,6 +210,10 @@ public:
return r;
}
app * mk_default(expr * a) {
return m_manager.mk_app(m_fid, OP_ARRAY_DEFAULT, 0, nullptr, 1, &a);
}
app * mk_const_array(sort * s, expr * v) {
parameter param(s);
return m_manager.mk_app(m_fid, OP_CONST_ARRAY, 1, &param, 1, &v);
@ -251,6 +255,14 @@ public:
parameter param(f);
return m_manager.mk_app(m_fid, OP_AS_ARRAY, 1, &param, 0, nullptr, nullptr);
}
sort* get_array_range_rec(sort* s) {
while (is_array(s)) {
s = get_array_range(s);
}
return s;
}
};

View file

@ -450,6 +450,19 @@ namespace datatype {
m_manager->raise_exception("datatype is not co-variant");
}
array_util autil(m);
for (sort* s : sorts) {
for (constructor const* c : get_def(s)) {
for (accessor const* a : *c) {
if (autil.is_array(a->range())) {
if (sorts.contains(get_array_range(a->range()))) {
m_has_nested_arrays = true;
}
}
}
}
}
u().compute_datatype_size_functions(m_def_block);
for (symbol const& s : m_def_block) {
sort_ref_vector ps(m);
@ -892,10 +905,13 @@ namespace datatype {
for (unsigned i = 0; i < n; ++i) {
get_subsorts(get_array_domain(s, i), subsorts);
}
if (!is_datatype(get_array_range(s))) {
get_subsorts(get_array_range(s), subsorts);
}
for (sort* r : subsorts) {
if (mark.is_marked(r)) return false;
}
return is_covariant(mark, subsorts, get_array_range(s));
return true;
}
def const& util::get_def(sort* s) const {
@ -1115,6 +1131,7 @@ namespace datatype {
ptr_vector<func_decl> const& constructors = *get_datatype_constructors(ty);
unsigned sz = constructors.size();
array_util autil(m);
TRACE("util_bug", tout << "get-non-rec constructor: " << sort_ref(ty, m) << "\n";
tout << "forbidden: ";
for (sort* s : forbidden_set) tout << sort_ref(s, m) << " ";
@ -1129,7 +1146,7 @@ namespace datatype {
TRACE("util_bug", tout << "checking " << sort_ref(ty, m) << ": " << func_decl_ref(c, m) << "\n";);
unsigned num_args = c->get_arity();
unsigned i = 0;
for (; i < num_args && !is_datatype(c->get_domain(i)); i++);
for (; i < num_args && !is_datatype(autil.get_array_range_rec(c->get_domain(i))); i++);
if (i == num_args) {
TRACE("util_bug", tout << "found non-rec " << func_decl_ref(c, m) << "\n";);
return c;
@ -1142,7 +1159,7 @@ namespace datatype {
unsigned num_args = c->get_arity();
unsigned i = 0;
for (; i < num_args; i++) {
sort * T_i = c->get_domain(i);
sort * T_i = autil.get_array_range_rec(c->get_domain(i));
TRACE("util_bug", tout << "c: " << i << " " << sort_ref(T_i, m) << "\n";);
if (!is_datatype(T_i)) {
TRACE("util_bug", tout << sort_ref(T_i, m) << " is not a datatype\n";);

View file

@ -210,13 +210,14 @@ namespace datatype {
unsigned m_id_counter;
svector<symbol> m_def_block;
unsigned m_class_id;
mutable bool m_has_nested_arrays;
void inherit(decl_plugin* other_p, ast_translation& tr) override;
void log_axiom_definitions(symbol const& s, sort * new_sort);
public:
plugin(): m_id_counter(0), m_class_id(0) {}
plugin(): m_id_counter(0), m_class_id(0), m_has_nested_arrays(false) {}
~plugin() override;
void finalize() override;
@ -254,6 +255,8 @@ namespace datatype {
unsigned get_axiom_base_id(symbol const& s) { return m_axiom_bases[s]; }
util & u() const;
bool has_nested_arrays() const { return m_has_nested_arrays; }
private:
bool is_value_visit(expr * arg, ptr_buffer<app> & todo) const;
@ -353,6 +356,7 @@ 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 are_siblings(sort * s1, sort * s2);
bool is_func_decl(op_kind k, unsigned num_params, parameter const* params, func_decl* f);