3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-24 23:03:41 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-04-04 16:47:00 -07:00
parent 9fbe178de4
commit 8faf35e2e0

View file

@ -50,11 +50,11 @@ ufbv_rewriter::~ufbv_rewriter() {
} }
bool ufbv_rewriter::is_demodulator(expr * e, expr_ref & large, expr_ref & small) const { bool ufbv_rewriter::is_demodulator(expr * e, expr_ref & large, expr_ref & small) const {
if (is_quantifier(e)) { if (!is_forall(e)) {
quantifier * q = to_quantifier(e); return false;
if (is_forall(q)) { }
expr * qe = q->get_expr(); expr * qe = to_quantifier(e)->get_expr();
expr * lhs = nullptr, *rhs = nullptr; expr * lhs = nullptr, *rhs = nullptr, *n;
if (m.is_eq(qe, lhs, rhs)) { if (m.is_eq(qe, lhs, rhs)) {
int subset = is_subset(lhs, rhs); int subset = is_subset(lhs, rhs);
int smaller = is_smaller(lhs, rhs); int smaller = is_smaller(lhs, rhs);
@ -69,15 +69,12 @@ bool ufbv_rewriter::is_demodulator(expr * e, expr_ref & large, expr_ref & small)
small = lhs; small = lhs;
return true; return true;
} }
#if 1
// lhs = (not rhs) --> (not lhs) = rhs // lhs = (not rhs) --> (not lhs) = rhs
expr * not_rhs; if (m.is_not(rhs, n) && is_uninterp(n)) {
if (m.is_not(rhs, not_rhs) && is_uninterp(not_rhs)) { large = n;
large = not_rhs;
small = m.mk_not(lhs); small = m.mk_not(lhs);
return true; return true;
} }
#endif
} }
if ((subset == -1 || subset == +2) && smaller == -1) { if ((subset == -1 || subset == +2) && smaller == -1) {
@ -86,31 +83,26 @@ bool ufbv_rewriter::is_demodulator(expr * e, expr_ref & large, expr_ref & small)
small = rhs; small = rhs;
return true; return true;
} }
#if 1
// (not lhs) = rhs --> lhs = (not rhs) // (not lhs) = rhs --> lhs = (not rhs)
expr * not_lhs; if (m.is_not(lhs, n) && is_uninterp(n)) {
if (m.is_not(lhs, not_lhs) && is_uninterp(not_lhs)) { large = n;
large = not_lhs;
small = m.mk_not(rhs); small = m.mk_not(rhs);
return true; return true;
} }
#endif
} }
}
} else if (m.is_not(qe) && is_uninterp(to_app(qe)->get_arg(0))) { else if (m.is_not(qe, n)) {
// this is like (not (f ... )) --> (= (f ...) false) // this is like (not (f ... )) --> (= (f ...) false)
large = to_app(qe)->get_arg(0); large = n;
small = m.mk_false(); small = m.mk_false();
return true; return true;
} else if (is_uninterp(qe)) { }
else if (is_uninterp(qe)) {
// this is like (f ... ) --> (= (f ...) true) // this is like (f ... ) --> (= (f ...) true)
large = to_app(qe); large = to_app(qe);
small = m.mk_true(); small = m.mk_true();
return true; return true;
} }
}
}
return false; return false;
} }
@ -171,20 +163,8 @@ int ufbv_rewriter::is_smaller(expr * e1, expr * e2) const {
return -1; return -1;
} }
} }
sz1 = get_depth(e1);
switch (e1->get_kind()) { sz2 = get_depth(e2);
case AST_VAR: sz1 = 1; break;
case AST_QUANTIFIER: sz1 = to_quantifier(e1)->get_depth(); break;
case AST_APP: sz1 = to_app(e1)->get_depth(); break;
default: UNREACHABLE();
}
switch (e2->get_kind()) {
case AST_VAR: sz2 = 1; break;
case AST_QUANTIFIER: sz2 = to_quantifier(e2)->get_depth(); break;
case AST_APP: sz2 = to_app(e2)->get_depth(); break;
default: UNREACHABLE();
}
return (sz1 == sz2) ? 0 : return (sz1 == sz2) ? 0 :
(sz1 < sz2) ? +1 : (sz1 < sz2) ? +1 :
@ -891,7 +871,9 @@ bool ufbv_rewriter::match_subst::operator()(expr * t, expr * i) {
m_todo.reset(); m_todo.reset();
if (is_var(t)) if (is_var(t))
return true; return true;
if (is_app(t) && is_app(i) && to_app(t)->get_decl() == to_app(i)->get_decl() && to_app(t)->get_num_args() == to_app(i)->get_num_args()) { if (is_app(t) && is_app(i) &&
to_app(t)->get_decl() == to_app(i)->get_decl() &&
to_app(t)->get_num_args() == to_app(i)->get_num_args()) {
return match_args(to_app(t), to_app(i)->get_args()); return match_args(to_app(t), to_app(i)->get_args());
} }
return false; return false;