mirror of
https://github.com/Z3Prover/z3
synced 2025-06-27 08:28:44 +00:00
bugfixes
This commit is contained in:
parent
c467f093d0
commit
1a742ff784
5 changed files with 26 additions and 17 deletions
|
@ -337,17 +337,21 @@ namespace polysat {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream& monomials::monomial::display(std::ostream& out) const {
|
||||||
|
out << var << " := ";
|
||||||
|
char const* sep = "";
|
||||||
|
for (auto p : args)
|
||||||
|
if (p.is_var())
|
||||||
|
out << sep << p, sep = " * ";
|
||||||
|
else
|
||||||
|
out << sep << "(" << p << ")", sep = " * ";
|
||||||
|
out << "\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream& monomials::display(std::ostream& out) const {
|
std::ostream& monomials::display(std::ostream& out) const {
|
||||||
for (auto const& mon : m_monomials) {
|
for (auto const& mon : m_monomials)
|
||||||
out << mon.var << " := ";
|
mon.display(out);
|
||||||
char const* sep = "";
|
|
||||||
for (auto p : mon.args)
|
|
||||||
if (p.is_var())
|
|
||||||
out << sep << p, sep = " * ";
|
|
||||||
else
|
|
||||||
out << sep << "(" << p << ")", sep = " * ";
|
|
||||||
out << "\n";
|
|
||||||
}
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace polysat {
|
||||||
rational val;
|
rational val;
|
||||||
unsigned size() const { return args.size(); }
|
unsigned size() const { return args.size(); }
|
||||||
unsigned num_bits() const { return args[0].manager().power_of_2(); }
|
unsigned num_bits() const { return args[0].manager().power_of_2(); }
|
||||||
|
std::ostream& display(std::ostream& out) const;
|
||||||
};
|
};
|
||||||
vector<monomial> m_monomials;
|
vector<monomial> m_monomials;
|
||||||
pdd_vector m_tmp;
|
pdd_vector m_tmp;
|
||||||
|
@ -74,6 +75,7 @@ namespace polysat {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream& out, monomials const& m) {
|
inline std::ostream& operator<<(std::ostream& out, monomials const& m) {
|
||||||
return m.display(out);
|
return m.display(out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -793,12 +793,13 @@ namespace polysat {
|
||||||
|
|
||||||
struct solver::undo_add_eq : public trail {
|
struct solver::undo_add_eq : public trail {
|
||||||
solver& s;
|
solver& s;
|
||||||
|
unsigned sz;
|
||||||
unsigned index;
|
unsigned index;
|
||||||
public:
|
public:
|
||||||
undo_add_eq(solver& s, unsigned i) : s(s), index(i) {}
|
undo_add_eq(solver& s, unsigned sz, unsigned i) : s(s), sz(sz), index(i) {}
|
||||||
void undo() override {
|
void undo() override {
|
||||||
SASSERT(index == s.m_eqs.back().index());
|
SASSERT(index == s.m_eqs.back().index());
|
||||||
s.m_eq2constraint.remove(index);
|
s.m_eq2constraint[sz].remove(index);
|
||||||
s.m_eqs.pop_back();
|
s.m_eqs.pop_back();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -808,7 +809,9 @@ namespace polysat {
|
||||||
constraint_id idx;
|
constraint_id idx;
|
||||||
std::pair<constraint_id, bool> elem;
|
std::pair<constraint_id, bool> elem;
|
||||||
bool is_new = true;
|
bool is_new = true;
|
||||||
if (m_eq2constraint.find(r.index(), elem)) {
|
unsigned sz = r.manager().power_of_2();
|
||||||
|
m_eq2constraint.reserve(sz + 1);
|
||||||
|
if (m_eq2constraint[sz].find(r.index(), elem)) {
|
||||||
if (elem.second == sign)
|
if (elem.second == sign)
|
||||||
return elem.first;
|
return elem.first;
|
||||||
is_new = false;
|
is_new = false;
|
||||||
|
@ -816,9 +819,9 @@ namespace polysat {
|
||||||
auto sc = m_core.eq(p, q);
|
auto sc = m_core.eq(p, q);
|
||||||
idx = m_core.register_constraint(sc, d);
|
idx = m_core.register_constraint(sc, d);
|
||||||
if (is_new) {
|
if (is_new) {
|
||||||
m_eq2constraint.insert(r.index(), { idx, sign });
|
m_eq2constraint[sz].insert(r.index(), { idx, sign });
|
||||||
m_eqs.push_back(r);
|
m_eqs.push_back(r);
|
||||||
ctx.push(undo_add_eq(*this, r.index()));
|
ctx.push(undo_add_eq(*this, sz, r.index()));
|
||||||
}
|
}
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,9 +217,9 @@ namespace polysat {
|
||||||
m_var_eqs_head++;
|
m_var_eqs_head++;
|
||||||
pdd p = var2pdd(v1);
|
pdd p = var2pdd(v1);
|
||||||
pdd q = var2pdd(v2);
|
pdd q = var2pdd(v2);
|
||||||
TRACE("bv", tout << ctx.bpp(n) << " == " << ctx.bpp(var2enode(v2)) << "\n");
|
|
||||||
auto d = dependency(v1, v2);
|
auto d = dependency(v1, v2);
|
||||||
constraint_id id = eq_constraint(p, q, false, d);
|
constraint_id id = eq_constraint(p, q, false, d);
|
||||||
|
TRACE("bv", tout << ctx.bpp(n) << " == " << ctx.bpp(var2enode(v2)) << " " << d << "\n");
|
||||||
m_core.assign_eh(id, false);
|
m_core.assign_eh(id, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace polysat {
|
||||||
void quot_rem(expr* quot, expr* rem, expr* x, expr* y);
|
void quot_rem(expr* quot, expr* rem, expr* x, expr* y);
|
||||||
|
|
||||||
vector<pdd> m_eqs;
|
vector<pdd> m_eqs;
|
||||||
u_map<std::pair<constraint_id, bool>> m_eq2constraint;
|
vector<u_map<std::pair<constraint_id, bool>>> m_eq2constraint;
|
||||||
struct undo_add_eq;
|
struct undo_add_eq;
|
||||||
constraint_id eq_constraint(pdd p, pdd q, bool sign, dependency d);
|
constraint_id eq_constraint(pdd p, pdd q, bool sign, dependency d);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue