Skip to content

Commit

Permalink
re-add bv_eq_axioms, fix #5842
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Mar 19, 2022
1 parent cfe02ed commit 964e513
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/smt/params/smt_params_helper.pyg
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def_module_params(module_name='smt',
('bv.enable_int2bv', BOOL, True, 'enable support for int2bv and bv2int operators'),
('bv.watch_diseq', BOOL, False, 'use watch lists instead of eager axioms for bit-vectors'),
('bv.delay', BOOL, True, 'delay internalize expensive bit-vector operations'),
('bv.eq_axioms', BOOL, True, 'enable redundant equality axioms for bit-vectors'),
('arith.random_initial_value', BOOL, False, 'use random initial values in the simplex-based procedure for linear arithmetic'),
('arith.solver', UINT, 6, 'arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination 4 - utvpi, 5 - infinitary lra, 6 - lra solver'),
('arith.nl', BOOL, True, '(incomplete) nonlinear arithmetic support based on Groebner basis and interval propagation, relevant only if smt.arith.solver=2'),
Expand Down
2 changes: 2 additions & 0 deletions src/smt/params/theory_bv_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void theory_bv_params::updt_params(params_ref const & _p) {
m_bv_reflect = p.bv_reflect();
m_bv_enable_int2bv2int = p.bv_enable_int2bv();
m_bv_delay = p.bv_delay();
m_bv_eq_axioms = p.bv_eq_axioms();
}

#define DISPLAY_PARAM(X) out << #X"=" << X << std::endl;
Expand All @@ -36,6 +37,7 @@ void theory_bv_params::display(std::ostream & out) const {
DISPLAY_PARAM(m_hi_div0);
DISPLAY_PARAM(m_bv_reflect);
DISPLAY_PARAM(m_bv_lazy_le);
DISPLAY_PARAM(m_bv_eq_axioms);
DISPLAY_PARAM(m_bv_cc);
DISPLAY_PARAM(m_bv_blast_max_size);
DISPLAY_PARAM(m_bv_enable_int2bv2int);
Expand Down
48 changes: 27 additions & 21 deletions src/smt/theory_bv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ namespace smt {
};

void theory_bv::add_fixed_eq(theory_var v1, theory_var v2) {
if (!params().m_bv_eq_axioms)
return;

if (v1 > v2) {
std::swap(v1, v2);
Expand Down Expand Up @@ -1150,6 +1152,8 @@ namespace smt {
}

void theory_bv::expand_diseq(theory_var v1, theory_var v2) {
if (!params().m_bv_eq_axioms)
return;

SASSERT(get_bv_size(v1) == get_bv_size(v2));
if (v1 > v2) {
Expand Down Expand Up @@ -1316,27 +1320,29 @@ namespace smt {
}
else {
ctx.assign(consequent, mk_bit_eq_justification(v1, v2, consequent, antecedent));

literal_vector lits;
lits.push_back(~consequent);
lits.push_back(antecedent);
literal eq = mk_eq(get_expr(v1), get_expr(v2), false);
lits.push_back(~eq);
//
// Issue #3035:
// merge_eh invokes assign_bit, which updates the propagation queue and includes the
// theory axiom for the propagated equality. When relevancy is non-zero, propagation may get
// lost on backtracking because the propagation queue is reset on conflicts.
// An alternative approach is to ensure the propagation queue is chronological with
// backtracking scopes (ie., it doesn't get reset, but shrunk to a previous level, and similar
// with a qhead indicator.
//
ctx.mark_as_relevant(lits[0]);
ctx.mark_as_relevant(lits[1]);
ctx.mark_as_relevant(lits[2]);
{
scoped_trace_stream _sts(*this, lits);
ctx.mk_th_axiom(get_id(), lits.size(), lits.data());
if (params().m_bv_eq_axioms) {

literal_vector lits;
lits.push_back(~consequent);
lits.push_back(antecedent);
literal eq = mk_eq(get_expr(v1), get_expr(v2), false);
lits.push_back(~eq);
//
// Issue #3035:
// merge_eh invokes assign_bit, which updates the propagation queue and includes the
// theory axiom for the propagated equality. When relevancy is non-zero, propagation may get
// lost on backtracking because the propagation queue is reset on conflicts.
// An alternative approach is to ensure the propagation queue is chronological with
// backtracking scopes (ie., it doesn't get reset, but shrunk to a previous level, and similar
// with a qhead indicator.
//
ctx.mark_as_relevant(lits[0]);
ctx.mark_as_relevant(lits[1]);
ctx.mark_as_relevant(lits[2]);
{
scoped_trace_stream _sts(*this, lits);
ctx.mk_th_axiom(get_id(), lits.size(), lits.data());
}
}

if (m_wpos[v2] == idx)
Expand Down

0 comments on commit 964e513

Please sign in to comment.