mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 13:28:47 +00:00
more efficient code in has_common_factor
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
ccc9a77a1f
commit
0ba8940ae7
|
@ -81,9 +81,16 @@ public:
|
||||||
static bool has_common_factor(const nex& c) {
|
static bool has_common_factor(const nex& c) {
|
||||||
TRACE("nla_cn", tout << "c=" << c << "\n";);
|
TRACE("nla_cn", tout << "c=" << c << "\n";);
|
||||||
SASSERT(c.is_sum());
|
SASSERT(c.is_sum());
|
||||||
unsigned size = c.children().size();
|
auto & ch = c.children();
|
||||||
for(const auto & p : get_mult_occurences(c)) {
|
auto common_vars = get_vars_of_expr(ch[0]);
|
||||||
if (p.second.m_occs == size) {
|
for (lpvar j : common_vars) {
|
||||||
|
bool divides_the_rest = true;
|
||||||
|
for(unsigned i = 1; i < ch.size() && divides_the_rest; i++) {
|
||||||
|
if (!ch[i].contains(j))
|
||||||
|
divides_the_rest = false;
|
||||||
|
}
|
||||||
|
if (divides_the_rest) {
|
||||||
|
TRACE("nla_cn_common_factor", tout << c << "\n";);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,13 +348,14 @@ public:
|
||||||
to explore only such variables to create all cross-nested forms.
|
to explore only such variables to create all cross-nested forms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (has_common_factor(a))
|
if (has_common_factor(a)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
update_front_with_split(e, j, front, a, b);
|
update_front_with_split(e, j, front, a, b);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
std::set<lpvar> get_vars_of_expr(const nex &e ) const {
|
static std::unordered_set<lpvar> get_vars_of_expr(const nex &e ) {
|
||||||
std::set<lpvar> r;
|
std::unordered_set<lpvar> r;
|
||||||
switch (e.type()) {
|
switch (e.type()) {
|
||||||
case expr_type::SCALAR:
|
case expr_type::SCALAR:
|
||||||
return r;
|
return r;
|
||||||
|
@ -367,7 +375,6 @@ public:
|
||||||
SASSERT(false);
|
SASSERT(false);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,6 @@ public:
|
||||||
intervals::interval interval_of_mul(const nex&);
|
intervals::interval interval_of_mul(const nex&);
|
||||||
void set_interval_for_scalar(intervals::interval&, const rational&);
|
void set_interval_for_scalar(intervals::interval&, const rational&);
|
||||||
void set_var_interval(lpvar j, intervals::interval&);
|
void set_var_interval(lpvar j, intervals::interval&);
|
||||||
std::set<lpvar> get_vars_of_expr(const nex &) const;
|
|
||||||
bool lemmas_on_expr(nex &);
|
bool lemmas_on_expr(nex &);
|
||||||
}; // end of horner
|
}; // end of horner
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue