mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 03:45:51 +00:00
port Grobner
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
4651eb7042
commit
71c3a09f4a
4 changed files with 44 additions and 11 deletions
|
@ -443,6 +443,34 @@ inline std::ostream& operator<<(std::ostream& out, const nex& e ) {
|
|||
// return less_than_nex(a, b, lt);
|
||||
// }
|
||||
|
||||
inline rational get_nex_val(const nex* e, std::function<rational (unsigned)> var_val) {
|
||||
switch (e->type()) {
|
||||
case expr_type::SCALAR:
|
||||
return to_scalar(e)->value();
|
||||
case expr_type::SUM:
|
||||
{
|
||||
rational r(0);
|
||||
for (auto c: *to_sum(e)) {
|
||||
r += get_nex_val(c, var_val);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
case expr_type::MUL:
|
||||
{
|
||||
const nex_mul * m = to_mul(e);
|
||||
rational t = m->coeff();
|
||||
for (auto& c: *m)
|
||||
t *= get_nex_val(c.e(), var_val).expt(c.pow());
|
||||
return t;
|
||||
}
|
||||
case expr_type::VAR:
|
||||
return var_val(to_var(e)->var());
|
||||
default:
|
||||
TRACE("nla_cn_details", tout << e->type() << "\n";);
|
||||
SASSERT(false);
|
||||
return rational();
|
||||
}
|
||||
}
|
||||
|
||||
inline std::unordered_set<lpvar> get_vars_of_expr(const nex *e ) {
|
||||
std::unordered_set<lpvar> r;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue