3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-09 12:50:32 +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

@ -146,32 +146,31 @@ public:
m_imp = alloc(imp, m, p);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(blast_term_ite_tactic, m, m_params);
}
virtual ~blast_term_ite_tactic() {
~blast_term_ite_tactic() override {
dealloc(m_imp);
}
virtual void updt_params(params_ref const & p) {
void updt_params(params_ref const & p) override {
m_params = p;
m_imp->m_rw.cfg().updt_params(p);
}
virtual void collect_param_descrs(param_descrs & r) {
void collect_param_descrs(param_descrs & r) override {
insert_max_memory(r);
insert_max_steps(r);
r.insert("max_args", CPK_UINT,
"(default: 128) maximum number of arguments (per application) that will be considered by the greedy (quadratic) heuristic.");
}
virtual void operator()(goal_ref const & in,
goal_ref_buffer & result) {
void operator()(goal_ref const & in, goal_ref_buffer & result) override {
(*m_imp)(in, result);
}
virtual void cleanup() {
void cleanup() override {
ast_manager & m = m_imp->m;
dealloc(m_imp);
m_imp = alloc(imp, m, m_params);

View file

@ -219,7 +219,7 @@ struct cofactor_elim_term_ite::imp {
break;
}
}
return 0;
return nullptr;
}
/**
@ -286,7 +286,7 @@ struct cofactor_elim_term_ite::imp {
break;
}
}
expr * best = 0;
expr * best = nullptr;
unsigned best_occs = 0;
obj_map<expr, unsigned>::iterator it = occs.begin();
obj_map<expr, unsigned>::iterator end = occs.end();
@ -329,7 +329,7 @@ struct cofactor_elim_term_ite::imp {
bool m_strict_upper;
app * m_upper;
cofactor_rw_cfg(ast_manager & _m, imp & owner, obj_hashtable<expr> * has_term_ite = 0):
cofactor_rw_cfg(ast_manager & _m, imp & owner, obj_hashtable<expr> * has_term_ite = nullptr):
m(_m),
m_owner(owner),
m_has_term_ite(has_term_ite),
@ -349,13 +349,13 @@ struct cofactor_elim_term_ite::imp {
if (m.is_not(t)) {
m_atom = to_app(t)->get_arg(0);
m_sign = true;
m_term = 0;
m_term = nullptr;
// TODO: bounds
}
else {
m_atom = t;
m_sign = false;
m_term = 0;
m_term = nullptr;
expr * lhs;
expr * rhs;
if (m_owner.m_cofactor_equalities && m.is_eq(t, lhs, rhs)) {
@ -377,19 +377,19 @@ struct cofactor_elim_term_ite::imp {
bool rewrite_patterns() const { return false; }
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
result_pr = 0;
result_pr = nullptr;
return m_mk_app.mk_core(f, num, args, result);
}
bool get_subst(expr * s, expr * & t, proof * & pr) {
pr = 0;
pr = nullptr;
if (s == m_atom) {
t = m_sign ? m.mk_false() : m.mk_true();
return true;
}
if (s == m_term && m_value != 0) {
if (s == m_term && m_value != nullptr) {
t = m_value;
return true;
}
@ -406,7 +406,7 @@ struct cofactor_elim_term_ite::imp {
struct cofactor_rw : rewriter_tpl<cofactor_rw_cfg> {
cofactor_rw_cfg m_cfg;
public:
cofactor_rw(ast_manager & m, imp & owner, obj_hashtable<expr> * has_term_ite = 0):
cofactor_rw(ast_manager & m, imp & owner, obj_hashtable<expr> * has_term_ite = nullptr):
rewriter_tpl<cofactor_rw_cfg>(m, false, m_cfg),
m_cfg(m, owner, has_term_ite) {
}
@ -444,7 +444,7 @@ struct cofactor_elim_term_ite::imp {
bool get_subst(expr * s, expr * & t, proof * & t_pr) {
if (m_candidates.contains(s)) {
t_pr = 0;
t_pr = nullptr;
if (m_cache.find(s, t))
return true;
@ -455,7 +455,7 @@ struct cofactor_elim_term_ite::imp {
while (true) {
// expr * c = m_owner.get_best(curr);
expr * c = m_owner.get_first(curr);
if (c == 0) {
if (c == nullptr) {
m_cache.insert(s, curr);
m_cache_domain.push_back(curr);
t = curr.get();
@ -532,7 +532,7 @@ struct cofactor_elim_term_ite::imp {
while (true) {
expr * c = m_owner.get_best(curr);
// expr * c = m_owner.get_first(curr);
if (c == 0) {
if (c == nullptr) {
r = curr.get();
return;
}
@ -607,7 +607,7 @@ struct cofactor_elim_term_ite::imp {
unsigned num = to_app(t)->get_num_args();
for (unsigned i = 0; i < num; i++) {
expr * arg = to_app(t)->get_arg(i);
expr * new_arg = 0;
expr * new_arg = nullptr;
TRACE("cofactor_bug", tout << "collecting child: " << arg->get_id() << "\n";);
m_cache.find(arg, new_arg);
SASSERT(new_arg != 0);
@ -645,7 +645,7 @@ struct cofactor_elim_term_ite::imp {
m_cache_domain.push_back(new_t);
m_frames.pop_back();
}
expr * result = 0;
expr * result = nullptr;
m_cache.find(t, result);
r = result;
}

View file

@ -36,7 +36,7 @@ class cofactor_term_ite_tactic : public tactic {
expr * f = g.form(i);
expr_ref new_f(m);
m_elim_ite(f, new_f);
g.update(i, new_f, 0, g.dep(i));
g.update(i, new_f, nullptr, g.dep(i));
}
}
@ -46,13 +46,13 @@ public:
m_elim_ite(m, p) {
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(cofactor_term_ite_tactic, m, m_params);
}
virtual ~cofactor_term_ite_tactic() {}
virtual void updt_params(params_ref const & p) { m_params = p; m_elim_ite.updt_params(p); }
virtual void collect_param_descrs(param_descrs & r) { m_elim_ite.collect_param_descrs(r); }
~cofactor_term_ite_tactic() override {}
void updt_params(params_ref const & p) override { m_params = p; m_elim_ite.updt_params(p); }
void collect_param_descrs(param_descrs & r) override { m_elim_ite.collect_param_descrs(r); }
void operator()(goal_ref const & g, goal_ref_buffer& result) override {
SASSERT(g->is_well_sorted());
@ -66,7 +66,7 @@ public:
SASSERT(g->is_well_sorted());
}
virtual void cleanup() { return m_elim_ite.cleanup(); }
void cleanup() override { return m_elim_ite.cleanup(); }
};

View file

@ -51,19 +51,19 @@ public:
m_params(p) {
}
virtual ~collect_statistics_tactic() {}
~collect_statistics_tactic() override {}
virtual tactic * translate(ast_manager & m_) {
tactic * translate(ast_manager & m_) override {
return alloc(collect_statistics_tactic, m_, m_params);
}
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 {}
virtual void operator()(goal_ref const & g, goal_ref_buffer & result) {
void operator()(goal_ref const & g, goal_ref_buffer & result) override {
tactic_report report("collect-statistics", *g);
collect_proc cp(m, m_stats);
@ -81,13 +81,13 @@ public:
result.push_back(g.get());
}
virtual void cleanup() {}
void cleanup() override {}
virtual void collect_statistics(statistics & st) const {
void collect_statistics(statistics & st) const override {
}
virtual void reset_statistics() { reset(); }
virtual void reset() { cleanup(); }
void reset_statistics() override { reset(); }
void reset() override { cleanup(); }
protected:
class collect_proc {

View file

@ -33,13 +33,13 @@ class ctx_propagate_assertions : public ctx_simplify_tactic::simplifier {
void assert_eq_core(expr * t, app * val);
public:
ctx_propagate_assertions(ast_manager& m);
virtual ~ctx_propagate_assertions() {}
virtual bool assert_expr(expr * t, bool sign);
virtual bool simplify(expr* t, expr_ref& result);
~ctx_propagate_assertions() override {}
bool assert_expr(expr * t, bool sign) override;
bool simplify(expr* t, expr_ref& result) override;
void push();
virtual void pop(unsigned num_scopes);
virtual unsigned scope_level() const { return m_scopes.size(); }
virtual simplifier * translate(ast_manager & m);
void pop(unsigned num_scopes) override;
unsigned scope_level() const override { return m_scopes.size(); }
simplifier * translate(ast_manager & m) override;
};
@ -148,7 +148,7 @@ struct ctx_simplify_tactic::imp {
struct cache_cell {
expr * m_from;
cached_result * m_result;
cache_cell():m_from(0), m_result(0) {}
cache_cell():m_from(nullptr), m_result(nullptr) {}
};
ast_manager & m;
@ -217,7 +217,7 @@ struct ctx_simplify_tactic::imp {
bool check_cache() {
for (unsigned i = 0; i < m_cache.size(); i++) {
cache_cell & cell = m_cache[i];
if (cell.m_from != 0) {
if (cell.m_from != nullptr) {
SASSERT(cell.m_result != 0);
cached_result * curr = cell.m_result;
while (curr) {
@ -235,10 +235,10 @@ struct ctx_simplify_tactic::imp {
m_cache.reserve(id+1);
cache_cell & cell = m_cache[id];
void * mem = m_allocator.allocate(sizeof(cached_result));
if (cell.m_from == 0) {
if (cell.m_from == nullptr) {
// new_entry
cell.m_from = from;
cell.m_result = new (mem) cached_result(to, scope_level(), 0);
cell.m_result = new (mem) cached_result(to, scope_level(), nullptr);
m.inc_ref(from);
m.inc_ref(to);
}
@ -281,9 +281,9 @@ struct ctx_simplify_tactic::imp {
if (to_delete->m_next) tout << mk_ismt2_pp(to_delete->m_next->m_to, m); else tout << "<null>";
tout << "\n";);
cell.m_result = to_delete->m_next;
if (cell.m_result == 0) {
if (cell.m_result == nullptr) {
m.dec_ref(cell.m_from);
cell.m_from = 0;
cell.m_from = nullptr;
}
m_allocator.deallocate(sizeof(cached_result), to_delete);
}
@ -316,7 +316,7 @@ struct ctx_simplify_tactic::imp {
return false;
cache_cell & cell = m_cache[id];
SASSERT(cell.m_result == 0 || cell.m_result->m_lvl <= scope_level());
if (cell.m_result != 0 && cell.m_result->m_lvl == scope_level()) {
if (cell.m_result != nullptr && cell.m_result->m_lvl == scope_level()) {
SASSERT(cell.m_from == t);
SASSERT(cell.m_result->m_to != 0);
r = cell.m_result->m_to;
@ -326,7 +326,7 @@ struct ctx_simplify_tactic::imp {
}
void simplify(expr * t, expr_ref & r) {
r = 0;
r = nullptr;
if (m_depth >= m_max_depth || m_num_steps >= m_max_steps || !is_app(t) || !m_simp->may_simplify(t)) {
r = t;
return;
@ -534,7 +534,7 @@ struct ctx_simplify_tactic::imp {
if (i < sz - 1 && !m.is_true(r) && !m.is_false(r) && !g.dep(i) && !assert_expr(r, false)) {
r = m.mk_false();
}
g.update(i, r, 0, g.dep(i));
g.update(i, r, nullptr, g.dep(i));
}
pop(scope_level() - old_lvl);
@ -549,7 +549,7 @@ struct ctx_simplify_tactic::imp {
if (i > 0 && !m.is_true(r) && !m.is_false(r) && !g.dep(i) && !assert_expr(r, false)) {
r = m.mk_false();
}
g.update(i, r, 0, g.dep(i));
g.update(i, r, nullptr, g.dep(i));
}
pop(scope_level() - old_lvl);
SASSERT(scope_level() == 0);
@ -582,7 +582,7 @@ struct ctx_simplify_tactic::imp {
for (unsigned i = 0; !g.inconsistent() && i < sz; ++i) {
expr * t = g.form(i);
process(t, r);
proof* new_pr = m.mk_modus_ponens(g.pr(i), m.mk_rewrite_star(t, r, 0, 0)); // TODO :-)
proof* new_pr = m.mk_modus_ponens(g.pr(i), m.mk_rewrite(t, r));
g.update(i, r, new_pr, g.dep(i));
}
}

View file

@ -46,18 +46,17 @@ protected:
public:
ctx_simplify_tactic(ast_manager & m, simplifier* simp, params_ref const & p = params_ref());
virtual tactic * translate(ast_manager & m);
tactic * translate(ast_manager & m) override;
virtual ~ctx_simplify_tactic();
~ctx_simplify_tactic() override;
virtual void updt_params(params_ref const & p);
void updt_params(params_ref const & p) override;
static void get_param_descrs(param_descrs & r);
virtual void collect_param_descrs(param_descrs & r) { get_param_descrs(r); }
void collect_param_descrs(param_descrs & r) override { get_param_descrs(r); }
virtual void operator()(goal_ref const & in,
goal_ref_buffer & result);
void operator()(goal_ref const & in, goal_ref_buffer & result) override;
virtual void cleanup();
void cleanup() override;
};
tactic * mk_ctx_simplify_tactic(ast_manager & m, params_ref const & p = params_ref());

View file

@ -65,22 +65,22 @@ public:
m_imp = alloc(imp, m);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(der_tactic, m);
}
virtual ~der_tactic() {
~der_tactic() override {
dealloc(m_imp);
}
virtual void operator()(goal_ref const & in,
goal_ref_buffer & result) {
void operator()(goal_ref const & in,
goal_ref_buffer & result) override {
(*m_imp)(*(in.get()));
in->inc_depth();
result.push_back(in.get());
}
virtual void cleanup() {
void cleanup() override {
ast_manager & m = m_imp->m();
imp * d = alloc(imp, m);
std::swap(d, m_imp);

View file

@ -93,14 +93,14 @@ class distribute_forall_tactic : public tactic {
rw * m_rw;
public:
distribute_forall_tactic():m_rw(0) {}
distribute_forall_tactic():m_rw(nullptr) {}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(distribute_forall_tactic);
}
virtual void operator()(goal_ref const & g,
goal_ref_buffer & result) {
void operator()(goal_ref const & g,
goal_ref_buffer & result) override {
SASSERT(g->is_well_sorted());
ast_manager & m = g->m();
bool produce_proofs = g->proofs_enabled();
@ -128,10 +128,10 @@ public:
result.push_back(g.get());
TRACE("distribute-forall", g->display(tout););
SASSERT(g->is_well_sorted());
m_rw = 0;
m_rw = nullptr;
}
virtual void cleanup() {}
void cleanup() override {}
};
tactic * mk_distribute_forall_tactic(ast_manager & m, params_ref const & p) {

View file

@ -100,7 +100,7 @@ bool expr_dominators::compute_dominators() {
for (unsigned i = 0; i + 1 < m_post2expr.size(); ++i) {
expr * child = m_post2expr[i];
ptr_vector<expr> const& p = m_parents[child];
expr * new_idom = 0, *idom2 = 0;
expr * new_idom = nullptr, *idom2 = nullptr;
for (expr * pred : p) {
if (m_doms.contains(pred)) {
@ -199,7 +199,7 @@ void dom_simplify_tactic::cleanup() {
expr_ref dom_simplify_tactic::simplify_ite(app * ite) {
expr_ref r(m);
expr * c = 0, *t = 0, *e = 0;
expr * c = nullptr, *t = nullptr, *e = nullptr;
VERIFY(m.is_ite(ite, c, t, e));
unsigned old_lvl = scope_level();
expr_ref new_c = simplify_arg(c);
@ -254,7 +254,7 @@ expr_ref dom_simplify_tactic::simplify_arg(expr * e) {
*/
expr_ref dom_simplify_tactic::simplify_rec(expr * e0) {
expr_ref r(m);
expr* e = 0;
expr* e = nullptr;
TRACE("simplify", tout << "depth: " << m_depth << " " << mk_pp(e0, m) << "\n";);
if (!m_result.find(e0, e)) {
@ -372,9 +372,9 @@ void dom_simplify_tactic::simplify_goal(goal& g) {
}
CTRACE("simplify", r != g.form(i), tout << r << " " << mk_pp(g.form(i), m) << "\n";);
change |= r != g.form(i);
proof* new_pr = 0;
proof* new_pr = nullptr;
if (g.proofs_enabled()) {
new_pr = m.mk_modus_ponens(g.pr(i), m.mk_rewrite_star(g.form(i), r, 0, 0));
new_pr = m.mk_modus_ponens(g.pr(i), m.mk_rewrite(g.form(i), r));
}
g.update(i, r, new_pr, g.dep(i));
}
@ -392,9 +392,9 @@ void dom_simplify_tactic::simplify_goal(goal& g) {
}
change |= r != g.form(i);
CTRACE("simplify", r != g.form(i), tout << r << " " << mk_pp(g.form(i), m) << "\n";);
proof* new_pr = 0;
proof* new_pr = nullptr;
if (g.proofs_enabled()) {
new_pr = m.mk_modus_ponens(g.pr(i), m.mk_rewrite_star(g.form(i), r, 0, 0));
new_pr = m.mk_modus_ponens(g.pr(i), m.mk_rewrite(g.form(i), r));
}
g.update(i, r, new_pr, g.dep(i));
}
@ -440,14 +440,14 @@ bool expr_substitution_simplifier::assert_expr(expr * t, bool sign) {
m_scoped_substitution.push();
expr* tt;
if (!sign) {
update_substitution(t, 0);
update_substitution(t, nullptr);
}
else if (m.is_not(t, tt)) {
update_substitution(tt, 0);
update_substitution(tt, nullptr);
}
else {
expr_ref nt(m.mk_not(t), m);
update_substitution(nt, 0);
update_substitution(nt, nullptr);
}
return true;
}

View file

@ -111,7 +111,7 @@ class dom_simplify_tactic : public tactic {
bool is_subexpr(expr * a, expr * b);
expr_ref get_cached(expr* t) { expr* r = 0; if (!m_result.find(t, r)) r = t; return expr_ref(r, m); }
expr_ref get_cached(expr* t) { expr* r = nullptr; if (!m_result.find(t, r)) r = t; return expr_ref(r, m); }
void cache(expr *t, expr* r) { m_result.insert(t, r); m_trail.push_back(r); }
ptr_vector<expr> const & tree(expr * e);
@ -129,7 +129,7 @@ public:
m_trail(m), m_args(m),
m_dominators(m), m_depth(0), m_max_depth(1024), m_forward(true) {}
virtual ~dom_simplify_tactic();
~dom_simplify_tactic() override;
tactic * translate(ast_manager & m) override;
void updt_params(params_ref const & p) override {}
@ -153,18 +153,18 @@ class expr_substitution_simplifier : public dom_simplifier {
public:
expr_substitution_simplifier(ast_manager& m): m(m), m_subst(m), m_scoped_substitution(m_subst), m_trail(m) {}
virtual ~expr_substitution_simplifier() {}
virtual bool assert_expr(expr * t, bool sign);
~expr_substitution_simplifier() override {}
bool assert_expr(expr * t, bool sign) override;
void update_substitution(expr* n, proof* pr);
virtual void operator()(expr_ref& r) { r = m_scoped_substitution.find(r); }
void operator()(expr_ref& r) override { r = m_scoped_substitution.find(r); }
virtual void pop(unsigned num_scopes) { m_scoped_substitution.pop(num_scopes); }
void pop(unsigned num_scopes) override { m_scoped_substitution.pop(num_scopes); }
virtual unsigned scope_level() const { return m_scoped_substitution.scope_level(); }
unsigned scope_level() const override { return m_scoped_substitution.scope_level(); }
virtual dom_simplifier * translate(ast_manager & m) {
dom_simplifier * translate(ast_manager & m) override {
SASSERT(m_subst.empty());
return alloc(expr_substitution_simplifier, m);
}

View file

@ -51,7 +51,7 @@ class elim_term_ite_tactic : public tactic {
proof_ref new_def_pr(m);
app_ref _result(m);
if (m_defined_names.mk_name(new_ite, new_def, new_def_pr, _result, result_pr)) {
m_goal->assert_expr(new_def, new_def_pr, 0);
m_goal->assert_expr(new_def, new_def_pr, nullptr);
m_num_fresh++;
if (m_produce_models) {
if (!m_mc)
@ -65,9 +65,9 @@ class elim_term_ite_tactic : public tactic {
rw_cfg(ast_manager & _m, params_ref const & p):
m(_m),
m_defined_names(m, 0 /* don't use prefix */) {
m_defined_names(m, nullptr /* don't use prefix */) {
updt_params(p);
m_goal = 0;
m_goal = nullptr;
m_num_fresh = 0;
}
@ -137,7 +137,7 @@ public:
m_imp = alloc(imp, m, p);
}
virtual ~elim_term_ite_tactic() {
~elim_term_ite_tactic() override {
dealloc(m_imp);
}

View file

@ -94,7 +94,7 @@ class elim_uncnstr_tactic : public tactic {
return false; // variable already existed for this application
}
v = m().mk_fresh_const(0, m().get_sort(t));
v = m().mk_fresh_const(nullptr, m().get_sort(t));
TRACE("elim_uncnstr_bug", tout << "eliminating:\n" << mk_ismt2_pp(t, m()) << "\n";);
TRACE("elim_uncnstr_bug_ll", tout << "eliminating:\n" << mk_bounded_pp(t, m()) << "\n";);
m_fresh_vars.push_back(v);
@ -219,7 +219,7 @@ class elim_uncnstr_tactic : public tactic {
t = arg1;
}
else {
return 0;
return nullptr;
}
sort * s = m().get_sort(arg1);
@ -242,14 +242,14 @@ class elim_uncnstr_tactic : public tactic {
// variables.
//
if (!m().is_fully_interp(s))
return 0;
return nullptr;
// If the interpreted sort has only one element,
// then it is unsound to eliminate the unconstrained variable in the equality
sort_size sz = s->get_num_elements();
if (sz.is_finite() && sz.size() <= 1)
return 0;
return nullptr;
if (!m_mc) {
// easy case, model generation is disabled.
@ -266,7 +266,7 @@ class elim_uncnstr_tactic : public tactic {
add_def(v, m().mk_ite(u, t, d));
return u;
}
return 0;
return nullptr;
}
app * process_basic_app(func_decl * f, unsigned num, expr * const * args) {
@ -298,7 +298,7 @@ class elim_uncnstr_tactic : public tactic {
add_def(args[2], r);
return r;
}
return 0;
return nullptr;
case OP_NOT:
SASSERT(num == 1);
if (uncnstr(args[0])) {
@ -309,7 +309,7 @@ class elim_uncnstr_tactic : public tactic {
add_def(args[0], m().mk_not(r));
return r;
}
return 0;
return nullptr;
case OP_AND:
if (num > 0 && uncnstr(num, args)) {
app * r;
@ -319,7 +319,7 @@ class elim_uncnstr_tactic : public tactic {
add_defs(num, args, r, m().mk_true());
return r;
}
return 0;
return nullptr;
case OP_OR:
if (num > 0 && uncnstr(num, args)) {
app * r;
@ -329,13 +329,13 @@ class elim_uncnstr_tactic : public tactic {
add_defs(num, args, r, m().mk_false());
return r;
}
return 0;
return nullptr;
case OP_IFF:
case OP_EQ:
SASSERT(num == 2);
return process_eq(f, args[0], args[1]);
default:
return 0;
return nullptr;
}
}
@ -352,7 +352,7 @@ class elim_uncnstr_tactic : public tactic {
le = !le;
}
else {
return 0;
return nullptr;
}
app * u;
if (!mk_fresh_uncnstr_var_for(f, arg1, arg2, u))
@ -367,9 +367,9 @@ class elim_uncnstr_tactic : public tactic {
app * process_add(family_id fid, decl_kind add_k, decl_kind sub_k, unsigned num, expr * const * args) {
if (num == 0)
return 0;
return nullptr;
unsigned i;
expr * v = 0;
expr * v = nullptr;
for (i = 0; i < num; i++) {
expr * arg = args[i];
if (uncnstr(arg)) {
@ -377,8 +377,8 @@ class elim_uncnstr_tactic : public tactic {
break;
}
}
if (v == 0)
return 0;
if (v == nullptr)
return nullptr;
app * u;
if (!mk_fresh_uncnstr_var_for(m().mk_app(fid, add_k, num, args), u))
return u;
@ -406,7 +406,7 @@ class elim_uncnstr_tactic : public tactic {
app * process_arith_mul(func_decl * f, unsigned num, expr * const * args) {
if (num == 0)
return 0;
return nullptr;
sort * s = m().get_sort(args[0]);
if (uncnstr(num, args)) {
app * r;
@ -421,7 +421,7 @@ class elim_uncnstr_tactic : public tactic {
rational val;
if (num == 2 && uncnstr(args[1]) && m_a_util.is_numeral(args[0], val, is_int) && !is_int) {
if (val.is_zero())
return 0;
return nullptr;
app * r;
if (!mk_fresh_uncnstr_var_for(f, num, args, r))
return r;
@ -431,7 +431,7 @@ class elim_uncnstr_tactic : public tactic {
}
return r;
}
return 0;
return nullptr;
}
app * process_arith_app(func_decl * f, unsigned num, expr * const * args) {
@ -449,13 +449,13 @@ class elim_uncnstr_tactic : public tactic {
SASSERT(num == 2);
return process_le_ge(f, args[0], args[1], false);
default:
return 0;
return nullptr;
}
}
app * process_bv_mul(func_decl * f, unsigned num, expr * const * args) {
if (num == 0)
return 0;
return nullptr;
if (uncnstr(num, args)) {
sort * s = m().get_sort(args[0]);
app * r;
@ -481,12 +481,12 @@ class elim_uncnstr_tactic : public tactic {
add_def(args[1], m_bv_util.mk_bv_mul(m_bv_util.mk_numeral(inv, s), r));
return r;
}
return 0;
return nullptr;
}
app * process_extract(func_decl * f, expr * arg) {
if (!uncnstr(arg))
return 0;
return nullptr;
app * r;
if (!mk_fresh_uncnstr_var_for(f, arg, r))
return r;
@ -522,14 +522,14 @@ class elim_uncnstr_tactic : public tactic {
add_def(arg2, m_bv_util.mk_numeral(rational(1), s));
return r;
}
return 0;
return nullptr;
}
app * process_concat(func_decl * f, unsigned num, expr * const * args) {
if (num == 0)
return 0;
return nullptr;
if (!uncnstr(num, args))
return 0;
return nullptr;
app * r;
if (!mk_fresh_uncnstr_var_for(f, num, args, r))
return r;
@ -552,7 +552,7 @@ class elim_uncnstr_tactic : public tactic {
// The result of bv_le is not just introducing a new fresh name,
// we need a side condition.
// TODO: the correct proof step
return 0;
return nullptr;
}
if (uncnstr(arg1)) {
// v <= t
@ -592,7 +592,7 @@ class elim_uncnstr_tactic : public tactic {
add_def(v, m().mk_ite(r, t, m_bv_util.mk_bv_sub(t, m_bv_util.mk_numeral(rational(1), bv_sz))));
return r;
}
return 0;
return nullptr;
}
app * process_bv_app(func_decl * f, unsigned num, expr * const * args) {
@ -629,7 +629,7 @@ class elim_uncnstr_tactic : public tactic {
add_def(args[0], m().mk_app(f, r));
return r;
}
return 0;
return nullptr;
case OP_BOR:
if (num > 0 && uncnstr(num, args)) {
sort * s = m().get_sort(args[0]);
@ -640,9 +640,9 @@ class elim_uncnstr_tactic : public tactic {
add_defs(num, args, r, m_bv_util.mk_numeral(rational(0), s));
return r;
}
return 0;
return nullptr;
default:
return 0;
return nullptr;
}
}
@ -659,7 +659,7 @@ class elim_uncnstr_tactic : public tactic {
add_def(args[0], m_ar_util.mk_const_array(s, r));
return r;
}
return 0;
return nullptr;
case OP_STORE:
if (uncnstr(args[0]) && uncnstr(args[num-1])) {
app * r;
@ -672,7 +672,7 @@ class elim_uncnstr_tactic : public tactic {
return r;
}
default:
return 0;
return nullptr;
}
}
@ -699,7 +699,7 @@ class elim_uncnstr_tactic : public tactic {
func_decl * c = m_dt_util.get_accessor_constructor(f);
for (unsigned i = 0; i < c->get_arity(); i++)
if (!m().is_fully_interp(c->get_domain(i)))
return 0;
return nullptr;
app * u;
if (!mk_fresh_uncnstr_var_for(f, num, args, u))
return u;
@ -729,7 +729,7 @@ class elim_uncnstr_tactic : public tactic {
return u;
}
}
return 0;
return nullptr;
}
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
@ -744,7 +744,7 @@ class elim_uncnstr_tactic : public tactic {
return BR_FAILED; // non-ground terms are not handled.
}
app * u = 0;
app * u = nullptr;
if (fid == m().get_basic_family_id())
u = process_basic_app(f, num, args);
@ -757,7 +757,7 @@ class elim_uncnstr_tactic : public tactic {
else if (fid == m_dt_util.get_family_id())
u = process_datatype_app(f, num, args);
if (u == 0)
if (u == nullptr)
return BR_FAILED;
result = u;
@ -805,7 +805,7 @@ class elim_uncnstr_tactic : public tactic {
void init_mc(bool produce_models) {
if (!produce_models) {
m_mc = 0;
m_mc = nullptr;
return;
}
m_mc = alloc(mc, m(), "elim_uncstr");
@ -814,12 +814,11 @@ class elim_uncnstr_tactic : public tactic {
void init_rw(bool produce_proofs) {
m_rw = alloc(rw, m(), produce_proofs, m_vars, m_mc.get(), m_max_memory, m_max_steps);
}
void operator()(goal_ref const & g,
goal_ref_buffer & result) {
void operator()(goal_ref const & g, goal_ref_buffer& result) {
bool produce_models = g->models_enabled();
bool produce_proofs = g->proofs_enabled();
TRACE("elim_uncnstr_bug", g->display(tout););
tactic_report report("elim-uncnstr-vars", *g);
m_vars.reset();
@ -832,10 +831,7 @@ class elim_uncnstr_tactic : public tactic {
}
bool modified = true;
TRACE("elim_uncnstr", tout << "unconstrained variables...\n";
obj_hashtable<expr>::iterator it = m_vars.begin();
obj_hashtable<expr>::iterator end = m_vars.end();
for (; it != end; ++it) {
expr * v = *it;
for (expr * v : m_vars) {
tout << mk_ismt2_pp(v, m()) << " ";
}
tout << "\n";);
@ -876,8 +872,8 @@ class elim_uncnstr_tactic : public tactic {
g->set((model_converter*)nullptr);
}
}
m_mc = 0;
m_rw = 0;
m_mc = nullptr;
m_rw = nullptr;
result.push_back(g.get());
g->inc_depth();
return;
@ -897,7 +893,7 @@ class elim_uncnstr_tactic : public tactic {
idx = 0;
}
}
};
imp * m_imp;
@ -908,31 +904,31 @@ public:
m_imp = alloc(imp, m, p);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(elim_uncnstr_tactic, m, m_params);
}
virtual ~elim_uncnstr_tactic() {
~elim_uncnstr_tactic() override {
dealloc(m_imp);
}
virtual void updt_params(params_ref const & p) {
void updt_params(params_ref const & p) override {
m_params = p;
m_imp->updt_params(p);
}
virtual void collect_param_descrs(param_descrs & r) {
void collect_param_descrs(param_descrs & r) override {
insert_max_memory(r);
insert_max_steps(r);
}
virtual void operator()(goal_ref const & g,
goal_ref_buffer & result) {
void operator()(goal_ref const & g,
goal_ref_buffer & result) override {
(*m_imp)(g, result);
report_tactic_progress(":num-elim-apps", get_num_elim_apps());
}
virtual void cleanup() {
void cleanup() override {
unsigned num_elim_apps = get_num_elim_apps();
ast_manager & m = m_imp->m_manager;
imp * d = alloc(imp, m, m_params);
@ -945,11 +941,11 @@ public:
return m_imp->m_num_elim_apps;
}
virtual void collect_statistics(statistics & st) const {
void collect_statistics(statistics & st) const override {
st.update("eliminated applications", get_num_elim_apps());
}
virtual void reset_statistics() {
void reset_statistics() override {
m_imp->m_num_elim_apps = 0;
}

View file

@ -246,28 +246,28 @@ public:
m_eq = alloc(rewriter_eq, m, *m_map, p);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(injectivity_tactic, m, m_params);
}
virtual ~injectivity_tactic() {
~injectivity_tactic() override {
dealloc(m_finder);
dealloc(m_eq);
dealloc(m_map);
}
virtual void updt_params(params_ref const & p) {
void updt_params(params_ref const & p) override {
m_params = p;
m_finder->updt_params(p);
}
virtual void collect_param_descrs(param_descrs & r) {
void collect_param_descrs(param_descrs & r) override {
insert_max_memory(r);
insert_produce_models(r);
}
virtual void operator()(goal_ref const & g,
goal_ref_buffer & result) {
void operator()(goal_ref const & g,
goal_ref_buffer & result) override {
(*m_finder)(g, result);
for (unsigned i = 0; i < g->size(); ++i) {
@ -280,7 +280,7 @@ public:
result.push_back(g.get());
}
virtual void cleanup() {
void cleanup() override {
InjHelper * m = alloc(InjHelper, m_manager);
finder * f = alloc(finder, m_manager, *m, m_params);
rewriter_eq * r = alloc(rewriter_eq, m_manager, *m, m_params);

View file

@ -33,28 +33,27 @@ class nnf_tactic : public tactic {
}
~set_nnf() {
m_owner.m_nnf = 0;
m_owner.m_nnf = nullptr;
}
};
public:
nnf_tactic(params_ref const & p):
m_params(p),
m_nnf(0) {
m_nnf(nullptr) {
TRACE("nnf", tout << "nnf_tactic constructor: " << p << "\n";);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(nnf_tactic, m_params);
}
virtual ~nnf_tactic() {}
~nnf_tactic() override {}
virtual void updt_params(params_ref const & p) { m_params = p; }
void updt_params(params_ref const & p) override { m_params = p; }
virtual void collect_param_descrs(param_descrs & r) { nnf::get_param_descrs(r); }
void collect_param_descrs(param_descrs & r) override { nnf::get_param_descrs(r); }
virtual void operator()(goal_ref const & g,
goal_ref_buffer & result) {
void operator()(goal_ref const & g, goal_ref_buffer & result) override {
TRACE("nnf", tout << "params: " << m_params << "\n"; g->display(tout););
SASSERT(g->is_well_sorted());
tactic_report report("nnf", *g);
@ -85,9 +84,9 @@ public:
sz = defs.size();
for (unsigned i = 0; i < sz; i++) {
if (produce_proofs)
g->assert_expr(defs.get(i), def_prs.get(i), 0);
g->assert_expr(defs.get(i), def_prs.get(i), nullptr);
else
g->assert_expr(defs.get(i), 0, 0);
g->assert_expr(defs.get(i), nullptr, nullptr);
}
g->inc_depth();
result.push_back(g.get());
@ -102,7 +101,7 @@ public:
SASSERT(g->is_well_sorted());
}
virtual void cleanup() {}
void cleanup() override {}
};
tactic * mk_snf_tactic(ast_manager & m, params_ref const & p) {

View file

@ -9,7 +9,7 @@ Abstract:
Put clauses in the assertion set in
OOC (one constraint per clause) form.
Constraints occuring in formulas that
Constraints occurring in formulas that
are not clauses are ignored.
The formula can be put into CNF by
using mk_sat_preprocessor strategy.
@ -68,7 +68,7 @@ class occf_tactic : public tactic {
expr * m_bvar;
unsigned m_gen_pos:1;
unsigned m_gen_neg:1;
bvar_info():m_bvar(0), m_gen_pos(false), m_gen_neg(false) {}
bvar_info():m_bvar(nullptr), m_gen_pos(false), m_gen_neg(false) {}
bvar_info(expr * var, bool sign):
m_bvar(var),
m_gen_pos(!sign),
@ -86,20 +86,20 @@ class occf_tactic : public tactic {
}
cnstr2bvar::obj_map_entry * entry = c2b.find_core(cnstr);
if (entry == 0)
return 0;
if (entry == nullptr)
return nullptr;
bvar_info & info = entry->get_data().m_value;
if (sign) {
if (!info.m_gen_neg) {
info.m_gen_neg = true;
g->assert_expr(m.mk_or(info.m_bvar, m.mk_not(cnstr)), 0, 0);
g->assert_expr(m.mk_or(info.m_bvar, m.mk_not(cnstr)), nullptr, nullptr);
}
return m.mk_not(info.m_bvar);
}
else {
if (!info.m_gen_pos) {
info.m_gen_pos = true;
g->assert_expr(m.mk_or(m.mk_not(info.m_bvar), cnstr), 0, 0);
g->assert_expr(m.mk_or(m.mk_not(info.m_bvar), cnstr), nullptr, nullptr);
}
return info.m_bvar;
}
@ -113,16 +113,16 @@ class occf_tactic : public tactic {
}
SASSERT(!c2b.contains(cnstr));
expr * bvar = m.mk_fresh_const(0, m.mk_bool_sort());
expr * bvar = m.mk_fresh_const(nullptr, m.mk_bool_sort());
if (produce_models)
m_mc->hide(to_app(bvar)->get_decl());
c2b.insert(cnstr, bvar_info(bvar, sign));
if (sign) {
g->assert_expr(m.mk_or(bvar, m.mk_not(cnstr)), 0, 0);
g->assert_expr(m.mk_or(bvar, m.mk_not(cnstr)), nullptr, nullptr);
return m.mk_not(bvar);
}
else {
g->assert_expr(m.mk_or(m.mk_not(bvar), cnstr), 0, 0);
g->assert_expr(m.mk_or(m.mk_not(bvar), cnstr), nullptr, nullptr);
return bvar;
}
}
@ -130,13 +130,12 @@ class occf_tactic : public tactic {
void operator()(goal_ref const & g,
goal_ref_buffer & result) {
SASSERT(g->is_well_sorted());
fail_if_proof_generation("occf", g);
bool produce_models = g->models_enabled();
tactic_report report("occf", *g);
m_mc = 0;
m_mc = nullptr;
ptr_vector<expr> new_lits;
@ -156,17 +155,17 @@ class occf_tactic : public tactic {
m_mc = alloc(generic_model_converter, m, "occf");
g->add(m_mc);
}
expr * keep = 0;
expr * keep = nullptr;
new_lits.reset();
unsigned num = cls->get_num_args();
for (unsigned j = 0; j < num; j++) {
expr * l = cls->get_arg(j);
if (is_constraint(l)) {
expr * new_l = get_aux_lit(c2b, l, g);
if (new_l != 0) {
if (new_l != nullptr) {
new_lits.push_back(new_l);
}
else if (keep == 0) {
else if (keep == nullptr) {
keep = l;
}
else {
@ -178,9 +177,9 @@ class occf_tactic : public tactic {
new_lits.push_back(l);
}
}
if (keep != 0)
if (keep != nullptr)
new_lits.push_back(keep);
g->update(i, m.mk_or(new_lits.size(), new_lits.c_ptr()), 0, d);
g->update(i, m.mk_or(new_lits.size(), new_lits.c_ptr()), nullptr, d);
}
g->inc_depth();
result.push_back(g.get());
@ -195,23 +194,23 @@ public:
m_imp = alloc(imp, m);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(occf_tactic, m);
}
virtual ~occf_tactic() {
~occf_tactic() override {
dealloc(m_imp);
}
virtual void updt_params(params_ref const & p) {}
virtual void collect_param_descrs(param_descrs & r) {}
void updt_params(params_ref const & p) override {}
void collect_param_descrs(param_descrs & r) override {}
virtual void operator()(goal_ref const & in,
goal_ref_buffer & result) {
void operator()(goal_ref const & in,
goal_ref_buffer & result) override {
(*m_imp)(in, result);
}
virtual void cleanup() {
void cleanup() override {
imp * d = alloc(imp, m_imp->m);
std::swap(d, m_imp);
dealloc(d);

View file

@ -9,7 +9,7 @@ Abstract:
Put clauses in the assertion set in
OOC (one constraint per clause) form.
Constraints occuring in formulas that
Constraints occurring in formulas that
are not clauses are ignored.
The formula can be put into CNF by
using mk_sat_preprocessor strategy.

View file

@ -101,9 +101,9 @@ public:
pb_preprocess_tactic(ast_manager& m, params_ref const& p = params_ref()):
m(m), pb(m), m_r(m) {}
virtual ~pb_preprocess_tactic() {}
~pb_preprocess_tactic() override {}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(pb_preprocess_tactic, m);
}
@ -212,7 +212,7 @@ public:
if (!to_ge(g->form(k), args2, coeffs2, k2)) continue;
if (subsumes(args1, coeffs1, k1, args2, coeffs2, k2)) {
IF_VERBOSE(3, verbose_stream() << "replace " << mk_pp(g->form(k), m) << "\n";);
g->update(k, m.mk_true(), 0, m.mk_join(g->dep(m_ge[i]), g->dep(k)));
g->update(k, m.mk_true(), nullptr, m.mk_join(g->dep(m_ge[i]), g->dep(k)));
m_progress = true;
}
}
@ -223,15 +223,15 @@ public:
return m_progress;
}
virtual void updt_params(params_ref const & p) {
void updt_params(params_ref const & p) override {
}
virtual void cleanup() {
void cleanup() override {
}
private:
void reset() {
void reset() override {
m_ge.reset();
m_other.reset();
m_vars.reset();
@ -290,12 +290,12 @@ private:
for (unsigned j = 0; j < cuts.size(); ++j) {
unsigned end = cuts[j];
fml1 = decompose_cut(a, start, end, cut_args, cut_coeffs);
g->assert_expr(fml1, 0, g->dep(i));
g->assert_expr(fml1, nullptr, g->dep(i));
start = end;
TRACE("pb", tout << fml1 << "\n";);
}
fml2 = pb.mk_ge(cut_args.size(), cut_coeffs.c_ptr(), cut_args.c_ptr(), pb.get_k(e));
g->update(i, fml2, 0, g->dep(i));
g->update(i, fml2, nullptr, g->dep(i));
TRACE("pb", tout << fml2 << "\n";);
}
}
@ -540,8 +540,8 @@ private:
tout << "resolve: " << mk_pp(fml1, m) << "\n" << mk_pp(fml2, m) << "\n" << tmp1 << "\n";
tout << "to\n" << mk_pp(fml2, m) << " -> " << tmp2 << "\n";);
g->update(idx2, tmp2, 0, m.mk_join(g->dep(idx1), g->dep(idx2)));
g->update(idx1, m.mk_true(), 0, 0);
g->update(idx2, tmp2, nullptr, m.mk_join(g->dep(idx1), g->dep(idx2)));
g->update(idx1, m.mk_true(), nullptr, nullptr);
m_progress = true;
//IF_VERBOSE(0, if (!g->inconsistent()) display_annotation(verbose_stream(), g););
}
@ -613,7 +613,7 @@ private:
}
}
}
m_r.set_substitution(0);
m_r.set_substitution(nullptr);
}
bool subsumes(expr_ref_vector const& args1,

View file

@ -39,7 +39,7 @@ class propagate_values_tactic : public tactic {
imp(ast_manager & m, params_ref const & p):
m(m),
m_r(m, p),
m_goal(0),
m_goal(nullptr),
m_occs(m, true /* track atoms */) {
updt_params_core(p);
}
@ -93,7 +93,7 @@ class propagate_values_tactic : public tactic {
if (m_goal->unsat_core_enabled()) {
new_d = m_goal->dep(m_idx);
expr_dependency * used_d = m_r.get_used_dependencies();
if (used_d != 0) {
if (used_d != nullptr) {
new_d = m.mk_join(new_d, used_d);
m_r.reset_used_dependencies();
}
@ -220,8 +220,7 @@ class propagate_values_tactic : public tactic {
SASSERT(m_goal->is_well_sorted());
TRACE("propagate_values", tout << "end\n"; m_goal->display(tout););
TRACE("propagate_values_core", m_goal->display_with_dependencies(tout););
//IF_VERBOSE(0, m_goal->display(verbose_stream()));
m_goal = 0;
m_goal = nullptr;
}
};
@ -233,20 +232,20 @@ public:
m_imp = alloc(imp, m, p);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(propagate_values_tactic, m, m_params);
}
virtual ~propagate_values_tactic() {
~propagate_values_tactic() override {
dealloc(m_imp);
}
virtual void updt_params(params_ref const & p) {
void updt_params(params_ref const & p) override {
m_params = p;
m_imp->updt_params(p);
}
virtual void collect_param_descrs(param_descrs & r) {
void collect_param_descrs(param_descrs & r) override {
th_rewriter::get_param_descrs(r);
r.insert("max_rounds", CPK_UINT, "(default: 2) maximum number of rounds.");
}
@ -260,10 +259,11 @@ public:
}
}
virtual void cleanup() {
void cleanup() override {
ast_manager & m = m_imp->m;
dealloc(m_imp);
m_imp = alloc(imp, m, m_params);
params_ref p = std::move(m_params);
m_imp->~imp();
new (m_imp) imp(m, p);
}
};

View file

@ -67,11 +67,11 @@ class reduce_args_tactic : public tactic {
public:
reduce_args_tactic(ast_manager & m);
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(reduce_args_tactic, m);
}
virtual ~reduce_args_tactic();
~reduce_args_tactic() override;
void operator()(goal_ref const & g, goal_ref_buffer & result) override;
void cleanup() override;
@ -103,7 +103,7 @@ struct reduce_args_tactic::imp {
}
static bool may_be_unique(ast_manager& m, bv_util& bv, expr* e, expr*& base) {
base = 0;
base = nullptr;
return m.is_unique_value(e) || is_var_plus_offset(m, bv, e, base);
}
@ -340,7 +340,7 @@ struct reduce_args_tactic::imp {
}
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
result_pr = 0;
result_pr = nullptr;
if (f->get_arity() == 0)
return BR_FAILED; // ignore constants
if (f->get_family_id() != null_family_id)
@ -356,7 +356,7 @@ struct reduce_args_tactic::imp {
}
app_ref tmp(m.mk_app(f, num, args), m);
func_decl *& new_f = map->insert_if_not_there2(tmp, 0)->get_data().m_value;
func_decl *& new_f = map->insert_if_not_there2(tmp, nullptr)->get_data().m_value;
if (!new_f) {
// create fresh symbol
ptr_buffer<sort> domain;
@ -397,7 +397,7 @@ struct reduce_args_tactic::imp {
for (auto const& kv : decl2arg2funcs) {
func_decl * f = kv.m_key;
arg2func * map = kv.m_value;
expr * def = 0;
expr * def = nullptr;
SASSERT(decl2args.contains(f));
bit_vector & bv = decl2args.find(f);
new_vars.reset();
@ -415,7 +415,7 @@ struct reduce_args_tactic::imp {
f_mc->hide(new_def);
SASSERT(new_def->get_arity() == new_args.size());
app * new_t = m_manager.mk_app(new_def, new_args.size(), new_args.c_ptr());
if (def == 0) {
if (def == nullptr) {
def = new_t;
}
else {

View file

@ -107,9 +107,9 @@ void simplify_tactic::operator()(goal_ref const & in,
void simplify_tactic::cleanup() {
ast_manager & m = m_imp->m();
imp * d = alloc(imp, m, m_params);
std::swap(d, m_imp);
dealloc(d);
params_ref p = std::move(m_params);
m_imp->~imp();
new (m_imp) imp(m, p);
}
unsigned simplify_tactic::get_num_steps() const {

View file

@ -28,7 +28,7 @@ class simplify_tactic : public tactic {
params_ref m_params;
public:
simplify_tactic(ast_manager & m, params_ref const & ref = params_ref());
virtual ~simplify_tactic();
~simplify_tactic() override;
void updt_params(params_ref const & p) override;

View file

@ -45,6 +45,7 @@ class solve_eqs_tactic : public tactic {
expr_sparse_mark m_candidate_set;
ptr_vector<expr> m_candidates;
ptr_vector<app> m_vars;
expr_sparse_mark m_nonzero;
ptr_vector<app> m_ordered_vars;
bool m_produce_proofs;
bool m_produce_unsat_cores;
@ -53,13 +54,12 @@ class solve_eqs_tactic : public tactic {
imp(ast_manager & m, params_ref const & p, expr_replacer * r, bool owner):
m_manager(m),
m_r(r),
m_r_owner(r == 0 || owner),
m_r_owner(r == nullptr || owner),
m_a_util(m),
m_num_steps(0),
m_num_eliminated_vars(0)
{
m_num_eliminated_vars(0) {
updt_params(p);
if (m_r == 0)
if (m_r == nullptr)
m_r = mk_default_expr_replacer(m);
}
@ -79,7 +79,7 @@ class solve_eqs_tactic : public tactic {
void checkpoint() {
if (m().canceled())
throw tactic_exception(m().limit().get_cancel_msg());
cooperate("solve-eqs");
cooperate("solve-eqs");
}
// Check if the number of occurrences of t is below the specified threshold :solve-eqs-max-occs
@ -99,7 +99,7 @@ class solve_eqs_tactic : public tactic {
if (is_uninterp_const(lhs) && !m_candidate_vars.is_marked(lhs) && !occurs(lhs, rhs) && check_occs(lhs)) {
var = to_app(lhs);
def = rhs;
pr = 0;
pr = nullptr;
return true;
}
else {
@ -107,7 +107,8 @@ class solve_eqs_tactic : public tactic {
}
}
bool trivial_solve(expr * lhs, expr * rhs, app_ref & var, expr_ref & def, proof_ref & pr) {
if (trivial_solve1(lhs, rhs, var, def, pr)) return true;
if (trivial_solve1(lhs, rhs, var, def, pr))
return true;
if (trivial_solve1(rhs, lhs, var, def, pr)) {
if (m_produce_proofs) {
pr = m().mk_commutativity(m().mk_eq(lhs, rhs));
@ -188,6 +189,77 @@ class solve_eqs_tactic : public tactic {
}
return false;
}
void add_pos(expr* f) {
expr* lhs = nullptr, *rhs = nullptr;
rational val;
if (m_a_util.is_le(f, lhs, rhs) && m_a_util.is_numeral(rhs, val) && val.is_neg()) {
m_nonzero.mark(lhs);
}
else if (m_a_util.is_ge(f, lhs, rhs) && m_a_util.is_numeral(rhs, val) && val.is_pos()) {
m_nonzero.mark(lhs);
}
else if (m().is_not(f, f)) {
if (m_a_util.is_le(f, lhs, rhs) && m_a_util.is_numeral(rhs, val) && !val.is_neg()) {
m_nonzero.mark(lhs);
}
else if (m_a_util.is_ge(f, lhs, rhs) && m_a_util.is_numeral(rhs, val) && !val.is_pos()) {
m_nonzero.mark(lhs);
}
else if (m().is_eq(f, lhs, rhs) && m_a_util.is_numeral(rhs, val) && val.is_zero()) {
m_nonzero.mark(lhs);
}
}
}
bool is_nonzero(expr* e) {
return m_nonzero.is_marked(e);
}
bool isolate_var(app* arg, app_ref& var, expr_ref& div, unsigned i, app* lhs, expr* rhs) {
if (!m_a_util.is_mul(arg)) return false;
unsigned n = arg->get_num_args();
for (unsigned j = 0; j < n; ++j) {
expr* e = arg->get_arg(j);
bool ok = is_uninterp_const(e) && check_occs(e) && !occurs(e, rhs) && !occurs_except(e, lhs, i);
if (!ok) continue;
var = to_app(e);
for (unsigned k = 0; ok && k < n; ++k) {
expr* arg_k = arg->get_arg(k);
ok = k == j || (!occurs(var, arg_k) && is_nonzero(arg_k));
}
if (!ok) continue;
ptr_vector<expr> args;
for (unsigned k = 0; k < n; ++k) {
if (k != j) args.push_back(arg->get_arg(k));
}
div = m_a_util.mk_mul(args.size(), args.c_ptr());
return true;
}
return false;
}
bool solve_nl(app * lhs, expr * rhs, expr* eq, app_ref& var, expr_ref & def, proof_ref & pr) {
SASSERT(m_a_util.is_add(lhs));
if (m_a_util.is_int(lhs)) return false;
unsigned num = lhs->get_num_args();
expr_ref div(m());
for (unsigned i = 0; i < num; i++) {
expr * arg = lhs->get_arg(i);
if (is_app(arg) && isolate_var(to_app(arg), var, div, i, lhs, rhs)) {
ptr_vector<expr> args;
for (unsigned k = 0; k < num; ++k) {
if (k != i) args.push_back(lhs->get_arg(k));
}
def = m_a_util.mk_sub(rhs, m_a_util.mk_add(args.size(), args.c_ptr()));
def = m_a_util.mk_div(def, div);
if (m_produce_proofs)
pr = m().mk_rewrite(eq, m().mk_eq(var, def));
return true;
}
}
return false;
}
bool solve_arith_core(app * lhs, expr * rhs, expr * eq, app_ref & var, expr_ref & def, proof_ref & pr) {
SASSERT(m_a_util.is_add(lhs));
@ -205,7 +277,8 @@ class solve_eqs_tactic : public tactic {
break;
}
else if (m_a_util.is_mul(arg, a, v) &&
is_uninterp_const(v) && !m_candidate_vars.is_marked(v) &&
is_uninterp_const(v) &&
!m_candidate_vars.is_marked(v) &&
m_a_util.is_numeral(a, a_val) &&
!a_val.is_zero() &&
(!is_int || a_val.is_minus_one()) &&
@ -253,16 +326,20 @@ class solve_eqs_tactic : public tactic {
return
(m_a_util.is_add(lhs) && solve_arith_core(to_app(lhs), rhs, eq, var, def, pr)) ||
(m_a_util.is_add(rhs) && solve_arith_core(to_app(rhs), lhs, eq, var, def, pr));
#if 0
// better done inside of nlsat
(m_a_util.is_add(lhs) && solve_nl(to_app(lhs), rhs, eq, var, def, pr)) ||
(m_a_util.is_add(rhs) && solve_nl(to_app(rhs), lhs, eq, var, def, pr));
#endif
}
bool solve(expr * f, app_ref & var, expr_ref & def, proof_ref & pr) {
if (m().is_eq(f)) {
if (trivial_solve(to_app(f)->get_arg(0), to_app(f)->get_arg(1), var, def, pr))
expr* arg1 = nullptr, *arg2 = nullptr;
if (m().is_eq(f, arg1, arg2)) {
if (trivial_solve(arg1, arg2, var, def, pr))
return true;
if (m_theory_solver) {
expr * lhs = to_app(f)->get_arg(0);
expr * rhs = to_app(f)->get_arg(1);
if (solve_arith(lhs, rhs, f, var, def, pr))
if (solve_arith(arg1, arg2, f, var, def, pr))
return true;
}
return false;
@ -317,16 +394,19 @@ class solve_eqs_tactic : public tactic {
void collect(goal const & g) {
m_subst->reset();
m_norm_subst->reset();
m_r->set_substitution(0);
m_r->set_substitution(nullptr);
m_candidate_vars.reset();
m_candidate_set.reset();
m_candidates.reset();
m_vars.reset();
m_nonzero.reset();
app_ref var(m());
expr_ref def(m());
proof_ref pr(m());
unsigned size = g.size();
for (unsigned idx = 0; idx < size; idx++) {
add_pos(g.form(idx));
}
for (unsigned idx = 0; idx < size; idx++) {
checkpoint();
expr * f = g.form(idx);
@ -373,12 +453,9 @@ class solve_eqs_tactic : public tactic {
typedef std::pair<expr *, unsigned> frame;
svector<frame> todo;
ptr_vector<app>::const_iterator it = m_vars.begin();
ptr_vector<app>::const_iterator end = m_vars.end();
unsigned num;
for (; it != end; ++it) {
unsigned num = 0;
for (app* v : m_vars) {
checkpoint();
app * v = *it;
if (!m_candidate_vars.is_marked(v))
continue;
todo.push_back(frame(v, 0));
@ -423,7 +500,7 @@ class solve_eqs_tactic : public tactic {
// Must save t and its definition.
// See comment in the beginning of the function
expr * def = 0;
expr * def = nullptr;
proof * pr;
expr_dependency * dep;
m_subst->find(to_app(t), def, pr, dep);
@ -437,7 +514,7 @@ class solve_eqs_tactic : public tactic {
else {
visiting.mark(t);
fr.second = 1;
expr * def = 0;
expr * def = nullptr;
proof * pr;
expr_dependency * dep;
m_subst->find(to_app(t), def, pr, dep);
@ -482,11 +559,12 @@ class solve_eqs_tactic : public tactic {
}
// cleanup
it = m_vars.begin();
for (unsigned idx = 0; it != end; ++it, ++idx) {
if (!m_candidate_vars.is_marked(*it)) {
unsigned idx = 0;
for (expr* v : m_vars) {
if (!m_candidate_vars.is_marked(v)) {
m_candidate_set.mark(m_candidates[idx], false);
}
++idx;
}
TRACE("solve_eqs",
@ -508,9 +586,9 @@ class solve_eqs_tactic : public tactic {
expr_dependency_ref new_dep(m());
for (app * v : m_ordered_vars) {
checkpoint();
expr * def = 0;
proof * pr = 0;
expr_dependency * dep = 0;
expr * def = nullptr;
proof * pr = nullptr;
expr_dependency * dep = nullptr;
m_subst->find(v, def, pr, dep);
SASSERT(def != 0);
m_r->operator()(def, new_def, new_pr, new_dep);
@ -564,7 +642,7 @@ class solve_eqs_tactic : public tactic {
// so, we must remove remove the mark before doing the update
m_candidate_set.mark(f, false);
SASSERT(!m_candidate_set.is_marked(f));
g.update(idx, m().mk_true(), m().mk_true_proof(), 0);
g.update(idx, m().mk_true(), m().mk_true_proof(), nullptr);
m_num_steps ++;
continue;
}
@ -606,14 +684,14 @@ class solve_eqs_tactic : public tactic {
IF_VERBOSE(100, if (!m_ordered_vars.empty()) verbose_stream() << "num. eliminated vars: " << m_ordered_vars.size() << "\n";);
m_num_eliminated_vars += m_ordered_vars.size();
if (m_produce_models) {
if (mc.get() == 0)
mc = alloc(gmc, m(), "solve_eqs");
for (app * v : m_ordered_vars) {
expr * def = 0;
if (!mc.get())
mc = alloc(gmc, m(), "solve-eqs");
for (app* v : m_ordered_vars) {
expr * def = nullptr;
proof * pr;
expr_dependency * dep;
expr_dependency * dep = nullptr;
m_norm_subst->find(v, def, pr, dep);
SASSERT(def != 0);
SASSERT(def);
static_cast<gmc*>(mc.get())->add(v, def);
}
}
@ -715,7 +793,7 @@ public:
return alloc(solve_eqs_tactic, m, m_params, mk_expr_simp_replacer(m, m_params), true);
}
virtual ~solve_eqs_tactic() {
~solve_eqs_tactic() override {
dealloc(m_imp);
}
@ -731,7 +809,7 @@ public:
}
void operator()(goal_ref const & in,
goal_ref_buffer & result) override {
goal_ref_buffer & result) override {
(*m_imp)(in, result);
report_tactic_progress(":num-elim-vars", m_imp->get_num_eliminated_vars());
}
@ -741,7 +819,7 @@ public:
ast_manager & m = m_imp->m();
expr_replacer * r = m_imp->m_r;
if (r)
r->set_substitution(0);
r->set_substitution(nullptr);
bool owner = m_imp->m_r_owner;
m_imp->m_r_owner = false; // stole replacer
@ -762,7 +840,7 @@ public:
};
tactic * mk_solve_eqs_tactic(ast_manager & m, params_ref const & p, expr_replacer * r) {
if (r == 0)
if (r == nullptr)
return clean(alloc(solve_eqs_tactic, m, p, mk_expr_simp_replacer(m, p), true));
else
return clean(alloc(solve_eqs_tactic, m, p, r, false));

View file

@ -24,7 +24,7 @@ class ast_manager;
class tactic;
class expr_replacer;
tactic * mk_solve_eqs_tactic(ast_manager & m, params_ref const & p = params_ref(), expr_replacer * r = 0);
tactic * mk_solve_eqs_tactic(ast_manager & m, params_ref const & p = params_ref(), expr_replacer * r = nullptr);
/*
ADD_TACTIC("solve-eqs", "eliminate variables by solving equations.", "mk_solve_eqs_tactic(m, p)")

View file

@ -53,7 +53,7 @@ class split_clause_tactic : public tactic {
split_pc(ast_manager & m, app * cls, proof * pr):m(m), m_clause(cls, m), m_clause_pr(pr, m) {
}
virtual ~split_pc() { }
~split_pc() override { }
proof_ref operator()(ast_manager & m, unsigned num_source, proof * const * source) override {
// Let m_clause be of the form (l_0 or ... or l_{num_source - 1})
@ -83,13 +83,13 @@ public:
updt_params(ref);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
split_clause_tactic * t = alloc(split_clause_tactic);
t->m_largest_clause = m_largest_clause;
return t;
}
virtual ~split_clause_tactic() {
~split_clause_tactic() override {
}
void updt_params(params_ref const & p) override {
@ -119,7 +119,7 @@ public:
for (expr* lit_i : *cls) {
goal * subgoal_i = alloc(goal, *in);
subgoal_i->set(in->mc());
proof * pr_i = 0;
proof * pr_i = nullptr;
if (produce_proofs)
pr_i = m.mk_hypothesis(lit_i);
subgoal_i->update(cls_pos, lit_i, pr_i, cls_dep);
@ -130,7 +130,7 @@ public:
in->add(dependency_converter::concat(result.size(), result.c_ptr()));
}
virtual void cleanup() {
void cleanup() override {
// do nothing this tactic is too simple
}
};

View file

@ -32,15 +32,15 @@ class symmetry_reduce_tactic : public tactic {
public:
symmetry_reduce_tactic(ast_manager & m);
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(symmetry_reduce_tactic, m);
}
virtual ~symmetry_reduce_tactic();
~symmetry_reduce_tactic() override;
virtual void operator()(goal_ref const & g,
goal_ref_buffer & result);
virtual void cleanup();
void operator()(goal_ref const & g,
goal_ref_buffer & result) override;
virtual void cleanup() override;
};
class ac_rewriter {
@ -85,7 +85,7 @@ struct ac_rewriter_cfg : public default_rewriter_cfg {
bool rewrite_patterns() const { return false; }
bool flat_assoc(func_decl * f) const { return false; }
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
result_pr = 0;
result_pr = nullptr;
return m_r.mk_app_core(f, num, args, result);
}
ac_rewriter_cfg(ast_manager & m):m_r(m) {}
@ -472,7 +472,7 @@ private:
T.reset();
ptr_vector<expr> todo;
todo.push_back(fml);
app* t = 0;
app* t = nullptr;
while (!todo.empty()) {
fml = todo.back();
todo.pop_back();
@ -487,24 +487,24 @@ private:
bool is_range_restriction(expr* form, term_set const& C, app*& t) {
if (!m().is_or(form)) return false;
unsigned sz = to_app(form)->get_num_args();
t = 0;
t = nullptr;
for (unsigned i = 0; i < sz; ++i) {
expr* e = to_app(form)->get_arg(i);
expr* e1, *e2;
if (!m().is_eq(e, e1, e2)) return false;
if (!is_app(e1) || !is_app(e2)) return false;
app* a1 = to_app(e1), *a2 = to_app(e2);
if (C.contains(a1) && (t == 0 || t == a2)) {
if (C.contains(a1) && (t == nullptr || t == a2)) {
t = a2;
}
else if (C.contains(a2) && (t == 0 || t == a1)) {
else if (C.contains(a2) && (t == nullptr || t == a1)) {
t = a1;
}
else {
return false;
}
}
return t != 0;
return t != nullptr;
}

View file

@ -177,7 +177,7 @@ class tseitin_cnf_tactic : public tactic {
goto start;
case OP_OR:
case OP_IFF:
l = 0;
l = nullptr;
m_cache.find(to_app(n), l);
SASSERT(l != 0);
mk_lit(l, sign, r);
@ -185,7 +185,7 @@ class tseitin_cnf_tactic : public tactic {
case OP_ITE:
case OP_EQ:
if (m.is_bool(to_app(n)->get_arg(1))) {
l = 0;
l = nullptr;
m_cache.find(to_app(n), l);
SASSERT(l != 0);
mk_lit(l, sign, r);
@ -341,7 +341,7 @@ class tseitin_cnf_tactic : public tactic {
app * mk_fresh() {
m_num_aux_vars++;
app * v = m.mk_fresh_const(0, m.mk_bool_sort());
app * v = m.mk_fresh_const(nullptr, m.mk_bool_sort());
m_fresh_vars.push_back(v);
if (m_mc)
m_mc->hide(v->get_decl());
@ -815,12 +815,12 @@ class tseitin_cnf_tactic : public tactic {
if (m_produce_models)
m_mc = alloc(generic_model_converter, m, "tseitin");
else
m_mc = 0;
m_mc = nullptr;
unsigned size = g->size();
for (unsigned idx = 0; idx < size; idx++) {
process(g->form(idx), g->dep(idx));
g->update(idx, m.mk_true(), 0, 0); // to save memory
g->update(idx, m.mk_true(), nullptr, nullptr); // to save memory
}
SASSERT(!m_produce_unsat_cores || m_clauses.size() == m_deps.size());
@ -834,7 +834,7 @@ class tseitin_cnf_tactic : public tactic {
continue;
added.mark(cls);
if (m_produce_unsat_cores)
g->assert_expr(cls, 0, m_deps.get(i));
g->assert_expr(cls, nullptr, m_deps.get(i));
else
g->assert_expr(cls);
}
@ -855,20 +855,20 @@ public:
m_imp = alloc(imp, m, p);
}
virtual tactic * translate(ast_manager & m) {
tactic * translate(ast_manager & m) override {
return alloc(tseitin_cnf_tactic, m, m_params);
}
virtual ~tseitin_cnf_tactic() {
~tseitin_cnf_tactic() override {
dealloc(m_imp);
}
virtual void updt_params(params_ref const & p) {
void updt_params(params_ref const & p) override {
m_params = p;
m_imp->updt_params(p);
}
virtual void collect_param_descrs(param_descrs & r) {
void collect_param_descrs(param_descrs & r) override {
insert_max_memory(r);
r.insert("common_patterns", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by identifing commonly used patterns");
r.insert("distributivity", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by applying distributivity over unshared subformulas");
@ -877,13 +877,12 @@ public:
r.insert("ite_extra", CPK_BOOL, "(default: true) add redundant clauses (that improve unit propagation) when encoding if-then-else formulas");
}
virtual void operator()(goal_ref const & in,
goal_ref_buffer & result) {
void operator()(goal_ref const & in, goal_ref_buffer & result) override {
(*m_imp)(in, result);
report_tactic_progress(":cnf-aux-vars", m_imp->m_num_aux_vars);
}
virtual void cleanup() {
void cleanup() override {
ast_manager & m = m_imp->m;
imp * d = alloc(imp, m, m_params);
d->m_num_aux_vars = m_imp->m_num_aux_vars;
@ -891,11 +890,11 @@ public:
dealloc(d);
}
virtual void collect_statistics(statistics & st) const {
void collect_statistics(statistics & st) const override {
st.update("cnf encoding aux vars", m_imp->m_num_aux_vars);
}
virtual void reset_statistics() {
void reset_statistics() override {
m_imp->m_num_aux_vars = 0;
}
};