3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

added updated bounds propagation

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2022-12-23 12:47:17 -08:00
parent 6f8fb39bc9
commit 9fefa0040f
3 changed files with 59 additions and 2 deletions

View file

@ -1199,6 +1199,10 @@ namespace polysat {
* - then index on patterns or features of literals?
*/
bool saturation::has_upper_bound(pvar x, conflict& core, rational& bound, signed_constraint& x_le_bound) {
bool found = s.m_viable.has_upper_bound(x, bound, x_le_bound);
verbose_stream() << "found " << found << "\n";
auto& m = s.var2pdd(x);
pdd y = s.var(x);
for (auto const& c : core) {
@ -1223,6 +1227,10 @@ namespace polysat {
}
bool saturation::has_lower_bound(pvar x, conflict& core, rational& bound, signed_constraint& x_ge_bound) {
bool found = s.m_viable.has_lower_bound(x, bound, x_ge_bound);
verbose_stream() << "found " << found << "\n";
auto& m = s.var2pdd(x);
pdd y = s.var(x);
for (auto const& c : core) {
@ -1314,10 +1322,9 @@ namespace polysat {
pdd b = a, c = a, y = a;
rational b_val, c_val, y_val, x_bound;
signed_constraint x_ge_bound, x_le_bound, b_bound, ax_bound;
if (is_AxB_l_Y(x, a_l_b, a, b, y) && y.is_val() && s.try_eval(b, b_val) && !y.is_zero() && !a.is_val()) {
if (is_AxB_l_Y(x, a_l_b, a, b, y) && s.try_eval(y, y_val) && s.try_eval(b, b_val) && !y_val.is_zero() && !a.is_val()) {
verbose_stream() << a_l_b << " a " << a << " b " << b << " := " << dd::val_pp(m, b_val, false) << " y " << y << "\n";
SASSERT(!a.is_zero());
y_val = y.val();
// define c := -b
c = -b;

View file

@ -643,6 +643,43 @@ namespace polysat {
return query<query_t::max_viable>(v, hi);
}
bool viable::has_upper_bound(pvar v, rational& out_hi, signed_constraint& out_c) {
entry const* first = m_units[v];
entry const* e = first;
do {
if (!e->refined) {
verbose_stream() << "has-upper-bound " << e->src << " " << e->interval << "\n";
auto const& lo = e->interval.lo();
auto const& hi = e->interval.hi();
if (lo.is_val() && hi.is_val() && lo.val() > hi.val()) {
out_c = e->src;
out_hi = lo.val() - 1;
return true;
}
}
e = e->next();
}
while (e != first);
return false;
}
bool viable::has_lower_bound(pvar v, rational& out_hi, signed_constraint& out_c) {
entry const* first = m_units[v];
entry const* e = first;
do {
if (!e->refined) {
verbose_stream() << "has-upper-bound " << e->src << " " << e->interval << "\n";
}
e = e->next();
}
while (e != first);
return false;
return false;
}
template <query_t mode>
lbool viable::query(pvar v, typename query_result<mode>::result_t& result) {
// max number of interval refinements before falling back to the univariate solver

View file

@ -184,6 +184,19 @@ namespace polysat {
*/
lbool max_viable(pvar v, rational& out_hi);
/**
* Query for an upper bound literal for v together with justification.
* @return true if a non-trivial upper bound is found, return justifying constraint.
*/
bool has_upper_bound(pvar v, rational& out_hi, signed_constraint& out_c);
/**
* Query for an lower bound literal for v together with justification.
* @return true if a non-trivial lower bound is found, return justifying constraint.
*/
bool has_lower_bound(pvar v, rational& out_hi, signed_constraint& out_c);
/**
* Find a next viable value for variable.
*/