3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-08 18:31:49 +00:00

do not use nl variables in random_update()

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2020-02-04 11:51:37 -08:00
parent 3ab7477663
commit 06173aa4d7
7 changed files with 57 additions and 7 deletions

View file

@ -325,6 +325,8 @@ public:
bool is_monic_var(lpvar v) const { return m_var2index.get(v, UINT_MAX) != UINT_MAX; }
bool is_used_in_monic(lpvar v) const { return v < m_use_lists.size() && m_use_lists[v].m_head != nullptr; }
bool elists_are_consistent(std::unordered_map<unsigned_vector, std::unordered_set<lpvar>, hash_svector> &lists) const;
}; // end of emonics

View file

@ -1439,15 +1439,11 @@ void lar_solver::fill_var_set_for_random_update(unsigned sz, var_index const * v
for (unsigned i = 0; i < sz; i++) {
var_index var = vars[i];
if (var >= m_terms_start_index) { // handle the term
lpvar j = adjust_term_index(var);
if (column_is_int(j))
continue;
for (auto it : *m_terms[var - m_terms_start_index]) {
column_list.push_back(it.var());
}
} else {
if (!column_is_int(var))
column_list.push_back(var);
column_list.push_back(var);
}
}
}

View file

@ -1712,4 +1712,25 @@ unsigned core::get_var_weight(lpvar j) const {
}
bool core::is_nl_var(lpvar j) const {
if (is_monic_var(j))
return true;
return m_emons.is_used_in_monic(j);
}
bool core::influences_nl_var(lpvar j) const {
if (m_lar_solver.is_term(j))
j = m_lar_solver.adjust_term_index(j);
if (is_nl_var(j))
return true;
for (const auto & c : m_lar_solver.A_r().m_columns[j]) {
lpvar basic_in_row = m_lar_solver.r_basis()[c.var()];
if (is_nl_var(basic_in_row))
return true;
}
return false;
}
} // end of nla

View file

@ -412,6 +412,9 @@ public:
dd::pdd pdd_expr(const rational& c, lpvar j, u_dependency*&);
void set_level2var_for_grobner();
void configure_grobner();
bool influences_nl_var(lpvar) const;
bool is_nl_var(lpvar) const;
bool is_used_in_monic(lpvar) const;
}; // end of core
struct pp_mon {

View file

@ -51,6 +51,10 @@ void solver::pop(unsigned n) {
solver::solver(lp::lar_solver& s): m_core(alloc(core, s, m_res_limit)) {
}
bool solver::influences_nl_var(lpvar j) const {
return m_core->influences_nl_var(j);
}
solver::~solver() {
dealloc(m_core);
}

View file

@ -44,5 +44,6 @@ public:
bool need_check();
lbool check(vector<lemma>&);
bool is_monic_var(lpvar) const;
bool influences_nl_var(lpvar) const;
};
}

View file

@ -1597,12 +1597,35 @@ public:
m_variable_values.clear();
}
bool influences_nl_var(theory_var v) const {
if (!m_use_nla)
return false; // that is the legacy solver behavior
if (!m_nla)
return false;
return m_nla->influences_nl_var(get_lpvar(v));
}
bool can_be_used_in_random_update(theory_var v) const {
if (!th.is_relevant_and_shared(get_enode(v)))
return false;
if (is_int(v))
return false;
if (influences_nl_var(v))
return false;
return true;
}
bool assume_eqs() {
svector<lpvar> vars;
theory_var sz = static_cast<theory_var>(th.get_num_vars());
for (theory_var v = 0; v < sz; ++v) {
if (th.is_relevant_and_shared(get_enode(v))) {
vars.push_back(get_lpvar(v));
if (th.is_relevant_and_shared(get_enode(v))) {
if (can_be_used_in_random_update(v))
vars.push_back(get_lpvar(v));
}
}
if (vars.empty()) {