mirror of
https://github.com/Z3Prover/z3
synced 2025-04-07 09:55:19 +00:00
bugfixes
This commit is contained in:
parent
7dc4ce8259
commit
ab0459e5aa
|
@ -38,13 +38,22 @@ namespace bv {
|
||||||
|
|
||||||
void sls::init_eval(std::function<bool(expr*, unsigned)>& eval) {
|
void sls::init_eval(std::function<bool(expr*, unsigned)>& eval) {
|
||||||
m_eval.init_eval(m_terms.assertions(), eval);
|
m_eval.init_eval(m_terms.assertions(), eval);
|
||||||
|
m_eval.init_fixed(m_terms.assertions());
|
||||||
|
init_repair();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sls::init_repair() {
|
||||||
|
m_repair_down.reset();
|
||||||
|
m_repair_up.reset();
|
||||||
for (auto* e : m_terms.assertions()) {
|
for (auto* e : m_terms.assertions()) {
|
||||||
if (!m_eval.bval0(e)) {
|
if (!m_eval.bval0(e)) {
|
||||||
m_eval.set(e, true);
|
m_eval.set(e, true);
|
||||||
m_repair_down.insert(e->get_id());
|
m_repair_down.insert(e->get_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_eval.init_fixed(m_terms.assertions());
|
for (app* t : m_terms.terms())
|
||||||
|
if (t && !eval_is_correct(t))
|
||||||
|
m_repair_down.insert(t->get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
void sls::reinit_eval() {
|
void sls::reinit_eval() {
|
||||||
|
@ -64,14 +73,7 @@ namespace bv {
|
||||||
return m_rand() % 2 == 0;
|
return m_rand() % 2 == 0;
|
||||||
};
|
};
|
||||||
m_eval.init_eval(m_terms.assertions(), eval);
|
m_eval.init_eval(m_terms.assertions(), eval);
|
||||||
m_repair_down.reset();
|
init_repair();
|
||||||
m_repair_up.reset();
|
|
||||||
for (auto* e : m_terms.assertions()) {
|
|
||||||
if (!m_eval.bval0(e)) {
|
|
||||||
m_eval.set(e, true);
|
|
||||||
m_repair_down.insert(e->get_id());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<bool, app*> sls::next_to_repair() {
|
std::pair<bool, app*> sls::next_to_repair() {
|
||||||
|
@ -95,12 +97,14 @@ namespace bv {
|
||||||
auto [down, e] = next_to_repair();
|
auto [down, e] = next_to_repair();
|
||||||
if (!e)
|
if (!e)
|
||||||
return l_true;
|
return l_true;
|
||||||
|
bool is_correct = eval_is_correct(e);
|
||||||
IF_VERBOSE(20, verbose_stream() << (down ? "d #" : "u #")
|
IF_VERBOSE(20, verbose_stream() << (down ? "d #" : "u #")
|
||||||
<< e->get_id() << ": "
|
<< e->get_id() << ": "
|
||||||
<< mk_bounded_pp(e, m, 1) << " ";
|
<< mk_bounded_pp(e, m, 1) << " ";
|
||||||
if (bv.is_bv(e)) verbose_stream() << m_eval.wval0(e);
|
if (bv.is_bv(e)) verbose_stream() << m_eval.wval0(e) << " ";
|
||||||
verbose_stream() << "\n");
|
if (m.is_bool(e)) verbose_stream() << m_eval.bval0(e) << " ";
|
||||||
if (eval_is_correct(e)) {
|
verbose_stream() << (is_correct?"C":"U") << "\n");
|
||||||
|
if (is_correct) {
|
||||||
if (down)
|
if (down)
|
||||||
m_repair_down.remove(e->get_id());
|
m_repair_down.remove(e->get_id());
|
||||||
else
|
else
|
||||||
|
@ -185,8 +189,8 @@ namespace bv {
|
||||||
|
|
||||||
model_ref sls::get_model() {
|
model_ref sls::get_model() {
|
||||||
model_ref mdl = alloc(model, m);
|
model_ref mdl = alloc(model, m);
|
||||||
m_eval.sort_assertions(m_terms.assertions());
|
auto& terms = m_eval.sort_assertions(m_terms.assertions());
|
||||||
for (expr* e : m_todo) {
|
for (expr* e : terms) {
|
||||||
if (!is_uninterp_const(e))
|
if (!is_uninterp_const(e))
|
||||||
continue;
|
continue;
|
||||||
auto f = to_app(e)->get_decl();
|
auto f = to_app(e)->get_decl();
|
||||||
|
@ -199,6 +203,7 @@ namespace bv {
|
||||||
mdl->register_decl(f, bv.mk_numeral(n, v.bw));
|
mdl->register_decl(f, bv.mk_numeral(n, v.bw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
terms.reset();
|
||||||
return mdl;
|
return mdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ namespace bv {
|
||||||
|
|
||||||
lbool search();
|
lbool search();
|
||||||
void reinit_eval();
|
void reinit_eval();
|
||||||
|
void init_repair();
|
||||||
void trace();
|
void trace();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1020,7 +1020,7 @@ namespace bv {
|
||||||
unsigned parity_e = e.parity(e.bits);
|
unsigned parity_e = e.parity(e.bits);
|
||||||
unsigned parity_b = b.parity(b.bits);
|
unsigned parity_b = b.parity(b.bits);
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
|
|
||||||
auto& x = m_tmp;
|
auto& x = m_tmp;
|
||||||
auto& y = m_tmp2;
|
auto& y = m_tmp2;
|
||||||
|
|
|
@ -103,9 +103,9 @@ namespace bv {
|
||||||
else if (!sign && m.is_eq(e, s, t)) {
|
else if (!sign && m.is_eq(e, s, t)) {
|
||||||
if (bv.is_numeral(s, a))
|
if (bv.is_numeral(s, a))
|
||||||
// t - a <= 0
|
// t - a <= 0
|
||||||
init_range(t, -a, nullptr, rational(0), !sign);
|
init_range(t, -a, nullptr, rational(0), false);
|
||||||
else if (bv.is_numeral(t, a))
|
else if (bv.is_numeral(t, a))
|
||||||
init_range(s, -a, nullptr, rational(0), !sign);
|
init_range(s, -a, nullptr, rational(0), false);
|
||||||
}
|
}
|
||||||
else if (bv.is_bit2bool(e, s, idx)) {
|
else if (bv.is_bit2bool(e, s, idx)) {
|
||||||
auto& val = wval0(s);
|
auto& val = wval0(s);
|
||||||
|
|
|
@ -67,6 +67,8 @@ namespace bv {
|
||||||
|
|
||||||
app* term(unsigned id) const { return m_terms.get(id); }
|
app* term(unsigned id) const { return m_terms.get(id); }
|
||||||
|
|
||||||
|
app_ref_vector const& terms() const { return m_terms; }
|
||||||
|
|
||||||
bool is_assertion(expr* e) const { return m_assertion_set.contains(e->get_id()); }
|
bool is_assertion(expr* e) const { return m_assertion_set.contains(e->get_id()); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -243,9 +243,10 @@ namespace bv {
|
||||||
|
|
||||||
void sls_valuation::get_value(svector<digit_t> const& bits, rational& r) const {
|
void sls_valuation::get_value(svector<digit_t> const& bits, rational& r) const {
|
||||||
rational p(1);
|
rational p(1);
|
||||||
|
r = 0;
|
||||||
for (unsigned i = 0; i < nw; ++i) {
|
for (unsigned i = 0; i < nw; ++i) {
|
||||||
r += p * rational(bits[i]);
|
r += p * rational(bits[i]);
|
||||||
p *= rational::power_of_two(bw);
|
p *= rational::power_of_two(8*sizeof(digit_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue