3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

merge with master

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-03-25 14:57:01 -07:00
commit c513f3ca09
883 changed files with 13979 additions and 16480 deletions

View file

@ -113,7 +113,7 @@ namespace sat {
void tmp_clause::set(unsigned num_lits, literal const * lits, bool learned) {
if (m_clause && m_clause->m_capacity < num_lits) {
dealloc_svect(m_clause);
m_clause = 0;
m_clause = nullptr;
}
if (!m_clause) {
void * mem = alloc_svect(char, clause::get_obj_size(num_lits));

View file

@ -121,7 +121,7 @@ namespace sat {
class tmp_clause {
clause * m_clause;
public:
tmp_clause():m_clause(0) {}
tmp_clause():m_clause(nullptr) {}
~tmp_clause() { if (m_clause) dealloc_svect(m_clause); }
clause * get() const { return m_clause; }
void set(unsigned num_lits, literal const * lits, bool learned);

View file

@ -61,7 +61,7 @@ namespace sat {
bool probing::try_lit(literal l, bool updt_cache) {
SASSERT(s.m_qhead == s.m_trail.size());
SASSERT(s.value(l.var()) == l_undef);
literal_vector * implied_lits = updt_cache ? 0 : cached_implied_lits(l);
literal_vector * implied_lits = updt_cache ? nullptr : cached_implied_lits(l);
if (implied_lits) {
for (literal lit : *implied_lits) {
if (m_assigned.contains(lit)) {

View file

@ -55,7 +55,6 @@ namespace sat {
struct report;
void reset_cache(literal l);
void cache_bins(literal l, unsigned old_tr_sz);
bool try_lit(literal l, bool updt_cache);
void process(bool_var v);
@ -66,6 +65,7 @@ namespace sat {
bool operator()(bool force = false);
void reset_cache(literal l);
void updt_params(params_ref const & p);
static void collect_param_descrs(param_descrs & d);
@ -77,10 +77,10 @@ namespace sat {
// return the literals implied by l.
// return 0, if the cache is not available
literal_vector * cached_implied_lits(literal l) {
if (!m_probing_cache) return 0;
if (l.index() >= m_cached_bins.size()) return 0;
if (!m_probing_cache) return nullptr;
if (l.index() >= m_cached_bins.size()) return nullptr;
cache_entry & e = m_cached_bins[l.index()];
if (!e.m_available) return 0;
if (!e.m_available) return nullptr;
return &(e.m_lits);
}

View file

@ -36,7 +36,7 @@ namespace sat {
m_rlimit(l),
m_checkpoint_enabled(true),
m_config(p),
m_par(0),
m_par(nullptr),
m_par_syncing_clauses(false),
m_par_id(0),
m_cleaner(*this),
@ -308,7 +308,7 @@ namespace sat {
bool keep = simplify_clause(num_lits, lits);
TRACE("sat_mk_clause", tout << "mk_clause (after simp), keep: " << keep << "\n" << mk_lits_pp(num_lits, lits) << "\n";);
if (!keep) {
return 0; // clause is equivalent to true.
return nullptr; // clause is equivalent to true.
}
++m_stats.m_non_learned_generation;
}
@ -317,14 +317,14 @@ namespace sat {
case 0:
if (m_config.m_drat) m_drat.add();
set_conflict(justification());
return 0;
return nullptr;
case 1:
assign(lits[0], justification());
return 0;
return nullptr;
case 2:
mk_bin_clause(lits[0], lits[1], learned);
if (learned && m_par) m_par->share_clause(*this, lits[0], lits[1]);
return 0;
return nullptr;
case 3:
return mk_ter_clause(lits, learned);
default:
@ -1454,7 +1454,7 @@ namespace sat {
}
void solver::reinit_assumptions() {
if (tracking_assumptions() && at_base_lvl()) {
if (tracking_assumptions() && at_base_lvl() && !inconsistent()) {
TRACE("sat", tout << m_assumptions << "\n";);
push();
for (unsigned i = 0; !inconsistent() && i < m_user_scope_literals.size(); ++i) {
@ -2849,10 +2849,7 @@ namespace sat {
// try to use cached implication if available
literal_vector * implied_lits = m_probing.cached_implied_lits(~l);
if (implied_lits) {
literal_vector::iterator it = implied_lits->begin();
literal_vector::iterator end = implied_lits->end();
for (; it != end; ++it) {
literal l2 = *it;
for (literal l2 : *implied_lits) {
// Here, we must check l0 != ~l2.
// l \/ l2 is an implied binary clause.
// However, it may have been deduced using a lemma that has been deleted.
@ -3048,15 +3045,22 @@ namespace sat {
clauses.shrink(j);
}
void solver::gc_bin(bool learned, literal nlit) {
m_user_bin_clauses.reset();
collect_bin_clauses(m_user_bin_clauses, learned);
for (unsigned i = 0; i < m_user_bin_clauses.size(); ++i) {
literal l1 = m_user_bin_clauses[i].first;
literal l2 = m_user_bin_clauses[i].second;
if (nlit == l1 || nlit == l2) {
detach_bin_clause(l1, l2, learned);
void solver::gc_bin(literal lit) {
bool_var v = lit.var();
for (watch_list& wlist : m_watches) {
watch_list::iterator it = wlist.begin();
watch_list::iterator it2 = wlist.begin();
watch_list::iterator end = wlist.end();
for (; it != end; ++it) {
if (it->is_binary_clause() && it->get_literal().var() == v) {
// skip
}
else {
*it2 = *it;
++it2;
}
}
wlist.set_end(it2);
}
}
@ -3096,6 +3100,8 @@ namespace sat {
if (v < m_level.size()) {
for (bool_var i = v; i < m_level.size(); ++i) {
m_case_split_queue.del_var_eh(i);
m_probing.reset_cache(literal(i, true));
m_probing.reset_cache(literal(i, false));
}
m_watches.shrink(2*v);
m_assignment.shrink(2*v);
@ -3116,6 +3122,7 @@ namespace sat {
void solver::user_pop(unsigned num_scopes) {
pop_to_base_level();
TRACE("sat", display(tout););
while (num_scopes > 0) {
literal lit = m_user_scope_literals.back();
m_user_scope_literals.pop_back();
@ -3124,8 +3131,7 @@ namespace sat {
gc_lit(m_learned, lit);
gc_lit(m_clauses, lit);
gc_bin(true, lit);
gc_bin(false, lit);
gc_bin(lit);
TRACE("sat", tout << "gc: " << lit << "\n"; display(tout););
--num_scopes;
for (unsigned i = 0; i < m_trail.size(); ++i) {
@ -3135,8 +3141,10 @@ namespace sat {
break;
}
}
gc_var(lit.var());
gc_var(lit.var());
}
m_qhead = 0;
propagate(false);
}
void solver::pop_to_base_level() {

View file

@ -351,7 +351,7 @@ namespace sat {
//
// -----------------------
public:
lbool check(unsigned num_lits = 0, literal const* lits = 0);
lbool check(unsigned num_lits = 0, literal const* lits = nullptr);
model const & get_model() const { return m_model; }
bool model_is_current() const { return m_model_is_current; }
@ -505,7 +505,7 @@ namespace sat {
literal_vector m_aux_literals;
svector<bin_clause> m_user_bin_clauses;
void gc_lit(clause_vector& clauses, literal lit);
void gc_bin(bool learned, literal nlit);
void gc_bin(literal lit);
void gc_var(bool_var v);
bool_var max_var(clause_vector& clauses, bool_var v);

View file

@ -104,7 +104,7 @@ public:
return m_solver.get_config().m_incremental;
}
virtual ~inc_sat_solver() {}
~inc_sat_solver() override {}
solver* translate(ast_manager& dst_m, params_ref const& p) override {
if (m_num_scopes > 0) {
@ -132,7 +132,7 @@ public:
void set_progress_callback(progress_callback * callback) override {}
void display_weighted(std::ostream& out, unsigned sz, expr * const * assumptions, unsigned const* weights) {
if (weights != 0) {
if (weights != nullptr) {
for (unsigned i = 0; i < sz; ++i) m_weights.push_back(weights[i]);
}
init_preprocess();
@ -299,7 +299,7 @@ public:
}
proof * get_proof() override {
UNREACHABLE();
return 0;
return nullptr;
}
expr_ref_vector cube(expr_ref_vector& vs, unsigned backtrack_level) override {
@ -527,8 +527,8 @@ private:
catch (tactic_exception & ex) {
IF_VERBOSE(0, verbose_stream() << "exception in tactic " << ex.msg() << "\n";);
TRACE("sat", tout << "exception: " << ex.msg() << "\n";);
m_preprocess = 0;
m_bb_rewriter = 0;
m_preprocess = nullptr;
m_bb_rewriter = nullptr;
return l_undef;
}
if (m_subgoals.size() != 1) {
@ -646,7 +646,7 @@ private:
expr_ref_vector conj(m);
internalize_value(value, v, val);
while (!premises.empty()) {
expr* e = 0;
expr* e = nullptr;
VERIFY(asm2dep.find(premises.pop().index(), e));
conj.push_back(e);
}
@ -746,7 +746,7 @@ private:
m_core.reset();
for (sat::literal c : core) {
expr* e = 0;
expr* e = nullptr;
VERIFY(asm2dep.find(c.index(), e));
if (asm2fml.contains(e)) {
e = asm2fml.find(e);

View file

@ -870,7 +870,7 @@ bool goal2sat::has_unsupported_bool(goal const & g) {
return test<unsupported_bool_proc>(g);
}
goal2sat::goal2sat():m_imp(0), m_interpreted_atoms(0) {
goal2sat::goal2sat():m_imp(nullptr), m_interpreted_atoms(nullptr) {
}
void goal2sat::collect_param_descrs(param_descrs & r) {
@ -884,7 +884,7 @@ struct goal2sat::scoped_set_imp {
m_owner->m_imp = i;
}
~scoped_set_imp() {
m_owner->m_imp = 0;
m_owner->m_imp = nullptr;
}
};
@ -1236,7 +1236,7 @@ struct sat2goal::imp {
};
sat2goal::sat2goal():m_imp(0) {
sat2goal::sat2goal():m_imp(nullptr) {
}
void sat2goal::collect_param_descrs(param_descrs & r) {
@ -1250,7 +1250,7 @@ struct sat2goal::scoped_set_imp {
m_owner->m_imp = i;
}
~scoped_set_imp() {
m_owner->m_imp = 0;
m_owner->m_imp = nullptr;
}
};

View file

@ -64,7 +64,7 @@ class sat_tactic : public tactic {
dep2assumptions(dep2asm, assumptions);
lbool r = m_solver.check(assumptions.size(), assumptions.c_ptr());
if (r == l_false) {
expr_dependency * lcore = 0;
expr_dependency * lcore = nullptr;
if (produce_core) {
sat::literal_vector const& ucore = m_solver.get_core();
u_map<expr*> asm2dep;
@ -75,7 +75,7 @@ class sat_tactic : public tactic {
lcore = m.mk_join(lcore, m.mk_leaf(dep));
}
}
g->assert_expr(m.mk_false(), 0, lcore);
g->assert_expr(m.mk_false(), nullptr, lcore);
}
else if (r == l_true && !map.interpreted_atoms()) {
// register model
@ -140,7 +140,7 @@ class sat_tactic : public tactic {
}
~scoped_set_imp() {
m_owner->m_imp = 0;
m_owner->m_imp = nullptr;
}
};
@ -150,30 +150,30 @@ class sat_tactic : public tactic {
public:
sat_tactic(ast_manager & m, params_ref const & p):
m_imp(0),
m_imp(nullptr),
m_params(p) {
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(sat_tactic, m, m_params);
}
virtual ~sat_tactic() {
~sat_tactic() override {
SASSERT(m_imp == 0);
}
virtual void updt_params(params_ref const & p) {
void updt_params(params_ref const & p) override {
m_params = p;
}
virtual void collect_param_descrs(param_descrs & r) {
void collect_param_descrs(param_descrs & r) override {
goal2sat::collect_param_descrs(r);
sat2goal::collect_param_descrs(r);
sat::solver::collect_param_descrs(r);
}
void operator()(goal_ref const & g,
goal_ref_buffer & result) {
goal_ref_buffer & result) override {
imp proc(g->m(), m_params);
scoped_set_imp set(this, &proc);
try {
@ -187,15 +187,15 @@ public:
TRACE("sat_stats", m_stats.display_smt2(tout););
}
virtual void cleanup() {
void cleanup() override {
SASSERT(m_imp == 0);
}
virtual void collect_statistics(statistics & st) const {
void collect_statistics(statistics & st) const override {
st.copy(m_stats);
}
virtual void reset_statistics() {
void reset_statistics() override {
m_stats.reset();
}