3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-06 01:24:08 +00:00
This commit is contained in:
Nikolaj Bjorner 2024-02-20 13:38:04 -08:00
parent 7dc4ce8259
commit ab0459e5aa
6 changed files with 29 additions and 20 deletions

View file

@ -38,13 +38,22 @@ namespace bv {
void sls::init_eval(std::function<bool(expr*, unsigned)>& 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()) {
if (!m_eval.bval0(e)) {
m_eval.set(e, true);
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() {
@ -64,14 +73,7 @@ namespace bv {
return m_rand() % 2 == 0;
};
m_eval.init_eval(m_terms.assertions(), eval);
m_repair_down.reset();
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());
}
}
init_repair();
}
std::pair<bool, app*> sls::next_to_repair() {
@ -95,12 +97,14 @@ namespace bv {
auto [down, e] = next_to_repair();
if (!e)
return l_true;
bool is_correct = eval_is_correct(e);
IF_VERBOSE(20, verbose_stream() << (down ? "d #" : "u #")
<< e->get_id() << ": "
<< mk_bounded_pp(e, m, 1) << " ";
if (bv.is_bv(e)) verbose_stream() << m_eval.wval0(e);
verbose_stream() << "\n");
if (eval_is_correct(e)) {
<< e->get_id() << ": "
<< mk_bounded_pp(e, m, 1) << " ";
if (bv.is_bv(e)) verbose_stream() << m_eval.wval0(e) << " ";
if (m.is_bool(e)) verbose_stream() << m_eval.bval0(e) << " ";
verbose_stream() << (is_correct?"C":"U") << "\n");
if (is_correct) {
if (down)
m_repair_down.remove(e->get_id());
else
@ -185,8 +189,8 @@ namespace bv {
model_ref sls::get_model() {
model_ref mdl = alloc(model, m);
m_eval.sort_assertions(m_terms.assertions());
for (expr* e : m_todo) {
auto& terms = m_eval.sort_assertions(m_terms.assertions());
for (expr* e : terms) {
if (!is_uninterp_const(e))
continue;
auto f = to_app(e)->get_decl();
@ -199,6 +203,7 @@ namespace bv {
mdl->register_decl(f, bv.mk_numeral(n, v.bw));
}
}
terms.reset();
return mdl;
}

View file

@ -59,6 +59,7 @@ namespace bv {
lbool search();
void reinit_eval();
void init_repair();
void trace();
public:

View file

@ -1020,7 +1020,7 @@ namespace bv {
unsigned parity_e = e.parity(e.bits);
unsigned parity_b = b.parity(b.bits);
#if 1
#if 0
auto& x = m_tmp;
auto& y = m_tmp2;

View file

@ -103,9 +103,9 @@ namespace bv {
else if (!sign && m.is_eq(e, s, t)) {
if (bv.is_numeral(s, a))
// 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))
init_range(s, -a, nullptr, rational(0), !sign);
init_range(s, -a, nullptr, rational(0), false);
}
else if (bv.is_bit2bool(e, s, idx)) {
auto& val = wval0(s);

View file

@ -67,6 +67,8 @@ namespace bv {
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()); }
};

View file

@ -243,9 +243,10 @@ namespace bv {
void sls_valuation::get_value(svector<digit_t> const& bits, rational& r) const {
rational p(1);
r = 0;
for (unsigned i = 0; i < nw; ++i) {
r += p * rational(bits[i]);
p *= rational::power_of_two(bw);
p *= rational::power_of_two(8*sizeof(digit_t));
}
}