mirror of
https://github.com/Z3Prover/z3
synced 2025-04-13 20:38:43 +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;
|
||||
}
|
||||
|
||||
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) {
|
||||
scoped_ext _scoped_ext(*this);
|
||||
lits.reset();
|
||||
|
@ -2102,22 +2111,13 @@ namespace sat {
|
|||
}
|
||||
backtrack_level = UINT_MAX;
|
||||
depth = m_cube_state.m_cube.size();
|
||||
if ((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)) {
|
||||
if (should_cutoff(depth)) {
|
||||
double dec = (1.0 - pow(m_config.m_cube_fraction, depth));
|
||||
m_cube_state.m_freevars_threshold *= dec;
|
||||
m_cube_state.m_psat_threshold *= 2.0 - dec;
|
||||
set_conflict();
|
||||
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);
|
||||
#endif
|
||||
vars.reset();
|
||||
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);
|
||||
|
|
|
@ -558,6 +558,8 @@ namespace sat {
|
|||
|
||||
double psat_heur();
|
||||
|
||||
bool should_cutoff(unsigned depth);
|
||||
|
||||
public:
|
||||
lookahead(solver& s) :
|
||||
m_s(s),
|
||||
|
|
|
@ -1030,6 +1030,7 @@ namespace sat {
|
|||
}
|
||||
break;
|
||||
case l_true: {
|
||||
lits.reset();
|
||||
pop_to_base_level();
|
||||
model const& mdl = m_cuber->get_model();
|
||||
for (bool_var v = 0; v < mdl.size(); ++v) {
|
||||
|
|
|
@ -308,6 +308,12 @@ public:
|
|||
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 {
|
||||
if (!is_internalized()) {
|
||||
lbool r = internalize_formulas();
|
||||
|
@ -326,15 +332,18 @@ public:
|
|||
}
|
||||
sat::literal_vector lits;
|
||||
lbool result = m_solver.cube(vars, lits, backtrack_level);
|
||||
if (result == l_false || lits.empty()) {
|
||||
expr_ref_vector result(m);
|
||||
result.push_back(m.mk_false());
|
||||
return result;
|
||||
}
|
||||
if (result == l_true) {
|
||||
IF_VERBOSE(1, verbose_stream() << "formulas are SAT\n");
|
||||
switch (result) {
|
||||
case l_true:
|
||||
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 lit2expr(m);
|
||||
lit2expr.resize(m_solver.num_vars() * 2);
|
||||
|
|
Loading…
Reference in a new issue