3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

fix nex simplification

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2019-10-02 17:14:34 -07:00
parent 43294cea16
commit a888e79696
3 changed files with 18 additions and 8 deletions

View file

@ -61,15 +61,15 @@ nex * nex_creator::mk_div(const nex* a, lpvar j) {
return mk_mul(bv);
}
bool nex_creator::eat_scalar_pow(nex_scalar *& r, nex_pow& p) {
bool nex_creator::eat_scalar_pow(nex_scalar *& r, nex_pow& p, unsigned pow) {
if (!p.e()->is_scalar())
return false;
nex_scalar *pe = to_scalar(p.e());
if (r == nullptr) {
r = pe;
r->value() = r->value().expt(p.pow());
r->value() = r->value().expt(p.pow()*pow);
} else {
r->value() *= pe->value().expt(p.pow());
r->value() *= pe->value().expt(p.pow()*pow);
}
return true;
}
@ -82,7 +82,7 @@ void nex_creator::simplify_children_of_mul(vector<nex_pow> & children) {
int skipped = 0;
for(unsigned j = 0; j < children.size(); j++) {
nex_pow& p = children[j];
if (eat_scalar_pow(r, p)) {
if (eat_scalar_pow(r, p, 1)) {
skipped++;
continue;
}
@ -101,8 +101,10 @@ void nex_creator::simplify_children_of_mul(vector<nex_pow> & children) {
children.shrink(children.size() - to_promote.size() - skipped);
for (nex_pow & p : to_promote) {
TRACE("nla_cn_details", tout << p << "\n";);
for (nex_pow& pp : to_mul(p.e())->children()) {
if (!eat_scalar_pow(r, pp))
TRACE("nla_cn_details", tout << pp << "\n";);
if (!eat_scalar_pow(r, pp, p.pow()))
children.push_back(nex_pow(pp.e(), pp.pow() * p.pow()));
}
}

View file

@ -224,7 +224,7 @@ public:
void simplify_children_of_sum(ptr_vector<nex> & children);
bool eat_scalar_pow(nex_scalar *& r, nex_pow& p);
bool eat_scalar_pow(nex_scalar *& r, nex_pow& p, unsigned);
void simplify_children_of_mul(vector<nex_pow> & children, lt_on_vars lt, std::function<nex_scalar*()> mk_scalar);
bool lt(const nex* a, const nex* b) const;