3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 09:35:32 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-07-02 08:10:47 -07:00
commit 05738702d6
31 changed files with 174 additions and 196 deletions

View file

@ -178,11 +178,12 @@ private:
if (m_bv.is_bv_mul(p)) {
expr_ref rest(m);
for (expr* arg : *to_app(p)) {
if (arg != v)
if (arg != v) {
if (rest)
rest = m_bv.mk_bv_mul(rest, arg);
else
rest = arg;
}
}
if (!rest) return false;
@ -251,24 +252,45 @@ private:
if (m_arith.is_mul(p) && m_arith.is_real(p)) {
expr_ref rest(m);
for (expr* arg : *to_app(p)) {
if (arg != v)
if (arg != v) {
if (rest)
rest = m_arith.mk_mul(rest, arg);
else
rest = arg;
}
}
if (!rest) return false;
expr_ref zero(m_arith.mk_numeral(rational::zero(), false), m);
expr_ref zero(m_arith.mk_real(0), m);
new_v = m.mk_ite(m.mk_eq(zero, rest), zero, v);
if (mc) {
ensure_mc(mc);
expr_ref def(m_arith.mk_div(v, rest), m);
(*mc)->add(v, def);
}
return true;
return true;
}
expr* e1 = nullptr, *e2 = nullptr;
// t / v -> if t = 0 then 0 else v
// inverse: t = 0 then 1 else v / t
if (m_arith.is_div(p, e1, e2) && e2 == v) {
expr_ref zero(m_arith.mk_real(0), m);
new_v = m.mk_ite(m.mk_eq(zero, e1), zero, v);
if (mc) {
ensure_mc(mc);
expr_ref def(m.mk_ite(m.mk_eq(zero, e1), m_arith.mk_real(1), m_arith.mk_div(e1, v)), m);
(*mc)->add(v, def);
}
return true;
}
// v / t unless t != 0
if (m_arith.is_div(p, e1, e2) && e1 == v) {
return false;
}
if (m.is_eq(p, e1, e2)) {
if (mc && has_diagonal(e1)) {
ensure_mc(mc);
@ -294,12 +316,15 @@ private:
bool has_diagonal(expr* e) {
return
m_bv.is_bv(e) ||
m.is_bool(e);
m.is_bool(e) ||
m_arith.is_int_real(e);
}
expr * mk_diagonal(expr* e) {
if (m_bv.is_bv(e)) return m_bv.mk_bv_neg(e);
if (m.is_bool(e)) return m.mk_not(e);
if (m_arith.is_int(e)) return m_arith.mk_add(m_arith.mk_int(1), e);
if (m_arith.is_real(e)) return m_arith.mk_add(m_arith.mk_real(1), e);
UNREACHABLE();
return e;
}

View file

@ -119,21 +119,6 @@ tactic * mk_fail_if_undecided_tactic();
tactic * mk_report_verbose_tactic(char const * msg, unsigned lvl);
tactic * mk_trace_tactic(char const * tag);
class tactic_factory {
public:
virtual ~tactic_factory() {}
virtual tactic * operator()(ast_manager & m, params_ref const & p) = 0;
};
#define MK_TACTIC_FACTORY(NAME, CODE) \
class NAME : public tactic_factory { \
public: \
virtual ~NAME() {} \
virtual tactic * operator()(ast_manager & m, params_ref const & p) { CODE } \
};
#define MK_SIMPLE_TACTIC_FACTORY(NAME, ST) MK_TACTIC_FACTORY(NAME, return ST;)
void exec(tactic & t, goal_ref const & in, goal_ref_buffer & result);
lbool check_sat(tactic & t, goal_ref & g, model_ref & md, labels_vec & labels, proof_ref & pr, expr_dependency_ref & core, std::string & reason_unknown);