mirror of
https://github.com/Z3Prover/z3
synced 2025-11-26 07:29:33 +00:00
outline for adding monomials
This commit is contained in:
parent
a6ea667776
commit
6adb234673
14 changed files with 242 additions and 140 deletions
|
|
@ -9,28 +9,20 @@ namespace nla {
|
|||
template <typename T>
|
||||
bool check_assignment(T const& m, variable_map_type & vars) {
|
||||
rational r1 = vars[m.var()];
|
||||
if (r1.is_zero()) {
|
||||
for (auto w : m.vars()) {
|
||||
if (vars[w].is_zero())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (r1.is_zero())
|
||||
return any_of(m.vars(), [&](auto w) { return vars[w].is_zero(); });
|
||||
rational r2(1);
|
||||
for (auto w : m.vars()) {
|
||||
r2 *= vars[w];
|
||||
}
|
||||
for (auto w : m.vars())
|
||||
r2 *= vars[w];
|
||||
return r1 == r2;
|
||||
}
|
||||
|
||||
template <typename K>
|
||||
bool check_assignments(const K & monomials,
|
||||
const lp::lar_solver& s,
|
||||
variable_map_type & vars) {
|
||||
s.get_model(vars);
|
||||
for (auto const& m : monomials) {
|
||||
if (!check_assignment(m, vars)) return false;
|
||||
}
|
||||
return true;
|
||||
return all_of(monomials, [&](auto const& m) { return check_assignment(m, vars); });
|
||||
}
|
||||
|
||||
template bool check_assignments<vector<mon_eq>>(const vector<mon_eq>&,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue