mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
bug fixes
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9cce1ff836
commit
6103c9d718
9 changed files with 124 additions and 21 deletions
|
@ -320,7 +320,8 @@ namespace polysat {
|
|||
if (!is_assigned(v0) || is_assigned(v1))
|
||||
continue;
|
||||
// detect unitary, add to viable, detect conflict?
|
||||
m_viable.add_unitary(v1, idx);
|
||||
if (value != l_undef)
|
||||
m_viable.add_unitary(v1, idx);
|
||||
}
|
||||
SASSERT(m_watch[v].size() == sz && "size of watch list was not changed");
|
||||
m_watch[v].shrink(j);
|
||||
|
@ -347,16 +348,20 @@ namespace polysat {
|
|||
}
|
||||
|
||||
dependency core::get_dependency(constraint_id idx) const {
|
||||
if (idx.is_null())
|
||||
return null_dependency;
|
||||
auto [sc, d, value] = m_constraint_index[idx.id];
|
||||
return d;
|
||||
}
|
||||
|
||||
#if 0
|
||||
dependency_vector core::get_dependencies(constraint_id_vector const& ids) const {
|
||||
dependency_vector result;
|
||||
for (auto id : ids)
|
||||
result.push_back(get_dependency(id));
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
void core::propagate(constraint_id id, signed_constraint& sc, lbool value, dependency const& d) {
|
||||
lbool eval_value = eval(sc);
|
||||
|
@ -442,8 +447,9 @@ namespace polysat {
|
|||
out << "polysat:\n";
|
||||
for (auto const& [sc, d, value] : m_constraint_index)
|
||||
out << sc << " " << d << " := " << value << "\n";
|
||||
for (unsigned i = 0; i < m_vars.size(); ++i)
|
||||
for (unsigned i = 0; i < m_vars.size(); ++i) {
|
||||
out << m_vars[i] << " := " << m_values[i] << " " << get_dependency(m_justification[i]) << "\n";
|
||||
}
|
||||
m_var_queue.display(out << "vars ") << "\n";
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace polysat {
|
|||
dependency_vector const& unsat_core() const { return m_unsat_core; }
|
||||
constraint_id_vector const& assigned_constraints() const { return m_prop_queue; }
|
||||
dependency get_dependency(constraint_id idx) const;
|
||||
dependency_vector get_dependencies(constraint_id_vector const& ids) const;
|
||||
// dependency_vector get_dependencies(constraint_id_vector const& ids) const;
|
||||
lbool eval(constraint_id id);
|
||||
dependency propagate(signed_constraint const& sc, dependency_vector const& deps) { return s.propagate(sc, deps); }
|
||||
lbool eval(signed_constraint const& sc);
|
||||
|
|
|
@ -110,7 +110,9 @@ namespace polysat {
|
|||
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, offset_slice const& js) {
|
||||
return out << "v" << js.v << "[" << js.offset << "[ @";
|
||||
if (js.offset == 0)
|
||||
return out << "v" << js.v;
|
||||
return out << "v" << js.v << " at offset " << js.offset;
|
||||
}
|
||||
|
||||
using fixed_bits_vector = svector<fixed_slice>;
|
||||
|
|
|
@ -84,6 +84,7 @@ namespace polysat {
|
|||
}
|
||||
|
||||
find_t viable::find_viable(pvar v, rational& lo) {
|
||||
display(verbose_stream() << "find viable for v" << v << "\n");
|
||||
rational hi;
|
||||
switch (find_viable(v, lo, hi)) {
|
||||
case l_true:
|
||||
|
@ -99,7 +100,6 @@ namespace polysat {
|
|||
m_overlaps.reset();
|
||||
c.get_bitvector_suffixes(v, m_overlaps);
|
||||
std::sort(m_overlaps.begin(), m_overlaps.end(), [&](auto const& x, auto const& y) { return c.size(x.v) < c.size(y.v); });
|
||||
LOG("Overlaps with v" << v << ":" << m_overlaps);
|
||||
}
|
||||
|
||||
lbool viable::find_viable(pvar v, rational& val1, rational& val2) {
|
||||
|
@ -217,6 +217,8 @@ namespace polysat {
|
|||
}
|
||||
// TODO check if admitted: layer.entries = e;
|
||||
m_explain.push_back(e);
|
||||
if (e->interval.is_full())
|
||||
return l_false;
|
||||
auto hi = e->interval.hi_val();
|
||||
if (hi < val1) {
|
||||
if (is_zero)
|
||||
|
@ -868,6 +870,25 @@ namespace polysat {
|
|||
return out;
|
||||
}
|
||||
|
||||
std::ostream& viable::display(std::ostream& out) const {
|
||||
for (unsigned v = 0; v < m_units.size(); ++v) {
|
||||
bool first = true;
|
||||
for (auto const& layer : m_units[v].get_layers()) {
|
||||
if (!layer.entries)
|
||||
continue;
|
||||
if (first)
|
||||
out << "v" << v << ": ";
|
||||
first = false;
|
||||
if (layer.bit_width != c.size(v))
|
||||
out << "width[" << layer.bit_width << "] ";
|
||||
display_all(out, v, layer.entries, " ");
|
||||
}
|
||||
if (!first)
|
||||
out << "\n";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lower bounds are strictly ascending.
|
||||
* Intervals don't contain each-other (since lower bounds are ascending, it suffices to check containment in one direction).
|
||||
|
|
|
@ -158,6 +158,9 @@ namespace polysat {
|
|||
*/
|
||||
void ensure_var(pvar v);
|
||||
|
||||
|
||||
std::ostream& display(std::ostream& out) const;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ namespace polysat {
|
|||
m_intblast(ctx),
|
||||
m_lemma(ctx.get_manager())
|
||||
{
|
||||
// ctx.get_egraph().add_plugin(alloc(euf::bv_plugin, ctx.get_egraph()));
|
||||
m_bv_plugin = alloc(euf::bv_plugin, ctx.get_egraph());
|
||||
ctx.get_egraph().add_plugin(m_bv_plugin);
|
||||
}
|
||||
|
||||
unsigned solver::get_bv_size(euf::enode* n) {
|
||||
|
@ -120,6 +121,20 @@ namespace polysat {
|
|||
auto lit = sat::literal(bv, s().value(bv) == l_false);
|
||||
core.push_back(lit);
|
||||
}
|
||||
else if (d.is_fixed_claim()) {
|
||||
auto const& o = d.fixed();
|
||||
std::function<void(euf::enode*, euf::enode*)> consume = [&](auto* a, auto* b) {
|
||||
eqs.push_back({ a, b });
|
||||
};
|
||||
explain_fixed(o.v, o.lo, o.hi, o.value, consume);
|
||||
}
|
||||
else if (d.is_offset_claim()) {
|
||||
auto const& offs = d.offset();
|
||||
std::function<void(euf::enode*, euf::enode*)> consume = [&](auto* a, auto* b) {
|
||||
eqs.push_back({ a, b });
|
||||
};
|
||||
explain_slice(offs.v, offs.w, offs.offset, consume);
|
||||
}
|
||||
else {
|
||||
auto const [v1, v2] = d.eq();
|
||||
euf::enode* const n1 = var2enode(v1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue