3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-19 10:52:02 +00:00

fix a bug in gt_on_powers_mul_same_degree()

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2020-01-08 09:59:14 -08:00
parent 2b7393778e
commit 35efc91aff

View file

@ -109,6 +109,7 @@ void nex_creator::simplify_children_of_mul(vector<nex_pow> & children, rational&
template <typename T> template <typename T>
bool nex_creator::gt_on_powers_mul_same_degree(const T& a, const nex_mul& b) const { bool nex_creator::gt_on_powers_mul_same_degree(const T& a, const nex_mul& b) const {
bool ret = false; bool ret = false;
std::cout << "'";
unsigned a_pow = a.begin()->pow(); unsigned a_pow = a.begin()->pow();
unsigned b_pow = b.begin()->pow(); unsigned b_pow = b.begin()->pow();
for (auto it_a = a.begin(), it_b = b.begin(); it_a != a.end() && it_b != b.end(); ) { for (auto it_a = a.begin(), it_b = b.begin(); it_a != a.end() && it_b != b.end(); ) {
@ -120,24 +121,19 @@ bool nex_creator::gt_on_powers_mul_same_degree(const T& a, const nex_mul& b) con
ret = false; ret = false;
break; break;
} }
if (a_pow > b_pow) { // b should be advanced if (a_pow > b_pow) {
b_pow -= a_pow;
++it_b;
if (it_b != b.end()) b_pow = it_b->pow();
ret = true; ret = true;
break;
} }
else if (a_pow < b_pow) { // a should be advanced if (a_pow < b_pow) {
b_pow -= a_pow;
++it_a;
if (it_a != a.end()) a_pow = it_a->pow();
ret = false; ret = false;
break;
} }
else {
++it_a; ++it_a;
++it_b; ++it_b;
if (it_a != a.end()) a_pow = it_a->pow(); if (it_a != a.end()) a_pow = it_a->pow();
if (it_b != b.end()) b_pow = it_b->pow(); if (it_b != b.end()) b_pow = it_b->pow();
}
} }
TRACE("nex_gt", tout << "a = "; print_vector(a, tout) << (ret?" > ":" <= ") << b << "\n";); TRACE("nex_gt", tout << "a = "; print_vector(a, tout) << (ret?" > ":" <= ") << b << "\n";);
return ret; return ret;