mirror of
https://github.com/Z3Prover/z3
synced 2025-07-19 10:52:02 +00:00
change lar_terms to use column indices
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
3313590b95
commit
c2e5cd78c8
13 changed files with 88 additions and 103 deletions
|
@ -50,7 +50,7 @@ bool core::compare_holds(const rational& ls, llc cmp, const rational& rs) const
|
|||
rational core::value(const lp::lar_term& r) const {
|
||||
rational ret(0);
|
||||
for (const auto & t : r) {
|
||||
ret += t.coeff() * val(t.var().index());
|
||||
ret += t.coeff() * val(t.column());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ rational core::value(const lp::lar_term& r) const {
|
|||
lp::lar_term core::subs_terms_to_columns(const lp::lar_term& t) const {
|
||||
lp::lar_term r;
|
||||
for (const auto& p : t) {
|
||||
lpvar j = p.var().index();
|
||||
lpvar j = p.column();
|
||||
if (lp::tv::is_term(j))
|
||||
j = m_lar_solver.map_term_index_to_column_index(j);
|
||||
r.add_monomial(p.coeff(), j);
|
||||
|
@ -323,25 +323,25 @@ bool core:: explain_coeff_lower_bound(const lp::lar_term::ival& p, rational& bou
|
|||
SASSERT(!a.is_zero());
|
||||
unsigned c; // the index for the lower or the upper bound
|
||||
if (a.is_pos()) {
|
||||
unsigned c = m_lar_solver.get_column_lower_bound_witness(p.var().index());
|
||||
unsigned c = m_lar_solver.get_column_lower_bound_witness(p.column());
|
||||
if (c + 1 == 0)
|
||||
return false;
|
||||
bound = a * m_lar_solver.get_lower_bound(p.var().index()).x;
|
||||
bound = a * m_lar_solver.get_lower_bound(p.column()).x;
|
||||
e.add(c);
|
||||
return true;
|
||||
}
|
||||
// a.is_neg()
|
||||
c = m_lar_solver.get_column_upper_bound_witness(p.var().index());
|
||||
c = m_lar_solver.get_column_upper_bound_witness(p.column());
|
||||
if (c + 1 == 0)
|
||||
return false;
|
||||
bound = a * m_lar_solver.get_upper_bound(p.var().index()).x;
|
||||
bound = a * m_lar_solver.get_upper_bound(p.column()).x;
|
||||
e.add(c);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool core::explain_coeff_upper_bound(const lp::lar_term::ival& p, rational& bound, lp::explanation& e) const {
|
||||
const rational& a = p.coeff();
|
||||
lpvar j = p.var().is_term()? m_lar_solver.map_term_index_to_column_index(p.var().index()) : p.var().index();
|
||||
lpvar j = p.column();
|
||||
SASSERT(!a.is_zero());
|
||||
unsigned c; // the index for the lower or the upper bound
|
||||
if (a.is_neg()) {
|
||||
|
@ -426,7 +426,6 @@ bool core:: explain_by_equiv(const lp::lar_term& t, lp::explanation& e) const {
|
|||
void core::mk_ineq(lp::lar_term& t, llc cmp, const rational& rs) {
|
||||
TRACE("nla_solver_details", m_lar_solver.print_term_as_indices(t, tout << "t = "););
|
||||
if (!explain_ineq(t, cmp, rs)) {
|
||||
m_lar_solver.subs_term_columns(t);
|
||||
current_lemma().push_back(ineq(cmp, t, rs));
|
||||
CTRACE("nla_solver", ineq_holds(ineq(cmp, t, rs)), print_ineq(ineq(cmp, t, rs), tout) << "\n";);
|
||||
SASSERT(!ineq_holds(ineq(cmp, t, rs)));
|
||||
|
@ -435,7 +434,6 @@ void core::mk_ineq(lp::lar_term& t, llc cmp, const rational& rs) {
|
|||
|
||||
void core::mk_ineq_no_expl_check(lp::lar_term& t, llc cmp, const rational& rs) {
|
||||
TRACE("nla_solver_details", m_lar_solver.print_term_as_indices(t, tout << "t = "););
|
||||
m_lar_solver.subs_term_columns(t);
|
||||
current_lemma().push_back(ineq(cmp, t, rs));
|
||||
CTRACE("nla_solver", ineq_holds(ineq(cmp, t, rs)), print_ineq(ineq(cmp, t, rs), tout) << "\n";);
|
||||
SASSERT(!ineq_holds(ineq(cmp, t, rs)));
|
||||
|
@ -681,7 +679,7 @@ std::ostream & core::print_ineqs(const lemma& l, std::ostream & out) const {
|
|||
print_ineq(in, out);
|
||||
if (i + 1 < l.ineqs().size()) out << " or ";
|
||||
for (const auto & p: in.m_term)
|
||||
vars.insert(p.var().index());
|
||||
vars.insert(p.column());
|
||||
}
|
||||
out << std::endl;
|
||||
for (lpvar j : vars) {
|
||||
|
@ -864,9 +862,9 @@ bool core:: is_octagon_term(const lp::lar_term& t, bool & sign, lpvar& i, lpvar
|
|||
return false;
|
||||
}
|
||||
if (i == static_cast<lpvar>(-1))
|
||||
i = p.var().index();
|
||||
i = p.column();
|
||||
else
|
||||
j = p.var().index();
|
||||
j = p.column();
|
||||
}
|
||||
SASSERT(j != static_cast<unsigned>(-1));
|
||||
sign = (seen_minus && seen_plus)? false : true;
|
||||
|
@ -987,7 +985,7 @@ std::unordered_set<lpvar> core::collect_vars(const lemma& l) const {
|
|||
|
||||
for (const auto& i : current_lemma().ineqs()) {
|
||||
for (const auto& p : i.term()) {
|
||||
insert_j(p.var().index());
|
||||
insert_j(p.column());
|
||||
}
|
||||
}
|
||||
for (const auto& p : current_expl()) {
|
||||
|
@ -1754,9 +1752,9 @@ std::unordered_set<lpvar> core::get_vars_of_expr_with_opening_terms(const nex *e
|
|||
if (ls.column_corresponds_to_term(j)) {
|
||||
const auto& t = m_lar_solver.get_term(lp::tv::raw(ls.local_to_external(j)));
|
||||
for (auto p : t) {
|
||||
if (ret.find(p.var().index()) == ret.end()) {
|
||||
added.push_back(p.var().index());
|
||||
ret.insert(p.var().index());
|
||||
if (ret.find(p.column()) == ret.end()) {
|
||||
added.push_back(p.column());
|
||||
ret.insert(p.column());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue