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

fi disequal: add special treatment for v > -a*v

This commit is contained in:
Jakob Rath 2022-01-24 17:03:49 +01:00
parent 7d3308b00e
commit 8c2f268506
2 changed files with 48 additions and 3 deletions

View file

@ -327,10 +327,31 @@ namespace polysat {
};
if (lhs > rhs || (e->src.is_negative() && lhs == rhs)) {
rational lo = val - delta_l(val);
rational hi = val + delta_u(val) + 1;
rational lo;
rational hi;
// TODO: extract into separate function
if (e->src.is_negative() && a2.is_one() && b1.is_zero() && b2.is_zero()) {
// special case: v > -a*v for some numeral a
rational const& a = mod(-a1, mod_value);
if (val.is_zero()) {
lo = 0;
hi = ceil( (mod_value + 1) / (a + 1) );
} else {
rational const y = mod(-a * val, mod_value);
lo = ceil( val + (y - max_value) / a );
hi = ceil( (y + a*val + 1) / (a + 1) );
// can always extend to 0
if (lo.is_one())
lo = 0;
}
} else {
// general case
lo = val - delta_l(val);
hi = val + delta_u(val) + 1;
// TODO: increase interval
}
// TODO: increase interval
LOG("refine-disequal-lin: " << " [" << lo << ", " << hi << "[");
SASSERT(0 <= lo && lo <= val);