mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 11:55:51 +00:00
fix remove lar_solver::add_constraint
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
7cd90537c3
commit
3c5b1086a1
8 changed files with 164 additions and 122 deletions
|
@ -376,6 +376,47 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool sum_is_linear() const {
|
||||
SASSERT(is_sum());
|
||||
int degree = 0;
|
||||
for (auto & e : children()) {
|
||||
int d = e.get_degree();
|
||||
if (d > 1)
|
||||
return false;
|
||||
if (d > degree)
|
||||
degree = d;
|
||||
}
|
||||
return degree == 1;
|
||||
}
|
||||
|
||||
int get_degree() const {
|
||||
switch (type()) {
|
||||
case expr_type::SUM: {
|
||||
int degree = 0;
|
||||
for (auto & e : children()) {
|
||||
degree = std::max(degree, e.get_degree());
|
||||
}
|
||||
return degree;
|
||||
}
|
||||
|
||||
case expr_type::MUL: {
|
||||
int degree = 0;
|
||||
for (auto & e : children()) {
|
||||
degree += e.get_degree();
|
||||
}
|
||||
return degree;
|
||||
}
|
||||
case expr_type::VAR:
|
||||
return 1;
|
||||
case expr_type::SCALAR:
|
||||
return 0;
|
||||
case expr_type::UNDEF:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue