Skip to content

Commit

Permalink
block flips to units
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Jan 2, 2025
1 parent cb61af0 commit 814d7f4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/ast/sls/sls_bv_lookahead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ namespace sls {
return false;
expr* e = vars[ctx.rand(vars.size())];
if (m.is_bool(e)) {
auto v = ctx.atom2bool_var(e);
if (ctx.is_unit(v))
return false ;
TRACE("bv", tout << "random flip " << mk_bounded_pp(e, m) << "\n";);
ctx.flip(ctx.atom2bool_var(e));
ctx.flip(v);
return true;
}
SASSERT(bv.is_bv(e));
Expand All @@ -126,7 +129,10 @@ namespace sls {
expr* e = vars[ctx.rand(vars.size())];
if (m.is_bool(e)) {
TRACE("bv", tout << "random move flip " << mk_bounded_pp(e, m) << "\n";);
ctx.flip(ctx.atom2bool_var(e));
auto v = ctx.atom2bool_var(e);
if (ctx.is_unit(v))
return false;
ctx.flip(v);
return true;
}
SASSERT(bv.is_bv(e));
Expand Down Expand Up @@ -370,6 +376,8 @@ namespace sls {
}

double bv_lookahead::lookahead_flip(sat::bool_var v) {
if (ctx.is_unit(v))
return -100;
auto a = ctx.atom(v);
return lookahead_update(a, m_v_updated);
}
Expand Down Expand Up @@ -541,6 +549,8 @@ namespace sls {
auto v = ctx.atom2bool_var(e);
auto v1 = m_ev.bval1(to_app(e));
if (v != sat::null_bool_var) {
if (ctx.is_unit(v))
continue;
if (ctx.is_true(v) == v1)
continue;
TRACE("bv", tout << "update flip " << mk_bounded_pp(e, m) << "\n";);
Expand Down
2 changes: 1 addition & 1 deletion src/ast/sls/sls_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ namespace sls {
if (clause.m_clause.size() == 1)
m_unit_literals.push_back(clause.m_clause[0]);
for (sat::literal lit : m_unit_literals)
m_unit_indices.insert(lit.index());
m_unit_indices.insert(lit.var());

IF_VERBOSE(3, verbose_stream() << "UNITS " << m_unit_literals << "\n");
for (unsigned i = 0; i < m_atoms.size(); ++i)
Expand Down
3 changes: 2 additions & 1 deletion src/ast/sls/sls_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ namespace sls {
unsigned rand(unsigned n) { return m_rand(n); }
sat::literal_vector const& root_literals() const { return m_root_literals; }
sat::literal_vector const& unit_literals() const { return m_unit_literals; }
bool is_unit(sat::literal lit) const { return m_unit_indices.contains(lit.index()); }
bool is_unit(sat::literal lit) const { return is_unit(lit.var()); }
bool is_unit(sat::bool_var v) const { return m_unit_indices.contains(v); }
void reinit_relevant();
void force_restart() { s.force_restart(); }
bool include_func_interp(func_decl* f) const { return any_of(m_plugins, [&](plugin* p) { return p && p->include_func_interp(f); }); }
Expand Down

0 comments on commit 814d7f4

Please sign in to comment.