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

some micro tuning

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-02-06 16:58:25 -08:00
parent 8b23a1701a
commit 200f47369d
6 changed files with 81 additions and 12 deletions

View file

@ -277,6 +277,9 @@ void asserted_formulas::reduce() {
TRACE("macros", m_macro_manager.display(tout););
flush_cache();
CASSERT("well_sorted",check_well_sorted());
// display(std::cout);
// exit(0);
}

View file

@ -2003,12 +2003,14 @@ namespace smt {
*/
void context::add_lit_occs(clause const& cls) {
if (!track_occs()) return;
for (literal l : cls) {
inc_ref(l);
}
}
void context::remove_lit_occs(clause const& cls, unsigned nbv) {
if (!track_occs()) return;
for (literal l : cls) {
if (l.var() < static_cast<int>(nbv))
dec_ref(l);
@ -2016,9 +2018,9 @@ namespace smt {
}
// TBD: enable as assertion when ready to re-check
void context::dec_ref(literal l) { if (m_lit_occs[l.index()] > 0) m_lit_occs[l.index()]--; }
void context::dec_ref(literal l) { if (track_occs() && m_lit_occs[l.index()] > 0) m_lit_occs[l.index()]--; }
void context::inc_ref(literal l) { m_lit_occs[l.index()]++; }
void context::inc_ref(literal l) { if (track_occs()) m_lit_occs[l.index()]++; }
/**
\brief Delete the given clause.

View file

@ -839,6 +839,8 @@ namespace smt {
void mk_ite_cnstr(app * n);
bool track_occs() const { return m_fparams.m_phase_selection == PS_THEORY; }
void dec_ref(literal l);
void inc_ref(literal l);

View file

@ -357,7 +357,8 @@ class theory_lra::imp {
scoped_ptr<lp::lar_solver> m_solver;
resource_limit m_resource_limit;
lp_bounds m_new_bounds;
switcher m_switcher;
switcher m_switcher;
symbol m_farkas;
context& ctx() const { return th.get_context(); }
theory_id get_id() const { return th.get_id(); }
@ -1001,7 +1002,8 @@ public:
m_model_eqs(DEFAULT_HASHTABLE_INITIAL_CAPACITY, var_value_hash(*this), var_value_eq(*this)),
m_solver(nullptr),
m_resource_limit(*this),
m_switcher(*this) {
m_switcher(*this),
m_farkas("farkas") {
}
~imp() {
@ -1911,17 +1913,19 @@ public:
if (m_idiv_terms.empty()) {
return true;
}
init_variable_values();
// init_variable_values();
bool all_divs_valid = true;
for (expr* n : m_idiv_terms) {
expr* p = nullptr, *q = nullptr;
VERIFY(a.is_idiv(n, p, q));
theory_var v = mk_var(n);
theory_var v1 = mk_var(p);
rational r1 = get_value(v1);
lp::impq r1 = get_ivalue(v1);
SASSERT(r1.y.is_zero());
SASSERT(r1.x.is_int());
rational r2;
if (!r1.is_int() || r1.is_neg()) {
if (!r1.x.is_int() || r1.x.is_neg()) {
// TBD
// r1 = 223/4, r2 = 2, r = 219/8
// take ceil(r1), floor(r1), ceil(r2), floor(r2), for floor(r2) > 0
@ -1932,15 +1936,17 @@ public:
}
if (a.is_numeral(q, r2) && r2.is_pos()) {
rational val_v = get_value(v);
if (val_v == div(r1, r2)) continue;
if (!is_bounded(n)) {
TRACE("arith", tout << "unbounded " << expr_ref(n, m) << "\n";);
continue;
}
lp::impq val_v = get_ivalue(v);
SASSERT(val_v.y.is_zero());
SASSERT(val_v.x.is_int());
if (val_v.x == div(r1.x, r2)) continue;
TRACE("arith", tout << get_value(v) << " != " << r1 << " div " << r2 << "\n";);
rational div_r = div(r1, r2);
rational div_r = div(r1.x, r2);
// p <= q * div(r1, q) + q - 1 => div(p, q) <= div(r1, r2)
// p >= q * div(r1, q) => div(r1, q) <= div(p, q)
rational mul(1);
@ -2842,7 +2848,7 @@ public:
m_core.reset();
m_eqs.reset();
m_core.push_back(lit1);
m_params.push_back(parameter(symbol("farkas")));
m_params.push_back(parameter(m_farkas));
m_params.push_back(parameter(rational(1)));
m_params.push_back(parameter(rational(1)));
assign(lit2);