mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 19:35:50 +00:00
propagate cheap eqs
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
865dfe0590
commit
1e4e887221
5 changed files with 78 additions and 82 deletions
|
@ -13,9 +13,8 @@ Abstract:
|
|||
In the same loop trying to pin variables by pushing the partial sum up, denoting the variable related to it by _l
|
||||
|
||||
Author:
|
||||
|
||||
Lev Nachmanson (levnach)
|
||||
|
||||
Lev Nachmanson (levnach)
|
||||
Nikolaj Bjorner (nbjorner)
|
||||
Revision History:
|
||||
|
||||
|
||||
|
@ -31,7 +30,7 @@ template <typename C, typename B> // C plays a role of a container, B - lp_bound
|
|||
class bound_analyzer_on_row {
|
||||
const C& m_row;
|
||||
B & m_bp;
|
||||
unsigned m_row_or_term_index;
|
||||
unsigned m_row_index;
|
||||
int m_column_of_u; // index of an unlimited from above monoid
|
||||
// -1 means that such a value is not found, -2 means that at least two of such monoids were found
|
||||
int m_column_of_l; // index of an unlimited from below monoid
|
||||
|
@ -48,7 +47,7 @@ public :
|
|||
:
|
||||
m_row(it),
|
||||
m_bp(bp),
|
||||
m_row_or_term_index(row_or_term_index),
|
||||
m_row_index(row_or_term_index),
|
||||
m_column_of_u(-1),
|
||||
m_column_of_l(-1),
|
||||
m_rs(rs)
|
||||
|
@ -62,7 +61,7 @@ public :
|
|||
B & bp) {
|
||||
bound_analyzer_on_row a(row, bj, rs, row_or_term_index, bp);
|
||||
a.analyze();
|
||||
// TBD: a.analyze_eq();
|
||||
a.analyze_eq();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -84,37 +83,6 @@ private:
|
|||
limit_all_monoids_from_above();
|
||||
}
|
||||
|
||||
|
||||
void analyze_eq() {
|
||||
lpvar x = null_lpvar, y = null_lpvar;
|
||||
for (const auto & c : m_row) {
|
||||
if (m_bp.get_column_type(c.var()) == column_type::fixed)
|
||||
continue;
|
||||
if (x == null_lpvar && c.coeff().is_one())
|
||||
x = c.var();
|
||||
else if (y == null_lpvar && c.coeff().is_minus_one())
|
||||
y = c.var();
|
||||
else
|
||||
return;
|
||||
}
|
||||
if (x == null_lpvar || y == null_lpvar)
|
||||
return;
|
||||
impq value;
|
||||
for (const auto & c : m_row) {
|
||||
if (m_bp.get_column_type(c.var()) == column_type::fixed)
|
||||
value += c.coeff() * lb(c.var());
|
||||
}
|
||||
if (!value.is_zero()) {
|
||||
// insert / check offset table to infer equalities
|
||||
// of the form y = z from offset table collision:
|
||||
// value = (x - y)
|
||||
// value = (x - z)
|
||||
}
|
||||
else {
|
||||
// m_bp.try_add_fixed(x, y, m_row_or_term_index);
|
||||
}
|
||||
}
|
||||
|
||||
bool bound_is_available(unsigned j, bool lower_bound) {
|
||||
return (lower_bound && lower_bound_is_available(j)) ||
|
||||
(!lower_bound && upper_bound_is_available(j));
|
||||
|
@ -327,7 +295,7 @@ private:
|
|||
// }
|
||||
|
||||
void limit_j(unsigned j, const mpq& u, bool coeff_before_j_is_pos, bool is_lower_bound, bool strict){
|
||||
m_bp.try_add_bound(u, j, is_lower_bound, coeff_before_j_is_pos, m_row_or_term_index, strict);
|
||||
m_bp.try_add_bound(u, j, is_lower_bound, coeff_before_j_is_pos, m_row_index, strict);
|
||||
}
|
||||
|
||||
void advance_u(unsigned j) {
|
||||
|
@ -361,6 +329,24 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void analyze_eq() {
|
||||
unsigned x = UINT_MAX, y = UINT_MAX;
|
||||
unsigned k = 0;
|
||||
for (const auto& c : m_row) {
|
||||
if (!m_bp.lp().column_is_fixed(c.var())) {
|
||||
if (x == UINT_MAX && c.coeff().is_one())
|
||||
x = k;
|
||||
else if (y == UINT_MAX && c.coeff().is_minus_one())
|
||||
y = k;
|
||||
else
|
||||
return;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
if (x == UINT_MAX || y == UINT_MAX)
|
||||
return;
|
||||
m_bp.try_create_eq(x, y, m_row_index);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue