3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25: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

@ -71,9 +71,9 @@ void func_entry::deallocate(ast_manager & m, unsigned arity) {
func_interp::func_interp(ast_manager & m, unsigned arity):
m_manager(m),
m_arity(arity),
m_else(0),
m_else(nullptr),
m_args_are_values(true),
m_interp(0) {
m_interp(nullptr) {
}
func_interp::~func_interp() {
@ -102,7 +102,7 @@ func_interp * func_interp::copy() const {
void func_interp::reset_interp_cache() {
m_manager.dec_ref(m_interp);
m_interp = 0;
m_interp = nullptr;
}
bool func_interp::is_fi_entry_expr(expr * e, ptr_vector<expr> & args) {
@ -112,7 +112,8 @@ bool func_interp::is_fi_entry_expr(expr * e, ptr_vector<expr> & args) {
return false;
}
if ((m_arity == 0) ||
if (!is_ground(t) ||
(m_arity == 0) ||
(m_arity == 1 && !m().is_eq(c, a0, a1)) ||
(m_arity > 1 && (!m().is_and(c) || to_app(c)->get_num_args() != m_arity)))
return false;
@ -183,13 +184,13 @@ func_entry * func_interp::get_entry(expr * const * args) const {
if (curr->eq_args(m(), m_arity, args))
return curr;
}
return 0;
return nullptr;
}
void func_interp::insert_entry(expr * const * args, expr * r) {
reset_interp_cache();
func_entry * entry = get_entry(args);
if (entry != 0) {
if (entry != nullptr) {
entry->set_result(m_manager, r);
return;
}
@ -219,7 +220,7 @@ void func_interp::insert_new_entry(expr * const * args, expr * r) {
}
bool func_interp::eval_else(expr * const * args, expr_ref & result) const {
if (m_else == 0)
if (m_else == nullptr)
return false;
var_subst s(m_manager, false);
SASSERT(!s.std_order()); // (VAR 0) <- args[0], (VAR 1) <- args[1], ...
@ -232,9 +233,9 @@ bool func_interp::eval_else(expr * const * args, expr_ref & result) const {
*/
expr * func_interp::get_max_occ_result() const {
if (m_entries.empty())
return 0;
return nullptr;
obj_map<expr, unsigned> num_occs;
expr * r_max = 0;
expr * r_max = nullptr;
unsigned max = 0;
ptr_vector<func_entry>::const_iterator it = m_entries.begin();
ptr_vector<func_entry>::const_iterator end = m_entries.end();
@ -257,7 +258,7 @@ expr * func_interp::get_max_occ_result() const {
\brief Remove entries e such that e.get_result() == m_else.
*/
void func_interp::compress() {
if (m_else == 0 || m_entries.empty())
if (m_else == nullptr || m_entries.empty())
return; // nothing to be done
if (!is_ground(m_else))
return; // forall entries e in m_entries e.get_result() is ground
@ -284,8 +285,8 @@ void func_interp::compress() {
}
expr * func_interp::get_interp_core() const {
if (m_else == 0)
return 0;
if (m_else == nullptr)
return nullptr;
expr * r = m_else;
ptr_buffer<expr> vars;
ptr_vector<func_entry>::const_iterator it = m_entries.begin();
@ -313,10 +314,10 @@ expr * func_interp::get_interp_core() const {
}
expr * func_interp::get_interp() const {
if (m_interp != 0)
if (m_interp != nullptr)
return m_interp;
expr * r = get_interp_core();
if (r != 0) {
if (r != nullptr) {
const_cast<func_interp*>(this)->m_interp = r;
m_manager.inc_ref(m_interp);
}

View file

@ -86,7 +86,7 @@ public:
unsigned get_arity() const { return m_arity; }
bool is_partial() const { return m_else == 0; }
bool is_partial() const { return m_else == nullptr; }
// A function interpretation is said to be simple if m_else is ground.
bool is_simple() const { return is_partial() || is_ground(m_else); }
bool is_constant() const;

View file

@ -91,13 +91,13 @@ bool model::eval(expr * e, expr_ref & result, bool model_completion) {
struct model::value_proc : public some_value_proc {
model & m_model;
value_proc(model & m):m_model(m) {}
virtual expr * operator()(sort * s) {
ptr_vector<expr> * u = 0;
expr * operator()(sort * s) override {
ptr_vector<expr> * u = nullptr;
if (m_model.m_usort2universe.find(s, u)) {
if (u->size() > 0)
return u->get(0);
}
return 0;
return nullptr;
}
};
@ -107,16 +107,16 @@ expr * model::get_some_value(sort * s) {
}
ptr_vector<expr> const & model::get_universe(sort * s) const {
ptr_vector<expr> * u = 0;
ptr_vector<expr> * u = nullptr;
m_usort2universe.find(s, u);
SASSERT(u != 0);
return *u;
}
bool model::has_uninterpreted_sort(sort * s) const {
ptr_vector<expr> * u = 0;
ptr_vector<expr> * u = nullptr;
m_usort2universe.find(s, u);
return u != 0;
return u != nullptr;
}
unsigned model::get_num_uninterpreted_sorts() const {

View file

@ -33,7 +33,7 @@ protected:
public:
model(ast_manager & m);
virtual ~model();
~model() override;
void copy_func_interps(model const & source);
void copy_const_interps(model const & source);
@ -44,11 +44,11 @@ public:
bool eval(func_decl * f, expr_ref & r) const { return model_core::eval(f, r); }
bool eval(expr * e, expr_ref & result, bool model_completion = false);
virtual expr * get_some_value(sort * s);
virtual ptr_vector<expr> const & get_universe(sort * s) const;
virtual unsigned get_num_uninterpreted_sorts() const;
virtual sort * get_uninterpreted_sort(unsigned idx) const;
bool has_uninterpreted_sort(sort * s) const;
expr * get_some_value(sort * s) override;
ptr_vector<expr> const & get_universe(sort * s) const override;
unsigned get_num_uninterpreted_sorts() const override;
sort * get_uninterpreted_sort(unsigned idx) const override;
bool has_uninterpreted_sort(sort * s) const;
//
// Primitives for building models

View file

@ -37,7 +37,7 @@ bool model_core::eval(func_decl* f, expr_ref & r) const {
}
else {
func_interp * fi = get_func_interp(f);
if (fi != 0) {
if (fi != nullptr) {
r = fi->get_interp();
return r != 0;
}

View file

@ -44,8 +44,8 @@ public:
unsigned get_num_decls() const { return m_decls.size(); }
func_decl * get_decl(unsigned i) const { return m_decls[i]; }
bool has_interpretation(func_decl * d) const { return m_interp.contains(d) || m_finterp.contains(d); }
expr * get_const_interp(func_decl * d) const { expr * v; return m_interp.find(d, v) ? v : 0; }
func_interp * get_func_interp(func_decl * d) const { func_interp * fi; return m_finterp.find(d, fi) ? fi : 0; }
expr * get_const_interp(func_decl * d) const { expr * v; return m_interp.find(d, v) ? v : nullptr; }
func_interp * get_func_interp(func_decl * d) const { func_interp * fi; return m_finterp.find(d, fi) ? fi : nullptr; }
bool eval(func_decl * f, expr_ref & r) const;

View file

@ -91,7 +91,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
bool evaluate(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
func_interp * fi = m_model.get_func_interp(f);
return (fi != 0) && eval_fi(fi, num, args, result);
return (fi != nullptr) && eval_fi(fi, num, args, result);
}
// Try to use the entries to quickly evaluate the fi
@ -110,7 +110,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
return false; // let get_macro handle it
func_entry * entry = fi->get_entry(args);
if (entry != 0) {
if (entry != nullptr) {
result = entry->get_result();
return true;
}
@ -119,12 +119,12 @@ struct evaluator_cfg : public default_rewriter_cfg {
}
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;
family_id fid = f->get_family_id();
bool is_uninterp = fid != null_family_id && m.get_plugin(fid)->is_considered_uninterpreted(f);
if (num == 0 && (fid == null_family_id || is_uninterp)) {
expr * val = m_model.get_const_interp(f);
if (val != 0) {
if (val != nullptr) {
result = val;
return BR_DONE;
}
@ -187,14 +187,14 @@ struct evaluator_cfg : public default_rewriter_cfg {
TRACE("model_evaluator", tout << "reduce_app " << f->get_name() << "\n";
for (unsigned i = 0; i < num; i++) tout << mk_ismt2_pp(args[i], m) << "\n";
tout << "---->\n" << mk_ismt2_pp(result, m) << "\n";);
return BR_DONE;
return BR_REWRITE1;
}
if (st == BR_FAILED && !m.is_builtin_family_id(fid))
st = evaluate_partial_theory_func(f, num, args, result, result_pr);
if (st == BR_DONE && is_app(result)) {
app* a = to_app(result);
if (evaluate(a->get_decl(), a->get_num_args(), a->get_args(), result)) {
return BR_DONE;
return BR_REWRITE1;
}
}
CTRACE("model_evaluator", st != BR_FAILED, tout << result << "\n";);
@ -224,7 +224,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
func_interp * fi = m_model.get_func_interp(f);
if (fi != 0) {
if (fi != nullptr) {
TRACE_MACRO;
if (fi->is_partial()) {
if (m_model_completion) {
@ -262,8 +262,8 @@ struct evaluator_cfg : public default_rewriter_cfg {
expr_ref & result, proof_ref & result_pr) {
SASSERT(f != 0);
SASSERT(!m.is_builtin_family_id(f->get_family_id()));
result = 0;
result_pr = 0;
result = nullptr;
result_pr = nullptr;
func_interp * fi = m_model.get_func_interp(f);
if (fi) {
@ -382,7 +382,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
continue;
}
table2.insert(stores2[i].c_ptr());
expr * const* args = 0;
expr * const* args = nullptr;
expr* val = stores2[i][arity];
if (table1.find(stores2[i].c_ptr(), args)) {
switch (compare(args[arity], val)) {
@ -399,12 +399,11 @@ struct evaluator_cfg : public default_rewriter_cfg {
}
}
}
args_table::iterator it = table1.begin(), end = table1.end();
for (; it != end; ++it) {
switch (compare((*it)[arity], else2)) {
for (auto const& t : table1) {
switch (compare((t)[arity], else2)) {
case l_true: break;
case l_false: result = m.mk_false(); return BR_DONE;
default: conj.push_back(m.mk_eq((*it)[arity], else2)); break;
default: conj.push_back(m.mk_eq((t)[arity], else2)); break;
}
}
result = mk_and(conj);

View file

@ -90,7 +90,7 @@ void model_implicant::reset() {
m_visited.reset();
m_numbers.reset();
m_refs.reset();
m_model = 0;
m_model = nullptr;
}
expr_ref_vector model_implicant::minimize_model(ptr_vector<expr> const & formulas, model_ref& mdl) {
@ -666,8 +666,8 @@ void model_implicant::eval_eq(app* e, expr* arg1, expr* arg2) {
}
void model_implicant::eval_basic(app* e) {
expr* arg1 = 0, *arg2 = 0;
expr *argCond = 0, *argThen = 0, *argElse = 0, *arg = 0;
expr* arg1 = nullptr, *arg2 = nullptr;
expr *argCond = nullptr, *argThen = nullptr, *argElse = nullptr, *arg = nullptr;
bool has_x = false;
unsigned arity = e->get_num_args();
switch(e->get_decl_kind()) {