Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Mar 5, 2024
1 parent 7dc4ce8 commit ab0459e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
37 changes: 21 additions & 16 deletions src/ast/sls/bv_sls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -199,6 +203,7 @@ namespace bv {
mdl->register_decl(f, bv.mk_numeral(n, v.bw));
}
}
terms.reset();
return mdl;
}

Expand Down
1 change: 1 addition & 0 deletions src/ast/sls/bv_sls.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace bv {

lbool search();
void reinit_eval();
void init_repair();
void trace();

public:
Expand Down
2 changes: 1 addition & 1 deletion src/ast/sls/bv_sls_eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/ast/sls/bv_sls_fixed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/ast/sls/bv_sls_terms.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()); }

};
Expand Down
3 changes: 2 additions & 1 deletion src/ast/sls/sls_valuation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit ab0459e

Please sign in to comment.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy