mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 13:28:47 +00:00
update empty cube case for sat/undef cases
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
be8a9c611e
commit
9d0aa4d02d
|
@ -2057,6 +2057,15 @@ namespace sat {
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lookahead::should_cutoff(unsigned depth) {
|
||||||
|
return depth > 0 &&
|
||||||
|
((m_config.m_cube_cutoff == depth_cutoff && depth == m_config.m_cube_depth) ||
|
||||||
|
(m_config.m_cube_cutoff == freevars_cutoff && m_freevars.size() <= m_init_freevars * m_config.m_cube_freevars) ||
|
||||||
|
(m_config.m_cube_cutoff == psat_cutoff && psat_heur() >= m_config.m_cube_psat_trigger) ||
|
||||||
|
(m_config.m_cube_cutoff == adaptive_freevars_cutoff && m_freevars.size() < m_cube_state.m_freevars_threshold) ||
|
||||||
|
(m_config.m_cube_cutoff == adaptive_psat_cutoff && psat_heur() >= m_cube_state.m_psat_threshold));
|
||||||
|
}
|
||||||
|
|
||||||
lbool lookahead::cube(bool_var_vector& vars, literal_vector& lits, unsigned backtrack_level) {
|
lbool lookahead::cube(bool_var_vector& vars, literal_vector& lits, unsigned backtrack_level) {
|
||||||
scoped_ext _scoped_ext(*this);
|
scoped_ext _scoped_ext(*this);
|
||||||
lits.reset();
|
lits.reset();
|
||||||
|
@ -2102,22 +2111,13 @@ namespace sat {
|
||||||
}
|
}
|
||||||
backtrack_level = UINT_MAX;
|
backtrack_level = UINT_MAX;
|
||||||
depth = m_cube_state.m_cube.size();
|
depth = m_cube_state.m_cube.size();
|
||||||
if ((m_config.m_cube_cutoff == depth_cutoff && depth == m_config.m_cube_depth) ||
|
if (should_cutoff(depth)) {
|
||||||
(m_config.m_cube_cutoff == freevars_cutoff && m_freevars.size() <= m_init_freevars * m_config.m_cube_freevars) ||
|
|
||||||
(m_config.m_cube_cutoff == psat_cutoff && psat_heur() >= m_config.m_cube_psat_trigger) ||
|
|
||||||
(m_config.m_cube_cutoff == adaptive_freevars_cutoff && m_freevars.size() < m_cube_state.m_freevars_threshold) ||
|
|
||||||
(m_config.m_cube_cutoff == adaptive_psat_cutoff && psat_heur() >= m_cube_state.m_psat_threshold)) {
|
|
||||||
double dec = (1.0 - pow(m_config.m_cube_fraction, depth));
|
double dec = (1.0 - pow(m_config.m_cube_fraction, depth));
|
||||||
m_cube_state.m_freevars_threshold *= dec;
|
m_cube_state.m_freevars_threshold *= dec;
|
||||||
m_cube_state.m_psat_threshold *= 2.0 - dec;
|
m_cube_state.m_psat_threshold *= 2.0 - dec;
|
||||||
set_conflict();
|
set_conflict();
|
||||||
m_cube_state.inc_cutoff();
|
m_cube_state.inc_cutoff();
|
||||||
#if 0
|
|
||||||
// return cube of all literals, not just the ones in the main cube
|
|
||||||
lits.append(m_trail.size() - init_trail, m_trail.c_ptr() + init_trail);
|
|
||||||
#else
|
|
||||||
lits.append(m_cube_state.m_cube);
|
lits.append(m_cube_state.m_cube);
|
||||||
#endif
|
|
||||||
vars.reset();
|
vars.reset();
|
||||||
for (auto v : m_freevars) if (in_reduced_clause(v)) vars.push_back(v);
|
for (auto v : m_freevars) if (in_reduced_clause(v)) vars.push_back(v);
|
||||||
backtrack(m_cube_state.m_cube, m_cube_state.m_is_decision);
|
backtrack(m_cube_state.m_cube, m_cube_state.m_is_decision);
|
||||||
|
|
|
@ -558,6 +558,8 @@ namespace sat {
|
||||||
|
|
||||||
double psat_heur();
|
double psat_heur();
|
||||||
|
|
||||||
|
bool should_cutoff(unsigned depth);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
lookahead(solver& s) :
|
lookahead(solver& s) :
|
||||||
m_s(s),
|
m_s(s),
|
||||||
|
|
|
@ -1030,6 +1030,7 @@ namespace sat {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case l_true: {
|
case l_true: {
|
||||||
|
lits.reset();
|
||||||
pop_to_base_level();
|
pop_to_base_level();
|
||||||
model const& mdl = m_cuber->get_model();
|
model const& mdl = m_cuber->get_model();
|
||||||
for (bool_var v = 0; v < mdl.size(); ++v) {
|
for (bool_var v = 0; v < mdl.size(); ++v) {
|
||||||
|
|
|
@ -308,6 +308,12 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expr_ref_vector last_cube() {
|
||||||
|
expr_ref_vector result(m);
|
||||||
|
result.push_back(m.mk_false());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
expr_ref_vector cube(expr_ref_vector& vs, unsigned backtrack_level) override {
|
expr_ref_vector cube(expr_ref_vector& vs, unsigned backtrack_level) override {
|
||||||
if (!is_internalized()) {
|
if (!is_internalized()) {
|
||||||
lbool r = internalize_formulas();
|
lbool r = internalize_formulas();
|
||||||
|
@ -326,15 +332,18 @@ public:
|
||||||
}
|
}
|
||||||
sat::literal_vector lits;
|
sat::literal_vector lits;
|
||||||
lbool result = m_solver.cube(vars, lits, backtrack_level);
|
lbool result = m_solver.cube(vars, lits, backtrack_level);
|
||||||
if (result == l_false || lits.empty()) {
|
switch (result) {
|
||||||
expr_ref_vector result(m);
|
case l_true:
|
||||||
result.push_back(m.mk_false());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
if (result == l_true) {
|
|
||||||
IF_VERBOSE(1, verbose_stream() << "formulas are SAT\n");
|
|
||||||
return expr_ref_vector(m);
|
return expr_ref_vector(m);
|
||||||
}
|
case l_false:
|
||||||
|
return last_cube();
|
||||||
|
default:
|
||||||
|
SASSERT(!lits.empty());
|
||||||
|
if (lits.empty()) {
|
||||||
|
IF_VERBOSE(0, verbose_stream() << "empty cube for undef\n";);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
expr_ref_vector fmls(m);
|
expr_ref_vector fmls(m);
|
||||||
expr_ref_vector lit2expr(m);
|
expr_ref_vector lit2expr(m);
|
||||||
lit2expr.resize(m_solver.num_vars() * 2);
|
lit2expr.resize(m_solver.num_vars() * 2);
|
||||||
|
|
Loading…
Reference in a new issue