mirror of
https://github.com/Z3Prover/z3
synced 2025-10-08 00:41:56 +00:00
update slicing to fix unbound variables. test datatype realizer
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
bfbdad3ce6
commit
37a13b1d09
3 changed files with 59 additions and 34 deletions
|
@ -732,7 +732,7 @@ namespace datalog {
|
|||
|
||||
|
||||
void mk_slice::update_rule(rule& r, rule_set& dst) {
|
||||
rule* new_rule;
|
||||
rule_ref new_rule(rm);
|
||||
if (rule_updated(r)) {
|
||||
init_vars(r);
|
||||
app_ref_vector tail(m);
|
||||
|
@ -794,16 +794,20 @@ namespace datalog {
|
|||
|
||||
}
|
||||
|
||||
|
||||
new_rule = rm.mk(head.get(), tail.size(), tail.c_ptr(), (const bool*) 0);
|
||||
|
||||
rm.fix_unbound_vars(new_rule, false);
|
||||
|
||||
TRACE("dl", r.display(m_ctx, tout << "replacing:\n"); new_rule->display(m_ctx, tout << "by:\n"););
|
||||
}
|
||||
else {
|
||||
new_rule = &r;
|
||||
}
|
||||
dst.add_rule(new_rule);
|
||||
dst.add_rule(new_rule.get());
|
||||
|
||||
if (m_pc) {
|
||||
m_pc->insert(&r, new_rule, 0, 0);
|
||||
m_pc->insert(&r, new_rule.get(), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace qe {
|
|||
func_decl* f = a->get_decl();
|
||||
if (m_util.is_recognizer(f) && a->get_arg(0) == x) {
|
||||
m_recognizers.push_back(a);
|
||||
TRACE("quant_elim", tout << "add recognizer:" << mk_pp(a, m) << "\n";);
|
||||
TRACE("qe", tout << "add recognizer:" << mk_pp(a, m) << "\n";);
|
||||
return true;
|
||||
}
|
||||
if (!m.is_eq(a)) {
|
||||
|
@ -161,6 +161,10 @@ namespace qe {
|
|||
unsigned num_neqs() { return m_neq_atoms.size(); }
|
||||
app* neq_atom(unsigned i) { return m_neq_atoms[i].get(); }
|
||||
|
||||
unsigned num_neq_terms() const { return m_neqs.size(); }
|
||||
expr* neq_term(unsigned i) const { return m_neqs[i]; }
|
||||
expr* const* neq_terms() const { return m_neqs.c_ptr(); }
|
||||
|
||||
unsigned num_recognizers() { return m_recognizers.size(); }
|
||||
app* recognizer(unsigned i) { return m_recognizers[i].get(); }
|
||||
|
||||
|
@ -212,7 +216,7 @@ namespace qe {
|
|||
}
|
||||
|
||||
void add_atom(app* a, bool is_pos) {
|
||||
TRACE("quant_elim", tout << "add atom:" << mk_pp(a, m) << " " << (is_pos?"pos":"neg") << "\n";);
|
||||
TRACE("qe", tout << "add atom:" << mk_pp(a, m) << " " << (is_pos?"pos":"neg") << "\n";);
|
||||
if (is_pos) {
|
||||
m_eq_atoms.push_back(a);
|
||||
}
|
||||
|
@ -326,7 +330,7 @@ namespace qe {
|
|||
for_each_expr(*this, fml.get());
|
||||
if (m_change) {
|
||||
fml = get_expr(fml.get());
|
||||
TRACE("quant_elim", tout << "lift:\n" << mk_pp(fml.get(), m) << "\n";);
|
||||
TRACE("qe", tout << "lift:\n" << mk_pp(fml.get(), m) << "\n";);
|
||||
}
|
||||
return m_change;
|
||||
}
|
||||
|
@ -380,7 +384,7 @@ namespace qe {
|
|||
}
|
||||
expr* e = m.mk_and(conj.size(), conj.c_ptr());
|
||||
m_map.insert(a, e, 0);
|
||||
TRACE("quant_elim", tout << "replace: " << mk_pp(a, m) << " ==> \n" << mk_pp(e, m) << "\n";);
|
||||
TRACE("qe", tout << "replace: " << mk_pp(a, m) << " ==> \n" << mk_pp(e, m) << "\n";);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -456,7 +460,7 @@ namespace qe {
|
|||
virtual void assign(contains_app& x, expr* fml, rational const& vl) {
|
||||
sort* s = x.x()->get_decl()->get_range();
|
||||
SASSERT(m_datatype_util.is_datatype(s));
|
||||
TRACE("quant_elim", tout << mk_pp(x.x(), m) << " " << vl << "\n";);
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " " << vl << "\n";);
|
||||
if (m_datatype_util.is_recursive(s)) {
|
||||
assign_rec(x, fml, vl);
|
||||
}
|
||||
|
@ -468,16 +472,13 @@ namespace qe {
|
|||
virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) {
|
||||
sort* s = x.x()->get_decl()->get_range();
|
||||
SASSERT(m_datatype_util.is_datatype(s));
|
||||
TRACE("quant_elim", tout << mk_pp(x.x(), m) << " " << vl << "\n";);
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " " << vl << "\n";);
|
||||
if (m_datatype_util.is_recursive(s)) {
|
||||
subst_rec(x, vl, fml, def);
|
||||
}
|
||||
else {
|
||||
subst_nonrec(x, vl, fml, def);
|
||||
}
|
||||
if (def) {
|
||||
*def = 0; // TBD
|
||||
}
|
||||
}
|
||||
|
||||
virtual unsigned get_weight( contains_app& x, expr* fml) {
|
||||
|
@ -605,7 +606,7 @@ namespace qe {
|
|||
num_branches = rational(eqs.num_eqs() + 1);
|
||||
return true;
|
||||
}
|
||||
TRACE("quant_elim", tout << "could not get number of branches " << mk_pp(x.x(), m) << "\n";);
|
||||
TRACE("qe", tout << "could not get number of branches " << mk_pp(x.x(), m) << "\n";);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -660,6 +661,7 @@ namespace qe {
|
|||
SASSERT(m_datatype_util.is_datatype(s));
|
||||
func_decl* c = 0, *r = 0;
|
||||
|
||||
TRACE("qe", tout << mk_pp(x, m) << " " << vl << " " << mk_pp(fml, m) << " " << (def != 0) << "\n";);
|
||||
//
|
||||
// Add recognizer to formula.
|
||||
// Introduce auxiliary variable to eliminate.
|
||||
|
@ -673,13 +675,13 @@ namespace qe {
|
|||
m_ctx.add_var(fresh_x);
|
||||
m_replace->apply_substitution(x, fresh_x, 0, fml);
|
||||
add_def(fresh_x, def);
|
||||
TRACE("quant_elim", tout << "Add recognizer " << mk_pp(is_c, m) << "\n";);
|
||||
TRACE("qe", tout << "Add recognizer " << mk_pp(is_c, m) << "\n";);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (has_selector(contains_x, fml, c)) {
|
||||
TRACE("quant_elim", tout << "Eliminate selector " << mk_ll_pp(c, m) << "\n";);
|
||||
TRACE("qe", tout << "Eliminate selector " << mk_ll_pp(c, m) << "\n";);
|
||||
subst_constructor(contains_x, c, fml, def);
|
||||
return;
|
||||
}
|
||||
|
@ -721,14 +723,19 @@ namespace qe {
|
|||
}
|
||||
|
||||
for (unsigned i = 0; i < eqs.num_neqs(); ++i) {
|
||||
m_replace->apply_substitution(eqs.neq_atom(i), m.mk_true(), fml);
|
||||
m_replace->apply_substitution(eqs.neq_atom(i), m.mk_false(), fml);
|
||||
}
|
||||
if (def) {
|
||||
NOT_IMPLEMENTED_YET();
|
||||
// you need to create a diagonal term
|
||||
sort* s = m.get_sort(x);
|
||||
ptr_vector<sort> sorts;
|
||||
sorts.resize(eqs.num_neq_terms(), s);
|
||||
func_decl* diag = m.mk_func_decl(symbol("diag"), sorts.size(), sorts.c_ptr(), s);
|
||||
expr_ref t(m);
|
||||
t = m.mk_app(diag, eqs.num_neq_terms(), eqs.neq_terms());
|
||||
add_def(t, def);
|
||||
}
|
||||
}
|
||||
TRACE("quant_elim", tout << "reduced " << mk_pp(fml.get(), m) << "\n";);
|
||||
TRACE("qe", tout << "reduced " << mk_pp(fml.get(), m) << "\n";);
|
||||
}
|
||||
|
||||
bool get_num_branches_nonrec( contains_app& x, expr* fml, rational& num_branches) {
|
||||
|
@ -738,10 +745,10 @@ namespace qe {
|
|||
func_decl* c = 0, *r = 0;
|
||||
|
||||
if (sz != 1 && has_recognizer(x.x(), fml, r, c)) {
|
||||
TRACE("quant_elim", tout << mk_pp(x.x(), m) << " has a recognizer\n";);
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " has a recognizer\n";);
|
||||
num_branches = rational(1);
|
||||
}
|
||||
TRACE("quant_elim", tout << mk_pp(x.x(), m) << " branches: " << sz << "\n";);
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " branches: " << sz << "\n";);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -757,7 +764,7 @@ namespace qe {
|
|||
}
|
||||
func_decl* c = 0, *r = 0;
|
||||
if (has_recognizer(x, fml, r, c)) {
|
||||
TRACE("quant_elim", tout << mk_pp(x, m) << " has a recognizer\n";);
|
||||
TRACE("qe", tout << mk_pp(x, m) << " has a recognizer\n";);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -776,7 +783,7 @@ namespace qe {
|
|||
SASSERT(!m_datatype_util.is_recursive(s));
|
||||
func_decl* c = 0, *r = 0;
|
||||
if (has_recognizer(x.x(), fml, r, c)) {
|
||||
TRACE("quant_elim", tout << mk_pp(x.x(), m) << " has a recognizer\n";);
|
||||
TRACE("qe", tout << mk_pp(x.x(), m) << " has a recognizer\n";);
|
||||
}
|
||||
else {
|
||||
unsigned sz = m_datatype_util.get_datatype_num_constructors(s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue