mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 09:35:32 +00:00
adding Cube method to .NET API, removing lookahead and get-lemmas
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
2774d6896b
commit
92b5301b7f
13 changed files with 38 additions and 187 deletions
|
@ -90,6 +90,8 @@ namespace sat {
|
|||
|
||||
inline void simplifier::checkpoint() { s.checkpoint(); }
|
||||
|
||||
bool simplifier::single_threaded() const { return s.m_config.m_num_threads == 1; }
|
||||
|
||||
void simplifier::register_clauses(clause_vector & cs) {
|
||||
std::stable_sort(cs.begin(), cs.end(), size_lt());
|
||||
for (clause* c : cs) {
|
||||
|
@ -230,7 +232,7 @@ namespace sat {
|
|||
subsume();
|
||||
if (s.inconsistent())
|
||||
return;
|
||||
if (!learned && elim_vars_enabled() && s.m_config.m_num_threads == 1)
|
||||
if (!learned && elim_vars_enabled())
|
||||
elim_vars();
|
||||
if (s.inconsistent())
|
||||
return;
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace sat {
|
|||
bool m_cce; // covered clause elimination
|
||||
bool m_acce; // cce with asymetric literal addition
|
||||
bool m_bca; // blocked (binary) clause addition.
|
||||
unsigned m_bce_delay;
|
||||
unsigned m_bce_delay;
|
||||
bool m_elim_blocked_clauses;
|
||||
unsigned m_elim_blocked_clauses_at;
|
||||
bool m_retain_blocked_clauses;
|
||||
|
@ -171,13 +171,14 @@ namespace sat {
|
|||
struct blocked_clause_elim;
|
||||
void elim_blocked_clauses();
|
||||
|
||||
bool single_threaded() const; // { return s.m_config.m_num_threads == 1; }
|
||||
bool bce_enabled() const { return !m_learned_in_use_lists && m_num_calls >= m_bce_delay && (m_elim_blocked_clauses || m_elim_blocked_clauses_at == m_num_calls || cce_enabled()); }
|
||||
bool acce_enabled() const { return !m_learned_in_use_lists && m_num_calls >= m_bce_delay && m_acce; }
|
||||
bool cce_enabled() const { return !m_learned_in_use_lists && m_num_calls >= m_bce_delay && (m_cce || acce_enabled()); }
|
||||
bool cce_enabled() const { return !m_learned_in_use_lists && m_num_calls >= m_bce_delay && (m_cce || acce_enabled()); }
|
||||
bool abce_enabled() const { return !m_learned_in_use_lists && m_num_calls >= m_bce_delay && m_abce; }
|
||||
bool bca_enabled() const { return m_bca && m_learned_in_use_lists; }
|
||||
bool elim_vars_bdd_enabled() const { return m_elim_vars_bdd && m_num_calls >= m_elim_vars_bdd_delay; }
|
||||
bool elim_vars_enabled() const { return m_elim_vars; }
|
||||
bool bca_enabled() const { return m_bca && m_learned_in_use_lists && single_threaded(); }
|
||||
bool elim_vars_bdd_enabled() const { return m_elim_vars_bdd && m_num_calls >= m_elim_vars_bdd_delay && single_threaded(); }
|
||||
bool elim_vars_enabled() const { return m_elim_vars && single_threaded(); }
|
||||
|
||||
unsigned get_num_unblocked_bin(literal l) const;
|
||||
unsigned get_to_elim_cost(bool_var v) const;
|
||||
|
|
|
@ -310,51 +310,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
virtual expr_ref lookahead(expr_ref_vector const& assumptions, expr_ref_vector const& candidates) {
|
||||
IF_VERBOSE(1, verbose_stream() << "(sat-lookahead " << candidates.size() << ")\n";);
|
||||
sat::bool_var_vector vars;
|
||||
sat::literal_vector lits;
|
||||
expr_ref_vector lit2expr(m);
|
||||
lit2expr.resize(m_solver.num_vars() * 2);
|
||||
m_map.mk_inv(lit2expr);
|
||||
for (auto c : candidates) {
|
||||
sat::bool_var v = m_map.to_bool_var(c);
|
||||
if (v != sat::null_bool_var) {
|
||||
vars.push_back(v);
|
||||
}
|
||||
}
|
||||
for (auto c : assumptions) {
|
||||
SASSERT(is_literal(c));
|
||||
sat::bool_var v = sat::null_bool_var;
|
||||
bool sign = false;
|
||||
expr* e = c;
|
||||
while (m.is_not(e, e)) {
|
||||
sign = !sign;
|
||||
}
|
||||
if (is_uninterp_const(e)) {
|
||||
v = m_map.to_bool_var(e);
|
||||
}
|
||||
if (v != sat::null_bool_var) {
|
||||
lits.push_back(sat::literal(v, sign));
|
||||
}
|
||||
else {
|
||||
IF_VERBOSE(0, verbose_stream() << "WARNING: could not handle " << mk_pp(c, m) << "\n";);
|
||||
}
|
||||
}
|
||||
if (vars.empty()) {
|
||||
return expr_ref(m.mk_true(), m);
|
||||
}
|
||||
sat::literal l = m_solver.select_lookahead(lits, vars);
|
||||
if (m_solver.inconsistent()) {
|
||||
IF_VERBOSE(1, verbose_stream() << "(sat-lookahead inconsistent)\n";);
|
||||
return expr_ref(m.mk_false(), m);
|
||||
}
|
||||
if (l == sat::null_literal) {
|
||||
return expr_ref(m.mk_true(), m);
|
||||
}
|
||||
expr_ref result(lit2expr[l.index()].get(), m);
|
||||
return result;
|
||||
}
|
||||
virtual expr_ref cube() {
|
||||
if (!m_internalized) {
|
||||
dep2asm_t dep2asm;
|
||||
|
@ -386,16 +341,6 @@ public:
|
|||
return mk_and(fmls);
|
||||
}
|
||||
|
||||
virtual void get_lemmas(expr_ref_vector & lemmas) {
|
||||
if (!m_internalized) return;
|
||||
sat2goal s2g;
|
||||
goal g(m, false, false, false);
|
||||
s2g.get_learned(m_solver, m_map, m_params, lemmas);
|
||||
IF_VERBOSE(1, verbose_stream() << "(sat :lemmas " << lemmas.size() << ")\n";);
|
||||
// TBD: handle externals properly.
|
||||
}
|
||||
|
||||
|
||||
virtual lbool get_consequences_core(expr_ref_vector const& assumptions, expr_ref_vector const& vars, expr_ref_vector& conseq) {
|
||||
init_preprocess();
|
||||
TRACE("sat", tout << assumptions << "\n" << vars << "\n";);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue