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

patch for Sturm sequence bug #4961

This commit is contained in:
Nikolaj Bjorner 2021-01-24 12:58:25 -08:00
parent 2d1684bc2d
commit 7d60d8462d
4 changed files with 124 additions and 114 deletions

View file

@ -71,20 +71,15 @@ namespace nlsat {
}
bool check_interval(anum_manager & am, interval const & i) {
if (i.m_lower_inf) {
SASSERT(i.m_lower_open);
}
if (i.m_upper_inf) {
SASSERT(i.m_upper_open);
}
SASSERT(!i.m_lower_inf || i.m_lower_open);
SASSERT(!i.m_upper_inf || i.m_upper_open);
if (!i.m_lower_inf && !i.m_upper_inf) {
auto s = am.compare(i.m_lower, i.m_upper);
TRACE("nlsat_interval", tout << "lower: "; am.display_decimal(tout, i.m_lower); tout << ", upper: "; am.display_decimal(tout, i.m_upper);
tout << "\ns: " << s << "\n";);
SASSERT(s <= 0);
if (::is_zero(s)) {
SASSERT(!i.m_lower_open && !i.m_upper_open);
}
SASSERT(!is_zero(s) || !i.m_lower_open && !i.m_upper_open);
}
return true;
}
@ -92,12 +87,10 @@ namespace nlsat {
bool check_no_overlap(anum_manager & am, interval const & curr, interval const & next) {
SASSERT(!curr.m_upper_inf);
SASSERT(!next.m_lower_inf);
int sign = am.compare(curr.m_upper, next.m_lower);
CTRACE("nlsat", sign > 0, display(tout, am, curr); tout << " "; display(tout, am, next); tout << "\n";);
SASSERT(sign <= 0);
if (sign == 0) {
SASSERT(curr.m_upper_open || next.m_lower_open);
}
sign s = am.compare(curr.m_upper, next.m_lower);
CTRACE("nlsat", s > 0, display(tout, am, curr); tout << " "; display(tout, am, next); tout << "\n";);
SASSERT(s <= 0);
SASSERT(!is_zero(s) || curr.m_upper_open || next.m_lower_open);
return true;
}
@ -107,9 +100,7 @@ namespace nlsat {
for (unsigned i = 0; i < sz; i++) {
interval const & curr = ints[i];
SASSERT(check_interval(am, curr));
if (i < sz - 1) {
SASSERT(check_no_overlap(am, curr, ints[i+1]));
}
SASSERT(i >= sz - 1 || check_no_overlap(am, curr, ints[i+1]));
});
return true;
}
@ -276,10 +267,9 @@ namespace nlsat {
interval_set * interval_set_manager::mk_union(interval_set const * s1, interval_set const * s2) {
#if 0
// issue #2867:
static unsigned s_count = 0;
s_count++;
if (s_count == 8442) {
if (s_count == 4470) {
enable_trace("nlsat_interval");
enable_trace("algebraic");
}
@ -416,7 +406,7 @@ namespace nlsat {
else {
SASSERT(l1_l2_sign > 0);
if (u1_u2_sign == 0) {
TRACE("nlsat_interval", tout << "l1_l2_sign > 0, u1_u2_sign == 0\n";);
TRACE("nlsat_interval", tout << "l2 < l1 <= u1 = u2\n";);
// Case:
// 1) [ ]
// [ ]
@ -426,7 +416,7 @@ namespace nlsat {
i2++;
}
else if (u1_u2_sign < 0) {
TRACE("nlsat_interval", tout << "l1_l2_sign > 0, u1_u2_sign > 0\n";);
TRACE("nlsat_interval", tout << "l2 < l1 <= u2 < u2\n";);
// Case:
// 1) [ ]
// [ ]
@ -436,7 +426,7 @@ namespace nlsat {
else {
auto u2_l1_sign = compare_upper_lower(m_am, int2, int1);
if (u2_l1_sign < 0) {
TRACE("nlsat_interval", tout << "l1_l2_sign > 0, u1_u2_sign > 0, u2_l1_sign < 0\n";);
TRACE("nlsat_interval", tout << "l2 <= u2 < l1 <= u1\n";);
// Case:
// 1) [ ]
// [ ]
@ -457,7 +447,7 @@ namespace nlsat {
i2++;
}
else {
TRACE("nlsat_interval", tout << "l1_l2_sign > 0, u1_u2_sign > 0, u2_l1_sign > 0\n";);
TRACE("nlsat_interval", tout << "l2 < l1 < u2 < u1\n";);
SASSERT(l1_l2_sign > 0);
SASSERT(u1_u2_sign > 0);
SASSERT(u2_l1_sign > 0);
@ -474,6 +464,7 @@ namespace nlsat {
}
SASSERT(result.size() <= 1 ||
check_no_overlap(m_am, result[result.size() - 2], result[result.size() - 1]));
}
SASSERT(!result.empty());