3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-13 20:38:43 +00:00

Fixed next_split call in pop (#6966)

* Give users ability to see if propagation failed

* Skip propagations in the new core if they are already satisfied

* Fix registration in final

* Don't make it too complicated...

* Fixed next_split when called in pop
Made delay_units available even without quantifiers

* Missing push calls before "decide"-callback
This commit is contained in:
Clemens Eisenhofer 2023-10-28 21:46:43 +02:00 committed by GitHub
parent 52d16a11f9
commit e7c17e68b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 32 deletions

View file

@ -4122,7 +4122,6 @@ namespace smt {
// Moreover, I backtrack only one level.
bool delay_forced_restart =
m_fparams.m_delay_units &&
internalized_quantifiers() &&
num_lits == 1 &&
conflict_lvl > m_search_lvl + 1 &&
!m.proofs_enabled() &&

View file

@ -79,7 +79,6 @@ void theory_user_propagator::add_expr(expr* term, bool ensure_enode) {
literal_vector explain;
if (ctx.is_fixed(n, r, explain))
m_prop.push_back(prop_info(explain, v, r));
}
bool theory_user_propagator::propagate_cb(
@ -109,14 +108,19 @@ void theory_user_propagator::register_cb(expr* e) {
bool theory_user_propagator::next_split_cb(expr* e, unsigned idx, lbool phase) {
if (e == nullptr) { // clear
m_next_split_var = null_bool_var;
m_next_split_var = nullptr;
return true;
}
if (!ctx.e_internalized(e)) {
// We may not eagerly internalize it (might crash when done in pop) => delay
m_next_split_var = e;
return true;
}
ensure_enode(e);
bool_var b = enode_to_bool(ctx.get_enode(e), idx);
if (b == null_bool_var || ctx.get_assignment(b) != l_undef)
return false;
m_next_split_var = b;
m_next_split_var = e;
m_next_split_idx = idx;
m_next_split_phase = phase;
return true;
}
@ -225,7 +229,7 @@ void theory_user_propagator::decide(bool_var& var, bool& is_pos) {
if (v == null_theory_var) {
// it is not a registered boolean value but it is a bitvector
auto registered_bv = ((theory_bv *) th)->get_bv_with_theory(var, get_family_id());
auto registered_bv = ((theory_bv*) th)->get_bv_with_theory(var, get_family_id());
if (!registered_bv.first)
// there is no registered bv associated with the bit
return;
@ -237,6 +241,7 @@ void theory_user_propagator::decide(bool_var& var, bool& is_pos) {
// call the registered callback
unsigned new_bit = original_bit;
force_push();
expr *e = var2expr(v);
m_decide_eh(m_user_context, this, e, new_bit, is_pos);
@ -252,12 +257,16 @@ void theory_user_propagator::decide(bool_var& var, bool& is_pos) {
}
bool theory_user_propagator::get_case_split(bool_var& var, bool& is_pos) {
if (m_next_split_var == null_bool_var)
if (m_next_split_var == nullptr)
return false;
var = m_next_split_var;
ensure_enode(m_next_split_var);
bool_var b = enode_to_bool(ctx.get_enode(m_next_split_var), m_next_split_idx);
if (b == null_bool_var || ctx.get_assignment(b) != l_undef)
return false;
var = b;
is_pos = ctx.guess(var, m_next_split_phase);
m_next_split_var = null_bool_var;
m_next_split_var = nullptr;
m_next_split_idx = 0;
m_next_split_phase = l_undef;
return true;
}
@ -291,9 +300,9 @@ void theory_user_propagator::propagate_consequence(prop_info const& prop) {
justification* js;
m_lits.reset();
m_eqs.reset();
for (expr* id : prop.m_ids)
for (expr* id: prop.m_ids)
m_lits.append(m_id2justification[expr2var(id)]);
for (auto const& [a,b] : prop.m_eqs)
for (auto const& [a, b]: prop.m_eqs)
if (a != b)
m_eqs.push_back(enode_pair(get_enode(expr2var(a)), get_enode(expr2var(b))));
DEBUG_CODE(for (auto const& [a, b] : m_eqs) VERIFY(a->get_root() == b->get_root()););

View file

@ -83,7 +83,8 @@ namespace smt {
expr_ref_vector m_to_add;
unsigned_vector m_to_add_lim;
unsigned m_to_add_qhead = 0;
bool_var m_next_split_var = null_bool_var;
expr* m_next_split_var = nullptr;
unsigned m_next_split_idx = 0;
lbool m_next_split_phase = l_undef;
expr* var2expr(theory_var v) { return m_var2expr.get(v); }