3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-06 15:25:46 +00:00

find_upper_bound

This commit is contained in:
Jakob Rath 2021-09-08 18:40:29 +02:00
parent 64ce6cb5c1
commit 18411afda2
3 changed files with 29 additions and 12 deletions

View file

@ -65,25 +65,26 @@ namespace polysat {
push_c(core, c, reason);
}
#if 0
bool find_upper_bound(pvar x, signed_constraint& c, rational& bound) {
auto & bounds = s().cjust[x];
rational best_bound = -1;
/// Find smallest upper bound for the variable x, i.e., a constraint 'x <= bound' where the rhs is constant.
bool inf_saturate::find_upper_bound(pvar x, signed_constraint& c, rational& bound) {
auto& bounds = s().m_cjust[x];
rational best_bound(-1);
pdd y = s().var(x);
for (auto& b : bounds) {
inequality bound = b.as_inequality();
if (is_x_l_Y(x, bound, y) && y.is_value()) {
if (y.value() < best_bound) {
if (bound.is_strict)
value = y.value() - 1;
if (is_x_l_Y(x, bound, y) && y.is_val()) {
rational value = y.val();
if (bound.is_strict && value > 0) // TODO: should we return something for "x < 0"? (is always false, should lead to conflict earlier)
value = value - 1;
if (value < best_bound) {
best_bound = value;
c = bound;
c = b;
}
}
}
return best_bound != -1;
}
#endif
/// Add Ω*(x, y) to the conflict state.
///
/// @param[in] p bit width
@ -171,6 +172,14 @@ namespace polysat {
return i.lhs == s().var(v);
}
/*
* Match [x] x <= y
*/
bool inf_saturate::is_x_l_Y(pvar x, inequality const& c, pdd& y) {
y = c.rhs;
return is_g_v(x, c);
}
/*
* Match [x] y <= a*x
*/