mirror of
https://github.com/Z3Prover/z3
synced 2025-07-19 02:42:02 +00:00
bug fixes
values cannot change on basic variables from inequalities arithmetic modulo can produce 0 coefficients
This commit is contained in:
parent
d1118cb178
commit
05d564e828
3 changed files with 33 additions and 14 deletions
|
@ -844,9 +844,8 @@ namespace polysat {
|
||||||
unsigned rz = r_z.id();
|
unsigned rz = r_z.id();
|
||||||
if (rz == rx)
|
if (rz == rx)
|
||||||
continue;
|
continue;
|
||||||
TRACE("fixplex,", display_row(tout << "eliminate ", r_z, false) << "\n";);
|
|
||||||
VERIFY(eliminate_var(r_x, col, tz_b, old_value_y));
|
VERIFY(eliminate_var(r_x, col, tz_b, old_value_y));
|
||||||
TRACE("fixplex,", display_row(tout << "eliminated ", r_z, false) << "\n";);
|
TRACE("fixplex", display_row(tout << "eliminated ", r_z, false) << "\n";);
|
||||||
add_patch(row2base(r_z));
|
add_patch(row2base(r_z));
|
||||||
}
|
}
|
||||||
SASSERT(well_formed());
|
SASSERT(well_formed());
|
||||||
|
@ -1345,7 +1344,7 @@ namespace polysat {
|
||||||
if (m_vars[v].max() >= m_vars[w].max() && !new_bound(i, v, 0, m_vars[w].max(), vlo, vhi, wlo, whi))
|
if (m_vars[v].max() >= m_vars[w].max() && !new_bound(i, v, 0, m_vars[w].max(), vlo, vhi, wlo, whi))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (value(v) >= value(w) && value(v) + 1 != 0 && m_vars[w].contains(value(v) + 1))
|
if (!is_base(w) && value(v) >= value(w) && value(v) + 1 != 0 && m_vars[w].contains(value(v) + 1))
|
||||||
update_value(w, value(v) - value(w) + 1);
|
update_value(w, value(v) - value(w) + 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1364,7 +1363,7 @@ namespace polysat {
|
||||||
if (m_vars[v].max() > m_vars[w].max() && !new_bound(i, v, 0, m_vars[w].max() + 1, vlo, vhi, wlo, whi))
|
if (m_vars[v].max() > m_vars[w].max() && !new_bound(i, v, 0, m_vars[w].max() + 1, vlo, vhi, wlo, whi))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (value(v) > value(w) && m_vars[w].contains(value(v)))
|
if (value(v) > value(w) && !is_base(w) && m_vars[w].contains(value(v)))
|
||||||
update_value(w, value(v) - value(w));
|
update_value(w, value(v) - value(w));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1475,6 +1474,7 @@ namespace polysat {
|
||||||
if (s == null_var)
|
if (s == null_var)
|
||||||
continue;
|
continue;
|
||||||
SASSERT(i == base2row(s).id());
|
SASSERT(i == base2row(s).id());
|
||||||
|
|
||||||
VERIFY(well_formed_row(r));
|
VERIFY(well_formed_row(r));
|
||||||
}
|
}
|
||||||
for (unsigned i = 0; i < m_vars.size(); ++i) {
|
for (unsigned i = 0; i < m_vars.size(); ++i) {
|
||||||
|
|
|
@ -289,7 +289,7 @@ namespace simplex {
|
||||||
col_entries_t col_entries(int v) { return col_entries_t(*this, v); }
|
col_entries_t col_entries(int v) { return col_entries_t(*this, v); }
|
||||||
|
|
||||||
void display(std::ostream& out);
|
void display(std::ostream& out);
|
||||||
void display_row(std::ostream& out, row const& r);
|
void display_row(std::ostream& out, row const& r) const;
|
||||||
bool well_formed() const;
|
bool well_formed() const;
|
||||||
|
|
||||||
void collect_statistics(::statistics & st) const;
|
void collect_statistics(::statistics & st) const;
|
||||||
|
|
|
@ -339,6 +339,10 @@ namespace simplex {
|
||||||
r_entry.m_var = v; \
|
r_entry.m_var = v; \
|
||||||
m.set(r_entry.m_coeff, it->m_coeff); \
|
m.set(r_entry.m_coeff, it->m_coeff); \
|
||||||
_SET_COEFF_; \
|
_SET_COEFF_; \
|
||||||
|
if (m.is_zero(r_entry.m_coeff)) { \
|
||||||
|
r1.del_row_entry(row_idx); \
|
||||||
|
continue; \
|
||||||
|
} \
|
||||||
column & c = m_columns[v]; \
|
column & c = m_columns[v]; \
|
||||||
int col_idx; \
|
int col_idx; \
|
||||||
col_entry & c_entry = c.add_col_entry(col_idx); \
|
col_entry & c_entry = c.add_col_entry(col_idx); \
|
||||||
|
@ -415,11 +419,25 @@ namespace simplex {
|
||||||
neg(r);
|
neg(r);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
bool has0 = false;
|
||||||
row_iterator it = row_begin(r);
|
row_iterator it = row_begin(r);
|
||||||
row_iterator end = row_end(r);
|
row_iterator end = row_end(r);
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
m.mul(it->m_coeff, n, it->m_coeff);
|
m.mul(it->m_coeff, n, it->m_coeff);
|
||||||
}
|
has0 |= m.is_zero(it->m_coeff);
|
||||||
|
}
|
||||||
|
if (has0) {
|
||||||
|
unsigned idx = 0;
|
||||||
|
unsigned_vector idxs;
|
||||||
|
_row& row = m_rows[r.id()];
|
||||||
|
for (auto const& e : row.m_entries) {
|
||||||
|
if (!e.is_dead() && m.is_zero(e.m_coeff))
|
||||||
|
idxs.push_back(idx);
|
||||||
|
++idx;
|
||||||
|
}
|
||||||
|
for (unsigned idx : idxs)
|
||||||
|
del_row_entry(row, idx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +510,7 @@ namespace simplex {
|
||||||
if (e.is_dead()) {
|
if (e.is_dead()) {
|
||||||
dead.insert(i);
|
dead.insert(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DEBUG_CODE(
|
DEBUG_CODE(
|
||||||
SASSERT(!vars.contains(e.var()));
|
SASSERT(!vars.contains(e.var()));
|
||||||
SASSERT(!m.is_zero(e.m_coeff));
|
SASSERT(!m.is_zero(e.m_coeff));
|
||||||
|
@ -558,17 +576,18 @@ namespace simplex {
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
void sparse_matrix<Ext>::display(std::ostream& out) {
|
void sparse_matrix<Ext>::display(std::ostream& out) {
|
||||||
for (unsigned i = 0; i < m_rows.size(); ++i) {
|
for (unsigned i = 0; i < m_rows.size(); ++i) {
|
||||||
if (m_rows[i].size() == 0) continue;
|
if (m_rows[i].size() != 0)
|
||||||
display_row(out, row(i));
|
display_row(out, row(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
void sparse_matrix<Ext>::display_row(std::ostream& out, row const& r) {
|
void sparse_matrix<Ext>::display_row(std::ostream& out, row const& r) const {
|
||||||
row_iterator it = row_begin(r), end = row_end(r);
|
for (auto const& e : m_rows[r.id()].m_entries) {
|
||||||
for (; it != end; ++it) {
|
if (!e.is_dead()) {
|
||||||
m.display(out, it->coeff());
|
m.display(out, e.coeff());
|
||||||
out << "*v" << it->var() << " ";
|
out << "*v" << e.var() << " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out << "\n";
|
out << "\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue