From 2a459c5ff648d0eed0be10d1f1c8503f48533200 Mon Sep 17 00:00:00 2001 From: Paul Ehrlich Date: Wed, 1 Nov 2017 12:02:48 +0100 Subject: [PATCH 001/263] MSYS offers a MINGW shell as well. (uses different os.uname()) --- scripts/mk_util.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 8d4fe5552..d44e8f416 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -610,7 +610,7 @@ elif os.name == 'posix': IS_CYGWIN=True if (CC != None and "mingw" in CC): IS_CYGWIN_MINGW=True - elif os.uname()[0].startswith('MSYS_NT'): + elif os.uname()[0].startswith('MSYS_NT') or os.uname()[0].startswith('MINGW'): IS_MSYS2=True if os.uname()[4] == 'x86_64': LINUX_X64=True @@ -1240,7 +1240,7 @@ def get_so_ext(): sysname = os.uname()[0] if sysname == 'Darwin': return 'dylib' - elif sysname == 'Linux' or sysname == 'FreeBSD' or sysname == 'OpenBSD' or sysname.startswith('MSYS_NT'): + elif sysname == 'Linux' or sysname == 'FreeBSD' or sysname == 'OpenBSD' or sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'): return 'so' elif sysname == 'CYGWIN': return 'dll' @@ -1888,7 +1888,6 @@ class MLComponent(Component): def _init_ocamlfind_paths(self): """ Initialises self.destdir and self.ldconf - Do not call this from the MLComponent constructor because OCAMLFIND has not been checked at that point """ @@ -2459,7 +2458,7 @@ def mk_config(): if sysname == 'Darwin': SO_EXT = '.dylib' SLIBFLAGS = '-dynamiclib' - elif sysname == 'Linux' or sysname.startswith('MSYS_NT'): + elif sysname == 'Linux' or sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'): CXXFLAGS = '%s -D_LINUX_' % CXXFLAGS OS_DEFINES = '-D_LINUX_' SO_EXT = '.so' @@ -3173,7 +3172,6 @@ class MakeRuleCmd(object): """ These class methods provide a convenient way to emit frequently needed commands used in Makefile rules - Note that several of the method are meant for use during ``make install`` and ``make uninstall``. These methods correctly use ``$(PREFIX)`` and ``$(DESTDIR)`` and therefore are preferrable @@ -3349,10 +3347,8 @@ def configure_file(template_file_path, output_file_path, substitutions): Read a template file ``template_file_path``, perform substitutions found in the ``substitutions`` dictionary and write the result to the output file ``output_file_path``. - The template file should contain zero or more template strings of the form ``@NAME@``. - The substitutions dictionary maps old strings (without the ``@`` symbols) to their replacements. """ From 429edf175fd74513d44f6ee50648e29dc89fcb7c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 5 Nov 2017 19:16:04 -0800 Subject: [PATCH 002/263] fix model converter bug in coi-filter #1241 Signed-off-by: Nikolaj Bjorner --- src/muz/dataflow/dataflow.h | 69 ++++++++++--------------- src/muz/transforms/dl_mk_coi_filter.cpp | 60 +++++++++++---------- 2 files changed, 59 insertions(+), 70 deletions(-) diff --git a/src/muz/dataflow/dataflow.h b/src/muz/dataflow/dataflow.h index 5e91a0149..e9e543b2d 100644 --- a/src/muz/dataflow/dataflow.h +++ b/src/muz/dataflow/dataflow.h @@ -62,8 +62,7 @@ namespace datalog { rule_set::decl2rules m_body2rules; void init_bottom_up() { - for (rule_set::iterator it = m_rules.begin(); it != m_rules.end(); ++it) { - rule* cur = *it; + for (rule* cur : m_rules) { for (unsigned i = 0; i < cur->get_uninterpreted_tail_size(); ++i) { func_decl *d = cur->get_decl(i); rule_set::decl2rules::obj_map_entry *e = m_body2rules.insert_if_not_there2(d, 0); @@ -83,31 +82,25 @@ namespace datalog { } void init_top_down() { - const func_decl_set& output_preds = m_rules.get_output_predicates(); - for (func_decl_set::iterator I = output_preds.begin(), - E = output_preds.end(); I != E; ++I) { - func_decl* sym = *I; + for (func_decl* sym : m_rules.get_output_predicates()) { TRACE("dl", tout << sym->get_name() << "\n";); const rule_vector& output_rules = m_rules.get_predicate_rules(sym); - for (unsigned i = 0; i < output_rules.size(); ++i) { - m_facts.insert_if_not_there2(sym, Fact())->get_data().m_value.init_down(m_context, output_rules[i]); + for (rule* r : output_rules) { + m_facts.insert_if_not_there2(sym, Fact())->get_data().m_value.init_down(m_context, r); m_todo[m_todo_idx].insert(sym); } } } void step_bottom_up() { - for(todo_set::iterator I = m_todo[m_todo_idx].begin(), - E = m_todo[m_todo_idx].end(); I!=E; ++I) { + for (func_decl* f : m_todo[m_todo_idx]) { ptr_vector * rules; - if (!m_body2rules.find(*I, rules)) + if (!m_body2rules.find(f, rules)) continue; - - for (ptr_vector::iterator I2 = rules->begin(), - E2 = rules->end(); I2 != E2; ++I2) { - func_decl* head_sym = (*I2)->get_head()->get_decl(); - fact_reader tail_facts(m_facts, *I2); - bool new_info = m_facts.insert_if_not_there2(head_sym, Fact())->get_data().m_value.propagate_up(m_context, *I2, tail_facts); + for (rule* r : *rules) { + func_decl* head_sym = r->get_head()->get_decl(); + fact_reader tail_facts(m_facts, r); + bool new_info = m_facts.insert_if_not_there2(head_sym, Fact())->get_data().m_value.propagate_up(m_context, r, tail_facts); if (new_info) { m_todo[!m_todo_idx].insert(head_sym); } @@ -119,15 +112,11 @@ namespace datalog { } void step_top_down() { - for(todo_set::iterator I = m_todo[m_todo_idx].begin(), - E = m_todo[m_todo_idx].end(); I!=E; ++I) { - func_decl* head_sym = *I; + for (func_decl* head_sym : m_todo[m_todo_idx]) { // We can't use a reference here because we are changing the map while using the reference const Fact head_fact = m_facts.get(head_sym, Fact::null_fact); const rule_vector& deps = m_rules.get_predicate_rules(head_sym); - const unsigned deps_size = deps.size(); - for (unsigned i = 0; i < deps_size; ++i) { - rule *trg_rule = deps[i]; + for (rule* trg_rule : deps) { fact_writer writer(m_facts, trg_rule, m_todo[!m_todo_idx]); // Generate new facts head_fact.propagate_down(m_context, trg_rule, writer); @@ -146,16 +135,13 @@ namespace datalog { dataflow_engine(typename Fact::ctx_t& ctx, const rule_set& rules) : m_rules(rules), m_todo_idx(0), m_context(ctx) {} ~dataflow_engine() { - for (rule_set::decl2rules::iterator it = m_body2rules.begin(); it != m_body2rules.end(); ++it) { - dealloc(it->m_value); - } + for (auto & kv : m_body2rules) + dealloc(kv.m_value); } void dump(std::ostream& outp) { obj_hashtable visited; - for (rule_set::iterator I = m_rules.begin(), - E = m_rules.end(); I != E; ++I) { - const rule* r = *I; + for (rule const* r : m_rules) { func_decl* head_decl = r->get_decl(); obj_hashtable::entry *dummy; if (visited.insert_if_not_there_core(head_decl, dummy)) { @@ -194,30 +180,29 @@ namespace datalog { iterator end() const { return m_facts.end(); } void join(const dataflow_engine& oth) { - for (typename fact_db::iterator I = oth.m_facts.begin(), - E = oth.m_facts.end(); I != E; ++I) { + for (auto const& kv : oth.m_facts) { typename fact_db::entry* entry; - if (m_facts.insert_if_not_there_core(I->m_key, entry)) { - entry->get_data().m_value = I->m_value; + if (m_facts.insert_if_not_there_core(kv.m_key, entry)) { + entry->get_data().m_value = kv.m_value; } else { - entry->get_data().m_value.join(m_context, I->m_value); + entry->get_data().m_value.join(m_context, kv.m_value); } } } void intersect(const dataflow_engine& oth) { vector to_delete; - for (typename fact_db::iterator I = m_facts.begin(), - E = m_facts.end(); I != E; ++I) { + for (auto const& kv : m_facts) { - if (typename fact_db::entry *entry = oth.m_facts.find_core(I->m_key)) { - I->m_value.intersect(m_context, entry->get_data().m_value); - } else { - to_delete.push_back(I->m_key); + if (typename fact_db::entry *entry = oth.m_facts.find_core(kv.m_key)) { + kv.m_value.intersect(m_context, entry->get_data().m_value); + } + else { + to_delete.push_back(kvm_key); } } - for (unsigned i = 0; i < to_delete.size(); ++i) { - m_facts.erase(to_delete[i]); + for (func_decl* f : to_delete) { + m_facts.erase(f); } } }; diff --git a/src/muz/transforms/dl_mk_coi_filter.cpp b/src/muz/transforms/dl_mk_coi_filter.cpp index 31188bf43..3ea0e305a 100644 --- a/src/muz/transforms/dl_mk_coi_filter.cpp +++ b/src/muz/transforms/dl_mk_coi_filter.cpp @@ -21,6 +21,7 @@ Author: #include "muz/dataflow/dataflow.h" #include "muz/dataflow/reachability.h" #include "ast/ast_pp.h" +#include "ast/ast_util.h" #include "tactic/extension_model_converter.h" namespace datalog { @@ -33,20 +34,28 @@ namespace datalog { rule_set * mk_coi_filter::bottom_up(rule_set const & source) { dataflow_engine engine(source.get_manager(), source); engine.run_bottom_up(); + func_decl_set unreachable; scoped_ptr res = alloc(rule_set, m_context); res->inherit_predicates(source); - for (rule_set::iterator it = source.begin(); it != source.end(); ++it) { - rule * r = *it; - + for (rule* r : source) { bool new_tail = false; bool contained = true; + m_new_tail.reset(); + m_new_tail_neg.reset(); for (unsigned i = 0; i < r->get_uninterpreted_tail_size(); ++i) { - if (m_context.has_facts(r->get_decl(i))) { + func_decl* decl_i = r->get_decl(i); + if (m_context.has_facts(decl_i)) { return 0; } + bool reachable = engine.get_fact(decl_i).is_reachable(); + + if (!reachable) { + unreachable.insert(decl_i); + } + if (r->is_neg_tail(i)) { - if (!engine.get_fact(r->get_decl(i)).is_reachable()) { + if (!reachable) { if (!new_tail) { for (unsigned j = 0; j < i; ++j) { m_new_tail.push_back(r->get_tail(j)); @@ -60,10 +69,9 @@ namespace datalog { m_new_tail_neg.push_back(true); } } - else { SASSERT(!new_tail); - if (!engine.get_fact(r->get_decl(i)).is_reachable()) { + if (!reachable) { contained = false; break; } @@ -78,24 +86,26 @@ namespace datalog { res->add_rule(r); } } - m_new_tail.reset(); - m_new_tail_neg.reset(); } if (res->get_num_rules() == source.get_num_rules()) { TRACE("dl", tout << "No transformation\n";); res = 0; - } else { + } + else { res->close(); } - + // set to false each unreached predicate - if (m_context.get_model_converter()) { + if (res && m_context.get_model_converter()) { extension_model_converter* mc0 = alloc(extension_model_converter, m); - for (dataflow_engine::iterator it = engine.begin(); it != engine.end(); it++) { - if (!it->m_value.is_reachable()) { - mc0->insert(it->m_key, m.mk_false()); + for (auto const& kv : engine) { + if (!kv.m_value.is_reachable()) { + mc0->insert(kv.m_key, m.mk_false()); } } + for (func_decl* f : unreachable) { + mc0->insert(f, m.mk_false()); + } m_context.add_model_converter(mc0); } CTRACE("dl", 0 != res, res->display(tout);); @@ -109,9 +119,7 @@ namespace datalog { scoped_ptr res = alloc(rule_set, m_context); res->inherit_predicates(source); - rule_set::iterator rend = source.end(); - for (rule_set::iterator rit = source.begin(); rit != rend; ++rit) { - rule * r = *rit; + for (rule * r : source) { func_decl * pred = r->get_decl(); if (engine.get_fact(pred).is_reachable()) { res->add_rule(r); @@ -125,14 +133,12 @@ namespace datalog { res = 0; } if (res && m_context.get_model_converter()) { - func_decl_set::iterator end = pruned_preds.end(); - func_decl_set::iterator it = pruned_preds.begin(); extension_model_converter* mc0 = alloc(extension_model_converter, m); - for (; it != end; ++it) { - const rule_vector& rules = source.get_predicate_rules(*it); + for (func_decl* f : pruned_preds) { + const rule_vector& rules = source.get_predicate_rules(f); expr_ref_vector fmls(m); - for (unsigned i = 0; i < rules.size(); ++i) { - app* head = rules[i]->get_head(); + for (rule * r : rules) { + app* head = r->get_head(); expr_ref_vector conj(m); for (unsigned j = 0; j < head->get_num_args(); ++j) { expr* arg = head->get_arg(j); @@ -140,11 +146,9 @@ namespace datalog { conj.push_back(m.mk_eq(m.mk_var(j, m.get_sort(arg)), arg)); } } - fmls.push_back(m.mk_and(conj.size(), conj.c_ptr())); + fmls.push_back(mk_and(conj)); } - expr_ref fml(m); - fml = m.mk_or(fmls.size(), fmls.c_ptr()); - mc0->insert(*it, fml); + mc0->insert(f, mk_or(fmls)); } m_context.add_model_converter(mc0); } From 5bb5a50490c5aecea92c7dba56033cdc24b6e8e6 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 5 Nov 2017 19:24:05 -0800 Subject: [PATCH 003/263] fix build Signed-off-by: Nikolaj Bjorner --- src/muz/dataflow/dataflow.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/muz/dataflow/dataflow.h b/src/muz/dataflow/dataflow.h index e9e543b2d..6f3010940 100644 --- a/src/muz/dataflow/dataflow.h +++ b/src/muz/dataflow/dataflow.h @@ -184,21 +184,22 @@ namespace datalog { typename fact_db::entry* entry; if (m_facts.insert_if_not_there_core(kv.m_key, entry)) { entry->get_data().m_value = kv.m_value; - } else { + } + else { entry->get_data().m_value.join(m_context, kv.m_value); } } } void intersect(const dataflow_engine& oth) { - vector to_delete; + ptr_vector to_delete; for (auto const& kv : m_facts) { if (typename fact_db::entry *entry = oth.m_facts.find_core(kv.m_key)) { kv.m_value.intersect(m_context, entry->get_data().m_value); } else { - to_delete.push_back(kvm_key); + to_delete.push_back(kv.m_key); } } for (func_decl* f : to_delete) { From 53ed1bb862cf7b1fd70eb71bf7e236895b01d35c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 6 Nov 2017 02:05:00 -0800 Subject: [PATCH 004/263] fix segfault reported as part of #1241 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_diff_logic_def.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/smt/theory_diff_logic_def.h b/src/smt/theory_diff_logic_def.h index 203dd24d2..59f5521c5 100644 --- a/src/smt/theory_diff_logic_def.h +++ b/src/smt/theory_diff_logic_def.h @@ -683,7 +683,9 @@ void theory_diff_logic::set_neg_cycle_conflict() { vector params; if (get_manager().proofs_enabled()) { params.push_back(parameter(symbol("farkas"))); - params.resize(lits.size()+1, parameter(rational(1))); + for (unsigned i = 0; i <= lits.size(); ++i) { + params.push_back(parameter(rational(1))); + } } ctx.set_conflict( From 16bab71df21f60f2cdb0faab438802f7a8c66128 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 6 Nov 2017 02:18:55 -0800 Subject: [PATCH 005/263] remove asserts for proof generation to enable mode switch in spacer virtual solver Signed-off-by: Nikolaj Bjorner --- src/ast/ast.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 3dbd0bc69..8c74cbe83 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -2842,21 +2842,18 @@ proof * ast_manager::mk_distributivity(expr * s, expr * r) { } proof * ast_manager::mk_rewrite(expr * s, expr * t) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; return mk_app(m_basic_family_id, PR_REWRITE, mk_eq(s, t)); } proof * ast_manager::mk_oeq_rewrite(expr * s, expr * t) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; return mk_app(m_basic_family_id, PR_REWRITE, mk_oeq(s, t)); } proof * ast_manager::mk_rewrite_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; ptr_buffer args; @@ -2866,42 +2863,36 @@ proof * ast_manager::mk_rewrite_star(expr * s, expr * t, unsigned num_proofs, pr } proof * ast_manager::mk_pull_quant(expr * e, quantifier * q) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; return mk_app(m_basic_family_id, PR_PULL_QUANT, mk_iff(e, q)); } proof * ast_manager::mk_pull_quant_star(expr * e, quantifier * q) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; return mk_app(m_basic_family_id, PR_PULL_QUANT_STAR, mk_iff(e, q)); } proof * ast_manager::mk_push_quant(quantifier * q, expr * e) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; return mk_app(m_basic_family_id, PR_PUSH_QUANT, mk_iff(q, e)); } proof * ast_manager::mk_elim_unused_vars(quantifier * q, expr * e) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; return mk_app(m_basic_family_id, PR_ELIM_UNUSED_VARS, mk_iff(q, e)); } proof * ast_manager::mk_der(quantifier * q, expr * e) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; return mk_app(m_basic_family_id, PR_DER, mk_iff(q, e)); } proof * ast_manager::mk_quant_inst(expr * not_q_or_i, unsigned num_bind, expr* const* binding) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; vector params; @@ -2937,7 +2928,6 @@ bool ast_manager::is_rewrite(expr const* e, expr*& r1, expr*& r2) const { } proof * ast_manager::mk_def_axiom(expr * ax) { - SASSERT(proofs_enabled()); if (proofs_disabled()) return m_undef_proof; return mk_app(m_basic_family_id, PR_DEF_AXIOM, ax); From 0f2b1ae7c81f1c381332a5aafddd29c73856f0c4 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 6 Nov 2017 02:35:10 -0800 Subject: [PATCH 006/263] fix proof mode related segfaults #1241 Signed-off-by: Nikolaj Bjorner --- src/ast/ast.cpp | 40 ++++++++++++++++----------------- src/ast/rewriter/rewriter_def.h | 3 +-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 8c74cbe83..7eae396ff 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -2626,7 +2626,7 @@ bool ast_manager::is_fully_interp(sort * s) const { proof * ast_manager::mk_proof(family_id fid, decl_kind k, unsigned num_args, expr * const * args) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(fid, k, num_args, args); } @@ -2843,19 +2843,19 @@ proof * ast_manager::mk_distributivity(expr * s, expr * r) { proof * ast_manager::mk_rewrite(expr * s, expr * t) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(m_basic_family_id, PR_REWRITE, mk_eq(s, t)); } proof * ast_manager::mk_oeq_rewrite(expr * s, expr * t) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(m_basic_family_id, PR_REWRITE, mk_oeq(s, t)); } proof * ast_manager::mk_rewrite_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; ptr_buffer args; args.append(num_proofs, (expr**) proofs); args.push_back(mk_eq(s, t)); @@ -2864,37 +2864,37 @@ proof * ast_manager::mk_rewrite_star(expr * s, expr * t, unsigned num_proofs, pr proof * ast_manager::mk_pull_quant(expr * e, quantifier * q) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(m_basic_family_id, PR_PULL_QUANT, mk_iff(e, q)); } proof * ast_manager::mk_pull_quant_star(expr * e, quantifier * q) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(m_basic_family_id, PR_PULL_QUANT_STAR, mk_iff(e, q)); } proof * ast_manager::mk_push_quant(quantifier * q, expr * e) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(m_basic_family_id, PR_PUSH_QUANT, mk_iff(q, e)); } proof * ast_manager::mk_elim_unused_vars(quantifier * q, expr * e) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(m_basic_family_id, PR_ELIM_UNUSED_VARS, mk_iff(q, e)); } proof * ast_manager::mk_der(quantifier * q, expr * e) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(m_basic_family_id, PR_DER, mk_iff(q, e)); } proof * ast_manager::mk_quant_inst(expr * not_q_or_i, unsigned num_bind, expr* const* binding) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; vector params; for (unsigned i = 0; i < num_bind; ++i) { params.push_back(parameter(binding[i])); @@ -2929,7 +2929,7 @@ bool ast_manager::is_rewrite(expr const* e, expr*& r1, expr*& r2) const { proof * ast_manager::mk_def_axiom(expr * ax) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; return mk_app(m_basic_family_id, PR_DEF_AXIOM, ax); } @@ -3067,7 +3067,7 @@ proof * ast_manager::mk_def_intro(expr * new_def) { proof * ast_manager::mk_apply_defs(expr * n, expr * def, unsigned num_proofs, proof * const * proofs) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; ptr_buffer args; args.append(num_proofs, (expr**) proofs); args.push_back(mk_oeq(n, def)); @@ -3100,7 +3100,7 @@ bool ast_manager::check_nnf_proof_parents(unsigned num_proofs, proof * const * p proof * ast_manager::mk_nnf_pos(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; check_nnf_proof_parents(num_proofs, proofs); ptr_buffer args; args.append(num_proofs, (expr**) proofs); @@ -3110,7 +3110,7 @@ proof * ast_manager::mk_nnf_pos(expr * s, expr * t, unsigned num_proofs, proof * proof * ast_manager::mk_nnf_neg(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; check_nnf_proof_parents(num_proofs, proofs); ptr_buffer args; args.append(num_proofs, (expr**) proofs); @@ -3120,7 +3120,7 @@ proof * ast_manager::mk_nnf_neg(expr * s, expr * t, unsigned num_proofs, proof * proof * ast_manager::mk_nnf_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; ptr_buffer args; args.append(num_proofs, (expr**) proofs); args.push_back(mk_oeq(s, t)); @@ -3129,7 +3129,7 @@ proof * ast_manager::mk_nnf_star(expr * s, expr * t, unsigned num_proofs, proof proof * ast_manager::mk_skolemization(expr * q, expr * e) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; SASSERT(is_bool(q)); SASSERT(is_bool(e)); return mk_app(m_basic_family_id, PR_SKOLEMIZE, mk_oeq(q, e)); @@ -3137,7 +3137,7 @@ proof * ast_manager::mk_skolemization(expr * q, expr * e) { proof * ast_manager::mk_cnf_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; ptr_buffer args; args.append(num_proofs, (expr**) proofs); args.push_back(mk_oeq(s, t)); @@ -3146,7 +3146,7 @@ proof * ast_manager::mk_cnf_star(expr * s, expr * t, unsigned num_proofs, proof proof * ast_manager::mk_and_elim(proof * p, unsigned i) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; SASSERT(has_fact(p)); SASSERT(is_and(get_fact(p))); CTRACE("mk_and_elim", i >= to_app(get_fact(p))->get_num_args(), tout << "i: " << i << "\n" << mk_pp(get_fact(p), *this) << "\n";); @@ -3157,7 +3157,7 @@ proof * ast_manager::mk_and_elim(proof * p, unsigned i) { proof * ast_manager::mk_not_or_elim(proof * p, unsigned i) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; SASSERT(has_fact(p)); SASSERT(is_not(get_fact(p))); SASSERT(is_or(to_app(get_fact(p))->get_arg(0))); @@ -3180,7 +3180,7 @@ proof * ast_manager::mk_th_lemma( ) { if (proofs_disabled()) - return m_undef_proof; + return nullptr; ptr_buffer args; vector parameters; diff --git a/src/ast/rewriter/rewriter_def.h b/src/ast/rewriter/rewriter_def.h index f5f72674d..2abd6d467 100644 --- a/src/ast/rewriter/rewriter_def.h +++ b/src/ast/rewriter/rewriter_def.h @@ -351,7 +351,6 @@ void rewriter_tpl::process_app(app * t, frame & fr) { if (is_ground(def)) { m_r = def; if (ProofGen) { - SASSERT(def_pr); m_pr = m().mk_transitivity(m_pr, def_pr); } } @@ -510,7 +509,7 @@ void rewriter_tpl::process_quantifier(quantifier * q, frame & fr) { new_no_pats = q->get_no_patterns(); } if (ProofGen) { - quantifier * new_q = m().update_quantifier(q, q->get_num_patterns(), new_pats, q->get_num_no_patterns(), new_no_pats, new_body); + quantifier_ref new_q(m().update_quantifier(q, q->get_num_patterns(), new_pats, q->get_num_no_patterns(), new_no_pats, new_body), m()); m_pr = q == new_q ? 0 : m().mk_quant_intro(q, new_q, result_pr_stack().get(fr.m_spos)); m_r = new_q; proof_ref pr2(m()); From 861a0745c148ae5a775a7ea9f3de0ecd1828ddf6 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Mon, 6 Nov 2017 10:36:10 +0000 Subject: [PATCH 007/263] remove a few unneded mem allocations --- src/tactic/bv/bv_size_reduction_tactic.cpp | 6 +++--- src/tactic/bv/max_bv_sharing_tactic.cpp | 7 ++++--- src/tactic/core/propagate_values_tactic.cpp | 5 +++-- src/tactic/core/simplify_tactic.cpp | 6 +++--- src/tactic/smtlogics/qfufbv_tactic.cpp | 8 ++++---- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/tactic/bv/bv_size_reduction_tactic.cpp b/src/tactic/bv/bv_size_reduction_tactic.cpp index 9401f74c1..ec4c21fe8 100644 --- a/src/tactic/bv/bv_size_reduction_tactic.cpp +++ b/src/tactic/bv/bv_size_reduction_tactic.cpp @@ -399,8 +399,8 @@ void bv_size_reduction_tactic::operator()(goal_ref const & g, void bv_size_reduction_tactic::cleanup() { - imp * d = alloc(imp, m_imp->m); - std::swap(d, m_imp); - dealloc(d); + ast_manager & m = m_imp->m; + m_imp->~imp(); + new (m_imp) imp(m); } diff --git a/src/tactic/bv/max_bv_sharing_tactic.cpp b/src/tactic/bv/max_bv_sharing_tactic.cpp index b0affeb4b..becaed276 100644 --- a/src/tactic/bv/max_bv_sharing_tactic.cpp +++ b/src/tactic/bv/max_bv_sharing_tactic.cpp @@ -307,9 +307,10 @@ public: } virtual void cleanup() { - imp * d = alloc(imp, m_imp->m(), m_params); - std::swap(d, m_imp); - dealloc(d); + ast_manager & m = m_imp->m(); + params_ref p = std::move(m_params); + m_imp->~imp(); + new (m_imp) imp(m, p); } }; diff --git a/src/tactic/core/propagate_values_tactic.cpp b/src/tactic/core/propagate_values_tactic.cpp index 7baac0b99..607ecbd79 100644 --- a/src/tactic/core/propagate_values_tactic.cpp +++ b/src/tactic/core/propagate_values_tactic.cpp @@ -255,8 +255,9 @@ public: virtual void cleanup() { 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); } }; diff --git a/src/tactic/core/simplify_tactic.cpp b/src/tactic/core/simplify_tactic.cpp index 9deff968e..de1fcc99c 100644 --- a/src/tactic/core/simplify_tactic.cpp +++ b/src/tactic/core/simplify_tactic.cpp @@ -111,9 +111,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 { diff --git a/src/tactic/smtlogics/qfufbv_tactic.cpp b/src/tactic/smtlogics/qfufbv_tactic.cpp index e89da3631..df2791a8f 100644 --- a/src/tactic/smtlogics/qfufbv_tactic.cpp +++ b/src/tactic/smtlogics/qfufbv_tactic.cpp @@ -70,8 +70,8 @@ public: const unsigned sz = g->size(); for (unsigned i = 0; i < sz; i++) flas.push_back(g->form(i)); scoped_ptr uffree_solver = setup_sat(); - scoped_ptr imp = alloc(lackr, m, m_p, m_st, flas, uffree_solver.get()); - const lbool o = imp->operator()(); + lackr imp(m, m_p, m_st, flas, uffree_solver.get()); + const lbool o = imp.operator()(); flas.reset(); // report result goal_ref resg(alloc(goal, *g, true)); @@ -79,8 +79,8 @@ public: if (o != l_undef) result.push_back(resg.get()); // report model if (g->models_enabled() && (o == l_true)) { - model_ref abstr_model = imp->get_model(); - mc = mk_qfufbv_ackr_model_converter(m, imp->get_info(), abstr_model); + model_ref abstr_model = imp.get_model(); + mc = mk_qfufbv_ackr_model_converter(m, imp.get_info(), abstr_model); } } From 9d3518736bda418f6a4a9b82d12cceaf83fee0b4 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 6 Nov 2017 15:25:10 -0800 Subject: [PATCH 008/263] fix #889 Signed-off-by: Nikolaj Bjorner --- src/ast/ast.cpp | 8 +------- src/smt/asserted_formulas.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 7eae396ff..98c1bdfed 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1683,7 +1683,7 @@ ast * ast_manager::register_node_core(ast * n) { bool contains = m_ast_table.contains(n); CASSERT("nondet_bug", contains || slow_not_contains(n)); #endif - + #if 0 static unsigned counter = 0; counter++; @@ -1719,12 +1719,6 @@ ast * ast_manager::register_node_core(ast * n) { n->m_id = is_decl(n) ? m_decl_id_gen.mk() : m_expr_id_gen.mk(); - static unsigned count = 0; - if (n->m_id == 404) { - ++count; - //if (count == 2) SASSERT(false); - } - TRACE("ast", tout << "Object " << n->m_id << " was created.\n";); TRACE("mk_var_bug", tout << "mk_ast: " << n->m_id << "\n";); // increment reference counters diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index dd92f250a..56600266a 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -511,11 +511,14 @@ void asserted_formulas::update_substitution(expr* n, proof* pr) { } TRACE("propagate_values", tout << "incompatible " << mk_pp(n, m) << "\n";); } - if (m.is_not(n, n1)) { - m_scoped_substitution.insert(n1, m.mk_false(), m.proofs_enabled() ? m.mk_iff_false(pr) : nullptr); + proof_ref pr1(m); + if (m.is_not(n, n1)) { + pr1 = m.proofs_enabled() ? m.mk_iff_false(pr) : nullptr; + m_scoped_substitution.insert(n1, m.mk_false(), pr1); } else { - m_scoped_substitution.insert(n, m.mk_true(), m.proofs_enabled() ? m.mk_iff_true(pr) : nullptr); + pr1 = m.proofs_enabled() ? m.mk_iff_true(pr) : nullptr; + m_scoped_substitution.insert(n, m.mk_true(), pr1); } } From 3350f32e1f2c01c9df63b7d71899796a18ce2272 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 6 Nov 2017 16:00:16 -0800 Subject: [PATCH 009/263] fix #877 by bypassing exception generation during label collection Signed-off-by: Nikolaj Bjorner --- src/duality/duality_rpfp.cpp | 94 +++++------------------------------- 1 file changed, 13 insertions(+), 81 deletions(-) diff --git a/src/duality/duality_rpfp.cpp b/src/duality/duality_rpfp.cpp index c9ad8fd56..5dc2283ae 100755 --- a/src/duality/duality_rpfp.cpp +++ b/src/duality/duality_rpfp.cpp @@ -1575,6 +1575,7 @@ namespace Duality { */ int RPFP::SubtermTruth(hash_map &memo, const Term &f) { + TRACE("duality", tout << f << "\n";); if (memo.find(f) != memo.end()) { return memo[f]; } @@ -1657,83 +1658,6 @@ namespace Duality { ands and, or, not. Returns result in memo. */ -#if 0 - int RPFP::GetLabelsRec(hash_map *memo, const Term &f, std::vector &labels, bool labpos){ - if(memo[labpos].find(f) != memo[labpos].end()){ - return memo[labpos][f]; - } - int res; - if(f.is_app()){ - int nargs = f.num_args(); - decl_kind k = f.decl().get_decl_kind(); - if(k == Implies){ - res = GetLabelsRec(memo,f.arg(1) || !f.arg(0), labels, labpos); - goto done; - } - if(k == And) { - res = 1; - for(int i = 0; i < nargs; i++){ - int ar = GetLabelsRec(memo,f.arg(i), labels, labpos); - if(ar == 0){ - res = 0; - goto done; - } - if(ar == 2)res = 2; - } - goto done; - } - else if(k == Or) { - res = 0; - for(int i = 0; i < nargs; i++){ - int ar = GetLabelsRec(memo,f.arg(i), labels, labpos); - if(ar == 1){ - res = 1; - goto done; - } - if(ar == 2)res = 2; - } - goto done; - } - else if(k == Not) { - int ar = GetLabelsRec(memo,f.arg(0), labels, !labpos); - res = (ar == 0) ? 1 : ((ar == 1) ? 0 : 2); - goto done; - } - } - { - bool pos; std::vector names; - if(f.is_label(pos,names)){ - res = GetLabelsRec(memo,f.arg(0), labels, labpos); - if(pos == labpos && res == (pos ? 1 : 0)) - for(unsigned i = 0; i < names.size(); i++) - labels.push_back(names[i]); - goto done; - } - } - { - expr bv = dualModel.eval(f); - if(bv.is_app() && bv.decl().get_decl_kind() == Equal && - bv.arg(0).is_array()){ - bv = EvalArrayEquality(bv); - } - // Hack!!!! array equalities can occur negatively! - if(bv.is_app() && bv.decl().get_decl_kind() == Not && - bv.arg(0).decl().get_decl_kind() == Equal && - bv.arg(0).arg(0).is_array()){ - bv = dualModel.eval(!EvalArrayEquality(bv.arg(0))); - } - if(eq(bv,ctx.bool_val(true))) - res = 1; - else if(eq(bv,ctx.bool_val(false))) - res = 0; - else - res = 2; - } - done: - memo[labpos][f] = res; - return res; - } -#endif void RPFP::GetLabelsRec(hash_map &memo, const Term &f, std::vector &labels, hash_set *done, bool truth) { @@ -1748,8 +1672,13 @@ namespace Duality { } if (k == Iff) { int b = SubtermTruth(memo, f.arg(0)); - if (b == 2) - throw "disaster in GetLabelsRec"; + if (b == 2) { + goto done; + // bypass error + std::ostringstream os; + os << "disaster in SubtermTruth processing " << f; + throw default_exception(os.str()); + } GetLabelsRec(memo, f.arg(1), labels, done, truth ? b : !b); goto done; } @@ -1825,8 +1754,11 @@ namespace Duality { } if (k == Iff) { int b = SubtermTruth(memo, f.arg(0)); - if (b == 2) - throw "disaster in ImplicantRed"; + if (b == 2) { + std::ostringstream os; + os << "disaster in SubtermTruth processing " << f; + throw default_exception(os.str()); + } ImplicantRed(memo, f.arg(1), lits, done, truth ? b : !b, dont_cares); goto done; } From d2c5e0e76acdd64df548533c740a12488fb8b0fb Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 8 Nov 2017 16:36:47 +0000 Subject: [PATCH 010/263] Fixed problems arising from unfortunate object destruction order in the Python API. Fixes #989. --- scripts/update_api.py | 140 ++++++++++++++++++++++++++-------------- src/api/python/z3/z3.py | 13 +--- 2 files changed, 94 insertions(+), 59 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 67a1b8a33..8e876d2fd 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -279,8 +279,8 @@ def mk_py_binding(name, result, params): global _API2PY _API2PY.append((name, result, params)) if result != VOID: - core_py.write(" _lib.%s.restype = %s\n" % (name, type2pystr(result))) - core_py.write(" _lib.%s.argtypes = [" % name) + core_py.write("_lib.%s.restype = %s\n" % (name, type2pystr(result))) + core_py.write("_lib.%s.argtypes = [" % name) first = True for p in params: if first: @@ -311,8 +311,30 @@ def display_args_to_z3(params): core_py.write("a%s" % i) i = i + 1 +NULLWrapped = [ 'Z3_mk_context', 'Z3_mk_context_rc', 'Z3_mk_interpolation_context' ] +Unwrapped = [ 'Z3_del_context', 'Z3_get_error_code' ] + def mk_py_wrappers(): - core_py.write("\n") + core_py.write(""" +class Elementaries: + def __init__(self, f): + self.f = f + self.get_error_code = _lib.Z3_get_error_code + self.get_error_message = _lib.Z3_get_error_msg + self.OK = Z3_OK + self.Exception = Z3Exception + + def Check(self, ctx): + err = self.get_error_code(ctx) + if err != self.OK: + raise self.Exception(self.get_error_message(ctx, err)) + +def Z3_set_error_handler(ctx, hndlr, _elems=Elementaries(_lib.Z3_set_error_handler)): + _elems.f(ctx, ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)(hndlr)) + _elems.Check(ctx) + +""") + for sig in _API2PY: name = sig[0] result = sig[1] @@ -320,25 +342,20 @@ def mk_py_wrappers(): num = len(params) core_py.write("def %s(" % name) display_args(num) - core_py.write("):\n") - core_py.write(" _lib = lib()\n") - core_py.write(" if _lib is None or _lib.%s is None:\n" % name) - core_py.write(" return\n") - if result != VOID: - core_py.write(" r = _lib.%s(" % name) - else: - core_py.write(" _lib.%s(" % name) + comma = ", " if num != 0 else "" + core_py.write("%s_elems=Elementaries(_lib.%s)):\n" % (comma, name)) + lval = "r = " if result != VOID else "" + core_py.write(" %s_elems.f(" % lval) display_args_to_z3(params) core_py.write(")\n") - if len(params) > 0 and param_type(params[0]) == CONTEXT: - core_py.write(" err = _lib.Z3_get_error_code(a0)\n") - core_py.write(" if err != Z3_OK:\n") - core_py.write(" raise Z3Exception(_lib.Z3_get_error_msg(a0, err))\n") + if len(params) > 0 and param_type(params[0]) == CONTEXT and not name in Unwrapped: + core_py.write(" _elems.Check(a0)\n") if result == STRING: core_py.write(" return _to_pystr(r)\n") elif result != VOID: core_py.write(" return r\n") core_py.write("\n") + core_py ## .NET API native interface @@ -391,10 +408,6 @@ def mk_dotnet(dotnet): dotnet.write(');\n\n') dotnet.write(' }\n') - -NULLWrapped = [ 'Z3_mk_context', 'Z3_mk_context_rc', 'Z3_mk_interpolation_context' ] -Unwrapped = [ 'Z3_del_context', 'Z3_get_error_code' ] - def mk_dotnet_wrappers(dotnet): global Type2Str dotnet.write("\n") @@ -1605,35 +1618,71 @@ def write_exe_c_preamble(exe_c): def write_core_py_post(core_py): core_py.write(""" - +# Clean up +del _lib +del _default_dirs +del _all_dirs +del _ext """) def write_core_py_preamble(core_py): - core_py.write('# Automatically generated file\n') - core_py.write('import sys, os\n') - core_py.write('import ctypes\n') - core_py.write('import pkg_resources\n') - core_py.write('from .z3types import *\n') - core_py.write('from .z3consts import *\n') core_py.write( """ +# Automatically generated file +import sys, os +import ctypes +import pkg_resources +from .z3types import * +from .z3consts import * + _ext = 'dll' if sys.platform in ('win32', 'cygwin') else 'dylib' if sys.platform == 'darwin' else 'so' - _lib = None +_default_dirs = ['.', + os.path.dirname(os.path.abspath(__file__)), + pkg_resources.resource_filename('z3', 'lib'), + os.path.join(sys.prefix, 'lib'), + None] +_all_dirs = [] -def lib(): - global _lib - if _lib is None: - _dirs = ['.', os.path.dirname(os.path.abspath(__file__)), pkg_resources.resource_filename('z3', 'lib'), os.path.join(sys.prefix, 'lib'), None] - for _dir in _dirs: - try: - init(_dir) - break - except: - pass - if _lib is None: - raise Z3Exception("init(Z3_LIBRARY_PATH) must be invoked before using Z3-python") - return _lib +if sys.version < '3': + import __builtin__ + if hasattr(__builtin__, "Z3_LIB_DIRS"): + _all_dirs = __builtin__.Z3_LIB_DIRS +else: + import builtins + if hasattr(builtins, "Z3_LIB_DIRS"): + _all_dirs = builtins.Z3_LIB_DIRS + +if 'Z3_LIBRARY_PATH' in os.environ: + lp = os.environ['Z3_LIBRARY_PATH']; + lds = lp.split(';') if sys.platform in ('win32') else lp.split(':') + _all_dirs.extend(lds) + +_all_dirs.extend(_default_dirs) + +for d in _all_dirs: + try: + d = os.path.realpath(d) + if os.path.isdir(d): + d = os.path.join(d, 'libz3.%s' % _ext) + if os.path.isfile(d): + _lib = ctypes.CDLL(d) + break + except: + pass + +if _lib is None: + print("Could not find libz3.%s; consider adding the directory containing it to" % _ext) + print(" - your system's PATH environment variable,") + print(" - the Z3_LIBRARY_PATH environment variable, or ") + print(" - to the custom Z3_LIBRARY_DIRS Python-builtin before importing the z3 module, e.g. via") + if sys.version < '3': + print(" import __builtin__") + print(" __builtin__.Z3_LIB_DIRS = [ '/path/to/libz3.%s' ] " % _ext) + else: + print(" import builtins") + print(" builtins.Z3_LIB_DIRS = [ '/path/to/libz3.%s' ] " % _ext) + raise Z3Exception("libz3.%s not found." % _ext) def _to_ascii(s): if isinstance(s, str): @@ -1653,16 +1702,9 @@ else: else: return "" -def init(PATH): - if PATH: - PATH = os.path.realpath(PATH) - if os.path.isdir(PATH): - PATH = os.path.join(PATH, 'libz3.%s' % _ext) - else: - PATH = 'libz3.%s' % _ext +_lib.Z3_set_error_handler.restype = None +_lib.Z3_set_error_handler.argtypes = [ContextObj, ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)] - global _lib - _lib = ctypes.CDLL(PATH) """ ) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index a521c5169..21ac695db 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -112,8 +112,6 @@ def _symbol2py(ctx, s): else: return Z3_get_symbol_string(ctx.ref(), s) -_error_handler_fptr = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint) - # Hack for having nary functions that can receive one argument that is the # list of arguments. def _get_args(args): @@ -127,13 +125,11 @@ def _get_args(args): except: # len is not necessarily defined when args is not a sequence (use reflection?) return args -def _Z3python_error_handler_core(c, e): +def z3_error_handler(c, e): # Do nothing error handler, just avoid exit(0) # The wrappers in z3core.py will raise a Z3Exception if an error is detected return -_Z3Python_error_handler = _error_handler_fptr(_Z3python_error_handler_core) - def _to_param_value(val): if isinstance(val, bool): if val == True: @@ -168,16 +164,13 @@ class Context: else: Z3_set_param_value(conf, str(prev), _to_param_value(a)) prev = None - self.lib = lib() self.ctx = Z3_mk_context_rc(conf) Z3_set_ast_print_mode(self.ctx, Z3_PRINT_SMTLIB2_COMPLIANT) - lib().Z3_set_error_handler.restype = None - lib().Z3_set_error_handler.argtypes = [ContextObj, _error_handler_fptr] - lib().Z3_set_error_handler(self.ctx, _Z3Python_error_handler) + Z3_set_error_handler(self.ctx, z3_error_handler) Z3_del_config(conf) def __del__(self): - self.lib.Z3_del_context(self.ctx) + Z3_del_context(self.ctx) self.ctx = None def ref(self): From ef800d7b931b46fa8dffed3e36698506f654655b Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 8 Nov 2017 17:20:25 +0000 Subject: [PATCH 011/263] Fixed library path order in Python API. --- scripts/update_api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 8e876d2fd..8c0c895d9 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -1653,10 +1653,11 @@ else: if hasattr(builtins, "Z3_LIB_DIRS"): _all_dirs = builtins.Z3_LIB_DIRS -if 'Z3_LIBRARY_PATH' in os.environ: - lp = os.environ['Z3_LIBRARY_PATH']; - lds = lp.split(';') if sys.platform in ('win32') else lp.split(':') - _all_dirs.extend(lds) +for v in ('Z3_LIBRARY_PATH', 'PATH'): + if v in os.environ: + lp = os.environ[v]; + lds = lp.split(';') if sys.platform in ('win32') else lp.split(':') + _all_dirs.extend(lds) _all_dirs.extend(_default_dirs) From bf563bbd5ffcba75f7a24d6a8b1095040884ca3a Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 8 Nov 2017 17:29:40 +0000 Subject: [PATCH 012/263] Fixed default library path order in Python API. --- scripts/update_api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/update_api.py b/scripts/update_api.py index 8c0c895d9..7d43b70ce 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -1672,6 +1672,13 @@ for d in _all_dirs: except: pass +if _lib is None: + # If all else failed, ask the system to find it. + try: + _lib = ctypes.CDLL('libz3.%s' % _ext) + except: + pass + if _lib is None: print("Could not find libz3.%s; consider adding the directory containing it to" % _ext) print(" - your system's PATH environment variable,") From a8b52419f58d1d17a046941e96e3b43f35b997df Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 8 Nov 2017 18:14:42 +0000 Subject: [PATCH 013/263] Fixed C example build. --- scripts/mk_util.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index d44e8f416..1a1833534 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -2072,7 +2072,6 @@ class ExampleComponent(Component): def is_example(self): return True - class CppExampleComponent(ExampleComponent): def __init__(self, name, path): ExampleComponent.__init__(self, name, path) @@ -2119,6 +2118,30 @@ class CExampleComponent(CppExampleComponent): def src_files(self): return get_c_files(self.ex_dir) + def mk_makefile(self, out): + dll_name = get_component(Z3_DLL_COMPONENT).dll_name + dll = '%s$(SO_EXT)' % dll_name + + objfiles = '' + for cfile in self.src_files(): + objfile = '%s$(OBJ_EXT)' % (cfile[:cfile.rfind('.')]) + objfiles = objfiles + ('%s ' % objfile) + out.write('%s: %s\n' % (objfile, os.path.join(self.to_ex_dir, cfile))); + out.write('\t%s $(CFLAGS) $(OS_DEFINES) $(EXAMP_DEBUG_FLAG) $(C_OUT_FLAG)%s $(LINK_FLAGS)' % (self.compiler(), objfile)) + out.write(' -I%s' % get_component(API_COMPONENT).to_src_dir) + out.write(' %s' % os.path.join(self.to_ex_dir, cfile)) + out.write('\n') + + exefile = '%s$(EXE_EXT)' % self.name + out.write('%s: %s %s\n' % (exefile, dll, objfiles)) + out.write('\t$(LINK) $(LINK_OUT_FLAG)%s $(LINK_FLAGS) %s ' % (exefile, objfiles)) + if IS_WINDOWS: + out.write('%s.lib' % dll_name) + else: + out.write(dll) + out.write(' $(LINK_EXTRA_FLAGS)\n') + out.write('_ex_%s: %s\n\n' % (self.name, exefile)) + class DotNetExampleComponent(ExampleComponent): def __init__(self, name, path): ExampleComponent.__init__(self, name, path) @@ -2512,6 +2535,7 @@ def mk_config(): config.write('CC=%s\n' % CC) config.write('CXX=%s\n' % CXX) config.write('CXXFLAGS=%s %s\n' % (CPPFLAGS, CXXFLAGS)) + config.write('CFLAGS=%s %s\n' % (CPPFLAGS, CXXFLAGS.replace('-std=c++11', ''))) config.write('EXAMP_DEBUG_FLAG=%s\n' % EXAMP_DEBUG_FLAG) config.write('CXX_OUT_FLAG=-o \n') config.write('OBJ_EXT=.o\n') From bec6c3f9e23ce509a10be74276b4670f8f8fc8ff Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 8 Nov 2017 18:22:17 +0000 Subject: [PATCH 014/263] Fixed C example build. --- scripts/mk_util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 1a1833534..e6de3019c 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -2343,6 +2343,7 @@ def mk_config(): 'CC=cl\n' 'CXX=cl\n' 'CXX_OUT_FLAG=/Fo\n' + 'C_OUT_FLAG=/Fo\n' 'OBJ_EXT=.obj\n' 'LIB_EXT=.lib\n' 'AR=lib\n' @@ -2538,6 +2539,7 @@ def mk_config(): config.write('CFLAGS=%s %s\n' % (CPPFLAGS, CXXFLAGS.replace('-std=c++11', ''))) config.write('EXAMP_DEBUG_FLAG=%s\n' % EXAMP_DEBUG_FLAG) config.write('CXX_OUT_FLAG=-o \n') + config.write('C_OUT_FLAG=-o \n') config.write('OBJ_EXT=.o\n') config.write('LIB_EXT=.a\n') config.write('AR=%s\n' % AR) From 17bcb37cf1f0560a6af8a2bed3bc1d6ec6bb77fb Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 8 Nov 2017 20:09:09 +0000 Subject: [PATCH 015/263] Fixed error handlers in Python API. --- scripts/update_api.py | 20 ++++++++++++-------- src/api/python/z3/z3.py | 15 ++++++++------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 7d43b70ce..2828a63f8 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -324,14 +324,16 @@ class Elementaries: self.OK = Z3_OK self.Exception = Z3Exception - def Check(self, ctx): + def Check(self, ctx): err = self.get_error_code(ctx) if err != self.OK: raise self.Exception(self.get_error_message(ctx, err)) def Z3_set_error_handler(ctx, hndlr, _elems=Elementaries(_lib.Z3_set_error_handler)): - _elems.f(ctx, ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)(hndlr)) + ceh = _error_handler_type(hndlr) + _elems.f(ctx, ceh) _elems.Check(ctx) + return ceh """) @@ -1637,10 +1639,10 @@ from .z3consts import * _ext = 'dll' if sys.platform in ('win32', 'cygwin') else 'dylib' if sys.platform == 'darwin' else 'so' _lib = None -_default_dirs = ['.', - os.path.dirname(os.path.abspath(__file__)), - pkg_resources.resource_filename('z3', 'lib'), - os.path.join(sys.prefix, 'lib'), +_default_dirs = ['.', + os.path.dirname(os.path.abspath(__file__)), + pkg_resources.resource_filename('z3', 'lib'), + os.path.join(sys.prefix, 'lib'), None] _all_dirs = [] @@ -1667,7 +1669,7 @@ for d in _all_dirs: if os.path.isdir(d): d = os.path.join(d, 'libz3.%s' % _ext) if os.path.isfile(d): - _lib = ctypes.CDLL(d) + _lib = ctypes.CDLL(d) break except: pass @@ -1710,8 +1712,10 @@ else: else: return "" +_error_handler_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint) + _lib.Z3_set_error_handler.restype = None -_lib.Z3_set_error_handler.argtypes = [ContextObj, ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)] +_lib.Z3_set_error_handler.argtypes = [ContextObj, _error_handler_type] """ ) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 21ac695db..a247d0a3a 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -125,11 +125,6 @@ def _get_args(args): except: # len is not necessarily defined when args is not a sequence (use reflection?) return args -def z3_error_handler(c, e): - # Do nothing error handler, just avoid exit(0) - # The wrappers in z3core.py will raise a Z3Exception if an error is detected - return - def _to_param_value(val): if isinstance(val, bool): if val == True: @@ -139,6 +134,11 @@ def _to_param_value(val): else: return str(val) +def z3_error_handler(c, e): + # Do nothing error handler, just avoid exit(0) + # The wrappers in z3core.py will raise a Z3Exception if an error is detected + return + class Context: """A Context manages all other Z3 objects, global configuration options, etc. @@ -165,13 +165,14 @@ class Context: Z3_set_param_value(conf, str(prev), _to_param_value(a)) prev = None self.ctx = Z3_mk_context_rc(conf) + self.eh = Z3_set_error_handler(self.ctx, z3_error_handler) Z3_set_ast_print_mode(self.ctx, Z3_PRINT_SMTLIB2_COMPLIANT) - Z3_set_error_handler(self.ctx, z3_error_handler) Z3_del_config(conf) def __del__(self): - Z3_del_context(self.ctx) + Z3_del_context(self.ctx) self.ctx = None + self.eh = None def ref(self): """Return a reference to the actual C pointer to the Z3 context.""" From 2d221155b3091afef3a38dd280084dd25fd96bab Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 8 Nov 2017 20:52:48 +0000 Subject: [PATCH 016/263] Fixed bug in fp.to_ieee_bv with rewriter.hi_fp_unspecified=true. Reported in #1349. --- src/ast/fpa/fpa2bv_converter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp index 220295dad..d2a946e0c 100644 --- a/src/ast/fpa/fpa2bv_converter.cpp +++ b/src/ast/fpa/fpa2bv_converter.cpp @@ -3093,8 +3093,10 @@ void fpa2bv_converter::mk_to_ieee_bv_unspecified(func_decl * f, unsigned num, ex unsigned ebits = f->get_domain()[0]->get_parameter(0).get_int(); unsigned sbits = f->get_domain()[0]->get_parameter(1).get_int(); - if (m_hi_fp_unspecified) - mk_nan(f->get_range(), result); + if (m_hi_fp_unspecified) { + mk_nan(f->get_domain()[0], result); + join_fp(result, result); + } else { expr * n = args[0]; expr_ref n_bv(m); From 19f43713c9380fd744cdc54917440b6652c0db96 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Wed, 8 Nov 2017 21:16:03 +0000 Subject: [PATCH 017/263] Fixed Windows build of C example. --- scripts/mk_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index e6de3019c..a5c9068db 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -2421,7 +2421,7 @@ def mk_config(): 'LINK_EXTRA_FLAGS=/link%s /DEBUG /MACHINE:X86 /SUBSYSTEM:CONSOLE /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT %s\n' 'SLINK_EXTRA_FLAGS=/link%s /DEBUG /MACHINE:X86 /SUBSYSTEM:WINDOWS /INCREMENTAL:NO /STACK:8388608 /OPT:REF /OPT:ICF /TLBID:1 %s %s\n' % (LTCG, link_extra_opt, LTCG, maybe_disable_dynamic_base, link_extra_opt)) - + config.write('CFLAGS=$(CXXFLAGS)\n') # End of Windows VS config.mk if is_verbose(): From a173b0faf7db1c27b87065e47ba9d59f5eb14fce Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Thu, 9 Nov 2017 13:34:32 +0000 Subject: [PATCH 018/263] Fixed API doc build --- doc/mk_api_doc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/mk_api_doc.py b/doc/mk_api_doc.py index ab4d32d39..3a2343803 100644 --- a/doc/mk_api_doc.py +++ b/doc/mk_api_doc.py @@ -288,6 +288,7 @@ try: # Put z3py at the beginning of the search path to try to avoid picking up # an installed copy of Z3py. sys.path.insert(0, os.path.dirname(Z3PY_PACKAGE_PATH)) + sys.path.insert(0, os.path.dirname(BUILD_DIR)) for modulename in ( 'z3', 'z3.z3consts', From d44d91841444f5cda70fc79680663ba932a3b6aa Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Sat, 11 Nov 2017 14:19:38 +0000 Subject: [PATCH 019/263] API doc build fix. Related to #1350. --- doc/mk_api_doc.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/mk_api_doc.py b/doc/mk_api_doc.py index 3a2343803..a944f2c65 100644 --- a/doc/mk_api_doc.py +++ b/doc/mk_api_doc.py @@ -288,7 +288,14 @@ try: # Put z3py at the beginning of the search path to try to avoid picking up # an installed copy of Z3py. sys.path.insert(0, os.path.dirname(Z3PY_PACKAGE_PATH)) - sys.path.insert(0, os.path.dirname(BUILD_DIR)) + + if sys.version < '3': + import __builtin__ + __builtin__.Z3_LIB_DIRS = [ BUILD_DIR ] + else: + import builtins + builtins.Z3_LIB_DIRS = [ BUILD_DIR ] + for modulename in ( 'z3', 'z3.z3consts', From 45975bec65ad3cad95a6eae8abeaa1f90502c90c Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Sat, 11 Nov 2017 15:11:54 +0000 Subject: [PATCH 020/263] Improved support for MSYS/MINGW. Fixes #969. --- scripts/mk_util.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index a5c9068db..ce83f58e5 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1240,9 +1240,9 @@ def get_so_ext(): sysname = os.uname()[0] if sysname == 'Darwin': return 'dylib' - elif sysname == 'Linux' or sysname == 'FreeBSD' or sysname == 'OpenBSD' or sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'): + elif sysname == 'Linux' or sysname == 'FreeBSD' or sysname == 'OpenBSD': return 'so' - elif sysname == 'CYGWIN': + elif sysname == 'CYGWIN' or sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'): return 'dll' else: assert(False) @@ -2442,6 +2442,8 @@ def mk_config(): CXX = find_cxx_compiler() CC = find_c_compiler() SLIBEXTRAFLAGS = '' + EXE_EXT = '' + LIB_EXT = '.a' if GPROF: CXXFLAGS = '%s -pg' % CXXFLAGS LDFLAGS = '%s -pg' % LDFLAGS @@ -2471,18 +2473,19 @@ def mk_config(): if DEBUG_MODE: CXXFLAGS = '%s -g -Wall' % CXXFLAGS EXAMP_DEBUG_FLAG = '-g' + CPPFLAGS = '%s -DZ3DEBUG -D_DEBUG' % CPPFLAGS else: + CXXFLAGS = '%s -O3' % CXXFLAGS if GPROF: - CXXFLAGS = '%s -O3 -D _EXTERNAL_RELEASE' % CXXFLAGS - else: - CXXFLAGS = '%s -O3 -D _EXTERNAL_RELEASE -fomit-frame-pointer' % CXXFLAGS + CXXFLAGS += '-fomit-frame-pointer' + CPPFLAGS = '%s -DNDEBUG -D_EXTERNAL_RELEASE' % CPPFLAGS if is_CXX_clangpp(): CXXFLAGS = '%s -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value' % CXXFLAGS sysname, _, _, _, machine = os.uname() if sysname == 'Darwin': SO_EXT = '.dylib' SLIBFLAGS = '-dynamiclib' - elif sysname == 'Linux' or sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'): + elif sysname == 'Linux': CXXFLAGS = '%s -D_LINUX_' % CXXFLAGS OS_DEFINES = '-D_LINUX_' SO_EXT = '.so' @@ -2501,15 +2504,22 @@ def mk_config(): OS_DEFINES = '-D_OPENBSD_' SO_EXT = '.so' SLIBFLAGS = '-shared' - elif sysname[:6] == 'CYGWIN': + elif sysname.startswith('CYGWIN'): CXXFLAGS = '%s -D_CYGWIN' % CXXFLAGS OS_DEFINES = '-D_CYGWIN' SO_EXT = '.dll' SLIBFLAGS = '-shared' + elif sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'): + CXXFLAGS = '%s' % CXXFLAGS + OS_DEFINES = '' + SO_EXT = '.dll' + SLIBFLAGS = '-shared' + EXE_EXT = '.exe' + LIB_EXT = '.lib' else: raise MKException('Unsupported platform: %s' % sysname) if is64(): - if sysname[:6] != 'CYGWIN': + if not sysname.startswith('CYGWIN') and not sysname.startswith('MSYS') and not sysname.startswith('MINGW'): CXXFLAGS = '%s -fPIC' % CXXFLAGS CPPFLAGS = '%s -D_AMD64_' % CPPFLAGS if sysname == 'Linux': @@ -2518,10 +2528,6 @@ def mk_config(): CXXFLAGS = '%s -m32' % CXXFLAGS LDFLAGS = '%s -m32' % LDFLAGS SLIBFLAGS = '%s -m32' % SLIBFLAGS - if DEBUG_MODE: - CPPFLAGS = '%s -DZ3DEBUG -D_DEBUG' % CPPFLAGS - else: - CPPFLAGS = '%s -DNDEBUG -D_EXTERNAL_RELEASE' % CPPFLAGS if TRACE or DEBUG_MODE: CPPFLAGS = '%s -D_TRACE' % CPPFLAGS if is_cygwin_mingw(): @@ -2541,11 +2547,11 @@ def mk_config(): config.write('CXX_OUT_FLAG=-o \n') config.write('C_OUT_FLAG=-o \n') config.write('OBJ_EXT=.o\n') - config.write('LIB_EXT=.a\n') + config.write('LIB_EXT=%s\n' % LIB_EXT) config.write('AR=%s\n' % AR) config.write('AR_FLAGS=rcs\n') config.write('AR_OUTFLAG=\n') - config.write('EXE_EXT=\n') + config.write('EXE_EXT=%s\n' % EXE_EXT) config.write('LINK=%s\n' % CXX) config.write('LINK_FLAGS=\n') config.write('LINK_OUT_FLAG=-o \n') From 7c63a5cc1ddf20e769a6d9abb1a43f561ca1ddf5 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Sat, 11 Nov 2017 16:38:53 +0000 Subject: [PATCH 021/263] Fixed MSYS/MinGW build. Fixes #1335. --- scripts/mk_util.py | 4 ++-- src/interp/iz3interp.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index ce83f58e5..b155fd7c2 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -2510,8 +2510,8 @@ def mk_config(): SO_EXT = '.dll' SLIBFLAGS = '-shared' elif sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'): - CXXFLAGS = '%s' % CXXFLAGS - OS_DEFINES = '' + CXXFLAGS = '%s -D_MINGW' % CXXFLAGS + OS_DEFINES = '-D_MINGW' SO_EXT = '.dll' SLIBFLAGS = '-shared' EXE_EXT = '.exe' diff --git a/src/interp/iz3interp.cpp b/src/interp/iz3interp.cpp index f9bf03951..c1c4588cc 100755 --- a/src/interp/iz3interp.cpp +++ b/src/interp/iz3interp.cpp @@ -550,7 +550,7 @@ void interpolation_options_struct::apply(iz3base &b){ // On linux and mac, unlimit stack space so we get recursion -#if defined(_WINDOWS) || defined(_CYGWIN) +#if defined(_WINDOWS) || defined(_CYGWIN) || defined(_MINGW) #else From dbb35b951c3260c628e178fc509384893577f46b Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 13 Nov 2017 08:51:16 -0800 Subject: [PATCH 022/263] make .NET and Java bindings for optimization use Expr instead of ArithExpr to accomodate bit-vector optimization Signed-off-by: Nikolaj Bjorner --- src/api/dotnet/Optimize.cs | 32 +++++++++++++++++--------------- src/api/java/Optimize.java | 32 ++++++++++++++++---------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/api/dotnet/Optimize.cs b/src/api/dotnet/Optimize.cs index 9d0636425..29e5e869a 100644 --- a/src/api/dotnet/Optimize.cs +++ b/src/api/dotnet/Optimize.cs @@ -124,7 +124,7 @@ namespace Microsoft.Z3 /// /// Retrieve a lower bound for the objective handle. /// - public ArithExpr Lower + public Expr Lower { get { return opt.GetLower(handle); } } @@ -132,7 +132,7 @@ namespace Microsoft.Z3 /// /// Retrieve an upper bound for the objective handle. /// - public ArithExpr Upper + public Expr Upper { get { return opt.GetUpper(handle); } } @@ -140,7 +140,7 @@ namespace Microsoft.Z3 /// /// Retrieve the value of an objective. /// - public ArithExpr Value + public Expr Value { get { return Lower; } } @@ -148,7 +148,7 @@ namespace Microsoft.Z3 /// /// Retrieve a lower bound for the objective handle. /// - public ArithExpr[] LowerAsVector + public Expr[] LowerAsVector { get { return opt.GetLowerAsVector(handle); } } @@ -156,7 +156,7 @@ namespace Microsoft.Z3 /// /// Retrieve an upper bound for the objective handle. /// - public ArithExpr[] UpperAsVector + public Expr[] UpperAsVector { get { return opt.GetUpperAsVector(handle); } } @@ -240,8 +240,9 @@ namespace Microsoft.Z3 /// Declare an arithmetical maximization objective. /// Return a handle to the objective. The handle is used as /// to retrieve the values of objectives after calling Check. + /// The expression can be either an arithmetical expression or bit-vector. /// - public Handle MkMaximize(ArithExpr e) + public Handle MkMaximize(Expr e) { return new Handle(this, Native.Z3_optimize_maximize(Context.nCtx, NativeObject, e.NativeObject)); } @@ -250,45 +251,46 @@ namespace Microsoft.Z3 /// Declare an arithmetical minimization objective. /// Similar to MkMaximize. /// - public Handle MkMinimize(ArithExpr e) + public Handle MkMinimize(Expr e) { return new Handle(this, Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject)); } + /// /// Retrieve a lower bound for the objective handle. /// - private ArithExpr GetLower(uint index) + private Expr GetLower(uint index) { - return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index)); + return Expr.Create(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index)); } /// /// Retrieve an upper bound for the objective handle. /// - private ArithExpr GetUpper(uint index) + private Expr GetUpper(uint index) { - return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index)); + return Expr.Create(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index)); } /// /// Retrieve a lower bound for the objective handle. /// - private ArithExpr[] GetLowerAsVector(uint index) + private Expr[] GetLowerAsVector(uint index) { ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_lower_as_vector(Context.nCtx, NativeObject, index)); - return v.ToArithExprArray(); + return v.ToExprArray(); } /// /// Retrieve an upper bound for the objective handle. /// - private ArithExpr[] GetUpperAsVector(uint index) + private Expr[] GetUpperAsVector(uint index) { ASTVector v = new ASTVector(Context, Native.Z3_optimize_get_upper_as_vector(Context.nCtx, NativeObject, index)); - return v.ToArithExprArray(); + return v.ToExprArray(); } /// diff --git a/src/api/java/Optimize.java b/src/api/java/Optimize.java index 3edbff73e..a434b6e9f 100644 --- a/src/api/java/Optimize.java +++ b/src/api/java/Optimize.java @@ -89,7 +89,7 @@ public class Optimize extends Z3Object { /** * Retrieve a lower bound for the objective handle. **/ - public ArithExpr getLower() + public Expr getLower() { return opt.GetLower(handle); } @@ -97,7 +97,7 @@ public class Optimize extends Z3Object { /** * Retrieve an upper bound for the objective handle. **/ - public ArithExpr getUpper() + public Expr getUpper() { return opt.GetUpper(handle); } @@ -110,7 +110,7 @@ public class Optimize extends Z3Object { * and otherwise is represented by the expression {@code value + eps * EPSILON}, * where {@code EPSILON} is an arbitrarily small real number. */ - public ArithExpr[] getUpperAsVector() + public Expr[] getUpperAsVector() { return opt.GetUpperAsVector(handle); } @@ -120,7 +120,7 @@ public class Optimize extends Z3Object { * *

See {@link #getUpperAsVector()} for triple semantics. */ - public ArithExpr[] getLowerAsVector() + public Expr[] getLowerAsVector() { return opt.GetLowerAsVector(handle); } @@ -128,7 +128,7 @@ public class Optimize extends Z3Object { /** * Retrieve the value of an objective. **/ - public ArithExpr getValue() + public Expr getValue() { return getLower(); } @@ -214,7 +214,7 @@ public class Optimize extends Z3Object { * Return a handle to the objective. The handle is used as * to retrieve the values of objectives after calling Check. **/ - public Handle MkMaximize(ArithExpr e) + public Handle MkMaximize(Expr e) { return new Handle(this, Native.optimizeMaximize(getContext().nCtx(), getNativeObject(), e.getNativeObject())); } @@ -223,7 +223,7 @@ public class Optimize extends Z3Object { * Declare an arithmetical minimization objective. * Similar to MkMaximize. **/ - public Handle MkMinimize(ArithExpr e) + public Handle MkMinimize(Expr e) { return new Handle(this, Native.optimizeMinimize(getContext().nCtx(), getNativeObject(), e.getNativeObject())); } @@ -231,17 +231,17 @@ public class Optimize extends Z3Object { /** * Retrieve a lower bound for the objective handle. **/ - private ArithExpr GetLower(int index) + private Expr GetLower(int index) { - return (ArithExpr)Expr.create(getContext(), Native.optimizeGetLower(getContext().nCtx(), getNativeObject(), index)); + return Expr.create(getContext(), Native.optimizeGetLower(getContext().nCtx(), getNativeObject(), index)); } /** * Retrieve an upper bound for the objective handle. **/ - private ArithExpr GetUpper(int index) + private Expr GetUpper(int index) { - return (ArithExpr)Expr.create(getContext(), Native.optimizeGetUpper(getContext().nCtx(), getNativeObject(), index)); + return Expr.create(getContext(), Native.optimizeGetUpper(getContext().nCtx(), getNativeObject(), index)); } /** @@ -249,7 +249,7 @@ public class Optimize extends Z3Object { * *

See {@link Handle#getUpperAsVector}. */ - private ArithExpr[] GetUpperAsVector(int index) { + private Expr[] GetUpperAsVector(int index) { return unpackObjectiveValueVector( Native.optimizeGetUpperAsVector( getContext().nCtx(), getNativeObject(), index @@ -262,7 +262,7 @@ public class Optimize extends Z3Object { * *

See {@link Handle#getLowerAsVector}. */ - private ArithExpr[] GetLowerAsVector(int index) { + private Expr[] GetLowerAsVector(int index) { return unpackObjectiveValueVector( Native.optimizeGetLowerAsVector( getContext().nCtx(), getNativeObject(), index @@ -270,12 +270,12 @@ public class Optimize extends Z3Object { ); } - private ArithExpr[] unpackObjectiveValueVector(long nativeVec) { + private Expr[] unpackObjectiveValueVector(long nativeVec) { ASTVector vec = new ASTVector( getContext(), nativeVec ); - return new ArithExpr[] { - (ArithExpr) vec.get(0), (ArithExpr) vec.get(1), (ArithExpr) vec.get(2) + return new Expr[] { + (Expr) vec.get(0), (Expr) vec.get(1), (Expr) vec.get(2) }; } From 195d81ebefad9ea8b38d0bf049a268ee3012f50c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 13 Nov 2017 13:49:03 -0800 Subject: [PATCH 023/263] fix rewriter loop reported in #1354 Signed-off-by: Nikolaj Bjorner --- src/ast/rewriter/arith_rewriter.cpp | 2 ++ src/interp/iz3translate.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ast/rewriter/arith_rewriter.cpp b/src/ast/rewriter/arith_rewriter.cpp index 631e1d8f3..acc3b889f 100644 --- a/src/ast/rewriter/arith_rewriter.cpp +++ b/src/ast/rewriter/arith_rewriter.cpp @@ -843,6 +843,8 @@ br_status arith_rewriter::mk_mod_core(expr * arg1, expr * arg2, expr_ref & resul continue; if (m_util.is_numeral(arg, arg_v) && mod(arg_v, v2) == arg_v) continue; + if (m().is_ite(arg)) + continue; // found target for rewriting break; } diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp index e4730ea63..ce2249a88 100755 --- a/src/interp/iz3translate.cpp +++ b/src/interp/iz3translate.cpp @@ -155,7 +155,7 @@ public: return res; } - void scan_skolems(const ast &proof){ + void scan_skolems(const ast &proof) { hash_map memo; scan_skolems_rec(memo,proof, INT_MAX); } From 1a0bff7480f0145a5f9bd1adf59d05d6dfd2aa9a Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Sat, 11 Nov 2017 22:49:14 +0000 Subject: [PATCH 024/263] [CMake] When invoking `mk_api_doc.py` pass the build directory. This change was requested by @wintersteiger as an alternative way to unbreak the TravisCI builds. --- doc/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 2f8ee0dc5..b097126d3 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -59,6 +59,7 @@ endif() add_custom_target(api_docs ${ALWAYS_BUILD_DOCS_ARG} COMMAND "${PYTHON_EXECUTABLE}" "${MK_API_DOC_SCRIPT}" + --build "${CMAKE_BINARY_DIR}" --doxygen-executable "${DOXYGEN_EXECUTABLE}" --output-dir "${DOC_DEST_DIR}" --temp-dir "${DOC_TEMP_DIR}" From 116094022fa5d67a1eb9c9319c87bf3504a71511 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 09:10:15 -0800 Subject: [PATCH 025/263] insert total relations in model converter. #1291 Signed-off-by: Nikolaj Bjorner --- .../dl_mk_interp_tail_simplifier.cpp | 3 ++ .../transforms/dl_mk_subsumption_checker.cpp | 53 ++++++++++--------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/muz/transforms/dl_mk_interp_tail_simplifier.cpp b/src/muz/transforms/dl_mk_interp_tail_simplifier.cpp index 7bd35b4ef..8421a99ba 100644 --- a/src/muz/transforms/dl_mk_interp_tail_simplifier.cpp +++ b/src/muz/transforms/dl_mk_interp_tail_simplifier.cpp @@ -607,6 +607,9 @@ namespace datalog { rule_set * res = alloc(rule_set, m_context); if (transform_rules(source, *res)) { res->inherit_predicates(source); + TRACE("dl", + source.display(tout); + res->display(tout);); } else { dealloc(res); res = 0; diff --git a/src/muz/transforms/dl_mk_subsumption_checker.cpp b/src/muz/transforms/dl_mk_subsumption_checker.cpp index e26f105c6..c6bb2864b 100644 --- a/src/muz/transforms/dl_mk_subsumption_checker.cpp +++ b/src/muz/transforms/dl_mk_subsumption_checker.cpp @@ -24,8 +24,10 @@ Revision History: #include "ast/rewriter/rewriter.h" #include "ast/rewriter/rewriter_def.h" #include "muz/transforms/dl_mk_subsumption_checker.h" - #include "muz/base/fixedpoint_params.hpp" +#include "tactic/extension_model_converter.h" + + namespace datalog { @@ -37,26 +39,28 @@ namespace datalog { bool mk_subsumption_checker::is_total_rule(const rule * r) { - if(r->get_tail_size()!=0) { return false; } + if (r->get_tail_size() != 0) { + return false; + } unsigned pt_len = r->get_positive_tail_size(); - if(pt_len!=r->get_uninterpreted_tail_size()) { - //we dont' expect rules with negative tails to be total + if(pt_len != r->get_uninterpreted_tail_size()) { + // we dont' expect rules with negative tails to be total return false; } - for(unsigned i=0; iget_tail(i)->get_decl(); - if(!m_total_relations.contains(tail_pred)) { - //this rule has a non-total predicate in the tail + if (!m_total_relations.contains(tail_pred)) { + // this rule has a non-total predicate in the tail return false; } } unsigned t_len = r->get_positive_tail_size(); - for(unsigned i=pt_len; iis_neg_tail(i)); //we assume interpreted tail not to be negated - if(!m.is_true(r->get_tail(i))) { + if (!m.is_true(r->get_tail(i))) { //this rule has an interpreted tail which is not constant true return false; } @@ -183,20 +187,15 @@ namespace datalog { rule_ref_vector orig_rules(m_context.get_rule_manager()); orig_rules.append(orig.get_num_rules(), orig.begin()); - rule * * rbegin = orig_rules.c_ptr(); - rule * * rend = rbegin + orig_rules.size(); - //before traversing we sort rules so that the shortest are in the beginning. //this will help make subsumption checks more efficient - std::sort(rbegin, rend, rule_size_comparator); + std::sort(orig_rules.c_ptr(), orig_rules.c_ptr() + orig_rules.size(), rule_size_comparator); - for(rule_set::iterator rit = rbegin; rit!=rend; ++rit) { - - rule * r = *rit; + for (rule * r : orig_rules) { func_decl * head_pred = r->get_decl(); - if(m_total_relations.contains(head_pred)) { - if(!orig.is_output_predicate(head_pred) || + if (m_total_relations.contains(head_pred)) { + if (!orig.is_output_predicate(head_pred) || total_relations_with_included_rules.contains(head_pred)) { //We just skip definitions of total non-output relations as //we'll eliminate them from the problem. @@ -205,8 +204,7 @@ namespace datalog { modified = true; continue; } - rule * defining_rule; - VERIFY(m_total_relation_defining_rules.find(head_pred, defining_rule)); + rule * defining_rule = m_total_relation_defining_rules.find(head_pred); if (defining_rule) { rule_ref totality_rule(m_context.get_rule_manager()); VERIFY(transform_rule(defining_rule, subs_index, totality_rule)); @@ -224,24 +222,31 @@ namespace datalog { } rule_ref new_rule(m_context.get_rule_manager()); - if(!transform_rule(r, subs_index, new_rule)) { + if (!transform_rule(r, subs_index, new_rule)) { modified = true; continue; } - if(m_new_total_relation_discovery_during_transformation && is_total_rule(new_rule)) { + if (m_new_total_relation_discovery_during_transformation && is_total_rule(new_rule)) { on_discovered_total_relation(head_pred, new_rule.get()); } - if(subs_index.is_subsumed(new_rule)) { + if (subs_index.is_subsumed(new_rule)) { modified = true; continue; } - if(new_rule.get()!=r) { + if (new_rule.get()!=r) { modified = true; } tgt.add_rule(new_rule); subs_index.add(new_rule); } tgt.inherit_predicates(orig); + if (!m_total_relations.empty() && m_context.get_model_converter()) { + extension_model_converter* mc0 = alloc(extension_model_converter, m); + for (func_decl* p : m_total_relations) { + mc0->insert(p, m.mk_true()); + } + m_context.add_model_converter(mc0); + } TRACE("dl", tout << "original set size: "< Date: Wed, 15 Nov 2017 11:46:28 -0800 Subject: [PATCH 026/263] include information whether rule is reachable in del_rule model converter for simpler model presentation #1241 Signed-off-by: Nikolaj Bjorner --- src/muz/base/dl_util.cpp | 19 ++++++++++++------- src/muz/base/dl_util.h | 2 +- src/muz/transforms/dl_mk_rule_inliner.cpp | 16 ++++++++-------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/muz/base/dl_util.cpp b/src/muz/base/dl_util.cpp index f0439a55c..fad424b90 100644 --- a/src/muz/base/dl_util.cpp +++ b/src/muz/base/dl_util.cpp @@ -277,16 +277,21 @@ namespace datalog { return get_max_var(has_var); } - void del_rule(horn_subsume_model_converter* mc, rule& r) { + void del_rule(horn_subsume_model_converter* mc, rule& r, bool unreachable) { if (mc) { ast_manager& m = mc->get_manager(); expr_ref_vector body(m); - for (unsigned i = 0; i < r.get_tail_size(); ++i) { - if (r.is_neg_tail(i)) { - body.push_back(m.mk_not(r.get_tail(i))); - } - else { - body.push_back(r.get_tail(i)); + if (unreachable) { + body.push_back(m.mk_false()); + } + else { + for (unsigned i = 0; i < r.get_tail_size(); ++i) { + if (r.is_neg_tail(i)) { + body.push_back(m.mk_not(r.get_tail(i))); + } + else { + body.push_back(r.get_tail(i)); + } } } TRACE("dl_dr", diff --git a/src/muz/base/dl_util.h b/src/muz/base/dl_util.h index c560ee28e..6b689fd17 100644 --- a/src/muz/base/dl_util.h +++ b/src/muz/base/dl_util.h @@ -354,7 +354,7 @@ namespace datalog { unsigned get_max_rule_var(const rule& r); }; - void del_rule(horn_subsume_model_converter* mc, rule& r); + void del_rule(horn_subsume_model_converter* mc, rule& r, bool unreachable); void resolve_rule(rule_manager& rm, replace_proof_converter* pc, rule const& r1, rule const& r2, unsigned idx, diff --git a/src/muz/transforms/dl_mk_rule_inliner.cpp b/src/muz/transforms/dl_mk_rule_inliner.cpp index 30ff330ab..f1a4eb32b 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.cpp +++ b/src/muz/transforms/dl_mk_rule_inliner.cpp @@ -426,7 +426,7 @@ namespace datalog { for (unsigned i = 0; i < m_inlined_rules.get_num_rules(); ++i) { rule* r = m_inlined_rules.get_rule(i); - datalog::del_rule(m_mc, *r); + datalog::del_rule(m_mc, *r, true); } } @@ -465,7 +465,7 @@ namespace datalog { } } if (modified) { - datalog::del_rule(m_mc, *r0); + datalog::del_rule(m_mc, *r0, true); } return modified; @@ -488,9 +488,9 @@ namespace datalog { } if (something_done && m_mc) { - for (rule_set::iterator rit = orig.begin(); rit!=rend; ++rit) { - if (inlining_allowed(orig, (*rit)->get_decl())) { - datalog::del_rule(m_mc, **rit); + for (rule* r : orig) { + if (inlining_allowed(orig, r->get_decl())) { + datalog::del_rule(m_mc, *r, true); } } } @@ -580,7 +580,7 @@ namespace datalog { // nothing unifies with the tail atom, therefore the rule is unsatisfiable // (we can say this because relation pred doesn't have any ground facts either) res = 0; - datalog::del_rule(m_mc, *r); + datalog::del_rule(m_mc, *r, false); return true; } if (!is_oriented_rewriter(inlining_candidate, strat)) { @@ -590,7 +590,7 @@ namespace datalog { goto process_next_tail; } if (!try_to_inline_rule(*r, *inlining_candidate, ti, res)) { - datalog::del_rule(m_mc, *r); + datalog::del_rule(m_mc, *r, false); res = 0; } return true; @@ -823,7 +823,7 @@ namespace datalog { if (num_tail_unifiers == 1) { TRACE("dl", tout << "setting invalid: " << j << "\n";); valid.set(j, false); - datalog::del_rule(m_mc, *r2); + datalog::del_rule(m_mc, *r2, true); del_rule(r2, j); } From 795e0c641a6a44362b47707c5885f921a07265e1 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 14:44:59 -0800 Subject: [PATCH 027/263] add method to create bit-vectors directly from an array of Booleans Signed-off-by: Nikolaj Bjorner --- scripts/update_api.py | 2 +- src/api/api_numeral.cpp | 14 ++++++++++++++ src/api/c++/z3++.h | 6 ++++++ src/api/dotnet/Context.cs | 14 ++++++++++++++ src/api/z3_api.h | 8 ++++++++ src/ast/ast.cpp | 14 +------------- src/ast/rewriter/poly_rewriter_def.h | 2 +- 7 files changed, 45 insertions(+), 15 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 2828a63f8..2096e00ba 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -957,7 +957,7 @@ def def_API(name, result, params): log_c.write(" }\n") log_c.write(" Au(a%s);\n" % sz) exe_c.write("in.get_uint_array(%s)" % i) - elif ty == INT: + elif ty == INT or ty == BOOL: log_c.write("U(a%s[i]);" % i) log_c.write(" }\n") log_c.write(" Au(a%s);\n" % sz) diff --git a/src/api/api_numeral.cpp b/src/api/api_numeral.cpp index 95bc0bef9..effa5f411 100644 --- a/src/api/api_numeral.cpp +++ b/src/api/api_numeral.cpp @@ -387,4 +387,18 @@ extern "C" { Z3_CATCH_RETURN(Z3_FALSE); } + Z3_ast Z3_API Z3_mk_bv_numeral(Z3_context c, unsigned sz, Z3_bool const* bits) { + Z3_TRY; + LOG_Z3_mk_bv_numeral(c, sz, bits); + RESET_ERROR_CODE(); + rational r(0), two(2), one(1); + for (unsigned i = 0; i < sz; ++i) { + r *= two; + if (bits[i]) r += one; + } + ast * a = mk_c(c)->mk_numeral_core(r, mk_c(c)->bvutil().mk_sort(sz)); + RETURN_Z3(of_ast(a)); + Z3_CATCH_RETURN(0); + } + }; diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 23a7bd22e..df385db78 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -301,6 +301,7 @@ namespace z3 { expr bv_val(__int64 n, unsigned sz); expr bv_val(__uint64 n, unsigned sz); expr bv_val(char const * n, unsigned sz); + expr bv_val(unsigned n, bool const* bits); expr string_val(char const* s); expr string_val(std::string const& s); @@ -2455,6 +2456,11 @@ namespace z3 { inline expr context::bv_val(__int64 n, unsigned sz) { Z3_ast r = Z3_mk_int64(m_ctx, n, bv_sort(sz)); check_error(); return expr(*this, r); } inline expr context::bv_val(__uint64 n, unsigned sz) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, bv_sort(sz)); check_error(); return expr(*this, r); } inline expr context::bv_val(char const * n, unsigned sz) { Z3_ast r = Z3_mk_numeral(m_ctx, n, bv_sort(sz)); check_error(); return expr(*this, r); } + inline expr context::bv_val(unsigned n, bool const* bits) { + array _bits(n); + for (unsigned i = 0; i < n; ++i) _bits[i] = bits[i] ? 1 : 0; + Z3_ast r = Z3_mk_bv_numeral(m_ctx, n, _bits.ptr()); check_error(); return expr(*this, r); + } inline expr context::string_val(char const* s) { Z3_ast r = Z3_mk_string(m_ctx, s); check_error(); return expr(*this, r); } inline expr context::string_val(std::string const& s) { Z3_ast r = Z3_mk_string(m_ctx, s.c_str()); check_error(); return expr(*this, r); } diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index 27711be81..914cee615 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -3127,6 +3127,20 @@ namespace Microsoft.Z3 return (BitVecNum)MkNumeral(v, MkBitVecSort(size)); } + + ///

+ /// Create a bit-vector numeral. + /// + /// An array of bits representing the bit-vector. Least signficant bit is at position 0. + public BitVecNum MkBV(bool[] bits) + { + Contract.Ensures(Contract.Result() != null); + int[] _bits = new int[bits.Length]; + for (int i = 0; i < bits.Length; ++i) _bits[i] = bits[i] ? 1 : 0; + return (BitVecNum)Expr.Create(this, Native.Z3_mk_bv_numeral(nCtx, (uint)bits.Length, _bits)); + } + + #endregion #endregion // Numerals diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 9f155b45e..cf1c8fca7 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -3248,6 +3248,14 @@ extern "C" { */ Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, __uint64 v, Z3_sort ty); + /** + \brief create a bit-vector numeral from a vector of Booleans. + + \sa Z3_mk_numeral + def_API('Z3_mk_bv_numeral', AST, (_in(CONTEXT), _in(UINT), _in_array(1, BOOL))) + */ + Z3_ast Z3_API Z3_mk_bv_numeral(Z3_context c, unsigned sz, Z3_bool const* bits); + /*@}*/ /** @name Sequences and regular expressions */ diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 98c1bdfed..d0921c8de 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -26,6 +26,7 @@ Revision History: #include "util/string_buffer.h" #include "ast/ast_util.h" #include "ast/ast_smt2_pp.h" +#include "ast/bv_decl_plugin.h" // ----------------------------------- // @@ -1684,22 +1685,9 @@ ast * ast_manager::register_node_core(ast * n) { CASSERT("nondet_bug", contains || slow_not_contains(n)); #endif -#if 0 - static unsigned counter = 0; - counter++; - if (counter % 100000 == 0) - verbose_stream() << "[ast-table] counter: " << counter << " collisions: " << m_ast_table.collisions() << " capacity: " << m_ast_table.capacity() << " size: " << m_ast_table.size() << "\n"; -#endif - ast * r = m_ast_table.insert_if_not_there(n); SASSERT(r->m_hash == h); if (r != n) { -#if 0 - static unsigned reused = 0; - reused++; - if (reused % 100000 == 0) - verbose_stream() << "[ast-table] reused: " << reused << "\n"; -#endif SASSERT(contains); SASSERT(m_ast_table.contains(n)); if (is_func_decl(r) && to_func_decl(r)->get_range() != to_func_decl(n)->get_range()) { diff --git a/src/ast/rewriter/poly_rewriter_def.h b/src/ast/rewriter/poly_rewriter_def.h index 3bb963a7f..71a9079a0 100644 --- a/src/ast/rewriter/poly_rewriter_def.h +++ b/src/ast/rewriter/poly_rewriter_def.h @@ -687,7 +687,7 @@ br_status poly_rewriter::mk_sub(unsigned num_args, expr * const * args, } set_curr_sort(m().get_sort(args[0])); expr_ref minus_one(mk_numeral(numeral(-1)), m()); - ptr_buffer new_args; + expr_ref_buffer new_args(m()); new_args.push_back(args[0]); for (unsigned i = 1; i < num_args; i++) { if (is_zero(args[i])) continue; From 7f13cf13f286fad9bc6d8e50bb9537f41bf15b72 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 15:00:11 -0800 Subject: [PATCH 028/263] clean up bv_numeral code and fix bug in how they are initialized Signed-off-by: Nikolaj Bjorner --- src/api/api_numeral.cpp | 5 ++--- src/ast/ast.cpp | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/api/api_numeral.cpp b/src/api/api_numeral.cpp index effa5f411..9a778d6e0 100644 --- a/src/api/api_numeral.cpp +++ b/src/api/api_numeral.cpp @@ -391,10 +391,9 @@ extern "C" { Z3_TRY; LOG_Z3_mk_bv_numeral(c, sz, bits); RESET_ERROR_CODE(); - rational r(0), two(2), one(1); + rational r(0); for (unsigned i = 0; i < sz; ++i) { - r *= two; - if (bits[i]) r += one; + if (bits[i]) r += rational::power_of_two(i); } ast * a = mk_c(c)->mk_numeral_core(r, mk_c(c)->bvutil().mk_sort(sz)); RETURN_Z3(of_ast(a)); diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index d0921c8de..e7d808b2b 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -26,7 +26,6 @@ Revision History: #include "util/string_buffer.h" #include "ast/ast_util.h" #include "ast/ast_smt2_pp.h" -#include "ast/bv_decl_plugin.h" // ----------------------------------- // From 61d149a724ca17970bae3b1525e4cf1a17825340 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 16:18:18 -0800 Subject: [PATCH 029/263] fix java build problem with bool arrays Signed-off-by: Nikolaj Bjorner --- scripts/update_api.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 2096e00ba..45ea9be23 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -240,7 +240,7 @@ def param2javaw(p): if k == OUT: return "jobject" elif k == IN_ARRAY or k == INOUT_ARRAY or k == OUT_ARRAY: - if param_type(p) == INT or param_type(p) == UINT: + if param_type(p) == INT or param_type(p) == UINT or param_type(p) == BOOL: return "jintArray" else: return "jlongArray" @@ -258,7 +258,7 @@ def param2pystr(p): def param2ml(p): k = param_kind(p) if k == OUT: - if param_type(p) == INT or param_type(p) == UINT or param_type(p) == INT64 or param_type(p) == UINT64: + if param_type(p) == INT or param_type(p) == UINT or param_type(p) == BOOL or param_type(p) == INT64 or param_type(p) == UINT64: return "int" elif param_type(p) == STRING: return "string" @@ -491,7 +491,7 @@ def java_method_name(name): # Return the type of the java array elements def java_array_element_type(p): - if param_type(p) == INT or param_type(p) == UINT: + if param_type(p) == INT or param_type(p) == UINT or param_type(p) == BOOL: return 'jint' else: return 'jlong' @@ -653,7 +653,7 @@ def mk_java(java_dir, package_name): if k == OUT or k == INOUT: java_wrapper.write(' %s _a%s;\n' % (type2str(param_type(param)), i)) elif k == IN_ARRAY or k == INOUT_ARRAY: - if param_type(param) == INT or param_type(param) == UINT: + if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL: java_wrapper.write(' %s * _a%s = (%s*) jenv->GetIntArrayElements(a%s, NULL);\n' % (type2str(param_type(param)), i, type2str(param_type(param)), i)) else: java_wrapper.write(' GETLONGAELEMS(%s, a%s, _a%s);\n' % (type2str(param_type(param)), i, i)) @@ -663,7 +663,7 @@ def mk_java(java_dir, package_name): type2str(param_type(param)), param_array_capacity_pos(param), type2str(param_type(param)))) - if param_type(param) == INT or param_type(param) == UINT: + if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL: java_wrapper.write(' jenv->GetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i)) else: java_wrapper.write(' GETLONGAREGION(%s, a%s, 0, a%s, _a%s);\n' % (type2str(param_type(param)), i, param_array_capacity_pos(param), i)) @@ -702,19 +702,19 @@ def mk_java(java_dir, package_name): for param in params: k = param_kind(param) if k == OUT_ARRAY: - if param_type(param) == INT or param_type(param) == UINT: + if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL: java_wrapper.write(' jenv->SetIntArrayRegion(a%s, 0, (jsize)a%s, (jint*)_a%s);\n' % (i, param_array_capacity_pos(param), i)) else: java_wrapper.write(' SETLONGAREGION(a%s, 0, a%s, _a%s);\n' % (i, param_array_capacity_pos(param), i)) java_wrapper.write(' free(_a%s);\n' % i) elif k == IN_ARRAY or k == OUT_ARRAY: - if param_type(param) == INT or param_type(param) == UINT: + if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL: java_wrapper.write(' jenv->ReleaseIntArrayElements(a%s, (jint*)_a%s, JNI_ABORT);\n' % (i, i)) else: java_wrapper.write(' RELEASELONGAELEMS(a%s, _a%s);\n' % (i, i)) elif k == OUT or k == INOUT: - if param_type(param) == INT or param_type(param) == UINT: + if param_type(param) == INT or param_type(param) == UINT or param_type(param) == BOOL: java_wrapper.write(' {\n') java_wrapper.write(' jclass mc = jenv->GetObjectClass(a%s);\n' % i) java_wrapper.write(' jfieldID fid = jenv->GetFieldID(mc, "value", "I");\n') From cde41cf16ca9d95acd95d66a24a136b0cddb09da Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 16:39:09 -0800 Subject: [PATCH 030/263] fix slicer for unsoundness. #1304 Signed-off-by: Nikolaj Bjorner --- src/muz/transforms/dl_mk_slice.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/muz/transforms/dl_mk_slice.cpp b/src/muz/transforms/dl_mk_slice.cpp index c094e5520..dc11935e3 100644 --- a/src/muz/transforms/dl_mk_slice.cpp +++ b/src/muz/transforms/dl_mk_slice.cpp @@ -426,8 +426,8 @@ namespace datalog { bool change = true; while (change) { change = false; - for (unsigned i = 0; i < src.get_num_rules(); ++i) { - change = prune_rule(*src.get_rule(i)) || change; + for (rule* r : src) { + change = prune_rule(*r) || change; } } } @@ -457,18 +457,19 @@ namespace datalog { void mk_slice::solve_vars(rule& r, uint_set& used_vars, uint_set& parameter_vars) { expr_ref_vector conjs = get_tail_conjs(r); - for (unsigned j = 0; j < conjs.size(); ++j) { - expr* e = conjs[j].get(); + for (expr * e : conjs) { expr_ref r(m); unsigned v; if (is_eq(e, v, r) && is_output(v) && m_var_is_sliceable[v]) { TRACE("dl", tout << "is_eq: " << mk_pp(e, m) << " " << (m_solved_vars[v].get()?"solved":"new") << "\n";); add_var(v); if (!m_solved_vars[v].get()) { + TRACE("dl", tout << v << " is solved\n";); add_free_vars(parameter_vars, r); m_solved_vars[v] = r; } else { + TRACE("dl", tout << v << " is used\n";); // variables can only be solved once. add_free_vars(used_vars, e); add_free_vars(used_vars, m_solved_vars[v].get()); @@ -508,10 +509,9 @@ namespace datalog { // uint_set used_vars, parameter_vars; solve_vars(r, used_vars, parameter_vars); - uint_set::iterator it = used_vars.begin(), end = used_vars.end(); - for (; it != end; ++it) { - if (*it < m_var_is_sliceable.size()) { - m_var_is_sliceable[*it] = false; + for (unsigned uv : used_vars) { + if (uv < m_var_is_sliceable.size()) { + m_var_is_sliceable[uv] = false; } } // @@ -533,6 +533,9 @@ namespace datalog { if (m_solved_vars[i].get()) { m_var_is_sliceable[i] = false; } + if (parameter_vars.contains(i)) { + m_var_is_sliceable[i] = false; + } } else if (is_output) { if (parameter_vars.contains(i)) { @@ -687,11 +690,9 @@ namespace datalog { } void mk_slice::display(std::ostream& out) { - obj_map::iterator it = m_sliceable.begin(); - obj_map::iterator end = m_sliceable.end(); - for (; it != end; ++it) { - out << it->m_key->get_name() << " "; - bit_vector const& bv = it->m_value; + for (auto const& kv : m_sliceable) { + out << kv.m_key->get_name() << " "; + bit_vector const& bv = kv.m_value; for (unsigned i = 0; i < bv.size(); ++i) { out << (bv.get(i)?"1":"0"); } From 58be77730746a357bf3d7123df9d5ceac49cc40f Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 20:32:37 -0800 Subject: [PATCH 031/263] fix #1358 Signed-off-by: Nikolaj Bjorner --- src/tactic/arith/diff_neq_tactic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tactic/arith/diff_neq_tactic.cpp b/src/tactic/arith/diff_neq_tactic.cpp index 651000297..c66483750 100644 --- a/src/tactic/arith/diff_neq_tactic.cpp +++ b/src/tactic/arith/diff_neq_tactic.cpp @@ -95,13 +95,13 @@ class diff_neq_tactic : public tactic { if (is_uninterp_const(lhs) && u.is_numeral(rhs, k) && m_max_neg_k <= k && k <= m_max_k) { var x = mk_var(lhs); int _k = static_cast(k.get_int64()); - m_upper[x] = _k; + m_upper[x] = std::min(m_upper[x], _k); } else if (is_uninterp_const(rhs) && u.is_numeral(lhs, k) && m_max_neg_k <= k && k <= m_max_k) { var x = mk_var(rhs); int _k = static_cast(k.get_int64()); - m_lower[x] = _k; + m_lower[x] = std::max(m_lower[x], _k); } else { throw_not_supported(); From c3f67f3b5f77bb7ea984baf2fa6117874d5aff44 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 21:17:00 -0800 Subject: [PATCH 032/263] fix infinite loop in traversing equivalence class, #1274, still requires addressing MBQI Signed-off-by: Nikolaj Bjorner --- src/smt/smt_context.cpp | 2 +- src/smt/smt_context.h | 7 ++++++- src/smt/theory_str.cpp | 19 +++++++++++++------ src/smt/theory_str.h | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 7b508c7d8..2e65fddc9 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -4373,7 +4373,7 @@ namespace smt { void context::add_rec_funs_to_model() { ast_manager& m = m_manager; SASSERT(m_model); - for (unsigned i = 0; i < m_asserted_formulas.get_num_formulas(); ++i) { + for (unsigned i = 0; !get_cancel_flag() && i < m_asserted_formulas.get_num_formulas(); ++i) { expr* e = m_asserted_formulas.get_formula(i); if (is_quantifier(e)) { TRACE("context", tout << mk_pp(e, m) << "\n";); diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index 3cc577b29..c6cca2c43 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -209,7 +209,12 @@ namespace smt { ~scoped_mk_model() { if (m_ctx.m_proto_model.get() != 0) { m_ctx.m_model = m_ctx.m_proto_model->mk_model(); - m_ctx.add_rec_funs_to_model(); + try { + m_ctx.add_rec_funs_to_model(); + } + catch (...) { + // no op + } m_ctx.m_proto_model = 0; // proto_model is not needed anymore. } } diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index a1f0f9777..17f889946 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -47,6 +47,8 @@ namespace smt { sLevel(0), finalCheckProgressIndicator(false), m_trail(m), + m_factory(nullptr), + m_unused_id(0), m_delayed_axiom_setup_terms(m), tmpStringVarCount(0), tmpXorVarCount(0), @@ -4648,14 +4650,17 @@ namespace smt { // We only check m_find for a string constant. expr * theory_str::z3str2_get_eqc_value(expr * n , bool & hasEqcValue) { - expr * curr = n; + theory_var curr = m_find.find(get_var(n)); + theory_var first = curr; do { - if (u.str.is_string(curr)) { + expr* a = get_ast(curr); + if (u.str.is_string(a)) { hasEqcValue = true; - return curr; + return a; } - curr = get_eqc_next(curr); - } while (curr != n); + curr = m_find.next(curr); + } + while (curr != first && curr != null_theory_var); hasEqcValue = false; return n; } @@ -10584,7 +10589,9 @@ namespace smt { return alloc(expr_wrapper_proc, val); } else { TRACE("str", tout << "WARNING: failed to find a concrete value, falling back" << std::endl;); - return alloc(expr_wrapper_proc, to_app(mk_string("**UNUSED**"))); + std::ostringstream unused; + unused << "**UNUSED**" << (m_unused_id++); + return alloc(expr_wrapper_proc, to_app(mk_string(unused.str().c_str()))); } } diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index acac8cad1..b478808d2 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -267,6 +267,10 @@ protected: str_value_factory * m_factory; + // Unique identifier appended to unused variables to ensure that model construction + // does not introduce equalities when they weren't enforced. + unsigned m_unused_id; + // terms we couldn't go through set_up_axioms() with because they weren't internalized expr_ref_vector m_delayed_axiom_setup_terms; From c3364f17fa5058903ce4e606da21a9d0e781d23a Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 21:19:22 -0800 Subject: [PATCH 033/263] fix infinite loop in traversing equivalence class, #1274, still requires addressing MBQI Signed-off-by: Nikolaj Bjorner --- src/smt/theory_str.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 17f889946..2ed8c578f 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -4652,15 +4652,17 @@ namespace smt { expr * theory_str::z3str2_get_eqc_value(expr * n , bool & hasEqcValue) { theory_var curr = m_find.find(get_var(n)); theory_var first = curr; - do { - expr* a = get_ast(curr); - if (u.str.is_string(a)) { - hasEqcValue = true; - return a; - } - curr = m_find.next(curr); - } - while (curr != first && curr != null_theory_var); + if (curr != null_theory_var) { + do { + expr* a = get_ast(curr); + if (u.str.is_string(a)) { + hasEqcValue = true; + return a; + } + curr = m_find.next(curr); + } + while (curr != first && curr != null_theory_var); + } hasEqcValue = false; return n; } From 2e6ae8cfd24bea46bbc9c2fd54ce7eb611d12caa Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 15 Nov 2017 23:06:05 -0800 Subject: [PATCH 034/263] fix crash Signed-off-by: Nikolaj Bjorner --- src/smt/theory_str.cpp | 15 ++++++++------- src/smt/theory_str.h | 2 +- src/util/union_find.h | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 2ed8c578f..ed926a50d 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -63,8 +63,8 @@ namespace smt { cacheHitCount(0), cacheMissCount(0), m_fresh_id(0), - m_find(*this), - m_trail_stack(*this) + m_trail_stack(*this), + m_find(*this) { initialize_charset(); } @@ -281,7 +281,7 @@ namespace smt { } else { theory_var v = theory::mk_var(n); m_find.mk_var(); - TRACE("str", tout << "new theory var v#" << v << std::endl;); + TRACE("str", tout << "new theory var v#" << v << " find " << m_find.find(v) << std::endl;); get_context().attach_th_var(n, this, v); get_context().mark_as_relevant(n); return v; @@ -1905,8 +1905,8 @@ namespace smt { // support for user_smt_theory-style EQC handling - app * theory_str::get_ast(theory_var i) { - return get_enode(i)->get_owner(); + app * theory_str::get_ast(theory_var v) { + return get_enode(v)->get_owner(); } theory_var theory_str::get_var(expr * n) const { @@ -4650,9 +4650,10 @@ namespace smt { // We only check m_find for a string constant. expr * theory_str::z3str2_get_eqc_value(expr * n , bool & hasEqcValue) { - theory_var curr = m_find.find(get_var(n)); - theory_var first = curr; + theory_var curr = get_var(n); if (curr != null_theory_var) { + curr = m_find.find(curr); + theory_var first = curr; do { expr* a = get_ast(curr); if (u.str.is_string(a)) { diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index b478808d2..03fd31162 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -362,8 +362,8 @@ protected: // cache mapping each string S to Length(S) obj_map length_ast_map; - th_union_find m_find; th_trail_stack m_trail_stack; + th_union_find m_find; theory_var get_var(expr * n) const; expr * get_eqc_next(expr * n); app * get_ast(theory_var i); diff --git a/src/util/union_find.h b/src/util/union_find.h index 7a99b149e..416b653af 100644 --- a/src/util/union_find.h +++ b/src/util/union_find.h @@ -102,6 +102,7 @@ public: unsigned find(unsigned v) const { while (true) { + SASSERT(v < m_find.size()); unsigned new_v = m_find[v]; if (new_v == v) return v; From 07031798ecf70edf76175195b55fef849d7099f3 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 16 Nov 2017 01:43:35 -0800 Subject: [PATCH 035/263] fix occurs function used in qe_lite #1241 Signed-off-by: Nikolaj Bjorner --- src/qe/qe_lite.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/qe/qe_lite.cpp b/src/qe/qe_lite.cpp index 257331161..01806bc24 100644 --- a/src/qe/qe_lite.cpp +++ b/src/qe/qe_lite.cpp @@ -20,7 +20,6 @@ Revision History: #include "qe/qe_lite.h" #include "ast/expr_abstract.h" #include "ast/used_vars.h" -#include "ast/occurs.h" #include "ast/rewriter/rewriter_def.h" #include "ast/ast_pp.h" #include "ast/ast_ll_pp.h" @@ -39,6 +38,30 @@ Revision History: #include "qe/qe_vartest.h" namespace eq { + + bool occurs_var(unsigned idx, expr* e) { + ptr_buffer todo; + todo.push_back(e); + ast_mark mark; + while (!todo.empty()) { + expr* e = todo.back(); + todo.pop_back(); + if (mark.is_marked(e)) continue; + mark.mark(e, true); + if (is_var(e)) { + if (to_var(e)->get_idx() == idx) return true; + } + else if (is_app(e)) { + todo.append(to_app(e)->get_num_args(), to_app(e)->get_args()); + } + else if (is_quantifier(e)) { + quantifier* q = to_quantifier(e); + if (occurs_var(idx + q->get_num_decls(), q->get_expr())) return true; + } + } + return false; + } + class der { ast_manager & m; arith_util a; @@ -65,7 +88,7 @@ namespace eq { for (unsigned i = 0; i < definitions.size(); i++) { var * v = vars[i]; expr * t = definitions[i]; - if (t == 0 || has_quantifiers(t) || occurs(v, t)) + if (t == 0 || has_quantifiers(t) || occurs_var(v->get_idx(), t)) definitions[i] = 0; else found = true; // found at least one candidate @@ -679,9 +702,9 @@ namespace eq { } bool is_unconstrained(var* x, expr* t, unsigned i, expr_ref_vector const& conjs) { - bool occ = occurs(x, t); + bool occ = occurs_var(x->get_idx(), t); for (unsigned j = 0; !occ && j < conjs.size(); ++j) { - occ = (i != j) && occurs(x, conjs[j]); + occ = (i != j) && occurs_var(x->get_idx(), conjs[j]); } return !occ; } From 2efcd5b78901a0635c4f0dc977a8ef06817913c0 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 16 Nov 2017 08:55:40 -0800 Subject: [PATCH 036/263] additional bit-vector operators over C++ API Signed-off-by: Nikolaj Bjorner --- src/api/c++/z3++.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index df385db78..3d39cdb74 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -965,6 +965,13 @@ namespace z3 { friend expr operator|(expr const & a, expr const & b); friend expr operator|(expr const & a, int b); friend expr operator|(int a, expr const & b); + friend expr nand(expr const& a, expr const& b); + friend expr nor(expr const& a, expr const& b); + friend expr xnor(expr const& a, expr const& b); + + expr rotate_left(unsigned i) { Z3_ast r = Z3_mk_rotate_left(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); } + expr rotate_right(unsigned i) { Z3_ast r = Z3_mk_rotate_right(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); } + expr repeat(unsigned i) { Z3_ast r = Z3_mk_repeat(ctx(), i, *this); ctx().check_error(); return expr(ctx(), r); } friend expr operator~(expr const & a); expr extract(unsigned hi, unsigned lo) const { Z3_ast r = Z3_mk_extract(ctx(), hi, lo, *this); ctx().check_error(); return expr(ctx(), r); } @@ -1333,6 +1340,10 @@ namespace z3 { inline expr operator|(expr const & a, int b) { return a | a.ctx().num_val(b, a.get_sort()); } inline expr operator|(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) | b; } + inline expr nand(expr const& a, expr const& b) { check_context(a, b); Z3_ast r = Z3_mk_bvnand(a.ctx(), a, b); return expr(a.ctx(), r); } + inline expr nor(expr const& a, expr const& b) { check_context(a, b); Z3_ast r = Z3_mk_bvnor(a.ctx(), a, b); return expr(a.ctx(), r); } + inline expr xnor(expr const& a, expr const& b) { check_context(a, b); Z3_ast r = Z3_mk_bvxnor(a.ctx(), a, b); return expr(a.ctx(), r); } + inline expr operator~(expr const & a) { Z3_ast r = Z3_mk_bvnot(a.ctx(), a); return expr(a.ctx(), r); } From a68d5131c7b91b841289f25044511f76f8232eaa Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 16 Nov 2017 09:00:14 -0800 Subject: [PATCH 037/263] add bvsmod Signed-off-by: Nikolaj Bjorner --- src/api/c++/z3++.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 3d39cdb74..4b5e9d04e 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -1418,11 +1418,18 @@ namespace z3 { inline expr udiv(int a, expr const & b) { return udiv(b.ctx().num_val(a, b.get_sort()), b); } /** - \brief signed reminder operator for bitvectors + \brief signed remainder operator for bitvectors */ inline expr srem(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsrem(a.ctx(), a, b)); } inline expr srem(expr const & a, int b) { return srem(a, a.ctx().num_val(b, a.get_sort())); } inline expr srem(int a, expr const & b) { return srem(b.ctx().num_val(a, b.get_sort()), b); } + + /** + \brief signed modulus operator for bitvectors + */ + inline expr smod(expr const & a, expr const & b) { return to_expr(a.ctx(), Z3_mk_bvsmod(a.ctx(), a, b)); } + inline expr smod(expr const & a, int b) { return smod(a, a.ctx().num_val(b, a.get_sort())); } + inline expr smod(int a, expr const & b) { return smod(b.ctx().num_val(a, b.get_sort()), b); } /** \brief unsigned reminder operator for bitvectors From 62cf6aace75f9dd74d17f4fb2d0d980b447a2207 Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Thu, 16 Nov 2017 10:20:21 -0800 Subject: [PATCH 038/263] avoid a warning Signed-off-by: Lev Nachmanson --- src/util/lp/lar_solver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/lp/lar_solver.h b/src/util/lp/lar_solver.h index 6d2cbea7d..1f1054bb6 100644 --- a/src/util/lp/lar_solver.h +++ b/src/util/lp/lar_solver.h @@ -1157,7 +1157,7 @@ public: bool explanation_is_correct(const vector>& explanation) const { #ifdef Z3DEBUG - lconstraint_kind kind; + lconstraint_kind kind = EQ; // initialize it just to avoid a warning SASSERT(the_relations_are_of_same_type(explanation, kind)); SASSERT(the_left_sides_sum_to_zero(explanation)); mpq rs = sum_of_right_sides_of_explanation(explanation); From f5ff9fae3477850d849d217193857f37c2ee5e0d Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 17 Nov 2017 21:15:30 +0000 Subject: [PATCH 039/263] Fixed bug check in bv2fpa converter. Fixes #1291. --- src/ast/fpa/bv2fpa_converter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ast/fpa/bv2fpa_converter.cpp b/src/ast/fpa/bv2fpa_converter.cpp index 2f5a7c3c1..d87929864 100644 --- a/src/ast/fpa/bv2fpa_converter.cpp +++ b/src/ast/fpa/bv2fpa_converter.cpp @@ -297,7 +297,7 @@ func_interp * bv2fpa_converter::convert_func_interp(model_core * mc, func_decl * // The BV model may have multiple equivalent entries using different // representations of NaN. We can only keep one and we check that // the results for all those entries are the same. - if (ft_fres != fe->get_result()) + if (m_fpa_util.is_float(rng) && ft_fres != fe->get_result()) throw default_exception("BUG: UF function entries disagree with each other"); } } From 620bd812690228eda0462e78ec209d4749590e9f Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 19 Nov 2017 20:41:42 -0800 Subject: [PATCH 040/263] avoid rationals for addition in checked_int64 Signed-off-by: Nikolaj Bjorner --- src/util/checked_int64.h | 66 +++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/src/util/checked_int64.h b/src/util/checked_int64.h index a9087e1c2..8a2eb124d 100644 --- a/src/util/checked_int64.h +++ b/src/util/checked_int64.h @@ -116,58 +116,48 @@ public: const checked_int64 operator--(int) { checked_int64 tmp(*this); --(*this); return tmp; } checked_int64& operator+=(checked_int64 const& other) { - if (CHECK && m_value > 0 && other.m_value > 0 && - (m_value > INT_MAX || other.m_value > INT_MAX)) { - rational r(r64(m_value) + r64(other.m_value)); - if (!r.is_int64()) { - throw overflow_exception(); - } - m_value = r.get_int64(); - return *this; + if (CHECK) { + uint64 x = static_cast(m_value); + uint64 y = static_cast(other.m_value); + int64 r = static_cast(x + y); + if (m_value > 0 && other.m_value > 0 && r <= 0) throw overflow_exception(); + if (m_value < 0 && other.m_value < 0 && r >= 0) throw overflow_exception(); + m_value = r; } - if (CHECK && m_value < 0 && other.m_value < 0 && - (m_value < INT_MIN || other.m_value < INT_MIN)) { - rational r(r64(m_value) + r64(other.m_value)); - if (!r.is_int64()) { - throw overflow_exception(); - } - m_value = r.get_int64(); - return *this; + else { + m_value += other.m_value; } - m_value += other.m_value; return *this; } checked_int64& operator-=(checked_int64 const& other) { - if (CHECK && m_value > 0 && other.m_value < 0 && - (m_value > INT_MAX || other.m_value < INT_MIN)) { - rational r(r64(m_value) - r64(other.m_value)); - if (!r.is_int64()) { - throw overflow_exception(); - } - m_value = r.get_int64(); - return *this; + if (CHECK) { + uint64 x = static_cast(m_value); + uint64 y = static_cast(other.m_value); + int64 r = static_cast(x - y); + if (m_value > 0 && other.m_value < 0 && r <= 0) throw overflow_exception(); + if (m_value < 0 && other.m_value > 0 && r >= 0) throw overflow_exception(); + m_value = r; } - if (CHECK && m_value < 0 && other.m_value > 0 && - (m_value < INT_MIN || other.m_value > INT_MAX)) { - rational r(r64(m_value) - r64(other.m_value)); - if (!r.is_int64()) { - throw overflow_exception(); - } - m_value = r.get_int64(); - return *this; + else { + m_value -= other.m_value; } - m_value -= other.m_value; return *this; } checked_int64& operator*=(checked_int64 const& other) { if (CHECK) { - rational r(r64(m_value) * r64(other.m_value)); - if (!r.is_int64()) { - throw overflow_exception(); + if (INT_MIN < m_value && m_value <= INT_MAX && INT_MIN < other.m_value && other.m_value <= INT_MAX) { + m_value *= other.m_value; + } + // TBD: could be tuned by using known techniques or 128-bit arithmetic. + else { + rational r(r64(m_value) * r64(other.m_value)); + if (!r.is_int64()) { + throw overflow_exception(); + } + m_value = r.get_int64(); } - m_value = r.get_int64(); } else { m_value *= other.m_value; From 33e8113c9e623d5b9099dc16482487a4487b882c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 20 Nov 2017 16:51:17 -0800 Subject: [PATCH 041/263] adding instrumentation to debug #1233 Signed-off-by: Nikolaj Bjorner --- src/muz/pdr/pdr_context.cpp | 26 +++++------ src/smt/smt_conflict_resolution.cpp | 70 +++++++++++++++-------------- src/smt/smt_context.cpp | 48 +++++++------------- src/smt/smt_context.h | 18 ++++---- src/smt/smt_context_pp.cpp | 58 ++++++++++-------------- src/solver/solver_pool.cpp | 1 - 6 files changed, 94 insertions(+), 127 deletions(-) diff --git a/src/muz/pdr/pdr_context.cpp b/src/muz/pdr/pdr_context.cpp index 37d80e2d6..1d3232deb 100644 --- a/src/muz/pdr/pdr_context.cpp +++ b/src/muz/pdr/pdr_context.cpp @@ -149,30 +149,27 @@ namespace pdr { } datalog::rule const& pred_transformer::find_rule(model_core const& model) const { - obj_map::iterator it = m_tag2rule.begin(), end = m_tag2rule.end(); TRACE("pdr_verbose", datalog::rule_manager& rm = ctx.get_context().get_rule_manager(); - for (; it != end; ++it) { - expr* pred = it->m_key; + for (auto const& kv : m_tag2rule) { + expr* pred = kv.m_key; tout << mk_pp(pred, m) << ":\n"; - if (it->m_value) rm.display_smt2(*it->m_value, tout) << "\n"; + if (kv.m_value) rm.display_smt2(*kv.m_value, tout) << "\n"; } ); - it = m_tag2rule.begin(); if (m_tag2rule.size() == 1) { - return *it->m_value; + return *m_tag2rule.begin()->m_value; } expr_ref vl(m); - for (; it != end; ++it) { - expr* pred = it->m_key; + for (auto const& kv : m_tag2rule) { + expr* pred = kv.m_key; if (model.eval(to_app(pred)->get_decl(), vl) && m.is_true(vl)) { - return *it->m_value; + return *kv.m_value; } } - UNREACHABLE(); - return *((datalog::rule*)0); + throw default_exception("could not find rule"); } void pred_transformer::find_predecessors(datalog::rule const& r, ptr_vector& preds) const { @@ -201,7 +198,7 @@ namespace pdr { void pred_transformer::simplify_formulas(tactic& tac, expr_ref_vector& v) { goal_ref g(alloc(goal, m, false, false, false)); - for (unsigned j = 0; j < v.size(); ++j) g->assert_expr(v[j].get()); + for (expr* e : v) g->assert_expr(e); model_converter_ref mc; proof_converter_ref pc; expr_dependency_ref core(m); @@ -216,9 +213,8 @@ namespace pdr { void pred_transformer::simplify_formulas() { tactic_ref us = mk_unit_subsumption_tactic(m); simplify_formulas(*us, m_invariants); - for (unsigned i = 0; i < m_levels.size(); ++i) { - simplify_formulas(*us, m_levels[i]); - } + for (auto & fmls : m_levels) + simplify_formulas(*us, fmls); } expr_ref pred_transformer::get_formulas(unsigned level, bool add_axioms) { diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index 80168df18..6188c8b1a 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -257,10 +257,8 @@ namespace smt { literal_vector & antecedents = m_tmp_literal_vector; antecedents.reset(); justification2literals(js, antecedents); - literal_vector::iterator it = antecedents.begin(); - literal_vector::iterator end = antecedents.end(); - for(; it != end; ++it) - r = std::max(r, m_ctx.get_assign_level(*it)); + for (literal lit : antecedents) + r = std::max(r, m_ctx.get_assign_level(lit)); return r; } @@ -335,6 +333,7 @@ namespace smt { } if (lvl == m_conflict_lvl) { + TRACE("conflict", m_ctx.display_literal(tout << "marking:", antecedent) << "\n";); num_marks++; } else { @@ -486,6 +485,20 @@ namespace smt { } bool conflict_resolution::resolve(b_justification conflict, literal not_l) { + +#if 0 + // for debugging #1233 + if (not_l == to_literal(22267)) { + std::cout << not_l << "\n"; + enable_trace("conflict"); + enable_trace("conflict_verbose"); + TRACE("conflict", + unsigned idx = 0; + for (literal lit : m_assigned_literals) { + m_ctx.display_literal(tout << (idx++) << ":", lit); tout << "\n"; + }); + } +#endif b_justification js; literal consequent; @@ -514,7 +527,7 @@ namespace smt { get_manager().trace_stream() << "\n"; } - TRACE("conflict", tout << "processing consequent: "; m_ctx.display_literal_verbose(tout, consequent); tout << "\n"; + TRACE("conflict", tout << "processing consequent: " << idx << " "; m_ctx.display_literal_verbose(tout, consequent); tout << "\n"; tout << "num_marks: " << num_marks << ", js kind: " << js.get_kind() << " level: " << m_ctx.get_assign_level(consequent) << "\n"; ); SASSERT(js != null_b_justification); @@ -566,8 +579,10 @@ namespace smt { if (m_ctx.is_marked(l.var())) break; CTRACE("conflict", m_ctx.get_assign_level(l) != m_conflict_lvl && m_ctx.get_assign_level(l) != m_ctx.get_base_level(), - tout << "assign_level(l): " << m_ctx.get_assign_level(l) << ", conflict_lvl: " << m_conflict_lvl << ", l: "; m_ctx.display_literal_verbose(tout, l); - tout << "\n";); + tout << "assign_level(l): " << m_ctx.get_assign_level(l) << ", conflict_lvl: "; + tout << m_conflict_lvl << ", l: "; m_ctx.display_literal_verbose(tout, l); + tout << "\n"; + tout << "num marks: " << num_marks << "\n";); SASSERT(m_ctx.get_assign_level(l) == m_conflict_lvl || // it may also be an (out-of-order) asserted literal m_ctx.get_assign_level(l) == m_ctx.get_base_level()); @@ -606,10 +621,8 @@ namespace smt { */ level_approx_set conflict_resolution::get_lemma_approx_level_set() { level_approx_set result; - literal_vector::const_iterator it = m_lemma.begin(); - literal_vector::const_iterator end = m_lemma.end(); - for(; it != end; ++it) - result.insert(m_ctx.get_assign_level(*it)); + for (literal l : m_lemma) + result.insert(m_ctx.get_assign_level(l)); return result; } @@ -660,10 +673,8 @@ namespace smt { // The method unmark_justifications must be invoked to reset these caches. // Remark: The method reset_unmark_and_justifications invokes unmark_justifications. justification2literals_core(js, antecedents); - literal_vector::iterator it = antecedents.begin(); - literal_vector::iterator end = antecedents.end(); - for(; it != end; ++it) - if (!process_antecedent_for_minimization(*it)) + for (literal l : antecedents) + if (!process_antecedent_for_minimization(l)) return false; return true; } @@ -1063,10 +1074,8 @@ namespace smt { m_eq2proof.reset(); m_lit2proof.reset(); m_js2proof.reset(); - literal_vector::iterator it = m_lemma.begin(); - literal_vector::iterator end = m_lemma.end(); - for (; it != end; ++it) - m_ctx.set_mark((*it).var()); + for (literal lit : m_lemma) + m_ctx.set_mark(lit.var()); } bool conflict_resolution::visit_b_justification(literal l, b_justification js) { @@ -1246,12 +1255,9 @@ namespace smt { SASSERT(conflict.get_kind() != b_justification::BIN_CLAUSE); SASSERT(conflict.get_kind() != b_justification::AXIOM); SASSERT(not_l == null_literal || conflict.get_kind() == b_justification::JUSTIFICATION); - TRACE("mk_conflict_proof", tout << "lemma literals: "; - literal_vector::iterator it = m_lemma.begin(); - literal_vector::iterator end = m_lemma.end(); - for (; it != end; ++it) { - m_ctx.display_literal(tout, *it); - tout << " "; + TRACE("mk_conflict_proof", tout << "lemma literals:"; + for (literal lit : m_lemma) { + m_ctx.display_literal(tout << " ", lit); } tout << "\n";); init_mk_proof(); @@ -1328,12 +1334,10 @@ namespace smt { pr = m_manager.mk_unit_resolution(2, prs); } expr_ref_buffer lits(m_manager); - literal_vector::iterator it = m_lemma.begin(); - literal_vector::iterator end = m_lemma.end(); - for (; it != end; ++it) { - m_ctx.unset_mark((*it).var()); + for (literal lit : m_lemma) { + m_ctx.unset_mark(lit.var()); expr_ref l_expr(m_manager); - m_ctx.literal2expr(*it, l_expr); + m_ctx.literal2expr(lit, l_expr); lits.push_back(l_expr); } expr * fact = 0; @@ -1369,10 +1373,8 @@ namespace smt { literal_vector & antecedents = m_tmp_literal_vector; antecedents.reset(); justification2literals_core(js, antecedents); - literal_vector::iterator it = antecedents.begin(); - literal_vector::iterator end = antecedents.end(); - for(; it != end; ++it) - process_antecedent_for_unsat_core(*it); + for (literal lit : antecedents) + process_antecedent_for_unsat_core(lit); } void conflict_resolution::mk_unsat_core(b_justification conflict, literal not_l) { diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 2e65fddc9..30979fc4b 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -1615,11 +1615,9 @@ namespace smt { \brief Return set of assigned literals as expressions. */ void context::get_assignments(expr_ref_vector& assignments) { - literal_vector::const_iterator it = m_assigned_literals.begin(); - literal_vector::const_iterator end = m_assigned_literals.end(); - for (; it != end; ++it) { + for (literal lit : m_assigned_literals) { expr_ref e(m_manager); - literal2expr(*it, e); + literal2expr(lit, e); assignments.push_back(e); } } @@ -1694,10 +1692,8 @@ namespace smt { } bool context::propagate_theories() { - ptr_vector::iterator it = m_theory_set.begin(); - ptr_vector::iterator end = m_theory_set.end(); - for (; it != end; ++it) { - (*it)->propagate(); + for (theory * t : m_theory_set) { + t->propagate(); if (inconsistent()) return false; } @@ -1733,10 +1729,8 @@ namespace smt { } bool context::can_theories_propagate() const { - ptr_vector::const_iterator it = m_theory_set.begin(); - ptr_vector::const_iterator end = m_theory_set.end(); - for (; it != end; ++it) { - if ((*it)->can_propagate()) { + for (theory* t : m_theory_set) { + if (t->can_propagate()) { return true; } } @@ -1821,7 +1815,7 @@ namespace smt { } void context::rescale_bool_var_activity() { - TRACE("case_split", tout << "rescale\n";); + TRACE("case_split", tout << "rescale\n";); svector::iterator it = m_activity.begin(); svector::iterator end = m_activity.end(); for (; it != end; ++it) @@ -1968,10 +1962,8 @@ namespace smt { m_case_split_queue->push_scope(); m_asserted_formulas.push_scope(); - ptr_vector::iterator it = m_theory_set.begin(); - ptr_vector::iterator end = m_theory_set.end(); - for (; it != end; ++it) - (*it)->push_scope_eh(); + for (theory* t : m_theory_set) + t->push_scope_eh(); CASSERT("context", check_invariant()); } @@ -2146,10 +2138,7 @@ namespace smt { } for (unsigned i = new_scope_lvl; i <= lim; i++) { clause_vector & v = m_clauses_to_reinit[i]; - clause_vector::iterator it = v.begin(); - clause_vector::iterator end = v.end(); - for (; it != end; ++it) { - clause * cls = *it; + for (clause* cls : v) { cache_generation(cls, new_scope_lvl); } } @@ -2246,10 +2235,7 @@ namespace smt { } for (unsigned i = m_scope_lvl+1; i <= lim; i++) { clause_vector & v = m_clauses_to_reinit[i]; - clause_vector::iterator it = v.begin(); - clause_vector::iterator end = v.end(); - for (; it != end; ++it) { - clause * cls = *it; + for (clause* cls : v) { if (cls->deleted()) { cls->release_atoms(m_manager); cls->m_reinit = false; @@ -2922,10 +2908,8 @@ namespace smt { TRACE("flush", tout << "m_scope_lvl: " << m_scope_lvl << "\n";); m_relevancy_propagator = 0; m_model_generator->reset(); - ptr_vector::iterator it = m_theory_set.begin(); - ptr_vector::iterator end = m_theory_set.end(); - for (; it != end; ++it) - (*it)->flush_eh(); + for (theory* t : m_theory_set) + t->flush_eh(); undo_trail_stack(0); m_qmanager = 0; del_clauses(m_aux_clauses, 0); @@ -3183,10 +3167,8 @@ namespace smt { } void context::reset_assumptions() { - literal_vector::iterator it = m_assumptions.begin(); - literal_vector::iterator end = m_assumptions.end(); - for (; it != end; ++it) - get_bdata(it->var()).m_assumption = false; + for (literal lit : m_assumptions) + get_bdata(lit.var()).m_assumption = false; m_assumptions.reset(); } diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index c6cca2c43..d55e36f44 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -1235,24 +1235,24 @@ namespace smt { void display_asserted_formulas(std::ostream & out) const; - void display_literal(std::ostream & out, literal l) const; + std::ostream& display_literal(std::ostream & out, literal l) const; void display_detailed_literal(std::ostream & out, literal l) const { l.display(out, m_manager, m_bool_var2expr.c_ptr()); } void display_literal_info(std::ostream & out, literal l) const; - void display_literals(std::ostream & out, unsigned num_lits, literal const * lits) const; + std::ostream& display_literals(std::ostream & out, unsigned num_lits, literal const * lits) const; - void display_literals(std::ostream & out, literal_vector const& lits) const { - display_literals(out, lits.size(), lits.c_ptr()); + std::ostream& display_literals(std::ostream & out, literal_vector const& lits) const { + return display_literals(out, lits.size(), lits.c_ptr()); } - void display_literal_verbose(std::ostream & out, literal lit) const; + std::ostream& display_literal_verbose(std::ostream & out, literal lit) const; - void display_literals_verbose(std::ostream & out, unsigned num_lits, literal const * lits) const; - - void display_literals_verbose(std::ostream & out, literal_vector const& lits) const { - display_literals_verbose(out, lits.size(), lits.c_ptr()); + std::ostream& display_literals_verbose(std::ostream & out, unsigned num_lits, literal const * lits) const; + + std::ostream& display_literals_verbose(std::ostream & out, literal_vector const& lits) const { + return display_literals_verbose(out, lits.size(), lits.c_ptr()); } void display_watch_list(std::ostream & out, literal l) const; diff --git a/src/smt/smt_context_pp.cpp b/src/smt/smt_context_pp.cpp index 6d66368ff..f2fb1084b 100644 --- a/src/smt/smt_context_pp.cpp +++ b/src/smt/smt_context_pp.cpp @@ -71,11 +71,9 @@ namespace smt { case NUM_CONFLICTS: r = "max-conflicts-reached"; break; case THEORY: { r = "(incomplete (theory"; - ptr_vector::const_iterator it = m_incomplete_theories.begin(); - ptr_vector::const_iterator end = m_incomplete_theories.end(); - for (; it != end; ++it) { + for (theory* t : m_incomplete_theories) { r += " "; - r += (*it)->get_name(); + r += t->get_name(); } r += "))"; break; @@ -91,20 +89,20 @@ namespace smt { m_asserted_formulas.display_ll(out, get_pp_visited()); } - void context::display_literal(std::ostream & out, literal l) const { - l.display_compact(out, m_bool_var2expr.c_ptr()); + std::ostream& context::display_literal(std::ostream & out, literal l) const { + l.display_compact(out, m_bool_var2expr.c_ptr()); return out; } - void context::display_literals(std::ostream & out, unsigned num_lits, literal const * lits) const { - display_compact(out, num_lits, lits, m_bool_var2expr.c_ptr()); + std::ostream& context::display_literals(std::ostream & out, unsigned num_lits, literal const * lits) const { + display_compact(out, num_lits, lits, m_bool_var2expr.c_ptr()); return out; } - void context::display_literal_verbose(std::ostream & out, literal lit) const { - display_literals_verbose(out, 1, &lit); + std::ostream& context::display_literal_verbose(std::ostream & out, literal lit) const { + return display_literals_verbose(out, 1, &lit); } - void context::display_literals_verbose(std::ostream & out, unsigned num_lits, literal const * lits) const { - display_verbose(out, m_manager, num_lits, lits, m_bool_var2expr.c_ptr(), "\n"); + std::ostream& context::display_literals_verbose(std::ostream & out, unsigned num_lits, literal const * lits) const { + display_verbose(out, m_manager, num_lits, lits, m_bool_var2expr.c_ptr(), "\n"); return out; } void context::display_literal_info(std::ostream & out, literal l) const { @@ -136,10 +134,8 @@ namespace smt { } void context::display_enode_defs(std::ostream & out) const { - ptr_vector::const_iterator it = m_enodes.begin(); - ptr_vector::const_iterator end = m_enodes.end(); - for (; it != end; ++it) { - expr * n = (*it)->get_owner(); + for (enode * x : m_enodes) { + expr * n = x->get_owner(); ast_def_ll_pp(out, m_manager, n, get_pp_visited(), true, false); } } @@ -169,10 +165,8 @@ namespace smt { } void context::display_clauses(std::ostream & out, ptr_vector const & v) const { - ptr_vector::const_iterator it = v.begin(); - ptr_vector::const_iterator end = v.end(); - for (; it != end; ++it) { - display_clause(out, *it); + for (clause* cp : v) { + display_clause(out, cp); out << "\n"; } } @@ -207,12 +201,10 @@ namespace smt { void context::display_assignment(std::ostream & out) const { if (!m_assigned_literals.empty()) { out << "current assignment:\n"; - literal_vector::const_iterator it = m_assigned_literals.begin(); - literal_vector::const_iterator end = m_assigned_literals.end(); - for (; it != end; ++it) { - display_literal(out, *it); + for (literal lit : m_assigned_literals) { + display_literal(out, lit); out << ": "; - display_verbose(out, m_manager, 1, &*it, m_bool_var2expr.c_ptr()); + display_verbose(out, m_manager, 1, &lit, m_bool_var2expr.c_ptr()); out << "\n"; } } @@ -223,11 +215,9 @@ namespace smt { pp.set_benchmark_name("lemma"); pp.set_status("unknown"); pp.set_logic(logic); - literal_vector::const_iterator it = m_assigned_literals.begin(); - literal_vector::const_iterator end = m_assigned_literals.end(); - for (; it != end; ++it) { + for (literal lit : m_assigned_literals) { expr_ref n(m_manager); - literal2expr(*it, n); + literal2expr(lit, n); pp.add_assumption(n); } pp.display_smt2(out, m_manager.mk_true()); @@ -235,11 +225,9 @@ namespace smt { void context::display_eqc(std::ostream & out) const { bool first = true; - ptr_vector::const_iterator it = m_enodes.begin(); - ptr_vector::const_iterator end = m_enodes.end(); - for (; it != end; ++it) { - expr * n = (*it)->get_owner(); - expr * r = (*it)->get_root()->get_owner(); + for (enode * x : m_enodes) { + expr * n = x->get_owner(); + expr * r = x->get_root()->get_owner(); if (n != r) { if (first) { out << "equivalence classes:\n"; @@ -610,7 +598,7 @@ namespace smt { break; } case b_justification::JUSTIFICATION: { - out << "justification "; + out << "justification " << j.get_justification()->get_from_theory() << ": "; literal_vector lits; const_cast(*m_conflict_resolution).justification2literals(j.get_justification(), lits); display_literals(out, lits.size(), lits.c_ptr()); diff --git a/src/solver/solver_pool.cpp b/src/solver/solver_pool.cpp index c6c85ec29..c8899e365 100644 --- a/src/solver/solver_pool.cpp +++ b/src/solver/solver_pool.cpp @@ -143,7 +143,6 @@ public: } out << ")\n"; m_base->display(out, num_assumptions, assumptions); - bool first = true; out << "(check-sat"; for (unsigned i = 0; i < num_assumptions; ++i) { out << " " << mk_pp(assumptions[i], m); From c5f231acdfab2a8032201fb213d169f818ac0cef Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 21 Nov 2017 08:16:41 -0800 Subject: [PATCH 042/263] debugging #1233 Signed-off-by: Nikolaj Bjorner --- src/smt/smt_conflict_resolution.cpp | 38 +++++++++-------------------- src/smt/smt_context.cpp | 9 ++++++- src/smt/smt_context.h | 2 +- src/smt/theory_seq.cpp | 23 +++++++++++++++++ 4 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index 6188c8b1a..02c38a2bd 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -313,8 +313,8 @@ namespace smt { SASSERT(var < static_cast(m_ctx.get_num_bool_vars())); TRACE("conflict", tout << "processing antecedent (level " << lvl << "):"; m_ctx.display_literal(tout, antecedent); - m_ctx.display_detailed_literal(tout << " ", antecedent); tout << "\n";); - + m_ctx.display_detailed_literal(tout << " ", antecedent) << "\n";); + if (!m_ctx.is_marked(var) && lvl > m_ctx.get_base_level()) { m_ctx.set_mark(var); m_ctx.inc_bvar_activity(var); @@ -328,8 +328,7 @@ namespace smt { if (get_manager().has_trace_stream()) { get_manager().trace_stream() << "[resolve-lit] " << m_conflict_lvl - lvl << " "; - m_ctx.display_literal(get_manager().trace_stream(), ~antecedent); - get_manager().trace_stream() << "\n"; + m_ctx.display_literal(get_manager().trace_stream(), ~antecedent) << "\n"; } if (lvl == m_conflict_lvl) { @@ -391,7 +390,7 @@ namespace smt { << " search_lvl: " << m_ctx.get_search_level() << "\n"; tout << "js.kind: " << js.get_kind() << "\n"; tout << "consequent: " << consequent << ": "; - m_ctx.display_literal_verbose(tout, consequent); tout << "\n"; + m_ctx.display_literal_verbose(tout, consequent) << "\n"; m_ctx.display(tout, js); tout << "\n"; ); @@ -430,32 +429,16 @@ namespace smt { void conflict_resolution::finalize_resolve(b_justification conflict, literal not_l) { unmark_justifications(0); - TRACE("conflict", - tout << "before minimization:\n"; - m_ctx.display_literals(tout, m_lemma); - tout << "\n";); + TRACE("conflict", m_ctx.display_literals(tout << "before minimization:\n", m_lemma) << "\n";); - TRACE("conflict_verbose", - tout << "before minimization:\n"; - m_ctx.display_literals_verbose(tout, m_lemma); - tout << "\n";); + TRACE("conflict_verbose",m_ctx.display_literals_verbose(tout << "before minimization:\n", m_lemma) << "\n";); if (m_params.m_minimize_lemmas) minimize_lemma(); - TRACE("conflict", - tout << "after minimization:\n"; - m_ctx.display_literals(tout, m_lemma); - tout << "\n";); - - TRACE("conflict_verbose", - tout << "after minimization:\n"; - m_ctx.display_literals_verbose(tout, m_lemma); - tout << "\n";); - - TRACE("conflict_bug", - m_ctx.display_literals_verbose(tout, m_lemma); - tout << "\n";); + TRACE("conflict", m_ctx.display_literals(tout << "after minimization:\n", m_lemma) << "\n";); + TRACE("conflict_verbose", m_ctx.display_literals_verbose(tout << "after minimization:\n", m_lemma) << "\n";); + TRACE("conflict_bug", m_ctx.display_literals_verbose(tout, m_lemma) << "\n";); literal_vector::iterator it = m_lemma.begin(); literal_vector::iterator end = m_lemma.end(); @@ -527,7 +510,8 @@ namespace smt { get_manager().trace_stream() << "\n"; } - TRACE("conflict", tout << "processing consequent: " << idx << " "; m_ctx.display_literal_verbose(tout, consequent); tout << "\n"; + TRACE("conflict", tout << "processing consequent id: " << idx << " lit: " << consequent << " "; m_ctx.display_literal(tout, consequent); + m_ctx.display_literal_verbose(tout, consequent) << "\n"; tout << "num_marks: " << num_marks << ", js kind: " << js.get_kind() << " level: " << m_ctx.get_assign_level(consequent) << "\n"; ); SASSERT(js != null_b_justification); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 30979fc4b..8819e37b6 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -287,6 +287,13 @@ namespace smt { void context::assign_core(literal l, b_justification j, bool decision) { +#if 0 + // for debugging #1233 + if (l.var() == 11133 && l.sign()) { + std::cout << l << "\n"; + UNREACHABLE(); + } +#endif TRACE("assign_core", tout << (decision?"decision: ":"propagating: ") << l << " "; display_literal_verbose(tout, l); tout << " level: " << m_scope_lvl << "\n"; display(tout, j);); @@ -902,7 +909,7 @@ namespace smt { } /** - \brief Propabate the boolean assignment when two equivalence classes are merged. + \brief Propagate the boolean assignment when two equivalence classes are merged. */ void context::propagate_bool_enode_assignment(enode * r1, enode * r2, enode * n1, enode * n2) { SASSERT(n1->is_bool()); diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index d55e36f44..e50c03c8a 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -1237,7 +1237,7 @@ namespace smt { std::ostream& display_literal(std::ostream & out, literal l) const; - void display_detailed_literal(std::ostream & out, literal l) const { l.display(out, m_manager, m_bool_var2expr.c_ptr()); } + std::ostream& display_detailed_literal(std::ostream & out, literal l) const { l.display(out, m_manager, m_bool_var2expr.c_ptr()); return out; } void display_literal_info(std::ostream & out, literal l) const; diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index d55484384..caba4e92e 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -1298,6 +1298,21 @@ void theory_seq::propagate_eq(dependency* dep, enode* n1, enode* n2) { display_deps(tout, dep); ); +#if 0 + //std::cout << mk_pp(n1->get_owner(), m) << " = " << mk_pp(n2->get_owner(), m) << "\n"; + //display_deps(std::cout, dep); + + for (literal lit : lits) { + SASSERT(ctx.get_assignment(lit) == l_true); + } + for (enode_pair p : eqs) { + if (p.first->get_root() != p.second->get_root()) { + std::cout << mk_pp(p.first->get_owner(), m) << " " << mk_pp(p.second->get_owner(), m) << "\n"; + } + SASSERT(p.first->get_root() == p.second->get_root()); + } +#endif + justification* js = ctx.mk_justification( ext_theory_eq_propagation_justification( get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), n1, n2)); @@ -3027,6 +3042,8 @@ expr_ref theory_seq::expand1(expr* e0, dependency*& eqs) { enode* n1 = ctx.get_enode(num); enode* n2 = ctx.get_enode(e1); res = m_util.str.mk_string(symbol(val.to_string().c_str())); +#if 1 + // TBD remove this: using roots is unsound for propagation. if (n1->get_root() == n2->get_root()) { result = res; deps = m_dm.mk_join(deps, m_dm.mk_leaf(assumption(n1, n2))); @@ -3037,6 +3054,12 @@ expr_ref theory_seq::expand1(expr* e0, dependency*& eqs) { add_axiom(mk_eq(num, e1, false), ~mk_eq(e, res, false)); result = e; } +#else + TRACE("seq", tout << "add axiom\n";); + add_axiom(~mk_eq(num, e1, false), mk_eq(e, res, false)); + add_axiom(mk_eq(num, e1, false), ~mk_eq(e, res, false)); + result = e; +#endif } else { result = e; From d520557ad95bba6a084b876b98d7f4327885c286 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 21 Nov 2017 11:52:15 -0800 Subject: [PATCH 043/263] fix #1233 Signed-off-by: Nikolaj Bjorner --- src/smt/smt_b_justification.h | 10 +++++ src/smt/smt_conflict_resolution.cpp | 14 ------- src/smt/smt_context.cpp | 8 ---- src/smt/smt_context_pp.cpp | 2 +- src/smt/theory_seq.cpp | 63 +++++++++++++---------------- src/smt/theory_seq.h | 2 +- 6 files changed, 41 insertions(+), 58 deletions(-) diff --git a/src/smt/smt_b_justification.h b/src/smt/smt_b_justification.h index 700c41807..55669a7ef 100644 --- a/src/smt/smt_b_justification.h +++ b/src/smt/smt_b_justification.h @@ -93,6 +93,16 @@ namespace smt { const b_justification null_b_justification(static_cast(0)); + inline std::ostream& operator<<(std::ostream& out, b_justification::kind k) { + switch (k) { + case b_justification::CLAUSE: return out << "clause"; + case b_justification::BIN_CLAUSE: return out << "bin_clause"; + case b_justification::AXIOM: return out << "axiom"; + case b_justification::JUSTIFICATION: return out << "theory"; + } + return out; + } + typedef std::pair justified_literal; }; diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index 02c38a2bd..a6432c960 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -468,20 +468,6 @@ namespace smt { } bool conflict_resolution::resolve(b_justification conflict, literal not_l) { - -#if 0 - // for debugging #1233 - if (not_l == to_literal(22267)) { - std::cout << not_l << "\n"; - enable_trace("conflict"); - enable_trace("conflict_verbose"); - TRACE("conflict", - unsigned idx = 0; - for (literal lit : m_assigned_literals) { - m_ctx.display_literal(tout << (idx++) << ":", lit); tout << "\n"; - }); - } -#endif b_justification js; literal consequent; diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 8819e37b6..62a569e2b 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -285,15 +285,7 @@ namespace smt { d.set_justification(j); } - void context::assign_core(literal l, b_justification j, bool decision) { -#if 0 - // for debugging #1233 - if (l.var() == 11133 && l.sign()) { - std::cout << l << "\n"; - UNREACHABLE(); - } -#endif TRACE("assign_core", tout << (decision?"decision: ":"propagating: ") << l << " "; display_literal_verbose(tout, l); tout << " level: " << m_scope_lvl << "\n"; display(tout, j);); diff --git a/src/smt/smt_context_pp.cpp b/src/smt/smt_context_pp.cpp index f2fb1084b..f5ba52128 100644 --- a/src/smt/smt_context_pp.cpp +++ b/src/smt/smt_context_pp.cpp @@ -601,7 +601,7 @@ namespace smt { out << "justification " << j.get_justification()->get_from_theory() << ": "; literal_vector lits; const_cast(*m_conflict_resolution).justification2literals(j.get_justification(), lits); - display_literals(out, lits.size(), lits.c_ptr()); + display_literals(out, lits); break; } default: diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index caba4e92e..6f7cf1b5e 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -1228,18 +1228,25 @@ bool theory_seq::is_solved() { return true; } -void theory_seq::linearize(dependency* dep, enode_pair_vector& eqs, literal_vector& lits) const { +/** + \brief while extracting dependency literals ensure that they have all been asserted on the context. +*/ +bool theory_seq::linearize(dependency* dep, enode_pair_vector& eqs, literal_vector& lits) const { + context & ctx = get_context(); + DEBUG_CODE(for (literal lit : lits) SASSERT(ctx.get_assignment(lit) == l_true); ); + bool asserted = true; svector assumptions; const_cast(m_dm).linearize(dep, assumptions); - for (unsigned i = 0; i < assumptions.size(); ++i) { - assumption const& a = assumptions[i]; + for (assumption const& a : assumptions) { if (a.lit != null_literal) { lits.push_back(a.lit); + asserted &= ctx.get_assignment(a.lit) == l_true; } if (a.n1 != 0) { eqs.push_back(enode_pair(a.n1, a.n2)); } } + return asserted; } @@ -1257,7 +1264,8 @@ void theory_seq::propagate_lit(dependency* dep, unsigned n, literal const* _lits ctx.mark_as_relevant(lit); enode_pair_vector eqs; - linearize(dep, eqs, lits); + if (!linearize(dep, eqs, lits)) + return; TRACE("seq", tout << "assert:"; ctx.display_detailed_literal(tout, lit); @@ -1276,7 +1284,8 @@ void theory_seq::set_conflict(dependency* dep, literal_vector const& _lits) { context& ctx = get_context(); enode_pair_vector eqs; literal_vector lits(_lits); - linearize(dep, eqs, lits); + if (!linearize(dep, eqs, lits)) + return; TRACE("seq", display_deps(tout << "assert conflict:", lits, eqs);); m_new_propagation = true; ctx.set_conflict( @@ -1292,27 +1301,13 @@ void theory_seq::propagate_eq(dependency* dep, enode* n1, enode* n2) { context& ctx = get_context(); literal_vector lits; enode_pair_vector eqs; - linearize(dep, eqs, lits); + if (!linearize(dep, eqs, lits)) + return; TRACE("seq", tout << "assert: " << mk_pp(n1->get_owner(), m) << " = " << mk_pp(n2->get_owner(), m) << " <-\n"; display_deps(tout, dep); ); -#if 0 - //std::cout << mk_pp(n1->get_owner(), m) << " = " << mk_pp(n2->get_owner(), m) << "\n"; - //display_deps(std::cout, dep); - - for (literal lit : lits) { - SASSERT(ctx.get_assignment(lit) == l_true); - } - for (enode_pair p : eqs) { - if (p.first->get_root() != p.second->get_root()) { - std::cout << mk_pp(p.first->get_owner(), m) << " " << mk_pp(p.second->get_owner(), m) << "\n"; - } - SASSERT(p.first->get_root() == p.second->get_root()); - } -#endif - justification* js = ctx.mk_justification( ext_theory_eq_propagation_justification( get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), n1, n2)); @@ -1858,12 +1853,12 @@ bool theory_seq::solve_ne(unsigned idx) { ne const& n = m_nqs[idx]; unsigned num_undef_lits = 0; - for (unsigned i = 0; i < n.lits().size(); ++i) { - switch (ctx.get_assignment(n.lits(i))) { + for (literal lit : n.lits()) { + switch (ctx.get_assignment(lit)) { case l_false: TRACE("seq", display_disequation(tout << "has false literal\n", n); - ctx.display_literal_verbose(tout, n.lits(i)); - tout << "\n" << n.lits(i) << " " << ctx.is_relevant(n.lits(i)) << "\n"; + ctx.display_literal_verbose(tout, lit); + tout << "\n" << lit << " " << ctx.is_relevant(lit) << "\n"; ); return true; case l_true: @@ -1967,8 +1962,7 @@ bool theory_seq::solve_ne(unsigned idx) { if (num_undef_lits == 1 && new_ls.empty()) { literal_vector lits; literal undef_lit = null_literal; - for (unsigned i = 0; i < new_lits.size(); ++i) { - literal lit = new_lits[i]; + for (literal lit : new_lits) { switch (ctx.get_assignment(lit)) { case l_true: lits.push_back(lit); @@ -2574,8 +2568,8 @@ void theory_seq::display_disequations(std::ostream& out) const { } void theory_seq::display_disequation(std::ostream& out, ne const& e) const { - for (unsigned j = 0; j < e.lits().size(); ++j) { - out << e.lits(j) << " "; + for (literal lit : e.lits()) { + out << lit << " "; } if (e.lits().size() > 0) { out << "\n"; @@ -3820,11 +3814,11 @@ literal theory_seq::mk_eq_empty(expr* _e, bool phase) { } expr_ref_vector concats(m); m_util.str.get_concat(e, concats); - for (unsigned i = 0; i < concats.size(); ++i) { - if (m_util.str.is_unit(concats[i].get())) { + for (expr* c : concats) { + if (m_util.str.is_unit(c)) { return false_literal; } - if (m_util.str.is_string(concats[i].get(), s) && s.length() > 0) { + if (m_util.str.is_string(c, s) && s.length() > 0) { return false_literal; } } @@ -3895,8 +3889,9 @@ void theory_seq::propagate_eq(dependency* deps, literal_vector const& _lits, exp literal_vector lits(_lits); enode_pair_vector eqs; - linearize(deps, eqs, lits); - + if (!linearize(deps, eqs, lits)) + return; + if (add_to_eqs) { deps = mk_join(deps, _lits); new_eq_eh(deps, n1, n2); diff --git a/src/smt/theory_seq.h b/src/smt/theory_seq.h index 2ad257fd7..e08c0588e 100644 --- a/src/smt/theory_seq.h +++ b/src/smt/theory_seq.h @@ -431,7 +431,7 @@ namespace smt { bool explain_empty(expr_ref_vector& es, dependency*& dep); // asserting consequences - void linearize(dependency* dep, enode_pair_vector& eqs, literal_vector& lits) const; + bool linearize(dependency* dep, enode_pair_vector& eqs, literal_vector& lits) const; void propagate_lit(dependency* dep, literal lit) { propagate_lit(dep, 0, 0, lit); } void propagate_lit(dependency* dep, unsigned n, literal const* lits, literal lit); void propagate_eq(dependency* dep, enode* n1, enode* n2); From 18200f55edf14e5360c9095736710ae689032f6d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 21 Nov 2017 15:14:49 -0800 Subject: [PATCH 044/263] add bit-vector over/underflow checks to Python API, #1364 Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index a247d0a3a..5ccab92dd 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -3993,6 +3993,65 @@ def BVRedOr(a): _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression") return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx) +def BVAddNoOverflow(a, b, signed): + """A predicate the determines that bit-vector addition does not overflow""" + if __debug__: + _z3_assert(is_bv(a), "Arguments should be bit-vectors") + _z3_assert(is_bv(b), "Arguments should be bit-vectors") + return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx) + +def BVAddNoUnderflow(a, b, signed): + """A predicate the determines that signed bit-vector addition does not underflow""" + if __debug__: + _z3_assert(is_bv(a), "Arguments should be bit-vectors") + _z3_assert(is_bv(b), "Arguments should be bit-vectors") + return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx) + +def BVSubNoOverflow(a, b): + """A predicate the determines that bit-vector subtraction does not overflow""" + if __debug__: + _z3_assert(is_bv(a), "Arguments should be bit-vectors") + _z3_assert(is_bv(b), "Arguments should be bit-vectors") + return BoolRef(Z3_mk_bvsub_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx) + + +def BVSubNoUnderflow(a, b, signed): + """A predicate the determines that bit-vector subtraction does not underflow""" + if __debug__: + _z3_assert(is_bv(a), "Arguments should be bit-vectors") + _z3_assert(is_bv(b), "Arguments should be bit-vectors") + return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx) + +def BVSDivNoOverflow(a, b): + """A predicate the determines that bit-vector signed division does not overflow""" + if __debug__: + _z3_assert(is_bv(a), "Arguments should be bit-vectors") + _z3_assert(is_bv(b), "Arguments should be bit-vectors") + return BoolRef(Z3_mk_bvsdiv_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx) + +def BVSNegNoOverflow(a): + """A predicate the determines that bit-vector unary negation does not overflow""" + if __debug__: + _z3_assert(is_bv(a), "Arguments should be bit-vectors") + return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx) + +def BVMulNoOverflow(a, b, signed): + """A predicate the determines that bit-vector multiplication does not overflow""" + if __debug__: + _z3_assert(is_bv(a), "Arguments should be bit-vectors") + _z3_assert(is_bv(b), "Arguments should be bit-vectors") + return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx) + + +def BVMulNoUnderflow(a, b, signed): + """A predicate the determines that bit-vector signed multiplication does not underflow""" + if __debug__: + _z3_assert(is_bv(a), "Arguments should be bit-vectors") + _z3_assert(is_bv(b), "Arguments should be bit-vectors") + return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx) + + + ######################################### # # Arrays From 2597ac67568f6709351d5fd2324e1b2a209b0b06 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 21 Nov 2017 15:44:15 -0800 Subject: [PATCH 045/263] fix argument validation to new overflow/underflow functions #1364 Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 5ccab92dd..17e5bbff8 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -3995,59 +3995,52 @@ def BVRedOr(a): def BVAddNoOverflow(a, b, signed): """A predicate the determines that bit-vector addition does not overflow""" - if __debug__: - _z3_assert(is_bv(a), "Arguments should be bit-vectors") - _z3_assert(is_bv(b), "Arguments should be bit-vectors") + _check_bv_args(a, b) + a, b = _coerce_exprs(a, b) return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx) def BVAddNoUnderflow(a, b, signed): """A predicate the determines that signed bit-vector addition does not underflow""" - if __debug__: - _z3_assert(is_bv(a), "Arguments should be bit-vectors") - _z3_assert(is_bv(b), "Arguments should be bit-vectors") + _check_bv_args(a, b) + a, b = _coerce_exprs(a, b) return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx) def BVSubNoOverflow(a, b): """A predicate the determines that bit-vector subtraction does not overflow""" - if __debug__: - _z3_assert(is_bv(a), "Arguments should be bit-vectors") - _z3_assert(is_bv(b), "Arguments should be bit-vectors") + _check_bv_args(a, b) + a, b = _coerce_exprs(a, b) return BoolRef(Z3_mk_bvsub_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx) def BVSubNoUnderflow(a, b, signed): """A predicate the determines that bit-vector subtraction does not underflow""" - if __debug__: - _z3_assert(is_bv(a), "Arguments should be bit-vectors") - _z3_assert(is_bv(b), "Arguments should be bit-vectors") + _check_bv_args(a, b) + a, b = _coerce_exprs(a, b) return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx) def BVSDivNoOverflow(a, b): """A predicate the determines that bit-vector signed division does not overflow""" - if __debug__: - _z3_assert(is_bv(a), "Arguments should be bit-vectors") - _z3_assert(is_bv(b), "Arguments should be bit-vectors") + _check_bv_args(a, b) + a, b = _coerce_exprs(a, b) return BoolRef(Z3_mk_bvsdiv_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx) def BVSNegNoOverflow(a): """A predicate the determines that bit-vector unary negation does not overflow""" if __debug__: - _z3_assert(is_bv(a), "Arguments should be bit-vectors") + _z3_assert(is_bv(a), "Argument should be a bit-vector") return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx) def BVMulNoOverflow(a, b, signed): """A predicate the determines that bit-vector multiplication does not overflow""" - if __debug__: - _z3_assert(is_bv(a), "Arguments should be bit-vectors") - _z3_assert(is_bv(b), "Arguments should be bit-vectors") + _check_bv_args(a, b) + a, b = _coerce_exprs(a, b) return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx) def BVMulNoUnderflow(a, b, signed): """A predicate the determines that bit-vector signed multiplication does not underflow""" - if __debug__: - _z3_assert(is_bv(a), "Arguments should be bit-vectors") - _z3_assert(is_bv(b), "Arguments should be bit-vectors") + _check_bv_args(a, b) + a, b = _coerce_exprs(a, b) return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx) From 56cc0a9018424409adb55b8aba75f92f2ac66d2e Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 21 Nov 2017 15:47:27 -0800 Subject: [PATCH 046/263] remove redundant argument #1364 Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 17e5bbff8..1f050d3bd 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -3999,7 +3999,7 @@ def BVAddNoOverflow(a, b, signed): a, b = _coerce_exprs(a, b) return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx) -def BVAddNoUnderflow(a, b, signed): +def BVAddNoUnderflow(a, b): """A predicate the determines that signed bit-vector addition does not underflow""" _check_bv_args(a, b) a, b = _coerce_exprs(a, b) @@ -4037,7 +4037,7 @@ def BVMulNoOverflow(a, b, signed): return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx) -def BVMulNoUnderflow(a, b, signed): +def BVMulNoUnderflow(a, b): """A predicate the determines that bit-vector signed multiplication does not underflow""" _check_bv_args(a, b) a, b = _coerce_exprs(a, b) From 357b4b20fd0ee83e38ba52328ca16b30bc2e5a0f Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 23 Nov 2017 11:17:41 -0800 Subject: [PATCH 047/263] fix #1365. Filter MBQI instantiations for as-array terms that lead the array theory to return unknown and therefore block further instantiations. as-array terms are at this point almost always created from internal model values so quantifier instantiations with these have little value, other than instantiations of other paraameters that may indepdendently help Signed-off-by: Nikolaj Bjorner --- src/smt/smt_model_checker.cpp | 5 +++-- src/smt/smt_model_checker.h | 2 ++ src/smt/smt_model_finder.cpp | 8 ++------ src/smt/smt_quantifier.cpp | 11 +++-------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/smt/smt_model_checker.cpp b/src/smt/smt_model_checker.cpp index f72485d0e..cd59014aa 100644 --- a/src/smt/smt_model_checker.cpp +++ b/src/smt/smt_model_checker.cpp @@ -32,6 +32,7 @@ namespace smt { model_checker::model_checker(ast_manager & m, qi_params const & p, model_finder & mf): m(m), m_params(p), + m_autil(m), m_qm(0), m_context(0), m_root2value(0), @@ -205,13 +206,13 @@ namespace smt { } void model_checker::operator()(expr *n) { - if (m.is_model_value(n)) { + if (m.is_model_value(n) || m_autil.is_as_array(n)) { throw is_model_value(); } } bool model_checker::contains_model_value(expr* n) { - if (m.is_model_value(n)) { + if (m.is_model_value(n) || m_autil.is_as_array(n)) { return true; } if (is_app(n) && to_app(n)->get_num_args() == 0) { diff --git a/src/smt/smt_model_checker.h b/src/smt/smt_model_checker.h index 778f913c3..dd63940b7 100644 --- a/src/smt/smt_model_checker.h +++ b/src/smt/smt_model_checker.h @@ -22,6 +22,7 @@ Revision History: #define SMT_MODEL_CHECKER_H_ #include "ast/ast.h" +#include "ast/array_decl_plugin.h" #include "util/obj_hashtable.h" #include "smt/params/qi_params.h" #include "smt/params/smt_params.h" @@ -39,6 +40,7 @@ namespace smt { class model_checker { ast_manager & m; // _manager; qi_params const & m_params; + array_util m_autil; // copy of smt_params for auxiliary context. // the idea is to use a different configuration for the aux context (e.g., disable relevancy) scoped_ptr m_fparams; diff --git a/src/smt/smt_model_finder.cpp b/src/smt/smt_model_finder.cpp index 0536c200d..11202d58a 100644 --- a/src/smt/smt_model_finder.cpp +++ b/src/smt/smt_model_finder.cpp @@ -643,12 +643,8 @@ namespace smt { return t_result; } - bool is_infinite(sort * s) const { - // we should not assume that uninterpreted sorts are infinite in benchmarks with quantifiers. - return - !m.is_uninterp(s) && - s->is_infinite(); - } + // we should not assume that uninterpreted sorts are infinite in benchmarks with quantifiers. + bool is_infinite(sort * s) const { return !m.is_uninterp(s) && s->is_infinite(); } /** \brief Return a fresh constant k that is used as a witness for elements that must be different from diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index 1d58e2bb3..c6f83c611 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -127,10 +127,8 @@ namespace smt { out << " #" << bindings[i]->get_owner_id(); } out << " ;"; - ptr_vector::const_iterator it = used_enodes.begin(); - ptr_vector::const_iterator end = used_enodes.end(); - for (; it != end; ++it) - out << " #" << (*it)->get_owner_id(); + for (enode* n : used_enodes) + out << " #" << n->get_owner_id(); out << "\n"; } m_qi_queue.insert(f, pat, max_generation, min_top_generation, max_top_generation); // TODO @@ -150,10 +148,7 @@ namespace smt { void init_search_eh() { m_num_instances = 0; - ptr_vector::iterator it2 = m_quantifiers.begin(); - ptr_vector::iterator end2 = m_quantifiers.end(); - for (; it2 != end2; ++it2) { - quantifier * q = *it2; + for (quantifier * q : m_quantifiers) { get_stat(q)->reset_num_instances_curr_search(); } m_qi_queue.init_search_eh(); From 1c5f798cbe473b5508ea295356bed7b97c05adbb Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 25 Nov 2017 12:03:47 -0800 Subject: [PATCH 048/263] expose extra symbols for logic ALL, requested in #1364 Signed-off-by: Nikolaj Bjorner --- src/ast/arith_decl_plugin.cpp | 2 +- src/ast/array_decl_plugin.cpp | 2 +- src/ast/bv_decl_plugin.cpp | 4 ++-- src/ast/datatype_decl_plugin.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ast/arith_decl_plugin.cpp b/src/ast/arith_decl_plugin.cpp index 03ee77458..85c54d1fa 100644 --- a/src/ast/arith_decl_plugin.cpp +++ b/src/ast/arith_decl_plugin.cpp @@ -539,7 +539,7 @@ void arith_decl_plugin::get_op_names(svector& op_names, symbol con op_names.push_back(builtin_name("to_int",OP_TO_INT)); op_names.push_back(builtin_name("is_int",OP_IS_INT)); op_names.push_back(builtin_name("abs", OP_ABS)); - if (logic == symbol::null) { + if (logic == symbol::null || logic == symbol("ALL")) { op_names.push_back(builtin_name("^", OP_POWER)); op_names.push_back(builtin_name("sin", OP_SIN)); op_names.push_back(builtin_name("cos", OP_COS)); diff --git a/src/ast/array_decl_plugin.cpp b/src/ast/array_decl_plugin.cpp index 0cc4f6031..1e789b7e5 100644 --- a/src/ast/array_decl_plugin.cpp +++ b/src/ast/array_decl_plugin.cpp @@ -524,7 +524,7 @@ void array_decl_plugin::get_sort_names(svector& sort_names, symbol void array_decl_plugin::get_op_names(svector& op_names, symbol const & logic) { op_names.push_back(builtin_name("store",OP_STORE)); op_names.push_back(builtin_name("select",OP_SELECT)); - if (logic == symbol::null || logic == symbol("HORN")) { + if (logic == symbol::null || logic == symbol("HORN") || logic == symbol("ALL")) { // none of the SMT2 logics support these extensions op_names.push_back(builtin_name("const",OP_CONST_ARRAY)); op_names.push_back(builtin_name("map",OP_ARRAY_MAP)); diff --git a/src/ast/bv_decl_plugin.cpp b/src/ast/bv_decl_plugin.cpp index 093d0f548..28c3d5f5d 100644 --- a/src/ast/bv_decl_plugin.cpp +++ b/src/ast/bv_decl_plugin.cpp @@ -670,7 +670,7 @@ bool bv_decl_plugin::are_distinct(app * a, app * b) const { } void bv_decl_plugin::get_sort_names(svector & sort_names, symbol const & logic) { - if (logic == symbol::null) + if (logic == symbol::null || logic == symbol("ALL")) sort_names.push_back(builtin_name("bv", BV_SORT)); sort_names.push_back(builtin_name("BitVec", BV_SORT)); } @@ -717,7 +717,7 @@ void bv_decl_plugin::get_op_names(svector & op_names, symbol const op_names.push_back(builtin_name("rotate_left",OP_ROTATE_LEFT)); op_names.push_back(builtin_name("rotate_right",OP_ROTATE_RIGHT)); - if (logic == symbol::null) { + if (logic == symbol::null || logic == symbol("ALL")) { op_names.push_back(builtin_name("bvumul_noovfl",OP_BUMUL_NO_OVFL)); op_names.push_back(builtin_name("bvsmul_noovfl",OP_BSMUL_NO_OVFL)); op_names.push_back(builtin_name("bvsmul_noudfl",OP_BSMUL_NO_UDFL)); diff --git a/src/ast/datatype_decl_plugin.cpp b/src/ast/datatype_decl_plugin.cpp index 566487e60..91e636ed7 100644 --- a/src/ast/datatype_decl_plugin.cpp +++ b/src/ast/datatype_decl_plugin.cpp @@ -458,7 +458,7 @@ namespace datatype { void plugin::get_op_names(svector & op_names, symbol const & logic) { op_names.push_back(builtin_name("is", OP_DT_IS)); - if (logic == symbol::null) { + if (logic == symbol::null || logic == symbol("ALL")) { op_names.push_back(builtin_name("update-field", OP_DT_UPDATE_FIELD)); } } From 77b74ddb8855b9f174cc70c34e046c0ae16b0d56 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 25 Nov 2017 17:55:20 -0800 Subject: [PATCH 049/263] fix #1366 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_seq.cpp | 122 +++++++++++++++++++++++++++-------------- src/smt/theory_seq.h | 1 + 2 files changed, 83 insertions(+), 40 deletions(-) diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 6f7cf1b5e..1286fa85d 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -1766,10 +1766,10 @@ bool theory_seq::get_length(expr* e, expr_ref& len, literal_vector& lits) { expr_ref ls(m_util.str.mk_length(s), m); expr_ref ls_minus_i_l(mk_sub(mk_sub(ls, i),l), m); bool i_is_zero = m_autil.is_numeral(i, r) && r.is_zero(); - literal i_ge_0 = i_is_zero?true_literal:mk_literal(m_autil.mk_ge(i, zero)); - literal i_lt_len_s = ~mk_literal(m_autil.mk_ge(mk_sub(i, ls), zero)); - literal li_ge_ls = mk_literal(m_autil.mk_ge(ls_minus_i_l, zero)); - literal l_ge_zero = mk_literal(m_autil.mk_ge(l, zero)); + literal i_ge_0 = i_is_zero?true_literal:mk_simplified_literal(m_autil.mk_ge(i, zero)); + literal i_lt_len_s = ~mk_simplified_literal(m_autil.mk_ge(mk_sub(i, ls), zero)); + literal li_ge_ls = mk_simplified_literal(m_autil.mk_ge(ls_minus_i_l, zero)); + literal l_ge_zero = mk_simplified_literal(m_autil.mk_ge(l, zero)); literal _lits[4] = { i_ge_0, i_lt_len_s, li_ge_ls, l_ge_zero }; if (ctx.get_assignment(i_ge_0) == l_true && ctx.get_assignment(i_lt_len_s) == l_true && @@ -1786,8 +1786,8 @@ bool theory_seq::get_length(expr* e, expr_ref& len, literal_vector& lits) { // has length 1 if 0 <= i < len(s) expr_ref zero(m_autil.mk_int(0), m); bool i_is_zero = m_autil.is_numeral(i, r) && r.is_zero(); - literal i_ge_0 = i_is_zero?true_literal:mk_literal(m_autil.mk_ge(i, zero)); - literal i_lt_len_s = ~mk_literal(m_autil.mk_ge(mk_sub(i, m_util.str.mk_length(s)), zero)); + literal i_ge_0 = i_is_zero?true_literal:mk_simplified_literal(m_autil.mk_ge(i, zero)); + literal i_lt_len_s = ~mk_simplified_literal(m_autil.mk_ge(mk_sub(i, m_util.str.mk_length(s)), zero)); literal _lits[2] = { i_ge_0, i_lt_len_s}; if (ctx.get_assignment(i_ge_0) == l_true && ctx.get_assignment(i_lt_len_s) == l_true) { @@ -1800,8 +1800,8 @@ bool theory_seq::get_length(expr* e, expr_ref& len, literal_vector& lits) { else if (is_pre(e, s, i)) { expr_ref zero(m_autil.mk_int(0), m); bool i_is_zero = m_autil.is_numeral(i, r) && r.is_zero(); - literal i_ge_0 = i_is_zero?true_literal:mk_literal(m_autil.mk_ge(i, zero)); - literal i_lt_len_s = ~mk_literal(m_autil.mk_ge(mk_sub(i, m_util.str.mk_length(s)), zero)); + literal i_ge_0 = i_is_zero?true_literal:mk_simplified_literal(m_autil.mk_ge(i, zero)); + literal i_lt_len_s = ~mk_simplified_literal(m_autil.mk_ge(mk_sub(i, m_util.str.mk_length(s)), zero)); literal _lits[2] = { i_ge_0, i_lt_len_s }; if (ctx.get_assignment(i_ge_0) == l_true && ctx.get_assignment(i_lt_len_s) == l_true) { @@ -1813,8 +1813,8 @@ bool theory_seq::get_length(expr* e, expr_ref& len, literal_vector& lits) { } else if (is_post(e, s, l)) { expr_ref zero(m_autil.mk_int(0), m); - literal l_ge_0 = mk_literal(m_autil.mk_ge(l, zero)); - literal l_le_len_s = mk_literal(m_autil.mk_ge(mk_sub(m_util.str.mk_length(s), l), zero)); + literal l_ge_0 = mk_simplified_literal(m_autil.mk_ge(l, zero)); + literal l_le_len_s = mk_simplified_literal(m_autil.mk_ge(mk_sub(m_util.str.mk_length(s), l), zero)); literal _lits[2] = { l_ge_0, l_le_len_s }; if (ctx.get_assignment(l_ge_0) == l_true && ctx.get_assignment(l_le_len_s) == l_true) { @@ -2353,7 +2353,7 @@ bool theory_seq::add_stoi_axiom(expr* e) { TRACE("seq", tout << mk_pp(e, m) << "\n";); VERIFY(m_util.str.is_stoi(e, n)); if (!get_num_value(e, val)) { - literal l = mk_literal(m_autil.mk_ge(e, arith_util(m).mk_int(-1))); + literal l = mk_simplified_literal(m_autil.mk_ge(e, arith_util(m).mk_int(-1))); add_axiom(l); TRACE("seq", tout << l << " " << ctx.get_assignment(l) << "\n"; ctx.display(tout);); @@ -3101,7 +3101,6 @@ void theory_seq::propagate() { } void theory_seq::enque_axiom(expr* e) { - TRACE("seq", tout << "add axioms for: " << mk_pp(e, m) << "\n";); if (!m_axiom_set.contains(e)) { m_axioms.push_back(e); m_axiom_set.insert(e); @@ -3111,6 +3110,7 @@ void theory_seq::enque_axiom(expr* e) { } void theory_seq::deque_axiom(expr* n) { + TRACE("seq", tout << "deque: " << mk_pp(n, m) << "\n";); if (m_util.str.is_length(n)) { add_length_axiom(n); } @@ -3156,11 +3156,24 @@ void theory_seq::tightest_prefix(expr* s, expr* x) { } /* - // index of s in t starting at offset. + [[str.indexof]](w, w2, i) is the smallest n such that for some some w1, w3 + - w = w1w2w3 + - i <= n = |w1| + + if [[str.contains]](w, w2) = true, |w2| > 0 and i >= 0. + + [[str.indexof]](w,w2,i) = -1 otherwise. + let i = Index(t, s, offset): + // index of s in t starting at offset. - offset >= len(t) => i = -1 + + |t| = 0 => |s| = 0 or indexof(t,s,offset) = -1 + |t| = 0 & |s| = 0 => indexof(t,s,offset) = 0 + + offset >= len(t) => |s| = 0 or i = -1 + len(t) != 0 & !contains(t, s) => i = -1 @@ -3190,32 +3203,45 @@ void theory_seq::add_indexof_axiom(expr* i) { literal cnt = mk_literal(m_util.str.mk_contains(t, s)); literal i_eq_m1 = mk_eq(i, minus_one, false); - add_axiom(cnt, i_eq_m1); + literal i_eq_0 = mk_eq(i, zero, false); literal s_eq_empty = mk_eq_empty(s); - add_axiom(~s_eq_empty, mk_eq(i, zero, false)); - add_axiom(s_eq_empty, ~mk_eq_empty(t), i_eq_m1); + literal t_eq_empty = mk_eq_empty(t); + + // |t| = 0 => |s| = 0 or indexof(t,s,offset) = -1 + // ~contains(t,s) => indexof(t,s,offset) = -1 + + add_axiom(cnt, i_eq_m1); + add_axiom(~t_eq_empty, s_eq_empty, i_eq_m1); if (!offset || (m_autil.is_numeral(offset, r) && r.is_zero())) { expr_ref x = mk_skolem(m_indexof_left, t, s); expr_ref y = mk_skolem(m_indexof_right, t, s); xsy = mk_concat(x, s, y); expr_ref lenx(m_util.str.mk_length(x), m); + // |s| = 0 => indexof(t,s,0) = 0 + // contains(t,s) & |s| != 0 => t = xsy & indexof(t,s,0) = |x| + add_axiom(~s_eq_empty, i_eq_0); add_axiom(~cnt, s_eq_empty, mk_seq_eq(t, xsy)); add_axiom(~cnt, s_eq_empty, mk_eq(i, lenx, false)); tightest_prefix(s, x); } else { - // offset >= len(t) => indexof(s, t, offset) = -1 - + // offset >= len(t) => |s| = 0 or indexof(t, s, offset) = -1 + // offset > len(t) => indexof(t, s, offset) = -1 + // offset = len(t) & |s| = 0 => indexof(t, s, offset) = offset expr_ref len_t(m_util.str.mk_length(t), m); - literal offset_ge_len = mk_literal(m_autil.mk_ge(mk_sub(offset, len_t), zero)); - add_axiom(~offset_ge_len, mk_eq(i, minus_one, false)); + literal offset_ge_len = mk_simplified_literal(m_autil.mk_ge(offset, len_t)); + literal offset_le_len = mk_simplified_literal(m_autil.mk_le(offset, len_t)); + literal i_eq_offset = mk_eq(i, offset, false); + add_axiom(~offset_ge_len, s_eq_empty, i_eq_m1); + add_axiom(offset_le_len, i_eq_m1); + add_axiom(~offset_ge_len, ~offset_le_len, ~s_eq_empty, i_eq_offset); expr_ref x = mk_skolem(m_indexof_left, t, s, offset); expr_ref y = mk_skolem(m_indexof_right, t, s, offset); expr_ref indexof0(m_util.str.mk_index(y, s, zero), m); expr_ref offset_p_indexof0(m_autil.mk_add(offset, indexof0), m); - literal offset_ge_0 = mk_literal(m_autil.mk_ge(offset, zero)); + literal offset_ge_0 = mk_simplified_literal(m_autil.mk_ge(offset, zero)); // 0 <= offset & offset < len(t) => t = xy // 0 <= offset & offset < len(t) => len(x) = offset @@ -3228,10 +3254,10 @@ void theory_seq::add_indexof_axiom(expr* i) { add_axiom(~offset_ge_0, offset_ge_len, ~mk_eq(indexof0, minus_one, false), i_eq_m1); add_axiom(~offset_ge_0, offset_ge_len, - ~mk_literal(m_autil.mk_ge(indexof0, zero)), + ~mk_simplified_literal(m_autil.mk_ge(indexof0, zero)), mk_eq(offset_p_indexof0, i, false)); - // offset < 0 => -1 = i + // offset < 0 => -1 = i add_axiom(offset_ge_0, i_eq_m1); } } @@ -3574,11 +3600,19 @@ bool theory_seq::get_length(expr* e, rational& val) const { let e = extract(s, i, l) - 0 <= i <= |s| -> prefix(xe,s) + i is start index, l is length of substring starting at index. + + i < 0 => e = "" + i >= |s| => e = "" + l <= 0 => e = "" + 0 <= i < |s| & l > 0 => s = xey, |x| = i, |e| = min(l, |s|-i) + +this translates to: + + 0 <= i <= |s| -> s = xey 0 <= i <= |s| -> len(x) = i 0 <= i <= |s| & 0 <= l <= |s| - i -> |e| = l 0 <= i <= |s| & |s| < l + i -> |e| = |s| - i - 0 <= i <= |s| & l < 0 -> |e| = 0 i >= |s| => |e| = 0 i < 0 => |e| = 0 l <= 0 => |e| = 0 @@ -3590,6 +3624,7 @@ bool theory_seq::get_length(expr* e, rational& val) const { */ void theory_seq::add_extract_axiom(expr* e) { + TRACE("seq", tout << mk_pp(e, m) << "\n";); expr* s = 0, *i = 0, *l = 0; VERIFY(m_util.str.is_extract(e, s, i, l)); if (is_tail(s, i, l)) { @@ -3618,13 +3653,13 @@ void theory_seq::add_extract_axiom(expr* e) { expr_ref xey = mk_concat(x, e, y); expr_ref zero(m_autil.mk_int(0), m); - literal i_ge_0 = mk_literal(m_autil.mk_ge(i, zero)); - literal ls_le_i = mk_literal(m_autil.mk_le(mk_sub(i, ls), zero)); - literal li_ge_ls = mk_literal(m_autil.mk_ge(ls_minus_i_l, zero)); - literal l_ge_zero = mk_literal(m_autil.mk_ge(l, zero)); - literal ls_le_0 = mk_literal(m_autil.mk_le(ls, zero)); + literal i_ge_0 = mk_simplified_literal(m_autil.mk_ge(i, zero)); + literal ls_le_i = mk_simplified_literal(m_autil.mk_le(mk_sub(i, ls), zero)); + literal li_ge_ls = mk_simplified_literal(m_autil.mk_ge(ls_minus_i_l, zero)); + literal l_ge_zero = mk_simplified_literal(m_autil.mk_ge(l, zero)); + literal l_le_zero = mk_simplified_literal(m_autil.mk_le(l, zero)); + literal ls_le_0 = mk_simplified_literal(m_autil.mk_le(ls, zero)); -// add_axiom(~i_ge_0, ~ls_le_i, mk_literal(m_util.str.mk_prefix(xe, s))); add_axiom(~i_ge_0, ~ls_le_i, mk_seq_eq(xey, s)); add_axiom(~i_ge_0, ~ls_le_i, mk_eq(lx, i, false)); add_axiom(~i_ge_0, ~ls_le_i, ~l_ge_zero, ~li_ge_ls, mk_eq(le, l, false)); @@ -3684,14 +3719,15 @@ bool theory_seq::is_extract_suffix(expr* s, expr* i, expr* l) { 0 <= l <= len(s) => s = ey & l = len(e) */ void theory_seq::add_extract_prefix_axiom(expr* e, expr* s, expr* l) { + TRACE("seq", tout << mk_pp(e, m) << " " << mk_pp(s, m) << " " << mk_pp(l, m) << "\n";); expr_ref le(m_util.str.mk_length(e), m); expr_ref ls(m_util.str.mk_length(s), m); expr_ref ls_minus_l(mk_sub(ls, l), m); expr_ref y(mk_skolem(m_post, s, ls_minus_l), m); expr_ref zero(m_autil.mk_int(0), m); expr_ref ey = mk_concat(e, y); - literal l_ge_0 = mk_literal(m_autil.mk_ge(l, zero)); - literal l_le_s = mk_literal(m_autil.mk_le(mk_sub(l, ls), zero)); + literal l_ge_0 = mk_simplified_literal(m_autil.mk_ge(l, zero)); + literal l_le_s = mk_simplified_literal(m_autil.mk_le(mk_sub(l, ls), zero)); add_axiom(~l_ge_0, ~l_le_s, mk_seq_eq(s, ey)); add_axiom(~l_ge_0, ~l_le_s, mk_eq(l, le, false)); add_axiom(~l_ge_0, ~l_le_s, mk_eq(ls_minus_l, m_util.str.mk_length(y), false)); @@ -3706,8 +3742,8 @@ void theory_seq::add_extract_suffix_axiom(expr* e, expr* s, expr* i) { expr_ref ls(m_util.str.mk_length(s), m); expr_ref zero(m_autil.mk_int(0), m); expr_ref xe = mk_concat(x, e); - literal i_ge_0 = mk_literal(m_autil.mk_ge(i, zero)); - literal i_le_s = mk_literal(m_autil.mk_le(mk_sub(i, ls), zero)); + literal i_ge_0 = mk_simplified_literal(m_autil.mk_ge(i, zero)); + literal i_le_s = mk_simplified_literal(m_autil.mk_le(mk_sub(i, ls), zero)); add_axiom(~i_ge_0, ~i_le_s, mk_seq_eq(s, xe)); add_axiom(~i_ge_0, ~i_le_s, mk_eq(i, lx, false)); } @@ -3733,8 +3769,8 @@ void theory_seq::add_at_axiom(expr* e) { expr_ref len_x(m_util.str.mk_length(x), m); expr_ref emp(m_util.str.mk_empty(m.get_sort(e)), m); - literal i_ge_0 = mk_literal(m_autil.mk_ge(i, zero)); - literal i_ge_len_s = mk_literal(m_autil.mk_ge(mk_sub(i, m_util.str.mk_length(s)), zero)); + literal i_ge_0 = mk_simplified_literal(m_autil.mk_ge(i, zero)); + literal i_ge_len_s = mk_simplified_literal(m_autil.mk_ge(mk_sub(i, m_util.str.mk_length(s)), zero)); add_axiom(~i_ge_0, i_ge_len_s, mk_seq_eq(s, xey)); @@ -3753,7 +3789,7 @@ void theory_seq::propagate_step(literal lit, expr* step) { expr* re = 0, *acc = 0, *s = 0, *idx = 0, *i = 0, *j = 0; VERIFY(is_step(step, s, idx, re, i, j, acc)); TRACE("seq", tout << mk_pp(step, m) << " -> " << mk_pp(acc, m) << "\n";); - propagate_lit(0, 1, &lit, mk_literal(acc)); + propagate_lit(0, 1, &lit, mk_simplified_literal(acc)); rational lo; rational _idx; if (lower_bound(s, lo) && lo.is_unsigned() && m_autil.is_numeral(idx, _idx) && lo >= _idx) { @@ -3790,6 +3826,12 @@ void theory_seq::ensure_nth(literal lit, expr* s, expr* idx) { propagate_eq(lit, s, conc, true); } +literal theory_seq::mk_simplified_literal(expr * _e) { + expr_ref e(_e, m); + m_rewrite(e); + return mk_literal(e); +} + literal theory_seq::mk_literal(expr* _e) { expr_ref e(_e, m); context& ctx = get_context(); @@ -3839,7 +3881,7 @@ void theory_seq::add_axiom(literal l1, literal l2, literal l3, literal l4, liter if (l3 != null_literal && l3 != false_literal) { ctx.mark_as_relevant(l3); lits.push_back(l3); } if (l4 != null_literal && l4 != false_literal) { ctx.mark_as_relevant(l4); lits.push_back(l4); } if (l5 != null_literal && l5 != false_literal) { ctx.mark_as_relevant(l5); lits.push_back(l5); } - TRACE("seq", ctx.display_literals_verbose(tout << "assert: ", lits); tout << "\n";); + TRACE("seq", ctx.display_literals_verbose(tout << "assert:\n", lits); tout << "\n";); m_new_propagation = true; ++m_stats.m_add_axiom; ctx.mk_th_axiom(get_id(), lits.size(), lits.c_ptr()); diff --git a/src/smt/theory_seq.h b/src/smt/theory_seq.h index e08c0588e..d4686c835 100644 --- a/src/smt/theory_seq.h +++ b/src/smt/theory_seq.h @@ -509,6 +509,7 @@ namespace smt { expr_ref digit2int(expr* ch); void add_itos_length_axiom(expr* n); literal mk_literal(expr* n); + literal mk_simplified_literal(expr* n); literal mk_eq_empty(expr* n, bool phase = true); literal mk_seq_eq(expr* a, expr* b); void tightest_prefix(expr* s, expr* x); From 841c48e04df40c0b91f7eabfbdc32b3a80173891 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 25 Nov 2017 18:24:45 -0800 Subject: [PATCH 050/263] fix break Signed-off-by: Nikolaj Bjorner --- src/smt/theory_seq.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 1286fa85d..fb8f36c59 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -3230,8 +3230,8 @@ void theory_seq::add_indexof_axiom(expr* i) { // offset > len(t) => indexof(t, s, offset) = -1 // offset = len(t) & |s| = 0 => indexof(t, s, offset) = offset expr_ref len_t(m_util.str.mk_length(t), m); - literal offset_ge_len = mk_simplified_literal(m_autil.mk_ge(offset, len_t)); - literal offset_le_len = mk_simplified_literal(m_autil.mk_le(offset, len_t)); + literal offset_ge_len = mk_simplified_literal(m_autil.mk_ge(m_autil.mk_sub(offset, len_t), zero)); + literal offset_le_len = mk_simplified_literal(m_autil.mk_le(m_autil.mk_sub(offset, len_t), zero)); literal i_eq_offset = mk_eq(i, offset, false); add_axiom(~offset_ge_len, s_eq_empty, i_eq_m1); add_axiom(offset_le_len, i_eq_m1); From 7d693a5f9f3a535317ea22c37a67388a367c1fa7 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 25 Nov 2017 20:01:14 -0800 Subject: [PATCH 051/263] fix different bug reported on #1366 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_seq.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index fb8f36c59..131d1fd1b 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -1987,10 +1987,13 @@ bool theory_seq::solve_ne(unsigned idx) { dependency* deps1 = 0; if (explain_eq(n.l(), n.r(), deps1)) { - new_lits.reset(); - new_lits.push_back(~mk_eq(n.l(), n.r(), false)); - new_deps = deps1; - TRACE("seq", tout << "conflict explained\n";); + literal diseq = mk_eq(n.l(), n.r(), false); + if (ctx.get_assignment(diseq) == l_false) { + new_lits.reset(); + new_lits.push_back(~diseq); + new_deps = deps1; + TRACE("seq", tout << "conflict explained\n";); + } } set_conflict(new_deps, new_lits); SASSERT(m_new_propagation); From 4520fafa8c2b15abf35074551cf49ab47512ed44 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 26 Nov 2017 19:13:35 -0800 Subject: [PATCH 052/263] fix #1368 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_arith.h | 2 +- src/smt/theory_arith_core.h | 33 +++++++++++++++------------ src/tactic/smtlogics/qflia_tactic.cpp | 5 +--- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/smt/theory_arith.h b/src/smt/theory_arith.h index 5f4e58a1b..806b2a05b 100644 --- a/src/smt/theory_arith.h +++ b/src/smt/theory_arith.h @@ -603,7 +603,7 @@ namespace smt { void internalize_is_int(app * n); theory_var internalize_numeral(app * n); theory_var internalize_term_core(app * n); - void mk_axiom(expr * n1, expr * n2); + void mk_axiom(expr * n1, expr * n2, bool simplify_conseq = true); void mk_idiv_mod_axioms(expr * dividend, expr * divisor); void mk_div_axiom(expr * dividend, expr * divisor); void mk_rem_axiom(expr * dividend, expr * divisor); diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index aa512a2be..b00648c36 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -443,7 +443,7 @@ namespace smt { } template - void theory_arith::mk_axiom(expr * ante, expr * conseq) { + void theory_arith::mk_axiom(expr * ante, expr * conseq, bool simplify_conseq) { ast_manager & m = get_manager(); context & ctx = get_context(); th_rewriter & s = ctx.get_rewriter(); @@ -459,7 +459,8 @@ namespace smt { literal l_ante = ctx.get_literal(s_ante); if (negated) l_ante.neg(); - s(conseq, s_conseq); + s_conseq = conseq; + if (simplify_conseq) s(conseq, s_conseq); if (ctx.get_cancel_flag()) return; negated = m.is_not(s_conseq, s_conseq_n); if (negated) s_conseq = s_conseq_n; @@ -507,26 +508,30 @@ namespace smt { template void theory_arith::mk_idiv_mod_axioms(expr * dividend, expr * divisor) { if (!m_util.is_zero(divisor)) { - // if divisor is zero, then idiv and mod are uninterpreted functions. ast_manager & m = get_manager(); - expr_ref div(m), mod(m), zero(m), abs_divisor(m); + bool is_numeral = m_util.is_numeral(divisor); + // if divisor is zero, then idiv and mod are uninterpreted functions. + expr_ref div(m), mod(m), zero(m), abs_divisor(m), one(m); expr_ref eqz(m), eq(m), lower(m), upper(m); + th_rewriter & s = get_context().get_rewriter(); div = m_util.mk_idiv(dividend, divisor); mod = m_util.mk_mod(dividend, divisor); - zero = m_util.mk_numeral(rational(0), true); - abs_divisor = m.mk_ite(m_util.mk_lt(divisor, zero), m_util.mk_sub(zero, divisor), divisor); + zero = m_util.mk_int(0); + one = m_util.mk_int(1); + abs_divisor = m_util.mk_sub(m.mk_ite(m_util.mk_lt(divisor, zero), m_util.mk_sub(zero, divisor), divisor), one); + s(abs_divisor); eqz = m.mk_eq(divisor, zero); eq = m.mk_eq(m_util.mk_add(m_util.mk_mul(divisor, div), mod), dividend); - lower = m_util.mk_le(zero, mod); - upper = m_util.mk_lt(mod, abs_divisor); + lower = m_util.mk_ge(mod, zero); + upper = m_util.mk_le(mod, abs_divisor); TRACE("div_axiom_bug", - tout << "eqz: " << mk_pp(eqz, m) << "\neq: " << mk_pp(eq, m) << "\n"; - tout << "lower: " << mk_pp(lower, m) << "\n"; - tout << "upper: " << mk_pp(upper, m) << "\n";); + tout << "eqz: " << eqz << " neq: " << eq << "\n"; + tout << "lower: " << lower << "\n"; + tout << "upper: " << upper << "\n";); - mk_axiom(eqz, eq); - mk_axiom(eqz, lower); - mk_axiom(eqz, upper); + mk_axiom(eqz, eq, !is_numeral); + mk_axiom(eqz, lower, !is_numeral); + mk_axiom(eqz, upper, !is_numeral); rational k; if (m_params.m_arith_enum_const_mod && m_util.is_numeral(divisor, k) && k.is_pos() && k < rational(8)) { diff --git a/src/tactic/smtlogics/qflia_tactic.cpp b/src/tactic/smtlogics/qflia_tactic.cpp index 248829c49..de542f3c4 100644 --- a/src/tactic/smtlogics/qflia_tactic.cpp +++ b/src/tactic/smtlogics/qflia_tactic.cpp @@ -42,10 +42,7 @@ struct quasi_pb_probe : public probe { bound_manager bm(g.m()); bm(g); rational l, u; bool st; - bound_manager::iterator it = bm.begin(); - bound_manager::iterator end = bm.end(); - for (; it != end; ++it) { - expr * t = *it; + for (expr * t : bm) { if (bm.has_lower(t, l, st) && bm.has_upper(t, u, st) && (l.is_zero() || l.is_one()) && (u.is_zero() || u.is_one())) continue; if (found_non_01) From bfe6260c58c740c7efda919861ab3d4e5c8f70d9 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 27 Nov 2017 08:39:20 -0800 Subject: [PATCH 053/263] fix #1376 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_seq.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 131d1fd1b..ca6ab048c 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -2400,6 +2400,7 @@ bool theory_seq::add_stoi_axiom(expr* e) { nums[i] = m_autil.mk_mul(coeff, nums[i].get()); } num = m_autil.mk_add(nums.size(), nums.c_ptr()); + ctx.get_rewriter()(num); lits.push_back(mk_eq(e, num, false)); ++m_stats.m_add_axiom; m_new_propagation = true; From 2b3ee995ffdf03f67c6e05586d1ebbc1081b9181 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 27 Nov 2017 09:03:52 -0800 Subject: [PATCH 054/263] fix #1375 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_str.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index ed926a50d..7936b581c 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -1077,13 +1077,14 @@ namespace smt { void theory_str::instantiate_axiom_CharAt(enode * e) { context & ctx = get_context(); ast_manager & m = get_manager(); - + expr* arg0, *arg1; app * expr = e->get_owner(); if (axiomatized_terms.contains(expr)) { TRACE("str", tout << "already set up CharAt axiom for " << mk_pp(expr, m) << std::endl;); return; } axiomatized_terms.insert(expr); + VERIFY(u.str.is_at(expr, arg0, arg1)); TRACE("str", tout << "instantiate CharAt axiom for " << mk_pp(expr, m) << std::endl;); @@ -1092,28 +1093,20 @@ namespace smt { expr_ref ts2(mk_str_var("ts2"), m); expr_ref cond(m.mk_and( - m_autil.mk_ge(expr->get_arg(1), mk_int(0)), - // REWRITE for arithmetic theory: - // m_autil.mk_lt(expr->get_arg(1), mk_strlen(expr->get_arg(0))) - mk_not(m, m_autil.mk_ge(m_autil.mk_add(expr->get_arg(1), m_autil.mk_mul(mk_int(-1), mk_strlen(expr->get_arg(0)))), mk_int(0))) - ), m); + m_autil.mk_ge(arg1, mk_int(0)), + m_autil.mk_lt(arg1, mk_strlen(arg0))), m); expr_ref_vector and_item(m); - and_item.push_back(ctx.mk_eq_atom(expr->get_arg(0), mk_concat(ts0, mk_concat(ts1, ts2)))); - and_item.push_back(ctx.mk_eq_atom(expr->get_arg(1), mk_strlen(ts0))); + and_item.push_back(ctx.mk_eq_atom(arg0, mk_concat(ts0, mk_concat(ts1, ts2)))); + and_item.push_back(ctx.mk_eq_atom(arg1, mk_strlen(ts0))); and_item.push_back(ctx.mk_eq_atom(mk_strlen(ts1), mk_int(1))); - expr_ref thenBranch(m.mk_and(and_item.size(), and_item.c_ptr()), m); + expr_ref thenBranch(::mk_and(and_item)); expr_ref elseBranch(ctx.mk_eq_atom(ts1, mk_string("")), m); - expr_ref axiom(m.mk_ite(cond, thenBranch, elseBranch), m); expr_ref reductionVar(ctx.mk_eq_atom(expr, ts1), m); - - SASSERT(axiom); - SASSERT(reductionVar); - expr_ref finalAxiom(m.mk_and(axiom, reductionVar), m); - SASSERT(finalAxiom); + get_context().get_rewriter()(finalAxiom); assert_axiom(finalAxiom); } From 36e5d4dec9c01f87e6d6c5f2de3c202d84b2e92a Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 27 Nov 2017 11:01:44 -0800 Subject: [PATCH 055/263] fix #1377 Signed-off-by: Nikolaj Bjorner --- src/ast/rewriter/seq_rewriter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ast/rewriter/seq_rewriter.cpp b/src/ast/rewriter/seq_rewriter.cpp index 13cb52df1..41b08a5d9 100644 --- a/src/ast/rewriter/seq_rewriter.cpp +++ b/src/ast/rewriter/seq_rewriter.cpp @@ -1572,6 +1572,8 @@ bool seq_rewriter::reduce_eq(expr_ref_vector& ls, expr_ref_vector& rs, expr_ref_ bool lchange = false; SASSERT(lhs.empty()); TRACE("seq", tout << ls << "\n"; tout << rs << "\n";); + //std::cout << ls << "\n"; + //std::cout << rs << "\n"; // solve from back while (true) { while (!rs.empty() && m_util.str.is_empty(rs.back())) { @@ -1645,6 +1647,7 @@ bool seq_rewriter::reduce_eq(expr_ref_vector& ls, expr_ref_vector& rs, expr_ref_ if (m_util.str.is_unit(r) && m_util.str.is_string(l)) { std::swap(l, r); ls.swap(rs); + std::swap(head1, head2); } if (l == r) { ++head1; From 81ec5bae9500756bd7ea28a1da28afcdb0ca848f Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 27 Nov 2017 11:02:48 -0800 Subject: [PATCH 056/263] fix #1377 Signed-off-by: Nikolaj Bjorner --- src/ast/rewriter/seq_rewriter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ast/rewriter/seq_rewriter.cpp b/src/ast/rewriter/seq_rewriter.cpp index 41b08a5d9..fa95278b4 100644 --- a/src/ast/rewriter/seq_rewriter.cpp +++ b/src/ast/rewriter/seq_rewriter.cpp @@ -1572,8 +1572,6 @@ bool seq_rewriter::reduce_eq(expr_ref_vector& ls, expr_ref_vector& rs, expr_ref_ bool lchange = false; SASSERT(lhs.empty()); TRACE("seq", tout << ls << "\n"; tout << rs << "\n";); - //std::cout << ls << "\n"; - //std::cout << rs << "\n"; // solve from back while (true) { while (!rs.empty() && m_util.str.is_empty(rs.back())) { From 103ce78c29a4a2933637e0e6d4d5cb1fa5e6c08c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 08:53:06 -0800 Subject: [PATCH 057/263] save model from level 0, fix #1380 Signed-off-by: Nikolaj Bjorner --- src/ast/rewriter/rewriter_def.h | 3 +++ src/qe/qsat.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ast/rewriter/rewriter_def.h b/src/ast/rewriter/rewriter_def.h index 2abd6d467..31f7d4849 100644 --- a/src/ast/rewriter/rewriter_def.h +++ b/src/ast/rewriter/rewriter_def.h @@ -190,6 +190,9 @@ bool rewriter_tpl::constant_fold(app * t, frame & fr) { else if (m().is_false(cond)) { arg = t->get_arg(2); } + else { + std::cout << mk_ismt2_pp(cond, m()) << "\n"; + } if (arg) { result_stack().shrink(fr.m_spos); result_stack().push_back(arg); diff --git a/src/qe/qsat.cpp b/src/qe/qsat.cpp index 713ecfe77..2419d1c77 100644 --- a/src/qe/qsat.cpp +++ b/src/qe/qsat.cpp @@ -626,6 +626,9 @@ namespace qe { SASSERT(validate_assumptions(*m_model.get(), asms)); SASSERT(validate_model(asms)); TRACE("qe", s.display(tout); display(tout << "\n", *m_model.get()); display(tout, asms); ); + if (m_level == 0) { + m_model_save = m_model; + } push(); if (m_level == 1 && m_mode == qsat_maximize) { maximize_model(); @@ -1274,7 +1277,7 @@ namespace qe { in->inc_depth(); result.push_back(in.get()); if (in->models_enabled()) { - mc = model2model_converter(m_model.get()); + mc = model2model_converter(m_model_save.get()); mc = concat(m_pred_abs.fmc(), mc.get()); } break; From 5a35d0076682cb0cf6b61d0c0dbecf034aa01539 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 08:55:45 -0800 Subject: [PATCH 058/263] remove std::cout Signed-off-by: Nikolaj Bjorner --- src/ast/rewriter/rewriter_def.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ast/rewriter/rewriter_def.h b/src/ast/rewriter/rewriter_def.h index 31f7d4849..2abd6d467 100644 --- a/src/ast/rewriter/rewriter_def.h +++ b/src/ast/rewriter/rewriter_def.h @@ -190,9 +190,6 @@ bool rewriter_tpl::constant_fold(app * t, frame & fr) { else if (m().is_false(cond)) { arg = t->get_arg(2); } - else { - std::cout << mk_ismt2_pp(cond, m()) << "\n"; - } if (arg) { result_stack().shrink(fr.m_spos); result_stack().push_back(arg); From d7042c234f32607c01324da7a3bbf74384d0aaab Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 09:34:44 -0800 Subject: [PATCH 059/263] fix #1371 Signed-off-by: Nikolaj Bjorner --- src/smt/smt_context.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 62a569e2b..3b69d4846 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -4366,8 +4366,9 @@ namespace smt { SASSERT(is_app(fn)); // reverse argument order so that variable 0 starts at the beginning. expr_ref_vector subst(m); + unsigned idx = 0; for (expr* arg : *to_app(fn)) { - subst.push_back(arg); + subst.push_back(m.mk_var(idx++, m.get_sort(arg))); } expr_ref bodyr(m); var_subst sub(m, true); From 89971e2a98e513a7516d84b09609dd8997337b5b Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 10:37:30 -0800 Subject: [PATCH 060/263] remove smtlib1 dependencies Signed-off-by: Nikolaj Bjorner --- scripts/mk_project.py | 3 +- src/CMakeLists.txt | 1 - src/api/CMakeLists.txt | 1 - src/api/api_context.cpp | 37 - src/api/api_context.h | 12 +- src/api/api_interp.cpp | 30 +- src/api/api_parsers.cpp | 222 +-- src/api/z3_api.h | 106 +- src/parsers/smt/CMakeLists.txt | 8 - src/parsers/smt/smtlib.cpp | 258 --- src/parsers/smt/smtlib.h | 232 --- src/parsers/smt/smtlib_solver.cpp | 119 -- src/parsers/smt/smtlib_solver.h | 48 - src/parsers/smt/smtparser.cpp | 2760 ----------------------------- src/parsers/smt/smtparser.h | 48 - src/shell/main.cpp | 11 +- src/shell/smtlib_frontend.cpp | 38 +- src/test/quant_elim.cpp | 7 +- 18 files changed, 23 insertions(+), 3918 deletions(-) delete mode 100644 src/parsers/smt/CMakeLists.txt delete mode 100644 src/parsers/smt/smtlib.cpp delete mode 100644 src/parsers/smt/smtlib.h delete mode 100644 src/parsers/smt/smtlib_solver.cpp delete mode 100644 src/parsers/smt/smtlib_solver.h delete mode 100644 src/parsers/smt/smtparser.cpp delete mode 100644 src/parsers/smt/smtparser.h diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 05190f217..5ab56d1c7 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -75,10 +75,9 @@ def init_project_def(): add_lib('smtlogic_tactics', ['ackermannization', 'sat_solver', 'arith_tactics', 'bv_tactics', 'nlsat_tactic', 'smt_tactic', 'aig_tactic', 'fp', 'muz','qe','nlsat_smt_tactic'], 'tactic/smtlogics') add_lib('fpa_tactics', ['fpa', 'core_tactics', 'bv_tactics', 'sat_tactic', 'smt_tactic', 'arith_tactics', 'smtlogic_tactics'], 'tactic/fpa') add_lib('portfolio', ['smtlogic_tactics', 'sat_solver', 'ufbv_tactic', 'fpa_tactics', 'aig_tactic', 'fp', 'qe','sls_tactic', 'subpaving_tactic'], 'tactic/portfolio') - add_lib('smtparser', ['portfolio'], 'parsers/smt') add_lib('opt', ['smt', 'smtlogic_tactics', 'sls_tactic', 'sat_solver'], 'opt') API_files = ['z3_api.h', 'z3_ast_containers.h', 'z3_algebraic.h', 'z3_polynomial.h', 'z3_rcf.h', 'z3_fixedpoint.h', 'z3_optimization.h', 'z3_interp.h', 'z3_fpa.h', 'z3_spacer.h'] - add_lib('api', ['portfolio', 'smtparser', 'realclosure', 'interp', 'opt'], + add_lib('api', ['portfolio', 'realclosure', 'interp', 'opt'], includes2install=['z3.h', 'z3_v1.h', 'z3_macros.h'] + API_files) add_exe('shell', ['api', 'sat', 'extra_cmds','opt'], exe_name='z3') add_exe('test', ['api', 'fuzzing', 'simplex'], exe_name='test-z3', install=False) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cfe6e5265..7cde89ae2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -98,7 +98,6 @@ add_subdirectory(sat/sat_solver) add_subdirectory(tactic/smtlogics) add_subdirectory(tactic/fpa) add_subdirectory(tactic/portfolio) -add_subdirectory(parsers/smt) add_subdirectory(opt) add_subdirectory(api) add_subdirectory(api/dll) diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt index a413376ac..fcdbb1651 100644 --- a/src/api/CMakeLists.txt +++ b/src/api/CMakeLists.txt @@ -71,5 +71,4 @@ z3_add_component(api opt portfolio realclosure - smtparser ) diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 1e3f7a0a4..73fb2c212 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -19,7 +19,6 @@ Revision History: --*/ #include #include "api/api_context.h" -#include "parsers/smt/smtparser.h" #include "util/version.h" #include "ast/ast_pp.h" #include "ast/ast_ll_pp.h" @@ -89,8 +88,6 @@ namespace api { m_print_mode = Z3_PRINT_SMTLIB_FULL; m_searching = false; - m_smtlib_parser = 0; - m_smtlib_parser_has_decls = false; m_interruptable = 0; m_error_handler = &default_error_handler; @@ -111,7 +108,6 @@ namespace api { context::~context() { - reset_parser(); m_last_obj = 0; u_map::iterator it = m_allocated_objects.begin(); while (it != m_allocated_objects.end()) { @@ -304,39 +300,6 @@ namespace api { } } - - // ------------------------ - // - // Parser interface for backward compatibility - // - // ------------------------ - - void context::reset_parser() { - if (m_smtlib_parser) { - dealloc(m_smtlib_parser); - m_smtlib_parser = 0; - m_smtlib_parser_has_decls = false; - m_smtlib_parser_decls.reset(); - m_smtlib_parser_sorts.reset(); - } - SASSERT(!m_smtlib_parser_has_decls); - } - - void context::extract_smtlib_parser_decls() { - if (m_smtlib_parser) { - if (!m_smtlib_parser_has_decls) { - smtlib::symtable * table = m_smtlib_parser->get_benchmark()->get_symtable(); - table->get_func_decls(m_smtlib_parser_decls); - table->get_sorts(m_smtlib_parser_sorts); - m_smtlib_parser_has_decls = true; - } - } - else { - m_smtlib_parser_decls.reset(); - m_smtlib_parser_sorts.reset(); - } - } - // ------------------------ // // RCF manager diff --git a/src/api/api_context.h b/src/api/api_context.h index 6f8dc43f6..58893d1c1 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -220,19 +220,11 @@ namespace api { // ------------------------ // - // Parser interface for backward compatibility + // Parser interface // // ------------------------ - // TODO: move to a "parser" object visible to the external world. - std::string m_smtlib_error_buffer; - smtlib::parser * m_smtlib_parser; - bool m_smtlib_parser_has_decls; - ptr_vector m_smtlib_parser_decls; - ptr_vector m_smtlib_parser_sorts; - - void reset_parser(); - void extract_smtlib_parser_decls(); + std::string m_parser_error_buffer; }; diff --git a/src/api/api_interp.cpp b/src/api/api_interp.cpp index 416c71adf..d6f4e1128 100644 --- a/src/api/api_interp.cpp +++ b/src/api/api_interp.cpp @@ -510,31 +510,15 @@ extern "C" { read_error.clear(); try { std::string foo(filename); - if (foo.size() >= 5 && foo.substr(foo.size() - 5) == ".smt2"){ - Z3_ast assrts = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0); - Z3_app app = Z3_to_app(ctx, assrts); - int nconjs = Z3_get_app_num_args(ctx, app); - assertions.resize(nconjs); - for (int k = 0; k < nconjs; k++) - assertions[k] = Z3_get_app_arg(ctx, app, k); - } - else { - Z3_parse_smtlib_file(ctx, filename, 0, 0, 0, 0, 0, 0); - int numa = Z3_get_smtlib_num_assumptions(ctx); - int numf = Z3_get_smtlib_num_formulas(ctx); - int num = numa + numf; - - assertions.resize(num); - for (int j = 0; j < num; j++){ - if (j < numa) - assertions[j] = Z3_get_smtlib_assumption(ctx, j); - else - assertions[j] = Z3_get_smtlib_formula(ctx, j - numa); - } - } + Z3_ast assrts = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0); + Z3_app app = Z3_to_app(ctx, assrts); + int nconjs = Z3_get_app_num_args(ctx, app); + assertions.resize(nconjs); + for (int k = 0; k < nconjs; k++) + assertions[k] = Z3_get_app_arg(ctx, app, k); } catch (...) { - read_error << "SMTLIB parse error: " << Z3_get_smtlib_error(ctx); + read_error << "SMTLIB parse error: " << Z3_get_parser_error(ctx); read_msg = read_error.str(); *error = read_msg.c_str(); return false; diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index b3252281b..867117984 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -22,232 +22,16 @@ Revision History: #include "api/api_util.h" #include "cmd_context/cmd_context.h" #include "parsers/smt2/smt2parser.h" -#include "parsers/smt/smtparser.h" #include "solver/solver_na2as.h" extern "C" { - void init_smtlib_parser(Z3_context c, - unsigned num_sorts, - Z3_symbol const sort_names[], - Z3_sort const types[], - unsigned num_decls, - Z3_symbol const decl_names[], - Z3_func_decl const decls[]) { - mk_c(c)->reset_parser(); - mk_c(c)->m_smtlib_parser = smtlib::parser::create(mk_c(c)->m()); - mk_c(c)->m_smtlib_parser->initialize_smtlib(); - smtlib::symtable * table = mk_c(c)->m_smtlib_parser->get_benchmark()->get_symtable(); - for (unsigned i = 0; i < num_sorts; i++) { - table->insert(to_symbol(sort_names[i]), to_sort(types[i])); - } - for (unsigned i = 0; i < num_decls; i++) { - table->insert(to_symbol(decl_names[i]), to_func_decl(decls[i])); - } - } - - void Z3_API Z3_parse_smtlib_string(Z3_context c, - const char * str, - unsigned num_sorts, - Z3_symbol const sort_names[], - Z3_sort const sorts[], - unsigned num_decls, - Z3_symbol const decl_names[], - Z3_func_decl const decls[]) { - Z3_TRY; - LOG_Z3_parse_smtlib_string(c, str, num_sorts, sort_names, sorts, num_decls, decl_names, decls); - scoped_ptr outs = alloc(std::ostringstream); - bool ok = false; - RESET_ERROR_CODE(); - init_smtlib_parser(c, num_sorts, sort_names, sorts, num_decls, decl_names, decls); - mk_c(c)->m_smtlib_parser->set_error_stream(*outs); - try { - ok = mk_c(c)->m_smtlib_parser->parse_string(str); - } - catch (...) { - ok = false; - } - mk_c(c)->m_smtlib_error_buffer = outs->str(); - outs = nullptr; - if (!ok) { - mk_c(c)->reset_parser(); - SET_ERROR_CODE(Z3_PARSER_ERROR); - } - Z3_CATCH; - } - - void Z3_API Z3_parse_smtlib_file(Z3_context c, - const char * file_name, - unsigned num_sorts, - Z3_symbol const sort_names[], - Z3_sort const types[], - unsigned num_decls, - Z3_symbol const decl_names[], - Z3_func_decl const decls[]) { + Z3_string Z3_API Z3_get_parser_error(Z3_context c) { Z3_TRY; - LOG_Z3_parse_smtlib_file(c, file_name, num_sorts, sort_names, types, num_decls, decl_names, decls); - bool ok = false; - RESET_ERROR_CODE(); - scoped_ptr outs = alloc(std::ostringstream); - init_smtlib_parser(c, num_sorts, sort_names, types, num_decls, decl_names, decls); - mk_c(c)->m_smtlib_parser->set_error_stream(*outs); - try { - ok = mk_c(c)->m_smtlib_parser->parse_file(file_name); - } - catch(...) { - ok = false; - } - mk_c(c)->m_smtlib_error_buffer = outs->str(); - outs = nullptr; - if (!ok) { - mk_c(c)->reset_parser(); - SET_ERROR_CODE(Z3_PARSER_ERROR); - } - Z3_CATCH; - } - - unsigned Z3_API Z3_get_smtlib_num_formulas(Z3_context c) { - Z3_TRY; - LOG_Z3_get_smtlib_num_formulas(c); - RESET_ERROR_CODE(); - if (mk_c(c)->m_smtlib_parser) { - return mk_c(c)->m_smtlib_parser->get_benchmark()->get_num_formulas(); - } - SET_ERROR_CODE(Z3_NO_PARSER); - return 0; - Z3_CATCH_RETURN(0); - } - - Z3_ast Z3_API Z3_get_smtlib_formula(Z3_context c, unsigned i) { - Z3_TRY; - LOG_Z3_get_smtlib_formula(c, i); - RESET_ERROR_CODE(); - if (mk_c(c)->m_smtlib_parser) { - if (i < mk_c(c)->m_smtlib_parser->get_benchmark()->get_num_formulas()) { - ast * f = mk_c(c)->m_smtlib_parser->get_benchmark()->begin_formulas()[i]; - mk_c(c)->save_ast_trail(f); - RETURN_Z3(of_ast(f)); - } - else { - SET_ERROR_CODE(Z3_IOB); - } - } - else { - SET_ERROR_CODE(Z3_NO_PARSER); - } - RETURN_Z3(0); - Z3_CATCH_RETURN(0); - } - - unsigned Z3_API Z3_get_smtlib_num_assumptions(Z3_context c) { - Z3_TRY; - LOG_Z3_get_smtlib_num_assumptions(c); - RESET_ERROR_CODE(); - if (mk_c(c)->m_smtlib_parser) { - return mk_c(c)->m_smtlib_parser->get_benchmark()->get_num_axioms(); - } - SET_ERROR_CODE(Z3_NO_PARSER); - return 0; - Z3_CATCH_RETURN(0); - } - - Z3_ast Z3_API Z3_get_smtlib_assumption(Z3_context c, unsigned i) { - Z3_TRY; - LOG_Z3_get_smtlib_assumption(c, i); - RESET_ERROR_CODE(); - if (mk_c(c)->m_smtlib_parser) { - if (i < mk_c(c)->m_smtlib_parser->get_benchmark()->get_num_axioms()) { - ast * a = mk_c(c)->m_smtlib_parser->get_benchmark()->begin_axioms()[i]; - mk_c(c)->save_ast_trail(a); - RETURN_Z3(of_ast(a)); - } - else { - SET_ERROR_CODE(Z3_IOB); - } - } - else { - SET_ERROR_CODE(Z3_NO_PARSER); - } - RETURN_Z3(0); - Z3_CATCH_RETURN(0); - } - - unsigned Z3_API Z3_get_smtlib_num_decls(Z3_context c) { - Z3_TRY; - LOG_Z3_get_smtlib_num_decls(c); - RESET_ERROR_CODE(); - if (mk_c(c)->m_smtlib_parser) { - mk_c(c)->extract_smtlib_parser_decls(); - return mk_c(c)->m_smtlib_parser_decls.size(); - } - SET_ERROR_CODE(Z3_NO_PARSER); - return 0; - Z3_CATCH_RETURN(0); - } - - Z3_func_decl Z3_API Z3_get_smtlib_decl(Z3_context c, unsigned i) { - Z3_TRY; - LOG_Z3_get_smtlib_decl(c, i); + LOG_Z3_get_parser_error(c); RESET_ERROR_CODE(); - mk_c(c)->extract_smtlib_parser_decls(); - if (mk_c(c)->m_smtlib_parser) { - if (i < mk_c(c)->m_smtlib_parser_decls.size()) { - func_decl * d = mk_c(c)->m_smtlib_parser_decls[i]; - mk_c(c)->save_ast_trail(d); - RETURN_Z3(of_func_decl(d)); - } - else { - SET_ERROR_CODE(Z3_IOB); - } - } - else { - SET_ERROR_CODE(Z3_NO_PARSER); - } - RETURN_Z3(0); - Z3_CATCH_RETURN(0); - } - - unsigned Z3_API Z3_get_smtlib_num_sorts(Z3_context c) { - Z3_TRY; - LOG_Z3_get_smtlib_num_sorts(c); - RESET_ERROR_CODE(); - if (mk_c(c)->m_smtlib_parser) { - mk_c(c)->extract_smtlib_parser_decls(); - return mk_c(c)->m_smtlib_parser_sorts.size(); - } - SET_ERROR_CODE(Z3_NO_PARSER); - return 0; - Z3_CATCH_RETURN(0); - } - - Z3_sort Z3_API Z3_get_smtlib_sort(Z3_context c, unsigned i) { - Z3_TRY; - LOG_Z3_get_smtlib_sort(c, i); - RESET_ERROR_CODE(); - if (mk_c(c)->m_smtlib_parser) { - mk_c(c)->extract_smtlib_parser_decls(); - if (i < mk_c(c)->m_smtlib_parser_sorts.size()) { - sort* s = mk_c(c)->m_smtlib_parser_sorts[i]; - mk_c(c)->save_ast_trail(s); - RETURN_Z3(of_sort(s)); - } - else { - SET_ERROR_CODE(Z3_IOB); - } - } - else { - SET_ERROR_CODE(Z3_NO_PARSER); - } - RETURN_Z3(0); - Z3_CATCH_RETURN(0); - } - - Z3_string Z3_API Z3_get_smtlib_error(Z3_context c) { - Z3_TRY; - LOG_Z3_get_smtlib_error(c); - RESET_ERROR_CODE(); - return mk_c(c)->m_smtlib_error_buffer.c_str(); + return mk_c(c)->m_parser_error_buffer.c_str(); Z3_CATCH_RETURN(""); } diff --git a/src/api/z3_api.h b/src/api/z3_api.h index cf1c8fca7..56d9f69b7 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -5228,115 +5228,13 @@ extern "C" { Z3_symbol const decl_names[], Z3_func_decl const decls[]); - /** - \brief Parse the given string using the SMT-LIB parser. - - The symbol table of the parser can be initialized using the given sorts and declarations. - The symbols in the arrays \c sort_names and \c decl_names don't need to match the names - of the sorts and declarations in the arrays \c sorts and \c decls. This is an useful feature - since we can use arbitrary names to reference sorts and declarations defined using the C API. - - The formulas, assumptions and declarations defined in \c str can be extracted using the functions: - #Z3_get_smtlib_num_formulas, #Z3_get_smtlib_formula, #Z3_get_smtlib_num_assumptions, #Z3_get_smtlib_assumption, - #Z3_get_smtlib_num_decls, and #Z3_get_smtlib_decl. - - def_API('Z3_parse_smtlib_string', VOID, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) - */ - void Z3_API Z3_parse_smtlib_string(Z3_context c, - Z3_string str, - unsigned num_sorts, - Z3_symbol const sort_names[], - Z3_sort const sorts[], - unsigned num_decls, - Z3_symbol const decl_names[], - Z3_func_decl const decls[] - ); - - /** - \brief Similar to #Z3_parse_smtlib_string, but reads the benchmark from a file. - - def_API('Z3_parse_smtlib_file', VOID, (_in(CONTEXT), _in(STRING), _in(UINT), _in_array(2, SYMBOL), _in_array(2, SORT), _in(UINT), _in_array(5, SYMBOL), _in_array(5, FUNC_DECL))) - */ - void Z3_API Z3_parse_smtlib_file(Z3_context c, - Z3_string file_name, - unsigned num_sorts, - Z3_symbol const sort_names[], - Z3_sort const sorts[], - unsigned num_decls, - Z3_symbol const decl_names[], - Z3_func_decl const decls[] - ); - - /** - \brief Return the number of SMTLIB formulas parsed by the last call to #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. - - def_API('Z3_get_smtlib_num_formulas', UINT, (_in(CONTEXT), )) - */ - unsigned Z3_API Z3_get_smtlib_num_formulas(Z3_context c); - - /** - \brief Return the i-th formula parsed by the last call to #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. - - \pre i < Z3_get_smtlib_num_formulas(c) - - def_API('Z3_get_smtlib_formula', AST, (_in(CONTEXT), _in(UINT))) - */ - Z3_ast Z3_API Z3_get_smtlib_formula(Z3_context c, unsigned i); - - /** - \brief Return the number of SMTLIB assumptions parsed by #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. - - def_API('Z3_get_smtlib_num_assumptions', UINT, (_in(CONTEXT), )) - */ - unsigned Z3_API Z3_get_smtlib_num_assumptions(Z3_context c); - - /** - \brief Return the i-th assumption parsed by the last call to #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. - - \pre i < Z3_get_smtlib_num_assumptions(c) - - def_API('Z3_get_smtlib_assumption', AST, (_in(CONTEXT), _in(UINT))) - */ - Z3_ast Z3_API Z3_get_smtlib_assumption(Z3_context c, unsigned i); - - /** - \brief Return the number of declarations parsed by #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. - - def_API('Z3_get_smtlib_num_decls', UINT, (_in(CONTEXT), )) - */ - unsigned Z3_API Z3_get_smtlib_num_decls(Z3_context c); - - /** - \brief Return the i-th declaration parsed by the last call to #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. - - \pre i < Z3_get_smtlib_num_decls(c) - - def_API('Z3_get_smtlib_decl', FUNC_DECL, (_in(CONTEXT), _in(UINT))) - */ - Z3_func_decl Z3_API Z3_get_smtlib_decl(Z3_context c, unsigned i); - - /** - \brief Return the number of sorts parsed by #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. - - def_API('Z3_get_smtlib_num_sorts', UINT, (_in(CONTEXT), )) - */ - unsigned Z3_API Z3_get_smtlib_num_sorts(Z3_context c); - - /** - \brief Return the i-th sort parsed by the last call to #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. - - \pre i < Z3_get_smtlib_num_sorts(c) - - def_API('Z3_get_smtlib_sort', SORT, (_in(CONTEXT), _in(UINT))) - */ - Z3_sort Z3_API Z3_get_smtlib_sort(Z3_context c, unsigned i); /** \brief Retrieve that last error message information generated from parsing. - def_API('Z3_get_smtlib_error', STRING, (_in(CONTEXT), )) + def_API('Z3_get_parser_error', STRING, (_in(CONTEXT), )) */ - Z3_string Z3_API Z3_get_smtlib_error(Z3_context c); + Z3_string Z3_API Z3_get_parser_error(Z3_context c); /*@}*/ /** @name Error Handling */ diff --git a/src/parsers/smt/CMakeLists.txt b/src/parsers/smt/CMakeLists.txt deleted file mode 100644 index 2edf7b679..000000000 --- a/src/parsers/smt/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -z3_add_component(smtparser - SOURCES - smtlib.cpp - smtlib_solver.cpp - smtparser.cpp - COMPONENT_DEPENDENCIES - portfolio -) diff --git a/src/parsers/smt/smtlib.cpp b/src/parsers/smt/smtlib.cpp deleted file mode 100644 index 71dd48156..000000000 --- a/src/parsers/smt/smtlib.cpp +++ /dev/null @@ -1,258 +0,0 @@ - -/*++ -Copyright (c) 2015 Microsoft Corporation - ---*/ - - -#include "parsers/smt/smtlib.h" -#include "ast/ast_pp.h" -#include "ast/ast_smt2_pp.h" - -#ifdef _WINDOWS -#ifdef ARRAYSIZE -#undef ARRAYSIZE -#endif -#include -#include -#endif - -#include - - -using namespace smtlib; - -// -------------------------------------------------------------------------- -// symtable - -symtable::~symtable() { - reset(); -} - -void symtable::reset() { - svector*> range; - m_ids.get_range(range); - for (unsigned i = 0; i < range.size(); ++i) { - ptr_vector const & v = *range[i]; - for (unsigned j = 0; j < v.size(); ++j) { - m_manager.dec_ref(v[j]); - } - dealloc(range[i]); - } - m_ids.reset(); - ptr_vector sorts; - m_sorts1.get_range(sorts); - for (unsigned i = 0; i < sorts.size(); ++i) { - m_manager.dec_ref(sorts[i]); - } - m_sorts1.reset(); - ptr_vector sort_builders; - m_sorts.get_range(sort_builders); - for (unsigned i = 0; i < sort_builders.size(); ++i) { - dealloc(sort_builders[i]); - } - m_sorts.reset(); -} - - -void symtable::insert(symbol s, func_decl * d) { - ptr_vector* decls = 0; - m_manager.inc_ref(d); - if (!m_ids.find(s, decls)) { - SASSERT(!decls); - decls = alloc(ptr_vector); - decls->push_back(d); - m_ids.insert(s, decls); - } - else { - SASSERT(decls); - if ((*decls)[0] != d) { - decls->push_back(d); - } - else { - m_manager.dec_ref(d); - } - } -} - -bool symtable::find1(symbol s, func_decl*& d) { - ptr_vector* decls = 0; - - if (!m_ids.find(s, decls)) { - SASSERT(!decls); - return false; - } - SASSERT(decls && !decls->empty()); - d = (*decls)[0]; - return true; -} - -bool symtable::find_overload(symbol s, ptr_vector const & dom, func_decl * & d) { - ptr_vector* decls = 0; - d = 0; - if (!m_ids.find(s, decls)) { - SASSERT(!decls); - return false; - } - SASSERT(decls); - for (unsigned i = 0; i < decls->size(); ++i) { - func_decl* decl = (*decls)[i]; - if (decl->is_associative() && decl->get_arity() > 0) { - for (unsigned j = 0; j < dom.size(); ++j) { - if (dom[j] != decl->get_domain(0)) { - goto try_next; - } - } - d = decl; - return true; - } - - if (decl->get_arity() != dom.size()) { - goto try_next; - } - for (unsigned j = 0; j < decl->get_arity(); ++j) { - if (decl->get_domain(j) != dom[j]) { - goto try_next; - } - } - d = decl; - return true; - - try_next: - if (decl->get_family_id() == m_manager.get_basic_family_id() && decl->get_decl_kind() == OP_DISTINCT) { - // we skip type checking for 'distinct' - d = decl; - return true; - } - } - return false; -} - -// Store in result the func_decl that are not attached to any family id. -// That is, the uninterpreted constants and function declarations. -void symtable::get_func_decls(ptr_vector & result) const { - svector*> tmp; - m_ids.get_range(tmp); - svector*>::const_iterator it = tmp.begin(); - svector*>::const_iterator end = tmp.end(); - for (; it != end; ++it) { - ptr_vector * curr = *it; - if (curr) { - ptr_vector::const_iterator it2 = curr->begin(); - ptr_vector::const_iterator end2 = curr->end(); - for (; it2 != end2; ++it2) { - func_decl * d = *it2; - if (d && d->get_family_id() == null_family_id) { - result.push_back(d); - } - } - } - } -} - -void symtable::insert(symbol s, sort_builder* sb) { - m_sorts.insert(s, sb); -} - -bool symtable::lookup(symbol s, sort_builder*& sb) { - return m_sorts.find(s, sb); -} - -void symtable::push_sort(symbol name, sort* srt) { - m_sorts.begin_scope(); - sort_builder* sb = alloc(basic_sort_builder,srt); - m_sorts.insert(name, sb); - m_sorts_trail.push_back(sb); -} - -void symtable::pop_sorts(unsigned num_sorts) { - while (num_sorts > 0) { - dealloc(m_sorts_trail.back()); - m_sorts_trail.pop_back(); - m_sorts.end_scope(); - } -} - -void symtable::get_sorts(ptr_vector& result) const { - vector tmp; - m_sorts1.get_range(tmp); - for (unsigned i = 0; i < tmp.size(); ++i) { - if (tmp[i]->get_family_id() == null_family_id) { - result.push_back(tmp[i]); - } - } -} - - -// -------------------------------------------------------------------------- -// theory - -func_decl * theory::declare_func(symbol const & id, sort_ref_buffer & domain, sort * range, - bool is_assoc, bool is_comm, bool is_inj) { - func_decl * decl = m_ast_manager.mk_func_decl(id, domain.size(), domain.c_ptr(), range, - is_assoc, is_comm, is_inj); - - m_symtable.insert(id, decl); - m_asts.push_back(decl); - return decl; -} - - -sort * theory::declare_sort(symbol const & id) { - sort * decl = m_ast_manager.mk_uninterpreted_sort(id); - m_symtable.insert(id, decl); - m_asts.push_back(decl); - return decl; -} - - -bool theory::get_func_decl(symbol id, func_decl * & decl) { - return m_symtable.find1(id, decl); -} - -bool theory::get_sort(symbol id, sort* & s) { - return m_symtable.find(id, s); -} - -bool theory::get_const(symbol id, expr * & term) { - func_decl* decl = 0; - if (!get_func_decl(id,decl)) { - return false; - } - if (decl->get_arity() != 0) { - return false; - } - term = m_ast_manager.mk_const(decl); - m_asts.push_back(term); - return true; -} - -void benchmark::display_as_smt2(std::ostream & out) const { - if (m_logic != symbol::null) - out << "(set-logic " << m_logic << ")\n"; - out << "(set-info :smt-lib-version 2.0)\n"; - out << "(set-info :status "; - switch (m_status) { - case SAT: out << "sat"; break; - case UNSAT: out << "unsat"; break; - default: out << "unknown"; break; - } - out << ")\n"; -#if 0 - ast_manager & m = m_ast_manager; - ptr_vector decls; - m_symtable.get_func_decls(decls); - ptr_vector::const_iterator it = decls.begin(); - ptr_vector::const_iterator end = decls.end(); - for (; it != end; ++it) { - func_decl * f = *it; - out << "(declare-fun " << f->get_name() << " ("; - for (unsigned i = 0; i < f->get_arity(); i++) { - if (i > 0) out << " "; - out << mk_ismt2_pp(f->get_domain(i), m); - } - out << ") " << mk_ismt2_pp(f->get_range(), m); - out << ")\n"; - } -#endif -} diff --git a/src/parsers/smt/smtlib.h b/src/parsers/smt/smtlib.h deleted file mode 100644 index f037e3d74..000000000 --- a/src/parsers/smt/smtlib.h +++ /dev/null @@ -1,232 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - smtlib.h - -Abstract: - - SMT library utilities - -Author: - - Nikolaj Bjorner (nbjorner) 2006-09-29 - -Revision History: - ---*/ -#ifndef SMTLIB_H_ -#define SMTLIB_H_ - -#include "ast/ast.h" -#include "util/symbol_table.h" -#include "util/map.h" -#include "ast/arith_decl_plugin.h" - -namespace smtlib { - - class sort_builder { - public: - virtual ~sort_builder() {} - virtual bool apply(unsigned num_params, parameter const* params, sort_ref& result) = 0; - virtual char const* error_message() { return ""; } - }; - - class basic_sort_builder : public sort_builder { - sort* m_sort; - public: - basic_sort_builder(sort* s) : m_sort(s) {} - - virtual bool apply(unsigned np, parameter const*, sort_ref& result) { - result = m_sort; - return m_sort && np != 0; - } - }; - - - class symtable { - ast_manager& m_manager; - symbol_table m_sorts1; - symbol_table m_sorts; - ptr_vector m_sorts_trail; - symbol_table* > m_ids; - - public: - - symtable(ast_manager& m): m_manager(m) {} - - ~symtable(); - - void reset(); - - void insert(symbol s, func_decl * d); - - bool find(symbol s, ptr_vector * & decls) { - return m_ids.find(s, decls); - } - - bool find1(symbol s, func_decl * & d); - - bool find_overload(symbol s, ptr_vector const & dom, func_decl * & d); - - void insert(symbol s, sort * d) { - sort * d2; - if (m_sorts1.find(s, d2)) { - m_manager.dec_ref(d2); - } - m_manager.inc_ref(d); - m_sorts1.insert(s, d); - } - - bool find(symbol s, sort * & d) { - return m_sorts1.find(s, d); - } - - void insert(symbol s, sort_builder* sb); - - bool lookup(symbol s, sort_builder*& sb); - - void push_sort(symbol s, sort*); - - void pop_sorts(unsigned num_sorts); - - void get_func_decls(ptr_vector & result) const; - - void get_sorts(ptr_vector& result) const; - }; - - class theory { - public: - typedef ptr_vector::const_iterator expr_iterator; - - theory(ast_manager & ast_manager, symbol const& name): - m_name(name), - m_ast_manager(ast_manager), - m_symtable(ast_manager), - m_asts(ast_manager) - {} - - virtual ~theory() {} - - symtable * get_symtable() { return &m_symtable; } - - void insert(sort * s) { m_symtable.insert(s->get_name(), s); } - - void insert(func_decl * c) { m_symtable.insert(c->get_name(), c); } - - func_decl * declare_func(symbol const & id, sort_ref_buffer & domain, sort * range, - bool is_assoc, bool is_comm, bool is_inj); - - sort * declare_sort(symbol const & id); - - void add_axiom(expr * axiom) { - m_asts.push_back(axiom); - m_axioms.push_back(axiom); - } - - expr_iterator begin_axioms() const { - return m_axioms.begin(); - } - - unsigned get_num_axioms() const { - return m_axioms.size(); - } - - expr * const * get_axioms() const { - return m_axioms.c_ptr(); - } - - expr_iterator end_axioms() const { - return m_axioms.end(); - } - - void add_assumption(expr * axiom) { - m_asts.push_back(axiom); - m_assumptions.push_back(axiom); - } - - unsigned get_num_assumptions() const { - return m_assumptions.size(); - } - - expr * const * get_assumptions() const { - return m_assumptions.c_ptr(); - } - - bool get_func_decl(symbol, func_decl*&); - - bool get_sort(symbol, sort*&); - - bool get_const(symbol, expr*&); - - void set_name(symbol const& name) { m_name = name; } - - symbol const get_name() const { return m_name; } - protected: - symbol m_name; - ast_manager& m_ast_manager; - ptr_vector m_axioms; - ptr_vector m_assumptions; - symtable m_symtable; - ast_ref_vector m_asts; - - private: - theory& operator=(theory const&); - - theory(theory const&); - }; - - class benchmark : public theory { - public: - enum status { - UNKNOWN, - SAT, - UNSAT - }; - - benchmark(ast_manager & ast_manager, symbol const & name) : - theory(ast_manager, name), - m_status(UNKNOWN) {} - - virtual ~benchmark() {} - - status get_status() const { return m_status; } - void set_status(status status) { m_status = status; } - - symbol get_logic() const { - if (m_logic == symbol::null) { - return symbol("ALL"); - } - return m_logic; - } - - void set_logic(symbol const & s) { m_logic = s; } - - unsigned get_num_formulas() const { - return m_formulas.size(); - } - - expr_iterator begin_formulas() const { - return m_formulas.begin(); - } - - expr_iterator end_formulas() const { - return m_formulas.end(); - } - - void add_formula(expr * formula) { - m_asts.push_back(formula); - m_formulas.push_back(formula); - } - - void display_as_smt2(std::ostream & out) const; - - private: - status m_status; - symbol m_logic; - ptr_vector m_formulas; - }; -}; - -#endif diff --git a/src/parsers/smt/smtlib_solver.cpp b/src/parsers/smt/smtlib_solver.cpp deleted file mode 100644 index 339be2ddd..000000000 --- a/src/parsers/smt/smtlib_solver.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - smtlib_solver.cpp - -Abstract: - - SMT based solver. - -Author: - - Nikolaj Bjorner (nbjorner) 2006-11-3. - -Revision History: - ---*/ - -#include "parsers/smt/smtparser.h" -#include "parsers/smt/smtlib_solver.h" -#include "util/warning.h" -#include "ast/ast_pp.h" -#include "ast/ast_ll_pp.h" -#include "ast/well_sorted.h" -#include "model/model.h" -#include "model/model_v2_pp.h" -#include "solver/solver.h" -#include "tactic/portfolio/smt_strategic_solver.h" -#include "cmd_context/cmd_context.h" -#include "model/model_params.hpp" -#include "parsers/util/parser_params.hpp" - -namespace smtlib { - - solver::solver(): - m_ast_manager(m_params.m_proof ? PGM_ENABLED : PGM_DISABLED, - m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0), - m_ctx(0), - m_error_code(0) { - parser_params ps; - m_parser = parser::create(m_ast_manager, ps.ignore_user_patterns()); - m_parser->initialize_smtlib(); - } - - solver::~solver() { - if (m_ctx) - dealloc(m_ctx); - } - - bool solver::solve_smt(char const * benchmark_file) { - IF_VERBOSE(100, verbose_stream() << "parsing...\n";); - if (!m_parser->parse_file(benchmark_file)) { - if (benchmark_file) { - warning_msg("could not parse file '%s'.", benchmark_file); - } - else { - warning_msg("could not parse input stream."); - } - m_error_code = ERR_PARSER; - return false; - } - benchmark * benchmark = m_parser->get_benchmark(); - solve_benchmark(*benchmark); - return true; - } - - bool solver::solve_smt_string(char const * benchmark_string) { - if (!m_parser->parse_string(benchmark_string)) { - warning_msg("could not parse string '%s'.", benchmark_string); - return false; - } - benchmark * benchmark = m_parser->get_benchmark(); - solve_benchmark(*benchmark); - return true; - } - - void solver::display_statistics() { - if (m_ctx) - m_ctx->display_statistics(); - } - - void solver::solve_benchmark(benchmark & benchmark) { - if (benchmark.get_num_formulas() == 0) { - // Hack: it seems SMT-LIB allow benchmarks without any :formula - benchmark.add_formula(m_ast_manager.mk_true()); - } - m_ctx = alloc(cmd_context, true, &m_ast_manager, benchmark.get_logic()); - m_ctx->set_solver_factory(mk_smt_strategic_solver_factory()); - theory::expr_iterator fit = benchmark.begin_formulas(); - theory::expr_iterator fend = benchmark.end_formulas(); - for (; fit != fend; ++fit) - solve_formula(benchmark, *fit); - } - - void solver::solve_formula(benchmark const & benchmark, expr * f) { - IF_VERBOSE(100, verbose_stream() << "starting...\n";); - m_ctx->reset(); - for (unsigned i = 0; i < benchmark.get_num_axioms(); i++) - m_ctx->assert_expr(benchmark.get_axioms()[i]); - m_ctx->assert_expr(f); - m_ctx->check_sat(benchmark.get_num_assumptions(), benchmark.get_assumptions()); - check_sat_result * r = m_ctx->get_check_sat_result(); - if (r != 0) { - proof * pr = r->get_proof(); - if (pr != 0 && m_params.m_proof) - std::cout << mk_ll_pp(pr, m_ast_manager, false, false); - model_ref md; - if (r->status() != l_false) r->get_model(md); - if (md.get() != 0 && m_params.m_model) { - model_params p; - model_v2_pp(std::cout, *(md.get()), p.partial()); - } - } - else { - m_error_code = ERR_UNKNOWN_RESULT; - } - } -}; diff --git a/src/parsers/smt/smtlib_solver.h b/src/parsers/smt/smtlib_solver.h deleted file mode 100644 index 6288c360b..000000000 --- a/src/parsers/smt/smtlib_solver.h +++ /dev/null @@ -1,48 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - smtlib_solver.h - -Abstract: - - SMT based solver. - -Author: - - Nikolaj Bjorner (nbjorner) 2006-11-3. - -Revision History: - ---*/ -#ifndef SMTLIB_SOLVER_H_ -#define SMTLIB_SOLVER_H_ - -#include "parsers/smt/smtparser.h" -#include "cmd_context/context_params.h" -#include "util/lbool.h" - -class cmd_context; - -namespace smtlib { - class solver { - context_params m_params; - ast_manager m_ast_manager; - cmd_context * m_ctx; - scoped_ptr m_parser; - unsigned m_error_code; - public: - solver(); - ~solver(); - bool solve_smt(char const * benchmark_file); - bool solve_smt_string(char const * benchmark_string); - void display_statistics(); - unsigned get_error_code() const { return m_error_code; } - private: - void solve_benchmark(benchmark & benchmark); - void solve_formula(benchmark const & benchmark, expr * f); - }; -}; - -#endif diff --git a/src/parsers/smt/smtparser.cpp b/src/parsers/smt/smtparser.cpp deleted file mode 100644 index 15f094e33..000000000 --- a/src/parsers/smt/smtparser.cpp +++ /dev/null @@ -1,2760 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - smtparser.cpp - -Abstract: - - SMT parser into ast. - -Author: - - Nikolaj Bjorner (nbjorner) 2006-10-4. - Leonardo de Moura (leonardo) - -Revision History: ---*/ -#include -#include -#include -#include -#include -#include "util/region.h" -#include "parsers/util/scanner.h" -#include "util/symbol.h" -#include "util/vector.h" -#include "util/symbol_table.h" -#include "parsers/smt/smtlib.h" -#include "parsers/smt/smtparser.h" -#include "ast/ast_pp.h" -#include "ast/bv_decl_plugin.h" -#include "ast/array_decl_plugin.h" -#include "util/warning.h" -#include "util/error_codes.h" -#include "parsers/util/pattern_validation.h" -#include "ast/rewriter/var_subst.h" -#include "ast/well_sorted.h" -#include "util/str_hashtable.h" -#include "util/stopwatch.h" - -class id_param_info { - symbol m_string; - unsigned m_num_params; - parameter m_params[0]; -public: - id_param_info(symbol const& s, unsigned n, parameter const* p) : m_string(s), m_num_params(n) { - for (unsigned i = 0; i < n; ++i) { - new (&(m_params[i])) parameter(); - m_params[i] = p[i]; - } - } - symbol string() const { return m_string; } - parameter * params() { return m_params; } - unsigned num_params() const { return m_num_params; } -}; - -class proto_region { - ptr_vector m_rationals; - ptr_vector m_id_infos; - region m_region; -public: - proto_region() { } - - ~proto_region() { reset(); } - - rational* allocate(rational const & n) { - rational* r = alloc(rational, n); - m_rationals.push_back(r); - return r; - } - - id_param_info* allocate(vector const& params, symbol const & s) { - unsigned size = sizeof(id_param_info) + sizeof(parameter)*(params.size()); - id_param_info* r = static_cast(m_region.allocate(size)); - new (r) id_param_info(s, params.size(), params.c_ptr()); - m_id_infos.push_back(r); - return r; - } - - void* allocate(size_t s) { return m_region.allocate(s); } - - void reset() { - for (unsigned i = 0; i < m_rationals.size(); ++i) { - dealloc(m_rationals[i]); - } - for (unsigned i = 0; i < m_id_infos.size(); ++i) { - unsigned n = m_id_infos[i]->num_params(); - for (unsigned j = 0; j < n; ++j) { - m_id_infos[i]->params()[j].~parameter(); - } - } - m_rationals.reset(); - m_id_infos.reset(); - m_region.reset(); - } - -private: - -}; - -inline void * operator new(size_t s, proto_region& r) { return r.allocate(s); } -inline void * operator new[](size_t s, proto_region & r) { return r.allocate(s); } -inline void operator delete(void*, proto_region& r) {} -inline void operator delete[](void *, proto_region& r) {} - -class proto_expr { -public: - - enum kind_t { - ID, - STRING, - COMMENT, - ANNOTATION, - INT, - FLOAT, - CONS - }; -private: - - int m_kind:8; - int m_line:24; - int m_pos; - union { - id_param_info* m_id_info; - rational* m_number; - proto_expr** m_children; - }; - -public: - - symbol string() { - if (m_kind == INT || m_kind == FLOAT) { - std::string s = m_number->to_string(); - return symbol(s.c_str()); - } - if (m_kind == CONS) { - return symbol(""); - } - SASSERT(m_kind == STRING || m_kind == COMMENT || m_kind == ID || m_kind == ANNOTATION); - return m_id_info->string(); - } - - rational const& number() { - SASSERT(m_kind == INT || m_kind == FLOAT); - return *m_number; - } - - proto_expr* const* children() const { - if (m_kind == CONS) { - return m_children; - } - else { - return 0; - } - } - - int line() { return m_line; } - int pos() { return m_pos; } - kind_t kind() { return static_cast(m_kind); } - - unsigned num_params() const { - SASSERT(m_kind == ID); - return m_id_info->num_params(); - } - - parameter * params() { - SASSERT(m_kind == ID); - return m_id_info->params(); - } - - proto_expr(proto_region & region, kind_t kind, symbol const & s, vector const & params, int line, int pos): - m_kind(kind), - m_line(line), - m_pos(pos), - m_id_info(region.allocate(params, s)) { - SASSERT(kind != CONS); - SASSERT(kind != INT); - SASSERT(kind != FLOAT); - } - - proto_expr(proto_region& region, bool is_int, rational const & n, int line, int pos): - m_kind(is_int?INT:FLOAT), - m_line(line), - m_pos(pos), - m_number(region.allocate(n)) - {} - - proto_expr(proto_region& region, ptr_vector& proto_exprs, int line, int pos): - m_kind(CONS), - m_line(line), - m_pos(pos) { - // - // null terminated list of proto_expression pointers. - // - unsigned num_children = proto_exprs.size(); - m_children = new (region) proto_expr*[num_children+1]; - for (unsigned i = 0; i < num_children; ++i) { - m_children[i] = proto_exprs[i]; - } - m_children[num_children] = 0; - } - - ~proto_expr() {} - - - static proto_expr* copy(proto_region& r, proto_expr* e) { - switch(e->kind()) { - case proto_expr::CONS: { - ptr_vector args; - proto_expr* const* children = e->children(); - while (children && *children) { - args.push_back(copy(r, *children)); - ++children; - } - return new (r) proto_expr(r, args, e->line(), e->pos()); - } - case proto_expr::INT: { - return new (r) proto_expr(r, true, e->number(), e->line(), e->pos()); - } - case proto_expr::FLOAT: { - return new (r) proto_expr(r, false, e->number(), e->line(), e->pos()); - } - case proto_expr::ID: { - vector params; - for (unsigned i = 0; i < e->num_params(); ++i) { - params.push_back(e->params()[i]); - } - return new (r) proto_expr(r, e->kind(), e->string(), params, e->line(), e->pos()); - } - default: { - vector params; - return new (r) proto_expr(r, e->kind(), e->string(), params, e->line(), e->pos()); - } - } - } - -private: - - proto_expr(proto_expr const & other); - proto_expr& operator=(proto_expr const & other); -}; - - -// -// build up proto_expr tree from token stream. -// - -class proto_expr_parser { - proto_region& m_region; - scanner& m_scanner; - std::ostream& m_err; - bool m_at_eof; -public: - proto_expr_parser(proto_region& region, scanner& scanner, std::ostream& err): - m_region(region), - m_scanner(scanner), - m_err(err), - m_at_eof(false) { - } - - ~proto_expr_parser() {} - - bool parse(ptr_vector & proto_exprs, bool parse_single_expr = false) { - scanner::token token; - vector stack; - proto_expr* result = 0; - - stack.push_back(frame(PROTO_EXPRS_PRE)); - - token = m_scanner.scan(); - - if (token == scanner::EOF_TOKEN) { - proto_exprs.reset(); - return true; - } - - while (!stack.empty()) { - - if (token == scanner::EOF_TOKEN) { - break; - } - - if (token == scanner::ERROR_TOKEN) { - print_error("unexpected token"); - goto done; - } - - switch(stack.back().m_state) { - - case PROTO_EXPR: - switch (token) { - case scanner::LEFT_PAREN: - stack.back().m_state = PROTO_EXPRS_PRE; - token = m_scanner.scan(); - break; - default: - stack.back().m_state = ATOM; - break; - } - break; - - case ATOM: - SASSERT(!result); - switch(token) { - case scanner::ID_TOKEN: - result = new (m_region) proto_expr(m_region, proto_expr::ID, m_scanner.get_id(), m_scanner.get_params(), - m_scanner.get_line(), m_scanner.get_pos()); - break; - case scanner::INT_TOKEN: - result = new (m_region) proto_expr(m_region, true, m_scanner.get_number(), m_scanner.get_line(), - m_scanner.get_pos()); - break; - case scanner::FLOAT_TOKEN: - result = new (m_region) proto_expr(m_region, false, m_scanner.get_number(), m_scanner.get_line(), - m_scanner.get_pos()); - break; - case scanner::STRING_TOKEN: - result = new (m_region) proto_expr(m_region, proto_expr::STRING, m_scanner.get_id(), m_scanner.get_params(), - m_scanner.get_line(), m_scanner.get_pos()); - break; - case scanner::COMMENT_TOKEN: - result = new (m_region) proto_expr(m_region, proto_expr::COMMENT, m_scanner.get_id(), m_scanner.get_params(), - m_scanner.get_line(), m_scanner.get_pos()); - break; - case scanner::COLON: - token = m_scanner.scan(); - if (token == scanner::ID_TOKEN) { - result = new (m_region) proto_expr(m_region, proto_expr::ANNOTATION, m_scanner.get_id(), - m_scanner.get_params(), m_scanner.get_line(), m_scanner.get_pos()); - } - else { - print_error("unexpected identifier ':'"); - token = scanner::ERROR_TOKEN; - goto done; - } - break; - default: - print_error("unexpected token"); - token = scanner::ERROR_TOKEN; - goto done; - } - stack.pop_back(); - SASSERT(!stack.empty()); - stack.back().m_proto_exprs.push_back(result); - result = 0; - if (parse_single_expr && stack.size() == 1) { - goto done; - } - token = m_scanner.scan(); - break; - - case PROTO_EXPRS_PRE: - SASSERT(!result); - switch(token) { - case scanner::RIGHT_PAREN: - result = new (m_region) proto_expr(m_region, stack.back().m_proto_exprs, m_scanner.get_line(), - m_scanner.get_pos()); - stack.pop_back(); - - if (stack.empty()) { - print_error("unexpected right parenthesis"); - token = scanner::ERROR_TOKEN; - result = 0; - goto done; - } - stack.back().m_proto_exprs.push_back(result); - if (parse_single_expr && stack.size() == 1) { - goto done; - } - result = 0; - token = m_scanner.scan(); - break; - - case scanner::EOF_TOKEN: - m_at_eof = true; - break; - - case scanner::ERROR_TOKEN: - print_error("could not parse expression"); - goto done; - - default: - stack.back().m_state = PROTO_EXPRS_POST; - stack.push_back(frame(PROTO_EXPR)); - break; - } - break; - - case PROTO_EXPRS_POST: - stack.back().m_state = PROTO_EXPRS_PRE; - break; - } - } - - done: - - if (stack.size() == 1) { - for (unsigned i = 0; i < stack.back().m_proto_exprs.size(); ++i) { - proto_exprs.push_back(stack.back().m_proto_exprs[i]); - } - return true; - } - - if (stack.size() == 2) { - proto_exprs.push_back(new (m_region) proto_expr(m_region, stack.back().m_proto_exprs, m_scanner.get_line(), - m_scanner.get_pos())); - return true; - } - - print_error("unexpected nesting of parenthesis: ", stack.size()); - return false; - } - - int get_line() { - return m_scanner.get_line(); - } - - bool at_eof() const { - return m_at_eof; - } - -private: - - template - void print_error(char const* msg1, T msg2) { - m_err << "ERROR: line " << m_scanner.get_line() - << " column " << m_scanner.get_pos() << ": " - << msg1 << msg2 << "\n"; - } - - void print_error(char const* msg) { - print_error(msg, ""); - } - - // stack frame: - enum frame_state { - PROTO_EXPR, - PROTO_EXPRS_PRE, - PROTO_EXPRS_POST, - ATOM - }; - - class frame { - public: - frame_state m_state; - ptr_vector m_proto_exprs; - frame(frame_state state): - m_state(state){ - } - frame(frame const & other): - m_state(other.m_state), - m_proto_exprs(other.m_proto_exprs) { - } - private: - frame& operator=(frame const &); - }; - -}; - -using namespace smtlib; - -class idbuilder { -public: - virtual ~idbuilder() {} - virtual bool apply(expr_ref_vector const & args, expr_ref & result) = 0; -}; - -class builtin_sort_builder : public sort_builder { - ast_manager& m_manager; - family_id m_fid; - decl_kind m_kind; -public: - builtin_sort_builder(ast_manager& m, family_id fid, decl_kind k) : - m_manager(m), m_fid(fid), m_kind(k) {} - - virtual bool apply(unsigned num_params, parameter const* params, sort_ref & result) { - result = m_manager.mk_sort(m_fid, m_kind, num_params, params); - return result.get() != 0; - } -}; - -class array_sort : public builtin_sort_builder { -public: - array_sort(ast_manager& m) : - builtin_sort_builder(m, m.mk_family_id("array"), ARRAY_SORT) {} -}; - -class bv_sort : public builtin_sort_builder { -public: - bv_sort(ast_manager& m) : - builtin_sort_builder(m, m.mk_family_id("bv"), BV_SORT) {} -}; - -class user_sort : public sort_builder { - user_sort_plugin * m_plugin; - decl_kind m_kind; - symbol m_name; - unsigned m_num_args; - std::string m_error_message; -public: - user_sort(ast_manager& m, unsigned num_args, symbol name): - m_name(name), - m_num_args(num_args) { - m_plugin = m.get_user_sort_plugin(); - m_kind = m_plugin->register_name(name); - } - - ~user_sort() {} - - virtual bool apply(unsigned num_params, parameter const* params, sort_ref & result) { - if (num_params != m_num_args) { - std::ostringstream strm; - strm << "wrong number of arguments passed to " << m_name << " " - << m_num_args << " expected, but " << num_params << " given"; - m_error_message = strm.str(); - return false; - } - result = m_plugin->mk_sort(m_kind, num_params, params); - return true; - } - - virtual char const* error_message() { - return m_error_message.c_str(); - } -}; - -class smtparser : public parser { - struct builtin_op { - family_id m_family_id; - decl_kind m_kind; - builtin_op() : m_family_id(null_family_id), m_kind(0) {} - builtin_op(family_id fid, decl_kind k) : m_family_id(fid), m_kind(k) {} - }; - - class add_plugins { - - public: - add_plugins(ast_manager& m) { -#define REGISTER_PLUGIN(NAME, MK) { \ - family_id fid = m.mk_family_id(symbol(NAME)); \ - if (!m.has_plugin(fid)) { \ - m.register_plugin(fid, MK); \ - } \ - } ((void) 0) - - REGISTER_PLUGIN("arith", alloc(arith_decl_plugin)); - REGISTER_PLUGIN("bv", alloc(bv_decl_plugin)); - REGISTER_PLUGIN("array", alloc(array_decl_plugin)); - - }; - }; - - ast_manager& m_manager; - add_plugins m_plugins; - arith_util m_anum_util; - bv_util m_bvnum_util; - pattern_validator m_pattern_validator; - bool m_ignore_user_patterns; - unsigned m_binding_level; // scope level for bound vars - benchmark m_benchmark; // currently parsed benchmark - - typedef map op_map; - op_map m_builtin_ops; - op_map m_builtin_sorts; - - symbol m_let; // commonly used symbols. - symbol m_flet; - symbol m_forall; - symbol m_exists; - symbol m_lblneg; - symbol m_lblpos; - symbol m_associative; - symbol m_commutative; - symbol m_injective; - symbol m_sorts; - symbol m_funs; - symbol m_preds; - symbol m_axioms; - symbol m_notes; - symbol m_array; - symbol m_bang; - symbol m_underscore; - sort* m_int_sort; - sort* m_real_sort; - family_id m_bv_fid; - family_id m_arith_fid; - family_id m_array_fid; - family_id m_rel_fid; - func_decl * m_sk_hack; - std::ostream* m_err; - bool m_display_error_for_vs; - - -public: - - smtparser(ast_manager& m, bool ignore_user_patterns): - m_manager(m), - m_plugins(m), - m_anum_util(m), - m_bvnum_util(m), - m_pattern_validator(m), - m_ignore_user_patterns(ignore_user_patterns), - m_binding_level(0), - m_benchmark(m_manager, symbol("")), - m_let("let"), - m_flet("flet"), - m_forall("forall"), - m_exists("exists"), - m_lblneg("lblneg"), - m_lblpos("lblpos"), - m_associative("assoc"), - m_commutative("comm"), - m_injective("injective"), - m_sorts("sorts"), - m_funs("funs"), - m_preds("preds"), - m_axioms("axioms"), - m_notes("notes"), - m_array("array"), - m_bang("!"), - m_underscore("_"), - m_err(0), - m_display_error_for_vs(false) - { - family_id bfid = m_manager.get_basic_family_id(); - - add_builtin_type("bool", bfid, BOOL_SORT); - m_benchmark.get_symtable()->insert(symbol("Array"), alloc(array_sort, m)); - m_benchmark.get_symtable()->insert(symbol("BitVec"), alloc(bv_sort, m)); - - - add_builtins(bfid); - } - - ~smtparser() { - } - - void set_error_stream(std::ostream& strm) { m_err = &strm; } - - std::ostream& get_err() { return m_err?(*m_err):std::cerr; } - - bool ignore_user_patterns() const { return m_ignore_user_patterns; } - - bool parse_stream(std::istream& stream) { - proto_region region; - scanner scanner(stream, get_err(), false); - proto_expr_parser parser(region, scanner, get_err()); - return parse(parser); - } - - bool parse_file(char const * filename) { - if (filename != 0) { - std::ifstream stream(filename); - if (!stream) { - get_err() << "ERROR: could not open file '" << filename << "'.\n"; - return false; - } - return parse_stream(stream); - } - else { - return parse_stream(std::cin); - } - } - - bool parse_string(char const * str) { - std::string s = str; - std::istringstream is(s); - return parse_stream(is); - } - - void add_builtin_op(char const * s, family_id fid, decl_kind k) { - m_builtin_ops.insert(symbol(s), builtin_op(fid, k)); - } - - void add_builtin_type(char const * s, family_id fid, decl_kind k) { - m_builtin_sorts.insert(symbol(s), builtin_op(fid, k)); - } - - void initialize_smtlib() { - smtlib::symtable* table = m_benchmark.get_symtable(); - - symbol arith("arith"); - family_id afid = m_manager.mk_family_id(arith); - m_arith_fid = afid; - - add_builtin_type("Int", afid, INT_SORT); - add_builtin_type("Real", afid, REAL_SORT); - add_builtin_type("Bool", m_manager.get_basic_family_id(), BOOL_SORT); - - m_int_sort = m_manager.mk_sort(m_arith_fid, INT_SORT); - m_real_sort = m_manager.mk_sort(m_arith_fid, REAL_SORT); - - add_builtins(afid); - - symbol bv("bv"); - family_id bfid = m_manager.mk_family_id(bv); - m_bv_fid = bfid; - - add_builtins(bfid); - - add_builtin_type("BitVec", bfid, BV_SORT); - - symbol array("array"); - afid = m_manager.mk_family_id(array); - m_array_fid = afid; - - add_builtins(afid); - - sort* a1, *a2; - func_decl* store1, *sel1, *store2, *sel2; - - // Array - parameter params0[2] = { parameter(m_int_sort), parameter(m_int_sort) }; - a1 = m_manager.mk_sort(afid, ARRAY_SORT, 2, params0); - table->insert(symbol("Array"), a1); - parameter param0(a1); - sort * args0[3] = { a1, m_int_sort, m_int_sort }; - store1 = m_manager.mk_func_decl(afid, OP_STORE, 0, 0, 3, args0); - table->insert(symbol("store"), store1); - sel1 = m_manager.mk_func_decl(afid, OP_SELECT, 0, 0, 2, args0); - table->insert(symbol("select"), sel1); - - // Array1 - parameter params1[2] = { parameter(m_int_sort), parameter(m_real_sort) }; - a1 = m_manager.mk_sort(afid, ARRAY_SORT, 2, params1); - table->insert(symbol("Array1"), a1); - parameter param1(a1); - sort * args1[3] = { a1, m_int_sort, m_real_sort }; - store1 = m_manager.mk_func_decl(afid, OP_STORE, 0, 0, 3, args1); - table->insert(symbol("store"), store1); - sel1 = m_manager.mk_func_decl(afid, OP_SELECT, 0, 0, 2, args1); - table->insert(symbol("select"), sel1); - - // Array2 - parameter params2[2] = { parameter(m_int_sort), parameter(a1) }; - a2 = m_manager.mk_sort(afid, ARRAY_SORT, 2, params2); - table->insert(symbol("Array2"), a2); - parameter param2(a2); - sort * args2[3] = { a2, m_int_sort, a1 }; - store2 = m_manager.mk_func_decl(afid, OP_STORE, 0, 0, 3, args2); - table->insert(symbol("store"), store2); - sel2 = m_manager.mk_func_decl(afid, OP_SELECT, 0, 0, 2, args2); - table->insert(symbol("select"), sel2); - - m_benchmark.declare_sort(symbol("U")); - - sort * bool_sort = m_manager.mk_bool_sort(); - m_sk_hack = m_manager.mk_func_decl(symbol("sk_hack"), 1, &bool_sort, bool_sort); - table->insert(symbol("sk_hack"), m_sk_hack); - } - - - void add_builtins(family_id fid) { - decl_plugin * plugin = m_manager.get_plugin(fid); - SASSERT(plugin); - svector op_names; - plugin->get_op_names(op_names); - for (unsigned i = 0; i < op_names.size(); ++i) { - add_builtin_op(op_names[i].m_name.bare_str(), fid, op_names[i].m_kind); - } - } - - smtlib::benchmark* get_benchmark() { return &m_benchmark; } - -private: - - - bool parse(proto_expr_parser& parser) { - symbol benchmark("benchmark"); - symbol name(""); - proto_expr* const* rest = 0; - ptr_vector proto_exprs; - bool result = parser.parse(proto_exprs); - proto_expr* proto_expr = 0; - - if (!result) { - get_err() << "ERROR: parse error at line " << parser.get_line() << ".\n"; - } - - for (unsigned i = 0; result && i < proto_exprs.size(); ++i) { - - proto_expr = proto_exprs[i]; - - if (match_cons(proto_expr, benchmark, name, rest)) { - result = make_benchmark(name, rest); - } - else if (proto_expr && proto_expr->kind() != proto_expr::COMMENT) { - set_error("could not match expression to benchmark ", proto_expr); - } - else { - // proto_expr->kind() == proto_expr::COMMENT. - } - } - return result; - } - - void error_prefix(proto_expr* e) { - if (m_display_error_for_vs) { - if (e) { - get_err() << "Z3(" << e->line() << "," << e->pos() << "): ERROR: "; - } - } - else { - get_err() << "ERROR: "; - if (e) { - get_err() << "line " << e->line() << " column " << e->pos() << ": "; - } - } - } - - void set_error(char const * str, proto_expr* e) { - error_prefix(e); - if (e->kind() == proto_expr::ID) { - get_err() << str << " '" << e->string() << "'.\n"; - } - else { - get_err() << str << ".\n"; - } - } - - template - void set_error(T1 str1, T2 str2, proto_expr* e) { - error_prefix(e); - get_err() << str1 << " " << str2 << ".\n"; - } - - template - void set_error(T1 str1, T2 str2, T3 str3, proto_expr* e) { - error_prefix(e); - get_err() << str1 << str2 << str3 << ".\n"; - } - - bool match_cons(proto_expr * e, symbol const & sym, symbol & name, proto_expr* const*& proto_exprs) { - if (e && - e->kind() == proto_expr::CONS && - e->children() && - e->children()[0] && - e->children()[0]->string() == sym && - e->children()[1]) { - proto_exprs = e->children() + 2; - name = e->children()[1]->string(); - return true; - } - - return false; - } - - bool make_benchmark(symbol & name, proto_expr * const* proto_exprs) { - symbol extrasorts("extrasorts"); - symbol extrafuns("extrafuns"); - symbol extrapreds("extrapreds"); - symbol assumption("assumption"); - symbol assumption_core("assumption-core"); - symbol define_sorts_sym("define_sorts"); - symbol logic("logic"); - symbol formula("formula"); - symbol status("status"); - symbol sat("sat"); - symbol unsat("unsat"); - symbol unknown("unknown"); - symbol empty(""); - symbol source("source"); - symbol difficulty("difficulty"); - symbol category("category"); - bool success = true; - - push_benchmark(name); - - while (proto_exprs && *proto_exprs) { - proto_expr* e = *proto_exprs; - ++proto_exprs; - proto_expr* e1 = *proto_exprs; - - if (logic == e->string() && e1) { - name = e1->string(); - m_benchmark.set_logic(name); - - set_default_num_sort(name); - - if (name == symbol("QF_AX")) { - // Hack for supporting new QF_AX theory... - sort * index = m_manager.mk_uninterpreted_sort(symbol("Index")); - sort * element = m_manager.mk_uninterpreted_sort(symbol("Element")); - parameter params[2] = { parameter(index), parameter(element) }; - sort * array = m_manager.mk_sort(m_array_fid, ARRAY_SORT, 2, params); - smtlib::symtable* table = m_benchmark.get_symtable(); - table->insert(symbol("Index"), index); - table->insert(symbol("Element"), element); - // overwrite Array definition... - table->insert(symbol("Array"), array); - sort * args[3] = { array, index, element }; - func_decl * store = m_manager.mk_func_decl(m_array_fid, OP_STORE, 0, 0, 3, args); - table->insert(symbol("store"), store); - func_decl * sel = m_manager.mk_func_decl(m_array_fid, OP_SELECT, 0, 0, 2, args); - table->insert(symbol("select"), sel); - } - - ++proto_exprs; - continue; - } - - if (assumption == e->string() && e1) { - expr_ref t(m_manager); - if (!make_expression(e1, t) || - !push_assumption(t.get())) { - return false; - } - ++proto_exprs; - continue; - } - - if (assumption_core == e->string() && e1) { - expr_ref t(m_manager); - if (!make_expression(e1, t)) - return false; - m_benchmark.add_assumption(t.get()); - ++proto_exprs; - continue; - } - - if (define_sorts_sym == e->string() && e1) { - if (!define_sorts(e1)) { - return false; - } - ++proto_exprs; - continue; - } - - if (formula == e->string() && e1) { - expr_ref t(m_manager); - if (!make_expression(e1, t) || - !push_formula(t.get())) { - return false; - } - ++proto_exprs; - continue; - } - - if (status == e->string() && e1) { - if (sat == e1->string()) { - if (!push_status(smtlib::benchmark::SAT)) { - set_error("could not push status ", e1->string(),e1); - return false; - } - } - else if (unsat == e1->string()) { - if (!push_status(smtlib::benchmark::UNSAT)) { - set_error("could not push status ", e1->string(),e1); - return false; - } - } - else if (unknown == e1->string()) { - if (!push_status(smtlib::benchmark::UNKNOWN)) { - set_error("could not push status ", e1->string(),e1); - return false; - } - } - else { - set_error("could not recognize status ", e1->string(),e1); - return false; - } - ++proto_exprs; - continue; - } - - if (extrasorts == e->string() && e1) { - if (!declare_sorts(e1)) { - return false; - } - ++proto_exprs; - continue; - } - if (extrafuns == e->string() && e1) { - if (!declare_funs(e1)) { - return false; - } - ++proto_exprs; - continue; - } - if (extrapreds == e->string() && e1) { - if (!declare_preds(e1)) { - return false; - } - ++proto_exprs; - continue; - } - if (m_notes == e->string() && e1) { - ++proto_exprs; - continue; - } - - if ((source == e->string() || difficulty == e->string() || category == e->string()) && e1) { - ++proto_exprs; - continue; - } - - if (e->string() != empty) { - set_error("ignoring unknown attribute '", e->string().bare_str(), "'", e); - if (e1) { - ++proto_exprs; - } - // do not fail. - // success = false; - continue; - } - - TRACE("smtparser", - tout << "skipping: " << e->string() << " " << - e->line() << " " << - e->pos() << ".\n";); - continue; - } - return success; - } - - bool is_id_token(proto_expr* expr) { - return - expr && - (expr->kind() == proto_expr::ID || - expr->kind() == proto_expr::STRING || - expr->kind() == proto_expr::ANNOTATION); - } - - bool check_id(proto_expr* e) { - return is_id_token(e); - } - - bool make_expression(proto_expr * e, expr_ref & result) { - m_binding_level = 0; - symbol_table local_scope; - return make_expression(local_scope, e, result); - } - - bool make_func_decl(proto_expr* e, func_decl_ref& result) { - func_decl* f; - if (m_benchmark.get_symtable()->find1(e->string(), f)) { - result = f; - return true; - } - else { - return false; - } - } - - bool make_bool_expression(symbol_table& local_scope, proto_expr * e, expr_ref & result) { - if (!make_expression(local_scope, e, result)) { - return false; - } - if (!m_manager.is_bool(result)) { - set_error("expecting Boolean expression", e); - return false; - } - return true; - } - - bool make_bool_expressions(symbol_table& local_scope, proto_expr * const* chs, expr_ref_vector & exprs) { - while (chs && *chs) { - expr_ref result(m_manager); - m_binding_level = 0; - if (!make_bool_expression(local_scope, *chs, result)) { - return false; - } - exprs.push_back(result); - ++chs; - } - return true; - } - - bool make_expression(symbol_table& local_scope, proto_expr * e, expr_ref & result) { - // - // Walk proto_expr by using the zipper. - // That is, maintain a stack of what's - // . left - already processed. - // . right - to be processed. - // . up - above the processed node. - // - - region region; - - expr_ref_vector * left = alloc(expr_ref_vector, m_manager); - proto_expr* const* right = 0; - ptr_vector up; - proto_expr* current = e; - bool success = false; - idbuilder* builder = 0; - - while (true) { - - if (!current && right && *right) { - // - // pull the current from right. - // - current = *right; - ++right; - } - - if (!current && up.empty()) { - // - // we are done. - // - if (left->size() == 0) { - // set_error(); - set_error("there are no expressions to return", e); - goto cleanup; - } - if (left->size() != 1) { - set_error("there are too many expressions to return", e); - goto cleanup; - } - result = left->back(); - success = true; - goto cleanup; - } - - if (!current && !up.empty()) { - // - // There is nothing more to process at this level. - // - // Apply the operator on the stack to the - // current 'left' vector. - // Adjust the stack by popping the left and right - // work-lists. - // - expr_ref term(m_manager); - parse_frame* above = up.back(); - // symbol sym = above->get_proto_expr()->string(); - - if (above->make_term()) { - if (!above->make_term()->apply(*left, term)) { - set_error("Could not create application", - above->get_proto_expr()); - success = false; - goto cleanup; - } - } - else if (!make_app(above->get_proto_expr(), *left, term)) { - success = false; - goto cleanup; - } - dealloc(left); - left = above->detach_left(); - left->push_back(term.get()); - right = above->right(); - m_binding_level = above->binding_level(); - up.pop_back(); - continue; - } - - while (current && - current->kind() == proto_expr::CONS && - current->children() && - current->children()[0] && - !current->children()[1]) { - current = current->children()[0]; - } - - switch(current->kind()) { - - case proto_expr::ANNOTATION: - // ignore - current = 0; - break; - - case proto_expr::ID: { - symbol const& id = current->string(); - expr_ref term(m_manager); - expr * const_term = 0; - bool ok = true; - - if (local_scope.find(id, builder)) { - expr_ref_vector tmp(m_manager); - if (!builder->apply(tmp, term)) { - set_error("identifier supplied with the wrong number of arguments ", id, current); - goto cleanup; - - } - } - else if (m_benchmark.get_const(id, const_term)) { - // found. - term = const_term; - } - else if (is_builtin_const(id, current, current->num_params(), current->params(), ok, term)) { - if (!ok) goto cleanup; - } - else if (is_bvconst(id, current->num_params(), current->params(), term)) { - // found - } - else { - set_error("could not locate id ", id, current); - goto cleanup; - } - - left->push_back(term.get()); - current = 0; - break; - } - - case proto_expr::STRING: - // - // Ignore strings. - // - current = 0; - break; - - case proto_expr::COMMENT: - // - // Ignore comments. - // - current = 0; - break; - - case proto_expr::INT: - - left->push_back(mk_number(current->number(), true)); - current = 0; - break; - - case proto_expr::FLOAT: - left->push_back(mk_number(current->number(), false)); - current = 0; - break; - - case proto_expr::CONS: - - if (!current->children() || - !current->children()[0]) { - set_error("cons does not have children", current); - current = 0; - goto cleanup; - } - - // - // expect the head to be a symbol - // which can be used to build a term of - // the subterms. - // - - symbol const& head_symbol = current->children()[0]->string(); - - if (head_symbol == m_underscore) { - - expr_ref term(m_manager); - - proto_expr * const* chs = current->children() + 1; - symbol const& id = chs[0]->string(); - sort_ref_vector sorts(m_manager); - vector params; - bool ok = true; - if (!parse_params(chs+1, params, sorts)) { - goto cleanup; - } - if (is_builtin_const(id, current, params.size(), params.c_ptr(), ok, term)) { - if (!ok) goto cleanup; - } - else if (is_bvconst(id, params.size(), params.c_ptr(), term)) { - // ok - } - else { - set_error("Could not parse _ term", current); - goto cleanup; - } - left->push_back(term.get()); - current = 0; - break; - } - - if ((head_symbol == m_let) || - (head_symbol == m_flet)) { - - if (!current->children()[1] || - !current->children()[2]) { - set_error("let does not have two arguments", current); - goto cleanup; - } - - proto_expr * let_binding = current->children()[1]; - proto_expr * const* let_body = current->children()+2; - - // - // Collect bound variables and definitions for the bound variables - // into vectors 'vars' and 'bound'. - // - svector vars; - ptr_vector bound_vec; - if (is_binary_let_binding(let_binding)) { - vars.push_back(let_binding->children()[0]->string()); - bound_vec.push_back(let_binding->children()[1]); - } - else { - proto_expr* const* children = let_binding->children(); - if (!children) { - set_error("let binding does not have two arguments", let_binding); - goto cleanup; - } - while (*children) { - proto_expr* ch = *children; - if (!is_binary_let_binding(ch)) { - set_error("let binding does not have two arguments", ch); - goto cleanup; - } - vars.push_back(ch->children()[0]->string()); - bound_vec.push_back(ch->children()[1]); - ++children; - } - } - bound_vec.push_back(0); - - proto_expr** bound = new (region) proto_expr*[bound_vec.size()]; - for (unsigned i = 0; i < bound_vec.size(); ++i) { - bound[i] = bound_vec[i]; - } - - // - // Let's justify the transformation that - // pushes push_let and pop_let on the stack. - // and how it processes the let declaration. - // - // walk up left ((let ((v1 x1) (v2 x2)) z)::right) - // - // = - // - // walk (up::(pop_let(),left,right)::(bind(v1,v2),[],[z])) [] [x1;x2] - // - // = (* assume x1 -> y1, x2 -> y2 *) - // - // walk (up::(pop_let(),left,right)::(bind(v1,v2),[],[z])) [y1;y2] [] - // - // = (* apply binding *) - // - // walk (up::(pop_let(),left,right)) [] [z] - // - // = (* assume z -> u *) - // - // walk up {left::u] right - // - // so if pop_let(v) [a,b] has the effect of removing v from the environment - // and projecting the second element "b", we obtain the effect of a let-binding. - // - - expr_ref_vector * pinned = alloc(expr_ref_vector, m_manager); - pop_let * popl = new (region) pop_let(local_scope, pinned); - up.push_back(new (region) parse_frame(let_binding, popl, left, right, m_binding_level)); - - - push_let_and * pushl = new (region) push_let_and(this, region, local_scope, pinned, vars.size(), vars.c_ptr()); - expr_ref_vector * tmp = alloc(expr_ref_vector, m_manager); - up.push_back(new (region) parse_frame(let_binding, pushl, tmp, let_body, m_binding_level)); - - - left = alloc(expr_ref_vector, m_manager); - right = bound; - current = 0; - break; - } - - if (head_symbol == m_lblneg || - head_symbol == m_lblpos) { - if (!current->children()[1] || - !current->children()[2]) { - set_error("labels require two arguments", current); - goto cleanup; - } - - bool is_pos = head_symbol == m_lblpos; - idbuilder* lbl = new (region) build_label(this, is_pos, current->children()[1]); - - up.push_back(new (region) parse_frame(current, lbl, left, right, m_binding_level)); - - // - // process the body. - // - left = alloc(expr_ref_vector, m_manager); - right = 0; - current = current->children()[2]; - break; - } - - if (head_symbol == m_bang) { - proto_expr* const* children = current->children(); - proto_expr* body = children[1]; - proto_expr* lblname = 0; - bool is_pos = false; - - children += 2; - - while (children[0] && - children[0]->kind() == proto_expr::ANNOTATION && - children[1]) { - symbol id = children[0]->string(); - - if ((id == m_lblneg) || - (id == m_lblpos)) { - is_pos = id == m_lblpos; - lblname = children[1]; - } - - children += 2; - } - - if (lblname) { - idbuilder* lbl = new (region) build_label(this, is_pos, lblname); - up.push_back(new (region) parse_frame(current, lbl, left, right, m_binding_level)); - left = alloc(expr_ref_vector, m_manager); - right = 0; - } - - // - // process the body. - // - current = body; - break; - } - - if ((head_symbol == m_forall) || - (head_symbol == m_exists)) { - - expr_ref_buffer patterns(m_manager); - expr_ref_buffer no_patterns(m_manager); - sort_ref_buffer sorts(m_manager); - svector vars; - int weight = 1; - - proto_expr* const* children = current->children(); - proto_expr* body = 0; - - ++children; - - if (!children[0] || !children[1]) { - set_error("quantifier should have at least two arguments", current); - goto cleanup; - } - - // - // restore 'left' and 'right' working set and m_binding_level. - // - up.push_back(new (region) parse_frame(current, new (region) identity(), left, right, m_binding_level)); - left = alloc(expr_ref_vector, m_manager); - - // - // declare the bound variables. - // - - local_scope.begin_scope(); - - while (children[0] && children[1] && - (children[1]->kind() != proto_expr::ANNOTATION)) { - - if (!parse_bound(local_scope, region, *children, vars, sorts)) { - goto cleanup; - } - ++children; - } - - body = children[0]; - - if (is_annotated_cons(body)) { - children = body->children()+1; - body = body->children()[1]; - } - - ++children; - - symbol qid = symbol(current->line()); - symbol skid = symbol(); - - read_patterns(vars.size(), local_scope, children, patterns, no_patterns, weight, qid, skid); - - // - // push a parse_frame to undo the scope of the quantifier. - // - - SASSERT(sorts.size() > 0); - - idbuilder* pop_q = new (region) pop_quantifier(this, (head_symbol == m_forall), weight, qid, skid, patterns, no_patterns, sorts, vars, local_scope); - - expr_ref_vector * empty_v = alloc(expr_ref_vector, m_manager); - up.push_back(new (region) parse_frame(current, pop_q, empty_v, 0, m_binding_level)); - - // - // process the body. - // - right = 0; - current = body; - break; - } - - if (is_underscore_op(region, current->children()[0], builder)) { - up.push_back(new (region) parse_frame(current, builder, left, right, m_binding_level)); - } - else if (local_scope.find(head_symbol, builder)) { - up.push_back(new (region) parse_frame(current, builder, left, right, m_binding_level)); - } - else { - up.push_back(new (region) parse_frame(current->children()[0], left, right, m_binding_level)); - } - left = alloc(expr_ref_vector, m_manager); - right = current->children() + 1; - current = 0; - break; - } - } - - cleanup: - - if (success && !is_well_sorted(m_manager, result)) { - set_error("expression is not well sorted", e); - success = false; - } - - dealloc(left); - while (!up.empty()) { - dealloc(up.back()->detach_left()); - up.pop_back(); - } - return success; - } - - bool read_patterns(unsigned num_bindings, symbol_table & local_scope, proto_expr * const * & children, - expr_ref_buffer & patterns, expr_ref_buffer & no_patterns, int& weight, symbol& qid, symbol& skid) { - proto_region region; - while (children[0] && - children[0]->kind() == proto_expr::ANNOTATION && - children[1]) { - - if (children[0]->string() == symbol("qid") || - children[0]->string() == symbol("named")) { - qid = children[1]->string(); - children += 2; - continue; - } - - if (children[0]->string() == symbol("skolemid")) { - skid = children[1]->string(); - children += 2; - continue; - } - - ptr_vector proto_exprs; - - if (children[1]->kind() == proto_expr::COMMENT) { - std::string s = children[1]->string().str(); - std::istringstream stream(s); - scanner scanner(stream, get_err(), false); - proto_expr_parser parser(region, scanner, get_err()); - - if (!parser.parse(proto_exprs)) { - set_error("could not parse expression", children[1]); - return false; - } - } else if (children[1]->kind() == proto_expr::CONS) { - for (proto_expr* const* pexpr = children[1]->children(); *pexpr; pexpr++) - proto_exprs.push_back(*pexpr); - } else { - proto_exprs.push_back(children[1]); - } - - expr_ref_buffer ts(m_manager); - for (unsigned i = 0; i < proto_exprs.size(); ++i) { - expr_ref t(m_manager); - if (!make_expression(local_scope, proto_exprs[i], t)) { - return false; - } - ts.push_back(t.get()); - } - - if (children[0]->string() == symbol("pat") || - children[0]->string() == symbol("pats") || - children[0]->string() == symbol("pattern")) { - for (unsigned i = 0; i < ts.size(); ++i) { - if (!is_app(ts[i])) { - set_error("invalid pattern", children[0]); - return false; - } - } - expr_ref p(m_manager); - p = m_manager.mk_pattern(ts.size(), (app*const*)(ts.c_ptr())); - if (!p || (!ignore_user_patterns() && !m_pattern_validator(num_bindings, p, children[0]->line(), children[0]->pos()))) { - set_error("invalid pattern", children[0]); - return false; - } - patterns.push_back(p); - } - else if (children[0]->string() == symbol("ex_act") && ts.size() == 1) { - app_ref sk_hack(m_manager); - sk_hack = m_manager.mk_app(m_sk_hack, 1, ts.c_ptr()); - app * sk_hackp = sk_hack.get(); - expr_ref p(m_manager); - p = m_manager.mk_pattern(1, &sk_hackp); - if (!p || (!ignore_user_patterns() && !m_pattern_validator(num_bindings, p, children[0]->line(), children[0]->pos()))) { - set_error("invalid pattern", children[0]); - return false; - } - patterns.push_back(p); - } - else if ((children[0]->string() == symbol("nopat") || - children[0]->string() == symbol("no-pattern")) - && ts.size() == 1) { - no_patterns.push_back(ts[0]); - } - else if (children[0]->string() == symbol("weight") && ts.size() == 1 && - proto_exprs[0]->kind() == proto_expr::INT && - proto_exprs[0]->number().is_unsigned()) { - weight = proto_exprs[0]->number().get_unsigned(); - } - else { - // TODO: this should be a warning, perferably once per unknown kind of annotation - set_error("could not understand annotation '", - children[0]->string().bare_str(), "'", children[0]); - } - - children += 2; - } - return true; - } - - void set_default_num_sort(symbol const& name) { - if (name == symbol("QF_RDL") || - name == symbol("QF_LRA") || - name == symbol("LRA") || - name == symbol("RDL") || - name == symbol("QF_NRA") || - name == symbol("QF_UFNRA") || - name == symbol("QF_UFLRA")) { - m_int_sort = m_real_sort; - } - } - - bool get_sort(theory* th, char const * s, sort_ref& sort) { - return make_sort(symbol(s), 0, 0, sort); - } - - - bool make_sort(symbol const & id, unsigned num_params, parameter const* params, sort_ref& s) { - builtin_op info; - if (m_builtin_sorts.find(id, info)) { - s = m_manager.mk_sort(info.m_family_id, info.m_kind, num_params, params); - return true; - } - - if (num_params == 2 && symbol("Array") == id) { - // Old HACK to accomodate bit-vector arrays. - - if (!params[0].is_int()) { - throw default_exception("Non-integer parameter to array"); - return false; - } - if (!params[1].is_int()) { - throw default_exception("Non-integer parameter to array"); - return false; - } - parameter bv_params0[1] = { parameter(params[0].get_int()) }; - parameter bv_params1[1] = { parameter(params[1].get_int()) }; - - sort * t1 = m_manager.mk_sort(m_bv_fid, BV_SORT, 1, bv_params0); - sort * t2 = m_manager.mk_sort(m_bv_fid, BV_SORT, 1, bv_params1); - parameter params[2] = { parameter(t1), parameter(t2) }; - s = m_manager.mk_sort(m_array_fid, ARRAY_SORT, 2, params); - return true; - } - - sort* srt = 0; - if (m_benchmark.get_sort(id, srt)) { - s = srt; - return true; - } - return false; - } - - bool make_sort(proto_expr * e, sort_ref& s) { - SASSERT(can_be_sort(e)); - symtable& env = *m_benchmark.get_symtable(); - sort_builder* mk_sort; - switch(e->kind()) { - case proto_expr::ID: { - if (make_sort(e->string(), e->num_params(), e->params(), s)) { - return true; - } - if (env.lookup(e->string(), mk_sort)) { - if (!mk_sort->apply(e->num_params(), e->params(), s)) { - set_error(mk_sort->error_message(), e); - return false; - } - return true; - } - set_error("could not find sort ", e); - return false; - } - case proto_expr::CONS: { - if (!can_be_sort(e)) { - set_error("expression cannot be a sort", e); - return false; - } - proto_expr *const* chs = e->children(); - if (is_underscore(e)) { - ++chs; - } - symbol name = (*chs)->string(); - if (!env.lookup(name, mk_sort)) { - set_error("could not find sort symbol '", name.str(), "'", e); - return false; - } - sort_ref_vector sorts(m_manager); - vector params; - if (!parse_params(chs+1, params, sorts)) { - return false; - } - - if (!mk_sort->apply(params.size(), params.c_ptr(), s)) { - set_error(mk_sort->error_message(), e); - return false; - } - return true; - } - default: - set_error("could not create sort ", e); - return false; - } - } - - bool parse_params(proto_expr* const* chs,vector& params, sort_ref_vector& sorts) { - while (*chs) { - if ((*chs)->kind() == proto_expr::INT) { - rational const& num = (*chs)->number(); - if (num.is_unsigned()) { - params.push_back(parameter(num.get_unsigned())); - } - else { - params.push_back(parameter(num)); - } - } - else { - sort_ref s1(m_manager); - if (!make_sort(*chs, s1)) { - return false; - } - sorts.push_back(s1); - params.push_back(parameter((ast*)s1.get())); - } - ++chs; - } - return true; - } - - bool parse_bound( - symbol_table& local_scope, - region& region, - proto_expr* bound, - svector& vars, - sort_ref_buffer& sorts - ) - { - if (is_cons_list(bound)) { - proto_expr *const* children = bound->children(); - while (*children) { - if (!parse_bound(local_scope, region, *children, vars, sorts)) { - return false; - } - ++children; - } - return true; - } - if (!can_be_sorted_var(bound)) { - set_error("bound variable should contain a list of pairs", bound); - return false; - } - proto_expr* var = bound->children()[0]; - proto_expr* sort_proto_expr = bound->children()[1]; - - sort_ref sort(m_manager); - if (!make_sort(sort_proto_expr, sort)) { - return false; - } - sorts.push_back(sort); - vars.push_back(var->string()); - - local_scope.insert( - var->string(), - new (region) bound_var(this, sort) - ); - - ++m_binding_level; - - return true; - } - - bool can_be_sort(proto_expr* e) { - if (e && e->kind() == proto_expr::ID) { - return true; - } - if (is_underscore(e)) { - return true; - } - - if (e && - e->kind() == proto_expr::CONS && - e->children() && - e->children()[0] && - e->children()[1]) { - proto_expr* const* ch = e->children(); - while(*ch) { - if (!can_be_sort(*ch)) { - return false; - } - ++ch; - } - return true; - } - return false; - } - - bool declare_sorts(proto_expr* e) { - proto_expr* const * children = e->children(); - - while (children && *children) { - proto_expr* ch = *children; - switch(ch->kind()) { - - case proto_expr::ID: - m_benchmark.declare_sort(ch->string()); - break; - - case proto_expr::CONS: - // - // The declaration of type constructors - // consists of an identifier together with - // a number indicating the arity of the - // constructor. - // - if (ch->children() && - ch->children()[0] && - ch->children()[0]->kind() == proto_expr::ID && - ch->children()[1] && - ch->children()[1]->kind() == proto_expr::INT) { - - // unsigned num = (unsigned) ch->children()[1]->number().get_uint64(); - m_benchmark.declare_sort(ch->children()[0]->string()); - } - break; - - case proto_expr::ANNOTATION: - break; - - default: - set_error("unexpected argument to sorts",ch); - return false; - } - ++children; - } - return true; - } - - bool define_sorts(proto_expr* e) { - proto_expr* const * children = e->children(); - - while (children && *children) { - if (!define_sort(*children)) { - return false; - } - ++children; - } - return true; - } - - bool define_sort(proto_expr* e) { - proto_expr* const * children = e->children(); - sort_ref_buffer domain(m_manager); - - // - // First element in list must be an identifier. - // there should be just two elements. - // - if (!children || - !children[0] || - !(children[0]->kind() == proto_expr::ID) || - !children[1] || - children[2]) { - set_error("unexpected arguments to function declaration", e); - return false; - } - symbol name = children[0]->string(); - sort_ref s(m_manager); - if (!can_be_sort(children[1]) || - !make_sort(children[1], s)) { - set_error("unexpected arguments to function declaration", e); - return false; - } - - m_benchmark.get_symtable()->insert(name, s); - - return true; - } - - bool declare_funs(proto_expr* e) { - proto_expr* const * children = e->children(); - - while (children && *children) { - if (!declare_fun(*children)) { - return false; - } - ++children; - } - return true; - } - class define_sort_cls : public sort_builder { - smtparser& m_parser; - proto_region m_region; - proto_expr* m_expr; - svector m_params; - symbol m_name; - std::string m_error_message; - - public: - define_sort_cls(smtparser& p, symbol const& name, proto_expr* e, unsigned num_params, symbol* params) : - m_parser(p), - m_name(name) { - for (unsigned i = 0; i < num_params; ++i) { - m_params.push_back(params[i]); - } - m_expr = proto_expr::copy(m_region, e); - } - - virtual bool apply(unsigned num_params, parameter const* params, sort_ref & result) { - smtlib::symtable * symtable = m_parser.m_benchmark.get_symtable(); - if (m_params.size() != num_params) { - std::ostringstream strm; - strm << "wrong number of arguments passed to " << m_name << " " - << m_params.size() << " expected, but " << num_params << " given"; - m_error_message = strm.str(); - return false; - } - for (unsigned i = 0; i < num_params; ++i) { - parameter p(params[i]); - if (!p.is_ast() || !is_sort(p.get_ast())) { - symtable->pop_sorts(i); - std::ostringstream strm; - strm << "argument " << i << " is not a sort"; - m_error_message = strm.str(); - return false; - } - symtable->push_sort(m_params[i], to_sort(p.get_ast())); - } - bool success = m_parser.make_sort(m_expr, result); - - symtable->pop_sorts(num_params); - return success; - } - - virtual char const* error_message() { - return m_error_message.c_str(); - } - - }; - - // (define-sort name (*) ) - bool define_sort(proto_expr* id, proto_expr* sorts, proto_expr* srt) { - symbol name = id->string(); - proto_expr* const * children = sorts->children(); - svector names; - - if (!children) { - set_error("Sort definition expects a list of sort symbols",id); - return false; - } - - while (children[0]) { - id = children[0]; - if(id->kind() != proto_expr::ID) { - set_error("unexpected argument, expected ID", id); - return false; - } - names.push_back(id->string()); - ++children; - } - - m_benchmark.get_symtable()->insert(name, alloc(define_sort_cls, *this, name, srt, names.size(), names.c_ptr())); - return true; - } - - bool declare_fun(proto_expr* id, proto_expr* sorts, proto_expr* srt) { - proto_expr* const * children = sorts?sorts->children():0; - sort_ref_buffer domain(m_manager); - symbol name = id->string(); - - if (sorts && !children) { - set_error("Function declaration expects a list of sorts", id); - return false; - } - // - // parse domain. - // - while (sorts && children[0]) { - sort_ref s(m_manager); - if (!make_sort(children[0], s)) { - return false; - } - domain.push_back(s); - ++children; - } - - sort_ref range(m_manager); - if (!make_sort(srt, range)) { - return false; - } - bool is_associative = false; - bool is_commutative = false; - bool is_injective = false; - m_benchmark.declare_func(name, domain, range, is_associative, is_commutative, is_injective); - return true; - } - - bool declare_fun(proto_expr* e) { - proto_expr* const * children = e->children(); - sort_ref_buffer domain(m_manager); - // - // Skip declaration of numbers. - // - if (children && - children[0] && - children[0]->kind() == proto_expr::INT) { - return true; - } - - // - // First element in list must be an identifier. - // - if (!children || - !children[0] || - !(children[0]->kind() == proto_expr::ID)) { - set_error("unexpected arguments to function declaration", e); - return false; - } - - symbol name = children[0]->string(); - - ++children; - - - if (!can_be_sort(children[0])) { - set_error("unexpected arguments to function declaration", e); - return false; - } - - // - // parse domain. - // - while (can_be_sort(children[1])) { - sort_ref s(m_manager); - if (!make_sort(children[0], s)) { - return false; - } - domain.push_back(s); - ++children; - } - - // - // parse range. - // - SASSERT(can_be_sort(children[0])); - - sort_ref range(m_manager); - if (!make_sort(children[0], range)) { - return false; - } - ++children; - - // - // parse attributes. - // - bool is_associative = false; - bool is_commutative = false; - bool is_injective = false; - - while(children[0] && children[0]->kind() == proto_expr::ANNOTATION) { - - if (m_associative == children[0]->string()) { - is_associative = true; - } - else if (m_commutative == children[0]->string()) { - is_commutative = true; - } - else if (m_injective == children[0]->string()) { - is_injective = true; - } - ++children; - } - - m_benchmark.declare_func(name, domain, range, is_associative, is_commutative, is_injective); - - return true; - } - - bool declare_preds(proto_expr* e) { - proto_expr* const * children = e->children(); - - while (children && *children) { - if (!declare_pred(*children)) { - return false; - } - ++children; - } - return true; - } - - - bool declare_pred(proto_expr* e) { - proto_expr* const * children = e->children(); - if (!children || !children[0] || !(children[0]->kind() == proto_expr::ID)) { - set_error("unexpected arguments to predicate declaration", e); - return false; - } - symbol const & name = children[0]->string(); - sort_ref_buffer domain(m_manager); - sort * bool_sort = m_manager.mk_bool_sort(); - - ++children; - - while (can_be_sort(children[0])) { - sort_ref s(m_manager); - if (!make_sort(children[0], s)) { - return false; - } - domain.push_back(s); - ++children; - } - - m_benchmark.declare_func(name, domain, bool_sort, false, false, false); - - return true; - } - - bool can_be_sorted_var(proto_expr* e) { - return - e && - (e->kind() == proto_expr::CONS) && - e->children() && - e->children()[0] && - (e->children()[0]->kind() == proto_expr::ID) && - can_be_sort(e->children()[1]); - } - - bool is_cons_list(proto_expr* e) { - return - e && - (e->kind() == proto_expr::CONS) && - e->children() && - e->children()[0] && - e->children()[0]->kind() == proto_expr::CONS; - } - - bool is_prefixed(proto_expr* e, symbol const& s) { - return - e && - (e->kind() == proto_expr::CONS) && - e->children() && - e->children()[0] && - e->children()[1] && - e->children()[0]->string() == s; - - } - - bool is_underscore(proto_expr* e) { - return - is_prefixed(e, m_underscore) && - e->children()[1]->kind() == proto_expr::ID; - } - - bool is_annotated_cons(proto_expr* e) { - return is_prefixed(e, m_bang); - } - - bool is_builtin_const(symbol const& id, proto_expr* current, unsigned num_params, parameter * params, bool& ok, expr_ref& term) { - builtin_op info; - ok = true; - if (!m_builtin_ops.find(id, info)) { - return false; - } - fix_parameters(num_params, params); - func_decl* d = m_manager.mk_func_decl(info.m_family_id, info.m_kind, num_params, params, 0, (expr * const *)0); - if (!d) { - set_error("could not create a term from constant ", id, current); - ok = false; - } - else if (d->get_arity() != 0) { - set_error("identifier expects arguments ", id, current); - ok = false; - } - else { - term = m_manager.mk_const(d); - } - return true; - } - - bool is_underscore_op(region& r, proto_expr* e, idbuilder*& builder) { - if (!is_underscore(e)) { - return false; - } - builtin_op info; - proto_expr *const* chs = e->children()+1; - symbol const& id = (*chs)->string(); - sort_ref_vector sorts(m_manager); - vector params; - - if (!m_builtin_ops.find(id, info)) { - return false; - } - if (!parse_params(chs+1, params, sorts)) { - return false; - } - - builder = new (r) builtin_builder(this, info.m_family_id, info.m_kind, params); - return true; - } - - void fix_parameters(unsigned num_params, parameter* params) { - for (unsigned i = 0; i < num_params; ++i) { - func_decl* d = 0; - sort* s = 0; - builtin_op info; - if (params[i].is_symbol() && m_benchmark.get_symtable()->find1(params[i].get_symbol(), d)) { - params[i] = parameter(d); - } - else if (params[i].is_symbol() && m_benchmark.get_symtable()->find(params[i].get_symbol(), s)) { - params[i] = parameter(s); - } - else if (params[i].is_symbol() && m_builtin_sorts.find(params[i].get_symbol(), info)) { - params[i] = parameter(m_manager.mk_sort(info.m_family_id, info.m_kind, 0, 0)); - } - } - } - - bool make_app(proto_expr * proto_expr, expr_ref_vector const & args, expr_ref & result) { - symbol const& name = proto_expr->string(); - ptr_vector sorts; - func_decl * d = 0; - smtlib::symtable * symtable = m_benchmark.get_symtable(); - - for (unsigned i = 0; i < args.size(); ++i) { - sorts.push_back(m_manager.get_sort(args.get(i))); - } - - if (symtable->find_overload(name, sorts, d)) { - result = m_manager.mk_app(d, args.size(), args.c_ptr()); - return true; - } - - builtin_op info; - if (m_builtin_ops.find(name, info)) { - unsigned num_params = proto_expr->num_params(); - parameter * params = proto_expr->params(); - fix_parameters(num_params, params); - d = m_manager.mk_func_decl(info.m_family_id, info.m_kind, num_params, params, args.size(), args.c_ptr()); - if (d) { - result = m_manager.mk_app(d, args.size(), args.c_ptr()); - return true; - } - } - - rational arg2_value; - bool arg2_is_int; - - if (name == symbol("store") && - args.size() == 3 && - m_anum_util.is_numeral(args.get(2), arg2_value, arg2_is_int) && - arg2_is_int) { - expr_ref_vector new_args(m_manager); - new_args.push_back(args.get(0)); - new_args.push_back(args.get(1)); - new_args.push_back(m_anum_util.mk_numeral(arg2_value, false)); - sorts.reset(); - for (unsigned i = 0; i < args.size(); ++i) { - sorts.push_back(m_manager.get_sort(new_args.get(i))); - } - if (symtable->find_overload(name, sorts, d)) { - result = m_manager.mk_app(d, new_args.size(), new_args.c_ptr()); - return true; - } - } - - error_prefix(proto_expr); - get_err() << "could not find overload for '" << name << "' "; - for (unsigned i = 0; i < sorts.size(); ++i) { - get_err() << "Argument: " - << mk_pp(args.get(i), m_manager) - << " has type " - << mk_pp(sorts[i], m_manager) - << ".\n"; - } - return false; - } - - class nullary : public idbuilder { - expr* m_expr; - smtparser* m_parser; - unsigned m_decl_level_save; - public: - nullary(expr* e, smtparser* p) : m_expr(e), m_parser(p), m_decl_level_save(p->m_binding_level) {} - - virtual bool apply(expr_ref_vector const& args, expr_ref & result) { - unsigned decl_level = m_parser->m_binding_level; - SASSERT(decl_level >= m_decl_level_save); - shift_vars shifty(m_parser->m_manager); - shifty(m_expr, decl_level - m_decl_level_save, result); - return (args.size() == 0); - } - }; - - class identity : public idbuilder { - public: - identity() {} - - virtual bool apply(expr_ref_vector const & args, expr_ref & result) { - if (args.size() == 1) { - result = args.back(); - return true; - } - else { - return false; - } - } - }; - - class parse_frame { - public: - - parse_frame(proto_expr * e, idbuilder * make, expr_ref_vector * left, proto_expr * const* right, unsigned binding_level): - m_proto_expr(e), - m_make_term(make), - m_left(left), - m_right(right), - m_binding_level(binding_level) { - } - - parse_frame(proto_expr * e, expr_ref_vector * left, proto_expr * const* right, unsigned binding_level): - m_proto_expr(e), - m_make_term(0), - m_left(left), - m_right(right), - m_binding_level(binding_level) { - } - - expr_ref_vector * detach_left() { - expr_ref_vector * result = m_left; - SASSERT(m_left); - m_left = 0; - return result; - } - - unsigned binding_level() const { return m_binding_level; } - - proto_expr* const * right() const { return m_right; } - - idbuilder* make_term() { return m_make_term; } - - proto_expr* get_proto_expr() const { return m_proto_expr; } - - ~parse_frame() { dealloc(m_left); } - - private: - - proto_expr* m_proto_expr; - idbuilder* m_make_term; - expr_ref_vector * m_left; - proto_expr* const * m_right; - unsigned m_binding_level; - - parse_frame & operator=(parse_frame const & other); - - parse_frame(parse_frame const & other); - - }; - - class build_label : public idbuilder { - bool m_pos; - symbol m_sym; - smtparser * m_smt; - public: - build_label(smtparser * smt, bool is_pos, proto_expr * sym): m_pos(is_pos), m_smt(smt) { - switch(sym->kind()) { - case proto_expr::ID: - case proto_expr::STRING: - m_sym = sym->string(); - break; - case proto_expr::INT: - m_sym = symbol(sym->number().to_string().c_str()); - break; - default: - UNREACHABLE(); - break; - } - } - - virtual bool apply(expr_ref_vector const & args, expr_ref & result) { - if (args.size() >= 1) { - result = m_smt->m_manager.mk_label(m_pos, m_sym, args.get(0)); - return true; - } - else { - return false; - } - } - }; - - class pop_let : public idbuilder { - public: - pop_let(symbol_table & local_scope, expr_ref_vector* pinned = 0): - m_local_scope(local_scope), - m_pinned(pinned) { - } - - virtual ~pop_let() {} - - virtual bool apply(expr_ref_vector const & args, expr_ref & result) { - dealloc(m_pinned); - if (args.size() == 2) { - m_local_scope.end_scope(); - result = args.get(1); - return true; - } - else { - return false; - } - } - private: - symbol_table & m_local_scope; - expr_ref_vector* m_pinned; - }; - - class push_let : public idbuilder { - smtparser* m_parser; - region & m_region; - symbol_table & m_local_scope; - symbol m_let_var; - - public: - push_let(smtparser* p, region & region, symbol_table & local_scope, symbol const & let_var): - m_parser(p), - m_region(region), - m_local_scope(local_scope), - m_let_var(let_var) { - } - - virtual bool apply(expr_ref_vector const & args, expr_ref & result) { - // - // . push a scope, - // . create a nullary function using the variable/term association. - // . return the (first) argument. - // - // - if (args.size() == 1) { - m_local_scope.begin_scope(); - m_local_scope.insert(m_let_var, new (m_region) nullary(args.back(), m_parser)); - result = args.back(); - return true; - } - else { - return false; - } - } - }; - - // push multiple let bound variables. - class push_let_and : public idbuilder { - smtparser* m_parser; - region & m_region; - symbol_table & m_local_scope; - unsigned m_num_vars; - symbol* m_vars; - expr_ref_vector* m_pinned; - - public: - push_let_and(smtparser* p, region & region, symbol_table & local_scope, expr_ref_vector* pinned, unsigned num_vars, symbol const* vars): - m_parser(p), - m_region(region), - m_local_scope(local_scope), - m_num_vars(num_vars), - m_vars(new (region) symbol[num_vars]), - m_pinned(pinned) { - for (unsigned i = 0; i < num_vars; ++i) { - m_vars[i] = vars[i]; - } - } - - virtual bool apply(expr_ref_vector const & args, expr_ref & result) { - if (args.size() != m_num_vars) { - return false; - } - - // - // . push a scope, - // . create a nullary function using the variable/term association. - // . return the last argument (arbitrary). - // - - m_local_scope.begin_scope(); - for (unsigned i = 0; i < m_num_vars; ++i) { - m_local_scope.insert(m_vars[i], new (m_region) nullary(args[i], m_parser)); - m_pinned->push_back(args[i]); - } - result = args.back(); - return true; - } - }; - - class bound_var : public idbuilder { - public: - bound_var(smtparser * smt, sort * sort): - m_smt(smt), - m_decl_level(smt->m_binding_level), - m_sort(sort) { - } - - virtual bool apply(expr_ref_vector const & args, expr_ref & result) { - SASSERT(m_smt->m_binding_level > m_decl_level); - unsigned idx = m_smt->m_binding_level - m_decl_level - 1; - result = m_smt->m_manager.mk_var(idx, m_sort); - return args.empty(); - } - - private: - smtparser * m_smt; - unsigned m_decl_level; - sort * m_sort; - }; - - class pop_quantifier : public idbuilder { - public: - pop_quantifier(smtparser * smt, bool is_forall, int weight, symbol const& qid, symbol const& skid, expr_ref_buffer & patterns, expr_ref_buffer & no_patterns, sort_ref_buffer & sorts, - svector& vars, symbol_table & local_scope): - m_smt(smt), - m_is_forall(is_forall), - m_weight(weight), - m_qid(qid), - m_skid(skid), - m_patterns(m_smt->m_manager), - m_no_patterns(m_smt->m_manager), - m_sorts(m_smt->m_manager), - m_local_scope(local_scope) { - SASSERT(sorts.size() == vars.size()); - - m_vars.append(vars); - m_sorts.append(sorts); - m_patterns.append(patterns); - m_no_patterns.append(no_patterns); - } - - virtual bool apply(expr_ref_vector const & args, expr_ref & result) { - if (args.size() != 1) { - return false; - } - - m_local_scope.end_scope(); - - expr * body = args.back(); - - if (m_smt->ignore_user_patterns()) { - TRACE("pat_bug", tout << "ignoring user patterns...: " << m_patterns.size() << "\n";); - result = m_smt->m_manager.mk_quantifier(m_is_forall, - m_sorts.size(), // num_decls - m_sorts.c_ptr(), // decl_sorts - m_vars.begin(), // decl_names - body, - m_weight, - m_qid, - m_skid, - 0, - 0, - 0, - 0); - } - else if (!m_patterns.empty()) { - if (!m_no_patterns.empty()) { - m_smt->set_error("patterns were provided, ignoring :nopat attribute.", ((proto_expr*)0)); - } - result = m_smt->m_manager.mk_quantifier(m_is_forall, - m_sorts.size(), // num_decls - m_sorts.c_ptr(), // decl_sorts - m_vars.begin(), // decl_names - body, - m_weight, - m_qid, - m_skid, - m_patterns.size(), - m_patterns.c_ptr(), - 0, - 0); - } - else { - result = m_smt->m_manager.mk_quantifier(m_is_forall, - m_sorts.size(), // num_decls - m_sorts.c_ptr(), // decl_sorts - m_vars.begin(), // decl_names - body, - m_weight, - m_qid, - m_skid, - 0, - 0, - m_no_patterns.size(), - m_no_patterns.c_ptr()); - } - - // - // reclaim memory resources on application. - // - - m_vars.finalize(); - m_sorts.finalize(); - m_patterns.finalize(); - m_no_patterns.finalize(); - return true; - } - - private: - smtparser* m_smt; - bool m_is_forall; - int m_weight; - symbol m_qid; - symbol m_skid; - expr_ref_buffer m_patterns; - expr_ref_buffer m_no_patterns; - sort_ref_buffer m_sorts; - svector m_vars; - symbol_table& m_local_scope; - }; - - class builtin_builder : public idbuilder { - smtparser* m_smt; - family_id m_fid; - decl_kind m_kind; - vector m_params; - - public: - builtin_builder(smtparser* smt, family_id fid, decl_kind k,vector const& p): - m_smt(smt), - m_fid(fid), - m_kind(k), - m_params(p) - { - } - - virtual bool apply(expr_ref_vector const& args, expr_ref& result) { - ast_manager& m = m_smt->m_manager; - func_decl* d = m.mk_func_decl(m_fid, m_kind, m_params.size(), m_params.c_ptr(), args.size(), args.c_ptr()); - if (d) { - result = m.mk_app(d, args.size(), args.c_ptr()); - } - m_params.finalize(); - return d != 0; - } - }; - - bool push_status(smtlib::benchmark::status status) { - m_benchmark.set_status( status); - return true; - } - - expr * mk_number(rational const & r, bool is_int){ - if (m_int_sort == m_real_sort) // integer constants should be mapped to real - is_int = false; - return m_anum_util.mk_numeral(r, is_int); - } - - void push_benchmark(symbol const & name) { - m_benchmark.set_name(name); - } - - bool push_assumption(expr * t) { - m_benchmark.add_axiom(t); - return true; - } - - bool push_formula(expr * t) { - m_benchmark.add_formula(t); - return true; - } - - bool is_binary_let_binding(proto_expr* let_binding) { - return - let_binding && - let_binding->children() && - let_binding->children()[0] && - (let_binding->children()[0]->kind() == proto_expr::ID) && - let_binding->children()[1] && - !let_binding->children()[2]; - } - - bool is_bvconst(symbol const & fname, unsigned num_params, parameter const* params, expr_ref & term) { - rational n; - char const * str = fname.bare_str(); - unsigned sz = 0; - - if (strncmp(str, "bvbin", 5) == 0) { - str += 5; - n = rational(0); - while (*str == '1' || *str == '0') { - n *= rational(2); - n += rational(*str - '0'); - ++sz; - ++str; - } - if (sz == 0) { - return false; - } - } - else if (strncmp(str, "bvhex", 5) == 0) { - n = rational(0); - str += 5; - while (('0' <= *str && *str <= '9') || - ('a' <= *str && *str <= 'f') || - ('A' <= *str && *str <= 'F')) { - n *= rational(16); - if ('0' <= *str && *str <= '9') { - n += rational(*str - '0'); - } - else if ('a' <= *str && *str <= 'f') { - n += rational(10); - n += rational(*str - 'a'); - } - else { - SASSERT('A' <= *str && *str <= 'F'); - n += rational(10); - n += rational(*str - 'A'); - } - sz += 4; - ++str; - } - if (sz == 0) { - return false; - } - } - else if (strncmp(str, "bv", 2) == 0 && '0' <= *(str + 2) && *(str + 2) <= '9') { - n = rational(0); - str += 2; - while ('0' <= *str && *str <= '9') { - n *= rational(10); - n += rational(*str - '0'); - ++str; - } - if (num_params == 1) { - sz = params[0].get_int(); - } - else { - sz = 32; - } - } - else { - return false; - } - - term = m_bvnum_util.mk_numeral(n, sz); - - return true; - } -}; - - -parser * parser::create(ast_manager& ast_manager, bool ignore_user_patterns) { - return alloc(smtparser, ast_manager, ignore_user_patterns); -} diff --git a/src/parsers/smt/smtparser.h b/src/parsers/smt/smtparser.h deleted file mode 100644 index d8999e8ab..000000000 --- a/src/parsers/smt/smtparser.h +++ /dev/null @@ -1,48 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - smtparser.h - -Abstract: - - SMT parsing utilities - -Author: - - Nikolaj Bjorner (nbjorner) 2006-09-25 - -Revision History: - ---*/ -#ifndef SMT_PARSER_H_ -#define SMT_PARSER_H_ - -#include -#include "ast/ast.h" -#include "util/vector.h" -#include "parsers/smt/smtlib.h" - -namespace smtlib { - class parser { - public: - static parser * create(ast_manager & ast_manager, bool ignore_user_patterns = false); - - virtual ~parser() {} - - virtual void add_builtin_op(char const *, family_id fid, decl_kind kind) = 0; - virtual void add_builtin_type(char const *, family_id fid, decl_kind kind) = 0; - - virtual void initialize_smtlib() = 0; - - virtual void set_error_stream(std::ostream& strm) = 0; - - virtual bool parse_file(char const * path) = 0; - virtual bool parse_string(char const * string) = 0; - - virtual benchmark * get_benchmark() = 0; - }; -}; - -#endif diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 3d2609c4f..8b719681c 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -37,7 +37,7 @@ Revision History: #include "util/env_params.h" #include "shell/lp_frontend.h" -typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_Z3_LOG, IN_MPS } input_kind; +typedef enum { IN_UNSPECIFIED, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_Z3_LOG, IN_MPS } input_kind; std::string g_aux_input_file; char const * g_input_file = 0; @@ -169,9 +169,6 @@ void parse_cmd_line_args(int argc, char ** argv) { std::cout << "\n"; exit(0); } - else if (strcmp(opt_name, "smt") == 0) { - g_input_kind = IN_SMTLIB; - } else if (strcmp(opt_name, "smt2") == 0) { g_input_kind = IN_SMTLIB_2; } @@ -340,9 +337,6 @@ int STD_CALL main(int argc, char ** argv) { else if (strcmp(ext, "smt2") == 0) { g_input_kind = IN_SMTLIB_2; } - else if (strcmp(ext, "smt") == 0) { - g_input_kind = IN_SMTLIB; - } else if (strcmp(ext, "mps") == 0 || strcmp(ext, "sif") == 0 || strcmp(ext, "MPS") == 0 || strcmp(ext, "SIF") == 0) { g_input_kind = IN_MPS; @@ -350,9 +344,6 @@ int STD_CALL main(int argc, char ** argv) { } } switch (g_input_kind) { - case IN_SMTLIB: - return_value = read_smtlib_file(g_input_file); - break; case IN_SMTLIB_2: memory::exit_when_out_of_memory(true, "(error \"out of memory\")"); return_value = read_smtlib2_commands(g_input_file); diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index 666a1e1fe..8c716a81a 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -21,7 +21,6 @@ Revision History: #include #include #include -#include "parsers/smt/smtlib_solver.h" #include "util/timeout.h" #include "parsers/smt2/smt2parser.h" #include "muz/fp/dl_cmds.h" @@ -35,20 +34,14 @@ Revision History: extern bool g_display_statistics; static clock_t g_start_time; -static smtlib::solver* g_solver = 0; static cmd_context * g_cmd_context = 0; static void display_statistics() { clock_t end_time = clock(); - if ((g_solver || g_cmd_context) && g_display_statistics) { + if (g_cmd_context && g_display_statistics) { std::cout.flush(); std::cerr.flush(); - if (g_solver) { - g_solver->display_statistics(); - memory::display_max_usage(std::cout); - std::cout << "time: " << ((static_cast(end_time) - static_cast(g_start_time)) / CLOCKS_PER_SEC) << " secs\n"; - } - else if (g_cmd_context) { + if (g_cmd_context) { g_cmd_context->set_regular_stream("stdout"); g_cmd_context->display_statistics(true, ((static_cast(end_time) - static_cast(g_start_time)) / CLOCKS_PER_SEC)); } @@ -72,33 +65,6 @@ static void STD_CALL on_ctrl_c(int) { raise(SIGINT); } -unsigned read_smtlib_file(char const * benchmark_file) { - g_start_time = clock(); - register_on_timeout_proc(on_timeout); - signal(SIGINT, on_ctrl_c); - smtlib::solver solver; - g_solver = &solver; - - bool ok = true; - - ok = solver.solve_smt(benchmark_file); - if (!ok) { - if (benchmark_file) { - std::cerr << "ERROR: solving '" << benchmark_file << "'.\n"; - } - else { - std::cerr << "ERROR: solving input stream.\n"; - } - } - - #pragma omp critical (g_display_stats) - { - display_statistics(); - register_on_timeout_proc(0); - g_solver = 0; - } - return solver.get_error_code(); -} unsigned read_smtlib2_commands(char const * file_name) { g_start_time = clock(); diff --git a/src/test/quant_elim.cpp b/src/test/quant_elim.cpp index 3674e6b70..12fca706d 100644 --- a/src/test/quant_elim.cpp +++ b/src/test/quant_elim.cpp @@ -8,8 +8,6 @@ Copyright (c) 2015 Microsoft Corporation #include "smt/params/smt_params.h" #include "qe/qe.h" #include "ast/ast_pp.h" -#include "parsers/smt/smtlib.h" -#include "parsers/smt/smtparser.h" #include "util/lbool.h" #include #include "ast/reg_decl_plugins.h" @@ -54,6 +52,9 @@ static void test_qe(ast_manager& m, lbool expected_outcome, expr* fml, char cons static void test_formula(lbool expected_outcome, char const* fml) { ast_manager m; reg_decl_plugins(m); + // No-op requires SMTLIB2 + +#if 0 scoped_ptr parser = smtlib::parser::create(m); parser->initialize_smtlib(); @@ -73,8 +74,10 @@ static void test_formula(lbool expected_outcome, char const* fml) { for (; it != end; ++it) { test_qe(m, expected_outcome, *it, 0); } +#endif } + void tst_quant_elim() { disable_debug("heap"); From 92b4b9e7a728bf95c0971fc0abec718b28534beb Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 11:14:00 -0800 Subject: [PATCH 061/263] fix error messaging for parsers Signed-off-by: Nikolaj Bjorner --- src/api/api_opt.cpp | 16 ++++++++++++-- src/api/api_parsers.cpp | 14 +++++++++++- src/api/python/z3/z3.py | 38 +++++++++++++++++++++++++++------ src/cmd_context/cmd_context.cpp | 7 ++++++ src/cmd_context/cmd_context.h | 2 ++ 5 files changed, 67 insertions(+), 10 deletions(-) diff --git a/src/api/api_opt.cpp b/src/api/api_opt.cpp index 9f5f7dd5d..ac11e1a33 100644 --- a/src/api/api_opt.cpp +++ b/src/api/api_opt.cpp @@ -286,11 +286,23 @@ extern "C" { scoped_ptr ctx = alloc(cmd_context, false, &m); install_opt_cmds(*ctx.get(), to_optimize_ptr(opt)); ctx->set_ignore_check(true); - if (!parse_smt2_commands(*ctx.get(), s)) { + std::stringstream errstrm; + ctx->set_regular_stream(errstrm); + try { + if (!parse_smt2_commands(*ctx.get(), s)) { + mk_c(c)->m_parser_error_buffer = errstrm.str(); + ctx = nullptr; + SET_ERROR_CODE(Z3_PARSER_ERROR); + return; + } + } + catch (z3_exception& e) { + errstrm << e.msg(); + mk_c(c)->m_parser_error_buffer = errstrm.str(); ctx = nullptr; SET_ERROR_CODE(Z3_PARSER_ERROR); return; - } + } ptr_vector::const_iterator it = ctx->begin_assertions(); ptr_vector::const_iterator end = ctx->end_assertions(); for (; it != end; ++it) { diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index 867117984..a7235ef65 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -55,7 +55,19 @@ extern "C" { psort* ps = ctx->pm().mk_psort_cnst(to_sort(sorts[i])); ctx->insert(ctx->pm().mk_psort_user_decl(0, to_symbol(sort_names[i]), ps)); } - if (!parse_smt2_commands(*ctx.get(), is)) { + std::stringstream errstrm; + ctx->set_regular_stream(errstrm); + try { + if (!parse_smt2_commands(*ctx.get(), is)) { + ctx = nullptr; + mk_c(c)->m_parser_error_buffer = errstrm.str(); + SET_ERROR_CODE(Z3_PARSER_ERROR); + return of_ast(mk_c(c)->m().mk_true()); + } + } + catch (z3_exception& e) { + errstrm << e.msg(); + mk_c(c)->m_parser_error_buffer = errstrm.str(); ctx = nullptr; SET_ERROR_CODE(Z3_PARSER_ERROR); return of_ast(mk_c(c)->m().mk_true()); diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 1f050d3bd..2304491c8 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -6668,11 +6668,17 @@ class Fixedpoint(Z3PPObject): def parse_string(self, s): """Parse rules and queries from a string""" - return AstVector(Z3_fixedpoint_from_string(self.ctx.ref(), self.fixedpoint, s), self.ctx) + try: + return AstVector(Z3_fixedpoint_from_string(self.ctx.ref(), self.fixedpoint, s), self.ctx) + except Z3Exception as e: + _handle_parse_error(e, self.ctx) def parse_file(self, f): """Parse rules and queries from a file""" - return AstVector(Z3_fixedpoint_from_file(self.ctx.ref(), self.fixedpoint, f), self.ctx) + try: + return AstVector(Z3_fixedpoint_from_file(self.ctx.ref(), self.fixedpoint, f), self.ctx) + except Z3Exception as e: + _handle_parse_error(e, self.ctx) def get_rules(self): """retrieve rules that have been added to fixedpoint context""" @@ -6995,15 +7001,21 @@ class Optimize(Z3PPObject): def upper_values(self, obj): if not isinstance(obj, OptimizeObjective): raise Z3Exception("Expecting objective handle returned by maximize/minimize") - return obj.upper_values() + return obj.upper_values() def from_file(self, filename): """Parse assertions and objectives from a file""" - Z3_optimize_from_file(self.ctx.ref(), self.optimize, filename) + try: + Z3_optimize_from_file(self.ctx.ref(), self.optimize, filename) + except Z3Exception as e: + _handle_parse_error(e, self.ctx) def from_string(self, s): """Parse assertions and objectives from a string""" - Z3_optimize_from_string(self.ctx.ref(), self.optimize, s) + try: + Z3_optimize_from_string(self.ctx.ref(), self.optimize, s) + except Z3Exception as e: + _handle_parse_error(e, self.ctx) def assertions(self): """Return an AST vector containing all added constraints.""" @@ -8071,6 +8083,12 @@ def _dict2darray(decls, ctx): i = i + 1 return sz, _names, _decls +def _handle_parse_error(ex, ctx): + msg = Z3_get_parser_error(ctx.ref()) + if msg != "": + raise Z3Exception(msg) + raise ex + def parse_smt2_string(s, sorts={}, decls={}, ctx=None): """Parse a string in SMT 2.0 format using the given sorts and decls. @@ -8089,7 +8107,10 @@ def parse_smt2_string(s, sorts={}, decls={}, ctx=None): ctx = _get_ctx(ctx) ssz, snames, ssorts = _dict2sarray(sorts, ctx) dsz, dnames, ddecls = _dict2darray(decls, ctx) - return _to_expr_ref(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx) + try: + return _to_expr_ref(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx) + except Z3Exception as e: + _handle_parse_error(e, ctx) def parse_smt2_file(f, sorts={}, decls={}, ctx=None): """Parse a file in SMT 2.0 format using the given sorts and decls. @@ -8099,7 +8120,10 @@ def parse_smt2_file(f, sorts={}, decls={}, ctx=None): ctx = _get_ctx(ctx) ssz, snames, ssorts = _dict2sarray(sorts, ctx) dsz, dnames, ddecls = _dict2darray(decls, ctx) - return _to_expr_ref(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx) + try: + return _to_expr_ref(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx) + except Z3Exception as e: + _handle_parse_error(e, ctx) def Interpolant(a,ctx=None): """Create an interpolation operator. diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index a1e7a4745..ec2eea032 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -339,6 +339,13 @@ void ast_object_ref::finalize(cmd_context & ctx) { ctx.m().dec_ref(m_ast); } +void stream_ref::set(std::ostream& out) { + reset(); + m_owner = false; + m_name = "caller-owned"; + m_stream = &out; +} + void stream_ref::set(char const * name) { if (!name) { throw cmd_exception("invalid stream name"); diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index b60f590a9..99d6c8284 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -128,6 +128,7 @@ public: stream_ref(std::string n, std::ostream & d):m_default_name(n), m_default(d), m_name(n), m_stream(&d), m_owner(false) {} ~stream_ref() { reset(); } void set(char const * name); + void set(std::ostream& strm); void reset(); std::ostream & operator*() { return *m_stream; } char const * name() const { return m_name.c_str(); } @@ -404,6 +405,7 @@ public: void reset_object_refs(); void reset_user_tactics(); void set_regular_stream(char const * name) { m_regular.set(name); } + void set_regular_stream(std::ostream& out) { m_regular.set(out); } void set_diagnostic_stream(char const * name); virtual std::ostream & regular_stream() { return *m_regular; } virtual std::ostream & diagnostic_stream() { return *m_diagnostic; } From 161b6a99831817379a8b81af4c39a7c810e51f71 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 11:51:37 -0800 Subject: [PATCH 062/263] increase minor version, update java/.net apis Signed-off-by: Nikolaj Bjorner --- scripts/mk_project.py | 2 +- src/api/dotnet/Context.cs | 150 -------------------------------------- src/api/java/Context.java | 139 ----------------------------------- 3 files changed, 1 insertion(+), 290 deletions(-) diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 5ab56d1c7..8f75e97ed 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -9,7 +9,7 @@ from mk_util import * # Z3 Project definition def init_project_def(): - set_version(4, 5, 1, 0) + set_version(4, 6, 1, 0) add_lib('util', []) add_lib('lp', ['util'], 'util/lp') add_lib('polynomial', ['util'], 'math/polynomial') diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index 914cee615..ac23d1dbc 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -3320,160 +3320,10 @@ namespace Microsoft.Z3 #endregion #region SMT Files & Strings - /// - /// Convert a benchmark into an SMT-LIB formatted string. - /// - /// Name of the benchmark. The argument is optional. - /// The benchmark logic. - /// The status string (sat, unsat, or unknown) - /// Other attributes, such as source, difficulty or category. - /// Auxiliary assumptions. - /// Formula to be checked for consistency in conjunction with assumptions. - /// A string representation of the benchmark. - public string BenchmarkToSMTString(string name, string logic, string status, string attributes, - BoolExpr[] assumptions, BoolExpr formula) - { - Contract.Requires(assumptions != null); - Contract.Requires(formula != null); - Contract.Ensures(Contract.Result() != null); - - return Native.Z3_benchmark_to_smtlib_string(nCtx, name, logic, status, attributes, - (uint)assumptions.Length, AST.ArrayToNative(assumptions), - formula.NativeObject); - } - - /// - /// Parse the given string using the SMT-LIB parser. - /// - /// - /// The symbol table of the parser can be initialized using the given sorts and declarations. - /// The symbols in the arrays and - /// don't need to match the names of the sorts and declarations in the arrays - /// and . This is a useful feature since we can use arbitrary names to - /// reference sorts and declarations. - /// - public void ParseSMTLIBString(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null) - { - uint csn = Symbol.ArrayLength(sortNames); - uint cs = Sort.ArrayLength(sorts); - uint cdn = Symbol.ArrayLength(declNames); - uint cd = AST.ArrayLength(decls); - if (csn != cs || cdn != cd) - throw new Z3Exception("Argument size mismatch"); - Native.Z3_parse_smtlib_string(nCtx, str, - AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), - AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)); - } - - /// - /// Parse the given file using the SMT-LIB parser. - /// - /// - public void ParseSMTLIBFile(string fileName, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null) - { - uint csn = Symbol.ArrayLength(sortNames); - uint cs = Sort.ArrayLength(sorts); - uint cdn = Symbol.ArrayLength(declNames); - uint cd = AST.ArrayLength(decls); - if (csn != cs || cdn != cd) - throw new Z3Exception("Argument size mismatch"); - Native.Z3_parse_smtlib_file(nCtx, fileName, - AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts), - AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls)); - } - - /// - /// The number of SMTLIB formulas parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - /// - public uint NumSMTLIBFormulas { get { return Native.Z3_get_smtlib_num_formulas(nCtx); } } - - /// - /// The formulas parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - /// - public BoolExpr[] SMTLIBFormulas - { - get - { - Contract.Ensures(Contract.Result() != null); - - uint n = NumSMTLIBFormulas; - BoolExpr[] res = new BoolExpr[n]; - for (uint i = 0; i < n; i++) - res[i] = (BoolExpr)Expr.Create(this, Native.Z3_get_smtlib_formula(nCtx, i)); - return res; - } - } - - /// - /// The number of SMTLIB assumptions parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - /// - public uint NumSMTLIBAssumptions { get { return Native.Z3_get_smtlib_num_assumptions(nCtx); } } - - /// - /// The assumptions parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - /// - public BoolExpr[] SMTLIBAssumptions - { - get - { - Contract.Ensures(Contract.Result() != null); - - uint n = NumSMTLIBAssumptions; - BoolExpr[] res = new BoolExpr[n]; - for (uint i = 0; i < n; i++) - res[i] = (BoolExpr)Expr.Create(this, Native.Z3_get_smtlib_assumption(nCtx, i)); - return res; - } - } - - /// - /// The number of SMTLIB declarations parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - /// - public uint NumSMTLIBDecls { get { return Native.Z3_get_smtlib_num_decls(nCtx); } } - - /// - /// The declarations parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - /// - public FuncDecl[] SMTLIBDecls - { - get - { - Contract.Ensures(Contract.Result() != null); - - uint n = NumSMTLIBDecls; - FuncDecl[] res = new FuncDecl[n]; - for (uint i = 0; i < n; i++) - res[i] = new FuncDecl(this, Native.Z3_get_smtlib_decl(nCtx, i)); - return res; - } - } - - /// - /// The number of SMTLIB sorts parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - /// - public uint NumSMTLIBSorts { get { return Native.Z3_get_smtlib_num_sorts(nCtx); } } - - /// - /// The declarations parsed by the last call to ParseSMTLIBString or ParseSMTLIBFile. - /// - public Sort[] SMTLIBSorts - { - get - { - Contract.Ensures(Contract.Result() != null); - - uint n = NumSMTLIBSorts; - Sort[] res = new Sort[n]; - for (uint i = 0; i < n; i++) - res[i] = Sort.Create(this, Native.Z3_get_smtlib_sort(nCtx, i)); - return res; - } - } /// /// Parse the given string using the SMT-LIB2 parser. /// - /// /// A conjunction of assertions in the scope (up to push/pop) at the end of the string. public BoolExpr ParseSMTLIB2String(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null) { diff --git a/src/api/java/Context.java b/src/api/java/Context.java index 76303d670..3458f4d97 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -2540,147 +2540,8 @@ public class Context implements AutoCloseable { AST.arrayToNative(assumptions), formula.getNativeObject()); } - /** - * Parse the given string using the SMT-LIB parser. - * Remarks: The symbol - * table of the parser can be initialized using the given sorts and - * declarations. The symbols in the arrays {@code sortNames} and - * {@code declNames} don't need to match the names of the sorts - * and declarations in the arrays {@code sorts} and {@code decls}. This is a useful feature since we can use arbitrary names - * to reference sorts and declarations. - **/ - public void parseSMTLIBString(String str, Symbol[] sortNames, Sort[] sorts, - Symbol[] declNames, FuncDecl[] decls) - { - int csn = Symbol.arrayLength(sortNames); - int cs = Sort.arrayLength(sorts); - int cdn = Symbol.arrayLength(declNames); - int cd = AST.arrayLength(decls); - if (csn != cs || cdn != cd) - throw new Z3Exception("Argument size mismatch"); - Native.parseSmtlibString(nCtx(), str, AST.arrayLength(sorts), - Symbol.arrayToNative(sortNames), AST.arrayToNative(sorts), - AST.arrayLength(decls), Symbol.arrayToNative(declNames), - AST.arrayToNative(decls)); - } - - /** - * Parse the given file using the SMT-LIB parser. - * @see #parseSMTLIBString - **/ - public void parseSMTLIBFile(String fileName, Symbol[] sortNames, - Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) - - { - int csn = Symbol.arrayLength(sortNames); - int cs = Sort.arrayLength(sorts); - int cdn = Symbol.arrayLength(declNames); - int cd = AST.arrayLength(decls); - if (csn != cs || cdn != cd) - throw new Z3Exception("Argument size mismatch"); - Native.parseSmtlibFile(nCtx(), fileName, AST.arrayLength(sorts), - Symbol.arrayToNative(sortNames), AST.arrayToNative(sorts), - AST.arrayLength(decls), Symbol.arrayToNative(declNames), - AST.arrayToNative(decls)); - } - - /** - * The number of SMTLIB formulas parsed by the last call to - * {@code ParseSMTLIBString} or {@code ParseSMTLIBFile}. - **/ - public int getNumSMTLIBFormulas() - { - return Native.getSmtlibNumFormulas(nCtx()); - } - - /** - * The formulas parsed by the last call to {@code ParseSMTLIBString} or - * {@code ParseSMTLIBFile}. - **/ - public BoolExpr[] getSMTLIBFormulas() - { - - int n = getNumSMTLIBFormulas(); - BoolExpr[] res = new BoolExpr[n]; - for (int i = 0; i < n; i++) - res[i] = (BoolExpr) Expr.create(this, - Native.getSmtlibFormula(nCtx(), i)); - return res; - } - - /** - * The number of SMTLIB assumptions parsed by the last call to - * {@code ParseSMTLIBString} or {@code ParseSMTLIBFile}. - **/ - public int getNumSMTLIBAssumptions() - { - return Native.getSmtlibNumAssumptions(nCtx()); - } - - /** - * The assumptions parsed by the last call to {@code ParseSMTLIBString} - * or {@code ParseSMTLIBFile}. - **/ - public BoolExpr[] getSMTLIBAssumptions() - { - - int n = getNumSMTLIBAssumptions(); - BoolExpr[] res = new BoolExpr[n]; - for (int i = 0; i < n; i++) - res[i] = (BoolExpr) Expr.create(this, - Native.getSmtlibAssumption(nCtx(), i)); - return res; - } - - /** - * The number of SMTLIB declarations parsed by the last call to - * {@code ParseSMTLIBString} or {@code ParseSMTLIBFile}. - **/ - public int getNumSMTLIBDecls() - { - return Native.getSmtlibNumDecls(nCtx()); - } - - /** - * The declarations parsed by the last call to - * {@code ParseSMTLIBString} or {@code ParseSMTLIBFile}. - **/ - public FuncDecl[] getSMTLIBDecls() - { - - int n = getNumSMTLIBDecls(); - FuncDecl[] res = new FuncDecl[n]; - for (int i = 0; i < n; i++) - res[i] = new FuncDecl(this, Native.getSmtlibDecl(nCtx(), i)); - return res; - } - - /** - * The number of SMTLIB sorts parsed by the last call to - * {@code ParseSMTLIBString} or {@code ParseSMTLIBFile}. - **/ - public int getNumSMTLIBSorts() - { - return Native.getSmtlibNumSorts(nCtx()); - } - - /** - * The declarations parsed by the last call to - * {@code ParseSMTLIBString} or {@code ParseSMTLIBFile}. - **/ - public Sort[] getSMTLIBSorts() - { - - int n = getNumSMTLIBSorts(); - Sort[] res = new Sort[n]; - for (int i = 0; i < n; i++) - res[i] = Sort.create(this, Native.getSmtlibSort(nCtx(), i)); - return res; - } - /** * Parse the given string using the SMT-LIB2 parser. - * @see #parseSMTLIBString * * @return A conjunction of assertions in the scope (up to push/pop) at the * end of the string. From eeee77889b7759bab231797e7242c7cc7a9e0535 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 11:58:58 -0800 Subject: [PATCH 063/263] add parser error Signed-off-by: Nikolaj Bjorner --- src/api/c++/z3++.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 4b5e9d04e..236750bdf 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -174,6 +174,15 @@ namespace z3 { return e; } + void check_parser_error() const { + Z3_error_code e = Z3_get_error_code(*this); + if (e != Z3_OK && enable_exceptions()) { + Z3_string s = Z3_get_parser_error(*this); + if (s && *s) Z3_THROW(exception(s)); + } + check_error(); + } + /** \brief The C++ API uses by defaults exceptions on errors. For applications that don't work well with exceptions (there should be only few) @@ -2774,13 +2783,12 @@ namespace z3 { inline expr context::parse_string(char const* s) { Z3_ast r = Z3_parse_smtlib2_string(*this, s, 0, 0, 0, 0, 0, 0); - check_error(); - return expr(*this, r); - + check_parser_error(); + return expr(*this, r); } inline expr context::parse_file(char const* s) { Z3_ast r = Z3_parse_smtlib2_file(*this, s, 0, 0, 0, 0, 0, 0); - check_error(); + check_parser_error(); return expr(*this, r); } @@ -2796,7 +2804,7 @@ namespace z3 { decl_names[i] = decls[i].name(); } Z3_ast r = Z3_parse_smtlib2_string(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr()); - check_error(); + check_parser_error(); return expr(*this, r); } @@ -2812,7 +2820,7 @@ namespace z3 { decl_names[i] = decls[i].name(); } Z3_ast r = Z3_parse_smtlib2_file(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr()); - check_error(); + check_parser_error(); return expr(*this, r); } From d1ee5431a7798c451cba613c2301a5e5b5b8ef6d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 14:19:30 -0800 Subject: [PATCH 064/263] Update version Signed-off-by: Nikolaj Bjorner --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 715679957..0be2de537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ endif() # Project version ################################################################################ set(Z3_VERSION_MAJOR 4) -set(Z3_VERSION_MINOR 5) +set(Z3_VERSION_MINOR 6) set(Z3_VERSION_PATCH 1) set(Z3_VERSION_TWEAK 0) set(Z3_VERSION "${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}.${Z3_VERSION_PATCH}.${Z3_VERSION_TWEAK}") From b8e5fc9f435f6c67de4c9ea78298ac567dd40502 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 15:08:28 -0800 Subject: [PATCH 065/263] remove SMTLIB1 printing Signed-off-by: Nikolaj Bjorner --- src/api/api_ast.cpp | 23 +---------------------- src/api/z3_api.h | 4 +--- src/ast/ast_smt_pp.cpp | 17 +++++++++-------- src/ast/ast_smt_pp.h | 1 - 4 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index e22603225..76b0eb717 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -832,30 +832,9 @@ extern "C" { case Z3_PRINT_LOW_LEVEL: buffer << mk_ll_pp(to_ast(a), mk_c(c)->m()); break; - case Z3_PRINT_SMTLIB_COMPLIANT: { - ast_smt_pp pp(mk_c(c)->m()); - pp_params params; - pp.set_simplify_implies(params.simplify_implies()); - ast* a1 = to_ast(a); - pp.set_logic(mk_c(c)->fparams().m_logic); - if (!is_expr(a1)) { - buffer << mk_pp(a1, mk_c(c)->m()); - break; - } - if (mk_c(c)->get_print_mode() == Z3_PRINT_SMTLIB_COMPLIANT) { - pp.display_expr(buffer, to_expr(a1)); - break; - } - if (mk_c(c)->get_print_mode() == Z3_PRINT_SMTLIB2_COMPLIANT) { - pp.display_expr_smt2(buffer, to_expr(a1)); - break; - } - break; - } - case Z3_PRINT_SMTLIB2_COMPLIANT: { + case Z3_PRINT_SMTLIB2_COMPLIANT: buffer << mk_ismt2_pp(to_ast(a), mk_c(c)->m()); break; - } default: UNREACHABLE(); } diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 56d9f69b7..7edcada37 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1314,13 +1314,11 @@ typedef enum { - Z3_PRINT_SMTLIB_FULL: Print AST nodes in SMTLIB verbose format. - Z3_PRINT_LOW_LEVEL: Print AST nodes using a low-level format. - - Z3_PRINT_SMTLIB_COMPLIANT: Print AST nodes in SMTLIB 1.x compliant format. - Z3_PRINT_SMTLIB2_COMPLIANT: Print AST nodes in SMTLIB 2.x compliant format. */ typedef enum { Z3_PRINT_SMTLIB_FULL, Z3_PRINT_LOW_LEVEL, - Z3_PRINT_SMTLIB_COMPLIANT, Z3_PRINT_SMTLIB2_COMPLIANT } Z3_ast_print_mode; @@ -5116,7 +5114,7 @@ extern "C" { To print shared common subexpressions only once, use the Z3_PRINT_LOW_LEVEL mode. To print in way that conforms to SMT-LIB standards and uses let - expressions to share common sub-expressions use Z3_PRINT_SMTLIB_COMPLIANT. + expressions to share common sub-expressions use Z3_PRINT_SMTLIB2_COMPLIANT. \sa Z3_ast_to_string \sa Z3_pattern_to_string diff --git a/src/ast/ast_smt_pp.cpp b/src/ast/ast_smt_pp.cpp index 906fd054b..352c8db98 100644 --- a/src/ast/ast_smt_pp.cpp +++ b/src/ast/ast_smt_pp.cpp @@ -478,7 +478,7 @@ class smt_printer { void print_no_lets(expr *e) { - smt_printer p(m_out, m_manager, m_qlists, m_renaming, m_logic, true, m_simplify_implies, true, m_indent, m_num_var_names, m_var_names); + smt_printer p(m_out, m_manager, m_qlists, m_renaming, m_logic, true, m_simplify_implies, m_indent, m_num_var_names, m_var_names); p(e); } @@ -511,7 +511,7 @@ class smt_printer { m_out << "(! "; } { - smt_printer p(m_out, m_manager, m_qlists, m_renaming, m_logic, false, true, m_simplify_implies, m_indent, m_num_var_names, m_var_names); + smt_printer p(m_out, m_manager, m_qlists, m_renaming, m_logic, false, m_simplify_implies, m_indent, m_num_var_names, m_var_names); p(q->get_expr()); } @@ -704,7 +704,7 @@ class smt_printer { public: smt_printer(std::ostream& out, ast_manager& m, ptr_vector& ql, smt_renaming& rn, - symbol logic, bool no_lets, bool is_smt2, bool simplify_implies, unsigned indent, unsigned num_var_names = 0, char const* const* var_names = 0) : + symbol logic, bool no_lets, bool simplify_implies, unsigned indent, unsigned num_var_names = 0, char const* const* var_names = 0) : m_out(out), m_manager(m), m_qlists(ql), @@ -895,24 +895,25 @@ ast_smt_pp::ast_smt_pp(ast_manager& m): {} +#if 0 void ast_smt_pp::display_expr(std::ostream& strm, expr* n) { - ptr_vector ql; - smt_renaming rn; - smt_printer p(strm, m_manager, ql, rn, m_logic, false, false, m_simplify_implies, 0); + ptr_vector ql; smt_renaming rn; + smt_printer p(strm, m_manager, ql, rn, m_logic, false, m_simplify_implies, 0); p(n); } +#endif void ast_smt_pp::display_expr_smt2(std::ostream& strm, expr* n, unsigned indent, unsigned num_var_names, char const* const* var_names) { ptr_vector ql; smt_renaming rn; - smt_printer p(strm, m_manager, ql, rn, m_logic, false, true, m_simplify_implies, indent, num_var_names, var_names); + smt_printer p(strm, m_manager, ql, rn, m_logic, false, m_simplify_implies, indent, num_var_names, var_names); p(n); } void ast_smt_pp::display_ast_smt2(std::ostream& strm, ast* a, unsigned indent, unsigned num_var_names, char const* const* var_names) { ptr_vector ql; smt_renaming rn; - smt_printer p(strm, m_manager, ql, rn, m_logic, false, true, m_simplify_implies, indent, num_var_names, var_names); + smt_printer p(strm, m_manager, ql, rn, m_logic, false, m_simplify_implies, indent, num_var_names, var_names); if (is_expr(a)) { p(to_expr(a)); } diff --git a/src/ast/ast_smt_pp.h b/src/ast/ast_smt_pp.h index dd2a6d753..41ed06a92 100644 --- a/src/ast/ast_smt_pp.h +++ b/src/ast/ast_smt_pp.h @@ -77,7 +77,6 @@ public: void display(std::ostream& strm, expr* n); void display_smt2(std::ostream& strm, expr* n); - void display_expr(std::ostream& strm, expr* n); void display_expr_smt2(std::ostream& strm, expr* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0); void display_ast_smt2(std::ostream& strm, ast* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0); From 2749e547cf546608749df79cc18b150618e5eb87 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 28 Nov 2017 18:14:24 -0800 Subject: [PATCH 066/263] fix c example, remove more smtlib1 printing Signed-off-by: Nikolaj Bjorner --- examples/c/test_capi.c | 87 +++---------------------- src/api/api_ast.cpp | 7 +- src/ast/ast_smt_pp.cpp | 106 +------------------------------ src/ast/ast_smt_pp.h | 1 - src/ast/proofs/proof_checker.cpp | 2 +- src/smt/theory_arith_pp.h | 2 +- 6 files changed, 15 insertions(+), 190 deletions(-) diff --git a/examples/c/test_capi.c b/examples/c/test_capi.c index f6d515389..d71771f98 100644 --- a/examples/c/test_capi.c +++ b/examples/c/test_capi.c @@ -395,11 +395,10 @@ void assert_comm_axiom(Z3_context ctx, Z3_solver s, Z3_func_decl f) t_name = Z3_mk_string_symbol(ctx, "T"); - Z3_parse_smtlib_string(ctx, - "(benchmark comm :formula (forall (x T) (y T) (= (f x y) (f y x))))", + q = Z3_parse_smtlib2_string(ctx, + "(assert (forall ((x T) (y T)) (= (f x y) (f y x))))", 1, &t_name, &t, 1, &f_name, &f); - q = Z3_get_smtlib_formula(ctx, 0); printf("assert axiom:\n%s\n", Z3_ast_to_string(ctx, q)); Z3_solver_assert(ctx, s, q); } @@ -1632,35 +1631,6 @@ void error_code_example2() { } } -/** - \brief Demonstrates how to use the SMTLIB parser. - */ -void parser_example1() -{ - Z3_context ctx = mk_context(); - Z3_solver s = mk_solver(ctx); - unsigned i, num_formulas; - - printf("\nparser_example1\n"); - LOG_MSG("parser_example1"); - - - Z3_parse_smtlib_string(ctx, - "(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))", - 0, 0, 0, - 0, 0, 0); - num_formulas = Z3_get_smtlib_num_formulas(ctx); - for (i = 0; i < num_formulas; i++) { - Z3_ast f = Z3_get_smtlib_formula(ctx, i); - printf("formula %d: %s\n", i, Z3_ast_to_string(ctx, f)); - Z3_solver_assert(ctx, s, f); - } - - check(ctx, s, Z3_L_TRUE); - - del_solver(ctx, s); - Z3_del_context(ctx); -} /** \brief Demonstrates how to initialize the parser symbol table. @@ -1690,12 +1660,11 @@ void parser_example2() names[0] = Z3_mk_string_symbol(ctx, "a"); names[1] = Z3_mk_string_symbol(ctx, "b"); - Z3_parse_smtlib_string(ctx, - "(benchmark tst :formula (> a b))", + f = Z3_parse_smtlib2_string(ctx, + "(assert (> a b))", 0, 0, 0, /* 'x' and 'y' declarations are inserted as 'a' and 'b' into the parser symbol table. */ 2, names, decls); - f = Z3_get_smtlib_formula(ctx, 0); printf("formula: %s\n", Z3_ast_to_string(ctx, f)); Z3_solver_assert(ctx, s, f); check(ctx, s, Z3_L_TRUE); @@ -1737,11 +1706,10 @@ void parser_example3() assert_comm_axiom(ctx, s, g); - Z3_parse_smtlib_string(ctx, - "(benchmark tst :formula (forall (x Int) (y Int) (implies (= x y) (= (g x 0) (g 0 y)))))", + thm = Z3_parse_smtlib2_string(ctx, + "(assert (forall ((x Int) (y Int)) (=> (= x y) (= (g x 0) (g 0 y)))))", 0, 0, 0, 1, &g_name, &g); - thm = Z3_get_smtlib_formula(ctx, 0); printf("formula: %s\n", Z3_ast_to_string(ctx, thm)); prove(ctx, s, thm, Z3_TRUE); @@ -1749,41 +1717,6 @@ void parser_example3() Z3_del_context(ctx); } -/** - \brief Display the declarations, assumptions and formulas in a SMT-LIB string. -*/ -void parser_example4() -{ - Z3_context ctx; - unsigned i, num_decls, num_assumptions, num_formulas; - - printf("\nparser_example4\n"); - LOG_MSG("parser_example4"); - - ctx = mk_context(); - - Z3_parse_smtlib_string(ctx, - "(benchmark tst :extrafuns ((x Int) (y Int)) :assumption (= x 20) :formula (> x y) :formula (> x 0))", - 0, 0, 0, - 0, 0, 0); - num_decls = Z3_get_smtlib_num_decls(ctx); - for (i = 0; i < num_decls; i++) { - Z3_func_decl d = Z3_get_smtlib_decl(ctx, i); - printf("declaration %d: %s\n", i, Z3_func_decl_to_string(ctx, d)); - } - num_assumptions = Z3_get_smtlib_num_assumptions(ctx); - for (i = 0; i < num_assumptions; i++) { - Z3_ast a = Z3_get_smtlib_assumption(ctx, i); - printf("assumption %d: %s\n", i, Z3_ast_to_string(ctx, a)); - } - num_formulas = Z3_get_smtlib_num_formulas(ctx); - for (i = 0; i < num_formulas; i++) { - Z3_ast f = Z3_get_smtlib_formula(ctx, i); - printf("formula %d: %s\n", i, Z3_ast_to_string(ctx, f)); - } - Z3_del_context(ctx); -} - /** \brief Demonstrates how to handle parser errors using Z3 error handling support. */ @@ -1802,9 +1735,9 @@ void parser_example5() { s = mk_solver(ctx); Z3_del_config(cfg); - Z3_parse_smtlib_string(ctx, + Z3_parse_smtlib2_string(ctx, /* the following string has a parsing error: missing parenthesis */ - "(benchmark tst :extrafuns ((x Int (y Int)) :formula (> x y) :formula (> x 0))", + "(declare-const x Int) declare-const y Int) (assert (and (> x y) (> x 0)))", 0, 0, 0, 0, 0, 0); e = Z3_get_error_code(ctx); @@ -1817,7 +1750,7 @@ void parser_example5() { err: printf("Z3 error: %s.\n", Z3_get_error_msg(ctx, e)); if (ctx != NULL) { - printf("Error message: '%s'.\n",Z3_get_smtlib_error(ctx)); + printf("Error message: '%s'.\n",Z3_get_parser_error(ctx)); del_solver(ctx, s); Z3_del_context(ctx); } @@ -3065,10 +2998,8 @@ int main() { two_contexts_example1(); error_code_example1(); error_code_example2(); - parser_example1(); parser_example2(); parser_example3(); - parser_example4(); parser_example5(); numeral_example(); ite_example(); diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 76b0eb717..ae23ca100 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -872,12 +872,7 @@ extern "C" { for (unsigned i = 0; i < num_assumptions; ++i) { pp.add_assumption(to_expr(assumptions[i])); } - if (mk_c(c)->get_print_mode() == Z3_PRINT_SMTLIB2_COMPLIANT) { - pp.display_smt2(buffer, to_expr(formula)); - } - else { - pp.display(buffer, to_expr(formula)); - } + pp.display_smt2(buffer, to_expr(formula)); return mk_c(c)->mk_external_string(buffer.str()); Z3_CATCH_RETURN(""); } diff --git a/src/ast/ast_smt_pp.cpp b/src/ast/ast_smt_pp.cpp index 352c8db98..bad4b1984 100644 --- a/src/ast/ast_smt_pp.cpp +++ b/src/ast/ast_smt_pp.cpp @@ -340,8 +340,7 @@ class smt_printer { } - void pp_arg(expr *arg, app *parent) - { + void pp_arg(expr *arg, app *parent) { pp_marked_expr(arg); } @@ -417,7 +416,7 @@ class smt_printer { else if (m_simplify_implies && m_manager.is_implies(decl) && m_manager.is_implies(n->get_arg(1))) { expr *curr = n; expr *arg; - m_out << "(implies (and"; + m_out << "(=> (and"; while (m_manager.is_implies(curr)) { arg = to_app(curr)->get_arg(0); @@ -476,8 +475,7 @@ class smt_printer { } } - void print_no_lets(expr *e) - { + void print_no_lets(expr *e) { smt_printer p(m_out, m_manager, m_qlists, m_renaming, m_logic, true, m_simplify_implies, m_indent, m_num_var_names, m_var_names); p(e); } @@ -894,15 +892,6 @@ ast_smt_pp::ast_smt_pp(ast_manager& m): m_simplify_implies(true) {} - -#if 0 -void ast_smt_pp::display_expr(std::ostream& strm, expr* n) { - ptr_vector ql; smt_renaming rn; - smt_printer p(strm, m_manager, ql, rn, m_logic, false, m_simplify_implies, 0); - p(n); -} -#endif - void ast_smt_pp::display_expr_smt2(std::ostream& strm, expr* n, unsigned indent, unsigned num_var_names, char const* const* var_names) { ptr_vector ql; smt_renaming rn; @@ -1022,92 +1011,3 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) { p(n); } } - -void ast_smt_pp::display(std::ostream& strm, expr* n) { - ptr_vector ql; - decl_collector decls(m_manager); - smt_renaming rn; - - for (unsigned i = 0; i < m_assumptions.size(); ++i) { - decls.visit(m_assumptions[i].get()); - } - for (unsigned i = 0; i < m_assumptions_star.size(); ++i) { - decls.visit(m_assumptions_star[i].get()); - } - decls.visit(n); - - strm << "(benchmark "; - - if (m_benchmark_name != symbol::null) { - strm << m_benchmark_name << "\n"; - } - else { - strm << "unnamed\n"; - } - if (m_source_info != symbol::null && m_source_info != symbol("")) { - strm << ":source { " << m_source_info << " }\n"; - } - strm << ":status " << m_status << "\n"; - if (m_category != symbol::null && m_category != symbol("")) { - strm << ":category { " << m_category << " }\n"; - } - if (m_logic != symbol::null && m_logic != symbol("")) { - strm << ":logic " << m_logic << "\n"; - } - - if (m_attributes.size() > 0) { - strm << m_attributes.c_str(); - } - - ast_mark sort_mark; - for (unsigned i = 0; i < decls.get_num_sorts(); ++i) { - sort* s = decls.get_sorts()[i]; - if (!(*m_is_declared)(s)) { - smt_printer p(strm, m_manager, ql, rn, m_logic, true, false, m_simplify_implies, 0); - p.pp_sort_decl(sort_mark, s); - } - } - - for (unsigned i = 0; i < decls.get_num_decls(); ++i) { - func_decl* d = decls.get_func_decls()[i]; - if (!(*m_is_declared)(d)) { - strm << ":extrafuns ("; - smt_printer p(strm, m_manager, ql, rn, m_logic, true, false, m_simplify_implies, 0); - p(d); - strm << ")\n"; - } - } - - for (unsigned i = 0; i < decls.get_num_preds(); ++i) { - func_decl* d = decls.get_pred_decls()[i]; - if (!(*m_is_declared)(d)) { - strm << ":extrapreds ("; - smt_printer p(strm, m_manager, ql, rn, m_logic, true, false, m_simplify_implies, 0); - p.visit_pred(d); - strm << ")\n"; - } - } - - for (unsigned i = 0; i < m_assumptions.size(); ++i) { - expr * e = m_assumptions[i].get(); - strm << ":assumption\n"; - smt_printer p(strm, m_manager, ql, rn, m_logic, false, false, m_simplify_implies, 0); - p(e); - strm << "\n"; - } - - for (unsigned i = 0; i < m_assumptions_star.size(); ++i) { - strm << ":assumption-core\n"; - smt_printer p(strm, m_manager, ql, rn, m_logic, false, false, m_simplify_implies, 0); - p(m_assumptions_star[i].get()); - strm << "\n"; - } - - { - strm << ":formula\n"; - smt_printer p(strm, m_manager, ql, rn, m_logic, false, false, m_simplify_implies, 0); - p(n); - strm << "\n"; - } - strm << ")\n"; -} diff --git a/src/ast/ast_smt_pp.h b/src/ast/ast_smt_pp.h index 41ed06a92..ac2e33140 100644 --- a/src/ast/ast_smt_pp.h +++ b/src/ast/ast_smt_pp.h @@ -75,7 +75,6 @@ public: void set_is_declared(is_declared* id) { m_is_declared = id; } - void display(std::ostream& strm, expr* n); void display_smt2(std::ostream& strm, expr* n); void display_expr_smt2(std::ostream& strm, expr* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0); void display_ast_smt2(std::ostream& strm, ast* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0); diff --git a/src/ast/proofs/proof_checker.cpp b/src/ast/proofs/proof_checker.cpp index 3f9438229..6fd876efc 100644 --- a/src/ast/proofs/proof_checker.cpp +++ b/src/ast/proofs/proof_checker.cpp @@ -1284,7 +1284,7 @@ void proof_checker::dump_proof(unsigned num_antecedents, expr * const * antecede pp.add_assumption(antecedents[i]); expr_ref n(m); n = m.mk_not(consequent); - pp.display(out, n); + pp.display_smt2(out, n); out.close(); m_proof_lemma_id++; } diff --git a/src/smt/theory_arith_pp.h b/src/smt/theory_arith_pp.h index 67fe5a572..997698411 100644 --- a/src/smt/theory_arith_pp.h +++ b/src/smt/theory_arith_pp.h @@ -526,7 +526,7 @@ namespace smt { } } } - pp.display(out, m.mk_true()); + pp.display_smt2(out, m.mk_true()); } template From 09dc773658b5cd997e4fcdcdc0b8f922aec1a34e Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 29 Nov 2017 08:50:35 -0800 Subject: [PATCH 067/263] fix maxsat compilation for maxsat example Signed-off-by: Nikolaj Bjorner --- examples/maxsat/maxsat.c | 72 ++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/examples/maxsat/maxsat.c b/examples/maxsat/maxsat.c index a312e79ad..b5d8a6a8c 100644 --- a/examples/maxsat/maxsat.c +++ b/examples/maxsat/maxsat.c @@ -116,41 +116,6 @@ Z3_ast mk_binary_and(Z3_context ctx, Z3_ast in_1, Z3_ast in_2) } -/** - \brief Get hard constraints from a SMT-LIB file. We assume hard constraints - are formulas preceeded with the keyword :formula. - Return an array containing all formulas read by the last Z3_parse_smtlib_file invocation. - It will store the number of formulas in num_cnstrs. -*/ -Z3_ast * get_hard_constraints(Z3_context ctx, unsigned * num_cnstrs) -{ - Z3_ast * result; - unsigned i; - *num_cnstrs = Z3_get_smtlib_num_formulas(ctx); - result = (Z3_ast *) malloc(sizeof(Z3_ast) * (*num_cnstrs)); - for (i = 0; i < *num_cnstrs; i++) { - result[i] = Z3_get_smtlib_formula(ctx, i); - } - return result; -} - -/** - \brief Get soft constraints from a SMT-LIB file. We assume soft constraints - are formulas preceeded with the keyword :assumption. - Return an array containing all assumptions read by the last Z3_parse_smtlib_file invocation. - It will store the number of formulas in num_cnstrs. -*/ -Z3_ast * get_soft_constraints(Z3_context ctx, unsigned * num_cnstrs) -{ - Z3_ast * result; - unsigned i; - *num_cnstrs = Z3_get_smtlib_num_assumptions(ctx); - result = (Z3_ast *) malloc(sizeof(Z3_ast) * (*num_cnstrs)); - for (i = 0; i < *num_cnstrs; i++) { - result[i] = Z3_get_smtlib_assumption(ctx, i); - } - return result; -} /** \brief Free the given array of cnstrs that was allocated using get_hard_constraints or get_soft_constraints. @@ -610,14 +575,42 @@ int smtlib_maxsat(char * file_name, int approach) { Z3_context ctx; Z3_solver s; + unsigned i; + Z3_optimize opt; unsigned num_hard_cnstrs, num_soft_cnstrs; - Z3_ast * hard_cnstrs, * soft_cnstrs; + Z3_ast * hard_cnstrs, * soft_cnstrs, soft; + Z3_ast_vector hard, objs; unsigned result = 0; ctx = mk_context(); s = mk_solver(ctx); - Z3_parse_smtlib_file(ctx, file_name, 0, 0, 0, 0, 0, 0); - hard_cnstrs = get_hard_constraints(ctx, &num_hard_cnstrs); - soft_cnstrs = get_soft_constraints(ctx, &num_soft_cnstrs); + opt = Z3_mk_optimize(ctx); + Z3_optimize_inc_ref(ctx, opt); + Z3_optimize_from_file(ctx, opt, file_name); + hard = Z3_optimize_get_assertions(ctx, opt); + Z3_ast_vector_inc_ref(ctx, hard); + num_hard_cnstrs = Z3_ast_vector_size(ctx, hard); + hard_cnstrs = (Z3_ast *) malloc(sizeof(Z3_ast) * (num_hard_cnstrs)); + for (i = 0; i < num_hard_cnstrs; i++) { + hard_cnstrs[i] = Z3_ast_vector_get(ctx, hard, i); + } + objs = Z3_optimize_get_objectives(ctx, opt); + Z3_ast_vector_inc_ref(ctx, objs); + num_soft_cnstrs = 0; + soft = Z3_ast_vector_get(ctx, objs, 0); + while (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, soft))) == Z3_OP_ITE) { + ++num_soft_cnstrs; + soft = Z3_get_app_arg(ctx, Z3_to_app(ctx, soft), 1); + } + soft_cnstrs = (Z3_ast *) malloc(sizeof(Z3_ast) * (num_soft_cnstrs)); + num_soft_cnstrs = 0; + soft = Z3_ast_vector_get(ctx, objs, 0); + while (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, soft))) == Z3_OP_ITE) { + soft_cnstrs[num_soft_cnstrs] = Z3_get_app_arg(ctx, Z3_to_app(ctx, soft), 0); + ++num_soft_cnstrs; + soft = Z3_get_app_arg(ctx, Z3_to_app(ctx, soft), 1); + } + + // soft_cnstrs = get_soft_constraints(ctx, &num_soft_cnstrs); switch (approach) { case NAIVE_MAXSAT: result = naive_maxsat(ctx, s, num_hard_cnstrs, hard_cnstrs, num_soft_cnstrs, soft_cnstrs); @@ -633,6 +626,7 @@ int smtlib_maxsat(char * file_name, int approach) free_cnstr_array(hard_cnstrs); free_cnstr_array(soft_cnstrs); Z3_solver_dec_ref(ctx, s); + Z3_optimize_dec_ref(ctx, opt); return result; } From 0a67f6ee9b8593e70472af131a61a0ec24e35c98 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 29 Nov 2017 09:00:37 -0800 Subject: [PATCH 068/263] fix maxsat compilation for maxsat example Signed-off-by: Nikolaj Bjorner --- examples/maxsat/maxsat.c | 23 +++++++++-------------- src/api/z3_api.h | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/examples/maxsat/maxsat.c b/examples/maxsat/maxsat.c index b5d8a6a8c..5696f5b89 100644 --- a/examples/maxsat/maxsat.c +++ b/examples/maxsat/maxsat.c @@ -578,8 +578,9 @@ int smtlib_maxsat(char * file_name, int approach) unsigned i; Z3_optimize opt; unsigned num_hard_cnstrs, num_soft_cnstrs; - Z3_ast * hard_cnstrs, * soft_cnstrs, soft; + Z3_ast * hard_cnstrs, * soft_cnstrs; Z3_ast_vector hard, objs; + Z3_app soft; unsigned result = 0; ctx = mk_context(); s = mk_solver(ctx); @@ -595,22 +596,16 @@ int smtlib_maxsat(char * file_name, int approach) } objs = Z3_optimize_get_objectives(ctx, opt); Z3_ast_vector_inc_ref(ctx, objs); - num_soft_cnstrs = 0; - soft = Z3_ast_vector_get(ctx, objs, 0); - while (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, soft))) == Z3_OP_ITE) { - ++num_soft_cnstrs; - soft = Z3_get_app_arg(ctx, Z3_to_app(ctx, soft), 1); - } + + // soft constraints are stored in a single objective which is a sum + // of if-then-else expressions. + soft = Z3_to_app(ctx, Z3_ast_vector_get(ctx, objs, 0)); + num_soft_cnstrs = Z3_get_app_num_args(ctx, soft); soft_cnstrs = (Z3_ast *) malloc(sizeof(Z3_ast) * (num_soft_cnstrs)); - num_soft_cnstrs = 0; - soft = Z3_ast_vector_get(ctx, objs, 0); - while (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, soft))) == Z3_OP_ITE) { - soft_cnstrs[num_soft_cnstrs] = Z3_get_app_arg(ctx, Z3_to_app(ctx, soft), 0); - ++num_soft_cnstrs; - soft = Z3_get_app_arg(ctx, Z3_to_app(ctx, soft), 1); + for (i = 0; i < num_soft_cnstrs; ++i) { + soft_cnstrs[i] = Z3_get_app_arg(ctx, Z3_to_app(ctx, Z3_get_app_arg(ctx, soft, i)), 0); } - // soft_cnstrs = get_soft_constraints(ctx, &num_soft_cnstrs); switch (approach) { case NAIVE_MAXSAT: result = naive_maxsat(ctx, s, num_hard_cnstrs, hard_cnstrs, num_soft_cnstrs, soft_cnstrs); diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 7edcada37..d620254d1 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -4299,7 +4299,7 @@ extern "C" { /** \brief Return the i-th argument of the given application. - \pre i < Z3_get_num_args(c, a) + \pre i < Z3_get_app_num_args(c, a) def_API('Z3_get_app_arg', AST, (_in(CONTEXT), _in(APP), _in(UINT))) */ From b3ebcfe55855589d3b2fb4dbeda1310a64a23862 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Wed, 29 Nov 2017 18:20:59 -0500 Subject: [PATCH 069/263] correctly check third argument of str.indexof in theory_str --- src/smt/theory_str.cpp | 47 ++++++++++++++++++++++-------------------- src/smt/theory_str.h | 2 +- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 7936b581c..a931ae458 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -641,7 +641,6 @@ namespace smt { } app * theory_str::mk_indexof(expr * haystack, expr * needle) { - // TODO check meaning of the third argument here app * indexof = u.str.mk_index(haystack, needle, mk_int(0)); m_trail.push_back(indexof); // immediately force internalization so that axiom setup does not fail @@ -844,14 +843,7 @@ namespace smt { instantiate_axiom_Contains(e); } else if (u.str.is_index(a)) { instantiate_axiom_Indexof(e); - /* TODO NEXT: Indexof2/Lastindexof rewrite? - } else if (is_Indexof2(e)) { - instantiate_axiom_Indexof2(e); - } else if (is_LastIndexof(e)) { - instantiate_axiom_LastIndexof(e); - */ } else if (u.str.is_extract(a)) { - // TODO check semantics of substr vs. extract instantiate_axiom_Substr(e); } else if (u.str.is_replace(a)) { instantiate_axiom_Replace(e); @@ -1232,27 +1224,37 @@ namespace smt { context & ctx = get_context(); ast_manager & m = get_manager(); - app * expr = e->get_owner(); - if (axiomatized_terms.contains(expr)) { - TRACE("str", tout << "already set up Indexof axiom for " << mk_pp(expr, m) << std::endl;); + app * ex = e->get_owner(); + if (axiomatized_terms.contains(ex)) { + TRACE("str", tout << "already set up str.indexof axiom for " << mk_pp(ex, m) << std::endl;); return; } - axiomatized_terms.insert(expr); + SASSERT(ex->get_num_args() == 3); + // if the third argument is exactly the integer 0, we can use this "simple" indexof; + // otherwise, we call the "extended" version + expr * startingPosition = ex->get_arg(2); + rational startingInteger; + if (!m_autil.is_numeral(startingPosition, startingInteger) || !startingInteger.is_zero()) { + // "extended" indexof term with prefix + instantiate_axiom_Indexof_extended(e); + return; + } + axiomatized_terms.insert(ex); - TRACE("str", tout << "instantiate Indexof axiom for " << mk_pp(expr, m) << std::endl;); + TRACE("str", tout << "instantiate str.indexof axiom for " << mk_pp(ex, m) << std::endl;); expr_ref x1(mk_str_var("x1"), m); expr_ref x2(mk_str_var("x2"), m); expr_ref indexAst(mk_int_var("index"), m); - expr_ref condAst(mk_contains(expr->get_arg(0), expr->get_arg(1)), m); + expr_ref condAst(mk_contains(ex->get_arg(0), ex->get_arg(1)), m); SASSERT(condAst); // ----------------------- // true branch expr_ref_vector thenItems(m); // args[0] = x1 . args[1] . x2 - thenItems.push_back(ctx.mk_eq_atom(expr->get_arg(0), mk_concat(x1, mk_concat(expr->get_arg(1), x2)))); + thenItems.push_back(ctx.mk_eq_atom(ex->get_arg(0), mk_concat(x1, mk_concat(ex->get_arg(1), x2)))); // indexAst = |x1| thenItems.push_back(ctx.mk_eq_atom(indexAst, mk_strlen(x1))); // args[0] = x3 . x4 @@ -1260,11 +1262,11 @@ namespace smt { // /\ ! contains(x3, args[1]) expr_ref x3(mk_str_var("x3"), m); expr_ref x4(mk_str_var("x4"), m); - expr_ref tmpLen(m_autil.mk_add(indexAst, mk_strlen(expr->get_arg(1)), mk_int(-1)), m); + expr_ref tmpLen(m_autil.mk_add(indexAst, mk_strlen(ex->get_arg(1)), mk_int(-1)), m); SASSERT(tmpLen); - thenItems.push_back(ctx.mk_eq_atom(expr->get_arg(0), mk_concat(x3, x4))); + thenItems.push_back(ctx.mk_eq_atom(ex->get_arg(0), mk_concat(x3, x4))); thenItems.push_back(ctx.mk_eq_atom(mk_strlen(x3), tmpLen)); - thenItems.push_back(mk_not(m, mk_contains(x3, expr->get_arg(1)))); + thenItems.push_back(mk_not(m, mk_contains(x3, ex->get_arg(1)))); expr_ref thenBranch(m.mk_and(thenItems.size(), thenItems.c_ptr()), m); SASSERT(thenBranch); @@ -1276,7 +1278,7 @@ namespace smt { expr_ref breakdownAssert(m.mk_ite(condAst, thenBranch, elseBranch), m); SASSERT(breakdownAssert); - expr_ref reduceToIndex(ctx.mk_eq_atom(expr, indexAst), m); + expr_ref reduceToIndex(ctx.mk_eq_atom(ex, indexAst), m); SASSERT(reduceToIndex); expr_ref finalAxiom(m.mk_and(breakdownAssert, reduceToIndex), m); @@ -1284,18 +1286,19 @@ namespace smt { assert_axiom(finalAxiom); } - void theory_str::instantiate_axiom_Indexof2(enode * e) { + void theory_str::instantiate_axiom_Indexof_extended(enode * e) { context & ctx = get_context(); ast_manager & m = get_manager(); app * expr = e->get_owner(); if (axiomatized_terms.contains(expr)) { - TRACE("str", tout << "already set up Indexof2 axiom for " << mk_pp(expr, m) << std::endl;); + TRACE("str", tout << "already set up extended str.indexof axiom for " << mk_pp(expr, m) << std::endl;); return; } + SASSERT(expr->get_num_args() == 3); axiomatized_terms.insert(expr); - TRACE("str", tout << "instantiate Indexof2 axiom for " << mk_pp(expr, m) << std::endl;); + TRACE("str", tout << "instantiate extended str.indexof axiom for " << mk_pp(expr, m) << std::endl;); // ------------------------------------------------------------------------------- // if (arg[2] >= length(arg[0])) // ite2 diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index 03fd31162..dd2ca585b 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -447,7 +447,7 @@ protected: void instantiate_axiom_suffixof(enode * e); void instantiate_axiom_Contains(enode * e); void instantiate_axiom_Indexof(enode * e); - void instantiate_axiom_Indexof2(enode * e); + void instantiate_axiom_Indexof_extended(enode * e); void instantiate_axiom_LastIndexof(enode * e); void instantiate_axiom_Substr(enode * e); void instantiate_axiom_Replace(enode * e); From 9f567a62151e0dac1b4c19410a4b0593623b1cfc Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 29 Nov 2017 19:38:47 -0800 Subject: [PATCH 070/263] fix example file to be smt2 format Signed-off-by: Nikolaj Bjorner --- examples/maxsat/ex.smt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/maxsat/ex.smt b/examples/maxsat/ex.smt index 14ac0db89..d28b27c80 100644 --- a/examples/maxsat/ex.smt +++ b/examples/maxsat/ex.smt @@ -1,11 +1,11 @@ -(benchmark ex - :logic AUFLIA - :extrafuns ((x Int) (y Int) (z Int)) - :assumption (> x 0) - :assumption (<= x -1) - :assumption (or (> x 0) (< y 1)) - :assumption (> y 2) - :assumption (> y 3) - :assumption (<= y -1) - :formula (= z (+ x y))) +(declare-const x Int) +(declare-const y Int) +(declare-const z Int) +(assert-soft (> x 0)) +(assert-soft (<= x -1)) +(assert-soft (or (> x 0) (< y 1))) +(assert-soft (> y 2)) +(assert-soft (> y 3)) +(assert-soft (<= y -1)) +(assert (= z (+ x y))) \ No newline at end of file From ab58723ffccefee813b8255d8a98a09ab4af607d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 29 Nov 2017 20:52:19 -0800 Subject: [PATCH 071/263] fix dotnet example Signed-off-by: Nikolaj Bjorner --- examples/dotnet/Program.cs | 64 ++++++-------------------------------- 1 file changed, 9 insertions(+), 55 deletions(-) diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs index 64149a553..e5c863b0a 100644 --- a/examples/dotnet/Program.cs +++ b/examples/dotnet/Program.cs @@ -173,10 +173,9 @@ namespace test_mapi throw new Exception("function must be binary, and argument types must be equal to return type"); } - string bench = string.Format("(benchmark comm :formula (forall (x {0}) (y {1}) (= ({2} x y) ({3} y x))))", + string bench = string.Format("(assert (forall ((x {0}) (y {1})) (= ({2} x y) ({3} y x))))", t.Name, t.Name, f.Name, f.Name); - ctx.ParseSMTLIBString(bench, new Symbol[] { t.Name }, new Sort[] { t }, new Symbol[] { f.Name }, new FuncDecl[] { f }); - return ctx.SMTLIBFormulas[0]; + return ctx.ParseSMTLIB2String(bench, new Symbol[] { t.Name }, new Sort[] { t }, new Symbol[] { f.Name }, new FuncDecl[] { f }); } /// @@ -965,21 +964,6 @@ namespace test_mapi } } - /// - /// Shows how to read an SMT1 file. - /// - static void SMT1FileTest(string filename) - { - Console.Write("SMT File test "); - - using (Context ctx = new Context(new Dictionary() { { "MODEL", "true" } })) - { - ctx.ParseSMTLIBFile(filename); - - BoolExpr a = ctx.MkAnd(ctx.SMTLIBFormulas); - Console.WriteLine("read formula: " + a); - } - } /// /// Shows how to read an SMT2 file. @@ -1399,11 +1383,10 @@ namespace test_mapi { Console.WriteLine("ParserExample1"); - ctx.ParseSMTLIBString("(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))"); - foreach (BoolExpr f in ctx.SMTLIBFormulas) - Console.WriteLine("formula {0}", f); + var fml = ctx.ParseSMTLIB2String("(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))"); + Console.WriteLine("formula {0}", fml); - Model m = Check(ctx, ctx.MkAnd(ctx.SMTLIBFormulas), Status.SATISFIABLE); + Model m = Check(ctx, fml, Status.SATISFIABLE); } /// @@ -1412,15 +1395,11 @@ namespace test_mapi public static void ParserExample2(Context ctx) { Console.WriteLine("ParserExample2"); - Symbol[] declNames = { ctx.MkSymbol("a"), ctx.MkSymbol("b") }; FuncDecl a = ctx.MkConstDecl(declNames[0], ctx.MkIntSort()); FuncDecl b = ctx.MkConstDecl(declNames[1], ctx.MkIntSort()); FuncDecl[] decls = new FuncDecl[] { a, b }; - - ctx.ParseSMTLIBString("(benchmark tst :formula (> a b))", - null, null, declNames, decls); - BoolExpr f = ctx.SMTLIBFormulas[0]; + BoolExpr f = ctx.ParseSMTLIB2String("(assert (> a b))", null, null, declNames, decls); Console.WriteLine("formula: {0}", f); Check(ctx, f, Status.SATISFIABLE); } @@ -1438,39 +1417,15 @@ namespace test_mapi BoolExpr ca = CommAxiom(ctx, g); - ctx.ParseSMTLIBString("(benchmark tst :formula (forall (x Int) (y Int) (implies (= x y) (= (gg x 0) (gg 0 y)))))", + BoolExpr thm = ctx.ParseSMTLIB2String("(assert (forall ((x Int) (y Int)) (implies (= x y) (= (gg x 0) (gg 0 y)))))", null, null, new Symbol[] { ctx.MkSymbol("gg") }, new FuncDecl[] { g }); - BoolExpr thm = ctx.SMTLIBFormulas[0]; Console.WriteLine("formula: {0}", thm); Prove(ctx, thm, false, ca); } - /// - /// Display the declarations, assumptions and formulas in a SMT-LIB string. - /// - public static void ParserExample4(Context ctx) - { - Console.WriteLine("ParserExample4"); - - ctx.ParseSMTLIBString - ("(benchmark tst :extrafuns ((x Int) (y Int)) :assumption (= x 20) :formula (> x y) :formula (> x 0))"); - foreach (var decl in ctx.SMTLIBDecls) - { - Console.WriteLine("Declaration: {0}", decl); - } - foreach (var f in ctx.SMTLIBAssumptions) - { - Console.WriteLine("Assumption: {0}", f); - } - foreach (var f in ctx.SMTLIBFormulas) - { - Console.WriteLine("Formula: {0}", f); - } - } - /// /// Demonstrates how to handle parser errors using Z3 error handling support. /// @@ -1481,9 +1436,9 @@ namespace test_mapi try { - ctx.ParseSMTLIBString( + ctx.ParseSMTLIB2String( /* the following string has a parsing error: missing parenthesis */ - "(benchmark tst :extrafuns ((x Int (y Int)) :formula (> x y) :formula (> x 0))"); + "(declare-const x Int (declare-const y Int)) (assert (> x y))"); } catch (Z3Exception e) { @@ -2213,7 +2168,6 @@ namespace test_mapi BitvectorExample2(ctx); ParserExample1(ctx); ParserExample2(ctx); - ParserExample4(ctx); ParserExample5(ctx); ITEExample(ctx); EvalExample1(ctx); From c18d60a9c5c618b0b6a408090f6b890693759741 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 29 Nov 2017 20:56:36 -0800 Subject: [PATCH 072/263] fix java Signed-off-by: Nikolaj Bjorner --- examples/java/JavaExample.java | 65 ++++++---------------------------- 1 file changed, 10 insertions(+), 55 deletions(-) diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index 25076e27c..40fb25a92 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -170,10 +170,9 @@ class JavaExample String bench = "(benchmark comm :formula (forall (x " + t.getName() + ") (y " + t.getName() + ") (= (" + f.getName() + " x y) (" + f.getName() + " y x))))"; - ctx.parseSMTLIBString(bench, new Symbol[] { t.getName() }, + return ctx.parseSMTLIB2String(bench, new Symbol[] { t.getName() }, new Sort[] { t }, new Symbol[] { f.getName() }, new FuncDecl[] { f }); - return ctx.getSMTLIBFormulas()[0]; } // / "Hello world" example: create a Z3 logical context, and delete it. @@ -1028,21 +1027,6 @@ class JavaExample } } - // / Shows how to read an SMT1 file. - - void smt1FileTest(String filename) - { - System.out.print("SMT File test "); - - { - HashMap cfg = new HashMap(); - Context ctx = new Context(cfg); - ctx.parseSMTLIBFile(filename, null, null, null, null); - - BoolExpr a = ctx.mkAnd(ctx.getSMTLIBFormulas()); - System.out.println("read formula: " + a); - } - } // / Shows how to read an SMT2 file. @@ -1459,15 +1443,13 @@ class JavaExample System.out.println("ParserExample1"); Log.append("ParserExample1"); - ctx.parseSMTLIBString( - "(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))", + BoolExpr f = ctx.parseSMTLIB2String( + "(declare-const x Int) (declare-const y Int) (assert (and (> x y) (> x 0)))", null, null, null, null); - for (BoolExpr f : ctx.getSMTLIBFormulas()) - System.out.println("formula " + f); + System.out.println("formula " + f); @SuppressWarnings("unused") - Model m = check(ctx, ctx.mkAnd(ctx.getSMTLIBFormulas()), - Status.SATISFIABLE); + Model m = check(ctx, f, Status.SATISFIABLE); } // / Demonstrates how to initialize the parser symbol table. @@ -1482,9 +1464,8 @@ class JavaExample FuncDecl b = ctx.mkConstDecl(declNames[1], ctx.mkIntSort()); FuncDecl[] decls = new FuncDecl[] { a, b }; - ctx.parseSMTLIBString("(benchmark tst :formula (> a b))", null, null, + BoolExpr f = ctx.parseSMTLIB2String("(assert (> a b))", null, null, declNames, decls); - BoolExpr f = ctx.getSMTLIBFormulas()[0]; System.out.println("formula: " + f); check(ctx, f, Status.SATISFIABLE); } @@ -1502,39 +1483,14 @@ class JavaExample BoolExpr ca = commAxiom(ctx, g); - ctx.parseSMTLIBString( - "(benchmark tst :formula (forall (x Int) (y Int) (implies (= x y) (= (gg x 0) (gg 0 y)))))", + BoolExpr thm = ctx.parseSMTLIB2String( + "(assert (forall ((x Int) (y Int)) (=> (= x y) (= (gg x 0) (gg 0 y)))))", null, null, new Symbol[] { ctx.mkSymbol("gg") }, new FuncDecl[] { g }); - - BoolExpr thm = ctx.getSMTLIBFormulas()[0]; System.out.println("formula: " + thm); prove(ctx, thm, false, ca); } - // / Display the declarations, assumptions and formulas in a SMT-LIB string. - - public void parserExample4(Context ctx) - { - System.out.println("ParserExample4"); - Log.append("ParserExample4"); - - ctx.parseSMTLIBString( - "(benchmark tst :extrafuns ((x Int) (y Int)) :assumption (= x 20) :formula (> x y) :formula (> x 0))", - null, null, null, null); - for (FuncDecl decl : ctx.getSMTLIBDecls()) - { - System.out.println("Declaration: " + decl); - } - for (BoolExpr f : ctx.getSMTLIBAssumptions()) - { - System.out.println("Assumption: " + f); - } - for (BoolExpr f : ctx.getSMTLIBFormulas()) - { - System.out.println("Formula: " + f); - } - } // / Demonstrates how to handle parser errors using Z3 error handling // support. @@ -1546,12 +1502,12 @@ class JavaExample try { - ctx.parseSMTLIBString( + ctx.parseSMTLIB2String( /* * the following string has a parsing error: missing * parenthesis */ - "(benchmark tst :extrafuns ((x Int (y Int)) :formula (> x y) :formula (> x 0))", + "(declare-const x Int (declare-const y Int)) (assert (> x y))", null, null, null, null); } catch (Z3Exception e) { @@ -2341,7 +2297,6 @@ class JavaExample p.bitvectorExample2(ctx); p.parserExample1(ctx); p.parserExample2(ctx); - p.parserExample4(ctx); p.parserExample5(ctx); p.iteExample(ctx); p.evalExample1(ctx); From b96dacfff2247521564681df8fe2fb9a6b19bbe9 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 30 Nov 2017 08:42:01 -0800 Subject: [PATCH 073/263] set version, fix build of test files Signed-off-by: Nikolaj Bjorner --- CMakeLists.txt | 2 +- scripts/mk_project.py | 2 +- src/test/expr_rand.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0be2de537..871852c04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ endif() ################################################################################ set(Z3_VERSION_MAJOR 4) set(Z3_VERSION_MINOR 6) -set(Z3_VERSION_PATCH 1) +set(Z3_VERSION_PATCH 0) set(Z3_VERSION_TWEAK 0) set(Z3_VERSION "${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}.${Z3_VERSION_PATCH}.${Z3_VERSION_TWEAK}") set(Z3_FULL_VERSION_STR "${Z3_VERSION}") # Note this might be modified diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 8f75e97ed..60b3b7756 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -9,7 +9,7 @@ from mk_util import * # Z3 Project definition def init_project_def(): - set_version(4, 6, 1, 0) + set_version(4, 6, 0, 0) add_lib('util', []) add_lib('lp', ['util'], 'util/lp') add_lib('polynomial', ['util'], 'math/polynomial') diff --git a/src/test/expr_rand.cpp b/src/test/expr_rand.cpp index f1b20ba8e..f04cfe74f 100644 --- a/src/test/expr_rand.cpp +++ b/src/test/expr_rand.cpp @@ -43,7 +43,7 @@ void tst_expr_arith(unsigned num_files) { buffer << "random_arith_" << i << ".smt"; std::cout << buffer.str() << "\n"; std::ofstream file(buffer.str().c_str()); - pp.display(file, e.get()); + pp.display_smt2(file, e.get()); file.close(); } @@ -86,7 +86,7 @@ void tst_expr_rand(unsigned num_files) { buffer << "random_bv_" << i << ".smt"; std::cout << buffer.str() << "\n"; std::ofstream file(buffer.str().c_str()); - pp.display(file, e.get()); + pp.display_smt2(file, e.get()); file.close(); } From 4bb0e9b6337fda57e114229f6cb482e67d6900da Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 1 Dec 2017 00:52:06 -0800 Subject: [PATCH 074/263] fix test build Signed-off-by: Nikolaj Bjorner --- src/test/expr_rand.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/expr_rand.cpp b/src/test/expr_rand.cpp index f1b20ba8e..f04cfe74f 100644 --- a/src/test/expr_rand.cpp +++ b/src/test/expr_rand.cpp @@ -43,7 +43,7 @@ void tst_expr_arith(unsigned num_files) { buffer << "random_arith_" << i << ".smt"; std::cout << buffer.str() << "\n"; std::ofstream file(buffer.str().c_str()); - pp.display(file, e.get()); + pp.display_smt2(file, e.get()); file.close(); } @@ -86,7 +86,7 @@ void tst_expr_rand(unsigned num_files) { buffer << "random_bv_" << i << ".smt"; std::cout << buffer.str() << "\n"; std::ofstream file(buffer.str().c_str()); - pp.display(file, e.get()); + pp.display_smt2(file, e.get()); file.close(); } From c31ad147473c086ae82155823258dd34a5a031b8 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 1 Dec 2017 00:52:32 -0800 Subject: [PATCH 075/263] fix test build Signed-off-by: Nikolaj Bjorner --- src/test/expr_rand.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/expr_rand.cpp b/src/test/expr_rand.cpp index f04cfe74f..e52bfbc1a 100644 --- a/src/test/expr_rand.cpp +++ b/src/test/expr_rand.cpp @@ -40,7 +40,7 @@ void tst_expr_arith(unsigned num_files) { pp.set_logic(symbol("QF_AUFLIA")); std::ostringstream buffer; - buffer << "random_arith_" << i << ".smt"; + buffer << "random_arith_" << i << ".smt2"; std::cout << buffer.str() << "\n"; std::ofstream file(buffer.str().c_str()); pp.display_smt2(file, e.get()); @@ -83,7 +83,7 @@ void tst_expr_rand(unsigned num_files) { pp.set_logic(symbol("QF_AUFBV")); std::ostringstream buffer; - buffer << "random_bv_" << i << ".smt"; + buffer << "random_bv_" << i << ".smt2"; std::cout << buffer.str() << "\n"; std::ofstream file(buffer.str().c_str()); pp.display_smt2(file, e.get()); From 8357210d3cd9f03bc29c3d87e0a12a29a020afe8 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 1 Dec 2017 01:07:41 -0800 Subject: [PATCH 076/263] fix lack of warning/error for unbounded objectives in context of quantifiers #1382 Signed-off-by: Nikolaj Bjorner --- src/opt/opt_context.cpp | 19 +++++++++++++++---- src/opt/opt_context.h | 3 ++- src/opt/optsmt.cpp | 8 ++++++++ src/opt/optsmt.h | 2 ++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index 8d73ea7c8..3d296d92b 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -345,12 +345,24 @@ namespace opt { fix_model(mdl); } + bool context::contains_quantifiers() const { + for (expr* f : m_hard_constraints) { + if (has_quantifiers(f)) return true; + } + return false; + } + + lbool context::execute_min_max(unsigned index, bool committed, bool scoped, bool is_max) { if (scoped) get_solver().push(); lbool result = m_optsmt.lex(index, is_max); if (result == l_true) m_optsmt.get_model(m_model, m_labels); if (scoped) get_solver().pop(1); if (result == l_true && committed) m_optsmt.commit_assignment(index); + if (result == l_true && m_optsmt.is_unbounded(index, is_max) && contains_quantifiers()) { + throw default_exception("unbounded objectives on quantified constraints is not supported"); + result = l_undef; + } return result; } @@ -646,8 +658,7 @@ namespace opt { expr_fast_mark1 visited; is_bv proc(m); try { - for (unsigned i = 0; i < m_objectives.size(); ++i) { - objective & obj = m_objectives[i]; + for (objective& obj : m_objectives) { if (obj.m_type != O_MAXSMT) return false; maxsmt& ms = *m_maxsmts.find(obj.m_id); for (unsigned j = 0; j < ms.size(); ++j) { @@ -658,8 +669,8 @@ namespace opt { for (unsigned i = 0; i < sz; i++) { quick_for_each_expr(proc, visited, get_solver().get_assertion(i)); } - for (unsigned i = 0; i < m_hard_constraints.size(); ++i) { - quick_for_each_expr(proc, visited, m_hard_constraints[i].get()); + for (expr* f : m_hard_constraints) { + quick_for_each_expr(proc, visited, f); } } catch (is_bv::found) { diff --git a/src/opt/opt_context.h b/src/opt/opt_context.h index ad40db074..1ae60ef87 100644 --- a/src/opt/opt_context.h +++ b/src/opt/opt_context.h @@ -233,13 +233,14 @@ namespace opt { private: lbool execute(objective const& obj, bool committed, bool scoped); - lbool execute_min_max(unsigned index, bool committed, bool scoped, bool is_max); + lbool execute_min_max(unsigned index, bool committed, bool scoped, bool is_max); lbool execute_maxsat(symbol const& s, bool committed, bool scoped); lbool execute_lex(); lbool execute_box(); lbool execute_pareto(); lbool adjust_unknown(lbool r); bool scoped_lex(); + bool contains_quantifiers() const; expr_ref to_expr(inf_eps const& n); void to_exprs(inf_eps const& n, expr_ref_vector& es); diff --git a/src/opt/optsmt.cpp b/src/opt/optsmt.cpp index f8f75fbfd..3258cb33d 100644 --- a/src/opt/optsmt.cpp +++ b/src/opt/optsmt.cpp @@ -161,6 +161,14 @@ namespace opt { return l_true; } + bool optsmt::is_unbounded(unsigned obj_index, bool is_maximize) { + if (is_maximize) { + return !m_upper[obj_index].is_finite(); + } + else { + return !m_lower[obj_index].is_finite(); + } + } lbool optsmt::geometric_lex(unsigned obj_index, bool is_maximize) { arith_util arith(m); diff --git a/src/opt/optsmt.h b/src/opt/optsmt.h index 921352898..93fa3f624 100644 --- a/src/opt/optsmt.h +++ b/src/opt/optsmt.h @@ -49,6 +49,8 @@ namespace opt { lbool lex(unsigned obj_index, bool is_maximize); + bool is_unbounded(unsigned obj_index, bool is_maximize); + unsigned add(app* t); void updt_params(params_ref& p); From a9ebda105c0bfe94242c0cf702655411e78a662a Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 1 Dec 2017 08:59:36 -0800 Subject: [PATCH 077/263] remove assertion that gets violated on exception path (declaration of datatypes are not getting removed) Signed-off-by: Nikolaj Bjorner --- examples/c++/example.cpp | 3 +++ src/cmd_context/pdecl.cpp | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/c++/example.cpp b/examples/c++/example.cpp index 035d032bc..a6846eb4d 100644 --- a/examples/c++/example.cpp +++ b/examples/c++/example.cpp @@ -1138,8 +1138,11 @@ static void parse_example() { decls.push_back(c.function("a", 0, 0, B)); expr a = c.parse_string("(assert a)", sorts, decls); std::cout << a << "\n"; + + expr b = c.parse_string("(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))"); } + int main() { try { diff --git a/src/cmd_context/pdecl.cpp b/src/cmd_context/pdecl.cpp index 7eac1f347..8a7359e3a 100644 --- a/src/cmd_context/pdecl.cpp +++ b/src/cmd_context/pdecl.cpp @@ -852,8 +852,7 @@ pdecl_manager::pdecl_manager(ast_manager & m): pdecl_manager::~pdecl_manager() { dec_ref(m_list); reset_sort_info(); - SASSERT(m_sort2psort.empty()); - SASSERT(m_table.empty()); + SASSERT(m_sort2psort.empty()); } psort * pdecl_manager::mk_psort_cnst(sort * s) { @@ -865,6 +864,8 @@ psort * pdecl_manager::mk_psort_cnst(sort * s) { return r; } +static unsigned r_count = 0; + psort * pdecl_manager::register_psort(psort * n) { TRACE("register_psort", tout << "registering psort...\n"; n->display(tout); tout << "\n";); psort * r = m_table.insert_if_not_there(n); From 0bfea99cffc058424ca07f462b3067da50520a70 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 1 Dec 2017 14:43:52 -0800 Subject: [PATCH 078/263] fix issues found in parsing examples Signed-off-by: Nikolaj Bjorner --- examples/c++/example.cpp | 2 +- examples/dotnet/Program.cs | 4 ++-- src/api/api_parsers.cpp | 8 ++++++-- src/cmd_context/pdecl.cpp | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/c++/example.cpp b/examples/c++/example.cpp index a6846eb4d..df977268a 100644 --- a/examples/c++/example.cpp +++ b/examples/c++/example.cpp @@ -1139,7 +1139,7 @@ static void parse_example() { expr a = c.parse_string("(assert a)", sorts, decls); std::cout << a << "\n"; - expr b = c.parse_string("(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))"); + // expr b = c.parse_string("(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))"); } diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs index e5c863b0a..af3c59099 100644 --- a/examples/dotnet/Program.cs +++ b/examples/dotnet/Program.cs @@ -1383,7 +1383,7 @@ namespace test_mapi { Console.WriteLine("ParserExample1"); - var fml = ctx.ParseSMTLIB2String("(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))"); + var fml = ctx.ParseSMTLIB2String("(declare-const x Int) (declare-const y Int) (assert (> x y)) (assert (> x 0))"); Console.WriteLine("formula {0}", fml); Model m = Check(ctx, fml, Status.SATISFIABLE); @@ -1417,7 +1417,7 @@ namespace test_mapi BoolExpr ca = CommAxiom(ctx, g); - BoolExpr thm = ctx.ParseSMTLIB2String("(assert (forall ((x Int) (y Int)) (implies (= x y) (= (gg x 0) (gg 0 y)))))", + BoolExpr thm = ctx.ParseSMTLIB2String("(assert (forall ((x Int) (y Int)) (=> (= x y) (= (gg x 0) (gg 0 y)))))", null, null, new Symbol[] { ctx.MkSymbol("gg") }, new FuncDecl[] { g }); diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index a7235ef65..d5a98672b 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -52,8 +52,12 @@ extern "C" { ctx->insert(to_symbol(decl_names[i]), to_func_decl(decls[i])); } for (unsigned i = 0; i < num_sorts; ++i) { - psort* ps = ctx->pm().mk_psort_cnst(to_sort(sorts[i])); - ctx->insert(ctx->pm().mk_psort_user_decl(0, to_symbol(sort_names[i]), ps)); + sort* srt = to_sort(sorts[i]); + symbol name(to_symbol(sort_names[i])); + if (!ctx->find_psort_decl(name)) { + psort* ps = ctx->pm().mk_psort_cnst(srt); + ctx->insert(ctx->pm().mk_psort_user_decl(0, name, ps)); + } } std::stringstream errstrm; ctx->set_regular_stream(errstrm); diff --git a/src/cmd_context/pdecl.cpp b/src/cmd_context/pdecl.cpp index 8a7359e3a..d1185544a 100644 --- a/src/cmd_context/pdecl.cpp +++ b/src/cmd_context/pdecl.cpp @@ -853,6 +853,7 @@ pdecl_manager::~pdecl_manager() { dec_ref(m_list); reset_sort_info(); SASSERT(m_sort2psort.empty()); + SASSERT(m_table.empty()); } psort * pdecl_manager::mk_psort_cnst(sort * s) { From 5ee30a3cd9d45f005058ad38180d48213ed535fa Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 3 Dec 2017 20:00:24 +0100 Subject: [PATCH 079/263] include special functionality in parsers for solvers and opt for additional file formats Signed-off-by: Nikolaj Bjorner --- src/api/api_opt.cpp | 42 ++++-- src/api/api_solver.cpp | 63 +++++++++ src/api/c++/z3++.h | 39 ++++++ src/api/dotnet/Params.cs | 34 +++-- src/api/dotnet/Solver.cs | 86 +++++++++++- src/api/java/Solver.java | 18 +++ src/api/python/z3/z3.py | 14 ++ src/api/z3_api.h | 14 ++ src/opt/CMakeLists.txt | 1 + src/shell/main.cpp | 14 +- src/shell/opt_frontend.cpp | 264 +------------------------------------ src/util/file_path.h | 38 ++++++ 12 files changed, 324 insertions(+), 303 deletions(-) create mode 100644 src/util/file_path.h diff --git a/src/api/api_opt.cpp b/src/api/api_opt.cpp index ac11e1a33..0d96a6719 100644 --- a/src/api/api_opt.cpp +++ b/src/api/api_opt.cpp @@ -16,17 +16,19 @@ Revision History: --*/ #include +#include "util/cancel_eh.h" +#include "util/file_path.h" +#include "util/scoped_timer.h" +#include "parsers/smt2/smt2parser.h" +#include "opt/opt_context.h" +#include "opt/opt_cmds.h" +#include "opt/opt_parse.h" #include "api/z3.h" #include "api/api_log_macros.h" #include "api/api_stats.h" #include "api/api_context.h" #include "api/api_util.h" #include "api/api_model.h" -#include "opt/opt_context.h" -#include "opt/opt_cmds.h" -#include "util/cancel_eh.h" -#include "util/scoped_timer.h" -#include "parsers/smt2/smt2parser.h" #include "api/api_ast_vector.h" extern "C" { @@ -281,16 +283,27 @@ extern "C" { static void Z3_optimize_from_stream( Z3_context c, Z3_optimize opt, - std::istream& s) { - ast_manager& m = mk_c(c)->m(); + std::istream& s, + char const* ext) { + ast_manager& m = mk_c(c)->m(); + if (ext && std::string("opb") == ext) { + unsigned_vector h; + parse_opb(*to_optimize_ptr(opt), s, h); + return; + } + if (ext && std::string("wcnf") == ext) { + unsigned_vector h; + parse_wcnf(*to_optimize_ptr(opt), s, h); + return; + } scoped_ptr ctx = alloc(cmd_context, false, &m); install_opt_cmds(*ctx.get(), to_optimize_ptr(opt)); - ctx->set_ignore_check(true); std::stringstream errstrm; ctx->set_regular_stream(errstrm); + ctx->set_ignore_check(true); try { if (!parse_smt2_commands(*ctx.get(), s)) { - mk_c(c)->m_parser_error_buffer = errstrm.str(); + mk_c(c)->m_parser_error_buffer = errstrm.str(); ctx = nullptr; SET_ERROR_CODE(Z3_PARSER_ERROR); return; @@ -303,6 +316,7 @@ extern "C" { SET_ERROR_CODE(Z3_PARSER_ERROR); return; } + ptr_vector::const_iterator it = ctx->begin_assertions(); ptr_vector::const_iterator end = ctx->end_assertions(); for (; it != end; ++it) { @@ -310,6 +324,8 @@ extern "C" { } } + + void Z3_API Z3_optimize_from_string( Z3_context c, Z3_optimize d, @@ -318,7 +334,7 @@ extern "C" { //LOG_Z3_optimize_from_string(c, d, s); std::string str(s); std::istringstream is(str); - Z3_optimize_from_stream(c, d, is); + Z3_optimize_from_stream(c, d, is, nullptr); Z3_CATCH; } @@ -334,7 +350,7 @@ extern "C" { strm << "Could not open file " << s; throw default_exception(strm.str()); } - Z3_optimize_from_stream(c, d, is); + Z3_optimize_from_stream(c, d, is, get_extension(s)); Z3_CATCH; } @@ -347,8 +363,8 @@ extern "C" { mk_c(c)->save_object(v); expr_ref_vector hard(mk_c(c)->m()); to_optimize_ptr(o)->get_hard_constraints(hard); - for (unsigned i = 0; i < hard.size(); i++) { - v->m_ast_vector.push_back(hard[i].get()); + for (expr* h : hard) { + v->m_ast_vector.push_back(h); } RETURN_Z3(of_ast_vector(v)); Z3_CATCH_RETURN(0); diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index 2030c5210..0a0039f4c 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -28,11 +28,17 @@ Revision History: #include "solver/tactic2solver.h" #include "util/scoped_ctrl_c.h" #include "util/cancel_eh.h" +#include "util/file_path.h" #include "util/scoped_timer.h" #include "tactic/portfolio/smt_strategic_solver.h" #include "smt/smt_solver.h" #include "smt/smt_implied_equalities.h" #include "solver/smt_logics.h" +#include "cmd_context/cmd_context.h" +#include "parsers/smt2/smt2parser.h" +#include "sat/dimacs.h" +#include "sat/sat_solver.h" +#include "sat/tactic/goal2sat.h" extern "C" { @@ -121,6 +127,63 @@ extern "C" { Z3_CATCH_RETURN(0); } + void solver_from_stream(Z3_context c, Z3_solver s, std::istream& is) { + scoped_ptr ctx = alloc(cmd_context, false, &(mk_c(c)->m())); + ctx->set_ignore_check(true); + + if (!parse_smt2_commands(*ctx.get(), is)) { + ctx = nullptr; + SET_ERROR_CODE(Z3_PARSER_ERROR); + return; + } + + bool initialized = to_solver(s)->m_solver.get() != 0; + if (!initialized) + init_solver(c, s); + ptr_vector::const_iterator it = ctx->begin_assertions(); + ptr_vector::const_iterator end = ctx->end_assertions(); + for (; it != end; ++it) { + to_solver_ref(s)->assert_expr(*it); + } + // to_solver_ref(s)->set_model_converter(ctx->get_model_converter()); + } + + void Z3_API Z3_solver_from_string(Z3_context c, Z3_solver s, Z3_string c_str) { + Z3_TRY; + LOG_Z3_solver_from_string(c, s, c_str); + std::string str(c_str); + std::istringstream is(str); + solver_from_stream(c, s, is); + Z3_CATCH; + } + + void Z3_API Z3_solver_from_file(Z3_context c, Z3_solver s, Z3_string file_name) { + Z3_TRY; + LOG_Z3_solver_from_file(c, s, file_name); + char const* ext = get_extension(file_name); + std::ifstream is(file_name); + if (!is) { + SET_ERROR_CODE(Z3_FILE_ACCESS_ERROR); + } + else if (ext && std::string("dimacs") == ext) { + ast_manager& m = to_solver_ref(s)->get_manager(); + sat::solver solver(to_solver_ref(s)->get_params(), m.limit(), nullptr); + parse_dimacs(is, solver); + sat2goal s2g; + model_converter_ref mc; + atom2bool_var a2b(m); + goal g(m); + s2g(solver, a2b, to_solver_ref(s)->get_params(), g, mc); + for (unsigned i = 0; i < g.size(); ++i) { + to_solver_ref(s)->assert_expr(g.form(i)); + } + } + else { + solver_from_stream(c, s, is); + } + Z3_CATCH; + } + Z3_string Z3_API Z3_solver_get_help(Z3_context c, Z3_solver s) { Z3_TRY; LOG_Z3_solver_get_help(c, s); diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 236750bdf..d8087c4ee 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -1536,6 +1536,35 @@ namespace z3 { m_vector = s.m_vector; return *this; } + bool contains(T const& x) const { + for (auto y : *this) if (eq(x, y)) return true; + return false; + } + + class iterator { + ast_vector_tpl const* m_vector; + unsigned m_index; + public: + iterator(ast_vector_tpl const* v, unsigned i): m_vector(v), m_index(i) {} + iterator(iterator& other): m_vector(other.m_vector), m_index(other.m_index) {} + iterator operator=(iterator const& other) { m_vector = other.m_vector; m_index = other.m_index; return *this; } + + bool operator==(iterator const& other) { + return other.m_index == m_index; + }; + bool operator!=(iterator const& other) { + return other.m_index != m_index; + }; + iterator& operator++() { + ++m_index; + return *this; + } + iterator operator++(int) { iterator tmp = *this; ++m_index; return tmp; } + T * operator->() const { return &(operator*()); } + T operator*() const { return (*m_vector)[m_index]; } + }; + iterator begin() const { return iterator(this, 0); } + iterator end() const { return iterator(this, size()); } friend std::ostream & operator<<(std::ostream & out, ast_vector_tpl const & v) { out << Z3_ast_vector_to_string(v.ctx(), v); return out; } }; @@ -1911,6 +1940,11 @@ namespace z3 { return *this; } void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); } + void set(char const * k, bool v) { params p(ctx()); p.set(k, v); set(p); } + void set(char const * k, unsigned v) { params p(ctx()); p.set(k, v); set(p); } + void set(char const * k, double v) { params p(ctx()); p.set(k, v); set(p); } + void set(char const * k, symbol const & v) { params p(ctx()); p.set(k, v); set(p); } + void set(char const * k, char const* v) { params p(ctx()); p.set(k, v); set(p); } void push() { Z3_solver_push(ctx(), m_solver); check_error(); } void pop(unsigned n = 1) { Z3_solver_pop(ctx(), m_solver, n); check_error(); } void reset() { Z3_solver_reset(ctx(), m_solver); check_error(); } @@ -1923,6 +1957,10 @@ namespace z3 { void add(expr const & e, char const * p) { add(e, ctx().bool_const(p)); } + void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); } + void from_file(char const* file) { Z3_solver_from_file(ctx(), m_solver, file); ctx().check_parser_error(); } + void from_string(char const* s) { Z3_solver_from_string(ctx(), m_solver, s); ctx().check_parser_error(); } + check_result check() { Z3_lbool r = Z3_solver_check(ctx(), m_solver); check_error(); return to_check_result(r); } check_result check(unsigned n, expr * const assumptions) { array _assumptions(n); @@ -2003,6 +2041,7 @@ namespace z3 { return *this; } void add(expr const & f) { check_context(*this, f); Z3_goal_assert(ctx(), m_goal, f); check_error(); } + void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); } unsigned size() const { return Z3_goal_size(ctx(), m_goal); } expr operator[](int i) const { assert(0 <= i); Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); } Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); } diff --git a/src/api/dotnet/Params.cs b/src/api/dotnet/Params.cs index 23b037c78..37d73d5b1 100644 --- a/src/api/dotnet/Params.cs +++ b/src/api/dotnet/Params.cs @@ -31,98 +31,108 @@ namespace Microsoft.Z3 /// /// Adds a parameter setting. /// - public void Add(Symbol name, bool value) + public Params Add(Symbol name, bool value) { Contract.Requires(name != null); Native.Z3_params_set_bool(Context.nCtx, NativeObject, name.NativeObject, (value) ? 1 : 0); + return this; } /// /// Adds a parameter setting. /// - public void Add(Symbol name, uint value) + public Params Add(Symbol name, uint value) { Contract.Requires(name != null); Native.Z3_params_set_uint(Context.nCtx, NativeObject, name.NativeObject, value); + return this; } /// /// Adds a parameter setting. /// - public void Add(Symbol name, double value) + public Params Add(Symbol name, double value) { - Contract.Requires(name != null); - + Contract.Requires(name != null); + Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value); + return this; } /// /// Adds a parameter setting. /// - public void Add(Symbol name, string value) + public Params Add(Symbol name, string value) { Contract.Requires(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, Context.MkSymbol(value).NativeObject); + return this; } /// /// Adds a parameter setting. /// - public void Add(Symbol name, Symbol value) + public Params Add(Symbol name, Symbol value) { Contract.Requires(name != null); Contract.Requires(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, value.NativeObject); + return this; } /// /// Adds a parameter setting. /// - public void Add(string name, bool value) + public Params Add(string name, bool value) { Native.Z3_params_set_bool(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, (value) ? 1 : 0); + return this; } /// /// Adds a parameter setting. /// - public void Add(string name, uint value) + public Params Add(string name, uint value) { Native.Z3_params_set_uint(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value); + return this; } /// /// Adds a parameter setting. /// - public void Add(string name, double value) + public Params Add(string name, double value) { Native.Z3_params_set_double(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value); + return this; } /// /// Adds a parameter setting. /// - public void Add(string name, Symbol value) + public Params Add(string name, Symbol value) { Contract.Requires(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject); + return this; } /// /// Adds a parameter setting. /// - public void Add(string name, string value) + public Params Add(string name, string value) { Contract.Requires(name != null); Contract.Requires(value != null); Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, Context.MkSymbol(value).NativeObject); + return this; } /// diff --git a/src/api/dotnet/Solver.cs b/src/api/dotnet/Solver.cs index dff2677df..a176e790b 100644 --- a/src/api/dotnet/Solver.cs +++ b/src/api/dotnet/Solver.cs @@ -57,6 +57,49 @@ namespace Microsoft.Z3 } } + /// + /// Sets parameter on the solver + /// + public void Set(string name, bool value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(string name, uint value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(string name, double value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(string name, string value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(string name, Symbol value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(Symbol name, bool value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(Symbol name, uint value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(Symbol name, double value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(Symbol name, string value) { Parameters = Context.MkParams().Add(name, value); } + /// + /// Sets parameter on the solver + /// + public void Set(Symbol name, Symbol value) { Parameters = Context.MkParams().Add(name, value); } + + + /// /// Retrieves parameter descriptions for solver. /// @@ -140,11 +183,11 @@ namespace Microsoft.Z3 /// using the Boolean constants in ps. /// /// - /// This API is an alternative to with assumptions for extracting unsat cores. + /// This API is an alternative to with assumptions for extracting unsat cores. /// Both APIs can be used in the same solver. The unsat core will contain a combination /// of the Boolean variables provided using /// and the Boolean literals - /// provided using with assumptions. + /// provided using with assumptions. /// public void AssertAndTrack(BoolExpr[] constraints, BoolExpr[] ps) { @@ -165,11 +208,11 @@ namespace Microsoft.Z3 /// using the Boolean constant p. /// /// - /// This API is an alternative to with assumptions for extracting unsat cores. + /// This API is an alternative to with assumptions for extracting unsat cores. /// Both APIs can be used in the same solver. The unsat core will contain a combination /// of the Boolean variables provided using /// and the Boolean literals - /// provided using with assumptions. + /// provided using with assumptions. /// public void AssertAndTrack(BoolExpr constraint, BoolExpr p) { @@ -181,6 +224,22 @@ namespace Microsoft.Z3 Native.Z3_solver_assert_and_track(Context.nCtx, NativeObject, constraint.NativeObject, p.NativeObject); } + /// + /// Load solver assertions from a file. + /// + public void FromFile(string file) + { + Native.Z3_solver_from_file(Context.nCtx, NativeObject, file); + } + + /// + /// Load solver assertions from a string. + /// + public void FromString(string str) + { + Native.Z3_solver_from_string(Context.nCtx, NativeObject, str); + } + /// /// The number of assertions in the solver. /// @@ -225,6 +284,25 @@ namespace Microsoft.Z3 return lboolToStatus(r); } + /// + /// Checks whether the assertions in the solver are consistent or not. + /// + /// + /// + /// + /// + /// + public Status Check(IEnumerable assumptions) + { + Z3_lbool r; + BoolExpr[] asms = assumptions.ToArray(); + if (asms.Length == 0) + r = (Z3_lbool)Native.Z3_solver_check(Context.nCtx, NativeObject); + else + r = (Z3_lbool)Native.Z3_solver_check_assumptions(Context.nCtx, NativeObject, (uint)asms.Length, AST.ArrayToNative(asms)); + return lboolToStatus(r); + } + /// /// Retrieve fixed assignments to the set of variables in the form of consequences. /// Each consequence is an implication of the form diff --git a/src/api/java/Solver.java b/src/api/java/Solver.java index 19f3b01da..5bd4e65ba 100644 --- a/src/api/java/Solver.java +++ b/src/api/java/Solver.java @@ -1,3 +1,4 @@ + /** Copyright (c) 2012-2014 Microsoft Corporation @@ -120,6 +121,23 @@ public class Solver extends Z3Object { } } + /** + * Load solver assertions from a file. + */ + public void fromFile(String file) + { + Native.solverFromFile(getContext().nCtx(), getNativeObject(), file); + } + + /** + * Load solver assertions from a string. + */ + public void fromString(String str) + { + Native.solverFromString(getContext().nCtx(), getNativeObject(), str); + } + + /** * Assert multiple constraints into the solver, and track them (in the * unsat) core diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 2304491c8..237f35433 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -6324,6 +6324,20 @@ class Solver(Z3PPObject): sz = len(consequences) consequences = [ consequences[i] for i in range(sz) ] return CheckSatResult(r), consequences + + def from_file(self, filename): + """Parse assertions from a file""" + try: + Z3_solver_from_file(self.ctx.ref(), self.solver, filename) + except Z3Exception as e: + _handle_parse_error(e, self.ctx) + + def from_string(self, s): + """Parse assertions from a string""" + try: + Z3_solver_from_string(self.ctx.ref(), self.solver, s) + except Z3Exception as e: + _handle_parse_error(e, self.ctx) def proof(self): """Return a proof for the last `check()`. Proof construction must be enabled.""" diff --git a/src/api/z3_api.h b/src/api/z3_api.h index d620254d1..064476b9b 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -6038,6 +6038,20 @@ extern "C" { */ Z3_ast_vector Z3_API Z3_solver_get_assertions(Z3_context c, Z3_solver s); + /** + \brief load solver assertions from a file. + + def_API('Z3_solver_from_file', VOID, (_in(CONTEXT), _in(SOLVER), _in(STRING))) + */ + void Z3_API Z3_solver_from_file(Z3_context c, Z3_solver s, Z3_string file_name); + + /** + \brief load solver assertions from a string. + + def_API('Z3_solver_from_string', VOID, (_in(CONTEXT), _in(SOLVER), _in(STRING))) + */ + void Z3_API Z3_solver_from_string(Z3_context c, Z3_solver s, Z3_string file_name); + /** \brief Check whether the assertions in a given solver are consistent or not. diff --git a/src/opt/CMakeLists.txt b/src/opt/CMakeLists.txt index 05a62b6c2..28a14be2e 100644 --- a/src/opt/CMakeLists.txt +++ b/src/opt/CMakeLists.txt @@ -6,6 +6,7 @@ z3_add_component(opt opt_cmds.cpp opt_context.cpp opt_pareto.cpp + opt_parse.cpp optsmt.cpp opt_solver.cpp pb_sls.cpp diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 8b719681c..f0e640d66 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -35,6 +35,7 @@ Revision History: #include "util/error_codes.h" #include "util/gparams.h" #include "util/env_params.h" +#include "util/file_path.h" #include "shell/lp_frontend.h" typedef enum { IN_UNSPECIFIED, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_Z3_LOG, IN_MPS } input_kind; @@ -286,19 +287,6 @@ void parse_cmd_line_args(int argc, char ** argv) { } } -char const * get_extension(char const * file_name) { - if (file_name == 0) - return 0; - char const * last_dot = 0; - for (;;) { - char const * tmp = strchr(file_name, '.'); - if (tmp == 0) { - return last_dot; - } - last_dot = tmp + 1; - file_name = last_dot; - } -} int STD_CALL main(int argc, char ** argv) { try{ diff --git a/src/shell/opt_frontend.cpp b/src/shell/opt_frontend.cpp index e1aff8669..8154cbde4 100644 --- a/src/shell/opt_frontend.cpp +++ b/src/shell/opt_frontend.cpp @@ -13,6 +13,7 @@ Copyright (c) 2015 Microsoft Corporation #include "util/gparams.h" #include "util/timeout.h" #include "ast/reg_decl_plugins.h" +#include "opt/opt_parse.h" extern bool g_display_statistics; static bool g_first_interrupt = true; @@ -20,262 +21,6 @@ static opt::context* g_opt = 0; static double g_start_time = 0; static unsigned_vector g_handles; -class opt_stream_buffer { - std::istream & m_stream; - int m_val; - unsigned m_line; -public: - opt_stream_buffer(std::istream & s): - m_stream(s), - m_line(0) { - m_val = m_stream.get(); - } - int operator *() const { return m_val;} - void operator ++() { m_val = m_stream.get(); } - int ch() const { return m_val; } - void next() { m_val = m_stream.get(); } - bool eof() const { return ch() == EOF; } - unsigned line() const { return m_line; } - void skip_whitespace() { - while ((ch() >= 9 && ch() <= 13) || ch() == 32) { - if (ch() == 10) ++m_line; - next(); - } - } - void skip_space() { - while (ch() != 10 && ((ch() >= 9 && ch() <= 13) || ch() == 32)) { - next(); - } - } - void skip_line() { - while(true) { - if (eof()) { - return; - } - if (ch() == '\n') { - ++m_line; - next(); - return; - } - next(); - } - } - - bool parse_token(char const* token) { - skip_whitespace(); - char const* t = token; - while (ch() == *t) { - next(); - ++t; - } - return 0 == *t; - } - - int parse_int() { - int val = 0; - bool neg = false; - skip_whitespace(); - - if (ch() == '-') { - neg = true; - next(); - } - else if (ch() == '+') { - next(); - } - if (ch() < '0' || ch() > '9') { - std::cerr << "(error line " << line() << " \"unexpected char: " << ((char)ch()) << "\" )\n"; - exit(3); - } - while (ch() >= '0' && ch() <= '9') { - val = val*10 + (ch() - '0'); - next(); - } - return neg ? -val : val; - } - - unsigned parse_unsigned() { - skip_space(); - if (ch() == '\n') { - return UINT_MAX; - } - unsigned val = 0; - while (ch() >= '0' && ch() <= '9') { - val = val*10 + (ch() - '0'); - next(); - } - return val; - } -}; - -class wcnf { - opt::context& opt; - ast_manager& m; - opt_stream_buffer& in; - - app_ref read_clause(unsigned& weight) { - int parsed_lit; - int var; - weight = in.parse_unsigned(); - app_ref result(m), p(m); - expr_ref_vector ors(m); - while (true) { - parsed_lit = in.parse_int(); - if (parsed_lit == 0) - break; - var = abs(parsed_lit); - p = m.mk_const(symbol(var), m.mk_bool_sort()); - if (parsed_lit < 0) p = m.mk_not(p); - ors.push_back(p); - } - result = to_app(mk_or(m, ors.size(), ors.c_ptr())); - return result; - } - - void parse_spec(unsigned& num_vars, unsigned& num_clauses, unsigned& max_weight) { - in.parse_token("wcnf"); - num_vars = in.parse_unsigned(); - num_clauses = in.parse_unsigned(); - max_weight = in.parse_unsigned(); - } - -public: - - wcnf(opt::context& opt, opt_stream_buffer& in): opt(opt), m(opt.get_manager()), in(in) { - opt.set_clausal(true); - } - - void parse() { - unsigned num_vars = 0, num_clauses = 0, max_weight = 0; - while (true) { - in.skip_whitespace(); - if (in.eof()) { - break; - } - else if (*in == 'c') { - in.skip_line(); - } - else if (*in == 'p') { - ++in; - parse_spec(num_vars, num_clauses, max_weight); - } - else { - unsigned weight = 0; - app_ref cls = read_clause(weight); - if (weight >= max_weight) { - opt.add_hard_constraint(cls); - } - else { - unsigned id = opt.add_soft_constraint(cls, rational(weight), symbol::null); - if (g_handles.empty()) { - g_handles.push_back(id); - } - } - } - } - } -}; - - -class opb { - opt::context& opt; - ast_manager& m; - opt_stream_buffer& in; - arith_util arith; - - app_ref parse_id() { - bool negated = in.parse_token("~"); - if (!in.parse_token("x")) { - std::cerr << "(error line " << in.line() << " \"unexpected char: " << ((char)in.ch()) << "\")\n"; - exit(3); - } - app_ref p(m); - int id = in.parse_int(); - p = m.mk_const(symbol(id), m.mk_bool_sort()); - if (negated) p = m.mk_not(p); - in.skip_whitespace(); - return p; - } - - app_ref parse_ids() { - app_ref result = parse_id(); - while (*in == '~' || *in == 'x') { - result = m.mk_and(result, parse_id()); - } - return result; - } - - rational parse_coeff_r() { - in.skip_whitespace(); - svector num; - bool pos = true; - if (*in == '-') pos = false, ++in; - if (*in == '+') ++in; - if (!pos) num.push_back('-'); - in.skip_whitespace(); - while ('0' <= *in && *in <='9') num.push_back(*in), ++in; - num.push_back(0); - return rational(num.c_ptr()); - } - - app_ref parse_coeff() { - return app_ref(arith.mk_numeral(parse_coeff_r(), true), m); - } - - app_ref parse_term() { - app_ref c = parse_coeff(); - app_ref e = parse_ids(); - return app_ref(m.mk_ite(e, c, arith.mk_numeral(rational(0), true)), m); - } - - void parse_objective() { - app_ref t = parse_term(); - while (!in.parse_token(";") && !in.eof()) { - t = arith.mk_add(t, parse_term()); - } - g_handles.push_back(opt.add_objective(t, false)); - } - - void parse_constraint() { - app_ref t = parse_term(); - while (!in.eof()) { - if (in.parse_token(">=")) { - t = arith.mk_ge(t, parse_coeff()); - in.parse_token(";"); - break; - } - if (in.parse_token("=")) { - t = m.mk_eq(t, parse_coeff()); - in.parse_token(";"); - break; - } - t = arith.mk_add(t, parse_term()); - } - opt.add_hard_constraint(t); - } -public: - opb(opt::context& opt, opt_stream_buffer& in): - opt(opt), m(opt.get_manager()), - in(in), arith(m) {} - - void parse() { - while (true) { - in.skip_whitespace(); - if (in.eof()) { - break; - } - else if (*in == '*') { - in.skip_line(); - } - else if (in.parse_token("min:")) { - parse_objective(); - } - else { - parse_constraint(); - } - } - } -}; static void display_results() { @@ -335,14 +80,11 @@ static unsigned parse_opt(std::istream& in, bool is_wcnf) { g_opt = &opt; params_ref p = gparams::get_module("opt"); opt.updt_params(p); - opt_stream_buffer _in(in); if (is_wcnf) { - wcnf wcnf(opt, _in); - wcnf.parse(); + parse_wcnf(opt, in, g_handles); } else { - opb opb(opt, _in); - opb.parse(); + parse_opb(opt, in, g_handles); } try { lbool r = opt.optimize(); diff --git a/src/util/file_path.h b/src/util/file_path.h new file mode 100644 index 000000000..8a2d053d8 --- /dev/null +++ b/src/util/file_path.h @@ -0,0 +1,38 @@ +/*++ +Copyright (c) 2017 Microsoft Corporation + +Module Name: + + file_path.h + +Abstract: + + File path functions. + +Author: + + Nikolaj Bjorner (nbjorner) 2017-11-19 + +Revision History: + +--*/ +#ifndef FILE_PATH_H_ +#define FILE_PATH_H_ + +inline char const * get_extension(char const * file_name) { + if (file_name == 0) + return 0; + char const * last_dot = 0; + for (;;) { + char const * tmp = strchr(file_name, '.'); + if (tmp == 0) { + return last_dot; + } + last_dot = tmp + 1; + file_name = last_dot; + } +} + +#endif /* FILE_PATH_H_ */ + + From a83af22841afb848eb0c339b2878eded602baf6b Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 3 Dec 2017 20:00:45 +0100 Subject: [PATCH 080/263] include special functionality in parsers for solvers and opt for additional file formats Signed-off-by: Nikolaj Bjorner --- src/opt/opt_parse.cpp | 317 ++++++++++++++++++++++++++++++++++++++++++ src/opt/opt_parse.h | 28 ++++ 2 files changed, 345 insertions(+) create mode 100644 src/opt/opt_parse.cpp create mode 100644 src/opt/opt_parse.h diff --git a/src/opt/opt_parse.cpp b/src/opt/opt_parse.cpp new file mode 100644 index 000000000..2cba7561f --- /dev/null +++ b/src/opt/opt_parse.cpp @@ -0,0 +1,317 @@ +/*++ +Copyright (c) 2017 Microsoft Corporation + +Module Name: + + opt_parse.cpp + +Abstract: + + Parse utilities for optimization. + +Author: + + Nikolaj Bjorner (nbjorner) 2017-11-19 + +Revision History: + +--*/ +#include "opt/opt_context.h" +#include "opt/opt_parse.h" + + +class opt_stream_buffer { + std::istream & m_stream; + int m_val; + unsigned m_line; +public: + opt_stream_buffer(std::istream & s): + m_stream(s), + m_line(0) { + m_val = m_stream.get(); + } + int operator *() const { return m_val;} + void operator ++() { m_val = m_stream.get(); } + int ch() const { return m_val; } + void next() { m_val = m_stream.get(); } + bool eof() const { return ch() == EOF; } + unsigned line() const { return m_line; } + void skip_whitespace(); + void skip_space(); + void skip_line(); + bool parse_token(char const* token); + int parse_int(); + unsigned parse_unsigned(); +}; + + +void opt_stream_buffer::skip_whitespace() { + while ((ch() >= 9 && ch() <= 13) || ch() == 32) { + if (ch() == 10) ++m_line; + next(); + } +} + +void opt_stream_buffer::skip_space() { + while (ch() != 10 && ((ch() >= 9 && ch() <= 13) || ch() == 32)) { + next(); + } +} +void opt_stream_buffer::skip_line() { + while(true) { + if (eof()) { + return; + } + if (ch() == '\n') { + ++m_line; + next(); + return; + } + next(); + } +} + +bool opt_stream_buffer::parse_token(char const* token) { + skip_whitespace(); + char const* t = token; + while (ch() == *t) { + next(); + ++t; + } + return 0 == *t; +} + +unsigned opt_stream_buffer::parse_unsigned() { + skip_space(); + if (ch() == '\n') { + return UINT_MAX; + } + unsigned val = 0; + while (ch() >= '0' && ch() <= '9') { + val = val*10 + (ch() - '0'); + next(); + } + return val; +} + +int opt_stream_buffer::parse_int() { + int val = 0; + bool neg = false; + skip_whitespace(); + + if (ch() == '-') { + neg = true; + next(); + } + else if (ch() == '+') { + next(); + } + if (ch() < '0' || ch() > '9') { + std::cerr << "(error line " << line() << " \"unexpected char: " << ((char)ch()) << "\" )\n"; + exit(3); + } + while (ch() >= '0' && ch() <= '9') { + val = val*10 + (ch() - '0'); + next(); + } + return neg ? -val : val; +} + + +class wcnf { + opt::context& opt; + ast_manager& m; + opt_stream_buffer& in; + unsigned_vector& m_handles; + + app_ref read_clause(unsigned& weight) { + int parsed_lit; + int var; + weight = in.parse_unsigned(); + app_ref result(m), p(m); + expr_ref_vector ors(m); + while (true) { + parsed_lit = in.parse_int(); + if (parsed_lit == 0) + break; + var = abs(parsed_lit); + p = m.mk_const(symbol(var), m.mk_bool_sort()); + if (parsed_lit < 0) p = m.mk_not(p); + ors.push_back(p); + } + result = to_app(mk_or(m, ors.size(), ors.c_ptr())); + return result; + } + + void parse_spec(unsigned& num_vars, unsigned& num_clauses, unsigned& max_weight) { + in.parse_token("wcnf"); + num_vars = in.parse_unsigned(); + num_clauses = in.parse_unsigned(); + max_weight = in.parse_unsigned(); + } + +public: + + wcnf(opt::context& opt, opt_stream_buffer& in, unsigned_vector& h): opt(opt), m(opt.get_manager()), in(in), m_handles(h) { + opt.set_clausal(true); + } + + void parse() { + unsigned num_vars = 0, num_clauses = 0, max_weight = 0; + while (true) { + in.skip_whitespace(); + if (in.eof()) { + break; + } + else if (*in == 'c') { + in.skip_line(); + } + else if (*in == 'p') { + ++in; + parse_spec(num_vars, num_clauses, max_weight); + } + else { + unsigned weight = 0; + app_ref cls = read_clause(weight); + if (weight >= max_weight) { + opt.add_hard_constraint(cls); + } + else { + unsigned id = opt.add_soft_constraint(cls, rational(weight), symbol::null); + if (m_handles.empty()) { + m_handles.push_back(id); + } + } + } + } + } +}; + + +class opb { + opt::context& opt; + ast_manager& m; + opt_stream_buffer& in; + unsigned_vector& m_handles; + arith_util arith; + + app_ref parse_id() { + bool negated = in.parse_token("~"); + if (!in.parse_token("x")) { + std::cerr << "(error line " << in.line() << " \"unexpected char: " << ((char)in.ch()) << "\" expected \"x\")\n"; + exit(3); + } + app_ref p(m); + int id = in.parse_int(); + p = m.mk_const(symbol(id), m.mk_bool_sort()); + if (negated) p = m.mk_not(p); + in.skip_whitespace(); + return p; + } + + app_ref parse_ids() { + app_ref result = parse_id(); + while (*in == '~' || *in == 'x') { + result = m.mk_and(result, parse_id()); + } + return result; + } + + rational parse_coeff_r() { + in.skip_whitespace(); + svector num; + bool pos = true; + if (*in == '-') pos = false, ++in; + if (*in == '+') ++in; + if (!pos) num.push_back('-'); + in.skip_whitespace(); + while ('0' <= *in && *in <='9') num.push_back(*in), ++in; + num.push_back(0); + return rational(num.c_ptr()); + } + + app_ref parse_coeff() { + return app_ref(arith.mk_numeral(parse_coeff_r(), true), m); + } + + app_ref parse_term() { + app_ref c = parse_coeff(); + app_ref e = parse_ids(); + return app_ref(m.mk_ite(e, c, arith.mk_numeral(rational(0), true)), m); + } + + void parse_objective(bool is_min) { + app_ref t = parse_term(); + while (!in.parse_token(";") && !in.eof()) { + if (is_min) { + t = arith.mk_add(t, parse_term()); + } + else { + t = arith.mk_sub(t, parse_term()); + } + } + m_handles.push_back(opt.add_objective(t, false)); + } + + void parse_constraint() { + app_ref t = parse_term(); + while (!in.eof()) { + if (in.parse_token(">=")) { + t = arith.mk_ge(t, parse_coeff()); + in.parse_token(";"); + break; + } + if (in.parse_token("=")) { + t = m.mk_eq(t, parse_coeff()); + in.parse_token(";"); + break; + } + if (in.parse_token("<=")) { + t = arith.mk_le(t, parse_coeff()); + in.parse_token(";"); + break; + } + t = arith.mk_add(t, parse_term()); + } + opt.add_hard_constraint(t); + } +public: + opb(opt::context& opt, opt_stream_buffer& in, unsigned_vector& h): + opt(opt), m(opt.get_manager()), + in(in), m_handles(h), arith(m) {} + + void parse() { + while (true) { + in.skip_whitespace(); + if (in.eof()) { + break; + } + else if (*in == '*') { + in.skip_line(); + } + else if (in.parse_token("min:")) { + parse_objective(true); + } + else if (in.parse_token("max:")) { + parse_objective(false); + } + else { + parse_constraint(); + } + } + } +}; + +void parse_wcnf(opt::context& opt, std::istream& is, unsigned_vector& h) { + opt_stream_buffer _is(is); + wcnf w(opt, _is, h); + w.parse(); +} + +void parse_opb(opt::context& opt, std::istream& is, unsigned_vector& h) { + opt_stream_buffer _is(is); + opb opb(opt, _is, h); + opb.parse(); +} + + diff --git a/src/opt/opt_parse.h b/src/opt/opt_parse.h new file mode 100644 index 000000000..b058efcac --- /dev/null +++ b/src/opt/opt_parse.h @@ -0,0 +1,28 @@ +/*++ +Copyright (c) 2017 Microsoft Corporation + +Module Name: + + opt_parse.h + +Abstract: + + Parse utilities for optimization. + +Author: + + Nikolaj Bjorner (nbjorner) 2017-11-19 + +Revision History: + +--*/ +#ifndef OPT_PARSE_H_ +#define OPT_PARSE_H_ + +void parse_wcnf(opt::context& opt, std::istream& is, unsigned_vector& h); + +void parse_opb(opt::context& opt, std::istream& is, unsigned_vector& h); + +#endif /* OPT_PARSE_H_ */ + + From fb470a1868f3990b9c2220a0b482ee4642f1e796 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 4 Dec 2017 15:32:20 +0530 Subject: [PATCH 081/263] include path Signed-off-by: Nikolaj Bjorner --- src/util/file_path.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/file_path.h b/src/util/file_path.h index 8a2d053d8..c34c8b408 100644 --- a/src/util/file_path.h +++ b/src/util/file_path.h @@ -18,6 +18,7 @@ Revision History: --*/ #ifndef FILE_PATH_H_ #define FILE_PATH_H_ +#include inline char const * get_extension(char const * file_name) { if (file_name == 0) From 5f8c97532ce6eb8b26c66a18caca53bd8596680c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 4 Dec 2017 18:10:48 +0530 Subject: [PATCH 082/263] circumvent build errors introduced when using the ast_vector_tpl iterator Signed-off-by: Nikolaj Bjorner --- src/api/c++/z3++.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index d8087c4ee..03fdfc39d 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -1537,7 +1537,7 @@ namespace z3 { return *this; } bool contains(T const& x) const { - for (auto y : *this) if (eq(x, y)) return true; + for (T y : *this) if (eq(x, y)) return true; return false; } @@ -1957,7 +1957,8 @@ namespace z3 { void add(expr const & e, char const * p) { add(e, ctx().bool_const(p)); } - void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); } + // fails for some compilers: + // void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); } void from_file(char const* file) { Z3_solver_from_file(ctx(), m_solver, file); ctx().check_parser_error(); } void from_string(char const* s) { Z3_solver_from_string(ctx(), m_solver, s); ctx().check_parser_error(); } @@ -2041,7 +2042,8 @@ namespace z3 { return *this; } void add(expr const & f) { check_context(*this, f); Z3_goal_assert(ctx(), m_goal, f); check_error(); } - void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); } + // fails for some compilers: + // void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); } unsigned size() const { return Z3_goal_size(ctx(), m_goal); } expr operator[](int i) const { assert(0 <= i); Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); } Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); } From 60af4a5820e05391096aacb92c9a9ca3675a7753 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 4 Dec 2017 19:12:51 +0530 Subject: [PATCH 083/263] deal with ambiguity Signed-off-by: Nikolaj Bjorner --- examples/dotnet/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs index af3c59099..71364013b 100644 --- a/examples/dotnet/Program.cs +++ b/examples/dotnet/Program.cs @@ -1945,7 +1945,7 @@ namespace test_mapi BoolExpr p2 = ctx.MkBoolConst("P2"); BoolExpr p3 = ctx.MkBoolConst("P3"); BoolExpr p4 = ctx.MkBoolConst("P4"); - BoolExpr[] assumptions = new BoolExpr[] { ctx.MkNot(p1), ctx.MkNot(p2), ctx.MkNot(p3), ctx.MkNot(p4) }; + Expr[] assumptions = new Expr[] { ctx.MkNot(p1), ctx.MkNot(p2), ctx.MkNot(p3), ctx.MkNot(p4) }; BoolExpr f1 = ctx.MkAnd(new BoolExpr[] { pa, pb, pc }); BoolExpr f2 = ctx.MkAnd(new BoolExpr[] { pa, ctx.MkNot(pb), pc }); BoolExpr f3 = ctx.MkOr(ctx.MkNot(pa), ctx.MkNot(pc)); From 2770c8f884c292c480804a074c18c23c77fc5b79 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 5 Dec 2017 08:15:23 +0530 Subject: [PATCH 084/263] disable C++11 dependency to fix the travis build Signed-off-by: Nikolaj Bjorner --- src/api/c++/z3++.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 03fdfc39d..8ff2be239 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -1536,10 +1536,13 @@ namespace z3 { m_vector = s.m_vector; return *this; } + /* + Disabled pending C++98 build upgrade bool contains(T const& x) const { for (T y : *this) if (eq(x, y)) return true; return false; } + */ class iterator { ast_vector_tpl const* m_vector; From 39d1ad3edb51e9d50788aa6c0533c741e81d9a28 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 7 Dec 2017 05:15:53 +0530 Subject: [PATCH 085/263] fix #1390 Signed-off-by: Nikolaj Bjorner --- src/api/api_context.cpp | 5 +++-- src/cmd_context/pdecl.cpp | 2 -- src/parsers/smt2/smt2parser.cpp | 10 +++++++--- src/smt/theory_seq.cpp | 1 - 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 73fb2c212..23ac62a66 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -111,9 +111,10 @@ namespace api { m_last_obj = 0; u_map::iterator it = m_allocated_objects.begin(); while (it != m_allocated_objects.end()) { - DEBUG_CODE(warning_msg("Uncollected memory: %d: %s", it->m_key, typeid(*it->m_value).name());); + api::object* val = it->m_value; + DEBUG_CODE(warning_msg("Uncollected memory: %d: %s", it->m_key, typeid(*val).name());); m_allocated_objects.remove(it->m_key); - dealloc(it->m_value); + dealloc(val); it = m_allocated_objects.begin(); } } diff --git a/src/cmd_context/pdecl.cpp b/src/cmd_context/pdecl.cpp index d1185544a..f75fbfa29 100644 --- a/src/cmd_context/pdecl.cpp +++ b/src/cmd_context/pdecl.cpp @@ -865,8 +865,6 @@ psort * pdecl_manager::mk_psort_cnst(sort * s) { return r; } -static unsigned r_count = 0; - psort * pdecl_manager::register_psort(psort * n) { TRACE("register_psort", tout << "registering psort...\n"; n->display(tout); tout << "\n";); psort * r = m_table.insert_if_not_there(n); diff --git a/src/parsers/smt2/smt2parser.cpp b/src/parsers/smt2/smt2parser.cpp index fd592f7c7..a06438c73 100644 --- a/src/parsers/smt2/smt2parser.cpp +++ b/src/parsers/smt2/smt2parser.cpp @@ -867,7 +867,7 @@ namespace smt2 { throw parser_exception("invalid datatype declaration, too many data-type bodies defined"); } symbol dt_name = m_dt_names[i]; - parse_datatype_dec(new_ct_decls); + parse_datatype_dec(nullptr, new_ct_decls); d = pm().mk_pdatatype_decl(m_dt_name2arity.find(dt_name), dt_name, new_ct_decls.size(), new_ct_decls.c_ptr()); } else { @@ -942,7 +942,7 @@ namespace smt2 { pdatatype_decl_ref d(pm()); pconstructor_decl_ref_buffer new_ct_decls(pm()); - parse_datatype_dec(new_ct_decls); + parse_datatype_dec(&dt_name, new_ct_decls); d = pm().mk_pdatatype_decl(m_sort_id2param_idx.size(), dt_name, new_ct_decls.size(), new_ct_decls.c_ptr()); check_missing(d, line, pos); @@ -956,12 +956,16 @@ namespace smt2 { // datatype_dec ::= ( constructor_dec+ ) | ( par ( symbol+ ) ( constructor_dec+ ) ) - void parse_datatype_dec(pconstructor_decl_ref_buffer & ct_decls) { + void parse_datatype_dec(symbol* dt_name, pconstructor_decl_ref_buffer & ct_decls) { check_lparen_next("invalid datatype declaration, '(' expected"); if (curr_id() == m_par) { next(); parse_sort_decl_params(); check_lparen_next("invalid constructor declaration after par, '(' expected"); + unsigned sz = m_sort_id2param_idx.size(); + if (sz > 0 && dt_name) { + m_ctx.insert(pm().mk_psort_dt_decl(sz, *dt_name)); + } parse_constructor_decls(ct_decls); check_rparen_next("invalid datatype declaration, ')' expected"); } diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index ca6ab048c..9830a16b4 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -3661,7 +3661,6 @@ void theory_seq::add_extract_axiom(expr* e) { literal ls_le_i = mk_simplified_literal(m_autil.mk_le(mk_sub(i, ls), zero)); literal li_ge_ls = mk_simplified_literal(m_autil.mk_ge(ls_minus_i_l, zero)); literal l_ge_zero = mk_simplified_literal(m_autil.mk_ge(l, zero)); - literal l_le_zero = mk_simplified_literal(m_autil.mk_le(l, zero)); literal ls_le_0 = mk_simplified_literal(m_autil.mk_le(ls, zero)); add_axiom(~i_ge_0, ~ls_le_i, mk_seq_eq(xey, s)); From 9554723b44860733e8a633de724aa06bb9ed9a99 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Wed, 6 Dec 2017 20:50:03 -0500 Subject: [PATCH 086/263] use safer mk_and in extended indexof --- src/smt/theory_str.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index a931ae458..4f84ed2f7 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -1330,7 +1330,7 @@ namespace smt { ite2ElseItems.push_back(ctx.mk_eq_atom(indexAst, mk_indexof(suffix, expr->get_arg(1)))); ite2ElseItems.push_back(ctx.mk_eq_atom(expr->get_arg(2), prefixLen)); ite2ElseItems.push_back(ite3); - expr_ref ite2Else(m.mk_and(ite2ElseItems.size(), ite2ElseItems.c_ptr()), m); + expr_ref ite2Else(mk_and(ite2ElseItems), m); SASSERT(ite2Else); expr_ref ite2(m.mk_ite( From 92059942e63b4605e1434dd70a49829420be7d18 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 7 Dec 2017 00:48:20 +0000 Subject: [PATCH 087/263] [CMake] Use C++11 when building C++ API example. This is a change requested by @NikolajBjorner ( https://github.com/Z3Prover/z3/commit/5f8c97532ce6eb8b26c66a18caca53bd8596680c#commitcomment-26049417 ). --- examples/c++/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt index d60604924..0a41d6a93 100644 --- a/examples/c++/CMakeLists.txt +++ b/examples/c++/CMakeLists.txt @@ -13,6 +13,22 @@ find_package(Z3 # use this option. NO_DEFAULT_PATH ) + +################################################################################ +# Z3 C++ API bindings require C++11 +################################################################################ +if ("${CMAKE_VERSION}" VERSION_LESS "3.1") + # Legacy CMake support + if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + else() + message(FATAL_ERROR "Setting C++ version to C++11 not supported for \"${CMAKE_CXX_COMPILER_ID}\"") + endif() +else () + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif () + message(STATUS "Z3_FOUND: ${Z3_FOUND}") message(STATUS "Found Z3 ${Z3_VERSION_STRING}") message(STATUS "Z3_DIR: ${Z3_DIR}") From 1941a539996f32e4dcb6add072b9db6cca971915 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 7 Dec 2017 00:53:54 +0000 Subject: [PATCH 088/263] [Release Notes] Note that C++11 is required to build Z3 and is also required by the C++ API bindings. --- RELEASE_NOTES | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index ec05160da..e85e3d8d6 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,7 +1,11 @@ RELEASE NOTES -Version 4.5.x +Version 4.6.0 ============= +- New requirements: + - C++11 capable compiler to build Z3. + - C++ API now requires C++11 or newer. + - New features (including): - A new string solver from University of Waterloo - A new linear real arithmetic solver From 8e1ab23c3d976030487adcb52bc4136e5b83fbfb Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 7 Dec 2017 18:43:29 +0530 Subject: [PATCH 089/263] remove deprecated functions from ML API. #1393 Signed-off-by: Nikolaj Bjorner --- src/api/ml/z3.ml | 50 ----------------------------------------------- src/api/ml/z3.mli | 37 ----------------------------------- 2 files changed, 87 deletions(-) diff --git a/src/api/ml/z3.ml b/src/api/ml/z3.ml index 46fe5bd6d..ce305bb4e 100644 --- a/src/api/ml/z3.ml +++ b/src/api/ml/z3.ml @@ -1975,56 +1975,6 @@ struct (List.length assumptions) assumptions formula - let parse_smtlib_string (ctx:context) (str:string) (sort_names:Symbol.symbol list) (sorts:Sort.sort list) (decl_names:Symbol.symbol list) (decls:func_decl list) = - let csn = List.length sort_names in - let cs = List.length sorts in - let cdn = List.length decl_names in - let cd = List.length decls in - if (csn <> cs || cdn <> cd) then - raise (Error "Argument size mismatch") - else - Z3native.parse_smtlib_string ctx str - cs sort_names sorts cd decl_names decls - - let parse_smtlib_file (ctx:context) (file_name:string) (sort_names:Symbol.symbol list) (sorts:Sort.sort list) (decl_names:Symbol.symbol list) (decls:func_decl list) = - let csn = (List.length sort_names) in - let cs = (List.length sorts) in - let cdn = (List.length decl_names) in - let cd = (List.length decls) in - if (csn <> cs || cdn <> cd) then - raise (Error "Argument size mismatch") - else - Z3native.parse_smtlib_file ctx file_name - cs sort_names sorts cd decl_names decls - - let get_num_smtlib_formulas (ctx:context) = Z3native.get_smtlib_num_formulas ctx - - let get_smtlib_formulas (ctx:context) = - let n = get_num_smtlib_formulas ctx in - let f i = Z3native.get_smtlib_formula ctx i in - mk_list f n - - let get_num_smtlib_assumptions (ctx:context) = Z3native.get_smtlib_num_assumptions ctx - - let get_smtlib_assumptions (ctx:context) = - let n = get_num_smtlib_assumptions ctx in - let f i = Z3native.get_smtlib_assumption ctx i in - mk_list f n - - let get_num_smtlib_decls (ctx:context) = Z3native.get_smtlib_num_decls ctx - - let get_smtlib_decls (ctx:context) = - let n = get_num_smtlib_decls ctx in - let f i = Z3native.get_smtlib_decl ctx i in - mk_list f n - - let get_num_smtlib_sorts (ctx:context) = Z3native.get_smtlib_num_sorts ctx - - let get_smtlib_sorts (ctx:context) = - let n = get_num_smtlib_sorts ctx in - let f i = Z3native.get_smtlib_sort ctx i in - mk_list f n - let parse_smtlib2_string (ctx:context) (str:string) (sort_names:Symbol.symbol list) (sorts:Sort.sort list) (decl_names:Symbol.symbol list) (decls:func_decl list) = let csn = List.length sort_names in let cs = List.length sorts in diff --git a/src/api/ml/z3.mli b/src/api/ml/z3.mli index 4f10b275a..9f4cd9cd9 100644 --- a/src/api/ml/z3.mli +++ b/src/api/ml/z3.mli @@ -3441,43 +3441,6 @@ sig @return A string representation of the benchmark. *) val benchmark_to_smtstring : context -> string -> string -> string -> string -> Expr.expr list -> Expr.expr -> string - (** Parse the given string using the SMT-LIB parser. - - The symbol table of the parser can be initialized using the given sorts and declarations. - The symbols in the arrays in the third and fifth argument - don't need to match the names of the sorts and declarations in the arrays in the fourth - and sixth argument. This is a useful feature since we can use arbitrary names to - reference sorts and declarations. *) - val parse_smtlib_string : context -> string -> Symbol.symbol list -> Sort.sort list -> Symbol.symbol list -> FuncDecl.func_decl list -> unit - - (** Parse the given file using the SMT-LIB parser. - {!parse_smtlib_string} *) - val parse_smtlib_file : context -> string -> Symbol.symbol list -> Sort.sort list -> Symbol.symbol list -> FuncDecl.func_decl list -> unit - - (** The number of SMTLIB formulas parsed by the last call to [ParseSMTLIBString] or [ParseSMTLIBFile]. *) - val get_num_smtlib_formulas : context -> int - - (** The formulas parsed by the last call to [ParseSMTLIBString] or [ParseSMTLIBFile]. *) - val get_smtlib_formulas : context -> Expr.expr list - - (** The number of SMTLIB assumptions parsed by the last call to [ParseSMTLIBString] or [ParseSMTLIBFile]. *) - val get_num_smtlib_assumptions : context -> int - - (** The assumptions parsed by the last call to [ParseSMTLIBString] or [ParseSMTLIBFile]. *) - val get_smtlib_assumptions : context -> Expr.expr list - - (** The number of SMTLIB declarations parsed by the last call to [ParseSMTLIBString] or [ParseSMTLIBFile]. *) - val get_num_smtlib_decls : context -> int - - (** The declarations parsed by the last call to [ParseSMTLIBString] or [ParseSMTLIBFile]. *) - val get_smtlib_decls : context -> FuncDecl.func_decl list - - (** The number of SMTLIB sorts parsed by the last call to [ParseSMTLIBString] or [ParseSMTLIBFile]. *) - val get_num_smtlib_sorts : context -> int - - (** The sort declarations parsed by the last call to [ParseSMTLIBString] or [ParseSMTLIBFile]. *) - val get_smtlib_sorts : context -> Sort.sort list - (** Parse the given string using the SMT-LIB2 parser. {!parse_smtlib_string} From 3f19c12a12de86c48fbd139af228490df3d1b5c9 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 8 Dec 2017 05:48:34 +0530 Subject: [PATCH 090/263] add obj_ref_map to make it easier to maintain reference counts with a map of objects Signed-off-by: Nikolaj Bjorner --- src/util/obj_ref_hashtable.h | 111 +++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/util/obj_ref_hashtable.h diff --git a/src/util/obj_ref_hashtable.h b/src/util/obj_ref_hashtable.h new file mode 100644 index 000000000..6bd4f1556 --- /dev/null +++ b/src/util/obj_ref_hashtable.h @@ -0,0 +1,111 @@ +/*++ +Copyright (c) 2017 Microsoft Corporation + +Module Name: + + obj_ref_hashtable.h + +Abstract: + + corresponding obj_map with reference count managment. + +Author: + + Nikolaj Bjorner (nbjorner) 2017-12-8 + +Revision History: + +--*/ +#ifndef OBJ_REF_HASHTABLE_H_ +#define OBJ_REF_HASHTABLE_H_ + +#include "util/obj_hashtable.h" + +template +class obj_ref_map { + M& m; + obj_map m_table; +public: + obj_ref_map(M& m):m(m) {} + + ~obj_ref_map() { reset(); } + + void reset() { + for (auto& kv : m_table) { + m.dec_ref(kv.m_key); + } + m_table.reset(); + } + + void finalize() { + reset(); + m_table.finalize(); + } + + bool empty() const { return m_table.empty(); } + + unsigned size() const { return m_table.size(); } + + unsigned capacity() const { return m_table.capacity(); } + + iterator begin() const { return m_table.begin(); } + + iterator end() const { return m_table.end(); } + + void insert(Key * const k, Value const & v) { + if (!m_table.contains(k)) m.inc_ref(k); + m_table.insert(k, v); + } + + void insert(Key * const k, Value && v) { + if (!m_table.contains(k)) m.inc_ref(k); + m_table.insert(k, v); + } + + key_data const & insert_if_not_there(Key * k, Value const & v) { + if (!m_table.contains(k)) m.inc_ref(k); + return m_table.insert_if_not_there(k, v); + } + + obj_map_entry * insert_if_not_there2(Key * k, Value const & v) { + if (!m_table.contains(k)) m.inc_ref(k); + return m_table.insert_if_not_there2(k, v); + } + + obj_map_entry * find_core(Key * k) const { return m_table.find_core(k); } + + bool find(Key * const k, Value & v) const { return m_table.find(k, v); } + + value const & find(key * k) const { return m_table.find(k); } + + value & find(key * k) { return m_table.find(k); } + + value const & operator[](key * k) const { return find(k); } + + value & operator[](key * k) { return find(k); } + + iterator find_iterator(Key * k) const { return m_table.find_iterator(k); } + + bool contains(Key * k) const { return m_table.contains(k); } + + void remove(Key * k) { + if (m_table.contains(k)) { + m_table.remove(k); + m.dec_ref(k); + } + } + + void erase(Key * k) { remove(k); } + + unsigned long long get_num_collision() const { return m_table.get_num_collision(); } + + void swap(obj_ref_map & other) { + m_table.swap(other.m_table); + } + + +}; + + +#endif /* OBJ_REF_HASHTABLE_H_ */ + From a5d5dfdf86c507e300a11b37f161bb9587e988e5 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 8 Dec 2017 09:23:57 +0530 Subject: [PATCH 091/263] fix setup for non-linear real arithmetic per QF_UFNRA regresssions Signed-off-by: Nikolaj Bjorner --- src/ast/static_features.cpp | 14 +++----------- src/smt/smt_setup.cpp | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/ast/static_features.cpp b/src/ast/static_features.cpp index 3db4d02a2..9f52ea9a5 100644 --- a/src/ast/static_features.cpp +++ b/src/ast/static_features.cpp @@ -111,16 +111,6 @@ void static_features::flush_cache() { m_expr2formula_depth.reset(); } -#if 0 -bool static_features::is_non_linear(expr * e) const { - if (!is_arith_expr(e)) - return false; - if (is_numeral(e)) - return true; - if (m_autil.is_add(e)) - return true; // the non -} -#endif bool static_features::is_diff_term(expr const * e, rational & r) const { // lhs can be 'x' or '(+ k x)' @@ -301,10 +291,12 @@ void static_features::update_core(expr * e) { m_num_interpreted_constants++; } if (fid == m_afid) { + // std::cout << mk_pp(e, m_manager) << "\n"; switch (to_app(e)->get_decl_kind()) { case OP_MUL: - if (!is_numeral(to_app(e)->get_arg(0))) + if (!is_numeral(to_app(e)->get_arg(0)) || to_app(e)->get_num_args() > 2) { m_num_non_linear++; + } break; case OP_DIV: case OP_IDIV: diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index 631805b4d..bbc91e4c6 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -968,7 +968,7 @@ namespace smt { if (st.num_theories() == 2 && st.has_uf() && is_arith(st)) { if (!st.m_has_real) setup_QF_UFLIA(st); - else if (!st.m_has_int) + else if (!st.m_has_int && st.m_num_non_linear == 0) setup_QF_UFLRA(); else setup_unknown(); From c8d9be0bbf363dac3430a1a0397800c0d9685055 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 8 Dec 2017 14:22:25 +0530 Subject: [PATCH 092/263] fix build of obj_ref_hashtable Signed-off-by: Nikolaj Bjorner --- src/util/obj_ref_hashtable.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/obj_ref_hashtable.h b/src/util/obj_ref_hashtable.h index 6bd4f1556..3d6bbf883 100644 --- a/src/util/obj_ref_hashtable.h +++ b/src/util/obj_ref_hashtable.h @@ -26,6 +26,12 @@ class obj_ref_map { M& m; obj_map m_table; public: + typedef typename obj_map iterator; + typedef Key key; + typedef Value value; + typedef typename obj_map::key_data key_data; + typedef typename obj_map::obj_map_entry obj_map_entry; + obj_ref_map(M& m):m(m) {} ~obj_ref_map() { reset(); } From faebbc5384dae4425d03fa743587303a83839296 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 8 Dec 2017 16:17:04 +0530 Subject: [PATCH 093/263] add shortcuts for concatenation and equality propagation Signed-off-by: Nikolaj Bjorner --- src/qe/nlqsat.cpp | 168 ----------------------------------------- src/smt/theory_seq.cpp | 48 ++++++------ src/smt/theory_seq.h | 6 +- 3 files changed, 32 insertions(+), 190 deletions(-) diff --git a/src/qe/nlqsat.cpp b/src/qe/nlqsat.cpp index 1f9c89f89..ab5095328 100644 --- a/src/qe/nlqsat.cpp +++ b/src/qe/nlqsat.cpp @@ -886,174 +886,6 @@ namespace qe { tactic * translate(ast_manager & m) { return alloc(nlqsat, m, m_mode, m_params); } - -#if 0 - - /** - - Algorithm: - I := true - while there is M, such that M |= ~B & I: - find P, such that M => P => exists y . ~B & I - ; forall y B => ~P - C := core of P with respect to A - ; A => ~ C => ~ P - I := I & ~C - - - Alternative Algorithm: - R := false - while there is M, such that M |= A & ~R: - find I, such that M => I => forall y . B - R := R | I - - */ - - lbool interpolate(expr* a, expr* b, expr_ref& result) { - SASSERT(m_mode == interp_t); - - reset(); - app_ref enableA(m), enableB(m); - expr_ref A(m), B(m), fml(m); - expr_ref_vector fmls(m), answer(m); - - // varsB are private to B. - nlsat::var_vector vars; - uint_set fvars; - private_vars(a, b, vars, fvars); - - enableA = m.mk_const(symbol("#A"), m.mk_bool_sort()); - enableB = m.mk_not(enableA); - A = m.mk_implies(enableA, a); - B = m.mk_implies(enableB, m.mk_not(b)); - fml = m.mk_and(A, B); - hoist(fml); - - - - nlsat::literal _enableB = nlsat::literal(m_a2b.to_var(enableB), false); - nlsat::literal _enableA = ~_enableB; - - while (true) { - m_mode = qsat_t; - // enable B - m_assumptions.reset(); - m_assumptions.push_back(_enableB); - lbool is_sat = check_sat(); - - switch (is_sat) { - case l_undef: - return l_undef; - case l_true: - break; - case l_false: - result = mk_and(answer); - return l_true; - } - - // disable B, enable A - m_assumptions.reset(); - m_assumptions.push_back(_enableA); - // add blocking clause to solver. - - nlsat::scoped_literal_vector core(m_solver); - - m_mode = elim_t; - - mbp(vars, fvars, core); - - // minimize core. - nlsat::literal_vector _core(core.size(), core.c_ptr()); - _core.push_back(_enableA); - is_sat = m_solver.check(_core); // TBD: only for quantifier-free A. Generalize output of elim_t to be a core. - switch (is_sat) { - case l_undef: - return l_undef; - case l_true: - UNREACHABLE(); - case l_false: - core.reset(); - core.append(_core.size(), _core.c_ptr()); - break; - } - negate_clause(core); - // keep polarity of enableA, such that clause is only - // used when checking satisfiability of B. - for (unsigned i = 0; i < core.size(); ++i) { - if (core[i].var() == _enableA.var()) core.set(i, ~core[i]); - } - add_clause(core); // Invariant is added as assumption for B. - answer.push_back(clause2fml(core)); // TBD: remove answer literal. - } - } - - /** - \brief extract variables that are private to a (not used in b). - vars cover the real variables, and fvars cover the Boolean variables. - - TBD: We want fvars to be the complement such that returned core contains - Shared boolean variables, but not the ones private to B. - */ - void private_vars(expr* a, expr* b, nlsat::var_vector& vars, uint_set& fvars) { - app_ref_vector varsA(m), varsB(m); - obj_hashtable varsAS; - pred_abs abs(m); - abs.get_free_vars(a, varsA); - abs.get_free_vars(b, varsB); - insert_set(varsAS, varsA); - for (unsigned i = 0; i < varsB.size(); ++i) { - if (varsAS.contains(varsB[i].get())) { - varsB[i] = varsB.back(); - varsB.pop_back(); - --i; - } - } - for (unsigned j = 0; j < varsB.size(); ++j) { - app* v = varsB[j].get(); - if (m_a2b.is_var(v)) { - fvars.insert(m_a2b.to_var(v)); - } - else if (m_t2x.is_var(v)) { - vars.push_back(m_t2x.to_var(v)); - } - } - } - - lbool maximize(app* _x, expr* _fml, scoped_anum& result, bool& unbounded) { - expr_ref fml(_fml, m); - reset(); - hoist(fml); - nlsat::literal_vector lits; - lbool is_sat = l_true; - nlsat::var x = m_t2x.to_var(_x); - m_mode = qsat_t; - while (is_sat == l_true) { - is_sat = check_sat(); - if (is_sat == l_true) { - // m_asms is minimized set of literals that satisfy formula. - nlsat::explain& ex = m_solver.get_explain(); - polynomial::manager& pm = m_solver.pm(); - anum_manager& am = m_solver.am(); - ex.maximize(x, m_asms.size(), m_asms.c_ptr(), result, unbounded); - if (unbounded) { - break; - } - // TBD: assert the new bound on x using the result. - bool is_even = false; - polynomial::polynomial_ref pr(pm); - pr = pm.mk_polynomial(x); - rational r; - am.get_upper(result, r); - // result is algebraic numeral, but polynomials are not defined over extension field. - polynomial::polynomial* p = pr; - nlsat::bool_var b = m_solver.mk_ineq_atom(nlsat::atom::GT, 1, &p, &is_even); - nlsat::literal bound(b, false); - m_solver.mk_clause(1, &bound); - } - } - return is_sat; - } -#endif }; }; diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 9830a16b4..597348589 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -397,15 +397,13 @@ bool theory_seq::branch_binary_variable(eq const& e) { expr_ref Y1(mk_skolem(symbol("seq.left"), x, y), m); expr_ref Y2(mk_skolem(symbol("seq.right"), x, y), m); ys.push_back(Y1); - expr_ref ysY1(m_util.str.mk_concat(ys.size(), ys.c_ptr()), m); - expr_ref xsE(m_util.str.mk_concat(xs.size(), xs.c_ptr()), m); - expr_ref Y1Y2(m_util.str.mk_concat(Y1, Y2), m); - literal_vector lits; - lits.push_back(~lit); + expr_ref ysY1(mk_concat(ys)); + expr_ref xsE(mk_concat(xs)); + expr_ref Y1Y2(mk_concat(Y1, Y2)); dependency* dep = e.dep(); - propagate_eq(dep, lits, x, ysY1, true); - propagate_eq(dep, lits, y, Y1Y2, true); - propagate_eq(dep, lits, Y2, xsE, true); + propagate_eq(dep, ~lit, x, ysY1); + propagate_eq(dep, ~lit, y, Y1Y2); + propagate_eq(dep, ~lit, Y2, xsE); } else { ctx.mark_as_relevant(lit); @@ -471,9 +469,7 @@ void theory_seq::branch_unit_variable(dependency* dep, expr* X, expr_ref_vector literal lit = mk_eq(m_autil.mk_int(lX), m_util.str.mk_length(X), false); if (l_true == ctx.get_assignment(lit)) { expr_ref R(m_util.str.mk_concat(lX, units.c_ptr()), m); - literal_vector lits; - lits.push_back(lit); - propagate_eq(dep, lits, X, R, true); + propagate_eq(dep, lit, X, R); TRACE("seq", tout << "propagate " << mk_pp(X, m) << " " << R << "\n";); } else { @@ -506,11 +502,10 @@ bool theory_seq::branch_variable_mb() { for (unsigned j = 0; j < len2.size(); ++j) l2 += len2[j]; if (l1 != l2) { TRACE("seq", tout << "lengths are not compatible\n";); - expr_ref l = mk_concat(e.ls().size(), e.ls().c_ptr()); - expr_ref r = mk_concat(e.rs().size(), e.rs().c_ptr()); + expr_ref l = mk_concat(e.ls()); + expr_ref r = mk_concat(e.rs()); expr_ref lnl(m_util.str.mk_length(l), m), lnr(m_util.str.mk_length(r), m); - literal_vector lits; - propagate_eq(e.dep(), lits, lnl, lnr, false); + propagate_eq(e.dep(), lnl, lnr, false); change = true; continue; } @@ -626,8 +621,8 @@ bool theory_seq::split_lengths(dependency* dep, SASSERT(is_var(Y)); expr_ref Y1(mk_skolem(symbol("seq.left"), X, b, Y), m); expr_ref Y2(mk_skolem(symbol("seq.right"), X, b, Y), m); - expr_ref bY1(m_util.str.mk_concat(b, Y1), m); - expr_ref Y1Y2(m_util.str.mk_concat(Y1, Y2), m); + expr_ref bY1 = mk_concat(b, Y1); + expr_ref Y1Y2 = mk_concat(Y1, Y2); propagate_eq(dep, lits, X, bY1, true); propagate_eq(dep, lits, Y, Y1Y2, true); } @@ -1317,6 +1312,18 @@ void theory_seq::propagate_eq(dependency* dep, enode* n1, enode* n2) { enforce_length_coherence(n1, n2); } +void theory_seq::propagate_eq(dependency* dep, expr* e1, expr* e2, bool add_eq) { + literal_vector lits; + propagate_eq(dep, lits, e1, e2, add_eq); +} + +void theory_seq::propagate_eq(dependency* dep, literal lit, expr* e1, expr* e2, bool add_to_eqs) { + literal_vector lits; + lits.push_back(lit); + propagate_eq(dep, lits, e1, e2, add_to_eqs); +} + + void theory_seq::enforce_length_coherence(enode* n1, enode* n2) { expr* o1 = n1->get_owner(); expr* o2 = n2->get_owner(); @@ -1662,19 +1669,18 @@ bool theory_seq::reduce_length(unsigned i, unsigned j, bool front, expr_ref_vect } SASSERT(0 < l1 && l1 < ls.size()); SASSERT(0 < r1 && r1 < rs.size()); - expr_ref l(m_util.str.mk_concat(l1, ls1), m); - expr_ref r(m_util.str.mk_concat(r1, rs1), m); + expr_ref l = mk_concat(l1, ls1); + expr_ref r = mk_concat(r1, rs1); expr_ref lenl(m_util.str.mk_length(l), m); expr_ref lenr(m_util.str.mk_length(r), m); literal lit = mk_eq(lenl, lenr, false); if (ctx.get_assignment(lit) == l_true) { - literal_vector lits; expr_ref_vector lhs(m), rhs(m); lhs.append(l2, ls2); rhs.append(r2, rs2); deps = mk_join(deps, lit); m_eqs.push_back(eq(m_eq_id++, lhs, rhs, deps)); - propagate_eq(deps, lits, l, r, true); + propagate_eq(deps, l, r, true); TRACE("seq", tout << "propagate eq\nlhs: " << lhs << "\nrhs: " << rhs << "\n";); return true; } diff --git a/src/smt/theory_seq.h b/src/smt/theory_seq.h index d4686c835..46f803f5b 100644 --- a/src/smt/theory_seq.h +++ b/src/smt/theory_seq.h @@ -410,6 +410,8 @@ namespace smt { expr_ref mk_empty(sort* s) { return expr_ref(m_util.str.mk_empty(s), m); } expr_ref mk_concat(unsigned n, expr*const* es) { return expr_ref(m_util.str.mk_concat(n, es), m); } expr_ref mk_concat(expr_ref_vector const& es, sort* s) { if (es.empty()) return mk_empty(s); return mk_concat(es.size(), es.c_ptr()); } + expr_ref mk_concat(expr_ref_vector const& es) { SASSERT(!es.empty()); return mk_concat(es.size(), es.c_ptr()); } + expr_ref mk_concat(ptr_vector const& es) { SASSERT(!es.empty()); return mk_concat(es.size(), es.c_ptr()); } expr_ref mk_concat(expr* e1, expr* e2) { return expr_ref(m_util.str.mk_concat(e1, e2), m); } expr_ref mk_concat(expr* e1, expr* e2, expr* e3) { return expr_ref(m_util.str.mk_concat(e1, e2, e3), m); } bool solve_nqs(unsigned i); @@ -436,7 +438,9 @@ namespace smt { void propagate_lit(dependency* dep, unsigned n, literal const* lits, literal lit); void propagate_eq(dependency* dep, enode* n1, enode* n2); void propagate_eq(literal lit, expr* e1, expr* e2, bool add_to_eqs); - void propagate_eq(dependency* dep, literal_vector const& lits, expr* e1, expr* e2, bool add_to_eqs); + void propagate_eq(dependency* dep, literal_vector const& lits, expr* e1, expr* e2, bool add_to_eqs = true); + void propagate_eq(dependency* dep, expr* e1, expr* e2, bool add_to_eqs = true); + void propagate_eq(dependency* dep, literal lit, expr* e1, expr* e2, bool add_to_eqs = true); void set_conflict(dependency* dep, literal_vector const& lits = literal_vector()); u_map m_branch_start; From 9d2c86f214304d224b7c439bc3bfd43da002dbdc Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Fri, 8 Dec 2017 20:31:22 -0500 Subject: [PATCH 094/263] fix incorrect clause in argumentsValid subterm of substr reduction --- src/smt/theory_str.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 7936b581c..022a2ad73 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -1450,7 +1450,7 @@ namespace smt { // pos < strlen(base) // --> pos + -1*strlen(base) < 0 argumentsValid_terms.push_back(mk_not(m, m_autil.mk_ge( - m_autil.mk_add(substrPos, m_autil.mk_mul(minusOne, substrLen)), + m_autil.mk_add(substrPos, m_autil.mk_mul(minusOne, mk_strlen(substrBase))), zero))); // len >= 0 From 2e186633ee17f9ee3c8265f976321cb0cd8f44b3 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 11 Dec 2017 14:59:25 +0000 Subject: [PATCH 095/263] Turned assertion failure into proper error message. --- src/ast/ast.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index e7d808b2b..3824325b3 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1289,7 +1289,7 @@ decl_kind user_sort_plugin::register_name(symbol s) { decl_plugin * user_sort_plugin::mk_fresh() { user_sort_plugin * p = alloc(user_sort_plugin); - for (symbol const& s : m_sort_names) + for (symbol const& s : m_sort_names) p->register_name(s); return p; } @@ -1415,7 +1415,7 @@ ast_manager::~ast_manager() { p->finalize(); } for (decl_plugin* p : m_plugins) { - if (p) + if (p) dealloc(p); } m_plugins.reset(); @@ -1454,13 +1454,13 @@ ast_manager::~ast_manager() { mark_array_ref(mark, to_quantifier(n)->get_num_patterns(), to_quantifier(n)->get_patterns()); mark_array_ref(mark, to_quantifier(n)->get_num_no_patterns(), to_quantifier(n)->get_no_patterns()); break; - } - } + } + } for (ast * n : m_ast_table) { if (!mark.is_marked(n)) { roots.push_back(n); } - } + } SASSERT(!roots.empty()); for (unsigned i = 0; i < roots.size(); ++i) { ast* a = roots[i]; @@ -1683,7 +1683,7 @@ ast * ast_manager::register_node_core(ast * n) { bool contains = m_ast_table.contains(n); CASSERT("nondet_bug", contains || slow_not_contains(n)); #endif - + ast * r = m_ast_table.insert_if_not_there(n); SASSERT(r->m_hash == h); if (r != n) { @@ -2358,8 +2358,9 @@ quantifier * ast_manager::mk_quantifier(bool forall, unsigned num_decls, sort * unsigned num_patterns, expr * const * patterns, unsigned num_no_patterns, expr * const * no_patterns) { SASSERT(body); - SASSERT(num_patterns == 0 || num_no_patterns == 0); SASSERT(num_decls > 0); + if (num_patterns != 0 && num_no_patterns != 0) + throw ast_exception("simultaneous patterns and no-patterns not supported"); DEBUG_CODE({ for (unsigned i = 0; i < num_patterns; ++i) { TRACE("ast", tout << i << " " << mk_pp(patterns[i], *this) << "\n";); @@ -2763,7 +2764,7 @@ proof * ast_manager::mk_transitivity(unsigned num_proofs, proof * const * proofs } proof * ast_manager::mk_transitivity(unsigned num_proofs, proof * const * proofs, expr * n1, expr * n2) { - if (num_proofs == 0) + if (num_proofs == 0) return nullptr; if (num_proofs == 1) return proofs[0]; From 49678065bd133721445bb7ef7be6ac03d826dd36 Mon Sep 17 00:00:00 2001 From: Ivan Gotovchits Date: Wed, 13 Dec 2017 14:37:19 -0500 Subject: [PATCH 096/263] fixes compilation flags for OCaml plugins The `-linkall` option is needed for a plugin to be standalone, otherwise it will miss those dependencies that are not used. --- scripts/mk_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index b155fd7c2..03256125c 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1990,7 +1990,7 @@ class MLComponent(Component): out.write('%s.cmxa: %s %s %s %s.cma\n' % (z3mls, cmxs, stubso, z3dllso, z3mls)) out.write('\t%s -o %s -I %s %s %s %s\n' % (OCAMLMKLIB, z3mls, self.sub_dir, stubso, cmxs, LIBZ3)) out.write('%s.cmxs: %s.cmxa\n' % (z3mls, z3mls)) - out.write('\t%s -shared -o %s.cmxs -I %s %s.cmxa\n' % (OCAMLOPTF, z3mls, self.sub_dir, z3mls)) + out.write('\t%s -linkall -shared -o %s.cmxs -I %s %s.cmxa\n' % (OCAMLOPTF, z3mls, self.sub_dir, z3mls)) out.write('\n') out.write('ml: %s.cma %s.cmxa %s.cmxs\n' % (z3mls, z3mls, z3mls)) From 5a479fca76d6e249490c7a9b42d9431318ddb6c9 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 13 Dec 2017 13:48:24 -0800 Subject: [PATCH 097/263] generalize model finder code to be independent of conjunction elimination Signed-off-by: Nikolaj Bjorner --- src/smt/smt_model_finder.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/smt/smt_model_finder.cpp b/src/smt/smt_model_finder.cpp index 11202d58a..28a65f898 100644 --- a/src/smt/smt_model_finder.cpp +++ b/src/smt/smt_model_finder.cpp @@ -2272,10 +2272,9 @@ namespace smt { process_literal(atom, pol == NEG); } - void process_or(app * n, polarity p) { - unsigned num_args = n->get_num_args(); - for (unsigned i = 0; i < num_args; i++) - visit_formula(n->get_arg(i), p); + void process_and_or(app * n, polarity p) { + for (expr* arg : *n) + visit_formula(arg, p); } void process_ite(app * n, polarity p) { @@ -2306,13 +2305,13 @@ namespace smt { if (is_app(curr)) { if (to_app(curr)->get_family_id() == m_manager.get_basic_family_id() && m_manager.is_bool(curr)) { switch (static_cast(to_app(curr)->get_decl_kind())) { - case OP_AND: case OP_IMPLIES: case OP_XOR: UNREACHABLE(); // simplifier eliminated ANDs, IMPLIEs, and XORs break; case OP_OR: - process_or(to_app(curr), pol); + case OP_AND: + process_and_or(to_app(curr), pol); break; case OP_NOT: visit_formula(to_app(curr)->get_arg(0), neg(pol)); From 58c6cb87c3bc26824fd2386e2eeb74bb3a826537 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 14 Dec 2017 11:48:22 -0800 Subject: [PATCH 098/263] small improvements to QF_NIA tactic Signed-off-by: Nikolaj Bjorner --- src/smt/theory_arith_nl.h | 1 + src/tactic/smtlogics/qfnia_tactic.cpp | 35 +++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/smt/theory_arith_nl.h b/src/smt/theory_arith_nl.h index 230b6de77..87b811e8f 100644 --- a/src/smt/theory_arith_nl.h +++ b/src/smt/theory_arith_nl.h @@ -711,6 +711,7 @@ namespace smt { if (ctx.is_relevant(get_enode(*it)) && !check_monomial_assignment(*it, computed_epsilon)) { TRACE("non_linear_failed", tout << "check_monomial_assignment failed for:\n" << mk_ismt2_pp(var2expr(*it), get_manager()) << "\n"; display_var(tout, *it);); + return false; } } diff --git a/src/tactic/smtlogics/qfnia_tactic.cpp b/src/tactic/smtlogics/qfnia_tactic.cpp index 3fb733ca4..f0a4ceb57 100644 --- a/src/tactic/smtlogics/qfnia_tactic.cpp +++ b/src/tactic/smtlogics/qfnia_tactic.cpp @@ -26,8 +26,10 @@ Notes: #include "tactic/bv/max_bv_sharing_tactic.h" #include "sat/tactic/sat_tactic.h" #include "tactic/arith/nla2bv_tactic.h" +#include "tactic/arith/elim01_tactic.h" #include "tactic/core/ctx_simplify_tactic.h" #include "tactic/core/cofactor_term_ite_tactic.h" +#include "nlsat/tactic/qfnra_nlsat_tactic.h" static tactic * mk_qfnia_bv_solver(ast_manager & m, params_ref const & p_ref) { params_ref p = p_ref; @@ -61,8 +63,6 @@ static tactic * mk_qfnia_premable(ast_manager & m, params_ref const & p_ref) { ctx_simp_p.set_uint("max_depth", 30); ctx_simp_p.set_uint("max_steps", 5000000); - params_ref simp_p = p_ref; - simp_p.set_bool("hoist_mul", true); params_ref elim_p = p_ref; elim_p.set_uint("max_memory",20); @@ -73,21 +73,42 @@ static tactic * mk_qfnia_premable(ast_manager & m, params_ref const & p_ref) { using_params(mk_ctx_simplify_tactic(m), ctx_simp_p), using_params(mk_simplify_tactic(m), pull_ite_p), mk_elim_uncnstr_tactic(m), - skip_if_failed(using_params(mk_cofactor_term_ite_tactic(m), elim_p)), - using_params(mk_simplify_tactic(m), simp_p)); + mk_elim01_tactic(m), + skip_if_failed(using_params(mk_cofactor_term_ite_tactic(m), elim_p))); } static tactic * mk_qfnia_sat_solver(ast_manager & m, params_ref const & p) { params_ref nia2sat_p = p; - nia2sat_p.set_uint("nla2bv_max_bv_size", 64); + nia2sat_p.set_uint("nla2bv_max_bv_size", 64); + params_ref simp_p = p; + simp_p.set_bool("hoist_mul", true); // hoist multipliers to create smaller circuits. - return and_then(mk_nla2bv_tactic(m, nia2sat_p), + return and_then(using_params(mk_simplify_tactic(m), simp_p), + mk_nla2bv_tactic(m, nia2sat_p), mk_qfnia_bv_solver(m, p), mk_fail_if_undecided_tactic()); } +static tactic * mk_qfnia_nlsat_solver(ast_manager & m, params_ref const & p) { + params_ref nia2sat_p = p; + nia2sat_p.set_uint("nla2bv_max_bv_size", 64); + params_ref simp_p = p; + simp_p.set_bool("som", true); // expand into sums of monomials + simp_p.set_bool("factor", false); + + + return and_then(using_params(mk_simplify_tactic(m), simp_p), + try_for(mk_qfnra_nlsat_tactic(m, simp_p), 10000), + mk_fail_if_undecided_tactic()); +} + tactic * mk_qfnia_tactic(ast_manager & m, params_ref const & p) { + params_ref simp_p = p; + simp_p.set_bool("som", true); // expand into sums of monomials + return and_then(mk_qfnia_premable(m, p), or_else(mk_qfnia_sat_solver(m, p), - mk_smt_tactic())); + mk_qfnia_nlsat_solver(m, p), + and_then(using_params(mk_simplify_tactic(m), simp_p), + mk_smt_tactic()))); } From e5fa35e969283027e6ca4b75a5dc5ee493c2e5e9 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 14 Dec 2017 17:07:17 -0800 Subject: [PATCH 099/263] add integer branch and bound to nlsat Signed-off-by: Nikolaj Bjorner --- src/nlsat/nlsat_interval_set.cpp | 4 +- src/nlsat/nlsat_interval_set.h | 2 +- src/nlsat/nlsat_solver.cpp | 70 ++++++++++++++++++++++++--- src/tactic/smtlogics/qfnia_tactic.cpp | 2 +- 4 files changed, 68 insertions(+), 10 deletions(-) diff --git a/src/nlsat/nlsat_interval_set.cpp b/src/nlsat/nlsat_interval_set.cpp index 2028095f4..090f94eeb 100644 --- a/src/nlsat/nlsat_interval_set.cpp +++ b/src/nlsat/nlsat_interval_set.cpp @@ -672,14 +672,14 @@ namespace nlsat { return new_set; } - void interval_set_manager::peek_in_complement(interval_set const * s, anum & w, bool randomize) { + void interval_set_manager::peek_in_complement(interval_set const * s, bool is_int, anum & w, bool randomize) { SASSERT(!is_full(s)); if (s == 0) { if (randomize) { int num = m_rand() % 2 == 0 ? 1 : -1; #define MAX_RANDOM_DEN_K 4 int den_k = (m_rand() % MAX_RANDOM_DEN_K); - int den = 1 << den_k; + int den = is_int ? 1 : (1 << den_k); scoped_mpq _w(m_am.qm()); m_am.qm().set(_w, num, den); m_am.set(w, _w); diff --git a/src/nlsat/nlsat_interval_set.h b/src/nlsat/nlsat_interval_set.h index 24b2ab37f..363d48de9 100644 --- a/src/nlsat/nlsat_interval_set.h +++ b/src/nlsat/nlsat_interval_set.h @@ -108,7 +108,7 @@ namespace nlsat { \pre !is_full(s) */ - void peek_in_complement(interval_set const * s, anum & w, bool randomize); + void peek_in_complement(interval_set const * s, bool is_int, anum & w, bool randomize); }; typedef obj_ref interval_set_ref; diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index c5e9babae..0ccaa2f2c 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -903,15 +903,18 @@ namespace nlsat { */ lbool value(literal l) { lbool val = assigned_value(l); - if (val != l_undef) + if (val != l_undef) { return val; + } bool_var b = l.var(); atom * a = m_atoms[b]; - if (a == 0) + if (a == 0) { return l_undef; + } var max = a->max_var(); - if (!m_assignment.is_assigned(max)) + if (!m_assignment.is_assigned(max)) { return l_undef; + } val = to_lbool(m_evaluator.eval(a, l.sign())); TRACE("value_bug", tout << "value of: "; display(tout, l); tout << " := " << val << "\n"; tout << "xk: " << m_xk << ", a->max_var(): " << a->max_var() << "\n"; @@ -1168,7 +1171,7 @@ namespace nlsat { void select_witness() { scoped_anum w(m_am); SASSERT(!m_ism.is_full(m_infeasible[m_xk])); - m_ism.peek_in_complement(m_infeasible[m_xk], w, m_randomize); + m_ism.peek_in_complement(m_infeasible[m_xk], m_is_int[m_xk], w, m_randomize); TRACE("nlsat", tout << "infeasible intervals: "; m_ism.display(tout, m_infeasible[m_xk]); tout << "\n"; tout << "assigning "; m_display_var(tout, m_xk); tout << "(x" << m_xk << ") -> " << w << "\n";); @@ -1232,6 +1235,61 @@ namespace nlsat { } } + lbool search_check() { + lbool r = l_undef; + while (true) { + r = search(); + if (r != l_true) break; + random_gen r(++m_random_seed); + unsigned start = r(num_vars()); + for (var y = 0; y < num_vars(); y++) { + var x = (y + start) % num_vars(); + if (m_is_int[x] && m_assignment.is_assigned(x) && !m_am.is_int(m_assignment.value(x))) { + scoped_anum v(m_am), vlo(m_am), vhi(m_am); + rational lo, hi; + bool is_even = false; + v = m_assignment.value(x); + init_search(); + m_am.int_lt(v, vlo); + m_am.int_gt(v, vhi); + if (!m_am.is_int(vlo)) break; + if (!m_am.is_int(vhi)) break; + m_am.to_rational(vlo, lo); + m_am.to_rational(vhi, hi); + + // derive tight bounds. + while (true) { + lo++; + if (!m_am.gt(v, lo.to_mpq())) { lo--; break; } + } + while (true) { + hi--; + if (!m_am.lt(v, hi.to_mpq())) { hi++; break; } + } + + polynomial_ref p(m_pm); + rational one(1); + m_lemma.reset(); + p = m_pm.mk_linear(1, &one, &x, -lo); + poly* p1 = p.get(); + m_lemma.push_back(~mk_ineq_literal(atom::GT, 1, &p1, &is_even)); + p = m_pm.mk_linear(1, &one, &x, -hi); + poly* p2 = p.get(); + m_lemma.push_back(~mk_ineq_literal(atom::LT, 1, &p2, &is_even)); + + // perform branch and bound + clause * cls = mk_clause(m_lemma.size(), m_lemma.c_ptr(), false, 0); + if (cls) { + TRACE("nlsat", display(tout << "conflict " << lo << " " << hi, *cls); tout << "\n";); + } + r = l_undef; + break; + } + } + } + return r; + } + lbool check() { TRACE("nlsat_smt2", display_smt2(tout);); TRACE("nlsat_fd", tout << "is_full_dimensional: " << is_full_dimensional() << "\n";); @@ -1250,7 +1308,7 @@ namespace nlsat { reordered = true; } sort_watched_clauses(); - lbool r = search(); + lbool r = search_check(); CTRACE("nlsat_model", r == l_true, tout << "model before restore order\n"; display_assignment(tout);); if (reordered) restore_order(); @@ -1929,7 +1987,7 @@ namespace nlsat { for (var x = 0; x < num; x++) { p.push_back(x); } - random_gen r(m_random_seed); + random_gen r(++m_random_seed); shuffle(p.size(), p.c_ptr(), r); reorder(p.size(), p.c_ptr()); } diff --git a/src/tactic/smtlogics/qfnia_tactic.cpp b/src/tactic/smtlogics/qfnia_tactic.cpp index f0a4ceb57..b4f25243a 100644 --- a/src/tactic/smtlogics/qfnia_tactic.cpp +++ b/src/tactic/smtlogics/qfnia_tactic.cpp @@ -107,7 +107,7 @@ tactic * mk_qfnia_tactic(ast_manager & m, params_ref const & p) { simp_p.set_bool("som", true); // expand into sums of monomials return and_then(mk_qfnia_premable(m, p), - or_else(mk_qfnia_sat_solver(m, p), + or_else(// mk_qfnia_sat_solver(m, p), mk_qfnia_nlsat_solver(m, p), and_then(using_params(mk_simplify_tactic(m), simp_p), mk_smt_tactic()))); From 1dac5bd45973c5954f29db23fbb77c429ddf7395 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 14 Dec 2017 17:07:52 -0800 Subject: [PATCH 100/263] remove comment out Signed-off-by: Nikolaj Bjorner --- src/tactic/smtlogics/qfnia_tactic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tactic/smtlogics/qfnia_tactic.cpp b/src/tactic/smtlogics/qfnia_tactic.cpp index b4f25243a..f0a4ceb57 100644 --- a/src/tactic/smtlogics/qfnia_tactic.cpp +++ b/src/tactic/smtlogics/qfnia_tactic.cpp @@ -107,7 +107,7 @@ tactic * mk_qfnia_tactic(ast_manager & m, params_ref const & p) { simp_p.set_bool("som", true); // expand into sums of monomials return and_then(mk_qfnia_premable(m, p), - or_else(// mk_qfnia_sat_solver(m, p), + or_else(mk_qfnia_sat_solver(m, p), mk_qfnia_nlsat_solver(m, p), and_then(using_params(mk_simplify_tactic(m), simp_p), mk_smt_tactic()))); From ab39f06df7833f1f3a47efbac2e7e8db3741c5d3 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 14 Dec 2017 17:22:49 -0800 Subject: [PATCH 101/263] fix crashes in nlsat Signed-off-by: Nikolaj Bjorner --- src/nlsat/nlsat_solver.cpp | 9 ++++++--- src/tactic/smtlogics/qfnia_tactic.cpp | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 0ccaa2f2c..0e3bf8c95 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -734,8 +734,10 @@ namespace nlsat { void undo_set_updt(interval_set * old_set) { SASSERT(m_xk != null_var); var x = m_xk; - m_ism.dec_ref(m_infeasible[x]); - m_infeasible[x] = old_set; + if (x < m_infeasible.size() && m_infeasible[x]) { + m_ism.dec_ref(m_infeasible[x]); + m_infeasible[x] = old_set; + } } void undo_new_stage() { @@ -757,7 +759,8 @@ namespace nlsat { void undo_updt_eq(atom * a) { SASSERT(m_xk != null_var); - m_var2eq[m_xk] = a; + if (m_var2eq.size() > m_xk) + m_var2eq[m_xk] = a; } template diff --git a/src/tactic/smtlogics/qfnia_tactic.cpp b/src/tactic/smtlogics/qfnia_tactic.cpp index f0a4ceb57..3b890b632 100644 --- a/src/tactic/smtlogics/qfnia_tactic.cpp +++ b/src/tactic/smtlogics/qfnia_tactic.cpp @@ -107,8 +107,8 @@ tactic * mk_qfnia_tactic(ast_manager & m, params_ref const & p) { simp_p.set_bool("som", true); // expand into sums of monomials return and_then(mk_qfnia_premable(m, p), - or_else(mk_qfnia_sat_solver(m, p), - mk_qfnia_nlsat_solver(m, p), + or_else(mk_qfnia_nlsat_solver(m, p), + mk_qfnia_sat_solver(m, p), and_then(using_params(mk_simplify_tactic(m), simp_p), mk_smt_tactic()))); } From 1c3d385c253b94b1932adf769a0059d1fad58b65 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 14 Dec 2017 17:24:13 -0800 Subject: [PATCH 102/263] fix crashes in nlsat Signed-off-by: Nikolaj Bjorner --- src/nlsat/nlsat_solver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 0e3bf8c95..da4f9646d 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -734,7 +734,7 @@ namespace nlsat { void undo_set_updt(interval_set * old_set) { SASSERT(m_xk != null_var); var x = m_xk; - if (x < m_infeasible.size() && m_infeasible[x]) { + if (x < m_infeasible.size()) { m_ism.dec_ref(m_infeasible[x]); m_infeasible[x] = old_set; } From 397cdfc608229a745879aa34ac191b56a79b3c6b Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 15 Dec 2017 06:38:56 -0800 Subject: [PATCH 103/263] avoid crash on nl Signed-off-by: Nikolaj Bjorner --- src/nlsat/nlsat_solver.cpp | 6 ++---- src/tactic/portfolio/default_tactic.cpp | 2 +- src/tactic/smtlogics/quant_tactics.cpp | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index da4f9646d..8f61fffac 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -732,7 +732,7 @@ namespace nlsat { } void undo_set_updt(interval_set * old_set) { - SASSERT(m_xk != null_var); + if (m_xk == null_var) return; var x = m_xk; if (x < m_infeasible.size()) { m_ism.dec_ref(m_infeasible[x]); @@ -741,8 +741,7 @@ namespace nlsat { } void undo_new_stage() { - SASSERT(m_xk != null_var); - if (m_xk == 0) { + if (m_xk == 0 || m_xk == null_var) { m_xk = null_var; } else { @@ -758,7 +757,6 @@ namespace nlsat { } void undo_updt_eq(atom * a) { - SASSERT(m_xk != null_var); if (m_var2eq.size() > m_xk) m_var2eq[m_xk] = a; } diff --git a/src/tactic/portfolio/default_tactic.cpp b/src/tactic/portfolio/default_tactic.cpp index 420cb961a..09052869b 100644 --- a/src/tactic/portfolio/default_tactic.cpp +++ b/src/tactic/portfolio/default_tactic.cpp @@ -41,8 +41,8 @@ tactic * mk_default_tactic(ast_manager & m, params_ref const & p) { cond(mk_is_qflra_probe(), mk_qflra_tactic(m), cond(mk_is_qfnra_probe(), mk_qfnra_tactic(m), cond(mk_is_qfnia_probe(), mk_qfnia_tactic(m), - cond(mk_is_nra_probe(), mk_nra_tactic(m), cond(mk_is_lira_probe(), mk_lira_tactic(m, p), + cond(mk_is_nra_probe(), mk_nra_tactic(m), cond(mk_is_qffp_probe(), mk_qffp_tactic(m, p), //cond(mk_is_qfufnra_probe(), mk_qfufnra_tactic(m, p), mk_smt_tactic()))))))))))), diff --git a/src/tactic/smtlogics/quant_tactics.cpp b/src/tactic/smtlogics/quant_tactics.cpp index 400089a0c..8438d1a32 100644 --- a/src/tactic/smtlogics/quant_tactics.cpp +++ b/src/tactic/smtlogics/quant_tactics.cpp @@ -24,7 +24,6 @@ Revision History: #include "qe/qe_tactic.h" #include "qe/qe_lite.h" #include "qe/qsat.h" -#include "qe/nlqsat.h" #include "tactic/core/ctx_simplify_tactic.h" #include "smt/tactic/smt_tactic.h" #include "tactic/core/elim_term_ite_tactic.h" From 21f685fa5a4a6f20e27bb0eb86828c0e553138dc Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 15 Dec 2017 06:54:02 -0800 Subject: [PATCH 104/263] fix nlsat regression Signed-off-by: Nikolaj Bjorner --- src/nlsat/nlsat_solver.cpp | 87 +++++++++++++-------------- src/tactic/smtlogics/qfnia_tactic.cpp | 2 +- 2 files changed, 43 insertions(+), 46 deletions(-) diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 8f61fffac..c088c406b 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -732,19 +732,19 @@ namespace nlsat { } void undo_set_updt(interval_set * old_set) { - if (m_xk == null_var) return; + if (m_xk == null_var) return; var x = m_xk; - if (x < m_infeasible.size()) { - m_ism.dec_ref(m_infeasible[x]); - m_infeasible[x] = old_set; - } + if (x < m_infeasible.size()) { + m_ism.dec_ref(m_infeasible[x]); + m_infeasible[x] = old_set; + } } void undo_new_stage() { - if (m_xk == 0 || m_xk == null_var) { + if (m_xk == 0) { m_xk = null_var; } - else { + else if (m_xk != null_var) { m_xk--; m_assignment.reset(m_xk); } @@ -757,7 +757,7 @@ namespace nlsat { } void undo_updt_eq(atom * a) { - if (m_var2eq.size() > m_xk) + if (m_var2eq.size() > m_xk) m_var2eq[m_xk] = a; } @@ -1241,50 +1241,47 @@ namespace nlsat { while (true) { r = search(); if (r != l_true) break; - random_gen r(++m_random_seed); - unsigned start = r(num_vars()); - for (var y = 0; y < num_vars(); y++) { - var x = (y + start) % num_vars(); - if (m_is_int[x] && m_assignment.is_assigned(x) && !m_am.is_int(m_assignment.value(x))) { - scoped_anum v(m_am), vlo(m_am), vhi(m_am); - rational lo, hi; - bool is_even = false; - v = m_assignment.value(x); - init_search(); - m_am.int_lt(v, vlo); - m_am.int_gt(v, vhi); - if (!m_am.is_int(vlo)) break; - if (!m_am.is_int(vhi)) break; - m_am.to_rational(vlo, lo); - m_am.to_rational(vhi, hi); + vector lows; + vector vars; + for (var x = 0; x < num_vars(); x++) { + if (m_is_int[x] && m_assignment.is_assigned(x) && !m_am.is_int(m_assignment.value(x))) { + scoped_anum v(m_am), vlo(m_am); + v = m_assignment.value(x); + rational lo; + m_am.int_lt(v, vlo); + if (!m_am.is_int(vlo)) continue; // derive tight bounds. while (true) { lo++; if (!m_am.gt(v, lo.to_mpq())) { lo--; break; } } - while (true) { - hi--; - if (!m_am.lt(v, hi.to_mpq())) { hi++; break; } - } - - polynomial_ref p(m_pm); - rational one(1); - m_lemma.reset(); - p = m_pm.mk_linear(1, &one, &x, -lo); - poly* p1 = p.get(); - m_lemma.push_back(~mk_ineq_literal(atom::GT, 1, &p1, &is_even)); - p = m_pm.mk_linear(1, &one, &x, -hi); - poly* p2 = p.get(); - m_lemma.push_back(~mk_ineq_literal(atom::LT, 1, &p2, &is_even)); + lows.push_back(lo); + vars.push_back(x); + } + } + if (lows.empty()) break; - // perform branch and bound - clause * cls = mk_clause(m_lemma.size(), m_lemma.c_ptr(), false, 0); - if (cls) { - TRACE("nlsat", display(tout << "conflict " << lo << " " << hi, *cls); tout << "\n";); - } - r = l_undef; - break; + init_search(); + for (unsigned i = 0; i < lows.size(); ++i) { + rational lo = lows[i]; + rational hi = lo + rational::one(); + var x = vars[i]; + bool is_even = false; + polynomial_ref p(m_pm); + rational one(1); + m_lemma.reset(); + p = m_pm.mk_linear(1, &one, &x, -lo); + poly* p1 = p.get(); + m_lemma.push_back(~mk_ineq_literal(atom::GT, 1, &p1, &is_even)); + p = m_pm.mk_linear(1, &one, &x, -hi); + poly* p2 = p.get(); + m_lemma.push_back(~mk_ineq_literal(atom::LT, 1, &p2, &is_even)); + + // perform branch and bound + clause * cls = mk_clause(m_lemma.size(), m_lemma.c_ptr(), false, 0); + if (cls) { + TRACE("nlsat", display(tout << "conflict " << lo << " " << hi, *cls); tout << "\n";); } } } diff --git a/src/tactic/smtlogics/qfnia_tactic.cpp b/src/tactic/smtlogics/qfnia_tactic.cpp index 3b890b632..5374ba1c1 100644 --- a/src/tactic/smtlogics/qfnia_tactic.cpp +++ b/src/tactic/smtlogics/qfnia_tactic.cpp @@ -98,7 +98,7 @@ static tactic * mk_qfnia_nlsat_solver(ast_manager & m, params_ref const & p) { return and_then(using_params(mk_simplify_tactic(m), simp_p), - try_for(mk_qfnra_nlsat_tactic(m, simp_p), 10000), + try_for(mk_qfnra_nlsat_tactic(m, simp_p), 3000), mk_fail_if_undecided_tactic()); } From c3add4eeda15dd44d8afe7423b0037dec34e9c8d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 15 Dec 2017 06:56:36 -0800 Subject: [PATCH 105/263] add back missing initialization of lo Signed-off-by: Nikolaj Bjorner --- src/nlsat/nlsat_solver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index c088c406b..e1dadf12b 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -1251,6 +1251,7 @@ namespace nlsat { rational lo; m_am.int_lt(v, vlo); if (!m_am.is_int(vlo)) continue; + m_am.to_rational(vlo, lo); // derive tight bounds. while (true) { lo++; From b0aaa4c6d7a739eb5e8e56a73e0486df46483222 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 18 Dec 2017 14:18:30 +0000 Subject: [PATCH 106/263] Updated release notes --- RELEASE_NOTES | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index e85e3d8d6..4f10cad26 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -2,6 +2,7 @@ RELEASE NOTES Version 4.6.0 ============= + - New requirements: - C++11 capable compiler to build Z3. - C++ API now requires C++11 or newer. @@ -14,6 +15,10 @@ Version 4.6.0 issuing the command (get-objectives). Pareto front objectives are accessed by issuing multiple (check-sat) calls until it returns unsat. +- Removed features: + - Removed support for SMT-LIB 1.x + + Version 4.5.0 ============= @@ -49,10 +54,9 @@ Version 4.5.0 over compound formulas, introduce a fresh predicate whose arguments are the relevant free variables in the formula and add a rule that uses the fresh predicate in the head and formula in the body. - - minimization of unsat cores is avaialble as an option for the SAT and SMT cores. + - Minimization of unsat cores is available as an option for the SAT and SMT cores. By setting smt.core.minimize=true resp. sat.core.minimize=true - cores produced by these modules are minimized. - + cores produced by these modules are minimized. - A multitude of bugs has been fixed. From 63951b815dec78bf4b49e9e39a1fef8b5e739939 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 18 Dec 2017 18:58:21 +0000 Subject: [PATCH 107/263] Bumped version number. --- CMakeLists.txt | 2 +- scripts/mk_project.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 871852c04..0be2de537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ endif() ################################################################################ set(Z3_VERSION_MAJOR 4) set(Z3_VERSION_MINOR 6) -set(Z3_VERSION_PATCH 0) +set(Z3_VERSION_PATCH 1) set(Z3_VERSION_TWEAK 0) set(Z3_VERSION "${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}.${Z3_VERSION_PATCH}.${Z3_VERSION_TWEAK}") set(Z3_FULL_VERSION_STR "${Z3_VERSION}") # Note this might be modified diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 60b3b7756..8f75e97ed 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -9,7 +9,7 @@ from mk_util import * # Z3 Project definition def init_project_def(): - set_version(4, 6, 0, 0) + set_version(4, 6, 1, 0) add_lib('util', []) add_lib('lp', ['util'], 'util/lp') add_lib('polynomial', ['util'], 'math/polynomial') From c3c06d756c9fe7a1e9ed06600cb500014977bf99 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 18 Dec 2017 20:11:18 +0000 Subject: [PATCH 108/263] Documentation fixes. --- doc/mk_api_doc.py | 7 +++++-- src/api/ml/z3.mli | 4 +--- src/api/z3_api.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/mk_api_doc.py b/doc/mk_api_doc.py index a944f2c65..a1a9e64bd 100644 --- a/doc/mk_api_doc.py +++ b/doc/mk_api_doc.py @@ -226,12 +226,14 @@ try: website_dox_substitutions = {} bullet_point_prefix='\n - ' if Z3PY_ENABLED: + print("Python documentation enabled") website_dox_substitutions['PYTHON_API'] = ( '{prefix}Python API ' '(also available in pydoc format)' ).format( prefix=bullet_point_prefix) else: + print("Python documentation disabled") website_dox_substitutions['PYTHON_API'] = '' if DOTNET_ENABLED: website_dox_substitutions['DOTNET_API'] = ( @@ -250,7 +252,7 @@ try: website_dox_substitutions['JAVA_API'] = '' if ML_ENABLED: website_dox_substitutions['OCAML_API'] = ( - 'ML/OCaml API' + '{prefix}ML/OCaml API' ).format( prefix=bullet_point_prefix) else: @@ -316,7 +318,7 @@ try: if ML_ENABLED: ml_output_dir = os.path.join(OUTPUT_DIRECTORY, 'html', 'ml') mk_dir(ml_output_dir) - if subprocess.call(['ocamldoc', '-html', '-d', ml_output_dir, '-sort', '-hide', 'Z3', '-I', '%s/api/ml' % BUILD_DIR, doc_path('../src/api/ml/z3enums.mli'), doc_path('../src/api/ml/z3.mli')]) != 0: + if subprocess.call(['ocamldoc', '-html', '-d', ml_output_dir, '-sort', '-hide', 'Z3', '-I', '%s/api/ml' % BUILD_DIR, '%s/api/ml/z3enums.mli' % BUILD_DIR, '%s/api/ml/z3.mli' % BUILD_DIR]) != 0: print("ERROR: ocamldoc failed.") exit(1) print("Generated ML/OCaml documentation.") @@ -326,3 +328,4 @@ except Exception: exctype, value = sys.exc_info()[:2] print("ERROR: failed to generate documentation: %s" % value) exit(1) + diff --git a/src/api/ml/z3.mli b/src/api/ml/z3.mli index 9f4cd9cd9..80923a0c7 100644 --- a/src/api/ml/z3.mli +++ b/src/api/ml/z3.mli @@ -3443,12 +3443,10 @@ sig (** Parse the given string using the SMT-LIB2 parser. - {!parse_smtlib_string} @return A conjunction of assertions in the scope (up to push/pop) at the end of the string. *) val parse_smtlib2_string : context -> string -> Symbol.symbol list -> Sort.sort list -> Symbol.symbol list -> FuncDecl.func_decl list -> Expr.expr - (** Parse the given file using the SMT-LIB2 parser. - {!parse_smtlib2_string} *) + (** Parse the given file using the SMT-LIB2 parser. *) val parse_smtlib2_file : context -> string -> Symbol.symbol list -> Sort.sort list -> Symbol.symbol list -> FuncDecl.func_decl list -> Expr.expr end diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 064476b9b..007bc3ab6 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1331,7 +1331,7 @@ typedef enum { - Z3_IOB: Index out of bounds. - Z3_INVALID_ARG: Invalid argument was provided. - Z3_PARSER_ERROR: An error occurred when parsing a string or file. - - Z3_NO_PARSER: Parser output is not available, that is, user didn't invoke #Z3_parse_smtlib_string or #Z3_parse_smtlib_file. + - Z3_NO_PARSER: Parser output is not available, that is, user didn't invoke #Z3_parse_smtlib2_string or #Z3_parse_smtlib2_file. - Z3_INVALID_PATTERN: Invalid pattern was used to build a quantifier. - Z3_MEMOUT_FAIL: A memory allocation failure was encountered. - Z3_FILE_ACCESS_ERRROR: A file could not be accessed. From 399b27fda3874a3897e8af8d531758e54b71f818 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 18 Dec 2017 12:20:44 -0800 Subject: [PATCH 109/263] add Python facility for int2bv, fix #1398 Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 237f35433..3bf48b611 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -3568,6 +3568,14 @@ def BV2Int(a, is_signed=False): ## investigate problem with bv2int return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), is_signed), ctx) +def Int2BV(a, num_bits): + """Return the z3 expression Int2BV(a, num_bits). + It is a bit-vector of width num_bits and represents the + modulo of a by 2^num_bits + """ + ctx = a.ctx + return BitVecRef(Z3_mk_int2bv(ctx.ref(), num_bits, a.as_ast()), ctx) + def BitVecSort(sz, ctx=None): """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used. From d695767f61f752ca8aecfe53792dd0fd1b90ec1e Mon Sep 17 00:00:00 2001 From: bannsec Date: Mon, 18 Dec 2017 21:48:54 +0000 Subject: [PATCH 110/263] Allowing slices and negative index in assertions --- src/api/python/z3/z3.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 3bf48b611..4cc401156 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -5140,9 +5140,18 @@ class AstVector(Z3PPObject): >>> A[1] y """ - if i >= self.__len__(): - raise IndexError - return _to_ast_ref(Z3_ast_vector_get(self.ctx.ref(), self.vector, i), self.ctx) + + if isinstance(i, int): + if i < 0: + i += self.__len__() + + if i >= self.__len__(): + raise IndexError + return _to_ast_ref(Z3_ast_vector_get(self.ctx.ref(), self.vector, i), self.ctx) + + elif isinstance(i, slice): + return [_to_ast_ref(Z3_ast_vector_get(self.ctx.ref(), self.vector, ii), self.ctx) for ii in range(*i.indices(self.__len__()))] + def __setitem__(self, i, v): """Update AST at position `i`. From 13ee8da65968d3f111666032f27813eee51e9e66 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 18 Dec 2017 15:57:16 -0800 Subject: [PATCH 111/263] add virtual destructor to see if this helps ASan error Signed-off-by: Nikolaj Bjorner --- src/nlsat/nlsat_types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nlsat/nlsat_types.h b/src/nlsat/nlsat_types.h index 8704f4444..488e16ae9 100644 --- a/src/nlsat/nlsat_types.h +++ b/src/nlsat/nlsat_types.h @@ -151,6 +151,7 @@ namespace nlsat { class solver_exception : public default_exception { public: solver_exception(char const * msg):default_exception(msg) {} + virtual ~solver_exception() {} }; class assignment; From 517b0812021129377590f2fc2afcbd263461a3ad Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 18 Dec 2017 21:13:03 -0800 Subject: [PATCH 112/263] remove custom exception, perhaps this handles exception issue Signed-off-by: Nikolaj Bjorner --- src/nlsat/nlsat_types.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/nlsat/nlsat_types.h b/src/nlsat/nlsat_types.h index 488e16ae9..db3b6ffa5 100644 --- a/src/nlsat/nlsat_types.h +++ b/src/nlsat/nlsat_types.h @@ -148,11 +148,7 @@ namespace nlsat { typedef algebraic_numbers::anum anum; typedef algebraic_numbers::manager anum_manager; - class solver_exception : public default_exception { - public: - solver_exception(char const * msg):default_exception(msg) {} - virtual ~solver_exception() {} - }; + typedef default_exception solver_exception; class assignment; From 36204fafa09f601052044052e1477b7ad3264005 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 19 Dec 2017 20:27:08 -0800 Subject: [PATCH 113/263] alternate strategies for QF_NIA Signed-off-by: Nikolaj Bjorner --- src/tactic/smtlogics/qflia_tactic.cpp | 1 - src/tactic/smtlogics/qfnia_tactic.cpp | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/tactic/smtlogics/qflia_tactic.cpp b/src/tactic/smtlogics/qflia_tactic.cpp index de542f3c4..23ae179e2 100644 --- a/src/tactic/smtlogics/qflia_tactic.cpp +++ b/src/tactic/smtlogics/qflia_tactic.cpp @@ -24,7 +24,6 @@ Notes: #include "tactic/core/solve_eqs_tactic.h" #include "tactic/core/elim_uncnstr_tactic.h" #include "smt/tactic/smt_tactic.h" -// include"mip_tactic.h" #include "tactic/arith/add_bounds_tactic.h" #include "tactic/arith/pb2bv_tactic.h" #include "tactic/arith/lia2pb_tactic.h" diff --git a/src/tactic/smtlogics/qfnia_tactic.cpp b/src/tactic/smtlogics/qfnia_tactic.cpp index 5374ba1c1..d967660ce 100644 --- a/src/tactic/smtlogics/qfnia_tactic.cpp +++ b/src/tactic/smtlogics/qfnia_tactic.cpp @@ -102,13 +102,17 @@ static tactic * mk_qfnia_nlsat_solver(ast_manager & m, params_ref const & p) { mk_fail_if_undecided_tactic()); } -tactic * mk_qfnia_tactic(ast_manager & m, params_ref const & p) { +static tactic * mk_qfnia_smt_solver(ast_manager& m, params_ref const& p) { params_ref simp_p = p; simp_p.set_bool("som", true); // expand into sums of monomials + return and_then(using_params(mk_simplify_tactic(m), simp_p), mk_smt_tactic()); +} + +tactic * mk_qfnia_tactic(ast_manager & m, params_ref const & p) { return and_then(mk_qfnia_premable(m, p), - or_else(mk_qfnia_nlsat_solver(m, p), - mk_qfnia_sat_solver(m, p), - and_then(using_params(mk_simplify_tactic(m), simp_p), - mk_smt_tactic()))); + or_else(mk_qfnia_sat_solver(m, p), + try_for(mk_qfnia_smt_solver(m, p), 2000), + mk_qfnia_nlsat_solver(m, p), + mk_qfnia_smt_solver(m, p))); } From 5bc4c9809e232d63f46018b200cb930bca993ce5 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 25 Dec 2017 12:50:11 -0800 Subject: [PATCH 114/263] initialize additional assumptions after setup_context is called the first time Signed-off-by: Nikolaj Bjorner --- src/smt/smt_context.cpp | 59 +++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 3b69d4846..a87042e2b 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -3202,10 +3202,8 @@ namespace smt { }); validate_unsat_core(); // theory validation of unsat core - ptr_vector::iterator th_it = m_theory_set.begin(); - ptr_vector::iterator th_end = m_theory_set.end(); - for (; th_it != th_end; ++th_it) { - lbool theory_result = (*th_it)->validate_unsat_core(m_unsat_core); + for (theory* th : m_theory_set) { + lbool theory_result = th->validate_unsat_core(m_unsat_core); if (theory_result == l_undef) { return l_undef; } @@ -3296,10 +3294,8 @@ namespace smt { #ifndef _EXTERNAL_RELEASE if (m_fparams.m_display_installed_theories) { std::cout << "(theories"; - ptr_vector::iterator it = m_theory_set.begin(); - ptr_vector::iterator end = m_theory_set.end(); - for (; it != end; ++it) { - std::cout << " " << (*it)->get_name(); + for (theory* th : m_theory_set) { + std::cout << " " << th->get_name(); } std::cout << ")" << std::endl; } @@ -3316,17 +3312,13 @@ namespace smt { m_fparams.m_relevancy_lemma = false; // setup all the theories - ptr_vector::iterator it = m_theory_set.begin(); - ptr_vector::iterator end = m_theory_set.end(); - for (; it != end; ++it) - (*it)->setup(); + for (theory* th : m_theory_set) + th->setup(); } void context::add_theory_assumptions(expr_ref_vector & theory_assumptions) { - ptr_vector::iterator it = m_theory_set.begin(); - ptr_vector::iterator end = m_theory_set.end(); - for (; it != end; ++it) { - (*it)->add_theory_assumptions(theory_assumptions); + for (theory* th : m_theory_set) { + th->add_theory_assumptions(theory_assumptions); } } @@ -3342,18 +3334,7 @@ namespace smt { if (!check_preamble(reset_cancel)) return l_undef; - expr_ref_vector all_assumptions(m_manager, ext_num_assumptions, ext_assumptions); - if (!already_did_theory_assumptions) { - add_theory_assumptions(all_assumptions); - } - - unsigned num_assumptions = all_assumptions.size(); - expr * const * assumptions = all_assumptions.c_ptr(); - - if (!validate_assumptions(num_assumptions, assumptions)) - return l_undef; TRACE("check_bug", tout << "inconsistent: " << inconsistent() << ", m_unsat_core.empty(): " << m_unsat_core.empty() << "\n";); - TRACE("unsat_core_bug", for (unsigned i = 0; i < num_assumptions; i++) { tout << mk_pp(assumptions[i], m_manager) << "\n";}); pop_to_base_lvl(); TRACE("before_search", display(tout);); SASSERT(at_base_level()); @@ -3363,6 +3344,18 @@ namespace smt { } else { setup_context(false); + expr_ref_vector all_assumptions(m_manager, ext_num_assumptions, ext_assumptions); + if (!already_did_theory_assumptions) { + add_theory_assumptions(all_assumptions); + } + + unsigned num_assumptions = all_assumptions.size(); + expr * const * assumptions = all_assumptions.c_ptr(); + + if (!validate_assumptions(num_assumptions, assumptions)) + return l_undef; + TRACE("unsat_core_bug", tout << all_assumptions << "\n";); + internalize_assertions(); TRACE("after_internalize_assertions", display(tout);); if (m_asserted_formulas.inconsistent()) { @@ -3551,10 +3544,9 @@ namespace smt { pop_scope(m_scope_lvl - curr_lvl); SASSERT(at_search_level()); } - ptr_vector::iterator it = m_theory_set.begin(); - ptr_vector::iterator end = m_theory_set.end(); - for (; it != end && !inconsistent(); ++it) - (*it)->restart_eh(); + for (theory* th : m_theory_set) { + if (!inconsistent()) th->restart_eh(); + } TRACE("mbqi_bug_detail", tout << "before instantiating quantifiers...\n";); if (!inconsistent()) { m_qmanager->restart_eh(); @@ -4070,10 +4062,7 @@ namespace smt { bool include = false; if (at_lbls) { // include if there is a label with the '@' sign. - buffer::const_iterator it = lbls.begin(); - buffer::const_iterator end = lbls.end(); - for (; it != end; ++it) { - symbol const & s = *it; + for (symbol const& s : lbls) { if (s.contains('@')) { include = true; break; From d86e8f02d7808fed783a5eedc4d8f5255008c6f4 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 27 Dec 2017 10:09:10 -0800 Subject: [PATCH 115/263] fix get-objectives error #1419 message (get-objectives) Signed-off-by: Nikolaj Bjorner --- src/opt/opt_context.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index 3d296d92b..0daf98320 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -1235,6 +1235,9 @@ namespace opt { } void context::display_assignment(std::ostream& out) { + if (m_scoped_state.m_objectives.size() != m_objectives.size()) { + throw default_exception("check-sat has not been called with latest objectives"); + } out << "(objectives\n"; for (unsigned i = 0; i < m_scoped_state.m_objectives.size(); ++i) { objective const& obj = m_scoped_state.m_objectives[i]; From 79a9dfd8fdd1ff3072fc571286217f788147084c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 30 Dec 2017 20:35:33 -0800 Subject: [PATCH 116/263] adding pre-processing to nlsat for equations Signed-off-by: Nikolaj Bjorner --- src/ast/arith_decl_plugin.h | 4 +- src/math/polynomial/polynomial.cpp | 93 +++- src/math/polynomial/polynomial.h | 35 +- src/nlsat/nlsat_clause.h | 2 + src/nlsat/nlsat_solver.cpp | 631 +++++++++++++++++------- src/nlsat/nlsat_solver.h | 2 +- src/nlsat/nlsat_types.h | 2 + src/nlsat/tactic/nlsat_tactic.cpp | 8 +- src/nlsat/tactic/qfnra_nlsat_tactic.cpp | 4 + src/qe/nlqsat.cpp | 2 +- src/tactic/core/solve_eqs_tactic.cpp | 135 +++-- 11 files changed, 696 insertions(+), 222 deletions(-) diff --git a/src/ast/arith_decl_plugin.h b/src/ast/arith_decl_plugin.h index 4b24ea5e6..4850b52a8 100644 --- a/src/ast/arith_decl_plugin.h +++ b/src/ast/arith_decl_plugin.h @@ -370,7 +370,7 @@ public: app * mk_lt(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_LT, arg1, arg2); } app * mk_gt(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_GT, arg1, arg2); } - app * mk_add(unsigned num_args, expr * const * args) const { return m_manager.mk_app(m_afid, OP_ADD, num_args, args); } + app * mk_add(unsigned num_args, expr * const * args) const { return num_args == 1 && is_app(args[0]) ? to_app(args[0]) : m_manager.mk_app(m_afid, OP_ADD, num_args, args); } app * mk_add(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_ADD, arg1, arg2); } app * mk_add(expr * arg1, expr * arg2, expr* arg3) const { return m_manager.mk_app(m_afid, OP_ADD, arg1, arg2, arg3); } @@ -378,7 +378,7 @@ public: app * mk_sub(unsigned num_args, expr * const * args) const { return m_manager.mk_app(m_afid, OP_SUB, num_args, args); } app * mk_mul(expr * arg1, expr * arg2) const { return m_manager.mk_app(m_afid, OP_MUL, arg1, arg2); } app * mk_mul(expr * arg1, expr * arg2, expr* arg3) const { return m_manager.mk_app(m_afid, OP_MUL, arg1, arg2, arg3); } - app * mk_mul(unsigned num_args, expr * const * args) const { return m_manager.mk_app(m_afid, OP_MUL, num_args, args); } + app * mk_mul(unsigned num_args, expr * const * args) const { return num_args == 1 && is_app(args[0]) ? to_app(args[0]) : m_manager.mk_app(m_afid, OP_MUL, num_args, args); } app * mk_uminus(expr * arg) const { return m_manager.mk_app(m_afid, OP_UMINUS, arg); } app * mk_div(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_DIV, arg1, arg2); } app * mk_idiv(expr * arg1, expr * arg2) { return m_manager.mk_app(m_afid, OP_IDIV, arg1, arg2); } diff --git a/src/math/polynomial/polynomial.cpp b/src/math/polynomial/polynomial.cpp index d6d392148..51d8489e3 100644 --- a/src/math/polynomial/polynomial.cpp +++ b/src/math/polynomial/polynomial.cpp @@ -150,7 +150,6 @@ namespace polynomial { return r; } - /** \brief Monomials (power products) */ @@ -192,7 +191,7 @@ namespace polynomial { }; static unsigned get_obj_size(unsigned sz) { return sizeof(monomial) + sz * sizeof(power); } - + monomial(unsigned id, unsigned sz, power const * pws, unsigned h): m_ref_count(0), m_id(id), @@ -257,9 +256,7 @@ namespace polynomial { if (m_size < SMALL_MONOMIAL) { // use linear search for small monomials // search backwards since we usually ask for the degree of "big" variables - unsigned i = last; - while (i > 0) { - --i; + for (unsigned i = last; i-- > 0; ) { if (get_var(i) == x) return i; } @@ -798,9 +795,8 @@ namespace polynomial { dec_ref(m_unit); CTRACE("polynomial", !m_monomials.empty(), tout << "monomials leaked\n"; - monomial_table::iterator it = m_monomials.begin(); monomial_table::iterator end = m_monomials.end(); - for (; it != end; ++it) { - (*it)->display(tout); tout << "\n"; + for (auto * m : m_monomials) { + m->display(tout); tout << "\n"; }); SASSERT(m_monomials.empty()); if (m_own_allocator) @@ -1510,6 +1506,8 @@ namespace polynomial { unsigned id() const { return m_id; } unsigned size() const { return m_size; } monomial * m(unsigned idx) const { SASSERT(idx < size()); return m_ms[idx]; } + monomial *const* begin() const { return m_ms; } + monomial *const* end() const { return m_ms + size(); } numeral const & a(unsigned idx) const { SASSERT(idx < size()); return m_as[idx]; } numeral & a(unsigned idx) { SASSERT(idx < size()); return m_as[idx]; } numeral const * as() const { return m_as; } @@ -1773,11 +1771,9 @@ namespace polynomial { } bool manager::is_linear(polynomial const * p) { - unsigned sz = p->size(); - for (unsigned i = 0; i < sz; i++) { - if (!is_linear(p->m(0))) + for (monomial* m : *p) + if (!is_linear(m)) return false; - } return true; } @@ -2396,6 +2392,7 @@ namespace polynomial { return mm().is_valid(x); } + void add_del_eh(del_eh * eh) { eh->m_next = m_del_eh; m_del_eh = eh; @@ -6101,6 +6098,33 @@ namespace polynomial { }); } + lbool sign(monomial* m, numeral const& c, svector const& sign_of_vars) { + unsigned sz = size(m); + lbool sign1 = m_manager.is_pos(c) ? l_true : l_false; + for (unsigned i = 0; i < sz; ++i) { + var v = get_var(m, i); + unsigned d = degree(m, i); + lbool sign2 = sign_of_vars.get(v, l_undef); + if (sign2 == l_undef) + return l_undef; + else if (1 == (d % 2) && sign2 == l_false) { + sign1 = sign1 == l_true ? l_false : l_true; + } + } + return sign1; + } + + lbool sign(polynomial const * p, svector const& sign_of_vars) { + unsigned sz = size(p); + if (sz == 0) return l_undef; + lbool sign1 = sign(p->m(0), p->a(0), sign_of_vars); + for (unsigned i = 1; sign1 != l_undef && i < sz; ++i) { + if (sign(p->m(i), p->a(i), sign_of_vars) != sign1) + return l_undef; + } + return sign1; + } + bool is_pos(polynomial const * p) { bool found_unit = false; unsigned sz = p->size(); @@ -6372,6 +6396,31 @@ namespace polynomial { R.add(new_a, mk_monomial(new_m)); } return R.mk(); + } + + void substitute(polynomial const* r, var x, polynomial const* p, polynomial const* q, polynomial_ref& result) { + unsigned md = degree(r, x); + if (md == 0) { + result = const_cast(r); + return; + } + result = 0; + polynomial_ref p1(pm()), q1(pm()); + polynomial_ref_buffer ps(pm()); + unsigned sz = r->size(); + for (unsigned i = 0; i < sz; i++) { + monomial * m0 = r->m(i); + unsigned dm = m0->degree_of(x); + SASSERT(md >= dm); + monomial_ref m1(div_x(m0, x), pm()); + pw(p, dm, p1); + pw(q, md - dm, q1); + p1 = mul(r->a(i), m1, p1 * q1); + if (result) + result = add(result, p1); + else + result = p1; + } } @@ -6918,6 +6967,18 @@ namespace polynomial { return m_imp->m().set_zp(p); } + bool manager::is_var(polynomial const* p, var& v) { + return p->size() == 1 && is_var(p->m(0), v) && m_imp->m().is_one(p->a(0)); + } + + bool manager::is_var(monomial const* m, var& v) { + return m->size() == 1 && m->degree(0) == 1 && (v = m->get_var(0), true); + } + + bool manager::is_var_num(polynomial const* p, var& v, scoped_numeral& n) { + return p->size() == 2 && m_imp->m().is_one(p->a(0)) && is_var(p->m(0), v) && is_unit(p->m(1)) && (n = p->a(1), true); + } + small_object_allocator & manager::allocator() const { return m_imp->mm().allocator(); } @@ -7271,6 +7332,10 @@ namespace polynomial { void manager::psc_chain(polynomial const * p, polynomial const * q, var x, polynomial_ref_vector & S) { m_imp->psc_chain(p, q, x, S); } + + lbool manager::sign(polynomial const * p, svector const& sign_of_vars) { + return m_imp->sign(p, sign_of_vars); + } bool manager::is_pos(polynomial const * p) { return m_imp->is_pos(p); @@ -7307,6 +7372,10 @@ namespace polynomial { polynomial * manager::substitute(polynomial const * p, unsigned xs_sz, var const * xs, numeral const * vs) { return m_imp->substitute(p, xs_sz, xs, vs); } + + void manager::substitute(polynomial const* r, var x, polynomial const* p, polynomial const* q, polynomial_ref& result) { + m_imp->substitute(r, x, p, q, result); + } void manager::factor(polynomial const * p, factors & r, factor_params const & params) { m_imp->factor(p, r, params); diff --git a/src/math/polynomial/polynomial.h b/src/math/polynomial/polynomial.h index 43b3c1138..b09af94bc 100644 --- a/src/math/polynomial/polynomial.h +++ b/src/math/polynomial/polynomial.h @@ -29,6 +29,7 @@ Notes: #include "util/params.h" #include "util/mpbqi.h" #include "util/rlimit.h" +#include "util/lbool.h" class small_object_allocator; @@ -98,7 +99,7 @@ namespace polynomial { }; struct display_var_proc { - virtual void operator()(std::ostream & out, var x) const { out << "x" << x; } + virtual std::ostream& operator()(std::ostream & out, var x) const { return out << "x" << x; } }; class polynomial; @@ -306,12 +307,27 @@ namespace polynomial { \brief Return true if m is linear (i.e., it is of the form 1 or x). */ static bool is_linear(monomial const * m); - + /** \brief Return true if all monomials in p are linear. */ static bool is_linear(polynomial const * p); + /** + \brief Return true if the monomial is a variable. + */ + static bool is_var(monomial const* p, var& v); + + /** + \brief Return true if the polynomial is a variable. + */ + bool is_var(polynomial const* p, var& v); + + /** + \brief Return true if the polynomial is of the form x + k + */ + bool is_var_num(polynomial const* p, var& v, scoped_numeral& n); + /** \brief Return the degree of variable x in p. */ @@ -860,7 +876,13 @@ namespace polynomial { \brief Return true if p is a square, and store its square root in r. */ bool sqrt(polynomial const * p, polynomial_ref & r); - + + + /** + \brief obtain the sign of the polynomial given sign of variables. + */ + lbool sign(polynomial const* p, svector const& sign_of_vars); + /** \brief Return true if p is always positive for any assignment of its variables. @@ -936,6 +958,13 @@ namespace polynomial { return substitute(p, 1, &x, &v); } + /** + \brief Apply substiution [x -> p/q] in r. + That is, given r \in Z[x, y_1, .., y_m] return + polynomial q^k * r(p/q, y_1, .., y_m), where k is the maximal degree of x in r. + */ + void substitute(polynomial const* r, var x, polynomial const* p, polynomial const* q, polynomial_ref& result); + /** \brief Factorize the given polynomial p and store its factors in r. */ diff --git a/src/nlsat/nlsat_clause.h b/src/nlsat/nlsat_clause.h index 898c32449..93dfb0e80 100644 --- a/src/nlsat/nlsat_clause.h +++ b/src/nlsat/nlsat_clause.h @@ -44,6 +44,8 @@ namespace nlsat { bool is_learned() const { return m_learned; } literal * begin() { return m_lits; } literal * end() { return m_lits + m_size; } + literal const * begin() const { return m_lits; } + literal const * end() const { return m_lits + m_size; } literal const * c_ptr() const { return m_lits; } void inc_activity() { m_activity++; } void set_activity(unsigned v) { m_activity = v; } diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index e1dadf12b..4cba6d123 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -18,19 +18,20 @@ Author: Revision History: --*/ +#include "util/z3_exception.h" +#include "util/chashtable.h" +#include "util/id_gen.h" +#include "util/map.h" +#include "util/dependency.h" +#include "util/permutation.h" +#include "math/polynomial/algebraic_numbers.h" +#include "math/polynomial/polynomial_cache.h" #include "nlsat/nlsat_solver.h" #include "nlsat/nlsat_clause.h" #include "nlsat/nlsat_assignment.h" #include "nlsat/nlsat_justification.h" #include "nlsat/nlsat_evaluator.h" #include "nlsat/nlsat_explain.h" -#include "math/polynomial/algebraic_numbers.h" -#include "util/z3_exception.h" -#include "util/chashtable.h" -#include "util/id_gen.h" -#include "util/dependency.h" -#include "math/polynomial/polynomial_cache.h" -#include "util/permutation.h" #include "nlsat/nlsat_params.hpp" #define NLSAT_EXTRA_VERBOSE @@ -68,6 +69,7 @@ namespace nlsat { reslimit& m_rlimit; small_object_allocator m_allocator; + bool m_incremental; unsynch_mpq_manager m_qm; pmanager m_pm; cache m_cache; @@ -78,6 +80,8 @@ namespace nlsat { interval_set_manager & m_ism; ineq_atom_table m_ineq_atoms; root_atom_table m_root_atoms; + svector m_patch_var; + polynomial_ref_vector m_patch_num, m_patch_denom; id_gen m_cid_gen; clause_vector m_clauses; // set of clauses @@ -108,11 +112,12 @@ namespace nlsat { m_perm(perm), m_proc(0) { } - virtual void operator()(std::ostream & out, var x) const { + std::ostream& operator()(std::ostream & out, var x) const { if (m_proc == 0) m_default_display_var(out, x); else (*m_proc)(out, m_perm[x]); + return out; } }; perm_display_var_proc m_display_var; @@ -158,9 +163,10 @@ namespace nlsat { unsigned m_stages; unsigned m_irrational_assignments; // number of irrational witnesses - imp(solver& s, reslimit& rlim, params_ref const & p): + imp(solver& s, reslimit& rlim, params_ref const & p, bool incremental): m_rlimit(rlim), m_allocator("nlsat"), + m_incremental(incremental), m_pm(rlim, m_qm, &m_allocator), m_cache(m_pm), m_am(rlim, m_qm, p, &m_allocator), @@ -168,6 +174,8 @@ namespace nlsat { m_assignment(m_am), m_evaluator(s, m_assignment, m_pm, m_allocator), m_ism(m_evaluator.ism()), + m_patch_num(m_pm), + m_patch_denom(m_pm), m_num_bool_vars(0), m_display_var(m_perm), m_explain(s, m_assignment, m_cache, m_atoms, m_var2eq, m_evaluator), @@ -330,9 +338,7 @@ namespace nlsat { */ bool_var max_bvar(clause const & cls) const { bool_var b = null_bool_var; - unsigned sz = cls.size(); - for (unsigned i = 0; i < sz; i++) { - literal l = cls[i]; + for (literal l : cls) { if (b == null_bool_var || l.var() > b) b = l.var(); } @@ -367,9 +373,7 @@ namespace nlsat { if (x == null_var) return 0; unsigned max = 0; - unsigned sz = c.size(); - for (unsigned i = 0; i < sz; i++) { - literal l = c[i]; + for (literal l : c) { atom const * a = m_atoms[l.var()]; if (a == 0) continue; @@ -496,13 +500,12 @@ namespace nlsat { // Delete atoms with ref_count == 0 void del_unref_atoms() { - unsigned sz = m_atoms.size(); - for (unsigned i = 0; i < sz; i++) { - del(m_atoms[i]); + for (auto* a : m_atoms) { + del(a); } } - bool_var mk_ineq_atom(atom::kind k, unsigned sz, poly * const * ps, bool const * is_even) { + ineq_atom* mk_ineq_atom(atom::kind k, unsigned sz, poly * const * ps, bool const * is_even, bool& is_new) { SASSERT(sz >= 1); SASSERT(k == atom::LT || k == atom::GT || k == atom::EQ); int sign = 1; @@ -522,23 +525,36 @@ namespace nlsat { void * mem = m_allocator.allocate(ineq_atom::get_obj_size(sz)); if (sign < 0) k = atom::flip(k); - ineq_atom * new_atom = new (mem) ineq_atom(k, sz, uniq_ps.c_ptr(), is_even, max); + ineq_atom * tmp_atom = new (mem) ineq_atom(k, sz, uniq_ps.c_ptr(), is_even, max); TRACE("nlsat_table_bug", ineq_atom::hash_proc h; - tout << "mk_ineq_atom hash: " << h(new_atom) << "\n"; display(tout, *new_atom, m_display_var); tout << "\n";); - ineq_atom * old_atom = m_ineq_atoms.insert_if_not_there(new_atom); - CTRACE("nlsat_table_bug", old_atom->max_var() != max, display(tout, *old_atom, m_display_var); tout << "\n";); - SASSERT(old_atom->max_var() == max); - if (old_atom != new_atom) { - deallocate(new_atom); - return old_atom->bvar(); + tout << "mk_ineq_atom hash: " << h(tmp_atom) << "\n"; display(tout, *tmp_atom, m_display_var); tout << "\n";); + ineq_atom * atom = m_ineq_atoms.insert_if_not_there(tmp_atom); + CTRACE("nlsat_table_bug", atom->max_var() != max, display(tout, *atom, m_display_var); tout << "\n";); + SASSERT(atom->max_var() == max); + is_new = (atom == tmp_atom); + if (is_new) { + for (unsigned i = 0; i < sz; i++) { + m_pm.inc_ref(atom->p(i)); + } } - bool_var b = mk_bool_var_core(); - m_atoms[b] = new_atom; - new_atom->m_bool_var = b; - for (unsigned i = 0; i < sz; i++) { - m_pm.inc_ref(new_atom->p(i)); + else { + deallocate(tmp_atom); + } + return atom; + } + + bool_var mk_ineq_atom(atom::kind k, unsigned sz, poly * const * ps, bool const * is_even) { + bool is_new = false; + ineq_atom* atom = mk_ineq_atom(k, sz, ps, is_even, is_new); + if (!is_new) { + return atom->bvar(); + } + else { + bool_var b = mk_bool_var_core(); + m_atoms[b] = atom; + atom->m_bool_var = b; + return b; } - return b; } literal mk_ineq_literal(atom::kind k, unsigned sz, poly * const * ps, bool const * is_even) { @@ -619,10 +635,14 @@ namespace nlsat { deallocate(cls); } + void del_clause(clause * cls, clause_vector& clauses) { + clauses.erase(cls); + del_clause(cls); + } + void del_clauses(ptr_vector & cs) { - unsigned sz = cs.size(); - for (unsigned i = 0; i < sz; i++) - del_clause(cs[i]); + for (clause* cp : cs) + del_clause(cp); } void del_clauses() { @@ -927,10 +947,9 @@ namespace nlsat { \brief Return true if the given clause is already satisfied in the current partial interpretation. */ bool is_satisfied(clause const & cls) const { - unsigned sz = cls.size(); - for (unsigned i = 0; i < sz; i++) { - if (const_cast(this)->value(cls[i]) == l_true) { - TRACE("value_bug:", tout << cls[i] << " := true\n";); + for (literal l : cls) { + if (const_cast(this)->value(l) == l_true) { + TRACE("value_bug:", tout << l << " := true\n";); return true; } } @@ -1023,7 +1042,7 @@ namespace nlsat { SASSERT(x != null_var); if (m_var2eq[x] != 0 && degree(m_var2eq[x]) <= degree(a)) return; // we only update m_var2eq if the new equality has smaller degree - TRACE("simplify_core", tout << "Saving equality for "; m_display_var(tout, x); tout << " (x" << x << ") "; + TRACE("simplify_core", tout << "Saving equality for "; m_display_var(tout, x) << " (x" << x << ") "; tout << "scope-lvl: " << scope_lvl() << "\n"; display(tout, literal(b, false)); tout << "\n";); save_updt_eq_trail(m_var2eq[x]); m_var2eq[x] = a; @@ -1045,10 +1064,9 @@ namespace nlsat { interval_set_ref first_undef_set(m_ism); // infeasible region of the first undefined literal interval_set * xk_set = m_infeasible[m_xk]; // current set of infeasible interval for current variable SASSERT(!m_ism.is_full(xk_set)); - unsigned sz = cls.size(); - for (unsigned i = 0; i < sz; i++) { + for (unsigned idx = 0; idx < cls.size(); ++idx) { + literal l = cls[idx]; checkpoint(); - literal l = cls[i]; if (value(l) == l_false) continue; SASSERT(value(l) == l_undef); @@ -1085,7 +1103,7 @@ namespace nlsat { } num_undef++; if (first_undef == UINT_MAX) { - first_undef = i; + first_undef = idx; first_undef_set = curr_set; } } @@ -1131,9 +1149,7 @@ namespace nlsat { Return 0, if the set was satisfied, or the violating clause otherwise */ clause * process_clauses(clause_vector const & cs) { - unsigned sz = cs.size(); - for (unsigned i = 0; i < sz; i++) { - clause * c = cs[i]; + for (clause* c : cs) { if (!process_clause(*c, false)) return c; } @@ -1175,7 +1191,7 @@ namespace nlsat { m_ism.peek_in_complement(m_infeasible[m_xk], m_is_int[m_xk], w, m_randomize); TRACE("nlsat", tout << "infeasible intervals: "; m_ism.display(tout, m_infeasible[m_xk]); tout << "\n"; - tout << "assigning "; m_display_var(tout, m_xk); tout << "(x" << m_xk << ") -> " << w << "\n";); + tout << "assigning "; m_display_var(tout, m_xk) << "(x" << m_xk << ") -> " << w << "\n";); TRACE("nlsat_root", tout << "value as root object: "; m_am.display_root(tout, w); tout << "\n";); if (!m_am.is_rational(w)) m_irrational_assignments++; @@ -1205,6 +1221,7 @@ namespace nlsat { TRACE("nlsat_bug", tout << "xk: x" << m_xk << " bk: b" << m_bk << "\n";); if (m_bk == null_bool_var && m_xk >= num_vars()) { TRACE("nlsat", tout << "found model\n"; display_assignment(tout);); + fix_patch(); return l_true; // all variables were assigned, and all clauses were satisfied. } TRACE("nlsat", tout << "processing variable "; @@ -1295,6 +1312,13 @@ namespace nlsat { init_search(); m_explain.set_full_dimensional(is_full_dimensional()); bool reordered = false; + +#if 0 + // disabled + if (!m_incremental) + simplify(); +#endif + if (!can_reorder()) { } @@ -1497,9 +1521,9 @@ namespace nlsat { TRACE("nlsat_mathematica", display_mathematica_lemma(tout, m_lazy_clause.size(), m_lazy_clause.c_ptr());); TRACE("nlsat_proof_sk", tout << "theory lemma\n"; display_abst(tout, m_lazy_clause.size(), m_lazy_clause.c_ptr()); tout << "\n";); TRACE("nlsat_resolve", - tout << "m_xk: " << m_xk << ", "; m_display_var(tout, m_xk); tout << "\n"; + tout << "m_xk: " << m_xk << ", "; m_display_var(tout, m_xk) << "\n"; tout << "new valid clause:\n"; - display(tout, m_lazy_clause.size(), m_lazy_clause.c_ptr()); tout << "\n";); + display(tout, m_lazy_clause.size(), m_lazy_clause.c_ptr()) << "\n";); DEBUG_CODE({ unsigned sz = m_lazy_clause.size(); @@ -1633,15 +1657,10 @@ namespace nlsat { TRACE("nlsat_proof", tout << "STARTING RESOLUTION\n";); TRACE("nlsat_proof_sk", tout << "STARTING RESOLUTION\n";); m_conflicts++; - TRACE("nlsat", tout << "resolve, conflicting clause:\n"; display(tout, *conflict_clause); tout << "\n"; + TRACE("nlsat", tout << "resolve, conflicting clause:\n"; display(tout, *conflict_clause) << "\n"; tout << "xk: "; if (m_xk != null_var) m_display_var(tout, m_xk); else tout << ""; tout << "\n"; tout << "scope_lvl: " << scope_lvl() << "\n"; tout << "current assignment\n"; display_assignment(tout);); - - // static unsigned counter = 0; - // counter++; - // if (counter > 6) - // exit(0); m_num_marks = 0; m_lemma.reset(); @@ -1750,7 +1769,7 @@ namespace nlsat { SASSERT(m_xk == new_max_var); new_cls = mk_clause(sz, m_lemma.c_ptr(), true, m_lemma_assumptions.get()); TRACE("nlsat", tout << "new_level: " << scope_lvl() << "\nnew_stage: " << new_max_var << " "; - if (new_max_var != null_var) m_display_var(tout, new_max_var); tout << "\n";); + if (new_max_var != null_var) m_display_var(tout, new_max_var) << "\n";); } else { SASSERT(scope_lvl() >= 1); @@ -1931,11 +1950,12 @@ namespace nlsat { collect(*(cs[i])); } - void display(std::ostream & out, display_var_proc const & proc) { + std::ostream& display(std::ostream & out, display_var_proc const & proc) { unsigned sz = m_num_occs.size(); for (unsigned i = 0; i < sz; i++) { proc(out, i); out << " -> " << m_max_degree[i] << " : " << m_num_occs[i] << "\n"; } + return out; } }; @@ -2169,12 +2189,10 @@ namespace nlsat { } void reattach_arith_clauses(clause_vector const & cs) { - unsigned sz = cs.size(); - for (unsigned i = 0; i < sz; i++) { - clause & c = *cs[i]; - var x = max_var(c); + for (clause* cp : cs) { + var x = max_var(*cp); if (x != null_var) - m_watches[x].push_back(&c); + m_watches[x].push_back(cp); } } @@ -2251,18 +2269,16 @@ namespace nlsat { } bool is_full_dimensional(clause const & c) const { - unsigned sz = c.size(); - for (unsigned i = 0; i < sz; i++) { - if (!is_full_dimensional(c[i])) + for (literal l : c) { + if (!is_full_dimensional(l)) return false; } return true; } bool is_full_dimensional(clause_vector const & cs) const { - unsigned sz = cs.size(); - for (unsigned i = 0; i < sz; i++) { - if (!is_full_dimensional(*(cs[i]))) + for (clause* c : cs) { + if (!is_full_dimensional(*c)) return false; } return true; @@ -2272,13 +2288,271 @@ namespace nlsat { return is_full_dimensional(m_clauses); } + + // ----------------------- + // + // Simplification + // + // ----------------------- + + // solve simple equalities + // TBD WU-Reit decomposition? + + /** + \brief isolate variables in unit equalities. + Assume a clause is c == v*p + q + and the context implies p > 0 + + replace v by -q/p + remove clause c, + The for other occurrences of v, + replace v*r + v*v*r' > 0 by + by p*p*v*r + p*p*v*v*r' > 0 + by p*q*r + q*q*r' > 0 + + The method ignores lemmas and assumes constraints don't use roots. + */ + + void simplify() { + polynomial_ref p(m_pm), q(m_pm); + var v; + init_var_signs(); + SASSERT(m_learned.empty()); + bool change = true; + while (change) { + change = false; + for (clause* c : m_clauses) { + if (solve_var(*c, v, p, q)) { + q = -q; + m_patch_var.push_back(v); + m_patch_num.push_back(q); + m_patch_denom.push_back(p); + del_clause(c, m_clauses); + substitute_var(v, p, q); + change = true; + break; + } + } + } + } + + void fix_patch() { + for (unsigned i = m_patch_var.size(); i-- > 0; ) { + var v = m_patch_var[i]; + poly* q = m_patch_num.get(i); + poly* p = m_patch_denom.get(i); + scoped_anum pv(m_am), qv(m_am), val(m_am); + m_pm.eval(p, m_assignment, pv); + m_pm.eval(q, m_assignment, qv); + val = qv / pv; + TRACE("nlsat", + m_display_var(tout << "patch ", v) << "\n"; + if (m_assignment.is_assigned(v)) m_am.display(tout << "previous value: ", m_assignment.value(v)); tout << "\n"; + m_am.display(tout << "updated value: ", val); tout << "\n"; + ); + m_assignment.set_core(v, val); + } + } + + void substitute_var(var x, poly* p, poly* q) { + polynomial_ref pr(m_pm); + polynomial_ref_vector ps(m_pm); + u_map b2l; + svector even; + unsigned num_atoms = m_atoms.size(); + for (unsigned j = 0; j < num_atoms; ++j) { + atom* a = m_atoms[j]; + if (a && a->is_ineq_atom()) { + ineq_atom const& a1 = *to_ineq_atom(a); + unsigned sz = a1.size(); + ps.reset(); + even.reset(); + bool change = false; + for (unsigned i = 0; i < sz; ++i) { + poly * po = a1.p(i); + m_pm.substitute(po, x, q, p, pr); + ps.push_back(pr); + even.push_back(a1.is_even(i)); + change |= pr != po; + if (m_pm.is_zero(pr)) { + ps.reset(); + even.reset(); + change = true; + break; + } + } + if (!change) continue; + literal l = mk_ineq_literal(a1.get_kind(), ps.size(), ps.c_ptr(), even.c_ptr()); + if (a1.m_bool_var != l.var()) { + b2l.insert(a1.m_bool_var, l); + inc_ref(l); + } + } + } + update_clauses(b2l); + for (auto const& kv : b2l) { + dec_ref(kv.m_value); + } + } + + + void update_clauses(u_map const& b2l) { + literal_vector lits; + clause_vector to_delete; + unsigned n = m_clauses.size(); + for (unsigned i = 0; i < n; ++i) { + clause* c = m_clauses[i]; + lits.reset(); + bool changed = false; + bool is_tautology = false; + for (literal l : *c) { + literal lit = null_literal; + if (b2l.find(l.var(), lit)) { + lit = l.sign() ? ~lit : lit; + if (lit == true_literal) { + is_tautology = true; + } + else if (lit != false_literal) { + lits.push_back(lit); + } + changed = true; + } + else { + lits.push_back(l); + } + } + if (changed) { + to_delete.push_back(c); + if (!is_tautology) { + mk_clause(lits.size(), lits.c_ptr(), c->is_learned(), static_cast<_assumption_set>(c->assumptions())); + } + } + } + for (clause* c : to_delete) { + del_clause(c, m_clauses); + } + } + + bool is_unit_ineq(clause const& c) const { + return + c.size() == 1 && + m_atoms[c[0].var()] && + m_atoms[c[0].var()]->is_ineq_atom(); + } + + bool is_unit_eq(clause const& c) const { + return + is_unit_ineq(c) && + !c[0].sign() && + m_atoms[c[0].var()]->is_eq(); + } + + /** + \brief determine whether the clause is a comparison v > k or v < k', where k >= 0 or k' <= 0. + */ + lbool is_cmp0(clause const& c, var& v) { + if (!is_unit_ineq(c)) return l_undef; + literal lit = c[0]; + ineq_atom const& a = *to_ineq_atom(m_atoms[lit.var()]); + bool sign = lit.sign(); + poly * p0; + if (!is_single_poly(a, p0)) return l_undef; + if (m_pm.is_var(p0, v)) { + if (!sign && a.get_kind() == atom::GT) { + return l_true; + } + if (!sign && a.get_kind() == atom::LT) { + return l_false; + } + return l_undef; + } + polynomial::scoped_numeral n(m_pm.m()); + if (m_pm.is_var_num(p0, v, n)) { + // x - k > 0 + if (!sign && a.get_kind() == atom::GT && m_pm.m().is_nonneg(n)) { + return l_true; + } + // x + k < 0 + if (!sign && a.get_kind() == atom::LT && m_pm.m().is_nonpos(n)) { + return l_false; + } + // !(x + k > 0) + if (sign && a.get_kind() == atom::GT && m_pm.m().is_pos(n)) { + return l_false; + } + // !(x - k < 0) + if (sign && a.get_kind() == atom::LT && m_pm.m().is_neg(n)) { + return l_true; + } + } + return l_undef; + } + + bool is_single_poly(ineq_atom const& a, poly*& p) { + unsigned sz = a.size(); + return sz == 1 && a.is_odd(0) && (p = a.p(0), true); + } + + svector m_var_signs; + + void init_var_signs() { + m_var_signs.reset(); + for (clause* cp : m_clauses) { + clause& c = *cp; + var x = 0; + lbool cmp = is_cmp0(c, x); + switch (cmp) { + case l_true: + m_var_signs.setx(x, l_true, l_undef); + break; + case l_false: + m_var_signs.setx(x, l_false, l_undef); + break; + default: + break; + } + } + } + + /** + \brief returns true then c is an equality that is equivalent to v*p + q, + and p > 0, v does not occur in p, q. + */ + bool solve_var(clause& c, var& v, polynomial_ref& p, polynomial_ref& q) { + poly* p0; + if (!is_unit_eq(c)) return false; + ineq_atom & a = *to_ineq_atom(m_atoms[c[0].var()]); + if (!is_single_poly(a, p0)) return false; + var mx = max_var(p0); + if (mx >= m_is_int.size()) return false; + for (var x = 0; x <= mx; ++x) { + if (m_is_int[x]) continue; + if (1 == m_pm.degree(p0, x)) { + p = m_pm.coeff(p0, x, 1, q); + switch (m_pm.sign(p, m_var_signs)) { + case l_true: + v = x; + return true; + case l_false: + v = x; + p = -p; + q = -q; + return true; + default: + break; + } + } + } + return false; + } + // ----------------------- // // Pretty printing // // ----------------------- - void display_num_assignment(std::ostream & out, display_var_proc const & proc) const { + std::ostream& display_num_assignment(std::ostream & out, display_var_proc const & proc) const { for (var x = 0; x < num_vars(); x++) { if (m_assignment.is_assigned(x)) { proc(out, x); @@ -2287,9 +2561,10 @@ namespace nlsat { out << "\n"; } } + return out; } - void display_bool_assignment(std::ostream & out) const { + std::ostream& display_bool_assignment(std::ostream & out) const { unsigned sz = m_atoms.size(); for (bool_var b = 0; b < sz; b++) { if (m_atoms[b] == 0 && m_bvalues[b] != l_undef) { @@ -2300,6 +2575,7 @@ namespace nlsat { for (bool_var b = 0; b < sz; b++) { out << "b" << b << " -> " << m_bvalues[b] << " " << m_atoms[b] << "\n"; }); + return out; } bool display_mathematica_assignment(std::ostream & out) const { @@ -2317,16 +2593,17 @@ namespace nlsat { return !first; } - void display_num_assignment(std::ostream & out) const { - display_num_assignment(out, m_display_var); + std::ostream& display_num_assignment(std::ostream & out) const { + return display_num_assignment(out, m_display_var); } - void display_assignment(std::ostream& out) const { + std::ostream& display_assignment(std::ostream& out) const { display_bool_assignment(out); display_num_assignment(out); + return out; } - void display(std::ostream & out, ineq_atom const & a, display_var_proc const & proc, bool use_star = false) const { + std::ostream& display(std::ostream & out, ineq_atom const & a, display_var_proc const & proc, bool use_star = false) const { unsigned sz = a.size(); for (unsigned i = 0; i < sz; i++) { if (use_star && i > 0) @@ -2346,9 +2623,10 @@ namespace nlsat { case atom::EQ: out << " = 0"; break; default: UNREACHABLE(); break; } + return out; } - - void display_mathematica(std::ostream & out, ineq_atom const & a) const { + + std::ostream& display_mathematica(std::ostream & out, ineq_atom const & a) const { unsigned sz = a.size(); for (unsigned i = 0; i < sz; i++) { if (i > 0) @@ -2370,9 +2648,10 @@ namespace nlsat { case atom::EQ: out << " == 0"; break; default: UNREACHABLE(); break; } + return out; } - void display_smt2(std::ostream & out, ineq_atom const & a, display_var_proc const & proc) const { + std::ostream& display_smt2(std::ostream & out, ineq_atom const & a, display_var_proc const & proc) const { switch (a.get_kind()) { case atom::LT: out << "(< "; break; case atom::GT: out << "(> "; break; @@ -2398,9 +2677,10 @@ namespace nlsat { if (sz > 1) out << ")"; out << " 0)"; + return out; } - void display(std::ostream & out, root_atom const & a, display_var_proc const & proc) const { + std::ostream& display(std::ostream & out, root_atom const & a, display_var_proc const & proc) const { proc(out, a.x()); switch (a.get_kind()) { case atom::ROOT_LT: out << " < "; break; @@ -2413,21 +2693,22 @@ namespace nlsat { out << "root[" << a.i() << "]("; m_pm.display(out, a.p(), proc); out << ")"; + return out; } struct mathematica_var_proc : public display_var_proc { var m_x; public: mathematica_var_proc(var x):m_x(x) {} - virtual void operator()(std::ostream & out, var x) const { + virtual std::ostream& operator()(std::ostream & out, var x) const { if (m_x == x) - out << "#1"; + return out << "#1"; else - out << "x" << x; + return out << "x" << x; } }; - void display_mathematica(std::ostream & out, root_atom const & a) const { + std::ostream& display_mathematica(std::ostream & out, root_atom const & a) const { out << "x" << a.x(); switch (a.get_kind()) { case atom::ROOT_LT: out << " < "; break; @@ -2440,65 +2721,74 @@ namespace nlsat { out << "Root["; m_pm.display(out, a.p(), mathematica_var_proc(a.x()), true); out << " &, " << a.i() << "]"; + return out; } - void display_smt2(std::ostream & out, root_atom const & a) const { + std::ostream& display_smt2(std::ostream & out, root_atom const & a) const { NOT_IMPLEMENTED_YET(); + return out; } - void display(std::ostream & out, atom const & a, display_var_proc const & proc) const { + std::ostream& display(std::ostream & out, atom const & a, display_var_proc const & proc) const { if (a.is_ineq_atom()) - display(out, static_cast(a), proc); + return display(out, static_cast(a), proc); else - display(out, static_cast(a), proc); + return display(out, static_cast(a), proc); } - void display_mathematica(std::ostream & out, atom const & a) const { - if (a.is_ineq_atom()) - display_mathematica(out, static_cast(a)); - else - display_mathematica(out, static_cast(a)); + std::ostream& display(std::ostream & out, atom const & a) const { + return display(out, a, m_display_var); } - void display_smt2(std::ostream & out, atom const & a, display_var_proc const & proc) const { + std::ostream& display_mathematica(std::ostream & out, atom const & a) const { if (a.is_ineq_atom()) - display_smt2(out, static_cast(a), proc); + return display_mathematica(out, static_cast(a)); else - display_smt2(out, static_cast(a), proc); + return display_mathematica(out, static_cast(a)); } - void display_atom(std::ostream & out, bool_var b, display_var_proc const & proc) const { + std::ostream& display_smt2(std::ostream & out, atom const & a, display_var_proc const & proc) const { + if (a.is_ineq_atom()) + return display_smt2(out, static_cast(a), proc); + else + return display_smt2(out, static_cast(a), proc); + } + + std::ostream& display_atom(std::ostream & out, bool_var b, display_var_proc const & proc) const { if (b == 0) out << "true"; else if (m_atoms[b] == 0) out << "b" << b; else display(out, *(m_atoms[b]), proc); + return out; } - void display_atom(std::ostream & out, bool_var b) const { - display_atom(out, b, m_display_var); + std::ostream& display_atom(std::ostream & out, bool_var b) const { + return display_atom(out, b, m_display_var); } - void display_mathematica_atom(std::ostream & out, bool_var b) const { + std::ostream& display_mathematica_atom(std::ostream & out, bool_var b) const { if (b == 0) out << "(0 < 1)"; else if (m_atoms[b] == 0) out << "b" << b; else display_mathematica(out, *(m_atoms[b])); + return out; } - void display_smt2_atom(std::ostream & out, bool_var b, display_var_proc const & proc) const { + std::ostream& display_smt2_atom(std::ostream & out, bool_var b, display_var_proc const & proc) const { if (b == 0) out << "true"; else if (m_atoms[b] == 0) out << "b" << b; else display_smt2(out, *(m_atoms[b]), proc); + return out; } - void display(std::ostream & out, literal l, display_var_proc const & proc) const { + std::ostream& display(std::ostream & out, literal l, display_var_proc const & proc) const { if (l.sign()) { bool_var b = l.var(); out << "!"; @@ -2511,13 +2801,14 @@ namespace nlsat { else { display_atom(out, l.var(), proc); } + return out; } - void display(std::ostream & out, literal l) const { - display(out, l, m_display_var); + std::ostream& display(std::ostream & out, literal l) const { + return display(out, l, m_display_var); } - void display_mathematica(std::ostream & out, literal l) const { + std::ostream& display_mathematica(std::ostream & out, literal l) const { if (l.sign()) { bool_var b = l.var(); out << "!"; @@ -2530,9 +2821,10 @@ namespace nlsat { else { display_mathematica_atom(out, l.var()); } + return out; } - void display_smt2(std::ostream & out, literal l, display_var_proc const & proc) const { + std::ostream& display_smt2(std::ostream & out, literal l, display_var_proc const & proc) const { if (l.sign()) { bool_var b = l.var(); out << "(not "; @@ -2542,41 +2834,43 @@ namespace nlsat { else { display_smt2_atom(out, l.var(), proc); } + return out; } - void display_assumptions(std::ostream & out, _assumption_set s) const { - + std::ostream& display_assumptions(std::ostream & out, _assumption_set s) const { + return out; } - void display(std::ostream & out, unsigned num, literal const * ls, display_var_proc const & proc) const { + std::ostream& display(std::ostream & out, unsigned num, literal const * ls, display_var_proc const & proc) const { for (unsigned i = 0; i < num; i++) { if (i > 0) out << " or "; display(out, ls[i], proc); } + return out; } - void display(std::ostream & out, unsigned num, literal const * ls) { - display(out, num, ls, m_display_var); + std::ostream& display(std::ostream & out, unsigned num, literal const * ls) { + return display(out, num, ls, m_display_var); + } + + std::ostream& display(std::ostream & out, scoped_literal_vector const & cs) { + return display(out, cs.size(), cs.c_ptr(), m_display_var); } - void display(std::ostream & out, scoped_literal_vector const & cs) { - display(out, cs.size(), cs.c_ptr(), m_display_var); - } - - void display(std::ostream & out, clause const & c, display_var_proc const & proc) const { + std::ostream& display(std::ostream & out, clause const & c, display_var_proc const & proc) const { if (c.assumptions() != 0) { display_assumptions(out, static_cast<_assumption_set>(c.assumptions())); out << " |- "; } - display(out, c.size(), c.c_ptr(), proc); + return display(out, c.size(), c.c_ptr(), proc); } - void display(std::ostream & out, clause const & c) const { - display(out, c, m_display_var); + std::ostream& display(std::ostream & out, clause const & c) const { + return display(out, c, m_display_var); } - void display_smt2(std::ostream & out, unsigned num, literal const * ls, display_var_proc const & proc) const { + std::ostream& display_smt2(std::ostream & out, unsigned num, literal const * ls, display_var_proc const & proc) const { if (num == 0) { out << "false"; } @@ -2591,13 +2885,14 @@ namespace nlsat { } out << ")"; } + return out; } - void display_smt2(std::ostream & out, clause const & c, display_var_proc const & proc = display_var_proc()) const { - display_smt2(out, c.size(), c.c_ptr(), proc); + std::ostream& display_smt2(std::ostream & out, clause const & c, display_var_proc const & proc = display_var_proc()) const { + return display_smt2(out, c.size(), c.c_ptr(), proc); } - void display_abst(std::ostream & out, literal l) const { + std::ostream& display_abst(std::ostream & out, literal l) const { if (l.sign()) { bool_var b = l.var(); out << "!"; @@ -2609,25 +2904,27 @@ namespace nlsat { else { out << "b" << l.var(); } + return out; } - void display_abst(std::ostream & out, unsigned num, literal const * ls) const { + std::ostream& display_abst(std::ostream & out, unsigned num, literal const * ls) const { for (unsigned i = 0; i < num; i++) { if (i > 0) out << " or "; display_abst(out, ls[i]); } + return out; } - void display_abst(std::ostream & out, scoped_literal_vector const & cs) const { - display_abst(out, cs.size(), cs.c_ptr()); + std::ostream& display_abst(std::ostream & out, scoped_literal_vector const & cs) const { + return display_abst(out, cs.size(), cs.c_ptr()); } - void display_abst(std::ostream & out, clause const & c) const { - display_abst(out, c.size(), c.c_ptr()); + std::ostream& display_abst(std::ostream & out, clause const & c) const { + return display_abst(out, c.size(), c.c_ptr()); } - void display_mathematica(std::ostream & out, clause const & c) const { + std::ostream& display_mathematica(std::ostream & out, clause const & c) const { out << "("; unsigned sz = c.size(); for (unsigned i = 0; i < sz; i++) { @@ -2636,12 +2933,13 @@ namespace nlsat { display_mathematica(out, c[i]); } out << ")"; + return out; } // Debugging support: // Display generated lemma in Mathematica format. // Mathematica must reduce lemma to True (modulo resource constraints). - void display_mathematica_lemma(std::ostream & out, unsigned num, literal const * ls, bool include_assignment = false) const { + std::ostream& display_mathematica_lemma(std::ostream & out, unsigned num, literal const * ls, bool include_assignment = false) const { out << "Resolve[ForAll[{"; // var definition for (unsigned i = 0; i < num_vars(); i++) { @@ -2662,71 +2960,69 @@ namespace nlsat { display_mathematica(out, ls[i]); } out << "], Reals]\n"; // end of exists + return out; } - void display(std::ostream & out, clause_vector const & cs, display_var_proc const & proc) const { - unsigned sz = cs.size(); - for (unsigned i = 0; i < sz; i++) { - display(out, *(cs[i]), proc); - out << "\n"; + std::ostream& display(std::ostream & out, clause_vector const & cs, display_var_proc const & proc) const { + for (clause* c : cs) { + display(out, *c, proc) << "\n"; } + return out; } - void display(std::ostream & out, clause_vector const & cs) const { - display(out, cs, m_display_var); + std::ostream& display(std::ostream & out, clause_vector const & cs) const { + return display(out, cs, m_display_var); } - void display_mathematica(std::ostream & out, clause_vector const & cs) const { + std::ostream& display_mathematica(std::ostream & out, clause_vector const & cs) const { unsigned sz = cs.size(); for (unsigned i = 0; i < sz; i++) { if (i > 0) out << ",\n"; - out << " "; - display_mathematica(out, *(cs[i])); + display_mathematica(out << " ", *(cs[i])); } + return out; } - void display_abst(std::ostream & out, clause_vector const & cs) const { - unsigned sz = cs.size(); - for (unsigned i = 0; i < sz; i++) { - display_abst(out, *(cs[i])); - out << "\n"; + std::ostream& display_abst(std::ostream & out, clause_vector const & cs) const { + for (clause* c : cs) { + display_abst(out, *c) << "\n"; } + return out; } - void display(std::ostream & out, display_var_proc const & proc) const { + std::ostream& display(std::ostream & out, display_var_proc const & proc) const { display(out, m_clauses, proc); if (!m_learned.empty()) { - out << "Lemmas:\n"; - display(out, m_learned, proc); + display(out << "Lemmas:\n", m_learned, proc); } + return out; } - void display_mathematica(std::ostream & out) const { - out << "{\n"; - display_mathematica(out, m_clauses); - out << "}\n"; + std::ostream& display_mathematica(std::ostream & out) const { + return display_mathematica(out << "{\n", m_clauses) << "}\n"; } - void display_abst(std::ostream & out) const { + std::ostream& display_abst(std::ostream & out) const { display_abst(out, m_clauses); if (!m_learned.empty()) { - out << "Lemmas:\n"; - display_abst(out, m_learned); + display_abst(out << "Lemmas:\n", m_learned); } + return out; } - void display(std::ostream & out) const { + std::ostream& display(std::ostream & out) const { display(out, m_display_var); - display_assignment(out); + return display_assignment(out); } - void display_vars(std::ostream & out) const { + std::ostream& display_vars(std::ostream & out) const { for (unsigned i = 0; i < num_vars(); i++) { out << i << " -> "; m_display_var(out, i); out << "\n"; } + return out; } - void display_smt2_arith_decls(std::ostream & out) const { + std::ostream& display_smt2_arith_decls(std::ostream & out) const { unsigned sz = m_is_int.size(); for (unsigned i = 0; i < sz; i++) { if (m_is_int[i]) @@ -2734,31 +3030,32 @@ namespace nlsat { else out << "(declare-fun x" << i << " () Real)\n"; } + return out; } - void display_smt2_bool_decls(std::ostream & out) const { + std::ostream& display_smt2_bool_decls(std::ostream & out) const { unsigned sz = m_atoms.size(); for (unsigned i = 0; i < sz; i++) { if (m_atoms[i] == 0) out << "(declare-fun b" << i << " () Bool)\n"; } + return out; } - void display_smt2(std::ostream & out) const { + std::ostream& display_smt2(std::ostream & out) const { display_smt2_bool_decls(out); display_smt2_arith_decls(out); out << "(assert (and true\n"; - unsigned sz = m_clauses.size(); - for (unsigned i = 0; i < sz; i++) { - display_smt2(out, *(m_clauses[i])); - out << "\n"; + for (clause* c : m_clauses) { + display_smt2(out, *c) << "\n"; } out << "))\n(check-sat)" << std::endl; + return out; } }; - solver::solver(reslimit& rlim, params_ref const & p) { - m_imp = alloc(imp, *this, rlim, p); + solver::solver(reslimit& rlim, params_ref const & p, bool incremental) { + m_imp = alloc(imp, *this, rlim, p, incremental); } solver::~solver() { diff --git a/src/nlsat/nlsat_solver.h b/src/nlsat/nlsat_solver.h index ac503c603..c632a0334 100644 --- a/src/nlsat/nlsat_solver.h +++ b/src/nlsat/nlsat_solver.h @@ -35,7 +35,7 @@ namespace nlsat { struct imp; imp * m_imp; public: - solver(reslimit& rlim, params_ref const & p); + solver(reslimit& rlim, params_ref const & p, bool incremental); ~solver(); /** diff --git a/src/nlsat/nlsat_types.h b/src/nlsat/nlsat_types.h index db3b6ffa5..647a5e3ee 100644 --- a/src/nlsat/nlsat_types.h +++ b/src/nlsat/nlsat_types.h @@ -47,6 +47,8 @@ namespace nlsat { typedef polynomial::var_vector var_vector; typedef polynomial::manager pmanager; typedef polynomial::polynomial poly; + typedef polynomial::monomial monomial; + typedef polynomial::numeral numeral; const var null_var = polynomial::null_var; const var true_bool_var = 0; diff --git a/src/nlsat/tactic/nlsat_tactic.cpp b/src/nlsat/tactic/nlsat_tactic.cpp index 510f503e7..9de7215e3 100644 --- a/src/nlsat/tactic/nlsat_tactic.cpp +++ b/src/nlsat/tactic/nlsat_tactic.cpp @@ -32,11 +32,11 @@ class nlsat_tactic : public tactic { ast_manager & m; expr_ref_vector m_var2expr; expr_display_var_proc(ast_manager & _m):m(_m), m_var2expr(_m) {} - virtual void operator()(std::ostream & out, nlsat::var x) const { + virtual std::ostream& operator()(std::ostream & out, nlsat::var x) const { if (x < m_var2expr.size()) - out << mk_ismt2_pp(m_var2expr.get(x), m); + return out << mk_ismt2_pp(m_var2expr.get(x), m); else - out << "x!" << x; + return out << "x!" << x; } }; @@ -51,7 +51,7 @@ class nlsat_tactic : public tactic { m(_m), m_params(p), m_display_var(_m), - m_solver(m.limit(), p) { + m_solver(m.limit(), p, false) { } void updt_params(params_ref const & p) { diff --git a/src/nlsat/tactic/qfnra_nlsat_tactic.cpp b/src/nlsat/tactic/qfnra_nlsat_tactic.cpp index 22f64af47..47b9e0505 100644 --- a/src/nlsat/tactic/qfnra_nlsat_tactic.cpp +++ b/src/nlsat/tactic/qfnra_nlsat_tactic.cpp @@ -48,11 +48,15 @@ tactic * mk_qfnra_nlsat_tactic(ast_manager & m, params_ref const & p) { purify_p), mk_propagate_values_tactic(m, p), mk_solve_eqs_tactic(m, p), + using_params(mk_purify_arith_tactic(m, p), + purify_p), mk_elim_uncnstr_tactic(m, p), mk_elim_term_ite_tactic(m, p)), and_then(/* mk_degree_shift_tactic(m, p), */ // may affect full dimensionality detection factor, mk_solve_eqs_tactic(m, p), + using_params(mk_purify_arith_tactic(m, p), + purify_p), using_params(mk_simplify_tactic(m, p), main_p), mk_tseitin_cnf_core_tactic(m, p), diff --git a/src/qe/nlqsat.cpp b/src/qe/nlqsat.cpp index ab5095328..e28f6ae4f 100644 --- a/src/qe/nlqsat.cpp +++ b/src/qe/nlqsat.cpp @@ -782,7 +782,7 @@ namespace qe { m(m), m_mode(mode), m_params(p), - m_solver(m.limit(), p), + m_solver(m.limit(), p, true), m_nftactic(0), m_rmodel(m_solver.am()), m_rmodel0(m_solver.am()), diff --git a/src/tactic/core/solve_eqs_tactic.cpp b/src/tactic/core/solve_eqs_tactic.cpp index 65d474182..5df523ff7 100644 --- a/src/tactic/core/solve_eqs_tactic.cpp +++ b/src/tactic/core/solve_eqs_tactic.cpp @@ -44,6 +44,7 @@ class solve_eqs_tactic : public tactic { expr_sparse_mark m_candidate_set; ptr_vector m_candidates; ptr_vector m_vars; + expr_sparse_mark m_nonzero; ptr_vector m_ordered_vars; bool m_produce_proofs; bool m_produce_unsat_cores; @@ -55,8 +56,7 @@ class solve_eqs_tactic : public tactic { m_r_owner(r == 0 || 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) m_r = mk_default_expr_replacer(m); @@ -78,7 +78,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 @@ -106,7 +106,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)); @@ -187,6 +188,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 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 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)); @@ -204,7 +276,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()) && @@ -252,16 +325,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 = 0, *arg2 = 0; + 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; @@ -321,11 +398,14 @@ class solve_eqs_tactic : public tactic { 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); @@ -347,10 +427,8 @@ class solve_eqs_tactic : public tactic { TRACE("solve_eqs", tout << "candidate vars:\n"; - ptr_vector::iterator it = m_vars.begin(); - ptr_vector::iterator end = m_vars.end(); - for (; it != end; ++it) { - tout << mk_ismt2_pp(*it, m()) << " "; + for (app* v : m_vars) { + tout << mk_ismt2_pp(v, m()) << " "; } tout << "\n";); } @@ -374,12 +452,9 @@ class solve_eqs_tactic : public tactic { typedef std::pair frame; svector todo; - ptr_vector::const_iterator it = m_vars.begin(); - ptr_vector::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)); @@ -483,20 +558,19 @@ 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", tout << "ordered vars:\n"; - ptr_vector::iterator it = m_ordered_vars.begin(); - ptr_vector::iterator end = m_ordered_vars.end(); - for (; it != end; ++it) { - SASSERT(m_candidate_vars.is_marked(*it)); - tout << mk_ismt2_pp(*it, m()) << " "; + for (app* v : m_ordered_vars) { + SASSERT(m_candidate_vars.is_marked(v)); + tout << mk_ismt2_pp(v, m()) << " "; } tout << "\n";); m_candidate_vars.reset(); @@ -609,10 +683,7 @@ class solve_eqs_tactic : public tactic { if (m_produce_models) { if (mc.get() == 0) mc = alloc(gmc, m()); - ptr_vector::iterator it = m_ordered_vars.begin(); - ptr_vector::iterator end = m_ordered_vars.end(); - for (; it != end; ++it) { - app * v = *it; + for (app* v : m_ordered_vars) { expr * def = 0; proof * pr; expr_dependency * dep; From b78c538e021763ef6608801bfa84d593964a63f2 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 30 Dec 2017 22:58:41 -0800 Subject: [PATCH 117/263] fix build of test Signed-off-by: Nikolaj Bjorner --- src/test/nlsat.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/nlsat.cpp b/src/test/nlsat.cpp index ecf73843f..19add1fab 100644 --- a/src/test/nlsat.cpp +++ b/src/test/nlsat.cpp @@ -272,7 +272,7 @@ static void tst4() { static void tst5() { params_ref ps; reslimit rlim; - nlsat::solver s(rlim, ps); + nlsat::solver s(rlim, ps, false); anum_manager & am = s.am(); nlsat::pmanager & pm = s.pm(); nlsat::assignment as(am); @@ -330,7 +330,7 @@ static nlsat::literal mk_eq(nlsat::solver& s, nlsat::poly* p) { static void tst6() { params_ref ps; reslimit rlim; - nlsat::solver s(rlim, ps); + nlsat::solver s(rlim, ps, false); anum_manager & am = s.am(); nlsat::pmanager & pm = s.pm(); nlsat::assignment as(am); @@ -390,7 +390,7 @@ static void tst6() { static void tst7() { params_ref ps; reslimit rlim; - nlsat::solver s(rlim, ps); + nlsat::solver s(rlim, ps, false); nlsat::pmanager & pm = s.pm(); nlsat::var x0, x1, x2, a, b, c, d; a = s.mk_var(false); @@ -443,7 +443,7 @@ static void tst7() { static void tst8() { params_ref ps; reslimit rlim; - nlsat::solver s(rlim, ps); + nlsat::solver s(rlim, ps, false); anum_manager & am = s.am(); nlsat::pmanager & pm = s.pm(); nlsat::assignment as(am); @@ -492,7 +492,7 @@ static void tst8() { static void tst9() { params_ref ps; reslimit rlim; - nlsat::solver s(rlim, ps); + nlsat::solver s(rlim, ps, false); anum_manager & am = s.am(); nlsat::pmanager & pm = s.pm(); nlsat::assignment as(am); @@ -624,7 +624,7 @@ static bool satisfies_root(nlsat::solver& s, nlsat::atom::kind k, nlsat::poly* p static void tst10() { params_ref ps; reslimit rlim; - nlsat::solver s(rlim, ps); + nlsat::solver s(rlim, ps, false); anum_manager & am = s.am(); nlsat::pmanager & pm = s.pm(); nlsat::assignment as(am); From 8dadd30db5e1f09739bcb877e9dc5fb3240b1cf9 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 1 Jan 2018 17:11:43 -0800 Subject: [PATCH 118/263] add __copy__, __deepcopy__ as alias to translate on same context #1427. Add generalized Gaussian elimination as an option to first-pass NL solver Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 24 +++++++++++++++++++ .../bit_blaster/bit_blaster_tpl_def.h | 1 - src/nlsat/nlsat_params.pyg | 1 + src/nlsat/nlsat_solver.cpp | 7 +++--- src/tactic/smtlogics/qfnra_tactic.cpp | 6 +++-- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 4cc401156..20c521df6 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -365,6 +365,12 @@ class AstRef(Z3PPObject): _z3_assert(isinstance(target, Context), "argument must be a Z3 context") return _to_ast_ref(Z3_translate(self.ctx.ref(), self.as_ast(), target.ref()), target) + def __copy__(self): + return self.translate(self.ctx) + + def __deepcopy__(self): + return self.translate(self.ctx) + def hash(self): """Return a hashcode for the `self`. @@ -5048,6 +5054,12 @@ class Goal(Z3PPObject): _z3_assert(isinstance(target, Context), "target must be a context") return Goal(goal=Z3_goal_translate(self.ctx.ref(), self.goal, target.ref()), ctx=target) + def __copy__(self): + return self.translate(self.ctx) + + def __deepcopy__(self): + return self.translate(self.ctx) + def simplify(self, *arguments, **keywords): """Return a new simplified goal. @@ -5230,6 +5242,12 @@ class AstVector(Z3PPObject): """ return AstVector(Z3_ast_vector_translate(self.ctx.ref(), self.vector, other_ctx.ref()), other_ctx) + def __copy__(self): + return self.translate(self.ctx) + + def __deepcopy__(self): + return self.translate(self.ctx) + def __repr__(self): return obj_to_string(self) @@ -6430,6 +6448,12 @@ class Solver(Z3PPObject): solver = Z3_solver_translate(self.ctx.ref(), self.solver, target.ref()) return Solver(solver, target) + def __copy__(self): + return self.translate(self.ctx) + + def __deepcopy__(self): + return self.translate(self.ctx) + def sexpr(self): """Return a formatted string (in Lisp-like format) with all added constraints. We say the string is in s-expression format. diff --git a/src/ast/rewriter/bit_blaster/bit_blaster_tpl_def.h b/src/ast/rewriter/bit_blaster/bit_blaster_tpl_def.h index a80994f6c..cf7e7c951 100644 --- a/src/ast/rewriter/bit_blaster/bit_blaster_tpl_def.h +++ b/src/ast/rewriter/bit_blaster/bit_blaster_tpl_def.h @@ -1193,7 +1193,6 @@ bool bit_blaster_tpl::mk_const_case_multiplier(unsigned sz, expr * const * return false; } SASSERT(out_bits.empty()); - ptr_buffer na_bits; na_bits.append(sz, a_bits); ptr_buffer nb_bits; diff --git a/src/nlsat/nlsat_params.pyg b/src/nlsat/nlsat_params.pyg index 6b1577113..0f2e03069 100644 --- a/src/nlsat/nlsat_params.pyg +++ b/src/nlsat/nlsat_params.pyg @@ -10,6 +10,7 @@ def_module_params('nlsat', ('randomize', BOOL, True, "randomize selection of a witness in nlsat."), ('max_conflicts', UINT, UINT_MAX, "maximum number of conflicts."), ('shuffle_vars', BOOL, False, "use a random variable order."), + ('inline_vars', BOOL, False, "inline variables that can be isolated from equations"), ('seed', UINT, 0, "random seed."), ('factor', BOOL, True, "factor polynomials produced during conflict resolution.") )) diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 4cba6d123..448aa624d 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -154,6 +154,7 @@ namespace nlsat { bool m_randomize; bool m_random_order; unsigned m_random_seed; + bool m_inline_vars; unsigned m_max_conflicts; // statistics @@ -210,6 +211,7 @@ namespace nlsat { m_max_conflicts = p.max_conflicts(); m_random_order = p.shuffle_vars(); m_random_seed = p.seed(); + m_inline_vars = p.inline_vars(); m_ism.set_seed(m_random_seed); m_explain.set_simplify_cores(m_simplify_cores); m_explain.set_minimize_cores(min_cores); @@ -1313,11 +1315,8 @@ namespace nlsat { m_explain.set_full_dimensional(is_full_dimensional()); bool reordered = false; -#if 0 - // disabled - if (!m_incremental) + if (!m_incremental && m_inline_vars) simplify(); -#endif if (!can_reorder()) { diff --git a/src/tactic/smtlogics/qfnra_tactic.cpp b/src/tactic/smtlogics/qfnra_tactic.cpp index 63c09c19c..cc01950a2 100644 --- a/src/tactic/smtlogics/qfnra_tactic.cpp +++ b/src/tactic/smtlogics/qfnra_tactic.cpp @@ -33,7 +33,9 @@ static tactic * mk_qfnra_sat_solver(ast_manager& m, params_ref const& p, unsigne } tactic * mk_qfnra_tactic(ast_manager & m, params_ref const& p) { - params_ref p1 = p; + params_ref p0 = p; + p0.set_bool("inline_vars", true); + params_ref p1 = p; p1.set_uint("seed", 11); p1.set_bool("factor", false); params_ref p2 = p; @@ -42,7 +44,7 @@ tactic * mk_qfnra_tactic(ast_manager & m, params_ref const& p) { return and_then(mk_simplify_tactic(m, p), mk_propagate_values_tactic(m, p), - or_else(try_for(mk_qfnra_nlsat_tactic(m, p), 5000), + or_else(try_for(mk_qfnra_nlsat_tactic(m, p0), 5000), try_for(mk_qfnra_nlsat_tactic(m, p1), 10000), mk_qfnra_sat_solver(m, p, 4), and_then(try_for(mk_smt_tactic(), 5000), mk_fail_if_undecided_tactic()), From f0a30ded7db8aa1e93cf91840ae2469e51c5deb5 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 1 Jan 2018 19:25:09 -0800 Subject: [PATCH 119/263] add shorthand for translating models #1407 Signed-off-by: Nikolaj Bjorner --- src/api/api_model.cpp | 12 ++++++++++++ src/api/c++/z3++.h | 2 ++ src/api/python/z3/z3.py | 31 +++++++++++++++++++++++++------ src/api/z3_api.h | 7 +++++++ src/smt/theory_seq.cpp | 3 ++- 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/api/api_model.cpp b/src/api/api_model.cpp index bda33f186..d9936ff66 100644 --- a/src/api/api_model.cpp +++ b/src/api/api_model.cpp @@ -212,6 +212,18 @@ extern "C" { RETURN_Z3(of_ast_vector(v)); Z3_CATCH_RETURN(0); } + + Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context target) { + Z3_TRY; + LOG_Z3_model_translate(c, m, target); + RESET_ERROR_CODE(); + Z3_model_ref* dst = alloc(Z3_model_ref, *mk_c(target)); + ast_translation tr(mk_c(c)->m(), mk_c(target)->m()); + dst->m_model = to_model_ref(m)->translate(tr); + mk_c(target)->save_object(dst); + RETURN_Z3(of_model(dst)); + Z3_CATCH_RETURN(0); + } Z3_bool Z3_API Z3_is_as_array(Z3_context c, Z3_ast a) { Z3_TRY; diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 8ff2be239..b1e667e9f 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -1809,9 +1809,11 @@ namespace z3 { Z3_model_inc_ref(ctx(), m); } public: + struct translate {}; model(context & c):object(c) { init(Z3_mk_model(c)); } model(context & c, Z3_model m):object(c) { init(m); } model(model const & s):object(s) { init(s.m_model); } + model(model& src, context& dst, translate) : object(dst) { init(Z3_model_translate(src.ctx(), src, dst)); } ~model() { Z3_model_dec_ref(ctx(), m_model); } operator Z3_model() const { return m_model; } model & operator=(model const & s) { diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 20c521df6..465e9aab8 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -5585,6 +5585,17 @@ class FuncInterp(Z3PPObject): raise IndexError return FuncEntry(Z3_func_interp_get_entry(self.ctx.ref(), self.f, idx), self.ctx) + def translate(self, other_ctx): + """Copy model 'self' to context 'other_ctx'. + """ + return ModelRef(Z3_model_translate(self.ctx.ref(), self.model, other_ctx.ref()), other_ctx) + + def __copy__(self): + return self.translate(self.ctx) + + def __deepcopy__(self): + return self.translate(self.ctx) + def as_list(self): """Return the function interpretation as a Python list. >>> f = Function('f', IntSort(), IntSort()) @@ -5614,9 +5625,6 @@ class ModelRef(Z3PPObject): self.ctx = ctx Z3_model_inc_ref(self.ctx.ref(), self.model) - def __deepcopy__(self, memo={}): - return ModelRef(self.m, self.ctx) - def __del__(self): if self.ctx.ref() is not None: Z3_model_dec_ref(self.ctx.ref(), self.model) @@ -5870,6 +5878,20 @@ class ModelRef(Z3PPObject): r.append(FuncDeclRef(Z3_model_get_func_decl(self.ctx.ref(), self.model, i), self.ctx)) return r + def translate(self, target): + """Translate `self` to the context `target`. That is, return a copy of `self` in the context `target`. + """ + if __debug__: + _z3_assert(isinstance(target, Context), "argument must be a Z3 context") + model = Z3_model_translate(self.ctx.ref(), self.model, target.ref()) + return Model(model, target) + + def __copy__(self): + return self.translate(self.ctx) + + def __deepcopy__(self): + return self.translate(self.ctx) + def is_as_array(n): """Return true if n is a Z3 expression of the form (_ as-array f).""" return isinstance(n, ExprRef) and Z3_is_as_array(n.ctx.ref(), n.as_ast()) @@ -6072,9 +6094,6 @@ class Solver(Z3PPObject): self.solver = solver Z3_solver_inc_ref(self.ctx.ref(), self.solver) - def __deepcopy__(self, memo={}): - return Solver(self.solver, self.ctx) - def __del__(self): if self.solver is not None and self.ctx.ref() is not None: Z3_solver_dec_ref(self.ctx.ref(), self.solver) diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 007bc3ab6..0ba49a5e5 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -4896,6 +4896,13 @@ extern "C" { */ Z3_ast_vector Z3_API Z3_model_get_sort_universe(Z3_context c, Z3_model m, Z3_sort s); + /** + \brief translate model from context c to context \c dst. + + def_API('Z3_model_translate', MODEL, (_in(CONTEXT), _in(MODEL), _in(CONTEXT))) + */ + Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context dst); + /** \brief The \ccode{(_ as-array f)} AST node is a construct for assigning interpretations for arrays in Z3. It is the array such that forall indices \c i we have that \ccode{(select (_ as-array f) i)} is equal to \ccode{(f i)}. diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 597348589..27ed95155 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -3218,9 +3218,10 @@ void theory_seq::add_indexof_axiom(expr* i) { literal t_eq_empty = mk_eq_empty(t); // |t| = 0 => |s| = 0 or indexof(t,s,offset) = -1 - // ~contains(t,s) => indexof(t,s,offset) = -1 + // ~contains(t,s) <=> indexof(t,s,offset) = -1 add_axiom(cnt, i_eq_m1); + add_axiom(~cnt, ~i_eq_m1); add_axiom(~t_eq_empty, s_eq_empty, i_eq_m1); if (!offset || (m_autil.is_numeral(offset, r) && r.is_zero())) { From c1c1b7378cffe3ac0781d4765fd1602c40531d33 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 1 Jan 2018 19:44:16 -0800 Subject: [PATCH 120/263] removing axiom exposing unsoundness, replace by weaker axiom Signed-off-by: Nikolaj Bjorner --- src/smt/theory_seq.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 27ed95155..f91685d43 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -3221,7 +3221,7 @@ void theory_seq::add_indexof_axiom(expr* i) { // ~contains(t,s) <=> indexof(t,s,offset) = -1 add_axiom(cnt, i_eq_m1); - add_axiom(~cnt, ~i_eq_m1); +// add_axiom(~cnt, ~i_eq_m1); add_axiom(~t_eq_empty, s_eq_empty, i_eq_m1); if (!offset || (m_autil.is_numeral(offset, r) && r.is_zero())) { @@ -3234,6 +3234,7 @@ void theory_seq::add_indexof_axiom(expr* i) { add_axiom(~s_eq_empty, i_eq_0); add_axiom(~cnt, s_eq_empty, mk_seq_eq(t, xsy)); add_axiom(~cnt, s_eq_empty, mk_eq(i, lenx, false)); + add_axiom(~cnt, mk_literal(m_autil.mk_ge(i, zero))); tightest_prefix(s, x); } else { From e8a9e1a58b3dac9155e93bd2b61ee89ba1275771 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 1 Jan 2018 20:04:55 -0800 Subject: [PATCH 121/263] set default rewriter behavior in incremental mode to distribute multiplication over addition #1373 Signed-off-by: Nikolaj Bjorner --- src/smt/asserted_formulas.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 56600266a..6ddce341d 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -131,6 +131,7 @@ void asserted_formulas::set_eliminate_and(bool flag) { p.set_bool("gcd_rounding", true); p.set_bool("expand_select_store", true); p.set_bool("bv_sort_ac", true); + p.set_bool("som", true); m_rewriter.updt_params(p); flush_cache(); } From 73b3da37d898c261892807197f72df48711383ab Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 2 Jan 2018 22:47:52 +0700 Subject: [PATCH 122/263] Typo fixes. --- README-CMake.md | 4 +- RELEASE_NOTES | 2 +- cmake/Z3Config.cmake.in | 2 +- contrib/suppressions/sanitizers/README.md | 2 +- examples/c/test_capi.c | 4 +- examples/dotnet/Program.cs | 2 +- examples/java/JavaExample.java | 2 +- examples/maxsat/README | 2 +- src/api/dotnet/Context.cs | 12 +++--- src/api/dotnet/Expr.cs | 14 +++---- src/api/dotnet/Model.cs | 2 +- src/api/java/Context.java | 6 +-- src/api/java/Expr.java | 10 ++--- src/api/java/Model.java | 2 +- src/api/ml/z3.mli | 26 ++++++------ src/api/python/z3/z3.py | 10 ++--- src/api/z3_api.h | 50 +++++++++++------------ src/ast/ast.h | 14 +++---- src/ast/proofs/proof_checker.cpp | 2 +- src/interp/iz3proof_itp.cpp | 8 ++-- src/interp/iz3translate_direct.cpp | 2 +- src/math/simplex/simplex_def.h | 2 +- src/muz/rel/dl_compiler.h | 2 +- src/muz/rel/dl_relation_manager.h | 2 +- src/nlsat/nlsat_solver.cpp | 8 ++-- src/qe/qe_lite.cpp | 2 +- src/smt/mam.cpp | 4 +- src/smt/smt_internalizer.cpp | 12 +++--- src/smt/smt_model_finder.cpp | 22 +++++----- src/smt/smt_quantifier.h | 2 +- src/smt/theory_arith.h | 2 +- src/tactic/arith/purify_arith_tactic.h | 2 +- src/tactic/ufbv/ufbv_rewriter.h | 2 +- 33 files changed, 120 insertions(+), 120 deletions(-) diff --git a/README-CMake.md b/README-CMake.md index 0d323e08f..1b1f72729 100644 --- a/README-CMake.md +++ b/README-CMake.md @@ -5,7 +5,7 @@ of the project written in the ``CMakeLists.txt`` files and emits a build system for that project of your choice using one of CMake's "generators". This allows CMake to support many different platforms and build tools. You can run ``cmake --help`` to see the list of supported "generators" -on your platform. Example generators include "UNIX Makfiles" and "Visual Studio +on your platform. Example generators include "UNIX Makefiles" and "Visual Studio 12 2013". ## Getting started @@ -44,7 +44,7 @@ cmake -G "Unix Makefiles" ../ make -j4 # Replace 4 with an appropriate number ``` -Note that on some platforms "Unix Makesfiles" is the default generator so on those +Note that on some platforms "Unix Makefiles" is the default generator so on those platforms you don't need to pass ``-G "Unix Makefiles"`` command line option to ``cmake``. diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 4f10cad26..5ce4d2682 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -712,7 +712,7 @@ The following bugs are fixed in this release: bvshl when using a shift amount that evaluates to the length of the bit-vector. Thanks to Trevor Hansen and Robert Brummayer. -- Incorrect NNF conversion in linear quantifier elimniation routines. +- Incorrect NNF conversion in linear quantifier elimination routines. Thanks to Josh Berdine. - Missing constant folding of extraction for large bit-vectors. diff --git a/cmake/Z3Config.cmake.in b/cmake/Z3Config.cmake.in index e7f604591..dbd63b103 100644 --- a/cmake/Z3Config.cmake.in +++ b/cmake/Z3Config.cmake.in @@ -2,7 +2,7 @@ # @AUTO_GEN_MSG@ # # This file is intended to be consumed by clients who wish to use Z3 from CMake. -# It can be use by doing `find_package(Z3 config)` from within a +# It can be used by doing `find_package(Z3 config)` from within a # `CMakeLists.txt` file. If CMake doesn't find this package automatically you # can give it a hint by passing `-DZ3_DIR=` to the CMake invocation where # `` is the path to the directory containing this file. diff --git a/contrib/suppressions/sanitizers/README.md b/contrib/suppressions/sanitizers/README.md index f76f920b2..1d7cd0ac8 100644 --- a/contrib/suppressions/sanitizers/README.md +++ b/contrib/suppressions/sanitizers/README.md @@ -1,4 +1,4 @@ -# Sanitizer supression files +# Sanitizer suppression files This directory contains files used to suppress ASan/LSan/UBSan warnings/errors. diff --git a/examples/c/test_capi.c b/examples/c/test_capi.c index d71771f98..b947928a7 100644 --- a/examples/c/test_capi.c +++ b/examples/c/test_capi.c @@ -1546,7 +1546,7 @@ void two_contexts_example1() } /** - \brief Demonstrates how error codes can be read insted of registering an error handler. + \brief Demonstrates how error codes can be read instead of registering an error handler. */ void error_code_example1() { @@ -2533,7 +2533,7 @@ void reference_counter_example() { cfg = Z3_mk_config(); Z3_set_param_value(cfg, "model", "true"); - // Create a Z3 context where the user is reponsible for managing + // Create a Z3 context where the user is responsible for managing // Z3_ast reference counters. ctx = Z3_mk_context_rc(cfg); Z3_del_config(cfg); diff --git a/examples/dotnet/Program.cs b/examples/dotnet/Program.cs index 71364013b..aec3bdcc5 100644 --- a/examples/dotnet/Program.cs +++ b/examples/dotnet/Program.cs @@ -622,7 +622,7 @@ namespace test_mapi Console.WriteLine("{0}", q1); } - // Quantifier with de-Brujin indices. + // Quantifier with de-Bruijn indices. { Expr x = ctx.MkBound(1, ctx.IntSort); Expr y = ctx.MkBound(0, ctx.IntSort); diff --git a/examples/java/JavaExample.java b/examples/java/JavaExample.java index 40fb25a92..7b8902768 100644 --- a/examples/java/JavaExample.java +++ b/examples/java/JavaExample.java @@ -660,7 +660,7 @@ class JavaExample System.out.println(q1); } - // Quantifier with de-Brujin indices. + // Quantifier with de-Bruijn indices. { Expr x = ctx.mkBound(1, ctx.getIntSort()); Expr y = ctx.mkBound(0, ctx.getIntSort()); diff --git a/examples/maxsat/README b/examples/maxsat/README index e5e4ba610..6c24da66b 100644 --- a/examples/maxsat/README +++ b/examples/maxsat/README @@ -9,4 +9,4 @@ On OSX and Linux, you must install z3 first using sudo make install OR update LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (OSX) with the build directory. You need that to be able to find the Z3 shared library. -This directory contains a test file (ex.smt) that can be use as input for the maxsat test application. +This directory contains a test file (ex.smt) that can be used as input for the maxsat test application. diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index ac23d1dbc..cbd6a1bac 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -2262,7 +2262,7 @@ namespace Microsoft.Z3 /// Maps f on the argument arrays. /// /// - /// Eeach element of args must be of an array sort [domain_i -> range_i]. + /// Each element of args must be of an array sort [domain_i -> range_i]. /// The function declaration f must have type range_1 .. range_n -> range. /// v must have sort range. The sort of the result is [domain_i -> range]. /// @@ -2862,7 +2862,7 @@ namespace Microsoft.Z3 } /// - /// Create a Term of a given sort. This function can be use to create numerals that fit in a machine integer. + /// Create a Term of a given sort. This function can be used to create numerals that fit in a machine integer. /// It is slightly faster than MakeNumeral since it is not necessary to parse a string. /// /// Value of the numeral @@ -2878,7 +2878,7 @@ namespace Microsoft.Z3 } /// - /// Create a Term of a given sort. This function can be use to create numerals that fit in a machine integer. + /// Create a Term of a given sort. This function can be used to create numerals that fit in a machine integer. /// It is slightly faster than MakeNumeral since it is not necessary to parse a string. /// /// Value of the numeral @@ -2894,7 +2894,7 @@ namespace Microsoft.Z3 } /// - /// Create a Term of a given sort. This function can be use to create numerals that fit in a machine integer. + /// Create a Term of a given sort. This function can be used to create numerals that fit in a machine integer. /// It is slightly faster than MakeNumeral since it is not necessary to parse a string. /// /// Value of the numeral @@ -2910,7 +2910,7 @@ namespace Microsoft.Z3 } /// - /// Create a Term of a given sort. This function can be use to create numerals that fit in a machine integer. + /// Create a Term of a given sort. This function can be used to create numerals that fit in a machine integer. /// It is slightly faster than MakeNumeral since it is not necessary to parse a string. /// /// Value of the numeral @@ -3211,7 +3211,7 @@ namespace Microsoft.Z3 /// Create an existential Quantifier. /// /// - /// Creates an existential quantifier using de-Brujin indexed variables. + /// Creates an existential quantifier using de-Bruijn indexed variables. /// (). /// public Quantifier MkExists(Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null) diff --git a/src/api/dotnet/Expr.cs b/src/api/dotnet/Expr.cs index 4fd306052..0726f9d53 100644 --- a/src/api/dotnet/Expr.cs +++ b/src/api/dotnet/Expr.cs @@ -959,7 +959,7 @@ namespace Microsoft.Z3 /// Tn: (R t_n s_n) /// [monotonicity T1 ... Tn]: (R (f t_1 ... t_n) (f s_1 ... s_n)) /// Remark: if t_i == s_i, then the antecedent Ti is suppressed. - /// That is, reflexivity proofs are supressed to save space. + /// That is, reflexivity proofs are suppressed to save space. /// public bool IsProofMonotonicity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; } } @@ -1002,7 +1002,7 @@ namespace Microsoft.Z3 public bool IsProofAndElimination { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_AND_ELIM; } } /// - /// Indicates whether the term is a proof by eliminiation of not-or + /// Indicates whether the term is a proof by elimination of not-or /// /// /// Given a proof for (not (or l_1 ... l_n)), produces a proof for (not l_i). @@ -1112,7 +1112,7 @@ namespace Microsoft.Z3 public bool IsProofQuantInst { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INST; } } /// - /// Indicates whether the term is a hypthesis marker. + /// Indicates whether the term is a hypothesis marker. /// /// Mark a hypothesis in a natural deduction style proof. public bool IsProofHypothesis { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS; } } @@ -1433,7 +1433,7 @@ namespace Microsoft.Z3 /// /// Filter (restrict) a relation with respect to a predicate. /// The first argument is a relation. - /// The second argument is a predicate with free de-Brujin indices + /// The second argument is a predicate with free de-Bruijn indices /// corresponding to the columns of the relation. /// So the first column in the relation has index 0. /// @@ -1649,7 +1649,7 @@ namespace Microsoft.Z3 public bool IsFPMul { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MUL; } } /// - /// Indicates whether the term is a floating-point divison term + /// Indicates whether the term is a floating-point division term /// public bool IsFPDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_DIV; } } @@ -1709,7 +1709,7 @@ namespace Microsoft.Z3 public bool IsFPLe { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_LE; } } /// - /// Indicates whether the term is a floating-point greater-than or erqual term + /// Indicates whether the term is a floating-point greater-than or equal term /// public bool IsFPGe { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_GE; } } @@ -1789,7 +1789,7 @@ namespace Microsoft.Z3 #region Bound Variables /// - /// The de-Burijn index of a bound variable. + /// The de-Bruijn index of a bound variable. /// /// /// Bound variables are indexed by de-Bruijn indices. It is perhaps easiest to explain diff --git a/src/api/dotnet/Model.cs b/src/api/dotnet/Model.cs index 12992fa8a..d11a57052 100644 --- a/src/api/dotnet/Model.cs +++ b/src/api/dotnet/Model.cs @@ -253,7 +253,7 @@ namespace Microsoft.Z3 /// The uninterpreted sorts that the model has an interpretation for. /// /// - /// Z3 also provides an intepretation for uninterpreted sorts used in a formula. + /// Z3 also provides an interpretation for uninterpreted sorts used in a formula. /// The interpretation for a sort is a finite set of distinct values. We say this finite set is /// the "universe" of the sort. /// diff --git a/src/api/java/Context.java b/src/api/java/Context.java index 3458f4d97..7e73fc15e 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -2234,7 +2234,7 @@ public class Context implements AutoCloseable { } /** - * Create a Term of a given sort. This function can be use to create + * Create a Term of a given sort. This function can be used to create * numerals that fit in a machine integer. It is slightly faster than * {@code MakeNumeral} since it is not necessary to parse a string. * @@ -2250,7 +2250,7 @@ public class Context implements AutoCloseable { } /** - * Create a Term of a given sort. This function can be use to create + * Create a Term of a given sort. This function can be used to create * numerals that fit in a machine integer. It is slightly faster than * {@code MakeNumeral} since it is not necessary to parse a string. * @@ -2438,7 +2438,7 @@ public class Context implements AutoCloseable { } /** - * Creates an existential quantifier using de-Brujin indexed variables. + * Creates an existential quantifier using de-Bruijn indexed variables. * @see #mkForall(Sort[],Symbol[],Expr,int,Pattern[],Expr[],Symbol,Symbol) **/ public Quantifier mkExists(Sort[] sorts, Symbol[] names, Expr body, diff --git a/src/api/java/Expr.java b/src/api/java/Expr.java index d3793a24b..7b20b7993 100644 --- a/src/api/java/Expr.java +++ b/src/api/java/Expr.java @@ -1421,7 +1421,7 @@ public class Expr extends AST * Remarks: T1: * (R t_1 s_1) ... Tn: (R t_n s_n) [monotonicity T1 ... Tn]: (R (f t_1 ... * t_n) (f s_1 ... s_n)) Remark: if t_i == s_i, then the antecedent Ti is - * suppressed. That is, reflexivity proofs are supressed to save space. + * suppressed. That is, reflexivity proofs are suppressed to save space. * * @throws Z3Exception on error * @return a boolean @@ -1473,7 +1473,7 @@ public class Expr extends AST } /** - * Indicates whether the term is a proof by eliminiation of not-or + * Indicates whether the term is a proof by elimination of not-or * Remarks: * Given a proof for (not (or l_1 ... l_n)), produces a proof for (not l_i). * T1: (not (or l_1 ... l_n)) [not-or-elim T1]: (not l_i) * @throws Z3Exception on error * @return a boolean @@ -1605,7 +1605,7 @@ public class Expr extends AST } /** - * Indicates whether the term is a hypthesis marker. + * Indicates whether the term is a hypothesis marker. * Remarks: Mark a * hypothesis in a natural deduction style proof. * @throws Z3Exception on error @@ -1987,7 +1987,7 @@ public class Expr extends AST * Indicates whether the term is a relation filter * Remarks: Filter * (restrict) a relation with respect to a predicate. The first argument is - * a relation. The second argument is a predicate with free de-Brujin + * a relation. The second argument is a predicate with free de-Bruijn * indices corresponding to the columns of the relation. So the first column * in the relation has index 0. * @throws Z3Exception on error @@ -2094,7 +2094,7 @@ public class Expr extends AST } /** - * The de-Burijn index of a bound variable. + * The de-Bruijn index of a bound variable. * Remarks: Bound variables are * indexed by de-Bruijn indices. It is perhaps easiest to explain the * meaning of de-Bruijn indices by indicating the compilation process from diff --git a/src/api/java/Model.java b/src/api/java/Model.java index 9c7013aca..d809b6790 100644 --- a/src/api/java/Model.java +++ b/src/api/java/Model.java @@ -239,7 +239,7 @@ public class Model extends Z3Object { /** * The uninterpreted sorts that the model has an interpretation for. - * Remarks: Z3 also provides an intepretation for uninterpreted sorts used + * Remarks: Z3 also provides an interpretation for uninterpreted sorts used * in a formula. The interpretation for a sort is a finite set of distinct * values. We say this finite set is the "universe" of the sort. * diff --git a/src/api/ml/z3.mli b/src/api/ml/z3.mli index 80923a0c7..20a1e9c10 100644 --- a/src/api/ml/z3.mli +++ b/src/api/ml/z3.mli @@ -536,7 +536,7 @@ sig @return A Term with the given value and sort *) val mk_numeral_string : context -> string -> Sort.sort -> expr - (** Create a numeral of a given sort. This function can be use to create numerals that fit in a machine integer. + (** Create a numeral of a given sort. This function can be used to create numerals that fit in a machine integer. It is slightly faster than [MakeNumeral] since it is not necessary to parse a string. @return A Term with the given value and sort *) val mk_numeral_int : context -> int -> Sort.sort -> expr @@ -667,7 +667,7 @@ sig end - (** The de-Burijn index of a bound variable. + (** The de-Bruijn index of a bound variable. Bound variables are indexed by de-Bruijn indices. It is perhaps easiest to explain the meaning of de-Bruijn indices by indicating the compilation process from @@ -830,7 +830,7 @@ sig (** Maps f on the argument arrays. - Eeach element of [args] must be of an array sort [[domain_i -> range_i]]. + Each element of [args] must be of an array sort [[domain_i -> range_i]]. The function declaration [f] must have type [ range_1 .. range_n -> range]. [v] must have sort range. The sort of the result is [[domain_i -> range]]. {!Z3Array.mk_sort} @@ -962,7 +962,7 @@ sig Filter (restrict) a relation with respect to a predicate. The first argument is a relation. - The second argument is a predicate with free de-Brujin indices + The second argument is a predicate with free de-Bruijn indices corresponding to the columns of the relation. So the first column in the relation has index 0. *) val is_filter : Expr.expr -> bool @@ -2085,7 +2085,7 @@ sig (** Indicates whether an expression is a floating-point lt expression *) val is_lt : Expr.expr -> bool - (** Indicates whether an expression is a floating-point geqexpression *) + (** Indicates whether an expression is a floating-point geq expression *) val is_geq : Expr.expr -> bool (** Indicates whether an expression is a floating-point gt expression *) @@ -2233,7 +2233,7 @@ sig (** Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort. *) val mk_to_fp_unsigned : context -> Expr.expr -> Expr.expr -> Sort.sort -> Expr.expr - (** C1onversion of a floating-point term into an unsigned bit-vector. *) + (** Conversion of a floating-point term into an unsigned bit-vector. *) val mk_to_ubv : context -> Expr.expr -> Expr.expr -> int -> Expr.expr (** Conversion of a floating-point term into a signed bit-vector. *) @@ -2385,7 +2385,7 @@ sig Tn: (R t_n s_n) [monotonicity T1 ... Tn]: (R (f t_1 ... t_n) (f s_1 ... s_n)) Remark: if t_i == s_i, then the antecedent Ti is suppressed. - That is, reflexivity proofs are supressed to save space. *) + That is, reflexivity proofs are suppressed to save space. *) val is_monotonicity : Expr.expr -> bool (** Indicates whether the term is a quant-intro proof @@ -2417,7 +2417,7 @@ sig [and-elim T1]: l_i *) val is_and_elimination : Expr.expr -> bool - (** Indicates whether the term is a proof by eliminiation of not-or + (** Indicates whether the term is a proof by elimination of not-or Given a proof for (not (or l_1 ... l_n)), produces a proof for (not l_i). T1: (not (or l_1 ... l_n)) @@ -2500,7 +2500,7 @@ sig A proof of (or (not (forall (x) (P x))) (P a)) *) val is_quant_inst : Expr.expr -> bool - (** Indicates whether the term is a hypthesis marker. + (** Indicates whether the term is a hypothesis marker. Mark a hypothesis in a natural deduction style proof. *) val is_hypothesis : Expr.expr -> bool @@ -2882,7 +2882,7 @@ sig (** The uninterpreted sorts that the model has an interpretation for. - Z3 also provides an intepretation for uninterpreted sorts used in a formula. + Z3 also provides an interpretation for uninterpreted sorts used in a formula. The interpretation for a sort is a finite set of distinct values. We say this finite set is the "universe" of the sort. {!get_num_sorts} @@ -3056,7 +3056,7 @@ sig (** Create a tactic that fails if the probe evaluates to false. *) val fail_if : context -> Probe.probe -> tactic - (** Create a tactic that fails if the goal is not triviall satisfiable (i.e., empty) + (** Create a tactic that fails if the goal is not trivially satisfiable (i.e., empty) or trivially unsatisfiable (i.e., contains `false'). *) val fail_if_not_decided : context -> tactic @@ -3105,7 +3105,7 @@ sig (** True if the entry is float-valued. *) val is_float : statistics_entry -> bool - (** The string representation of the the entry's value. *) + (** The string representation of the entry's value. *) val to_string_value : statistics_entry -> string (** The string representation of the entry (key and value) *) @@ -3370,7 +3370,7 @@ sig (** Assert a constraints into the optimize solver. *) val add : optimize -> Expr.expr list -> unit - (** Asssert a soft constraint. + (** Assert a soft constraint. Supply integer weight and string that identifies a group of soft constraints. *) val add_soft : optimize -> Expr.expr -> string -> Symbol.symbol -> handle diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 465e9aab8..4896a475d 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -182,7 +182,7 @@ class Context: """Interrupt a solver performing a satisfiability test, a tactic processing a goal, or simplify functions. This method can be invoked from a thread different from the one executing the - interruptable procedure. + interruptible procedure. """ Z3_interrupt(self.ref()) @@ -602,7 +602,7 @@ def _sort(ctx, a): return _to_sort_ref(Z3_get_sort(ctx.ref(), a), ctx) def DeclareSort(name, ctx=None): - """Create a new uninterpred sort named `name`. + """Create a new uninterpreted sort named `name`. If `ctx=None`, then the new sort is declared in the global Z3Py context. @@ -724,7 +724,7 @@ class FuncDeclRef(AstRef): The arguments must be Z3 expressions. This method assumes that the sorts of the elements in `args` match the sorts of the - domain. Limited coersion is supported. For example, if + domain. Limited coercion is supported. For example, if args[0] is a Python integer, and the function expects a Z3 integer, then the argument is automatically converted into a Z3 integer. @@ -9243,7 +9243,7 @@ def fpMul(rm, a, b, ctx=None): return _mk_fp_bin(Z3_mk_fpa_mul, rm, a, b, ctx) def fpDiv(rm, a, b, ctx=None): - """Create a Z3 floating-point divison expression. + """Create a Z3 floating-point division expression. >>> s = FPSort(8, 24) >>> rm = RNE() @@ -9270,7 +9270,7 @@ def fpRem(a, b, ctx=None): return _mk_fp_bin_norm(Z3_mk_fpa_rem, a, b, ctx) def fpMin(a, b, ctx=None): - """Create a Z3 floating-point minimium expression. + """Create a Z3 floating-point minimum expression. >>> s = FPSort(8, 24) >>> rm = RNE() diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 0ba49a5e5..5e5b84450 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -270,7 +270,7 @@ typedef enum - Z3_OP_ARRAY_MAP Array map operator. It satisfies map[f](a1,..,a_n)[i] = f(a1[i],...,a_n[i]) for every i. - - Z3_OP_SET_UNION Set union between two Booelan arrays (two arrays whose range type is Boolean). The function is binary. + - Z3_OP_SET_UNION Set union between two Boolean arrays (two arrays whose range type is Boolean). The function is binary. - Z3_OP_SET_INTERSECT Set intersection between two Boolean arrays. The function is binary. @@ -406,7 +406,7 @@ typedef enum - Z3_OP_BSMUL_NO_UDFL: check that bit-wise signed multiplication does not underflow. Signed multiplication underflows if the operands have opposite signs and the result of multiplication - does not fit within the avaialble bits. Z3_mk_bvmul_no_underflow. + does not fit within the available bits. Z3_mk_bvmul_no_underflow. - Z3_OP_BSDIV_I: Binary signed division. It has the same semantics as Z3_OP_BSDIV, but created in a context where the second operand can be assumed to be non-zero. @@ -485,7 +485,7 @@ typedef enum [monotonicity T1 ... Tn]: (R (f t_1 ... t_n) (f s_1 ... s_n)) } Remark: if t_i == s_i, then the antecedent Ti is suppressed. - That is, reflexivity proofs are supressed to save space. + That is, reflexivity proofs are suppressed to save space. - Z3_OP_PR_QUANT_INTRO: Given a proof for (~ p q), produces a proof for (~ (forall (x) p) (forall (x) q)). @@ -832,7 +832,7 @@ typedef enum - Z3_OP_RA_FILTER: Filter (restrict) a relation with respect to a predicate. The first argument is a relation. - The second argument is a predicate with free de-Brujin indices + The second argument is a predicate with free de-Bruijn indices corresponding to the columns of the relation. So the first column in the relation has index 0. @@ -969,7 +969,7 @@ typedef enum - Z3_OP_FPA_TO_FP: Floating-point conversion (various) - - Z3_OP_FPA_TO_FP_UNSIGNED: Floating-point conversion from unsigend bit-vector + - Z3_OP_FPA_TO_FP_UNSIGNED: Floating-point conversion from unsigned bit-vector - Z3_OP_FPA_TO_UBV: Floating-point conversion to unsigned bit-vector @@ -984,7 +984,7 @@ typedef enum of non-relevant terms in theory_fpa) - Z3_OP_FPA_BV2RM: Conversion of a 3-bit bit-vector term to a - floating-point rouding-mode term + floating-point rounding-mode term The conversion uses the following values: 0 = 000 = Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN, @@ -1922,7 +1922,7 @@ extern "C" { \param c logical context \param name name of the enumeration sort. - \param n number of elemenets in enumeration sort. + \param n number of elements in enumeration sort. \param enum_names names of the enumerated elements. \param enum_consts constants corresponding to the enumerated elements. \param enum_testers predicates testing if terms of the enumeration sort correspond to an enumeration. @@ -3186,7 +3186,7 @@ extern "C" { \param c logical context. \param num numerator of rational. - \param den denomerator of rational. + \param den denominator of rational. \pre den != 0 @@ -3201,7 +3201,7 @@ extern "C" { /** \brief Create a numeral of an int, bit-vector, or finite-domain sort. - This function can be use to create numerals that fit in a machine integer. + This function can be used to create numerals that fit in a machine integer. It is slightly faster than #Z3_mk_numeral since it is not necessary to parse a string. \sa Z3_mk_numeral @@ -3213,7 +3213,7 @@ extern "C" { /** \brief Create a numeral of a int, bit-vector, or finite-domain sort. - This function can be use to create numerals that fit in a machine unsinged integer. + This function can be used to create numerals that fit in a machine unsigned integer. It is slightly faster than #Z3_mk_numeral since it is not necessary to parse a string. \sa Z3_mk_numeral @@ -3225,7 +3225,7 @@ extern "C" { /** \brief Create a numeral of a int, bit-vector, or finite-domain sort. - This function can be use to create numerals that fit in a machine __int64 integer. + This function can be used to create numerals that fit in a machine __int64 integer. It is slightly faster than #Z3_mk_numeral since it is not necessary to parse a string. \sa Z3_mk_numeral @@ -3237,7 +3237,7 @@ extern "C" { /** \brief Create a numeral of a int, bit-vector, or finite-domain sort. - This function can be use to create numerals that fit in a machine __uint64 integer. + This function can be used to create numerals that fit in a machine __uint64 integer. It is slightly faster than #Z3_mk_numeral since it is not necessary to parse a string. \sa Z3_mk_numeral @@ -3493,8 +3493,8 @@ extern "C" { Z3_ast Z3_API Z3_mk_re_range(Z3_context c, Z3_ast lo, Z3_ast hi); /** - \brief Create a regular expression loop. The supplied regular expression \c r is repated - between \c lo and \c hi times. The \c lo should be below \c hi with one exection: when + \brief Create a regular expression loop. The supplied regular expression \c r is repeated + between \c lo and \c hi times. The \c lo should be below \c hi with one exception: when supplying the value \c hi as 0, the meaning is to repeat the argument \c r at least \c lo number of times, and with an unbounded upper bound. @@ -4248,7 +4248,7 @@ extern "C" { Z3_sort Z3_API Z3_get_decl_sort_parameter(Z3_context c, Z3_func_decl d, unsigned idx); /** - \brief Return the expresson value associated with an expression parameter. + \brief Return the expression value associated with an expression parameter. \pre Z3_get_decl_parameter_kind(c, d, idx) == Z3_PARAMETER_AST @@ -4257,7 +4257,7 @@ extern "C" { Z3_ast Z3_API Z3_get_decl_ast_parameter(Z3_context c, Z3_func_decl d, unsigned idx); /** - \brief Return the expresson value associated with an expression parameter. + \brief Return the expression value associated with an expression parameter. \pre Z3_get_decl_parameter_kind(c, d, idx) == Z3_PARAMETER_FUNC_DECL @@ -4327,7 +4327,7 @@ extern "C" { /** \brief Return a hash code for the given AST. - The hash code is structural. You can use Z3_get_ast_id interchangably with + The hash code is structural. You can use Z3_get_ast_id interchangeably with this function. def_API('Z3_get_ast_hash', UINT, (_in(CONTEXT), _in(AST))) @@ -4556,7 +4556,7 @@ extern "C" { Z3_ast Z3_API Z3_get_pattern(Z3_context c, Z3_pattern p, unsigned idx); /** - \brief Return index of de-Brujin bound variable. + \brief Return index of de-Bruijn bound variable. \pre Z3_get_ast_kind(a) == Z3_VAR_AST @@ -4659,7 +4659,7 @@ extern "C" { Provides an interface to the AST simplifier used by Z3. It returns an AST object which is equal to the argument. - The returned AST is simplified using algebraic simplificaiton rules, + The returned AST is simplified using algebraic simplification rules, such as constant propagation (propagating true/false over logical connectives). def_API('Z3_simplify', AST, (_in(CONTEXT), _in(AST))) @@ -4861,9 +4861,9 @@ extern "C" { Z3_func_decl Z3_API Z3_model_get_func_decl(Z3_context c, Z3_model m, unsigned i); /** - \brief Return the number of uninterpreted sorts that \c m assigs an interpretation to. + \brief Return the number of uninterpreted sorts that \c m assigns an interpretation to. - Z3 also provides an intepretation for uninterpreted sorts used in a formua. + Z3 also provides an interpretation for uninterpreted sorts used in a formula. The interpretation for a sort \c s is a finite set of distinct values. We say this finite set is the "universe" of \c s. @@ -4971,7 +4971,7 @@ extern "C" { unsigned Z3_API Z3_func_interp_get_num_entries(Z3_context c, Z3_func_interp f); /** - \brief Return a "point" of the given function intepretation. It represents the + \brief Return a "point" of the given function interpretation. It represents the value of \c f in a particular point. \pre i < Z3_func_interp_get_num_entries(c, f) @@ -5013,7 +5013,7 @@ extern "C" { \brief add a function entry to a function interpretation. \param c logical context - \param fi a function interpregation to be updated. + \param fi a function interpretation to be updated. \param args list of arguments. They should be constant values (such as integers) and be of the same types as the domain of the function. \param value value of the function when the parameters match args. @@ -5466,7 +5466,7 @@ extern "C" { Z3_bool Z3_API Z3_goal_is_decided_unsat(Z3_context c, Z3_goal g); /** - \brief Copy a goal \c g from the context \c source to a the context \c target. + \brief Copy a goal \c g from the context \c source to the context \c target. def_API('Z3_goal_translate', GOAL, (_in(CONTEXT), _in(GOAL), _in(CONTEXT))) */ @@ -5932,7 +5932,7 @@ extern "C" { Z3_solver Z3_API Z3_mk_solver_from_tactic(Z3_context c, Z3_tactic t); /** - \brief Copy a solver \c s from the context \c source to a the context \c target. + \brief Copy a solver \c s from the context \c source to the context \c target. def_API('Z3_solver_translate', SOLVER, (_in(CONTEXT), _in(SOLVER), _in(CONTEXT))) */ diff --git a/src/ast/ast.h b/src/ast/ast.h index 2d06d03de..24e2b93b6 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -330,7 +330,7 @@ std::ostream& operator<<(std::ostream& out, sort_size const & ss); // ----------------------------------- /** - \brief Extra information that may be attached to intepreted sorts. + \brief Extra information that may be attached to interpreted sorts. */ class sort_info : public decl_info { sort_size m_num_elements; @@ -932,7 +932,7 @@ struct builtin_name { }; /** - \brief Each family of intepreted function declarations and sorts must provide a plugin + \brief Each family of interpreted function declarations and sorts must provide a plugin to build sorts and decls of the family. */ class decl_plugin { @@ -1059,7 +1059,7 @@ protected: ptr_vector m_eq_decls; // cached eqs ptr_vector m_ite_decls; // cached ites - ptr_vector m_oeq_decls; // cached obsevational eqs + ptr_vector m_oeq_decls; // cached observational eqs sort * m_proof_sort; func_decl * m_undef_decl; func_decl * m_true_pr_decl; @@ -1161,7 +1161,7 @@ public: virtual expr * get_some_value(sort * s); }; -typedef app proof; /* a proof is just an applicaton */ +typedef app proof; /* a proof is just an application */ // ----------------------------------- // @@ -1220,7 +1220,7 @@ enum pattern_op_kind { /** \brief Patterns are used to group expressions. These expressions are using during E-matching for - heurisitic quantifier instantiation. + heuristic quantifier instantiation. */ class pattern_decl_plugin : public decl_plugin { public: @@ -1245,13 +1245,13 @@ enum model_value_op_kind { /** \brief Values are used during model construction. All values are assumed to be different. Users should not use them, since they may - introduce unsoundess if the sort of a value is finite. + introduce unsoundness if the sort of a value is finite. Moreover, values should never be internalized in a logical context. However, values can be used during evaluation (i.e., simplification). - \remark Model values can be viewed as the partion ids in Z3 1.x. + \remark Model values can be viewed as the partition ids in Z3 1.x. */ class model_value_decl_plugin : public decl_plugin { public: diff --git a/src/ast/proofs/proof_checker.cpp b/src/ast/proofs/proof_checker.cpp index 6fd876efc..5126198c6 100644 --- a/src/ast/proofs/proof_checker.cpp +++ b/src/ast/proofs/proof_checker.cpp @@ -502,7 +502,7 @@ bool proof_checker::check1_basic(proof* p, expr_ref_vector& side_conditions) { return false; } case PR_HYPOTHESIS: { - // TBD all branches with hyptheses must be closed by a later lemma. + // TBD all branches with hypotheses must be closed by a later lemma. if (match_proof(p) && match_fact(p, fml)) { return true; diff --git a/src/interp/iz3proof_itp.cpp b/src/interp/iz3proof_itp.cpp index fc9d0fac6..32cb9cccb 100755 --- a/src/interp/iz3proof_itp.cpp +++ b/src/interp/iz3proof_itp.cpp @@ -55,7 +55,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /* The summation rule. The term sum(p,c,i) takes a proof p of an inequality i', an integer coefficient c and an inequality i, and - yieds a proof of i' + ci. */ + yields a proof of i' + ci. */ symb sum; /* Proof rotation. The proof term rotate(q,p) takes a @@ -75,7 +75,7 @@ class iz3proof_itp_impl : public iz3proof_itp { symb leq2eq; /* Equality to inequality. eq2leq(p, q) takes a proof p of x=y, and - a proof q ~(x <= y) and and yields a proof of false. */ + a proof q ~(x <= y) and yields a proof of false. */ symb eq2leq; /* Proof term cong(p,q) takes a proof p of x=y and a proof @@ -97,7 +97,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /* This oprerator represents a concatenation of rewrites. The term a=b;c=d represents an A rewrite from a to b, followed by a B - rewrite fron b to c, followed by an A rewrite from c to d. + rewrite from b to c, followed by an A rewrite from c to d. */ symb concat; @@ -1542,7 +1542,7 @@ class iz3proof_itp_impl : public iz3proof_itp { return my_implies(arg(rew,1),arg(rew,2)); } - // make rewrite rew conditon on rewrite cond + // make rewrite rew condition on rewrite cond ast rewrite_conditional(const ast &cond, const ast &rew){ ast cf = rewrite_to_formula(cond); return make(sym(rew),arg(rew,0),my_and(arg(rew,1),cf),arg(rew,2)); diff --git a/src/interp/iz3translate_direct.cpp b/src/interp/iz3translate_direct.cpp index b88e488b4..e71475e45 100755 --- a/src/interp/iz3translate_direct.cpp +++ b/src/interp/iz3translate_direct.cpp @@ -9,7 +9,7 @@ Translate a Z3 proof into the interpolating proof calculus. Translation is direct, without transformations on the target proof - representaiton. + representation. Author: diff --git a/src/math/simplex/simplex_def.h b/src/math/simplex/simplex_def.h index 762e8ceb2..ceec60622 100644 --- a/src/math/simplex/simplex_def.h +++ b/src/math/simplex/simplex_def.h @@ -634,7 +634,7 @@ namespace simplex { // // max { c*x | A*x = 0 and l <= x <= u } // - // start with feasible assigment + // start with feasible assignment // A*x0 = 0 and l <= x0 <= u // // Identify pivot: i, j: such that x_i is base, diff --git a/src/muz/rel/dl_compiler.h b/src/muz/rel/dl_compiler.h index 9aedf141a..6ac33ae91 100644 --- a/src/muz/rel/dl_compiler.h +++ b/src/muz/rel/dl_compiler.h @@ -60,7 +60,7 @@ namespace datalog { ACK_UNBOUND_VAR(var_index) - encodes that the column contains a variable that is unbound (by the corresponding rule body), - var_index is the de-Brujin index (var->get_idx()) + var_index is the de-Bruijn index (var->get_idx()) of the variable associated with the column. ACK_CONSTANT(constant) - encodes that the column contains the constant. diff --git a/src/muz/rel/dl_relation_manager.h b/src/muz/rel/dl_relation_manager.h index c77127eb7..610c523e1 100644 --- a/src/muz/rel/dl_relation_manager.h +++ b/src/muz/rel/dl_relation_manager.h @@ -609,7 +609,7 @@ namespace datalog { std::string to_nice_string(const relation_element & el) const; /** This one may give a nicer representation of \c el than the - \c to_nice_string(const relation_element & el) function, by unsing the information about the sort + \c to_nice_string(const relation_element & el) function, by using the information about the sort of the element. */ std::string to_nice_string(const relation_sort & s, const relation_element & el) const; diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 448aa624d..12b063759 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -89,7 +89,7 @@ namespace nlsat { unsigned m_num_bool_vars; atom_vector m_atoms; // bool_var -> atom - svector m_bvalues; // boolean assigment + svector m_bvalues; // boolean assignment unsigned_vector m_levels; // bool_var -> level svector m_justifications; vector m_bwatches; // bool_var (that are not attached to atoms) -> clauses where it is maximal @@ -1051,7 +1051,7 @@ namespace nlsat { } /** - \brief Process a clause that contains nonlinar arithmetic literals + \brief Process a clause that contains nonlinear arithmetic literals If satisfy_learned is true, then learned clauses are satisfied even if m_lazy > 0 */ @@ -1569,7 +1569,7 @@ namespace nlsat { max = lvl; } else { - // l must be a literal from a previous stage that is false in the current intepretation + // l must be a literal from a previous stage that is false in the current interpretation SASSERT(assigned_value(l) == l_undef); SASSERT(max_var(b) != null_var); SASSERT(m_xk != null_var); @@ -1890,7 +1890,7 @@ namespace nlsat { // ----------------------- // - // Variable reodering + // Variable reordering // // ----------------------- diff --git a/src/qe/qe_lite.cpp b/src/qe/qe_lite.cpp index 01806bc24..3975945cb 100644 --- a/src/qe/qe_lite.cpp +++ b/src/qe/qe_lite.cpp @@ -974,7 +974,7 @@ namespace ar { // ------------------------------------------------------------ -// fm_tactic adapted to eliminate designated de-Brujin indices. +// fm_tactic adapted to eliminate designated de-Bruijn indices. namespace fm { typedef ptr_vector clauses; diff --git a/src/smt/mam.cpp b/src/smt/mam.cpp index 96334e3ce..c979e476e 100644 --- a/src/smt/mam.cpp +++ b/src/smt/mam.cpp @@ -188,7 +188,7 @@ namespace smt { 1) Variables: (f ... X ...) 2) Ground terms: (f ... t ...) 3) depth 2 joint: (f ... (g ... X ...) ...) - Joint2 stores the declartion g, and the position of variable X, and its idx. + Joint2 stores the declaration g, and the position of variable X, and its idx. \remark Z3 has no support for depth 3 joints (f ... (g ... (h ... X ...) ...) ....) */ @@ -211,7 +211,7 @@ namespace smt { approx_set m_lbl_set; // singleton set containing m_label /* The following field is an array of tagged pointers. - Each positon contains: + Each position contains: 1- null (no joint), NULL_TAG 2- a boxed integer (i.e., register that contains the variable bind) VAR_TAG 3- an enode pointer (ground term) GROUND_TERM_TAG diff --git a/src/smt/smt_internalizer.cpp b/src/smt/smt_internalizer.cpp index ffaee434f..c38ef4e4a 100644 --- a/src/smt/smt_internalizer.cpp +++ b/src/smt/smt_internalizer.cpp @@ -369,7 +369,7 @@ namespace smt { else { TRACE("internalize_bug", tout << "creating enode for #" << n->get_id() << "\n";); mk_enode(to_app(n), - true, /* supress arguments, we not not use CC for this kind of enode */ + true, /* suppress arguments, we not not use CC for this kind of enode */ true, /* bool enode must be merged with true/false, since it is not in the context of a gate */ false /* CC is not enabled */ ); set_enode_flag(v, false); @@ -453,7 +453,7 @@ namespace smt { // must be associated with an enode. if (!e_internalized(n)) { mk_enode(to_app(n), - true, /* supress arguments, we not not use CC for this kind of enode */ + true, /* suppress arguments, we not not use CC for this kind of enode */ true /* bool enode must be merged with true/false, since it is not in the context of a gate */, false /* CC is not enabled */); } @@ -739,7 +739,7 @@ namespace smt { app_ref eq1(mk_eq_atom(n, t), m_manager); app_ref eq2(mk_eq_atom(n, e), m_manager); mk_enode(n, - true /* supress arguments, I don't want to apply CC on ite terms */, + true /* suppress arguments, I don't want to apply CC on ite terms */, false /* it is a term, so it should not be merged with true/false */, false /* CC is not enabled */); internalize(c, true); @@ -797,7 +797,7 @@ namespace smt { } enode * e = mk_enode(n, - false, /* do not supress args */ + false, /* do not suppress args */ false, /* it is a term, so it should not be merged with true/false */ true); apply_sort_cnstr(n, e); @@ -1506,7 +1506,7 @@ namespace smt { relevancy_eh * eh = m_relevancy_propagator->mk_and_relevancy_eh(n); unsigned num = n->get_num_args(); for (unsigned i = 0; i < num; i++) { - // if one child is assigned to false, the the and-parent must be notified + // if one child is assigned to false, the and-parent must be notified literal l = get_literal(n->get_arg(i)); add_rel_watch(~l, eh); } @@ -1518,7 +1518,7 @@ namespace smt { relevancy_eh * eh = m_relevancy_propagator->mk_or_relevancy_eh(n); unsigned num = n->get_num_args(); for (unsigned i = 0; i < num; i++) { - // if one child is assigned to true, the the or-parent must be notified + // if one child is assigned to true, the or-parent must be notified literal l = get_literal(n->get_arg(i)); add_rel_watch(l, eh); } diff --git a/src/smt/smt_model_finder.cpp b/src/smt/smt_model_finder.cpp index 28a65f898..f443d671b 100644 --- a/src/smt/smt_model_finder.cpp +++ b/src/smt/smt_model_finder.cpp @@ -537,7 +537,7 @@ namespace smt { } } - // For each instantiation_set, reemove entries that do not evaluate to values. + // For each instantiation_set, remove entries that do not evaluate to values. void cleanup_instantiation_sets() { ptr_vector to_delete; for (node * curr : m_nodes) { @@ -735,7 +735,7 @@ namespace smt { } } // TBD: add support for the else of bitvectors. - // Idea: get the term t with the minimal interpreation and use t - 1. + // Idea: get the term t with the minimal interpretation and use t - 1. } n->set_else((*(elems.begin())).m_key); } @@ -955,7 +955,7 @@ namespace smt { if (elems.empty()) { // The method get_some_value cannot be used if n->get_sort() is an uninterpreted sort or is a sort built using uninterpreted sorts // (e.g., (Array S S) where S is uninterpreted). The problem is that these sorts do not have a fixed interpretation. - // Moreover, a model assigns an arbitrary intepretation to these sorts using "model_values" a model value. + // Moreover, a model assigns an arbitrary interpretation to these sorts using "model_values" a model value. // If these module values "leak" inside the logical context, they may affect satisfiability. // sort * ns = n->get_sort(); @@ -1007,7 +1007,7 @@ namespace smt { This may happen because the evaluator uses model_completion. In the beginning of fix_model() we collected all f with partial interpretations. During the process of computing the - projections we used the evalutator with model_completion, + projections we used the evaluator with model_completion, and it may have fixed the "else" case of some partial interpretations. This is ok, because in the "limit" the "else" of the interpretation is irrelevant after the projections are applied. @@ -1570,7 +1570,7 @@ namespace smt { ast_manager & m = ctx->get_manager(); sort * s = q->get_decl_sort(num_vars - m_var_i - 1); if (m.is_uninterp(s)) { - // For uninterpreted sorst, we add all terms in the context. + // For uninterpreted sorts, we add all terms in the context. // See Section 4.1 in the paper "Complete Quantifier Instantiation" node * S_q_i = slv.get_uvar(q, m_var_i); ptr_vector::const_iterator it = ctx->begin_enodes(); @@ -1741,7 +1741,7 @@ namespace smt { if (has_quantifiers(q->get_expr())) { static bool displayed_flat_msg = false; if (!displayed_flat_msg) { - // [Leo]: This warning message is not usefult. + // [Leo]: This warning message is not useful. // warning_msg("For problems containing quantifiers, the model finding capabilities of Z3 work better when the formula does not contain nested quantifiers. You can use PULL_NESTED_QUANTIFIERS=true to eliminate nested quantifiers."); displayed_flat_msg = true; } @@ -2104,7 +2104,7 @@ namespace smt { } /** - \brief Process unintrepreted applications. + \brief Process uninterpreted applications. */ void process_u_app(app * t) { unsigned num_args = t->get_num_args(); @@ -2130,7 +2130,7 @@ namespace smt { /** \brief A term \c t is said to be a auf_select if - it is of ther form + it is of the form (select a i) Where: @@ -2151,7 +2151,7 @@ namespace smt { } /** - \brief Process intrepreted applications. + \brief Process interpreted applications. */ void process_i_app(app * t) { if (is_auf_select(t)) { @@ -2512,7 +2512,7 @@ namespace smt { SASSERT(f_else != 0); // Remark: I can ignore the conditions of m because // I know the (partial) interpretation of f satisfied the ground part. - // MBQI will force extra instantiations if the the (partial) interpretation of f + // MBQI will force extra instantiations if the (partial) interpretation of f // does not satisfy the quantifier. // In all other cases the "else" of f will satisfy the quantifier. set_else_interp(f, f_else); @@ -2937,7 +2937,7 @@ namespace smt { } /** - \brief Use m_fs to set the interpreation of the function symbols that were used to satisfy the + \brief Use m_fs to set the interpretation of the function symbols that were used to satisfy the quantifiers in m_satisfied. */ void set_interp() { diff --git a/src/smt/smt_quantifier.h b/src/smt/smt_quantifier.h index d89f3f6a4..ad5f58e49 100644 --- a/src/smt/smt_quantifier.h +++ b/src/smt/smt_quantifier.h @@ -152,7 +152,7 @@ namespace smt { virtual bool mbqi_enabled(quantifier *q) const {return true;} /** - \brief Give a change to the plugin to adjust the interpretation of unintepreted functions. + \brief Give a change to the plugin to adjust the interpretation of uninterpreted functions. It can basically change the "else" of each uninterpreted function. */ virtual void adjust_model(proto_model * m) = 0; diff --git a/src/smt/theory_arith.h b/src/smt/theory_arith.h index 806b2a05b..6794ca3ac 100644 --- a/src/smt/theory_arith.h +++ b/src/smt/theory_arith.h @@ -660,7 +660,7 @@ namespace smt { satisfy their respective constraints. However, when they do that the may create inconsistencies in the other modules. I use m_liberal_final_check to avoid infinite - loops where the modules keep changing the assigment and no + loops where the modules keep changing the assignment and no progress is made. If m_liberal_final_check is set to false, these modules will avoid mutating the assignment to satisfy constraints. diff --git a/src/tactic/arith/purify_arith_tactic.h b/src/tactic/arith/purify_arith_tactic.h index bbb62710c..44b4f9b58 100644 --- a/src/tactic/arith/purify_arith_tactic.h +++ b/src/tactic/arith/purify_arith_tactic.h @@ -16,7 +16,7 @@ Abstract: Remarks: - The semantics of division by zero is not specified. Thus, uninterpreted functions are used. An ExRCF procedure may - treat the unintepreted function applications as fresh + treat the uninterpreted function applications as fresh constants. Then, in any model produced by this procedure, the interpretation for division by zero must be checked. diff --git a/src/tactic/ufbv/ufbv_rewriter.h b/src/tactic/ufbv/ufbv_rewriter.h index 1e13f4fa4..af9888751 100644 --- a/src/tactic/ufbv/ufbv_rewriter.h +++ b/src/tactic/ufbv/ufbv_rewriter.h @@ -74,7 +74,7 @@ each offset is a different "variable bank". A pair (expr, offset) is essentially where every variable in expr is assumed to be from the "bank" offset. The class substitution (in substitution.h) manages offsets for us. -The class matcher (in matcher.h) can be use to test whether an expression is an instance of another one. +The class matcher (in matcher.h) can be used to test whether an expression is an instance of another one. Finally, there is the problem when we have N demodulators (where N is big), and a big formula, and we want to traverse the formula only once looking for opportunities for applying these N demodulators. From a3ad0aff8b6750c25e730c3e6493736545fd841c Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 2 Jan 2018 22:50:50 +0700 Subject: [PATCH 123/263] print_stat_f: Remove implicit conversion of float to double. --- src/util/stats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/stats.h b/src/util/stats.h index 0acc18f43..680f9c9df 100644 --- a/src/util/stats.h +++ b/src/util/stats.h @@ -29,7 +29,7 @@ inline void print_stat(std::ostream& out, char const* msg, unsigned num) { } inline void print_stat_f(std::ostream& out, char const* msg, float num) { - if (num > 0.0) { + if (num > 0.0f) { out << msg << num << "\n"; } } From a875d3e491052bccb62ac490cbb554a97be4c129 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 2 Jan 2018 07:54:31 -0800 Subject: [PATCH 124/263] fix #1429 Signed-off-by: Nikolaj Bjorner --- src/api/ml/z3.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/ml/z3.ml b/src/api/ml/z3.ml index ce305bb4e..120b0ddfd 100644 --- a/src/api/ml/z3.ml +++ b/src/api/ml/z3.ml @@ -1994,7 +1994,7 @@ struct if csn <> cs || cdn <> cd then raise (Error "Argument size mismatch") else - Z3native.parse_smtlib2_string ctx file_name + Z3native.parse_smtlib2_file ctx file_name cs sort_names sorts cd decl_names decls end From a5a31fc23cd74463749da2911a71d60edcddcb19 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 2 Jan 2018 23:11:36 +0700 Subject: [PATCH 125/263] Fix code formatting: Incorrect indentation. --- src/util/container_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/container_util.h b/src/util/container_util.h index e114c87b9..e68ab7199 100644 --- a/src/util/container_util.h +++ b/src/util/container_util.h @@ -29,7 +29,7 @@ Revision History: // ----------------------------------- template - void set_intersection(Set1 & tgt, const Set2 & src) { +void set_intersection(Set1 & tgt, const Set2 & src) { svector to_remove; for (auto const& itm : tgt) if (!src.contains(itm)) From 11db7784425516f77d1a378cea2a3c5bb5589a63 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 2 Jan 2018 23:12:28 +0700 Subject: [PATCH 126/263] Remove ignored const qualifiers. The `const` qualifier on a scalar value is ignored in return types. --- src/util/lp/numeric_pair.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/lp/numeric_pair.h b/src/util/lp/numeric_pair.h index 4ebe63613..a8a743a71 100644 --- a/src/util/lp/numeric_pair.h +++ b/src/util/lp/numeric_pair.h @@ -38,10 +38,10 @@ template class numeric_traits {}; template <> class numeric_traits { public: static bool precise() { return true; } - static unsigned const zero() { return 0; } - static unsigned const one() { return 1; } + static unsigned zero() { return 0; } + static unsigned one() { return 1; } static bool is_zero(unsigned v) { return v == 0; } - static double const get_double(unsigned const & d) { return d; } + static double get_double(unsigned const & d) { return d; } }; template <> class numeric_traits { @@ -66,7 +66,7 @@ template <> class numeric_traits { static rational const & zero() { return rational::zero(); } static rational const & one() { return rational::one(); } static bool is_zero(const rational & v) { return v.is_zero(); } - static double const get_double(const rational & d) { return d.get_double();} + static double get_double(const rational & d) { return d.get_double();} static rational log(rational const& r) { UNREACHABLE(); return r; } static rational from_string(std::string const & str) { return rational(str.c_str()); } static bool is_pos(const rational & d) {return d.is_pos();} From 5a0f5a778fd6cdc383dd3594034b456b5911fb99 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 2 Jan 2018 23:14:29 +0700 Subject: [PATCH 127/263] Remove unnecessary copy of coeff in iteration. --- src/smt/theory_lra.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smt/theory_lra.cpp b/src/smt/theory_lra.cpp index 292d2ab0d..21b66d3a0 100644 --- a/src/smt/theory_lra.cpp +++ b/src/smt/theory_lra.cpp @@ -1916,7 +1916,7 @@ namespace smt { lp::var_index vi = m_theory_var2var_index[v]; SASSERT(m_solver->is_term(vi)); lp::lar_term const& term = m_solver->get_term(vi); - for (auto const coeff : term.m_coeffs) { + for (auto const& coeff : term.m_coeffs) { lp::var_index wi = coeff.first; lp::constraint_index ci; rational value; From b06f4135852cce8649fa1da92a9a53a8c7994782 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 2 Jan 2018 23:20:00 +0700 Subject: [PATCH 128/263] raise_exception: Annotate that this doesn't return. --- src/ast/ast.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ast/ast.h b/src/ast/ast.h index 24e2b93b6..ea97af004 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -53,6 +53,12 @@ Revision History: #pragma warning(disable : 4355) #endif +#ifdef __GNUC__ +# define Z3_NORETURN __attribute__((noreturn)) +#else +# define Z3_NORETURN +#endif + class ast; class ast_manager; @@ -1515,7 +1521,7 @@ public: void compress_ids(); // Equivalent to throw ast_exception(msg) - void raise_exception(char const * msg); + void raise_exception(char const * msg) Z3_NORETURN; bool is_format_manager() const { return m_format_manager == 0; } From 7457fa77cb44f9cfdfb4fc552581e10c41ee69b6 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 2 Jan 2018 08:46:17 -0800 Subject: [PATCH 129/263] add noreturn attribute #1435 Signed-off-by: Nikolaj Bjorner --- src/ast/ast.cpp | 41 ++++++++++++++--------------------------- src/ast/ast.h | 8 +------- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 3824325b3..0f18170df 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1492,11 +1492,8 @@ void ast_manager::compact_memory() { unsigned capacity = m_ast_table.capacity(); if (capacity > 4*m_ast_table.size()) { ast_table new_ast_table; - ast_table::iterator it = m_ast_table.begin(); - ast_table::iterator end = m_ast_table.end(); - for (; it != end; ++it) { - new_ast_table.insert(*it); - } + for (ast* curr : m_ast_table) + new_ast_table.insert(curr); m_ast_table.swap(new_ast_table); IF_VERBOSE(10, verbose_stream() << "(ast-table :prev-capacity " << capacity << " :capacity " << m_ast_table.capacity() << " :size " << m_ast_table.size() << ")\n";); @@ -1510,10 +1507,7 @@ void ast_manager::compress_ids() { ptr_vector asts; m_expr_id_gen.cleanup(); m_decl_id_gen.cleanup(c_first_decl_id); - ast_table::iterator it = m_ast_table.begin(); - ast_table::iterator end = m_ast_table.end(); - for (; it != end; ++it) { - ast * n = *it; + for (ast * n : m_ast_table) { if (is_decl(n)) n->m_id = m_decl_id_gen.mk(); else @@ -1521,13 +1515,11 @@ void ast_manager::compress_ids() { asts.push_back(n); } m_ast_table.finalize(); - ptr_vector::iterator it2 = asts.begin(); - ptr_vector::iterator end2 = asts.end(); - for (; it2 != end2; ++it2) - m_ast_table.insert(*it2); + for (ast* a : asts) + m_ast_table.insert(a); } -void ast_manager::raise_exception(char const * msg) { +[[noreturn]] void ast_manager::raise_exception(char const * msg) { throw ast_exception(msg); } @@ -1570,20 +1562,15 @@ void ast_manager::copy_families_plugins(ast_manager const & from) { } void ast_manager::set_next_expr_id(unsigned id) { - while (true) { - id = m_expr_id_gen.set_next_id(id); - ast_table::iterator it = m_ast_table.begin(); - ast_table::iterator end = m_ast_table.end(); - for (; it != end; ++it) { - ast * curr = *it; - if (curr->get_id() == id) - break; + try_again: + id = m_expr_id_gen.set_next_id(id); + for (ast * curr : m_ast_table) { + if (curr->get_id() == id) { + // id is in use, move to the next one. + ++id; + goto try_again; } - if (it == end) - return; - // id is in use, move to the next one. - id++; - } + } } unsigned ast_manager::get_node_size(ast const * n) { return ::get_node_size(n); } diff --git a/src/ast/ast.h b/src/ast/ast.h index ea97af004..482ec3a99 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -53,12 +53,6 @@ Revision History: #pragma warning(disable : 4355) #endif -#ifdef __GNUC__ -# define Z3_NORETURN __attribute__((noreturn)) -#else -# define Z3_NORETURN -#endif - class ast; class ast_manager; @@ -1521,7 +1515,7 @@ public: void compress_ids(); // Equivalent to throw ast_exception(msg) - void raise_exception(char const * msg) Z3_NORETURN; + [[noreturn]] void raise_exception(char const * msg); bool is_format_manager() const { return m_format_manager == 0; } From 16044c74bfcd64384065fa38b514882a52a013c7 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 2 Jan 2018 09:29:14 -0800 Subject: [PATCH 130/263] revert use of [[noreturn]]. It's not fully supported on compilers #1435 Signed-off-by: Nikolaj Bjorner --- src/ast/ast.cpp | 2 +- src/ast/ast.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 0f18170df..cc4beb1b6 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1519,7 +1519,7 @@ void ast_manager::compress_ids() { m_ast_table.insert(a); } -[[noreturn]] void ast_manager::raise_exception(char const * msg) { +void ast_manager::raise_exception(char const * msg) { throw ast_exception(msg); } diff --git a/src/ast/ast.h b/src/ast/ast.h index 482ec3a99..ea97af004 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -53,6 +53,12 @@ Revision History: #pragma warning(disable : 4355) #endif +#ifdef __GNUC__ +# define Z3_NORETURN __attribute__((noreturn)) +#else +# define Z3_NORETURN +#endif + class ast; class ast_manager; @@ -1515,7 +1521,7 @@ public: void compress_ids(); // Equivalent to throw ast_exception(msg) - [[noreturn]] void raise_exception(char const * msg); + void raise_exception(char const * msg) Z3_NORETURN; bool is_format_manager() const { return m_format_manager == 0; } From 11f5fdccdf1f3e7b72a052be73203760d75472b4 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 3 Jan 2018 01:02:07 +0700 Subject: [PATCH 131/263] Use noreturn attribute and __declspec version. --- src/ast/ast.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ast/ast.h b/src/ast/ast.h index ea97af004..7a662a193 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -53,10 +53,10 @@ Revision History: #pragma warning(disable : 4355) #endif -#ifdef __GNUC__ -# define Z3_NORETURN __attribute__((noreturn)) +#ifdef _MSC_VER +# define Z3_NORETURN __declspec(noreturn) #else -# define Z3_NORETURN +# define Z3_NORETURN [[noreturn]] #endif class ast; @@ -1521,7 +1521,7 @@ public: void compress_ids(); // Equivalent to throw ast_exception(msg) - void raise_exception(char const * msg) Z3_NORETURN; + Z3_NORETURN void raise_exception(char const * msg); bool is_format_manager() const { return m_format_manager == 0; } From e9be339d9df0d7d16d31e58aeb1ff81b9215a563 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 3 Jan 2018 12:42:43 +0000 Subject: [PATCH 132/263] [CMake] Fix #1437. The `clock_gettime()` function in glibc < 2.17 required linking against librt. Until #1437 nobody had tried using the CMake build system with a really old version of glibc (in this case 2.12). The python build system always linked against librt but the CMake build system never tried to link against it leading to link failures. This patch teaches the CMake build system to detect if librt is required when linking against `clock_gettime()` and adds `rt` as a link dependency if necessary. --- CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0be2de537..69a0ca123 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,6 +257,46 @@ list(APPEND Z3_COMPONENT_EXTRA_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/src" "${CMAKE_SOURCE_DIR}/src" ) + +################################################################################ +# Linux specific configuration +################################################################################ +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + # Try to detect if it is necessary to link against librt. + # Note that glibc < 2.17 required librt to be linked to use clock_gettime() + # and friends. + set(CLOCK_GETTIME_REQUIRES_LIBRT_TEST_CODE + " + #include + int main() { + timespec res; + int result = clock_gettime(CLOCK_REALTIME, &res); + return result == 0; + } + " + ) + check_cxx_source_compiles( + "${CLOCK_GETTIME_REQUIRES_LIBRT_TEST_CODE}" + CLOCK_GETTIME_NO_REQUIRE_LIBRT + ) + if (NOT CLOCK_GETTIME_NO_REQUIRE_LIBRT) + # Try again with librt + message(STATUS "Failed to link against clock_gettime(), trying with librt") + set(CMAKE_REQUIRED_LIBRARIES_OLD "${CMAKE_REQUIRED_LIBRARIES}") + set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} rt") + check_cxx_source_compiles( + "${CLOCK_GETTIME_REQUIRES_LIBRT_TEST_CODE}" + CLOCK_GETTIME_REQUIRES_LIBRT + ) + set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_OLD}") + if (CLOCK_GETTIME_REQUIRES_LIBRT) + list(APPEND Z3_DEPENDENT_LIBS "rt") + else() + message(FATAL_ERROR "Failed to link against clock_gettime()") + endif() + endif() +endif() + ################################################################################ # GNU multiple precision library support ################################################################################ From a5180edc760a49ce05ddef98e69af510fc19f6b5 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Wed, 3 Jan 2018 16:05:34 -0500 Subject: [PATCH 133/263] make linear search the default for theory_str --- src/smt/params/smt_params_helper.pyg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smt/params/smt_params_helper.pyg b/src/smt/params/smt_params_helper.pyg index 937aa6a2b..d6ca8c9b2 100644 --- a/src/smt/params/smt_params_helper.pyg +++ b/src/smt/params/smt_params_helper.pyg @@ -74,7 +74,7 @@ def_module_params(module_name='smt', ('str.fast_length_tester_cache', BOOL, False, 'cache length tester constants instead of regenerating them'), ('str.fast_value_tester_cache', BOOL, True, 'cache value tester constants instead of regenerating them'), ('str.string_constant_cache', BOOL, True, 'cache all generated string constants generated from anywhere in theory_str'), - ('str.use_binary_search', BOOL, True, 'use a binary search heuristic for finding concrete length values for free variables in theory_str (set to False to use linear search)'), + ('str.use_binary_search', BOOL, False, 'use a binary search heuristic for finding concrete length values for free variables in theory_str (set to False to use linear search)'), ('str.binary_search_start', UINT, 64, 'initial upper bound for theory_str binary search'), ('theory_aware_branching', BOOL, False, 'Allow the context to use extra information from theory solvers regarding literal branching prioritization.'), ('str.finite_overlap_models', BOOL, False, 'attempt a finite model search for overlapping variables instead of completely giving up on the arrangement'), From 482738bc8a08e7abd0abaa7030261aa5255a984d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 7 Jan 2018 15:51:45 -0800 Subject: [PATCH 134/263] avoid reset_error in dec_ref in bv_val #1443. Add BSD required template instance #1444 Signed-off-by: Nikolaj Bjorner --- src/api/api_context.cpp | 6 ++++++ src/api/api_context.h | 2 +- src/api/api_numeral.cpp | 4 ++-- src/api/c++/z3++.h | 10 +++++----- src/util/lp/lp_solver_instances.cpp | 1 + 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 23ac62a66..8299c136c 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -152,6 +152,12 @@ namespace api { } } + void context::reset_error_code() { + m_error_code = Z3_OK; + } + + + void context::check_searching() { if (m_searching) { set_error_code(Z3_INVALID_USAGE); // TBD: error code could be fixed. diff --git a/src/api/api_context.h b/src/api/api_context.h index 58893d1c1..a2321d7fe 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -138,7 +138,7 @@ namespace api { datatype_decl_plugin * get_dt_plugin() const { return m_dt_plugin; } Z3_error_code get_error_code() const { return m_error_code; } - void reset_error_code() { m_error_code = Z3_OK; } + void reset_error_code(); void set_error_code(Z3_error_code err); void set_error_handler(Z3_error_handler h) { m_error_handler = h; } // Sign an error if solver is searching diff --git a/src/api/api_numeral.cpp b/src/api/api_numeral.cpp index 9a778d6e0..1cee7469c 100644 --- a/src/api/api_numeral.cpp +++ b/src/api/api_numeral.cpp @@ -73,7 +73,7 @@ extern "C" { ('P' == *m) || ('+' == *m))))) { SET_ERROR_CODE(Z3_PARSER_ERROR); - return 0; + RETURN_Z3(0); } ++m; } @@ -235,7 +235,7 @@ extern "C" { expr* e = to_expr(a); if (!e) { SET_ERROR_CODE(Z3_INVALID_ARG); - return ""; + RETURN_Z3(""); } rational r; arith_util & u = mk_c(c)->autil(); diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index b1e667e9f..808382561 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -2524,11 +2524,11 @@ namespace z3 { inline expr context::real_val(__uint64 n) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } inline expr context::real_val(char const * n) { Z3_ast r = Z3_mk_numeral(m_ctx, n, real_sort()); check_error(); return expr(*this, r); } - inline expr context::bv_val(int n, unsigned sz) { Z3_ast r = Z3_mk_int(m_ctx, n, bv_sort(sz)); check_error(); return expr(*this, r); } - inline expr context::bv_val(unsigned n, unsigned sz) { Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, bv_sort(sz)); check_error(); return expr(*this, r); } - inline expr context::bv_val(__int64 n, unsigned sz) { Z3_ast r = Z3_mk_int64(m_ctx, n, bv_sort(sz)); check_error(); return expr(*this, r); } - inline expr context::bv_val(__uint64 n, unsigned sz) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, bv_sort(sz)); check_error(); return expr(*this, r); } - inline expr context::bv_val(char const * n, unsigned sz) { Z3_ast r = Z3_mk_numeral(m_ctx, n, bv_sort(sz)); check_error(); return expr(*this, r); } + inline expr context::bv_val(int n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int(m_ctx, n, s); check_error(); return expr(*this, r); } + inline expr context::bv_val(unsigned n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, s); check_error(); return expr(*this, r); } + inline expr context::bv_val(__int64 n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_int64(m_ctx, n, s); check_error(); return expr(*this, r); } + inline expr context::bv_val(__uint64 n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, s); check_error(); return expr(*this, r); } + inline expr context::bv_val(char const * n, unsigned sz) { sort s = bv_sort(sz); Z3_ast r = Z3_mk_numeral(m_ctx, n, s); check_error(); return expr(*this, r); } inline expr context::bv_val(unsigned n, bool const* bits) { array _bits(n); for (unsigned i = 0; i < n; ++i) _bits[i] = bits[i] ? 1 : 0; diff --git a/src/util/lp/lp_solver_instances.cpp b/src/util/lp/lp_solver_instances.cpp index 4fe04c05f..599a0a8bc 100644 --- a/src/util/lp/lp_solver_instances.cpp +++ b/src/util/lp/lp_solver_instances.cpp @@ -34,6 +34,7 @@ template void lp::lp_solver::print_statistics_on_A(std::ostream template bool lp::lp_solver::problem_is_empty(); template void lp::lp_solver::scale(); template void lp::lp_solver::set_scaled_cost(unsigned int); +template std::string lp::lp_solver::get_column_name(unsigned int) const; template lp::lp_solver::~lp_solver(); template void lp::lp_solver::add_constraint(lp::lp_relation, lp::mpq, unsigned int); template void lp::lp_solver::cleanup(); From e7851a063761785c25c4285c502313a4844bc1f2 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 7 Jan 2018 18:32:31 -0800 Subject: [PATCH 135/263] fix build Signed-off-by: Nikolaj Bjorner --- src/api/api_numeral.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/api_numeral.cpp b/src/api/api_numeral.cpp index 1cee7469c..d3dabcd4e 100644 --- a/src/api/api_numeral.cpp +++ b/src/api/api_numeral.cpp @@ -235,7 +235,7 @@ extern "C" { expr* e = to_expr(a); if (!e) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(""); + return ""; } rational r; arith_util & u = mk_c(c)->autil(); From 1992749e785762338f83f03fc38717757daab98e Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 7 Jan 2018 18:52:00 -0800 Subject: [PATCH 136/263] to ascii or not to ascii #1447 Signed-off-by: Nikolaj Bjorner --- scripts/update_api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/update_api.py b/scripts/update_api.py index 45ea9be23..18878d6ea 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -1696,7 +1696,11 @@ if _lib is None: def _to_ascii(s): if isinstance(s, str): - return s.encode('ascii') + try: + return s.encode('ascii') + except: + # kick the bucket down the road. :-J + return s else: return s From cfdde2f4d1d1286d2bfcaad7bf5c7be202b024ad Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Mon, 8 Jan 2018 13:24:52 +0000 Subject: [PATCH 137/263] Added apply_result::as_expr to the C++ API. Requested here: https://stackoverflow.com/questions/48071840/get-result-of-tactics-application-as-an-expression-in-z3 --- src/api/c++/z3++.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 808382561..89b051eb5 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -2101,6 +2101,19 @@ namespace z3 { check_error(); return model(ctx(), new_m); } + expr as_expr() const { + unsigned n = size(); + if (n == 0) + return ctx().bool_val(true); + else if (n == 1) + return operator[](0).as_expr(); + else { + array args(n); + for (unsigned i = 0; i < n; i++) + args[i] = operator[](i).as_expr(); + return expr(ctx(), Z3_mk_or(ctx(), n, args.ptr())); + } + } friend std::ostream & operator<<(std::ostream & out, apply_result const & r); }; inline std::ostream & operator<<(std::ostream & out, apply_result const & r) { out << Z3_apply_result_to_string(r.ctx(), r); return out; } From 5159291d573e18d582c813bc10a59f6c6327c1e3 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 12 Jan 2018 19:29:42 -0800 Subject: [PATCH 138/263] add missing interpreted tail during bottom-up simplification #1452 Signed-off-by: Nikolaj Bjorner --- src/muz/transforms/dl_mk_coi_filter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/muz/transforms/dl_mk_coi_filter.cpp b/src/muz/transforms/dl_mk_coi_filter.cpp index 3ea0e305a..2ca64aa68 100644 --- a/src/muz/transforms/dl_mk_coi_filter.cpp +++ b/src/muz/transforms/dl_mk_coi_filter.cpp @@ -79,6 +79,10 @@ namespace datalog { } if (contained) { if (new_tail) { + for (unsigned i = r->get_uninterpreted_tail_size(); i < r->get_tail_size(); ++i) { + m_new_tail.push_back(r->get_tail(i)); + m_new_tail_neg.push_back(false); + } rule* new_r = m_context.get_rule_manager().mk(r->get_head(), m_new_tail.size(), m_new_tail.c_ptr(), m_new_tail_neg.c_ptr(), symbol::null, false); res->add_rule(new_r); From b5335bc34be690c722e94192d4471c3894ab67da Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 13 Jan 2018 20:08:23 -0800 Subject: [PATCH 139/263] change behavior of single-objective pareto to use Pareto GIA algorithm (so not a good idea with MaxSAT solving, but then uniform behavior #1439 Signed-off-by: Nikolaj Bjorner --- src/opt/opt_context.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index 0daf98320..f5f3f06fd 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -287,27 +287,24 @@ namespace opt { TRACE("opt", model_smt2_pp(tout, m, *m_model, 0);); m_optsmt.setup(*m_opt_solver.get()); update_lower(); + + opt_params optp(m_params); + symbol pri = optp.priority(); - switch (m_objectives.size()) { - case 0: - break; - case 1: - is_sat = execute(m_objectives[0], true, false); - break; - default: { - opt_params optp(m_params); - symbol pri = optp.priority(); - if (pri == symbol("pareto")) { - is_sat = execute_pareto(); - } - else if (pri == symbol("box")) { - is_sat = execute_box(); - } - else { - is_sat = execute_lex(); - } - break; + if (0 == m_objectives.size()) { + // no op } + else if (pri == symbol("pareto")) { + is_sat = execute_pareto(); + } + else if (1 == m_objectives.size()) { + is_sat = execute(m_objectives[0], true, false); + } + else if (pri == symbol("box")) { + is_sat = execute_box(); + } + else { + is_sat = execute_lex(); } return adjust_unknown(is_sat); } From 57406d6cc4f6f4c5ee6725e5e1f4a0188105ffe2 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 17 Jan 2018 18:11:14 -0800 Subject: [PATCH 140/263] more updates for #1439 Signed-off-by: Nikolaj Bjorner --- src/opt/opt_context.cpp | 17 +++++++++++++---- src/opt/opt_context.h | 3 ++- src/sat/sat_model_converter.cpp | 4 +--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index f5f3f06fd..4ccf30563 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -122,6 +122,7 @@ namespace opt { m_bv(m), m_hard_constraints(m), m_solver(0), + m_pareto1(false), m_box_index(UINT_MAX), m_optsmt(m), m_scoped_state(m), @@ -294,12 +295,19 @@ namespace opt { if (0 == m_objectives.size()) { // no op } + else if (1 == m_objectives.size()) { + if (m_pareto1) { + is_sat = l_false; + m_pareto1 = false; + } + else { + m_pareto1 = (pri == symbol("pareto")); + is_sat = execute(m_objectives[0], true, false); + } + } else if (pri == symbol("pareto")) { is_sat = execute_pareto(); } - else if (1 == m_objectives.size()) { - is_sat = execute(m_objectives[0], true, false); - } else if (pri == symbol("box")) { is_sat = execute_box(); } @@ -1358,13 +1366,14 @@ namespace opt { } void context::clear_state() { - set_pareto(0); + set_pareto(0); m_box_index = UINT_MAX; m_model.reset(); } void context::set_pareto(pareto_base* p) { m_pareto = p; + m_pareto1 = p != nullptr; } void context::collect_statistics(statistics& stats) const { diff --git a/src/opt/opt_context.h b/src/opt/opt_context.h index 1ae60ef87..513f2dd85 100644 --- a/src/opt/opt_context.h +++ b/src/opt/opt_context.h @@ -144,7 +144,8 @@ namespace opt { ref m_opt_solver; ref m_solver; ref m_sat_solver; - scoped_ptr m_pareto; + scoped_ptr m_pareto; + bool m_pareto1; scoped_ptr m_qmax; sref_vector m_box_models; unsigned m_box_index; diff --git a/src/sat/sat_model_converter.cpp b/src/sat/sat_model_converter.cpp index 1a881618a..1a3b4104f 100644 --- a/src/sat/sat_model_converter.cpp +++ b/src/sat/sat_model_converter.cpp @@ -74,9 +74,7 @@ namespace sat { DEBUG_CODE({ // all clauses must be satisfied bool sat = false; - it2 = it->m_clauses.begin(); - for (; it2 != end2; ++it2) { - literal l = *it2; + for (literal l : m_clauses) { if (l == null_literal) { SASSERT(sat); sat = false; From 305212c021a0b43961076f182c05a3f3075aa77a Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Thu, 25 Jan 2018 15:18:05 +0000 Subject: [PATCH 141/263] Added rewrite cycle detection in demodulator/ufbv_rewriter. Partial fix for #1456. --- src/tactic/ufbv/ufbv_rewriter.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/tactic/ufbv/ufbv_rewriter.cpp b/src/tactic/ufbv/ufbv_rewriter.cpp index 446d1a49c..573873c89 100644 --- a/src/tactic/ufbv/ufbv_rewriter.cpp +++ b/src/tactic/ufbv/ufbv_rewriter.cpp @@ -322,8 +322,27 @@ bool ufbv_rewriter::rewrite_visit_children(app * a) { while (j > 0) { expr * e = a->get_arg(--j); if (!m_rewrite_cache.contains(e) || !m_rewrite_cache.get(e).second) { - m_rewrite_todo.push_back(e); - res = false; + bool recursive = false; + unsigned sz = m_rewrite_todo.size(); + expr * v = e; + if (m_rewrite_cache.contains(e)) { + expr_bool_pair const & ebp = m_rewrite_cache.get(e); + if (ebp.second) + v = ebp.first; + } + for (unsigned i = sz; i > 0; i--) { + if (m_rewrite_todo[i - 1] == v) { + recursive = true; + TRACE("demodulator", tout << "Detected demodulator cycle: " << + mk_pp(a, m_manager) << " --> " << mk_pp(v, m_manager) << std::endl;); + m_rewrite_cache.insert(e, expr_bool_pair(v, true)); + break; + } + } + if (!recursive) { + m_rewrite_todo.push_back(e); + res = false; + } } } return res; @@ -347,7 +366,8 @@ expr * ufbv_rewriter::rewrite(expr * n) { while (!m_rewrite_todo.empty()) { TRACE("demodulator_stack", tout << "STACK: " << std::endl; for ( unsigned i = 0; i& new_soft) { @@ -391,6 +391,10 @@ namespace opt { return m_c.get_solver(); } + void maxsmt::model_updated(model* mdl) { + m_c.model_updated(mdl); + } + }; diff --git a/src/opt/maxsmt.h b/src/opt/maxsmt.h index 0541a9a88..7b4be9842 100644 --- a/src/opt/maxsmt.h +++ b/src/opt/maxsmt.h @@ -147,6 +147,7 @@ namespace opt { bool get_assignment(unsigned index) const; void display_answer(std::ostream& out) const; void collect_statistics(statistics& st) const; + void model_updated(model* mdl); private: bool is_maxsat_problem(weights_t& ws) const; void verify_assignment(); diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index 4ccf30563..743ab20d9 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -138,6 +138,7 @@ namespace opt { p.set_bool("unsat_core", true); p.set_bool("elim_to_real", true); updt_params(p); + m_model_counter = 0; } context::~context() { @@ -1007,6 +1008,22 @@ namespace opt { } } + void context::model_updated(model* md) { + opt_params optp(m_params); + symbol prefix = optp.solution_prefix(); + if (prefix == symbol::null) return; + model_ref mdl = md->copy(); + fix_model(mdl); + std::ostringstream buffer; + buffer << prefix << (m_model_counter++) << ".smt2"; + std::ofstream out(buffer.str()); + if (out) { + model_smt2_pp(out, m, *mdl, 0); + out.close(); + } + } + + bool context::verify_model(unsigned index, model* md, rational const& _v) { rational r; app_ref term = m_objectives[index].m_term; @@ -1015,7 +1032,7 @@ namespace opt { } rational v = m_objectives[index].m_adjust_value(_v); expr_ref val(m); - model_ref mdl = md; + model_ref mdl = md->copy(); fix_model(mdl); if (!mdl->eval(term, val)) { diff --git a/src/opt/opt_context.h b/src/opt/opt_context.h index 513f2dd85..372c6672c 100644 --- a/src/opt/opt_context.h +++ b/src/opt/opt_context.h @@ -57,6 +57,7 @@ namespace opt { virtual unsigned num_objectives() = 0; virtual bool verify_model(unsigned id, model* mdl, rational const& v) = 0; virtual void set_model(model_ref& _m) = 0; + virtual void model_updated(model* mdl) = 0; }; /** @@ -154,9 +155,10 @@ namespace opt { map_t m_maxsmts; scoped_state m_scoped_state; vector m_objectives; - model_ref m_model; + model_ref m_model; model_converter_ref m_model_converter; filter_model_converter m_fm; + unsigned m_model_counter; obj_map m_objective_fns; obj_map m_objective_orig; func_decl_ref_vector m_objective_refs; @@ -231,6 +233,8 @@ namespace opt { virtual bool verify_model(unsigned id, model* mdl, rational const& v); + + virtual void model_updated(model* mdl); private: lbool execute(objective const& obj, bool committed, bool scoped); diff --git a/src/opt/opt_params.pyg b/src/opt/opt_params.pyg index cfcc5e47e..09d849e1a 100644 --- a/src/opt/opt_params.pyg +++ b/src/opt/opt_params.pyg @@ -5,6 +5,7 @@ def_module_params('opt', ('maxsat_engine', SYMBOL, 'maxres', "select engine for maxsat: 'core_maxsat', 'wmax', 'maxres', 'pd-maxres'"), ('priority', SYMBOL, 'lex', "select how to priortize objectives: 'lex' (lexicographic), 'pareto', or 'box'"), ('dump_benchmarks', BOOL, False, 'dump benchmarks for profiling'), + ('solution_prefix', SYMBOL, None, "path prefix to dump intermediary, but non-optimal, solutions"), ('timeout', UINT, UINT_MAX, 'timeout (in milliseconds) (UINT_MAX and 0 mean no timeout)'), ('rlimit', UINT, 0, 'resource limit (0 means no limit)'), ('enable_sls', BOOL, False, 'enable SLS tuning during weighted maxsast'), From 2f6c80ef086161331dfc1aefe762f380ed1afd54 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 28 Jan 2018 12:06:14 -0800 Subject: [PATCH 144/263] fix build Signed-off-by: Nikolaj Bjorner --- src/sat/sat_model_converter.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/sat/sat_model_converter.cpp b/src/sat/sat_model_converter.cpp index 1a3b4104f..4882018bb 100644 --- a/src/sat/sat_model_converter.cpp +++ b/src/sat/sat_model_converter.cpp @@ -43,10 +43,7 @@ namespace sat { // and the following procedure flips its value. bool sat = false; bool var_sign = false; - literal_vector::const_iterator it2 = it->m_clauses.begin(); - literal_vector::const_iterator end2 = it->m_clauses.end(); - for (; it2 != end2; ++it2) { - literal l = *it2; + for (literal l : it->m_clauses) { if (l == null_literal) { // end of clause if (!sat) { @@ -74,7 +71,7 @@ namespace sat { DEBUG_CODE({ // all clauses must be satisfied bool sat = false; - for (literal l : m_clauses) { + for (literal l : it->m_clauses) { if (l == null_literal) { SASSERT(sat); sat = false; From 5a16d3ef7ff477cebea9593c067cf01c7ccbfda1 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 29 Jan 2018 19:14:17 -0800 Subject: [PATCH 145/263] fix license in sstream Signed-off-by: Nikolaj Bjorner --- src/util/sstream.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/util/sstream.h b/src/util/sstream.h index 23d5bdfbb..fba13c5d5 100644 --- a/src/util/sstream.h +++ b/src/util/sstream.h @@ -1,10 +1,20 @@ - - /* -Copyright (c) 2013 Microsoft Corporation. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. +Copyright (c) 2018 Microsoft Corporation + +Module Name: + + nat_set.h + +Abstract: + + Wrapper for sstream. + +Author: + + Leonardo de Moura (leonardo) 2013 + +Revision History: -Author: Leonardo de Moura */ #pragma once #include From 73e9d351dc9870cc2190ba36ddcf46e22a8d9038 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 30 Jan 2018 03:21:58 -0800 Subject: [PATCH 146/263] adding initial model to updated #1463 Signed-off-by: Nikolaj Bjorner --- src/opt/opt_context.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index 743ab20d9..a7c8c3f5b 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -280,6 +280,7 @@ namespace opt { if (is_sat != l_false) { s.get_model(m_model); s.get_labels(m_labels); + model_updated(m_model.get()); } if (is_sat != l_true) { TRACE("opt", tout << m_hard_constraints << "\n";); From 177414c0ee82e10d9243fac9be219f7bf951b766 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 30 Jan 2018 21:43:56 +0700 Subject: [PATCH 147/263] Use const refs to reduce copying. These are things that have been found by `clang-tidy`. --- src/ast/proofs/proof_utils.h | 2 +- src/cmd_context/cmd_context.h | 2 +- src/duality/duality.h | 2 +- src/duality/duality_rpfp.cpp | 4 ++-- src/duality/duality_solver.cpp | 2 +- src/duality/duality_wrapper.h | 16 ++++++++-------- src/muz/base/dl_context.cpp | 4 ++-- src/muz/base/dl_context.h | 2 +- src/muz/base/dl_util.cpp | 8 ++++---- src/muz/base/dl_util.h | 12 ++++++------ src/muz/fp/datalog_parser.cpp | 6 +++--- src/muz/rel/dl_finite_product_relation.cpp | 4 ++-- src/muz/rel/dl_finite_product_relation.h | 4 ++-- src/muz/rel/dl_instruction.cpp | 8 ++++---- src/muz/rel/dl_instruction.h | 8 ++++---- src/muz/rel/dl_mk_explanations.cpp | 2 +- src/muz/rel/dl_product_relation.cpp | 2 +- src/muz/rel/dl_relation_manager.h | 8 ++++---- src/muz/rel/dl_sieve_relation.h | 2 +- src/muz/rel/dl_table_relation.cpp | 2 +- src/muz/spacer/spacer_context.cpp | 2 +- src/muz/spacer/spacer_context.h | 2 +- src/muz/spacer/spacer_matrix.cpp | 4 ++-- src/muz/spacer/spacer_matrix.h | 4 ++-- src/muz/spacer/spacer_unsat_core_learner.cpp | 2 +- src/muz/spacer/spacer_unsat_core_learner.h | 2 +- src/smt/smt_context.cpp | 2 +- src/smt/smt_context.h | 6 +++--- 28 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/ast/proofs/proof_utils.h b/src/ast/proofs/proof_utils.h index b953c834d..473df31e6 100644 --- a/src/ast/proofs/proof_utils.h +++ b/src/ast/proofs/proof_utils.h @@ -88,7 +88,7 @@ class elim_aux_assertions { app_ref m_aux; public: - elim_aux_assertions(app_ref aux) : m_aux(aux) {} + elim_aux_assertions(app_ref aux) : m_aux(std::move(aux)) {} void mk_or_core(expr_ref_vector &args, expr_ref &res) { diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 99d6c8284..212de585a 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -125,7 +125,7 @@ class stream_ref { std::ostream * m_stream; bool m_owner; public: - stream_ref(std::string n, std::ostream & d):m_default_name(n), m_default(d), m_name(n), m_stream(&d), m_owner(false) {} + stream_ref(const std::string& n, std::ostream & d):m_default_name(n), m_default(d), m_name(n), m_stream(&d), m_owner(false) {} ~stream_ref() { reset(); } void set(char const * name); void set(std::ostream& strm); diff --git a/src/duality/duality.h b/src/duality/duality.h index 657fa18b4..28cf96df3 100644 --- a/src/duality/duality.h +++ b/src/duality/duality.h @@ -66,7 +66,7 @@ namespace Duality { bool is_variable(const Term &t); - FuncDecl SuffixFuncDecl(Term t, int n); + FuncDecl SuffixFuncDecl(const Term &t, int n); Term SubstRecHide(hash_map &memo, const Term &t, int number); diff --git a/src/duality/duality_rpfp.cpp b/src/duality/duality_rpfp.cpp index 5dc2283ae..9dae5eba9 100755 --- a/src/duality/duality_rpfp.cpp +++ b/src/duality/duality_rpfp.cpp @@ -2157,7 +2157,7 @@ namespace Duality { std::vector la_pos_vars; bool fixing; - void IndexLAcoeff(const Term &coeff1, const Term &coeff2, Term t, int id) { + void IndexLAcoeff(const Term &coeff1, const Term &coeff2, const Term &t, int id) { Term coeff = coeff1 * coeff2; coeff = coeff.simplify(); Term is_pos = (coeff >= ctx.int_val(0)); @@ -3303,7 +3303,7 @@ namespace Duality { // This returns a new FuncDel with same sort as top-level function // of term t, but with numeric suffix appended to name. - Z3User::FuncDecl Z3User::SuffixFuncDecl(Term t, int n) + Z3User::FuncDecl Z3User::SuffixFuncDecl(const Term &t, int n) { std::string name = t.decl().name().str() + "_" + string_of_int(n); std::vector sorts; diff --git a/src/duality/duality_solver.cpp b/src/duality/duality_solver.cpp index 1711b65ad..15d79ba8d 100644 --- a/src/duality/duality_solver.cpp +++ b/src/duality/duality_solver.cpp @@ -107,7 +107,7 @@ namespace Duality { struct InternalError { std::string msg; - InternalError(const std::string _msg) + InternalError(const std::string & _msg) : msg(_msg) {} }; diff --git a/src/duality/duality_wrapper.h b/src/duality/duality_wrapper.h index 96c49b36b..18b6948d5 100644 --- a/src/duality/duality_wrapper.h +++ b/src/duality/duality_wrapper.h @@ -191,7 +191,7 @@ namespace Duality { sort int_sort(); sort real_sort(); sort bv_sort(unsigned sz); - sort array_sort(sort d, sort r); + sort array_sort(const sort & d, const sort & r); func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range); func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range); @@ -763,11 +763,11 @@ namespace Duality { unsigned size() const; func_decl operator[](unsigned i) const; - expr get_const_interp(func_decl f) const { + expr get_const_interp(const func_decl & f) const { return ctx().cook(m_model->get_const_interp(to_func_decl(f.raw()))); } - func_interp get_func_interp(func_decl f) const { + func_interp get_func_interp(const func_decl & f) const { return func_interp(ctx(),m_model->get_func_interp(to_func_decl(f.raw()))); } @@ -1169,7 +1169,7 @@ namespace Duality { ::sort *s = m().mk_sort(m_arith_fid, REAL_SORT); return sort(*this, s); } - inline sort context::array_sort(sort d, sort r) { + inline sort context::array_sort(const sort & d, const sort & r) { parameter params[2] = { parameter(d), parameter(to_sort(r)) }; ::sort * s = m().mk_sort(m_array_fid, ARRAY_SORT, 2, params); return sort(*this, s); @@ -1274,11 +1274,11 @@ namespace Duality { class TermTree { public: - TermTree(expr _term){ + TermTree(const expr &_term){ term = _term; } - TermTree(expr _term, const std::vector &_children){ + TermTree(const expr &_term, const std::vector &_children){ term = _term; children = _children; } @@ -1302,9 +1302,9 @@ namespace Duality { return num; } - inline void setTerm(expr t){term = t;} + inline void setTerm(const expr &t){term = t;} - inline void addTerm(expr t){terms.push_back(t);} + inline void addTerm(const expr &t){terms.push_back(t);} inline void setChildren(const std::vector & _children){ children = _children; diff --git a/src/muz/base/dl_context.cpp b/src/muz/base/dl_context.cpp index 39e044ec3..78860bdde 100644 --- a/src/muz/base/dl_context.cpp +++ b/src/muz/base/dl_context.cpp @@ -400,7 +400,7 @@ namespace datalog { } uint64 res; if (!try_get_sort_constant_count(srt, res)) { - sort_size sz = srt->get_num_elements(); + const sort_size & sz = srt->get_num_elements(); if (sz.is_finite()) { res = sz.size(); } @@ -411,7 +411,7 @@ namespace datalog { return res; } - void context::set_argument_names(const func_decl * pred, svector var_names) + void context::set_argument_names(const func_decl * pred, const svector & var_names) { SASSERT(!m_argument_var_names.contains(pred)); m_argument_var_names.insert(pred, var_names); diff --git a/src/muz/base/dl_context.h b/src/muz/base/dl_context.h index 129277514..0fb68d396 100644 --- a/src/muz/base/dl_context.h +++ b/src/muz/base/dl_context.h @@ -368,7 +368,7 @@ namespace datalog { These names are used when printing out the relations to make the output conform to the one of bddbddb. */ - void set_argument_names(const func_decl * pred, svector var_names); + void set_argument_names(const func_decl * pred, const svector & var_names); symbol get_argument_name(const func_decl * pred, unsigned arg_index); void set_predicate_representation(func_decl * pred, unsigned relation_name_cnt, diff --git a/src/muz/base/dl_util.cpp b/src/muz/base/dl_util.cpp index fad424b90..e391da381 100644 --- a/src/muz/base/dl_util.cpp +++ b/src/muz/base/dl_util.cpp @@ -547,7 +547,7 @@ namespace datalog { // // ----------------------------------- - void get_file_names(std::string directory, std::string extension, bool traverse_subdirs, + void get_file_names(std::string directory, const std::string & extension, bool traverse_subdirs, string_vector & res) { if(directory[directory.size()-1]!='\\' && directory[directory.size()-1]!='/') { @@ -595,7 +595,7 @@ namespace datalog { #endif } - bool file_exists(std::string name) { + bool file_exists(const std::string & name) { struct stat st; if(stat(name.c_str(),&st) == 0) { return true; @@ -603,7 +603,7 @@ namespace datalog { return false; } - bool is_directory(std::string name) { + bool is_directory(const std::string & name) { if(!file_exists(name)) { return false; } @@ -612,7 +612,7 @@ namespace datalog { return (status.st_mode&S_IFDIR)!=0; } - std::string get_file_name_without_extension(std::string name) { + std::string get_file_name_without_extension(const std::string & name) { size_t slash_index = name.find_last_of("\\/"); size_t dot_index = name.rfind("."); size_t ofs = (slash_index==std::string::npos) ? 0 : slash_index+1; diff --git a/src/muz/base/dl_util.h b/src/muz/base/dl_util.h index 6b689fd17..32f016f63 100644 --- a/src/muz/base/dl_util.h +++ b/src/muz/base/dl_util.h @@ -290,7 +290,7 @@ namespace datalog { } template - void project_out_vector_columns(T & container, const unsigned_vector removed_cols) { + void project_out_vector_columns(T & container, const unsigned_vector & removed_cols) { project_out_vector_columns(container, removed_cols.size(), removed_cols.c_ptr()); } @@ -342,7 +342,7 @@ namespace datalog { } template - void permutate_by_cycle(T & container, const unsigned_vector permutation_cycle) { + void permutate_by_cycle(T & container, const unsigned_vector & permutation_cycle) { permutate_by_cycle(container, permutation_cycle.size(), permutation_cycle.c_ptr()); } @@ -578,13 +578,13 @@ namespace datalog { // // ----------------------------------- - void get_file_names(std::string directory, std::string extension, bool traverse_subdirs, + void get_file_names(std::string directory, const std::string & extension, bool traverse_subdirs, string_vector & res); - bool file_exists(std::string name); - bool is_directory(std::string name); + bool file_exists(const std::string & name); + bool is_directory(const std::string & name); - std::string get_file_name_without_extension(std::string name); + std::string get_file_name_without_extension(const std::string & name); // ----------------------------------- // diff --git a/src/muz/fp/datalog_parser.cpp b/src/muz/fp/datalog_parser.cpp index 7191f1931..f839c5c5a 100644 --- a/src/muz/fp/datalog_parser.cpp +++ b/src/muz/fp/datalog_parser.cpp @@ -1303,7 +1303,7 @@ private: } } - void parse_rules_file(std::string fname) { + void parse_rules_file(const std::string & fname) { SASSERT(file_exists(fname)); flet flet_cur_file(m_current_file, fname); @@ -1347,7 +1347,7 @@ private: return true; } - void parse_rel_file(std::string fname) { + void parse_rel_file(const std::string & fname) { SASSERT(file_exists(fname)); IF_VERBOSE(10, verbose_stream() << "Parsing relation file " << fname << "\n";); @@ -1496,7 +1496,7 @@ private: return true; } - void parse_map_file(std::string fname) { + void parse_map_file(const std::string & fname) { SASSERT(file_exists(fname)); IF_VERBOSE(10, verbose_stream() << "Parsing map file " << fname << "\n";); diff --git a/src/muz/rel/dl_finite_product_relation.cpp b/src/muz/rel/dl_finite_product_relation.cpp index c036d3cfd..163ba1b0b 100644 --- a/src/muz/rel/dl_finite_product_relation.cpp +++ b/src/muz/rel/dl_finite_product_relation.cpp @@ -1924,7 +1924,7 @@ namespace datalog { } } - void finite_product_relation::extract_table_fact(const relation_fact rf, table_fact & tf) const { + void finite_product_relation::extract_table_fact(const relation_fact & rf, table_fact & tf) const { const relation_signature & sig = get_signature(); relation_manager & rmgr = get_manager(); @@ -1940,7 +1940,7 @@ namespace datalog { tf.push_back(0); } - void finite_product_relation::extract_other_fact(const relation_fact rf, relation_fact & of) const { + void finite_product_relation::extract_other_fact(const relation_fact & rf, relation_fact & of) const { of.reset(); unsigned o_sz = m_other_sig.size(); for(unsigned i=0; idisplay_indented(ctx, out, indentation+" "); } }; @@ -1182,7 +1182,7 @@ namespace datalog { } } - void instruction_block::display_indented(execution_context const& _ctx, std::ostream & out, std::string indentation) const { + void instruction_block::display_indented(execution_context const& _ctx, std::ostream & out, const std::string & indentation) const { rel_context const& ctx = _ctx.get_rel_context(); instr_seq_type::const_iterator it = m_data.begin(); instr_seq_type::const_iterator end = m_data.end(); diff --git a/src/muz/rel/dl_instruction.h b/src/muz/rel/dl_instruction.h index 56dd249a5..d2e1c30f5 100644 --- a/src/muz/rel/dl_instruction.h +++ b/src/muz/rel/dl_instruction.h @@ -150,7 +150,7 @@ namespace datalog { return m_reg_annotation.find(reg, res); } - void set_register_annotation(reg_idx reg, std::string str) { + void set_register_annotation(reg_idx reg, const std::string & str) { m_reg_annotation.insert(reg, str); } @@ -233,7 +233,7 @@ namespace datalog { Each line must be prepended by \c indentation and ended by a newline character. */ - virtual void display_body_impl(execution_context const & ctx, std::ostream & out, std::string indentation) const {} + virtual void display_body_impl(execution_context const & ctx, std::ostream & out, const std::string & indentation) const {} void log_verbose(execution_context& ctx); public: @@ -249,7 +249,7 @@ namespace datalog { void display(execution_context const& ctx, std::ostream & out) const { display_indented(ctx, out, ""); } - void display_indented(execution_context const & ctx, std::ostream & out, std::string indentation) const; + void display_indented(execution_context const & ctx, std::ostream & out, const std::string & indentation) const; static instruction * mk_load(ast_manager & m, func_decl * pred, reg_idx tgt); /** @@ -359,7 +359,7 @@ namespace datalog { void display(execution_context const & ctx, std::ostream & out) const { display_indented(ctx, out, ""); } - void display_indented(execution_context const & ctx, std::ostream & out, std::string indentation) const; + void display_indented(execution_context const & ctx, std::ostream & out, const std::string & indentation) const; unsigned num_instructions() const { return m_data.size(); } }; diff --git a/src/muz/rel/dl_mk_explanations.cpp b/src/muz/rel/dl_mk_explanations.cpp index c4fb57eeb..ca04ca099 100644 --- a/src/muz/rel/dl_mk_explanations.cpp +++ b/src/muz/rel/dl_mk_explanations.cpp @@ -454,7 +454,7 @@ namespace datalog { : m_manager(ctx.get_manager()), m_subst(ctx.get_var_subst()), m_col_idx(col_idx), - m_new_rule(new_rule) {} + m_new_rule(std::move(new_rule)) {} virtual void operator()(relation_base & r0) { explanation_relation & r = static_cast(r0); diff --git a/src/muz/rel/dl_product_relation.cpp b/src/muz/rel/dl_product_relation.cpp index 8a2029748..1a91d6828 100644 --- a/src/muz/rel/dl_product_relation.cpp +++ b/src/muz/rel/dl_product_relation.cpp @@ -488,7 +488,7 @@ namespace datalog { ptr_vector m_transforms; public: transform_fn(relation_signature s, unsigned num_trans, relation_transformer_fn** trans): - m_sig(s), + m_sig(std::move(s)), m_transforms(num_trans, trans) {} ~transform_fn() { dealloc_ptr_vector_content(m_transforms); } diff --git a/src/muz/rel/dl_relation_manager.h b/src/muz/rel/dl_relation_manager.h index 610c523e1..088b246e4 100644 --- a/src/muz/rel/dl_relation_manager.h +++ b/src/muz/rel/dl_relation_manager.h @@ -289,7 +289,7 @@ namespace datalog { relation_transformer_fn * mk_permutation_rename_fn(const relation_base & t, const unsigned * permutation); relation_transformer_fn * mk_permutation_rename_fn(const relation_base & t, - const unsigned_vector permutation) { + const unsigned_vector & permutation) { SASSERT(t.get_signature().size()==permutation.size()); return mk_permutation_rename_fn(t, permutation.c_ptr()); } @@ -343,7 +343,7 @@ namespace datalog { relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, const unsigned * identical_cols); - relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, const unsigned_vector identical_cols) { + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, const unsigned_vector & identical_cols) { return mk_filter_identical_fn(t, identical_cols.size(), identical_cols.c_ptr()); } @@ -468,7 +468,7 @@ namespace datalog { of column number. */ table_transformer_fn * mk_permutation_rename_fn(const table_base & t, const unsigned * permutation); - table_transformer_fn * mk_permutation_rename_fn(const table_base & t, const unsigned_vector permutation) { + table_transformer_fn * mk_permutation_rename_fn(const table_base & t, const unsigned_vector & permutation) { SASSERT(t.get_signature().size()==permutation.size()); return mk_permutation_rename_fn(t, permutation.c_ptr()); } @@ -522,7 +522,7 @@ namespace datalog { table_mutator_fn * mk_filter_identical_fn(const table_base & t, unsigned col_cnt, const unsigned * identical_cols); - table_mutator_fn * mk_filter_identical_fn(const table_base & t, const unsigned_vector identical_cols) { + table_mutator_fn * mk_filter_identical_fn(const table_base & t, const unsigned_vector & identical_cols) { return mk_filter_identical_fn(t, identical_cols.size(), identical_cols.c_ptr()); } diff --git a/src/muz/rel/dl_sieve_relation.h b/src/muz/rel/dl_sieve_relation.h index 021c9d8df..e369e04aa 100644 --- a/src/muz/rel/dl_sieve_relation.h +++ b/src/muz/rel/dl_sieve_relation.h @@ -108,7 +108,7 @@ namespace datalog { sieve_relation * mk_from_inner(const relation_signature & s, const bool * inner_columns, relation_base * inner_rel); - sieve_relation * mk_from_inner(const relation_signature & s, const svector inner_columns, + sieve_relation * mk_from_inner(const relation_signature & s, const svector & inner_columns, relation_base * inner_rel) { SASSERT(inner_columns.size()==s.size()); return mk_from_inner(s, inner_columns.c_ptr(), inner_rel); diff --git a/src/muz/rel/dl_table_relation.cpp b/src/muz/rel/dl_table_relation.cpp index d8f1c7314..b8cf8e724 100644 --- a/src/muz/rel/dl_table_relation.cpp +++ b/src/muz/rel/dl_table_relation.cpp @@ -240,7 +240,7 @@ namespace datalog { const table_relation & tr_src = static_cast(src); relation_manager & rmgr = tr_src.get_manager(); - relation_signature sig = tr_src.get_signature(); + const relation_signature & sig = tr_src.get_signature(); SASSERT(tgt.get_signature()==sig); SASSERT(!delta || delta->get_signature()==sig); diff --git a/src/muz/spacer/spacer_context.cpp b/src/muz/spacer/spacer_context.cpp index b057730d8..28ff7d787 100644 --- a/src/muz/spacer/spacer_context.cpp +++ b/src/muz/spacer/spacer_context.cpp @@ -3418,7 +3418,7 @@ expr_ref context::get_constraints (unsigned level) return m_pm.mk_and (constraints); } -void context::add_constraints (unsigned level, expr_ref c) +void context::add_constraints (unsigned level, const expr_ref& c) { if (!c.get()) { return; } if (m.is_true(c)) { return; } diff --git a/src/muz/spacer/spacer_context.h b/src/muz/spacer/spacer_context.h index cb422d08f..898c1639e 100644 --- a/src/muz/spacer/spacer_context.h +++ b/src/muz/spacer/spacer_context.h @@ -833,7 +833,7 @@ public: pob& get_root() const { return m_pob_queue.get_root(); } expr_ref get_constraints (unsigned lvl); - void add_constraints (unsigned lvl, expr_ref c); + void add_constraints (unsigned lvl, const expr_ref& c); }; inline bool pred_transformer::use_native_mbp () {return ctx.use_native_mbp ();} diff --git a/src/muz/spacer/spacer_matrix.cpp b/src/muz/spacer/spacer_matrix.cpp index 3cc83996c..ea9b3cb32 100644 --- a/src/muz/spacer/spacer_matrix.cpp +++ b/src/muz/spacer/spacer_matrix.cpp @@ -42,7 +42,7 @@ namespace spacer return m_num_cols; } - rational spacer_matrix::get(unsigned int i, unsigned int j) + const rational& spacer_matrix::get(unsigned int i, unsigned int j) { SASSERT(i < m_num_rows); SASSERT(j < m_num_cols); @@ -50,7 +50,7 @@ namespace spacer return m_matrix[i][j]; } - void spacer_matrix::set(unsigned int i, unsigned int j, rational v) + void spacer_matrix::set(unsigned int i, unsigned int j, const rational& v) { SASSERT(i < m_num_rows); SASSERT(j < m_num_cols); diff --git a/src/muz/spacer/spacer_matrix.h b/src/muz/spacer/spacer_matrix.h index 4fc418f2b..5e6dabea8 100644 --- a/src/muz/spacer/spacer_matrix.h +++ b/src/muz/spacer/spacer_matrix.h @@ -30,8 +30,8 @@ namespace spacer { unsigned num_rows(); unsigned num_cols(); - rational get(unsigned i, unsigned j); - void set(unsigned i, unsigned j, rational v); + const rational& get(unsigned i, unsigned j); + void set(unsigned i, unsigned j, const rational& v); unsigned perform_gaussian_elimination(); diff --git a/src/muz/spacer/spacer_unsat_core_learner.cpp b/src/muz/spacer/spacer_unsat_core_learner.cpp index d478b1e8f..bc066d32d 100644 --- a/src/muz/spacer/spacer_unsat_core_learner.cpp +++ b/src/muz/spacer/spacer_unsat_core_learner.cpp @@ -301,7 +301,7 @@ public: void operator()(quantifier*) {} }; -void unsat_core_learner::collect_symbols_b(expr_set axioms_b) +void unsat_core_learner::collect_symbols_b(const expr_set& axioms_b) { expr_mark visited; collect_pure_proc proc(m_symbols_b); diff --git a/src/muz/spacer/spacer_unsat_core_learner.h b/src/muz/spacer/spacer_unsat_core_learner.h index a7c9f6aa7..87238b5fd 100644 --- a/src/muz/spacer/spacer_unsat_core_learner.h +++ b/src/muz/spacer/spacer_unsat_core_learner.h @@ -82,7 +82,7 @@ namespace spacer { private: ptr_vector m_plugins; func_decl_set m_symbols_b; // symbols, which occur in any b-asserted formula - void collect_symbols_b(expr_set axioms_b); + void collect_symbols_b(const expr_set& axioms_b); ast_mark m_a_mark; ast_mark m_b_mark; diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index a87042e2b..375ff7e6f 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -1791,7 +1791,7 @@ namespace smt { } } - void context::set_conflict(b_justification js, literal not_l) { + void context::set_conflict(const b_justification & js, literal not_l) { if (!inconsistent()) { TRACE("set_conflict", display_literal_verbose(tout, not_l); display(tout, js); ); m_conflict = js; diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index e50c03c8a..55d8f03f2 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -897,7 +897,7 @@ namespace smt { void trace_assign(literal l, b_justification j, bool decision) const; public: - void assign(literal l, b_justification j, bool decision = false) { + void assign(literal l, const b_justification & j, bool decision = false) { SASSERT(l != false_literal); SASSERT(l != null_literal); switch (get_assignment(l)) { @@ -998,9 +998,9 @@ namespace smt { void assign_quantifier(quantifier * q); - void set_conflict(b_justification js, literal not_l); + void set_conflict(const b_justification & js, literal not_l); - void set_conflict(b_justification js) { + void set_conflict(const b_justification & js) { set_conflict(js, null_literal); } From 6d6b61492456af67958d23b8ea22d6833e4e3ff9 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 30 Jan 2018 21:45:12 +0700 Subject: [PATCH 148/263] Use char version of rfind. There is only a single character involved, so use the char version. This was found via `clang-tidy`. --- src/muz/base/dl_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/muz/base/dl_util.cpp b/src/muz/base/dl_util.cpp index fad424b90..787dc6cfa 100644 --- a/src/muz/base/dl_util.cpp +++ b/src/muz/base/dl_util.cpp @@ -614,7 +614,7 @@ namespace datalog { std::string get_file_name_without_extension(std::string name) { size_t slash_index = name.find_last_of("\\/"); - size_t dot_index = name.rfind("."); + size_t dot_index = name.rfind('.'); size_t ofs = (slash_index==std::string::npos) ? 0 : slash_index+1; size_t count = (dot_index!=std::string::npos && dot_index>ofs) ? (dot_index-ofs) : std::string::npos; From ae8027e594c67a78366c2662a36b1ec110a23d4e Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 30 Jan 2018 20:36:12 +0700 Subject: [PATCH 149/263] Fix typos. --- RELEASE_NOTES | 12 ++++---- src/api/api_context.h | 4 +-- src/api/c++/z3++.h | 10 +++---- src/api/dotnet/Statistics.cs | 2 +- src/api/java/Context.java | 2 +- src/api/java/Statistics.java | 2 +- src/api/python/z3/z3.py | 10 +++---- src/api/z3_fixedpoint.h | 2 +- src/api/z3_fpa.h | 2 +- src/ast/proofs/proof_utils.cpp | 10 +++---- src/cmd_context/basic_cmds.cpp | 2 +- src/duality/duality_solver.cpp | 4 +-- src/math/polynomial/polynomial.h | 8 +++--- .../polynomial/upolynomial_factorization.cpp | 28 +++++++++---------- .../polynomial/upolynomial_factorization.h | 12 ++++---- src/muz/rel/aig_exporter.cpp | 2 +- src/muz/rel/dl_sieve_relation.cpp | 2 +- src/muz/rel/dl_sparse_table.h | 4 +-- src/muz/spacer/spacer_matrix.h | 2 +- src/nlsat/nlsat_explain.cpp | 4 +-- src/test/rational.cpp | 4 +-- src/util/gparams.h | 4 +-- src/util/mpz.h | 2 +- 23 files changed, 67 insertions(+), 67 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 5ce4d2682..86e7039dd 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -427,11 +427,11 @@ Version 3.0 - New Bitvector (QF_BV) solver. The new solver is only available when using the new SMT2 front-end. -- Major performace improvements. +- Major performance improvements. - New preprocessing stack. -- Performance improvements for linear and nonlinear arithmetic. The improvements are only available when using the the SMT2 front-end. +- Performance improvements for linear and nonlinear arithmetic. The improvements are only available when using the SMT2 front-end. - Added API for parsing SMT2 files. @@ -772,7 +772,7 @@ This release also introduces some new preprocessing features: - More efficient destructive equality resolution DER=true. -- DISTRIBUTE_FORALL=true (distributes universal quatifiers over conjunctions, this transformation may affect pattern inference). +- DISTRIBUTE_FORALL=true (distributes universal quantifiers over conjunctions, this transformation may affect pattern inference). - Rewriter that uses universally quantified equations PRE_DEMODULATOR=true (yes, the option name is not good, we will change it in a future release). @@ -842,7 +842,7 @@ This release introduces the following features: It fixes the following bugs: -- Incorrect simplification of map over store in the extendted array theory. Reported by Catalin Hritcu. +- Incorrect simplification of map over store in the extended array theory. Reported by Catalin Hritcu. - Incomplete handling of equality propagation with constant arrays. Reported by Catalin Hritcu. @@ -886,7 +886,7 @@ Version 2.0 proof object. - Proof Objects. - The #Z3_check_assumptions retuns a proof object if + The #Z3_check_assumptions returns a proof object if the configuration flag PROOF_MODE is set to 1 or 2. - Partial support for non-linear arithmetic. @@ -899,4 +899,4 @@ Version 2.0 The theory of well-founded recursive data-types is supported over the binary APIs. It supports ground satisfiability checking for tuples, enumeration types (scalars), - lists and mututally recursive data-types. + lists and mutually recursive data-types. diff --git a/src/api/api_context.h b/src/api/api_context.h index a2321d7fe..7009250cc 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -51,7 +51,7 @@ namespace api { class context : public tactic_manager { struct add_plugins { add_plugins(ast_manager & m); }; context_params m_params; - bool m_user_ref_count; //!< if true, the user is responsible for managing referenc counters. + bool m_user_ref_count; //!< if true, the user is responsible for managing reference counters. scoped_ptr m_manager; add_plugins m_plugins; @@ -158,7 +158,7 @@ namespace api { // Create a numeral of the given sort expr * mk_numeral_core(rational const & n, sort * s); - // Return a conjuction that will be exposed to the "external" world. + // Return a conjunction that will be exposed to the "external" world. expr * mk_and(unsigned num_exprs, expr * const * exprs); // Hack for preventing an AST for being GC when ref-count is not used diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 89b051eb5..49f6cfbf3 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -187,8 +187,8 @@ namespace z3 { \brief The C++ API uses by defaults exceptions on errors. For applications that don't work well with exceptions (there should be only few) you have the ability to turn off exceptions. The tradeoffs are that applications - have to very careful about using check_error() after calls that may result in an errornous - state. + have to very careful about using check_error() after calls that may result in an + erroneous state. */ void set_enable_exceptions(bool f) { m_enable_exceptions = f; } @@ -213,7 +213,7 @@ namespace z3 { /** \brief Interrupt the current procedure being executed by any object managed by this context. - This is a soft interruption: there is no guarantee the object will actualy stop. + This is a soft interruption: there is no guarantee the object will actually stop. */ void interrupt() { Z3_interrupt(m_ctx); } @@ -709,7 +709,7 @@ namespace z3 { It only makes sense to use this function if the caller can ensure that the result is an integer or if exceptions are enabled. - If exceptions are disabled, then use the the is_numeral_i function. + If exceptions are disabled, then use the is_numeral_i function. \pre is_numeral() */ @@ -729,7 +729,7 @@ namespace z3 { It only makes sense to use this function if the caller can ensure that the result is an integer or if exceptions are enabled. - If exceptions are disabled, then use the the is_numeral_u function. + If exceptions are disabled, then use the is_numeral_u function. \pre is_numeral() */ unsigned get_numeral_uint() const { diff --git a/src/api/dotnet/Statistics.cs b/src/api/dotnet/Statistics.cs index cf4b703fe..c94af625c 100644 --- a/src/api/dotnet/Statistics.cs +++ b/src/api/dotnet/Statistics.cs @@ -56,7 +56,7 @@ namespace Microsoft.Z3 public bool IsDouble { get { return m_is_double; } } /// - /// The string representation of the the entry's value. + /// The string representation of the entry's value. /// public string Value { diff --git a/src/api/java/Context.java b/src/api/java/Context.java index 7e73fc15e..ba96209b3 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -934,7 +934,7 @@ public class Context implements AutoCloseable { * exposed. It follows the semantics prescribed by the SMT-LIB standard. * * You can take the floor of a real by creating an auxiliary integer Term - * {@code k} and and asserting + * {@code k} and asserting * {@code MakeInt2Real(k) <= t1 < MkInt2Real(k)+1}. The argument * must be of integer sort. **/ diff --git a/src/api/java/Statistics.java b/src/api/java/Statistics.java index 356cbeadb..d509424ed 100644 --- a/src/api/java/Statistics.java +++ b/src/api/java/Statistics.java @@ -65,7 +65,7 @@ public class Statistics extends Z3Object { } /** - * The string representation of the the entry's value. + * The string representation of the entry's value. * * @throws Z3Exception **/ diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 4896a475d..c28a14c3b 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -5741,7 +5741,7 @@ class ModelRef(Z3PPObject): return None def num_sorts(self): - """Return the number of unintepreted sorts that contain an interpretation in the model `self`. + """Return the number of uninterpreted sorts that contain an interpretation in the model `self`. >>> A = DeclareSort('A') >>> a, b = Consts('a b', A) @@ -5756,7 +5756,7 @@ class ModelRef(Z3PPObject): return int(Z3_model_get_num_sorts(self.ctx.ref(), self.model)) def get_sort(self, idx): - """Return the unintepreted sort at position `idx` < self.num_sorts(). + """Return the uninterpreted sort at position `idx` < self.num_sorts(). >>> A = DeclareSort('A') >>> B = DeclareSort('B') @@ -5796,7 +5796,7 @@ class ModelRef(Z3PPObject): return [ self.get_sort(i) for i in range(self.num_sorts()) ] def get_universe(self, s): - """Return the intepretation for the uninterpreted sort `s` in the model `self`. + """Return the interpretation for the uninterpreted sort `s` in the model `self`. >>> A = DeclareSort('A') >>> a, b = Consts('a b', A) @@ -5816,7 +5816,7 @@ class ModelRef(Z3PPObject): return None def __getitem__(self, idx): - """If `idx` is an integer, then the declaration at position `idx` in the model `self` is returned. If `idx` is a declaration, then the actual interpreation is returned. + """If `idx` is an integer, then the declaration at position `idx` in the model `self` is returned. If `idx` is a declaration, then the actual interpretation is returned. The elements can be retrieved using position or the actual declaration. @@ -5860,7 +5860,7 @@ class ModelRef(Z3PPObject): return None def decls(self): - """Return a list with all symbols that have an interpreation in the model `self`. + """Return a list with all symbols that have an interpretation in the model `self`. >>> f = Function('f', IntSort(), IntSort()) >>> x = Int('x') >>> s = Solver() diff --git a/src/api/z3_fixedpoint.h b/src/api/z3_fixedpoint.h index dc98fdb30..a651993ce 100644 --- a/src/api/z3_fixedpoint.h +++ b/src/api/z3_fixedpoint.h @@ -363,7 +363,7 @@ extern "C" { void Z3_API Z3_fixedpoint_set_reduce_assign_callback( Z3_context c ,Z3_fixedpoint d, Z3_fixedpoint_reduce_assign_callback_fptr cb); - /** \brief Register a callback for buildling terms based on the relational operators. */ + /** \brief Register a callback for building terms based on the relational operators. */ void Z3_API Z3_fixedpoint_set_reduce_app_callback( Z3_context c, Z3_fixedpoint d, Z3_fixedpoint_reduce_app_callback_fptr cb); diff --git a/src/api/z3_fpa.h b/src/api/z3_fpa.h index e92b728d7..358a3c619 100644 --- a/src/api/z3_fpa.h +++ b/src/api/z3_fpa.h @@ -433,7 +433,7 @@ extern "C" { \param c logical context \param rm term of RoundingMode sort \param t1 term of FloatingPoint sort - \param t2 term of FloatingPoint sor + \param t2 term of FloatingPoint sort \param t3 term of FloatingPoint sort The result is round((t1 * t2) + t3) diff --git a/src/ast/proofs/proof_utils.cpp b/src/ast/proofs/proof_utils.cpp index 58500cb79..722bfe14e 100644 --- a/src/ast/proofs/proof_utils.cpp +++ b/src/ast/proofs/proof_utils.cpp @@ -83,7 +83,7 @@ class reduce_hypotheses { // map from unit literals to their hypotheses-free derivations obj_map m_units; - // -- all hypotheses in the the proof + // -- all hypotheses in the proof obj_hashtable m_hyps; // marks hypothetical proofs @@ -192,7 +192,7 @@ class reduce_hypotheses { res = mk_lemma_core(args.get(0), m.get_fact(p)); compute_mark1(res); } else if (m.is_unit_resolution(p)) { - // unit: reduce untis; reduce the first premise; rebuild unit resolution + // unit: reduce units; reduce the first premise; rebuild unit resolution res = mk_unit_resolution_core(args.size(), args.c_ptr()); compute_mark1(res); } else { @@ -340,7 +340,7 @@ void reduce_hypotheses(proof_ref &pr) { class reduce_hypotheses0 { typedef obj_hashtable expr_set; ast_manager& m; - // reference for any expression created by the tranformation + // reference for any expression created by the transformation expr_ref_vector m_refs; // currently computed result obj_map m_cache; @@ -352,7 +352,7 @@ class reduce_hypotheses0 { unsigned_vector m_limits; // map from proofs to active hypotheses obj_map m_hypmap; - // refernce train for hypotheses sets + // reference train for hypotheses sets ptr_vector m_hyprefs; ptr_vector m_literals; @@ -492,7 +492,7 @@ public: // replace result by m_units[m.get_fact (p)] if defined // AG: This is the main step. Replace a hypothesis by a derivation of its consequence if (!m_units.find(m.get_fact(p), result)) { - // restore ther result back to p + // restore the result back to p result = p.get(); } // compute hypothesis of the result diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index 65c8860b1..572abc8fe 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -761,7 +761,7 @@ public: return m_array_fid; } virtual char const * get_usage() const { return " (+) "; } - virtual char const * get_descr(cmd_context & ctx) const { return "declare a new array map operator with name using the given function declaration.\n ::= \n | ( (*) )\n | ((_ +) (*) )\nThe last two cases are used to disumbiguate between declarations with the same name and/or select (indexed) builtin declarations.\nFor more details about the the array map operator, see 'Generalized and Efficient Array Decision Procedures' (FMCAD 2009).\nExample: (declare-map set-union (Int) (or (Bool Bool) Bool))\nDeclares a new function (declare-fun set-union ((Array Int Bool) (Array Int Bool)) (Array Int Bool)).\nThe instance of the map axiom for this new declaration is:\n(forall ((a1 (Array Int Bool)) (a2 (Array Int Bool)) (i Int)) (= (select (set-union a1 a2) i) (or (select a1 i) (select a2 i))))"; } + virtual char const * get_descr(cmd_context & ctx) const { return "declare a new array map operator with name using the given function declaration.\n ::= \n | ( (*) )\n | ((_ +) (*) )\nThe last two cases are used to disumbiguate between declarations with the same name and/or select (indexed) builtin declarations.\nFor more details about the array map operator, see 'Generalized and Efficient Array Decision Procedures' (FMCAD 2009).\nExample: (declare-map set-union (Int) (or (Bool Bool) Bool))\nDeclares a new function (declare-fun set-union ((Array Int Bool) (Array Int Bool)) (Array Int Bool)).\nThe instance of the map axiom for this new declaration is:\n(forall ((a1 (Array Int Bool)) (a2 (Array Int Bool)) (i Int)) (= (select (set-union a1 a2) i) (or (select a1 i) (select a2 i))))"; } virtual unsigned get_arity() const { return 3; } virtual void prepare(cmd_context & ctx) { m_name = symbol::null; m_domain.reset(); } virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { diff --git a/src/duality/duality_solver.cpp b/src/duality/duality_solver.cpp index 1711b65ad..165f1d2bc 100644 --- a/src/duality/duality_solver.cpp +++ b/src/duality/duality_solver.cpp @@ -112,9 +112,9 @@ namespace Duality { }; - /** This is the main solver. It takes anarbitrary (possibly cyclic) + /** This is the main solver. It takes an arbitrary (possibly cyclic) RPFP and either annotates it with a solution, or returns a - counterexample derivation in the form of an embedd RPFP tree. */ + counterexample derivation in the form of an embedded RPFP tree. */ class Duality : public Solver { diff --git a/src/math/polynomial/polynomial.h b/src/math/polynomial/polynomial.h index b09af94bc..c4dedb043 100644 --- a/src/math/polynomial/polynomial.h +++ b/src/math/polynomial/polynomial.h @@ -233,7 +233,7 @@ namespace polynomial { /** \brief Install a "delete polynomial" event handler. - The even hanlder is not owned by the polynomial manager. + The event handler is not owned by the polynomial manager. If eh = 0, then it uninstall the event handler. */ void add_del_eh(del_eh * eh); @@ -426,7 +426,7 @@ namespace polynomial { polynomial * flip_sign_if_lm_neg(polynomial const * p); /** - \breif Return the gcd g of p and q. + \brief Return the gcd g of p and q. */ void gcd(polynomial const * p, polynomial const * q, polynomial_ref & g); @@ -853,7 +853,7 @@ namespace polynomial { void resultant(polynomial const * p, polynomial const * q, var x, polynomial_ref & r); /** - \brief Stroe in r the discriminant of p with respect to variable x. + \brief Store in r the discriminant of p with respect to variable x. discriminant(p, x, r) == resultant(p, derivative(p, x), x, r) */ void discriminant(polynomial const * p, var x, polynomial_ref & r); @@ -959,7 +959,7 @@ namespace polynomial { } /** - \brief Apply substiution [x -> p/q] in r. + \brief Apply substitution [x -> p/q] in r. That is, given r \in Z[x, y_1, .., y_m] return polynomial q^k * r(p/q, y_1, .., y_m), where k is the maximal degree of x in r. */ diff --git a/src/math/polynomial/upolynomial_factorization.cpp b/src/math/polynomial/upolynomial_factorization.cpp index 11a37648a..a1f6e6ec1 100644 --- a/src/math/polynomial/upolynomial_factorization.cpp +++ b/src/math/polynomial/upolynomial_factorization.cpp @@ -152,7 +152,7 @@ public: } /** - \brief 'Disagonalizes' the matrix using only column operations. The reusling matrix will have -1 at pivot + \brief 'Diagonalizes' the matrix using only column operations. The resulting matrix will have -1 at pivot elements. Returns the rank of the null space. */ unsigned diagonalize() { @@ -170,7 +170,7 @@ public: m_column_pivot[j] = i; m_row_pivot[i] = j; - // found a pivot, to make it -1 we compute the multuplier -p^-1 + // found a pivot, to make it -1 we compute the multiplier -p^-1 m_zpm.set(multiplier, get(i, j)); m_zpm.inv(multiplier); m_zpm.neg(multiplier); @@ -201,7 +201,7 @@ public: } /** - If rank of the matrix is n - r, we are interested in linearly indeprendent vectors v_1, ..., v_r (the basis of + If rank of the matrix is n - r, we are interested in linearly independent vectors v_1, ..., v_r (the basis of the null space), such that v_k A = 0. This method will give one at a time. The method returns true if vector has been computed properly. The first vector [1, 0, ..., 0] is ignored (m_null_row starts from 1). */ @@ -417,7 +417,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f, // construct the berlekamp Q matrix to get the null space berlekamp_matrix Q_I(upm, f); - // copy the inital polynomial to factors + // copy the initial polynomial to factors unsigned first_factor = factors.distinct_factors(); factors.push_back(f, 1); @@ -473,7 +473,7 @@ bool zp_factor_square_free_berlekamp(zp_manager & upm, numeral_vector const & f, // get the gcd upm.gcd(v_k.size(), v_k.c_ptr(), current_factor.size(), current_factor.c_ptr(), gcd); - // if the gcd is 1, or the the gcd is f, we just ignroe it + // if the gcd is 1, or the gcd is f, we just ignore it if (gcd.size() != 1 && gcd.size() != current_factor.size()) { // get the divisor also (no need to normalize the div, both are monic) @@ -568,13 +568,13 @@ bool check_hansel_lift(z_manager & upm, numeral_vector const & C, } /** - Performs a Hensel lift of A and B in Z_a to Z_b, where p is prime and and a = p^{a_k}, b = p^{b_k}, + Performs a Hensel lift of A and B in Z_a to Z_b, where p is prime and a = p^{a_k}, b = p^{b_k}, r = (a, b), with the following assumptions: - (1) UA + VB = 1 (mod a) + (1) UA + VB = 1 (mod a) (2) C = A*B (mod b) - (3) (l(A), r) = 1 (importand in order to divide by A, i.e. to invert l(A)) - (4) deg(A) + deg(B) = deg(C) + (3) (l(A), r) = 1 (important in order to divide by A, i.e. to invert l(A)) + (4) deg(A) + deg(B) = deg(C) The output of is two polynomials A1, B1 such that A1 = A (mod b), B1 = B (mod b), l(A1) = l(A), deg(A1) = deg(A), deg(B1) = deg(B) and C = A1 B1 (mod b*r). Such A1, B1 are unique if @@ -625,7 +625,7 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral // having (1) AU + BV = 1 (mod r) and (5) AT + BS = f (mod r), we know that // A*(fU) + B*(fV) = f (mod r), i.e. T = fU, S = fV is a solution // but we also know that we need an S with deg(S) <= deg(A) so we can do the following - // we know that l(A) is invertible so we can find the exact remainder of fV with A, i.e. find the qotient + // we know that l(A) is invertible so we can find the exact remainder of fV with A, i.e. find the quotient // t in the division and set // A*(fU + tB) + B*(fV - tA) = f // T = fU + tB, S = fU - tA @@ -1093,7 +1093,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs, continue; } - // if it's not square free, we also try somehting else + // if it's not square free, we also try something else scoped_numeral_vector f_pp_zp(nm); to_zp_manager(zp_upm, f_pp, f_pp_zp); @@ -1170,7 +1170,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs, zp_numeral_manager & zpe_nm = zpe_upm.m(); zp_factors zpe_fs(zpe_upm); - // this might give something bigger than p^e, but the lifting proocedure will update the zpe_nm + // this might give something bigger than p^e, but the lifting procedure will update the zpe_nm // zp factors are monic, so will be the zpe factors, i.e. f_pp = zpe_fs * lc(f_pp) (mod p^e) hensel_lift(upm, f_pp, zp_fs, e, zpe_fs); @@ -1182,7 +1182,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs, scoped_numeral f_pp_lc(nm); zpe_nm.set(f_pp_lc, f_pp.back()); - // we always keep in f_pp the the actual primitive part f_pp*lc(f_pp) + // we always keep in f_pp the actual primitive part f_pp*lc(f_pp) upm.mul(f_pp, f_pp_lc); // now we go through the combinations of factors to check construct the factorization @@ -1287,7 +1287,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs, fs.push_back(f_pp, k); } else { - // if a constant it must be 1 (it was primitve) + // if a constant it must be 1 (it was primitive) SASSERT(f_pp.size() == 1 && nm.is_one(f_pp.back())); } diff --git a/src/math/polynomial/upolynomial_factorization.h b/src/math/polynomial/upolynomial_factorization.h index 6fe0f2be6..c33f1844d 100644 --- a/src/math/polynomial/upolynomial_factorization.h +++ b/src/math/polynomial/upolynomial_factorization.h @@ -34,12 +34,12 @@ namespace upolynomial { typedef manager::scoped_numeral scoped_numeral; /** - \breif Factor f into f = f_1^k_1 * ... * p_n^k_n, such that p_i are square-free and coprime. + \brief Factor f into f = f_1^k_1 * ... * p_n^k_n, such that p_i are square-free and coprime. */ void zp_square_free_factor(zp_manager & zp_upm, numeral_vector const & f, zp_factors & sq_free_factors); /** - \brief Factor the monic square-free polynomial f from Z_p[x]. Returns true if factorization was sucesseful, or false + \brief Factor the monic square-free polynomial f from Z_p[x]. Returns true if factorization was successful, or false if f is an irreducible square-free polynomial in Z_p[x]. */ bool zp_factor_square_free(zp_manager & zp_upm, numeral_vector const & f, zp_factors & factors); @@ -55,17 +55,17 @@ namespace upolynomial { bool zp_factor_square_free_berlekamp(zp_manager & zp_upm, numeral_vector const & f, zp_factors & factors, bool randomized = true); /** - \brief Factor the polynomial f from Z_p[x]. Returns true if factorization was sucesseful, or false if f is + \brief Factor the polynomial f from Z_p[x]. Returns true if factorization was successful, or false if f is an irreducible polynomial in Z_p[x] */ bool zp_factor(zp_manager & zp_upm, numeral_vector const & f, zp_factors & factors); /** - \brief Performs a Hensel lift of A and B in Z_a to Z_b, where p is prime and and a = p^{a_k}, b = p^{b_k}, + \brief Performs a Hensel lift of A and B in Z_a to Z_b, where p is prime and a = p^{a_k}, b = p^{b_k}, r = (a, b), with the following assumptions: * UA + VB = 1 (mod a) * C = AB (mod b) - * (l(A), r) = 1 (importand in order to divide by A, i.e. to invert l(A)) + * (l(A), r) = 1 (important in order to divide by A, i.e. to invert l(A)) the output of is two polynomials A1, B1 (replacing A and B) such that A1 = A (mod b), B1 = B (mod b), l(A1) = l(A), deg(A1) = deg(A), deg(B1) = deg(B) and C = A1 B1 (mod b*r). Such A1, B1 are unique if r is prime. See [3] p. 138. @@ -82,7 +82,7 @@ namespace upolynomial { void hensel_lift(z_manager & upm, numeral_vector const & f, zp_factors const & factors_p, unsigned e, zp_factors & factors_pe); /** - \brief Factor the square-free polynomial f from Z[x]. Returns true if factorization was sucesseful, or false if + \brief Factor the square-free polynomial f from Z[x]. Returns true if factorization was successful, or false if f is an irreducible polynomial in Z[x]. The vector of factors is cleared. */ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs, factor_params const & ps = factor_params()); diff --git a/src/muz/rel/aig_exporter.cpp b/src/muz/rel/aig_exporter.cpp index bc98ab1f8..3fed47f80 100644 --- a/src/muz/rel/aig_exporter.cpp +++ b/src/muz/rel/aig_exporter.cpp @@ -32,7 +32,7 @@ namespace datalog { predicates.insert(I->first); } - // reserve pred id = 0 for initalization purposes + // reserve pred id = 0 for initialization purposes unsigned num_preds = (unsigned)predicates.size() + 1; // poor's man round-up log2 diff --git a/src/muz/rel/dl_sieve_relation.cpp b/src/muz/rel/dl_sieve_relation.cpp index 0d70212e2..7e274cbef 100644 --- a/src/muz/rel/dl_sieve_relation.cpp +++ b/src/muz/rel/dl_sieve_relation.cpp @@ -67,7 +67,7 @@ namespace datalog { } relation_base * sieve_relation::complement(func_decl* p) const { - //this is not precisely a complement, because we still treat the ignored collumns as + //this is not precisely a complement, because we still treat the ignored columns as //full, but it should give reasonable results inside the product relation relation_base * new_inner = get_inner().complement(p); return get_plugin().mk_from_inner(get_signature(), m_inner_cols.c_ptr(), new_inner); diff --git a/src/muz/rel/dl_sparse_table.h b/src/muz/rel/dl_sparse_table.h index a699cf165..d3481dc7f 100644 --- a/src/muz/rel/dl_sparse_table.h +++ b/src/muz/rel/dl_sparse_table.h @@ -424,7 +424,7 @@ namespace datalog { /** \c array \c removed_cols contains column indexes to be removed in ascending order and - is terminated by a number greated than the highest column index of a join the the two tables. + is terminated by a number greater than the highest column index of a join the two tables. This is to simplify the traversal of the array when building facts. */ static void concatenate_rows(const column_layout & layout1, const column_layout & layout2, @@ -436,7 +436,7 @@ namespace datalog { columns from t2 using indexing. \c array \c removed_cols contains column indexes to be removed in ascending order and - is terminated by a number greated than the highest column index of a join the the two tables. + is terminated by a number greater than the highest column index of a join the two tables. This is to simplify the traversal of the array when building facts. \c tables_swapped value means that the resulting facts should contain facts from t2 first, diff --git a/src/muz/spacer/spacer_matrix.h b/src/muz/spacer/spacer_matrix.h index 4fc418f2b..a5ee909b2 100644 --- a/src/muz/spacer/spacer_matrix.h +++ b/src/muz/spacer/spacer_matrix.h @@ -25,7 +25,7 @@ namespace spacer { class spacer_matrix { public: - spacer_matrix(unsigned m, unsigned n); // m rows, n colums + spacer_matrix(unsigned m, unsigned n); // m rows, n columns unsigned num_rows(); unsigned num_cols(); diff --git a/src/nlsat/nlsat_explain.cpp b/src/nlsat/nlsat_explain.cpp index 3a6c3f067..8d32a0edf 100644 --- a/src/nlsat/nlsat_explain.cpp +++ b/src/nlsat/nlsat_explain.cpp @@ -242,7 +242,7 @@ namespace nlsat { } /** - \breif Store in ps the polynomials occurring in the given literals. + \brief Store in ps the polynomials occurring in the given literals. */ void collect_polys(unsigned num, literal const * ls, polynomial_ref_vector & ps) { ps.reset(); @@ -332,7 +332,7 @@ namespace nlsat { if (!is_zero(lc)) { if (sign(lc) != 0) return; - // lc is not the zero polynomial, but it vanished in the current interpretaion. + // lc is not the zero polynomial, but it vanished in the current interpretation. // so we keep searching... add_zero_assumption(lc); } diff --git a/src/test/rational.cpp b/src/test/rational.cpp index 7b5e474f0..0618a01fb 100644 --- a/src/test/rational.cpp +++ b/src/test/rational.cpp @@ -387,9 +387,9 @@ static void tst9() { static void tst10(bool use_ints) { if (use_ints) - std::cout << "Testing multiplication performace using small ints\n"; + std::cout << "Testing multiplication performance using small ints\n"; else - std::cout << "Testing multiplication performace using small rationals\n"; + std::cout << "Testing multiplication performance using small rationals\n"; vector vals; vector vals2; vector fvals; diff --git a/src/util/gparams.h b/src/util/gparams.h index 894732890..7ddaf0ccb 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -47,7 +47,7 @@ public: set_global_param('pp.decimal', 'true') will set the parameter "decimal" in the module "pp" to true. - An exception is thrown if the the parameter name is unknown, or if the value is incorrect. + An exception is thrown if the parameter name is unknown, or if the value is incorrect. */ static void set(char const * name, char const * value); static void set(symbol const & name, char const * value); @@ -57,7 +57,7 @@ public: If the parameter is not set, then it just returns 'default'. - An exception is thrown if the the parameter name is unknown. + An exception is thrown if the parameter name is unknown. */ static std::string get_value(char const * name); static std::string get_value(symbol const & name); diff --git a/src/util/mpz.h b/src/util/mpz.h index f04430e17..f4629958f 100644 --- a/src/util/mpz.h +++ b/src/util/mpz.h @@ -187,7 +187,7 @@ class mpz_manager { /** \brief Set \c a with the value stored at m_tmp[IDX], and the given sign. - \c sz is an overapproximation of the the size of the number stored at \c tmp. + \c sz is an overapproximation of the size of the number stored at \c tmp. */ template void set(mpz & a, int sign, unsigned sz); From ad3b0ecad0dc32ac06295a3164def5e029d7d66d Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 2 Feb 2018 19:27:36 +0000 Subject: [PATCH 150/263] Fixed pattern rewriting to produce only valid patterns (which led to a segfault). Bug reported by Youcheng Sun. --- src/ast/rewriter/rewriter_def.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/ast/rewriter/rewriter_def.h b/src/ast/rewriter/rewriter_def.h index 2abd6d467..5a3b930c8 100644 --- a/src/ast/rewriter/rewriter_def.h +++ b/src/ast/rewriter/rewriter_def.h @@ -497,23 +497,27 @@ void rewriter_tpl::process_quantifier(quantifier * q, frame & fr) { SASSERT(fr.m_spos + num_children == result_stack().size()); expr * const * it = result_stack().c_ptr() + fr.m_spos; expr * new_body = *it; - expr * const * new_pats; - expr * const * new_no_pats; + unsigned num_pats = q->get_num_patterns(); + unsigned num_no_pats = q->get_num_no_patterns(); + expr_ref_vector new_pats(m_manager, num_pats, q->get_patterns()); + expr_ref_vector new_no_pats(m_manager, num_no_pats, q->get_no_patterns()); if (rewrite_patterns()) { TRACE("reduce_quantifier_bug", tout << "rewrite patterns\n";); - new_pats = it + 1; - new_no_pats = new_pats + q->get_num_patterns(); - } - else { - new_pats = q->get_patterns(); - new_no_pats = q->get_no_patterns(); + expr * const * np = it + 1; + expr * const * nnp = np + num_pats; + for (unsigned i = 0; i < num_pats; i++) + if (m_manager.is_pattern(np[i])) + new_pats[i] = np[i]; + for (unsigned i = 0; i < num_no_pats; i++) + if (m_manager.is_pattern(nnp[i])) + new_no_pats[i] = nnp[i]; } if (ProofGen) { - quantifier_ref new_q(m().update_quantifier(q, q->get_num_patterns(), new_pats, q->get_num_no_patterns(), new_no_pats, new_body), m()); + quantifier_ref new_q(m().update_quantifier(q, num_pats, new_pats.c_ptr(), num_no_pats, new_no_pats.c_ptr(), new_body), m()); m_pr = q == new_q ? 0 : m().mk_quant_intro(q, new_q, result_pr_stack().get(fr.m_spos)); m_r = new_q; proof_ref pr2(m()); - if (m_cfg.reduce_quantifier(new_q, new_body, new_pats, new_no_pats, m_r, pr2)) { + if (m_cfg.reduce_quantifier(new_q, new_body, new_pats.c_ptr(), new_no_pats.c_ptr(), m_r, pr2)) { m_pr = m().mk_transitivity(m_pr, pr2); } TRACE("reduce_quantifier_bug", tout << "m_pr is_null: " << (m_pr.get() == 0) << "\n"; @@ -524,9 +528,9 @@ void rewriter_tpl::process_quantifier(quantifier * q, frame & fr) { else { expr_ref tmp(m()); TRACE("reduce_quantifier_bug", tout << mk_ismt2_pp(q, m()) << " " << mk_ismt2_pp(new_body, m()) << "\n";); - if (!m_cfg.reduce_quantifier(q, new_body, new_pats, new_no_pats, m_r, m_pr)) { + if (!m_cfg.reduce_quantifier(q, new_body, new_pats.c_ptr(), new_no_pats.c_ptr(), m_r, m_pr)) { if (fr.m_new_child) { - m_r = m().update_quantifier(q, q->get_num_patterns(), new_pats, q->get_num_no_patterns(), new_no_pats, new_body); + m_r = m().update_quantifier(q, num_pats, new_pats.c_ptr(), num_no_pats, new_no_pats.c_ptr(), new_body); } else { TRACE("rewriter_reuse", tout << "reusing:\n" << mk_ismt2_pp(q, m()) << "\n";); From 8689921e9cf96426ca47054f3f618300e7e1ce27 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Sat, 3 Feb 2018 15:16:23 +0000 Subject: [PATCH 151/263] Fixed missing bit of precision in fp.to_ubv/fp.to_sbv. Thanks to Youcheng Sun for reporting this bug. --- src/ast/fpa/fpa2bv_converter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp index d2a946e0c..b2c07d56e 100644 --- a/src/ast/fpa/fpa2bv_converter.cpp +++ b/src/ast/fpa/fpa2bv_converter.cpp @@ -3139,6 +3139,7 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args unsigned bv_sz = (unsigned)f->get_parameter(0).get_int(); expr_ref bv0(m), bv1(m); + bv0 = m_bv_util.mk_numeral(0, 1); bv1 = m_bv_util.mk_numeral(1, 1); expr_ref x_is_nan(m), x_is_inf(m), x_is_zero(m), x_is_neg(m), x_is_nzero(m); @@ -3188,9 +3189,9 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args exp_m_lz = m_bv_util.mk_bv_sub(m_bv_util.mk_sign_extend(2, exp), m_bv_util.mk_zero_extend(2, lz)); - // big_sig is +- [... bv_sz+2 bits ...].[r][g][ ... sbits-1 ... ] - big_sig = m_bv_util.mk_zero_extend(bv_sz+2, sig); - unsigned big_sig_sz = sig_sz+bv_sz+2; + // big_sig is +- [... bv_sz+2 bits ...][1].[r][ ... sbits-1 ... ] + big_sig = m_bv_util.mk_concat(m_bv_util.mk_zero_extend(bv_sz + 2, sig), bv0); + unsigned big_sig_sz = sig_sz+1+bv_sz+2; SASSERT(m_bv_util.get_bv_size(big_sig) == big_sig_sz); is_neg_shift = m_bv_util.mk_sle(exp_m_lz, m_bv_util.mk_numeral(0, ebits+2)); From c3ed9860318d3d9ae2b5f9c5da31264188b05794 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Sat, 3 Feb 2018 16:44:44 +0000 Subject: [PATCH 152/263] Fixed RNA FP rounding mode semantics. Fixes #1190 and bugs reported by Youcheng Sun. --- src/ast/fpa/fpa2bv_converter.cpp | 6 +----- src/util/mpf.cpp | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp index b2c07d56e..7c13d4315 100644 --- a/src/ast/fpa/fpa2bv_converter.cpp +++ b/src/ast/fpa/fpa2bv_converter.cpp @@ -3746,14 +3746,10 @@ expr_ref fpa2bv_converter::mk_rounding_decision(expr * rm, expr * sgn, expr * la expr * nround_lors[2] = { not_round, not_lors }; expr * pos_args[2] = { sgn, not_rors }; expr * neg_args[2] = { not_sgn, not_rors }; - expr * nl_r[2] = { last, not_round }; - expr * nl_nr_sn[3] = { not_last, not_round, not_sticky }; expr_ref inc_teven(m), inc_taway(m), inc_pos(m), inc_neg(m); inc_teven = m_bv_util.mk_bv_not(m_bv_util.mk_bv_or(2, nround_lors)); - expr *taway_args[2] = { m_bv_util.mk_bv_not(m_bv_util.mk_bv_or(2, nl_r)), - m_bv_util.mk_bv_not(m_bv_util.mk_bv_or(3, nl_nr_sn)) }; - inc_taway = m_bv_util.mk_bv_or(2, taway_args); + inc_taway = round; inc_pos = m_bv_util.mk_bv_not(m_bv_util.mk_bv_or(2, pos_args)); inc_neg = m_bv_util.mk_bv_not(m_bv_util.mk_bv_or(2, neg_args)); diff --git a/src/util/mpf.cpp b/src/util/mpf.cpp index 9e309a726..b9829f02d 100644 --- a/src/util/mpf.cpp +++ b/src/util/mpf.cpp @@ -2045,7 +2045,7 @@ void mpf_manager::round(mpf_rounding_mode rm, mpf & o) { bool inc = false; switch (rm) { case MPF_ROUND_NEAREST_TEVEN: inc = round && (last || sticky); break; - case MPF_ROUND_NEAREST_TAWAY: inc = round && (!last || sticky); break; + case MPF_ROUND_NEAREST_TAWAY: inc = round; break; case MPF_ROUND_TOWARD_POSITIVE: inc = (!o.sign && (round || sticky)); break; case MPF_ROUND_TOWARD_NEGATIVE: inc = (o.sign && (round || sticky)); break; case MPF_ROUND_TOWARD_ZERO: inc = false; break; From 333374229d99157f6edd5bc6d21af595ed89dbd2 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Sat, 3 Feb 2018 16:48:05 +0000 Subject: [PATCH 153/263] Fixed UFs for unspecified cases of FP conversion operators. Thanks for Youcheng Sun for reporting this bug. --- src/ast/fpa/fpa2bv_converter.cpp | 36 ++++++++++++++++++-------------- src/ast/fpa/fpa2bv_converter.h | 1 + 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp index 7c13d4315..df5d56505 100644 --- a/src/ast/fpa/fpa2bv_converter.cpp +++ b/src/ast/fpa/fpa2bv_converter.cpp @@ -3098,13 +3098,11 @@ void fpa2bv_converter::mk_to_ieee_bv_unspecified(func_decl * f, unsigned num, ex join_fp(result, result); } else { - expr * n = args[0]; - expr_ref n_bv(m); - join_fp(n, n_bv); + expr_ref nw = nan_wrap(args[0]); - sort * domain[1] = { m.get_sort(n_bv) }; + sort * domain[1] = { m.get_sort(nw) }; func_decl * f_bv = mk_bv_uf(f, domain, f->get_range()); - result = m.mk_app(f_bv, n_bv); + result = m.mk_app(f_bv, nw); expr_ref exp_bv(m), exp_all_ones(m); exp_bv = m_bv_util.mk_extract(ebits+sbits-2, sbits-1, result); @@ -3280,6 +3278,17 @@ void fpa2bv_converter::mk_to_sbv(func_decl * f, unsigned num, expr * const * arg mk_to_bv(f, num, args, true, result); } +expr_ref fpa2bv_converter::nan_wrap(expr * n) { + expr_ref n_bv(m), arg_is_nan(m), nan(m), nan_bv(m), res(m); + mk_is_nan(n, arg_is_nan); + mk_nan(m.get_sort(n), nan); + join_fp(nan, nan_bv); + join_fp(n, n_bv); + res = expr_ref(m.mk_ite(arg_is_nan, nan_bv, n_bv), m); + SASSERT(is_well_sorted(m, res)); + return res; +} + void fpa2bv_converter::mk_to_bv_unspecified(func_decl * f, unsigned num, expr * const * args, expr_ref & result) { SASSERT(num == 2); SASSERT(m_util.is_bv2rm(args[0])); @@ -3289,13 +3298,10 @@ void fpa2bv_converter::mk_to_bv_unspecified(func_decl * f, unsigned num, expr * result = m_bv_util.mk_numeral(0, m_bv_util.get_bv_size(f->get_range())); else { expr * rm_bv = to_app(args[0])->get_arg(0); - expr * n = args[1]; - expr_ref n_bv(m); - join_fp(n, n_bv); - - sort * domain[2] = { m.get_sort(rm_bv), m.get_sort(n_bv) }; + expr_ref nw = nan_wrap(args[1]); + sort * domain[2] = { m.get_sort(rm_bv), m.get_sort(nw) }; func_decl * f_bv = mk_bv_uf(f, domain, f->get_range()); - result = m.mk_app(f_bv, rm_bv, n_bv); + result = m.mk_app(f_bv, rm_bv, nw); } TRACE("fpa2bv_to_bv_unspecified", tout << "result=" << mk_ismt2_pp(result, m) << std::endl;); @@ -3309,12 +3315,10 @@ void fpa2bv_converter::mk_to_real_unspecified(func_decl * f, unsigned num, expr result = m_arith_util.mk_numeral(rational(0), false); else { expr * n = args[0]; - expr_ref n_bv(m); - join_fp(n, n_bv); - - sort * domain[1] = { m.get_sort(n_bv) }; + expr_ref nw = nan_wrap(n); + sort * domain[1] = { m.get_sort(nw) }; func_decl * f_bv = mk_bv_uf(f, domain, f->get_range()); - result = m.mk_app(f_bv, n_bv); + result = m.mk_app(f_bv, nw); } } diff --git a/src/ast/fpa/fpa2bv_converter.h b/src/ast/fpa/fpa2bv_converter.h index f0e50ba2d..062f7afe9 100644 --- a/src/ast/fpa/fpa2bv_converter.h +++ b/src/ast/fpa/fpa2bv_converter.h @@ -219,6 +219,7 @@ private: void mk_to_fp_float(sort * s, expr * rm, expr * x, expr_ref & result); func_decl * mk_bv_uf(func_decl * f, sort * const * domain, sort * range); + expr_ref nan_wrap(expr * n); }; #endif From 20d6543538e993a596b77175a22476e7372d77e5 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 4 Feb 2018 12:56:21 -0800 Subject: [PATCH 154/263] set uninitialized fields. Maybe related to #1468 Signed-off-by: Nikolaj Bjorner --- src/interp/iz3interp.cpp | 4 ++++ src/interp/iz3translate.cpp | 33 +++++++++++++++++---------------- src/interp/iz3translate.h | 3 ++- src/sat/sat_clause.cpp | 2 ++ src/sat/sat_solver.cpp | 5 +---- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/interp/iz3interp.cpp b/src/interp/iz3interp.cpp index c1c4588cc..6f918bccb 100755 --- a/src/interp/iz3interp.cpp +++ b/src/interp/iz3interp.cpp @@ -255,9 +255,11 @@ public: throw interpolation_failure(msg); } catch (const iz3translation::unsupported &) { + TRACE("iz3", tout << "unsupported\n";); throw interpolation_error(); } catch (const iz3proof::proof_error &) { + TRACE("iz3", tout << "proof error\n";); throw interpolation_error(); } profiling::timer_stop("Proof translation"); @@ -304,9 +306,11 @@ public: throw interpolation_failure(msg); } catch (const iz3translation::unsupported &) { + TRACE("iz3", tout << "unsupported\n";); throw interpolation_error(); } catch (const iz3proof::proof_error &) { + TRACE("iz3", tout << "proof error\n";); throw interpolation_error(); } profiling::timer_stop("Proof translation"); diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp index ce2249a88..b108ba047 100755 --- a/src/interp/iz3translate.cpp +++ b/src/interp/iz3translate.cpp @@ -983,6 +983,7 @@ public: ast get_bounded_variable(const ast &ineq, bool &lb){ ast nineq = normalize_inequality(ineq); ast lhs = arg(nineq,0); + lhs.raw(); switch(op(lhs)){ case Uninterpreted: lb = false; @@ -993,10 +994,10 @@ public: else if(arg(lhs,0) == make_int(rational(-1))) lb = true; else - throw unsupported(); + throw unsupported(lhs); return arg(lhs,1); default: - throw unsupported(); + throw unsupported(lhs); } } @@ -1101,10 +1102,10 @@ public: rational xcoeff = get_first_coefficient(arg(x,0),xvar); rational ycoeff = get_first_coefficient(arg(y,0),yvar); if(xcoeff == rational(0) || ycoeff == rational(0) || xvar != yvar) - throw unsupported(); // can be caused by non-linear arithmetic + throw unsupported(x); // can be caused by non-linear arithmetic rational ratio = xcoeff/ycoeff; if(denominator(ratio) != rational(1)) - throw unsupported(); // can this ever happen? + throw unsupported(y); // can this ever happen? return make_int(ratio); // better be integer! } @@ -1113,7 +1114,7 @@ public: get_assign_bounds_coeffs(proof,farkas_coeffs); int nargs = num_args(con); if(nargs != (int)(farkas_coeffs.size())) - throw unsupported(); // should never happen + throw unsupported(proof); // should never happen #if 0 if(farkas_coeffs[0] != make_int(rational(1))) farkas_coeffs[0] = make_int(rational(1)); @@ -1237,7 +1238,7 @@ public: if(pr(rew) == PR_REWRITE){ return clause; // just hope the rewrite does nothing! } - throw unsupported(); + throw unsupported(rew); } @@ -1311,7 +1312,7 @@ public: ast commute_equality_iff(const ast &con){ if(op(con) != Iff || op(arg(con,0)) != Equal) - throw unsupported(); + throw unsupported(con); return make(Iff,commute_equality(arg(con,0)),commute_equality(arg(con,1))); } @@ -1337,7 +1338,7 @@ public: prs.push_back(con); return clone(proof,prs); default: - throw unsupported(); + throw unsupported(proof); } } @@ -1837,7 +1838,7 @@ public: for(unsigned i = 0; i < nprems; i++) if(sym(args[i]) == commute && !(dk == PR_TRANSITIVITY || dk == PR_MODUS_PONENS || dk == PR_SYMMETRY || (dk == PR_MONOTONICITY && op(arg(con,0)) == Not))) - throw unsupported(); + throw unsupported(proof); switch(dk){ case PR_TRANSITIVITY: { @@ -1908,7 +1909,7 @@ public: int nargs = num_args(con); if(farkas_coeffs.size() != (unsigned)nargs){ pfgoto(proof); - throw unsupported(); + throw unsupported(proof); } for(int i = 0; i < nargs; i++){ ast lit = mk_not(arg(con,i)); @@ -1946,7 +1947,7 @@ public: get_broken_gcd_test_coeffs(proof,farkas_coeffs); if(farkas_coeffs.size() != nprems){ pfgoto(proof); - throw unsupported(); + throw unsupported(proof); } std::vector my_prems; my_prems.resize(2); std::vector my_prem_cons; my_prem_cons.resize(2); @@ -1969,7 +1970,7 @@ public: if(args.size() > 0) res = GomoryCutRule2Farkas(proof, conc(proof), args); else - throw unsupported(); + throw unsupported(proof); break; } case EqPropagateKind: { @@ -1988,7 +1989,7 @@ public: break; } default: - throw unsupported(); + throw unsupported(proof); } break; case ArrayTheory: {// nothing fancy for this @@ -2000,7 +2001,7 @@ public: break; } default: - throw unsupported(); + throw unsupported(proof); } break; } @@ -2024,7 +2025,7 @@ public: if(is_local(con)) res = args[0]; else - throw unsupported(); + throw unsupported(con); break; } case PR_COMMUTATIVITY: { @@ -2048,7 +2049,7 @@ public: IF_VERBOSE(0, verbose_stream() << "Unsupported proof rule: " << expr_ref((expr*)proof.raw(), *proof.mgr()) << "\n";); // pfgoto(proof); // SASSERT(0 && "translate_main: unsupported proof rule"); - throw unsupported(); + throw unsupported(proof); } } diff --git a/src/interp/iz3translate.h b/src/interp/iz3translate.h index 8ecafbd3a..d80c3b3fe 100755 --- a/src/interp/iz3translate.h +++ b/src/interp/iz3translate.h @@ -36,7 +36,8 @@ class iz3translation : public iz3base { /** This is thrown when the proof cannot be translated. */ struct unsupported: public iz3_exception { - unsupported(): iz3_exception("unsupported") { } + raw_ast* m_ast; + unsupported(ast const& a): iz3_exception("unsupported"), m_ast(a.raw()) { } }; static iz3translation *create(iz3mgr &mgr, diff --git a/src/sat/sat_clause.cpp b/src/sat/sat_clause.cpp index c5829ae4e..76a1ee8c3 100644 --- a/src/sat/sat_clause.cpp +++ b/src/sat/sat_clause.cpp @@ -33,6 +33,8 @@ namespace sat { m_frozen(false), m_reinit_stack(false), m_inact_rounds(0) { + m_psm = 0; + m_glue = 0; memcpy(m_lits, lits, sizeof(literal) * sz); mark_strengthened(); SASSERT(check_approx()); diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index 03c17aaf0..91bff7406 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -2460,10 +2460,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. From bf04c38a639556ef17ef7afc5eea1cd769626b51 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 4 Feb 2018 13:06:14 -0800 Subject: [PATCH 155/263] add logging for #1470 Signed-off-by: Nikolaj Bjorner --- src/interp/iz3translate.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp index b108ba047..4831e7eaf 100755 --- a/src/interp/iz3translate.cpp +++ b/src/interp/iz3translate.cpp @@ -49,6 +49,9 @@ using namespace stl_ext; prover is used. */ + +#define throw_unsupported(_e_) { TRACE("iz3", tout << expr_ref((expr*)_e_.raw(), *_e_.mgr()) << "\n";); throw unsupported(_e_); } + class iz3translation_full : public iz3translation { public: @@ -994,10 +997,10 @@ public: else if(arg(lhs,0) == make_int(rational(-1))) lb = true; else - throw unsupported(lhs); + throw_unsupported(lhs); return arg(lhs,1); default: - throw unsupported(lhs); + throw_unsupported(lhs); } } @@ -1102,10 +1105,10 @@ public: rational xcoeff = get_first_coefficient(arg(x,0),xvar); rational ycoeff = get_first_coefficient(arg(y,0),yvar); if(xcoeff == rational(0) || ycoeff == rational(0) || xvar != yvar) - throw unsupported(x); // can be caused by non-linear arithmetic + throw_unsupported(x); // can be caused by non-linear arithmetic rational ratio = xcoeff/ycoeff; if(denominator(ratio) != rational(1)) - throw unsupported(y); // can this ever happen? + throw_unsupported(y); // can this ever happen? return make_int(ratio); // better be integer! } @@ -1114,7 +1117,7 @@ public: get_assign_bounds_coeffs(proof,farkas_coeffs); int nargs = num_args(con); if(nargs != (int)(farkas_coeffs.size())) - throw unsupported(proof); // should never happen + throw_unsupported(proof); // should never happen #if 0 if(farkas_coeffs[0] != make_int(rational(1))) farkas_coeffs[0] = make_int(rational(1)); @@ -1238,7 +1241,7 @@ public: if(pr(rew) == PR_REWRITE){ return clause; // just hope the rewrite does nothing! } - throw unsupported(rew); + throw_unsupported(rew); } @@ -1312,7 +1315,7 @@ public: ast commute_equality_iff(const ast &con){ if(op(con) != Iff || op(arg(con,0)) != Equal) - throw unsupported(con); + throw_unsupported(con); return make(Iff,commute_equality(arg(con,0)),commute_equality(arg(con,1))); } @@ -1338,7 +1341,7 @@ public: prs.push_back(con); return clone(proof,prs); default: - throw unsupported(proof); + throw_unsupported(proof); } } @@ -1838,7 +1841,7 @@ public: for(unsigned i = 0; i < nprems; i++) if(sym(args[i]) == commute && !(dk == PR_TRANSITIVITY || dk == PR_MODUS_PONENS || dk == PR_SYMMETRY || (dk == PR_MONOTONICITY && op(arg(con,0)) == Not))) - throw unsupported(proof); + throw_unsupported(proof); switch(dk){ case PR_TRANSITIVITY: { @@ -1909,7 +1912,7 @@ public: int nargs = num_args(con); if(farkas_coeffs.size() != (unsigned)nargs){ pfgoto(proof); - throw unsupported(proof); + throw_unsupported(proof); } for(int i = 0; i < nargs; i++){ ast lit = mk_not(arg(con,i)); @@ -1947,7 +1950,7 @@ public: get_broken_gcd_test_coeffs(proof,farkas_coeffs); if(farkas_coeffs.size() != nprems){ pfgoto(proof); - throw unsupported(proof); + throw_unsupported(proof); } std::vector my_prems; my_prems.resize(2); std::vector my_prem_cons; my_prem_cons.resize(2); @@ -1970,7 +1973,7 @@ public: if(args.size() > 0) res = GomoryCutRule2Farkas(proof, conc(proof), args); else - throw unsupported(proof); + throw_unsupported(proof); break; } case EqPropagateKind: { @@ -1989,7 +1992,7 @@ public: break; } default: - throw unsupported(proof); + throw_unsupported(proof); } break; case ArrayTheory: {// nothing fancy for this @@ -2001,7 +2004,7 @@ public: break; } default: - throw unsupported(proof); + throw_unsupported(proof); } break; } @@ -2025,7 +2028,7 @@ public: if(is_local(con)) res = args[0]; else - throw unsupported(con); + throw_unsupported(con); break; } case PR_COMMUTATIVITY: { @@ -2049,7 +2052,7 @@ public: IF_VERBOSE(0, verbose_stream() << "Unsupported proof rule: " << expr_ref((expr*)proof.raw(), *proof.mgr()) << "\n";); // pfgoto(proof); // SASSERT(0 && "translate_main: unsupported proof rule"); - throw unsupported(proof); + throw_unsupported(proof); } } From 885dfad237e897920618641fafe1f1dd31c4a4f9 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 4 Feb 2018 20:54:21 -0800 Subject: [PATCH 156/263] fix #1458 Signed-off-by: Nikolaj Bjorner --- src/sat/sat_solver.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index 91bff7406..4cb7339d1 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -2715,6 +2715,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(); @@ -2734,8 +2735,10 @@ namespace sat { break; } } - gc_var(lit.var()); + gc_var(lit.var()); } + m_qhead = 0; + propagate(false); } void solver::pop_to_base_level() { From a5caa506067a949afc445c5bf467fe8403538ec9 Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Mon, 5 Feb 2018 09:42:56 -0800 Subject: [PATCH 157/263] adding template definitions Signed-off-by: Lev Nachmanson --- src/util/lp/lp_solver_instances.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/lp/lp_solver_instances.cpp b/src/util/lp/lp_solver_instances.cpp index 599a0a8bc..4de1f74c8 100644 --- a/src/util/lp/lp_solver_instances.cpp +++ b/src/util/lp/lp_solver_instances.cpp @@ -54,3 +54,5 @@ template void lp::lp_solver::scale(); template void lp::lp_solver::set_scaled_cost(unsigned int); template lp::lp_solver::~lp_solver(); template double lp::lp_solver::get_column_value_by_name(std::string) const; +template std::string lp::lp_solver::get_column_name(unsigned int) const; +template std::string lp::lp_solver::get_column_name(unsigned int) const; From 3e810d6c547e404cbc96aea0972485434d0baecd Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 5 Feb 2018 16:46:49 -0800 Subject: [PATCH 158/263] remove static from format (not thread safe), remove std::move #1466 Signed-off-by: Nikolaj Bjorner --- src/ast/format.cpp | 4 ++-- src/ast/proofs/proof_utils.h | 2 +- src/muz/rel/dl_instruction.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ast/format.cpp b/src/ast/format.cpp index 835892121..6c2a02989 100644 --- a/src/ast/format.cpp +++ b/src/ast/format.cpp @@ -151,7 +151,7 @@ namespace format_ns { } format * mk_int(ast_manager & m, int i) { - static char buffer[128]; + char buffer[128]; #ifdef _WINDOWS sprintf_s(buffer, ARRAYSIZE(buffer), "%d", i); #else @@ -161,7 +161,7 @@ namespace format_ns { } format * mk_unsigned(ast_manager & m, unsigned u) { - static char buffer[128]; + char buffer[128]; #ifdef _WINDOWS sprintf_s(buffer, ARRAYSIZE(buffer), "%u", u); #else diff --git a/src/ast/proofs/proof_utils.h b/src/ast/proofs/proof_utils.h index 473df31e6..455f39c4f 100644 --- a/src/ast/proofs/proof_utils.h +++ b/src/ast/proofs/proof_utils.h @@ -88,7 +88,7 @@ class elim_aux_assertions { app_ref m_aux; public: - elim_aux_assertions(app_ref aux) : m_aux(std::move(aux)) {} + elim_aux_assertions(app_ref const& aux) : m_aux(aux) {} void mk_or_core(expr_ref_vector &args, expr_ref &res) { diff --git a/src/muz/rel/dl_instruction.cpp b/src/muz/rel/dl_instruction.cpp index 0a33e99f1..26139fb7c 100644 --- a/src/muz/rel/dl_instruction.cpp +++ b/src/muz/rel/dl_instruction.cpp @@ -190,8 +190,8 @@ namespace datalog { func_decl_ref m_pred; reg_idx m_reg; public: - instr_io(bool store, func_decl_ref pred, reg_idx reg) - : m_store(store), m_pred(std::move(pred)), m_reg(reg) {} + instr_io(bool store, func_decl_ref const& pred, reg_idx reg) + : m_store(store), m_pred(pred), m_reg(reg) {} virtual bool perform(execution_context & ctx) { log_verbose(ctx); if (m_store) { From a1d4e485a4435a0e5de38ba17337fa7fd77953ae Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 5 Feb 2018 18:33:31 -0800 Subject: [PATCH 159/263] fix #1469 Signed-off-by: Nikolaj Bjorner --- src/qe/qe.cpp | 71 +++++++++++++++++++------------------- src/qe/qe.h | 2 +- src/qe/qe_arith_plugin.cpp | 43 +++++++++++++++-------- src/qe/qe_sat_tactic.cpp | 2 +- 4 files changed, 65 insertions(+), 53 deletions(-) diff --git a/src/qe/qe.cpp b/src/qe/qe.cpp index 061f403e3..0a3f880b7 100644 --- a/src/qe/qe.cpp +++ b/src/qe/qe.cpp @@ -130,8 +130,7 @@ namespace qe { visited.mark(e, true); } } - for (unsigned i = 0; i < conjs.size(); ++i) { - expr* e = conjs[i].get(); + for (expr* e : conjs) { bool cv = contains_var.is_marked(e); bool cu = contains_uf.is_marked(e); if (cv && cu) { @@ -989,11 +988,11 @@ namespace qe { todo.pop_back(); if (st->m_children.empty() && st->fml() && st->m_vars.empty() && !st->has_var()) { + TRACE("qe", st->display(tout << "appending leaf\n");); result.push_back(st->fml()); } - for (unsigned i = 0; i < st->m_children.size(); ++i) { - todo.push_back(st->m_children[i]); - } + for (auto * ch : st->m_children) + todo.push_back(ch); } } @@ -1020,9 +1019,7 @@ namespace qe { void reset() { TRACE("qe",tout << "resetting\n";); - for (unsigned i = 0; i < m_children.size(); ++i) { - dealloc(m_children[i]); - } + for (auto* ch : m_children) dealloc(ch); m_pos.reset(); m_neg.reset(); m_children.reset(); @@ -1046,9 +1043,10 @@ namespace qe { } unsigned num_free_vars() const { return m_vars.size(); } - app* const* free_vars() const { return m_vars.c_ptr(); } + // app* const* free_vars() const { return m_vars.c_ptr(); } + app_ref_vector const& free_vars() const { return m_vars; } app* free_var(unsigned i) const { return m_vars[i]; } - void reset_free_vars() { m_vars.reset(); } + void reset_free_vars() { TRACE("qe", tout << m_vars << "\n";); m_vars.reset(); } atom_set const& pos_atoms() const { return m_pos; } atom_set const& neg_atoms() const { return m_neg; } @@ -1119,7 +1117,7 @@ namespace qe { st->init(fml); st->m_vars.append(m_vars.size(), m_vars.c_ptr()); SASSERT(invariant()); - TRACE("qe", tout << mk_pp(m_fml, m) << " child: " << mk_pp(fml, m) << "\n";); + TRACE("qe", display_node(tout); st->display_node(tout);); return st; } @@ -1133,7 +1131,7 @@ namespace qe { m_branch_index.insert(branch_id, index); st->m_vars.append(m_vars.size(), m_vars.c_ptr()); SASSERT(invariant()); - //TRACE("qe", tout << mk_pp(m_fml, m) << " child: " << mk_pp(st->fml(), m) << "\n";); + TRACE("qe", display_node(tout); st->display_node(tout);); return st; } @@ -1141,27 +1139,29 @@ namespace qe { display(out, ""); } - void display(std::ostream& out, char const* indent) const { - - out << indent << "node\n"; + void display_node(std::ostream& out, char const* indent = "") const { + out << indent << "node " << std::hex << this << std::dec << "\n"; if (m_var) { - out << indent << " var: " << mk_ismt2_pp(m_var.get(), m) << "\n"; + out << indent << " var: " << m_var << "\n"; } - for (unsigned i = 0; i < m_vars.size(); ++i) { - out << indent << " free: " << mk_ismt2_pp(m_vars[i], m) << "\n"; + for (app* v : m_vars) { + out << indent << " free: " << mk_pp(v, m) << "\n"; } if (m_fml) { - out << indent << " fml: " << mk_ismt2_pp(m_fml.get(), m) << "\n"; + out << indent << " fml: " << m_fml << "\n"; } for (unsigned i = 0; i < m_def.size(); ++i) { out << indent << " def: " << m_def.var(i)->get_name() << " = " << mk_ismt2_pp(m_def.def(i), m) << "\n"; } out << indent << " branches: " << m_num_branches << "\n"; + } + void display(std::ostream& out, char const* indent) const { + display_node(out, indent); std::string new_indent(indent); new_indent += " "; - for (unsigned i = 0; i < m_children.size(); ++i) { - m_children[i]->display(out, new_indent.c_str()); + for (auto * ch : m_children) { + ch->display(out, new_indent.c_str()); } } @@ -1214,6 +1214,7 @@ namespace qe { out << "(push)\n"; pp.display_smt2(out, fml); out << "(pop)\n\n"; +#if 0 DEBUG_CODE( smt_params params; params.m_simplify_bit2int = true; @@ -1227,7 +1228,8 @@ namespace qe { std::cout << "; Validation failed:\n"; std::cout << mk_pp(fml, m) << "\n"; } -); + ); +#endif } for (unsigned i = 0; i < m_children.size(); ++i) { @@ -1486,9 +1488,7 @@ namespace qe { tout << "subformula: " << mk_ismt2_pp(m_subfml, m) << "\n"; m_root.display(tout); m_root.display_validate(tout); - for (unsigned i = 0; i < m_free_vars.size(); ++i) tout << mk_ismt2_pp(m_free_vars[i].get(), m) << " "; - tout << "\n"; - ); + tout << "free: " << m_free_vars << "\n";); free_vars.append(m_free_vars); if (!m_free_vars.empty() || m_solver.inconsistent()) { @@ -1546,14 +1546,14 @@ namespace qe { app* get_var(unsigned idx) const { return m_current->free_var(idx); } - app* const* get_vars() const { return m_current->free_vars(); } + app_ref_vector const& get_vars() const { return m_current->free_vars(); } contains_app& contains(unsigned idx) { return contains(get_var(idx)); } // // The variable at idx is eliminated (without branching). // - void elim_var(unsigned idx, expr* _fml, expr* def) { + void elim_var(unsigned idx, expr* _fml, expr* def) override { app* x = get_var(idx); expr_ref fml(_fml, m); TRACE("qe", tout << mk_pp(x,m) << " " << mk_pp(def, m) << "\n";); @@ -1598,7 +1598,7 @@ namespace qe { add_literal(l3); expr_ref fml(m); fml = m.mk_or(m_literals.size(), m_literals.c_ptr()); - TRACE("qe", tout << mk_ismt2_pp(fml, m) << "\n";); + TRACE("qe", tout << fml << "\n";); m_solver.assert_expr(fml); } @@ -1654,9 +1654,7 @@ namespace qe { } app* get_branch_id(app* x) { - app* result = 0; - VERIFY (m_var2branch.find(x, result)); - return result; + return m_var2branch[x]; } bool extract_partition(ptr_vector& vars) { @@ -1912,6 +1910,7 @@ namespace qe { } m_current->set_var(x, k); + TRACE("qe", tout << mk_pp(x, m) << " := " << k << "\n";); if (m_bv.is_bv(x)) { return; } @@ -1952,7 +1951,7 @@ namespace qe { vars.reset(); closed = closed && (r != l_undef); } - TRACE("qe", tout << mk_pp(fml, m) << "\n";); + TRACE("qe", tout << fml << " free: " << m_current->free_vars() << "\n";); m_current->add_child(fml)->reset_free_vars(); block_assignment(); } @@ -1961,9 +1960,7 @@ namespace qe { // variable queueing. contains_app& contains(app* x) { - contains_app* result = 0; - VERIFY(m_var2contains.find(x, result)); - return *result; + return *m_var2contains[x]; } bool find_min_weight(app*& x, rational& num_branches) { @@ -2003,6 +2000,7 @@ namespace qe { bool solved = true; while (solved) { expr_ref fml(m_current->fml(), m); + TRACE("qe", tout << fml << "\n";); conj_enum conjs(m, fml); solved = false; for (unsigned i = 0; !solved && i < m_plugins.size(); ++i) { @@ -2512,7 +2510,7 @@ namespace qe { // Access current set of variables to solve virtual unsigned get_num_vars() const { return m_vars->size(); } virtual app* get_var(unsigned idx) const { return (*m_vars)[idx].get(); } - virtual app*const* get_vars() const { return m_vars->c_ptr(); } + virtual app_ref_vector const& get_vars() const { return *m_vars; } virtual bool is_var(expr* e, unsigned& idx) const { for (unsigned i = 0; i < m_vars->size(); ++i) { if ((*m_vars)[i].get() == e) { @@ -2540,6 +2538,7 @@ namespace qe { // callback to add new variable to branch. virtual void add_var(app* x) { + TRACE("qe", tout << "add var: " << mk_pp(x, m) << "\n";); m_vars->push_back(x); } diff --git a/src/qe/qe.h b/src/qe/qe.h index b6754b384..6946f9566 100644 --- a/src/qe/qe.h +++ b/src/qe/qe.h @@ -86,7 +86,7 @@ namespace qe { // Access current set of variables to solve virtual unsigned get_num_vars() const = 0; virtual app* get_var(unsigned idx) const = 0; - virtual app*const* get_vars() const = 0; + virtual app_ref_vector const& get_vars() const = 0; virtual bool is_var(expr* e, unsigned& idx) const; virtual contains_app& contains(unsigned idx) = 0; diff --git a/src/qe/qe_arith_plugin.cpp b/src/qe/qe_arith_plugin.cpp index 1085ec3c2..89dee9586 100644 --- a/src/qe/qe_arith_plugin.cpp +++ b/src/qe/qe_arith_plugin.cpp @@ -105,6 +105,7 @@ namespace qe { public: arith_util m_arith; // initialize before m_zero_i, etc. th_rewriter simplify; + app_ref_vector m_vars_added; private: arith_eq_solver m_arith_solver; bv_util m_bv; @@ -126,6 +127,7 @@ namespace qe { m_ctx(ctx), m_arith(m), simplify(m), + m_vars_added(m), m_arith_solver(m), m_bv(m), m_zero_i(m_arith.mk_numeral(numeral(0), true), m), @@ -783,6 +785,11 @@ namespace qe { } } + void add_var(app* v, bool track = true) { + m_ctx.add_var(v); + if (track) m_vars_added.push_back(v); + } + private: @@ -850,10 +857,11 @@ namespace qe { << mk_pp(result, m) << "\n";); } + void mk_big_or_symbolic(numeral up, app* x, expr* body, expr_ref& result) { app_ref z_bv(m); mk_big_or_symbolic(up, x, body, z_bv, result); - m_ctx.add_var(z_bv); + add_var(z_bv); } void mk_big_or_symbolic_blast(numeral up, app* x, expr* body, expr_ref& result) { @@ -999,9 +1007,9 @@ namespace qe { bool solve_linear(expr* p, expr* fml) { vector values; unsigned num_vars = m_ctx.get_num_vars(); - app*const* vars_ptr = m_ctx.get_vars(); + app_ref_vector const& vars = m_ctx.get_vars(); - if (!is_linear(p, num_vars, vars_ptr, values)) { + if (!is_linear(p, num_vars, vars.c_ptr(), values)) { return false; } @@ -1025,7 +1033,7 @@ namespace qe { // it has coefficient 'm' = values[index]. SASSERT(values[index] >= rational(3)); z = m.mk_fresh_const("x", m_arith.mk_int()); - m_ctx.add_var(z); + add_var(z); p1 = m_arith.mk_mul(m_arith.mk_numeral(values[index], true), z); } else { @@ -1475,16 +1483,18 @@ public: expr* m_result; rational m_coeff; expr* m_term; + ptr_vector m_vars; branch_formula(): m_fml(0), m_var(0), m_branch(0), m_result(0), m_term(0) {} - branch_formula(expr* fml, app* var, unsigned b, expr* r, rational coeff, expr* term): + branch_formula(expr* fml, app* var, unsigned b, expr* r, rational coeff, expr* term, app_ref_vector const& vars): m_fml(fml), m_var(var), m_branch(b), m_result(r), m_coeff(coeff), - m_term(term) + m_term(term), + m_vars(vars.size(), vars.c_ptr()) {} unsigned mk_hash() const { @@ -1544,6 +1554,7 @@ public: if (get_cache(x, fml, v, result)) { return; } + m_util.m_vars_added.reset(); bounds_proc& bounds = get_bounds(x, fml); bool is_lower = get_bound_sizes(bounds, x, t_size, e_size); @@ -1601,8 +1612,7 @@ public: expr_ref t(bounds.exprs(is_strict, is_lower)[index], m); rational a = bounds.coeffs(is_strict, is_lower)[index]; - - + mk_bounds(bounds, x, true, is_eq, is_strict, is_lower, index, a, t, result); mk_bounds(bounds, x, false, is_eq, is_strict, is_lower, index, a, t, result); @@ -1617,7 +1627,7 @@ public: { tout << vl << " " << mk_pp(bounds.atoms(is_strict, is_lower)[index],m) << "\n"; tout << mk_pp(fml, m) << "\n"; - tout << mk_pp(result, m) << "\n"; + tout << result << "\n"; } ); } @@ -1637,7 +1647,7 @@ public: virtual void subst(contains_app& contains_x, rational const& vl, expr_ref& fml, expr_ref* def) { SASSERT(vl.is_unsigned()); - if (def) { + if (def) { get_def(contains_x, vl.get_unsigned(), fml, *def); } VERIFY(get_cache(contains_x.x(), fml, vl.get_unsigned(), fml)); @@ -1740,7 +1750,7 @@ public: x_subst x_t(m_util); bounds_proc& bounds = get_bounds(x, fml); branch_formula bf; - VERIFY (m_subst.find(branch_formula(fml, x, v, 0, rational::zero(), 0), bf)); + VERIFY (m_subst.find(branch_formula(fml, x, v, 0, rational::zero(), 0, m_util.m_vars_added), bf)); x_t.set_term(bf.m_term); x_t.set_coeff(bf.m_coeff); @@ -2022,16 +2032,19 @@ public: m_trail.push_back(fml); m_trail.push_back(result); if (term) m_trail.push_back(term); - m_subst.insert(branch_formula(fml, x, v, result, coeff, term)); + m_subst.insert(branch_formula(fml, x, v, result, coeff, term, m_util.m_vars_added)); } bool get_cache(app* x, expr* fml, unsigned v, expr_ref& result) { branch_formula bf; - if (!m_subst.find(branch_formula(fml, x, v, 0, rational::zero(), 0), bf)) { + if (!m_subst.find(branch_formula(fml, x, v, 0, rational::zero(), 0, m_util.m_vars_added), bf)) { return false; } SASSERT(bf.m_result); result = bf.m_result; + for (app* v : bf.m_vars) { + m_util.add_var(v, false); + } return true; } @@ -2043,7 +2056,7 @@ public: if (!bounds.div_z(d, z_bv, z)) { return; } - m_ctx.add_var(z_bv); + m_util.add_var(z_bv); // // assert @@ -2120,7 +2133,7 @@ public: app* z1_bv = bounds.nested_div_z_bv(i); app* z1 = bounds.nested_div_z(i); - m_ctx.add_var(z1_bv); + m_util.add_var(z1_bv); // // assert diff --git a/src/qe/qe_sat_tactic.cpp b/src/qe/qe_sat_tactic.cpp index 69ebc1a42..250ffff4a 100644 --- a/src/qe/qe_sat_tactic.cpp +++ b/src/qe/qe_sat_tactic.cpp @@ -122,7 +122,7 @@ namespace qe { // Access current set of variables to solve virtual unsigned get_num_vars() const { return m_vars.size(); } virtual app* get_var(unsigned idx) const { return m_vars[idx]; } - virtual app*const* get_vars() const { return m_vars.c_ptr(); } + virtual app_ref_vector const& get_vars() const { return m_vars; } virtual bool is_var(expr* e, unsigned& idx) const { for (unsigned i = 0; i < m_vars.size(); ++i) { if (e == m_vars[i]) return (idx = i, true); From b2bd4dd3b4ce591aab630adb25ddf2df30e8fc5f Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 5 Feb 2018 18:54:14 -0800 Subject: [PATCH 160/263] fix #1471 Signed-off-by: Nikolaj Bjorner --- src/sat/sat_integrity_checker.cpp | 30 ++++++++++++++---------------- src/sat/sat_solver.cpp | 26 ++++++++++++++++---------- src/sat/sat_solver.h | 2 +- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/sat/sat_integrity_checker.cpp b/src/sat/sat_integrity_checker.cpp index 08a6072b6..027cd8a6f 100644 --- a/src/sat/sat_integrity_checker.cpp +++ b/src/sat/sat_integrity_checker.cpp @@ -153,7 +153,7 @@ namespace sat { } bool integrity_checker::check_watches() const { - DEBUG_CODE( + DEBUG_CODE( vector::const_iterator it = s.m_watches.begin(); vector::const_iterator end = s.m_watches.end(); for (unsigned l_idx = 0; it != end; ++it, ++l_idx) { @@ -165,30 +165,28 @@ namespace sat { s.display_watches(tout); s.display(tout);); SASSERT(!s.was_eliminated(l.var()) || wlist.empty()); - watch_list::const_iterator it2 = wlist.begin(); - watch_list::const_iterator end2 = wlist.end(); - for (; it2 != end2; ++it2) { - switch (it2->get_kind()) { + for (watched const& w : wlist) { + switch (w.get_kind()) { case watched::BINARY: - SASSERT(!s.was_eliminated(it2->get_literal().var())); - CTRACE("sat_watched_bug", !s.get_wlist(~(it2->get_literal())).contains(watched(l, it2->is_learned())), - tout << "l: " << l << " l2: " << it2->get_literal() << "\n"; + SASSERT(!s.was_eliminated(w.get_literal().var())); + CTRACE("sat_watched_bug", !s.get_wlist(~(w.get_literal())).contains(watched(l, w.is_learned())), + tout << "l: " << l << " l2: " << w.get_literal() << "\n"; tout << "was_eliminated1: " << s.was_eliminated(l.var()); - tout << " was_eliminated2: " << s.was_eliminated(it2->get_literal().var()); - tout << " learned: " << it2->is_learned() << "\n"; + tout << " was_eliminated2: " << s.was_eliminated(w.get_literal().var()); + tout << " learned: " << w.is_learned() << "\n"; sat::display(tout, s.m_cls_allocator, wlist); tout << "\n"; - sat::display(tout, s.m_cls_allocator, s.get_wlist(~(it2->get_literal()))); + sat::display(tout, s.m_cls_allocator, s.get_wlist(~(w.get_literal()))); tout << "\n";); - SASSERT(s.get_wlist(~(it2->get_literal())).contains(watched(l, it2->is_learned()))); + SASSERT(s.get_wlist(~(w.get_literal())).contains(watched(l, w.is_learned()))); break; case watched::TERNARY: - SASSERT(!s.was_eliminated(it2->get_literal1().var())); - SASSERT(!s.was_eliminated(it2->get_literal2().var())); - SASSERT(it2->get_literal1().index() < it2->get_literal2().index()); + SASSERT(!s.was_eliminated(w.get_literal1().var())); + SASSERT(!s.was_eliminated(w.get_literal2().var())); + SASSERT(w.get_literal1().index() < w.get_literal2().index()); break; case watched::CLAUSE: - SASSERT(!s.m_cls_allocator.get_clause(it2->get_clause_offset())->was_removed()); + SASSERT(!s.m_cls_allocator.get_clause(w.get_clause_offset())->was_removed()); break; default: break; diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index 4cb7339d1..f0c23e087 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -2641,15 +2641,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); } } @@ -2724,8 +2731,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) { diff --git a/src/sat/sat_solver.h b/src/sat/sat_solver.h index c011eb46d..c275b8ee2 100644 --- a/src/sat/sat_solver.h +++ b/src/sat/sat_solver.h @@ -444,7 +444,7 @@ namespace sat { literal_vector m_aux_literals; svector 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); From 54b3cd00717914aad0d343d381621506ff3f40c4 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Feb 2018 11:21:17 +0700 Subject: [PATCH 161/263] Reserve vector space when possible. This fixes all current instances of the `performance-inefficient-vector-operation` warning in clang-tidy. --- src/duality/duality.h | 1 + src/duality/duality_rpfp.cpp | 21 +++++++++++++++++++-- src/duality/duality_solver.cpp | 1 + src/interp/iz3interp.cpp | 1 + src/interp/iz3translate.cpp | 2 ++ src/muz/duality/duality_dl_interface.cpp | 1 + 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/duality/duality.h b/src/duality/duality.h index 28cf96df3..e8f36a0cd 100644 --- a/src/duality/duality.h +++ b/src/duality/duality.h @@ -507,6 +507,7 @@ namespace Duality { { std::vector _IndParams; int nargs = t.num_args(); + _IndParams.reserve(nargs); for(int i = 0; i < nargs; i++) _IndParams.push_back(t.arg(i)); Node *n = new Node(t.decl(), diff --git a/src/duality/duality_rpfp.cpp b/src/duality/duality_rpfp.cpp index 9dae5eba9..b6dd42f00 100755 --- a/src/duality/duality_rpfp.cpp +++ b/src/duality/duality_rpfp.cpp @@ -234,6 +234,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for (int i = 0; i < nargs; i++) args.push_back(LocalizeRec(e, memo, t.arg(i))); hash_map::iterator rit = e->relMap.find(f); @@ -352,6 +353,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for (int i = 0; i < nargs; i++) args.push_back(SubstRec(memo, t.arg(i))); res = f(args.size(), VEC2PTR(args)); @@ -379,6 +381,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for (int i = 0; i < nargs; i++) args.push_back(SubstRec(memo, map, t.arg(i))); hash_map::iterator it = map.find(f); @@ -409,6 +412,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for (int i = 0; i < nargs; i++) args.push_back(ExtractStores(memo, t.arg(i), cnstrs, renaming)); res = f(args.size(), VEC2PTR(args)); @@ -655,6 +659,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for (int i = 0; i < nargs; i++) args.push_back(RemoveRedundancyRec(memo, smemo, t.arg(i))); @@ -703,6 +708,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for (int i = 0; i < nargs; i++) args.push_back(IneqToEqRec(memo, t.arg(i))); @@ -749,6 +755,7 @@ namespace Duality { res = ctx.constant(name.c_str(), t.get_sort()); return res; } + args.reserve(nargs); for (int i = 0; i < nargs; i++) args.push_back(SubstRec(memo, t.arg(i))); res = f(args.size(), VEC2PTR(args)); @@ -3308,6 +3315,7 @@ namespace Duality { std::string name = t.decl().name().str() + "_" + string_of_int(n); std::vector sorts; int nargs = t.num_args(); + sorts.reserve(nargs); for(int i = 0; i < nargs; i++) sorts.push_back(t.arg(i).get_sort()); return ctx.function(name.c_str(), nargs, VEC2PTR(sorts), t.get_sort()); @@ -3319,8 +3327,9 @@ namespace Duality { name = name.substr(0,name.rfind('_')) + "_" + string_of_int(n); int arity = f.arity(); std::vector domain; + domain.reserve(arity); for(int i = 0; i < arity; i++) - domain.push_back(f.domain(i)); + domain.push_back(f.domain(i)); return ctx.function(name.c_str(), arity, VEC2PTR(domain), f.range()); } @@ -3330,8 +3339,9 @@ namespace Duality { name = name + "_" + string_of_int(n); int arity = f.arity(); std::vector domain; + domain.reserve(arity); for(int i = 0; i < arity; i++) - domain.push_back(f.domain(i)); + domain.push_back(f.domain(i)); return ctx.function(name.c_str(), arity, VEC2PTR(domain), f.range()); } @@ -3355,6 +3365,7 @@ namespace Duality { } int nargs = t.num_args(); std::vector args; + args.reserve(nargs); for(int i = 0; i < nargs; i++) args.push_back(ScanBody(memo,t.arg(i),pmap,parms,nodes)); res = f(nargs, VEC2PTR(args)); @@ -3403,6 +3414,7 @@ namespace Duality { else { int nargs = t.num_args(); std::vector args; + args.reserve(nargs); for(int i = 0; i < nargs; i++) args.push_back(RemoveLabelsRec(memo,t.arg(i),lbls)); res = f(nargs, VEC2PTR(args)); @@ -3432,6 +3444,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); if(nargs == 0 && f.get_decl_kind() == Uninterpreted) ls->declare_constant(f); // keep track of background constants for(int i = 0; i < nargs; i++) @@ -3474,6 +3487,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for(int i = 0; i < nargs; i++) args.push_back(DeleteBoundRec(memo, level, num, t.arg(i))); res = f(args.size(), VEC2PTR(args)); @@ -3870,6 +3884,7 @@ namespace Duality { void RPFP::AddParamsToNode(Node *node, const std::vector ¶ms){ int arity = node->Annotation.IndParams.size(); std::vector domain; + domain.reserve(arity + params.size()); for(int i = 0; i < arity; i++) domain.push_back(node->Annotation.IndParams[i].get_sort()); for(unsigned i = 0; i < params.size(); i++) @@ -3936,6 +3951,7 @@ namespace Duality { func_decl fd = SuffixFuncDecl(new_lit,j); int nargs = new_lit.num_args(); std::vector args; + args.reserve(nargs); for(int k = 0; k < nargs; k++) args.push_back(new_lit.arg(k)); new_lit = fd(nargs, VEC2PTR(args)); @@ -4126,6 +4142,7 @@ namespace Duality { // int idx; std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for(int i = 0; i < nargs; i++) args.push_back(ToRuleRec(e, memo, t.arg(i),quants)); hash_map::iterator rit = e->relMap.find(f); diff --git a/src/duality/duality_solver.cpp b/src/duality/duality_solver.cpp index 59e68e046..6053295b5 100644 --- a/src/duality/duality_solver.cpp +++ b/src/duality/duality_solver.cpp @@ -3424,6 +3424,7 @@ namespace Duality { func_decl f = t.decl(); std::vector args; int nargs = t.num_args(); + args.reserve(nargs); for(int i = 0; i < nargs; i++) args.push_back(AddParamToRels(memo, rmap, p, t.arg(i))); hash_map::iterator rit = rmap.find(f); diff --git a/src/interp/iz3interp.cpp b/src/interp/iz3interp.cpp index 6f918bccb..91b0c5a63 100755 --- a/src/interp/iz3interp.cpp +++ b/src/interp/iz3interp.cpp @@ -97,6 +97,7 @@ struct frame_reducer : public iz3mgr { // if multiple children of a tree node are used, we can't delete it std::vector used_children; + used_children.reserve(frames); for(int i = 0; i < frames; i++) used_children.push_back(0); for(int i = 0; i < frames; i++) diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp index 4831e7eaf..32b76b224 100755 --- a/src/interp/iz3translate.cpp +++ b/src/interp/iz3translate.cpp @@ -1146,6 +1146,7 @@ public: my_cons.push_back(mk_not(farkas_con)); my_coeffs.push_back(make_int("1")); std::vector my_hyps; + my_hyps.reserve(nargs); for(int i = 0; i < nargs; i++) my_hyps.push_back(iproof->make_hypothesis(my_cons[i])); ast res = iproof->make_farkas(mk_false(),my_hyps,my_cons,my_coeffs); @@ -1203,6 +1204,7 @@ public: int nargs = num_prems(proof); if(nargs != (int)(my_coeffs.size())) throw "bad gomory-cut theory lemma"; + my_prem_cons.reserve(nargs); for(int i = 0; i < nargs; i++) my_prem_cons.push_back(conc(prem(proof,i))); ast my_con = normalize_inequality(sum_inequalities(my_coeffs,my_prem_cons)); diff --git a/src/muz/duality/duality_dl_interface.cpp b/src/muz/duality/duality_dl_interface.cpp index 5ce4ef957..15f7f84d8 100755 --- a/src/muz/duality/duality_dl_interface.cpp +++ b/src/muz/duality/duality_dl_interface.cpp @@ -273,6 +273,7 @@ namespace Duality { if (!heads.contains(fd)) { int arity = f.arity(); std::vector args; + args.reserve(arity); for (int j = 0; j < arity; j++) args.push_back(_d->ctx.fresh_func_decl("X", f.domain(j))()); expr c = implies(_d->ctx.bool_val(false), f(args)); From 5911f810edb8933bd903153d03ff42f4ede23f53 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Feb 2018 11:23:08 +0700 Subject: [PATCH 162/263] Fix inconsistent missing override warnings. --- src/qe/qe.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qe/qe.cpp b/src/qe/qe.cpp index 0a3f880b7..57a8c365b 100644 --- a/src/qe/qe.cpp +++ b/src/qe/qe.cpp @@ -1536,19 +1536,19 @@ namespace qe { pop(*model_eval); } - ast_manager& get_manager() { return m; } + ast_manager& get_manager() override { return m; } - atom_set const& pos_atoms() const { return m_current->pos_atoms(); } + atom_set const& pos_atoms() const override { return m_current->pos_atoms(); } - atom_set const& neg_atoms() const { return m_current->neg_atoms(); } + atom_set const& neg_atoms() const override { return m_current->neg_atoms(); } - unsigned get_num_vars() const { return m_current->num_free_vars(); } + unsigned get_num_vars() const override { return m_current->num_free_vars(); } - app* get_var(unsigned idx) const { return m_current->free_var(idx); } + app* get_var(unsigned idx) const override { return m_current->free_var(idx); } - app_ref_vector const& get_vars() const { return m_current->free_vars(); } + app_ref_vector const& get_vars() const override { return m_current->free_vars(); } - contains_app& contains(unsigned idx) { return contains(get_var(idx)); } + contains_app& contains(unsigned idx) override { return contains(get_var(idx)); } // // The variable at idx is eliminated (without branching). @@ -1564,7 +1564,7 @@ namespace qe { normalize(*m_current); } - void add_var(app* x) { + void add_var(app* x) override { m_new_vars.push_back(x); if (m_var2branch.contains(x)) { return; @@ -1583,7 +1583,7 @@ namespace qe { m_var2branch.insert(x, bv); } - virtual void add_constraint(bool use_current_val, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) { + void add_constraint(bool use_current_val, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) override { search_tree* node = m_current; if (!use_current_val) { node = m_current->parent(); @@ -1602,7 +1602,7 @@ namespace qe { m_solver.assert_expr(fml); } - void blast_or(app* var, expr_ref& fml) { + void blast_or(app* var, expr_ref& fml) override { m_qe.eliminate_exists(1, &var, fml, m_free_vars, false, 0); } From c74ad466827307ca847ea5c4940baf8cb2d26374 Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Mon, 5 Feb 2018 21:22:46 -0800 Subject: [PATCH 163/263] remove a duplicate definition Signed-off-by: Lev Nachmanson --- src/util/lp/lp_solver_instances.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/lp/lp_solver_instances.cpp b/src/util/lp/lp_solver_instances.cpp index 4de1f74c8..d7caf9a18 100644 --- a/src/util/lp/lp_solver_instances.cpp +++ b/src/util/lp/lp_solver_instances.cpp @@ -54,5 +54,4 @@ template void lp::lp_solver::scale(); template void lp::lp_solver::set_scaled_cost(unsigned int); template lp::lp_solver::~lp_solver(); template double lp::lp_solver::get_column_value_by_name(std::string) const; -template std::string lp::lp_solver::get_column_name(unsigned int) const; template std::string lp::lp_solver::get_column_name(unsigned int) const; From cb6896087dbb3a1746dd2d0e76dfe57c99804655 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 6 Feb 2018 10:21:02 -0800 Subject: [PATCH 164/263] fix #1468 Signed-off-by: Nikolaj Bjorner --- src/sat/sat_probing.h | 2 +- src/sat/sat_solver.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sat/sat_probing.h b/src/sat/sat_probing.h index 391098ef7..fb9b1dd30 100644 --- a/src/sat/sat_probing.h +++ b/src/sat/sat_probing.h @@ -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); diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index f0c23e087..dbd996cd0 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -2702,6 +2702,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); From 1ee7871bbfb0b92be2a2eb58349e489db75e300a Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 6 Feb 2018 18:48:03 -0800 Subject: [PATCH 165/263] to fix #1476 Signed-off-by: Nikolaj Bjorner --- src/opt/opt_context.cpp | 2 +- src/opt/opt_params.pyg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index a7c8c3f5b..2fdef6ca4 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -1012,7 +1012,7 @@ namespace opt { void context::model_updated(model* md) { opt_params optp(m_params); symbol prefix = optp.solution_prefix(); - if (prefix == symbol::null) return; + if (prefix == symbol::null || prefix == symbol("")) return; model_ref mdl = md->copy(); fix_model(mdl); std::ostringstream buffer; diff --git a/src/opt/opt_params.pyg b/src/opt/opt_params.pyg index 09d849e1a..1d6d7ee6a 100644 --- a/src/opt/opt_params.pyg +++ b/src/opt/opt_params.pyg @@ -5,7 +5,7 @@ def_module_params('opt', ('maxsat_engine', SYMBOL, 'maxres', "select engine for maxsat: 'core_maxsat', 'wmax', 'maxres', 'pd-maxres'"), ('priority', SYMBOL, 'lex', "select how to priortize objectives: 'lex' (lexicographic), 'pareto', or 'box'"), ('dump_benchmarks', BOOL, False, 'dump benchmarks for profiling'), - ('solution_prefix', SYMBOL, None, "path prefix to dump intermediary, but non-optimal, solutions"), + ('solution_prefix', SYMBOL, '', "path prefix to dump intermediary, but non-optimal, solutions"), ('timeout', UINT, UINT_MAX, 'timeout (in milliseconds) (UINT_MAX and 0 mean no timeout)'), ('rlimit', UINT, 0, 'resource limit (0 means no limit)'), ('enable_sls', BOOL, False, 'enable SLS tuning during weighted maxsast'), From 61934d81061344e9c15b03e9ab0ab0d8025b64a2 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 7 Feb 2018 20:08:15 -0800 Subject: [PATCH 166/263] align semantics of re.allchar with string proposal. #1475 Signed-off-by: Nikolaj Bjorner --- src/api/api_ast.cpp | 5 ++-- src/api/api_seq.cpp | 2 +- src/ast/rewriter/seq_rewriter.cpp | 41 ++++++++++++++++++++++--------- src/ast/seq_decl_plugin.cpp | 25 +++++++++++++------ src/ast/seq_decl_plugin.h | 11 ++++++--- src/smt/theory_seq.cpp | 3 ++- src/smt/theory_str.cpp | 11 ++++++--- 7 files changed, 67 insertions(+), 31 deletions(-) diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index ae23ca100..6c39ad07d 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -1115,7 +1115,7 @@ extern "C" { case _OP_STRING_SUBSTR: return Z3_OP_SEQ_EXTRACT; case _OP_STRING_STRIDOF: return Z3_OP_SEQ_INDEX; case _OP_REGEXP_EMPTY: return Z3_OP_RE_EMPTY_SET; - case _OP_REGEXP_FULL: return Z3_OP_RE_FULL_SET; + case _OP_REGEXP_FULL_CHAR: return Z3_OP_RE_FULL_SET; case OP_STRING_STOI: return Z3_OP_STR_TO_INT; case OP_STRING_ITOS: return Z3_OP_INT_TO_STR; @@ -1127,7 +1127,8 @@ extern "C" { case OP_RE_UNION: return Z3_OP_RE_UNION; case OP_RE_INTERSECT: return Z3_OP_RE_INTERSECT; case OP_RE_LOOP: return Z3_OP_RE_LOOP; - case OP_RE_FULL_SET: return Z3_OP_RE_FULL_SET; + // case OP_RE_FULL_SEQ_SET: return Z3_OP_RE_FULL_SET; + case OP_RE_FULL_CHAR_SET: return Z3_OP_RE_FULL_SET; case OP_RE_EMPTY_SET: return Z3_OP_RE_EMPTY_SET; default: return Z3_OP_INTERNAL; diff --git a/src/api/api_seq.cpp b/src/api/api_seq.cpp index 44003a5fb..428d86d0d 100644 --- a/src/api/api_seq.cpp +++ b/src/api/api_seq.cpp @@ -165,7 +165,7 @@ extern "C" { MK_BINARY(Z3_mk_re_range, mk_c(c)->get_seq_fid(), OP_RE_RANGE, SKIP); MK_SORTED(Z3_mk_re_empty, mk_c(c)->sutil().re.mk_empty); - MK_SORTED(Z3_mk_re_full, mk_c(c)->sutil().re.mk_full); + MK_SORTED(Z3_mk_re_full, mk_c(c)->sutil().re.mk_full_seq); diff --git a/src/ast/rewriter/seq_rewriter.cpp b/src/ast/rewriter/seq_rewriter.cpp index fa95278b4..ec3e72cc4 100644 --- a/src/ast/rewriter/seq_rewriter.cpp +++ b/src/ast/rewriter/seq_rewriter.cpp @@ -286,7 +286,7 @@ eautomaton* re2automaton::re2aut(expr* e) { else if (u.re.is_empty(e)) { return alloc(eautomaton, sm); } - else if (u.re.is_full(e)) { + else if (u.re.is_full_seq(e)) { expr_ref tt(m.mk_true(), m); sort *seq_s = 0, *char_s = 0; VERIFY (u.is_re(m.get_sort(e), seq_s)); @@ -294,6 +294,15 @@ eautomaton* re2automaton::re2aut(expr* e) { sym_expr* _true = sym_expr::mk_pred(tt, char_s); return eautomaton::mk_loop(sm, _true); } + else if (u.re.is_full_char(e)) { + expr_ref tt(m.mk_true(), m); + sort *seq_s = 0, *char_s = 0; + VERIFY (u.is_re(m.get_sort(e), seq_s)); + VERIFY (u.is_seq(seq_s, char_s)); + sym_expr* _true = sym_expr::mk_pred(tt, char_s); + a = alloc(eautomaton, sm, _true); + return a.detach(); + } else if (u.re.is_intersection(e, e1, e2) && m_sa && (a = re2aut(e1)) && (b = re2aut(e2))) { return m_sa->mk_product(*a, *b); } @@ -370,7 +379,9 @@ br_status seq_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * con return mk_re_loop(num_args, args, result); case OP_RE_EMPTY_SET: return BR_FAILED; - case OP_RE_FULL_SET: + case OP_RE_FULL_SEQ_SET: + return BR_FAILED; + case OP_RE_FULL_CHAR_SET: return BR_FAILED; case OP_RE_OF_PRED: return BR_FAILED; @@ -1217,7 +1228,7 @@ br_status seq_rewriter::mk_str_in_regexp(expr* a, expr* b, expr_ref& result) { result = m().mk_false(); return BR_DONE; } - if (m_util.re.is_full(b)) { + if (m_util.re.is_full_seq(b)) { result = m().mk_true(); return BR_DONE; } @@ -1312,7 +1323,7 @@ br_status seq_rewriter::mk_str_to_regexp(expr* a, expr_ref& result) { return BR_FAILED; } br_status seq_rewriter::mk_re_concat(expr* a, expr* b, expr_ref& result) { - if (m_util.re.is_full(a) && m_util.re.is_full(b)) { + if (m_util.re.is_full_seq(a) && m_util.re.is_full_seq(b)) { result = a; return BR_DONE; } @@ -1352,11 +1363,11 @@ br_status seq_rewriter::mk_re_union(expr* a, expr* b, expr_ref& result) { result = a; return BR_DONE; } - if (m_util.re.is_full(a)) { + if (m_util.re.is_full_seq(a)) { result = a; return BR_DONE; } - if (m_util.re.is_full(b)) { + if (m_util.re.is_full_seq(b)) { result = b; return BR_DONE; } @@ -1382,10 +1393,10 @@ br_status seq_rewriter::mk_re_complement(expr* a, expr_ref& result) { return BR_REWRITE2; } if (m_util.re.is_empty(a)) { - result = m_util.re.mk_full(m().get_sort(a)); + result = m_util.re.mk_full_seq(m().get_sort(a)); return BR_DONE; } - if (m_util.re.is_full(a)) { + if (m_util.re.is_full_seq(a)) { result = m_util.re.mk_empty(m().get_sort(a)); return BR_DONE; } @@ -1412,11 +1423,11 @@ br_status seq_rewriter::mk_re_inter(expr* a, expr* b, expr_ref& result) { result = b; return BR_DONE; } - if (m_util.re.is_full(a)) { + if (m_util.re.is_full_seq(a)) { result = b; return BR_DONE; } - if (m_util.re.is_full(b)) { + if (m_util.re.is_full_seq(b)) { result = a; return BR_DONE; } @@ -1459,10 +1470,16 @@ br_status seq_rewriter::mk_re_loop(unsigned num_args, expr* const* args, expr_re */ br_status seq_rewriter::mk_re_star(expr* a, expr_ref& result) { expr* b, *c, *b1, *c1; - if (m_util.re.is_star(a) || m_util.re.is_full(a)) { + if (m_util.re.is_star(a) || m_util.re.is_full_seq(a)) { result = a; return BR_DONE; } + if (m_util.re.is_full_char(a)) { + sort* seq_sort = 0; + VERIFY(m_util.is_re(a, seq_sort)); + result = m_util.re.mk_full_seq(seq_sort); + return BR_DONE; + } if (m_util.re.is_empty(a)) { sort* seq_sort = 0; VERIFY(m_util.is_re(a, seq_sort)); @@ -1519,7 +1536,7 @@ br_status seq_rewriter::mk_re_plus(expr* a, expr_ref& result) { result = a; return BR_DONE; } - if (m_util.re.is_full(a)) { + if (m_util.re.is_full_seq(a)) { result = a; return BR_DONE; } diff --git a/src/ast/seq_decl_plugin.cpp b/src/ast/seq_decl_plugin.cpp index 7cc0ccb12..daf39b79e 100644 --- a/src/ast/seq_decl_plugin.cpp +++ b/src/ast/seq_decl_plugin.cpp @@ -544,7 +544,8 @@ void seq_decl_plugin::init() { m_sigs[OP_RE_LOOP] = alloc(psig, m, "re.loop", 1, 1, &reA, reA); m_sigs[OP_RE_COMPLEMENT] = alloc(psig, m, "re.complement", 1, 1, &reA, reA); m_sigs[OP_RE_EMPTY_SET] = alloc(psig, m, "re.empty", 1, 0, 0, reA); - m_sigs[OP_RE_FULL_SET] = alloc(psig, m, "re.all", 1, 0, 0, reA); + m_sigs[OP_RE_FULL_SEQ_SET] = alloc(psig, m, "re.all", 1, 0, 0, reA); + m_sigs[OP_RE_FULL_CHAR_SET] = alloc(psig, m, "re.all1", 1, 0, 0, reA); m_sigs[OP_RE_OF_PRED] = alloc(psig, m, "re.of.pred", 1, 1, &predA, reA); m_sigs[OP_SEQ_TO_RE] = alloc(psig, m, "seq.to.re", 1, 1, &seqA, reA); m_sigs[OP_SEQ_IN_RE] = alloc(psig, m, "seq.in.re", 1, 2, seqAreA, boolT); @@ -562,7 +563,7 @@ void seq_decl_plugin::init() { m_sigs[_OP_STRING_IN_REGEXP] = alloc(psig, m, "str.in.re", 0, 2, strTreT, boolT); m_sigs[_OP_STRING_TO_REGEXP] = alloc(psig, m, "str.to.re", 0, 1, &strT, reT); m_sigs[_OP_REGEXP_EMPTY] = alloc(psig, m, "re.nostr", 0, 0, 0, reT); - m_sigs[_OP_REGEXP_FULL] = alloc(psig, m, "re.allchar", 0, 0, 0, reT); + m_sigs[_OP_REGEXP_FULL_CHAR] = alloc(psig, m, "re.allchar", 0, 0, 0, reT); m_sigs[_OP_STRING_SUBSTR] = alloc(psig, m, "str.substr", 0, 3, strTint2T, strT); m_sigs[_OP_RE_UNROLL] = alloc(psig, m, "_re.unroll", 0, 2, reTintT, strT); } @@ -669,20 +670,24 @@ func_decl * seq_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, match(*m_sigs[k], arity, domain, range, rng); return m.mk_func_decl(m_sigs[k]->m_name, arity, domain, rng, func_decl_info(m_family_id, k)); - case _OP_REGEXP_FULL: + case _OP_REGEXP_FULL_CHAR: if (!range) { range = m_re; } match(*m_sigs[k], arity, domain, range, rng); - return m.mk_func_decl(symbol("re.allchar"), arity, domain, rng, func_decl_info(m_family_id, OP_RE_FULL_SET)); - case OP_RE_FULL_SET: + return m.mk_func_decl(symbol("re.allchar"), arity, domain, rng, func_decl_info(m_family_id, OP_RE_FULL_CHAR_SET)); + + case OP_RE_FULL_CHAR_SET: if (!range) range = m_re; if (range == m_re) { match(*m_sigs[k], arity, domain, range, rng); return m.mk_func_decl(symbol("re.allchar"), arity, domain, rng, func_decl_info(m_family_id, k)); } return m.mk_func_decl(m_sigs[k]->m_name, arity, domain, range, func_decl_info(m_family_id, k)); - + + case OP_RE_FULL_SEQ_SET: + if (!range) range = m_re; + return m.mk_func_decl(m_sigs[k]->m_name, arity, domain, range, func_decl_info(m_family_id, k)); case _OP_REGEXP_EMPTY: if (!range) { @@ -972,8 +977,12 @@ app* seq_util::re::mk_loop(expr* r, unsigned lo, unsigned hi) { return m.mk_app(m_fid, OP_RE_LOOP, 2, params, 1, &r); } -app* seq_util::re::mk_full(sort* s) { - return m.mk_app(m_fid, OP_RE_FULL_SET, 0, 0, 0, 0, s); +app* seq_util::re::mk_full_char(sort* s) { + return m.mk_app(m_fid, OP_RE_FULL_CHAR_SET, 0, 0, 0, 0, s); +} + +app* seq_util::re::mk_full_seq(sort* s) { + return m.mk_app(m_fid, OP_RE_FULL_SEQ_SET, 0, 0, 0, 0, s); } app* seq_util::re::mk_empty(sort* s) { diff --git a/src/ast/seq_decl_plugin.h b/src/ast/seq_decl_plugin.h index 17fa50423..2e3b3fd24 100644 --- a/src/ast/seq_decl_plugin.h +++ b/src/ast/seq_decl_plugin.h @@ -56,7 +56,8 @@ enum seq_op_kind { OP_RE_LOOP, OP_RE_COMPLEMENT, OP_RE_EMPTY_SET, - OP_RE_FULL_SET, + OP_RE_FULL_SEQ_SET, + OP_RE_FULL_CHAR_SET, OP_RE_OF_PRED, @@ -77,7 +78,7 @@ enum seq_op_kind { _OP_STRING_SUBSTR, _OP_STRING_STRIDOF, _OP_REGEXP_EMPTY, - _OP_REGEXP_FULL, + _OP_REGEXP_FULL_CHAR, _OP_SEQ_SKOLEM, _OP_RE_UNROLL, LAST_SEQ_OP @@ -327,7 +328,8 @@ public: app* mk_opt(expr* r) { return m.mk_app(m_fid, OP_RE_OPTION, r); } app* mk_loop(expr* r, unsigned lo); app* mk_loop(expr* r, unsigned lo, unsigned hi); - app* mk_full(sort* s); + app* mk_full_char(sort* s); + app* mk_full_seq(sort* s); app* mk_empty(sort* s); bool is_to_re(expr const* n) const { return is_app_of(n, m_fid, OP_SEQ_TO_RE); } @@ -341,7 +343,8 @@ public: bool is_range(expr const* n) const { return is_app_of(n, m_fid, OP_RE_RANGE); } bool is_loop(expr const* n) const { return is_app_of(n, m_fid, OP_RE_LOOP); } bool is_empty(expr const* n) const { return is_app_of(n, m_fid, OP_RE_EMPTY_SET); } - bool is_full(expr const* n) const { return is_app_of(n, m_fid, OP_RE_FULL_SET); } + bool is_full_char(expr const* n) const { return is_app_of(n, m_fid, OP_RE_FULL_CHAR_SET); } + bool is_full_seq(expr const* n) const { return is_app_of(n, m_fid, OP_RE_FULL_SEQ_SET); } MATCH_UNARY(is_to_re); MATCH_BINARY(is_concat); MATCH_BINARY(is_union); diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index f91685d43..4c1a63a2f 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -2271,7 +2271,8 @@ bool theory_seq::internalize_re(expr* e) { m_util.re.is_concat(e, e1, e2)) { return internalize_re(e1) && internalize_re(e2); } - if (m_util.re.is_full(e) || + if (m_util.re.is_full_seq(e) || + m_util.re.is_full_char(e) || m_util.re.is_empty(e)) { return true; } diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 022a2ad73..56a54f964 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -1689,8 +1689,10 @@ namespace smt { u.str.is_string(range1, range1val); u.str.is_string(range2, range2val); return zstring("[") + range1val + zstring("-") + range2val + zstring("]"); - } else if (u.re.is_full(a_regex)) { + } else if (u.re.is_full_seq(a_regex)) { return zstring("(.*)"); + } else if (u.re.is_full_char(a_regex)) { + return zstring("str.allchar"); } else { TRACE("str", tout << "BUG: unrecognized regex term " << mk_pp(regex, get_manager()) << std::endl;); UNREACHABLE(); return zstring(""); @@ -1806,9 +1808,12 @@ namespace smt { expr_ref finalAxiom(m.mk_iff(ex, rhs), m); SASSERT(finalAxiom); assert_axiom(finalAxiom); - } else if (u.re.is_full(regex)) { + } else if (u.re.is_full_seq(regex)) { // trivially true for any string! assert_axiom(ex); + } else if (u.re.is_full_char(regex)) { + TRACE("str", tout << "ERROR: unknown regex expression " << mk_pp(regex, m) << "!" << std::endl;); + NOT_IMPLEMENTED_YET(); } else { TRACE("str", tout << "ERROR: unknown regex expression " << mk_pp(regex, m) << "!" << std::endl;); NOT_IMPLEMENTED_YET(); @@ -6309,7 +6314,7 @@ namespace smt { } TRACE("str", tout << "range NFA: start = " << start << ", end = " << end << std::endl;); - } else if (u.re.is_full(e)) { + } else if (u.re.is_full_seq(e)) { // effectively the same as .* where . can be any single character // start --e--> tmp // tmp --e--> end From 3f7453f5c5b59396daa55e98de73b7d6aa816d7e Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 7 Feb 2018 20:23:31 -0800 Subject: [PATCH 167/263] fixing build Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 2 +- src/ast/seq_decl_plugin.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index c28a14c3b..641dba59c 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -9838,7 +9838,7 @@ def Full(s): re.all >>> e1 = Full(ReSort(StringSort())) >>> print(e1) - re.allchar + re.all """ if isinstance(s, ReSortRef): return ReRef(Z3_mk_re_full(s.ctx_ref(), s.ast), s.ctx) diff --git a/src/ast/seq_decl_plugin.cpp b/src/ast/seq_decl_plugin.cpp index daf39b79e..2790c5c48 100644 --- a/src/ast/seq_decl_plugin.cpp +++ b/src/ast/seq_decl_plugin.cpp @@ -545,7 +545,7 @@ void seq_decl_plugin::init() { m_sigs[OP_RE_COMPLEMENT] = alloc(psig, m, "re.complement", 1, 1, &reA, reA); m_sigs[OP_RE_EMPTY_SET] = alloc(psig, m, "re.empty", 1, 0, 0, reA); m_sigs[OP_RE_FULL_SEQ_SET] = alloc(psig, m, "re.all", 1, 0, 0, reA); - m_sigs[OP_RE_FULL_CHAR_SET] = alloc(psig, m, "re.all1", 1, 0, 0, reA); + m_sigs[OP_RE_FULL_CHAR_SET] = alloc(psig, m, "re.allchar", 1, 0, 0, reA); m_sigs[OP_RE_OF_PRED] = alloc(psig, m, "re.of.pred", 1, 1, &predA, reA); m_sigs[OP_SEQ_TO_RE] = alloc(psig, m, "seq.to.re", 1, 1, &seqA, reA); m_sigs[OP_SEQ_IN_RE] = alloc(psig, m, "seq.in.re", 1, 2, seqAreA, boolT); From 50f3e9c3c054691fefefc8b3d3f02114cd1591c8 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Feb 2018 14:30:43 +0700 Subject: [PATCH 168/263] Fix typos. --- src/ast/rewriter/der.cpp | 2 +- src/duality/duality.h | 12 ++++++------ src/duality/duality_rpfp.cpp | 4 ++-- src/math/polynomial/polynomial.cpp | 10 +++++----- src/muz/spacer/spacer_unsat_core_learner.cpp | 2 +- src/qe/qe_lite.cpp | 2 +- src/smt/theory_arith_core.h | 2 +- src/smt/theory_arith_nl.h | 4 ++-- src/tactic/arith/fix_dl_var_tactic.cpp | 2 +- src/tactic/core/occf_tactic.cpp | 2 +- src/tactic/core/occf_tactic.h | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ast/rewriter/der.cpp b/src/ast/rewriter/der.cpp index 56f895b8a..d1fecf2fb 100644 --- a/src/ast/rewriter/der.cpp +++ b/src/ast/rewriter/der.cpp @@ -260,7 +260,7 @@ void der_sort_vars(ptr_vector & vars, ptr_vector & definitions, unsig vidx = to_var(t)->get_idx(); if (fr.second == 0) { CTRACE("der_bug", vidx >= definitions.size(), tout << "vidx: " << vidx << "\n";); - // Remark: The size of definitions may be smaller than the number of variables occuring in the quantified formula. + // Remark: The size of definitions may be smaller than the number of variables occurring in the quantified formula. if (definitions.get(vidx, 0) != 0) { if (visiting.is_marked(t)) { // cycle detected: remove t diff --git a/src/duality/duality.h b/src/duality/duality.h index e8f36a0cd..f1aba90bc 100644 --- a/src/duality/duality.h +++ b/src/duality/duality.h @@ -722,7 +722,7 @@ namespace Duality { check_result CheckUpdateModel(Node *root, std::vector assumps); - /** Determines the value in the counterexample of a symbol occuring in the transformer formula of + /** Determines the value in the counterexample of a symbol occurring in the transformer formula of * a given edge. */ Term Eval(Edge *e, Term t); @@ -731,7 +731,7 @@ namespace Duality { Term EvalNode(Node *p); - /** Returns true if the given node is empty in the primal solution. For proecudure summaries, + /** Returns true if the given node is empty in the primal solution. For procedure summaries, this means that the procedure is not called in the current counter-model. */ bool Empty(Node *p); @@ -854,7 +854,7 @@ namespace Duality { /** Write the RPFP to a file (currently in SMTLIB 1.2 format) */ void WriteProblemToFile(std::string filename, FileFormat format = DualityFormat); - /** Read the RPFP from a file (in specificed format) */ + /** Read the RPFP from a file (in specified format) */ void ReadProblemFromFile(std::string filename, FileFormat format = DualityFormat); /** Translate problem to Horn clause form */ @@ -870,9 +870,9 @@ namespace Duality { std::vector edges; /** Fuse a vector of transformers. If the total number of inputs of the transformers - is N, then the result is an N-ary transfomer whose output is the union of - the outputs of the given transformers. The is, suppose we have a vetor of transfoermers - {T_i(r_i1,...,r_iN(i) : i=1..M}. The the result is a transformer + is N, then the result is an N-ary transformer whose output is the union of + the outputs of the given transformers. The is, suppose we have a vector of transformers + {T_i(r_i1,...,r_iN(i) : i=1..M}. The result is a transformer F(r_11,...,r_iN(1),...,r_M1,...,r_MN(M)) = T_1(r_11,...,r_iN(1)) U ... U T_M(r_M1,...,r_MN(M)) diff --git a/src/duality/duality_rpfp.cpp b/src/duality/duality_rpfp.cpp index b6dd42f00..81ed3d017 100755 --- a/src/duality/duality_rpfp.cpp +++ b/src/duality/duality_rpfp.cpp @@ -1491,7 +1491,7 @@ namespace Duality { return res; } - /** Determines the value in the counterexample of a symbol occuring in the transformer formula of + /** Determines the value in the counterexample of a symbol occurring in the transformer formula of * a given edge. */ RPFP::Term RPFP::Eval(Edge *e, Term t) @@ -1500,7 +1500,7 @@ namespace Duality { return dualModel.eval(tl); } - /** Returns true if the given node is empty in the primal solution. For proecudure summaries, + /** Returns true if the given node is empty in the primal solution. For proceudure summaries, this means that the procedure is not called in the current counter-model. */ bool RPFP::Empty(Node *p) diff --git a/src/math/polynomial/polynomial.cpp b/src/math/polynomial/polynomial.cpp index 51d8489e3..dcd5af1cc 100644 --- a/src/math/polynomial/polynomial.cpp +++ b/src/math/polynomial/polynomial.cpp @@ -1421,7 +1421,7 @@ namespace polynomial { } } - // Return the maximal variable y occuring in [m_ms + start, m_ms + end) that is smaller than x + // Return the maximal variable y occurring in [m_ms + start, m_ms + end) that is smaller than x var max_smaller_than(unsigned start, unsigned end, var x) { var max = null_var; for (unsigned i = start; i < end; i++) { @@ -1456,7 +1456,7 @@ namespace polynomial { } /** - \brief Make sure that the first monomial contains the maximal variable x occuring in the polynomial, + \brief Make sure that the first monomial contains the maximal variable x occurring in the polynomial, and x occurs with maximal degree. */ void make_first_maximal() { @@ -3209,7 +3209,7 @@ namespace polynomial { typedef sbuffer var_buffer; /** - Store in pws the variables occuring in p and their (minimal or maximal) degrees. + Store in pws the variables occurring in p and their (minimal or maximal) degrees. */ unsigned_vector m_var_degrees_tmp; template @@ -3470,7 +3470,7 @@ namespace polynomial { pp = mk_one(); return; } - // Apply filter and collect powers of x occuring in p + // Apply filter and collect powers of x occurring in p // The quick filter is the following: // If p contains a monomial x^k and no monomial of the form m*x^k m != 1, then // c = m_unit_poly @@ -3479,7 +3479,7 @@ namespace polynomial { // - found monomial x^k then iccp_powers[k]++; // - found monomial m*x^k then iccp_powers[k]+=2; // If after traversing p, there is a k s.t. iccp_powers[k] == 1, we know c == 1 - // We store iccp_powers the powers of x occuring in p. + // We store iccp_powers the powers of x occurring in p. sbuffer iccp_filter; sbuffer iccp_powers; iccp_filter.resize(d+1, 0); diff --git a/src/muz/spacer/spacer_unsat_core_learner.cpp b/src/muz/spacer/spacer_unsat_core_learner.cpp index bc066d32d..f36143c5f 100644 --- a/src/muz/spacer/spacer_unsat_core_learner.cpp +++ b/src/muz/spacer/spacer_unsat_core_learner.cpp @@ -46,7 +46,7 @@ void unsat_core_learner::compute_unsat_core(proof *root, expr_set& asserted_b, e verbose_stream() << "Reduced proof:\n" << mk_ismt2_pp(pr, m) << "\n"; ); - // compute symbols occuring in B + // compute symbols occurring in B collect_symbols_b(asserted_b); // traverse proof diff --git a/src/qe/qe_lite.cpp b/src/qe/qe_lite.cpp index 3975945cb..1220bd571 100644 --- a/src/qe/qe_lite.cpp +++ b/src/qe/qe_lite.cpp @@ -125,7 +125,7 @@ namespace eq { vidx = to_var(t)->get_idx(); if (fr.second == 0) { CTRACE("der_bug", vidx >= definitions.size(), tout << "vidx: " << vidx << "\n";); - // Remark: The size of definitions may be smaller than the number of variables occuring in the quantified formula. + // Remark: The size of definitions may be smaller than the number of variables occurring in the quantified formula. if (definitions.get(vidx, 0) != 0) { if (visiting.is_marked(t)) { // cycle detected: remove t diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index b00648c36..03830f7d0 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -40,7 +40,7 @@ namespace smt { template void theory_arith::found_underspecified_op(app * n) { if (!m_found_underspecified_op) { - TRACE("arith", tout << "found underspecificed expression:\n" << mk_pp(n, get_manager()) << "\n";); + TRACE("arith", tout << "found underspecified expression:\n" << mk_pp(n, get_manager()) << "\n";); get_context().push_trail(value_trail(m_found_underspecified_op)); m_found_underspecified_op = true; } diff --git a/src/smt/theory_arith_nl.h b/src/smt/theory_arith_nl.h index 87b811e8f..7eee008e9 100644 --- a/src/smt/theory_arith_nl.h +++ b/src/smt/theory_arith_nl.h @@ -141,8 +141,8 @@ namespace smt { \brief Return the number of variables that do not have bounds associated with it. The result is 0, 1, or 2. The value 2 means "2 or more". - The second value is the idx of the a variable that does not - have bounds associated with it. It is only usefull when the first value is 1. + The second value is the idx of the variable that does not + have bounds associated with it. It is only useful when the first value is 1. The second value is -1 if such variable does not exist, that is, the first value is 0. diff --git a/src/tactic/arith/fix_dl_var_tactic.cpp b/src/tactic/arith/fix_dl_var_tactic.cpp index 7ff7bd835..2c25c12e1 100644 --- a/src/tactic/arith/fix_dl_var_tactic.cpp +++ b/src/tactic/arith/fix_dl_var_tactic.cpp @@ -196,7 +196,7 @@ class fix_dl_var_tactic : public tactic { app * most_occs() { // We try to choose a variable that when set to 0 will generate many bounded variables. - // That is why we give preference to variables occuring in non-nested inequalities. + // That is why we give preference to variables occurring in non-nested inequalities. unsigned best1, best2; app * r1, * r2; r1 = most_occs(m_non_nested_occs, best1); diff --git a/src/tactic/core/occf_tactic.cpp b/src/tactic/core/occf_tactic.cpp index 6d9d63971..254f8166c 100644 --- a/src/tactic/core/occf_tactic.cpp +++ b/src/tactic/core/occf_tactic.cpp @@ -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. diff --git a/src/tactic/core/occf_tactic.h b/src/tactic/core/occf_tactic.h index 80f8f6042..0ef7eb1f6 100644 --- a/src/tactic/core/occf_tactic.h +++ b/src/tactic/core/occf_tactic.h @@ -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. From 757b7c66efa6b8e081489b3c6105d324ff009beb Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Feb 2018 14:29:54 +0700 Subject: [PATCH 169/263] Remove unnecessary value parameter copies. --- src/ast/rewriter/bv_bounds.cpp | 12 +++++----- src/ast/rewriter/bv_bounds.h | 16 +++++++------- src/duality/duality.h | 2 +- src/duality/duality_rpfp.cpp | 2 +- src/interp/iz3mgr.h | 28 ++++++++++++------------ src/util/lp/core_solver_pretty_printer.h | 2 +- src/util/lp/mps_reader.h | 18 +++++++-------- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/ast/rewriter/bv_bounds.cpp b/src/ast/rewriter/bv_bounds.cpp index fd263efb2..0a32f8bc2 100644 --- a/src/ast/rewriter/bv_bounds.cpp +++ b/src/ast/rewriter/bv_bounds.cpp @@ -449,7 +449,7 @@ bool bv_bounds::add_constraint(expr* e) { return m_okay; } -bool bv_bounds::add_bound_unsigned(app * v, numeral a, numeral b, bool negate) { +bool bv_bounds::add_bound_unsigned(app * v, const numeral& a, const numeral& b, bool negate) { TRACE("bv_bounds", tout << "bound_unsigned " << mk_ismt2_pp(v, m_m) << ": " << (negate ? "~[" : "[") << a << ";" << b << "]" << std::endl;); const unsigned bv_sz = m_bv_util.get_bv_size(v); const numeral& zero = numeral::zero(); @@ -472,7 +472,7 @@ bool bv_bounds::add_bound_unsigned(app * v, numeral a, numeral b, bool negate) { } } -bv_bounds::conv_res bv_bounds::convert_signed(app * v, numeral a, numeral b, bool negate, vector& nis) { +bv_bounds::conv_res bv_bounds::convert_signed(app * v, const numeral& a, const numeral& b, bool negate, vector& nis) { TRACE("bv_bounds", tout << "convert_signed " << mk_ismt2_pp(v, m_m) << ":" << (negate ? "~[" : "[") << a << ";" << b << "]" << std::endl;); const unsigned bv_sz = m_bv_util.get_bv_size(v); SASSERT(a <= b); @@ -496,7 +496,7 @@ bv_bounds::conv_res bv_bounds::convert_signed(app * v, numeral a, numeral b, boo } } -bool bv_bounds::add_bound_signed(app * v, numeral a, numeral b, bool negate) { +bool bv_bounds::add_bound_signed(app * v, const numeral& a, const numeral& b, bool negate) { TRACE("bv_bounds", tout << "bound_signed " << mk_ismt2_pp(v, m_m) << ":" << (negate ? "~" : " ") << a << ";" << b << std::endl;); const unsigned bv_sz = m_bv_util.get_bv_size(v); SASSERT(a <= b); @@ -519,7 +519,7 @@ bool bv_bounds::add_bound_signed(app * v, numeral a, numeral b, bool negate) { } } -bool bv_bounds::bound_lo(app * v, numeral l) { +bool bv_bounds::bound_lo(app * v, const numeral& l) { SASSERT(in_range(v, l)); TRACE("bv_bounds", tout << "lower " << mk_ismt2_pp(v, m_m) << ":" << l << std::endl;); // l <= v @@ -530,7 +530,7 @@ bool bv_bounds::bound_lo(app * v, numeral l) { return m_okay; } -bool bv_bounds::bound_up(app * v, numeral u) { +bool bv_bounds::bound_up(app * v, const numeral& u) { SASSERT(in_range(v, u)); TRACE("bv_bounds", tout << "upper " << mk_ismt2_pp(v, m_m) << ":" << u << std::endl;); // v <= u @@ -541,7 +541,7 @@ bool bv_bounds::bound_up(app * v, numeral u) { return m_okay; } -bool bv_bounds::add_neg_bound(app * v, numeral a, numeral b) { +bool bv_bounds::add_neg_bound(app * v, const numeral& a, const numeral& b) { TRACE("bv_bounds", tout << "negative bound " << mk_ismt2_pp(v, m_m) << ":" << a << ";" << b << std::endl;); bv_bounds::interval negative_interval(a, b); SASSERT(m_bv_util.is_bv(v)); diff --git a/src/ast/rewriter/bv_bounds.h b/src/ast/rewriter/bv_bounds.h index 4a7226fa7..775941d1d 100644 --- a/src/ast/rewriter/bv_bounds.h +++ b/src/ast/rewriter/bv_bounds.h @@ -49,11 +49,11 @@ public: // bounds addition methods **/ bool add_constraint(expr* e); - bool bound_up(app * v, numeral u); // v <= u - bool bound_lo(app * v, numeral l); // l <= v - inline bool add_neg_bound(app * v, numeral a, numeral b); // not (a<=v<=b) - bool add_bound_signed(app * v, numeral a, numeral b, bool negate); - bool add_bound_unsigned(app * v, numeral a, numeral b, bool negate); + bool bound_up(app * v, const numeral& u); // v <= u + bool bound_lo(app * v, const numeral& l); // l <= v + inline bool add_neg_bound(app * v, const numeral& a, const numeral& b); // not (a<=v<=b) + bool add_bound_signed(app * v, const numeral& a, const numeral& b, bool negate); + bool add_bound_unsigned(app * v, const numeral& a, const numeral& b, bool negate); public: bool is_sat(); ///< Determine if the set of considered constraints is satisfiable. bool is_okay(); @@ -70,7 +70,7 @@ protected: enum conv_res { CONVERTED, UNSAT, UNDEF }; conv_res convert(expr * e, vector& nis, bool negated); conv_res record(app * v, numeral lo, numeral hi, bool negated, vector& nis); - conv_res convert_signed(app * v, numeral a, numeral b, bool negate, vector& nis); + conv_res convert_signed(app * v, const numeral& a, const numeral& b, bool negate, vector& nis); typedef vector intervals; typedef obj_map intervals_map; @@ -83,7 +83,7 @@ protected: bool m_okay; bool is_sat(app * v); bool is_sat_core(app * v); - inline bool in_range(app *v, numeral l); + inline bool in_range(app *v, const numeral& l); inline bool is_constant_add(unsigned bv_sz, expr * e, app*& v, numeral& val); void record_singleton(app * v, numeral& singleton_value); inline bool to_bound(const expr * e) const; @@ -99,7 +99,7 @@ inline bool bv_bounds::to_bound(const expr * e) const { && !m_bv_util.is_numeral(e); } -inline bool bv_bounds::in_range(app *v, bv_bounds::numeral n) { +inline bool bv_bounds::in_range(app *v, const bv_bounds::numeral& n) { const unsigned bv_sz = m_bv_util.get_bv_size(v); const bv_bounds::numeral zero(0); const bv_bounds::numeral mod(rational::power_of_two(bv_sz)); diff --git a/src/duality/duality.h b/src/duality/duality.h index e8f36a0cd..71687c648 100644 --- a/src/duality/duality.h +++ b/src/duality/duality.h @@ -725,7 +725,7 @@ namespace Duality { /** Determines the value in the counterexample of a symbol occuring in the transformer formula of * a given edge. */ - Term Eval(Edge *e, Term t); + Term Eval(Edge *e, const Term& t); /** Return the fact derived at node p in a counterexample. */ diff --git a/src/duality/duality_rpfp.cpp b/src/duality/duality_rpfp.cpp index b6dd42f00..5ddc196c8 100755 --- a/src/duality/duality_rpfp.cpp +++ b/src/duality/duality_rpfp.cpp @@ -1494,7 +1494,7 @@ namespace Duality { /** Determines the value in the counterexample of a symbol occuring in the transformer formula of * a given edge. */ - RPFP::Term RPFP::Eval(Edge *e, Term t) + RPFP::Term RPFP::Eval(Edge *e, const Term& t) { Term tl = Localize(e, t); return dualModel.eval(tl); diff --git a/src/interp/iz3mgr.h b/src/interp/iz3mgr.h index 0ad751326..8de1a44e8 100755 --- a/src/interp/iz3mgr.h +++ b/src/interp/iz3mgr.h @@ -245,7 +245,7 @@ class iz3mgr { /** Methods for destructing ast. */ - int num_args(ast t){ + int num_args(const ast& t){ ast_kind dk = t.raw()->get_kind(); switch(dk){ case AST_APP: @@ -285,7 +285,7 @@ class iz3mgr { return res; } - symb sym(ast t){ + symb sym(const ast& t){ raw_ast *_ast = t.raw(); return is_app(_ast) ? to_app(_ast)->get_decl() : 0; } @@ -302,7 +302,7 @@ class iz3mgr { } } - type get_type(ast t){ + type get_type(const ast& t){ return m().get_sort(to_expr(t.raw())); } @@ -442,23 +442,23 @@ class iz3mgr { bool is_farkas_coefficient_negative(const ast &proof, int n); - bool is_true(ast t){ + bool is_true(const ast& t){ return op(t) == True; } - bool is_false(ast t){ + bool is_false(const ast& t){ return op(t) == False; } - bool is_iff(ast t){ + bool is_iff(const ast& t){ return op(t) == Iff; } - bool is_or(ast t){ + bool is_or(const ast& t){ return op(t) == Or; } - bool is_not(ast t){ + bool is_not(const ast& t){ return op(t) == Not; } @@ -472,7 +472,7 @@ class iz3mgr { // Some constructors that simplify things - ast mk_not(ast x){ + ast mk_not(const ast& x){ opr o = op(x); if(o == True) return make(False); if(o == False) return make(True); @@ -480,7 +480,7 @@ class iz3mgr { return make(Not,x); } - ast mk_and(ast x, ast y){ + ast mk_and(const ast& x, const ast& y){ opr ox = op(x); opr oy = op(y); if(ox == True) return y; @@ -491,7 +491,7 @@ class iz3mgr { return make(And,x,y); } - ast mk_or(ast x, ast y){ + ast mk_or(const ast& x, const ast& y){ opr ox = op(x); opr oy = op(y); if(ox == False) return y; @@ -502,7 +502,7 @@ class iz3mgr { return make(Or,x,y); } - ast mk_implies(ast x, ast y){ + ast mk_implies(const ast& x, const ast& y){ opr ox = op(x); opr oy = op(y); if(ox == True) return y; @@ -537,7 +537,7 @@ class iz3mgr { return make(And,conjs); } - ast mk_equal(ast x, ast y){ + ast mk_equal(const ast& x, const ast& y){ if(x == y) return make(True); opr ox = op(x); opr oy = op(y); @@ -550,7 +550,7 @@ class iz3mgr { return make(Equal,x,y); } - ast z3_ite(ast x, ast y, ast z){ + ast z3_ite(const ast& x, const ast& y, const ast& z){ opr ox = op(x); opr oy = op(y); opr oz = op(z); diff --git a/src/util/lp/core_solver_pretty_printer.h b/src/util/lp/core_solver_pretty_printer.h index 20b2c1cbe..87c528792 100644 --- a/src/util/lp/core_solver_pretty_printer.h +++ b/src/util/lp/core_solver_pretty_printer.h @@ -86,7 +86,7 @@ public: unsigned get_column_width(unsigned column); - unsigned regular_cell_width(unsigned row, unsigned column, std::string name) { + unsigned regular_cell_width(unsigned row, unsigned column, const std::string & name) { return regular_cell_string(row, column, name).size(); } diff --git a/src/util/lp/mps_reader.h b/src/util/lp/mps_reader.h index 1b020407d..916e56322 100644 --- a/src/util/lp/mps_reader.h +++ b/src/util/lp/mps_reader.h @@ -95,7 +95,7 @@ inline vector string_split(const std::string &source, const char *d return results; } -inline vector split_and_trim(std::string line) { +inline vector split_and_trim(const std::string &line) { auto split = string_split(line, " \t", false); vector ret; for (auto s : split) { @@ -127,9 +127,9 @@ class mps_reader { std::string m_name; bound * m_bound; unsigned m_index; - column(std::string name, unsigned index): m_name(name), - m_bound(nullptr), - m_index(index) { + column(const std::string &name, unsigned index): m_name(name), + m_bound(nullptr), + m_index(index) { } }; @@ -140,7 +140,7 @@ class mps_reader { unsigned m_index; T m_right_side; T m_range; - row(row_type type, std::string name, unsigned index) : + row(row_type type, const std::string &name, unsigned index) : m_type(type), m_name(name), m_index(index), @@ -254,7 +254,7 @@ class mps_reader { } while (m_is_OK); } - void read_column_by_columns(std::string column_name, std::string column_data) { + void read_column_by_columns(const std::string & column_name, std::string column_data) { // uph, let us try to work with columns if (column_data.size() >= 22) { std::string ss = column_data.substr(0, 8); @@ -283,7 +283,7 @@ class mps_reader { } } - void read_column(std::string column_name, std::string column_data){ + void read_column(const std::string & column_name, const std::string & column_data){ auto tokens = split_and_trim(column_data); for (unsigned i = 0; i < tokens.size() - 1; i+= 2) { auto row_name = tokens[i]; @@ -421,7 +421,7 @@ class mps_reader { } - void read_bound_by_columns(std::string colstr) { + void read_bound_by_columns(const std::string & colstr) { if (colstr.size() < 14) { (*m_message_stream) << "line is too short" << std::endl; (*m_message_stream) << m_line << std::endl; @@ -763,7 +763,7 @@ public: } } - mps_reader(std::string file_name): + mps_reader(const std::string & file_name): m_is_OK(true), m_file_name(file_name), m_file_stream(file_name), From b7d1753843609dc007ea2d919e62b910da632da6 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Fri, 9 Feb 2018 21:15:02 +0700 Subject: [PATCH 170/263] Use override rather than virtual. --- src/ast/arith_decl_plugin.h | 38 +-- src/ast/array_decl_plugin.h | 18 +- src/ast/ast.h | 74 +++--- src/ast/ast_printer.cpp | 20 +- src/ast/ast_printer.h | 2 +- src/ast/ast_smt2_pp.h | 18 +- src/ast/bv_decl_plugin.h | 32 +-- src/ast/datatype_decl_plugin.h | 54 ++-- src/ast/dl_decl_plugin.h | 18 +- src/ast/expr2polynomial.h | 6 +- src/ast/expr_functors.h | 2 +- src/ast/format.cpp | 14 +- src/ast/fpa_decl_plugin.h | 30 +-- src/ast/normal_forms/defined_names.cpp | 2 +- src/ast/normal_forms/name_exprs.cpp | 16 +- src/ast/pb_decl_plugin.h | 14 +- src/ast/proofs/proof_checker.h | 22 +- src/ast/rewriter/elim_bounds.h | 2 +- src/ast/rewriter/expr_replacer.cpp | 22 +- src/ast/rewriter/maximize_ac_sharing.h | 4 +- src/ast/rewriter/pull_ite_tree.h | 4 +- src/ast/rewriter/push_app_ite.h | 2 +- src/ast/rewriter/rewriter.h | 6 +- src/ast/rewriter/seq_rewriter.cpp | 16 +- src/ast/seq_decl_plugin.h | 28 +- src/cmd_context/basic_cmds.cpp | 134 +++++----- src/cmd_context/cmd_context.cpp | 26 +- src/cmd_context/cmd_context.h | 36 +-- src/cmd_context/echo_tactic.cpp | 22 +- src/cmd_context/eval_cmd.cpp | 14 +- src/cmd_context/extra_cmds/dbg_cmds.cpp | 60 ++--- .../extra_cmds/polynomial_cmds.cpp | 32 +-- src/cmd_context/interpolant_cmds.cpp | 16 +- src/cmd_context/parametric_cmd.h | 28 +- src/cmd_context/pdecl.cpp | 68 ++--- src/cmd_context/pdecl.h | 74 +++--- src/cmd_context/simplify_cmd.cpp | 18 +- src/cmd_context/tactic_cmds.cpp | 40 +-- src/duality/duality.h | 36 +-- src/duality/duality_solver.cpp | 76 +++--- src/math/automata/boolean_algebra.h | 2 +- src/math/polynomial/polynomial_var2value.h | 6 +- src/model/model.cpp | 2 +- src/model/model.h | 12 +- src/nlsat/nlsat_assignment.h | 12 +- src/nlsat/nlsat_solver.cpp | 4 +- src/nlsat/tactic/goal2nlsat.cpp | 4 +- src/nlsat/tactic/nlsat_tactic.cpp | 26 +- src/solver/check_sat_result.h | 18 +- src/solver/combined_solver.cpp | 58 ++-- src/solver/solver.h | 2 +- src/solver/solver2tactic.cpp | 28 +- src/solver/solver_na2as.h | 22 +- src/solver/solver_pool.cpp | 38 +-- src/solver/tactic2solver.cpp | 48 ++-- src/tactic/aig/aig_tactic.cpp | 18 +- src/tactic/arith/add_bounds_tactic.cpp | 24 +- src/tactic/arith/arith_bounds_tactic.cpp | 14 +- src/tactic/arith/card2bv_tactic.cpp | 20 +- src/tactic/arith/degree_shift_tactic.cpp | 16 +- src/tactic/arith/diff_neq_tactic.cpp | 24 +- src/tactic/arith/elim01_tactic.cpp | 22 +- src/tactic/arith/eq2bv_tactic.cpp | 25 +- src/tactic/arith/factor_tactic.cpp | 20 +- src/tactic/arith/fix_dl_var_tactic.cpp | 20 +- src/tactic/arith/fm_tactic.cpp | 28 +- src/tactic/arith/lia2card_tactic.cpp | 18 +- src/tactic/arith/lia2pb_tactic.cpp | 20 +- src/tactic/arith/nla2bv_tactic.cpp | 20 +- src/tactic/arith/normalize_bounds_tactic.cpp | 20 +- src/tactic/arith/pb2bv_model_converter.h | 10 +- src/tactic/arith/pb2bv_tactic.cpp | 22 +- src/tactic/arith/probe_arith.cpp | 34 +-- src/tactic/arith/propagate_ineqs_tactic.cpp | 12 +- src/tactic/arith/purify_arith_tactic.cpp | 20 +- src/tactic/arith/recover_01_tactic.cpp | 18 +- src/tactic/bv/bit_blaster_model_converter.cpp | 10 +- src/tactic/bv/bit_blaster_tactic.cpp | 20 +- src/tactic/bv/bv1_blaster_tactic.cpp | 22 +- src/tactic/bv/bv_bound_chk_tactic.cpp | 16 +- src/tactic/bv/bv_bounds_tactic.cpp | 28 +- src/tactic/bv/bv_size_reduction_tactic.cpp | 8 +- src/tactic/bv/bvarray2uf_tactic.cpp | 20 +- src/tactic/bv/dt2bv_tactic.cpp | 22 +- src/tactic/bv/elim_small_bv_tactic.cpp | 14 +- src/tactic/bv/max_bv_sharing_tactic.cpp | 20 +- src/tactic/converter.h | 12 +- src/tactic/core/blast_term_ite_tactic.cpp | 20 +- src/tactic/core/cofactor_term_ite_tactic.cpp | 20 +- src/tactic/core/collect_statistics_tactic.cpp | 22 +- src/tactic/core/ctx_simplify_tactic.cpp | 12 +- src/tactic/core/ctx_simplify_tactic.h | 20 +- src/tactic/core/der_tactic.cpp | 16 +- src/tactic/core/distribute_forall_tactic.cpp | 14 +- src/tactic/core/dom_simplify_tactic.h | 32 +-- src/tactic/core/elim_term_ite_tactic.cpp | 20 +- src/tactic/core/elim_uncnstr_tactic.cpp | 24 +- src/tactic/core/injectivity_tactic.cpp | 20 +- src/tactic/core/nnf_tactic.cpp | 20 +- src/tactic/core/occf_tactic.cpp | 20 +- src/tactic/core/pb_preprocess_tactic.cpp | 25 +- src/tactic/core/propagate_values_tactic.cpp | 20 +- src/tactic/core/reduce_args_tactic.cpp | 8 +- src/tactic/core/simplify_tactic.h | 22 +- src/tactic/core/solve_eqs_tactic.cpp | 24 +- src/tactic/core/split_clause_tactic.cpp | 26 +- src/tactic/core/symmetry_reduce_tactic.cpp | 16 +- src/tactic/core/tseitin_cnf_tactic.cpp | 24 +- src/tactic/equiv_proof_converter.h | 6 +- src/tactic/extension_model_converter.h | 8 +- src/tactic/filter_model_converter.h | 12 +- src/tactic/fpa/fpa2bv_model_converter.h | 10 +- src/tactic/fpa/fpa2bv_tactic.cpp | 20 +- src/tactic/fpa/qffp_tactic.cpp | 8 +- src/tactic/horn_subsume_model_converter.h | 4 +- src/tactic/model_converter.cpp | 34 +-- src/tactic/nlsat_smt/nl_purify_tactic.cpp | 22 +- .../portfolio/bounded_int2bv_solver.cpp | 44 +-- src/tactic/portfolio/enum2bv_solver.cpp | 44 +-- src/tactic/portfolio/pb2bv_solver.cpp | 44 +-- src/tactic/portfolio/smt_strategic_solver.cpp | 4 +- src/tactic/probe.cpp | 52 ++-- src/tactic/proof_converter.cpp | 20 +- src/tactic/proof_converter.h | 2 +- src/tactic/replace_proof_converter.h | 6 +- src/tactic/sine_filter.cpp | 18 +- src/tactic/sls/sls_tactic.cpp | 24 +- src/tactic/smtlogics/qflia_tactic.cpp | 2 +- src/tactic/smtlogics/qfufbv_tactic.cpp | 16 +- src/tactic/tactic.cpp | 44 +-- src/tactic/tactic.h | 6 +- src/tactic/tactic_exception.h | 4 +- src/tactic/tactical.cpp | 251 +++++++++--------- src/tactic/ufbv/macro_finder_tactic.cpp | 20 +- src/tactic/ufbv/quasi_macros_tactic.cpp | 20 +- src/tactic/ufbv/ufbv_rewriter_tactic.cpp | 20 +- src/util/cancel_eh.h | 4 +- src/util/z3_exception.h | 8 +- 138 files changed, 1621 insertions(+), 1624 deletions(-) diff --git a/src/ast/arith_decl_plugin.h b/src/ast/arith_decl_plugin.h index 4850b52a8..6cebdaded 100644 --- a/src/ast/arith_decl_plugin.h +++ b/src/ast/arith_decl_plugin.h @@ -145,7 +145,7 @@ protected: bool m_convert_int_numerals_to_real; func_decl * mk_func_decl(decl_kind k, bool is_real); - virtual void set_manager(ast_manager * m, family_id id); + void set_manager(ast_manager * m, family_id id) override; decl_kind fix_kind(decl_kind k, unsigned arity); void check_arity(unsigned arity, unsigned expected_arity); func_decl * mk_num_decl(unsigned num_parameters, parameter const * parameters, unsigned arity); @@ -153,38 +153,38 @@ protected: public: arith_decl_plugin(); - virtual ~arith_decl_plugin(); - virtual void finalize(); + ~arith_decl_plugin() override; + void finalize() override; algebraic_numbers::manager & am() const; algebraic_numbers_wrapper & aw() const; - virtual void del(parameter const & p); - virtual parameter translate(parameter const & p, decl_plugin & target); + void del(parameter const & p) override; + parameter translate(parameter const & p, decl_plugin & target) override; - virtual decl_plugin * mk_fresh() { + decl_plugin * mk_fresh() override { return alloc(arith_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned num_args, expr * const * args, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned num_args, expr * const * args, sort * range) override; - virtual bool is_value(app * e) const; + bool is_value(app * e) const override; - virtual bool is_unique_value(app * e) const; + bool is_unique_value(app * e) const override; - virtual bool are_equal(app * a, app * b) const; + bool are_equal(app * a, app * b) const override; - virtual bool are_distinct(app * a, app * b) const; + bool are_distinct(app * a, app * b) const override; - virtual void get_op_names(svector & op_names, symbol const & logic); + void get_op_names(svector & op_names, symbol const & logic) override; - virtual void get_sort_names(svector & sort_names, symbol const & logic); + void get_sort_names(svector & sort_names, symbol const & logic) override; app * mk_numeral(rational const & n, bool is_int); @@ -197,9 +197,9 @@ public: app * mk_e() const { return m_e; } - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; - virtual bool is_considered_uninterpreted(func_decl * f) { + bool is_considered_uninterpreted(func_decl * f) override { if (f->get_family_id() != get_family_id()) return false; switch (f->get_decl_kind()) diff --git a/src/ast/array_decl_plugin.h b/src/ast/array_decl_plugin.h index 911bb3f27..488ee71fb 100644 --- a/src/ast/array_decl_plugin.h +++ b/src/ast/array_decl_plugin.h @@ -98,9 +98,9 @@ class array_decl_plugin : public decl_plugin { bool is_array_sort(sort* s) const; public: array_decl_plugin(); - virtual ~array_decl_plugin() {} + ~array_decl_plugin() override {} - virtual decl_plugin * mk_fresh() { + decl_plugin * mk_fresh() override { return alloc(array_decl_plugin); } @@ -111,23 +111,23 @@ class array_decl_plugin : public decl_plugin { // parameters[n-1] - nth dimension // parameters[n] - range // - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; // // Contract for func_decl: // parameters[0] - array sort // Contract for others: // no parameters - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; - virtual void get_op_names(svector & op_names, symbol const & logic); + void get_op_names(svector & op_names, symbol const & logic) override; - virtual void get_sort_names(svector & sort_names, symbol const & logic); + void get_sort_names(svector & sort_names, symbol const & logic) override; - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; - virtual bool is_fully_interp(sort * s) const; + bool is_fully_interp(sort * s) const override; }; class array_recognizers { diff --git a/src/ast/ast.h b/src/ast/ast.h index 7a662a193..77049fa53 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -1129,7 +1129,7 @@ protected: unsigned num_parameters, parameter const* params, unsigned num_parents); - virtual void set_manager(ast_manager * m, family_id id); + void set_manager(ast_manager * m, family_id id) override; func_decl * mk_eq_decl_core(char const * name, decl_kind k, sort * s, ptr_vector & cache); func_decl * mk_ite_decl(sort * s); sort* join(sort* s1, sort* s2); @@ -1138,33 +1138,33 @@ protected: public: basic_decl_plugin(); - virtual ~basic_decl_plugin() {} - virtual void finalize(); + ~basic_decl_plugin() override {} + void finalize() override; - virtual decl_plugin * mk_fresh() { + decl_plugin * mk_fresh() override { return alloc(basic_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const* parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const* parameters) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned num_args, expr * const * args, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned num_args, expr * const * args, sort * range) override; - virtual void get_op_names(svector & op_names, symbol const & logic); + void get_op_names(svector & op_names, symbol const & logic) override; - virtual void get_sort_names(svector & sort_names, symbol const & logic); + void get_sort_names(svector & sort_names, symbol const & logic) override; - virtual bool is_value(app* a) const; + bool is_value(app* a) const override; - virtual bool is_unique_value(app* a) const; + bool is_unique_value(app* a) const override; sort * mk_bool_sort() const { return m_bool_sort; } sort * mk_proof_sort() const { return m_proof_sort; } - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; }; typedef app proof; /* a proof is just an application */ @@ -1188,15 +1188,15 @@ class label_decl_plugin : public decl_plugin { symbol m_lblneg; symbol m_lbllit; - virtual void set_manager(ast_manager * m, family_id id); + void set_manager(ast_manager * m, family_id id) override; public: label_decl_plugin(); - virtual ~label_decl_plugin(); + ~label_decl_plugin() override; - virtual decl_plugin * mk_fresh() { return alloc(label_decl_plugin); } + decl_plugin * mk_fresh() override { return alloc(label_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; /** contract: when label @@ -1210,8 +1210,8 @@ public: ... parameter[n-1] (symbol): label's tag. */ - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; }; // ----------------------------------- @@ -1230,12 +1230,12 @@ enum pattern_op_kind { */ class pattern_decl_plugin : public decl_plugin { public: - virtual decl_plugin * mk_fresh() { return alloc(pattern_decl_plugin); } + decl_plugin * mk_fresh() override { return alloc(pattern_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; }; // ----------------------------------- @@ -1263,21 +1263,21 @@ class model_value_decl_plugin : public decl_plugin { public: model_value_decl_plugin() {} - virtual decl_plugin * mk_fresh() { return alloc(model_value_decl_plugin); } + decl_plugin * mk_fresh() override { return alloc(model_value_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; /** contract: parameter[0]: (integer) value idx parameter[1]: (ast) sort of the value. */ - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; - virtual bool is_value(app* n) const; + bool is_value(app* n) const override; - virtual bool is_unique_value(app* a) const; + bool is_unique_value(app* a) const override; }; // ----------------------------------- @@ -1292,11 +1292,11 @@ class user_sort_plugin : public decl_plugin { public: user_sort_plugin() {} - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; decl_kind register_name(symbol s); - virtual decl_plugin * mk_fresh(); + decl_plugin * mk_fresh() override; }; @@ -2467,9 +2467,9 @@ class scoped_mark : public ast_mark { unsigned_vector m_lim; public: scoped_mark(ast_manager& m): m_stack(m) {} - virtual ~scoped_mark() {} - virtual void mark(ast * n, bool flag); - virtual void reset(); + ~scoped_mark() override {} + void mark(ast * n, bool flag) override; + void reset() override; void mark(ast * n); void push_scope(); void pop_scope(); diff --git a/src/ast/ast_printer.cpp b/src/ast/ast_printer.cpp index b5cf60ee9..63e855c59 100644 --- a/src/ast/ast_printer.cpp +++ b/src/ast/ast_printer.cpp @@ -25,24 +25,24 @@ class simple_ast_printer_context : public ast_printer_context { smt2_pp_environment_dbg & env() const { return *(m_env.get()); } public: simple_ast_printer_context(ast_manager & m):m_manager(m) { m_env = alloc(smt2_pp_environment_dbg, m); } - virtual ~simple_ast_printer_context() {} + ~simple_ast_printer_context() override {} ast_manager & m() const { return m_manager; } - virtual ast_manager & get_ast_manager() { return m_manager; } - virtual void display(std::ostream & out, sort * s, unsigned indent = 0) const { out << mk_ismt2_pp(s, m(), indent); } - virtual void display(std::ostream & out, expr * n, unsigned indent = 0) const { out << mk_ismt2_pp(n, m(), indent); } - virtual void display(std::ostream & out, func_decl * f, unsigned indent = 0) const { + ast_manager & get_ast_manager() override { return m_manager; } + void display(std::ostream & out, sort * s, unsigned indent = 0) const override { out << mk_ismt2_pp(s, m(), indent); } + void display(std::ostream & out, expr * n, unsigned indent = 0) const override { out << mk_ismt2_pp(n, m(), indent); } + void display(std::ostream & out, func_decl * f, unsigned indent = 0) const override { out << f->get_name(); } - virtual void pp(sort * s, format_ns::format_ref & r) const { mk_smt2_format(s, env(), params_ref(), r); } - virtual void pp(func_decl * f, format_ns::format_ref & r) const { mk_smt2_format(f, env(), params_ref(), r); } - virtual void pp(expr * n, format_ns::format_ref & r) const { + void pp(sort * s, format_ns::format_ref & r) const override { mk_smt2_format(s, env(), params_ref(), r); } + void pp(func_decl * f, format_ns::format_ref & r) const override { mk_smt2_format(f, env(), params_ref(), r); } + void pp(expr * n, format_ns::format_ref & r) const override { sbuffer buf; mk_smt2_format(n, env(), params_ref(), 0, 0, r, buf); } - virtual void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const { + void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const override { mk_smt2_format(n, env(), params_ref(), num_vars, var_prefix, r, var_names); } - virtual void display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer & var_names) const { + void display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer & var_names) const override { NOT_IMPLEMENTED_YET(); } diff --git a/src/ast/ast_printer.h b/src/ast/ast_printer.h index 87fa8ef3d..c962fedc5 100644 --- a/src/ast/ast_printer.h +++ b/src/ast/ast_printer.h @@ -45,7 +45,7 @@ public: class ast_printer_context : public ast_printer { public: - virtual ~ast_printer_context() {} + ~ast_printer_context() override {} virtual ast_manager & get_ast_manager() = 0; virtual std::ostream & regular_stream() { return std::cout; } virtual std::ostream & diagnostic_stream() { return std::cerr; } diff --git a/src/ast/ast_smt2_pp.h b/src/ast/ast_smt2_pp.h index 3e8b1aa39..041622b74 100644 --- a/src/ast/ast_smt2_pp.h +++ b/src/ast/ast_smt2_pp.h @@ -80,15 +80,15 @@ class smt2_pp_environment_dbg : public smt2_pp_environment { datalog::dl_decl_util m_dlutil; public: smt2_pp_environment_dbg(ast_manager & m):m_manager(m), m_autil(m), m_bvutil(m), m_arutil(m), m_futil(m), m_sutil(m), m_dtutil(m), m_dlutil(m) {} - virtual ast_manager & get_manager() const { return m_manager; } - virtual arith_util & get_autil() { return m_autil; } - virtual bv_util & get_bvutil() { return m_bvutil; } - virtual seq_util & get_sutil() { return m_sutil; } - virtual array_util & get_arutil() { return m_arutil; } - virtual fpa_util & get_futil() { return m_futil; } - virtual datalog::dl_decl_util& get_dlutil() { return m_dlutil; } - virtual datatype_util& get_dtutil() { return m_dtutil; } - virtual bool uses(symbol const & s) const { return false; } + ast_manager & get_manager() const override { return m_manager; } + arith_util & get_autil() override { return m_autil; } + bv_util & get_bvutil() override { return m_bvutil; } + seq_util & get_sutil() override { return m_sutil; } + array_util & get_arutil() override { return m_arutil; } + fpa_util & get_futil() override { return m_futil; } + datalog::dl_decl_util& get_dlutil() override { return m_dlutil; } + datatype_util& get_dtutil() override { return m_dtutil; } + bool uses(symbol const & s) const override { return false; } }; void mk_smt2_format(expr * n, smt2_pp_environment & env, params_ref const & p, diff --git a/src/ast/bv_decl_plugin.h b/src/ast/bv_decl_plugin.h index a4ea7af80..18054ca09 100644 --- a/src/ast/bv_decl_plugin.h +++ b/src/ast/bv_decl_plugin.h @@ -204,7 +204,7 @@ protected: vector > m_bit2bool; ptr_vector m_mkbv; - virtual void set_manager(ast_manager * m, family_id id); + void set_manager(ast_manager * m, family_id id) override; void mk_bv_sort(unsigned bv_size); sort * get_bv_sort(unsigned bv_size); func_decl * mk_func_decl(decl_kind k, unsigned bv_size); @@ -241,34 +241,34 @@ protected: public: bv_decl_plugin(); - virtual ~bv_decl_plugin() {} - virtual void finalize(); + ~bv_decl_plugin() override {} + void finalize() override; - virtual decl_plugin * mk_fresh() { return alloc(bv_decl_plugin); } + decl_plugin * mk_fresh() override { return alloc(bv_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned num_args, expr * const * args, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned num_args, expr * const * args, sort * range) override; - virtual bool is_value(app * e) const; + bool is_value(app * e) const override; - virtual bool is_unique_value(app * e) const { return is_value(e); } + bool is_unique_value(app * e) const override { return is_value(e); } - virtual void get_op_names(svector & op_names, symbol const & logic); + void get_op_names(svector & op_names, symbol const & logic) override; - virtual void get_sort_names(svector & sort_names, symbol const & logic); + void get_sort_names(svector & sort_names, symbol const & logic) override; - virtual bool are_distinct(app* a, app* b) const; + bool are_distinct(app* a, app* b) const override; - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; bool get_int2bv_size(unsigned num_parameters, parameter const * parameters, int & result); - virtual bool is_considered_uninterpreted(func_decl * f) { + bool is_considered_uninterpreted(func_decl * f) override { if (f->get_family_id() != get_family_id()) return false; switch (f->get_decl_kind()) { diff --git a/src/ast/datatype_decl_plugin.h b/src/ast/datatype_decl_plugin.h index 515ca6e20..b61142909 100644 --- a/src/ast/datatype_decl_plugin.h +++ b/src/ast/datatype_decl_plugin.h @@ -124,16 +124,16 @@ namespace datatype { struct offset : public size { sort_size m_offset; offset(sort_size const& s): m_offset(s) {} - virtual ~offset() {} - virtual size* subst(obj_map& S) { return this; } - virtual sort_size eval(obj_map const& S) { return m_offset; } + ~offset() override {} + size* subst(obj_map& S) override { return this; } + sort_size eval(obj_map const& S) override { return m_offset; } }; struct plus : public size { size* m_arg1, *m_arg2; plus(size* a1, size* a2): m_arg1(a1), m_arg2(a2) { a1->inc_ref(); a2->inc_ref();} - virtual ~plus() { m_arg1->dec_ref(); m_arg2->dec_ref(); } - virtual size* subst(obj_map& S) { return mk_plus(m_arg1->subst(S), m_arg2->subst(S)); } - virtual sort_size eval(obj_map const& S) { + ~plus() override { m_arg1->dec_ref(); m_arg2->dec_ref(); } + size* subst(obj_map& S) override { return mk_plus(m_arg1->subst(S), m_arg2->subst(S)); } + sort_size eval(obj_map const& S) override { sort_size s1 = m_arg1->eval(S); sort_size s2 = m_arg2->eval(S); if (s1.is_infinite()) return s1; @@ -147,9 +147,9 @@ namespace datatype { struct times : public size { size* m_arg1, *m_arg2; times(size* a1, size* a2): m_arg1(a1), m_arg2(a2) { a1->inc_ref(); a2->inc_ref(); } - virtual ~times() { m_arg1->dec_ref(); m_arg2->dec_ref(); } - virtual size* subst(obj_map& S) { return mk_times(m_arg1->subst(S), m_arg2->subst(S)); } - virtual sort_size eval(obj_map const& S) { + ~times() override { m_arg1->dec_ref(); m_arg2->dec_ref(); } + size* subst(obj_map& S) override { return mk_times(m_arg1->subst(S), m_arg2->subst(S)); } + sort_size eval(obj_map const& S) override { sort_size s1 = m_arg1->eval(S); sort_size s2 = m_arg2->eval(S); if (s1.is_infinite()) return s1; @@ -163,9 +163,9 @@ namespace datatype { struct power : public size { size* m_arg1, *m_arg2; power(size* a1, size* a2): m_arg1(a1), m_arg2(a2) { a1->inc_ref(); a2->inc_ref(); } - virtual ~power() { m_arg1->dec_ref(); m_arg2->dec_ref(); } - virtual size* subst(obj_map& S) { return mk_power(m_arg1->subst(S), m_arg2->subst(S)); } - virtual sort_size eval(obj_map const& S) { + ~power() override { m_arg1->dec_ref(); m_arg2->dec_ref(); } + size* subst(obj_map& S) override { return mk_power(m_arg1->subst(S), m_arg2->subst(S)); } + sort_size eval(obj_map const& S) override { sort_size s1 = m_arg1->eval(S); sort_size s2 = m_arg2->eval(S); // s1^s2 @@ -183,9 +183,9 @@ namespace datatype { struct sparam : public size { sort_ref m_param; sparam(sort_ref& p): m_param(p) {} - virtual ~sparam() {} - virtual size* subst(obj_map& S) { return S[m_param]; } - virtual sort_size eval(obj_map const& S) { return S[m_param]; } + ~sparam() override {} + size* subst(obj_map& S) override { return S[m_param]; } + sort_size eval(obj_map const& S) override { return S[m_param]; } }; }; @@ -241,30 +241,30 @@ namespace datatype { unsigned m_class_id; util & u() const; - virtual void inherit(decl_plugin* other_p, ast_translation& tr); + void inherit(decl_plugin* other_p, ast_translation& tr) override; public: plugin(): m_class_id(0) {} - virtual ~plugin(); + ~plugin() override; - virtual void finalize(); + void finalize() override; - virtual decl_plugin * mk_fresh() { return alloc(plugin); } + decl_plugin * mk_fresh() override { return alloc(plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; - virtual bool is_fully_interp(sort * s) const; + bool is_fully_interp(sort * s) const override; - virtual bool is_value(app* e) const; + bool is_value(app* e) const override; - virtual bool is_unique_value(app * e) const { return is_value(e); } + bool is_unique_value(app * e) const override { return is_value(e); } - virtual void get_op_names(svector & op_names, symbol const & logic); + void get_op_names(svector & op_names, symbol const & logic) override; void begin_def_block() { m_class_id++; m_def_block.reset(); } diff --git a/src/ast/dl_decl_plugin.h b/src/ast/dl_decl_plugin.h index 75969d385..2c68cc12c 100644 --- a/src/ast/dl_decl_plugin.h +++ b/src/ast/dl_decl_plugin.h @@ -102,9 +102,9 @@ namespace datalog { public: dl_decl_plugin(); - virtual ~dl_decl_plugin() {} + ~dl_decl_plugin() override {} - virtual decl_plugin * mk_fresh() { return alloc(dl_decl_plugin); } + decl_plugin * mk_fresh() override { return alloc(dl_decl_plugin); } // // Contract for sort DL_RELATION_SORT @@ -116,7 +116,7 @@ namespace datalog { // parameters[0] - name // parameters[1] - uint64 // - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; // // Contract for func_decl: @@ -126,15 +126,15 @@ namespace datalog { // parameters[1] - a DL_FINITE_SORT sort of the constant // Contract for others: // no parameters - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; - virtual void get_op_names(svector & op_names, symbol const & logic); + void get_op_names(svector & op_names, symbol const & logic) override; - virtual void get_sort_names(svector & sort_names, symbol const & logic); + void get_sort_names(svector & sort_names, symbol const & logic) override; - virtual bool is_value(app * e) const { return is_app_of(e, m_family_id, OP_DL_CONSTANT); } - virtual bool is_unique_value(app * e) const { return is_value(e); } + bool is_value(app * e) const override { return is_app_of(e, m_family_id, OP_DL_CONSTANT); } + bool is_unique_value(app * e) const override { return is_value(e); } }; diff --git a/src/ast/expr2polynomial.h b/src/ast/expr2polynomial.h index e7cbac6e5..8becf55dd 100644 --- a/src/ast/expr2polynomial.h +++ b/src/ast/expr2polynomial.h @@ -103,10 +103,10 @@ class default_expr2polynomial : public expr2polynomial { svector m_is_int; public: default_expr2polynomial(ast_manager & am, polynomial::manager & pm); - virtual ~default_expr2polynomial(); - virtual bool is_int(polynomial::var x) const; + ~default_expr2polynomial() override; + bool is_int(polynomial::var x) const override; protected: - virtual polynomial::var mk_var(bool is_int); + polynomial::var mk_var(bool is_int) override; }; #endif diff --git a/src/ast/expr_functors.h b/src/ast/expr_functors.h index 322b9402a..3d66a69ae 100644 --- a/src/ast/expr_functors.h +++ b/src/ast/expr_functors.h @@ -73,7 +73,7 @@ class contains_app { app* m_x; public: pred(app* x) : m_x(x) {} - virtual bool operator()(expr* e) { + bool operator()(expr* e) override { return m_x == e; } }; diff --git a/src/ast/format.cpp b/src/ast/format.cpp index 6c2a02989..3013e3e40 100644 --- a/src/ast/format.cpp +++ b/src/ast/format.cpp @@ -32,7 +32,7 @@ namespace format_ns { symbol m_line_break; symbol m_line_break_ext; - virtual void set_manager(ast_manager * m, family_id id) { + void set_manager(ast_manager * m, family_id id) override { SASSERT(m->is_format_manager()); decl_plugin::set_manager(m, id); @@ -52,24 +52,24 @@ namespace format_ns { m_line_break_ext("cr++") { } - virtual ~format_decl_plugin() {} + ~format_decl_plugin() override {} - virtual void finalize() { + void finalize() override { if (m_format_sort) m_manager->dec_ref(m_format_sort); } - virtual decl_plugin * mk_fresh() { + decl_plugin * mk_fresh() override { return alloc(format_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const* parameters) { + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const* parameters) override { SASSERT(k == FORMAT_SORT); return m_format_sort; } - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range) { + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override { switch (k) { case OP_NIL: return m_manager->mk_func_decl(m_nil, arity, domain, m_format_sort, diff --git a/src/ast/fpa_decl_plugin.h b/src/ast/fpa_decl_plugin.h index 4e86c9d3f..4d0accfbb 100644 --- a/src/ast/fpa_decl_plugin.h +++ b/src/ast/fpa_decl_plugin.h @@ -159,11 +159,11 @@ class fpa_decl_plugin : public decl_plugin { func_decl * mk_bv_wrap(decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned arity, sort * const * domain, sort * range); - virtual void set_manager(ast_manager * m, family_id id); + void set_manager(ast_manager * m, family_id id) override; unsigned mk_id(mpf const & v); void recycled_id(unsigned id); - virtual bool is_considered_uninterpreted(func_decl * f) { return false; } + bool is_considered_uninterpreted(func_decl * f) override { return false; } public: fpa_decl_plugin(); @@ -171,18 +171,18 @@ public: bool is_float_sort(sort * s) const { return is_sort_of(s, m_family_id, FLOATING_POINT_SORT); } bool is_rm_sort(sort * s) const { return is_sort_of(s, m_family_id, ROUNDING_MODE_SORT); } - virtual ~fpa_decl_plugin(); - virtual void finalize(); + ~fpa_decl_plugin() override; + void finalize() override; - virtual decl_plugin * mk_fresh(); - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); - virtual void get_op_names(svector & op_names, symbol const & logic); - virtual void get_sort_names(svector & sort_names, symbol const & logic); - virtual expr * get_some_value(sort * s); - virtual bool is_value(app* e) const; - virtual bool is_unique_value(app* e) const; + decl_plugin * mk_fresh() override; + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; + void get_op_names(svector & op_names, symbol const & logic) override; + void get_sort_names(svector & sort_names, symbol const & logic) override; + expr * get_some_value(sort * s) override; + bool is_value(app* e) const override; + bool is_unique_value(app* e) const override; mpf_manager & fm() { return m_fm; } func_decl * mk_numeral_decl(mpf const & v); @@ -197,8 +197,8 @@ public: return m_values[id]; } - virtual void del(parameter const & p); - virtual parameter translate(parameter const & p, decl_plugin & target); + void del(parameter const & p) override; + parameter translate(parameter const & p, decl_plugin & target) override; }; class fpa_util { diff --git a/src/ast/normal_forms/defined_names.cpp b/src/ast/normal_forms/defined_names.cpp index 12085b992..cab14c433 100644 --- a/src/ast/normal_forms/defined_names.cpp +++ b/src/ast/normal_forms/defined_names.cpp @@ -74,7 +74,7 @@ struct defined_names::impl { struct defined_names::pos_impl : public defined_names::impl { pos_impl(ast_manager & m, char const * fresh_prefix):impl(m, fresh_prefix) {} - virtual void mk_definition(expr * e, app * n, sort_ref_buffer & var_sorts, buffer const & var_names, expr_ref & new_def); + void mk_definition(expr * e, app * n, sort_ref_buffer & var_sorts, buffer const & var_names, expr_ref & new_def) override; }; diff --git a/src/ast/normal_forms/name_exprs.cpp b/src/ast/normal_forms/name_exprs.cpp index 7cc2719c9..909f0abb1 100644 --- a/src/ast/normal_forms/name_exprs.cpp +++ b/src/ast/normal_forms/name_exprs.cpp @@ -77,10 +77,10 @@ public: m_rw(m, m.proofs_enabled(), m_cfg) { } - virtual ~name_exprs_core() { + ~name_exprs_core() override { } - virtual void operator()(expr * n, expr_ref_vector & new_defs, proof_ref_vector & new_def_proofs, expr_ref & r, proof_ref & p) { + void operator()(expr * n, expr_ref_vector & new_defs, proof_ref_vector & new_def_proofs, expr_ref & r, proof_ref & p) override { m_cfg.m_def_exprs = &new_defs; m_cfg.m_def_proofs = &new_def_proofs; m_rw(n, r, p); @@ -88,7 +88,7 @@ public: } - virtual void reset() { + void reset() override { m_rw.reset(); } }; @@ -102,7 +102,7 @@ class name_quantifier_labels : public name_exprs_core { ast_manager & m_manager; public: pred(ast_manager & m):m_manager(m) {} - virtual bool operator()(expr * t) { + bool operator()(expr * t) override { return is_quantifier(t) || m_manager.is_label(t); } }; @@ -114,7 +114,7 @@ public: m_pred(m) { } - virtual ~name_quantifier_labels() { + ~name_quantifier_labels() override { } }; @@ -129,7 +129,7 @@ class name_nested_formulas : public name_exprs_core { pred(ast_manager & m):m_manager(m), m_root(0) {} - virtual bool operator()(expr * t) { + bool operator()(expr * t) override { TRACE("name_exprs", tout << "name_nested_formulas::pred:\n" << mk_ismt2_pp(t, m_manager) << "\n";); if (is_app(t)) return to_app(t)->get_family_id() == m_manager.get_basic_family_id() && to_app(t)->get_num_args() > 0 && t != m_root; @@ -145,10 +145,10 @@ public: m_pred(m) { } - virtual ~name_nested_formulas() { + ~name_nested_formulas() override { } - virtual void operator()(expr * n, expr_ref_vector & new_defs, proof_ref_vector & new_def_proofs, expr_ref & r, proof_ref & p) { + void operator()(expr * n, expr_ref_vector & new_defs, proof_ref_vector & new_def_proofs, expr_ref & r, proof_ref & p) override { m_pred.m_root = n; TRACE("name_exprs", tout << "operator()\n";); name_exprs_core::operator()(n, new_defs, new_def_proofs, r, p); diff --git a/src/ast/pb_decl_plugin.h b/src/ast/pb_decl_plugin.h index 7fdb592aa..e7c42d569 100644 --- a/src/ast/pb_decl_plugin.h +++ b/src/ast/pb_decl_plugin.h @@ -53,14 +53,14 @@ class pb_decl_plugin : public decl_plugin { func_decl * mk_eq(unsigned arity, rational const* coeffs, int k); public: pb_decl_plugin(); - virtual ~pb_decl_plugin() {} + ~pb_decl_plugin() override {} - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) { + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override { UNREACHABLE(); return 0; } - virtual decl_plugin * mk_fresh() { + decl_plugin * mk_fresh() override { return alloc(pb_decl_plugin); } @@ -69,11 +69,11 @@ public: // parameters[0] - integer (at most k elements) // all sorts are Booleans // parameters[1] .. parameters[arity] - coefficients - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); - virtual void get_op_names(svector & op_names, symbol const & logic); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; + void get_op_names(svector & op_names, symbol const & logic) override; - virtual bool is_considered_uninterpreted(func_decl * f) { return false; } + bool is_considered_uninterpreted(func_decl * f) override { return false; } }; diff --git a/src/ast/proofs/proof_checker.h b/src/ast/proofs/proof_checker.h index ce2684c51..ccb815c61 100644 --- a/src/ast/proofs/proof_checker.h +++ b/src/ast/proofs/proof_checker.h @@ -48,24 +48,24 @@ class proof_checker { func_decl* m_atom; func_decl* m_nil; sort* m_cell; - virtual void set_manager(ast_manager * m, family_id id); + void set_manager(ast_manager * m, family_id id) override; func_decl * mk_func_decl(decl_kind k); public: hyp_decl_plugin(); - virtual ~hyp_decl_plugin() {} + ~hyp_decl_plugin() override {} - virtual void finalize(); + void finalize() override; - virtual decl_plugin * mk_fresh() { return alloc(hyp_decl_plugin); } + decl_plugin * mk_fresh() override { return alloc(hyp_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const* parameters); - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned num_args, expr * const * args, sort * range); - virtual void get_op_names(svector & op_names, symbol const & logic); - virtual void get_sort_names(svector & sort_names, symbol const & logic); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const* parameters) override; + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned num_args, expr * const * args, sort * range) override; + void get_op_names(svector & op_names, symbol const & logic) override; + void get_sort_names(svector & sort_names, symbol const & logic) override; }; public: proof_checker(ast_manager& m); diff --git a/src/ast/rewriter/elim_bounds.h b/src/ast/rewriter/elim_bounds.h index e0bba4e60..4dcb24173 100644 --- a/src/ast/rewriter/elim_bounds.h +++ b/src/ast/rewriter/elim_bounds.h @@ -70,7 +70,7 @@ public: m_cfg(m) {} - virtual ~elim_bounds_rw() {} + ~elim_bounds_rw() override {} }; #endif /* ELIM_BOUNDS2_H_ */ diff --git a/src/ast/rewriter/expr_replacer.cpp b/src/ast/rewriter/expr_replacer.cpp index 70e12dced..fb85e3372 100644 --- a/src/ast/rewriter/expr_replacer.cpp +++ b/src/ast/rewriter/expr_replacer.cpp @@ -90,14 +90,14 @@ public: m_replacer(m, m.proofs_enabled(), m_cfg) { } - virtual ast_manager & m() const { return m_replacer.m(); } + ast_manager & m() const override { return m_replacer.m(); } - virtual void set_substitution(expr_substitution * s) { + void set_substitution(expr_substitution * s) override { m_replacer.cleanup(); m_replacer.cfg().m_subst = s; } - virtual void operator()(expr * t, expr_ref & result, proof_ref & result_pr, expr_dependency_ref & result_dep) { + void operator()(expr * t, expr_ref & result, proof_ref & result_pr, expr_dependency_ref & result_dep) override { result_dep = 0; m_replacer.operator()(t, result, result_pr); if (m_cfg.m_used_dependencies != 0) { @@ -108,11 +108,11 @@ public: } - virtual unsigned get_num_steps() const { + unsigned get_num_steps() const override { return m_replacer.get_num_steps(); } - virtual void reset() { + void reset() override { m_replacer.reset(); } }; @@ -131,23 +131,23 @@ public: m_r(m, p) { } - virtual ~th_rewriter2expr_replacer() {} + ~th_rewriter2expr_replacer() override {} - virtual ast_manager & m() const { return m_r.m(); } + ast_manager & m() const override { return m_r.m(); } - virtual void set_substitution(expr_substitution * s) { m_r.set_substitution(s); } + void set_substitution(expr_substitution * s) override { m_r.set_substitution(s); } - virtual void operator()(expr * t, expr_ref & result, proof_ref & result_pr, expr_dependency_ref & result_dep) { + void operator()(expr * t, expr_ref & result, proof_ref & result_pr, expr_dependency_ref & result_dep) override { m_r(t, result, result_pr); result_dep = m_r.get_used_dependencies(); m_r.reset_used_dependencies(); } - virtual unsigned get_num_steps() const { + unsigned get_num_steps() const override { return m_r.get_num_steps(); } - virtual void reset() { + void reset() override { m_r.reset(); } diff --git a/src/ast/rewriter/maximize_ac_sharing.h b/src/ast/rewriter/maximize_ac_sharing.h index c0ee0d09f..7144c7ad3 100644 --- a/src/ast/rewriter/maximize_ac_sharing.h +++ b/src/ast/rewriter/maximize_ac_sharing.h @@ -103,8 +103,8 @@ public: class maximize_bv_sharing : public maximize_ac_sharing { bv_util m_util; protected: - virtual void init_core(); - virtual bool is_numeral(expr * n) const; + void init_core() override; + bool is_numeral(expr * n) const override; public: maximize_bv_sharing(ast_manager & m); }; diff --git a/src/ast/rewriter/pull_ite_tree.h b/src/ast/rewriter/pull_ite_tree.h index 3ff0a716d..ea462315a 100644 --- a/src/ast/rewriter/pull_ite_tree.h +++ b/src/ast/rewriter/pull_ite_tree.h @@ -96,8 +96,8 @@ public: class pull_cheap_ite_tree_cfg : public pull_ite_tree_cfg { public: pull_cheap_ite_tree_cfg(ast_manager & m):pull_ite_tree_cfg(m) {} - virtual ~pull_cheap_ite_tree_cfg() {} - virtual bool is_target(app * n) const; + ~pull_cheap_ite_tree_cfg() override {} + bool is_target(app * n) const override; }; class pull_cheap_ite_tree_rw : public rewriter_tpl { diff --git a/src/ast/rewriter/push_app_ite.h b/src/ast/rewriter/push_app_ite.h index ae06aad30..8f737ea4d 100644 --- a/src/ast/rewriter/push_app_ite.h +++ b/src/ast/rewriter/push_app_ite.h @@ -45,7 +45,7 @@ struct push_app_ite_cfg : public default_rewriter_cfg { */ class ng_push_app_ite_cfg : public push_app_ite_cfg { protected: - virtual bool is_target(func_decl * decl, unsigned num_args, expr * const * args); + bool is_target(func_decl * decl, unsigned num_args, expr * const * args) override; public: ng_push_app_ite_cfg(ast_manager& m, bool conservative = true): push_app_ite_cfg(m, conservative) {} virtual ~ng_push_app_ite_cfg() {} diff --git a/src/ast/rewriter/rewriter.h b/src/ast/rewriter/rewriter.h index 17742f670..8c00f541b 100644 --- a/src/ast/rewriter/rewriter.h +++ b/src/ast/rewriter/rewriter.h @@ -150,7 +150,7 @@ class var_shifter : public var_shifter_core { unsigned m_bound; unsigned m_shift1; unsigned m_shift2; - virtual void process_var(var * v); + void process_var(var * v) override; public: var_shifter(ast_manager & m):var_shifter_core(m) {} void operator()(expr * t, unsigned bound, unsigned shift1, unsigned shift2, expr_ref & r); @@ -183,7 +183,7 @@ public: class inv_var_shifter : public var_shifter_core { protected: unsigned m_shift; - virtual void process_var(var * v); + void process_var(var * v) override; public: inv_var_shifter(ast_manager & m):var_shifter_core(m) {} void operator()(expr * t, unsigned shift, expr_ref & r); @@ -339,7 +339,7 @@ public: Config & cfg() { return m_cfg; } Config const & cfg() const { return m_cfg; } - ~rewriter_tpl(); + ~rewriter_tpl() override; void reset(); void cleanup(); diff --git a/src/ast/rewriter/seq_rewriter.cpp b/src/ast/rewriter/seq_rewriter.cpp index ec3e72cc4..5fb85d6bb 100644 --- a/src/ast/rewriter/seq_rewriter.cpp +++ b/src/ast/rewriter/seq_rewriter.cpp @@ -85,15 +85,15 @@ public: sym_expr_boolean_algebra(ast_manager& m, expr_solver& s): m(m), m_solver(s) {} - virtual T mk_false() { + T mk_false() override { expr_ref fml(m.mk_false(), m); return sym_expr::mk_pred(fml, m.mk_bool_sort()); // use of Bool sort for bound variable is arbitrary } - virtual T mk_true() { + T mk_true() override { expr_ref fml(m.mk_true(), m); return sym_expr::mk_pred(fml, m.mk_bool_sort()); } - virtual T mk_and(T x, T y) { + T mk_and(T x, T y) override { if (x->is_char() && y->is_char()) { if (x->get_char() == y->get_char()) { return x; @@ -118,7 +118,7 @@ public: br.mk_and(fml1, fml2, fml); return sym_expr::mk_pred(fml, x->get_sort()); } - virtual T mk_or(T x, T y) { + T mk_or(T x, T y) override { if (x->is_char() && y->is_char() && x->get_char() == y->get_char()) { return x; @@ -135,7 +135,7 @@ public: return sym_expr::mk_pred(fml, x->get_sort()); } - virtual T mk_and(unsigned sz, T const* ts) { + T mk_and(unsigned sz, T const* ts) override { switch (sz) { case 0: return mk_true(); case 1: return ts[0]; @@ -148,7 +148,7 @@ public: } } } - virtual T mk_or(unsigned sz, T const* ts) { + T mk_or(unsigned sz, T const* ts) override { switch (sz) { case 0: return mk_false(); case 1: return ts[0]; @@ -161,7 +161,7 @@ public: } } } - virtual lbool is_sat(T x) { + lbool is_sat(T x) override { if (x->is_char()) { return l_true; } @@ -178,7 +178,7 @@ public: } return m_solver.check_sat(fml); } - virtual T mk_not(T x) { + T mk_not(T x) override { var_ref v(m.mk_var(0, x->get_sort()), m); expr_ref fml(m.mk_not(x->accept(v)), m); return sym_expr::mk_pred(fml, x->get_sort()); diff --git a/src/ast/seq_decl_plugin.h b/src/ast/seq_decl_plugin.h index 2e3b3fd24..e765e69a4 100644 --- a/src/ast/seq_decl_plugin.h +++ b/src/ast/seq_decl_plugin.h @@ -162,34 +162,34 @@ class seq_decl_plugin : public decl_plugin { void init(); - virtual void set_manager(ast_manager * m, family_id id); + void set_manager(ast_manager * m, family_id id) override; public: seq_decl_plugin(); - virtual ~seq_decl_plugin() {} - virtual void finalize(); + ~seq_decl_plugin() override {} + void finalize() override; - virtual decl_plugin * mk_fresh() { return alloc(seq_decl_plugin); } + decl_plugin * mk_fresh() override { return alloc(seq_decl_plugin); } - virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters); + sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override; - virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range); + func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) override; - virtual void get_op_names(svector & op_names, symbol const & logic); + void get_op_names(svector & op_names, symbol const & logic) override; - virtual void get_sort_names(svector & sort_names, symbol const & logic); + void get_sort_names(svector & sort_names, symbol const & logic) override; - virtual bool is_value(app * e) const; + bool is_value(app * e) const override; - virtual bool is_unique_value(app * e) const { return false; } + bool is_unique_value(app * e) const override { return false; } - virtual bool are_equal(app* a, app* b) const; + bool are_equal(app* a, app* b) const override; - virtual bool are_distinct(app* a, app* b) const; + bool are_distinct(app* a, app* b) const override; - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; bool is_char(ast* a) const { return a == m_char; } diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index 572abc8fe..f1357126c 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -49,12 +49,12 @@ class help_cmd : public cmd { public: help_cmd():cmd("help") {} - virtual char const * get_usage() const { return "*"; } - virtual char const * get_descr(cmd_context & ctx) const { return "print this help."; } - virtual unsigned get_arity() const { return VAR_ARITY; } - virtual void prepare(cmd_context & ctx) { m_cmds.reset(); } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_SYMBOL; } - virtual void set_next_arg(cmd_context & ctx, symbol const & s) { + char const * get_usage() const override { return "*"; } + char const * get_descr(cmd_context & ctx) const override { return "print this help."; } + unsigned get_arity() const override { return VAR_ARITY; } + void prepare(cmd_context & ctx) override { m_cmds.reset(); } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_SYMBOL; } + void set_next_arg(cmd_context & ctx, symbol const & s) override { cmd * c = ctx.find_cmd(s); if (c == 0) { std::string err_msg("unknown command '"); @@ -69,7 +69,7 @@ public: bool operator()(named_cmd const & c1, named_cmd const & c2) const { return c1.first.str() < c2.first.str(); } }; - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { ctx.regular_stream() << "\""; if (m_cmds.empty()) { vector cmds; @@ -101,14 +101,14 @@ class get_model_cmd : public cmd { unsigned m_index; public: get_model_cmd(): cmd("get-model"), m_index(0) {} - virtual char const * get_usage() const { return "[]"; } - virtual char const * get_descr(cmd_context & ctx) const { + char const * get_usage() const override { return "[]"; } + char const * get_descr(cmd_context & ctx) const override { return "retrieve model for the last check-sat command.\nSupply optional index if retrieving a model corresponding to a box optimization objective"; } - virtual unsigned get_arity() const { return VAR_ARITY; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_UINT; } - virtual void set_next_arg(cmd_context & ctx, unsigned index) { m_index = index; } - virtual void execute(cmd_context & ctx) { + unsigned get_arity() const override { return VAR_ARITY; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_UINT; } + void set_next_arg(cmd_context & ctx, unsigned index) override { m_index = index; } + void execute(cmd_context & ctx) override { if (!ctx.is_model_available() || ctx.get_check_sat_result() == 0) throw cmd_exception("model is not available"); model_ref m; @@ -120,7 +120,7 @@ public: } ctx.display_model(m); } - virtual void reset(cmd_context& ctx) { + void reset(cmd_context& ctx) override { m_index = 0; } }; @@ -166,10 +166,10 @@ class cmd_is_declared : public ast_smt_pp::is_declared { public: cmd_is_declared(cmd_context& ctx): m_ctx(ctx) {} - virtual bool operator()(func_decl* d) const { + bool operator()(func_decl* d) const override { return m_ctx.is_func_decl(d->get_name()); } - virtual bool operator()(sort* s) const { + bool operator()(sort* s) const override { return m_ctx.is_sort_decl(s->get_name()); } }; @@ -360,7 +360,7 @@ public: m_int_real_coercions(":int-real-coercions"), m_reproducible_resource_limit(":reproducible-resource-limit") { } - virtual ~set_get_option_cmd() {} + ~set_get_option_cmd() override {} }; @@ -477,19 +477,19 @@ public: m_unsupported(false) { } - virtual char const * get_usage() const { return " "; } + char const * get_usage() const override { return " "; } - virtual char const * get_descr(cmd_context & ctx) const { return "set configuration option."; } + char const * get_descr(cmd_context & ctx) const override { return "set configuration option."; } - virtual unsigned get_arity() const { return 2; } + unsigned get_arity() const override { return 2; } - virtual void prepare(cmd_context & ctx) { m_unsupported = false; m_option = symbol::null; } + void prepare(cmd_context & ctx) override { m_unsupported = false; m_option = symbol::null; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return m_option == symbol::null ? CPK_KEYWORD : CPK_OPTION_VALUE; } - virtual void set_next_arg(cmd_context & ctx, symbol const & opt) { + void set_next_arg(cmd_context & ctx, symbol const & opt) override { if (m_option == symbol::null) { m_option = opt; } @@ -498,7 +498,7 @@ public: } } - virtual void set_next_arg(cmd_context & ctx, rational const & val) { + void set_next_arg(cmd_context & ctx, rational const & val) override { if (m_option == m_random_seed) { ctx.set_random_seed(to_unsigned(val)); } @@ -517,7 +517,7 @@ public: } } - virtual void set_next_arg(cmd_context & ctx, char const * value) { + void set_next_arg(cmd_context & ctx, char const * value) override { if (m_option == m_regular_output_channel) { ctx.set_regular_stream(value); } @@ -532,7 +532,7 @@ public: } } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { if (m_unsupported) ctx.print_unsupported(m_option, m_line, m_pos); else @@ -557,11 +557,11 @@ public: get_option_cmd(): set_get_option_cmd("get-option") { } - virtual char const * get_usage() const { return ""; } - virtual char const * get_descr(cmd_context & ctx) const { return "get configuration option."; } - virtual unsigned get_arity() const { return 1; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_KEYWORD; } - virtual void set_next_arg(cmd_context & ctx, symbol const & opt) { + char const * get_usage() const override { return ""; } + char const * get_descr(cmd_context & ctx) const override { return "get configuration option."; } + unsigned get_arity() const override { return 1; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_KEYWORD; } + void set_next_arg(cmd_context & ctx, symbol const & opt) override { if (opt == m_print_success) { print_bool(ctx, ctx.print_success_enabled()); } @@ -651,11 +651,11 @@ public: m_all_statistics(":all-statistics"), m_assertion_stack_levels(":assertion-stack-levels") { } - virtual char const * get_usage() const { return ""; } - virtual char const * get_descr(cmd_context & ctx) const { return "get information."; } - virtual unsigned get_arity() const { return 1; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_KEYWORD; } - virtual void set_next_arg(cmd_context & ctx, symbol const & opt) { + char const * get_usage() const override { return ""; } + char const * get_descr(cmd_context & ctx) const override { return "get information."; } + unsigned get_arity() const override { return 1; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_KEYWORD; } + void set_next_arg(cmd_context & ctx, symbol const & opt) override { if (opt == m_error_behavior) { if (ctx.exit_on_error()) ctx.regular_stream() << "(:error-behavior immediate-exit)" << std::endl; @@ -707,16 +707,16 @@ public: m_sat("sat"), m_unknown("unknown") { } - virtual char const * get_usage() const { return " "; } - virtual char const * get_descr(cmd_context & ctx) const { return "set information."; } - virtual unsigned get_arity() const { return 2; } - virtual void prepare(cmd_context & ctx) { m_info = symbol::null; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + char const * get_usage() const override { return " "; } + char const * get_descr(cmd_context & ctx) const override { return "set information."; } + unsigned get_arity() const override { return 2; } + void prepare(cmd_context & ctx) override { m_info = symbol::null; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return m_info == symbol::null ? CPK_KEYWORD : CPK_OPTION_VALUE; } - virtual void set_next_arg(cmd_context & ctx, rational const & val) {} - virtual void set_next_arg(cmd_context & ctx, char const * val) {} - virtual void set_next_arg(cmd_context & ctx, symbol const & s) { + void set_next_arg(cmd_context & ctx, rational const & val) override {} + void set_next_arg(cmd_context & ctx, char const * val) override {} + void set_next_arg(cmd_context & ctx, symbol const & s) override { if (m_info == symbol::null) { m_info = s; } @@ -737,7 +737,7 @@ public: } } } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { ctx.print_success(); } }; @@ -760,30 +760,30 @@ public: } return m_array_fid; } - virtual char const * get_usage() const { return " (+) "; } - virtual char const * get_descr(cmd_context & ctx) const { return "declare a new array map operator with name using the given function declaration.\n ::= \n | ( (*) )\n | ((_ +) (*) )\nThe last two cases are used to disumbiguate between declarations with the same name and/or select (indexed) builtin declarations.\nFor more details about the array map operator, see 'Generalized and Efficient Array Decision Procedures' (FMCAD 2009).\nExample: (declare-map set-union (Int) (or (Bool Bool) Bool))\nDeclares a new function (declare-fun set-union ((Array Int Bool) (Array Int Bool)) (Array Int Bool)).\nThe instance of the map axiom for this new declaration is:\n(forall ((a1 (Array Int Bool)) (a2 (Array Int Bool)) (i Int)) (= (select (set-union a1 a2) i) (or (select a1 i) (select a2 i))))"; } - virtual unsigned get_arity() const { return 3; } - virtual void prepare(cmd_context & ctx) { m_name = symbol::null; m_domain.reset(); } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + char const * get_usage() const override { return " (+) "; } + char const * get_descr(cmd_context & ctx) const override { return "declare a new array map operator with name using the given function declaration.\n ::= \n | ( (*) )\n | ((_ +) (*) )\nThe last two cases are used to disumbiguate between declarations with the same name and/or select (indexed) builtin declarations.\nFor more details about the array map operator, see 'Generalized and Efficient Array Decision Procedures' (FMCAD 2009).\nExample: (declare-map set-union (Int) (or (Bool Bool) Bool))\nDeclares a new function (declare-fun set-union ((Array Int Bool) (Array Int Bool)) (Array Int Bool)).\nThe instance of the map axiom for this new declaration is:\n(forall ((a1 (Array Int Bool)) (a2 (Array Int Bool)) (i Int)) (= (select (set-union a1 a2) i) (or (select a1 i) (select a2 i))))"; } + unsigned get_arity() const override { return 3; } + void prepare(cmd_context & ctx) override { m_name = symbol::null; m_domain.reset(); } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_name == symbol::null) return CPK_SYMBOL; if (m_domain.empty()) return CPK_SORT_LIST; return CPK_FUNC_DECL; } - virtual void set_next_arg(cmd_context & ctx, symbol const & s) { m_name = s; } - virtual void set_next_arg(cmd_context & ctx, unsigned num, sort * const * slist) { + void set_next_arg(cmd_context & ctx, symbol const & s) override { m_name = s; } + void set_next_arg(cmd_context & ctx, unsigned num, sort * const * slist) override { if (num == 0) throw cmd_exception("invalid map declaration, empty sort list"); m_domain.append(num, slist); } - virtual void set_next_arg(cmd_context & ctx, func_decl * f) { + void set_next_arg(cmd_context & ctx, func_decl * f) override { m_f = f; if (m_f->get_arity() == 0) throw cmd_exception("invalid map declaration, function declaration must have arity > 0"); } - virtual void reset(cmd_context & ctx) { + void reset(cmd_context & ctx) override { m_array_fid = null_family_id; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { psort_decl * array_sort = ctx.find_psort_decl(m_array_sort); if (array_sort == 0) throw cmd_exception("Array sort is not available"); @@ -813,11 +813,11 @@ class get_consequences_cmd : public cmd { unsigned m_count; public: get_consequences_cmd(): cmd("get-consequences"), m_count(0) {} - virtual char const * get_usage() const { return "(*) (*)"; } - virtual char const * get_descr(cmd_context & ctx) const { return "retrieve consequences that fix values for supplied variables"; } - virtual unsigned get_arity() const { return 2; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_EXPR_LIST; } - virtual void set_next_arg(cmd_context & ctx, unsigned num, expr * const * tlist) { + char const * get_usage() const override { return "(*) (*)"; } + char const * get_descr(cmd_context & ctx) const override { return "retrieve consequences that fix values for supplied variables"; } + unsigned get_arity() const override { return 2; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_EXPR_LIST; } + void set_next_arg(cmd_context & ctx, unsigned num, expr * const * tlist) override { if (m_count == 0) { m_assumptions.append(num, tlist); ++m_count; @@ -826,8 +826,8 @@ public: m_variables.append(num, tlist); } } - virtual void failure_cleanup(cmd_context & ctx) {} - virtual void execute(cmd_context & ctx) { + void failure_cleanup(cmd_context & ctx) override {} + void execute(cmd_context & ctx) override { ast_manager& m = ctx.m(); expr_ref_vector assumptions(m), variables(m), consequences(m); assumptions.append(m_assumptions.size(), m_assumptions.c_ptr()); @@ -835,12 +835,12 @@ public: ctx.get_consequences(assumptions, variables, consequences); ctx.regular_stream() << consequences << "\n"; } - virtual void prepare(cmd_context & ctx) { reset(ctx); } + void prepare(cmd_context & ctx) override { reset(ctx); } - virtual void reset(cmd_context& ctx) { + void reset(cmd_context& ctx) override { m_assumptions.reset(); m_variables.reset(); m_count = 0; } - virtual void finalize(cmd_context & ctx) {} + void finalize(cmd_context & ctx) override {} }; // provides "help" for builtin cmds @@ -850,8 +850,8 @@ class builtin_cmd : public cmd { public: builtin_cmd(char const * name, char const * usage, char const * descr): cmd(name), m_usage(usage), m_descr(descr) {} - virtual char const * get_usage() const { return m_usage; } - virtual char const * get_descr(cmd_context & ctx) const { return m_descr; } + char const * get_usage() const override { return m_usage; } + char const * get_descr(cmd_context & ctx) const override { return m_descr; } }; diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index ec2eea032..c6c36606a 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -414,25 +414,25 @@ protected: public: pp_env(cmd_context & o):m_owner(o), m_autil(o.m()), m_bvutil(o.m()), m_arutil(o.m()), m_futil(o.m()), m_sutil(o.m()), m_dtutil(o.m()), m_dlutil(o.m()) {} - virtual ~pp_env() {} - virtual ast_manager & get_manager() const { return m_owner.m(); } - virtual arith_util & get_autil() { return m_autil; } - virtual bv_util & get_bvutil() { return m_bvutil; } - virtual array_util & get_arutil() { return m_arutil; } - virtual fpa_util & get_futil() { return m_futil; } - virtual seq_util & get_sutil() { return m_sutil; } - virtual datatype_util & get_dtutil() { return m_dtutil; } + ~pp_env() override {} + ast_manager & get_manager() const override { return m_owner.m(); } + arith_util & get_autil() override { return m_autil; } + bv_util & get_bvutil() override { return m_bvutil; } + array_util & get_arutil() override { return m_arutil; } + fpa_util & get_futil() override { return m_futil; } + seq_util & get_sutil() override { return m_sutil; } + datatype_util & get_dtutil() override { return m_dtutil; } - virtual datalog::dl_decl_util& get_dlutil() { return m_dlutil; } - virtual bool uses(symbol const & s) const { + datalog::dl_decl_util& get_dlutil() override { return m_dlutil; } + bool uses(symbol const & s) const override { return m_owner.m_builtin_decls.contains(s) || m_owner.m_func_decls.contains(s); } - virtual format_ns::format * pp_sort(sort * s) { + format_ns::format * pp_sort(sort * s) override { return m_owner.pp(s); } - virtual format_ns::format * pp_fdecl(func_decl * f, unsigned & len) { + format_ns::format * pp_fdecl(func_decl * f, unsigned & len) override { symbol s = f->get_name(); func_decls fs; if (m_owner.m_func_decls.find(s, fs) && fs.contains(f)) { @@ -443,7 +443,7 @@ public: } return smt2_pp_environment::pp_fdecl(f, len); } - virtual format_ns::format * pp_fdecl_ref(func_decl * f) { + format_ns::format * pp_fdecl_ref(func_decl * f) override { symbol s = f->get_name(); func_decls fs; if (m_owner.m_func_decls.find(s, fs) && fs.contains(f)) { diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 212de585a..cd3191fc6 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -112,10 +112,10 @@ class ast_object_ref : public object_ref { ast * m_ast; public: ast_object_ref(cmd_context & ctx, ast * a); - virtual void finalize(cmd_context & ctx); + void finalize(cmd_context & ctx) override; ast * get_ast() const { return m_ast; } static char const * cls_kind() { return "AST"; } - virtual char const * kind() const { return cls_kind(); } + char const * kind() const override { return cls_kind(); } }; class stream_ref { @@ -250,8 +250,8 @@ protected: datatype_util m_dt_util; public: dt_eh(cmd_context & owner); - virtual ~dt_eh(); - virtual void operator()(sort * dt, pdecl* pd); + ~dt_eh() override; + void operator()(sort * dt, pdecl* pd) override; }; friend class dt_eh; @@ -307,7 +307,7 @@ protected: public: cmd_context(bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); - ~cmd_context(); + ~cmd_context() override; void set_cancel(bool f); context_params & params() { return m_params; } solver_factory &get_solver_factory() { return *m_solver_factory; } @@ -354,7 +354,7 @@ public: bool has_manager() const { return m_manager != 0; } ast_manager & m() const { const_cast(this)->init_manager(); return *m_manager; } - virtual ast_manager & get_ast_manager() { return m(); } + ast_manager & get_ast_manager() override { return m(); } pdecl_manager & pm() const { if (!m_pmanager) const_cast(this)->init_manager(); return *m_pmanager; } sexpr_manager & sm() const { if (!m_sexpr_manager) const_cast(this)->m_sexpr_manager = alloc(sexpr_manager); return *m_sexpr_manager; } @@ -407,8 +407,8 @@ public: void set_regular_stream(char const * name) { m_regular.set(name); } void set_regular_stream(std::ostream& out) { m_regular.set(out); } void set_diagnostic_stream(char const * name); - virtual std::ostream & regular_stream() { return *m_regular; } - virtual std::ostream & diagnostic_stream() { return *m_diagnostic; } + std::ostream & regular_stream() override { return *m_regular; } + std::ostream & diagnostic_stream() override { return *m_diagnostic; } char const * get_regular_stream_name() const { return m_regular.name(); } char const * get_diagnostic_stream_name() const { return m_diagnostic.name(); } typedef dictionary::iterator cmd_iterator; @@ -462,14 +462,14 @@ public: } format_ns::format * pp(sort * s) const; - virtual void pp(sort * s, format_ns::format_ref & r) const { r = pp(s); } - virtual void pp(func_decl * f, format_ns::format_ref & r) const; - virtual void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const; - virtual void pp(expr * n, format_ns::format_ref & r) const; - virtual void display(std::ostream & out, sort * s, unsigned indent = 0) const; - virtual void display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer & var_names) const; - virtual void display(std::ostream & out, expr * n, unsigned indent = 0) const; - virtual void display(std::ostream & out, func_decl * f, unsigned indent = 0) const; + void pp(sort * s, format_ns::format_ref & r) const override { r = pp(s); } + void pp(func_decl * f, format_ns::format_ref & r) const override; + void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const override; + void pp(expr * n, format_ns::format_ref & r) const override; + void display(std::ostream & out, sort * s, unsigned indent = 0) const override; + void display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer & var_names) const override; + void display(std::ostream & out, expr * n, unsigned indent = 0) const override; + void display(std::ostream & out, func_decl * f, unsigned indent = 0) const override; // dump assertions in out using the pretty printer. void dump_assertions(std::ostream & out) const; @@ -478,8 +478,8 @@ public: void display_smt2_benchmark(std::ostream & out, unsigned num, expr * const * assertions, symbol const & logic = symbol::null) const; - virtual void slow_progress_sample(); - virtual void fast_progress_sample(); + void slow_progress_sample() override; + void fast_progress_sample() override; }; std::ostream & operator<<(std::ostream & out, cmd_context::status st); diff --git a/src/cmd_context/echo_tactic.cpp b/src/cmd_context/echo_tactic.cpp index 848ae5429..b511d509f 100644 --- a/src/cmd_context/echo_tactic.cpp +++ b/src/cmd_context/echo_tactic.cpp @@ -27,11 +27,11 @@ class echo_tactic : public skip_tactic { public: echo_tactic(cmd_context & ctx, char const * msg, bool newline):m_ctx(ctx), m_msg(msg), m_newline(newline) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { #pragma omp critical (echo_tactic) { m_ctx.regular_stream() << m_msg; @@ -57,15 +57,15 @@ public: m_p->inc_ref(); } - ~probe_value_tactic() { + ~probe_value_tactic() override { m_p->dec_ref(); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { double val = (*m_p)(*(in.get())).get_value(); #pragma omp critical (probe_value_tactic) { diff --git a/src/cmd_context/eval_cmd.cpp b/src/cmd_context/eval_cmd.cpp index 9d3c1ced3..b1a7905d1 100644 --- a/src/cmd_context/eval_cmd.cpp +++ b/src/cmd_context/eval_cmd.cpp @@ -29,33 +29,33 @@ class eval_cmd : public parametric_cmd { public: eval_cmd():parametric_cmd("eval") {} - virtual char const * get_usage() const { return " ( )*"; } + char const * get_usage() const override { return " ( )*"; } - virtual char const * get_main_descr() const { + char const * get_main_descr() const override { return "evaluate the given term in the current model."; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { model_evaluator::get_param_descrs(p); insert_timeout(p); p.insert("model_index", CPK_UINT, "(default: 0) index of model from box optimization objective"); } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); m_target = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_target == 0) return CPK_EXPR; return parametric_cmd::next_arg_kind(ctx); } - virtual void set_next_arg(cmd_context & ctx, expr * arg) { + void set_next_arg(cmd_context & ctx, expr * arg) override { m_target = arg; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { if (!ctx.is_model_available()) throw cmd_exception("model is not available"); if (!m_target) diff --git a/src/cmd_context/extra_cmds/dbg_cmds.cpp b/src/cmd_context/extra_cmds/dbg_cmds.cpp index dfdfa6175..6dab3e39f 100644 --- a/src/cmd_context/extra_cmds/dbg_cmds.cpp +++ b/src/cmd_context/extra_cmds/dbg_cmds.cpp @@ -104,15 +104,15 @@ class subst_cmd : public cmd { ptr_vector m_subst; public: subst_cmd():cmd("dbg-subst") {} - virtual char const * get_usage() const { return " (*) "; } - virtual char const * get_descr(cmd_context & ctx) const { return "substitute the free variables in the AST referenced by using the ASTs referenced by *"; } - virtual unsigned get_arity() const { return 3; } - virtual void prepare(cmd_context & ctx) { m_idx = 0; m_source = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + char const * get_usage() const override { return " (*) "; } + char const * get_descr(cmd_context & ctx) const override { return "substitute the free variables in the AST referenced by using the ASTs referenced by *"; } + unsigned get_arity() const override { return 3; } + void prepare(cmd_context & ctx) override { m_idx = 0; m_source = 0; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_idx == 1) return CPK_SYMBOL_LIST; return CPK_SYMBOL; } - virtual void set_next_arg(cmd_context & ctx, symbol const & s) { + void set_next_arg(cmd_context & ctx, symbol const & s) override { if (m_idx == 0) { m_source = get_expr_ref(ctx, s); } @@ -121,7 +121,7 @@ public: } m_idx++; } - virtual void set_next_arg(cmd_context & ctx, unsigned num, symbol const * s) { + void set_next_arg(cmd_context & ctx, unsigned num, symbol const * s) override { m_subst.reset(); unsigned i = num; while (i > 0) { @@ -130,7 +130,7 @@ public: } m_idx++; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { expr_ref r(ctx.m()); beta_reducer p(ctx.m()); p(m_source, m_subst.size(), m_subst.c_ptr(), r); @@ -179,18 +179,18 @@ class lt_cmd : public cmd { expr * m_t2; public: lt_cmd():cmd("dbg-lt") {} - virtual char const * get_usage() const { return " "; } - virtual char const * get_descr(cmd_context & ctx) const { return "return true if the first term is smaller than the second one in the internal Z3 total order on terms."; } - virtual unsigned get_arity() const { return 2; } - virtual void prepare(cmd_context & ctx) { m_t1 = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_EXPR; } - virtual void set_next_arg(cmd_context & ctx, expr * arg) { + char const * get_usage() const override { return " "; } + char const * get_descr(cmd_context & ctx) const override { return "return true if the first term is smaller than the second one in the internal Z3 total order on terms."; } + unsigned get_arity() const override { return 2; } + void prepare(cmd_context & ctx) override { m_t1 = 0; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_EXPR; } + void set_next_arg(cmd_context & ctx, expr * arg) override { if (m_t1 == 0) m_t1 = arg; else m_t2 = arg; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { bool r = lt(m_t1, m_t2); ctx.regular_stream() << (r ? "true" : "false") << std::endl; } @@ -283,23 +283,23 @@ protected: ptr_vector m_args; public: instantiate_cmd_core(char const * name):cmd(name) {} - virtual char const * get_usage() const { return " (*)"; } - virtual char const * get_descr(cmd_context & ctx) const { return "instantiate the quantifier using the given expressions."; } - virtual unsigned get_arity() const { return 2; } - virtual void prepare(cmd_context & ctx) { m_q = 0; m_args.reset(); } + char const * get_usage() const override { return " (*)"; } + char const * get_descr(cmd_context & ctx) const override { return "instantiate the quantifier using the given expressions."; } + unsigned get_arity() const override { return 2; } + void prepare(cmd_context & ctx) override { m_q = 0; m_args.reset(); } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_q == 0) return CPK_EXPR; else return CPK_EXPR_LIST; } - virtual void set_next_arg(cmd_context & ctx, expr * s) { + void set_next_arg(cmd_context & ctx, expr * s) override { if (!is_quantifier(s)) throw cmd_exception("invalid command, quantifier expected."); m_q = to_quantifier(s); } - virtual void set_next_arg(cmd_context & ctx, unsigned num, expr * const * ts) { + void set_next_arg(cmd_context & ctx, unsigned num, expr * const * ts) override { if (num != m_q->get_num_decls()) throw cmd_exception("invalid command, mismatch between the number of quantified variables and the number of arguments."); unsigned i = num; @@ -315,7 +315,7 @@ public: m_args.append(num, ts); } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { expr_ref r(ctx.m()); instantiate(ctx.m(), m_q, m_args.c_ptr(), r); ctx.display(ctx.regular_stream(), r); @@ -332,9 +332,9 @@ class instantiate_nested_cmd : public instantiate_cmd_core { public: instantiate_nested_cmd():instantiate_cmd_core("dbg-instantiate-nested") {} - virtual char const * get_descr(cmd_context & ctx) const { return "instantiate the quantifier nested in the outermost quantifier, this command is used to test the instantiation procedure with quantifiers that contain free variables."; } + char const * get_descr(cmd_context & ctx) const override { return "instantiate the quantifier nested in the outermost quantifier, this command is used to test the instantiation procedure with quantifiers that contain free variables."; } - virtual void set_next_arg(cmd_context & ctx, expr * s) { + void set_next_arg(cmd_context & ctx, expr * s) override { instantiate_cmd_core::set_next_arg(ctx, s); if (!is_quantifier(m_q->get_expr())) throw cmd_exception("invalid command, nested quantifier expected"); @@ -345,11 +345,11 @@ public: class print_dimacs_cmd : public cmd { public: print_dimacs_cmd():cmd("display-dimacs") {} - virtual char const * get_usage() const { return ""; } - virtual char const * get_descr(cmd_context & ctx) const { return "print benchmark in DIMACS format"; } - virtual unsigned get_arity() const { return 0; } - virtual void prepare(cmd_context & ctx) {} - virtual void execute(cmd_context & ctx) { ctx.display_dimacs(); } + char const * get_usage() const override { return ""; } + char const * get_descr(cmd_context & ctx) const override { return "print benchmark in DIMACS format"; } + unsigned get_arity() const override { return 0; } + void prepare(cmd_context & ctx) override {} + void execute(cmd_context & ctx) override { ctx.display_dimacs(); } }; diff --git a/src/cmd_context/extra_cmds/polynomial_cmds.cpp b/src/cmd_context/extra_cmds/polynomial_cmds.cpp index 7a748ac66..8adaa660d 100644 --- a/src/cmd_context/extra_cmds/polynomial_cmds.cpp +++ b/src/cmd_context/extra_cmds/polynomial_cmds.cpp @@ -164,33 +164,33 @@ class poly_isolate_roots_cmd : public cmd { public: poly_isolate_roots_cmd(char const * name = "poly/isolate-roots"):cmd(name), m_ctx(0) {} - virtual char const * get_usage() const { return " ( )*"; } + char const * get_usage() const override { return " ( )*"; } - virtual char const * get_descr(cmd_context & ctx) const { return "isolate the roots a multivariate polynomial modulo an assignment"; } + char const * get_descr(cmd_context & ctx) const override { return "isolate the roots a multivariate polynomial modulo an assignment"; } - virtual unsigned get_arity() const { return VAR_ARITY; } + unsigned get_arity() const override { return VAR_ARITY; } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { m_ctx = alloc(context, ctx.m()); } - virtual void finalize(cmd_context & ctx) { + void finalize(cmd_context & ctx) override { m_ctx = 0; } - virtual void failure_cleanup(cmd_context & ctx) { + void failure_cleanup(cmd_context & ctx) override { m_ctx = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_EXPR; } - virtual void set_next_arg(cmd_context & ctx, expr * arg) { + void set_next_arg(cmd_context & ctx, expr * arg) override { m_ctx->set_next_arg(ctx, arg); } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { m_ctx->execute(ctx); m_ctx = 0; } @@ -204,31 +204,31 @@ class poly_factor_cmd : public parametric_cmd { public: poly_factor_cmd(char const * name = "poly/factor"):parametric_cmd(name) {} - virtual char const * get_usage() const { return " ( )*"; } + char const * get_usage() const override { return " ( )*"; } - virtual char const * get_main_descr() const { + char const * get_main_descr() const override { return "factor a polynomial"; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { polynomial::factor_params::get_param_descrs(p); } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); m_target = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_target == 0) return CPK_EXPR; return parametric_cmd::next_arg_kind(ctx); } - virtual void set_next_arg(cmd_context & ctx, expr * arg) { + void set_next_arg(cmd_context & ctx, expr * arg) override { m_target = arg; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { polynomial::factor_params ps; ps.updt_params(m_params); factor(ctx, m_target, ps); diff --git a/src/cmd_context/interpolant_cmds.cpp b/src/cmd_context/interpolant_cmds.cpp index 8b9f0ebd8..62824c2ec 100644 --- a/src/cmd_context/interpolant_cmds.cpp +++ b/src/cmd_context/interpolant_cmds.cpp @@ -219,29 +219,29 @@ protected: public: get_interpolant_cmd(char const * name = "get-interpolant"):parametric_cmd(name) {} - virtual char const * get_usage() const { return "+"; } + char const * get_usage() const override { return "+"; } - virtual char const * get_main_descr() const { + char const * get_main_descr() const override { return "get interpolant for formulas"; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); m_targets.resize(0); } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_EXPR; } - virtual void set_next_arg(cmd_context & ctx, expr * arg) { + void set_next_arg(cmd_context & ctx, expr * arg) override { m_targets.push_back(arg); } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { get_interpolant(ctx,m_targets,m_params); } }; @@ -250,7 +250,7 @@ class compute_interpolant_cmd : public get_interpolant_cmd { public: compute_interpolant_cmd(char const * name = "compute-interpolant"):get_interpolant_cmd(name) {} - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { compute_interpolant(ctx,m_targets,m_params); } diff --git a/src/cmd_context/parametric_cmd.h b/src/cmd_context/parametric_cmd.h index 6d676d6f9..84b29a17d 100644 --- a/src/cmd_context/parametric_cmd.h +++ b/src/cmd_context/parametric_cmd.h @@ -31,48 +31,48 @@ public: scoped_ptr m_pdescrs; public: parametric_cmd(char const * name):cmd(name), m_descr(0) {} - virtual ~parametric_cmd() { if (m_descr) dealloc(m_descr); } + ~parametric_cmd() override { if (m_descr) dealloc(m_descr); } virtual void init_pdescrs(cmd_context & ctx, param_descrs & d) = 0; param_descrs const & pdescrs(cmd_context & ctx) const; params_ref const & ps() const { return m_params; } virtual char const * get_main_descr() const = 0; - virtual char const * get_descr(cmd_context & ctx) const; - virtual unsigned get_arity() const { return VAR_ARITY; } - virtual void prepare(cmd_context & ctx) { m_last = symbol::null; m_params.reset(); } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const; - virtual void set_next_arg(cmd_context & ctx, symbol const & s); - virtual void set_next_arg(cmd_context & ctx, unsigned val) { + char const * get_descr(cmd_context & ctx) const override; + unsigned get_arity() const override { return VAR_ARITY; } + void prepare(cmd_context & ctx) override { m_last = symbol::null; m_params.reset(); } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override; + void set_next_arg(cmd_context & ctx, symbol const & s) override; + void set_next_arg(cmd_context & ctx, unsigned val) override { m_params.set_uint(m_last, val); m_last = symbol::null; } - virtual void set_next_arg(cmd_context & ctx, bool val) { + void set_next_arg(cmd_context & ctx, bool val) override { m_params.set_bool(m_last, val); m_last = symbol::null; } - virtual void set_next_arg(cmd_context & ctx, rational const & val) { + void set_next_arg(cmd_context & ctx, rational const & val) override { m_params.set_rat(m_last, val); m_last = symbol::null; } - virtual void set_next_arg(cmd_context & ctx, char const * val) { + void set_next_arg(cmd_context & ctx, char const * val) override { m_params.set_str(m_last, val); m_last = symbol::null; } - virtual void set_next_arg(cmd_context & ctx, sort * s) { + void set_next_arg(cmd_context & ctx, sort * s) override { NOT_IMPLEMENTED_YET(); // m_params.set_sort(m_last, s); // m_last = symbol::null; } - virtual void set_next_arg(cmd_context & ctx, expr * t) { + void set_next_arg(cmd_context & ctx, expr * t) override { NOT_IMPLEMENTED_YET(); // m_params.set_expr(m_last, t); // m_last = symbol::null; } - virtual void set_next_arg(cmd_context & ctx, func_decl * f) { + void set_next_arg(cmd_context & ctx, func_decl * f) override { NOT_IMPLEMENTED_YET(); // m_params.set_func_decl(m_last, f); // m_last = symbol::null; } - virtual void set_next_arg(cmd_context & ctx, sexpr * n) { UNREACHABLE(); } + void set_next_arg(cmd_context & ctx, sexpr * n) override { UNREACHABLE(); } }; #endif diff --git a/src/cmd_context/pdecl.cpp b/src/cmd_context/pdecl.cpp index f75fbfa29..f485aea75 100644 --- a/src/cmd_context/pdecl.cpp +++ b/src/cmd_context/pdecl.cpp @@ -136,25 +136,25 @@ class psort_sort : public psort { friend class pdecl_manager; sort * m_sort; psort_sort(unsigned id, pdecl_manager & m, sort * s):psort(id, 0), m_sort(s) { m.m().inc_ref(m_sort); } - virtual void finalize(pdecl_manager & m) { + void finalize(pdecl_manager & m) override { m.m().dec_ref(m_sort); psort::finalize(m); } - virtual bool check_num_params(pdecl * other) const { return true; } - virtual size_t obj_size() const { return sizeof(psort_sort); } + bool check_num_params(pdecl * other) const override { return true; } + size_t obj_size() const override { return sizeof(psort_sort); } sort * get_sort() const { return m_sort; } - virtual sort * instantiate(pdecl_manager & m, sort * const * s) { return m_sort; } + sort * instantiate(pdecl_manager & m, sort * const * s) override { return m_sort; } public: - virtual ~psort_sort() {} - virtual bool is_sort_wrapper() const { return true; } - virtual char const * hcons_kind() const { return "psort_sort"; } - virtual unsigned hcons_hash() const { return m_sort->get_id(); } - virtual bool hcons_eq(psort const * other) const { + ~psort_sort() override {} + bool is_sort_wrapper() const override { return true; } + char const * hcons_kind() const override { return "psort_sort"; } + unsigned hcons_hash() const override { return m_sort->get_id(); } + bool hcons_eq(psort const * other) const override { if (other->hcons_kind() != hcons_kind()) return false; return m_sort == static_cast(other)->m_sort; } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { out << m_sort->get_name(); } }; @@ -163,19 +163,19 @@ class psort_var : public psort { friend class pdecl_manager; unsigned m_idx; psort_var(unsigned id, unsigned num_params, unsigned idx):psort(id, num_params), m_idx(idx) { SASSERT(idx < num_params); } - virtual sort * instantiate(pdecl_manager & m, sort * const * s) { return s[m_idx]; } - virtual size_t obj_size() const { return sizeof(psort_var); } + sort * instantiate(pdecl_manager & m, sort * const * s) override { return s[m_idx]; } + size_t obj_size() const override { return sizeof(psort_var); } public: - virtual ~psort_var() {} - virtual char const * hcons_kind() const { return "psort_var"; } - virtual unsigned hcons_hash() const { return hash_u_u(m_num_params, m_idx); } - virtual bool hcons_eq(psort const * other) const { + ~psort_var() override {} + char const * hcons_kind() const override { return "psort_var"; } + unsigned hcons_hash() const override { return hash_u_u(m_num_params, m_idx); } + bool hcons_eq(psort const * other) const override { return other->hcons_kind() == hcons_kind() && get_num_params() == other->get_num_params() && m_idx == static_cast(other)->m_idx; } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { out << "s_" << m_idx; } unsigned idx() const { return m_idx; } @@ -196,13 +196,13 @@ class psort_app : public psort { DEBUG_CODE(if (num_args == num_params) { for (unsigned i = 0; i < num_params; i++) args[i]->check_num_params(this); }); } - virtual void finalize(pdecl_manager & m) { + void finalize(pdecl_manager & m) override { m.lazy_dec_ref(m_decl); m.lazy_dec_ref(m_args.size(), m_args.c_ptr()); psort::finalize(m); } - virtual size_t obj_size() const { return sizeof(psort_app); } + size_t obj_size() const override { return sizeof(psort_app); } struct khasher { unsigned operator()(psort_app const * d) const { return d->m_decl->hash(); } @@ -212,7 +212,7 @@ class psort_app : public psort { unsigned operator()(psort_app const * d, unsigned idx) const { return d->m_args[idx]->hash(); } }; - virtual sort * instantiate(pdecl_manager & m, sort * const * s) { + sort * instantiate(pdecl_manager & m, sort * const * s) override { sort * r = find(s); if (r) return r; @@ -228,12 +228,12 @@ class psort_app : public psort { } public: - virtual ~psort_app() {} - virtual char const * hcons_kind() const { return "psort_app"; } - virtual unsigned hcons_hash() const { + ~psort_app() override {} + char const * hcons_kind() const override { return "psort_app"; } + unsigned hcons_hash() const override { return get_composite_hash(const_cast(this), m_args.size()); } - virtual bool hcons_eq(psort const * other) const { + bool hcons_eq(psort const * other) const override { if (other->hcons_kind() != hcons_kind()) return false; if (get_num_params() != other->get_num_params()) @@ -249,7 +249,7 @@ public: } return true; } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { if (m_args.empty()) { out << m_decl->get_name(); } @@ -752,16 +752,16 @@ struct pdecl_manager::app_sort_info : public pdecl_manager::sort_info { m.m().inc_array_ref(n, s); } - virtual ~app_sort_info() {} + ~app_sort_info() override {} - virtual unsigned obj_size() const { return sizeof(app_sort_info); } + unsigned obj_size() const override { return sizeof(app_sort_info); } - virtual void finalize(pdecl_manager & m) { + void finalize(pdecl_manager & m) override { sort_info::finalize(m); m.m().dec_array_ref(m_args.size(), m_args.c_ptr()); } - virtual void display(std::ostream & out, pdecl_manager const & m) const { + void display(std::ostream & out, pdecl_manager const & m) const override { if (m_args.empty()) { out << m_decl->get_name(); } @@ -775,7 +775,7 @@ struct pdecl_manager::app_sort_info : public pdecl_manager::sort_info { } } - virtual format * pp(pdecl_manager const & m) const { + format * pp(pdecl_manager const & m) const override { if (m_args.empty()) { return mk_string(m.m(), m_decl->get_name().str().c_str()); } @@ -796,11 +796,11 @@ struct pdecl_manager::indexed_sort_info : public pdecl_manager::sort_info { m_indices(n, s) { } - virtual ~indexed_sort_info() {} + ~indexed_sort_info() override {} - virtual unsigned obj_size() const { return sizeof(indexed_sort_info); } + unsigned obj_size() const override { return sizeof(indexed_sort_info); } - virtual void display(std::ostream & out, pdecl_manager const & m) const { + void display(std::ostream & out, pdecl_manager const & m) const override { if (m_indices.empty()) { out << m_decl->get_name(); } @@ -813,7 +813,7 @@ struct pdecl_manager::indexed_sort_info : public pdecl_manager::sort_info { } } - virtual format * pp(pdecl_manager const & m) const { + format * pp(pdecl_manager const & m) const override { if (m_indices.empty()) { return mk_string(m.m(), m_decl->get_name().str().c_str()); } diff --git a/src/cmd_context/pdecl.h b/src/cmd_context/pdecl.h index c72020827..d6fea179d 100644 --- a/src/cmd_context/pdecl.h +++ b/src/cmd_context/pdecl.h @@ -65,9 +65,9 @@ protected: psort_inst_cache * m_inst_cache; friend class pdecl_manager; psort(unsigned id, unsigned num_params):pdecl(id, num_params), m_inst_cache(0) {} - virtual bool is_psort() const { return true; } - virtual void finalize(pdecl_manager & m); - virtual ~psort() {} + bool is_psort() const override { return true; } + void finalize(pdecl_manager & m) override; + ~psort() override {} virtual void cache(pdecl_manager & m, sort * const * s, sort * r); virtual sort * find(sort * const * s) const; public: @@ -77,7 +77,7 @@ public: virtual char const * hcons_kind() const = 0; virtual unsigned hcons_hash() const = 0; virtual bool hcons_eq(psort const * other) const = 0; - virtual void reset_cache(pdecl_manager& m); + void reset_cache(pdecl_manager& m) override; }; // for hash consing @@ -98,8 +98,8 @@ protected: void cache(pdecl_manager & m, sort * const * s, sort * r); sort * find(sort * const * s); psort_decl(unsigned id, unsigned num_params, pdecl_manager & m, symbol const & n); - virtual void finalize(pdecl_manager & m); - virtual ~psort_decl() {} + void finalize(pdecl_manager & m) override; + ~psort_decl() override {} public: virtual sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s) = 0; virtual sort * instantiate(pdecl_manager & m, unsigned n, unsigned const * s) { return 0; } @@ -108,7 +108,7 @@ public: // Only builtin declarations can have a variable number of parameters. bool has_var_params() const { return m_num_params == PSORT_DECL_VAR_PARAMS; } symbol const & get_name() const { return m_name; } - virtual void reset_cache(pdecl_manager& m); + void reset_cache(pdecl_manager& m) override; bool is_user_decl() const { return m_psort_kind == PSORT_USER; } bool is_builtin_decl() const { return m_psort_kind == PSORT_BUILTIN; } bool is_dt_decl() const { return m_psort_kind == PSORT_DT; } @@ -119,12 +119,12 @@ protected: friend class pdecl_manager; psort * m_def; psort_user_decl(unsigned id, unsigned num_params, pdecl_manager & m, symbol const & n, psort * p); - virtual size_t obj_size() const { return sizeof(psort_user_decl); } - virtual void finalize(pdecl_manager & m); - virtual ~psort_user_decl() {} + size_t obj_size() const override { return sizeof(psort_user_decl); } + void finalize(pdecl_manager & m) override; + ~psort_user_decl() override {} public: - virtual sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s); - virtual void display(std::ostream & out) const; + sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s) override; + void display(std::ostream & out) const override; }; class psort_builtin_decl : public psort_decl { @@ -133,23 +133,23 @@ protected: family_id m_fid; decl_kind m_kind; psort_builtin_decl(unsigned id, pdecl_manager & m, symbol const & n, family_id fid, decl_kind k); - virtual size_t obj_size() const { return sizeof(psort_builtin_decl); } - virtual ~psort_builtin_decl() {} + size_t obj_size() const override { return sizeof(psort_builtin_decl); } + ~psort_builtin_decl() override {} public: - virtual sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s); - virtual sort * instantiate(pdecl_manager & m, unsigned n, unsigned const * s); - virtual void display(std::ostream & out) const; + sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s) override; + sort * instantiate(pdecl_manager & m, unsigned n, unsigned const * s) override; + void display(std::ostream & out) const override; }; class psort_dt_decl : public psort_decl { protected: friend class pdecl_manager; psort_dt_decl(unsigned id, unsigned num_params, pdecl_manager & m, symbol const & n); - virtual size_t obj_size() const { return sizeof(psort_dt_decl); } - virtual ~psort_dt_decl() {} + size_t obj_size() const override { return sizeof(psort_dt_decl); } + ~psort_dt_decl() override {} public: - virtual sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s); - virtual void display(std::ostream & out) const; + sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s) override; + void display(std::ostream & out) const override; }; @@ -190,16 +190,16 @@ class paccessor_decl : public pdecl { symbol m_name; ptype m_type; paccessor_decl(unsigned id, unsigned num_params, pdecl_manager & m, symbol const & n, ptype const & r); - virtual void finalize(pdecl_manager & m); - virtual size_t obj_size() const { return sizeof(paccessor_decl); } + void finalize(pdecl_manager & m) override; + size_t obj_size() const override { return sizeof(paccessor_decl); } bool has_missing_refs(symbol & missing) const; bool fix_missing_refs(dictionary const & symbol2idx, symbol & missing); accessor_decl * instantiate_decl(pdecl_manager & m, sort * const * s); symbol const & get_name() const { return m_name; } ptype const & get_type() const { return m_type; } - virtual ~paccessor_decl() {} + ~paccessor_decl() override {} public: - virtual void display(std::ostream & out) const { pdecl::display(out); } + void display(std::ostream & out) const override { pdecl::display(out); } void display(std::ostream & out, pdatatype_decl const * const * dts) const; }; @@ -211,16 +211,16 @@ class pconstructor_decl : public pdecl { ptr_vector m_accessors; pconstructor_decl(unsigned id, unsigned num_params, pdecl_manager & m, symbol const & n, symbol const & r, unsigned num_accessors, paccessor_decl * const * accessors); - virtual void finalize(pdecl_manager & m); - virtual size_t obj_size() const { return sizeof(pconstructor_decl); } + void finalize(pdecl_manager & m) override; + size_t obj_size() const override { return sizeof(pconstructor_decl); } bool has_missing_refs(symbol & missing) const; bool fix_missing_refs(dictionary const & symbol2idx, symbol & missing); symbol const & get_name() const { return m_name; } symbol const & get_recognizer_name() const { return m_recogniser_name; } constructor_decl * instantiate_decl(pdecl_manager & m, sort * const * s); - virtual ~pconstructor_decl() {} + ~pconstructor_decl() override {} public: - virtual void display(std::ostream & out) const { pdecl::display(out); } + void display(std::ostream & out) const override { pdecl::display(out); } void display(std::ostream & out, pdatatype_decl const * const * dts) const; }; @@ -231,14 +231,14 @@ class pdatatype_decl : public psort_decl { pdatatypes_decl * m_parent; pdatatype_decl(unsigned id, unsigned num_params, pdecl_manager & m, symbol const & n, unsigned num_constructors, pconstructor_decl * const * constructors); - virtual void finalize(pdecl_manager & m); - virtual size_t obj_size() const { return sizeof(pdatatype_decl); } + void finalize(pdecl_manager & m) override; + size_t obj_size() const override { return sizeof(pdatatype_decl); } bool fix_missing_refs(dictionary const & symbol2idx, symbol & missing); datatype_decl * instantiate_decl(pdecl_manager & m, sort * const * s); - virtual ~pdatatype_decl() {} + ~pdatatype_decl() override {} public: - sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s); - virtual void display(std::ostream & out) const; + sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s) override; + void display(std::ostream & out) const override; bool has_missing_refs(symbol & missing) const; bool has_duplicate_accessors(symbol & repeated) const; bool commit(pdecl_manager& m); @@ -252,11 +252,11 @@ class pdatatypes_decl : public pdecl { friend class pdatatype_decl; ptr_vector m_datatypes; pdatatypes_decl(unsigned id, unsigned num_params, pdecl_manager & m, unsigned num_datatypes, pdatatype_decl * const * dts); - virtual void finalize(pdecl_manager & m); - virtual size_t obj_size() const { return sizeof(pdatatypes_decl); } + void finalize(pdecl_manager & m) override; + size_t obj_size() const override { return sizeof(pdatatypes_decl); } bool fix_missing_refs(symbol & missing); bool instantiate(pdecl_manager & m, sort * const * s); - virtual ~pdatatypes_decl() {} + ~pdatatypes_decl() override {} public: pdatatype_decl const * const * children() const { return m_datatypes.c_ptr(); } pdatatype_decl * const * begin() const { return m_datatypes.begin(); } diff --git a/src/cmd_context/simplify_cmd.cpp b/src/cmd_context/simplify_cmd.cpp index 5112a6ea2..999351d25 100644 --- a/src/cmd_context/simplify_cmd.cpp +++ b/src/cmd_context/simplify_cmd.cpp @@ -36,7 +36,7 @@ class simplify_cmd : public parametric_cmd { public: th_solver(cmd_context& ctx): m_ctx(ctx) {} - virtual lbool check_sat(expr* e) { + lbool check_sat(expr* e) override { if (!m_solver) { m_solver = m_ctx.get_solver_factory()(m_ctx.m(), m_params, false, true, false, symbol::null); } @@ -52,13 +52,13 @@ class simplify_cmd : public parametric_cmd { public: simplify_cmd(char const * name = "simplify"):parametric_cmd(name) {} - virtual char const * get_usage() const { return " ( )*"; } + char const * get_usage() const override { return " ( )*"; } - virtual char const * get_main_descr() const { + char const * get_main_descr() const override { return "simplify the given term using builtin theory simplification rules."; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { th_rewriter::get_param_descrs(p); insert_timeout(p); p.insert("print", CPK_BOOL, "(default: true) print the simplified term."); @@ -66,24 +66,24 @@ public: p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } - virtual ~simplify_cmd() { + ~simplify_cmd() override { } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); m_target = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_target == 0) return CPK_EXPR; return parametric_cmd::next_arg_kind(ctx); } - virtual void set_next_arg(cmd_context & ctx, expr * arg) { + void set_next_arg(cmd_context & ctx, expr * arg) override { m_target = arg; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { if (m_target == 0) throw cmd_exception("invalid simplify command, argument expected"); expr_ref r(ctx.m()); diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index cbc90c62c..f35267714 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -58,17 +58,17 @@ public: m_decl(0) { } - virtual char const * get_usage() const { return " "; } - virtual char const * get_descr(cmd_context & ctx) const { return "declare a new tactic, use (help-tactic) for the tactic language syntax."; } - virtual unsigned get_arity() const { return 2; } - virtual void prepare(cmd_context & ctx) { m_name = symbol::null; m_decl = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + char const * get_usage() const override { return " "; } + char const * get_descr(cmd_context & ctx) const override { return "declare a new tactic, use (help-tactic) for the tactic language syntax."; } + unsigned get_arity() const override { return 2; } + void prepare(cmd_context & ctx) override { m_name = symbol::null; m_decl = 0; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_name == symbol::null) return CPK_SYMBOL; return CPK_SEXPR; } - virtual void set_next_arg(cmd_context & ctx, symbol const & s) { m_name = s; } - virtual void set_next_arg(cmd_context & ctx, sexpr * n) { m_decl = n; } - virtual void execute(cmd_context & ctx) { + void set_next_arg(cmd_context & ctx, symbol const & s) override { m_name = s; } + void set_next_arg(cmd_context & ctx, sexpr * n) override { m_decl = n; } + void execute(cmd_context & ctx) override { tactic_ref t = sexpr2tactic(ctx, m_decl); // make sure the tactic is well formed. ctx.insert_user_tactic(m_name, m_decl); } @@ -133,23 +133,23 @@ public: parametric_cmd(name) { } - virtual char const * get_usage() const { return " ( )*"; } + char const * get_usage() const override { return " ( )*"; } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); m_tactic = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_tactic == 0) return CPK_SEXPR; return parametric_cmd::next_arg_kind(ctx); } - virtual void set_next_arg(cmd_context & ctx, sexpr * arg) { + void set_next_arg(cmd_context & ctx, sexpr * arg) override { m_tactic = arg; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { insert_timeout(p); insert_max_memory(p); p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); @@ -172,7 +172,7 @@ public: check_sat_tactic_result(ast_manager & m) : simple_check_sat_result(m) { } - virtual void get_labels(svector & r) { + void get_labels(svector & r) override { r.append(labels); } @@ -187,16 +187,16 @@ public: exec_given_tactic_cmd("check-sat-using") { } - virtual char const * get_main_descr() const { return "check if the current context is satisfiable using the given tactic, use (help-tactic) for the tactic language syntax."; } + char const * get_main_descr() const override { return "check if the current context is satisfiable using the given tactic, use (help-tactic) for the tactic language syntax."; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { exec_given_tactic_cmd::init_pdescrs(ctx, p); p.insert("print_unsat_core", CPK_BOOL, "(default: false) print unsatisfiable core."); p.insert("print_proof", CPK_BOOL, "(default: false) print proof."); p.insert("print_model", CPK_BOOL, "(default: false) print model."); } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { if (!m_tactic) { throw cmd_exception("check-sat-using needs a tactic argument"); } @@ -295,9 +295,9 @@ public: exec_given_tactic_cmd("apply") { } - virtual char const * get_main_descr() const { return "apply the given tactic to the current context, and print the resultant set of goals."; } + char const * get_main_descr() const override { return "apply the given tactic to the current context, and print the resultant set of goals."; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { p.insert("print", CPK_BOOL, "(default: true) print resultant goals."); #ifndef _EXTERNAL_RELEASE p.insert("print_proof", CPK_BOOL, "(default: false) print proof associated with each assertion."); @@ -308,7 +308,7 @@ public: exec_given_tactic_cmd::init_pdescrs(ctx, p); } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { if (!m_tactic) { throw cmd_exception("apply needs a tactic argument"); } diff --git a/src/duality/duality.h b/src/duality/duality.h index c9ef3c52d..bb736feb9 100644 --- a/src/duality/duality.h +++ b/src/duality/duality.h @@ -248,14 +248,14 @@ namespace Duality { TermTree *&interpolants, model &_model, TermTree *goals = 0, - bool weak = false) + bool weak = false) override { literals _labels; islvr->SetWeakInterpolants(weak); return islvr->interpolate_tree(assumptions,interpolants,_model,_labels,true); } - void assert_axiom(const expr &axiom){ + void assert_axiom(const expr &axiom) override { #if 1 // HACK: large "distict" predicates can kill the legacy SMT solver. // encode them with a UIF @@ -280,11 +280,11 @@ namespace Duality { islvr->AssertInterpolationAxiom(axiom); } - const std::vector &get_axioms() { + const std::vector &get_axioms() override { return islvr->GetInterpolationAxioms(); } - std::string profile(){ + std::string profile() override { return islvr->profile(); } @@ -307,31 +307,31 @@ namespace Duality { void write_interpolation_problem(const std::string &file_name, const std::vector &assumptions, const std::vector &theory - ){ + ) override { #if 0 islvr->write_interpolation_problem(file_name,assumptions,theory); #endif } - void cancel(){islvr->cancel();} + void cancel() override {islvr->cancel();} /** Declare a constant in the background theory. */ - virtual void declare_constant(const func_decl &f){ + void declare_constant(const func_decl &f) override { bckg.insert(f); } /** Is this a background constant? */ - virtual bool is_constant(const func_decl &f){ + bool is_constant(const func_decl &f) override { return bckg.find(f) != bckg.end(); } /** Get the constants in the background vocabulary */ - virtual hash_set &get_constants(){ + hash_set &get_constants() override { return bckg; } - ~iZ3LogicSolver(){ + ~iZ3LogicSolver() override { // delete ictx; delete islvr; } @@ -1274,7 +1274,7 @@ namespace Duality { virtual void AssertEdge(Edge *e, int persist = 0, bool with_children = false, bool underapprox = false); #endif - virtual ~RPFP_caching(){} + ~RPFP_caching() override {} protected: hash_map AssumptionLits; @@ -1320,21 +1320,21 @@ namespace Duality { void FilterCore(std::vector &core, std::vector &full_core); void ConstrainEdgeLocalizedCache(Edge *e, const Term &tl, std::vector &lits); - virtual void slvr_add(const expr &e); + void slvr_add(const expr &e) override; - virtual void slvr_pop(int i); + void slvr_pop(int i) override; - virtual void slvr_push(); + void slvr_push() override; - virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0); + check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0) override; - virtual lbool ls_interpolate_tree(TermTree *assumptions, + lbool ls_interpolate_tree(TermTree *assumptions, TermTree *&interpolants, model &_model, TermTree *goals = 0, - bool weak = false); + bool weak = false) override; - virtual bool proof_core_contains(const expr &e); + bool proof_core_contains(const expr &e) override; void GetTermTreeAssertionLiterals(TermTree *assumptions); diff --git a/src/duality/duality_solver.cpp b/src/duality/duality_solver.cpp index 6053295b5..66bcf4ab3 100644 --- a/src/duality/duality_solver.cpp +++ b/src/duality/duality_solver.cpp @@ -151,7 +151,7 @@ namespace Duality { } } - ~Duality(){ + ~Duality() override { #ifdef USE_RPFP_CLONE delete clone_rpfp; #endif @@ -321,7 +321,7 @@ namespace Duality { #endif /** Solve the problem. */ - virtual bool Solve(){ + bool Solve() override { PreSolve(); bool res = SolveMain(); // does the actual work PostSolve(); @@ -398,7 +398,7 @@ namespace Duality { } - void Cancel(){ + void Cancel() override { // TODO } @@ -418,7 +418,7 @@ namespace Duality { } #endif - virtual void LearnFrom(Solver *other_solver){ + void LearnFrom(Solver *other_solver) override { // get the counterexample as a guide cex.swap(other_solver->GetCounterexample()); @@ -429,7 +429,7 @@ namespace Duality { } /** Return a reference to the counterexample */ - virtual Counterexample &GetCounterexample(){ + Counterexample &GetCounterexample() override { return cex; } @@ -462,7 +462,7 @@ namespace Duality { } /** Set options (not currently used) */ - virtual bool SetOption(const std::string &option, const std::string &value){ + bool SetOption(const std::string &option, const std::string &value) override { if(option == "full_expand"){ return SetBoolOption(FullExpand,value); } @@ -828,7 +828,7 @@ namespace Duality { } } - bool IsResultRecursionBounded(){ + bool IsResultRecursionBounded() override { return recursionBounded; } @@ -2186,7 +2186,7 @@ namespace Duality { struct DoRestart {}; - virtual bool Build(){ + bool Build() override { restart_interval = 3; while (true) { try { @@ -2499,7 +2499,7 @@ namespace Duality { hash_map > node_map; std::list updated_nodes; - virtual void ExpandNode(RPFP::Node *p){ + void ExpandNode(RPFP::Node *p) override { stack.push_back(stack_entry()); stack.back().level = tree->slvr().get_scope_level(); stack.back().expansions.push_back(p); @@ -2990,13 +2990,13 @@ namespace Duality { old_cex.swap(_old_cex); // take ownership from caller } - ~ReplayHeuristic(){ + ~ReplayHeuristic() override { } // Maps nodes of derivation tree into old cex hash_map cex_map; - void Done() { + void Done() override { cex_map.clear(); old_cex.clear(); } @@ -3045,7 +3045,7 @@ namespace Duality { return cex_map[node]; } - int UseNode(Node *node){ + int UseNode(Node *node) override { if (!old_cex.get_tree()) return 0; Node *old_node = MatchNode(node); @@ -3054,7 +3054,7 @@ namespace Duality { return old_cex.get_tree()->Empty(old_node) ? -1 : 1; } - virtual void ChooseExpand(const std::set &choices, std::set &best, bool high_priority, bool best_only){ + void ChooseExpand(const std::set &choices, std::set &best, bool high_priority, bool best_only) override { if(cex_map.empty()) cex_map[*(choices.begin())] = old_cex.get_root(); // match the root nodes if(!high_priority || !old_cex.get_tree()){ @@ -3099,7 +3099,7 @@ namespace Duality { // Maps nodes of derivation tree into old subtree hash_map cex_map; - virtual void ChooseExpand(const std::set &choices, std::set &best, bool, bool){ + void ChooseExpand(const std::set &choices, std::set &best, bool, bool) override { if(old_node == 0){ Heuristic::ChooseExpand(choices,best); return; @@ -3200,11 +3200,11 @@ namespace Duality { } } - virtual std::vector &Propose(Node *node){ + std::vector &Propose(Node *node) override { return conjectures[node->map]; } - virtual ~HistoryProposer(){ + ~HistoryProposer() override { }; private: @@ -3273,68 +3273,68 @@ namespace Duality { } s << "[" << event++ << "]" ; } - virtual void Extend(RPFP::Node *node){ + void Extend(RPFP::Node *node) override { ev(); s << "node " << node->number << ": " << node->Name.name(); std::vector &rps = node->Outgoing->Children; for(unsigned i = 0; i < rps.size(); i++) s << " " << rps[i]->number; s << std::endl; } - virtual void Update(RPFP::Node *node, const RPFP::Transformer &update, bool eager){ + void Update(RPFP::Node *node, const RPFP::Transformer &update, bool eager) override { ev(); s << "update " << node->number << " " << node->Name.name() << ": "; rpfp->Summarize(update.Formula); if(depth > 0) s << " (depth=" << depth << ")"; if(eager) s << " (eager)"; s << std::endl; } - virtual void Bound(RPFP::Node *node){ + void Bound(RPFP::Node *node) override { ev(); s << "check " << node->number << std::endl; } - virtual void Expand(RPFP::Edge *edge){ + void Expand(RPFP::Edge *edge) override { RPFP::Node *node = edge->Parent; ev(); s << "expand " << node->map->number << " " << node->Name.name(); if(depth > 0) s << " (depth=" << depth << ")"; s << std::endl; } - virtual void Depth(int d){ + void Depth(int d) override { depth = d; } - virtual void AddCover(RPFP::Node *covered, std::vector &covering){ + void AddCover(RPFP::Node *covered, std::vector &covering) override { ev(); s << "cover " << covered->Name.name() << ": " << covered->number << " by "; for(unsigned i = 0; i < covering.size(); i++) s << covering[i]->number << " "; s << std::endl; } - virtual void RemoveCover(RPFP::Node *covered, RPFP::Node *covering){ + void RemoveCover(RPFP::Node *covered, RPFP::Node *covering) override { ev(); s << "uncover " << covered->Name.name() << ": " << covered->number << " by " << covering->number << std::endl; } - virtual void Forcing(RPFP::Node *covered, RPFP::Node *covering){ + void Forcing(RPFP::Node *covered, RPFP::Node *covering) override { ev(); s << "forcing " << covered->Name.name() << ": " << covered->number << " by " << covering->number << std::endl; } - virtual void Conjecture(RPFP::Node *node, const RPFP::Transformer &t){ + void Conjecture(RPFP::Node *node, const RPFP::Transformer &t) override { ev(); s << "conjecture " << node->number << " " << node->Name.name() << ": "; rpfp->Summarize(t.Formula); s << std::endl; } - virtual void Dominates(RPFP::Node *node, RPFP::Node *other){ + void Dominates(RPFP::Node *node, RPFP::Node *other) override { ev(); s << "dominates " << node->Name.name() << ": " << node->number << " > " << other->number << std::endl; } - virtual void InductionFailure(RPFP::Edge *edge, const std::vector &children){ + void InductionFailure(RPFP::Edge *edge, const std::vector &children) override { ev(); s << "induction failure: " << edge->Parent->Name.name() << ", children ="; for(unsigned i = 0; i < children.size(); i++) s << " " << children[i]->number; s << std::endl; } - virtual void UpdateUnderapprox(RPFP::Node *node, const RPFP::Transformer &update){ + void UpdateUnderapprox(RPFP::Node *node, const RPFP::Transformer &update) override { ev(); s << "underapprox " << node->number << " " << node->Name.name() << ": " << update.Formula << std::endl; } - virtual void Reject(RPFP::Edge *edge, const std::vector &children){ + void Reject(RPFP::Edge *edge, const std::vector &children) override { ev(); s << "reject " << edge->Parent->number << " " << edge->Parent->Name.name() << ": "; for(unsigned i = 0; i < children.size(); i++) s << " " << children[i]->number; s << std::endl; } - virtual void Message(const std::string &msg){ + void Message(const std::string &msg) override { ev(); s << "msg " << msg << std::endl; } @@ -3356,12 +3356,12 @@ namespace Duality { duality = alloc(Duality,drpfp); } - ~DualityDepthBounded(){ + ~DualityDepthBounded() override { dealloc(duality); delete drpfp; } - bool Solve(){ + bool Solve() override { int depth_bound = 10; bool res; SetMaxDepthRPFP(depth_bound); @@ -3382,26 +3382,26 @@ namespace Duality { return res; } - Counterexample &GetCounterexample(){ + Counterexample &GetCounterexample() override { return cex; } - bool SetOption(const std::string &option, const std::string &value){ + bool SetOption(const std::string &option, const std::string &value) override { return duality->SetOption(option,value); } - virtual void LearnFrom(Solver *old_solver){ + void LearnFrom(Solver *old_solver) override { DualityDepthBounded *old = dynamic_cast(old_solver); if(old){ duality->LearnFrom(old->duality); } } - bool IsResultRecursionBounded(){ + bool IsResultRecursionBounded() override { return duality->IsResultRecursionBounded(); } - void Cancel(){ + void Cancel() override { duality->Cancel(); } @@ -3580,7 +3580,7 @@ namespace Duality { public: ConjectureFileReporter(RPFP *_rpfp, const std::string &fname) : Reporter(_rpfp), s(fname.c_str()) {} - virtual void Update(RPFP::Node *node, const RPFP::Transformer &update, bool eager){ + void Update(RPFP::Node *node, const RPFP::Transformer &update, bool eager) override { s << "(define-fun " << node->Name.name() << " ("; for(unsigned i = 0; i < update.IndParams.size(); i++){ if(i != 0) diff --git a/src/math/automata/boolean_algebra.h b/src/math/automata/boolean_algebra.h index d54ff5d1a..ea2b66995 100644 --- a/src/math/automata/boolean_algebra.h +++ b/src/math/automata/boolean_algebra.h @@ -39,7 +39,7 @@ public: template class boolean_algebra : public positive_boolean_algebra { public: - virtual ~boolean_algebra() {} + ~boolean_algebra() override {} virtual T mk_not(T x) = 0; }; diff --git a/src/math/polynomial/polynomial_var2value.h b/src/math/polynomial/polynomial_var2value.h index c4aa16dfa..523703709 100644 --- a/src/math/polynomial/polynomial_var2value.h +++ b/src/math/polynomial/polynomial_var2value.h @@ -32,9 +32,9 @@ namespace polynomial { public: simple_var2value(ValManager & m):m_vs(m) {} void push_back(var x, typename ValManager::numeral const & v) { m_xs.push_back(x); m_vs.push_back(v); } - virtual ValManager & m() const { return m_vs.m(); } - virtual bool contains(var x) const { return std::find(m_xs.begin(), m_xs.end(), x) != m_xs.end(); } - virtual typename ValManager::numeral const & operator()(var x) const { + ValManager & m() const override { return m_vs.m(); } + bool contains(var x) const override { return std::find(m_xs.begin(), m_xs.end(), x) != m_xs.end(); } + typename ValManager::numeral const & operator()(var x) const override { for (unsigned i = 0; i < m_xs.size(); i++) if (m_xs[i] == x) return m_vs[i]; diff --git a/src/model/model.cpp b/src/model/model.cpp index 7ac1300de..7823a6f6b 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -93,7 +93,7 @@ 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) { + expr * operator()(sort * s) override { ptr_vector * u = 0; if (m_model.m_usort2universe.find(s, u)) { if (u->size() > 0) diff --git a/src/model/model.h b/src/model/model.h index f6de8ce0e..758d3d451 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -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 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 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 diff --git a/src/nlsat/nlsat_assignment.h b/src/nlsat/nlsat_assignment.h index 097ad76b6..cae15f4e1 100644 --- a/src/nlsat/nlsat_assignment.h +++ b/src/nlsat/nlsat_assignment.h @@ -66,9 +66,9 @@ namespace nlsat { void reset() { m_assigned.reset(); } bool is_assigned(var x) const { return m_assigned.get(x, false); } anum const & value(var x) const { return m_values[x]; } - virtual anum_manager & m() const { return am(); } - virtual bool contains(var x) const { return is_assigned(x); } - virtual anum const & operator()(var x) const { SASSERT(is_assigned(x)); return value(x); } + anum_manager & m() const override { return am(); } + bool contains(var x) const override { return is_assigned(x); } + anum const & operator()(var x) const override { SASSERT(is_assigned(x)); return value(x); } void swap(var x, var y) { SASSERT(x < m_values.size() && y < m_values.size()); std::swap(m_assigned[x], m_assigned[y]); @@ -95,9 +95,9 @@ namespace nlsat { var m_y; public: undef_var_assignment(assignment const & a, var y):m_assignment(a), m_y(y) {} - virtual anum_manager & m() const { return m_assignment.am(); } - virtual bool contains(var x) const { return x != m_y && m_assignment.is_assigned(x); } - virtual anum const & operator()(var x) const { return m_assignment.value(x); } + anum_manager & m() const override { return m_assignment.am(); } + bool contains(var x) const override { return x != m_y && m_assignment.is_assigned(x); } + anum const & operator()(var x) const override { return m_assignment.value(x); } }; }; diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 12b063759..3358dd61a 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -112,7 +112,7 @@ namespace nlsat { m_perm(perm), m_proc(0) { } - std::ostream& operator()(std::ostream & out, var x) const { + std::ostream& operator()(std::ostream & out, var x) const override { if (m_proc == 0) m_default_display_var(out, x); else @@ -2699,7 +2699,7 @@ namespace nlsat { var m_x; public: mathematica_var_proc(var x):m_x(x) {} - virtual std::ostream& operator()(std::ostream & out, var x) const { + std::ostream& operator()(std::ostream & out, var x) const override { if (m_x == x) return out << "#1"; else diff --git a/src/nlsat/tactic/goal2nlsat.cpp b/src/nlsat/tactic/goal2nlsat.cpp index 6d7e1c767..51536e493 100644 --- a/src/nlsat/tactic/goal2nlsat.cpp +++ b/src/nlsat/tactic/goal2nlsat.cpp @@ -41,11 +41,11 @@ struct goal2nlsat::imp { m_solver(s) { } - virtual bool is_int(polynomial::var x) const { + bool is_int(polynomial::var x) const override { return m_solver.is_int(x); } - virtual polynomial::var mk_var(bool is_int) { + polynomial::var mk_var(bool is_int) override { return m_solver.mk_var(is_int); } }; diff --git a/src/nlsat/tactic/nlsat_tactic.cpp b/src/nlsat/tactic/nlsat_tactic.cpp index 9de7215e3..74531a9a7 100644 --- a/src/nlsat/tactic/nlsat_tactic.cpp +++ b/src/nlsat/tactic/nlsat_tactic.cpp @@ -32,7 +32,7 @@ class nlsat_tactic : public tactic { ast_manager & m; expr_ref_vector m_var2expr; expr_display_var_proc(ast_manager & _m):m(_m), m_var2expr(_m) {} - virtual std::ostream& operator()(std::ostream & out, nlsat::var x) const { + std::ostream& operator()(std::ostream & out, nlsat::var x) const override { if (x < m_var2expr.size()) return out << mk_ismt2_pp(m_var2expr.get(x), m); else @@ -214,29 +214,29 @@ public: m_imp = 0; } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(nlsat_tactic, m_params); } - virtual ~nlsat_tactic() { + ~nlsat_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 { goal2nlsat::collect_param_descrs(r); nlsat::solver::collect_param_descrs(r); algebraic_numbers::manager::collect_param_descrs(r); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { imp local_imp(in->m(), m_params); scoped_set_imp setter(*this, local_imp); @@ -251,13 +251,13 @@ public: } } - virtual void cleanup() {} + void cleanup() override {} - 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(); } }; diff --git a/src/solver/check_sat_result.h b/src/solver/check_sat_result.h index 38720a5e9..76956718c 100644 --- a/src/solver/check_sat_result.h +++ b/src/solver/check_sat_result.h @@ -76,15 +76,15 @@ struct simple_check_sat_result : public check_sat_result { simple_check_sat_result(ast_manager & m); - virtual ~simple_check_sat_result(); - virtual ast_manager& get_manager() const { return m_proof.get_manager(); } - virtual void collect_statistics(statistics & st) const; - virtual void get_unsat_core(ptr_vector & r); - virtual void get_model(model_ref & m); - virtual proof * get_proof(); - virtual std::string reason_unknown() const; - virtual void get_labels(svector & r); - virtual void set_reason_unknown(char const* msg) { m_unknown = msg; } + ~simple_check_sat_result() override; + ast_manager& get_manager() const override { return m_proof.get_manager(); } + void collect_statistics(statistics & st) const override; + void get_unsat_core(ptr_vector & r) override; + void get_model(model_ref & m) override; + proof * get_proof() override; + std::string reason_unknown() const override; + void get_labels(svector & r) override; + void set_reason_unknown(char const* msg) override { m_unknown = msg; } }; #endif diff --git a/src/solver/combined_solver.cpp b/src/solver/combined_solver.cpp index 81e10e443..397f3bdb1 100644 --- a/src/solver/combined_solver.cpp +++ b/src/solver/combined_solver.cpp @@ -84,12 +84,12 @@ private: solver * m_solver; volatile bool m_canceled; aux_timeout_eh(solver * s):m_solver(s), m_canceled(false) {} - ~aux_timeout_eh() { + ~aux_timeout_eh() override { if (m_canceled) { m_solver->get_manager().limit().dec_cancel(); } } - virtual void operator()(event_handler_caller_t caller_id) { + void operator()(event_handler_caller_t caller_id) override { m_canceled = true; m_solver->get_manager().limit().inc_cancel(); } @@ -102,7 +102,7 @@ private: m_inc_unknown_behavior = static_cast(p.solver2_unknown()); } - virtual ast_manager& get_manager() const { return m_solver1->get_manager(); } + ast_manager& get_manager() const override { return m_solver1->get_manager(); } bool has_quantifiers() const { unsigned sz = get_num_assertions(); @@ -135,7 +135,7 @@ public: m_use_solver1_results = true; } - solver* translate(ast_manager& m, params_ref const& p) { + solver* translate(ast_manager& m, params_ref const& p) override { solver* s1 = m_solver1->translate(m, p); solver* s2 = m_solver2->translate(m, p); combined_solver* r = alloc(combined_solver, s1, s2, p); @@ -146,25 +146,25 @@ public: return r; } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { solver::updt_params(p); m_solver1->updt_params(p); m_solver2->updt_params(p); updt_local_params(p); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { m_solver1->collect_param_descrs(r); m_solver2->collect_param_descrs(r); combined_solver_params::collect_param_descrs(r); } - virtual void set_produce_models(bool f) { + void set_produce_models(bool f) override { m_solver1->set_produce_models(f); m_solver2->set_produce_models(f); } - virtual void assert_expr(expr * t) { + void assert_expr(expr * t) override { if (m_check_sat_executed) switch_inc_mode(); m_solver1->assert_expr(t); @@ -172,7 +172,7 @@ public: m_solver2->assert_expr(t); } - virtual void assert_expr(expr * t, expr * a) { + void assert_expr(expr * t, expr * a) override { if (m_check_sat_executed) switch_inc_mode(); m_solver1->assert_expr(t, a); @@ -180,23 +180,23 @@ public: m_solver2->assert_expr(t, a); } - virtual void push() { + void push() override { switch_inc_mode(); m_solver1->push(); m_solver2->push(); } - virtual void pop(unsigned n) { + void pop(unsigned n) override { switch_inc_mode(); m_solver1->pop(n); m_solver2->pop(n); } - virtual unsigned get_scope_level() const { + unsigned get_scope_level() const override { return m_solver1->get_scope_level(); } - virtual lbool get_consequences(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) { + lbool get_consequences(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) override { switch_inc_mode(); m_use_solver1_results = false; try { @@ -213,7 +213,7 @@ public: return l_undef; } - virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions) { + lbool check_sat(unsigned num_assumptions, expr * const * assumptions) override { m_check_sat_executed = true; m_use_solver1_results = false; @@ -258,73 +258,73 @@ public: return m_solver1->check_sat(num_assumptions, assumptions); } - virtual void set_progress_callback(progress_callback * callback) { + void set_progress_callback(progress_callback * callback) override { m_solver1->set_progress_callback(callback); m_solver2->set_progress_callback(callback); } - virtual unsigned get_num_assertions() const { + unsigned get_num_assertions() const override { return m_solver1->get_num_assertions(); } - virtual expr * get_assertion(unsigned idx) const { + expr * get_assertion(unsigned idx) const override { return m_solver1->get_assertion(idx); } - virtual unsigned get_num_assumptions() const { + unsigned get_num_assumptions() const override { return m_solver1->get_num_assumptions() + m_solver2->get_num_assumptions(); } - virtual expr * get_assumption(unsigned idx) const { + expr * get_assumption(unsigned idx) const override { unsigned c1 = m_solver1->get_num_assumptions(); if (idx < c1) return m_solver1->get_assumption(idx); return m_solver2->get_assumption(idx - c1); } - virtual std::ostream& display(std::ostream & out, unsigned n, expr* const* es) const { + std::ostream& display(std::ostream & out, unsigned n, expr* const* es) const override { return m_solver1->display(out, n, es); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { m_solver2->collect_statistics(st); if (m_use_solver1_results) m_solver1->collect_statistics(st); } - virtual void get_unsat_core(ptr_vector & r) { + void get_unsat_core(ptr_vector & r) override { if (m_use_solver1_results) m_solver1->get_unsat_core(r); else m_solver2->get_unsat_core(r); } - virtual void get_model(model_ref & m) { + void get_model(model_ref & m) override { if (m_use_solver1_results) m_solver1->get_model(m); else m_solver2->get_model(m); } - virtual proof * get_proof() { + proof * get_proof() override { if (m_use_solver1_results) return m_solver1->get_proof(); else return m_solver2->get_proof(); } - virtual std::string reason_unknown() const { + std::string reason_unknown() const override { if (m_use_solver1_results) return m_solver1->reason_unknown(); else return m_solver2->reason_unknown(); } - virtual void set_reason_unknown(char const* msg) { + void set_reason_unknown(char const* msg) override { m_solver1->set_reason_unknown(msg); m_solver2->set_reason_unknown(msg); } - virtual void get_labels(svector & r) { + void get_labels(svector & r) override { if (m_use_solver1_results) return m_solver1->get_labels(r); else @@ -343,9 +343,9 @@ class combined_solver_factory : public solver_factory { scoped_ptr m_f2; public: combined_solver_factory(solver_factory * f1, solver_factory * f2):m_f1(f1), m_f2(f2) {} - virtual ~combined_solver_factory() {} + ~combined_solver_factory() override {} - virtual solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) { + solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) override { return mk_combined_solver((*m_f1)(m, p, proofs_enabled, models_enabled, unsat_core_enabled, logic), (*m_f2)(m, p, proofs_enabled, models_enabled, unsat_core_enabled, logic), p); diff --git a/src/solver/solver.h b/src/solver/solver.h index 0a406455b..0b0acb644 100644 --- a/src/solver/solver.h +++ b/src/solver/solver.h @@ -45,7 +45,7 @@ public: class solver : public check_sat_result { params_ref m_params; public: - virtual ~solver() {} + ~solver() override {} /** \brief Creates a clone of the solver. diff --git a/src/solver/solver2tactic.cpp b/src/solver/solver2tactic.cpp index fa0711d70..3bc66e3b4 100644 --- a/src/solver/solver2tactic.cpp +++ b/src/solver/solver2tactic.cpp @@ -92,20 +92,20 @@ public: m_solver(s) {} - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_params.append(p); m_solver->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { m_solver->collect_param_descrs(r); } - virtual void operator()(/* in */ goal_ref const & in, - /* out */ goal_ref_buffer & result, - /* out */ model_converter_ref & mc, - /* out */ proof_converter_ref & pc, - /* out */ expr_dependency_ref & core) { + void operator()(/* in */ goal_ref const & in, + /* out */ goal_ref_buffer & result, + /* out */ model_converter_ref & mc, + /* out */ proof_converter_ref & pc, + /* out */ expr_dependency_ref & core) override { pc = 0; mc = 0; core = 0; expr_ref_vector clauses(m); expr2expr_map bool2dep; @@ -155,21 +155,21 @@ public: local_solver->collect_statistics(m_st); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { st.copy(m_st); } - virtual void reset_statistics() { m_st.reset(); } + void reset_statistics() override { m_st.reset(); } - virtual void cleanup() { } - virtual void reset() { cleanup(); } + void cleanup() override { } + void reset() override { cleanup(); } - virtual void set_logic(symbol const & l) {} + void set_logic(symbol const & l) override {} - virtual void set_progress_callback(progress_callback * callback) { + void set_progress_callback(progress_callback * callback) override { m_solver->set_progress_callback(callback); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(solver2tactic, m_solver->translate(m, m_params)); } }; diff --git a/src/solver/solver_na2as.h b/src/solver/solver_na2as.h index 3e726be12..0a041bd57 100644 --- a/src/solver/solver_na2as.h +++ b/src/solver/solver_na2as.h @@ -32,21 +32,21 @@ class solver_na2as : public solver { void restore_assumptions(unsigned old_sz); public: solver_na2as(ast_manager & m); - virtual ~solver_na2as(); + ~solver_na2as() override; - virtual void assert_expr(expr * t, expr * a); - virtual void assert_expr(expr * t) = 0; + void assert_expr(expr * t, expr * a) override; + void assert_expr(expr * t) override = 0; // Subclasses of solver_na2as should redefine the following *_core methods instead of these ones. - virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions); - virtual void push(); - virtual void pop(unsigned n); - virtual unsigned get_scope_level() const; + lbool check_sat(unsigned num_assumptions, expr * const * assumptions) override; + void push() override; + void pop(unsigned n) override; + unsigned get_scope_level() const override; - virtual unsigned get_num_assumptions() const { return m_assumptions.size(); } - virtual expr * get_assumption(unsigned idx) const { return m_assumptions[idx]; } - virtual lbool get_consequences(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences); - virtual lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes); + unsigned get_num_assumptions() const override { return m_assumptions.size(); } + expr * get_assumption(unsigned idx) const override { return m_assumptions[idx]; } + lbool get_consequences(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) override; + lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) override; protected: virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) = 0; virtual void push_core() = 0; diff --git a/src/solver/solver_pool.cpp b/src/solver/solver_pool.cpp index c8899e365..d58895708 100644 --- a/src/solver/solver_pool.cpp +++ b/src/solver/solver_pool.cpp @@ -53,7 +53,7 @@ public: } } - virtual ~pool_solver() { + ~pool_solver() override { if (m_pushed) pop(get_scope_level()); if (is_virtual()) { m_pred = m.mk_not(m_pred); @@ -63,12 +63,12 @@ public: solver* base_solver() { return m_base.get(); } - virtual solver* translate(ast_manager& m, params_ref const& p) { UNREACHABLE(); return nullptr; } - virtual void updt_params(params_ref const& p) { solver::updt_params(p); m_base->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { m_base->collect_param_descrs(r); } - virtual void collect_statistics(statistics & st) const { m_base->collect_statistics(st); } + solver* translate(ast_manager& m, params_ref const& p) override { UNREACHABLE(); return nullptr; } + void updt_params(params_ref const& p) override { solver::updt_params(p); m_base->updt_params(p); } + void collect_param_descrs(param_descrs & r) override { m_base->collect_param_descrs(r); } + void collect_statistics(statistics & st) const override { m_base->collect_statistics(st); } - virtual void get_unsat_core(ptr_vector & r) { + void get_unsat_core(ptr_vector & r) override { m_base->get_unsat_core(r); unsigned j = 0; for (unsigned i = 0; i < r.size(); ++i) @@ -77,12 +77,12 @@ public: r.shrink(j); } - virtual unsigned get_num_assumptions() const { + unsigned get_num_assumptions() const override { unsigned sz = solver_na2as::get_num_assumptions(); return is_virtual() ? sz - 1 : sz; } - virtual proof * get_proof() { + proof * get_proof() override { scoped_watch _t_(m_pool.m_proof_watch); if (!m_proof.get()) { elim_aux_assertions pc(m_pred); @@ -101,7 +101,7 @@ public: } } - virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) { + lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) override { SASSERT(!m_pushed || get_scope_level() > 0); m_proof.reset(); scoped_watch _t_(m_pool.m_check_watch); @@ -158,7 +158,7 @@ public: return res; } - virtual void push_core() { + void push_core() override { SASSERT(!m_pushed || get_scope_level() > 0); if (m_in_delayed_scope) { // second push @@ -178,7 +178,7 @@ public: } } - virtual void pop_core(unsigned n) { + void pop_core(unsigned n) override { SASSERT(!m_pushed || get_scope_level() > 0); if (m_pushed) { SASSERT(!m_in_delayed_scope); @@ -190,7 +190,7 @@ public: } } - virtual void assert_expr(expr * e) { + void assert_expr(expr * e) override { SASSERT(!m_pushed || get_scope_level() > 0); if (m.is_true(e)) return; if (m_in_delayed_scope) { @@ -211,18 +211,18 @@ public: } } - virtual void get_model(model_ref & _m) { m_base->get_model(_m); } + void get_model(model_ref & _m) override { m_base->get_model(_m); } - virtual expr * get_assumption(unsigned idx) const { + expr * get_assumption(unsigned idx) const override { return solver_na2as::get_assumption(idx + is_virtual()); } - virtual std::string reason_unknown() const { return m_base->reason_unknown(); } - virtual void set_reason_unknown(char const* msg) { return m_base->set_reason_unknown(msg); } - virtual void get_labels(svector & r) { return m_base->get_labels(r); } - virtual void set_progress_callback(progress_callback * callback) { m_base->set_progress_callback(callback); } + std::string reason_unknown() const override { return m_base->reason_unknown(); } + void set_reason_unknown(char const* msg) override { return m_base->set_reason_unknown(msg); } + void get_labels(svector & r) override { return m_base->get_labels(r); } + void set_progress_callback(progress_callback * callback) override { m_base->set_progress_callback(callback); } - virtual ast_manager& get_manager() const { return m_base->get_manager(); } + ast_manager& get_manager() const override { return m_base->get_manager(); } void refresh(solver* new_base) { SASSERT(!m_pushed); diff --git a/src/solver/tactic2solver.cpp b/src/solver/tactic2solver.cpp index a24f1d4c7..9dc4fe43d 100644 --- a/src/solver/tactic2solver.cpp +++ b/src/solver/tactic2solver.cpp @@ -44,36 +44,36 @@ class tactic2solver : public solver_na2as { public: tactic2solver(ast_manager & m, tactic * t, params_ref const & p, bool produce_proofs, bool produce_models, bool produce_unsat_cores, symbol const & logic); - virtual ~tactic2solver(); + ~tactic2solver() override; - virtual solver* translate(ast_manager& m, params_ref const& p); + solver* translate(ast_manager& m, params_ref const& p) override; - 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 set_produce_models(bool f) { m_produce_models = f; } + void set_produce_models(bool f) override { m_produce_models = f; } - virtual void assert_expr(expr * t); + void assert_expr(expr * t) override; - virtual void push_core(); - virtual void pop_core(unsigned n); - virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions); + void push_core() override; + void pop_core(unsigned n) override; + lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) override; - virtual void collect_statistics(statistics & st) const; - virtual void get_unsat_core(ptr_vector & r); - virtual void get_model(model_ref & m); - virtual proof * get_proof(); - virtual std::string reason_unknown() const; - virtual void set_reason_unknown(char const* msg); - virtual void get_labels(svector & r) {} + void collect_statistics(statistics & st) const override; + void get_unsat_core(ptr_vector & r) override; + void get_model(model_ref & m) override; + proof * get_proof() override; + std::string reason_unknown() const override; + void set_reason_unknown(char const* msg) override; + void get_labels(svector & r) override {} - virtual void set_progress_callback(progress_callback * callback) {} + void set_progress_callback(progress_callback * callback) override {} - virtual unsigned get_num_assertions() const; - virtual expr * get_assertion(unsigned idx) const; + unsigned get_num_assertions() const override; + expr * get_assertion(unsigned idx) const override; - virtual ast_manager& get_manager() const; + ast_manager& get_manager() const override; }; ast_manager& tactic2solver::get_manager() const { return m_assertions.get_manager(); } @@ -261,9 +261,9 @@ public: tactic2solver_factory(tactic * t):m_tactic(t) { } - virtual ~tactic2solver_factory() {} + ~tactic2solver_factory() override {} - virtual solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) { + solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) override { return mk_tactic2solver(m, m_tactic.get(), p, proofs_enabled, models_enabled, unsat_core_enabled, logic); } }; @@ -274,9 +274,9 @@ public: tactic_factory2solver_factory(tactic_factory * f):m_factory(f) { } - virtual ~tactic_factory2solver_factory() {} + ~tactic_factory2solver_factory() override {} - virtual solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) { + solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) override { tactic * t = (*m_factory)(m, p); return mk_tactic2solver(m, t, p, proofs_enabled, models_enabled, unsat_core_enabled, logic); } diff --git a/src/tactic/aig/aig_tactic.cpp b/src/tactic/aig/aig_tactic.cpp index 37ffc6124..b6b5021a1 100644 --- a/src/tactic/aig/aig_tactic.cpp +++ b/src/tactic/aig/aig_tactic.cpp @@ -46,7 +46,7 @@ public: updt_params(p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { aig_tactic * t = alloc(aig_tactic); t->m_max_memory = m_max_memory; t->m_aig_gate_encoding = m_aig_gate_encoding; @@ -54,13 +54,13 @@ public: return t; } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); m_aig_gate_encoding = p.get_bool("aig_default_gate_encoding", true); m_aig_per_assertion = p.get_bool("aig_per_assertion", true); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { insert_max_memory(r); r.insert("aig_per_assertion", CPK_BOOL, "(default: true) process one assertion at a time."); } @@ -90,11 +90,11 @@ public: SASSERT(g->is_well_sorted()); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { fail_if_proof_generation("aig", g); mc = 0; pc = 0; core = 0; operator()(g); @@ -102,7 +102,7 @@ public: result.push_back(g.get()); } - virtual void cleanup() {} + void cleanup() override {} }; diff --git a/src/tactic/arith/add_bounds_tactic.cpp b/src/tactic/arith/add_bounds_tactic.cpp index ac105eb06..e71542532 100644 --- a/src/tactic/arith/add_bounds_tactic.cpp +++ b/src/tactic/arith/add_bounds_tactic.cpp @@ -48,10 +48,10 @@ bool is_unbounded(goal const & g) { class is_unbounded_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_unbounded(g); } - virtual ~is_unbounded_probe() {} + ~is_unbounded_probe() override {} }; probe * mk_is_unbounded_probe() { @@ -142,33 +142,33 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(add_bounds_tactic, m, m_params); } - virtual ~add_bounds_tactic() { + ~add_bounds_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 { r.insert("add_bound_lower", CPK_NUMERAL, "(default: -2) lower bound to be added to unbounded variables."); r.insert("add_bound_upper", CPK_NUMERAL, "(default: 2) upper bound to be added to unbounded variables."); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(g, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m, m_params); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/arith/arith_bounds_tactic.cpp b/src/tactic/arith/arith_bounds_tactic.cpp index b750689b1..31e5d4fdc 100644 --- a/src/tactic/arith/arith_bounds_tactic.cpp +++ b/src/tactic/arith/arith_bounds_tactic.cpp @@ -23,15 +23,15 @@ struct arith_bounds_tactic : public tactic { ast_manager& get_manager() { return m; } - virtual void operator()(/* in */ goal_ref const & in, - /* out */ goal_ref_buffer & result, - /* out */ model_converter_ref & mc, - /* out */ proof_converter_ref & pc, - /* out */ expr_dependency_ref & core) { + void operator()(/* in */ goal_ref const & in, + /* out */ goal_ref_buffer & result, + /* out */ model_converter_ref & mc, + /* out */ proof_converter_ref & pc, + /* out */ expr_dependency_ref & core) override { bounds_arith_subsumption(in, result); } - virtual tactic* translate(ast_manager & mgr) { + tactic* translate(ast_manager & mgr) override { return alloc(arith_bounds_tactic, mgr); } @@ -146,7 +146,7 @@ struct arith_bounds_tactic : public tactic { TRACE("arith_subsumption", s->display(tout); ); } - virtual void cleanup() {} + void cleanup() override {} }; diff --git a/src/tactic/arith/card2bv_tactic.cpp b/src/tactic/arith/card2bv_tactic.cpp index d2453eba2..b268ea3de 100644 --- a/src/tactic/arith/card2bv_tactic.cpp +++ b/src/tactic/arith/card2bv_tactic.cpp @@ -36,26 +36,26 @@ public: m_params(p) { } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(card2bv_tactic, m, m_params); } - virtual ~card2bv_tactic() { + ~card2bv_tactic() override { } - 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { TRACE("card2bv-before", g->display(tout);); SASSERT(g->is_well_sorted()); mc = 0; pc = 0; core = 0; result.reset(); @@ -101,7 +101,7 @@ public: SASSERT(g->is_well_sorted()); } - virtual void cleanup() { + void cleanup() override { } }; diff --git a/src/tactic/arith/degree_shift_tactic.cpp b/src/tactic/arith/degree_shift_tactic.cpp index 6344c4c51..778a73ba5 100644 --- a/src/tactic/arith/degree_shift_tactic.cpp +++ b/src/tactic/arith/degree_shift_tactic.cpp @@ -297,23 +297,23 @@ public: m_imp = alloc(imp, m); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(degree_shift_tactic, m); } - virtual ~degree_shift_tactic() { + ~degree_shift_tactic() override { dealloc(m_imp); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/arith/diff_neq_tactic.cpp b/src/tactic/arith/diff_neq_tactic.cpp index c66483750..90dcf099c 100644 --- a/src/tactic/arith/diff_neq_tactic.cpp +++ b/src/tactic/arith/diff_neq_tactic.cpp @@ -354,28 +354,28 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(diff_neq_tactic, m, m_params); } - virtual ~diff_neq_tactic() { + ~diff_neq_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 { r.insert("diff_neq_max_k", CPK_UINT, "(default: 1024) maximum variable upper bound for diff neq solver."); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { st.update("conflicts", m_imp->m_num_conflicts); } - virtual void reset_statistics() { + void reset_statistics() override { m_imp->m_num_conflicts = 0; } @@ -383,15 +383,15 @@ public: \brief Fix a DL variable in s to 0. If s is not really in the difference logic fragment, then this is a NOOP. */ - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m, m_params); d->m_num_conflicts = m_imp->m_num_conflicts; std::swap(d, m_imp); diff --git a/src/tactic/arith/elim01_tactic.cpp b/src/tactic/arith/elim01_tactic.cpp index b6fd5eee7..7a923cf0a 100644 --- a/src/tactic/arith/elim01_tactic.cpp +++ b/src/tactic/arith/elim01_tactic.cpp @@ -41,7 +41,7 @@ public: m_refs(m) {} - virtual void operator()(model_ref & old_model, unsigned goal_idx) { + void operator()(model_ref & old_model, unsigned goal_idx) override { SASSERT(goal_idx == 0); model * new_model = alloc(model, m); unsigned num = old_model->get_num_constants(); @@ -106,7 +106,7 @@ public: } } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { bool2int_model_converter* mc = alloc(bool2int_model_converter, translator.to()); for (unsigned i = 0; i < m_nums_as_int.size(); ++i) { mc->insert(m_nums_as_int[i], m_nums_as_bool[i].size(), m_nums_as_bool[i].c_ptr()); @@ -134,24 +134,24 @@ public: m_max_hi(rational(m_max_hi_default)) { } - virtual ~elim01_tactic() { + ~elim01_tactic() override { } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_max_hi = rational(p.get_uint("max_coefficient", m_max_hi_default)); m_params = p; } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { r.insert("max_coefficient", CPK_UINT, "(default: 1) maximal upper bound for finite range -> Bool conversion"); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); mc = 0; pc = 0; core = 0; @@ -211,11 +211,11 @@ public: // TBD: support proof conversion (or not..) } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(elim01_tactic, m, m_params); } - virtual void cleanup() {} + void cleanup() override {} void add_variable(bool2int_model_converter* b2i, expr_safe_replace& sub, diff --git a/src/tactic/arith/eq2bv_tactic.cpp b/src/tactic/arith/eq2bv_tactic.cpp index 255665b56..1219b980e 100644 --- a/src/tactic/arith/eq2bv_tactic.cpp +++ b/src/tactic/arith/eq2bv_tactic.cpp @@ -82,7 +82,7 @@ class eq2bv_tactic : public tactic { m_map.insert(c_new, c_old); } - virtual void operator()(model_ref& mdl) { + void operator()(model_ref& mdl) override { ast_manager& m = mdl->get_manager(); bv_util bv(m); arith_util a(m); @@ -105,7 +105,7 @@ class eq2bv_tactic : public tactic { mdl = new_m; } - virtual model_converter* translate(ast_translation & translator) { + model_converter* translate(ast_translation & translator) override { bvmc* v = alloc(bvmc); obj_map::iterator it = m_map.begin(), end = m_map.end(); for (; it != end; ++it) { @@ -136,19 +136,18 @@ public: m_bounds(m) { } - virtual ~eq2bv_tactic() { + ~eq2bv_tactic() override { } - void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { } - virtual void operator()( - goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); mc = 0; pc = 0; core = 0; m_trail.reset(); @@ -213,14 +212,14 @@ public: } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(eq2bv_tactic, m); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { } - virtual void cleanup() { + void cleanup() override { } void cleanup_fd(ref& mc) { diff --git a/src/tactic/arith/factor_tactic.cpp b/src/tactic/arith/factor_tactic.cpp index d187c0078..ed49e11f7 100644 --- a/src/tactic/arith/factor_tactic.cpp +++ b/src/tactic/arith/factor_tactic.cpp @@ -293,30 +293,30 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(factor_tactic, m, m_params); } - virtual ~factor_tactic() { + ~factor_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 { r.insert("split_factors", CPK_BOOL, "(default: true) apply simplifications such as (= (* p1 p2) 0) --> (or (= p1 0) (= p2 0))."); polynomial::factor_params::get_param_descrs(r); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { (*m_imp)(in, result, mc, pc, core); } @@ -328,7 +328,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m, m_params); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/arith/fix_dl_var_tactic.cpp b/src/tactic/arith/fix_dl_var_tactic.cpp index 2c25c12e1..0e0a15ba6 100644 --- a/src/tactic/arith/fix_dl_var_tactic.cpp +++ b/src/tactic/arith/fix_dl_var_tactic.cpp @@ -303,28 +303,28 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(fix_dl_var_tactic, m, m_params); } - virtual ~fix_dl_var_tactic() { + ~fix_dl_var_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); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { (*m_imp)(in, result, mc, pc, core); } @@ -333,7 +333,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m, m_params); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/arith/fm_tactic.cpp b/src/tactic/arith/fm_tactic.cpp index 48f584169..9a27d6874 100644 --- a/src/tactic/arith/fm_tactic.cpp +++ b/src/tactic/arith/fm_tactic.cpp @@ -164,7 +164,7 @@ class fm_tactic : public tactic { public: fm_model_converter(ast_manager & _m):m(_m) {} - virtual ~fm_model_converter() { + ~fm_model_converter() override { m.dec_array_ref(m_xs.size(), m_xs.c_ptr()); vector::iterator it = m_clauses.begin(); vector::iterator end = m_clauses.end(); @@ -180,7 +180,7 @@ class fm_tactic : public tactic { m_clauses.back().swap(c); } - virtual void operator()(model_ref & md, unsigned goal_idx) { + void operator()(model_ref & md, unsigned goal_idx) override { TRACE("fm_mc", model_v2_pp(tout, *md); display(tout);); model_evaluator ev(*(md.get())); ev.set_model_completion(true); @@ -244,7 +244,7 @@ class fm_tactic : public tactic { } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { out << "(fm-model-converter"; SASSERT(m_xs.size() == m_clauses.size()); unsigned sz = m_xs.size(); @@ -261,7 +261,7 @@ class fm_tactic : public tactic { out << ")\n"; } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { ast_manager & to_m = translator.to(); fm_model_converter * res = alloc(fm_model_converter, to_m); unsigned sz = m_xs.size(); @@ -1643,20 +1643,20 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(fm_tactic, m, m_params); } - virtual ~fm_tactic() { + ~fm_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_produce_models(r); insert_max_memory(r); r.insert("fm_real_only", CPK_BOOL, "(default: true) consider only real variables for fourier-motzkin elimination."); @@ -1668,17 +1668,17 @@ public: } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m, m_params); std::swap(d, m_imp); dealloc(d); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } }; diff --git a/src/tactic/arith/lia2card_tactic.cpp b/src/tactic/arith/lia2card_tactic.cpp index ec41f5845..8b95d0781 100644 --- a/src/tactic/arith/lia2card_tactic.cpp +++ b/src/tactic/arith/lia2card_tactic.cpp @@ -148,21 +148,21 @@ public: m_compile_equality(false) { } - virtual ~lia2card_tactic() { + ~lia2card_tactic() override { dealloc(m_todo); dealloc(m_01s); } - void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_params = p; m_compile_equality = p.get_bool("compile_equality", false); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); mc = 0; pc = 0; core = 0; m_01s->reset(); @@ -389,16 +389,16 @@ public: } } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(lia2card_tactic, m, m_params); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { r.insert("compile_equality", CPK_BOOL, "(default:false) compile equalities into pseudo-Boolean equality"); } - virtual void cleanup() { + void cleanup() override { expr_set* d = alloc(expr_set); ptr_vector* todo = alloc(ptr_vector); std::swap(m_01s, d); diff --git a/src/tactic/arith/lia2pb_tactic.cpp b/src/tactic/arith/lia2pb_tactic.cpp index d303463db..ce21aa824 100644 --- a/src/tactic/arith/lia2pb_tactic.cpp +++ b/src/tactic/arith/lia2pb_tactic.cpp @@ -313,30 +313,30 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(lia2pb_tactic, m, m_params); } - virtual ~lia2pb_tactic() { + ~lia2pb_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 { r.insert("lia2pb_partial", CPK_BOOL, "(default: false) partial lia2pb conversion."); r.insert("lia2pb_max_bits", CPK_UINT, "(default: 32) maximum number of bits to be used (per variable) in lia2pb."); r.insert("lia2pb_total_bits", CPK_UINT, "(default: 2048) total number of bits to be used (per problem) in lia2pb."); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { (*m_imp)(in, result, mc, pc, core); } @@ -345,7 +345,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m, m_params); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/arith/nla2bv_tactic.cpp b/src/tactic/arith/nla2bv_tactic.cpp index 6f5f49aee..08eb97c4b 100644 --- a/src/tactic/arith/nla2bv_tactic.cpp +++ b/src/tactic/arith/nla2bv_tactic.cpp @@ -418,18 +418,18 @@ public: m_imp(0) { } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(nla2bv_tactic, m_params); } - virtual ~nla2bv_tactic() { + ~nla2bv_tactic() override { } - 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 { r.insert("nla2bv_max_bv_size", CPK_UINT, "(default: inf) maximum bit-vector size used by nla2bv tactic"); r.insert("nla2bv_bv_size", CPK_UINT, "(default: 4) default bit-vector size used by nla2bv tactic."); r.insert("nla2bv_root", CPK_UINT, "(default: 2) nla2bv tactic encodes reals into bit-vectors using expressions of the form a+b*sqrt(c), this parameter sets the value of c used in the encoding."); @@ -441,11 +441,11 @@ public: arithmetic in place of non-linear integer arithmetic. \return false if transformation is not possible. */ - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); fail_if_proof_generation("nla2bv", g); fail_if_unsat_core_generation("nla2bv", g); @@ -459,7 +459,7 @@ public: SASSERT(g->is_well_sorted()); } - virtual void cleanup(void) { + void cleanup(void) override { } }; diff --git a/src/tactic/arith/normalize_bounds_tactic.cpp b/src/tactic/arith/normalize_bounds_tactic.cpp index 2b3ff5ab0..a9eeb3744 100644 --- a/src/tactic/arith/normalize_bounds_tactic.cpp +++ b/src/tactic/arith/normalize_bounds_tactic.cpp @@ -156,28 +156,28 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(normalize_bounds_tactic, m, m_params); } - virtual ~normalize_bounds_tactic() { + ~normalize_bounds_tactic() override { dealloc(m_imp); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_imp->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { insert_produce_models(r); r.insert("norm_int_only", CPK_BOOL, "(default: true) normalize only the bounds of integer constants."); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { (*m_imp)(in, result, mc, pc, core); } @@ -186,7 +186,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; imp * d = alloc(imp, m, m_params); std::swap(d, m_imp); diff --git a/src/tactic/arith/pb2bv_model_converter.h b/src/tactic/arith/pb2bv_model_converter.h index 0c2826573..7e181b7dc 100644 --- a/src/tactic/arith/pb2bv_model_converter.h +++ b/src/tactic/arith/pb2bv_model_converter.h @@ -30,11 +30,11 @@ class pb2bv_model_converter : public model_converter { public: pb2bv_model_converter(ast_manager & _m); pb2bv_model_converter(ast_manager & _m, obj_map const & c2bit, bound_manager const & bm); - virtual ~pb2bv_model_converter(); - virtual void operator()(model_ref & md); - virtual void operator()(model_ref & md, unsigned goal_idx); - virtual void display(std::ostream & out); - virtual model_converter * translate(ast_translation & translator); + ~pb2bv_model_converter() override; + void operator()(model_ref & md) override; + void operator()(model_ref & md, unsigned goal_idx) override; + void display(std::ostream & out) override; + model_converter * translate(ast_translation & translator) override; }; #endif diff --git a/src/tactic/arith/pb2bv_tactic.cpp b/src/tactic/arith/pb2bv_tactic.cpp index 259cbc0c8..05b91cf53 100644 --- a/src/tactic/arith/pb2bv_tactic.cpp +++ b/src/tactic/arith/pb2bv_tactic.cpp @@ -983,32 +983,32 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(pb2bv_tactic, m, m_params); } - virtual ~pb2bv_tactic() { + ~pb2bv_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 { m_imp->collect_param_descrs(r); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; imp * d = alloc(imp, m, m_params); std::swap(d, m_imp); @@ -1023,7 +1023,7 @@ tactic * mk_pb2bv_tactic(ast_manager & m, params_ref const & p) { } struct is_pb_probe : public probe { - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { try { ast_manager & m = g.m(); bound_manager bm(m); diff --git a/src/tactic/arith/probe_arith.cpp b/src/tactic/arith/probe_arith.cpp index edd4483e7..36ee89a1b 100644 --- a/src/tactic/arith/probe_arith.cpp +++ b/src/tactic/arith/probe_arith.cpp @@ -74,7 +74,7 @@ class arith_degree_probe : public probe { public: arith_degree_probe(bool avg):m_avg(avg) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { proc p(g.m()); for_each_expr_at(p, g); if (m_avg) @@ -117,7 +117,7 @@ class arith_bw_probe : public probe { public: arith_bw_probe(bool avg):m_avg(avg) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { proc p(g.m()); for_each_expr_at(p, g); if (m_avg) @@ -269,14 +269,14 @@ static bool is_qfauflia(goal const & g) { class is_qflia_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_qflia(g); } }; class is_qfauflia_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_qfauflia(g); } }; @@ -288,7 +288,7 @@ static bool is_qflra(goal const & g) { class is_qflra_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_qflra(g); } }; @@ -300,7 +300,7 @@ static bool is_qflira(goal const & g) { class is_qflira_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_qflira(g); } }; @@ -344,14 +344,14 @@ static bool is_mip(goal const & g) { class is_ilp_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_ilp(g); } }; class is_mip_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_mip(g); } }; @@ -583,56 +583,56 @@ struct is_non_qfufnra_functor { class is_qfnia_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_qfnia(g); } }; class is_qfnra_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_qfnra(g); } }; class is_nia_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_nia(g); } }; class is_nra_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_nra(g); } }; class is_nira_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_nira(g); } }; class is_lia_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_lia(g); } }; class is_lra_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_lra(g); } }; class is_lira_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_lira(g); } }; @@ -644,7 +644,7 @@ static bool is_qfufnra(goal const& g) { class is_qfufnra_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return is_qfufnra(g); } }; diff --git a/src/tactic/arith/propagate_ineqs_tactic.cpp b/src/tactic/arith/propagate_ineqs_tactic.cpp index d7209740f..cbb29f6b4 100644 --- a/src/tactic/arith/propagate_ineqs_tactic.cpp +++ b/src/tactic/arith/propagate_ineqs_tactic.cpp @@ -43,18 +43,18 @@ class propagate_ineqs_tactic : public tactic { public: propagate_ineqs_tactic(ast_manager & m, params_ref const & p); - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(propagate_ineqs_tactic, m, m_params); } - virtual ~propagate_ineqs_tactic(); + ~propagate_ineqs_tactic() override; - 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 & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core); + void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override; - virtual void cleanup(); + void cleanup() override; }; tactic * mk_propagate_ineqs_tactic(ast_manager & m, params_ref const & p) { diff --git a/src/tactic/arith/purify_arith_tactic.cpp b/src/tactic/arith/purify_arith_tactic.cpp index 7e89794ce..38ea0a2b9 100644 --- a/src/tactic/arith/purify_arith_tactic.cpp +++ b/src/tactic/arith/purify_arith_tactic.cpp @@ -802,18 +802,18 @@ public: m_params(p) { } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(purify_arith_tactic, m, m_params); } - virtual ~purify_arith_tactic() { + ~purify_arith_tactic() override { } - 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 { r.insert("complete", CPK_BOOL, "(default: true) add constraints to make sure that any interpretation of a underspecified arithmetic operators is a function. The result will include additional uninterpreted functions/constants: /0, div0, mod0, 0^0, neg-root"); r.insert("elim_root_objects", CPK_BOOL, @@ -823,11 +823,11 @@ public: th_rewriter::get_param_descrs(r); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { SASSERT(g->is_well_sorted()); mc = 0; pc = 0; core = 0; @@ -852,7 +852,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { } }; diff --git a/src/tactic/arith/recover_01_tactic.cpp b/src/tactic/arith/recover_01_tactic.cpp index d3b9ecc3e..cf2beacb2 100644 --- a/src/tactic/arith/recover_01_tactic.cpp +++ b/src/tactic/arith/recover_01_tactic.cpp @@ -390,29 +390,29 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(recover_01_tactic, m, m_params); } - virtual ~recover_01_tactic() { + ~recover_01_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("recover_01_max_bits", CPK_UINT, "(default: 10) maximum number of bits to consider in a clause."); } - void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + expr_dependency_ref & core) override { try { (*m_imp)(g, result, mc, pc, core); } @@ -421,7 +421,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m, m_params); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/bv/bit_blaster_model_converter.cpp b/src/tactic/bv/bit_blaster_model_converter.cpp index 373cf3113..2a1ddcd4a 100644 --- a/src/tactic/bv/bit_blaster_model_converter.cpp +++ b/src/tactic/bv/bit_blaster_model_converter.cpp @@ -46,7 +46,7 @@ struct bit_blaster_model_converter : public model_converter { } } - virtual ~bit_blaster_model_converter() { + ~bit_blaster_model_converter() override { } void collect_bits(obj_hashtable & bits) { @@ -142,7 +142,7 @@ struct bit_blaster_model_converter : public model_converter { } } - virtual void operator()(model_ref & md, unsigned goal_idx) { + void operator()(model_ref & md, unsigned goal_idx) override { SASSERT(goal_idx == 0); model * new_model = alloc(model, m()); obj_hashtable bits; @@ -152,11 +152,11 @@ struct bit_blaster_model_converter : public model_converter { md = new_model; } - virtual void operator()(model_ref & md) { + void operator()(model_ref & md) override { operator()(md, 0); } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { out << "(bit-blaster-model-converter"; unsigned sz = m_vars.size(); for (unsigned i = 0; i < sz; i++) { @@ -171,7 +171,7 @@ protected: bit_blaster_model_converter(ast_manager & m):m_vars(m), m_bits(m) { } public: - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { bit_blaster_model_converter * res = alloc(bit_blaster_model_converter, translator.to()); for (unsigned i = 0; i < m_vars.size(); i++) res->m_vars.push_back(translator(m_vars[i].get())); diff --git a/src/tactic/bv/bit_blaster_tactic.cpp b/src/tactic/bv/bit_blaster_tactic.cpp index 5c6c43778..a44f32044 100644 --- a/src/tactic/bv/bit_blaster_tactic.cpp +++ b/src/tactic/bv/bit_blaster_tactic.cpp @@ -111,21 +111,21 @@ public: m_imp = alloc(imp, m, m_rewriter, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { SASSERT(!m_rewriter); // assume translation isn't used where rewriter is external. return alloc(bit_blaster_tactic, m, 0, m_params); } - virtual ~bit_blaster_tactic() { + ~bit_blaster_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); r.insert("blast_mul", CPK_BOOL, "(default: true) bit-blast multipliers (and dividers, remainders)."); @@ -134,11 +134,11 @@ public: r.insert("blast_full", CPK_BOOL, "(default: false) bit-blast any term with bit-vector sort, this option will make E-matching ineffective in any pattern containing bit-vector terms."); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { (*m_imp)(g, result, mc, pc, core); } @@ -147,7 +147,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m(), m_rewriter, m_params); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/bv/bv1_blaster_tactic.cpp b/src/tactic/bv/bv1_blaster_tactic.cpp index e7e374184..196835c51 100644 --- a/src/tactic/bv/bv1_blaster_tactic.cpp +++ b/src/tactic/bv/bv1_blaster_tactic.cpp @@ -426,20 +426,20 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(bv1_blaster_tactic, m, m_params); } - virtual ~bv1_blaster_tactic() { + ~bv1_blaster_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); } @@ -454,15 +454,15 @@ public: It also does not support quantifiers. Return a model_converter that converts any model for the updated set into a model for the old set. */ - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(g, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m(), m_params); std::swap(d, m_imp); dealloc(d); @@ -480,7 +480,7 @@ tactic * mk_bv1_blaster_tactic(ast_manager & m, params_ref const & p) { class is_qfbv_eq_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { bv1_blaster_tactic t(g.m()); return t.is_target(g); diff --git a/src/tactic/bv/bv_bound_chk_tactic.cpp b/src/tactic/bv/bv_bound_chk_tactic.cpp index b71b44bd0..2d717c0ae 100644 --- a/src/tactic/bv/bv_bound_chk_tactic.cpp +++ b/src/tactic/bv/bv_bound_chk_tactic.cpp @@ -111,7 +111,7 @@ struct bv_bound_chk_rewriter : public rewriter_tpl { updt_params(p); } - virtual ~bv_bound_chk_rewriter() {} + ~bv_bound_chk_rewriter() override {} void updt_params(params_ref const & _p) { m_cfg.updt_params(_p); @@ -135,17 +135,17 @@ class bv_bound_chk_tactic : public tactic { bv_bound_chk_stats m_stats; public: bv_bound_chk_tactic(ast_manager & m, params_ref const & p); - virtual ~bv_bound_chk_tactic(); + ~bv_bound_chk_tactic() override; void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core); - virtual tactic * translate(ast_manager & m); - virtual void updt_params(params_ref const & p); - void cleanup(); - void collect_statistics(statistics & st) const; - void reset_statistics(); + expr_dependency_ref & core) override; + tactic * translate(ast_manager & m) override; + void updt_params(params_ref const & p) override; + void cleanup() override; + void collect_statistics(statistics & st) const override; + void reset_statistics() override; }; class bv_bound_chk_tactic::imp { diff --git a/src/tactic/bv/bv_bounds_tactic.cpp b/src/tactic/bv/bv_bounds_tactic.cpp index a279e441b..0628b4013 100644 --- a/src/tactic/bv/bv_bounds_tactic.cpp +++ b/src/tactic/bv/bv_bounds_tactic.cpp @@ -305,7 +305,7 @@ namespace { updt_params(p); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_propagate_eq = p.get_bool("propagate_eq", false); } @@ -313,7 +313,7 @@ namespace { r.insert("propagate-eq", CPK_BOOL, "(default: false) propagate equalities from inequalities"); } - virtual ~bv_bounds_simplifier() { + ~bv_bounds_simplifier() override { for (unsigned i = 0, e = m_expr_vars.size(); i < e; ++i) { dealloc(m_expr_vars[i]); } @@ -322,7 +322,7 @@ namespace { } } - virtual bool assert_expr(expr * t, bool sign) { + bool assert_expr(expr * t, bool sign) override { while (m.is_not(t, t)) { sign = !sign; } @@ -353,7 +353,7 @@ namespace { return true; } - virtual bool simplify(expr* t, expr_ref& result) { + bool simplify(expr* t, expr_ref& result) override { expr* t1; interval b; @@ -465,7 +465,7 @@ namespace { return false; } - virtual bool may_simplify(expr* t) { + bool may_simplify(expr* t) override { if (m_bv.is_numeral(t)) return false; @@ -504,7 +504,7 @@ namespace { return false; } - virtual void pop(unsigned num_scopes) { + void pop(unsigned num_scopes) override { TRACE("bv", tout << "pop: " << num_scopes << "\n";); if (m_scopes.empty()) return; @@ -526,11 +526,11 @@ namespace { m_scopes.shrink(target); } - virtual simplifier * translate(ast_manager & m) { + simplifier * translate(ast_manager & m) override { return alloc(bv_bounds_simplifier, m, m_params); } - virtual unsigned scope_level() const { + unsigned scope_level() const override { return m_scopes.size(); } }; @@ -622,7 +622,7 @@ namespace { r.insert("propagate-eq", CPK_BOOL, "(default: false) propagate equalities from inequalities"); } - virtual ~dom_bv_bounds_simplifier() { + ~dom_bv_bounds_simplifier() override { for (unsigned i = 0, e = m_expr_vars.size(); i < e; ++i) { dealloc(m_expr_vars[i]); } @@ -631,7 +631,7 @@ namespace { } } - virtual bool assert_expr(expr * t, bool sign) { + bool assert_expr(expr * t, bool sign) override { while (m.is_not(t, t)) { sign = !sign; } @@ -662,7 +662,7 @@ namespace { return true; } - virtual void operator()(expr_ref& r) { + void operator()(expr_ref& r) override { expr* t1, * t = r; interval b; @@ -781,7 +781,7 @@ namespace { return false; } - virtual void pop(unsigned num_scopes) { + void pop(unsigned num_scopes) override { TRACE("bv", tout << "pop: " << num_scopes << "\n";); if (m_scopes.empty()) return; @@ -803,11 +803,11 @@ namespace { m_scopes.shrink(target); } - virtual dom_simplifier * translate(ast_manager & m) { + dom_simplifier * translate(ast_manager & m) override { return alloc(dom_bv_bounds_simplifier, m, m_params); } - virtual unsigned scope_level() const { + unsigned scope_level() const override { return m_scopes.size(); } diff --git a/src/tactic/bv/bv_size_reduction_tactic.cpp b/src/tactic/bv/bv_size_reduction_tactic.cpp index ec4c21fe8..2c70e554f 100644 --- a/src/tactic/bv/bv_size_reduction_tactic.cpp +++ b/src/tactic/bv/bv_size_reduction_tactic.cpp @@ -34,15 +34,15 @@ class bv_size_reduction_tactic : public tactic { public: bv_size_reduction_tactic(ast_manager & m); - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(bv_size_reduction_tactic, m); } - virtual ~bv_size_reduction_tactic(); + ~bv_size_reduction_tactic() override; - virtual void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core); + void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override; - virtual void cleanup(); + void cleanup() override; }; tactic * mk_bv_size_reduction_tactic(ast_manager & m, params_ref const & p) { diff --git a/src/tactic/bv/bvarray2uf_tactic.cpp b/src/tactic/bv/bvarray2uf_tactic.cpp index 87f43ae8d..844d64429 100644 --- a/src/tactic/bv/bvarray2uf_tactic.cpp +++ b/src/tactic/bv/bvarray2uf_tactic.cpp @@ -113,32 +113,32 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(bvarray2uf_tactic, m, m_params); } - virtual ~bvarray2uf_tactic() { + ~bvarray2uf_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_produce_models(r); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m(); imp * d = alloc(imp, m, m_params); std::swap(d, m_imp); diff --git a/src/tactic/bv/dt2bv_tactic.cpp b/src/tactic/bv/dt2bv_tactic.cpp index fe59480e7..62093d191 100644 --- a/src/tactic/bv/dt2bv_tactic.cpp +++ b/src/tactic/bv/dt2bv_tactic.cpp @@ -95,8 +95,8 @@ class dt2bv_tactic : public tactic { struct sort_pred : public i_sort_pred { dt2bv_tactic& m_t; sort_pred(dt2bv_tactic& t): m_t(t) {} - virtual ~sort_pred() {} - virtual bool operator()(sort* s) { + ~sort_pred() override {} + bool operator()(sort* s) override { return m_t.m_fd_sorts.contains(s); } }; @@ -107,21 +107,21 @@ public: dt2bv_tactic(ast_manager& m, params_ref const& p): m(m), m_params(p), m_dt(m), m_bv(m), m_is_fd(*this) {} - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(dt2bv_tactic, m, m_params); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { } - 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { mc = 0; pc = 0; core = 0; bool produce_proofs = g->proofs_enabled(); tactic_report report("dt2bv", *g); @@ -177,7 +177,7 @@ public: SASSERT(g->is_well_sorted()); } - virtual void cleanup() { + void cleanup() override { m_fd_sorts.reset(); m_non_fd_sorts.reset(); } diff --git a/src/tactic/bv/elim_small_bv_tactic.cpp b/src/tactic/bv/elim_small_bv_tactic.cpp index ab4b3920d..f5f0c2b88 100644 --- a/src/tactic/bv/elim_small_bv_tactic.cpp +++ b/src/tactic/bv/elim_small_bv_tactic.cpp @@ -268,34 +268,34 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(elim_small_bv_tactic, m, m_params); } - virtual ~elim_small_bv_tactic() { + ~elim_small_bv_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_bits", CPK_UINT, "(default: 4) maximum bit-vector size of quantified bit-vectors to be eliminated."); } - virtual void operator()(goal_ref const & in, + void operator()(goal_ref const & in, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; m_imp->~imp(); m_imp = new (m_imp) imp(m, m_params); diff --git a/src/tactic/bv/max_bv_sharing_tactic.cpp b/src/tactic/bv/max_bv_sharing_tactic.cpp index becaed276..0b7d0d345 100644 --- a/src/tactic/bv/max_bv_sharing_tactic.cpp +++ b/src/tactic/bv/max_bv_sharing_tactic.cpp @@ -278,35 +278,35 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(max_bv_sharing_tactic, m, m_params); } - virtual ~max_bv_sharing_tactic() { + ~max_bv_sharing_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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m(); params_ref p = std::move(m_params); m_imp->~imp(); diff --git a/src/tactic/converter.h b/src/tactic/converter.h index 9de8218c3..924971d27 100644 --- a/src/tactic/converter.h +++ b/src/tactic/converter.h @@ -58,16 +58,16 @@ protected: public: concat_converter(T * c1, T * c2):m_c1(c1), m_c2(c2) {} - virtual ~concat_converter() {} + ~concat_converter() override {} - virtual void cancel() { + void cancel() override { m_c2->cancel(); m_c1->cancel(); } virtual char const * get_name() const = 0; - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { out << "(" << get_name() << "\n"; m_c1->display(out); m_c2->display(out); @@ -104,7 +104,7 @@ public: } } - virtual ~concat_star_converter() { + ~concat_star_converter() override { unsigned sz = m_c2s.size(); for (unsigned i = 0; i < sz; i++) { T * c2 = m_c2s[i]; @@ -113,7 +113,7 @@ public: } } - virtual void cancel() { + void cancel() override { if (m_c1) m_c1->cancel(); unsigned num = m_c2s.size(); @@ -125,7 +125,7 @@ public: virtual char const * get_name() const = 0; - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { out << "(" << get_name() << "\n"; if (m_c1) m_c1->display(out); diff --git a/src/tactic/core/blast_term_ite_tactic.cpp b/src/tactic/core/blast_term_ite_tactic.cpp index ae0ea019b..27d907b63 100644 --- a/src/tactic/core/blast_term_ite_tactic.cpp +++ b/src/tactic/core/blast_term_ite_tactic.cpp @@ -152,35 +152,35 @@ 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; dealloc(m_imp); m_imp = alloc(imp, m, m_params); diff --git a/src/tactic/core/cofactor_term_ite_tactic.cpp b/src/tactic/core/cofactor_term_ite_tactic.cpp index 65cdef147..64c2c0f66 100644 --- a/src/tactic/core/cofactor_term_ite_tactic.cpp +++ b/src/tactic/core/cofactor_term_ite_tactic.cpp @@ -46,19 +46,19 @@ 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); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); fail_if_proof_generation("cofactor-term-ite", g); fail_if_unsat_core_generation("cofactor-term-ite", g); @@ -71,7 +71,7 @@ public: SASSERT(g->is_well_sorted()); } - virtual void cleanup() { return m_elim_ite.cleanup(); } + void cleanup() override { return m_elim_ite.cleanup(); } }; diff --git a/src/tactic/core/collect_statistics_tactic.cpp b/src/tactic/core/collect_statistics_tactic.cpp index 26f6842e3..166fb6036 100644 --- a/src/tactic/core/collect_statistics_tactic.cpp +++ b/src/tactic/core/collect_statistics_tactic.cpp @@ -51,21 +51,21 @@ 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, - model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, goal_ref_buffer & result, + model_converter_ref & mc, proof_converter_ref & pc, + expr_dependency_ref & core) override { mc = 0; tactic_report report("collect-statistics", *g); @@ -86,13 +86,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 { diff --git a/src/tactic/core/ctx_simplify_tactic.cpp b/src/tactic/core/ctx_simplify_tactic.cpp index 5bb54073d..89bdcca1c 100644 --- a/src/tactic/core/ctx_simplify_tactic.cpp +++ b/src/tactic/core/ctx_simplify_tactic.cpp @@ -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; }; diff --git a/src/tactic/core/ctx_simplify_tactic.h b/src/tactic/core/ctx_simplify_tactic.h index 9efa7e7db..e84a5fccc 100644 --- a/src/tactic/core/ctx_simplify_tactic.h +++ b/src/tactic/core/ctx_simplify_tactic.h @@ -46,21 +46,21 @@ 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core); + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override; - virtual void cleanup(); + void cleanup() override; }; tactic * mk_ctx_simplify_tactic(ast_manager & m, params_ref const & p = params_ref()); diff --git a/src/tactic/core/der_tactic.cpp b/src/tactic/core/der_tactic.cpp index 5df009969..d4c20a065 100644 --- a/src/tactic/core/der_tactic.cpp +++ b/src/tactic/core/der_tactic.cpp @@ -65,26 +65,26 @@ 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { mc = 0; pc = 0; core = 0; (*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); diff --git a/src/tactic/core/distribute_forall_tactic.cpp b/src/tactic/core/distribute_forall_tactic.cpp index 3ee2697c4..9a5ef0c48 100644 --- a/src/tactic/core/distribute_forall_tactic.cpp +++ b/src/tactic/core/distribute_forall_tactic.cpp @@ -95,15 +95,15 @@ class distribute_forall_tactic : public tactic { public: distribute_forall_tactic():m_rw(0) {} - 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); ast_manager & m = g->m(); bool produce_proofs = g->proofs_enabled(); @@ -134,7 +134,7 @@ public: m_rw = 0; } - virtual void cleanup() {} + void cleanup() override {} }; tactic * mk_distribute_forall_tactic(ast_manager & m, params_ref const & p) { diff --git a/src/tactic/core/dom_simplify_tactic.h b/src/tactic/core/dom_simplify_tactic.h index 56eea8d9a..2b114bb71 100644 --- a/src/tactic/core/dom_simplify_tactic.h +++ b/src/tactic/core/dom_simplify_tactic.h @@ -130,20 +130,20 @@ public: m_dominators(m), m_depth(0), m_max_depth(1024), m_forward(true) {} - virtual ~dom_simplify_tactic(); + ~dom_simplify_tactic() override; - virtual tactic * translate(ast_manager & m); - virtual void updt_params(params_ref const & p) {} + tactic * translate(ast_manager & m) override; + 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core); + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override; - virtual void cleanup(); + void cleanup() override; }; class expr_substitution_simplifier : public dom_simplifier { @@ -160,18 +160,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); } diff --git a/src/tactic/core/elim_term_ite_tactic.cpp b/src/tactic/core/elim_term_ite_tactic.cpp index 79526a101..522aa90c6 100644 --- a/src/tactic/core/elim_term_ite_tactic.cpp +++ b/src/tactic/core/elim_term_ite_tactic.cpp @@ -141,35 +141,35 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(elim_term_ite_tactic, m, m_params); } - virtual ~elim_term_ite_tactic() { + ~elim_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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; m_imp->~imp(); m_imp = new (m_imp) imp(m, m_params); diff --git a/src/tactic/core/elim_uncnstr_tactic.cpp b/src/tactic/core/elim_uncnstr_tactic.cpp index 6a38f787e..a702ab18f 100644 --- a/src/tactic/core/elim_uncnstr_tactic.cpp +++ b/src/tactic/core/elim_uncnstr_tactic.cpp @@ -915,34 +915,34 @@ 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(g, result, mc, pc, core); 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); @@ -955,11 +955,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; } diff --git a/src/tactic/core/injectivity_tactic.cpp b/src/tactic/core/injectivity_tactic.cpp index 7d90a2155..e4c6408bd 100644 --- a/src/tactic/core/injectivity_tactic.cpp +++ b/src/tactic/core/injectivity_tactic.cpp @@ -250,31 +250,31 @@ 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_finder)(g, result, mc, pc, core); for (unsigned i = 0; i < g->size(); ++i) { @@ -287,7 +287,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); diff --git a/src/tactic/core/nnf_tactic.cpp b/src/tactic/core/nnf_tactic.cpp index 6b360e711..1f2454d5e 100644 --- a/src/tactic/core/nnf_tactic.cpp +++ b/src/tactic/core/nnf_tactic.cpp @@ -43,21 +43,21 @@ public: 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { TRACE("nnf", tout << "params: " << m_params << "\n"; g->display(tout);); SASSERT(g->is_well_sorted()); mc = 0; pc = 0; core = 0; @@ -106,7 +106,7 @@ public: SASSERT(g->is_well_sorted()); } - virtual void cleanup() {} + void cleanup() override {} }; tactic * mk_snf_tactic(ast_manager & m, params_ref const & p) { diff --git a/src/tactic/core/occf_tactic.cpp b/src/tactic/core/occf_tactic.cpp index 254f8166c..69e5e8fb2 100644 --- a/src/tactic/core/occf_tactic.cpp +++ b/src/tactic/core/occf_tactic.cpp @@ -199,26 +199,26 @@ 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/core/pb_preprocess_tactic.cpp b/src/tactic/core/pb_preprocess_tactic.cpp index 6a0d7205b..5f128d378 100644 --- a/src/tactic/core/pb_preprocess_tactic.cpp +++ b/src/tactic/core/pb_preprocess_tactic.cpp @@ -48,7 +48,7 @@ class pb_preproc_model_converter : public model_converter { public: pb_preproc_model_converter(ast_manager& m):m(m), pb(m), m_refs(m) {} - virtual void operator()(model_ref & mdl, unsigned goal_idx) { + void operator()(model_ref & mdl, unsigned goal_idx) override { SASSERT(goal_idx == 0); for (unsigned i = 0; i < m_const.size(); ++i) { mdl->register_decl(m_const[i].first->get_decl(), m_const[i].second); @@ -63,7 +63,7 @@ public: set_value_p(to_app(e), p?m.mk_true():m.mk_false()); } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { pb_preproc_model_converter* mc = alloc(pb_preproc_model_converter, translator.to()); for (unsigned i = 0; i < m_const.size(); ++i) { mc->set_value_p(translator(m_const[i].first), translator(m_const[i].second)); @@ -136,18 +136,17 @@ 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); } - virtual void operator()( - goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); pc = 0; core = 0; @@ -262,15 +261,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(); diff --git a/src/tactic/core/propagate_values_tactic.cpp b/src/tactic/core/propagate_values_tactic.cpp index 607ecbd79..39333226b 100644 --- a/src/tactic/core/propagate_values_tactic.cpp +++ b/src/tactic/core/propagate_values_tactic.cpp @@ -222,29 +222,29 @@ 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."); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { (*m_imp)(in, result, mc, pc, core); } @@ -253,7 +253,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; params_ref p = std::move(m_params); m_imp->~imp(); diff --git a/src/tactic/core/reduce_args_tactic.cpp b/src/tactic/core/reduce_args_tactic.cpp index 476c21232..a7aadedbe 100644 --- a/src/tactic/core/reduce_args_tactic.cpp +++ b/src/tactic/core/reduce_args_tactic.cpp @@ -68,14 +68,14 @@ 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; - virtual void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core); - virtual void cleanup(); + void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override; + void cleanup() override; }; tactic * mk_reduce_args_tactic(ast_manager & m, params_ref const & p) { diff --git a/src/tactic/core/simplify_tactic.h b/src/tactic/core/simplify_tactic.h index 1e8420c62..c780ceabd 100644 --- a/src/tactic/core/simplify_tactic.h +++ b/src/tactic/core/simplify_tactic.h @@ -28,23 +28,23 @@ 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; - 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core); - - virtual void cleanup(); + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override; + + void cleanup() override; unsigned get_num_steps() const; - virtual tactic * translate(ast_manager & m) { return alloc(simplify_tactic, m, m_params); } + tactic * translate(ast_manager & m) override { return alloc(simplify_tactic, m, m_params); } }; diff --git a/src/tactic/core/solve_eqs_tactic.cpp b/src/tactic/core/solve_eqs_tactic.cpp index 5df523ff7..a6346185f 100644 --- a/src/tactic/core/solve_eqs_tactic.cpp +++ b/src/tactic/core/solve_eqs_tactic.cpp @@ -790,35 +790,35 @@ public: m_imp = alloc(imp, m, p, r, owner); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { 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); } - 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 { r.insert("solve_eqs_max_occs", CPK_UINT, "(default: infty) maximum number of occurrences for considering a variable for gaussian eliminations."); r.insert("theory_solver", CPK_BOOL, "(default: true) use theory solvers."); r.insert("ite_solver", CPK_BOOL, "(default: true) use if-then-else solver."); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); report_tactic_progress(":num-elim-vars", m_imp->get_num_eliminated_vars()); } - virtual void cleanup() { + void cleanup() override { unsigned num_elim_vars = m_imp->m_num_eliminated_vars; ast_manager & m = m_imp->m(); expr_replacer * r = m_imp->m_r; @@ -833,11 +833,11 @@ public: dealloc(d); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { st.update("eliminated vars", m_imp->get_num_eliminated_vars()); } - virtual void reset_statistics() { + void reset_statistics() override { m_imp->m_num_eliminated_vars = 0; } diff --git a/src/tactic/core/split_clause_tactic.cpp b/src/tactic/core/split_clause_tactic.cpp index 7a2df81b5..5986ca392 100644 --- a/src/tactic/core/split_clause_tactic.cpp +++ b/src/tactic/core/split_clause_tactic.cpp @@ -55,12 +55,12 @@ class split_clause_tactic : public tactic { m.inc_ref(pr); } - ~split_pc() { + ~split_pc() override { m_manager.dec_ref(m_clause); m_manager.dec_ref(m_clause_pr); } - virtual void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) { + void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) override { // Let m_clause be of the form (l_0 or ... or l_{num_source - 1}) // Each source[i] proof is a proof for "false" using l_i as a hypothesis // So, I use lemma for producing a proof for (not l_i) that does not contain the hypothesis, @@ -76,7 +76,7 @@ class split_clause_tactic : public tactic { result = m.mk_unit_resolution(prs.size(), prs.c_ptr()); } - virtual proof_converter * translate(ast_translation & translator) { + proof_converter * translate(ast_translation & translator) override { return alloc(split_pc, translator.to(), translator(m_clause), translator(m_clause_pr)); } }; @@ -86,28 +86,28 @@ 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 { } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_largest_clause = p.get_bool("split_largest_clause", false); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { r.insert("split_largest_clause", CPK_BOOL, "(default: false) split the largest clause in the goal."); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { SASSERT(in->is_well_sorted()); tactic_report report("split-clause", *in); TRACE("before_split_clause", in->display(tout);); @@ -140,7 +140,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { // do nothing this tactic is too simple } }; diff --git a/src/tactic/core/symmetry_reduce_tactic.cpp b/src/tactic/core/symmetry_reduce_tactic.cpp index 8e87a6741..1bc3fde60 100644 --- a/src/tactic/core/symmetry_reduce_tactic.cpp +++ b/src/tactic/core/symmetry_reduce_tactic.cpp @@ -32,18 +32,18 @@ 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core); - virtual void cleanup(); + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override; + void cleanup() override; }; class ac_rewriter { diff --git a/src/tactic/core/tseitin_cnf_tactic.cpp b/src/tactic/core/tseitin_cnf_tactic.cpp index dbfc748b0..af0143488 100644 --- a/src/tactic/core/tseitin_cnf_tactic.cpp +++ b/src/tactic/core/tseitin_cnf_tactic.cpp @@ -861,20 +861,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"); @@ -883,16 +883,16 @@ 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); 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; @@ -900,11 +900,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; } }; diff --git a/src/tactic/equiv_proof_converter.h b/src/tactic/equiv_proof_converter.h index 79f5142b2..12cd26215 100644 --- a/src/tactic/equiv_proof_converter.h +++ b/src/tactic/equiv_proof_converter.h @@ -33,13 +33,13 @@ public: equiv_proof_converter(ast_manager& m): m(m), m_replace(m) {} - virtual ~equiv_proof_converter() {} + ~equiv_proof_converter() override {} - virtual void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) { + void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) override { m_replace(m, num_source, source, result); } - virtual proof_converter * translate(ast_translation & translator) { + proof_converter * translate(ast_translation & translator) override { return m_replace.translate(translator); } diff --git a/src/tactic/extension_model_converter.h b/src/tactic/extension_model_converter.h index dbd7a7e3b..bc1a2699d 100644 --- a/src/tactic/extension_model_converter.h +++ b/src/tactic/extension_model_converter.h @@ -31,18 +31,18 @@ public: extension_model_converter(ast_manager & m):m_vars(m), m_defs(m) { } - virtual ~extension_model_converter(); + ~extension_model_converter() override; ast_manager & m() const { return m_vars.get_manager(); } - virtual void operator()(model_ref & md, unsigned goal_idx); + void operator()(model_ref & md, unsigned goal_idx) override; - virtual void display(std::ostream & out); + void display(std::ostream & out) override; // register a variable that was eliminated void insert(func_decl * v, expr * def); - virtual model_converter * translate(ast_translation & translator); + model_converter * translate(ast_translation & translator) override; }; diff --git a/src/tactic/filter_model_converter.h b/src/tactic/filter_model_converter.h index b5d6b86f4..012c43fb6 100644 --- a/src/tactic/filter_model_converter.h +++ b/src/tactic/filter_model_converter.h @@ -26,25 +26,25 @@ class filter_model_converter : public model_converter { public: filter_model_converter(ast_manager & m):m_decls(m) {} - virtual ~filter_model_converter(); + ~filter_model_converter() override; ast_manager & m() const { return m_decls.get_manager(); } - virtual void operator()(model_ref & md, unsigned goal_idx); + void operator()(model_ref & md, unsigned goal_idx) override; virtual void operator()(svector & labels, unsigned goal_idx); - virtual void operator()(model_ref & md) { operator()(md, 0); } // TODO: delete + void operator()(model_ref & md) override { operator()(md, 0); } // TODO: delete - virtual void cancel() {} + void cancel() override {} - virtual void display(std::ostream & out); + void display(std::ostream & out) override; void insert(func_decl * d) { m_decls.push_back(d); } - virtual model_converter * translate(ast_translation & translator); + model_converter * translate(ast_translation & translator) override; }; typedef ref filter_model_converter_ref; diff --git a/src/tactic/fpa/fpa2bv_model_converter.h b/src/tactic/fpa/fpa2bv_model_converter.h index 989caaa58..cf26f53db 100644 --- a/src/tactic/fpa/fpa2bv_model_converter.h +++ b/src/tactic/fpa/fpa2bv_model_converter.h @@ -33,24 +33,24 @@ public: m_bv2fp(alloc(bv2fpa_converter, m, conv)) { } - virtual ~fpa2bv_model_converter() { + ~fpa2bv_model_converter() override { dealloc(m_bv2fp); } - virtual void operator()(model_ref & md, unsigned goal_idx) { + void operator()(model_ref & md, unsigned goal_idx) override { SASSERT(goal_idx == 0); model * new_model = alloc(model, m); convert(md.get(), new_model); md = new_model; } - virtual void operator()(model_ref & md) { + void operator()(model_ref & md) override { operator()(md, 0); } - void display(std::ostream & out); + void display(std::ostream & out) override; - virtual model_converter * translate(ast_translation & translator); + model_converter * translate(ast_translation & translator) override; protected: fpa2bv_model_converter(ast_manager & m) : diff --git a/src/tactic/fpa/fpa2bv_tactic.cpp b/src/tactic/fpa/fpa2bv_tactic.cpp index 6d90b46ea..7cd4a404c 100644 --- a/src/tactic/fpa/fpa2bv_tactic.cpp +++ b/src/tactic/fpa/fpa2bv_tactic.cpp @@ -123,27 +123,27 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(fpa2bv_tactic, m, m_params); } - virtual ~fpa2bv_tactic() { + ~fpa2bv_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 { } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { (*m_imp)(in, result, mc, pc, core); } @@ -152,7 +152,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { imp * d = alloc(imp, m_imp->m, m_params); std::swap(d, m_imp); dealloc(d); diff --git a/src/tactic/fpa/qffp_tactic.cpp b/src/tactic/fpa/qffp_tactic.cpp index cdc363453..1c48fef38 100644 --- a/src/tactic/fpa/qffp_tactic.cpp +++ b/src/tactic/fpa/qffp_tactic.cpp @@ -66,10 +66,10 @@ struct is_non_fp_qfnra_predicate { class is_fp_qfnra_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return !test(g); } - virtual ~is_fp_qfnra_probe() {} + ~is_fp_qfnra_probe() override {} }; probe * mk_is_fp_qfnra_probe() { @@ -141,11 +141,11 @@ struct is_non_qffp_predicate { class is_qffp_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return !test(g); } - virtual ~is_qffp_probe() {} + ~is_qffp_probe() override {} }; probe * mk_is_qffp_probe() { diff --git a/src/tactic/horn_subsume_model_converter.h b/src/tactic/horn_subsume_model_converter.h index 1c1ae9feb..5b9c22f17 100644 --- a/src/tactic/horn_subsume_model_converter.h +++ b/src/tactic/horn_subsume_model_converter.h @@ -72,9 +72,9 @@ public: void insert(func_decl* p, expr* body) { m_funcs.push_back(p); m_bodies.push_back(body); } - virtual void operator()(model_ref& _m); + void operator()(model_ref& _m) override; - virtual model_converter * translate(ast_translation & translator); + model_converter * translate(ast_translation & translator) override; ast_manager& get_manager() { return m; } diff --git a/src/tactic/model_converter.cpp b/src/tactic/model_converter.cpp index 4269946a1..351fbcce7 100644 --- a/src/tactic/model_converter.cpp +++ b/src/tactic/model_converter.cpp @@ -23,25 +23,25 @@ class concat_model_converter : public concat_converter { public: concat_model_converter(model_converter * mc1, model_converter * mc2):concat_converter(mc1, mc2) {} - virtual void operator()(model_ref & m) { + void operator()(model_ref & m) override { this->m_c2->operator()(m); this->m_c1->operator()(m); } - virtual void operator()(model_ref & m, unsigned goal_idx) { + void operator()(model_ref & m, unsigned goal_idx) override { this->m_c2->operator()(m, goal_idx); this->m_c1->operator()(m, 0); } - virtual void operator()(labels_vec & r, unsigned goal_idx) { + void operator()(labels_vec & r, unsigned goal_idx) override { this->m_c2->operator()(r, goal_idx); this->m_c1->operator()(r, 0); } - virtual char const * get_name() const { return "concat-model-converter"; } + char const * get_name() const override { return "concat-model-converter"; } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { return this->translate_core(translator); } }; @@ -60,12 +60,12 @@ public: concat_star_converter(mc1, num, mc2s, szs) { } - virtual void operator()(model_ref & m) { + void operator()(model_ref & m) override { // TODO: delete method after conversion is complete UNREACHABLE(); } - virtual void operator()(model_ref & m, unsigned goal_idx) { + void operator()(model_ref & m, unsigned goal_idx) override { unsigned num = this->m_c2s.size(); for (unsigned i = 0; i < num; i++) { if (goal_idx < this->m_szs[i]) { @@ -83,7 +83,7 @@ public: UNREACHABLE(); } - virtual void operator()(labels_vec & r, unsigned goal_idx) { + void operator()(labels_vec & r, unsigned goal_idx) override { unsigned num = this->m_c2s.size(); for (unsigned i = 0; i < num; i++) { if (goal_idx < this->m_szs[i]) { @@ -101,9 +101,9 @@ public: UNREACHABLE(); } - virtual char const * get_name() const { return "concat-star-model-converter"; } + char const * get_name() const override { return "concat-star-model-converter"; } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { return this->translate_core(translator); } }; @@ -132,30 +132,30 @@ public: model2mc(model * m, buffer const & r):m_model(m), m_labels(r) {} - virtual ~model2mc() {} + ~model2mc() override {} - virtual void operator()(model_ref & m) { + void operator()(model_ref & m) override { m = m_model; } - virtual void operator()(model_ref & m, unsigned goal_idx) { + void operator()(model_ref & m, unsigned goal_idx) override { m = m_model; } - virtual void operator()(labels_vec & r, unsigned goal_idx) { + void operator()(labels_vec & r, unsigned goal_idx) override { r.append(m_labels.size(), m_labels.c_ptr()); } - virtual void cancel() { + void cancel() override { } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { out << "(model->model-converter-wrapper\n"; model_v2_pp(out, *m_model); out << ")\n"; } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { model * m = m_model->translate(translator); return alloc(model2mc, m); } diff --git a/src/tactic/nlsat_smt/nl_purify_tactic.cpp b/src/tactic/nlsat_smt/nl_purify_tactic.cpp index c99ea545a..828758caa 100644 --- a/src/tactic/nlsat_smt/nl_purify_tactic.cpp +++ b/src/tactic/nlsat_smt/nl_purify_tactic.cpp @@ -709,27 +709,27 @@ public: m_asms(m) {} - virtual ~nl_purify_tactic() {} + ~nl_purify_tactic() override {} - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_params = p; } - virtual tactic * translate(ast_manager& m) { + tactic * translate(ast_manager& m) override { return alloc(nl_purify_tactic, m, m_params); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { m_nl_tac->collect_statistics(st); m_solver->collect_statistics(st); } - virtual void reset_statistics() { + void reset_statistics() override { m_nl_tac->reset_statistics(); } - virtual void cleanup() { + void cleanup() override { m_solver = mk_smt_solver(m, m_params, symbol::null); m_nl_tac->cleanup(); m_eq_preds.reset(); @@ -744,11 +744,11 @@ public: m_bool2dep.reset(); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { tactic_report report("qfufnl-purify", *g); TRACE("nlsat_smt", g->display(tout);); diff --git a/src/tactic/portfolio/bounded_int2bv_solver.cpp b/src/tactic/portfolio/bounded_int2bv_solver.cpp index 58078e106..7b82772c5 100644 --- a/src/tactic/portfolio/bounded_int2bv_solver.cpp +++ b/src/tactic/portfolio/bounded_int2bv_solver.cpp @@ -65,18 +65,18 @@ public: m_bounds.push_back(alloc(bound_manager, m)); } - virtual ~bounded_int2bv_solver() { + ~bounded_int2bv_solver() override { while (!m_bounds.empty()) { dealloc(m_bounds.back()); m_bounds.pop_back(); } } - virtual solver* translate(ast_manager& m, params_ref const& p) { + solver* translate(ast_manager& m, params_ref const& p) override { return alloc(bounded_int2bv_solver, m, p, m_solver->translate(m, p)); } - virtual void assert_expr(expr * t) { + void assert_expr(expr * t) override { unsigned i = m_assertions.size(); m_assertions.push_back(t); while (i < m_assertions.size()) { @@ -92,14 +92,14 @@ public: } } - virtual void push_core() { + void push_core() override { flush_assertions(); m_solver->push(); m_bv_fns_lim.push_back(m_bv_fns.size()); m_bounds.push_back(alloc(bound_manager, m)); } - virtual void pop_core(unsigned n) { + void pop_core(unsigned n) override { m_assertions.reset(); m_solver->pop(n); @@ -125,31 +125,31 @@ public: } } - virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) { + lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) override { flush_assertions(); return m_solver->check_sat(num_assumptions, assumptions); } - virtual void updt_params(params_ref const & p) { solver::updt_params(p); m_solver->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { m_solver->collect_param_descrs(r); } - virtual void set_produce_models(bool f) { m_solver->set_produce_models(f); } - virtual void set_progress_callback(progress_callback * callback) { m_solver->set_progress_callback(callback); } - virtual void collect_statistics(statistics & st) const { m_solver->collect_statistics(st); } - virtual void get_unsat_core(ptr_vector & r) { m_solver->get_unsat_core(r); } - virtual void get_model(model_ref & mdl) { + void updt_params(params_ref const & p) override { solver::updt_params(p); m_solver->updt_params(p); } + void collect_param_descrs(param_descrs & r) override { m_solver->collect_param_descrs(r); } + void set_produce_models(bool f) override { m_solver->set_produce_models(f); } + void set_progress_callback(progress_callback * callback) override { m_solver->set_progress_callback(callback); } + void collect_statistics(statistics & st) const override { m_solver->collect_statistics(st); } + void get_unsat_core(ptr_vector & r) override { m_solver->get_unsat_core(r); } + void get_model(model_ref & mdl) override { m_solver->get_model(mdl); if (mdl) { extend_model(mdl); filter_model(mdl); } } - virtual proof * get_proof() { return m_solver->get_proof(); } - virtual std::string reason_unknown() const { return m_solver->reason_unknown(); } - virtual void set_reason_unknown(char const* msg) { m_solver->set_reason_unknown(msg); } - virtual void get_labels(svector & r) { m_solver->get_labels(r); } - virtual ast_manager& get_manager() const { return m; } - virtual lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) { return m_solver->find_mutexes(vars, mutexes); } - virtual lbool get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) { + proof * get_proof() override { return m_solver->get_proof(); } + std::string reason_unknown() const override { return m_solver->reason_unknown(); } + void set_reason_unknown(char const* msg) override { m_solver->set_reason_unknown(msg); } + void get_labels(svector & r) override { m_solver->get_labels(r); } + ast_manager& get_manager() const override { return m; } + lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) override { return m_solver->find_mutexes(vars, mutexes); } + lbool get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) override { flush_assertions(); expr_ref_vector bvars(m); for (unsigned i = 0; i < vars.size(); ++i) { @@ -319,12 +319,12 @@ private: m_rewriter.reset(); } - virtual unsigned get_num_assertions() const { + unsigned get_num_assertions() const override { flush_assertions(); return m_solver->get_num_assertions(); } - virtual expr * get_assertion(unsigned idx) const { + expr * get_assertion(unsigned idx) const override { flush_assertions(); return m_solver->get_assertion(idx); } diff --git a/src/tactic/portfolio/enum2bv_solver.cpp b/src/tactic/portfolio/enum2bv_solver.cpp index dd0ee7c4b..029914b88 100644 --- a/src/tactic/portfolio/enum2bv_solver.cpp +++ b/src/tactic/portfolio/enum2bv_solver.cpp @@ -47,13 +47,13 @@ public: solver::updt_params(p); } - virtual ~enum2bv_solver() {} + ~enum2bv_solver() override {} - virtual solver* translate(ast_manager& m, params_ref const& p) { + solver* translate(ast_manager& m, params_ref const& p) override { return alloc(enum2bv_solver, m, p, m_solver->translate(m, p)); } - virtual void assert_expr(expr * t) { + void assert_expr(expr * t) override { expr_ref tmp(t, m); expr_ref_vector bounds(m); proof_ref tmp_proof(m); @@ -63,40 +63,40 @@ public: m_solver->assert_expr(bounds); } - virtual void push_core() { + void push_core() override { m_rewriter.push(); m_solver->push(); } - virtual void pop_core(unsigned n) { + void pop_core(unsigned n) override { m_solver->pop(n); m_rewriter.pop(n); } - virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) { + lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) override { return m_solver->check_sat(num_assumptions, assumptions); } - virtual void updt_params(params_ref const & p) { solver::updt_params(p); m_solver->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { m_solver->collect_param_descrs(r); } - virtual void set_produce_models(bool f) { m_solver->set_produce_models(f); } - virtual void set_progress_callback(progress_callback * callback) { m_solver->set_progress_callback(callback); } - virtual void collect_statistics(statistics & st) const { m_solver->collect_statistics(st); } - virtual void get_unsat_core(ptr_vector & r) { m_solver->get_unsat_core(r); } - virtual void get_model(model_ref & mdl) { + void updt_params(params_ref const & p) override { solver::updt_params(p); m_solver->updt_params(p); } + void collect_param_descrs(param_descrs & r) override { m_solver->collect_param_descrs(r); } + void set_produce_models(bool f) override { m_solver->set_produce_models(f); } + void set_progress_callback(progress_callback * callback) override { m_solver->set_progress_callback(callback); } + void collect_statistics(statistics & st) const override { m_solver->collect_statistics(st); } + void get_unsat_core(ptr_vector & r) override { m_solver->get_unsat_core(r); } + void get_model(model_ref & mdl) override { m_solver->get_model(mdl); if (mdl) { extend_model(mdl); filter_model(mdl); } } - virtual proof * get_proof() { return m_solver->get_proof(); } - virtual std::string reason_unknown() const { return m_solver->reason_unknown(); } - virtual void set_reason_unknown(char const* msg) { m_solver->set_reason_unknown(msg); } - virtual void get_labels(svector & r) { m_solver->get_labels(r); } - virtual ast_manager& get_manager() const { return m; } - virtual lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) { return m_solver->find_mutexes(vars, mutexes); } - virtual lbool get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) { + proof * get_proof() override { return m_solver->get_proof(); } + std::string reason_unknown() const override { return m_solver->reason_unknown(); } + void set_reason_unknown(char const* msg) override { m_solver->set_reason_unknown(msg); } + void get_labels(svector & r) override { m_solver->get_labels(r); } + ast_manager& get_manager() const override { return m; } + lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) override { return m_solver->find_mutexes(vars, mutexes); } + lbool get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) override { datatype_util dt(m); bv_util bv(m); expr_ref_vector bvars(m), conseq(m), bounds(m); @@ -163,11 +163,11 @@ public: ext(mdl, 0); } - virtual unsigned get_num_assertions() const { + unsigned get_num_assertions() const override { return m_solver->get_num_assertions(); } - virtual expr * get_assertion(unsigned idx) const { + expr * get_assertion(unsigned idx) const override { return m_solver->get_assertion(idx); } diff --git a/src/tactic/portfolio/pb2bv_solver.cpp b/src/tactic/portfolio/pb2bv_solver.cpp index a06ff77c0..8339272b1 100644 --- a/src/tactic/portfolio/pb2bv_solver.cpp +++ b/src/tactic/portfolio/pb2bv_solver.cpp @@ -42,55 +42,55 @@ public: solver::updt_params(p); } - virtual ~pb2bv_solver() {} + ~pb2bv_solver() override {} - virtual solver* translate(ast_manager& m, params_ref const& p) { + solver* translate(ast_manager& m, params_ref const& p) override { return alloc(pb2bv_solver, m, p, m_solver->translate(m, p)); } - virtual void assert_expr(expr * t) { + void assert_expr(expr * t) override { m_assertions.push_back(t); } - virtual void push_core() { + void push_core() override { flush_assertions(); m_rewriter.push(); m_solver->push(); } - virtual void pop_core(unsigned n) { + void pop_core(unsigned n) override { m_assertions.reset(); m_solver->pop(n); m_rewriter.pop(n); } - virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) { + lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) override { flush_assertions(); return m_solver->check_sat(num_assumptions, assumptions); } - virtual void updt_params(params_ref const & p) { solver::updt_params(p); m_solver->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { m_solver->collect_param_descrs(r); } - virtual void set_produce_models(bool f) { m_solver->set_produce_models(f); } - virtual void set_progress_callback(progress_callback * callback) { m_solver->set_progress_callback(callback); } - virtual void collect_statistics(statistics & st) const { + void updt_params(params_ref const & p) override { solver::updt_params(p); m_solver->updt_params(p); } + void collect_param_descrs(param_descrs & r) override { m_solver->collect_param_descrs(r); } + void set_produce_models(bool f) override { m_solver->set_produce_models(f); } + void set_progress_callback(progress_callback * callback) override { m_solver->set_progress_callback(callback); } + void collect_statistics(statistics & st) const override { m_rewriter.collect_statistics(st); m_solver->collect_statistics(st); } - virtual void get_unsat_core(ptr_vector & r) { m_solver->get_unsat_core(r); } - virtual void get_model(model_ref & mdl) { + void get_unsat_core(ptr_vector & r) override { m_solver->get_unsat_core(r); } + void get_model(model_ref & mdl) override { m_solver->get_model(mdl); if (mdl) { filter_model(mdl); } } - virtual proof * get_proof() { return m_solver->get_proof(); } - virtual std::string reason_unknown() const { return m_solver->reason_unknown(); } - virtual void set_reason_unknown(char const* msg) { m_solver->set_reason_unknown(msg); } - virtual void get_labels(svector & r) { m_solver->get_labels(r); } - virtual ast_manager& get_manager() const { return m; } - virtual lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) { return m_solver->find_mutexes(vars, mutexes); } - virtual lbool get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) { + proof * get_proof() override { return m_solver->get_proof(); } + std::string reason_unknown() const override { return m_solver->reason_unknown(); } + void set_reason_unknown(char const* msg) override { m_solver->set_reason_unknown(msg); } + void get_labels(svector & r) override { m_solver->get_labels(r); } + ast_manager& get_manager() const override { return m; } + lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) override { return m_solver->find_mutexes(vars, mutexes); } + lbool get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences) override { flush_assertions(); return m_solver->get_consequences(asms, vars, consequences); } @@ -106,12 +106,12 @@ public: filter(mdl, 0); } - virtual unsigned get_num_assertions() const { + unsigned get_num_assertions() const override { flush_assertions(); return m_solver->get_num_assertions(); } - virtual expr * get_assertion(unsigned idx) const { + expr * get_assertion(unsigned idx) const override { flush_assertions(); return m_solver->get_assertion(idx); } diff --git a/src/tactic/portfolio/smt_strategic_solver.cpp b/src/tactic/portfolio/smt_strategic_solver.cpp index 3e77b7abc..aa699695e 100644 --- a/src/tactic/portfolio/smt_strategic_solver.cpp +++ b/src/tactic/portfolio/smt_strategic_solver.cpp @@ -122,8 +122,8 @@ class smt_strategic_solver_factory : public solver_factory { public: smt_strategic_solver_factory(symbol const & logic):m_logic(logic) {} - virtual ~smt_strategic_solver_factory() {} - virtual solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) { + ~smt_strategic_solver_factory() override {} + solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) override { symbol l; if (m_logic != symbol::null) l = m_logic; diff --git a/src/tactic/probe.cpp b/src/tactic/probe.cpp index 072b866b1..c9863c9b1 100644 --- a/src/tactic/probe.cpp +++ b/src/tactic/probe.cpp @@ -27,7 +27,7 @@ Revision History: class memory_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(static_cast(memory::get_allocation_size())/static_cast(1024*1024)); } }; @@ -38,21 +38,21 @@ probe * mk_memory_probe() { class depth_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(g.depth()); } }; class size_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(g.size()); } }; class num_exprs_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(g.num_exprs()); } }; @@ -79,7 +79,7 @@ public: p->inc_ref(); } - ~unary_probe() { + ~unary_probe() override { m_p->dec_ref(); } @@ -99,7 +99,7 @@ public: p2->inc_ref(); } - ~bin_probe() { + ~bin_probe() override { m_p1->dec_ref(); m_p2->dec_ref(); } @@ -108,7 +108,7 @@ public: class not_probe : public unary_probe { public: not_probe(probe * p):unary_probe(p) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(!m_p->operator()(g).is_true()); } }; @@ -116,7 +116,7 @@ public: class and_probe : public bin_probe { public: and_probe(probe * p1, probe * p2):bin_probe(p1, p2) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_p1->operator()(g).is_true() && m_p2->operator()(g).is_true()); } }; @@ -124,7 +124,7 @@ public: class or_probe : public bin_probe { public: or_probe(probe * p1, probe * p2):bin_probe(p1, p2) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_p1->operator()(g).is_true() || m_p2->operator()(g).is_true()); } }; @@ -132,7 +132,7 @@ public: class eq_probe : public bin_probe { public: eq_probe(probe * p1, probe * p2):bin_probe(p1, p2) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_p1->operator()(g).get_value() == m_p2->operator()(g).get_value()); } }; @@ -140,7 +140,7 @@ public: class le_probe : public bin_probe { public: le_probe(probe * p1, probe * p2):bin_probe(p1, p2) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_p1->operator()(g).get_value() <= m_p2->operator()(g).get_value()); } }; @@ -148,7 +148,7 @@ public: class add_probe : public bin_probe { public: add_probe(probe * p1, probe * p2):bin_probe(p1, p2) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_p1->operator()(g).get_value() + m_p2->operator()(g).get_value()); } }; @@ -156,7 +156,7 @@ public: class sub_probe : public bin_probe { public: sub_probe(probe * p1, probe * p2):bin_probe(p1, p2) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_p1->operator()(g).get_value() - m_p2->operator()(g).get_value()); } }; @@ -164,7 +164,7 @@ public: class mul_probe : public bin_probe { public: mul_probe(probe * p1, probe * p2):bin_probe(p1, p2) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_p1->operator()(g).get_value() * m_p2->operator()(g).get_value()); } }; @@ -172,7 +172,7 @@ public: class div_probe : public bin_probe { public: div_probe(probe * p1, probe * p2):bin_probe(p1, p2) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_p1->operator()(g).get_value() / m_p2->operator()(g).get_value()); } }; @@ -182,7 +182,7 @@ class const_probe : public probe { public: const_probe(double v):m_val(v) {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return result(m_val); } }; @@ -303,7 +303,7 @@ struct is_non_qfbv_predicate { class is_propositional_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return !test(g); } }; @@ -311,7 +311,7 @@ public: class is_qfbv_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return !test(g); } }; @@ -353,7 +353,7 @@ struct is_non_qfaufbv_predicate { class is_qfaufbv_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return !test(g); } }; @@ -391,7 +391,7 @@ struct is_non_qfufbv_predicate { class is_qfufbv_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return !test(g); } }; @@ -442,7 +442,7 @@ public: num_consts_probe(bool b, char const * f): m_bool(b), m_family(f) { } - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { proc p(g.m(), m_bool, m_family); unsigned sz = g.size(); expr_fast_mark1 visited; @@ -471,21 +471,21 @@ probe * mk_num_bv_consts_probe() { class produce_proofs_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return g.proofs_enabled(); } }; class produce_models_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return g.models_enabled(); } }; class produce_unsat_cores_probe : public probe { public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { return g.unsat_core_enabled(); } }; @@ -514,7 +514,7 @@ struct has_pattern_probe : public probe { } }; public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { try { expr_fast_mark1 visited; proc p; @@ -544,7 +544,7 @@ struct has_quantifier_probe : public probe { void operator()(quantifier * n) { throw found(); } }; public: - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { try { expr_fast_mark1 visited; proc p; diff --git a/src/tactic/proof_converter.cpp b/src/tactic/proof_converter.cpp index 095488415..5ac48def0 100644 --- a/src/tactic/proof_converter.cpp +++ b/src/tactic/proof_converter.cpp @@ -23,16 +23,16 @@ class concat_proof_converter : public concat_converter { public: concat_proof_converter(proof_converter * pc1, proof_converter * pc2):concat_converter(pc1, pc2) {} - virtual char const * get_name() const { return "concat-proof-converter"; } + char const * get_name() const override { return "concat-proof-converter"; } - virtual void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) { + void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) override { proof_ref tmp(m); this->m_c2->operator()(m, num_source, source, tmp); proof * new_source = tmp.get(); this->m_c1->operator()(m, 1, &new_source, result); } - virtual proof_converter * translate(ast_translation & translator) { + proof_converter * translate(ast_translation & translator) override { return this->translate_core(translator); } }; @@ -51,9 +51,9 @@ public: concat_star_converter(pc1, num, pc2s, szs) { } - virtual char const * get_name() const { return "concat-star-proof-converter"; } + char const * get_name() const override { return "concat-star-proof-converter"; } - virtual void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) { + void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) override { unsigned num = this->m_szs.size(); #ifdef Z3DEBUG unsigned sum = 0; @@ -86,7 +86,7 @@ public: } } - virtual proof_converter * translate(ast_translation & translator) { + proof_converter * translate(ast_translation & translator) override { return this->translate_core(translator); } }; @@ -111,18 +111,18 @@ class proof2pc : public proof_converter { proof_ref m_pr; public: proof2pc(ast_manager & m, proof * pr):m_pr(pr, m) {} - virtual ~proof2pc() {} + ~proof2pc() override {} - virtual void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) { + void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) override { SASSERT(num_source == 0); result = m_pr; } - virtual proof_converter * translate(ast_translation & translator) { + proof_converter * translate(ast_translation & translator) override { return alloc(proof2pc, translator.to(), translator(m_pr.get())); } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { out << "(proof->proof-converter-wrapper\n" << mk_ismt2_pp(m_pr.get(), m_pr.get_manager()) << ")\n"; } }; diff --git a/src/tactic/proof_converter.h b/src/tactic/proof_converter.h index e925436d2..c3a841b31 100644 --- a/src/tactic/proof_converter.h +++ b/src/tactic/proof_converter.h @@ -25,7 +25,7 @@ Notes: class proof_converter : public converter { public: - virtual ~proof_converter() { } + ~proof_converter() override { } virtual void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) = 0; virtual proof_converter * translate(ast_translation & translator) = 0; }; diff --git a/src/tactic/replace_proof_converter.h b/src/tactic/replace_proof_converter.h index b768a18a0..44ba2d82d 100644 --- a/src/tactic/replace_proof_converter.h +++ b/src/tactic/replace_proof_converter.h @@ -32,11 +32,11 @@ public: replace_proof_converter(ast_manager& _m): m(_m), m_proofs(m) {} - virtual ~replace_proof_converter() {} + ~replace_proof_converter() override {} - virtual void operator()(ast_manager & _m, unsigned num_source, proof * const * source, proof_ref & result); + void operator()(ast_manager & _m, unsigned num_source, proof * const * source, proof_ref & result) override; - virtual proof_converter * translate(ast_translation & translator); + proof_converter * translate(ast_translation & translator) override; void insert(proof* p) { m_proofs.push_back(p); } diff --git a/src/tactic/sine_filter.cpp b/src/tactic/sine_filter.cpp index ba35bac84..4aecc0274 100644 --- a/src/tactic/sine_filter.cpp +++ b/src/tactic/sine_filter.cpp @@ -38,21 +38,21 @@ public: sine_tactic(ast_manager& m, params_ref const& p): m(m), m_params(p) {} - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(sine_tactic, m, m_params); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { } - 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, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { mc = 0; pc = 0; core = 0; TRACE("sine", g->display(tout);); @@ -73,7 +73,7 @@ public: mc = fmc; } - virtual void cleanup() { + void cleanup() override { } private: diff --git a/src/tactic/sls/sls_tactic.cpp b/src/tactic/sls/sls_tactic.cpp index 19937e8b0..aaf4c24c0 100644 --- a/src/tactic/sls/sls_tactic.cpp +++ b/src/tactic/sls/sls_tactic.cpp @@ -42,28 +42,28 @@ public: m_engine = alloc(sls_engine, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(sls_tactic, m, m_params); } - virtual ~sls_tactic() { + ~sls_tactic() override { dealloc(m_engine); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_params = p; m_engine->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { sls_params::collect_param_descrs(r); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); mc = 0; pc = 0; core = 0; result.reset(); @@ -78,17 +78,17 @@ public: SASSERT(g->is_well_sorted()); } - virtual void cleanup() { + void cleanup() override { sls_engine * d = alloc(sls_engine, m, m_params); std::swap(d, m_engine); dealloc(d); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { m_engine->collect_statistics(st); } - virtual void reset_statistics() { + void reset_statistics() override { m_engine->reset_statistics(); } diff --git a/src/tactic/smtlogics/qflia_tactic.cpp b/src/tactic/smtlogics/qflia_tactic.cpp index 23ae179e2..628555cae 100644 --- a/src/tactic/smtlogics/qflia_tactic.cpp +++ b/src/tactic/smtlogics/qflia_tactic.cpp @@ -36,7 +36,7 @@ Notes: #include "tactic/arith/probe_arith.h" struct quasi_pb_probe : public probe { - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { bool found_non_01 = false; bound_manager bm(g.m()); bm(g); diff --git a/src/tactic/smtlogics/qfufbv_tactic.cpp b/src/tactic/smtlogics/qfufbv_tactic.cpp index df2791a8f..1d3f251a4 100644 --- a/src/tactic/smtlogics/qfufbv_tactic.cpp +++ b/src/tactic/smtlogics/qfufbv_tactic.cpp @@ -51,13 +51,13 @@ public: , m_inc_use_sat(false) {} - virtual ~qfufbv_ackr_tactic() { } + ~qfufbv_ackr_tactic() override { } - virtual void operator()(goal_ref const & g, + void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + expr_dependency_ref & core) override { mc = 0; ast_manager& m(g->m()); tactic_report report("qfufbv_ackr", *g); @@ -84,23 +84,23 @@ public: } } - void updt_params(params_ref const & _p) { + void updt_params(params_ref const & _p) override { qfufbv_tactic_params p(_p); m_use_sat = p.sat_backend(); m_inc_use_sat = p.inc_sat_backend(); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { ackermannization_params p(m_p); if (!p.eager()) st.update("lackr-its", m_st.m_it); st.update("ackr-constraints", m_st.m_ackrs_sz); } - virtual void reset_statistics() { m_st.reset(); } + void reset_statistics() override { m_st.reset(); } - virtual void cleanup() { } + void cleanup() override { } - virtual tactic* translate(ast_manager& m) { + tactic* translate(ast_manager& m) override { return alloc(qfufbv_ackr_tactic, m, m_p); } private: diff --git a/src/tactic/tactic.cpp b/src/tactic/tactic.cpp index 6c4ca7476..7ccd44e7d 100644 --- a/src/tactic/tactic.cpp +++ b/src/tactic/tactic.cpp @@ -85,17 +85,17 @@ tactic * mk_skip_tactic() { class fail_tactic : public tactic { public: - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { throw tactic_exception("fail tactic"); } - virtual void cleanup() {} + void cleanup() override {} - virtual tactic * translate(ast_manager & m) { return this; } + tactic * translate(ast_manager & m) override { return this; } }; tactic * mk_fail_tactic() { @@ -108,11 +108,11 @@ class report_verbose_tactic : public skip_tactic { public: report_verbose_tactic(char const * msg, unsigned lvl) : m_msg(msg), m_lvl(lvl) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { IF_VERBOSE(m_lvl, verbose_stream() << m_msg << "\n";); skip_tactic::operator()(in, result, mc, pc, core); } @@ -127,11 +127,11 @@ class trace_tactic : public skip_tactic { public: trace_tactic(char const * tag): m_tag(tag) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { TRACE(m_tag, in->display(tout);); (void)m_tag; skip_tactic::operator()(in, result, mc, pc, core); @@ -146,11 +146,11 @@ class fail_if_undecided_tactic : public skip_tactic { public: fail_if_undecided_tactic() {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { if (!in->is_decided()) throw tactic_exception("undecided"); skip_tactic::operator()(in, result, mc, pc, core); diff --git a/src/tactic/tactic.h b/src/tactic/tactic.h index 0e4c61611..096ce367e 100644 --- a/src/tactic/tactic.h +++ b/src/tactic/tactic.h @@ -119,9 +119,9 @@ void report_tactic_progress(char const * id, unsigned val); class skip_tactic : public tactic { public: - virtual void operator()(goal_ref const & in, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core); - virtual void cleanup() {} - virtual tactic * translate(ast_manager & m) { return this; } + void operator()(goal_ref const & in, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override; + void cleanup() override {} + tactic * translate(ast_manager & m) override { return this; } }; tactic * mk_skip_tactic(); diff --git a/src/tactic/tactic_exception.h b/src/tactic/tactic_exception.h index e989ed2bf..177524726 100644 --- a/src/tactic/tactic_exception.h +++ b/src/tactic/tactic_exception.h @@ -27,8 +27,8 @@ protected: std::string m_msg; public: tactic_exception(char const * msg):m_msg(msg) {} - virtual ~tactic_exception() {} - virtual char const * msg() const { return m_msg.c_str(); } + ~tactic_exception() override {} + char const * msg() const override { return m_msg.c_str(); } }; #define TACTIC_CANCELED_MSG Z3_CANCELED_MSG diff --git a/src/tactic/tactical.cpp b/src/tactic/tactical.cpp index c5a70c0db..fe0c7385f 100644 --- a/src/tactic/tactical.cpp +++ b/src/tactic/tactical.cpp @@ -39,47 +39,47 @@ public: m_t2->inc_ref(); } - virtual ~binary_tactical() { + ~binary_tactical() override { m_t1->dec_ref(); m_t2->dec_ref(); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_t1->updt_params(p); m_t2->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { m_t1->collect_param_descrs(r); m_t2->collect_param_descrs(r); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { m_t1->collect_statistics(st); m_t2->collect_statistics(st); } - virtual void reset_statistics() { + void reset_statistics() override { m_t1->reset_statistics(); m_t2->reset_statistics(); } - virtual void cleanup() { + void cleanup() override { m_t1->cleanup(); m_t2->cleanup(); } - virtual void reset() { + void reset() override { m_t1->reset(); m_t2->reset(); } - virtual void set_logic(symbol const & l) { + void set_logic(symbol const & l) override { m_t1->set_logic(l); m_t2->set_logic(l); } - virtual void set_progress_callback(progress_callback * callback) { + void set_progress_callback(progress_callback * callback) override { m_t1->set_progress_callback(callback); m_t2->set_progress_callback(callback); } @@ -104,13 +104,13 @@ struct false_pred { class and_then_tactical : public binary_tactical { public: and_then_tactical(tactic * t1, tactic * t2):binary_tactical(t1, t2) {} - virtual ~and_then_tactical() {} + ~and_then_tactical() override {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { bool models_enabled = in->models_enabled(); bool proofs_enabled = in->proofs_enabled(); @@ -212,7 +212,7 @@ public: } } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return translate_core(m); } @@ -282,14 +282,14 @@ public: } } - virtual ~nary_tactical() { + ~nary_tactical() override { unsigned sz = m_ts.size(); for (unsigned i = 0; i < sz; i++) { m_ts[i]->dec_ref(); } } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { TRACE("nary_tactical_updt_params", tout << "updt_params: " << p << "\n";); ptr_vector::iterator it = m_ts.begin(); ptr_vector::iterator end = m_ts.end(); @@ -297,49 +297,49 @@ public: (*it)->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { ptr_vector::iterator it = m_ts.begin(); ptr_vector::iterator end = m_ts.end(); for (; it != end; ++it) (*it)->collect_param_descrs(r); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { ptr_vector::const_iterator it = m_ts.begin(); ptr_vector::const_iterator end = m_ts.end(); for (; it != end; ++it) (*it)->collect_statistics(st); } - virtual void reset_statistics() { + void reset_statistics() override { ptr_vector::const_iterator it = m_ts.begin(); ptr_vector::const_iterator end = m_ts.end(); for (; it != end; ++it) (*it)->reset_statistics(); } - virtual void cleanup() { + void cleanup() override { ptr_vector::iterator it = m_ts.begin(); ptr_vector::iterator end = m_ts.end(); for (; it != end; ++it) (*it)->cleanup(); } - virtual void reset() { + void reset() override { ptr_vector::iterator it = m_ts.begin(); ptr_vector::iterator end = m_ts.end(); for (; it != end; ++it) (*it)->reset(); } - virtual void set_logic(symbol const & l) { + void set_logic(symbol const & l) override { ptr_vector::iterator it = m_ts.begin(); ptr_vector::iterator end = m_ts.end(); for (; it != end; ++it) (*it)->set_logic(l); } - virtual void set_progress_callback(progress_callback * callback) { + void set_progress_callback(progress_callback * callback) override { ptr_vector::iterator it = m_ts.begin(); ptr_vector::iterator end = m_ts.end(); for (; it != end; ++it) @@ -367,13 +367,13 @@ class or_else_tactical : public nary_tactical { public: or_else_tactical(unsigned num, tactic * const * ts):nary_tactical(num, ts) { SASSERT(num > 0); } - virtual ~or_else_tactical() {} + ~or_else_tactical() override {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { goal orig(*(in.get())); unsigned sz = m_ts.size(); unsigned i; @@ -401,7 +401,7 @@ public: } } - virtual tactic * translate(ast_manager & m) { return translate_core(m); } + tactic * translate(ast_manager & m) override { return translate_core(m); } }; tactic * or_else(unsigned num, tactic * const * ts) { @@ -464,15 +464,15 @@ class par_tactical : public or_else_tactical { public: par_tactical(unsigned num, tactic * const * ts):or_else_tactical(num, ts) {} - virtual ~par_tactical() {} + ~par_tactical() override {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { bool use_seq; #ifdef _NO_OMP_ use_seq = true; @@ -572,7 +572,7 @@ public: } } - virtual tactic * translate(ast_manager & m) { return translate_core(m); } + tactic * translate(ast_manager & m) override { return translate_core(m); } }; tactic * par(unsigned num, tactic * const * ts) { @@ -597,13 +597,13 @@ tactic * par(tactic * t1, tactic * t2, tactic * t3, tactic * t4) { class par_and_then_tactical : public and_then_tactical { public: par_and_then_tactical(tactic * t1, tactic * t2):and_then_tactical(t1, t2) {} - virtual ~par_and_then_tactical() {} + ~par_and_then_tactical() override {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { bool use_seq; #ifdef _NO_OMP_ use_seq = true; @@ -862,7 +862,7 @@ public: } } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return translate_core(m); } @@ -895,26 +895,26 @@ public: t->inc_ref(); } - virtual ~unary_tactical() { + ~unary_tactical() override { m_t->dec_ref(); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { m_t->operator()(in, result, mc, pc, core); } - virtual void cleanup(void) { m_t->cleanup(); } - virtual void collect_statistics(statistics & st) const { m_t->collect_statistics(st); } - virtual void reset_statistics() { m_t->reset_statistics(); } - virtual void updt_params(params_ref const & p) { m_t->updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { m_t->collect_param_descrs(r); } - virtual void reset() { m_t->reset(); } - virtual void set_logic(symbol const& l) { m_t->set_logic(l); } - virtual void set_progress_callback(progress_callback * callback) { m_t->set_progress_callback(callback); } + void cleanup(void) override { m_t->cleanup(); } + void collect_statistics(statistics & st) const override { m_t->collect_statistics(st); } + void reset_statistics() override { m_t->reset_statistics(); } + void updt_params(params_ref const & p) override { m_t->updt_params(p); } + void collect_param_descrs(param_descrs & r) override { m_t->collect_param_descrs(r); } + void reset() override { m_t->reset(); } + void set_logic(symbol const& l) override { m_t->set_logic(l); } + void set_progress_callback(progress_callback * callback) override { m_t->set_progress_callback(callback); } protected: template @@ -1056,15 +1056,15 @@ public: m_max_depth(max_depth) { } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { operator()(0, in, result, mc, pc, core); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { tactic * new_t = m_t->translate(m); return alloc(repeat_tactical, new_t, m_max_depth); } @@ -1079,11 +1079,11 @@ class fail_if_branching_tactical : public unary_tactical { public: fail_if_branching_tactical(tactic * t, unsigned threshold):unary_tactical(t), m_threshold(threshold) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { m_t->operator()(in, result, mc, pc, core); if (result.size() > m_threshold) { result.reset(); @@ -1094,7 +1094,7 @@ public: } }; - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { tactic * new_t = m_t->translate(m); return alloc(fail_if_branching_tactical, new_t, m_threshold); } @@ -1108,16 +1108,16 @@ class cleanup_tactical : public unary_tactical { public: cleanup_tactical(tactic * t):unary_tactical(t) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { m_t->operator()(in, result, mc, pc, core); m_t->cleanup(); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { tactic * new_t = m_t->translate(m); return alloc(cleanup_tactical, new_t); } @@ -1132,11 +1132,11 @@ class try_for_tactical : public unary_tactical { public: try_for_tactical(tactic * t, unsigned ts):unary_tactical(t), m_timeout(ts) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { cancel_eh eh(in->m().limit()); { // Warning: scoped_timer is not thread safe in Linux. @@ -1145,7 +1145,7 @@ public: } } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { tactic * new_t = m_t->translate(m); return alloc(try_for_tactical, new_t, m_timeout); } @@ -1162,7 +1162,7 @@ public: t->updt_params(p); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { TRACE("using_params", tout << "before p: " << p << "\n"; tout << "m_params: " << m_params << "\n";); @@ -1177,7 +1177,7 @@ public: tout << "new_p: " << new_p << "\n";); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { tactic * new_t = m_t->translate(m); return alloc(using_params_tactical, new_t, m_params); } @@ -1202,16 +1202,16 @@ public: annotate_tactical(char const* name, tactic* t): unary_tactical(t), m_name(name) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { scope _scope(m_name); m_t->operator()(in, result, mc, pc, core); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { tactic * new_t = m_t->translate(m); return alloc(annotate_tactical, m_name.c_str(), new_t); } @@ -1232,22 +1232,22 @@ public: m_p->inc_ref(); } - ~cond_tactical() { + ~cond_tactical() override { m_p->dec_ref(); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { if (m_p->operator()(*(in.get())).is_true()) m_t1->operator()(in, result, mc, pc, core); else m_t2->operator()(in, result, mc, pc, core); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { tactic * new_t1 = m_t1->translate(m); tactic * new_t2 = m_t2->translate(m); return alloc(cond_tactical, m_p, new_t1, new_t2); @@ -1271,17 +1271,17 @@ public: m_p->inc_ref(); } - ~fail_if_tactic() { + ~fail_if_tactic() override { m_p->dec_ref(); } - void cleanup() {} + void cleanup() override {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { mc = 0; pc = 0; core = 0; @@ -1291,7 +1291,7 @@ public: result.push_back(in.get()); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return this; } }; @@ -1308,11 +1308,11 @@ class if_no_proofs_tactical : public unary_tactical { public: if_no_proofs_tactical(tactic * t):unary_tactical(t) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { if (in->proofs_enabled()) { mc = 0; pc = 0; core = 0; result.reset(); @@ -1323,18 +1323,18 @@ public: } } - virtual tactic * translate(ast_manager & m) { return translate_core(m); } + tactic * translate(ast_manager & m) override { return translate_core(m); } }; class if_no_unsat_cores_tactical : public unary_tactical { public: if_no_unsat_cores_tactical(tactic * t):unary_tactical(t) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { if (in->unsat_core_enabled()) { mc = 0; pc = 0; core = 0; result.reset(); @@ -1345,18 +1345,18 @@ public: } } - virtual tactic * translate(ast_manager & m) { return translate_core(m); } + tactic * translate(ast_manager & m) override { return translate_core(m); } }; class if_no_models_tactical : public unary_tactical { public: if_no_models_tactical(tactic * t):unary_tactical(t) {} - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { if (in->models_enabled()) { mc = 0; pc = 0; core = 0; result.reset(); @@ -1367,7 +1367,7 @@ public: } } - virtual tactic * translate(ast_manager & m) { return translate_core(m); } + tactic * translate(ast_manager & m) override { return translate_core(m); } }; tactic * if_no_proofs(tactic * t) { @@ -1386,4 +1386,3 @@ tactic * skip_if_failed(tactic * t) { return or_else(t, mk_skip_tactic()); } - diff --git a/src/tactic/ufbv/macro_finder_tactic.cpp b/src/tactic/ufbv/macro_finder_tactic.cpp index 3a482f37c..88b1e6a67 100644 --- a/src/tactic/ufbv/macro_finder_tactic.cpp +++ b/src/tactic/ufbv/macro_finder_tactic.cpp @@ -97,35 +97,35 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(macro_finder_tactic, m, m_params); } - virtual ~macro_finder_tactic() { + ~macro_finder_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_produce_models(r); insert_produce_proofs(r); r.insert("elim_and", CPK_BOOL, "(default: false) eliminate conjunctions during (internal) calls to the simplifier."); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m(); imp * d = alloc(imp, m, m_params); std::swap(d, m_imp); diff --git a/src/tactic/ufbv/quasi_macros_tactic.cpp b/src/tactic/ufbv/quasi_macros_tactic.cpp index 925b5a5e3..e9d081c53 100644 --- a/src/tactic/ufbv/quasi_macros_tactic.cpp +++ b/src/tactic/ufbv/quasi_macros_tactic.cpp @@ -109,34 +109,34 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(quasi_macros_tactic, m, m_params); } - virtual ~quasi_macros_tactic() { + ~quasi_macros_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_produce_models(r); insert_produce_proofs(r); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m(); imp * d = alloc(imp, m, m_params); std::swap(d, m_imp); diff --git a/src/tactic/ufbv/ufbv_rewriter_tactic.cpp b/src/tactic/ufbv/ufbv_rewriter_tactic.cpp index 615593317..3dcc6d9a1 100644 --- a/src/tactic/ufbv/ufbv_rewriter_tactic.cpp +++ b/src/tactic/ufbv/ufbv_rewriter_tactic.cpp @@ -81,34 +81,34 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(ufbv_rewriter_tactic, m, m_params); } - virtual ~ufbv_rewriter_tactic() { + ~ufbv_rewriter_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_produce_models(r); insert_produce_proofs(r); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m(); imp * d = alloc(imp, m, m_params); std::swap(d, m_imp); diff --git a/src/util/cancel_eh.h b/src/util/cancel_eh.h index 59f11b3f3..09b996582 100644 --- a/src/util/cancel_eh.h +++ b/src/util/cancel_eh.h @@ -30,8 +30,8 @@ class cancel_eh : public event_handler { T & m_obj; public: cancel_eh(T & o): m_canceled(false), m_obj(o) {} - ~cancel_eh() { if (m_canceled) m_obj.dec_cancel(); } - virtual void operator()(event_handler_caller_t caller_id) { + ~cancel_eh() override { if (m_canceled) m_obj.dec_cancel(); } + void operator()(event_handler_caller_t caller_id) override { if (!m_canceled) { m_caller_id = caller_id; m_canceled = true; diff --git a/src/util/z3_exception.h b/src/util/z3_exception.h index 8d0acda28..e3260e89d 100644 --- a/src/util/z3_exception.h +++ b/src/util/z3_exception.h @@ -33,8 +33,8 @@ class z3_error : public z3_exception { unsigned m_error_code; public: z3_error(unsigned error_code); - virtual char const * msg() const; - virtual unsigned error_code() const; + char const * msg() const override; + unsigned error_code() const override; }; class default_exception : public z3_exception { @@ -43,8 +43,8 @@ public: struct fmt {}; default_exception(std::string const& msg); default_exception(fmt, char const* msg, ...); - virtual ~default_exception() {} - virtual char const * msg() const; + ~default_exception() override {} + char const * msg() const override; }; #endif From 7167fda1dc839b6caa558fe08269988b258b7e93 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sat, 10 Feb 2018 09:15:12 +0700 Subject: [PATCH 171/263] Use override rather than virtual. --- .../ackermannize_bv_tactic.cpp | 18 +- src/ackermannization/ackr_bound_probe.cpp | 2 +- src/ackermannization/ackr_model_converter.cpp | 8 +- .../lackr_model_converter_lazy.cpp | 8 +- src/api/api_algebraic.cpp | 6 +- src/api/api_ast_map.h | 2 +- src/api/api_ast_vector.h | 2 +- src/api/api_datalog.cpp | 8 +- src/api/api_datalog.h | 2 +- src/api/api_goal.h | 2 +- src/api/api_model.h | 6 +- src/api/api_opt.cpp | 2 +- src/api/api_solver.h | 2 +- src/api/api_stats.h | 2 +- src/api/api_tactic.h | 6 +- src/api/api_util.h | 4 +- src/ast/ast_trail.h | 2 +- src/interp/iz3proof_itp.cpp | 38 ++--- src/interp/iz3translate.cpp | 4 +- src/interp/iz3translate_direct.cpp | 4 +- src/math/hilbert/heap_trie.h | 16 +- src/math/hilbert/hilbert_basis.cpp | 2 +- src/math/polynomial/algebraic_numbers.cpp | 30 ++-- src/math/polynomial/polynomial.cpp | 12 +- .../upolynomial_factorization_int.h | 2 +- src/math/realclosure/realclosure.cpp | 4 +- src/math/subpaving/subpaving.cpp | 64 +++---- src/math/subpaving/subpaving_t_def.h | 6 +- .../subpaving/tactic/subpaving_tactic.cpp | 26 +-- src/muz/base/dl_context.cpp | 16 +- src/muz/base/dl_context.h | 6 +- src/muz/base/dl_util.cpp | 6 +- src/muz/bmc/dl_bmc_engine.h | 14 +- src/muz/clp/clp_context.h | 12 +- src/muz/ddnf/ddnf.h | 12 +- src/muz/duality/duality_dl_interface.h | 28 +-- src/muz/fp/datalog_parser.cpp | 8 +- src/muz/fp/dl_cmds.cpp | 84 ++++----- src/muz/fp/dl_register_engine.h | 4 +- src/muz/fp/horn_tactic.cpp | 24 +-- src/muz/pdr/pdr_dl_interface.h | 24 +-- src/muz/pdr/pdr_generalizers.h | 30 ++-- src/muz/pdr/pdr_smt_context_manager.h | 18 +- src/muz/rel/check_relation.cpp | 36 ++-- src/muz/rel/check_relation.h | 76 ++++----- src/muz/rel/dl_base.cpp | 6 +- src/muz/rel/dl_base.h | 34 ++-- src/muz/rel/dl_bound_relation.cpp | 20 +-- src/muz/rel/dl_bound_relation.h | 76 ++++----- src/muz/rel/dl_check_table.cpp | 22 +-- src/muz/rel/dl_check_table.h | 74 ++++---- src/muz/rel/dl_compiler.h | 2 +- src/muz/rel/dl_external_relation.cpp | 14 +- src/muz/rel/dl_external_relation.h | 58 +++---- src/muz/rel/dl_finite_product_relation.cpp | 36 ++-- src/muz/rel/dl_finite_product_relation.h | 72 ++++---- src/muz/rel/dl_instruction.cpp | 114 ++++++------- src/muz/rel/dl_interval_relation.cpp | 14 +- src/muz/rel/dl_interval_relation.h | 64 +++---- src/muz/rel/dl_lazy_table.cpp | 16 +- src/muz/rel/dl_lazy_table.h | 122 ++++++------- src/muz/rel/dl_mk_explanations.cpp | 70 ++++---- src/muz/rel/dl_mk_explanations.h | 2 +- src/muz/rel/dl_mk_similarity_compressor.h | 2 +- src/muz/rel/dl_mk_simple_joins.h | 2 +- src/muz/rel/dl_product_relation.cpp | 24 +-- src/muz/rel/dl_product_relation.h | 62 +++---- src/muz/rel/dl_relation_manager.cpp | 68 ++++---- src/muz/rel/dl_sieve_relation.cpp | 10 +- src/muz/rel/dl_sieve_relation.h | 64 +++---- src/muz/rel/dl_sparse_table.cpp | 30 ++-- src/muz/rel/dl_sparse_table.h | 78 ++++----- src/muz/rel/dl_table.cpp | 20 +-- src/muz/rel/dl_table.h | 36 ++-- src/muz/rel/dl_table_relation.cpp | 12 +- src/muz/rel/dl_table_relation.h | 80 ++++----- src/muz/rel/dl_vector_relation.h | 8 +- src/muz/rel/karr_relation.cpp | 30 ++-- src/muz/rel/karr_relation.h | 34 ++-- src/muz/rel/rel_context.h | 58 +++---- src/muz/rel/udoc_relation.cpp | 28 +-- src/muz/rel/udoc_relation.h | 82 ++++----- src/muz/spacer/spacer_dl_interface.h | 34 ++-- src/muz/spacer/spacer_generalizers.h | 28 +-- src/muz/spacer/spacer_itp_solver.h | 52 +++--- src/muz/spacer/spacer_qe_project.cpp | 4 +- src/muz/spacer/spacer_unsat_core_plugin.h | 14 +- src/muz/spacer/spacer_virtual_solver.h | 40 ++--- src/muz/tab/tab_context.h | 14 +- src/muz/transforms/dl_mk_array_blast.h | 4 +- src/muz/transforms/dl_mk_array_eq_rewrite.h | 4 +- .../transforms/dl_mk_array_instantiation.h | 4 +- src/muz/transforms/dl_mk_backwards.h | 4 +- src/muz/transforms/dl_mk_bit_blast.cpp | 4 +- src/muz/transforms/dl_mk_bit_blast.h | 4 +- src/muz/transforms/dl_mk_coalesce.h | 2 +- src/muz/transforms/dl_mk_coi_filter.h | 2 +- src/muz/transforms/dl_mk_filter_rules.h | 4 +- .../transforms/dl_mk_interp_tail_simplifier.h | 4 +- src/muz/transforms/dl_mk_karr_invariants.cpp | 6 +- src/muz/transforms/dl_mk_karr_invariants.h | 4 +- src/muz/transforms/dl_mk_loop_counter.h | 4 +- src/muz/transforms/dl_mk_magic_sets.h | 2 +- src/muz/transforms/dl_mk_magic_symbolic.h | 4 +- .../dl_mk_quantifier_abstraction.cpp | 6 +- .../transforms/dl_mk_quantifier_abstraction.h | 4 +- .../dl_mk_quantifier_instantiation.h | 4 +- src/muz/transforms/dl_mk_rule_inliner.h | 6 +- src/muz/transforms/dl_mk_scale.cpp | 6 +- src/muz/transforms/dl_mk_scale.h | 4 +- .../transforms/dl_mk_separate_negated_tails.h | 2 +- src/muz/transforms/dl_mk_slice.cpp | 8 +- src/muz/transforms/dl_mk_slice.h | 4 +- .../transforms/dl_mk_subsumption_checker.h | 4 +- src/muz/transforms/dl_mk_unbound_compressor.h | 2 +- src/muz/transforms/dl_mk_unfold.h | 2 +- src/opt/maxsmt.h | 14 +- src/opt/opt_context.h | 70 ++++---- src/opt/opt_pareto.h | 8 +- src/opt/opt_solver.h | 42 ++--- src/parsers/util/cost_parser.h | 6 +- src/qe/nlarith_util.cpp | 34 ++-- src/qe/nlqsat.cpp | 22 +-- src/qe/qe.cpp | 42 ++--- src/qe/qe.h | 4 +- src/qe/qe_arith.h | 10 +- src/qe/qe_arith_plugin.cpp | 38 ++--- src/qe/qe_array_plugin.cpp | 12 +- src/qe/qe_arrays.h | 8 +- src/qe/qe_bool_plugin.cpp | 14 +- src/qe/qe_bv_plugin.cpp | 14 +- src/qe/qe_cmd.cpp | 16 +- src/qe/qe_datatype_plugin.cpp | 18 +- src/qe/qe_datatypes.h | 8 +- src/qe/qe_dl_plugin.cpp | 10 +- src/qe/qe_lite.cpp | 18 +- src/qe/qe_sat_tactic.cpp | 57 +++---- src/qe/qe_tactic.cpp | 24 +-- src/qe/qe_vartest.h | 2 +- src/qe/qsat.cpp | 22 +-- src/sat/sat_solver/inc_sat_solver.cpp | 52 +++--- src/sat/tactic/goal2sat.cpp | 6 +- src/sat/tactic/sat_tactic.cpp | 28 +-- src/shell/lp_frontend.cpp | 2 +- src/smt/arith_eq_adapter.cpp | 6 +- src/smt/asserted_formulas.h | 52 +++--- src/smt/dyn_ack.cpp | 12 +- src/smt/mam.cpp | 30 ++-- src/smt/proto_model/array_factory.h | 8 +- src/smt/proto_model/datatype_factory.h | 6 +- src/smt/proto_model/numeral_factory.h | 10 +- src/smt/proto_model/proto_model.h | 10 +- src/smt/proto_model/struct_factory.h | 6 +- src/smt/proto_model/value_factory.h | 30 ++-- src/smt/smt2_extra_cmds.cpp | 20 +-- src/smt/smt_case_split_queue.cpp | 160 +++++++++--------- src/smt/smt_context.cpp | 8 +- src/smt/smt_context.h | 4 +- src/smt/smt_for_each_relevant_expr.h | 8 +- src/smt/smt_internalizer.cpp | 8 +- src/smt/smt_justification.h | 110 ++++++------ src/smt/smt_model_finder.cpp | 100 +++++------ src/smt/smt_model_generator.h | 8 +- src/smt/smt_quantifier.cpp | 42 ++--- src/smt/smt_relevancy.cpp | 40 ++--- src/smt/smt_relevancy.h | 8 +- src/smt/smt_solver.cpp | 46 ++--- src/smt/tactic/ctx_solver_simplify_tactic.cpp | 25 ++- src/smt/tactic/smt_tactic.cpp | 28 +-- src/smt/tactic/unit_subsumption_tactic.cpp | 16 +- src/smt/theory_arith.h | 104 ++++++------ src/smt/theory_arith_int.h | 2 +- src/smt/theory_array.h | 36 ++-- src/smt/theory_array_base.cpp | 6 +- src/smt/theory_array_base.h | 20 +-- src/smt/theory_array_full.h | 36 ++-- src/smt/theory_bv.cpp | 20 +-- src/smt/theory_bv.h | 50 +++--- src/smt/theory_datatype.cpp | 8 +- src/smt/theory_datatype.h | 46 ++--- src/smt/theory_dense_diff_logic.h | 62 +++---- src/smt/theory_diff_logic.h | 64 +++---- src/smt/theory_dl.cpp | 28 +-- src/smt/theory_dummy.h | 24 +-- src/smt/theory_fpa.cpp | 4 +- src/smt/theory_fpa.h | 64 +++---- src/smt/theory_lra.cpp | 6 +- src/smt/theory_lra.h | 62 +++---- src/smt/theory_pb.cpp | 22 +-- src/smt/theory_pb.h | 40 ++--- src/smt/theory_seq.cpp | 8 +- src/smt/theory_seq.h | 64 +++---- src/smt/theory_seq_empty.h | 26 +-- src/smt/theory_str.h | 60 +++---- src/smt/theory_utvpi.h | 58 +++---- src/smt/theory_wmaxsat.h | 38 ++--- src/test/ex.cpp | 4 +- src/util/checked_int64.h | 2 +- src/util/lp/eta_matrix.h | 10 +- src/util/lp/iterator_on_column.h | 10 +- src/util/lp/iterator_on_indexed_vector.h | 10 +- src/util/lp/iterator_on_pivot_row.h | 10 +- src/util/lp/iterator_on_row.h | 10 +- src/util/lp/iterator_on_term_with_basis_var.h | 10 +- src/util/lp/lar_constraints.h | 14 +- src/util/lp/lar_solver.h | 2 +- src/util/lp/lp_dual_core_solver.h | 2 +- src/util/lp/lp_dual_simplex.h | 8 +- src/util/lp/lp_primal_core_solver.h | 2 +- src/util/lp/lp_primal_simplex.h | 8 +- src/util/lp/lp_settings.h | 2 +- src/util/lp/lu.h | 10 +- src/util/lp/permutation_matrix.h | 10 +- src/util/lp/row_eta_matrix.h | 10 +- src/util/lp/square_dense_submatrix.h | 10 +- src/util/mpff.h | 6 +- src/util/mpfx.h | 6 +- src/util/timeout.cpp | 2 +- src/util/trail.h | 42 ++--- src/util/union_find.h | 8 +- 220 files changed, 2546 insertions(+), 2548 deletions(-) diff --git a/src/ackermannization/ackermannize_bv_tactic.cpp b/src/ackermannization/ackermannize_bv_tactic.cpp index 82ef19274..5d749b7d5 100644 --- a/src/ackermannization/ackermannize_bv_tactic.cpp +++ b/src/ackermannization/ackermannize_bv_tactic.cpp @@ -27,13 +27,13 @@ public: : m(m), m_p(p) {} - virtual ~ackermannize_bv_tactic() { } + ~ackermannize_bv_tactic() override { } - virtual void operator()(goal_ref const & g, + void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + expr_dependency_ref & core) override { mc = 0; tactic_report report("ackermannize", *g); fail_if_unsat_core_generation("ackermannize", g); @@ -69,24 +69,24 @@ public: } - void updt_params(params_ref const & _p) { + void updt_params(params_ref const & _p) override { ackermannize_bv_tactic_params p(_p); m_lemma_limit = p.div0_ackermann_limit(); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { ackermannize_bv_tactic_params::collect_param_descrs(r); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { st.update("ackr-constraints", m_st.m_ackrs_sz); } - virtual void reset_statistics() { m_st.reset(); } + void reset_statistics() override { m_st.reset(); } - virtual void cleanup() { } + void cleanup() override { } - virtual tactic* translate(ast_manager& m) { + tactic* translate(ast_manager& m) override { return alloc(ackermannize_bv_tactic, m, m_p); } private: diff --git a/src/ackermannization/ackr_bound_probe.cpp b/src/ackermannization/ackr_bound_probe.cpp index 50b9cc092..f5e072368 100644 --- a/src/ackermannization/ackr_bound_probe.cpp +++ b/src/ackermannization/ackr_bound_probe.cpp @@ -57,7 +57,7 @@ class ackr_bound_probe : public probe { public: ackr_bound_probe() {} - virtual result operator()(goal const & g) { + result operator()(goal const & g) override { proc p(g.m()); unsigned sz = g.size(); expr_fast_mark1 visited; diff --git a/src/ackermannization/ackr_model_converter.cpp b/src/ackermannization/ackr_model_converter.cpp index a7c021913..c8df89bad 100644 --- a/src/ackermannization/ackr_model_converter.cpp +++ b/src/ackermannization/ackr_model_converter.cpp @@ -37,9 +37,9 @@ public: , fixed_model(false) { } - virtual ~ackr_model_converter() { } + ~ackr_model_converter() override { } - virtual void operator()(model_ref & md, unsigned goal_idx) { + void operator()(model_ref & md, unsigned goal_idx) override { SASSERT(goal_idx == 0); SASSERT(!fixed_model || md.get() == 0 || (!md->get_num_constants() && !md->get_num_functions())); model_ref& old_model = fixed_model ? abstr_model : md; @@ -49,9 +49,9 @@ public: md = new_model; } - virtual void operator()(model_ref & md) { operator()(md, 0); } + void operator()(model_ref & md) override { operator()(md, 0); } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { ackr_info_ref retv_info = info->translate(translator); if (fixed_model) { model_ref retv_mod_ref = abstr_model->translate(translator); diff --git a/src/ackermannization/lackr_model_converter_lazy.cpp b/src/ackermannization/lackr_model_converter_lazy.cpp index 2a7adb839..15673ffb6 100644 --- a/src/ackermannization/lackr_model_converter_lazy.cpp +++ b/src/ackermannization/lackr_model_converter_lazy.cpp @@ -28,9 +28,9 @@ public: , model_constructor(lmc) { } - virtual ~lackr_model_converter_lazy() { } + ~lackr_model_converter_lazy() override { } - virtual void operator()(model_ref & md, unsigned goal_idx) { + void operator()(model_ref & md, unsigned goal_idx) override { SASSERT(goal_idx == 0); SASSERT(md.get() == 0 || (!md->get_num_constants() && !md->get_num_functions())); SASSERT(model_constructor.get()); @@ -39,13 +39,13 @@ public: model_constructor->make_model(md); } - virtual void operator()(model_ref & md) { + void operator()(model_ref & md) override { operator()(md, 0); } //void display(std::ostream & out); - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { NOT_IMPLEMENTED_YET(); } protected: diff --git a/src/api/api_algebraic.cpp b/src/api/api_algebraic.cpp index 96d8392ba..b4eda2c03 100644 --- a/src/api/api_algebraic.cpp +++ b/src/api/api_algebraic.cpp @@ -345,9 +345,9 @@ extern "C" { public: vector_var2anum(scoped_anum_vector & as):m_as(as) {} virtual ~vector_var2anum() {} - virtual algebraic_numbers::manager & m() const { return m_as.m(); } - virtual bool contains(polynomial::var x) const { return static_cast(x) < m_as.size(); } - virtual algebraic_numbers::anum const & operator()(polynomial::var x) const { return m_as.get(x); } + algebraic_numbers::manager & m() const override { return m_as.m(); } + bool contains(polynomial::var x) const override { return static_cast(x) < m_as.size(); } + algebraic_numbers::anum const & operator()(polynomial::var x) const override { return m_as.get(x); } }; Z3_ast_vector Z3_API Z3_algebraic_roots(Z3_context c, Z3_ast p, unsigned n, Z3_ast a[]) { diff --git a/src/api/api_ast_map.h b/src/api/api_ast_map.h index 3dacc54f1..27ad1eb9d 100644 --- a/src/api/api_ast_map.h +++ b/src/api/api_ast_map.h @@ -25,7 +25,7 @@ struct Z3_ast_map_ref : public api::object { ast_manager & m; obj_map m_map; Z3_ast_map_ref(api::context& c, ast_manager & _m): api::object(c), m(_m) {} - virtual ~Z3_ast_map_ref(); + ~Z3_ast_map_ref() override; }; inline Z3_ast_map_ref * to_ast_map(Z3_ast_map v) { return reinterpret_cast(v); } diff --git a/src/api/api_ast_vector.h b/src/api/api_ast_vector.h index ced20481e..d9d3913e7 100644 --- a/src/api/api_ast_vector.h +++ b/src/api/api_ast_vector.h @@ -27,7 +27,7 @@ namespace api { struct Z3_ast_vector_ref : public api::object { ast_ref_vector m_ast_vector; Z3_ast_vector_ref(api::context& c, ast_manager & m): api::object(c), m_ast_vector(m) {} - virtual ~Z3_ast_vector_ref() {} + ~Z3_ast_vector_ref() override {} }; inline Z3_ast_vector_ref * to_ast_vector(Z3_ast_vector v) { return reinterpret_cast(v); } diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 397e2a8af..431638864 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -51,8 +51,8 @@ namespace api { m_context(m, m_register_engine, p), m_trail(m) {} - virtual ~fixedpoint_context() {} - family_id get_family_id() const { return const_cast(m_context).get_decl_util().get_family_id(); } + ~fixedpoint_context() override {} + family_id get_family_id() const override { return const_cast(m_context).get_decl_util().get_family_id(); } void set_state(void* state) { SASSERT(!m_state); m_state = state; @@ -73,7 +73,7 @@ namespace api { void set_reduce_assign(reduce_assign_callback_fptr f) { m_reduce_assign = f; } - virtual void reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result) { + void reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result) override { expr* r = 0; if (m_reduce_app) { m_reduce_app(m_state, f, num_args, args, &r); @@ -90,7 +90,7 @@ namespace api { result = m.mk_app(f, num_args, args); } } - virtual void reduce_assign(func_decl* f, unsigned num_args, expr * const* args, unsigned num_out, expr* const* outs) { + void reduce_assign(func_decl* f, unsigned num_args, expr * const* args, unsigned num_out, expr* const* outs) override { if (m_reduce_assign) { m_trail.push_back(f); for (unsigned i = 0; i < num_args; ++i) { diff --git a/src/api/api_datalog.h b/src/api/api_datalog.h index c8dbc4180..588ee02d3 100644 --- a/src/api/api_datalog.h +++ b/src/api/api_datalog.h @@ -38,7 +38,7 @@ struct Z3_fixedpoint_ref : public api::object { api::fixedpoint_context * m_datalog; params_ref m_params; Z3_fixedpoint_ref(api::context& c): api::object(c), m_datalog(0) {} - virtual ~Z3_fixedpoint_ref() { dealloc(m_datalog); } + ~Z3_fixedpoint_ref() override { dealloc(m_datalog); } }; inline Z3_fixedpoint_ref * to_fixedpoint(Z3_fixedpoint s) { return reinterpret_cast(s); } diff --git a/src/api/api_goal.h b/src/api/api_goal.h index 4e9729df5..3b109f8da 100644 --- a/src/api/api_goal.h +++ b/src/api/api_goal.h @@ -24,7 +24,7 @@ Revision History: struct Z3_goal_ref : public api::object { goal_ref m_goal; Z3_goal_ref(api::context& c) : api::object(c) {} - virtual ~Z3_goal_ref() {} + ~Z3_goal_ref() override {} }; inline Z3_goal_ref * to_goal(Z3_goal g) { return reinterpret_cast(g); } diff --git a/src/api/api_model.h b/src/api/api_model.h index 64427cfb8..1ab10da79 100644 --- a/src/api/api_model.h +++ b/src/api/api_model.h @@ -24,7 +24,7 @@ Revision History: struct Z3_model_ref : public api::object { model_ref m_model; Z3_model_ref(api::context& c): api::object(c) {} - virtual ~Z3_model_ref() {} + ~Z3_model_ref() override {} }; inline Z3_model_ref * to_model(Z3_model s) { return reinterpret_cast(s); } @@ -35,7 +35,7 @@ struct Z3_func_interp_ref : public api::object { model_ref m_model; // must have it to prevent reference to m_func_interp to be killed. func_interp * m_func_interp; Z3_func_interp_ref(api::context& c, model * m): api::object(c), m_model(m), m_func_interp(0) {} - virtual ~Z3_func_interp_ref() {} + ~Z3_func_interp_ref() override {} }; inline Z3_func_interp_ref * to_func_interp(Z3_func_interp s) { return reinterpret_cast(s); } @@ -47,7 +47,7 @@ struct Z3_func_entry_ref : public api::object { func_interp * m_func_interp; func_entry const * m_func_entry; Z3_func_entry_ref(api::context& c, model * m):api::object(c), m_model(m), m_func_interp(0), m_func_entry(0) {} - virtual ~Z3_func_entry_ref() {} + ~Z3_func_entry_ref() override {} }; inline Z3_func_entry_ref * to_func_entry(Z3_func_entry s) { return reinterpret_cast(s); } diff --git a/src/api/api_opt.cpp b/src/api/api_opt.cpp index 0d96a6719..72180388e 100644 --- a/src/api/api_opt.cpp +++ b/src/api/api_opt.cpp @@ -36,7 +36,7 @@ extern "C" { struct Z3_optimize_ref : public api::object { opt::context* m_opt; Z3_optimize_ref(api::context& c): api::object(c), m_opt(0) {} - virtual ~Z3_optimize_ref() { dealloc(m_opt); } + ~Z3_optimize_ref() override { dealloc(m_opt); } }; inline Z3_optimize_ref * to_optimize(Z3_optimize o) { return reinterpret_cast(o); } inline Z3_optimize of_optimize(Z3_optimize_ref * o) { return reinterpret_cast(o); } diff --git a/src/api/api_solver.h b/src/api/api_solver.h index 4f344a00d..3da702f1e 100644 --- a/src/api/api_solver.h +++ b/src/api/api_solver.h @@ -27,7 +27,7 @@ struct Z3_solver_ref : public api::object { params_ref m_params; symbol m_logic; Z3_solver_ref(api::context& c, solver_factory * f): api::object(c), m_solver_factory(f), m_solver(0), m_logic(symbol::null) {} - virtual ~Z3_solver_ref() {} + ~Z3_solver_ref() override {} }; inline Z3_solver_ref * to_solver(Z3_solver s) { return reinterpret_cast(s); } diff --git a/src/api/api_stats.h b/src/api/api_stats.h index 5ce616084..e5ad5d315 100644 --- a/src/api/api_stats.h +++ b/src/api/api_stats.h @@ -24,7 +24,7 @@ Revision History: struct Z3_stats_ref : public api::object { statistics m_stats; Z3_stats_ref(api::context& c): api::object(c) {} - virtual ~Z3_stats_ref() {} + ~Z3_stats_ref() override {} }; inline Z3_stats_ref * to_stats(Z3_stats s) { return reinterpret_cast(s); } diff --git a/src/api/api_tactic.h b/src/api/api_tactic.h index fd2f05185..cc5e55a4e 100644 --- a/src/api/api_tactic.h +++ b/src/api/api_tactic.h @@ -29,13 +29,13 @@ namespace api { struct Z3_tactic_ref : public api::object { tactic_ref m_tactic; Z3_tactic_ref(api::context& c): api::object(c) {} - virtual ~Z3_tactic_ref() {} + ~Z3_tactic_ref() override {} }; struct Z3_probe_ref : public api::object { probe_ref m_probe; Z3_probe_ref(api::context& c):api::object(c) {} - virtual ~Z3_probe_ref() {} + ~Z3_probe_ref() override {} }; inline Z3_tactic_ref * to_tactic(Z3_tactic g) { return reinterpret_cast(g); } @@ -52,7 +52,7 @@ struct Z3_apply_result_ref : public api::object { proof_converter_ref m_pc; expr_dependency_ref m_core; Z3_apply_result_ref(api::context& c, ast_manager & m); - virtual ~Z3_apply_result_ref() {} + ~Z3_apply_result_ref() override {} }; inline Z3_apply_result_ref * to_apply_result(Z3_apply_result g) { return reinterpret_cast(g); } diff --git a/src/api/api_util.h b/src/api/api_util.h index bc6781c2c..e2e4621d4 100644 --- a/src/api/api_util.h +++ b/src/api/api_util.h @@ -88,7 +88,7 @@ inline lbool to_lbool(Z3_lbool b) { return static_cast(b); } struct Z3_params_ref : public api::object { params_ref m_params; Z3_params_ref(api::context& c): api::object(c) {} - virtual ~Z3_params_ref() {} + ~Z3_params_ref() override {} }; inline Z3_params_ref * to_params(Z3_params p) { return reinterpret_cast(p); } @@ -98,7 +98,7 @@ inline params_ref to_param_ref(Z3_params p) { return p == 0 ? params_ref() : to_ struct Z3_param_descrs_ref : public api::object { param_descrs m_descrs; Z3_param_descrs_ref(api::context& c): api::object(c) {} - virtual ~Z3_param_descrs_ref() {} + ~Z3_param_descrs_ref() override {} }; inline Z3_param_descrs_ref * to_param_descrs(Z3_param_descrs p) { return reinterpret_cast(p); } diff --git a/src/ast/ast_trail.h b/src/ast/ast_trail.h index d5245bd77..78ef74a47 100644 --- a/src/ast/ast_trail.h +++ b/src/ast/ast_trail.h @@ -66,7 +66,7 @@ public: m.insert(s,t); } - virtual void undo(Ctx& ctx) { + void undo(Ctx& ctx) override { m_map.pop(); } }; diff --git a/src/interp/iz3proof_itp.cpp b/src/interp/iz3proof_itp.cpp index 32cb9cccb..bbeb8d072 100755 --- a/src/interp/iz3proof_itp.cpp +++ b/src/interp/iz3proof_itp.cpp @@ -211,7 +211,7 @@ class iz3proof_itp_impl : public iz3proof_itp { pivot literal, while the conclusion of premise2 should contain the pivot literal. */ - node make_resolution(ast pivot, const std::vector &conc, node premise1, node premise2) { + node make_resolution(ast pivot, const std::vector &conc, node premise1, node premise2) override { LitType lt = get_term_type(pivot); if(lt == LitA) return my_or(premise1,premise2); @@ -2146,7 +2146,7 @@ class iz3proof_itp_impl : public iz3proof_itp { } /** Make an assumption node. The given clause is assumed in the given frame. */ - virtual node make_assumption(int frame, const std::vector &assumption){ + node make_assumption(int frame, const std::vector &assumption) override { if(!weak){ if(pv->in_range(frame,rng)){ std::vector itp_clause; @@ -2219,7 +2219,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /** Make a modus-ponens node. This takes derivations of |- x and |- x = y and produces |- y */ - virtual node make_mp(const ast &p_eq_q, const ast &prem1, const ast &prem2){ + node make_mp(const ast &p_eq_q, const ast &prem1, const ast &prem2) override { /* Interpolate the axiom p, p=q -> q */ ast p = arg(p_eq_q,0); @@ -2281,7 +2281,7 @@ class iz3proof_itp_impl : public iz3proof_itp { } /** Make an axiom node. The conclusion must be an instance of an axiom. */ - virtual node make_axiom(const std::vector &conclusion, prover::range frng){ + node make_axiom(const std::vector &conclusion, prover::range frng) override { int nargs = conclusion.size(); std::vector largs(nargs); std::vector eqs; @@ -2306,20 +2306,20 @@ class iz3proof_itp_impl : public iz3proof_itp { return capture_localization(itp); } - virtual node make_axiom(const std::vector &conclusion){ + node make_axiom(const std::vector &conclusion) override { return make_axiom(conclusion,pv->range_full()); } /** Make a Contra node. This rule takes a derivation of the form Gamma |- False and produces |- \/~Gamma. */ - virtual node make_contra(node prem, const std::vector &conclusion){ + node make_contra(node prem, const std::vector &conclusion) override { return prem; } /** Make hypothesis. Creates a node of the form P |- P. */ - virtual node make_hypothesis(const ast &P){ + node make_hypothesis(const ast &P) override { if(is_not(P)) return make_hypothesis(arg(P,0)); switch(get_term_type(P)){ @@ -2354,7 +2354,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /** Make a Reflexivity node. This rule produces |- x = x */ - virtual node make_reflexivity(ast con){ + node make_reflexivity(ast con) override { if(get_term_type(con) == LitA) return mk_false(); if(get_term_type(con) == LitB) @@ -2367,7 +2367,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /** Make a Symmetry node. This takes a derivation of |- x = y and produces | y = x. Ditto for ~(x=y) */ - virtual node make_symmetry(ast con, const ast &premcon, node prem){ + node make_symmetry(ast con, const ast &premcon, node prem) override { #if 0 ast x = arg(con,0); ast y = arg(con,1); @@ -2394,7 +2394,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /** Make a transitivity node. This takes derivations of |- x = y and |- y = z produces | x = z */ - virtual node make_transitivity(const ast &x, const ast &y, const ast &z, node prem1, node prem2){ + node make_transitivity(const ast &x, const ast &y, const ast &z, node prem1, node prem2) override { /* Interpolate the axiom x=y,y=z,-> x=z */ ast p = make_equiv_rel(x,y); @@ -2413,7 +2413,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /** Make a congruence node. This takes derivations of |- x_i = y_i and produces |- f(x_1,...,x_n) = f(y_1,...,y_n) */ - virtual node make_congruence(const ast &p, const ast &con, const ast &prem1){ + node make_congruence(const ast &p, const ast &con, const ast &prem1) override { ast x = arg(p,0), y = arg(p,1); ast itp; LitType con_t = get_term_type(con); @@ -2454,7 +2454,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /** Make a congruence node. This takes derivations of |- x_i1 = y_i1, |- x_i2 = y_i2,... and produces |- f(...x_i1...x_i2...) = f(...y_i1...y_i2...) */ - node make_congruence(const std::vector &p, const ast &con, const std::vector &prems){ + node make_congruence(const std::vector &p, const ast &con, const std::vector &prems) override { if(p.size() == 0) throw proof_error(); if(p.size() == 1) @@ -2516,8 +2516,8 @@ class iz3proof_itp_impl : public iz3proof_itp { /** Make a farkas proof node. */ - virtual node make_farkas(ast con, const std::vector &prems, const std::vector &prem_cons, - const std::vector &coeffs){ + node make_farkas(ast con, const std::vector &prems, const std::vector &prem_cons, + const std::vector &coeffs) override { /* Compute the interpolant for the clause */ @@ -2619,7 +2619,7 @@ class iz3proof_itp_impl : public iz3proof_itp { } /* Make an axiom instance of the form |- x<=y, y<= x -> x =y */ - virtual node make_leq2eq(ast x, ast y, const ast &xleqy, const ast &yleqx){ + node make_leq2eq(ast x, ast y, const ast &xleqy, const ast &yleqx) override { ast con = make(Equal,x,y); ast itp; switch(get_term_type(con)){ @@ -2658,7 +2658,7 @@ class iz3proof_itp_impl : public iz3proof_itp { } /* Make an axiom instance of the form |- x = y -> x <= y */ - virtual node make_eq2leq(ast x, ast y, const ast &xleqy){ + node make_eq2leq(ast x, ast y, const ast &xleqy) override { ast itp; switch(get_term_type(xleqy)){ case LitA: @@ -2681,7 +2681,7 @@ class iz3proof_itp_impl : public iz3proof_itp { /* Make an inference of the form t <= c |- t/d <= floor(c/d) where t is an affine term divisble by d and c is an integer constant */ - virtual node make_cut_rule(const ast &tleqc, const ast &d, const ast &con, const ast &prem){ + node make_cut_rule(const ast &tleqc, const ast &d, const ast &con, const ast &prem) override { ast itp = mk_false(); switch(get_term_type(con)){ case LitA: @@ -2965,7 +2965,7 @@ class iz3proof_itp_impl : public iz3proof_itp { } /* Return an interpolant from a proof of false */ - ast interpolate(const node &pf){ + ast interpolate(const node &pf) override { // proof of false must be a formula, with quantified symbols #ifndef BOGUS_QUANTS return close_universally(add_quants(z3_simplify(pf))); @@ -3089,7 +3089,7 @@ public: m().inc_ref(sexists); } - ~iz3proof_itp_impl(){ + ~iz3proof_itp_impl() override { m().dec_ref(contra); m().dec_ref(sum); m().dec_ref(rotate_sum); diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp index 32b76b224..4196d2016 100755 --- a/src/interp/iz3translate.cpp +++ b/src/interp/iz3translate.cpp @@ -2068,7 +2068,7 @@ public: // We actually compute the interpolant here and then produce a proof consisting of just a lemma - iz3proof::node translate(ast proof, iz3proof &dst){ + iz3proof::node translate(ast proof, iz3proof &dst) override { std::vector itps; scan_skolems(proof); for(int i = 0; i < frames -1; i++){ @@ -2114,7 +2114,7 @@ public: m().inc_ref(commute); } - ~iz3translation_full(){ + ~iz3translation_full() override { m().dec_ref(commute); } }; diff --git a/src/interp/iz3translate_direct.cpp b/src/interp/iz3translate_direct.cpp index e71475e45..0d5b9ccc3 100755 --- a/src/interp/iz3translate_direct.cpp +++ b/src/interp/iz3translate_direct.cpp @@ -1611,7 +1611,7 @@ public: // 1) Translate ast proof term to Zproof // 2) Translate Zproof to Iproof - Iproof::node translate(ast proof, Iproof &dst){ + Iproof::node translate(ast proof, Iproof &dst) override { iproof = &dst; Iproof::node Ipf = translate_main(proof,0); // builds result in dst return Ipf; @@ -1629,7 +1629,7 @@ public: traced_lit = ast(); } - ~iz3translation_direct(){ + ~iz3translation_direct() override { for(hash_map::iterator it = non_local_lits_unique.begin(), en = non_local_lits_unique.end(); diff --git a/src/math/hilbert/heap_trie.h b/src/math/hilbert/heap_trie.h index ace5381b8..e53f9e7dc 100644 --- a/src/math/hilbert/heap_trie.h +++ b/src/math/hilbert/heap_trie.h @@ -81,14 +81,14 @@ class heap_trie { Value m_value; public: leaf(): node(leaf_t) {} - virtual ~leaf() {} + ~leaf() override {} Value const& get_value() const { return m_value; } void set_value(Value const& v) { m_value = v; } - virtual void display(std::ostream& out, unsigned indent) const { + void display(std::ostream& out, unsigned indent) const override { out << " value: " << m_value; } - virtual unsigned num_nodes() const { return 1; } - virtual unsigned num_leaves() const { return this->ref_count()>0?1:0; } + unsigned num_nodes() const override { return 1; } + unsigned num_leaves() const override { return this->ref_count()>0?1:0; } }; typedef buffer, true, 2> children_t; @@ -99,7 +99,7 @@ class heap_trie { public: trie(): node(trie_t) {} - virtual ~trie() { + ~trie() override { } node* find_or_insert(Key k, node* n) { @@ -137,7 +137,7 @@ class heap_trie { children_t const& nodes() const { return m_nodes; } children_t & nodes() { return m_nodes; } - virtual void display(std::ostream& out, unsigned indent) const { + void display(std::ostream& out, unsigned indent) const override { for (unsigned j = 0; j < m_nodes.size(); ++j) { if (j != 0 || indent > 0) { out << "\n"; @@ -151,7 +151,7 @@ class heap_trie { } } - virtual unsigned num_nodes() const { + unsigned num_nodes() const override { unsigned sz = 1; for (unsigned j = 0; j < m_nodes.size(); ++j) { sz += m_nodes[j].second->num_nodes(); @@ -159,7 +159,7 @@ class heap_trie { return sz; } - virtual unsigned num_leaves() const { + unsigned num_leaves() const override { unsigned sz = 0; for (unsigned j = 0; j < m_nodes.size(); ++j) { sz += m_nodes[j].second->num_leaves(); diff --git a/src/math/hilbert/hilbert_basis.cpp b/src/math/hilbert/hilbert_basis.cpp index 9baa0beac..bbc56bdd5 100644 --- a/src/math/hilbert/hilbert_basis.cpp +++ b/src/math/hilbert/hilbert_basis.cpp @@ -175,7 +175,7 @@ class hilbert_basis::value_index2 { hilbert_basis* hb; offset_t m_value; checker(): hb(0) {} - virtual bool operator()(unsigned const& v) { + bool operator()(unsigned const& v) override { if (m_value.m_offset != v) { // && hb->is_subsumed(m_value, offset_t(v))) { return true; } diff --git a/src/math/polynomial/algebraic_numbers.cpp b/src/math/polynomial/algebraic_numbers.cpp index 9484c3c83..8c42bb418 100644 --- a/src/math/polynomial/algebraic_numbers.cpp +++ b/src/math/polynomial/algebraic_numbers.cpp @@ -1932,9 +1932,9 @@ namespace algebraic_numbers { imp & m_imp; polynomial::var2anum const & m_x2v; opt_var2basic(imp & i, polynomial::var2anum const & x2v):m_imp(i), m_x2v(x2v) {} - virtual unsynch_mpq_manager & m() const { return m_imp.qm(); } - virtual bool contains(polynomial::var x) const { return m_x2v.contains(x); } - virtual mpq const & operator()(polynomial::var x) const { + unsynch_mpq_manager & m() const override { return m_imp.qm(); } + bool contains(polynomial::var x) const override { return m_x2v.contains(x); } + mpq const & operator()(polynomial::var x) const override { anum const & v = m_x2v(x); if (!v.is_basic()) throw failed(); @@ -1949,9 +1949,9 @@ namespace algebraic_numbers { imp & m_imp; polynomial::var2anum const & m_x2v; var2basic(imp & i, polynomial::var2anum const & x2v):m_imp(i), m_x2v(x2v) {} - virtual unsynch_mpq_manager & m() const { return m_imp.qm(); } - virtual bool contains(polynomial::var x) const { return m_x2v.contains(x) && m_x2v(x).is_basic(); } - virtual mpq const & operator()(polynomial::var x) const { + unsynch_mpq_manager & m() const override { return m_imp.qm(); } + bool contains(polynomial::var x) const override { return m_x2v.contains(x) && m_x2v(x).is_basic(); } + mpq const & operator()(polynomial::var x) const override { anum const & v = m_x2v(x); SASSERT(v.is_basic()); TRACE("var2basic", tout << "getting value of x" << x << " -> " << m().to_string(m_imp.basic_value(v)) << "\n";); @@ -1966,9 +1966,9 @@ namespace algebraic_numbers { imp & m_imp; polynomial::var2anum const & m_x2v; var2interval(imp & i, polynomial::var2anum const & x2v):m_imp(i), m_x2v(x2v) {} - virtual mpbqi_manager & m() const { return m_imp.bqim(); } - virtual bool contains(polynomial::var x) const { return m_x2v.contains(x) && !m_x2v(x).is_basic(); } - virtual mpbqi const & operator()(polynomial::var x) const { + mpbqi_manager & m() const override { return m_imp.bqim(); } + bool contains(polynomial::var x) const override { return m_x2v.contains(x) && !m_x2v(x).is_basic(); } + mpbqi const & operator()(polynomial::var x) const override { anum const & v = m_x2v(x); SASSERT(!v.is_basic()); return v.to_algebraic()->m_interval; @@ -2220,9 +2220,9 @@ namespace algebraic_numbers { m_x(x), m_v(v) { } - virtual manager & m() const { return m_am; } - virtual bool contains(polynomial::var x) const { return x == m_x || m_x2v.contains(x); } - virtual anum const & operator()(polynomial::var x) const { + manager & m() const override { return m_am; } + bool contains(polynomial::var x) const override { return x == m_x || m_x2v.contains(x); } + anum const & operator()(polynomial::var x) const override { if (x == m_x) return m_v; else @@ -2553,9 +2553,9 @@ namespace algebraic_numbers { m_x2v(x2v), m_v(v) { } - virtual manager & m() const { return m_am; } - virtual bool contains(polynomial::var x) const { return true; } - virtual anum const & operator()(polynomial::var x) const { + manager & m() const override { return m_am; } + bool contains(polynomial::var x) const override { return true; } + anum const & operator()(polynomial::var x) const override { if (m_x2v.contains(x)) return m_x2v(x); else diff --git a/src/math/polynomial/polynomial.cpp b/src/math/polynomial/polynomial.cpp index dcd5af1cc..d6eafac05 100644 --- a/src/math/polynomial/polynomial.cpp +++ b/src/math/polynomial/polynomial.cpp @@ -6350,9 +6350,9 @@ namespace polynomial { m_var_pos(buffer, xs_sz, xs), m_vs(vs) { } - virtual unsynch_mpq_manager & m() const { UNREACHABLE(); static unsynch_mpq_manager m; return m; } - virtual bool contains(var x) const { return m_var_pos(x) != UINT_MAX; } - virtual mpq const & operator()(var x) const { return m_vs[m_var_pos(x)]; } + unsynch_mpq_manager & m() const override { UNREACHABLE(); static unsynch_mpq_manager m; return m; } + bool contains(var x) const override { return m_var_pos(x) != UINT_MAX; } + mpq const & operator()(var x) const override { return m_vs[m_var_pos(x)]; } }; polynomial * substitute(polynomial const * p, unsigned xs_sz, var const * xs, mpq const * vs) { @@ -6527,9 +6527,9 @@ namespace polynomial { numeral const & m_val; public: single_var2value(numeral_manager & m, var x, numeral const & val):m_manager(m), m_x(x), m_val(val) {} - virtual numeral_manager & m() const { return m_manager; } - virtual bool contains(var x) const { return m_x == x; } - virtual numeral const & operator()(var x) const { SASSERT(m_x == x); return m_val; } + numeral_manager & m() const override { return m_manager; } + bool contains(var x) const override { return m_x == x; } + numeral const & operator()(var x) const override { SASSERT(m_x == x); return m_val; } }; void univ_eval(polynomial const * p, var x, numeral const & val, numeral & r) { diff --git a/src/math/polynomial/upolynomial_factorization_int.h b/src/math/polynomial/upolynomial_factorization_int.h index ea2b51d8f..e422c15a6 100644 --- a/src/math/polynomial/upolynomial_factorization_int.h +++ b/src/math/polynomial/upolynomial_factorization_int.h @@ -322,7 +322,7 @@ namespace upolynomial { /** \brief Filter the ones not in the degree set. */ - bool filter_current() const { + bool filter_current() const override { // select only the ones that have degrees in the degree set if (!m_degree_set.in_set(current_degree())) { diff --git a/src/math/realclosure/realclosure.cpp b/src/math/realclosure/realclosure.cpp index 8f2d933e2..3f399990d 100644 --- a/src/math/realclosure/realclosure.cpp +++ b/src/math/realclosure/realclosure.cpp @@ -344,13 +344,13 @@ namespace realclosure { // --------------------------------- struct mk_pi_interval : public mk_interval { - virtual void operator()(unsigned k, mpqi_manager & im, mpqi_manager::interval & r) { + void operator()(unsigned k, mpqi_manager & im, mpqi_manager::interval & r) override { im.pi(k, r); } }; struct mk_e_interval : public mk_interval { - virtual void operator()(unsigned k, mpqi_manager & im, mpqi_manager::interval & r) { + void operator()(unsigned k, mpqi_manager & im, mpqi_manager::interval & r) override { im.e(k, r); } }; diff --git a/src/math/subpaving/subpaving.cpp b/src/math/subpaving/subpaving.cpp index 96fc5b6d7..1f32a6189 100644 --- a/src/math/subpaving/subpaving.cpp +++ b/src/math/subpaving/subpaving.cpp @@ -38,22 +38,22 @@ namespace subpaving { CTX m_ctx; public: context_wrapper(reslimit& lim, typename CTX::numeral_manager & m, params_ref const & p, small_object_allocator * a):m_ctx(lim, m, p, a) {} - virtual ~context_wrapper() {} - virtual unsigned num_vars() const { return m_ctx.num_vars(); } - virtual var mk_var(bool is_int) { return m_ctx.mk_var(is_int); } - virtual bool is_int(var x) const { return m_ctx.is_int(x); } - virtual var mk_monomial(unsigned sz, power const * pws) { return m_ctx.mk_monomial(sz, pws); } - virtual void inc_ref(ineq * a) { m_ctx.inc_ref(reinterpret_cast(a)); } - virtual void dec_ref(ineq * a) { m_ctx.dec_ref(reinterpret_cast(a)); } - virtual void add_clause(unsigned sz, ineq * const * atoms) { m_ctx.add_clause(sz, reinterpret_cast(atoms)); } - virtual void display_constraints(std::ostream & out, bool use_star) const { m_ctx.display_constraints(out, use_star); } - virtual void set_display_proc(display_var_proc * p) { m_ctx.set_display_proc(p); } - virtual void reset_statistics() { m_ctx.reset_statistics(); } - virtual void collect_statistics(statistics & st) const { m_ctx.collect_statistics(st); } - virtual void collect_param_descrs(param_descrs & r) { m_ctx.collect_param_descrs(r); } - virtual void updt_params(params_ref const & p) { m_ctx.updt_params(p); } - virtual void operator()() { m_ctx(); } - virtual void display_bounds(std::ostream & out) const { m_ctx.display_bounds(out); } + ~context_wrapper() override {} + unsigned num_vars() const override { return m_ctx.num_vars(); } + var mk_var(bool is_int) override { return m_ctx.mk_var(is_int); } + bool is_int(var x) const override { return m_ctx.is_int(x); } + var mk_monomial(unsigned sz, power const * pws) override { return m_ctx.mk_monomial(sz, pws); } + void inc_ref(ineq * a) override { m_ctx.inc_ref(reinterpret_cast(a)); } + void dec_ref(ineq * a) override { m_ctx.dec_ref(reinterpret_cast(a)); } + void add_clause(unsigned sz, ineq * const * atoms) override { m_ctx.add_clause(sz, reinterpret_cast(atoms)); } + void display_constraints(std::ostream & out, bool use_star) const override { m_ctx.display_constraints(out, use_star); } + void set_display_proc(display_var_proc * p) override { m_ctx.set_display_proc(p); } + void reset_statistics() override { m_ctx.reset_statistics(); } + void collect_statistics(statistics & st) const override { m_ctx.collect_statistics(st); } + void collect_param_descrs(param_descrs & r) override { m_ctx.collect_param_descrs(r); } + void updt_params(params_ref const & p) override { m_ctx.updt_params(p); } + void operator()() override { m_ctx(); } + void display_bounds(std::ostream & out) const override { m_ctx.display_bounds(out); } }; class context_mpq_wrapper : public context_wrapper { @@ -66,11 +66,11 @@ namespace subpaving { m_as(m) {} - virtual ~context_mpq_wrapper() {} + ~context_mpq_wrapper() override {} - virtual unsynch_mpq_manager & qm() const { return m_ctx.nm(); } + unsynch_mpq_manager & qm() const override { return m_ctx.nm(); } - virtual var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) { + var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override { m_as.reserve(sz); for (unsigned i = 0; i < sz; i++) { m_ctx.nm().set(m_as[i], as[i]); @@ -78,7 +78,7 @@ namespace subpaving { m_ctx.nm().set(m_c, c); return m_ctx.mk_sum(m_c, sz, m_as.c_ptr(), xs); } - virtual ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) { + ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override { return reinterpret_cast(m_ctx.mk_ineq(x, k, lower, open)); } }; @@ -108,11 +108,11 @@ namespace subpaving { m_q2(m_qm) { } - virtual ~context_mpf_wrapper() {} + ~context_mpf_wrapper() override {} - virtual unsynch_mpq_manager & qm() const { return m_qm; } + unsynch_mpq_manager & qm() const override { return m_qm; } - virtual var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) { + var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override { try { m_as.reserve(sz); for (unsigned i = 0; i < sz; i++) { @@ -125,7 +125,7 @@ namespace subpaving { throw subpaving::exception(); } } - virtual ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) { + ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override { try { f2n & m = m_ctx.nm(); if (lower) @@ -165,11 +165,11 @@ namespace subpaving { m_qm(qm) { } - virtual ~context_hwf_wrapper() {} + ~context_hwf_wrapper() override {} - virtual unsynch_mpq_manager & qm() const { return m_qm; } + unsynch_mpq_manager & qm() const override { return m_qm; } - virtual var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) { + var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override { try { m_as.reserve(sz); for (unsigned i = 0; i < sz; i++) { @@ -182,7 +182,7 @@ namespace subpaving { throw subpaving::exception(); } } - virtual ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) { + ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override { try { f2n & m = m_ctx.nm(); if (lower) @@ -223,11 +223,11 @@ namespace subpaving { m_z2(m_qm) { } - virtual ~context_fpoint_wrapper() {} + ~context_fpoint_wrapper() override {} - virtual unsynch_mpq_manager & qm() const { return m_qm; } + unsynch_mpq_manager & qm() const override { return m_qm; } - virtual var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) { + var mk_sum(mpz const & c, unsigned sz, mpz const * as, var const * xs) override { try { m_as.reserve(sz); for (unsigned i = 0; i < sz; i++) { @@ -241,7 +241,7 @@ namespace subpaving { } } - virtual ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) { + ineq * mk_ineq(var x, mpq const & k, bool lower, bool open) override { try { typename context_fpoint::numeral_manager & m = this->m_ctx.nm(); if (lower) diff --git a/src/math/subpaving/subpaving_t_def.h b/src/math/subpaving/subpaving_t_def.h index 3574787d8..5729cbfa0 100644 --- a/src/math/subpaving/subpaving_t_def.h +++ b/src/math/subpaving/subpaving_t_def.h @@ -36,7 +36,7 @@ public: context_t::node_selector(ctx) { } - virtual node * operator()(node * front, node * back) { + node * operator()(node * front, node * back) override { return back; } }; @@ -80,7 +80,7 @@ public: } // Return the next variable to branch. - virtual var operator()(typename context_t::node * n) { + var operator()(typename context_t::node * n) override { typename context_t::numeral_manager & nm = this->ctx()->nm(); SASSERT(this->ctx()->num_vars() > 0); var x = this->ctx()->splitting_var(n); @@ -197,7 +197,7 @@ public: SASSERT(m_delta < INT_MAX); } - virtual void operator()(node * n, var x) { + void operator()(node * n, var x) override { SASSERT(!n->inconsistent()); numeral_manager & nm = this->ctx()->nm(); node * left = this->mk_node(n); diff --git a/src/math/subpaving/tactic/subpaving_tactic.cpp b/src/math/subpaving/tactic/subpaving_tactic.cpp index 6a7bc11e8..ebc9356d9 100644 --- a/src/math/subpaving/tactic/subpaving_tactic.cpp +++ b/src/math/subpaving/tactic/subpaving_tactic.cpp @@ -40,7 +40,7 @@ class subpaving_tactic : public tactic { ast_manager & m() const { return m_inv.get_manager(); } - virtual void operator()(std::ostream & out, subpaving::var x) const { + void operator()(std::ostream & out, subpaving::var x) const override { expr * t = m_inv.get(x, 0); if (t != 0) out << mk_ismt2_pp(t, m()); @@ -216,36 +216,36 @@ public: m_params(p) { } - virtual ~subpaving_tactic() { + ~subpaving_tactic() override { dealloc(m_imp); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(subpaving_tactic, m, m_params); } - 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 { m_imp->collect_param_descrs(r); } - 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(); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { m_imp->process(*in); m_imp->collect_statistics(m_stats); @@ -261,7 +261,7 @@ public: } } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m(); dealloc(m_imp); m_imp = alloc(imp, m, m_params); diff --git a/src/muz/base/dl_context.cpp b/src/muz/base/dl_context.cpp index 78860bdde..106c15d5f 100644 --- a/src/muz/base/dl_context.cpp +++ b/src/muz/base/dl_context.cpp @@ -90,10 +90,10 @@ namespace datalog { return idx; } - virtual unsigned get_constant_count() const { + unsigned get_constant_count() const override { return m_el_names.size(); } - virtual void print_element(finite_element el_num, std::ostream & out) { + void print_element(finite_element el_num, std::ostream & out) override { if (el_num>=m_el_names.size()) { out << el_num; return; @@ -132,10 +132,10 @@ namespace datalog { } return idx; } - virtual unsigned get_constant_count() const { + unsigned get_constant_count() const override { return m_el_names.size(); } - virtual void print_element(finite_element el_num, std::ostream & out) { + void print_element(finite_element el_num, std::ostream & out) override { if (el_num >= m_el_names.size()) { out << "get_name() << ":" << el_num << '>'; return; @@ -159,9 +159,9 @@ namespace datalog { public: restore_rules(rule_set& r): m_old_rules(alloc(rule_set, r)) {} - virtual ~restore_rules() {} + ~restore_rules() override {} - virtual void undo(context& ctx) { + void undo(context& ctx) override { ctx.replace_rules(*m_old_rules); reset(); } @@ -173,8 +173,8 @@ namespace datalog { unsigned m_old_size; public: restore_vec_size_trail(Vec& v): m_vector(v), m_old_size(v.size()) {} - virtual ~restore_vec_size_trail() {} - virtual void undo(Ctx& ctx) { m_vector.shrink(m_old_size); } + ~restore_vec_size_trail() override {} + void undo(Ctx& ctx) override { m_vector.shrink(m_old_size); } }; void context::push() { diff --git a/src/muz/base/dl_context.h b/src/muz/base/dl_context.h index 0fb68d396..3051dbf86 100644 --- a/src/muz/base/dl_context.h +++ b/src/muz/base/dl_context.h @@ -110,7 +110,7 @@ namespace datalog { class rel_context_base : public engine_base { public: rel_context_base(ast_manager& m, char const* name): engine_base(m, name) {} - virtual ~rel_context_base() {} + ~rel_context_base() override {} virtual relation_manager & get_rmanager() = 0; virtual const relation_manager & get_rmanager() const = 0; virtual relation_base & get_relation(func_decl * pred) = 0; @@ -146,9 +146,9 @@ namespace datalog { context const& ctx; public: contains_pred(context& ctx): ctx(ctx) {} - virtual ~contains_pred() {} + ~contains_pred() override {} - virtual bool operator()(expr* e) { + bool operator()(expr* e) override { return ctx.is_predicate(e); } }; diff --git a/src/muz/base/dl_util.cpp b/src/muz/base/dl_util.cpp index 715964e3a..aceeba364 100644 --- a/src/muz/base/dl_util.cpp +++ b/src/muz/base/dl_util.cpp @@ -385,7 +385,7 @@ namespace datalog { public: skip_model_converter() {} - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { return alloc(skip_model_converter); } @@ -394,12 +394,12 @@ namespace datalog { model_converter* mk_skip_model_converter() { return alloc(skip_model_converter); } class skip_proof_converter : public proof_converter { - virtual void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) { + void operator()(ast_manager & m, unsigned num_source, proof * const * source, proof_ref & result) override { SASSERT(num_source == 1); result = source[0]; } - virtual proof_converter * translate(ast_translation & translator) { + proof_converter * translate(ast_translation & translator) override { return alloc(skip_proof_converter); } diff --git a/src/muz/bmc/dl_bmc_engine.h b/src/muz/bmc/dl_bmc_engine.h index fd5ce92e6..a5824fa82 100644 --- a/src/muz/bmc/dl_bmc_engine.h +++ b/src/muz/bmc/dl_bmc_engine.h @@ -55,18 +55,18 @@ namespace datalog { public: bmc(context& ctx); - ~bmc(); + ~bmc() override; - lbool query(expr* query); + lbool query(expr* query) override; - void display_certificate(std::ostream& out) const; + void display_certificate(std::ostream& out) const override; - void collect_statistics(statistics& st) const; + void collect_statistics(statistics& st) const override; - void reset_statistics(); - void get_rules_along_trace(datalog::rule_ref_vector& rules); + void reset_statistics() override; + void get_rules_along_trace(datalog::rule_ref_vector& rules) override; - expr_ref get_answer(); + expr_ref get_answer() override; // direct access to (new) non-linear compiler. void compile(rule_set const& rules, expr_ref_vector& fmls, unsigned level); diff --git a/src/muz/clp/clp_context.h b/src/muz/clp/clp_context.h index 44f99d564..378fdd473 100644 --- a/src/muz/clp/clp_context.h +++ b/src/muz/clp/clp_context.h @@ -32,12 +32,12 @@ namespace datalog { imp* m_imp; public: clp(context& ctx); - ~clp(); - virtual lbool query(expr* query); - virtual void reset_statistics(); - virtual void collect_statistics(statistics& st) const; - virtual void display_certificate(std::ostream& out) const; - virtual expr_ref get_answer(); + ~clp() override; + lbool query(expr* query) override; + void reset_statistics() override; + void collect_statistics(statistics& st) const override; + void display_certificate(std::ostream& out) const override; + expr_ref get_answer() override; }; }; diff --git a/src/muz/ddnf/ddnf.h b/src/muz/ddnf/ddnf.h index 29e9b1555..14c9f3cc7 100644 --- a/src/muz/ddnf/ddnf.h +++ b/src/muz/ddnf/ddnf.h @@ -35,12 +35,12 @@ namespace datalog { imp* m_imp; public: ddnf(context& ctx); - ~ddnf(); - virtual lbool query(expr* query); - virtual void reset_statistics(); - virtual void collect_statistics(statistics& st) const; - virtual void display_certificate(std::ostream& out) const; - virtual expr_ref get_answer(); + ~ddnf() override; + lbool query(expr* query) override; + void reset_statistics() override; + void collect_statistics(statistics& st) const override; + void display_certificate(std::ostream& out) const override; + expr_ref get_answer() override; }; class ddnf_node; diff --git a/src/muz/duality/duality_dl_interface.h b/src/muz/duality/duality_dl_interface.h index 506642217..8178618ae 100644 --- a/src/muz/duality/duality_dl_interface.h +++ b/src/muz/duality/duality_dl_interface.h @@ -41,33 +41,33 @@ namespace Duality { public: dl_interface(datalog::context& ctx); - ~dl_interface(); + ~dl_interface() override; - lbool query(expr* query); + lbool query(expr* query) override; - void cancel(); + void cancel() override; - void cleanup(); + void cleanup() override; - void display_certificate(std::ostream& out) const; + void display_certificate(std::ostream& out) const override; - void collect_statistics(statistics& st) const; + void collect_statistics(statistics& st) const override; - void reset_statistics(); + void reset_statistics() override; - expr_ref get_answer(); + expr_ref get_answer() override; - unsigned get_num_levels(func_decl* pred); + unsigned get_num_levels(func_decl* pred) override; - expr_ref get_cover_delta(int level, func_decl* pred); + expr_ref get_cover_delta(int level, func_decl* pred) override; - void add_cover(int level, func_decl* pred, expr* property); + void add_cover(int level, func_decl* pred, expr* property) override; - void updt_params(); + void updt_params() override; - model_ref get_model(); + model_ref get_model() override; - proof_ref get_proof(); + proof_ref get_proof() override; duality_data *dd(){return _d;} diff --git a/src/muz/fp/datalog_parser.cpp b/src/muz/fp/datalog_parser.cpp index f839c5c5a..fd3eae944 100644 --- a/src/muz/fp/datalog_parser.cpp +++ b/src/muz/fp/datalog_parser.cpp @@ -494,7 +494,7 @@ public: { } - virtual bool parse_file(char const * filename) { + bool parse_file(char const * filename) override { reset(); if (filename != 0) { set_path(filename); @@ -510,7 +510,7 @@ public: } } - virtual bool parse_string(char const * string) { + bool parse_string(char const * string) override { reset(); std::string s(string); std::istringstream is(s); @@ -1200,13 +1200,13 @@ public: m_short_sort(ctx.get_manager()), m_use_map_names(ctx.use_map_names()) { } - ~wpa_parser_impl() { + ~wpa_parser_impl() override { reset_dealloc_values(m_sort_contents); } void reset() { } - virtual bool parse_directory(char const * path) { + bool parse_directory(char const * path) override { bool result = false; try { result = parse_directory_core(path); diff --git a/src/muz/fp/dl_cmds.cpp b/src/muz/fp/dl_cmds.cpp index 2610f821c..deb8887ec 100644 --- a/src/muz/fp/dl_cmds.cpp +++ b/src/muz/fp/dl_cmds.cpp @@ -166,10 +166,10 @@ public: m_arg_idx(0), m_t(0), m_bound(UINT_MAX) {} - virtual char const * get_usage() const { return "(forall (q) (=> (and body) head)) :optional-name :optional-recursion-bound"; } - virtual char const * get_descr(cmd_context & ctx) const { return "add a Horn rule."; } - virtual unsigned get_arity() const { return VAR_ARITY; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + char const * get_usage() const override { return "(forall (q) (=> (and body) head)) :optional-name :optional-recursion-bound"; } + char const * get_descr(cmd_context & ctx) const override { return "add a Horn rule."; } + unsigned get_arity() const override { return VAR_ARITY; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { switch(m_arg_idx) { case 0: return CPK_EXPR; case 1: return CPK_SYMBOL; @@ -177,23 +177,23 @@ public: default: return CPK_SYMBOL; } } - virtual void set_next_arg(cmd_context & ctx, expr * t) { + void set_next_arg(cmd_context & ctx, expr * t) override { m_t = t; m_arg_idx++; } - virtual void set_next_arg(cmd_context & ctx, symbol const & s) { + void set_next_arg(cmd_context & ctx, symbol const & s) override { m_name = s; m_arg_idx++; } - virtual void set_next_arg(cmd_context & ctx, unsigned bound) { + void set_next_arg(cmd_context & ctx, unsigned bound) override { m_bound = bound; m_arg_idx++; } - virtual void reset(cmd_context & ctx) { m_dl_ctx->reset(); prepare(ctx); m_t = nullptr; } - virtual void prepare(cmd_context& ctx) { m_arg_idx = 0; m_name = symbol::null; m_bound = UINT_MAX; } - virtual void finalize(cmd_context & ctx) { + void reset(cmd_context & ctx) override { m_dl_ctx->reset(); prepare(ctx); m_t = nullptr; } + void prepare(cmd_context& ctx) override { m_arg_idx = 0; m_name = symbol::null; m_bound = UINT_MAX; } + void finalize(cmd_context & ctx) override { } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { if (!m_t) throw cmd_exception("invalid rule, expected formula"); m_dl_ctx->add_rule(m_t, m_name, m_bound); } @@ -208,17 +208,17 @@ public: m_dl_ctx(dl_ctx), m_target(0) { } - virtual char const * get_usage() const { return "predicate"; } - virtual char const * get_main_descr() const { + char const * get_usage() const override { return "predicate"; } + char const * get_main_descr() const override { return "pose a query to a predicate based on the Horn rules."; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_target == 0) return CPK_FUNC_DECL; return parametric_cmd::next_arg_kind(ctx); } - virtual void set_next_arg(cmd_context & ctx, func_decl* t) { + void set_next_arg(cmd_context & ctx, func_decl* t) override { m_target = t; if (t->get_family_id() != null_family_id) { throw cmd_exception("Invalid query argument, expected uinterpreted function name, but argument is interpreted"); @@ -229,13 +229,13 @@ public: } } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { ctx.m(); // ensure manager is initialized. parametric_cmd::prepare(ctx); m_target = 0; } - virtual void execute(cmd_context& ctx) { + void execute(cmd_context& ctx) override { if (m_target == 0) { throw cmd_exception("invalid query command, argument expected"); } @@ -321,7 +321,7 @@ public: m_target = 0; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { m_dl_ctx->dlctx().collect_params(p); } @@ -385,30 +385,30 @@ public: m_dl_ctx(dl_ctx), m_domain(0) {} - virtual char const * get_usage() const { return " ( ...) *"; } - virtual char const * get_descr(cmd_context & ctx) const { return "declare new relation"; } - virtual unsigned get_arity() const { return VAR_ARITY; } + char const * get_usage() const override { return " ( ...) *"; } + char const * get_descr(cmd_context & ctx) const override { return "declare new relation"; } + unsigned get_arity() const override { return VAR_ARITY; } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { ctx.m(); // ensure manager is initialized. m_arg_idx = 0; m_query_arg_idx = 0; m_domain.reset(); m_kinds.reset(); } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { switch(m_query_arg_idx++) { case 0: return CPK_SYMBOL; // relation name case 1: return CPK_SORT_LIST; // arguments default: return CPK_SYMBOL; // optional representation specification } } - virtual void set_next_arg(cmd_context & ctx, unsigned num, sort * const * slist) { + void set_next_arg(cmd_context & ctx, unsigned num, sort * const * slist) override { m_domain.reset(); m_domain.append(num, slist); m_arg_idx++; } - virtual void set_next_arg(cmd_context & ctx, symbol const & s) { + void set_next_arg(cmd_context & ctx, symbol const & s) override { if(m_arg_idx==0) { m_rel_name = s; } @@ -418,7 +418,7 @@ public: } m_arg_idx++; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { if(m_arg_idx<2) { throw cmd_exception("at least 2 arguments expected"); } @@ -444,15 +444,15 @@ public: m_dl_ctx(dl_ctx) {} - virtual char const * get_usage() const { return " "; } - virtual char const * get_descr(cmd_context & ctx) const { return "declare constant as variable"; } - virtual unsigned get_arity() const { return 2; } + char const * get_usage() const override { return " "; } + char const * get_descr(cmd_context & ctx) const override { return "declare constant as variable"; } + unsigned get_arity() const override { return 2; } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { ctx.m(); // ensure manager is initialized. m_arg_idx = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { SASSERT(m_arg_idx <= 1); if (m_arg_idx == 0) { return CPK_SYMBOL; @@ -460,17 +460,17 @@ public: return CPK_SORT; } - virtual void set_next_arg(cmd_context & ctx, sort* s) { + void set_next_arg(cmd_context & ctx, sort* s) override { m_var_sort = s; ++m_arg_idx; } - virtual void set_next_arg(cmd_context & ctx, symbol const & s) { + void set_next_arg(cmd_context & ctx, symbol const & s) override { m_var_name = s; ++m_arg_idx; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { ast_manager& m = ctx.m(); func_decl_ref var(m.mk_func_decl(m_var_name, 0, static_cast(0), m_var_sort), m); ctx.insert(var); @@ -489,10 +489,10 @@ public: m_dl_ctx(dl_ctx) {} - virtual char const * get_usage() const { return ""; } - virtual char const * get_descr(cmd_context & ctx) const { return "push the fixedpoint context"; } - virtual unsigned get_arity() const { return 0; } - virtual void execute(cmd_context & ctx) { + char const * get_usage() const override { return ""; } + char const * get_descr(cmd_context & ctx) const override { return "push the fixedpoint context"; } + unsigned get_arity() const override { return 0; } + void execute(cmd_context & ctx) override { m_dl_ctx->push(); } }; @@ -508,10 +508,10 @@ public: m_dl_ctx(dl_ctx) {} - virtual char const * get_usage() const { return ""; } - virtual char const * get_descr(cmd_context & ctx) const { return "pop the fixedpoint context"; } - virtual unsigned get_arity() const { return 0; } - virtual void execute(cmd_context & ctx) { + char const * get_usage() const override { return ""; } + char const * get_descr(cmd_context & ctx) const override { return "pop the fixedpoint context"; } + unsigned get_arity() const override { return 0; } + void execute(cmd_context & ctx) override { m_dl_ctx->pop(); } }; diff --git a/src/muz/fp/dl_register_engine.h b/src/muz/fp/dl_register_engine.h index 11f778346..e401c141a 100644 --- a/src/muz/fp/dl_register_engine.h +++ b/src/muz/fp/dl_register_engine.h @@ -27,8 +27,8 @@ namespace datalog { context* m_ctx; public: register_engine(); - engine_base* mk_engine(DL_ENGINE engine_type); - void set_context(context* ctx) { m_ctx = ctx; } + engine_base* mk_engine(DL_ENGINE engine_type) override; + void set_context(context* ctx) override { m_ctx = ctx; } }; } diff --git a/src/muz/fp/horn_tactic.cpp b/src/muz/fp/horn_tactic.cpp index 5db57a12c..273489164 100644 --- a/src/muz/fp/horn_tactic.cpp +++ b/src/muz/fp/horn_tactic.cpp @@ -365,43 +365,43 @@ public: m_imp = alloc(imp, t, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(horn_tactic, m_is_simplify, m, m_params); } - virtual ~horn_tactic() { + ~horn_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 { m_imp->collect_param_descrs(r); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { m_imp->collect_statistics(st); st.copy(m_stats); } - virtual void reset_statistics() { + void reset_statistics() override { m_stats.reset(); m_imp->reset_statistics(); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; m_imp->collect_statistics(m_stats); dealloc(m_imp); diff --git a/src/muz/pdr/pdr_dl_interface.h b/src/muz/pdr/pdr_dl_interface.h index 884f89e4b..1a0b04635 100644 --- a/src/muz/pdr/pdr_dl_interface.h +++ b/src/muz/pdr/pdr_dl_interface.h @@ -47,29 +47,29 @@ namespace pdr { public: dl_interface(datalog::context& ctx); - ~dl_interface(); + ~dl_interface() override; - virtual lbool query(expr* query); + lbool query(expr* query) override; - virtual void display_certificate(std::ostream& out) const; + void display_certificate(std::ostream& out) const override; - virtual void collect_statistics(statistics& st) const; + void collect_statistics(statistics& st) const override; - virtual void reset_statistics(); + void reset_statistics() override; - virtual expr_ref get_answer(); + expr_ref get_answer() override; - virtual unsigned get_num_levels(func_decl* pred); + unsigned get_num_levels(func_decl* pred) override; - virtual expr_ref get_cover_delta(int level, func_decl* pred); + expr_ref get_cover_delta(int level, func_decl* pred) override; - virtual void add_cover(int level, func_decl* pred, expr* property); + void add_cover(int level, func_decl* pred, expr* property) override; - virtual void updt_params(); + void updt_params() override; - virtual model_ref get_model(); + model_ref get_model() override; - virtual proof_ref get_proof(); + proof_ref get_proof() override; }; } diff --git a/src/muz/pdr/pdr_generalizers.h b/src/muz/pdr/pdr_generalizers.h index e0feda310..a75b347a4 100644 --- a/src/muz/pdr/pdr_generalizers.h +++ b/src/muz/pdr/pdr_generalizers.h @@ -30,8 +30,8 @@ namespace pdr { unsigned m_failure_limit; public: core_bool_inductive_generalizer(context& ctx, unsigned failure_limit) : core_generalizer(ctx), m_failure_limit(failure_limit) {} - virtual ~core_bool_inductive_generalizer() {} - virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level); + ~core_bool_inductive_generalizer() override {} + void operator()(model_node& n, expr_ref_vector& core, bool& uses_level) override; }; template @@ -61,17 +61,17 @@ namespace pdr { bool substitute_alias(rational const&r, expr* x, expr* e, expr_ref& result); public: core_arith_inductive_generalizer(context& ctx); - virtual ~core_arith_inductive_generalizer() {} - virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level); + ~core_arith_inductive_generalizer() override {} + void operator()(model_node& n, expr_ref_vector& core, bool& uses_level) override; }; class core_farkas_generalizer : public core_generalizer { farkas_learner m_farkas_learner; public: core_farkas_generalizer(context& ctx, ast_manager& m, smt_params& p); - virtual ~core_farkas_generalizer() {} - virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level); - virtual void collect_statistics(statistics& st) const; + ~core_farkas_generalizer() override {} + void operator()(model_node& n, expr_ref_vector& core, bool& uses_level) override; + void collect_statistics(statistics& st) const override; }; @@ -85,26 +85,26 @@ namespace pdr { bool is_unsat(expr_ref_vector const& As, expr* B); public: core_convex_hull_generalizer(context& ctx, bool is_closure); - virtual ~core_convex_hull_generalizer() {} - virtual void operator()(model_node& n, expr_ref_vector const& core, bool uses_level, cores& new_cores); - virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level); + ~core_convex_hull_generalizer() override {} + void operator()(model_node& n, expr_ref_vector const& core, bool uses_level, cores& new_cores) override; + void operator()(model_node& n, expr_ref_vector& core, bool& uses_level) override; }; class core_multi_generalizer : public core_generalizer { core_bool_inductive_generalizer m_gen; public: core_multi_generalizer(context& ctx, unsigned max_failures): core_generalizer(ctx), m_gen(ctx, max_failures) {} - virtual ~core_multi_generalizer() {} - virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level); - virtual void operator()(model_node& n, expr_ref_vector const& core, bool uses_level, cores& new_cores); + ~core_multi_generalizer() override {} + void operator()(model_node& n, expr_ref_vector& core, bool& uses_level) override; + void operator()(model_node& n, expr_ref_vector const& core, bool uses_level, cores& new_cores) override; }; class core_induction_generalizer : public core_generalizer { class imp; public: core_induction_generalizer(context& ctx): core_generalizer(ctx) {} - virtual ~core_induction_generalizer() {} - virtual void operator()(model_node& n, expr_ref_vector& core, bool& uses_level); + ~core_induction_generalizer() override {} + void operator()(model_node& n, expr_ref_vector& core, bool& uses_level) override; }; }; #endif diff --git a/src/muz/pdr/pdr_smt_context_manager.h b/src/muz/pdr/pdr_smt_context_manager.h index 735b2cd62..747cd6457 100644 --- a/src/muz/pdr/pdr_smt_context_manager.h +++ b/src/muz/pdr/pdr_smt_context_manager.h @@ -59,15 +59,15 @@ namespace pdr { smt::kernel & m_context; public: _smt_context(smt::kernel & ctx, smt_context_manager& p, app* pred); - virtual ~_smt_context() {} - virtual void assert_expr(expr* e); - virtual lbool check(expr_ref_vector& assumptions); - virtual void get_model(model_ref& model); - virtual proof* get_proof(); - virtual void push() { m_context.push(); } - virtual void pop() { m_context.pop(1); } - virtual unsigned get_unsat_core_size() { return m_context.get_unsat_core_size(); } - virtual expr* get_unsat_core_expr(unsigned i) { return m_context.get_unsat_core_expr(i); } + ~_smt_context() override {} + void assert_expr(expr* e) override; + lbool check(expr_ref_vector& assumptions) override; + void get_model(model_ref& model) override; + proof* get_proof() override; + void push() override { m_context.push(); } + void pop() override { m_context.pop(1); } + unsigned get_unsat_core_size() override { return m_context.get_unsat_core_size(); } + expr* get_unsat_core_expr(unsigned i) override { return m_context.get_unsat_core_expr(i); } }; class smt_context_manager { diff --git a/src/muz/rel/check_relation.cpp b/src/muz/rel/check_relation.cpp index ddda295cd..a6298cf22 100644 --- a/src/muz/rel/check_relation.cpp +++ b/src/muz/rel/check_relation.cpp @@ -192,8 +192,8 @@ namespace datalog { const unsigned * cols1, const unsigned * cols2) : convenient_join_fn(o1_sig, o2_sig, col_cnt, cols1, cols2), m_join(j) {} - virtual ~join_fn() {} - virtual relation_base * operator()(const relation_base & r1, const relation_base & r2) { + ~join_fn() override {} + relation_base * operator()(const relation_base & r1, const relation_base & r2) override { check_relation const& t1 = get(r1); check_relation const& t2 = get(r2); check_relation_plugin& p = t1.get_plugin(); @@ -221,8 +221,8 @@ namespace datalog { : convenient_join_project_fn(o1_sig, o2_sig, col_cnt, cols1, cols2, removed_col_cnt, removed_cols), m_join(j) {} - virtual ~join_project_fn() {} - virtual relation_base * operator()(const relation_base & r1, const relation_base & r2) { + ~join_project_fn() override {} + relation_base * operator()(const relation_base & r1, const relation_base & r2) override { check_relation const& t1 = get(r1); check_relation const& t2 = get(r2); check_relation_plugin& p = t1.get_plugin(); @@ -491,7 +491,7 @@ namespace datalog { public: union_fn(relation_union_fn* m): m_union(m) {} - virtual void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) { + void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) override { TRACE("doc", _r.display(tout << "dst:\n"); _src.display(tout << "src:\n");); check_relation& r = get(_r); check_relation const& src = get(_src); @@ -529,9 +529,9 @@ namespace datalog { m_filter(f) { } - virtual ~filter_identical_fn() {} + ~filter_identical_fn() override {} - virtual void operator()(relation_base & _r) { + void operator()(relation_base & _r) override { check_relation& r = get(_r); check_relation_plugin& p = r.get_plugin(); ast_manager& m = p.m; @@ -565,9 +565,9 @@ namespace datalog { m_condition(condition) { } - virtual ~filter_interpreted_fn() {} + ~filter_interpreted_fn() override {} - virtual void operator()(relation_base & tb) { + void operator()(relation_base & tb) override { check_relation& r = get(tb); check_relation_plugin& p = r.get_plugin(); expr_ref fml = r.m_fml; @@ -592,9 +592,9 @@ namespace datalog { m_project(p) { } - virtual ~project_fn() {} + ~project_fn() override {} - virtual relation_base * operator()(const relation_base & tb) { + relation_base * operator()(const relation_base & tb) override { check_relation const& t = get(tb); check_relation_plugin& p = t.get_plugin(); relation_base* r = (*m_project)(t.rb()); @@ -620,9 +620,9 @@ namespace datalog { m_permute(permute) { } - virtual ~rename_fn() {} + ~rename_fn() override {} - virtual relation_base * operator()(const relation_base & _t) { + relation_base * operator()(const relation_base & _t) override { check_relation const& t = get(_t); check_relation_plugin& p = t.get_plugin(); relation_signature const& sig = get_result_signature(); @@ -649,8 +649,8 @@ namespace datalog { m_val(val), m_col(col) {} - virtual ~filter_equal_fn() { } - virtual void operator()(relation_base & tb) { + ~filter_equal_fn() override { } + void operator()(relation_base & tb) override { check_relation & t = get(tb); check_relation_plugin& p = t.get_plugin(); (*m_filter)(t.rb()); @@ -682,7 +682,7 @@ namespace datalog { SASSERT(joined_col_cnt > 0); } - virtual void operator()(relation_base& tb, const relation_base& negb) { + void operator()(relation_base& tb, const relation_base& negb) override { check_relation& t = get(tb); check_relation const& n = get(negb); check_relation_plugin& p = t.get_plugin(); @@ -763,9 +763,9 @@ namespace datalog { m_xform(xform) {} - virtual ~filter_proj_fn() {} + ~filter_proj_fn() override {} - virtual relation_base* operator()(const relation_base & tb) { + relation_base* operator()(const relation_base & tb) override { check_relation const & t = get(tb); check_relation_plugin& p = t.get_plugin(); relation_base* r = (*m_xform)(t.rb()); diff --git a/src/muz/rel/check_relation.h b/src/muz/rel/check_relation.h index 0fbb2a269..8fbce4184 100644 --- a/src/muz/rel/check_relation.h +++ b/src/muz/rel/check_relation.h @@ -38,20 +38,20 @@ namespace datalog { expr_ref mk_eq(relation_fact const& f) const; public: check_relation(check_relation_plugin& p, relation_signature const& s, relation_base* r); - virtual ~check_relation(); - virtual void reset(); - virtual void add_fact(const relation_fact & f); - virtual void add_new_fact(const relation_fact & f); - virtual bool contains_fact(const relation_fact & f) const; - virtual check_relation * clone() const; - virtual check_relation * complement(func_decl*) const; - virtual void to_formula(expr_ref& fml) const; + ~check_relation() override; + void reset() override; + void add_fact(const relation_fact & f) override; + void add_new_fact(const relation_fact & f) override; + bool contains_fact(const relation_fact & f) const override; + check_relation * clone() const override; + check_relation * complement(func_decl*) const override; + void to_formula(expr_ref& fml) const override; check_relation_plugin& get_plugin() const; - virtual bool fast_empty() const; - virtual bool empty() const; - virtual void display(std::ostream& out) const; - virtual bool is_precise() const { return m_relation->is_precise(); } - virtual unsigned get_size_estimate_rows() const { return m_relation->get_size_estimate_rows(); } + bool fast_empty() const override; + bool empty() const override; + void display(std::ostream& out) const override; + bool is_precise() const override { return m_relation->is_precise(); } + unsigned get_size_estimate_rows() const override { return m_relation->get_size_estimate_rows(); } relation_base& rb() { return *m_relation; } relation_base const& rb() const { return *m_relation; } expr_ref ground(expr* fml) const; @@ -90,39 +90,39 @@ namespace datalog { unsigned_vector const& cols1, unsigned_vector const& cols2); public: check_relation_plugin(relation_manager& rm); - ~check_relation_plugin(); + ~check_relation_plugin() override; void set_plugin(relation_plugin* p) { m_base = p; } - virtual bool can_handle_signature(const relation_signature & s); + bool can_handle_signature(const relation_signature & s) override; static symbol get_name() { return symbol("check_relation"); } - virtual relation_base * mk_empty(const relation_signature & s); - virtual relation_base * mk_full(func_decl* p, const relation_signature & s); - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_join_fn * mk_join_project_fn( + relation_base * mk_empty(const relation_signature & s) override; + relation_base * mk_full(func_decl* p, const relation_signature & s) override; + relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_join_fn * mk_join_project_fn( const relation_base & t1, const relation_base & t2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2, - unsigned removed_col_cnt, const unsigned * removed_cols); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); - virtual relation_intersection_filter_fn * mk_filter_by_negation_fn( + unsigned removed_col_cnt, const unsigned * removed_cols) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; + relation_intersection_filter_fn * mk_filter_by_negation_fn( const relation_base& t, const relation_base& neg, unsigned joined_col_cnt, const unsigned *t_cols, - const unsigned *negated_cols); - virtual relation_transformer_fn * mk_filter_interpreted_and_project_fn( + const unsigned *negated_cols) override; + relation_transformer_fn * mk_filter_interpreted_and_project_fn( const relation_base & t, app * condition, - unsigned removed_col_cnt, const unsigned * removed_cols); + unsigned removed_col_cnt, const unsigned * removed_cols) override; void verify_join(relation_base const& t1, relation_base const& t2, relation_base const& t, unsigned_vector const& cols1, unsigned_vector const& cols2); diff --git a/src/muz/rel/dl_base.cpp b/src/muz/rel/dl_base.cpp index 904faf71f..5ca84c895 100644 --- a/src/muz/rel/dl_base.cpp +++ b/src/muz/rel/dl_base.cpp @@ -423,17 +423,17 @@ namespace datalog { const row_interface & m_parent; unsigned m_index; protected: - virtual bool is_finished() const { return m_index==m_parent.size(); } + bool is_finished() const override { return m_index==m_parent.size(); } public: fact_row_iterator(const row_interface & row, bool finished) : m_parent(row), m_index(finished ? row.size() : 0) {} - virtual table_element operator*() { + table_element operator*() override { SASSERT(!is_finished()); return m_parent[m_index]; } - virtual void operator++() { + void operator++() override { m_index++; SASSERT(m_index<=m_parent.size()); } diff --git a/src/muz/rel/dl_base.h b/src/muz/rel/dl_base.h index 4e59e9258..277f37f70 100644 --- a/src/muz/rel/dl_base.h +++ b/src/muz/rel/dl_base.h @@ -220,7 +220,7 @@ namespace datalog { */ class mutator_fn : public base_fn { public: - virtual ~mutator_fn() {} + ~mutator_fn() override {} virtual void operator()(base_object & t) = 0; @@ -629,19 +629,19 @@ namespace datalog { class identity_transformer_fn : public transformer_fn { public: - virtual base_object * operator()(const base_object & t) { + base_object * operator()(const base_object & t) override { return t.clone(); } }; class identity_mutator_fn : public mutator_fn { public: - virtual void operator()(base_object & t) {}; + void operator()(base_object & t) override {}; }; class identity_intersection_filter_fn : public intersection_filter_fn { public: - virtual void operator()(base_object & t, const base_object & neg) {}; + void operator()(base_object & t, const base_object & neg) override {}; }; class default_permutation_rename_fn : public transformer_fn { @@ -655,11 +655,11 @@ namespace datalog { : m_permutation(o.get_signature().size(), permutation), m_renamers_initialized(false) {} - ~default_permutation_rename_fn() { + ~default_permutation_rename_fn() override { dealloc_ptr_vector_content(m_renamers); } - base_object * operator()(const base_object & o) { + base_object * operator()(const base_object & o) override { const base_object * res = &o; scoped_rel res_scoped; if(m_renamers_initialized) { @@ -803,11 +803,11 @@ namespace datalog { protected: relation_base(relation_plugin & plugin, const relation_signature & s) : base_ancestor(plugin, s) {} - virtual ~relation_base() {} + ~relation_base() override {} public: virtual relation_base * complement(func_decl* p) const = 0; - virtual void reset(); + void reset() override; virtual void display_tuples(func_decl & pred, std::ostream & out) const { out << "Tuples in " << pred.get_name() << ": \n"; @@ -1022,7 +1022,7 @@ namespace datalog { table_plugin(symbol const& n, relation_manager & manager) : plugin_object(n, manager) {} public: - virtual bool can_handle_signature(const table_signature & s) { return s.functional_columns()==0; } + bool can_handle_signature(const table_signature & s) override { return s.functional_columns()==0; } protected: /** @@ -1044,17 +1044,17 @@ namespace datalog { protected: table_base(table_plugin & plugin, const table_signature & s) : base_ancestor(plugin, s) {} - virtual ~table_base() {} + ~table_base() override {} public: - virtual table_base * clone() const; + table_base * clone() const override; virtual table_base * complement(func_decl* p, const table_element * func_columns = 0) const; - virtual bool empty() const; + bool empty() const override; /** \brief Return true if table contains fact that corresponds to \c f in all non-functional columns. */ - virtual bool contains_fact(const table_fact & f) const; + bool contains_fact(const table_fact & f) const override; /** \brief If \c f (i.e. its non-functional part) is not present in the table, @@ -1082,11 +1082,11 @@ namespace datalog { virtual void remove_fact(table_element const* fact) = 0; virtual void remove_facts(unsigned fact_cnt, const table_fact * facts); virtual void remove_facts(unsigned fact_cnt, const table_element * facts); - virtual void reset(); + void reset() override; class row_interface; - virtual void display(std::ostream & out) const; + void display(std::ostream & out) const override; /** \brief Convert table to a formula that encodes the table. @@ -1245,9 +1245,9 @@ namespace datalog { public: caching_row_interface(const table_base & parent) : row_interface(parent) {} - virtual void get_fact(table_fact & result) const = 0; + void get_fact(table_fact & result) const override = 0; - virtual table_element operator[](unsigned col) const { + table_element operator[](unsigned col) const override { ensure_populated(); return m_current[col]; } diff --git a/src/muz/rel/dl_bound_relation.cpp b/src/muz/rel/dl_bound_relation.cpp index 9dc0eb8d5..74b87d96e 100644 --- a/src/muz/rel/dl_bound_relation.cpp +++ b/src/muz/rel/dl_bound_relation.cpp @@ -79,7 +79,7 @@ namespace datalog { : convenient_relation_join_fn(o1_sig, o2_sig, col_cnt, cols1, cols2) { } - virtual relation_base * operator()(const relation_base & _r1, const relation_base & _r2) { + relation_base * operator()(const relation_base & _r1, const relation_base & _r2) override { bound_relation const& r1 = get(_r1); bound_relation const& r2 = get(_r2); bound_relation_plugin& p = r1.get_plugin(); @@ -104,7 +104,7 @@ namespace datalog { : convenient_relation_project_fn(orig_sig, removed_col_cnt, removed_cols) { } - virtual relation_base * operator()(const relation_base & _r) { + relation_base * operator()(const relation_base & _r) override { bound_relation const& r = get(_r); bound_relation_plugin& p = r.get_plugin(); bound_relation* result = get(p.mk_full(0, get_result_signature())); @@ -124,7 +124,7 @@ namespace datalog { : convenient_relation_rename_fn(orig_sig, cycle_len, cycle) { } - virtual relation_base * operator()(const relation_base & _r) { + relation_base * operator()(const relation_base & _r) override { bound_relation const& r = get(_r); bound_relation_plugin& p = r.get_plugin(); bound_relation* result = get(p.mk_full(0, get_result_signature())); @@ -148,7 +148,7 @@ namespace datalog { union_fn(bool is_widen) : m_is_widen(is_widen) { } - virtual void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) { + void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) override { TRACE("bound_relation", _r.display(tout << "dst:\n"); _src.display(tout << "src:\n");); get(_r).mk_union(get(_src), get(_delta), m_is_widen); } @@ -160,7 +160,7 @@ namespace datalog { union_fn_i(bool is_widen) : m_is_widen(is_widen) { } - virtual void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) { + void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) override { TRACE("bound_relation", _r.display(tout << "dst:\n"); _src.display(tout << "src:\n");); get(_r).mk_union_i(get_interval_relation(_src), get(_delta), m_is_widen); TRACE("bound_relation", _r.display(tout << "dst':\n");); @@ -197,7 +197,7 @@ namespace datalog { filter_identical_fn(unsigned col_cnt, const unsigned * identical_cols) : m_cols(col_cnt, identical_cols) {} - virtual void operator()(relation_base & r) { + void operator()(relation_base & r) override { for (unsigned i = 1; i < m_cols.size(); ++i) { get(r).equate(m_cols[0], m_cols[i]); } @@ -216,7 +216,7 @@ namespace datalog { public: filter_equal_fn(relation_element const& value, unsigned col) {} - virtual void operator()(relation_base & r) { } + void operator()(relation_base & r) override { } }; relation_mutator_fn * bound_relation_plugin::mk_filter_equal_fn(const relation_base & r, @@ -342,7 +342,7 @@ namespace datalog { // x < y + z // - void operator()(relation_base& t) { + void operator()(relation_base& t) override { TRACE("dl", tout << mk_pp(m_cond, m_cond.get_manager()) << "\n"; t.display(tout);); bound_relation& r = get(t); switch(m_kind) { @@ -370,11 +370,11 @@ namespace datalog { TRACE("dl", t.display(tout << "result\n");); } - bool supports_attachment(relation_base& t) { + bool supports_attachment(relation_base& t) override { return is_interval_relation(t); } - void attach(relation_base& t) { + void attach(relation_base& t) override { SASSERT(is_interval_relation(t)); interval_relation& r = get_interval_relation(t); m_interval = &r; diff --git a/src/muz/rel/dl_bound_relation.h b/src/muz/rel/dl_bound_relation.h index 3dec9d313..da1aad71a 100644 --- a/src/muz/rel/dl_bound_relation.h +++ b/src/muz/rel/dl_bound_relation.h @@ -47,29 +47,29 @@ namespace datalog { bool_rewriter m_bsimp; public: bound_relation_plugin(relation_manager& m); - virtual bool can_handle_signature(const relation_signature & s); + bool can_handle_signature(const relation_signature & s) override; static symbol get_name() { return symbol("bound_relation"); } - virtual relation_base * mk_empty(const relation_signature & s); - virtual relation_base * mk_full(func_decl* p, const relation_signature & s); - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); - - virtual relation_join_fn * mk_join_project_fn(const relation_base & t1, const relation_base & t2, - unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, - unsigned removed_col_cnt, const unsigned * removed_cols) { return 0; } + relation_base * mk_empty(const relation_signature & s) override; + relation_base * mk_full(func_decl* p, const relation_signature & s) override; + relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; + + relation_join_fn * mk_join_project_fn(const relation_base & t1, const relation_base & t2, + unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, + unsigned removed_col_cnt, const unsigned * removed_cols) override { return 0; } #if 0 @@ -123,12 +123,12 @@ namespace datalog { bound_relation(bound_relation_plugin& p, relation_signature const& s, bool is_empty); bound_relation& operator=(bound_relation const& other); - virtual bool empty() const { return m_empty; } - virtual void add_fact(const relation_fact & f); - virtual bool contains_fact(const relation_fact & f) const; - virtual bound_relation * clone() const; - virtual bound_relation * complement(func_decl* p) const; - virtual void to_formula(expr_ref& fml) const; + bool empty() const override { return m_empty; } + void add_fact(const relation_fact & f) override; + bool contains_fact(const relation_fact & f) const override; + bound_relation * clone() const override; + bound_relation * complement(func_decl* p) const override; + void to_formula(expr_ref& fml) const override; bound_relation_plugin& get_plugin() const; void mk_union_i(interval_relation const& src, bound_relation* delta, bool is_widen); @@ -141,28 +141,28 @@ namespace datalog { bool is_lt(unsigned i, unsigned j) const; - virtual bool is_precise() const { return false; } + bool is_precise() const override { return false; } private: typedef uint_set2 T; - virtual T mk_intersect(T const& t1, T const& t2, bool& is_empty) const; + T mk_intersect(T const& t1, T const& t2, bool& is_empty) const override; - virtual T mk_widen(T const& t1, T const& t2) const; + T mk_widen(T const& t1, T const& t2) const override; - virtual T mk_unite(T const& t1, T const& t2) const; + T mk_unite(T const& t1, T const& t2) const override; - virtual T mk_eq(union_find<> const& old_eqs, union_find<> const& new_eqs, T const& t) const; + T mk_eq(union_find<> const& old_eqs, union_find<> const& new_eqs, T const& t) const override; - virtual void mk_rename_elem(T& i, unsigned col_cnt, unsigned const* cycle); + void mk_rename_elem(T& i, unsigned col_cnt, unsigned const* cycle) override; - virtual bool is_subset_of(T const& t1, T const& t2) const; + bool is_subset_of(T const& t1, T const& t2) const override; - virtual bool is_full(T const& t) const; + bool is_full(T const& t) const override; - virtual bool is_empty(unsigned idx, T const& t) const; + bool is_empty(unsigned idx, T const& t) const override; - virtual void display_index(unsigned idx, T const& t, std::ostream& out) const; + void display_index(unsigned idx, T const& t, std::ostream& out) const override; void normalize(T const& src, T& dst) const; diff --git a/src/muz/rel/dl_check_table.cpp b/src/muz/rel/dl_check_table.cpp index 0c4be18f1..b7d22159e 100644 --- a/src/muz/rel/dl_check_table.cpp +++ b/src/muz/rel/dl_check_table.cpp @@ -65,7 +65,7 @@ namespace datalog { m_checker = p.get_manager().mk_join_fn(checker(t1), checker(t2), col_cnt, cols1, cols2); } - virtual table_base* operator()(const table_base & t1, const table_base & t2) { + table_base* operator()(const table_base & t1, const table_base & t2) override { IF_VERBOSE(1, verbose_stream() << __FUNCTION__ << "\n";); table_base* ttocheck = (*m_tocheck)(tocheck(t1), tocheck(t2)); table_base* tchecker = (*m_checker)(checker(t1), checker(t2)); @@ -93,7 +93,7 @@ namespace datalog { m_checker = p.get_manager().mk_join_project_fn(checker(t1), checker(t2), col_cnt, cols1, cols2, removed_col_cnt, removed_cols); } - virtual table_base* operator()(const table_base & t1, const table_base & t2) { + table_base* operator()(const table_base & t1, const table_base & t2) override { table_base* ttocheck = (*m_tocheck)(tocheck(t1), tocheck(t2)); table_base* tchecker = (*m_checker)(checker(t1), checker(t2)); check_table* result = alloc(check_table, get(t1).get_plugin(), ttocheck->get_signature(), ttocheck, tchecker); @@ -119,7 +119,7 @@ namespace datalog { m_checker = p.get_manager().mk_union_fn(checker(tgt), checker(src), checker(delta)); } - virtual void operator()(table_base& tgt, const table_base& src, table_base* delta) { + void operator()(table_base& tgt, const table_base& src, table_base* delta) override { IF_VERBOSE(1, verbose_stream() << __FUNCTION__ << "\n";); (*m_tocheck)(tocheck(tgt), tocheck(src), tocheck(delta)); (*m_checker)(checker(tgt), checker(src), checker(delta)); @@ -147,7 +147,7 @@ namespace datalog { m_tocheck = p.get_manager().mk_project_fn(tocheck(t), col_cnt, removed_cols); } - table_base* operator()(table_base const& src) { + table_base* operator()(table_base const& src) override { table_base* tchecker = (*m_checker)(checker(src)); table_base* ttocheck = (*m_tocheck)(tocheck(src)); check_table* result = alloc(check_table, get(src).get_plugin(), tchecker->get_signature(), ttocheck, tchecker); @@ -171,7 +171,7 @@ namespace datalog { m_tocheck = p.get_manager().mk_select_equal_and_project_fn(tocheck(t), value, col); } - table_base* operator()(table_base const& src) { + table_base* operator()(table_base const& src) override { table_base* tchecker = (*m_checker)(checker(src)); table_base* ttocheck = (*m_tocheck)(tocheck(src)); check_table* result = alloc(check_table, get(src).get_plugin(), tchecker->get_signature(), ttocheck, tchecker); @@ -196,7 +196,7 @@ namespace datalog { m_tocheck = p.get_manager().mk_rename_fn(tocheck(t), cycle_len, cycle); } - table_base* operator()(table_base const& src) { + table_base* operator()(table_base const& src) override { IF_VERBOSE(1, verbose_stream() << __FUNCTION__ << "\n";); table_base* tchecker = (*m_checker)(checker(src)); table_base* ttocheck = (*m_tocheck)(tocheck(src)); @@ -222,7 +222,7 @@ namespace datalog { m_tocheck = p.get_manager().mk_filter_identical_fn(tocheck(t), cnt, cols); } - void operator()(table_base & t) { + void operator()(table_base & t) override { (*m_checker)(checker(t)); (*m_tocheck)(tocheck(t)); get(t).well_formed(); @@ -247,7 +247,7 @@ namespace datalog { m_tocheck = p.get_manager().mk_filter_equal_fn(tocheck(t), v, col); } - virtual void operator()(table_base& src) { + void operator()(table_base& src) override { (*m_checker)(checker(src)); (*m_tocheck)(tocheck(src)); get(src).well_formed(); @@ -271,7 +271,7 @@ namespace datalog { m_tocheck = p.get_manager().mk_filter_interpreted_fn(tocheck(t), condition); } - virtual void operator()(table_base& src) { + void operator()(table_base& src) override { (*m_checker)(checker(src)); (*m_tocheck)(tocheck(src)); get(src).well_formed(); @@ -296,7 +296,7 @@ namespace datalog { m_tocheck = p.get_manager().mk_filter_interpreted_and_project_fn(tocheck(t), condition, removed_col_cnt, removed_cols); } - table_base* operator()(table_base const& src) { + table_base* operator()(table_base const& src) override { table_base* tchecker = (*m_checker)(checker(src)); table_base* ttocheck = (*m_tocheck)(tocheck(src)); check_table* result = alloc(check_table, get(src).get_plugin(), ttocheck->get_signature(), ttocheck, tchecker); @@ -325,7 +325,7 @@ namespace datalog { m_tocheck = p.get_manager().mk_filter_by_negation_fn(tocheck(t), tocheck(negated_obj), joined_col_cnt, t_cols, negated_cols); } - virtual void operator()(table_base& src, table_base const& negated_obj) { + void operator()(table_base& src, table_base const& negated_obj) override { IF_VERBOSE(1, verbose_stream() << __FUNCTION__ << "\n";); (*m_checker)(checker(src), checker(negated_obj)); (*m_tocheck)(tocheck(src), tocheck(negated_obj)); diff --git a/src/muz/rel/dl_check_table.h b/src/muz/rel/dl_check_table.h index 412dd2dbc..77d9d0cdf 100644 --- a/src/muz/rel/dl_check_table.h +++ b/src/muz/rel/dl_check_table.h @@ -53,34 +53,34 @@ namespace datalog { m_checker(*manager.get_table_plugin(checker)), m_tocheck(*manager.get_table_plugin(tocheck)), m_count(0) {} - virtual table_base * mk_empty(const table_signature & s); + table_base * mk_empty(const table_signature & s) override; - virtual table_join_fn * mk_join_fn(const table_base & t1, const table_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual table_join_fn * mk_join_project_fn(const table_base & t1, const table_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, - const unsigned * removed_cols); - virtual table_union_fn * mk_union_fn(const table_base & tgt, const table_base & src, - const table_base * delta); - virtual table_transformer_fn * mk_project_fn(const table_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual table_transformer_fn * mk_select_equal_and_project_fn(const table_base & t, - const table_element & value, unsigned col); - virtual table_transformer_fn * mk_rename_fn(const table_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual table_mutator_fn * mk_filter_identical_fn(const table_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual table_mutator_fn * mk_filter_equal_fn(const table_base & t, const table_element & value, - unsigned col); - virtual table_mutator_fn * mk_filter_interpreted_fn(const table_base & t, app * condition); - virtual table_transformer_fn * mk_filter_interpreted_and_project_fn(const table_base & t, - app * condition, unsigned removed_col_cnt, const unsigned * removed_cols); - virtual table_intersection_filter_fn * mk_filter_by_negation_fn( - const table_base & t, - const table_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols); + table_join_fn * mk_join_fn(const table_base & t1, const table_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + table_join_fn * mk_join_project_fn(const table_base & t1, const table_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, + const unsigned * removed_cols) override; + table_union_fn * mk_union_fn(const table_base & tgt, const table_base & src, + const table_base * delta) override; + table_transformer_fn * mk_project_fn(const table_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + table_transformer_fn * mk_select_equal_and_project_fn(const table_base & t, + const table_element & value, unsigned col) override; + table_transformer_fn * mk_rename_fn(const table_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + table_mutator_fn * mk_filter_identical_fn(const table_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + table_mutator_fn * mk_filter_equal_fn(const table_base & t, const table_element & value, + unsigned col) override; + table_mutator_fn * mk_filter_interpreted_fn(const table_base & t, app * condition) override; + table_transformer_fn * mk_filter_interpreted_and_project_fn(const table_base & t, + app * condition, unsigned removed_col_cnt, const unsigned * removed_cols) override; + table_intersection_filter_fn * mk_filter_by_negation_fn( + const table_base & t, + const table_base & negated_obj, unsigned joined_col_cnt, + const unsigned * t_cols, const unsigned * negated_cols) override; - virtual bool can_handle_signature(table_signature const& s); + bool can_handle_signature(table_signature const& s) override; private: static check_table& get(table_base& r); @@ -106,7 +106,7 @@ namespace datalog { check_table(check_table_plugin & p, const table_signature & sig); check_table(check_table_plugin & p, const table_signature & sig, table_base* tocheck, table_base* checker); - virtual ~check_table(); + ~check_table() override; bool well_formed() const; @@ -116,18 +116,18 @@ namespace datalog { return static_cast(table_base::get_plugin()); } - virtual bool empty() const; - virtual void add_fact(const table_fact & f); - virtual void remove_fact(const table_element* fact); - virtual bool contains_fact(const table_fact & f) const; - virtual table_base * complement(func_decl* p, const table_element * func_columns = 0) const; - virtual table_base * clone() const; + bool empty() const override; + void add_fact(const table_fact & f) override; + void remove_fact(const table_element* fact) override; + bool contains_fact(const table_fact & f) const override; + table_base * complement(func_decl* p, const table_element * func_columns = 0) const override; + table_base * clone() const override; - virtual iterator begin() const { SASSERT(well_formed()); return m_tocheck->begin(); } - virtual iterator end() const { return m_tocheck->end(); } + iterator begin() const override { SASSERT(well_formed()); return m_tocheck->begin(); } + iterator end() const override { return m_tocheck->end(); } - virtual unsigned get_size_estimate_rows() const { return m_tocheck->get_size_estimate_rows(); } - virtual unsigned get_size_estimate_bytes() const { return m_tocheck->get_size_estimate_bytes(); } + unsigned get_size_estimate_rows() const override { return m_tocheck->get_size_estimate_rows(); } + unsigned get_size_estimate_bytes() const override { return m_tocheck->get_size_estimate_bytes(); } }; }; diff --git a/src/muz/rel/dl_compiler.h b/src/muz/rel/dl_compiler.h index 6ac33ae91..51ec7643c 100644 --- a/src/muz/rel/dl_compiler.h +++ b/src/muz/rel/dl_compiler.h @@ -97,7 +97,7 @@ namespace datalog { void start_rule(rule * r) { SASSERT(!m_current); m_current=r; } void finish_rule() { m_current = 0; } - virtual void notify(instruction * i) { + void notify(instruction * i) override { if(m_current) { i->set_accounting_parent_object(m_parent.m_context, m_current); } diff --git a/src/muz/rel/dl_external_relation.cpp b/src/muz/rel/dl_external_relation.cpp index ff9bef40e..403c5cbd3 100644 --- a/src/muz/rel/dl_external_relation.cpp +++ b/src/muz/rel/dl_external_relation.cpp @@ -195,7 +195,7 @@ namespace datalog { m_join_fn = m.mk_func_decl(fid, OP_RA_JOIN, params.size(), params.c_ptr(), 2, domain); } - virtual relation_base * operator()(const relation_base & r1, const relation_base & r2) { + relation_base * operator()(const relation_base & r1, const relation_base & r2) override { expr_ref res(m_plugin.get_ast_manager()); m_args[0] = get(r1).get_relation(); m_args[1] = get(r2).get_relation(); @@ -231,7 +231,7 @@ namespace datalog { m_project_fn = m.mk_func_decl(fid, OP_RA_PROJECT, params.size(), params.c_ptr(), 1, &relation_sort); } - virtual relation_base * operator()(const relation_base & r) { + relation_base * operator()(const relation_base & r) override { expr_ref res(m_plugin.get_ast_manager()); expr* rel = get(r).get_relation(); m_plugin.reduce(m_project_fn, 1, &rel, res); @@ -265,7 +265,7 @@ namespace datalog { m_rename_fn = m.mk_func_decl(fid, OP_RA_RENAME, params.size(), params.c_ptr(), 1, &relation_sort); } - virtual relation_base * operator()(const relation_base & r) { + relation_base * operator()(const relation_base & r) override { expr* rel = get(r).get_relation(); expr_ref res(m_plugin.get_ast_manager()); m_args[0] = rel; @@ -298,7 +298,7 @@ namespace datalog { m_union_fn = m.mk_func_decl(p.get_family_id(), k, 0, 0, 2, domain); } - virtual void operator()(relation_base & r, const relation_base & src, relation_base * delta) { + void operator()(relation_base & r, const relation_base & src, relation_base * delta) override { ast_manager& m = m_plugin.get_ast_manager(); expr_ref_vector res(m); m_args[0] = get(r).get_relation(); @@ -342,7 +342,7 @@ namespace datalog { SASSERT(p.get_ast_manager().is_bool(condition)); } - virtual void operator()(relation_base & r) { + void operator()(relation_base & r) override { SASSERT(m_plugin.check_kind(r)); expr* arg = get(r).get_relation(); m_plugin.reduce_assign(m_filter_fn, 1, &arg, 1, &arg); @@ -396,7 +396,7 @@ namespace datalog { } } - virtual void operator()(relation_base & r) { + void operator()(relation_base & r) override { expr* r0 = get(r).get_relation(); for (unsigned i = 0; i < m_filter_fn.size(); ++i) { m_plugin.reduce_assign(m_filter_fn[i].get(), 1, &r0, 1, &r0); @@ -436,7 +436,7 @@ namespace datalog { m_negated_filter_fn = m.mk_func_decl(fid, OP_RA_NEGATION_FILTER, params.size(), params.c_ptr(), 2, domain); } - void operator()(relation_base & t, const relation_base & negated_obj) { + void operator()(relation_base & t, const relation_base & negated_obj) override { m_args[0] = get(t).get_relation(); m_args[1] = get(negated_obj).get_relation(); m_plugin.reduce_assign(m_negated_filter_fn.get(), 2, m_args, 1, m_args); diff --git a/src/muz/rel/dl_external_relation.h b/src/muz/rel/dl_external_relation.h index 0dfb4a7f2..485e03618 100644 --- a/src/muz/rel/dl_external_relation.h +++ b/src/muz/rel/dl_external_relation.h @@ -54,30 +54,30 @@ namespace datalog { public: external_relation_plugin(external_relation_context& ctx, relation_manager & m); - virtual bool can_handle_signature(const relation_signature & s) { return true; } + bool can_handle_signature(const relation_signature & s) override { return true; } static symbol get_name() { return symbol("external_relation"); } - virtual relation_base * mk_empty(const relation_signature & s); + relation_base * mk_empty(const relation_signature & s) override; - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); - virtual relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, - const relation_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols); + relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; + relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, + const relation_base & negated_obj, unsigned joined_col_cnt, + const unsigned * t_cols, const unsigned * negated_cols) override; private: @@ -123,28 +123,28 @@ namespace datalog { void mk_accessor(decl_kind k, func_decl_ref& fn, const relation_fact& f, bool destructive, expr_ref& res) const; external_relation(external_relation_plugin & p, const relation_signature & s, expr* r); - virtual ~external_relation(); + ~external_relation() override; public: external_relation_plugin & get_plugin() const; - virtual bool empty() const; + bool empty() const override; - virtual void add_fact(const relation_fact & f); + void add_fact(const relation_fact & f) override; - virtual bool contains_fact(const relation_fact & f) const; + bool contains_fact(const relation_fact & f) const override; - virtual external_relation * clone() const; + external_relation * clone() const override; - virtual external_relation * complement(func_decl*) const; + external_relation * complement(func_decl*) const override; - virtual void display(std::ostream & out) const; + void display(std::ostream & out) const override; - virtual void display_tuples(func_decl & pred, std::ostream & out) const; + void display_tuples(func_decl & pred, std::ostream & out) const override; expr* get_relation() const { return m_rel.get(); } - virtual void to_formula(expr_ref& fml) const { fml = get_relation(); } + void to_formula(expr_ref& fml) const override { fml = get_relation(); } }; diff --git a/src/muz/rel/dl_finite_product_relation.cpp b/src/muz/rel/dl_finite_product_relation.cpp index 163ba1b0b..4cb683df1 100644 --- a/src/muz/rel/dl_finite_product_relation.cpp +++ b/src/muz/rel/dl_finite_product_relation.cpp @@ -333,7 +333,7 @@ namespace datalog { : convenient_relation_join_fn(sig1, sig2, col_cnt, cols1, cols2), m_plugin(plugin) {} - virtual relation_base * operator()(const relation_base & r1, const relation_base & r2) { + relation_base * operator()(const relation_base & r1, const relation_base & r2) override { scoped_rel r1_conv; if(&r1.get_plugin()!=&m_plugin) { r1_conv = convert(r1); @@ -390,7 +390,7 @@ namespace datalog { relation_vector & rjoins) : m_parent(parent), m_r1(r1), m_r2(r2), m_rjoins(rjoins) {} - virtual bool operator()(table_element * func_columns) { + bool operator()(table_element * func_columns) override { const relation_base & or1 = m_r1.get_inner_rel(func_columns[0]); const relation_base & or2 = m_r2.get_inner_rel(func_columns[1]); SASSERT(&or1); @@ -450,7 +450,7 @@ namespace datalog { return (*m_rjoin_fn)(r1, r2); } - virtual relation_base * operator()(const relation_base & rb1, const relation_base & rb2) { + relation_base * operator()(const relation_base & rb1, const relation_base & rb2) override { finite_product_relation_plugin & plugin = get(rb1).get_plugin(); relation_manager & rmgr = plugin.get_manager(); @@ -565,7 +565,7 @@ namespace datalog { project_reducer(project_fn & parent, relation_vector & relations) : m_parent(parent), m_relations(relations) {} - virtual void operator()(table_element * func_columns, const table_element * merged_func_columns) { + void operator()(table_element * func_columns, const table_element * merged_func_columns) override { relation_base * tgt = m_relations[static_cast(func_columns[0])]->clone(); relation_base & src = *m_relations[static_cast(merged_func_columns[0])]; if(!m_parent.m_inner_rel_union) { @@ -579,7 +579,7 @@ namespace datalog { } }; - virtual relation_base * operator()(const relation_base & rb) { + relation_base * operator()(const relation_base & rb) override { const finite_product_relation & r = get(rb); finite_product_relation_plugin & plugin = r.get_plugin(); const table_base & rtable = r.get_table(); @@ -696,7 +696,7 @@ namespace datalog { } - virtual relation_base * operator()(const relation_base & rb) { + relation_base * operator()(const relation_base & rb) override { const finite_product_relation & r = get(rb); const table_base & rtable = r.get_table(); @@ -795,9 +795,9 @@ namespace datalog { m_delta_indexes(delta_indexes), m_delta_rels(delta_rels) {} - virtual ~union_mapper() {} + ~union_mapper() override {} - virtual bool operator()(table_element * func_columns) { + bool operator()(table_element * func_columns) override { relation_base & otgt_orig = m_tgt.get_inner_rel(func_columns[0]); const relation_base & osrc = m_src.get_inner_rel(func_columns[1]); @@ -838,7 +838,7 @@ namespace datalog { src_copying_mapper(finite_product_relation & tgt, const finite_product_relation & src) : m_tgt(tgt), m_src(src) {} - virtual bool operator()(table_element * func_columns) { + bool operator()(table_element * func_columns) override { const relation_base & osrc = m_src.get_inner_rel(func_columns[0]); unsigned new_tgt_idx = m_tgt.get_next_rel_idx(); m_tgt.set_inner_rel(new_tgt_idx, osrc.clone()); @@ -847,7 +847,7 @@ namespace datalog { } }; - virtual void operator()(relation_base & tgtb, const relation_base & srcb, relation_base * deltab) { + void operator()(relation_base & tgtb, const relation_base & srcb, relation_base * deltab) override { finite_product_relation & tgt = get(tgtb); const finite_product_relation & src0 = get(srcb); finite_product_relation * delta = get(deltab); @@ -1088,7 +1088,7 @@ namespace datalog { class finite_product_relation_plugin::converting_union_fn : public relation_union_fn { scoped_ptr m_tr_union_fun; public: - virtual void operator()(relation_base & tgtb, const relation_base & srcb, relation_base * deltab) { + void operator()(relation_base & tgtb, const relation_base & srcb, relation_base * deltab) override { SASSERT(srcb.get_plugin().is_finite_product_relation()); const finite_product_relation & src = get(srcb); finite_product_relation_plugin & plugin = src.get_plugin(); @@ -1164,7 +1164,7 @@ namespace datalog { SASSERT(m_rel_filter); } - virtual void operator()(relation_base & rb) { + void operator()(relation_base & rb) override { finite_product_relation & r = get(rb); if(m_table_cols.size()>1) { @@ -1212,7 +1212,7 @@ namespace datalog { } } - virtual void operator()(relation_base & rb) { + void operator()(relation_base & rb) override { finite_product_relation & r = get(rb); if(m_table_filter) { @@ -1339,7 +1339,7 @@ namespace datalog { } } - virtual void operator()(relation_base & rb) { + void operator()(relation_base & rb) override { finite_product_relation & r = get(rb); table_base & rtable = r.get_table(); table_plugin & tplugin = r.get_table_plugin(); @@ -1537,7 +1537,7 @@ namespace datalog { const finite_product_relation & inters) : m_parent(parent), m_r(r), m_inters(inters) {} - virtual bool operator()(table_element * func_columns) { + bool operator()(table_element * func_columns) override { relation_base * r_inner = m_r.get_inner_rel(func_columns[0]).clone(); const relation_base & inters_inner = m_inters.get_inner_rel(func_columns[1]); @@ -1557,7 +1557,7 @@ namespace datalog { }; - virtual void operator()(relation_base & rb, const relation_base & negb) { + void operator()(relation_base & rb, const relation_base & negb) override { finite_product_relation & r = get(rb); const finite_product_relation & neg = get(negb); @@ -1662,7 +1662,7 @@ namespace datalog { } } - virtual void operator()(relation_base & rb) { + void operator()(relation_base & rb) override { finite_product_relation & r = get(rb); finite_product_relation_plugin & plugin = r.get_plugin(); table_plugin & tplugin = r.get_table_plugin(); @@ -2043,7 +2043,7 @@ namespace datalog { public: live_rel_collection_reducer(idx_set & accumulator) : m_accumulator(accumulator) {} - virtual void operator()(table_element * func_columns, const table_element * merged_func_columns) { + void operator()(table_element * func_columns, const table_element * merged_func_columns) override { m_accumulator.insert(static_cast(merged_func_columns[0])); } }; diff --git a/src/muz/rel/dl_finite_product_relation.h b/src/muz/rel/dl_finite_product_relation.h index e13b7fcf9..750ac325f 100644 --- a/src/muz/rel/dl_finite_product_relation.h +++ b/src/muz/rel/dl_finite_product_relation.h @@ -93,23 +93,23 @@ namespace datalog { finite_product_relation_plugin(relation_plugin & inner_plugin, relation_manager & manager); - virtual void initialize(family_id fid); + void initialize(family_id fid) override; relation_plugin & get_inner_plugin() const { return m_inner_plugin; } - virtual bool can_handle_signature(const relation_signature & s); + bool can_handle_signature(const relation_signature & s) override; - virtual relation_base * mk_empty(const relation_signature & s); + relation_base * mk_empty(const relation_signature & s) override; /** \c inner_kind==null_family_id means we don't care about the kind of the inner relation */ finite_product_relation * mk_empty(const relation_signature & s, const bool * table_columns, family_id inner_kind=null_family_id); finite_product_relation * mk_empty(const finite_product_relation & original); - virtual relation_base * mk_empty(const relation_base & original); - virtual relation_base * mk_empty(const relation_signature & s, family_id kind); + relation_base * mk_empty(const relation_base & original) override; + relation_base * mk_empty(const relation_signature & s, family_id kind) override; - virtual relation_base * mk_full(func_decl* p, const relation_signature & s); + relation_base * mk_full(func_decl* p, const relation_signature & s) override; /** \brief Return true if \c r can be converted to \c finite_product_relation_plugin either @@ -127,22 +127,22 @@ namespace datalog { table_relation * to_table_relation(const finite_product_relation & r); protected: - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); - virtual relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, - const relation_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols); + relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; + relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, + const relation_base & negated_obj, unsigned joined_col_cnt, + const unsigned * t_cols, const unsigned * negated_cols) override; private: /** @@ -309,7 +309,7 @@ namespace datalog { bool try_modify_specification(const bool * table_cols); - virtual bool can_swap(const relation_base & r) const + bool can_swap(const relation_base & r) const override { return &get_plugin()==&r.get_plugin(); } /** @@ -317,7 +317,7 @@ namespace datalog { Both relations must come from the same plugin and be of the same signature. */ - virtual void swap(relation_base & r); + void swap(relation_base & r) override; /** \brief Create a \c finite_product_relation object. @@ -325,7 +325,7 @@ namespace datalog { finite_product_relation(finite_product_relation_plugin & p, const relation_signature & s, const bool * table_columns, table_plugin & tplugin, relation_plugin & oplugin, family_id other_kind); finite_product_relation(const finite_product_relation & r); - virtual ~finite_product_relation(); + ~finite_product_relation() override; public: context & get_context() const; finite_product_relation_plugin & get_plugin() const { @@ -342,22 +342,22 @@ namespace datalog { /** The function calls garbage_collect, so the internal state may change when it is called. */ - virtual bool empty() const; - void reset() { m_table->reset(); garbage_collect(false); } + bool empty() const override; + void reset() override { m_table->reset(); garbage_collect(false); } - virtual void add_fact(const relation_fact & f); - virtual bool contains_fact(const relation_fact & f) const; + void add_fact(const relation_fact & f) override; + bool contains_fact(const relation_fact & f) const override; - virtual finite_product_relation * clone() const; - virtual finite_product_relation * complement(func_decl* p) const; + finite_product_relation * clone() const override; + finite_product_relation * complement(func_decl* p) const override; - virtual void display(std::ostream & out) const; - virtual void display_tuples(func_decl & pred, std::ostream & out) const; + void display(std::ostream & out) const override; + void display_tuples(func_decl & pred, std::ostream & out) const override; - virtual unsigned get_size_estimate_rows() const { return m_table->get_size_estimate_rows(); } - virtual unsigned get_size_estimate_bytes() const { return m_table->get_size_estimate_bytes(); } + unsigned get_size_estimate_rows() const override { return m_table->get_size_estimate_rows(); } + unsigned get_size_estimate_bytes() const override { return m_table->get_size_estimate_bytes(); } - virtual void to_formula(expr_ref& fml) const; + void to_formula(expr_ref& fml) const override; }; }; diff --git a/src/muz/rel/dl_instruction.cpp b/src/muz/rel/dl_instruction.cpp index 26139fb7c..d82f42b19 100644 --- a/src/muz/rel/dl_instruction.cpp +++ b/src/muz/rel/dl_instruction.cpp @@ -192,7 +192,7 @@ namespace datalog { public: instr_io(bool store, func_decl_ref const& pred, reg_idx reg) : m_store(store), m_pred(pred), m_reg(reg) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); if (m_store) { if (ctx.reg(m_reg)) { @@ -218,10 +218,10 @@ namespace datalog { } return true; } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { ctx.set_register_annotation(m_reg, m_pred->get_name().bare_str()); } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { const char * rel_name = m_pred->get_name().bare_str(); if (m_store) { out << "store " << m_reg << " into " << rel_name; @@ -245,14 +245,14 @@ namespace datalog { reg_idx m_reg; public: instr_dealloc(reg_idx reg) : m_reg(reg) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { ctx.make_empty(m_reg); return true; } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { ctx.set_register_annotation(m_reg, "alloc"); } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "dealloc " << m_reg; } }; @@ -268,7 +268,7 @@ namespace datalog { public: instr_clone_move(bool clone, reg_idx src, reg_idx tgt) : m_clone(clone), m_src(src), m_tgt(tgt) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { if (ctx.reg(m_src)) log_verbose(ctx); if (m_clone) { ctx.set_reg(m_tgt, ctx.reg(m_src) ? ctx.reg(m_src)->clone() : 0); @@ -278,7 +278,7 @@ namespace datalog { } return true; } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::string str; if (ctx.get_register_annotation(m_src, str)) { ctx.set_register_annotation(m_tgt, str); @@ -287,7 +287,7 @@ namespace datalog { ctx.set_register_annotation(m_src, str); } } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << (m_clone ? "clone " : "move ") << m_src << " into " << m_tgt; } }; @@ -317,17 +317,17 @@ namespace datalog { return true; } protected: - virtual void process_all_costs() { + void process_all_costs() override { instruction::process_all_costs(); m_body->process_all_costs(); } public: instr_while_loop(unsigned control_reg_cnt, const reg_idx * control_regs, instruction_block * body) : m_controls(control_reg_cnt, control_regs), m_body(body) {} - virtual ~instr_while_loop() { + ~instr_while_loop() override { dealloc(m_body); } - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); TRACE("dl", tout << "loop entered\n";); unsigned count = 0; @@ -341,14 +341,14 @@ namespace datalog { TRACE("dl", tout << "while loop exited\n";); return true; } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { m_body->make_annotations(ctx); } - virtual void display_head_impl(execution_context const & ctx, std::ostream & out) const { + void display_head_impl(execution_context const & ctx, std::ostream & out) const override { out << "while"; print_container(m_controls, out); } - virtual void display_body_impl(execution_context const & ctx, std::ostream & out, const std::string & indentation) const { + void display_body_impl(execution_context const & ctx, std::ostream & out, const std::string & indentation) const override { m_body->display_indented(ctx, out, indentation+" "); } }; @@ -371,7 +371,7 @@ namespace datalog { const unsigned * cols2, reg_idx result) : m_rel1(rel1), m_rel2(rel2), m_cols1(col_cnt, cols1), m_cols2(col_cnt, cols2), m_res(result) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); ++ctx.m_stats.m_join; if (!ctx.reg(m_rel1) || !ctx.reg(m_rel2)) { @@ -408,13 +408,13 @@ namespace datalog { } return true; } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::string a1 = "rel1", a2 = "rel2"; ctx.get_register_annotation(m_rel1, a1); ctx.get_register_annotation(m_rel1, a1); ctx.set_register_annotation(m_res, "join " + a1 + " " + a2); } - virtual void display_head_impl(execution_context const & ctx, std::ostream & out) const { + void display_head_impl(execution_context const & ctx, std::ostream & out) const override { out << "join " << m_rel1; print_container(m_cols1, out); out << " and " << m_rel2; @@ -435,7 +435,7 @@ namespace datalog { public: instr_filter_equal(ast_manager & m, reg_idx reg, const relation_element & value, unsigned col) : m_reg(reg), m_value(value, m), m_col(col) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); ++ctx.m_stats.m_filter_eq; if (!ctx.reg(m_reg)) { @@ -460,12 +460,12 @@ namespace datalog { } return true; } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::stringstream a; a << "filter_equal " << m_col << " val: " << ctx.get_rel_context().get_rmanager().to_nice_string(m_value); ctx.set_register_annotation(m_reg, a.str()); } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "filter_equal " << m_reg << " col: " << m_col << " val: " << ctx.get_rel_context().get_rmanager().to_nice_string(m_value); } @@ -484,7 +484,7 @@ namespace datalog { public: instr_filter_identical(reg_idx reg, unsigned col_cnt, const unsigned * identical_cols) : m_reg(reg), m_cols(col_cnt, identical_cols) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); ++ctx.m_stats.m_filter_id; if (!ctx.reg(m_reg)) { @@ -509,11 +509,11 @@ namespace datalog { } return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "filter_identical " << m_reg << " "; print_container(m_cols, out); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { ctx.set_register_annotation(m_reg, "filter_identical"); } }; @@ -529,7 +529,7 @@ namespace datalog { public: instr_filter_interpreted(reg_idx reg, app_ref & condition) : m_reg(reg), m_cond(condition) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { if (!ctx.reg(m_reg)) { return true; } @@ -557,11 +557,11 @@ namespace datalog { return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "filter_interpreted " << m_reg << " using " << mk_pp(m_cond, m_cond.get_manager()); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::stringstream a; a << "filter_interpreted " << mk_pp(m_cond, m_cond.get_manager()); ctx.set_register_annotation(m_reg, a.str()); @@ -584,7 +584,7 @@ namespace datalog { : m_src(src), m_cond(condition), m_cols(col_cnt, removed_cols), m_res(result) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); if (!ctx.reg(m_src)) { ctx.make_empty(m_res); @@ -614,14 +614,14 @@ namespace datalog { return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "filter_interpreted_and_project " << m_src << " into " << m_res; out << " using " << mk_pp(m_cond, m_cond.get_manager()); out << " deleting columns "; print_container(m_cols, out); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::stringstream s; std::string a = "rel_src"; ctx.get_register_annotation(m_src, a); @@ -644,7 +644,7 @@ namespace datalog { public: instr_union(reg_idx src, reg_idx tgt, reg_idx delta, bool widen) : m_src(src), m_tgt(tgt), m_delta(delta), m_widen(widen) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { TRACE("dl", tout << "union " << m_src << " into " << m_tgt << " " << ctx.reg(m_src) << " " << ctx.reg(m_tgt) << "\n";); if (!ctx.reg(m_src)) { @@ -721,7 +721,7 @@ namespace datalog { return true; } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::string str = "union"; if (!ctx.get_register_annotation(m_tgt, str)) { ctx.set_register_annotation(m_tgt, "union"); @@ -731,7 +731,7 @@ namespace datalog { } ctx.set_register_annotation(m_delta, str); } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << (m_widen ? "widen " : "union ") << m_src << " into " << m_tgt; if (m_delta!=execution_context::void_register) { out << " with delta " << m_delta; @@ -758,7 +758,7 @@ namespace datalog { instr_project_rename(bool projection, reg_idx src, unsigned col_cnt, const unsigned * cols, reg_idx tgt) : m_projection(projection), m_src(src), m_cols(col_cnt, cols), m_tgt(tgt) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { if (!ctx.reg(m_src)) { ctx.make_empty(m_tgt); return true; @@ -787,12 +787,12 @@ namespace datalog { return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << (m_projection ? "project " : "rename ") << m_src << " into " << m_tgt; out << (m_projection ? " deleting columns " : " with cycle "); print_container(m_cols, out); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::stringstream s; std::string a = "rel_src"; ctx.get_register_annotation(m_src, a); @@ -825,7 +825,7 @@ namespace datalog { : m_rel1(rel1), m_rel2(rel2), m_cols1(joined_col_cnt, cols1), m_cols2(joined_col_cnt, cols2), m_removed_cols(removed_col_cnt, removed_cols), m_res(result) { } - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); if (!ctx.reg(m_rel1) || !ctx.reg(m_rel2)) { ctx.make_empty(m_res); @@ -852,7 +852,7 @@ namespace datalog { } return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { relation_base const* r1 = ctx.reg(m_rel1); relation_base const* r2 = ctx.reg(m_rel2); out << "join_project " << m_rel1; @@ -870,7 +870,7 @@ namespace datalog { out << " into " << m_res << " removing columns "; print_container(m_removed_cols, out); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::string s1 = "rel1", s2 = "rel2"; ctx.get_register_annotation(m_rel1, s1); ctx.get_register_annotation(m_rel2, s2); @@ -898,7 +898,7 @@ namespace datalog { // TRACE("dl", tout << "src:" << m_src << " result: " << m_result << " value:" << m_value << " column:" << m_col << "\n";); } - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { if (!ctx.reg(m_src)) { ctx.make_empty(m_result); return true; @@ -923,11 +923,11 @@ namespace datalog { } return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "select_equal_and_project " << m_src <<" into " << m_result << " col: " << m_col << " val: " << ctx.get_rel_context().get_rmanager().to_nice_string(m_value); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::stringstream s; std::string s1 = "src"; ctx.get_register_annotation(m_src, s1); @@ -953,7 +953,7 @@ namespace datalog { instr_filter_by_negation(reg_idx tgt, reg_idx neg_rel, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) : m_tgt(tgt), m_neg_rel(neg_rel), m_cols1(col_cnt, cols1), m_cols2(col_cnt, cols2) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); if (!ctx.reg(m_tgt) || !ctx.reg(m_neg_rel)) { return true; @@ -980,14 +980,14 @@ namespace datalog { } return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "filter_by_negation on " << m_tgt; print_container(m_cols1, out); out << " with " << m_neg_rel; print_container(m_cols2, out); out << " as the negated table"; } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::string s = "negated relation"; ctx.get_register_annotation(m_neg_rel, s); ctx.set_register_annotation(m_tgt, "filter by negation " + s); @@ -1011,7 +1011,7 @@ namespace datalog { m_sig.push_back(s); m_fact.push_back(val); } - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); ++ctx.m_stats.m_unary_singleton; relation_base * rel = ctx.get_rel_context().get_rmanager().mk_empty_relation(m_sig, m_pred); @@ -1019,12 +1019,12 @@ namespace datalog { ctx.set_reg(m_tgt, rel); return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "mk_unary_singleton into " << m_tgt << " sort:" << ctx.get_rel_context().get_rmanager().to_nice_string(m_sig[0]) << " val:" << ctx.get_rel_context().get_rmanager().to_nice_string(m_sig[0], m_fact[0]); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::string s; if (!ctx.get_register_annotation(m_tgt, s)) { ctx.set_register_annotation(m_tgt, "mk unary singleton"); @@ -1044,18 +1044,18 @@ namespace datalog { reg_idx m_tgt; public: instr_mk_total(const relation_signature & sig, func_decl* p, reg_idx tgt) : m_sig(sig), m_pred(p), m_tgt(tgt) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); ++ctx.m_stats.m_total; ctx.set_reg(m_tgt, ctx.get_rel_context().get_rmanager().mk_full_relation(m_sig, m_pred)); return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "mk_total into " << m_tgt << " sort:" << ctx.get_rel_context().get_rmanager().to_nice_string(m_sig) << " " << m_pred->get_name(); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::string s; if (!ctx.get_register_annotation(m_tgt, s)) { ctx.set_register_annotation(m_tgt, "mk_total"); @@ -1072,15 +1072,15 @@ namespace datalog { public: instr_mark_saturated(ast_manager & m, func_decl * pred) : m_pred(pred, m) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); ctx.get_rel_context().get_rmanager().mark_saturated(m_pred); return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "mark_saturated " << m_pred->get_name().bare_str(); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { } }; @@ -1094,18 +1094,18 @@ namespace datalog { public: instr_assert_signature(const relation_signature & s, reg_idx tgt) : m_sig(s), m_tgt(tgt) {} - virtual bool perform(execution_context & ctx) { + bool perform(execution_context & ctx) override { log_verbose(ctx); if (ctx.reg(m_tgt)) { SASSERT(ctx.reg(m_tgt)->get_signature()==m_sig); } return true; } - virtual void display_head_impl(execution_context const& ctx, std::ostream & out) const { + void display_head_impl(execution_context const& ctx, std::ostream & out) const override { out << "instr_assert_signature of " << m_tgt << " signature:"; print_container(m_sig, out); } - virtual void make_annotations(execution_context & ctx) { + void make_annotations(execution_context & ctx) override { std::string s; if (!ctx.get_register_annotation(m_tgt, s)) { ctx.set_register_annotation(m_tgt, "assert signature"); diff --git a/src/muz/rel/dl_interval_relation.cpp b/src/muz/rel/dl_interval_relation.cpp index e14d242bb..12b6815cc 100644 --- a/src/muz/rel/dl_interval_relation.cpp +++ b/src/muz/rel/dl_interval_relation.cpp @@ -59,7 +59,7 @@ namespace datalog { : convenient_relation_join_fn(o1_sig, o2_sig, col_cnt, cols1, cols2){ } - virtual relation_base * operator()(const relation_base & _r1, const relation_base & _r2) { + relation_base * operator()(const relation_base & _r1, const relation_base & _r2) override { interval_relation const& r1 = get(_r1); interval_relation const& r2 = get(_r2); interval_relation_plugin& p = r1.get_plugin(); @@ -84,7 +84,7 @@ namespace datalog { : convenient_relation_project_fn(orig_sig, removed_col_cnt, removed_cols) { } - virtual relation_base * operator()(const relation_base & _r) { + relation_base * operator()(const relation_base & _r) override { interval_relation const& r = get(_r); interval_relation_plugin& p = r.get_plugin(); interval_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); @@ -104,7 +104,7 @@ namespace datalog { : convenient_relation_rename_fn(orig_sig, cycle_len, cycle) { } - virtual relation_base * operator()(const relation_base & _r) { + relation_base * operator()(const relation_base & _r) override { interval_relation const& r = get(_r); interval_relation_plugin& p = r.get_plugin(); interval_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); @@ -198,7 +198,7 @@ namespace datalog { m_is_widen(is_widen) { } - virtual void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) { + void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) override { TRACE("interval_relation", _r.display(tout << "dst:\n"); _src.display(tout << "src:\n");); @@ -237,7 +237,7 @@ namespace datalog { filter_identical_fn(unsigned col_cnt, const unsigned * identical_cols) : m_identical_cols(col_cnt, identical_cols) {} - virtual void operator()(relation_base & r) { + void operator()(relation_base & r) override { interval_relation & pr = get(r); for (unsigned i = 1; i < m_identical_cols.size(); ++i) { unsigned c1 = m_identical_cols[0]; @@ -266,7 +266,7 @@ namespace datalog { VERIFY(arith.is_numeral(value, m_value)); } - virtual void operator()(relation_base & _r) { + void operator()(relation_base & _r) override { interval_relation & r = get(_r); interval_relation_plugin & p = r.get_plugin(); r.mk_intersect(m_col, interval(p.dep(), m_value)); @@ -290,7 +290,7 @@ namespace datalog { m_cond(cond, t.get_plugin().get_ast_manager()) { } - void operator()(relation_base& t) { + void operator()(relation_base& t) override { get(t).filter_interpreted(m_cond); TRACE("interval_relation", tout << mk_pp(m_cond, m_cond.get_manager()) << "\n"; t.display(tout);); } diff --git a/src/muz/rel/dl_interval_relation.h b/src/muz/rel/dl_interval_relation.h index a9cce9802..896bb30ab 100644 --- a/src/muz/rel/dl_interval_relation.h +++ b/src/muz/rel/dl_interval_relation.h @@ -53,25 +53,25 @@ namespace datalog { public: interval_relation_plugin(relation_manager& m); - virtual bool can_handle_signature(const relation_signature & s); + bool can_handle_signature(const relation_signature & s) override; static symbol get_name() { return symbol("interval_relation"); } - virtual relation_base * mk_empty(const relation_signature & s); - virtual relation_base * mk_full(func_decl* p, const relation_signature & s); - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); + relation_base * mk_empty(const relation_signature & s) override; + relation_base * mk_full(func_decl* p, const relation_signature & s) override; + relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; static bool is_empty(unsigned idx, interval const& i); static bool is_infinite(interval const& i); @@ -97,39 +97,39 @@ namespace datalog { public: interval_relation(interval_relation_plugin& p, relation_signature const& s, bool is_empty); - virtual void add_fact(const relation_fact & f); - virtual bool contains_fact(const relation_fact & f) const; - virtual interval_relation * clone() const; - virtual interval_relation * complement(func_decl*) const; - virtual void to_formula(expr_ref& fml) const; + void add_fact(const relation_fact & f) override; + bool contains_fact(const relation_fact & f) const override; + interval_relation * clone() const override; + interval_relation * complement(func_decl*) const override; + void to_formula(expr_ref& fml) const override; interval_relation_plugin& get_plugin() const; void filter_interpreted(app* cond); - virtual bool is_precise() const { return false; } + bool is_precise() const override { return false; } private: - virtual interval mk_intersect(interval const& t1, interval const& t2, bool& is_empty) const { + interval mk_intersect(interval const& t1, interval const& t2, bool& is_empty) const override { return get_plugin().meet(t1, t2, is_empty); } - virtual interval mk_unite(interval const& t1, interval const& t2) const { return get_plugin().unite(t1,t2); } + interval mk_unite(interval const& t1, interval const& t2) const override { return get_plugin().unite(t1,t2); } - virtual interval mk_widen(interval const& t1, interval const& t2) const { return get_plugin().widen(t1,t2); } + interval mk_widen(interval const& t1, interval const& t2) const override { return get_plugin().widen(t1,t2); } - virtual bool is_subset_of(interval const& t1, interval const& t2) const { NOT_IMPLEMENTED_YET(); return false; } + bool is_subset_of(interval const& t1, interval const& t2) const override { NOT_IMPLEMENTED_YET(); return false; } - virtual bool is_full(interval const& t) const { + bool is_full(interval const& t) const override { return interval_relation_plugin::is_infinite(t); } - virtual bool is_empty(unsigned idx, interval const& t) const { + bool is_empty(unsigned idx, interval const& t) const override { return interval_relation_plugin::is_empty(idx, t); } - virtual void mk_rename_elem(interval& i, unsigned col_cnt, unsigned const* cycle); + void mk_rename_elem(interval& i, unsigned col_cnt, unsigned const* cycle) override; - virtual void display_index(unsigned idx, interval const & i, std::ostream& out) const; + void display_index(unsigned idx, interval const & i, std::ostream& out) const override; void mk_intersect(unsigned idx, interval const& i); diff --git a/src/muz/rel/dl_lazy_table.cpp b/src/muz/rel/dl_lazy_table.cpp index 54105891a..1b8681ab0 100644 --- a/src/muz/rel/dl_lazy_table.cpp +++ b/src/muz/rel/dl_lazy_table.cpp @@ -50,7 +50,7 @@ namespace datalog { unsigned const* cols1, unsigned const* cols2): convenient_table_join_fn(s1, s2, col_cnt, cols1, cols2) {} - virtual table_base* operator()(const table_base& _t1, const table_base& _t2) { + table_base* operator()(const table_base& _t1, const table_base& _t2) override { lazy_table const& t1 = get(_t1); lazy_table const& t2 = get(_t2); lazy_table_ref* tr = alloc(lazy_table_join, m_cols1.size(), m_cols1.c_ptr(), m_cols2.c_ptr(), t1, t2, get_result_signature()); @@ -75,7 +75,7 @@ namespace datalog { class lazy_table_plugin::union_fn : public table_union_fn { public: void operator()(table_base & _tgt, const table_base & _src, - table_base * _delta) { + table_base * _delta) override { lazy_table& tgt = get(_tgt); lazy_table const& src = get(_src); lazy_table* delta = get(_delta); @@ -111,7 +111,7 @@ namespace datalog { convenient_table_project_fn(orig_sig, cnt, cols) {} - virtual table_base* operator()(table_base const& _t) { + table_base* operator()(table_base const& _t) override { lazy_table const& t = get(_t); return alloc(lazy_table, alloc(lazy_table_project, m_removed_cols.size(), m_removed_cols.c_ptr(), t, get_result_signature())); } @@ -137,7 +137,7 @@ namespace datalog { convenient_table_rename_fn(orig_sig, cnt, cols) {} - virtual table_base* operator()(table_base const& _t) { + table_base* operator()(table_base const& _t) override { lazy_table const& t = get(_t); return alloc(lazy_table, alloc(lazy_table_rename, m_cycle.size(), m_cycle.c_ptr(), t, get_result_signature())); } @@ -163,7 +163,7 @@ namespace datalog { public: filter_identical_fn(unsigned cnt, unsigned const* cols): m_cols(cnt, cols) {} - virtual void operator()(table_base& _t) { + void operator()(table_base& _t) override { lazy_table& t = get(_t); t.set(alloc(lazy_table_filter_identical, m_cols.size(), m_cols.c_ptr(), t)); } @@ -188,7 +188,7 @@ namespace datalog { public: filter_interpreted_fn(app_ref& p): m_condition(p) {} - virtual void operator()(table_base& _t) { + void operator()(table_base& _t) override { lazy_table& t = get(_t); t.set(alloc(lazy_table_filter_interpreted, t, m_condition)); } @@ -214,7 +214,7 @@ namespace datalog { public: filter_by_negation_fn(unsigned cnt, unsigned const* cols1, unsigned const* cols2): m_cols1(cnt, cols1), m_cols2(cnt, cols2) {} - virtual void operator()(table_base & _t, const table_base & _intersected_obj) { + void operator()(table_base & _t, const table_base & _intersected_obj) override { lazy_table& t = get(_t); lazy_table const& it = get(_intersected_obj); t.set(alloc(lazy_table_filter_by_negation, t, it, m_cols1, m_cols2)); @@ -246,7 +246,7 @@ namespace datalog { m_col(col) { } - virtual void operator()(table_base& _t) { + void operator()(table_base& _t) override { lazy_table& t = get(_t); t.set(alloc(lazy_table_filter_equal, m_col, m_value, t)); } diff --git a/src/muz/rel/dl_lazy_table.h b/src/muz/rel/dl_lazy_table.h index 6752e5a5a..19ea6773e 100644 --- a/src/muz/rel/dl_lazy_table.h +++ b/src/muz/rel/dl_lazy_table.h @@ -48,37 +48,37 @@ namespace datalog { table_plugin(mk_name(p), p.get_manager()), m_plugin(p) {} - virtual bool can_handle_signature(const table_signature & s) { + bool can_handle_signature(const table_signature & s) override { return m_plugin.can_handle_signature(s); } - virtual table_base * mk_empty(const table_signature & s); + table_base * mk_empty(const table_signature & s) override; static table_plugin* mk_sparse(relation_manager& rm); protected: - virtual table_join_fn * mk_join_fn( + table_join_fn * mk_join_fn( const table_base & t1, const table_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual table_union_fn * mk_union_fn( - const table_base & tgt, const table_base & src, - const table_base * delta); - virtual table_transformer_fn * mk_project_fn( - const table_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual table_transformer_fn * mk_rename_fn( + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + table_union_fn * mk_union_fn( + const table_base & tgt, const table_base & src, + const table_base * delta) override; + table_transformer_fn * mk_project_fn( + const table_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + table_transformer_fn * mk_rename_fn( const table_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual table_mutator_fn * mk_filter_identical_fn( - const table_base & t, unsigned col_cnt, const unsigned * identical_cols); - virtual table_mutator_fn * mk_filter_equal_fn( - const table_base & t, const table_element & value, unsigned col); - virtual table_mutator_fn * mk_filter_interpreted_fn( - const table_base & t, app * condition); - virtual table_intersection_filter_fn * mk_filter_by_negation_fn( - const table_base & t, - const table_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols); + const unsigned * permutation_cycle) override; + table_mutator_fn * mk_filter_identical_fn( + const table_base & t, unsigned col_cnt, const unsigned * identical_cols) override; + table_mutator_fn * mk_filter_equal_fn( + const table_base & t, const table_element & value, unsigned col) override; + table_mutator_fn * mk_filter_interpreted_fn( + const table_base & t, app * condition) override; + table_intersection_filter_fn * mk_filter_by_negation_fn( + const table_base & t, + const table_base & negated_obj, unsigned joined_col_cnt, + const unsigned * t_cols, const unsigned * negated_cols) override; static lazy_table const& get(table_base const& tb); static lazy_table& get(table_base& tb); @@ -129,30 +129,30 @@ namespace datalog { m_ref(t) {} - virtual ~lazy_table() {} + ~lazy_table() override {} lazy_table_plugin& get_lplugin() const { return dynamic_cast(table_base::get_plugin()); } - virtual table_base * clone() const; - virtual table_base * complement(func_decl* p, const table_element * func_columns = 0) const; - virtual bool empty() const; - virtual bool contains_fact(const table_fact & f) const; - virtual void remove_fact(table_element const* fact); - virtual void remove_facts(unsigned fact_cnt, const table_fact * facts); - virtual void remove_facts(unsigned fact_cnt, const table_element * facts); - virtual void reset(); - virtual void add_fact(table_fact const& f); + table_base * clone() const override; + table_base * complement(func_decl* p, const table_element * func_columns = 0) const override; + bool empty() const override; + bool contains_fact(const table_fact & f) const override; + void remove_fact(table_element const* fact) override; + void remove_facts(unsigned fact_cnt, const table_fact * facts) override; + void remove_facts(unsigned fact_cnt, const table_element * facts) override; + void reset() override; + void add_fact(table_fact const& f) override; - virtual unsigned get_size_estimate_rows() const { return 1; } - virtual unsigned get_size_estimate_bytes() const { return 1; } - virtual bool knows_exact_size() const { return false; } + unsigned get_size_estimate_rows() const override { return 1; } + unsigned get_size_estimate_bytes() const override { return 1; } + bool knows_exact_size() const override { return false; } table_base* eval() const; - virtual table_base::iterator begin() const; - virtual table_base::iterator end() const; + table_base::iterator begin() const override; + table_base::iterator end() const override; lazy_table_ref* get_ref() const { return m_ref.get(); } void set(lazy_table_ref* r) { m_ref = r; } @@ -165,9 +165,9 @@ namespace datalog { m_table = table; // SASSERT(&p.m_plugin == &table->get_lplugin()); } - virtual ~lazy_table_base() {} - virtual lazy_table_kind kind() const { return LAZY_TABLE_BASE; } - virtual table_base* force() { return m_table.get(); } + ~lazy_table_base() override {} + lazy_table_kind kind() const override { return LAZY_TABLE_BASE; } + table_base* force() override { return m_table.get(); } }; class lazy_table_join : public lazy_table_ref { @@ -184,13 +184,13 @@ namespace datalog { m_cols2(col_cnt, cols2), m_t1(t1.get_ref()), m_t2(t2.get_ref()) { } - virtual ~lazy_table_join() {} - virtual lazy_table_kind kind() const { return LAZY_TABLE_JOIN; } + ~lazy_table_join() override {} + lazy_table_kind kind() const override { return LAZY_TABLE_JOIN; } unsigned_vector const& cols1() const { return m_cols1; } unsigned_vector const& cols2() const { return m_cols2; } lazy_table_ref* t1() const { return m_t1.get(); } lazy_table_ref* t2() const { return m_t2.get(); } - virtual table_base* force(); + table_base* force() override; }; @@ -202,12 +202,12 @@ namespace datalog { : lazy_table_ref(src.get_lplugin(), sig), m_cols(col_cnt, cols), m_src(src.get_ref()) {} - virtual ~lazy_table_project() {} + ~lazy_table_project() override {} - virtual lazy_table_kind kind() const { return LAZY_TABLE_PROJECT; } + lazy_table_kind kind() const override { return LAZY_TABLE_PROJECT; } unsigned_vector const& cols() const { return m_cols; } lazy_table_ref* src() const { return m_src.get(); } - virtual table_base* force(); + table_base* force() override; }; class lazy_table_rename : public lazy_table_ref { @@ -218,12 +218,12 @@ namespace datalog { : lazy_table_ref(src.get_lplugin(), sig), m_cols(col_cnt, cols), m_src(src.get_ref()) {} - virtual ~lazy_table_rename() {} + ~lazy_table_rename() override {} - virtual lazy_table_kind kind() const { return LAZY_TABLE_RENAME; } + lazy_table_kind kind() const override { return LAZY_TABLE_RENAME; } unsigned_vector const& cols() const { return m_cols; } lazy_table_ref* src() const { return m_src.get(); } - virtual table_base* force(); + table_base* force() override; }; class lazy_table_filter_identical : public lazy_table_ref { @@ -232,12 +232,12 @@ namespace datalog { public: lazy_table_filter_identical(unsigned col_cnt, const unsigned * cols, lazy_table const& src) : lazy_table_ref(src.get_lplugin(), src.get_signature()), m_cols(col_cnt, cols), m_src(src.get_ref()) {} - virtual ~lazy_table_filter_identical() {} + ~lazy_table_filter_identical() override {} - virtual lazy_table_kind kind() const { return LAZY_TABLE_FILTER_IDENTICAL; } + lazy_table_kind kind() const override { return LAZY_TABLE_FILTER_IDENTICAL; } unsigned_vector const& cols() const { return m_cols; } lazy_table_ref* src() const { return m_src.get(); } - virtual table_base* force(); + table_base* force() override; }; class lazy_table_filter_equal : public lazy_table_ref { @@ -250,13 +250,13 @@ namespace datalog { m_col(col), m_value(value), m_src(src.get_ref()) {} - virtual ~lazy_table_filter_equal() {} + ~lazy_table_filter_equal() override {} - virtual lazy_table_kind kind() const { return LAZY_TABLE_FILTER_EQUAL; } + lazy_table_kind kind() const override { return LAZY_TABLE_FILTER_EQUAL; } unsigned col() const { return m_col; } table_element value() const { return m_value; } lazy_table_ref* src() const { return m_src.get(); } - virtual table_base* force(); + table_base* force() override; }; class lazy_table_filter_interpreted : public lazy_table_ref { @@ -266,12 +266,12 @@ namespace datalog { lazy_table_filter_interpreted(lazy_table const& src, app* condition) : lazy_table_ref(src.get_lplugin(), src.get_signature()), m_condition(condition, src.get_lplugin().get_ast_manager()), m_src(src.get_ref()) {} - virtual ~lazy_table_filter_interpreted() {} + ~lazy_table_filter_interpreted() override {} - virtual lazy_table_kind kind() const { return LAZY_TABLE_FILTER_INTERPRETED; } + lazy_table_kind kind() const override { return LAZY_TABLE_FILTER_INTERPRETED; } app* condition() const { return m_condition; } lazy_table_ref* src() const { return m_src.get(); } - virtual table_base* force(); + table_base* force() override; }; @@ -288,13 +288,13 @@ namespace datalog { m_src(src.get_ref()), m_cols1(c1), m_cols2(c2) {} - virtual ~lazy_table_filter_by_negation() {} - virtual lazy_table_kind kind() const { return LAZY_TABLE_FILTER_BY_NEGATION; } + ~lazy_table_filter_by_negation() override {} + lazy_table_kind kind() const override { return LAZY_TABLE_FILTER_BY_NEGATION; } lazy_table_ref* tgt() const { return m_tgt.get(); } lazy_table_ref* src() const { return m_src.get(); } unsigned_vector const& cols1() const { return m_cols1; } unsigned_vector const& cols2() const { return m_cols2; } - virtual table_base* force(); + table_base* force() override; }; diff --git a/src/muz/rel/dl_mk_explanations.cpp b/src/muz/rel/dl_mk_explanations.cpp index ca04ca099..4823ffb9b 100644 --- a/src/muz/rel/dl_mk_explanations.cpp +++ b/src/muz/rel/dl_mk_explanations.cpp @@ -69,7 +69,7 @@ namespace datalog { m_relation_level_explanations(relation_level), m_union_decl(mk_explanations::get_union_decl(get_context()), get_ast_manager()) {} - ~explanation_relation_plugin() { + ~explanation_relation_plugin() override { for (unsigned i = 0; i < m_pool.size(); ++i) { for (unsigned j = 0; j < m_pool[i].size(); ++j) { dealloc(m_pool[i][j]); @@ -77,7 +77,7 @@ namespace datalog { } } - virtual bool can_handle_signature(const relation_signature & s) { + bool can_handle_signature(const relation_signature & s) override { unsigned n=s.size(); for (unsigned i=0; i(relation_base::get_plugin()); } - virtual void to_formula(expr_ref& fml) const { + void to_formula(expr_ref& fml) const override { ast_manager& m = fml.get_manager(); fml = m.mk_eq(m.mk_var(0, m.get_sort(m_data[0])), m_data[0]); } @@ -204,23 +204,23 @@ namespace datalog { return true; } - virtual bool empty() const { return m_empty; } + bool empty() const override { return m_empty; } - virtual void reset() { + void reset() override { m_empty = true; } - virtual void add_fact(const relation_fact & f) { + void add_fact(const relation_fact & f) override { SASSERT(empty()); assign_data(f); } - virtual bool contains_fact(const relation_fact & f) const { + bool contains_fact(const relation_fact & f) const override { UNREACHABLE(); throw 0; } - virtual explanation_relation * clone() const { + explanation_relation * clone() const override { explanation_relation * res = static_cast(get_plugin().mk_empty(get_signature())); res->m_empty = m_empty; SASSERT(res->m_data.empty()); @@ -228,7 +228,7 @@ namespace datalog { return res; } - virtual relation_base * complement(func_decl* pred) const { + relation_base * complement(func_decl* pred) const override { explanation_relation * res = static_cast(get_plugin().mk_empty(get_signature())); if (empty()) { res->set_undefined(); @@ -247,7 +247,7 @@ namespace datalog { } } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { if (empty()) { out << "\n"; return; @@ -298,7 +298,7 @@ namespace datalog { join_fn(const relation_signature & sig1, const relation_signature & sig2) : convenient_relation_join_fn(sig1, sig2, 0, 0, 0) {} - virtual relation_base * operator()(const relation_base & r1_0, const relation_base & r2_0) { + relation_base * operator()(const relation_base & r1_0, const relation_base & r2_0) override { const explanation_relation & r1 = static_cast(r1_0); const explanation_relation & r2 = static_cast(r2_0); explanation_relation_plugin & plugin = r1.get_plugin(); @@ -331,7 +331,7 @@ namespace datalog { project_fn(const relation_signature & sig, unsigned col_cnt, const unsigned * removed_cols) : convenient_relation_project_fn(sig, col_cnt, removed_cols) {} - virtual relation_base * operator()(const relation_base & r0) { + relation_base * operator()(const relation_base & r0) override { const explanation_relation & r = static_cast(r0); explanation_relation_plugin & plugin = r.get_plugin(); @@ -359,7 +359,7 @@ namespace datalog { rename_fn(const relation_signature & sig, unsigned permutation_cycle_len, const unsigned * permutation_cycle) : convenient_relation_rename_fn(sig, permutation_cycle_len, permutation_cycle) {} - virtual relation_base * operator()(const relation_base & r0) { + relation_base * operator()(const relation_base & r0) override { const explanation_relation & r = static_cast(r0); explanation_relation_plugin & plugin = r.get_plugin(); @@ -382,7 +382,7 @@ namespace datalog { class explanation_relation_plugin::union_fn : public relation_union_fn { scoped_ptr m_delta_union_fun; public: - virtual void operator()(relation_base & tgt0, const relation_base & src0, relation_base * delta0) { + void operator()(relation_base & tgt0, const relation_base & src0, relation_base * delta0) override { explanation_relation & tgt = static_cast(tgt0); const explanation_relation & src = static_cast(src0); explanation_relation * delta = delta0 ? static_cast(delta0) : 0; @@ -418,7 +418,7 @@ namespace datalog { class explanation_relation_plugin::foreign_union_fn : public relation_union_fn { scoped_ptr m_delta_union_fun; public: - virtual void operator()(relation_base & tgt0, const relation_base & src, relation_base * delta0) { + void operator()(relation_base & tgt0, const relation_base & src, relation_base * delta0) override { explanation_relation & tgt = static_cast(tgt0); explanation_relation * delta = delta0 ? static_cast(delta0) : 0; @@ -456,7 +456,7 @@ namespace datalog { m_col_idx(col_idx), m_new_rule(std::move(new_rule)) {} - virtual void operator()(relation_base & r0) { + void operator()(relation_base & r0) override { explanation_relation & r = static_cast(r0); if (!r.is_undefined(m_col_idx)) { @@ -509,7 +509,7 @@ namespace datalog { class explanation_relation_plugin::negation_filter_fn : public relation_intersection_filter_fn { public: - virtual void operator()(relation_base & r, const relation_base & neg) { + void operator()(relation_base & r, const relation_base & neg) override { if (!neg.empty()) { r.reset(); } @@ -531,7 +531,7 @@ namespace datalog { intersection_filter_fn(explanation_relation_plugin & plugin) : m_union_decl(plugin.m_union_decl) {} - virtual void operator()(relation_base & tgt0, const relation_base & src0) { + void operator()(relation_base & tgt0, const relation_base & src0) override { explanation_relation & tgt = static_cast(tgt0); const explanation_relation & src = static_cast(src0); diff --git a/src/muz/rel/dl_mk_explanations.h b/src/muz/rel/dl_mk_explanations.h index 6142b61d6..a96d50cb3 100644 --- a/src/muz/rel/dl_mk_explanations.h +++ b/src/muz/rel/dl_mk_explanations.h @@ -76,7 +76,7 @@ namespace datalog { return get_union_decl(m_context); } - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; static expr* get_explanation(relation_base const& r); }; diff --git a/src/muz/rel/dl_mk_similarity_compressor.h b/src/muz/rel/dl_mk_similarity_compressor.h index 096305c59..da56e9eca 100644 --- a/src/muz/rel/dl_mk_similarity_compressor.h +++ b/src/muz/rel/dl_mk_similarity_compressor.h @@ -69,7 +69,7 @@ namespace datalog { public: mk_similarity_compressor(context & ctx); - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/rel/dl_mk_simple_joins.h b/src/muz/rel/dl_mk_simple_joins.h index cf4522c22..8eb6bd0c2 100644 --- a/src/muz/rel/dl_mk_simple_joins.h +++ b/src/muz/rel/dl_mk_simple_joins.h @@ -54,7 +54,7 @@ namespace datalog { public: mk_simple_joins(context & ctx); - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/rel/dl_product_relation.cpp b/src/muz/rel/dl_product_relation.cpp index 1a91d6828..56fd56505 100644 --- a/src/muz/rel/dl_product_relation.cpp +++ b/src/muz/rel/dl_product_relation.cpp @@ -444,12 +444,12 @@ namespace datalog { init(r1.get_signature(), 1, rels1, r2.get_signature(), 1, rels2, col_cnt, cols1, cols2); } - ~join_fn() { + ~join_fn() override { dealloc_ptr_vector_content(m_joins); dealloc_ptr_vector_content(m_full); } - virtual relation_base * operator()(const relation_base & _r1, const relation_base & _r2) { + relation_base * operator()(const relation_base & _r1, const relation_base & _r2) override { TRACE("dl", _r1.display(tout); _r2.display(tout);); ptr_vector relations; unsigned sz = m_joins.size(); @@ -491,9 +491,9 @@ namespace datalog { m_sig(std::move(s)), m_transforms(num_trans, trans) {} - ~transform_fn() { dealloc_ptr_vector_content(m_transforms); } + ~transform_fn() override { dealloc_ptr_vector_content(m_transforms); } - virtual relation_base * operator()(const relation_base & _r) { + relation_base * operator()(const relation_base & _r) override { product_relation const& r = get(_r); product_relation_plugin& p = r.get_plugin(); SASSERT(m_transforms.size() == r.size()); @@ -628,14 +628,14 @@ namespace datalog { init(tgt.m_relations, src.m_relations, delta ? &delta->m_relations : 0); } - ~aligned_union_fn() { + ~aligned_union_fn() override { unsigned sz = m_unions.size(); for(unsigned i=0; iis_precise()) { return false; diff --git a/src/muz/rel/dl_relation_manager.cpp b/src/muz/rel/dl_relation_manager.cpp index 1eb973776..8226d0198 100644 --- a/src/muz/rel/dl_relation_manager.cpp +++ b/src/muz/rel/dl_relation_manager.cpp @@ -538,7 +538,7 @@ namespace datalog { class relation_manager::empty_signature_relation_join_fn : public relation_join_fn { public: - virtual relation_base * operator()(const relation_base & r1, const relation_base & r2) { + relation_base * operator()(const relation_base & r1, const relation_base & r2) override { TRACE("dl", tout << r1.get_plugin().get_name() << " " << r2.get_plugin().get_name() << "\n";); if(r1.get_signature().empty()) { if(r1.empty()) { @@ -615,7 +615,7 @@ namespace datalog { m_project(0), m_removed_cols(removed_col_cnt, removed_cols) {} - virtual relation_base * operator()(const relation_base & t) { + relation_base * operator()(const relation_base & t) override { scoped_rel t1 = t.clone(); (*m_filter)(*t1); if( !m_project) { @@ -658,11 +658,11 @@ namespace datalog { default_relation_apply_sequential_fn(unsigned n, relation_mutator_fn ** mutators): m_mutators(n, mutators) { } - virtual ~default_relation_apply_sequential_fn() { + ~default_relation_apply_sequential_fn() override { std::for_each(m_mutators.begin(), m_mutators.end(), delete_proc()); } - virtual void operator()(relation_base& t) { + void operator()(relation_base& t) override { for (unsigned i = 0; i < m_mutators.size(); ++i) { if (t.empty()) return; (*(m_mutators[i]))(t); @@ -688,7 +688,7 @@ namespace datalog { const unsigned * removed_cols) : m_join(join), m_project(0), m_removed_cols(removed_col_cnt, removed_cols) {} - virtual relation_base * operator()(const relation_base & t1, const relation_base & t2) { + relation_base * operator()(const relation_base & t1, const relation_base & t2) override { scoped_rel aux = (*m_join)(t1, t2); if(!m_project) { relation_manager & rmgr = aux->get_plugin().get_manager(); @@ -787,7 +787,7 @@ namespace datalog { default_relation_select_equal_and_project_fn(relation_mutator_fn * filter, relation_transformer_fn * project) : m_filter(filter), m_project(project) {} - virtual relation_base * operator()(const relation_base & t1) { + relation_base * operator()(const relation_base & t1) override { TRACE("dl", tout << t1.get_plugin().get_name() << "\n";); scoped_rel aux = t1.clone(); (*m_filter)(*aux); @@ -823,7 +823,7 @@ namespace datalog { default_relation_intersection_filter_fn(relation_join_fn * join_fun, relation_union_fn * union_fun) : m_join_fun(join_fun), m_union_fun(union_fun) {} - virtual void operator()(relation_base & tgt, const relation_base & intersected_obj) { + void operator()(relation_base & tgt, const relation_base & intersected_obj) override { scoped_rel filtered_rel = (*m_join_fun)(tgt, intersected_obj); TRACE("dl", tgt.display(tout << "tgt:\n"); @@ -926,7 +926,7 @@ namespace datalog { const unsigned * cols1, const unsigned * cols2) : convenient_table_join_fn(t1_sig, t2_sig, col_cnt, cols1, cols2), m_col_cnt(col_cnt) {} - virtual table_base * operator()(const table_base & t1, const table_base & t2) { + table_base * operator()(const table_base & t1, const table_base & t2) override { table_plugin * plugin = &t1.get_plugin(); const table_signature & res_sign = get_result_signature(); @@ -1037,15 +1037,15 @@ namespace datalog { SASSERT(removed_col_cnt>0); } - virtual const table_signature & get_result_signature() const { + const table_signature & get_result_signature() const override { return convenient_table_project_fn::get_result_signature(); } - virtual void modify_fact(table_fact & f) const { + void modify_fact(table_fact & f) const override { project_out_vector_columns(f, m_removed_cols); } - virtual table_base * operator()(const table_base & t) { + table_base * operator()(const table_base & t) override { return auxiliary_table_transformer_fn::operator()(t); } }; @@ -1054,7 +1054,7 @@ namespace datalog { const table_signature m_empty_sig; public: null_signature_table_project_fn() : m_empty_sig() {} - virtual table_base * operator()(const table_base & t) { + table_base * operator()(const table_base & t) override { relation_manager & m = t.get_plugin().get_manager(); table_base * res = m.mk_empty_table(m_empty_sig); if(!t.empty()) { @@ -1096,14 +1096,14 @@ namespace datalog { m_removed_cols(removed_col_cnt, removed_cols) {} class unreachable_reducer : public table_row_pair_reduce_fn { - virtual void operator()(table_element * func_columns, const table_element * merged_func_columns) { + void operator()(table_element * func_columns, const table_element * merged_func_columns) override { //we do project_with_reduce only if we are sure there will be no reductions //(see code of the table_signature::from_join_project function) UNREACHABLE(); } }; - virtual table_base * operator()(const table_base & t1, const table_base & t2) { + table_base * operator()(const table_base & t1, const table_base & t2) override { table_base * aux = (*m_join)(t1, t2); if(m_project==0) { relation_manager & rmgr = aux->get_plugin().get_manager(); @@ -1154,15 +1154,15 @@ namespace datalog { SASSERT(permutation_cycle_len>=2); } - virtual const table_signature & get_result_signature() const { + const table_signature & get_result_signature() const override { return convenient_table_rename_fn::get_result_signature(); } - virtual void modify_fact(table_fact & f) const { + void modify_fact(table_fact & f) const override { permutate_by_cycle(f, m_cycle); } - virtual table_base * operator()(const table_base & t) { + table_base * operator()(const table_base & t) override { return auxiliary_table_transformer_fn::operator()(t); } @@ -1190,7 +1190,7 @@ namespace datalog { class relation_manager::default_table_union_fn : public table_union_fn { table_fact m_row; public: - virtual void operator()(table_base & tgt, const table_base & src, table_base * delta) { + void operator()(table_base & tgt, const table_base & src, table_base * delta) override { table_base::iterator it = src.begin(); table_base::iterator iend = src.end(); @@ -1283,7 +1283,7 @@ namespace datalog { SASSERT(col_cnt>=2); } - virtual bool should_remove(const table_fact & f) const { + bool should_remove(const table_fact & f) const override { table_element val=f[m_identical_cols[0]]; for(unsigned i=1; i(m_args); args.reset(); @@ -1425,7 +1425,7 @@ namespace datalog { return m_ast_manager.is_false(ground); } - virtual void operator()(table_base & t) { + void operator()(table_base & t) override { auxiliary_table_filter_fn::operator()(t); } }; @@ -1455,7 +1455,7 @@ namespace datalog { : m_filter(filter), m_condition(condition, ctx.get_manager()), m_removed_cols(removed_col_cnt, removed_cols) {} - virtual table_base* operator()(const table_base & tb) { + table_base* operator()(const table_base & tb) override { table_base *t2 = tb.clone(); (*m_filter)(*t2); if (!m_project) { @@ -1506,7 +1506,7 @@ namespace datalog { m_aux_fact.resize(neg_t.get_signature().size()); } - virtual bool should_remove(const table_fact & f) const { + bool should_remove(const table_fact & f) const override { if(!m_all_neg_bound || m_overlap) { table_base::iterator nit = m_negated_table->begin(); table_base::iterator nend = m_negated_table->end(); @@ -1524,7 +1524,7 @@ namespace datalog { } } - virtual void operator()(table_base & tgt, const table_base & negated_table) { + void operator()(table_base & tgt, const table_base & negated_table) override { SASSERT(m_negated_table==0); flet flet_neg_table(m_negated_table, &negated_table); auxiliary_table_filter_fn::operator()(tgt); @@ -1568,7 +1568,7 @@ namespace datalog { default_table_select_equal_and_project_fn(table_mutator_fn * filter, table_transformer_fn * project) : m_filter(filter), m_project(project) {} - virtual table_base * operator()(const table_base & t1) { + table_base * operator()(const table_base & t1) override { TRACE("dl", tout << t1.get_plugin().get_name() << "\n";); scoped_rel aux = t1.clone(); (*m_filter)(*aux); @@ -1606,9 +1606,9 @@ namespace datalog { m_union_fn = plugin.mk_union_fn(t, *m_aux_table, static_cast(0)); } - virtual ~default_table_map_fn() {} + ~default_table_map_fn() override {} - virtual void operator()(table_base & t) { + void operator()(table_base & t) override { SASSERT(t.get_signature()==m_aux_table->get_signature()); if(!m_aux_table->empty()) { m_aux_table->reset(); @@ -1664,7 +1664,7 @@ namespace datalog { m_former_row.resize(get_result_signature().size()); } - virtual ~default_table_project_with_reduce_fn() {} + ~default_table_project_with_reduce_fn() override {} virtual void modify_fact(table_fact & f) const { unsigned ofs=1; @@ -1693,7 +1693,7 @@ namespace datalog { } } - virtual table_base * operator()(const table_base & t) { + table_base * operator()(const table_base & t) override { table_plugin & plugin = t.get_plugin(); const table_signature & res_sign = get_result_signature(); SASSERT(plugin.can_handle_signature(res_sign)); diff --git a/src/muz/rel/dl_sieve_relation.cpp b/src/muz/rel/dl_sieve_relation.cpp index 7e274cbef..401d519d5 100644 --- a/src/muz/rel/dl_sieve_relation.cpp +++ b/src/muz/rel/dl_sieve_relation.cpp @@ -294,7 +294,7 @@ namespace datalog { } } - virtual relation_base * operator()(const relation_base & r1, const relation_base & r2) { + relation_base * operator()(const relation_base & r1, const relation_base & r2) override { bool r1_sieved = r1.get_plugin().is_sieve_relation(); bool r2_sieved = r2.get_plugin().is_sieve_relation(); SASSERT(r1_sieved || r2_sieved); @@ -357,7 +357,7 @@ namespace datalog { get_result_signature() = result_sig; } - virtual relation_base * operator()(const relation_base & r0) { + relation_base * operator()(const relation_base & r0) override { SASSERT(r0.get_plugin().is_sieve_relation()); const sieve_relation & r = static_cast(r0); sieve_relation_plugin & plugin = r.get_plugin(); @@ -439,7 +439,7 @@ namespace datalog { public: union_fn(relation_union_fn * union_fun) : m_union_fun(union_fun) {} - virtual void operator()(relation_base & tgt, const relation_base & src, relation_base * delta) { + void operator()(relation_base & tgt, const relation_base & src, relation_base * delta) override { bool tgt_sieved = tgt.get_plugin().is_sieve_relation(); bool src_sieved = src.get_plugin().is_sieve_relation(); bool delta_sieved = delta && delta->get_plugin().is_sieve_relation(); @@ -504,7 +504,7 @@ namespace datalog { filter_fn(relation_mutator_fn * inner_fun) : m_inner_fun(inner_fun) {} - virtual void operator()(relation_base & r0) { + void operator()(relation_base & r0) override { SASSERT(r0.get_plugin().is_sieve_relation()); sieve_relation & r = static_cast(r0); @@ -600,7 +600,7 @@ namespace datalog { negation_filter_fn(relation_intersection_filter_fn * inner_fun) : m_inner_fun(inner_fun) {} - virtual void operator()(relation_base & r, const relation_base & neg) { + void operator()(relation_base & r, const relation_base & neg) override { bool r_sieved = r.get_plugin().is_sieve_relation(); bool neg_sieved = neg.get_plugin().is_sieve_relation(); SASSERT(r_sieved || neg_sieved); diff --git a/src/muz/rel/dl_sieve_relation.h b/src/muz/rel/dl_sieve_relation.h index e369e04aa..5f20cecb4 100644 --- a/src/muz/rel/dl_sieve_relation.h +++ b/src/muz/rel/dl_sieve_relation.h @@ -85,7 +85,7 @@ namespace datalog { sieve_relation_plugin(relation_manager & manager); - virtual void initialize(family_id fid); + void initialize(family_id fid) override; family_id get_relation_kind(const relation_signature & sig, const bool * inner_columns, family_id inner_kind); @@ -95,15 +95,15 @@ namespace datalog { return get_relation_kind(sig, inner_columns.c_ptr(), inner_kind); } - virtual bool can_handle_signature(const relation_signature & s); + bool can_handle_signature(const relation_signature & s) override; - virtual relation_base * mk_empty(const relation_signature & s); + relation_base * mk_empty(const relation_signature & s) override; sieve_relation * mk_empty(const sieve_relation & original); - virtual relation_base * mk_empty(const relation_base & original); - virtual relation_base * mk_empty(const relation_signature & s, family_id kind); + relation_base * mk_empty(const relation_base & original) override; + relation_base * mk_empty(const relation_signature & s, family_id kind) override; sieve_relation * mk_empty(const relation_signature & s, relation_plugin & inner_plugin); - virtual relation_base * mk_full(func_decl* p, const relation_signature & s); + relation_base * mk_full(func_decl* p, const relation_signature & s) override; sieve_relation * full(func_decl* p, const relation_signature & s, relation_plugin & inner_plugin); sieve_relation * mk_from_inner(const relation_signature & s, const bool * inner_columns, @@ -116,22 +116,22 @@ namespace datalog { protected: - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); - virtual relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, - const relation_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols); + relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; + relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, + const relation_base & negated_obj, unsigned joined_col_cnt, + const unsigned * t_cols, const unsigned * negated_cols) override; }; @@ -176,18 +176,18 @@ namespace datalog { relation_base & get_inner() { return *m_inner; } const relation_base & get_inner() const { return *m_inner; } - virtual void add_fact(const relation_fact & f); - virtual bool contains_fact(const relation_fact & f) const; - virtual sieve_relation * clone() const; - virtual relation_base * complement(func_decl*p) const; - virtual void to_formula(expr_ref& fml) const; + void add_fact(const relation_fact & f) override; + bool contains_fact(const relation_fact & f) const override; + sieve_relation * clone() const override; + relation_base * complement(func_decl*p) const override; + void to_formula(expr_ref& fml) const override; - virtual bool empty() const { return get_inner().empty(); } - virtual void reset() { get_inner().reset(); } - virtual unsigned get_size_estimate_rows() const { return get_inner().get_size_estimate_rows(); } - virtual unsigned get_size_estimate_bytes() const { return get_inner().get_size_estimate_bytes(); } + bool empty() const override { return get_inner().empty(); } + void reset() override { get_inner().reset(); } + unsigned get_size_estimate_rows() const override { return get_inner().get_size_estimate_rows(); } + unsigned get_size_estimate_bytes() const override { return get_inner().get_size_estimate_bytes(); } - virtual void display(std::ostream & out) const; + void display(std::ostream & out) const override; }; diff --git a/src/muz/rel/dl_sparse_table.cpp b/src/muz/rel/dl_sparse_table.cpp index 6048f358b..50386152c 100644 --- a/src/muz/rel/dl_sparse_table.cpp +++ b/src/muz/rel/dl_sparse_table.cpp @@ -198,7 +198,7 @@ namespace datalog { row_interface(t), m_parent(parent) {} - virtual table_element operator[](unsigned col) const { + table_element operator[](unsigned col) const override { return m_parent.m_layout.get(m_parent.m_ptr, col); } @@ -218,15 +218,15 @@ namespace datalog { m_row_obj(t, *this), m_layout(t.m_column_layout) {} - virtual bool is_finished() const { + bool is_finished() const override { return m_ptr == m_end; } - virtual row_interface & operator*() { + row_interface & operator*() override { SASSERT(!is_finished()); return m_row_obj; } - virtual void operator++() { + void operator++() override { SASSERT(!is_finished()); m_ptr+=m_fact_size; } @@ -312,7 +312,7 @@ namespace datalog { m_keys(key_len*sizeof(table_element)), m_first_nonindexed(0) {} - virtual void update(const sparse_table & t) { + void update(const sparse_table & t) override { if (m_first_nonindexed == t.m_data.after_last_offset()) { return; } @@ -351,7 +351,7 @@ namespace datalog { m_first_nonindexed = t.m_data.after_last_offset(); } - virtual query_result get_matching_offsets(const key_value & key) const { + query_result get_matching_offsets(const key_value & key) const override { key_to_reserve(key); store_offset ofs; if (!m_keys.find_reserve_content(ofs)) { @@ -406,9 +406,9 @@ namespace datalog { m_key_fact.resize(t.get_signature().size()); } - virtual ~full_signature_key_indexer() {} + ~full_signature_key_indexer() override {} - virtual query_result get_matching_offsets(const key_value & key) const { + query_result get_matching_offsets(const key_value & key) const override { unsigned key_len = m_key_cols.size(); for (unsigned i=0; i0; } - virtual table_base * mk_empty(const table_signature & s); + table_base * mk_empty(const table_signature & s) override; sparse_table * mk_clone(const sparse_table & t); protected: - virtual table_join_fn * mk_join_fn(const table_base & t1, const table_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual table_join_fn * mk_join_project_fn(const table_base & t1, const table_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, - const unsigned * removed_cols); - virtual table_union_fn * mk_union_fn(const table_base & tgt, const table_base & src, - const table_base * delta); - virtual table_transformer_fn * mk_project_fn(const table_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual table_transformer_fn * mk_rename_fn(const table_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual table_transformer_fn * mk_select_equal_and_project_fn(const table_base & t, - const table_element & value, unsigned col); - virtual table_intersection_filter_fn * mk_filter_by_negation_fn(const table_base & t, - const table_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols); - virtual table_intersection_join_filter_fn* mk_filter_by_negated_join_fn( - const table_base & t, - const table_base & src1, - const table_base & src2, + table_join_fn * mk_join_fn(const table_base & t1, const table_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + table_join_fn * mk_join_project_fn(const table_base & t1, const table_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, + const unsigned * removed_cols) override; + table_union_fn * mk_union_fn(const table_base & tgt, const table_base & src, + const table_base * delta) override; + table_transformer_fn * mk_project_fn(const table_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + table_transformer_fn * mk_rename_fn(const table_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + table_transformer_fn * mk_select_equal_and_project_fn(const table_base & t, + const table_element & value, unsigned col) override; + table_intersection_filter_fn * mk_filter_by_negation_fn(const table_base & t, + const table_base & negated_obj, unsigned joined_col_cnt, + const unsigned * t_cols, const unsigned * negated_cols) override; + table_intersection_join_filter_fn* mk_filter_by_negated_join_fn( + const table_base & t, + const table_base & src1, + const table_base & src2, unsigned_vector const& t_cols, unsigned_vector const& src_cols, unsigned_vector const& src1_cols, - unsigned_vector const& src2_cols); + unsigned_vector const& src2_cols) override; static sparse_table const& get(table_base const&); static sparse_table& get(table_base&); @@ -463,10 +463,10 @@ namespace datalog { sparse_table(sparse_table_plugin & p, const table_signature & sig, unsigned init_capacity=0); sparse_table(const sparse_table & t); - virtual ~sparse_table(); + ~sparse_table() override; public: - virtual void deallocate() { + void deallocate() override { get_plugin().recycle(this); } @@ -475,22 +475,22 @@ namespace datalog { sparse_table_plugin & get_plugin() const { return static_cast(table_base::get_plugin()); } - virtual bool empty() const { return row_count()==0; } - virtual void add_fact(const table_fact & f); - virtual bool contains_fact(const table_fact & f) const; - virtual bool fetch_fact(table_fact & f) const; - virtual void ensure_fact(const table_fact & f); - virtual void remove_fact(const table_element* fact); - virtual void reset(); + bool empty() const override { return row_count()==0; } + void add_fact(const table_fact & f) override; + bool contains_fact(const table_fact & f) const override; + bool fetch_fact(table_fact & f) const override; + void ensure_fact(const table_fact & f) override; + void remove_fact(const table_element* fact) override; + void reset() override; - virtual table_base * clone() const; + table_base * clone() const override; - virtual table_base::iterator begin() const; - virtual table_base::iterator end() const; + table_base::iterator begin() const override; + table_base::iterator end() const override; - virtual unsigned get_size_estimate_rows() const { return row_count(); } - virtual unsigned get_size_estimate_bytes() const; - virtual bool knows_exact_size() const { return true; } + unsigned get_size_estimate_rows() const override { return row_count(); } + unsigned get_size_estimate_bytes() const override; + bool knows_exact_size() const override { return true; } }; }; diff --git a/src/muz/rel/dl_table.cpp b/src/muz/rel/dl_table.cpp index 1c068a878..963820c91 100644 --- a/src/muz/rel/dl_table.cpp +++ b/src/muz/rel/dl_table.cpp @@ -43,7 +43,7 @@ namespace datalog { : convenient_table_join_fn(t1_sig, t2_sig, col_cnt, cols1, cols2), m_joined_col_cnt(col_cnt) {} - virtual table_base * operator()(const table_base & t1, const table_base & t2) { + table_base * operator()(const table_base & t1, const table_base & t2) override { const hashtable_table & ht1 = static_cast(t1); const hashtable_table & ht2 = static_cast(t2); @@ -105,10 +105,10 @@ namespace datalog { public: our_row(const our_iterator_core & parent) : row_interface(parent.m_parent), m_parent(parent) {} - virtual void get_fact(table_fact & result) const { + void get_fact(table_fact & result) const override { result = *m_parent.m_inner; } - virtual table_element operator[](unsigned col) const { + table_element operator[](unsigned col) const override { return (*m_parent.m_inner)[col]; } @@ -121,15 +121,15 @@ namespace datalog { m_parent(t), m_inner(finished ? t.m_data.end() : t.m_data.begin()), m_end(t.m_data.end()), m_row_obj(*this) {} - virtual bool is_finished() const { + bool is_finished() const override { return m_inner==m_end; } - virtual row_interface & operator*() { + row_interface & operator*() override { SASSERT(!is_finished()); return m_row_obj; } - virtual void operator++() { + void operator++() override { SASSERT(!is_finished()); ++m_inner; } @@ -192,7 +192,7 @@ namespace datalog { const bv_iterator& m_parent; public: our_row(const bv_iterator & p) : caching_row_interface(p.m_bv), m_parent(p) {} - virtual void get_fact(table_fact& result) const { + void get_fact(table_fact& result) const override { if (result.size() < size()) { result.resize(size(), 0); } @@ -210,15 +210,15 @@ namespace datalog { } } - virtual bool is_finished() const { + bool is_finished() const override { return m_offset == m_bv.m_bv.size(); } - virtual row_interface & operator*() { + row_interface & operator*() override { SASSERT(!is_finished()); return m_row_obj; } - virtual void operator++() { + void operator++() override { SASSERT(!is_finished()); ++m_offset; while (!is_finished() && !m_bv.m_bv.get(m_offset)) { diff --git a/src/muz/rel/dl_table.h b/src/muz/rel/dl_table.h index c428191af..168108e65 100644 --- a/src/muz/rel/dl_table.h +++ b/src/muz/rel/dl_table.h @@ -61,10 +61,10 @@ namespace datalog { hashtable_table_plugin(relation_manager & manager) : table_plugin(symbol("hashtable"), manager) {} - virtual table_base * mk_empty(const table_signature & s); + table_base * mk_empty(const table_signature & s) override; - virtual table_join_fn * mk_join_fn(const table_base & t1, const table_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); + table_join_fn * mk_join_fn(const table_base & t1, const table_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; }; class hashtable_table : public table_base { @@ -84,23 +84,23 @@ namespace datalog { hashtable_table_plugin & get_plugin() const { return static_cast(table_base::get_plugin()); } - virtual void add_fact(const table_fact & f) { + void add_fact(const table_fact & f) override { m_data.insert(f); } - virtual void remove_fact(const table_element* fact) { + void remove_fact(const table_element* fact) override { table_fact f(get_signature().size(), fact); m_data.remove(f); } - virtual bool contains_fact(const table_fact & f) const { + bool contains_fact(const table_fact & f) const override { return m_data.contains(f); } - virtual iterator begin() const; - virtual iterator end() const; + iterator begin() const override; + iterator end() const override; - virtual unsigned get_size_estimate_rows() const { return m_data.size(); } - virtual unsigned get_size_estimate_bytes() const { return m_data.size()*get_signature().size()*8; } - virtual bool knows_exact_size() const { return true; } + unsigned get_size_estimate_rows() const override { return m_data.size(); } + unsigned get_size_estimate_bytes() const override { return m_data.size()*get_signature().size()*8; } + bool knows_exact_size() const override { return true; } }; // ----------------------------------- @@ -118,9 +118,9 @@ namespace datalog { bitvector_table_plugin(relation_manager & manager) : table_plugin(symbol("bitvector"), manager) {} - virtual bool can_handle_signature(const table_signature & s); + bool can_handle_signature(const table_signature & s) override; - virtual table_base * mk_empty(const table_signature & s); + table_base * mk_empty(const table_signature & s) override; }; class bitvector_table : public table_base { @@ -137,11 +137,11 @@ namespace datalog { bitvector_table(bitvector_table_plugin & plugin, const table_signature & sig); public: - virtual void add_fact(const table_fact & f); - virtual void remove_fact(const table_element* fact); - virtual bool contains_fact(const table_fact & f) const; - virtual iterator begin() const; - virtual iterator end() const; + void add_fact(const table_fact & f) override; + void remove_fact(const table_element* fact) override; + bool contains_fact(const table_fact & f) const override; + iterator begin() const override; + iterator end() const override; }; diff --git a/src/muz/rel/dl_table_relation.cpp b/src/muz/rel/dl_table_relation.cpp index b8cf8e724..d5d8fd3c9 100644 --- a/src/muz/rel/dl_table_relation.cpp +++ b/src/muz/rel/dl_table_relation.cpp @@ -82,7 +82,7 @@ namespace datalog { : convenient_relation_join_project_fn(s1, s2, col_cnt, cols1, cols2, removed_col_cnt, removed_cols), m_tfun(tfun) {} - virtual relation_base * operator()(const relation_base & t1, const relation_base & t2) { + relation_base * operator()(const relation_base & t1, const relation_base & t2) override { SASSERT(t1.from_table()); SASSERT(t2.from_table()); table_relation_plugin & plugin = static_cast(t1.get_plugin()); @@ -146,7 +146,7 @@ namespace datalog { tr_transformer_fn(const relation_signature & rsig, table_transformer_fn * tfun) : m_tfun(tfun) { get_result_signature() = rsig; } - virtual relation_base * operator()(const relation_base & t) { + relation_base * operator()(const relation_base & t) override { SASSERT(t.from_table()); table_relation_plugin & plugin = static_cast(t.get_plugin()); @@ -235,7 +235,7 @@ namespace datalog { by iterating through the table and calling \c add_fact of the target relation. */ class table_relation_plugin::universal_target_union_fn : public relation_union_fn { - virtual void operator()(relation_base & tgt, const relation_base & src, relation_base * delta) { + void operator()(relation_base & tgt, const relation_base & src, relation_base * delta) override { SASSERT(src.from_table()); const table_relation & tr_src = static_cast(src); @@ -271,7 +271,7 @@ namespace datalog { public: tr_union_fn(table_union_fn * tfun) : m_tfun(tfun) {} - virtual void operator()(relation_base & tgt, const relation_base & src, relation_base * delta) { + void operator()(relation_base & tgt, const relation_base & src, relation_base * delta) override { SASSERT(tgt.from_table()); SASSERT(src.from_table()); SASSERT(!delta || delta->from_table()); @@ -311,7 +311,7 @@ namespace datalog { public: tr_mutator_fn(table_mutator_fn * tfun) : m_tfun(tfun) {} - virtual void operator()(relation_base & r) { + void operator()(relation_base & r) override { SASSERT(r.from_table()); table_relation & tr = static_cast(r); (*m_tfun)(tr.get_table()); @@ -377,7 +377,7 @@ namespace datalog { public: tr_intersection_filter_fn(table_intersection_filter_fn * tfun) : m_tfun(tfun) {} - virtual void operator()(relation_base & r, const relation_base & src) { + void operator()(relation_base & r, const relation_base & src) override { SASSERT(r.from_table()); SASSERT(src.from_table()); diff --git a/src/muz/rel/dl_table_relation.h b/src/muz/rel/dl_table_relation.h index 16ff8c482..8ebb6d44d 100644 --- a/src/muz/rel/dl_table_relation.h +++ b/src/muz/rel/dl_table_relation.h @@ -46,40 +46,40 @@ namespace datalog { table_plugin & get_table_plugin() { return m_table_plugin; } - virtual bool can_handle_signature(const relation_signature & s); + bool can_handle_signature(const relation_signature & s) override; - virtual relation_base * mk_empty(const relation_signature & s); + relation_base * mk_empty(const relation_signature & s) override; virtual relation_base * mk_full_relation(const relation_signature & s, func_decl* p, family_id kind); relation_base * mk_from_table(const relation_signature & s, table_base * t); protected: - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_join_fn * mk_join_project_fn(const relation_base & t1, const relation_base & t2, - unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_transformer_fn * mk_permutation_rename_fn(const relation_base & t, - const unsigned * permutation); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); - virtual relation_transformer_fn * mk_filter_interpreted_and_project_fn(const relation_base & t, - app * condition, unsigned removed_col_cnt, const unsigned * removed_cols); - virtual relation_intersection_filter_fn * mk_filter_by_intersection_fn(const relation_base & t, - const relation_base & src, unsigned joined_col_cnt, const unsigned * t_cols, const unsigned * src_cols); - virtual relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, - const relation_base & negated_obj, unsigned joined_col_cnt, - const unsigned * t_cols, const unsigned * negated_cols); - virtual relation_transformer_fn * mk_select_equal_and_project_fn(const relation_base & t, - const relation_element & value, unsigned col); + relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_join_fn * mk_join_project_fn(const relation_base & t1, const relation_base & t2, + unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_transformer_fn * mk_permutation_rename_fn(const relation_base & t, + const unsigned * permutation) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; + relation_transformer_fn * mk_filter_interpreted_and_project_fn(const relation_base & t, + app * condition, unsigned removed_col_cnt, const unsigned * removed_cols) override; + relation_intersection_filter_fn * mk_filter_by_intersection_fn(const relation_base & t, + const relation_base & src, unsigned joined_col_cnt, const unsigned * t_cols, const unsigned * src_cols) override; + relation_intersection_filter_fn * mk_filter_by_negation_fn(const relation_base & t, + const relation_base & negated_obj, unsigned joined_col_cnt, + const unsigned * t_cols, const unsigned * negated_cols) override; + relation_transformer_fn * mk_select_equal_and_project_fn(const relation_base & t, + const relation_element & value, unsigned col) override; }; class table_relation : public relation_base { @@ -107,24 +107,24 @@ namespace datalog { table_base & get_table() { return *m_table; } const table_base & get_table() const { return *m_table; } - virtual bool empty() const { return m_table->empty(); } + bool empty() const override { return m_table->empty(); } void add_table_fact(const table_fact & f); - virtual void add_fact(const relation_fact & f); - virtual bool contains_fact(const relation_fact & f) const; - virtual relation_base * clone() const; - virtual relation_base * complement(func_decl* p) const; - virtual void to_formula(expr_ref& fml) const { get_table().to_formula(get_signature(), fml); } + void add_fact(const relation_fact & f) override; + bool contains_fact(const relation_fact & f) const override; + relation_base * clone() const override; + relation_base * complement(func_decl* p) const override; + void to_formula(expr_ref& fml) const override { get_table().to_formula(get_signature(), fml); } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { get_table().display(out); } - virtual void display_tuples(func_decl & pred, std::ostream & out) const; + void display_tuples(func_decl & pred, std::ostream & out) const override; - virtual unsigned get_size_estimate_rows() const { return m_table->get_size_estimate_rows(); } - virtual unsigned get_size_estimate_bytes() const { return m_table->get_size_estimate_bytes(); } - virtual bool knows_exact_size() const { return m_table->knows_exact_size(); } + unsigned get_size_estimate_rows() const override { return m_table->get_size_estimate_rows(); } + unsigned get_size_estimate_bytes() const override { return m_table->get_size_estimate_bytes(); } + bool knows_exact_size() const override { return m_table->knows_exact_size(); } }; }; diff --git a/src/muz/rel/dl_vector_relation.h b/src/muz/rel/dl_vector_relation.h index 85e7a78d1..fe1d603fe 100644 --- a/src/muz/rel/dl_vector_relation.h +++ b/src/muz/rel/dl_vector_relation.h @@ -55,12 +55,12 @@ namespace datalog { } } - virtual ~vector_relation() { + ~vector_relation() override { dealloc(m_eqs); dealloc(m_elems); } - virtual void swap(relation_base& other) { + void swap(relation_base& other) override { vector_relation& o = dynamic_cast(other); if (&o == this) return; std::swap(o.m_eqs, m_eqs); @@ -85,7 +85,7 @@ namespace datalog { } - virtual bool empty() const { return m_empty; } + bool empty() const override { return m_empty; } T& operator[](unsigned i) { return (*m_elems)[find(i)]; } @@ -93,7 +93,7 @@ namespace datalog { virtual void display_index(unsigned i, T const& t, std::ostream& out) const = 0; - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { if (empty()) { out << "empty\n"; return; diff --git a/src/muz/rel/karr_relation.cpp b/src/muz/rel/karr_relation.cpp index c8a489d69..c73b8356d 100644 --- a/src/muz/rel/karr_relation.cpp +++ b/src/muz/rel/karr_relation.cpp @@ -36,13 +36,13 @@ namespace datalog { { } - virtual bool empty() const { + bool empty() const override { return m_empty; } - virtual bool is_precise() const { return false; } + bool is_precise() const override { return false; } - virtual void add_fact(const relation_fact & f) { + void add_fact(const relation_fact & f) override { SASSERT(m_empty); SASSERT(!m_basis_valid); m_empty = false; @@ -60,12 +60,12 @@ namespace datalog { } } - virtual bool contains_fact(const relation_fact & f) const { + bool contains_fact(const relation_fact & f) const override { UNREACHABLE(); return false; } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { if (m_fn) { out << m_fn->get_name() << "\n"; } @@ -82,18 +82,18 @@ namespace datalog { } } - virtual karr_relation * clone() const { + karr_relation * clone() const override { karr_relation* result = alloc(karr_relation, m_plugin, m_fn, get_signature(), m_empty); result->copy(*this); return result; } - virtual karr_relation * complement(func_decl*) const { + karr_relation * complement(func_decl*) const override { UNREACHABLE(); return 0; } - virtual void to_formula(expr_ref& fml) const { + void to_formula(expr_ref& fml) const override { if (empty()) { fml = m.mk_false(); } @@ -514,7 +514,7 @@ namespace datalog { : convenient_relation_join_fn(o1_sig, o2_sig, col_cnt, cols1, cols2){ } - virtual relation_base * operator()(const relation_base & _r1, const relation_base & _r2) { + relation_base * operator()(const relation_base & _r1, const relation_base & _r2) override { karr_relation const& r1 = get(_r1); karr_relation const& r2 = get(_r2); karr_relation_plugin& p = r1.get_plugin(); @@ -540,7 +540,7 @@ namespace datalog { : convenient_relation_project_fn(orig_sig, removed_col_cnt, removed_cols) { } - virtual relation_base * operator()(const relation_base & _r) { + relation_base * operator()(const relation_base & _r) override { karr_relation const& r = get(_r); karr_relation_plugin& p = r.get_plugin(); karr_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); @@ -559,7 +559,7 @@ namespace datalog { rename_fn(karr_relation_plugin& p, const relation_signature & orig_sig, unsigned cycle_len, const unsigned * cycle) : convenient_relation_rename_fn(orig_sig, cycle_len, cycle) {} - virtual relation_base * operator()(const relation_base & _r) { + relation_base * operator()(const relation_base & _r) override { karr_relation const& r = get(_r); karr_relation_plugin& p = r.get_plugin(); karr_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); @@ -676,7 +676,7 @@ namespace datalog { public: union_fn() {} - virtual void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) { + void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) override { karr_relation& r = get(_r); karr_relation const& src = get(_src); @@ -707,7 +707,7 @@ namespace datalog { filter_identical_fn(unsigned col_cnt, const unsigned * identical_cols) : m_identical_cols(col_cnt, identical_cols) {} - virtual void operator()(relation_base & _r) { + void operator()(relation_base & _r) override { karr_relation & r = get(_r); TRACE("dl", r.display(tout << "src:\n");); r.get_ineqs(); @@ -747,7 +747,7 @@ namespace datalog { m_valid = arith.is_numeral(value, m_value) && m_value.is_int(); } - virtual void operator()(relation_base & _r) { + void operator()(relation_base & _r) override { karr_relation & r = get(_r); if (m_valid) { r.get_ineqs(); @@ -779,7 +779,7 @@ namespace datalog { m_cond(cond, t.get_plugin().get_ast_manager()) { } - void operator()(relation_base& t) { + void operator()(relation_base& t) override { get(t).filter_interpreted(m_cond); TRACE("dl", tout << mk_pp(m_cond, m_cond.get_manager()) << "\n"; t.display(tout);); } diff --git a/src/muz/rel/karr_relation.h b/src/muz/rel/karr_relation.h index 47e10f09e..e8637f2bd 100644 --- a/src/muz/rel/karr_relation.h +++ b/src/muz/rel/karr_relation.h @@ -45,33 +45,33 @@ namespace datalog { a(get_ast_manager()) {} - virtual bool can_handle_signature(const relation_signature & sig) { + bool can_handle_signature(const relation_signature & sig) override { return get_manager().get_context().karr(); } static symbol get_name() { return symbol("karr_relation"); } - virtual relation_base * mk_empty(const relation_signature & s); + relation_base * mk_empty(const relation_signature & s) override; - virtual relation_base * mk_full(func_decl* p, const relation_signature & s); + relation_base * mk_full(func_decl* p, const relation_signature & s) override; static karr_relation& get(relation_base& r); static karr_relation const & get(relation_base const& r); - virtual relation_join_fn * mk_join_fn( - const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); + relation_join_fn * mk_join_fn( + const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; private: bool dualizeI(matrix& dst, matrix const& src); diff --git a/src/muz/rel/rel_context.h b/src/muz/rel/rel_context.h index f4a87d496..0a31c4e9f 100644 --- a/src/muz/rel/rel_context.h +++ b/src/muz/rel/rel_context.h @@ -56,72 +56,72 @@ namespace datalog { public: rel_context(context& ctx); - virtual ~rel_context(); + ~rel_context() override; - virtual relation_manager & get_rmanager(); - virtual const relation_manager & get_rmanager() const; + relation_manager & get_rmanager() override; + const relation_manager & get_rmanager() const override; ast_manager& get_manager() const { return m; } context& get_context() const { return m_context; } - virtual relation_base & get_relation(func_decl * pred); - virtual relation_base * try_get_relation(func_decl * pred) const; - virtual bool is_empty_relation(func_decl* pred) const; - virtual expr_ref try_get_formula(func_decl * pred) const; - virtual expr_ref get_answer() { return m_answer; } + relation_base & get_relation(func_decl * pred) override; + relation_base * try_get_relation(func_decl * pred) const override; + bool is_empty_relation(func_decl* pred) const override; + expr_ref try_get_formula(func_decl * pred) const override; + expr_ref get_answer() override { return m_answer; } - virtual bool output_profile() const; + bool output_profile() const override; - virtual lbool query(expr* q); - virtual lbool query(unsigned num_rels, func_decl * const* rels); + lbool query(expr* q) override; + lbool query(unsigned num_rels, func_decl * const* rels) override; - virtual void set_predicate_representation(func_decl * pred, unsigned relation_name_cnt, - symbol const * relation_names); + void set_predicate_representation(func_decl * pred, unsigned relation_name_cnt, + symbol const * relation_names) override; - virtual void inherit_predicate_kind(func_decl* new_pred, func_decl* orig_pred); + void inherit_predicate_kind(func_decl* new_pred, func_decl* orig_pred) override; - virtual void collect_statistics(statistics& st) const; + void collect_statistics(statistics& st) const override; - virtual void updt_params(); + void updt_params() override; /** \brief Restrict the set of used predicates to \c res. The function deallocates unsused relations, it does not deal with rules. */ - virtual void restrict_predicates(func_decl_set const& predicates); + void restrict_predicates(func_decl_set const& predicates) override; - virtual void transform_rules(); + void transform_rules() override; - virtual bool try_get_size(func_decl* pred, unsigned& rel_size) const; + bool try_get_size(func_decl* pred, unsigned& rel_size) const override; /** \brief query result if it contains fact. */ - virtual bool result_contains_fact(relation_fact const& f); + bool result_contains_fact(relation_fact const& f) override; - virtual void collect_non_empty_predicates(func_decl_set& ps) { + void collect_non_empty_predicates(func_decl_set& ps) override { return get_rmanager().collect_non_empty_predicates(ps); } /** \brief add facts to relation */ - virtual void add_fact(func_decl* pred, relation_fact const& fact); - virtual void add_fact(func_decl* pred, table_fact const& fact); + void add_fact(func_decl* pred, relation_fact const& fact) override; + void add_fact(func_decl* pred, table_fact const& fact) override; /** \brief check if facts were added to relation */ - virtual bool has_facts(func_decl * pred) const; + bool has_facts(func_decl * pred) const override; /** \brief Store the relation \c rel under the predicate \c pred. The \c context object takes over the ownership of the relation object. */ - virtual void store_relation(func_decl * pred, relation_base * rel); + void store_relation(func_decl * pred, relation_base * rel) override; - virtual void display_output_facts(rule_set const& rules, std::ostream & out) const; - virtual void display_facts(std::ostream & out) const; + void display_output_facts(rule_set const& rules, std::ostream & out) const override; + void display_facts(std::ostream & out) const override; - virtual void display_profile(std::ostream& out); + void display_profile(std::ostream& out) override; - virtual lbool saturate(); + lbool saturate() override; }; }; diff --git a/src/muz/rel/udoc_relation.cpp b/src/muz/rel/udoc_relation.cpp index febabb36d..a5b9a2084 100644 --- a/src/muz/rel/udoc_relation.cpp +++ b/src/muz/rel/udoc_relation.cpp @@ -328,7 +328,7 @@ namespace datalog { t2.expand_column_vector(m_cols2); } - virtual relation_base * operator()(const relation_base & _r1, const relation_base & _r2) { + relation_base * operator()(const relation_base & _r1, const relation_base & _r2) override { udoc_relation const& r1 = get(_r1); udoc_relation const& r2 = get(_r2); TRACE("doc", r1.display(tout << "r1:\n"); r2.display(tout << "r2:\n");); @@ -369,7 +369,7 @@ namespace datalog { } } - virtual relation_base * operator()(const relation_base & tb) { + relation_base * operator()(const relation_base & tb) override { TRACE("doc", tb.display(tout << "src:\n");); udoc_relation const& t = get(tb); udoc_plugin& p = t.get_plugin(); @@ -462,7 +462,7 @@ namespace datalog { } } - virtual relation_base * operator()(const relation_base & _r) { + relation_base * operator()(const relation_base & _r) override { udoc_relation const& r = get(_r); TRACE("doc", r.display(tout << "r:\n");); udoc_plugin& p = r.get_plugin(); @@ -494,7 +494,7 @@ namespace datalog { public: union_fn() {} - virtual void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) { + void operator()(relation_base & _r, const relation_base & _src, relation_base * _delta) override { TRACE("doc", _r.display(tout << "dst:\n"); _src.display(tout << "src:\n");); udoc_relation& r = get(_r); udoc_relation const& src = get(_src); @@ -574,7 +574,7 @@ namespace datalog { } } - virtual void operator()(relation_base & _r) { + void operator()(relation_base & _r) override { udoc_relation& r = get(_r); udoc& d = r.get_udoc(); doc_manager& dm = r.get_dm(); @@ -602,10 +602,10 @@ namespace datalog { SASSERT(num_bits == hi - lo); dm.tbvm().set(m_filter->pos(), r, hi-1, lo); } - virtual ~filter_equal_fn() { + ~filter_equal_fn() override { dm.deallocate(m_filter); } - virtual void operator()(relation_base & tb) { + void operator()(relation_base & tb) override { udoc_relation & t = get(tb); t.get_udoc().intersect(dm, *m_filter); SASSERT(t.get_udoc().well_formed(t.get_dm())); @@ -932,11 +932,11 @@ namespace datalog { m_udoc.display(dm, tout) << "\n";); } - virtual ~filter_interpreted_fn() { + ~filter_interpreted_fn() override { m_udoc.reset(dm); } - virtual void operator()(relation_base & tb) { + void operator()(relation_base & tb) override { udoc_relation & t = get(tb); udoc& u = t.get_udoc(); SASSERT(u.well_formed(dm)); @@ -987,7 +987,7 @@ namespace datalog { // TBD: replace this by "join" given below. - virtual relation_base* operator()(relation_base const& t1, relation_base const& t2) { + relation_base* operator()(relation_base const& t1, relation_base const& t2) override { #if 1 return join(get(t1), get(t2)); #else @@ -1043,7 +1043,7 @@ namespace datalog { public: join_project_and_fn() {} - virtual relation_base* operator()(relation_base const& t1, relation_base const& t2) { + relation_base* operator()(relation_base const& t1, relation_base const& t2) override { udoc_relation *result = get(t1.clone()); result->get_udoc().intersect(result->get_dm(), get(t2).get_udoc()); return result; @@ -1121,7 +1121,7 @@ namespace datalog { neg.expand_column_vector(m_neg_cols); } - virtual void operator()(relation_base& tb, const relation_base& negb) { + void operator()(relation_base& tb, const relation_base& negb) override { udoc_relation& t = get(tb); udoc_relation const& n = get(negb); IF_VERBOSE(3, t.display(verbose_stream() << "dst:");); @@ -1223,10 +1223,10 @@ namespace datalog { t.compile_guard(guard, m_udoc, m_to_delete); } - virtual ~filter_proj_fn() { + ~filter_proj_fn() override { m_udoc.reset(dm); } - virtual relation_base* operator()(const relation_base & tb) { + relation_base* operator()(const relation_base & tb) override { udoc_relation const & t = get(tb); udoc const& u1 = t.get_udoc(); doc_manager& dm = t.get_dm(); diff --git a/src/muz/rel/udoc_relation.h b/src/muz/rel/udoc_relation.h index 15918d80d..87755f75e 100644 --- a/src/muz/rel/udoc_relation.h +++ b/src/muz/rel/udoc_relation.h @@ -39,21 +39,21 @@ namespace datalog { expr_ref to_formula(doc const& d) const; public: udoc_relation(udoc_plugin& p, relation_signature const& s); - virtual ~udoc_relation(); - virtual void reset(); - virtual void add_fact(const relation_fact & f); - virtual void add_new_fact(const relation_fact & f); - virtual bool contains_fact(const relation_fact & f) const; - virtual udoc_relation * clone() const; - virtual udoc_relation * complement(func_decl*) const; - virtual void to_formula(expr_ref& fml) const; + ~udoc_relation() override; + void reset() override; + void add_fact(const relation_fact & f) override; + void add_new_fact(const relation_fact & f) override; + bool contains_fact(const relation_fact & f) const override; + udoc_relation * clone() const override; + udoc_relation * complement(func_decl*) const override; + void to_formula(expr_ref& fml) const override; udoc_plugin& get_plugin() const; - virtual bool fast_empty() const { return m_elems.is_empty(); } - virtual bool empty() const; - virtual void display(std::ostream& out) const; - virtual bool is_precise() const { return true; } - virtual unsigned get_size_estimate_rows() const { return m_elems.size(); } - virtual unsigned get_size_estimate_bytes() const; + bool fast_empty() const override { return m_elems.is_empty(); } + bool empty() const override; + void display(std::ostream& out) const override; + bool is_precise() const override { return true; } + unsigned get_size_estimate_rows() const override { return m_elems.size(); } + unsigned get_size_estimate_bytes() const override; doc_manager& get_dm() const { return dm; } udoc const& get_udoc() const { return m_elems; } @@ -113,38 +113,38 @@ namespace datalog { expr* mk_numeral(rational const& r, sort* s); public: udoc_plugin(relation_manager& rm); - ~udoc_plugin(); - virtual bool can_handle_signature(const relation_signature & s); + ~udoc_plugin() override; + bool can_handle_signature(const relation_signature & s) override; static symbol get_name() { return symbol("doc"); } - virtual relation_base * mk_empty(const relation_signature & s); - virtual relation_base * mk_full(func_decl* p, const relation_signature & s); - virtual relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2); - virtual relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, - const unsigned * removed_cols); - virtual relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle); - virtual relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, - const relation_base * delta); - virtual relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, - const unsigned * identical_cols); - virtual relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, - unsigned col); - virtual relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition); - virtual relation_intersection_filter_fn * mk_filter_by_negation_fn( + relation_base * mk_empty(const relation_signature & s) override; + relation_base * mk_full(func_decl* p, const relation_signature & s) override; + relation_join_fn * mk_join_fn(const relation_base & t1, const relation_base & t2, + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) override; + relation_transformer_fn * mk_project_fn(const relation_base & t, unsigned col_cnt, + const unsigned * removed_cols) override; + relation_transformer_fn * mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, + const unsigned * permutation_cycle) override; + relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_union_fn * mk_widen_fn(const relation_base & tgt, const relation_base & src, + const relation_base * delta) override; + relation_mutator_fn * mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, + const unsigned * identical_cols) override; + relation_mutator_fn * mk_filter_equal_fn(const relation_base & t, const relation_element & value, + unsigned col) override; + relation_mutator_fn * mk_filter_interpreted_fn(const relation_base & t, app * condition) override; + relation_intersection_filter_fn * mk_filter_by_negation_fn( const relation_base& t, const relation_base& neg, unsigned joined_col_cnt, const unsigned *t_cols, - const unsigned *negated_cols); - virtual relation_transformer_fn * mk_filter_interpreted_and_project_fn( + const unsigned *negated_cols) override; + relation_transformer_fn * mk_filter_interpreted_and_project_fn( const relation_base & t, app * condition, - unsigned removed_col_cnt, const unsigned * removed_cols); - virtual relation_join_fn * mk_join_project_fn( + unsigned removed_col_cnt, const unsigned * removed_cols) override; + relation_join_fn * mk_join_project_fn( relation_base const& t1, relation_base const& t2, - unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, - unsigned removed_col_cnt, const unsigned * removed_cols); - + unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, + unsigned removed_col_cnt, const unsigned * removed_cols) override; + void disable_fast_pass() { m_disable_fast_pass = true; } }; }; diff --git a/src/muz/spacer/spacer_dl_interface.h b/src/muz/spacer/spacer_dl_interface.h index 1581762d5..e5a41427d 100644 --- a/src/muz/spacer/spacer_dl_interface.h +++ b/src/muz/spacer/spacer_dl_interface.h @@ -45,39 +45,39 @@ class dl_interface : public datalog::engine_base { public: dl_interface(datalog::context& ctx); - ~dl_interface(); + ~dl_interface() override; - lbool query(expr* query); + lbool query(expr* query) override; - lbool query_from_lvl(expr* query, unsigned lvl); + lbool query_from_lvl(expr* query, unsigned lvl) override; - void display_certificate(std::ostream& out) const; + void display_certificate(std::ostream& out) const override; - void collect_statistics(statistics& st) const; + void collect_statistics(statistics& st) const override; - void reset_statistics(); + void reset_statistics() override; - expr_ref get_answer(); + expr_ref get_answer() override; - expr_ref get_ground_sat_answer(); + expr_ref get_ground_sat_answer() override; - void get_rules_along_trace(datalog::rule_ref_vector& rules); + void get_rules_along_trace(datalog::rule_ref_vector& rules) override; - unsigned get_num_levels(func_decl* pred); + unsigned get_num_levels(func_decl* pred) override; - expr_ref get_cover_delta(int level, func_decl* pred); + expr_ref get_cover_delta(int level, func_decl* pred) override; - void add_cover(int level, func_decl* pred, expr* property); + void add_cover(int level, func_decl* pred, expr* property) override; - void add_invariant(func_decl* pred, expr* property); + void add_invariant(func_decl* pred, expr* property) override; - expr_ref get_reachable(func_decl *pred); + expr_ref get_reachable(func_decl *pred) override; - void updt_params(); + void updt_params() override; - model_ref get_model(); + model_ref get_model() override; - proof_ref get_proof(); + proof_ref get_proof() override; }; } diff --git a/src/muz/spacer/spacer_generalizers.h b/src/muz/spacer/spacer_generalizers.h index aa542ec04..1962e74e0 100644 --- a/src/muz/spacer/spacer_generalizers.h +++ b/src/muz/spacer/spacer_generalizers.h @@ -30,8 +30,8 @@ namespace spacer { class lemma_sanity_checker : public lemma_generalizer { public: lemma_sanity_checker(context& ctx) : lemma_generalizer(ctx) {} - virtual ~lemma_sanity_checker() {} - virtual void operator()(lemma_ref &lemma); + ~lemma_sanity_checker() override {} + void operator()(lemma_ref &lemma) override; }; /** @@ -53,11 +53,11 @@ class lemma_bool_inductive_generalizer : public lemma_generalizer { public: lemma_bool_inductive_generalizer(context& ctx, unsigned failure_limit) : lemma_generalizer(ctx), m_failure_limit(failure_limit) {} - virtual ~lemma_bool_inductive_generalizer() {} - virtual void operator()(lemma_ref &lemma); + ~lemma_bool_inductive_generalizer() override {} + void operator()(lemma_ref &lemma) override; - virtual void collect_statistics(statistics& st) const; - virtual void reset_statistics() {m_st.reset();} + void collect_statistics(statistics& st) const override; + void reset_statistics() override {m_st.reset();} }; class unsat_core_generalizer : public lemma_generalizer { @@ -72,26 +72,26 @@ class unsat_core_generalizer : public lemma_generalizer { stats m_st; public: unsat_core_generalizer(context &ctx) : lemma_generalizer(ctx) {} - virtual ~unsat_core_generalizer() {} - virtual void operator()(lemma_ref &lemma); + ~unsat_core_generalizer() override {} + void operator()(lemma_ref &lemma) override; - virtual void collect_statistics(statistics &st) const; - virtual void reset_statistics() {m_st.reset();} + void collect_statistics(statistics &st) const override; + void reset_statistics() override {m_st.reset();} }; class lemma_array_eq_generalizer : public lemma_generalizer { public: lemma_array_eq_generalizer(context &ctx) : lemma_generalizer(ctx) {} - virtual ~lemma_array_eq_generalizer() {} - virtual void operator()(lemma_ref &lemma); + ~lemma_array_eq_generalizer() override {} + void operator()(lemma_ref &lemma) override; }; class lemma_eq_generalizer : public lemma_generalizer { public: lemma_eq_generalizer(context &ctx) : lemma_generalizer(ctx) {} - virtual ~lemma_eq_generalizer() {} - virtual void operator()(lemma_ref &lemma); + ~lemma_eq_generalizer() override {} + void operator()(lemma_ref &lemma) override; }; diff --git a/src/muz/spacer/spacer_itp_solver.h b/src/muz/spacer/spacer_itp_solver.h index 8194379b8..8dbac022e 100644 --- a/src/muz/spacer/spacer_itp_solver.h +++ b/src/muz/spacer/spacer_itp_solver.h @@ -86,10 +86,10 @@ public: m_farkas_a_const(farkas_a_const) {} - virtual ~itp_solver() {} + ~itp_solver() override {} /* itp solver specific */ - virtual void get_unsat_core(expr_ref_vector &core); + void get_unsat_core(expr_ref_vector &core) override; virtual void get_itp_core(expr_ref_vector &core); void set_split_literals(bool v) {m_split_literals = v;} bool mk_proxies(expr_ref_vector &v, unsigned from = 0); @@ -104,53 +104,53 @@ public: /* solver interface */ - virtual solver* translate(ast_manager &m, params_ref const &p) + solver* translate(ast_manager &m, params_ref const &p) override {return m_solver.translate(m, p);} - virtual void updt_params(params_ref const &p) + void updt_params(params_ref const &p) override {m_solver.updt_params(p);} - virtual void collect_param_descrs(param_descrs &r) + void collect_param_descrs(param_descrs &r) override {m_solver.collect_param_descrs(r);} - virtual void set_produce_models(bool f) + void set_produce_models(bool f) override {m_solver.set_produce_models(f);} - virtual void assert_expr(expr *t) + void assert_expr(expr *t) override {m_solver.assert_expr(t);} - virtual void assert_expr(expr *t, expr *a) + void assert_expr(expr *t, expr *a) override {NOT_IMPLEMENTED_YET();} - virtual void push(); - virtual void pop(unsigned n); - virtual unsigned get_scope_level() const + void push() override; + void pop(unsigned n) override; + unsigned get_scope_level() const override {return m_solver.get_scope_level();} - virtual lbool check_sat(unsigned num_assumptions, expr * const *assumptions); - virtual void set_progress_callback(progress_callback *callback) + lbool check_sat(unsigned num_assumptions, expr * const *assumptions) override; + void set_progress_callback(progress_callback *callback) override {m_solver.set_progress_callback(callback);} - virtual unsigned get_num_assertions() const + unsigned get_num_assertions() const override {return m_solver.get_num_assertions();} - virtual expr * get_assertion(unsigned idx) const + expr * get_assertion(unsigned idx) const override {return m_solver.get_assertion(idx);} - virtual unsigned get_num_assumptions() const + unsigned get_num_assumptions() const override {return m_solver.get_num_assumptions();} - virtual expr * get_assumption(unsigned idx) const + expr * get_assumption(unsigned idx) const override {return m_solver.get_assumption(idx);} - virtual std::ostream &display(std::ostream &out, unsigned n, expr* const* es) const + std::ostream &display(std::ostream &out, unsigned n, expr* const* es) const override { return m_solver.display(out, n, es); } /* check_sat_result interface */ - virtual void collect_statistics(statistics &st) const ; + void collect_statistics(statistics &st) const override ; virtual void reset_statistics(); - virtual void get_unsat_core(ptr_vector &r); - virtual void get_model(model_ref &m) {m_solver.get_model(m);} - virtual proof *get_proof() {return m_solver.get_proof();} - virtual std::string reason_unknown() const + void get_unsat_core(ptr_vector &r) override; + void get_model(model_ref &m) override {m_solver.get_model(m);} + proof *get_proof() override {return m_solver.get_proof();} + std::string reason_unknown() const override {return m_solver.reason_unknown();} - virtual void set_reason_unknown(char const* msg) + void set_reason_unknown(char const* msg) override {m_solver.set_reason_unknown(msg);} - virtual void get_labels(svector &r) + void get_labels(svector &r) override {m_solver.get_labels(r);} - virtual ast_manager &get_manager() const {return m;} + ast_manager &get_manager() const override {return m;} virtual void refresh(); diff --git a/src/muz/spacer/spacer_qe_project.cpp b/src/muz/spacer/spacer_qe_project.cpp index 9f4f4e4fe..cde188aac 100644 --- a/src/muz/spacer/spacer_qe_project.cpp +++ b/src/muz/spacer/spacer_qe_project.cpp @@ -190,14 +190,14 @@ namespace qe { class is_relevant_default : public i_expr_pred { public: - bool operator()(expr* e) { + bool operator()(expr* e) override { return true; } }; class mk_atom_default : public i_nnf_atom { public: - virtual void operator()(expr* e, bool pol, expr_ref& result) { + void operator()(expr* e, bool pol, expr_ref& result) override { if (pol) result = e; else result = result.get_manager().mk_not(e); } diff --git a/src/muz/spacer/spacer_unsat_core_plugin.h b/src/muz/spacer/spacer_unsat_core_plugin.h index 96d03140c..2ea4b4b51 100644 --- a/src/muz/spacer/spacer_unsat_core_plugin.h +++ b/src/muz/spacer/spacer_unsat_core_plugin.h @@ -43,7 +43,7 @@ class unsat_core_plugin_lemma : public unsat_core_plugin { public: unsat_core_plugin_lemma(unsat_core_learner& learner) : unsat_core_plugin(learner){}; - virtual void compute_partial_core(proof* step) override; + void compute_partial_core(proof* step) override; private: void add_lowest_split_to_core(proof* step) const; @@ -55,7 +55,7 @@ class unsat_core_plugin_farkas_lemma : public unsat_core_plugin { public: unsat_core_plugin_farkas_lemma(unsat_core_learner& learner, bool split_literals, bool use_constant_from_a=true) : unsat_core_plugin(learner), m_split_literals(split_literals), m_use_constant_from_a(use_constant_from_a) {}; - virtual void compute_partial_core(proof* step) override; + void compute_partial_core(proof* step) override; private: bool m_split_literals; @@ -71,8 +71,8 @@ private: public: unsat_core_plugin_farkas_lemma_optimized(unsat_core_learner& learner, ast_manager& m) : unsat_core_plugin(learner), m(m) {}; - virtual void compute_partial_core(proof* step) override; - virtual void finalize() override; + void compute_partial_core(proof* step) override; + void finalize() override; protected: vector > > m_linear_combinations; @@ -88,7 +88,7 @@ private: public: unsat_core_plugin_farkas_lemma_bounded(unsat_core_learner& learner, ast_manager& m) : unsat_core_plugin_farkas_lemma_optimized(learner, m) {}; - virtual void finalize() override; + void finalize() override; }; class unsat_core_plugin_min_cut : public unsat_core_plugin { @@ -96,8 +96,8 @@ private: public: unsat_core_plugin_min_cut(unsat_core_learner& learner, ast_manager& m); - virtual void compute_partial_core(proof* step) override; - virtual void finalize() override; + void compute_partial_core(proof* step) override; + void finalize() override; private: ast_manager& m; diff --git a/src/muz/spacer/spacer_virtual_solver.h b/src/muz/spacer/spacer_virtual_solver.h index fed64c589..38e038d9e 100644 --- a/src/muz/spacer/spacer_virtual_solver.h +++ b/src/muz/spacer/spacer_virtual_solver.h @@ -65,46 +65,46 @@ private: void refresh(); public: - virtual ~virtual_solver(); - virtual unsigned get_num_assumptions() const + ~virtual_solver() override; + unsigned get_num_assumptions() const override { unsigned sz = solver_na2as::get_num_assumptions(); return m_virtual ? sz - 1 : sz; } - virtual expr* get_assumption(unsigned idx) const + expr* get_assumption(unsigned idx) const override { if(m_virtual) { idx++; } return solver_na2as::get_assumption(idx); } - virtual void get_unsat_core(ptr_vector &r); - virtual void assert_expr(expr *e); - virtual void collect_statistics(statistics &st) const {} - virtual void get_model(model_ref &m) {m_context.get_model(m);} - virtual proof* get_proof(); - virtual std::string reason_unknown() const + void get_unsat_core(ptr_vector &r) override; + void assert_expr(expr *e) override; + void collect_statistics(statistics &st) const override {} + void get_model(model_ref &m) override {m_context.get_model(m);} + proof* get_proof() override; + std::string reason_unknown() const override {return m_context.last_failure_as_string();} - virtual void set_reason_unknown(char const *msg) + void set_reason_unknown(char const *msg) override {m_context.set_reason_unknown(msg);} - virtual ast_manager& get_manager() const {return m;} - virtual void get_labels(svector &r); - virtual void set_produce_models(bool f); + ast_manager& get_manager() const override {return m;} + void get_labels(svector &r) override; + void set_produce_models(bool f) override; virtual bool get_produce_models(); virtual smt_params &fparams(); virtual void reset(); - virtual void set_progress_callback(progress_callback *callback) + void set_progress_callback(progress_callback *callback) override {UNREACHABLE();} - virtual solver *translate(ast_manager &m, params_ref const &p); + solver *translate(ast_manager &m, params_ref const &p) override; - 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; protected: - virtual lbool check_sat_core(unsigned num_assumptions, expr *const * assumptions); - virtual void push_core(); - virtual void pop_core(unsigned n); + lbool check_sat_core(unsigned num_assumptions, expr *const * assumptions) override; + void push_core() override; + void pop_core(unsigned n) override; }; /// multi-solver abstraction on top of a single smt::kernel diff --git a/src/muz/tab/tab_context.h b/src/muz/tab/tab_context.h index 329234524..84d6e2420 100644 --- a/src/muz/tab/tab_context.h +++ b/src/muz/tab/tab_context.h @@ -32,13 +32,13 @@ namespace datalog { imp* m_imp; public: tab(context& ctx); - ~tab(); - virtual lbool query(expr* query); - virtual void cleanup(); - virtual void reset_statistics(); - virtual void collect_statistics(statistics& st) const; - virtual void display_certificate(std::ostream& out) const; - virtual expr_ref get_answer(); + ~tab() override; + lbool query(expr* query) override; + void cleanup() override; + void reset_statistics() override; + void collect_statistics(statistics& st) const override; + void display_certificate(std::ostream& out) const override; + expr_ref get_answer() override; }; }; diff --git a/src/muz/transforms/dl_mk_array_blast.h b/src/muz/transforms/dl_mk_array_blast.h index e7b951168..ba2f826dd 100644 --- a/src/muz/transforms/dl_mk_array_blast.h +++ b/src/muz/transforms/dl_mk_array_blast.h @@ -66,9 +66,9 @@ namespace datalog { */ mk_array_blast(context & ctx, unsigned priority); - virtual ~mk_array_blast(); + ~mk_array_blast() override; - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; diff --git a/src/muz/transforms/dl_mk_array_eq_rewrite.h b/src/muz/transforms/dl_mk_array_eq_rewrite.h index 166c01142..298697998 100644 --- a/src/muz/transforms/dl_mk_array_eq_rewrite.h +++ b/src/muz/transforms/dl_mk_array_eq_rewrite.h @@ -40,8 +40,8 @@ namespace datalog { public: mk_array_eq_rewrite(context & ctx, unsigned priority); - rule_set * operator()(rule_set const & source); - virtual ~mk_array_eq_rewrite(){} + rule_set * operator()(rule_set const & source) override; + ~mk_array_eq_rewrite() override{} }; diff --git a/src/muz/transforms/dl_mk_array_instantiation.h b/src/muz/transforms/dl_mk_array_instantiation.h index b87f679fc..cd5715a4f 100644 --- a/src/muz/transforms/dl_mk_array_instantiation.h +++ b/src/muz/transforms/dl_mk_array_instantiation.h @@ -112,8 +112,8 @@ namespace datalog { expr_ref_vector getId(app*old_pred, const expr_ref_vector& new_args); public: mk_array_instantiation(context & ctx, unsigned priority); - rule_set * operator()(rule_set const & source); - virtual ~mk_array_instantiation(){} + rule_set * operator()(rule_set const & source) override; + ~mk_array_instantiation() override{} }; diff --git a/src/muz/transforms/dl_mk_backwards.h b/src/muz/transforms/dl_mk_backwards.h index ca441fd0a..344da2afb 100644 --- a/src/muz/transforms/dl_mk_backwards.h +++ b/src/muz/transforms/dl_mk_backwards.h @@ -28,8 +28,8 @@ namespace datalog { context& m_ctx; public: mk_backwards(context & ctx, unsigned priority = 33000); - ~mk_backwards(); - rule_set * operator()(rule_set const & source); + ~mk_backwards() override; + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_bit_blast.cpp b/src/muz/transforms/dl_mk_bit_blast.cpp index 3c8045e34..8637af14f 100644 --- a/src/muz/transforms/dl_mk_bit_blast.cpp +++ b/src/muz/transforms/dl_mk_bit_blast.cpp @@ -59,11 +59,11 @@ namespace datalog { m_new_funcs.push_back(new_f); } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { return alloc(bit_blast_model_converter, m); } - virtual void operator()(model_ref & model) { + void operator()(model_ref & model) override { for (unsigned i = 0; i < m_new_funcs.size(); ++i) { func_decl* p = m_new_funcs[i].get(); func_decl* q = m_old_funcs[i].get(); diff --git a/src/muz/transforms/dl_mk_bit_blast.h b/src/muz/transforms/dl_mk_bit_blast.h index 31df57567..a8be254a6 100644 --- a/src/muz/transforms/dl_mk_bit_blast.h +++ b/src/muz/transforms/dl_mk_bit_blast.h @@ -28,8 +28,8 @@ namespace datalog { impl* m_impl; public: mk_bit_blast(context & ctx, unsigned priority = 35000); - ~mk_bit_blast(); - rule_set * operator()(rule_set const & source); + ~mk_bit_blast() override; + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_coalesce.h b/src/muz/transforms/dl_mk_coalesce.h index 47d702fbb..7721d7556 100644 --- a/src/muz/transforms/dl_mk_coalesce.h +++ b/src/muz/transforms/dl_mk_coalesce.h @@ -52,7 +52,7 @@ namespace datalog { */ mk_coalesce(context & ctx); - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_coi_filter.h b/src/muz/transforms/dl_mk_coi_filter.h index c03308b6a..4fe7033bd 100644 --- a/src/muz/transforms/dl_mk_coi_filter.h +++ b/src/muz/transforms/dl_mk_coi_filter.h @@ -42,7 +42,7 @@ namespace datalog { m(ctx.get_manager()), m_context(ctx) {} - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; } diff --git a/src/muz/transforms/dl_mk_filter_rules.h b/src/muz/transforms/dl_mk_filter_rules.h index b81921d59..3e357dc4e 100644 --- a/src/muz/transforms/dl_mk_filter_rules.h +++ b/src/muz/transforms/dl_mk_filter_rules.h @@ -73,11 +73,11 @@ namespace datalog { public: mk_filter_rules(context & ctx); - ~mk_filter_rules(); + ~mk_filter_rules() override; /** \brief Return a new rule set where only filter rules contain atoms with repeated variables and/or values. */ - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_interp_tail_simplifier.h b/src/muz/transforms/dl_mk_interp_tail_simplifier.h index a8a7393cd..e9120b9b1 100644 --- a/src/muz/transforms/dl_mk_interp_tail_simplifier.h +++ b/src/muz/transforms/dl_mk_interp_tail_simplifier.h @@ -90,7 +90,7 @@ namespace datalog { bool transform_rules(const rule_set & orig, rule_set & tgt); public: mk_interp_tail_simplifier(context & ctx, unsigned priority=40000); - virtual ~mk_interp_tail_simplifier(); + ~mk_interp_tail_simplifier() override; /**If rule should be retained, assign transformed version to res and return true; if rule can be deleted, return false. @@ -100,7 +100,7 @@ namespace datalog { */ bool transform_rule(rule * r, rule_ref& res); - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_karr_invariants.cpp b/src/muz/transforms/dl_mk_karr_invariants.cpp index 48219eeb9..5dafafb19 100644 --- a/src/muz/transforms/dl_mk_karr_invariants.cpp +++ b/src/muz/transforms/dl_mk_karr_invariants.cpp @@ -111,7 +111,7 @@ namespace datalog { add_invariant_model_converter(ast_manager& m): m(m), a(m), m_funcs(m), m_invs(m) {} - virtual ~add_invariant_model_converter() { } + ~add_invariant_model_converter() override { } void add(func_decl* p, expr* inv) { if (!m.is_true(inv)) { @@ -120,7 +120,7 @@ namespace datalog { } } - virtual void operator()(model_ref & mr) { + void operator()(model_ref & mr) override { for (unsigned i = 0; i < m_funcs.size(); ++i) { func_decl* p = m_funcs[i].get(); func_interp* f = mr->get_func_interp(p); @@ -142,7 +142,7 @@ namespace datalog { } } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { add_invariant_model_converter* mc = alloc(add_invariant_model_converter, m); for (unsigned i = 0; i < m_funcs.size(); ++i) { mc->add(translator(m_funcs[i].get()), m_invs[i].get()); diff --git a/src/muz/transforms/dl_mk_karr_invariants.h b/src/muz/transforms/dl_mk_karr_invariants.h index b31f1f8d9..cf021efda 100644 --- a/src/muz/transforms/dl_mk_karr_invariants.h +++ b/src/muz/transforms/dl_mk_karr_invariants.h @@ -65,9 +65,9 @@ namespace datalog { public: mk_karr_invariants(context & ctx, unsigned priority); - virtual ~mk_karr_invariants(); + ~mk_karr_invariants() override; - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; diff --git a/src/muz/transforms/dl_mk_loop_counter.h b/src/muz/transforms/dl_mk_loop_counter.h index fb4b6d704..cf79dc218 100644 --- a/src/muz/transforms/dl_mk_loop_counter.h +++ b/src/muz/transforms/dl_mk_loop_counter.h @@ -36,9 +36,9 @@ namespace datalog { app_ref del_arg(app* fn); public: mk_loop_counter(context & ctx, unsigned priority = 33000); - ~mk_loop_counter(); + ~mk_loop_counter() override; - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; func_decl* get_old(func_decl* f) const { return m_new2old.find(f); } diff --git a/src/muz/transforms/dl_mk_magic_sets.h b/src/muz/transforms/dl_mk_magic_sets.h index 73b5e94f6..dc3ad03b7 100644 --- a/src/muz/transforms/dl_mk_magic_sets.h +++ b/src/muz/transforms/dl_mk_magic_sets.h @@ -126,7 +126,7 @@ namespace datalog { */ mk_magic_sets(context & ctx, func_decl* goal); - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_magic_symbolic.h b/src/muz/transforms/dl_mk_magic_symbolic.h index 9c51a5287..451b2c46f 100644 --- a/src/muz/transforms/dl_mk_magic_symbolic.h +++ b/src/muz/transforms/dl_mk_magic_symbolic.h @@ -30,8 +30,8 @@ namespace datalog { app_ref mk_query(app* q); public: mk_magic_symbolic(context & ctx, unsigned priority = 33037); - ~mk_magic_symbolic(); - rule_set * operator()(rule_set const & source); + ~mk_magic_symbolic() override; + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_quantifier_abstraction.cpp b/src/muz/transforms/dl_mk_quantifier_abstraction.cpp index b171aaa7c..a4a5ac35f 100644 --- a/src/muz/transforms/dl_mk_quantifier_abstraction.cpp +++ b/src/muz/transforms/dl_mk_quantifier_abstraction.cpp @@ -47,9 +47,9 @@ namespace datalog { qa_model_converter(ast_manager& m): m(m), m_old_funcs(m), m_new_funcs(m) {} - virtual ~qa_model_converter() {} + ~qa_model_converter() override {} - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { return alloc(qa_model_converter, m); } @@ -61,7 +61,7 @@ namespace datalog { m_sorts.push_back(sorts); } - virtual void operator()(model_ref & old_model) { + void operator()(model_ref & old_model) override { model_ref new_model = alloc(model, m); for (unsigned i = 0; i < m_new_funcs.size(); ++i) { func_decl* p = m_new_funcs[i].get(); diff --git a/src/muz/transforms/dl_mk_quantifier_abstraction.h b/src/muz/transforms/dl_mk_quantifier_abstraction.h index 593e458b9..83d0e975d 100644 --- a/src/muz/transforms/dl_mk_quantifier_abstraction.h +++ b/src/muz/transforms/dl_mk_quantifier_abstraction.h @@ -51,9 +51,9 @@ namespace datalog { public: mk_quantifier_abstraction(context & ctx, unsigned priority); - virtual ~mk_quantifier_abstraction(); + ~mk_quantifier_abstraction() override; - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; diff --git a/src/muz/transforms/dl_mk_quantifier_instantiation.h b/src/muz/transforms/dl_mk_quantifier_instantiation.h index 4f1626ec6..f8e12f712 100644 --- a/src/muz/transforms/dl_mk_quantifier_instantiation.h +++ b/src/muz/transforms/dl_mk_quantifier_instantiation.h @@ -61,9 +61,9 @@ namespace datalog { public: mk_quantifier_instantiation(context & ctx, unsigned priority); - virtual ~mk_quantifier_instantiation(); + ~mk_quantifier_instantiation() override; - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; diff --git a/src/muz/transforms/dl_mk_rule_inliner.h b/src/muz/transforms/dl_mk_rule_inliner.h index 55b9b9487..7b00d26ad 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.h +++ b/src/muz/transforms/dl_mk_rule_inliner.h @@ -89,7 +89,7 @@ namespace datalog { obj_map m_positions; public: visitor(context& c, substitution & s): st_visitor(s), m_context(c) { (void) m_context; } - virtual bool operator()(expr* e); + bool operator()(expr* e) override; void reset() { m_unifiers.reset(); } void reset(unsigned sz); svector& can_remove() { return m_can_remove; } @@ -194,9 +194,9 @@ namespace datalog { m_head_visitor(ctx, m_subst), m_tail_visitor(ctx, m_subst) {} - virtual ~mk_rule_inliner() { } + ~mk_rule_inliner() override { } - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_scale.cpp b/src/muz/transforms/dl_mk_scale.cpp index 5bc10b957..abc5d20e7 100644 --- a/src/muz/transforms/dl_mk_scale.cpp +++ b/src/muz/transforms/dl_mk_scale.cpp @@ -30,7 +30,7 @@ namespace datalog { public: scale_model_converter(ast_manager& m): m(m), m_trail(m), a(m) {} - virtual ~scale_model_converter() {} + ~scale_model_converter() override {} void add_new2old(func_decl* new_f, func_decl* old_f) { m_trail.push_back(old_f); @@ -38,7 +38,7 @@ namespace datalog { m_new2old.insert(new_f, old_f); } - virtual void operator()(model_ref& md) { + void operator()(model_ref& md) override { model_ref old_model = alloc(model, m); obj_map::iterator it = m_new2old.begin(); obj_map::iterator end = m_new2old.end(); @@ -95,7 +95,7 @@ namespace datalog { //TRACE("dl", model_smt2_pp(tout, m, *md, 0); ); } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { UNREACHABLE(); return 0; } diff --git a/src/muz/transforms/dl_mk_scale.h b/src/muz/transforms/dl_mk_scale.h index 10a5ea8b2..c171a1d06 100644 --- a/src/muz/transforms/dl_mk_scale.h +++ b/src/muz/transforms/dl_mk_scale.h @@ -43,8 +43,8 @@ namespace datalog { app_ref mk_constraint(unsigned num_vars, app* q); public: mk_scale(context & ctx, unsigned priority = 33039); - virtual ~mk_scale(); - rule_set * operator()(rule_set const & source); + ~mk_scale() override; + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_separate_negated_tails.h b/src/muz/transforms/dl_mk_separate_negated_tails.h index a5cdda003..aae90b2db 100644 --- a/src/muz/transforms/dl_mk_separate_negated_tails.h +++ b/src/muz/transforms/dl_mk_separate_negated_tails.h @@ -51,7 +51,7 @@ namespace datalog { public: mk_separate_negated_tails(context& ctx, unsigned priority = 21000); - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; } diff --git a/src/muz/transforms/dl_mk_slice.cpp b/src/muz/transforms/dl_mk_slice.cpp index dc11935e3..3c5cf53c7 100644 --- a/src/muz/transforms/dl_mk_slice.cpp +++ b/src/muz/transforms/dl_mk_slice.cpp @@ -271,14 +271,14 @@ namespace datalog { m_renaming.insert(orig_rule, unsigned_vector(sz, renaming)); } - virtual void operator()(ast_manager& m, unsigned num_source, proof * const * source, proof_ref & result) { + void operator()(ast_manager& m, unsigned num_source, proof * const * source, proof_ref & result) override { SASSERT(num_source == 1); result = source[0]; init_form2rule(); translate_proof(result); } - virtual proof_converter * translate(ast_translation & translator) { + proof_converter * translate(ast_translation & translator) override { UNREACHABLE(); // this would require implementing translation for the dl_context. return 0; @@ -305,7 +305,7 @@ namespace datalog { m_sliceable.insert(f, bv); } - virtual void operator()(model_ref & md) { + void operator()(model_ref & md) override { if (m_slice2old.empty()) { return; } @@ -391,7 +391,7 @@ namespace datalog { TRACE("dl", model_smt2_pp(tout, m, *md, 0); ); } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { UNREACHABLE(); return 0; } diff --git a/src/muz/transforms/dl_mk_slice.h b/src/muz/transforms/dl_mk_slice.h index 4a7d4a81a..0bc58c95a 100644 --- a/src/muz/transforms/dl_mk_slice.h +++ b/src/muz/transforms/dl_mk_slice.h @@ -100,9 +100,9 @@ namespace datalog { */ mk_slice(context & ctx); - virtual ~mk_slice() { } + ~mk_slice() override { } - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; func_decl* get_predicate(func_decl* p) { func_decl* q = p; m_predicates.find(p, q); return q; } diff --git a/src/muz/transforms/dl_mk_subsumption_checker.h b/src/muz/transforms/dl_mk_subsumption_checker.h index 01d828d6e..8c71096c3 100644 --- a/src/muz/transforms/dl_mk_subsumption_checker.h +++ b/src/muz/transforms/dl_mk_subsumption_checker.h @@ -80,11 +80,11 @@ namespace datalog { m_context(ctx), m_ref_holder(ctx.get_rule_manager()), m_new_total_relation_discovery_during_transformation(true) {} - ~mk_subsumption_checker() { + ~mk_subsumption_checker() override { reset_dealloc_values(m_ground_unconditional_rule_heads); } - virtual rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_unbound_compressor.h b/src/muz/transforms/dl_mk_unbound_compressor.h index 6f53e0707..b37a2f1a7 100644 --- a/src/muz/transforms/dl_mk_unbound_compressor.h +++ b/src/muz/transforms/dl_mk_unbound_compressor.h @@ -86,7 +86,7 @@ namespace datalog { public: mk_unbound_compressor(context & ctx); - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/muz/transforms/dl_mk_unfold.h b/src/muz/transforms/dl_mk_unfold.h index 8ebe2d328..02469e6fb 100644 --- a/src/muz/transforms/dl_mk_unfold.h +++ b/src/muz/transforms/dl_mk_unfold.h @@ -44,7 +44,7 @@ namespace datalog { */ mk_unfold(context & ctx); - rule_set * operator()(rule_set const & source); + rule_set * operator()(rule_set const & source) override; }; }; diff --git a/src/opt/maxsmt.h b/src/opt/maxsmt.h index 7b4be9842..ebe226db0 100644 --- a/src/opt/maxsmt.h +++ b/src/opt/maxsmt.h @@ -73,15 +73,15 @@ namespace opt { public: maxsmt_solver_base(maxsat_context& c, weights_t& ws, expr_ref_vector const& soft); - virtual ~maxsmt_solver_base() {} - virtual rational get_lower() const { return m_lower; } - virtual rational get_upper() const { return m_upper; } - virtual bool get_assignment(unsigned index) const { return m_assignment[index]; } - virtual void collect_statistics(statistics& st) const { } - virtual void get_model(model_ref& mdl, svector& labels) { mdl = m_model.get(); labels = m_labels;} + ~maxsmt_solver_base() override {} + rational get_lower() const override { return m_lower; } + rational get_upper() const override { return m_upper; } + bool get_assignment(unsigned index) const override { return m_assignment[index]; } + void collect_statistics(statistics& st) const override { } + void get_model(model_ref& mdl, svector& labels) override { mdl = m_model.get(); labels = m_labels;} virtual void commit_assignment(); void set_model() { s().get_model(m_model); s().get_labels(m_labels); } - virtual void updt_params(params_ref& p); + void updt_params(params_ref& p) override; solver& s(); bool init(); void set_mus(bool f); diff --git a/src/opt/opt_context.h b/src/opt/opt_context.h index 372c6672c..c9e5ce3de 100644 --- a/src/opt/opt_context.h +++ b/src/opt/opt_context.h @@ -173,7 +173,7 @@ namespace opt { std::string m_unknown; public: context(ast_manager& m); - virtual ~context(); + ~context() override; unsigned add_soft_constraint(expr* f, rational const& w, symbol const& id); unsigned add_objective(app* t, bool is_max); void add_hard_constraint(expr* f); @@ -181,30 +181,30 @@ namespace opt { void get_hard_constraints(expr_ref_vector& hard); expr_ref get_objective(unsigned i); - virtual void push(); - virtual void pop(unsigned n); - virtual bool empty() { return m_scoped_state.m_objectives.empty(); } - virtual void set_hard_constraints(ptr_vector & hard); - virtual lbool optimize(); - virtual void set_model(model_ref& _m) { m_model = _m; } - virtual void get_model(model_ref& _m); - virtual void get_box_model(model_ref& _m, unsigned index); - virtual void fix_model(model_ref& _m); - virtual void collect_statistics(statistics& stats) const; - virtual proof* get_proof() { return 0; } - virtual void get_labels(svector & r); - virtual void get_unsat_core(ptr_vector & r); - virtual std::string reason_unknown() const; - virtual void set_reason_unknown(char const* msg) { m_unknown = msg; } + void push() override; + void pop(unsigned n) override; + bool empty() override { return m_scoped_state.m_objectives.empty(); } + void set_hard_constraints(ptr_vector & hard) override; + lbool optimize() override; + void set_model(model_ref& _m) override { m_model = _m; } + void get_model(model_ref& _m) override; + void get_box_model(model_ref& _m, unsigned index) override; + void fix_model(model_ref& _m) override; + void collect_statistics(statistics& stats) const override; + proof* get_proof() override { return 0; } + void get_labels(svector & r) override; + void get_unsat_core(ptr_vector & r) override; + std::string reason_unknown() const override; + void set_reason_unknown(char const* msg) override { m_unknown = msg; } - virtual void display_assignment(std::ostream& out); - virtual bool is_pareto() { return m_pareto.get() != 0; } - virtual void set_logic(symbol const& s) { m_logic = s; } + void display_assignment(std::ostream& out) override; + bool is_pareto() override { return m_pareto.get() != 0; } + void set_logic(symbol const& s) override { m_logic = s; } void set_clausal(bool f) { m_is_clausal = f; } void display(std::ostream& out); static void collect_param_descrs(param_descrs & r); - virtual void updt_params(params_ref const& p); + void updt_params(params_ref const& p) override; params_ref& get_params() { return m_params; } expr_ref get_lower(unsigned idx); @@ -216,25 +216,25 @@ namespace opt { std::string to_string() const; - virtual unsigned num_objectives() { return m_scoped_state.m_objectives.size(); } - virtual expr_ref mk_gt(unsigned i, model_ref& model); - virtual expr_ref mk_ge(unsigned i, model_ref& model); - virtual expr_ref mk_le(unsigned i, model_ref& model); + unsigned num_objectives() override { return m_scoped_state.m_objectives.size(); } + expr_ref mk_gt(unsigned i, model_ref& model) override; + expr_ref mk_ge(unsigned i, model_ref& model) override; + expr_ref mk_le(unsigned i, model_ref& model) override; - virtual smt::context& smt_context() { return m_opt_solver->get_context(); } - virtual filter_model_converter& fm() { return m_fm; } - virtual bool sat_enabled() const { return 0 != m_sat_solver.get(); } - virtual solver& get_solver(); - virtual ast_manager& get_manager() const { return this->m; } - virtual params_ref& params() { return m_params; } - virtual void enable_sls(bool force); - virtual symbol const& maxsat_engine() const { return m_maxsat_engine; } - virtual void get_base_model(model_ref& _m); + smt::context& smt_context() override { return m_opt_solver->get_context(); } + filter_model_converter& fm() override { return m_fm; } + bool sat_enabled() const override { return 0 != m_sat_solver.get(); } + solver& get_solver() override; + ast_manager& get_manager() const override { return this->m; } + params_ref& params() override { return m_params; } + void enable_sls(bool force) override; + symbol const& maxsat_engine() const override { return m_maxsat_engine; } + void get_base_model(model_ref& _m) override; - virtual bool verify_model(unsigned id, model* mdl, rational const& v); + bool verify_model(unsigned id, model* mdl, rational const& v) override; - virtual void model_updated(model* mdl); + void model_updated(model* mdl) override; private: lbool execute(objective const& obj, bool committed, bool scoped); diff --git a/src/opt/opt_pareto.h b/src/opt/opt_pareto.h index c0ccc93da..5a2aab6f3 100644 --- a/src/opt/opt_pareto.h +++ b/src/opt/opt_pareto.h @@ -87,9 +87,9 @@ namespace opt { params_ref & p): pareto_base(m, cb, s, p) { } - virtual ~gia_pareto() {} + ~gia_pareto() override {} - virtual lbool operator()(); + lbool operator()() override; }; // opportunistic improvement algorithm. @@ -101,9 +101,9 @@ namespace opt { params_ref & p): pareto_base(m, cb, s, p) { } - virtual ~oia_pareto() {} + ~oia_pareto() override {} - virtual lbool operator()(); + lbool operator()() override; }; } diff --git a/src/opt/opt_solver.h b/src/opt/opt_solver.h index 4bd23c120..41e9dee2d 100644 --- a/src/opt/opt_solver.h +++ b/src/opt/opt_solver.h @@ -85,28 +85,28 @@ namespace opt { bool m_was_unknown; public: opt_solver(ast_manager & m, params_ref const & p, filter_model_converter& fm); - virtual ~opt_solver(); + ~opt_solver() override; - virtual solver* translate(ast_manager& m, params_ref const& p); - virtual void updt_params(params_ref const& p); - virtual void collect_param_descrs(param_descrs & r); - virtual void collect_statistics(statistics & st) const; - virtual void assert_expr(expr * t); - virtual void push_core(); - virtual void pop_core(unsigned n); - virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions); - virtual void get_unsat_core(ptr_vector & r); - virtual void get_model(model_ref & _m); - virtual proof * get_proof(); - virtual std::string reason_unknown() const; - virtual void set_reason_unknown(char const* msg); - virtual void get_labels(svector & r); - virtual void set_progress_callback(progress_callback * callback); - virtual unsigned get_num_assertions() const; - virtual expr * get_assertion(unsigned idx) const; - virtual ast_manager& get_manager() const { return m; } - virtual lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes); - virtual lbool preferred_sat(expr_ref_vector const& asms, vector& cores); + solver* translate(ast_manager& m, params_ref const& p) override; + void updt_params(params_ref const& p) override; + void collect_param_descrs(param_descrs & r) override; + void collect_statistics(statistics & st) const override; + void assert_expr(expr * t) override; + void push_core() override; + void pop_core(unsigned n) override; + lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) override; + void get_unsat_core(ptr_vector & r) override; + void get_model(model_ref & _m) override; + proof * get_proof() override; + std::string reason_unknown() const override; + void set_reason_unknown(char const* msg) override; + void get_labels(svector & r) override; + void set_progress_callback(progress_callback * callback) override; + unsigned get_num_assertions() const override; + expr * get_assertion(unsigned idx) const override; + ast_manager& get_manager() const override { return m; } + lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) override; + lbool preferred_sat(expr_ref_vector const& asms, vector& cores) override; void set_logic(symbol const& logic); smt::theory_var add_objective(app* term); diff --git a/src/parsers/util/cost_parser.h b/src/parsers/util/cost_parser.h index f0330d824..d2a96dc25 100644 --- a/src/parsers/util/cost_parser.h +++ b/src/parsers/util/cost_parser.h @@ -27,9 +27,9 @@ class cost_parser : public simple_parser { var_ref_vector m_vars; public: cost_parser(ast_manager & m); - virtual ~cost_parser() {} - virtual expr * parse_int(rational const & r); - virtual expr * parse_float(rational const & r); + ~cost_parser() override {} + expr * parse_int(rational const & r) override; + expr * parse_float(rational const & r) override; unsigned add_var(symbol name); unsigned add_var(char const * name) { return add_var(symbol(name)); } void reset_vars(); diff --git a/src/qe/nlarith_util.cpp b/src/qe/nlarith_util.cpp index 4f07b59dd..7d86860b3 100644 --- a/src/qe/nlarith_util.cpp +++ b/src/qe/nlarith_util.cpp @@ -1018,13 +1018,13 @@ namespace nlarith { app* m_x; public: basic_subst(imp& i, app* x) : isubst(i), m_x(x) {} - virtual void mk_lt(poly const& p, app_ref& r) { + void mk_lt(poly const& p, app_ref& r) override { imp& I = m_imp; app_ref result(I.m()); I.mk_polynomial(m_x, p, result); r = I.mk_lt(result); } - virtual void mk_eq(poly const& p, app_ref& r) { + void mk_eq(poly const& p, app_ref& r) override { imp& I = m_imp; app_ref result(I.m()); I.mk_polynomial(m_x, p, result); @@ -1039,7 +1039,7 @@ namespace nlarith { // p[e/x] < 0: (a*parity(d) < 0 /\ 0 < a*a - b*b*c) \/ // (b*parity(d) <= 0 /\ (a*parity(d) < 0 \/ a*a - b*b*c < 0)) - virtual void mk_lt(poly const& p, app_ref& r) { + void mk_lt(poly const& p, app_ref& r) override { imp& I = m_imp; ast_manager& m = I.m(); app_ref a(m), b(m), c(m_s.m_c), d(m); @@ -1061,7 +1061,7 @@ namespace nlarith { // p[e/x] = 0: a*b <= 0 & a*a - b*b*c = 0 - virtual void mk_eq(poly const& p, app_ref& r) { + void mk_eq(poly const& p, app_ref& r) override { imp& I = m_imp; ast_manager& m = I.m(); app_ref a(m), b(m), c(m_s.m_c),d(m), aabbc(m); @@ -1076,7 +1076,7 @@ namespace nlarith { } // p[e/x] <= 0: a*parity(d) <= 0 /\ 0 <= a*a - b*b*c \/ b*parity(d) <= 0 /\ a*a - b*b*c <= 0 - virtual void mk_le(poly const& p, app_ref& r) { + void mk_le(poly const& p, app_ref& r) override { imp& I = m_imp; ast_manager& m = I.m(); app_ref a(m), b(m), c(m_s.m_c), d(m); @@ -1125,10 +1125,10 @@ namespace nlarith { public: plus_eps_subst(imp& i, isubst& s) : isubst(i), m_s(s) {} - virtual void mk_lt(poly const& p, app_ref& r) { mk_nu(p, r); } + void mk_lt(poly const& p, app_ref& r) override { mk_nu(p, r); } // /\ p[i] = 0 - virtual void mk_eq(poly const& p, app_ref& r) { r = m_imp.mk_zero(p); } + void mk_eq(poly const& p, app_ref& r) override { r = m_imp.mk_zero(p); } }; class minus_eps_subst : public isubst { @@ -1172,10 +1172,10 @@ namespace nlarith { public: minus_eps_subst(imp& i, isubst& s) : isubst(i), m_s(s) {} - virtual void mk_lt(poly const& p, app_ref& r) { mk_nu(p, true, r); } + void mk_lt(poly const& p, app_ref& r) override { mk_nu(p, true, r); } // /\ p[i] = 0 - virtual void mk_eq(poly const& p, app_ref& r) { r = m_imp.mk_zero(p); } + void mk_eq(poly const& p, app_ref& r) override { r = m_imp.mk_zero(p); } }; class minus_inf_subst : public isubst { @@ -1208,12 +1208,12 @@ namespace nlarith { public: minus_inf_subst(imp& i) : isubst(i) {} - virtual void mk_lt(poly const& p, app_ref& r) { + void mk_lt(poly const& p, app_ref& r) override { r = mk_lt(p, p.size()); } // /\ p[i] = 0 - virtual void mk_eq(poly const& p, app_ref& r) { r = m_imp.mk_zero(p); } + void mk_eq(poly const& p, app_ref& r) override { r = m_imp.mk_zero(p); } }; @@ -1238,10 +1238,10 @@ namespace nlarith { public: plus_inf_subst(imp& i) : isubst(i) {} - virtual void mk_lt(poly const& p, app_ref& r) { r = mk_lt(p, p.size()); } + void mk_lt(poly const& p, app_ref& r) override { r = mk_lt(p, p.size()); } // /\ p[i] = 0 - virtual void mk_eq(poly const& p, app_ref& r) { r = m_imp.mk_zero(p); } + void mk_eq(poly const& p, app_ref& r) override { r = m_imp.mk_zero(p); } }; /** @@ -1615,9 +1615,9 @@ namespace nlarith { public: simple_branch(ast_manager& m, app* cnstr): m_cnstr(cnstr, m), m_atoms(m) {} - virtual ~simple_branch() {} - virtual app* get_constraint() { return m_cnstr.get(); } - virtual void get_updates(ptr_vector& atoms, svector& updates) { + ~simple_branch() override {} + app* get_constraint() override { return m_cnstr.get(); } + void get_updates(ptr_vector& atoms, svector& updates) override { for (unsigned i = 0; i < m_atoms.size(); ++i) { atoms.push_back(m_atoms[i].get()); updates.push_back(m_updates[i]); @@ -1635,7 +1635,7 @@ namespace nlarith { public: ins_rem_branch(ast_manager& m, app* a, app* r, app* cnstr): simple_branch(m, cnstr) { insert(a); remove(r); } - virtual ~ins_rem_branch() {} + ~ins_rem_branch() override {} }; /** diff --git a/src/qe/nlqsat.cpp b/src/qe/nlqsat.cpp index e28f6ae4f..0898afeda 100644 --- a/src/qe/nlqsat.cpp +++ b/src/qe/nlqsat.cpp @@ -555,7 +555,7 @@ namespace qe { } - void reset() { + void reset() override { //m_solver.reset(); m_asms.reset(); m_cached_asms.reset(); @@ -798,16 +798,16 @@ namespace qe { m_nftactic = mk_tseitin_cnf_tactic(m); } - virtual ~nlqsat() { + ~nlqsat() override { } - void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { params_ref p2(p); p2.set_bool("factor", false); m_solver.updt_params(p2); } - void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { } @@ -815,7 +815,7 @@ namespace qe { /* out */ goal_ref_buffer & result, /* out */ model_converter_ref & mc, /* out */ proof_converter_ref & pc, - /* out */ expr_dependency_ref & core) { + /* out */ expr_dependency_ref & core) override { tactic_report report("nlqsat-tactic", *in); @@ -863,27 +863,27 @@ namespace qe { } - void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { st.copy(m_st); st.update("qsat num rounds", m_stats.m_num_rounds); } - void reset_statistics() { + void reset_statistics() override { m_stats.reset(); m_solver.reset_statistics(); } - void cleanup() { + void cleanup() override { reset(); } - void set_logic(symbol const & l) { + void set_logic(symbol const & l) override { } - void set_progress_callback(progress_callback * callback) { + void set_progress_callback(progress_callback * callback) override { } - tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(nlqsat, m, m_mode, m_params); } }; diff --git a/src/qe/qe.cpp b/src/qe/qe.cpp index 57a8c365b..08a0c44c0 100644 --- a/src/qe/qe.cpp +++ b/src/qe/qe.cpp @@ -1383,7 +1383,7 @@ namespace qe { m_rewriter.updt_params(params); } - virtual ~quant_elim_plugin() { + ~quant_elim_plugin() override { reset(); } @@ -2035,7 +2035,7 @@ namespace qe { { } - virtual ~quant_elim_new() { + ~quant_elim_new() override { reset(); } @@ -2052,17 +2052,17 @@ namespace qe { } - void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { for (unsigned i = 0; i < m_plugins.size(); ++i) { m_plugins[i]->collect_statistics(st); } } - void updt_params(params_ref const& p) { + void updt_params(params_ref const& p) override { m_eliminate_variables_as_block = p.get_bool("eliminate_variables_as_block", m_eliminate_variables_as_block); } - void eliminate(bool is_forall, unsigned num_vars, app* const* vars, expr_ref& fml) { + void eliminate(bool is_forall, unsigned num_vars, app* const* vars, expr_ref& fml) override { if (is_forall) { eliminate_forall_bind(num_vars, vars, fml); } @@ -2092,14 +2092,14 @@ namespace qe { } } - virtual void set_assumption(expr* fml) { + void set_assumption(expr* fml) override { m_assumption = fml; } - virtual lbool eliminate_exists( + lbool eliminate_exists( unsigned num_vars, app* const* vars, expr_ref& fml, - app_ref_vector& free_vars, bool get_first, guarded_defs* defs) { + app_ref_vector& free_vars, bool get_first, guarded_defs* defs) override { if (get_first) { return eliminate_block(num_vars, vars, fml, free_vars, get_first, defs); } @@ -2483,7 +2483,7 @@ namespace qe { m_fparams.updt_params(p); } - virtual ~simplify_solver_context() { reset(); } + ~simplify_solver_context() override { reset(); } void solve(expr_ref& fml, app_ref_vector& vars) { @@ -2502,16 +2502,16 @@ namespace qe { while (solved); } - virtual ast_manager& get_manager() { return m; } + ast_manager& get_manager() override { return m; } - virtual atom_set const& pos_atoms() const { return m_pos; } - virtual atom_set const& neg_atoms() const { return m_neg; } + atom_set const& pos_atoms() const override { return m_pos; } + atom_set const& neg_atoms() const override { return m_neg; } // Access current set of variables to solve - virtual unsigned get_num_vars() const { return m_vars->size(); } - virtual app* get_var(unsigned idx) const { return (*m_vars)[idx].get(); } - virtual app_ref_vector const& get_vars() const { return *m_vars; } - virtual bool is_var(expr* e, unsigned& idx) const { + unsigned get_num_vars() const override { return m_vars->size(); } + app* get_var(unsigned idx) const override { return (*m_vars)[idx].get(); } + app_ref_vector const& get_vars() const override { return *m_vars; } + bool is_var(expr* e, unsigned& idx) const override { for (unsigned i = 0; i < m_vars->size(); ++i) { if ((*m_vars)[i].get() == e) { idx = i; @@ -2521,12 +2521,12 @@ namespace qe { return false; } - virtual contains_app& contains(unsigned idx) { + contains_app& contains(unsigned idx) override { return *m_contains[idx]; } // callback to replace variable at index 'idx' with definition 'def' and updated formula 'fml' - virtual void elim_var(unsigned idx, expr* fml, expr* def) { + void elim_var(unsigned idx, expr* fml, expr* def) override { TRACE("qe", tout << mk_pp(m_vars->get(idx), m) << " " << mk_pp(fml, m) << "\n";); *m_fml = fml; m_vars->set(idx, m_vars->get(m_vars->size()-1)); @@ -2537,17 +2537,17 @@ namespace qe { } // callback to add new variable to branch. - virtual void add_var(app* x) { + void add_var(app* x) override { TRACE("qe", tout << "add var: " << mk_pp(x, m) << "\n";); m_vars->push_back(x); } // callback to add constraints in branch. - virtual void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) { + void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) override { UNREACHABLE(); } // eliminate finite domain variable 'var' from fml. - virtual void blast_or(app* var, expr_ref& fml) { + void blast_or(app* var, expr_ref& fml) override { UNREACHABLE(); } diff --git a/src/qe/qe.h b/src/qe/qe.h index 6946f9566..bdce4d159 100644 --- a/src/qe/qe.h +++ b/src/qe/qe.h @@ -49,13 +49,13 @@ namespace qe { i_solver_context& m_s; public: is_relevant(i_solver_context& s):m_s(s) {} - virtual bool operator()(expr* e); + bool operator()(expr* e) override; }; class mk_atom_fn : public i_nnf_atom { i_solver_context& m_s; public: mk_atom_fn(i_solver_context& s) : m_s(s) {} - void operator()(expr* e, bool p, expr_ref& result); + void operator()(expr* e, bool p, expr_ref& result) override; }; is_relevant m_is_relevant; diff --git a/src/qe/qe_arith.h b/src/qe/qe_arith.h index 88675d5a4..8e2400ac7 100644 --- a/src/qe/qe_arith.h +++ b/src/qe/qe_arith.h @@ -25,11 +25,11 @@ namespace qe { imp* m_imp; public: arith_project_plugin(ast_manager& m); - virtual ~arith_project_plugin(); - virtual bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits); - virtual bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits); - virtual family_id get_family_id(); - virtual void operator()(model& model, app_ref_vector& vars, expr_ref_vector& lits); + ~arith_project_plugin() override; + bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits) override; + bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits) override; + family_id get_family_id() override; + void operator()(model& model, app_ref_vector& vars, expr_ref_vector& lits) override; opt::inf_eps maximize(expr_ref_vector const& fmls, model& mdl, app* t, expr_ref& ge, expr_ref& gt); diff --git a/src/qe/qe_arith_plugin.cpp b/src/qe/qe_arith_plugin.cpp index 89dee9586..9e056cdc2 100644 --- a/src/qe/qe_arith_plugin.cpp +++ b/src/qe/qe_arith_plugin.cpp @@ -1536,14 +1536,14 @@ public: m_trail(m) {} - ~arith_plugin() { + ~arith_plugin() override { bounds_cache::iterator it = m_bounds_cache.begin(), end = m_bounds_cache.end(); for (; it != end; ++it) { dealloc(it->get_value()); } } - virtual void assign(contains_app& contains_x, expr* fml, rational const& vl) { + void assign(contains_app& contains_x, expr* fml, rational const& vl) override { SASSERT(vl.is_unsigned()); app* x = contains_x.x(); unsigned v = vl.get_unsigned(); @@ -1633,7 +1633,7 @@ public: } - virtual bool get_num_branches(contains_app& contains_x, expr* fml, rational& nb) { + bool get_num_branches(contains_app& contains_x, expr* fml, rational& nb) override { app* x = contains_x.x(); if (!update_bounds(contains_x, fml)) { return false; @@ -1645,7 +1645,7 @@ public: return true; } - virtual void subst(contains_app& contains_x, rational const& vl, expr_ref& fml, expr_ref* def) { + void subst(contains_app& contains_x, rational const& vl, expr_ref& fml, expr_ref* def) override { SASSERT(vl.is_unsigned()); if (def) { get_def(contains_x, vl.get_unsigned(), fml, *def); @@ -1654,7 +1654,7 @@ public: TRACE("qe", tout << mk_pp(contains_x.x(), m) << " " << vl << "\n" << mk_pp(fml, m) << "\n";); } - virtual bool project(contains_app& x, model_ref& model, expr_ref& fml) { + bool project(contains_app& x, model_ref& model, expr_ref& fml) override { if (!update_bounds(x, fml)) { TRACE("qe", tout << mk_pp(x.x(), m) << " failed to update bounds\n";); return false; @@ -1668,19 +1668,19 @@ public: } - virtual unsigned get_weight(contains_app& contains_x, expr* fml) { + unsigned get_weight(contains_app& contains_x, expr* fml) override { return 2; } - virtual bool solve(conj_enum& conjs, expr* fml) { + bool solve(conj_enum& conjs, expr* fml) override { return m_util.solve(conjs, fml); } - virtual bool mk_atom(expr* e, bool p, expr_ref& result) { + bool mk_atom(expr* e, bool p, expr_ref& result) override { return m_util.mk_atom(e, p, result); } - virtual bool is_uninterpreted(app* f) { + bool is_uninterpreted(app* f) override { switch(f->get_decl_kind()) { case OP_NUM: case OP_LE: @@ -2456,7 +2456,7 @@ public: m_util.set_enable_linear(true); // (produce_models); } - virtual ~nlarith_plugin() { + ~nlarith_plugin() override { bcs_t::iterator it = m_cache.begin(), end = m_cache.end(); for (; it != end; ++it) { dealloc(it->get_value()); @@ -2467,7 +2467,7 @@ public: } } - virtual bool simplify(expr_ref& fml) { + bool simplify(expr_ref& fml) override { expr_ref tmp(m), tmp2(m); m_factor_rw(fml, tmp); m_rewriter(tmp, tmp2); @@ -2478,7 +2478,7 @@ public: return false; } - virtual void assign(contains_app& x, expr* fml, rational const& vl) { + void assign(contains_app& x, expr* fml, rational const& vl) override { nlarith::branch_conditions *brs = 0; VERIFY (m_cache.find(x.x(), fml, brs)); SASSERT(vl.is_unsigned()); @@ -2491,8 +2491,8 @@ public: m_ctx.add_constraint(true, result); } - virtual bool get_num_branches(contains_app& x, - expr* fml, rational& num_branches) { + bool get_num_branches(contains_app& x, + expr* fml, rational& num_branches) override { nlarith::branch_conditions *brs; if (m_cache.find(x.x(), fml, brs)) { num_branches = rational(brs->size()); @@ -2515,7 +2515,7 @@ public: return true; } - virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) { + void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override { nlarith::branch_conditions *brs = 0; VERIFY (m_cache.find(x.x(), fml, brs)); SASSERT(vl.is_unsigned()); @@ -2534,7 +2534,7 @@ public: } - virtual unsigned get_weight(contains_app& x, expr* fml) { + unsigned get_weight(contains_app& x, expr* fml) override { obj_map* weights = 0; unsigned weight = 0; if (!m_weights.find(fml, weights)) { @@ -2553,12 +2553,12 @@ public: return UINT_MAX; } - virtual bool solve(conj_enum& conjs, expr* fml) { return false; } + bool solve(conj_enum& conjs, expr* fml) override { return false; } // we don't need to modify the atom. - virtual bool mk_atom(expr* e, bool p, expr_ref& result) { return false; } + bool mk_atom(expr* e, bool p, expr_ref& result) override { return false; } - virtual bool is_uninterpreted(app* f) { + bool is_uninterpreted(app* f) override { if (m_produce_models) { return true; } diff --git a/src/qe/qe_array_plugin.cpp b/src/qe/qe_array_plugin.cpp index 9eeccd6a4..775dd0443 100644 --- a/src/qe/qe_array_plugin.cpp +++ b/src/qe/qe_array_plugin.cpp @@ -27,23 +27,23 @@ namespace qe { { } - virtual ~array_plugin() {} + ~array_plugin() override {} - virtual void assign(contains_app& x, expr* fml, rational const& vl) { + void assign(contains_app& x, expr* fml, rational const& vl) override { UNREACHABLE(); } - virtual bool get_num_branches( contains_app& x, expr* fml, rational& num_branches) { + bool get_num_branches( contains_app& x, expr* fml, rational& num_branches) override { return false; } - virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) { + void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override { UNREACHABLE(); } - virtual bool solve(conj_enum& conjs, expr* fml) { + bool solve(conj_enum& conjs, expr* fml) override { conj_enum::iterator it = conjs.begin(), end = conjs.end(); for (; it != end; ++it) { @@ -65,7 +65,7 @@ namespace qe { return false; } - virtual bool is_uninterpreted(app* f) { + bool is_uninterpreted(app* f) override { return true; } diff --git a/src/qe/qe_arrays.h b/src/qe/qe_arrays.h index e100ebce4..a955250a8 100644 --- a/src/qe/qe_arrays.h +++ b/src/qe/qe_arrays.h @@ -31,10 +31,10 @@ namespace qe { imp* m_imp; public: array_project_plugin(ast_manager& m); - virtual ~array_project_plugin(); - virtual bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits); - virtual bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits); - virtual family_id get_family_id(); + ~array_project_plugin() override; + bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits) override; + bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits) override; + family_id get_family_id() override; }; }; diff --git a/src/qe/qe_bool_plugin.cpp b/src/qe/qe_bool_plugin.cpp index 82e09bbed..eb0553a0e 100644 --- a/src/qe/qe_bool_plugin.cpp +++ b/src/qe/qe_bool_plugin.cpp @@ -39,16 +39,16 @@ namespace qe { m_replace(m) {} - virtual void assign(contains_app& x, expr* fml, rational const& vl) { + void assign(contains_app& x, expr* fml, rational const& vl) override { SASSERT(vl.is_zero() || vl.is_one()); } - virtual bool get_num_branches(contains_app& x, expr* fml, rational& nb) { + bool get_num_branches(contains_app& x, expr* fml, rational& nb) override { nb = rational(2); return true; } - virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) { + void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override { SASSERT(vl.is_one() || vl.is_zero()); expr* tf = (vl.is_one())?m.mk_true():m.mk_false(); m_replace.apply_substitution(x.x(), tf, fml); @@ -57,7 +57,7 @@ namespace qe { } } - virtual bool project(contains_app& x, model_ref& model, expr_ref& fml) { + bool project(contains_app& x, model_ref& model, expr_ref& fml) override { model_evaluator model_eval(*model); expr_ref val_x(m); rational val; @@ -69,7 +69,7 @@ namespace qe { return true; } - virtual unsigned get_weight(contains_app& contains_x, expr* fml) { + unsigned get_weight(contains_app& contains_x, expr* fml) override { app* x = contains_x.x(); bool p = m_ctx.pos_atoms().contains(x); bool n = m_ctx.neg_atoms().contains(x); @@ -79,13 +79,13 @@ namespace qe { return 0; } - virtual bool solve(conj_enum& conjs,expr* fml) { + bool solve(conj_enum& conjs,expr* fml) override { return solve_units(conjs, fml) || solve_polarized(fml); } - virtual bool is_uninterpreted(app* a) { + bool is_uninterpreted(app* a) override { return false; } diff --git a/src/qe/qe_bv_plugin.cpp b/src/qe/qe_bv_plugin.cpp index 6678d6fcf..ef87f235f 100644 --- a/src/qe/qe_bv_plugin.cpp +++ b/src/qe/qe_bv_plugin.cpp @@ -37,16 +37,16 @@ namespace qe { m_bv(m) {} - virtual void assign(contains_app& x, expr* fml, rational const& vl) { + void assign(contains_app& x, expr* fml, rational const& vl) override { } - virtual bool get_num_branches(contains_app& x, expr* fml, rational& nb) { + bool get_num_branches(contains_app& x, expr* fml, rational& nb) override { unsigned sz = m_bv.get_bv_size(x.x()); nb = power(rational(2), sz); return true; } - virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) { + void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override { app_ref c(m_bv.mk_numeral(vl, m_bv.get_bv_size(x.x())), m); m_replace.apply_substitution(x.x(), c, fml); if (def) { @@ -54,7 +54,7 @@ namespace qe { } } - virtual bool project(contains_app& x, model_ref& model, expr_ref& fml) { + bool project(contains_app& x, model_ref& model, expr_ref& fml) override { model_evaluator model_eval(*model); expr_ref val_x(m); rational val(0); @@ -65,13 +65,13 @@ namespace qe { return true; } - virtual unsigned get_weight(contains_app& contains_x, expr* fml) { + unsigned get_weight(contains_app& contains_x, expr* fml) override { return 2; } - bool solve(conj_enum& conjs, expr* fml) { return false; } + bool solve(conj_enum& conjs, expr* fml) override { return false; } - virtual bool is_uninterpreted(app* f) { + bool is_uninterpreted(app* f) override { switch(f->get_decl_kind()) { case OP_BSDIV0: case OP_BUDIV0: diff --git a/src/qe/qe_cmd.cpp b/src/qe/qe_cmd.cpp index 3c55c0f49..eb119ce0b 100644 --- a/src/qe/qe_cmd.cpp +++ b/src/qe/qe_cmd.cpp @@ -14,36 +14,36 @@ class qe_cmd : public parametric_cmd { public: qe_cmd(char const* name = "elim-quantifiers"):parametric_cmd(name) {} - virtual char const * get_usage() const { return " ( )*"; } + char const * get_usage() const override { return " ( )*"; } - virtual char const * get_main_descr() const { + char const * get_main_descr() const override { return "apply quantifier elimination to the supplied expression"; } - virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { + void init_pdescrs(cmd_context & ctx, param_descrs & p) override { insert_timeout(p); p.insert("print", CPK_BOOL, "(default: true) print the simplified term."); p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } - virtual ~qe_cmd() { + ~qe_cmd() override { } - virtual void prepare(cmd_context & ctx) { + void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); m_target = 0; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_target == 0) return CPK_EXPR; return parametric_cmd::next_arg_kind(ctx); } - virtual void set_next_arg(cmd_context & ctx, expr * arg) { + void set_next_arg(cmd_context & ctx, expr * arg) override { m_target = arg; } - virtual void execute(cmd_context & ctx) { + void execute(cmd_context & ctx) override { proof_ref pr(ctx.m()); qe::simplify_rewriter_star qe(ctx.m()); expr_ref result(ctx.m()); diff --git a/src/qe/qe_datatype_plugin.cpp b/src/qe/qe_datatype_plugin.cpp index c3525aa33..0bfe82751 100644 --- a/src/qe/qe_datatype_plugin.cpp +++ b/src/qe/qe_datatype_plugin.cpp @@ -435,7 +435,7 @@ namespace qe { { } - virtual ~datatype_plugin() { + ~datatype_plugin() override { { eqs_cache::iterator it = m_eqs_cache.begin(), end = m_eqs_cache.end(); for (; it != end; ++it) { @@ -451,7 +451,7 @@ namespace qe { } - virtual bool get_num_branches( contains_app& x, expr* fml, rational& num_branches) { + bool get_num_branches( contains_app& x, expr* fml, rational& num_branches) override { sort* s = x.x()->get_decl()->get_range(); SASSERT(m_datatype_util.is_datatype(s)); if (m_datatype_util.is_recursive(s)) { @@ -463,7 +463,7 @@ namespace qe { } - virtual void assign(contains_app& x, expr* fml, rational const& vl) { + void assign(contains_app& x, expr* fml, rational const& vl) override { sort* s = x.x()->get_decl()->get_range(); SASSERT(m_datatype_util.is_datatype(s)); TRACE("qe", tout << mk_pp(x.x(), m) << " " << vl << "\n";); @@ -475,7 +475,7 @@ namespace qe { } } - virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) { + void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override { sort* s = x.x()->get_decl()->get_range(); SASSERT(m_datatype_util.is_datatype(s)); TRACE("qe", tout << mk_pp(x.x(), m) << " " << vl << "\n";); @@ -487,20 +487,20 @@ namespace qe { } } - virtual unsigned get_weight( contains_app& x, expr* fml) { + unsigned get_weight( contains_app& x, expr* fml) override { return UINT_MAX; } - virtual bool solve( conj_enum& conj, expr* fml) { + bool solve( conj_enum& conj, expr* fml) override { return false; } - virtual bool simplify( expr_ref& fml) { + bool simplify( expr_ref& fml) override { lift_foreign_vars lift(m, m_datatype_util, m_ctx); return lift.lift(fml); } - virtual bool mk_atom(expr* e, bool p, expr_ref& result) { + bool mk_atom(expr* e, bool p, expr_ref& result) override { return false; } @@ -807,7 +807,7 @@ namespace qe { public: has_select(app* x, func_decl* c, datatype_util& u): m_x(x), m_c(c), m_util(u) {} - virtual bool operator()(expr* e) { + bool operator()(expr* e) override { if (!is_app(e)) return false; app* a = to_app(e); if (!m_util.is_accessor(a)) return false; diff --git a/src/qe/qe_datatypes.h b/src/qe/qe_datatypes.h index 7352b4ca7..9c8eb5a76 100644 --- a/src/qe/qe_datatypes.h +++ b/src/qe/qe_datatypes.h @@ -31,10 +31,10 @@ namespace qe { imp* m_imp; public: datatype_project_plugin(ast_manager& m); - virtual ~datatype_project_plugin(); - virtual bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits); - virtual bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits); - virtual family_id get_family_id(); + ~datatype_project_plugin() override; + bool operator()(model& model, app* var, app_ref_vector& vars, expr_ref_vector& lits) override; + bool solve(model& model, app_ref_vector& vars, expr_ref_vector& lits) override; + family_id get_family_id() override; }; }; diff --git a/src/qe/qe_dl_plugin.cpp b/src/qe/qe_dl_plugin.cpp index 7ff7bc11e..714540e41 100644 --- a/src/qe/qe_dl_plugin.cpp +++ b/src/qe/qe_dl_plugin.cpp @@ -56,7 +56,7 @@ namespace qe { { } - virtual ~dl_plugin() { + ~dl_plugin() override { eqs_cache::iterator it = m_eqs_cache.begin(), end = m_eqs_cache.end(); for (; it != end; ++it) { dealloc(it->get_value()); @@ -65,7 +65,7 @@ namespace qe { - bool get_num_branches(contains_app & x,expr * fml,rational & num_branches) { + bool get_num_branches(contains_app & x,expr * fml,rational & num_branches) override { if (!update_eqs(x, fml)) { return false; } @@ -80,7 +80,7 @@ namespace qe { return true; } - void assign(contains_app & x,expr * fml,const rational & v) { + void assign(contains_app & x,expr * fml,const rational & v) override { SASSERT(v.is_unsigned()); eq_atoms& eqs = get_eqs(x.x(), fml); unsigned uv = v.get_unsigned(); @@ -94,7 +94,7 @@ namespace qe { } } - void subst(contains_app & x,const rational & v,expr_ref & fml, expr_ref* def) { + void subst(contains_app & x,const rational & v,expr_ref & fml, expr_ref* def) override { SASSERT(v.is_unsigned()); eq_atoms& eqs = get_eqs(x.x(), fml); unsigned uv = v.get_unsigned(); @@ -111,7 +111,7 @@ namespace qe { } } - virtual bool solve(conj_enum& conjs, expr* fml) { return false; } + bool solve(conj_enum& conjs, expr* fml) override { return false; } private: diff --git a/src/qe/qe_lite.cpp b/src/qe/qe_lite.cpp index 1220bd571..678c5e29b 100644 --- a/src/qe/qe_lite.cpp +++ b/src/qe/qe_lite.cpp @@ -2607,43 +2607,43 @@ public: m_imp = alloc(imp, m, p); } - virtual ~qe_lite_tactic() { + ~qe_lite_tactic() override { dealloc(m_imp); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(qe_lite_tactic, m, m_params); } - 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 { // m_imp->collect_param_descrs(r); } - virtual void operator()(goal_ref const & in, + void operator()(goal_ref const & in, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { // m_imp->collect_statistics(st); } - virtual void reset_statistics() { + void reset_statistics() override { // m_imp->reset_statistics(); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; dealloc(m_imp); m_imp = alloc(imp, m, m_params); diff --git a/src/qe/qe_sat_tactic.cpp b/src/qe/qe_sat_tactic.cpp index 250ffff4a..547f6bad1 100644 --- a/src/qe/qe_sat_tactic.cpp +++ b/src/qe/qe_sat_tactic.cpp @@ -39,14 +39,14 @@ namespace qe { class is_relevant_default : public i_expr_pred { public: - bool operator()(expr* e) { + bool operator()(expr* e) override { return true; } }; class mk_atom_default : public i_nnf_atom { public: - virtual void operator()(expr* e, bool pol, expr_ref& result) { + void operator()(expr* e, bool pol, expr_ref& result) override { if (pol) result = e; else result = result.get_manager().mk_not(e); } @@ -97,7 +97,7 @@ namespace qe { m_fml(m), m_projection_mode_param(true) {} - virtual ~solver_context() { + ~solver_context() override { std::for_each(m_contains_app.begin(), m_contains_app.end(), delete_proc()); } @@ -111,28 +111,28 @@ namespace qe { void set_projection_mode(bool p) { m_projection_mode_param = p; } - ast_manager& get_manager() { return m; } + ast_manager& get_manager() override { return m; } expr* fml() { return m_fml; } // set of atoms in current formula. - virtual atom_set const& pos_atoms() const { return m_pos; } - virtual atom_set const& neg_atoms() const { return m_neg; } + atom_set const& pos_atoms() const override { return m_pos; } + atom_set const& neg_atoms() const override { return m_neg; } // Access current set of variables to solve - virtual unsigned get_num_vars() const { return m_vars.size(); } - virtual app* get_var(unsigned idx) const { return m_vars[idx]; } - virtual app_ref_vector const& get_vars() const { return m_vars; } - virtual bool is_var(expr* e, unsigned& idx) const { + unsigned get_num_vars() const override { return m_vars.size(); } + app* get_var(unsigned idx) const override { return m_vars[idx]; } + app_ref_vector const& get_vars() const override { return m_vars; } + bool is_var(expr* e, unsigned& idx) const override { for (unsigned i = 0; i < m_vars.size(); ++i) { if (e == m_vars[i]) return (idx = i, true); } return false; } - virtual contains_app& contains(unsigned idx) { return *m_contains_app[idx]; } + contains_app& contains(unsigned idx) override { return *m_contains_app[idx]; } // callback to replace variable at index 'idx' with definition 'def' and updated formula 'fml' - virtual void elim_var(unsigned idx, expr* fml, expr* def) { + void elim_var(unsigned idx, expr* fml, expr* def) override { m_fml = fml; m_pos.reset(); m_neg.reset(); @@ -143,13 +143,13 @@ namespace qe { } // callback to add new variable to branch. - virtual void add_var(app* x) { + void add_var(app* x) override { m_vars.push_back(x); m_contains_app.push_back(alloc(contains_app, m, x)); } // callback to add constraints in branch. - virtual void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) { + void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) override { ptr_buffer args; if (l1) args.push_back(l1); if (l2) args.push_back(l2); @@ -160,7 +160,7 @@ namespace qe { } // eliminate finite domain variable 'var' from fml. - virtual void blast_or(app* var, expr_ref& fml) { + void blast_or(app* var, expr_ref& fml) override { expr_ref result(m); expr_quant_elim qelim(m, m_super.m_fparams); qe::mk_exists(1, &var, fml); @@ -223,20 +223,19 @@ namespace qe { m_fparams.m_model = true; } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(sat_tactic, m); } - virtual ~sat_tactic() { + ~sat_tactic() override { reset(); } - virtual void operator()( - goal_ref const& goal, - goal_ref_buffer& result, - model_converter_ref& mc, - proof_converter_ref & pc, - expr_dependency_ref& core) + void operator()(goal_ref const& goal, + goal_ref_buffer& result, + model_converter_ref& mc, + proof_converter_ref & pc, + expr_dependency_ref& core) override { try { checkpoint(); @@ -269,7 +268,7 @@ namespace qe { } } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { for (unsigned i = 0; i < m_solvers.size(); ++i) { m_solvers[i]->collect_statistics(st); } @@ -277,7 +276,7 @@ namespace qe { m_ctx_rewriter.collect_statistics(st); } - virtual void reset_statistics() { + void reset_statistics() override { for (unsigned i = 0; i < m_solvers.size(); ++i) { m_solvers[i]->reset_statistics(); } @@ -285,9 +284,9 @@ namespace qe { m_ctx_rewriter.reset_statistics(); } - virtual void cleanup() {} + void cleanup() override {} - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_extrapolate_strategy_param = p.get_uint("extrapolate_strategy", m_extrapolate_strategy_param); m_projection_mode_param = p.get_bool("projection_mode", m_projection_mode_param); m_strong_context_simplify_param = p.get_bool("strong_context_simplify", m_strong_context_simplify_param); @@ -296,7 +295,7 @@ namespace qe { m_qe_rw.updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { r.insert("extrapolate_strategy",CPK_UINT, "(default: 0 trivial extrapolation) 1 - nnf strengthening 2 - smt-test 3 - nnf_weakening"); r.insert("projection_mode", CPK_BOOL, "(default: true - full) false - partial quantifier instantiation"); r.insert("strong_context_simplify", CPK_BOOL, "(default: true) use strong context simplifier on result of quantifier elimination"); @@ -326,7 +325,7 @@ namespace qe { smt::kernel& solver(unsigned i) { return *m_solvers[i]; } - void reset() { + void reset() override { for (unsigned i = 0; i < m_solvers.size(); ++i) { dealloc(m_solvers[i]); } diff --git a/src/qe/qe_tactic.cpp b/src/qe/qe_tactic.cpp index 5d1a74813..5a8c3061c 100644 --- a/src/qe/qe_tactic.cpp +++ b/src/qe/qe_tactic.cpp @@ -102,46 +102,46 @@ public: m_imp = alloc(imp, m, p); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(qe_tactic, m, m_params); } - virtual ~qe_tactic() { + ~qe_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 { r.insert("qe_nonlinear", CPK_BOOL, "(default: false) enable virtual term substitution."); m_imp->collect_param_descrs(r); } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { (*m_imp)(in, result, mc, pc, core); m_st.reset(); m_imp->collect_statistics(m_st); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { st.copy(m_st); } - virtual void reset_statistics() { + void reset_statistics() override { m_st.reset(); } - virtual void cleanup() { + void cleanup() override { ast_manager & m = m_imp->m; dealloc(m_imp); m_imp = alloc(imp, m, m_params); diff --git a/src/qe/qe_vartest.h b/src/qe/qe_vartest.h index 047964825..56d9229b8 100644 --- a/src/qe/qe_vartest.h +++ b/src/qe/qe_vartest.h @@ -42,7 +42,7 @@ public: m_num_decls(num_decls), m_var_kind(BY_NUM_DECLS) {} - virtual bool operator()(expr* e) const { + bool operator()(expr* e) const override { if (!is_var(e)) { return false; } diff --git a/src/qe/qsat.cpp b/src/qe/qsat.cpp index 2419d1c77..6d470c5de 100644 --- a/src/qe/qsat.cpp +++ b/src/qe/qsat.cpp @@ -696,7 +696,7 @@ namespace qe { m_level -= num_scopes; } - void reset() { + void reset() override { m_st.reset(); m_fa.s().collect_statistics(m_st); m_ex.s().collect_statistics(m_st); @@ -1204,14 +1204,14 @@ namespace qe { reset(); } - virtual ~qsat() { + ~qsat() override { reset(); } - void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { } - void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { } @@ -1219,7 +1219,7 @@ namespace qe { /* out */ goal_ref_buffer & result, /* out */ model_converter_ref & mc, /* out */ proof_converter_ref & pc, - /* out */ expr_dependency_ref & core) { + /* out */ expr_dependency_ref & core) override { tactic_report report("qsat-tactic", *in); ptr_vector fmls; expr_ref_vector defs(m); @@ -1291,7 +1291,7 @@ namespace qe { } } - void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { st.copy(m_st); m_fa.s().collect_statistics(st); m_ex.s().collect_statistics(st); @@ -1300,23 +1300,23 @@ namespace qe { m_pred_abs.collect_statistics(st); } - void reset_statistics() { + void reset_statistics() override { m_stats.reset(); m_fa.reset(); m_ex.reset(); } - void cleanup() { + void cleanup() override { reset(); } - void set_logic(symbol const & l) { + void set_logic(symbol const & l) override { } - void set_progress_callback(progress_callback * callback) { + void set_progress_callback(progress_callback * callback) override { } - tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(qsat, m, m_params, m_mode); } diff --git a/src/sat/sat_solver/inc_sat_solver.cpp b/src/sat/sat_solver/inc_sat_solver.cpp index 191c49294..0b0ef24d2 100644 --- a/src/sat/sat_solver/inc_sat_solver.cpp +++ b/src/sat/sat_solver/inc_sat_solver.cpp @@ -83,9 +83,9 @@ public: init_preprocess(); } - virtual ~inc_sat_solver() {} + ~inc_sat_solver() override {} - virtual solver* translate(ast_manager& dst_m, params_ref const& p) { + solver* translate(ast_manager& dst_m, params_ref const& p) override { ast_translation tr(m, dst_m); if (m_num_scopes > 0) { throw default_exception("Cannot translate sat solver at non-base level"); @@ -103,7 +103,7 @@ public: return result; } - virtual void set_progress_callback(progress_callback * callback) {} + 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) { @@ -135,7 +135,7 @@ public: (m.is_not(e, e) && is_uninterp_const(e)); } - virtual lbool check_sat(unsigned sz, expr * const * assumptions) { + lbool check_sat(unsigned sz, expr * const * assumptions) override { m_solver.pop_to_base_level(); expr_ref_vector _assumptions(m); obj_map asm2fml; @@ -185,7 +185,7 @@ public: } return r; } - virtual void push() { + void push() override { internalize_formulas(); m_solver.user_push(); ++m_num_scopes; @@ -195,7 +195,7 @@ public: if (m_bb_rewriter) m_bb_rewriter->push(); m_map.push(); } - virtual void pop(unsigned n) { + void pop(unsigned n) override { if (n > m_num_scopes) { // allow inc_sat_solver to n = m_num_scopes; // take over for another solver. } @@ -214,10 +214,10 @@ public: --n; } } - virtual unsigned get_scope_level() const { + unsigned get_scope_level() const override { return m_num_scopes; } - virtual void assert_expr(expr * t, expr * a) { + void assert_expr(expr * t, expr * a) override { if (a) { m_asmsf.push_back(a); assert_expr(m.mk_implies(a, t)); @@ -226,42 +226,42 @@ public: assert_expr(t); } } - virtual ast_manager& get_manager() const { return m; } - virtual void assert_expr(expr * t) { + ast_manager& get_manager() const override { return m; } + void assert_expr(expr * t) override { TRACE("sat", tout << mk_pp(t, m) << "\n";); m_fmls.push_back(t); } - virtual void set_produce_models(bool f) {} - virtual void collect_param_descrs(param_descrs & r) { + void set_produce_models(bool f) override {} + void collect_param_descrs(param_descrs & r) override { goal2sat::collect_param_descrs(r); sat::solver::collect_param_descrs(r); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { solver::updt_params(p); m_params.set_bool("elim_vars", false); m_solver.updt_params(m_params); m_optimize_model = m_params.get_bool("optimize_model", false); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { if (m_preprocess) m_preprocess->collect_statistics(st); m_solver.collect_statistics(st); } - virtual void get_unsat_core(ptr_vector & r) { + void get_unsat_core(ptr_vector & r) override { r.reset(); r.append(m_core.size(), m_core.c_ptr()); } - virtual void get_model(model_ref & mdl) { + void get_model(model_ref & mdl) override { if (!m_model.get()) { extract_model(); } mdl = m_model; } - virtual proof * get_proof() { + proof * get_proof() override { UNREACHABLE(); return 0; } - virtual lbool get_consequences_core(expr_ref_vector const& assumptions, expr_ref_vector const& vars, expr_ref_vector& conseq) { + lbool get_consequences_core(expr_ref_vector const& assumptions, expr_ref_vector const& vars, expr_ref_vector& conseq) override { init_preprocess(); TRACE("sat", tout << assumptions << "\n" << vars << "\n";); sat::literal_vector asms; @@ -304,7 +304,7 @@ public: return r; } - virtual lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) { + lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) override { sat::literal_vector ls; u_map lit2var; for (unsigned i = 0; i < vars.size(); ++i) { @@ -330,24 +330,24 @@ public: return l_true; } - virtual std::string reason_unknown() const { + std::string reason_unknown() const override { return m_unknown; } - virtual void set_reason_unknown(char const* msg) { + void set_reason_unknown(char const* msg) override { m_unknown = msg; } - virtual void get_labels(svector & r) { + void get_labels(svector & r) override { } - virtual unsigned get_num_assertions() const { + unsigned get_num_assertions() const override { return m_fmls.size(); } - virtual expr * get_assertion(unsigned idx) const { + expr * get_assertion(unsigned idx) const override { return m_fmls[idx]; } - virtual unsigned get_num_assumptions() const { + unsigned get_num_assumptions() const override { return m_asmsf.size(); } - virtual expr * get_assumption(unsigned idx) const { + expr * get_assumption(unsigned idx) const override { return m_asmsf[idx]; } diff --git a/src/sat/tactic/goal2sat.cpp b/src/sat/tactic/goal2sat.cpp index 1f9dd91d1..bb5907003 100644 --- a/src/sat/tactic/goal2sat.cpp +++ b/src/sat/tactic/goal2sat.cpp @@ -593,7 +593,7 @@ struct sat2goal::imp { } } - virtual void operator()(model_ref & md, unsigned goal_idx) { + void operator()(model_ref & md, unsigned goal_idx) override { SASSERT(goal_idx == 0); TRACE("sat_mc", tout << "before sat_mc\n"; model_v2_pp(tout, *md); display(tout);); // REMARK: potential problem @@ -644,7 +644,7 @@ struct sat2goal::imp { TRACE("sat_mc", tout << "after sat_mc\n"; model_v2_pp(tout, *md);); } - virtual model_converter * translate(ast_translation & translator) { + model_converter * translate(ast_translation & translator) override { sat_model_converter * res = alloc(sat_model_converter, translator.to()); res->m_fmc = static_cast(m_fmc->translate(translator)); unsigned sz = m_var2expr.size(); @@ -653,7 +653,7 @@ struct sat2goal::imp { return res; } - void display(std::ostream & out) { + void display(std::ostream & out) override { out << "(sat-model-converter\n"; m_mc.display(out); sat::bool_var_set vars; diff --git a/src/sat/tactic/sat_tactic.cpp b/src/sat/tactic/sat_tactic.cpp index 4a6171f70..3db379cb1 100644 --- a/src/sat/tactic/sat_tactic.cpp +++ b/src/sat/tactic/sat_tactic.cpp @@ -39,9 +39,9 @@ class sat_tactic : public tactic { SASSERT(!m.proofs_enabled()); } - void operator()(goal_ref const & g, - goal_ref_buffer & result, - model_converter_ref & mc, + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { mc = 0; pc = 0; core = 0; @@ -162,29 +162,29 @@ public: 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, - model_converter_ref & mc, + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, proof_converter_ref & pc, - expr_dependency_ref & core) { + expr_dependency_ref & core) override { imp proc(g->m(), m_params); scoped_set_imp set(this, &proc); try { @@ -198,15 +198,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(); } diff --git a/src/shell/lp_frontend.cpp b/src/shell/lp_frontend.cpp index 95f9e1eb3..c1afd5e13 100644 --- a/src/shell/lp_frontend.cpp +++ b/src/shell/lp_frontend.cpp @@ -49,7 +49,7 @@ struct front_end_resource_limit : public lp::lp_resource_limit { m_reslim(lim) {} - virtual bool get_cancel_flag() { return !m_reslim.inc(); } + bool get_cancel_flag() override { return !m_reslim.inc(); } }; void run_solver(lp_params & params, char const * mps_file_name) { diff --git a/src/smt/arith_eq_adapter.cpp b/src/smt/arith_eq_adapter.cpp index 307bdc671..febec9565 100644 --- a/src/smt/arith_eq_adapter.cpp +++ b/src/smt/arith_eq_adapter.cpp @@ -42,7 +42,7 @@ namespace smt { m_n2(n2) { } - virtual void undo(context & ctx) { + void undo(context & ctx) override { m_already_processed.erase(m_n1, m_n2); TRACE("arith_eq_adapter_profile", tout << "del #" << m_n1->get_owner_id() << " #" << m_n2->get_owner_id() << "\n";); } @@ -67,9 +67,9 @@ namespace smt { m_ge(ge) { } - virtual ~arith_eq_relevancy_eh() {} + ~arith_eq_relevancy_eh() override {} - virtual void operator()(relevancy_propagator & rp) { + void operator()(relevancy_propagator & rp) override { if (!rp.is_relevant(m_n1)) return; if (!rp.is_relevant(m_n2)) diff --git a/src/smt/asserted_formulas.h b/src/smt/asserted_formulas.h index 88c9e13a7..a67b975eb 100644 --- a/src/smt/asserted_formulas.h +++ b/src/smt/asserted_formulas.h @@ -82,80 +82,80 @@ class asserted_formulas { class reduce_asserted_formulas_fn : public simplify_fmls { public: reduce_asserted_formulas_fn(asserted_formulas& af): simplify_fmls(af, "reduce-asserted") {} - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { af.m_rewriter(j.get_fml(), n, p); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { af.m_rewriter(j.get_fml(), n, p); } }; class find_macros_fn : public simplify_fmls { public: find_macros_fn(asserted_formulas& af): simplify_fmls(af, "find-macros") {} - virtual void operator()() { af.find_macros_core(); } - virtual bool should_apply() const { return af.m_params.m_macro_finder && af.has_quantifiers(); } - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { UNREACHABLE(); } + void operator()() override { af.find_macros_core(); } + bool should_apply() const override { return af.m_params.m_macro_finder && af.has_quantifiers(); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { UNREACHABLE(); } }; class apply_quasi_macros_fn : public simplify_fmls { public: apply_quasi_macros_fn(asserted_formulas& af): simplify_fmls(af, "find-quasi-macros") {} - virtual void operator()() { af.apply_quasi_macros(); } - virtual bool should_apply() const { return af.m_params.m_quasi_macros && af.has_quantifiers(); } - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { UNREACHABLE(); } + void operator()() override { af.apply_quasi_macros(); } + bool should_apply() const override { return af.m_params.m_quasi_macros && af.has_quantifiers(); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { UNREACHABLE(); } }; class nnf_cnf_fn : public simplify_fmls { public: nnf_cnf_fn(asserted_formulas& af): simplify_fmls(af, "nnf-cnf") {} - virtual void operator()() { af.nnf_cnf(); } - virtual bool should_apply() const { return af.m_params.m_nnf_cnf || (af.m_params.m_mbqi && af.has_quantifiers()); } - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { UNREACHABLE(); } + void operator()() override { af.nnf_cnf(); } + bool should_apply() const override { return af.m_params.m_nnf_cnf || (af.m_params.m_mbqi && af.has_quantifiers()); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { UNREACHABLE(); } }; class propagate_values_fn : public simplify_fmls { public: propagate_values_fn(asserted_formulas& af): simplify_fmls(af, "propagate-values") {} - virtual void operator()() { af.propagate_values(); } - virtual bool should_apply() const { return af.m_params.m_propagate_values; } - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { UNREACHABLE(); } + void operator()() override { af.propagate_values(); } + bool should_apply() const override { return af.m_params.m_propagate_values; } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { UNREACHABLE(); } }; class distribute_forall_fn : public simplify_fmls { distribute_forall m_functor; public: distribute_forall_fn(asserted_formulas& af): simplify_fmls(af, "distribute-forall"), m_functor(af.m) {} - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { m_functor(j.get_fml(), n); } - virtual bool should_apply() const { return af.m_params.m_distribute_forall && af.has_quantifiers(); } - virtual void post_op() { af.reduce_and_solve(); TRACE("asserted_formulas", af.display(tout);); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_functor(j.get_fml(), n); } + bool should_apply() const override { return af.m_params.m_distribute_forall && af.has_quantifiers(); } + void post_op() override { af.reduce_and_solve(); TRACE("asserted_formulas", af.display(tout);); } }; class pattern_inference_fn : public simplify_fmls { pattern_inference_rw m_infer; public: pattern_inference_fn(asserted_formulas& af): simplify_fmls(af, "pattern-inference"), m_infer(af.m, af.m_params) {} - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { m_infer(j.get_fml(), n, p); } - virtual bool should_apply() const { return af.m_params.m_ematching && af.has_quantifiers(); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_infer(j.get_fml(), n, p); } + bool should_apply() const override { return af.m_params.m_ematching && af.has_quantifiers(); } }; class refine_inj_axiom_fn : public simplify_fmls { public: refine_inj_axiom_fn(asserted_formulas& af): simplify_fmls(af, "refine-injectivity") {} - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p); - virtual bool should_apply() const { return af.m_params.m_refine_inj_axiom && af.has_quantifiers(); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override; + bool should_apply() const override { return af.m_params.m_refine_inj_axiom && af.has_quantifiers(); } }; class max_bv_sharing_fn : public simplify_fmls { public: max_bv_sharing_fn(asserted_formulas& af): simplify_fmls(af, "maximizing-bv-sharing") {} - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { af.m_bv_sharing(j.get_fml(), n, p); } - virtual bool should_apply() const { return af.m_params.m_max_bv_sharing; } - virtual void post_op() { af.m_reduce_asserted_formulas(); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { af.m_bv_sharing(j.get_fml(), n, p); } + bool should_apply() const override { return af.m_params.m_max_bv_sharing; } + void post_op() override { af.m_reduce_asserted_formulas(); } }; class elim_term_ite_fn : public simplify_fmls { elim_term_ite_rw m_elim; public: elim_term_ite_fn(asserted_formulas& af): simplify_fmls(af, "elim-term-ite"), m_elim(af.m, af.m_defined_names) {} - virtual void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { m_elim(j.get_fml(), n, p); } - virtual bool should_apply() const { return af.m_params.m_eliminate_term_ite && af.m_params.m_lift_ite != LI_FULL; } - virtual void post_op() { af.m_formulas.append(m_elim.new_defs()); af.reduce_and_solve(); m_elim.reset(); } + void simplify(justified_expr const& j, expr_ref& n, proof_ref& p) override { m_elim(j.get_fml(), n, p); } + bool should_apply() const override { return af.m_params.m_eliminate_term_ite && af.m_params.m_lift_ite != LI_FULL; } + void post_op() override { af.m_formulas.append(m_elim.new_defs()); af.reduce_and_solve(); m_elim.reset(); } }; #define MK_SIMPLIFIERA(NAME, FUNCTOR, MSG, APP, ARG, REDUCE) \ diff --git a/src/smt/dyn_ack.cpp b/src/smt/dyn_ack.cpp index baa8129bb..dd77640bc 100644 --- a/src/smt/dyn_ack.cpp +++ b/src/smt/dyn_ack.cpp @@ -39,12 +39,12 @@ namespace smt { SASSERT(m_app1->get_id() < m_app2->get_id()); } - virtual char const * get_name() const { return "dyn-ack"; } + char const * get_name() const override { return "dyn-ack"; } - virtual void get_antecedents(conflict_resolution & cr) { + void get_antecedents(conflict_resolution & cr) override { } - virtual void display_debug_info(conflict_resolution & cr, std::ostream & out) { + void display_debug_info(conflict_resolution & cr, std::ostream & out) override { ast_manager & m = cr.get_manager(); out << "m_app1:\n" << mk_pp(m_app1, m) << "\n"; out << "m_app2:\n" << mk_pp(m_app2, m) << "\n"; @@ -70,7 +70,7 @@ namespace smt { } } - virtual proof * mk_proof(conflict_resolution & cr) { + proof * mk_proof(conflict_resolution & cr) override { ast_manager & m = cr.get_manager(); context & ctx = cr.get_context(); unsigned num_args = m_app1->get_num_args(); @@ -288,8 +288,8 @@ namespace smt { dyn_ack_clause_del_eh(dyn_ack_manager & m): m_manager(m) { } - virtual ~dyn_ack_clause_del_eh() {} - virtual void operator()(ast_manager & m, clause * cls) { + ~dyn_ack_clause_del_eh() override {} + void operator()(ast_manager & m, clause * cls) override { m_manager.del_clause_eh(cls); dealloc(this); } diff --git a/src/smt/mam.cpp b/src/smt/mam.cpp index c979e476e..7fd1dd9d0 100644 --- a/src/smt/mam.cpp +++ b/src/smt/mam.cpp @@ -2844,7 +2844,7 @@ namespace smt { unsigned m_lbl_id; public: mk_tree_trail(ptr_vector & t, unsigned id):m_trees(t), m_lbl_id(id) {} - virtual void undo(mam_impl & m) { + void undo(mam_impl & m) override { dealloc(m_trees[m_lbl_id]); m_trees[m_lbl_id] = 0; } @@ -3104,7 +3104,7 @@ namespace smt { enode * m_enode; public: add_shared_enode_trail(enode * n):m_enode(n) {} - virtual void undo(mam_impl & m) { m.m_shared_enodes.erase(m_enode); } + void undo(mam_impl & m) override { m.m_shared_enodes.erase(m_enode); } }; #ifdef Z3DEBUG @@ -3819,11 +3819,11 @@ namespace smt { reset_pp_pc(); } - virtual ~mam_impl() { + ~mam_impl() override { m_trail_stack.reset(); } - virtual void add_pattern(quantifier * qa, app * mp) { + void add_pattern(quantifier * qa, app * mp) override { SASSERT(m_ast_manager.is_pattern(mp)); TRACE("trigger_bug", tout << "adding pattern\n" << mk_ismt2_pp(qa, m_ast_manager) << "\n" << mk_ismt2_pp(mp, m_ast_manager) << "\n";); TRACE("mam_bug", tout << "adding pattern\n" << mk_pp(qa, m_ast_manager) << "\n" << mk_pp(mp, m_ast_manager) << "\n";); @@ -3846,11 +3846,11 @@ namespace smt { m_trees.add_pattern(qa, mp, i); } - virtual void push_scope() { + void push_scope() override { m_trail_stack.push_scope(); } - virtual void pop_scope(unsigned num_scopes) { + void pop_scope(unsigned num_scopes) override { if (!m_to_match.empty()) { ptr_vector::iterator it = m_to_match.begin(); ptr_vector::iterator end = m_to_match.end(); @@ -3864,7 +3864,7 @@ namespace smt { m_trail_stack.pop_scope(num_scopes); } - virtual void reset() { + void reset() override { m_trail_stack.reset(); m_trees.reset(); m_to_match.reset(); @@ -3875,7 +3875,7 @@ namespace smt { m_tmp_region.reset(); } - virtual void display(std::ostream& out) { + void display(std::ostream& out) override { out << "mam:\n"; m_lbl_hasher.display(out); ptr_vector::iterator it = m_trees.begin_code_trees(); @@ -3886,7 +3886,7 @@ namespace smt { } } - virtual void match() { + void match() override { TRACE("trigger_bug", tout << "match\n"; display(tout);); ptr_vector::iterator it = m_to_match.begin(); ptr_vector::iterator end = m_to_match.end(); @@ -3903,7 +3903,7 @@ namespace smt { } } - virtual void rematch(bool use_irrelevant) { + void rematch(bool use_irrelevant) override { ptr_vector::iterator it = m_trees.begin_code_trees(); ptr_vector::iterator end = m_trees.end_code_trees(); unsigned lbl = 0; @@ -3932,7 +3932,7 @@ namespace smt { } #endif - virtual void on_match(quantifier * qa, app * pat, unsigned num_bindings, enode * const * bindings, unsigned max_generation, ptr_vector & used_enodes) { + void on_match(quantifier * qa, app * pat, unsigned num_bindings, enode * const * bindings, unsigned max_generation, ptr_vector & used_enodes) override { TRACE("trigger_bug", tout << "found match " << mk_pp(qa, m_ast_manager) << "\n";); #ifdef Z3DEBUG if (m_check_missing_instances) { @@ -3955,13 +3955,13 @@ namespace smt { m_context.add_instance(qa, pat, num_bindings, bindings, max_generation, min_gen, max_gen, used_enodes); } - virtual bool is_shared(enode * n) const { + bool is_shared(enode * n) const override { return !m_shared_enodes.empty() && m_shared_enodes.contains(n); } // This method is invoked when n becomes relevant. // If lazy == true, then n is not added to the list of candidate enodes for matching. That is, the method just updates the lbls. - virtual void relevant_eh(enode * n, bool lazy) { + void relevant_eh(enode * n, bool lazy) override { TRACE("trigger_bug", tout << "relevant_eh:\n" << mk_ismt2_pp(n->get_owner(), m_ast_manager) << "\n"; tout << "mam: " << this << "\n";); TRACE("mam", tout << "relevant_eh: #" << n->get_owner_id() << "\n";); @@ -3984,11 +3984,11 @@ namespace smt { } } - virtual bool has_work() const { + bool has_work() const override { return !m_to_match.empty() || !m_new_patterns.empty(); } - virtual void add_eq_eh(enode * r1, enode * r2) { + void add_eq_eh(enode * r1, enode * r2) override { flet l1(m_r1, r1); flet l2(m_r2, r2); diff --git a/src/smt/proto_model/array_factory.h b/src/smt/proto_model/array_factory.h index 4d4f52944..b59df3f94 100644 --- a/src/smt/proto_model/array_factory.h +++ b/src/smt/proto_model/array_factory.h @@ -32,13 +32,13 @@ class array_factory : public struct_factory { public: array_factory(ast_manager & m, proto_model & md); - virtual ~array_factory() {} + ~array_factory() override {} - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2); + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override; - virtual expr * get_fresh_value(sort * s); + expr * get_fresh_value(sort * s) override; }; #endif /* ARRAY_FACTORY_H_ */ diff --git a/src/smt/proto_model/datatype_factory.h b/src/smt/proto_model/datatype_factory.h index 9f64b8daa..85b264382 100644 --- a/src/smt/proto_model/datatype_factory.h +++ b/src/smt/proto_model/datatype_factory.h @@ -33,9 +33,9 @@ class datatype_factory : public struct_factory { public: datatype_factory(ast_manager & m, proto_model & md); - virtual ~datatype_factory() {} - virtual expr * get_some_value(sort * s); - virtual expr * get_fresh_value(sort * s); + ~datatype_factory() override {} + expr * get_some_value(sort * s) override; + expr * get_fresh_value(sort * s) override; }; #endif /* DATATYPE_FACTORY_H_ */ diff --git a/src/smt/proto_model/numeral_factory.h b/src/smt/proto_model/numeral_factory.h index f1b68223b..198ff0d32 100644 --- a/src/smt/proto_model/numeral_factory.h +++ b/src/smt/proto_model/numeral_factory.h @@ -26,17 +26,17 @@ Revision History: class numeral_factory : public simple_factory { public: numeral_factory(ast_manager & m, family_id fid):simple_factory(m, fid) {} - virtual ~numeral_factory() {} + ~numeral_factory() override {} }; class arith_factory : public numeral_factory { arith_util m_util; - virtual app * mk_value_core(rational const & val, sort * s); + app * mk_value_core(rational const & val, sort * s) override; public: arith_factory(ast_manager & m); - virtual ~arith_factory(); + ~arith_factory() override; app * mk_num_value(rational const & val, bool is_int); }; @@ -44,11 +44,11 @@ public: class bv_factory : public numeral_factory { bv_util m_util; - virtual app * mk_value_core(rational const & val, sort * s); + app * mk_value_core(rational const & val, sort * s) override; public: bv_factory(ast_manager & m); - virtual ~bv_factory(); + ~bv_factory() override; app * mk_num_value(rational const & val, unsigned bv_size); }; diff --git a/src/smt/proto_model/proto_model.h b/src/smt/proto_model/proto_model.h index 05af0091c..d92d459e4 100644 --- a/src/smt/proto_model/proto_model.h +++ b/src/smt/proto_model/proto_model.h @@ -60,7 +60,7 @@ class proto_model : public model_core { public: proto_model(ast_manager & m, params_ref const & p = params_ref()); - virtual ~proto_model() {} + ~proto_model() override {} void register_factory(value_factory * f) { m_factories.register_plugin(f); } @@ -69,7 +69,7 @@ public: value_factory * get_factory(family_id fid); - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2); @@ -93,9 +93,9 @@ public: void freeze_universe(sort * s); bool is_finite(sort * s) const; obj_hashtable const & get_known_universe(sort * s) const; - virtual ptr_vector const & get_universe(sort * s) const; - virtual unsigned get_num_uninterpreted_sorts() const; - virtual sort * get_uninterpreted_sort(unsigned idx) const; + ptr_vector const & get_universe(sort * s) const override; + unsigned get_num_uninterpreted_sorts() const override; + sort * get_uninterpreted_sort(unsigned idx) const override; // // Complete partial function interps diff --git a/src/smt/proto_model/struct_factory.h b/src/smt/proto_model/struct_factory.h index bfbd90ede..9fe54392c 100644 --- a/src/smt/proto_model/struct_factory.h +++ b/src/smt/proto_model/struct_factory.h @@ -43,11 +43,11 @@ protected: public: struct_factory(ast_manager & m, family_id fid, proto_model & md); - virtual ~struct_factory(); + ~struct_factory() override; - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2); + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override; - virtual void register_value(expr * array_value); + void register_value(expr * array_value) override; }; #endif /* STRUCT_FACTORY_H_ */ diff --git a/src/smt/proto_model/value_factory.h b/src/smt/proto_model/value_factory.h index e81c63306..3979a47bb 100644 --- a/src/smt/proto_model/value_factory.h +++ b/src/smt/proto_model/value_factory.h @@ -64,13 +64,13 @@ class basic_factory : public value_factory { public: basic_factory(ast_manager & m); - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2); + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override; - virtual expr * get_fresh_value(sort * s); + expr * get_fresh_value(sort * s) override; - virtual void register_value(expr * n) { } + void register_value(expr * n) override { } }; /** @@ -133,11 +133,11 @@ public: m_sorts(m) { } - virtual ~simple_factory() { + ~simple_factory() override { std::for_each(m_sets.begin(), m_sets.end(), delete_proc()); } - virtual expr * get_some_value(sort * s) { + expr * get_some_value(sort * s) override { value_set * set = 0; expr * result = 0; if (m_sort2value_set.find(s, set) && !set->m_values.empty()) @@ -147,7 +147,7 @@ public: return result; } - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override { value_set * set = 0; if (m_sort2value_set.find(s, set)) { switch (set->m_values.size()) { @@ -176,7 +176,7 @@ public: return true; } - virtual expr * get_fresh_value(sort * s) { + expr * get_fresh_value(sort * s) override { value_set * set = get_value_set(s); bool is_new = false; expr * result = 0; @@ -202,7 +202,7 @@ public: return result; } - virtual void register_value(expr * n) { + void register_value(expr * n) override { sort * s = this->m_manager.get_sort(n); value_set * set = get_value_set(s); if (!set->m_values.contains(n)) { @@ -228,10 +228,10 @@ public: class user_sort_factory : public simple_factory { obj_hashtable m_finite; //!< set of sorts that are marked as finite. obj_hashtable m_empty_universe; - virtual app * mk_value_core(unsigned const & val, sort * s); + app * mk_value_core(unsigned const & val, sort * s) override; public: user_sort_factory(ast_manager & m); - virtual ~user_sort_factory() {} + ~user_sort_factory() override {} /** \brief Make the universe of \c s finite, by preventing new @@ -257,13 +257,13 @@ public: */ obj_hashtable const & get_finite_sorts() const { return m_finite; } - virtual expr * get_some_value(sort * s); + expr * get_some_value(sort * s) override; - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2); + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override; - virtual expr * get_fresh_value(sort * s); + expr * get_fresh_value(sort * s) override; - virtual void register_value(expr * n); + void register_value(expr * n) override; }; #endif /* VALUE_FACTORY_H_ */ diff --git a/src/smt/smt2_extra_cmds.cpp b/src/smt/smt2_extra_cmds.cpp index 136805e43..238295a49 100644 --- a/src/smt/smt2_extra_cmds.cpp +++ b/src/smt/smt2_extra_cmds.cpp @@ -24,22 +24,22 @@ class include_cmd : public cmd { char const * m_filename; public: include_cmd() : cmd("include"), m_filename(0) {} - virtual char const * get_usage() const { return ""; } - virtual char const * get_descr(cmd_context & ctx) const { return "include a file"; } - virtual unsigned get_arity() const { return 1; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { return CPK_STRING; } - virtual void set_next_arg(cmd_context & ctx, char const * val) { m_filename = val; } - virtual void failure_cleanup(cmd_context & ctx) {} - virtual void execute(cmd_context & ctx) { + char const * get_usage() const override { return ""; } + char const * get_descr(cmd_context & ctx) const override { return "include a file"; } + unsigned get_arity() const override { return 1; } + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_STRING; } + void set_next_arg(cmd_context & ctx, char const * val) override { m_filename = val; } + void failure_cleanup(cmd_context & ctx) override {} + void execute(cmd_context & ctx) override { std::ifstream is(m_filename); if (is.bad() || is.fail()) throw cmd_exception(std::string("failed to open file '") + m_filename + "'"); parse_smt2_commands(ctx, is, false, params_ref(), m_filename); is.close(); } - virtual void prepare(cmd_context & ctx) { reset(ctx); } - virtual void reset(cmd_context & ctx) { m_filename = 0; } - virtual void finalize(cmd_context & ctx) { reset(ctx); } + void prepare(cmd_context & ctx) override { reset(ctx); } + void reset(cmd_context & ctx) override { m_filename = 0; } + void finalize(cmd_context & ctx) override { reset(ctx); } }; void install_smt2_extra_cmds(cmd_context & ctx) { diff --git a/src/smt/smt_case_split_queue.cpp b/src/smt/smt_case_split_queue.cpp index 6aef5f0a9..3da6ce295 100644 --- a/src/smt/smt_case_split_queue.cpp +++ b/src/smt/smt_case_split_queue.cpp @@ -75,42 +75,42 @@ namespace smt { m_queue(1024, bool_var_act_lt(ctx.get_activity_vector())) { } - virtual void activity_increased_eh(bool_var v) { + void activity_increased_eh(bool_var v) override { if (m_queue.contains(v)) m_queue.decreased(v); } - virtual void mk_var_eh(bool_var v) { + void mk_var_eh(bool_var v) override { m_queue.reserve(v+1); SASSERT(!m_queue.contains(v)); m_queue.insert(v); } - virtual void del_var_eh(bool_var v) { + void del_var_eh(bool_var v) override { if (m_queue.contains(v)) m_queue.erase(v); } - virtual void unassign_var_eh(bool_var v) { + void unassign_var_eh(bool_var v) override { if (!m_queue.contains(v)) m_queue.insert(v); } - virtual void relevant_eh(expr * n) {} + void relevant_eh(expr * n) override {} - virtual void init_search_eh() {} + void init_search_eh() override {} - virtual void end_search_eh() {} + void end_search_eh() override {} - virtual void reset() { + void reset() override { m_queue.reset(); } - virtual void push_scope() {} + void push_scope() override {} - virtual void pop_scope(unsigned num_scopes) {} + void pop_scope(unsigned num_scopes) override {} - virtual void next_case_split(bool_var & next, lbool & phase) { + void next_case_split(bool_var & next, lbool & phase) override { phase = l_undef; if (m_context.get_random_value() < static_cast(m_params.m_random_var_freq * random_gen::max_value())) { @@ -129,7 +129,7 @@ namespace smt { next = null_bool_var; } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { bool first = true; for (unsigned v : m_queue) { if (m_context.get_assignment(v) == l_undef) { @@ -144,7 +144,7 @@ namespace smt { out << "\n"; } - virtual ~act_case_split_queue() {}; + ~act_case_split_queue() override {}; }; /** @@ -159,7 +159,7 @@ namespace smt { m_delayed_queue(1024, bool_var_act_lt(ctx.get_activity_vector())) { } - virtual void activity_increased_eh(bool_var v) { + void activity_increased_eh(bool_var v) override { act_case_split_queue::activity_increased_eh(v); if (m_queue.contains(v)) m_queue.decreased(v); @@ -167,7 +167,7 @@ namespace smt { m_delayed_queue.decreased(v); } - virtual void mk_var_eh(bool_var v) { + void mk_var_eh(bool_var v) override { m_queue.reserve(v+1); m_delayed_queue.reserve(v+1); SASSERT(!m_delayed_queue.contains(v)); @@ -178,28 +178,28 @@ namespace smt { m_queue.insert(v); } - virtual void del_var_eh(bool_var v) { + void del_var_eh(bool_var v) override { act_case_split_queue::del_var_eh(v); if (m_delayed_queue.contains(v)) m_delayed_queue.erase(v); } - virtual void relevant_eh(expr * n) {} + void relevant_eh(expr * n) override {} - virtual void init_search_eh() {} + void init_search_eh() override {} - virtual void end_search_eh() {} + void end_search_eh() override {} - virtual void reset() { + void reset() override { act_case_split_queue::reset(); m_delayed_queue.reset(); } - virtual void push_scope() {} + void push_scope() override {} - virtual void pop_scope(unsigned num_scopes) {} + void pop_scope(unsigned num_scopes) override {} - virtual void next_case_split(bool_var & next, lbool & phase) { + void next_case_split(bool_var & next, lbool & phase) override { act_case_split_queue::next_case_split(next, phase); if (next != null_bool_var) return; @@ -229,7 +229,7 @@ namespace smt { m_cache_domain(ctx.get_manager()) { } - virtual void mk_var_eh(bool_var v) { + void mk_var_eh(bool_var v) override { expr * n = m_context.bool_var2expr(v); double act; if (m_cache.find(n, act)) @@ -237,7 +237,7 @@ namespace smt { act_case_split_queue::mk_var_eh(v); } - virtual void del_var_eh(bool_var v) { + void del_var_eh(bool_var v) override { if (m_context.is_searching()) { double act = m_context.get_activity(v); if (act > 0.0) { @@ -249,14 +249,14 @@ namespace smt { act_case_split_queue::del_var_eh(v); } - virtual void init_search_eh() { + void init_search_eh() override { m_cache.reset(); m_cache_domain.reset(); } - virtual void end_search_eh() {} + void end_search_eh() override {} - virtual void reset() { + void reset() override { init_search_eh(); } }; @@ -322,15 +322,15 @@ namespace smt { m_head2(0) { } - virtual void activity_increased_eh(bool_var v) {} + void activity_increased_eh(bool_var v) override {} - virtual void mk_var_eh(bool_var v) {} + void mk_var_eh(bool_var v) override {} - virtual void del_var_eh(bool_var v) {} + void del_var_eh(bool_var v) override {} - virtual void unassign_var_eh(bool_var v) {} + void unassign_var_eh(bool_var v) override {} - virtual void relevant_eh(expr * n) { + void relevant_eh(expr * n) override { if (!m_manager.is_bool(n)) return; bool is_or = m_manager.is_or(n); @@ -361,15 +361,15 @@ namespace smt { m_queue2.push_back(n); } - virtual void init_search_eh() { + void init_search_eh() override { m_bs_num_bool_vars = m_context.get_num_bool_vars(); } - virtual void end_search_eh() { + void end_search_eh() override { m_bs_num_bool_vars = UINT_MAX; } - virtual void reset() { + void reset() override { m_queue.reset(); m_head = 0; m_queue2.reset(); @@ -377,7 +377,7 @@ namespace smt { m_scopes.reset(); } - virtual void push_scope() { + void push_scope() override { m_scopes.push_back(scope()); scope & s = m_scopes.back(); s.m_queue_trail = m_queue.size(); @@ -387,7 +387,7 @@ namespace smt { TRACE("case_split", tout << "head: " << m_head << "\n";); } - virtual void pop_scope(unsigned num_scopes) { + void pop_scope(unsigned num_scopes) override { SASSERT(num_scopes <= m_scopes.size()); unsigned new_lvl = m_scopes.size() - num_scopes; scope & s = m_scopes[new_lvl]; @@ -443,7 +443,7 @@ namespace smt { next = null_bool_var; } - virtual void next_case_split(bool_var & next, lbool & phase) { + void next_case_split(bool_var & next, lbool & phase) override { next_case_split_core(m_queue, m_head, next, phase); if (next == null_bool_var) next_case_split_core(m_queue2, m_head2, next, phase); @@ -471,7 +471,7 @@ namespace smt { out << "\n"; } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { if (m_queue.empty() && m_queue2.empty()) return; out << "case-splits:\n"; @@ -507,9 +507,9 @@ namespace smt { m_delayed_queue(1024, bool_var_act_lt(ctx.get_activity_vector())) { } - virtual void activity_increased_eh(bool_var v) {} + void activity_increased_eh(bool_var v) override {} - virtual void mk_var_eh(bool_var v) { + void mk_var_eh(bool_var v) override { if (m_context.is_searching()) { SASSERT(v >= m_bs_num_bool_vars); m_delayed_queue.reserve(v+1); @@ -517,19 +517,19 @@ namespace smt { } } - virtual void del_var_eh(bool_var v) { + void del_var_eh(bool_var v) override { if (v >= m_bs_num_bool_vars && m_delayed_queue.contains(v)) m_delayed_queue.erase(v); } - virtual void unassign_var_eh(bool_var v) { + void unassign_var_eh(bool_var v) override { if (v < m_bs_num_bool_vars) return; if (!m_delayed_queue.contains(v)) m_delayed_queue.insert(v); } - virtual void relevant_eh(expr * n) { + void relevant_eh(expr * n) override { if (!m_manager.is_bool(n)) return; bool is_or = m_manager.is_or(n); @@ -558,22 +558,22 @@ namespace smt { m_queue.push_back(n); } - virtual void init_search_eh() { + void init_search_eh() override { m_bs_num_bool_vars = m_context.get_num_bool_vars(); } - virtual void end_search_eh() { + void end_search_eh() override { m_bs_num_bool_vars = UINT_MAX; } - virtual void reset() { + void reset() override { m_queue.reset(); m_head = 0; m_delayed_queue.reset(); m_scopes.reset(); } - virtual void push_scope() { + void push_scope() override { m_scopes.push_back(scope()); scope & s = m_scopes.back(); s.m_queue_trail = m_queue.size(); @@ -581,7 +581,7 @@ namespace smt { TRACE("case_split", tout << "head: " << m_head << "\n";); } - virtual void pop_scope(unsigned num_scopes) { + void pop_scope(unsigned num_scopes) override { SASSERT(num_scopes <= m_scopes.size()); unsigned new_lvl = m_scopes.size() - num_scopes; scope & s = m_scopes[new_lvl]; @@ -632,7 +632,7 @@ namespace smt { next = null_bool_var; } - virtual void next_case_split(bool_var & next, lbool & phase) { + void next_case_split(bool_var & next, lbool & phase) override { if (m_context.get_random_value() < static_cast(0.02 * random_gen::max_value())) { next = m_context.get_random_value() % m_context.get_num_b_internalized(); TRACE("random_split", tout << "next: " << next << " get_assignment(next): " << m_context.get_assignment(next) << "\n";); @@ -664,7 +664,7 @@ namespace smt { out << "\n"; } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { if (m_queue.empty()) return; out << "case-splits:\n"; @@ -751,15 +751,15 @@ namespace smt { set_global_generation(); } - virtual void activity_increased_eh(bool_var v) {} + void activity_increased_eh(bool_var v) override {} - virtual void mk_var_eh(bool_var v) {} + void mk_var_eh(bool_var v) override {} - virtual void del_var_eh(bool_var v) {} + void del_var_eh(bool_var v) override {} - virtual void unassign_var_eh(bool_var v) {} + void unassign_var_eh(bool_var v) override {} - virtual void relevant_eh(expr * n) { + void relevant_eh(expr * n) override { if (get_generation(n) == 0 && m_current_generation != 0) set_generation_rec(n, m_current_generation); @@ -793,21 +793,21 @@ namespace smt { add_to_queue2(n); } - virtual void internalize_instance_eh(expr * e, unsigned gen) + void internalize_instance_eh(expr * e, unsigned gen) override { //lower_generation(e, gen); } - virtual void init_search_eh() { + void init_search_eh() override { m_bs_num_bool_vars = m_context.get_num_bool_vars(); set_global_generation(); } - virtual void end_search_eh() { + void end_search_eh() override { m_bs_num_bool_vars = UINT_MAX; } - virtual void reset() { + void reset() override { m_queue.reset(); m_head = 0; m_queue2.reset(); @@ -816,7 +816,7 @@ namespace smt { set_global_generation(); } - virtual void push_scope() { + void push_scope() override { m_scopes.push_back(scope()); scope & s = m_scopes.back(); s.m_queue_trail = m_queue.size(); @@ -827,7 +827,7 @@ namespace smt { TRACE("case_split", tout << "head: " << m_head << "\n";); } - virtual void pop_scope(unsigned num_scopes) { + void pop_scope(unsigned num_scopes) override { SASSERT(num_scopes <= m_scopes.size()); unsigned new_lvl = m_scopes.size() - num_scopes; scope & s = m_scopes[new_lvl]; @@ -898,7 +898,7 @@ namespace smt { next = null_bool_var; } - virtual void next_case_split(bool_var & next, lbool & phase) { + void next_case_split(bool_var & next, lbool & phase) override { phase = l_undef; next = null_bool_var; @@ -943,7 +943,7 @@ namespace smt { out << "\n"; } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { if (m_queue.empty() && m_queue2.empty()) return; out << "case-splits:\n"; @@ -951,7 +951,7 @@ namespace smt { //display_core(out, m_queue2, m_head2, 2); } - virtual void assign_lit_eh(literal l) { + void assign_lit_eh(literal l) override { // if (m_current_generation > stop_gen) // m_current_generation--; @@ -1128,41 +1128,41 @@ namespace smt { m_queue(1024, theory_aware_act_lt(ctx.get_activity_vector(), m_theory_var_priority)) { } - virtual void activity_increased_eh(bool_var v) { + void activity_increased_eh(bool_var v) override { if (m_queue.contains(v)) m_queue.decreased(v); } - virtual void mk_var_eh(bool_var v) { + void mk_var_eh(bool_var v) override { m_queue.reserve(v+1); m_queue.insert(v); } - virtual void del_var_eh(bool_var v) { + void del_var_eh(bool_var v) override { if (m_queue.contains(v)) m_queue.erase(v); } - virtual void unassign_var_eh(bool_var v) { + void unassign_var_eh(bool_var v) override { if (!m_queue.contains(v)) m_queue.insert(v); } - virtual void relevant_eh(expr * n) {} + void relevant_eh(expr * n) override {} - virtual void init_search_eh() {} + void init_search_eh() override {} - virtual void end_search_eh() {} + void end_search_eh() override {} - virtual void reset() { + void reset() override { m_queue.reset(); } - virtual void push_scope() {} + void push_scope() override {} - virtual void pop_scope(unsigned num_scopes) {} + void pop_scope(unsigned num_scopes) override {} - virtual void next_case_split(bool_var & next, lbool & phase) { + void next_case_split(bool_var & next, lbool & phase) override { int threshold = static_cast(m_params.m_random_var_freq * random_gen::max_value()); SASSERT(threshold >= 0); if (m_context.get_random_value() < threshold) { @@ -1187,7 +1187,7 @@ namespace smt { } } - virtual void add_theory_aware_branching_info(bool_var v, double priority, lbool phase) { + void add_theory_aware_branching_info(bool_var v, double priority, lbool phase) override { TRACE("theory_aware_branching", tout << "Add theory-aware branching information for l#" << v << ": priority=" << priority << std::endl;); m_theory_vars.insert(v); m_theory_var_phase.insert(v, phase); @@ -1203,7 +1203,7 @@ namespace smt { // m_theory_queue.insert(v); } - virtual void display(std::ostream & out) { + void display(std::ostream & out) override { bool first = true; bool_var_act_queue::const_iterator it = m_queue.begin(); bool_var_act_queue::const_iterator end = m_queue.end(); @@ -1222,7 +1222,7 @@ namespace smt { } - virtual ~theory_aware_branching_queue() {}; + ~theory_aware_branching_queue() override {}; }; diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 375ff7e6f..0f09f1f59 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -476,7 +476,7 @@ namespace smt { m_r2_num_parents(r2_num_parents) { } - virtual void undo(context & ctx) { + void undo(context & ctx) override { ctx.undo_add_eq(m_r1, m_n1, m_r2_num_parents); } }; @@ -1451,7 +1451,7 @@ namespace smt { bool_var m_var; public: set_var_theory_trail(bool_var v):m_var(v) {} - virtual void undo(context & ctx) { + void undo(context & ctx) override { bool_var_data & d = ctx.m_bdata[m_var]; d.reset_notify_theory(); } @@ -2951,7 +2951,7 @@ namespace smt { case_split_insert_trail(literal l): l(l) { } - virtual void undo(context & ctx) { + void undo(context & ctx) override { ctx.undo_th_case_split(l); } }; @@ -4131,7 +4131,7 @@ namespace smt { bool_var m_var; public: set_true_first_trail(bool_var v):m_var(v) {} - virtual void undo(context & ctx) { + void undo(context & ctx) override { ctx.m_bdata[m_var].reset_true_first_flag(); } }; diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index 55d8f03f2..3cd93fbe5 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -746,7 +746,7 @@ namespace smt { friend class mk_bool_var_trail; class mk_bool_var_trail : public trail { public: - virtual void undo(context & ctx) { ctx.undo_mk_bool_var(); } + void undo(context & ctx) override { ctx.undo_mk_bool_var(); } }; mk_bool_var_trail m_mk_bool_var_trail; @@ -755,7 +755,7 @@ namespace smt { friend class mk_enode_trail; class mk_enode_trail : public trail { public: - virtual void undo(context & ctx) { ctx.undo_mk_enode(); } + void undo(context & ctx) override { ctx.undo_mk_enode(); } }; mk_enode_trail m_mk_enode_trail; diff --git a/src/smt/smt_for_each_relevant_expr.h b/src/smt/smt_for_each_relevant_expr.h index b81023349..3626e37c7 100644 --- a/src/smt/smt_for_each_relevant_expr.h +++ b/src/smt/smt_for_each_relevant_expr.h @@ -93,8 +93,8 @@ namespace smt { for_each_relevant_expr(ctx), m_buffer(b) { } - virtual ~collect_relevant_label_lits() {} - virtual void operator()(expr * n); + ~collect_relevant_label_lits() override {} + void operator()(expr * n) override; }; class collect_relevant_labels : public for_each_relevant_expr { @@ -104,8 +104,8 @@ namespace smt { for_each_relevant_expr(ctx), m_buffer(b) { } - virtual ~collect_relevant_labels() {} - virtual void operator()(expr * n); + ~collect_relevant_labels() override {} + void operator()(expr * n) override; }; }; diff --git a/src/smt/smt_internalizer.cpp b/src/smt/smt_internalizer.cpp index c38ef4e4a..3c92b8318 100644 --- a/src/smt/smt_internalizer.cpp +++ b/src/smt/smt_internalizer.cpp @@ -631,7 +631,7 @@ namespace smt { set_merge_tf_trail(enode * n): m_node(n) { } - virtual void undo(context & ctx) { + void undo(context & ctx) override { m_node->m_merge_tf = false; } }; @@ -667,7 +667,7 @@ namespace smt { set_enode_flag_trail(bool_var v): m_var(v) { } - virtual void undo(context & ctx) { + void undo(context & ctx) override { bool_var_data & data = ctx.m_bdata[m_var]; data.reset_enode_flag(); } @@ -1612,7 +1612,7 @@ namespace smt { SASSERT(m_th_var != null_theory_var); } - virtual void undo(context & ctx) { + void undo(context & ctx) override { theory_var v = m_enode->get_th_var(m_th_id); SASSERT(v != null_theory_var); SASSERT(m_th_var == v); @@ -1637,7 +1637,7 @@ namespace smt { m_old_th_var(old_var) { } - virtual void undo(context & ctx) { + void undo(context & ctx) override { SASSERT(m_enode->get_th_var(m_th_id) != null_theory_var); m_enode->replace_th_var(m_old_th_var, m_th_id); } diff --git a/src/smt/smt_justification.h b/src/smt/smt_justification.h index 0af8e61ff..1b5aecfe5 100644 --- a/src/smt/smt_justification.h +++ b/src/smt/smt_justification.h @@ -102,15 +102,15 @@ namespace smt { public: justification_proof_wrapper(context & ctx, proof * pr, bool in_region = true); - virtual bool has_del_eh() const { + bool has_del_eh() const override { return true; } - virtual void del_eh(ast_manager & m); + void del_eh(ast_manager & m) override; - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "proof-wrapper"; } + char const * get_name() const override { return "proof-wrapper"; } }; class unit_resolution_justification : public justification { @@ -122,21 +122,21 @@ namespace smt { unit_resolution_justification(justification * js, unsigned num_lits, literal const * lits); - ~unit_resolution_justification(); + ~unit_resolution_justification() override; - virtual bool has_del_eh() const { + bool has_del_eh() const override { return !in_region() && m_antecedent && m_antecedent->has_del_eh(); } - virtual void del_eh(ast_manager & m) { + void del_eh(ast_manager & m) override { if (!in_region() && m_antecedent) m_antecedent->del_eh(m); } - virtual void get_antecedents(conflict_resolution & cr); + void get_antecedents(conflict_resolution & cr) override; - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "unit-resolution"; } + char const * get_name() const override { return "unit-resolution"; } }; class eq_conflict_justification : public justification { @@ -150,11 +150,11 @@ namespace smt { m_js(js) { } - virtual void get_antecedents(conflict_resolution & cr); + void get_antecedents(conflict_resolution & cr) override; - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "eq-conflict"; } + char const * get_name() const override { return "eq-conflict"; } }; /** @@ -166,11 +166,11 @@ namespace smt { eq_root_propagation_justification(enode * n):m_node(n) { } - virtual void get_antecedents(conflict_resolution & cr); + void get_antecedents(conflict_resolution & cr) override; - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "eq-root"; } + char const * get_name() const override { return "eq-root"; } }; /** @@ -184,11 +184,11 @@ namespace smt { SASSERT(n1 != n2); } - virtual void get_antecedents(conflict_resolution & cr); + void get_antecedents(conflict_resolution & cr) override; - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "eq-propagation"; } + char const * get_name() const override { return "eq-propagation"; } }; /** @@ -201,11 +201,11 @@ namespace smt { mp_iff_justification(enode * n1, enode * n2):m_node1(n1), m_node2(n2) { } - virtual void get_antecedents(conflict_resolution & cr); + void get_antecedents(conflict_resolution & cr) override; - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "mp-iff"; } + char const * get_name() const override { return "mp-iff"; } }; /** @@ -221,11 +221,11 @@ namespace smt { public: simple_justification(region & r, unsigned num_lits, literal const * lits); - virtual void get_antecedents(conflict_resolution & cr); + void get_antecedents(conflict_resolution & cr) override; - virtual proof * mk_proof(conflict_resolution & cr) = 0; + proof * mk_proof(conflict_resolution & cr) override = 0; - virtual char const * get_name() const { return "simple"; } + char const * get_name() const override { return "simple"; } }; @@ -240,13 +240,13 @@ namespace smt { unsigned num_params, parameter* params): simple_justification(r, num_lits, lits), m_th_id(fid), m_params(num_params, params) {} - virtual ~simple_theory_justification() {} + ~simple_theory_justification() override {} - virtual bool has_del_eh() const { return !m_params.empty(); } + bool has_del_eh() const override { return !m_params.empty(); } - virtual void del_eh(ast_manager & m) { m_params.reset(); } + void del_eh(ast_manager & m) override { m_params.reset(); } - virtual theory_id get_from_theory() const { return m_th_id; } + theory_id get_from_theory() const override { return m_th_id; } }; @@ -258,11 +258,11 @@ namespace smt { unsigned num_params = 0, parameter* params = 0): simple_theory_justification(fid, r, num_lits, lits, num_params, params) {} - virtual void get_antecedents(conflict_resolution & cr) {} + void get_antecedents(conflict_resolution & cr) override {} - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "theory-axiom"; } + char const * get_name() const override { return "theory-axiom"; } }; class theory_propagation_justification : public simple_theory_justification { @@ -272,10 +272,10 @@ namespace smt { unsigned num_params = 0, parameter* params = 0): simple_theory_justification(fid, r, num_lits, lits, num_params, params), m_consequent(consequent) {} - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "theory-propagation"; } + char const * get_name() const override { return "theory-propagation"; } }; @@ -285,9 +285,9 @@ namespace smt { unsigned num_params = 0, parameter* params = 0): simple_theory_justification(fid, r, num_lits, lits, num_params, params) {} - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "theory-conflict"; } + char const * get_name() const override { return "theory-conflict"; } }; /** @@ -304,11 +304,11 @@ namespace smt { ext_simple_justification(region & r, unsigned num_lits, literal const * lits, unsigned num_eqs, enode_pair const * eqs); - virtual void get_antecedents(conflict_resolution & cr); + void get_antecedents(conflict_resolution & cr) override; - virtual proof * mk_proof(conflict_resolution & cr) = 0; + proof * mk_proof(conflict_resolution & cr) override = 0; - virtual char const * get_name() const { return "ext-simple"; } + char const * get_name() const override { return "ext-simple"; } }; /** @@ -325,13 +325,13 @@ namespace smt { unsigned num_params = 0, parameter* params = 0): ext_simple_justification(r, num_lits, lits, num_eqs, eqs), m_th_id(fid), m_params(num_params, params) {} - virtual ~ext_theory_simple_justification() {} + ~ext_theory_simple_justification() override {} - virtual bool has_del_eh() const { return !m_params.empty(); } + bool has_del_eh() const override { return !m_params.empty(); } - virtual void del_eh(ast_manager & m) { m_params.reset(); } + void del_eh(ast_manager & m) override { m_params.reset(); } - virtual theory_id get_from_theory() const { return m_th_id; } + theory_id get_from_theory() const override { return m_th_id; } }; class ext_theory_propagation_justification : public ext_theory_simple_justification { @@ -345,9 +345,9 @@ namespace smt { ext_theory_simple_justification(fid, r, num_lits, lits, num_eqs, eqs, num_params, params), m_consequent(consequent) {} - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "ext-theory-propagation"; } + char const * get_name() const override { return "ext-theory-propagation"; } }; class ext_theory_conflict_justification : public ext_theory_simple_justification { @@ -357,9 +357,9 @@ namespace smt { unsigned num_params = 0, parameter* params = 0): ext_theory_simple_justification(fid, r, num_lits, lits, num_eqs, eqs, num_params, params) {} - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "ext-theory-conflict"; } + char const * get_name() const override { return "ext-theory-conflict"; } }; class ext_theory_eq_propagation_justification : public ext_theory_simple_justification { @@ -374,9 +374,9 @@ namespace smt { unsigned num_params = 0, parameter* params = 0): ext_theory_simple_justification(fid, r, num_lits, lits, num_eqs, eqs, num_params, params), m_lhs(lhs), m_rhs(rhs) {} - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "ext-theory-eq-propagation"; } + char const * get_name() const override { return "ext-theory-eq-propagation"; } }; /** @@ -394,19 +394,19 @@ namespace smt { theory_lemma_justification(family_id fid, context & ctx, unsigned num_lits, literal const * lits, unsigned num_params = 0, parameter* params = 0); - virtual ~theory_lemma_justification(); + ~theory_lemma_justification() override; - virtual bool has_del_eh() const { + bool has_del_eh() const override { return true; } - virtual void del_eh(ast_manager & m); + void del_eh(ast_manager & m) override; - virtual void get_antecedents(conflict_resolution & cr) {} + void get_antecedents(conflict_resolution & cr) override {} - virtual proof * mk_proof(conflict_resolution & cr); + proof * mk_proof(conflict_resolution & cr) override; - virtual char const * get_name() const { return "theory-lemma"; } + char const * get_name() const override { return "theory-lemma"; } }; }; diff --git a/src/smt/smt_model_finder.cpp b/src/smt/smt_model_finder.cpp index f443d671b..447705572 100644 --- a/src/smt/smt_model_finder.cpp +++ b/src/smt/smt_model_finder.cpp @@ -566,7 +566,7 @@ namespace smt { } } - virtual expr * eval(expr * n, bool model_completion) { + expr * eval(expr * n, bool model_completion) override { expr * r = 0; if (m_eval_cache[model_completion].find(n, r)) { return r; @@ -1134,24 +1134,24 @@ namespace smt { unsigned m_var_j; public: f_var(func_decl * f, unsigned i, unsigned j):m_f(f), m_arg_i(i), m_var_j(j) {} - virtual ~f_var() {} + ~f_var() override {} - virtual char const * get_kind() const { + char const * get_kind() const override { return "f_var"; } - virtual bool is_equal(qinfo const * qi) const { + bool is_equal(qinfo const * qi) const override { if (qi->get_kind() != get_kind()) return false; f_var const * other = static_cast(qi); return m_f == other->m_f && m_arg_i == other->m_arg_i && m_var_j == other->m_var_j; } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { out << "(" << m_f->get_name() << ":" << m_arg_i << " -> v!" << m_var_j << ")"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { node * n1 = s.get_A_f_i(m_f, m_arg_i); node * n2 = s.get_uvar(q, m_var_j); CTRACE("model_finder", n1->get_sort() != n2->get_sort(), @@ -1170,7 +1170,7 @@ namespace smt { n1->merge(n2); } - virtual void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) { + void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) override { node * A_f_i = s.get_A_f_i(m_f, m_arg_i); enode_vector::const_iterator it = ctx->begin_enodes_of(m_f); enode_vector::const_iterator end = ctx->end_enodes_of(m_f); @@ -1193,7 +1193,7 @@ namespace smt { } } - virtual void populate_inst_sets(quantifier * q, func_decl * mhead, ptr_vector & uvar_inst_sets, context * ctx) { + void populate_inst_sets(quantifier * q, func_decl * mhead, ptr_vector & uvar_inst_sets, context * ctx) override { if (m_f != mhead) return; uvar_inst_sets.reserve(m_var_j+1, 0); @@ -1222,31 +1222,31 @@ namespace smt { f_var(f, i, j), m_offset(offset, m) { } - virtual ~f_var_plus_offset() {} + ~f_var_plus_offset() override {} - virtual char const * get_kind() const { + char const * get_kind() const override { return "f_var_plus_offset"; } - virtual bool is_equal(qinfo const * qi) const { + bool is_equal(qinfo const * qi) const override { if (qi->get_kind() != get_kind()) return false; f_var_plus_offset const * other = static_cast(qi); return m_f == other->m_f && m_arg_i == other->m_arg_i && m_var_j == other->m_var_j && m_offset.get() == other->m_offset.get(); } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { out << "(" << m_f->get_name() << ":" << m_arg_i << " - " << mk_bounded_pp(m_offset.get(), m_offset.get_manager()) << " -> v!" << m_var_j << ")"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { // just create the nodes /* node * A_f_i = */ s.get_A_f_i(m_f, m_arg_i); /* node * S_j = */ s.get_uvar(q, m_var_j); } - virtual void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) { + void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) override { // S_j is not necessary equal to A_f_i. node * A_f_i = s.get_A_f_i(m_f, m_arg_i)->get_root(); node * S_j = s.get_uvar(q, m_var_j)->get_root(); @@ -1318,7 +1318,7 @@ namespace smt { } } - virtual void populate_inst_sets2(quantifier * q, auf_solver & s, context * ctx) { + void populate_inst_sets2(quantifier * q, auf_solver & s, context * ctx) override { node * A_f_i = s.get_A_f_i(m_f, m_arg_i)->get_root(); node * S_j = s.get_uvar(q, m_var_j)->get_root(); // If A_f_i == S_j, then there is no finite fixpoint, so we do nothing here. @@ -1331,7 +1331,7 @@ namespace smt { } } - virtual void populate_inst_sets(quantifier * q, func_decl * mhead, ptr_vector & uvar_inst_sets, context * ctx) { + void populate_inst_sets(quantifier * q, func_decl * mhead, ptr_vector & uvar_inst_sets, context * ctx) override { // ignored when in macro } @@ -1391,24 +1391,24 @@ namespace smt { public: select_var(ast_manager & m, app * s, unsigned i, unsigned j):m_manager(m), m_array(m), m_select(s), m_arg_i(i), m_var_j(j) {} - virtual ~select_var() {} + ~select_var() override {} - virtual char const * get_kind() const { + char const * get_kind() const override { return "select_var"; } - virtual bool is_equal(qinfo const * qi) const { + bool is_equal(qinfo const * qi) const override { if (qi->get_kind() != get_kind()) return false; select_var const * other = static_cast(qi); return m_select == other->m_select && m_arg_i == other->m_arg_i && m_var_j == other->m_var_j; } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { out << "(" << mk_bounded_pp(m_select, m_manager) << ":" << m_arg_i << " -> v!" << m_var_j << ")"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { ptr_buffer arrays; get_auf_arrays(get_array(), ctx, arrays); TRACE("select_var", @@ -1428,7 +1428,7 @@ namespace smt { } } - virtual void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) { + void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) override { ptr_buffer arrays; get_auf_arrays(get_array(), ctx, arrays); for (enode * curr : arrays) { @@ -1461,20 +1461,20 @@ namespace smt { std::swap(m_var_i, m_var_j); } - virtual ~var_pair() {} + ~var_pair() override {} - virtual bool is_equal(qinfo const * qi) const { + bool is_equal(qinfo const * qi) const override { if (qi->get_kind() != get_kind()) return false; var_pair const * other = static_cast(qi); return m_var_i == other->m_var_i && m_var_j == other->m_var_j; } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { out << "(" << get_kind() << ":v!" << m_var_i << ":v!" << m_var_j << ")"; } - virtual void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) { + void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) override { // do nothing } }; @@ -1482,9 +1482,9 @@ namespace smt { class x_eq_y : public var_pair { public: x_eq_y(unsigned i, unsigned j):var_pair(i, j) {} - virtual char const * get_kind() const { return "x_eq_y"; } + char const * get_kind() const override { return "x_eq_y"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { node * n1 = s.get_uvar(q, m_var_i); node * n2 = s.get_uvar(q, m_var_j); n1->insert_avoid(n2); @@ -1496,9 +1496,9 @@ namespace smt { class x_neq_y : public var_pair { public: x_neq_y(unsigned i, unsigned j):var_pair(i, j) {} - virtual char const * get_kind() const { return "x_neq_y"; } + char const * get_kind() const override { return "x_neq_y"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { node * n1 = s.get_uvar(q, m_var_i); node * n2 = s.get_uvar(q, m_var_j); n1->merge(n2); @@ -1508,9 +1508,9 @@ namespace smt { class x_leq_y : public var_pair { public: x_leq_y(unsigned i, unsigned j):var_pair(i, j) {} - virtual char const * get_kind() const { return "x_leq_y"; } + char const * get_kind() const override { return "x_leq_y"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { node * n1 = s.get_uvar(q, m_var_i); node * n2 = s.get_uvar(q, m_var_j); n1->merge(n2); @@ -1522,9 +1522,9 @@ namespace smt { class x_sleq_y : public x_leq_y { public: x_sleq_y(unsigned i, unsigned j):x_leq_y(i, j) {} - virtual char const * get_kind() const { return "x_sleq_y"; } + char const * get_kind() const override { return "x_sleq_y"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { node * n1 = s.get_uvar(q, m_var_i); node * n2 = s.get_uvar(q, m_var_j); n1->merge(n2); @@ -1540,16 +1540,16 @@ namespace smt { public: var_expr_pair(ast_manager & m, unsigned i, expr * t): m_var_i(i), m_t(t, m) {} - ~var_expr_pair() {} + ~var_expr_pair() override {} - virtual bool is_equal(qinfo const * qi) const { + bool is_equal(qinfo const * qi) const override { if (qi->get_kind() != get_kind()) return false; var_expr_pair const * other = static_cast(qi); return m_var_i == other->m_var_i && m_t.get() == other->m_t.get(); } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { out << "(" << get_kind() << ":v!" << m_var_i << ":" << mk_bounded_pp(m_t.get(), m_t.get_manager()) << ")"; } }; @@ -1558,14 +1558,14 @@ namespace smt { public: x_eq_t(ast_manager & m, unsigned i, expr * t): var_expr_pair(m, i, t) {} - virtual char const * get_kind() const { return "x_eq_t"; } + char const * get_kind() const override { return "x_eq_t"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { node * n1 = s.get_uvar(q, m_var_i); n1->insert_exception(m_t); } - virtual void populate_inst_sets(quantifier * q, auf_solver & slv, context * ctx) { + void populate_inst_sets(quantifier * q, auf_solver & slv, context * ctx) override { unsigned num_vars = q->get_num_decls(); ast_manager & m = ctx->get_manager(); sort * s = q->get_decl_sort(num_vars - m_var_i - 1); @@ -1589,14 +1589,14 @@ namespace smt { public: x_neq_t(ast_manager & m, unsigned i, expr * t): var_expr_pair(m, i, t) {} - virtual char const * get_kind() const { return "x_neq_t"; } + char const * get_kind() const override { return "x_neq_t"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { // make sure that S_q_i is create. s.get_uvar(q, m_var_i); } - virtual void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) { + void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) override { node * S_q_i = s.get_uvar(q, m_var_i); S_q_i->insert(m_t, 0); } @@ -1606,15 +1606,15 @@ namespace smt { public: x_gle_t(ast_manager & m, unsigned i, expr * t): var_expr_pair(m, i, t) {} - virtual char const * get_kind() const { return "x_gle_t"; } + char const * get_kind() const override { return "x_gle_t"; } - virtual void process_auf(quantifier * q, auf_solver & s, context * ctx) { + void process_auf(quantifier * q, auf_solver & s, context * ctx) override { // make sure that S_q_i is create. node * n1 = s.get_uvar(q, m_var_i); n1->set_mono_proj(); } - virtual void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) { + void populate_inst_sets(quantifier * q, auf_solver & s, context * ctx) override { node * S_q_i = s.get_uvar(q, m_var_i); S_q_i->insert(m_t, 0); } @@ -2524,7 +2524,7 @@ namespace smt { return false; } - virtual bool process(ptr_vector const & qs, ptr_vector & new_qs, ptr_vector & residue) { + bool process(ptr_vector const & qs, ptr_vector & new_qs, ptr_vector & residue) override { bool removed = false; for (quantifier* q : qs) { if (process(q, qs)) @@ -2957,7 +2957,7 @@ namespace smt { m_fs.reset(); } - virtual bool process(ptr_vector const & qs, ptr_vector & new_qs, ptr_vector & residue) { + bool process(ptr_vector const & qs, ptr_vector & new_qs, ptr_vector & residue) override { reset(); ptr_vector qcandidates; preprocess(qs, qcandidates, new_qs); @@ -2988,7 +2988,7 @@ namespace smt { m_satisfied(ev_handler(this)) { } - virtual ~hint_solver() { + ~hint_solver() override { reset(); } @@ -3115,7 +3115,7 @@ namespace smt { } } - virtual bool process(ptr_vector const & qs, ptr_vector & new_qs, ptr_vector & residue) { + bool process(ptr_vector const & qs, ptr_vector & new_qs, ptr_vector & residue) override { obj_map full_macros; func_decl_set cond_macros; obj_hashtable removed; diff --git a/src/smt/smt_model_generator.h b/src/smt/smt_model_generator.h index ee133482d..2c86ff9ce 100644 --- a/src/smt/smt_model_generator.h +++ b/src/smt/smt_model_generator.h @@ -159,16 +159,16 @@ namespace smt { app * m_value; public: expr_wrapper_proc(app * v):m_value(v) {} - virtual app * mk_value(model_generator & m, ptr_vector & values) { return m_value; } + app * mk_value(model_generator & m, ptr_vector & values) override { return m_value; } }; class fresh_value_proc : public model_value_proc { extra_fresh_value * m_value; public: fresh_value_proc(extra_fresh_value * v):m_value(v) {} - virtual void get_dependencies(buffer & result) { result.push_back(m_value); } - virtual app * mk_value(model_generator & m, ptr_vector & values) { return to_app(values[0]); } - virtual bool is_fresh() const { return true; } + void get_dependencies(buffer & result) override { result.push_back(m_value); } + app * mk_value(model_generator & m, ptr_vector & values) override { return to_app(values[0]); } + bool is_fresh() const override { return true; } }; /** diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index c6f83c611..108ebfaf2 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -415,10 +415,10 @@ namespace smt { m_active(false) { } - virtual ~default_qm_plugin() { + ~default_qm_plugin() override { } - virtual void set_manager(quantifier_manager & qm) { + void set_manager(quantifier_manager & qm) override { SASSERT(m_qm == 0); m_qm = &qm; m_context = &(qm.get_context()); @@ -434,11 +434,11 @@ namespace smt { m_model_checker->set_qm(qm); } - virtual quantifier_manager_plugin * mk_fresh() { return alloc(default_qm_plugin); } + quantifier_manager_plugin * mk_fresh() override { return alloc(default_qm_plugin); } - virtual bool model_based() const { return m_fparams->m_mbqi; } + bool model_based() const override { return m_fparams->m_mbqi; } - virtual bool mbqi_enabled(quantifier *q) const { + bool mbqi_enabled(quantifier *q) const override { if (!m_fparams->m_mbqi_id) return true; const symbol &s = q->get_qid(); size_t len = strlen(m_fparams->m_mbqi_id); @@ -450,16 +450,16 @@ namespace smt { /* Quantifier id's must begin with the prefix specified by parameter mbqi.id to be instantiated with MBQI. The default value is the empty string, so all quantifiers are instantiated. */ - virtual void add(quantifier * q) { + void add(quantifier * q) override { if (m_fparams->m_mbqi && mbqi_enabled(q)) { m_active = true; m_model_finder->register_quantifier(q); } } - virtual void del(quantifier * q) { } + void del(quantifier * q) override { } - virtual void push() { + void push() override { m_mam->push_scope(); m_lazy_mam->push_scope(); if (m_fparams->m_mbqi) { @@ -467,7 +467,7 @@ namespace smt { } } - virtual void pop(unsigned num_scopes) { + void pop(unsigned num_scopes) override { m_mam->pop_scope(num_scopes); m_lazy_mam->pop_scope(num_scopes); if (m_fparams->m_mbqi) { @@ -475,7 +475,7 @@ namespace smt { } } - virtual void init_search_eh() { + void init_search_eh() override { m_lazy_matching_idx = 0; if (m_fparams->m_mbqi) { m_model_finder->init_search_eh(); @@ -483,7 +483,7 @@ namespace smt { } } - virtual void assign_eh(quantifier * q) { + void assign_eh(quantifier * q) override { m_active = true; ast_manager& m = m_context->get_manager(); if (!m_fparams->m_ematching) { @@ -531,23 +531,23 @@ namespace smt { return m_fparams->m_ematching && !m_qm->empty(); } - virtual void add_eq_eh(enode * e1, enode * e2) { + void add_eq_eh(enode * e1, enode * e2) override { if (use_ematching()) m_mam->add_eq_eh(e1, e2); } - virtual void relevant_eh(enode * e) { + void relevant_eh(enode * e) override { if (use_ematching()) { m_mam->relevant_eh(e, false); m_lazy_mam->relevant_eh(e, true); } } - virtual bool can_propagate() const { + bool can_propagate() const override { return m_mam->has_work(); } - virtual void restart_eh() { + void restart_eh() override { if (m_fparams->m_mbqi) { m_model_finder->restart_eh(); m_model_checker->restart_eh(); @@ -555,17 +555,17 @@ namespace smt { TRACE("mam_stats", m_mam->display(tout);); } - virtual bool is_shared(enode * n) const { + bool is_shared(enode * n) const override { return m_active && (m_mam->is_shared(n) || m_lazy_mam->is_shared(n)); } - virtual void adjust_model(proto_model * m) { + void adjust_model(proto_model * m) override { if (m_fparams->m_mbqi) { m_model_finder->fix_model(m); } } - virtual void propagate() { + void propagate() override { m_mam->match(); if (!m_context->relevancy() && use_ematching()) { ptr_vector::const_iterator it = m_context->begin_enodes(); @@ -585,8 +585,8 @@ namespace smt { } } - virtual quantifier_manager::check_model_result - check_model(proto_model * m, obj_map const & root2value) { + quantifier_manager::check_model_result + check_model(proto_model * m, obj_map const & root2value) override { if (m_fparams->m_mbqi) { IF_VERBOSE(10, verbose_stream() << "(smt.mbqi)\n";); if (m_model_checker->check(m, root2value)) { @@ -599,7 +599,7 @@ namespace smt { return quantifier_manager::UNKNOWN; } - virtual final_check_status final_check_eh(bool full) { + final_check_status final_check_eh(bool full) override { if (!full) { if (m_fparams->m_qi_lazy_instantiation) return final_check_quant(); diff --git a/src/smt/smt_relevancy.cpp b/src/smt/smt_relevancy.cpp index 00457c643..7a2d4167f 100644 --- a/src/smt/smt_relevancy.cpp +++ b/src/smt/smt_relevancy.cpp @@ -52,24 +52,24 @@ namespace smt { app * m_parent; public: and_relevancy_eh(app * p):m_parent(p) {} - virtual ~and_relevancy_eh() {} - virtual void operator()(relevancy_propagator & rp); + ~and_relevancy_eh() override {} + void operator()(relevancy_propagator & rp) override; }; class or_relevancy_eh : public relevancy_eh { app * m_parent; public: or_relevancy_eh(app * p):m_parent(p) {} - virtual ~or_relevancy_eh() {} - virtual void operator()(relevancy_propagator & rp); + ~or_relevancy_eh() override {} + void operator()(relevancy_propagator & rp) override; }; class ite_relevancy_eh : public relevancy_eh { app * m_parent; public: ite_relevancy_eh(app * p):m_parent(p) {} - virtual ~ite_relevancy_eh() {} - virtual void operator()(relevancy_propagator & rp); + ~ite_relevancy_eh() override {} + void operator()(relevancy_propagator & rp) override; }; class ite_term_relevancy_eh : public relevancy_eh { @@ -78,8 +78,8 @@ namespace smt { app * m_else_eq; public: ite_term_relevancy_eh(app * p, app * then_eq, app * else_eq):m_parent(p), m_then_eq(then_eq), m_else_eq(else_eq) {} - virtual ~ite_term_relevancy_eh() {} - virtual void operator()(relevancy_propagator & rp); + ~ite_term_relevancy_eh() override {} + void operator()(relevancy_propagator & rp) override; }; relevancy_propagator::relevancy_propagator(context & ctx): @@ -154,7 +154,7 @@ namespace smt { relevancy_propagator(ctx), m_qhead(0), m_relevant_exprs(ctx.get_manager()), m_propagating(false) {} - virtual ~relevancy_propagator_imp() { + ~relevancy_propagator_imp() override { undo_trail(0); } @@ -191,7 +191,7 @@ namespace smt { m_trail.push_back(t); } - virtual void add_handler(expr * source, relevancy_eh * eh) { + void add_handler(expr * source, relevancy_eh * eh) override { if (!enabled()) return; if (is_relevant_core(source)) { @@ -204,7 +204,7 @@ namespace smt { } } - virtual void add_watch(expr * n, bool val, relevancy_eh * eh) { + void add_watch(expr * n, bool val, relevancy_eh * eh) override { if (!enabled()) return; lbool lval = m_context.find_assignment(n); @@ -224,7 +224,7 @@ namespace smt { } } - virtual void add_watch(expr * n, bool val, expr * target) { + void add_watch(expr * n, bool val, expr * target) override { if (!enabled()) return; lbool lval = m_context.find_assignment(n); @@ -244,18 +244,18 @@ namespace smt { bool is_relevant_core(expr * n) const { return m_is_relevant.contains(n); } - virtual bool is_relevant(expr * n) const { + bool is_relevant(expr * n) const override { return !enabled() || is_relevant_core(n); } - virtual void push() { + void push() override { m_scopes.push_back(scope()); scope & s = m_scopes.back(); s.m_relevant_exprs_lim = m_relevant_exprs.size(); s.m_trail_lim = m_trail.size(); } - virtual void pop(unsigned num_scopes) { + void pop(unsigned num_scopes) override { SASSERT(m_context.get_scope_level() == m_scopes.size()); unsigned lvl = m_scopes.size(); SASSERT(num_scopes <= lvl); @@ -325,7 +325,7 @@ namespace smt { \brief Mark the given expression as relevant if it is not already marked. */ - virtual void mark_as_relevant(expr * n) { + void mark_as_relevant(expr * n) override { if (!enabled()) return; if (!is_relevant_core(n)) { @@ -450,7 +450,7 @@ namespace smt { [m_qhead, m_relevant_exprs.size()) in the stack of relevant expressions. */ - virtual void propagate() { + void propagate() override { if (m_propagating) { return; } @@ -494,11 +494,11 @@ namespace smt { } } - virtual bool can_propagate() const { + bool can_propagate() const override { return m_qhead < m_relevant_exprs.size(); } - virtual void assign_eh(expr * n, bool val) { + void assign_eh(expr * n, bool val) override { if (!enabled()) return; ast_manager & m = get_manager(); @@ -516,7 +516,7 @@ namespace smt { } } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { if (enabled() && !m_relevant_exprs.empty()) { out << "relevant exprs:\n"; for (unsigned i = 0; i < m_relevant_exprs.size(); i++) { diff --git a/src/smt/smt_relevancy.h b/src/smt/smt_relevancy.h index 75019b110..edaa237b8 100644 --- a/src/smt/smt_relevancy.h +++ b/src/smt/smt_relevancy.h @@ -50,8 +50,8 @@ namespace smt { expr * m_target; public: simple_relevancy_eh(expr * t):m_target(t) {} - virtual ~simple_relevancy_eh() {} - virtual void operator()(relevancy_propagator & rp); + ~simple_relevancy_eh() override {} + void operator()(relevancy_propagator & rp) override; }; /** @@ -63,8 +63,8 @@ namespace smt { expr * m_target; public: pair_relevancy_eh(expr * s1, expr * s2, expr * t):m_source1(s1), m_source2(s2), m_target(t) {} - virtual ~pair_relevancy_eh() {} - virtual void operator()(relevancy_propagator & rp); + ~pair_relevancy_eh() override {} + void operator()(relevancy_propagator & rp) override; }; /** diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index 1f9ad3ef7..b805253d8 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -55,7 +55,7 @@ namespace smt { updt_params(p); } - virtual solver * translate(ast_manager & m, params_ref const & p) { + solver * translate(ast_manager & m, params_ref const & p) override { ast_translation translator(get_manager(), m); smt_solver * result = alloc(smt_solver, m, p, m_logic); @@ -68,11 +68,11 @@ namespace smt { return result; } - virtual ~smt_solver() { + ~smt_solver() override { dec_ref_values(get_manager(), m_name2assertion); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { solver::updt_params(p); m_smt_params.updt_params(p); m_context.updt_params(p); @@ -82,28 +82,28 @@ namespace smt { m_core_extend_nonlocal_patterns = smth.core_extend_nonlocal_patterns(); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { m_context.collect_param_descrs(r); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { m_context.collect_statistics(st); } - virtual lbool get_consequences_core(expr_ref_vector const& assumptions, expr_ref_vector const& vars, expr_ref_vector& conseq) { + lbool get_consequences_core(expr_ref_vector const& assumptions, expr_ref_vector const& vars, expr_ref_vector& conseq) override { expr_ref_vector unfixed(m_context.m()); return m_context.get_consequences(assumptions, vars, conseq, unfixed); } - virtual lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) { + lbool find_mutexes(expr_ref_vector const& vars, vector& mutexes) override { return m_context.find_mutexes(vars, mutexes); } - virtual void assert_expr(expr * t) { + void assert_expr(expr * t) override { m_context.assert_expr(t); } - virtual void assert_expr(expr * t, expr * a) { + void assert_expr(expr * t, expr * a) override { if (m_name2assertion.contains(a)) { throw default_exception("named assertion defined twice"); } @@ -112,11 +112,11 @@ namespace smt { m_name2assertion.insert(a, t); } - virtual void push_core() { + void push_core() override { m_context.push(); } - virtual void pop_core(unsigned n) { + void pop_core(unsigned n) override { unsigned cur_sz = m_assumptions.size(); if (n > 0 && cur_sz > 0) { unsigned lvl = m_scopes.size(); @@ -135,7 +135,7 @@ namespace smt { m_context.pop(n); } - virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) { + lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) override { TRACE("solver_na2as", tout << "smt_solver::check_sat_core: " << num_assumptions << "\n";); return m_context.check(num_assumptions, assumptions); } @@ -154,7 +154,7 @@ namespace smt { } }; - virtual void get_unsat_core(ptr_vector & r) { + void get_unsat_core(ptr_vector & r) override { unsigned sz = m_context.get_unsat_core_size(); for (unsigned i = 0; i < sz; i++) { r.push_back(m_context.get_unsat_core_expr(i)); @@ -177,40 +177,40 @@ namespace smt { add_nonlocal_pattern_literals_to_core(r); } - virtual void get_model(model_ref & m) { + void get_model(model_ref & m) override { m_context.get_model(m); } - virtual proof * get_proof() { + proof * get_proof() override { return m_context.get_proof(); } - virtual std::string reason_unknown() const { + std::string reason_unknown() const override { return m_context.last_failure_as_string(); } - virtual void set_reason_unknown(char const* msg) { + void set_reason_unknown(char const* msg) override { m_context.set_reason_unknown(msg); } - virtual void get_labels(svector & r) { + void get_labels(svector & r) override { buffer tmp; m_context.get_relevant_labels(0, tmp); r.append(tmp.size(), tmp.c_ptr()); } - virtual ast_manager & get_manager() const { return m_context.m(); } + ast_manager & get_manager() const override { return m_context.m(); } - virtual void set_progress_callback(progress_callback * callback) { + void set_progress_callback(progress_callback * callback) override { m_callback = callback; m_context.set_progress_callback(callback); } - virtual unsigned get_num_assertions() const { + unsigned get_num_assertions() const override { return m_context.size(); } - virtual expr * get_assertion(unsigned idx) const { + expr * get_assertion(unsigned idx) const override { SASSERT(idx < get_num_assertions()); return m_context.get_formula(idx); } @@ -368,7 +368,7 @@ solver * mk_smt_solver(ast_manager & m, params_ref const & p, symbol const & log class smt_solver_factory : public solver_factory { public: - virtual solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) { + solver * operator()(ast_manager & m, params_ref const & p, bool proofs_enabled, bool models_enabled, bool unsat_core_enabled, symbol const & logic) override { return mk_smt_solver(m, p, logic); } }; diff --git a/src/smt/tactic/ctx_solver_simplify_tactic.cpp b/src/smt/tactic/ctx_solver_simplify_tactic.cpp index edc4b4ff5..98de6a79b 100644 --- a/src/smt/tactic/ctx_solver_simplify_tactic.cpp +++ b/src/smt/tactic/ctx_solver_simplify_tactic.cpp @@ -43,11 +43,11 @@ public: m_fn = m.mk_func_decl(symbol(0xbeef101), i_sort, m.mk_bool_sort()); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(ctx_solver_simplify_tactic, m, m_params); } - virtual ~ctx_solver_simplify_tactic() { + ~ctx_solver_simplify_tactic() override { obj_map::iterator it = m_fns.begin(), end = m_fns.end(); for (; it != end; ++it) { m.dec_ref(it->m_value); @@ -55,33 +55,32 @@ public: m_fns.reset(); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_solver.updt_params(p); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { m_solver.collect_param_descrs(r); } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { st.update("solver-simplify-steps", m_num_steps); } - virtual void reset_statistics() { m_num_steps = 0; } + void reset_statistics() override { m_num_steps = 0; } - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { - + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { mc = 0; pc = 0; core = 0; reduce(*(in.get())); in->inc_depth(); result.push_back(in.get()); } - virtual void cleanup() { + void cleanup() override { reset_statistics(); m_solver.reset(); } diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index 57ac7b34b..af717c807 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -53,11 +53,11 @@ public: TRACE("smt_tactic", tout << "p: " << p << "\n";); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(smt_tactic, m_params_ref); } - virtual ~smt_tactic() { + ~smt_tactic() override { SASSERT(m_ctx == 0); } @@ -74,7 +74,7 @@ public: m_fail_if_inconclusive = p.get_bool("fail_if_inconclusive", true); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { TRACE("smt_tactic", tout << "updt_params: " << p << "\n";); updt_params_core(p); fparams().updt_params(p); @@ -86,7 +86,7 @@ public: SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { r.insert("candidate_models", CPK_BOOL, "(default: false) create candidate models even when quantifier or theory reasoning is incomplete."); r.insert("fail_if_inconclusive", CPK_BOOL, "(default: true) fail if found unsat (sat) for under (over) approximated goal."); smt_params_helper::collect_param_descrs(r); @@ -94,25 +94,25 @@ public: } - virtual void collect_statistics(statistics & st) const { + void collect_statistics(statistics & st) const override { if (m_ctx) m_ctx->collect_statistics(st); // ctx is still running... else st.copy(m_stats); } - virtual void cleanup() { + void cleanup() override { } - virtual void reset_statistics() { + void reset_statistics() override { m_stats.reset(); } - virtual void set_logic(symbol const & l) { + void set_logic(symbol const & l) override { m_logic = l; } - virtual void set_progress_callback(progress_callback * callback) { + void set_progress_callback(progress_callback * callback) override { m_callback = callback; } @@ -144,11 +144,11 @@ public: }; - virtual void operator()(goal_ref const & in, - goal_ref_buffer & result, - model_converter_ref & mc, - proof_converter_ref & pc, - expr_dependency_ref & core) { + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { try { IF_VERBOSE(10, verbose_stream() << "(smt.tactic start)\n";); mc = 0; pc = 0; core = 0; diff --git a/src/smt/tactic/unit_subsumption_tactic.cpp b/src/smt/tactic/unit_subsumption_tactic.cpp index 68a34cea8..3adf1cb51 100644 --- a/src/smt/tactic/unit_subsumption_tactic.cpp +++ b/src/smt/tactic/unit_subsumption_tactic.cpp @@ -37,22 +37,22 @@ struct unit_subsumption_tactic : public tactic { m_clauses(m) { } - void cleanup() {} + void cleanup() override {} - virtual void operator()(/* in */ goal_ref const & in, - /* out */ goal_ref_buffer & result, - /* out */ model_converter_ref & mc, - /* out */ proof_converter_ref & pc, - /* out */ expr_dependency_ref & core) { + void operator()(/* in */ goal_ref const & in, + /* out */ goal_ref_buffer & result, + /* out */ model_converter_ref & mc, + /* out */ proof_converter_ref & pc, + /* out */ expr_dependency_ref & core) override { reduce_core(in, result); } - virtual void updt_params(params_ref const& p) { + void updt_params(params_ref const& p) override { m_params = p; // m_context.updt_params(p); does not exist. } - virtual tactic* translate(ast_manager& m) { + tactic* translate(ast_manager& m) override { return alloc(unit_subsumption_tactic, m, m_params); } diff --git a/src/smt/theory_arith.h b/src/smt/theory_arith.h index 6794ca3ac..98bbefd42 100644 --- a/src/smt/theory_arith.h +++ b/src/smt/theory_arith.h @@ -306,16 +306,16 @@ namespace smt { public: atom(bool_var bv, theory_var v, inf_numeral const & k, atom_kind kind); atom_kind get_atom_kind() const { return static_cast(m_atom_kind); } - virtual ~atom() {} + ~atom() override {} inline inf_numeral const & get_k() const { return m_k; } bool_var get_bool_var() const { return m_bvar; } bool is_true() const { return m_is_true; } void assign_eh(bool is_true, inf_numeral const & epsilon); - virtual bool has_justification() const { return true; } - virtual void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) { + bool has_justification() const override { return true; } + void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) override { a.push_lit(literal(get_bool_var(), !m_is_true), coeff, proofs_enabled); } - virtual void display(theory_arith const& th, std::ostream& out) const; + void display(theory_arith const& th, std::ostream& out) const override; }; class eq_bound : public bound { @@ -328,13 +328,13 @@ namespace smt { m_rhs(rhs) { SASSERT(m_lhs->get_root() == m_rhs->get_root()); } - virtual ~eq_bound() {} - virtual bool has_justification() const { return true; } - virtual void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) { + ~eq_bound() override {} + bool has_justification() const override { return true; } + void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) override { SASSERT(m_lhs->get_root() == m_rhs->get_root()); a.push_eq(enode_pair(m_lhs, m_rhs), coeff, proofs_enabled); } - virtual void display(theory_arith const& th, std::ostream& out) const; + void display(theory_arith const& th, std::ostream& out) const override; }; class derived_bound : public bound { @@ -344,14 +344,14 @@ namespace smt { friend class theory_arith; public: derived_bound(theory_var v, inf_numeral const & val, bound_kind k):bound(v, val, k, false) {} - virtual ~derived_bound() {} + ~derived_bound() override {} literal_vector const& lits() const { return m_lits; } eq_vector const& eqs() const { return m_eqs; } - virtual bool has_justification() const { return true; } - virtual void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled); + bool has_justification() const override { return true; } + void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) override; virtual void push_lit(literal l, numeral const&) { m_lits.push_back(l); } virtual void push_eq(enode_pair const& p, numeral const&) { m_eqs.push_back(p); } - virtual void display(theory_arith const& th, std::ostream& out) const; + void display(theory_arith const& th, std::ostream& out) const override; }; @@ -361,12 +361,12 @@ namespace smt { friend class theory_arith; public: justified_derived_bound(theory_var v, inf_numeral const & val, bound_kind k):derived_bound(v, val, k) {} - virtual ~justified_derived_bound() {} - virtual bool has_justification() const { return true; } - virtual void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled); - virtual void push_lit(literal l, numeral const& coeff); + ~justified_derived_bound() override {} + bool has_justification() const override { return true; } + void push_justification(antecedents& a, numeral const& coeff, bool proofs_enabled) override; + void push_lit(literal l, numeral const& coeff) override; - virtual void push_eq(enode_pair const& p, numeral const& coeff); + void push_eq(enode_pair const& p, numeral const& coeff) override; }; typedef int_hashtable > literal_idx_set; @@ -510,7 +510,7 @@ namespace smt { typedef int_hashtable var_value_table; var_value_table m_var_value_table; - virtual theory_var mk_var(enode * n); + theory_var mk_var(enode * n) override; void found_unsupported_op(app * n); void found_underspecified_op(app * n); @@ -635,24 +635,24 @@ namespace smt { struct compare_atoms { bool operator()(atom* a1, atom* a2) const { return a1->get_k() < a2->get_k(); } }; - virtual bool default_internalizer() const { return false; } - virtual bool internalize_atom(app * n, bool gate_ctx); - virtual bool internalize_term(app * term); - virtual void internalize_eq_eh(app * atom, bool_var v); - virtual void apply_sort_cnstr(enode * n, sort * s); + bool default_internalizer() const override { return false; } + bool internalize_atom(app * n, bool gate_ctx) override; + bool internalize_term(app * term) override; + void internalize_eq_eh(app * atom, bool_var v) override; + void apply_sort_cnstr(enode * n, sort * s) override; - virtual void assign_eh(bool_var v, bool is_true); - virtual void new_eq_eh(theory_var v1, theory_var v2); - virtual bool use_diseqs() const; - virtual void new_diseq_eh(theory_var v1, theory_var v2); + void assign_eh(bool_var v, bool is_true) override; + void new_eq_eh(theory_var v1, theory_var v2) override; + bool use_diseqs() const override; + void new_diseq_eh(theory_var v1, theory_var v2) override; - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; - virtual void relevant_eh(app * n); + void relevant_eh(app * n) override; - virtual void restart_eh(); - virtual void init_search_eh(); + void restart_eh() override; + void init_search_eh() override; /** \brief True if the assignment may be changed during final check. assume_eqs, check_int_feasibility, @@ -669,18 +669,18 @@ namespace smt { */ bool m_liberal_final_check; final_check_status final_check_core(); - virtual final_check_status final_check_eh(); + final_check_status final_check_eh() override; - virtual bool can_propagate(); - virtual void propagate(); + bool can_propagate() override; + void propagate() override; bool propagate_core(); void failed(); - virtual void flush_eh(); - virtual void reset_eh(); + void flush_eh() override; + void reset_eh() override; - virtual bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const; + bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const override; // ----------------------------------- // @@ -867,7 +867,7 @@ namespace smt { void propagate_cheap_eq(unsigned rid); void propagate_eq_to_core(theory_var x, theory_var y, antecedents& antecedents); - virtual bool is_shared(theory_var v) const; + bool is_shared(theory_var v) const override; // ----------------------------------- // @@ -909,7 +909,7 @@ namespace smt { /** \brief See comment in theory::mk_eq_atom */ - virtual app * mk_eq_atom(expr * lhs, expr * rhs) { return m_util.mk_eq(lhs, rhs); } + app * mk_eq_atom(expr * lhs, expr * rhs) override { return m_util.mk_eq(lhs, rhs); } // ----------------------------------- // @@ -1039,13 +1039,13 @@ namespace smt { // ----------------------------------- public: theory_arith(ast_manager & m, theory_arith_params & params); - virtual ~theory_arith(); + ~theory_arith() override; - virtual theory * mk_fresh(context * new_ctx); + theory * mk_fresh(context * new_ctx) override; - virtual void setup(); + void setup() override; - virtual char const * get_name() const { return "arithmetic"; } + char const * get_name() const override { return "arithmetic"; } // ----------------------------------- // @@ -1058,15 +1058,15 @@ namespace smt { void compute_epsilon(); void refine_epsilon(); - virtual void init_model(model_generator & m); - virtual model_value_proc * mk_value(enode * n, model_generator & mg); + void init_model(model_generator & m) override; + model_value_proc * mk_value(enode * n, model_generator & mg) override; // ----------------------------------- // // Model checker // // ----------------------------------- - virtual bool get_value(enode * n, expr_ref & r); + bool get_value(enode * n, expr_ref & r) override; bool get_lower(enode* n, expr_ref& r); bool get_upper(enode* n, expr_ref& r); @@ -1078,9 +1078,9 @@ namespace smt { // Optimization // // ----------------------------------- - virtual inf_eps_rational maximize(theory_var v, expr_ref& blocker, bool& has_shared); - virtual inf_eps_rational value(theory_var v); - virtual theory_var add_objective(app* term); + inf_eps_rational maximize(theory_var v, expr_ref& blocker, bool& has_shared) override; + inf_eps_rational value(theory_var v) override; + theory_var add_objective(app* term) override; expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_numeral const& val); void enable_record_conflict(expr* bound); void record_conflict(unsigned num_lits, literal const * lits, @@ -1102,8 +1102,8 @@ namespace smt { // // ----------------------------------- public: - virtual void collect_statistics(::statistics & st) const; - virtual void display(std::ostream & out) const; + void collect_statistics(::statistics & st) const override; + void display(std::ostream & out) const override; protected: void display_row(std::ostream & out, unsigned r_id, bool compact = true) const; void display_row(std::ostream & out, row const & r, bool compact = true) const; diff --git a/src/smt/theory_arith_int.h b/src/smt/theory_arith_int.h index 4f15a6156..593b9c56b 100644 --- a/src/smt/theory_arith_int.h +++ b/src/smt/theory_arith_int.h @@ -472,7 +472,7 @@ namespace smt { bounds.num_params(), bounds.params("gomory-cut")) { } // Remark: the assignment must be propagated back to arith - virtual theory_id get_from_theory() const { return null_theory_id; } + theory_id get_from_theory() const override { return null_theory_id; } }; /** diff --git a/src/smt/theory_array.h b/src/smt/theory_array.h index 3a013cf73..26d59c7bf 100644 --- a/src/smt/theory_array.h +++ b/src/smt/theory_array.h @@ -55,19 +55,19 @@ namespace smt { th_trail_stack m_trail_stack; unsigned m_final_check_idx; - virtual void init(context * ctx); - virtual theory_var mk_var(enode * n); - virtual bool internalize_atom(app * atom, bool gate_ctx); - virtual bool internalize_term(app * term); - virtual void apply_sort_cnstr(enode * n, sort * s); - virtual void new_eq_eh(theory_var v1, theory_var v2); - virtual void new_diseq_eh(theory_var v1, theory_var v2); - virtual void relevant_eh(app * n); - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); - virtual final_check_status final_check_eh(); - virtual void reset_eh(); - virtual void init_search_eh() { m_final_check_idx = 0; } + void init(context * ctx) override; + theory_var mk_var(enode * n) override; + bool internalize_atom(app * atom, bool gate_ctx) override; + bool internalize_term(app * term) override; + void apply_sort_cnstr(enode * n, sort * s) override; + void new_eq_eh(theory_var v1, theory_var v2) override; + void new_diseq_eh(theory_var v1, theory_var v2) override; + void relevant_eh(app * n) override; + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; + final_check_status final_check_eh() override; + void reset_eh() override; + void init_search_eh() override { m_final_check_idx = 0; } virtual void set_prop_upward(theory_var v); virtual void set_prop_upward(enode* n); @@ -96,15 +96,15 @@ namespace smt { static void display_ids(std::ostream & out, unsigned n, enode * const * v); public: theory_array(ast_manager & m, theory_array_params & params); - virtual ~theory_array(); + ~theory_array() override; - virtual theory * mk_fresh(context * new_ctx) { return alloc(theory_array, new_ctx->get_manager(), new_ctx->get_fparams()); } + theory * mk_fresh(context * new_ctx) override { return alloc(theory_array, new_ctx->get_manager(), new_ctx->get_fparams()); } - virtual char const * get_name() const { return "array"; } + char const * get_name() const override { return "array"; } virtual void display_var(std::ostream & out, theory_var v) const; - virtual void display(std::ostream & out) const; - virtual void collect_statistics(::statistics & st) const; + void display(std::ostream & out) const override; + void collect_statistics(::statistics & st) const override; th_trail_stack & get_trail_stack() { return m_trail_stack; } virtual void merge_eh(theory_var v1, theory_var v2, theory_var, theory_var); static void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) {} diff --git a/src/smt/theory_array_base.cpp b/src/smt/theory_array_base.cpp index 472053fdc..0aba7c2f2 100644 --- a/src/smt/theory_array_base.cpp +++ b/src/smt/theory_array_base.cpp @@ -828,7 +828,7 @@ namespace smt { m_unspecified_else(true) { } - virtual ~array_value_proc() {} + ~array_value_proc() override {} void add_entry(unsigned num_args, enode * const * args, enode * value) { SASSERT(num_args > 0); @@ -840,11 +840,11 @@ namespace smt { m_dependencies.push_back(model_value_dependency(value)); } - virtual void get_dependencies(buffer & result) { + void get_dependencies(buffer & result) override { result.append(m_dependencies.size(), m_dependencies.c_ptr()); } - virtual app * mk_value(model_generator & mg, ptr_vector & values) { + app * mk_value(model_generator & mg, ptr_vector & values) override { // values must have size = m_num_entries * (m_dim + 1) + ((m_else || m_unspecified_else) ? 0 : 1) // an array value is a lookup table + else_value // each entry has m_dim indexes that map to a value. diff --git a/src/smt/theory_array_base.h b/src/smt/theory_array_base.h index 197ad9d2f..730c02f94 100644 --- a/src/smt/theory_array_base.h +++ b/src/smt/theory_array_base.h @@ -123,15 +123,15 @@ namespace smt { // // // -------------------------------------------------- - virtual bool is_shared(theory_var v) const; + bool is_shared(theory_var v) const override; void collect_shared_vars(sbuffer & result); unsigned mk_interface_eqs(); - virtual bool can_propagate(); - virtual void propagate(); - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); - virtual void reset_eh(); + bool can_propagate() override; + void propagate() override; + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; + void reset_eh() override; void reset_queues(); // ----------------------------------- @@ -177,7 +177,7 @@ namespace smt { void set_default(theory_var v, enode* n); enode* get_default(theory_var v); - virtual void init_model(model_generator & m); + void init_model(model_generator & m) override; bool is_unspecified_default_ok() const; void collect_defaults(); void collect_selects(); @@ -185,12 +185,12 @@ namespace smt { void propagate_selects_to_store_parents(enode * r, enode_pair_vector & todo); void propagate_selects(); select_set * get_select_set(enode * n); - virtual void finalize_model(model_generator & m); - virtual model_value_proc * mk_value(enode * n, model_generator & m); + void finalize_model(model_generator & m) override; + model_value_proc * mk_value(enode * n, model_generator & m) override; public: theory_array_base(ast_manager & m); - virtual ~theory_array_base() { restore_sorts(0); } + ~theory_array_base() override { restore_sorts(0); } }; }; diff --git a/src/smt/theory_array_full.h b/src/smt/theory_array_full.h index 2cad3acbd..3216b4286 100644 --- a/src/smt/theory_array_full.h +++ b/src/smt/theory_array_full.h @@ -42,29 +42,29 @@ namespace smt { protected: //virtual final_check_status final_check_eh(); - virtual void reset_eh(); + void reset_eh() override; - virtual void set_prop_upward(theory_var v); - virtual void set_prop_upward(enode* n); - virtual void set_prop_upward(theory_var v, var_data* d); - virtual unsigned get_lambda_equiv_size(theory_var v, var_data* d); + void set_prop_upward(theory_var v) override; + void set_prop_upward(enode* n) override; + void set_prop_upward(theory_var v, var_data* d) override; + unsigned get_lambda_equiv_size(theory_var v, var_data* d) override; - virtual bool internalize_term(app * term); - virtual bool internalize_atom(app * atom, bool gate_ctx); - virtual void pop_scope_eh(unsigned num_scopes); - virtual theory_var mk_var(enode * n); - virtual void relevant_eh(app * n); + bool internalize_term(app * term) override; + bool internalize_atom(app * atom, bool gate_ctx) override; + void pop_scope_eh(unsigned num_scopes) override; + theory_var mk_var(enode * n) override; + void relevant_eh(app * n) override; void add_const(theory_var v, enode* c); void add_map(theory_var v, enode* s); void add_parent_map(theory_var v, enode* s); void add_as_array(theory_var v, enode* arr); - virtual void add_parent_select(theory_var v, enode * s); + void add_parent_select(theory_var v, enode * s) override; void add_parent_default(theory_var v); - virtual final_check_status assert_delayed_axioms(); + final_check_status assert_delayed_axioms() override; bool instantiate_default_const_axiom(enode* cnst); bool instantiate_default_store_axiom(enode* store); @@ -87,14 +87,14 @@ namespace smt { public: theory_array_full(ast_manager & m, theory_array_params & params); - virtual ~theory_array_full(); + ~theory_array_full() override; - virtual theory * mk_fresh(context * new_ctx); + theory * mk_fresh(context * new_ctx) override; - virtual void merge_eh(theory_var v1, theory_var v2, theory_var, theory_var); - virtual void display_var(std::ostream & out, theory_var v) const; - virtual void collect_statistics(::statistics & st) const; - virtual void init(context* ctx) { + void merge_eh(theory_var v1, theory_var v2, theory_var, theory_var) override; + void display_var(std::ostream & out, theory_var v) const override; + void collect_statistics(::statistics & st) const override; + void init(context* ctx) override { // the parent class is theory_array. // theory::init(ctx); theory_array::init(ctx); diff --git a/src/smt/theory_bv.cpp b/src/smt/theory_bv.cpp index ec3913415..0f5c235f3 100644 --- a/src/smt/theory_bv.cpp +++ b/src/smt/theory_bv.cpp @@ -65,7 +65,7 @@ namespace smt { bool_var m_var; public: mk_atom_trail(bool_var v):m_var(v) {} - virtual void undo(theory_bv & th) { + void undo(theory_bv & th) override { theory_bv::atom * a = th.get_bv2a(m_var); a->~atom(); th.erase_bv2a(m_var); @@ -213,7 +213,7 @@ namespace smt { theory_bv::bit_atom * m_atom; public: add_var_pos_trail(theory_bv::bit_atom * a):m_atom(a) {} - virtual void undo(theory_bv & th) { + void undo(theory_bv & th) override { SASSERT(m_atom->m_occs); m_atom->m_occs = m_atom->m_occs->m_next; } @@ -389,12 +389,12 @@ namespace smt { m_th(th), m_var1(v1), m_var2(v2) { } - virtual void get_antecedents(conflict_resolution & cr) { + void get_antecedents(conflict_resolution & cr) override { mark_bits(cr, m_th.m_bits[m_var1]); mark_bits(cr, m_th.m_bits[m_var2]); } - virtual proof * mk_proof(conflict_resolution & cr) { + proof * mk_proof(conflict_resolution & cr) override { ptr_buffer prs; context & ctx = cr.get_context(); bool visited = true; @@ -414,11 +414,11 @@ namespace smt { return m.mk_th_lemma(get_from_theory(), fact, prs.size(), prs.c_ptr()); } - virtual theory_id get_from_theory() const { + theory_id get_from_theory() const override { return m_th.get_id(); } - virtual char const * get_name() const { return "bv-fixed-eq"; } + char const * get_name() const override { return "bv-fixed-eq"; } }; @@ -1510,13 +1510,13 @@ namespace smt { bit_eq_justification(theory_id th_id, enode * v1, enode * v2, literal c, literal a): m_v1(v1), m_v2(v2), m_th_id(th_id), m_consequent(c), m_antecedent(a) {} - virtual void get_antecedents(conflict_resolution & cr) { + void get_antecedents(conflict_resolution & cr) override { cr.mark_eq(m_v1, m_v2); if (m_antecedent.var() != true_bool_var) cr.mark_literal(m_antecedent); } - virtual proof * mk_proof(conflict_resolution & cr) { + proof * mk_proof(conflict_resolution & cr) override { bool visited = true; ptr_buffer prs; proof * pr = cr.get_proof(m_v1, m_v2); @@ -1540,11 +1540,11 @@ namespace smt { return m.mk_th_lemma(get_from_theory(), fact, prs.size(), prs.c_ptr()); } - virtual theory_id get_from_theory() const { + theory_id get_from_theory() const override { return m_th_id; } - virtual char const * get_name() const { return "bv-bit-eq"; } + char const * get_name() const override { return "bv-bit-eq"; } }; inline justification * theory_bv::mk_bit_eq_justification(theory_var v1, theory_var v2, literal consequent, literal antecedent) { diff --git a/src/smt/theory_bv.h b/src/smt/theory_bv.h index c35078ace..ca3338cb7 100644 --- a/src/smt/theory_bv.h +++ b/src/smt/theory_bv.h @@ -58,16 +58,16 @@ namespace smt { struct bit_atom : public atom { var_pos_occ * m_occs; bit_atom():m_occs(0) {} - virtual ~bit_atom() {} - virtual bool is_bit() const { return true; } + ~bit_atom() override {} + bool is_bit() const override { return true; } }; struct le_atom : public atom { literal m_var; literal m_def; le_atom(literal v, literal d):m_var(v), m_def(d) {} - virtual ~le_atom() {} - virtual bool is_bit() const { return false; } + ~le_atom() override {} + bool is_bit() const override { return false; } }; /** @@ -216,21 +216,21 @@ namespace smt { void assert_bv2int_axiom(app* n); protected: - virtual void init(context * ctx); - virtual theory_var mk_var(enode * n); - virtual bool internalize_atom(app * atom, bool gate_ctx); - virtual bool internalize_term(app * term); - virtual void apply_sort_cnstr(enode * n, sort * s); - virtual void new_eq_eh(theory_var v1, theory_var v2); - virtual void new_diseq_eh(theory_var v1, theory_var v2); + void init(context * ctx) override; + theory_var mk_var(enode * n) override; + bool internalize_atom(app * atom, bool gate_ctx) override; + bool internalize_term(app * term) override; + void apply_sort_cnstr(enode * n, sort * s) override; + void new_eq_eh(theory_var v1, theory_var v2) override; + void new_diseq_eh(theory_var v1, theory_var v2) override; virtual void expand_diseq(theory_var v1, theory_var v2); - virtual void assign_eh(bool_var v, bool is_true); - virtual void relevant_eh(app * n); - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); - virtual final_check_status final_check_eh(); - virtual void reset_eh(); - virtual bool include_func_interp(func_decl* f); + void assign_eh(bool_var v, bool is_true) override; + void relevant_eh(app * n) override; + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; + final_check_status final_check_eh() override; + void reset_eh() override; + bool include_func_interp(func_decl* f) override; svector m_merge_aux[2]; //!< auxiliary vector used in merge_zero_one_bits bool merge_zero_one_bits(theory_var r1, theory_var r2); @@ -240,16 +240,16 @@ namespace smt { // // ----------------------------------- bv_factory * m_factory; - virtual void init_model(model_generator & m); - virtual model_value_proc * mk_value(enode * n, model_generator & mg); + void init_model(model_generator & m) override; + model_value_proc * mk_value(enode * n, model_generator & mg) override; public: theory_bv(ast_manager & m, theory_bv_params const & params, bit_blaster_params const & bb_params); - virtual ~theory_bv(); + ~theory_bv() override; - virtual theory * mk_fresh(context * new_ctx); + theory * mk_fresh(context * new_ctx) override; - virtual char const * get_name() const { return "bit-vector"; } + char const * get_name() const override { return "bit-vector"; } th_trail_stack & get_trail_stack() { return m_trail_stack; } void merge_eh(theory_var, theory_var, theory_var v1, theory_var v2); @@ -259,8 +259,8 @@ namespace smt { void display_var(std::ostream & out, theory_var v) const; void display_bit_atom(std::ostream & out, bool_var v, bit_atom const * a) const; void display_atoms(std::ostream & out) const; - virtual void display(std::ostream & out) const; - virtual void collect_statistics(::statistics & st) const; + void display(std::ostream & out) const override; + void collect_statistics(::statistics & st) const override; bool get_fixed_value(app* x, numeral & result) const; diff --git a/src/smt/theory_datatype.cpp b/src/smt/theory_datatype.cpp index bbed6840d..f9422ee8a 100644 --- a/src/smt/theory_datatype.cpp +++ b/src/smt/theory_datatype.cpp @@ -33,7 +33,7 @@ namespace smt { ext_theory_eq_propagation_justification(fid, r, 1, &antecedent, 0, 0, lhs, rhs) { } // Remark: the assignment must be propagated back to the datatype theory. - virtual theory_id get_from_theory() const { return null_theory_id; } + theory_id get_from_theory() const override { return null_theory_id; } }; @@ -551,11 +551,11 @@ namespace smt { public: datatype_value_proc(func_decl * d):m_constructor(d) {} void add_dependency(enode * n) { m_dependencies.push_back(model_value_dependency(n)); } - virtual ~datatype_value_proc() {} - virtual void get_dependencies(buffer & result) { + ~datatype_value_proc() override {} + void get_dependencies(buffer & result) override { result.append(m_dependencies.size(), m_dependencies.c_ptr()); } - virtual app * mk_value(model_generator & mg, ptr_vector & values) { + app * mk_value(model_generator & mg, ptr_vector & values) override { SASSERT(values.size() == m_dependencies.size()); return mg.get_manager().mk_app(m_constructor, values.size(), values.c_ptr()); } diff --git a/src/smt/theory_datatype.h b/src/smt/theory_datatype.h index 20fa371fa..3329c71cb 100644 --- a/src/smt/theory_datatype.h +++ b/src/smt/theory_datatype.h @@ -84,35 +84,35 @@ namespace smt { void display_var(std::ostream & out, theory_var v) const; protected: - virtual theory_var mk_var(enode * n); - virtual bool internalize_atom(app * atom, bool gate_ctx); - virtual bool internalize_term(app * term); - virtual void apply_sort_cnstr(enode * n, sort * s); - virtual void new_eq_eh(theory_var v1, theory_var v2); - virtual bool use_diseqs() const; - virtual void new_diseq_eh(theory_var v1, theory_var v2); - virtual void assign_eh(bool_var v, bool is_true); - virtual void relevant_eh(app * n); - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); - virtual final_check_status final_check_eh(); - virtual void reset_eh(); - virtual void restart_eh() { m_util.reset(); } - virtual bool is_shared(theory_var v) const; + theory_var mk_var(enode * n) override; + bool internalize_atom(app * atom, bool gate_ctx) override; + bool internalize_term(app * term) override; + void apply_sort_cnstr(enode * n, sort * s) override; + void new_eq_eh(theory_var v1, theory_var v2) override; + bool use_diseqs() const override; + void new_diseq_eh(theory_var v1, theory_var v2) override; + void assign_eh(bool_var v, bool is_true) override; + void relevant_eh(app * n) override; + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; + final_check_status final_check_eh() override; + void reset_eh() override; + void restart_eh() override { m_util.reset(); } + bool is_shared(theory_var v) const override; public: theory_datatype(ast_manager & m, theory_datatype_params & p); - virtual ~theory_datatype(); - virtual theory * mk_fresh(context * new_ctx); - virtual void display(std::ostream & out) const; - virtual void collect_statistics(::statistics & st) const; - virtual void init_model(model_generator & m); - virtual model_value_proc * mk_value(enode * n, model_generator & m); + ~theory_datatype() override; + theory * mk_fresh(context * new_ctx) override; + void display(std::ostream & out) const override; + void collect_statistics(::statistics & st) const override; + void init_model(model_generator & m) override; + model_value_proc * mk_value(enode * n, model_generator & m) override; th_trail_stack & get_trail_stack() { return m_trail_stack; } virtual void merge_eh(theory_var v1, theory_var v2, theory_var, theory_var); static void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) {} void unmerge_eh(theory_var v1, theory_var v2); - virtual char const * get_name() const { return "datatype"; } - virtual bool include_func_interp(func_decl* f); + char const * get_name() const override { return "datatype"; } + bool include_func_interp(func_decl* f) override; }; diff --git a/src/smt/theory_dense_diff_logic.h b/src/smt/theory_dense_diff_logic.h index 980830447..dbf6a13a9 100644 --- a/src/smt/theory_dense_diff_logic.h +++ b/src/smt/theory_dense_diff_logic.h @@ -182,7 +182,7 @@ namespace smt { return false; } app * mk_zero_for(expr * n); - theory_var mk_var(enode * n); + theory_var mk_var(enode * n) override; theory_var internalize_term_core(app * n); void found_non_diff_logic_expr(expr * n); bool is_connected(theory_var source, theory_var target) const { return m_matrix[source][target].m_edge_id != null_edge_id; } @@ -214,38 +214,38 @@ namespace smt { // Internalization // // ----------------------------------- - virtual bool internalize_atom(app * n, bool gate_ctx); - virtual bool internalize_term(app * term); - virtual void internalize_eq_eh(app * atom, bool_var v); - virtual void apply_sort_cnstr(enode * n, sort * s); + bool internalize_atom(app * n, bool gate_ctx) override; + bool internalize_term(app * term) override; + void internalize_eq_eh(app * atom, bool_var v) override; + void apply_sort_cnstr(enode * n, sort * s) override; - virtual void assign_eh(bool_var v, bool is_true); - virtual void new_eq_eh(theory_var v1, theory_var v2); - virtual bool use_diseqs() const; - virtual void new_diseq_eh(theory_var v1, theory_var v2); + void assign_eh(bool_var v, bool is_true) override; + void new_eq_eh(theory_var v1, theory_var v2) override; + bool use_diseqs() const override; + void new_diseq_eh(theory_var v1, theory_var v2) override; - virtual void conflict_resolution_eh(app * atom, bool_var v); + void conflict_resolution_eh(app * atom, bool_var v) override; - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; - virtual void restart_eh(); - virtual void init_search_eh(); - virtual final_check_status final_check_eh(); + void restart_eh() override; + void init_search_eh() override; + final_check_status final_check_eh() override; - virtual bool can_propagate(); - virtual void propagate(); + bool can_propagate() override; + void propagate() override; - virtual void flush_eh(); - virtual void reset_eh(); + void flush_eh() override; + void reset_eh() override; bool dump_lemmas() const { return m_params.m_arith_dump_lemmas; } - virtual bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const; + bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const override; - virtual void display(std::ostream & out) const; + void display(std::ostream & out) const override; virtual void display_atom(std::ostream & out, atom * a) const; - virtual void collect_statistics(::statistics & st) const; + void collect_statistics(::statistics & st) const override; // ----------------------------------- // @@ -258,8 +258,8 @@ namespace smt { void compute_epsilon(); void fix_zero(); - virtual void init_model(model_generator & m); - virtual model_value_proc * mk_value(enode * n, model_generator & mg); + void init_model(model_generator & m) override; + model_value_proc * mk_value(enode * n, model_generator & mg) override; // ----------------------------------- // @@ -267,9 +267,9 @@ namespace smt { // // ----------------------------------- - virtual inf_eps_rational maximize(theory_var v, expr_ref& blocker, bool& has_shared); - virtual inf_eps_rational value(theory_var v); - virtual theory_var add_objective(app* term); + inf_eps_rational maximize(theory_var v, expr_ref& blocker, bool& has_shared) override; + inf_eps_rational value(theory_var v) override; + theory_var add_objective(app* term) override; virtual expr_ref mk_gt(theory_var v, inf_eps const& val); expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_eps const& val); @@ -280,16 +280,16 @@ namespace smt { // ----------------------------------- public: theory_dense_diff_logic(ast_manager & m, theory_arith_params & p); - virtual ~theory_dense_diff_logic() { reset_eh(); } + ~theory_dense_diff_logic() override { reset_eh(); } - virtual theory * mk_fresh(context * new_ctx); + theory * mk_fresh(context * new_ctx) override; - virtual char const * get_name() const { return "difference-logic"; } + char const * get_name() const override { return "difference-logic"; } /** \brief See comment in theory::mk_eq_atom */ - virtual app * mk_eq_atom(expr * lhs, expr * rhs) { return m_autil.mk_eq(lhs, rhs); } + app * mk_eq_atom(expr * lhs, expr * rhs) override { return m_autil.mk_eq(lhs, rhs); } }; typedef theory_dense_diff_logic theory_dense_mi; diff --git a/src/smt/theory_diff_logic.h b/src/smt/theory_diff_logic.h index 1ad239e58..ce0814f10 100644 --- a/src/smt/theory_diff_logic.h +++ b/src/smt/theory_diff_logic.h @@ -208,7 +208,7 @@ namespace smt { void new_edge(dl_var src, dl_var dst, unsigned num_edges, edge_id const* edges); // Create a new theory variable. - virtual theory_var mk_var(enode* n); + theory_var mk_var(enode* n) override; virtual theory_var mk_var(app* n); @@ -240,79 +240,79 @@ namespace smt { m_num_simplex_edges(0) { } - virtual ~theory_diff_logic() { + ~theory_diff_logic() override { reset_eh(); } - virtual theory * mk_fresh(context * new_ctx); + theory * mk_fresh(context * new_ctx) override; - virtual char const * get_name() const { return "difference-logic"; } + char const * get_name() const override { return "difference-logic"; } /** \brief See comment in theory::mk_eq_atom */ - virtual app * mk_eq_atom(expr * lhs, expr * rhs) { return m_util.mk_eq(lhs, rhs); } + app * mk_eq_atom(expr * lhs, expr * rhs) override { return m_util.mk_eq(lhs, rhs); } - virtual void init(context * ctx); + void init(context * ctx) override; - virtual bool internalize_atom(app * atom, bool gate_ctx); + bool internalize_atom(app * atom, bool gate_ctx) override; - virtual bool internalize_term(app * term); + bool internalize_term(app * term) override; - virtual void internalize_eq_eh(app * atom, bool_var v); + void internalize_eq_eh(app * atom, bool_var v) override; - virtual void assign_eh(bool_var v, bool is_true); + void assign_eh(bool_var v, bool is_true) override; - virtual void new_eq_eh(theory_var v1, theory_var v2); + void new_eq_eh(theory_var v1, theory_var v2) override; - virtual bool use_diseqs() const { return true; } + bool use_diseqs() const override { return true; } - virtual void new_diseq_eh(theory_var v1, theory_var v2); + void new_diseq_eh(theory_var v1, theory_var v2) override; - virtual void push_scope_eh(); + void push_scope_eh() override; - virtual void pop_scope_eh(unsigned num_scopes); + void pop_scope_eh(unsigned num_scopes) override; - virtual void restart_eh() { + void restart_eh() override { m_arith_eq_adapter.restart_eh(); } - virtual void relevant_eh(app* e) {} + void relevant_eh(app* e) override {} - virtual void init_search_eh() { + void init_search_eh() override { m_arith_eq_adapter.init_search_eh(); } - virtual final_check_status final_check_eh(); + final_check_status final_check_eh() override; - virtual bool is_shared(theory_var v) const { + bool is_shared(theory_var v) const override { return false; } - virtual bool can_propagate() { + bool can_propagate() override { return m_asserted_qhead != m_asserted_atoms.size(); } - virtual void propagate(); + void propagate() override; - virtual justification * why_is_diseq(theory_var v1, theory_var v2) { + justification * why_is_diseq(theory_var v1, theory_var v2) override { NOT_IMPLEMENTED_YET(); return 0; } // virtual void flush_eh(); - virtual void reset_eh(); + void reset_eh() override; - virtual void init_model(model_generator & m); + void init_model(model_generator & m) override; - virtual model_value_proc * mk_value(enode * n, model_generator & mg); + model_value_proc * mk_value(enode * n, model_generator & mg) override; - virtual bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const; + bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const override; - virtual void display(std::ostream & out) const; + void display(std::ostream & out) const override; - virtual void collect_statistics(::statistics & st) const; + void collect_statistics(::statistics & st) const override; // ----------------------------------- @@ -321,9 +321,9 @@ namespace smt { // // ----------------------------------- - virtual inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared); - virtual inf_eps value(theory_var v); - virtual theory_var add_objective(app* term); + inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared) override; + inf_eps value(theory_var v) override; + theory_var add_objective(app* term) override; expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_eps const& val); bool internalize_objective(expr * n, rational const& m, rational& r, objective_term & objective); diff --git a/src/smt/theory_dl.cpp b/src/smt/theory_dl.cpp index ea02121d9..1e9df2973 100644 --- a/src/smt/theory_dl.cpp +++ b/src/smt/theory_dl.cpp @@ -51,7 +51,7 @@ namespace smt { m_util(u) {} - virtual app * mk_value_core(unsigned const & val, sort * s) { + app * mk_value_core(unsigned const & val, sort * s) override { return m_util.mk_numeral(val, s); } }; @@ -74,9 +74,9 @@ namespace smt { dl_value_proc(theory_dl& th, smt::enode* n) : m_th(th), m_node(n) {} - virtual void get_dependencies(buffer & result) {} + void get_dependencies(buffer & result) override {} - virtual app * mk_value(smt::model_generator & mg, ptr_vector & ) { + app * mk_value(smt::model_generator & mg, ptr_vector & ) override { smt::context& ctx = m_th.get_context(); app* result = 0; expr* n = m_node->get_owner(); @@ -111,9 +111,9 @@ namespace smt { } - virtual char const * get_name() const { return "datalog"; } + char const * get_name() const override { return "datalog"; } - virtual bool internalize_atom(app * atom, bool gate_ctx) { + bool internalize_atom(app * atom, bool gate_ctx) override { TRACE("theory_dl", tout << mk_pp(atom, m()) << "\n";); context& ctx = get_context(); if (ctx.b_internalized(atom)) { @@ -136,7 +136,7 @@ namespace smt { return false; } - virtual bool internalize_term(app * term) { + bool internalize_term(app * term) override { TRACE("theory_dl", tout << mk_pp(term, m()) << "\n";); if (u().is_finite_sort(term)) { return mk_rep(term); @@ -146,27 +146,27 @@ namespace smt { } } - virtual void new_eq_eh(theory_var v1, theory_var v2) { + void new_eq_eh(theory_var v1, theory_var v2) override { } - virtual void new_diseq_eh(theory_var v1, theory_var v2) { + void new_diseq_eh(theory_var v1, theory_var v2) override { } - virtual theory * mk_fresh(context * new_ctx) { + theory * mk_fresh(context * new_ctx) override { return alloc(theory_dl, new_ctx->get_manager()); } - virtual void init_model(smt::model_generator & m) { + void init_model(smt::model_generator & m) override { m.register_factory(alloc(dl_factory, m_util, m.get_model())); } - virtual smt::model_value_proc * mk_value(smt::enode * n, smt::model_generator&) { + smt::model_value_proc * mk_value(smt::enode * n, smt::model_generator&) override { return alloc(dl_value_proc, *this, n); } - virtual void apply_sort_cnstr(enode * n, sort * s) { + void apply_sort_cnstr(enode * n, sort * s) override { app* term = n->get_owner(); if (u().is_finite_sort(term)) { mk_rep(term); @@ -174,7 +174,7 @@ namespace smt { } - virtual void relevant_eh(app * n) { + void relevant_eh(app * n) override { if (u().is_finite_sort(n)) { sort* s = m().get_sort(n); func_decl* r, *v; @@ -194,7 +194,7 @@ namespace smt { } } - virtual void display(std::ostream & out) const { + void display(std::ostream & out) const override { } diff --git a/src/smt/theory_dummy.h b/src/smt/theory_dummy.h index b20d86270..c58695aac 100644 --- a/src/smt/theory_dummy.h +++ b/src/smt/theory_dummy.h @@ -33,25 +33,25 @@ namespace smt { void found_theory_expr(); protected: - virtual bool internalize_atom(app * atom, bool gate_ctx); - virtual bool internalize_term(app * term); - virtual void new_eq_eh(theory_var v1, theory_var v2); - virtual bool use_diseqs() const; - virtual void new_diseq_eh(theory_var v1, theory_var v2); - virtual void reset_eh(); - virtual final_check_status final_check_eh(); - virtual bool build_models() const { + bool internalize_atom(app * atom, bool gate_ctx) override; + bool internalize_term(app * term) override; + void new_eq_eh(theory_var v1, theory_var v2) override; + bool use_diseqs() const override; + void new_diseq_eh(theory_var v1, theory_var v2) override; + void reset_eh() override; + final_check_status final_check_eh() override; + bool build_models() const override { return false; } - virtual void display(std::ostream& out) const {} + void display(std::ostream& out) const override {} public: theory_dummy(family_id fid, char const * name); - virtual ~theory_dummy() {} + ~theory_dummy() override {} - virtual theory * mk_fresh(context * new_ctx) { return alloc(theory_dummy, get_family_id(), m_name); } + theory * mk_fresh(context * new_ctx) override { return alloc(theory_dummy, get_family_id(), m_name); } - virtual char const * get_name() const; + char const * get_name() const override; }; }; diff --git a/src/smt/theory_fpa.cpp b/src/smt/theory_fpa.cpp index cc9b0017d..36ee5c15a 100644 --- a/src/smt/theory_fpa.cpp +++ b/src/smt/theory_fpa.cpp @@ -32,8 +32,8 @@ namespace smt { public: fpa2bv_conversion_trail_elem(ast_manager & m, obj_map & map, expr * e) : m(m), m_map(map), key(e, m) { } - virtual ~fpa2bv_conversion_trail_elem() { } - virtual void undo(theory_fpa & th) { + ~fpa2bv_conversion_trail_elem() override { } + void undo(theory_fpa & th) override { expr * val = m_map.find(key); m_map.remove(key); m.dec_ref(key); diff --git a/src/smt/theory_fpa.h b/src/smt/theory_fpa.h index 9e9801ee0..8cd01d2e9 100644 --- a/src/smt/theory_fpa.h +++ b/src/smt/theory_fpa.h @@ -43,16 +43,16 @@ namespace smt { value_factory(m, fid), m_util(m) {} - virtual ~fpa_value_factory() {} + ~fpa_value_factory() override {} - virtual expr * get_some_value(sort * s) { + expr * get_some_value(sort * s) override { mpf_manager & mpfm = m_util.fm(); scoped_mpf q(mpfm); mpfm.set(q, m_util.get_ebits(s), m_util.get_sbits(s), 0); return m_util.mk_value(q); } - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override { mpf_manager & mpfm = m_util.fm(); scoped_mpf q(mpfm); mpfm.set(q, m_util.get_ebits(s), m_util.get_sbits(s), 0); @@ -62,8 +62,8 @@ namespace smt { return true; } - virtual expr * get_fresh_value(sort * s) { NOT_IMPLEMENTED_YET(); } - virtual void register_value(expr * n) { /* Ignore */ } + expr * get_fresh_value(sort * s) override { NOT_IMPLEMENTED_YET(); } + void register_value(expr * n) override { /* Ignore */ } app * mk_value(mpf const & x) { return m_util.mk_value(x); @@ -81,8 +81,8 @@ namespace smt { fpa2bv_converter(m), m_th(*th) {} virtual ~fpa2bv_converter_wrapped() {} - virtual void mk_const(func_decl * f, expr_ref & result); - virtual void mk_rm_const(func_decl * f, expr_ref & result); + void mk_const(func_decl * f, expr_ref & result) override; + void mk_rm_const(func_decl * f, expr_ref & result) override; }; class fpa_value_proc : public model_value_proc { @@ -100,15 +100,15 @@ namespace smt { m_th(*th), m(th->get_manager()), m_fu(th->m_fpa_util), m_bu(th->m_bv_util), m_ebits(ebits), m_sbits(sbits) {} - virtual ~fpa_value_proc() {} + ~fpa_value_proc() override {} void add_dependency(enode * e) { m_deps.push_back(model_value_dependency(e)); } - virtual void get_dependencies(buffer & result) { + void get_dependencies(buffer & result) override { result.append(m_deps); } - virtual app * mk_value(model_generator & mg, ptr_vector & values); + app * mk_value(model_generator & mg, ptr_vector & values) override; }; class fpa_rm_value_proc : public model_value_proc { @@ -124,12 +124,12 @@ namespace smt { void add_dependency(enode * e) { m_deps.push_back(model_value_dependency(e)); } - virtual void get_dependencies(buffer & result) { + void get_dependencies(buffer & result) override { result.append(m_deps); } - virtual ~fpa_rm_value_proc() {} - virtual app * mk_value(model_generator & mg, ptr_vector & values); + ~fpa_rm_value_proc() override {} + app * mk_value(model_generator & mg, ptr_vector & values) override; }; protected: @@ -145,32 +145,32 @@ namespace smt { bool m_is_initialized; obj_hashtable m_is_added_to_model; - virtual final_check_status final_check_eh(); - virtual bool internalize_atom(app * atom, bool gate_ctx); - virtual bool internalize_term(app * term); - virtual void apply_sort_cnstr(enode * n, sort * s); - virtual void new_eq_eh(theory_var, theory_var); - virtual void new_diseq_eh(theory_var, theory_var); - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); - virtual void reset_eh(); - virtual theory* mk_fresh(context* new_ctx); - virtual char const * get_name() const { return "fpa"; } + final_check_status final_check_eh() override; + bool internalize_atom(app * atom, bool gate_ctx) override; + bool internalize_term(app * term) override; + void apply_sort_cnstr(enode * n, sort * s) override; + void new_eq_eh(theory_var, theory_var) override; + void new_diseq_eh(theory_var, theory_var) override; + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; + void reset_eh() override; + theory* mk_fresh(context* new_ctx) override; + char const * get_name() const override { return "fpa"; } - virtual model_value_proc * mk_value(enode * n, model_generator & mg); + model_value_proc * mk_value(enode * n, model_generator & mg) override; - void assign_eh(bool_var v, bool is_true); - virtual void relevant_eh(app * n); - virtual void init_model(model_generator & m); - virtual void finalize_model(model_generator & mg); + void assign_eh(bool_var v, bool is_true) override; + void relevant_eh(app * n) override; + void init_model(model_generator & m) override; + void finalize_model(model_generator & mg) override; public: theory_fpa(ast_manager & m); - virtual ~theory_fpa(); + ~theory_fpa() override; - virtual void init(context * ctx); + void init(context * ctx) override; - virtual void display(std::ostream & out) const; + void display(std::ostream & out) const override; protected: expr_ref mk_side_conditions(); diff --git a/src/smt/theory_lra.cpp b/src/smt/theory_lra.cpp index 21b66d3a0..d369ddefa 100644 --- a/src/smt/theory_lra.cpp +++ b/src/smt/theory_lra.cpp @@ -137,7 +137,7 @@ namespace smt { imp& m_imp; public: resource_limit(imp& i): m_imp(i) { } - virtual bool get_cancel_flag() { return m_imp.m.canceled(); } + bool get_cancel_flag() override { return m_imp.m.canceled(); } }; @@ -1358,11 +1358,11 @@ namespace smt { imp & m_imp; local_bound_propagator(imp& i) : lp_bound_propagator(*i.m_solver), m_imp(i) {} - bool bound_is_interesting(unsigned j, lp::lconstraint_kind kind, const rational & v) { + bool bound_is_interesting(unsigned j, lp::lconstraint_kind kind, const rational & v) override { return m_imp.bound_is_interesting(j, kind, v); } - virtual void consume(rational const& v, unsigned j) { + void consume(rational const& v, unsigned j) override { m_imp.set_evidence(j); } }; diff --git a/src/smt/theory_lra.h b/src/smt/theory_lra.h index 774ec15ad..f3ef77495 100644 --- a/src/smt/theory_lra.h +++ b/src/smt/theory_lra.h @@ -29,66 +29,66 @@ namespace smt { public: theory_lra(ast_manager& m, theory_arith_params& ap); - virtual ~theory_lra(); - virtual theory* mk_fresh(context* new_ctx); - virtual char const* get_name() const { return "lra"; } + ~theory_lra() override; + theory* mk_fresh(context* new_ctx) override; + char const* get_name() const override { return "lra"; } - virtual void init(context * ctx); + void init(context * ctx) override; - virtual bool internalize_atom(app * atom, bool gate_ctx); + bool internalize_atom(app * atom, bool gate_ctx) override; - virtual bool internalize_term(app * term); + bool internalize_term(app * term) override; - virtual void internalize_eq_eh(app * atom, bool_var v); + void internalize_eq_eh(app * atom, bool_var v) override; - virtual void assign_eh(bool_var v, bool is_true); + void assign_eh(bool_var v, bool is_true) override; - virtual void new_eq_eh(theory_var v1, theory_var v2); + void new_eq_eh(theory_var v1, theory_var v2) override; - virtual bool use_diseqs() const; + bool use_diseqs() const override; - virtual void new_diseq_eh(theory_var v1, theory_var v2); + void new_diseq_eh(theory_var v1, theory_var v2) override; - virtual void push_scope_eh(); + void push_scope_eh() override; - virtual void pop_scope_eh(unsigned num_scopes); + void pop_scope_eh(unsigned num_scopes) override; - virtual void restart_eh(); + void restart_eh() override; - virtual void relevant_eh(app* e); + void relevant_eh(app* e) override; - virtual void init_search_eh(); + void init_search_eh() override; - virtual final_check_status final_check_eh(); + final_check_status final_check_eh() override; - virtual bool is_shared(theory_var v) const; + bool is_shared(theory_var v) const override; - virtual bool can_propagate(); + bool can_propagate() override; - virtual void propagate(); + void propagate() override; - virtual justification * why_is_diseq(theory_var v1, theory_var v2); + justification * why_is_diseq(theory_var v1, theory_var v2) override; // virtual void flush_eh(); - virtual void reset_eh(); + void reset_eh() override; - virtual void init_model(model_generator & m); + void init_model(model_generator & m) override; - virtual model_value_proc * mk_value(enode * n, model_generator & mg); + model_value_proc * mk_value(enode * n, model_generator & mg) override; - virtual bool get_value(enode* n, expr_ref& r); + bool get_value(enode* n, expr_ref& r) override; - virtual bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const; + bool validate_eq_in_model(theory_var v1, theory_var v2, bool is_true) const override; - virtual void display(std::ostream & out) const; + void display(std::ostream & out) const override; - virtual void collect_statistics(::statistics & st) const; + void collect_statistics(::statistics & st) const override; // optimization - virtual inf_eps value(theory_var); - virtual inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared); - virtual theory_var add_objective(app* term); + inf_eps value(theory_var) override; + inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared) override; + theory_var add_objective(app* term) override; virtual expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_rational const& val); diff --git a/src/smt/theory_pb.cpp b/src/smt/theory_pb.cpp index 9d2059f55..cc9b6b9b1 100644 --- a/src/smt/theory_pb.cpp +++ b/src/smt/theory_pb.cpp @@ -254,7 +254,7 @@ namespace smt { unsigned v; public: remove_var(theory_pb& pb, unsigned v): pb(pb), v(v) {} - virtual void undo(context& ctx) { + void undo(context& ctx) override { pb.m_vars.remove(v); pb.m_simplex.unset_lower(v); pb.m_simplex.unset_upper(v); @@ -282,7 +282,7 @@ namespace smt { m_last_bound_valid(last_bound_valid), m_last_explain(last_explain) {} - virtual void undo(context& ctx) { + void undo(context& ctx) override { if (m_is_lower) { if (m_last_bound_valid) { pb.m_simplex.set_lower(m_v, m_last_bound); @@ -889,7 +889,7 @@ namespace smt { ineq& c; public: rewatch_vars(theory_pb& p, ineq& c): pb(p), c(c) {} - virtual void undo(context& ctx) { + void undo(context& ctx) override { for (unsigned i = 0; i < c.size(); ++i) { pb.watch_var(c.lit(i).var(), &c); } @@ -900,7 +900,7 @@ namespace smt { ineq& c; public: negate_ineq(ineq& c): c(c) {} - virtual void undo(context& ctx) { + void undo(context& ctx) override { c.negate(); } }; @@ -1357,7 +1357,7 @@ namespace smt { public: unwatch_ge(theory_pb& p, ineq& c): pb(p), c(c) {} - virtual void undo(context& ctx) { + void undo(context& ctx) override { for (unsigned i = 0; i < c.watch_size(); ++i) { pb.unwatch_literal(c.lit(i), &c); } @@ -2008,11 +2008,11 @@ namespace smt { m_dependencies.push_back(model_value_dependency(n)); } - virtual void get_dependencies(buffer & result) { + void get_dependencies(buffer & result) override { result.append(m_dependencies.size(), m_dependencies.c_ptr()); } - virtual app * mk_value(model_generator & mg, ptr_vector & values) { + app * mk_value(model_generator & mg, ptr_vector & values) override { ast_manager& m = mg.get_manager(); SASSERT(values.size() == m_dependencies.size()); SASSERT(values.size() == m_app->get_num_args()); @@ -2049,18 +2049,18 @@ namespace smt { pb_factory(ast_manager& m, family_id fid): value_factory(m, fid) {} - virtual expr * get_some_value(sort * s) { + expr * get_some_value(sort * s) override { return m_manager.mk_true(); } - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override { v1 = m_manager.mk_true(); v2 = m_manager.mk_false(); return true; } - virtual expr * get_fresh_value(sort * s) { + expr * get_fresh_value(sort * s) override { return 0; } - virtual void register_value(expr * n) { } + void register_value(expr * n) override { } }; void theory_pb::init_model(model_generator & m) { diff --git a/src/smt/theory_pb.h b/src/smt/theory_pb.h index 662378bdf..5eb6e3312 100644 --- a/src/smt/theory_pb.h +++ b/src/smt/theory_pb.h @@ -261,7 +261,7 @@ namespace smt { std::ostream& display(std::ostream& out, ineq const& c, bool values = false) const; std::ostream& display(std::ostream& out, arg_t const& c, bool values = false) const; - virtual void display(std::ostream& out) const; + void display(std::ostream& out) const override; void display_watch(std::ostream& out, bool_var v, bool sign) const; void display_resolved_lemma(std::ostream& out) const; @@ -317,26 +317,26 @@ namespace smt { public: theory_pb(ast_manager& m, theory_pb_params& p); - virtual ~theory_pb(); + ~theory_pb() override; - virtual theory * mk_fresh(context * new_ctx); - virtual bool internalize_atom(app * atom, bool gate_ctx); - virtual bool internalize_term(app * term) { UNREACHABLE(); return false; } - virtual void new_eq_eh(theory_var v1, theory_var v2); - virtual void new_diseq_eh(theory_var v1, theory_var v2) { } - virtual bool use_diseqs() const { return false; } - virtual bool build_models() const { return false; } - virtual final_check_status final_check_eh(); - virtual void reset_eh(); - virtual void assign_eh(bool_var v, bool is_true); - virtual void init_search_eh(); - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); - virtual void restart_eh(); - virtual void collect_statistics(::statistics & st) const; - virtual model_value_proc * mk_value(enode * n, model_generator & mg); - virtual void init_model(model_generator & m); - virtual bool include_func_interp(func_decl* f) { return false; } + theory * mk_fresh(context * new_ctx) override; + bool internalize_atom(app * atom, bool gate_ctx) override; + bool internalize_term(app * term) override { UNREACHABLE(); return false; } + void new_eq_eh(theory_var v1, theory_var v2) override; + void new_diseq_eh(theory_var v1, theory_var v2) override { } + bool use_diseqs() const override { return false; } + bool build_models() const override { return false; } + final_check_status final_check_eh() override; + void reset_eh() override; + void assign_eh(bool_var v, bool is_true) override; + void init_search_eh() override; + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; + void restart_eh() override; + void collect_statistics(::statistics & st) const override; + model_value_proc * mk_value(enode * n, model_generator & mg) override; + void init_model(model_generator & m) override; + bool include_func_interp(func_decl* f) override { return false; } static literal assert_ge(context& ctx, unsigned k, unsigned n, literal const* xs); }; diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 4c1a63a2f..6fabbf865 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -45,7 +45,7 @@ public: m_kernel(m, fp) {} - virtual lbool check_sat(expr* e) { + lbool check_sat(expr* e) override { m_kernel.push(); m_kernel.assert_expr(e); lbool r = m_kernel.check(); @@ -2691,7 +2691,7 @@ class theory_seq::seq_value_proc : public model_value_proc { public: seq_value_proc(theory_seq& th, sort* s): th(th), m_sort(s) { } - virtual ~seq_value_proc() {} + ~seq_value_proc() override {} void add_unit(enode* n) { m_dependencies.push_back(model_value_dependency(n)); m_source.push_back(unit_source); @@ -2704,7 +2704,7 @@ public: m_strings.push_back(n); m_source.push_back(string_source); } - virtual void get_dependencies(buffer & result) { + void get_dependencies(buffer & result) override { result.append(m_dependencies.size(), m_dependencies.c_ptr()); } @@ -2714,7 +2714,7 @@ public: } } - virtual app * mk_value(model_generator & mg, ptr_vector & values) { + app * mk_value(model_generator & mg, ptr_vector & values) override { SASSERT(values.size() == m_dependencies.size()); expr_ref_vector args(th.m); unsigned j = 0, k = 0; diff --git a/src/smt/theory_seq.h b/src/smt/theory_seq.h index 46f803f5b..3cb1f1b4b 100644 --- a/src/smt/theory_seq.h +++ b/src/smt/theory_seq.h @@ -224,8 +224,8 @@ namespace smt { expr_ref m_e; public: replay_length_coherence(ast_manager& m, expr* e) : m_e(e, m) {} - virtual ~replay_length_coherence() {} - virtual void operator()(theory_seq& th) { + ~replay_length_coherence() override {} + void operator()(theory_seq& th) override { th.check_length_coherence(m_e); m_e.reset(); } @@ -235,8 +235,8 @@ namespace smt { expr_ref m_e; public: replay_fixed_length(ast_manager& m, expr* e) : m_e(e, m) {} - virtual ~replay_fixed_length() {} - virtual void operator()(theory_seq& th) { + ~replay_fixed_length() override {} + void operator()(theory_seq& th) override { th.fixed_length(m_e); m_e.reset(); } @@ -246,8 +246,8 @@ namespace smt { expr_ref m_e; public: replay_axiom(ast_manager& m, expr* e) : m_e(e, m) {} - virtual ~replay_axiom() {} - virtual void operator()(theory_seq& th) { + ~replay_axiom() override {} + void operator()(theory_seq& th) override { th.enque_axiom(m_e); m_e.reset(); } @@ -257,7 +257,7 @@ namespace smt { apply* m_apply; public: push_replay(apply* app): m_apply(app) {} - virtual void undo(theory_seq& th) { + void undo(theory_seq& th) override { th.m_replay.push_back(m_apply); } }; @@ -266,7 +266,7 @@ namespace smt { unsigned k; public: pop_branch(unsigned k): k(k) {} - virtual void undo(theory_seq& th) { + void undo(theory_seq& th) override { th.m_branch_start.erase(k); } }; @@ -340,29 +340,29 @@ namespace smt { obj_hashtable m_fixed; // string variables that are fixed length. - virtual void init(context* ctx); - virtual final_check_status final_check_eh(); - virtual bool internalize_atom(app* atom, bool); - virtual bool internalize_term(app*); - virtual void internalize_eq_eh(app * atom, bool_var v); - virtual void new_eq_eh(theory_var, theory_var); - virtual void new_diseq_eh(theory_var, theory_var); - virtual void assign_eh(bool_var v, bool is_true); - virtual bool can_propagate(); - virtual void propagate(); - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); - virtual void restart_eh(); - virtual void relevant_eh(app* n); - virtual theory* mk_fresh(context* new_ctx) { return alloc(theory_seq, new_ctx->get_manager()); } - virtual char const * get_name() const { return "seq"; } - virtual theory_var mk_var(enode* n); - virtual void apply_sort_cnstr(enode* n, sort* s); - virtual void display(std::ostream & out) const; - virtual void collect_statistics(::statistics & st) const; - virtual model_value_proc * mk_value(enode * n, model_generator & mg); - virtual void init_model(model_generator & mg); - virtual void init_search_eh(); + void init(context* ctx) override; + final_check_status final_check_eh() override; + bool internalize_atom(app* atom, bool) override; + bool internalize_term(app*) override; + void internalize_eq_eh(app * atom, bool_var v) override; + void new_eq_eh(theory_var, theory_var) override; + void new_diseq_eh(theory_var, theory_var) override; + void assign_eh(bool_var v, bool is_true) override; + bool can_propagate() override; + void propagate() override; + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; + void restart_eh() override; + void relevant_eh(app* n) override; + theory* mk_fresh(context* new_ctx) override { return alloc(theory_seq, new_ctx->get_manager()); } + char const * get_name() const override { return "seq"; } + theory_var mk_var(enode* n) override; + void apply_sort_cnstr(enode* n, sort* s) override; + void display(std::ostream & out) const override; + void collect_statistics(::statistics & st) const override; + model_value_proc * mk_value(enode * n, model_generator & mg) override; + void init_model(model_generator & mg) override; + void init_search_eh() override; void init_model(expr_ref_vector const& es); // final check @@ -584,7 +584,7 @@ namespace smt { void display_nc(std::ostream& out, nc const& nc) const; public: theory_seq(ast_manager& m); - virtual ~theory_seq(); + ~theory_seq() override; // model building app* mk_value(app* a); diff --git a/src/smt/theory_seq_empty.h b/src/smt/theory_seq_empty.h index 85408f7e5..647b54320 100644 --- a/src/smt/theory_seq_empty.h +++ b/src/smt/theory_seq_empty.h @@ -63,7 +63,7 @@ namespace smt { m_unique_sequences.insert(m.get_sort(uniq), uniq); } - virtual expr* get_some_value(sort* s) { + expr* get_some_value(sort* s) override { if (u.is_seq(s)) { return u.str.mk_empty(s); } @@ -74,7 +74,7 @@ namespace smt { UNREACHABLE(); return 0; } - virtual bool get_some_values(sort* s, expr_ref& v1, expr_ref& v2) { + bool get_some_values(sort* s, expr_ref& v1, expr_ref& v2) override { if (u.is_string(s)) { v1 = u.str.mk_string(symbol("a")); v2 = u.str.mk_string(symbol("b")); @@ -94,7 +94,7 @@ namespace smt { NOT_IMPLEMENTED_YET(); return false; } - virtual expr* get_fresh_value(sort* s) { + expr* get_fresh_value(sort* s) override { if (u.is_string(s)) { while (true) { std::ostringstream strm; @@ -122,7 +122,7 @@ namespace smt { UNREACHABLE(); return 0; } - virtual void register_value(expr* n) { + void register_value(expr* n) override { symbol sym; if (u.str.is_string(n, sym)) { m_strings.insert(sym); @@ -148,17 +148,17 @@ namespace smt { class theory_seq_empty : public theory { bool m_used; - virtual final_check_status final_check_eh() { return m_used?FC_GIVEUP:FC_DONE; } - virtual bool internalize_atom(app*, bool) { if (!m_used) { get_context().push_trail(value_trail(m_used)); m_used = true; } return false; } - virtual bool internalize_term(app*) { return internalize_atom(0,false); } - virtual void new_eq_eh(theory_var, theory_var) { } - virtual void new_diseq_eh(theory_var, theory_var) {} - virtual theory* mk_fresh(context* new_ctx) { return alloc(theory_seq_empty, new_ctx->get_manager()); } - virtual char const * get_name() const { return "seq-empty"; } - virtual void display(std::ostream& out) const {} + final_check_status final_check_eh() override { return m_used?FC_GIVEUP:FC_DONE; } + bool internalize_atom(app*, bool) override { if (!m_used) { get_context().push_trail(value_trail(m_used)); m_used = true; } return false; } + bool internalize_term(app*) override { return internalize_atom(0,false); } + void new_eq_eh(theory_var, theory_var) override { } + void new_diseq_eh(theory_var, theory_var) override {} + theory* mk_fresh(context* new_ctx) override { return alloc(theory_seq_empty, new_ctx->get_manager()); } + char const * get_name() const override { return "seq-empty"; } + void display(std::ostream& out) const override {} public: theory_seq_empty(ast_manager& m):theory(m.mk_family_id("seq")), m_used(false) {} - virtual void init_model(model_generator & mg) { + void init_model(model_generator & mg) override { mg.register_factory(alloc(seq_factory, get_manager(), get_family_id(), mg.get_model())); } diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index 03fd31162..52d06efd1 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -46,16 +46,16 @@ public: str_value_factory(ast_manager & m, family_id fid) : value_factory(m, fid), u(m), delim("!"), m_next(0) {} - virtual ~str_value_factory() {} - virtual expr * get_some_value(sort * s) { + ~str_value_factory() override {} + expr * get_some_value(sort * s) override { return u.str.mk_string(symbol("some value")); } - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override { v1 = u.str.mk_string(symbol("value 1")); v2 = u.str.mk_string(symbol("value 2")); return true; } - virtual expr * get_fresh_value(sort * s) { + expr * get_fresh_value(sort * s) override { if (u.is_string(s)) { while (true) { std::ostringstream strm; @@ -74,7 +74,7 @@ public: TRACE("t_str", tout << "unexpected sort in get_fresh_value(): " << mk_pp(s, m_manager) << std::endl;); UNREACHABLE(); return NULL; } - virtual void register_value(expr * n) { /* Ignore */ } + void register_value(expr * n) override { /* Ignore */ } }; // rather than modify obj_pair_map I inherit from it and add my own helper methods @@ -104,8 +104,8 @@ class binary_search_trail : public trail { public: binary_search_trail(obj_map > & target, expr * entry) : target(target), entry(entry) {} - virtual ~binary_search_trail() {} - virtual void undo(Ctx & ctx) { + ~binary_search_trail() override {} + void undo(Ctx & ctx) override { TRACE("t_str_binary_search", tout << "in binary_search_trail::undo()" << std::endl;); if (target.contains(entry)) { if (!target[entry].empty()) { @@ -616,10 +616,10 @@ protected: public: theory_str(ast_manager & m, theory_str_params const & params); - virtual ~theory_str(); + ~theory_str() override; - virtual char const * get_name() const { return "seq"; } - virtual void display(std::ostream & out) const; + char const * get_name() const override { return "seq"; } + void display(std::ostream & out) const override; bool overlapping_variables_detected() const { return loopDetected; } @@ -628,33 +628,33 @@ public: void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) { } void unmerge_eh(theory_var v1, theory_var v2) {} protected: - virtual bool internalize_atom(app * atom, bool gate_ctx); - virtual bool internalize_term(app * term); + bool internalize_atom(app * atom, bool gate_ctx) override; + bool internalize_term(app * term) override; virtual enode* ensure_enode(expr* e); - virtual theory_var mk_var(enode * n); + theory_var mk_var(enode * n) override; - virtual void new_eq_eh(theory_var, theory_var); - virtual void new_diseq_eh(theory_var, theory_var); + void new_eq_eh(theory_var, theory_var) override; + void new_diseq_eh(theory_var, theory_var) override; - virtual theory* mk_fresh(context*) { return alloc(theory_str, get_manager(), m_params); } - virtual void init_search_eh(); - virtual void add_theory_assumptions(expr_ref_vector & assumptions); - virtual lbool validate_unsat_core(expr_ref_vector & unsat_core); - virtual void relevant_eh(app * n); - virtual void assign_eh(bool_var v, bool is_true); - virtual void push_scope_eh(); - virtual void pop_scope_eh(unsigned num_scopes); - virtual void reset_eh(); + theory* mk_fresh(context*) override { return alloc(theory_str, get_manager(), m_params); } + void init_search_eh() override; + void add_theory_assumptions(expr_ref_vector & assumptions) override; + lbool validate_unsat_core(expr_ref_vector & unsat_core) override; + void relevant_eh(app * n) override; + void assign_eh(bool_var v, bool is_true) override; + void push_scope_eh() override; + void pop_scope_eh(unsigned num_scopes) override; + void reset_eh() override; - virtual bool can_propagate(); - virtual void propagate(); + bool can_propagate() override; + void propagate() override; - virtual final_check_status final_check_eh(); + final_check_status final_check_eh() override; virtual void attach_new_th_var(enode * n); - virtual void init_model(model_generator & m); - virtual model_value_proc * mk_value(enode * n, model_generator & mg); - virtual void finalize_model(model_generator & mg); + void init_model(model_generator & m) override; + model_value_proc * mk_value(enode * n, model_generator & mg) override; + void finalize_model(model_generator & mg) override; }; }; diff --git a/src/smt/theory_utvpi.h b/src/smt/theory_utvpi.h index 55bbb9838..ca4f4737e 100644 --- a/src/smt/theory_utvpi.h +++ b/src/smt/theory_utvpi.h @@ -166,7 +166,7 @@ namespace smt { void new_edge(dl_var src, dl_var dst, unsigned num_edges, edge_id const* edges) {} // Create a new theory variable. - virtual th_var mk_var(enode* n); + th_var mk_var(enode* n) override; virtual th_var mk_var(expr* n); @@ -181,83 +181,83 @@ namespace smt { public: theory_utvpi(ast_manager& m); - virtual ~theory_utvpi(); + ~theory_utvpi() override; - virtual theory * mk_fresh(context * new_ctx); + theory * mk_fresh(context * new_ctx) override; - virtual char const * get_name() const { return "utvpi-logic"; } + char const * get_name() const override { return "utvpi-logic"; } /** \brief See comment in theory::mk_eq_atom */ - virtual app * mk_eq_atom(expr * lhs, expr * rhs) { return a.mk_eq(lhs, rhs); } + app * mk_eq_atom(expr * lhs, expr * rhs) override { return a.mk_eq(lhs, rhs); } - virtual void init(context * ctx); + void init(context * ctx) override; - virtual bool internalize_atom(app * atom, bool gate_ctx); + bool internalize_atom(app * atom, bool gate_ctx) override; - virtual bool internalize_term(app * term); + bool internalize_term(app * term) override; - virtual void internalize_eq_eh(app * atom, bool_var v); + void internalize_eq_eh(app * atom, bool_var v) override; - virtual void assign_eh(bool_var v, bool is_true); + void assign_eh(bool_var v, bool is_true) override; - virtual void new_eq_eh(th_var v1, th_var v2) { + void new_eq_eh(th_var v1, th_var v2) override { m_stats.m_num_core2th_eqs++; m_arith_eq_adapter.new_eq_eh(v1, v2); } - virtual bool use_diseqs() const { return true; } + bool use_diseqs() const override { return true; } - virtual void new_diseq_eh(th_var v1, th_var v2) { + void new_diseq_eh(th_var v1, th_var v2) override { m_arith_eq_adapter.new_diseq_eh(v1, v2); } - virtual void push_scope_eh(); + void push_scope_eh() override; - virtual void pop_scope_eh(unsigned num_scopes); + void pop_scope_eh(unsigned num_scopes) override; - virtual void restart_eh() { + void restart_eh() override { m_arith_eq_adapter.restart_eh(); } - virtual void relevant_eh(app* e) {} + void relevant_eh(app* e) override {} - virtual void init_search_eh() { + void init_search_eh() override { m_arith_eq_adapter.init_search_eh(); } - virtual final_check_status final_check_eh(); + final_check_status final_check_eh() override; - virtual bool is_shared(th_var v) const { + bool is_shared(th_var v) const override { return false; } - virtual bool can_propagate() { + bool can_propagate() override { SASSERT(m_asserted_qhead <= m_asserted_atoms.size()); return m_asserted_qhead != m_asserted_atoms.size(); } - virtual void propagate(); + void propagate() override; - virtual justification * why_is_diseq(th_var v1, th_var v2) { + justification * why_is_diseq(th_var v1, th_var v2) override { UNREACHABLE(); return 0; } - virtual void reset_eh(); + void reset_eh() override; - virtual void init_model(model_generator & m); + void init_model(model_generator & m) override; - virtual model_value_proc * mk_value(enode * n, model_generator & mg); + model_value_proc * mk_value(enode * n, model_generator & mg) override; - virtual bool validate_eq_in_model(th_var v1, th_var v2, bool is_true) const { + bool validate_eq_in_model(th_var v1, th_var v2, bool is_true) const override { return true; } - virtual void display(std::ostream & out) const; + void display(std::ostream & out) const override; - virtual void collect_statistics(::statistics & st) const; + void collect_statistics(::statistics & st) const override; private: diff --git a/src/smt/theory_wmaxsat.h b/src/smt/theory_wmaxsat.h index 739a22c71..16dab488b 100644 --- a/src/smt/theory_wmaxsat.h +++ b/src/smt/theory_wmaxsat.h @@ -57,7 +57,7 @@ namespace smt { stats m_stats; public: theory_wmaxsat(ast_manager& m, filter_model_converter& mc); - virtual ~theory_wmaxsat(); + ~theory_wmaxsat() override; void get_assignment(svector& result); expr* assert_weighted(expr* fml, rational const& w); void disable_var(expr* var); @@ -76,43 +76,43 @@ namespace smt { old.push_back(value); } - virtual ~numeral_trail() { + ~numeral_trail() override { } - virtual void undo(context & ctx) { + void undo(context & ctx) override { m_value = m_old_values.back(); m_old_values.shrink(m_old_values.size() - 1); } }; - virtual void init_search_eh(); - virtual void assign_eh(bool_var v, bool is_true); - virtual final_check_status final_check_eh(); - virtual bool use_diseqs() const { + void init_search_eh() override; + void assign_eh(bool_var v, bool is_true) override; + final_check_status final_check_eh() override; + bool use_diseqs() const override { return false; } - virtual bool build_models() const { + bool build_models() const override { return false; } void reset_local(); - virtual void reset_eh(); - virtual theory * mk_fresh(context * new_ctx) { return 0; } - virtual bool internalize_atom(app * atom, bool gate_ctx) { return false; } - virtual bool internalize_term(app * term) { return false; } - virtual void new_eq_eh(theory_var v1, theory_var v2) { } - virtual void new_diseq_eh(theory_var v1, theory_var v2) { } - virtual void display(std::ostream& out) const {} - virtual void restart_eh(); + void reset_eh() override; + theory * mk_fresh(context * new_ctx) override { return 0; } + bool internalize_atom(app * atom, bool gate_ctx) override { return false; } + bool internalize_term(app * term) override { return false; } + void new_eq_eh(theory_var v1, theory_var v2) override { } + void new_diseq_eh(theory_var v1, theory_var v2) override { } + void display(std::ostream& out) const override {} + void restart_eh() override; - virtual void collect_statistics(::statistics & st) const { + void collect_statistics(::statistics & st) const override { st.update("wmaxsat num blocks", m_stats.m_num_blocks); st.update("wmaxsat num props", m_stats.m_num_propagations); } - virtual bool can_propagate() { + bool can_propagate() override { return m_propagate || m_can_propagate; } - virtual void propagate(); + void propagate() override; bool is_optimal() const; expr_ref mk_block(); diff --git a/src/test/ex.cpp b/src/test/ex.cpp index 591813814..444431475 100644 --- a/src/test/ex.cpp +++ b/src/test/ex.cpp @@ -29,14 +29,14 @@ class ex1 : public ex { char const * m_msg; public: ex1(char const * m):m_msg(m) {} - virtual char const * msg() const { return m_msg; } + char const * msg() const override { return m_msg; } }; class ex2 : public ex { std::string m_msg; public: ex2(char const * m):m_msg(m) {} - virtual char const * msg() const { return m_msg.c_str(); } + char const * msg() const override { return m_msg.c_str(); } }; static void th() { diff --git a/src/util/checked_int64.h b/src/util/checked_int64.h index 8a2eb124d..e5a88fb31 100644 --- a/src/util/checked_int64.h +++ b/src/util/checked_int64.h @@ -41,7 +41,7 @@ public: checked_int64(checked_int64 const& other) { m_value = other.m_value; } class overflow_exception : public z3_exception { - virtual char const * msg() const { return "checked_int64 overflow/underflow";} + char const * msg() const override { return "checked_int64 overflow/underflow";} }; bool is_zero() const { return m_value == 0; } diff --git a/src/util/lp/eta_matrix.h b/src/util/lp/eta_matrix.h index 6c30e2146..7224fa846 100644 --- a/src/util/lp/eta_matrix.h +++ b/src/util/lp/eta_matrix.h @@ -46,7 +46,7 @@ public: #endif m_column_index(column_index) {} - bool is_dense() const { return false; } + bool is_dense() const override { return false; } void print(std::ostream & out) { print_matrix(*this, out); @@ -65,12 +65,12 @@ public: return m_diagonal_element; } - void apply_from_left(vector & w, lp_settings & ); + void apply_from_left(vector & w, lp_settings & ) override; template void apply_from_left_local(indexed_vector & w, lp_settings & settings); - void apply_from_left_to_T(indexed_vector & w, lp_settings & settings) { + void apply_from_left_to_T(indexed_vector & w, lp_settings & settings) override { apply_from_left_local(w, settings); } @@ -80,8 +80,8 @@ public: m_column_vector.push_back(row_index, val); } - void apply_from_right(vector & w); - void apply_from_right(indexed_vector & w); + void apply_from_right(vector & w) override; + void apply_from_right(indexed_vector & w) override; T get_elem(unsigned i, unsigned j) const; #ifdef Z3DEBUG diff --git a/src/util/lp/iterator_on_column.h b/src/util/lp/iterator_on_column.h index 5bb43f4c6..c9112a064 100644 --- a/src/util/lp/iterator_on_column.h +++ b/src/util/lp/iterator_on_column.h @@ -27,14 +27,14 @@ struct iterator_on_column:linear_combination_iterator { const vector& m_column; // the offset in term coeffs const static_matrix & m_A; int m_i; // the initial offset in the column - unsigned size() const { return m_column.size(); } + unsigned size() const override { return m_column.size(); } iterator_on_column(const vector& column, const static_matrix & A) // the offset in term coeffs : m_column(column), m_A(A), m_i(-1) {} - bool next(mpq & a, unsigned & i) { + bool next(mpq & a, unsigned & i) override { if (++m_i >= static_cast(m_column.size())) return false; @@ -44,7 +44,7 @@ struct iterator_on_column:linear_combination_iterator { return true; } - bool next(unsigned & i) { + bool next(unsigned & i) override { if (++m_i >= static_cast(m_column.size())) return false; @@ -53,11 +53,11 @@ struct iterator_on_column:linear_combination_iterator { return true; } - void reset() { + void reset() override { m_i = -1; } - linear_combination_iterator * clone() { + linear_combination_iterator * clone() override { iterator_on_column * r = new iterator_on_column(m_column, m_A); return r; } diff --git a/src/util/lp/iterator_on_indexed_vector.h b/src/util/lp/iterator_on_indexed_vector.h index 2c8daf83b..6cb98b8f2 100644 --- a/src/util/lp/iterator_on_indexed_vector.h +++ b/src/util/lp/iterator_on_indexed_vector.h @@ -28,8 +28,8 @@ struct iterator_on_indexed_vector:linear_combination_iterator { m_v(v), m_offset(0) {} - unsigned size() const { return m_v.m_index.size(); } - bool next(T & a, unsigned & i) { + unsigned size() const override { return m_v.m_index.size(); } + bool next(T & a, unsigned & i) override { if (m_offset >= m_v.m_index.size()) return false; i = m_v.m_index[m_offset++]; @@ -37,16 +37,16 @@ struct iterator_on_indexed_vector:linear_combination_iterator { return true; } - bool next(unsigned & i) { + bool next(unsigned & i) override { if (m_offset >= m_v.m_index.size()) return false; i = m_v.m_index[m_offset++]; return true; } - void reset() { + void reset() override { m_offset = 0; } - linear_combination_iterator* clone() { + linear_combination_iterator* clone() override { return new iterator_on_indexed_vector(m_v); } }; diff --git a/src/util/lp/iterator_on_pivot_row.h b/src/util/lp/iterator_on_pivot_row.h index 8aa498477..721502bc2 100644 --- a/src/util/lp/iterator_on_pivot_row.h +++ b/src/util/lp/iterator_on_pivot_row.h @@ -26,11 +26,11 @@ struct iterator_on_pivot_row:linear_combination_iterator { const indexed_vector & m_v; unsigned m_basis_j; iterator_on_indexed_vector m_it; - unsigned size() const { return m_it.size(); } + unsigned size() const override { return m_it.size(); } iterator_on_pivot_row(const indexed_vector & v, unsigned basis_j) : m_basis_returned(false), m_v(v), m_basis_j(basis_j), m_it(v) {} - bool next(T & a, unsigned & i) { + bool next(T & a, unsigned & i) override { if (m_basis_returned == false) { m_basis_returned = true; a = one_of_type(); @@ -39,7 +39,7 @@ struct iterator_on_pivot_row:linear_combination_iterator { } return m_it.next(a, i); } - bool next(unsigned & i) { + bool next(unsigned & i) override { if (m_basis_returned == false) { m_basis_returned = true; i = m_basis_j; @@ -47,11 +47,11 @@ struct iterator_on_pivot_row:linear_combination_iterator { } return m_it.next(i); } - void reset() { + void reset() override { m_basis_returned = false; m_it.reset(); } - linear_combination_iterator * clone() { + linear_combination_iterator * clone() override { iterator_on_pivot_row * r = new iterator_on_pivot_row(m_v, m_basis_j); return r; } diff --git a/src/util/lp/iterator_on_row.h b/src/util/lp/iterator_on_row.h index 1ac5b66bc..55fbda907 100644 --- a/src/util/lp/iterator_on_row.h +++ b/src/util/lp/iterator_on_row.h @@ -26,8 +26,8 @@ struct iterator_on_row:linear_combination_iterator { unsigned m_i; // offset iterator_on_row(const vector> & row) : m_row(row), m_i(0) {} - unsigned size() const { return m_row.size(); } - bool next(T & a, unsigned & i) { + unsigned size() const override { return m_row.size(); } + bool next(T & a, unsigned & i) override { if (m_i == m_row.size()) return false; auto &c = m_row[m_i++]; @@ -35,17 +35,17 @@ struct iterator_on_row:linear_combination_iterator { a = c.get_val(); return true; } - bool next(unsigned & i) { + bool next(unsigned & i) override { if (m_i == m_row.size()) return false; auto &c = m_row[m_i++]; i = c.m_j; return true; } - void reset() { + void reset() override { m_i = 0; } - linear_combination_iterator* clone() { + linear_combination_iterator* clone() override { return new iterator_on_row(m_row); } }; diff --git a/src/util/lp/iterator_on_term_with_basis_var.h b/src/util/lp/iterator_on_term_with_basis_var.h index e566b92b5..85d11cf36 100644 --- a/src/util/lp/iterator_on_term_with_basis_var.h +++ b/src/util/lp/iterator_on_term_with_basis_var.h @@ -27,14 +27,14 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator { std::unordered_map::const_iterator m_i; // the offset in term coeffs bool m_term_j_returned; unsigned m_term_j; - unsigned size() const {return static_cast(m_term.m_coeffs.size() + 1);} + unsigned size() const override {return static_cast(m_term.m_coeffs.size() + 1);} iterator_on_term_with_basis_var(const lar_term & t, unsigned term_j) : m_term(t), m_i(t.m_coeffs.begin()), m_term_j_returned(false), m_term_j(term_j) {} - bool next(mpq & a, unsigned & i) { + bool next(mpq & a, unsigned & i) override { if (m_term_j_returned == false) { m_term_j_returned = true; a = - one_of_type(); @@ -48,7 +48,7 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator { m_i++; return true; } - bool next(unsigned & i) { + bool next(unsigned & i) override { if (m_term_j_returned == false) { m_term_j_returned = true; i = m_term_j; @@ -60,11 +60,11 @@ struct iterator_on_term_with_basis_var:linear_combination_iterator { m_i++; return true; } - void reset() { + void reset() override { m_term_j_returned = false; m_i = m_term.m_coeffs.begin(); } - linear_combination_iterator * clone() { + linear_combination_iterator * clone() override { iterator_on_term_with_basis_var * r = new iterator_on_term_with_basis_var(m_term, m_term_j); return r; } diff --git a/src/util/lp/lar_constraints.h b/src/util/lp/lar_constraints.h index 7b573bab7..9d3a0e0aa 100644 --- a/src/util/lp/lar_constraints.h +++ b/src/util/lp/lar_constraints.h @@ -59,24 +59,24 @@ public: struct lar_var_constraint: public lar_base_constraint { unsigned m_j; - vector> get_left_side_coefficients() const { + vector> get_left_side_coefficients() const override { vector> ret; ret.push_back(std::make_pair(one_of_type(), m_j)); return ret; } - unsigned size() const { return 1;} + unsigned size() const override { return 1;} lar_var_constraint(unsigned j, lconstraint_kind kind, const mpq& right_side) : lar_base_constraint(kind, right_side), m_j(j) { } }; struct lar_term_constraint: public lar_base_constraint { const lar_term * m_term; - vector> get_left_side_coefficients() const { + vector> get_left_side_coefficients() const override { return m_term->coeffs_as_vector(); } - unsigned size() const { return m_term->size();} + unsigned size() const override { return m_term->size();} lar_term_constraint(const lar_term *t, lconstraint_kind kind, const mpq& right_side) : lar_base_constraint(kind, right_side), m_term(t) { } - virtual mpq get_free_coeff_of_left_side() const { return m_term->m_v;} + mpq get_free_coeff_of_left_side() const override { return m_term->m_v;} }; @@ -92,10 +92,10 @@ public: SASSERT(false); // should not be called : todo! } - unsigned size() const { + unsigned size() const override { return static_cast(m_coeffs.size()); } - vector> get_left_side_coefficients() const { return m_coeffs; } + vector> get_left_side_coefficients() const override { return m_coeffs; } }; } diff --git a/src/util/lp/lar_solver.h b/src/util/lp/lar_solver.h index 1f1054bb6..c26333edb 100644 --- a/src/util/lp/lar_solver.h +++ b/src/util/lp/lar_solver.h @@ -1011,7 +1011,7 @@ public: return ret; } - std::string get_column_name(unsigned j) const { + std::string get_column_name(unsigned j) const override { if (j >= m_terms_start_index) return std::string("_t") + T_to_string(j); if (j >= m_columns_to_ext_vars_or_term_indices.size()) diff --git a/src/util/lp/lp_dual_core_solver.h b/src/util/lp/lp_dual_core_solver.h index ba4be494f..7aa572171 100644 --- a/src/util/lp/lp_dual_core_solver.h +++ b/src/util/lp/lp_dual_core_solver.h @@ -207,6 +207,6 @@ public: void solve(); - bool low_bounds_are_set() const { return true; } + bool low_bounds_are_set() const override { return true; } }; } diff --git a/src/util/lp/lp_dual_simplex.h b/src/util/lp/lp_dual_simplex.h index c17a9e99e..15463fc34 100644 --- a/src/util/lp/lp_dual_simplex.h +++ b/src/util/lp/lp_dual_simplex.h @@ -33,7 +33,7 @@ class lp_dual_simplex: public lp_solver { vector m_column_types_of_logicals; vector m_can_enter_basis; public: - ~lp_dual_simplex() { + ~lp_dual_simplex() override { if (m_core_solver != nullptr) { delete m_core_solver; } @@ -84,12 +84,12 @@ public: void copy_m_b_aside_and_set_it_to_zeros(); - void find_maximal_solution(); + void find_maximal_solution() override; - virtual T get_column_value(unsigned column) const { + T get_column_value(unsigned column) const override { return this->get_column_value_with_core_solver(column, m_core_solver); } - T get_current_cost() const; + T get_current_cost() const override; }; } diff --git a/src/util/lp/lp_primal_core_solver.h b/src/util/lp/lp_primal_core_solver.h index a7614862b..139cf3ad5 100644 --- a/src/util/lp/lp_primal_core_solver.h +++ b/src/util/lp/lp_primal_core_solver.h @@ -770,7 +770,7 @@ public: void init_reduced_costs(); - bool low_bounds_are_set() const { return true; } + bool low_bounds_are_set() const override { return true; } int advance_on_sorted_breakpoints(unsigned entering, X & t); diff --git a/src/util/lp/lp_primal_simplex.h b/src/util/lp/lp_primal_simplex.h index d8fd114e4..06ea26f8f 100644 --- a/src/util/lp/lp_primal_simplex.h +++ b/src/util/lp/lp_primal_simplex.h @@ -70,7 +70,7 @@ public: void set_core_solver_bounds(); - void find_maximal_solution(); + void find_maximal_solution() override; void fill_A_x_and_basis_for_stage_one_total_inf(); @@ -79,7 +79,7 @@ public: void solve_with_total_inf(); - ~lp_primal_simplex(); + ~lp_primal_simplex() override; bool bounds_hold(std::unordered_map const & solution); @@ -96,11 +96,11 @@ public: return bounds_hold(solution) && row_constraints_hold(solution); } - virtual T get_column_value(unsigned column) const { + T get_column_value(unsigned column) const override { return this->get_column_value_with_core_solver(column, m_core_solver); } - T get_current_cost() const; + T get_current_cost() const override; }; diff --git a/src/util/lp/lp_settings.h b/src/util/lp/lp_settings.h index a7e6e2665..cd9e78321 100644 --- a/src/util/lp/lp_settings.h +++ b/src/util/lp/lp_settings.h @@ -109,7 +109,7 @@ private: default_lp_resource_limit(lp_settings& s): m_settings(s) { m_sw.start(); } - virtual bool get_cancel_flag() { + bool get_cancel_flag() override { return (m_sw.get_current_seconds() > m_settings.time_limit); } }; diff --git a/src/util/lp/lu.h b/src/util/lp/lu.h index 5498a1849..f9432c323 100644 --- a/src/util/lp/lu.h +++ b/src/util/lp/lu.h @@ -67,7 +67,7 @@ public: #endif } - bool is_dense() const { return false; } + bool is_dense() const override { return false; } one_elem_on_diag(const one_elem_on_diag & o); @@ -83,15 +83,15 @@ public: unsigned row_count() const { return m_m; } // not defined } unsigned column_count() const { return m_m; } // not defined } #endif - void apply_from_left(vector & w, lp_settings &) { + void apply_from_left(vector & w, lp_settings &) override { w[m_i] /= m_val; } - void apply_from_right(vector & w) { + void apply_from_right(vector & w) override { w[m_i] /= m_val; } - void apply_from_right(indexed_vector & w) { + void apply_from_right(indexed_vector & w) override { if (is_zero(w.m_data[m_i])) return; auto & v = w.m_data[m_i] /= m_val; @@ -102,7 +102,7 @@ public: } - void apply_from_left_to_T(indexed_vector & w, lp_settings & settings); + void apply_from_left_to_T(indexed_vector & w, lp_settings & settings) override; void conjugate_by_permutation(permutation_matrix & p) { // this = p * this * p(-1) diff --git a/src/util/lp/permutation_matrix.h b/src/util/lp/permutation_matrix.h index 7cf64a5c7..f080d45b9 100644 --- a/src/util/lp/permutation_matrix.h +++ b/src/util/lp/permutation_matrix.h @@ -64,7 +64,7 @@ class permutation_matrix : public tail_matrix { // create a unit permutation of the given length void init(unsigned length); unsigned get_rev(unsigned i) { return m_rev[i]; } - bool is_dense() const { return false; } + bool is_dense() const override { return false; } #ifdef Z3DEBUG permutation_matrix get_inverse() const { return permutation_matrix(size(), m_rev); @@ -76,13 +76,13 @@ class permutation_matrix : public tail_matrix { unsigned operator[](unsigned i) const { return m_permutation[i]; } - void apply_from_left(vector & w, lp_settings &); + void apply_from_left(vector & w, lp_settings &) override; - void apply_from_left_to_T(indexed_vector & w, lp_settings & settings); + void apply_from_left_to_T(indexed_vector & w, lp_settings & settings) override; - void apply_from_right(vector & w); + void apply_from_right(vector & w) override; - void apply_from_right(indexed_vector & w); + void apply_from_right(indexed_vector & w) override; template void copy_aside(vector & t, vector & tmp_index, indexed_vector & w); diff --git a/src/util/lp/row_eta_matrix.h b/src/util/lp/row_eta_matrix.h index c287e263a..f6fb4537d 100644 --- a/src/util/lp/row_eta_matrix.h +++ b/src/util/lp/row_eta_matrix.h @@ -50,7 +50,7 @@ public: m_row_start(row_start), m_row(row) { } - bool is_dense() const { return false; } + bool is_dense() const override { return false; } void print(std::ostream & out) { print_matrix(*this, out); @@ -60,12 +60,12 @@ public: return m_row_vector.m_data[m_row]; } - void apply_from_left(vector & w, lp_settings &); + void apply_from_left(vector & w, lp_settings &) override; void apply_from_left_local_to_T(indexed_vector & w, lp_settings & settings); void apply_from_left_local_to_X(indexed_vector & w, lp_settings & settings); - void apply_from_left_to_T(indexed_vector & w, lp_settings & settings) { + void apply_from_left_to_T(indexed_vector & w, lp_settings & settings) override { apply_from_left_local_to_T(w, settings); } @@ -74,8 +74,8 @@ public: m_row_vector.push_back(row_index, val); } - void apply_from_right(vector & w); - void apply_from_right(indexed_vector & w); + void apply_from_right(vector & w) override; + void apply_from_right(indexed_vector & w) override; void conjugate_by_permutation(permutation_matrix & p); #ifdef Z3DEBUG diff --git a/src/util/lp/square_dense_submatrix.h b/src/util/lp/square_dense_submatrix.h index 3e88e8114..a2cade85a 100644 --- a/src/util/lp/square_dense_submatrix.h +++ b/src/util/lp/square_dense_submatrix.h @@ -70,7 +70,7 @@ public: void init(sparse_matrix *parent_matrix, unsigned index_start); - bool is_dense() const { return true; } + bool is_dense() const override { return true; } ref operator[] (unsigned i) { SASSERT(i >= m_index_start); @@ -137,13 +137,13 @@ public: bool is_L_matrix() const; - void apply_from_left_to_T(indexed_vector & w, lp_settings & settings) { + void apply_from_left_to_T(indexed_vector & w, lp_settings & settings) override { apply_from_left_local(w, settings); } - void apply_from_right(indexed_vector & w) { + void apply_from_right(indexed_vector & w) override { #if 1==0 indexed_vector wcopy = w; apply_from_right(wcopy.m_data); @@ -207,11 +207,11 @@ public: w = m_work_vector; #endif } - void apply_from_left(vector & w, lp_settings & /*settings*/) { + void apply_from_left(vector & w, lp_settings & /*settings*/) override { apply_from_left_to_vector(w);// , settings); } - void apply_from_right(vector & w); + void apply_from_right(vector & w) override; #ifdef Z3DEBUG T get_elem (unsigned i, unsigned j) const; diff --git a/src/util/mpff.h b/src/util/mpff.h index 4fdd0baef..e34f2cb41 100644 --- a/src/util/mpff.h +++ b/src/util/mpff.h @@ -178,15 +178,15 @@ public: static bool field() { return true; } class exception : public z3_exception { - virtual char const * msg() const { return "multi-precision floating point (mpff) exception"; } + char const * msg() const override { return "multi-precision floating point (mpff) exception"; } }; class overflow_exception : public exception { - virtual char const * msg() const { return "multi-precision floating point (mpff) overflow"; } + char const * msg() const override { return "multi-precision floating point (mpff) overflow"; } }; class div0_exception : public exception { - virtual char const * msg() const { return "multi-precision floating point (mpff) division by zero"; } + char const * msg() const override { return "multi-precision floating point (mpff) division by zero"; } }; mpff_manager(unsigned prec = 2, unsigned initial_capacity = 1024); diff --git a/src/util/mpfx.h b/src/util/mpfx.h index 98f9bb322..03a805f69 100644 --- a/src/util/mpfx.h +++ b/src/util/mpfx.h @@ -125,15 +125,15 @@ public: static bool field() { return true; } class exception : public z3_exception { - virtual char const * msg() const { return "multi-precision fixed point (mpfx) exception"; } + char const * msg() const override { return "multi-precision fixed point (mpfx) exception"; } }; class overflow_exception : public exception { - virtual char const * msg() const { return "multi-precision fixed point (mpfx) overflow"; } + char const * msg() const override { return "multi-precision fixed point (mpfx) overflow"; } }; class div0_exception : public exception { - virtual char const * msg() const { return "multi-precision fixed point (mpfx) division by zero"; } + char const * msg() const override { return "multi-precision fixed point (mpfx) division by zero"; } }; mpfx_manager(unsigned int_sz = 2, unsigned frac_sz = 1, unsigned initial_capacity = 1024); diff --git a/src/util/timeout.cpp b/src/util/timeout.cpp index 67995c2aa..496c5c859 100644 --- a/src/util/timeout.cpp +++ b/src/util/timeout.cpp @@ -32,7 +32,7 @@ void (* g_on_timeout)() = 0; class g_timeout_eh : public event_handler { public: - void operator()(event_handler_caller_t caller_id) { + void operator()(event_handler_caller_t caller_id) override { #pragma omp critical (g_timeout_cs) { std::cout << "timeout\n"; diff --git a/src/util/trail.h b/src/util/trail.h index bba71fb00..adcd57860 100644 --- a/src/util/trail.h +++ b/src/util/trail.h @@ -43,10 +43,10 @@ public: m_old_value(value) { } - virtual ~value_trail() { + ~value_trail() override { } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_value = m_old_value; } }; @@ -59,10 +59,10 @@ public: m_value(value) { } - virtual ~reset_flag_trail() { + ~reset_flag_trail() override { } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_value = false; } }; @@ -76,7 +76,7 @@ public: SASSERT(m_ptr == 0); } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_ptr = 0; } }; @@ -94,9 +94,9 @@ public: m_vector(v), m_old_size(v.size()) { } - virtual ~restore_size_trail() { + ~restore_size_trail() override { } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_vector.shrink(m_old_size); } }; @@ -113,10 +113,10 @@ public: m_old_value(v[idx]) { } - virtual ~vector_value_trail() { + ~vector_value_trail() override { } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_vector[m_idx] = m_old_value; } }; @@ -128,8 +128,8 @@ class insert_obj_map : public trail { D* m_obj; public: insert_obj_map(obj_map& t, D* o) : m_map(t), m_obj(o) {} - virtual ~insert_obj_map() {} - virtual void undo(Ctx & ctx) { m_map.remove(m_obj); } + ~insert_obj_map() override {} + void undo(Ctx & ctx) override { m_map.remove(m_obj); } }; template @@ -138,8 +138,8 @@ class insert_map : public trail { D m_obj; public: insert_map(M& t, D o) : m_map(t), m_obj(o) {} - virtual ~insert_map() {} - virtual void undo(Ctx & ctx) { m_map.remove(m_obj); } + ~insert_map() override {} + void undo(Ctx & ctx) override { m_map.remove(m_obj); } }; @@ -152,7 +152,7 @@ public: m_vector(v) { } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_vector.pop_back(); } }; @@ -167,10 +167,10 @@ public: m_idx(idx) { } - virtual ~set_vector_idx_trail() { + ~set_vector_idx_trail() override { } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_vector[m_idx] = 0; } }; @@ -218,7 +218,7 @@ public: m_vector(v) { } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_vector.pop_back(); } }; @@ -251,7 +251,7 @@ public: m_vector[m_idx] = true; } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { m_vector[m_idx] = false; } }; @@ -264,7 +264,7 @@ public: m_obj(obj) { } - virtual void undo(Ctx & ctx) { + void undo(Ctx & ctx) override { dealloc(m_obj); } }; @@ -288,8 +288,8 @@ class insert_obj_trail : public trail { T* m_obj; public: insert_obj_trail(obj_hashtable& t, T* o) : m_table(t), m_obj(o) {} - virtual ~insert_obj_trail() {} - virtual void undo(Ctx & ctx) { m_table.remove(m_obj); } + ~insert_obj_trail() override {} + void undo(Ctx & ctx) override { m_table.remove(m_obj); } }; diff --git a/src/util/union_find.h b/src/util/union_find.h index 416b653af..9dd0b6fbd 100644 --- a/src/util/union_find.h +++ b/src/util/union_find.h @@ -52,8 +52,8 @@ class union_find { union_find & m_owner; public: mk_var_trail(union_find & o):m_owner(o) {} - virtual ~mk_var_trail() {} - virtual void undo(Ctx & ctx) { + ~mk_var_trail() override {} + void undo(Ctx & ctx) override { m_owner.m_find.pop_back(); m_owner.m_size.pop_back(); m_owner.m_next.pop_back(); @@ -70,8 +70,8 @@ class union_find { unsigned m_r1; public: merge_trail(union_find & o, unsigned r1):m_owner(o), m_r1(r1) {} - virtual ~merge_trail() {} - virtual void undo(Ctx & ctx) { m_owner.unmerge(m_r1); } + ~merge_trail() override {} + void undo(Ctx & ctx) override { m_owner.unmerge(m_r1); } }; void unmerge(unsigned r1) { From 76eb7b9edec29f0583255855d3ff2f89e3ad8d80 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 12 Feb 2018 14:05:55 +0700 Subject: [PATCH 172/263] Use nullptr. --- .../ackermannize_bv_tactic.cpp | 10 +- src/ackermannization/ackr_bound_probe.cpp | 2 +- src/ackermannization/ackr_info.h | 2 +- src/ackermannization/ackr_model_converter.cpp | 4 +- src/ackermannization/lackr.cpp | 8 +- .../lackr_model_constructor.cpp | 14 +- src/api/api_algebraic.cpp | 46 ++-- src/api/api_arith.cpp | 36 +-- src/api/api_array.cpp | 50 ++-- src/api/api_ast.cpp | 104 ++++---- src/api/api_ast_map.cpp | 14 +- src/api/api_ast_vector.cpp | 12 +- src/api/api_bv.cpp | 30 +-- src/api/api_config_params.cpp | 2 +- src/api/api_context.cpp | 20 +- src/api/api_datalog.cpp | 42 +-- src/api/api_datalog.h | 2 +- src/api/api_datalog_spacer.inc | 8 +- src/api/api_datatype.cpp | 74 ++--- src/api/api_fpa.cpp | 252 +++++++++--------- src/api/api_goal.cpp | 10 +- src/api/api_goal.h | 2 +- src/api/api_interp.cpp | 20 +- src/api/api_log.cpp | 16 +- src/api/api_model.cpp | 64 ++--- src/api/api_model.h | 4 +- src/api/api_numeral.cpp | 28 +- src/api/api_opt.cpp | 22 +- src/api/api_params.cpp | 12 +- src/api/api_parsers.cpp | 8 +- src/api/api_pb.cpp | 10 +- src/api/api_polynomial.cpp | 4 +- src/api/api_qe.cpp | 14 +- src/api/api_quant.cpp | 54 ++-- src/api/api_rcf.cpp | 24 +- src/api/api_seq.cpp | 10 +- src/api/api_solver.cpp | 46 ++-- src/api/api_solver.h | 2 +- src/api/api_tactic.cpp | 76 +++--- src/api/api_tactic.h | 4 +- src/api/api_util.h | 4 +- src/api/z3_replayer.cpp | 8 +- src/ast/act_cache.cpp | 4 +- src/ast/arith_decl_plugin.cpp | 114 ++++---- src/ast/array_decl_plugin.cpp | 82 +++--- src/ast/array_decl_plugin.h | 6 +- src/ast/ast.cpp | 224 ++++++++-------- src/ast/ast.h | 106 ++++---- src/ast/ast_ll_pp.cpp | 4 +- src/ast/ast_pp.h | 4 +- src/ast/ast_pp_util.cpp | 2 +- src/ast/ast_printer.cpp | 2 +- src/ast/ast_smt2_pp.cpp | 16 +- src/ast/ast_smt2_pp.h | 6 +- src/ast/ast_smt_pp.cpp | 4 +- src/ast/ast_smt_pp.h | 6 +- src/ast/ast_translation.cpp | 8 +- src/ast/ast_util.cpp | 2 +- src/ast/bv_decl_plugin.cpp | 50 ++-- src/ast/bv_decl_plugin.h | 2 +- src/ast/datatype_decl_plugin.cpp | 44 +-- src/ast/datatype_decl_plugin.h | 6 +- src/ast/dl_decl_plugin.cpp | 152 +++++------ src/ast/dl_decl_plugin.h | 4 +- src/ast/expr2polynomial.cpp | 10 +- src/ast/expr2var.cpp | 2 +- src/ast/expr_abstract.cpp | 2 +- src/ast/expr_delta_pair.h | 2 +- src/ast/expr_functors.cpp | 10 +- src/ast/expr_functors.h | 2 +- src/ast/expr_map.cpp | 6 +- src/ast/expr_substitution.cpp | 6 +- src/ast/expr_substitution.h | 6 +- src/ast/factor_equivs.cpp | 4 +- src/ast/format.cpp | 10 +- src/ast/fpa/bv2fpa_converter.cpp | 12 +- src/ast/fpa/bv2fpa_converter.h | 2 +- src/ast/fpa/fpa2bv_converter.cpp | 20 +- src/ast/fpa/fpa2bv_rewriter.cpp | 4 +- src/ast/fpa_decl_plugin.cpp | 24 +- src/ast/fpa_decl_plugin.h | 2 +- src/ast/func_decl_dependencies.cpp | 4 +- src/ast/func_decl_dependencies.h | 2 +- src/ast/macro_substitution.cpp | 6 +- src/ast/macro_substitution.h | 2 +- src/ast/macros/macro_finder.cpp | 18 +- src/ast/macros/macro_manager.cpp | 16 +- src/ast/macros/macro_manager.h | 4 +- src/ast/macros/macro_util.cpp | 32 +-- src/ast/macros/macro_util.h | 2 +- src/ast/macros/quasi_macros.cpp | 12 +- src/ast/normal_forms/defined_names.cpp | 2 +- src/ast/normal_forms/name_exprs.cpp | 6 +- src/ast/normal_forms/nnf.cpp | 26 +- src/ast/normal_forms/pull_quant.cpp | 12 +- src/ast/pattern/expr_pattern_match.cpp | 2 +- src/ast/pattern/expr_pattern_match.h | 4 +- src/ast/pattern/pattern_inference.cpp | 22 +- src/ast/pattern/pattern_inference.h | 2 +- src/ast/pb_decl_plugin.cpp | 6 +- src/ast/pb_decl_plugin.h | 2 +- src/ast/proofs/proof_checker.cpp | 20 +- src/ast/proofs/proof_utils.cpp | 10 +- src/ast/recurse_expr_def.h | 2 +- src/ast/rewriter/arith_rewriter.cpp | 10 +- src/ast/rewriter/bit2int.cpp | 2 +- src/ast/rewriter/bit2int.h | 2 +- .../bit_blaster/bit_blaster_rewriter.cpp | 10 +- src/ast/rewriter/bool_rewriter.cpp | 2 +- src/ast/rewriter/bool_rewriter.h | 2 +- src/ast/rewriter/bv_bounds.cpp | 10 +- src/ast/rewriter/bv_bounds.h | 2 +- src/ast/rewriter/bv_elim.cpp | 2 +- src/ast/rewriter/bv_rewriter.cpp | 18 +- src/ast/rewriter/bv_trailing.cpp | 22 +- src/ast/rewriter/der.cpp | 12 +- src/ast/rewriter/distribute_forall.h | 2 +- src/ast/rewriter/elim_bounds.cpp | 22 +- src/ast/rewriter/enum2bv_rewriter.cpp | 4 +- src/ast/rewriter/expr_replacer.cpp | 12 +- src/ast/rewriter/expr_safe_replace.cpp | 2 +- src/ast/rewriter/factor_rewriter.h | 2 +- src/ast/rewriter/fpa_rewriter.cpp | 6 +- src/ast/rewriter/inj_axiom.cpp | 8 +- src/ast/rewriter/maximize_ac_sharing.cpp | 4 +- src/ast/rewriter/maximize_ac_sharing.h | 2 +- src/ast/rewriter/mk_extract_proc.cpp | 4 +- src/ast/rewriter/mk_simplified_app.cpp | 2 +- src/ast/rewriter/pb2bv_rewriter.cpp | 2 +- src/ast/rewriter/poly_rewriter.h | 2 +- src/ast/rewriter/poly_rewriter_def.h | 22 +- src/ast/rewriter/pull_ite_tree.cpp | 34 +-- src/ast/rewriter/push_app_ite.cpp | 2 +- src/ast/rewriter/rewriter.cpp | 10 +- src/ast/rewriter/rewriter_def.h | 58 ++-- src/ast/rewriter/seq_rewriter.cpp | 28 +- src/ast/rewriter/th_rewriter.cpp | 28 +- src/ast/rewriter/var_subst.cpp | 4 +- src/ast/seq_decl_plugin.cpp | 32 +-- src/ast/seq_decl_plugin.h | 4 +- src/ast/substitution/expr_offset.h | 2 +- src/ast/substitution/substitution.cpp | 12 +- src/ast/substitution/substitution.h | 2 +- src/ast/substitution/substitution_tree.cpp | 18 +- src/ast/substitution/substitution_tree.h | 2 +- src/cmd_context/basic_cmds.cpp | 8 +- src/cmd_context/check_logic.cpp | 10 +- src/cmd_context/cmd_context.cpp | 128 ++++----- src/cmd_context/cmd_context.h | 14 +- src/cmd_context/cmd_context_to_goal.cpp | 4 +- src/cmd_context/context_params.cpp | 4 +- src/cmd_context/eval_cmd.cpp | 4 +- src/cmd_context/extra_cmds/dbg_cmds.cpp | 10 +- .../extra_cmds/polynomial_cmds.cpp | 16 +- src/cmd_context/interpolant_cmds.cpp | 4 +- src/cmd_context/parametric_cmd.cpp | 2 +- src/cmd_context/parametric_cmd.h | 2 +- src/cmd_context/pdecl.cpp | 56 ++-- src/cmd_context/pdecl.h | 10 +- src/cmd_context/simplify_cmd.cpp | 8 +- src/cmd_context/tactic_cmds.cpp | 20 +- src/cmd_context/tactic_manager.cpp | 4 +- src/duality/duality.h | 36 +-- src/duality/duality_profiling.cpp | 2 +- src/duality/duality_rpfp.cpp | 14 +- src/duality/duality_solver.cpp | 42 +-- src/duality/duality_wrapper.cpp | 16 +- src/duality/duality_wrapper.h | 24 +- src/interp/iz3base.cpp | 4 +- src/interp/iz3checker.cpp | 4 +- src/interp/iz3hash.h | 18 +- src/interp/iz3interp.cpp | 12 +- src/interp/iz3interp.h | 4 +- src/interp/iz3mgr.cpp | 14 +- src/interp/iz3mgr.h | 6 +- src/interp/iz3profiling.cpp | 2 +- src/interp/iz3proof.h | 2 +- src/interp/iz3translate.cpp | 2 +- src/interp/iz3translate_direct.cpp | 12 +- src/math/automata/automaton.h | 8 +- src/math/automata/symbolic_automata_def.h | 2 +- src/math/euclid/euclidean_solver.cpp | 8 +- src/math/grobner/grobner.cpp | 22 +- src/math/grobner/grobner.h | 10 +- src/math/hilbert/heap_trie.h | 8 +- src/math/hilbert/hilbert_basis.cpp | 4 +- src/math/polynomial/algebraic_numbers.cpp | 22 +- src/math/polynomial/algebraic_numbers.h | 4 +- src/math/polynomial/polynomial.cpp | 60 ++--- src/math/polynomial/polynomial.h | 4 +- src/math/polynomial/polynomial_cache.cpp | 4 +- src/math/polynomial/rpolynomial.cpp | 54 ++-- src/math/polynomial/rpolynomial.h | 2 +- src/math/polynomial/upolynomial.cpp | 2 +- src/math/polynomial/upolynomial.h | 2 +- src/math/realclosure/mpz_matrix.cpp | 8 +- src/math/realclosure/mpz_matrix.h | 2 +- src/math/realclosure/realclosure.cpp | 134 +++++----- src/math/realclosure/realclosure.h | 4 +- src/math/simplex/simplex_def.h | 2 +- src/math/simplex/sparse_matrix_def.h | 2 +- src/math/subpaving/subpaving.h | 10 +- src/math/subpaving/subpaving_t.h | 20 +- src/math/subpaving/subpaving_t_def.h | 142 +++++----- src/math/subpaving/tactic/expr2subpaving.cpp | 6 +- src/math/subpaving/tactic/expr2subpaving.h | 2 +- .../subpaving/tactic/subpaving_tactic.cpp | 12 +- src/model/func_interp.cpp | 26 +- src/model/func_interp.h | 2 +- src/model/model.cpp | 10 +- src/model/model_core.cpp | 2 +- src/model/model_core.h | 4 +- src/model/model_evaluator.cpp | 16 +- src/model/model_implicant.cpp | 6 +- src/muz/base/dl_boogie_proof.h | 2 +- src/muz/base/dl_context.cpp | 30 +-- src/muz/base/dl_context.h | 4 +- src/muz/base/dl_costs.cpp | 4 +- src/muz/base/dl_costs.h | 4 +- src/muz/base/dl_rule.cpp | 16 +- src/muz/base/dl_rule.h | 6 +- src/muz/base/dl_rule_set.cpp | 10 +- src/muz/base/dl_rule_transformer.h | 2 +- src/muz/base/dl_util.cpp | 8 +- src/muz/base/hnf.cpp | 14 +- src/muz/bmc/dl_bmc_engine.cpp | 24 +- src/muz/clp/clp_context.cpp | 2 +- src/muz/ddnf/ddnf.cpp | 12 +- src/muz/duality/duality_dl_interface.cpp | 10 +- src/muz/fp/datalog_parser.cpp | 42 +-- src/muz/fp/dl_cmds.cpp | 20 +- src/muz/fp/dl_register_engine.cpp | 6 +- src/muz/fp/horn_tactic.cpp | 8 +- src/muz/pdr/pdr_closure.h | 4 +- src/muz/pdr/pdr_context.cpp | 44 +-- src/muz/pdr/pdr_context.h | 10 +- src/muz/pdr/pdr_dl_interface.cpp | 2 +- src/muz/pdr/pdr_farkas_learner.cpp | 2 +- src/muz/pdr/pdr_generalizers.cpp | 10 +- src/muz/pdr/pdr_manager.h | 2 +- src/muz/pdr/pdr_prop_solver.cpp | 14 +- src/muz/pdr/pdr_reachable_cache.cpp | 2 +- src/muz/pdr/pdr_smt_context_manager.cpp | 2 +- src/muz/pdr/pdr_sym_mux.h | 4 +- src/muz/pdr/pdr_util.cpp | 2 +- src/muz/rel/aig_exporter.cpp | 4 +- src/muz/rel/aig_exporter.h | 4 +- src/muz/rel/check_relation.cpp | 34 +-- src/muz/rel/dl_base.cpp | 4 +- src/muz/rel/dl_base.h | 44 +-- src/muz/rel/dl_bound_relation.cpp | 28 +- src/muz/rel/dl_bound_relation.h | 2 +- src/muz/rel/dl_check_table.cpp | 30 +-- src/muz/rel/dl_check_table.h | 2 +- src/muz/rel/dl_compiler.cpp | 6 +- src/muz/rel/dl_compiler.h | 4 +- src/muz/rel/dl_external_relation.cpp | 30 +-- src/muz/rel/dl_finite_product_relation.cpp | 48 ++-- src/muz/rel/dl_instruction.cpp | 14 +- src/muz/rel/dl_instruction.h | 6 +- src/muz/rel/dl_interval_relation.cpp | 48 ++-- src/muz/rel/dl_lazy_table.cpp | 28 +- src/muz/rel/dl_lazy_table.h | 2 +- src/muz/rel/dl_mk_explanations.cpp | 40 +-- src/muz/rel/dl_mk_similarity_compressor.cpp | 2 +- src/muz/rel/dl_mk_simple_joins.cpp | 16 +- src/muz/rel/dl_product_relation.cpp | 42 +-- src/muz/rel/dl_relation_manager.cpp | 48 ++-- src/muz/rel/dl_relation_manager.h | 8 +- src/muz/rel/dl_sieve_relation.cpp | 70 ++--- src/muz/rel/dl_sparse_table.cpp | 30 +-- src/muz/rel/dl_table.cpp | 2 +- src/muz/rel/dl_table_relation.cpp | 40 +-- src/muz/rel/doc.cpp | 2 +- src/muz/rel/doc.h | 6 +- src/muz/rel/karr_relation.cpp | 28 +- src/muz/rel/rel_context.cpp | 4 +- src/muz/rel/tbv.h | 4 +- src/muz/rel/udoc_relation.cpp | 24 +- src/muz/rel/udoc_relation.h | 2 +- src/muz/spacer/spacer_antiunify.cpp | 2 +- src/muz/spacer/spacer_context.cpp | 80 +++--- src/muz/spacer/spacer_context.h | 18 +- src/muz/spacer/spacer_dl_interface.cpp | 2 +- src/muz/spacer/spacer_generalizers.cpp | 2 +- src/muz/spacer/spacer_itp_solver.cpp | 2 +- src/muz/spacer/spacer_legacy_mev.cpp | 2 +- src/muz/spacer/spacer_prop_solver.cpp | 12 +- src/muz/spacer/spacer_prop_solver.h | 2 +- src/muz/spacer/spacer_qe_project.cpp | 48 ++-- src/muz/spacer/spacer_smt_context_manager.cpp | 2 +- src/muz/spacer/spacer_sym_mux.h | 4 +- src/muz/spacer/spacer_unsat_core_plugin.cpp | 6 +- src/muz/spacer/spacer_util.cpp | 8 +- src/muz/spacer/spacer_util.h | 2 +- src/muz/spacer/spacer_virtual_solver.cpp | 4 +- src/muz/tab/tab_context.cpp | 2 +- src/muz/transforms/dl_mk_array_blast.cpp | 6 +- src/muz/transforms/dl_mk_bit_blast.cpp | 10 +- src/muz/transforms/dl_mk_coi_filter.cpp | 6 +- src/muz/transforms/dl_mk_filter_rules.cpp | 6 +- .../dl_mk_interp_tail_simplifier.cpp | 24 +- .../transforms/dl_mk_interp_tail_simplifier.h | 2 +- src/muz/transforms/dl_mk_karr_invariants.cpp | 14 +- src/muz/transforms/dl_mk_loop_counter.cpp | 2 +- src/muz/transforms/dl_mk_magic_sets.cpp | 16 +- src/muz/transforms/dl_mk_magic_symbolic.cpp | 4 +- .../dl_mk_quantifier_abstraction.cpp | 18 +- .../dl_mk_quantifier_instantiation.cpp | 12 +- src/muz/transforms/dl_mk_rule_inliner.cpp | 20 +- src/muz/transforms/dl_mk_rule_inliner.h | 2 +- src/muz/transforms/dl_mk_scale.cpp | 4 +- .../dl_mk_separate_negated_tails.cpp | 2 +- src/muz/transforms/dl_mk_slice.cpp | 22 +- .../transforms/dl_mk_subsumption_checker.cpp | 6 +- .../transforms/dl_mk_unbound_compressor.cpp | 4 +- src/nlsat/nlsat_explain.cpp | 24 +- src/nlsat/nlsat_interval_set.cpp | 22 +- src/nlsat/nlsat_interval_set.h | 4 +- src/nlsat/nlsat_justification.h | 4 +- src/nlsat/nlsat_solver.cpp | 58 ++-- src/nlsat/nlsat_solver.h | 2 +- src/nlsat/tactic/goal2nlsat.cpp | 4 +- src/nlsat/tactic/nlsat_tactic.cpp | 14 +- src/opt/maxres.cpp | 16 +- src/opt/maxsmt.cpp | 4 +- src/opt/opt_cmds.cpp | 4 +- src/opt/opt_cmds.h | 2 +- src/opt/opt_context.cpp | 14 +- src/opt/opt_context.h | 6 +- src/opt/opt_pareto.cpp | 6 +- src/opt/opt_solver.cpp | 8 +- src/opt/optsmt.cpp | 18 +- src/opt/optsmt.h | 2 +- src/opt/sortmax.cpp | 2 +- src/opt/wmax.cpp | 6 +- src/parsers/smt2/marshal.cpp | 2 +- src/parsers/smt2/smt2parser.cpp | 114 ++++---- src/parsers/smt2/smt2parser.h | 2 +- src/parsers/util/simple_parser.cpp | 6 +- src/qe/nlarith_util.cpp | 14 +- src/qe/nlqsat.cpp | 6 +- src/qe/qe.cpp | 52 ++-- src/qe/qe.h | 2 +- src/qe/qe_arith.cpp | 2 +- src/qe/qe_arith_plugin.cpp | 24 +- src/qe/qe_arrays.cpp | 2 +- src/qe/qe_bool_plugin.cpp | 2 +- src/qe/qe_bv_plugin.cpp | 2 +- src/qe/qe_cmd.cpp | 4 +- src/qe/qe_datatype_plugin.cpp | 20 +- src/qe/qe_dl_plugin.cpp | 6 +- src/qe/qe_lite.cpp | 32 +-- src/qe/qe_mbp.cpp | 2 +- src/qe/qe_sat_tactic.cpp | 8 +- src/qe/qe_tactic.cpp | 4 +- src/qe/qsat.cpp | 10 +- src/sat/sat_clause.cpp | 2 +- src/sat/sat_clause.h | 2 +- src/sat/sat_probing.cpp | 2 +- src/sat/sat_probing.h | 6 +- src/sat/sat_simplifier.cpp | 6 +- src/sat/sat_solver.cpp | 14 +- src/sat/sat_solver.h | 2 +- src/sat/sat_solver/inc_sat_solver.cpp | 18 +- src/sat/tactic/goal2sat.cpp | 12 +- src/sat/tactic/sat_tactic.cpp | 12 +- src/shell/datalog_frontend.cpp | 4 +- src/shell/dimacs_frontend.cpp | 6 +- src/shell/lp_frontend.cpp | 6 +- src/shell/main.cpp | 10 +- src/shell/opt_frontend.cpp | 6 +- src/shell/smtlib_frontend.cpp | 4 +- src/smt/arith_eq_adapter.cpp | 4 +- src/smt/arith_eq_adapter.h | 2 +- src/smt/asserted_formulas.cpp | 14 +- src/smt/cached_var_subst.cpp | 4 +- src/smt/dyn_ack.cpp | 6 +- src/smt/expr_context_simplifier.cpp | 10 +- src/smt/fingerprints.cpp | 6 +- src/smt/mam.cpp | 120 ++++----- src/smt/old_interval.cpp | 58 ++-- src/smt/old_interval.h | 2 +- src/smt/params/qi_params.h | 2 +- src/smt/proto_model/array_factory.cpp | 12 +- src/smt/proto_model/datatype_factory.cpp | 14 +- src/smt/proto_model/proto_model.cpp | 10 +- src/smt/proto_model/struct_factory.cpp | 2 +- src/smt/proto_model/value_factory.cpp | 14 +- src/smt/proto_model/value_factory.h | 14 +- src/smt/qi_queue.cpp | 2 +- src/smt/smt2_extra_cmds.cpp | 4 +- src/smt/smt_almost_cg_table.cpp | 6 +- src/smt/smt_almost_cg_table.h | 2 +- src/smt/smt_b_justification.h | 2 +- src/smt/smt_case_split_queue.cpp | 8 +- src/smt/smt_cg_table.h | 10 +- src/smt/smt_checker.cpp | 18 +- src/smt/smt_checker.h | 4 +- src/smt/smt_clause.cpp | 8 +- src/smt/smt_clause.h | 10 +- src/smt/smt_conflict_resolution.cpp | 58 ++-- src/smt/smt_consequences.cpp | 2 +- src/smt/smt_context.cpp | 70 ++--- src/smt/smt_context.h | 24 +- src/smt/smt_enode.cpp | 12 +- src/smt/smt_enode.h | 6 +- src/smt/smt_eq_justification.h | 2 +- src/smt/smt_implied_equalities.cpp | 16 +- src/smt/smt_internalizer.cpp | 26 +- src/smt/smt_justification.cpp | 34 +-- src/smt/smt_justification.h | 16 +- src/smt/smt_kernel.h | 2 +- src/smt/smt_model_checker.cpp | 28 +- src/smt/smt_model_finder.cpp | 126 ++++----- src/smt/smt_model_generator.cpp | 24 +- src/smt/smt_model_generator.h | 4 +- src/smt/smt_quantifier.cpp | 8 +- src/smt/smt_quantifier_stat.h | 2 +- src/smt/smt_quick_checker.cpp | 6 +- src/smt/smt_quick_checker.h | 2 +- src/smt/smt_relevancy.cpp | 18 +- src/smt/smt_solver.cpp | 2 +- src/smt/smt_theory.cpp | 4 +- src/smt/smt_theory.h | 6 +- src/smt/smt_theory_var_list.h | 4 +- src/smt/tactic/ctx_solver_simplify_tactic.cpp | 8 +- src/smt/tactic/smt_tactic.cpp | 16 +- src/smt/theory_arith.h | 18 +- src/smt/theory_arith_aux.h | 18 +- src/smt/theory_arith_core.h | 38 +-- src/smt/theory_arith_eq.h | 2 +- src/smt/theory_arith_int.h | 22 +- src/smt/theory_arith_nl.h | 72 ++--- src/smt/theory_arith_pp.h | 4 +- src/smt/theory_array_base.cpp | 32 +-- src/smt/theory_array_full.cpp | 2 +- src/smt/theory_bv.cpp | 6 +- src/smt/theory_bv.h | 4 +- src/smt/theory_datatype.cpp | 30 +-- src/smt/theory_datatype.h | 2 +- src/smt/theory_dense_diff_logic_def.h | 2 +- src/smt/theory_diff_logic.h | 4 +- src/smt/theory_diff_logic_def.h | 14 +- src/smt/theory_dl.cpp | 8 +- src/smt/theory_fpa.cpp | 10 +- src/smt/theory_lra.cpp | 34 +-- src/smt/theory_pb.cpp | 42 +-- src/smt/theory_pb.h | 6 +- src/smt/theory_seq.cpp | 182 ++++++------- src/smt/theory_seq.h | 6 +- src/smt/theory_seq_empty.h | 10 +- src/smt/theory_str.cpp | 186 ++++++------- src/smt/theory_str.h | 6 +- src/smt/theory_utvpi.h | 2 +- src/smt/theory_utvpi_def.h | 6 +- src/smt/theory_wmaxsat.cpp | 4 +- src/smt/theory_wmaxsat.h | 2 +- src/smt/watch_list.cpp | 2 +- src/smt/watch_list.h | 10 +- src/solver/check_sat_result.cpp | 4 +- src/solver/mus.cpp | 4 +- src/solver/solver.cpp | 4 +- src/solver/solver2tactic.cpp | 12 +- src/solver/solver_na2as.cpp | 2 +- src/solver/tactic2solver.cpp | 12 +- src/solver/tactic2solver.h | 2 +- src/tactic/aig/aig.cpp | 32 +-- src/tactic/aig/aig_tactic.cpp | 8 +- src/tactic/arith/add_bounds_tactic.cpp | 2 +- src/tactic/arith/arith_bounds_tactic.cpp | 2 +- src/tactic/arith/bound_manager.cpp | 10 +- src/tactic/arith/bound_manager.h | 6 +- src/tactic/arith/bound_propagator.cpp | 14 +- src/tactic/arith/bv2int_rewriter.cpp | 6 +- src/tactic/arith/bv2int_rewriter.h | 2 +- src/tactic/arith/bv2real_rewriter.h | 4 +- src/tactic/arith/card2bv_tactic.cpp | 2 +- src/tactic/arith/card2bv_tactic.h | 2 +- src/tactic/arith/degree_shift_tactic.cpp | 14 +- src/tactic/arith/diff_neq_tactic.cpp | 2 +- src/tactic/arith/elim01_tactic.cpp | 2 +- src/tactic/arith/eq2bv_tactic.cpp | 6 +- src/tactic/arith/factor_tactic.cpp | 2 +- src/tactic/arith/fix_dl_var_tactic.cpp | 10 +- src/tactic/arith/fm_tactic.cpp | 32 +-- src/tactic/arith/lia2card_tactic.cpp | 4 +- src/tactic/arith/lia2pb_tactic.cpp | 16 +- src/tactic/arith/linear_equation.cpp | 4 +- src/tactic/arith/nla2bv_tactic.cpp | 8 +- src/tactic/arith/normalize_bounds_tactic.cpp | 8 +- src/tactic/arith/pb2bv_model_converter.cpp | 4 +- src/tactic/arith/pb2bv_tactic.cpp | 14 +- src/tactic/arith/propagate_ineqs_tactic.cpp | 12 +- src/tactic/arith/purify_arith_tactic.cpp | 14 +- src/tactic/arith/recover_01_tactic.cpp | 16 +- src/tactic/bv/bit_blaster_model_converter.cpp | 4 +- src/tactic/bv/bit_blaster_tactic.cpp | 8 +- src/tactic/bv/bv1_blaster_tactic.cpp | 6 +- src/tactic/bv/bv_bound_chk_tactic.cpp | 4 +- src/tactic/bv/bv_bounds_tactic.cpp | 6 +- src/tactic/bv/bv_size_reduction_tactic.cpp | 22 +- src/tactic/bv/bvarray2uf_rewriter.cpp | 8 +- src/tactic/bv/bvarray2uf_tactic.cpp | 2 +- src/tactic/bv/dt2bv_tactic.cpp | 2 +- src/tactic/bv/elim_small_bv_tactic.cpp | 10 +- src/tactic/bv/max_bv_sharing_tactic.cpp | 14 +- src/tactic/converter.h | 4 +- src/tactic/core/blast_term_ite_tactic.cpp | 2 +- src/tactic/core/cofactor_elim_term_ite.cpp | 28 +- src/tactic/core/cofactor_term_ite_tactic.cpp | 4 +- src/tactic/core/collect_statistics_tactic.cpp | 2 +- src/tactic/core/ctx_simplify_tactic.cpp | 24 +- src/tactic/core/der_tactic.cpp | 2 +- src/tactic/core/distribute_forall_tactic.cpp | 6 +- src/tactic/core/dom_simplify_tactic.cpp | 22 +- src/tactic/core/dom_simplify_tactic.h | 2 +- src/tactic/core/elim_term_ite_tactic.cpp | 8 +- src/tactic/core/elim_uncnstr_tactic.cpp | 84 +++--- src/tactic/core/injectivity_tactic.cpp | 2 +- src/tactic/core/nnf_tactic.cpp | 10 +- src/tactic/core/occf_tactic.cpp | 30 +-- src/tactic/core/pb_preprocess_tactic.cpp | 14 +- src/tactic/core/propagate_values_tactic.cpp | 8 +- src/tactic/core/reduce_args_tactic.cpp | 12 +- src/tactic/core/simplify_tactic.cpp | 2 +- src/tactic/core/solve_eqs_tactic.cpp | 34 +-- src/tactic/core/solve_eqs_tactic.h | 2 +- src/tactic/core/split_clause_tactic.cpp | 4 +- src/tactic/core/symmetry_reduce_tactic.cpp | 14 +- src/tactic/core/tseitin_cnf_tactic.cpp | 16 +- src/tactic/fpa/fpa2bv_model_converter.h | 2 +- src/tactic/fpa/fpa2bv_tactic.cpp | 2 +- src/tactic/goal.cpp | 14 +- src/tactic/goal.h | 8 +- src/tactic/model_converter.cpp | 14 +- src/tactic/nlsat_smt/nl_purify_tactic.cpp | 18 +- .../portfolio/bounded_int2bv_solver.cpp | 2 +- src/tactic/portfolio/enum2bv_solver.cpp | 4 +- src/tactic/portfolio/smt_strategic_solver.cpp | 2 +- src/tactic/probe.cpp | 6 +- src/tactic/proof_converter.cpp | 12 +- src/tactic/replace_proof_converter.cpp | 2 +- src/tactic/sine_filter.cpp | 4 +- src/tactic/sls/bvsls_opt_engine.cpp | 2 +- src/tactic/sls/sls_engine.cpp | 4 +- src/tactic/sls/sls_tactic.cpp | 2 +- src/tactic/sls/sls_tracker.h | 12 +- src/tactic/smtlogics/qfufbv_tactic.cpp | 4 +- src/tactic/tactic.cpp | 14 +- src/tactic/tactical.cpp | 80 +++--- src/tactic/ufbv/macro_finder_tactic.cpp | 6 +- src/tactic/ufbv/quasi_macros_tactic.cpp | 6 +- src/tactic/ufbv/ufbv_rewriter_tactic.cpp | 6 +- src/test/check_assumptions.cpp | 12 +- src/test/cnf_backbones.cpp | 6 +- src/test/ddnf.cpp | 2 +- src/test/escaped.cpp | 4 +- src/test/expr_rand.cpp | 4 +- src/test/fuzzing/expr_rand.cpp | 90 +++---- src/test/get_consequences.cpp | 12 +- src/test/hilbert_basis.cpp | 2 +- src/test/list.cpp | 8 +- src/test/main.cpp | 6 +- src/test/nlsat.cpp | 2 +- src/test/old_interval.cpp | 6 +- src/test/pb2bv.cpp | 4 +- src/test/pdr.cpp | 2 +- src/test/polynorm.cpp | 2 +- src/test/sat_user_scope.cpp | 4 +- src/test/smt2print_parse.cpp | 20 +- src/test/sorting_network.cpp | 2 +- src/test/theory_pb.cpp | 4 +- src/test/udoc_relation.cpp | 10 +- src/test/var_subst.cpp | 2 +- src/util/array.h | 6 +- src/util/bit_vector.h | 4 +- src/util/chashtable.h | 54 ++-- src/util/cmd_context_types.h | 4 +- src/util/cooperate.cpp | 2 +- src/util/debug.cpp | 8 +- src/util/dependency.h | 6 +- src/util/file_path.h | 8 +- src/util/gparams.cpp | 30 +-- src/util/hashtable.h | 22 +- src/util/list.h | 4 +- src/util/lp/lar_core_solver.h | 2 +- src/util/map.h | 4 +- src/util/memory_manager.cpp | 4 +- src/util/memory_manager.h | 6 +- src/util/mpfx.cpp | 2 +- src/util/mpz.h | 12 +- src/util/obj_hashtable.h | 16 +- src/util/obj_pair_hashtable.h | 14 +- src/util/obj_ref.h | 10 +- src/util/obj_triple_hashtable.h | 12 +- src/util/optional.h | 8 +- src/util/page.cpp | 2 +- src/util/params.cpp | 22 +- src/util/params.h | 6 +- src/util/parray.h | 22 +- src/util/plugin_manager.h | 2 +- src/util/prime_generator.cpp | 2 +- src/util/prime_generator.h | 2 +- src/util/rational.cpp | 4 +- src/util/ref.h | 8 +- src/util/region.cpp | 20 +- src/util/s_integer.cpp | 2 +- src/util/scoped_ctrl_c.cpp | 2 +- src/util/scoped_ptr_vector.h | 4 +- src/util/scoped_timer.cpp | 8 +- src/util/small_object_allocator.cpp | 28 +- src/util/smt2_util.cpp | 2 +- src/util/stack.cpp | 8 +- src/util/symbol.cpp | 12 +- src/util/symbol.h | 8 +- src/util/symbol_table.h | 4 +- src/util/timeit.cpp | 2 +- src/util/timeout.cpp | 6 +- src/util/trace.cpp | 4 +- src/util/trail.h | 2 +- src/util/util.cpp | 4 +- src/util/util.h | 6 +- src/util/vector.h | 30 +-- src/util/warning.cpp | 4 +- 625 files changed, 4639 insertions(+), 4639 deletions(-) mode change 100755 => 100644 src/duality/duality_profiling.cpp mode change 100755 => 100644 src/duality/duality_rpfp.cpp mode change 100755 => 100644 src/duality/duality_wrapper.cpp mode change 100755 => 100644 src/interp/iz3base.cpp mode change 100755 => 100644 src/interp/iz3checker.cpp mode change 100755 => 100644 src/interp/iz3interp.cpp mode change 100755 => 100644 src/interp/iz3mgr.cpp mode change 100755 => 100644 src/interp/iz3mgr.h mode change 100755 => 100644 src/interp/iz3profiling.cpp mode change 100755 => 100644 src/interp/iz3proof.h mode change 100755 => 100644 src/interp/iz3translate.cpp mode change 100755 => 100644 src/interp/iz3translate_direct.cpp mode change 100755 => 100644 src/muz/duality/duality_dl_interface.cpp diff --git a/src/ackermannization/ackermannize_bv_tactic.cpp b/src/ackermannization/ackermannize_bv_tactic.cpp index 5d749b7d5..73034622e 100644 --- a/src/ackermannization/ackermannize_bv_tactic.cpp +++ b/src/ackermannization/ackermannize_bv_tactic.cpp @@ -34,7 +34,7 @@ public: model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override { - mc = 0; + mc = nullptr; tactic_report report("ackermannize", *g); fail_if_unsat_core_generation("ackermannize", g); fail_if_proof_generation("ackermannize", g); @@ -43,7 +43,7 @@ public: expr_ref_vector flas(m); const unsigned sz = g->size(); for (unsigned i = 0; i < sz; i++) flas.push_back(g->form(i)); - lackr lackr(m, m_p, m_st, flas, NULL); + lackr lackr(m, m_p, m_st, flas, nullptr); // mk result goal_ref resg(alloc(goal, *g, true)); @@ -52,9 +52,9 @@ public: TRACE("ackermannize", tout << "ackermannize not run due to limit" << std::endl;); result.reset(); result.push_back(g.get()); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; return; } result.push_back(resg.get()); diff --git a/src/ackermannization/ackr_bound_probe.cpp b/src/ackermannization/ackr_bound_probe.cpp index f5e072368..c6cdaf268 100644 --- a/src/ackermannization/ackr_bound_probe.cpp +++ b/src/ackermannization/ackr_bound_probe.cpp @@ -45,7 +45,7 @@ class ackr_bound_probe : public probe { if (a->get_num_args() == 0) return; if (!m_ackr_helper.should_ackermannize(a)) return; func_decl* const fd = a->get_decl(); - app_set* ts = 0; + app_set* ts = nullptr; if (!m_fun2terms.find(fd, ts)) { ts = alloc(app_set); m_fun2terms.insert(fd, ts); diff --git a/src/ackermannization/ackr_info.h b/src/ackermannization/ackr_info.h index 0b67e144f..db5f64a70 100644 --- a/src/ackermannization/ackr_info.h +++ b/src/ackermannization/ackr_info.h @@ -65,7 +65,7 @@ class ackr_info { } inline app* find_term(func_decl* c) const { - app * rv = 0; + app * rv = nullptr; m_c2t.find(c,rv); return rv; } diff --git a/src/ackermannization/ackr_model_converter.cpp b/src/ackermannization/ackr_model_converter.cpp index c8df89bad..f5b90de1b 100644 --- a/src/ackermannization/ackr_model_converter.cpp +++ b/src/ackermannization/ackr_model_converter.cpp @@ -116,7 +116,7 @@ void ackr_model_converter::add_entry(model_evaluator & evaluator, << mk_ismt2_pp(value, m, 2) << "\n"; ); - func_interp * fi = 0; + func_interp * fi = nullptr; func_decl * const declaration = term->get_decl(); const unsigned sz = declaration->get_arity(); SASSERT(sz == term->get_num_args()); @@ -133,7 +133,7 @@ void ackr_model_converter::add_entry(model_evaluator & evaluator, evaluator(aarg, arg_value); args.push_back(arg_value); } - if (fi->get_entry(args.c_ptr()) == 0) { + if (fi->get_entry(args.c_ptr()) == nullptr) { TRACE("ackr_model", tout << mk_ismt2_pp(declaration, m) << " args: " << std::endl; for (unsigned i = 0; i < args.size(); i++) diff --git a/src/ackermannization/lackr.cpp b/src/ackermannization/lackr.cpp index aac98d7dc..b739af9d3 100644 --- a/src/ackermannization/lackr.cpp +++ b/src/ackermannization/lackr.cpp @@ -185,7 +185,7 @@ void lackr::add_term(app* a) { if (a->get_num_args() == 0) return; if (!m_ackr_helper.should_ackermannize(a)) return; func_decl* const fd = a->get_decl(); - app_set* ts = 0; + app_set* ts = nullptr; if (!m_fun2terms.find(fd, ts)) { ts = alloc(app_set); m_fun2terms.insert(fd, ts); @@ -205,7 +205,7 @@ lbool lackr::eager() { SASSERT(m_is_init); push_abstraction(); TRACE("lackr", tout << "run sat 0\n"; ); - const lbool rv0 = m_sat->check_sat(0, 0); + const lbool rv0 = m_sat->check_sat(0, nullptr); if (rv0 == l_false) return l_false; eager_enc(); expr_ref all(m_m); @@ -213,7 +213,7 @@ lbool lackr::eager() { m_simp(all); m_sat->assert_expr(all); TRACE("lackr", tout << "run sat all\n"; ); - return m_sat->check_sat(0, 0); + return m_sat->check_sat(0, nullptr); } lbool lackr::lazy() { @@ -225,7 +225,7 @@ lbool lackr::lazy() { m_st.m_it++; checkpoint(); TRACE("lackr", tout << "lazy check: " << m_st.m_it << "\n";); - const lbool r = m_sat->check_sat(0, 0); + const lbool r = m_sat->check_sat(0, nullptr); if (r == l_undef) return l_undef; // give up if (r == l_false) return l_false; // abstraction unsat // reconstruct model diff --git a/src/ackermannization/lackr_model_constructor.cpp b/src/ackermannization/lackr_model_constructor.cpp index 641c70cbc..420fbda10 100644 --- a/src/ackermannization/lackr_model_constructor.cpp +++ b/src/ackermannization/lackr_model_constructor.cpp @@ -34,7 +34,7 @@ struct lackr_model_constructor::imp { , m_conflicts(conflicts) , m_b_rw(m) , m_bv_rw(m) - , m_evaluator(NULL) + , m_evaluator(nullptr) , m_empty_model(m) , m_ackr_helper(m) {} @@ -121,7 +121,7 @@ struct lackr_model_constructor::imp { void add_entry(app* term, expr* value, obj_map& interpretations) { - func_interp* fi = 0; + func_interp* fi = nullptr; func_decl * const declaration = term->get_decl(); const unsigned sz = declaration->get_arity(); SASSERT(sz == term->get_num_args()); @@ -169,7 +169,7 @@ struct lackr_model_constructor::imp { // Stops upon the first failure. // Returns true if and only if all congruence checks succeeded. bool _check_stack() { - if (m_evaluator == NULL) m_evaluator = alloc(model_evaluator, m_empty_model); + if (m_evaluator == nullptr) m_evaluator = alloc(model_evaluator, m_empty_model); expr * curr; while (!m_stack.empty()) { curr = m_stack.back(); @@ -276,7 +276,7 @@ struct lackr_model_constructor::imp { SASSERT(a->get_num_args() == 0); func_decl * const fd = a->get_decl(); expr * val = m_abstr_model->get_const_interp(fd); - if (val == 0) { // TODO: avoid model completetion? + if (val == nullptr) { // TODO: avoid model completetion? sort * s = fd->get_range(); val = m_abstr_model->get_some_value(s); } @@ -295,7 +295,7 @@ struct lackr_model_constructor::imp { expr_ref value(m_m); value = m_abstr_model->get_const_interp(ac->get_decl()); // get ackermann constant's interpretation - if (value.get() == 0) { // TODO: avoid model completion? + if (value.get() == nullptr) { // TODO: avoid model completion? sort * s = a_fd->get_range(); value = m_abstr_model->get_some_value(s); } @@ -362,7 +362,7 @@ struct lackr_model_constructor::imp { }; lackr_model_constructor::lackr_model_constructor(ast_manager& m, ackr_info_ref info) - : m_imp(0) + : m_imp(nullptr) , m_m(m) , m_state(UNKNOWN) , m_info(info) @@ -377,7 +377,7 @@ bool lackr_model_constructor::check(model_ref& abstr_model) { m_conflicts.reset(); if (m_imp) { dealloc(m_imp); - m_imp = 0; + m_imp = nullptr; } m_imp = alloc(lackr_model_constructor::imp, m_m, m_info, abstr_model, m_conflicts); const bool rv = m_imp->check(); diff --git a/src/api/api_algebraic.cpp b/src/api/api_algebraic.cpp index b4eda2c03..47d91209e 100644 --- a/src/api/api_algebraic.cpp +++ b/src/api/api_algebraic.cpp @@ -162,57 +162,57 @@ extern "C" { Z3_TRY; LOG_Z3_algebraic_add(c, a, b); RESET_ERROR_CODE(); - CHECK_IS_ALGEBRAIC_X(a, 0); - CHECK_IS_ALGEBRAIC_X(b, 0); + CHECK_IS_ALGEBRAIC_X(a, nullptr); + CHECK_IS_ALGEBRAIC_X(b, nullptr); BIN_OP(+,add); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_algebraic_sub(Z3_context c, Z3_ast a, Z3_ast b) { Z3_TRY; LOG_Z3_algebraic_sub(c, a, b); RESET_ERROR_CODE(); - CHECK_IS_ALGEBRAIC_X(a, 0); - CHECK_IS_ALGEBRAIC_X(b, 0); + CHECK_IS_ALGEBRAIC_X(a, nullptr); + CHECK_IS_ALGEBRAIC_X(b, nullptr); BIN_OP(-,sub); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_algebraic_mul(Z3_context c, Z3_ast a, Z3_ast b) { Z3_TRY; LOG_Z3_algebraic_mul(c, a, b); RESET_ERROR_CODE(); - CHECK_IS_ALGEBRAIC_X(a, 0); - CHECK_IS_ALGEBRAIC_X(b, 0); + CHECK_IS_ALGEBRAIC_X(a, nullptr); + CHECK_IS_ALGEBRAIC_X(b, nullptr); BIN_OP(*,mul); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_algebraic_div(Z3_context c, Z3_ast a, Z3_ast b) { Z3_TRY; LOG_Z3_algebraic_div(c, a, b); RESET_ERROR_CODE(); - CHECK_IS_ALGEBRAIC_X(a, 0); - CHECK_IS_ALGEBRAIC_X(b, 0); + CHECK_IS_ALGEBRAIC_X(a, nullptr); + CHECK_IS_ALGEBRAIC_X(b, nullptr); if ((is_rational(c, b) && get_rational(c, b).is_zero()) || (!is_rational(c, b) && am(c).is_zero(get_irrational(c, b)))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } BIN_OP(/,div); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_algebraic_root(Z3_context c, Z3_ast a, unsigned k) { Z3_TRY; LOG_Z3_algebraic_root(c, a, k); RESET_ERROR_CODE(); - CHECK_IS_ALGEBRAIC_X(a, 0); + CHECK_IS_ALGEBRAIC_X(a, nullptr); if (k % 2 == 0) { if ((is_rational(c, a) && get_rational(c, a).is_neg()) || (!is_rational(c, a) && am(c).is_neg(get_irrational(c, a)))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } } algebraic_numbers::manager & _am = am(c); @@ -229,14 +229,14 @@ extern "C" { expr * r = au(c).mk_numeral(_r, false); mk_c(c)->save_ast_trail(r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_algebraic_power(Z3_context c, Z3_ast a, unsigned k) { Z3_TRY; LOG_Z3_algebraic_power(c, a, k); RESET_ERROR_CODE(); - CHECK_IS_ALGEBRAIC_X(a, 0); + CHECK_IS_ALGEBRAIC_X(a, nullptr); algebraic_numbers::manager & _am = am(c); scoped_anum _r(_am); if (is_rational(c, a)) { @@ -251,7 +251,7 @@ extern "C" { expr * r = au(c).mk_numeral(_r, false); mk_c(c)->save_ast_trail(r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } #define BIN_PRED(RAT_PRED, IRAT_PRED) \ @@ -357,17 +357,17 @@ extern "C" { polynomial::manager & pm = mk_c(c)->pm(); polynomial_ref _p(pm); polynomial::scoped_numeral d(pm.m()); - expr2polynomial converter(mk_c(c)->m(), pm, 0, true); + expr2polynomial converter(mk_c(c)->m(), pm, nullptr, true); if (!converter.to_polynomial(to_expr(p), _p, d) || static_cast(max_var(_p)) >= n + 1) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } algebraic_numbers::manager & _am = am(c); scoped_anum_vector as(_am); if (!to_anum_vector(c, n, a, as)) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } scoped_anum_vector roots(_am); { @@ -383,7 +383,7 @@ extern "C" { result->m_ast_vector.push_back(au(c).mk_numeral(roots.get(i), false)); } RETURN_Z3(of_ast_vector(result)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } int Z3_API Z3_algebraic_eval(Z3_context c, Z3_ast p, unsigned n, Z3_ast a[]) { @@ -393,7 +393,7 @@ extern "C" { polynomial::manager & pm = mk_c(c)->pm(); polynomial_ref _p(pm); polynomial::scoped_numeral d(pm.m()); - expr2polynomial converter(mk_c(c)->m(), pm, 0, true); + expr2polynomial converter(mk_c(c)->m(), pm, nullptr, true); if (!converter.to_polynomial(to_expr(p), _p, d) || static_cast(max_var(_p)) >= n) { SET_ERROR_CODE(Z3_INVALID_ARG); diff --git a/src/api/api_arith.cpp b/src/api/api_arith.cpp index 8fbed6f46..9bb236fe2 100644 --- a/src/api/api_arith.cpp +++ b/src/api/api_arith.cpp @@ -34,7 +34,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_sort r = of_sort(mk_c(c)->m().mk_sort(mk_c(c)->get_arith_fid(), INT_SORT)); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_real_sort(Z3_context c) { @@ -43,7 +43,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_sort r = of_sort(mk_c(c)->m().mk_sort(mk_c(c)->get_arith_fid(), REAL_SORT)); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_real(Z3_context c, int num, int den) { @@ -52,12 +52,12 @@ extern "C" { RESET_ERROR_CODE(); if (den == 0) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } sort* s = mk_c(c)->m().mk_sort(mk_c(c)->get_arith_fid(), REAL_SORT); ast* a = mk_c(c)->mk_numeral_core(rational(num, den), s); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } MK_ARITH_OP(Z3_mk_add, OP_ADD); @@ -77,11 +77,11 @@ extern "C" { k = OP_DIV; } expr * args[2] = { to_expr(n1), to_expr(n2) }; - ast* a = mk_c(c)->m().mk_app(mk_c(c)->get_arith_fid(), k, 0, 0, 2, args); + ast* a = mk_c(c)->m().mk_app(mk_c(c)->get_arith_fid(), k, 0, nullptr, 2, args); mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } MK_ARITH_PRED(Z3_mk_lt, OP_LT); @@ -98,17 +98,17 @@ extern "C" { RESET_ERROR_CODE(); if (num_args == 0) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr* r = to_expr(args[0]); for (unsigned i = 1; i < num_args; ++i) { expr* args1[2] = { r, to_expr(args[i]) }; - r = mk_c(c)->m().mk_app(mk_c(c)->get_arith_fid(), OP_SUB, 0, 0, 2, args1); + r = mk_c(c)->m().mk_app(mk_c(c)->get_arith_fid(), OP_SUB, 0, nullptr, 2, args1); check_sorts(c, r); } mk_c(c)->save_ast_trail(r); RETURN_Z3(of_expr(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_unary_minus(Z3_context c, Z3_ast n) { @@ -116,7 +116,7 @@ extern "C" { LOG_Z3_mk_unary_minus(c, n); RESET_ERROR_CODE(); MK_UNARY_BODY(Z3_mk_unary_minus, mk_c(c)->get_arith_fid(), OP_UMINUS, SKIP); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_is_algebraic_number(Z3_context c, Z3_ast a) { @@ -134,7 +134,7 @@ extern "C" { RESET_ERROR_CODE(); if (!Z3_is_algebraic_number(c, a)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr * e = to_expr(a); algebraic_numbers::anum const & val = mk_c(c)->autil().to_irrational_algebraic_numeral(e); @@ -143,7 +143,7 @@ extern "C" { expr * r = mk_c(c)->autil().mk_numeral(l, false); mk_c(c)->save_ast_trail(r); RETURN_Z3(of_expr(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_get_algebraic_number_upper(Z3_context c, Z3_ast a, unsigned precision) { @@ -152,7 +152,7 @@ extern "C" { RESET_ERROR_CODE(); if (!Z3_is_algebraic_number(c, a)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr * e = to_expr(a); algebraic_numbers::anum const & val = mk_c(c)->autil().to_irrational_algebraic_numeral(e); @@ -161,7 +161,7 @@ extern "C" { expr * r = mk_c(c)->autil().mk_numeral(l, false); mk_c(c)->save_ast_trail(r); RETURN_Z3(of_expr(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_get_numerator(Z3_context c, Z3_ast a) { @@ -172,12 +172,12 @@ extern "C" { ast * _a = to_ast(a); if (!is_expr(_a) || !mk_c(c)->autil().is_numeral(to_expr(_a), val)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr * r = mk_c(c)->autil().mk_numeral(numerator(val), true); mk_c(c)->save_ast_trail(r); RETURN_Z3(of_expr(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_get_denominator(Z3_context c, Z3_ast a) { @@ -188,12 +188,12 @@ extern "C" { ast * _a = to_ast(a); if (!is_expr(_a) || !mk_c(c)->autil().is_numeral(to_expr(_a), val)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr * r = mk_c(c)->autil().mk_numeral(denominator(val), true); mk_c(c)->save_ast_trail(r); RETURN_Z3(of_expr(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_array.cpp b/src/api/api_array.cpp index 5e6764dff..61c37ec3e 100644 --- a/src/api/api_array.cpp +++ b/src/api/api_array.cpp @@ -31,7 +31,7 @@ extern "C" { sort * ty = mk_c(c)->m().mk_sort(mk_c(c)->get_array_fid(), ARRAY_SORT, 2, params); mk_c(c)->save_ast_trail(ty); RETURN_Z3(of_sort(ty)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_array_sort_n(Z3_context c, unsigned n, Z3_sort const* domain, Z3_sort range) { @@ -44,7 +44,7 @@ extern "C" { sort * ty = mk_c(c)->m().mk_sort(mk_c(c)->get_array_fid(), ARRAY_SORT, params.size(), params.c_ptr()); mk_c(c)->save_ast_trail(ty); RETURN_Z3(of_sort(ty)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_select(Z3_context c, Z3_ast a, Z3_ast i) { @@ -58,7 +58,7 @@ extern "C" { sort * i_ty = m.get_sort(_i); if (a_ty->get_family_id() != mk_c(c)->get_array_fid()) { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } sort * domain[2] = {a_ty, i_ty}; func_decl * d = m.mk_func_decl(mk_c(c)->get_array_fid(), OP_SELECT, 2, a_ty->get_parameters(), 2, domain); @@ -67,7 +67,7 @@ extern "C" { mk_c(c)->save_ast_trail(r); check_sorts(c, r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_select_n(Z3_context c, Z3_ast a, unsigned n, Z3_ast const* idxs) { @@ -81,7 +81,7 @@ extern "C" { // sort * i_ty = m.get_sort(_i); if (a_ty->get_family_id() != mk_c(c)->get_array_fid()) { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ptr_vector domain; ptr_vector args; @@ -96,7 +96,7 @@ extern "C" { mk_c(c)->save_ast_trail(r); check_sorts(c, r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v) { @@ -112,7 +112,7 @@ extern "C" { sort * v_ty = m.get_sort(_v); if (a_ty->get_family_id() != mk_c(c)->get_array_fid()) { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } sort * domain[3] = {a_ty, i_ty, v_ty}; func_decl * d = m.mk_func_decl(mk_c(c)->get_array_fid(), OP_STORE, 2, a_ty->get_parameters(), 3, domain); @@ -121,7 +121,7 @@ extern "C" { mk_c(c)->save_ast_trail(r); check_sorts(c, r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_store_n(Z3_context c, Z3_ast a, unsigned n, Z3_ast const* idxs, Z3_ast v) { @@ -135,7 +135,7 @@ extern "C" { sort * v_ty = m.get_sort(_v); if (a_ty->get_family_id() != mk_c(c)->get_array_fid()) { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ptr_vector domain; ptr_vector args; @@ -152,7 +152,7 @@ extern "C" { mk_c(c)->save_ast_trail(r); check_sorts(c, r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_map(Z3_context c, Z3_func_decl f, unsigned n, Z3_ast const* args) { @@ -161,7 +161,7 @@ extern "C" { RESET_ERROR_CODE(); if (n == 0) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ast_manager & m = mk_c(c)->m(); func_decl* _f = to_func_decl(f); @@ -177,7 +177,7 @@ extern "C" { mk_c(c)->save_ast_trail(r); check_sorts(c, r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v) { @@ -196,7 +196,7 @@ extern "C" { mk_c(c)->save_ast_trail(r); check_sorts(c, r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_array_default(Z3_context c, Z3_ast array) { @@ -206,12 +206,12 @@ extern "C" { ast_manager & m = mk_c(c)->m(); expr * _a = to_expr(array); - func_decl * f = m.mk_func_decl(mk_c(c)->get_array_fid(), OP_ARRAY_DEFAULT, 0, 0, 1, &_a); + func_decl * f = m.mk_func_decl(mk_c(c)->get_array_fid(), OP_ARRAY_DEFAULT, 0, nullptr, 1, &_a); app * r = m.mk_app(f, 1, &_a); mk_c(c)->save_ast_trail(r); check_sorts(c, r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast mk_app_array_core(Z3_context c, Z3_sort domain, Z3_ast v) { @@ -233,7 +233,7 @@ extern "C" { Z3_sort Z3_API Z3_mk_set_sort(Z3_context c, Z3_sort ty) { Z3_TRY; return Z3_mk_array_sort(c, ty, Z3_mk_bool_sort(c)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain) { @@ -242,7 +242,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_ast r = mk_app_array_core(c, domain, Z3_mk_false(c)); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain) { @@ -251,7 +251,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_ast r = mk_app_array_core(c, domain, Z3_mk_true(c)); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } MK_NARY(Z3_mk_set_union, mk_c(c)->get_array_fid(), OP_SET_UNION, SKIP); @@ -270,7 +270,7 @@ extern "C" { app * r = a.mk_as_array(to_func_decl(f)); mk_c(c)->save_ast_trail(r); return of_ast(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set) { @@ -289,22 +289,22 @@ extern "C" { Z3_TRY; LOG_Z3_get_array_sort_domain(c, t); RESET_ERROR_CODE(); - CHECK_VALID_AST(t, 0); + CHECK_VALID_AST(t, nullptr); if (to_sort(t)->get_family_id() == mk_c(c)->get_array_fid() && to_sort(t)->get_decl_kind() == ARRAY_SORT) { Z3_sort r = reinterpret_cast(to_sort(t)->get_parameter(0).get_ast()); RETURN_Z3(r); } SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); - Z3_CATCH_RETURN(0); + RETURN_Z3(nullptr); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_get_array_sort_range(Z3_context c, Z3_sort t) { Z3_TRY; LOG_Z3_get_array_sort_range(c, t); RESET_ERROR_CODE(); - CHECK_VALID_AST(t, 0); + CHECK_VALID_AST(t, nullptr); if (to_sort(t)->get_family_id() == mk_c(c)->get_array_fid() && to_sort(t)->get_decl_kind() == ARRAY_SORT) { unsigned n = to_sort(t)->get_num_parameters(); @@ -312,8 +312,8 @@ extern "C" { RETURN_Z3(r); } SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); - Z3_CATCH_RETURN(0); + RETURN_Z3(nullptr); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 6c39ad07d..f820b184b 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -49,11 +49,11 @@ extern "C" { RESET_ERROR_CODE(); if (i < 0 || (size_t)i >= (SIZE_MAX >> PTR_ALIGNMENT)) { SET_ERROR_CODE(Z3_IOB); - return 0; + return nullptr; } Z3_symbol result = of_symbol(symbol(i)); return result; - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_symbol Z3_API Z3_mk_string_symbol(Z3_context c, char const * str) { @@ -61,13 +61,13 @@ extern "C" { LOG_Z3_mk_string_symbol(c, str); RESET_ERROR_CODE(); symbol s; - if (str == 0 || *str == 0) + if (str == nullptr || *str == 0) s = symbol::null; else s = symbol(str); Z3_symbol result = of_symbol(s); return result; - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_is_eq_sort(Z3_context c, Z3_sort s1, Z3_sort s2) { @@ -82,7 +82,7 @@ extern "C" { sort* ty = mk_c(c)->m().mk_uninterpreted_sort(to_symbol(name)); mk_c(c)->save_ast_trail(ty); RETURN_Z3(of_sort(ty)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_is_eq_ast(Z3_context c, Z3_ast s1, Z3_ast s2) { @@ -107,7 +107,7 @@ extern "C" { mk_c(c)->save_ast_trail(d); RETURN_Z3(of_func_decl(d)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const * args) { @@ -123,7 +123,7 @@ extern "C" { mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty) { @@ -133,7 +133,7 @@ extern "C" { app* a = mk_c(c)->m().mk_const(mk_c(c)->m().mk_const_decl(to_symbol(s), to_sort(ty))); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } @@ -142,7 +142,7 @@ extern "C" { Z3_TRY; LOG_Z3_mk_fresh_func_decl(c, prefix, domain_size, domain, range); RESET_ERROR_CODE(); - if (prefix == 0) { + if (prefix == nullptr) { prefix = ""; } @@ -153,20 +153,20 @@ extern "C" { mk_c(c)->save_ast_trail(d); RETURN_Z3(of_func_decl(d)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, const char * prefix, Z3_sort ty) { Z3_TRY; LOG_Z3_mk_fresh_const(c, prefix, ty); RESET_ERROR_CODE(); - if (prefix == 0) { + if (prefix == nullptr) { prefix = ""; } app* a = mk_c(c)->m().mk_fresh_const(prefix, to_sort(ty)); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_true(Z3_context c) { @@ -175,7 +175,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_ast r = of_ast(mk_c(c)->m().mk_true()); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_false(Z3_context c) { @@ -184,7 +184,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_ast r = of_ast(mk_c(c)->m().mk_false()); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } MK_UNARY(Z3_mk_not, mk_c(c)->get_basic_fid(), OP_NOT, SKIP); @@ -210,7 +210,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_ast r = mk_ite_core(c, t1, t2, t3); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_bool_sort(Z3_context c) { @@ -219,7 +219,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_sort r = of_sort(mk_c(c)->m().mk_sort(mk_c(c)->m().get_basic_family_id(), BOOL_SORT)); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_app_to_ast(Z3_context c, Z3_app a) { @@ -335,7 +335,7 @@ extern "C" { Z3_bool Z3_API Z3_is_app(Z3_context c, Z3_ast a) { LOG_Z3_is_app(c, a); RESET_ERROR_CODE(); - return a != 0 && is_app(reinterpret_cast(a)); + return a != nullptr && is_app(reinterpret_cast(a)); } Z3_app Z3_API Z3_to_app(Z3_context c, Z3_ast a) { @@ -357,7 +357,7 @@ extern "C" { RESET_ERROR_CODE(); if (!is_app(reinterpret_cast(a))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } RETURN_Z3(of_func_decl(to_app(a)->get_decl())); } @@ -373,11 +373,11 @@ extern "C" { RESET_ERROR_CODE(); if (!is_app(reinterpret_cast(a))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } if (i >= to_app(a)->get_num_args()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } RETURN_Z3(of_ast(to_app(a)->get_arg(i))); } @@ -466,15 +466,15 @@ extern "C" { RESET_ERROR_CODE(); if (idx >= to_func_decl(d)->get_num_parameters()) { SET_ERROR_CODE(Z3_IOB); - return 0; + return nullptr; } parameter const& p = to_func_decl(d)->get_parameters()[idx]; if (!p.is_symbol()) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } return of_symbol(p.get_symbol()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_get_decl_sort_parameter(Z3_context c, Z3_func_decl d, unsigned idx) { @@ -483,15 +483,15 @@ extern "C" { RESET_ERROR_CODE(); if (idx >= to_func_decl(d)->get_num_parameters()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } parameter const& p = to_func_decl(d)->get_parameters()[idx]; if (!p.is_ast() || !is_sort(p.get_ast())) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } RETURN_Z3(of_sort(to_sort(p.get_ast()))); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_get_decl_ast_parameter(Z3_context c, Z3_func_decl d, unsigned idx) { @@ -500,15 +500,15 @@ extern "C" { RESET_ERROR_CODE(); if (idx >= to_func_decl(d)->get_num_parameters()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } parameter const& p = to_func_decl(d)->get_parameters()[idx]; if (!p.is_ast()) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } RETURN_Z3(of_ast(p.get_ast())); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_func_decl Z3_API Z3_get_decl_func_decl_parameter(Z3_context c, Z3_func_decl d, unsigned idx) { @@ -517,15 +517,15 @@ extern "C" { RESET_ERROR_CODE(); if (idx >= to_func_decl(d)->get_num_parameters()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } parameter const& p = to_func_decl(d)->get_parameters()[idx]; if (!p.is_ast() || !is_func_decl(p.get_ast())) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } RETURN_Z3(of_func_decl(to_func_decl(p.get_ast()))); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_get_decl_rational_parameter(Z3_context c, Z3_func_decl d, unsigned idx) { @@ -551,17 +551,17 @@ extern "C" { LOG_Z3_get_sort_name(c, t); RESET_ERROR_CODE(); return of_symbol(to_sort(t)->get_name()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a) { Z3_TRY; LOG_Z3_get_sort(c, a); RESET_ERROR_CODE(); - CHECK_IS_EXPR(a, 0); + CHECK_IS_EXPR(a, nullptr); Z3_sort r = of_sort(mk_c(c)->m().get_sort(to_expr(a))); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_get_arity(Z3_context c, Z3_func_decl d) { @@ -586,21 +586,21 @@ extern "C" { RESET_ERROR_CODE(); if (i >= to_func_decl(d)->get_arity()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_sort r = of_sort(to_func_decl(d)->get_domain(i)); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_get_range(Z3_context c, Z3_func_decl d) { Z3_TRY; LOG_Z3_get_range(c, d); RESET_ERROR_CODE(); - CHECK_VALID_AST(d, 0); + CHECK_VALID_AST(d, nullptr); Z3_sort r = of_sort(to_func_decl(d)->get_range()); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort_kind Z3_get_sort_kind(Z3_context c, Z3_sort t) { @@ -688,17 +688,17 @@ extern "C" { } catch (z3_exception & ex) { mk_c(c)->handle_exception(ex); - return 0; + return nullptr; } } mk_c(c)->save_ast_trail(result); return of_ast(result.get()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_simplify(Z3_context c, Z3_ast _a) { LOG_Z3_simplify(c, _a); - RETURN_Z3(simplify(c, _a, 0)); + RETURN_Z3(simplify(c, _a, nullptr)); } Z3_ast Z3_API Z3_simplify_ex(Z3_context c, Z3_ast _a, Z3_params p) { @@ -727,7 +727,7 @@ extern "C" { th_rewriter::get_param_descrs(d->m_descrs); Z3_param_descrs r = of_param_descrs(d); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_update_term(Z3_context c, Z3_ast _a, unsigned num_args, Z3_ast const _args[]) { @@ -762,7 +762,7 @@ extern "C" { } mk_c(c)->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_substitute(Z3_context c, @@ -777,11 +777,11 @@ extern "C" { expr * a = to_expr(_a); expr * const * from = to_exprs(_from); expr * const * to = to_exprs(_to); - expr * r = 0; + expr * r = nullptr; for (unsigned i = 0; i < num_exprs; i++) { if (m.get_sort(from[i]) != m.get_sort(to[i])) { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(of_expr(0)); + RETURN_Z3(of_expr(nullptr)); } SASSERT(from[i]->get_ref_count() > 0); SASSERT(to[i]->get_ref_count() > 0); @@ -795,7 +795,7 @@ extern "C" { mk_c(c)->save_ast_trail(new_a); r = new_a.get(); RETURN_Z3(of_expr(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_substitute_vars(Z3_context c, @@ -813,7 +813,7 @@ extern "C" { subst(a, num_exprs, to, new_a); mk_c(c)->save_ast_trail(new_a); RETURN_Z3(of_expr(new_a.get())); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_API char const * Z3_ast_to_string(Z3_context c, Z3_ast a) { @@ -839,7 +839,7 @@ extern "C" { UNREACHABLE(); } return mk_c(c)->mk_external_string(buffer.str()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_API char const * Z3_sort_to_string(Z3_context c, Z3_sort s) { @@ -1233,17 +1233,17 @@ extern "C" { Z3_TRY; LOG_Z3_translate(c, a, target); RESET_ERROR_CODE(); - CHECK_VALID_AST(a, 0); + CHECK_VALID_AST(a, nullptr); if (c == target) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } SASSERT(mk_c(c)->m().contains(to_ast(a))); ast_translation translator(mk_c(c)->m(), mk_c(target)->m()); ast * _result = translator(to_ast(a)); mk_c(target)->save_ast_trail(_result); RETURN_Z3(of_ast(_result)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_ast_map.cpp b/src/api/api_ast_map.cpp index d0388b97a..17dd086b5 100644 --- a/src/api/api_ast_map.cpp +++ b/src/api/api_ast_map.cpp @@ -38,7 +38,7 @@ extern "C" { mk_c(c)->save_object(m); Z3_ast_map r = of_ast_map(m); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_ast_map_inc_ref(Z3_context c, Z3_ast_map m) { @@ -70,15 +70,15 @@ extern "C" { LOG_Z3_ast_map_find(c, m, k); RESET_ERROR_CODE(); obj_map::obj_map_entry * entry = to_ast_map_ref(m).find_core(to_ast(k)); - if (entry == 0) { + if (entry == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } else { ast * r = entry->get_data().m_value; RETURN_Z3(of_ast(r)); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_ast_map_insert(Z3_context c, Z3_ast_map m, Z3_ast k, Z3_ast v) { @@ -115,7 +115,7 @@ extern "C" { Z3_TRY; LOG_Z3_ast_map_erase(c, m, k); RESET_ERROR_CODE(); - ast * v = 0; + ast * v = nullptr; if (to_ast_map_ref(m).find(to_ast(k), v)) { to_ast_map_ref(m).erase(to_ast(k)); ast_manager & mng = to_ast_map(m)->m; @@ -146,7 +146,7 @@ extern "C" { } Z3_ast_vector r = of_ast_vector(v); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_ast_map_to_string(Z3_context c, Z3_ast_map m) { @@ -163,7 +163,7 @@ extern "C" { } buffer << ")"; return mk_c(c)->mk_external_string(buffer.str()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_ast_vector.cpp b/src/api/api_ast_vector.cpp index 471a308b6..ae5adecea 100644 --- a/src/api/api_ast_vector.cpp +++ b/src/api/api_ast_vector.cpp @@ -33,7 +33,7 @@ extern "C" { mk_c(c)->save_object(v); Z3_ast_vector r = of_ast_vector(v); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_ast_vector_inc_ref(Z3_context c, Z3_ast_vector v) { @@ -66,12 +66,12 @@ extern "C" { RESET_ERROR_CODE(); if (i >= to_ast_vector_ref(v).size()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } // Remark: Don't need to invoke save_object. ast * r = to_ast_vector_ref(v).get(i); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_ast_vector_set(Z3_context c, Z3_ast_vector v, unsigned i, Z3_ast a) { @@ -108,7 +108,7 @@ extern "C" { RESET_ERROR_CODE(); if (c == t) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ast_translation translator(mk_c(c)->m(), mk_c(t)->m()); Z3_ast_vector_ref * new_v = alloc(Z3_ast_vector_ref, *mk_c(t), mk_c(t)->m()); @@ -119,7 +119,7 @@ extern "C" { new_v->m_ast_vector.push_back(new_ast); } RETURN_Z3(of_ast_vector(new_v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_ast_vector_to_string(Z3_context c, Z3_ast_vector v) { @@ -134,7 +134,7 @@ extern "C" { } buffer << ")"; return mk_c(c)->mk_external_string(buffer.str()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_bv.cpp b/src/api/api_bv.cpp index 3b5d60be3..1876d930d 100644 --- a/src/api/api_bv.cpp +++ b/src/api/api_bv.cpp @@ -33,7 +33,7 @@ extern "C" { parameter p(sz); Z3_sort r = of_sort(mk_c(c)->m().mk_sort(mk_c(c)->get_bv_fid(), BV_SORT, 1, &p)); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } #define MK_BV_UNARY(NAME, OP) MK_UNARY(NAME, mk_c(c)->get_bv_fid(), OP, SKIP) @@ -85,7 +85,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_ast r = mk_extract_core(c, high, low, n); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } #define MK_BV_PUNARY(NAME, OP) \ @@ -146,7 +146,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ check_sorts(c, a); RETURN_Z3(of_ast(a)); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } /** @@ -164,7 +164,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ unsigned sz = Z3_get_bv_sort_size(c, s); if (sz == 0) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } Z3_ast x = Z3_mk_int64(c, 1, s); Z3_inc_ref(c, x); @@ -174,7 +174,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ Z3_dec_ref(c, x); Z3_dec_ref(c, y); return result; - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_mk_bvsmin(Z3_context c, Z3_sort s) { @@ -229,7 +229,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ Z3_dec_ref(c, r); return result; } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } // only for signed machine integers @@ -257,7 +257,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ Z3_dec_ref(c, args_neg); Z3_dec_ref(c, zero); return result; - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } // only for signed machine integers @@ -286,7 +286,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ Z3_dec_ref(c, z); Z3_dec_ref(c, zero); return result; - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_bvsub_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_bool is_signed) { @@ -311,7 +311,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ else { return Z3_mk_bvule(c, t2, t1); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_bvmul_no_overflow(Z3_context c, Z3_ast n1, Z3_ast n2, Z3_bool is_signed) { @@ -336,11 +336,11 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ Z3_TRY; RESET_ERROR_CODE(); Z3_ast min = Z3_mk_bvsmin(c, Z3_get_sort(c, t)); - if (Z3_get_error_code(c) != Z3_OK) return 0; + if (Z3_get_error_code(c) != Z3_OK) return nullptr; Z3_ast eq = Z3_mk_eq(c, t, min); - if (Z3_get_error_code(c) != Z3_OK) return 0; + if (Z3_get_error_code(c) != Z3_OK) return nullptr; return Z3_mk_not(c, eq); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } // only for signed machine integers @@ -366,7 +366,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ Z3_dec_ref(c, z); Z3_dec_ref(c, u); return result; - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast n1, Z3_ast n2) { @@ -374,7 +374,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ LOG_Z3_mk_bvsub(c, n1, n2); RESET_ERROR_CODE(); MK_BINARY_BODY(Z3_mk_bvsub, mk_c(c)->get_bv_fid(), OP_BSUB, SKIP); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast n) { @@ -382,7 +382,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \ LOG_Z3_mk_bvneg(c, n); RESET_ERROR_CODE(); MK_UNARY_BODY(Z3_mk_bvneg, mk_c(c)->get_bv_fid(), OP_BNEG, SKIP); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_get_bv_sort_size(Z3_context c, Z3_sort t) { diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 460101d34..604177561 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -53,7 +53,7 @@ extern "C" { Z3_bool_opt Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value) { memory::initialize(UINT_MAX); LOG_Z3_global_param_get(param_id, param_value); - *param_value = 0; + *param_value = nullptr; try { g_Z3_global_param_get_buffer = gparams::get_value(param_id); *param_value = g_Z3_global_param_get_buffer.c_str(); diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 8299c136c..12a4642c1 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -70,7 +70,7 @@ namespace api { // ------------------------ context::context(context_params * p, bool user_ref_count): - m_params(p != 0 ? *p : context_params()), + m_params(p != nullptr ? *p : context_params()), m_user_ref_count(user_ref_count), m_manager(m_params.mk_ast_manager()), m_plugins(m()), @@ -89,7 +89,7 @@ namespace api { m_searching = false; - m_interruptable = 0; + m_interruptable = nullptr; m_error_handler = &default_error_handler; m_basic_fid = m().get_basic_family_id(); @@ -108,7 +108,7 @@ namespace api { context::~context() { - m_last_obj = 0; + m_last_obj = nullptr; u_map::iterator it = m_allocated_objects.begin(); while (it != m_allocated_objects.end()) { api::object* val = it->m_value; @@ -131,7 +131,7 @@ namespace api { context::set_interruptable::~set_interruptable() { #pragma omp critical (set_interruptable) { - m_ctx.m_interruptable = 0; + m_ctx.m_interruptable = nullptr; } } @@ -175,7 +175,7 @@ namespace api { } expr * context::mk_numeral_core(rational const & n, sort * s) { - expr* e = 0; + expr* e = nullptr; family_id fid = s->get_family_id(); if (fid == m_arith_fid) { e = m_arith_util.mk_numeral(n, s); @@ -239,7 +239,7 @@ namespace api { void context::reset_last_result() { if (m_user_ref_count) m_last_result.reset(); - m_last_obj = 0; + m_last_obj = nullptr; } void context::save_object(object * r) { @@ -313,7 +313,7 @@ namespace api { // // ----------------------- realclosure::manager & context::rcfm() { - if (m_rcf_manager.get() == 0) { + if (m_rcf_manager.get() == nullptr) { m_rcf_manager = alloc(realclosure::manager, m_limit, m_rcf_qm); } return *(m_rcf_manager.get()); @@ -336,7 +336,7 @@ extern "C" { memory::initialize(UINT_MAX); Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), false)); RETURN_Z3(r); - Z3_CATCH_RETURN_NO_HANDLE(0); + Z3_CATCH_RETURN_NO_HANDLE(nullptr); } Z3_context Z3_API Z3_mk_context_rc(Z3_config c) { @@ -345,7 +345,7 @@ extern "C" { memory::initialize(UINT_MAX); Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), true)); RETURN_Z3(r); - Z3_CATCH_RETURN_NO_HANDLE(0); + Z3_CATCH_RETURN_NO_HANDLE(nullptr); } void Z3_API Z3_del_context(Z3_context c) { @@ -459,7 +459,7 @@ extern "C" { case Z3_INTERNAL_FATAL: return "internal error"; case Z3_INVALID_USAGE: return "invalid usage"; case Z3_DEC_REF_ERROR: return "invalid dec_ref command"; - case Z3_EXCEPTION: return c == 0 ? "Z3 exception" : mk_c(c)->get_exception_msg(); + case Z3_EXCEPTION: return c == nullptr ? "Z3 exception" : mk_c(c)->get_exception_msg(); default: return "unknown"; } } diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 431638864..5e0082f09 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -45,9 +45,9 @@ namespace api { ast_ref_vector m_trail; public: fixedpoint_context(ast_manager& m, smt_params& p): - m_state(0), - m_reduce_app(0), - m_reduce_assign(0), + m_state(nullptr), + m_reduce_app(nullptr), + m_reduce_assign(nullptr), m_context(m, m_register_engine, p), m_trail(m) {} @@ -74,7 +74,7 @@ namespace api { m_reduce_assign = f; } void reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result) override { - expr* r = 0; + expr* r = nullptr; if (m_reduce_app) { m_reduce_app(m_state, f, num_args, args, &r); result = r; @@ -85,7 +85,7 @@ namespace api { m_trail.push_back(r); } // allow fallthrough. - if (r == 0) { + if (r == nullptr) { ast_manager& m = m_context.get_manager(); result = m.mk_app(f, num_args, args); } @@ -171,22 +171,22 @@ extern "C" { sort * r = to_sort(s); if (Z3_get_sort_kind(c, s) != Z3_RELATION_SORT) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } if (col >= r->get_num_parameters()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } parameter const& p = r->get_parameter(col); if (!p.is_ast() || !is_sort(p.get_ast())) { UNREACHABLE(); warning_msg("Sort parameter expected at %d", col); SET_ERROR_CODE(Z3_INTERNAL_FATAL); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_sort res = of_sort(to_sort(p.get_ast())); RETURN_Z3(res); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, __uint64 size) { @@ -196,7 +196,7 @@ extern "C" { sort* s = mk_c(c)->datalog_util().mk_sort(to_symbol(name), size); mk_c(c)->save_ast_trail(s); RETURN_Z3(of_sort(s)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_get_finite_domain_sort_size(Z3_context c, Z3_sort s, __uint64 * out) { @@ -228,7 +228,7 @@ extern "C" { mk_c(c)->save_object(d); Z3_fixedpoint r = of_datalog(d); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_fixedpoint_inc_ref(Z3_context c, Z3_fixedpoint s) { @@ -331,7 +331,7 @@ extern "C" { expr* e = to_fixedpoint_ref(d)->ctx().get_answer_as_formula(); mk_c(c)->save_ast_trail(e); RETURN_Z3(of_expr(e)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_fixedpoint_get_reason_unknown(Z3_context c,Z3_fixedpoint d) { @@ -366,7 +366,7 @@ extern "C" { ctx.set_ignore_check(true); if (!parse_smt2_commands(ctx, s)) { SET_ERROR_CODE(Z3_PARSER_ERROR); - return 0; + return nullptr; } Z3_ast_vector_ref* v = alloc(Z3_ast_vector_ref, *mk_c(c), m); @@ -398,7 +398,7 @@ extern "C" { std::string str(s); std::istringstream is(str); RETURN_Z3(Z3_fixedpoint_from_stream(c, d, is)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast_vector Z3_API Z3_fixedpoint_from_file( @@ -410,10 +410,10 @@ extern "C" { std::ifstream is(s); if (!is) { SET_ERROR_CODE(Z3_PARSER_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } RETURN_Z3(Z3_fixedpoint_from_stream(c, d, is)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } @@ -426,7 +426,7 @@ extern "C" { mk_c(c)->save_object(st); Z3_stats r = of_stats(st); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_fixedpoint_register_relation(Z3_context c,Z3_fixedpoint d, Z3_func_decl f) { @@ -473,7 +473,7 @@ extern "C" { v->m_ast_vector.push_back(m.mk_not(queries[i].get())); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast_vector Z3_API Z3_fixedpoint_get_assertions( @@ -490,7 +490,7 @@ extern "C" { v->m_ast_vector.push_back(to_fixedpoint_ref(d)->ctx().get_assertion(i)); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_fixedpoint_set_reduce_assign_callback( @@ -541,7 +541,7 @@ extern "C" { expr_ref r = to_fixedpoint_ref(d)->get_cover_delta(level, to_func_decl(pred)); mk_c(c)->save_ast_trail(r); RETURN_Z3(of_expr(r.get())); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_fixedpoint_add_cover(Z3_context c, Z3_fixedpoint d, int level, Z3_func_decl pred, Z3_ast property) { @@ -573,7 +573,7 @@ extern "C" { to_fixedpoint_ref(f)->collect_param_descrs(d->m_descrs); Z3_param_descrs r = of_param_descrs(d); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_fixedpoint_set_params(Z3_context c, Z3_fixedpoint d, Z3_params p) { diff --git a/src/api/api_datalog.h b/src/api/api_datalog.h index 588ee02d3..35458f902 100644 --- a/src/api/api_datalog.h +++ b/src/api/api_datalog.h @@ -37,7 +37,7 @@ namespace api { struct Z3_fixedpoint_ref : public api::object { api::fixedpoint_context * m_datalog; params_ref m_params; - Z3_fixedpoint_ref(api::context& c): api::object(c), m_datalog(0) {} + Z3_fixedpoint_ref(api::context& c): api::object(c), m_datalog(nullptr) {} ~Z3_fixedpoint_ref() override { dealloc(m_datalog); } }; diff --git a/src/api/api_datalog_spacer.inc b/src/api/api_datalog_spacer.inc index 871d2be63..1888d4b96 100644 --- a/src/api/api_datalog_spacer.inc +++ b/src/api/api_datalog_spacer.inc @@ -49,7 +49,7 @@ Notes: expr* e = to_fixedpoint_ref(d)->ctx().get_ground_sat_answer(); mk_c(c)->save_ast_trail(e); RETURN_Z3(of_expr(e)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast_vector Z3_API Z3_fixedpoint_get_rules_along_trace( @@ -69,7 +69,7 @@ Notes: v->m_ast_vector.push_back(rules[i].get()); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_symbol Z3_API Z3_fixedpoint_get_rule_names_along_trace( @@ -90,7 +90,7 @@ Notes: ss << ";" << names[i].str(); } RETURN_Z3(of_symbol(symbol(ss.str().substr(1).c_str()))); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_fixedpoint_add_invariant(Z3_context c, Z3_fixedpoint d, Z3_func_decl pred, Z3_ast property) { @@ -108,6 +108,6 @@ Notes: expr_ref r = to_fixedpoint_ref(d)->ctx().get_reachable(to_func_decl(pred)); mk_c(c)->save_ast_trail(r); RETURN_Z3(of_expr(r.get())); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } diff --git a/src/api/api_datatype.cpp b/src/api/api_datatype.cpp index d667a7428..df0b2317f 100644 --- a/src/api/api_datatype.cpp +++ b/src/api/api_datatype.cpp @@ -52,12 +52,12 @@ extern "C" { { datatype_decl * dt = mk_datatype_decl(dt_util, to_symbol(name), 0, nullptr, 1, constrs); - bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &dt, 0, 0, tuples); + bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &dt, 0, nullptr, tuples); del_datatype_decl(dt); if (!is_ok) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } } @@ -82,7 +82,7 @@ extern "C" { proj_decls[i] = of_func_decl(_accs[i]); } RETURN_Z3_mk_tuple_sort(of_sort(tuple)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_enumeration_sort(Z3_context c, @@ -108,18 +108,18 @@ extern "C" { recognizer_s += e_name.str(); symbol recognizer(recognizer_s.c_str()); - constrs.push_back(mk_constructor_decl(e_name, recognizer, 0, 0)); + constrs.push_back(mk_constructor_decl(e_name, recognizer, 0, nullptr)); } { - datatype_decl * dt = mk_datatype_decl(dt_util, to_symbol(name), 0, 0, n, constrs.c_ptr()); - bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &dt, 0, 0, sorts); + datatype_decl * dt = mk_datatype_decl(dt_util, to_symbol(name), 0, nullptr, n, constrs.c_ptr()); + bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &dt, 0, nullptr, sorts); del_datatype_decl(dt); if (!is_ok) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } } @@ -143,7 +143,7 @@ extern "C" { } RETURN_Z3_mk_enumeration_sort(of_sort(e)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_list_sort(Z3_context c, @@ -168,7 +168,7 @@ extern "C" { mk_accessor_decl(m, symbol("tail"), type_ref(0)) }; constructor_decl* constrs[2] = { - mk_constructor_decl(symbol("nil"), symbol("is_nil"), 0, 0), + mk_constructor_decl(symbol("nil"), symbol("is_nil"), 0, nullptr), // Leo: SMT 2.0 document uses 'insert' instead of cons mk_constructor_decl(symbol("cons"), symbol("is_cons"), 2, head_tail) }; @@ -176,12 +176,12 @@ extern "C" { sort_ref_vector sorts(m); { datatype_decl * decl = mk_datatype_decl(dt_util, to_symbol(name), 0, nullptr, 2, constrs); - bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &decl, 0, 0, sorts); + bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &decl, 0, nullptr, sorts); del_datatype_decl(decl); if (!is_ok) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } } sort * s = sorts.get(0); @@ -225,7 +225,7 @@ extern "C" { *tail_decl = of_func_decl(f); } RETURN_Z3_mk_list_sort(of_sort(s)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } struct constructor { @@ -259,7 +259,7 @@ extern "C" { cnstr->m_sort_refs.push_back(sort_refs[i]); } RETURN_Z3(reinterpret_cast(cnstr)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } @@ -349,12 +349,12 @@ extern "C" { sort_ref_vector sorts(m); { datatype_decl * data = mk_datatype_decl(c, name, num_constructors, constructors); - bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &data, 0, 0, sorts); + bool is_ok = mk_c(c)->get_dt_plugin()->mk_datatypes(1, &data, 0, nullptr, sorts); del_datatype_decl(data); if (!is_ok) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } } sort * s = sorts.get(0); @@ -367,7 +367,7 @@ extern "C" { cn->m_constructor = cnstrs[i]; } RETURN_Z3_mk_datatype(of_sort(s)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } typedef ptr_vector constructor_list; @@ -383,7 +383,7 @@ extern "C" { result->push_back(reinterpret_cast(constructors[i])); } RETURN_Z3(reinterpret_cast(result)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_del_constructor_list(Z3_context c, Z3_constructor_list clist) { @@ -412,7 +412,7 @@ extern "C" { datas.push_back(mk_datatype_decl(c, sort_names[i], cl->size(), reinterpret_cast(cl->c_ptr()))); } sort_ref_vector _sorts(m); - bool ok = mk_c(c)->get_dt_plugin()->mk_datatypes(datas.size(), datas.c_ptr(), 0, 0, _sorts); + bool ok = mk_c(c)->get_dt_plugin()->mk_datatypes(datas.size(), datas.c_ptr(), 0, nullptr, _sorts); del_datatype_decls(datas.size(), datas.c_ptr()); if (!ok) { @@ -454,17 +454,17 @@ extern "C" { Z3_func_decl get_datatype_sort_constructor_core(Z3_context c, Z3_sort t, unsigned idx) { RESET_ERROR_CODE(); - CHECK_VALID_AST(t, 0); + CHECK_VALID_AST(t, nullptr); sort * _t = to_sort(t); datatype_util& dt_util = mk_c(c)->dtutil(); if (!dt_util.is_datatype(_t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } ptr_vector const & decls = *dt_util.get_datatype_constructors(_t); if (idx >= decls.size()) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } func_decl* decl = (decls)[idx]; mk_c(c)->save_ast_trail(decl); @@ -477,7 +477,7 @@ extern "C" { RESET_ERROR_CODE(); Z3_func_decl r = get_datatype_sort_constructor_core(c, t, idx); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_func_decl Z3_API Z3_get_datatype_sort_recognizer(Z3_context c, Z3_sort t, unsigned idx) { @@ -489,18 +489,18 @@ extern "C" { if (!dt_util.is_datatype(_t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ptr_vector const & decls = *dt_util.get_datatype_constructors(_t); if (idx >= decls.size()) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } func_decl* decl = (decls)[idx]; decl = dt_util.get_constructor_recognizer(decl); mk_c(c)->save_ast_trail(decl); RETURN_Z3(of_func_decl(decl)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_func_decl Z3_API Z3_get_datatype_sort_constructor_accessor(Z3_context c, Z3_sort t, unsigned idx_c, unsigned idx_a) { @@ -512,28 +512,28 @@ extern "C" { if (!dt_util.is_datatype(_t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ptr_vector const & decls = *dt_util.get_datatype_constructors(_t); if (idx_c >= decls.size()) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } func_decl* decl = (decls)[idx_c]; if (decl->get_arity() <= idx_a) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ptr_vector const & accs = *dt_util.get_constructor_accessors(decl); SASSERT(accs.size() == decl->get_arity()); if (accs.size() <= idx_a) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } decl = (accs)[idx_a]; mk_c(c)->save_ast_trail(decl); RETURN_Z3(of_func_decl(decl)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_func_decl Z3_API Z3_get_tuple_sort_mk_decl(Z3_context c, Z3_sort t) { @@ -544,11 +544,11 @@ extern "C" { datatype_util& dt_util = mk_c(c)->dtutil(); if (!dt_util.is_datatype(tuple) || dt_util.is_recursive(tuple) || dt_util.get_datatype_num_constructors(tuple) != 1) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_func_decl r = get_datatype_sort_constructor_core(c, t, 0); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_get_tuple_sort_num_fields(Z3_context c, Z3_sort t) { @@ -579,22 +579,22 @@ extern "C" { datatype_util& dt_util = mk_c(c)->dtutil(); if (!dt_util.is_datatype(tuple) || dt_util.is_recursive(tuple) || dt_util.get_datatype_num_constructors(tuple) != 1) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ptr_vector const & decls = *dt_util.get_datatype_constructors(tuple); if (decls.size() != 1) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ptr_vector const & accs = *dt_util.get_constructor_accessors((decls)[0]); if (accs.size() <= i) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } func_decl* acc = (accs)[i]; mk_c(c)->save_ast_trail(acc); RETURN_Z3(of_func_decl(acc)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_datatype_update_field( @@ -614,7 +614,7 @@ extern "C" { mk_c(c)->save_ast_trail(r); check_sorts(c, r); RETURN_Z3(of_ast(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } diff --git a/src/api/api_fpa.cpp b/src/api/api_fpa.cpp index 484cb3d76..972505ca2 100644 --- a/src/api/api_fpa.cpp +++ b/src/api/api_fpa.cpp @@ -56,7 +56,7 @@ extern "C" { sort * s = ctx->fpautil().mk_rm_sort(); mk_c(c)->save_ast_trail(s); RETURN_Z3(of_sort(s)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(Z3_context c) { @@ -67,7 +67,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_nearest_ties_to_even(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_rne(Z3_context c) { @@ -78,7 +78,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_nearest_ties_to_even(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(Z3_context c) { @@ -89,7 +89,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_nearest_ties_to_away(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_rna(Z3_context c) { @@ -100,7 +100,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_nearest_ties_to_away(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(Z3_context c) { @@ -111,7 +111,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_toward_positive(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_rtp(Z3_context c) { @@ -122,7 +122,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_toward_positive(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(Z3_context c) { @@ -133,7 +133,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_toward_negative(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_rtn(Z3_context c) { @@ -144,7 +144,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_toward_negative(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(Z3_context c) { @@ -155,7 +155,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_toward_zero(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_rtz(Z3_context c) { @@ -166,7 +166,7 @@ extern "C" { expr * a = ctx->fpautil().mk_round_toward_zero(); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } @@ -181,7 +181,7 @@ extern "C" { sort * s = ctx->fpautil().mk_float_sort(ebits, sbits); ctx->save_ast_trail(s); RETURN_Z3(of_sort(s)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_fpa_sort_half(Z3_context c) { @@ -220,50 +220,50 @@ extern "C" { Z3_TRY; LOG_Z3_mk_fpa_nan(c, s); RESET_ERROR_CODE(); - CHECK_VALID_AST(s, 0); + CHECK_VALID_AST(s, nullptr); if (!is_fp_sort(c, s)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_nan(to_sort(s)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative) { Z3_TRY; LOG_Z3_mk_fpa_inf(c, s, negative); RESET_ERROR_CODE(); - CHECK_VALID_AST(s, 0); + CHECK_VALID_AST(s, nullptr); if (!is_fp_sort(c, s)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = negative != 0 ? ctx->fpautil().mk_ninf(to_sort(s)) : ctx->fpautil().mk_pinf(to_sort(s)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_bool negative) { Z3_TRY; LOG_Z3_mk_fpa_inf(c, s, negative); RESET_ERROR_CODE(); - CHECK_VALID_AST(s, 0); + CHECK_VALID_AST(s, nullptr); if (!is_fp_sort(c, s)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = negative != 0 ? ctx->fpautil().mk_nzero(to_sort(s)) : ctx->fpautil().mk_pzero(to_sort(s)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_fp(Z3_context c, Z3_ast sgn, Z3_ast exp, Z3_ast sig) { @@ -272,13 +272,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_bv(c, sgn) || !is_bv(c, exp) || !is_bv(c, sig)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_fp(to_expr(sgn), to_expr(exp), to_expr(sig)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_numeral_float(Z3_context c, float v, Z3_sort ty) { @@ -287,7 +287,7 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp_sort(c, ty)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); scoped_mpf tmp(ctx->fpautil().fm()); @@ -298,7 +298,7 @@ extern "C" { expr * a = ctx->fpautil().mk_value(tmp); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_numeral_double(Z3_context c, double v, Z3_sort ty) { @@ -307,7 +307,7 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp_sort(c, ty)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); scoped_mpf tmp(ctx->fpautil().fm()); @@ -315,7 +315,7 @@ extern "C" { expr * a = ctx->fpautil().mk_value(tmp); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_numeral_int(Z3_context c, signed v, Z3_sort ty) { @@ -324,7 +324,7 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp_sort(c, ty)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); scoped_mpf tmp(ctx->fpautil().fm()); @@ -335,7 +335,7 @@ extern "C" { expr * a = ctx->fpautil().mk_value(tmp); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_numeral_int_uint(Z3_context c, Z3_bool sgn, signed exp, unsigned sig, Z3_sort ty) { @@ -344,7 +344,7 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp_sort(c, ty)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); scoped_mpf tmp(ctx->fpautil().fm()); @@ -355,7 +355,7 @@ extern "C" { expr * a = ctx->fpautil().mk_value(tmp); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, __int64 exp, __uint64 sig, Z3_sort ty) { @@ -364,7 +364,7 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp_sort(c, ty)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); scoped_mpf tmp(ctx->fpautil().fm()); @@ -375,7 +375,7 @@ extern "C" { expr * a = ctx->fpautil().mk_value(tmp); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t) { @@ -384,13 +384,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_abs(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t) { @@ -399,13 +399,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_neg(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_add(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) { @@ -414,13 +414,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_add(to_expr(rm), to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_sub(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) { @@ -429,13 +429,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_sub(to_expr(rm), to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_mul(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) { @@ -444,13 +444,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_mul(to_expr(rm), to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_div(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) { @@ -459,13 +459,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_div(to_expr(rm), to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_fma(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2, Z3_ast t3) { @@ -474,13 +474,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t1) || !is_fp(c, t2) || !is_fp(c, t3)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_fma(to_expr(rm), to_expr(t1), to_expr(t2), to_expr(t3)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_sqrt(Z3_context c, Z3_ast rm, Z3_ast t) { @@ -489,13 +489,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_sqrt(to_expr(rm), to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_rem(Z3_context c, Z3_ast t1, Z3_ast t2) { @@ -504,13 +504,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_rem(to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_round_to_integral(Z3_context c, Z3_ast rm, Z3_ast t) { @@ -519,13 +519,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_round_to_integral(to_expr(rm), to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_min(Z3_context c, Z3_ast t1, Z3_ast t2) { @@ -534,13 +534,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_min(to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_max(Z3_context c, Z3_ast t1, Z3_ast t2) { @@ -549,13 +549,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_max(to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_leq(Z3_context c, Z3_ast t1, Z3_ast t2) { @@ -564,13 +564,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_le(to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_lt(Z3_context c, Z3_ast t1, Z3_ast t2) { @@ -579,13 +579,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_lt(to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_geq(Z3_context c, Z3_ast t1, Z3_ast t2) { @@ -594,13 +594,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_ge(to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_gt(Z3_context c, Z3_ast t1, Z3_ast t2) { @@ -609,13 +609,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_gt(to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_eq(Z3_context c, Z3_ast t1, Z3_ast t2) { @@ -624,13 +624,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t1) || !is_fp(c, t2)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_float_eq(to_expr(t1), to_expr(t2)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_is_normal(Z3_context c, Z3_ast t) { @@ -639,13 +639,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_is_normal(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_is_subnormal(Z3_context c, Z3_ast t) { @@ -654,13 +654,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_is_subnormal(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_is_zero(Z3_context c, Z3_ast t) { @@ -669,13 +669,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_is_zero(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_is_infinite(Z3_context c, Z3_ast t) { @@ -684,13 +684,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_is_inf(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_is_nan(Z3_context c, Z3_ast t) { @@ -699,13 +699,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_is_nan(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_is_negative(Z3_context c, Z3_ast t) { @@ -714,13 +714,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_is_negative(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_is_positive(Z3_context c, Z3_ast t) { @@ -729,13 +729,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_is_positive(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } @@ -745,19 +745,19 @@ extern "C" { RESET_ERROR_CODE(); if (!is_bv(c, bv) || !is_fp_sort(c, s)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); fpa_util & fu = ctx->fpautil(); if (!ctx->bvutil().is_bv(to_expr(bv)) || !fu.is_float(to_sort(s))) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } expr * a = fu.mk_to_fp(to_sort(s), to_expr(bv)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) { @@ -770,12 +770,12 @@ extern "C" { !fu.is_float(to_expr(t)) || !fu.is_float(to_sort(s))) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_fp_real(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) { @@ -788,12 +788,12 @@ extern "C" { !ctx->autil().is_real(to_expr(t)) || !fu.is_float(to_sort(s))) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) { @@ -806,12 +806,12 @@ extern "C" { !ctx->bvutil().is_bv(to_expr(t)) || !fu.is_float(to_sort(s))) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) { @@ -824,12 +824,12 @@ extern "C" { !ctx->bvutil().is_bv(to_expr(t)) || !fu.is_float(to_sort(s))) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } expr * a = fu.mk_to_fp_unsigned(to_sort(s), to_expr(rm), to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_ubv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz) { @@ -838,13 +838,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_to_ubv(to_expr(rm), to_expr(t), sz); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_sbv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz) { @@ -853,13 +853,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_rm(c, rm) || !is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_to_sbv(to_expr(rm), to_expr(t), sz); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_real(Z3_context c, Z3_ast t) { @@ -868,13 +868,13 @@ extern "C" { RESET_ERROR_CODE(); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); expr * a = ctx->fpautil().mk_to_real(to_expr(t)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_fpa_get_ebits(Z3_context c, Z3_sort s) { @@ -911,7 +911,7 @@ extern "C" { RESET_ERROR_CODE(); CHECK_NON_NULL(t, 0); CHECK_VALID_AST(t, 0); - if (sgn == 0) { + if (sgn == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG); return 0; } @@ -939,8 +939,8 @@ extern "C" { Z3_TRY; LOG_Z3_fpa_get_numeral_sign_bv(c, t); RESET_ERROR_CODE(); - CHECK_NON_NULL(t, 0); - CHECK_VALID_AST(t, 0); + CHECK_NON_NULL(t, nullptr); + CHECK_VALID_AST(t, nullptr); ast_manager & m = mk_c(c)->m(); mpf_manager & mpfm = mk_c(c)->fpautil().fm(); family_id fid = mk_c(c)->get_fpa_fid(); @@ -949,13 +949,13 @@ extern "C" { expr * e = to_expr(t); if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } scoped_mpf val(mpfm); bool r = plugin->is_numeral(to_expr(t), val); if (!r || mpfm.is_nan(val)) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } app * a; if (mpfm.is_pos(val)) @@ -964,15 +964,15 @@ extern "C" { a = ctx->bvutil().mk_numeral(1, 1); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_fpa_get_numeral_significand_bv(Z3_context c, Z3_ast t) { Z3_TRY; LOG_Z3_fpa_get_numeral_significand_bv(c, t); RESET_ERROR_CODE(); - CHECK_NON_NULL(t, 0); - CHECK_VALID_AST(t, 0); + CHECK_NON_NULL(t, nullptr); + CHECK_VALID_AST(t, nullptr); ast_manager & m = mk_c(c)->m(); mpf_manager & mpfm = mk_c(c)->fpautil().fm(); unsynch_mpq_manager & mpqm = mpfm.mpq_manager(); @@ -982,13 +982,13 @@ extern "C" { expr * e = to_expr(t); if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } scoped_mpf val(mpfm); bool r = plugin->is_numeral(e, val); if (!r || !(mpfm.is_normal(val) || mpfm.is_denormal(val) || mpfm.is_zero(val) || mpfm.is_inf(val))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } unsigned sbits = val.get().get_sbits(); scoped_mpq q(mpqm); @@ -997,15 +997,15 @@ extern "C" { app * a = mk_c(c)->bvutil().mk_numeral(q.get(), sbits-1); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_fpa_get_numeral_significand_string(Z3_context c, Z3_ast t) { Z3_TRY; LOG_Z3_fpa_get_numeral_significand_string(c, t); RESET_ERROR_CODE(); - CHECK_NON_NULL(t, 0); - CHECK_VALID_AST(t, 0); + CHECK_NON_NULL(t, nullptr); + CHECK_VALID_AST(t, nullptr); ast_manager & m = mk_c(c)->m(); mpf_manager & mpfm = mk_c(c)->fpautil().fm(); unsynch_mpq_manager & mpqm = mpfm.mpq_manager(); @@ -1041,7 +1041,7 @@ extern "C" { RESET_ERROR_CODE(); CHECK_NON_NULL(t, 0); CHECK_VALID_AST(t, 0); - if (n == 0) { + if (n == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG); return 0; } @@ -1076,8 +1076,8 @@ extern "C" { Z3_TRY; LOG_Z3_fpa_get_numeral_exponent_string(c, t, biased); RESET_ERROR_CODE(); - CHECK_NON_NULL(t, 0); - CHECK_VALID_AST(t, 0); + CHECK_NON_NULL(t, nullptr); + CHECK_VALID_AST(t, nullptr); ast_manager & m = mk_c(c)->m(); mpf_manager & mpfm = mk_c(c)->fpautil().fm(); family_id fid = mk_c(c)->get_fpa_fid(); @@ -1119,7 +1119,7 @@ extern "C" { RESET_ERROR_CODE(); CHECK_NON_NULL(t, 0); CHECK_VALID_AST(t, 0); - if (n == 0) { + if (n == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG); return 0; } @@ -1161,8 +1161,8 @@ extern "C" { Z3_TRY; LOG_Z3_fpa_get_numeral_exponent_bv(c, t, biased); RESET_ERROR_CODE(); - CHECK_NON_NULL(t, 0); - CHECK_VALID_AST(t, 0); + CHECK_NON_NULL(t, nullptr); + CHECK_VALID_AST(t, nullptr); ast_manager & m = mk_c(c)->m(); mpf_manager & mpfm = mk_c(c)->fpautil().fm(); family_id fid = mk_c(c)->get_fpa_fid(); @@ -1170,13 +1170,13 @@ extern "C" { expr * e = to_expr(t); if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } scoped_mpf val(mpfm); bool r = plugin->is_numeral(e, val); if (!r || !(mpfm.is_normal(val) || mpfm.is_denormal(val) || mpfm.is_zero(val) || mpfm.is_inf(val))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } unsigned ebits = val.get().get_ebits(); mpf_exp_t exp; @@ -1194,23 +1194,23 @@ extern "C" { app * a = mk_c(c)->bvutil().mk_numeral(exp, ebits); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_ieee_bv(Z3_context c, Z3_ast t) { Z3_TRY; LOG_Z3_mk_fpa_to_ieee_bv(c, t); RESET_ERROR_CODE(); - CHECK_NON_NULL(t, 0); - CHECK_VALID_AST(t, 0); + CHECK_NON_NULL(t, nullptr); + CHECK_VALID_AST(t, nullptr); if (!is_fp(c, t)) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } api::context * ctx = mk_c(c); Z3_ast r = of_ast(ctx->fpautil().mk_to_ieee_bv(to_expr(t))); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_fpa_to_fp_int_real(Z3_context c, Z3_ast rm, Z3_ast exp, Z3_ast sig, Z3_sort s) { @@ -1224,12 +1224,12 @@ extern "C" { !ctx->autil().is_real(to_expr(sig)) || !fu.is_float(to_sort(s))) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(exp), to_expr(sig)); ctx->save_ast_trail(a); RETURN_Z3(of_expr(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_fpa_is_numeral_nan(Z3_context c, Z3_ast t) { diff --git a/src/api/api_goal.cpp b/src/api/api_goal.cpp index 0f1b9056b..0783af5ab 100644 --- a/src/api/api_goal.cpp +++ b/src/api/api_goal.cpp @@ -30,14 +30,14 @@ extern "C" { RESET_ERROR_CODE(); if (proofs != 0 && !mk_c(c)->m().proofs_enabled()) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_goal_ref * g = alloc(Z3_goal_ref, *mk_c(c)); g->m_goal = alloc(goal, mk_c(c)->m(), proofs != 0, models != 0, unsat_cores != 0); mk_c(c)->save_object(g); Z3_goal r = of_goal(g); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_goal_inc_ref(Z3_context c, Z3_goal g) { @@ -119,12 +119,12 @@ extern "C" { RESET_ERROR_CODE(); if (idx >= to_goal_ref(g)->size()) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr * result = to_goal_ref(g)->form(idx); mk_c(c)->save_ast_trail(result); RETURN_Z3(of_ast(result)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_goal_num_exprs(Z3_context c, Z3_goal g) { @@ -161,7 +161,7 @@ extern "C" { mk_c(target)->save_object(_r); Z3_goal r = of_goal(_r); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_goal_to_string(Z3_context c, Z3_goal g) { diff --git a/src/api/api_goal.h b/src/api/api_goal.h index 3b109f8da..fa2ea61cf 100644 --- a/src/api/api_goal.h +++ b/src/api/api_goal.h @@ -29,6 +29,6 @@ struct Z3_goal_ref : public api::object { inline Z3_goal_ref * to_goal(Z3_goal g) { return reinterpret_cast(g); } inline Z3_goal of_goal(Z3_goal_ref * g) { return reinterpret_cast(g); } -inline goal_ref to_goal_ref(Z3_goal g) { return g == 0 ? goal_ref() : to_goal(g)->m_goal; } +inline goal_ref to_goal_ref(Z3_goal g) { return g == nullptr ? goal_ref() : to_goal(g)->m_goal; } #endif diff --git a/src/api/api_interp.cpp b/src/api/api_interp.cpp index d6f4e1128..1000a6d3b 100644 --- a/src/api/api_interp.cpp +++ b/src/api/api_interp.cpp @@ -110,7 +110,7 @@ extern "C" { pre_parents_vec, interpolants, theory_vec, - 0); // ignore params for now FIXME + nullptr); // ignore params for now FIXME // copy result back for (unsigned i = 0; i < interpolants.size(); i++){ @@ -174,7 +174,7 @@ extern "C" { itp_vec, theory_vec); - *error = res ? 0 : itp_err.str().c_str(); + *error = res ? nullptr : itp_err.str().c_str(); return res; } @@ -227,7 +227,7 @@ extern "C" { cnsts, _pat, interp, - (interpolation_options_struct *)0 // ignore params for now + (interpolation_options_struct *)nullptr // ignore params for now ); // copy result back @@ -236,7 +236,7 @@ extern "C" { _m.dec_ref(interp[i]); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_lbool Z3_API Z3_compute_interpolant(Z3_context c, Z3_ast pat, Z3_params p, Z3_ast_vector *out_interp, Z3_model *model){ @@ -283,7 +283,7 @@ extern "C" { cnsts, interp, m, - 0 // ignore params for now + nullptr // ignore params for now ); } catch (z3_exception & ex) { @@ -297,8 +297,8 @@ extern "C" { Z3_lbool status = of_lbool(_status); - Z3_ast_vector_ref *v = 0; - *model = 0; + Z3_ast_vector_ref *v = nullptr; + *model = nullptr; if (_status == l_false){ // copy result back @@ -510,7 +510,7 @@ extern "C" { read_error.clear(); try { std::string foo(filename); - Z3_ast assrts = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0); + Z3_ast assrts = Z3_parse_smtlib2_file(ctx, filename, 0, nullptr, nullptr, 0, nullptr, nullptr); Z3_app app = Z3_to_app(ctx, assrts); int nconjs = Z3_get_app_num_args(ctx, app); assertions.resize(nconjs); @@ -523,7 +523,7 @@ extern "C" { *error = read_msg.c_str(); return false; } - Z3_set_error_handler(ctx, 0); + Z3_set_error_handler(ctx, nullptr); return true; } @@ -571,7 +571,7 @@ extern "C" { hash_map pred_map; for (unsigned j = 0; j < num; j++){ - Z3_ast lhs = 0, rhs = read_cnsts[j]; + Z3_ast lhs = nullptr, rhs = read_cnsts[j]; if (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, rhs))) == Z3_OP_IMPLIES){ Z3_app app1 = Z3_to_app(ctx, rhs); diff --git a/src/api/api_log.cpp b/src/api/api_log.cpp index 410110d9a..1bdbb8735 100644 --- a/src/api/api_log.cpp +++ b/src/api/api_log.cpp @@ -21,15 +21,15 @@ Revision History: #include "util/util.h" #include "util/version.h" -std::ostream * g_z3_log = 0; +std::ostream * g_z3_log = nullptr; bool g_z3_log_enabled = false; extern "C" { void Z3_close_log_unsafe(void) { - if (g_z3_log != 0) { + if (g_z3_log != nullptr) { dealloc(g_z3_log); g_z3_log_enabled = false; - g_z3_log = 0; + g_z3_log = nullptr; } } @@ -40,12 +40,12 @@ extern "C" { #pragma omp critical (z3_log) { #endif - if (g_z3_log != 0) + if (g_z3_log != nullptr) Z3_close_log_unsafe(); g_z3_log = alloc(std::ofstream, filename); if (g_z3_log->bad() || g_z3_log->fail()) { dealloc(g_z3_log); - g_z3_log = 0; + g_z3_log = nullptr; res = Z3_FALSE; } else { @@ -61,13 +61,13 @@ extern "C" { } void Z3_API Z3_append_log(Z3_string str) { - if (g_z3_log == 0) + if (g_z3_log == nullptr) return; #ifdef Z3_LOG_SYNC #pragma omp critical (z3_log) { #endif - if (g_z3_log != 0) + if (g_z3_log != nullptr) _Z3_append_log(static_cast(str)); #ifdef Z3_LOG_SYNC } @@ -75,7 +75,7 @@ extern "C" { } void Z3_API Z3_close_log(void) { - if (g_z3_log != 0) { + if (g_z3_log != nullptr) { #ifdef Z3_LOG_SYNC #pragma omp critical (z3_log) { diff --git a/src/api/api_model.cpp b/src/api/api_model.cpp index d9936ff66..09a255738 100644 --- a/src/api/api_model.cpp +++ b/src/api/api_model.cpp @@ -38,7 +38,7 @@ extern "C" { m_ref->m_model = alloc(model, mk_c(c)->m()); mk_c(c)->save_object(m_ref); RETURN_Z3(of_model(m_ref)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_model_inc_ref(Z3_context c, Z3_model m) { @@ -65,14 +65,14 @@ extern "C" { Z3_TRY; LOG_Z3_model_get_const_interp(c, m, a); RESET_ERROR_CODE(); - CHECK_NON_NULL(m, 0); + CHECK_NON_NULL(m, nullptr); expr * r = to_model_ref(m)->get_const_interp(to_func_decl(a)); if (!r) { - RETURN_Z3(0); + RETURN_Z3(nullptr); } mk_c(c)->save_ast_trail(r); RETURN_Z3(of_expr(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_model_has_interp(Z3_context c, Z3_model m, Z3_func_decl a) { @@ -91,17 +91,17 @@ extern "C" { Z3_TRY; LOG_Z3_model_get_func_interp(c, m, f); RESET_ERROR_CODE(); - CHECK_NON_NULL(m, 0); + CHECK_NON_NULL(m, nullptr); func_interp * _fi = to_model_ref(m)->get_func_interp(to_func_decl(f)); if (!_fi) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_func_interp_ref * fi = alloc(Z3_func_interp_ref, *mk_c(c), to_model_ref(m)); fi->m_func_interp = _fi; mk_c(c)->save_object(fi); RETURN_Z3(of_func_interp(fi)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_model_get_num_consts(Z3_context c, Z3_model m) { @@ -117,16 +117,16 @@ extern "C" { Z3_TRY; LOG_Z3_model_get_const_decl(c, m, i); RESET_ERROR_CODE(); - CHECK_NON_NULL(m, 0); + CHECK_NON_NULL(m, nullptr); model * _m = to_model_ref(m); if (i < _m->get_num_constants()) { RETURN_Z3(of_func_decl(_m->get_constant(i))); } else { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_model_get_num_funcs(Z3_context c, Z3_model m) { @@ -139,11 +139,11 @@ extern "C" { } Z3_func_decl get_model_func_decl_core(Z3_context c, Z3_model m, unsigned i) { - CHECK_NON_NULL(m, 0); + CHECK_NON_NULL(m, nullptr); model * _m = to_model_ref(m); if (i >= _m->get_num_functions()) { SET_ERROR_CODE(Z3_IOB); - return 0; + return nullptr; } return of_func_decl(_m->get_function(i)); } @@ -154,13 +154,13 @@ extern "C" { RESET_ERROR_CODE(); Z3_func_decl r = get_model_func_decl_core(c, m, i); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_model_eval(Z3_context c, Z3_model m, Z3_ast t, Z3_bool model_completion, Z3_ast * v) { Z3_TRY; LOG_Z3_model_eval(c, m, t, model_completion, v); - if (v) *v = 0; + if (v) *v = nullptr; RESET_ERROR_CODE(); CHECK_NON_NULL(m, Z3_FALSE); CHECK_IS_EXPR(t, Z3_FALSE); @@ -187,11 +187,11 @@ extern "C" { RESET_ERROR_CODE(); if (i >= to_model_ref(m)->get_num_uninterpreted_sorts()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } sort * s = to_model_ref(m)->get_uninterpreted_sort(i); RETURN_Z3(of_sort(s)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast_vector Z3_API Z3_model_get_sort_universe(Z3_context c, Z3_model m, Z3_sort s) { @@ -200,7 +200,7 @@ extern "C" { RESET_ERROR_CODE(); if (!to_model_ref(m)->has_uninterpreted_sort(to_sort(s))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ptr_vector const & universe = to_model_ref(m)->get_universe(to_sort(s)); Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m()); @@ -210,7 +210,7 @@ extern "C" { v->m_ast_vector.push_back(universe[i]); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context target) { @@ -222,7 +222,7 @@ extern "C" { dst->m_model = to_model_ref(m)->translate(tr); mk_c(target)->save_object(dst); RETURN_Z3(of_model(dst)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_is_as_array(Z3_context c, Z3_ast a) { @@ -242,9 +242,9 @@ extern "C" { } else { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_func_interp Z3_API Z3_add_func_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast else_val) { @@ -259,7 +259,7 @@ extern "C" { mdl->register_decl(d, f_ref->m_func_interp); f_ref->m_func_interp->set_else(to_expr(else_val)); RETURN_Z3(of_func_interp(f_ref)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_add_const_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast a) { @@ -310,30 +310,30 @@ extern "C" { Z3_TRY; LOG_Z3_func_interp_get_entry(c, f, i); RESET_ERROR_CODE(); - CHECK_NON_NULL(f, 0); + CHECK_NON_NULL(f, nullptr); if (i >= to_func_interp_ref(f)->num_entries()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_func_entry_ref * e = alloc(Z3_func_entry_ref, *mk_c(c), to_func_interp(f)->m_model.get()); e->m_func_interp = to_func_interp_ref(f); e->m_func_entry = to_func_interp_ref(f)->get_entry(i); mk_c(c)->save_object(e); RETURN_Z3(of_func_entry(e)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_func_interp_get_else(Z3_context c, Z3_func_interp f) { Z3_TRY; LOG_Z3_func_interp_get_else(c, f); RESET_ERROR_CODE(); - CHECK_NON_NULL(f, 0); + CHECK_NON_NULL(f, nullptr); expr * e = to_func_interp_ref(f)->get_else(); if (e) { mk_c(c)->save_ast_trail(e); } RETURN_Z3(of_expr(e)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_func_interp_set_else(Z3_context c, Z3_func_interp f, Z3_ast else_value) { @@ -399,7 +399,7 @@ extern "C" { expr * v = to_func_entry_ref(e)->get_result(); mk_c(c)->save_ast_trail(v); RETURN_Z3(of_expr(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_func_entry_get_num_args(Z3_context c, Z3_func_entry e) { @@ -416,11 +416,11 @@ extern "C" { RESET_ERROR_CODE(); if (i >= to_func_entry(e)->m_func_interp->get_arity()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr * r = to_func_entry(e)->m_func_entry->get_arg(i); RETURN_Z3(of_expr(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } // ---------------------------- @@ -491,7 +491,7 @@ extern "C" { Z3_TRY; LOG_Z3_model_to_string(c, m); RESET_ERROR_CODE(); - CHECK_NON_NULL(m, 0); + CHECK_NON_NULL(m, nullptr); std::ostringstream buffer; std::string result; if (mk_c(c)->get_print_mode() == Z3_PRINT_SMTLIB2_COMPLIANT) { @@ -507,7 +507,7 @@ extern "C" { result = buffer.str(); } return mk_c(c)->mk_external_string(result); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_model.h b/src/api/api_model.h index 1ab10da79..fa94e9728 100644 --- a/src/api/api_model.h +++ b/src/api/api_model.h @@ -34,7 +34,7 @@ inline model * to_model_ref(Z3_model s) { return to_model(s)->m_model.get(); } struct Z3_func_interp_ref : public api::object { model_ref m_model; // must have it to prevent reference to m_func_interp to be killed. func_interp * m_func_interp; - Z3_func_interp_ref(api::context& c, model * m): api::object(c), m_model(m), m_func_interp(0) {} + Z3_func_interp_ref(api::context& c, model * m): api::object(c), m_model(m), m_func_interp(nullptr) {} ~Z3_func_interp_ref() override {} }; @@ -46,7 +46,7 @@ struct Z3_func_entry_ref : public api::object { model_ref m_model; // must have it to prevent reference to m_func_entry to be killed. func_interp * m_func_interp; func_entry const * m_func_entry; - Z3_func_entry_ref(api::context& c, model * m):api::object(c), m_model(m), m_func_interp(0), m_func_entry(0) {} + Z3_func_entry_ref(api::context& c, model * m):api::object(c), m_model(m), m_func_interp(nullptr), m_func_entry(nullptr) {} ~Z3_func_entry_ref() override {} }; diff --git a/src/api/api_numeral.cpp b/src/api/api_numeral.cpp index d3dabcd4e..5aa762a96 100644 --- a/src/api/api_numeral.cpp +++ b/src/api/api_numeral.cpp @@ -52,11 +52,11 @@ extern "C" { LOG_Z3_mk_numeral(c, n, ty); RESET_ERROR_CODE(); if (!check_numeral_sort(c, ty)) { - RETURN_Z3(0); + RETURN_Z3(nullptr); } if (!n) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } sort * _ty = to_sort(ty); bool is_float = mk_c(c)->fpautil().is_float(_ty); @@ -73,11 +73,11 @@ extern "C" { ('P' == *m) || ('+' == *m))))) { SET_ERROR_CODE(Z3_PARSER_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } ++m; } - ast * a = 0; + ast * a = nullptr; if (_ty->get_family_id() == mk_c(c)->get_fpa_fid()) { // avoid expanding floats into huge rationals. fpa_util & fu = mk_c(c)->fpautil(); @@ -89,7 +89,7 @@ extern "C" { else a = mk_c(c)->mk_numeral_core(rational(n), _ty); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_int(Z3_context c, int value, Z3_sort ty) { @@ -97,11 +97,11 @@ extern "C" { LOG_Z3_mk_int(c, value, ty); RESET_ERROR_CODE(); if (!check_numeral_sort(c, ty)) { - RETURN_Z3(0); + RETURN_Z3(nullptr); } ast * a = mk_c(c)->mk_numeral_core(rational(value), to_sort(ty)); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_unsigned_int(Z3_context c, unsigned value, Z3_sort ty) { @@ -109,11 +109,11 @@ extern "C" { LOG_Z3_mk_unsigned_int(c, value, ty); RESET_ERROR_CODE(); if (!check_numeral_sort(c, ty)) { - RETURN_Z3(0); + RETURN_Z3(nullptr); } ast * a = mk_c(c)->mk_numeral_core(rational(value), to_sort(ty)); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_int64(Z3_context c, long long value, Z3_sort ty) { @@ -121,12 +121,12 @@ extern "C" { LOG_Z3_mk_int64(c, value, ty); RESET_ERROR_CODE(); if (!check_numeral_sort(c, ty)) { - RETURN_Z3(0); + RETURN_Z3(nullptr); } rational n(value, rational::i64()); ast* a = mk_c(c)->mk_numeral_core(n, to_sort(ty)); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, unsigned long long value, Z3_sort ty) { @@ -134,12 +134,12 @@ extern "C" { LOG_Z3_mk_unsigned_int64(c, value, ty); RESET_ERROR_CODE(); if (!check_numeral_sort(c, ty)) { - RETURN_Z3(0); + RETURN_Z3(nullptr); } rational n(value, rational::ui64()); ast * a = mk_c(c)->mk_numeral_core(n, to_sort(ty)); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_is_numeral_ast(Z3_context c, Z3_ast a) { @@ -397,7 +397,7 @@ extern "C" { } ast * a = mk_c(c)->mk_numeral_core(r, mk_c(c)->bvutil().mk_sort(sz)); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_opt.cpp b/src/api/api_opt.cpp index 72180388e..2712eef6f 100644 --- a/src/api/api_opt.cpp +++ b/src/api/api_opt.cpp @@ -35,7 +35,7 @@ extern "C" { struct Z3_optimize_ref : public api::object { opt::context* m_opt; - Z3_optimize_ref(api::context& c): api::object(c), m_opt(0) {} + Z3_optimize_ref(api::context& c): api::object(c), m_opt(nullptr) {} ~Z3_optimize_ref() override { dealloc(m_opt); } }; inline Z3_optimize_ref * to_optimize(Z3_optimize o) { return reinterpret_cast(o); } @@ -50,7 +50,7 @@ extern "C" { o->m_opt = alloc(opt::context,mk_c(c)->m()); mk_c(c)->save_object(o); RETURN_Z3(of_optimize(o)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_optimize_inc_ref(Z3_context c, Z3_optimize o) { @@ -171,7 +171,7 @@ extern "C" { } mk_c(c)->save_object(m_ref); RETURN_Z3(of_model(m_ref)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_optimize_set_params(Z3_context c, Z3_optimize o, Z3_params p) { @@ -195,7 +195,7 @@ extern "C" { to_optimize_ptr(o)->collect_param_descrs(d->m_descrs); Z3_param_descrs r = of_param_descrs(d); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } // get lower value or current approximation @@ -206,7 +206,7 @@ extern "C" { expr_ref e = to_optimize_ptr(o)->get_lower(idx); mk_c(c)->save_ast_trail(e); RETURN_Z3(of_expr(e)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } // get upper or current approximation @@ -217,7 +217,7 @@ extern "C" { expr_ref e = to_optimize_ptr(o)->get_upper(idx); mk_c(c)->save_ast_trail(e); RETURN_Z3(of_expr(e)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } // get lower value or current approximation @@ -231,7 +231,7 @@ extern "C" { mk_c(c)->save_object(v); v->m_ast_vector.append(es.size(), (ast*const*)es.c_ptr()); RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } // get upper or current approximation @@ -245,7 +245,7 @@ extern "C" { mk_c(c)->save_object(v); v->m_ast_vector.append(es.size(), (ast*const*)es.c_ptr()); RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_optimize_to_string(Z3_context c, Z3_optimize o) { @@ -277,7 +277,7 @@ extern "C" { mk_c(c)->save_object(st); Z3_stats r = of_stats(st); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } static void Z3_optimize_from_stream( @@ -367,7 +367,7 @@ extern "C" { v->m_ast_vector.push_back(h); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast_vector Z3_API Z3_optimize_get_objectives(Z3_context c, Z3_optimize o) { @@ -381,7 +381,7 @@ extern "C" { v->m_ast_vector.push_back(to_optimize_ptr(o)->get_objective(i)); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } diff --git a/src/api/api_params.cpp b/src/api/api_params.cpp index 3f3cbed1d..d021ed6ad 100644 --- a/src/api/api_params.cpp +++ b/src/api/api_params.cpp @@ -34,7 +34,7 @@ extern "C" { mk_c(c)->save_object(p); Z3_params r = of_params(p); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } /** @@ -172,11 +172,11 @@ extern "C" { RESET_ERROR_CODE(); if (i >= to_param_descrs_ptr(p)->size()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_symbol result = of_symbol(to_param_descrs_ptr(p)->get_param_name(i)); return result; - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_param_descrs_get_documentation(Z3_context c, Z3_param_descrs p, Z3_symbol s) { @@ -184,12 +184,12 @@ extern "C" { LOG_Z3_param_descrs_get_documentation(c, p, s); RESET_ERROR_CODE(); char const* result = to_param_descrs_ptr(p)->get_descr(to_symbol(s)); - if (result == 0) { + if (result == nullptr) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } return mk_c(c)->mk_external_string(result); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_param_descrs_to_string(Z3_context c, Z3_param_descrs p) { diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index d5a98672b..2e33c1a13 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -80,7 +80,7 @@ extern "C" { ptr_vector::const_iterator end = ctx->end_assertions(); unsigned size = static_cast(end - it); return of_ast(mk_c(c)->mk_and(size, it)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_parse_smtlib2_string(Z3_context c, Z3_string str, @@ -96,7 +96,7 @@ extern "C" { std::istringstream is(s); Z3_ast r = parse_smtlib2_stream(false, c, is, num_sorts, sort_names, sorts, num_decls, decl_names, decls); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_parse_smtlib2_file(Z3_context c, Z3_string file_name, @@ -111,10 +111,10 @@ extern "C" { std::ifstream is(file_name); if (!is) { SET_ERROR_CODE(Z3_PARSER_ERROR); - return 0; + return nullptr; } Z3_ast r = parse_smtlib2_stream(false, c, is, num_sorts, sort_names, sorts, num_decls, decl_names, decls); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_pb.cpp b/src/api/api_pb.cpp index e6f8f77b4..8116789f9 100644 --- a/src/api/api_pb.cpp +++ b/src/api/api_pb.cpp @@ -34,7 +34,7 @@ extern "C" { mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_atleast(Z3_context c, unsigned num_args, @@ -48,7 +48,7 @@ extern "C" { mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_pble(Z3_context c, unsigned num_args, @@ -66,7 +66,7 @@ extern "C" { mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_pbge(Z3_context c, unsigned num_args, @@ -84,7 +84,7 @@ extern "C" { mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_pbeq(Z3_context c, unsigned num_args, @@ -102,7 +102,7 @@ extern "C" { mk_c(c)->save_ast_trail(a); check_sorts(c, a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } diff --git a/src/api/api_polynomial.cpp b/src/api/api_polynomial.cpp index 9be73289f..35ece4a59 100644 --- a/src/api/api_polynomial.cpp +++ b/src/api/api_polynomial.cpp @@ -50,7 +50,7 @@ extern "C" { if (!converter.to_polynomial(to_expr(p), _p, d) || !converter.to_polynomial(to_expr(q), _q, d)) { SET_ERROR_CODE(Z3_INVALID_ARG); - return 0; + return nullptr; } Z3_ast_vector_ref* result = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m()); mk_c(c)->save_object(result); @@ -74,7 +74,7 @@ extern "C" { } } RETURN_Z3(of_ast_vector(result)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_qe.cpp b/src/api/api_qe.cpp index 34f21d64b..2516aacfb 100644 --- a/src/api/api_qe.cpp +++ b/src/api/api_qe.cpp @@ -56,7 +56,7 @@ extern "C" app_ref_vector vars(mk_c(c)->m ()); if (!to_apps(num_bounds, bound, vars)) { SET_ERROR_CODE (Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr_ref result (mk_c(c)->m ()); @@ -66,7 +66,7 @@ extern "C" mk_c(c)->save_ast_trail (result.get ()); return of_expr (result.get ()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_qe_model_project_skolem (Z3_context c, @@ -83,7 +83,7 @@ extern "C" ast_manager& man = mk_c(c)->m (); app_ref_vector vars(man); if (!to_apps(num_bounds, bound, vars)) { - RETURN_Z3(0); + RETURN_Z3(nullptr); } expr_ref result (mk_c(c)->m ()); @@ -103,7 +103,7 @@ extern "C" } return of_expr (result.get ()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_model_extrapolate (Z3_context c, @@ -130,7 +130,7 @@ extern "C" mk_c(c)->save_ast_trail (result.get ()); return of_expr (result.get ()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_qe_lite (Z3_context c, Z3_ast_vector vars, Z3_ast body) @@ -145,7 +145,7 @@ extern "C" app *a = to_app (vVars.get (i)); if (a->get_kind () != AST_APP) { SET_ERROR_CODE (Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } vApps.push_back (a); } @@ -167,7 +167,7 @@ extern "C" mk_c(c)->save_ast_trail (result.get ()); return of_expr (result); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } } diff --git a/src/api/api_quant.cpp b/src/api/api_quant.cpp index e56505e6d..6e0162024 100644 --- a/src/api/api_quant.cpp +++ b/src/api/api_quant.cpp @@ -37,10 +37,10 @@ extern "C" { c, is_forall, weight, - 0, - 0, + nullptr, + nullptr, num_patterns, patterns, - 0, 0, + 0, nullptr, num_decls, sorts, decl_names, body @@ -104,7 +104,7 @@ extern "C" { } mk_c(c)->save_ast_trail(result.get()); return of_ast(result.get()); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_quantifier_ex( @@ -166,17 +166,17 @@ extern "C" { ptr_vector bound_asts; if (num_patterns > 0 && num_no_patterns > 0) { SET_ERROR_CODE(Z3_INVALID_USAGE); - RETURN_Z3(0); + RETURN_Z3(nullptr); } if (num_bound == 0) { SET_ERROR_CODE(Z3_INVALID_USAGE); - RETURN_Z3(0); + RETURN_Z3(nullptr); } for (unsigned i = 0; i < num_bound; ++i) { app* a = to_app(bound[i]); if (a->get_kind() != AST_APP) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } symbol s(to_app(a)->get_decl()->get_name()); names.push_back(of_symbol(s)); @@ -184,7 +184,7 @@ extern "C" { bound_asts.push_back(a); if (a->get_family_id() != null_family_id || a->get_num_args() != 0) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } } // Abstract patterns @@ -205,7 +205,7 @@ extern "C" { expr_ref result(mk_c(c)->m()); if (!is_app(to_expr(no_patterns[i]))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } app* pat = to_app(to_expr(no_patterns[i])); expr_abstract(mk_c(c)->m(), 0, num_bound, bound_asts.c_ptr(), pat, result); @@ -224,7 +224,7 @@ extern "C" { names.size(), types.c_ptr(), names.c_ptr(), of_ast(abs_body.get())); RETURN_Z3(result); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_quantifier_const(Z3_context c, @@ -235,10 +235,10 @@ extern "C" { unsigned num_patterns, Z3_pattern const patterns[], Z3_ast body) { - return Z3_mk_quantifier_const_ex(c, is_forall, weight, 0, 0, + return Z3_mk_quantifier_const_ex(c, is_forall, weight, nullptr, nullptr, num_bound, bound, num_patterns, patterns, - 0, 0, + 0, nullptr, body); } @@ -269,13 +269,13 @@ extern "C" { for (unsigned i = 0; i < num_patterns; ++i) { if (!is_app(to_expr(terms[i]))) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } } app* a = mk_c(c)->m().mk_pattern(num_patterns, reinterpret_cast(to_exprs(terms))); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_pattern(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_bound(Z3_context c, unsigned index, Z3_sort ty) { @@ -285,7 +285,7 @@ extern "C" { ast* a = mk_c(c)->m().mk_var(index, to_sort(ty)); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a) { @@ -344,9 +344,9 @@ extern "C" { } else { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } @@ -376,9 +376,9 @@ extern "C" { } else { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_symbol Z3_API Z3_get_quantifier_bound_name(Z3_context c, Z3_ast a, unsigned i) { @@ -391,9 +391,9 @@ extern "C" { } else { SET_ERROR_CODE(Z3_SORT_ERROR); - return 0; + return nullptr; } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_get_quantifier_bound_sort(Z3_context c, Z3_ast a, unsigned i) { @@ -407,9 +407,9 @@ extern "C" { } else { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a) { @@ -423,9 +423,9 @@ extern "C" { } else { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_get_quantifier_num_bound(Z3_context c, Z3_ast a) { @@ -470,9 +470,9 @@ extern "C" { } else { SET_ERROR_CODE(Z3_SORT_ERROR); - RETURN_Z3(0); + RETURN_Z3(nullptr); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_pattern_to_ast(Z3_context c, Z3_pattern p) { diff --git a/src/api/api_rcf.cpp b/src/api/api_rcf.cpp index 84c250114..3d65cb1cd 100644 --- a/src/api/api_rcf.cpp +++ b/src/api/api_rcf.cpp @@ -62,7 +62,7 @@ extern "C" { rcnumeral r; rcfm(c).set(r, q); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_mk_small_int(Z3_context c, int val) { @@ -73,7 +73,7 @@ extern "C" { rcnumeral r; rcfm(c).set(r, val); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_mk_pi(Z3_context c) { @@ -84,7 +84,7 @@ extern "C" { rcnumeral r; rcfm(c).mk_pi(r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_mk_e(Z3_context c) { @@ -95,7 +95,7 @@ extern "C" { rcnumeral r; rcfm(c).mk_e(r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_mk_infinitesimal(Z3_context c) { @@ -106,7 +106,7 @@ extern "C" { rcnumeral r; rcfm(c).mk_infinitesimal(r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_rcf_mk_roots(Z3_context c, unsigned n, Z3_rcf_num const a[], Z3_rcf_num roots[]) { @@ -145,7 +145,7 @@ extern "C" { rcnumeral r; rcfm(c).add(to_rcnumeral(a), to_rcnumeral(b), r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_sub(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) { @@ -156,7 +156,7 @@ extern "C" { rcnumeral r; rcfm(c).sub(to_rcnumeral(a), to_rcnumeral(b), r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_mul(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) { @@ -167,7 +167,7 @@ extern "C" { rcnumeral r; rcfm(c).mul(to_rcnumeral(a), to_rcnumeral(b), r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_div(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) { @@ -178,7 +178,7 @@ extern "C" { rcnumeral r; rcfm(c).div(to_rcnumeral(a), to_rcnumeral(b), r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_neg(Z3_context c, Z3_rcf_num a) { @@ -189,7 +189,7 @@ extern "C" { rcnumeral r; rcfm(c).neg(to_rcnumeral(a), r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_inv(Z3_context c, Z3_rcf_num a) { @@ -200,7 +200,7 @@ extern "C" { rcnumeral r; rcfm(c).inv(to_rcnumeral(a), r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_rcf_num Z3_API Z3_rcf_power(Z3_context c, Z3_rcf_num a, unsigned k) { @@ -211,7 +211,7 @@ extern "C" { rcnumeral r; rcfm(c).power(to_rcnumeral(a), k, r); RETURN_Z3(from_rcnumeral(r)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_rcf_lt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) { diff --git a/src/api/api_seq.cpp b/src/api/api_seq.cpp index 428d86d0d..84cfdca32 100644 --- a/src/api/api_seq.cpp +++ b/src/api/api_seq.cpp @@ -31,7 +31,7 @@ extern "C" { sort * ty = mk_c(c)->sutil().str.mk_seq(to_sort(domain)); mk_c(c)->save_ast_trail(ty); RETURN_Z3(of_sort(ty)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_re_sort(Z3_context c, Z3_sort domain) { @@ -41,7 +41,7 @@ extern "C" { sort * ty = mk_c(c)->sutil().re.mk_re(to_sort(domain)); mk_c(c)->save_ast_trail(ty); RETURN_Z3(of_sort(ty)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_mk_string(Z3_context c, Z3_string str) { @@ -52,7 +52,7 @@ extern "C" { app* a = mk_c(c)->sutil().str.mk_string(s); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_sort Z3_API Z3_mk_string_sort(Z3_context c) { @@ -62,7 +62,7 @@ extern "C" { sort* ty = mk_c(c)->sutil().str.mk_string_sort(); mk_c(c)->save_ast_trail(ty); RETURN_Z3(of_sort(ty)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_bool Z3_API Z3_is_seq_sort(Z3_context c, Z3_sort s) { @@ -152,7 +152,7 @@ extern "C" { app* a = hi == 0 ? mk_c(c)->sutil().re.mk_loop(to_expr(r), lo) : mk_c(c)->sutil().re.mk_loop(to_expr(r), lo, hi); mk_c(c)->save_ast_trail(a); RETURN_Z3(of_ast(a)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } MK_UNARY(Z3_mk_re_plus, mk_c(c)->get_seq_fid(), OP_RE_PLUS, SKIP); diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index 0a0039f4c..aab783afa 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -57,7 +57,7 @@ extern "C" { } static void init_solver(Z3_context c, Z3_solver s) { - if (to_solver(s)->m_solver.get() == 0) + if (to_solver(s)->m_solver.get() == nullptr) init_solver_core(c, s); } @@ -69,7 +69,7 @@ extern "C" { mk_c(c)->save_object(s); Z3_solver r = of_solver(s); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_solver Z3_API Z3_mk_solver(Z3_context c) { @@ -80,7 +80,7 @@ extern "C" { mk_c(c)->save_object(s); Z3_solver r = of_solver(s); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_solver Z3_API Z3_mk_solver_for_logic(Z3_context c, Z3_symbol logic) { @@ -91,7 +91,7 @@ extern "C" { std::ostringstream strm; strm << "logic '" << to_symbol(logic) << "' is not recognized"; throw default_exception(strm.str()); - RETURN_Z3(0); + RETURN_Z3(nullptr); } else { Z3_solver_ref * s = alloc(Z3_solver_ref, *mk_c(c), mk_smt_strategic_solver_factory(to_symbol(logic))); @@ -99,7 +99,7 @@ extern "C" { Z3_solver r = of_solver(s); RETURN_Z3(r); } - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_solver Z3_API Z3_mk_solver_from_tactic(Z3_context c, Z3_tactic t) { @@ -110,7 +110,7 @@ extern "C" { mk_c(c)->save_object(s); Z3_solver r = of_solver(s); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_solver Z3_API Z3_solver_translate(Z3_context c, Z3_solver s, Z3_context target) { @@ -118,13 +118,13 @@ extern "C" { LOG_Z3_solver_translate(c, s, target); RESET_ERROR_CODE(); params_ref const& p = to_solver(s)->m_params; - Z3_solver_ref * sr = alloc(Z3_solver_ref, *mk_c(target), 0); + Z3_solver_ref * sr = alloc(Z3_solver_ref, *mk_c(target), nullptr); init_solver(c, s); sr->m_solver = to_solver(s)->m_solver->translate(mk_c(target)->m(), p); mk_c(target)->save_object(sr); Z3_solver r = of_solver(sr); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void solver_from_stream(Z3_context c, Z3_solver s, std::istream& is) { @@ -137,7 +137,7 @@ extern "C" { return; } - bool initialized = to_solver(s)->m_solver.get() != 0; + bool initialized = to_solver(s)->m_solver.get() != nullptr; if (!initialized) init_solver(c, s); ptr_vector::const_iterator it = ctx->begin_assertions(); @@ -190,13 +190,13 @@ extern "C" { RESET_ERROR_CODE(); std::ostringstream buffer; param_descrs descrs; - bool initialized = to_solver(s)->m_solver.get() != 0; + bool initialized = to_solver(s)->m_solver.get() != nullptr; if (!initialized) init_solver(c, s); to_solver_ref(s)->collect_param_descrs(descrs); context_params::collect_solver_param_descrs(descrs); if (!initialized) - to_solver(s)->m_solver = 0; + to_solver(s)->m_solver = nullptr; descrs.display(buffer); return mk_c(c)->mk_external_string(buffer.str()); Z3_CATCH_RETURN(""); @@ -208,16 +208,16 @@ extern "C" { RESET_ERROR_CODE(); Z3_param_descrs_ref * d = alloc(Z3_param_descrs_ref, *mk_c(c)); mk_c(c)->save_object(d); - bool initialized = to_solver(s)->m_solver.get() != 0; + bool initialized = to_solver(s)->m_solver.get() != nullptr; if (!initialized) init_solver(c, s); to_solver_ref(s)->collect_param_descrs(d->m_descrs); context_params::collect_solver_param_descrs(d->m_descrs); if (!initialized) - to_solver(s)->m_solver = 0; + to_solver(s)->m_solver = nullptr; Z3_param_descrs r = of_param_descrs(d); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_solver_set_params(Z3_context c, Z3_solver s, Z3_params p) { @@ -288,7 +288,7 @@ extern "C" { Z3_TRY; LOG_Z3_solver_reset(c, s); RESET_ERROR_CODE(); - to_solver(s)->m_solver = 0; + to_solver(s)->m_solver = nullptr; Z3_CATCH; } @@ -334,7 +334,7 @@ extern "C" { v->m_ast_vector.push_back(to_solver_ref(s)->get_assertion(i)); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } static Z3_lbool _solver_check(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[]) { @@ -375,7 +375,7 @@ extern "C" { LOG_Z3_solver_check(c, s); RESET_ERROR_CODE(); init_solver(c, s); - return _solver_check(c, s, 0, 0); + return _solver_check(c, s, 0, nullptr); Z3_CATCH_RETURN(Z3_L_UNDEF); } @@ -397,13 +397,13 @@ extern "C" { to_solver_ref(s)->get_model(_m); if (!_m) { SET_ERROR_CODE(Z3_INVALID_USAGE); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_model_ref * m_ref = alloc(Z3_model_ref, *mk_c(c)); m_ref->m_model = _m; mk_c(c)->save_object(m_ref); RETURN_Z3(of_model(m_ref)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast Z3_API Z3_solver_get_proof(Z3_context c, Z3_solver s) { @@ -414,11 +414,11 @@ extern "C" { proof * p = to_solver_ref(s)->get_proof(); if (!p) { SET_ERROR_CODE(Z3_INVALID_USAGE); - RETURN_Z3(0); + RETURN_Z3(nullptr); } mk_c(c)->save_ast_trail(p); RETURN_Z3(of_ast(p)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_ast_vector Z3_API Z3_solver_get_unsat_core(Z3_context c, Z3_solver s) { @@ -434,7 +434,7 @@ extern "C" { v->m_ast_vector.push_back(core[i]); } RETURN_Z3(of_ast_vector(v)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_solver_get_reason_unknown(Z3_context c, Z3_solver s) { @@ -458,7 +458,7 @@ extern "C" { mk_c(c)->save_object(st); Z3_stats r = of_stats(st); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_solver_to_string(Z3_context c, Z3_solver s) { diff --git a/src/api/api_solver.h b/src/api/api_solver.h index 3da702f1e..90d1c2c65 100644 --- a/src/api/api_solver.h +++ b/src/api/api_solver.h @@ -26,7 +26,7 @@ struct Z3_solver_ref : public api::object { ref m_solver; params_ref m_params; symbol m_logic; - Z3_solver_ref(api::context& c, solver_factory * f): api::object(c), m_solver_factory(f), m_solver(0), m_logic(symbol::null) {} + Z3_solver_ref(api::context& c, solver_factory * f): api::object(c), m_solver_factory(f), m_solver(nullptr), m_logic(symbol::null) {} ~Z3_solver_ref() override {} }; diff --git a/src/api/api_tactic.cpp b/src/api/api_tactic.cpp index ccb1ce597..fb2c10b68 100644 --- a/src/api/api_tactic.cpp +++ b/src/api/api_tactic.cpp @@ -51,13 +51,13 @@ extern "C" { LOG_Z3_mk_tactic(c, name); RESET_ERROR_CODE(); tactic_cmd * t = mk_c(c)->find_tactic_cmd(symbol(name)); - if (t == 0) { + if (t == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } tactic * new_t = t->mk(mk_c(c)->m()); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_tactic_inc_ref(Z3_context c, Z3_tactic t) { @@ -81,13 +81,13 @@ extern "C" { LOG_Z3_mk_probe(c, name); RESET_ERROR_CODE(); probe_info * p = mk_c(c)->find_probe(symbol(name)); - if (p == 0) { + if (p == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG); - RETURN_Z3(0); + RETURN_Z3(nullptr); } probe * new_p = p->get(); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_probe_inc_ref(Z3_context c, Z3_probe p) { @@ -112,7 +112,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = and_then(to_tactic_ref(t1), to_tactic_ref(t2)); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_or_else(Z3_context c, Z3_tactic t1, Z3_tactic t2) { @@ -121,7 +121,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = or_else(to_tactic_ref(t1), to_tactic_ref(t2)); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_par_or(Z3_context c, unsigned num, Z3_tactic const ts[]) { @@ -134,7 +134,7 @@ extern "C" { } tactic * new_t = par(num, _ts.c_ptr()); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_par_and_then(Z3_context c, Z3_tactic t1, Z3_tactic t2) { @@ -143,7 +143,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = par_and_then(to_tactic_ref(t1), to_tactic_ref(t2)); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_try_for(Z3_context c, Z3_tactic t, unsigned ms) { @@ -152,7 +152,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = try_for(to_tactic_ref(t), ms); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_when(Z3_context c, Z3_probe p, Z3_tactic t) { @@ -161,7 +161,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = when(to_probe_ref(p), to_tactic_ref(t)); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_cond(Z3_context c, Z3_probe p, Z3_tactic t1, Z3_tactic t2) { @@ -170,7 +170,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = cond(to_probe_ref(p), to_tactic_ref(t1), to_tactic_ref(t2)); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_repeat(Z3_context c, Z3_tactic t, unsigned max) { @@ -179,7 +179,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = repeat(to_tactic_ref(t), max); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_skip(Z3_context c) { @@ -188,7 +188,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = mk_skip_tactic(); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_fail(Z3_context c) { @@ -197,7 +197,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = mk_fail_tactic(); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_fail_if(Z3_context c, Z3_probe p) { @@ -206,7 +206,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = fail_if(to_probe_ref(p)); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_fail_if_not_decided(Z3_context c) { @@ -215,7 +215,7 @@ extern "C" { RESET_ERROR_CODE(); tactic * new_t = mk_fail_if_undecided_tactic(); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_tactic Z3_API Z3_tactic_using_params(Z3_context c, Z3_tactic t, Z3_params p) { @@ -227,7 +227,7 @@ extern "C" { to_param_ref(p).validate(r); tactic * new_t = using_params(to_tactic_ref(t), to_param_ref(p)); RETURN_TACTIC(new_t); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_const(Z3_context c, double val) { @@ -236,7 +236,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_const_probe(val); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_lt(Z3_context c, Z3_probe p1, Z3_probe p2) { @@ -245,7 +245,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_lt(to_probe_ref(p1), to_probe_ref(p2)); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_gt(Z3_context c, Z3_probe p1, Z3_probe p2) { @@ -254,7 +254,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_gt(to_probe_ref(p1), to_probe_ref(p2)); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_le(Z3_context c, Z3_probe p1, Z3_probe p2) { @@ -263,7 +263,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_le(to_probe_ref(p1), to_probe_ref(p2)); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_ge(Z3_context c, Z3_probe p1, Z3_probe p2) { @@ -272,7 +272,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_ge(to_probe_ref(p1), to_probe_ref(p2)); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_eq(Z3_context c, Z3_probe p1, Z3_probe p2) { @@ -281,7 +281,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_eq(to_probe_ref(p1), to_probe_ref(p2)); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_and(Z3_context c, Z3_probe p1, Z3_probe p2) { @@ -290,7 +290,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_and(to_probe_ref(p1), to_probe_ref(p2)); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_or(Z3_context c, Z3_probe p1, Z3_probe p2) { @@ -299,7 +299,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_or(to_probe_ref(p1), to_probe_ref(p2)); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_probe Z3_API Z3_probe_not(Z3_context c, Z3_probe p) { @@ -308,7 +308,7 @@ extern "C" { RESET_ERROR_CODE(); probe * new_p = mk_not(to_probe_ref(p)); RETURN_PROBE(new_p); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } unsigned Z3_API Z3_get_num_tactics(Z3_context c) { @@ -372,7 +372,7 @@ extern "C" { to_tactic_ref(t)->collect_param_descrs(d->m_descrs); Z3_param_descrs r = of_param_descrs(d); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_string Z3_API Z3_tactic_get_descr(Z3_context c, Z3_string name) { @@ -380,7 +380,7 @@ extern "C" { LOG_Z3_tactic_get_descr(c, name); RESET_ERROR_CODE(); tactic_cmd * t = mk_c(c)->find_tactic_cmd(symbol(name)); - if (t == 0) { + if (t == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG); return ""; } @@ -393,7 +393,7 @@ extern "C" { LOG_Z3_probe_get_descr(c, name); RESET_ERROR_CODE(); probe_info * p = mk_c(c)->find_probe(symbol(name)); - if (p == 0) { + if (p == nullptr) { SET_ERROR_CODE(Z3_INVALID_ARG); return ""; } @@ -423,7 +423,7 @@ extern "C" { } catch (z3_exception & ex) { mk_c(c)->handle_exception(ex); - return 0; + return nullptr; } } } @@ -443,7 +443,7 @@ extern "C" { params_ref p; Z3_apply_result r = _tactic_apply(c, t, g, p); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_apply_result Z3_API Z3_tactic_apply_ex(Z3_context c, Z3_tactic t, Z3_goal g, Z3_params p) { @@ -455,7 +455,7 @@ extern "C" { to_param_ref(p).validate(pd); Z3_apply_result r = _tactic_apply(c, t, g, to_param_ref(p)); RETURN_Z3(r); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } void Z3_API Z3_apply_result_inc_ref(Z3_context c, Z3_apply_result r) { @@ -503,14 +503,14 @@ extern "C" { RESET_ERROR_CODE(); if (i > to_apply_result(r)->m_subgoals.size()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } Z3_goal_ref * g = alloc(Z3_goal_ref, *mk_c(c)); g->m_goal = to_apply_result(r)->m_subgoals[i]; mk_c(c)->save_object(g); Z3_goal result = of_goal(g); RETURN_Z3(result); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } Z3_model Z3_API Z3_apply_result_convert_model(Z3_context c, Z3_apply_result r, unsigned i, Z3_model m) { @@ -519,7 +519,7 @@ extern "C" { RESET_ERROR_CODE(); if (i > to_apply_result(r)->m_subgoals.size()) { SET_ERROR_CODE(Z3_IOB); - RETURN_Z3(0); + RETURN_Z3(nullptr); } model_ref new_m = to_model_ref(m)->copy(); if (to_apply_result(r)->m_mc) @@ -528,7 +528,7 @@ extern "C" { m_ref->m_model = new_m; mk_c(c)->save_object(m_ref); RETURN_Z3(of_model(m_ref)); - Z3_CATCH_RETURN(0); + Z3_CATCH_RETURN(nullptr); } }; diff --git a/src/api/api_tactic.h b/src/api/api_tactic.h index cc5e55a4e..d33f3afe2 100644 --- a/src/api/api_tactic.h +++ b/src/api/api_tactic.h @@ -40,11 +40,11 @@ struct Z3_probe_ref : public api::object { inline Z3_tactic_ref * to_tactic(Z3_tactic g) { return reinterpret_cast(g); } inline Z3_tactic of_tactic(Z3_tactic_ref * g) { return reinterpret_cast(g); } -inline tactic * to_tactic_ref(Z3_tactic g) { return g == 0 ? 0 : to_tactic(g)->m_tactic.get(); } +inline tactic * to_tactic_ref(Z3_tactic g) { return g == nullptr ? nullptr : to_tactic(g)->m_tactic.get(); } inline Z3_probe_ref * to_probe(Z3_probe g) { return reinterpret_cast(g); } inline Z3_probe of_probe(Z3_probe_ref * g) { return reinterpret_cast(g); } -inline probe * to_probe_ref(Z3_probe g) { return g == 0 ? 0 : to_probe(g)->m_probe.get(); } +inline probe * to_probe_ref(Z3_probe g) { return g == nullptr ? nullptr : to_probe(g)->m_probe.get(); } struct Z3_apply_result_ref : public api::object { goal_ref_buffer m_subgoals; diff --git a/src/api/api_util.h b/src/api/api_util.h index e2e4621d4..848d935c5 100644 --- a/src/api/api_util.h +++ b/src/api/api_util.h @@ -93,7 +93,7 @@ struct Z3_params_ref : public api::object { inline Z3_params_ref * to_params(Z3_params p) { return reinterpret_cast(p); } inline Z3_params of_params(Z3_params_ref * p) { return reinterpret_cast(p); } -inline params_ref to_param_ref(Z3_params p) { return p == 0 ? params_ref() : to_params(p)->m_params; } +inline params_ref to_param_ref(Z3_params p) { return p == nullptr ? params_ref() : to_params(p)->m_params; } struct Z3_param_descrs_ref : public api::object { param_descrs m_descrs; @@ -103,7 +103,7 @@ struct Z3_param_descrs_ref : public api::object { inline Z3_param_descrs_ref * to_param_descrs(Z3_param_descrs p) { return reinterpret_cast(p); } inline Z3_param_descrs of_param_descrs(Z3_param_descrs_ref * p) { return reinterpret_cast(p); } -inline param_descrs * to_param_descrs_ptr(Z3_param_descrs p) { return p == 0 ? 0 : &(to_param_descrs(p)->m_descrs); } +inline param_descrs * to_param_descrs_ptr(Z3_param_descrs p) { return p == nullptr ? nullptr : &(to_param_descrs(p)->m_descrs); } #define SKIP ((void) 0) diff --git a/src/api/z3_replayer.cpp b/src/api/z3_replayer.cpp index 84dcfc363..1515e6df7 100644 --- a/src/api/z3_replayer.cpp +++ b/src/api/z3_replayer.cpp @@ -430,10 +430,10 @@ struct z3_replayer::imp { next(); skip_blank(); read_ptr(); TRACE("z3_replayer", tout << "[" << m_line << "] " << "P " << m_ptr << "\n";); if (m_ptr == 0) { - m_args.push_back(0); + m_args.push_back(nullptr); } else { - void * obj = 0; + void * obj = nullptr; if (!m_heap.find(m_ptr, obj)) throw z3_replayer_exception("invalid pointer"); m_args.push_back(value(obj)); @@ -453,7 +453,7 @@ struct z3_replayer::imp { // push null symbol next(); TRACE("z3_replayer", tout << "[" << m_line << "] " << "N\n";); - m_args.push_back(value(SYMBOL, static_cast(0))); + m_args.push_back(value(SYMBOL, static_cast(nullptr))); break; case '$': { // push symbol @@ -689,7 +689,7 @@ struct z3_replayer::imp { } void reset() { - m_result = 0; + m_result = nullptr; m_args.reset(); m_obj_arrays.reset(); m_sym_arrays.reset(); diff --git a/src/ast/act_cache.cpp b/src/ast/act_cache.cpp index 74a7d6fca..14f0985b4 100644 --- a/src/ast/act_cache.cpp +++ b/src/ast/act_cache.cpp @@ -187,8 +187,8 @@ void act_cache::insert(expr * k, expr * v) { */ expr * act_cache::find(expr * k) { map::key_value * entry = m_table.find_core(k); - if (entry == 0) - return 0; + if (entry == nullptr) + return nullptr; if (GET_TAG(entry->m_value) == 0) { entry->m_value = TAG(expr*, entry->m_value, 1); SASSERT(GET_TAG(entry->m_value) == 1); diff --git a/src/ast/arith_decl_plugin.cpp b/src/ast/arith_decl_plugin.cpp index 85c54d1fa..688edbcd5 100644 --- a/src/ast/arith_decl_plugin.cpp +++ b/src/ast/arith_decl_plugin.cpp @@ -65,7 +65,7 @@ struct arith_decl_plugin::algebraic_numbers_wrapper { }; arith_decl_plugin::algebraic_numbers_wrapper & arith_decl_plugin::aw() const { - if (m_aw == 0) + if (m_aw == nullptr) const_cast(this)->m_aw = alloc(algebraic_numbers_wrapper, m_manager->limit()); return *m_aw; } @@ -100,7 +100,7 @@ app * arith_decl_plugin::mk_numeral(sexpr const * p, unsigned i) { void arith_decl_plugin::del(parameter const & p) { SASSERT(p.is_external()); - if (m_aw != 0) { + if (m_aw != nullptr) { aw().recycle_id(p.get_ext_id()); } } @@ -222,56 +222,56 @@ void arith_decl_plugin::set_manager(ast_manager * m, family_id id) { } arith_decl_plugin::arith_decl_plugin(): - m_aw(0), + m_aw(nullptr), m_intv_sym("Int"), m_realv_sym("Real"), m_rootv_sym("RootObject"), - m_real_decl(0), - m_int_decl(0), - m_r_le_decl(0), - m_r_ge_decl(0), - m_r_lt_decl(0), - m_r_gt_decl(0), - m_r_add_decl(0), - m_r_sub_decl(0), - m_r_uminus_decl(0), - m_r_mul_decl(0), - m_r_div_decl(0), - m_i_le_decl(0), - m_i_ge_decl(0), - m_i_lt_decl(0), - m_i_gt_decl(0), - m_i_add_decl(0), - m_i_sub_decl(0), - m_i_uminus_decl(0), - m_i_mul_decl(0), - m_i_div_decl(0), - m_i_mod_decl(0), - m_i_rem_decl(0), - m_to_real_decl(0), - m_to_int_decl(0), - m_is_int_decl(0), - m_r_power_decl(0), - m_i_power_decl(0), - m_r_abs_decl(0), - m_i_abs_decl(0), - m_sin_decl(0), - m_cos_decl(0), - m_tan_decl(0), - m_asin_decl(0), - m_acos_decl(0), - m_atan_decl(0), - m_sinh_decl(0), - m_cosh_decl(0), - m_tanh_decl(0), - m_asinh_decl(0), - m_acosh_decl(0), - m_atanh_decl(0), - m_pi(0), - m_e(0), - m_neg_root_decl(0), - m_u_asin_decl(0), - m_u_acos_decl(0), + m_real_decl(nullptr), + m_int_decl(nullptr), + m_r_le_decl(nullptr), + m_r_ge_decl(nullptr), + m_r_lt_decl(nullptr), + m_r_gt_decl(nullptr), + m_r_add_decl(nullptr), + m_r_sub_decl(nullptr), + m_r_uminus_decl(nullptr), + m_r_mul_decl(nullptr), + m_r_div_decl(nullptr), + m_i_le_decl(nullptr), + m_i_ge_decl(nullptr), + m_i_lt_decl(nullptr), + m_i_gt_decl(nullptr), + m_i_add_decl(nullptr), + m_i_sub_decl(nullptr), + m_i_uminus_decl(nullptr), + m_i_mul_decl(nullptr), + m_i_div_decl(nullptr), + m_i_mod_decl(nullptr), + m_i_rem_decl(nullptr), + m_to_real_decl(nullptr), + m_to_int_decl(nullptr), + m_is_int_decl(nullptr), + m_r_power_decl(nullptr), + m_i_power_decl(nullptr), + m_r_abs_decl(nullptr), + m_i_abs_decl(nullptr), + m_sin_decl(nullptr), + m_cos_decl(nullptr), + m_tan_decl(nullptr), + m_asin_decl(nullptr), + m_acos_decl(nullptr), + m_atan_decl(nullptr), + m_sinh_decl(nullptr), + m_cosh_decl(nullptr), + m_tanh_decl(nullptr), + m_asinh_decl(nullptr), + m_acosh_decl(nullptr), + m_atanh_decl(nullptr), + m_pi(nullptr), + m_e(nullptr), + m_neg_root_decl(nullptr), + m_u_asin_decl(nullptr), + m_u_acos_decl(nullptr), m_convert_int_numerals_to_real(false) { } @@ -335,7 +335,7 @@ sort * arith_decl_plugin::mk_sort(decl_kind k, unsigned num_parameters, paramete switch (k) { case REAL_SORT: return m_real_decl; case INT_SORT: return m_int_decl; - default: return 0; + default: return nullptr; } } @@ -380,7 +380,7 @@ inline func_decl * arith_decl_plugin::mk_func_decl(decl_kind k, bool is_real) { //case OP_MOD_0: return m_mod_0_decl; case OP_U_ASIN: return m_u_asin_decl; case OP_U_ACOS: return m_u_acos_decl; - default: return 0; + default: return nullptr; } } @@ -408,7 +408,7 @@ app * arith_decl_plugin::mk_numeral(rational const & val, bool is_int) { if (u_val < MAX_SMALL_NUM_TO_CACHE) { if (is_int && !m_convert_int_numerals_to_real) { app * r = m_small_ints.get(u_val, 0); - if (r == 0) { + if (r == nullptr) { parameter p[2] = { parameter(val), parameter(1) }; r = m_manager->mk_const(m_manager->mk_const_decl(m_intv_sym, m_int_decl, func_decl_info(m_family_id, OP_NUM, 2, p))); m_manager->inc_ref(r); @@ -418,7 +418,7 @@ app * arith_decl_plugin::mk_numeral(rational const & val, bool is_int) { } else { app * r = m_small_reals.get(u_val, 0); - if (r == 0) { + if (r == nullptr) { parameter p[2] = { parameter(val), parameter(0) }; r = m_manager->mk_const(m_manager->mk_const_decl(m_realv_sym, m_real_decl, func_decl_info(m_family_id, OP_NUM, 2, p))); m_manager->inc_ref(r); @@ -440,7 +440,7 @@ app * arith_decl_plugin::mk_numeral(rational const & val, bool is_int) { func_decl * arith_decl_plugin::mk_num_decl(unsigned num_parameters, parameter const * parameters, unsigned arity) { if (!(num_parameters == 2 && arity == 0 && parameters[0].is_rational() && parameters[1].is_int())) { m_manager->raise_exception("invalid numeral declaration"); - return 0; + return nullptr; } if (parameters[1].get_int() != 0) return m_manager->mk_const_decl(m_intv_sym, m_int_decl, func_decl_info(m_family_id, OP_NUM, num_parameters, parameters)); @@ -480,7 +480,7 @@ func_decl * arith_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters return mk_num_decl(num_parameters, parameters, arity); if (arity == 0 && !is_const_op(k)) { m_manager->raise_exception("no arguments supplied to arithmetical operator"); - return 0; + return nullptr; } if (m_manager->int_real_coercions() && use_coercion(k)) { return mk_func_decl(fix_kind(k, arity), has_real_arg(arity, domain, m_real_decl)); @@ -497,7 +497,7 @@ func_decl * arith_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters return mk_num_decl(num_parameters, parameters, num_args); if (num_args == 0 && !is_const_op(k)) { m_manager->raise_exception("no arguments supplied to arithmetical operator"); - return 0; + return nullptr; } if (m_manager->int_real_coercions() && use_coercion(k)) { return mk_func_decl(fix_kind(k, num_args), has_real_arg(m_manager, num_args, args, m_real_decl)); @@ -641,7 +641,7 @@ bool arith_recognizers::is_numeral(expr const * n, rational & val, bool & is_int arith_util::arith_util(ast_manager & m): arith_recognizers(m.mk_family_id("arith")), m_manager(m), - m_plugin(0) { + m_plugin(nullptr) { } void arith_util::init_plugin() { diff --git a/src/ast/array_decl_plugin.cpp b/src/ast/array_decl_plugin.cpp index 1e789b7e5..af451f9c5 100644 --- a/src/ast/array_decl_plugin.cpp +++ b/src/ast/array_decl_plugin.cpp @@ -44,7 +44,7 @@ sort * array_decl_plugin::mk_sort(decl_kind k, unsigned num_parameters, paramete if (k == _SET_SORT) { if (num_parameters != 1) { m_manager->raise_exception("invalid array sort definition, invalid number of parameters"); - return 0; + return nullptr; } parameter params[2] = { parameters[0], parameter(m_manager->mk_bool_sort()) }; return mk_sort(ARRAY_SORT, 2, params); @@ -52,13 +52,13 @@ sort * array_decl_plugin::mk_sort(decl_kind k, unsigned num_parameters, paramete SASSERT(k == ARRAY_SORT); if (num_parameters < 2) { m_manager->raise_exception("invalid array sort definition, invalid number of parameters"); - return 0; + return nullptr; } for (unsigned i = 0; i < num_parameters; i++) { if (!parameters[i].is_ast() || !is_sort(parameters[i].get_ast())) { m_manager->raise_exception("invalid array sort definition, parameter is not a sort"); - return 0; + return nullptr; } } sort * range = to_sort(parameters[num_parameters - 1].get_ast()); @@ -120,15 +120,15 @@ bool array_decl_plugin::is_array_sort(sort* s) const { func_decl * array_decl_plugin::mk_const(sort * s, unsigned arity, sort * const * domain) { if (arity != 1) { m_manager->raise_exception("invalid const array definition, invalid domain size"); - return 0; + return nullptr; } if (!is_array_sort(s)) { m_manager->raise_exception("invalid const array definition, parameter is not an array sort"); - return 0; + return nullptr; } if (!m_manager->compatible_sorts(get_array_range(s), domain[0])) { m_manager->raise_exception("invalid const array definition, sort mismatch between array range and argument"); - return 0; + return nullptr; } parameter param(s); func_decl_info info(m_family_id, OP_CONST_ARRAY, 1, ¶m); @@ -142,11 +142,11 @@ func_decl * array_decl_plugin::mk_map(func_decl* f, unsigned arity, sort* const* buffer << "map expects to take as many arguments as the function being mapped, " << "it was given " << arity << " but expects " << f->get_arity(); m_manager->raise_exception(buffer.str().c_str()); - return 0; + return nullptr; } if (arity == 0) { m_manager->raise_exception("don't use map on constants"); - return 0; + return nullptr; } // // check that each domain[i] is an array sort @@ -159,14 +159,14 @@ func_decl * array_decl_plugin::mk_map(func_decl* f, unsigned arity, sort* const* std::ostringstream buffer; buffer << "map expects an array sort as argument at position " << i; m_manager->raise_exception(buffer.str().c_str()); - return 0; + return nullptr; } if (get_array_arity(domain[i]) != dom_arity) { std::ostringstream buffer; buffer << "map expects all arguments to have the same array domain, " << "this is not the case for argument " << i; m_manager->raise_exception(buffer.str().c_str()); - return 0; + return nullptr; } for (unsigned j = 0; j < dom_arity; ++j) { if (get_array_domain(domain[i],j) != get_array_domain(domain[0],j)) { @@ -174,7 +174,7 @@ func_decl * array_decl_plugin::mk_map(func_decl* f, unsigned arity, sort* const* buffer << "map expects all arguments to have the same array domain, " << "this is not the case for argument " << i; m_manager->raise_exception(buffer.str().c_str()); - return 0; + return nullptr; } } if (get_array_range(domain[i]) != f->get_domain(i)) { @@ -182,7 +182,7 @@ func_decl * array_decl_plugin::mk_map(func_decl* f, unsigned arity, sort* const* buffer << "map expects the argument at position " << i << " to have the array range the same as the function"; m_manager->raise_exception(buffer.str().c_str()); - return 0; + return nullptr; } } vector parameters; @@ -211,19 +211,19 @@ func_decl * array_decl_plugin::mk_map(func_decl* f, unsigned arity, sort* const* func_decl * array_decl_plugin::mk_default(unsigned domain_size, sort * const * domain) { if (domain_size != 1) { m_manager->raise_exception("invalid default array definition, invalid domain size"); - return 0; + return nullptr; } // check that domain[0] is an array sort. unsigned num_parameters = domain[0]->get_num_parameters(); if (num_parameters <= 1) { m_manager->raise_exception("parameter mismatch. There should be more than one parameter to defaults"); - return 0; + return nullptr; } parameter param(domain[0]->get_parameter(num_parameters-1)); if (!param.is_ast() || !is_sort(param.get_ast())) { m_manager->raise_exception("last parameter should be a sort"); - return 0; + return nullptr; } sort * s = to_sort(param.get_ast()); @@ -235,7 +235,7 @@ func_decl * array_decl_plugin::mk_default(unsigned domain_size, sort * const * d func_decl* array_decl_plugin::mk_select(unsigned arity, sort * const * domain) { if (arity <= 1) { m_manager->raise_exception("select takes at least two arguments"); - return 0; + return nullptr; } sort * s = domain[0]; unsigned num_parameters = s->get_num_parameters(); @@ -245,7 +245,7 @@ func_decl* array_decl_plugin::mk_select(unsigned arity, sort * const * domain) { std::stringstream strm; strm << "select requires " << num_parameters << " arguments, but was provided with " << arity << " arguments"; m_manager->raise_exception(strm.str().c_str()); - return 0; + return nullptr; } ptr_buffer new_domain; // we need this because of coercions. new_domain.push_back(s); @@ -255,7 +255,7 @@ func_decl* array_decl_plugin::mk_select(unsigned arity, sort * const * domain) { !m_manager->compatible_sorts(domain[i+1], to_sort(parameters[i].get_ast()))) { m_manager->raise_exception("domain sort and parameter do not match"); UNREACHABLE(); - return 0; + return nullptr; } new_domain.push_back(to_sort(parameters[i].get_ast())); } @@ -267,7 +267,7 @@ func_decl* array_decl_plugin::mk_select(unsigned arity, sort * const * domain) { func_decl * array_decl_plugin::mk_store(unsigned arity, sort * const * domain) { if (arity < 3) { m_manager->raise_exception("store takes at least 3 arguments"); - return 0; + return nullptr; } sort * s = domain[0]; unsigned num_parameters = s->get_num_parameters(); @@ -275,7 +275,7 @@ func_decl * array_decl_plugin::mk_store(unsigned arity, sort * const * domain) { if (!is_array_sort(s)) { m_manager->raise_exception("store expects the first argument sort to be an array"); UNREACHABLE(); - return 0; + return nullptr; } if (arity != num_parameters+1) { std::ostringstream buffer; @@ -283,19 +283,19 @@ func_decl * array_decl_plugin::mk_store(unsigned arity, sort * const * domain) { << ", instead it was passed " << (arity - 1) << "arguments"; m_manager->raise_exception(buffer.str().c_str()); UNREACHABLE(); - return 0; + return nullptr; } ptr_buffer new_domain; // we need this because of coercions. new_domain.push_back(s); for (unsigned i = 0; i < num_parameters; ++i) { if (!parameters[i].is_ast() || !is_sort(parameters[i].get_ast())) { m_manager->raise_exception("expecting sort parameter"); - return 0; + return nullptr; } if (!m_manager->compatible_sorts(to_sort(parameters[i].get_ast()), domain[i+1])) { m_manager->raise_exception("domain sort and parameter do not match"); UNREACHABLE(); - return 0; + return nullptr; } new_domain.push_back(to_sort(parameters[i].get_ast())); } @@ -307,13 +307,13 @@ func_decl * array_decl_plugin::mk_store(unsigned arity, sort * const * domain) { func_decl * array_decl_plugin::mk_array_ext(unsigned arity, sort * const * domain, unsigned i) { if (arity != 2 || domain[0] != domain[1]) { UNREACHABLE(); - return 0; + return nullptr; } sort * s = domain[0]; unsigned num_parameters = s->get_num_parameters(); if (num_parameters == 0 || i >= num_parameters - 1) { UNREACHABLE(); - return 0; + return nullptr; } sort * r = to_sort(s->get_parameter(i).get_ast()); parameter param(i); @@ -362,11 +362,11 @@ func_decl * array_decl_plugin::mk_set_union(unsigned arity, sort * const * domai if (arity == 0) { m_manager->raise_exception("union takes at least one argument"); - return 0; + return nullptr; } sort * s = domain[0]; if (!check_set_arguments(arity, domain)) { - return 0; + return nullptr; } parameter param(s); func_decl_info info(m_family_id, OP_SET_UNION, 1, ¶m); @@ -381,10 +381,10 @@ func_decl * array_decl_plugin::mk_set_intersect(unsigned arity, sort * const * d if (arity == 0) { m_manager->raise_exception("intersection takes at least one argument"); - return 0; + return nullptr; } if (!check_set_arguments(arity, domain)) { - return 0; + return nullptr; } func_decl_info info(m_family_id, OP_SET_INTERSECT); info.set_associative(); @@ -397,10 +397,10 @@ func_decl * array_decl_plugin::mk_set_intersect(unsigned arity, sort * const * d func_decl * array_decl_plugin::mk_set_difference(unsigned arity, sort * const * domain) { if (arity != 2) { m_manager->raise_exception("set difference takes precisely two arguments"); - return 0; + return nullptr; } if (!check_set_arguments(arity, domain)) { - return 0; + return nullptr; } return m_manager->mk_func_decl(m_set_difference_sym, arity, domain, domain[0], func_decl_info(m_family_id, OP_SET_DIFFERENCE)); @@ -409,10 +409,10 @@ func_decl * array_decl_plugin::mk_set_difference(unsigned arity, sort * const * func_decl * array_decl_plugin::mk_set_complement(unsigned arity, sort * const * domain) { if (arity != 1) { m_manager->raise_exception("set complement takes one argument"); - return 0; + return nullptr; } if (!check_set_arguments(arity, domain)) { - return 0; + return nullptr; } return m_manager->mk_func_decl(m_set_complement_sym, arity, domain, domain[0], func_decl_info(m_family_id, OP_SET_COMPLEMENT)); @@ -421,10 +421,10 @@ func_decl * array_decl_plugin::mk_set_complement(unsigned arity, sort * const * func_decl * array_decl_plugin::mk_set_subset(unsigned arity, sort * const * domain) { if (arity != 2) { m_manager->raise_exception("subset takes two arguments"); - return 0; + return nullptr; } if (!check_set_arguments(arity, domain)) { - return 0; + return nullptr; } sort * bool_sort = m_manager->mk_bool_sort(); return m_manager->mk_func_decl(m_set_subset_sym, arity, domain, bool_sort, @@ -456,20 +456,20 @@ func_decl * array_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters sort * s = to_sort(parameters[0].get_ast()); return mk_const(s, arity, domain); } - else if (range != 0) { + else if (range != nullptr) { return mk_const(range, arity, domain); } else { m_manager->raise_exception("array operation requires one sort parameter (the array sort)"); UNREACHABLE(); - return 0; + return nullptr; } } case OP_ARRAY_MAP: { if (num_parameters != 1 || !parameters[0].is_ast() || !is_func_decl(parameters[0].get_ast())) { m_manager->raise_exception("array operation requires one function declaration parameter (the function to be mapped)"); UNREACHABLE(); - return 0; + return nullptr; } func_decl * f = to_func_decl(parameters[0].get_ast()); return mk_map(f, arity, domain); @@ -480,7 +480,7 @@ func_decl * array_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters } if (num_parameters != 1 || !parameters[0].is_int()) { UNREACHABLE(); - return 0; + return nullptr; } return mk_array_ext(arity, domain, parameters[0].get_int()); case OP_ARRAY_DEFAULT: @@ -506,12 +506,12 @@ func_decl * array_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters tout << "as-array-bug: " << to_func_decl(parameters[0].get_ast())->get_name() << " " << to_func_decl(parameters[0].get_ast())->get_arity() << std::endl;); m_manager->raise_exception("as-array takes one parameter, a function declaration with arity greater than zero"); UNREACHABLE(); - return 0; + return nullptr; } func_decl * f = to_func_decl(parameters[0].get_ast()); return mk_as_array(f); } - default: return 0; + default: return nullptr; } } diff --git a/src/ast/array_decl_plugin.h b/src/ast/array_decl_plugin.h index 488ee71fb..beaccfbd3 100644 --- a/src/ast/array_decl_plugin.h +++ b/src/ast/array_decl_plugin.h @@ -161,11 +161,11 @@ public: bool is_as_array_tree(expr * n); app * mk_store(unsigned num_args, expr * const * args) { - return m_manager.mk_app(m_fid, OP_STORE, 0, 0, num_args, args); + return m_manager.mk_app(m_fid, OP_STORE, 0, nullptr, num_args, args); } app * mk_select(unsigned num_args, expr * const * args) { - return m_manager.mk_app(m_fid, OP_SELECT, 0, 0, num_args, args); + return m_manager.mk_app(m_fid, OP_SELECT, 0, nullptr, num_args, args); } app * mk_map(func_decl * f, unsigned num_args, expr * const * args) { @@ -191,7 +191,7 @@ public: app * mk_as_array(func_decl * f) { parameter param(f); - return m_manager.mk_app(m_fid, OP_AS_ARRAY, 1, ¶m, 0, 0, 0); + return m_manager.mk_app(m_fid, OP_AS_ARRAY, 1, ¶m, 0, nullptr, nullptr); } }; diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index cc4beb1b6..b524cd8d4 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -405,7 +405,7 @@ sort * get_sort(expr const * n) { break; default: UNREACHABLE(); - return 0; + return nullptr; } } } @@ -434,18 +434,18 @@ bool compare_nodes(ast const * n1, ast const * n2) { } switch (n1->get_kind()) { case AST_SORT: - if ((to_sort(n1)->get_info() == 0) != (to_sort(n2)->get_info() == 0)) { + if ((to_sort(n1)->get_info() == nullptr) != (to_sort(n2)->get_info() == nullptr)) { return false; } - if (to_sort(n1)->get_info() != 0 && !(*to_sort(n1)->get_info() == *to_sort(n2)->get_info())) { + if (to_sort(n1)->get_info() != nullptr && !(*to_sort(n1)->get_info() == *to_sort(n2)->get_info())) { return false; } return to_sort(n1)->get_name() == to_sort(n2)->get_name(); case AST_FUNC_DECL: - if ((to_func_decl(n1)->get_info() == 0) != (to_func_decl(n2)->get_info() == 0)) { + if ((to_func_decl(n1)->get_info() == nullptr) != (to_func_decl(n2)->get_info() == nullptr)) { return false; } - if (to_func_decl(n1)->get_info() != 0 && !(*to_func_decl(n1)->get_info() == *to_func_decl(n2)->get_info())) { + if (to_func_decl(n1)->get_info() != nullptr && !(*to_func_decl(n1)->get_info() == *to_func_decl(n2)->get_info())) { return false; } return @@ -549,13 +549,13 @@ unsigned get_node_hash(ast const * n) { switch (n->get_kind()) { case AST_SORT: - if (to_sort(n)->get_info() == 0) + if (to_sort(n)->get_info() == nullptr) return to_sort(n)->get_name().hash(); else return combine_hash(to_sort(n)->get_name().hash(), to_sort(n)->get_info()->hash()); case AST_FUNC_DECL: return ast_array_hash(to_func_decl(n)->get_domain(), to_func_decl(n)->get_arity(), - to_func_decl(n)->get_info() == 0 ? + to_func_decl(n)->get_info() == nullptr ? to_func_decl(n)->get_name().hash() : combine_hash(to_func_decl(n)->get_name().hash(), to_func_decl(n)->get_info()->hash())); case AST_APP: return ast_array_hash(to_app(n)->get_args(), @@ -587,13 +587,13 @@ void ast_table::erase(ast * n) { unsigned idx = h & mask; cell * c = m_table + idx; SASSERT(!c->is_free()); - cell * prev = 0; + cell * prev = nullptr; while (true) { if (c->m_data == n) { m_size--; - if (prev == 0) { + if (prev == nullptr) { cell * next = c->m_next; - if (next == 0) { + if (next == nullptr) { m_used_slots--; c->mark_free(); SASSERT(c->is_free()); @@ -638,49 +638,49 @@ func_decl * decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, para // ----------------------------------- basic_decl_plugin::basic_decl_plugin(): - m_bool_sort(0), - m_true_decl(0), - m_false_decl(0), - m_and_decl(0), - m_or_decl(0), - m_iff_decl(0), - m_xor_decl(0), - m_not_decl(0), - m_interp_decl(0), - m_implies_decl(0), + m_bool_sort(nullptr), + m_true_decl(nullptr), + m_false_decl(nullptr), + m_and_decl(nullptr), + m_or_decl(nullptr), + m_iff_decl(nullptr), + m_xor_decl(nullptr), + m_not_decl(nullptr), + m_interp_decl(nullptr), + m_implies_decl(nullptr), - m_proof_sort(0), - m_undef_decl(0), - m_true_pr_decl(0), - m_asserted_decl(0), - m_goal_decl(0), - m_modus_ponens_decl(0), - m_reflexivity_decl(0), - m_symmetry_decl(0), - m_transitivity_decl(0), - m_quant_intro_decl(0), - m_and_elim_decl(0), - m_not_or_elim_decl(0), - m_rewrite_decl(0), - m_pull_quant_decl(0), - m_pull_quant_star_decl(0), - m_push_quant_decl(0), - m_elim_unused_vars_decl(0), - m_der_decl(0), - m_quant_inst_decl(0), + m_proof_sort(nullptr), + m_undef_decl(nullptr), + m_true_pr_decl(nullptr), + m_asserted_decl(nullptr), + m_goal_decl(nullptr), + m_modus_ponens_decl(nullptr), + m_reflexivity_decl(nullptr), + m_symmetry_decl(nullptr), + m_transitivity_decl(nullptr), + m_quant_intro_decl(nullptr), + m_and_elim_decl(nullptr), + m_not_or_elim_decl(nullptr), + m_rewrite_decl(nullptr), + m_pull_quant_decl(nullptr), + m_pull_quant_star_decl(nullptr), + m_push_quant_decl(nullptr), + m_elim_unused_vars_decl(nullptr), + m_der_decl(nullptr), + m_quant_inst_decl(nullptr), - m_hypothesis_decl(0), - m_iff_true_decl(0), - m_iff_false_decl(0), - m_commutativity_decl(0), - m_def_axiom_decl(0), - m_lemma_decl(0), + m_hypothesis_decl(nullptr), + m_iff_true_decl(nullptr), + m_iff_false_decl(nullptr), + m_commutativity_decl(nullptr), + m_def_axiom_decl(nullptr), + m_lemma_decl(nullptr), - m_def_intro_decl(0), - m_iff_oeq_decl(0), - m_skolemize_decl(0), - m_mp_oeq_decl(0), - m_hyper_res_decl0(0) { + m_def_intro_decl(nullptr), + m_iff_oeq_decl(nullptr), + m_skolemize_decl(nullptr), + m_mp_oeq_decl(nullptr), + m_hyper_res_decl0(nullptr) { } bool basic_decl_plugin::check_proof_sorts(basic_op_kind k, unsigned arity, sort * const * domain) const { @@ -790,7 +790,7 @@ func_decl * basic_decl_plugin::mk_proof_decl(basic_op_kind k, unsigned num_param } default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -852,7 +852,7 @@ func_decl * basic_decl_plugin::mk_proof_decl(basic_op_kind k, unsigned num_paren case PR_HYPER_RESOLVE: return mk_proof_decl("hyper-res", k, num_parents, m_hyper_res_decl0); default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -1067,10 +1067,10 @@ func_decl * basic_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters case OP_IFF: return m_iff_decl; case OP_IMPLIES: return m_implies_decl; case OP_XOR: return m_xor_decl; - case OP_ITE: return arity == 3 ? mk_ite_decl(join(domain[1], domain[2])) : 0; + case OP_ITE: return arity == 3 ? mk_ite_decl(join(domain[1], domain[2])) : nullptr; // eq and oeq must have at least two arguments, they can have more since they are chainable - case OP_EQ: return arity >= 2 ? mk_eq_decl_core("=", OP_EQ, join(arity, domain), m_eq_decls) : 0; - case OP_OEQ: return arity >= 2 ? mk_eq_decl_core("~", OP_OEQ, join(arity, domain), m_oeq_decls) : 0; + case OP_EQ: return arity >= 2 ? mk_eq_decl_core("=", OP_EQ, join(arity, domain), m_eq_decls) : nullptr; + case OP_OEQ: return arity >= 2 ? mk_eq_decl_core("~", OP_OEQ, join(arity, domain), m_oeq_decls) : nullptr; case OP_DISTINCT: { func_decl_info info(m_family_id, OP_DISTINCT); info.set_pairwise(); @@ -1110,10 +1110,10 @@ func_decl * basic_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters case OP_IFF: return m_iff_decl; case OP_IMPLIES: return m_implies_decl; case OP_XOR: return m_xor_decl; - case OP_ITE: return num_args == 3 ? mk_ite_decl(join(m_manager->get_sort(args[1]), m_manager->get_sort(args[2]))): 0; + case OP_ITE: return num_args == 3 ? mk_ite_decl(join(m_manager->get_sort(args[1]), m_manager->get_sort(args[2]))): nullptr; // eq and oeq must have at least two arguments, they can have more since they are chainable - case OP_EQ: return num_args >= 2 ? mk_eq_decl_core("=", OP_EQ, join(num_args, args), m_eq_decls) : 0; - case OP_OEQ: return num_args >= 2 ? mk_eq_decl_core("~", OP_OEQ, join(num_args, args), m_oeq_decls) : 0; + case OP_EQ: return num_args >= 2 ? mk_eq_decl_core("=", OP_EQ, join(num_args, args), m_eq_decls) : nullptr; + case OP_OEQ: return num_args >= 2 ? mk_eq_decl_core("~", OP_OEQ, join(num_args, args), m_oeq_decls) : nullptr; case OP_DISTINCT: return decl_plugin::mk_func_decl(k, num_parameters, parameters, num_args, args, range); default: @@ -1134,7 +1134,7 @@ func_decl * basic_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters expr * basic_decl_plugin::get_some_value(sort * s) { if (s == m_bool_sort) return m_manager->mk_false(); - return 0; + return nullptr; } bool basic_recognizers::is_ite(expr const * n, expr * & t1, expr * & t2, expr * & t3) const { @@ -1168,7 +1168,7 @@ void label_decl_plugin::set_manager(ast_manager * m, family_id id) { sort * label_decl_plugin::mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) { UNREACHABLE(); - return 0; + return nullptr; } func_decl * label_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, @@ -1176,12 +1176,12 @@ func_decl * label_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters if (k == OP_LABEL) { if (arity != 1 || num_parameters < 2 || !parameters[0].is_int() || !parameters[1].is_symbol() || !m_manager->is_bool(domain[0])) { m_manager->raise_exception("invalid label declaration"); - return 0; + return nullptr; } for (unsigned i = 2; i < num_parameters; i++) { if (!parameters[i].is_symbol()) { m_manager->raise_exception("invalid label declaration"); - return 0; + return nullptr; } } return m_manager->mk_func_decl(parameters[0].get_int() ? m_lblpos : m_lblneg, arity, domain, domain[0], @@ -1191,15 +1191,15 @@ func_decl * label_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters SASSERT(k == OP_LABEL_LIT); if (arity != 0) { m_manager->raise_exception("invalid label literal declaration"); - return 0; + return nullptr; } for (unsigned i = 0; i < num_parameters; i++) { if (!parameters[i].is_symbol()) { m_manager->raise_exception("invalid label literal declaration"); - return 0; + return nullptr; } } - return m_manager->mk_func_decl(m_lbllit, 0, static_cast(0), m_manager->mk_bool_sort(), + return m_manager->mk_func_decl(m_lbllit, 0, static_cast(nullptr), m_manager->mk_bool_sort(), func_decl_info(m_family_id, OP_LABEL_LIT, num_parameters, parameters)); } } @@ -1212,7 +1212,7 @@ func_decl * label_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters sort * pattern_decl_plugin::mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) { UNREACHABLE(); - return 0; + return nullptr; } func_decl * pattern_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, @@ -1230,7 +1230,7 @@ func_decl * pattern_decl_plugin::mk_func_decl(decl_kind k, unsigned num_paramete sort * model_value_decl_plugin::mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) { UNREACHABLE(); - return 0; + return nullptr; } func_decl * model_value_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, @@ -1239,7 +1239,7 @@ func_decl * model_value_decl_plugin::mk_func_decl(decl_kind k, unsigned num_para if (arity != 0 || num_parameters != 2 || !parameters[0].is_int() || !parameters[1].is_ast() || !is_sort(parameters[1].get_ast())) { UNREACHABLE(); m_manager->raise_exception("invalid model value"); - return 0; + return nullptr; } int idx = parameters[0].get_int(); sort * s = to_sort(parameters[1].get_ast()); @@ -1247,7 +1247,7 @@ func_decl * model_value_decl_plugin::mk_func_decl(decl_kind k, unsigned num_para buffer << s->get_name().bare_str() << "!val!" << idx; func_decl_info info(m_family_id, k, num_parameters, parameters); info.m_private_parameters = true; - return m_manager->mk_func_decl(symbol(buffer.c_str()), 0, static_cast(0), s, info); + return m_manager->mk_func_decl(symbol(buffer.c_str()), 0, static_cast(nullptr), s, info); } bool model_value_decl_plugin::is_value(app* n) const { @@ -1274,7 +1274,7 @@ sort * user_sort_plugin::mk_sort(decl_kind k, unsigned num_parameters, parameter func_decl * user_sort_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned arity, sort * const * domain, sort * range) { UNREACHABLE(); - return 0; + return nullptr; } decl_kind user_sort_plugin::register_name(symbol s) { @@ -1307,7 +1307,7 @@ ast_manager::ast_manager(proof_gen_mode m, char const * trace_file, bool is_form m_expr_dependency_manager(*this, m_alloc), m_expr_dependency_array_manager(*this, m_alloc), m_proof_mode(m), - m_trace_stream(0), + m_trace_stream(nullptr), m_trace_stream_owner(false), m_rec_fun(":rec-fun") { @@ -1319,7 +1319,7 @@ ast_manager::ast_manager(proof_gen_mode m, char const * trace_file, bool is_form if (!is_format_manager) m_format_manager = alloc(ast_manager, PGM_DISABLED, m_trace_stream, true); else - m_format_manager = 0; + m_format_manager = nullptr; init(); } @@ -1336,7 +1336,7 @@ ast_manager::ast_manager(proof_gen_mode m, std::fstream * trace_stream, bool is_ if (!is_format_manager) m_format_manager = alloc(ast_manager, PGM_DISABLED, trace_stream, true); else - m_format_manager = 0; + m_format_manager = nullptr; init(); } @@ -1361,7 +1361,7 @@ void ast_manager::init() { m_fresh_id = 0; m_expr_id_gen.reset(0); m_decl_id_gen.reset(c_first_decl_id); - m_some_value_proc = 0; + m_some_value_proc = nullptr; m_basic_family_id = mk_family_id("basic"); m_label_family_id = mk_family_id("label"); m_pattern_family_id = mk_family_id("pattern"); @@ -1427,14 +1427,14 @@ ast_manager::~ast_manager() { switch (n->get_kind()) { case AST_SORT: { sort_info* info = to_sort(n)->get_info(); - if (info != 0) { + if (info != nullptr) { mark_array_ref(mark, info->get_num_parameters(), info->get_parameters()); } break; } case AST_FUNC_DECL: { func_decl_info* info = to_func_decl(n)->get_info(); - if (info != 0) { + if (info != nullptr) { mark_array_ref(mark, info->get_num_parameters(), info->get_parameters()); } mark_array_ref(mark, to_func_decl(n)->get_arity(), to_func_decl(n)->get_domain()); @@ -1476,14 +1476,14 @@ ast_manager::~ast_manager() { delete_node(a); } } - if (m_format_manager != 0) + if (m_format_manager != nullptr) dealloc(m_format_manager); if (m_trace_stream_owner) { std::fstream & tmp = * m_trace_stream; tmp << "[eof]\n"; tmp.close(); dealloc(m_trace_stream); - m_trace_stream = 0; + m_trace_stream = nullptr; } } @@ -1587,7 +1587,7 @@ decl_plugin * ast_manager::get_plugin(family_id fid) const { bool ast_manager::is_value(expr* e) const { - decl_plugin const * p = 0; + decl_plugin const * p = nullptr; if (is_app(e)) { p = get_plugin(to_app(e)->get_family_id()); return p && p->is_value(to_app(e)); @@ -1596,7 +1596,7 @@ bool ast_manager::is_value(expr* e) const { } bool ast_manager::is_unique_value(expr* e) const { - decl_plugin const * p = 0; + decl_plugin const * p = nullptr; if (is_app(e)) { p = get_plugin(to_app(e)->get_family_id()); return p && p->is_unique_value(to_app(e)); @@ -1698,13 +1698,13 @@ ast * ast_manager::register_node_core(ast * n) { // increment reference counters switch (n->get_kind()) { case AST_SORT: - if (to_sort(n)->m_info != 0) { + if (to_sort(n)->m_info != nullptr) { to_sort(n)->m_info = alloc(sort_info, *(to_sort(n)->get_info())); to_sort(n)->m_info->init_eh(*this); } break; case AST_FUNC_DECL: - if (to_func_decl(n)->m_info != 0) { + if (to_func_decl(n)->m_info != nullptr) { to_func_decl(n)->m_info = alloc(func_decl_info, *(to_func_decl(n)->get_info())); to_func_decl(n)->m_info->init_eh(*this); } @@ -1807,14 +1807,14 @@ void ast_manager::delete_node(ast * n) { #endif switch (n->get_kind()) { case AST_SORT: - if (to_sort(n)->m_info != 0 && !m_debug_ref_count) { + if (to_sort(n)->m_info != nullptr && !m_debug_ref_count) { sort_info * info = to_sort(n)->get_info(); info->del_eh(*this); dealloc(info); } break; case AST_FUNC_DECL: - if (to_func_decl(n)->m_info != 0 && !m_debug_ref_count) { + if (to_func_decl(n)->m_info != nullptr && !m_debug_ref_count) { func_decl_info * info = to_func_decl(n)->get_info(); info->del_eh(*this); dealloc(info); @@ -1849,7 +1849,7 @@ sort * ast_manager::mk_sort(family_id fid, decl_kind k, unsigned num_parameters, decl_plugin * p = get_plugin(fid); if (p) return p->mk_sort(k, num_parameters, parameters); - return 0; + return nullptr; } func_decl * ast_manager::mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters, @@ -1857,7 +1857,7 @@ func_decl * ast_manager::mk_func_decl(family_id fid, decl_kind k, unsigned num_p decl_plugin * p = get_plugin(fid); if (p) return p->mk_func_decl(k, num_parameters, parameters, arity, domain, range); - return 0; + return nullptr; } func_decl * ast_manager::mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters, @@ -1865,33 +1865,33 @@ func_decl * ast_manager::mk_func_decl(family_id fid, decl_kind k, unsigned num_p decl_plugin * p = get_plugin(fid); if (p) return p->mk_func_decl(k, num_parameters, parameters, num_args, args, range); - return 0; + return nullptr; } app * ast_manager::mk_app(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned num_args, expr * const * args, sort * range) { func_decl * decl = mk_func_decl(fid, k, num_parameters, parameters, num_args, args, range); - if (decl != 0) + if (decl != nullptr) return mk_app(decl, num_args, args); - return 0; + return nullptr; } app * ast_manager::mk_app(family_id fid, decl_kind k, unsigned num_args, expr * const * args) { - return mk_app(fid, k, 0, 0, num_args, args); + return mk_app(fid, k, 0, nullptr, num_args, args); } app * ast_manager::mk_app(family_id fid, decl_kind k, expr * arg) { - return mk_app(fid, k, 0, 0, 1, &arg); + return mk_app(fid, k, 0, nullptr, 1, &arg); } app * ast_manager::mk_app(family_id fid, decl_kind k, expr * arg1, expr * arg2) { expr * args[2] = { arg1, arg2 }; - return mk_app(fid, k, 0, 0, 2, args); + return mk_app(fid, k, 0, nullptr, 2, args); } app * ast_manager::mk_app(family_id fid, decl_kind k, expr * arg1, expr * arg2, expr * arg3) { expr * args[3] = { arg1, arg2, arg3 }; - return mk_app(fid, k, 0, 0, 3, args); + return mk_app(fid, k, 0, nullptr, 3, args); } sort * ast_manager::mk_sort(symbol const & name, sort_info * info) { @@ -2062,8 +2062,8 @@ bool ast_manager::coercion_needed(func_decl * decl, unsigned num_args, expr * co } app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const * args) { - app * r = 0; - app * new_node = 0; + app * r = nullptr; + app * new_node = nullptr; unsigned sz = app::get_obj_size(num_args); void * mem = allocate_node(sz); @@ -2171,7 +2171,7 @@ app * ast_manager::mk_app(func_decl * decl, unsigned num_args, expr * const * ar << ") passed to function " << mk_pp(decl, *this); throw ast_exception(buffer.str().c_str()); } - app * r = 0; + app * r = nullptr; if (num_args == 1 && decl->is_chainable() && decl->get_arity() == 2) { r = mk_true(); } @@ -2200,7 +2200,7 @@ app * ast_manager::mk_app(func_decl * decl, unsigned num_args, expr * const * ar r = mk_and(new_args.size(), new_args.c_ptr()); } } - if (r == 0) { + if (r == nullptr) { r = mk_app_core(decl, num_args, args); } SASSERT(r != 0); @@ -2287,7 +2287,7 @@ app * ast_manager::mk_label_lit(unsigned num_names, symbol const * names) { buffer p; for (unsigned i = 0; i < num_names; i++) p.push_back(parameter(names[i])); - return mk_app(m_label_family_id, OP_LABEL_LIT, p.size(), p.c_ptr(), 0, 0); + return mk_app(m_label_family_id, OP_LABEL_LIT, p.size(), p.c_ptr(), 0, nullptr); } app * ast_manager::mk_label_lit(symbol const & name) { @@ -2309,7 +2309,7 @@ app * ast_manager::mk_pattern(unsigned num_exprs, app * const * exprs) { for (unsigned i = 0; i < num_exprs; ++i) { SASSERT(is_app(exprs[i])); }}); - return mk_app(m_pattern_family_id, OP_PATTERN, 0, 0, num_exprs, (expr*const*)exprs); + return mk_app(m_pattern_family_id, OP_PATTERN, 0, nullptr, num_exprs, (expr*const*)exprs); } bool ast_manager::is_pattern(expr const * n) const { @@ -2406,7 +2406,7 @@ quantifier * ast_manager::update_quantifier(quantifier * q, unsigned num_pattern num_patterns, patterns, num_patterns == 0 ? q->get_num_no_patterns() : 0, - num_patterns == 0 ? q->get_no_patterns() : 0); + num_patterns == 0 ? q->get_no_patterns() : nullptr); } quantifier * ast_manager::update_quantifier(quantifier * q, unsigned num_patterns, expr * const * patterns, unsigned num_no_patterns, expr * const * no_patterns, expr * body) { @@ -2492,7 +2492,7 @@ quantifier * ast_manager::update_quantifier(quantifier * q, bool is_forall, unsi num_patterns, patterns, num_patterns == 0 ? q->get_num_no_patterns() : 0, - num_patterns == 0 ? q->get_no_patterns() : 0); + num_patterns == 0 ? q->get_no_patterns() : nullptr); } app * ast_manager::mk_distinct(unsigned num_args, expr * const * args) { @@ -2524,14 +2524,14 @@ app * ast_manager::mk_distinct_expanded(unsigned num_args, expr * const * args) // ----------------------------------- expr_dependency * ast_manager::mk_leaf(expr * t) { - if (t == 0) - return 0; + if (t == nullptr) + return nullptr; else return m_expr_dependency_manager.mk_leaf(t); } expr_dependency * ast_manager::mk_join(unsigned n, expr * const * ts) { - expr_dependency * d = 0; + expr_dependency * d = nullptr; for (unsigned i = 0; i < n; i++) d = mk_join(d, mk_leaf(ts[i])); return d; @@ -2550,7 +2550,7 @@ void ast_manager::linearize(expr_dependency * d, ptr_vector & ts) { app * ast_manager::mk_model_value(unsigned idx, sort * s) { parameter p[2] = { parameter(idx), parameter(s) }; - return mk_app(m_model_value_family_id, OP_MODEL_VALUE, 2, p, 0, static_cast(0)); + return mk_app(m_model_value_family_id, OP_MODEL_VALUE, 2, p, 0, static_cast(nullptr)); } expr * ast_manager::get_some_value(sort * s, some_value_proc * p) { @@ -2559,17 +2559,17 @@ expr * ast_manager::get_some_value(sort * s, some_value_proc * p) { } expr * ast_manager::get_some_value(sort * s) { - expr * v = 0; + expr * v = nullptr; if (m_some_value_proc) v = (*m_some_value_proc)(s); - if (v != 0) + if (v != nullptr) return v; family_id fid = s->get_family_id(); if (fid != null_family_id) { decl_plugin * p = get_plugin(fid); - if (p != 0) { + if (p != nullptr) { v = p->get_some_value(s); - if (v != 0) + if (v != nullptr) return v; } } @@ -2582,7 +2582,7 @@ bool ast_manager::is_fully_interp(sort * s) const { family_id fid = s->get_family_id(); SASSERT(fid != null_family_id); decl_plugin * p = get_plugin(fid); - if (p != 0) + if (p != nullptr) return p->is_fully_interp(s); return false; } @@ -2780,14 +2780,14 @@ proof * ast_manager::mk_congruence(app * f1, app * f2, unsigned num_proofs, proo SASSERT(get_sort(f1) == get_sort(f2)); sort * s = get_sort(f1); sort * d[2] = { s, s }; - return mk_monotonicity(mk_func_decl(m_basic_family_id, get_eq_op(f1), 0, 0, 2, d), f1, f2, num_proofs, proofs); + return mk_monotonicity(mk_func_decl(m_basic_family_id, get_eq_op(f1), 0, nullptr, 2, d), f1, f2, num_proofs, proofs); } proof * ast_manager::mk_oeq_congruence(app * f1, app * f2, unsigned num_proofs, proof * const * proofs) { SASSERT(get_sort(f1) == get_sort(f2)); sort * s = get_sort(f1); sort * d[2] = { s, s }; - return mk_monotonicity(mk_func_decl(m_basic_family_id, OP_OEQ, 0, 0, 2, d), f1, f2, num_proofs, proofs); + return mk_monotonicity(mk_func_decl(m_basic_family_id, OP_OEQ, 0, nullptr, 2, d), f1, f2, num_proofs, proofs); } proof * ast_manager::mk_quant_intro(quantifier * q1, quantifier * q2, proof * p) { diff --git a/src/ast/ast.h b/src/ast/ast.h index 77049fa53..55fea1b69 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -132,7 +132,7 @@ public: case PARAM_INT: m_int = other.get_int(); break; case PARAM_AST: m_ast = other.get_ast(); break; case PARAM_SYMBOL: m_symbol = other.m_symbol; break; - case PARAM_RATIONAL: m_rational = 0; std::swap(m_rational, other.m_rational); break; + case PARAM_RATIONAL: m_rational = nullptr; std::swap(m_rational, other.m_rational); break; case PARAM_DOUBLE: m_dval = other.m_dval; break; case PARAM_EXTERNAL: m_ext_id = other.m_ext_id; break; default: @@ -258,7 +258,7 @@ class decl_info { public: bool m_private_parameters; decl_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind, - unsigned num_parameters = 0, parameter const * parameters = 0, bool private_params = false); + unsigned num_parameters = 0, parameter const * parameters = nullptr, bool private_params = false); decl_info(decl_info const& other); ~decl_info() {} @@ -342,17 +342,17 @@ class sort_info : public decl_info { sort_size m_num_elements; public: sort_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind, - unsigned num_parameters = 0, parameter const * parameters = 0, bool private_parameters = false): + unsigned num_parameters = 0, parameter const * parameters = nullptr, bool private_parameters = false): decl_info(family_id, k, num_parameters, parameters, private_parameters) { } sort_info(family_id family_id, decl_kind k, uint64 num_elements, - unsigned num_parameters = 0, parameter const * parameters = 0, bool private_parameters = false): + unsigned num_parameters = 0, parameter const * parameters = nullptr, bool private_parameters = false): decl_info(family_id, k, num_parameters, parameters, private_parameters), m_num_elements(num_elements) { } sort_info(family_id family_id, decl_kind k, sort_size const& num_elements, - unsigned num_parameters = 0, parameter const * parameters = 0, bool private_parameters = false): + unsigned num_parameters = 0, parameter const * parameters = nullptr, bool private_parameters = false): decl_info(family_id, k, num_parameters, parameters, private_parameters), m_num_elements(num_elements) { } sort_info(sort_info const& other) : decl_info(other), m_num_elements(other.m_num_elements) { @@ -390,7 +390,7 @@ struct func_decl_info : public decl_info { bool m_idempotent:1; bool m_skolem:1; - func_decl_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind, unsigned num_parameters = 0, parameter const * parameters = 0); + func_decl_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind, unsigned num_parameters = 0, parameter const * parameters = nullptr); ~func_decl_info() {} bool is_associative() const { return m_left_assoc && m_right_assoc; } @@ -565,12 +565,12 @@ public: unsigned get_decl_id() const { SASSERT(get_id() >= c_first_decl_id); return get_id() - c_first_decl_id; } symbol const & get_name() const { return m_name; } decl_info * get_info() const { return m_info; } - family_id get_family_id() const { return m_info == 0 ? null_family_id : m_info->get_family_id(); } - decl_kind get_decl_kind() const { return m_info == 0 ? null_decl_kind : m_info->get_decl_kind(); } - unsigned get_num_parameters() const { return m_info == 0 ? 0 : m_info->get_num_parameters(); } + family_id get_family_id() const { return m_info == nullptr ? null_family_id : m_info->get_family_id(); } + decl_kind get_decl_kind() const { return m_info == nullptr ? null_decl_kind : m_info->get_decl_kind(); } + unsigned get_num_parameters() const { return m_info == nullptr ? 0 : m_info->get_num_parameters(); } parameter const & get_parameter(unsigned idx) const { return m_info->get_parameter(idx); } - parameter const * get_parameters() const { return m_info == 0 ? 0 : m_info->get_parameters(); } - bool private_parameters() const { return m_info != 0 && m_info->private_parameters(); } + parameter const * get_parameters() const { return m_info == nullptr ? nullptr : m_info->get_parameters(); } + bool private_parameters() const { return m_info != nullptr && m_info->private_parameters(); } }; // ----------------------------------- @@ -587,8 +587,8 @@ class sort : public decl { sort(symbol const & name, sort_info * info):decl(AST_SORT, name, info) {} public: sort_info * get_info() const { return static_cast(m_info); } - bool is_infinite() const { return get_info() == 0 || get_info()->is_infinite(); } - bool is_very_big() const { return get_info() == 0 || get_info()->is_very_big(); } + bool is_infinite() const { return get_info() == nullptr || get_info()->is_infinite(); } + bool is_very_big() const { return get_info() == nullptr || get_info()->is_very_big(); } bool is_sort_of(family_id fid, decl_kind k) const { return get_family_id() == fid && get_decl_kind() == k; } sort_size const & get_num_elements() const { return get_info()->get_num_elements(); } void set_num_elements(sort_size const& s) { get_info()->set_num_elements(s); } @@ -613,16 +613,16 @@ class func_decl : public decl { func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range, func_decl_info * info); public: func_decl_info * get_info() const { return static_cast(m_info); } - bool is_associative() const { return get_info() != 0 && get_info()->is_associative(); } - bool is_left_associative() const { return get_info() != 0 && get_info()->is_left_associative(); } - bool is_right_associative() const { return get_info() != 0 && get_info()->is_right_associative(); } - bool is_flat_associative() const { return get_info() != 0 && get_info()->is_flat_associative(); } - bool is_commutative() const { return get_info() != 0 && get_info()->is_commutative(); } - bool is_chainable() const { return get_info() != 0 && get_info()->is_chainable(); } - bool is_pairwise() const { return get_info() != 0 && get_info()->is_pairwise(); } - bool is_injective() const { return get_info() != 0 && get_info()->is_injective(); } - bool is_skolem() const { return get_info() != 0 && get_info()->is_skolem(); } - bool is_idempotent() const { return get_info() != 0 && get_info()->is_idempotent(); } + bool is_associative() const { return get_info() != nullptr && get_info()->is_associative(); } + bool is_left_associative() const { return get_info() != nullptr && get_info()->is_left_associative(); } + bool is_right_associative() const { return get_info() != nullptr && get_info()->is_right_associative(); } + bool is_flat_associative() const { return get_info() != nullptr && get_info()->is_flat_associative(); } + bool is_commutative() const { return get_info() != nullptr && get_info()->is_commutative(); } + bool is_chainable() const { return get_info() != nullptr && get_info()->is_chainable(); } + bool is_pairwise() const { return get_info() != nullptr && get_info()->is_pairwise(); } + bool is_injective() const { return get_info() != nullptr && get_info()->is_injective(); } + bool is_skolem() const { return get_info() != nullptr && get_info()->is_skolem(); } + bool is_idempotent() const { return get_info() != nullptr && get_info()->is_idempotent(); } unsigned get_arity() const { return m_arity; } sort * get_domain(unsigned idx) const { SASSERT(idx < get_arity()); return m_domain[idx]; } sort * const * get_domain() const { return m_domain; } @@ -957,7 +957,7 @@ protected: friend class ast_manager; public: - decl_plugin():m_manager(0), m_family_id(null_family_id) {} + decl_plugin():m_manager(nullptr), m_family_id(null_family_id) {} virtual ~decl_plugin() {} virtual void finalize() {} @@ -1013,7 +1013,7 @@ public: virtual void get_sort_names(svector & sort_names, symbol const & logic = symbol()) {} - virtual expr * get_some_value(sort * s) { return 0; } + virtual expr * get_some_value(sort * s) { return nullptr; } // Return true if the interpreted sort s does not depend on uninterpreted sorts. // This may be the case, for example, for array and datatype sorts. @@ -1497,14 +1497,14 @@ protected: public: - ast_manager(proof_gen_mode = PGM_DISABLED, char const * trace_file = 0, bool is_format_manager = false); + ast_manager(proof_gen_mode = PGM_DISABLED, char const * trace_file = nullptr, bool is_format_manager = false); ast_manager(proof_gen_mode, std::fstream * trace_stream, bool is_format_manager = false); ast_manager(ast_manager const & src, bool disable_proofs = false); ~ast_manager(); // propagate cancellation signal to decl_plugins - bool has_trace_stream() const { return m_trace_stream != 0; } + bool has_trace_stream() const { return m_trace_stream != nullptr; } std::ostream & trace_stream() { SASSERT(has_trace_stream()); return *m_trace_stream; } void enable_int_real_coercions(bool f) { m_int_real_coercions = f; } @@ -1523,7 +1523,7 @@ public: // Equivalent to throw ast_exception(msg) Z3_NORETURN void raise_exception(char const * msg); - bool is_format_manager() const { return m_format_manager == 0; } + bool is_format_manager() const { return m_format_manager == nullptr; } ast_manager & get_format_manager() { return is_format_manager() ? *this : *m_format_manager; } @@ -1558,7 +1558,7 @@ public: decl_plugin * get_plugin(family_id fid) const; - bool has_plugin(family_id fid) const { return get_plugin(fid) != 0; } + bool has_plugin(family_id fid) const { return get_plugin(fid) != nullptr; } bool has_plugin(symbol const & s) const { return m_family_manager.has_family(s) && has_plugin(m_family_manager.get_family_id(s)); } @@ -1670,7 +1670,7 @@ private: public: sort * mk_uninterpreted_sort(symbol const & name, unsigned num_parameters, parameter const * parameters); - sort * mk_uninterpreted_sort(symbol const & name) { return mk_uninterpreted_sort(name, 0, 0); } + sort * mk_uninterpreted_sort(symbol const & name) { return mk_uninterpreted_sort(name, 0, nullptr); } sort * mk_sort(symbol const & name, sort_info const & info) { if (info.get_family_id() == null_family_id) { @@ -1681,7 +1681,7 @@ public: } } - sort * mk_sort(family_id fid, decl_kind k, unsigned num_parameters = 0, parameter const * parameters = 0); + sort * mk_sort(family_id fid, decl_kind k, unsigned num_parameters = 0, parameter const * parameters = nullptr); sort * substitute(sort* s, unsigned n, sort * const * src, sort * const * dst); @@ -1700,13 +1700,13 @@ public: bool is_fully_interp(sort * s) const; func_decl * mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned arity, sort * const * domain, sort * range = 0); + unsigned arity, sort * const * domain, sort * range = nullptr); func_decl * mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters, - unsigned num_args, expr * const * args, sort * range = 0); + unsigned num_args, expr * const * args, sort * range = nullptr); - app * mk_app(family_id fid, decl_kind k, unsigned num_parameters = 0, parameter const * parameters = 0, - unsigned num_args = 0, expr * const * args = 0, sort * range = 0); + app * mk_app(family_id fid, decl_kind k, unsigned num_parameters = 0, parameter const * parameters = nullptr, + unsigned num_args = 0, expr * const * args = nullptr, sort * range = nullptr); app * mk_app(family_id fid, decl_kind k, unsigned num_args, expr * const * args); @@ -1716,7 +1716,7 @@ public: app * mk_app(family_id fid, decl_kind k, expr * arg1, expr * arg2, expr * arg3); - app * mk_const(family_id fid, decl_kind k) { return mk_app(fid, k, 0, static_cast(0)); } + app * mk_const(family_id fid, decl_kind k) { return mk_app(fid, k, 0, static_cast(nullptr)); } private: func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range, func_decl_info * info); @@ -1727,13 +1727,13 @@ private: public: func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range) { - return mk_func_decl(name, arity, domain, range, static_cast(0)); + return mk_func_decl(name, arity, domain, range, static_cast(nullptr)); } func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range, func_decl_info const & info) { if (info.is_null()) { - return mk_func_decl(name, arity, domain, range, static_cast(0)); + return mk_func_decl(name, arity, domain, range, static_cast(nullptr)); } else { return mk_func_decl(name, arity, domain, range, & const_cast(info)); @@ -1746,11 +1746,11 @@ public: } func_decl * mk_const_decl(symbol const & name, sort * s) { - return mk_func_decl(name, static_cast(0), 0, s); + return mk_func_decl(name, static_cast(0), nullptr, s); } func_decl * mk_const_decl(symbol const & name, sort * s, func_decl_info const & info) { - return mk_func_decl(name, static_cast(0), 0, s, info); + return mk_func_decl(name, static_cast(0), nullptr, s, info); } func_decl * mk_func_decl(symbol const & name, sort * domain, sort * range, func_decl_info const & info) { @@ -1804,7 +1804,7 @@ public: app * mk_const(func_decl * decl) { SASSERT(decl->get_arity() == 0); - return mk_app(decl, static_cast(0), static_cast(0)); + return mk_app(decl, static_cast(0), static_cast(nullptr)); } app * mk_const(symbol const & name, sort * s) { @@ -1825,9 +1825,9 @@ public: return mk_fresh_func_decl(symbol(prefix), symbol::null, arity, domain, range); } - app * mk_fresh_const(char const * prefix, sort * s) { return mk_const(mk_fresh_func_decl(prefix, 0, 0, s)); } + app * mk_fresh_const(char const * prefix, sort * s) { return mk_const(mk_fresh_func_decl(prefix, 0, nullptr, s)); } - symbol mk_fresh_var_name(char const * prefix = 0); + symbol mk_fresh_var_name(char const * prefix = nullptr); var * mk_var(unsigned idx, sort * ty); @@ -1879,21 +1879,21 @@ public: quantifier * mk_quantifier(bool forall, unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body, int weight = 0, symbol const & qid = symbol::null, symbol const & skid = symbol::null, - unsigned num_patterns = 0, expr * const * patterns = 0, - unsigned num_no_patterns = 0, expr * const * no_patterns = 0); + unsigned num_patterns = 0, expr * const * patterns = nullptr, + unsigned num_no_patterns = 0, expr * const * no_patterns = nullptr); quantifier * mk_forall(unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body, int weight = 0, symbol const & qid = symbol::null, symbol const & skid = symbol::null, - unsigned num_patterns = 0, expr * const * patterns = 0, - unsigned num_no_patterns = 0, expr * const * no_patterns = 0) { + unsigned num_patterns = 0, expr * const * patterns = nullptr, + unsigned num_no_patterns = 0, expr * const * no_patterns = nullptr) { return mk_quantifier(true, num_decls, decl_sorts, decl_names, body, weight, qid, skid, num_patterns, patterns, num_no_patterns, no_patterns); } quantifier * mk_exists(unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body, int weight = 0, symbol const & qid = symbol::null, symbol const & skid = symbol::null, - unsigned num_patterns = 0, expr * const * patterns = 0, - unsigned num_no_patterns = 0, expr * const * no_patterns = 0) { + unsigned num_patterns = 0, expr * const * patterns = nullptr, + unsigned num_no_patterns = 0, expr * const * no_patterns = nullptr) { return mk_quantifier(false, num_decls, decl_sorts, decl_names, body, weight, qid, skid, num_patterns, patterns, num_no_patterns, no_patterns); } @@ -2057,12 +2057,12 @@ public: func_decl* mk_and_decl() { sort* domain[2] = { m_bool_sort, m_bool_sort }; - return mk_func_decl(m_basic_family_id, OP_AND, 0, 0, 2, domain); + return mk_func_decl(m_basic_family_id, OP_AND, 0, nullptr, 2, domain); } - func_decl* mk_not_decl() { return mk_func_decl(m_basic_family_id, OP_NOT, 0, 0, 1, &m_bool_sort); } + func_decl* mk_not_decl() { return mk_func_decl(m_basic_family_id, OP_NOT, 0, nullptr, 1, &m_bool_sort); } func_decl* mk_or_decl() { sort* domain[2] = { m_bool_sort, m_bool_sort }; - return mk_func_decl(m_basic_family_id, OP_OR, 0, 0, 2, domain); + return mk_func_decl(m_basic_family_id, OP_OR, 0, nullptr, 2, domain); } // ----------------------------------- @@ -2210,7 +2210,7 @@ public: proof * mk_th_lemma(family_id tid, expr * fact, unsigned num_proofs, proof * const * proofs, - unsigned num_params = 0, parameter const* params = 0); + unsigned num_params = 0, parameter const* params = nullptr); protected: bool check_nnf_proof_parents(unsigned num_proofs, proof * const * proofs) const; diff --git a/src/ast/ast_ll_pp.cpp b/src/ast/ast_ll_pp.cpp index c00053780..cbdd94efb 100644 --- a/src/ast/ast_ll_pp.cpp +++ b/src/ast/ast_ll_pp.cpp @@ -319,11 +319,11 @@ void ast_ll_pp(std::ostream & out, ast_manager & m, ast * n, ast_mark & visited, } void ast_def_ll_pp(std::ostream & out, ast_manager & m, ast * n, ast_mark & visited, bool only_exprs, bool compact) { - ll_printer p(out, m, 0, only_exprs, compact); + ll_printer p(out, m, nullptr, only_exprs, compact); p.pp(n, visited); } void ast_ll_bounded_pp(std::ostream & out, ast_manager & m, ast * n, unsigned depth) { - ll_printer p(out, m, 0, false, true); + ll_printer p(out, m, nullptr, false, true); p.display_bounded(n, depth); } diff --git a/src/ast/ast_pp.h b/src/ast/ast_pp.h index 997b1a6e0..5629f847a 100644 --- a/src/ast/ast_pp.h +++ b/src/ast/ast_pp.h @@ -24,10 +24,10 @@ Revision History: #include "ast/ast_smt2_pp.h" struct mk_pp : public mk_ismt2_pp { - mk_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0): + mk_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = nullptr): mk_ismt2_pp(t, m, p, indent, num_vars, var_prefix) { } - mk_pp(ast * t, ast_manager & m, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0): + mk_pp(ast * t, ast_manager & m, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = nullptr): mk_ismt2_pp(t, m, indent, num_vars, var_prefix) { } }; diff --git a/src/ast/ast_pp_util.cpp b/src/ast/ast_pp_util.cpp index 677422b8a..4579f2ffc 100644 --- a/src/ast/ast_pp_util.cpp +++ b/src/ast/ast_pp_util.cpp @@ -40,7 +40,7 @@ void ast_pp_util::display_decls(std::ostream& out) { ast_smt_pp pp(m); unsigned n = coll.get_num_sorts(); for (unsigned i = 0; i < n; ++i) { - pp.display_ast_smt2(out, coll.get_sorts()[i], 0, 0, 0); + pp.display_ast_smt2(out, coll.get_sorts()[i], 0, 0, nullptr); } n = coll.get_num_decls(); for (unsigned i = 0; i < n; ++i) { diff --git a/src/ast/ast_printer.cpp b/src/ast/ast_printer.cpp index 63e855c59..536e1af92 100644 --- a/src/ast/ast_printer.cpp +++ b/src/ast/ast_printer.cpp @@ -37,7 +37,7 @@ public: void pp(func_decl * f, format_ns::format_ref & r) const override { mk_smt2_format(f, env(), params_ref(), r); } void pp(expr * n, format_ns::format_ref & r) const override { sbuffer buf; - mk_smt2_format(n, env(), params_ref(), 0, 0, r, buf); + mk_smt2_format(n, env(), params_ref(), 0, nullptr, r, buf); } void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const override { mk_smt2_format(n, env(), params_ref(), num_vars, var_prefix, r, var_names); diff --git a/src/ast/ast_smt2_pp.cpp b/src/ast/ast_smt2_pp.cpp index 0139cb0f0..8ad7c27f1 100644 --- a/src/ast/ast_smt2_pp.cpp +++ b/src/ast/ast_smt2_pp.cpp @@ -236,7 +236,7 @@ format * smt2_pp_environment::pp_float_literal(app * t, bool use_bv_lits, bool u mpf_manager & fm = get_futil().fm(); scoped_mpf v(fm); ast_manager & m = get_manager(); - format * body = 0; + format * body = nullptr; string_buffer<> buf; VERIFY(get_futil().is_numeral(t, v)); if (fm.is_nan(v)) { @@ -750,7 +750,7 @@ class smt2_printer { } buffer labels; bool is_pos; - format * f = 0; + format * f = nullptr; format ** it = m_format_stack.c_ptr() + fr.m_spos; format ** end = m_format_stack.c_ptr() + m_format_stack.size(); if (m().is_label(t, is_pos, labels)) { @@ -1004,7 +1004,7 @@ class smt2_printer { void del_expr2alias_stack() { std::for_each(m_expr2alias_stack.begin(), m_expr2alias_stack.end(), delete_proc()); m_expr2alias_stack.reset(); - m_expr2alias = 0; + m_expr2alias = nullptr; } void reset_expr2alias_stack() { @@ -1064,7 +1064,7 @@ public: m_manager(env.get_manager()), m_env(env), m_soccs(m_manager), - m_root(0), + m_root(nullptr), m_aliased_pps(fm()), m_next_alias_idx(1), m_format_stack(fm()) { @@ -1092,7 +1092,7 @@ public: void operator()(expr * n, unsigned num, char const * var_prefix, format_ref & r, sbuffer & var_names) { reset_var_names(); - if (var_prefix == 0) + if (var_prefix == nullptr) var_prefix = "x"; if (strcmp(var_prefix, ALIAS_PREFIX) == 0) { var_prefix = "_a"; @@ -1228,7 +1228,7 @@ mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, unsigned indent, unsigned num std::ostream& operator<<(std::ostream& out, mk_ismt2_pp const & p) { smt2_pp_environment_dbg env(p.m_manager); - if (p.m_ast == 0) { + if (p.m_ast == nullptr) { out << "null"; } else if (is_expr(p.m_ast)) { @@ -1263,13 +1263,13 @@ std::ostream& operator<<(std::ostream& out, sort_ref const& e) { std::ostream& operator<<(std::ostream& out, expr_ref_vector const& e) { smt2_pp_environment_dbg env(e.get_manager()); params_ref p; - return ast_smt2_pp(out, e.size(), e.c_ptr(), env, p, 0, 0, 0); + return ast_smt2_pp(out, e.size(), e.c_ptr(), env, p, 0, 0, nullptr); } std::ostream& operator<<(std::ostream& out, app_ref_vector const& e) { smt2_pp_environment_dbg env(e.get_manager()); params_ref p; - return ast_smt2_pp(out, e.size(), (expr*const*)e.c_ptr(), env, p, 0, 0, 0); + return ast_smt2_pp(out, e.size(), (expr*const*)e.c_ptr(), env, p, 0, 0, nullptr); } std::ostream& operator<<(std::ostream& out, func_decl_ref_vector const& e) { diff --git a/src/ast/ast_smt2_pp.h b/src/ast/ast_smt2_pp.h index 041622b74..69b8d67f9 100644 --- a/src/ast/ast_smt2_pp.h +++ b/src/ast/ast_smt2_pp.h @@ -98,7 +98,7 @@ void mk_smt2_format(sort * s, smt2_pp_environment & env, params_ref const & p, f void mk_smt2_format(func_decl * f, smt2_pp_environment & env, params_ref const & p, format_ns::format_ref & r); std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & env, params_ref const & p = params_ref(), unsigned indent = 0, - unsigned num_vars = 0, char const * var_prefix = 0); + unsigned num_vars = 0, char const * var_prefix = nullptr); std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & env, params_ref const & p = params_ref(), unsigned indent = 0); std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, params_ref const & p = params_ref(), unsigned indent = 0); @@ -113,8 +113,8 @@ struct mk_ismt2_pp { unsigned m_indent; unsigned m_num_vars; char const * m_var_prefix; - mk_ismt2_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0); - mk_ismt2_pp(ast * t, ast_manager & m, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0); + mk_ismt2_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = nullptr); + mk_ismt2_pp(ast * t, ast_manager & m, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = nullptr); }; std::ostream& operator<<(std::ostream& out, mk_ismt2_pp const & p); diff --git a/src/ast/ast_smt_pp.cpp b/src/ast/ast_smt_pp.cpp index bad4b1984..ace0de2cc 100644 --- a/src/ast/ast_smt_pp.cpp +++ b/src/ast/ast_smt_pp.cpp @@ -702,7 +702,7 @@ class smt_printer { public: smt_printer(std::ostream& out, ast_manager& m, ptr_vector& ql, smt_renaming& rn, - symbol logic, bool no_lets, bool simplify_implies, unsigned indent, unsigned num_var_names = 0, char const* const* var_names = 0) : + symbol logic, bool no_lets, bool simplify_implies, unsigned indent, unsigned num_var_names = 0, char const* const* var_names = nullptr) : m_out(out), m_manager(m), m_qlists(ql), @@ -768,7 +768,7 @@ public: } m_mark.reset(); m_num_lets = 0; - m_top = 0; + m_top = nullptr; } void pp_dt(ast_mark& mark, sort* s) { diff --git a/src/ast/ast_smt_pp.h b/src/ast/ast_smt_pp.h index ac2e33140..71842904c 100644 --- a/src/ast/ast_smt_pp.h +++ b/src/ast/ast_smt_pp.h @@ -76,8 +76,8 @@ public: void set_is_declared(is_declared* id) { m_is_declared = id; } void display_smt2(std::ostream& strm, expr* n); - void display_expr_smt2(std::ostream& strm, expr* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0); - void display_ast_smt2(std::ostream& strm, ast* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0); + void display_expr_smt2(std::ostream& strm, expr* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = nullptr); + void display_ast_smt2(std::ostream& strm, ast* n, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = nullptr); }; @@ -87,7 +87,7 @@ struct mk_smt_pp { unsigned m_indent; unsigned m_num_var_names; char const* const* m_var_names; - mk_smt_pp(ast* e, ast_manager & m, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = 0) : + mk_smt_pp(ast* e, ast_manager & m, unsigned indent = 0, unsigned num_var_names = 0, char const* const* var_names = nullptr) : m_ast(e), m_manager(m), m_indent(indent), m_num_var_names(num_var_names), m_var_names(var_names) {} }; diff --git a/src/ast/ast_translation.cpp b/src/ast/ast_translation.cpp index 1bce4bcbe..8d6ebf221 100644 --- a/src/ast/ast_translation.cpp +++ b/src/ast/ast_translation.cpp @@ -108,7 +108,7 @@ void ast_translation::copy_params(decl * d, unsigned rpos, buffer & p void ast_translation::mk_sort(sort * s, frame & fr) { sort_info * si = s->get_info(); sort * new_s; - if (si == 0) { + if (si == nullptr) { // TODO: investigate: this branch is probably unreachable. // It became unreachable after we started using mk_uninterpreted_sort for creating uninterpreted sorts, // and mk_uninterpreted_sort actually creates a user_sort. @@ -139,7 +139,7 @@ void ast_translation::mk_func_decl(func_decl * f, frame & fr) { sort ** new_domain = reinterpret_cast(m_result_stack.c_ptr() + fr.m_rpos + num_extra); sort * new_range = static_cast(m_result_stack.back()); func_decl * new_f; - if (fi == 0) { + if (fi == nullptr) { new_f = m_to_manager.mk_func_decl(f->get_name(), f->get_arity(), new_domain, @@ -182,7 +182,7 @@ void ast_translation::mk_func_decl(func_decl * f, frame & fr) { } ast * ast_translation::process(ast const * _n) { - if (!_n) return 0; + if (!_n) return nullptr; SASSERT(m_result_stack.empty()); SASSERT(m_frame_stack.empty()); SASSERT(m_extra_children_stack.empty()); @@ -320,7 +320,7 @@ ast * ast_translation::process(ast const * _n) { } expr_dependency * expr_dependency_translation::operator()(expr_dependency * d) { - if (d == 0) + if (d == nullptr) return d; m_buffer.reset(); m_translation.from().linearize(d, m_buffer); diff --git a/src/ast/ast_util.cpp b/src/ast/ast_util.cpp index 68f5b2486..92a539d88 100644 --- a/src/ast/ast_util.cpp +++ b/src/ast/ast_util.cpp @@ -38,7 +38,7 @@ app * mk_list_assoc_app(ast_manager & m, func_decl * f, unsigned num_args, expr } app * mk_list_assoc_app(ast_manager & m, family_id fid, decl_kind k, unsigned num_args, expr * const * args) { - func_decl * decl = m.mk_func_decl(fid, k, 0, 0, num_args, args, 0); + func_decl * decl = m.mk_func_decl(fid, k, 0, nullptr, num_args, args, nullptr); SASSERT(decl != 0); SASSERT(decl->is_associative()); return mk_list_assoc_app(m, decl, num_args, args); diff --git a/src/ast/bv_decl_plugin.cpp b/src/ast/bv_decl_plugin.cpp index 28c3d5f5d..e3e7c7167 100644 --- a/src/ast/bv_decl_plugin.cpp +++ b/src/ast/bv_decl_plugin.cpp @@ -34,11 +34,11 @@ bv_decl_plugin::bv_decl_plugin(): m_repeat_sym("repeat"), m_bit2bool_sym("bit2bool"), m_mkbv_sym("mkbv"), - m_bit0(0), - m_bit1(0), - m_carry(0), - m_xor3(0), - m_int_sort(0) { + m_bit0(nullptr), + m_bit1(nullptr), + m_carry(nullptr), + m_xor3(nullptr), + m_int_sort(nullptr) { } void bv_decl_plugin::set_manager(ast_manager * m, family_id id) { @@ -218,7 +218,7 @@ func_decl * bv_decl_plugin::mk_int2bv(unsigned bv_size, unsigned num_parameters, if (arity != 1) { m_manager->raise_exception("expecting one argument to int2bv"); - return 0; + return nullptr; } if (m_int2bv[bv_size] == 0) { @@ -237,7 +237,7 @@ func_decl * bv_decl_plugin::mk_bv2int(unsigned bv_size, unsigned num_parameters, if (arity != 1) { m_manager->raise_exception("expecting one argument to bv2int"); - return 0; + return nullptr; } if (m_bv2int[bv_size] == 0) { @@ -341,7 +341,7 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned bv_size) { case OP_EXT_ROTATE_LEFT: return mk_binary(m_ext_rotate_left, k, "ext_rotate_left", bv_size, false); case OP_EXT_ROTATE_RIGHT: return mk_binary(m_ext_rotate_right, k, "ext_rotate_right", bv_size, false); - default: return 0; + default: return nullptr; } } @@ -417,7 +417,7 @@ bool bv_decl_plugin::get_int2bv_size(unsigned num_parameters, parameter const * func_decl * bv_decl_plugin::mk_num_decl(unsigned num_parameters, parameter const * parameters, unsigned arity) { if (!(num_parameters == 2 && arity == 0 && parameters[0].is_rational() && parameters[1].is_int())) { m_manager->raise_exception("invalid bit-vector numeral declaration"); - return 0; + return nullptr; } unsigned bv_size = parameters[1].get_int(); if (bv_size == 0) { @@ -437,7 +437,7 @@ func_decl * bv_decl_plugin::mk_bit2bool(unsigned bv_size, unsigned num_parameter unsigned arity, sort * const * domain) { if (!(num_parameters == 1 && parameters[0].is_int() && arity == 1 && parameters[0].get_int() < static_cast(bv_size))) { m_manager->raise_exception("invalid bit2bool declaration"); - return 0; + return nullptr; } unsigned idx = parameters[0].get_int(); m_bit2bool.reserve(bv_size+1); @@ -455,7 +455,7 @@ func_decl * bv_decl_plugin::mk_mkbv(unsigned arity, sort * const * domain) { for (unsigned i = 0; i < arity; i++) { if (!m_manager->is_bool(domain[i])) { m_manager->raise_exception("invalid mkbv operator"); - return 0; + return nullptr; } } unsigned bv_size = arity; @@ -493,26 +493,26 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p } else if (arity == 0) { m_manager->raise_exception("no arguments supplied to bit-vector operator"); - return 0; + return nullptr; } else if (!get_bv_size(domain[0], bv_size)) { m_manager->raise_exception("could not extract bit-vector size"); - return 0; + return nullptr; } func_decl * r = mk_func_decl(k, bv_size); - if (r != 0) { + if (r != nullptr) { if (arity != r->get_arity()) { if (r->get_info()->is_associative()) arity = r->get_arity(); else { m_manager->raise_exception("declared arity mismatches supplied arity"); - return 0; + return nullptr; } } for (unsigned i = 0; i < arity; ++i) { if (domain[i] != r->get_domain(i)) { m_manager->raise_exception("declared sorts do not match supplied sorts"); - return 0; + return nullptr; } } return r; @@ -565,7 +565,7 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p return m_manager->mk_func_decl(m_repeat_sym, arity, domain, get_bv_sort(bv_size * parameters[0].get_int()), func_decl_info(m_family_id, k, num_parameters, parameters)); default: - return 0; + return nullptr; } } @@ -596,24 +596,24 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p } else if (num_args == 0 || !get_bv_size(args[0], bv_size)) { m.raise_exception("operator is applied to arguments of the wrong sort"); - return 0; + return nullptr; } func_decl * r = mk_func_decl(k, bv_size); - if (r != 0) { + if (r != nullptr) { if (num_args != r->get_arity()) { if (r->get_info()->is_associative()) { sort * fs = r->get_domain(0); for (unsigned i = 0; i < num_args; ++i) { if (m.get_sort(args[i]) != fs) { m_manager->raise_exception("declared sorts do not match supplied sorts"); - return 0; + return nullptr; } } return r; } else { m.raise_exception("declared arity mismatches supplied arity"); - return 0; + return nullptr; } } for (unsigned i = 0; i < num_args; ++i) { @@ -621,7 +621,7 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p std::ostringstream buffer; buffer << "Argument " << mk_pp(args[i], m) << " at position " << i << " does not match declaration " << mk_pp(r, m); m.raise_exception(buffer.str().c_str()); - return 0; + return nullptr; } } return r; @@ -747,7 +747,7 @@ expr * bv_decl_plugin::get_some_value(sort * s) { SASSERT(s->is_sort_of(m_family_id, BV_SORT)); unsigned bv_size = s->get_parameter(0).get_int(); parameter p[2] = { parameter(rational(0)), parameter(static_cast(bv_size)) }; - return m_manager->mk_app(m_family_id, OP_BV_NUM, 2, p, 0, 0); + return m_manager->mk_app(m_family_id, OP_BV_NUM, 2, p, 0, nullptr); } rational bv_recognizers::norm(rational const & val, unsigned bv_size, bool is_signed) const { @@ -856,7 +856,7 @@ bv_util::bv_util(ast_manager & m): app * bv_util::mk_numeral(rational const & val, sort* s) const { if (!is_bv_sort(s)) { - return 0; + return nullptr; } unsigned bv_size = get_bv_size(s); return mk_numeral(val, bv_size); @@ -864,7 +864,7 @@ app * bv_util::mk_numeral(rational const & val, sort* s) const { app * bv_util::mk_numeral(rational const & val, unsigned bv_size) const { parameter p[2] = { parameter(val), parameter(static_cast(bv_size)) }; - return m_manager.mk_app(get_fid(), OP_BV_NUM, 2, p, 0, 0); + return m_manager.mk_app(get_fid(), OP_BV_NUM, 2, p, 0, nullptr); } sort * bv_util::mk_sort(unsigned bv_size) { diff --git a/src/ast/bv_decl_plugin.h b/src/ast/bv_decl_plugin.h index 18054ca09..4aff8cd06 100644 --- a/src/ast/bv_decl_plugin.h +++ b/src/ast/bv_decl_plugin.h @@ -122,7 +122,7 @@ inline bv_op_kind get_div0_op(bv_op_kind k) { // models the value of "div" it is underspecified (i.e., when the denominator is zero). inline func_decl * get_div0_decl(ast_manager & m, func_decl * decl) { return m.mk_func_decl(decl->get_family_id(), get_div0_op(static_cast(decl->get_decl_kind())), - 0, 0, 1, decl->get_domain()); + 0, nullptr, 1, decl->get_domain()); } class bv_decl_plugin : public decl_plugin { diff --git a/src/ast/datatype_decl_plugin.cpp b/src/ast/datatype_decl_plugin.cpp index 91e636ed7..44752866c 100644 --- a/src/ast/datatype_decl_plugin.cpp +++ b/src/ast/datatype_decl_plugin.cpp @@ -157,13 +157,13 @@ namespace datatype { dealloc(kv.m_value); } m_defs.reset(); - m_util = 0; // force deletion + m_util = nullptr; // force deletion } util & plugin::u() const { SASSERT(m_manager); SASSERT(m_family_id != null_family_id); - if (m_util.get() == 0) { + if (m_util.get() == nullptr) { m_util = alloc(util, *m_manager); } return *(m_util.get()); @@ -215,7 +215,7 @@ namespace datatype { sort* s = m_manager->mk_sort(name.get_symbol(), sort_info(m_family_id, k, num_parameters, parameters, true)); - def* d = 0; + def* d = nullptr; if (m_defs.find(s->get_name(), d) && d->sort_size()) { obj_map S; for (unsigned i = 0; i + 1 < num_parameters; ++i) { @@ -233,7 +233,7 @@ namespace datatype { } catch (invalid_datatype) { m_manager->raise_exception("invalid datatype"); - return 0; + return nullptr; } } @@ -245,35 +245,35 @@ namespace datatype { if (num_parameters != 1 || !parameters[0].is_ast()) { m.raise_exception("invalid parameters for datatype field update"); - return 0; + return nullptr; } if (arity != 2) { m.raise_exception("invalid number of arguments for datatype field update"); - return 0; + return nullptr; } - func_decl* acc = 0; + func_decl* acc = nullptr; if (is_func_decl(parameters[0].get_ast())) { acc = to_func_decl(parameters[0].get_ast()); } if (acc && !u().is_accessor(acc)) { - acc = 0; + acc = nullptr; } if (!acc) { m.raise_exception("datatype field update requires a datatype accessor as the second argument"); - return 0; + return nullptr; } sort* dom = acc->get_domain(0); sort* rng = acc->get_range(); if (dom != domain[0]) { m.raise_exception("first argument to field update should be a data-type"); - return 0; + return nullptr; } if (rng != domain[1]) { std::ostringstream buffer; buffer << "second argument to field update should be " << mk_ismt2_pp(rng, m) << " instead of " << mk_ismt2_pp(domain[1], m); m.raise_exception(buffer.str().c_str()); - return 0; + return nullptr; } range = domain[0]; func_decl_info info(m_family_id, k, num_parameters, parameters); @@ -345,7 +345,7 @@ namespace datatype { return mk_update_field(num_parameters, parameters, arity, domain, range); default: m_manager->raise_exception("invalid datatype operator kind"); - return 0; + return nullptr; } } @@ -386,7 +386,7 @@ namespace datatype { bool plugin::mk_datatypes(unsigned num_datatypes, def * const * datatypes, unsigned num_params, sort* const* sort_params, sort_ref_vector & new_sorts) { begin_def_block(); for (unsigned i = 0; i < num_datatypes; ++i) { - def* d = 0; + def* d = nullptr; TRACE("datatype", tout << "declaring " << datatypes[i]->name() << "\n";); if (m_defs.find(datatypes[i]->name(), d)) { TRACE("datatype", tout << "delete previous version for " << datatypes[i]->name() << "\n";); @@ -404,7 +404,7 @@ namespace datatype { } void plugin::remove(symbol const& s) { - def* d = 0; + def* d = nullptr; if (m_defs.find(s, d)) dealloc(d); m_defs.remove(s); } @@ -750,7 +750,7 @@ namespace datatype { ptr_vector const * util::get_datatype_constructors(sort * ty) { SASSERT(is_datatype(ty)); - ptr_vector * r = 0; + ptr_vector * r = nullptr; if (m_datatype2constructors.find(ty, r)) return r; r = alloc(ptr_vector); @@ -768,7 +768,7 @@ namespace datatype { ptr_vector const * util::get_constructor_accessors(func_decl * con) { SASSERT(is_constructor(con)); - ptr_vector * res = 0; + ptr_vector * res = nullptr; if (m_constructor2accessors.find(con, res)) { return res; } @@ -793,7 +793,7 @@ namespace datatype { func_decl * util::get_constructor_recognizer(func_decl * con) { SASSERT(is_constructor(con)); - func_decl * d = 0; + func_decl * d = nullptr; if (m_constructor2recognizer.find(con, d)) return d; sort * datatype = con->get_range(); @@ -848,7 +848,7 @@ namespace datatype { func_decl * util::get_accessor_constructor(func_decl * accessor) { SASSERT(is_accessor(accessor)); - func_decl * r = 0; + func_decl * r = nullptr; if (m_accessor2constructor.find(accessor, r)) return r; sort * datatype = accessor->get_domain(0); @@ -892,10 +892,10 @@ namespace datatype { */ func_decl * util::get_non_rec_constructor(sort * ty) { SASSERT(is_datatype(ty)); - func_decl * r = 0; + func_decl * r = nullptr; if (m_datatype2nonrec_constructor.find(ty, r)) return r; - r = 0; + r = nullptr; ptr_vector forbidden_set; forbidden_set.push_back(ty); TRACE("util_bug", tout << "invoke get-non-rec: " << sort_ref(ty, m) << "\n";); @@ -962,14 +962,14 @@ namespace datatype { func_decl * nested_c = get_non_rec_constructor_core(T_i, forbidden_set); SASSERT(forbidden_set.back() == T_i); forbidden_set.pop_back(); - if (nested_c == 0) + if (nested_c == nullptr) break; TRACE("util_bug", tout << "nested_c: " << nested_c->get_name() << "\n";); } if (i == num_args) return c; } - return 0; + return nullptr; } unsigned util::get_constructor_idx(func_decl * f) const { diff --git a/src/ast/datatype_decl_plugin.h b/src/ast/datatype_decl_plugin.h index b61142909..81c2d09a5 100644 --- a/src/ast/datatype_decl_plugin.h +++ b/src/ast/datatype_decl_plugin.h @@ -204,7 +204,7 @@ namespace datatype { m_util(u), m_name(n), m_class_id(class_id), - m_sort_size(0), + m_sort_size(nullptr), m_params(m, num_params, params), m_sort(m) {} @@ -228,7 +228,7 @@ namespace datatype { sort_ref_vector const& params() const { return m_params; } util& u() const { return m_util; } param_size::size* sort_size() { return m_sort_size; } - void set_sort_size(param_size::size* p) { m_sort_size = p; p->inc_ref(); m_sort = 0; } + void set_sort_size(param_size::size* p) { m_sort_size = p; p->inc_ref(); m_sort = nullptr; } def* translate(ast_translation& tr, util& u); }; @@ -398,7 +398,7 @@ typedef datatype::util datatype_util; class type_ref { void * m_data; public: - type_ref():m_data(TAG(void *, static_cast(0), 1)) {} + type_ref():m_data(TAG(void *, nullptr, 1)) {} type_ref(int idx):m_data(BOXINT(void *, idx)) {} type_ref(sort * s):m_data(TAG(void *, s, 1)) {} diff --git a/src/ast/dl_decl_plugin.cpp b/src/ast/dl_decl_plugin.cpp index 1be3c4756..e5b9ed930 100644 --- a/src/ast/dl_decl_plugin.cpp +++ b/src/ast/dl_decl_plugin.cpp @@ -72,7 +72,7 @@ namespace datalog { for (unsigned i = 0; is_finite && i < num_parameters; ++i) { if (!parameters[i].is_ast() || !is_sort(parameters[i].get_ast())) { m_manager->raise_exception("expecting sort parameters"); - return 0; + return nullptr; } sort* s = to_sort(parameters[i].get_ast()); sort_size sz1 = s->get_num_elements(); @@ -97,16 +97,16 @@ namespace datalog { sort * dl_decl_plugin::mk_finite_sort(unsigned num_params, parameter const* params) { if (num_params != 2) { m_manager->raise_exception("expecting two parameters"); - return 0; + return nullptr; } if (!params[0].is_symbol()) { m_manager->raise_exception("expecting symbol"); - return 0; + return nullptr; } if (!params[1].is_rational() || !params[1].get_rational().is_uint64()) { m_manager->raise_exception("expecting rational"); - return 0; + return nullptr; } sort_size sz = sort_size::mk_finite(params[1].get_rational().get_uint64()); sort_info info(m_family_id, DL_FINITE_SORT, sz, num_params, params); @@ -115,7 +115,7 @@ namespace datalog { sort* dl_decl_plugin::mk_rule_sort() { sort_size sz(sort_size::mk_infinite()); - sort_info info(m_family_id, DL_RULE_SORT, sz, 0, 0); + sort_info info(m_family_id, DL_RULE_SORT, sz, 0, nullptr); return m_manager->mk_sort(m_rule_sym, info); } @@ -130,7 +130,7 @@ namespace datalog { default: UNREACHABLE(); } - return 0; + return nullptr; } bool dl_decl_plugin::is_rel_sort(sort* r) { @@ -173,11 +173,11 @@ namespace datalog { } ptr_vector sorts; if (!is_rel_sort(r, sorts)) { - return 0; + return nullptr; } if (sorts.size() + 1 != arity) { m_manager->raise_exception("wrong arity supplied to relational access"); - return 0; + return nullptr; } for (unsigned i = 0; i < sorts.size(); ++i) { if (sorts[i] != domain[i+1]) { @@ -186,10 +186,10 @@ namespace datalog { mk_pp(sorts[i], m) << "\n" << mk_pp(domain[i+1], m) << "\n";); m_manager->raise_exception("sort miss-match for relational access"); - return 0; + return nullptr; } } - func_decl_info info(m_family_id, k, 0, 0); + func_decl_info info(m_family_id, k, 0, nullptr); return m.mk_func_decl(sym, arity, domain, r, info); } @@ -197,14 +197,14 @@ namespace datalog { ast_manager& m = *m_manager; if (!p.is_ast() || !is_sort(p.get_ast())) { m_manager->raise_exception("expected sort parameter"); - return 0; + return nullptr; } sort* r = to_sort(p.get_ast()); if (!is_rel_sort(r)) { - return 0; + return nullptr; } func_decl_info info(m_family_id, OP_RA_EMPTY, 1, &p); - return m.mk_func_decl(m_empty_sym, 0, (sort*const*)0, r, info); + return m.mk_func_decl(m_empty_sym, 0, (sort*const*)nullptr, r, info); } func_decl* dl_decl_plugin::mk_project(unsigned num_params, parameter const* params, sort* r) { @@ -219,7 +219,7 @@ namespace datalog { tout << "\n"; ); if (!is_rel_sort(r, sorts)) { - return 0; + return nullptr; } SASSERT(sorts.size() >= num_params); // populate ps @@ -227,12 +227,12 @@ namespace datalog { for (; i < num_params; ++i) { if (!params[i].is_int()) { m_manager->raise_exception("expecting integer parameter"); - return 0; + return nullptr; } unsigned k = params[i].get_int(); if (j > k) { m_manager->raise_exception("arguments to projection should be increasing"); - return 0; + return nullptr; } while (j < k) { ps.push_back(parameter(sorts[j])); @@ -253,13 +253,13 @@ namespace datalog { ast_manager& m = *m_manager; if (s1 != s2) { m_manager->raise_exception("sort miss-match for arguments to union"); - return 0; + return nullptr; } if (!is_rel_sort(s1)) { - return 0; + return nullptr; } sort* domain[2] = { s1, s2 }; - func_decl_info info(m_family_id, k, 0, 0); + func_decl_info info(m_family_id, k, 0, nullptr); return m.mk_func_decl(m_union_sym, 2, domain, s1, info); } @@ -267,7 +267,7 @@ namespace datalog { ast_manager& m = *m_manager; ptr_vector sorts; if (!is_rel_sort(r, sorts)) { - return 0; + return nullptr; } if (!p.is_ast() || !is_expr(p.get_ast())) { m_manager->raise_exception("ast expression expected to filter"); @@ -277,7 +277,7 @@ namespace datalog { // 2. the free variables in f correspond to column types of r. if (!m.is_bool(f)) { m_manager->raise_exception("filter predicate should be of Boolean type"); - return 0; + return nullptr; } ptr_vector todo; todo.push_back(f); @@ -295,11 +295,11 @@ namespace datalog { idx = to_var(e)->get_idx(); if (idx >= sorts.size()) { m_manager->raise_exception("illegal index"); - return 0; + return nullptr; } if (sorts[idx] != m.get_sort(e)) { m_manager->raise_exception("sort miss-match in filter"); - return 0; + return nullptr; } break; case AST_APP: @@ -309,10 +309,10 @@ namespace datalog { break; case AST_QUANTIFIER: m_manager->raise_exception("quantifiers are not allowed in filter expressions"); - return 0; + return nullptr; default: m_manager->raise_exception("unexpected filter expression kind"); - return 0; + return nullptr; } } func_decl_info info(m_family_id, OP_RA_FILTER, 1, &p); @@ -322,23 +322,23 @@ namespace datalog { func_decl * dl_decl_plugin::mk_rename(unsigned num_params, parameter const* params, sort* r) { ptr_vector sorts; if (!is_rel_sort(r, sorts)) { - return 0; + return nullptr; } unsigned index0 = 0; - sort* last_sort = 0; + sort* last_sort = nullptr; SASSERT(num_params > 0); for (unsigned i = 0; i < num_params; ++i) { parameter const& p = params[i]; if (!p.is_int()) { m_manager->raise_exception("expected integer parameter"); - return 0; + return nullptr; } unsigned j = p.get_int(); if (j >= sorts.size()) { // We should not use ast_pp anymore on error messages. // m_manager->raise_exception("index %d out of bound %s : %d", j, ast_pp(r, *m_manager).c_str(), sorts.size()); m_manager->raise_exception("index out of bound"); - return 0; + return nullptr; } if (i == 0) { index0 = j; @@ -362,10 +362,10 @@ namespace datalog { vector params2; ptr_vector sorts1, sorts2; if (!is_rel_sort(r1, sorts1)) { - return 0; + return nullptr; } if (!is_rel_sort(r2, sorts2)) { - return 0; + return nullptr; } for (unsigned i = 0; i < sorts1.size(); ++i) { params2.push_back(parameter(sorts1[i])); @@ -375,24 +375,24 @@ namespace datalog { } if (0 != num_params % 2) { m_manager->raise_exception("expecting an even number of parameters to join"); - return 0; + return nullptr; } for (unsigned i = 0; i + 1 < num_params; i += 2) { parameter const& p1 = params[i]; parameter const& p2 = params[i+1]; if (!p1.is_int() || !p2.is_int()) { m_manager->raise_exception("encountered non-integer parameter"); - return 0; + return nullptr; } unsigned i1 = p1.get_int(); unsigned i2 = p2.get_int(); if (i1 >= sorts1.size() || i2 >= sorts2.size()) { m_manager->raise_exception("index out of bounds"); - return 0; + return nullptr; } if (sorts1[i1] != sorts2[i2]) { m_manager->raise_exception("sort miss-match in join"); - return 0; + return nullptr; } } sort* args[2] = { r1, r2 }; @@ -403,40 +403,40 @@ namespace datalog { func_decl* dl_decl_plugin::mk_complement(sort* s) { if (!is_rel_sort(s)) { - return 0; + return nullptr; } - func_decl_info info(m_family_id, OP_RA_COMPLEMENT, 0, 0); + func_decl_info info(m_family_id, OP_RA_COMPLEMENT, 0, nullptr); return m_manager->mk_func_decl(m_complement_sym, 1, &s, s, info); } func_decl * dl_decl_plugin::mk_negation_filter(unsigned num_params, parameter const* params, sort* r1, sort* r2) { ptr_vector sorts1, sorts2; if (!is_rel_sort(r1, sorts1)) { - return 0; + return nullptr; } if (!is_rel_sort(r2, sorts2)) { - return 0; + return nullptr; } if (0 != num_params % 2) { m_manager->raise_exception("expecting an even number of parameters to negation filter"); - return 0; + return nullptr; } for (unsigned i = 0; i + 1 < num_params; i += 2) { parameter const& p1 = params[i]; parameter const& p2 = params[i+1]; if (!p1.is_int() || !p2.is_int()) { m_manager->raise_exception("encountered non-integer parameter"); - return 0; + return nullptr; } unsigned i1 = p1.get_int(); unsigned i2 = p2.get_int(); if (i1 >= sorts1.size() || i2 >= sorts2.size()) { m_manager->raise_exception("index out of bounds"); - return 0; + return nullptr; } if (sorts1[i1] != sorts2[i2]) { m_manager->raise_exception("sort miss-match in join"); - return 0; + return nullptr; } } sort* args[2] = { r1, r2 }; @@ -446,9 +446,9 @@ namespace datalog { func_decl * dl_decl_plugin::mk_is_empty(sort* s) { if (!is_rel_sort(s)) { - return 0; + return nullptr; } - func_decl_info info(m_family_id, OP_RA_IS_EMPTY, 0, 0); + func_decl_info info(m_family_id, OP_RA_IS_EMPTY, 0, nullptr); sort* rng = m_manager->mk_bool_sort(); return m_manager->mk_func_decl(m_is_empty_sym, 1, &s, rng, info); } @@ -458,35 +458,35 @@ namespace datalog { parameter const& ps = params[1]; if (!p.is_rational() || !p.get_rational().is_uint64()) { m_manager->raise_exception("first parameter should be a rational"); - return 0; + return nullptr; } if (!ps.is_ast() || !is_sort(ps.get_ast()) || !is_fin_sort(to_sort(ps.get_ast()))) { m_manager->raise_exception("second parameter should be a finite domain sort"); - return 0; + return nullptr; } sort* s = to_sort(ps.get_ast()); func_decl_info info(m_family_id, OP_DL_CONSTANT, 2, params); - return m_manager->mk_func_decl(m_num_sym, 0, (sort*const*)0, s, info); + return m_manager->mk_func_decl(m_num_sym, 0, (sort*const*)nullptr, s, info); } func_decl * dl_decl_plugin::mk_compare(decl_kind k, symbol const& sym, sort *const* domain) { if (!is_sort_of(domain[0], m_family_id, DL_FINITE_SORT)) { m_manager->raise_exception("expecting finite domain sort"); - return 0; + return nullptr; } if (domain[0] != domain[1]) { m_manager->raise_exception("expecting two identical finite domain sorts"); - return 0; + return nullptr; } - func_decl_info info(m_family_id, k, 0, 0); + func_decl_info info(m_family_id, k, 0, nullptr); return m_manager->mk_func_decl(sym, 2, domain, m_manager->mk_bool_sort(), info); } func_decl * dl_decl_plugin::mk_clone(sort* s) { if (!is_rel_sort(s)) { - return 0; + return nullptr; } - func_decl_info info(m_family_id, OP_RA_CLONE, 0, 0); + func_decl_info info(m_family_id, OP_RA_CLONE, 0, nullptr); return m_manager->mk_func_decl(m_clone_sym, 1, &s, s, info); } @@ -494,14 +494,14 @@ namespace datalog { func_decl * dl_decl_plugin::mk_func_decl( decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned arity, sort * const * domain, sort * range) { - func_decl* result = 0; + func_decl* result = nullptr; switch(k) { case OP_RA_STORE: case OP_RA_SELECT: if (!check_params(0, 0, num_parameters) || !check_domain(1, UINT_MAX, arity)) { - return 0; + return nullptr; } result = mk_store_select(k, arity, domain); break; @@ -509,7 +509,7 @@ namespace datalog { case OP_RA_EMPTY: if (!check_params( 1, 1, num_parameters) || !check_domain(0, 0, arity)) { - return 0; + return nullptr; } result = mk_empty(parameters[0]); break; @@ -517,7 +517,7 @@ namespace datalog { case OP_RA_JOIN: if (!check_params(0, UINT_MAX, num_parameters) || !check_domain(2, 2, arity)) { - return 0; + return nullptr; } result = mk_join(num_parameters, parameters, domain[0], domain[1]); break; @@ -526,7 +526,7 @@ namespace datalog { case OP_RA_WIDEN: if (!check_params( 0, 0, num_parameters) || !check_domain(2, 2, arity)) { - return 0; + return nullptr; } result = mk_unionw(k, domain[0], domain[1]); break; @@ -534,7 +534,7 @@ namespace datalog { case OP_RA_PROJECT: if (!check_params( 1, UINT_MAX, num_parameters) || !check_domain(1, 1, arity)) { - return 0; + return nullptr; } result = mk_project(num_parameters, parameters, domain[0]); break; @@ -542,7 +542,7 @@ namespace datalog { case OP_RA_FILTER: if (!check_params( 1, 1, num_parameters) || !check_domain(1, 1, arity)) { - return 0; + return nullptr; } result = mk_filter(parameters[0], domain[0]); break; @@ -550,7 +550,7 @@ namespace datalog { case OP_RA_IS_EMPTY: if (!check_params( 0, 0, num_parameters) || !check_domain(1, 1, arity)) { - return 0; + return nullptr; } result = mk_is_empty(domain[0]); break; @@ -558,7 +558,7 @@ namespace datalog { case OP_RA_RENAME: if (!check_params( 2, UINT_MAX, num_parameters) || !check_domain(1, 1, arity)) { - return 0; + return nullptr; } result = mk_rename(num_parameters, parameters, domain[0]); break; @@ -566,7 +566,7 @@ namespace datalog { case OP_RA_COMPLEMENT: if (!check_params( 0, 0, num_parameters) || !check_domain(1, 1, arity)) { - return 0; + return nullptr; } result = mk_complement(domain[0]); break; @@ -574,14 +574,14 @@ namespace datalog { case OP_RA_NEGATION_FILTER: if (!check_params(1, UINT_MAX, num_parameters) || !check_domain(2, 2, arity)) { - return 0; + return nullptr; } result = mk_negation_filter(num_parameters, parameters, domain[0], domain[1]); break; case OP_RA_CLONE: if (!check_params(0, 0, num_parameters) || !check_domain(1, 1, arity)) { - return 0; + return nullptr; } result = mk_clone(domain[0]); break; @@ -589,7 +589,7 @@ namespace datalog { case OP_DL_CONSTANT: if (!check_params( 2, 2, num_parameters) || !check_domain(0, 0, arity)) { - return 0; + return nullptr; } result = mk_constant(parameters); break; @@ -597,23 +597,23 @@ namespace datalog { case OP_DL_LT: if (!check_params( 0, 0, num_parameters) || !check_domain(2, 2, arity)) { - return 0; + return nullptr; } result = mk_compare(OP_DL_LT, m_lt_sym, domain); break; case OP_DL_REP: { if (!check_domain(0, 0, num_parameters) || - !check_domain(1, 1, arity)) return 0; - func_decl_info info(m_family_id, k, 0, 0); + !check_domain(1, 1, arity)) return nullptr; + func_decl_info info(m_family_id, k, 0, nullptr); result = m_manager->mk_func_decl(symbol("rep"), 1, domain, range, info); break; } case OP_DL_ABS: { if (!check_domain(0, 0, num_parameters) || - !check_domain(1, 1, arity)) return 0; - func_decl_info info(m_family_id, k, 0, 0); + !check_domain(1, 1, arity)) return nullptr; + func_decl_info info(m_family_id, k, 0, nullptr); result = m_manager->mk_func_decl(symbol("abs"), 1, domain, range, info); break; } @@ -621,7 +621,7 @@ namespace datalog { default: m_manager->raise_exception("operator not recognized"); - return 0; + return nullptr; } TRACE("dl_decl_plugin", tout << mk_pp(result, *m_manager) << "\n";); @@ -659,7 +659,7 @@ namespace datalog { m.raise_exception("value is out of bounds"); } parameter params[2] = { parameter(rational(value, rational::ui64())), parameter(s) }; - return m.mk_const(m.mk_func_decl(m_fid, OP_DL_CONSTANT, 2, params, 0, (sort*const*)0)); + return m.mk_const(m.mk_func_decl(m_fid, OP_DL_CONSTANT, 2, params, 0, (sort*const*)nullptr)); } if (m_arith.is_int(s) || m_arith.is_real(s)) { return m_arith.mk_numeral(rational(value, rational::ui64()), s); @@ -677,7 +677,7 @@ namespace datalog { std::stringstream strm; strm << "sort '" << mk_pp(s, m) << "' is not recognized as a sort that contains numeric values.\nUse Bool, BitVec, Int, Real, or a Finite domain sort"; m.raise_exception(strm.str().c_str()); - return 0; + return nullptr; } bool dl_decl_util::is_numeral(const expr* e, uint64& v) const { @@ -745,12 +745,12 @@ namespace datalog { app* dl_decl_util::mk_lt(expr* a, expr* b) { expr* args[2] = { a, b }; - return m.mk_app(m_fid, OP_DL_LT, 0, 0, 2, args); + return m.mk_app(m_fid, OP_DL_LT, 0, nullptr, 2, args); } app* dl_decl_util::mk_le(expr* a, expr* b) { expr* args[2] = { b, a }; - return m.mk_not(m.mk_app(m_fid, OP_DL_LT, 0, 0, 2, args)); + return m.mk_not(m.mk_app(m_fid, OP_DL_LT, 0, nullptr, 2, args)); } sort* dl_decl_util::mk_rule_sort() { diff --git a/src/ast/dl_decl_plugin.h b/src/ast/dl_decl_plugin.h index 2c68cc12c..03b9d1fd8 100644 --- a/src/ast/dl_decl_plugin.h +++ b/src/ast/dl_decl_plugin.h @@ -204,9 +204,9 @@ namespace datalog { sort* mk_rule_sort(); - app* mk_rule(symbol const& name, unsigned num_args = 0, expr* const* args = 0); + app* mk_rule(symbol const& name, unsigned num_args = 0, expr* const* args = nullptr); - app* mk_fact(symbol const& name) { return mk_rule(name, 0, 0); } + app* mk_fact(symbol const& name) { return mk_rule(name, 0, nullptr); } ast_manager& get_manager() const { return m; } diff --git a/src/ast/expr2polynomial.cpp b/src/ast/expr2polynomial.cpp index 7413624cd..280d7487a 100644 --- a/src/ast/expr2polynomial.cpp +++ b/src/ast/expr2polynomial.cpp @@ -29,7 +29,7 @@ struct expr2polynomial::imp { struct frame { app * m_curr; unsigned m_idx; - frame():m_curr(0), m_idx(0) {} + frame():m_curr(nullptr), m_idx(0) {} frame(app * t):m_curr(t), m_idx(0) {} }; @@ -59,8 +59,8 @@ struct expr2polynomial::imp { m_am(am), m_autil(am), m_pm(pm), - m_expr2var(e2v == 0 && !use_var_idxs ? alloc(expr2var, am) : e2v), - m_expr2var_owner(e2v == 0 && !use_var_idxs), + m_expr2var(e2v == nullptr && !use_var_idxs ? alloc(expr2var, am) : e2v), + m_expr2var_owner(e2v == nullptr && !use_var_idxs), m_var2expr(am), m_cached_domain(am), m_cached_polynomials(pm), @@ -156,7 +156,7 @@ struct expr2polynomial::imp { x = m_wrapper.mk_var(is_int); m_expr2var->insert(t, x); if (x >= m_var2expr.size()) - m_var2expr.resize(x+1, 0); + m_var2expr.resize(x+1, nullptr); m_var2expr.set(x, t); } } @@ -502,7 +502,7 @@ void expr2polynomial::set_cancel(bool f) { } default_expr2polynomial::default_expr2polynomial(ast_manager & am, polynomial::manager & pm): - expr2polynomial(am, pm, 0) { + expr2polynomial(am, pm, nullptr) { } default_expr2polynomial::~default_expr2polynomial() { diff --git a/src/ast/expr2var.cpp b/src/ast/expr2var.cpp index 2f850d645..c6b4257a0 100644 --- a/src/ast/expr2var.cpp +++ b/src/ast/expr2var.cpp @@ -64,7 +64,7 @@ void expr2var::mk_inv(expr_ref_vector & var2expr) const { expr * t = it->m_key; var x = it->m_value; if (x >= var2expr.size()) - var2expr.resize(x+1, 0); + var2expr.resize(x+1, nullptr); var2expr.set(x, t); } } diff --git a/src/ast/expr_abstract.cpp b/src/ast/expr_abstract.cpp index 43035e203..c45e445fd 100644 --- a/src/ast/expr_abstract.cpp +++ b/src/ast/expr_abstract.cpp @@ -27,7 +27,7 @@ void expr_abstractor::operator()(unsigned base, unsigned num_bound, expr* const* result = n; return; } - expr * curr = 0, *b = 0; + expr * curr = nullptr, *b = nullptr; SASSERT(n->get_ref_count() > 0); m_stack.push_back(n); diff --git a/src/ast/expr_delta_pair.h b/src/ast/expr_delta_pair.h index f4cc40ae4..f40f4cbe8 100644 --- a/src/ast/expr_delta_pair.h +++ b/src/ast/expr_delta_pair.h @@ -26,7 +26,7 @@ struct expr_delta_pair { expr * m_node; unsigned m_delta; - expr_delta_pair():m_node(0), m_delta(0) {} + expr_delta_pair():m_node(nullptr), m_delta(0) {} expr_delta_pair(expr * n, unsigned d):m_node(n), m_delta(d) {} unsigned hash() const { return hash_u_u(m_node->hash(), m_delta); } bool operator==(const expr_delta_pair & e) const { return m_node == e.m_node && m_delta == e.m_delta; } diff --git a/src/ast/expr_functors.cpp b/src/ast/expr_functors.cpp index 4906ed3d7..cada71ac9 100644 --- a/src/ast/expr_functors.cpp +++ b/src/ast/expr_functors.cpp @@ -121,22 +121,22 @@ void map_proc::reconstruct(app* a) { } if (is_new) { expr* b = m.mk_app(a->get_decl(), m_args.size(), m_args.c_ptr()); - m_map.insert(a, b, 0); + m_map.insert(a, b, nullptr); } else { - m_map.insert(a, a, 0); + m_map.insert(a, a, nullptr); } } void map_proc::visit(quantifier* e) { expr_ref q(m); q = m.update_quantifier(e, get_expr(e->get_expr())); - m_map.insert(e, q, 0); + m_map.insert(e, q, nullptr); } expr* map_proc::get_expr(expr* e) { - expr* result = 0; - proof* p = 0; + expr* result = nullptr; + proof* p = nullptr; m_map.get(e, result, p); return result; } diff --git a/src/ast/expr_functors.h b/src/ast/expr_functors.h index 3d66a69ae..5a4cac477 100644 --- a/src/ast/expr_functors.h +++ b/src/ast/expr_functors.h @@ -115,7 +115,7 @@ public: void reset() { m_map.reset(); } - void visit(var* e) { m_map.insert(e, e, 0); } + void visit(var* e) { m_map.insert(e, e, nullptr); } void visit(quantifier* e); diff --git a/src/ast/expr_map.cpp b/src/ast/expr_map.cpp index 89fcccb00..a9b32f906 100644 --- a/src/ast/expr_map.cpp +++ b/src/ast/expr_map.cpp @@ -38,7 +38,7 @@ expr_map::~expr_map() { void expr_map::insert(expr * k, expr * d, proof * p) { m_manager.inc_ref(d); obj_map::obj_map_entry * entry = m_expr2expr.find_core(k); - if (entry != 0) { + if (entry != nullptr) { m_manager.dec_ref(entry->get_data().m_value); entry->get_data().m_value = d; if (m_store_proofs) { @@ -61,7 +61,7 @@ void expr_map::insert(expr * k, expr * d, proof * p) { void expr_map::get(expr * k, expr * & d, proof * & p) const { if (m_expr2expr.find(k, d)) { - p = 0; + p = nullptr; if (m_store_proofs) m_expr2pr.find(k, p); } @@ -73,7 +73,7 @@ void expr_map::erase(expr * k) { m_expr2expr.erase(k); m_manager.dec_ref(v); if (m_store_proofs) { - proof * pr = 0; + proof * pr = nullptr; m_expr2pr.find(k, pr); m_expr2pr.erase(k); m_manager.dec_ref(pr); diff --git a/src/ast/expr_substitution.cpp b/src/ast/expr_substitution.cpp index f9333c443..e8d75f461 100644 --- a/src/ast/expr_substitution.cpp +++ b/src/ast/expr_substitution.cpp @@ -106,20 +106,20 @@ void expr_substitution::insert(expr * c, expr * def, proof * def_pr, expr_depend void expr_substitution::erase(expr * c) { if (proofs_enabled()) { - proof * pr = 0; + proof * pr = nullptr; if (m_subst_pr->find(c, pr)) { m_manager.dec_ref(pr); m_subst_pr->erase(c); } } if (unsat_core_enabled()) { - expr_dependency * dep = 0; + expr_dependency * dep = nullptr; if (m_subst_dep->find(c, dep)) { m_manager.dec_ref(dep); m_subst_dep->erase(c); } } - expr * def = 0; + expr * def = nullptr; if (m_subst.find(c, def)) { m_manager.dec_ref(c); m_manager.dec_ref(def); diff --git a/src/ast/expr_substitution.h b/src/ast/expr_substitution.h index 1590f888c..cbe00433c 100644 --- a/src/ast/expr_substitution.h +++ b/src/ast/expr_substitution.h @@ -43,7 +43,7 @@ public: bool unsat_core_enabled() const { return m_cores_enabled; } bool empty() const { return m_subst.empty(); } - void insert(expr * s, expr * def, proof * def_pr = 0, expr_dependency * def_dep = 0); + void insert(expr * s, expr * def, proof * def_pr = nullptr, expr_dependency * def_dep = nullptr); void erase(expr * s); bool find(expr * s, expr * & def, proof * & def_pr); bool find(expr * s, expr * & def, proof * & def_pr, expr_dependency * & def_dep); @@ -63,7 +63,7 @@ public: scoped_expr_substitution(expr_substitution& s): m_subst(s), m_trail(s.m()) {} ~scoped_expr_substitution() {} - void insert(expr * s, expr * def, proof * def_pr = 0, expr_dependency * def_dep = 0) { + void insert(expr * s, expr * def, proof * def_pr = nullptr, expr_dependency * def_dep = nullptr) { if (!m_subst.contains(s)) { m_subst.insert(s, def, def_pr, def_dep); m_trail.push_back(s); @@ -82,7 +82,7 @@ public: } unsigned scope_level() const { return m_trail_lim.size(); } bool empty() const { return m_subst.empty(); } - expr* find(expr * e) { proof* pr; expr* d = 0; if (find(e, d, pr)) return d; else return e; } + expr* find(expr * e) { proof* pr; expr* d = nullptr; if (find(e, d, pr)) return d; else return e; } bool find(expr * s, expr * & def, proof * & def_pr) { return m_subst.find(s, def, def_pr); } bool find(expr * s, expr * & def, proof * & def_pr, expr_dependency * & def_dep) { return m_subst.find(s, def, def_pr, def_dep); } bool contains(expr * s) { return m_subst.contains(s); } diff --git a/src/ast/factor_equivs.cpp b/src/ast/factor_equivs.cpp index bbb21c1b2..c33b3a18e 100644 --- a/src/ast/factor_equivs.cpp +++ b/src/ast/factor_equivs.cpp @@ -34,7 +34,7 @@ Revision History: void factor_eqs(expr_ref_vector &v, expr_equiv_class &equiv) { ast_manager &m = v.get_manager(); arith_util arith(m); - expr *e1 = 0, *e2 = 0; + expr *e1 = nullptr, *e2 = nullptr; flatten_and(v); unsigned j = 0; @@ -45,7 +45,7 @@ void factor_eqs(expr_ref_vector &v, expr_equiv_class &equiv) { } // y + -1*x == 0 - expr* a0 = 0, *a1 = 0, *x = 0; + expr* a0 = nullptr, *a1 = nullptr, *x = nullptr; if (arith.is_zero(e2) && arith.is_add(e1, a0, a1)) { if (arith.is_times_minus_one(a1, x)) { e1 = a0; diff --git a/src/ast/format.cpp b/src/ast/format.cpp index 3013e3e40..40df437ea 100644 --- a/src/ast/format.cpp +++ b/src/ast/format.cpp @@ -42,7 +42,7 @@ namespace format_ns { public: format_decl_plugin(): - m_format_sort(0), + m_format_sort(nullptr), m_nil("nil"), m_string("string"), m_indent("indent"), @@ -94,7 +94,7 @@ namespace format_ns { return m_manager->mk_func_decl(m_line_break_ext, arity, domain, m_format_sort, func_decl_info(m_family_id, OP_LINE_BREAK_EXT, num_parameters, parameters)); default: - return 0; + return nullptr; } } }; @@ -124,8 +124,8 @@ namespace format_ns { SASSERT(m_manager.is_format_manager()); } - format * visit(var *) { UNREACHABLE(); return 0; } - format * visit(quantifier * q, format *, format * const *, format * const *) { UNREACHABLE(); return 0; } + format * visit(var *) { UNREACHABLE(); return nullptr; } + format * visit(quantifier * q, format *, format * const *, format * const *) { UNREACHABLE(); return nullptr; } format * visit(format * n, format * const * children) { if (is_app_of(n, m_fid, OP_LINE_BREAK)) return mk_string(m_manager, " "); @@ -147,7 +147,7 @@ namespace format_ns { format * mk_string(ast_manager & m, char const * str) { symbol s(str); parameter p(s); - return fm(m).mk_app(fid(m), OP_STRING, 1, &p, 0, 0); + return fm(m).mk_app(fid(m), OP_STRING, 1, &p, 0, nullptr); } format * mk_int(ast_manager & m, int i) { diff --git a/src/ast/fpa/bv2fpa_converter.cpp b/src/ast/fpa/bv2fpa_converter.cpp index d87929864..ede6e43f3 100644 --- a/src/ast/fpa/bv2fpa_converter.cpp +++ b/src/ast/fpa/bv2fpa_converter.cpp @@ -198,7 +198,7 @@ expr_ref bv2fpa_converter::rebuild_floats(model_core * mc, sort * s, app * e) { tout << std::endl; ); if (m_fpa_util.is_float(s)) { - if (e == 0) + if (e == nullptr) result = m_fpa_util.mk_pzero(s); else if (m_fpa_util.is_numeral(e)) result = e; @@ -208,7 +208,7 @@ expr_ref bv2fpa_converter::rebuild_floats(model_core * mc, sort * s, app * e) { } } else if (m_fpa_util.is_rm(s)) { - if (e == 0) + if (e == nullptr) result = m_fpa_util.mk_round_toward_zero(); else if (m_fpa_util.is_rm_numeral(e)) result = e; @@ -256,7 +256,7 @@ bv2fpa_converter::array_model bv2fpa_converter::convert_array_func_interp(model_ func_interp * bv2fpa_converter::convert_func_interp(model_core * mc, func_decl * f, func_decl * bv_f) { SASSERT(f->get_arity() > 0); - func_interp * result = 0; + func_interp * result = nullptr; sort * rng = f->get_range(); sort * const * dmn = f->get_domain(); @@ -291,7 +291,7 @@ func_interp * bv2fpa_converter::convert_func_interp(model_core * mc, func_decl * mk_ismt2_pp(new_args[i], m) << std::endl; tout << mk_ismt2_pp(bv_fres, m) << " == " << mk_ismt2_pp(ft_fres, m) << std::endl;); func_entry * fe = result->get_entry(new_args.c_ptr()); - if (fe == 0) + if (fe == nullptr) result->insert_new_entry(new_args.c_ptr(), ft_fres); else { // The BV model may have multiple equivalent entries using different @@ -338,7 +338,7 @@ void bv2fpa_converter::convert_consts(model_core * mc, model_core * target_model v2 = mc->get_const_interp(a2->get_decl()); #else expr * bv = mc->get_const_interp(to_app(to_app(a0)->get_arg(0))->get_decl()); - if (bv == 0) { + if (bv == nullptr) { v0 = m_bv_util.mk_numeral(0, 1); v1 = m_bv_util.mk_numeral(0, ebits); v2 = m_bv_util.mk_numeral(0, sbits-1); @@ -477,7 +477,7 @@ void bv2fpa_converter::convert_uf2bvuf(model_core * mc, model_core * target_mode fmv->set_else(m.mk_app(it->m_key, n, args.c_ptr())); #else - fmv->set_else(0); + fmv->set_else(nullptr); #endif target_model->register_decl(f, fmv); } diff --git a/src/ast/fpa/bv2fpa_converter.h b/src/ast/fpa/bv2fpa_converter.h index caf36c1fc..3cb7f4c63 100644 --- a/src/ast/fpa/bv2fpa_converter.h +++ b/src/ast/fpa/bv2fpa_converter.h @@ -64,7 +64,7 @@ public: func_interp * new_float_fi; func_decl * bv_fd; expr_ref result; - array_model(ast_manager & m) : new_float_fd(0), new_float_fi(0), bv_fd(0), result(m) {} + array_model(ast_manager & m) : new_float_fd(nullptr), new_float_fi(nullptr), bv_fd(nullptr), result(m) {} }; array_model convert_array_func_interp(model_core * mc, func_decl * f, func_decl * bv_f); diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp index df5d56505..5e7db2ca9 100644 --- a/src/ast/fpa/fpa2bv_converter.cpp +++ b/src/ast/fpa/fpa2bv_converter.cpp @@ -197,7 +197,7 @@ void fpa2bv_converter::mk_const(func_decl * f, expr_ref & result) { #else app_ref bv(m); unsigned bv_sz = 1 + ebits + (sbits - 1); - bv = mk_fresh_const(0, bv_sz); + bv = mk_fresh_const(nullptr, bv_sz); sgn = m_bv_util.mk_extract(bv_sz - 1, bv_sz - 1, bv); e = m_bv_util.mk_extract(bv_sz - 2, sbits - 1, bv); @@ -288,7 +288,7 @@ void fpa2bv_converter::mk_rm_const(func_decl * f, expr_ref & result) { #ifdef Z3DEBUG "fpa2bv_rm" #else - 0 + nullptr #endif , m_bv_util.mk_sort(3)); @@ -1274,8 +1274,8 @@ expr_ref fpa2bv_converter::mk_min_max_unspecified(func_decl * f, expr * x, expr std::pair decls(0, 0); if (!m_min_max_ufs.find(f, decls)) { - decls.first = m.mk_fresh_const(0, m_bv_util.mk_sort(1)); - decls.second = m.mk_fresh_const(0, m_bv_util.mk_sort(1)); + decls.first = m.mk_fresh_const(nullptr, m_bv_util.mk_sort(1)); + decls.second = m.mk_fresh_const(nullptr, m_bv_util.mk_sort(1)); m_min_max_ufs.insert(f, decls); m.inc_ref(f); m.inc_ref(decls.first); @@ -2681,11 +2681,11 @@ void fpa2bv_converter::mk_to_fp_real_int(func_decl * f, unsigned num, expr * con a_tz = m_plugin->mk_numeral(tz); expr_ref bv_nte(m), bv_nta(m), bv_tp(m), bv_tn(m), bv_tz(m); - mk_numeral(a_nte->get_decl(), 0, 0, bv_nte); - mk_numeral(a_nta->get_decl(), 0, 0, bv_nta); - mk_numeral(a_tp->get_decl(), 0, 0, bv_tp); - mk_numeral(a_tn->get_decl(), 0, 0, bv_tn); - mk_numeral(a_tz->get_decl(), 0, 0, bv_tz); + mk_numeral(a_nte->get_decl(), 0, nullptr, bv_nte); + mk_numeral(a_nta->get_decl(), 0, nullptr, bv_nta); + mk_numeral(a_tp->get_decl(), 0, nullptr, bv_tp); + mk_numeral(a_tn->get_decl(), 0, nullptr, bv_tn); + mk_numeral(a_tz->get_decl(), 0, nullptr, bv_tz); expr_ref c1(m), c2(m), c3(m), c4(m); c1 = m.mk_eq(bv_rm, m_bv_util.mk_numeral(BV_RM_TO_POSITIVE, 3)); @@ -4103,7 +4103,7 @@ void fpa2bv_converter::reset(void) { func_decl * fpa2bv_converter::mk_bv_uf(func_decl * f, sort * const * domain, sort * range) { func_decl * res; if (!m_uf2bvuf.find(f, res)) { - res = m.mk_fresh_func_decl(0, f->get_arity(), domain, range); + res = m.mk_fresh_func_decl(nullptr, f->get_arity(), domain, range); m_uf2bvuf.insert(f, res); m.inc_ref(f); m.inc_ref(res); diff --git a/src/ast/fpa/fpa2bv_rewriter.cpp b/src/ast/fpa/fpa2bv_rewriter.cpp index 6c96d92c1..2ddc69aaf 100644 --- a/src/ast/fpa/fpa2bv_rewriter.cpp +++ b/src/ast/fpa/fpa2bv_rewriter.cpp @@ -220,7 +220,7 @@ bool fpa2bv_rewriter_cfg::reduce_quantifier(quantifier * old_q, result = m().mk_quantifier(old_q->is_forall(), new_decl_sorts.size(), new_decl_sorts.c_ptr(), new_decl_names.c_ptr(), new_body, old_q->get_weight(), old_q->get_qid(), old_q->get_skid(), old_q->get_num_patterns(), new_patterns, old_q->get_num_no_patterns(), new_no_patterns); - result_pr = 0; + result_pr = nullptr; m_bindings.shrink(old_sz); TRACE("fpa2bv", tout << "reduce_quantifier[" << old_q->get_depth() << "]: " << mk_ismt2_pp(old_q->get_expr(), m()) << std::endl << @@ -249,7 +249,7 @@ bool fpa2bv_rewriter_cfg::reduce_var(var * t, expr_ref & result, proof_ref & res new_exp = m().mk_var(t->get_idx(), s); result = new_exp; - result_pr = 0; + result_pr = nullptr; TRACE("fpa2bv", tout << "reduce_var: " << mk_ismt2_pp(t, m()) << " -> " << mk_ismt2_pp(result, m()) << std::endl;); return true; } diff --git a/src/ast/fpa_decl_plugin.cpp b/src/ast/fpa_decl_plugin.cpp index 9d298b413..419175a7f 100644 --- a/src/ast/fpa_decl_plugin.cpp +++ b/src/ast/fpa_decl_plugin.cpp @@ -23,9 +23,9 @@ Revision History: fpa_decl_plugin::fpa_decl_plugin(): m_values(m_fm), m_value_table(mpf_hash_proc(m_values), mpf_eq_proc(m_values)) { - m_real_sort = 0; - m_int_sort = 0; - m_bv_plugin = 0; + m_real_sort = nullptr; + m_int_sort = nullptr; + m_bv_plugin = nullptr; } void fpa_decl_plugin::set_manager(ast_manager * m, family_id id) { @@ -70,7 +70,7 @@ void fpa_decl_plugin::recycled_id(unsigned id) { func_decl * fpa_decl_plugin::mk_numeral_decl(mpf const & v) { sort * s = mk_float_sort(v.get_ebits(), v.get_sbits()); - func_decl * r = 0; + func_decl * r = nullptr; if (m_fm.is_nan(v)) r = m_manager->mk_const_decl(symbol("NaN"), s, func_decl_info(m_family_id, OP_FPA_NAN)); else if (m_fm.is_pinf(v)) @@ -223,7 +223,7 @@ sort * fpa_decl_plugin::mk_sort(decl_kind k, unsigned num_parameters, parameter return mk_float_sort(15, 113); default: m_manager->raise_exception("unknown floating point theory sort"); - return 0; + return nullptr; } } @@ -248,20 +248,20 @@ func_decl * fpa_decl_plugin::mk_rm_const_decl(decl_kind k, unsigned num_paramete return m_manager->mk_const_decl(symbol("roundTowardZero"), s, finfo); default: UNREACHABLE(); - return 0; + return nullptr; } } func_decl * fpa_decl_plugin::mk_float_const_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned arity, sort * const * domain, sort * range) { - sort * s = 0; + sort * s = nullptr; if (num_parameters == 1 && parameters[0].is_ast() && is_sort(parameters[0].get_ast()) && is_float_sort(to_sort(parameters[0].get_ast()))) { s = to_sort(parameters[0].get_ast()); } else if (num_parameters == 2 && parameters[0].is_int() && parameters[1].is_int()) { s = mk_float_sort(parameters[0].get_int(), parameters[1].get_int()); } - else if (range != 0 && is_float_sort(range)) { + else if (range != nullptr && is_float_sort(range)) { s = range; } else { @@ -561,7 +561,7 @@ func_decl * fpa_decl_plugin::mk_to_fp(decl_kind k, unsigned num_parameters, para ); } - return 0; + return nullptr; } func_decl * fpa_decl_plugin::mk_to_fp_unsigned(decl_kind k, unsigned num_parameters, parameter const * parameters, @@ -779,7 +779,7 @@ func_decl * fpa_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, default: m_manager->raise_exception("unsupported floating point operator"); - return 0; + return nullptr; } } @@ -862,12 +862,12 @@ expr * fpa_decl_plugin::get_some_value(sort * s) { return res; } else if (s->is_sort_of(m_family_id, ROUNDING_MODE_SORT)) { - func_decl * f = mk_rm_const_decl(OP_FPA_RM_TOWARD_ZERO, 0, 0, 0, 0, s); + func_decl * f = mk_rm_const_decl(OP_FPA_RM_TOWARD_ZERO, 0, nullptr, 0, nullptr, s); return m_manager->mk_const(f); } UNREACHABLE(); - return 0; + return nullptr; } bool fpa_decl_plugin::is_value(app * e) const { diff --git a/src/ast/fpa_decl_plugin.h b/src/ast/fpa_decl_plugin.h index 4d0accfbb..c914bb6c7 100644 --- a/src/ast/fpa_decl_plugin.h +++ b/src/ast/fpa_decl_plugin.h @@ -342,7 +342,7 @@ public: app * mk_bv2rm(expr * bv3) { SASSERT(m_bv_util.is_bv(bv3) && m_bv_util.get_bv_size(bv3) == 3); - return m().mk_app(m_fid, OP_FPA_BV2RM, 0, 0, 1, &bv3, mk_rm_sort()); + return m().mk_app(m_fid, OP_FPA_BV2RM, 0, nullptr, 1, &bv3, mk_rm_sort()); } bool is_bvwrap(expr const * e) const { return is_app_of(e, get_family_id(), OP_FPA_BVWRAP); } diff --git a/src/ast/func_decl_dependencies.cpp b/src/ast/func_decl_dependencies.cpp index a5412f206..2a69f4514 100644 --- a/src/ast/func_decl_dependencies.cpp +++ b/src/ast/func_decl_dependencies.cpp @@ -86,7 +86,7 @@ class func_decl_dependencies::top_sort { ptr_vector m_todo; func_decl_set * definition(func_decl * f) const { - func_decl_set * r = 0; + func_decl_set * r = nullptr; m_deps.find(f, r); return r; } @@ -210,7 +210,7 @@ bool func_decl_dependencies::insert(func_decl * f, func_decl_set * s) { } void func_decl_dependencies::erase(func_decl * f) { - func_decl_set * s = 0; + func_decl_set * s = nullptr; if (m_deps.find(f, s)) { m_manager.dec_ref(f); dec_ref(m_manager, *s); diff --git a/src/ast/func_decl_dependencies.h b/src/ast/func_decl_dependencies.h index 0a3c1892f..b813dc31f 100644 --- a/src/ast/func_decl_dependencies.h +++ b/src/ast/func_decl_dependencies.h @@ -96,7 +96,7 @@ public: */ bool contains(func_decl * f) const { return m_deps.contains(f); } - func_decl_set * get_dependencies(func_decl * f) const { func_decl_set * r = 0; m_deps.find(f, r); return r; } + func_decl_set * get_dependencies(func_decl * f) const { func_decl_set * r = nullptr; m_deps.find(f, r); return r; } /** \brief Erase \c f (and its dependencies) from the manager. diff --git a/src/ast/macro_substitution.cpp b/src/ast/macro_substitution.cpp index 7b4cd6244..a51e1a066 100644 --- a/src/ast/macro_substitution.cpp +++ b/src/ast/macro_substitution.cpp @@ -123,20 +123,20 @@ void macro_substitution::insert(func_decl * f, quantifier * q, proof * pr, expr_ void macro_substitution::erase(func_decl * f) { if (proofs_enabled()) { - proof * pr = 0; + proof * pr = nullptr; if (m_decl2macro_pr->find(f, pr)) { m_manager.dec_ref(pr); m_decl2macro_pr->erase(f); } } if (unsat_core_enabled()) { - expr_dependency * dep = 0; + expr_dependency * dep = nullptr; if (m_decl2macro_dep->find(f, dep)) { m_manager.dec_ref(dep); m_decl2macro_dep->erase(f); } } - quantifier * q = 0; + quantifier * q = nullptr; if (m_decl2macro.find(f, q)) { m_manager.dec_ref(f); m_manager.dec_ref(q); diff --git a/src/ast/macro_substitution.h b/src/ast/macro_substitution.h index 7c65421fd..e028dcef8 100644 --- a/src/ast/macro_substitution.h +++ b/src/ast/macro_substitution.h @@ -45,7 +45,7 @@ public: bool empty() const { return m_decl2macro.empty(); } - void insert(func_decl * f, quantifier * m, proof * pr, expr_dependency * dep = 0); + void insert(func_decl * f, quantifier * m, proof * pr, expr_dependency * dep = nullptr); void erase(func_decl * f); bool contains(func_decl * f) { return m_decl2macro.contains(f); } bool find(func_decl * f, quantifier * & q, proof * & pr); diff --git a/src/ast/macros/macro_finder.cpp b/src/ast/macros/macro_finder.cpp index ed067f331..5a46da65a 100644 --- a/src/ast/macros/macro_finder.cpp +++ b/src/ast/macros/macro_finder.cpp @@ -71,7 +71,7 @@ bool macro_finder::is_arith_macro(expr * n, proof * pr, expr_dependency * dep, e quantifier_ref new_q(m); new_q = m.update_quantifier(to_quantifier(n), new_body); - proof * new_pr = 0; + proof * new_pr = nullptr; if (m.proofs_enabled()) { proof * rw = m.mk_rewrite(n, new_q); new_pr = m.mk_modus_ponens(pr, rw); @@ -142,7 +142,7 @@ bool macro_finder::is_arith_macro(expr * n, proof * pr, vector& quantifier_ref new_q(m); new_q = m.update_quantifier(to_quantifier(n), new_body); - proof * new_pr = 0; + proof * new_pr = nullptr; if (m.proofs_enabled()) { proof * rw = m.mk_rewrite(n, new_q); new_pr = m.mk_modus_ponens(pr, rw); @@ -163,7 +163,7 @@ bool macro_finder::is_arith_macro(expr * n, proof * pr, vector& quantifier * q1 = m.update_quantifier(new_q, body1); expr * patterns[1] = { m.mk_pattern(k_app) }; quantifier * q2 = m.update_quantifier(new_q, 1, patterns, body2); - proof* pr1 = 0, *pr2 = 0; + proof* pr1 = nullptr, *pr2 = nullptr; if (m.proofs_enabled()) { // new_pr : new_q // rw : [rewrite] new_q ~ q1 & q2 @@ -233,7 +233,7 @@ static void pseudo_predicate_macro2macro(ast_manager & m, app * head, app * t, e app * body_1 = m.mk_eq(head, ite); app * body_2 = m.mk_not(m.mk_eq(k_app, t)); quantifier * q1 = m.update_quantifier(q, body_1); - proof * pr1 = 0, *pr2 = 0; + proof * pr1 = nullptr, *pr2 = nullptr; expr * pats[1] = { m.mk_pattern(k_app) }; quantifier * q2 = m.update_quantifier(q, 1, pats, body_2); // erase patterns if (m.proofs_enabled()) { @@ -268,8 +268,8 @@ bool macro_finder::expand_macros(unsigned num, expr * const * exprs, proof * con bool found_new_macro = false; for (unsigned i = 0; i < num; i++) { expr * n = exprs[i]; - proof * pr = m.proofs_enabled() ? prs[i] : 0; - expr_dependency * depi = deps != 0 ? deps[i] : 0; + proof * pr = m.proofs_enabled() ? prs[i] : nullptr; + expr_dependency * depi = deps != nullptr ? deps[i] : nullptr; expr_ref new_n(m), def(m); proof_ref new_pr(m); expr_dependency_ref new_dep(m); @@ -292,7 +292,7 @@ bool macro_finder::expand_macros(unsigned num, expr * const * exprs, proof * con new_exprs.push_back(new_n); if (m.proofs_enabled()) new_prs.push_back(new_pr); - if (deps != 0) + if (deps != nullptr) new_deps.push_back(new_dep); } } @@ -333,11 +333,11 @@ bool macro_finder::expand_macros(unsigned num, justified_expr const * fmls, vect bool found_new_macro = false; for (unsigned i = 0; i < num; i++) { expr * n = fmls[i].get_fml(); - proof * pr = m.proofs_enabled() ? fmls[i].get_proof() : 0; + proof * pr = m.proofs_enabled() ? fmls[i].get_proof() : nullptr; expr_ref new_n(m), def(m); proof_ref new_pr(m); expr_dependency_ref new_dep(m); - m_macro_manager.expand_macros(n, pr, 0, new_n, new_pr, new_dep); + m_macro_manager.expand_macros(n, pr, nullptr, new_n, new_pr, new_dep); app_ref head(m), t(m); if (is_macro(new_n, head, def) && m_macro_manager.insert(head->get_decl(), to_quantifier(new_n.get()), new_pr)) { TRACE("macro_finder_found", tout << "found new macro: " << head->get_decl()->get_name() << "\n" << new_n << "\n";); diff --git a/src/ast/macros/macro_manager.cpp b/src/ast/macros/macro_manager.cpp index 855cae107..71bdac0a4 100644 --- a/src/ast/macros/macro_manager.cpp +++ b/src/ast/macros/macro_manager.cpp @@ -188,7 +188,7 @@ void macro_manager::display(std::ostream & out) { unsigned sz = m_decls.size(); for (unsigned i = 0; i < sz; i++) { func_decl * f = m_decls.get(i); - quantifier * q = 0; + quantifier * q = nullptr; m_decl2macro.find(f, q); app * head; expr * def; @@ -226,7 +226,7 @@ struct macro_manager::macro_expander_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 BR_FAILED; } @@ -255,7 +255,7 @@ struct macro_manager::macro_expander_cfg : public default_rewriter_cfg { erase_patterns = true; } if (erase_patterns) { - result = m.update_quantifier(old_q, 0, 0, 0, 0, new_body); + result = m.update_quantifier(old_q, 0, nullptr, 0, nullptr, new_body); } return erase_patterns; } @@ -264,13 +264,13 @@ struct macro_manager::macro_expander_cfg : public default_rewriter_cfg { if (!is_app(_n)) return false; app * n = to_app(_n); - quantifier * q = 0; + quantifier * q = nullptr; func_decl * d = n->get_decl(); TRACE("macro_manager", tout << "trying to expand:\n" << mk_pp(n, m) << "\nd:\n" << d->get_name() << "\n";); if (mm.m_decl2macro.find(d, q)) { TRACE("macro_manager", tout << "expanding: " << mk_pp(n, m) << "\n";); - app * head = 0; - expr * def = 0; + app * head = nullptr; + expr * def = nullptr; mm.get_head_def(q, d, head, def); unsigned num = n->get_num_args(); SASSERT(head && def); @@ -292,14 +292,14 @@ struct macro_manager::macro_expander_cfg : public default_rewriter_cfg { expr_ref instance(m); s(q->get_expr(), num, subst_args.c_ptr(), instance); proof * qi_pr = m.mk_quant_inst(m.mk_or(m.mk_not(q), instance), num, subst_args.c_ptr()); - proof * q_pr = 0; + proof * q_pr = nullptr; mm.m_decl2macro_pr.find(d, q_pr); SASSERT(q_pr != 0); proof * prs[2] = { qi_pr, q_pr }; p = m.mk_unit_resolution(2, prs); } else { - p = 0; + p = nullptr; } expr_dependency * ed = mm.m_decl2macro_dep.find(d); m_used_macro_dependencies = m.mk_join(m_used_macro_dependencies, ed); diff --git a/src/ast/macros/macro_manager.h b/src/ast/macros/macro_manager.h index 0205fb891..4fcb29f5d 100644 --- a/src/ast/macros/macro_manager.h +++ b/src/ast/macros/macro_manager.h @@ -67,7 +67,7 @@ public: ~macro_manager(); ast_manager & get_manager() const { return m; } macro_util & get_util() { return m_util; } - bool insert(func_decl * f, quantifier * m, proof * pr, expr_dependency * dep = 0); + bool insert(func_decl * f, quantifier * m, proof * pr, expr_dependency * dep = nullptr); bool has_macros() const { return !m_macros.empty(); } void push_scope(); void pop_scope(unsigned num_scopes); @@ -82,7 +82,7 @@ public: unsigned get_first_macro_last_level() const { return m_scopes.empty() ? 0 : m_scopes.back().m_decls_lim; } func_decl * get_macro_func_decl(unsigned i) const { return m_decls.get(i); } func_decl * get_macro_interpretation(unsigned i, expr_ref & interp) const; - quantifier * get_macro_quantifier(func_decl * f) const { quantifier * q = 0; m_decl2macro.find(f, q); return q; } + quantifier * get_macro_quantifier(func_decl * f) const { quantifier * q = nullptr; m_decl2macro.find(f, q); return q; } void get_head_def(quantifier * q, func_decl * d, app * & head, expr * & def) const; void expand_macros(expr * n, proof * pr, expr_dependency * dep, expr_ref & r, proof_ref & new_pr, expr_dependency_ref & new_dep); diff --git a/src/ast/macros/macro_util.cpp b/src/ast/macros/macro_util.cpp index 1ab54d0b5..77290c95f 100644 --- a/src/ast/macros/macro_util.cpp +++ b/src/ast/macros/macro_util.cpp @@ -33,8 +33,8 @@ macro_util::macro_util(ast_manager & m): m_arith(m), m_arith_rw(m), m_bv_rw(m), - m_forbidden_set(0), - m_curr_clause(0) { + m_forbidden_set(nullptr), + m_curr_clause(nullptr) { } @@ -256,7 +256,7 @@ bool macro_util::is_arith_macro(expr * n, unsigned num_decls, app_ref & head, ex inv = false; ptr_buffer args; - expr * h = 0; + expr * h = nullptr; unsigned lhs_num_args; expr * const * lhs_args; if (is_add(lhs)) { @@ -270,13 +270,13 @@ bool macro_util::is_arith_macro(expr * n, unsigned num_decls, app_ref & head, ex for (unsigned i = 0; i < lhs_num_args; i++) { expr * arg = lhs_args[i]; expr * neg_arg; - if (h == 0 && + if (h == nullptr && is_macro_head(arg, num_decls) && !is_forbidden(to_app(arg)->get_decl()) && !poly_contains_head(lhs, to_app(arg)->get_decl(), arg)) { h = arg; } - else if (h == 0 && m_arith_rw.is_times_minus_one(arg, neg_arg) && + else if (h == nullptr && m_arith_rw.is_times_minus_one(arg, neg_arg) && is_macro_head(neg_arg, num_decls) && !is_forbidden(to_app(neg_arg)->get_decl()) && !poly_contains_head(lhs, to_app(neg_arg)->get_decl(), arg)) { @@ -287,7 +287,7 @@ bool macro_util::is_arith_macro(expr * n, unsigned num_decls, app_ref & head, ex args.push_back(arg); } } - if (h == 0) + if (h == nullptr) return false; head = to_app(h); expr_ref tmp(m_manager); @@ -666,7 +666,7 @@ void macro_util::insert_macro(app * head, unsigned num_decls, expr * def, expr * expr_ref norm_def(m_manager); expr_ref norm_cond(m_manager); normalize_expr(head, num_decls, def, norm_def); - if (cond != 0) + if (cond != nullptr) normalize_expr(head, num_decls, cond, norm_cond); else if (!hint) norm_cond = m_manager.mk_true(); @@ -682,7 +682,7 @@ void macro_util::insert_quasi_macro(app * head, unsigned num_decls, expr * def, expr_ref new_cond(m_manager); if (!hint) { quasi_macro_head_to_macro_head(head, num_decls, new_head, extra_cond); - if (cond == 0) + if (cond == nullptr) new_cond = extra_cond; else bool_rewriter(m_manager).mk_and(cond, extra_cond, new_cond); @@ -701,7 +701,7 @@ void macro_util::insert_quasi_macro(app * head, unsigned num_decls, expr * def, } bool macro_util::rest_contains_decl(func_decl * f, expr * except_lit) { - if (m_curr_clause == 0) + if (m_curr_clause == nullptr) return false; SASSERT(is_clause(m_manager, m_curr_clause)); unsigned num_lits = get_clause_num_literals(m_manager, m_curr_clause); @@ -714,7 +714,7 @@ bool macro_util::rest_contains_decl(func_decl * f, expr * except_lit) { } void macro_util::get_rest_clause_as_cond(expr * except_lit, expr_ref & extra_cond) { - if (m_curr_clause == 0) + if (m_curr_clause == nullptr) return; SASSERT(is_clause(m_manager, m_curr_clause)); expr_ref_buffer neg_other_lits(m_manager); @@ -795,7 +795,7 @@ void macro_util::collect_arith_macro_candidates(expr * lhs, expr * rhs, expr * a mk_sub(rhs, rest, def); // If is_poly_hint, rhs may contain variables that do not occur in to_app(arg). // So, we should re-check. - if (!_is_poly_hint || is_poly_hint(def, to_app(arg), 0)) + if (!_is_poly_hint || is_poly_hint(def, to_app(arg), nullptr)) add_arith_macro_candidate(to_app(arg), num_decls, def, atom, is_ineq, _is_poly_hint, r); } else if (is_times_minus_one(arg, neg_arg) && is_app(neg_arg)) { @@ -816,7 +816,7 @@ void macro_util::collect_arith_macro_candidates(expr * lhs, expr * rhs, expr * a mk_sub(rest, rhs, def); // If is_poly_hint, rhs may contain variables that do not occur in to_app(neg_arg). // So, we should re-check. - if (!_is_poly_hint || is_poly_hint(def, to_app(neg_arg), 0)) + if (!_is_poly_hint || is_poly_hint(def, to_app(neg_arg), nullptr)) add_arith_macro_candidate(to_app(neg_arg), num_decls, def, atom, is_ineq, _is_poly_hint, r); } } @@ -885,7 +885,7 @@ void macro_util::collect_macro_candidates_core(expr * atom, unsigned num_decls, insert_quasi_macro(to_app(lhs), num_decls, rhs, cond, false, true, false, r); } else if (is_hint_atom(lhs, rhs)) { - insert_quasi_macro(to_app(lhs), num_decls, rhs, 0, false, true, true, r); + insert_quasi_macro(to_app(lhs), num_decls, rhs, nullptr, false, true, true, r); } if (is_quasi_macro_head(rhs, num_decls) && @@ -897,7 +897,7 @@ void macro_util::collect_macro_candidates_core(expr * atom, unsigned num_decls, insert_quasi_macro(to_app(rhs), num_decls, lhs, cond, false, true, false, r); } else if (is_hint_atom(rhs, lhs)) { - insert_quasi_macro(to_app(rhs), num_decls, lhs, 0, false, true, true, r); + insert_quasi_macro(to_app(rhs), num_decls, lhs, nullptr, false, true, true, r); } } @@ -905,7 +905,7 @@ void macro_util::collect_macro_candidates_core(expr * atom, unsigned num_decls, } void macro_util::collect_macro_candidates(expr * atom, unsigned num_decls, macro_candidates & r) { - m_curr_clause = 0; + m_curr_clause = nullptr; r.reset(); collect_macro_candidates_core(atom, num_decls, r); } @@ -922,7 +922,7 @@ void macro_util::collect_macro_candidates(quantifier * q, macro_candidates & r) unsigned num_lits = get_clause_num_literals(m_manager, n); for (unsigned i = 0; i < num_lits; i++) collect_macro_candidates_core(get_clause_literal(m_manager, n, i), num_decls, r); - m_curr_clause = 0; + m_curr_clause = nullptr; } else { collect_macro_candidates_core(n, num_decls, r); diff --git a/src/ast/macros/macro_util.h b/src/ast/macros/macro_util.h index 3ab00df2a..fecdeb97f 100644 --- a/src/ast/macros/macro_util.h +++ b/src/ast/macros/macro_util.h @@ -64,7 +64,7 @@ private: mutable bv_rewriter m_bv_rw; obj_hashtable * m_forbidden_set; - bool is_forbidden(func_decl * f) const { return m_forbidden_set != 0 && m_forbidden_set->contains(f); } + bool is_forbidden(func_decl * f) const { return m_forbidden_set != nullptr && m_forbidden_set->contains(f); } bool poly_contains_head(expr * n, func_decl * f, expr * exception) const; void collect_arith_macros(expr * n, unsigned num_decls, unsigned max_macros, bool allow_cond_macros, diff --git a/src/ast/macros/quasi_macros.cpp b/src/ast/macros/quasi_macros.cpp index 7d5e7c3db..afef6c43f 100644 --- a/src/ast/macros/quasi_macros.cpp +++ b/src/ast/macros/quasi_macros.cpp @@ -281,10 +281,10 @@ bool quasi_macros::find_macros(unsigned n, expr * const * exprs) { quasi_macro_to_macro(to_quantifier(exprs[i]), a, t, macro); TRACE("quasi_macros", tout << "Found quasi macro: " << mk_pp(exprs[i], m_manager) << std::endl; tout << "Macro: " << mk_pp(macro, m_manager) << std::endl; ); - proof * pr = 0; + proof * pr = nullptr; if (m_manager.proofs_enabled()) pr = m_manager.mk_def_axiom(macro); - expr_dependency * dep = 0; + expr_dependency * dep = nullptr; if (m_macro_manager.insert(a->get_decl(), macro, pr, dep)) res = true; } @@ -320,7 +320,7 @@ bool quasi_macros::find_macros(unsigned n, justified_expr const * exprs) { quasi_macro_to_macro(to_quantifier(exprs[i].get_fml()), a, t, macro); TRACE("quasi_macros", tout << "Found quasi macro: " << mk_pp(exprs[i].get_fml(), m_manager) << std::endl; tout << "Macro: " << mk_pp(macro, m_manager) << std::endl; ); - proof * pr = 0; + proof * pr = nullptr; if (m_manager.proofs_enabled()) pr = m_manager.mk_def_axiom(macro); if (m_macro_manager.insert(a->get_decl(), macro, pr)) @@ -336,7 +336,7 @@ void quasi_macros::apply_macros(unsigned n, expr * const * exprs, proof * const expr_ref r(m_manager), rs(m_manager); proof_ref pr(m_manager), ps(m_manager); expr_dependency_ref dep(m_manager); - proof * p = m_manager.proofs_enabled() ? prs[i] : 0; + proof * p = m_manager.proofs_enabled() ? prs[i] : nullptr; m_macro_manager.expand_macros(exprs[i], p, deps[i], r, pr, dep); m_rewriter(r); @@ -366,9 +366,9 @@ void quasi_macros::apply_macros(unsigned n, justified_expr const* fmls, vectoris_forall()) p = m().mk_skolemization(m().mk_not(q), m().mk_not(r)); @@ -163,8 +163,8 @@ public: void operator()(quantifier * q, expr_ref & r, proof_ref & p) { r = m_cache.find(q); - if (r.get() != 0) { - p = 0; + if (r.get() != nullptr) { + p = nullptr; if (m().proofs_enabled()) p = static_cast(m_cache_pr.find(q)); } @@ -496,7 +496,7 @@ struct nnf::imp { return false; } expr * r = m_result_stack.back(); - proof * pr = 0; + proof * pr = nullptr; if (proofs_enabled()) { pr = m_result_pr_stack.back(); if (!fr.m_pol) { @@ -673,7 +673,7 @@ struct nnf::imp { } expr * arg = m_result_stack.back(); - proof * arg_pr = proofs_enabled() ? m_result_pr_stack.back() : 0; + proof * arg_pr = proofs_enabled() ? m_result_pr_stack.back() : nullptr; if (m_ignore_labels && !proofs_enabled()) return true; // the result is already on the stack @@ -765,7 +765,7 @@ struct nnf::imp { if (q->is_forall() == fr.m_pol || !m_skolemize) { expr * new_expr = m_result_stack.back(); - proof * new_expr_pr = proofs_enabled() ? m_result_pr_stack.back() : 0; + proof * new_expr_pr = proofs_enabled() ? m_result_pr_stack.back() : nullptr; ptr_buffer new_patterns; @@ -783,8 +783,8 @@ struct nnf::imp { // So, ignore patterns } - quantifier * new_q = 0; - proof * new_q_pr = 0; + quantifier * new_q = nullptr; + proof * new_q_pr = nullptr; if (fr.m_pol) { new_q = m().update_quantifier(q, new_patterns.size(), new_patterns.c_ptr(), new_expr); if (proofs_enabled()) @@ -827,7 +827,7 @@ struct nnf::imp { if (proofs_enabled()) { result_pr = m_result_pr_stack.back(); m_result_pr_stack.pop_back(); - if (result_pr.get() == 0) + if (result_pr.get() == nullptr) result_pr = m().mk_reflexivity(t); SASSERT(m_result_pr_stack.empty()); } @@ -870,7 +870,7 @@ struct nnf::imp { if (status) { if (fr.m_cache_result) - cache_result(fr.m_curr, fr.m_pol, fr.m_in_q, m_result_stack.back(), proofs_enabled() ? m_result_pr_stack.back() : 0); + cache_result(fr.m_curr, fr.m_pol, fr.m_in_q, m_result_stack.back(), proofs_enabled() ? m_result_pr_stack.back() : nullptr); m_frame_stack.pop_back(); } } diff --git a/src/ast/normal_forms/pull_quant.cpp b/src/ast/normal_forms/pull_quant.cpp index ee618c747..06881f97b 100644 --- a/src/ast/normal_forms/pull_quant.cpp +++ b/src/ast/normal_forms/pull_quant.cpp @@ -85,7 +85,7 @@ struct pull_quant::imp { var_sorts.push_back(nested_q->get_decl_sort(j)); symbol s = nested_q->get_decl_name(j); if (std::find(var_names.begin(), var_names.end(), s) != var_names.end()) - var_names.push_back(m_manager.mk_fresh_var_name(s.is_numerical() ? 0 : s.bare_str())); + var_names.push_back(m_manager.mk_fresh_var_name(s.is_numerical() ? nullptr : s.bare_str())); else var_names.push_back(s); } @@ -215,7 +215,7 @@ struct pull_quant::imp { // Code for proof generation... void pull_quant2(expr * n, expr_ref & r, proof_ref & pr) { - pr = 0; + pr = nullptr; if (is_app(n)) { expr_ref_buffer new_args(m_manager); expr_ref new_arg(m_manager); @@ -231,8 +231,8 @@ struct pull_quant::imp { pull_quant1(to_app(n)->get_decl(), new_args.size(), new_args.c_ptr(), r); if (m_manager.proofs_enabled()) { app * r1 = m_manager.mk_app(to_app(n)->get_decl(), new_args.size(), new_args.c_ptr()); - proof * p1 = proofs.empty() ? 0 : m_manager.mk_congruence(to_app(n), r1, proofs.size(), proofs.c_ptr()); - proof * p2 = r1 == r ? 0 : m_manager.mk_pull_quant(r1, to_quantifier(r)); + proof * p1 = proofs.empty() ? nullptr : m_manager.mk_congruence(to_app(n), r1, proofs.size(), proofs.c_ptr()); + proof * p2 = r1 == r ? nullptr : m_manager.mk_pull_quant(r1, to_quantifier(r)); pr = m_manager.mk_transitivity(p1, p2); } } @@ -242,12 +242,12 @@ struct pull_quant::imp { pull_quant1(to_quantifier(n), new_expr, r); if (m_manager.proofs_enabled()) { quantifier * q1 = m_manager.update_quantifier(to_quantifier(n), new_expr); - proof * p1 = 0; + proof * p1 = nullptr; if (n != q1) { proof * p0 = m_manager.mk_pull_quant(n, to_quantifier(new_expr)); p1 = m_manager.mk_quant_intro(to_quantifier(n), q1, p0); } - proof * p2 = q1 == r ? 0 : m_manager.mk_pull_quant(q1, to_quantifier(r)); + proof * p2 = q1 == r ? nullptr : m_manager.mk_pull_quant(q1, to_quantifier(r)); pr = m_manager.mk_transitivity(p1, p2); } } diff --git a/src/ast/pattern/expr_pattern_match.cpp b/src/ast/pattern/expr_pattern_match.cpp index 628c777d3..d688c840c 100644 --- a/src/ast/pattern/expr_pattern_match.cpp +++ b/src/ast/pattern/expr_pattern_match.cpp @@ -83,7 +83,7 @@ expr_pattern_match::instantiate(expr* a, unsigned num_bound, subst& s, expr_ref& inst_proc proc(m_manager, s, b, m_regs); for_each_ast(proc, a); - expr* v = 0; + expr* v = nullptr; proc.m_memoize.find(a, v); SASSERT(v); result = v; diff --git a/src/ast/pattern/expr_pattern_match.h b/src/ast/pattern/expr_pattern_match.h index 6d9d47e1e..d1388b43f 100644 --- a/src/ast/pattern/expr_pattern_match.h +++ b/src/ast/pattern/expr_pattern_match.h @@ -80,7 +80,7 @@ class expr_pattern_match { } void operator()(var* v) { - var* b = 0; + var* b = nullptr; if (m_bound.find(v, b)) { m_memoize.insert(v, b); } @@ -99,7 +99,7 @@ class expr_pattern_match { decl = to_app(m_regs[r])->get_decl(); } for (unsigned i = 0; i < num_args; ++i) { - expr* arg = 0; + expr* arg = nullptr; if (m_memoize.find(n->get_arg(i), arg)) { SASSERT(arg); args.push_back(arg); diff --git a/src/ast/pattern/pattern_inference.cpp b/src/ast/pattern/pattern_inference.cpp index 17d8747f2..704de822c 100644 --- a/src/ast/pattern/pattern_inference.cpp +++ b/src/ast/pattern/pattern_inference.cpp @@ -168,7 +168,7 @@ bool pattern_inference_cfg::collect::visit_children(expr * n, unsigned delta) { inline void pattern_inference_cfg::collect::save(expr * n, unsigned delta, info * i) { m_cache.insert(entry(n, delta), i); - if (i != 0) + if (i != nullptr) m_info.push_back(i); } @@ -181,7 +181,7 @@ void pattern_inference_cfg::collect::save_candidate(expr * n, unsigned delta) { uint_set free_vars; if (idx < m_num_bindings) free_vars.insert(idx); - info * i = 0; + info * i = nullptr; if (delta == 0) i = alloc(info, m, n, free_vars, 1); else @@ -189,7 +189,7 @@ void pattern_inference_cfg::collect::save_candidate(expr * n, unsigned delta) { save(n, delta, i); } else { - save(n, delta, 0); + save(n, delta, nullptr); } return; } @@ -197,7 +197,7 @@ void pattern_inference_cfg::collect::save_candidate(expr * n, unsigned delta) { app * c = to_app(n); func_decl * decl = c->get_decl(); if (m_owner.is_forbidden(c)) { - save(n, delta, 0); + save(n, delta, nullptr); return; } @@ -213,14 +213,14 @@ void pattern_inference_cfg::collect::save_candidate(expr * n, unsigned delta) { unsigned num = c->get_num_args(); for (unsigned i = 0; i < num; i++) { expr * child = c->get_arg(i); - info * child_info = 0; + info * child_info = nullptr; #ifdef Z3DEBUG bool found = #endif m_cache.find(entry(child, delta), child_info); SASSERT(found); - if (child_info == 0) { - save(n, delta, 0); + if (child_info == nullptr) { + save(n, delta, nullptr); return; } buffer.push_back(child_info->m_node.get()); @@ -230,7 +230,7 @@ void pattern_inference_cfg::collect::save_candidate(expr * n, unsigned delta) { changed = true; } - app * new_node = 0; + app * new_node = nullptr; if (changed) new_node = m.mk_app(decl, buffer.size(), buffer.c_ptr()); else @@ -254,7 +254,7 @@ void pattern_inference_cfg::collect::save_candidate(expr * n, unsigned delta) { return; } default: - save(n, delta, 0); + save(n, delta, nullptr); return; } } @@ -630,7 +630,7 @@ bool pattern_inference_cfg::reduce_quantifier( if (new_patterns.empty() && num_no_patterns > 0) { if (new_patterns.empty()) { - mk_patterns(q->get_num_decls(), new_body, 0, 0, new_patterns); + mk_patterns(q->get_num_decls(), new_body, 0, nullptr, new_patterns); if (m_params.m_pi_warnings && !new_patterns.empty()) { warning_msg("ignoring nopats annotation because Z3 couldn't find any other pattern (quantifier id: %s)", q->get_qid().str().c_str()); } @@ -683,7 +683,7 @@ bool pattern_inference_cfg::reduce_quantifier( pull(new_q, new_expr, new_pr); quantifier * result2 = to_quantifier(new_expr); if (result2 != new_q) { - mk_patterns(result2->get_num_decls(), result2->get_expr(), 0, 0, new_patterns); + mk_patterns(result2->get_num_decls(), result2->get_expr(), 0, nullptr, new_patterns); if (!new_patterns.empty()) { if (m_params.m_pi_warnings) { warning_msg("pulled nested quantifier to be able to find an useable pattern (quantifier id: %s)", q->get_qid().str().c_str()); diff --git a/src/ast/pattern/pattern_inference.h b/src/ast/pattern/pattern_inference.h index 905662477..f32dcecd0 100644 --- a/src/ast/pattern/pattern_inference.h +++ b/src/ast/pattern/pattern_inference.h @@ -118,7 +118,7 @@ class pattern_inference_cfg : public default_rewriter_cfg { struct entry { expr * m_node; unsigned m_delta; - entry():m_node(0), m_delta(0) {} + entry():m_node(nullptr), m_delta(0) {} entry(expr * n, unsigned d):m_node(n), m_delta(d) {} unsigned hash() const { return hash_u_u(m_node->get_id(), m_delta); diff --git a/src/ast/pb_decl_plugin.cpp b/src/ast/pb_decl_plugin.cpp index 06c6aac48..57c6a0a8c 100644 --- a/src/ast/pb_decl_plugin.cpp +++ b/src/ast/pb_decl_plugin.cpp @@ -86,7 +86,7 @@ func_decl * pb_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p } default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -299,6 +299,6 @@ bool pb_util::has_unit_coefficients(func_decl* f) const { app* pb_util::mk_fresh_bool() { symbol name = m.mk_fresh_var_name("pb"); - func_decl_info info(m_fid, OP_PB_AUX_BOOL, 0, 0); - return m.mk_const(m.mk_func_decl(name, 0, (sort *const*)0, m.mk_bool_sort(), info)); + func_decl_info info(m_fid, OP_PB_AUX_BOOL, 0, nullptr); + return m.mk_const(m.mk_func_decl(name, 0, (sort *const*)nullptr, m.mk_bool_sort(), info)); } diff --git a/src/ast/pb_decl_plugin.h b/src/ast/pb_decl_plugin.h index e7c42d569..ea4049e13 100644 --- a/src/ast/pb_decl_plugin.h +++ b/src/ast/pb_decl_plugin.h @@ -57,7 +57,7 @@ public: sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) override { UNREACHABLE(); - return 0; + return nullptr; } decl_plugin * mk_fresh() override { diff --git a/src/ast/proofs/proof_checker.cpp b/src/ast/proofs/proof_checker.cpp index 5126198c6..9ba52a402 100644 --- a/src/ast/proofs/proof_checker.cpp +++ b/src/ast/proofs/proof_checker.cpp @@ -17,10 +17,10 @@ Copyright (c) 2015 Microsoft Corporation #define SAME_OP(_d1_, _d2_) ((_d1_ == _d2_) || (IS_EQUIV(_d1_) && IS_EQUIV(_d2_))) proof_checker::hyp_decl_plugin::hyp_decl_plugin() : - m_cons(0), - m_atom(0), - m_nil(0), - m_cell(0) { + m_cons(nullptr), + m_atom(nullptr), + m_nil(nullptr), + m_cell(nullptr) { } void proof_checker::hyp_decl_plugin::finalize() { @@ -54,7 +54,7 @@ func_decl * proof_checker::hyp_decl_plugin::mk_func_decl(decl_kind k) { case OP_NIL: return m_nil; default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -739,7 +739,7 @@ bool proof_checker::check1_basic(proof* p, expr_ref_vector& side_conditions) { // (not (forall ?x (p ?x y))) -> (not (p (sk y) y)) if (match_fact(p, fact) && match_oeq(fact.get(), t1, t2)) { - quantifier* q = 0; + quantifier* q = nullptr; expr* e = t1.get(); bool is_forall = false; if (match_not(t1.get(), s1)) { @@ -823,7 +823,7 @@ bool proof_checker::check1_basic(proof* p, expr_ref_vector& side_conditions) { premise0 = fmls[0].get(); for (unsigned i = 1; i < fmls.size(); ++i) { expr_ref lit1(m), lit2(m); - expr* lit3 = 0; + expr* lit3 = nullptr; std::pair pos = positions[i-1]; premise1 = fmls[i].get(); set_false(premise0, pos.first, lit1); @@ -1099,7 +1099,7 @@ void proof_checker::get_ors(expr* e, expr_ref_vector& ors) { void proof_checker::get_hypotheses(proof* p, expr_ref_vector& ante) { ptr_vector stack; - expr* h = 0; + expr* h = nullptr; expr_ref hyp(m); stack.push_back(p); @@ -1234,7 +1234,7 @@ bool proof_checker::is_hypothesis(proof* p) const { } expr* proof_checker::mk_hyp(unsigned num_hyps, expr * const * hyps) { - expr* result = 0; + expr* result = nullptr; for (unsigned i = 0; i < num_hyps; ++i) { if (!match_nil(hyps[i])) { if (result) { @@ -1245,7 +1245,7 @@ expr* proof_checker::mk_hyp(unsigned num_hyps, expr * const * hyps) { } } } - if (result == 0) { + if (result == nullptr) { return mk_nil(); } else { diff --git a/src/ast/proofs/proof_utils.cpp b/src/ast/proofs/proof_utils.cpp index 722bfe14e..97213c235 100644 --- a/src/ast/proofs/proof_utils.cpp +++ b/src/ast/proofs/proof_utils.cpp @@ -143,7 +143,7 @@ class reduce_hypotheses { void reduce(proof* pf, proof_ref &out) { - proof *res = NULL; + proof *res = nullptr; m_todo.reset(); m_todo.push_back(pf); @@ -392,7 +392,7 @@ class reduce_hypotheses0 { } void add_hypotheses(proof* p) { - expr_set* hyps = 0; + expr_set* hyps = nullptr; bool inherited = false; if (p->get_decl_kind() == PR_HYPOTHESIS) { hyps = alloc(expr_set); @@ -509,7 +509,7 @@ public: // eliminate hypothesis recursively in the proof of the lemma elim(tmp); expr_set* hyps = m_hypmap.find(tmp); - expr_set* new_hyps = 0; + expr_set* new_hyps = nullptr; // XXX if the proof is correct, the hypotheses of the tmp // XXX should be exactly those of the consequence of the lemma // XXX but if this code actually eliminates hypotheses, the set might be a subset @@ -567,7 +567,7 @@ public: } if (new_hyps && new_hyps->empty()) { dealloc(new_hyps); - new_hyps = 0; + new_hyps = nullptr; } m_hypmap.insert(result, new_hyps); // might push 0 into m_hyprefs. No reason for that @@ -822,7 +822,7 @@ bool proof_utils::is_closed(ast_manager& m, proof* p) { static void permute_unit_resolution(expr_ref_vector& refs, obj_map& cache, proof_ref& pr) { ast_manager& m = pr.get_manager(); - proof* pr2 = 0; + proof* pr2 = nullptr; proof_ref_vector parents(m); proof_ref prNew(pr); if (cache.find(pr, pr2)) { diff --git a/src/ast/recurse_expr_def.h b/src/ast/recurse_expr_def.h index d4f608c5a..b4a83c082 100644 --- a/src/ast/recurse_expr_def.h +++ b/src/ast/recurse_expr_def.h @@ -72,7 +72,7 @@ void recurse_expr::process(expr * n break; case AST_QUANTIFIER: if (IgnorePatterns) { - cache_result(n, this->Visitor::visit(to_quantifier(n), get_cached(to_quantifier(n)->get_expr()), 0, 0)); + cache_result(n, this->Visitor::visit(to_quantifier(n), get_cached(to_quantifier(n)->get_expr()), nullptr, nullptr)); } else { m_results1.reset(); diff --git a/src/ast/rewriter/arith_rewriter.cpp b/src/ast/rewriter/arith_rewriter.cpp index acc3b889f..744c8a235 100644 --- a/src/ast/rewriter/arith_rewriter.cpp +++ b/src/ast/rewriter/arith_rewriter.cpp @@ -1056,7 +1056,7 @@ br_status arith_rewriter::mk_power_core(expr * arg1, expr * arg2, expr_ref & res br_status arith_rewriter::mk_to_int_core(expr * arg, expr_ref & result) { numeral a; - expr* x = 0; + expr* x = nullptr; if (m_util.is_numeral(arg, a)) { result = m_util.mk_numeral(floor(a), true); return BR_DONE; @@ -1303,7 +1303,7 @@ expr * arith_rewriter::mk_sin_value(rational const & k) { expr * result = m_util.mk_div(m_util.mk_add(mk_sqrt(rational(6)), mk_sqrt(rational(2))), m_util.mk_numeral(rational(4), false)); return neg ? m_util.mk_uminus(result) : result; } - return 0; + return nullptr; } br_status arith_rewriter::mk_sin_core(expr * arg, expr_ref & result) { @@ -1327,7 +1327,7 @@ br_status arith_rewriter::mk_sin_core(expr * arg, expr_ref & result) { if (is_pi_multiple(arg, k)) { result = mk_sin_value(k); - if (result.get() != 0) + if (result.get() != nullptr) return BR_REWRITE_FULL; } @@ -1386,7 +1386,7 @@ br_status arith_rewriter::mk_cos_core(expr * arg, expr_ref & result) { if (is_pi_multiple(arg, k)) { k = k + rational(1, 2); result = mk_sin_value(k); - if (result.get() != 0) + if (result.get() != nullptr) return BR_REWRITE_FULL; } @@ -1443,7 +1443,7 @@ br_status arith_rewriter::mk_tan_core(expr * arg, expr_ref & result) { if (is_pi_multiple(arg, k)) { expr_ref n(m()), d(m()); n = mk_sin_value(k); - if (n.get() == 0) + if (n.get() == nullptr) goto end; if (is_zero(n)) { result = n; diff --git a/src/ast/rewriter/bit2int.cpp b/src/ast/rewriter/bit2int.cpp index 257740412..a72b73c4d 100644 --- a/src/ast/rewriter/bit2int.cpp +++ b/src/ast/rewriter/bit2int.cpp @@ -273,7 +273,7 @@ void bit2int::visit(app* n) { // bv2int(x) <= z - bv2int(y) -> bv2int(x) + bv2int(y) <= z // - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; expr_ref tmp1(m_manager), tmp2(m_manager); expr_ref tmp3(m_manager); expr_ref pos1(m_manager), neg1(m_manager); diff --git a/src/ast/rewriter/bit2int.h b/src/ast/rewriter/bit2int.h index fbbf2e6d1..048884a94 100644 --- a/src/ast/rewriter/bit2int.h +++ b/src/ast/rewriter/bit2int.h @@ -77,7 +77,7 @@ protected: bool mk_add(expr* e1, expr* e2, expr_ref& result); expr * get_cached(expr * n) const; - bool is_cached(expr * n) const { return get_cached(n) != 0; } + bool is_cached(expr * n) const { return get_cached(n) != nullptr; } void cache_result(expr * n, expr * r); void reset_cache() { m_cache.reset(); } void flush_cache() { m_cache.cleanup(); } diff --git a/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp b/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp index c47dacc96..ec9eaaa05 100644 --- a/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp +++ b/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp @@ -200,7 +200,7 @@ struct blaster_rewriter_cfg : public default_rewriter_cfg { sort * b = m().mk_bool_sort(); m_out.reset(); for (unsigned i = 0; i < bv_size; i++) { - m_out.push_back(m().mk_fresh_const(0, b)); + m_out.push_back(m().mk_fresh_const(nullptr, b)); } r = mk_mkbv(m_out); m_const2bits.insert(f, r); @@ -342,11 +342,11 @@ MK_PARAMETRIC_UNARY_REDUCE(reduce_sign_extend, mk_sign_extend); bits.push_back(m().mk_app(butil().get_family_id(), OP_BIT2BOOL, 1, &p, 1, &t)); } result = mk_mkbv(bits); - result_pr = 0; + result_pr = nullptr; } 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; TRACE("bit_blaster", tout << f->get_name() << " "; for (unsigned i = 0; i < num; ++i) tout << mk_pp(args[i], m()) << " "; tout << "\n";); @@ -569,7 +569,7 @@ MK_PARAMETRIC_UNARY_REDUCE(reduce_sign_extend, mk_sign_extend); if (t->get_idx() >= m_bindings.size()) return false; result = m_bindings.get(m_bindings.size() - t->get_idx() - 1); - result_pr = 0; + result_pr = nullptr; return true; } @@ -616,7 +616,7 @@ MK_PARAMETRIC_UNARY_REDUCE(reduce_sign_extend, mk_sign_extend); result = m().mk_quantifier(old_q->is_forall(), new_decl_sorts.size(), new_decl_sorts.c_ptr(), new_decl_names.c_ptr(), new_body, old_q->get_weight(), old_q->get_qid(), old_q->get_skid(), old_q->get_num_patterns(), new_patterns, old_q->get_num_no_patterns(), new_no_patterns); - result_pr = 0; + result_pr = nullptr; m_bindings.shrink(old_sz); return true; } diff --git a/src/ast/rewriter/bool_rewriter.cpp b/src/ast/rewriter/bool_rewriter.cpp index 6e99cb23e..5cf25335b 100644 --- a/src/ast/rewriter/bool_rewriter.cpp +++ b/src/ast/rewriter/bool_rewriter.cpp @@ -585,7 +585,7 @@ bool bool_rewriter::local_ctx_simp(unsigned num_args, expr * const * args, expr_ */ br_status bool_rewriter::try_ite_value(app * ite, app * val, expr_ref & result) { - expr* cond = 0, *t = 0, *e = 0; + expr* cond = nullptr, *t = nullptr, *e = nullptr; VERIFY(m().is_ite(ite, cond, t, e)); SASSERT(m().is_value(val)); diff --git a/src/ast/rewriter/bool_rewriter.h b/src/ast/rewriter/bool_rewriter.h index be9799c13..34e03c1ed 100644 --- a/src/ast/rewriter/bool_rewriter.h +++ b/src/ast/rewriter/bool_rewriter.h @@ -183,7 +183,7 @@ struct bool_rewriter_cfg : public default_rewriter_cfg { bool flat_assoc(func_decl * f) const { return m_r.flat() && (m_r.m().is_and(f) || m_r.m().is_or(f)); } 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; if (f->get_family_id() != m_r.get_fid()) return BR_FAILED; return m_r.mk_app_core(f, num, args, result); diff --git a/src/ast/rewriter/bv_bounds.cpp b/src/ast/rewriter/bv_bounds.cpp index 0a32f8bc2..f337ca638 100644 --- a/src/ast/rewriter/bv_bounds.cpp +++ b/src/ast/rewriter/bv_bounds.cpp @@ -200,7 +200,7 @@ bv_bounds::conv_res bv_bounds::convert(expr * e, vector& nis, bool ne } // v + c1 <= v + c2 - app * v1(NULL), *v2(NULL); + app * v1(nullptr), *v2(nullptr); numeral val1, val2; if (is_constant_add(bv_sz, lhs, v1, val1) && is_constant_add(bv_sz, rhs, v2, val2) @@ -412,7 +412,7 @@ bool bv_bounds::add_constraint(expr* e) { } // v + c1 <= v + c2 - app * v1(NULL), *v2(NULL); + app * v1(nullptr), *v2(nullptr); numeral val1, val2; if (is_constant_add(bv_sz, lhs, v1, val1) && is_constant_add(bv_sz, rhs, v2, val2) @@ -550,8 +550,8 @@ bool bv_bounds::add_neg_bound(app * v, const numeral& a, const numeral& b) { SASSERT(a <= b); intervals_map::obj_map_entry * const e = m_negative_intervals.find_core(v); - intervals * ivs(NULL); - if (e == 0) { + intervals * ivs(nullptr); + if (e == nullptr) { ivs = alloc(intervals); m_negative_intervals.insert(v, ivs); } @@ -621,7 +621,7 @@ bool bv_bounds::is_sat_core(app * v) { if (!has_lower) lower = numeral::zero(); if (!has_upper) upper = (numeral::power_of_two(bv_sz) - one); TRACE("bv_bounds", tout << "is_sat bound:" << lower << "-" << upper << std::endl;); - intervals * negative_intervals(NULL); + intervals * negative_intervals(nullptr); const bool has_neg_intervals = m_negative_intervals.find(v, negative_intervals); bool is_sat(false); numeral new_lo = lower; diff --git a/src/ast/rewriter/bv_bounds.h b/src/ast/rewriter/bv_bounds.h index 775941d1d..fcd173a12 100644 --- a/src/ast/rewriter/bv_bounds.h +++ b/src/ast/rewriter/bv_bounds.h @@ -109,7 +109,7 @@ inline bool bv_bounds::in_range(app *v, const bv_bounds::numeral& n) { inline bool bv_bounds::is_constant_add(unsigned bv_sz, expr * e, app*& v, numeral& val) { SASSERT(e && !v); SASSERT(m_bv_util.get_bv_size(e) == bv_sz); - expr *lhs(NULL), *rhs(NULL); + expr *lhs(nullptr), *rhs(nullptr); if (!m_bv_util.is_bv_add(e, lhs, rhs)) { v = to_app(e); val = rational(0); diff --git a/src/ast/rewriter/bv_elim.cpp b/src/ast/rewriter/bv_elim.cpp index 270d7deb8..0c6484ed6 100644 --- a/src/ast/rewriter/bv_elim.cpp +++ b/src/ast/rewriter/bv_elim.cpp @@ -58,7 +58,7 @@ bool bv_elim_cfg::reduce_quantifier(quantifier * q, _sorts.push_back(m.mk_bool_sort()); _names.push_back(symbol(new_name.str().c_str())); } - bv = m.mk_app(bfid, OP_MKBV, 0, 0, args.size(), args.c_ptr()); + bv = m.mk_app(bfid, OP_MKBV, 0, nullptr, args.size(), args.c_ptr()); _subst_map.push_back(bv.get()); } else { diff --git a/src/ast/rewriter/bv_rewriter.cpp b/src/ast/rewriter/bv_rewriter.cpp index ce35300ca..e327df452 100644 --- a/src/ast/rewriter/bv_rewriter.cpp +++ b/src/ast/rewriter/bv_rewriter.cpp @@ -630,13 +630,13 @@ unsigned bv_rewriter::propagate_extract(unsigned high, expr * arg, expr_ref & re const bool curr_is_conc = m_util.is_concat(curr); if (curr_is_conc && to_app(curr)->get_num_args() == 0) continue; expr * const curr_first = curr_is_conc ? to_app(curr)->get_arg(0) : curr; - expr * new_first = NULL; + expr * new_first = nullptr; if (is_numeral(curr_first, val, curr_first_sz)) { SASSERT(curr_first_sz >= removable); const unsigned new_num_sz = curr_first_sz - removable; - new_first = new_num_sz ? mk_numeral(val, new_num_sz) : NULL; + new_first = new_num_sz ? mk_numeral(val, new_num_sz) : nullptr; } - expr * new_arg = NULL; + expr * new_arg = nullptr; if (curr_is_conc) { const unsigned conc_num = to_app(curr)->get_num_args(); if (new_first) { @@ -650,7 +650,7 @@ unsigned bv_rewriter::propagate_extract(unsigned high, expr * arg, expr_ref & re expr * const * const old_conc_args = to_app(curr)->get_args(); switch (conc_num) { case 0: UNREACHABLE(); break; - case 1: new_arg = NULL; break; + case 1: new_arg = nullptr; break; case 2: new_arg = to_app(curr)->get_arg(1); break; default: new_arg = m_util.mk_concat(conc_num - 1, old_conc_args + 1); } @@ -1458,10 +1458,10 @@ br_status bv_rewriter::mk_concat(unsigned num_args, expr * const * args, expr_re bool fused_extract = false; for (unsigned i = 0; i < num_args; i++) { expr * arg = args[i]; - expr * prev = 0; + expr * prev = nullptr; if (i > 0) prev = new_args.back(); - if (is_numeral(arg, v1, sz1) && prev != 0 && is_numeral(prev, v2, sz2)) { + if (is_numeral(arg, v1, sz1) && prev != nullptr && is_numeral(prev, v2, sz2)) { v2 *= rational::power_of_two(sz1); v2 += v1; new_args.pop_back(); @@ -1476,7 +1476,7 @@ br_status bv_rewriter::mk_concat(unsigned num_args, expr * const * args, expr_re expanded = true; } else if (m_util.is_extract(arg) && - prev != 0 && + prev != nullptr && m_util.is_extract(prev) && to_app(arg)->get_arg(0) == to_app(prev)->get_arg(0) && m_util.get_extract_low(prev) == m_util.get_extract_high(arg) + 1) { @@ -1814,7 +1814,7 @@ br_status bv_rewriter::mk_bv_xor(unsigned num, expr * const * args, expr_ref & r // if (!v1.is_zero() && num_coeffs == num - 1) { // find argument that is not a numeral - expr * t = 0; + expr * t = nullptr; for (unsigned i = 0; i < num; i++) { t = args[i]; if (!is_numeral(t)) @@ -1937,7 +1937,7 @@ br_status bv_rewriter::mk_bv_not(expr * arg, expr_ref & result) { } if (m_bvnot_simpl) { - expr *s(0), *t(0); + expr *s(nullptr), *t(nullptr); if (m_util.is_bv_mul(arg, s, t)) { // ~(-1 * x) --> (x - 1) bv_size = m_util.get_bv_size(s); diff --git a/src/ast/rewriter/bv_trailing.cpp b/src/ast/rewriter/bv_trailing.cpp index 5cdf27574..ad9350eca 100644 --- a/src/ast/rewriter/bv_trailing.cpp +++ b/src/ast/rewriter/bv_trailing.cpp @@ -39,7 +39,7 @@ struct bv_trailing::imp { TRACE("bv-trailing", tout << "ctor\n";); for (unsigned i = 0; i <= TRAILING_DEPTH; ++i) - m_count_cache[i] = NULL; + m_count_cache[i] = nullptr; } virtual ~imp() { @@ -116,7 +116,7 @@ struct bv_trailing::imp { const unsigned sz = m_util.get_bv_size(a); if (to_rm == sz) { - result = NULL; + result = nullptr; return sz; } @@ -155,7 +155,7 @@ struct bv_trailing::imp { const unsigned new_sz = sz - retv; if (!new_sz) { - result = NULL; + result = nullptr; return retv; } @@ -181,7 +181,7 @@ struct bv_trailing::imp { const unsigned num = a->get_num_args(); unsigned retv = 0; unsigned i = num; - expr_ref new_last(NULL, m); + expr_ref new_last(nullptr, m); while (i && retv < n) { i--; expr * const curr = a->get_arg(i); @@ -197,7 +197,7 @@ struct bv_trailing::imp { if (!i && !new_last) {// all args eaten completely SASSERT(retv == m_util.get_bv_size(a)); - result = NULL; + result = nullptr; return retv; } @@ -230,7 +230,7 @@ struct bv_trailing::imp { if (m_util.is_numeral(e, e_val, sz)) { retv = remove_trailing(std::min(n, sz), e_val); const unsigned new_sz = sz - retv; - result = new_sz ? (retv ? m_util.mk_numeral(e_val, new_sz) : e) : NULL; + result = new_sz ? (retv ? m_util.mk_numeral(e_val, new_sz) : e) : nullptr; return retv; } if (m_util.is_bv_mul(e)) @@ -338,7 +338,7 @@ struct bv_trailing::imp { void cache(unsigned depth, expr * e, unsigned min, unsigned max) { SASSERT(depth <= TRAILING_DEPTH); if (depth == 0) return; - if (m_count_cache[depth] == NULL) + if (m_count_cache[depth] == nullptr) m_count_cache[depth] = alloc(map); SASSERT(!m_count_cache[depth]->contains(e)); m.inc_ref(e); @@ -353,10 +353,10 @@ struct bv_trailing::imp { max = m_util.get_bv_size(e); return true; } - if (m_count_cache[depth] == NULL) + if (m_count_cache[depth] == nullptr) return false; const map::obj_map_entry * const oe = m_count_cache[depth]->find_core(e); - if (oe == NULL) return false; + if (oe == nullptr) return false; min = oe->get_data().m_value.first; max = oe->get_data().m_value.second; TRACE("bv-trailing", tout << "cached@" << depth << ": " << mk_ismt2_pp(e, m) << '[' << m_util.get_bv_size(e) << "]\n: " << min << '-' << max << "\n";); @@ -366,7 +366,7 @@ struct bv_trailing::imp { void reset_cache(const unsigned condition) { SASSERT(m_count_cache[0] == NULL); for (unsigned i = 1; i <= TRAILING_DEPTH; ++i) { - if (m_count_cache[i] == NULL) continue; + if (m_count_cache[i] == nullptr) continue; TRACE("bv-trailing", tout << "may reset cache " << i << " " << condition << "\n";); if (condition && m_count_cache[i]->size() < condition) continue; TRACE("bv-trailing", tout << "reset cache " << i << "\n";); @@ -374,7 +374,7 @@ struct bv_trailing::imp { map::iterator end = m_count_cache[i]->end(); for (; it != end; ++it) m.dec_ref(it->m_key); dealloc(m_count_cache[i]); - m_count_cache[i] = NULL; + m_count_cache[i] = nullptr; } } diff --git a/src/ast/rewriter/der.cpp b/src/ast/rewriter/der.cpp index d1fecf2fb..021943585 100644 --- a/src/ast/rewriter/der.cpp +++ b/src/ast/rewriter/der.cpp @@ -118,7 +118,7 @@ bool der::is_var_diseq(expr * e, unsigned num_decls, var * & v, expr_ref & t) { void der::operator()(quantifier * q, expr_ref & r, proof_ref & pr) { bool reduced = false; - pr = 0; + pr = nullptr; r = q; TRACE("der", tout << mk_pp(q, m_manager) << "\n";); @@ -149,14 +149,14 @@ void der::operator()(quantifier * q, expr_ref & r, proof_ref & pr) { void der::reduce1(quantifier * q, expr_ref & r, proof_ref & pr) { if (!is_forall(q)) { - pr = 0; + pr = nullptr; r = q; return; } expr * e = q->get_expr(); unsigned num_decls = q->get_num_decls(); - var * v = 0; + var * v = nullptr; expr_ref t(m_manager); if (m_manager.is_or(e)) { @@ -211,7 +211,7 @@ void der::reduce1(quantifier * q, expr_ref & r, proof_ref & pr) { r = q; if (m_manager.proofs_enabled()) { - pr = r == q ? 0 : m_manager.mk_der(q, r); + pr = r == q ? nullptr : m_manager.mk_der(q, r); } } @@ -223,7 +223,7 @@ void der_sort_vars(ptr_vector & vars, ptr_vector & definitions, unsig for (unsigned i = 0; i < definitions.size(); i++) { var * v = vars[i]; expr * t = definitions[i]; - if (t == 0 || has_quantifiers(t) || occurs(v, t)) + if (t == nullptr || has_quantifiers(t) || occurs(v, t)) definitions[i] = 0; else found = true; // found at least one candidate @@ -342,7 +342,7 @@ void der::get_elimination_order() { void der::create_substitution(unsigned sz) { m_subst_map.reset(); - m_subst_map.resize(sz, 0); + m_subst_map.resize(sz, nullptr); for(unsigned i = 0; i < m_order.size(); i++) { expr_ref cur(m_map[m_order[i]], m_manager); diff --git a/src/ast/rewriter/distribute_forall.h b/src/ast/rewriter/distribute_forall.h index ab0976945..8bb77d70d 100644 --- a/src/ast/rewriter/distribute_forall.h +++ b/src/ast/rewriter/distribute_forall.h @@ -71,7 +71,7 @@ protected: void reduce1_app(app * a); expr * get_cached(expr * n) const; - bool is_cached(expr * n) const { return get_cached(n) != 0; } + bool is_cached(expr * n) const { return get_cached(n) != nullptr; } void cache_result(expr * n, expr * r); void reset_cache() { m_cache.reset(); } void flush_cache() { m_cache.cleanup(); } diff --git a/src/ast/rewriter/elim_bounds.cpp b/src/ast/rewriter/elim_bounds.cpp index d3240e511..a640081ba 100644 --- a/src/ast/rewriter/elim_bounds.cpp +++ b/src/ast/rewriter/elim_bounds.cpp @@ -44,15 +44,15 @@ elim_bounds_cfg::elim_bounds_cfg(ast_manager & m): It also detects >=, and the atom can be negated. */ bool elim_bounds_cfg::is_bound(expr * n, var * & lower, var * & upper) { - upper = 0; - lower = 0; + upper = nullptr; + lower = nullptr; bool neg = false; if (m.is_not(n)) { n = to_app(n)->get_arg(0); neg = true; } - expr* l = 0, *r = 0; + expr* l = nullptr, *r = nullptr; bool le = false; if (m_util.is_le(n, l, r) && m_util.is_numeral(r)) { n = l; @@ -139,14 +139,14 @@ bool elim_bounds_cfg::reduce_quantifier(quantifier * q, ptr_buffer candidates; #define ADD_CANDIDATE(V) if (!lowers.contains(V) && !uppers.contains(V)) { candidate_set.insert(V); candidates.push_back(V); } for (expr * a : atoms) { - var * lower = 0; - var * upper = 0; + var * lower = nullptr; + var * upper = nullptr; if (is_bound(a, lower, upper)) { - if (lower != 0 && !used_vars.contains(lower->get_idx()) && lower->get_idx() < num_vars) { + if (lower != nullptr && !used_vars.contains(lower->get_idx()) && lower->get_idx() < num_vars) { ADD_CANDIDATE(lower); lowers.insert(lower); } - if (upper != 0 && !used_vars.contains(upper->get_idx()) && upper->get_idx() < num_vars) { + if (upper != nullptr && !used_vars.contains(upper->get_idx()) && upper->get_idx() < num_vars) { ADD_CANDIDATE(upper); uppers.insert(upper); } @@ -167,9 +167,9 @@ bool elim_bounds_cfg::reduce_quantifier(quantifier * q, unsigned j = 0; for (unsigned i = 0; i < atoms.size(); ++i) { expr * a = atoms[i]; - var * lower = 0; - var * upper = 0; - if (is_bound(a, lower, upper) && ((lower != 0 && candidate_set.contains(lower)) || (upper != 0 && candidate_set.contains(upper)))) + var * lower = nullptr; + var * upper = nullptr; + if (is_bound(a, lower, upper) && ((lower != nullptr && candidate_set.contains(lower)) || (upper != nullptr && candidate_set.contains(upper)))) continue; atoms[j] = a; j++; @@ -178,7 +178,7 @@ bool elim_bounds_cfg::reduce_quantifier(quantifier * q, return false; } atoms.resize(j); - expr * new_body = 0; + expr * new_body = nullptr; switch (atoms.size()) { case 0: result = m.mk_false(); diff --git a/src/ast/rewriter/enum2bv_rewriter.cpp b/src/ast/rewriter/enum2bv_rewriter.cpp index eb6b195f0..814a25ee9 100644 --- a/src/ast/rewriter/enum2bv_rewriter.cpp +++ b/src/ast/rewriter/enum2bv_rewriter.cpp @@ -194,7 +194,7 @@ struct enum2bv_rewriter::imp { q->get_weight(), q->get_qid(), q->get_skid(), q->get_num_patterns(), new_patterns, q->get_num_no_patterns(), new_no_patterns); - result_pr = 0; + result_pr = nullptr; return true; } @@ -226,7 +226,7 @@ struct enum2bv_rewriter::imp { m_enum_bvs(m), m_enum_defs(m), m_num_translated(0), - m_sort_pred(0), + m_sort_pred(nullptr), m_rw(*this, m, p) { } diff --git a/src/ast/rewriter/expr_replacer.cpp b/src/ast/rewriter/expr_replacer.cpp index fb85e3372..c9bf834fd 100644 --- a/src/ast/rewriter/expr_replacer.cpp +++ b/src/ast/rewriter/expr_replacer.cpp @@ -34,7 +34,7 @@ void expr_replacer::operator()(expr * t, expr_ref & result) { struct expr_replacer::scoped_set_subst { expr_replacer & m_r; scoped_set_subst(expr_replacer & r, expr_substitution & s):m_r(r) { m_r.set_substitution(&s); } - ~scoped_set_subst() { m_r.set_substitution(0); } + ~scoped_set_subst() { m_r.set_substitution(nullptr); } }; void expr_replacer::apply_substitution(expr * s, expr * def, proof * def_pr, expr_ref & t) { @@ -58,14 +58,14 @@ struct default_expr_replacer_cfg : public default_rewriter_cfg { default_expr_replacer_cfg(ast_manager & _m): m(_m), - m_subst(0), + m_subst(nullptr), m_used_dependencies(_m) { } bool get_subst(expr * s, expr * & t, proof * & pr) { - if (m_subst == 0) + if (m_subst == nullptr) return false; - expr_dependency * d = 0; + expr_dependency * d = nullptr; if (m_subst->find(s, t, pr, d)) { m_used_dependencies = m.mk_join(m_used_dependencies, d); return true; @@ -98,12 +98,12 @@ public: } void operator()(expr * t, expr_ref & result, proof_ref & result_pr, expr_dependency_ref & result_dep) override { - result_dep = 0; + result_dep = nullptr; m_replacer.operator()(t, result, result_pr); if (m_cfg.m_used_dependencies != 0) { result_dep = m_cfg.m_used_dependencies; m_replacer.reset(); // reset cache - m_cfg.m_used_dependencies = 0; + m_cfg.m_used_dependencies = nullptr; } } diff --git a/src/ast/rewriter/expr_safe_replace.cpp b/src/ast/rewriter/expr_safe_replace.cpp index 31453691e..0ed0efc00 100644 --- a/src/ast/rewriter/expr_safe_replace.cpp +++ b/src/ast/rewriter/expr_safe_replace.cpp @@ -61,7 +61,7 @@ void expr_safe_replace::operator()(expr* e, expr_ref& res) { m_args.reset(); bool arg_differs = false; for (unsigned i = 0; i < n; ++i) { - expr* d = 0, *arg = c->get_arg(i); + expr* d = nullptr, *arg = c->get_arg(i); if (m_cache.find(arg, d)) { m_args.push_back(d); arg_differs |= arg != d; diff --git a/src/ast/rewriter/factor_rewriter.h b/src/ast/rewriter/factor_rewriter.h index aae9b05b3..823a8ae69 100644 --- a/src/ast/rewriter/factor_rewriter.h +++ b/src/ast/rewriter/factor_rewriter.h @@ -61,7 +61,7 @@ struct factor_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); } factor_rewriter_cfg(ast_manager & m):m_r(m) {} diff --git a/src/ast/rewriter/fpa_rewriter.cpp b/src/ast/rewriter/fpa_rewriter.cpp index e62c9346f..162f9d5c7 100644 --- a/src/ast/rewriter/fpa_rewriter.cpp +++ b/src/ast/rewriter/fpa_rewriter.cpp @@ -48,17 +48,17 @@ br_status fpa_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * con case OP_FPA_RM_TOWARD_POSITIVE: case OP_FPA_RM_TOWARD_NEGATIVE: case OP_FPA_RM_TOWARD_ZERO: - SASSERT(num_args == 0); result = m().mk_app(f, (expr * const *)0); st = BR_DONE; break; + SASSERT(num_args == 0); result = m().mk_app(f, (expr * const *)nullptr); st = BR_DONE; break; case OP_FPA_PLUS_INF: case OP_FPA_MINUS_INF: case OP_FPA_NAN: case OP_FPA_PLUS_ZERO: case OP_FPA_MINUS_ZERO: - SASSERT(num_args == 0); result = m().mk_app(f, (expr * const *)0); st = BR_DONE; break; + SASSERT(num_args == 0); result = m().mk_app(f, (expr * const *)nullptr); st = BR_DONE; break; case OP_FPA_NUM: - SASSERT(num_args == 0); result = m().mk_app(f, (expr * const *)0); st = BR_DONE; break; + SASSERT(num_args == 0); result = m().mk_app(f, (expr * const *)nullptr); st = BR_DONE; break; case OP_FPA_ADD: SASSERT(num_args == 3); st = mk_add(args[0], args[1], args[2], result); break; case OP_FPA_SUB: SASSERT(num_args == 3); st = mk_sub(args[0], args[1], args[2], result); break; diff --git a/src/ast/rewriter/inj_axiom.cpp b/src/ast/rewriter/inj_axiom.cpp index d322f3228..184c84144 100644 --- a/src/ast/rewriter/inj_axiom.cpp +++ b/src/ast/rewriter/inj_axiom.cpp @@ -29,9 +29,9 @@ Revision History: */ bool simplify_inj_axiom(ast_manager & m, quantifier * q, expr_ref & result) { expr * n = q->get_expr(); - expr* arg1 = 0, * arg2 = 0, *narg = 0; - expr* app1 = 0, * app2 = 0; - expr* var1 = 0, * var2 = 0; + expr* arg1 = nullptr, * arg2 = nullptr, *narg = nullptr; + expr* app1 = nullptr, * app2 = nullptr; + expr* var1 = nullptr, * var2 = nullptr; if (q->is_forall() && m.is_or(n, arg1, arg2)) { if (m.is_not(arg2)) std::swap(arg1, arg2); @@ -84,7 +84,7 @@ bool simplify_inj_axiom(ast_manager & m, quantifier * q, expr_ref & result) { ptr_buffer decls; buffer names; - expr * var = 0; + expr * var = nullptr; for (unsigned i = 0; i < num; i++) { expr * c = f1->get_arg(i); if (is_var(c)) { diff --git a/src/ast/rewriter/maximize_ac_sharing.cpp b/src/ast/rewriter/maximize_ac_sharing.cpp index a838f59fa..a8bee62d5 100644 --- a/src/ast/rewriter/maximize_ac_sharing.cpp +++ b/src/ast/rewriter/maximize_ac_sharing.cpp @@ -35,7 +35,7 @@ br_status maximize_ac_sharing::reduce_app(func_decl * f, unsigned num_args, expr if (std::find(m_kinds.begin(), m_kinds.end(), k) == m_kinds.end()) return BR_FAILED; ptr_buffer _args; - expr * numeral = 0; + expr * numeral = nullptr; if (is_numeral(args[0])) { numeral = args[0]; for (unsigned i = 1; i < num_args; i++) @@ -86,7 +86,7 @@ br_status maximize_ac_sharing::reduce_app(func_decl * f, unsigned num_args, expr } num_args = j; if (num_args == 1) { - if (numeral == 0) { + if (numeral == nullptr) { result = _args[0]; } else { diff --git a/src/ast/rewriter/maximize_ac_sharing.h b/src/ast/rewriter/maximize_ac_sharing.h index 7144c7ad3..a36a31101 100644 --- a/src/ast/rewriter/maximize_ac_sharing.h +++ b/src/ast/rewriter/maximize_ac_sharing.h @@ -45,7 +45,7 @@ class maximize_ac_sharing : public default_rewriter_cfg { expr * m_arg1; expr * m_arg2; - entry(func_decl * d = 0, expr * arg1 = 0, expr * arg2 = 0):m_decl(d), m_arg1(arg1), m_arg2(arg2) { + entry(func_decl * d = nullptr, expr * arg1 = nullptr, expr * arg2 = nullptr):m_decl(d), m_arg1(arg1), m_arg2(arg2) { SASSERT((d == 0 && arg1 == 0 && arg2 == 0) || (d != 0 && arg1 != 0 && arg2 != 0)); if (arg1->get_id() > arg2->get_id()) std::swap(m_arg1, m_arg2); diff --git a/src/ast/rewriter/mk_extract_proc.cpp b/src/ast/rewriter/mk_extract_proc.cpp index da22c3b80..e245f3a3d 100644 --- a/src/ast/rewriter/mk_extract_proc.cpp +++ b/src/ast/rewriter/mk_extract_proc.cpp @@ -19,8 +19,8 @@ mk_extract_proc::mk_extract_proc(bv_util & u): m_util(u), m_high(0), m_low(UINT_MAX), - m_domain(0), - m_f_cached(0) { + m_domain(nullptr), + m_f_cached(nullptr) { } mk_extract_proc::~mk_extract_proc() { diff --git a/src/ast/rewriter/mk_simplified_app.cpp b/src/ast/rewriter/mk_simplified_app.cpp index eac26ddc3..9bf460aa9 100644 --- a/src/ast/rewriter/mk_simplified_app.cpp +++ b/src/ast/rewriter/mk_simplified_app.cpp @@ -98,7 +98,7 @@ br_status mk_simplified_app::mk_core(func_decl * decl, unsigned num, expr * cons } void mk_simplified_app::operator()(func_decl * decl, unsigned num, expr * const * args, expr_ref & result) { - result = 0; + result = nullptr; mk_core(decl, num, args, result); if (!result) result = m_imp->m.mk_app(decl, num, args); diff --git a/src/ast/rewriter/pb2bv_rewriter.cpp b/src/ast/rewriter/pb2bv_rewriter.cpp index 39d6e2143..0bdeda475 100644 --- a/src/ast/rewriter/pb2bv_rewriter.cpp +++ b/src/ast/rewriter/pb2bv_rewriter.cpp @@ -403,7 +403,7 @@ struct pb2bv_rewriter::imp { 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); } card2bv_rewriter_cfg(imp& i, ast_manager & m):m_r(i, m) {} diff --git a/src/ast/rewriter/poly_rewriter.h b/src/ast/rewriter/poly_rewriter.h index 23743399e..c4b120ae5 100644 --- a/src/ast/rewriter/poly_rewriter.h +++ b/src/ast/rewriter/poly_rewriter.h @@ -96,7 +96,7 @@ protected: public: poly_rewriter(ast_manager & m, params_ref const & p = params_ref()): Config(m), - m_curr_sort(0), + m_curr_sort(nullptr), m_sort_sums(false) { updt_params(p); SASSERT(!m_som || m_flat); // som of monomials form requires flattening to be enabled. diff --git a/src/ast/rewriter/poly_rewriter_def.h b/src/ast/rewriter/poly_rewriter_def.h index 71a9079a0..f27c9ffcf 100644 --- a/src/ast/rewriter/poly_rewriter_def.h +++ b/src/ast/rewriter/poly_rewriter_def.h @@ -206,7 +206,7 @@ br_status poly_rewriter::mk_nflat_mul_core(unsigned num_args, expr * con numeral c(1); unsigned num_coeffs = 0; unsigned num_add = 0; - expr * var = 0; + expr * var = nullptr; for (unsigned i = 0; i < num_args; i++) { expr * arg = args[i]; if (is_numeral(arg, a)) { @@ -290,13 +290,13 @@ br_status poly_rewriter::mk_nflat_mul_core(unsigned num_args, expr * con if (!m_som || num_add == 0) { ptr_buffer new_args; - expr * prev = 0; + expr * prev = nullptr; bool ordered = true; for (unsigned i = 0; i < num_args; i++) { expr * curr = args[i]; if (is_numeral(curr)) continue; - if (prev != 0 && lt(curr, prev)) + if (prev != nullptr && lt(curr, prev)) ordered = false; new_args.push_back(curr); prev = curr; @@ -532,7 +532,7 @@ br_status poly_rewriter::mk_nflat_add_core(unsigned num_args, expr * con expr_fast_mark1 visited; // visited.is_marked(power_product) if the power_product occurs in args expr_fast_mark2 multiple; // multiple.is_marked(power_product) if power_product occurs more than once bool has_multiple = false; - expr * prev = 0; + expr * prev = nullptr; bool ordered = true; for (unsigned i = 0; i < num_args; i++) { expr * arg = args[i]; @@ -543,7 +543,7 @@ br_status poly_rewriter::mk_nflat_add_core(unsigned num_args, expr * con ordered = !m_sort_sums || i == 0; } else if (m_sort_sums && ordered) { - if (prev != 0 && lt(arg, prev)) + if (prev != nullptr && lt(arg, prev)) ordered = false; prev = arg; } @@ -874,8 +874,8 @@ br_status poly_rewriter::cancel_monomials(expr * lhs, expr * rhs, bool m const bool insert_c_rhs = c_at_rhs && (new_rhs_monomials.size() == 1 || !c.is_zero()); const unsigned lhs_offset = insert_c_lhs ? 0 : 1; const unsigned rhs_offset = insert_c_rhs ? 0 : 1; - new_rhs_monomials[0] = insert_c_rhs ? mk_numeral(c) : NULL; - new_lhs_monomials[0] = insert_c_lhs ? mk_numeral(c) : NULL; + new_rhs_monomials[0] = insert_c_rhs ? mk_numeral(c) : nullptr; + new_lhs_monomials[0] = insert_c_lhs ? mk_numeral(c) : nullptr; lhs_result = mk_add_app(new_lhs_monomials.size() - lhs_offset, new_lhs_monomials.c_ptr() + lhs_offset); rhs_result = mk_add_app(new_rhs_monomials.size() - rhs_offset, new_rhs_monomials.c_ptr() + rhs_offset); TRACE("mk_le_bug", tout << lhs_result << " " << rhs_result << "\n";); @@ -994,7 +994,7 @@ bool poly_rewriter::is_var_plus_ground(expr * n, bool & inv, var * & v, return false; ptr_buffer args; - v = 0; + v = nullptr; expr * curr = to_app(n); bool stop = false; inv = false; @@ -1013,12 +1013,12 @@ bool poly_rewriter::is_var_plus_ground(expr * n, bool & inv, var * & v, args.push_back(arg); } else if (is_var(arg)) { - if (v != 0) + if (v != nullptr) return false; // already found variable v = to_var(arg); } else if (is_times_minus_one(arg, neg_arg) && is_var(neg_arg)) { - if (v != 0) + if (v != nullptr) return false; // already found variable v = to_var(neg_arg); inv = true; @@ -1027,7 +1027,7 @@ bool poly_rewriter::is_var_plus_ground(expr * n, bool & inv, var * & v, return false; // non ground term. } } - if (v == 0) + if (v == nullptr) return false; // did not find variable SASSERT(!args.empty()); mk_add(args.size(), args.c_ptr(), t); diff --git a/src/ast/rewriter/pull_ite_tree.cpp b/src/ast/rewriter/pull_ite_tree.cpp index 651744bf9..61114387c 100644 --- a/src/ast/rewriter/pull_ite_tree.cpp +++ b/src/ast/rewriter/pull_ite_tree.cpp @@ -56,10 +56,10 @@ void pull_ite_tree::reduce(expr * n) { expr * c = to_app(n)->get_arg(0); expr * t_old = to_app(n)->get_arg(1); expr * e_old = to_app(n)->get_arg(2); - expr * t = 0; - proof * t_pr = 0; - expr * e = 0; - proof * e_pr = 0; + expr * t = nullptr; + proof * t_pr = nullptr; + expr * e = nullptr; + proof * e_pr = nullptr; get_cached(t_old, t, t_pr); get_cached(e_old, e, e_pr); expr_ref r(m_manager); @@ -67,7 +67,7 @@ void pull_ite_tree::reduce(expr * n) { r = m_rewriter.mk_app(to_app(n)->get_decl(), 3, args); if (!m_manager.proofs_enabled()) { // expr * r = m_manager.mk_ite(c, t, e); - cache_result(n, r, 0); + cache_result(n, r, nullptr); } else { // t_pr is a proof for (m_p ... t_old ...) == t @@ -83,15 +83,15 @@ void pull_ite_tree::reduce(expr * n) { proof * pr1 = m_manager.mk_rewrite(old, tmp1); // proof for (m_p ... (ite c t_old e_old) ...) = (ite c (m_p ... t_old ...) (m_p ... e_old ...)) expr_ref tmp2(m_manager); tmp2 = m_manager.mk_ite(c, t, e); // (ite c t e) - proof * pr2 = 0; // it will contain a proof for (ite c (m_p ... t_old ...) (m_p ... e_old ...)) = (ite c t e) - proof * pr3 = 0; // it will contain a proof for (m_p ... (ite c t_old e_old) ...) = (ite c t e) + proof * pr2 = nullptr; // it will contain a proof for (ite c (m_p ... t_old ...) (m_p ... e_old ...)) = (ite c t e) + proof * pr3 = nullptr; // it will contain a proof for (m_p ... (ite c t_old e_old) ...) = (ite c t e) proof * proofs[2]; unsigned num_proofs = 0; - if (t_pr != 0) { + if (t_pr != nullptr) { proofs[num_proofs] = t_pr; num_proofs++; } - if (e_pr != 0) { + if (e_pr != nullptr) { proofs[num_proofs] = e_pr; num_proofs++; } @@ -102,8 +102,8 @@ void pull_ite_tree::reduce(expr * n) { else { pr3 = pr1; } - proof * pr4 = 0; // it will contain a proof for (ite c t e) = r - proof * pr5 = 0; // it will contain a proof for (m_p ... (ite c t_old e_old) ...) = r + proof * pr4 = nullptr; // it will contain a proof for (ite c t e) = r + proof * pr5 = nullptr; // it will contain a proof for (m_p ... (ite c t_old e_old) ...) = r if (tmp2 != r) { pr4 = m_manager.mk_rewrite(tmp2, r); pr5 = m_manager.mk_transitivity(pr3, pr4); @@ -120,14 +120,14 @@ void pull_ite_tree::reduce(expr * n) { r = m_rewriter.mk_app(m_p, m_args.size(), m_args.c_ptr()); if (!m_manager.proofs_enabled()) { // expr * r = m_manager.mk_app(m_p, m_args.size(), m_args.c_ptr()); - cache_result(n, r, 0); + cache_result(n, r, nullptr); } else { expr_ref old(m_manager); proof * p; old = mk_p_arg(n); if (old == r) - p = 0; + p = nullptr; else p = m_manager.mk_rewrite(old, r); cache_result(n, r, p); @@ -139,7 +139,7 @@ void pull_ite_tree::operator()(app * n, app_ref & r, proof_ref & pr) { unsigned num_args = n->get_num_args(); m_args.resize(num_args); m_p = n->get_decl(); - expr * ite = 0; + expr * ite = nullptr; for (unsigned i = 0; i < num_args; i++) { expr * arg = n->get_arg(i); if (ite) { @@ -156,7 +156,7 @@ void pull_ite_tree::operator()(app * n, app_ref & r, proof_ref & pr) { } if (!ite) { r = n; - pr = 0; + pr = nullptr; return; } m_todo.push_back(ite); @@ -170,8 +170,8 @@ void pull_ite_tree::operator()(app * n, app_ref & r, proof_ref & pr) { } } SASSERT(is_cached(ite)); - expr * _r = 0; - proof * _pr = 0; + expr * _r = nullptr; + proof * _pr = nullptr; get_cached(ite, _r, _pr); r = to_app(_r); pr = _pr; diff --git a/src/ast/rewriter/push_app_ite.cpp b/src/ast/rewriter/push_app_ite.cpp index f3df4d711..411c61d8e 100644 --- a/src/ast/rewriter/push_app_ite.cpp +++ b/src/ast/rewriter/push_app_ite.cpp @@ -63,7 +63,7 @@ br_status push_app_ite_cfg::reduce_app(func_decl * f, unsigned num, expr * const return BR_FAILED; } app * ite = to_app(args[ite_arg_idx]); - expr * c = 0, * t = 0, * e = 0; + expr * c = nullptr, * t = nullptr, * e = nullptr; VERIFY(m.is_ite(ite, c, t, e)); expr ** args_prime = const_cast(args); expr * old = args_prime[ite_arg_idx]; diff --git a/src/ast/rewriter/rewriter.cpp b/src/ast/rewriter/rewriter.cpp index 36ad2dec4..4356f8f45 100644 --- a/src/ast/rewriter/rewriter.cpp +++ b/src/ast/rewriter/rewriter.cpp @@ -34,11 +34,11 @@ void rewriter_core::init_cache_stack() { void rewriter_core::del_cache_stack() { std::for_each(m_cache_stack.begin(), m_cache_stack.end(), delete_proc()); m_cache_stack.finalize(); - m_cache = 0; + m_cache = nullptr; if (m_proof_gen) { std::for_each(m_cache_pr_stack.begin(), m_cache_pr_stack.end(), delete_proc()); m_cache_pr_stack.finalize(); - m_cache_pr = 0; + m_cache_pr = nullptr; } } @@ -161,7 +161,7 @@ void rewriter_core::elim_reflex_prs(unsigned spos) { unsigned j = spos; for (unsigned i = spos; i < sz; i++) { proof * pr = m_result_pr_stack.get(i); - if (pr != 0) { + if (pr != nullptr) { if (i != j) m_result_pr_stack.set(j, pr); j++; @@ -192,7 +192,7 @@ void rewriter_core::reset() { m_result_stack.reset(); if (m_proof_gen) m_result_pr_stack.reset(); - m_root = 0; + m_root = nullptr; m_num_qvars = 0; m_scopes.reset(); } @@ -201,7 +201,7 @@ void rewriter_core::reset() { void rewriter_core::cleanup() { free_memory(); init_cache_stack(); - m_root = 0; + m_root = nullptr; m_num_qvars = 0; } diff --git a/src/ast/rewriter/rewriter_def.h b/src/ast/rewriter/rewriter_def.h index 5a3b930c8..658fb2e05 100644 --- a/src/ast/rewriter/rewriter_def.h +++ b/src/ast/rewriter/rewriter_def.h @@ -28,11 +28,11 @@ void rewriter_tpl::process_var(var * v) { SASSERT(v->get_sort() == m().get_sort(m_r)); if (ProofGen) { result_pr_stack().push_back(m_pr); - m_pr = 0; + m_pr = nullptr; } set_new_child_flag(v); TRACE("rewriter", tout << mk_ismt2_pp(v, m()) << " -> " << m_r << "\n";); - m_r = 0; + m_r = nullptr; return; } if (!ProofGen) { @@ -41,7 +41,7 @@ void rewriter_tpl::process_var(var * v) { if (idx < m_bindings.size()) { unsigned index = m_bindings.size() - idx - 1; var * r = (var*)(m_bindings[index]); - if (r != 0) { + if (r != nullptr) { CTRACE("rewriter", v->get_sort() != m().get_sort(r), tout << expr_ref(v, m()) << ":" << sort_ref(v->get_sort(), m()) << " != " << expr_ref(r, m()) << ":" << sort_ref(m().get_sort(r), m()); tout << "index " << index << " bindings " << m_bindings.size() << "\n"; @@ -67,14 +67,14 @@ void rewriter_tpl::process_var(var * v) { } result_stack().push_back(v); if (ProofGen) - result_pr_stack().push_back(0); // implicit reflexivity + result_pr_stack().push_back(nullptr); // implicit reflexivity } template template void rewriter_tpl::process_const(app * t) { SASSERT(t->get_num_args() == 0); - br_status st = m_cfg.reduce_app(t->get_decl(), 0, 0, m_r, m_pr); + br_status st = m_cfg.reduce_app(t->get_decl(), 0, nullptr, m_r, m_pr); SASSERT(st != BR_DONE || m().get_sort(m_r) == m().get_sort(t)); SASSERT(st == BR_FAILED || st == BR_DONE); if (st == BR_DONE) { @@ -84,15 +84,15 @@ void rewriter_tpl::process_const(app * t) { result_pr_stack().push_back(m_pr); else result_pr_stack().push_back(m().mk_rewrite(t, m_r)); - m_pr = 0; + m_pr = nullptr; } - m_r = 0; + m_r = nullptr; set_new_child_flag(t); } else { result_stack().push_back(t); if (ProofGen) - result_pr_stack().push_back(0); // implicit reflexivity + result_pr_stack().push_back(nullptr); // implicit reflexivity } } @@ -108,8 +108,8 @@ template template bool rewriter_tpl::visit(expr * t, unsigned max_depth) { TRACE("rewriter_visit", tout << "visiting\n" << mk_ismt2_pp(t, m()) << "\n";); - expr * new_t = 0; - proof * new_t_pr = 0; + expr * new_t = nullptr; + proof * new_t_pr = nullptr; if (m_cfg.get_subst(t, new_t, new_t_pr)) { TRACE("rewriter_subst", tout << "subst\n" << mk_ismt2_pp(t, m()) << "\n---->\n" << mk_ismt2_pp(new_t, m()) << "\n";); SASSERT(m().get_sort(t) == m().get_sort(new_t)); @@ -122,7 +122,7 @@ bool rewriter_tpl::visit(expr * t, unsigned max_depth) { if (max_depth == 0) { result_stack().push_back(t); if (ProofGen) - result_pr_stack().push_back(0); // implicit reflexivity + result_pr_stack().push_back(nullptr); // implicit reflexivity return true; // t is not going to be processed } SASSERT(max_depth > 0); @@ -150,7 +150,7 @@ bool rewriter_tpl::visit(expr * t, unsigned max_depth) { if (!pre_visit(t)) { result_stack().push_back(t); if (ProofGen) - result_pr_stack().push_back(0); // implicit reflexivity + result_pr_stack().push_back(nullptr); // implicit reflexivity return true; // t is not going to be processed } switch (t->get_kind()) { @@ -183,7 +183,7 @@ template bool rewriter_tpl::constant_fold(app * t, frame & fr) { if (fr.m_i == 1 && m().is_ite(t)) { expr * cond = result_stack()[fr.m_spos].get(); - expr* arg = 0; + expr* arg = nullptr; if (m().is_true(cond)) { arg = t->get_arg(1); } @@ -203,7 +203,7 @@ bool rewriter_tpl::constant_fold(app * t, frame & fr) { frame_stack().pop_back(); set_new_child_flag(t); } - m_r = 0; + m_r = nullptr; return true; } } @@ -255,7 +255,7 @@ void rewriter_tpl::process_app(app * t, frame & fr) { unsigned num_prs = result_pr_stack().size() - fr.m_spos; if (num_prs == 0) { new_t = t; - m_pr = 0; + m_pr = nullptr; } else { new_t = m().mk_app(f, new_num_args, new_args); @@ -278,16 +278,16 @@ void rewriter_tpl::process_app(app * t, frame & fr) { if (!m_pr2) m_pr2 = m().mk_rewrite(new_t, m_r); m_pr = m().mk_transitivity(m_pr, m_pr2); - m_pr2 = 0; + m_pr2 = nullptr; result_pr_stack().push_back(m_pr); } if (st == BR_DONE) { cache_result(t, m_r, m_pr, fr.m_cache_result); frame_stack().pop_back(); set_new_child_flag(t); - m_r = 0; + m_r = nullptr; if (ProofGen) - m_pr = 0; + m_pr = nullptr; return; } else { @@ -318,16 +318,16 @@ void rewriter_tpl::process_app(app * t, frame & fr) { cache_result(t, m_r, m_pr, fr.m_cache_result); frame_stack().pop_back(); set_new_child_flag(t); - m_r = 0; + m_r = nullptr; if (ProofGen) - m_pr = 0; + m_pr = nullptr; return; } else { // frame was created for processing m_r - m_r = 0; + m_r = nullptr; if (ProofGen) - m_pr = 0; + m_pr = nullptr; return; } } @@ -407,11 +407,11 @@ void rewriter_tpl::process_app(app * t, frame & fr) { if (ProofGen) { result_pr_stack().shrink(fr.m_spos); result_pr_stack().push_back(m_pr); - m_pr = 0; + m_pr = nullptr; } frame_stack().pop_back(); set_new_child_flag(t, m_r); - m_r = 0; + m_r = nullptr; return; } case REWRITE_BUILTIN: @@ -514,7 +514,7 @@ void rewriter_tpl::process_quantifier(quantifier * q, frame & fr) { } if (ProofGen) { quantifier_ref new_q(m().update_quantifier(q, num_pats, new_pats.c_ptr(), num_no_pats, new_no_pats.c_ptr(), new_body), m()); - m_pr = q == new_q ? 0 : m().mk_quant_intro(q, new_q, result_pr_stack().get(fr.m_spos)); + m_pr = q == new_q ? nullptr : m().mk_quant_intro(q, new_q, result_pr_stack().get(fr.m_spos)); m_r = new_q; proof_ref pr2(m()); if (m_cfg.reduce_quantifier(new_q, new_body, new_pats.c_ptr(), new_no_pats.c_ptr(), m_r, pr2)) { @@ -550,9 +550,9 @@ void rewriter_tpl::process_quantifier(quantifier * q, frame & fr) { } else { cache_result(q, m_r, m_pr, fr.m_cache_result); - m_pr = 0; + m_pr = nullptr; } - m_r = 0; + m_r = nullptr; frame_stack().pop_back(); set_new_child_flag(q, m_r); } @@ -656,7 +656,7 @@ void rewriter_tpl::main_loop(expr * t, expr_ref & result, proof_ref & re if (ProofGen) { result_pr = result_pr_stack().back(); result_pr_stack().pop_back(); - if (result_pr.get() == 0) + if (result_pr.get() == nullptr) result_pr = m().mk_reflexivity(t); SASSERT(result_pr_stack().empty()); } @@ -721,7 +721,7 @@ void rewriter_tpl::resume_core(expr_ref & result, proof_ref & result_pr) if (ProofGen) { result_pr = result_pr_stack().back(); result_pr_stack().pop_back(); - if (result_pr.get() == 0) + if (result_pr.get() == nullptr) result_pr = m().mk_reflexivity(m_root); SASSERT(result_pr_stack().empty()); } diff --git a/src/ast/rewriter/seq_rewriter.cpp b/src/ast/rewriter/seq_rewriter.cpp index 5fb85d6bb..387e5d6f2 100644 --- a/src/ast/rewriter/seq_rewriter.cpp +++ b/src/ast/rewriter/seq_rewriter.cpp @@ -190,7 +190,7 @@ public: }*/ }; -re2automaton::re2automaton(ast_manager& m): m(m), u(m), bv(m), m_ba(0), m_sa(0) {} +re2automaton::re2automaton(ast_manager& m): m(m), u(m), bv(m), m_ba(nullptr), m_sa(nullptr) {} re2automaton::~re2automaton() {} @@ -288,7 +288,7 @@ eautomaton* re2automaton::re2aut(expr* e) { } else if (u.re.is_full_seq(e)) { expr_ref tt(m.mk_true(), m); - sort *seq_s = 0, *char_s = 0; + sort *seq_s = nullptr, *char_s = nullptr; VERIFY (u.is_re(m.get_sort(e), seq_s)); VERIFY (u.is_seq(seq_s, char_s)); sym_expr* _true = sym_expr::mk_pred(tt, char_s); @@ -296,7 +296,7 @@ eautomaton* re2automaton::re2aut(expr* e) { } else if (u.re.is_full_char(e)) { expr_ref tt(m.mk_true(), m); - sort *seq_s = 0, *char_s = 0; + sort *seq_s = nullptr, *char_s = nullptr; VERIFY (u.is_re(m.get_sort(e), seq_s)); VERIFY (u.is_seq(seq_s, char_s)); sym_expr* _true = sym_expr::mk_pred(tt, char_s); @@ -307,7 +307,7 @@ eautomaton* re2automaton::re2aut(expr* e) { return m_sa->mk_product(*a, *b); } - return 0; + return nullptr; } eautomaton* re2automaton::seq2aut(expr* e) { @@ -335,7 +335,7 @@ eautomaton* re2automaton::seq2aut(expr* e) { } return alloc(eautomaton, sm, init, final, mvs); } - return 0; + return nullptr; } br_status seq_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { @@ -993,14 +993,14 @@ br_status seq_rewriter::mk_seq_suffix(expr* a, expr* b, expr_ref& result) { bool isc1 = false; bool isc2 = false; - expr *a1 = 0, *a2 = 0, *b1 = 0, *b2 = 0; + expr *a1 = nullptr, *a2 = nullptr, *b1 = nullptr, *b2 = nullptr; if (m_util.str.is_concat(a, a1, a2) && m_util.str.is_string(a2, s1)) { isc1 = true; } else if (m_util.str.is_string(a, s1)) { isc1 = true; a2 = a; - a1 = 0; + a1 = nullptr; } if (m_util.str.is_concat(b, b1, b2) && m_util.str.is_string(b2, s2)) { @@ -1009,7 +1009,7 @@ br_status seq_rewriter::mk_seq_suffix(expr* a, expr* b, expr_ref& result) { else if (m_util.str.is_string(b, s2)) { isc2 = true; b2 = b; - b1 = 0; + b1 = nullptr; } if (isc1 && isc2) { if (s1.length() == s2.length()) { @@ -1019,7 +1019,7 @@ br_status seq_rewriter::mk_seq_suffix(expr* a, expr* b, expr_ref& result) { } else if (s1.length() < s2.length()) { bool suffix = s1.suffixof(s2); - if (suffix && a1 == 0) { + if (suffix && a1 == nullptr) { result = m().mk_true(); return BR_DONE; } @@ -1036,7 +1036,7 @@ br_status seq_rewriter::mk_seq_suffix(expr* a, expr* b, expr_ref& result) { } else { SASSERT(s1.length() > s2.length()); - if (b1 == 0) { + if (b1 == nullptr) { result = m().mk_false(); return BR_DONE; } @@ -1475,13 +1475,13 @@ br_status seq_rewriter::mk_re_star(expr* a, expr_ref& result) { return BR_DONE; } if (m_util.re.is_full_char(a)) { - sort* seq_sort = 0; + sort* seq_sort = nullptr; VERIFY(m_util.is_re(a, seq_sort)); result = m_util.re.mk_full_seq(seq_sort); return BR_DONE; } if (m_util.re.is_empty(a)) { - sort* seq_sort = 0; + sort* seq_sort = nullptr; VERIFY(m_util.is_re(a, seq_sort)); result = m_util.re.mk_to_re(m_util.str.mk_empty(seq_sort)); return BR_DONE; @@ -1559,7 +1559,7 @@ br_status seq_rewriter::mk_re_plus(expr* a, expr_ref& result) { } br_status seq_rewriter::mk_re_opt(expr* a, expr_ref& result) { - sort* s = 0; + sort* s = nullptr; VERIFY(m_util.is_re(a, s)); result = m_util.re.mk_union(m_util.re.mk_to_re(m_util.str.mk_empty(s)), a); return BR_REWRITE1; @@ -1883,7 +1883,7 @@ expr* seq_rewriter::concat_non_empty(unsigned n, expr* const* as) { bool seq_rewriter::set_empty(unsigned sz, expr* const* es, bool all, expr_ref_vector& lhs, expr_ref_vector& rhs) { zstring s; - expr* emp = 0; + expr* emp = nullptr; for (unsigned i = 0; i < sz; ++i) { if (m_util.str.is_unit(es[i])) { if (all) return false; diff --git a/src/ast/rewriter/th_rewriter.cpp b/src/ast/rewriter/th_rewriter.cpp index a2ca12b24..f5a0ff0f7 100644 --- a/src/ast/rewriter/th_rewriter.cpp +++ b/src/ast/rewriter/th_rewriter.cpp @@ -440,8 +440,8 @@ struct th_rewriter_cfg : public default_rewriter_cfg { } if (num1 != num2 && num1 != num2 + 1 && num1 != num2 - 1) return false; - new_t1 = 0; - new_t2 = 0; + new_t1 = nullptr; + new_t2 = nullptr; expr_fast_mark1 visited1; expr_fast_mark2 visited2; for (unsigned i = 0; i < num1; i++) { @@ -533,7 +533,7 @@ struct th_rewriter_cfg : public default_rewriter_cfg { expr * c = args[0]; expr * t = args[1]; expr * e = args[2]; - func_decl * f_prime = 0; + func_decl * f_prime = nullptr; expr_ref new_t(m()), new_e(m()), common(m()); bool first; TRACE("push_ite", tout << "unifying:\n" << mk_ismt2_pp(t, m()) << "\n" << mk_ismt2_pp(e, m()) << "\n";); @@ -559,7 +559,7 @@ struct th_rewriter_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; br_status st = reduce_app_core(f, num, args, result); if (st != BR_DONE && st != BR_FAILED) { CTRACE("th_rewriter_step", st != BR_FAILED, @@ -604,7 +604,7 @@ struct th_rewriter_cfg : public default_rewriter_cfg { expr_ref & result, proof_ref & result_pr) { quantifier_ref q1(m()); - proof * p1 = 0; + proof * p1 = nullptr; if (is_quantifier(new_body) && to_quantifier(new_body)->is_forall() == old_q->is_forall() && !old_q->has_patterns() && @@ -627,7 +627,7 @@ struct th_rewriter_cfg : public default_rewriter_cfg { std::min(old_q->get_weight(), nested_q->get_weight()), old_q->get_qid(), old_q->get_skid(), - 0, 0, 0, 0); + 0, nullptr, 0, nullptr); SASSERT(is_well_sorted(m(), q1)); @@ -657,9 +657,9 @@ struct th_rewriter_cfg : public default_rewriter_cfg { TRACE("reduce_quantifier", tout << "after elim_unused_vars:\n" << mk_ismt2_pp(result, m()) << "\n";); - result_pr = 0; + result_pr = nullptr; if (m().proofs_enabled()) { - proof * p2 = 0; + proof * p2 = nullptr; if (q1.get() != result.get()) p2 = m().mk_elim_unused_vars(q1, result); result_pr = m().mk_transitivity(p1, p2); @@ -680,7 +680,7 @@ struct th_rewriter_cfg : public default_rewriter_cfg { m_a_util(m), m_bv_util(m), m_used_dependencies(m), - m_subst(0) { + m_subst(nullptr) { updt_local_params(p); } @@ -690,13 +690,13 @@ struct th_rewriter_cfg : public default_rewriter_cfg { } void reset() { - m_subst = 0; + m_subst = nullptr; } bool get_subst(expr * s, expr * & t, proof * & pr) { - if (m_subst == 0) + if (m_subst == nullptr) return false; - expr_dependency * d = 0; + expr_dependency * d = nullptr; if (m_subst->find(s, t, pr, d)) { m_used_dependencies = m().mk_join(m_used_dependencies, d); return true; @@ -798,9 +798,9 @@ expr_dependency * th_rewriter::get_used_dependencies() { } void th_rewriter::reset_used_dependencies() { - if (get_used_dependencies() != 0) { + if (get_used_dependencies() != nullptr) { set_substitution(m_imp->cfg().m_subst); // reset cache preserving subst - m_imp->cfg().m_used_dependencies = 0; + m_imp->cfg().m_used_dependencies = nullptr; } } diff --git a/src/ast/rewriter/var_subst.cpp b/src/ast/rewriter/var_subst.cpp index 756e62a5f..97e0ddb19 100644 --- a/src/ast/rewriter/var_subst.cpp +++ b/src/ast/rewriter/var_subst.cpp @@ -94,7 +94,7 @@ void unused_vars_eliminator::operator()(quantifier* q, expr_ref & result) { } else { num_removed++; - var_mapping.push_back(0); + var_mapping.push_back(nullptr); } } // (VAR 0) is in the first position of var_mapping. @@ -104,7 +104,7 @@ void unused_vars_eliminator::operator()(quantifier* q, expr_ref & result) { if (s) var_mapping.push_back(m.mk_var(i - num_removed, s)); else - var_mapping.push_back(0); + var_mapping.push_back(nullptr); } diff --git a/src/ast/seq_decl_plugin.cpp b/src/ast/seq_decl_plugin.cpp index 2790c5c48..91aeeac3b 100644 --- a/src/ast/seq_decl_plugin.cpp +++ b/src/ast/seq_decl_plugin.cpp @@ -339,9 +339,9 @@ bool operator<(const zstring& lhs, const zstring& rhs) { seq_decl_plugin::seq_decl_plugin(): m_init(false), m_stringc_sym("String"), m_charc_sym("Char"), - m_string(0), - m_char(0), - m_re(0) {} + m_string(nullptr), + m_char(nullptr), + m_re(nullptr) {} void seq_decl_plugin::finalize() { for (unsigned i = 0; i < m_sigs.size(); ++i) @@ -524,7 +524,7 @@ void seq_decl_plugin::init() { m_sigs.resize(LAST_SEQ_OP); // TBD: have (par ..) construct and load parameterized signature from premable. m_sigs[OP_SEQ_UNIT] = alloc(psig, m, "seq.unit", 1, 1, &A, seqA); - m_sigs[OP_SEQ_EMPTY] = alloc(psig, m, "seq.empty", 1, 0, 0, seqA); + m_sigs[OP_SEQ_EMPTY] = alloc(psig, m, "seq.empty", 1, 0, nullptr, seqA); m_sigs[OP_SEQ_CONCAT] = alloc(psig, m, "seq.++", 1, 2, seqAseqA, seqA); m_sigs[OP_SEQ_PREFIX] = alloc(psig, m, "seq.prefixof", 1, 2, seqAseqA, boolT); m_sigs[OP_SEQ_SUFFIX] = alloc(psig, m, "seq.suffixof", 1, 2, seqAseqA, boolT); @@ -543,9 +543,9 @@ void seq_decl_plugin::init() { m_sigs[OP_RE_INTERSECT] = alloc(psig, m, "re.inter", 1, 2, reAreA, reA); m_sigs[OP_RE_LOOP] = alloc(psig, m, "re.loop", 1, 1, &reA, reA); m_sigs[OP_RE_COMPLEMENT] = alloc(psig, m, "re.complement", 1, 1, &reA, reA); - m_sigs[OP_RE_EMPTY_SET] = alloc(psig, m, "re.empty", 1, 0, 0, reA); - m_sigs[OP_RE_FULL_SEQ_SET] = alloc(psig, m, "re.all", 1, 0, 0, reA); - m_sigs[OP_RE_FULL_CHAR_SET] = alloc(psig, m, "re.allchar", 1, 0, 0, reA); + m_sigs[OP_RE_EMPTY_SET] = alloc(psig, m, "re.empty", 1, 0, nullptr, reA); + m_sigs[OP_RE_FULL_SEQ_SET] = alloc(psig, m, "re.all", 1, 0, nullptr, reA); + m_sigs[OP_RE_FULL_CHAR_SET] = alloc(psig, m, "re.allchar", 1, 0, nullptr, reA); m_sigs[OP_RE_OF_PRED] = alloc(psig, m, "re.of.pred", 1, 1, &predA, reA); m_sigs[OP_SEQ_TO_RE] = alloc(psig, m, "seq.to.re", 1, 1, &seqA, reA); m_sigs[OP_SEQ_IN_RE] = alloc(psig, m, "seq.in.re", 1, 2, seqAreA, boolT); @@ -562,8 +562,8 @@ void seq_decl_plugin::init() { m_sigs[_OP_STRING_SUFFIX] = alloc(psig, m, "str.suffixof", 0, 2, str2T, boolT); m_sigs[_OP_STRING_IN_REGEXP] = alloc(psig, m, "str.in.re", 0, 2, strTreT, boolT); m_sigs[_OP_STRING_TO_REGEXP] = alloc(psig, m, "str.to.re", 0, 1, &strT, reT); - m_sigs[_OP_REGEXP_EMPTY] = alloc(psig, m, "re.nostr", 0, 0, 0, reT); - m_sigs[_OP_REGEXP_FULL_CHAR] = alloc(psig, m, "re.allchar", 0, 0, 0, reT); + m_sigs[_OP_REGEXP_EMPTY] = alloc(psig, m, "re.nostr", 0, 0, nullptr, reT); + m_sigs[_OP_REGEXP_FULL_CHAR] = alloc(psig, m, "re.allchar", 0, 0, nullptr, reT); m_sigs[_OP_STRING_SUBSTR] = alloc(psig, m, "str.substr", 0, 3, strTint2T, strT); m_sigs[_OP_RE_UNROLL] = alloc(psig, m, "_re.unroll", 0, 2, reTintT, strT); } @@ -609,7 +609,7 @@ sort * seq_decl_plugin::mk_sort(decl_kind k, unsigned num_parameters, parameter return m_string; default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -650,7 +650,7 @@ func_decl * seq_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, match(*m_sigs[k], arity, domain, range, rng); if (rng == m_string) { parameter param(symbol("")); - return mk_func_decl(OP_STRING_CONST, 1, ¶m, 0, 0, m_string); + return mk_func_decl(OP_STRING_CONST, 1, ¶m, 0, nullptr, m_string); } else { parameter param(rng.get()); @@ -819,7 +819,7 @@ func_decl * seq_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, } default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -921,7 +921,7 @@ expr* seq_decl_plugin::get_some_value(sort* s) { return util.re.mk_to_re(util.str.mk_empty(seq)); } UNREACHABLE(); - return 0; + return nullptr; } app* seq_util::mk_skolem(symbol const& name, unsigned n, expr* const* args, sort* range) { @@ -978,15 +978,15 @@ app* seq_util::re::mk_loop(expr* r, unsigned lo, unsigned hi) { } app* seq_util::re::mk_full_char(sort* s) { - return m.mk_app(m_fid, OP_RE_FULL_CHAR_SET, 0, 0, 0, 0, s); + return m.mk_app(m_fid, OP_RE_FULL_CHAR_SET, 0, nullptr, 0, nullptr, s); } app* seq_util::re::mk_full_seq(sort* s) { - return m.mk_app(m_fid, OP_RE_FULL_SEQ_SET, 0, 0, 0, 0, s); + return m.mk_app(m_fid, OP_RE_FULL_SEQ_SET, 0, nullptr, 0, nullptr, s); } app* seq_util::re::mk_empty(sort* s) { - return m.mk_app(m_fid, OP_RE_EMPTY_SET, 0, 0, 0, 0, s); + return m.mk_app(m_fid, OP_RE_EMPTY_SET, 0, nullptr, 0, nullptr, s); } diff --git a/src/ast/seq_decl_plugin.h b/src/ast/seq_decl_plugin.h index e765e69a4..8bd4d2807 100644 --- a/src/ast/seq_decl_plugin.h +++ b/src/ast/seq_decl_plugin.h @@ -233,8 +233,8 @@ public: str(seq_util& u): u(u), m(u.m), m_fid(u.m_fid) {} sort* mk_seq(sort* s) { parameter param(s); return m.mk_sort(m_fid, SEQ_SORT, 1, ¶m); } - sort* mk_string_sort() const { return m.mk_sort(m_fid, _STRING_SORT, 0, 0); } - app* mk_empty(sort* s) const { return m.mk_const(m.mk_func_decl(m_fid, OP_SEQ_EMPTY, 0, 0, 0, (expr*const*)0, s)); } + sort* mk_string_sort() const { return m.mk_sort(m_fid, _STRING_SORT, 0, nullptr); } + app* mk_empty(sort* s) const { return m.mk_const(m.mk_func_decl(m_fid, OP_SEQ_EMPTY, 0, nullptr, 0, (expr*const*)nullptr, s)); } app* mk_string(zstring const& s); app* mk_string(symbol const& s) { return u.seq.mk_string(s); } app* mk_char(char ch); diff --git a/src/ast/substitution/expr_offset.h b/src/ast/substitution/expr_offset.h index 1f27f222a..ee098053f 100644 --- a/src/ast/substitution/expr_offset.h +++ b/src/ast/substitution/expr_offset.h @@ -30,7 +30,7 @@ class expr_offset { expr * m_expr; unsigned m_offset; public: - expr_offset():m_expr(0), m_offset(0) {} + expr_offset():m_expr(nullptr), m_offset(0) {} expr_offset(expr * e, unsigned o):m_expr(e), m_offset(o) {} expr * get_expr() const { return m_expr; } diff --git a/src/ast/substitution/substitution.cpp b/src/ast/substitution/substitution.cpp index d54a8e057..39e9e07a2 100644 --- a/src/ast/substitution/substitution.cpp +++ b/src/ast/substitution/substitution.cpp @@ -79,13 +79,13 @@ void substitution::apply(unsigned num_actual_offsets, unsigned const * deltas, e // It is incorrect to cache results between different calls if we are applying a substitution // modulo a substitution s -> t. - if (m_state == INSERT || s != expr_offset(0,0)) + if (m_state == INSERT || s != expr_offset(nullptr,0)) reset_cache(); m_state = APPLY; unsigned j; - expr * e = 0; + expr * e = nullptr; unsigned off; expr_offset n1; bool visited; @@ -146,7 +146,7 @@ void substitution::apply(unsigned num_actual_offsets, unsigned const * deltas, e bool has_new_args = false; for (unsigned i = 0; i < num_args; i++) { expr * arg = to_app(e)->get_arg(i); - expr * new_arg = 0; + expr * new_arg = nullptr; VERIFY(m_apply_cache.find(expr_offset(arg, off), new_arg)); new_args.push_back(new_arg); @@ -185,10 +185,10 @@ void substitution::apply(unsigned num_actual_offsets, unsigned const * deltas, e } expr_offset body(q->get_expr(), off); expr_ref s1_ref(m_manager), t1_ref(m_manager); - if (s.get_expr() != 0) { + if (s.get_expr() != nullptr) { var_sh(s.get_expr(), num_vars, s1_ref); } - if (t.get_expr() != 0) { + if (t.get_expr() != nullptr) { var_sh(t.get_expr(), num_vars, t1_ref); } expr_offset s1(s1_ref, s.get_offset()); @@ -218,7 +218,7 @@ void substitution::apply(unsigned num_actual_offsets, unsigned const * deltas, e m_new_exprs.push_back(e); result = e; - if (s != expr_offset(0,0)) + if (s != expr_offset(nullptr,0)) reset_cache(); TRACE("subst_bug", tout << "END substitution::apply\nresult:\n" << mk_pp(e, m_manager) << "\nref_count: " << e->get_ref_count() << "\n";); diff --git a/src/ast/substitution/substitution.h b/src/ast/substitution/substitution.h index 0d318e4fb..5f1288fd7 100644 --- a/src/ast/substitution/substitution.h +++ b/src/ast/substitution/substitution.h @@ -178,7 +178,7 @@ public: to the variable x+delta[i]. */ void apply(unsigned num_actual_offsets, unsigned const * deltas, expr_offset const & n, expr_ref & result) { - apply(num_actual_offsets, deltas, n, expr_offset(0, 0), expr_offset(0, 0), result); + apply(num_actual_offsets, deltas, n, expr_offset(nullptr, 0), expr_offset(nullptr, 0), result); } /** diff --git a/src/ast/substitution/substitution_tree.cpp b/src/ast/substitution/substitution_tree.cpp index 20d5f1590..809197c8f 100644 --- a/src/ast/substitution/substitution_tree.cpp +++ b/src/ast/substitution/substitution_tree.cpp @@ -172,7 +172,7 @@ substitution_tree::node * substitution_tree::find_best_child(node * r) { #ifdef Z3DEBUG unsigned todo_size = m_todo.size(); #endif - node * best_child = 0; + node * best_child = nullptr; unsigned max_measure = 0; node * curr_child = r->m_first_child; while (curr_child) { @@ -335,7 +335,7 @@ void substitution_tree::insert(app * new_expr) { else { mark_used_regs(r->m_subst); node * best_child = find_best_child(r); - if (best_child == 0) { + if (best_child == nullptr) { // there is no compatible child node * n = mk_node_for(new_expr); n->m_next_sibling = r->m_first_child; @@ -414,7 +414,7 @@ bool substitution_tree::is_fully_compatible(svector const & sv) { */ bool substitution_tree::find_fully_compatible_child(node * r, node * & prev, node * & child) { SASSERT(!r->m_leaf); - prev = 0; + prev = nullptr; child = r->m_first_child; while (child) { if (is_fully_compatible(child->m_subst)) @@ -462,8 +462,8 @@ void substitution_tree::erase(app * e) { m_todo.push_back(0); node * r = m_roots[id]; - node * parent = 0; - node * prev = 0; + node * parent = nullptr; + node * prev = nullptr; while (true) { svector & sv = r->m_subst; @@ -495,12 +495,12 @@ void substitution_tree::erase(app * e) { if (m_todo.empty()) { reset_registers(0); SASSERT(r->m_expr == e); - if (parent == 0) { + if (parent == nullptr) { delete_node(r); m_roots[id] = 0; } else if (at_least_3_children(parent)) { - if (prev == 0) + if (prev == nullptr) parent->m_first_child = r->m_next_sibling; else prev->m_next_sibling = r->m_next_sibling; @@ -843,7 +843,7 @@ void substitution_tree::visit(expr * e, st_visitor & st, unsigned in_offset, uns ptr_vector::iterator end = m_roots.end(); for (; it != end; ++it) { node * r = *it; - if (r != 0) { + if (r != nullptr) { var * v = r->m_subst[0].first; if (v->get_sort() == to_var(e)->get_sort()) if (!visit(e, st, r)) @@ -878,7 +878,7 @@ void substitution_tree::display(std::ostream & out) const { ptr_vector::const_iterator end2 = m_vars.end(); for (; it2 != end2; ++it2) { var_ref_vector * v = *it2; - if (v == 0) + if (v == nullptr) continue; // m_vars may contain null pointers. See substitution_tree::insert. unsigned num = v->size(); for (unsigned i = 0; i < num; i++) { diff --git a/src/ast/substitution/substitution_tree.h b/src/ast/substitution/substitution_tree.h index 7a8c30a63..018bee471 100644 --- a/src/ast/substitution/substitution_tree.h +++ b/src/ast/substitution/substitution_tree.h @@ -50,7 +50,7 @@ class substitution_tree { node * m_first_child; expr * m_expr; }; - node(bool leaf):m_leaf(leaf), m_next_sibling(0), m_first_child(0) {} + node(bool leaf):m_leaf(leaf), m_next_sibling(nullptr), m_first_child(nullptr) {} }; ast_manager & m_manager; diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index f1357126c..0c9c5360c 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -56,7 +56,7 @@ public: cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_SYMBOL; } void set_next_arg(cmd_context & ctx, symbol const & s) override { cmd * c = ctx.find_cmd(s); - if (c == 0) { + if (c == nullptr) { std::string err_msg("unknown command '"); err_msg = err_msg + s.bare_str() + "'"; throw cmd_exception(err_msg); @@ -109,7 +109,7 @@ public: cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_UINT; } void set_next_arg(cmd_context & ctx, unsigned index) override { m_index = index; } void execute(cmd_context & ctx) override { - if (!ctx.is_model_available() || ctx.get_check_sat_result() == 0) + if (!ctx.is_model_available() || ctx.get_check_sat_result() == nullptr) throw cmd_exception("model is not available"); model_ref m; if (m_index > 0 && ctx.get_opt()) { @@ -785,7 +785,7 @@ public: } void execute(cmd_context & ctx) override { psort_decl * array_sort = ctx.find_psort_decl(m_array_sort); - if (array_sort == 0) + if (array_sort == nullptr) throw cmd_exception("Array sort is not available"); ptr_vector & array_sort_args = m_domain; sort_ref_buffer domain(ctx.m()); @@ -892,7 +892,7 @@ void install_ext_basic_cmds(cmd_context & ctx) { ctx.insert(alloc(echo_cmd)); ctx.insert(alloc(labels_cmd)); ctx.insert(alloc(declare_map_cmd)); - ctx.insert(alloc(builtin_cmd, "reset", 0, "reset the shell (all declarations and assertions will be erased)")); + ctx.insert(alloc(builtin_cmd, "reset", nullptr, "reset the shell (all declarations and assertions will be erased)")); install_simplify_cmd(ctx); install_eval_cmd(ctx); } diff --git a/src/cmd_context/check_logic.cpp b/src/cmd_context/check_logic.cpp index dd08ac9db..55be27c6d 100644 --- a/src/cmd_context/check_logic.cpp +++ b/src/cmd_context/check_logic.cpp @@ -328,17 +328,17 @@ struct check_logic::imp { bool is_offset(app * t) { while (true) { - expr * non_numeral = 0; + expr * non_numeral = nullptr; unsigned num_args = t->get_num_args(); for (unsigned i = 0; i < num_args; i++) { expr * arg = t->get_arg(i); if (is_numeral(arg)) continue; - if (non_numeral != 0) + if (non_numeral != nullptr) return false; non_numeral = arg; } - if (non_numeral == 0) + if (non_numeral == nullptr) return true; if (is_diff_var(non_numeral)) return true; @@ -501,7 +501,7 @@ struct check_logic::imp { }; check_logic::check_logic() { - m_imp = 0; + m_imp = nullptr; } check_logic::~check_logic() { @@ -512,7 +512,7 @@ check_logic::~check_logic() { void check_logic::reset() { if (m_imp) dealloc(m_imp); - m_imp = 0; + m_imp = nullptr; } void check_logic::set_logic(ast_manager & m, symbol const & logic) { diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index c6c36606a..436e1b538 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -67,7 +67,7 @@ void func_decls::finalize(ast_manager & m) { } dealloc(fs); } - m_decls = 0; + m_decls = nullptr; } bool func_decls::signatures_collide(func_decl* f, func_decl* g) const { @@ -116,7 +116,7 @@ bool func_decls::insert(ast_manager & m, func_decl * f) { if (contains(f)) return false; m.inc_ref(f); - if (m_decls == 0) { + if (m_decls == nullptr) { m_decls = TAG(func_decl*, f, 0); } else if (GET_TAG(m_decls) == 0) { @@ -137,7 +137,7 @@ void func_decls::erase(ast_manager & m, func_decl * f) { return; if (GET_TAG(m_decls) == 0) { m.dec_ref(f); - m_decls = 0; + m_decls = nullptr; } else { func_decl_set * fs = UNTAG(func_decl_set *, m_decls); @@ -145,7 +145,7 @@ void func_decls::erase(ast_manager & m, func_decl * f) { m.dec_ref(f); if (fs->empty()) { dealloc(fs); - m_decls = 0; + m_decls = nullptr; } } } @@ -154,7 +154,7 @@ void func_decls::erase(ast_manager & m, func_decl * f) { \brief Return true if func_decls contains a declaration different from f, but with the same domain. */ bool func_decls::clash(func_decl * f) const { - if (m_decls == 0) + if (m_decls == nullptr) return false; if (GET_TAG(m_decls) == 0) return false; @@ -176,15 +176,15 @@ bool func_decls::clash(func_decl * f) const { } bool func_decls::more_than_one() const { - if (m_decls == 0 || GET_TAG(m_decls) == 0) + if (m_decls == nullptr || GET_TAG(m_decls) == 0) return false; func_decl_set * fs = UNTAG(func_decl_set *, m_decls); return fs->size() > 1; } func_decl * func_decls::first() const { - if (m_decls == 0) - return 0; + if (m_decls == nullptr) + return nullptr; if (GET_TAG(m_decls) == 0) return UNTAG(func_decl*, m_decls); func_decl_set * fs = UNTAG(func_decl_set *, m_decls); @@ -197,7 +197,7 @@ func_decl * func_decls::find(unsigned arity, sort * const * domain, sort * range return first(); func_decl_set * fs = UNTAG(func_decl_set *, m_decls); for (func_decl * f : *fs) { - if (range != 0 && f->get_range() != range) + if (range != nullptr && f->get_range() != range) continue; if (f->get_arity() != arity) continue; @@ -209,7 +209,7 @@ func_decl * func_decls::find(unsigned arity, sort * const * domain, sort * range if (i == arity) return f; } - return 0; + return nullptr; } func_decl * func_decls::find(ast_manager & m, unsigned num_args, expr * const * args, sort * range) const { @@ -257,7 +257,7 @@ bool macro_decls::insert(ast_manager& m, unsigned arity, sort *const* domain, ex } expr* macro_decls::find(unsigned arity, sort *const* domain) const { - if (!m_decls) return 0; + if (!m_decls) return nullptr; for (auto v : *m_decls) { if (v.m_domain.size() != arity) continue; bool eq = true; @@ -266,7 +266,7 @@ expr* macro_decls::find(unsigned arity, sort *const* domain) const { } if (eq) return v.m_body; } - return 0; + return nullptr; } void macro_decls::erase_last(ast_manager& m) { @@ -291,7 +291,7 @@ bool cmd_context::contains_macro(symbol const& s, func_decl* f) const { bool cmd_context::contains_macro(symbol const& s, unsigned arity, sort *const* domain) const { macro_decls decls; - return m_macros.find(s, decls) && 0 != decls.find(arity, domain); + return m_macros.find(s, decls) && nullptr != decls.find(arity, domain); } void cmd_context::insert_macro(symbol const& s, unsigned arity, sort*const* domain, expr* t) { @@ -472,11 +472,11 @@ cmd_context::cmd_context(bool main_ctx, ast_manager * m, symbol const & l): m_processing_pareto(false), m_exit_on_error(false), m_manager(m), - m_own_manager(m == 0), + m_own_manager(m == nullptr), m_manager_initialized(false), m_rec_fun_declared(false), - m_pmanager(0), - m_sexpr_manager(0), + m_pmanager(nullptr), + m_sexpr_manager(nullptr), m_regular("stdout", std::cout), m_diagnostic("stderr", std::cerr) { SASSERT(m != 0 || !has_manager()); @@ -498,8 +498,8 @@ cmd_context::~cmd_context() { finalize_tactic_cmds(); finalize_probes(); reset(true); - m_solver = 0; - m_check_sat_result = 0; + m_solver = nullptr; + m_check_sat_result = nullptr; } void cmd_context::set_cancel(bool f) { @@ -593,7 +593,7 @@ bool cmd_context::validate_model_enabled() const { } cmd_context::check_sat_state cmd_context::cs_state() const { - if (m_check_sat_result.get() == 0) + if (m_check_sat_result.get() == nullptr) return css_clear; switch (m_check_sat_result->status()) { case l_true: return css_sat; @@ -741,7 +741,7 @@ void cmd_context::init_manager() { else { m_manager_initialized = true; SASSERT(m_pmanager == 0); - m_check_sat_result = 0; + m_check_sat_result = nullptr; m_manager = m_params.mk_ast_manager(); m_pmanager = alloc(pdecl_manager, *m_manager); init_manager_core(true); @@ -771,7 +771,7 @@ bool cmd_context::set_logic(symbol const & s) { } std::string cmd_context::reason_unknown() const { - if (m_check_sat_result.get() == 0) + if (m_check_sat_result.get() == nullptr) return "state of the most recent check-sat command is not known"; return m_check_sat_result->reason_unknown(); } @@ -861,7 +861,7 @@ void cmd_context::insert_user_tactic(symbol const & s, sexpr * d) { void cmd_context::insert(symbol const & s, object_ref * r) { r->inc_ref(*this); - object_ref * old_r = 0; + object_ref * old_r = nullptr; if (m_object_refs.find(s, old_r)) { old_r->dec_ref(*this); } @@ -905,8 +905,8 @@ func_decl * cmd_context::find_func_decl(symbol const & s) const { try { // Remark: ignoring m_next of d. We do not allow two different theories to define the same constant name. func_decl * f; - f = m().mk_func_decl(d.m_fid, d.m_decl, 0, 0, 0, static_cast(0), 0); - if (f != 0) + f = m().mk_func_decl(d.m_fid, d.m_decl, 0, nullptr, 0, static_cast(nullptr), nullptr); + if (f != nullptr) return f; } catch (ast_exception &) { @@ -923,7 +923,7 @@ func_decl * cmd_context::find_func_decl(symbol const & s) const { return fs.first(); } throw cmd_exception("invalid function declaration reference, unknown function ", s); - return 0; + return nullptr; } /** @@ -936,7 +936,7 @@ func_decl * cmd_context::find_func_decl(symbol const & s) const { */ static builtin_decl const & peek_builtin_decl(builtin_decl const & first, family_id target_id) { builtin_decl const * curr = &first; - while (curr != 0) { + while (curr != nullptr) { if (curr->m_fid == target_id) return *curr; curr = curr->m_next; @@ -958,7 +958,7 @@ func_decl * cmd_context::find_func_decl(symbol const & s, unsigned num_indices, } func_decl * f; if (num_indices == 0) { - f = m().mk_func_decl(fid, k, 0, 0, arity, domain, range); + f = m().mk_func_decl(fid, k, 0, nullptr, arity, domain, range); } else { buffer ps; @@ -966,7 +966,7 @@ func_decl * cmd_context::find_func_decl(symbol const & s, unsigned num_indices, ps.push_back(parameter(indices[i])); f = m().mk_func_decl(fid, k, num_indices, ps.c_ptr(), arity, domain, range); } - if (f == 0) + if (f == nullptr) throw cmd_exception("invalid function declaration reference, invalid builtin reference ", s); return f; } @@ -977,46 +977,46 @@ func_decl * cmd_context::find_func_decl(symbol const & s, unsigned num_indices, if (num_indices > 0) throw cmd_exception("invalid indexed function declaration reference, unknown builtin function ", s); - func_decl * f = 0; + func_decl * f = nullptr; func_decls fs; if (m_func_decls.find(s, fs)) { f = fs.find(arity, domain, range); } - if (f == 0) + if (f == nullptr) throw cmd_exception("invalid function declaration reference, unknown function ", s); return f; } psort_decl * cmd_context::find_psort_decl(symbol const & s) const { - psort_decl * p = 0; + psort_decl * p = nullptr; m_psort_decls.find(s, p); return p; } cmd * cmd_context::find_cmd(symbol const & s) const { - cmd * c = 0; + cmd * c = nullptr; m_cmds.find(s, c); return c; } sexpr * cmd_context::find_user_tactic(symbol const & s) const { - sexpr * n = 0; + sexpr * n = nullptr; m_user_tactic_decls.find(s, n); return n; } object_ref * cmd_context::find_object_ref(symbol const & s) const { - object_ref * r = 0; + object_ref * r = nullptr; m_object_refs.find(s, r); - if (r == 0) throw cmd_exception("unknown global variable ", s); + if (r == nullptr) throw cmd_exception("unknown global variable ", s); return r; } #define CHECK_SORT(T) if (well_sorted_check_enabled()) m().check_sorts_core(T) void cmd_context::mk_const(symbol const & s, expr_ref & result) const { - mk_app(s, 0, 0, 0, 0, 0, result); + mk_app(s, 0, nullptr, 0, nullptr, nullptr, result); } void cmd_context::mk_app(symbol const & s, unsigned num_args, expr * const * args, unsigned num_indices, parameter const * indices, sort * range, @@ -1032,12 +1032,12 @@ void cmd_context::mk_app(symbol const & s, unsigned num_args, expr * const * arg k = d2.m_decl; } if (num_indices == 0) { - result = m().mk_app(fid, k, 0, 0, num_args, args, range); + result = m().mk_app(fid, k, 0, nullptr, num_args, args, range); } else { result = m().mk_app(fid, k, num_indices, indices, num_args, args, range); } - if (result.get() == 0) + if (result.get() == nullptr) throw cmd_exception("invalid builtin application ", s); CHECK_SORT(result.get()); return; @@ -1066,11 +1066,11 @@ void cmd_context::mk_app(symbol const & s, unsigned num_args, expr * const * arg throw cmd_exception("unknown function/constant ", s); } - if (num_args == 0 && range == 0) { + if (num_args == 0 && range == nullptr) { if (fs.more_than_one()) throw cmd_exception("ambiguous constant reference, more than one constant with the same sort, use a qualified expression (as ) to disumbiguate ", s); func_decl * f = fs.first(); - if (f == 0) { + if (f == nullptr) { throw cmd_exception("unknown constant ", s); } if (f->get_arity() != 0) @@ -1079,7 +1079,7 @@ void cmd_context::mk_app(symbol const & s, unsigned num_args, expr * const * arg } else { func_decl * f = fs.find(m(), num_args, args, range); - if (f == 0) { + if (f == nullptr) { std::ostringstream buffer; buffer << "unknown constant " << s << " "; buffer << " ("; @@ -1173,7 +1173,7 @@ void cmd_context::erase_user_tactic(symbol const & s) { } void cmd_context::erase_object_ref(symbol const & s) { - object_ref * r = 0; + object_ref * r = nullptr; if (m_object_refs.find(s, r)) { r->dec_ref(*this); m_object_refs.erase(s); @@ -1242,7 +1242,7 @@ void cmd_context::insert_aux_pdecl(pdecl * p) { void cmd_context::reset(bool finalize) { m_processing_pareto = false; m_logic = symbol::null; - m_check_sat_result = 0; + m_check_sat_result = nullptr; m_numeral_as_real = false; m_builtin_decls.reset(); m_extra_builtin_decls.reset(); @@ -1255,17 +1255,17 @@ void cmd_context::reset(bool finalize) { reset_func_decls(); restore_assertions(0); if (m_solver) - m_solver = 0; + m_solver = nullptr; m_scopes.reset(); - m_opt = 0; - m_pp_env = 0; - m_dt_eh = 0; + m_opt = nullptr; + m_pp_env = nullptr; + m_dt_eh = nullptr; if (m_manager) { dealloc(m_pmanager); - m_pmanager = 0; + m_pmanager = nullptr; if (m_own_manager) { dealloc(m_manager); - m_manager = 0; + m_manager = nullptr; m_manager_initialized = false; } else { @@ -1279,7 +1279,7 @@ void cmd_context::reset(bool finalize) { } if (m_sexpr_manager) { dealloc(m_sexpr_manager); - m_sexpr_manager = 0; + m_sexpr_manager = nullptr; } SASSERT(!m_own_manager || !has_manager()); } @@ -1288,7 +1288,7 @@ void cmd_context::assert_expr(expr * t) { m_processing_pareto = false; if (!m_check_logic(t)) throw cmd_exception(m_check_logic.get_last_error()); - m_check_sat_result = 0; + m_check_sat_result = nullptr; m().inc_ref(t); m_assertions.push_back(t); if (produce_unsat_cores()) @@ -1305,7 +1305,7 @@ void cmd_context::assert_expr(symbol const & name, expr * t) { assert_expr(t); return; } - m_check_sat_result = 0; + m_check_sat_result = nullptr; m().inc_ref(t); m_assertions.push_back(t); expr * ans = m().mk_const(name, m().mk_bool_sort()); @@ -1316,7 +1316,7 @@ void cmd_context::assert_expr(symbol const & name, expr * t) { } void cmd_context::push() { - m_check_sat_result = 0; + m_check_sat_result = nullptr; init_manager(); m_scopes.push_back(scope()); scope & s = m_scopes.back(); @@ -1362,7 +1362,7 @@ void cmd_context::restore_psort_decls(unsigned old_sz) { svector::iterator end = m_psort_decls_stack.end(); for (; it != end; ++it) { symbol const & s = *it; - psort_decl * d = 0; + psort_decl * d = nullptr; VERIFY(m_psort_decls.find(s, d)); pm().dec_ref(d); m_psort_decls.erase(s); @@ -1418,7 +1418,7 @@ void cmd_context::restore_assertions(unsigned old_sz) { } void cmd_context::pop(unsigned n) { - m_check_sat_result = 0; + m_check_sat_result = nullptr; m_processing_pareto = false; if (n == 0) return; @@ -1556,10 +1556,10 @@ void cmd_context::reset_assertions() { } if (m_opt) { - m_opt = 0; + m_opt = nullptr; } if (m_solver) { - m_solver = 0; + m_solver = nullptr; mk_solver(); } restore_assertions(0); @@ -1778,7 +1778,7 @@ void cmd_context::validate_model() { for (; it != end; ++it) { expr * a = *it; if (is_ground(a)) { - r = 0; + r = nullptr; evaluator(a, r); TRACE("model_validate", tout << "checking\n" << mk_ismt2_pp(a, m()) << "\nresult:\n" << mk_ismt2_pp(r, m()) << "\n";); if (m().is_true(r)) @@ -1830,8 +1830,8 @@ void cmd_context::set_interpolating_solver_factory(solver_factory * f) { void cmd_context::set_solver_factory(solver_factory * f) { m_solver_factory = f; - m_check_sat_result = 0; - if (has_manager() && f != 0) { + m_check_sat_result = nullptr; + if (has_manager() && f != nullptr) { mk_solver(); // assert formulas and create scopes in the new solver. unsigned lim = 0; @@ -1890,7 +1890,7 @@ bool cmd_context::is_model_available() const { (cs_state() == css_sat || cs_state() == css_unknown)) { model_ref md; get_check_sat_result()->get_model(md); - return md.get() != 0; + return md.get() != nullptr; } return false; } @@ -1901,7 +1901,7 @@ format_ns::format * cmd_context::pp(sort * s) const { } cmd_context::pp_env & cmd_context::get_pp_env() const { - if (m_pp_env.get() == 0) { + if (m_pp_env.get() == nullptr) { const_cast(this)->m_pp_env = alloc(pp_env, *const_cast(this)); } return *(m_pp_env.get()); @@ -1913,7 +1913,7 @@ void cmd_context::pp(expr * n, unsigned num_vars, char const * var_prefix, forma void cmd_context::pp(expr * n, format_ns::format_ref & r) const { sbuffer buf; - pp(n, 0, 0, r, buf); + pp(n, 0, nullptr, r, buf); } void cmd_context::pp(func_decl * f, format_ns::format_ref & r) const { @@ -1938,7 +1938,7 @@ void cmd_context::display(std::ostream & out, expr * n, unsigned indent, unsigne void cmd_context::display(std::ostream & out, expr * n, unsigned indent) const { sbuffer buf; - display(out, n, indent, 0, 0, buf); + display(out, n, indent, 0, nullptr, buf); } void cmd_context::display(std::ostream & out, func_decl * d, unsigned indent) const { diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index cd3191fc6..d1e470c3b 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -45,7 +45,7 @@ class func_decls { bool signatures_collide(func_decl* f, func_decl* g) const; bool signatures_collide(unsigned n, sort*const* domain, sort* range, func_decl* g) const; public: - func_decls():m_decls(0) {} + func_decls():m_decls(nullptr) {} func_decls(ast_manager & m, func_decl * f); void finalize(ast_manager & m); bool contains(func_decl * f) const; @@ -54,7 +54,7 @@ public: void erase(ast_manager & m, func_decl * f); bool more_than_one() const; bool clash(func_decl * f) const; - bool empty() const { return m_decls == 0; } + bool empty() const { return m_decls == nullptr; } func_decl * first() const; func_decl * find(unsigned arity, sort * const * domain, sort * range) const; func_decl * find(ast_manager & m, unsigned num_args, expr * const * args, sort * range) const; @@ -76,7 +76,7 @@ struct macro_decl { class macro_decls { vector* m_decls; public: - macro_decls() { m_decls = 0; } + macro_decls() { m_decls = nullptr; } void finalize(ast_manager& m); bool insert(ast_manager& m, unsigned arity, sort *const* domain, expr* body); expr* find(unsigned arity, sort *const* domain) const; @@ -138,8 +138,8 @@ struct builtin_decl { family_id m_fid; decl_kind m_decl; builtin_decl * m_next; - builtin_decl():m_fid(null_family_id), m_decl(0), m_next(0) {} - builtin_decl(family_id fid, decl_kind k, builtin_decl * n = 0):m_fid(fid), m_decl(k), m_next(n) {} + builtin_decl():m_fid(null_family_id), m_decl(0), m_next(nullptr) {} + builtin_decl(family_id fid, decl_kind k, builtin_decl * n = nullptr):m_fid(fid), m_decl(k), m_next(n) {} }; class opt_wrapper : public check_sat_result { @@ -306,7 +306,7 @@ protected: public: - cmd_context(bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); + cmd_context(bool main_ctx = true, ast_manager * m = nullptr, symbol const & l = symbol::null); ~cmd_context() override; void set_cancel(bool f); context_params & params() { return m_params; } @@ -352,7 +352,7 @@ public: status get_status() const { return m_status; } std::string reason_unknown() const; - bool has_manager() const { return m_manager != 0; } + bool has_manager() const { return m_manager != nullptr; } ast_manager & m() const { const_cast(this)->init_manager(); return *m_manager; } ast_manager & get_ast_manager() override { return m(); } pdecl_manager & pm() const { if (!m_pmanager) const_cast(this)->init_manager(); return *m_pmanager; } diff --git a/src/cmd_context/cmd_context_to_goal.cpp b/src/cmd_context/cmd_context_to_goal.cpp index beff9a7bd..a66f9e5de 100644 --- a/src/cmd_context/cmd_context_to_goal.cpp +++ b/src/cmd_context/cmd_context_to_goal.cpp @@ -33,14 +33,14 @@ void assert_exprs_from(cmd_context const & ctx, goal & t) { ptr_vector::const_iterator it2 = ctx.begin_assertion_names(); SASSERT(end - it == ctx.end_assertion_names() - it2); for (; it != end; ++it, ++it2) { - t.assert_expr(*it, proofs_enabled ? m.mk_asserted(*it) : 0, m.mk_leaf(*it2)); + t.assert_expr(*it, proofs_enabled ? m.mk_asserted(*it) : nullptr, m.mk_leaf(*it2)); } } else { ptr_vector::const_iterator it = ctx.begin_assertions(); ptr_vector::const_iterator end = ctx.end_assertions(); for (; it != end; ++it) { - t.assert_expr(*it, proofs_enabled ? m.mk_asserted(*it) : 0, 0); + t.assert_expr(*it, proofs_enabled ? m.mk_asserted(*it) : nullptr, nullptr); } SASSERT(ctx.begin_assertion_names() == ctx.end_assertion_names()); } diff --git a/src/cmd_context/context_params.cpp b/src/cmd_context/context_params.cpp index 78f4223fc..85ac2274b 100644 --- a/src/cmd_context/context_params.cpp +++ b/src/cmd_context/context_params.cpp @@ -62,7 +62,7 @@ void context_params::set_uint(unsigned & opt, char const * param, char const * v } if (is_uint) { - long val = strtol(value, 0, 10); + long val = strtol(value, nullptr, 10); opt = static_cast(val); } else { @@ -198,7 +198,7 @@ void context_params::get_solver_params(ast_manager const & m, params_ref & p, bo ast_manager * context_params::mk_ast_manager() { ast_manager * r = alloc(ast_manager, m_proof ? PGM_ENABLED : PGM_DISABLED, - m_trace ? m_trace_file_name.c_str() : 0); + m_trace ? m_trace_file_name.c_str() : nullptr); if (m_smtlib2_compliant) r->enable_int_real_coercions(false); if (m_debug_ref_count) diff --git a/src/cmd_context/eval_cmd.cpp b/src/cmd_context/eval_cmd.cpp index b1a7905d1..d4004fca8 100644 --- a/src/cmd_context/eval_cmd.cpp +++ b/src/cmd_context/eval_cmd.cpp @@ -43,11 +43,11 @@ public: void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); - m_target = 0; + m_target = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { - if (m_target == 0) return CPK_EXPR; + if (m_target == nullptr) return CPK_EXPR; return parametric_cmd::next_arg_kind(ctx); } diff --git a/src/cmd_context/extra_cmds/dbg_cmds.cpp b/src/cmd_context/extra_cmds/dbg_cmds.cpp index 6dab3e39f..465bcb956 100644 --- a/src/cmd_context/extra_cmds/dbg_cmds.cpp +++ b/src/cmd_context/extra_cmds/dbg_cmds.cpp @@ -107,7 +107,7 @@ public: char const * get_usage() const override { return " (*) "; } char const * get_descr(cmd_context & ctx) const override { return "substitute the free variables in the AST referenced by using the ASTs referenced by *"; } unsigned get_arity() const override { return 3; } - void prepare(cmd_context & ctx) override { m_idx = 0; m_source = 0; } + void prepare(cmd_context & ctx) override { m_idx = 0; m_source = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_idx == 1) return CPK_SYMBOL_LIST; return CPK_SYMBOL; @@ -182,10 +182,10 @@ public: char const * get_usage() const override { return " "; } char const * get_descr(cmd_context & ctx) const override { return "return true if the first term is smaller than the second one in the internal Z3 total order on terms."; } unsigned get_arity() const override { return 2; } - void prepare(cmd_context & ctx) override { m_t1 = 0; } + void prepare(cmd_context & ctx) override { m_t1 = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { return CPK_EXPR; } void set_next_arg(cmd_context & ctx, expr * arg) override { - if (m_t1 == 0) + if (m_t1 == nullptr) m_t1 = arg; else m_t2 = arg; @@ -286,10 +286,10 @@ public: char const * get_usage() const override { return " (*)"; } char const * get_descr(cmd_context & ctx) const override { return "instantiate the quantifier using the given expressions."; } unsigned get_arity() const override { return 2; } - void prepare(cmd_context & ctx) override { m_q = 0; m_args.reset(); } + void prepare(cmd_context & ctx) override { m_q = nullptr; m_args.reset(); } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { - if (m_q == 0) return CPK_EXPR; + if (m_q == nullptr) return CPK_EXPR; else return CPK_EXPR_LIST; } diff --git a/src/cmd_context/extra_cmds/polynomial_cmds.cpp b/src/cmd_context/extra_cmds/polynomial_cmds.cpp index 8adaa660d..1f4915ca5 100644 --- a/src/cmd_context/extra_cmds/polynomial_cmds.cpp +++ b/src/cmd_context/extra_cmds/polynomial_cmds.cpp @@ -104,7 +104,7 @@ class poly_isolate_roots_cmd : public cmd { } void set_next_arg(cmd_context & ctx, expr * arg) { - if (m_p.get() == 0) { + if (m_p.get() == nullptr) { scoped_mpz d(m_qm); if (!m_expr2poly.to_polynomial(arg, m_p, d)) throw cmd_exception("expression is not a polynomial"); @@ -132,7 +132,7 @@ class poly_isolate_roots_cmd : public cmd { } void execute(cmd_context & ctx) { - if (m_p.get() == 0) + if (m_p.get() == nullptr) throw cmd_exception("polynomial expected"); polynomial::var_vector xs; m_pm.vars(m_p, xs); @@ -162,7 +162,7 @@ class poly_isolate_roots_cmd : public cmd { scoped_ptr m_ctx; public: - poly_isolate_roots_cmd(char const * name = "poly/isolate-roots"):cmd(name), m_ctx(0) {} + poly_isolate_roots_cmd(char const * name = "poly/isolate-roots"):cmd(name), m_ctx(nullptr) {} char const * get_usage() const override { return " ( )*"; } @@ -175,11 +175,11 @@ public: } void finalize(cmd_context & ctx) override { - m_ctx = 0; + m_ctx = nullptr; } void failure_cleanup(cmd_context & ctx) override { - m_ctx = 0; + m_ctx = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { @@ -192,7 +192,7 @@ public: void execute(cmd_context & ctx) override { m_ctx->execute(ctx); - m_ctx = 0; + m_ctx = nullptr; } }; @@ -216,11 +216,11 @@ public: void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); - m_target = 0; + m_target = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { - if (m_target == 0) return CPK_EXPR; + if (m_target == nullptr) return CPK_EXPR; return parametric_cmd::next_arg_kind(ctx); } diff --git a/src/cmd_context/interpolant_cmds.cpp b/src/cmd_context/interpolant_cmds.cpp index 62824c2ec..dd1d0acec 100644 --- a/src/cmd_context/interpolant_cmds.cpp +++ b/src/cmd_context/interpolant_cmds.cpp @@ -117,7 +117,7 @@ static void get_interpolant_and_maybe_check(cmd_context & ctx, expr * t, params_ ptr_vector interps; try { - iz3interpolate(ctx.m(),pr.get(),cnsts,t,interps,0); + iz3interpolate(ctx.m(),pr.get(),cnsts,t,interps,nullptr); } catch (iz3_bad_tree &) { throw cmd_exception("interpolation pattern contains non-asserted formula"); @@ -160,7 +160,7 @@ static void compute_interpolant_and_maybe_check(cmd_context & ctx, expr * t, par lbool res; try { - res = iz3interpolate(_m, *sp.get(), t, cnsts, interps, m, 0); + res = iz3interpolate(_m, *sp.get(), t, cnsts, interps, m, nullptr); } catch (iz3_incompleteness &) { throw cmd_exception("incompleteness in interpolator"); diff --git a/src/cmd_context/parametric_cmd.cpp b/src/cmd_context/parametric_cmd.cpp index 4a85821b2..524662ed3 100644 --- a/src/cmd_context/parametric_cmd.cpp +++ b/src/cmd_context/parametric_cmd.cpp @@ -20,7 +20,7 @@ Notes: #include "cmd_context/parametric_cmd.h" char const * parametric_cmd::get_descr(cmd_context & ctx) const { - if (m_descr == 0) { + if (m_descr == nullptr) { const_cast(this)->m_descr = alloc(string_buffer<>); m_descr->append(get_main_descr()); m_descr->append("\nThe following options are available:\n"); diff --git a/src/cmd_context/parametric_cmd.h b/src/cmd_context/parametric_cmd.h index 84b29a17d..79517219d 100644 --- a/src/cmd_context/parametric_cmd.h +++ b/src/cmd_context/parametric_cmd.h @@ -30,7 +30,7 @@ public: params_ref m_params; scoped_ptr m_pdescrs; public: - parametric_cmd(char const * name):cmd(name), m_descr(0) {} + parametric_cmd(char const * name):cmd(name), m_descr(nullptr) {} ~parametric_cmd() override { if (m_descr) dealloc(m_descr); } virtual void init_pdescrs(cmd_context & ctx, param_descrs & d) = 0; param_descrs const & pdescrs(cmd_context & ctx) const; diff --git a/src/cmd_context/pdecl.cpp b/src/cmd_context/pdecl.cpp index f485aea75..3a684b867 100644 --- a/src/cmd_context/pdecl.cpp +++ b/src/cmd_context/pdecl.cpp @@ -25,7 +25,7 @@ class psort_inst_cache { sort * m_const; obj_map m_map; // if m_num_params == 1 value is a sort, otherwise it is a reference to another inst_cache public: - psort_inst_cache(unsigned num_params):m_num_params(num_params), m_const(0) { + psort_inst_cache(unsigned num_params):m_num_params(num_params), m_const(nullptr) { } ~psort_inst_cache() { SASSERT(m_map.empty()); SASSERT(m_const == 0); } @@ -35,7 +35,7 @@ public: SASSERT(m_map.empty()); if (m_const) m.m().dec_ref(m_const); - m_const = 0; + m_const = nullptr; } else { SASSERT(m_const == 0); @@ -71,7 +71,7 @@ public: m.m().inc_ref(r); return; } - void * next = 0; + void * next = nullptr; if (!curr->m_map.find(*s, next)) { next = new (m.a().allocate(sizeof(psort_inst_cache))) psort_inst_cache(curr->m_num_params-1); curr->m_map.insert(*s, next); @@ -90,22 +90,22 @@ public: psort_inst_cache const * curr = this; while (true) { if (curr->m_num_params == 1) { - void * r = 0; + void * r = nullptr; curr->m_map.find(*s, r); return static_cast(r); } else { - void * next = 0; + void * next = nullptr; curr->m_map.find(*s, next); - if (next == 0) - return 0; + if (next == nullptr) + return nullptr; s++; curr = static_cast(next); } } } - bool empty() const { return m_num_params == 0 ? m_const == 0 : m_map.empty(); } + bool empty() const { return m_num_params == 0 ? m_const == nullptr : m_map.empty(); } }; void psort::cache(pdecl_manager & m, sort * const * s, sort * r) { @@ -116,7 +116,7 @@ void psort::cache(pdecl_manager & m, sort * const * s, sort * r) { sort * psort::find(sort * const * s) const { if (!m_inst_cache) - return 0; + return nullptr; return m_inst_cache->find(s); } @@ -126,7 +126,7 @@ void psort::finalize(pdecl_manager & m) { void psort::reset_cache(pdecl_manager& m) { m.del_inst_cache(m_inst_cache); - m_inst_cache = 0; + m_inst_cache = nullptr; } /** @@ -269,7 +269,7 @@ psort_decl::psort_decl(unsigned id, unsigned num_params, pdecl_manager & m, symb pdecl(id, num_params), m_name(n), m_psort_kind(PSORT_BASE), - m_inst_cache(0) { + m_inst_cache(nullptr) { } void psort_decl::finalize(pdecl_manager & m) { @@ -278,7 +278,7 @@ void psort_decl::finalize(pdecl_manager & m) { void psort_decl::reset_cache(pdecl_manager& m) { m.del_inst_cache(m_inst_cache); - m_inst_cache = 0; + m_inst_cache = nullptr; } void psort_decl::cache(pdecl_manager & m, sort * const * s, sort * r) { @@ -289,7 +289,7 @@ void psort_decl::cache(pdecl_manager & m, sort * const * s, sort * r) { sort * psort_decl::find(sort * const * s) { if (!m_inst_cache) - return 0; + return nullptr; return m_inst_cache->find(s); } @@ -303,7 +303,7 @@ psort_user_decl::psort_user_decl(unsigned id, unsigned num_params, pdecl_manager void psort_user_decl::finalize(pdecl_manager & m) { m.dec_ref(m_def); - m_def = 0; + m_def = nullptr; psort_decl::finalize(m); } @@ -312,7 +312,7 @@ sort * psort_user_decl::instantiate(pdecl_manager & m, unsigned n, sort * const sort * r = find(s); if (r) return r; - if (m_def == 0) { + if (m_def == nullptr) { buffer ps; for (unsigned i = 0; i < n; i++) ps.push_back(parameter(s[i])); @@ -462,7 +462,7 @@ accessor_decl * paccessor_decl::instantiate_decl(pdecl_manager & m, sort * const default: // missing refs must have been eliminated. UNREACHABLE(); - return 0; + return nullptr; } } @@ -522,7 +522,7 @@ pdatatype_decl::pdatatype_decl(unsigned id, unsigned num_params, pdecl_manager & symbol const & n, unsigned num_constructors, pconstructor_decl * const * constructors): psort_decl(id, num_params, m, n), m_constructors(num_constructors, constructors), - m_parent(0) { + m_parent(nullptr) { m.inc_ref(num_constructors, constructors); } @@ -633,7 +633,7 @@ bool pdatatype_decl::commit(pdecl_manager& m) { TRACE("datatype", tout << m_name << "\n";); sort_ref_vector ps(m.m()); for (unsigned i = 0; i < m_num_params; ++i) { - ps.push_back(m.m().mk_uninterpreted_sort(symbol(i), 0, 0)); + ps.push_back(m.m().mk_uninterpreted_sort(symbol(i), 0, nullptr)); } datatype_decl_buffer dts; dts.m_buffer.push_back(instantiate_decl(m, ps.c_ptr())); @@ -712,7 +712,7 @@ bool pdatatypes_decl::commit(pdecl_manager& m) { for (pdatatype_decl* d : m_datatypes) { sort_ref_vector ps(m.m()); for (unsigned i = 0; i < d->get_num_params(); ++i) { - ps.push_back(m.m().mk_uninterpreted_sort(symbol(i), 0, 0)); + ps.push_back(m.m().mk_uninterpreted_sort(symbol(i), 0, nullptr)); } dts.m_buffer.push_back(d->instantiate_decl(m, ps.c_ptr())); } @@ -834,7 +834,7 @@ void pdecl_manager::init_list() { ptype ListT(0); paccessor_decl * as[2] = { mk_paccessor_decl(1, symbol("head"), T), mk_paccessor_decl(1, symbol("tail"), ListT) }; - pconstructor_decl * cs[2] = { mk_pconstructor_decl(1, symbol("nil"), symbol("is-nil"), 0, 0), + pconstructor_decl * cs[2] = { mk_pconstructor_decl(1, symbol("nil"), symbol("is-nil"), 0, nullptr), mk_pconstructor_decl(1, symbol("insert"), symbol("is-insert"), 2, as) }; m_list = mk_pdatatype_decl(1, symbol("List"), 2, cs); inc_ref(m_list); @@ -844,8 +844,8 @@ void pdecl_manager::init_list() { pdecl_manager::pdecl_manager(ast_manager & m): m_manager(m), m_allocator(m.get_allocator()), - m_new_dt_eh(0) { - m_list = 0; + m_new_dt_eh(nullptr) { + m_list = nullptr; m_datatype_fid = m.mk_family_id("datatype"); } @@ -857,7 +857,7 @@ pdecl_manager::~pdecl_manager() { } psort * pdecl_manager::mk_psort_cnst(sort * s) { - psort * r = 0; + psort * r = nullptr; if (m_sort2psort.find(s, r)) return r; r = new (a().allocate(sizeof(psort_sort))) psort_sort(m_id_gen.mk(), *this, s); @@ -907,9 +907,9 @@ psort * pdecl_manager::mk_psort_app(unsigned num_params, psort_decl * d, unsigne psort * pdecl_manager::mk_psort_app(psort_decl * d) { SASSERT(d->get_num_params() == 0 || d->get_num_params() == PSORT_DECL_VAR_PARAMS); - sort * s = d->instantiate(*this, 0, static_cast(0)); - if (s == 0) - return 0; + sort * s = d->instantiate(*this, 0, static_cast(nullptr)); + if (s == nullptr) + return nullptr; return mk_psort_cnst(s); } @@ -1010,7 +1010,7 @@ void pdecl_manager::reset_sort_info() { } void pdecl_manager::display(std::ostream & out, sort * s) const { - sort_info * info = 0; + sort_info * info = nullptr; if (m_sort2info.find(s, info)) { info->display(out, *this); return; @@ -1019,7 +1019,7 @@ void pdecl_manager::display(std::ostream & out, sort * s) const { } format * pdecl_manager::pp(sort * s) const { - sort_info * info = 0; + sort_info * info = nullptr; if (m_sort2info.find(s, info)) { return info->pp(*this); } diff --git a/src/cmd_context/pdecl.h b/src/cmd_context/pdecl.h index d6fea179d..12e6399fe 100644 --- a/src/cmd_context/pdecl.h +++ b/src/cmd_context/pdecl.h @@ -64,7 +64,7 @@ class psort : public pdecl { protected: psort_inst_cache * m_inst_cache; friend class pdecl_manager; - psort(unsigned id, unsigned num_params):pdecl(id, num_params), m_inst_cache(0) {} + psort(unsigned id, unsigned num_params):pdecl(id, num_params), m_inst_cache(nullptr) {} bool is_psort() const override { return true; } void finalize(pdecl_manager & m) override; ~psort() override {} @@ -72,7 +72,7 @@ protected: virtual sort * find(sort * const * s) const; public: virtual bool is_sort_wrapper() const { return false; } - virtual sort * instantiate(pdecl_manager & m, sort * const * s) { return 0; } + virtual sort * instantiate(pdecl_manager & m, sort * const * s) { return nullptr; } // we use hash-consing for psorts. virtual char const * hcons_kind() const = 0; virtual unsigned hcons_hash() const = 0; @@ -102,8 +102,8 @@ protected: ~psort_decl() override {} public: virtual sort * instantiate(pdecl_manager & m, unsigned n, sort * const * s) = 0; - virtual sort * instantiate(pdecl_manager & m, unsigned n, unsigned const * s) { return 0; } - virtual sort * instantiate(pdecl_manager & m) { return instantiate(m, 0, static_cast(0)); } + virtual sort * instantiate(pdecl_manager & m, unsigned n, unsigned const * s) { return nullptr; } + virtual sort * instantiate(pdecl_manager & m) { return instantiate(m, 0, static_cast(nullptr)); } // return true if the declaration accepts a variable number of parameters. // Only builtin declarations can have a variable number of parameters. bool has_var_params() const { return m_num_params == PSORT_DECL_VAR_PARAMS; } @@ -172,7 +172,7 @@ class ptype { }; symbol m_missing_ref; public: - ptype():m_kind(PTR_PSORT), m_sort(0) {} + ptype():m_kind(PTR_PSORT), m_sort(nullptr) {} ptype(int idx):m_kind(PTR_REC_REF), m_idx(idx) {} ptype(psort * s):m_kind(PTR_PSORT), m_sort(s) {} ptype(symbol const & s):m_kind(PTR_MISSING_REF), m_missing_ref(s) {} diff --git a/src/cmd_context/simplify_cmd.cpp b/src/cmd_context/simplify_cmd.cpp index 999351d25..de548562e 100644 --- a/src/cmd_context/simplify_cmd.cpp +++ b/src/cmd_context/simplify_cmd.cpp @@ -42,7 +42,7 @@ class simplify_cmd : public parametric_cmd { } m_solver->push(); m_solver->assert_expr(e); - lbool r = m_solver->check_sat(0,0); + lbool r = m_solver->check_sat(0,nullptr); m_solver->pop(1); return r; } @@ -71,11 +71,11 @@ public: void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); - m_target = 0; + m_target = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { - if (m_target == 0) return CPK_EXPR; + if (m_target == nullptr) return CPK_EXPR; return parametric_cmd::next_arg_kind(ctx); } @@ -84,7 +84,7 @@ public: } void execute(cmd_context & ctx) override { - if (m_target == 0) + if (m_target == nullptr) throw cmd_exception("invalid simplify command, argument expected"); expr_ref r(ctx.m()); proof_ref pr(ctx.m()); diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index f35267714..32a92ea59 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -55,13 +55,13 @@ class declare_tactic_cmd : public cmd { public: declare_tactic_cmd(): cmd("declare-tactic"), - m_decl(0) { + m_decl(nullptr) { } char const * get_usage() const override { return " "; } char const * get_descr(cmd_context & ctx) const override { return "declare a new tactic, use (help-tactic) for the tactic language syntax."; } unsigned get_arity() const override { return 2; } - void prepare(cmd_context & ctx) override { m_name = symbol::null; m_decl = 0; } + void prepare(cmd_context & ctx) override { m_name = symbol::null; m_decl = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { if (m_name == symbol::null) return CPK_SYMBOL; return CPK_SEXPR; @@ -137,11 +137,11 @@ public: void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); - m_tactic = 0; + m_tactic = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { - if (m_tactic == 0) return CPK_SEXPR; + if (m_tactic == nullptr) return CPK_SEXPR; return parametric_cmd::next_arg_kind(ctx); } @@ -597,9 +597,9 @@ static tactic * mk_echo(cmd_context & ctx, sexpr * n) { if (curr->is_string()) t = mk_echo_tactic(ctx, curr->get_string().c_str(), last); else - t = mk_probe_value_tactic(ctx, 0, sexpr2probe(ctx, curr), last); + t = mk_probe_value_tactic(ctx, nullptr, sexpr2probe(ctx, curr), last); tactic * new_res; - if (res.get() == 0) + if (res.get() == nullptr) new_res = t; else new_res = and_then(res.get(), t); @@ -608,7 +608,7 @@ static tactic * mk_echo(cmd_context & ctx, sexpr * n) { res = new_res; } UNREACHABLE(); - return 0; + return nullptr; } static tactic * mk_fail_if_branching(cmd_context & ctx, sexpr * n) { @@ -665,10 +665,10 @@ static tactic * mk_skip_if_failed(cmd_context & ctx, sexpr * n) { tactic * sexpr2tactic(cmd_context & ctx, sexpr * n) { if (n->is_symbol()) { tactic_cmd * cmd = ctx.find_tactic_cmd(n->get_symbol()); - if (cmd != 0) + if (cmd != nullptr) return cmd->mk(ctx.m()); sexpr * decl = ctx.find_user_tactic(n->get_symbol()); - if (decl != 0) + if (decl != nullptr) return sexpr2tactic(ctx, decl); throw cmd_exception("invalid tactic, unknown tactic ", n->get_symbol(), n->get_line(), n->get_pos()); } @@ -778,7 +778,7 @@ MK_NARY_PROBE(mk_mul); probe * sexpr2probe(cmd_context & ctx, sexpr * n) { if (n->is_symbol()) { probe_info * pinfo = ctx.find_probe(n->get_symbol()); - if (pinfo != 0) + if (pinfo != nullptr) return pinfo->get(); throw cmd_exception("invalid probe, unknown builtin probe ", n->get_symbol(), n->get_line(), n->get_pos()); } diff --git a/src/cmd_context/tactic_manager.cpp b/src/cmd_context/tactic_manager.cpp index 94b5e35ab..d4b3374b4 100644 --- a/src/cmd_context/tactic_manager.cpp +++ b/src/cmd_context/tactic_manager.cpp @@ -38,13 +38,13 @@ void tactic_manager::insert(probe_info * p) { } tactic_cmd * tactic_manager::find_tactic_cmd(symbol const & s) const { - tactic_cmd * c = 0; + tactic_cmd * c = nullptr; m_name2tactic.find(s, c); return c; } probe_info * tactic_manager::find_probe(symbol const & s) const { - probe_info * p = 0; + probe_info * p = nullptr; m_name2probe.find(s, p); return p; } diff --git a/src/duality/duality.h b/src/duality/duality.h index bb736feb9..9bf323d8b 100644 --- a/src/duality/duality.h +++ b/src/duality/duality.h @@ -199,7 +199,7 @@ namespace Duality { lbool interpolate_tree(TermTree *assumptions, TermTree *&interpolants, model &_model, - TermTree *goals = 0, + TermTree *goals = nullptr, bool weak = false ) = 0; @@ -247,7 +247,7 @@ namespace Duality { lbool interpolate_tree(TermTree *assumptions, TermTree *&interpolants, model &_model, - TermTree *goals = 0, + TermTree *goals = nullptr, bool weak = false) override { literals _labels; @@ -393,7 +393,7 @@ namespace Duality { edgeCount = 0; stack.push_back(stack_entry()); HornClauses = false; - proof_core = 0; + proof_core = nullptr; } virtual ~RPFP(); @@ -494,7 +494,7 @@ namespace Duality { unsigned recursion_bound; Node(const FuncDecl &_Name, const Transformer &_Annotation, const Transformer &_Bound, const Transformer &_Underapprox, const Term &_dual, RPFP *_owner, int _number) - : Name(_Name), Annotation(_Annotation), Bound(_Bound), Underapprox(_Underapprox), dual(_dual) {owner = _owner; number = _number; Outgoing = 0; recursion_bound = UINT_MAX;} + : Name(_Name), Annotation(_Annotation), Bound(_Bound), Underapprox(_Underapprox), dual(_dual) {owner = _owner; number = _number; Outgoing = nullptr; recursion_bound = UINT_MAX;} }; /** Create a node in the graph. The input is a term R(v_1...v_n) @@ -591,7 +591,7 @@ namespace Duality { /** Delete a hyper-edge and unlink it from any nodes. */ void DeleteEdge(Edge *edge){ if(edge->Parent) - edge->Parent->Outgoing = 0; + edge->Parent->Outgoing = nullptr; for(unsigned int i = 0; i < edge->Children.size(); i++){ std::vector &ic = edge->Children[i]->Incoming; for(std::vector::iterator it = ic.begin(), en = ic.end(); it != en; ++it){ @@ -705,7 +705,7 @@ namespace Duality { /** Get the constraint tree (but don't solve it) */ - TermTree *GetConstraintTree(Node *root, Node *skip_descendant = 0); + TermTree *GetConstraintTree(Node *root, Node *skip_descendant = nullptr); /** Dispose of the dual model (counterexample) if there is one. */ @@ -715,7 +715,7 @@ namespace Duality { * Solve, except no primal solution (interpolant) is generated in the unsat case. */ check_result Check(Node *root, std::vector underapproxes = std::vector(), - std::vector *underapprox_core = 0); + std::vector *underapprox_core = nullptr); /** Update the model, attempting to make the propositional literals in assumps true. If possible, return sat, else return unsat and keep the old model. */ @@ -841,7 +841,7 @@ namespace Duality { #ifdef _WINDOWS __declspec(dllexport) #endif - void FromClauses(const std::vector &clauses, const std::vector *bounds = 0); + void FromClauses(const std::vector &clauses, const std::vector *bounds = nullptr); void FromFixpointContext(fixedpoint fp, std::vector &queries); @@ -927,7 +927,7 @@ namespace Duality { void ClearProofCore(){ if(proof_core) delete proof_core; - proof_core = 0; + proof_core = nullptr; } Term SuffixVariable(const Term &t, int n); @@ -944,7 +944,7 @@ namespace Duality { Term ReducedDualEdge(Edge *e); - TermTree *ToTermTree(Node *root, Node *skip_descendant = 0); + TermTree *ToTermTree(Node *root, Node *skip_descendant = nullptr); TermTree *ToGoalTree(Node *root); @@ -1096,12 +1096,12 @@ namespace Duality { virtual void slvr_push(); - virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0); + virtual check_result slvr_check(unsigned n = 0, expr * const assumptions = nullptr, unsigned *core_size = nullptr, expr *core = nullptr); virtual lbool ls_interpolate_tree(TermTree *assumptions, TermTree *&interpolants, model &_model, - TermTree *goals = 0, + TermTree *goals = nullptr, bool weak = false); virtual bool proof_core_contains(const expr &e); @@ -1121,8 +1121,8 @@ namespace Duality { RPFP::Node *root; public: Counterexample(){ - tree = 0; - root = 0; + tree = nullptr; + root = nullptr; } Counterexample(RPFP *_tree, RPFP::Node *_root){ tree = _tree; @@ -1142,7 +1142,7 @@ namespace Duality { } void clear(){ if(tree) delete tree; - tree = 0; + tree = nullptr; } RPFP *get_tree() const {return tree;} RPFP::Node *get_root() const {return root;} @@ -1313,7 +1313,7 @@ namespace Duality { - void GetAssumptionLits(const expr &fmla, std::vector &lits, hash_map *opt_map = 0); + void GetAssumptionLits(const expr &fmla, std::vector &lits, hash_map *opt_map = nullptr); void GreedyReduceCache(std::vector &assumps, std::vector &core); @@ -1326,12 +1326,12 @@ namespace Duality { void slvr_push() override; - check_result slvr_check(unsigned n = 0, expr * const assumptions = 0, unsigned *core_size = 0, expr *core = 0) override; + check_result slvr_check(unsigned n = 0, expr * const assumptions = nullptr, unsigned *core_size = nullptr, expr *core = nullptr) override; lbool ls_interpolate_tree(TermTree *assumptions, TermTree *&interpolants, model &_model, - TermTree *goals = 0, + TermTree *goals = nullptr, bool weak = false) override; bool proof_core_contains(const expr &e) override; diff --git a/src/duality/duality_profiling.cpp b/src/duality/duality_profiling.cpp old mode 100755 new mode 100644 index 2e659f0a1..6bb995e2d --- a/src/duality/duality_profiling.cpp +++ b/src/duality/duality_profiling.cpp @@ -55,7 +55,7 @@ namespace Duality { node::node(){ time = 0; - parent = 0; + parent = nullptr; } struct node *current; diff --git a/src/duality/duality_rpfp.cpp b/src/duality/duality_rpfp.cpp old mode 100755 new mode 100644 index 5180e1315..3358eb45e --- a/src/duality/duality_rpfp.cpp +++ b/src/duality/duality_rpfp.cpp @@ -1345,8 +1345,8 @@ namespace Duality { { timer_start("Solve"); TermTree *tree = GetConstraintTree(root); - TermTree *interpolant = NULL; - TermTree *goals = NULL; + TermTree *interpolant = nullptr; + TermTree *goals = nullptr; if(ls->need_goals) goals = GetGoalTree(root); ClearProofCore(); @@ -1396,11 +1396,11 @@ namespace Duality { timer_start("Solve"); TermTree *tree = CollapseTermTree(GetConstraintTree(root,node)); tree->getChildren().push_back(CollapseTermTree(ToTermTree(node))); - TermTree *interpolant = NULL; + TermTree *interpolant = nullptr; ClearProofCore(); timer_start("interpolate_tree"); - lbool res = ls_interpolate_tree(tree, interpolant, dualModel,0,true); + lbool res = ls_interpolate_tree(tree, interpolant, dualModel,nullptr,true); timer_stop("interpolate_tree"); if (res == l_false) { DecodeTree(node, interpolant->getChildren()[0], 0); @@ -1423,7 +1423,7 @@ namespace Duality { void RPFP::DisposeDualModel() { - dualModel = model(ctx,NULL); + dualModel = model(ctx,nullptr); } RPFP::Term RPFP::UnderapproxFlag(Node *n){ @@ -3281,9 +3281,9 @@ namespace Duality { { stack_entry &back = stack.back(); for(std::list::iterator it = back.edges.begin(), en = back.edges.end(); it != en; ++it) - (*it)->dual = expr(ctx,NULL); + (*it)->dual = expr(ctx,nullptr); for(std::list::iterator it = back.nodes.begin(), en = back.nodes.end(); it != en; ++it) - (*it)->dual = expr(ctx,NULL); + (*it)->dual = expr(ctx,nullptr); for(std::list >::iterator it = back.constraints.begin(), en = back.constraints.end(); it != en; ++it) (*it).first->constraints.pop_back(); stack.pop_back(); diff --git a/src/duality/duality_solver.cpp b/src/duality/duality_solver.cpp index 66bcf4ab3..7782f4a8b 100644 --- a/src/duality/duality_solver.cpp +++ b/src/duality/duality_solver.cpp @@ -126,10 +126,10 @@ namespace Duality { edges(_rpfp->edges) { rpfp = _rpfp; - reporter = 0; - conj_reporter = 0; - heuristic = 0; - unwinding = 0; + reporter = nullptr; + conj_reporter = nullptr; + heuristic = nullptr; + unwinding = nullptr; FullExpand = false; NoConj = false; FeasibleEdges = true; @@ -330,7 +330,7 @@ namespace Duality { void PreSolve(){ reporter = Report ? CreateStdoutReporter(rpfp) : new Reporter(rpfp); - conj_reporter = ConjectureFile.empty() ? 0 : CreateConjectureFileReporter(rpfp,ConjectureFile); + conj_reporter = ConjectureFile.empty() ? nullptr : CreateConjectureFileReporter(rpfp,ConjectureFile); #ifndef LOCALIZE_CONJECTURES heuristic = !cex.get_tree() ? new Heuristic(rpfp) : new ReplayHeuristic(rpfp,cex); #else @@ -524,7 +524,7 @@ namespace Duality { node->Annotation.SetFull(); // allow this node to cover others else updated_nodes.insert(node); - e->map = 0; + e->map = nullptr; reporter->Extend(node); #ifdef EARLY_EXPAND if(!do_not_expand) @@ -537,7 +537,7 @@ namespace Duality { node->Annotation.SetFull(); Edge *e = unwinding->CreateLowerBoundEdge(node); overapproxes.insert(node); - e->map = 0; + e->map = nullptr; } /** We start the unwinding with leaves that under-approximate @@ -1144,14 +1144,14 @@ namespace Duality { Edge *e = unwinding->CreateLowerBoundEdge(under_node); under_node->Annotation.SetFull(); // allow this node to cover others back_edges[under_node] = back_edges[node]; - e->map = 0; + e->map = nullptr; reporter->Extend(under_node); return under_node; } /** Try to prove a conjecture about a node. If successful update the unwinding annotation appropriately. */ - bool ProveConjecture(Node *node, const RPFP::Transformer &t,Node *other = 0, Counterexample *_cex = 0){ + bool ProveConjecture(Node *node, const RPFP::Transformer &t,Node *other = nullptr, Counterexample *_cex = nullptr){ reporter->Conjecture(node,t); timer_start("ProveConjecture"); RPFP::Transformer save = node->Bound; @@ -1245,7 +1245,7 @@ namespace Duality { marker_disjunction = marker_disjunction || marker; } - bool GenNodeSolutionWithMarkers(Node *node, RPFP::Transformer &annot, bool expanded_only = false, Node *other_node = 0){ + bool GenNodeSolutionWithMarkers(Node *node, RPFP::Transformer &annot, bool expanded_only = false, Node *other_node = nullptr){ bool res = false; annot.SetFull(); expr marker_disjunction = ctx.bool_val(false); @@ -1267,14 +1267,14 @@ namespace Duality { Node *root = checker->CloneNode(edge->Parent); GenNodeSolutionFromIndSet(edge->Parent, root->Bound); if(root->Bound.IsFull()) - return 0; + return nullptr; checker->AssertNode(root); std::vector cs; for(unsigned j = 0; j < edge->Children.size(); j++){ Node *oc = edge->Children[j]; Node *nc = checker->CloneNode(oc); if(!GenNodeSolutionWithMarkers(oc,nc->Annotation,expanded_only)) - return 0; + return nullptr; Edge *e = checker->CreateLowerBoundEdge(nc); checker->AssertEdge(e); cs.push_back(nc); @@ -1873,7 +1873,7 @@ namespace Duality { mode. */ - bool Derive(RPFP *rpfp, RPFP::Node *root, bool _underapprox, bool _constrained = false, RPFP *_tree = 0){ + bool Derive(RPFP *rpfp, RPFP::Node *root, bool _underapprox, bool _constrained = false, RPFP *_tree = nullptr){ underapprox = _underapprox; constrained = _constrained; false_approx = true; @@ -2608,7 +2608,7 @@ namespace Duality { bool dominated; std::set dominates; cover_info(){ - covered_by = 0; + covered_by = nullptr; dominated = false; } }; @@ -2708,7 +2708,7 @@ namespace Duality { for(std::vector::iterator it = cs.begin(), en = cs.end(); it != en; it++){ Node *other = *it; if(covered_by(other) && CoverOrder(node,other)){ - covered_by(other) = 0; + covered_by(other) = nullptr; reporter()->RemoveCover(*it,node); } } @@ -2934,7 +2934,7 @@ namespace Duality { #else Node *GetSimilarNode(Node *node){ if(!some_updates) - return 0; + return nullptr; std::vector &insts = insts_of_node(node->map); for(int i = insts.size() - 1; i >= 0; i--){ Node *other = insts[i]; @@ -2942,19 +2942,19 @@ namespace Duality { && !IsCovered(other)) return other; } - return 0; + return nullptr; } #endif bool Dominates(Node * node, Node *other){ if(node == other) return false; - if(other->Outgoing->map == 0) return true; + if(other->Outgoing->map == nullptr) return true; if(node->Outgoing->map == other->Outgoing->map){ assert(node->Outgoing->Children.size() == other->Outgoing->Children.size()); for(unsigned i = 0; i < node->Outgoing->Children.size(); i++){ Node *nc = node->Outgoing->Children[i]; Node *oc = other->Outgoing->Children[i]; - if(!(nc == oc || oc->Outgoing->map ==0 || dominates(nc,oc))) + if(!(nc == oc || oc->Outgoing->map ==nullptr || dominates(nc,oc))) return false; } return true; @@ -3088,7 +3088,7 @@ namespace Duality { LocalHeuristic(RPFP *_rpfp) : Heuristic(_rpfp) { - old_node = 0; + old_node = nullptr; } void SetOldNode(RPFP::Node *_old_node){ @@ -3100,7 +3100,7 @@ namespace Duality { hash_map cex_map; void ChooseExpand(const std::set &choices, std::set &best, bool, bool) override { - if(old_node == 0){ + if(old_node == nullptr){ Heuristic::ChooseExpand(choices,best); return; } diff --git a/src/duality/duality_wrapper.cpp b/src/duality/duality_wrapper.cpp old mode 100755 new mode 100644 index 4493beddf..17adbdcea --- a/src/duality/duality_wrapper.cpp +++ b/src/duality/duality_wrapper.cpp @@ -111,7 +111,7 @@ namespace Duality { } expr context::mki(family_id fid, ::decl_kind dk, int n, ::expr **args){ - return cook(m().mk_app(fid, dk, 0, 0, n, (::expr **)args)); + return cook(m().mk_app(fid, dk, 0, nullptr, n, (::expr **)args)); } expr context::make(decl_kind op, const std::vector &args){ @@ -120,11 +120,11 @@ namespace Duality { a.resize(args.size()); for(unsigned i = 0; i < args.size(); i++) a[i] = to_expr(args[i].raw()); - return make(op,args.size(), args.size() ? VEC2PTR(a) : 0); + return make(op,args.size(), args.size() ? VEC2PTR(a) : nullptr); } expr context::make(decl_kind op){ - return make(op,0,0); + return make(op,0,nullptr); } expr context::make(decl_kind op, const expr &arg0){ @@ -173,8 +173,8 @@ namespace Duality { 0, ::symbol(), ::symbol(), - 0, 0, - 0, 0 + 0, nullptr, + 0, nullptr ); return cook(result.get()); } @@ -199,8 +199,8 @@ namespace Duality { 0, ::symbol(), ::symbol(), - 0, 0, - 0, 0 + 0, nullptr, + 0, nullptr ); return cook(result.get()); } @@ -422,7 +422,7 @@ namespace Duality { func_decl context::fresh_func_decl(char const * prefix, sort const & range){ ::func_decl* d = m().mk_fresh_func_decl(prefix, 0, - 0, + nullptr, to_sort(range.raw())); return func_decl(*this,d); } diff --git a/src/duality/duality_wrapper.h b/src/duality/duality_wrapper.h index 18b6948d5..69f821a08 100644 --- a/src/duality/duality_wrapper.h +++ b/src/duality/duality_wrapper.h @@ -276,7 +276,7 @@ namespace Duality { protected: context * m_ctx; public: - object(): m_ctx((context *)0) {} + object(): m_ctx((context *)nullptr) {} object(context & c):m_ctx(&c) {} object(object const & s):m_ctx(s.m_ctx) {} context & ctx() const { return *m_ctx; } @@ -317,9 +317,9 @@ namespace Duality { ::ast *_ast; public: ::ast * const &raw() const {return _ast;} - ast_i(context & c, ::ast *a = 0) : object(c) {_ast = a;} + ast_i(context & c, ::ast *a = nullptr) : object(c) {_ast = a;} - ast_i(){_ast = 0;} + ast_i(){_ast = nullptr;} bool eq(const ast_i &other) const { return _ast == other._ast; } @@ -346,7 +346,7 @@ namespace Duality { friend bool eq(ast const & a, ast const & b) { return a.raw() == b.raw(); } - ast(context &c, ::ast *a = 0) : ast_i(c,a) { + ast(context &c, ::ast *a = nullptr) : ast_i(c,a) { if(_ast) m().inc_ref(a); } @@ -729,7 +729,7 @@ namespace Duality { m_model = m; } public: - model(context & c, ::model * m = 0):object(c), m_model(m) { } + model(context & c, ::model * m = nullptr):object(c), m_model(m) { } model(model const & s):object(s), m_model(s.m_model) { } ~model() { } operator ::model *() const { return m_model.get(); } @@ -869,28 +869,28 @@ namespace Duality { check_result check() { scoped_proof_mode spm(m(),m_mode); checkpoint(); - lbool r = m_solver->check_sat(0,0); + lbool r = m_solver->check_sat(0,nullptr); model_ref m; m_solver->get_model(m); the_model = m.get(); return to_check_result(r); } - check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) { + check_result check_keep_model(unsigned n, expr * const assumptions, unsigned *core_size = nullptr, expr *core = nullptr) { scoped_proof_mode spm(m(),m_mode); model old_model(the_model); check_result res = check(n,assumptions,core_size,core); - if(the_model == 0) + if(the_model == nullptr) the_model = old_model; return res; } - check_result check(unsigned n, expr * const assumptions, unsigned *core_size = 0, expr *core = 0) { + check_result check(unsigned n, expr * const assumptions, unsigned *core_size = nullptr, expr *core = nullptr) { scoped_proof_mode spm(m(),m_mode); checkpoint(); std::vector< ::expr *> _assumptions(n); for (unsigned i = 0; i < n; i++) { _assumptions[i] = to_expr(assumptions[i]); } - the_model = 0; + the_model = nullptr; lbool r = m_solver->check_sat(n, VEC2PTR(_assumptions)); if(core_size && core){ @@ -1228,7 +1228,7 @@ namespace Duality { return operator()(args.size(), VEC2PTR(args)); } inline expr func_decl::operator()() const { - return operator()(0,0); + return operator()(0,nullptr); } inline expr func_decl::operator()(expr const & a) const { return operator()(1,&a); @@ -1413,7 +1413,7 @@ namespace Duality { template class uptr { public: X *ptr; - uptr(){ptr = 0;} + uptr(){ptr = nullptr;} void set(X *_ptr){ if(ptr) delete ptr; ptr = _ptr; diff --git a/src/interp/iz3base.cpp b/src/interp/iz3base.cpp old mode 100755 new mode 100644 index b9284b869..43e7bdff8 --- a/src/interp/iz3base.cpp +++ b/src/interp/iz3base.cpp @@ -272,7 +272,7 @@ bool iz3base::is_sat(const std::vector &q, ast &_proof, std::vector &v for(unsigned i = 0; i < q.size(); i++) s.assert_expr(to_expr(q[i].raw())); - lbool res = s.check_sat(0,0); + lbool res = s.check_sat(0,nullptr); if (m().canceled()) { throw iz3_exception(Z3_CANCELED_MSG); } @@ -293,7 +293,7 @@ bool iz3base::is_sat(const std::vector &q, ast &_proof, std::vector &v vars[i] = cook(r.get()); } } - solver = 0; + solver = nullptr; return res != l_false; } diff --git a/src/interp/iz3checker.cpp b/src/interp/iz3checker.cpp old mode 100755 new mode 100644 index 8fa99fe10..cfea511ad --- a/src/interp/iz3checker.cpp +++ b/src/interp/iz3checker.cpp @@ -98,7 +98,7 @@ struct iz3checker : iz3base { s->assert_expr(to_expr(itp[cs[j]].raw())); if(i != num-1) s->assert_expr(to_expr(mk_not(itp[i]).raw())); - lbool result = s->check_sat(0,0); + lbool result = s->check_sat(0,nullptr); if(result != l_false){ err << "interpolant " << i << " is incorrect"; @@ -110,7 +110,7 @@ struct iz3checker : iz3base { s->assert_expr(to_expr(cnsts[j].raw())); if(i != num-1) s->assert_expr(to_expr(mk_not(itp[i]).raw())); - lbool result = s->check_sat(0,0); + lbool result = s->check_sat(0,nullptr); if(result != l_false) err << "interpolant " << i << " is not implied by its downeard closurn"; diff --git a/src/interp/iz3hash.h b/src/interp/iz3hash.h index c796a247b..f85242ed1 100644 --- a/src/interp/iz3hash.h +++ b/src/interp/iz3hash.h @@ -132,7 +132,7 @@ namespace hash_space { Entry* next; Value val; - Entry(const Value &_val) : val(_val) {next = 0;} + Entry(const Value &_val) : val(_val) {next = nullptr;} }; @@ -242,7 +242,7 @@ namespace hash_space { public: - hashtable(size_t init_size) : buckets(init_size,(Entry *)0) { + hashtable(size_t init_size) : buckets(init_size,(Entry *)nullptr) { entries = 0; } @@ -281,7 +281,7 @@ namespace hash_space { } iterator end() { - return iterator(0, this); + return iterator(nullptr, this); } const_iterator begin() const { @@ -292,7 +292,7 @@ namespace hash_space { } const_iterator end() const { - return const_iterator(0, this); + return const_iterator(nullptr, this); } size_t get_bucket(const Value& val, size_t n) const { @@ -318,7 +318,7 @@ namespace hash_space { if (key_eq_fun(get_key(ent->val), get_key(val))) return ent; - if(!ins) return 0; + if(!ins) return nullptr; Entry* tmp = new Entry(val); tmp->next = from; @@ -336,7 +336,7 @@ namespace hash_space { if (key_eq_fun(get_key(ent->val), key)) return ent; - return 0; + return nullptr; } const_iterator find(const Key& key) const { @@ -381,7 +381,7 @@ namespace hash_space { if (new_size <= old_n) return; const size_t n = next_prime(new_size); if (n <= old_n) return; - Table tmp(n, (Entry*)(0)); + Table tmp(n, (Entry*)nullptr); for (size_t i = 0; i < old_n; ++i) { Entry* ent = buckets[i]; while (ent) { @@ -398,12 +398,12 @@ namespace hash_space { void clear() { for (size_t i = 0; i < buckets.size(); ++i) { - for (Entry* ent = buckets[i]; ent != 0;) { + for (Entry* ent = buckets[i]; ent != nullptr;) { Entry* next = ent->next; delete ent; ent = next; } - buckets[i] = 0; + buckets[i] = nullptr; } entries = 0; } diff --git a/src/interp/iz3interp.cpp b/src/interp/iz3interp.cpp old mode 100755 new mode 100644 index 91b0c5a63..3d1d84f3c --- a/src/interp/iz3interp.cpp +++ b/src/interp/iz3interp.cpp @@ -171,7 +171,7 @@ struct frame_reducer { template struct killme { T *p; - killme(){p = 0;} + killme(){p = nullptr;} void set(T *_p) {p = _p;} ~killme(){ if(p) @@ -205,7 +205,7 @@ public: const std::vector &parents, std::vector &interps, const std::vector &theory, - interpolation_options_struct *options = 0 + interpolation_options_struct *options = nullptr ){ #if 0 test_secondary(cnsts,parents,interps); @@ -229,7 +229,7 @@ public: parents_vec.clear(); // secondary prover no longer supported - iz3secondary *sp = NULL; + iz3secondary *sp = nullptr; #define BINARY_INTERPOLATION #ifndef BINARY_INTERPOLATION @@ -336,7 +336,7 @@ public: const std::vector &parents, std::vector &interps, const std::vector &theory, - interpolation_options_struct *options = 0 + interpolation_options_struct *options = nullptr ){ std::vector > cnsts_vec(cnsts.size()); for(unsigned i = 0; i < cnsts.size(); i++) @@ -350,7 +350,7 @@ public: const std::vector &_cnsts, const ast &tree, std::vector &interps, - interpolation_options_struct *options = 0 + interpolation_options_struct *options = nullptr ){ std::vector pos_map; @@ -524,7 +524,7 @@ lbool iz3interpolate(ast_manager &_m_manager, std::vector _cnsts; itp.assert_conjuncts(s,_cnsts,_tree); profiling::timer_start("solving"); - lbool res = s.check_sat(0,0); + lbool res = s.check_sat(0,nullptr); profiling::timer_stop("solving"); if(res == l_false){ ast *proof = s.get_proof(); diff --git a/src/interp/iz3interp.h b/src/interp/iz3interp.h index a4e1024a9..909703bed 100644 --- a/src/interp/iz3interp.h +++ b/src/interp/iz3interp.h @@ -78,7 +78,7 @@ void iz3interpolate(ast_manager &_m_manager, const ::vector &parents, ptr_vector &interps, const ptr_vector &theory, - interpolation_options_struct * options = 0); + interpolation_options_struct * options = nullptr); /* Same as above, but each constraint is a vector of formulas. */ @@ -88,7 +88,7 @@ void iz3interpolate(ast_manager &_m_manager, const ::vector &parents, ptr_vector &interps, const ptr_vector &theory, - interpolation_options_struct * options = 0); + interpolation_options_struct * options = nullptr); /* Compute an interpolant from a proof. This version uses the ast representation, for compatibility with the new API. Here, cnsts is diff --git a/src/interp/iz3mgr.cpp b/src/interp/iz3mgr.cpp old mode 100755 new mode 100644 index 7314403b0..bb37d7f48 --- a/src/interp/iz3mgr.cpp +++ b/src/interp/iz3mgr.cpp @@ -102,7 +102,7 @@ iz3mgr::ast iz3mgr::make(opr op, int n, raw_ast **args){ } iz3mgr::ast iz3mgr::mki(family_id fid, decl_kind dk, int n, raw_ast **args){ - return cook(m().mk_app(fid, dk, 0, 0, n, (expr **)args)); + return cook(m().mk_app(fid, dk, 0, nullptr, n, (expr **)args)); } iz3mgr::ast iz3mgr::make(opr op, const std::vector &args){ @@ -111,11 +111,11 @@ iz3mgr::ast iz3mgr::make(opr op, const std::vector &args){ a.resize(args.size()); for(unsigned i = 0; i < args.size(); i++) a[i] = args[i].raw(); - return make(op,args.size(), args.size() ? &a[0] : 0); + return make(op,args.size(), args.size() ? &a[0] : nullptr); } iz3mgr::ast iz3mgr::make(opr op){ - return make(op,0,0); + return make(op,0,nullptr); } iz3mgr::ast iz3mgr::make(opr op, const ast &arg0){ @@ -148,11 +148,11 @@ iz3mgr::ast iz3mgr::make(symb sym, const std::vector &args){ a.resize(args.size()); for(unsigned i = 0; i < args.size(); i++) a[i] = args[i].raw(); - return make(sym,args.size(), args.size() ? &a[0] : 0); + return make(sym,args.size(), args.size() ? &a[0] : nullptr); } iz3mgr::ast iz3mgr::make(symb sym){ - return make(sym,0,0); + return make(sym,0,nullptr); } iz3mgr::ast iz3mgr::make(symb sym, const ast &arg0){ @@ -201,8 +201,8 @@ iz3mgr::ast iz3mgr::make_quant(opr op, const std::vector &bvs, ast &body){ 0, symbol("itp"), symbol(), - 0, 0, - 0, 0 + 0, nullptr, + 0, nullptr ); return cook(result.get()); } diff --git a/src/interp/iz3mgr.h b/src/interp/iz3mgr.h old mode 100755 new mode 100644 index 8de1a44e8..49552f92f --- a/src/interp/iz3mgr.h +++ b/src/interp/iz3mgr.h @@ -63,7 +63,7 @@ public: raw_ast * const &raw() const {return _ast;} ast_i(raw_ast *a){_ast = a;} - ast_i(){_ast = 0;} + ast_i(){_ast = nullptr;} bool eq(const ast_i &other) const { return _ast == other._ast; } @@ -92,7 +92,7 @@ public: m->inc_ref(a); } - ast_r() {_m = 0;} + ast_r() {_m = nullptr;} ast_r(const ast_r &other) : ast_i(other) { _m = other._m; @@ -287,7 +287,7 @@ class iz3mgr { symb sym(const ast& t){ raw_ast *_ast = t.raw(); - return is_app(_ast) ? to_app(_ast)->get_decl() : 0; + return is_app(_ast) ? to_app(_ast)->get_decl() : nullptr; } std::string string_of_symbol(symb s){ diff --git a/src/interp/iz3profiling.cpp b/src/interp/iz3profiling.cpp old mode 100755 new mode 100644 index df3126e4f..ba4fd0206 --- a/src/interp/iz3profiling.cpp +++ b/src/interp/iz3profiling.cpp @@ -75,7 +75,7 @@ namespace profiling { node::node(){ time = 0; - parent = 0; + parent = nullptr; } struct node *current; diff --git a/src/interp/iz3proof.h b/src/interp/iz3proof.h old mode 100755 new mode 100644 index ba4507ba2..a7dcb9b75 --- a/src/interp/iz3proof.h +++ b/src/interp/iz3proof.h @@ -210,7 +210,7 @@ class iz3proof { } /** Default constructor */ - iz3proof(){pv = 0;} + iz3proof(){pv = nullptr;} protected: diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp old mode 100755 new mode 100644 index 4196d2016..9680ec95e --- a/src/interp/iz3translate.cpp +++ b/src/interp/iz3translate.cpp @@ -2188,7 +2188,7 @@ void iz3translation_full_conc_symbols_out_of_scope(iz3translation_full *p, int i struct stdio_fixer { stdio_fixer(){ - std::cout.rdbuf()->pubsetbuf(0,0); + std::cout.rdbuf()->pubsetbuf(nullptr,0); } } my_stdio_fixer; diff --git a/src/interp/iz3translate_direct.cpp b/src/interp/iz3translate_direct.cpp old mode 100755 new mode 100644 index 0d5b9ccc3..8c2016149 --- a/src/interp/iz3translate_direct.cpp +++ b/src/interp/iz3translate_direct.cpp @@ -1124,7 +1124,7 @@ public: for(unsigned i = 0; i < la.size(); i++) lits.push_back(mk_not(from_ast(conc(la[i])))); // lits.push_back(from_ast(conc(proof))); - Iproof::node res =fix_lemma(lits,hyps, lemma_nll ? nll : 0); + Iproof::node res =fix_lemma(lits,hyps, lemma_nll ? nll : nullptr); for(unsigned i = 0; i < la.size(); i++){ Iproof::node q = translate_main(la[i],nll,false); ast pnode = from_ast(conc(la[i])); @@ -1200,7 +1200,7 @@ public: Iproof::node res = iproof->make_contra(ipf,lits); for(unsigned i = 0; i < la.size(); i++){ - Iproof::node q = translate_main(la[i],0,false); + Iproof::node q = translate_main(la[i],nullptr,false); ast pnode = from_ast(conc(la[i])); assert(is_local(pnode) || equivs.find(pnode) != equivs.end()); Iproof::node neg = res; @@ -1381,8 +1381,8 @@ public: non_local_lits *find_nll(ResolventAppSet &proofs){ if(proofs.empty()) - return (non_local_lits *)0; - std::pair foo(non_local_lits(proofs),(non_local_lits *)0); + return (non_local_lits *)nullptr; + std::pair foo(non_local_lits(proofs),(non_local_lits *)nullptr); std::pair::iterator,bool> bar = non_local_lits_unique.insert(foo); non_local_lits *&res = bar.first->second; @@ -1392,7 +1392,7 @@ public: } Z3_resolvent *find_resolvent(ast proof, bool unit, ast pivot){ - std::pair foo(Z3_resolvent(proof,unit,pivot),(Z3_resolvent *)0); + std::pair foo(Z3_resolvent(proof,unit,pivot),(Z3_resolvent *)nullptr); std::pair::iterator,bool> bar = Z3_resolvent_unique.insert(foo); Z3_resolvent *&res = bar.first->second; @@ -1613,7 +1613,7 @@ public: Iproof::node translate(ast proof, Iproof &dst) override { iproof = &dst; - Iproof::node Ipf = translate_main(proof,0); // builds result in dst + Iproof::node Ipf = translate_main(proof,nullptr); // builds result in dst return Ipf; } diff --git a/src/math/automata/automaton.h b/src/math/automata/automaton.h index 41fc19907..de72d6b2d 100644 --- a/src/math/automata/automaton.h +++ b/src/math/automata/automaton.h @@ -43,7 +43,7 @@ public: unsigned m_src; unsigned m_dst; public: - move(M& m, unsigned s, unsigned d, T* t = 0): m(m), m_t(t), m_src(s), m_dst(d) { + move(M& m, unsigned s, unsigned d, T* t = nullptr): m(m), m_t(t), m_src(s), m_dst(d) { if (t) m.inc_ref(t); } ~move() { @@ -69,7 +69,7 @@ public: unsigned src() const { return m_src; } T* t() const { return m_t; } - bool is_epsilon() const { return m_t == 0; } + bool is_epsilon() const { return m_t == nullptr; } }; typedef vector moves; private: @@ -407,7 +407,7 @@ public: mvs1.push_back(move(m, mv1.src(), dst1, t)); } for (move const& mv1 : mvs1) { - remove(mv1.src(), dst, 0); + remove(mv1.src(), dst, nullptr); add(mv1); } remove(dst, dst1, t); @@ -431,7 +431,7 @@ public: else { continue; } - remove(src, dst, 0); + remove(src, dst, nullptr); --j; } } diff --git a/src/math/automata/symbolic_automata_def.h b/src/math/automata/symbolic_automata_def.h index be38a60bc..17a53fc33 100644 --- a/src/math/automata/symbolic_automata_def.h +++ b/src/math/automata/symbolic_automata_def.h @@ -399,7 +399,7 @@ typename symbolic_automata::automaton_t* symbolic_automata::mk_produ continue; } else if (is_sat == l_undef) { - return 0; + return nullptr; } unsigned_pair tgt_pair(mvsA[i].dst(), mvsB[j].dst()); unsigned tgt; diff --git a/src/math/euclid/euclidean_solver.cpp b/src/math/euclid/euclidean_solver.cpp index 1be239c36..70b424375 100644 --- a/src/math/euclid/euclidean_solver.cpp +++ b/src/math/euclid/euclidean_solver.cpp @@ -506,8 +506,8 @@ struct euclidean_solver::imp { } imp(numeral_manager * m): - m_manager(m == 0 ? alloc(numeral_manager) : m), - m_owns_m(m == 0), + m_manager(m == nullptr ? alloc(numeral_manager) : m), + m_owns_m(m == nullptr), m_decompose_buffer(*m_manager), m_as_buffer(*m_manager), m_bs_buffer(*m_manager), @@ -550,7 +550,7 @@ struct euclidean_solver::imp { return; equation * eq; if (j == null_justification) { - eq = mk_eq(num, as, xs, c, 0, 0, 0); + eq = mk_eq(num, as, xs, c, 0, nullptr, nullptr); } else { mpq one(1); @@ -694,7 +694,7 @@ struct euclidean_solver::imp { mpz new_c; decompose(m_next_pos_a, m_next_a, eq.m_c, new_c, eq.m_c); // create auxiliary equation - equation * new_eq = mk_eq(m_tmp_xs.size(), buffer.c_ptr(), m_tmp_xs.c_ptr(), new_c, 0, 0, 0, false); + equation * new_eq = mk_eq(m_tmp_xs.size(), buffer.c_ptr(), m_tmp_xs.c_ptr(), new_c, 0, nullptr, nullptr, false); // new_eq doesn't need to normalized, since it has unit coefficients TRACE("euclidean_solver", tout << "decomposition: new parameter x" << p << " aux eq:\n"; display(tout, *new_eq); tout << "\n"; diff --git a/src/math/grobner/grobner.cpp b/src/math/grobner/grobner.cpp index 3295c4eae..017f1cf77 100644 --- a/src/math/grobner/grobner.cpp +++ b/src/math/grobner/grobner.cpp @@ -29,7 +29,7 @@ grobner::grobner(ast_manager & m, v_dependency_manager & d): m_var_lt(m_var2weight), m_monomial_lt(m_var_lt), m_changed_leading_term(false), - m_unsat(0) { + m_unsat(nullptr) { } grobner::~grobner() { @@ -116,7 +116,7 @@ void grobner::reset() { m_to_process.reset(); m_equations_to_unfreeze.reset(); m_equations_to_delete.reset(); - m_unsat = 0; + m_unsat = nullptr; } void grobner::display_var(std::ostream & out, expr * var) const { @@ -410,7 +410,7 @@ void grobner::assert_monomial_tautology(expr * m) { m1->m_vars.push_back(m); eq->m_monomials.push_back(m1); normalize_coeff(eq->m_monomials); - init_equation(eq, static_cast(0)); \ + init_equation(eq, static_cast(nullptr)); \ m_to_process.insert(eq); } @@ -625,7 +625,7 @@ grobner::equation * grobner::copy_equation(equation const * eq) { grobner::equation * grobner::simplify(equation const * source, equation * target) { TRACE("grobner", tout << "simplifying: "; display_equation(tout, *target); tout << "using: "; display_equation(tout, *source);); if (source->get_num_monomials() == 0) - return 0; + return nullptr; m_stats.m_simplify++; bool result = false; bool simplified; @@ -676,7 +676,7 @@ grobner::equation * grobner::simplify(equation const * source, equation * target } while (simplified && !m_manager.canceled()); TRACE("grobner", tout << "result: "; display_equation(tout, *target);); - return result ? target : 0; + return result ? target : nullptr; } /** @@ -702,13 +702,13 @@ grobner::equation * grobner::simplify_using_processed(equation * eq) { eq = new_eq; } if (m_manager.canceled()) { - return 0; + return nullptr; } } } while (simplified); TRACE("grobner", tout << "simplification result: "; display_equation(tout, *eq);); - return result ? eq : 0; + return result ? eq : nullptr; } /** @@ -732,7 +732,7 @@ bool grobner::is_better_choice(equation * eq1, equation * eq2) { \brief Pick next unprocessed equation */ grobner::equation * grobner::pick_next() { - equation * r = 0; + equation * r = nullptr; ptr_buffer to_delete; equation_set::iterator it = m_to_process.begin(); equation_set::iterator end = m_to_process.end(); @@ -767,7 +767,7 @@ bool grobner::simplify_processed(equation * eq) { m_changed_leading_term = false; // if the leading term is simplified, then the equation has to be moved to m_to_process equation * new_curr = simplify(eq, curr); - if (new_curr != 0) { + if (new_curr != nullptr) { if (new_curr != curr) { m_equations_to_unfreeze.push_back(curr); to_remove.push_back(curr); @@ -817,7 +817,7 @@ void grobner::simplify_to_process(equation * eq) { for (; it != end; ++it) { equation * curr = *it; equation * new_curr = simplify(eq, curr); - if (new_curr != 0 && new_curr != curr) { + if (new_curr != nullptr && new_curr != curr) { m_equations_to_unfreeze.push_back(curr); to_insert.push_back(new_curr); to_remove.push_back(curr); @@ -947,7 +947,7 @@ bool grobner::compute_basis_step() { } #endif equation * new_eq = simplify_using_processed(eq); - if (new_eq != 0 && eq != new_eq) { + if (new_eq != nullptr && eq != new_eq) { // equation was updated using non destructive updates m_equations_to_unfreeze.push_back(eq); eq = new_eq; diff --git a/src/math/grobner/grobner.h b/src/math/grobner/grobner.h index f024a33e4..9233866d5 100644 --- a/src/math/grobner/grobner.h +++ b/src/math/grobner/grobner.h @@ -220,25 +220,25 @@ public: \brief Assert the given equality. This method assumes eq is simplified. */ - void assert_eq(expr * eq, v_dependency * ex = 0); + void assert_eq(expr * eq, v_dependency * ex = nullptr); /** \brief Assert the equality monomials[0] + ... + monomials[num_monomials - 1] = 0. This method assumes the monomials were simplified. */ - void assert_eq_0(unsigned num_monomials, expr * const * monomials, v_dependency * ex = 0); + void assert_eq_0(unsigned num_monomials, expr * const * monomials, v_dependency * ex = nullptr); /** \brief Assert the equality monomials[0] + ... + monomials[num_monomials - 1] = 0. This method assumes the monomials were simplified. */ - void assert_eq_0(unsigned num_monomials, monomial * const * monomials, v_dependency * ex = 0); + void assert_eq_0(unsigned num_monomials, monomial * const * monomials, v_dependency * ex = nullptr); /** \brief Assert the equality coeffs[0] * monomials[0] + ... + coeffs[num_monomials-1] * monomials[num_monomials - 1] = 0. This method assumes the monomials were simplified. */ - void assert_eq_0(unsigned num_monomials, rational const * coeffs, expr * const * monomials, v_dependency * ex = 0); + void assert_eq_0(unsigned num_monomials, rational const * coeffs, expr * const * monomials, v_dependency * ex = nullptr); /** \brief Assert the monomial tautology (quote (x_1 * ... * x_n)) - x_1 * ... * x_n = 0 @@ -263,7 +263,7 @@ public: /** \brief Return true if an inconsistency was detected. */ - bool inconsistent() const { return m_unsat != 0; } + bool inconsistent() const { return m_unsat != nullptr; } /** \brief Simplify the given expression using the equalities asserted diff --git a/src/math/hilbert/heap_trie.h b/src/math/hilbert/heap_trie.h index e53f9e7dc..3c6ecd1cb 100644 --- a/src/math/hilbert/heap_trie.h +++ b/src/math/hilbert/heap_trie.h @@ -195,9 +195,9 @@ public: m_le(le), m_num_keys(0), m_do_reshuffle(4), - m_root(0), - m_spare_leaf(0), - m_spare_trie(0) + m_root(nullptr), + m_spare_leaf(nullptr), + m_spare_trie(nullptr) {} ~heap_trie() { @@ -283,7 +283,7 @@ public: ++m_stats.m_num_removes; // assumption: key is in table. node* n = m_root; - node* m = 0; + node* m = nullptr; for (unsigned i = 0; i < num_keys(); ++i) { n->dec_ref(); VERIFY (to_trie(n)->find(get_key(keys, i), m)); diff --git a/src/math/hilbert/hilbert_basis.cpp b/src/math/hilbert/hilbert_basis.cpp index bbc56bdd5..d6d4366db 100644 --- a/src/math/hilbert/hilbert_basis.cpp +++ b/src/math/hilbert/hilbert_basis.cpp @@ -174,7 +174,7 @@ class hilbert_basis::value_index2 { struct checker : public ht::check_value { hilbert_basis* hb; offset_t m_value; - checker(): hb(0) {} + checker(): hb(nullptr) {} bool operator()(unsigned const& v) override { if (m_value.m_offset != v) { // && hb->is_subsumed(m_value, offset_t(v))) { return true; @@ -278,7 +278,7 @@ public: m_zero.insert(idx, vs); } else { - value_index* map = 0; + value_index* map = nullptr; if (!m_neg.find(vs.weight(), map)) { map = alloc(value_index, hb); map->reset(m_num_ineqs); diff --git a/src/math/polynomial/algebraic_numbers.cpp b/src/math/polynomial/algebraic_numbers.cpp index 8c42bb418..5811811fc 100644 --- a/src/math/polynomial/algebraic_numbers.cpp +++ b/src/math/polynomial/algebraic_numbers.cpp @@ -48,7 +48,7 @@ namespace algebraic_numbers { unsigned m_sign_lower:1; unsigned m_not_rational:1; // if true we know for sure it is not a rational unsigned m_i:29; // number is the i-th root of p, 0 if it is not known which root of p the number is. - algebraic_cell():m_p_sz(0), m_p(0), m_minimal(false), m_not_rational(false), m_i(0) {} + algebraic_cell():m_p_sz(0), m_p(nullptr), m_minimal(false), m_not_rational(false), m_i(0) {} bool is_minimal() const { return m_minimal != 0; } }; @@ -186,7 +186,7 @@ namespace algebraic_numbers { for (unsigned i = 0; i < c->m_p_sz; i++) qm().del(c->m_p[i]); m_allocator.deallocate(sizeof(mpz)*c->m_p_sz, c->m_p); - c->m_p = 0; + c->m_p = nullptr; c->m_p_sz = 0; } @@ -201,13 +201,13 @@ namespace algebraic_numbers { } void del(numeral & a) { - if (a.m_cell == 0) + if (a.m_cell == nullptr) return; if (a.is_basic()) del(a.to_basic()); else del(a.to_algebraic()); - a.m_cell = 0; + a.m_cell = nullptr; } void reset(numeral & a) { @@ -215,7 +215,7 @@ namespace algebraic_numbers { } bool is_zero(numeral const & a) { - return a.m_cell == 0; + return a.m_cell == nullptr; } bool is_pos(numeral const & a) { @@ -361,7 +361,7 @@ namespace algebraic_numbers { basic_cell * mk_basic_cell(mpq & n) { if (qm().is_zero(n)) - return 0; + return nullptr; void * mem = static_cast(m_allocator.allocate(sizeof(basic_cell))); basic_cell * c = new (mem) basic_cell(); qm().swap(c->m_value, n); @@ -1037,7 +1037,7 @@ namespace algebraic_numbers { unsigned target_i = UINT_MAX; // index of sequence that is isolating int target_lV = 0, target_uV = 0; for (unsigned i = 0; i < num_fs; i++) { - if (seqs[i] == 0) + if (seqs[i] == nullptr) continue; // sequence was discarded because it does not contain the root. TRACE("anum_mk_binary", tout << "sequence " << i << "\n"; upm().display(tout, *(seqs[i])); tout << "\n";); int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower()); @@ -1050,7 +1050,7 @@ namespace algebraic_numbers { ); if (V <= 0) { // discard sequence, since factor does not contain the root - seqs.set(i, 0); + seqs.set(i, nullptr); } else if (V == 1) { target_i = i; @@ -1115,7 +1115,7 @@ namespace algebraic_numbers { unsigned target_i = UINT_MAX; // index of sequence that is isolating int target_lV = 0, target_uV = 0; for (unsigned i = 0; i < num_fs; i++) { - if (seqs[i] == 0) + if (seqs[i] == nullptr) continue; // sequence was discarded because it does not contain the root. int lV = upm().sign_variations_at(*(seqs[i]), r_i.lower()); int uV = upm().sign_variations_at(*(seqs[i]), r_i.upper()); @@ -1126,7 +1126,7 @@ namespace algebraic_numbers { ); if (V <= 0) { // discard sequence, since factor does not contain the root - seqs.set(i, 0); + seqs.set(i, nullptr); } else if (V == 1) { target_i = i; @@ -2772,7 +2772,7 @@ namespace algebraic_numbers { manager::manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) { m_own_allocator = false; m_allocator = a; - if (m_allocator == 0) { + if (m_allocator == nullptr) { m_own_allocator = true; m_allocator = alloc(small_object_allocator, "algebraic"); } diff --git a/src/math/polynomial/algebraic_numbers.h b/src/math/polynomial/algebraic_numbers.h index 3a8ee766b..fa9731b62 100644 --- a/src/math/polynomial/algebraic_numbers.h +++ b/src/math/polynomial/algebraic_numbers.h @@ -58,7 +58,7 @@ namespace algebraic_numbers { typedef _scoped_numeral scoped_numeral; typedef _scoped_numeral_vector scoped_numeral_vector; - manager(reslimit& rl, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0); + manager(reslimit& rl, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr); ~manager(); static void get_param_descrs(param_descrs & r); @@ -372,7 +372,7 @@ namespace algebraic_numbers { basic_cell * to_basic() const { SASSERT(is_basic()); return UNTAG(basic_cell*, m_cell); } algebraic_cell * to_algebraic() const { SASSERT(!is_basic()); return UNTAG(algebraic_cell*, m_cell); } public: - anum():m_cell(0) {} + anum():m_cell(nullptr) {} }; }; diff --git a/src/math/polynomial/polynomial.cpp b/src/math/polynomial/polynomial.cpp index d6eafac05..a58f26597 100644 --- a/src/math/polynomial/polynomial.cpp +++ b/src/math/polynomial/polynomial.cpp @@ -510,7 +510,7 @@ namespace polynomial { monomial * allocate(unsigned capacity) { void * mem = memory::allocate(monomial::get_obj_size(capacity)); - return new (mem) monomial(UINT_MAX, 0, 0, 0); + return new (mem) monomial(UINT_MAX, 0, nullptr, 0); } void deallocate(monomial * ptr, unsigned capacity) { @@ -776,10 +776,10 @@ namespace polynomial { tmp_monomial m_tmp3; svector m_powers_tmp; public: - monomial_manager(small_object_allocator * a = 0) { + monomial_manager(small_object_allocator * a = nullptr) { m_ref_count = 0; m_next_var = 0; - if (a == 0) { + if (a == nullptr) { m_allocator = alloc(small_object_allocator, "polynomial"); m_own_allocator = true; } @@ -787,7 +787,7 @@ namespace polynomial { m_allocator = a; m_own_allocator = false; } - m_unit = mk_monomial(0, static_cast(0)); + m_unit = mk_monomial(0, static_cast(nullptr)); inc_ref(m_unit); } @@ -1185,7 +1185,7 @@ namespace polynomial { sqrt_tmp.reserve(sz); for (unsigned i = 0; i < sz; i++) { if (m->degree(i) % 2 == 1) - return 0; + return nullptr; sqrt_tmp.set_power(i, power(m->get_var(i), m->degree(i) / 2)); } sqrt_tmp.set_size(sz); @@ -1927,7 +1927,7 @@ namespace polynomial { } public: - som_buffer():m_owner(0) {} + som_buffer():m_owner(nullptr) {} void reset() { if (empty()) @@ -2173,7 +2173,7 @@ namespace polynomial { public: som_buffer_vector() { - m_owner = 0; + m_owner = nullptr; } ~som_buffer_vector() { @@ -2185,7 +2185,7 @@ namespace polynomial { void set_owner(imp * owner) { SASSERT(m_owner == owner || m_owner == 0); - if (m_owner == 0) { + if (m_owner == nullptr) { m_owner = owner; unsigned sz = m_buffers.size(); for (unsigned i = 0; i < sz; i++) { @@ -2222,7 +2222,7 @@ namespace polynomial { numeral_vector m_tmp_as; monomial_vector m_tmp_ms; public: - cheap_som_buffer():m_owner(0) {} + cheap_som_buffer():m_owner(nullptr) {} void set_owner(imp * o) { m_owner = o; } bool empty() const { return m_tmp_ms.empty(); } @@ -2306,12 +2306,12 @@ namespace polynomial { cheap_som_buffer m_cheap_som_buffer2; void init() { - m_del_eh = 0; + m_del_eh = nullptr; m_som_buffer.set_owner(this); m_som_buffer2.set_owner(this); m_cheap_som_buffer.set_owner(this); m_cheap_som_buffer2.set_owner(this); - m_zero = mk_polynomial_core(0, 0, 0); + m_zero = mk_polynomial_core(0, nullptr, nullptr); m().set(m_zero_numeral, 0); inc_ref(m_zero); numeral one(1); @@ -2326,7 +2326,7 @@ namespace polynomial { m_wrapper(w), m_manager(m), m_upm(lim, m) { - if (mm == 0) + if (mm == nullptr) mm = alloc(monomial_manager); m_monomial_manager = mm; m_monomial_manager->inc_ref(); @@ -2419,13 +2419,13 @@ namespace polynomial { void del(polynomial * p) { TRACE("polynomial", tout << "deleting: "; p->display(tout, m_manager); tout << "\n";); - if (m_del_eh != 0) { + if (m_del_eh != nullptr) { del_eh * curr = m_del_eh; do { (*curr)(p); curr = curr->m_next; } - while (curr != 0); + while (curr != nullptr); } unsigned sz = p->size(); unsigned obj_sz = polynomial::get_obj_size(sz); @@ -2924,7 +2924,7 @@ namespace polynomial { imp * m_imp; ptr_vector m_data; public: - newton_interpolator_vector():m_imp(0) {} + newton_interpolator_vector():m_imp(nullptr) {} ~newton_interpolator_vector() { flush(); @@ -2983,7 +2983,7 @@ namespace polynomial { ms.push_back(p->m(i)); } std::sort(ms.begin(), ms.end(), lex_lt2(x)); - monomial * prev = 0; + monomial * prev = nullptr; for (unsigned i = 0; i < sz; i++) { monomial * orig_m = ms[i]; monomial * m; @@ -3831,7 +3831,7 @@ namespace polynomial { r = mk_const(d_a); return; } - if (C_star.get() == 0) { + if (C_star.get() == nullptr) { C_star = q; m().set(bound, p); } @@ -4153,7 +4153,7 @@ namespace polynomial { counter = 0; min_deg_q = deg_q; // start from scratch - if (sk == 0) { + if (sk == nullptr) { interpolator.reset(); interpolator.add(val, q); } @@ -4165,7 +4165,7 @@ namespace polynomial { } else if (deg_q == min_deg_q) { TRACE("mgcd_detail", tout << "adding sample point...\n";); - if (sk == 0) { + if (sk == nullptr) { interpolator.add(val, q); } else { @@ -4178,7 +4178,7 @@ namespace polynomial { continue; } bool found_candidate = false; - if (sk == 0) { + if (sk == nullptr) { SASSERT(interpolator.num_sample_points() > 0); interpolator.mk(x, H); TRACE("mgcd_detail", tout << "idx: " << idx << "\ncandidate H: " << H << "\n";); @@ -4214,14 +4214,14 @@ namespace polynomial { r = mul(ci_g, r); done = true; } - else if (sk != 0) { + else if (sk != nullptr) { throw sparse_mgcd_failed(); } } if (done) { TRACE("mgcd", tout << "idx: " << idx << "\nresult: " << r << "\n";); - if (sk == 0 && m_use_sparse_gcd) { + if (sk == nullptr && m_use_sparse_gcd) { // save skeleton skeleton * new_sk = alloc(skeleton, *this, H, x); m_mgcd_skeletons.set(idx, new_sk); @@ -4255,7 +4255,7 @@ namespace polynomial { m_mgcd_skeletons.reset(); for (unsigned i = 0; i < num_vars; i++) { vars.push_back(var_min_degrees[i].get_var()); - m_mgcd_skeletons.push_back(0); + m_mgcd_skeletons.push_back(nullptr); } scoped_numeral c_u(m()), c_v(m()); @@ -4311,7 +4311,7 @@ namespace polynomial { r = mk_const(d_a); return; } - if (C_star.get() == 0) { + if (C_star.get() == nullptr) { C_star = q; m().set(bound, p); } @@ -4903,7 +4903,7 @@ namespace polynomial { */ template void pseudo_division_core(polynomial const * p, polynomial const * q, var x, unsigned & d, polynomial_ref & Q, polynomial_ref & R, - var2degree const * x2d = 0) { + var2degree const * x2d = nullptr) { SASSERT(is_valid(x)); SASSERT(!ModD || x2d != 0); TRACE("polynomial", tout << "pseudo_division\np: "; p->display(tout, m_manager); @@ -5138,7 +5138,7 @@ namespace polynomial { } monomial const * m_r = R.m(max_R); numeral const & a_r = R.a(max_R); - monomial * m_r_q = 0; + monomial * m_r_q = nullptr; VERIFY(div(m_r, m_q, m_r_q)); TRACE("polynomial", tout << "m_r: "; m_r->display(tout); tout << "\nm_q: "; m_q->display(tout); tout << "\n"; if (m_r_q) { tout << "m_r_q: "; m_r_q->display(tout); tout << "\n"; }); @@ -5175,7 +5175,7 @@ namespace polynomial { } monomial const * m_r = R.m(max_R); numeral const & a_r = R.a(max_R); - monomial * m_r_q = 0; + monomial * m_r_q = nullptr; bool q_div_r = div(m_r, m_q, m_r_q); m_r_q_ref = m_r_q; TRACE("polynomial", tout << "m_r: "; m_r->display(tout); tout << "\nm_q: "; m_q->display(tout); tout << "\n"; @@ -5639,7 +5639,7 @@ namespace polynomial { pw(h1, d1, hs1); hs1 = mul(g1, hs1); G3 = exact_div(Gh3, hs1); - hs1 = 0; + hs1 = nullptr; } // prepare for next iteration @@ -6083,7 +6083,7 @@ namespace polynomial { polynomial_vector::iterator end2 = m_polynomials.end(); for (; it2 != end2; ++it2) { polynomial * p = *it2; - if (p == 0) + if (p == nullptr) continue; p->make_first_maximal(); SASSERT(p->size() <= 1 || !p->lex_sorted()); @@ -6404,7 +6404,7 @@ namespace polynomial { result = const_cast(r); return; } - result = 0; + result = nullptr; polynomial_ref p1(pm()), q1(pm()); polynomial_ref_buffer ps(pm()); unsigned sz = r->size(); diff --git a/src/math/polynomial/polynomial.h b/src/math/polynomial/polynomial.h index c4dedb043..43774f0ac 100644 --- a/src/math/polynomial/polynomial.h +++ b/src/math/polynomial/polynomial.h @@ -192,7 +192,7 @@ namespace polynomial { private: imp * m_imp; public: - manager(reslimit& lim, numeral_manager & m, monomial_manager * mm = 0); + manager(reslimit& lim, numeral_manager & m, monomial_manager * mm = nullptr); manager(reslimit& lim, numeral_manager & m, small_object_allocator * a); ~manager(); @@ -227,7 +227,7 @@ namespace polynomial { friend class manager; del_eh * m_next; public: - del_eh():m_next(0) {} + del_eh():m_next(nullptr) {} virtual void operator()(polynomial * p) = 0; }; diff --git a/src/math/polynomial/polynomial_cache.cpp b/src/math/polynomial/polynomial_cache.cpp index 9a021ce36..a617e9412 100644 --- a/src/math/polynomial/polynomial_cache.cpp +++ b/src/math/polynomial/polynomial_cache.cpp @@ -47,7 +47,7 @@ namespace polynomial { m_x(x), m_hash(h), m_result_sz(0), - m_result(0) { + m_result(nullptr) { } struct hash_proc { unsigned operator()(psc_chain_entry const * entry) const { return entry->m_hash; } }; @@ -69,7 +69,7 @@ namespace polynomial { m_p(p), m_hash(h), m_result_sz(0), - m_result(0) { + m_result(nullptr) { } struct hash_proc { unsigned operator()(factor_entry const * entry) const { return entry->m_hash; } }; diff --git a/src/math/polynomial/rpolynomial.cpp b/src/math/polynomial/rpolynomial.cpp index 5e7a829f6..90db9c832 100644 --- a/src/math/polynomial/rpolynomial.cpp +++ b/src/math/polynomial/rpolynomial.cpp @@ -63,8 +63,8 @@ namespace rpolynomial { m_wrapper(w), m_manager(m), m_allocator(a), - m_own_allocator(a == 0) { - if (a == 0) + m_own_allocator(a == nullptr) { + if (a == nullptr) m_allocator = alloc(small_object_allocator, "rpolynomial"); } @@ -107,7 +107,7 @@ namespace rpolynomial { unsigned sz = p->size(); for (unsigned i = 0; i < sz; i++) { poly_or_num * pn = p->arg(i); - if (pn == 0) + if (pn == nullptr) continue; if (is_num(pn)) { del_numeral(to_num_ptr(pn)); @@ -141,11 +141,11 @@ namespace rpolynomial { static bool is_const(polynomial const * p) { SASSERT(p == 0 || (p->max_var() == null_var) == (p->size() == 1 && p->arg(0) != 0 && is_num(p->arg(0)))); - return p == 0 || p->max_var() == null_var; + return p == nullptr || p->max_var() == null_var; } bool is_zero(polynomial const * p) { - return p == 0; + return p == nullptr; } static bool is_univariate(polynomial const * p) { @@ -154,7 +154,7 @@ namespace rpolynomial { unsigned sz = p->size(); for (unsigned i = 0; i < sz; i++) { poly_or_num * pn = p->arg(i); - if (pn == 0) + if (pn == nullptr) continue; if (is_poly(pn)) return false; @@ -169,7 +169,7 @@ namespace rpolynomial { SASSERT(sz > 0); SASSERT(p->arg(sz - 1) != 0); for (unsigned i = 0; i < sz - 1; i++) { - if (p->arg(i) != 0) + if (p->arg(i) != nullptr) return false; } SASSERT(is_poly(p->arg(sz - 1))); @@ -179,13 +179,13 @@ namespace rpolynomial { unsigned degree(polynomial const * p) { SASSERT(p != 0); SASSERT(p->size() > 0); - return p == 0 ? 0 : p->size() - 1; + return p == nullptr ? 0 : p->size() - 1; } bool eq(polynomial const * p1, polynomial const * p2) { if (p1 == p2) return true; - if (p1 == 0 || p2 == 0) + if (p1 == nullptr || p2 == nullptr) return false; if (p1->size() != p2->size()) return false; @@ -195,9 +195,9 @@ namespace rpolynomial { for (unsigned i = 0; i < sz; i++) { poly_or_num * pn1 = p1->arg(i); poly_or_num * pn2 = p2->arg(i); - if (pn1 == 0 && pn2 == 0) + if (pn1 == nullptr && pn2 == nullptr) continue; - if (pn1 == 0 || pn2 == 0) + if (pn1 == nullptr || pn2 == nullptr) return false; if (is_num(pn1) && is_num(pn2)) { if (!m_manager.eq(to_num(pn1), to_num(pn2))) @@ -217,7 +217,7 @@ namespace rpolynomial { void inc_ref_args(unsigned sz, poly_or_num * const * args) { for (unsigned i = 0; i < sz; i++) { poly_or_num * pn = args[i]; - if (pn == 0 || is_num(pn)) + if (pn == nullptr || is_num(pn)) continue; inc_ref(to_poly(pn)); } @@ -226,7 +226,7 @@ namespace rpolynomial { void dec_ref_args(unsigned sz, poly_or_num * const * args) { for (unsigned i = 0; i < sz; i++) { poly_or_num * pn = args[i]; - if (pn == 0 || is_num(pn)) + if (pn == nullptr || is_num(pn)) continue; dec_ref(to_poly(pn)); } @@ -234,7 +234,7 @@ namespace rpolynomial { unsigned trim(unsigned sz, poly_or_num * const * args) { while (sz > 0) { - if (args[sz - 1] != 0) + if (args[sz - 1] != nullptr) return sz; sz--; } @@ -281,8 +281,8 @@ namespace rpolynomial { polynomial * mk_poly(unsigned sz, poly_or_num * const * args, var max_var) { poly_or_num * _p = mk_poly_core(sz, args, max_var); - if (_p == 0) - return 0; + if (_p == nullptr) + return nullptr; else if (is_num(_p)) return allocate_poly(1, &_p, null_var); else @@ -291,7 +291,7 @@ namespace rpolynomial { polynomial * mk_const(numeral const & n) { if (m_manager.is_zero(n)) - return 0; + return nullptr; numeral * a = mk_numeral(); m_manager.set(*a, n); poly_or_num * _a = to_poly_or_num(a); @@ -322,8 +322,8 @@ namespace rpolynomial { } poly_or_num * unpack(polynomial const * p) { - if (p == 0) { - return 0; + if (p == nullptr) { + return nullptr; } else if (is_const(p)) { SASSERT(p->size() == 1); @@ -336,8 +336,8 @@ namespace rpolynomial { } polynomial * pack(poly_or_num * p) { - if (p == 0) - return 0; + if (p == nullptr) + return nullptr; else if (is_num(p)) return mk_poly(1, &p, null_var); else @@ -345,8 +345,8 @@ namespace rpolynomial { } poly_or_num * mul_core(numeral const & c, poly_or_num * p) { - if (m_manager.is_zero(c) || p == 0) { - return 0; + if (m_manager.is_zero(c) || p == nullptr) { + return nullptr; } else if (is_num(p)) { numeral * r = mk_numeral(); @@ -379,7 +379,7 @@ namespace rpolynomial { if (m_manager.is_zero(c)) { return p; } - else if (p == 0) { + else if (p == nullptr) { numeral * r = mk_numeral(); m_manager.set(*r, c); return to_poly_or_num(r); @@ -388,7 +388,7 @@ namespace rpolynomial { numeral a; m_manager.add(c, to_num(p), a); if (m_manager.is_zero(a)) - return 0; + return nullptr; numeral * new_arg = mk_numeral(); m_manager.swap(*new_arg, a); return to_poly_or_num(new_arg); @@ -662,7 +662,7 @@ namespace rpolynomial { while (i > 0) { --i; poly_or_num * pn = p->arg(i); - if (pn == 0) + if (pn == nullptr) continue; if (first) first = false; @@ -730,7 +730,7 @@ namespace rpolynomial { } bool manager::is_zero(polynomial const * p) { - return p == 0; + return p == nullptr; } #if 0 diff --git a/src/math/polynomial/rpolynomial.h b/src/math/polynomial/rpolynomial.h index f2ba78894..ba51f785e 100644 --- a/src/math/polynomial/rpolynomial.h +++ b/src/math/polynomial/rpolynomial.h @@ -51,7 +51,7 @@ namespace rpolynomial { private: imp * m_imp; public: - manager(numeral_manager & m, small_object_allocator * a = 0); + manager(numeral_manager & m, small_object_allocator * a = nullptr); ~manager(); numeral_manager & m() const; diff --git a/src/math/polynomial/upolynomial.cpp b/src/math/polynomial/upolynomial.cpp index fe890b040..f7cc16de2 100644 --- a/src/math/polynomial/upolynomial.cpp +++ b/src/math/polynomial/upolynomial.cpp @@ -190,7 +190,7 @@ namespace upolynomial { // Copy elements from p to buffer. void core_manager::set(unsigned sz, numeral const * p, numeral_vector & buffer) { - if (p != 0 && buffer.c_ptr() == p) { + if (p != nullptr && buffer.c_ptr() == p) { SASSERT(buffer.size() == sz); return; } diff --git a/src/math/polynomial/upolynomial.h b/src/math/polynomial/upolynomial.h index f8efae465..6bd3e4a27 100644 --- a/src/math/polynomial/upolynomial.h +++ b/src/math/polynomial/upolynomial.h @@ -117,7 +117,7 @@ namespace upolynomial { numeral_vector m_sqf_tmp2; numeral_vector m_pw_tmp; - static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.c_ptr() != 0 && buffer.c_ptr() == p; } + static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.c_ptr() != nullptr && buffer.c_ptr() == p; } void neg_core(unsigned sz1, numeral const * p1, numeral_vector & buffer); void add_core(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer); void sub_core(unsigned sz1, numeral const * p1, unsigned sz2, numeral const * p2, numeral_vector & buffer); diff --git a/src/math/realclosure/mpz_matrix.cpp b/src/math/realclosure/mpz_matrix.cpp index 62a328b8d..3bbd387c6 100644 --- a/src/math/realclosure/mpz_matrix.cpp +++ b/src/math/realclosure/mpz_matrix.cpp @@ -49,7 +49,7 @@ void mpz_matrix_manager::mk(unsigned m, unsigned n, mpz_matrix & A) { } void mpz_matrix_manager::del(mpz_matrix & A) { - if (A.a_ij != 0) { + if (A.a_ij != nullptr) { for (unsigned i = 0; i < A.m; i++) for (unsigned j = 0; j < A.n; j++) nm().del(A(i,j)); @@ -57,7 +57,7 @@ void mpz_matrix_manager::del(mpz_matrix & A) { m_allocator.deallocate(sz, A.a_ij); A.m = 0; A.n = 0; - A.a_ij = 0; + A.a_ij = nullptr; } } @@ -208,7 +208,7 @@ bool mpz_matrix_manager::eliminate(mpz_matrix & A, mpz * b, unsigned k1, unsigne // a_ik <- 0 nm().set(A(i, k2), 0); // normalize row i - if (!normalize_row(A.row(i), A.n, b ? &(b[i]) : 0, int_solver)) + if (!normalize_row(A.row(i), A.n, b ? &(b[i]) : nullptr, int_solver)) return false; } SASSERT(nm().is_zero(A(i, k2))); @@ -386,7 +386,7 @@ unsigned mpz_matrix_manager::linear_independent_rows(mpz_matrix const & _A, unsi r_sz++; if (r_sz >= A.n()) break; - eliminate(A, 0, k1, k2, false); + eliminate(A, nullptr, k1, k2, false); k2++; } std::sort(r, r + r_sz); diff --git a/src/math/realclosure/mpz_matrix.h b/src/math/realclosure/mpz_matrix.h index f5d7358da..92716ec0d 100644 --- a/src/math/realclosure/mpz_matrix.h +++ b/src/math/realclosure/mpz_matrix.h @@ -45,7 +45,7 @@ class mpz_matrix { unsigned n; mpz * a_ij; public: - mpz_matrix():m(0), n(0), a_ij(0) {} + mpz_matrix():m(0), n(0), a_ij(nullptr) {} mpz const & operator()(unsigned i, unsigned j) const { SASSERT(i < m); SASSERT(j < n); diff --git a/src/math/realclosure/realclosure.cpp b/src/math/realclosure/realclosure.cpp index 3f399990d..d41937c29 100644 --- a/src/math/realclosure/realclosure.cpp +++ b/src/math/realclosure/realclosure.cpp @@ -162,7 +162,7 @@ namespace realclosure { // To cope with this issue, we cache the value m_interval in m_old_interval whenever the width of m_interval is below // a give threshold. Then, after finishing OP, we restore the old_interval. mpbqi * m_old_interval; - value(bool rat):m_ref_count(0), m_rational(rat), m_old_interval(0) {} + value(bool rat):m_ref_count(0), m_rational(rat), m_old_interval(nullptr) {} bool is_rational() const { return m_rational; } mpbqi const & interval() const { return m_interval; } mpbqi & interval() { return m_interval; } @@ -220,7 +220,7 @@ namespace realclosure { mpbqi m_interval; mpbqi * m_old_interval; - extension(kind k, unsigned idx):m_ref_count(0), m_kind(k), m_idx(idx), m_old_interval(0) {} + extension(kind k, unsigned idx):m_ref_count(0), m_kind(k), m_idx(idx), m_old_interval(nullptr) {} unsigned idx() const { return m_idx; } kind knd() const { return static_cast(m_kind); } @@ -256,7 +256,7 @@ namespace realclosure { unsigned m_mark:1; // auxiliary mark used during deletion int m_sign; // Sign of the polynomial associated with m_q_idx sign_condition * m_prev; // Antecedent - sign_condition():m_q_idx(0), m_mark(false), m_sign(0), m_prev(0) {} + sign_condition():m_q_idx(0), m_mark(false), m_sign(0), m_prev(nullptr) {} sign_condition(unsigned qidx, int sign, sign_condition * prev):m_q_idx(qidx), m_mark(false), m_sign(sign), m_prev(prev) {} sign_condition * prev() const { return m_prev; } @@ -287,13 +287,13 @@ namespace realclosure { unsigned m_sc_idx; //!< != UINT_MAX if m_sign_det != 0, in this case m_sc_idx < m_sign_det->m_sign_conditions.size() bool m_depends_on_infinitesimals; //!< True if the polynomial p depends on infinitesimal extensions. - algebraic(unsigned idx):extension(ALGEBRAIC, idx), m_sign_det(0), m_sc_idx(0), m_depends_on_infinitesimals(false) {} + algebraic(unsigned idx):extension(ALGEBRAIC, idx), m_sign_det(nullptr), m_sc_idx(0), m_depends_on_infinitesimals(false) {} polynomial const & p() const { return m_p; } bool depends_on_infinitesimals() const { return m_depends_on_infinitesimals; } sign_det * sdt() const { return m_sign_det; } unsigned sc_idx() const { return m_sc_idx; } - unsigned num_roots_inside_interval() const { return m_sign_det == 0 ? 1 : m_sign_det->num_roots(); } + unsigned num_roots_inside_interval() const { return m_sign_det == nullptr ? 1 : m_sign_det->num_roots(); } mpbqi & iso_interval() { return m_iso_interval; } }; @@ -497,8 +497,8 @@ namespace realclosure { imp(reslimit& lim, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a): m_limit(lim), - m_allocator(a == 0 ? alloc(small_object_allocator, "realclosure") : a), - m_own_allocator(a == 0), + m_allocator(a == nullptr ? alloc(small_object_allocator, "realclosure") : a), + m_own_allocator(a == nullptr), m_qm(qm), m_mm(m_qm, *m_allocator), m_bqm(m_qm), @@ -509,8 +509,8 @@ namespace realclosure { mpq one(1); m_one = mk_rational(one); inc_ref(m_one); - m_pi = 0; - m_e = 0; + m_pi = nullptr; + m_e = nullptr; m_exec_depth = 0; @@ -657,7 +657,7 @@ namespace realclosure { */ template void save_interval(T * v, ptr_vector & to_restore) { - if (v->m_old_interval != 0) + if (v->m_old_interval != nullptr) return; // interval was already saved. to_restore.push_back(v); inc_ref(v); @@ -698,7 +698,7 @@ namespace realclosure { set_interval(v->m_interval, *(v->m_old_interval)); bqim().del(*(v->m_old_interval)); allocator().deallocate(sizeof(mpbqi), v->m_old_interval); - v->m_old_interval = 0; + v->m_old_interval = nullptr; dec_ref(v); } to_restore.reset(); @@ -811,12 +811,12 @@ namespace realclosure { } void inc_ref_sign_det(sign_det * sd) { - if (sd != 0) + if (sd != nullptr) sd->m_ref_count++; } void dec_ref_sign_det(sign_det * sd) { - if (sd != 0) { + if (sd != nullptr) { sd->m_ref_count--; if (sd->m_ref_count == 0) { del_sign_det(sd); @@ -887,7 +887,7 @@ namespace realclosure { void del(numeral & a) { dec_ref(a.m_value); - a.m_value = 0; + a.m_value = nullptr; } void del(numeral_vector & v) { @@ -910,7 +910,7 @@ namespace realclosure { \brief Return true if v is zero. */ static bool is_zero(value * v) { - return v == 0; + return v == nullptr; } /** @@ -1260,14 +1260,14 @@ namespace realclosure { } rational_function_value * mk_rational_function_value_core(algebraic * ext, unsigned num_sz, value * const * num) { - return mk_rational_function_value_core(ext, num_sz, num, 0, 0); + return mk_rational_function_value_core(ext, num_sz, num, 0, nullptr); } /** \brief Create a value using the given extension. */ rational_function_value * mk_rational_function_value(extension * ext) { - value * num[2] = { 0, one() }; + value * num[2] = { nullptr, one() }; value * den[1] = { one() }; rational_function_value * v = mk_rational_function_value_core(ext, 2, num, 1, den); set_interval(v->interval(), ext->interval()); @@ -1838,7 +1838,7 @@ namespace realclosure { interval contains only one root of p. */ void add_root(unsigned p_sz, value * const * p, mpbqi const & interval, mpbqi const & iso_interval, numeral_vector & roots) { - add_root(p_sz, p, interval, iso_interval, 0, UINT_MAX, roots); + add_root(p_sz, p, interval, iso_interval, nullptr, UINT_MAX, roots); } /** @@ -1965,7 +1965,7 @@ namespace realclosure { // Sequence of sign conditions associated with the columns of M_s // These are sign conditions on the polynomials in qs. scoped_sign_conditions scs(*this); - scs.push_back(0); + scs.push_back(nullptr); // Starting configuration // @@ -2322,7 +2322,7 @@ namespace realclosure { if (num_neg_roots > 0) { if (num_neg_roots == 1) { - add_root(n, p, neg_interval, minf_zero, 0, UINT_MAX, roots); + add_root(n, p, neg_interval, minf_zero, nullptr, UINT_MAX, roots); } else { if (has_neg_lower) { @@ -2336,7 +2336,7 @@ namespace realclosure { if (num_pos_roots > 0) { if (num_pos_roots == 1) { - add_root(n, p, pos_interval, zero_inf, 0, UINT_MAX, roots); + add_root(n, p, pos_interval, zero_inf, nullptr, UINT_MAX, roots); } else { if (has_pos_upper) { @@ -2668,7 +2668,7 @@ namespace realclosure { \brief Remove 0s */ void adjust_size(value_ref_buffer & r) { - while (!r.empty() && r.back() == 0) { + while (!r.empty() && r.back() == nullptr) { r.pop_back(); } } @@ -2753,7 +2753,7 @@ namespace realclosure { void mul(value * a, unsigned sz, value * const * p, value_ref_buffer & r) { SASSERT(p != r.c_ptr()); r.reset(); - if (a == 0) + if (a == nullptr) return; value_ref a_i(*this); for (unsigned i = 0; i < sz; i++) { @@ -2778,7 +2778,7 @@ namespace realclosure { value_ref tmp(*this); for (unsigned i = 0; i < sz1; i++) { checkpoint(); - if (p1[i] == 0) + if (p1[i] == nullptr) continue; for (unsigned j = 0; j < sz2; j++) { // r[i+j] <- r[i+j] + p1[i]*p2[j] @@ -3060,7 +3060,7 @@ namespace realclosure { bool struct_eq(value * a, value * b) const { if (a == b) return true; - else if (a == 0 || b == 0) + else if (a == nullptr || b == nullptr) return false; else if (is_nz_rational(a) && is_nz_rational(b)) return qm().eq(to_mpq(a), to_mpq(b)); @@ -3112,7 +3112,7 @@ namespace realclosure { - a is a rational_function_value of the form p_a(x)/1 where the coefficients of p_a also have clean denominators. */ bool has_clean_denominators(value * a) const { - if (a == 0) + if (a == nullptr) return true; else if (is_nz_rational(a)) return qm().is_int(to_mpq(a)); @@ -3150,7 +3150,7 @@ namespace realclosure { INC_DEPTH(); TRACE("rcf_clean", tout << "clean_denominators_core [" << m_exec_depth << "]\na: "; display(tout, a, false); tout << "\n";); p.reset(); q.reset(); - if (a == 0) { + if (a == nullptr) { p = a; q = one(); } @@ -3205,8 +3205,8 @@ namespace realclosure { dens.push_back(a_d); } else { - nums.push_back(0); - dens.push_back(0); + nums.push_back(nullptr); + dens.push_back(nullptr); } } if (all_one) { @@ -3258,7 +3258,7 @@ namespace realclosure { value_ref m(*this); for (unsigned i = 0; i < p_sz; i++) { if (!nums[i]) { - norm_p.push_back(0); + norm_p.push_back(nullptr); } else { SASSERT(dens[i]); @@ -3348,7 +3348,7 @@ namespace realclosure { If g != 0, then it will compute the gcd of g and the coefficients in a. */ bool gcd_int_coeffs(value * a, mpz & g) { - if (a == 0) { + if (a == nullptr) { return false; } else if (is_nz_rational(a)) { @@ -3410,7 +3410,7 @@ namespace realclosure { for (unsigned i = 0; i < p.size(); i++) { if (p[i]) { a = p[i]; - p.set(i, 0); + p.set(i, nullptr); exact_div_z(a, g); p.set(i, a); } @@ -3448,7 +3448,7 @@ namespace realclosure { new_ais.push_back(ai); } else { - new_ais.push_back(0); + new_ais.push_back(nullptr); } } rational_function_value * r = mk_rational_function_value_core(rf->ext(), new_ais.size(), new_ais.c_ptr(), 1, &m_one); @@ -3759,7 +3759,7 @@ namespace realclosure { while (i > 0) { checkpoint(); --i; - if (p[i] != 0) + if (p[i] != nullptr) bqim().add(r, interval(p[i]), r); if (i > 0) bqim().mul(r, bi, r); @@ -3772,7 +3772,7 @@ namespace realclosure { */ bool has_refineable_approx_coeffs(unsigned n, value * const * p) { for (unsigned i = 0; i < n; i++) { - if (p[i] != 0) { + if (p[i] != nullptr) { mpbqi & a_i = interval(p[i]); if (a_i.lower_is_inf() || a_i.upper_is_inf()) return false; @@ -3786,7 +3786,7 @@ namespace realclosure { */ void mk_polynomial_value(unsigned n, value * const * p, value * b, value_ref & r) { SASSERT(n > 0); - if (n == 1 || b == 0) { + if (n == 1 || b == nullptr) { r = p[0]; } else { @@ -3798,7 +3798,7 @@ namespace realclosure { unsigned i = n - 1; while (i > 0) { --i; - if (p[i] != 0) + if (p[i] != nullptr) add(r, p[i], r); // r <- r + a_i if (i > 0) mul(r, b, r); // r <- r * b @@ -3856,7 +3856,7 @@ namespace realclosure { int find_biggest_interval_magnitude(unsigned n, value * const * p) { int r = INT_MIN; for (unsigned i = 0; i < n; i++) { - if (p[i] != 0) { + if (p[i] != nullptr) { mpbqi & a_i = interval(p[i]); SASSERT(!a_i.lower_is_inf() && !a_i.upper_is_inf()); int m = magnitude(a_i); @@ -4089,7 +4089,7 @@ namespace realclosure { */ bool refine_coeffs_interval(unsigned n, value * const * p, unsigned prec) { for (unsigned i = 0; i < n; i++) { - if (p[i] != 0 && !refine_interval(p[i], prec)) + if (p[i] != nullptr && !refine_interval(p[i], prec)) return false; } return true; @@ -4243,7 +4243,7 @@ namespace realclosure { bool refine_algebraic_interval(algebraic * a, unsigned prec) { save_interval_if_too_small(a, prec); - if (a->sdt() != 0) { + if (a->sdt() != nullptr) { // We don't bisect the interval, since it contains more than one root. // To bisect this kind of interval we would have to use Tarski queries. return false; @@ -4941,7 +4941,7 @@ namespace realclosure { } else { // The new value is 0 - r = 0; + r = nullptr; } } } @@ -4979,7 +4979,7 @@ namespace realclosure { // num <- a + b * ad add(an.size(), an.c_ptr(), b_ad.size(), b_ad.c_ptr(), num); if (num.empty()) - r = 0; + r = nullptr; else { value_ref_buffer new_num(*this); value_ref_buffer new_den(*this); @@ -5003,7 +5003,7 @@ namespace realclosure { value_ref_buffer new_num(*this); add(an.size(), an.c_ptr(), bn.size(), bn.c_ptr(), new_num); if (new_num.empty()) - r = 0; + r = nullptr; else { // We don't need to invoke normalize_algebraic even if x (== a->ext()) is algebraic. // Reason: by construction the polynomials a->num() and b->num() are "normalized". @@ -5035,7 +5035,7 @@ namespace realclosure { value_ref_buffer num(*this); add(an_bd.size(), an_bd.c_ptr(), bn_ad.size(), bn_ad.c_ptr(), num); if (num.empty()) { - r = 0; + r = nullptr; } else { value_ref_buffer den(*this); @@ -5050,17 +5050,17 @@ namespace realclosure { } void add(value * a, value * b, value_ref & r) { - if (a == 0) { + if (a == nullptr) { r = b; } - else if (b == 0) { + else if (b == nullptr) { r = a; } else if (is_nz_rational(a) && is_nz_rational(b)) { scoped_mpq v(qm()); qm().add(to_mpq(a), to_mpq(b), v); if (qm().is_zero(v)) - r = 0; + r = nullptr; else r = mk_rational_and_swap(v); } @@ -5079,17 +5079,17 @@ namespace realclosure { } void sub(value * a, value * b, value_ref & r) { - if (a == 0) { + if (a == nullptr) { neg(b, r); } - else if (b == 0) { + else if (b == nullptr) { r = a; } else if (is_nz_rational(a) && is_nz_rational(b)) { scoped_mpq v(qm()); qm().sub(to_mpq(a), to_mpq(b), v); if (qm().is_zero(v)) - r = 0; + r = nullptr; else r = mk_rational_and_swap(v); } @@ -5118,8 +5118,8 @@ namespace realclosure { } void neg(value * a, value_ref & r) { - if (a == 0) { - r = 0; + if (a == nullptr) { + r = nullptr; } else if (is_nz_rational(a)) { scoped_mpq v(qm()); @@ -5155,7 +5155,7 @@ namespace realclosure { } else { // The new value is 0 - r = 0; + r = nullptr; } } } @@ -5252,8 +5252,8 @@ namespace realclosure { } void mul(value * a, value * b, value_ref & r) { - if (a == 0 || b == 0) { - r = 0; + if (a == nullptr || b == nullptr) { + r = nullptr; } else if (is_rational_one(a)) { r = b; @@ -5287,10 +5287,10 @@ namespace realclosure { } void div(value * a, value * b, value_ref & r) { - if (a == 0) { - r = 0; + if (a == nullptr) { + r = nullptr; } - else if (b == 0) { + else if (b == nullptr) { throw exception("division by zero"); } else if (is_rational_one(b)) { @@ -5461,7 +5461,7 @@ namespace realclosure { // r == 1/inv(new_a) inv(new_a, r); } - else if (alpha->sdt() == 0) { + else if (alpha->sdt() == nullptr) { // Another easy case: we just have to replace // alpha->p() with new_p. // The m_iso_interval for p() is also an isolating interval for new_p, @@ -5552,7 +5552,7 @@ namespace realclosure { } void inv(value * a, value_ref & r) { - if (a == 0) { + if (a == nullptr) { throw exception("division by zero"); } if (is_nz_rational(a)) { @@ -5644,7 +5644,7 @@ namespace realclosure { neg(a.m_value, neg_a); p.push_back(neg_a); for (unsigned i = 0; i < k - 1; i++) - p.push_back(0); + p.push_back(nullptr); p.push_back(one()); numeral_vector roots; @@ -5687,9 +5687,9 @@ namespace realclosure { // --------------------------------- int compare(value * a, value * b) { - if (a == 0) + if (a == nullptr) return -sign(b); - else if (b == 0) + else if (b == nullptr) return sign(a); else if (is_nz_rational(a) && is_nz_rational(b)) { if (qm().eq(to_mpq(a), to_mpq(b))) @@ -5744,7 +5744,7 @@ namespace realclosure { } void mark(value * v) { - if (v == 0 || is_nz_rational(v)) + if (v == nullptr || is_nz_rational(v)) return; rational_function_value * rf = to_rational_function(v); mark(rf->ext()); @@ -5779,7 +5779,7 @@ namespace realclosure { bool first = true; while (i > 0) { --i; - if (p[i] == 0) + if (p[i] == nullptr) continue; if (first) first = false; @@ -5893,7 +5893,7 @@ namespace realclosure { out << ", "; display_interval(out, a->iso_interval(), pp); out << ", "; - if (a->sdt() != 0) + if (a->sdt() != nullptr) display_sign_conditions(out, a->sdt()->sc(a->sc_idx()), a->sdt()->qs(), compact, pp); else out << "{}"; @@ -5931,7 +5931,7 @@ namespace realclosure { } void display(std::ostream & out, value * v, bool compact, bool pp=false) const { - if (v == 0) + if (v == nullptr) out << "0"; else if (is_nz_rational(v)) qm().display(out, to_mpq(v)); diff --git a/src/math/realclosure/realclosure.h b/src/math/realclosure/realclosure.h index c18f626a3..cfba0e99e 100644 --- a/src/math/realclosure/realclosure.h +++ b/src/math/realclosure/realclosure.h @@ -48,7 +48,7 @@ namespace realclosure { friend class save_interval_ctx; imp * m_imp; public: - manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0); + manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr); ~manager(); typedef num numeral; typedef svector numeral_vector; @@ -271,7 +271,7 @@ namespace realclosure { friend struct manager::imp; value * m_value; public: - num():m_value(0) {} + num():m_value(nullptr) {} // Low level functions for implementing the C API void * c_ptr() { return m_value; } diff --git a/src/math/simplex/simplex_def.h b/src/math/simplex/simplex_def.h index ceec60622..89af0b3ad 100644 --- a/src/math/simplex/simplex_def.h +++ b/src/math/simplex/simplex_def.h @@ -745,7 +745,7 @@ namespace simplex { numeral const& base_coeff = vs.m_base_coeff; SASSERT(!m.is_zero(coeff)); bool base_to_lower = (m.is_pos(coeff) != m.is_pos(base_coeff)) == to_lower; - eps_numeral const* bound = 0; + eps_numeral const* bound = nullptr; if (!base_to_lower && vs.m_upper_valid) { bound = &vs.m_upper; } diff --git a/src/math/simplex/sparse_matrix_def.h b/src/math/simplex/sparse_matrix_def.h index be18a8702..0b48e0049 100644 --- a/src/math/simplex/sparse_matrix_def.h +++ b/src/math/simplex/sparse_matrix_def.h @@ -233,7 +233,7 @@ namespace simplex { return it; } } - return 0; + return nullptr; } template diff --git a/src/math/subpaving/subpaving.h b/src/math/subpaving/subpaving.h index 2c2c9978f..541f7ea7a 100644 --- a/src/math/subpaving/subpaving.h +++ b/src/math/subpaving/subpaving.h @@ -111,11 +111,11 @@ public: virtual void display_bounds(std::ostream & out) const = 0; }; - context * mk_mpq_context(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0); -context * mk_mpf_context(reslimit& lim, f2n & m, params_ref const & p = params_ref(), small_object_allocator * a = 0); -context * mk_hwf_context(reslimit& lim, f2n & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0); -context * mk_mpff_context(reslimit& lim, mpff_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0); -context * mk_mpfx_context(reslimit& lim, mpfx_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0); + context * mk_mpq_context(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr); +context * mk_mpf_context(reslimit& lim, f2n & m, params_ref const & p = params_ref(), small_object_allocator * a = nullptr); +context * mk_hwf_context(reslimit& lim, f2n & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = nullptr); +context * mk_mpff_context(reslimit& lim, mpff_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = nullptr); +context * mk_mpfx_context(reslimit& lim, mpfx_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = nullptr); }; diff --git a/src/math/subpaving/subpaving_t.h b/src/math/subpaving/subpaving_t.h index a4bc02ff6..360b2a32f 100644 --- a/src/math/subpaving/subpaving_t.h +++ b/src/math/subpaving/subpaving_t.h @@ -210,7 +210,7 @@ public: bool inconsistent() const { return m_conflict != null_var; } void set_conflict(var x) { SASSERT(!inconsistent()); m_conflict = x; } bound * trail_stack() const { return m_trail; } - bound * parent_trail_stack() const { return m_parent == 0 ? 0 : m_parent->m_trail; } + bound * parent_trail_stack() const { return m_parent == nullptr ? nullptr : m_parent->m_trail; } bound * lower(var x) const { return bm().get(m_lowers, x); } bound * upper(var x) const { return bm().get(m_uppers, x); } node * parent() const { return m_parent; } @@ -221,7 +221,7 @@ public: /** \brief Return true if x is unbounded in this node */ - bool is_unbounded(var x) const { return lower(x) == 0 && upper(x) == 0; } + bool is_unbounded(var x) const { return lower(x) == nullptr && upper(x) == nullptr; } void push(bound * b); void set_first_child(node * n) { m_first_child = n; } @@ -275,32 +275,32 @@ public: numeral const & lower(interval const & a) const { if (a.m_constant) { bound * b = a.m_node->lower(a.m_x); - return b == 0 ? a.m_l_val /* don't care */ : b->value(); + return b == nullptr ? a.m_l_val /* don't care */ : b->value(); } return a.m_l_val; } numeral const & upper(interval const & a) const { if (a.m_constant) { bound * b = a.m_node->upper(a.m_x); - return b == 0 ? a.m_u_val /* don't care */ : b->value(); + return b == nullptr ? a.m_u_val /* don't care */ : b->value(); } return a.m_u_val; } numeral & lower(interval & a) { SASSERT(!a.m_constant); return a.m_l_val; } numeral & upper(interval & a) { SASSERT(!a.m_constant); return a.m_u_val; } - bool lower_is_inf(interval const & a) const { return a.m_constant ? a.m_node->lower(a.m_x) == 0 : a.m_l_inf; } - bool upper_is_inf(interval const & a) const { return a.m_constant ? a.m_node->upper(a.m_x) == 0 : a.m_u_inf; } + bool lower_is_inf(interval const & a) const { return a.m_constant ? a.m_node->lower(a.m_x) == nullptr : a.m_l_inf; } + bool upper_is_inf(interval const & a) const { return a.m_constant ? a.m_node->upper(a.m_x) == nullptr : a.m_u_inf; } bool lower_is_open(interval const & a) const { if (a.m_constant) { bound * b = a.m_node->lower(a.m_x); - return b == 0 || b->is_open(); + return b == nullptr || b->is_open(); } return a.m_l_open; } bool upper_is_open(interval const & a) const { if (a.m_constant) { bound * b = a.m_node->upper(a.m_x); - return b == 0 || b->is_open(); + return b == nullptr || b->is_open(); } return a.m_u_open; } @@ -367,7 +367,7 @@ public: private: void * m_data; public: - watched():m_data(0) {} + watched():m_data(nullptr) {} explicit watched(var x) { m_data = BOXTAGINT(void*, x, DEFINITION); } explicit watched(clause * c) { m_data = TAG(void*, c, CLAUSE); } kind get_kind() const { return static_cast(GET_TAG(m_data)); } @@ -563,7 +563,7 @@ private: void add_clause_core(unsigned sz, ineq * const * atoms, bool lemma, bool watched); void del_clause(clause * cls); - node * mk_node(node * parent = 0); + node * mk_node(node * parent = nullptr); void del_node(node * n); void del_nodes(); diff --git a/src/math/subpaving/subpaving_t_def.h b/src/math/subpaving/subpaving_t_def.h index 5729cbfa0..bb129fee7 100644 --- a/src/math/subpaving/subpaving_t_def.h +++ b/src/math/subpaving/subpaving_t_def.h @@ -93,7 +93,7 @@ public: if (!m_only_non_def || !this->ctx()->is_definition(x)) { bound * lower = n->lower(x); bound * upper = n->upper(x); - if (lower == 0 || upper == 0 || !nm.eq(lower->value(), upper->value())) { + if (lower == nullptr || upper == nullptr || !nm.eq(lower->value(), upper->value())) { return x; } } @@ -205,11 +205,11 @@ public: bound * lower = n->lower(x); bound * upper = n->upper(x); _scoped_numeral mid(nm); - if (lower == 0 && upper == 0) { + if (lower == nullptr && upper == nullptr) { nm.set(mid, 0); // mid == 0 } - else if (lower == 0) { + else if (lower == nullptr) { _scoped_numeral delta(nm); SASSERT(upper != 0); nm.set(delta, static_cast(m_delta)); @@ -218,7 +218,7 @@ public: nm.sub(mid, delta, mid); // mid == upper - delta } - else if (upper == 0) { + else if (upper == nullptr) { _scoped_numeral delta(nm); SASSERT(lower != 0); nm.set(delta, static_cast(m_delta)); @@ -294,17 +294,17 @@ context_t::node::node(context_t & s, unsigned id): m_depth = 0; unsigned num_vars = s.num_vars(); m_conflict = null_var; - m_trail = 0; - m_parent = 0; - m_first_child = 0; - m_next_sibling = 0; - m_prev = 0; - m_next = 0; + m_trail = nullptr; + m_parent = nullptr; + m_first_child = nullptr; + m_next_sibling = nullptr; + m_prev = nullptr; + m_next = nullptr; bm().mk(m_lowers); bm().mk(m_uppers); for (unsigned i = 0; i < num_vars; i++) { - bm().push_back(m_lowers, 0); - bm().push_back(m_uppers, 0); + bm().push_back(m_lowers, nullptr); + bm().push_back(m_uppers, nullptr); } } @@ -318,10 +318,10 @@ context_t::node::node(node * parent, unsigned id): m_conflict = parent->m_conflict; m_trail = parent->m_trail; m_parent = parent; - m_first_child = 0; + m_first_child = nullptr; m_next_sibling = parent->m_first_child; - m_prev = 0; - m_next = 0; + m_prev = nullptr; + m_next = nullptr; parent->m_first_child = this; } @@ -350,7 +350,7 @@ var context_t::splitting_var(node * n) const { if (n == m_root) return null_var; bound * b = n->trail_stack(); - while (b != 0) { + while (b != nullptr) { if (b->jst().is_axiom()) return b->x(); b = b->prev(); @@ -416,16 +416,16 @@ template context_t::context_t(reslimit& lim, C const & c, params_ref const & p, small_object_allocator * a): m_limit(lim), m_c(c), - m_own_allocator(a == 0), - m_allocator(a == 0 ? alloc(small_object_allocator, "subpaving") : a), + m_own_allocator(a == nullptr), + m_allocator(a == nullptr ? alloc(small_object_allocator, "subpaving") : a), m_bm(*this, *m_allocator), m_im(lim, interval_config(m_c.m())), m_num_buffer(nm()) { m_arith_failed = false; m_timestamp = 0; - m_root = 0; - m_leaf_head = 0; - m_leaf_tail = 0; + m_root = nullptr; + m_leaf_head = nullptr; + m_leaf_tail = nullptr; m_conflict = null_var; m_qhead = 0; m_display_proc = &m_default_display_proc; @@ -638,14 +638,14 @@ void context_t::display_bounds(std::ostream & out, node * n) const { for (unsigned x = 0; x < num; x++) { bound * l = n->lower(x); bound * u = n->upper(x); - if (l != 0) { + if (l != nullptr) { display(out, l); out << " "; } - if (u != 0) { + if (u != nullptr) { display(out, u); } - if (l != 0 || u != 0) + if (l != nullptr || u != nullptr) out << "\n"; } } @@ -878,7 +878,7 @@ template typename context_t::node * context_t::mk_node(node * parent) { void * mem = allocator().allocate(sizeof(node)); node * r; - if (parent == 0) + if (parent == nullptr) r = new (mem) node(*this, m_node_id_gen.mk()); else r = new (mem) node(parent, m_node_id_gen.mk()); @@ -910,7 +910,7 @@ void context_t::del_node(node * n) { node * p = n->parent(); bound * b = n->trail_stack(); bound * b_old; - if (p != 0) { + if (p != nullptr) { node * c = p->first_child(); if (c == n) { // n is the first child @@ -928,7 +928,7 @@ void context_t::del_node(node * n) { b_old = p->trail_stack(); } else { - b_old = 0; + b_old = nullptr; } while (b != b_old) { bound * old = b; @@ -944,18 +944,18 @@ void context_t::del_node(node * n) { template void context_t::del_nodes() { ptr_buffer todo; - if (m_root == 0) + if (m_root == nullptr) return; todo.push_back(m_root); while (!todo.empty()) { node * n = todo.back(); node * c = n->first_child(); - if (c == 0) { + if (c == nullptr) { del_node(n); todo.pop_back(); } else { - while (c != 0) { + while (c != nullptr) { todo.push_back(c); c = c->next_sibling(); } @@ -969,7 +969,7 @@ void context_t::push_front(node * n) { SASSERT(n->next() == 0); SASSERT(n->prev() == 0); n->set_next(m_leaf_head); - if (m_leaf_head != 0) { + if (m_leaf_head != nullptr) { SASSERT(m_leaf_head->prev() == 0); m_leaf_head->set_prev(n); } @@ -986,7 +986,7 @@ void context_t::push_back(node * n) { SASSERT(n->next() == 0); SASSERT(n->prev() == 0); n->set_prev(m_leaf_tail); - if (m_leaf_tail != 0) { + if (m_leaf_tail != nullptr) { SASSERT(m_leaf_tail->next() == 0); m_leaf_tail->set_next(n); } @@ -1001,14 +1001,14 @@ template void context_t::reset_leaf_dlist() { // Remove all nodes from the lead doubly linked list node * n = m_leaf_head; - while (n != 0) { + while (n != nullptr) { node * next = n->next(); - n->set_next(0); - n->set_prev(0); + n->set_next(nullptr); + n->set_prev(nullptr); n = next; } - m_leaf_head = 0; - m_leaf_tail = 0; + m_leaf_head = nullptr; + m_leaf_tail = nullptr; } template @@ -1016,18 +1016,18 @@ void context_t::rebuild_leaf_dlist(node * n) { reset_leaf_dlist(); // Reinsert all leaves in the leaf dlist. ptr_buffer todo; - if (m_root != 0) + if (m_root != nullptr) todo.push_back(m_root); while (!todo.empty()) { node * n = todo.back(); todo.pop_back(); node * c = n->first_child(); - if (c == 0) { + if (c == nullptr) { if (!n->inconsistent()) push_front(n); } else { - while (c != 0) { + while (c != nullptr) { SASSERT(c->parent() == n); todo.push_back(c); c = c->next_sibling(); @@ -1043,19 +1043,19 @@ void context_t::remove_from_leaf_dlist(node * n) { SASSERT(prev == 0 || prev != next); SASSERT(next == 0 || prev != next); SASSERT(prev != n); SASSERT(next != n); - if (prev != 0) { + if (prev != nullptr) { SASSERT(m_leaf_head != n); prev->set_next(next); - n->set_prev(0); + n->set_prev(nullptr); } else if (m_leaf_head == n) { m_leaf_head = next; } - if (next != 0) { + if (next != nullptr) { SASSERT(m_leaf_tail != n); next->set_prev(prev); - n->set_next(0); + n->set_next(nullptr); } else if (m_leaf_tail == n) { m_leaf_tail = prev; @@ -1067,18 +1067,18 @@ template void context_t::collect_leaves(ptr_vector & leaves) const { // Copy all leaves to the given vector. ptr_buffer todo; - if (m_root != 0) + if (m_root != nullptr) todo.push_back(m_root); while (!todo.empty()) { node * n = todo.back(); todo.pop_back(); node * c = n->first_child(); - if (c == 0) { + if (c == nullptr) { if (!n->inconsistent()) leaves.push_back(n); } else { - while (c != 0) { + while (c != nullptr) { SASSERT(c->parent() == n); todo.push_back(c); c = c->next_sibling(); @@ -1115,7 +1115,7 @@ void context_t::del_definitions() { unsigned sz = num_vars(); for (unsigned i = 0; i < sz; i++) { definition * d = m_defs[i]; - if (d == 0) + if (d == nullptr) continue; switch (d->get_kind()) { case constraint::MONOMIAL: @@ -1219,24 +1219,24 @@ bool context_t::relevant_new_bound(var x, numeral const & k, bool lower, bool return true; } // If m_epsilon is zero, then bound is relevant only if it improves existing bound. - if (m_zero_epsilon && curr_lower != 0 && (nm().lt(k, curr_lower->value()) || ((curr_lower->is_open() || !open) && nm().eq(k, curr_lower->value())))) { + if (m_zero_epsilon && curr_lower != nullptr && (nm().lt(k, curr_lower->value()) || ((curr_lower->is_open() || !open) && nm().eq(k, curr_lower->value())))) { // new lower bound does not improve existing bound TRACE("subpaving_relevant_bound", tout << "irrelevant because does not improve existing bound.\n";); return false; } - if (curr_upper == 0 && nm().lt(m_max_bound, k)) { + if (curr_upper == nullptr && nm().lt(m_max_bound, k)) { // new lower bound exceeds the :max-bound threshold TRACE("subpaving_relevant_bound", tout << "irrelevant because exceeds :max-bound threshold.\n";); return false; } - if (!m_zero_epsilon && curr_lower != 0) { + if (!m_zero_epsilon && curr_lower != nullptr) { // check if: // new-lower > lower + m_epsilon * max(min(upper - lower, |lower|), 1) numeral & min = m_tmp1; numeral & abs_lower = m_tmp2; nm().set(abs_lower, curr_lower->value()); nm().abs(abs_lower); - if (curr_upper != 0) { + if (curr_upper != nullptr) { nm().sub(curr_upper->value(), curr_lower->value(), min); if (nm().lt(abs_lower, min)) nm().set(min, abs_lower); @@ -1269,24 +1269,24 @@ bool context_t::relevant_new_bound(var x, numeral const & k, bool lower, bool return true; } // If m_epsilon is zero, then bound is relevant only if it improves existing bound. - if (m_zero_epsilon && curr_upper != 0 && (nm().lt(curr_upper->value(), k) || ((curr_upper->is_open() || !open) && nm().eq(k, curr_upper->value())))) { + if (m_zero_epsilon && curr_upper != nullptr && (nm().lt(curr_upper->value(), k) || ((curr_upper->is_open() || !open) && nm().eq(k, curr_upper->value())))) { // new upper bound does not improve existing bound TRACE("subpaving_relevant_bound", tout << "irrelevant because does not improve existing bound.\n";); return false; } - if (curr_lower == 0 && nm().lt(k, m_minus_max_bound)) { + if (curr_lower == nullptr && nm().lt(k, m_minus_max_bound)) { // new upper bound exceeds the -:max-bound threshold TRACE("subpaving_relevant_bound", tout << "irrelevant because exceeds -:max-bound threshold.\n";); return false; } - if (!m_zero_epsilon && curr_upper != 0) { + if (!m_zero_epsilon && curr_upper != nullptr) { // check if: // new-upper < upper - m_epsilon * max(min(upper - lower, |upper|), 1) numeral & min = m_tmp1; numeral & abs_upper = m_tmp2; nm().set(abs_upper, curr_upper->value()); nm().abs(abs_upper); - if (curr_lower != 0) { + if (curr_lower != nullptr) { nm().sub(curr_upper->value(), curr_lower->value(), min); if (nm().lt(abs_upper, min)) nm().set(min, abs_upper); @@ -1323,14 +1323,14 @@ bool context_t::is_zero(var x, node * n) const { // Return true if lower(x) == upper(x) == 0 at n bound * l = n->lower(x); bound * u = n->upper(x); - return l != 0 && u != 0 && nm().is_zero(l->value()) && nm().is_zero(u->value()) && !l->is_open() && !u->is_open(); + return l != nullptr && u != nullptr && nm().is_zero(l->value()) && nm().is_zero(u->value()) && !l->is_open() && !u->is_open(); } template bool context_t::is_upper_zero(var x, node * n) const { // Return true if upper(x) is zero at node n bound * u = n->upper(x); - return u != 0 && nm().is_zero(u->value()) && !u->is_open(); + return u != nullptr && nm().is_zero(u->value()) && !u->is_open(); } template @@ -1338,7 +1338,7 @@ bool context_t::conflicting_bounds(var x, node * n) const { // Return true if upper(x) < lower(x) at node n bound * l = n->lower(x); bound * u = n->upper(x); - return l != 0 && u != 0 && (nm().lt(u->value(), l->value()) || ((l->is_open() || u->is_open()) && nm().eq(u->value(), l->value()))); + return l != nullptr && u != nullptr && (nm().lt(u->value(), l->value()) || ((l->is_open() || u->is_open()) && nm().eq(u->value(), l->value()))); } /** @@ -1351,20 +1351,20 @@ lbool context_t::value(ineq * t, node * n) { var x = t->x(); bound * u = n->upper(x); bound * l = n->lower(x); - if (u == 0 && l == 0) + if (u == nullptr && l == nullptr) return l_undef; else if (t->is_lower()) { - if (u != 0 && (nm().lt(u->value(), t->value()) || ((u->is_open() || t->is_open()) && nm().eq(u->value(), t->value())))) + if (u != nullptr && (nm().lt(u->value(), t->value()) || ((u->is_open() || t->is_open()) && nm().eq(u->value(), t->value())))) return l_false; - else if (l != 0 && (nm().gt(l->value(), t->value()) || ((l->is_open() || !t->is_open()) && nm().eq(l->value(), t->value())))) + else if (l != nullptr && (nm().gt(l->value(), t->value()) || ((l->is_open() || !t->is_open()) && nm().eq(l->value(), t->value())))) return l_true; else return l_undef; } else { - if (l != 0 && (nm().gt(l->value(), t->value()) || ((l->is_open() || t->is_open()) && nm().eq(l->value(), t->value())))) + if (l != nullptr && (nm().gt(l->value(), t->value()) || ((l->is_open() || t->is_open()) && nm().eq(l->value(), t->value())))) return l_false; - else if (u != 0 && (nm().lt(u->value(), t->value()) || ((u->is_open() || !t->is_open()) && nm().eq(u->value(), t->value())))) + else if (u != nullptr && (nm().lt(u->value(), t->value()) || ((u->is_open() || !t->is_open()) && nm().eq(u->value(), t->value())))) return l_true; else return l_undef; @@ -1804,17 +1804,17 @@ void context_t::init() { template void context_t::operator()() { - if (m_root == 0) + if (m_root == nullptr) init(); TRACE("subpaving_stats", statistics st; collect_statistics(st); tout << "statistics:\n"; st.display_smt2(tout);); TRACE("subpaving_main", display_params(tout);); - while (m_leaf_head != 0) { + while (m_leaf_head != nullptr) { checkpoint(); SASSERT(m_queue.empty()); if (m_num_nodes > m_max_nodes) break; node * n = (*m_node_selector)(m_leaf_head, m_leaf_tail); - if (n == 0) + if (n == nullptr) break; TRACE("subpaving_main", tout << "selected node: #" << n->id() << ", depth: " << n->depth() << "\n";); remove_from_leaf_dlist(n); @@ -1892,7 +1892,7 @@ void context_t::collect_statistics(statistics & st) const { template bool context_t::is_bound_of(bound * b, node * n) const { bound * c = n->trail_stack(); - while (c != 0) { + while (c != nullptr) { if (c == b) return true; if (c->timestamp() <= b->timestamp()) @@ -1905,7 +1905,7 @@ bool context_t::is_bound_of(bound * b, node * n) const { template bool context_t::check_leaf_dlist() const { node * n = m_leaf_head; - while (n != 0) { + while (n != nullptr) { node * next = n->next(); SASSERT(next != 0 || m_leaf_tail == n); SASSERT(next == 0 || next->prev() == n); @@ -1917,13 +1917,13 @@ bool context_t::check_leaf_dlist() const { template bool context_t::check_tree() const { ptr_buffer todo; - if (m_root != 0) + if (m_root != nullptr) todo.push_back(m_root); while (!todo.empty()) { node * n = todo.back(); todo.pop_back(); node * c = n->first_child(); - while (c != 0) { + while (c != nullptr) { SASSERT(c->parent() == n); todo.push_back(c); c = c->next_sibling(); diff --git a/src/math/subpaving/tactic/expr2subpaving.cpp b/src/math/subpaving/tactic/expr2subpaving.cpp index b00c0007f..1eb4ad108 100644 --- a/src/math/subpaving/tactic/expr2subpaving.cpp +++ b/src/math/subpaving/tactic/expr2subpaving.cpp @@ -30,7 +30,7 @@ struct expr2subpaving::imp { struct frame { app * m_curr; unsigned m_idx; - frame():m_curr(0), m_idx(0) {} + frame():m_curr(nullptr), m_idx(0) {} frame(app * t):m_curr(t), m_idx(0) {} }; @@ -62,7 +62,7 @@ struct expr2subpaving::imp { m_cached_numerators(m_qm), m_cached_denominators(m_qm) { - if (e2v == 0) { + if (e2v == nullptr) { m_expr2var = alloc(expr2var, m); m_expr2var_owner = true; } @@ -107,7 +107,7 @@ struct expr2subpaving::imp { x = s().mk_var(is_int); m_expr2var->insert(t, x); if (x >= m_var2expr.size()) - m_var2expr.resize(x+1, 0); + m_var2expr.resize(x+1, nullptr); m_var2expr.set(x, t); } return x; diff --git a/src/math/subpaving/tactic/expr2subpaving.h b/src/math/subpaving/tactic/expr2subpaving.h index d95699759..32caf49a9 100644 --- a/src/math/subpaving/tactic/expr2subpaving.h +++ b/src/math/subpaving/tactic/expr2subpaving.h @@ -29,7 +29,7 @@ class expr2subpaving { struct imp; imp * m_imp; public: - expr2subpaving(ast_manager & m, subpaving::context & s, expr2var * e2v = 0); + expr2subpaving(ast_manager & m, subpaving::context & s, expr2var * e2v = nullptr); ~expr2subpaving(); ast_manager & m() const; diff --git a/src/math/subpaving/tactic/subpaving_tactic.cpp b/src/math/subpaving/tactic/subpaving_tactic.cpp index ebc9356d9..1f5f87eef 100644 --- a/src/math/subpaving/tactic/subpaving_tactic.cpp +++ b/src/math/subpaving/tactic/subpaving_tactic.cpp @@ -41,8 +41,8 @@ class subpaving_tactic : public tactic { ast_manager & m() const { return m_inv.get_manager(); } void operator()(std::ostream & out, subpaving::var x) const override { - expr * t = m_inv.get(x, 0); - if (t != 0) + expr * t = m_inv.get(x, nullptr); + if (t != nullptr) out << mk_ismt2_pp(t, m()); else out << "k!" << x; @@ -160,7 +160,7 @@ class subpaving_tactic : public tactic { } void process_clause(expr * c) { - expr * const * args = 0; + expr * const * args = nullptr; unsigned sz; if (m().is_or(c)) { args = to_app(c)->get_args(); @@ -251,9 +251,9 @@ public: m_imp->collect_statistics(m_stats); result.reset(); result.push_back(in.get()); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; } catch (z3_exception & ex) { // convert all Z3 exceptions into tactic exceptions diff --git a/src/model/func_interp.cpp b/src/model/func_interp.cpp index e458cc4b0..accb45a25 100644 --- a/src/model/func_interp.cpp +++ b/src/model/func_interp.cpp @@ -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 & args) { @@ -183,13 +183,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 +219,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 +232,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 num_occs; - expr * r_max = 0; + expr * r_max = nullptr; unsigned max = 0; ptr_vector::const_iterator it = m_entries.begin(); ptr_vector::const_iterator end = m_entries.end(); @@ -257,7 +257,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 +284,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 vars; ptr_vector::const_iterator it = m_entries.begin(); @@ -313,10 +313,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(this)->m_interp = r; m_manager.inc_ref(m_interp); } diff --git a/src/model/func_interp.h b/src/model/func_interp.h index 47eb0e82c..e2b98d6ea 100644 --- a/src/model/func_interp.h +++ b/src/model/func_interp.h @@ -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; diff --git a/src/model/model.cpp b/src/model/model.cpp index 7823a6f6b..486b1e92e 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -94,12 +94,12 @@ struct model::value_proc : public some_value_proc { model & m_model; value_proc(model & m):m_model(m) {} expr * operator()(sort * s) override { - ptr_vector * u = 0; + ptr_vector * u = nullptr; if (m_model.m_usort2universe.find(s, u)) { if (u->size() > 0) return u->get(0); } - return 0; + return nullptr; } }; @@ -109,16 +109,16 @@ expr * model::get_some_value(sort * s) { } ptr_vector const & model::get_universe(sort * s) const { - ptr_vector * u = 0; + ptr_vector * u = nullptr; m_usort2universe.find(s, u); SASSERT(u != 0); return *u; } bool model::has_uninterpreted_sort(sort * s) const { - ptr_vector * u = 0; + ptr_vector * u = nullptr; m_usort2universe.find(s, u); - return u != 0; + return u != nullptr; } unsigned model::get_num_uninterpreted_sorts() const { diff --git a/src/model/model_core.cpp b/src/model/model_core.cpp index 833c254c3..648768bf3 100644 --- a/src/model/model_core.cpp +++ b/src/model/model_core.cpp @@ -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; } diff --git a/src/model/model_core.h b/src/model/model_core.h index ec128c796..ce211c0b8 100644 --- a/src/model/model_core.h +++ b/src/model/model_core.h @@ -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; diff --git a/src/model/model_evaluator.cpp b/src/model/model_evaluator.cpp index 32ed1e236..fd2dc7656 100644 --- a/src/model/model_evaluator.cpp +++ b/src/model/model_evaluator.cpp @@ -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; } @@ -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)) { diff --git a/src/model/model_implicant.cpp b/src/model/model_implicant.cpp index 6abdacfba..3456c2746 100644 --- a/src/model/model_implicant.cpp +++ b/src/model/model_implicant.cpp @@ -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 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()) { diff --git a/src/muz/base/dl_boogie_proof.h b/src/muz/base/dl_boogie_proof.h index f335159b6..ed2f5a801 100644 --- a/src/muz/base/dl_boogie_proof.h +++ b/src/muz/base/dl_boogie_proof.h @@ -82,7 +82,7 @@ namespace datalog { void get_labels(proof* p, labels&); public: - boogie_proof(ast_manager& m): m(m), m_proof(m), m_model(0) {} + boogie_proof(ast_manager& m): m(m), m_proof(m), m_model(nullptr) {} void set_proof(proof* p); diff --git a/src/muz/base/dl_context.cpp b/src/muz/base/dl_context.cpp index 106c15d5f..47d7cc357 100644 --- a/src/muz/base/dl_context.cpp +++ b/src/muz/base/dl_context.cpp @@ -154,7 +154,7 @@ namespace datalog { rule_set* m_old_rules; void reset() { dealloc(m_old_rules); - m_old_rules = 0; + m_old_rules = nullptr; } public: restore_rules(rule_set& r): m_old_rules(alloc(rule_set, r)) {} @@ -221,9 +221,9 @@ namespace datalog { m_rule_fmls_head(0), m_rule_fmls(m), m_background(m), - m_mc(0), - m_rel(0), - m_engine(0), + m_mc(nullptr), + m_rel(nullptr), + m_engine(nullptr), m_closed(false), m_saturation_was_run(false), m_enable_bind_variables(true), @@ -251,8 +251,8 @@ namespace datalog { m_preds.reset(); m_preds_by_name.reset(); reset_dealloc_values(m_sorts); - m_engine = 0; - m_rel = 0; + m_engine = nullptr; + m_rel = nullptr; } bool context::is_fact(app * head) const { @@ -465,7 +465,7 @@ namespace datalog { scoped_proof_mode _scp(m, generate_proof_trace()?PGM_ENABLED:PGM_DISABLED); while (m_rule_fmls_head < m_rule_fmls.size()) { expr* fml = m_rule_fmls[m_rule_fmls_head].get(); - proof* p = generate_proof_trace()?m.mk_asserted(fml):0; + proof* p = generate_proof_trace()?m.mk_asserted(fml):nullptr; rm.mk_rule(fml, p, m_rule_set, m_rule_names[m_rule_fmls_head]); ++m_rule_fmls_head; } @@ -478,7 +478,7 @@ namespace datalog { // void context::update_rule(expr* rl, symbol const& name) { datalog::rule_manager& rm = get_rule_manager(); - proof* p = 0; + proof* p = nullptr; if (generate_proof_trace()) { p = m.mk_asserted(rl); } @@ -493,7 +493,7 @@ namespace datalog { // The new rule is inserted last: rule_ref r(m_rule_set.get_rule(size_before), rm); rule_ref_vector const& rls = m_rule_set.get_rules(); - rule* old_rule = 0; + rule* old_rule = nullptr; for (unsigned i = 0; i < size_before; ++i) { if (rls[i]->name() == name) { if (old_rule) { @@ -861,8 +861,8 @@ namespace datalog { lbool context::query(expr* query) { m_mc = mk_skip_model_converter(); m_last_status = OK; - m_last_answer = 0; - m_last_ground_answer = 0; + m_last_answer = nullptr; + m_last_ground_answer = nullptr; switch (get_engine()) { case DATALOG_ENGINE: case SPACER_ENGINE: @@ -890,8 +890,8 @@ namespace datalog { lbool context::query_from_lvl (expr* query, unsigned lvl) { m_mc = mk_skip_model_converter(); m_last_status = OK; - m_last_answer = 0; - m_last_ground_answer = 0; + m_last_answer = nullptr; + m_last_ground_answer = nullptr; switch (get_engine()) { case DATALOG_ENGINE: case SPACER_ENGINE: @@ -933,7 +933,7 @@ namespace datalog { } lbool context::rel_query(unsigned num_rels, func_decl * const* rels) { - m_last_answer = 0; + m_last_answer = nullptr; ensure_engine(); return m_engine->query(num_rels, rels); } @@ -1059,7 +1059,7 @@ namespace datalog { for (unsigned i = m_rule_fmls_head; i < m_rule_fmls.size(); ++i) { m_free_vars(m_rule_fmls[i].get()); if (!m_free_vars.empty()) { - rm.mk_rule(m_rule_fmls[i].get(), 0, m_rule_set, m_rule_names[i]); + rm.mk_rule(m_rule_fmls[i].get(), nullptr, m_rule_set, m_rule_names[i]); m_rule_fmls[i] = m_rule_fmls.back(); m_rule_names[i] = m_rule_names.back(); m_rule_fmls.pop_back(); diff --git a/src/muz/base/dl_context.h b/src/muz/base/dl_context.h index 3051dbf86..f37826feb 100644 --- a/src/muz/base/dl_context.h +++ b/src/muz/base/dl_context.h @@ -331,7 +331,7 @@ namespace datalog { names. Generally, the names coming from the parses are registered here. */ func_decl * try_get_predicate_decl(symbol const& pred_name) const { - func_decl * res = 0; + func_decl * res = nullptr; m_preds_by_name.find(pred_name, res); return res; } @@ -341,7 +341,7 @@ namespace datalog { */ func_decl * mk_fresh_head_predicate(symbol const & prefix, symbol const & suffix, - unsigned arity, sort * const * domain, func_decl* orig_pred=0); + unsigned arity, sort * const * domain, func_decl* orig_pred=nullptr); /** diff --git a/src/muz/base/dl_costs.cpp b/src/muz/base/dl_costs.cpp index f97a4d451..d429af803 100644 --- a/src/muz/base/dl_costs.cpp +++ b/src/muz/base/dl_costs.cpp @@ -128,7 +128,7 @@ namespace datalog { // // ----------------------------------- - cost_recorder::cost_recorder() : m_obj(0) { + cost_recorder::cost_recorder() : m_obj(nullptr) { m_stopwatch = alloc(stopwatch); m_stopwatch->start(); } @@ -149,7 +149,7 @@ namespace datalog { c.milliseconds+=time_delta; m_obj->m_being_recorded = false; } - m_running = obj!=0; + m_running = obj!=nullptr; m_obj = obj; m_last_time = curr_time; if(obj) { diff --git a/src/muz/base/dl_costs.h b/src/muz/base/dl_costs.h index fd5a99f15..59d4fd8c1 100644 --- a/src/muz/base/dl_costs.h +++ b/src/muz/base/dl_costs.h @@ -63,7 +63,7 @@ namespace datalog { costs m_processed_cost; bool m_being_recorded; protected: - accounted_object() : m_context(0), m_parent_object(0), m_being_recorded(false) {} + accounted_object() : m_context(nullptr), m_parent_object(nullptr), m_being_recorded(false) {} ~accounted_object(); public: @@ -107,7 +107,7 @@ namespace datalog { before separately. */ void start(accounted_object *); - void finish() { start(0); } + void finish() { start(nullptr); } }; }; diff --git a/src/muz/base/dl_rule.cpp b/src/muz/base/dl_rule.cpp index 4f832c4c9..68e0aca6b 100644 --- a/src/muz/base/dl_rule.cpp +++ b/src/muz/base/dl_rule.cpp @@ -81,7 +81,7 @@ namespace datalog { } var_idx_set& rule_manager::collect_vars(expr* e) { - return collect_vars(e, 0); + return collect_vars(e, nullptr); } var_idx_set& rule_manager::collect_vars(expr* e1, expr* e2) { @@ -274,11 +274,11 @@ namespace datalog { bind_variables(query, false, q); quantifier_hoister qh(m); - qh.pull_quantifier(false, q, 0, &names); + qh.pull_quantifier(false, q, nullptr, &names); // retrieve free variables. m_free_vars(q); vars.append(m_free_vars.size(), m_free_vars.c_ptr()); - if (vars.contains(static_cast(0))) { + if (vars.contains(static_cast(nullptr))) { var_subst sub(m, false); expr_ref_vector args(m); // [s0, 0, s2, ..] @@ -306,7 +306,7 @@ namespace datalog { } body.push_back(to_app(q)); flatten_body(body); - func_decl* body_pred = 0; + func_decl* body_pred = nullptr; for (unsigned i = 0; i < body.size(); i++) { if (is_uninterp(body[i].get())) { body_pred = body[i]->get_decl(); @@ -472,7 +472,7 @@ namespace datalog { r->m_head = head; r->m_name = name; r->m_tail_size = n; - r->m_proof = 0; + r->m_proof = nullptr; m.inc_ref(r->m_head); app * * uninterp_tail = r->m_tail; //grows upwards @@ -482,7 +482,7 @@ namespace datalog { bool has_neg = false; for (unsigned i = 0; i < n; i++) { - bool is_neg = (is_negated != 0 && is_negated[i]); + bool is_neg = (is_negated != nullptr && is_negated[i]); app * curr = tail[i]; if (is_neg && !m_ctx.is_predicate(curr)) { @@ -548,7 +548,7 @@ namespace datalog { r->m_tail_size = n; r->m_positive_cnt = source->m_positive_cnt; r->m_uninterp_cnt = source->m_uninterp_cnt; - r->m_proof = 0; + r->m_proof = nullptr; m.inc_ref(r->m_head); for (unsigned i = 0; i < n; i++) { r->m_tail[i] = source->m_tail[i]; @@ -978,7 +978,7 @@ namespace datalog { subst_vals.push_back(m.mk_var(next_fresh_var++, var_srt)); } else { - subst_vals.push_back(0); + subst_vals.push_back(nullptr); } } diff --git a/src/muz/base/dl_rule.h b/src/muz/base/dl_rule.h index ea0e64e4f..2537adbb0 100644 --- a/src/muz/base/dl_rule.h +++ b/src/muz/base/dl_rule.h @@ -54,7 +54,7 @@ namespace datalog { bool m_found; func_decl* m_func; uninterpreted_function_finder_proc(ast_manager& m): - m(m), m_dt(m), m_dl(m), m_found(false), m_func(0) {} + m(m), m_dt(m), m_dl(m), m_found(false), m_func(nullptr) {} void operator()(var * n) { } void operator()(quantifier * n) { } void operator()(app * n) { @@ -71,7 +71,7 @@ namespace datalog { } } } - void reset() { m_found = false; m_func = 0; } + void reset() { m_found = false; m_func = nullptr; } bool found(func_decl*& f) const { f = m_func; return m_found; } }; @@ -209,7 +209,7 @@ namespace datalog { \remark A tail may contain negation. tail[i] is assumed to be negated if is_neg != 0 && is_neg[i] == true */ - rule * mk(app * head, unsigned n, app * const * tail, bool const * is_neg = 0, + rule * mk(app * head, unsigned n, app * const * tail, bool const * is_neg = nullptr, symbol const& name = symbol::null, bool normalize = true); /** diff --git a/src/muz/base/dl_rule_set.cpp b/src/muz/base/dl_rule_set.cpp index 65c940091..acd200d44 100644 --- a/src/muz/base/dl_rule_set.cpp +++ b/src/muz/base/dl_rule_set.cpp @@ -282,7 +282,7 @@ namespace datalog { m_rule_manager(ctx.get_rule_manager()), m_rules(m_rule_manager), m_deps(ctx), - m_stratifier(0), + m_stratifier(nullptr), m_refs(ctx.get_manager()) { } @@ -291,7 +291,7 @@ namespace datalog { m_rule_manager(other.m_rule_manager), m_rules(m_rule_manager), m_deps(other.m_context), - m_stratifier(0), + m_stratifier(nullptr), m_refs(m_context.get_manager()) { add_rules(other); if (other.m_stratifier) { @@ -307,7 +307,7 @@ namespace datalog { m_rules.reset(); reset_dealloc_values(m_head2rules); m_deps.reset(); - m_stratifier = 0; + m_stratifier = nullptr; m_output_preds.reset(); m_orig2pred.reset(); m_pred2orig.reset(); @@ -401,7 +401,7 @@ namespace datalog { m_deps.populate(*this); m_stratifier = alloc(rule_stratifier, m_deps); if (!stratified_negation()) { - m_stratifier = 0; + m_stratifier = nullptr; m_deps.reset(); return false; } @@ -410,7 +410,7 @@ namespace datalog { void rule_set::reopen() { if (is_closed()) { - m_stratifier = 0; + m_stratifier = nullptr; m_deps.reset(); } } diff --git a/src/muz/base/dl_rule_transformer.h b/src/muz/base/dl_rule_transformer.h index dc930ae2b..2bcc1da5c 100644 --- a/src/muz/base/dl_rule_transformer.h +++ b/src/muz/base/dl_rule_transformer.h @@ -87,7 +87,7 @@ namespace datalog { (higher priority plugins will be applied first). */ plugin(unsigned priority, bool can_destratify_negation = false) : m_priority(priority), - m_can_destratify_negation(can_destratify_negation), m_transformer(0) {} + m_can_destratify_negation(can_destratify_negation), m_transformer(nullptr) {} public: virtual ~plugin() {} diff --git a/src/muz/base/dl_util.cpp b/src/muz/base/dl_util.cpp index aceeba364..c2622cec4 100644 --- a/src/muz/base/dl_util.cpp +++ b/src/muz/base/dl_util.cpp @@ -34,7 +34,7 @@ Revision History: namespace datalog { - verbose_action::verbose_action(char const* msg, unsigned lvl): m_lvl(lvl), m_sw(0) { + verbose_action::verbose_action(char const* msg, unsigned lvl): m_lvl(lvl), m_sw(nullptr) { IF_VERBOSE(m_lvl, (verbose_stream() << msg << "...").flush(); m_sw = alloc(stopwatch); @@ -87,7 +87,7 @@ namespace datalog { else { SASSERT(is_var(arg)); int vidx = to_var(arg)->get_idx(); - var * new_var = 0; + var * new_var = nullptr; if (!varidx2var.find(vidx, new_var)) { new_var = m.mk_var(next_idx, to_var(arg)->get_sort()); next_idx++; @@ -428,7 +428,7 @@ namespace datalog { unsigned tgt_sz = max_var_idx+1; unsigned tgt_ofs = tgt_sz-1; - tgt.resize(tgt_sz, 0); + tgt.resize(tgt_sz, nullptr); for(unsigned i=0; i=0; i--) { out << (len-1-i) <<"->"; - if(cont.get(i)==0) { + if(cont.get(i)==nullptr) { out << "{none}"; } else { diff --git a/src/muz/base/hnf.cpp b/src/muz/base/hnf.cpp index 7db30a9f0..f0cbc0620 100644 --- a/src/muz/base/hnf.cpp +++ b/src/muz/base/hnf.cpp @@ -153,7 +153,7 @@ public: m_fresh_predicates.reset(); m_todo.push_back(n); m_proofs.push_back(p); - m_produce_proofs = p != 0; + m_produce_proofs = p != nullptr; while (!m_todo.empty() && checkpoint()) { fml = m_todo.back(); pr = m_proofs.back(); @@ -269,7 +269,7 @@ private: expr* const* args = _or->get_args(); for (unsigned i = 0; i < sz; ++i) { m_todo.push_back(bind_variables(m.mk_implies(args[i], head))); - m_proofs.push_back(0); + m_proofs.push_back(nullptr); } if (premise) { @@ -284,7 +284,7 @@ private: m_proofs[m_proofs.size()-sz+i] = m.mk_and_elim(p2, i); } } - fml = 0; + fml = nullptr; return; } @@ -330,7 +330,7 @@ private: bool is_disj = false; expr_ref_vector _body(m); unsigned num_disj = 0; - expr* const* disjs = 0; + expr* const* disjs = nullptr; if (!contains_predicate(b)) { return; } @@ -356,7 +356,7 @@ private: negate_args = false; } if (is_disj) { - app* old_head = 0; + app* old_head = nullptr; if (m_memoize_disj.find(b, old_head)) { body = old_head; } @@ -369,7 +369,7 @@ private: e = m.mk_not(e); } m_todo.push_back(bind_variables(m.mk_implies(e, head))); - m_proofs.push_back(0); + m_proofs.push_back(nullptr); if (produce_proofs()) { defs.push_back(m.mk_def_intro(m_todo.back())); m_proofs[m_proofs.size()-1] = defs.back(); @@ -423,7 +423,7 @@ private: if (!is_predicate(e)) { app_ref head = mk_fresh_head(e); m_todo.push_back(bind_variables(m.mk_implies(e, head))); - m_proofs.push_back(0); + m_proofs.push_back(nullptr); body = m.update_quantifier(q, head); if (produce_proofs()) { proof* def_intro = m.mk_def_intro(m_todo.back()); diff --git a/src/muz/bmc/dl_bmc_engine.cpp b/src/muz/bmc/dl_bmc_engine.cpp index 3368c7640..56b7e449d 100644 --- a/src/muz/bmc/dl_bmc_engine.cpp +++ b/src/muz/bmc/dl_bmc_engine.cpp @@ -270,7 +270,7 @@ namespace datalog { TRACE("bmc", tout << "Predicate: " << pred->get_name() << "\n";); expr_ref_vector sub(m); rule_vector const& rls = b.m_rules.get_predicate_rules(pred); - rule* r = 0; + rule* r = nullptr; unsigned i = 0; for (; i < rls.size(); ++i) { rule_i = m.mk_app(mk_q_rule(pred, i), mk_q_num(level).get()); @@ -489,7 +489,7 @@ namespace datalog { proof_ref get_proof(model_ref& md, func_decl* pred, app* prop, unsigned level) { if (m.canceled()) { - return proof_ref(0, m); + return proof_ref(nullptr, m); } TRACE("bmc", tout << "Predicate: " << pred->get_name() << "\n";); rule_manager& rm = b.m_ctx.get_rule_manager(); @@ -500,7 +500,7 @@ namespace datalog { // find the rule that was triggered by evaluating the arguments to prop. rule_vector const& rls = b.m_rules.get_predicate_rules(pred); - rule* r = 0; + rule* r = nullptr; for (unsigned i = 0; i < rls.size(); ++i) { func_decl_ref rule_i = mk_level_rule(pred, i, level); TRACE("bmc", rls[i]->display(b.m_ctx, tout << "Checking rule " << mk_pp(rule_i, m) << " ");); @@ -606,7 +606,7 @@ namespace datalog { binding.push_back(m.mk_app(f, args.size(), args.c_ptr())); } else { - binding.push_back(0); + binding.push_back(nullptr); } } return binding; @@ -642,7 +642,7 @@ namespace datalog { names.push_back(symbol(i)); } else { - binding.push_back(0); + binding.push_back(nullptr); } } sorts.reverse(); @@ -686,7 +686,7 @@ namespace datalog { } else { expr * const * no_pats = &new_body; - result = n.m.update_quantifier(old_q, 0, 0, 1, no_pats, new_body); + result = n.m.update_quantifier(old_q, 0, nullptr, 1, no_pats, new_body); } return true; } @@ -986,7 +986,7 @@ namespace datalog { sort_ref_vector new_sorts(m); family_id dfid = m.mk_family_id("datatype"); datatype_decl_plugin* dtp = static_cast(m.get_plugin(dfid)); - VERIFY (dtp->mk_datatypes(dts.size(), dts.c_ptr(), 0, 0, new_sorts)); + VERIFY (dtp->mk_datatypes(dts.size(), dts.c_ptr(), 0, nullptr, new_sorts)); it = b.m_rules.begin_grouped_rules(); for (unsigned i = 0; it != end; ++it, ++i) { @@ -1012,7 +1012,7 @@ namespace datalog { unsigned sz = r->get_uninterpreted_tail_size(); max_arity = std::max(sz, max_arity); } - cnstrs.push_back(mk_constructor_decl(symbol("Z#"), symbol("Z#?"), 0, 0)); + cnstrs.push_back(mk_constructor_decl(symbol("Z#"), symbol("Z#?"), 0, nullptr)); for (unsigned i = 0; i + 1 < max_arity; ++i) { std::stringstream _name; @@ -1028,7 +1028,7 @@ namespace datalog { cnstrs.push_back(mk_constructor_decl(name, is_name, accs.size(), accs.c_ptr())); } dts.push_back(mk_datatype_decl(dtu, symbol("Path"), 0, nullptr, cnstrs.size(), cnstrs.c_ptr())); - VERIFY (dtp->mk_datatypes(dts.size(), dts.c_ptr(), 0, 0, new_sorts)); + VERIFY (dtp->mk_datatypes(dts.size(), dts.c_ptr(), 0, nullptr, new_sorts)); m_path_sort = new_sorts[0].get(); } } @@ -1090,7 +1090,7 @@ namespace datalog { } } UNREACHABLE(); - return proof_ref(0, m); + return proof_ref(nullptr, m); } // instantiation of algebraic data-types takes care of the rest. @@ -1201,7 +1201,7 @@ namespace datalog { TRACE("bmc", tout << "Predicate: " << pred->get_name() << "\n";); expr_ref_vector sub(m); rule_vector const& rls = b.m_rules.get_predicate_rules(pred); - rule* r = 0; + rule* r = nullptr; unsigned i = 0; for (; i < rls.size(); ++i) { expr_ref rule_i = mk_level_rule(pred, i, level); @@ -1446,7 +1446,7 @@ namespace datalog { lbool bmc::query(expr* query) { m_solver.reset(); - m_answer = 0; + m_answer = nullptr; m_ctx.ensure_opened(); m_rules.reset(); datalog::rule_manager& rule_manager = m_ctx.get_rule_manager(); diff --git a/src/muz/clp/clp_context.cpp b/src/muz/clp/clp_context.cpp index d1ce80e12..8ed017214 100644 --- a/src/muz/clp/clp_context.cpp +++ b/src/muz/clp/clp_context.cpp @@ -197,7 +197,7 @@ namespace datalog { proof_ref get_proof() const { - return proof_ref(0, m); + return proof_ref(nullptr, m); } }; diff --git a/src/muz/ddnf/ddnf.cpp b/src/muz/ddnf/ddnf.cpp index da1f5392b..6a42860e2 100644 --- a/src/muz/ddnf/ddnf.cpp +++ b/src/muz/ddnf/ddnf.cpp @@ -462,7 +462,7 @@ namespace datalog { private: ddnf_mgr* insert(unsigned n) { - ddnf_mgr* m = 0; + ddnf_mgr* m = nullptr; if (!m_mgrs.find(n, m)) { m = alloc(ddnf_mgr, n); m_mgrs.insert(n, m); @@ -673,7 +673,7 @@ namespace datalog { void dump_rules(rule_set& rules) { init_ctx(rules); - m_inner_ctx.display_smt2(0, 0, std::cout); + m_inner_ctx.display_smt2(0, nullptr, std::cout); } lbool execute_rules(rule_set& rules) { @@ -715,7 +715,7 @@ namespace datalog { compile_expr(r.get_tail(i), tmp); body.push_back(to_app(tmp)); } - rule* r_new = rm.mk(head, body.size(), body.c_ptr(), 0, r.name(), false); + rule* r_new = rm.mk(head, body.size(), body.c_ptr(), nullptr, r.name(), false); new_rules.add_rule(r_new); IF_VERBOSE(20, r_new->display(m_ctx, verbose_stream());); if (old_rules.is_output_predicate(r.get_decl())) { @@ -775,11 +775,11 @@ namespace datalog { return bv.mk_sort(nb); } UNREACHABLE(); - return 0; + return nullptr; } void compile_expr(expr* e, expr_ref& result) { - expr* r = 0; + expr* r = nullptr; if (m_cache.find(e, r)) { result = r; return; @@ -847,7 +847,7 @@ namespace datalog { } void compile_eq(expr* e, expr_ref& result, var* v, unsigned hi, unsigned lo, expr* c) { - tbv* t = 0; + tbv* t = nullptr; // TBD: hi, lo are ignored. VERIFY(m_expr2tbv.find(e, t)); var_ref w(m); diff --git a/src/muz/duality/duality_dl_interface.cpp b/src/muz/duality/duality_dl_interface.cpp old mode 100755 new mode 100644 index 15f7f84d8..60ed1755c --- a/src/muz/duality/duality_dl_interface.cpp +++ b/src/muz/duality/duality_dl_interface.cpp @@ -71,10 +71,10 @@ namespace Duality { Solver::Counterexample cex; duality_data(ast_manager &_m) : ctx(_m,config(params_ref())) { - ls = 0; - rpfp = 0; + ls = nullptr; + rpfp = nullptr; status = StatusNull; - old_rs = 0; + old_rs = nullptr; } ~duality_data(){ if(old_rs) @@ -92,7 +92,7 @@ namespace Duality { m_ctx(dl_ctx) { - _d = 0; + _d = nullptr; // dl_ctx.get_manager().toggle_proof_mode(PGM_FINE); } @@ -138,7 +138,7 @@ namespace Duality { // if there is old data, get the cex and dispose (later) duality_data *old_data = _d; - Solver *old_rs = 0; + Solver *old_rs = nullptr; if(old_data){ old_rs = old_data->old_rs; old_rs->GetCounterexample().swap(old_data->cex); diff --git a/src/muz/fp/datalog_parser.cpp b/src/muz/fp/datalog_parser.cpp index fd3eae944..956be52fc 100644 --- a/src/muz/fp/datalog_parser.cpp +++ b/src/muz/fp/datalog_parser.cpp @@ -104,7 +104,7 @@ public: m_ok = (m_file != NULL) && (err == 0); #else m_file = fopen(fname, "rb"); - m_ok = (m_file != NULL); + m_ok = (m_file != nullptr); #endif } ~line_reader() { @@ -171,7 +171,7 @@ class char_reader { public: char_reader(char const* file): m_line_reader(file), - m_line(0) + m_line(nullptr) {} bool operator()() { return m_line_reader(); } @@ -184,7 +184,7 @@ public: m_line = m_line_reader.get_line(); } if (!(m_line[0])) { - m_line = 0; + m_line = nullptr; return '\n'; } char result = m_line[0]; @@ -266,8 +266,8 @@ public: } dlexer(): - m_input(0), - m_reader(0), + m_input(nullptr), + m_reader(nullptr), m_prev_char(0), m_curr_char(0), m_line(1), @@ -496,17 +496,17 @@ public: bool parse_file(char const * filename) override { reset(); - if (filename != 0) { + if (filename != nullptr) { set_path(filename); char_reader reader(filename); if (!reader()) { get_err() << "ERROR: could not open file '" << filename << "'.\n"; return false; } - return parse_stream(0, &reader); + return parse_stream(nullptr, &reader); } else { - return parse_stream(&std::cin, 0); + return parse_stream(&std::cin, nullptr); } } @@ -514,7 +514,7 @@ public: reset(); std::string s(string); std::istringstream is(s); - return parse_stream(&is, 0); + return parse_stream(&is, nullptr); } protected: @@ -701,7 +701,7 @@ protected: if(is_predicate_declaration) { return unexpected(tok, "predicate declaration should not end with '.'"); } - add_rule(pred, 0, 0, 0); + add_rule(pred, 0, nullptr, nullptr); return m_lexer->next_token(); case TK_LEFT_ARROW: return parse_body(pred); @@ -777,7 +777,7 @@ protected: dtoken parse_infix(dtoken tok1, char const* td, app_ref& pred) { symbol td1(td); expr_ref v1(m_manager), v2(m_manager); - sort* s = 0; + sort* s = nullptr; dtoken tok2 = m_lexer->next_token(); if (tok2 != TK_NEQ && tok2 != TK_GT && tok2 != TK_LT && tok2 != TK_EQ) { return unexpected(tok2, "built-in infix operator"); @@ -790,12 +790,12 @@ protected: symbol td2(td); if (tok1 == TK_ID) { - expr* _v1 = 0; + expr* _v1 = nullptr; m_vars.find(td1.bare_str(), _v1); v1 = _v1; } if (tok3 == TK_ID) { - expr* _v2 = 0; + expr* _v2 = nullptr; m_vars.find(td2.bare_str(), _v2); v2 = _v2; } @@ -842,8 +842,8 @@ protected: svector arg_names; func_decl* f = m_context.try_get_predicate_decl(s); tok = parse_args(tok, f, args, arg_names); - is_predicate_declaration = f==0; - if (f==0) { + is_predicate_declaration = f==nullptr; + if (f==nullptr) { //we're in a declaration unsigned arity = args.size(); ptr_vector domain; @@ -884,7 +884,7 @@ protected: tok = m_lexer->next_token(); while (tok != TK_EOS && tok != TK_ERROR) { symbol alias; - sort* s = 0; + sort* s = nullptr; if(!f) { //we're in a predicate declaration @@ -951,7 +951,7 @@ protected: symbol data (m_lexer->get_token_data()); if (is_var(data.bare_str())) { unsigned idx = 0; - expr* v = 0; + expr* v = nullptr; if (!m_vars.find(data.bare_str(), v)) { idx = m_num_vars++; v = m_manager.mk_var(idx, s); @@ -1014,7 +1014,7 @@ protected: dlexer lexer; { flet lexer_let(m_lexer, &lexer); - m_lexer->set_stream(0, &stream); + m_lexer->set_stream(nullptr, &stream); tok = m_lexer->next_token(); if(parsing_domain) { tok = parse_domains(tok); @@ -1186,7 +1186,7 @@ class wpa_parser_impl : public wpa_parser, dparser { bool m_use_map_names; uint64_set& ensure_sort_content(symbol sort_name) { - sym2nums::entry * e = m_sort_contents.insert_if_not_there2(sort_name, 0); + sym2nums::entry * e = m_sort_contents.insert_if_not_there2(sort_name, nullptr); if(!e->get_data().m_value) { e->get_data().m_value = alloc(uint64_set); } @@ -1312,10 +1312,10 @@ private: dlexer lexer; m_lexer = &lexer; - m_lexer->set_stream(&stm, 0); + m_lexer->set_stream(&stm, nullptr); dtoken tok = m_lexer->next_token(); tok = parse_decls(tok); - m_lexer = 0; + m_lexer = nullptr; } bool parse_rel_line(char * full_line, uint64_vector & args) { diff --git a/src/muz/fp/dl_cmds.cpp b/src/muz/fp/dl_cmds.cpp index deb8887ec..ba12c849c 100644 --- a/src/muz/fp/dl_cmds.cpp +++ b/src/muz/fp/dl_cmds.cpp @@ -56,7 +56,7 @@ struct dl_context { m_cmd(ctx), m_collected_cmds(collected_cmds), m_ref_count(0), - m_decl_plugin(0), + m_decl_plugin(nullptr), m_trail(*this) {} void inc_ref() { @@ -88,7 +88,7 @@ struct dl_context { } void reset() { - m_context = 0; + m_context = nullptr; } void register_predicate(func_decl* pred, unsigned num_kinds, symbol const* kinds) { @@ -164,7 +164,7 @@ public: cmd("rule"), m_dl_ctx(dl_ctx), m_arg_idx(0), - m_t(0), + m_t(nullptr), m_bound(UINT_MAX) {} char const * get_usage() const override { return "(forall (q) (=> (and body) head)) :optional-name :optional-recursion-bound"; } char const * get_descr(cmd_context & ctx) const override { return "add a Horn rule."; } @@ -206,7 +206,7 @@ public: dl_query_cmd(dl_context * dl_ctx): parametric_cmd("query"), m_dl_ctx(dl_ctx), - m_target(0) { + m_target(nullptr) { } char const * get_usage() const override { return "predicate"; } char const * get_main_descr() const override { @@ -214,7 +214,7 @@ public: } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { - if (m_target == 0) return CPK_FUNC_DECL; + if (m_target == nullptr) return CPK_FUNC_DECL; return parametric_cmd::next_arg_kind(ctx); } @@ -232,11 +232,11 @@ public: void prepare(cmd_context & ctx) override { ctx.m(); // ensure manager is initialized. parametric_cmd::prepare(ctx); - m_target = 0; + m_target = nullptr; } void execute(cmd_context& ctx) override { - if (m_target == 0) { + if (m_target == nullptr) { throw cmd_exception("invalid query command, argument expected"); } if (m_dl_ctx->collect_query(m_target)) { @@ -318,7 +318,7 @@ public: } dlctx.cleanup(); print_statistics(ctx); - m_target = 0; + m_target = nullptr; } void init_pdescrs(cmd_context & ctx, param_descrs & p) override { @@ -472,7 +472,7 @@ public: void execute(cmd_context & ctx) override { ast_manager& m = ctx.m(); - func_decl_ref var(m.mk_func_decl(m_var_name, 0, static_cast(0), m_var_sort), m); + func_decl_ref var(m.mk_func_decl(m_var_name, 0, static_cast(nullptr), m_var_sort), m); ctx.insert(var); m_dl_ctx->dlctx().register_variable(var); } @@ -528,7 +528,7 @@ static void install_dl_cmds_aux(cmd_context& ctx, dl_collected_cmds* collected_c } void install_dl_cmds(cmd_context & ctx) { - install_dl_cmds_aux(ctx, 0); + install_dl_cmds_aux(ctx, nullptr); } void install_dl_collect_cmds(dl_collected_cmds& collected_cmds, cmd_context & ctx) { diff --git a/src/muz/fp/dl_register_engine.cpp b/src/muz/fp/dl_register_engine.cpp index b56a07a7c..267bfc390 100644 --- a/src/muz/fp/dl_register_engine.cpp +++ b/src/muz/fp/dl_register_engine.cpp @@ -27,7 +27,7 @@ Revision History: #include "muz/spacer/spacer_dl_interface.h" namespace datalog { - register_engine::register_engine(): m_ctx(0) {} + register_engine::register_engine(): m_ctx(nullptr) {} engine_base* register_engine::mk_engine(DL_ENGINE engine_type) { switch(engine_type) { @@ -51,10 +51,10 @@ namespace datalog { return alloc(ddnf, *m_ctx); case LAST_ENGINE: UNREACHABLE(); - return 0; + return nullptr; } UNREACHABLE(); - return 0; + return nullptr; } } diff --git a/src/muz/fp/horn_tactic.cpp b/src/muz/fp/horn_tactic.cpp index 273489164..88fb4e03d 100644 --- a/src/muz/fp/horn_tactic.cpp +++ b/src/muz/fp/horn_tactic.cpp @@ -65,7 +65,7 @@ class horn_tactic : public tactic { void normalize(expr_ref& f) { bool is_positive = true; - expr* e = 0; + expr* e = nullptr; while (true) { if (is_forall(f) && is_positive) { f = to_quantifier(f)->get_expr(); @@ -141,7 +141,7 @@ class horn_tactic : public tactic { ast_mark mark; expr_ref_vector args(m), body(m); expr_ref head(m); - expr* a = 0, *a1 = 0; + expr* a = nullptr, *a1 = nullptr; flatten_or(tmp, args); for (unsigned i = 0; i < args.size(); ++i) { a = args[i].get(); @@ -182,7 +182,7 @@ class horn_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("horn", *g); bool produce_proofs = g->proofs_enabled(); @@ -270,7 +270,7 @@ class horn_tactic : public tactic { if (produce_proofs) { proof_ref proof = m_ctx.get_proof(); pc = proof2proof_converter(m, proof); - g->assert_expr(m.mk_false(), proof, 0); + g->assert_expr(m.mk_false(), proof, nullptr); } else { g->assert_expr(m.mk_false()); diff --git a/src/muz/pdr/pdr_closure.h b/src/muz/pdr/pdr_closure.h index 8af53376b..c41e83389 100644 --- a/src/muz/pdr/pdr_closure.h +++ b/src/muz/pdr/pdr_closure.h @@ -35,8 +35,8 @@ namespace pdr { expr* m_k; obj_map* m_translate; public: - scaler(ast_manager& m): m(m), a(m), m_translate(0) {} - expr_ref operator()(expr* e, expr* k, obj_map* translate = 0); + scaler(ast_manager& m): m(m), a(m), m_translate(nullptr) {} + expr_ref operator()(expr* e, expr* k, obj_map* translate = nullptr); expr_ref undo_k(expr* e, expr* k); private: expr_ref scale(expr* e, bool is_mul); diff --git a/src/muz/pdr/pdr_context.cpp b/src/muz/pdr/pdr_context.cpp index 1d3232deb..971ec9193 100644 --- a/src/muz/pdr/pdr_context.cpp +++ b/src/muz/pdr/pdr_context.cpp @@ -128,7 +128,7 @@ namespace pdr { std::stringstream name_stm; name_stm << m_head->get_name() << '_' << i; func_decl_ref stm(m); - stm = m.mk_func_decl(symbol(name_stm.str().c_str()), 0, (sort*const*)0, arg_sort); + stm = m.mk_func_decl(symbol(name_stm.str().c_str()), 0, (sort*const*)nullptr, arg_sort); m_sig.push_back(pm.get_o_pred(stm, 0)); } } @@ -443,7 +443,7 @@ namespace pdr { else if (is_sat == l_false) { uses_level = m_solver.assumes_level(); } - m_solver.set_model(0); + m_solver.set_model(nullptr); return is_sat; } @@ -459,7 +459,7 @@ namespace pdr { tmp = pm.mk_and(conj); prop_solver::scoped_level _sl(m_solver, level); m_solver.set_core(core); - m_solver.set_model(0); + m_solver.set_model(nullptr); lbool r = m_solver.check_conjunction_as_assumptions(tmp); if (r == l_false) { assumes_level = m_solver.assumes_level(); @@ -477,7 +477,7 @@ namespace pdr { prop_solver::scoped_level _sl(m_solver, level); m_solver.set_core(&core); m_solver.set_subset_based_core(true); - m_solver.set_model(0); + m_solver.set_model(nullptr); lbool res = m_solver.check_assumptions_and_formula(lits, fml); if (res == l_false) { lits.reset(); @@ -649,7 +649,7 @@ namespace pdr { expr_free_vars fv; fv(e); while (vars.size() < fv.size()) { - vars.push_back(0); + vars.push_back(nullptr); } for (unsigned i = 0; i < fv.size(); ++i) { if (fv[i] && !vars[i].get()) { @@ -821,7 +821,7 @@ namespace pdr { datalog::rule const& rl2 = pt().find_rule(*mdl); SASSERT(is_ini(rl2)); set_rule(&rl2); - pt().get_solver().set_model(0); + pt().get_solver().set_model(nullptr); return const_cast(m_rule); } @@ -899,7 +899,7 @@ namespace pdr { if (this == m_next) { SASSERT(m_prev == this); if (root == this) { - root = 0; + root = nullptr; } } else { @@ -910,8 +910,8 @@ namespace pdr { } } TRACE("pdr", tout << "new root: " << root << "\n";); - m_prev = 0; - m_next = 0; + m_prev = nullptr; + m_next = nullptr; } @@ -938,7 +938,7 @@ namespace pdr { */ model_node* model_search::next() { if (!m_goal) { - return 0; + return nullptr; } else { model_node* result = m_goal; @@ -1161,7 +1161,7 @@ namespace pdr { todo.push_back(m_root); while (!todo.empty()) { model_node* n = todo.back(); - model* md = 0; + model* md = nullptr; if (!n->get_model_ptr()) { if (models.find(n->state(), md)) { TRACE("pdr", tout << n->state() << "\n";); @@ -1300,7 +1300,7 @@ namespace pdr { ptr_vector todo; proof_ref_vector trail(m); datalog::rule_ref_vector rules_trail(rm); - proof* pr = 0; + proof* pr = nullptr; unif.set_normalize(true); todo.push_back(m_root); update_models(); @@ -1416,7 +1416,7 @@ namespace pdr { erase_children(*m_root, false); remove_node(*m_root, false); dealloc(m_root); - m_root = 0; + m_root = nullptr; } m_cache.reset(); } @@ -1448,10 +1448,10 @@ namespace pdr { : m_fparams(fparams), m_params(params), m(m), - m_context(0), + m_context(nullptr), m_pm(m_fparams, params.pdr_max_num_contexts(), m), m_query_pred(m), - m_query(0), + m_query(nullptr), m_search(m_params.pdr_bfs_model_search()), m_last_result(l_undef), m_inductive_lvl(0), @@ -1479,7 +1479,7 @@ namespace pdr { reset(m_rels_tmp); } m_search.reset(); - m_query = 0; + m_query = nullptr; m_last_result = l_undef; m_inductive_lvl = 0; } @@ -1546,7 +1546,7 @@ namespace pdr { init_rules(rules, m_rels_tmp); decl2rel::iterator it = m_rels_tmp.begin(), end = m_rels_tmp.end(); for (; it != end; ++it) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (m_rels.find(it->m_key, pt)) { it->m_value->inherit_properties(*pt); } @@ -1561,7 +1561,7 @@ namespace pdr { } unsigned context::get_num_levels(func_decl* p) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (m_rels.find(p, pt)) { return pt->get_num_levels(); } @@ -1572,7 +1572,7 @@ namespace pdr { } expr_ref context::get_cover_delta(int level, func_decl* p_orig, func_decl* p) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (m_rels.find(p, pt)) { return pt->get_cover_delta(p_orig, level); } @@ -1583,7 +1583,7 @@ namespace pdr { } void context::add_cover(int level, func_decl* p, expr* property) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (!m_rels.find(p, pt)) { pt = alloc(pred_transformer, *this, get_pdr_manager(), p); m_rels.insert(p, pt); @@ -2026,7 +2026,7 @@ namespace pdr { // bool context::check_reachability(unsigned level) { expr_ref state(m.mk_true(), m); - model_node* root = alloc(model_node, 0, state, *m_query, level); + model_node* root = alloc(model_node, nullptr, state, *m_query, level); m_search.set_root(root); while (model_node* node = m_search.next()) { @@ -2403,7 +2403,7 @@ namespace pdr { if (m_params.print_boogie_certificate()) { datalog::boogie_proof bp(m); bp.set_proof(get_proof()); - bp.set_model(0); + bp.set_model(nullptr); bp.pp(strm); } else { diff --git a/src/muz/pdr/pdr_context.h b/src/muz/pdr/pdr_context.h index f160cff6a..ebaa3f257 100644 --- a/src/muz/pdr/pdr_context.h +++ b/src/muz/pdr/pdr_context.h @@ -143,7 +143,7 @@ namespace pdr { void add_property(expr * lemma, unsigned lvl); // add property 'p' to state at level. lbool is_reachable(model_node& n, expr_ref_vector* core, bool& uses_level); - bool is_invariant(unsigned level, expr* co_state, bool inductive, bool& assumes_level, expr_ref_vector* core = 0); + bool is_invariant(unsigned level, expr* co_state, bool inductive, bool& assumes_level, expr_ref_vector* core = nullptr); bool check_inductive(unsigned level, expr_ref_vector& state, bool& assumes_level); expr_ref get_formulas(unsigned level, bool add_axioms); @@ -199,8 +199,8 @@ namespace pdr { datalog::rule const* m_rule; public: model_node(model_node* parent, expr_ref& state, pred_transformer& pt, unsigned level): - m_parent(parent), m_next(0), m_prev(0), m_pt(pt), m_state(state), m_model(0), - m_level(level), m_orig_level(level), m_depth(0), m_closed(false), m_rule(0) { + m_parent(parent), m_next(nullptr), m_prev(nullptr), m_pt(pt), m_state(state), m_model(nullptr), + m_level(level), m_orig_level(level), m_depth(0), m_closed(false), m_rule(nullptr) { model_node* p = m_parent; if (p) { p->m_children.push_back(this); @@ -253,7 +253,7 @@ namespace pdr { void dequeue(model_node*& root); void enqueue(model_node* n); model_node* next() const { return m_next; } - bool is_goal() const { return 0 != next(); } + bool is_goal() const { return nullptr != next(); } }; class model_search { @@ -271,7 +271,7 @@ namespace pdr { unsigned num_goals() const; public: - model_search(bool bfs): m_bfs(bfs), m_root(0), m_goal(0) {} + model_search(bool bfs): m_bfs(bfs), m_root(nullptr), m_goal(nullptr) {} ~model_search(); void reset(); diff --git a/src/muz/pdr/pdr_dl_interface.cpp b/src/muz/pdr/pdr_dl_interface.cpp index 87bc68bd9..27ce0500c 100644 --- a/src/muz/pdr/pdr_dl_interface.cpp +++ b/src/muz/pdr/pdr_dl_interface.cpp @@ -38,7 +38,7 @@ dl_interface::dl_interface(datalog::context& ctx) : m_ctx(ctx), m_pdr_rules(ctx), m_old_rules(ctx), - m_context(0), + m_context(nullptr), m_refs(ctx.get_manager()) { m_context = alloc(pdr::context, ctx.get_fparams(), ctx.get_params(), ctx.get_manager()); } diff --git a/src/muz/pdr/pdr_farkas_learner.cpp b/src/muz/pdr/pdr_farkas_learner.cpp index 4a77d2f5f..cb2d3529e 100644 --- a/src/muz/pdr/pdr_farkas_learner.cpp +++ b/src/muz/pdr/pdr_farkas_learner.cpp @@ -373,7 +373,7 @@ namespace pdr { farkas_learner::farkas_learner(smt_params& params, ast_manager& outer_mgr) : m_proof_params(get_proof_params(params)), m_pr(PGM_ENABLED), - m_constr(0), + m_constr(nullptr), m_combine_farkas_coefficients(true), p2o(m_pr, outer_mgr), o2p(outer_mgr, m_pr) diff --git a/src/muz/pdr/pdr_generalizers.cpp b/src/muz/pdr/pdr_generalizers.cpp index 094379a0b..8e52cb6f4 100644 --- a/src/muz/pdr/pdr_generalizers.cpp +++ b/src/muz/pdr/pdr_generalizers.cpp @@ -189,7 +189,7 @@ namespace pdr { expr_ref fml1 = mk_and(core); expr_ref fml2 = n.pt().get_formulas(n.level(), false); fml1_2.push_back(fml1); - fml1_2.push_back(0); + fml1_2.push_back(nullptr); flatten_and(fml2, fmls); for (unsigned i = 0; i < fmls.size(); ++i) { fml2 = m.mk_not(fmls[i].get()); @@ -199,7 +199,7 @@ namespace pdr { tout << "Check states:\n" << mk_pp(state, m) << "\n"; tout << "Old states:\n" << mk_pp(fml2, m) << "\n"; ); - model_node nd(0, state, n.pt(), n.level()); + model_node nd(nullptr, state, n.pt(), n.level()); pred_transformer::scoped_farkas sf(n.pt(), true); bool uses_level1 = uses_level; if (l_false == n.pt().is_reachable(nd, &conv2, uses_level1)) { @@ -236,7 +236,7 @@ namespace pdr { n.pt().get_solver().set_consequences(&consequences); pred_transformer::scoped_farkas sf (n.pt(), true); VERIFY(l_false == n.pt().is_reachable(n, &core1, uses_level1)); - n.pt().get_solver().set_consequences(0); + n.pt().get_solver().set_consequences(nullptr); } IF_VERBOSE(0, verbose_stream() << "Consequences: " << consequences.size() << "\n"; @@ -257,7 +257,7 @@ namespace pdr { cstate.push_back(m.mk_not(consequences[i].get())); } tmp = m.mk_and(cstate.size(), cstate.c_ptr()); - model_node nd(0, tmp, n.pt(), n.level()); + model_node nd(nullptr, tmp, n.pt(), n.level()); pred_transformer::scoped_farkas sf (n.pt(), false); VERIFY(l_false == n.pt().is_reachable(nd, &core1, uses_level1)); } @@ -752,7 +752,7 @@ namespace pdr { // void core_induction_generalizer::operator()(model_node& n, expr_ref_vector& core, bool& uses_level) { model_node* p = n.parent(); - if (p == 0) { + if (p == nullptr) { return; } unsigned depth = 2; diff --git a/src/muz/pdr/pdr_manager.h b/src/muz/pdr/pdr_manager.h index 9fc98940d..ccbbbe356 100644 --- a/src/muz/pdr/pdr_manager.h +++ b/src/muz/pdr/pdr_manager.h @@ -289,7 +289,7 @@ namespace pdr { bg is background knowledge and can be null */ - bool implication_surely_holds(expr * lhs, expr * rhs, expr * bg=0); + bool implication_surely_holds(expr * lhs, expr * rhs, expr * bg=nullptr); unsigned get_unique_num() { return m_next_unique_num++; } diff --git a/src/muz/pdr/pdr_prop_solver.cpp b/src/muz/pdr/pdr_prop_solver.cpp index 3055985f4..801d06e50 100644 --- a/src/muz/pdr/pdr_prop_solver.cpp +++ b/src/muz/pdr/pdr_prop_solver.cpp @@ -234,9 +234,9 @@ namespace pdr { m_pos_level_atoms(m), m_neg_level_atoms(m), m_proxies(m), - m_core(0), - m_model(0), - m_consequences(0), + m_core(nullptr), + m_model(nullptr), + m_consequences(nullptr), m_subset_based_core(false), m_use_farkas(false), m_in_level(false), @@ -249,7 +249,7 @@ namespace pdr { unsigned idx = level_cnt(); std::stringstream name; name << m_name << "#level_" << idx; - func_decl * lev_pred = m.mk_fresh_func_decl(name.str().c_str(), 0, 0,m.mk_bool_sort()); + func_decl * lev_pred = m.mk_fresh_func_decl(name.str().c_str(), 0, nullptr,m.mk_bool_sort()); m_aux_symbols.insert(lev_pred); m_level_preds.push_back(lev_pred); @@ -301,7 +301,7 @@ namespace pdr { safe_assumptions& safe, const expr_ref_vector& atoms) { - flet _model(m_fparams.m_model, m_model != 0); + flet _model(m_fparams.m_model, m_model != nullptr); expr_ref_vector expr_atoms(m); expr_atoms.append(atoms.size(), atoms.c_ptr()); @@ -342,8 +342,8 @@ namespace pdr { extract_subset_core(safe); SASSERT(expr_atoms.size() >= m_core->size()); } - m_core = 0; - m_model = 0; + m_core = nullptr; + m_model = nullptr; m_subset_based_core = false; return result; } diff --git a/src/muz/pdr/pdr_reachable_cache.cpp b/src/muz/pdr/pdr_reachable_cache.cpp index d28c1415b..5d553df4d 100644 --- a/src/muz/pdr/pdr_reachable_cache.cpp +++ b/src/muz/pdr/pdr_reachable_cache.cpp @@ -24,7 +24,7 @@ namespace pdr { reachable_cache::reachable_cache(pdr::manager & pm, datalog::PDR_CACHE_MODE cm) : m(pm.get_manager()), m_pm(pm), - m_ctx(0), + m_ctx(nullptr), m_ref_holder(m), m_disj_connector(m), m_cache_mode(cm) { diff --git a/src/muz/pdr/pdr_smt_context_manager.cpp b/src/muz/pdr/pdr_smt_context_manager.cpp index b87d1e451..88734049b 100644 --- a/src/muz/pdr/pdr_smt_context_manager.cpp +++ b/src/muz/pdr/pdr_smt_context_manager.cpp @@ -130,7 +130,7 @@ namespace pdr { smt_context* smt_context_manager::mk_fresh() { ++m_num_contexts; app_ref pred(m); - smt::kernel * ctx = 0; + smt::kernel * ctx = nullptr; if (m_max_num_contexts == 0) { m_contexts.push_back(alloc(smt::kernel, m, m_fparams)); pred = m.mk_true(); diff --git a/src/muz/pdr/pdr_sym_mux.h b/src/muz/pdr/pdr_sym_mux.h index 981dc9615..64a2878a9 100644 --- a/src/muz/pdr/pdr_sym_mux.h +++ b/src/muz/pdr/pdr_sym_mux.h @@ -122,7 +122,7 @@ public: func_decl * try_get_primary_by_prefix(func_decl* prefix) const { func_decl * res; if(!m_prefix2prim.find(prefix, res)) { - return 0; + return nullptr; } return res; } @@ -133,7 +133,7 @@ public: func_decl * try_get_by_prefix(func_decl* prefix, unsigned idx) { func_decl * prim = try_get_primary_by_prefix(prefix); if(!prim) { - return 0; + return nullptr; } return conv(prim, 0, idx); } diff --git a/src/muz/pdr/pdr_util.cpp b/src/muz/pdr/pdr_util.cpp index 19ffdeeec..ad75ae799 100644 --- a/src/muz/pdr/pdr_util.cpp +++ b/src/muz/pdr/pdr_util.cpp @@ -244,7 +244,7 @@ namespace pdr { } bool test_eq(expr* e) const { - expr* lhs = 0, *rhs = 0; + expr* lhs = nullptr, *rhs = nullptr; VERIFY(m.is_eq(e, lhs, rhs)); if (!a.is_int_real(lhs)) { return true; diff --git a/src/muz/rel/aig_exporter.cpp b/src/muz/rel/aig_exporter.cpp index 3fed47f80..c38964be0 100644 --- a/src/muz/rel/aig_exporter.cpp +++ b/src/muz/rel/aig_exporter.cpp @@ -118,7 +118,7 @@ namespace datalog { } exprs.reset(); - assert_pred_id(numqs ? r->get_tail(0)->get_decl() : 0, m_ruleid_var_set, exprs); + assert_pred_id(numqs ? r->get_tail(0)->get_decl() : nullptr, m_ruleid_var_set, exprs); assert_pred_id(r->get_head()->get_decl(), m_ruleid_varp_set, exprs); subst.reset(); @@ -141,7 +141,7 @@ namespace datalog { if (m_facts) { for (fact_vector::const_iterator I = m_facts->begin(), E = m_facts->end(); I != E; ++I) { exprs.reset(); - assert_pred_id(0, m_ruleid_var_set, exprs); + assert_pred_id(nullptr, m_ruleid_var_set, exprs); assert_pred_id(I->first, m_ruleid_varp_set, exprs); for (unsigned i = 0; i < I->second.size(); ++i) { diff --git a/src/muz/rel/aig_exporter.h b/src/muz/rel/aig_exporter.h index ea241fe2b..aac139adb 100644 --- a/src/muz/rel/aig_exporter.h +++ b/src/muz/rel/aig_exporter.h @@ -23,7 +23,7 @@ Abstract: namespace datalog { class aig_exporter { public: - aig_exporter(const rule_set& rules, context& ctx, const fact_vector *facts = 0); + aig_exporter(const rule_set& rules, context& ctx, const fact_vector *facts = nullptr); void operator()(std::ostream& out); private: @@ -60,7 +60,7 @@ namespace datalog { unsigned mk_or(unsigned id1, unsigned id2); unsigned get_var(const expr *e); unsigned mk_var(const expr *e); - unsigned mk_input_var(const expr *e = 0); + unsigned mk_input_var(const expr *e = nullptr); unsigned mk_expr_id(); }; } diff --git a/src/muz/rel/check_relation.cpp b/src/muz/rel/check_relation.cpp index a6298cf22..bd8fb4778 100644 --- a/src/muz/rel/check_relation.cpp +++ b/src/muz/rel/check_relation.cpp @@ -150,7 +150,7 @@ namespace datalog { check_relation_plugin::check_relation_plugin(relation_manager& rm): relation_plugin(check_relation_plugin::get_name(), rm), m(rm.get_context().get_manager()), - m_base(0) { + m_base(nullptr) { } check_relation_plugin::~check_relation_plugin() { } @@ -158,7 +158,7 @@ namespace datalog { return dynamic_cast(r); } check_relation* check_relation_plugin::get(relation_base* r) { - return r?dynamic_cast(r):0; + return r?dynamic_cast(r):nullptr; } check_relation const & check_relation_plugin::get(relation_base const& r) { return dynamic_cast(r); @@ -207,7 +207,7 @@ namespace datalog { const relation_base & t1, const relation_base & t2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { relation_join_fn* j = m_base->mk_join_fn(get(t1).rb(), get(t2).rb(), col_cnt, cols1, cols2); - return j?alloc(join_fn, j, t1.get_signature(), t2.get_signature(), col_cnt, cols1, cols2):0; + return j?alloc(join_fn, j, t1.get_signature(), t2.get_signature(), col_cnt, cols1, cols2):nullptr; } class check_relation_plugin::join_project_fn : public convenient_relation_join_project_fn { @@ -239,7 +239,7 @@ namespace datalog { relation_join_fn* j = m_base->mk_join_project_fn(get(t1).rb(), get(t2).rb(), col_cnt, cols1, cols2, removed_col_cnt, removed_cols); return j?alloc(join_project_fn, j, t1.get_signature(), t2.get_signature(), col_cnt, cols1, cols2, - removed_col_cnt, removed_cols):0; + removed_col_cnt, removed_cols):nullptr; } void check_relation_plugin::verify_filter_project( @@ -499,8 +499,8 @@ namespace datalog { expr_ref fml0 = r.m_fml; expr_ref delta0(r.m_fml.get_manager()); if (d) d->to_formula(delta0); - (*m_union)(r.rb(), src.rb(), d?(&d->rb()):0); - r.get_plugin().verify_union(fml0, src.rb(), r.rb(), delta0, d?(&d->rb()):0); + (*m_union)(r.rb(), src.rb(), d?(&d->rb()):nullptr); + r.get_plugin().verify_union(fml0, src.rb(), r.rb(), delta0, d?(&d->rb()):nullptr); r.rb().to_formula(r.m_fml); if (d) d->rb().to_formula(d->m_fml); } @@ -508,16 +508,16 @@ namespace datalog { relation_union_fn * check_relation_plugin::mk_union_fn( const relation_base & tgt, const relation_base & src, const relation_base * delta) { - relation_base const* d1 = delta?(&(get(*delta).rb())):0; + relation_base const* d1 = delta?(&(get(*delta).rb())):nullptr; relation_union_fn* u = m_base->mk_union_fn(get(tgt).rb(), get(src).rb(), d1); - return u?alloc(union_fn, u):0; + return u?alloc(union_fn, u):nullptr; } relation_union_fn * check_relation_plugin::mk_widen_fn( const relation_base & tgt, const relation_base & src, const relation_base * delta) { - relation_base const* d1 = delta?(&(get(*delta).rb())):0; + relation_base const* d1 = delta?(&(get(*delta).rb())):nullptr; relation_union_fn* u = m_base->mk_widen_fn(get(tgt).rb(), get(src).rb(), d1); - return u?alloc(union_fn, u):0; + return u?alloc(union_fn, u):nullptr; } class check_relation_plugin::filter_identical_fn : public relation_mutator_fn { @@ -553,7 +553,7 @@ namespace datalog { relation_mutator_fn * check_relation_plugin::mk_filter_identical_fn( const relation_base & t, unsigned col_cnt, const unsigned * identical_cols) { relation_mutator_fn* r = m_base->mk_filter_identical_fn(get(t).rb(), col_cnt, identical_cols); - return r?alloc(filter_identical_fn, r, col_cnt, identical_cols):0; + return r?alloc(filter_identical_fn, r, col_cnt, identical_cols):nullptr; } class check_relation_plugin::filter_interpreted_fn : public relation_mutator_fn { @@ -579,7 +579,7 @@ namespace datalog { relation_mutator_fn * check_relation_plugin::mk_filter_interpreted_fn(const relation_base & t, app * condition) { relation_mutator_fn* r = m_base->mk_filter_interpreted_fn(get(t).rb(), condition); app_ref cond(condition, m); - return r?alloc(filter_interpreted_fn, r, cond):0; + return r?alloc(filter_interpreted_fn, r, cond):nullptr; } class check_relation_plugin::project_fn : public convenient_relation_project_fn { @@ -608,7 +608,7 @@ namespace datalog { const relation_base & t, unsigned col_cnt, const unsigned * removed_cols) { relation_transformer_fn* p = m_base->mk_project_fn(get(t).rb(), col_cnt, removed_cols); - return p?alloc(project_fn, p, t, col_cnt, removed_cols):0; + return p?alloc(project_fn, p, t, col_cnt, removed_cols):nullptr; } class check_relation_plugin::rename_fn : public convenient_relation_rename_fn { @@ -635,7 +635,7 @@ namespace datalog { const relation_base & r, unsigned cycle_len, const unsigned * permutation_cycle) { relation_transformer_fn* p = m_base->mk_rename_fn(get(r).rb(), cycle_len, permutation_cycle); - return p?alloc(rename_fn, p, r, cycle_len, permutation_cycle):0; + return p?alloc(rename_fn, p, r, cycle_len, permutation_cycle):nullptr; } class check_relation_plugin::filter_equal_fn : public relation_mutator_fn { @@ -663,7 +663,7 @@ namespace datalog { relation_mutator_fn * check_relation_plugin::mk_filter_equal_fn( const relation_base & t, const relation_element & value, unsigned col) { relation_mutator_fn* r = m_base->mk_filter_equal_fn(get(t).rb(), value, col); - return r?alloc(filter_equal_fn, r, t, value, col):0; + return r?alloc(filter_equal_fn, r, t, value, col):nullptr; } @@ -700,7 +700,7 @@ namespace datalog { const relation_base& neg, unsigned joined_col_cnt, const unsigned *t_cols, const unsigned *negated_cols) { relation_intersection_filter_fn* f = m_base->mk_filter_by_negation_fn(get(t).rb(), get(neg).rb(), joined_col_cnt, t_cols, negated_cols); - return f?alloc(negation_filter_fn, f, joined_col_cnt, t_cols, negated_cols):0; + return f?alloc(negation_filter_fn, f, joined_col_cnt, t_cols, negated_cols):nullptr; } /* @@ -779,7 +779,7 @@ namespace datalog { unsigned removed_col_cnt, const unsigned * removed_cols) { relation_transformer_fn* r = m_base->mk_filter_interpreted_and_project_fn(get(t).rb(), condition, removed_col_cnt, removed_cols); app_ref cond(condition, m); - return r?alloc(filter_proj_fn, r, t, cond, removed_col_cnt, removed_cols):0; + return r?alloc(filter_proj_fn, r, t, cond, removed_col_cnt, removed_cols):nullptr; } diff --git a/src/muz/rel/dl_base.cpp b/src/muz/rel/dl_base.cpp index 5ca84c895..20418e3bb 100644 --- a/src/muz/rel/dl_base.cpp +++ b/src/muz/rel/dl_base.cpp @@ -51,7 +51,7 @@ namespace datalog { ast_manager & m = renaming_arg.get_manager(); unsigned sz = map.size(); unsigned ofs = sz-1; - renaming_arg.resize(sz, static_cast(0)); + renaming_arg.resize(sz, static_cast(nullptr)); for(unsigned i=0; i() { return m_t; } const T* operator->() const { return m_t; } T& operator*() { return *m_t; } const T& operator*() const { return *m_t; } - operator bool() const { return m_t!=0; } + operator bool() const { return m_t!=nullptr; } T* get() const { return m_t; } /** \brief Remove object from \c scoped_rel without deleting it. */ T* release() { T* res = m_t; - m_t = 0; + m_t = nullptr; return res; } }; @@ -202,7 +202,7 @@ namespace datalog { virtual void operator()(base_object & tgt, const base_object & src, base_object * delta) = 0; void operator()(base_object & tgt, const base_object & src) { - (*this)(tgt, src, static_cast(0)); + (*this)(tgt, src, static_cast(nullptr)); } }; @@ -335,55 +335,55 @@ namespace datalog { virtual join_fn * mk_join_fn(const base_object & t1, const base_object & t2, - unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { return 0; } + unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { return nullptr; } virtual transformer_fn * mk_project_fn(const base_object & t, unsigned col_cnt, - const unsigned * removed_cols) { return 0; } + const unsigned * removed_cols) { return nullptr; } virtual join_fn * mk_join_project_fn(const base_object & t1, const base_object & t2, unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, - unsigned removed_col_cnt, const unsigned * removed_cols) { return 0; } + unsigned removed_col_cnt, const unsigned * removed_cols) { return nullptr; } virtual transformer_fn * mk_rename_fn(const base_object & t, unsigned permutation_cycle_len, - const unsigned * permutation_cycle) { return 0; } + const unsigned * permutation_cycle) { return nullptr; } virtual transformer_fn * mk_permutation_rename_fn(const base_object & t, - const unsigned * permutation) { return 0; } + const unsigned * permutation) { return nullptr; } public: virtual union_fn * mk_union_fn(const base_object & tgt, const base_object & src, - const base_object * delta) { return 0; } + const base_object * delta) { return nullptr; } protected: virtual union_fn * mk_widen_fn(const base_object & tgt, const base_object & src, - const base_object * delta) { return 0; } + const base_object * delta) { return nullptr; } virtual mutator_fn * mk_filter_identical_fn(const base_object & t, unsigned col_cnt, - const unsigned * identical_cols) { return 0; } + const unsigned * identical_cols) { return nullptr; } virtual mutator_fn * mk_filter_equal_fn(const base_object & t, const element & value, - unsigned col) { return 0; } + unsigned col) { return nullptr; } virtual mutator_fn * mk_filter_interpreted_fn(const base_object & t, app * condition) - { return 0; } + { return nullptr; } virtual transformer_fn * mk_filter_interpreted_and_project_fn(const base_object & t, app * condition, unsigned removed_col_cnt, const unsigned * removed_cols) - { return 0; } + { return nullptr; } virtual transformer_fn * mk_select_equal_and_project_fn(const base_object & t, - const element & value, unsigned col) { return 0; } + const element & value, unsigned col) { return nullptr; } virtual intersection_filter_fn * mk_filter_by_intersection_fn(const base_object & t, const base_object & src, unsigned joined_col_cnt, const unsigned * t_cols, const unsigned * src_cols) - { return 0; } + { return nullptr; } virtual intersection_filter_fn * mk_filter_by_negation_fn(const base_object & t, const base_object & negated_obj, unsigned joined_col_cnt, const unsigned * t_cols, const unsigned * negated_cols) - { return 0; } + { return nullptr; } virtual intersection_join_filter_fn * mk_filter_by_negated_join_fn( const base_object & t, @@ -393,7 +393,7 @@ namespace datalog { unsigned_vector const& src_cols, unsigned_vector const& src1_cols, unsigned_vector const& src2_cols) - { return 0; } + { return nullptr; } }; @@ -1029,14 +1029,14 @@ namespace datalog { If the returned value is non-zero, the returned object must take ownership of \c mapper. Otherwise \c mapper must remain unmodified. */ - virtual table_mutator_fn * mk_map_fn(const table_base & t, table_row_mutator_fn * mapper) { return 0; } + virtual table_mutator_fn * mk_map_fn(const table_base & t, table_row_mutator_fn * mapper) { return nullptr; } /** If the returned value is non-zero, the returned object must take ownership of \c reducer. Otherwise \c reducer must remain unmodified. */ virtual table_transformer_fn * mk_project_with_reduce_fn(const table_base & t, unsigned col_cnt, - const unsigned * removed_cols, table_row_pair_reduce_fn * reducer) { return 0; } + const unsigned * removed_cols, table_row_pair_reduce_fn * reducer) { return nullptr; } }; @@ -1047,7 +1047,7 @@ namespace datalog { ~table_base() override {} public: table_base * clone() const override; - virtual table_base * complement(func_decl* p, const table_element * func_columns = 0) const; + virtual table_base * complement(func_decl* p, const table_element * func_columns = nullptr) const; bool empty() const override; /** diff --git a/src/muz/rel/dl_bound_relation.cpp b/src/muz/rel/dl_bound_relation.cpp index 74b87d96e..60358db48 100644 --- a/src/muz/rel/dl_bound_relation.cpp +++ b/src/muz/rel/dl_bound_relation.cpp @@ -83,7 +83,7 @@ namespace datalog { bound_relation const& r1 = get(_r1); bound_relation const& r2 = get(_r2); bound_relation_plugin& p = r1.get_plugin(); - bound_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); + bound_relation* result = dynamic_cast(p.mk_full(nullptr, get_result_signature())); result->mk_join(r1, r2, m_cols1.size(), m_cols1.c_ptr(), m_cols2.c_ptr()); return result; } @@ -92,7 +92,7 @@ namespace datalog { relation_join_fn * bound_relation_plugin::mk_join_fn(const relation_base & r1, const relation_base & r2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if (!check_kind(r1) || !check_kind(r2)) { - return 0; + return nullptr; } return alloc(join_fn, r1.get_signature(), r2.get_signature(), col_cnt, cols1, cols2); } @@ -107,7 +107,7 @@ namespace datalog { relation_base * operator()(const relation_base & _r) override { bound_relation const& r = get(_r); bound_relation_plugin& p = r.get_plugin(); - bound_relation* result = get(p.mk_full(0, get_result_signature())); + bound_relation* result = get(p.mk_full(nullptr, get_result_signature())); result->mk_project(r, m_removed_cols.size(), m_removed_cols.c_ptr()); return result; } @@ -127,7 +127,7 @@ namespace datalog { relation_base * operator()(const relation_base & _r) override { bound_relation const& r = get(_r); bound_relation_plugin& p = r.get_plugin(); - bound_relation* result = get(p.mk_full(0, get_result_signature())); + bound_relation* result = get(p.mk_full(nullptr, get_result_signature())); result->mk_rename(r, m_cycle.size(), m_cycle.c_ptr()); return result; } @@ -138,7 +138,7 @@ namespace datalog { if(check_kind(r)) { return alloc(rename_fn, r.get_signature(), cycle_len, permutation_cycle); } - return 0; + return nullptr; } @@ -176,7 +176,7 @@ namespace datalog { if (check_kind(tgt) && check_kind(src) && (!delta || check_kind(*delta))) { return alloc(union_fn, false); } - return 0; + return nullptr; } relation_union_fn * bound_relation_plugin::mk_widen_fn( @@ -188,7 +188,7 @@ namespace datalog { if (check_kind(tgt) && check_kind(src) && (!delta || check_kind(*delta))) { return alloc(union_fn, true); } - return 0; + return nullptr; } class bound_relation_plugin::filter_identical_fn : public relation_mutator_fn { @@ -209,7 +209,7 @@ namespace datalog { if(check_kind(t)) { return alloc(filter_identical_fn, col_cnt, identical_cols); } - return 0; + return nullptr; } class bound_relation_plugin::filter_equal_fn : public relation_mutator_fn { @@ -224,7 +224,7 @@ namespace datalog { if (check_kind(r)) { return alloc(filter_equal_fn, value, col); } - return 0; + return nullptr; } class bound_relation_plugin::filter_interpreted_fn : public relation_mutator_fn { @@ -280,7 +280,7 @@ namespace datalog { filter_interpreted_fn(ast_manager& m, app* cond) : m_cond(cond, m), - m_lt(m), m_arith(m), m_interval(0), m_kind(NOT_APPLICABLE) { + m_lt(m), m_arith(m), m_interval(nullptr), m_kind(NOT_APPLICABLE) { expr* l, *r, *r1, *r2, *c2; rational n1; if ((m_arith.is_lt(cond, l, r) || m_arith.is_gt(cond, r, l)) && @@ -592,7 +592,7 @@ namespace datalog { scoped_ptr fe = get_plugin().mk_filter_equal_fn(r, f[i], i); (*fe)(r); } - mk_union(r, 0, false); + mk_union(r, nullptr, false); } bool bound_relation::contains_fact(const relation_fact & f) const { @@ -604,12 +604,12 @@ namespace datalog { } bound_relation * bound_relation::clone() const { - bound_relation* result = 0; + bound_relation* result = nullptr; if (empty()) { result = bound_relation_plugin::get(get_plugin().mk_empty(get_signature())); } else { - result = bound_relation_plugin::get(get_plugin().mk_full(0, get_signature())); + result = bound_relation_plugin::get(get_plugin().mk_full(nullptr, get_signature())); result->copy(*this); } return result; @@ -647,7 +647,7 @@ namespace datalog { bound_relation * bound_relation::complement(func_decl* p) const { UNREACHABLE(); - return 0; + return nullptr; } void bound_relation::to_formula(expr_ref& fml) const { diff --git a/src/muz/rel/dl_bound_relation.h b/src/muz/rel/dl_bound_relation.h index da1aad71a..6c613a472 100644 --- a/src/muz/rel/dl_bound_relation.h +++ b/src/muz/rel/dl_bound_relation.h @@ -69,7 +69,7 @@ namespace datalog { relation_join_fn * mk_join_project_fn(const relation_base & t1, const relation_base & t2, unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, - unsigned removed_col_cnt, const unsigned * removed_cols) override { return 0; } + unsigned removed_col_cnt, const unsigned * removed_cols) override { return nullptr; } #if 0 diff --git a/src/muz/rel/dl_check_table.cpp b/src/muz/rel/dl_check_table.cpp index b7d22159e..0a6d90027 100644 --- a/src/muz/rel/dl_check_table.cpp +++ b/src/muz/rel/dl_check_table.cpp @@ -40,12 +40,12 @@ namespace datalog { table_base& check_table_plugin::checker(table_base& r) { return *get(r).m_checker; } table_base const& check_table_plugin::checker(table_base const& r) { return *get(r).m_checker; } - table_base* check_table_plugin::checker(table_base* r) { return r?(get(*r).m_checker):0; } - table_base const* check_table_plugin::checker(table_base const* r) { return r?(get(*r).m_checker):0; } + table_base* check_table_plugin::checker(table_base* r) { return r?(get(*r).m_checker):nullptr; } + table_base const* check_table_plugin::checker(table_base const* r) { return r?(get(*r).m_checker):nullptr; } table_base& check_table_plugin::tocheck(table_base& r) { return *get(r).m_tocheck; } table_base const& check_table_plugin::tocheck(table_base const& r) { return *get(r).m_tocheck; } - table_base* check_table_plugin::tocheck(table_base* r) { return r?(get(*r).m_tocheck):0; } - table_base const* check_table_plugin::tocheck(table_base const* r) { return r?(get(*r).m_tocheck):0; } + table_base* check_table_plugin::tocheck(table_base* r) { return r?(get(*r).m_tocheck):nullptr; } + table_base const* check_table_plugin::tocheck(table_base const* r) { return r?(get(*r).m_tocheck):nullptr; } table_base * check_table_plugin::mk_empty(const table_signature & s) { IF_VERBOSE(1, verbose_stream() << __FUNCTION__ << "\n";); @@ -77,7 +77,7 @@ namespace datalog { table_join_fn * check_table_plugin::mk_join_fn(const table_base & t1, const table_base & t2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if (!check_kind(t1) || !check_kind(t2)) { - return 0; + return nullptr; } return alloc(join_fn, *this, t1, t2, col_cnt, cols1, cols2); } @@ -105,7 +105,7 @@ namespace datalog { unsigned col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, const unsigned * removed_cols) { if (!check_kind(t1) || !check_kind(t2)) { - return 0; + return nullptr; } return alloc(join_project_fn, *this, t1, t2, col_cnt, cols1, cols2, removed_col_cnt, removed_cols); } @@ -132,7 +132,7 @@ namespace datalog { table_union_fn * check_table_plugin::mk_union_fn(const table_base & tgt, const table_base & src, const table_base * delta) { if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; + return nullptr; } return alloc(union_fn, *this, tgt, src, delta); @@ -157,7 +157,7 @@ namespace datalog { table_transformer_fn * check_table_plugin::mk_project_fn(const table_base & t, unsigned col_cnt, const unsigned * removed_cols) { if (!check_kind(t)) { - return 0; + return nullptr; } return alloc(project_fn, *this, t, col_cnt, removed_cols); } @@ -182,7 +182,7 @@ namespace datalog { table_transformer_fn * check_table_plugin::mk_select_equal_and_project_fn(const table_base & t, const table_element & value, unsigned col) { if (!check_kind(t)) { - return 0; + return nullptr; } return alloc(select_equal_and_project_fn, *this, t, value, col); } @@ -207,7 +207,7 @@ namespace datalog { table_transformer_fn * check_table_plugin::mk_rename_fn(const table_base & t, unsigned len, const unsigned * cycle) { if (!check_kind(t)) { - return 0; + return nullptr; } return alloc(rename_fn, *this, t, len, cycle); } @@ -234,7 +234,7 @@ namespace datalog { if (check_kind(t)) { return alloc(filter_identical_fn, *this, t, col_cnt, identical_cols); } - return 0; + return nullptr; } class check_table_plugin::filter_equal_fn : public table_mutator_fn { @@ -258,7 +258,7 @@ namespace datalog { if (check_kind(t)) { return alloc(filter_equal_fn, *this, t, value, col); } - return 0; + return nullptr; } class check_table_plugin::filter_interpreted_fn : public table_mutator_fn { @@ -282,7 +282,7 @@ namespace datalog { if (check_kind(t)) { return alloc(filter_interpreted_fn, *this, t, condition); } - return 0; + return nullptr; } class check_table_plugin::filter_interpreted_and_project_fn : public table_transformer_fn { @@ -309,7 +309,7 @@ namespace datalog { if (check_kind(t)) { return alloc(filter_interpreted_and_project_fn, *this, t, condition, removed_col_cnt, removed_cols); } - return 0; + return nullptr; } class check_table_plugin::filter_by_negation_fn : public table_intersection_filter_fn { @@ -340,7 +340,7 @@ namespace datalog { if (check_kind(t) && check_kind(negated_obj)) { return alloc(filter_by_negation_fn, *this, t, negated_obj, joined_col_cnt, t_cols, negated_cols); } - return 0; + return nullptr; } // ------------------ diff --git a/src/muz/rel/dl_check_table.h b/src/muz/rel/dl_check_table.h index 77d9d0cdf..7bd4cf12d 100644 --- a/src/muz/rel/dl_check_table.h +++ b/src/muz/rel/dl_check_table.h @@ -120,7 +120,7 @@ namespace datalog { void add_fact(const table_fact & f) override; void remove_fact(const table_element* fact) override; bool contains_fact(const table_fact & f) const override; - table_base * complement(func_decl* p, const table_element * func_columns = 0) const override; + table_base * complement(func_decl* p, const table_element * func_columns = nullptr) const override; table_base * clone() const override; iterator begin() const override { SASSERT(well_formed()); return m_tocheck->begin(); } diff --git a/src/muz/rel/dl_compiler.cpp b/src/muz/rel/dl_compiler.cpp index 32bcfed50..2de0679a5 100644 --- a/src/muz/rel/dl_compiler.cpp +++ b/src/muz/rel/dl_compiler.cpp @@ -1120,7 +1120,7 @@ namespace datalog { //and clear local deltas make_inloop_delta_transition(global_head_deltas, global_tail_deltas, local_deltas, *loop_body); - loop_body->set_observer(0); + loop_body->set_observer(nullptr); acc.push_back(instruction::mk_while_loop(loop_control_regs.size(), loop_control_regs.c_ptr(), loop_body)); } @@ -1316,7 +1316,7 @@ namespace datalog { pred2idx empty_pred2idx_map; - compile_strats(m_rule_set.get_stratifier(), static_cast(0), + compile_strats(m_rule_set.get_stratifier(), static_cast(nullptr), empty_pred2idx_map, true, execution_code); @@ -1331,7 +1331,7 @@ namespace datalog { termination_code.push_back(instruction::mk_store(m_context.get_manager(), pred, reg)); } - acc.set_observer(0); + acc.set_observer(nullptr); TRACE("dl", execution_code.display(execution_context(m_context), tout);); } diff --git a/src/muz/rel/dl_compiler.h b/src/muz/rel/dl_compiler.h index 51ec7643c..d7bdcad34 100644 --- a/src/muz/rel/dl_compiler.h +++ b/src/muz/rel/dl_compiler.h @@ -93,10 +93,10 @@ namespace datalog { compiler & m_parent; rule * m_current; public: - instruction_observer(compiler & parent) : m_parent(parent), m_current(0) {} + instruction_observer(compiler & parent) : m_parent(parent), m_current(nullptr) {} void start_rule(rule * r) { SASSERT(!m_current); m_current=r; } - void finish_rule() { m_current = 0; } + void finish_rule() { m_current = nullptr; } void notify(instruction * i) override { if(m_current) { i->set_accounting_parent_object(m_parent.m_context, m_current); diff --git a/src/muz/rel/dl_external_relation.cpp b/src/muz/rel/dl_external_relation.cpp index 403c5cbd3..88511530e 100644 --- a/src/muz/rel/dl_external_relation.cpp +++ b/src/muz/rel/dl_external_relation.cpp @@ -46,7 +46,7 @@ namespace datalog { args.push_back(f[i]); } if (!fn.get()) { - fn = m.mk_func_decl(fid, k, 0, 0, args.size(), args.c_ptr()); + fn = m.mk_func_decl(fid, k, 0, nullptr, args.size(), args.c_ptr()); } if (destructive) { get_plugin().reduce_assign(fn, args.size(), args.c_ptr(), 1, args.c_ptr()); @@ -63,7 +63,7 @@ namespace datalog { expr_ref res(m); if (!m_is_empty_fn.get()) { family_id fid = get_plugin().get_family_id(); - const_cast(m_is_empty_fn) = m.mk_func_decl(fid, OP_RA_IS_EMPTY, 0, 0, 1, &r); + const_cast(m_is_empty_fn) = m.mk_func_decl(fid, OP_RA_IS_EMPTY, 0, nullptr, 1, &r); } get_plugin().reduce(m_is_empty_fn, 1, &r, res); return m.is_true(res); @@ -86,7 +86,7 @@ namespace datalog { expr* rel = m_rel.get(); expr_ref res(m.mk_fresh_const("T", m.get_sort(rel)), m); expr* rel_out = res.get(); - func_decl_ref fn(m.mk_func_decl(fid, OP_RA_CLONE,0,0, 1, &rel), m); + func_decl_ref fn(m.mk_func_decl(fid, OP_RA_CLONE,0,nullptr, 1, &rel), m); get_plugin().reduce_assign(fn, 1, &rel, 1, &rel_out); return alloc(external_relation, get_plugin(), get_signature(), res); } @@ -96,7 +96,7 @@ namespace datalog { family_id fid = get_plugin().get_family_id(); expr_ref res(m); expr* rel = m_rel; - func_decl_ref fn(m.mk_func_decl(fid, OP_RA_COMPLEMENT,0,0, 1, &rel), m); + func_decl_ref fn(m.mk_func_decl(fid, OP_RA_COMPLEMENT,0,nullptr, 1, &rel), m); get_plugin().reduce(fn, 1, &rel, res); return alloc(external_relation, get_plugin(), get_signature(), res); } @@ -140,8 +140,8 @@ namespace datalog { family_id fid = get_family_id(); expr_ref e(m.mk_fresh_const("T", r_sort), m); expr* args[1] = { e.get() }; - func_decl_ref empty_decl(m.mk_func_decl(fid, OP_RA_EMPTY, 1, ¶m, 0, (sort*const*)0), m); - reduce_assign(empty_decl, 0, 0, 1, args); + func_decl_ref empty_decl(m.mk_func_decl(fid, OP_RA_EMPTY, 1, ¶m, 0, (sort*const*)nullptr), m); + reduce_assign(empty_decl, 0, nullptr, 1, args); return alloc(external_relation, *this, s, e); } @@ -207,7 +207,7 @@ namespace datalog { relation_join_fn * external_relation_plugin::mk_join_fn(const relation_base & r1, const relation_base & r2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if (!check_kind(r1) || !check_kind(r2)) { - return 0; + return nullptr; } return alloc(join_fn, *this, r1.get_signature(), r2.get_signature() , col_cnt, cols1, cols2); } @@ -277,7 +277,7 @@ namespace datalog { relation_transformer_fn * external_relation_plugin::mk_rename_fn(const relation_base & r, unsigned cycle_len, const unsigned * permutation_cycle) { if(!check_kind(r)) { - return 0; + return nullptr; } return alloc(rename_fn, *this, get(r).get_sort(), r.get_signature(), cycle_len, permutation_cycle); } @@ -295,7 +295,7 @@ namespace datalog { m_union_fn(p.get_ast_manager()) { ast_manager& m = p.get_ast_manager(); sort* domain[2] = { relation_sort, relation_sort }; - m_union_fn = m.mk_func_decl(p.get_family_id(), k, 0, 0, 2, domain); + m_union_fn = m.mk_func_decl(p.get_family_id(), k, 0, nullptr, 2, domain); } void operator()(relation_base & r, const relation_base & src, relation_base * delta) override { @@ -316,7 +316,7 @@ namespace datalog { relation_union_fn * external_relation_plugin::mk_union_fn(const relation_base & tgt, const relation_base & src, const relation_base * delta) { if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; + return nullptr; } return alloc(union_fn, *this, OP_RA_UNION, get(src).get_sort()); } @@ -324,7 +324,7 @@ namespace datalog { relation_union_fn * external_relation_plugin::mk_widen_fn(const relation_base & tgt, const relation_base & src, const relation_base * delta) { if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; + return nullptr; } return alloc(union_fn, *this, OP_RA_WIDEN, get(src).get_sort()); } @@ -351,7 +351,7 @@ namespace datalog { relation_mutator_fn * external_relation_plugin::mk_filter_interpreted_fn(const relation_base & r, app * condition) { if(!check_kind(r)) { - return 0; + return nullptr; } return alloc(filter_interpreted_fn, *this, get(r).get_sort(), condition); } @@ -359,7 +359,7 @@ namespace datalog { relation_mutator_fn * external_relation_plugin::mk_filter_equal_fn(const relation_base & r, const relation_element & value, unsigned col) { if(!check_kind(r)) { - return 0; + return nullptr; } ast_manager& m = get_ast_manager(); app_ref condition(m); @@ -407,7 +407,7 @@ namespace datalog { relation_mutator_fn * external_relation_plugin::mk_filter_identical_fn(const relation_base & r, unsigned col_cnt, const unsigned * identical_cols) { if (!check_kind(r)) { - return 0; + return nullptr; } return alloc(filter_identical_fn, *this, get(r).get_sort(), col_cnt, identical_cols); } @@ -447,7 +447,7 @@ namespace datalog { const relation_base & negated_obj, unsigned joined_col_cnt, const unsigned * t_cols, const unsigned * negated_cols) { if (!check_kind(t) || !check_kind(negated_obj)) { - return 0; + return nullptr; } return alloc(negation_filter_fn, *this, t, negated_obj, joined_col_cnt, t_cols, negated_cols); } diff --git a/src/muz/rel/dl_finite_product_relation.cpp b/src/muz/rel/dl_finite_product_relation.cpp index 4cb683df1..030fc1327 100644 --- a/src/muz/rel/dl_finite_product_relation.cpp +++ b/src/muz/rel/dl_finite_product_relation.cpp @@ -245,14 +245,14 @@ namespace datalog { } finite_product_relation * finite_product_relation_plugin::mk_from_table_relation(const table_relation & r) { - func_decl* pred = 0; + func_decl* pred = nullptr; const relation_signature & sig = r.get_signature(); const table_base & t = r.get_table(); table_plugin & tplugin = r.get_table().get_plugin(); relation_signature inner_sig; //empty signature for the inner relation if(!get_inner_plugin().can_handle_signature(inner_sig)) { - return 0; + return nullptr; } table_signature idx_singleton_sig; @@ -270,7 +270,7 @@ namespace datalog { idx_singleton_fact.push_back(0); idx_singleton->add_fact(idx_singleton_fact); - scoped_ptr join_fun = get_manager().mk_join_fn(t, *idx_singleton, 0, 0, 0); + scoped_ptr join_fun = get_manager().mk_join_fn(t, *idx_singleton, 0, nullptr, nullptr); SASSERT(join_fun); scoped_rel res_table = (*join_fun)(t, *idx_singleton); @@ -513,7 +513,7 @@ namespace datalog { return alloc(converting_join_fn, *this, rb1.get_signature(), rb2.get_signature(), col_cnt, cols1, cols2); } - return 0; + return nullptr; } const finite_product_relation & r1 = get(rb1); const finite_product_relation & r2 = get(rb2); @@ -590,7 +590,7 @@ namespace datalog { unsigned orig_rel_cnt = r.m_others.size(); for(unsigned i=0; iclone() : 0); + res_relations.push_back(orig_rel ? orig_rel->clone() : nullptr); } SASSERT(res_relations.size()==orig_rel_cnt); @@ -608,7 +608,7 @@ namespace datalog { res_table = (*tproject)(rtable); } - relation_plugin * res_oplugin = 0; + relation_plugin * res_oplugin = nullptr; if(!m_removed_rel_cols.empty()) { unsigned res_rel_cnt = res_relations.size(); @@ -651,7 +651,7 @@ namespace datalog { relation_transformer_fn * finite_product_relation_plugin::mk_project_fn(const relation_base & rb, unsigned col_cnt, const unsigned * removed_cols) { if(&rb.get_plugin()!=this) { - return 0; + return nullptr; } return alloc(project_fn, get(rb), col_cnt, removed_cols); } @@ -705,7 +705,7 @@ namespace datalog { unsigned orig_rel_cnt = r.m_others.size(); for(unsigned i=0; iclone() : 0); + res_relations.push_back(orig_rel ? orig_rel->clone() : nullptr); } if(!m_rel_identity) { @@ -746,7 +746,7 @@ namespace datalog { unsigned permutation_cycle_len, const unsigned * permutation_cycle) { if(&rb.get_plugin()!=this) { - return 0; + return nullptr; } const finite_product_relation & r = get(rb); return alloc(rename_fn, r, permutation_cycle_len, permutation_cycle); @@ -771,7 +771,7 @@ namespace datalog { relation_union_fn & get_inner_rel_union_op(relation_base & r) { if(!m_rel_union) { - m_rel_union = r.get_manager().mk_union_fn(r, r, m_use_delta ? &r : 0); + m_rel_union = r.get_manager().mk_union_fn(r, r, m_use_delta ? &r : nullptr); } return *m_rel_union; } @@ -1104,19 +1104,19 @@ namespace datalog { relation_union_fn * finite_product_relation_plugin::mk_union_fn(const relation_base & tgtb, const relation_base & srcb, const relation_base * deltab) { if(&srcb.get_plugin()!=this) { - return 0; + return nullptr; } const finite_product_relation & src = get(srcb); if(&tgtb.get_plugin()!=this || (deltab && &deltab->get_plugin()!=this) ) { if(can_convert_to_table_relation(src)) { return alloc(converting_union_fn); } - return 0; + return nullptr; } const finite_product_relation * delta = get(deltab); - return alloc(union_fn, get(tgtb), delta!=0); + return alloc(union_fn, get(tgtb), delta!=nullptr); } @@ -1131,7 +1131,7 @@ namespace datalog { scoped_ptr m_tr_filter; public: filter_identical_fn(const finite_product_relation & r, unsigned col_cnt, const unsigned * identical_cols) - : m_table_filter(0), m_rel_filter(0), m_tr_filter(0) { + : m_table_filter(nullptr), m_rel_filter(nullptr), m_tr_filter(nullptr) { finite_product_relation_plugin & plugin = r.get_plugin(); for(unsigned i=0; i complement_table = m_table->complement(p, &full_rel_idx); - scoped_ptr u_fn = get_manager().mk_union_fn(*m_table, *complement_table, 0); + scoped_ptr u_fn = get_manager().mk_union_fn(*m_table, *complement_table, nullptr); SASSERT(u_fn); - (*u_fn)(*m_table, *complement_table, 0); + (*u_fn)(*m_table, *complement_table, nullptr); } finite_product_relation * finite_product_relation::complement(func_decl* p) const { diff --git a/src/muz/rel/dl_instruction.cpp b/src/muz/rel/dl_instruction.cpp index d82f42b19..f7d1665d2 100644 --- a/src/muz/rel/dl_instruction.cpp +++ b/src/muz/rel/dl_instruction.cpp @@ -36,7 +36,7 @@ namespace datalog { execution_context::execution_context(context & context) : m_context(context), - m_stopwatch(0), + m_stopwatch(nullptr), m_timelimit_ms(0) {} execution_context::~execution_context() { @@ -271,10 +271,10 @@ namespace datalog { bool perform(execution_context & ctx) override { if (ctx.reg(m_src)) log_verbose(ctx); if (m_clone) { - ctx.set_reg(m_tgt, ctx.reg(m_src) ? ctx.reg(m_src)->clone() : 0); + ctx.set_reg(m_tgt, ctx.reg(m_src) ? ctx.reg(m_src)->clone() : nullptr); } else { - ctx.set_reg(m_tgt, ctx.reg(m_src) ? ctx.release_reg(m_src) : 0); + ctx.set_reg(m_tgt, ctx.reg(m_src) ? ctx.release_reg(m_src) : nullptr); } return true; } @@ -662,7 +662,7 @@ namespace datalog { relation_base * new_delta = r_tgt.get_plugin().mk_empty(r_tgt); ctx.set_reg(m_delta, new_delta); } - relation_base * r_delta = (m_delta!=execution_context::void_register) ? ctx.reg(m_delta) : 0; + relation_base * r_delta = (m_delta!=execution_context::void_register) ? ctx.reg(m_delta) : nullptr; relation_union_fn * fn; @@ -687,10 +687,10 @@ namespace datalog { else { if (!find_fn(r_tgt, r_src, fn)) { if (m_widen) { - fn = r_src.get_manager().mk_widen_fn(r_tgt, r_src, 0); + fn = r_src.get_manager().mk_widen_fn(r_tgt, r_src, nullptr); } else { - fn = r_src.get_manager().mk_union_fn(r_tgt, r_src, 0); + fn = r_src.get_manager().mk_union_fn(r_tgt, r_src, nullptr); } if (!fn) { std::stringstream sstm; @@ -1135,7 +1135,7 @@ namespace datalog { dealloc(*it); } m_data.reset(); - m_observer = 0; + m_observer = nullptr; } bool instruction_block::perform(execution_context & ctx) const { diff --git a/src/muz/rel/dl_instruction.h b/src/muz/rel/dl_instruction.h index d2e1c30f5..6e0b7bfe5 100644 --- a/src/muz/rel/dl_instruction.h +++ b/src/muz/rel/dl_instruction.h @@ -107,7 +107,7 @@ namespace datalog { */ reg_type reg(reg_idx i) const { if (i >= m_registers.size()) { - return 0; + return nullptr; } return m_registers[i]; } @@ -138,7 +138,7 @@ namespace datalog { void make_empty(reg_idx i) { if (reg(i)) { - set_reg(i, 0); + set_reg(i, nullptr); } } @@ -326,7 +326,7 @@ namespace datalog { instr_seq_type m_data; instruction_observer* m_observer; public: - instruction_block() : m_observer(0) {} + instruction_block() : m_observer(nullptr) {} ~instruction_block(); void reset(); diff --git a/src/muz/rel/dl_interval_relation.cpp b/src/muz/rel/dl_interval_relation.cpp index 12b6815cc..75f9e7e42 100644 --- a/src/muz/rel/dl_interval_relation.cpp +++ b/src/muz/rel/dl_interval_relation.cpp @@ -63,7 +63,7 @@ namespace datalog { interval_relation const& r1 = get(_r1); interval_relation const& r2 = get(_r2); interval_relation_plugin& p = r1.get_plugin(); - interval_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); + interval_relation* result = dynamic_cast(p.mk_full(nullptr, get_result_signature())); result->mk_join(r1, r2, m_cols1.size(), m_cols1.c_ptr(), m_cols2.c_ptr()); return result; } @@ -72,7 +72,7 @@ namespace datalog { relation_join_fn * interval_relation_plugin::mk_join_fn(const relation_base & r1, const relation_base & r2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if (!check_kind(r1) || !check_kind(r2)) { - return 0; + return nullptr; } return alloc(join_fn, r1.get_signature(), r2.get_signature(), col_cnt, cols1, cols2); } @@ -87,7 +87,7 @@ namespace datalog { relation_base * operator()(const relation_base & _r) override { interval_relation const& r = get(_r); interval_relation_plugin& p = r.get_plugin(); - interval_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); + interval_relation* result = dynamic_cast(p.mk_full(nullptr, get_result_signature())); result->mk_project(r, m_removed_cols.size(), m_removed_cols.c_ptr()); return result; } @@ -107,7 +107,7 @@ namespace datalog { relation_base * operator()(const relation_base & _r) override { interval_relation const& r = get(_r); interval_relation_plugin& p = r.get_plugin(); - interval_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); + interval_relation* result = dynamic_cast(p.mk_full(nullptr, get_result_signature())); result->mk_rename(r, m_cycle.size(), m_cycle.c_ptr()); return result; } @@ -116,7 +116,7 @@ namespace datalog { relation_transformer_fn * interval_relation_plugin::mk_rename_fn(const relation_base & r, unsigned cycle_len, const unsigned * permutation_cycle) { if(!check_kind(r)) { - return 0; + return nullptr; } return alloc(rename_fn, r.get_signature(), cycle_len, permutation_cycle); } @@ -134,7 +134,7 @@ namespace datalog { high = src2.sup(); r_open = src2.is_upper_open(); } - return interval(dep(), low, l_open, 0, high, r_open, 0); + return interval(dep(), low, l_open, nullptr, high, r_open, nullptr); } interval interval_relation_plugin::widen(interval const& src1, interval const& src2) { @@ -151,7 +151,7 @@ namespace datalog { high = ext_numeral(true); r_open = true; } - return interval(dep(), low, l_open, 0, high, r_open, 0); + return interval(dep(), low, l_open, nullptr, high, r_open, nullptr); } interval interval_relation_plugin::meet(interval const& src1, interval const& src2, bool& isempty) { @@ -179,7 +179,7 @@ namespace datalog { return interval(dep()); } else { - return interval(dep(), low, l_open, 0, high, r_open, 0); + return interval(dep(), low, l_open, nullptr, high, r_open, nullptr); } } @@ -209,7 +209,7 @@ namespace datalog { r.mk_union(src, &d, m_is_widen); } else { - r.mk_union(src, 0, m_is_widen); + r.mk_union(src, nullptr, m_is_widen); } } }; @@ -217,7 +217,7 @@ namespace datalog { relation_union_fn * interval_relation_plugin::mk_union_fn(const relation_base & tgt, const relation_base & src, const relation_base * delta) { if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; + return nullptr; } return alloc(union_fn, false); } @@ -226,7 +226,7 @@ namespace datalog { const relation_base & tgt, const relation_base & src, const relation_base * delta) { if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; + return nullptr; } return alloc(union_fn, true); } @@ -250,7 +250,7 @@ namespace datalog { relation_mutator_fn * interval_relation_plugin::mk_filter_identical_fn( const relation_base & t, unsigned col_cnt, const unsigned * identical_cols) { if(!check_kind(t)) { - return 0; + return nullptr; } return alloc(filter_identical_fn, col_cnt, identical_cols); } @@ -279,7 +279,7 @@ namespace datalog { if(check_kind(r)) { return alloc(filter_equal_fn, get_manager(), value, col); } - return 0; + return nullptr; } @@ -300,7 +300,7 @@ namespace datalog { if (check_kind(t)) { return alloc(filter_interpreted_fn, get(t), condition); } - return 0; + return nullptr; } interval_relation& interval_relation_plugin::get(relation_base& r) { @@ -329,7 +329,7 @@ namespace datalog { eq = m.mk_eq(m.mk_var(i, m.get_sort(e)), e); r.filter_interpreted(eq.get()); } - mk_union(r, 0, false); + mk_union(r, nullptr, false); } bool interval_relation::contains_fact(const relation_fact & f) const { @@ -365,7 +365,7 @@ namespace datalog { interval_relation * interval_relation::complement(func_decl*) const { UNREACHABLE(); - return 0; + return nullptr; } void interval_relation::to_formula(expr_ref& fml) const { @@ -434,22 +434,22 @@ namespace datalog { // 0 < x - y + k if (x == UINT_MAX) { // y < k - mk_intersect(y, interval(p.dep(), k, true, false, 0)); + mk_intersect(y, interval(p.dep(), k, true, false, nullptr)); return; } if (y == UINT_MAX) { // -k < x - mk_intersect(x, interval(p.dep(), -k, true, true, 0)); + mk_intersect(x, interval(p.dep(), -k, true, true, nullptr)); return; } // y < x + k ext_numeral x_hi = (*this)[x].sup(); ext_numeral y_lo = (*this)[y].inf(); if (!x_hi.is_infinite()) { - mk_intersect(y, interval(p.dep(), k + x_hi.to_rational(), true, false, 0)); + mk_intersect(y, interval(p.dep(), k + x_hi.to_rational(), true, false, nullptr)); } if (!y_lo.is_infinite()) { - mk_intersect(x, interval(p.dep(), y_lo.to_rational() - k, true, true, 0)); + mk_intersect(x, interval(p.dep(), y_lo.to_rational() - k, true, true, nullptr)); } return; } @@ -458,21 +458,21 @@ namespace datalog { // 0 <= x - y + k if (x == UINT_MAX) { // y <= k - mk_intersect(y, interval(p.dep(), k, false, false, 0)); + mk_intersect(y, interval(p.dep(), k, false, false, nullptr)); return; } if (y == UINT_MAX) { // -k <= x - mk_intersect(x, interval(p.dep(), -k, false, true, 0)); + mk_intersect(x, interval(p.dep(), -k, false, true, nullptr)); return; } ext_numeral x_hi = (*this)[x].sup(); ext_numeral y_lo = (*this)[y].inf(); if (!x_hi.is_infinite()) { - mk_intersect(y, interval(p.dep(), k + x_hi.to_rational(), false, false, 0)); + mk_intersect(y, interval(p.dep(), k + x_hi.to_rational(), false, false, nullptr)); } if (!y_lo.is_infinite()) { - mk_intersect(x, interval(p.dep(), y_lo.to_rational() - k, false, true, 0)); + mk_intersect(x, interval(p.dep(), y_lo.to_rational() - k, false, true, nullptr)); } return; } diff --git a/src/muz/rel/dl_lazy_table.cpp b/src/muz/rel/dl_lazy_table.cpp index 1b8681ab0..53d099532 100644 --- a/src/muz/rel/dl_lazy_table.cpp +++ b/src/muz/rel/dl_lazy_table.cpp @@ -65,7 +65,7 @@ namespace datalog { return alloc(join_fn, t1.get_signature(), t2.get_signature(), col_cnt, cols1, cols2); } else { - return 0; + return nullptr; } } @@ -81,7 +81,7 @@ namespace datalog { lazy_table* delta = get(_delta); table_base const* t_src = src.eval(); table_base * t_tgt = tgt.eval(); - table_base * t_delta = delta?delta->eval():0; + table_base * t_delta = delta?delta->eval():nullptr; verbose_action _t("union"); table_union_fn* m = tgt.get_lplugin().get_manager().mk_union_fn(*t_tgt, *t_src, t_delta); SASSERT(m); @@ -98,7 +98,7 @@ namespace datalog { return alloc(union_fn); } else { - return 0; + return nullptr; } } @@ -124,7 +124,7 @@ namespace datalog { return alloc(project_fn, t.get_signature(), col_cnt, removed_cols); } else { - return 0; + return nullptr; } } @@ -150,7 +150,7 @@ namespace datalog { return alloc(rename_fn, t.get_signature(), col_cnt, removed_cols); } else { - return 0; + return nullptr; } } @@ -175,7 +175,7 @@ namespace datalog { return alloc(filter_identical_fn, col_cnt, identical_cols); } else { - return 0; + return nullptr; } } @@ -201,7 +201,7 @@ namespace datalog { return alloc(filter_interpreted_fn, cond); } else { - return 0; + return nullptr; } } @@ -229,7 +229,7 @@ namespace datalog { return alloc(filter_by_negation_fn, joined_col_cnt, t_cols, negated_cols); } else { - return 0; + return nullptr; } } @@ -258,7 +258,7 @@ namespace datalog { return alloc(filter_equal_fn, value, col); } else { - return 0; + return nullptr; } } @@ -269,7 +269,7 @@ namespace datalog { return alloc(lazy_table_plugin, *sp); } else { - return 0; + return nullptr; } } @@ -397,7 +397,7 @@ namespace datalog { SASSERT(!m_table); m_table = m_src->eval(); m_src->release_table(); - m_src = 0; + m_src = nullptr; verbose_action _t("filter_identical"); table_mutator_fn* m = rm().mk_filter_identical_fn(*m_table, m_cols.size(), m_cols.c_ptr()); SASSERT(m); @@ -410,7 +410,7 @@ namespace datalog { SASSERT(!m_table); m_table = m_src->eval(); m_src->release_table(); - m_src = 0; + m_src = nullptr; verbose_action _t("filter_equal"); table_mutator_fn* m = rm().mk_filter_equal_fn(*m_table, m_value, m_col); SASSERT(m); @@ -423,7 +423,7 @@ namespace datalog { SASSERT(!m_table); m_table = m_src->eval(); m_src->release_table(); - m_src = 0; + m_src = nullptr; verbose_action _t("filter_interpreted"); table_mutator_fn* m = rm().mk_filter_interpreted_fn(*m_table, m_condition); SASSERT(m); @@ -436,7 +436,7 @@ namespace datalog { SASSERT(!m_table); m_table = m_tgt->eval(); m_tgt->release_table(); - m_tgt = 0; + m_tgt = nullptr; switch(m_src->kind()) { diff --git a/src/muz/rel/dl_lazy_table.h b/src/muz/rel/dl_lazy_table.h index 19ea6773e..7e5991a7a 100644 --- a/src/muz/rel/dl_lazy_table.h +++ b/src/muz/rel/dl_lazy_table.h @@ -136,7 +136,7 @@ namespace datalog { } table_base * clone() const override; - table_base * complement(func_decl* p, const table_element * func_columns = 0) const override; + table_base * complement(func_decl* p, const table_element * func_columns = nullptr) const override; bool empty() const override; bool contains_fact(const table_fact & f) const override; void remove_fact(table_element const* fact) override; diff --git a/src/muz/rel/dl_mk_explanations.cpp b/src/muz/rel/dl_mk_explanations.cpp index 4823ffb9b..1a1a47f74 100644 --- a/src/muz/rel/dl_mk_explanations.cpp +++ b/src/muz/rel/dl_mk_explanations.cpp @@ -189,7 +189,7 @@ namespace datalog { } bool is_undefined(unsigned col_idx) const { - return m_data[col_idx]==0; + return m_data[col_idx]==nullptr; } bool no_undefined() const { if (empty()) { @@ -296,7 +296,7 @@ namespace datalog { class explanation_relation_plugin::join_fn : public convenient_relation_join_fn { public: join_fn(const relation_signature & sig1, const relation_signature & sig2) - : convenient_relation_join_fn(sig1, sig2, 0, 0, 0) {} + : convenient_relation_join_fn(sig1, sig2, 0, nullptr, nullptr) {} relation_base * operator()(const relation_base & r1_0, const relation_base & r2_0) override { const explanation_relation & r1 = static_cast(r1_0); @@ -317,10 +317,10 @@ namespace datalog { relation_join_fn * explanation_relation_plugin::mk_join_fn(const relation_base & r1, const relation_base & r2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if (&r1.get_plugin()!=this || &r2.get_plugin()!=this) { - return 0; + return nullptr; } if (col_cnt!=0) { - return 0; + return nullptr; } return alloc(join_fn, r1.get_signature(), r2.get_signature()); } @@ -348,7 +348,7 @@ namespace datalog { relation_transformer_fn * explanation_relation_plugin::mk_project_fn(const relation_base & r, unsigned col_cnt, const unsigned * removed_cols) { if (&r.get_plugin()!=this) { - return 0; + return nullptr; } return alloc(project_fn, r.get_signature(), col_cnt, removed_cols); } @@ -385,7 +385,7 @@ namespace datalog { void operator()(relation_base & tgt0, const relation_base & src0, relation_base * delta0) override { explanation_relation & tgt = static_cast(tgt0); const explanation_relation & src = static_cast(src0); - explanation_relation * delta = delta0 ? static_cast(delta0) : 0; + explanation_relation * delta = delta0 ? static_cast(delta0) : nullptr; explanation_relation_plugin & plugin = tgt.get_plugin(); if (!src.no_undefined() || !tgt.no_undefined() || (delta && !delta->no_undefined())) { @@ -420,7 +420,7 @@ namespace datalog { public: void operator()(relation_base & tgt0, const relation_base & src, relation_base * delta0) override { explanation_relation & tgt = static_cast(tgt0); - explanation_relation * delta = delta0 ? static_cast(delta0) : 0; + explanation_relation * delta = delta0 ? static_cast(delta0) : nullptr; if (src.empty()) { return; @@ -435,7 +435,7 @@ namespace datalog { relation_union_fn * explanation_relation_plugin::mk_union_fn(const relation_base & tgt, const relation_base & src, const relation_base * delta) { if (!check_kind(tgt) || (delta && !check_kind(*delta))) { - return 0; + return nullptr; } if (!check_kind(src)) { //this is to handle the product relation @@ -480,11 +480,11 @@ namespace datalog { relation_mutator_fn * explanation_relation_plugin::mk_filter_interpreted_fn(const relation_base & r, app * cond) { if (&r.get_plugin()!=this) { - return 0; + return nullptr; } ast_manager & m = get_ast_manager(); if (!m.is_eq(cond)) { - return 0; + return nullptr; } expr * arg1 = cond->get_arg(0); expr * arg2 = cond->get_arg(1); @@ -494,12 +494,12 @@ namespace datalog { } if (!is_var(arg1) || !is_app(arg2)) { - return 0; + return nullptr; } var * col_var = to_var(arg1); app * new_rule = to_app(arg2); if (!get_context().get_decl_util().is_rule_sort(col_var->get_sort())) { - return 0; + return nullptr; } unsigned col_idx = col_var->get_idx(); @@ -520,7 +520,7 @@ namespace datalog { const relation_base & neg, unsigned joined_col_cnt, const unsigned * t_cols, const unsigned * negated_cols) { if (&r.get_plugin()!=this || &neg.get_plugin()!=this) { - return 0; + return nullptr; } return alloc(negation_filter_fn); } @@ -569,18 +569,18 @@ namespace datalog { const relation_base & tgt, const relation_base & src, unsigned joined_col_cnt, const unsigned * tgt_cols, const unsigned * src_cols) { if (&tgt.get_plugin()!=this || &src.get_plugin()!=this) { - return 0; + return nullptr; } //this checks the join is one to one on all columns if (tgt.get_signature()!=src.get_signature() || joined_col_cnt!=tgt.get_signature().size() || !containers_equal(tgt_cols, tgt_cols+joined_col_cnt, src_cols, src_cols+joined_col_cnt)) { - return 0; + return nullptr; } counter ctr; ctr.count(joined_col_cnt, tgt_cols); if (ctr.get_max_counter_value()>1 || (joined_col_cnt && ctr.get_max_positive()!=joined_col_cnt-1)) { - return 0; + return nullptr; } return alloc(intersection_filter_fn, *this); } @@ -776,7 +776,7 @@ namespace datalog { app_ref orig_lit(m_manager.mk_app(orig_decl, lit_args.c_ptr()), m_manager); app_ref e_lit(get_e_lit(orig_lit, arity), m_manager); app * tail[] = { e_lit.get() }; - dst.add_rule(m_context.get_rule_manager().mk(orig_lit, 1, tail, 0)); + dst.add_rule(m_context.get_rule_manager().mk(orig_lit, 1, tail, nullptr)); } } @@ -852,7 +852,7 @@ namespace datalog { translate_rel_level_relation(rmgr, orig_rel, e_rel); } else { - scoped_ptr product_fun = rmgr.mk_join_fn(orig_rel, *m_e_fact_relation, 0, 0, 0); + scoped_ptr product_fun = rmgr.mk_join_fn(orig_rel, *m_e_fact_relation, 0, nullptr, nullptr); SASSERT(product_fun); scoped_rel aux_extended_rel = (*product_fun)(orig_rel, *m_e_fact_relation); TRACE("dl", tout << aux_extended_rel << " " << aux_extended_rel->get_plugin().get_name() << "\n"; @@ -868,10 +868,10 @@ namespace datalog { rule_set * mk_explanations::operator()(rule_set const & source) { if (source.empty()) { - return 0; + return nullptr; } if (!m_context.generate_explanations()) { - return 0; + return nullptr; } rule_set * res = alloc(rule_set, m_context); transform_facts(m_context.get_rel_context()->get_rmanager(), source, *res); diff --git a/src/muz/rel/dl_mk_similarity_compressor.cpp b/src/muz/rel/dl_mk_similarity_compressor.cpp index c4abf326a..c6063772a 100644 --- a/src/muz/rel/dl_mk_similarity_compressor.cpp +++ b/src/muz/rel/dl_mk_similarity_compressor.cpp @@ -531,7 +531,7 @@ namespace datalog { } } - rule_set * result = static_cast(0); + rule_set * result = static_cast(nullptr); if (m_modified) { result = alloc(rule_set, m_context); unsigned fin_rule_cnt = m_result_rules.size(); diff --git a/src/muz/rel/dl_mk_simple_joins.cpp b/src/muz/rel/dl_mk_simple_joins.cpp index 60eea2e53..ac3d30e9e 100644 --- a/src/muz/rel/dl_mk_simple_joins.cpp +++ b/src/muz/rel/dl_mk_simple_joins.cpp @@ -165,7 +165,7 @@ namespace datalog { SASSERT(is_var(t->get_arg(i))); var * v = to_var(t->get_arg(i)); unsigned var_idx = v->get_idx(); - if (result[res_ofs-var_idx]==0) { + if (result[res_ofs-var_idx]==nullptr) { result[res_ofs-var_idx]=m.mk_var(next_var, v->get_sort()); next_var++; } @@ -235,7 +235,7 @@ namespace datalog { //so the order should not matter } - result.resize(max_var_idx+1, static_cast(0)); + result.resize(max_var_idx+1, static_cast(nullptr)); unsigned next_var = 0; get_normalizer(t1, next_var, result); get_normalizer(t2, next_var, result); @@ -268,9 +268,9 @@ namespace datalog { */ void register_pair(app * t1, app * t2, rule * r, const var_idx_set & non_local_vars) { SASSERT(t1!=t2); - cost_map::entry * e = m_costs.insert_if_not_there2(get_key(t1, t2), 0); + cost_map::entry * e = m_costs.insert_if_not_there2(get_key(t1, t2), nullptr); pair_info * & ptr_inf = e->get_data().m_value; - if (ptr_inf==0) { + if (ptr_inf==nullptr) { ptr_inf = alloc(pair_info); } pair_info & inf = *ptr_inf; @@ -297,7 +297,7 @@ namespace datalog { } void remove_rule_from_pair(app_pair key, rule * r, unsigned original_len) { - pair_info * ptr = 0; + pair_info * ptr = nullptr; if (m_costs.find(key, ptr) && ptr && ptr->remove_rule(r, original_len)) { SASSERT(ptr->m_rules.empty()); @@ -354,7 +354,7 @@ namespace datalog { void join_pair(app_pair pair_key) { app * t1 = pair_key.first; app * t2 = pair_key.second; - pair_info* infp = 0; + pair_info* infp = nullptr; if (!m_costs.find(pair_key, infp) || !infp) { UNREACHABLE(); return; @@ -402,7 +402,7 @@ namespace datalog { app * tail[] = {t1, t2}; - rule * new_rule = m_context.get_rule_manager().mk(head, 2, tail, 0); + rule * new_rule = m_context.get_rule_manager().mk(head, 2, tail, nullptr); //TODO: update accounting so that it can handle multiple parents new_rule->set_accounting_parent_object(m_context, one_parent); @@ -702,7 +702,7 @@ namespace datalog { } if (!m_modified_rules) { - return 0; + return nullptr; } rule_set * result = alloc(rule_set, m_context); rule_pred_map::iterator rcit = m_rules_content.begin(); diff --git a/src/muz/rel/dl_product_relation.cpp b/src/muz/rel/dl_product_relation.cpp index 56fd56505..c591b7186 100644 --- a/src/muz/rel/dl_product_relation.cpp +++ b/src/muz/rel/dl_product_relation.cpp @@ -261,7 +261,7 @@ namespace datalog { void init(relation_signature const& r1_sig, unsigned num_rels1, relation_base const* const* r1, relation_signature const& r2_sig, unsigned num_rels2, relation_base const* const* r2, unsigned col_cnt, unsigned const* cols1, unsigned const* cols2) { - func_decl* p = 0; + func_decl* p = nullptr; bit_vector bv; bv.resize(num_rels2); relation_manager& rmgr = m_plugin.get_manager(); @@ -453,7 +453,7 @@ namespace datalog { TRACE("dl", _r1.display(tout); _r2.display(tout);); ptr_vector relations; unsigned sz = m_joins.size(); - relation_base* result = 0; + relation_base* result = nullptr; for (unsigned i = 0; i < sz; ++i) { relation_base const& r1 = (m_kind1[i] == T_FULL)?(*m_full[m_offset1[i]]):access(m_offset1[i], _r1); relation_base const& r2 = (m_kind2[i] == T_FULL)?(*m_full[m_offset2[i]]):access(m_offset2[i], _r2); @@ -479,7 +479,7 @@ namespace datalog { if (r1.get_kind() != r2.get_kind()) { return alloc(join_fn, *this, r1, r2, col_cnt, cols1, cols2); } - return 0; + return nullptr; } @@ -519,7 +519,7 @@ namespace datalog { relation_signature::from_project(r.get_signature(), col_cnt, removed_cols, s); return alloc(transform_fn, s, projs.size(), projs.c_ptr()); } - return 0; + return nullptr; } relation_transformer_fn * product_relation_plugin::mk_rename_fn(const relation_base & _r, @@ -534,7 +534,7 @@ namespace datalog { relation_signature::from_rename(r.get_signature(), cycle_len, permutation_cycle, s); return alloc(transform_fn, s, trans.size(), trans.c_ptr()); } - return 0; + return nullptr; } class product_relation_plugin::aligned_union_fn : public relation_union_fn { @@ -549,7 +549,7 @@ namespace datalog { void mk_union_fn(unsigned i, unsigned j, relation_base const& r1, relation_base const& r2, const relation_base* delta) { relation_manager& rmgr = r1.get_manager(); - relation_union_fn* u = 0; + relation_union_fn* u = nullptr; if (m_is_widen) { u = rmgr.mk_widen_fn(r1, r2, delta); } @@ -596,7 +596,7 @@ namespace datalog { return; } do_intersection(*tgt, *src); - src = 0; + src = nullptr; } void do_intersection(relation_base& tgt, relation_base& src) { @@ -625,7 +625,7 @@ namespace datalog { m_is_widen(is_widen) { SASSERT(vectors_equal(tgt.m_spec, src.m_spec)); SASSERT(!delta || vectors_equal(tgt.m_spec, delta->m_spec)); - init(tgt.m_relations, src.m_relations, delta ? &delta->m_relations : 0); + init(tgt.m_relations, src.m_relations, delta ? &delta->m_relations : nullptr); } ~aligned_union_fn() override { @@ -650,9 +650,9 @@ namespace datalog { for (unsigned i = 0; i < num; ++i) { relation_base& itgt = tgt[i]; - relation_base* idelta = delta ? &(*delta)[i] : 0; + relation_base* idelta = delta ? &(*delta)[i] : nullptr; - scoped_rel fresh_delta = idelta ? idelta->get_plugin().mk_empty(*idelta) : 0; + scoped_rel fresh_delta = idelta ? idelta->get_plugin().mk_empty(*idelta) : nullptr; scoped_rel side_result; scoped_rel side_delta; @@ -665,7 +665,7 @@ namespace datalog { TRACE("dl", itgt.display(tout << "tgt:\n"); src[j].display(tout << "src:\n");); // union[i][j] scoped_rel one_side_union = itgt.clone(); - scoped_rel one_side_delta = fresh_delta ? fresh_delta->clone() : 0; + scoped_rel one_side_delta = fresh_delta ? fresh_delta->clone() : nullptr; TRACE("dl", one_side_union->display(tout << "union 1:\n"); src[j].display(tout);); do_inner_union(i, j, *one_side_union, src[j], one_side_delta.get()); TRACE("dl", one_side_union->display(tout << "union:\n");); @@ -679,7 +679,7 @@ namespace datalog { // union[j][i] one_side_union = src[i].clone(); - one_side_delta = fresh_delta ? fresh_delta->clone() : 0; + one_side_delta = fresh_delta ? fresh_delta->clone() : nullptr; TRACE("dl", one_side_union->display(tout << "union 2:\n"); tgt[j].display(tout);); do_inner_union(i, j, *one_side_union, tgt[j], one_side_delta.get()); TRACE("dl", one_side_union->display(tout << "union:\n");); @@ -697,8 +697,8 @@ namespace datalog { } for (unsigned i = 0; i < num; ++i) { relation_base& itgt = tgt[i]; - relation_base* idelta = delta ? &(*delta)[i] : 0; - scoped_rel fresh_delta = idelta ? idelta->get_plugin().mk_empty(*idelta) : 0; + relation_base* idelta = delta ? &(*delta)[i] : nullptr; + scoped_rel fresh_delta = idelta ? idelta->get_plugin().mk_empty(*idelta) : nullptr; scoped_rel side_result(side_results[i]); scoped_rel side_delta(side_deltas[i]); @@ -752,7 +752,7 @@ namespace datalog { TRACE("dl_verbose", _tgt.display(tout << "dst:\n"); _src.display(tout << "src:\n");); product_relation& tgt = get(_tgt); product_relation const& src0 = get(_src); - product_relation* delta = _delta ? get(_delta) : 0; + product_relation* delta = _delta ? get(_delta) : nullptr; tgt.convert_spec(m_common_spec); if(delta) { @@ -815,7 +815,7 @@ namespace datalog { } } } - return 0; + return nullptr; } relation_union_fn * product_relation_plugin::mk_union_fn(const relation_base & tgt, const relation_base & src, @@ -867,7 +867,7 @@ namespace datalog { return alloc(mutator_fn, mutators.size(), mutators.c_ptr()); } } - return 0; + return nullptr; } relation_mutator_fn * product_relation_plugin::mk_filter_equal_fn(const relation_base & _t, @@ -885,7 +885,7 @@ namespace datalog { return alloc(mutator_fn, mutators.size(), mutators.c_ptr()); } } - return 0; + return nullptr; } class product_relation_plugin::filter_interpreted_fn : public relation_mutator_fn { @@ -983,7 +983,7 @@ namespace datalog { void product_relation::convert_spec(const rel_spec & spec) { - func_decl* p = 0; + func_decl* p = nullptr; const relation_signature & sig = get_signature(); family_id new_kind = get_plugin().get_relation_kind(sig, spec); if (new_kind == get_kind()) { @@ -1008,7 +1008,7 @@ namespace datalog { //the loop is quadratic with the number of relations, maybe we want to fix it for(unsigned i=0; iget_kind()==ikind) { @@ -1096,7 +1096,7 @@ namespace datalog { return res; } UNREACHABLE(); - return 0; + return nullptr; } bool product_relation::empty() const { diff --git a/src/muz/rel/dl_relation_manager.cpp b/src/muz/rel/dl_relation_manager.cpp index 8226d0198..deb289277 100644 --- a/src/muz/rel/dl_relation_manager.cpp +++ b/src/muz/rel/dl_relation_manager.cpp @@ -47,8 +47,8 @@ namespace datalog { void relation_manager::reset() { reset_relations(); - m_favourite_table_plugin = static_cast(0); - m_favourite_relation_plugin = static_cast(0); + m_favourite_table_plugin = static_cast(nullptr); + m_favourite_relation_plugin = static_cast(nullptr); dealloc_ptr_vector_content(m_table_plugins); m_table_plugins.reset(); dealloc_ptr_vector_content(m_relation_plugins); @@ -95,9 +95,9 @@ namespace datalog { } relation_base * relation_manager::try_get_relation(func_decl * pred) const { - relation_base * res = 0; + relation_base * res = nullptr; if(!m_relations.find(pred, res)) { - return 0; + return nullptr; } SASSERT(res); return res; @@ -217,7 +217,7 @@ namespace datalog { return *rpit; } } - return 0; + return nullptr; } relation_plugin & relation_manager::get_appropriate_plugin(const relation_signature & s) { @@ -239,7 +239,7 @@ namespace datalog { return *tpit; } } - return 0; + return nullptr; } table_plugin & relation_manager::get_appropriate_plugin(const table_signature & t) { @@ -258,13 +258,13 @@ namespace datalog { return *rpit; } } - return 0; + return nullptr; } relation_plugin & relation_manager::get_relation_plugin(family_id kind) { SASSERT(kind>=0); SASSERT(kind aux = (*m_join)(t1, t2); @@ -851,21 +851,21 @@ namespace datalog { scoped_rel join_fun = mk_join_project_fn(tgt, src, joined_col_cnt, tgt_cols, src_cols, join_removed_cols.size(), join_removed_cols.c_ptr(), false); if(!join_fun) { - return 0; + return nullptr; } //we perform the join operation here to see what the result is scoped_rel join_res = (*join_fun)(tgt, src); if(tgt.can_swap(*join_res)) { - return alloc(default_relation_intersection_filter_fn, join_fun.release(), 0); + return alloc(default_relation_intersection_filter_fn, join_fun.release(), nullptr); } if(join_res->get_plugin().is_product_relation()) { //we cannot have the product relation here, since it uses the intersection operation //for unions and therefore we would get into an infinite recursion - return 0; + return nullptr; } scoped_rel union_fun = mk_union_fn(tgt, *join_res); if(!union_fun) { - return 0; + return nullptr; } return alloc(default_relation_intersection_filter_fn, join_fun.release(), union_fun.release()); } @@ -1357,11 +1357,11 @@ namespace datalog { static table_mutator_fn* mk(context& ctx, expr* condition) { ast_manager& m = ctx.get_manager(); if (!m.is_not(condition)) { - return 0; + return nullptr; } condition = to_app(condition)->get_arg(0); if (!m.is_eq(condition)) { - return 0; + return nullptr; } expr* x = to_app(condition)->get_arg(0); expr* y = to_app(condition)->get_arg(1); @@ -1369,12 +1369,12 @@ namespace datalog { std::swap(x, y); } if (!is_var(x)) { - return 0; + return nullptr; } dl_decl_util decl_util(m); uint64 value = 0; if (!decl_util.is_numeral_ext(y, value)) { - return 0; + return nullptr; } return alloc(default_table_filter_not_equal_fn, ctx, to_var(x)->get_idx(), value); } @@ -1410,7 +1410,7 @@ namespace datalog { unsigned col_cnt = f.size(); for(int i=col_cnt-1;i>=0;i--) { if(!m_free_vars.contains(i)) { - args.push_back(0); + args.push_back(nullptr); continue; //this variable does not occur in the condition; } @@ -1502,7 +1502,7 @@ namespace datalog { default_table_negation_filter_fn(const table_base & tgt, const table_base & neg_t, unsigned joined_col_cnt, const unsigned * t_cols, const unsigned * negated_cols) : convenient_table_negation_filter_fn(tgt, neg_t, joined_col_cnt, t_cols, negated_cols), - m_negated_table(0) { + m_negated_table(nullptr) { m_aux_fact.resize(neg_t.get_signature().size()); } @@ -1603,7 +1603,7 @@ namespace datalog { SASSERT(t.get_signature().functional_columns()>0); table_plugin & plugin = t.get_plugin(); m_aux_table = plugin.mk_empty(t.get_signature()); - m_union_fn = plugin.mk_union_fn(t, *m_aux_table, static_cast(0)); + m_union_fn = plugin.mk_union_fn(t, *m_aux_table, static_cast(nullptr)); } ~default_table_map_fn() override {} @@ -1625,7 +1625,7 @@ namespace datalog { } t.reset(); - (*m_union_fn)(t, *m_aux_table, static_cast(0)); + (*m_union_fn)(t, *m_aux_table, static_cast(nullptr)); } }; diff --git a/src/muz/rel/dl_relation_manager.h b/src/muz/rel/dl_relation_manager.h index 088b246e4..bd7b9ae8c 100644 --- a/src/muz/rel/dl_relation_manager.h +++ b/src/muz/rel/dl_relation_manager.h @@ -109,8 +109,8 @@ namespace datalog { public: relation_manager(context & ctx) : m_context(ctx), - m_favourite_table_plugin(0), - m_favourite_relation_plugin(0), + m_favourite_table_plugin(nullptr), + m_favourite_relation_plugin(nullptr), m_next_table_fid(0), m_next_relation_fid(0) {} @@ -331,7 +331,7 @@ namespace datalog { const relation_base * delta); relation_union_fn * mk_union_fn(const relation_base & tgt, const relation_base & src) { - return mk_union_fn(tgt, src, static_cast(0)); + return mk_union_fn(tgt, src, static_cast(nullptr)); } /** @@ -510,7 +510,7 @@ namespace datalog { const table_base * delta); table_union_fn * mk_union_fn(const table_base & tgt, const table_base & src) { - return mk_union_fn(tgt, src, static_cast(0)); + return mk_union_fn(tgt, src, static_cast(nullptr)); } /** diff --git a/src/muz/rel/dl_sieve_relation.cpp b/src/muz/rel/dl_sieve_relation.cpp index 401d519d5..a5ad20059 100644 --- a/src/muz/rel/dl_sieve_relation.cpp +++ b/src/muz/rel/dl_sieve_relation.cpp @@ -226,7 +226,7 @@ namespace datalog { relation_base * sieve_relation_plugin::mk_empty(const relation_signature & s) { UNREACHABLE(); - return 0; + return nullptr; #if 0 svector inner_cols(s.size()); extract_inner_columns(s, inner_cols.c_ptr()); @@ -278,8 +278,8 @@ namespace datalog { m_inner_join_fun(inner_join_fun) { bool r1_sieved = r1.get_plugin().is_sieve_relation(); bool r2_sieved = r2.get_plugin().is_sieve_relation(); - const sieve_relation * sr1 = r1_sieved ? static_cast(&r1) : 0; - const sieve_relation * sr2 = r2_sieved ? static_cast(&r2) : 0; + const sieve_relation * sr1 = r1_sieved ? static_cast(&r1) : nullptr; + const sieve_relation * sr2 = r2_sieved ? static_cast(&r2) : nullptr; if(r1_sieved) { m_result_inner_cols.append(sr1->m_inner_cols); } @@ -298,8 +298,8 @@ namespace datalog { bool r1_sieved = r1.get_plugin().is_sieve_relation(); bool r2_sieved = r2.get_plugin().is_sieve_relation(); SASSERT(r1_sieved || r2_sieved); - const sieve_relation * sr1 = r1_sieved ? static_cast(&r1) : 0; - const sieve_relation * sr2 = r2_sieved ? static_cast(&r2) : 0; + const sieve_relation * sr1 = r1_sieved ? static_cast(&r1) : nullptr; + const sieve_relation * sr2 = r2_sieved ? static_cast(&r2) : nullptr; const relation_base & inner1 = r1_sieved ? sr1->get_inner() : r1; const relation_base & inner2 = r2_sieved ? sr2->get_inner() : r2; @@ -313,12 +313,12 @@ namespace datalog { unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if( &r1.get_plugin()!=this && &r2.get_plugin()!=this ) { //we create just operations that involve the current plugin - return 0; + return nullptr; } bool r1_sieved = r1.get_plugin().is_sieve_relation(); bool r2_sieved = r2.get_plugin().is_sieve_relation(); - const sieve_relation * sr1 = r1_sieved ? static_cast(&r1) : 0; - const sieve_relation * sr2 = r2_sieved ? static_cast(&r2) : 0; + const sieve_relation * sr1 = r1_sieved ? static_cast(&r1) : nullptr; + const sieve_relation * sr2 = r2_sieved ? static_cast(&r2) : nullptr; const relation_base & inner1 = r1_sieved ? sr1->get_inner() : r1; const relation_base & inner2 = r2_sieved ? sr2->get_inner() : r2; @@ -340,7 +340,7 @@ namespace datalog { relation_join_fn * inner_join_fun = get_manager().mk_join_fn(inner1, inner2, inner_cols1, inner_cols2, false); if(!inner_join_fun) { - return 0; + return nullptr; } return alloc(join_fn, *this, r1, r2, col_cnt, cols1, cols2, inner_join_fun); } @@ -371,7 +371,7 @@ namespace datalog { relation_transformer_fn * sieve_relation_plugin::mk_project_fn(const relation_base & r0, unsigned col_cnt, const unsigned * removed_cols) { if(&r0.get_plugin()!=this) { - return 0; + return nullptr; } const sieve_relation & r = static_cast(r0); unsigned_vector inner_removed_cols; @@ -398,7 +398,7 @@ namespace datalog { } if(!inner_fun) { - return 0; + return nullptr; } return alloc(transformer_fn, inner_fun, result_sig, result_inner_cols.c_ptr()); } @@ -406,7 +406,7 @@ namespace datalog { relation_transformer_fn * sieve_relation_plugin::mk_rename_fn(const relation_base & r0, unsigned cycle_len, const unsigned * permutation_cycle) { if(&r0.get_plugin()!=this) { - return 0; + return nullptr; } const sieve_relation & r = static_cast(r0); @@ -428,7 +428,7 @@ namespace datalog { relation_transformer_fn * inner_fun = get_manager().mk_permutation_rename_fn(r.get_inner(), inner_permutation); if(!inner_fun) { - return 0; + return nullptr; } return alloc(transformer_fn, inner_fun, result_sig, result_inner_cols.c_ptr()); } @@ -443,9 +443,9 @@ namespace datalog { bool tgt_sieved = tgt.get_plugin().is_sieve_relation(); bool src_sieved = src.get_plugin().is_sieve_relation(); bool delta_sieved = delta && delta->get_plugin().is_sieve_relation(); - sieve_relation * stgt = tgt_sieved ? static_cast(&tgt) : 0; - const sieve_relation * ssrc = src_sieved ? static_cast(&src) : 0; - sieve_relation * sdelta = delta_sieved ? static_cast(delta) : 0; + sieve_relation * stgt = tgt_sieved ? static_cast(&tgt) : nullptr; + const sieve_relation * ssrc = src_sieved ? static_cast(&src) : nullptr; + sieve_relation * sdelta = delta_sieved ? static_cast(delta) : nullptr; relation_base & itgt = tgt_sieved ? stgt->get_inner() : tgt; const relation_base & isrc = src_sieved ? ssrc->get_inner() : src; relation_base * idelta = delta_sieved ? &sdelta->get_inner() : delta; @@ -458,15 +458,15 @@ namespace datalog { const relation_base * delta) { if(&tgt.get_plugin()!=this && &src.get_plugin()!=this && (delta && &delta->get_plugin()!=this)) { //we create the operation only if it involves this plugin - return 0; + return nullptr; } bool tgt_sieved = tgt.get_plugin().is_sieve_relation(); bool src_sieved = src.get_plugin().is_sieve_relation(); bool delta_sieved = delta && delta->get_plugin().is_sieve_relation(); - const sieve_relation * stgt = tgt_sieved ? static_cast(&tgt) : 0; - const sieve_relation * ssrc = src_sieved ? static_cast(&src) : 0; - const sieve_relation * sdelta = delta_sieved ? static_cast(delta) : 0; + const sieve_relation * stgt = tgt_sieved ? static_cast(&tgt) : nullptr; + const sieve_relation * ssrc = src_sieved ? static_cast(&src) : nullptr; + const sieve_relation * sdelta = delta_sieved ? static_cast(delta) : nullptr; const relation_base & itgt = tgt_sieved ? stgt->get_inner() : tgt; const relation_base & isrc = src_sieved ? ssrc->get_inner() : src; const relation_base * idelta = delta_sieved ? &sdelta->get_inner() : delta; @@ -476,7 +476,7 @@ namespace datalog { if( tgt_sieved && src_sieved && (!delta || delta_sieved) ) { if( !vectors_equal(stgt->m_inner_cols, ssrc->m_inner_cols) || (delta && !vectors_equal(stgt->m_inner_cols, sdelta->m_inner_cols)) ) { - return 0; + return nullptr; } } else { @@ -485,13 +485,13 @@ namespace datalog { || (sdelta && !sdelta->no_sieved_columns()) ) { //We have an unsieved relation and then some relation with some sieved columns, //which means there is an misalignment. - return 0; + return nullptr; } } relation_union_fn * union_fun = get_manager().mk_union_fn(itgt, isrc, idelta); if(!union_fun) { - return 0; + return nullptr; } return alloc(union_fn, union_fun); @@ -515,7 +515,7 @@ namespace datalog { relation_mutator_fn * sieve_relation_plugin::mk_filter_identical_fn(const relation_base & r0, unsigned col_cnt, const unsigned * identical_cols) { if(&r0.get_plugin()!=this) { - return 0; + return nullptr; } const sieve_relation & r = static_cast(r0); unsigned_vector inner_icols; @@ -534,7 +534,7 @@ namespace datalog { relation_mutator_fn * inner_fun = get_manager().mk_filter_identical_fn(r.get_inner(), inner_icols); if(!inner_fun) { - return 0; + return nullptr; } return alloc(filter_fn, inner_fun); } @@ -542,7 +542,7 @@ namespace datalog { relation_mutator_fn * sieve_relation_plugin::mk_filter_equal_fn(const relation_base & r0, const relation_element & value, unsigned col) { if(&r0.get_plugin()!=this) { - return 0; + return nullptr; } const sieve_relation & r = static_cast(r0); if(!r.is_inner_col(col)) { @@ -553,7 +553,7 @@ namespace datalog { relation_mutator_fn * inner_fun = get_manager().mk_filter_equal_fn(r.get_inner(), value, inner_col); if(!inner_fun) { - return 0; + return nullptr; } return alloc(filter_fn, inner_fun); } @@ -561,7 +561,7 @@ namespace datalog { relation_mutator_fn * sieve_relation_plugin::mk_filter_interpreted_fn(const relation_base & rb, app * condition) { if(&rb.get_plugin()!=this) { - return 0; + return nullptr; } ast_manager & m = get_ast_manager(); const sieve_relation & r = static_cast(rb); @@ -589,7 +589,7 @@ namespace datalog { relation_mutator_fn * inner_fun = get_manager().mk_filter_interpreted_fn(r.get_inner(), to_app(inner_cond)); if(!inner_fun) { - return 0; + return nullptr; } return alloc(filter_fn, inner_fun); } @@ -604,8 +604,8 @@ namespace datalog { bool r_sieved = r.get_plugin().is_sieve_relation(); bool neg_sieved = neg.get_plugin().is_sieve_relation(); SASSERT(r_sieved || neg_sieved); - sieve_relation * sr = r_sieved ? static_cast(&r) : 0; - const sieve_relation * sneg = neg_sieved ? static_cast(&neg) : 0; + sieve_relation * sr = r_sieved ? static_cast(&r) : nullptr; + const sieve_relation * sneg = neg_sieved ? static_cast(&neg) : nullptr; relation_base & inner_r = r_sieved ? sr->get_inner() : r; const relation_base & inner_neg = neg_sieved ? sneg->get_inner() : neg; @@ -618,13 +618,13 @@ namespace datalog { const unsigned * neg_cols) { if(&r.get_plugin()!=this && &neg.get_plugin()!=this) { //we create just operations that involve the current plugin - return 0; + return nullptr; } bool r_sieved = r.get_plugin().is_sieve_relation(); bool neg_sieved = neg.get_plugin().is_sieve_relation(); SASSERT(r_sieved || neg_sieved); - const sieve_relation * sr = r_sieved ? static_cast(&r) : 0; - const sieve_relation * sneg = neg_sieved ? static_cast(&neg) : 0; + const sieve_relation * sr = r_sieved ? static_cast(&r) : nullptr; + const sieve_relation * sneg = neg_sieved ? static_cast(&neg) : nullptr; const relation_base & inner_r = r_sieved ? sr->get_inner() : r; const relation_base & inner_neg = neg_sieved ? sneg->get_inner() : neg; @@ -657,7 +657,7 @@ namespace datalog { relation_intersection_filter_fn * inner_fun = get_manager().mk_filter_by_negation_fn(inner_r, inner_neg, ir_cols, ineg_cols); if(!inner_fun) { - return 0; + return nullptr; } return alloc(negation_filter_fn, inner_fun); } diff --git a/src/muz/rel/dl_sparse_table.cpp b/src/muz/rel/dl_sparse_table.cpp index 50386152c..779172b0d 100644 --- a/src/muz/rel/dl_sparse_table.cpp +++ b/src/muz/rel/dl_sparse_table.cpp @@ -257,8 +257,8 @@ namespace datalog { \brief Empty result. */ query_result() : m_singleton(false) { - m_many.begin = 0; - m_many.end = 0; + m_many.begin = nullptr; + m_many.end = nullptr; } query_result(offset_iterator begin, offset_iterator end) : m_singleton(false) { m_many.begin = begin; @@ -327,7 +327,7 @@ namespace datalog { key_value key; key.resize(key_len); - offset_vector * index_entry = 0; + offset_vector * index_entry = nullptr; bool key_modified = true; for (; ofs!=after_last; ofs+=t.m_fact_size) { @@ -473,7 +473,7 @@ namespace datalog { #endif key_spec kspec; kspec.append(key_len, key_cols); - key_index_map::entry * key_map_entry = m_key_indexes.insert_if_not_there2(kspec, 0); + key_index_map::entry * key_map_entry = m_key_indexes.insert_if_not_there2(kspec, nullptr); if (!key_map_entry->get_data().m_value) { if (full_signature_key_indexer::can_handle(key_len, key_cols, *this)) { key_map_entry->get_data().m_value = alloc(full_signature_key_indexer, key_len, key_cols, *this); @@ -777,9 +777,9 @@ namespace datalog { const table_signature & sig = t->get_signature(); t->reset(); - table_pool::entry * e = m_pool.insert_if_not_there2(sig, 0); + table_pool::entry * e = m_pool.insert_if_not_there2(sig, nullptr); sp_table_vector * & vect = e->get_data().m_value; - if (vect == 0) { + if (vect == nullptr) { vect = alloc(sp_table_vector); } IF_VERBOSE(12, verbose_stream() << "Recycle: " << t->get_size_estimate_bytes() << "\n";); @@ -859,9 +859,9 @@ namespace datalog { if (t1.get_kind()!=get_kind() || t2.get_kind()!=get_kind() || join_involves_functional(sig1, sig2, col_cnt, cols1, cols2)) { //We also don't allow indexes on functional columns (and they are needed for joins) - return 0; + return nullptr; } - return mk_join_project_fn(t1, t2, col_cnt, cols1, cols2, 0, static_cast(0)); + return mk_join_project_fn(t1, t2, col_cnt, cols1, cols2, 0, static_cast(nullptr)); } table_join_fn * sparse_table_plugin::mk_join_project_fn(const table_base & t1, const table_base & t2, @@ -874,7 +874,7 @@ namespace datalog { || join_involves_functional(sig1, sig2, col_cnt, cols1, cols2)) { //We don't allow sparse tables with zero signatures (and project on all columns leads to such) //We also don't allow indexes on functional columns. - return 0; + return nullptr; } return alloc(join_project_fn, t1.get_signature(), t2.get_signature(), col_cnt, cols1, cols2, removed_col_cnt, removed_cols); @@ -905,7 +905,7 @@ namespace datalog { || (delta && delta->get_kind()!=get_kind()) || tgt.get_signature()!=src.get_signature() || (delta && delta->get_signature()!=tgt.get_signature())) { - return 0; + return nullptr; } return alloc(union_fn); } @@ -969,7 +969,7 @@ namespace datalog { table_transformer_fn * sparse_table_plugin::mk_project_fn(const table_base & t, unsigned col_cnt, const unsigned * removed_cols) { if (col_cnt == t.get_signature().size()) { - return 0; + return nullptr; } return alloc(project_fn, t.get_signature(), col_cnt, removed_cols); } @@ -1032,7 +1032,7 @@ namespace datalog { //column table produces one). //We also don't allow indexes on functional columns. And our implementation of //select_equal_and_project uses index on \c col. - return 0; + return nullptr; } return alloc(select_equal_and_project_fn, t.get_signature(), value, col); } @@ -1113,7 +1113,7 @@ namespace datalog { table_transformer_fn * sparse_table_plugin::mk_rename_fn(const table_base & t, unsigned permutation_cycle_len, const unsigned * permutation_cycle) { if (t.get_kind()!=get_kind()) { - return 0; + return nullptr; } return alloc(rename_fn, t.get_signature(), permutation_cycle_len, permutation_cycle); } @@ -1252,7 +1252,7 @@ namespace datalog { if (!check_kind(t) || !check_kind(negated_obj) || join_involves_functional(t.get_signature(), negated_obj.get_signature(), joined_col_cnt, t_cols, negated_cols) ) { - return 0; + return nullptr; } return alloc(negation_filter_fn, t, negated_obj, joined_col_cnt, t_cols, negated_cols); } @@ -1394,7 +1394,7 @@ namespace datalog { return alloc(negated_join_fn, src1, t_cols, src_cols, src1_cols, src2_cols); } else { - return 0; + return nullptr; } } diff --git a/src/muz/rel/dl_table.cpp b/src/muz/rel/dl_table.cpp index 963820c91..71ffd88f3 100644 --- a/src/muz/rel/dl_table.cpp +++ b/src/muz/rel/dl_table.cpp @@ -89,7 +89,7 @@ namespace datalog { table_join_fn * hashtable_table_plugin::mk_join_fn(const table_base & t1, const table_base & t2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if(t1.get_kind()!=get_kind() || t2.get_kind()!=get_kind()) { - return 0; + return nullptr; } return alloc(join_fn, t1.get_signature(), t2.get_signature(), col_cnt, cols1, cols2); } diff --git a/src/muz/rel/dl_table_relation.cpp b/src/muz/rel/dl_table_relation.cpp index d5d8fd3c9..de55998f8 100644 --- a/src/muz/rel/dl_table_relation.cpp +++ b/src/muz/rel/dl_table_relation.cpp @@ -48,7 +48,7 @@ namespace datalog { relation_base * table_relation_plugin::mk_empty(const relation_signature & s) { table_signature tsig; if (!get_manager().relation_signature_to_table(s, tsig)) { - return 0; + return nullptr; } table_base * t = m_table_plugin.mk_empty(tsig); return alloc(table_relation, *this, s, t); @@ -57,7 +57,7 @@ namespace datalog { relation_base * table_relation_plugin::mk_full_relation(const relation_signature & s, func_decl* p, family_id kind) { table_signature tsig; if(!get_manager().relation_signature_to_table(s, tsig)) { - return 0; + return nullptr; } table_base * t = m_table_plugin.mk_full(p, tsig, kind); return alloc(table_relation, *this, s, t); @@ -108,25 +108,25 @@ namespace datalog { relation_join_fn * table_relation_plugin::mk_join_fn(const relation_base & r1, const relation_base & r2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if(!r1.from_table() || !r2.from_table()) { - return 0; + return nullptr; } const table_relation & tr1 = static_cast(r1); const table_relation & tr2 = static_cast(r2); table_join_fn * tfun = get_manager().mk_join_fn(tr1.get_table(), tr2.get_table(), col_cnt, cols1, cols2); if(!tfun) { - return 0; + return nullptr; } return alloc(tr_join_project_fn, r1.get_signature(), r2.get_signature(), col_cnt, cols1, - cols2, 0, static_cast(0), tfun); + cols2, 0, static_cast(nullptr), tfun); } relation_join_fn * table_relation_plugin::mk_join_project_fn(const relation_base & r1, const relation_base & r2, unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, const unsigned * removed_cols) { if(!r1.from_table() || !r2.from_table()) { - return 0; + return nullptr; } const table_relation & tr1 = static_cast(r1); const table_relation & tr2 = static_cast(r2); @@ -168,7 +168,7 @@ namespace datalog { relation_transformer_fn * table_relation_plugin::mk_project_fn(const relation_base & t, unsigned col_cnt, const unsigned * removed_cols) { if(!t.from_table()) { - return 0; + return nullptr; } const table_relation & tr = static_cast(t); @@ -184,7 +184,7 @@ namespace datalog { relation_transformer_fn * table_relation_plugin::mk_rename_fn(const relation_base & t, unsigned permutation_cycle_len, const unsigned * permutation_cycle) { if(!t.from_table()) { - return 0; + return nullptr; } const table_relation & tr = static_cast(t); @@ -200,7 +200,7 @@ namespace datalog { relation_transformer_fn * table_relation_plugin::mk_permutation_rename_fn(const relation_base & t, const unsigned * permutation) { if(!t.from_table()) { - return 0; + return nullptr; } const table_relation & tr = static_cast(t); @@ -216,7 +216,7 @@ namespace datalog { relation_transformer_fn * table_relation_plugin::mk_select_equal_and_project_fn(const relation_base & t, const relation_element & value, unsigned col) { if(!t.from_table()) { - return 0; + return nullptr; } const table_relation & tr = static_cast(t); @@ -280,7 +280,7 @@ namespace datalog { const table_relation & tr_src = static_cast(src); table_relation * tr_delta = static_cast(delta); - (*m_tfun)(tr_tgt.get_table(), tr_src.get_table(), tr_delta ? &tr_delta->get_table() : 0); + (*m_tfun)(tr_tgt.get_table(), tr_src.get_table(), tr_delta ? &tr_delta->get_table() : nullptr); TRACE("dl_table_relation", tout << "# union => "; tr_tgt.get_table().display(tout);); } @@ -289,7 +289,7 @@ namespace datalog { relation_union_fn * table_relation_plugin::mk_union_fn(const relation_base & tgt, const relation_base & src, const relation_base * delta) { if(!src.from_table()) { - return 0; + return nullptr; } if(!tgt.from_table() || (delta && !delta->from_table())) { return alloc(universal_target_union_fn); @@ -299,7 +299,7 @@ namespace datalog { const table_relation * tr_delta = static_cast(delta); table_union_fn * tfun = get_manager().mk_union_fn(tr_tgt.get_table(), tr_src.get_table(), - tr_delta ? &tr_delta->get_table() : 0); + tr_delta ? &tr_delta->get_table() : nullptr); SASSERT(tfun); return alloc(tr_union_fn, tfun); @@ -322,7 +322,7 @@ namespace datalog { relation_mutator_fn * table_relation_plugin::mk_filter_identical_fn(const relation_base & t, unsigned col_cnt, const unsigned * identical_cols) { if(!t.from_table()) { - return 0; + return nullptr; } const table_relation & tr = static_cast(t); @@ -334,7 +334,7 @@ namespace datalog { relation_mutator_fn * table_relation_plugin::mk_filter_equal_fn(const relation_base & t, const relation_element & value, unsigned col) { if(!t.from_table()) { - return 0; + return nullptr; } const table_relation & tr = static_cast(t); @@ -349,7 +349,7 @@ namespace datalog { relation_mutator_fn * table_relation_plugin::mk_filter_interpreted_fn(const relation_base & t, app * condition) { bool condition_needs_transforming = false; if(!t.from_table() || condition_needs_transforming) { - return 0; + return nullptr; } const table_relation & tr = static_cast(t); table_mutator_fn * tfun = get_manager().mk_filter_interpreted_fn(tr.get_table(), condition); @@ -360,7 +360,7 @@ namespace datalog { relation_transformer_fn * table_relation_plugin::mk_filter_interpreted_and_project_fn(const relation_base & t, app * condition, unsigned removed_col_cnt, const unsigned * removed_cols) { if (!t.from_table()) - return 0; + return nullptr; const table_relation & tr = static_cast(t); table_transformer_fn * tfun = get_manager().mk_filter_interpreted_and_project_fn(tr.get_table(), @@ -392,14 +392,14 @@ namespace datalog { relation_intersection_filter_fn * table_relation_plugin::mk_filter_by_intersection_fn(const relation_base & r, const relation_base & src, unsigned joined_col_cnt, const unsigned * r_cols, const unsigned * src_cols) { if(!r.from_table() || !src.from_table()) { - return 0; + return nullptr; } const table_relation & tr = static_cast(r); const table_relation & tr_neg = static_cast(src); table_intersection_filter_fn * tfun = get_manager().mk_filter_by_intersection_fn(tr.get_table(), tr_neg.get_table(), joined_col_cnt, r_cols, src_cols); if(!tfun) { - return 0; + return nullptr; } return alloc(tr_intersection_filter_fn, tfun); @@ -410,7 +410,7 @@ namespace datalog { const relation_base & negated_rel, unsigned joined_col_cnt, const unsigned * r_cols, const unsigned * negated_cols) { if(!r.from_table() || !negated_rel.from_table()) { - return 0; + return nullptr; } const table_relation & tr = static_cast(r); const table_relation & tr_neg = static_cast(negated_rel); diff --git a/src/muz/rel/doc.cpp b/src/muz/rel/doc.cpp index 23d24dfc3..d205e7725 100644 --- a/src/muz/rel/doc.cpp +++ b/src/muz/rel/doc.cpp @@ -447,7 +447,7 @@ doc* doc_manager::join(const doc& d1, const doc& d2, doc_manager& dm1, } else if (v1 != v2) { // columns don't match - return 0; + return nullptr; } SASSERT(well_formed(*d)); } diff --git a/src/muz/rel/doc.h b/src/muz/rel/doc.h index 419081892..81f55497a 100644 --- a/src/muz/rel/doc.h +++ b/src/muz/rel/doc.h @@ -373,7 +373,7 @@ class doc_ref { doc_manager& dm; doc* d; public: - doc_ref(doc_manager& dm):dm(dm),d(0) {} + doc_ref(doc_manager& dm):dm(dm),d(nullptr) {} doc_ref(doc_manager& dm, doc* d):dm(dm),d(d) {} ~doc_ref() { if (d) dm.deallocate(d); @@ -385,8 +385,8 @@ public: } doc& operator*() { return *d; } doc* operator->() { return d; } - doc* detach() { doc* r = d; d = 0; return r; } - operator bool() const { return d != 0; } + doc* detach() { doc* r = d; d = nullptr; return r; } + operator bool() const { return d != nullptr; } }; #endif /* DOC_H_ */ diff --git a/src/muz/rel/karr_relation.cpp b/src/muz/rel/karr_relation.cpp index c73b8356d..956244b4f 100644 --- a/src/muz/rel/karr_relation.cpp +++ b/src/muz/rel/karr_relation.cpp @@ -90,7 +90,7 @@ namespace datalog { karr_relation * complement(func_decl*) const override { UNREACHABLE(); - return 0; + return nullptr; } void to_formula(expr_ref& fml) const override { @@ -111,8 +111,8 @@ namespace datalog { void filter_interpreted(app* cond) { rational one(1), mone(-1); - expr* e1 = 0, *e2 = 0, *en = 0; - var* v = 0, *w = 0; + expr* e1 = nullptr, *e2 = nullptr, *en = nullptr; + var* v = nullptr, *w = nullptr; rational n1, n2; expr_ref_vector conjs(m); flatten_and(cond, conjs); @@ -500,7 +500,7 @@ namespace datalog { } relation_base * karr_relation_plugin::mk_empty(const relation_signature & s) { - return alloc(karr_relation, *this, 0, s, true); + return alloc(karr_relation, *this, nullptr, s, true); } relation_base * karr_relation_plugin::mk_full(func_decl* p, const relation_signature & s) { @@ -518,7 +518,7 @@ namespace datalog { karr_relation const& r1 = get(_r1); karr_relation const& r2 = get(_r2); karr_relation_plugin& p = r1.get_plugin(); - karr_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); + karr_relation* result = dynamic_cast(p.mk_full(nullptr, get_result_signature())); result->mk_join(r1, r2, m_cols1.size(), m_cols1.c_ptr(), m_cols2.c_ptr()); return result; } @@ -528,7 +528,7 @@ namespace datalog { const relation_base & t1, const relation_base & t2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if (!check_kind(t1) || !check_kind(t2)) { - return 0; + return nullptr; } return alloc(join_fn, t1.get_signature(), t2.get_signature(), col_cnt, cols1, cols2); } @@ -543,7 +543,7 @@ namespace datalog { relation_base * operator()(const relation_base & _r) override { karr_relation const& r = get(_r); karr_relation_plugin& p = r.get_plugin(); - karr_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); + karr_relation* result = dynamic_cast(p.mk_full(nullptr, get_result_signature())); result->mk_project(r, m_removed_cols.size(), m_removed_cols.c_ptr()); return result; } @@ -562,7 +562,7 @@ namespace datalog { relation_base * operator()(const relation_base & _r) override { karr_relation const& r = get(_r); karr_relation_plugin& p = r.get_plugin(); - karr_relation* result = dynamic_cast(p.mk_full(0, get_result_signature())); + karr_relation* result = dynamic_cast(p.mk_full(nullptr, get_result_signature())); result->mk_rename(r, m_cycle.size(), m_cycle.c_ptr()); return result; } @@ -571,7 +571,7 @@ namespace datalog { relation_transformer_fn * karr_relation_plugin::mk_rename_fn(const relation_base & r, unsigned cycle_len, const unsigned * permutation_cycle) { if (!check_kind(r)) { - return 0; + return nullptr; } return alloc(rename_fn, *this, r.get_signature(), cycle_len, permutation_cycle); } @@ -687,7 +687,7 @@ namespace datalog { r.mk_union(src, &d); } else { - r.mk_union(src, 0); + r.mk_union(src, nullptr); } TRACE("dl", r.display(tout << "result:\n");); } @@ -696,7 +696,7 @@ namespace datalog { relation_union_fn * karr_relation_plugin::mk_union_fn(const relation_base & tgt, const relation_base & src, const relation_base * delta) { if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; + return nullptr; } return alloc(union_fn); } @@ -730,7 +730,7 @@ namespace datalog { relation_mutator_fn * karr_relation_plugin::mk_filter_identical_fn( const relation_base & t, unsigned col_cnt, const unsigned * identical_cols) { if(!check_kind(t)) { - return 0; + return nullptr; } return alloc(filter_identical_fn, col_cnt, identical_cols); } @@ -768,7 +768,7 @@ namespace datalog { if (check_kind(r)) { return alloc(filter_equal_fn, get_manager(), value, col); } - return 0; + return nullptr; } @@ -789,6 +789,6 @@ namespace datalog { if (check_kind(t)) { return alloc(filter_interpreted_fn, get(t), condition); } - return 0; + return nullptr; } }; diff --git a/src/muz/rel/rel_context.cpp b/src/muz/rel/rel_context.cpp index 9fb1e89e0..dfef3ac73 100644 --- a/src/muz/rel/rel_context.cpp +++ b/src/muz/rel/rel_context.cpp @@ -96,7 +96,7 @@ namespace datalog { m(ctx.get_manager()), m_rmanager(ctx), m_answer(m), - m_last_result_relation(0), + m_last_result_relation(nullptr), m_ectx(ctx), m_sw(0) { @@ -121,7 +121,7 @@ namespace datalog { rel_context::~rel_context() { if (m_last_result_relation) { m_last_result_relation->deallocate(); - m_last_result_relation = 0; + m_last_result_relation = nullptr; } } diff --git a/src/muz/rel/tbv.h b/src/muz/rel/tbv.h index 1839700d6..22c25a5e9 100644 --- a/src/muz/rel/tbv.h +++ b/src/muz/rel/tbv.h @@ -130,7 +130,7 @@ class tbv_ref { tbv_manager& mgr; tbv* d; public: - tbv_ref(tbv_manager& mgr):mgr(mgr),d(0) {} + tbv_ref(tbv_manager& mgr):mgr(mgr),d(nullptr) {} tbv_ref(tbv_manager& mgr, tbv* d):mgr(mgr),d(d) {} ~tbv_ref() { if (d) mgr.deallocate(d); @@ -143,7 +143,7 @@ public: tbv& operator*() { return *d; } tbv* operator->() { return d; } tbv* get() { return d; } - tbv* detach() { tbv* result = d; d = 0; return result; } + tbv* detach() { tbv* result = d; d = nullptr; return result; } }; diff --git a/src/muz/rel/udoc_relation.cpp b/src/muz/rel/udoc_relation.cpp index a5b9a2084..ff23a5e53 100644 --- a/src/muz/rel/udoc_relation.cpp +++ b/src/muz/rel/udoc_relation.cpp @@ -203,7 +203,7 @@ namespace datalog { return dynamic_cast(r); } udoc_relation* udoc_plugin::get(relation_base* r) { - return r?dynamic_cast(r):0; + return r?dynamic_cast(r):nullptr; } udoc_relation const & udoc_plugin::get(relation_base const& r) { return dynamic_cast(r); @@ -351,7 +351,7 @@ namespace datalog { const relation_base & t1, const relation_base & t2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if (!check_kind(t1) || !check_kind(t2)) { - return 0; + return nullptr; } return alloc(join_fn, *this, get(t1), get(t2), col_cnt, cols1, cols2); } @@ -394,7 +394,7 @@ namespace datalog { const relation_base & t, unsigned col_cnt, const unsigned * removed_cols) { if (!check_kind(t)) - return 0; + return nullptr; return alloc(project_fn, get(t), col_cnt, removed_cols); } @@ -487,7 +487,7 @@ namespace datalog { return alloc(rename_fn, get(r), cycle_len, permutation_cycle); } else { - return 0; + return nullptr; } } class udoc_plugin::union_fn : public relation_union_fn { @@ -500,7 +500,7 @@ namespace datalog { udoc_relation const& src = get(_src); udoc_relation* d = get(_delta); doc_manager& dm = r.get_dm(); - udoc* d1 = 0; + udoc* d1 = nullptr; if (d) d1 = &d->get_udoc(); IF_VERBOSE(3, r.display(verbose_stream() << "orig: ");); r.get_plugin().mk_union(dm, r.get_udoc(), src.get_udoc(), d1); @@ -539,7 +539,7 @@ namespace datalog { const relation_base & tgt, const relation_base & src, const relation_base * delta) { if (!check_kind(tgt) || !check_kind(src) || (delta && !check_kind(*delta))) { - return 0; + return nullptr; } return alloc(union_fn); } @@ -585,7 +585,7 @@ namespace datalog { }; relation_mutator_fn * udoc_plugin::mk_filter_identical_fn( const relation_base & t, unsigned col_cnt, const unsigned * identical_cols) { - return check_kind(t)?alloc(filter_identical_fn, t, col_cnt, identical_cols):0; + return check_kind(t)?alloc(filter_identical_fn, t, col_cnt, identical_cols):nullptr; } class udoc_plugin::filter_equal_fn : public relation_mutator_fn { doc_manager& dm; @@ -614,7 +614,7 @@ namespace datalog { relation_mutator_fn * udoc_plugin::mk_filter_equal_fn( const relation_base & t, const relation_element & value, unsigned col) { if (!check_kind(t)) - return 0; + return nullptr; return alloc(filter_equal_fn, *this, get(t), value, col); } @@ -951,7 +951,7 @@ namespace datalog { } }; relation_mutator_fn * udoc_plugin::mk_filter_interpreted_fn(const relation_base & t, app * condition) { - return check_kind(t)?alloc(filter_interpreted_fn, get(t), get_ast_manager(), condition):0; + return check_kind(t)?alloc(filter_interpreted_fn, get(t), get_ast_manager(), condition):nullptr; } class udoc_plugin::join_project_fn : public convenient_relation_join_project_fn { @@ -1055,7 +1055,7 @@ namespace datalog { unsigned joined_col_cnt, const unsigned * cols1, const unsigned * cols2, unsigned removed_col_cnt, const unsigned * removed_cols) { if (!check_kind(t1) || !check_kind(t2)) - return 0; + return nullptr; // special case where we have h(X) :- f(X), g(X). if (joined_col_cnt == removed_col_cnt && t1.get_signature().size() == joined_col_cnt && @@ -1183,7 +1183,7 @@ namespace datalog { const relation_base& neg, unsigned joined_col_cnt, const unsigned *t_cols, const unsigned *negated_cols) { if (!check_kind(t) || !check_kind(neg)) - return 0; + return nullptr; return alloc(negation_filter_fn, get(t), get(neg), joined_col_cnt, t_cols, negated_cols); } @@ -1250,7 +1250,7 @@ namespace datalog { relation_transformer_fn * udoc_plugin::mk_filter_interpreted_and_project_fn( const relation_base & t, app * condition, unsigned removed_col_cnt, const unsigned * removed_cols) { - return check_kind(t)?alloc(filter_proj_fn, get(t), get_ast_manager(), condition, removed_col_cnt, removed_cols):0; + return check_kind(t)?alloc(filter_proj_fn, get(t), get_ast_manager(), condition, removed_col_cnt, removed_cols):nullptr; } diff --git a/src/muz/rel/udoc_relation.h b/src/muz/rel/udoc_relation.h index 87755f75e..01b2e8b43 100644 --- a/src/muz/rel/udoc_relation.h +++ b/src/muz/rel/udoc_relation.h @@ -63,7 +63,7 @@ namespace datalog { unsigned get_num_cols() const { return m_column_info.size()-1; } unsigned column_idx(unsigned col) const { return m_column_info[col]; } unsigned column_num_bits(unsigned col) const { return m_column_info[col+1] - m_column_info[col]; } - void expand_column_vector(unsigned_vector& v, const udoc_relation* other = 0) const; + void expand_column_vector(unsigned_vector& v, const udoc_relation* other = nullptr) const; void extract_guard(expr* condition, expr_ref& guard, expr_ref& rest) const; bool is_guard(expr* g) const; bool is_guard(unsigned n, expr* const *g) const; diff --git a/src/muz/spacer/spacer_antiunify.cpp b/src/muz/spacer/spacer_antiunify.cpp index 7dae59b6a..6baf9e93d 100644 --- a/src/muz/spacer/spacer_antiunify.cpp +++ b/src/muz/spacer/spacer_antiunify.cpp @@ -441,7 +441,7 @@ struct subs_rewriter_cfg : public default_rewriter_cfg { bool reduce_var(var * t, expr_ref & result, proof_ref & result_pr) { result = m_c; - result_pr = 0; + result_pr = nullptr; return true; } }; diff --git a/src/muz/spacer/spacer_context.cpp b/src/muz/spacer/spacer_context.cpp index 28ff7d787..ae67d3793 100644 --- a/src/muz/spacer/spacer_context.cpp +++ b/src/muz/spacer/spacer_context.cpp @@ -127,7 +127,7 @@ void pred_transformer::init_sig() std::stringstream name_stm; name_stm << m_head->get_name() << '_' << i; func_decl_ref stm(m); - stm = m.mk_func_decl(symbol(name_stm.str().c_str()), 0, (sort*const*)0, arg_sort); + stm = m.mk_func_decl(symbol(name_stm.str().c_str()), 0, (sort*const*)nullptr, arg_sort); m_sig.push_back(pm.get_o_pred(stm, 0)); } } @@ -153,7 +153,7 @@ bool pred_transformer::is_must_reachable(expr* state, model_ref* model) m_reach_ctx->push (); m_reach_ctx->assert_expr (state); m_reach_ctx->assert_expr (m.mk_not (m_reach_case_vars.back ())); - lbool res = m_reach_ctx->check_sat (0, NULL); + lbool res = m_reach_ctx->check_sat (0, nullptr); if (model) { m_reach_ctx->get_model(*model); } m_reach_ctx->pop (1); return (res == l_true); @@ -176,14 +176,14 @@ reach_fact* pred_transformer::get_used_reach_fact (model_evaluator_util& mev, } UNREACHABLE (); - return NULL; + return nullptr; } reach_fact *pred_transformer::get_used_origin_reach_fact (model_evaluator_util& mev, unsigned oidx) { expr_ref b(m), v(m); - reach_fact *res = NULL; + reach_fact *res = nullptr; for (unsigned i = 0, sz = m_reach_case_vars.size (); i < sz; i++) { pm.formula_n2o (m_reach_case_vars.get (i), v, oidx); @@ -219,7 +219,7 @@ datalog::rule const* pred_transformer::find_rule(model &model, // prefer a rule where the model intersects with reach facts of all predecessors; // also find how many predecessors' reach facts are true in the model expr_ref vl(m); - datalog::rule const* r = ((datalog::rule*)0); + datalog::rule const* r = ((datalog::rule*)nullptr); tag2rule::iterator it = m_tag2rule.begin(), end = m_tag2rule.end(); for (; it != end; ++it) { expr* tag = it->m_key; @@ -392,7 +392,7 @@ expr* pred_transformer::mk_fresh_reach_case_var () name << head ()->get_name () << "#reach_case_" << m_reach_case_vars.size (); decl = m.mk_func_decl (symbol (name.str ().c_str ()), 0, - (sort*const*)0, m.mk_bool_sort ()); + (sort*const*)nullptr, m.mk_bool_sort ()); m_reach_case_vars.push_back (m.mk_const (pm.get_n_pred (decl))); return m_reach_case_vars.back (); } @@ -495,7 +495,7 @@ expr_ref pred_transformer::get_reachable() expr* pred_transformer::get_last_reach_case_var () const { - return m_reach_case_vars.empty () ? NULL : m_reach_case_vars.back (); + return m_reach_case_vars.empty () ? nullptr : m_reach_case_vars.back (); } expr_ref pred_transformer::get_cover_delta(func_decl* p_orig, int level) @@ -557,7 +557,7 @@ expr_ref pred_transformer::get_origin_summary (model_evaluator_util &mev, if (!must) { // use may summary summary.push_back (get_formulas (level, false)); // -- no auxiliary variables in lemmas - *aux = NULL; + *aux = nullptr; } else { // find must summary to use reach_fact *f = get_used_origin_reach_fact (mev, oidx); summary.push_back (f->get ()); @@ -613,12 +613,12 @@ bool pred_transformer::is_blocked (pob &n, unsigned &uses_level) { ensure_level (n.level ()); prop_solver::scoped_level _sl (m_solver, n.level ()); - m_solver.set_core (NULL); - m_solver.set_model (NULL); + m_solver.set_core (nullptr); + m_solver.set_model (nullptr); expr_ref_vector post(m), aux(m); post.push_back (n.post ()); - lbool res = m_solver.check_assumptions (post, aux, 0, NULL, 0); + lbool res = m_solver.check_assumptions (post, aux, 0, nullptr, 0); if (res == l_false) { uses_level = m_solver.uses_level(); } return res == l_false; } @@ -775,7 +775,7 @@ bool pred_transformer::is_invariant(unsigned level, expr* lemma, prop_solver::scoped_level _sl(m_solver, level); prop_solver::scoped_subset_core _sc (m_solver, true); m_solver.set_core(core); - m_solver.set_model(0); + m_solver.set_model(nullptr); expr * bg = m_extend_lit.get (); lbool r = m_solver.check_assumptions (conj, aux, 1, &bg, 1); if (r == l_false) { @@ -799,7 +799,7 @@ bool pred_transformer::check_inductive(unsigned level, expr_ref_vector& state, prop_solver::scoped_level _sl(m_solver, level); prop_solver::scoped_subset_core _sc (m_solver, true); m_solver.set_core(&core); - m_solver.set_model (0); + m_solver.set_model (nullptr); expr_ref_vector aux (m); conj.push_back (m_extend_lit); lbool res = m_solver.check_assumptions (state, aux, conj.size (), conj.c_ptr (), 1); @@ -1023,7 +1023,7 @@ void pred_transformer::ground_free_vars(expr* e, app_ref_vector& vars, fv(e); while (vars.size() < fv.size()) { - vars.push_back(0); + vars.push_back(nullptr); } for (unsigned i = 0; i < fv.size(); ++i) { if (fv[i] && !vars[i].get()) { @@ -1110,7 +1110,7 @@ lemma::lemma (ast_manager &manager, expr * body, unsigned lvl) : m_ref_count(0), m(manager), m_body(body, m), m_cube(m), m_bindings(m), m_lvl(lvl), - m_pob(0), m_new_pob(false) { + m_pob(nullptr), m_new_pob(false) { SASSERT(m_body); normalize(m_body, m_body); } @@ -1579,7 +1579,7 @@ void derivation::add_premise (pred_transformer &pt, pob *derivation::create_first_child (model_evaluator_util &mev) { - if (m_premises.empty()) { return NULL; } + if (m_premises.empty()) { return nullptr; } m_active = 0; return create_next_child(mev); } @@ -1602,7 +1602,7 @@ pob *derivation::create_next_child (model_evaluator_util &mev) vars.append (m_premises[m_active].get_ovars ()); ++m_active; } - if (m_active >= m_premises.size()) { return NULL; } + if (m_active >= m_premises.size()) { return nullptr; } // -- update m_trans with the pre-image of m_trans over the must summaries summaries.push_back (m_trans); @@ -1621,7 +1621,7 @@ pob *derivation::create_next_child (model_evaluator_util &mev) if (!mev.is_true (m_premises[m_active].get_summary())) { IF_VERBOSE(1, verbose_stream() << "Summary unexpectendly not true\n";); - return NULL; + return nullptr; } @@ -1670,7 +1670,7 @@ pob *derivation::create_next_child (model_evaluator_util &mev) pob *derivation::create_next_child () { - if (m_active + 1 >= m_premises.size()) { return NULL; } + if (m_active + 1 >= m_premises.size()) { return nullptr; } bool use_native_mbp = get_context ().use_native_mbp (); bool ground = get_context ().use_ground_cti (); @@ -1697,7 +1697,7 @@ pob *derivation::create_next_child () // if not true, bail out, the must summary of m_active is not strong enough // this is possible if m_post was weakened for some reason - if (!pt.is_must_reachable(pm.mk_and(summaries), &model)) { return NULL; } + if (!pt.is_must_reachable(pm.mk_and(summaries), &model)) { return nullptr; } model_evaluator_util mev (m); mev.set_model (*model); @@ -1848,12 +1848,12 @@ void pob::get_skolems(app_ref_vector &v) { pob* pob_queue::top () { /// nothing in the queue - if (m_obligations.empty()) { return NULL; } + if (m_obligations.empty()) { return nullptr; } /// top queue element is above max level - if (m_obligations.top()->level() > m_max_level) { return NULL; } + if (m_obligations.top()->level() > m_max_level) { return nullptr; } /// top queue element is at the max level, but at a higher than base depth if (m_obligations.top ()->level () == m_max_level && - m_obligations.top()->depth() > m_min_depth) { return NULL; } + m_obligations.top()->depth() > m_min_depth) { return nullptr; } /// there is something good in the queue return m_obligations.top ().get (); @@ -1882,10 +1882,10 @@ context::context(fixedpoint_params const& params, ast_manager& m) : m_params(params), m(m), - m_context(0), + m_context(nullptr), m_pm(params.pdr_max_num_contexts(), m), m_query_pred(m), - m_query(0), + m_query(nullptr), m_pob_queue(), m_last_result(l_undef), m_inductive_lvl(0), @@ -1914,7 +1914,7 @@ void context::reset() dealloc(it->m_value); } m_rels.reset(); - m_query = 0; + m_query = nullptr; m_last_result = l_undef; m_inductive_lvl = 0; } @@ -1985,7 +1985,7 @@ void context::update_rules(datalog::rule_set& rules) init_rules(rules, rels); decl2rel::iterator it = rels.begin(), end = rels.end(); for (; it != end; ++it) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (m_rels.find(it->m_key, pt)) { it->m_value->inherit_properties(*pt); } @@ -1999,7 +1999,7 @@ void context::update_rules(datalog::rule_set& rules) unsigned context::get_num_levels(func_decl* p) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (m_rels.find(p, pt)) { return pt->get_num_levels(); } else { @@ -2010,7 +2010,7 @@ unsigned context::get_num_levels(func_decl* p) expr_ref context::get_cover_delta(int level, func_decl* p_orig, func_decl* p) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (m_rels.find(p, pt)) { return pt->get_cover_delta(p_orig, level); } else { @@ -2021,7 +2021,7 @@ expr_ref context::get_cover_delta(int level, func_decl* p_orig, func_decl* p) void context::add_cover(int level, func_decl* p, expr* property) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (!m_rels.find(p, pt)) { pt = alloc(pred_transformer, *this, get_manager(), p); m_rels.insert(p, pt); @@ -2036,7 +2036,7 @@ void context::add_invariant (func_decl *p, expr *property) expr_ref context::get_reachable(func_decl *p) { - pred_transformer* pt = 0; + pred_transformer* pt = nullptr; if (!m_rels.find(p, pt)) { return expr_ref(m.mk_false(), m); } return pt->get_reachable(); @@ -2300,7 +2300,7 @@ unsigned context::get_cex_depth() // get current pt and fact pt = pts.get (curr); // check for depth marker - if (pt == NULL) { + if (pt == nullptr) { ++cex_depth; // insert new marker if there are pts at higher depth if (curr + 1 < pts.size()) { pts.push_back(NULL); } @@ -2635,7 +2635,7 @@ bool context::check_reachability () while (last_reachable) { checkpoint (); node = last_reachable; - last_reachable = NULL; + last_reachable = nullptr; if (m_pob_queue.is_root(*node)) { return true; } if (is_reachable (*node->parent())) { last_reachable = node->parent (); @@ -2751,14 +2751,14 @@ bool context::is_reachable(pob &n) // used in case n is reachable bool is_concrete; - const datalog::rule * r = NULL; + const datalog::rule * r = nullptr; // denotes which predecessor's (along r) reach facts are used vector reach_pred_used; unsigned num_reuse_reach = 0; unsigned saved = n.level (); n.m_level = infty_level (); - lbool res = n.pt().is_reachable(n, NULL, &model, + lbool res = n.pt().is_reachable(n, nullptr, &model, uses_level, is_concrete, r, reach_pred_used, num_reuse_reach); n.m_level = saved; @@ -2782,7 +2782,7 @@ bool context::is_reachable(pob &n) // if n has a derivation, create a new child and report l_undef // otherwise if n has no derivation or no new children, report l_true - pob *next = NULL; + pob *next = nullptr; scoped_ptr deriv; if (n.has_derivation()) {deriv = n.detach_derivation();} @@ -2854,7 +2854,7 @@ lbool context::expand_node(pob& n) // used in case n is reachable bool is_concrete; - const datalog::rule * r = NULL; + const datalog::rule * r = nullptr; // denotes which predecessor's (along r) reach facts are used vector reach_pred_used; unsigned num_reuse_reach = 0; @@ -2899,7 +2899,7 @@ lbool context::expand_node(pob& n) // if n has a derivation, create a new child and report l_undef // otherwise if n has no derivation or no new children, report l_true - pob *next = NULL; + pob *next = nullptr; scoped_ptr deriv; if (n.has_derivation()) {deriv = n.detach_derivation();} @@ -3264,7 +3264,7 @@ bool context::create_children(pob& n, datalog::rule const& r, pred_transformer &pt = get_pred_transformer (preds [j]); - const ptr_vector *aux = NULL; + const ptr_vector *aux = nullptr; expr_ref sum(m); // XXX This is a bit confusing. The summary is returned over // XXX o-variables. But it is simpler if it is returned over n-variables instead. @@ -3432,7 +3432,7 @@ void context::add_constraints (unsigned level, const expr_ref& c) expr *e1, *e2; if (m.is_implies(c, e1, e2)) { SASSERT (is_app (e1)); - pred_transformer *r = 0; + pred_transformer *r = nullptr; if (m_rels.find (to_app (e1)->get_decl (), r)) { r->add_lemma(e2, level); } } diff --git a/src/muz/spacer/spacer_context.h b/src/muz/spacer/spacer_context.h index 898c1639e..a95b1bdb9 100644 --- a/src/muz/spacer/spacer_context.h +++ b/src/muz/spacer/spacer_context.h @@ -323,7 +323,7 @@ public: { for (unsigned i = 0, sz = m_reach_facts.size (); i < sz; ++i) if(v == m_reach_facts [i]->get()) { return m_reach_facts[i]; } - return NULL; + return nullptr; } void add_rule(datalog::rule* r) { m_rules.push_back(r); } @@ -348,7 +348,7 @@ public: void collect_statistics(statistics& st) const; void reset_statistics(); - bool is_must_reachable (expr* state, model_ref* model = 0); + bool is_must_reachable (expr* state, model_ref* model = nullptr); /// \brief Returns reachability fact active in the given model /// all determines whether initial reachability facts are included as well reach_fact *get_used_reach_fact (model_evaluator_util& mev, bool all = true); @@ -397,7 +397,7 @@ public: vector& reach_pred_used, unsigned& num_reuse_reach); bool is_invariant(unsigned level, expr* lemma, - unsigned& solver_level, expr_ref_vector* core = 0); + unsigned& solver_level, expr_ref_vector* core = nullptr); bool check_inductive(unsigned level, expr_ref_vector& state, unsigned& assumes_level); @@ -475,7 +475,7 @@ public: void set_derivation (derivation *d) {m_derivation = d;} bool has_derivation () const {return (bool)m_derivation;} derivation &get_derivation() const {return *m_derivation.get ();} - void reset_derivation () {set_derivation (NULL);} + void reset_derivation () {set_derivation (nullptr);} /// detaches derivation from the node without deallocating derivation* detach_derivation () {return m_derivation.detach ();} @@ -503,7 +503,7 @@ public: /// clean a dirty node void clean(); - void reset () {clean (); m_derivation = NULL; m_open = true;} + void reset () {clean (); m_derivation = nullptr; m_open = true;} bool is_closed () const { return !m_open; } void close(); @@ -563,7 +563,7 @@ class derivation { public: premise (pred_transformer &pt, unsigned oidx, expr *summary, bool must, - const ptr_vector *aux_vars = NULL); + const ptr_vector *aux_vars = nullptr); premise (const premise &p); bool is_must () {return m_must;} @@ -575,7 +575,7 @@ class derivation { /// \brief Updated the summary. /// The new summary is over n-variables. void set_summary (expr * summary, bool must, - const ptr_vector *aux_vars = NULL); + const ptr_vector *aux_vars = nullptr); }; @@ -600,7 +600,7 @@ public: derivation (pob& parent, datalog::rule const& rule, expr *trans, app_ref_vector const &evars); void add_premise (pred_transformer &pt, unsigned oidx, - expr * summary, bool must, const ptr_vector *aux_vars = NULL); + expr * summary, bool must, const ptr_vector *aux_vars = nullptr); /// creates the first child. Must be called after all the premises /// are added. The model must be valid for the premises @@ -628,7 +628,7 @@ class pob_queue { pob_ref_gt> m_obligations; public: - pob_queue(): m_root(NULL), m_max_level(0), m_min_depth(0) {} + pob_queue(): m_root(nullptr), m_max_level(0), m_min_depth(0) {} ~pob_queue(); void reset(); diff --git a/src/muz/spacer/spacer_dl_interface.cpp b/src/muz/spacer/spacer_dl_interface.cpp index 78776e074..52209454d 100644 --- a/src/muz/spacer/spacer_dl_interface.cpp +++ b/src/muz/spacer/spacer_dl_interface.cpp @@ -42,7 +42,7 @@ dl_interface::dl_interface(datalog::context& ctx) : m_ctx(ctx), m_spacer_rules(ctx), m_old_rules(ctx), - m_context(0), + m_context(nullptr), m_refs(ctx.get_manager()) { m_context = alloc(spacer::context, ctx.get_params(), ctx.get_manager()); diff --git a/src/muz/spacer/spacer_generalizers.cpp b/src/muz/spacer/spacer_generalizers.cpp index 94c419493..19989e440 100644 --- a/src/muz/spacer/spacer_generalizers.cpp +++ b/src/muz/spacer/spacer_generalizers.cpp @@ -161,7 +161,7 @@ class collect_array_proc { sort *m_sort; public: collect_array_proc(ast_manager &m, func_decl_set& s) : - m_au(m), m_symbs(s), m_sort(NULL) {} + m_au(m), m_symbs(s), m_sort(nullptr) {} void operator()(app* a) { diff --git a/src/muz/spacer/spacer_itp_solver.cpp b/src/muz/spacer/spacer_itp_solver.cpp index bcf6b07ae..7ca66fbfd 100644 --- a/src/muz/spacer/spacer_itp_solver.cpp +++ b/src/muz/spacer/spacer_itp_solver.cpp @@ -146,7 +146,7 @@ app* itp_solver::def_manager::mk_proxy (expr *v) bool itp_solver::def_manager::is_proxy (app *k, app_ref &def) { - app *r = NULL; + app *r = nullptr; bool found = m_proxy2def.find (k, r); def = r; return found; diff --git a/src/muz/spacer/spacer_legacy_mev.cpp b/src/muz/spacer/spacer_legacy_mev.cpp index 16e2cc734..fc3eabc56 100644 --- a/src/muz/spacer/spacer_legacy_mev.cpp +++ b/src/muz/spacer/spacer_legacy_mev.cpp @@ -80,7 +80,7 @@ void model_evaluator::reset() m_visited.reset(); m_numbers.reset(); m_refs.reset(); - m_model = 0; + m_model = nullptr; } diff --git a/src/muz/spacer/spacer_prop_solver.cpp b/src/muz/spacer/spacer_prop_solver.cpp index 19c5c3aa3..059374e39 100644 --- a/src/muz/spacer/spacer_prop_solver.cpp +++ b/src/muz/spacer/spacer_prop_solver.cpp @@ -43,10 +43,10 @@ prop_solver::prop_solver(manager& pm, fixedpoint_params const& p, symbol const& m(pm.get_manager()), m_pm(pm), m_name(name), - m_ctx(NULL), + m_ctx(nullptr), m_pos_level_atoms(m), m_neg_level_atoms(m), - m_core(0), + m_core(nullptr), m_subset_based_core(false), m_uses_level(infty_level()), m_delta_level(false), @@ -72,7 +72,7 @@ void prop_solver::add_level() unsigned idx = level_cnt(); std::stringstream name; name << m_name << "#level_" << idx; - func_decl * lev_pred = m.mk_fresh_func_decl(name.str().c_str(), 0, 0, m.mk_bool_sort()); + func_decl * lev_pred = m.mk_fresh_func_decl(name.str().c_str(), 0, nullptr, m.mk_bool_sort()); m_level_preds.push_back(lev_pred); app_ref pos_la(m.mk_const(lev_pred), m); @@ -196,7 +196,7 @@ lbool prop_solver::internal_check_assumptions( // XXX Turn model generation if m_model != 0 SASSERT(m_ctx); SASSERT(m_ctx_fparams); - flet _model(m_ctx_fparams->m_model, m_model != 0); + flet _model(m_ctx_fparams->m_model, m_model != nullptr); if (m_in_level) { assert_level_atoms(m_current_level); } lbool result = maxsmt(hard_atoms, soft_atoms); @@ -280,8 +280,8 @@ lbool prop_solver::check_assumptions(const expr_ref_vector & _hard, SASSERT(soft_sz >= soft.size()); // -- reset all parameters - m_core = 0; - m_model = 0; + m_core = nullptr; + m_model = nullptr; m_subset_based_core = false; return res; } diff --git a/src/muz/spacer/spacer_prop_solver.h b/src/muz/spacer/spacer_prop_solver.h index 1ddec91c6..0cbcecfbf 100644 --- a/src/muz/spacer/spacer_prop_solver.h +++ b/src/muz/spacer/spacer_prop_solver.h @@ -97,7 +97,7 @@ public: lbool check_assumptions(const expr_ref_vector & hard, expr_ref_vector & soft, unsigned num_bg = 0, - expr * const *bg = NULL, + expr * const *bg = nullptr, unsigned solver_id = 0); void collect_statistics(statistics& st) const; diff --git a/src/muz/spacer/spacer_qe_project.cpp b/src/muz/spacer/spacer_qe_project.cpp index cde188aac..753bb43b8 100644 --- a/src/muz/spacer/spacer_qe_project.cpp +++ b/src/muz/spacer/spacer_qe_project.cpp @@ -595,7 +595,7 @@ namespace qe { // c*x + t = 0 <=> x = -t/c expr_ref eq_term (mk_mul (-(rational::one ()/m_coeffs[eq_idx]), m_terms.get (eq_idx)), m); m_rw (eq_term); - map.insert (m_var->x (), eq_term, 0); + map.insert (m_var->x (), eq_term, nullptr); TRACE ("qe", tout << "Using equality term: " << mk_pp (eq_term, m) << "\n"; ); @@ -680,7 +680,7 @@ namespace qe { } else { new_lit = m.mk_true (); } - map.insert (m_lits.get (i), new_lit, 0); + map.insert (m_lits.get (i), new_lit, nullptr); TRACE ("qe", tout << "Old literal: " << mk_pp (m_lits.get (i), m) << "\n"; tout << "New literal: " << mk_pp (new_lit, m) << "\n"; @@ -722,7 +722,7 @@ namespace qe { } else { new_lit = m.mk_true (); } - map.insert (m_lits.get (i), new_lit, 0); + map.insert (m_lits.get (i), new_lit, nullptr); TRACE ("qe", tout << "Old literal: " << mk_pp (m_lits.get (i), m) << "\n"; tout << "New literal: " << mk_pp (new_lit, m) << "\n"; @@ -932,7 +932,7 @@ namespace qe { if (!all_done) continue; // all args so far have been processed // get the correct arg to use - proof* pr = 0; expr* new_arg = 0; + proof* pr = nullptr; expr* new_arg = nullptr; factored_terms.get (old_arg, new_arg, pr); if (new_arg) { // changed @@ -965,7 +965,7 @@ namespace qe { mdl.register_decl (new_var->get_decl (), val); } if (changed) { - factored_terms.insert (e, new_term, 0); + factored_terms.insert (e, new_term, nullptr); } done.mark (e, true); todo.pop_back (); @@ -973,7 +973,7 @@ namespace qe { } // mk new fml - proof* pr = 0; expr* new_fml = 0; + proof* pr = nullptr; expr* new_fml = nullptr; factored_terms.get (fml, new_fml, pr); if (new_fml) { fml = new_fml; @@ -994,9 +994,9 @@ namespace qe { * the divisibility atom is a special mod term ((t1-t2) % num == 0) */ void mod2div (expr_ref& fml, expr_map& map) { - expr* new_fml = 0; + expr* new_fml = nullptr; - proof *pr = 0; + proof *pr = nullptr; map.get (fml, new_fml, pr); if (new_fml) { fml = new_fml; @@ -1065,7 +1065,7 @@ namespace qe { new_fml = m.mk_app (a->get_decl (), children.size (), children.c_ptr ()); } - map.insert (fml, new_fml, 0); + map.insert (fml, new_fml, nullptr); fml = new_fml; } @@ -1133,7 +1133,7 @@ namespace qe { z); } } - map.insert (m_lits.get (i), new_lit, 0); + map.insert (m_lits.get (i), new_lit, nullptr); TRACE ("qe", tout << "Old literal: " << mk_pp (m_lits.get (i), m) << "\n"; tout << "New literal: " << mk_pp (new_lit, m) << "\n"; @@ -1145,7 +1145,7 @@ namespace qe { expr_substitution sub (m); // literals for (unsigned i = 0; i < lits.size (); i++) { - expr* new_lit = 0; proof* pr = 0; + expr* new_lit = nullptr; proof* pr = nullptr; app* old_lit = lits.get (i); map.get (old_lit, new_lit, pr); if (new_lit) { @@ -1157,7 +1157,7 @@ namespace qe { } } // substitute for x, if any - expr* x_term = 0; proof* pr = 0; + expr* x_term = nullptr; proof* pr = nullptr; map.get (m_var->x (), x_term, pr); if (x_term) { sub.insert (m_var->x (), x_term); @@ -1292,9 +1292,9 @@ namespace qe { model_evaluator_array_util m_mev; void reset_v () { - m_v = 0; + m_v = nullptr; m_has_stores_v.reset (); - m_subst_term_v = 0; + m_subst_term_v = nullptr; m_true_sub_v.reset (); m_false_sub_v.reset (); m_aux_lits_v.reset (); @@ -1302,7 +1302,7 @@ namespace qe { } void reset () { - M = 0; + M = nullptr; reset_v (); m_aux_vars.reset (); } @@ -1393,7 +1393,7 @@ namespace qe { todo.push_back (to_app (arg)); } else if (all_done) { // all done so far.. - expr* arg_new = 0; proof* pr; + expr* arg_new = nullptr; proof* pr; sel_cache.get (arg, arg_new, pr); if (!arg_new) { arg_new = arg; @@ -1423,12 +1423,12 @@ namespace qe { } if (a != a_new) { - sel_cache.insert (a, a_new, 0); + sel_cache.insert (a, a_new, nullptr); pinned.push_back (a_new); } done.mark (a, true); } - expr* res = 0; proof* pr; + expr* res = nullptr; proof* pr; sel_cache.get (fml, res, pr); if (res) { fml = to_app (res); @@ -1478,7 +1478,7 @@ namespace qe { void find_subst_term (app* eq) { app_ref p_exp (m); - mk_peq (eq->get_arg (0), eq->get_arg (1), 0, 0, p_exp); + mk_peq (eq->get_arg (0), eq->get_arg (1), 0, nullptr, p_exp); bool subst_eq_found = false; while (true) { TRACE ("qe", @@ -1672,7 +1672,7 @@ namespace qe { expr* rhs = eq->get_arg (1); bool lhs_has_v = (lhs == m_v || m_has_stores_v.is_marked (lhs)); bool rhs_has_v = (rhs == m_v || m_has_stores_v.is_marked (rhs)); - app* store = 0; + app* store = nullptr; SASSERT (lhs_has_v || rhs_has_v); @@ -1829,7 +1829,7 @@ namespace qe { m_cache.reset (); m_pinned.reset (); m_idx_lits.reset (); - M = 0; + M = nullptr; m_arr_test.reset (); m_has_stores.reset (); m_reduce_all_selects = false; @@ -1864,7 +1864,7 @@ namespace qe { bool reduce (expr_ref& e) { if (!is_app (e)) return true; - expr *r = 0; + expr *r = nullptr; if (m_cache.find (e, r)) { e = r; return true; @@ -1882,7 +1882,7 @@ namespace qe { for (unsigned i = 0; i < a->get_num_args (); ++i) { expr *arg = a->get_arg (i); - expr *narg = 0; + expr *narg = nullptr; if (!is_app (arg)) args.push_back (arg); else if (m_cache.find (arg, narg)) { @@ -2025,7 +2025,7 @@ namespace qe { m_idx_vals.reset (); m_sel_consts.reset (); m_idx_lits.reset (); - M = 0; + M = nullptr; m_sub.reset (); m_arr_test.reset (); } diff --git a/src/muz/spacer/spacer_smt_context_manager.cpp b/src/muz/spacer/spacer_smt_context_manager.cpp index e6ab2c883..e26381afd 100644 --- a/src/muz/spacer/spacer_smt_context_manager.cpp +++ b/src/muz/spacer/spacer_smt_context_manager.cpp @@ -50,7 +50,7 @@ smt_context_manager::~smt_context_manager() virtual_solver* smt_context_manager::mk_fresh() { ++m_num_contexts; - virtual_solver_factory *solver_factory = 0; + virtual_solver_factory *solver_factory = nullptr; if (m_max_num_contexts == 0 || m_solvers.size() < m_max_num_contexts) { m_solvers.push_back(alloc(spacer::virtual_solver_factory, m, m_fparams)); diff --git a/src/muz/spacer/spacer_sym_mux.h b/src/muz/spacer/spacer_sym_mux.h index 892542557..a4d10971a 100644 --- a/src/muz/spacer/spacer_sym_mux.h +++ b/src/muz/spacer/spacer_sym_mux.h @@ -126,7 +126,7 @@ public: { func_decl * res; if(!m_prefix2prim.find(prefix, res)) { - return 0; + return nullptr; } return res; } @@ -138,7 +138,7 @@ public: { func_decl * prim = try_get_primary_by_prefix(prefix); if(!prim) { - return 0; + return nullptr; } return conv(prim, 0, idx); } diff --git a/src/muz/spacer/spacer_unsat_core_plugin.cpp b/src/muz/spacer/spacer_unsat_core_plugin.cpp index af9230713..a1a937de0 100644 --- a/src/muz/spacer/spacer_unsat_core_plugin.cpp +++ b/src/muz/spacer/spacer_unsat_core_plugin.cpp @@ -506,7 +506,7 @@ void unsat_core_plugin_farkas_lemma::compute_linear_combination(const vectorcheck_sat(0,0); + lbool res = s->check_sat(0,nullptr); // if sat extract model and add corresponding linear combinations to core if (res == lbool::l_true) { diff --git a/src/muz/spacer/spacer_util.cpp b/src/muz/spacer/spacer_util.cpp index 83042cd6d..cdec5d7eb 100644 --- a/src/muz/spacer/spacer_util.cpp +++ b/src/muz/spacer/spacer_util.cpp @@ -72,17 +72,17 @@ namespace spacer { // model_evaluator_util::model_evaluator_util(ast_manager& m) : - m(m), m_mev(nullptr) { - reset (nullptr); + m(m), m_mev(nullptr) { + reset (nullptr); } - model_evaluator_util::~model_evaluator_util() {reset (NULL);} + model_evaluator_util::~model_evaluator_util() {reset (nullptr);} void model_evaluator_util::reset(model* model) { if (m_mev) { dealloc(m_mev); - m_mev = NULL; + m_mev = nullptr; } m_model = model; if (!m_model) { return; } diff --git a/src/muz/spacer/spacer_util.h b/src/muz/spacer/spacer_util.h index 7fb17329e..7be2ee4b3 100644 --- a/src/muz/spacer/spacer_util.h +++ b/src/muz/spacer/spacer_util.h @@ -162,7 +162,7 @@ void find_decls (expr* fml, app_ref_vector& decls, std::string& prefix); struct mk_epp : public mk_pp { params_ref m_epp_params; expr_ref m_epp_expr; - mk_epp(ast *t, ast_manager &m, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0); + mk_epp(ast *t, ast_manager &m, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = nullptr); void rw(expr *e, expr_ref &out); }; diff --git a/src/muz/spacer/spacer_virtual_solver.cpp b/src/muz/spacer/spacer_virtual_solver.cpp index 938e8cb94..562fc1ee0 100644 --- a/src/muz/spacer/spacer_virtual_solver.cpp +++ b/src/muz/spacer/spacer_virtual_solver.cpp @@ -257,14 +257,14 @@ void virtual_solver::get_labels(svector &r) { r.reset(); buffer tmp; - m_context.get_relevant_labels(0, tmp); + m_context.get_relevant_labels(nullptr, tmp); r.append(tmp.size(), tmp.c_ptr()); } solver* virtual_solver::translate(ast_manager& m, params_ref const& p) { UNREACHABLE(); - return 0; + return nullptr; } void virtual_solver::updt_params(params_ref const &p) { m_factory.updt_params(p); } diff --git a/src/muz/tab/tab_context.cpp b/src/muz/tab/tab_context.cpp index 8809c0dc7..da5a96e2c 100644 --- a/src/muz/tab/tab_context.cpp +++ b/src/muz/tab/tab_context.cpp @@ -1129,7 +1129,7 @@ namespace tb { } else { change = true; - m_rename.push_back(0); + m_rename.push_back(nullptr); } } if (change) { diff --git a/src/muz/transforms/dl_mk_array_blast.cpp b/src/muz/transforms/dl_mk_array_blast.cpp index 8fe3f0e43..6894cf4fa 100644 --- a/src/muz/transforms/dl_mk_array_blast.cpp +++ b/src/muz/transforms/dl_mk_array_blast.cpp @@ -176,7 +176,7 @@ namespace datalog { if (m_defs.find(e1, v)) { cache.insert(e, v); } - else if (!insert_def(r, e1, 0)) { + else if (!insert_def(r, e1, nullptr)) { return false; } else { @@ -320,7 +320,7 @@ namespace datalog { rule_set * mk_array_blast::operator()(rule_set const & source) { if (!m_ctx.array_blast ()) { - return 0; + return nullptr; } rule_set* rules = alloc(rule_set, m_ctx); rules->inherit_predicates(source); @@ -331,7 +331,7 @@ namespace datalog { } if (!change) { dealloc(rules); - rules = 0; + rules = nullptr; } return rules; } diff --git a/src/muz/transforms/dl_mk_bit_blast.cpp b/src/muz/transforms/dl_mk_bit_blast.cpp index 8637af14f..a9461c1e3 100644 --- a/src/muz/transforms/dl_mk_bit_blast.cpp +++ b/src/muz/transforms/dl_mk_bit_blast.cpp @@ -138,8 +138,8 @@ namespace datalog { m_g_vars(m), m_old_funcs(m), m_new_funcs(m), - m_src(0), - m_dst(0) + m_src(nullptr), + m_dst(nullptr) {} ~expand_mkbv_cfg() {} @@ -186,7 +186,7 @@ namespace datalog { m_g_vars.push_back(m_f_vars.back()); } } - func_decl* g = 0; + func_decl* g = nullptr; if (!m_pred2blast.find(f, g)) { @@ -202,7 +202,7 @@ namespace datalog { m_dst->inherit_predicate(*m_src, f, g); } result = m.mk_app(g, m_args.size(), m_args.c_ptr()); - result_pr = 0; + result_pr = nullptr; return BR_DONE; } }; @@ -262,7 +262,7 @@ namespace datalog { rule_set * operator()(rule_set const & source) { // TODO pc if (!m_context.xform_bit_blast()) { - return 0; + return nullptr; } rule_manager& rm = m_context.get_rule_manager(); unsigned sz = source.get_num_rules(); diff --git a/src/muz/transforms/dl_mk_coi_filter.cpp b/src/muz/transforms/dl_mk_coi_filter.cpp index 2ca64aa68..53722a22c 100644 --- a/src/muz/transforms/dl_mk_coi_filter.cpp +++ b/src/muz/transforms/dl_mk_coi_filter.cpp @@ -45,7 +45,7 @@ namespace datalog { for (unsigned i = 0; i < r->get_uninterpreted_tail_size(); ++i) { func_decl* decl_i = r->get_decl(i); if (m_context.has_facts(decl_i)) { - return 0; + return nullptr; } bool reachable = engine.get_fact(decl_i).is_reachable(); @@ -93,7 +93,7 @@ namespace datalog { } if (res->get_num_rules() == source.get_num_rules()) { TRACE("dl", tout << "No transformation\n";); - res = 0; + res = nullptr; } else { res->close(); @@ -134,7 +134,7 @@ namespace datalog { if (res->get_num_rules() == source.get_num_rules()) { TRACE("dl", tout << "No transformation\n";); - res = 0; + res = nullptr; } if (res && m_context.get_model_converter()) { extension_model_converter* mc0 = alloc(extension_model_converter, m); diff --git a/src/muz/transforms/dl_mk_filter_rules.cpp b/src/muz/transforms/dl_mk_filter_rules.cpp index a8c13fc17..b5dfb84ec 100644 --- a/src/muz/transforms/dl_mk_filter_rules.cpp +++ b/src/muz/transforms/dl_mk_filter_rules.cpp @@ -29,7 +29,7 @@ namespace datalog { m_context(ctx), m(ctx.get_manager()), rm(ctx.get_rule_manager()), - m_result(0), + m_result(nullptr), m_pinned(m) { } @@ -89,7 +89,7 @@ namespace datalog { app_ref filter_head(m); filter_head = m.mk_app(filter_decl, key->filter_args.size(), key->filter_args.c_ptr()); app * filter_tail = key->new_pred; - rule * filter_rule = m_context.get_rule_manager().mk(filter_head, 1, &filter_tail, (const bool *)0); + rule * filter_rule = m_context.get_rule_manager().mk(filter_head, 1, &filter_tail, (const bool *)nullptr); filter_rule->set_accounting_parent_object(m_context, m_current); m_result->add_rule(filter_rule); m_context.get_rule_manager().mk_rule_asserted_proof(*filter_rule); @@ -161,7 +161,7 @@ namespace datalog { } if(!m_modified) { dealloc(m_result); - return static_cast(0); + return static_cast(nullptr); } m_result->inherit_predicates(source); return m_result; diff --git a/src/muz/transforms/dl_mk_interp_tail_simplifier.cpp b/src/muz/transforms/dl_mk_interp_tail_simplifier.cpp index 8421a99ba..38000c65a 100644 --- a/src/muz/transforms/dl_mk_interp_tail_simplifier.cpp +++ b/src/muz/transforms/dl_mk_interp_tail_simplifier.cpp @@ -222,20 +222,20 @@ namespace datalog { */ app * detect_equivalence(const arg_pair& p1, const arg_pair& p2, bool inside_disjunction) { - if (m.is_not(p1.first)==m.is_not(p2.first)) { return 0; } - if (m.is_not(p1.second)==m.is_not(p2.second)) { return 0; } + if (m.is_not(p1.first)==m.is_not(p2.first)) { return nullptr; } + if (m.is_not(p1.second)==m.is_not(p2.second)) { return nullptr; } - expr * first_bare = 0; - if (m.is_not(p1.first, first_bare) && p2.first!=first_bare) { return 0; } - if (m.is_not(p2.first, first_bare) && p1.first!=first_bare) { return 0; } + expr * first_bare = nullptr; + if (m.is_not(p1.first, first_bare) && p2.first!=first_bare) { return nullptr; } + if (m.is_not(p2.first, first_bare) && p1.first!=first_bare) { return nullptr; } SASSERT(first_bare); - expr * second_bare = 0; - if (m.is_not(p1.second, second_bare) && p2.second!=second_bare) { return 0; } - if (m.is_not(p2.second, second_bare) && p1.second!=second_bare) { return 0; } + expr * second_bare = nullptr; + if (m.is_not(p1.second, second_bare) && p2.second!=second_bare) { return nullptr; } + if (m.is_not(p2.second, second_bare) && p1.second!=second_bare) { return nullptr; } SASSERT(second_bare); - if (!m.is_bool(first_bare) || !m.is_bool(second_bare)) { return 0; } + if (!m.is_bool(first_bare) || !m.is_bool(second_bare)) { return nullptr; } //both negations are in the same pair bool negs_together = m.is_not(p1.first)==m.is_not(p1.second); @@ -261,7 +261,7 @@ namespace datalog { arg_pair new_ap; if (match_arg_pair(e, new_ap, inside_disjunction)) { - app * neq = 0; + app * neq = nullptr; if (have_pair) { neq = detect_equivalence(ap, new_ap, inside_disjunction); } @@ -601,7 +601,7 @@ namespace datalog { rule_set * mk_interp_tail_simplifier::operator()(rule_set const & source) { if (source.get_num_rules() == 0) { - return 0; + return nullptr; } rule_set * res = alloc(rule_set, m_context); @@ -612,7 +612,7 @@ namespace datalog { res->display(tout);); } else { dealloc(res); - res = 0; + res = nullptr; } return res; } diff --git a/src/muz/transforms/dl_mk_interp_tail_simplifier.h b/src/muz/transforms/dl_mk_interp_tail_simplifier.h index e9120b9b1..713827588 100644 --- a/src/muz/transforms/dl_mk_interp_tail_simplifier.h +++ b/src/muz/transforms/dl_mk_interp_tail_simplifier.h @@ -44,7 +44,7 @@ namespace datalog { void apply(app * a, app_ref& res); public: rule_substitution(context & ctx) - : m(ctx.get_manager()), m_context(ctx), m_subst(m), m_unif(m), m_head(m), m_tail(m), m_rule(0) {} + : m(ctx.get_manager()), m_context(ctx), m_subst(m), m_unif(m), m_head(m), m_tail(m), m_rule(nullptr) {} /** Reset substitution and get it ready for working with rule r. diff --git a/src/muz/transforms/dl_mk_karr_invariants.cpp b/src/muz/transforms/dl_mk_karr_invariants.cpp index 5dafafb19..a17aecd15 100644 --- a/src/muz/transforms/dl_mk_karr_invariants.cpp +++ b/src/muz/transforms/dl_mk_karr_invariants.cpp @@ -191,13 +191,13 @@ namespace datalog { rule_set * mk_karr_invariants::operator()(rule_set const & source) { if (!m_ctx.karr()) { - return 0; + return nullptr; } rule_set::iterator it = source.begin(), end = source.end(); for (; it != end; ++it) { rule const& r = **it; if (r.has_negation()) { - return 0; + return nullptr; } } mk_loop_counter lc(m_ctx); @@ -209,7 +209,7 @@ namespace datalog { get_invariants(*src_loop); if (m.canceled()) { - return 0; + return nullptr; } // figure out whether to update same rules as used for saturation. @@ -248,7 +248,7 @@ namespace datalog { func_decl* p = dit->m_key; expr_ref fml = rctx.try_get_formula(p); if (fml && !m.is_true(fml)) { - expr* inv = 0; + expr* inv = nullptr; if (m_fun2inv.find(p, inv)) { fml = m.mk_and(inv, fml); } @@ -270,7 +270,7 @@ namespace datalog { rule_set::decl2rules::iterator gend = src.end_grouped_rules(); for (; git != gend; ++git) { func_decl* p = git->m_key; - expr* fml = 0; + expr* fml = nullptr; if (m_fun2inv.find(p, fml)) { kmc->add(p, fml); } @@ -292,7 +292,7 @@ namespace datalog { } for (unsigned i = 0; i < utsz; ++i) { func_decl* q = r.get_decl(i); - expr* fml = 0; + expr* fml = nullptr; if (m_fun2inv.find(q, fml)) { expr_safe_replace rep(m); for (unsigned j = 0; j < q->get_arity(); ++j) { @@ -306,7 +306,7 @@ namespace datalog { } rule* new_rule = &r; if (tail.size() != tsz) { - new_rule = rm.mk(r.get_head(), tail.size(), tail.c_ptr(), 0, r.name()); + new_rule = rm.mk(r.get_head(), tail.size(), tail.c_ptr(), nullptr, r.name()); } rules.add_rule(new_rule); rm.mk_rule_rewrite_proof(r, *new_rule); // should be weakening rule. diff --git a/src/muz/transforms/dl_mk_loop_counter.cpp b/src/muz/transforms/dl_mk_loop_counter.cpp index 62568640c..1aea7be45 100644 --- a/src/muz/transforms/dl_mk_loop_counter.cpp +++ b/src/muz/transforms/dl_mk_loop_counter.cpp @@ -56,7 +56,7 @@ namespace datalog { app_ref mk_loop_counter::del_arg(app* fn) { expr_ref_vector args(m); - func_decl* old_fn = 0, *new_fn = fn->get_decl(); + func_decl* old_fn = nullptr, *new_fn = fn->get_decl(); SASSERT(fn->get_num_args() > 0); args.append(fn->get_num_args()-1, fn->get_args()); VERIFY (m_new2old.find(new_fn, old_fn)); diff --git a/src/muz/transforms/dl_mk_magic_sets.cpp b/src/muz/transforms/dl_mk_magic_sets.cpp index 15a4c1093..0de37a4ce 100644 --- a/src/muz/transforms/dl_mk_magic_sets.cpp +++ b/src/muz/transforms/dl_mk_magic_sets.cpp @@ -129,9 +129,9 @@ namespace datalog { SASSERT(m.is_bool(old_pred->get_range())); adornment_desc adn(old_pred); adn.m_adornment.populate(lit, bound_vars); - adornment_map::entry * e = m_adorned_preds.insert_if_not_there2(adn, 0); + adornment_map::entry * e = m_adorned_preds.insert_if_not_there2(adn, nullptr); func_decl * new_pred = e->get_data().m_value; - if (new_pred==0) { + if (new_pred==nullptr) { std::string suffix = "ad_"+adn.m_adornment.to_string(); new_pred = m_context.mk_fresh_head_predicate( old_pred->get_name(), symbol(suffix.c_str()), @@ -163,7 +163,7 @@ namespace datalog { pred2pred::obj_map_entry * e = m_magic_preds.insert_if_not_there2(l_pred, 0); func_decl * mag_pred = e->get_data().m_value; - if (mag_pred==0) { + if (mag_pred==nullptr) { unsigned mag_arity = bound_args.size(); ptr_vector mag_domain; @@ -264,7 +264,7 @@ namespace datalog { } - func_decl * new_head_pred = 0; + func_decl * new_head_pred = nullptr; VERIFY( m_adorned_preds.find(adornment_desc(head->get_decl(), head_adornment), new_head_pred) ); app * new_head = m.mk_app(new_head_pred, head->get_args()); @@ -301,14 +301,14 @@ namespace datalog { app * tail[] = {lit, mag_lit}; - rule * r = m_context.get_rule_manager().mk(adn_lit, 2, tail, 0); + rule * r = m_context.get_rule_manager().mk(adn_lit, 2, tail, nullptr); result.add_rule(r); } rule_set * mk_magic_sets::operator()(rule_set const & source) { if (!m_context.magic_sets_for_queries()) { - return 0; + return nullptr; } SASSERT(source.contains(m_goal)); SASSERT(source.get_predicate_rules(m_goal).size() == 1); @@ -372,10 +372,10 @@ namespace datalog { app * adn_goal_head = adorn_literal(goal_head, empty_var_idx_set); app * mag_goal_head = create_magic_literal(adn_goal_head); SASSERT(mag_goal_head->is_ground()); - rule * mag_goal_rule = m_context.get_rule_manager().mk(mag_goal_head, 0, 0, 0); + rule * mag_goal_rule = m_context.get_rule_manager().mk(mag_goal_head, 0, nullptr, nullptr); result->add_rule(mag_goal_rule); - rule * back_to_goal_rule = m_context.get_rule_manager().mk(goal_head, 1, &adn_goal_head, 0); + rule * back_to_goal_rule = m_context.get_rule_manager().mk(goal_head, 1, &adn_goal_head, nullptr); result->add_rule(back_to_goal_rule); return result; } diff --git a/src/muz/transforms/dl_mk_magic_symbolic.cpp b/src/muz/transforms/dl_mk_magic_symbolic.cpp index 2edc57375..0e2e4991a 100644 --- a/src/muz/transforms/dl_mk_magic_symbolic.cpp +++ b/src/muz/transforms/dl_mk_magic_symbolic.cpp @@ -68,7 +68,7 @@ namespace datalog { rule_set * mk_magic_symbolic::operator()(rule_set const & source) { if (!m_ctx.magic()) { - return 0; + return nullptr; } context& ctx = source.get_context(); rule_manager& rm = source.get_rule_manager(); @@ -98,7 +98,7 @@ namespace datalog { result->add_rule(new_rule); if (source.is_output_predicate(r.get_decl())) { result->set_output_predicate(new_rule->get_decl()); - new_rule = rm.mk(mk_query(r.get_head()), 0, 0, 0, r.name(), true); + new_rule = rm.mk(mk_query(r.get_head()), 0, nullptr, nullptr, r.name(), true); result->add_rule(new_rule); } diff --git a/src/muz/transforms/dl_mk_quantifier_abstraction.cpp b/src/muz/transforms/dl_mk_quantifier_abstraction.cpp index a4a5ac35f..744efdb93 100644 --- a/src/muz/transforms/dl_mk_quantifier_abstraction.cpp +++ b/src/muz/transforms/dl_mk_quantifier_abstraction.cpp @@ -143,7 +143,7 @@ namespace datalog { m_ctx(ctx), a(m), m_refs(m), - m_mc(NULL){ + m_mc(nullptr) { } mk_quantifier_abstraction::~mk_quantifier_abstraction() { @@ -153,7 +153,7 @@ namespace datalog { if (rules.is_output_predicate(old_p)) { dst.inherit_predicate(rules, old_p, old_p); - return 0; + return nullptr; } unsigned sz = old_p->get_arity(); @@ -164,10 +164,10 @@ namespace datalog { } } if (num_arrays == 0) { - return 0; + return nullptr; } - func_decl* new_p = 0; + func_decl* new_p = nullptr; if (!m_old2new.find(old_p, new_p)) { expr_ref_vector sub(m), vars(m); svector bound; @@ -281,7 +281,7 @@ namespace datalog { } args.push_back(arg); } - expr* pat = 0; + expr* pat = nullptr; expr_ref pattern(m); pattern = m.mk_pattern(pats.size(), pats.c_ptr()); pat = pattern.get(); @@ -301,13 +301,13 @@ namespace datalog { rule_set * mk_quantifier_abstraction::operator()(rule_set const & source) { if (!m_ctx.quantify_arrays()) { - return 0; + return nullptr; } unsigned sz = source.get_num_rules(); for (unsigned i = 0; i < sz; ++i) { rule& r = *source.get_rule(i); if (r.has_negation()) { - return 0; + return nullptr; } } @@ -351,12 +351,12 @@ namespace datalog { if (m_old2new.empty()) { dealloc(result); dealloc(m_mc); - result = 0; + result = nullptr; } else { m_ctx.add_model_converter(m_mc); } - m_mc = 0; + m_mc = nullptr; return result; } diff --git a/src/muz/transforms/dl_mk_quantifier_instantiation.cpp b/src/muz/transforms/dl_mk_quantifier_instantiation.cpp index 8986bf506..4cbcc5712 100644 --- a/src/muz/transforms/dl_mk_quantifier_instantiation.cpp +++ b/src/muz/transforms/dl_mk_quantifier_instantiation.cpp @@ -139,7 +139,7 @@ namespace datalog { return; } expr* arg = pat->get_arg(i); - ptr_vector* terms = 0; + ptr_vector* terms = nullptr; if (m_funs.find(to_app(arg)->get_decl(), terms)) { for (unsigned k = 0; k < terms->size(); ++k) { @@ -185,7 +185,7 @@ namespace datalog { } if (is_app(e)) { app* ap = to_app(e); - ptr_vector* terms = 0; + ptr_vector* terms = nullptr; if (!m_funs.find(ap->get_decl(), terms)) { terms = alloc(ptr_vector); m_funs.insert(ap->get_decl(), terms); @@ -250,7 +250,7 @@ namespace datalog { rule_set * mk_quantifier_instantiation::operator()(rule_set const & source) { if (!m_ctx.instantiate_quantifiers()) { - return 0; + return nullptr; } bool has_quantifiers = false; unsigned sz = source.get_num_rules(); @@ -259,11 +259,11 @@ namespace datalog { rule& r = *source.get_rule(i); has_quantifiers = has_quantifiers || rm.has_quantifiers(r); if (r.has_negation()) { - return 0; + return nullptr; } } if (!has_quantifiers) { - return 0; + return nullptr; } expr_ref_vector conjs(m); @@ -291,7 +291,7 @@ namespace datalog { } else { dealloc(result); - result = 0; + result = nullptr; } return result; } diff --git a/src/muz/transforms/dl_mk_rule_inliner.cpp b/src/muz/transforms/dl_mk_rule_inliner.cpp index f1a4eb32b..a9d2c7090 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.cpp +++ b/src/muz/transforms/dl_mk_rule_inliner.cpp @@ -549,16 +549,16 @@ namespace datalog { const rule_vector& pred_rules = rules.get_predicate_rules(pred); - rule * inlining_candidate = 0; + rule * inlining_candidate = nullptr; unsigned rule_cnt = pred_rules.size(); if (rule_cnt == 0) { - inlining_candidate = 0; + inlining_candidate = nullptr; } else if (rule_cnt == 1) { inlining_candidate = pred_rules[0]; } else { - inlining_candidate = 0; + inlining_candidate = nullptr; for (unsigned ri = 0; ri < rule_cnt; ++ri) { rule * pred_rule = pred_rules[ri]; @@ -566,7 +566,7 @@ namespace datalog { //we skip rules which don't unify with the tail atom continue; } - if (inlining_candidate != 0) { + if (inlining_candidate != nullptr) { // We have two rules that can be inlined into the current // tail predicate. In this situation we don't do inlinning // on this tail atom, as we don't want the overall number @@ -576,10 +576,10 @@ namespace datalog { inlining_candidate = pred_rule; } } - if (inlining_candidate == 0) { + if (inlining_candidate == nullptr) { // nothing unifies with the tail atom, therefore the rule is unsatisfiable // (we can say this because relation pred doesn't have any ground facts either) - res = 0; + res = nullptr; datalog::del_rule(m_mc, *r, false); return true; } @@ -591,7 +591,7 @@ namespace datalog { } if (!try_to_inline_rule(*r, *inlining_candidate, ti, res)) { datalog::del_rule(m_mc, *r, false); - res = 0; + res = nullptr; } return true; @@ -852,13 +852,13 @@ namespace datalog { ref hsmc; if (source.get_num_rules() == 0) { - return 0; + return nullptr; } rule_set::iterator end = source.end(); for (rule_set::iterator it = source.begin(); it != end; ++ it) { if (has_quantifier(**it)) { - return 0; + return nullptr; } } @@ -893,7 +893,7 @@ namespace datalog { } if (!something_done) { - res = 0; + res = nullptr; } else { m_context.add_model_converter(hsmc.get()); diff --git a/src/muz/transforms/dl_mk_rule_inliner.h b/src/muz/transforms/dl_mk_rule_inliner.h index 7b00d26ad..27b6dd418 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.h +++ b/src/muz/transforms/dl_mk_rule_inliner.h @@ -186,7 +186,7 @@ namespace datalog { m_simp(m_context.get_rewriter()), m_pinned(m_rm), m_inlined_rules(m_context), - m_mc(0), + m_mc(nullptr), m_unifier(ctx), m_head_index(m), m_tail_index(m), diff --git a/src/muz/transforms/dl_mk_scale.cpp b/src/muz/transforms/dl_mk_scale.cpp index abc5d20e7..49a8ff423 100644 --- a/src/muz/transforms/dl_mk_scale.cpp +++ b/src/muz/transforms/dl_mk_scale.cpp @@ -97,7 +97,7 @@ namespace datalog { model_converter * translate(ast_translation & translator) override { UNREACHABLE(); - return 0; + return nullptr; } }; @@ -116,7 +116,7 @@ namespace datalog { rule_set * mk_scale::operator()(rule_set const & source) { if (!m_ctx.scale()) { - return 0; + return nullptr; } rule_manager& rm = source.get_rule_manager(); rule_set * result = alloc(rule_set, m_ctx); diff --git a/src/muz/transforms/dl_mk_separate_negated_tails.cpp b/src/muz/transforms/dl_mk_separate_negated_tails.cpp index 3da759f9b..c50aba827 100644 --- a/src/muz/transforms/dl_mk_separate_negated_tails.cpp +++ b/src/muz/transforms/dl_mk_separate_negated_tails.cpp @@ -127,7 +127,7 @@ namespace datalog { } } if (!has_new_rule) { - return 0; + return nullptr; } else { result->inherit_predicates(src); diff --git a/src/muz/transforms/dl_mk_slice.cpp b/src/muz/transforms/dl_mk_slice.cpp index 3c5cf53c7..c6d08493c 100644 --- a/src/muz/transforms/dl_mk_slice.cpp +++ b/src/muz/transforms/dl_mk_slice.cpp @@ -155,8 +155,8 @@ namespace datalog { } bool translate_asserted(proof* p) { - expr* fact = 0; - rule* r = 0; + expr* fact = nullptr; + rule* r = nullptr; if (!m.is_asserted(p, fact)) { return false; } @@ -215,7 +215,7 @@ namespace datalog { proof* p1_new = m_new_proof.find(p1); expr* fact1 = m.get_fact(p1); TRACE("dl", tout << "fact1: " << mk_pp(fact1, m) << "\n";); - rule* orig1 = 0; + rule* orig1 = nullptr; if (!m_sliceform2rule.find(fact1, orig1)) { return false; } @@ -281,7 +281,7 @@ namespace datalog { proof_converter * translate(ast_translation & translator) override { UNREACHABLE(); // this would require implementing translation for the dl_context. - return 0; + return nullptr; } }; @@ -393,7 +393,7 @@ namespace datalog { model_converter * translate(ast_translation & translator) override { UNREACHABLE(); - return 0; + return nullptr; } }; @@ -405,8 +405,8 @@ namespace datalog { rm(ctx.get_rule_manager()), m_solved_vars(m), m_pinned(m), - m_pc(0), - m_mc(0) + m_pc(nullptr), + m_mc(nullptr) {} @@ -790,7 +790,7 @@ namespace datalog { tail.push_back(to_app(e)); } - new_rule = rm.mk(head.get(), tail.size(), tail.c_ptr(), (const bool*) 0, r.name()); + new_rule = rm.mk(head.get(), tail.size(), tail.c_ptr(), (const bool*) nullptr, r.name()); rm.fix_unbound_vars(new_rule, false); @@ -805,7 +805,7 @@ namespace datalog { dst.add_rule(new_rule.get()); if (m_pc) { - m_pc->insert(&r, new_rule.get(), 0, 0); + m_pc->insert(&r, new_rule.get(), 0, nullptr); } } @@ -819,7 +819,7 @@ namespace datalog { rule_manager& rm = m_ctx.get_rule_manager(); for (unsigned i = 0; i < src.get_num_rules(); ++i) { if (rm.has_quantifiers(*src.get_rule(i))) { - return 0; + return nullptr; } } ref spc; @@ -839,7 +839,7 @@ namespace datalog { if (m_predicates.empty()) { // nothing could be sliced. dealloc(result); - return 0; + return nullptr; } TRACE("dl", display(tout);); update_rules(src, *result); diff --git a/src/muz/transforms/dl_mk_subsumption_checker.cpp b/src/muz/transforms/dl_mk_subsumption_checker.cpp index c6bb2864b..1280b3e4b 100644 --- a/src/muz/transforms/dl_mk_subsumption_checker.cpp +++ b/src/muz/transforms/dl_mk_subsumption_checker.cpp @@ -297,7 +297,7 @@ namespace datalog { SASSERT(total_size>=rel_sz); if(total_size==rel_sz) { - on_discovered_total_relation(pred, 0); + on_discovered_total_relation(pred, nullptr); } } next_pred:; @@ -335,7 +335,7 @@ namespace datalog { rule_set * mk_subsumption_checker::operator()(rule_set const & source) { // TODO mc if (!m_context.get_params ().xform_subsumption_checker()) - return 0; + return nullptr; m_have_new_total_rule = false; collect_ground_unconditional_rule_heads(source); @@ -348,7 +348,7 @@ namespace datalog { if (!m_have_new_total_rule && !modified) { dealloc(res); - return 0; + return nullptr; } diff --git a/src/muz/transforms/dl_mk_unbound_compressor.cpp b/src/muz/transforms/dl_mk_unbound_compressor.cpp index 47ce20a76..7844c3144 100644 --- a/src/muz/transforms/dl_mk_unbound_compressor.cpp +++ b/src/muz/transforms/dl_mk_unbound_compressor.cpp @@ -346,7 +346,7 @@ namespace datalog { // TODO mc if (!m_context.compress_unbound()) { - return 0; + return nullptr; } m_modified = false; @@ -387,7 +387,7 @@ namespace datalog { } } - rule_set * result = static_cast(0); + rule_set * result = static_cast(nullptr); if (m_modified) { result = alloc(rule_set, m_context); unsigned fin_rule_cnt = m_rules.size(); diff --git a/src/nlsat/nlsat_explain.cpp b/src/nlsat/nlsat_explain.cpp index 8d32a0edf..ac16d9d68 100644 --- a/src/nlsat/nlsat_explain.cpp +++ b/src/nlsat/nlsat_explain.cpp @@ -146,7 +146,7 @@ namespace nlsat { m_todo(u), m_core1(s), m_core2(s), - m_result(0), + m_result(nullptr), m_evaluator(ev) { m_simplify_cores = false; m_full_dimensional = false; @@ -521,7 +521,7 @@ namespace nlsat { polynomial::var max_var(literal l) { atom * a = m_atoms[l.var()]; - if (a != 0) + if (a != nullptr) return a->max_var(); else return null_var; @@ -535,7 +535,7 @@ namespace nlsat { for (unsigned i = 0; i < sz; i++) { literal l = ls[i]; atom * a = m_atoms[l.var()]; - if (a != 0) { + if (a != nullptr) { var x = a->max_var(); SASSERT(x != null_var); if (max == null_var || x > max) @@ -705,7 +705,7 @@ namespace nlsat { m_result = &result; add_root_literal(k, y, i, p); reset_already_added(); - m_result = 0; + m_result = nullptr; } void add_root_literal(atom::kind k, var y, unsigned i, poly * p) { @@ -1232,7 +1232,7 @@ namespace nlsat { This method selects the equation of minimal degree in max. */ poly * select_eq(scoped_literal_vector & C, var max) { - poly * r = 0; + poly * r = nullptr; unsigned min_d = UINT_MAX; unsigned sz = C.size(); for (unsigned i = 0; i < sz; i++) { @@ -1289,7 +1289,7 @@ namespace nlsat { if (y >= max) continue; atom * eq = m_x2eq[y]; - if (eq == 0) + if (eq == nullptr) continue; SASSERT(eq->is_ineq_atom()); SASSERT(to_ineq_atom(eq)->size() == 1); @@ -1305,7 +1305,7 @@ namespace nlsat { } } } - return 0; + return nullptr; } /** @@ -1315,7 +1315,7 @@ namespace nlsat { // Simplify using equations in the core while (!C.empty()) { poly * eq = select_eq(C, max); - if (eq == 0) + if (eq == nullptr) break; TRACE("nlsat_simplify_core", tout << "using equality for simplifying core\n"; m_pm.display(tout, eq, m_solver.display_proc()); tout << "\n";); @@ -1325,7 +1325,7 @@ namespace nlsat { // Simplify using equations using variables from lower stages. while (!C.empty()) { ineq_atom * eq = select_lower_stage_eq(C, max); - if (eq == 0) + if (eq == nullptr) break; SASSERT(eq->size() == 1); SASSERT(!eq->is_even(0)); @@ -1456,7 +1456,7 @@ namespace nlsat { m_result = &result; process(num, ls); reset_already_added(); - m_result = 0; + m_result = nullptr; TRACE("nlsat_explain", tout << "[explain] result\n"; display(tout, result);); CASSERT("nlsat", check_already_added()); } @@ -1495,14 +1495,14 @@ namespace nlsat { project(m_ps, mx_var); } reset_already_added(); - m_result = 0; + m_result = nullptr; if (x != mx_var) { m_solver.restore_order(); } } else { reset_already_added(); - m_result = 0; + m_result = nullptr; } for (unsigned i = 0; i < result.size(); ++i) { result.set(i, ~result[i]); diff --git a/src/nlsat/nlsat_interval_set.cpp b/src/nlsat/nlsat_interval_set.cpp index 090f94eeb..922440fea 100644 --- a/src/nlsat/nlsat_interval_set.cpp +++ b/src/nlsat/nlsat_interval_set.cpp @@ -122,7 +122,7 @@ namespace nlsat { } void interval_set_manager::del(interval_set * s) { - if (s == 0) + if (s == nullptr) return; unsigned num = s->m_num_intervals; unsigned obj_sz = interval_set::get_obj_size(num); @@ -270,9 +270,9 @@ namespace nlsat { interval_set * interval_set_manager::mk_union(interval_set const * s1, interval_set const * s2) { TRACE("nlsat_interval", tout << "mk_union\ns1: "; display(tout, s1); tout << "\ns2: "; display(tout, s2); tout << "\n";); - if (s1 == 0 || s1 == s2) + if (s1 == nullptr || s1 == s2) return const_cast(s2); - if (s2 == 0) + if (s2 == nullptr) return const_cast(s1); if (s1->m_full) return const_cast(s1); @@ -514,22 +514,22 @@ namespace nlsat { } bool interval_set_manager::is_full(interval_set const * s) { - if (s == 0) + if (s == nullptr) return false; return s->m_full == 1; } unsigned interval_set_manager::num_intervals(interval_set const * s) const { - if (s == 0) return 0; + if (s == nullptr) return 0; return s->m_num_intervals; } bool interval_set_manager::subset(interval_set const * s1, interval_set const * s2) { if (s1 == s2) return true; - if (s1 == 0) + if (s1 == nullptr) return true; - if (s2 == 0) + if (s2 == nullptr) return false; if (s2->m_full) return true; @@ -616,7 +616,7 @@ namespace nlsat { } bool interval_set_manager::set_eq(interval_set const * s1, interval_set const * s2) { - if (s1 == 0 || s2 == 0) + if (s1 == nullptr || s2 == nullptr) return s1 == s2; if (s1->m_full || s2->m_full) return s1->m_full == s2->m_full; @@ -625,7 +625,7 @@ namespace nlsat { } bool interval_set_manager::eq(interval_set const * s1, interval_set const * s2) { - if (s1 == 0 || s2 == 0) + if (s1 == nullptr || s2 == nullptr) return s1 == s2; if (s1->m_num_intervals != s2->m_num_intervals) return false; @@ -674,7 +674,7 @@ namespace nlsat { void interval_set_manager::peek_in_complement(interval_set const * s, bool is_int, anum & w, bool randomize) { SASSERT(!is_full(s)); - if (s == 0) { + if (s == nullptr) { if (randomize) { int num = m_rand() % 2 == 0 ? 1 : -1; #define MAX_RANDOM_DEN_K 4 @@ -744,7 +744,7 @@ namespace nlsat { } void interval_set_manager::display(std::ostream & out, interval_set const * s) const { - if (s == 0) { + if (s == nullptr) { out << "{}"; return; } diff --git a/src/nlsat/nlsat_interval_set.h b/src/nlsat/nlsat_interval_set.h index 363d48de9..22d04b86a 100644 --- a/src/nlsat/nlsat_interval_set.h +++ b/src/nlsat/nlsat_interval_set.h @@ -40,7 +40,7 @@ namespace nlsat { /** \brief Return the empty set. */ - interval_set * mk_empty() { return 0; } + interval_set * mk_empty() { return nullptr; } /** \brief Return a set of composed of a single interval. @@ -64,7 +64,7 @@ namespace nlsat { \brief Return true if s is the empty set. */ bool is_empty(interval_set const * s) { - return s == 0; + return s == nullptr; } /** diff --git a/src/nlsat/nlsat_justification.h b/src/nlsat/nlsat_justification.h index 13759e035..61c6f40e2 100644 --- a/src/nlsat/nlsat_justification.h +++ b/src/nlsat/nlsat_justification.h @@ -54,8 +54,8 @@ namespace nlsat { void * m_data; public: enum kind { NULL_JST = 0, DECISION, CLAUSE, LAZY }; - justification():m_data(TAG(void *, static_cast(0), NULL_JST)) { SASSERT(is_null()); } - justification(bool):m_data(TAG(void *, static_cast(0), DECISION)) { SASSERT(is_decision()); } + justification():m_data(TAG(void *, nullptr, NULL_JST)) { SASSERT(is_null()); } + justification(bool):m_data(TAG(void *, nullptr, DECISION)) { SASSERT(is_decision()); } justification(clause * c):m_data(TAG(void *, c, CLAUSE)) { SASSERT(is_clause()); } justification(lazy_justification * j):m_data(TAG(void *, j, LAZY)) { SASSERT(is_lazy()); } kind get_kind() const { return static_cast(GET_TAG(m_data)); } diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 3358dd61a..9767448b1 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -110,10 +110,10 @@ namespace nlsat { display_var_proc const * m_proc; // display external var ids perm_display_var_proc(var_vector & perm): m_perm(perm), - m_proc(0) { + m_proc(nullptr) { } std::ostream& operator()(std::ostream & out, var x) const override { - if (m_proc == 0) + if (m_proc == nullptr) m_default_display_var(out, x); else (*m_proc)(out, m_perm[x]); @@ -197,7 +197,7 @@ namespace nlsat { bool_var b = mk_bool_var(); SASSERT(b == true_bool_var); literal true_lit(b, false); - mk_clause(1, &true_lit, false, 0); + mk_clause(1, &true_lit, false, nullptr); } void updt_params(params_ref const & _p) { @@ -259,11 +259,11 @@ namespace nlsat { void dec_ref(assumption) {} void inc_ref(_assumption_set a) { - if (a != 0) m_asm.inc_ref(a); + if (a != nullptr) m_asm.inc_ref(a); } void dec_ref(_assumption_set a) { - if (a != 0) m_asm.dec_ref(a); + if (a != nullptr) m_asm.dec_ref(a); } void inc_ref(bool_var b) { @@ -284,7 +284,7 @@ namespace nlsat { if (b == null_bool_var) return; atom * a = m_atoms[b]; - if (a == 0) + if (a == nullptr) return; SASSERT(a->ref_count() > 0); a->dec_ref(); @@ -377,7 +377,7 @@ namespace nlsat { unsigned max = 0; for (literal l : c) { atom const * a = m_atoms[l.var()]; - if (a == 0) + if (a == nullptr) continue; unsigned d = degree(a); if (d > max) @@ -429,7 +429,7 @@ namespace nlsat { void vars(literal l, var_vector& vs) { vs.reset(); atom * a = m_atoms[l.var()]; - if (a == 0) { + if (a == nullptr) { } else if (a->is_ineq_atom()) { @@ -492,7 +492,7 @@ namespace nlsat { } void del(atom * a) { - if (a == 0) + if (a == nullptr) return ; if (a->is_ineq_atom()) del(to_ineq_atom(a)); @@ -664,11 +664,11 @@ namespace nlsat { bool operator()(literal l1, literal l2) const { atom * a1 = m.m_atoms[l1.var()]; atom * a2 = m.m_atoms[l2.var()]; - if (a1 == 0 && a2 == 0) + if (a1 == nullptr && a2 == nullptr) return l1.index() < l2.index(); - if (a1 == 0) + if (a1 == nullptr) return true; - if (a2 == 0) + if (a2 == nullptr) return false; var x1 = a1->max_var(); var x2 = a2->max_var(); @@ -712,8 +712,8 @@ namespace nlsat { void mk_clause(unsigned num_lits, literal const * lits, assumption a) { SASSERT(num_lits > 0); - _assumption_set as = 0; - if (a != 0) + _assumption_set as = nullptr; + if (a != nullptr) as = m_asm.mk_leaf(a); mk_clause(num_lits, lits, false, as); } @@ -931,7 +931,7 @@ namespace nlsat { } bool_var b = l.var(); atom * a = m_atoms[b]; - if (a == 0) { + if (a == nullptr) { return l_undef; } var max = a->max_var(); @@ -1037,7 +1037,7 @@ namespace nlsat { if (m_bvalues[b] != l_true) return; atom * a = m_atoms[b]; - if (a == 0 || a->get_kind() != atom::EQ || to_ineq_atom(a)->size() > 1 || to_ineq_atom(a)->is_even(0)) + if (a == nullptr || a->get_kind() != atom::EQ || to_ineq_atom(a)->size() > 1 || to_ineq_atom(a)->is_even(0)) return; var x = m_xk; SASSERT(a->max_var() == x); @@ -1082,13 +1082,13 @@ namespace nlsat { TRACE("nlsat_inf_set", tout << "infeasible set for literal: "; display(tout, l); tout << "\n"; m_ism.display(tout, curr_set); tout << "\n";); if (m_ism.is_empty(curr_set)) { TRACE("nlsat_inf_set", tout << "infeasible set is empty, found literal\n";); - R_propagate(l, 0); + R_propagate(l, nullptr); SASSERT(is_satisfied(cls)); return true; } if (m_ism.is_full(curr_set)) { TRACE("nlsat_inf_set", tout << "infeasible set is R, skip literal\n";); - R_propagate(~l, 0); + R_propagate(~l, nullptr); continue; } if (m_ism.subset(curr_set, xk_set)) { @@ -1155,7 +1155,7 @@ namespace nlsat { if (!process_clause(*c, false)) return c; } - return 0; // succeeded + return nullptr; // succeeded } /** @@ -1235,7 +1235,7 @@ namespace nlsat { conflict_clause = process_clauses(m_bwatches[m_bk]); else conflict_clause = process_clauses(m_watches[m_xk]); - if (conflict_clause == 0) + if (conflict_clause == nullptr) break; if (!resolve(*conflict_clause)) return l_false; @@ -1299,7 +1299,7 @@ namespace nlsat { m_lemma.push_back(~mk_ineq_literal(atom::LT, 1, &p2, &is_even)); // perform branch and bound - clause * cls = mk_clause(m_lemma.size(), m_lemma.c_ptr(), false, 0); + clause * cls = mk_clause(m_lemma.size(), m_lemma.c_ptr(), false, nullptr); if (cls) { TRACE("nlsat", display(tout << "conflict " << lo << " " << hi, *cls); tout << "\n";); } @@ -1403,7 +1403,7 @@ namespace nlsat { unsigned sz = assumptions.size(); literal const* ptr = assumptions.c_ptr(); _assumption_set asms = static_cast<_assumption_set>(c.assumptions()); - if (asms == 0) { + if (asms == nullptr) { return false; } vector deps; @@ -1663,7 +1663,7 @@ namespace nlsat { m_num_marks = 0; m_lemma.reset(); - m_lemma_assumptions = 0; + m_lemma_assumptions = nullptr; resolve_clause(null_bool_var, *conflict_clause); @@ -1757,7 +1757,7 @@ namespace nlsat { // in a previous scope level. We may backjump many decisions. // unsigned sz = m_lemma.size(); - clause * new_cls = 0; + clause * new_cls = nullptr; if (!found_decision) { // Case 1) // We just have to find the maximal variable in m_lemma, and return to that stage @@ -1924,7 +1924,7 @@ namespace nlsat { void collect(literal l) { bool_var b = l.var(); atom * a = m_atoms[b]; - if (a == 0) + if (a == nullptr) return; if (a->is_ineq_atom()) { unsigned sz = to_ineq_atom(a)->size(); @@ -2123,7 +2123,7 @@ namespace nlsat { for (unsigned i = 0; i < sz; i++) { bool_var b = c[i].var(); atom * a = m_atoms[b]; - if (a == 0) + if (a == nullptr) continue; if (a->is_ineq_atom()) continue; @@ -2158,7 +2158,7 @@ namespace nlsat { reinit_cache(m_atoms[b]); } void reinit_cache(atom* a) { - if (a == 0) { + if (a == nullptr) { } else if (a->is_ineq_atom()) { @@ -2250,7 +2250,7 @@ namespace nlsat { bool is_full_dimensional(literal l) const { atom * a = m_atoms[l.var()]; - if (a == 0) + if (a == nullptr) return true; switch (a->get_kind()) { case atom::EQ: return l.sign(); @@ -2858,7 +2858,7 @@ namespace nlsat { } std::ostream& display(std::ostream & out, clause const & c, display_var_proc const & proc) const { - if (c.assumptions() != 0) { + if (c.assumptions() != nullptr) { display_assumptions(out, static_cast<_assumption_set>(c.assumptions())); out << " |- "; } diff --git a/src/nlsat/nlsat_solver.h b/src/nlsat/nlsat_solver.h index c632a0334..e7b250f64 100644 --- a/src/nlsat/nlsat_solver.h +++ b/src/nlsat/nlsat_solver.h @@ -108,7 +108,7 @@ namespace nlsat { /** \brief Create a new clause. */ - void mk_clause(unsigned num_lits, literal * lits, assumption a = 0); + void mk_clause(unsigned num_lits, literal * lits, assumption a = nullptr); // ----------------------- // diff --git a/src/nlsat/tactic/goal2nlsat.cpp b/src/nlsat/tactic/goal2nlsat.cpp index 51536e493..133652c1d 100644 --- a/src/nlsat/tactic/goal2nlsat.cpp +++ b/src/nlsat/tactic/goal2nlsat.cpp @@ -269,12 +269,12 @@ struct goal2nlsat::scoped_set_imp { } ~scoped_set_imp() { - m_owner.m_imp = 0; + m_owner.m_imp = nullptr; } }; goal2nlsat::goal2nlsat() { - m_imp = 0; + m_imp = nullptr; } goal2nlsat::~goal2nlsat() { diff --git a/src/nlsat/tactic/nlsat_tactic.cpp b/src/nlsat/tactic/nlsat_tactic.cpp index 74531a9a7..92c6e0ffb 100644 --- a/src/nlsat/tactic/nlsat_tactic.cpp +++ b/src/nlsat/tactic/nlsat_tactic.cpp @@ -68,7 +68,7 @@ class nlsat_tactic : public tactic { } for (unsigned b = 0; b < b2a.size(); b++) { expr * a = b2a.get(b); - if (a == 0) + if (a == nullptr) continue; if (is_uninterp_const(a)) continue; @@ -116,7 +116,7 @@ class nlsat_tactic : public tactic { } for (unsigned b = 0; b < b2a.size(); b++) { expr * a = b2a.get(b); - if (a == 0 || !is_uninterp_const(a)) + if (a == nullptr || !is_uninterp_const(a)) continue; lbool val = m_solver.bvalue(b); if (val == l_undef) @@ -134,7 +134,7 @@ class nlsat_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("nlsat", *g); if (g->is_decided()) { @@ -173,7 +173,7 @@ class nlsat_tactic : public tactic { } } else { - expr_dependency* lcore = 0; + expr_dependency* lcore = nullptr; if (g->unsat_core_enabled()) { vector assumptions; m_solver.get_core(assumptions); @@ -182,7 +182,7 @@ class nlsat_tactic : public tactic { lcore = m.mk_join(lcore, d); } } - g->assert_expr(m.mk_false(), 0, lcore); + g->assert_expr(m.mk_false(), nullptr, lcore); } g->inc_depth(); @@ -204,14 +204,14 @@ class nlsat_tactic : public tactic { ~scoped_set_imp() { m_owner.m_imp->m_solver.collect_statistics(m_owner.m_stats); - m_owner.m_imp = 0; + m_owner.m_imp = nullptr; } }; public: nlsat_tactic(params_ref const & p): m_params(p) { - m_imp = 0; + m_imp = nullptr; } tactic * translate(ast_manager & m) override { diff --git a/src/opt/maxres.cpp b/src/opt/maxres.cpp index 9d32d48e3..178b87037 100644 --- a/src/opt/maxres.cpp +++ b/src/opt/maxres.cpp @@ -243,7 +243,7 @@ public: case l_true: get_current_correction_set(cs); if (cs.empty()) { - m_found_feasible_optimum = m_model.get() != 0; + m_found_feasible_optimum = m_model.get() != nullptr; m_lower = m_upper; } else { @@ -443,7 +443,7 @@ public: rational w = split_core(corr_set); cs_max_resolve(corr_set, w); IF_VERBOSE(2, verbose_stream() << "(opt.maxres.correction-set " << corr_set.size() << ")\n";); - m_csmodel = 0; + m_csmodel = nullptr; m_correction_set_size = 0; } @@ -488,7 +488,7 @@ public: } void process_unsat(exprs const& core) { - IF_VERBOSE(3, verbose_stream() << "(maxres cs model valid: " << (m_csmodel.get() != 0) << " cs size:" << m_correction_set_size << " core: " << core.size() << ")\n";); + IF_VERBOSE(3, verbose_stream() << "(maxres cs model valid: " << (m_csmodel.get() != nullptr) << " cs size:" << m_correction_set_size << " core: " << core.size() << ")\n";); expr_ref fml(m); remove_core(core); SASSERT(!core.empty()); @@ -524,7 +524,7 @@ public: if (m_c.sat_enabled()) { // SAT solver core extracts some model // during unsat core computation. - mdl = 0; + mdl = nullptr; s().get_model(mdl); } else { @@ -533,7 +533,7 @@ public: if (mdl.get() && w < m_upper) { update_assignment(mdl.get()); } - return 0 != mdl.get(); + return nullptr != mdl.get(); } lbool minimize_core(exprs& core) { @@ -820,7 +820,7 @@ public: m_found_feasible_optimum = false; m_last_index = 0; add_upper_bound_block(); - m_csmodel = 0; + m_csmodel = nullptr; m_correction_set_size = 0; return l_true; } @@ -844,7 +844,7 @@ public: smt_solver->assert_expr(s().get_assertion(i)); } smt_solver->assert_expr(core); - lbool is_sat = smt_solver->check_sat(0, 0); + lbool is_sat = smt_solver->check_sat(0, nullptr); if (is_sat == l_true) { IF_VERBOSE(0, verbose_stream() << "not a core\n";); } @@ -864,7 +864,7 @@ public: } smt_solver->assert_expr(n); } - lbool is_sat = smt_solver->check_sat(0, 0); + lbool is_sat = smt_solver->check_sat(0, nullptr); if (is_sat == l_false) { IF_VERBOSE(0, verbose_stream() << "assignment is infeasible\n";); } diff --git a/src/opt/maxsmt.cpp b/src/opt/maxsmt.cpp index 6df375240..91e843ca0 100644 --- a/src/opt/maxsmt.cpp +++ b/src/opt/maxsmt.cpp @@ -116,7 +116,7 @@ namespace opt { return dynamic_cast(th); } else { - return 0; + return nullptr; } } @@ -228,7 +228,7 @@ namespace opt { lbool maxsmt::operator()() { lbool is_sat = l_undef; - m_msolver = 0; + m_msolver = nullptr; symbol const& maxsat_engine = m_c.maxsat_engine(); IF_VERBOSE(1, verbose_stream() << "(maxsmt)\n";); TRACE("opt", tout << "maxsmt\n"; diff --git a/src/opt/opt_cmds.cpp b/src/opt/opt_cmds.cpp index 89264a9c8..4ff8fab71 100644 --- a/src/opt/opt_cmds.cpp +++ b/src/opt/opt_cmds.cpp @@ -52,7 +52,7 @@ public: assert_soft_cmd(opt::context* opt): parametric_cmd("assert-soft"), m_idx(0), - m_formula(0), + m_formula(nullptr), m_opt(opt) {} @@ -61,7 +61,7 @@ public: virtual void reset(cmd_context & ctx) { m_idx = 0; - m_formula = 0; + m_formula = nullptr; } virtual char const * get_usage() const { return " [:weight ] [:id ]"; } diff --git a/src/opt/opt_cmds.h b/src/opt/opt_cmds.h index 60f83d201..3ca8228df 100644 --- a/src/opt/opt_cmds.h +++ b/src/opt/opt_cmds.h @@ -23,7 +23,7 @@ Notes: class cmd_context; -void install_opt_cmds(cmd_context & ctx, opt::context* opt = 0); +void install_opt_cmds(cmd_context & ctx, opt::context* opt = nullptr); #endif diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index 2fdef6ca4..2f6bad9e8 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -121,7 +121,7 @@ namespace opt { m_arith(m), m_bv(m), m_hard_constraints(m), - m_solver(0), + m_solver(nullptr), m_pareto1(false), m_box_index(UINT_MAX), m_optsmt(m), @@ -274,7 +274,7 @@ namespace opt { s.assert_expr(m_hard_constraints); display_benchmark(); IF_VERBOSE(1, verbose_stream() << "(optimize:check-sat)\n";); - lbool is_sat = s.check_sat(0,0); + lbool is_sat = s.check_sat(0,nullptr); TRACE("opt", tout << "initial search result: " << is_sat << "\n"; s.display(tout);); if (is_sat != l_false) { @@ -435,7 +435,7 @@ namespace opt { return l_true; } if (m_box_index < m_objectives.size()) { - m_model = 0; + m_model = nullptr; ++m_box_index; return l_undef; } @@ -553,7 +553,7 @@ namespace opt { } lbool is_sat = (*(m_pareto.get()))(); if (is_sat != l_true) { - set_pareto(0); + set_pareto(nullptr); } if (is_sat == l_true) { yield(); @@ -925,7 +925,7 @@ namespace opt { func_decl* f = m.mk_fresh_func_decl(name,"", domain.size(), domain.c_ptr(), m.mk_bool_sort()); m_objective_fns.insert(f, index); m_objective_refs.push_back(f); - m_objective_orig.insert(f, sz > 0 ? args[0] : 0); + m_objective_orig.insert(f, sz > 0 ? args[0] : nullptr); return m.mk_app(f, sz, args); } @@ -968,7 +968,7 @@ namespace opt { } mk_atomic(terms); SASSERT(obj.m_id == id); - obj.m_term = orig_term?to_app(orig_term):0; + obj.m_term = orig_term?to_app(orig_term):nullptr; obj.m_terms.reset(); obj.m_terms.append(terms); obj.m_weights.reset(); @@ -1384,7 +1384,7 @@ namespace opt { } void context::clear_state() { - set_pareto(0); + set_pareto(nullptr); m_box_index = UINT_MAX; m_model.reset(); } diff --git a/src/opt/opt_context.h b/src/opt/opt_context.h index c9e5ce3de..6af106ef3 100644 --- a/src/opt/opt_context.h +++ b/src/opt/opt_context.h @@ -191,14 +191,14 @@ namespace opt { void get_box_model(model_ref& _m, unsigned index) override; void fix_model(model_ref& _m) override; void collect_statistics(statistics& stats) const override; - proof* get_proof() override { return 0; } + proof* get_proof() override { return nullptr; } void get_labels(svector & r) override; void get_unsat_core(ptr_vector & r) override; std::string reason_unknown() const override; void set_reason_unknown(char const* msg) override { m_unknown = msg; } void display_assignment(std::ostream& out) override; - bool is_pareto() override { return m_pareto.get() != 0; } + bool is_pareto() override { return m_pareto.get() != nullptr; } void set_logic(symbol const& s) override { m_logic = s; } void set_clausal(bool f) { m_is_clausal = f; } @@ -223,7 +223,7 @@ namespace opt { smt::context& smt_context() override { return m_opt_solver->get_context(); } filter_model_converter& fm() override { return m_fm; } - bool sat_enabled() const override { return 0 != m_sat_solver.get(); } + bool sat_enabled() const override { return nullptr != m_sat_solver.get(); } solver& get_solver() override; ast_manager& get_manager() const override { return this->m; } params_ref& params() override { return m_params; } diff --git a/src/opt/opt_pareto.cpp b/src/opt/opt_pareto.cpp index 026d10abc..c316e697e 100644 --- a/src/opt/opt_pareto.cpp +++ b/src/opt/opt_pareto.cpp @@ -29,7 +29,7 @@ namespace opt { lbool gia_pareto::operator()() { expr_ref fml(m); - lbool is_sat = m_solver->check_sat(0, 0); + lbool is_sat = m_solver->check_sat(0, nullptr); if (is_sat == l_true) { { solver::scoped_push _s(*m_solver.get()); @@ -45,7 +45,7 @@ namespace opt { model_smt2_pp(verbose_stream() << "new model:\n", m, *mdl, 0);); // TBD: we can also use local search to tune solution coordinate-wise. mk_dominates(); - is_sat = m_solver->check_sat(0, 0); + is_sat = m_solver->check_sat(0, nullptr); } } if (is_sat == l_undef) { @@ -91,7 +91,7 @@ namespace opt { lbool oia_pareto::operator()() { solver::scoped_push _s(*m_solver.get()); - lbool is_sat = m_solver->check_sat(0, 0); + lbool is_sat = m_solver->check_sat(0, nullptr); if (m.canceled()) { is_sat = l_undef; } diff --git a/src/opt/opt_solver.cpp b/src/opt/opt_solver.cpp index 49b48e68f..715f45291 100644 --- a/src/opt/opt_solver.cpp +++ b/src/opt/opt_solver.cpp @@ -69,7 +69,7 @@ namespace opt { solver* opt_solver::translate(ast_manager& m, params_ref const& p) { UNREACHABLE(); - return 0; + return nullptr; } void opt_solver::collect_param_descrs(param_descrs & r) { @@ -261,7 +261,7 @@ namespace opt { expr_ref ge = mk_ge(i, val); TRACE("opt", tout << ge << "\n";); assert_expr(ge); - lbool is_sat = m_context.check(0, 0); + lbool is_sat = m_context.check(0, nullptr); is_sat = adjust_result(is_sat); if (is_sat == l_true) { set_model(i); @@ -316,7 +316,7 @@ namespace opt { void opt_solver::get_labels(svector & r) { r.reset(); buffer tmp; - m_context.get_relevant_labels(0, tmp); + m_context.get_relevant_labels(nullptr, tmp); r.append(tmp.size(), tmp.c_ptr()); } @@ -340,7 +340,7 @@ namespace opt { m_objective_values.push_back(inf_eps(rational(-1), inf_rational())); m_objective_terms.push_back(term); m_valid_objectives.push_back(true); - m_models.push_back(0); + m_models.push_back(nullptr); return v; } diff --git a/src/opt/optsmt.cpp b/src/opt/optsmt.cpp index 3258cb33d..66174a28b 100644 --- a/src/opt/optsmt.cpp +++ b/src/opt/optsmt.cpp @@ -112,7 +112,7 @@ namespace opt { while (!m.canceled()) { SASSERT(delta_per_step.is_int()); SASSERT(delta_per_step.is_pos()); - is_sat = m_s->check_sat(0, 0); + is_sat = m_s->check_sat(0, nullptr); if (is_sat == l_true) { bound = update_lower(); if (!get_max_delta(lower, delta_index)) { @@ -188,7 +188,7 @@ namespace opt { while (!m.canceled()) { SASSERT(delta_per_step.is_int()); SASSERT(delta_per_step.is_pos()); - is_sat = m_s->check_sat(0, 0); + is_sat = m_s->check_sat(0, nullptr); if (is_sat == l_true) { m_s->maximize_objective(obj_index, bound); m_s->get_model(m_model); @@ -416,7 +416,7 @@ namespace opt { bounds.push_back(bound); } else { - bounds.push_back(0); + bounds.push_back(nullptr); mid.push_back(inf_eps()); } } @@ -429,7 +429,7 @@ namespace opt { case l_true: IF_VERBOSE(2, verbose_stream() << "(optsmt lower bound for v" << m_vars[i] << " := " << m_upper[i] << ")\n";); m_lower[i] = mid[i]; - th.enable_record_conflict(0); + th.enable_record_conflict(nullptr); m_s->assert_expr(update_lower()); break; case l_false: @@ -444,10 +444,10 @@ namespace opt { } break; default: - th.enable_record_conflict(0); + th.enable_record_conflict(nullptr); return l_undef; } - th.enable_record_conflict(0); + th.enable_record_conflict(nullptr); progress = true; } } @@ -505,7 +505,7 @@ namespace opt { commit_assignment(i); } while (is_sat == l_true && !m.canceled()) { - is_sat = m_s->check_sat(0, 0); + is_sat = m_s->check_sat(0, nullptr); if (is_sat != l_true) break; m_s->maximize_objective(obj_index, bound); @@ -599,7 +599,7 @@ namespace opt { m_lower.push_back(inf_eps(rational(-1),inf_rational(0))); m_upper.push_back(inf_eps(rational(1), inf_rational(0))); m_lower_fmls.push_back(m.mk_true()); - m_models.push_back(0); + m_models.push_back(nullptr); return m_objs.size()-1; } @@ -615,7 +615,7 @@ namespace opt { m_vars.reset(); m_model.reset(); m_lower_fmls.reset(); - m_s = 0; + m_s = nullptr; } } diff --git a/src/opt/optsmt.h b/src/opt/optsmt.h index 93fa3f624..6db7eaadf 100644 --- a/src/opt/optsmt.h +++ b/src/opt/optsmt.h @@ -41,7 +41,7 @@ namespace opt { sref_vector m_models; public: optsmt(ast_manager& m): - m(m), m_s(0), m_objs(m), m_lower_fmls(m) {} + m(m), m_s(nullptr), m_objs(m), m_lower_fmls(m) {} void setup(opt_solver& solver); diff --git a/src/opt/sortmax.cpp b/src/opt/sortmax.cpp index 00cab488c..1bbafc90b 100644 --- a/src/opt/sortmax.cpp +++ b/src/opt/sortmax.cpp @@ -89,7 +89,7 @@ namespace opt { while (l_true == is_sat && first < out.size() && m_lower < m_upper) { trace_bounds("sortmax"); s().assert_expr(out[first]); - is_sat = s().check_sat(0, 0); + is_sat = s().check_sat(0, nullptr); TRACE("opt", tout << is_sat << "\n"; s().display(tout); tout << "\n";); if (m.canceled()) { is_sat = l_undef; diff --git a/src/opt/wmax.cpp b/src/opt/wmax.cpp index afc0334eb..52b87e536 100644 --- a/src/opt/wmax.cpp +++ b/src/opt/wmax.cpp @@ -80,7 +80,7 @@ namespace opt { while (!m.canceled() && m_lower < m_upper) { //mk_assumptions(asms); //is_sat = s().preferred_sat(asms, cores); - is_sat = s().check_sat(0, 0); + is_sat = s().check_sat(0, nullptr); if (m.canceled()) { is_sat = l_undef; } @@ -162,7 +162,7 @@ namespace opt { void verify_core(expr_ref_vector const& core) { s().push(); s().assert_expr(core); - VERIFY(l_false == s().check_sat(0, 0)); + VERIFY(l_false == s().check_sat(0, nullptr)); s().pop(1); } @@ -216,7 +216,7 @@ namespace opt { rational remove_negations(smt::theory_wmaxsat& th, expr_ref_vector const& core, ptr_vector& keys, vector& weights) { rational min_weight(-1); for (unsigned i = 0; i < core.size(); ++i) { - expr* e = 0; + expr* e = nullptr; VERIFY(m.is_not(core[i], e)); keys.push_back(m_keys[e]); rational weight = m_weights[e]; diff --git a/src/parsers/smt2/marshal.cpp b/src/parsers/smt2/marshal.cpp index ae144e491..11244760a 100644 --- a/src/parsers/smt2/marshal.cpp +++ b/src/parsers/smt2/marshal.cpp @@ -36,7 +36,7 @@ std::string marshal(expr_ref e, ast_manager &m) { expr_ref unmarshal(std::istream &is, ast_manager &m) { cmd_context ctx(false, &m); ctx.set_ignore_check(true); - if (!parse_smt2_commands(ctx, is)) { return expr_ref(0, m); } + if (!parse_smt2_commands(ctx, is)) { return expr_ref(nullptr, m); } ptr_vector::const_iterator it = ctx.begin_assertions(); ptr_vector::const_iterator end = ctx.end_assertions(); diff --git a/src/parsers/smt2/smt2parser.cpp b/src/parsers/smt2/smt2parser.cpp index a06438c73..0b0420873 100644 --- a/src/parsers/smt2/smt2parser.cpp +++ b/src/parsers/smt2/smt2parser.cpp @@ -46,7 +46,7 @@ namespace smt2 { struct local { expr * m_term; unsigned m_level; - local():m_term(0), m_level(0) {} + local():m_term(nullptr), m_level(0) {} local(expr * t, unsigned l):m_term(t), m_level(l) {} }; symbol_table m_env; @@ -222,31 +222,31 @@ namespace smt2 { } psort_ref_vector & psort_stack() { - if (m_psort_stack.get() == 0) + if (m_psort_stack.get() == nullptr) m_psort_stack = alloc(psort_ref_vector, pm()); return *(m_psort_stack.get()); } sort_ref_vector & sort_stack() { - if (m_sort_stack.get() == 0) + if (m_sort_stack.get() == nullptr) m_sort_stack = alloc(sort_ref_vector, m()); return *(m_sort_stack.get()); } expr_ref_vector & expr_stack() { - if (m_expr_stack.get() == 0) + if (m_expr_stack.get() == nullptr) m_expr_stack = alloc(expr_ref_vector, m()); return *(m_expr_stack.get()); } template static unsigned size(scoped_ptr & v) { - return v.get() == 0 ? 0 : v->size(); + return v.get() == nullptr ? 0 : v->size(); } template static void shrink(scoped_ptr & v, unsigned old_sz) { - if (v.get() == 0) { + if (v.get() == nullptr) { SASSERT(old_sz == 0); } else { @@ -255,13 +255,13 @@ namespace smt2 { } expr_ref_vector & pattern_stack() { - if (m_pattern_stack.get() == 0) + if (m_pattern_stack.get() == nullptr) m_pattern_stack = alloc(expr_ref_vector, m()); return *(m_pattern_stack.get()); } expr_ref_vector & nopattern_stack() { - if (m_nopattern_stack.get() == 0) + if (m_nopattern_stack.get() == nullptr) m_nopattern_stack = alloc(expr_ref_vector, m()); return *(m_nopattern_stack.get()); } @@ -271,44 +271,44 @@ namespace smt2 { } sexpr_ref_vector & sexpr_stack() { - if (m_sexpr_stack.get() == 0) + if (m_sexpr_stack.get() == nullptr) m_sexpr_stack = alloc(sexpr_ref_vector, sm()); return *(m_sexpr_stack.get()); } arith_util & autil() { - if (m_arith_util.get() == 0) + if (m_arith_util.get() == nullptr) m_arith_util = alloc(arith_util, m()); return *(m_arith_util.get()); } datatype_util & dtutil() { - if (m_datatype_util.get() == 0) + if (m_datatype_util.get() == nullptr) m_datatype_util = alloc(datatype_util, m()); return *(m_datatype_util.get()); } seq_util & sutil() { - if (m_seq_util.get() == 0) + if (m_seq_util.get() == nullptr) m_seq_util = alloc(seq_util, m()); return *(m_seq_util.get()); } bv_util & butil() { - if (m_bv_util.get() == 0) + if (m_bv_util.get() == nullptr) m_bv_util = alloc(bv_util, m()); return *(m_bv_util.get()); } pattern_validator & pat_validator() { - if (m_pattern_validator.get() == 0) { + if (m_pattern_validator.get() == nullptr) { m_pattern_validator = alloc(pattern_validator, m()); } return *(m_pattern_validator.get()); } var_shifter & shifter() { - if (m_var_shifter.get() == 0) + if (m_var_shifter.get() == nullptr) m_var_shifter = alloc(var_shifter, m()); return *(m_var_shifter.get()); } @@ -569,12 +569,12 @@ namespace smt2 { SASSERT(curr_is_identifier()); symbol id = curr_id(); psort_decl * d = m_ctx.find_psort_decl(id); - if (d == 0) + if (d == nullptr) unknown_sort(id, context); if (!d->has_var_params() && d->get_num_params() != 0) throw parser_exception("sort constructor expects parameters"); sort * r = d->instantiate(pm()); - if (r == 0) + if (r == nullptr) throw parser_exception("invalid sort application"); next(); return r; @@ -584,7 +584,7 @@ namespace smt2 { SASSERT(curr_is_identifier()); symbol id = curr_id(); psort_decl * d = m_ctx.find_psort_decl(id); - if (d != 0) { + if (d != nullptr) { if (!d->has_var_params() && d->get_num_params() != 0) throw parser_exception("sort constructor expects parameters"); next(); @@ -601,7 +601,7 @@ namespace smt2 { unknown_sort(id); UNREACHABLE(); } - return 0; + return nullptr; } } } @@ -612,7 +612,7 @@ namespace smt2 { next(); symbol id = check_identifier_next("invalid indexed sort, symbol expected"); psort_decl * d = m_ctx.find_psort_decl(id); - if (d == 0) + if (d == nullptr) unknown_sort(id); sbuffer args; while (!curr_is_rparen()) { @@ -624,7 +624,7 @@ namespace smt2 { if (args.empty()) throw parser_exception("invalid indexed sort, index expected"); sort * r = d->instantiate(pm(), args.size(), args.c_ptr()); - if (r == 0) + if (r == nullptr) throw parser_exception("invalid sort application"); next(); return r; @@ -634,7 +634,7 @@ namespace smt2 { SASSERT(curr_is_identifier()); symbol id = curr_id(); psort_decl * d = m_ctx.find_psort_decl(id); - if (d == 0) { + if (d == nullptr) { unknown_sort(id); } next(); @@ -697,7 +697,7 @@ namespace smt2 { SASSERT(curr_is_identifier()); symbol id = curr_id(); psort_decl * d = m_ctx.find_psort_decl(id); - if (d == 0) + if (d == nullptr) unknown_sort(id); next(); void * mem = m_stack.allocate(sizeof(sort_frame)); @@ -717,7 +717,7 @@ namespace smt2 { throw parser_exception("invalid number of parameters to sort constructor"); } sort * r = d->instantiate(pm(), num, sort_stack().c_ptr() + spos); - if (r == 0) + if (r == nullptr) throw parser_exception("invalid sort application"); sort_stack().shrink(spos); sort_stack().push_back(r); @@ -783,7 +783,7 @@ namespace smt2 { SASSERT(curr_is_identifier()); psort * p = parse_psort_name(true); ptype result; - if (p != 0) { + if (p != nullptr) { result = ptype(p); } else { @@ -828,7 +828,7 @@ namespace smt2 { symbol r_name(r_str.c_str()); next(); TRACE("datatype_parser_bug", tout << ct_name << " " << r_name << "\n";); - ct_decls.push_back(pm().mk_pconstructor_decl(m_sort_id2param_idx.size(), ct_name, r_name, 0, 0)); + ct_decls.push_back(pm().mk_pconstructor_decl(m_sort_id2param_idx.size(), ct_name, r_name, 0, nullptr)); } else { check_lparen_next("invalid datatype declaration, '(' or ')' expected"); @@ -999,13 +999,13 @@ namespace smt2 { TRACE("name_expr", tout << "naming: " << s << " ->\n" << mk_pp(n, m()) << "\n";); if (!is_ground(n) && has_free_vars(n)) throw parser_exception("invalid named expression, expression contains free variables"); - m_ctx.insert(s, 0, 0, n); + m_ctx.insert(s, 0, nullptr, n); m_last_named_expr.first = s; m_last_named_expr.second = n; } bool in_quant_ctx(attr_expr_frame * fr) { - return fr != 0 && fr->m_prev != 0 && fr->m_prev->m_kind == EF_QUANT; + return fr != nullptr && fr->m_prev != nullptr && fr->m_prev->m_kind == EF_QUANT; } void check_in_quant_ctx(attr_expr_frame * fr) { @@ -1018,7 +1018,7 @@ namespace smt2 { return; if (fr->m_last_symbol == m_pattern) { expr * pat = expr_stack().back(); - if (pat == 0) { + if (pat == nullptr) { if (!ignore_bad_patterns()) throw parser_exception("invalid empty pattern"); } @@ -1191,7 +1191,7 @@ namespace smt2 { if (!ignore_bad_patterns()) throw parser_exception("invalid pattern, '(' expected"); consume_sexpr(); - expr_stack().push_back(0); // empty pattern + expr_stack().push_back(nullptr); // empty pattern return; } @@ -1203,7 +1203,7 @@ namespace smt2 { } else if (curr_is_rparen()) { next(); - expr_stack().push_back(0); // empty pattern + expr_stack().push_back(nullptr); // empty pattern } else { // unary pattern @@ -1211,7 +1211,7 @@ namespace smt2 { // when Simplify benchmarks were converted into SMT2 ones. if (curr_is_identifier()) { symbol id = curr_id(); - func_decl * f = 0; + func_decl * f = nullptr; try { f = m_ctx.find_func_decl(id); } @@ -1223,7 +1223,7 @@ namespace smt2 { while (!curr_is_rparen()) consume_sexpr(); next(); - expr_stack().push_back(0); // empty pattern + expr_stack().push_back(nullptr); // empty pattern return; // no frame is created } } @@ -1761,7 +1761,7 @@ namespace smt2 { return; } expr_ref t_ref(m()); - m_ctx.mk_app(r, 0, 0, num_indices, m_param_stack.c_ptr() + param_spos, has_as ? sort_stack().back() : 0, t_ref); + m_ctx.mk_app(r, 0, nullptr, num_indices, m_param_stack.c_ptr() + param_spos, has_as ? sort_stack().back() : nullptr, t_ref); m_param_stack.shrink(param_spos); expr_stack().push_back(t_ref.get()); if (has_as) { @@ -1851,7 +1851,7 @@ namespace smt2 { expr_stack().c_ptr() + fr->m_expr_spos, num_indices, m_param_stack.c_ptr() + fr->m_param_spos, - fr->m_as_sort ? sort_stack().back() : 0, + fr->m_as_sort ? sort_stack().back() : nullptr, t_ref); expr_stack().shrink(fr->m_expr_spos); m_param_stack.shrink(fr->m_param_spos); @@ -2050,7 +2050,7 @@ namespace smt2 { parse_bv_numeral(); break; case scanner::LEFT_PAREN: - push_expr_frame(m_num_expr_frames == 0 ? 0 : static_cast(m_stack.top())); + push_expr_frame(m_num_expr_frames == 0 ? nullptr : static_cast(m_stack.top())); break; case scanner::KEYWORD_TOKEN: throw parser_exception("invalid expression, unexpected keyword"); @@ -2149,17 +2149,17 @@ namespace smt2 { check_identifier("invalid sort declaration, symbol expected"); symbol id = curr_id(); - if (m_ctx.find_psort_decl(id) != 0) + if (m_ctx.find_psort_decl(id) != nullptr) throw parser_exception("invalid sort declaration, sort already declared/defined"); next(); if (curr_is_rparen()) { - psort_decl * decl = pm().mk_psort_user_decl(0, id, 0); + psort_decl * decl = pm().mk_psort_user_decl(0, id, nullptr); m_ctx.insert(decl); } else { check_int("invalid sort declaration, arity () or ')' expected"); unsigned u = curr_unsigned(); - psort_decl * decl = pm().mk_psort_user_decl(u, id, 0); + psort_decl * decl = pm().mk_psort_user_decl(u, id, nullptr); m_ctx.insert(decl); next(); check_rparen("invalid sort declaration, ')' expected"); @@ -2174,7 +2174,7 @@ namespace smt2 { next(); check_identifier("invalid sort definition, symbol expected"); symbol id = curr_id(); - if (m_ctx.find_psort_decl(id) != 0) + if (m_ctx.find_psort_decl(id) != nullptr) throw parser_exception("invalid sort definition, sort already declared/defined"); next(); parse_sort_decl_params(); @@ -2355,7 +2355,7 @@ namespace smt2 { parse_expr(); if (m().get_sort(expr_stack().back()) != sort_stack().back()) throw parser_exception("invalid constant definition, sort mismatch"); - m_ctx.insert(id, 0, 0, expr_stack().back()); + m_ctx.insert(id, 0, nullptr, expr_stack().back()); check_rparen("invalid constant definition, ')' expected"); expr_stack().pop_back(); sort_stack().pop_back(); @@ -2574,7 +2574,7 @@ namespace smt2 { } check_rparen("invalid get-value command, ')' expected"); - if (!m_ctx.is_model_available() || m_ctx.get_check_sat_result() == 0) + if (!m_ctx.is_model_available() || m_ctx.get_check_sat_result() == nullptr) throw cmd_exception("model is not available"); model_ref md; if (index == 0) { @@ -2804,7 +2804,7 @@ namespace smt2 { void parse_ext_cmd(int line, int pos) { symbol s = curr_id(); m_curr_cmd = m_ctx.find_cmd(s); - if (m_curr_cmd == 0) { + if (m_curr_cmd == nullptr) { parse_unknown_cmd(); return; } @@ -2823,7 +2823,7 @@ namespace smt2 { throw parser_exception("invalid command, argument(s) missing"); m_curr_cmd->execute(m_ctx); next(); - m_curr_cmd = 0; + m_curr_cmd = nullptr; shrink(m_sort_stack, sort_spos); shrink(m_expr_stack, expr_spos); shrink(m_sexpr_stack, sexpr_spos); @@ -2923,12 +2923,12 @@ namespace smt2 { } public: - parser(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & p, char const * filename=0): + parser(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & p, char const * filename=nullptr): m_ctx(ctx), m_params(p), m_scanner(ctx, is, interactive), m_curr(scanner::NULL_TOKEN), - m_curr_cmd(0), + m_curr_cmd(nullptr), m_num_bindings(0), m_let("let"), m_bang("!"), @@ -2988,23 +2988,23 @@ namespace smt2 { void reset() { reset_stack(); m_num_bindings = 0; - m_psort_stack = 0; - m_sort_stack = 0; - m_expr_stack = 0; - m_pattern_stack = 0; - m_nopattern_stack = 0; - m_sexpr_stack = 0; + m_psort_stack = nullptr; + m_sort_stack = nullptr; + m_expr_stack = nullptr; + m_pattern_stack = nullptr; + m_nopattern_stack = nullptr; + m_sexpr_stack = nullptr; m_symbol_stack .reset(); m_param_stack .reset(); m_env .reset(); m_sort_id2param_idx .reset(); m_dt_name2idx .reset(); - m_bv_util = 0; - m_arith_util = 0; - m_seq_util = 0; - m_pattern_validator = 0; - m_var_shifter = 0; + m_bv_util = nullptr; + m_arith_util = nullptr; + m_seq_util = nullptr; + m_pattern_validator = nullptr; + m_var_shifter = nullptr; } bool operator()() { diff --git a/src/parsers/smt2/smt2parser.h b/src/parsers/smt2/smt2parser.h index 0976fc5f4..70ea287e0 100644 --- a/src/parsers/smt2/smt2parser.h +++ b/src/parsers/smt2/smt2parser.h @@ -21,6 +21,6 @@ Revision History: #include "cmd_context/cmd_context.h" -bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive = false, params_ref const & p = params_ref(), char const * filename = 0); +bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive = false, params_ref const & p = params_ref(), char const * filename = nullptr); #endif diff --git a/src/parsers/util/simple_parser.cpp b/src/parsers/util/simple_parser.cpp index 770da9dbb..c9d00ebcc 100644 --- a/src/parsers/util/simple_parser.cpp +++ b/src/parsers/util/simple_parser.cpp @@ -87,7 +87,7 @@ expr * simple_parser::parse_expr(scanner & s) { } throw parser_error(); case scanner::RIGHT_PAREN: - return 0; + return nullptr; case scanner::ID_TOKEN: if (m_builtin.find(s.get_id(), op)) { expr * r = m_manager.mk_const(op.m_family_id, op.m_kind); @@ -123,7 +123,7 @@ bool simple_parser::parse(std::istream & in, expr_ref & result) { return false; } m_exprs.reset(); - return result.get() != 0; + return result.get() != nullptr; } bool simple_parser::parse_string(char const * str, expr_ref & result) { @@ -133,7 +133,7 @@ bool simple_parser::parse_string(char const * str, expr_ref & result) { } bool simple_parser::parse_file(char const * file, expr_ref & result) { - if (file != 0) { + if (file != nullptr) { std::ifstream stream(file); if (!stream) { warning_msg("ERROR: could not open file '%s'.", file); diff --git a/src/qe/nlarith_util.cpp b/src/qe/nlarith_util.cpp index 7d86860b3..12977b449 100644 --- a/src/qe/nlarith_util.cpp +++ b/src/qe/nlarith_util.cpp @@ -32,7 +32,7 @@ namespace nlarith { svector m_comps; public: - literal_set(ast_manager& m) : m_inf(m), m_sup(m), m_x(0), m_lits(m) {} + literal_set(ast_manager& m) : m_inf(m), m_sup(m), m_x(nullptr), m_lits(m) {} unsigned size() const { return m_lits.size(); } app_ref_vector& lits() { return m_lits; } @@ -123,7 +123,7 @@ namespace nlarith { return false; } - if (!get_polys(contains_x, num_lits, lits, polys, comps, &branch_conds, 0)) { + if (!get_polys(contains_x, num_lits, lits, polys, comps, &branch_conds, nullptr)) { TRACE("nlarith", tout << "could not extract polynomials " << mk_pp(x, m()) << "\n"; for (unsigned i = 0; i < num_lits; ++i) { @@ -1514,9 +1514,9 @@ namespace nlarith { new_atoms.reset(); app_ref tmp(m()); expr_ref_vector conjs(m()); - mk_exists_zero(literals, true, 0, conjs, new_atoms); + mk_exists_zero(literals, true, nullptr, conjs, new_atoms); mk_same_sign (literals, true, conjs, new_atoms); - mk_exists_zero(literals, false, 0, conjs, new_atoms); + mk_exists_zero(literals, false, nullptr, conjs, new_atoms); mk_same_sign (literals, false, conjs, new_atoms); mk_lt(literals.x(), literals.x_inf(), conjs, new_atoms); mk_lt(literals.x_sup(), literals.x(), conjs, new_atoms); @@ -1922,7 +1922,7 @@ namespace nlarith { } extract_non_linear(atms.size(), atms.begin(), nlvars); if (nlvars.empty()) { - lits = 0; + lits = nullptr; return true; } app* x = nlvars.back(); @@ -1930,11 +1930,11 @@ namespace nlarith { expr* const* _atoms = (expr*const*)atms.begin(); lits = alloc(util::literal_set, m()); lits->set_x(x); - if (get_polys(contains_x, atms.size(), _atoms, lits->polys(), lits->comps(), 0, &lits->lits())) { + if (get_polys(contains_x, atms.size(), _atoms, lits->polys(), lits->comps(), nullptr, &lits->lits())) { return true; } dealloc(lits); - lits = 0; + lits = nullptr; return false; } diff --git a/src/qe/nlqsat.cpp b/src/qe/nlqsat.cpp index 0898afeda..c71e942a1 100644 --- a/src/qe/nlqsat.cpp +++ b/src/qe/nlqsat.cpp @@ -766,7 +766,7 @@ namespace qe { for (; it != end; ++it) { expr * a = it->m_key; nlsat::bool_var b = it->m_value; - if (a == 0 || !is_uninterp_const(a) || b == m_is_true.var() || !m_free_vars.contains(a) || m_aux_vars.contains(a)) + if (a == nullptr || !is_uninterp_const(a) || b == m_is_true.var() || !m_free_vars.contains(a) || m_aux_vars.contains(a)) continue; lbool val = m_bmodel0.get(b, l_undef); if (val == l_undef) @@ -783,7 +783,7 @@ namespace qe { m_mode(mode), m_params(p), m_solver(m.limit(), p, true), - m_nftactic(0), + m_nftactic(nullptr), m_rmodel(m_solver.am()), m_rmodel0(m_solver.am()), m_valid_model(false), @@ -821,7 +821,7 @@ namespace qe { ptr_vector fmls; expr_ref fml(m); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; in->get_formulas(fmls); fml = mk_and(m, fmls.size(), fmls.c_ptr()); if (m_mode == elim_t) { diff --git a/src/qe/qe.cpp b/src/qe/qe.cpp index 08a0c44c0..daed18f7a 100644 --- a/src/qe/qe.cpp +++ b/src/qe/qe.cpp @@ -361,7 +361,7 @@ namespace qe { } app* ite; if (find_ite(fml, ite)) { - expr* cond = 0, *th = 0, *el = 0; + expr* cond = nullptr, *th = nullptr, *el = nullptr; VERIFY(m.is_ite(ite, cond, th, el)); expr_ref tmp1(fml, m), tmp2(fml, m); m_replace->apply_substitution(ite, th, tmp1); @@ -448,7 +448,7 @@ namespace qe { } expr* lookup(expr* e, bool p) { - expr* r = 0; + expr* r = nullptr; if (p && m_pos.find(e, r)) { return r; } @@ -457,7 +457,7 @@ namespace qe { } m_todo.push_back(e); m_pols.push_back(p); - return 0; + return nullptr; } void insert(expr* e, bool p, expr* r) { @@ -687,7 +687,7 @@ namespace qe { bool visit(app* e) { bool all_visit = true; - expr* f = 0; + expr* f = nullptr; expr_ref tmp(m); if (!m_is_relevant(e)) { m_cache.insert(e, e); @@ -970,7 +970,7 @@ namespace qe { app* var() const { SASSERT(has_var()); return m_var; } - bool has_var() const { return 0 != m_var.get(); } + bool has_var() const { return nullptr != m_var.get(); } search_tree* parent() const { return m_parent; } @@ -1025,7 +1025,7 @@ namespace qe { m_children.reset(); m_vars.reset(); m_branch_index.reset(); - m_var = 0; + m_var = nullptr; m_def.reset(); m_num_branches = rational::zero(); m_pure = true; @@ -1371,11 +1371,11 @@ namespace qe { m_trail(m), m_fml(m), m_subfml(m), - m_root(0, m, m.mk_true()), - m_current(0), + m_root(nullptr, m, m.mk_true()), + m_current(nullptr), m_new_vars(m), m_get_first(false), - m_defs(0), + m_defs(nullptr), m_nnf(m, get_is_relevant(), get_mk_atom()) { params_ref params; @@ -1398,8 +1398,8 @@ namespace qe { m_var2branch.reset(); m_root.reset(); m_new_vars.reset(); - m_fml = 0; - m_defs = 0; + m_fml = nullptr; + m_defs = nullptr; m_nnf.reset(); } @@ -1501,7 +1501,7 @@ namespace qe { } reset(); m_solver.pop(1); - f = 0; + f = nullptr; } void collect_statistics(statistics& st) { @@ -1571,7 +1571,7 @@ namespace qe { } contains_app* ca = alloc(contains_app, m, x); m_var2contains.insert(x, ca); - app* bv = 0; + app* bv = nullptr; if (m.is_bool(x) || m_bv.is_bv(x)) { bv = x; } @@ -1583,7 +1583,7 @@ namespace qe { m_var2branch.insert(x, bv); } - void add_constraint(bool use_current_val, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) override { + void add_constraint(bool use_current_val, expr* l1 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) override { search_tree* node = m_current; if (!use_current_val) { node = m_current->parent(); @@ -1603,7 +1603,7 @@ namespace qe { } void blast_or(app* var, expr_ref& fml) override { - m_qe.eliminate_exists(1, &var, fml, m_free_vars, false, 0); + m_qe.eliminate_exists(1, &var, fml, m_free_vars, false, nullptr); } lbool eliminate_exists(unsigned num_vars, app* const* vars, expr_ref& fml, bool get_first, guarded_defs* defs) { @@ -1613,7 +1613,7 @@ namespace qe { private: void add_literal(expr* l) { - if (l != 0) { + if (l != nullptr) { m_literals.push_back(l); } } @@ -1705,11 +1705,11 @@ namespace qe { return NEED_PROPAGATION; } m_current = m_current->child(branch); - if (m_current->fml() == 0) { + if (m_current->fml() == nullptr) { SASSERT(!m_current->has_var()); if (apply) { expr_ref def(m); - plugin(x).subst(contains(x), branch, fml, m_defs?&def:0); + plugin(x).subst(contains(x), branch, fml, m_defs?&def:nullptr); SASSERT(!contains(x)(fml)); m_current->consume_vars(m_new_vars); m_current->init(fml); @@ -2197,7 +2197,7 @@ namespace qe { void eliminate_exists_bind(unsigned num_vars, app* const* vars, expr_ref& fml) { checkpoint(); app_ref_vector free_vars(m); - eliminate_exists(num_vars, vars, fml, free_vars, false, 0); + eliminate_exists(num_vars, vars, fml, free_vars, false, nullptr); bind_variables(free_vars.size(), free_vars.c_ptr(), fml); } @@ -2219,7 +2219,7 @@ namespace qe { m_fparams(fp), m_params(p), m_trail(m), - m_qe(0), + m_qe(nullptr), m_assumption(m.mk_true()) { } @@ -2302,7 +2302,7 @@ namespace qe { m_trail.push_back(result); todo.push_back(result); - expr* e = 0, *r = 0; + expr* e = nullptr, *r = nullptr; while (!todo.empty()) { e = todo.back(); @@ -2472,8 +2472,8 @@ namespace qe { public: simplify_solver_context(ast_manager& m): m(m), - m_vars(0), - m_fml(0) + m_vars(nullptr), + m_fml(nullptr) { add_plugin(mk_bool_plugin(*this)); add_plugin(mk_arith_plugin(*this, false, m_fparams)); @@ -2543,7 +2543,7 @@ namespace qe { } // callback to add constraints in branch. - void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) override { + void add_constraint(bool use_var, expr* l1 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) override { UNREACHABLE(); } // eliminate finite domain variable 'var' from fml. @@ -2605,7 +2605,7 @@ namespace qe { } m_ctx.solve(result, vars); if (old_q->is_forall()) { - expr* e = 0; + expr* e = nullptr; result = m.is_not(result, e)?e:mk_not(m, result); } var_shifter shift(m); @@ -2621,7 +2621,7 @@ namespace qe { if (!vars.empty()) { result = m.mk_quantifier(old_q->is_forall(), vars.size(), sorts.c_ptr(), names.c_ptr(), result, 1); } - result_pr = 0; + result_pr = nullptr; return true; } diff --git a/src/qe/qe.h b/src/qe/qe.h index bdce4d159..1027f0b61 100644 --- a/src/qe/qe.h +++ b/src/qe/qe.h @@ -97,7 +97,7 @@ namespace qe { virtual void add_var(app* x) = 0; // callback to add constraints in branch. - virtual void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) = 0; + virtual void add_constraint(bool use_var, expr* l1 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) = 0; // eliminate finite domain variable 'var' from fml. virtual void blast_or(app* var, expr_ref& fml) = 0; diff --git a/src/qe/qe_arith.cpp b/src/qe/qe_arith.cpp index 6b3b3a11f..6ea4118a0 100644 --- a/src/qe/qe_arith.cpp +++ b/src/qe/qe_arith.cpp @@ -126,7 +126,7 @@ namespace qe { map values; bool found_eq = false; for (unsigned i = 0; !found_eq && i < to_app(lit)->get_num_args(); ++i) { - expr* arg1 = to_app(lit)->get_arg(i), *arg2 = 0; + expr* arg1 = to_app(lit)->get_arg(i), *arg2 = nullptr; rational r; expr_ref val = eval(arg1); if (!a.is_numeral(val, r)) return false; diff --git a/src/qe/qe_arith_plugin.cpp b/src/qe/qe_arith_plugin.cpp index 9e056cdc2..21e50182f 100644 --- a/src/qe/qe_arith_plugin.cpp +++ b/src/qe/qe_arith_plugin.cpp @@ -891,7 +891,7 @@ namespace qe { while (m_arith.is_add(p)) { bool found_x = false; - expr* next_p = 0; + expr* next_p = nullptr; for (unsigned i = 0; i < to_app(p)->get_num_args(); ++i) { expr* arg = to_app(p)->get_arg(i); if (contains_x(arg)) { @@ -1287,7 +1287,7 @@ namespace qe { m_div_coeffs.reset(); m_div_divisors.reset(); m_div_atoms.reset(); - m_div_z = 0; + m_div_z = nullptr; m_nested_div_terms.reset(); m_nested_div_coeffs.reset(); m_nested_div_divisors.reset(); @@ -1485,7 +1485,7 @@ public: expr* m_term; ptr_vector m_vars; - branch_formula(): m_fml(0), m_var(0), m_branch(0), m_result(0), m_term(0) {} + branch_formula(): m_fml(nullptr), m_var(nullptr), m_branch(0), m_result(nullptr), m_term(nullptr) {} branch_formula(expr* fml, app* var, unsigned b, expr* r, rational coeff, expr* term, app_ref_vector const& vars): m_fml(fml), @@ -1750,7 +1750,7 @@ public: x_subst x_t(m_util); bounds_proc& bounds = get_bounds(x, fml); branch_formula bf; - VERIFY (m_subst.find(branch_formula(fml, x, v, 0, rational::zero(), 0, m_util.m_vars_added), bf)); + VERIFY (m_subst.find(branch_formula(fml, x, v, nullptr, rational::zero(), nullptr, m_util.m_vars_added), bf)); x_t.set_term(bf.m_term); x_t.set_coeff(bf.m_coeff); @@ -1949,7 +1949,7 @@ public: } } assign(x, fml, vl); - subst(x, vl, fml, 0); + subst(x, vl, fml, nullptr); TRACE("qe", tout << mk_pp(fml, m) << "\n";); return true; } @@ -1972,7 +1972,7 @@ public: vl = numeral(0); } assign(x, fml, vl); - subst(x, vl, fml, 0); + subst(x, vl, fml, nullptr); TRACE("qe", tout << mk_pp(fml, m) << "\n";); return true; @@ -2037,7 +2037,7 @@ public: bool get_cache(app* x, expr* fml, unsigned v, expr_ref& result) { branch_formula bf; - if (!m_subst.find(branch_formula(fml, x, v, 0, rational::zero(), 0, m_util.m_vars_added), bf)) { + if (!m_subst.find(branch_formula(fml, x, v, nullptr, rational::zero(), nullptr, m_util.m_vars_added), bf)) { return false; } SASSERT(bf.m_result); @@ -2171,7 +2171,7 @@ public: } bounds_proc& get_bounds(app* x, expr* fml) { - bounds_proc* result = 0; + bounds_proc* result = nullptr; VERIFY (m_bounds_cache.find(x, fml, result)); return *result; } @@ -2407,7 +2407,7 @@ public: } bool update_bounds(contains_app& contains_x, expr* fml) { - bounds_proc* bounds = 0; + bounds_proc* bounds = nullptr; if (m_bounds_cache.find(contains_x.x(), fml, bounds)) { return true; } @@ -2479,7 +2479,7 @@ public: } void assign(contains_app& x, expr* fml, rational const& vl) override { - nlarith::branch_conditions *brs = 0; + nlarith::branch_conditions *brs = nullptr; VERIFY (m_cache.find(x.x(), fml, brs)); SASSERT(vl.is_unsigned()); SASSERT(vl.get_unsigned() < brs->size()); @@ -2516,7 +2516,7 @@ public: } void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override { - nlarith::branch_conditions *brs = 0; + nlarith::branch_conditions *brs = nullptr; VERIFY (m_cache.find(x.x(), fml, brs)); SASSERT(vl.is_unsigned()); SASSERT(vl.get_unsigned() < brs->size()); @@ -2535,7 +2535,7 @@ public: unsigned get_weight(contains_app& x, expr* fml) override { - obj_map* weights = 0; + obj_map* weights = nullptr; unsigned weight = 0; if (!m_weights.find(fml, weights)) { weights = alloc(weight_m); diff --git a/src/qe/qe_arrays.cpp b/src/qe/qe_arrays.cpp index 6d0bf82bf..a227d755e 100644 --- a/src/qe/qe_arrays.cpp +++ b/src/qe/qe_arrays.cpp @@ -39,7 +39,7 @@ namespace qe { imp* m_imp; rw_cfg(ast_manager& m, array_util& a): - m(m), a(a), m_lits(m), m_model(0) {} + m(m), a(a), m_lits(m), m_model(nullptr) {} br_status reduce_app(func_decl* f, unsigned n, expr* const* args, expr_ref& result, proof_ref & pr) { if (a.is_select(f) && a.is_store(args[0])) { diff --git a/src/qe/qe_bool_plugin.cpp b/src/qe/qe_bool_plugin.cpp index eb0553a0e..fba76a7e6 100644 --- a/src/qe/qe_bool_plugin.cpp +++ b/src/qe/qe_bool_plugin.cpp @@ -65,7 +65,7 @@ namespace qe { CTRACE("qe", (!m.is_true(val_x) && !m.is_false(val_x)), tout << "Boolean is a don't care: " << mk_pp(x.x(), m) << "\n";); val = m.is_true(val_x)?rational::one():rational::zero(); - subst(x, val, fml, 0); + subst(x, val, fml, nullptr); return true; } diff --git a/src/qe/qe_bv_plugin.cpp b/src/qe/qe_bv_plugin.cpp index ef87f235f..603004020 100644 --- a/src/qe/qe_bv_plugin.cpp +++ b/src/qe/qe_bv_plugin.cpp @@ -61,7 +61,7 @@ namespace qe { unsigned bv_size; model_eval(x.x(), val_x); m_bv.is_numeral(val_x, val, bv_size); - subst(x, val, fml, 0); + subst(x, val, fml, nullptr); return true; } diff --git a/src/qe/qe_cmd.cpp b/src/qe/qe_cmd.cpp index eb119ce0b..f708d5223 100644 --- a/src/qe/qe_cmd.cpp +++ b/src/qe/qe_cmd.cpp @@ -31,11 +31,11 @@ public: void prepare(cmd_context & ctx) override { parametric_cmd::prepare(ctx); - m_target = 0; + m_target = nullptr; } cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { - if (m_target == 0) return CPK_EXPR; + if (m_target == nullptr) return CPK_EXPR; return parametric_cmd::next_arg_kind(ctx); } diff --git a/src/qe/qe_datatype_plugin.cpp b/src/qe/qe_datatype_plugin.cpp index 0bfe82751..58878d067 100644 --- a/src/qe/qe_datatype_plugin.cpp +++ b/src/qe/qe_datatype_plugin.cpp @@ -389,7 +389,7 @@ namespace qe { conj.push_back(m.mk_eq(l_i, r_i)); } expr* e = m.mk_and(conj.size(), conj.c_ptr()); - m_map.insert(a, e, 0); + m_map.insert(a, e, nullptr); TRACE("qe", tout << "replace: " << mk_pp(a, m) << " ==> \n" << mk_pp(e, m) << "\n";); return true; } @@ -521,7 +521,7 @@ namespace qe { // replace x by C(y1,..,yn) where y1,..,yn are fresh variables. // void subst_constructor(contains_app& x, func_decl* c, expr_ref& fml, expr_ref* def) { - subst_clos* sub = 0; + subst_clos* sub = nullptr; if (m_subst_cache.find(x.x(), c, sub)) { m_replace.apply_substitution(x.x(), sub->first, fml); @@ -588,7 +588,7 @@ namespace qe { unsigned sz = m_datatype_util.get_datatype_num_constructors(s); num_branches = rational(sz); - func_decl* c = 0, *r = 0; + func_decl* c = nullptr, *r = nullptr; // // If 'x' does not yet have a recognizer, then branch according to recognizers. @@ -620,7 +620,7 @@ namespace qe { void assign_rec(contains_app& contains_x, expr* fml, rational const& vl) { app* x = contains_x.x(); sort* s = x->get_decl()->get_range(); - func_decl* c = 0, *r = 0; + func_decl* c = nullptr, *r = nullptr; // // If 'x' does not yet have a recognizer, then branch according to recognizers. @@ -665,7 +665,7 @@ namespace qe { app* x = contains_x.x(); sort* s = x->get_decl()->get_range(); SASSERT(m_datatype_util.is_datatype(s)); - func_decl* c = 0, *r = 0; + func_decl* c = nullptr, *r = nullptr; TRACE("qe", tout << mk_pp(x, m) << " " << vl << " " << mk_pp(fml, m) << " " << (def != 0) << "\n";); // @@ -748,7 +748,7 @@ namespace qe { sort* s = x.x()->get_decl()->get_range(); unsigned sz = m_datatype_util.get_datatype_num_constructors(s); num_branches = rational(sz); - func_decl* c = 0, *r = 0; + func_decl* c = nullptr, *r = nullptr; if (sz != 1 && has_recognizer(x.x(), fml, r, c)) { TRACE("qe", tout << mk_pp(x.x(), m) << " has a recognizer\n";); @@ -768,7 +768,7 @@ namespace qe { if (sz == 1) { return; } - func_decl* c = 0, *r = 0; + func_decl* c = nullptr, *r = nullptr; if (has_recognizer(x, fml, r, c)) { TRACE("qe", tout << mk_pp(x, m) << " has a recognizer\n";); return; @@ -787,7 +787,7 @@ namespace qe { sort* s = x.x()->get_decl()->get_range(); SASSERT(m_datatype_util.is_datatype(s)); SASSERT(!m_datatype_util.is_recursive(s)); - func_decl* c = 0, *r = 0; + func_decl* c = nullptr, *r = nullptr; if (has_recognizer(x.x(), fml, r, c)) { TRACE("qe", tout << mk_pp(x.x(), m) << " has a recognizer\n";); } @@ -824,13 +824,13 @@ namespace qe { } datatype_atoms& get_eqs(app* x, expr* fml) { - datatype_atoms* eqs = 0; + datatype_atoms* eqs = nullptr; VERIFY (m_eqs_cache.find(x, fml, eqs)); return *eqs; } bool update_eqs(contains_app& contains_x, expr* fml) { - datatype_atoms* eqs = 0; + datatype_atoms* eqs = nullptr; if (m_eqs_cache.find(contains_x.x(), fml, eqs)) { return true; } diff --git a/src/qe/qe_dl_plugin.cpp b/src/qe/qe_dl_plugin.cpp index 714540e41..8d688d80c 100644 --- a/src/qe/qe_dl_plugin.cpp +++ b/src/qe/qe_dl_plugin.cpp @@ -107,7 +107,7 @@ namespace qe { subst_large_domain(x, eqs, uv, fml); } if (def) { - *def = 0; // TBD + *def = nullptr; // TBD } } @@ -169,13 +169,13 @@ namespace qe { eq_atoms& get_eqs(app* x, expr* fml) { - eq_atoms* eqs = 0; + eq_atoms* eqs = nullptr; VERIFY(m_eqs_cache.find(x, fml, eqs)); return *eqs; } bool update_eqs(contains_app& contains_x, expr* fml) { - eq_atoms* eqs = 0; + eq_atoms* eqs = nullptr; if (m_eqs_cache.find(contains_x.x(), fml, eqs)) { return true; } diff --git a/src/qe/qe_lite.cpp b/src/qe/qe_lite.cpp index 678c5e29b..8cbf6c70f 100644 --- a/src/qe/qe_lite.cpp +++ b/src/qe/qe_lite.cpp @@ -88,7 +88,7 @@ namespace eq { for (unsigned i = 0; i < definitions.size(); i++) { var * v = vars[i]; expr * t = definitions[i]; - if (t == 0 || has_quantifiers(t) || occurs_var(v->get_idx(), t)) + if (t == nullptr || has_quantifiers(t) || occurs_var(v->get_idx(), t)) definitions[i] = 0; else found = true; // found at least one candidate @@ -442,7 +442,7 @@ namespace eq { void create_substitution(unsigned sz) { m_subst_map.reset(); - m_subst_map.resize(sz, 0); + m_subst_map.resize(sz, nullptr); for (unsigned i = 0; i < m_order.size(); i++) { expr_ref cur(m_map[m_order[i]], m); // do all the previous substitutions before inserting @@ -544,7 +544,7 @@ namespace eq { } if (m.proofs_enabled()) { - pr = r == q ? 0 : m.mk_der(q, r); + pr = r == q ? nullptr : m.mk_der(q, r); } } @@ -776,7 +776,7 @@ namespace eq { m(m), a(m), dt(m), - m_is_variable(0), + m_is_variable(nullptr), m_subst(m), m_new_exprs(m), m_subst_map(m), @@ -788,7 +788,7 @@ namespace eq { void operator()(quantifier * q, expr_ref & r, proof_ref & pr) { TRACE("qe_lite", tout << mk_pp(q, m) << "\n";); - pr = 0; + pr = nullptr; r = q; reduce_quantifier(q, r, pr); if (r != q) { @@ -955,7 +955,7 @@ namespace ar { public: - der(ast_manager& m): m(m), a(m), m_is_variable(0) {} + der(ast_manager& m): m(m), a(m), m_is_variable(nullptr) {} void operator()(expr_ref_vector& fmls) { for (unsigned i = 0; i < fmls.size(); ++i) { @@ -1473,7 +1473,7 @@ namespace fm { fm(ast_manager & _m): m(_m), - m_is_variable(0), + m_is_variable(nullptr), m_allocator("fm-elim"), m_util(m), m_bvar2expr(m), @@ -1534,7 +1534,7 @@ namespace fm { reset_constraints(); m_bvar2expr.reset(); m_bvar2sign.reset(); - m_bvar2expr.push_back(0); // bvar 0 is not used + m_bvar2expr.push_back(nullptr); // bvar 0 is not used m_bvar2sign.push_back(0); m_expr2var.reset(); m_is_int.reset(); @@ -1547,7 +1547,7 @@ namespace fm { m_new_fmls.reset(); m_counter = 0; m_inconsistent = false; - m_inconsistent_core = 0; + m_inconsistent_core = nullptr; init_forbidden_set(g); } @@ -1583,7 +1583,7 @@ namespace fm { // 0 <= 0 -- > true if (c.m_c.is_pos() || (!c.m_strict && c.m_c.is_zero())) return m.mk_true(); - ineq = 0; + ineq = nullptr; } else { bool int_cnstr = all_int(c); @@ -1833,7 +1833,7 @@ namespace fm { for (unsigned i = 0; !m_inconsistent && i < sz; i++) { expr * f = g[i]; if (is_occ(f)) - add_constraint(f, 0); + add_constraint(f, nullptr); else m_new_fmls.push_back(f); } @@ -2065,7 +2065,7 @@ namespace fm { display(tout, l); tout << "\n"; display(tout, u); tout << "\n";); - return 0; // no constraint needs to be created. + return nullptr; // no constraint needs to be created. } new_lits.reset(); @@ -2109,7 +2109,7 @@ namespace fm { display(tout, l); tout << "\n"; display(tout, u); tout << "\n";); - return 0; + return nullptr; } expr_dependency * new_dep = m.mk_join(l.m_dep, u.m_dep); @@ -2121,7 +2121,7 @@ namespace fm { display(tout, u); tout << "\n";); m_inconsistent = true; m_inconsistent_core = new_dep; - return 0; + return nullptr; } constraint * new_cnstr = mk_constraint(new_lits.size(), @@ -2191,7 +2191,7 @@ namespace fm { constraint const & l_c = *(l[i]); constraint const & u_c = *(u[j]); constraint * new_c = resolve(l_c, u_c, x); - if (new_c != 0) { + if (new_c != nullptr) { num_new_cnstrs++; new_constraints.push_back(new_c); } @@ -2560,7 +2560,7 @@ class qe_lite_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("qe-lite", *g); proof_ref new_pr(m); expr_ref new_f(m); diff --git a/src/qe/qe_mbp.cpp b/src/qe/qe_mbp.cpp index 329687a36..432569ff9 100644 --- a/src/qe/qe_mbp.cpp +++ b/src/qe/qe_mbp.cpp @@ -71,7 +71,7 @@ expr_ref project_plugin::pick_equality(ast_manager& m, model& model, expr* t) { vals.push_back(val); } UNREACHABLE(); - return expr_ref(0, m); + return expr_ref(nullptr, m); } void project_plugin::partition_values(model& model, expr_ref_vector const& vals, expr_ref_vector& lits) { diff --git a/src/qe/qe_sat_tactic.cpp b/src/qe/qe_sat_tactic.cpp index 547f6bad1..4c56b74a7 100644 --- a/src/qe/qe_sat_tactic.cpp +++ b/src/qe/qe_sat_tactic.cpp @@ -149,7 +149,7 @@ namespace qe { } // callback to add constraints in branch. - void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) override { + void add_constraint(bool use_var, expr* l1 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) override { ptr_buffer args; if (l1) args.push_back(l1); if (l2) args.push_back(l2); @@ -179,7 +179,7 @@ namespace qe { m_super.m_rewriter(m_fml); TRACE("qe", model_v2_pp(tout, *model); tout << "\n"; tout << mk_pp(m_fml, m) << "\n";); - elim_var(i, m_fml, 0); + elim_var(i, m_fml, nullptr); } void project_var_full(unsigned i) { @@ -191,7 +191,7 @@ namespace qe { m_fml = result; m_super.m_rewriter(m_fml); TRACE("qe", tout << mk_pp(m_fml, m) << "\n";); - elim_var(i, m_fml, 0); + elim_var(i, m_fml, nullptr); } void project_var(unsigned i) { @@ -329,7 +329,7 @@ namespace qe { for (unsigned i = 0; i < m_solvers.size(); ++i) { dealloc(m_solvers[i]); } - m_fml = 0; + m_fml = nullptr; m_Ms.reset(); m_fparamv.reset(); m_solvers.reset(); diff --git a/src/qe/qe_tactic.cpp b/src/qe/qe_tactic.cpp index 5a8c3061c..fab1f3382 100644 --- a/src/qe/qe_tactic.cpp +++ b/src/qe/qe_tactic.cpp @@ -56,7 +56,7 @@ class qe_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("qe", *g); m_fparams.m_model = g->models_enabled(); proof_ref new_pr(m); @@ -72,7 +72,7 @@ class qe_tactic : public tactic { if (!has_quantifiers(f)) continue; m_qe(m.mk_true(), f, new_f); - new_pr = 0; + new_pr = nullptr; if (produce_proofs) { new_pr = m.mk_modus_ponens(g->pr(i), new_pr); } diff --git a/src/qe/qsat.cpp b/src/qe/qsat.cpp index 6d470c5de..f463a62e5 100644 --- a/src/qe/qsat.cpp +++ b/src/qe/qsat.cpp @@ -706,7 +706,7 @@ namespace qe { m_asms.reset(); m_pred_abs.reset(); m_vars.reset(); - m_model = 0; + m_model = nullptr; m_fa.reset(); m_ex.reset(); m_free_vars.reset(); @@ -956,7 +956,7 @@ namespace qe { ptr_vector todo; trail.push_back(fml); todo.push_back(fml); - expr* e = 0, *r = 0; + expr* e = nullptr, *r = nullptr; while (!todo.empty()) { check_cancel(); @@ -1196,8 +1196,8 @@ namespace qe { m_mode(mode), m_avars(m), m_free_vars(m), - m_objective(0), - m_value(0), + m_objective(nullptr), + m_value(nullptr), m_was_sat(false), m_gt(m) { @@ -1224,7 +1224,7 @@ namespace qe { ptr_vector fmls; expr_ref_vector defs(m); expr_ref fml(m); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; in->get_formulas(fmls); diff --git a/src/sat/sat_clause.cpp b/src/sat/sat_clause.cpp index 76a1ee8c3..67f894566 100644 --- a/src/sat/sat_clause.cpp +++ b/src/sat/sat_clause.cpp @@ -105,7 +105,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)); diff --git a/src/sat/sat_clause.h b/src/sat/sat_clause.h index 5ad08e52a..b7cf5e577 100644 --- a/src/sat/sat_clause.h +++ b/src/sat/sat_clause.h @@ -115,7 +115,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); diff --git a/src/sat/sat_probing.cpp b/src/sat/sat_probing.cpp index b23d57164..57b09c7f7 100644 --- a/src/sat/sat_probing.cpp +++ b/src/sat/sat_probing.cpp @@ -60,7 +60,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) { literal_vector::iterator it = implied_lits->begin(); literal_vector::iterator end = implied_lits->end(); diff --git a/src/sat/sat_probing.h b/src/sat/sat_probing.h index fb9b1dd30..2e1f97909 100644 --- a/src/sat/sat_probing.h +++ b/src/sat/sat_probing.h @@ -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); } diff --git a/src/sat/sat_simplifier.cpp b/src/sat/sat_simplifier.cpp index 84534bf3f..432903b4c 100644 --- a/src/sat/sat_simplifier.cpp +++ b/src/sat/sat_simplifier.cpp @@ -949,7 +949,7 @@ namespace sat { void process(literal l) { TRACE("blocked_clause", tout << "processing: " << l << "\n";); - model_converter::entry * new_entry = 0; + model_converter::entry * new_entry = nullptr; if (!process_var(l.var())) { return; } @@ -965,7 +965,7 @@ namespace sat { s.mark_all_but(c, l); if (all_tautology(l)) { TRACE("blocked_clause", tout << "new blocked clause: " << c << "\n";); - if (new_entry == 0) + if (new_entry == nullptr) new_entry = &(mc.mk(model_converter::BLOCK_LIT, l.var())); m_to_remove.push_back(&c); s.m_num_blocked_clauses++; @@ -1003,7 +1003,7 @@ namespace sat { literal l2 = it->get_literal(); s.mark_visited(l2); if (all_tautology(l)) { - if (new_entry == 0) + if (new_entry == nullptr) new_entry = &(mc.mk(model_converter::BLOCK_LIT, l.var())); TRACE("blocked_clause", tout << "new blocked clause: " << l2 << " " << l << "\n";); s.remove_bin_clause_half(l2, l, it->is_learned()); diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index dbd996cd0..a3d190854 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -36,7 +36,7 @@ namespace sat { m_checkpoint_enabled(true), m_config(p), m_ext(ext), - m_par(0), + m_par(nullptr), m_cleaner(*this), m_simplifier(*this, p), m_scc(*this, p), @@ -198,7 +198,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; } @@ -206,13 +206,13 @@ namespace sat { switch (num_lits) { case 0: 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); - return 0; + return nullptr; case 3: return mk_ter_clause(lits, learned); default: @@ -815,7 +815,7 @@ namespace sat { if (i == 1 + num_threads/2) { m_params.set_sym("phase", symbol("random")); } - solvers[i] = alloc(sat::solver, m_params, rlims[i], 0); + solvers[i] = alloc(sat::solver, m_params, rlims[i], nullptr); solvers[i]->copy(*this); solvers[i]->set_par(&par); scoped_rlimit.push_child(&solvers[i]->rlimit()); @@ -874,7 +874,7 @@ namespace sat { } } } - set_par(0); + set_par(nullptr); if (finished_id != -1 && finished_id < num_extra_solvers) { m_stats = solvers[finished_id]->m_stats; } diff --git a/src/sat/sat_solver.h b/src/sat/sat_solver.h index c275b8ee2..7f5a02ab3 100644 --- a/src/sat/sat_solver.h +++ b/src/sat/sat_solver.h @@ -315,7 +315,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; } diff --git a/src/sat/sat_solver/inc_sat_solver.cpp b/src/sat/sat_solver/inc_sat_solver.cpp index 0b0ef24d2..453fff417 100644 --- a/src/sat/sat_solver/inc_sat_solver.cpp +++ b/src/sat/sat_solver/inc_sat_solver.cpp @@ -68,7 +68,7 @@ class inc_sat_solver : public solver { typedef obj_map dep2asm_t; public: inc_sat_solver(ast_manager& m, params_ref const& p): - m(m), m_solver(p, m.limit(), 0), + m(m), m_solver(p, m.limit(), nullptr), m_optimize_model(false), m_fmls(m), m_asmsf(m), @@ -106,7 +106,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(); @@ -155,7 +155,7 @@ public: TRACE("sat", tout << _assumptions << "\n";); dep2asm_t dep2asm; - m_model = 0; + m_model = nullptr; lbool r = internalize_formulas(); if (r != l_true) return r; r = internalize_assumptions(sz, _assumptions.c_ptr(), dep2asm); @@ -258,7 +258,7 @@ public: } proof * get_proof() override { UNREACHABLE(); - return 0; + return nullptr; } lbool get_consequences_core(expr_ref_vector const& assumptions, expr_ref_vector const& vars, expr_ref_vector& conseq) override { @@ -403,8 +403,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) { @@ -515,7 +515,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); } @@ -616,7 +616,7 @@ private: m_core.reset(); for (unsigned i = 0; i < core.size(); ++i) { - expr* e = 0; + expr* e = nullptr; VERIFY(asm2dep.find(core[i].index(), e)); if (asm2fml.contains(e)) { e = asm2fml.find(e); @@ -643,7 +643,7 @@ private: void extract_model() { TRACE("sat", tout << "retrieve model " << (m_solver.model_is_current()?"present":"absent") << "\n";); if (!m_solver.model_is_current()) { - m_model = 0; + m_model = nullptr; return; } sat::model const & ll_m = m_solver.get_model(); diff --git a/src/sat/tactic/goal2sat.cpp b/src/sat/tactic/goal2sat.cpp index bb5907003..5a16d5e8c 100644 --- a/src/sat/tactic/goal2sat.cpp +++ b/src/sat/tactic/goal2sat.cpp @@ -525,7 +525,7 @@ bool goal2sat::has_unsupported_bool(goal const & g) { return test(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) { @@ -539,7 +539,7 @@ struct goal2sat::scoped_set_imp { m_owner->m_imp = i; } ~scoped_set_imp() { - m_owner->m_imp = 0; + m_owner->m_imp = nullptr; } }; @@ -703,9 +703,9 @@ struct sat2goal::imp { for (sat::bool_var v = 0; v < num_vars; v++) { checkpoint(); sat::literal l(v, false); - if (m_lit2expr.get(l.index()) == 0) { + if (m_lit2expr.get(l.index()) == nullptr) { SASSERT(m_lit2expr.get((~l).index()) == 0); - app * aux = m.mk_fresh_const(0, b); + app * aux = m.mk_fresh_const(nullptr, b); if (_mc) _mc->insert(aux, true); m_lit2expr.set(l.index(), aux); @@ -776,7 +776,7 @@ struct sat2goal::imp { }; -sat2goal::sat2goal():m_imp(0) { +sat2goal::sat2goal():m_imp(nullptr) { } void sat2goal::collect_param_descrs(param_descrs & r) { @@ -790,7 +790,7 @@ struct sat2goal::scoped_set_imp { m_owner->m_imp = i; } ~scoped_set_imp() { - m_owner->m_imp = 0; + m_owner->m_imp = nullptr; } }; diff --git a/src/sat/tactic/sat_tactic.cpp b/src/sat/tactic/sat_tactic.cpp index 3db379cb1..4bb644a43 100644 --- a/src/sat/tactic/sat_tactic.cpp +++ b/src/sat/tactic/sat_tactic.cpp @@ -34,7 +34,7 @@ class sat_tactic : public tactic { imp(ast_manager & _m, params_ref const & p): m(_m), - m_solver(p, m.limit(), 0), + m_solver(p, m.limit(), nullptr), m_params(p) { SASSERT(!m.proofs_enabled()); } @@ -44,7 +44,7 @@ class sat_tactic : public tactic { model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; fail_if_proof_generation("sat", g); bool produce_models = g->models_enabled(); bool produce_core = g->unsat_core_enabled(); @@ -74,7 +74,7 @@ class sat_tactic : public tactic { } } 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 asm2dep; @@ -85,7 +85,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 @@ -148,7 +148,7 @@ class sat_tactic : public tactic { } ~scoped_set_imp() { - m_owner->m_imp = 0; + m_owner->m_imp = nullptr; } }; @@ -158,7 +158,7 @@ class sat_tactic : public tactic { public: sat_tactic(ast_manager & m, params_ref const & p): - m_imp(0), + m_imp(nullptr), m_params(p) { } diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index b2b181977..427c1015f 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -41,7 +41,7 @@ static stopwatch g_overall_time; static stopwatch g_piece_timer; static unsigned t_parsing = 0; -static datalog::context * g_ctx = 0; +static datalog::context * g_ctx = nullptr; static datalog::rule_set * g_orig_rules; static datalog::instruction_block * g_code; static datalog::execution_context * g_ectx; @@ -257,7 +257,7 @@ unsigned read_datalog(char const * file) { true); return ERR_MEMOUT; } - register_on_timeout_proc(0); + register_on_timeout_proc(nullptr); return 0; } diff --git a/src/shell/dimacs_frontend.cpp b/src/shell/dimacs_frontend.cpp index 999574f1e..eafaa8960 100644 --- a/src/shell/dimacs_frontend.cpp +++ b/src/shell/dimacs_frontend.cpp @@ -26,7 +26,7 @@ Revision History: #include "util/gparams.h" extern bool g_display_statistics; -static sat::solver * g_solver = 0; +static sat::solver * g_solver = nullptr; static clock_t g_start_time; static void display_statistics() { @@ -134,7 +134,7 @@ unsigned read_dimacs(char const * file_name) { params_ref p = gparams::get_module("sat"); p.set_bool("produce_models", true); reslimit limit; - sat::solver solver(p, limit, 0); + sat::solver solver(p, limit, nullptr); g_solver = &solver; if (file_name) { @@ -152,7 +152,7 @@ unsigned read_dimacs(char const * file_name) { lbool r; vector tracking_clauses; - sat::solver solver2(p, limit, 0); + sat::solver solver2(p, limit, nullptr); if (p.get_bool("dimacs.core", false)) { g_solver = &solver2; sat::literal_vector assumptions; diff --git a/src/shell/lp_frontend.cpp b/src/shell/lp_frontend.cpp index c1afd5e13..c79396cd1 100644 --- a/src/shell/lp_frontend.cpp +++ b/src/shell/lp_frontend.cpp @@ -17,7 +17,7 @@ Author: #include "util/gparams.h" #include -static lp::lp_solver* g_solver = 0; +static lp::lp_solver* g_solver = nullptr; static void display_statistics() { if (g_solver && g_solver->settings().print_statistics) { @@ -95,8 +95,8 @@ void run_solver(lp_params & params, char const * mps_file_name) { // #pragma omp critical (g_display_stats) { display_statistics(); - register_on_timeout_proc(0); - g_solver = 0; + register_on_timeout_proc(nullptr); + g_solver = nullptr; } delete solver; } diff --git a/src/shell/main.cpp b/src/shell/main.cpp index f0e640d66..40c98a686 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -41,7 +41,7 @@ Revision History: typedef enum { IN_UNSPECIFIED, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_WCNF, IN_OPB, IN_Z3_LOG, IN_MPS } input_kind; std::string g_aux_input_file; -char const * g_input_file = 0; +char const * g_input_file = nullptr; bool g_standard_input = false; input_kind g_input_kind = IN_UNSPECIFIED; bool g_display_statistics = false; @@ -113,7 +113,7 @@ void display_usage() { void parse_cmd_line_args(int argc, char ** argv) { int i = 1; - char * eq_pos = 0; + char * eq_pos = nullptr; while (i < argc) { char * arg = argv[i]; @@ -145,7 +145,7 @@ void parse_cmd_line_args(int argc, char ** argv) { // allow names such as --help if (*opt_name == '-') opt_name++; - char * opt_arg = 0; + char * opt_arg = nullptr; char * colon = strchr(arg, ':'); if (colon) { opt_arg = colon + 1; @@ -200,7 +200,7 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "v") == 0) { if (!opt_arg) error("option argument (-v:level) is missing."); - long lvl = strtol(opt_arg, 0, 10); + long lvl = strtol(opt_arg, nullptr, 10); set_verbosity_level(lvl); } else if (strcmp(opt_name, "file") == 0) { @@ -209,7 +209,7 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "T") == 0) { if (!opt_arg) error("option argument (-T:timeout) is missing."); - long tm = strtol(opt_arg, 0, 10); + long tm = strtol(opt_arg, nullptr, 10); set_timeout(tm * 1000); } else if (strcmp(opt_name, "t") == 0) { diff --git a/src/shell/opt_frontend.cpp b/src/shell/opt_frontend.cpp index 8154cbde4..714188505 100644 --- a/src/shell/opt_frontend.cpp +++ b/src/shell/opt_frontend.cpp @@ -17,7 +17,7 @@ Copyright (c) 2015 Microsoft Corporation extern bool g_display_statistics; static bool g_first_interrupt = true; -static opt::context* g_opt = 0; +static opt::context* g_opt = nullptr; static double g_start_time = 0; static unsigned_vector g_handles; @@ -115,8 +115,8 @@ static unsigned parse_opt(std::istream& in, bool is_wcnf) { #pragma omp critical (g_display_stats) { display_statistics(); - register_on_timeout_proc(0); - g_opt = 0; + register_on_timeout_proc(nullptr); + g_opt = nullptr; } return 0; } diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index 8c716a81a..7218558fa 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -34,7 +34,7 @@ Revision History: extern bool g_display_statistics; static clock_t g_start_time; -static cmd_context * g_cmd_context = 0; +static cmd_context * g_cmd_context = nullptr; static void display_statistics() { clock_t end_time = clock(); @@ -102,7 +102,7 @@ unsigned read_smtlib2_commands(char const * file_name) { #pragma omp critical (g_display_stats) { display_statistics(); - g_cmd_context = 0; + g_cmd_context = nullptr; } return result ? 0 : 1; } diff --git a/src/smt/arith_eq_adapter.cpp b/src/smt/arith_eq_adapter.cpp index febec9565..593eb1d71 100644 --- a/src/smt/arith_eq_adapter.cpp +++ b/src/smt/arith_eq_adapter.cpp @@ -154,8 +154,8 @@ namespace smt { // Requires that the theory arithmetic internalizer accept non simplified terms of the form t1 - t2 // if t1 and t2 already have slacks (theory variables) associated with them. // It also accepts terms with repeated variables (Issue #429). - app * le = 0; - app * ge = 0; + app * le = nullptr; + app * ge = nullptr; if (m_util.is_numeral(t1)) std::swap(t1, t2); if (m_util.is_numeral(t2)) { diff --git a/src/smt/arith_eq_adapter.h b/src/smt/arith_eq_adapter.h index 4a8a293e3..42aae6821 100644 --- a/src/smt/arith_eq_adapter.h +++ b/src/smt/arith_eq_adapter.h @@ -53,7 +53,7 @@ namespace smt { expr * m_t1_eq_t2; expr * m_le; expr * m_ge; - data():m_t1_eq_t2(0), m_le(0), m_ge(0) {} + data():m_t1_eq_t2(nullptr), m_le(nullptr), m_ge(nullptr) {} data(expr * t1_eq_t2, expr * le, expr * ge):m_t1_eq_t2(t1_eq_t2), m_le(le), m_ge(ge) {} }; diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 6ddce341d..465371434 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -90,7 +90,7 @@ void asserted_formulas::push_assertion(expr * e, proof * pr, vectorget_num_args(); ++i) { expr* arg = to_app(e)->get_arg(i); - proof_ref _pr(m.proofs_enabled() ? m.mk_and_elim(pr, i) : 0, m); + proof_ref _pr(m.proofs_enabled() ? m.mk_and_elim(pr, i) : nullptr, m); push_assertion(arg, _pr, result); } } else if (m.is_not(e, e1) && m.is_or(e1)) { for (unsigned i = 0; i < to_app(e1)->get_num_args(); ++i) { expr* arg = to_app(e1)->get_arg(i); - proof_ref _pr(m.proofs_enabled() ? m.mk_not_or_elim(pr, i) : 0, m); + proof_ref _pr(m.proofs_enabled() ? m.mk_not_or_elim(pr, i) : nullptr, m); expr_ref narg(mk_not(m, arg), m); push_assertion(narg, _pr, result); } @@ -376,7 +376,7 @@ void asserted_formulas::nnf_cnf() { unsigned sz2 = push_todo.size(); for (unsigned k = 0; k < sz2; k++) { expr * n = push_todo.get(k); - pr = 0; + pr = nullptr; m_rewriter(n, r1, pr1); CASSERT("well_sorted",is_well_sorted(m, r1)); if (canceled()) { @@ -598,15 +598,15 @@ void asserted_formulas::compute_depth(expr* e) { proof * asserted_formulas::get_inconsistency_proof() const { if (!inconsistent()) - return 0; + return nullptr; if (!m.proofs_enabled()) - return 0; + return nullptr; for (justified_expr const& j : m_formulas) { if (m.is_false(j.get_fml())) return j.get_proof(); } UNREACHABLE(); - return 0; + return nullptr; } void asserted_formulas::refine_inj_axiom_fn::simplify(justified_expr const& j, expr_ref& n, proof_ref& p) { diff --git a/src/smt/cached_var_subst.cpp b/src/smt/cached_var_subst.cpp index 7c0997bc5..1f184c39c 100644 --- a/src/smt/cached_var_subst.cpp +++ b/src/smt/cached_var_subst.cpp @@ -44,7 +44,7 @@ void cached_var_subst::reset() { void cached_var_subst::operator()(quantifier * qa, unsigned num_bindings, smt::enode * const * bindings, expr_ref & result) { m_new_keys.reserve(num_bindings+1, 0); key * new_key = m_new_keys[num_bindings]; - if (new_key == 0) + if (new_key == nullptr) new_key = static_cast(m_region.allocate(sizeof(key) + sizeof(expr*)*num_bindings)); new_key->m_qa = qa; @@ -52,7 +52,7 @@ void cached_var_subst::operator()(quantifier * qa, unsigned num_bindings, smt::e for (unsigned i = 0; i < num_bindings; i++) new_key->m_bindings[i] = bindings[i]->get_owner(); - instances::entry * entry = m_instances.insert_if_not_there2(new_key, 0); + instances::entry * entry = m_instances.insert_if_not_there2(new_key, nullptr); if (entry->get_data().m_key != new_key) { SASSERT(entry->get_data().m_value != 0); // entry was already there diff --git a/src/smt/dyn_ack.cpp b/src/smt/dyn_ack.cpp index dd77640bc..a006c9dd5 100644 --- a/src/smt/dyn_ack.cpp +++ b/src/smt/dyn_ack.cpp @@ -299,7 +299,7 @@ namespace smt { TRACE("dyn_ack", tout << "del_clause_eh: "; m_context.display_clause(tout, cls); tout << "\n";); m_context.m_stats.m_num_del_dyn_ack++; - app_pair p((app*)0,(app*)0); + app_pair p((app*)nullptr,(app*)nullptr); if (m_clause2app_pair.find(cls, p)) { SASSERT(p.first && p.second); m_instantiated.erase(p); @@ -371,7 +371,7 @@ namespace smt { lits.push_back(mk_eq(n1, n2)); clause_del_eh * del_eh = alloc(dyn_ack_clause_del_eh, *this); - justification * js = 0; + justification * js = nullptr; if (m_manager.proofs_enabled()) js = alloc(dyn_ack_justification, n1, n2); clause * cls = m_context.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, del_eh); @@ -423,7 +423,7 @@ namespace smt { lits.push_back(mk_eq(n1, n2)); clause_del_eh * del_eh = alloc(dyn_ack_clause_del_eh, *this); - justification * js = 0; + justification * js = nullptr; if (m_manager.proofs_enabled()) js = alloc(dyn_ack_justification, n1, n2); clause * cls = m_context.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, del_eh); diff --git a/src/smt/expr_context_simplifier.cpp b/src/smt/expr_context_simplifier.cpp index c420543e1..bce28420d 100644 --- a/src/smt/expr_context_simplifier.cpp +++ b/src/smt/expr_context_simplifier.cpp @@ -311,7 +311,7 @@ bool expr_context_simplifier::is_false(expr* e) const { // expr_strong_context_simplifier::expr_strong_context_simplifier(smt_params& p, ast_manager& m): - m_manager(m), m_arith(m), m_fn(0,m), m_solver(m, p) { + m_manager(m), m_arith(m), m_fn(nullptr,m), m_solver(m, p) { sort* i_sort = m_arith.mk_int(); m_fn = m.mk_func_decl(symbol(0xbeef101), i_sort, m.mk_bool_sort()); } @@ -358,7 +358,7 @@ void expr_strong_context_simplifier::simplify_basic(expr* fml, expr_ref& result) m_solver.push(); while (!todo.empty()) { - r = 0; + r = nullptr; ptr_buffer args; expr* e = todo.back(); unsigned pos = parent_ids.back(); @@ -405,7 +405,7 @@ void expr_strong_context_simplifier::simplify_basic(expr* fml, expr_ref& result) self_pos = self_ids.back(); sz = a->get_num_args(); - n2 = 0; + n2 = nullptr; for (unsigned i = 0; i < sz; ++i) { expr* arg = a->get_arg(i); @@ -620,7 +620,7 @@ void expr_strong_context_simplifier::simplify_model_based(expr* fml, expr_ref& r m_solver.push(); while (!todo.empty()) { - r = 0; + r = nullptr; ptr_buffer args; expr* e = todo.back(); unsigned pos = parent_ids.back(); @@ -681,7 +681,7 @@ void expr_strong_context_simplifier::simplify_model_based(expr* fml, expr_ref& r self_pos = self_ids.back(); sz = a->get_num_args(); - n2 = 0; + n2 = nullptr; for (unsigned i = 0; i < sz; ++i) { expr* arg = a->get_arg(i); diff --git a/src/smt/fingerprints.cpp b/src/smt/fingerprints.cpp index 435350396..832f539df 100644 --- a/src/smt/fingerprints.cpp +++ b/src/smt/fingerprints.cpp @@ -24,7 +24,7 @@ namespace smt { m_data(d), m_data_hash(d_h), m_num_args(n), - m_args(0) { + m_args(nullptr) { m_args = new (r) enode*[n]; memcpy(m_args, args, sizeof(enode*) * n); } @@ -54,7 +54,7 @@ namespace smt { fingerprint * fingerprint_set::insert(void * data, unsigned data_hash, unsigned num_args, enode * const * args) { fingerprint * d = mk_dummy(data, data_hash, num_args, args); if (m_set.contains(d)) - return 0; + return nullptr; TRACE("fingerprint_bug", tout << "1) inserting: " << data_hash << " num_args: " << num_args; for (unsigned i = 0; i < num_args; i++) tout << " " << args[i]->get_owner_id(); tout << "\n";); @@ -64,7 +64,7 @@ namespace smt { TRACE("fingerprint_bug", tout << "failed: " << data_hash << " num_args: " << num_args; for (unsigned i = 0; i < num_args; i++) tout << " " << d->m_args[i]->get_owner_id(); tout << "\n";); - return 0; + return nullptr; } TRACE("fingerprint_bug", tout << "2) inserting: " << data_hash << " num_args: " << num_args; for (unsigned i = 0; i < num_args; i++) tout << " " << args[i]->get_owner_id(); diff --git a/src/smt/mam.cpp b/src/smt/mam.cpp index 7fd1dd9d0..5c881684f 100644 --- a/src/smt/mam.cpp +++ b/src/smt/mam.cpp @@ -423,20 +423,20 @@ namespace smt { instruction * curr = head; out << *curr; curr = curr->m_next; - while (curr != 0 && curr->m_opcode != CHOOSE && curr->m_opcode != NOOP) { + while (curr != nullptr && curr->m_opcode != CHOOSE && curr->m_opcode != NOOP) { out << "\n"; out << *curr; curr = curr->m_next; } out << "\n"; - if (curr != 0) { + if (curr != nullptr) { display_children(out, static_cast(curr), indent + 1); } } void display_children(std::ostream & out, choose * first_child, unsigned indent) const { choose * curr = first_child; - while (curr != 0) { + while (curr != nullptr) { display_seq(out, curr, indent); curr = curr->m_alt; } @@ -485,7 +485,7 @@ namespace smt { m_filter_candidates(filter_candidates), m_num_regs(num_args + 1), m_num_choices(0), - m_root(0) { + m_root(nullptr) { DEBUG_CODE(m_context = 0;); #ifdef _PROFILE_MAM m_counter = 0; @@ -607,7 +607,7 @@ namespace smt { void * mem = m_region.allocate(size); OP * r = new (mem) OP; r->m_opcode = op; - r->m_next = 0; + r->m_next = nullptr; #ifdef _PROFILE_MAM r->m_counter = 0; #endif @@ -696,7 +696,7 @@ namespace smt { choose * mk_noop() { choose * r = mk_instr(NOOP, sizeof(choose)); - r->m_alt = 0; + r->m_alt = nullptr; return r; } @@ -923,7 +923,7 @@ namespace smt { */ void linearise_core() { m_aux.reset(); - app * first_app = 0; + app * first_app = nullptr; unsigned first_app_reg; unsigned first_app_sz; unsigned first_app_num_unbound_vars; @@ -1111,7 +1111,7 @@ namespace smt { // multi_pattern support for (unsigned i = 1; i < num_args; i++) { // select the pattern with the biggest number of bound variables - app * best = 0; + app * best = nullptr; unsigned best_num_bvars = 0; unsigned best_j = 0; bool found_bounded_mp = false; @@ -1127,7 +1127,7 @@ namespace smt { found_bounded_mp = true; break; } - if (best == 0 || (num_bvars > best_num_bvars)) { + if (best == nullptr || (num_bvars > best_num_bvars)) { best = p; best_num_bvars = num_bvars; best_j = j; @@ -1286,16 +1286,16 @@ namespace smt { choose * find_best_child(choose * first_child) { unsigned num_too_simple = 0; - choose * best_child = 0; + choose * best_child = nullptr; unsigned max_compatibility = 0; choose * curr_child = first_child; - while (curr_child != 0) { + while (curr_child != nullptr) { bool simple = false; unsigned curr_compatibility = get_compatibility_measure(curr_child, simple); if (simple) { num_too_simple++; if (num_too_simple > FIND_BEST_CHILD_THRESHOLD) - return 0; // it is unlikely we will find a compatible node + return nullptr; // it is unlikely we will find a compatible node } if (curr_compatibility > max_compatibility) { best_child = curr_child; @@ -1310,7 +1310,7 @@ namespace smt { unsigned ireg = instr->m_ireg; expr * n = m_registers[ireg]; return - n != 0 && + n != nullptr && is_app(n) && // It is wasteful to use a bind of a ground term. // Actually, in the rest of the code I assume that. @@ -1450,7 +1450,7 @@ namespace smt { unsigned weight = 0; unsigned num_instr = 0; instruction * curr = child->m_next; - while (curr != 0 && curr->m_opcode != CHOOSE && curr->m_opcode != NOOP) { + while (curr != nullptr && curr->m_opcode != CHOOSE && curr->m_opcode != NOOP) { num_instr++; switch (curr->m_opcode) { case BIND1: case BIND2: case BIND3: case BIND4: case BIND5: case BIND6: case BINDN: @@ -1493,7 +1493,7 @@ namespace smt { } curr = curr->m_next; } - if (num_instr > SIMPLE_SEQ_THRESHOLD || (curr != 0 && curr->m_opcode == CHOOSE)) + if (num_instr > SIMPLE_SEQ_THRESHOLD || (curr != nullptr && curr->m_opcode == CHOOSE)) simple = false; unsigned_vector::iterator it = m_to_reset.begin(); unsigned_vector::iterator end = m_to_reset.end(); @@ -1509,7 +1509,7 @@ namespace smt { TRACE("mam_compiler_detail", tout << "processing head: " << *head << "\n";); instruction * curr = head->m_next; instruction * last = head; - while (curr != 0 && curr->m_opcode != CHOOSE && curr->m_opcode != NOOP) { + while (curr != nullptr && curr->m_opcode != CHOOSE && curr->m_opcode != NOOP) { TRACE("mam_compiler_detail", tout << "processing instr: " << *curr << "\n";); switch (curr->m_opcode) { case BIND1: case BIND2: case BIND3: case BIND4: case BIND5: case BIND6: case BINDN: @@ -1680,7 +1680,7 @@ namespace smt { SASSERT(curr->m_opcode == CHOOSE); choose * first_child = static_cast(curr); choose * best_child = find_best_child(first_child); - if (best_child == 0) { + if (best_child == nullptr) { // There is no compatible child // Suppose the sequence is: // head -> c1 -> ... -> (cn == last) -> first_child; @@ -1902,7 +1902,7 @@ namespace smt { curr = curr->get_next(); } while (curr != first); - return 0; + return nullptr; } enode * get_next_f_app(func_decl * lbl, unsigned num_expected_args, enode * first, enode * curr) { @@ -1914,7 +1914,7 @@ namespace smt { } curr = curr->get_next(); } - return 0; + return nullptr; } /** @@ -2094,7 +2094,7 @@ namespace smt { enode_vector * interpreter::mk_depth2_vector(joint2 * j2, func_decl * f, unsigned i) { enode * n = m_registers[j2->m_reg]->get_root(); if (n->get_num_parents() == 0) - return 0; + return nullptr; unsigned num_args = n->get_num_args(); enode_vector * v = mk_enode_vector(); enode_vector::const_iterator it1 = n->begin_parents(); @@ -2132,7 +2132,7 @@ namespace smt { // quick filter... check if any of the joint points have zero parents... for (unsigned i = 0; i < num_args; i++) { void * bare = c->m_joints[i]; - enode * n = 0; + enode * n = nullptr; switch (GET_TAG(bare)) { case NULL_TAG: goto non_depth1; @@ -2147,20 +2147,20 @@ namespace smt { } r = n->get_root(); if (m_use_filters && r->get_plbls().empty_intersection(c->m_lbl_set)) - return 0; + return nullptr; if (r->get_num_parents() == 0) - return 0; + return nullptr; non_depth1: ; } // traverse each joint and select the best one. - enode_vector * best_v = 0; + enode_vector * best_v = nullptr; for (unsigned i = 0; i < num_args; i++) { enode * bare = c->m_joints[i]; - enode_vector * curr_v = 0; + enode_vector * curr_v = nullptr; switch (GET_TAG(bare)) { case NULL_TAG: - curr_v = 0; + curr_v = nullptr; break; case GROUND_TERM_TAG: curr_v = mk_depth1_vector(UNTAG(enode *, bare), lbl, i); @@ -2172,14 +2172,14 @@ namespace smt { curr_v = mk_depth2_vector(UNTAG(joint2 *, bare), lbl, i); break; } - if (curr_v != 0) { - if (curr_v->size() < min_sz && (best_v == 0 || curr_v->size() < best_v->size())) { + if (curr_v != nullptr) { + if (curr_v->size() < min_sz && (best_v == nullptr || curr_v->size() < best_v->size())) { if (best_v) recycle_enode_vector(best_v); best_v = curr_v; if (best_v->empty()) { recycle_enode_vector(best_v); - return 0; + return nullptr; } } else { @@ -2191,10 +2191,10 @@ namespace smt { bp.m_instr = c; bp.m_old_max_generation = m_max_generation; bp.m_old_used_enodes_size = m_used_enodes.size(); - if (best_v == 0) { + if (best_v == nullptr) { TRACE("mam_bug", tout << "m_top: " << m_top << ", m_backtrack_stack.size(): " << m_backtrack_stack.size() << "\n"; tout << *c << "\n";); - bp.m_to_recycle = 0; + bp.m_to_recycle = nullptr; bp.m_it = m_context.begin_enodes_of(lbl); bp.m_end = m_context.end_enodes_of(lbl); } @@ -2211,7 +2211,7 @@ namespace smt { break; } if (bp.m_it == bp.m_end) - return 0; + return nullptr; m_top++; update_max_generation(*(bp.m_it)); return *(bp.m_it); @@ -2648,7 +2648,7 @@ namespace smt { m_num_args = static_cast(m_pc)->m_num_args; m_oreg = static_cast(m_pc)->m_oreg; m_app = init_continue(static_cast(m_pc), m_num_args); - if (m_app == 0) + if (m_app == nullptr) goto backtrack; m_pattern_instances.push_back(m_app); TRACE("mam_int", tout << "continue candidate:\n" << mk_ll_pp(m_app->get_owner(), m_ast_manager);); @@ -2911,7 +2911,7 @@ namespace smt { if (lbl_id < m_trees.size()) return m_trees[lbl_id]; else - return 0; + return nullptr; } ptr_vector::iterator begin_code_trees() { @@ -2974,11 +2974,11 @@ namespace smt { if (p1->m_label != p2->m_label || p1->m_arg_idx != p2->m_arg_idx || p1->m_pattern_idx != p2->m_pattern_idx || - (p1->m_child == 0) != (p2->m_child == 0)) { + (p1->m_child == nullptr) != (p2->m_child == nullptr)) { return false; } - if (p1->m_child == 0 && p2->m_child == 0) + if (p1->m_child == nullptr && p2->m_child == nullptr) return true; p1 = p1->m_child; @@ -3014,11 +3014,11 @@ namespace smt { m_arg_idx(p->m_arg_idx), m_ground_arg_idx(p->m_ground_arg_idx), m_ground_arg(p->m_ground_arg), - m_code(0), + m_code(nullptr), m_filter(h(p->m_label)), - m_sibling(0), - m_first_child(0), - m_todo(0) { + m_sibling(nullptr), + m_first_child(nullptr), + m_todo(nullptr) { #ifdef _PROFILE_PATH_TREE m_counter = 0; m_num_eq_visited = 0; @@ -3029,7 +3029,7 @@ namespace smt { void display(std::ostream & out, unsigned indent) { path_tree * curr = this; - while (curr != 0) { + while (curr != nullptr) { for (unsigned i = 0; i < indent; i++) out << " "; out << curr->m_label->get_name() << ":" << curr->m_arg_idx; if (curr->m_ground_arg) @@ -3122,7 +3122,7 @@ namespace smt { } void add_candidate(code_tree * t, enode * app) { - if (t != 0) { + if (t != nullptr) { TRACE("mam_candidate", tout << "adding candidate:\n" << mk_ll_pp(app->get_owner(), m_ast_manager);); if (!t->has_candidates()) m_to_match.push_back(t); @@ -3221,7 +3221,7 @@ namespace smt { for (unsigned j = 0; j < APPROX_SET_CAPACITY; j++) { m_pp[i][j].first = 0; m_pp[i][j].second = 0; - m_pc[i][j] = 0; + m_pc[i][j] = nullptr; } } } @@ -3240,10 +3240,10 @@ namespace smt { SASSERT(m_ast_manager.is_pattern(mp)); SASSERT(p != 0); unsigned pat_idx = p->m_pattern_idx; - path_tree * head = 0; - path_tree * curr = 0; - path_tree * prev = 0; - while (p != 0) { + path_tree * head = nullptr; + path_tree * curr = nullptr; + path_tree * prev = nullptr; + while (p != nullptr) { curr = new (m_region) path_tree(p, m_lbl_hasher); if (prev) prev->m_first_child = curr; @@ -3260,9 +3260,9 @@ namespace smt { void insert(path_tree * t, path * p, quantifier * qa, app * mp) { SASSERT(m_ast_manager.is_pattern(mp)); path_tree * head = t; - path_tree * prev_sibling = 0; + path_tree * prev_sibling = nullptr; bool found_label = false; - while (t != 0) { + while (t != nullptr) { if (t->m_label == p->m_label) { found_label = true; if (t->m_arg_idx == p->m_arg_idx && @@ -3270,8 +3270,8 @@ namespace smt { t->m_ground_arg_idx == p->m_ground_arg_idx ) { // found compatible node - if (t->m_first_child == 0) { - if (p->m_child == 0) { + if (t->m_first_child == nullptr) { + if (p->m_child == nullptr) { SASSERT(t->m_code != 0); insert_code(t, qa, mp, p->m_pattern_idx); } @@ -3281,7 +3281,7 @@ namespace smt { } } else { - if (p->m_child == 0) { + if (p->m_child == nullptr) { if (t->m_code) { insert_code(t, qa, mp, p->m_pattern_idx); } @@ -3393,7 +3393,7 @@ namespace smt { return mk_enode(m_context, qa, to_app(arg)); } } - return 0; + return nullptr; } /** @@ -3460,7 +3460,7 @@ namespace smt { unsigned num_patterns = mp->get_num_args(); for (unsigned i = 0; i < num_patterns; i++) { app * pat = to_app(mp->get_arg(i)); - update_filters(pat, 0, qa, mp, i); + update_filters(pat, nullptr, qa, mp, i); } } @@ -3496,7 +3496,7 @@ namespace smt { \brief Collect new E-matching candidates using the inverted path index t. */ void collect_parents(enode * r, path_tree * t) { - if (t == 0) + if (t == nullptr) return; #ifdef _PROFILE_PATH_TREE t->m_watch.start(); @@ -3604,7 +3604,7 @@ namespace smt { // Filter 2. ( // curr_tree has no support for the filter based on a ground argument. - curr_tree->m_ground_arg == 0 || + curr_tree->m_ground_arg == nullptr || // checks whether the child of the parent is equal to the expected ground argument. is_eq(curr_tree->m_ground_arg, curr_parent->get_arg(curr_tree->m_ground_arg_idx)) )) { @@ -3614,7 +3614,7 @@ namespace smt { } if (curr_tree->m_first_child) { path_tree * child = curr_tree->m_first_child; - if (child->m_todo == 0) { + if (child->m_todo == nullptr) { child->m_todo = mk_tmp_vector(); m_todo.push_back(child); } @@ -3636,7 +3636,7 @@ namespace smt { } } recycle(t->m_todo); - t->m_todo = 0; + t->m_todo = nullptr; // remove both marks. unmark_enodes(to_unmark->size(), to_unmark->c_ptr()); unmark_enodes2(to_unmark2->size(), to_unmark2->c_ptr()); @@ -3812,8 +3812,8 @@ namespace smt { m_interpreter(ctx, *this, use_filters), m_trees(m_ast_manager, m_compiler, m_trail_stack), m_region(m_trail_stack.get_region()), - m_r1(0), - m_r2(0) { + m_r1(nullptr), + m_r2(nullptr) { DEBUG_CODE(m_trees.set_context(&ctx);); DEBUG_CODE(m_check_missing_instances = false;); reset_pp_pc(); diff --git a/src/smt/old_interval.cpp b/src/smt/old_interval.cpp index d126c2f32..da589893b 100644 --- a/src/smt/old_interval.cpp +++ b/src/smt/old_interval.cpp @@ -157,8 +157,8 @@ interval::interval(v_dependency_manager & m): m_upper(true), m_lower_open(true), m_upper_open(true), - m_lower_dep(0), - m_upper_dep(0) { + m_lower_dep(nullptr), + m_upper_dep(nullptr) { } /** @@ -215,12 +215,12 @@ interval::interval(v_dependency_manager & m, rational const & val, bool open, bo m_lower_dep = d; m_upper = ext_numeral(true); m_upper_open = true; - m_upper_dep = 0; + m_upper_dep = nullptr; } else { m_lower = ext_numeral(false); m_lower_open = true; - m_lower_dep = 0; + m_lower_dep = nullptr; m_upper = ext_numeral(val); m_upper_open = open; m_upper_dep = d; @@ -252,8 +252,8 @@ interval & interval::operator+=(interval const & other) { m_upper += other.m_upper; m_lower_open |= other.m_lower_open; m_upper_open |= other.m_upper_open; - m_lower_dep = m_lower.is_infinite() ? 0 : m_manager.mk_join(m_lower_dep, other.m_lower_dep); - m_upper_dep = m_upper.is_infinite() ? 0 : m_manager.mk_join(m_upper_dep, other.m_upper_dep); + m_lower_dep = m_lower.is_infinite() ? nullptr : m_manager.mk_join(m_lower_dep, other.m_lower_dep); + m_upper_dep = m_upper.is_infinite() ? nullptr : m_manager.mk_join(m_upper_dep, other.m_upper_dep); return *this; } @@ -283,7 +283,7 @@ v_dependency * interval::join_opt(v_dependency * d1, v_dependency * d2, v_depend return join(d1, d2); if (opt2 == d1 || opt2 == d2) return join(d1, d2); - if (opt1 == 0 || opt2 == 0) + if (opt1 == nullptr || opt2 == nullptr) return join(d1, d2); // TODO: more opts... return join(d1, d2, opt1); @@ -331,8 +331,8 @@ interval & interval::operator*=(interval const & other) { m_upper_open = a_o || c_o; SASSERT(a.is_neg() && c.is_neg()); m_lower = new_lower; m_upper = new_upper; - m_lower_dep = m_lower.is_infinite() ? 0 : join(b_d, d_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join_opt(a_d, c_d, b_d, d_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join(b_d, d_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join_opt(a_d, c_d, b_d, d_d); } else if (other.is_M()) { // a <= x <= b <= 0, y <= d, d > 0 --> a*d <= x*y (uses the fact that b is not positive) @@ -344,8 +344,8 @@ interval & interval::operator*=(interval const & other) { m_upper_open = a_o || c_o; m_lower = new_lower; m_upper = new_upper; - m_lower_dep = m_lower.is_infinite() ? 0 : join(a_d, d_d, b_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join(a_d, c_d, b_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join(a_d, d_d, b_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join(a_d, c_d, b_d); } else { // a <= x <= b <= 0, 0 <= c <= y <= d --> a*d <= x*y (uses the fact that x is neg (b is not positive) or y is pos (c is not negative)) @@ -359,8 +359,8 @@ interval & interval::operator*=(interval const & other) { m_upper_open = (is_N0_old || other.is_P0()) ? false : (b_o || c_o); m_lower = new_lower; m_upper = new_upper; - m_lower_dep = m_lower.is_infinite() ? 0 : join_opt(a_d, d_d, b_d, c_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join(b_d, c_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join_opt(a_d, d_d, b_d, c_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join(b_d, c_d); } } else if (is_M()) { @@ -374,8 +374,8 @@ interval & interval::operator*=(interval const & other) { m_upper_open = a_o || c_o; SASSERT(a.is_neg() && c.is_neg()); m_lower = new_lower; m_upper = new_upper; - m_lower_dep = m_lower.is_infinite() ? 0 : join(b_d, c_d, d_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join(a_d, c_d, d_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join(b_d, c_d, d_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join(a_d, c_d, d_d); } else if (other.is_M()) { TRACE("interval_bug", tout << "(M, M)\n";); @@ -404,8 +404,8 @@ interval & interval::operator*=(interval const & other) { m_upper = bd; m_upper_open = bd_o; } - m_lower_dep = m_lower.is_infinite() ? 0 : join(a_d, b_d, c_d, d_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join(a_d, b_d, c_d, d_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join(a_d, b_d, c_d, d_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join(a_d, b_d, c_d, d_d); } else { // a < 0, a <= x, 0 <= c <= y <= d --> a*d <= x*y (uses the fact that c is not negative) @@ -418,8 +418,8 @@ interval & interval::operator*=(interval const & other) { m_upper_open = b_o || d_o; SASSERT(b.is_pos() && d.is_pos()); m_lower = new_lower; m_upper = new_upper; - m_lower_dep = m_lower.is_infinite() ? 0 : join(a_d, d_d, c_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join(b_d, d_d, c_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join(a_d, d_d, c_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join(b_d, d_d, c_d); } } else { @@ -435,8 +435,8 @@ interval & interval::operator*=(interval const & other) { m_upper_open = (is_P0_old || other.is_N0()) ? false : a_o || d_o; m_lower = new_lower; m_upper = new_upper; - m_lower_dep = m_lower.is_infinite() ? 0 : join_opt(b_d, c_d, a_d, d_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join(a_d, d_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join_opt(b_d, c_d, a_d, d_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join(a_d, d_d); } else if (other.is_M()) { // 0 <= a <= x <= b, c <= y --> b*c <= x*y (uses the fact that a is not negative) @@ -448,8 +448,8 @@ interval & interval::operator*=(interval const & other) { m_upper_open = b_o || d_o; m_lower = new_lower; m_upper = new_upper; - m_lower_dep = m_lower.is_infinite() ? 0 : join(b_d, c_d, a_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join(b_d, d_d, a_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join(b_d, c_d, a_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join(b_d, d_d, a_d); } else { // 0 <= a <= x, 0 <= c <= y --> a*c <= x*y @@ -462,8 +462,8 @@ interval & interval::operator*=(interval const & other) { m_upper_open = b_o || d_o; SASSERT(b.is_pos() && d.is_pos()); m_lower = new_lower; m_upper = new_upper; - m_lower_dep = m_lower.is_infinite() ? 0 : join(a_d, c_d); - m_upper_dep = m_upper.is_infinite() ? 0 : join_opt(b_d, d_d, a_d, c_d); + m_lower_dep = m_lower.is_infinite() ? nullptr : join(a_d, c_d); + m_upper_dep = m_upper.is_infinite() ? nullptr : join_opt(b_d, d_d, a_d, c_d); } } TRACE("interval_bug", tout << "operator*= result: " << *this << "\n";); @@ -590,7 +590,7 @@ void interval::expt(unsigned n) { // 0 < a <= x <= b --> x^n <= b^n (use lower and upper bound -- need the fact that x is positive) m_lower.expt(n); m_upper.expt(n); - m_upper_dep = m_upper.is_infinite() ? 0 : m_manager.mk_join(m_lower_dep, m_upper_dep); + m_upper_dep = m_upper.is_infinite() ? nullptr : m_manager.mk_join(m_lower_dep, m_upper_dep); } else if (m_upper.is_neg()) { // [l, u]^n = [u^n, l^n] if u < 0 @@ -601,7 +601,7 @@ void interval::expt(unsigned n) { std::swap(m_lower_dep, m_upper_dep); m_lower.expt(n); m_upper.expt(n); - m_upper_dep = m_upper.is_infinite() ? 0 : m_manager.mk_join(m_lower_dep, m_upper_dep); + m_upper_dep = m_upper.is_infinite() ? nullptr : m_manager.mk_join(m_lower_dep, m_upper_dep); } else { // [l, u]^n = [0, max{l^n, u^n}] otherwise @@ -614,10 +614,10 @@ void interval::expt(unsigned n) { m_upper = m_lower; m_upper_open = m_lower_open; } - m_upper_dep = m_upper.is_infinite() ? 0 : m_manager.mk_join(m_lower_dep, m_upper_dep); + m_upper_dep = m_upper.is_infinite() ? nullptr : m_manager.mk_join(m_lower_dep, m_upper_dep); m_lower = ext_numeral(0); m_lower_open = false; - m_lower_dep = 0; + m_lower_dep = nullptr; } } else { diff --git a/src/smt/old_interval.h b/src/smt/old_interval.h index e9cb73b8f..1928a1c70 100644 --- a/src/smt/old_interval.h +++ b/src/smt/old_interval.h @@ -80,7 +80,7 @@ class old_interval { public: explicit old_interval(v_dependency_manager & m); explicit old_interval(v_dependency_manager & m, rational const & lower, bool l_open, v_dependency * l_dep, rational const & upper, bool u_open, v_dependency * u_dep); - explicit old_interval(v_dependency_manager & m, rational const & val, v_dependency * l_dep = 0, v_dependency * u_dep = 0); + explicit old_interval(v_dependency_manager & m, rational const & val, v_dependency * l_dep = nullptr, v_dependency * u_dep = nullptr); explicit old_interval(v_dependency_manager & m, rational const & val, bool open, bool lower, v_dependency * d); explicit old_interval(v_dependency_manager & m, ext_numeral const& lower, bool l_open, v_dependency * l_dep, ext_numeral const & upper, bool u_open, v_dependency * u_dep); old_interval(old_interval const & other); diff --git a/src/smt/params/qi_params.h b/src/smt/params/qi_params.h index 2cee6dc72..cc1a30673 100644 --- a/src/smt/params/qi_params.h +++ b/src/smt/params/qi_params.h @@ -99,7 +99,7 @@ struct qi_params { m_mbqi_max_iterations(1000), m_mbqi_trace(false), m_mbqi_force_template(10), - m_mbqi_id(0) + m_mbqi_id(nullptr) { updt_params(p); } diff --git a/src/smt/proto_model/array_factory.cpp b/src/smt/proto_model/array_factory.cpp index d112331f0..919f18dc0 100644 --- a/src/smt/proto_model/array_factory.cpp +++ b/src/smt/proto_model/array_factory.cpp @@ -62,7 +62,7 @@ void array_factory::get_some_args_for(sort * s, ptr_buffer & args) { expr * array_factory::get_some_value(sort * s) { TRACE("array_factory", tout << mk_pp(s, m_manager) << "\n";); - value_set * set = 0; + value_set * set = nullptr; if (m_sort2value_set.find(s, set) && !set->empty()) return *(set->begin()); func_interp * fi; @@ -99,7 +99,7 @@ bool array_factory::mk_two_diff_values_for(sort * s) { } bool array_factory::get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { - value_set * set = 0; + value_set * set = nullptr; if (!m_sort2value_set.find(s, set) || set->size() == 0) { if (!mk_two_diff_values_for(s)) return false; @@ -111,7 +111,7 @@ bool array_factory::get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { if (set->size() == 1) { v1 = *(set->begin()); v2 = get_fresh_value(s); - return v2.get() != 0; + return v2.get() != nullptr; } else { SASSERT(set->size() >= 2); @@ -139,7 +139,7 @@ expr * array_factory::get_fresh_value(sort * s) { } sort * range = get_array_range(s); expr * range_val = m_model.get_fresh_value(range); - if (range_val != 0) { + if (range_val != nullptr) { // easy case func_interp * fi; expr * val = mk_array_interp(s, fi); @@ -170,7 +170,7 @@ expr * array_factory::get_fresh_value(sort * s) { if (!found) { expr * arg1 = m_model.get_fresh_value(d); expr * arg2 = m_model.get_fresh_value(d); - if (arg1 != 0 && arg2 != 0) { + if (arg1 != nullptr && arg2 != nullptr) { found = true; args1.push_back(arg1); args2.push_back(arg2); @@ -201,6 +201,6 @@ expr * array_factory::get_fresh_value(sort * s) { // failed to create a fresh array value TRACE("array_factory_bug", tout << "failed to build fresh array value\n";); - return 0; + return nullptr; } diff --git a/src/smt/proto_model/datatype_factory.cpp b/src/smt/proto_model/datatype_factory.cpp index 550b694da..eded55cc3 100644 --- a/src/smt/proto_model/datatype_factory.cpp +++ b/src/smt/proto_model/datatype_factory.cpp @@ -27,7 +27,7 @@ datatype_factory::datatype_factory(ast_manager & m, proto_model & md): } expr * datatype_factory::get_some_value(sort * s) { - value_set * set = 0; + value_set * set = nullptr; if (m_sort2value_set.find(s, set) && !set->empty()) return *(set->begin()); func_decl * c = m_util.get_non_rec_constructor(s); @@ -46,7 +46,7 @@ expr * datatype_factory::get_some_value(sort * s) { \brief Return the last fresh (or almost) fresh value of sort s. */ expr * datatype_factory::get_last_fresh_value(sort * s) { - expr * val = 0; + expr * val = nullptr; if (m_last_fresh_value.find(s, val)) { TRACE("datatype", tout << "cached fresh value: " << mk_pp(val, m_manager) << "\n";); return val; @@ -98,7 +98,7 @@ expr * datatype_factory::get_almost_fresh_value(sort * s) { sort * s_arg = constructor->get_domain(i); if (!found_fresh_arg && (!m_util.is_datatype(s_arg) || !m_util.are_siblings(s, s_arg))) { expr * new_arg = m_model.get_fresh_value(s_arg); - if (new_arg != 0) { + if (new_arg != nullptr) { found_fresh_arg = true; args.push_back(new_arg); continue; @@ -131,7 +131,7 @@ expr * datatype_factory::get_almost_fresh_value(sort * s) { } } SASSERT(!m_util.is_recursive(s)); - return 0; + return nullptr; } @@ -160,7 +160,7 @@ expr * datatype_factory::get_fresh_value(sort * s) { sort * s_arg = constructor->get_domain(i); if (!found_fresh_arg && (!m_util.is_recursive(s) || !m_util.is_datatype(s_arg) || !m_util.are_siblings(s, s_arg))) { expr * new_arg = m_model.get_fresh_value(s_arg); - if (new_arg != 0) { + if (new_arg != nullptr) { found_fresh_arg = true; args.push_back(new_arg); continue; @@ -204,7 +204,7 @@ expr * datatype_factory::get_fresh_value(sort * s) { << found_sibling << "\n";); if (!found_sibling && m_util.is_datatype(s_arg) && m_util.are_siblings(s, s_arg)) { found_sibling = true; - expr * maybe_new_arg = 0; + expr * maybe_new_arg = nullptr; if (num_iterations <= 1) { maybe_new_arg = get_almost_fresh_value(s_arg); } @@ -245,6 +245,6 @@ expr * datatype_factory::get_fresh_value(sort * s) { // Search for value that was not created before. SASSERT(!m_util.is_recursive(s)); - return 0; + return nullptr; } diff --git a/src/smt/proto_model/proto_model.cpp b/src/smt/proto_model/proto_model.cpp index 0a75ff700..688ded834 100644 --- a/src/smt/proto_model/proto_model.cpp +++ b/src/smt/proto_model/proto_model.cpp @@ -53,11 +53,11 @@ void proto_model::register_aux_decl(func_decl * d) { */ void proto_model::reregister_decl(func_decl * f, func_interp * new_fi, func_decl * f_aux) { func_interp * fi = get_func_interp(f); - if (fi == 0) { + if (fi == nullptr) { register_decl(f, new_fi); } else { - if (f_aux != 0) { + if (f_aux != nullptr) { register_decl(f_aux, fi); m_aux_decls.insert(f_aux); } @@ -135,7 +135,7 @@ void proto_model::cleanup_func_interp(func_interp * fi, func_decl_set & found_au todo.pop_back(); func_decl * a_decl = to_app(a)->get_decl(); expr * ai = get_const_interp(a_decl); - if (ai == 0) { + if (ai == nullptr) { ai = get_some_value(a_decl->get_range()); register_decl(a_decl, ai); } @@ -148,7 +148,7 @@ void proto_model::cleanup_func_interp(func_interp * fi, func_decl_set & found_au bool visited = true; args.reset(); for (expr* t_arg : *t) { - expr * arg = 0; + expr * arg = nullptr; if (!cache.find(t_arg, arg)) { visited = false; todo.push_back(t_arg); @@ -346,7 +346,7 @@ void proto_model::complete_partial_func(func_decl * f) { func_interp * fi = get_func_interp(f); if (fi && fi->is_partial()) { expr * else_value = fi->get_max_occ_result(); - if (else_value == 0) + if (else_value == nullptr) else_value = get_some_value(f->get_range()); fi->set_else(else_value); } diff --git a/src/smt/proto_model/struct_factory.cpp b/src/smt/proto_model/struct_factory.cpp index 8d85c6485..a31dd84dd 100644 --- a/src/smt/proto_model/struct_factory.cpp +++ b/src/smt/proto_model/struct_factory.cpp @@ -20,7 +20,7 @@ Revision History: #include "smt/proto_model/proto_model.h" struct_factory::value_set * struct_factory::get_value_set(sort * s) { - value_set * set = 0; + value_set * set = nullptr; if (!m_sort2value_set.find(s, set)) { set = alloc(value_set); m_sort2value_set.insert(s, set); diff --git a/src/smt/proto_model/value_factory.cpp b/src/smt/proto_model/value_factory.cpp index e41696165..5a0d012dc 100644 --- a/src/smt/proto_model/value_factory.cpp +++ b/src/smt/proto_model/value_factory.cpp @@ -34,7 +34,7 @@ basic_factory::basic_factory(ast_manager & m): expr * basic_factory::get_some_value(sort * s) { if (m_manager.is_bool(s)) return m_manager.mk_false(); - return 0; + return nullptr; } bool basic_factory::get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { @@ -47,7 +47,7 @@ bool basic_factory::get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { } expr * basic_factory::get_fresh_value(sort * s) { - return 0; + return nullptr; } user_sort_factory::user_sort_factory(ast_manager & m): @@ -56,7 +56,7 @@ user_sort_factory::user_sort_factory(ast_manager & m): void user_sort_factory::freeze_universe(sort * s) { if (!m_finite.contains(s)) { - value_set * set = 0; + value_set * set = nullptr; m_sort2value_set.find(s, set); if (!m_sort2value_set.find(s, set) || set->m_values.empty()) { // we cannot freeze an empty universe. @@ -68,7 +68,7 @@ void user_sort_factory::freeze_universe(sort * s) { } obj_hashtable const & user_sort_factory::get_known_universe(sort * s) const { - value_set * set = 0; + value_set * set = nullptr; if (m_sort2value_set.find(s, set)) { return set->m_values; } @@ -77,7 +77,7 @@ obj_hashtable const & user_sort_factory::get_known_universe(sort * s) cons expr * user_sort_factory::get_some_value(sort * s) { if (is_finite(s)) { - value_set * set = 0; + value_set * set = nullptr; m_sort2value_set.find(s, set); SASSERT(set != 0); SASSERT(!set->m_values.empty()); @@ -88,7 +88,7 @@ expr * user_sort_factory::get_some_value(sort * s) { bool user_sort_factory::get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { if (is_finite(s)) { - value_set * set = 0; + value_set * set = nullptr; if (m_sort2value_set.find(s, set) && set->m_values.size() >= 2) { obj_hashtable::iterator it = set->m_values.begin(); v1 = *it; @@ -103,7 +103,7 @@ bool user_sort_factory::get_some_values(sort * s, expr_ref & v1, expr_ref & v2) expr * user_sort_factory::get_fresh_value(sort * s) { if (is_finite(s)) - return 0; + return nullptr; return simple_factory::get_fresh_value(s); } diff --git a/src/smt/proto_model/value_factory.h b/src/smt/proto_model/value_factory.h index 3979a47bb..77452d424 100644 --- a/src/smt/proto_model/value_factory.h +++ b/src/smt/proto_model/value_factory.h @@ -95,7 +95,7 @@ protected: ptr_vector m_sets; value_set * get_value_set(sort * s) { - value_set * set = 0; + value_set * set = nullptr; if (!m_sort2value_set.find(s, set)) { set = alloc(value_set); m_sort2value_set.insert(s, set); @@ -138,8 +138,8 @@ public: } expr * get_some_value(sort * s) override { - value_set * set = 0; - expr * result = 0; + value_set * set = nullptr; + expr * result = nullptr; if (m_sort2value_set.find(s, set) && !set->m_values.empty()) result = *(set->m_values.begin()); else @@ -148,7 +148,7 @@ public: } bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override { - value_set * set = 0; + value_set * set = nullptr; if (m_sort2value_set.find(s, set)) { switch (set->m_values.size()) { case 0: @@ -179,9 +179,9 @@ public: expr * get_fresh_value(sort * s) override { value_set * set = get_value_set(s); bool is_new = false; - expr * result = 0; + expr * result = nullptr; sort_info* s_info = s->get_info(); - sort_size const* sz = s_info?&s_info->get_num_elements():0; + sort_size const* sz = s_info?&s_info->get_num_elements():nullptr; bool has_max = false; Number max_size(0); if (sz && sz->is_finite() && sz->size() < UINT_MAX) { @@ -195,7 +195,7 @@ public: result = mk_value(next, s, is_new); next++; if (has_max && next > max_size + start) { - return 0; + return nullptr; } } SASSERT(result != 0); diff --git a/src/smt/qi_queue.cpp b/src/smt/qi_queue.cpp index 2a8d9d199..4e639a7b2 100644 --- a/src/smt/qi_queue.cpp +++ b/src/smt/qi_queue.cpp @@ -128,7 +128,7 @@ namespace smt { unsigned qi_queue::get_new_gen(quantifier * q, unsigned generation, float cost) { // max_top_generation and min_top_generation are not available for computing inc_gen - set_values(q, 0, generation, 0, 0, cost); + set_values(q, nullptr, generation, 0, 0, cost); float r = m_evaluator(m_new_gen_function, m_vals.size(), m_vals.c_ptr()); return static_cast(r); } diff --git a/src/smt/smt2_extra_cmds.cpp b/src/smt/smt2_extra_cmds.cpp index 238295a49..d66849338 100644 --- a/src/smt/smt2_extra_cmds.cpp +++ b/src/smt/smt2_extra_cmds.cpp @@ -23,7 +23,7 @@ Notes: class include_cmd : public cmd { char const * m_filename; public: - include_cmd() : cmd("include"), m_filename(0) {} + include_cmd() : cmd("include"), m_filename(nullptr) {} char const * get_usage() const override { return ""; } char const * get_descr(cmd_context & ctx) const override { return "include a file"; } unsigned get_arity() const override { return 1; } @@ -38,7 +38,7 @@ public: is.close(); } void prepare(cmd_context & ctx) override { reset(ctx); } - void reset(cmd_context & ctx) override { m_filename = 0; } + void reset(cmd_context & ctx) override { m_filename = nullptr; } void finalize(cmd_context & ctx) override { reset(ctx); } }; diff --git a/src/smt/smt_almost_cg_table.cpp b/src/smt/smt_almost_cg_table.cpp index 4d24ea0d0..b891c002d 100644 --- a/src/smt/smt_almost_cg_table.cpp +++ b/src/smt/smt_almost_cg_table.cpp @@ -108,8 +108,8 @@ namespace smt { void almost_cg_table::insert(enode * n) { table::entry * entry = m_table.find_core(n); - if (entry == 0) { - list * new_lst = new (m_region) list(n, 0); + if (entry == nullptr) { + list * new_lst = new (m_region) list(n, nullptr); m_table.insert(n, new_lst); } else { @@ -119,7 +119,7 @@ namespace smt { } list * almost_cg_table::find(enode * n) { - list * result = 0; + list * result = nullptr; m_table.find(n, result); return result; } diff --git a/src/smt/smt_almost_cg_table.h b/src/smt/smt_almost_cg_table.h index 7807f705a..d514f1478 100644 --- a/src/smt/smt_almost_cg_table.h +++ b/src/smt/smt_almost_cg_table.h @@ -57,7 +57,7 @@ namespace smt { table m_table; public: - almost_cg_table(enode * r1 = 0, enode * r2 = 0); + almost_cg_table(enode * r1 = nullptr, enode * r2 = nullptr); void reset(enode * r1, enode * r2) { m_r1 = r1->get_root(); m_r2 = r2->get_root(); reset(); } void reset(); void insert(enode *); diff --git a/src/smt/smt_b_justification.h b/src/smt/smt_b_justification.h index 55669a7ef..7aeb268cb 100644 --- a/src/smt/smt_b_justification.h +++ b/src/smt/smt_b_justification.h @@ -91,7 +91,7 @@ namespace smt { } }; - const b_justification null_b_justification(static_cast(0)); + const b_justification null_b_justification(static_cast(nullptr)); inline std::ostream& operator<<(std::ostream& out, b_justification::kind k) { switch (k) { diff --git a/src/smt/smt_case_split_queue.cpp b/src/smt/smt_case_split_queue.cpp index 3da6ce295..5c51b906f 100644 --- a/src/smt/smt_case_split_queue.cpp +++ b/src/smt/smt_case_split_queue.cpp @@ -419,7 +419,7 @@ namespace smt { val = l_true; } if ((is_or && val == l_true) || (is_and && val == l_false)) { - expr * undef_child = 0; + expr * undef_child = nullptr; if (!has_child_assigned_to(m_context, to_app(curr), val, undef_child, m_params.m_rel_case_split_order)) { if (m_manager.has_trace_stream()) { m_manager.trace_stream() << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; @@ -611,7 +611,7 @@ namespace smt { val = l_true; } if ((is_or && val == l_true) || (is_and && val == l_false)) { - expr * undef_child = 0; + expr * undef_child = nullptr; if (!has_child_assigned_to(m_context, to_app(curr), val, undef_child, m_params.m_rel_case_split_order)) { TRACE("case_split", tout << "found AND/OR candidate: #" << curr->get_id() << " #" << undef_child->get_id() << "\n";); literal l = m_context.get_literal(undef_child); @@ -747,7 +747,7 @@ namespace smt { m_head(0), m_bs_num_bool_vars(UINT_MAX), m_priority_queue2(0, generation_lt(*this)), - m_current_goal(0) { + m_current_goal(nullptr) { set_global_generation(); } @@ -875,7 +875,7 @@ namespace smt { val = l_true; } if ((is_or && val == l_true) || (is_and && val == l_false)) { - expr * undef_child = 0; + expr * undef_child = nullptr; if (!has_child_assigned_to(m_context, to_app(curr), val, undef_child, m_params.m_rel_case_split_order)) { if (m_manager.has_trace_stream()) { m_manager.trace_stream() << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; diff --git a/src/smt/smt_cg_table.h b/src/smt/smt_cg_table.h index 1e3fd8b83..64c8328d0 100644 --- a/src/smt/smt_cg_table.h +++ b/src/smt/smt_cg_table.h @@ -307,17 +307,17 @@ namespace smt { enode * find(enode * n) const { SASSERT(n->get_num_args() > 0); - enode * r = 0; + enode * r = nullptr; void * t = const_cast(this)->get_table(n); switch (static_cast(GET_TAG(t))) { case UNARY: - return UNTAG(unary_table*, t)->find(n, r) ? r : 0; + return UNTAG(unary_table*, t)->find(n, r) ? r : nullptr; case BINARY: - return UNTAG(binary_table*, t)->find(n, r) ? r : 0; + return UNTAG(binary_table*, t)->find(n, r) ? r : nullptr; case BINARY_COMM: - return UNTAG(comm_table*, t)->find(n, r) ? r : 0; + return UNTAG(comm_table*, t)->find(n, r) ? r : nullptr; default: - return UNTAG(table*, t)->find(n, r) ? r : 0; + return UNTAG(table*, t)->find(n, r) ? r : nullptr; } } diff --git a/src/smt/smt_checker.cpp b/src/smt/smt_checker.cpp index a7a25037c..ed80eaab7 100644 --- a/src/smt/smt_checker.cpp +++ b/src/smt/smt_checker.cpp @@ -125,28 +125,28 @@ namespace smt { unsigned num = n->get_num_args(); for (unsigned i = 0; i < num; i++) { enode * arg = get_enode_eq_to(n->get_arg(i)); - if (arg == 0) - return 0; + if (arg == nullptr) + return nullptr; buffer.push_back(arg); } enode * e = m_context.get_enode_eq_to(n->get_decl(), num, buffer.c_ptr()); - if (e == 0) - return 0; - return m_context.is_relevant(e) ? e : 0; + if (e == nullptr) + return nullptr; + return m_context.is_relevant(e) ? e : nullptr; } enode * checker::get_enode_eq_to(expr * n) { if (is_var(n)) { unsigned idx = to_var(n)->get_idx(); if (idx >= m_num_bindings) - return 0; + return nullptr; return m_bindings[m_num_bindings - idx - 1]; } if (m_context.e_internalized(n) && m_context.is_relevant(n)) return m_context.get_enode(n); if (!is_app(n) || to_app(n)->get_num_args() == 0) - return 0; - enode * r = 0; + return nullptr; + enode * r = nullptr; if (n->get_ref_count() > 1 && m_to_enode_cache.find(n, r)) return r; r = get_enode_eq_to_core(to_app(n)); @@ -179,7 +179,7 @@ namespace smt { m_context(c), m_manager(c.get_manager()), m_num_bindings(0), - m_bindings(0) { + m_bindings(nullptr) { } }; diff --git a/src/smt/smt_checker.h b/src/smt/smt_checker.h index 5e841f572..beb32239c 100644 --- a/src/smt/smt_checker.h +++ b/src/smt/smt_checker.h @@ -47,8 +47,8 @@ namespace smt { public: checker(context & c); - bool is_sat(expr * n, unsigned num_bindings = 0, enode * const * bindings = 0); - bool is_unsat(expr * n, unsigned num_bindings = 0, enode * const * bindings = 0); + bool is_sat(expr * n, unsigned num_bindings = 0, enode * const * bindings = nullptr); + bool is_unsat(expr * n, unsigned num_bindings = 0, enode * const * bindings = nullptr); }; }; diff --git a/src/smt/smt_clause.cpp b/src/smt/smt_clause.cpp index ccb336941..a9365fffc 100644 --- a/src/smt/smt_clause.cpp +++ b/src/smt/smt_clause.cpp @@ -29,7 +29,7 @@ namespace smt { clause_del_eh * del_eh, bool save_atoms, expr * const * bool_var2expr_map) { SASSERT(k == CLS_AUX || js == 0 || !js->in_region()); SASSERT(num_lits >= 2); - unsigned sz = get_obj_size(num_lits, k, save_atoms, del_eh != 0, js != 0); + unsigned sz = get_obj_size(num_lits, k, save_atoms, del_eh != nullptr, js != nullptr); void * mem = m.get_allocator().allocate(sz); clause * cls = new (mem) clause(); cls->m_num_literals = num_lits; @@ -38,8 +38,8 @@ namespace smt { cls->m_reinit = save_atoms; cls->m_reinternalize_atoms = save_atoms; cls->m_has_atoms = save_atoms; - cls->m_has_del_eh = del_eh != 0; - cls->m_has_justification = js != 0; + cls->m_has_del_eh = del_eh != nullptr; + cls->m_has_justification = js != nullptr; cls->m_deleted = false; SASSERT(!m.proofs_enabled() || js != 0); memcpy(cls->m_lits, lits, sizeof(literal) * num_lits); @@ -92,7 +92,7 @@ namespace smt { unsigned num_atoms = get_num_atoms(); for (unsigned i = 0; i < num_atoms; i++) { m.dec_ref(get_atom(i)); - const_cast(get_atoms_addr())[i] = 0; + const_cast(get_atoms_addr())[i] = nullptr; } } diff --git a/src/smt/smt_clause.h b/src/smt/smt_clause.h index d4b9ee02f..8e843c4cf 100644 --- a/src/smt/smt_clause.h +++ b/src/smt/smt_clause.h @@ -149,8 +149,8 @@ namespace smt { void release_atoms(ast_manager & m); public: - static clause * mk(ast_manager & m, unsigned num_lits, literal * lits, clause_kind k, justification * js = 0, - clause_del_eh * del_eh = 0, bool save_atoms = false, expr * const * bool_var2expr_map = 0); + static clause * mk(ast_manager & m, unsigned num_lits, literal * lits, clause_kind k, justification * js = nullptr, + clause_del_eh * del_eh = nullptr, bool save_atoms = false, expr * const * bool_var2expr_map = nullptr); void deallocate(ast_manager & m); @@ -211,11 +211,11 @@ namespace smt { } clause_del_eh * get_del_eh() const { - return m_has_del_eh ? *(get_del_eh_addr()) : 0; + return m_has_del_eh ? *(get_del_eh_addr()) : nullptr; } justification * get_justification() const { - return m_has_justification ? *(get_justification_addr()) : 0; + return m_has_justification ? *(get_justification_addr()) : nullptr; } unsigned get_num_atoms() const { @@ -253,7 +253,7 @@ namespace smt { clause_del_eh * del_eh = get_del_eh(); if (del_eh) { (*del_eh)(m, this); - *(const_cast(get_del_eh_addr())) = 0; + *(const_cast(get_del_eh_addr())) = nullptr; } } diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index a6432c960..379846ed7 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -43,7 +43,7 @@ namespace smt { m_assigned_literals(assigned_literals), m_lemma_atoms(m), m_todo_js_qhead(0), - m_antecedents(0), + m_antecedents(nullptr), m_watches(watches), m_new_proofs(m), m_lemma_proof(m) @@ -204,7 +204,7 @@ namespace smt { eq2literals(p.first, p.second); } if (m_todo_js_qhead == m_todo_js.size()) { - m_antecedents = 0; + m_antecedents = nullptr; return; } } @@ -480,7 +480,7 @@ namespace smt { // save space for first uip m_lemma.push_back(null_literal); - m_lemma_atoms.push_back(0); + m_lemma_atoms.push_back(nullptr); unsigned num_marks = 0; if (not_l != null_literal) { @@ -758,7 +758,7 @@ namespace smt { return pr; } m_todo_pr.push_back(tp_elem(n1, n2)); - return 0; + return nullptr; } /** @@ -766,7 +766,7 @@ namespace smt { */ proof * conflict_resolution::norm_eq_proof(enode * n1, enode * n2, proof * pr) { if (!pr) - return 0; + return nullptr; SASSERT(m_manager.has_fact(pr)); app * fact = to_app(m_manager.get_fact(pr)); app * n1_owner = n1->get_owner(); @@ -814,7 +814,7 @@ namespace smt { switch (js.get_kind()) { case eq_justification::AXIOM: UNREACHABLE(); - return 0; + return nullptr; case eq_justification::EQUATION: TRACE("proof_gen_bug", tout << js.get_literal() << "\n"; m_ctx.display_literal_info(tout, js.get_literal());); return norm_eq_proof(n1, n2, get_proof(js.get_literal())); @@ -845,11 +845,11 @@ namespace smt { visited = false; } if (!visited) - return 0; + return nullptr; app * e1 = n1->get_owner(); app * e2 = n2->get_owner(); app * e2_prime = m_manager.mk_app(e2->get_decl(), e2->get_arg(1), e2->get_arg(0)); - proof * pr1 = 0; + proof * pr1 = nullptr; if (!prs.empty()) { pr1 = m_manager.mk_congruence(e1, e2_prime, prs.size(), prs.c_ptr()); m_new_proofs.push_back(pr1); @@ -877,14 +877,14 @@ namespace smt { } } if (!visited) - return 0; + return nullptr; proof * pr = m_manager.mk_congruence(n1->get_owner(), n2->get_owner(), prs.size(), prs.c_ptr()); m_new_proofs.push_back(pr); return pr; } default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -899,7 +899,7 @@ namespace smt { return pr; } m_todo_pr.push_back(tp_elem(l)); - return 0; + return nullptr; } /** @@ -945,7 +945,7 @@ namespace smt { SASSERT(js); proof * pr = get_proof(js); ptr_buffer prs; - bool visited = pr != 0; + bool visited = pr != nullptr; TRACE("get_proof_bug", if (pr != 0) tout << js->get_name() << "\n";); CTRACE("get_proof_bug_after", invocation_counter >= DUMP_AFTER_NUM_INVOCATIONS, if (pr != 0) tout << js->get_name() << "\n";); CTRACE("get_proof_bug_after", invocation_counter >= DUMP_AFTER_NUM_INVOCATIONS, if (pr != 0) js->display_debug_info(*this, tout);); @@ -973,7 +973,7 @@ namespace smt { visited = false; } if (!visited) - return 0; + return nullptr; expr_ref l_exr(m_manager); m_ctx.literal2expr(l, l_exr); TRACE("get_proof_bug", @@ -1034,7 +1034,7 @@ namespace smt { } SASSERT(js != 0); m_todo_pr.push_back(tp_elem(js)); - return 0; + return nullptr; } void conflict_resolution::init_mk_proof() { @@ -1061,7 +1061,7 @@ namespace smt { SASSERT(js.get_kind() != b_justification::AXIOM); if (js.get_kind() == b_justification::CLAUSE) { clause * cls = js.get_clause(); - bool visited = get_proof(cls->get_justification()) != 0; + bool visited = get_proof(cls->get_justification()) != nullptr; unsigned num_lits = cls->get_num_literals(); unsigned i = 0; if (l != false_literal) { @@ -1070,20 +1070,20 @@ namespace smt { } else { SASSERT(cls->get_literal(1) == l); - if (get_proof(~cls->get_literal(0)) == 0) + if (get_proof(~cls->get_literal(0)) == nullptr) visited = false; i = 2; } } for (; i < num_lits; i++) { SASSERT(cls->get_literal(i) != l); - if (get_proof(~cls->get_literal(i)) == 0) + if (get_proof(~cls->get_literal(i)) == nullptr) visited = false; } return visited; } else - return get_proof(js.get_justification()) != 0; + return get_proof(js.get_justification()) != nullptr; } void conflict_resolution::mk_proof(literal l, b_justification js) { @@ -1114,11 +1114,11 @@ namespace smt { UNREACHABLE(); break; case eq_justification::EQUATION: - if (get_proof(js.get_literal()) == 0) + if (get_proof(js.get_literal()) == nullptr) visited = false; break; case eq_justification::JUSTIFICATION: - if (get_proof(js.get_justification()) == 0) + if (get_proof(js.get_justification()) == nullptr) visited = false; break; case eq_justification::CONGRUENCE: { @@ -1132,16 +1132,16 @@ namespace smt { enode * c1_2 = n1->get_arg(1); enode * c2_1 = n2->get_arg(0); enode * c2_2 = n2->get_arg(1); - if (c1_1 != c2_2 && get_proof(c1_1, c2_2) == 0) + if (c1_1 != c2_2 && get_proof(c1_1, c2_2) == nullptr) visited = false; - if (c1_2 != c2_1 && get_proof(c1_2, c2_1) == 0) + if (c1_2 != c2_1 && get_proof(c1_2, c2_1) == nullptr) visited = false; } else { for (unsigned i = 0; i < num_args; i++) { enode * c1 = n1->get_arg(i); enode * c2 = n2->get_arg(i); - if (c1 != c2 && get_proof(c1, c2) == 0) + if (c1 != c2 && get_proof(c1, c2) == nullptr) visited = false; } } @@ -1204,7 +1204,7 @@ namespace smt { } prs2.pop_back(); } - proof * pr = 0; + proof * pr = nullptr; SASSERT(!prs1.empty()); if (prs1.size() == 1) pr = prs1[0]; @@ -1290,13 +1290,13 @@ namespace smt { } SASSERT(visit_b_justification(consequent, conflict)); - proof * pr = 0; + proof * pr = nullptr; if (not_l == null_literal) { pr = get_proof(false_literal, conflict); SASSERT(pr); } else { - proof * prs[2] = { 0, 0}; + proof * prs[2] = { nullptr, nullptr}; m_lit2proof.find(not_l, prs[0]); SASSERT(prs[0]); prs[1] = get_proof(consequent, conflict); @@ -1310,13 +1310,13 @@ namespace smt { m_ctx.literal2expr(lit, l_expr); lits.push_back(l_expr); } - expr * fact = 0; + expr * fact = nullptr; switch (lits.size()) { - case 0: fact = 0; break; + case 0: fact = nullptr; break; case 1: fact = lits[0]; break; default: fact = m_manager.mk_or(lits.size(), lits.c_ptr()); } - if (fact == 0) + if (fact == nullptr) m_lemma_proof = pr; else m_lemma_proof = m_manager.mk_lemma(pr, fact); diff --git a/src/smt/smt_consequences.cpp b/src/smt/smt_consequences.cpp index 0bf2a2939..13fd9e6ea 100644 --- a/src/smt/smt_consequences.cpp +++ b/src/smt/smt_consequences.cpp @@ -244,7 +244,7 @@ namespace smt { } literal lit = mk_diseq(k, v); literals.push_back(lit); - mk_clause(literals.size(), literals.c_ptr(), 0); + mk_clause(literals.size(), literals.c_ptr(), nullptr); TRACE("context", display_literals_verbose(tout, literals.size(), literals.c_ptr());); } } diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 0f09f1f59..dd38776bc 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -51,7 +51,7 @@ namespace smt { m_relevancy_propagator(mk_relevancy_propagator(*this)), m_random(p.m_random_seed), m_flushing(false), - m_progress_callback(0), + m_progress_callback(nullptr), m_next_progress_sample(0), m_fingerprints(m_region), m_b_internalized_stack(m), @@ -59,7 +59,7 @@ namespace smt { m_final_check_idx(0), m_cg_table(m), m_dyn_ack_manager(*this, p), - m_is_diseq_tmp(0), + m_is_diseq_tmp(nullptr), m_units_to_reassert(m_manager), m_qhead(0), m_simp_qhead(0), @@ -176,7 +176,7 @@ namespace smt { for (unsigned i = 0; i < src_ctx.m_assigned_literals.size(); ++i) { literal lit; lit = TRANSLATE(src_ctx.m_assigned_literals[i]); - dst_ctx.mk_clause(1, &lit, 0, CLS_AUX, 0); + dst_ctx.mk_clause(1, &lit, nullptr, CLS_AUX, nullptr); } #if 0 literal_vector lits; @@ -232,8 +232,8 @@ namespace smt { } context * context::mk_fresh(symbol const * l, smt_params * p) { - context * new_ctx = alloc(context, m_manager, p == 0 ? m_fparams : *p); - new_ctx->set_logic(l == 0 ? m_setup.get_logic() : *l); + context * new_ctx = alloc(context, m_manager, p == nullptr ? m_fparams : *p); + new_ctx->set_logic(l == nullptr ? m_setup.get_logic() : *l); copy_plugins(*this, *new_ctx); return new_ctx; } @@ -741,9 +741,9 @@ namespace smt { enode * curr = n->m_trans.m_target; enode * prev = n; eq_justification js = n->m_trans.m_justification; - prev->m_trans.m_target = 0; + prev->m_trans.m_target = nullptr; prev->m_trans.m_justification = null_eq_justification; - while (curr != 0) { + while (curr != nullptr) { SASSERT(prev->trans_reaches(n)); enode * new_curr = curr->m_trans.m_target; eq_justification new_js = curr->m_trans.m_justification; @@ -798,7 +798,7 @@ namespace smt { theory_var context::get_closest_var(enode * n, theory_id th_id) { if (th_id == null_theory_id) return null_theory_var; - while (n != 0) { + while (n != nullptr) { theory_var v = n->get_th_var(th_id); if (v != null_theory_var) return v; @@ -826,7 +826,7 @@ namespace smt { if (js.get_kind() == eq_justification::JUSTIFICATION) from_th = js.get_justification()->get_from_theory(); - if (r2->m_th_var_list.get_next() == 0 && r1->m_th_var_list.get_next() == 0) { + if (r2->m_th_var_list.get_next() == nullptr && r1->m_th_var_list.get_next() == nullptr) { // Common case: r2 and r1 have at most one theory var. theory_id t2 = r2->m_th_var_list.get_th_id(); theory_id t1 = r1->m_th_var_list.get_th_id(); @@ -1023,7 +1023,7 @@ namespace smt { } // restore theory vars - if (r2->m_th_var_list.get_next() == 0) { + if (r2->m_th_var_list.get_next() == nullptr) { // common case: r2 has at most one variable theory_var v2 = r2->m_th_var_list.get_th_var(); if (v2 != null_theory_var) { @@ -1043,7 +1043,7 @@ namespace smt { // r1 -> .. -> n1 -> n2 -> ... -> r2 SASSERT(r1->trans_reaches(r2)); SASSERT(r1->trans_reaches(n1)); - n1->m_trans.m_target = 0; + n1->m_trans.m_target = nullptr; n1->m_trans.m_justification = null_eq_justification; invert_trans(r1); // --------------- @@ -1067,7 +1067,7 @@ namespace smt { */ void context::restore_theory_vars(enode * r2, enode * r1) { SASSERT(r2->get_root() == r2); - theory_var_list * new_l2 = 0; + theory_var_list * new_l2 = nullptr; theory_var_list * l2 = r2->get_th_var_list(); while (l2) { theory_var v2 = l2->get_th_var(); @@ -1091,11 +1091,11 @@ namespace smt { } if (new_l2) { - new_l2->set_next(0); + new_l2->set_next(nullptr); } else { r2->m_th_var_list.set_th_var(null_theory_var); - r2->m_th_var_list.set_next(0); + r2->m_th_var_list.set_next(nullptr); } } @@ -1128,7 +1128,7 @@ namespace smt { } // Propagate disequalities to theories - if (r1->m_th_var_list.get_next() == 0 && r2->m_th_var_list.get_next() == 0) { + if (r1->m_th_var_list.get_next() == nullptr && r2->m_th_var_list.get_next() == nullptr) { // common case: r2 and r1 have at most one theory var. theory_id t1 = r1->m_th_var_list.get_th_id(); theory_var v1 = m_fparams.m_new_core2th_eq ? get_closest_var(n1, t1) : r1->m_th_var_list.get_th_var(); @@ -1646,11 +1646,11 @@ namespace smt { m_qmanager->relevant_eh(e); } - theory * propagated_th = 0; + theory * propagated_th = nullptr; family_id fid = to_app(n)->get_family_id(); if (fid != m_manager.get_basic_family_id()) { theory * th = get_theory(fid); - if (th != 0) { + if (th != nullptr) { th->relevant_eh(to_app(n)); propagated_th = th; // <<< mark that relevancy_eh was already invoked for theory th. } @@ -2412,7 +2412,7 @@ namespace smt { if (!bs.m_inconsistent) { m_conflict = null_b_justification; m_not_l = null_literal; - m_unsat_proof = 0; + m_unsat_proof = nullptr; } m_base_scopes.shrink(new_lvl); } @@ -2532,7 +2532,7 @@ namespace smt { if (m_manager.proofs_enabled() && !simp_lits.empty()) { SASSERT(m_scope_lvl == m_base_lvl); justification * js = cls->get_justification(); - justification * new_js = 0; + justification * new_js = nullptr; if (js->in_region()) new_js = mk_justification(unit_resolution_justification(m_region, js, @@ -2586,7 +2586,7 @@ namespace smt { } } justification * cls_js = cls->get_justification(); - justification * js = 0; + justification * js = nullptr; if (!cls_js || cls_js->in_region()) { // If cls_js is 0 or is allocated in a region, then // we can allocate the new justification in a region too. @@ -2598,7 +2598,7 @@ namespace smt { else { js = alloc(unit_resolution_justification, cls_js, simp_lits.size(), simp_lits.c_ptr()); // js took ownership of the justification object. - cls->set_justification(0); + cls->set_justification(nullptr); m_justifications.push_back(js); } set_justification(v0, m_bdata[v0], b_justification(js)); @@ -2851,7 +2851,7 @@ namespace smt { #endif void context::register_plugin(theory * th) { - if (m_theories.get_plugin(th->get_family_id()) != 0) { + if (m_theories.get_plugin(th->get_family_id()) != nullptr) { dealloc(th); return; // context already has a theory for the given family id. } @@ -2905,12 +2905,12 @@ namespace smt { void context::flush() { flet l1(m_flushing, true); TRACE("flush", tout << "m_scope_lvl: " << m_scope_lvl << "\n";); - m_relevancy_propagator = 0; + m_relevancy_propagator = nullptr; m_model_generator->reset(); for (theory* t : m_theory_set) t->flush_eh(); undo_trail_stack(0); - m_qmanager = 0; + m_qmanager = nullptr; del_clauses(m_aux_clauses, 0); del_clauses(m_lemmas, 0); del_justifications(m_justifications, 0); @@ -2918,7 +2918,7 @@ namespace smt { m_is_diseq_tmp->del_eh(m_manager, false); m_manager.dec_ref(m_is_diseq_tmp->get_owner()); enode::del_dummy(m_is_diseq_tmp); - m_is_diseq_tmp = 0; + m_is_diseq_tmp = nullptr; } std::for_each(m_almost_cg_tables.begin(), m_almost_cg_tables.end(), delete_proc()); } @@ -2929,7 +2929,7 @@ namespace smt { TRACE("begin_assert_expr", tout << mk_pp(e, m_manager) << "\n";); TRACE("begin_assert_expr_ll", tout << mk_ll_pp(e, m_manager) << "\n";); pop_to_base_lvl(); - if (pr == 0) + if (pr == nullptr) m_asserted_formulas.assert_expr(e); else m_asserted_formulas.assert_expr(e, pr); @@ -2937,7 +2937,7 @@ namespace smt { } void context::assert_expr(expr * e) { - assert_expr(e, 0); + assert_expr(e, nullptr); } void context::assert_expr(expr * e, proof * pr) { @@ -2966,7 +2966,7 @@ namespace smt { for (unsigned j = i+1; j < num_lits; ++j) { literal l1 = lits[i]; literal l2 = lits[j]; - mk_clause(~l1, ~l2, (justification*) 0); + mk_clause(~l1, ~l2, (justification*) nullptr); } } } else { @@ -3084,7 +3084,7 @@ namespace smt { } if (m_asserted_formulas.inconsistent() && !inconsistent()) { proof * pr = m_asserted_formulas.get_inconsistency_proof(); - if (pr == 0) { + if (pr == nullptr) { set_conflict(b_justification::mk_axiom()); } else { @@ -3404,7 +3404,7 @@ namespace smt { m_luby_idx = 1; m_lemma_gc_threshold = m_fparams.m_lemma_gc_initial; m_last_search_failure = OK; - m_unsat_proof = 0; + m_unsat_proof = nullptr; m_unsat_core .reset(); m_dyn_ack_manager .init_search_eh(); m_final_check_idx = 0; @@ -3866,7 +3866,7 @@ namespace smt { expr_signs.push_back(l.sign()); } #endif - proof * pr = 0; + proof * pr = nullptr; if (m_manager.proofs_enabled()) { pr = m_conflict_resolution->get_lemma_proof(); // check_proof(pr); @@ -3939,7 +3939,7 @@ namespace smt { } } #endif - justification * js = 0; + justification * js = nullptr; if (m_manager.proofs_enabled()) { js = alloc(justification_proof_wrapper, *this, pr, false); } @@ -4271,7 +4271,7 @@ namespace smt { sort * s = m_manager.get_sort(n->get_owner()); family_id fid = s->get_family_id(); theory * th = get_theory(fid); - if (th == 0) + if (th == nullptr) return false; return th->get_value(n, value); } @@ -4321,13 +4321,13 @@ namespace smt { proof * context::get_proof() { if (!m_manager.proofs_enabled()) - return 0; + return nullptr; return m_unsat_proof; } void context::get_model(model_ref & m) const { if (inconsistent()) - m = 0; + m = nullptr; else m = const_cast(m_model.get()); } diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index 3cd93fbe5..b637d8082 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -203,11 +203,11 @@ namespace smt { struct scoped_mk_model { context & m_ctx; scoped_mk_model(context & ctx):m_ctx(ctx) { - m_ctx.m_proto_model = 0; - m_ctx.m_model = 0; + m_ctx.m_proto_model = nullptr; + m_ctx.m_model = nullptr; } ~scoped_mk_model() { - if (m_ctx.m_proto_model.get() != 0) { + if (m_ctx.m_proto_model.get() != nullptr) { m_ctx.m_model = m_ctx.m_proto_model->mk_model(); try { m_ctx.add_rec_funs_to_model(); @@ -215,7 +215,7 @@ namespace smt { catch (...) { // no op } - m_ctx.m_proto_model = 0; // proto_model is not needed anymore. + m_ctx.m_proto_model = nullptr; // proto_model is not needed anymore. } } }; @@ -514,12 +514,12 @@ namespace smt { enode_vector::const_iterator begin_enodes_of(func_decl const * decl) const { unsigned id = decl->get_decl_id(); - return id < m_decl2enodes.size() ? m_decl2enodes[id].begin() : 0; + return id < m_decl2enodes.size() ? m_decl2enodes[id].begin() : nullptr; } enode_vector::const_iterator end_enodes_of(func_decl const * decl) const { unsigned id = decl->get_decl_id(); - return id < m_decl2enodes.size() ? m_decl2enodes[id].end() : 0; + return id < m_decl2enodes.size() ? m_decl2enodes[id].end() : nullptr; } ptr_vector::const_iterator begin_enodes() const { @@ -822,17 +822,17 @@ namespace smt { void internalize(expr * n, bool gate_ctx, unsigned generation); - clause * mk_clause(unsigned num_lits, literal * lits, justification * j, clause_kind k = CLS_AUX, clause_del_eh * del_eh = 0); + clause * mk_clause(unsigned num_lits, literal * lits, justification * j, clause_kind k = CLS_AUX, clause_del_eh * del_eh = nullptr); void mk_clause(literal l1, literal l2, justification * j); void mk_clause(literal l1, literal l2, literal l3, justification * j); - void mk_th_axiom(theory_id tid, unsigned num_lits, literal * lits, unsigned num_params = 0, parameter * params = 0); + void mk_th_axiom(theory_id tid, unsigned num_lits, literal * lits, unsigned num_params = 0, parameter * params = nullptr); - void mk_th_axiom(theory_id tid, literal l1, literal l2, unsigned num_params = 0, parameter * params = 0); + void mk_th_axiom(theory_id tid, literal l1, literal l2, unsigned num_params = 0, parameter * params = nullptr); - void mk_th_axiom(theory_id tid, literal l1, literal l2, literal l3, unsigned num_params = 0, parameter * params = 0); + void mk_th_axiom(theory_id tid, literal l1, literal l2, literal l3, unsigned num_params = 0, parameter * params = nullptr); /* * Provide a hint to the core solver that the specified literals form a "theory case split". @@ -1460,7 +1460,7 @@ namespace smt { If l == 0, then the logic of this context is used in the new context. If p == 0, then this->m_params is used */ - context * mk_fresh(symbol const * l = 0, smt_params * p = 0); + context * mk_fresh(symbol const * l = nullptr, smt_params * p = nullptr); static void copy(context& src, context& dst); @@ -1482,7 +1482,7 @@ namespace smt { void pop(unsigned num_scopes); - lbool check(unsigned num_assumptions = 0, expr * const * assumptions = 0, bool reset_cancel = true, bool already_did_theory_assumptions = false); + lbool check(unsigned num_assumptions = 0, expr * const * assumptions = nullptr, bool reset_cancel = true, bool already_did_theory_assumptions = false); lbool get_consequences(expr_ref_vector const& assumptions, expr_ref_vector const& vars, expr_ref_vector& conseq, expr_ref_vector& unfixed); diff --git a/src/smt/smt_enode.cpp b/src/smt/smt_enode.cpp index 1452dc610..e09e83f6b 100644 --- a/src/smt/smt_enode.cpp +++ b/src/smt/smt_enode.cpp @@ -32,7 +32,7 @@ namespace smt { n->m_owner = owner; n->m_root = n; n->m_next = n; - n->m_cg = 0; + n->m_cg = nullptr; n->m_class_size = 1; n->m_generation = generation; n->m_func_decl_id = UINT_MAX; @@ -130,11 +130,11 @@ namespace smt { if (m_th_var_list.get_th_var() == null_theory_var) { m_th_var_list.set_th_var(v); m_th_var_list.set_th_id(id); - m_th_var_list.set_next(0); + m_th_var_list.set_next(nullptr); } else { theory_var_list * l = &m_th_var_list; - while (l->get_next() != 0) { + while (l->get_next() != nullptr) { SASSERT(l->get_th_id() != id); l = l->get_next(); } @@ -172,11 +172,11 @@ namespace smt { SASSERT(get_th_var(id) != null_theory_var); if (m_th_var_list.get_th_id() == id) { theory_var_list * next = m_th_var_list.get_next(); - if (next == 0) { + if (next == nullptr) { // most common case m_th_var_list.set_th_var(null_theory_var); m_th_var_list.set_th_id(null_theory_id); - m_th_var_list.set_next(0); + m_th_var_list.set_next(nullptr); } else { m_th_var_list = *next; @@ -405,7 +405,7 @@ namespace smt { tmp_enode::tmp_enode(): m_app(0), m_capacity(0), - m_enode_data(0) { + m_enode_data(nullptr) { SASSERT(m_app.get_app()->get_decl() == 0); set_capacity(5); } diff --git a/src/smt/smt_enode.h b/src/smt/smt_enode.h index f471314fa..b216665e5 100644 --- a/src/smt/smt_enode.h +++ b/src/smt/smt_enode.h @@ -33,7 +33,7 @@ namespace smt { enode * m_target; eq_justification m_justification; trans_justification(): - m_target(0), + m_target(nullptr), m_justification(null_eq_justification) { } }; @@ -116,7 +116,7 @@ namespace smt { theory_var_list * get_th_var_list() { - return m_th_var_list.get_th_var() == null_theory_var ? 0 : &m_th_var_list; + return m_th_var_list.get_th_var() == null_theory_var ? nullptr : &m_th_var_list; } friend class set_merge_tf_trail; @@ -306,7 +306,7 @@ namespace smt { } theory_var_list const * get_th_var_list() const { - return m_th_var_list.get_th_var() == null_theory_var ? 0 : &m_th_var_list; + return m_th_var_list.get_th_var() == null_theory_var ? nullptr : &m_th_var_list; } bool has_th_vars() const { diff --git a/src/smt/smt_eq_justification.h b/src/smt/smt_eq_justification.h index af538a130..952caa2a5 100644 --- a/src/smt/smt_eq_justification.h +++ b/src/smt/smt_eq_justification.h @@ -78,7 +78,7 @@ namespace smt { } }; - const eq_justification null_eq_justification(static_cast(0)); + const eq_justification null_eq_justification(static_cast(nullptr)); }; #endif /* SMT_EQ_JUSTIFICATION_H_ */ diff --git a/src/smt/smt_implied_equalities.cpp b/src/smt/smt_implied_equalities.cpp index d021708fc..0b944c145 100644 --- a/src/smt/smt_implied_equalities.cpp +++ b/src/smt/smt_implied_equalities.cpp @@ -96,7 +96,7 @@ namespace smt { ++m_stats_calls; m_solver.push(); m_solver.assert_expr(m.mk_not(m.mk_eq(s, t))); - bool is_eq = l_false == m_solver.check_sat(0,0); + bool is_eq = l_false == m_solver.check_sat(0,nullptr); m_solver.pop(1); TRACE("get_implied_equalities", tout << mk_pp(t, m) << " = " << mk_pp(s, m) << " " << (is_eq?"eq":"unrelated") << "\n";); if (is_eq) { @@ -123,7 +123,7 @@ namespace smt { m_stats_timer.start(); m_solver.push(); m_solver.assert_expr(m.mk_not(m.mk_eq(s, t))); - bool is_eq = l_false == m_solver.check_sat(0,0); + bool is_eq = l_false == m_solver.check_sat(0,nullptr); m_solver.pop(1); m_stats_timer.stop(); TRACE("get_implied_equalities", tout << mk_pp(t, m) << " = " << mk_pp(s, m) << " " << (is_eq?"eq":"unrelated") << "\n";); @@ -155,7 +155,7 @@ namespace smt { m_solver.push(); unsigned arity = get_array_arity(srt); expr_ref_vector args(m); - args.push_back(0); + args.push_back(nullptr); for (unsigned i = 0; i < arity; ++i) { sort* srt_i = get_array_domain(srt, i); expr* idx = m.mk_fresh_const("index", srt_i); @@ -163,10 +163,10 @@ namespace smt { } for (unsigned i = 0; i < terms.size(); ++i) { args[0] = terms[i].term; - terms[i].term = m.mk_app(m_array_util.get_family_id(), OP_SELECT, 0, 0, args.size(), args.c_ptr()); + terms[i].term = m.mk_app(m_array_util.get_family_id(), OP_SELECT, 0, nullptr, args.size(), args.c_ptr()); } assert_relevant(terms); - VERIFY(m_solver.check_sat(0,0) != l_false); + VERIFY(m_solver.check_sat(0,nullptr) != l_false); model_ref model1; m_solver.get_model(model1); SASSERT(model1.get()); @@ -215,7 +215,7 @@ namespace smt { expr* s = terms[vec[j]].term; m_solver.push(); m_solver.assert_expr(m.mk_not(m.mk_eq(t, s))); - lbool is_sat = m_solver.check_sat(0,0); + lbool is_sat = m_solver.check_sat(0,nullptr); m_solver.pop(1); TRACE("get_implied_equalities", tout << mk_pp(t, m) << " = " << mk_pp(s, m) << " " << is_sat << "\n";); if (is_sat == l_false) { @@ -284,7 +284,7 @@ namespace smt { } lbool reduce_cond(model_ref& model, expr* e) { - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; if (m.is_eq(e, e1, e2) && m_array_util.is_as_array(e1) && m_array_util.is_as_array(e2)) { if (e1 == e2) { return l_true; @@ -335,7 +335,7 @@ namespace smt { m_solver.push(); assert_relevant(num_terms, terms); - lbool is_sat = m_solver.check_sat(0,0); + lbool is_sat = m_solver.check_sat(0,nullptr); if (is_sat != l_false) { model_ref model; diff --git a/src/smt/smt_internalizer.cpp b/src/smt/smt_internalizer.cpp index 3c92b8318..3d999c3b7 100644 --- a/src/smt/smt_internalizer.cpp +++ b/src/smt/smt_internalizer.cpp @@ -121,7 +121,7 @@ namespace smt { bool visited = true; family_id fid = to_app(n)->get_family_id(); theory * th = m_theories.get_plugin(fid); - bool def_int = th == 0 || th->default_internalizer(); + bool def_int = th == nullptr || th->default_internalizer(); if (!def_int) { ptr_buffer descendants; get_foreign_descendants(to_app(n), fid, descendants); @@ -301,7 +301,7 @@ namespace smt { e->mark_as_interpreted(); app_ref eq(m_manager.mk_eq(fapp, val), m_manager); TRACE("assert_distinct", tout << "eq: " << mk_pp(eq, m_manager) << "\n";); - assert_default(eq, 0); + assert_default(eq, nullptr); mark_as_relevant(eq.get()); // TODO: we may want to hide the auxiliary values val and the function f from the model. } @@ -695,7 +695,7 @@ namespace smt { void context::internalize_term(app * n) { if (e_internalized(n)) { theory * th = m_theories.get_plugin(n->get_family_id()); - if (th != 0) { + if (th != nullptr) { // This code is necessary because some theories may decide // not to create theory variables for a nested application. // Example: @@ -1271,7 +1271,7 @@ namespace smt { case CLS_AUX: { literal_buffer simp_lits; if (!simplify_aux_clause_literals(num_lits, lits, simp_lits)) - return 0; // clause is equivalent to true; + return nullptr; // clause is equivalent to true; DEBUG_CODE({ for (unsigned i = 0; i < simp_lits.size(); i++) { SASSERT(get_assignment(simp_lits[i]) == l_true); @@ -1284,7 +1284,7 @@ namespace smt { } case CLS_AUX_LEMMA: { if (!simplify_aux_lemma_literals(num_lits, lits)) - return 0; // clause is equivalent to true + return nullptr; // clause is equivalent to true // simplify_aux_lemma_literals does not delete literals assigned to false, so // it is not necessary to create a unit_resolution_justification break; @@ -1303,14 +1303,14 @@ namespace smt { if (j && !j->in_region()) m_justifications.push_back(j); TRACE("mk_clause", tout << "empty clause... setting conflict\n";); - set_conflict(j == 0 ? b_justification::mk_axiom() : b_justification(j)); + set_conflict(j == nullptr ? b_justification::mk_axiom() : b_justification(j)); SASSERT(inconsistent()); - return 0; + return nullptr; case 1: if (j && !j->in_region()) m_justifications.push_back(j); assign(lits[0], j); - return 0; + return nullptr; case 2: if (use_binary_clause_opt(lits[0], lits[1], lemma)) { literal l1 = lits[0]; @@ -1321,7 +1321,7 @@ namespace smt { assign(l1, b_justification(~l2)); m_stats.m_num_mk_bin_clause++; - return 0; + return nullptr; } default: { m_stats.m_num_mk_clause++; @@ -1404,7 +1404,7 @@ namespace smt { } void context::mk_th_axiom(theory_id tid, unsigned num_lits, literal * lits, unsigned num_params, parameter * params) { - justification * js = 0; + justification * js = nullptr; TRACE("mk_th_axiom", display_literals_verbose(tout, num_lits, lits); tout << "\n";); @@ -1449,12 +1449,12 @@ namespace smt { void context::mk_gate_clause(unsigned num_lits, literal * lits) { if (m_manager.proofs_enabled()) { - proof * pr = mk_clause_def_axiom(num_lits, lits, 0); + proof * pr = mk_clause_def_axiom(num_lits, lits, nullptr); TRACE("gate_clause", tout << mk_ll_pp(pr, m_manager);); mk_clause(num_lits, lits, mk_justification(justification_proof_wrapper(*this, pr))); } else { - mk_clause(num_lits, lits, 0); + mk_clause(num_lits, lits, nullptr); } } @@ -1487,7 +1487,7 @@ namespace smt { mk_clause(num_lits, lits, mk_justification(justification_proof_wrapper(*this, pr))); } else { - mk_clause(num_lits, lits, 0); + mk_clause(num_lits, lits, nullptr); } } diff --git a/src/smt/smt_justification.cpp b/src/smt/smt_justification.cpp index 440da7297..4ac176a2b 100644 --- a/src/smt/smt_justification.cpp +++ b/src/smt/smt_justification.cpp @@ -90,17 +90,17 @@ namespace smt { SASSERT(m_antecedent); ptr_buffer prs; proof * pr = cr.get_proof(m_antecedent); - bool visited = pr != 0; + bool visited = pr != nullptr; prs.push_back(pr); for (unsigned i = 0; i < m_num_literals; i++) { proof * pr = cr.get_proof(m_literals[i]); - if (pr == 0) + if (pr == nullptr) visited = false; else prs.push_back(pr); } if (!visited) - return 0; + return nullptr; ast_manager & m = cr.get_manager(); TRACE("unit_resolution_justification_bug", tout << "in mk_proof\n"; @@ -150,7 +150,7 @@ namespace smt { } if (!visited) - return 0; + return nullptr; expr * lhs = m_node1->get_root()->get_owner(); expr * rhs = m_node2->get_root()->get_owner(); @@ -178,7 +178,7 @@ namespace smt { proof * pr2 = m.mk_rewrite(m.get_fact(pr1), lit); return m.mk_modus_ponens(pr1, pr2); } - return 0; + return nullptr; } void eq_propagation_justification::get_antecedents(conflict_resolution & cr) { @@ -241,7 +241,7 @@ namespace smt { mk_pp(m.get_fact(pr), m) << "\n";); return pr; } - return 0; + return nullptr; } simple_justification::simple_justification(region & r, unsigned num_lits, literal const * lits): @@ -266,7 +266,7 @@ namespace smt { bool visited = true; for (unsigned i = 0; i < m_num_literals; i++) { proof * pr = cr.get_proof(m_literals[i]); - if (pr == 0) + if (pr == nullptr) visited = false; else result.push_back(pr); @@ -284,15 +284,15 @@ namespace smt { lits.push_back(l); } if (lits.size() == 1) - return m.mk_th_lemma(m_th_id, lits.get(0), 0, 0, m_params.size(), m_params.c_ptr()); + return m.mk_th_lemma(m_th_id, lits.get(0), 0, nullptr, m_params.size(), m_params.c_ptr()); else - return m.mk_th_lemma(m_th_id, m.mk_or(lits.size(), lits.c_ptr()), 0, 0, m_params.size(), m_params.c_ptr()); + return m.mk_th_lemma(m_th_id, m.mk_or(lits.size(), lits.c_ptr()), 0, nullptr, m_params.size(), m_params.c_ptr()); } proof * theory_propagation_justification::mk_proof(conflict_resolution & cr) { ptr_buffer prs; if (!antecedent2proof(cr, prs)) - return 0; + return nullptr; context & ctx = cr.get_context(); ast_manager & m = cr.get_manager(); expr_ref fact(m); @@ -303,7 +303,7 @@ namespace smt { proof * theory_conflict_justification::mk_proof(conflict_resolution & cr) { ptr_buffer prs; if (!antecedent2proof(cr, prs)) - return 0; + return nullptr; ast_manager & m = cr.get_manager(); return m.mk_th_lemma(m_th_id, m.mk_false(), prs.size(), prs.c_ptr(), m_params.size(), m_params.c_ptr()); } @@ -334,7 +334,7 @@ namespace smt { for (unsigned i = 0; i < m_num_eqs; i++) { enode_pair const & p = m_eqs[i]; proof * pr = cr.get_proof(p.first, p.second); - if (pr == 0) + if (pr == nullptr) visited = false; else result.push_back(pr); @@ -345,7 +345,7 @@ namespace smt { proof * ext_theory_propagation_justification::mk_proof(conflict_resolution & cr) { ptr_buffer prs; if (!antecedent2proof(cr, prs)) - return 0; + return nullptr; context & ctx = cr.get_context(); ast_manager & m = cr.get_manager(); expr_ref fact(m); @@ -356,7 +356,7 @@ namespace smt { proof * ext_theory_conflict_justification::mk_proof(conflict_resolution & cr) { ptr_buffer prs; if (!antecedent2proof(cr, prs)) - return 0; + return nullptr; ast_manager & m = cr.get_manager(); return m.mk_th_lemma(m_th_id, m.mk_false(), prs.size(), prs.c_ptr(), m_params.size(), m_params.c_ptr()); } @@ -364,7 +364,7 @@ namespace smt { proof * ext_theory_eq_propagation_justification::mk_proof(conflict_resolution & cr) { ptr_buffer prs; if (!antecedent2proof(cr, prs)) - return 0; + return nullptr; ast_manager & m = cr.get_manager(); context & ctx = cr.get_context(); expr * fact = ctx.mk_eq_atom(m_lhs->get_owner(), m_rhs->get_owner()); @@ -415,9 +415,9 @@ namespace smt { lits.push_back(l); } if (lits.size() == 1) - return m.mk_th_lemma(m_th_id, lits.get(0), 0, 0, m_params.size(), m_params.c_ptr()); + return m.mk_th_lemma(m_th_id, lits.get(0), 0, nullptr, m_params.size(), m_params.c_ptr()); else - return m.mk_th_lemma(m_th_id, m.mk_or(lits.size(), lits.c_ptr()), 0, 0, m_params.size(), m_params.c_ptr()); + return m.mk_th_lemma(m_th_id, m.mk_or(lits.size(), lits.c_ptr()), 0, nullptr, m_params.size(), m_params.c_ptr()); } }; diff --git a/src/smt/smt_justification.h b/src/smt/smt_justification.h index 1b5aecfe5..8354c8860 100644 --- a/src/smt/smt_justification.h +++ b/src/smt/smt_justification.h @@ -255,7 +255,7 @@ namespace smt { theory_axiom_justification(family_id fid, region & r, unsigned num_lits, literal const * lits, - unsigned num_params = 0, parameter* params = 0): + unsigned num_params = 0, parameter* params = nullptr): simple_theory_justification(fid, r, num_lits, lits, num_params, params) {} void get_antecedents(conflict_resolution & cr) override {} @@ -269,7 +269,7 @@ namespace smt { literal m_consequent; public: theory_propagation_justification(family_id fid, region & r, unsigned num_lits, literal const * lits, literal consequent, - unsigned num_params = 0, parameter* params = 0): + unsigned num_params = 0, parameter* params = nullptr): simple_theory_justification(fid, r, num_lits, lits, num_params, params), m_consequent(consequent) {} proof * mk_proof(conflict_resolution & cr) override; @@ -282,7 +282,7 @@ namespace smt { class theory_conflict_justification : public simple_theory_justification { public: theory_conflict_justification(family_id fid, region & r, unsigned num_lits, literal const * lits, - unsigned num_params = 0, parameter* params = 0): + unsigned num_params = 0, parameter* params = nullptr): simple_theory_justification(fid, r, num_lits, lits, num_params, params) {} proof * mk_proof(conflict_resolution & cr) override; @@ -322,7 +322,7 @@ namespace smt { public: ext_theory_simple_justification(family_id fid, region & r, unsigned num_lits, literal const * lits, unsigned num_eqs, enode_pair const * eqs, - unsigned num_params = 0, parameter* params = 0): + unsigned num_params = 0, parameter* params = nullptr): ext_simple_justification(r, num_lits, lits, num_eqs, eqs), m_th_id(fid), m_params(num_params, params) {} ~ext_theory_simple_justification() override {} @@ -341,7 +341,7 @@ namespace smt { unsigned num_lits, literal const * lits, unsigned num_eqs, enode_pair const * eqs, literal consequent, - unsigned num_params = 0, parameter* params = 0): + unsigned num_params = 0, parameter* params = nullptr): ext_theory_simple_justification(fid, r, num_lits, lits, num_eqs, eqs, num_params, params), m_consequent(consequent) {} @@ -354,7 +354,7 @@ namespace smt { public: ext_theory_conflict_justification(family_id fid, region & r, unsigned num_lits, literal const * lits, unsigned num_eqs, enode_pair const * eqs, - unsigned num_params = 0, parameter* params = 0): + unsigned num_params = 0, parameter* params = nullptr): ext_theory_simple_justification(fid, r, num_lits, lits, num_eqs, eqs, num_params, params) {} proof * mk_proof(conflict_resolution & cr) override; @@ -371,7 +371,7 @@ namespace smt { unsigned num_lits, literal const * lits, unsigned num_eqs, enode_pair const * eqs, enode * lhs, enode * rhs, - unsigned num_params = 0, parameter* params = 0): + unsigned num_params = 0, parameter* params = nullptr): ext_theory_simple_justification(fid, r, num_lits, lits, num_eqs, eqs, num_params, params), m_lhs(lhs), m_rhs(rhs) {} proof * mk_proof(conflict_resolution & cr) override; @@ -392,7 +392,7 @@ namespace smt { public: theory_lemma_justification(family_id fid, context & ctx, unsigned num_lits, literal const * lits, - unsigned num_params = 0, parameter* params = 0); + unsigned num_params = 0, parameter* params = nullptr); ~theory_lemma_justification() override; diff --git a/src/smt/smt_kernel.h b/src/smt/smt_kernel.h index d10cab4f3..141ab1dae 100644 --- a/src/smt/smt_kernel.h +++ b/src/smt/smt_kernel.h @@ -126,7 +126,7 @@ namespace smt { /** \brief Satisfiability check. */ - lbool check(unsigned num_assumptions = 0, expr * const * assumptions = 0); + lbool check(unsigned num_assumptions = 0, expr * const * assumptions = nullptr); lbool check(expr_ref_vector const& asms) { return check(asms.size(), asms.c_ptr()); } diff --git a/src/smt/smt_model_checker.cpp b/src/smt/smt_model_checker.cpp index cd59014aa..765cc87f5 100644 --- a/src/smt/smt_model_checker.cpp +++ b/src/smt/smt_model_checker.cpp @@ -33,19 +33,19 @@ namespace smt { m(m), m_params(p), m_autil(m), - m_qm(0), - m_context(0), - m_root2value(0), + m_qm(nullptr), + m_context(nullptr), + m_root2value(nullptr), m_model_finder(mf), m_max_cexs(1), m_iteration_idx(0), - m_curr_model(0), + m_curr_model(nullptr), m_pinned_exprs(m) { } model_checker::~model_checker() { - m_aux_context = 0; // delete aux context before fparams - m_fparams = 0; + m_aux_context = nullptr; // delete aux context before fparams + m_fparams = nullptr; } quantifier * model_checker::get_flat_quantifier(quantifier * q) { @@ -72,7 +72,7 @@ namespace smt { m_value2expr.insert(val, n->get_owner()); } } - expr * t = 0; + expr * t = nullptr; m_value2expr.find(val, t); return t; } @@ -111,10 +111,10 @@ namespace smt { ptr_buffer subst_args; unsigned num_decls = q->get_num_decls(); subst_args.resize(num_decls, 0); - sks.resize(num_decls, 0); + sks.resize(num_decls, nullptr); for (unsigned i = 0; i < num_decls; i++) { sort * s = q->get_decl_sort(num_decls - i - 1); - expr * sk = m.mk_fresh_const(0, s); + expr * sk = m.mk_fresh_const(nullptr, s); sks[num_decls - i - 1] = sk; subst_args[num_decls - i - 1] = sk; if (m_curr_model->is_finite(s)) { @@ -132,7 +132,7 @@ namespace smt { } bool model_checker::add_instance(quantifier * q, model * cex, expr_ref_vector & sks, bool use_inv) { - if (cex == 0) { + if (cex == nullptr) { TRACE("model_checker", tout << "no model is available\n";); return false; } @@ -158,7 +158,7 @@ namespace smt { if (use_inv) { unsigned sk_term_gen; expr * sk_term = m_model_finder.get_inv(q, i, sk_value, sk_term_gen); - if (sk_term != 0) { + if (sk_term != nullptr) { TRACE("model_checker", tout << "Found inverse " << mk_pp(sk_term, m) << "\n";); SASSERT(!m.is_model_value(sk_term)); if (sk_term_gen > max_generation) @@ -172,7 +172,7 @@ namespace smt { } else { expr * sk_term = get_term_from_ctx(sk_value); - if (sk_term != 0) { + if (sk_term != nullptr) { sk_value = sk_term; } } @@ -323,7 +323,7 @@ namespace smt { bool is_undef = false; expr_ref_vector args(m); unsigned num_decls = q->get_num_decls(); - args.resize(num_decls, 0); + args.resize(num_decls, nullptr); var_subst sub(m); expr_ref tmp(m), result(m); for (; it != end; ++it) { @@ -502,7 +502,7 @@ namespace smt { expr_ref inst_expr(m); instantiate(m, q, inst->m_bindings, inst_expr); tout << "(assert " << mk_ismt2_pp(inst_expr, m) << ")\n";); - m_context->add_instance(q, 0, num_decls, bindings.c_ptr(), gen, gen, gen, dummy); + m_context->add_instance(q, nullptr, num_decls, bindings.c_ptr(), gen, gen, gen, dummy); TRACE("model_checker_bug_detail", tout << "after instantiating, inconsistent: " << m_context->inconsistent() << "\n";); } } diff --git a/src/smt/smt_model_finder.cpp b/src/smt/smt_model_finder.cpp index 447705572..778337697 100644 --- a/src/smt/smt_model_finder.cpp +++ b/src/smt/smt_model_finder.cpp @@ -120,7 +120,7 @@ namespace smt { } expr * get_inv(expr * v) const { - expr * t = 0; + expr * t = nullptr; m_inv.find(v, t); return t; } @@ -140,7 +140,7 @@ namespace smt { if (!t_val) break; TRACE("model_finder", tout << mk_pp(t, m_manager) << " " << mk_pp(t_val, m_manager) << "\n";); - expr * old_t = 0; + expr * old_t = nullptr; if (m_inv.find(t_val, old_t)) { unsigned old_t_gen = 0; SASSERT(m_elems.contains(old_t)); @@ -223,14 +223,14 @@ namespace smt { public: node(unsigned id, sort * s): m_id(id), - m_find(0), + m_find(nullptr), m_eqc_size(1), m_sort(s), m_mono_proj(false), m_signed_proj(false), - m_set(0), - m_else(0), - m_proj(0) { + m_set(nullptr), + m_else(nullptr), + m_proj(nullptr) { } ~node() { @@ -242,7 +242,7 @@ namespace smt { sort * get_sort() const { return m_sort; } - bool is_root() const { return m_find == 0; } + bool is_root() const { return m_find == nullptr; } node * get_root() const { node * curr = const_cast(this); @@ -428,7 +428,7 @@ namespace smt { } node * mk_node(key2node & m, ast * n, unsigned i, sort * s) { - node * r = 0; + node * r = nullptr; ast_idx_pair k(n, i); if (m.find(k, r)) { SASSERT(r->get_sort() == s); @@ -469,11 +469,11 @@ namespace smt { m_arith(m), m_bv(m), m_next_node_id(0), - m_context(0), + m_context(nullptr), m_ks(m), - m_model(0), + m_model(nullptr), m_eval_cache_range(m), - m_new_constraints(0) { + m_new_constraints(nullptr) { } virtual ~auf_solver() { @@ -523,10 +523,10 @@ namespace smt { instantiation_set const * get_uvar_inst_set(quantifier * q, unsigned i) const { SASSERT(!has_quantifiers(q->get_expr())); ast_idx_pair k(q, i); - node * r = 0; + node * r = nullptr; if (m_uvars.find(k, r)) return r->get_instantiation_set(); - return 0; + return nullptr; } void mk_instantiation_sets() { @@ -567,13 +567,13 @@ namespace smt { } expr * eval(expr * n, bool model_completion) override { - expr * r = 0; + expr * r = nullptr; if (m_eval_cache[model_completion].find(n, r)) { return r; } expr_ref tmp(m); if (!m_model->eval(n, tmp, model_completion)) { - r = 0; + r = nullptr; TRACE("model_finder", tout << "eval\n" << mk_pp(n, m) << "\n-----> null\n";); } else { @@ -602,7 +602,7 @@ namespace smt { for (node* a : avoid_set) { node * n = a->get_root(); - if (!n->is_mono_proj() && n->get_else() != 0) { + if (!n->is_mono_proj() && n->get_else() != nullptr) { expr * val = eval(n->get_else(), true); SASSERT(val != 0); r.push_back(val); @@ -621,7 +621,7 @@ namespace smt { instantiation_set const * s = n->get_instantiation_set(); obj_map const & elems = s->get_elems(); - expr * t_result = 0; + expr * t_result = nullptr; unsigned gen_result = UINT_MAX; for (auto const& kv : elems) { expr * t = kv.m_key; @@ -635,7 +635,7 @@ namespace smt { break; } } - if (!found && (t_result == 0 || gen < gen_result)) { + if (!found && (t_result == nullptr || gen < gen_result)) { t_result = t; gen_result = gen; } @@ -652,7 +652,7 @@ namespace smt { */ app * get_k_for(sort * s) { SASSERT(is_infinite(s)); - app * r = 0; + app * r = nullptr; if (m_sort2k.find(s, r)) return r; r = m.mk_fresh_const("k", s); @@ -674,11 +674,11 @@ namespace smt { SASSERT(is_infinite(s)); func_decl * k_decl = k->get_decl(); expr * r = m_model->get_const_interp(k_decl); - if (r != 0) + if (r != nullptr) return r; r = m_model->get_fresh_value(s); - if (r == 0) - return 0; + if (r == nullptr) + return nullptr; m_model->register_decl(k_decl, r); SASSERT(m_model->get_const_interp(k_decl) == r); TRACE("model_finder", tout << mk_pp(r, m) << "\n";); @@ -694,7 +694,7 @@ namespace smt { TRACE("assert_k_diseq_exceptions", tout << "assert_k_diseq_exceptions, " << "k: " << mk_pp(k, m) << "\nexceptions:\n"; for (expr * e : exceptions) tout << mk_pp(e, m) << "\n";); expr * k_interp = get_k_interp(k); - if (k_interp == 0) + if (k_interp == nullptr) return false; for (expr * ex : exceptions) { expr * ex_val = eval(ex, true); @@ -720,7 +720,7 @@ namespace smt { ptr_buffer ex_vals; collect_exceptions_values(n, ex_vals); expr * e = pick_instance_diff_exceptions(n, ex_vals); - if (e != 0) { + if (e != nullptr) { n->set_else(e); return; } @@ -912,7 +912,7 @@ namespace smt { func_decl * f = to_func_decl(kv.m_key.first); if (!r.contains(f)) { func_interp * fi = m_model->get_func_interp(f); - if (fi == 0) { + if (fi == nullptr) { fi = alloc(func_interp, m, f->get_arity()); m_model->register_decl(f, fi); SASSERT(fi->is_partial()); @@ -1013,10 +1013,10 @@ namespace smt { is irrelevant after the projections are applied. */ func_decl * get_f_i_proj(func_decl * f, unsigned i) { - node * r = 0; + node * r = nullptr; ast_idx_pair k(f, i); if (!m_A_f_is.find(k, r)) - return 0; + return nullptr; return r->get_proj(); } @@ -1039,7 +1039,7 @@ namespace smt { for (unsigned i = 0; i < arity; i++) { var * v = m.mk_var(i, f->get_domain(i)); func_decl * pi = get_f_i_proj(f, i); - if (pi != 0) { + if (pi != nullptr) { args.push_back(m.mk_app(pi, v)); has_proj = true; } @@ -1384,9 +1384,9 @@ namespace smt { func_decl * get_array_func_decl(app * ground_array, auf_solver & s) { expr * ground_array_interp = s.eval(ground_array, false); - if (ground_array_interp != 0 && m_array.is_as_array(ground_array_interp)) + if (ground_array_interp != nullptr && m_array.is_as_array(ground_array_interp)) return m_array.get_as_array_func_decl(ground_array_interp); - return 0; + return nullptr; } public: @@ -1656,7 +1656,7 @@ namespace smt { expr * get_cond() const { return m_cond; } - bool is_unconditional() const { return m_cond == 0 || m_manager.is_true(m_cond); } + bool is_unconditional() const { return m_cond == nullptr || m_manager.is_true(m_cond); } bool satisfy_atom() const { return m_satisfy_atom; } @@ -1736,8 +1736,8 @@ namespace smt { m_flat_q(m), m_is_auf(true), m_has_x_eq_y(false), - m_the_one(0), - m_uvar_inst_sets(0) { + m_the_one(nullptr), + m_uvar_inst_sets(nullptr) { if (has_quantifiers(q->get_expr())) { static bool displayed_flat_msg = false; if (!displayed_flat_msg) { @@ -1850,30 +1850,30 @@ namespace smt { void populate_macro_based_inst_sets(context * ctx, evaluator & ev) { SASSERT(m_the_one != 0); - if (m_uvar_inst_sets != 0) + if (m_uvar_inst_sets != nullptr) return; m_uvar_inst_sets = alloc(ptr_vector); for (qinfo* qi : m_qinfo_vect) qi->populate_inst_sets(m_flat_q, m_the_one, *m_uvar_inst_sets, ctx); for (instantiation_set * s : *m_uvar_inst_sets) { - if (s != 0) + if (s != nullptr) s->mk_inverse(ev); } } instantiation_set * get_macro_based_inst_set(unsigned vidx, context * ctx, evaluator & ev) { - if (m_the_one == 0) - return 0; + if (m_the_one == nullptr) + return nullptr; populate_macro_based_inst_sets(ctx, ev); return m_uvar_inst_sets->get(vidx, 0); } void reset_the_one() { - m_the_one = 0; + m_the_one = nullptr; if (m_uvar_inst_sets) { std::for_each(m_uvar_inst_sets->begin(), m_uvar_inst_sets->end(), delete_proc()); dealloc(m_uvar_inst_sets); - m_uvar_inst_sets = 0; + m_uvar_inst_sets = nullptr; } } }; @@ -2389,7 +2389,7 @@ namespace smt { m_array_util(m), m_arith_util(m), m_bv_util(m), - m_info(0) { + m_info(nullptr) { } @@ -2416,7 +2416,7 @@ namespace smt { collect_macro_candidates(q); - m_info = 0; + m_info = nullptr; } }; @@ -2431,7 +2431,7 @@ namespace smt { proto_model * m_model; quantifier_info * get_qinfo(quantifier * q) const { - quantifier_info * qi = 0; + quantifier_info * qi = nullptr; m_q2info.find(q, qi); SASSERT(qi != 0); return qi; @@ -2440,7 +2440,7 @@ namespace smt { void set_else_interp(func_decl * f, expr * f_else) { SASSERT(f_else != 0); func_interp * fi = m_model->get_func_interp(f); - if (fi == 0) { + if (fi == nullptr) { fi = alloc(func_interp, m_manager, f->get_arity()); m_model->register_decl(f, fi); } @@ -2453,7 +2453,7 @@ namespace smt { base_macro_solver(ast_manager & m, obj_map const & q2i): m_manager(m), m_q2info(q2i), - m_model(0) { + m_model(nullptr) { } virtual ~base_macro_solver() {} @@ -2596,7 +2596,7 @@ namespace smt { void insert_q_f(quantifier * q, func_decl * f) { SASSERT(!m_forbidden.contains(f)); - quantifier_set * s = 0; + quantifier_set * s = nullptr; if (!m_q_f.find(f, s)) { s = alloc(quantifier_set); m_q_f.insert(f, s); @@ -2607,7 +2607,7 @@ namespace smt { } void insert_f2def(func_decl * f, expr * def) { - expr_set * s = 0; + expr_set * s = nullptr; if (!m_f2defs.find(f, s)) { s = alloc(expr_set); m_f2defs.insert(f, s); @@ -2619,7 +2619,7 @@ namespace smt { void insert_q_f_def(quantifier * q, func_decl * f, expr * def) { SASSERT(!m_forbidden.contains(f)); - quantifier_set * s = 0; + quantifier_set * s = nullptr; if (!m_q_f_def.find(f, def, s)) { s = alloc(quantifier_set); m_q_f_def.insert(f, def, s); @@ -2631,21 +2631,21 @@ namespace smt { } quantifier_set * get_q_f(func_decl * f) { - quantifier_set * s = 0; + quantifier_set * s = nullptr; m_q_f.find(f, s); SASSERT(s != 0); return s; } quantifier_set * get_q_f_def(func_decl * f, expr * def) { - quantifier_set * s = 0; + quantifier_set * s = nullptr; m_q_f_def.find(f, def, s); SASSERT(s != 0); return s; } expr_set * get_f_defs(func_decl * f) { - expr_set * s = 0; + expr_set * s = nullptr; m_f2defs.find(f, s); SASSERT(s != 0); return s; @@ -2762,7 +2762,7 @@ namespace smt { void operator()(quantifier * q, bool ins) { quantifier_info * qi = m_owner->get_qinfo(q); - qi->set_the_one(0); + qi->set_the_one(nullptr); } ev_handler(hint_solver * o): @@ -3020,7 +3020,7 @@ namespace smt { // Return true if r1 is a better macro than r2. bool is_better_macro(cond_macro * r1, cond_macro * r2) { - if (r2 == 0 || !r1->is_hint()) + if (r2 == nullptr || !r1->is_hint()) return true; if (!r2->is_hint()) return false; @@ -3031,7 +3031,7 @@ namespace smt { } cond_macro * get_macro_for(func_decl * f, quantifier * q) { - cond_macro * r = 0; + cond_macro * r = nullptr; quantifier_info * qi = get_qinfo(q); quantifier_info::macro_iterator it = qi->begin_macros(); quantifier_info::macro_iterator end = qi->end_macros(); @@ -3094,14 +3094,14 @@ namespace smt { if (m->is_unconditional()) return; // f is part of a full macro... ignoring it. to_remove.push_back(q); - if (fi_else.get() == 0) { + if (fi_else.get() == nullptr) { fi_else = m->get_def(); } else { fi_else = m_manager.mk_ite(m->get_cond(), m->get_def(), fi_else); } } - if (fi_else.get() != 0 && add_macro(f, fi_else)) { + if (fi_else.get() != nullptr && add_macro(f, fi_else)) { for (quantifier * q : to_remove) { get_qinfo(q)->set_the_one(f); removed.insert(q); @@ -3139,7 +3139,7 @@ namespace smt { non_auf_macro_solver(ast_manager & m, obj_map const & q2i, func_decl_dependencies & d): base_macro_solver(m, q2i), m_dependencies(d), - m_qi_params(0) { + m_qi_params(nullptr) { } void set_params(qi_params const & p) { @@ -3157,7 +3157,7 @@ namespace smt { model_finder::model_finder(ast_manager & m): m_manager(m), - m_context(0), + m_context(nullptr), m_analyzer(alloc(quantifier_analyzer, *this, m)), m_auf_solver(alloc(auf_solver, m)), m_dependencies(m), @@ -3182,7 +3182,7 @@ namespace smt { } mf::quantifier_info * model_finder::get_quantifier_info(quantifier * q) const { - quantifier_info * info = 0; + quantifier_info * info = nullptr; m_q2info.find(q, info); SASSERT(info != 0); return info; @@ -3348,7 +3348,7 @@ namespace smt { instantiation_set const * r = m_auf_solver->get_uvar_inst_set(flat_q, flat_q->get_num_decls() - q->get_num_decls() + i); TRACE("model_finder", tout << "q: #" << q->get_id() << "\n" << mk_pp(q,m_manager) << "\nflat_q: " << mk_pp(flat_q, m_manager) << "\ni: " << i << " " << flat_q->get_num_decls() - q->get_num_decls() + i << "\n";); - if (r != 0) + if (r != nullptr) return r; // quantifier was not processed by AUF solver... // it must have been satisfied by "macro"/"hint". @@ -3368,10 +3368,10 @@ namespace smt { */ expr * model_finder::get_inv(quantifier * q, unsigned i, expr * val, unsigned & generation) const { instantiation_set const * s = get_uvar_inst_set(q, i); - if (s == 0) - return 0; + if (s == nullptr) + return nullptr; expr * t = s->get_inv(val); - if (t != 0) { + if (t != nullptr) { generation = s->get_generation(t); } return t; @@ -3399,7 +3399,7 @@ namespace smt { for (unsigned i = 0; i < num_decls; i++) { expr * sk = sks.get(num_decls - i - 1); instantiation_set const * s = get_uvar_inst_set(q, i); - if (s == 0) + if (s == nullptr) continue; // nothing to do obj_map const & inv = s->get_inv_map(); if (inv.empty()) diff --git a/src/smt/smt_model_generator.cpp b/src/smt/smt_model_generator.cpp index df6865f1e..98b55c3dd 100644 --- a/src/smt/smt_model_generator.cpp +++ b/src/smt/smt_model_generator.cpp @@ -29,10 +29,10 @@ namespace smt { model_generator::model_generator(ast_manager & m): m_manager(m), - m_context(0), + m_context(nullptr), m_fresh_idx(1), m_asts(m_manager), - m_model(0) { + m_model(nullptr) { } model_generator::~model_generator() { @@ -44,7 +44,7 @@ namespace smt { m_fresh_idx = 1; m_root2value.reset(); m_asts.reset(); - m_model = 0; + m_model = nullptr; } void model_generator::init_model() { @@ -89,7 +89,7 @@ namespace smt { if (r == r->get_root() && m_context->is_relevant(r)) { roots.push_back(r); sort * s = m_manager.get_sort(r->get_owner()); - model_value_proc * proc = 0; + model_value_proc * proc = nullptr; if (m_manager.is_bool(s)) { CTRACE("model", m_context->get_assignment(r) == l_undef, tout << mk_pp(r->get_owner(), m_manager) << "\n";); @@ -177,7 +177,7 @@ namespace smt { if (m_manager.get_sort(r->get_owner()) != s) continue; SASSERT(r == r->get_root()); - model_value_proc * proc = 0; + model_value_proc * proc = nullptr; root2proc.find(r, proc); SASSERT(proc); if (proc->is_fresh()) @@ -196,7 +196,7 @@ namespace smt { enode * n = src.get_enode(); SASSERT(n == n->get_root()); bool visited = true; - model_value_proc * proc = 0; + model_value_proc * proc = nullptr; root2proc.find(n, proc); SASSERT(proc); buffer dependencies; @@ -283,7 +283,7 @@ namespace smt { sz = roots.size(); for (unsigned i = 0; i < sz; i++) { enode * r = roots[i]; - model_value_proc * proc = 0; + model_value_proc * proc = nullptr; root2proc.find(r, proc); SASSERT(proc); if (!proc->is_fresh()) @@ -345,7 +345,7 @@ namespace smt { TRACE("mg_top_sort", tout << "#" << n->get_owner_id() << "\n";); dependencies.reset(); dependency_values.reset(); - model_value_proc * proc = 0; + model_value_proc * proc = nullptr; VERIFY(root2proc.find(n, proc)); SASSERT(proc); proc->get_dependencies(dependencies); @@ -364,7 +364,7 @@ namespace smt { enode * child = d.get_enode(); TRACE("mg_top_sort", tout << "#" << n->get_owner_id() << " (" << mk_pp(n->get_owner(), m_manager) << "): " << mk_pp(child->get_owner(), m_manager) << " " << mk_pp(child->get_root()->get_owner(), m_manager) << "\n";); child = child->get_root(); - app * val = 0; + app * val = nullptr; m_root2value.find(child, val); SASSERT(val); dependency_values.push_back(val); @@ -395,7 +395,7 @@ namespace smt { } app * model_generator::get_value(enode * n) const { - app * val = 0; + app * val = nullptr; m_root2value.find(n->get_root(), val); SASSERT(val); return val; @@ -438,7 +438,7 @@ namespace smt { args.push_back(arg); } func_interp * fi = m_model->get_func_interp(f); - if (fi == 0) { + if (fi == nullptr) { fi = alloc(func_interp, m_manager, f->get_arity()); m_model->register_decl(f, fi); } @@ -454,7 +454,7 @@ namespace smt { tout << "value: #" << n->get_owner_id() << "\n" << mk_ismt2_pp(result, m_manager) << "\n";); if (m_context->get_last_search_failure() == smt::THEORY) { // if the theory solvers are incomplete, then we cannot assume the e-graph is close under congruence - if (fi->get_entry(args.c_ptr()) == 0) + if (fi->get_entry(args.c_ptr()) == nullptr) fi->insert_new_entry(args.c_ptr(), result); } else { diff --git a/src/smt/smt_model_generator.h b/src/smt/smt_model_generator.h index 2c86ff9ce..7466b8877 100644 --- a/src/smt/smt_model_generator.h +++ b/src/smt/smt_model_generator.h @@ -80,7 +80,7 @@ namespace smt { unsigned m_idx; expr * m_value; public: - extra_fresh_value(sort * s, unsigned idx):m_sort(s), m_idx(idx), m_value(0) {} + extra_fresh_value(sort * s, unsigned idx):m_sort(s), m_idx(idx), m_value(nullptr) {} sort * get_sort() const { return m_sort; } unsigned get_idx() const { return m_idx; } void set_value(expr * n) { SASSERT(m_value == 0); m_value = n; } @@ -100,7 +100,7 @@ namespace smt { extra_fresh_value * m_value; //!< When m_fresh == true, contains the sort of the fresh value }; public: - model_value_dependency():m_fresh(true), m_value(0) {} + model_value_dependency():m_fresh(true), m_value(nullptr) {} model_value_dependency(enode * n):m_fresh(false), m_enode(n->get_root()) {} model_value_dependency(extra_fresh_value * v):m_fresh(true), m_value(v) {} bool is_fresh_value() const { return m_fresh; } diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index 108ebfaf2..0ca244185 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -143,7 +143,7 @@ namespace smt { tout << "inserted: " << (f != 0) << "\n"; ); - return f != 0; + return f != nullptr; } void init_search_eh() { @@ -300,7 +300,7 @@ namespace smt { bool quantifier_manager::add_instance(quantifier * q, unsigned num_bindings, enode * const * bindings, unsigned generation) { ptr_vector tmp; - return add_instance(q, 0, num_bindings, bindings, generation, generation, generation, tmp); + return add_instance(q, nullptr, num_bindings, bindings, generation, generation, generation, tmp); } void quantifier_manager::init_search_eh() { @@ -408,8 +408,8 @@ namespace smt { bool m_active; public: default_qm_plugin(): - m_qm(0), - m_context(0), + m_qm(nullptr), + m_context(nullptr), m_new_enode_qhead(0), m_lazy_matching_idx(0), m_active(false) { diff --git a/src/smt/smt_quantifier_stat.h b/src/smt/smt_quantifier_stat.h index 308534833..5c31032f9 100644 --- a/src/smt/smt_quantifier_stat.h +++ b/src/smt/smt_quantifier_stat.h @@ -119,7 +119,7 @@ namespace smt { expr * m_expr; unsigned m_depth:31; bool m_depth_only:1; //!< track only the depth of this entry. - entry():m_expr(0), m_depth(0), m_depth_only(false) {} + entry():m_expr(nullptr), m_depth(0), m_depth_only(false) {} entry(expr * n, unsigned depth = 0, bool depth_only = false):m_expr(n), m_depth(depth), m_depth_only(depth_only) {} }; ast_manager & m_manager; diff --git a/src/smt/smt_quick_checker.cpp b/src/smt/smt_quick_checker.cpp index 72c28fd7d..64c791a0e 100644 --- a/src/smt/smt_quick_checker.cpp +++ b/src/smt/smt_quick_checker.cpp @@ -108,7 +108,7 @@ namespace smt { if (n->get_family_id() != m_manager.get_basic_family_id()) collect(arg, n->get_decl(), j); else - collect(arg, 0, 0); + collect(arg, nullptr, 0); } } } @@ -157,7 +157,7 @@ namespace smt { flet l(m_conservative, conservative); init(q); TRACE("collector", tout << "model checking: #" << q->get_id() << "\n" << mk_pp(q, m_manager) << "\n";); - collect(q->get_expr(), 0, 0); + collect(q->get_expr(), nullptr, 0); save_result(candidates); } @@ -251,7 +251,7 @@ namespace smt { TRACE("quick_checker_sizes", tout << "found new candidate\n"; for (unsigned i = 0; i < m_num_bindings; i++) tout << "#" << m_bindings[i]->get_owner_id() << " "; tout << "\n";); unsigned max_generation = get_max_generation(m_num_bindings, m_bindings.c_ptr()); - if (m_context.add_instance(q, 0 /* no pattern was used */, m_num_bindings, m_bindings.c_ptr(), max_generation, + if (m_context.add_instance(q, nullptr /* no pattern was used */, m_num_bindings, m_bindings.c_ptr(), max_generation, 0, // min_top_generation is only available for instances created by the MAM 0, // max_top_generation is only available for instances created by the MAM empty_used_enodes)) diff --git a/src/smt/smt_quick_checker.h b/src/smt/smt_quick_checker.h index 21a570c3c..d3af8e2e0 100644 --- a/src/smt/smt_quick_checker.h +++ b/src/smt/smt_quick_checker.h @@ -50,7 +50,7 @@ namespace smt { expr * m_expr; func_decl * m_parent; unsigned m_parent_pos; - entry(expr * n = 0, func_decl * d = 0, unsigned p = 0):m_expr(n), m_parent(d), m_parent_pos(p) {} + entry(expr * n = nullptr, func_decl * d = nullptr, unsigned p = 0):m_expr(n), m_parent(d), m_parent_pos(p) {} unsigned hash() const { return m_parent ? mk_mix(m_expr->get_id(), m_parent->get_id(), m_parent_pos) : m_expr->get_id(); } bool operator==(entry const & e) const { return m_expr == e.m_expr && m_parent == e.m_parent && m_parent_pos == e.m_parent_pos; } }; diff --git a/src/smt/smt_relevancy.cpp b/src/smt/smt_relevancy.cpp index 7a2d4167f..9eabb8319 100644 --- a/src/smt/smt_relevancy.cpp +++ b/src/smt/smt_relevancy.cpp @@ -159,28 +159,28 @@ namespace smt { } relevancy_ehs * get_handlers(expr * n) { - relevancy_ehs * r = 0; + relevancy_ehs * r = nullptr; m_relevant_ehs.find(n, r); SASSERT(m_relevant_ehs.contains(n) || r == 0); return r; } void set_handlers(expr * n, relevancy_ehs * ehs) { - if (ehs == 0) + if (ehs == nullptr) m_relevant_ehs.erase(n); else m_relevant_ehs.insert(n, ehs); } relevancy_ehs * get_watches(expr * n, bool val) { - relevancy_ehs * r = 0; + relevancy_ehs * r = nullptr; m_watches[val ? 1 : 0].find(n, r); SASSERT(m_watches[val ? 1 : 0].contains(n) || r == 0); return r; } void set_watches(expr * n, bool val, relevancy_ehs * ehs) { - if (ehs == 0) + if (ehs == nullptr) m_watches[val ? 1 : 0].erase(n); else m_watches[val ? 1 : 0].insert(n, ehs); @@ -330,7 +330,7 @@ namespace smt { return; if (!is_relevant_core(n)) { enode * e = m_context.find_enode(n); - if (e != 0) { + if (e != nullptr) { enode * curr = e; do { set_relevant(curr->get_owner()); @@ -376,7 +376,7 @@ namespace smt { case l_undef: break; case l_true: { - expr * true_arg = 0; + expr * true_arg = nullptr; unsigned num_args = n->get_num_args(); for (unsigned i = 0; i < num_args; i++) { expr * arg = n->get_arg(i); @@ -400,7 +400,7 @@ namespace smt { lbool val = m_context.find_assignment(n); switch (val) { case l_false: { - expr * false_arg = 0; + expr * false_arg = nullptr; unsigned num_args = n->get_num_args(); for (unsigned i = 0; i < num_args; i++) { expr * arg = n->get_arg(i); @@ -487,7 +487,7 @@ namespace smt { } relevancy_ehs * ehs = get_handlers(n); - while (ehs != 0) { + while (ehs != nullptr) { ehs->head()->operator()(*this, n); ehs = ehs->tail(); } @@ -510,7 +510,7 @@ namespace smt { propagate_relevant_and(to_app(n)); } relevancy_ehs * ehs = get_watches(n, val); - while (ehs != 0) { + while (ehs != nullptr) { ehs->head()->operator()(*this, n, val); ehs = ehs->tail(); } diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index b805253d8..d813f249a 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -195,7 +195,7 @@ namespace smt { void get_labels(svector & r) override { buffer tmp; - m_context.get_relevant_labels(0, tmp); + m_context.get_relevant_labels(nullptr, tmp); r.append(tmp.size(), tmp.c_ptr()); } diff --git a/src/smt/smt_theory.cpp b/src/smt/smt_theory.cpp index 515503d41..b5ad68adc 100644 --- a/src/smt/smt_theory.cpp +++ b/src/smt/smt_theory.cpp @@ -130,8 +130,8 @@ namespace smt { theory::theory(family_id fid): m_id(fid), - m_context(0), - m_manager(0) { + m_context(nullptr), + m_manager(nullptr) { } theory::~theory() { diff --git a/src/smt/smt_theory.h b/src/smt/smt_theory.h index 2ee0db322..9d5a4f49f 100644 --- a/src/smt/smt_theory.h +++ b/src/smt/smt_theory.h @@ -235,7 +235,7 @@ namespace smt { disequality propagation. */ virtual justification * why_is_diseq(theory_var v1, theory_var v2) { - return 0; + return nullptr; } /** @@ -369,7 +369,7 @@ namespace smt { theory_var other = null_theory_var; TRACE("assume_eqs", tout << "#" << n->get_owner_id() << " is_relevant_and_shared: " << is_relevant_and_shared(n) << "\n";); - if (n != 0 && is_relevant_and_shared(n)) { + if (n != nullptr && is_relevant_and_shared(n)) { other = table.insert_if_not_there(v); if (other != v) { enode * n2 = get_enode(other); @@ -423,7 +423,7 @@ namespace smt { \brief Return a functor that can build the value (interpretation) for n. */ virtual model_value_proc * mk_value(enode * n, model_generator & mg) { - return 0; + return nullptr; } virtual bool include_func_interp(func_decl* f) { diff --git a/src/smt/smt_theory_var_list.h b/src/smt/smt_theory_var_list.h index aa2816786..69180ad66 100644 --- a/src/smt/smt_theory_var_list.h +++ b/src/smt/smt_theory_var_list.h @@ -32,10 +32,10 @@ namespace smt { theory_var_list(): m_th_id(null_theory_id), m_th_var(null_theory_var), - m_next(0) { + m_next(nullptr) { } - theory_var_list(theory_id t, theory_var v, theory_var_list * n = 0): + theory_var_list(theory_id t, theory_var v, theory_var_list * n = nullptr): m_th_id(t), m_th_var(v), m_next(n) { diff --git a/src/smt/tactic/ctx_solver_simplify_tactic.cpp b/src/smt/tactic/ctx_solver_simplify_tactic.cpp index 98de6a79b..417922858 100644 --- a/src/smt/tactic/ctx_solver_simplify_tactic.cpp +++ b/src/smt/tactic/ctx_solver_simplify_tactic.cpp @@ -74,7 +74,7 @@ public: model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; reduce(*(in.get())); in->inc_depth(); result.push_back(in.get()); @@ -126,7 +126,7 @@ protected: m_solver.pop(1); }); g.reset(); - g.assert_expr(fml, 0, 0); + g.assert_expr(fml, nullptr, nullptr); IF_VERBOSE(TACTIC_VERBOSITY_LVL, verbose_stream() << "(ctx-solver-simplify :num-steps " << m_num_steps << ")\n";); SASSERT(g.is_well_sorted()); } @@ -140,7 +140,7 @@ protected: m_parent(p), m_self(s), m_idx(i), m_expr(e) {} expr_pos(): - m_parent(0), m_self(0), m_idx(0), m_expr(0) + m_parent(0), m_self(0), m_idx(0), m_expr(nullptr) {} }; @@ -193,7 +193,7 @@ protected: a = to_app(e); sz = a->get_num_args(); - n2 = 0; + n2 = nullptr; for (unsigned i = 0; i < sz; ++i) { expr* arg = a->get_arg(i); diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index af717c807..14a9c3e11 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -47,8 +47,8 @@ class smt_tactic : public tactic { public: smt_tactic(params_ref const & p): m_params_ref(p), - m_ctx(0), - m_callback(0) { + m_ctx(nullptr), + m_callback(nullptr) { updt_params_core(p); TRACE("smt_tactic", tout << "p: " << p << "\n";); } @@ -136,7 +136,7 @@ public: ~scoped_init_ctx() { smt::kernel * d = m_owner.m_ctx; - m_owner.m_ctx = 0; + m_owner.m_ctx = nullptr; if (d) dealloc(d); @@ -151,7 +151,7 @@ public: expr_dependency_ref & core) override { try { IF_VERBOSE(10, verbose_stream() << "(smt.tactic start)\n";); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; SASSERT(in->is_well_sorted()); ast_manager & m = in->m(); TRACE("smt_tactic", tout << this << "\nAUTO_CONFIG: " << fparams().m_auto_config << " HIDIV0: " << fparams().m_hi_div0 << " " @@ -220,7 +220,7 @@ public: model_ref md; m_ctx->get_model(md); buffer r; - m_ctx->get_relevant_labels(0, r); + m_ctx->get_relevant_labels(nullptr, r); mc = model_and_labels2model_converter(md.get(), r); mc = concat(fmc.get(), mc.get()); } @@ -233,8 +233,8 @@ public: } // formula is unsat, reset the goal, and store false there. in->reset(); - proof * pr = 0; - expr_dependency * lcore = 0; + proof * pr = nullptr; + expr_dependency * lcore = nullptr; if (in->proofs_enabled()) pr = m_ctx->get_proof(); if (in->unsat_core_enabled()) { @@ -269,7 +269,7 @@ public: model_ref md; m_ctx->get_model(md); buffer r; - m_ctx->get_relevant_labels(0, r); + m_ctx->get_relevant_labels(nullptr, r); mc = model_and_labels2model_converter(md.get(), r); } return; diff --git a/src/smt/theory_arith.h b/src/smt/theory_arith.h index 98bbefd42..5040f1034 100644 --- a/src/smt/theory_arith.h +++ b/src/smt/theory_arith.h @@ -561,16 +561,16 @@ namespace smt { bound * upper(theory_var v) const { return m_bounds[1][v]; } inf_numeral const & lower_bound(theory_var v) const { SASSERT(lower(v) != 0); return lower(v)->get_value(); } inf_numeral const & upper_bound(theory_var v) const { SASSERT(upper(v) != 0); return upper(v)->get_value(); } - bool below_lower(theory_var v) const { bound * l = lower(v); return l != 0 && get_value(v) < l->get_value(); } - bool above_upper(theory_var v) const { bound * u = upper(v); return u != 0 && get_value(v) > u->get_value(); } - bool below_upper(theory_var v) const { bound * u = upper(v); return u == 0 || get_value(v) < u->get_value(); } - bool above_lower(theory_var v) const { bound * l = lower(v); return l == 0 || get_value(v) > l->get_value(); } + bool below_lower(theory_var v) const { bound * l = lower(v); return l != nullptr && get_value(v) < l->get_value(); } + bool above_upper(theory_var v) const { bound * u = upper(v); return u != nullptr && get_value(v) > u->get_value(); } + bool below_upper(theory_var v) const { bound * u = upper(v); return u == nullptr || get_value(v) < u->get_value(); } + bool above_lower(theory_var v) const { bound * l = lower(v); return l == nullptr || get_value(v) > l->get_value(); } bool at_bound(theory_var v) const; - bool at_lower(theory_var v) const { bound * l = lower(v); return l != 0 && get_value(v) == l->get_value(); } - bool at_upper(theory_var v) const { bound * u = upper(v); return u != 0 && get_value(v) == u->get_value(); } - bool is_free(theory_var v) const { return lower(v) == 0 && upper(v) == 0; } - bool is_non_free(theory_var v) const { return lower(v) != 0 || upper(v) != 0; } - bool is_bounded(theory_var v) const { return lower(v) != 0 && upper(v) != 0; } + bool at_lower(theory_var v) const { bound * l = lower(v); return l != nullptr && get_value(v) == l->get_value(); } + bool at_upper(theory_var v) const { bound * u = upper(v); return u != nullptr && get_value(v) == u->get_value(); } + bool is_free(theory_var v) const { return lower(v) == nullptr && upper(v) == nullptr; } + bool is_non_free(theory_var v) const { return lower(v) != nullptr || upper(v) != nullptr; } + bool is_bounded(theory_var v) const { return lower(v) != nullptr && upper(v) != nullptr; } bool is_free(expr * n) const { SASSERT(get_context().e_internalized(n) && get_context().get_enode(n)->get_th_var(get_id()) != null_theory_var); return is_free(get_context().get_enode(n)->get_th_var(get_id())); diff --git a/src/smt/theory_arith_aux.h b/src/smt/theory_arith_aux.h index a1558e5e5..6a19f2f6e 100644 --- a/src/smt/theory_arith_aux.h +++ b/src/smt/theory_arith_aux.h @@ -279,7 +279,7 @@ namespace smt { return it; } } - return 0; + return nullptr; } template @@ -357,7 +357,7 @@ namespace smt { template parameter * theory_arith::antecedents_t::params(char const* name) { - if (empty()) return 0; + if (empty()) return nullptr; init(); m_params[0] = parameter(symbol(name)); return m_params.c_ptr(); @@ -444,19 +444,19 @@ namespace smt { template bool theory_arith::at_bound(theory_var v) const { bound * l = lower(v); - if (l != 0 && get_value(v) == l->get_value()) + if (l != nullptr && get_value(v) == l->get_value()) return true; bound * u = upper(v); - return u != 0 && get_value(v) == u->get_value(); + return u != nullptr && get_value(v) == u->get_value(); } template bool theory_arith::is_fixed(theory_var v) const { bound * l = lower(v); - if (l == 0) + if (l == nullptr) return false; bound * u = upper(v); - if (u == 0) + if (u == nullptr) return false; return l->get_value() == u->get_value(); } @@ -483,7 +483,7 @@ namespace smt { while (true) { column const & c = m_columns[v]; if (c.size() == 0) - return 0; + return nullptr; int quasi_base_rid = -1; typename svector::const_iterator it = c.begin_entries(); typename svector::const_iterator end = c.end_entries(); @@ -533,7 +533,7 @@ namespace smt { typename theory_arith::col_entry const * theory_arith::get_row_for_eliminating(theory_var v) const { column const & c = m_columns[v]; if (c.size() == 0) - return 0; + return nullptr; typename svector::const_iterator it = c.begin_entries(); typename svector::const_iterator end = c.end_entries(); for (; it != end; ++it) { @@ -556,7 +556,7 @@ namespace smt { return it; } } - return 0; + return nullptr; } template diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index 03830f7d0..fe62efbf4 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -472,7 +472,7 @@ namespace smt { tout << s_ante << "\n" << s_conseq << "\n";); // literal lits[2] = {l_ante, l_conseq}; - mk_clause(l_ante, l_conseq, 0, 0); + mk_clause(l_ante, l_conseq, 0, nullptr); if (ctx.relevancy()) { if (l_ante == false_literal) { ctx.mark_as_relevant(l_conseq); @@ -1347,8 +1347,8 @@ namespace smt { std::swap(n1, n2); } rational k; - bound * b1 = 0; - bound * b2 = 0; + bound * b1 = nullptr; + bound * b2 = nullptr; if (m_util.is_numeral(n2->get_owner(), k)) { inf_numeral val(k); b1 = alloc(eq_bound, v1, val, B_LOWER, n1, n2); @@ -2342,7 +2342,7 @@ namespace smt { row const & r = m_rows[get_var_row(x_i)]; int idx = r.get_idx_of(x_i); SASSERT(idx >= 0); - bound * b = 0; + bound * b = nullptr; // Remark: // if x_i is an integer variable, then delta can be negative: @@ -2616,7 +2616,7 @@ namespace smt { return; } bool is_pos = it->m_coeff.is_pos(); - if (lower(it->m_var) == 0) { + if (lower(it->m_var) == nullptr) { if (is_pos) { UPDATE_IDX(upper_idx); } @@ -2624,7 +2624,7 @@ namespace smt { UPDATE_IDX(lower_idx); } } - if (upper(it->m_var) == 0) { + if (upper(it->m_var) == nullptr) { if (is_pos) { UPDATE_IDX(lower_idx); } @@ -2661,7 +2661,7 @@ namespace smt { if (entry.m_coeff.is_pos() == is_lower) { // implied_k is a lower bound for entry.m_var bound * curr = lower(entry.m_var); - if (curr == 0 || implied_k > curr->get_value()) { + if (curr == nullptr || implied_k > curr->get_value()) { TRACE("arith_imply_bound", tout << "implying lower bound for v" << entry.m_var << " " << implied_k << " using row:\n"; display_row_info(tout, r); @@ -2672,7 +2672,7 @@ namespace smt { else { // implied_k is an upper bound for it->m_var bound * curr = upper(entry.m_var); - if (curr == 0 || implied_k < curr->get_value()) { + if (curr == nullptr || implied_k < curr->get_value()) { TRACE("arith_imply_bound", tout << "implying upper bound for v" << entry.m_var << " " << implied_k << " using row:\n"; display_row_info(tout, r); @@ -2722,7 +2722,7 @@ namespace smt { if (it->m_coeff.is_pos() == is_lower) { // implied_k is a lower bound for it->m_var bound * curr = lower(it->m_var); - if (curr == 0 || implied_k > curr->get_value()) { + if (curr == nullptr || implied_k > curr->get_value()) { // improved lower bound TRACE("arith_imply_bound", tout << "implying lower bound for v" << it->m_var << " " << implied_k << " using row:\n"; @@ -2734,7 +2734,7 @@ namespace smt { else { // implied_k is an upper bound for it->m_var bound * curr = upper(it->m_var); - if (curr == 0 || implied_k < curr->get_value()) { + if (curr == nullptr || implied_k < curr->get_value()) { // improved upper bound TRACE("arith_imply_bound", tout << "implying upper bound for v" << it->m_var << " " << implied_k << " using row:\n"; @@ -2809,7 +2809,7 @@ namespace smt { TRACE("propagate_bounds_bug", tout << "is_b_lower: " << is_b_lower << " k1: " << k_1 << " limit_k1: " << limit_k1 << " delta: " << delta << " coeff: " << coeff << "\n";); inf_numeral k_2 = k_1; - atom * new_atom = 0; + atom * new_atom = nullptr; atoms const & as = m_var_occs[it->m_var]; typename atoms::const_iterator it = as.begin(); typename atoms::const_iterator end = as.end(); @@ -2844,7 +2844,7 @@ namespace smt { } SASSERT(!is_b_lower || k_2 <= k_1); SASSERT(is_b_lower || k_2 >= k_1); - if (new_atom == 0) { + if (new_atom == nullptr) { b->push_justification(ante, coeff, coeffs_enabled()); continue; } @@ -2976,12 +2976,12 @@ namespace smt { literal_vector::const_iterator end = ante.lits().end(); for (; it != end; ++it) lits.push_back(~(*it)); - justification * js = 0; + justification * js = nullptr; if (proofs_enabled()) { js = alloc(theory_lemma_justification, get_id(), ctx, lits.size(), lits.c_ptr(), ante.num_params(), ante.params("assign-bounds")); } - ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, 0); + ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, nullptr); } else { region & r = ctx.get_region(); @@ -3169,9 +3169,9 @@ namespace smt { for (theory_var v = 0; v < num; v++) { bound * l = lower(v); bound * u = upper(v); - if (l != 0) + if (l != nullptr) update_epsilon(l->get_value(), get_value(v)); - if (u != 0) + if (u != nullptr) update_epsilon(get_value(v), u->get_value()); } TRACE("epsilon_bug", tout << "epsilon: " << m_epsilon << "\n";); @@ -3289,14 +3289,14 @@ namespace smt { template bool theory_arith::get_lower(enode * n, expr_ref & r) { theory_var v = n->get_th_var(get_id()); - bound* b = (v == null_theory_var) ? 0 : lower(v); + bound* b = (v == null_theory_var) ? nullptr : lower(v); return b && to_expr(b->get_value(), is_int(v), r); } template bool theory_arith::get_upper(enode * n, expr_ref & r) { theory_var v = n->get_th_var(get_id()); - bound* b = (v == null_theory_var) ? 0 : upper(v); + bound* b = (v == null_theory_var) ? nullptr : upper(v); return b && to_expr(b->get_value(), is_int(v), r); } @@ -3388,7 +3388,7 @@ namespace smt { bound * b = it->get_old_bound(); SASSERT(is_base(v) || is_non_base(v)); restore_bound(v, b, it->is_upper()); - if (lazy_pivoting_lvl() > 2 && b == 0 && is_base(v) && is_free(v)) { + if (lazy_pivoting_lvl() > 2 && b == nullptr && is_base(v) && is_free(v)) { SASSERT(!has_var_kind(get_var_row(v), BASE)); SASSERT(!has_var_kind(get_var_row(v), QUASI_BASE)); eliminate(v, false); diff --git a/src/smt/theory_arith_eq.h b/src/smt/theory_arith_eq.h index a7f7fae59..40879edd9 100644 --- a/src/smt/theory_arith_eq.h +++ b/src/smt/theory_arith_eq.h @@ -117,7 +117,7 @@ namespace smt { for (; it != end; ++it) { if (!it->is_dead()) { theory_var v = it->m_var; - if (lower(v) != 0 && upper(v) != 0) + if (lower(v) != nullptr && upper(v) != nullptr) continue; bad++; if (bad > 2) { diff --git a/src/smt/theory_arith_int.h b/src/smt/theory_arith_int.h index 593b9c56b..528324040 100644 --- a/src/smt/theory_arith_int.h +++ b/src/smt/theory_arith_int.h @@ -50,15 +50,15 @@ namespace smt { bound * l = lower(v); bound * u = upper(v); const inf_numeral & val = get_value(v); - if (l != 0 && u != 0) { + if (l != nullptr && u != nullptr) { if (val != l->get_value() && val != u->get_value()) set_value(v, l->get_value()); } - else if (l != 0) { + else if (l != nullptr) { if (val != l->get_value()) set_value(v, l->get_value()); } - else if (u != 0) { + else if (u != nullptr) { if (val != u->get_value()) set_value(v, u->get_value()); } @@ -245,12 +245,12 @@ namespace smt { numeral const_coeff(0); bound* l = lower(b), *u = upper(b); - if (l != 0 && get_value(b) - inf_numeral(1) < l->get_value()) { + if (l != nullptr && get_value(b) - inf_numeral(1) < l->get_value()) { SASSERT(l->get_value() <= get_value(b)); is_tight = true; const_coeff = l->get_value().get_rational(); } - else if (u != 0 && get_value(b) + inf_numeral(1) > u->get_value()) { + else if (u != nullptr && get_value(b) + inf_numeral(1) > u->get_value()) { SASSERT(get_value(b) <= u->get_value()); is_tight = true; const_coeff = u->get_value().get_rational(); @@ -1074,7 +1074,7 @@ namespace smt { derived_bound * new_bound = alloc(derived_bound, v, inf_numeral(k), lower ? B_LOWER : B_UPPER); t.m_tmp_lit_set.reset(); t.m_tmp_eq_set.reset(); - if (old_bound != 0) { + if (old_bound != nullptr) { t.accumulate_justification(*old_bound, *new_bound, numeral(0) /* refine for proof gen */, t.m_tmp_lit_set, t.m_tmp_eq_set); } unsigned_vector::const_iterator it = js.begin(); @@ -1174,8 +1174,8 @@ namespace smt { c2 = rational(c); TRACE("euclidean_solver_new", tout << "new fixed: " << c2 << "\n";); propagated = true; - mk_lower(v, c2, 0, m_js); - mk_upper(v, c2, 0, m_js); + mk_lower(v, c2, nullptr, m_js); + mk_upper(v, c2, nullptr, m_js); } else { TRACE("euclidean_solver", tout << "inequality can be tightned, since all coefficients are multiple of: " << g << "\n";); @@ -1187,7 +1187,7 @@ namespace smt { bound * l = t.lower(v); bound * u = t.upper(v); c2 = rational(c); - if (l != 0) { + if (l != nullptr) { rational l_old = l->get_value().get_rational().to_rational(); rational l_new = g*ceil((l_old - c2)/g) + c2; TRACE("euclidean_solver_new", tout << "new lower: " << l_new << " old: " << l_old << "\n"; @@ -1197,7 +1197,7 @@ namespace smt { mk_lower(v, l_new, l, m_js); } } - if (u != 0) { + if (u != nullptr) { rational u_old = u->get_value().get_rational().to_rational(); rational u_new = g*floor((u_old - c2)/g) + c2; TRACE("euclidean_solver_new", tout << "new upper: " << u_new << " old: " << u_old << "\n";); @@ -1223,7 +1223,7 @@ namespace smt { continue; // skip equations... if (!t.is_int(v)) continue; // skip non integer definitions... - if (t.lower(v) == 0 && t.upper(v) == 0) + if (t.lower(v) == nullptr && t.upper(v) == nullptr) continue; // there is nothing to be tightned if (tight_bounds(v)) propagated = true; diff --git a/src/smt/theory_arith_nl.h b/src/smt/theory_arith_nl.h index 7eee008e9..ba6648dac 100644 --- a/src/smt/theory_arith_nl.h +++ b/src/smt/theory_arith_nl.h @@ -161,14 +161,14 @@ namespace smt { template std::pair theory_arith::analyze_monomial(expr * m) const { SASSERT(is_pure_monomial(m)); - expr * var = 0; + expr * var = nullptr; unsigned power = 0; unsigned c = 0; int free_var_idx = -1; int idx = 0; for (unsigned i = 0; i < to_app(m)->get_num_args(); i++) { expr * arg = to_app(m)->get_arg(i); - if (var == 0) { + if (var == nullptr) { var = arg; power = 1; } @@ -227,7 +227,7 @@ namespace smt { SASSERT(!m_util.is_numeral(m)); if (m_util.is_mul(m)) { unsigned num_vars = 0; - expr * var = 0; + expr * var = nullptr; for (unsigned i = 0; i < to_app(m)->get_num_args(); i++) { expr * curr = to_app(m)->get_arg(i); if (var != curr) { @@ -252,12 +252,12 @@ namespace smt { m = get_monomial_body(m); if (m_util.is_mul(m)) { unsigned curr_idx = 0; - expr * var = 0; + expr * var = nullptr; unsigned power = 0; unsigned j; for (j = 0; j < to_app(m)->get_num_args(); j++) { expr * arg = to_app(m)->get_arg(j); - if (var == 0) { + if (var == nullptr) { var = arg; power = 1; } @@ -471,7 +471,7 @@ namespace smt { } } bound * old_lower = lower(v); - if (old_lower == 0 || new_lower > old_lower->get_value()) { + if (old_lower == nullptr || new_lower > old_lower->get_value()) { TRACE("non_linear", tout << "NEW lower bound for v" << v << " " << new_lower << "\n"; display_interval(tout, i); tout << "\n";); mk_derived_nl_bound(v, new_lower, B_LOWER, i.get_lower_dependencies()); @@ -494,7 +494,7 @@ namespace smt { } } bound * old_upper = upper(v); - if (old_upper == 0 || new_upper < old_upper->get_value()) { + if (old_upper == nullptr || new_upper < old_upper->get_value()) { TRACE("non_linear", tout << "NEW upper bound for v" << v << " " << new_upper << "\n"; display_interval(tout, i); tout << "\n";); mk_derived_nl_bound(v, new_upper, B_UPPER, i.get_upper_dependencies()); @@ -788,7 +788,7 @@ namespace smt { TRACE("non_linear", tout << "BRANCHING on v" << v << "\n";); m_stats.m_nl_branching++; SASSERT(is_int(v)); - expr * bound = 0; + expr * bound = nullptr; if (lower(v)) bound = m_util.mk_le(var2expr(v), m_util.mk_numeral(lower_bound(v).get_rational().to_rational(), true)); else if (upper(v)) @@ -857,7 +857,7 @@ namespace smt { if (!is_fixed(_var)) return arg; } - return 0; + return nullptr; } /** @@ -882,12 +882,12 @@ namespace smt { numeral k = get_monomial_fixed_var_product(m); TRACE("non_linear", tout << "new linear monomial... k: " << k << "\n";); - expr * x_n = k.is_zero() ? 0 : get_monomial_non_fixed_var(m); + expr * x_n = k.is_zero() ? nullptr : get_monomial_non_fixed_var(m); TRACE("non_linear_bug", if (x_n != 0) { tout << "x_n: " << mk_bounded_pp(x_n, get_manager()) << "\nx_n: #" << x_n->get_id() << "\n"; }); context & ctx = get_context(); - derived_bound * new_lower = 0; - derived_bound * new_upper = 0; - if (x_n != 0) { + derived_bound * new_lower = nullptr; + derived_bound * new_upper = nullptr; + if (x_n != nullptr) { // All but one of the x_i variables are assigned. // Let x_n be the unassigned variable. // Then, we know that x_1*...*x_n = k*x_n, where k is the product of beta(x_1)*...*beta(x_{n-1}) @@ -1267,7 +1267,7 @@ namespace smt { expr * var = ce.second; if (!c.is_one()) { rational c2; - expr * m = 0; + expr * m = nullptr; if (m_util.is_numeral(var, c2)) m = m_util.mk_numeral(c*c2, m_util.is_int(var) && c.is_int() && c2.is_int()); else @@ -1492,7 +1492,7 @@ namespace smt { r.push_back(coeff_expr(kv.first, f)); } } - expr * s = cross_nested(e, 0); + expr * s = cross_nested(e, nullptr); if (!r.empty()) { expr * q = horner(r, var); // TODO: improve here @@ -1519,7 +1519,7 @@ namespace smt { template expr * theory_arith::cross_nested(sbuffer & p, expr * var) { TRACE("non_linear", tout << "p.size: " << p.size() << "\n";); - if (var == 0) { + if (var == nullptr) { sbuffer varinfo; get_polynomial_info(p, varinfo); if (varinfo.empty()) @@ -1556,7 +1556,7 @@ namespace smt { tout << "b: " << b << "\n"; tout << "nm: " << nm << "\n";); SASSERT(n != nm); - expr * new_expr = 0; + expr * new_expr = nullptr; if (nm < n) { std::swap(n, nm); std::swap(a, b); @@ -1576,7 +1576,7 @@ namespace smt { expr * xm_a2b = m_util.mk_add(m_util.mk_numeral(a2b, m_util.is_int(var)), xm); expr * xm_a2b2 = m_util.mk_mul(xm_a2b, xm_a2b); expr * rhs = m_util.mk_add(xm_a2b2, m_util.mk_numeral(ma2b2, m_util.is_int(var))); - expr * rhs2 = 0; + expr * rhs2 = nullptr; if (n > m) rhs2 = m_util.mk_mul(power(var, n - m), rhs); else @@ -1593,7 +1593,7 @@ namespace smt { if (rest.empty()) return new_expr; TRACE("non_linear", tout << "rest size: " << rest.size() << ", i1: " << i1 << ", i2: " << i2 << "\n";); - expr * h = cross_nested(rest, 0); + expr * h = cross_nested(rest, nullptr); expr * r = m_util.mk_add(new_expr, h); m_nl_new_exprs.push_back(r); return r; @@ -1631,7 +1631,7 @@ namespace smt { tout << "c:\n" << mk_ismt2_pp(cn, get_manager()) << "\n";); interval i = evaluate_as_interval(cn); TRACE("cross_nested", tout << "interval: " << i << "\n";); - v_dependency * d = 0; + v_dependency * d = nullptr; if (!i.minus_infinity() && (i.get_lower_value().is_pos() || (i.get_lower_value().is_zero() && i.is_lower_open()))) d = i.get_lower_dependencies(); else if (!i.plus_infinity() && (i.get_upper_value().is_neg() || (i.get_upper_value().is_zero() && i.is_upper_open()))) @@ -1823,7 +1823,7 @@ namespace smt { if (!coeff.is_zero()) return gb.mk_monomial(coeff, vars.size(), vars.c_ptr()); else - return 0; + return nullptr; } /** @@ -1834,7 +1834,7 @@ namespace smt { void theory_arith::add_row_to_gb(row const & r, grobner & gb) { TRACE("non_linear", tout << "adding row to gb\n"; display_row(tout, r);); ptr_buffer monomials; - v_dependency * dep = 0; + v_dependency * dep = nullptr; m_tmp_var_set.reset(); typename vector::const_iterator it = r.begin_entries(); typename vector::const_iterator end = r.end_entries(); @@ -1860,7 +1860,7 @@ namespace smt { template void theory_arith::add_monomial_def_to_gb(theory_var v, grobner & gb) { ptr_buffer monomials; - v_dependency * dep = 0; + v_dependency * dep = nullptr; m_tmp_var_set.reset(); expr * m = var2expr(v); SASSERT(is_pure_monomial(m)); @@ -1872,7 +1872,7 @@ namespace smt { dep = m_dep_manager.mk_join(dep, m_dep_manager.mk_join(m_dep_manager.mk_leaf(lower(v)), m_dep_manager.mk_leaf(upper(v)))); coeff *= lower_bound(v).get_rational().to_rational(); if (!coeff.is_zero()) - monomials.push_back(gb.mk_monomial(coeff, 0, 0)); + monomials.push_back(gb.mk_monomial(coeff, 0, nullptr)); } else { monomials.push_back(gb.mk_monomial(coeff, 1, &m)); @@ -1904,12 +1904,12 @@ namespace smt { template interval theory_arith::mk_interval_for(grobner::monomial const * m) { interval r(m_dep_manager, rational(m->get_coeff())); - expr * var = 0; + expr * var = nullptr; unsigned power = 0; unsigned num_vars = m->get_degree(); for (unsigned i = 0; i < num_vars; i++) { expr * curr = m->get_var(i); - if (var == 0) { + if (var == nullptr) { var = curr; power = 1; } @@ -1922,7 +1922,7 @@ namespace smt { power = 1; } } - if (var != 0) + if (var != nullptr) mul_bound_of(var, power, r); return r; } @@ -1957,7 +1957,7 @@ namespace smt { return false; } TRACE("non_linear_bug", tout << "is_inconsistent, r: " << r << "\n";); - v_dependency * interval_deps = 0; + v_dependency * interval_deps = nullptr; bool conflict = false; if (!r.minus_infinity() && (r.get_lower_value().is_pos() || (r.get_lower_value().is_zero() && r.is_lower_open()))) { interval_deps = r.get_lower_dependencies(); @@ -2002,11 +2002,11 @@ namespace smt { return false; if (!m->get_coeff().is_perfect_square(r)) return false; - expr * var = 0; + expr * var = nullptr; unsigned power = 0; for (unsigned i = 0; i < num_vars; i++) { expr * curr = m->get_var(i); - if (var == 0) { + if (var == nullptr) { var = curr; power = 1; } @@ -2050,18 +2050,18 @@ namespace smt { unsigned i1, i2, i12; i1 = i2 = i12 = 0; while (true) { - expr * v1 = 0; - expr * v2 = 0; - expr * v12 = 0; + expr * v1 = nullptr; + expr * v2 = nullptr; + expr * v12 = nullptr; if (i1 < num1) v1 = m1_sq->get_var(i1); if (i2 < num2) v2 = m2_sq->get_var(i2); if (i12 < num12) v12 = m1m2->get_var(i12); - if (v1 == 0 && v2 == 0 && v12 == 0) + if (v1 == nullptr && v2 == nullptr && v12 == nullptr) return true; - if (v12 == 0) + if (v12 == nullptr) return false; if (v1 == v12) { SASSERT(m1_sq->get_var(i1+1) == v1); @@ -2162,7 +2162,7 @@ namespace smt { } if (monomials.size() == num) return false; // didn't find any perfect square. - interval ge_zero(m_dep_manager, rational(0), false, true, 0); + interval ge_zero(m_dep_manager, rational(0), false, true, nullptr); if (is_inconsistent(ge_zero, monomials.size(), monomials.c_ptr(), eq->get_dependency())) { TRACE("non_linear", tout << "found conflict\n"; gb.display_equation(tout, *eq);); return true; diff --git a/src/smt/theory_arith_pp.h b/src/smt/theory_arith_pp.h index 997698411..a218445f5 100644 --- a/src/smt/theory_arith_pp.h +++ b/src/smt/theory_arith_pp.h @@ -504,7 +504,7 @@ namespace smt { pp.add_assumption(eq); } else { - if (lower(v) != 0) { + if (lower(v) != nullptr) { inf_numeral k_inf = lower_bound(v); rational k = k_inf.get_rational().to_rational(); expr_ref ineq(m); @@ -514,7 +514,7 @@ namespace smt { ineq = m_util.mk_lt(m_util.mk_numeral(k, is_int(v)), n); pp.add_assumption(ineq); } - if (upper(v) != 0) { + if (upper(v) != nullptr) { inf_numeral k_inf = upper_bound(v); rational k = k_inf.get_rational().to_rational(); expr_ref ineq(m); diff --git a/src/smt/theory_array_base.cpp b/src/smt/theory_array_base.cpp index 0aba7c2f2..a0e9fad2b 100644 --- a/src/smt/theory_array_base.cpp +++ b/src/smt/theory_array_base.cpp @@ -41,7 +41,7 @@ namespace smt { } app * theory_array_base::mk_select(unsigned num_args, expr * const * args) { - app * r = get_manager().mk_app(get_family_id(), OP_SELECT, 0, 0, num_args, args); + app * r = get_manager().mk_app(get_family_id(), OP_SELECT, 0, nullptr, num_args, args); TRACE("mk_var_bug", tout << "mk_select: " << r->get_id() << " num_args: " << num_args; for (unsigned i = 0; i < num_args; i++) tout << " " << args[i]->get_id(); tout << "\n";); @@ -49,7 +49,7 @@ namespace smt { } app * theory_array_base::mk_store(unsigned num_args, expr * const * args) { - return get_manager().mk_app(get_family_id(), OP_STORE, 0, 0, num_args, args); + return get_manager().mk_app(get_family_id(), OP_STORE, 0, nullptr, num_args, args); } app * theory_array_base::mk_default(expr * a) { @@ -152,7 +152,7 @@ namespace smt { expr_ref sel1(m), sel2(m); bool init = false; literal conseq = null_literal; - expr * conseq_expr = 0; + expr * conseq_expr = nullptr; for (unsigned i = 0; i < num_args; i++) { enode * idx1 = js[i]; @@ -212,7 +212,7 @@ namespace smt { func_decl_ref_vector * theory_array_base::register_sort(sort * s_array) { unsigned dimension = get_dimension(s_array); - func_decl_ref_vector * ext_skolems = 0; + func_decl_ref_vector * ext_skolems = nullptr; if (!m_sort2skolem.find(s_array, ext_skolems)) { array_util util(get_manager()); ast_manager & m = get_manager(); @@ -305,7 +305,7 @@ namespace smt { context & ctx = get_context(); ast_manager & m = get_manager(); - func_decl_ref_vector * funcs = 0; + func_decl_ref_vector * funcs = nullptr; sort * s = m.get_sort(e1); VERIFY(m_sort2skolem.find(s, funcs)); @@ -495,7 +495,7 @@ namespace smt { void theory_array_base::restore_sorts(unsigned old_size) { while (m_sorts_trail.size() > old_size) { sort * s = m_sorts_trail.back(); - func_decl_ref_vector * funcs = 0; + func_decl_ref_vector * funcs = nullptr; if (m_sort2skolem.find(s, funcs)) { m_sort2skolem.remove(s); dealloc(funcs); @@ -672,9 +672,9 @@ namespace smt { theory_array_base::select_set * theory_array_base::get_select_set(enode * n) { enode * r = n->get_root(); - select_set * set = 0; + select_set * set = nullptr; m_selects.find(r, set); - if (set == 0) { + if (set == nullptr) { set = alloc(select_set); m_selects.insert(r, set); m_selects_domain.push_back(r); @@ -795,7 +795,7 @@ namespace smt { m_sort(s), m_num_entries(0), m_dim(0), - m_else(0), + m_else(nullptr), m_unspecified_else(false) { m_dependencies.push_back(model_value_dependency(v)); } @@ -814,7 +814,7 @@ namespace smt { m_sort(s), m_num_entries(0), m_dim(0), - m_else(0), + m_else(nullptr), m_unspecified_else(false) { m_dependencies.push_back(model_value_dependency(else_value)); } @@ -824,7 +824,7 @@ namespace smt { m_sort(s), m_num_entries(0), m_dim(0), - m_else(0), + m_else(nullptr), m_unspecified_else(true) { } @@ -888,14 +888,14 @@ namespace smt { SASSERT(v != null_theory_var); sort * s = get_manager().get_sort(n->get_owner()); enode * else_val_n = get_default(v); - array_value_proc * result = 0; + array_value_proc * result = nullptr; if (m_use_unspecified_default) { SASSERT(else_val_n == 0); result = alloc(array_value_proc, get_id(), s); } else { - if (else_val_n != 0) { + if (else_val_n != nullptr) { SASSERT(get_context().is_relevant(else_val_n)); result = alloc(array_value_proc, get_id(), s, else_val_n); } @@ -905,7 +905,7 @@ namespace smt { // DISABLED. It seems wrong, since different nodes can share the same // else_val according to the mg class. // SASSERT(else_val == 0 || get_context().is_relevant(UNTAG(app*, else_val))); - if (else_val == 0) { + if (else_val == nullptr) { sort * range = to_sort(s->get_parameter(s->get_num_parameters() - 1).get_ast()); // IMPORTANT: // The implementation should not assume a fresh value is created for @@ -925,9 +925,9 @@ namespace smt { } } SASSERT(result != 0); - select_set * sel_set = 0; + select_set * sel_set = nullptr; m_selects.find(n->get_root(), sel_set); - if (sel_set != 0) { + if (sel_set != nullptr) { ptr_buffer args; select_set::iterator it = sel_set->begin(); select_set::iterator end = sel_set->end(); diff --git a/src/smt/theory_array_full.cpp b/src/smt/theory_array_full.cpp index 274f89e8b..048e3f581 100644 --- a/src/smt/theory_array_full.cpp +++ b/src/smt/theory_array_full.cpp @@ -746,7 +746,7 @@ namespace smt { } app* theory_array_full::mk_epsilon(sort* s) { - app* eps = 0; + app* eps = nullptr; if (m_sort2epsilon.find(s, eps)) { return eps; } diff --git a/src/smt/theory_bv.cpp b/src/smt/theory_bv.cpp index 0f5c235f3..873d1692d 100644 --- a/src/smt/theory_bv.cpp +++ b/src/smt/theory_bv.cpp @@ -373,7 +373,7 @@ namespace smt { void get_proof(conflict_resolution & cr, literal l, ptr_buffer & prs, bool & visited) { if (l.var() == true_bool_var) return; - proof * pr = 0; + proof * pr = nullptr; if (cr.get_context().get_assignment(l) == l_true) pr = cr.get_proof(l); else @@ -408,7 +408,7 @@ namespace smt { get_proof(cr, *it2, prs, visited); } if (!visited) - return 0; + return nullptr; expr * fact = ctx.mk_eq_atom(m_th.get_enode(m_var1)->get_owner(), m_th.get_enode(m_var2)->get_owner()); ast_manager & m = ctx.get_manager(); return m.mk_th_lemma(get_from_theory(), fact, prs.size(), prs.c_ptr()); @@ -1532,7 +1532,7 @@ namespace smt { visited = false; } if (!visited) - return 0; + return nullptr; context & ctx = cr.get_context(); ast_manager & m = cr.get_manager(); expr_ref fact(m); diff --git a/src/smt/theory_bv.h b/src/smt/theory_bv.h index ca3338cb7..f2e0f5bed 100644 --- a/src/smt/theory_bv.h +++ b/src/smt/theory_bv.h @@ -52,12 +52,12 @@ namespace smt { theory_var m_var; unsigned m_idx; var_pos_occ * m_next; - var_pos_occ(theory_var v = null_theory_var, unsigned idx = 0, var_pos_occ * next = 0):m_var(v), m_idx(idx), m_next(next) {} + var_pos_occ(theory_var v = null_theory_var, unsigned idx = 0, var_pos_occ * next = nullptr):m_var(v), m_idx(idx), m_next(next) {} }; struct bit_atom : public atom { var_pos_occ * m_occs; - bit_atom():m_occs(0) {} + bit_atom():m_occs(nullptr) {} ~bit_atom() override {} bool is_bit() const override { return true; } }; diff --git a/src/smt/theory_datatype.cpp b/src/smt/theory_datatype.cpp index f9422ee8a..695d479f4 100644 --- a/src/smt/theory_datatype.cpp +++ b/src/smt/theory_datatype.cpp @@ -30,7 +30,7 @@ namespace smt { class dt_eq_justification : public ext_theory_eq_propagation_justification { public: dt_eq_justification(family_id fid, region & r, literal antecedent, enode * lhs, enode * rhs): - ext_theory_eq_propagation_justification(fid, r, 1, &antecedent, 0, 0, lhs, rhs) { + ext_theory_eq_propagation_justification(fid, r, 1, &antecedent, 0, nullptr, lhs, rhs) { } // Remark: the assignment must be propagated back to the datatype theory. theory_id get_from_theory() const override { return null_theory_id; } @@ -340,12 +340,12 @@ namespace smt { func_decl * c = m_util.get_recognizer_constructor(r); if (is_true) { SASSERT(tv != null_theory_var); - if (d->m_constructor != 0 && d->m_constructor->get_decl() == c) + if (d->m_constructor != nullptr && d->m_constructor->get_decl() == c) return; // do nothing assert_is_constructor_axiom(arg, c, literal(v)); } else { - if (d->m_constructor != 0) { + if (d->m_constructor != nullptr) { if (d->m_constructor->get_decl() == c) { // conflict sign_recognizer_conflict(d->m_constructor, n); @@ -400,7 +400,7 @@ namespace smt { if (m_params.m_dt_lazy_splits > 0) { // using lazy case splits... var_data * d = m_var_data[v]; - if (d->m_constructor == 0) { + if (d->m_constructor == nullptr) { mk_split(v); r = FC_CONTINUE; } @@ -427,7 +427,7 @@ namespace smt { if (res) { context & ctx = get_context(); region & r = ctx.get_region(); - ctx.set_conflict(ctx.mk_justification(ext_theory_conflict_justification(get_id(), r, 0, 0, m_used_eqs.size(), m_used_eqs.c_ptr()))); + ctx.set_conflict(ctx.mk_justification(ext_theory_conflict_justification(get_id(), r, 0, nullptr, m_used_eqs.size(), m_used_eqs.c_ptr()))); TRACE("occurs_check", tout << "occurs_check: true\n"; for (enode_pair const& p : m_used_eqs) { @@ -581,21 +581,21 @@ namespace smt { SASSERT(v1 == static_cast(m_find.find(v1))); var_data * d1 = m_var_data[v1]; var_data * d2 = m_var_data[v2]; - if (d2->m_constructor != 0) { + if (d2->m_constructor != nullptr) { context & ctx = get_context(); - if (d1->m_constructor != 0 && d1->m_constructor->get_decl() != d2->m_constructor->get_decl()) { + if (d1->m_constructor != nullptr && d1->m_constructor->get_decl() != d2->m_constructor->get_decl()) { region & r = ctx.get_region(); enode_pair p(d1->m_constructor, d2->m_constructor); SASSERT(d1->m_constructor->get_root() == d2->m_constructor->get_root()); - ctx.set_conflict(ctx.mk_justification(ext_theory_conflict_justification(get_id(), r, 0, 0, 1, &p))); + ctx.set_conflict(ctx.mk_justification(ext_theory_conflict_justification(get_id(), r, 0, nullptr, 1, &p))); } - if (d1->m_constructor == 0) { + if (d1->m_constructor == nullptr) { m_trail_stack.push(set_ptr_trail(d1->m_constructor)); // check whether there is a recognizer in d1 that conflicts with d2->m_constructor; if (!d1->m_recognizers.empty()) { unsigned c_idx = m_util.get_constructor_idx(d2->m_constructor->get_decl()); enode * recognizer = d1->m_recognizers[c_idx]; - if (recognizer != 0 && ctx.get_assignment(recognizer) == l_false) { + if (recognizer != nullptr && ctx.get_assignment(recognizer) == l_false) { sign_recognizer_conflict(d2->m_constructor, recognizer); return; } @@ -634,7 +634,7 @@ namespace smt { // Otherwise, it will be set when assign_eh is invoked. return; } - if (val == l_false && d->m_constructor != 0) { + if (val == l_false && d->m_constructor != nullptr) { func_decl * c_decl = m_util.get_recognizer_constructor(recognizer->get_decl()); if (d->m_constructor->get_decl() == c_decl) { // conflict @@ -747,7 +747,7 @@ namespace smt { unsigned non_rec_idx = m_util.get_constructor_idx(non_rec_c); var_data * d = m_var_data[v]; SASSERT(d->m_constructor == 0); - func_decl * r = 0; + func_decl * r = nullptr; m_stats.m_splits++; if (d->m_recognizers.empty()) { @@ -755,7 +755,7 @@ namespace smt { } else { enode * recognizer = d->m_recognizers[non_rec_idx]; - if (recognizer == 0) { + if (recognizer == nullptr) { r = m_util.get_constructor_recognizer(non_rec_c); } else if (!ctx.is_relevant(recognizer)) { @@ -773,7 +773,7 @@ namespace smt { ptr_vector::const_iterator end = d->m_recognizers.end(); for (unsigned idx = 0; it != end; ++it, ++idx) { enode * curr = *it; - if (curr == 0) { + if (curr == nullptr) { ptr_vector const & constructors = *m_util.get_datatype_constructors(s); // found empty slot... r = m_util.get_constructor_recognizer(constructors[idx]); @@ -787,7 +787,7 @@ namespace smt { return; } } - if (r == 0) + if (r == nullptr) return; // all recognizers are asserted to false... conflict will be detected... } } diff --git a/src/smt/theory_datatype.h b/src/smt/theory_datatype.h index 3329c71cb..2337fd0ea 100644 --- a/src/smt/theory_datatype.h +++ b/src/smt/theory_datatype.h @@ -35,7 +35,7 @@ namespace smt { ptr_vector m_recognizers; //!< recognizers of this equivalence class that are being watched. enode * m_constructor; //!< constructor of this equivalence class, 0 if there is no constructor in the eqc. var_data(): - m_constructor(0) { + m_constructor(nullptr) { } }; diff --git a/src/smt/theory_dense_diff_logic_def.h b/src/smt/theory_dense_diff_logic_def.h index 78fb4d03d..86e1fd5e8 100644 --- a/src/smt/theory_dense_diff_logic_def.h +++ b/src/smt/theory_dense_diff_logic_def.h @@ -867,7 +867,7 @@ namespace smt { } else { context& ctx = get_context(); - enode * e = 0; + enode * e = nullptr; theory_var v = 0; if (ctx.e_internalized(n)) { e = ctx.get_enode(to_app(n)); diff --git a/src/smt/theory_diff_logic.h b/src/smt/theory_diff_logic.h index ce0814f10..6090b2f5f 100644 --- a/src/smt/theory_diff_logic.h +++ b/src/smt/theory_diff_logic.h @@ -234,7 +234,7 @@ namespace smt { m_agility(0.5), m_is_lia(true), m_non_diff_logic_exprs(false), - m_factory(0), + m_factory(nullptr), m_nc_functor(*this), m_S(m.limit()), m_num_simplex_edges(0) { @@ -297,7 +297,7 @@ namespace smt { justification * why_is_diseq(theory_var v1, theory_var v2) override { NOT_IMPLEMENTED_YET(); - return 0; + return nullptr; } // virtual void flush_eh(); diff --git a/src/smt/theory_diff_logic_def.h b/src/smt/theory_diff_logic_def.h index 59f5521c5..fc4ff25c7 100644 --- a/src/smt/theory_diff_logic_def.h +++ b/src/smt/theory_diff_logic_def.h @@ -298,7 +298,7 @@ void theory_diff_logic::internalize_eq_eh(app * atom, bool_var v) { template void theory_diff_logic::assign_eh(bool_var v, bool is_true) { m_stats.m_num_assertions++; - atom * a = 0; + atom * a = nullptr; VERIFY (m_bool_var2atom.find(v, a)); SASSERT(a); SASSERT(get_context().get_assignment(v) != l_undef); @@ -602,7 +602,7 @@ void theory_diff_logic::new_edge(dl_var src, dl_var dst, unsigned num_edges ctx.mark_as_relevant(le.get()); literal lit(ctx.get_literal(le)); bool_var bv = lit.var(); - atom* a = 0; + atom* a = nullptr; m_bool_var2atom.find(bv, a); SASSERT(a); @@ -619,7 +619,7 @@ void theory_diff_logic::new_edge(dl_var src, dl_var dst, unsigned num_edges tout << "\n"; ); - justification * js = 0; + justification * js = nullptr; if (get_manager().proofs_enabled()) { vector params; params.push_back(parameter(symbol("farkas"))); @@ -628,7 +628,7 @@ void theory_diff_logic::new_edge(dl_var src, dl_var dst, unsigned num_edges lits.size(), lits.c_ptr(), params.size(), params.c_ptr()); } - ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, 0); + ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, nullptr); if (dump_lemmas()) { symbol logic(m_is_lia ? "QF_LIA" : "QF_LRA"); ctx.display_lemma_as_smt_problem(lits.size(), lits.c_ptr(), false_literal, logic); @@ -692,7 +692,7 @@ void theory_diff_logic::set_neg_cycle_conflict() { ctx.mk_justification( ext_theory_conflict_justification( get_id(), ctx.get_region(), - lits.size(), lits.c_ptr(), 0, 0, params.size(), params.c_ptr()))); + lits.size(), lits.c_ptr(), 0, nullptr, params.size(), params.c_ptr()))); } @@ -774,7 +774,7 @@ theory_var theory_diff_logic::mk_term(app* n) { template theory_var theory_diff_logic::mk_num(app* n, rational const& r) { theory_var v = null_theory_var; - enode* e = 0; + enode* e = nullptr; context& ctx = get_context(); if (r.is_zero()) { v = get_zero(); @@ -813,7 +813,7 @@ theory_var theory_diff_logic::mk_var(enode* n) { template theory_var theory_diff_logic::mk_var(app* n) { context & ctx = get_context(); - enode* e = 0; + enode* e = nullptr; theory_var v = null_theory_var; if (ctx.e_internalized(n)) { e = ctx.get_enode(n); diff --git a/src/smt/theory_dl.cpp b/src/smt/theory_dl.cpp index 1e9df2973..285c03946 100644 --- a/src/smt/theory_dl.cpp +++ b/src/smt/theory_dl.cpp @@ -78,7 +78,7 @@ namespace smt { app * mk_value(smt::model_generator & mg, ptr_vector & ) override { smt::context& ctx = m_th.get_context(); - app* result = 0; + app* result = nullptr; expr* n = m_node->get_owner(); sort* s = m_th.m().get_sort(n); func_decl* r, *v; @@ -204,8 +204,8 @@ namespace smt { if(!m_reps.find(s, r) || !m_vals.find(s,v)) { SASSERT(!m_reps.contains(s)); sort* bv = b().mk_sort(64); - r = m().mk_func_decl(m_util.get_family_id(), datalog::OP_DL_REP, 0, 0, 1, &s, bv); - v = m().mk_func_decl(m_util.get_family_id(), datalog::OP_DL_ABS, 0, 0, 1, &bv, s); + r = m().mk_func_decl(m_util.get_family_id(), datalog::OP_DL_REP, 0, nullptr, 1, &s, bv); + v = m().mk_func_decl(m_util.get_family_id(), datalog::OP_DL_ABS, 0, nullptr, 1, &bv, s); m_reps.insert(s, r); m_vals.insert(s, v); add_trail(r); @@ -218,7 +218,7 @@ namespace smt { bool mk_rep(app* n) { context & ctx = get_context(); unsigned num_args = n->get_num_args(); - enode * e = 0; + enode * e = nullptr; for (unsigned i = 0; i < num_args; i++) { ctx.internalize(n->get_arg(i), false); } diff --git a/src/smt/theory_fpa.cpp b/src/smt/theory_fpa.cpp index 36ee5c15a..b7aaff68a 100644 --- a/src/smt/theory_fpa.cpp +++ b/src/smt/theory_fpa.cpp @@ -38,7 +38,7 @@ namespace smt { m_map.remove(key); m.dec_ref(key); m.dec_ref(val); - key = 0; + key = nullptr; } }; @@ -208,7 +208,7 @@ namespace smt { for (unsigned i = 0; i < values.size(); i++) tout << "value[" << i << "] = " << mk_ismt2_pp(values[i], m) << std::endl;); - app * result = 0; + app * result = nullptr; unsigned bv_sz; rational val(0); @@ -256,7 +256,7 @@ namespace smt { } func_decl_ref wrap_fd(m); - wrap_fd = m.mk_func_decl(get_family_id(), OP_FPA_BVWRAP, 0, 0, 1, &es, bv_srt); + wrap_fd = m.mk_func_decl(get_family_id(), OP_FPA_BVWRAP, 0, nullptr, 1, &es, bv_srt); res = m.mk_app(wrap_fd, e); } @@ -705,7 +705,7 @@ namespace smt { m_trail_stack.pop_scope(m_trail_stack.get_num_scopes()); if (m_factory) { dealloc(m_factory); - m_factory = 0; + m_factory = nullptr; } ast_manager & m = get_manager(); dec_ref_map_key_values(m, m_conversions); @@ -743,7 +743,7 @@ namespace smt { return alloc(expr_wrapper_proc, owner); } - model_value_proc * res = 0; + model_value_proc * res = nullptr; app_ref wrapped(m); wrapped = wrap(owner); diff --git a/src/smt/theory_lra.cpp b/src/smt/theory_lra.cpp index d369ddefa..f475a8279 100644 --- a/src/smt/theory_lra.cpp +++ b/src/smt/theory_lra.cpp @@ -658,12 +658,12 @@ namespace smt { m_internalize_head(0), m_delay_constraints(false), m_delayed_terms(m), - m_not_handled(0), + m_not_handled(nullptr), m_asserted_qhead(0), m_assume_eq_head(0), m_num_conflicts(0), m_model_eqs(DEFAULT_HASHTABLE_INITIAL_CAPACITY, var_value_hash(*this), var_value_eq(*this)), - m_solver(0), + m_solver(nullptr), m_resource_limit(*this) { } @@ -689,7 +689,7 @@ namespace smt { SASSERT(!ctx().b_internalized(atom)); bool_var bv = ctx().mk_bool_var(atom); ctx().set_var_theory(bv, get_id()); - expr* n1 = 0, *n2 = 0; + expr* n1 = nullptr, *n2 = nullptr; rational r; lra_lp::bound_kind k; theory_var v = null_theory_var; @@ -721,7 +721,7 @@ namespace smt { SASSERT(!ctx().b_internalized(atom)); bool_var bv = ctx().mk_bool_var(atom); ctx().set_var_theory(bv, get_id()); - expr* n1 = 0, *n2 = 0; + expr* n1 = nullptr, *n2 = nullptr; rational r; lra_lp::bound_kind k; theory_var v = null_theory_var; @@ -771,7 +771,7 @@ namespace smt { } void internalize_eq_eh(app * atom, bool_var) { - expr* lhs = 0, *rhs = 0; + expr* lhs = nullptr, *rhs = nullptr; VERIFY(m.is_eq(atom, lhs, rhs)); enode * n1 = get_enode(lhs); enode * n2 = get_enode(rhs); @@ -862,7 +862,7 @@ namespace smt { void relevant_eh(app* n) { TRACE("arith", tout << mk_pp(n, m) << "\n";); - expr* n1 = 0, *n2 = 0; + expr* n1 = nullptr, *n2 = nullptr; if (a.is_mod(n, n1, n2)) mk_idiv_mod_axioms(n1, n2); else if (a.is_rem(n, n1, n2)) @@ -898,7 +898,7 @@ namespace smt { // to_int (to_real x) = x // to_real(to_int(x)) <= x < to_real(to_int(x)) + 1 void mk_to_int_axiom(app* n) { - expr* x = 0, *y = 0; + expr* x = nullptr, *y = nullptr; VERIFY (a.is_to_int(n, x)); if (a.is_to_real(x, y)) { mk_axiom(th.mk_eq(y, n, false)); @@ -914,7 +914,7 @@ namespace smt { // is_int(x) <=> to_real(to_int(x)) = x void mk_is_int_axiom(app* n) { - expr* x = 0; + expr* x = nullptr; VERIFY(a.is_is_int(n, x)); literal eq = th.mk_eq(a.mk_to_real(a.mk_to_int(x)), x, false); literal is_int = ctx().get_literal(n); @@ -1180,7 +1180,7 @@ namespace smt { if (assume_eqs()) { return FC_CONTINUE; } - if (m_not_handled != 0) { + if (m_not_handled != nullptr) { return FC_GIVEUP; } return FC_DONE; @@ -1439,12 +1439,12 @@ namespace smt { m_core2.push_back(~m_core[i]); } m_core2.push_back(lit); - justification * js = 0; + justification * js = nullptr; if (proofs_enabled()) { js = alloc(theory_lemma_justification, get_id(), ctx(), m_core2.size(), m_core2.c_ptr(), m_params.size(), m_params.c_ptr()); } - ctx().mk_clause(m_core2.size(), m_core2.c_ptr(), js, CLS_AUX_LEMMA, 0); + ctx().mk_clause(m_core2.size(), m_core2.c_ptr(), js, CLS_AUX_LEMMA, nullptr); } else { ctx().assign( @@ -1499,7 +1499,7 @@ namespace smt { rational const& k1 = b.get_value(); lp_bounds & bounds = m_bounds[v]; - lra_lp::bound* end = 0; + lra_lp::bound* end = nullptr; lra_lp::bound* lo_inf = end, *lo_sup = end; lra_lp::bound* hi_inf = end, *hi_sup = end; @@ -1764,7 +1764,7 @@ namespace smt { bool find_glb = (is_true == (k == lra_lp::lower_t)); if (find_glb) { rational glb; - lra_lp::bound* lb = 0; + lra_lp::bound* lb = nullptr; for (unsigned i = 0; i < bounds.size(); ++i) { lra_lp::bound* b2 = bounds[i]; if (b2 == &b) continue; @@ -1780,7 +1780,7 @@ namespace smt { } else { rational lub; - lra_lp::bound* ub = 0; + lra_lp::bound* ub = nullptr; for (unsigned i = 0; i < bounds.size(); ++i) { lra_lp::bound* b2 = bounds[i]; if (b2 == &b) continue; @@ -2111,7 +2111,7 @@ namespace smt { justification* js = ctx().mk_justification( ext_theory_eq_propagation_justification( - get_id(), ctx().get_region(), m_core.size(), m_core.c_ptr(), m_eqs.size(), m_eqs.c_ptr(), x, y, 0, 0)); + get_id(), ctx().get_region(), m_core.size(), m_core.c_ptr(), m_eqs.size(), m_eqs.c_ptr(), x, y, 0, nullptr)); TRACE("arith", for (unsigned i = 0; i < m_core.size(); ++i) { @@ -2236,12 +2236,12 @@ namespace smt { } justification * why_is_diseq(theory_var v1, theory_var v2) { - return 0; + return nullptr; } void reset_eh() { m_arith_eq_adapter.reset_eh(); - m_solver = 0; + m_solver = nullptr; m_not_handled = nullptr; del_bounds(0); m_unassigned_bounds.reset(); diff --git a/src/smt/theory_pb.cpp b/src/smt/theory_pb.cpp index cc9b6b9b1..aca617daa 100644 --- a/src/smt/theory_pb.cpp +++ b/src/smt/theory_pb.cpp @@ -403,12 +403,12 @@ namespace smt { } m_stats.m_num_conflicts++; - justification* js = 0; + justification* js = nullptr; if (proofs_enabled()) { js = alloc(theory_lemma_justification, get_id(), ctx, lits.size(), lits.c_ptr()); } TRACE("pb", tout << lits << "\n";); - ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, 0); + ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, nullptr); return false; } @@ -697,7 +697,7 @@ namespace smt { void theory_pb::watch_literal(literal lit, ineq* c) { init_watch(lit.var()); ptr_vector* ineqs = m_var_infos[lit.var()].m_lit_watch[lit.sign()]; - if (ineqs == 0) { + if (ineqs == nullptr) { ineqs = alloc(ptr_vector); m_var_infos[lit.var()].m_lit_watch[lit.sign()] = ineqs; } @@ -707,7 +707,7 @@ namespace smt { void theory_pb::watch_var(bool_var v, ineq* c) { init_watch(v); ptr_vector* ineqs = m_var_infos[v].m_var_watch; - if (ineqs == 0) { + if (ineqs == nullptr) { ineqs = alloc(ptr_vector); m_var_infos[v].m_var_watch = ineqs; } @@ -770,12 +770,12 @@ namespace smt { } void theory_pb::assign_eh(bool_var v, bool is_true) { - ptr_vector* ineqs = 0; + ptr_vector* ineqs = nullptr; literal nlit(v, is_true); init_watch(v); TRACE("pb", tout << "assign: " << ~nlit << "\n";); ineqs = m_var_infos[v].m_lit_watch[nlit.sign()]; - if (ineqs != 0) { + if (ineqs != nullptr) { if (m_enable_simplex) { mpq_inf num(mpq(is_true?1:0),mpq(0)); if (!update_bound(v, ~nlit, is_true, num)) { @@ -796,14 +796,14 @@ namespace smt { } } ineqs = m_var_infos[v].m_var_watch; - if (ineqs != 0) { + if (ineqs != nullptr) { for (unsigned i = 0; i < ineqs->size(); ++i) { ineq* c = (*ineqs)[i]; assign_watch(v, is_true, *c); } } ineq* c = m_var_infos[v].m_ineq; - if (c != 0) { + if (c != nullptr) { if (m_enable_simplex) { row_info const& info = m_ineq_row_info.find(v); unsynch_mpq_manager mgr; @@ -1197,7 +1197,7 @@ namespace smt { void mk_clause(unsigned n, literal const* ls) { literal_vector tmp(n, ls); - ctx.mk_clause(n, tmp.c_ptr(), th.justify(tmp), CLS_AUX, 0); + ctx.mk_clause(n, tmp.c_ptr(), th.justify(tmp), CLS_AUX, nullptr); } literal mk_false() { return false_literal; } @@ -1319,7 +1319,7 @@ namespace smt { bool_var v = m_ineqs_trail.back(); ineq* c = m_var_infos[v].m_ineq; clear_watch(*c); - m_var_infos[v].m_ineq = 0; + m_var_infos[v].m_ineq = nullptr; m_ineqs_trail.pop_back(); if (m_enable_simplex) { row_info r_info; @@ -1449,7 +1449,7 @@ namespace smt { tout << "\n"; display(tout, c, true);); - justification* js = 0; + justification* js = nullptr; if (m_conflict_frequency == 0 || (m_conflict_frequency -1 == (c.m_num_propagations % m_conflict_frequency))) { resolve_conflict(c); @@ -1458,7 +1458,7 @@ namespace smt { js = alloc(theory_lemma_justification, get_id(), ctx, lits.size(), lits.c_ptr()); } TRACE("pb", tout << lits << "\n";); - ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, 0); + ctx.mk_clause(lits.size(), lits.c_ptr(), js, CLS_AUX_LEMMA, nullptr); } @@ -1702,18 +1702,18 @@ namespace smt { break; case b_justification::JUSTIFICATION: { justification* j = js.get_justification(); - pb_justification* pbj = 0; + pb_justification* pbj = nullptr; if (!conseq.sign() && j->get_from_theory() == get_id()) { pbj = dynamic_cast(j); } if (pbj && pbj->get_ineq().is_eq()) { // only resolve >= that are positive consequences. - pbj = 0; + pbj = nullptr; } if (pbj && pbj->get_ineq().lit() == conseq) { // can't resolve against literal representing inequality. - pbj = 0; + pbj = nullptr; } if (pbj) { // weaken the lemma and resolve. @@ -1765,7 +1765,7 @@ namespace smt { m_ineq_literals[i].neg(); } TRACE("pb", tout << m_ineq_literals << "\n";); - ctx.mk_clause(m_ineq_literals.size(), m_ineq_literals.c_ptr(), justify(m_ineq_literals), CLS_AUX_LEMMA, 0); + ctx.mk_clause(m_ineq_literals.size(), m_ineq_literals.c_ptr(), justify(m_ineq_literals), CLS_AUX_LEMMA, nullptr); break; default: { app_ref tmp = m_lemma.to_expr(false, ctx, get_manager()); @@ -1785,7 +1785,7 @@ namespace smt { justification* theory_pb::justify(literal l1, literal l2) { literal lits[2] = { l1, l2 }; - justification* js = 0; + justification* js = nullptr; if (proofs_enabled()) { js = get_context().mk_justification(theory_axiom_justification(get_id(), get_context().get_region(), 2, lits)); } @@ -1793,7 +1793,7 @@ namespace smt { } justification* theory_pb::justify(literal_vector const& lits) { - justification* js = 0; + justification* js = nullptr; if (proofs_enabled()) { js = get_context().mk_justification(theory_axiom_justification(get_id(), get_context().get_region(), lits.size(), lits.c_ptr())); } @@ -2038,9 +2038,9 @@ namespace smt { return (sum >= k)?m.mk_true():m.mk_false(); default: UNREACHABLE(); - return 0; + return nullptr; } - return 0; + return nullptr; } }; @@ -2058,7 +2058,7 @@ namespace smt { return true; } expr * get_fresh_value(sort * s) override { - return 0; + return nullptr; } void register_value(expr * n) override { } }; diff --git a/src/smt/theory_pb.h b/src/smt/theory_pb.h index 5eb6e3312..07c763469 100644 --- a/src/smt/theory_pb.h +++ b/src/smt/theory_pb.h @@ -198,10 +198,10 @@ namespace smt { watch_list* m_var_watch; ineq* m_ineq; - var_info(): m_var_watch(0), m_ineq(0) + var_info(): m_var_watch(nullptr), m_ineq(nullptr) { - m_lit_watch[0] = 0; - m_lit_watch[1] = 0; + m_lit_watch[0] = nullptr; + m_lit_watch[1] = nullptr; } void reset() { diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 6fabbf865..e92a25159 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -87,7 +87,7 @@ bool theory_seq::solution_map::is_root(expr* e) const { // e1 -> ... x, e2 -> ... x void theory_seq::solution_map::find_rec(expr* e, svector >& finds) { - dependency* d = 0; + dependency* d = nullptr; std::pair value(e, d); do { e = value.first; @@ -111,7 +111,7 @@ bool theory_seq::solution_map::find1(expr* e, expr*& r, dependency*& d) { expr* theory_seq::solution_map::find(expr* e, dependency*& d) { std::pair value; - d = 0; + d = nullptr; expr* result = e; while (m_map.find(result, value)) { d = m_dm.mk_join(d, value.second); @@ -199,12 +199,12 @@ theory_seq::theory_seq(ast_manager& m): m_reset_cache(false), m_eq_id(0), m_find(*this), - m_factory(0), + m_factory(nullptr), m_exclude(m), m_axioms(m), m_axioms_head(0), m_int_string(m), - m_mg(0), + m_mg(nullptr), m_rewrite(m), m_seq_rewrite(m), m_util(m), @@ -381,7 +381,7 @@ bool theory_seq::branch_binary_variable(eq const& e) { // |x| - |y| = |ys| - |xs| expr_ref a(mk_sub(m_util.str.mk_length(x), m_util.str.mk_length(y)), m); expr_ref b(m_autil.mk_int(ys.size()-xs.size()), m); - propagate_lit(e.dep(), 0, 0, mk_eq(a, b, false)); + propagate_lit(e.dep(), 0, nullptr, mk_eq(a, b, false)); return true; } if (lenX <= rational(ys.size())) { @@ -456,7 +456,7 @@ void theory_seq::branch_unit_variable(dependency* dep, expr* X, expr_ref_vector if (lenX > rational(units.size())) { expr_ref le(m_autil.mk_le(m_util.str.mk_length(X), m_autil.mk_int(units.size())), m); TRACE("seq", tout << "propagate length on " << mk_pp(X, m) << "\n";); - propagate_lit(dep, 0, 0, mk_literal(le)); + propagate_lit(dep, 0, nullptr, mk_literal(le)); return; } SASSERT(lenX.is_unsigned()); @@ -1003,7 +1003,7 @@ bool theory_seq::fixed_length(expr* e) { */ void theory_seq::propagate_non_empty(literal lit, expr* s) { SASSERT(get_context().get_assignment(lit) == l_true); - propagate_lit(0, 1, &lit, ~mk_eq_empty(s)); + propagate_lit(nullptr, 1, &lit, ~mk_eq_empty(s)); } bool theory_seq::propagate_is_conc(expr* e, expr* conc) { @@ -1011,7 +1011,7 @@ bool theory_seq::propagate_is_conc(expr* e, expr* conc) { context& ctx = get_context(); literal lit = ~mk_eq_empty(e); if (ctx.get_assignment(lit) == l_true) { - propagate_lit(0, 1, &lit, mk_eq(e, conc, false)); + propagate_lit(nullptr, 1, &lit, mk_eq(e, conc, false)); expr_ref e1(e, m), e2(conc, m); new_eq_eh(m_dm.mk_leaf(assumption(lit)), ctx.get_enode(e1), ctx.get_enode(e2)); return true; @@ -1060,9 +1060,9 @@ bool theory_seq::is_post(expr* e, expr*& s, expr*& i) { expr_ref theory_seq::mk_nth(expr* s, expr* idx) { - sort* char_sort = 0; + sort* char_sort = nullptr; VERIFY(m_util.is_seq(m.get_sort(s), char_sort)); - return mk_skolem(m_nth, s, idx, 0, char_sort); + return mk_skolem(m_nth, s, idx, nullptr, char_sort); } expr_ref theory_seq::mk_sk_ite(expr* c, expr* t, expr* e) { @@ -1074,9 +1074,9 @@ expr_ref theory_seq::mk_last(expr* s) { if (m_util.str.is_string(s, str) && str.length() > 0) { return expr_ref(m_util.str.mk_char(str, str.length()-1), m); } - sort* char_sort = 0; + sort* char_sort = nullptr; VERIFY(m_util.is_seq(m.get_sort(s), char_sort)); - return mk_skolem(m_seq_last, s, 0, 0, char_sort); + return mk_skolem(m_seq_last, s, nullptr, nullptr, char_sort); } expr_ref theory_seq::mk_first(expr* s) { @@ -1089,7 +1089,7 @@ expr_ref theory_seq::mk_first(expr* s) { void theory_seq::mk_decompose(expr* e, expr_ref& head, expr_ref& tail) { - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; zstring s; if (m_util.str.is_empty(e)) { head = m_util.str.mk_unit(mk_nth(e, m_autil.mk_int(0))); @@ -1136,7 +1136,7 @@ bool theory_seq::check_extensionality() { continue; } if (!seqs.empty() && ctx.is_relevant(n1) && m_util.is_seq(o1) && ctx.is_shared(n1)) { - dependency* dep = 0; + dependency* dep = nullptr; expr_ref e1 = canonize(o1, dep); for (unsigned i = 0; i < seqs.size(); ++i) { enode* n2 = get_enode(seqs[i]); @@ -1237,7 +1237,7 @@ bool theory_seq::linearize(dependency* dep, enode_pair_vector& eqs, literal_vect lits.push_back(a.lit); asserted &= ctx.get_assignment(a.lit) == l_true; } - if (a.n1 != 0) { + if (a.n1 != nullptr) { eqs.push_back(enode_pair(a.n1, a.n2)); } } @@ -1286,7 +1286,7 @@ void theory_seq::set_conflict(dependency* dep, literal_vector const& _lits) { ctx.set_conflict( ctx.mk_justification( ext_theory_conflict_justification( - get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), 0, 0))); + get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), 0, nullptr))); } void theory_seq::propagate_eq(dependency* dep, enode* n1, enode* n2) { @@ -1438,7 +1438,7 @@ bool theory_seq::occurs(expr* a, expr* b) { // true if a occurs under an interpreted function or under left/right selector. SASSERT(is_var(a)); SASSERT(m_todo.empty()); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; m_todo.push_back(b); while (!m_todo.empty()) { b = m_todo.back(); @@ -1508,7 +1508,7 @@ bool theory_seq::solve_eq(expr_ref_vector const& l, expr_ref_vector const& r, de expr_ref_vector& ls = m_ls; expr_ref_vector& rs = m_rs; rs.reset(); ls.reset(); - dependency* dep2 = 0; + dependency* dep2 = nullptr; bool change = canonize(l, ls, dep2); change = canonize(r, rs, dep2) || change; deps = m_dm.mk_join(dep2, deps); @@ -1545,7 +1545,7 @@ bool theory_seq::propagate_max_length(expr* l, expr* r, dependency* deps) { } rational hi; if (is_tail(l, s, idx) && has_length(s) && m_util.str.is_empty(r) && !upper_bound(s, hi)) { - propagate_lit(deps, 0, 0, mk_literal(m_autil.mk_le(m_util.str.mk_length(s), m_autil.mk_int(idx+1)))); + propagate_lit(deps, 0, nullptr, mk_literal(m_autil.mk_le(m_util.str.mk_length(s), m_autil.mk_int(idx+1)))); return true; } return false; @@ -1737,7 +1737,7 @@ bool theory_seq::solve_binary_eq(expr_ref_vector const& ls, expr_ref_vector cons } ctx.mark_as_relevant(eq); if (sz == 1) { - propagate_lit(dep, 0, 0, eq); + propagate_lit(dep, 0, nullptr, eq); return true; } m_new_propagation = true; @@ -1885,7 +1885,7 @@ bool theory_seq::solve_ne(unsigned idx) { expr_ref_vector& lhs = m_lhs; expr_ref_vector& rhs = m_rhs; ls.reset(); rs.reset(); lhs.reset(); rhs.reset(); - dependency* deps = 0; + dependency* deps = nullptr; bool change = false; change = canonize(n.ls(i), ls, deps) || change; change = canonize(n.rs(i), rs, deps) || change; @@ -1991,7 +1991,7 @@ bool theory_seq::solve_ne(unsigned idx) { if (num_undef_lits == 0 && new_ls.empty()) { TRACE("seq", tout << "conflict\n";); - dependency* deps1 = 0; + dependency* deps1 = nullptr; if (explain_eq(n.l(), n.r(), deps1)) { literal diseq = mk_eq(n.l(), n.r(), false); if (ctx.get_assignment(diseq) == l_false) { @@ -2034,10 +2034,10 @@ bool theory_seq::solve_nc(unsigned idx) { return true; } - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; if (m.is_eq(c, e1, e2)) { literal eq = mk_eq(e1, e2, false); - propagate_lit(deps, 0, 0, ~eq); + propagate_lit(deps, 0, nullptr, ~eq); return true; } @@ -2059,7 +2059,7 @@ theory_seq::cell* theory_seq::mk_cell(cell* p, expr* e, dependency* d) { } void theory_seq::unfold(cell* c, ptr_vector& cons) { - dependency* dep = 0; + dependency* dep = nullptr; expr* a, *e1, *e2; if (m_rep.find1(c->m_expr, a, dep)) { cell* c1 = mk_cell(c, a, m_dm.mk_join(dep, c->m_dep)); @@ -2067,7 +2067,7 @@ void theory_seq::unfold(cell* c, ptr_vector& cons) { } else if (m_util.str.is_concat(c->m_expr, e1, e2)) { cell* c1 = mk_cell(c, e1, c->m_dep); - cell* c2 = mk_cell(0, e2, 0); + cell* c2 = mk_cell(nullptr, e2, nullptr); unfold(c1, cons); unfold(c2, cons); } @@ -2085,7 +2085,7 @@ void theory_seq::unfold(cell* c, ptr_vector& cons) { void theory_seq::display_explain(std::ostream& out, unsigned indent, expr* e) { expr* e1, *e2, *a; - dependency* dep = 0; + dependency* dep = nullptr; smt2_pp_environment_dbg env(m); params_ref p; for (unsigned i = 0; i < indent; ++i) out << " "; @@ -2109,8 +2109,8 @@ bool theory_seq::explain_eq(expr* e1, expr* e2, dependency*& dep) { expr* a1, *a2; ptr_vector v1, v2; unsigned cells_sz = m_all_cells.size(); - cell* c1 = mk_cell(0, e1, 0); - cell* c2 = mk_cell(0, e2, 0); + cell* c1 = mk_cell(nullptr, e1, nullptr); + cell* c2 = mk_cell(nullptr, e2, nullptr); unfold(c1, v1); unfold(c2, v2); unsigned i = 0, j = 0; @@ -2300,7 +2300,7 @@ bool theory_seq::internalize_term(app* term) { ctx.mark_as_relevant(bv); } - enode* e = 0; + enode* e = nullptr; if (ctx.e_internalized(term)) { e = ctx.get_enode(term); } @@ -2358,7 +2358,7 @@ bool theory_seq::check_int_string() { bool theory_seq::add_stoi_axiom(expr* e) { context& ctx = get_context(); - expr* n = 0; + expr* n = nullptr; rational val; TRACE("seq", tout << mk_pp(e, m) << "\n";); VERIFY(m_util.str.is_stoi(e, n)); @@ -2426,7 +2426,7 @@ bool theory_seq::add_stoi_axiom(expr* e) { literal theory_seq::is_digit(expr* ch) { bv_util bv(m); - literal isd = mk_literal(mk_skolem(symbol("seq.is_digit"), ch, 0, 0, m.mk_bool_sort())); + literal isd = mk_literal(mk_skolem(symbol("seq.is_digit"), ch, nullptr, nullptr, m.mk_bool_sort())); expr_ref d2i = digit2int(ch); expr_ref _lo(bv.mk_ule(bv.mk_numeral(rational('0'), bv.mk_sort(8)), ch), m); expr_ref _hi(bv.mk_ule(ch, bv.mk_numeral(rational('9'), bv.mk_sort(8))), m); @@ -2442,13 +2442,13 @@ literal theory_seq::is_digit(expr* ch) { } expr_ref theory_seq::digit2int(expr* ch) { - return expr_ref(mk_skolem(symbol("seq.digit2int"), ch, 0, 0, m_autil.mk_int()), m); + return expr_ref(mk_skolem(symbol("seq.digit2int"), ch, nullptr, nullptr, m_autil.mk_int()), m); } bool theory_seq::add_itos_axiom(expr* e) { context& ctx = get_context(); rational val; - expr* n = 0; + expr* n = nullptr; TRACE("seq", tout << mk_pp(e, m) << "\n";); VERIFY(m_util.str.is_itos(e, n)); if (get_num_value(n, val)) { @@ -2656,7 +2656,7 @@ void theory_seq::init_search_eh() { void theory_seq::init_model(expr_ref_vector const& es) { expr_ref new_s(m); for (expr* e : es) { - dependency* eqs = 0; + dependency* eqs = nullptr; expr_ref s = canonize(e, eqs); if (is_var(s)) { new_s = m_factory->get_fresh_value(m.get_sort(s)); @@ -2734,7 +2734,7 @@ public: break; } case string_source: { - dependency* deps = 0; + dependency* deps = nullptr; expr_ref tmp = th.canonize(m_strings[k], deps); zstring zs; if (th.m_util.str.is_string(tmp, zs)) { @@ -2848,7 +2848,7 @@ app* theory_seq::mk_value(app* e) { } m_factory->add_trail(result); TRACE("seq", tout << mk_pp(e, m) << " -> " << result << "\n";); - m_rep.update(e, result, 0); + m_rep.update(e, result, nullptr); return to_app(result); } @@ -2944,7 +2944,7 @@ expr_ref theory_seq::expand1(expr* e0, dependency*& eqs) { expr_ref result(m); result = try_expand(e0, eqs); if (result) return result; - dependency* deps = 0; + dependency* deps = nullptr; expr* e = m_rep.find(e0, deps); expr* e1, *e2, *e3; expr_ref arg1(m), arg2(m); @@ -3074,7 +3074,7 @@ expr_ref theory_seq::expand1(expr* e0, dependency*& eqs) { result = e; } if (result == e0) { - deps = 0; + deps = nullptr; } expr_dep edr(result, deps); m_rep.add_cache(e0, edr); @@ -3204,7 +3204,7 @@ void theory_seq::tightest_prefix(expr* s, expr* x) { (len(s) <= len(t) -> i <= len(t)-len(s)) */ void theory_seq::add_indexof_axiom(expr* i) { - expr* s = 0, *t = 0, *offset = 0; + expr* s = nullptr, *t = nullptr, *offset = nullptr; rational r; VERIFY(m_util.str.is_index(i, t, s) || m_util.str.is_index(i, t, s, offset)); @@ -3289,7 +3289,7 @@ void theory_seq::add_indexof_axiom(expr* i) { */ void theory_seq::add_replace_axiom(expr* r) { context& ctx = get_context(); - expr* a = 0, *s = 0, *t = 0; + expr* a = nullptr, *s = nullptr, *t = nullptr; VERIFY(m_util.str.is_replace(r, a, s, t)); expr_ref x = mk_skolem(m_indexof_left, a, s); expr_ref y = mk_skolem(m_indexof_right, a, s); @@ -3319,7 +3319,7 @@ void theory_seq::add_elim_string_axiom(expr* n) { result = mk_concat(m_util.str.mk_unit(m_util.str.mk_char(s, i)), result); } add_axiom(mk_eq(n, result, false)); - m_rep.update(n, result, 0); + m_rep.update(n, result, nullptr); m_new_solution = true; } @@ -3335,7 +3335,7 @@ void theory_seq::add_elim_string_axiom(expr* n) { */ void theory_seq::add_length_axiom(expr* n) { context& ctx = get_context(); - expr* x = 0; + expr* x = nullptr; VERIFY(m_util.str.is_length(n, x)); if (m_util.str.is_concat(x) || m_util.str.is_unit(x) || @@ -3358,7 +3358,7 @@ void theory_seq::add_length_axiom(expr* n) { } void theory_seq::add_itos_length_axiom(expr* len) { - expr* x = 0, *n = 0; + expr* x = nullptr, *n = nullptr; VERIFY(m_util.str.is_length(len, x)); VERIFY(m_util.str.is_itos(x, n)); @@ -3423,7 +3423,7 @@ void theory_seq::add_itos_length_axiom(expr* len) { void theory_seq::propagate_in_re(expr* n, bool is_true) { TRACE("seq", tout << mk_pp(n, m) << " <- " << (is_true?"true":"false") << "\n";); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; VERIFY(m_util.str.is_in_re(n, e1, e2)); expr_ref tmp(n, m); @@ -3432,7 +3432,7 @@ void theory_seq::propagate_in_re(expr* n, bool is_true) { if (!is_true) { literal_vector lits; lits.push_back(mk_literal(n)); - set_conflict(0, lits); + set_conflict(nullptr, lits); } return; } @@ -3440,7 +3440,7 @@ void theory_seq::propagate_in_re(expr* n, bool is_true) { if (is_true) { literal_vector lits; lits.push_back(~mk_literal(n)); - set_conflict(0, lits); + set_conflict(nullptr, lits); } return; } @@ -3474,7 +3474,7 @@ void theory_seq::propagate_in_re(expr* n, bool is_true) { lits.push_back(mk_accept(e1, zero, e3, states[i])); } if (lits.size() == 2) { - propagate_lit(0, 1, &lit, lits[1]); + propagate_lit(nullptr, 1, &lit, lits[1]); } else { TRACE("seq", ctx.display_literals_verbose(tout, lits); tout << "\n";); @@ -3506,7 +3506,7 @@ static T* get_th_arith(context& ctx, theory_id afid, expr* e) { return dynamic_cast(th); } else { - return 0; + return nullptr; } } @@ -3566,7 +3566,7 @@ bool theory_seq::get_length(expr* e, rational& val) const { context& ctx = get_context(); rational val1; expr_ref len(m), len_val(m); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; ptr_vector todo; todo.push_back(e); val.reset(); @@ -3638,7 +3638,7 @@ this translates to: void theory_seq::add_extract_axiom(expr* e) { TRACE("seq", tout << mk_pp(e, m) << "\n";); - expr* s = 0, *i = 0, *l = 0; + expr* s = nullptr, *i = nullptr, *l = nullptr; VERIFY(m_util.str.is_extract(e, s, i, l)); if (is_tail(s, i, l)) { add_tail_axiom(e, s); @@ -3769,7 +3769,7 @@ void theory_seq::add_extract_suffix_axiom(expr* e, expr* s, expr* i) { */ void theory_seq::add_at_axiom(expr* e) { - expr* s = 0, *i = 0; + expr* s = nullptr, *i = nullptr; VERIFY(m_util.str.is_at(e, s, i)); expr_ref len_e(m_util.str.mk_length(e), m); expr_ref len_s(m_util.str.mk_length(s), m); @@ -3798,17 +3798,17 @@ void theory_seq::add_at_axiom(expr* e) { */ void theory_seq::propagate_step(literal lit, expr* step) { SASSERT(get_context().get_assignment(lit) == l_true); - expr* re = 0, *acc = 0, *s = 0, *idx = 0, *i = 0, *j = 0; + expr* re = nullptr, *acc = nullptr, *s = nullptr, *idx = nullptr, *i = nullptr, *j = nullptr; VERIFY(is_step(step, s, idx, re, i, j, acc)); TRACE("seq", tout << mk_pp(step, m) << " -> " << mk_pp(acc, m) << "\n";); - propagate_lit(0, 1, &lit, mk_simplified_literal(acc)); + propagate_lit(nullptr, 1, &lit, mk_simplified_literal(acc)); rational lo; rational _idx; if (lower_bound(s, lo) && lo.is_unsigned() && m_autil.is_numeral(idx, _idx) && lo >= _idx) { // skip } else { - propagate_lit(0, 1, &lit, ~mk_literal(m_autil.mk_le(m_util.str.mk_length(s), idx))); + propagate_lit(nullptr, 1, &lit, ~mk_literal(m_autil.mk_le(m_util.str.mk_length(s), idx))); } ensure_nth(lit, s, idx); } @@ -3854,7 +3854,7 @@ literal theory_seq::mk_literal(expr* _e) { literal theory_seq::mk_seq_eq(expr* a, expr* b) { SASSERT(m_util.is_seq(a)); - return mk_literal(mk_skolem(m_eq, a, b, 0, m.mk_bool_sort())); + return mk_literal(mk_skolem(m_eq, a, b, nullptr, m.mk_bool_sort())); } literal theory_seq::mk_eq_empty(expr* _e, bool phase) { @@ -3927,7 +3927,7 @@ theory_seq::dependency* theory_seq::mk_join(dependency* deps, literal_vector con void theory_seq::propagate_eq(literal lit, expr* e1, expr* e2, bool add_to_eqs) { literal_vector lits; lits.push_back(lit); - propagate_eq(0, lits, e1, e2, add_to_eqs); + propagate_eq(nullptr, lits, e1, e2, add_to_eqs); } void theory_seq::propagate_eq(dependency* deps, literal_vector const& _lits, expr* e1, expr* e2, bool add_to_eqs) { @@ -3966,7 +3966,7 @@ void theory_seq::propagate_eq(dependency* deps, literal_vector const& _lits, exp void theory_seq::assign_eh(bool_var v, bool is_true) { context & ctx = get_context(); expr* e = ctx.bool_var2expr(v); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; expr_ref f(m); bool change = false; literal lit(v, !is_true); @@ -4231,7 +4231,7 @@ void theory_seq::relevant_eh(app* n) { eautomaton* theory_seq::get_automaton(expr* re) { - eautomaton* result = 0; + eautomaton* result = nullptr; if (m_re2aut.find(re, result)) { return result; } @@ -4312,9 +4312,9 @@ expr_ref theory_seq::mk_step(expr* s, expr* idx, expr* re, unsigned i, unsigned rej(s, idx, re, i) -> len(s) > idx if i is final */ void theory_seq::propagate_acc_rej_length(literal lit, expr* e) { - expr *s = 0, *idx = 0, *re = 0; + expr *s = nullptr, *idx = nullptr, *re = nullptr; unsigned src; - eautomaton* aut = 0; + eautomaton* aut = nullptr; bool is_acc; is_acc = is_accept(e, s, idx, re, src, aut); if (!is_acc) { @@ -4324,15 +4324,15 @@ void theory_seq::propagate_acc_rej_length(literal lit, expr* e) { SASSERT(m_autil.is_numeral(idx)); SASSERT(get_context().get_assignment(lit) == l_true); if (aut->is_sink_state(src)) { - propagate_lit(0, 1, &lit, false_literal); + propagate_lit(nullptr, 1, &lit, false_literal); return; } bool is_final = aut->is_final_state(src); if (is_final == is_acc) { - propagate_lit(0, 1, &lit, mk_literal(m_autil.mk_ge(m_util.str.mk_length(s), idx))); + propagate_lit(nullptr, 1, &lit, mk_literal(m_autil.mk_ge(m_util.str.mk_length(s), idx))); } else { - propagate_lit(0, 1, &lit, ~mk_literal(m_autil.mk_le(m_util.str.mk_length(s), idx))); + propagate_lit(nullptr, 1, &lit, ~mk_literal(m_autil.mk_le(m_util.str.mk_length(s), idx))); } } @@ -4345,10 +4345,10 @@ bool theory_seq::add_accept2step(expr* acc, bool& change) { TRACE("seq", tout << mk_pp(acc, m) << "\n";); SASSERT(ctx.get_assignment(acc) == l_true); - expr *e = 0, *idx = 0, *re = 0; + expr *e = nullptr, *idx = nullptr, *re = nullptr; expr_ref step(m); unsigned src; - eautomaton* aut = 0; + eautomaton* aut = nullptr; VERIFY(is_accept(acc, e, idx, re, src, aut)); if (!aut || m_util.str.is_length(idx)) { return false; @@ -4401,7 +4401,7 @@ bool theory_seq::add_accept2step(expr* acc, bool& change) { for (unsigned i = 0; i < lits.size(); ++i) { lits[i].neg(); } - propagate_lit(0, lits.size(), lits.c_ptr(), lit); + propagate_lit(nullptr, lits.size(), lits.c_ptr(), lit); return false; } if (has_undef) { @@ -4412,7 +4412,7 @@ bool theory_seq::add_accept2step(expr* acc, bool& change) { SASSERT(ctx.get_assignment(lits[i]) == l_false); lits[i].neg(); } - set_conflict(0, lits); + set_conflict(nullptr, lits); return false; } @@ -4424,7 +4424,7 @@ bool theory_seq::add_accept2step(expr* acc, bool& change) { bool theory_seq::add_step2accept(expr* step, bool& change) { context& ctx = get_context(); SASSERT(ctx.get_assignment(step) == l_true); - expr* re = 0, *_acc = 0, *s = 0, *idx = 0, *i = 0, *j = 0; + expr* re = nullptr, *_acc = nullptr, *s = nullptr, *idx = nullptr, *i = nullptr, *j = nullptr; VERIFY(is_step(step, s, idx, re, i, j, _acc)); literal acc1 = mk_accept(s, idx, re, i); switch (ctx.get_assignment(acc1)) { @@ -4445,12 +4445,12 @@ bool theory_seq::add_step2accept(expr* step, bool& change) { lits.push_back(~acc2); switch (ctx.get_assignment(acc2)) { case l_undef: - propagate_lit(0, 2, lits.c_ptr(), acc2); + propagate_lit(nullptr, 2, lits.c_ptr(), acc2); break; case l_true: break; case l_false: - set_conflict(0, lits); + set_conflict(nullptr, lits); break; } break; @@ -4473,10 +4473,10 @@ Recall we also have: bool theory_seq::add_reject2reject(expr* rej, bool& change) { context& ctx = get_context(); SASSERT(ctx.get_assignment(rej) == l_true); - expr* s = 0, *idx = 0, *re = 0; + expr* s = nullptr, *idx = nullptr, *re = nullptr; unsigned src; rational r; - eautomaton* aut = 0; + eautomaton* aut = nullptr; VERIFY(is_reject(rej, s, idx, re, src, aut)); if (!aut || m_util.str.is_length(idx)) return false; VERIFY(m_autil.is_numeral(idx, r) && r.is_unsigned()); @@ -4535,7 +4535,7 @@ bool theory_seq::add_reject2reject(expr* rej, bool& change) { void theory_seq::propagate_not_prefix(expr* e) { context& ctx = get_context(); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; VERIFY(m_util.str.is_prefix(e, e1, e2)); literal lit = ctx.get_literal(e); SASSERT(ctx.get_assignment(lit) == l_false); @@ -4545,13 +4545,13 @@ void theory_seq::propagate_not_prefix(expr* e) { propagate_non_empty(~lit, e1); expr_ref emp(m_util.str.mk_empty(m.get_sort(e1)), m); literal e2_is_emp = mk_seq_eq(e2, emp); - sort* char_sort = 0; + sort* char_sort = nullptr; VERIFY(m_util.is_seq(m.get_sort(e1), char_sort)); expr_ref x = mk_skolem(symbol("seq.prefix.x"), e1, e2); expr_ref y = mk_skolem(symbol("seq.prefix.y"), e1, e2); expr_ref z = mk_skolem(symbol("seq.prefix.z"), e1, e2); - expr_ref c = mk_skolem(symbol("seq.prefix.c"), e1, e2, 0, char_sort); - expr_ref d = mk_skolem(symbol("seq.prefix.d"), e1, e2, 0, char_sort); + expr_ref c = mk_skolem(symbol("seq.prefix.c"), e1, e2, nullptr, char_sort); + expr_ref d = mk_skolem(symbol("seq.prefix.d"), e1, e2, nullptr, char_sort); add_axiom(lit, e2_is_emp, mk_seq_eq(e1, mk_concat(x, m_util.str.mk_unit(c), y))); add_axiom(lit, e2_is_emp, mk_seq_eq(e2, mk_concat(x, m_util.str.mk_unit(d), z)), mk_seq_eq(e2, x)); add_axiom(lit, e2_is_emp, ~mk_eq(c, d, false), mk_seq_eq(e2, x)); @@ -4564,7 +4564,7 @@ void theory_seq::propagate_not_prefix(expr* e) { void theory_seq::propagate_not_prefix2(expr* e) { context& ctx = get_context(); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; VERIFY(m_util.str.is_prefix(e, e1, e2)); literal lit = ctx.get_literal(e); SASSERT(ctx.get_assignment(lit) == l_false); @@ -4591,7 +4591,7 @@ void theory_seq::propagate_not_prefix2(expr* e) { void theory_seq::propagate_not_suffix(expr* e) { context& ctx = get_context(); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; VERIFY(m_util.str.is_suffix(e, e1, e2)); literal lit = ctx.get_literal(e); SASSERT(ctx.get_assignment(lit) == l_false); @@ -4602,13 +4602,13 @@ void theory_seq::propagate_not_suffix(expr* e) { expr_ref emp(m_util.str.mk_empty(m.get_sort(e1)), m); literal e2_is_emp = mk_seq_eq(e2, emp); - sort* char_sort = 0; + sort* char_sort = nullptr; VERIFY(m_util.is_seq(m.get_sort(e1), char_sort)); expr_ref x = mk_skolem(symbol("seq.suffix.x"), e1, e2); expr_ref y = mk_skolem(symbol("seq.suffix.y"), e1, e2); expr_ref z = mk_skolem(symbol("seq.suffix.z"), e1, e2); - expr_ref c = mk_skolem(symbol("seq.suffix.c"), e1, e2, 0, char_sort); - expr_ref d = mk_skolem(symbol("seq.suffix.d"), e1, e2, 0, char_sort); + expr_ref c = mk_skolem(symbol("seq.suffix.c"), e1, e2, nullptr, char_sort); + expr_ref d = mk_skolem(symbol("seq.suffix.d"), e1, e2, nullptr, char_sort); add_axiom(lit, e2_is_emp, mk_seq_eq(e1, mk_concat(y, m_util.str.mk_unit(c), x))); add_axiom(lit, e2_is_emp, mk_seq_eq(e2, mk_concat(z, m_util.str.mk_unit(d), x)), mk_seq_eq(e2, x)); add_axiom(lit, e2_is_emp, ~mk_eq(c, d, false), mk_seq_eq(e2, x)); @@ -4620,7 +4620,7 @@ void theory_seq::propagate_not_suffix(expr* e) { */ bool theory_seq::add_prefix2prefix(expr* e, bool& change) { context& ctx = get_context(); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; VERIFY(m_util.str.is_prefix(e, e1, e2)); SASSERT(ctx.get_assignment(e) == l_false); if (canonizes(false, e)) { @@ -4682,7 +4682,7 @@ bool theory_seq::add_prefix2prefix(expr* e, bool& change) { lits.push_back(~ctx.get_literal(e)); lits.push_back(~e2_is_emp); lits.push_back(lit); - propagate_lit(0, lits.size(), lits.c_ptr(), ~mk_literal(m_util.str.mk_prefix(tail1, tail2))); + propagate_lit(nullptr, lits.size(), lits.c_ptr(), ~mk_literal(m_util.str.mk_prefix(tail1, tail2))); TRACE("seq", tout << mk_pp(e, m) << " saturate: " << tail1 << " = " << tail2 << "\n";); return false; } @@ -4692,7 +4692,7 @@ bool theory_seq::add_prefix2prefix(expr* e, bool& change) { */ bool theory_seq::add_suffix2suffix(expr* e, bool& change) { context& ctx = get_context(); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; VERIFY(m_util.str.is_suffix(e, e1, e2)); SASSERT(ctx.get_assignment(e) == l_false); if (canonizes(false, e)) { @@ -4746,21 +4746,21 @@ bool theory_seq::add_suffix2suffix(expr* e, bool& change) { lits.push_back(~ctx.get_literal(e)); lits.push_back(~e2_is_emp); lits.push_back(last_eq); - propagate_lit(0, lits.size(), lits.c_ptr(), ~mk_literal(m_util.str.mk_suffix(first1, first2))); + propagate_lit(nullptr, lits.size(), lits.c_ptr(), ~mk_literal(m_util.str.mk_suffix(first1, first2))); TRACE("seq", tout << mk_pp(e, m) << " saturate\n";); return false; } bool theory_seq::canonizes(bool sign, expr* e) { context& ctx = get_context(); - dependency* deps = 0; + dependency* deps = nullptr; expr_ref cont = canonize(e, deps); TRACE("seq", tout << mk_pp(e, m) << " -> " << cont << "\n"; if (deps) display_deps(tout, deps);); if ((m.is_true(cont) && !sign) || (m.is_false(cont) && sign)) { TRACE("seq", display(tout); tout << ctx.get_assignment(ctx.get_literal(e)) << "\n";); - propagate_lit(deps, 0, 0, ctx.get_literal(e)); + propagate_lit(deps, 0, nullptr, ctx.get_literal(e)); return true; } if ((m.is_false(cont) && !sign) || @@ -4778,7 +4778,7 @@ bool theory_seq::canonizes(bool sign, expr* e) { bool theory_seq::add_contains2contains(expr* e, bool& change) { context& ctx = get_context(); - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; VERIFY(m_util.str.is_contains(e, e1, e2)); SASSERT(ctx.get_assignment(e) == l_false); if (canonizes(false, e)) { @@ -4803,7 +4803,7 @@ bool theory_seq::add_contains2contains(expr* e, bool& change) { propagate_eq(~e1_is_emp, e1, conc, true); literal lits[2] = { ~ctx.get_literal(e), ~e1_is_emp }; - propagate_lit(0, 2, lits, ~mk_literal(m_util.str.mk_contains(tail, e2))); + propagate_lit(nullptr, 2, lits, ~mk_literal(m_util.str.mk_contains(tail, e2))); return false; } @@ -4848,7 +4848,7 @@ bool theory_seq::propagate_automata() { } void theory_seq::get_concat(expr* e, ptr_vector& concats) { - expr* e1 = 0, *e2 = 0; + expr* e1 = nullptr, *e2 = nullptr; while (true) { e = m_rep.find(e); if (m_util.str.is_concat(e, e1, e2)) { diff --git a/src/smt/theory_seq.h b/src/smt/theory_seq.h index 3cb1f1b4b..203dae633 100644 --- a/src/smt/theory_seq.h +++ b/src/smt/theory_seq.h @@ -37,7 +37,7 @@ namespace smt { enode* n1, *n2; literal lit; assumption(enode* n1, enode* n2): n1(n1), n2(n2), lit(null_literal) {} - assumption(literal lit): n1(0), n2(0), lit(lit) {} + assumption(literal lit): n1(nullptr), n2(nullptr), lit(lit) {} }; typedef scoped_dependency_manager dependency_manager; typedef dependency_manager::dependency dependency; @@ -434,7 +434,7 @@ namespace smt { // asserting consequences bool linearize(dependency* dep, enode_pair_vector& eqs, literal_vector& lits) const; - void propagate_lit(dependency* dep, literal lit) { propagate_lit(dep, 0, 0, lit); } + void propagate_lit(dependency* dep, literal lit) { propagate_lit(dep, 0, nullptr, lit); } void propagate_lit(dependency* dep, unsigned n, literal const* lits, literal lit); void propagate_eq(dependency* dep, enode* n1, enode* n2); void propagate_eq(literal lit, expr* e1, expr* e2, bool add_to_eqs); @@ -531,7 +531,7 @@ namespace smt { bool get_length(expr* s, rational& val) const; void mk_decompose(expr* e, expr_ref& head, expr_ref& tail); - expr_ref mk_skolem(symbol const& s, expr* e1, expr* e2 = 0, expr* e3 = 0, sort* range = 0); + expr_ref mk_skolem(symbol const& s, expr* e1, expr* e2 = nullptr, expr* e3 = nullptr, sort* range = nullptr); bool is_skolem(symbol const& s, expr* e) const; void set_incomplete(app* term); diff --git a/src/smt/theory_seq_empty.h b/src/smt/theory_seq_empty.h index 647b54320..93b4be173 100644 --- a/src/smt/theory_seq_empty.h +++ b/src/smt/theory_seq_empty.h @@ -67,12 +67,12 @@ namespace smt { if (u.is_seq(s)) { return u.str.mk_empty(s); } - sort* seq = 0; + sort* seq = nullptr; if (u.is_re(s, seq)) { return u.re.mk_to_re(u.str.mk_empty(seq)); } UNREACHABLE(); - return 0; + return nullptr; } bool get_some_values(sort* s, expr_ref& v1, expr_ref& v2) override { if (u.is_string(s)) { @@ -105,7 +105,7 @@ namespace smt { return u.str.mk_string(sym); } } - sort* seq = 0, *ch = 0; + sort* seq = nullptr, *ch = nullptr; if (u.is_re(s, seq)) { expr* v0 = get_fresh_value(seq); return u.re.mk_to_re(v0); @@ -120,7 +120,7 @@ namespace smt { return u.str.mk_unit(v); } UNREACHABLE(); - return 0; + return nullptr; } void register_value(expr* n) override { symbol sym; @@ -150,7 +150,7 @@ namespace smt { bool m_used; final_check_status final_check_eh() override { return m_used?FC_GIVEUP:FC_DONE; } bool internalize_atom(app*, bool) override { if (!m_used) { get_context().push_trail(value_trail(m_used)); m_used = true; } return false; } - bool internalize_term(app*) override { return internalize_atom(0,false); } + bool internalize_term(app*) override { return internalize_atom(nullptr,false); } void new_eq_eh(theory_var, theory_var) override { } void new_diseq_eh(theory_var, theory_var) override {} theory* mk_fresh(context* new_ctx) override { return alloc(theory_seq_empty, new_ctx->get_manager()); } diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 56a54f964..c5058d00a 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -458,7 +458,7 @@ namespace smt { buffer << "!tmp"; buffer << m_fresh_id; m_fresh_id++; - return u.mk_skolem(symbol(buffer.c_str()), 0, 0, s); + return u.mk_skolem(symbol(buffer.c_str()), 0, nullptr, s); } @@ -617,7 +617,7 @@ namespace smt { ast_manager & m = get_manager(); expr * args[2] = {n, bound}; - app * unrollFunc = get_manager().mk_app(get_id(), _OP_RE_UNROLL, 0, 0, 2, args); + app * unrollFunc = get_manager().mk_app(get_id(), _OP_RE_UNROLL, 0, nullptr, 2, args); m_trail.push_back(unrollFunc); expr_ref_vector items(m); @@ -659,7 +659,7 @@ namespace smt { } else { if (false) { // use cache - app * lenTerm = NULL; + app * lenTerm = nullptr; if (!length_ast_map.find(e, lenTerm)) { lenTerm = u.str.mk_length(e); length_ast_map.insert(e, lenTerm); @@ -705,14 +705,14 @@ namespace smt { return n1; } } - return NULL; + return nullptr; } expr * theory_str::mk_concat(expr * n1, expr * n2) { context & ctx = get_context(); ast_manager & m = get_manager(); - ENSURE(n1 != NULL); - ENSURE(n2 != NULL); + ENSURE(n1 != nullptr); + ENSURE(n2 != nullptr); bool n1HasEqcValue = false; bool n2HasEqcValue = false; n1 = get_eqc_value(n1, n1HasEqcValue); @@ -770,7 +770,7 @@ namespace smt { // Z3 treats (ast1) and (ast2) as two different nodes. //------------------------------------------------------- - expr * concatAst = NULL; + expr * concatAst = nullptr; if (!concat_astNode_map.find(n1, n2, concatAst)) { concatAst = u.str.mk_concat(n1, n2); @@ -1424,9 +1424,9 @@ namespace smt { void theory_str::instantiate_axiom_Substr(enode * e) { context & ctx = get_context(); ast_manager & m = get_manager(); - expr* substrBase = 0; - expr* substrPos = 0; - expr* substrLen = 0; + expr* substrBase = nullptr; + expr* substrPos = nullptr; + expr* substrLen = nullptr; app * expr = e->get_owner(); if (axiomatized_terms.contains(expr)) { @@ -2001,7 +2001,7 @@ namespace smt { } } // give up - return NULL; + return nullptr; } // trace code helper @@ -2091,7 +2091,7 @@ namespace smt { // (Concat n_eqNode arg1) /\ arg1 has eq const expr * concatResult = eval_concat(eq_str, arg1); - if (concatResult != NULL) { + if (concatResult != nullptr) { bool arg1HasEqcValue = false; expr * arg1Value = get_eqc_value(arg1, arg1HasEqcValue); expr_ref implyL(m); @@ -2162,7 +2162,7 @@ namespace smt { // (Concat arg0 n_eqNode) /\ arg0 has eq const expr * concatResult = eval_concat(arg0, eq_str); - if (concatResult != NULL) { + if (concatResult != nullptr) { bool arg0HasEqcValue = false; expr * arg0Value = get_eqc_value(arg0, arg0HasEqcValue); expr_ref implyL(m); @@ -2846,8 +2846,8 @@ namespace smt { //************************************************************* if (is_concat_eq_type2(new_nn1, new_nn2)) { - expr * y = NULL; - expr * m = NULL; + expr * y = nullptr; + expr * m = nullptr; expr * v1_arg0 = to_app(new_nn1)->get_arg(0); expr * v1_arg1 = to_app(new_nn1)->get_arg(1); expr * v2_arg0 = to_app(new_nn2)->get_arg(0); @@ -2878,8 +2878,8 @@ namespace smt { expr * v2_arg0 = to_app(new_nn2)->get_arg(0); expr * v2_arg1 = to_app(new_nn2)->get_arg(1); - expr * x = NULL; - expr * n = NULL; + expr * x = nullptr; + expr * n = nullptr; if (u.str.is_string(v1_arg0) && !u.str.is_string(v2_arg0)) { n = v1_arg1; @@ -2920,8 +2920,8 @@ namespace smt { expr * v2_arg0 = to_app(new_nn2)->get_arg(0); expr * v2_arg1 = to_app(new_nn2)->get_arg(1); - expr * y = NULL; - expr * m = NULL; + expr * y = nullptr; + expr * m = nullptr; if (u.str.is_string(v1_arg0)) { y = v1_arg1; @@ -3020,9 +3020,9 @@ namespace smt { << "split type " << splitType << std::endl; ); - expr * t1 = NULL; - expr * t2 = NULL; - expr * xorFlag = NULL; + expr * t1 = nullptr; + expr * t2 = nullptr; + expr * xorFlag = nullptr; std::pair key1(concatAst1, concatAst2); std::pair key2(concatAst2, concatAst1); @@ -3390,10 +3390,10 @@ namespace smt { return; } - expr * x = NULL; - expr * y = NULL; - expr * strAst = NULL; - expr * m = NULL; + expr * x = nullptr; + expr * y = nullptr; + expr * strAst = nullptr; + expr * m = nullptr; expr * v1_arg0 = to_app(concatAst1)->get_arg(0); expr * v1_arg1 = to_app(concatAst1)->get_arg(1); @@ -3424,8 +3424,8 @@ namespace smt { // setup - expr * xorFlag = NULL; - expr * temp1 = NULL; + expr * xorFlag = nullptr; + expr * temp1 = nullptr; std::pair key1(concatAst1, concatAst2); std::pair key2(concatAst2, concatAst1); @@ -3758,10 +3758,10 @@ namespace smt { expr * v2_arg0 = to_app(concatAst2)->get_arg(0); expr * v2_arg1 = to_app(concatAst2)->get_arg(1); - expr * x = NULL; - expr * y = NULL; - expr * strAst = NULL; - expr * n = NULL; + expr * x = nullptr; + expr * y = nullptr; + expr * strAst = nullptr; + expr * n = nullptr; if (u.str.is_string(v1_arg0) && !u.str.is_string(v2_arg0)) { strAst = v1_arg0; @@ -4318,10 +4318,10 @@ namespace smt { expr * v2_arg1 = to_app(concatAst2)->get_arg(1); - expr * str1Ast = NULL; - expr * y = NULL; - expr * m = NULL; - expr * str2Ast = NULL; + expr * str1Ast = nullptr; + expr * y = nullptr; + expr * m = nullptr; + expr * str2Ast = nullptr; if (u.str.is_string(v1_arg0)) { str1Ast = v1_arg0; @@ -4362,8 +4362,8 @@ namespace smt { } //---------------------------------------------------------------- - expr * commonVar = NULL; - expr * xorFlag = NULL; + expr * commonVar = nullptr; + expr * xorFlag = nullptr; std::pair key1(concatAst1, concatAst2); std::pair key2(concatAst2, concatAst1); @@ -4674,7 +4674,7 @@ namespace smt { return dynamic_cast(th); } else { - return 0; + return nullptr; } } @@ -4846,7 +4846,7 @@ namespace smt { } expr * theory_str::collect_eq_nodes(expr * n, expr_ref_vector & eqcSet) { - expr * constStrNode = NULL; + expr * constStrNode = nullptr; expr * ex = n; do { @@ -4891,7 +4891,7 @@ namespace smt { expr * strAst = itor1->first; expr * substrAst = itor1->second; - expr * boolVar = NULL; + expr * boolVar = nullptr; if (!contain_pair_bool_map.find(strAst, substrAst, boolVar)) { TRACE("str", tout << "warning: no entry for boolVar in contain_pair_bool_map" << std::endl;); } @@ -5028,7 +5028,7 @@ namespace smt { expr * strAst = itor1->first; expr * substrAst = itor1->second; - expr * boolVar = NULL; + expr * boolVar = nullptr; if (!contain_pair_bool_map.find(strAst, substrAst, boolVar)) { TRACE("str", tout << "warning: no entry for boolVar in contain_pair_bool_map" << std::endl;); } @@ -5445,7 +5445,7 @@ namespace smt { expr_ref_vector willEqClass(m); expr * constStrAst_1 = collect_eq_nodes(n1, willEqClass); expr * constStrAst_2 = collect_eq_nodes(n2, willEqClass); - expr * constStrAst = (constStrAst_1 != NULL) ? constStrAst_1 : constStrAst_2; + expr * constStrAst = (constStrAst_1 != nullptr) ? constStrAst_1 : constStrAst_2; TRACE("str", tout << "eqc of n1 is {"; for (expr_ref_vector::iterator it = willEqClass.begin(); it != willEqClass.end(); ++it) { @@ -5461,7 +5461,7 @@ namespace smt { ); // step 1: we may have constant values for Contains checks now - if (constStrAst != NULL) { + if (constStrAst != nullptr) { expr_ref_vector::iterator itAst = willEqClass.begin(); for (; itAst != willEqClass.end(); itAst++) { if (*itAst == constStrAst) { @@ -6405,9 +6405,9 @@ namespace smt { expr * constStr_1 = collect_eq_nodes(nn1, eqNodeSet); expr * constStr_2 = collect_eq_nodes(nn2, eqNodeSet); - expr * constStr = (constStr_1 != NULL) ? constStr_1 : constStr_2; + expr * constStr = (constStr_1 != nullptr) ? constStr_1 : constStr_2; - if (constStr == NULL) { + if (constStr == nullptr) { return; } else { expr_ref_vector::iterator itor = eqNodeSet.begin(); @@ -6615,7 +6615,7 @@ namespace smt { } else { // Case 4: Concat(var, var) == const TRACE("str", tout << "Case 4: Concat(var, var) == const" << std::endl;); - if (eval_concat(arg1, arg2) == NULL) { + if (eval_concat(arg1, arg2) == nullptr) { rational arg1Len, arg2Len; bool arg1Len_exists = get_len_value(arg1, arg1Len); bool arg2Len_exists = get_len_value(arg2, arg2Len); @@ -6860,7 +6860,7 @@ namespace smt { } else { // start binary search as normal expr_ref implLhs(ctx.mk_eq_atom(testvar, str), m); - expr_ref implRhs(binary_search_length_test(v, NULL, ""), m); + expr_ref implRhs(binary_search_length_test(v, nullptr, ""), m); assert_implication(implLhs, implRhs); } } else { @@ -6992,14 +6992,14 @@ namespace smt { } expr * valueAssert = gen_free_var_options(fVar, effectiveLenInd, effectiveLenIndiStr, valTester, valTesterValue); TRACE("str", tout << "asserting more value tests for free variable " << mk_ismt2_pp(fVar, m) << std::endl;); - if (valueAssert != NULL) { + if (valueAssert != nullptr) { assert_axiom(valueAssert); } } } else { int lenTesterCount = fvar_lenTester_map[fVar].size(); - expr * effectiveLenInd = NULL; + expr * effectiveLenInd = nullptr; zstring effectiveLenIndiStr = ""; for (int i = 0; i < lenTesterCount; ++i) { expr * len_indicator_pre = fvar_lenTester_map[fVar][i]; @@ -7017,7 +7017,7 @@ namespace smt { } expr * valueAssert = gen_free_var_options(fVar, effectiveLenInd, effectiveLenIndiStr, valTester, valTesterValue); TRACE("str", tout << "asserting more value tests for free variable " << mk_ismt2_pp(fVar, m) << std::endl;); - if (valueAssert != NULL) { + if (valueAssert != nullptr) { assert_axiom(valueAssert); } } @@ -7262,20 +7262,20 @@ namespace smt { simplify_parent(lhs, nn2_value); } - expr * nn1EqConst = NULL; + expr * nn1EqConst = nullptr; std::set nn1EqUnrollFuncs; get_eqc_allUnroll(lhs, nn1EqConst, nn1EqUnrollFuncs); - expr * nn2EqConst = NULL; + expr * nn2EqConst = nullptr; std::set nn2EqUnrollFuncs; get_eqc_allUnroll(rhs, nn2EqConst, nn2EqUnrollFuncs); - if (nn2EqConst != NULL) { + if (nn2EqConst != nullptr) { for (std::set::iterator itor1 = nn1EqUnrollFuncs.begin(); itor1 != nn1EqUnrollFuncs.end(); itor1++) { process_unroll_eq_const_str(*itor1, nn2EqConst); } } - if (nn1EqConst != NULL) { + if (nn1EqConst != nullptr) { for (std::set::iterator itor2 = nn2EqUnrollFuncs.begin(); itor2 != nn2EqUnrollFuncs.end(); itor2++) { process_unroll_eq_const_str(*itor2, nn1EqConst); } @@ -7917,13 +7917,13 @@ namespace smt { if (aliasUnrollSet.find(unrollItor->first) != aliasUnrollSet.end()) { continue; } - expr * aRoot = NULL; + expr * aRoot = nullptr; enode * e_currEqc = ctx.get_enode(unrollItor->first); enode * e_curr = e_currEqc; do { app * curr = e_currEqc->get_owner(); if (u.re.is_unroll(curr)) { - if (aRoot == NULL) { + if (aRoot == nullptr) { aRoot = curr; } aliasUnrollSet[curr] = aRoot; @@ -7948,11 +7948,11 @@ namespace smt { if (aliasIndexMap.find(varItor->first) != aliasIndexMap.end()) { continue; } - expr * aRoot = NULL; + expr * aRoot = nullptr; expr * curr = varItor->first; do { if (variable_set.find(curr) != variable_set.end()) { - if (aRoot == NULL) { + if (aRoot == nullptr) { aRoot = curr; } else { aliasIndexMap[curr] = aRoot; @@ -8040,11 +8040,11 @@ namespace smt { if (concats_eq_index_map.find(concatItor->first) != concats_eq_index_map.end()) { continue; } - expr * aRoot = NULL; + expr * aRoot = nullptr; expr * curr = concatItor->first; do { if (u.str.is_concat(to_app(curr))) { - if (aRoot == NULL) { + if (aRoot == nullptr) { aRoot = curr; } else { concats_eq_index_map[curr] = aRoot; @@ -8056,7 +8056,7 @@ namespace smt { concatItor = concatMap.begin(); for(; concatItor != concatMap.end(); ++concatItor) { - expr * deAliasConcat = NULL; + expr * deAliasConcat = nullptr; if (concats_eq_index_map.find(concatItor->first) != concats_eq_index_map.end()) { deAliasConcat = concats_eq_index_map[concatItor->first]; } else { @@ -8194,15 +8194,15 @@ namespace smt { mostLeftNodes.clear(); mostRightNodes.clear(); - expr * mLConst = NULL; - expr * mRConst = NULL; + expr * mLConst = nullptr; + expr * mRConst = nullptr; for (std::map::iterator itor1 = itor->second.begin(); itor1 != itor->second.end(); itor1++) { expr * concatNode = itor1->first; expr * mLNode = getMostLeftNodeInConcat(concatNode); zstring strval; if (u.str.is_string(to_app(mLNode), strval)) { - if (mLConst == NULL && strval.empty()) { + if (mLConst == nullptr && strval.empty()) { mLConst = mLNode; } } else { @@ -8211,7 +8211,7 @@ namespace smt { expr * mRNode = getMostRightNodeInConcat(concatNode); if (u.str.is_string(to_app(mRNode), strval)) { - if (mRConst == NULL && strval.empty()) { + if (mRConst == nullptr && strval.empty()) { mRConst = mRNode; } } else { @@ -8219,7 +8219,7 @@ namespace smt { } } - if (mLConst != NULL) { + if (mLConst != nullptr) { // ------------------------------------------------------------------------------------- // The left most variable in a concat is constrained by a constant string in eqc concat // ------------------------------------------------------------------------------------- @@ -8273,7 +8273,7 @@ namespace smt { } } - if (mRConst != NULL) { + if (mRConst != nullptr) { for (std::map::iterator itor1 = mostRightNodes.begin(); itor1 != mostRightNodes.end(); itor1++) { expr * deVar = get_alias_index_ast(aliasIndexMap, itor1->first); @@ -8952,7 +8952,7 @@ namespace smt { // ----------------------------------------------------------- std::map > fv_unrolls_map; std::set tmpSet; - expr * constValue = NULL; + expr * constValue = nullptr; for (std::map::iterator fvIt2 = freeVar_map.begin(); fvIt2 != freeVar_map.end(); fvIt2++) { expr * var = fvIt2->first; tmpSet.clear(); @@ -9036,7 +9036,7 @@ namespace smt { // Assign free variables std::set fSimpUnroll; - constValue = NULL; + constValue = nullptr; { TRACE("str", tout << "free var map (#" << freeVar_map.size() << "):" << std::endl; @@ -9074,8 +9074,8 @@ namespace smt { continue; } */ - expr * toAssert = gen_len_val_options_for_free_var(freeVar, NULL, ""); - if (toAssert != NULL) { + expr * toAssert = gen_len_val_options_for_free_var(freeVar, nullptr, ""); + if (toAssert != nullptr) { assert_axiom(toAssert); } } @@ -9095,7 +9095,7 @@ namespace smt { gen_assign_unroll_reg(fv_unrolls_map[var]); } else { expr * toAssert = gen_assign_unroll_Str2Reg(var, fSimpUnroll); - if (toAssert != NULL) { + if (toAssert != nullptr) { assert_axiom(toAssert); } } @@ -9381,7 +9381,7 @@ namespace smt { } if (valTesterValueStr == "more") { - expr * valTester = NULL; + expr * valTester = nullptr; if (i + 1 < testerTotal) { valTester = fvar_valueTester_map[freeVar][len][i + 1].second; refresh_theory_var(valTester); @@ -9394,7 +9394,7 @@ namespace smt { return gen_val_options(freeVar, len_indicator, valTester, len_valueStr, i + 1); } - return NULL; + return nullptr; } } @@ -9627,14 +9627,14 @@ namespace smt { int lcm = 1; int coreValueCount = 0; - expr * oneUnroll = NULL; + expr * oneUnroll = nullptr; zstring oneCoreStr(""); for (std::set::iterator itor = unrolls.begin(); itor != unrolls.end(); itor++) { expr * str2RegFunc = to_app(*itor)->get_arg(0); expr * coreVal = to_app(str2RegFunc)->get_arg(0); zstring coreStr; u.str.is_string(coreVal, coreStr); - if (oneUnroll == NULL) { + if (oneUnroll == nullptr) { oneUnroll = *itor; oneCoreStr = coreStr; } @@ -10060,7 +10060,7 @@ namespace smt { TRACE("str", tout << "invoked with previousLenTester info matching top of stack" << std::endl;); } else { TRACE("str", tout << "WARNING: unexpected reordering of length testers!" << std::endl;); - UNREACHABLE(); return NULL; + UNREACHABLE(); return nullptr; } } else { u.str.is_string(lastTesterValue, lastTesterConstant); @@ -10076,7 +10076,7 @@ namespace smt { } TRACE("str", tout << "last bounds are [" << lastBounds.lowerBound << " | " << lastBounds.midPoint << " | " << lastBounds.upperBound << "]!" << lastBounds.windowSize << std::endl;); binary_search_info newBounds; - expr * newTester = 0; + expr * newTester = nullptr; if (lastTesterConstant == "more") { // special case: if the midpoint, upper bound, and window size are all equal, // we double the window size and adjust the bounds @@ -10144,7 +10144,7 @@ namespace smt { return axiom; } // length is fixed - expr * valueAssert = gen_free_var_options(freeVar, lastTester, lastTesterConstant, NULL, zstring("")); + expr * valueAssert = gen_free_var_options(freeVar, lastTester, lastTesterConstant, nullptr, zstring("")); return valueAssert; } } else { @@ -10254,7 +10254,7 @@ namespace smt { } else { TRACE("str", tout << "found previous in-scope length assertions" << std::endl;); - expr * effectiveLenInd = NULL; + expr * effectiveLenInd = nullptr; zstring effectiveLenIndiStr(""); int lenTesterCount = (int) fvar_lenTester_map[freeVar].size(); @@ -10355,7 +10355,7 @@ namespace smt { } else { TRACE("str", tout << "length is fixed; generating models for free var" << std::endl;); // length is fixed - expr * valueAssert = gen_free_var_options(freeVar, effectiveLenInd, effectiveLenIndiStr, NULL, zstring("")); + expr * valueAssert = gen_free_var_options(freeVar, effectiveLenInd, effectiveLenIndiStr, nullptr, zstring("")); return valueAssert; } } // fVarLenCountMap.find(...) @@ -10409,7 +10409,7 @@ namespace smt { std::set eqVarSet; get_var_in_eqc(freeVar, eqVarSet); bool duplicated = false; - expr * dupVar = NULL; + expr * dupVar = nullptr; for (std::set::iterator itorEqv = eqVarSet.begin(); itorEqv != eqVarSet.end(); itorEqv++) { if (eqcRepSet.find(*itorEqv) != eqcRepSet.end()) { duplicated = true; @@ -10417,7 +10417,7 @@ namespace smt { break; } } - if (duplicated && dupVar != NULL) { + if (duplicated && dupVar != nullptr) { TRACE("str", tout << "Duplicated free variable found:" << mk_pp(freeVar, get_manager()) << " = " << mk_ismt2_pp(dupVar, get_manager()) << " (SKIP)" << std::endl;); continue; @@ -10465,10 +10465,10 @@ namespace smt { for(std::set::iterator itor1 = leafVarSet.begin(); itor1 != leafVarSet.end(); ++itor1) { - expr * toAssert = gen_len_val_options_for_free_var(*itor1, NULL, ""); + expr * toAssert = gen_len_val_options_for_free_var(*itor1, nullptr, ""); // gen_len_val_options_for_free_var() can legally return NULL, // as methods that it calls may assert their own axioms instead. - if (toAssert != NULL) { + if (toAssert != nullptr) { assert_axiom(toAssert); } } @@ -10477,9 +10477,9 @@ namespace smt { mItor != aloneVars.end(); ++mItor) { std::set::iterator itor2 = mItor->second.begin(); for(; itor2 != mItor->second.end(); ++itor2) { - expr * toAssert = gen_len_val_options_for_free_var(*itor2, NULL, ""); + expr * toAssert = gen_len_val_options_for_free_var(*itor2, nullptr, ""); // same deal with returning a NULL axiom here - if(toAssert != NULL) { + if(toAssert != nullptr) { assert_axiom(toAssert); } } @@ -10491,7 +10491,7 @@ namespace smt { * and constant string in eqc of node n */ void theory_str::get_eqc_allUnroll(expr * n, expr * &constStr, std::set & unrollFuncSet) { - constStr = NULL; + constStr = nullptr; unrollFuncSet.clear(); expr * curr = n; @@ -10509,7 +10509,7 @@ namespace smt { // Collect simple Unroll functions (whose core is Str2Reg) and constant strings in the EQC of n. void theory_str::get_eqc_simpleUnroll(expr * n, expr * &constStr, std::set & unrollFuncSet) { - constStr = NULL; + constStr = nullptr; unrollFuncSet.clear(); expr * curr = n; @@ -10556,7 +10556,7 @@ namespace smt { app * a0_conststr = mk_value_helper(to_app(a0)); app * a1_conststr = mk_value_helper(to_app(a1)); - if (a0_conststr != NULL && a1_conststr != NULL) { + if (a0_conststr != nullptr && a1_conststr != nullptr) { zstring a0_s, a1_s; u.str.is_string(a0_conststr, a0_s); u.str.is_string(a1_conststr, a1_s); @@ -10571,7 +10571,7 @@ namespace smt { if (hasEqc) { return to_app(n_eqc); } else { - return NULL; + return nullptr; } } @@ -10586,7 +10586,7 @@ namespace smt { SASSERT(get_context().e_internalized(owner)); app * val = mk_value_helper(owner); - if (val != NULL) { + if (val != nullptr) { return alloc(expr_wrapper_proc, val); } else { TRACE("str", tout << "WARNING: failed to find a concrete value, falling back" << std::endl;); diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index 52d06efd1..3b71a2282 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -66,13 +66,13 @@ public: return u.str.mk_string(sym); } } - sort* seq = 0; + sort* seq = nullptr; if (u.is_re(s, seq)) { expr* v0 = get_fresh_value(seq); return u.re.mk_to_re(v0); } TRACE("t_str", tout << "unexpected sort in get_fresh_value(): " << mk_pp(s, m_manager) << std::endl;); - UNREACHABLE(); return NULL; + UNREACHABLE(); return nullptr; } void register_value(expr * n) override { /* Ignore */ } }; @@ -87,7 +87,7 @@ public: return value; } else { TRACE("t_str", tout << "WARNING: lookup miss in contain_pair_bool_map!" << std::endl;); - return NULL; + return nullptr; } } diff --git a/src/smt/theory_utvpi.h b/src/smt/theory_utvpi.h index ca4f4737e..64aa9f2c5 100644 --- a/src/smt/theory_utvpi.h +++ b/src/smt/theory_utvpi.h @@ -242,7 +242,7 @@ namespace smt { justification * why_is_diseq(th_var v1, th_var v2) override { UNREACHABLE(); - return 0; + return nullptr; } void reset_eh() override; diff --git a/src/smt/theory_utvpi_def.h b/src/smt/theory_utvpi_def.h index 7c1edb585..b051c504a 100644 --- a/src/smt/theory_utvpi_def.h +++ b/src/smt/theory_utvpi_def.h @@ -70,7 +70,7 @@ namespace smt { m_lra(false), m_non_utvpi_exprs(false), m_test(m), - m_factory(0) { + m_factory(nullptr) { } template @@ -106,7 +106,7 @@ namespace smt { template theory_var theory_utvpi::mk_var(expr* n) { context & ctx = get_context(); - enode* e = 0; + enode* e = nullptr; th_var v = null_theory_var; m_lia |= a.is_int(n); m_lra |= a.is_real(n); @@ -239,7 +239,7 @@ namespace smt { ctx.mk_justification( ext_theory_conflict_justification( get_id(), ctx.get_region(), - lits.size(), lits.c_ptr(), 0, 0, params.size(), params.c_ptr()))); + lits.size(), lits.c_ptr(), 0, nullptr, params.size(), params.c_ptr()))); m_nc_functor.reset(); } diff --git a/src/smt/theory_wmaxsat.cpp b/src/smt/theory_wmaxsat.cpp index 88ba89610..53116cb60 100644 --- a/src/smt/theory_wmaxsat.cpp +++ b/src/smt/theory_wmaxsat.cpp @@ -287,7 +287,7 @@ namespace smt { ctx.set_conflict( ctx.mk_justification( - ext_theory_conflict_justification(get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), 0, 0, 0, 0))); + ext_theory_conflict_justification(get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), 0, nullptr, 0, nullptr))); } bool theory_wmaxsat::max_unassigned_is_blocked() { @@ -337,7 +337,7 @@ namespace smt { region& r = ctx.get_region(); ctx.assign(lit, ctx.mk_justification( ext_theory_propagation_justification( - get_id(), r, lits.size(), lits.c_ptr(), 0, 0, lit, 0, 0))); + get_id(), r, lits.size(), lits.c_ptr(), 0, nullptr, lit, 0, nullptr))); } diff --git a/src/smt/theory_wmaxsat.h b/src/smt/theory_wmaxsat.h index 16dab488b..f2266a36f 100644 --- a/src/smt/theory_wmaxsat.h +++ b/src/smt/theory_wmaxsat.h @@ -96,7 +96,7 @@ namespace smt { } void reset_local(); void reset_eh() override; - theory * mk_fresh(context * new_ctx) override { return 0; } + theory * mk_fresh(context * new_ctx) override { return nullptr; } bool internalize_atom(app * atom, bool gate_ctx) override { return false; } bool internalize_term(app * term) override { return false; } void new_eq_eh(theory_var v1, theory_var v2) override { } diff --git a/src/smt/watch_list.cpp b/src/smt/watch_list.cpp index edd6923d7..9835142f6 100644 --- a/src/smt/watch_list.cpp +++ b/src/smt/watch_list.cpp @@ -35,7 +35,7 @@ namespace smt { } void watch_list::expand() { - if (m_data == 0) { + if (m_data == nullptr) { unsigned size = DEFAULT_WATCH_LIST_SIZE + HEADER_SIZE; unsigned * mem = reinterpret_cast(alloc_svect(char, size)); #ifdef _AMD64_ diff --git a/src/smt/watch_list.h b/src/smt/watch_list.h index 1cc29da5a..6d7a509d5 100644 --- a/src/smt/watch_list.h +++ b/src/smt/watch_list.h @@ -83,10 +83,10 @@ namespace smt { public: watch_list(): - m_data(0) { + m_data(nullptr) { } - watch_list(watch_list && other) : m_data(0) { + watch_list(watch_list && other) : m_data(nullptr) { std::swap(m_data, other.m_data); } @@ -115,7 +115,7 @@ namespace smt { void reset_and_release_memory() { destroy(); - m_data = 0; + m_data = nullptr; } clause_iterator begin_clause() { @@ -155,7 +155,7 @@ namespace smt { } void insert_clause(clause * c) { - if (m_data == 0 || end_cls_core() + sizeof(clause *) >= begin_lits_core()) { + if (m_data == nullptr || end_cls_core() + sizeof(clause *) >= begin_lits_core()) { expand(); } *(reinterpret_cast(m_data + end_cls_core())) = c; @@ -163,7 +163,7 @@ namespace smt { } void insert_literal(literal const & l) { - if (m_data == 0 || begin_lits_core() <= end_cls_core() + sizeof(literal)) { + if (m_data == nullptr || begin_lits_core() <= end_cls_core() + sizeof(literal)) { expand(); } SASSERT(begin_lits_core() >= sizeof(literal)); diff --git a/src/solver/check_sat_result.cpp b/src/solver/check_sat_result.cpp index f1bedfc08..e7c15964e 100644 --- a/src/solver/check_sat_result.cpp +++ b/src/solver/check_sat_result.cpp @@ -57,11 +57,11 @@ void simple_check_sat_result::get_model(model_ref & m) { if (m_status != l_false) m = m_model; else - m = 0; + m = nullptr; } proof * simple_check_sat_result::get_proof() { - return m_status == l_false ? m_proof.get() : 0; + return m_status == l_false ? m_proof.get() : nullptr; } std::string simple_check_sat_result::reason_unknown() const { diff --git a/src/solver/mus.cpp b/src/solver/mus.cpp index 7eb692567..e4ebd7e3b 100644 --- a/src/solver/mus.cpp +++ b/src/solver/mus.cpp @@ -136,7 +136,7 @@ struct mus::imp { // use correction sets lbool get_mus2(expr_ref_vector& mus) { - expr* lit = 0; + expr* lit = nullptr; lbool is_sat; ptr_vector unknown(m_lit2expr.size(), m_lit2expr.c_ptr()); while (!unknown.empty()) { @@ -163,7 +163,7 @@ struct mus::imp { expr_ref_vector nmcs(m); expr_set core, min_core, nmcs_set; bool min_core_valid = false; - expr* min_lit = 0; + expr* min_lit = nullptr; while (!unknown.empty()) { expr* lit = unknown.back(); unknown.pop_back(); diff --git a/src/solver/solver.cpp b/src/solver/solver.cpp index bf53cb669..d49b3620f 100644 --- a/src/solver/solver.cpp +++ b/src/solver/solver.cpp @@ -31,7 +31,7 @@ unsigned solver::get_num_assertions() const { expr * solver::get_assertion(unsigned idx) const { NOT_IMPLEMENTED_YET(); - return 0; + return nullptr; } std::ostream& solver::display(std::ostream & out, unsigned n, expr* const* assumptions) const { @@ -156,7 +156,7 @@ lbool solver::find_mutexes(expr_ref_vector const& vars, vector& } lbool solver::preferred_sat(expr_ref_vector const& asms, vector& cores) { - return check_sat(0, 0); + return check_sat(0, nullptr); } bool solver::is_literal(ast_manager& m, expr* e) { diff --git a/src/solver/solver2tactic.cpp b/src/solver/solver2tactic.cpp index 3bc66e3b4..8bb3fdf78 100644 --- a/src/solver/solver2tactic.cpp +++ b/src/solver/solver2tactic.cpp @@ -34,7 +34,7 @@ void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clause for (unsigned i = 0; i < sz; i++) { expr * f = g->form(i); expr_dependency * d = g->dep(i); - if (d == 0 || !g->unsat_core_enabled()) { + if (d == nullptr || !g->unsat_core_enabled()) { clauses.push_back(f); } else { @@ -58,9 +58,9 @@ void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clause } else { // must normalize assumption - expr * b = 0; + expr * b = nullptr; if (!dep2bool.find(d, b)) { - b = m.mk_fresh_const(0, m.mk_bool_sort()); + b = m.mk_fresh_const(nullptr, m.mk_bool_sort()); dep2bool.insert(d, b); bool2dep.insert(b, d); assumptions.push_back(b); @@ -106,7 +106,7 @@ public: /* out */ model_converter_ref & mc, /* out */ proof_converter_ref & pc, /* out */ expr_dependency_ref & core) override { - pc = 0; mc = 0; core = 0; + pc = nullptr; mc = nullptr; core = nullptr; expr_ref_vector clauses(m); expr2expr_map bool2dep; ptr_vector assumptions; @@ -128,8 +128,8 @@ public: break; case l_false: { in->reset(); - proof* pr = 0; - expr_dependency* lcore = 0; + proof* pr = nullptr; + expr_dependency* lcore = nullptr; if (in->proofs_enabled()) { pr = local_solver->get_proof(); pc = proof2proof_converter(m, pr); diff --git a/src/solver/solver_na2as.cpp b/src/solver/solver_na2as.cpp index 2628380c5..402edc19a 100644 --- a/src/solver/solver_na2as.cpp +++ b/src/solver/solver_na2as.cpp @@ -31,7 +31,7 @@ solver_na2as::solver_na2as(ast_manager & m): solver_na2as::~solver_na2as() {} void solver_na2as::assert_expr(expr * t, expr * a) { - if (a == 0) { + if (a == nullptr) { assert_expr(t); } else { diff --git a/src/solver/tactic2solver.cpp b/src/solver/tactic2solver.cpp index 9dc4fe43d..5c3c6bc7a 100644 --- a/src/solver/tactic2solver.cpp +++ b/src/solver/tactic2solver.cpp @@ -105,12 +105,12 @@ void tactic2solver::collect_param_descrs(param_descrs & r) { void tactic2solver::assert_expr(expr * t) { m_assertions.push_back(t); - m_result = 0; + m_result = nullptr; } void tactic2solver::push_core() { m_scopes.push_back(m_assertions.size()); - m_result = 0; + m_result = nullptr; } void tactic2solver::pop_core(unsigned n) { @@ -118,11 +118,11 @@ void tactic2solver::pop_core(unsigned n) { unsigned old_sz = m_scopes[new_lvl]; m_assertions.shrink(old_sz); m_scopes.shrink(new_lvl); - m_result = 0; + m_result = nullptr; } lbool tactic2solver::check_sat_core(unsigned num_assumptions, expr * const * assumptions) { - if (m_tactic.get() == 0) + if (m_tactic.get() == nullptr) return l_false; ast_manager & m = m_assertions.m(); m_result = alloc(simple_check_sat_result, m); @@ -187,7 +187,7 @@ lbool tactic2solver::check_sat_core(unsigned num_assumptions, expr * const * ass solver* tactic2solver::translate(ast_manager& m, params_ref const& p) { tactic* t = m_tactic->translate(m); tactic2solver* r = alloc(tactic2solver, m, t, p, m_produce_proofs, m_produce_models, m_produce_unsat_cores, m_logic); - r->m_result = 0; + r->m_result = nullptr; if (!m_scopes.empty()) { throw default_exception("translation of contexts is only supported at base level"); } @@ -220,7 +220,7 @@ proof * tactic2solver::get_proof() { if (m_result.get()) return m_result->get_proof(); else - return 0; + return nullptr; } std::string tactic2solver::reason_unknown() const { diff --git a/src/solver/tactic2solver.h b/src/solver/tactic2solver.h index 2da0f69eb..ddab66dc5 100644 --- a/src/solver/tactic2solver.h +++ b/src/solver/tactic2solver.h @@ -30,7 +30,7 @@ class solver; class solver_factory; solver * mk_tactic2solver(ast_manager & m, - tactic * t = 0, + tactic * t = nullptr, params_ref const & p = params_ref(), bool produce_proofs = false, bool produce_models = true, diff --git a/src/tactic/aig/aig.cpp b/src/tactic/aig/aig.cpp index e8226e159..40c68f72a 100644 --- a/src/tactic/aig/aig.cpp +++ b/src/tactic/aig/aig.cpp @@ -30,13 +30,13 @@ class aig_lit { friend class aig_ref; aig * m_ref; public: - aig_lit(aig * n = 0):m_ref(n) {} + aig_lit(aig * n = nullptr):m_ref(n) {} aig_lit(aig_ref const & r):m_ref(static_cast(r.m_ref)) {} bool is_inverted() const { return (reinterpret_cast(m_ref) & static_cast(1)) == static_cast(1); } void invert() { m_ref = reinterpret_cast(reinterpret_cast(m_ref) ^ static_cast(1)); } aig * ptr() const { return reinterpret_cast(reinterpret_cast(m_ref) & ~static_cast(1)); } aig * ptr_non_inverted() const { SASSERT(!is_inverted()); return m_ref; } - bool is_null() const { return m_ref == 0; } + bool is_null() const { return m_ref == nullptr; } friend bool operator==(aig_lit const & r1, aig_lit const & r2) { return r1.m_ref == r2.m_ref; } friend bool operator!=(aig_lit const & r1, aig_lit const & r2) { return r1.m_ref != r2.m_ref; } aig_lit & operator=(aig_lit const & r) { m_ref = r.m_ref; return *this; } @@ -151,7 +151,7 @@ struct aig_manager::imp { m_num_aigs--; if (is_var(n)) { m_var_id_gen.recycle(n->m_id); - m_var2exprs.set(n->m_id, 0); + m_var2exprs.set(n->m_id, nullptr); } else { m_table.erase(n); @@ -797,7 +797,7 @@ struct aig_manager::imp { m_cache.resize(idx+1); return false; } - return m_cache.get(idx) != 0; + return m_cache.get(idx) != nullptr; } void cache_result(aig * n, expr * t) { @@ -960,14 +960,14 @@ struct aig_manager::imp { } unsigned idx = to_idx(t); cache.reserve(idx+1); - if (cache.get(idx) != 0) { + if (cache.get(idx) != nullptr) { todo.pop_back(); continue; } bool ok = true; for (unsigned i = 0; i < 2; i++) { aig * c = t->m_children[i].ptr(); - if (!is_var(c) && cache.get(to_idx(c), 0) == 0) { + if (!is_var(c) && cache.get(to_idx(c), nullptr) == nullptr) { todo.push_back(c); ok = false; } @@ -981,7 +981,7 @@ struct aig_manager::imp { if (is_var(c)) args[i] = m.m_var2exprs.get(c->m_id); else - args[i] = cache.get(to_idx(c), 0); + args[i] = cache.get(to_idx(c), nullptr); if (!l.is_inverted()) args[i] = invert(args[i]); } @@ -1009,16 +1009,16 @@ struct aig_manager::imp { aig_lit n = roots.back(); roots.pop_back(); if (n.is_inverted()) { - g.assert_expr(invert(process_root(n.ptr())), 0, 0); + g.assert_expr(invert(process_root(n.ptr())), nullptr, nullptr); continue; } aig * p = n.ptr(); if (m.is_ite(p)) { - g.assert_expr(process_root(p), 0, 0); + g.assert_expr(process_root(p), nullptr, nullptr); continue; } if (is_var(p)) { - g.assert_expr(m.var2expr(p), 0, 0); + g.assert_expr(m.var2expr(p), nullptr, nullptr); continue; } roots.push_back(left(p)); @@ -1081,7 +1081,7 @@ struct aig_manager::imp { bool visit(aig * p) { if (is_var(p)) { - push_result(0); + push_result(nullptr); return true; } if (is_cached(p)) @@ -1654,8 +1654,8 @@ public: aig_ref::aig_ref(): - m_manager(0), - m_ref(0) { + m_manager(nullptr), + m_ref(nullptr) { } aig_ref::aig_ref(aig_manager & m, aig_lit const & l): @@ -1665,15 +1665,15 @@ aig_ref::aig_ref(aig_manager & m, aig_lit const & l): } aig_ref::~aig_ref() { - if (m_ref != 0) { + if (m_ref != nullptr) { m_manager->m_imp->dec_ref(aig_lit(*this)); } } aig_ref & aig_ref::operator=(aig_ref const & r) { - if (r.m_ref != 0) + if (r.m_ref != nullptr) r.m_manager->m_imp->inc_ref(aig_lit(r)); - if (m_ref != 0) + if (m_ref != nullptr) m_manager->m_imp->dec_ref(aig_lit(*this)); m_ref = r.m_ref; m_manager = r.m_manager; diff --git a/src/tactic/aig/aig_tactic.cpp b/src/tactic/aig/aig_tactic.cpp index b6b5021a1..391d4b412 100644 --- a/src/tactic/aig/aig_tactic.cpp +++ b/src/tactic/aig/aig_tactic.cpp @@ -37,12 +37,12 @@ class aig_tactic : public tactic { ~mk_aig_manager() { dealloc(m_owner.m_aig_manager); - m_owner.m_aig_manager = 0; + m_owner.m_aig_manager = nullptr; } }; public: - aig_tactic(params_ref const & p = params_ref()):m_aig_manager(0) { + aig_tactic(params_ref const & p = params_ref()):m_aig_manager(nullptr) { updt_params(p); } @@ -77,7 +77,7 @@ public: expr_ref new_f(g->m()); m_aig_manager->to_formula(r, new_f); expr_dependency * ed = g->dep(i); - g->update(i, new_f, 0, ed); + g->update(i, new_f, nullptr, ed); } } else { @@ -96,7 +96,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { fail_if_proof_generation("aig", g); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; operator()(g); g->inc_depth(); result.push_back(g.get()); diff --git a/src/tactic/arith/add_bounds_tactic.cpp b/src/tactic/arith/add_bounds_tactic.cpp index e71542532..5d64fff95 100644 --- a/src/tactic/arith/add_bounds_tactic.cpp +++ b/src/tactic/arith/add_bounds_tactic.cpp @@ -115,7 +115,7 @@ class add_bounds_tactic : public tactic { model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("add-bounds", *g); bound_manager bm(m); expr_fast_mark1 visited; diff --git a/src/tactic/arith/arith_bounds_tactic.cpp b/src/tactic/arith/arith_bounds_tactic.cpp index 31e5d4fdc..bf5381a5b 100644 --- a/src/tactic/arith/arith_bounds_tactic.cpp +++ b/src/tactic/arith/arith_bounds_tactic.cpp @@ -50,7 +50,7 @@ struct arith_bounds_tactic : public tactic { void mk_proof(proof_ref& pr, goal_ref const& s, unsigned i, unsigned j) { if (s->proofs_enabled()) { - proof* th_lemma = m.mk_th_lemma(a.get_family_id(), m.mk_implies(s->form(i), s->form(j)), 0, 0); + proof* th_lemma = m.mk_th_lemma(a.get_family_id(), m.mk_implies(s->form(i), s->form(j)), 0, nullptr); pr = m.mk_modus_ponens(s->pr(i), th_lemma); } } diff --git a/src/tactic/arith/bound_manager.cpp b/src/tactic/arith/bound_manager.cpp index da507ea10..045d49f5b 100644 --- a/src/tactic/arith/bound_manager.cpp +++ b/src/tactic/arith/bound_manager.cpp @@ -201,22 +201,22 @@ bool bound_manager::is_disjunctive_bound(expr * f, expr_dependency * d) { if (!m().is_or(f)) return false; unsigned sz = to_app(f)->get_num_args(); if (sz == 0) return false; - expr * x, * y, * v = 0; + expr * x, * y, * v = nullptr; bool is_int; for (unsigned i = 0; i < sz; ++i) { expr * e = to_app(f)->get_arg(i); if (!m().is_eq(e, x, y)) return false; if (is_uninterp_const(x) && is_numeral(y, n, is_int) && is_int && - (x == v || v == 0)) { - if (v == 0) { v = x; lo = hi = n; } + (x == v || v == nullptr)) { + if (v == nullptr) { v = x; lo = hi = n; } if (n < lo) lo = n; if (n > hi) hi = n; } else if (is_uninterp_const(y) && is_numeral(x, n, is_int) && is_int && - (y == v || v == 0)) { - if (v == 0) { v = y; lo = hi = n; } + (y == v || v == nullptr)) { + if (v == nullptr) { v = y; lo = hi = n; } if (n < lo) lo = n; if (n > hi) hi = n; } diff --git a/src/tactic/arith/bound_manager.h b/src/tactic/arith/bound_manager.h index a08a53614..54a80ce5d 100644 --- a/src/tactic/arith/bound_manager.h +++ b/src/tactic/arith/bound_manager.h @@ -50,7 +50,7 @@ public: ast_manager & m() const { return m_util.get_manager(); } void operator()(goal const & g); - void operator()(expr * n, expr_dependency * d = 0); + void operator()(expr * n, expr_dependency * d = nullptr); bool has_lower(expr * c, numeral & v, bool & strict) const { limit l; @@ -76,14 +76,14 @@ public: expr_dependency * d; if (m_lower_deps.find(c, d)) return d; - return 0; + return nullptr; } expr_dependency * upper_dep(expr * c) const { expr_dependency * d; if (m_upper_deps.find(c, d)) return d; - return 0; + return nullptr; } bool has_lower(expr * c) const { diff --git a/src/tactic/arith/bound_propagator.cpp b/src/tactic/arith/bound_propagator.cpp index 51499674b..4ddfe9721 100644 --- a/src/tactic/arith/bound_propagator.cpp +++ b/src/tactic/arith/bound_propagator.cpp @@ -182,7 +182,7 @@ void bound_propagator::mk_eq(unsigned sz, mpz * as, var * xs) { } void bound_propagator::init_eq(linear_equation * eq) { - if (eq == 0) + if (eq == nullptr) return; unsigned c_idx = m_constraints.size(); m_constraints.push_back(constraint()); @@ -383,7 +383,7 @@ bool bound_propagator::relevant_bound(var x, double new_k) const { if (LOWER && has_lower(x)) tout << "old: " << m.to_string(m_lowers[x]->m_k) << " | " << m_lowers[x]->m_approx_k << "\n"; if (!LOWER && has_upper(x)) tout << "old: " << m.to_string(m_uppers[x]->m_k) << " | " << m_uppers[x]->m_approx_k << "\n";); bound * b = LOWER ? m_lowers[x] : m_uppers[x]; - if (b == 0) + if (b == nullptr) return true; // variable did not have a bound double interval_size; @@ -537,7 +537,7 @@ bool bound_propagator::propagate_eq(unsigned c_idx) { bound * u_i = m_uppers[x_i]; if (a_i < 0.0) { if (!ll_failed) { - if (l_i == 0) { + if (l_i == nullptr) { if (ll_i == UINT_MAX) ll_i = i; else @@ -549,7 +549,7 @@ bool bound_propagator::propagate_eq(unsigned c_idx) { } if (!uu_failed) { - if (u_i == 0) { + if (u_i == nullptr) { if (uu_i == UINT_MAX) uu_i = i; else @@ -562,7 +562,7 @@ bool bound_propagator::propagate_eq(unsigned c_idx) { } else { if (!ll_failed) { - if (u_i == 0) { + if (u_i == nullptr) { if (ll_i == UINT_MAX) ll_i = i; else @@ -574,7 +574,7 @@ bool bound_propagator::propagate_eq(unsigned c_idx) { } if (!uu_failed) { - if (l_i == 0) { + if (l_i == nullptr) { if (uu_i == UINT_MAX) uu_i = i; else @@ -780,7 +780,7 @@ bool bound_propagator::upper(var x, mpq & k, bool & strict, unsigned & ts) const bound_propagator::bound * bound_propagator::bound::at(unsigned timestamp) { bound * r = this; - while (r != 0 && r->m_timestamp >= timestamp) + while (r != nullptr && r->m_timestamp >= timestamp) r = r->m_prev; return r; } diff --git a/src/tactic/arith/bv2int_rewriter.cpp b/src/tactic/arith/bv2int_rewriter.cpp index 4315b0f5f..c4c13e316 100644 --- a/src/tactic/arith/bv2int_rewriter.cpp +++ b/src/tactic/arith/bv2int_rewriter.cpp @@ -38,7 +38,7 @@ void bv2int_rewriter_ctx::collect_power2(goal const& s) { expr* f = s.form(j); if (!m.is_or(f)) continue; unsigned sz = to_app(f)->get_num_args(); - expr* x, *y, *v = 0; + expr* x, *y, *v = nullptr; rational n; vector bounds; bool is_int, ok = true; @@ -50,12 +50,12 @@ void bv2int_rewriter_ctx::collect_power2(goal const& s) { break; } if (arith.is_numeral(y, n, is_int) && is_int && - (x == v || v == 0)) { + (x == v || v == nullptr)) { v = x; bounds.push_back(n); } else if (arith.is_numeral(x, n, is_int) && is_int && - (y == v || v == 0)) { + (y == v || v == nullptr)) { v = y; bounds.push_back(n); } diff --git a/src/tactic/arith/bv2int_rewriter.h b/src/tactic/arith/bv2int_rewriter.h index 9ef256197..89a572d12 100644 --- a/src/tactic/arith/bv2int_rewriter.h +++ b/src/tactic/arith/bv2int_rewriter.h @@ -103,7 +103,7 @@ struct bv2int_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); } bv2int_rewriter_cfg(ast_manager & m, bv2int_rewriter_ctx& ctx):m_r(m, ctx) {} diff --git a/src/tactic/arith/bv2real_rewriter.h b/src/tactic/arith/bv2real_rewriter.h index f020f9f1e..e03637453 100644 --- a/src/tactic/arith/bv2real_rewriter.h +++ b/src/tactic/arith/bv2real_rewriter.h @@ -181,7 +181,7 @@ struct bv2real_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); } bv2real_rewriter_cfg(ast_manager & m, bv2real_util& u):m_r(m, u) {} @@ -216,7 +216,7 @@ struct bv2real_elim_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); } bv2real_elim_rewriter_cfg(bv2real_util& u):m_r(u) {} diff --git a/src/tactic/arith/card2bv_tactic.cpp b/src/tactic/arith/card2bv_tactic.cpp index b268ea3de..b86628f0b 100644 --- a/src/tactic/arith/card2bv_tactic.cpp +++ b/src/tactic/arith/card2bv_tactic.cpp @@ -58,7 +58,7 @@ public: expr_dependency_ref & core) override { TRACE("card2bv-before", g->display(tout);); SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); tactic_report report("card2bv", *g); th_rewriter rw1(m, m_params); pb2bv_rewriter rw2(m, m_params); diff --git a/src/tactic/arith/card2bv_tactic.h b/src/tactic/arith/card2bv_tactic.h index 287dfa27e..e11c78048 100644 --- a/src/tactic/arith/card2bv_tactic.h +++ b/src/tactic/arith/card2bv_tactic.h @@ -79,7 +79,7 @@ namespace pb { 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); } card2bv_rewriter_cfg(ast_manager & m):m_r(m) {} diff --git a/src/tactic/arith/degree_shift_tactic.cpp b/src/tactic/arith/degree_shift_tactic.cpp index 778a73ba5..59e83908f 100644 --- a/src/tactic/arith/degree_shift_tactic.cpp +++ b/src/tactic/arith/degree_shift_tactic.cpp @@ -94,7 +94,7 @@ class degree_shift_tactic : public tactic { m_autil(_m), m_pinned(_m), m_one(1), - m_rw(0) { + m_rw(nullptr) { } @@ -205,8 +205,8 @@ class degree_shift_tactic : public tactic { void prepare_substitution(model_converter_ref & mc) { SASSERT(!m_var2degree.empty()); - filter_model_converter * fmc = 0; - extension_model_converter * xmc = 0; + filter_model_converter * fmc = nullptr; + extension_model_converter * xmc = nullptr; if (m_produce_models) { fmc = alloc(filter_model_converter, m); xmc = alloc(extension_model_converter, m); @@ -217,7 +217,7 @@ class degree_shift_tactic : public tactic { for (; it != end; ++it) { SASSERT(it->m_value.is_int()); SASSERT(it->m_value >= rational(2)); - app * fresh = m.mk_fresh_const(0, it->m_key->get_decl()->get_range()); + app * fresh = m.mk_fresh_const(nullptr, it->m_key->get_decl()->get_range()); m_pinned.push_back(fresh); m_var2var.insert(it->m_key, fresh); if (m_produce_models) { @@ -241,7 +241,7 @@ class degree_shift_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; m_produce_proofs = g->proofs_enabled(); m_produce_models = g->models_enabled(); tactic_report report("degree_shift", *g); @@ -275,12 +275,12 @@ class degree_shift_tactic : public tactic { if (it->m_value.is_even()) { app * new_var = m_var2var.find(it->m_key); app * new_c = m_autil.mk_ge(new_var, m_autil.mk_numeral(rational(0), false)); - proof * new_pr = 0; + proof * new_pr = nullptr; if (m_produce_proofs) { proof * pr = m_var2pr.find(it->m_key); new_pr = m.mk_th_lemma(m_autil.get_family_id(), new_c, 1, &pr); } - g->assert_expr(new_c, new_pr, 0); + g->assert_expr(new_c, new_pr, nullptr); } } } diff --git a/src/tactic/arith/diff_neq_tactic.cpp b/src/tactic/arith/diff_neq_tactic.cpp index 90dcf099c..13f30e19d 100644 --- a/src/tactic/arith/diff_neq_tactic.cpp +++ b/src/tactic/arith/diff_neq_tactic.cpp @@ -319,7 +319,7 @@ class diff_neq_tactic : public tactic { expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); m_produce_models = g->models_enabled(); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); tactic_report report("diff-neq", *g); fail_if_proof_generation("diff-neq", g); fail_if_unsat_core_generation("diff-neq", g); diff --git a/src/tactic/arith/elim01_tactic.cpp b/src/tactic/arith/elim01_tactic.cpp index 7a923cf0a..46c6f1e1c 100644 --- a/src/tactic/arith/elim01_tactic.cpp +++ b/src/tactic/arith/elim01_tactic.cpp @@ -153,7 +153,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("elim01", *g); diff --git a/src/tactic/arith/eq2bv_tactic.cpp b/src/tactic/arith/eq2bv_tactic.cpp index 1219b980e..2a1af28fc 100644 --- a/src/tactic/arith/eq2bv_tactic.cpp +++ b/src/tactic/arith/eq2bv_tactic.cpp @@ -59,7 +59,7 @@ class eq2bv_tactic : public tactic { 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 mk_app_core(f, num, args, result); } eq_rewriter_cfg(eq2bv_tactic& t):m(t.m), t(t) {} @@ -149,7 +149,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; m_trail.reset(); m_fd.reset(); m_max.reset(); @@ -175,7 +175,7 @@ public: expr_ref new_curr(m); proof_ref new_pr(m); if (is_bound(g->form(i))) { - g->update(i, m.mk_true(), 0, 0); + g->update(i, m.mk_true(), nullptr, nullptr); continue; } m_rw(g->form(i), new_curr, new_pr); diff --git a/src/tactic/arith/factor_tactic.cpp b/src/tactic/arith/factor_tactic.cpp index ed49e11f7..d65d3abaf 100644 --- a/src/tactic/arith/factor_tactic.cpp +++ b/src/tactic/arith/factor_tactic.cpp @@ -262,7 +262,7 @@ class factor_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("factor", *g); bool produce_proofs = g->proofs_enabled(); diff --git a/src/tactic/arith/fix_dl_var_tactic.cpp b/src/tactic/arith/fix_dl_var_tactic.cpp index 0e0a15ba6..a9331c9a2 100644 --- a/src/tactic/arith/fix_dl_var_tactic.cpp +++ b/src/tactic/arith/fix_dl_var_tactic.cpp @@ -44,7 +44,7 @@ class fix_dl_var_tactic : public tactic { m_util(u) { } - void throw_failed(expr * ctx1, expr * ctx2 = 0) { + void throw_failed(expr * ctx1, expr * ctx2 = nullptr) { TRACE("fix_dl_var", tout << mk_ismt2_pp(ctx1, m) << "\n"; if (ctx2) tout << mk_ismt2_pp(ctx2, m) << "\n";); throw failed(); } @@ -178,7 +178,7 @@ class fix_dl_var_tactic : public tactic { } app * most_occs(obj_map & occs, unsigned & best) { - app * r = 0; + app * r = nullptr; best = 0; obj_map::iterator it = occs.begin(); obj_map::iterator end = occs.end(); @@ -227,7 +227,7 @@ class fix_dl_var_tactic : public tactic { return most_occs(); } catch (failed) { - return 0; + return nullptr; } } }; @@ -254,13 +254,13 @@ class fix_dl_var_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("fix-dl-var", *g); bool produce_proofs = g->proofs_enabled(); m_produce_models = g->models_enabled(); app * var = is_target(u)(*g); - if (var != 0) { + if (var != nullptr) { IF_VERBOSE(TACTIC_VERBOSITY_LVL, verbose_stream() << "(fixing-at-zero " << var->get_decl()->get_name() << ")\n";); tactic_report report("fix-dl-var", *g); diff --git a/src/tactic/arith/fm_tactic.cpp b/src/tactic/arith/fm_tactic.cpp index 9a27d6874..882836d3f 100644 --- a/src/tactic/arith/fm_tactic.cpp +++ b/src/tactic/arith/fm_tactic.cpp @@ -54,7 +54,7 @@ class fm_tactic : public tactic { bool is_false(model_ref & md, app * p) { SASSERT(is_uninterp_const(p)); expr * val = md->get_const_interp(p->get_decl()); - if (val == 0) { + if (val == nullptr) { // if it is don't care, then set to false md->register_decl(p->get_decl(), m.mk_false()); return true; @@ -828,7 +828,7 @@ class fm_tactic : public tactic { reset_constraints(); m_bvar2expr.reset(); m_bvar2sign.reset(); - m_bvar2expr.push_back(0); // bvar 0 is not used + m_bvar2expr.push_back(nullptr); // bvar 0 is not used m_bvar2sign.push_back(0); m_expr2var.reset(); m_is_int.reset(); @@ -838,11 +838,11 @@ class fm_tactic : public tactic { m_expr2var.reset(); m_lowers.reset(); m_uppers.reset(); - m_new_goal = 0; - m_mc = 0; + m_new_goal = nullptr; + m_mc = nullptr; m_counter = 0; m_inconsistent = false; - m_inconsistent_core = 0; + m_inconsistent_core = nullptr; init_forbidden_set(g); } @@ -878,7 +878,7 @@ class fm_tactic : public tactic { // 0 <= 0 -- > true if (c.m_c.is_pos() || (!c.m_strict && c.m_c.is_zero())) return m.mk_true(); - ineq = 0; + ineq = nullptr; } else { bool int_cnstr = all_int(c); @@ -1115,7 +1115,7 @@ class fm_tactic : public tactic { } else { TRACE("add_constraint_bug", tout << "all variables are forbidden "; display(tout, *c); tout << "\n";); - m_new_goal->assert_expr(to_expr(*c), 0, c->m_dep); + m_new_goal->assert_expr(to_expr(*c), nullptr, c->m_dep); del_constraint(c); return false; } @@ -1130,7 +1130,7 @@ class fm_tactic : public tactic { if (is_occ(f)) add_constraint(f, g.dep(i)); else - m_new_goal->assert_expr(f, 0, g.dep(i)); + m_new_goal->assert_expr(f, nullptr, g.dep(i)); } } @@ -1367,7 +1367,7 @@ class fm_tactic : public tactic { display(tout, l); tout << "\n"; display(tout, u); tout << "\n";); - return 0; // no constraint needs to be created. + return nullptr; // no constraint needs to be created. } new_lits.reset(); @@ -1411,7 +1411,7 @@ class fm_tactic : public tactic { display(tout, l); tout << "\n"; display(tout, u); tout << "\n";); - return 0; + return nullptr; } expr_dependency * new_dep = m.mk_join(l.m_dep, u.m_dep); @@ -1423,7 +1423,7 @@ class fm_tactic : public tactic { display(tout, u); tout << "\n";); m_inconsistent = true; m_inconsistent_core = new_dep; - return 0; + return nullptr; } constraint * new_cnstr = mk_constraint(new_lits.size(), @@ -1493,7 +1493,7 @@ class fm_tactic : public tactic { constraint const & l_c = *(l[i]); constraint const & u_c = *(u[j]); constraint * new_c = resolve(l_c, u_c, x); - if (new_c != 0) { + if (new_c != nullptr) { num_new_cnstrs++; new_constraints.push_back(new_c); } @@ -1528,7 +1528,7 @@ class fm_tactic : public tactic { c->m_dead = true; expr * new_f = to_expr(*c); TRACE("fm_bug", tout << "asserting...\n" << mk_ismt2_pp(new_f, m) << "\nnew_dep: " << c->m_dep << "\n";); - m_new_goal->assert_expr(new_f, 0, c->m_dep); + m_new_goal->assert_expr(new_f, nullptr, c->m_dep); } } } @@ -1555,7 +1555,7 @@ class fm_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("fm", *g); fail_if_proof_generation("fm", g); m_produce_models = g->models_enabled(); @@ -1571,7 +1571,7 @@ class fm_tactic : public tactic { if (m_inconsistent) { m_new_goal->reset(); - m_new_goal->assert_expr(m.mk_false(), 0, m_inconsistent_core); + m_new_goal->assert_expr(m.mk_false(), nullptr, m_inconsistent_core); } else { TRACE("fm", display(tout);); @@ -1595,7 +1595,7 @@ class fm_tactic : public tactic { eliminated++; if (m_inconsistent) { m_new_goal->reset(); - m_new_goal->assert_expr(m.mk_false(), 0, m_inconsistent_core); + m_new_goal->assert_expr(m.mk_false(), nullptr, m_inconsistent_core); break; } } diff --git a/src/tactic/arith/lia2card_tactic.cpp b/src/tactic/arith/lia2card_tactic.cpp index 8b95d0781..7f005b4b3 100644 --- a/src/tactic/arith/lia2card_tactic.cpp +++ b/src/tactic/arith/lia2card_tactic.cpp @@ -112,7 +112,7 @@ class lia2card_tactic : public tactic { 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 mk_app_core(f, num, args, result); } lia_rewriter_cfg(lia2card_tactic& t):m(t.m), t(t), a(m), args(m) {} @@ -164,7 +164,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; m_01s->reset(); tactic_report report("cardinality-intro", *g); diff --git a/src/tactic/arith/lia2pb_tactic.cpp b/src/tactic/arith/lia2pb_tactic.cpp index ce21aa824..48cbb76ef 100644 --- a/src/tactic/arith/lia2pb_tactic.cpp +++ b/src/tactic/arith/lia2pb_tactic.cpp @@ -197,7 +197,7 @@ class lia2pb_tactic : public tactic { fail_if_proof_generation("lia2pb", g); m_produce_models = g->models_enabled(); m_produce_unsat_cores = g->unsat_core_enabled(); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); tactic_report report("lia2pb", *g); m_bm.reset(); m_rw.reset(); m_new_deps.reset(); @@ -224,8 +224,8 @@ class lia2pb_tactic : public tactic { if (!check_num_bits()) throw tactic_exception("lia2pb failed, number of necessary bits exceeds specified threshold (use option :lia2pb-total-bits to increase threshold)"); - extension_model_converter * mc1 = 0; - filter_model_converter * mc2 = 0; + extension_model_converter * mc1 = nullptr; + filter_model_converter * mc2 = nullptr; if (m_produce_models) { mc1 = alloc(extension_model_converter, m); mc2 = alloc(filter_model_converter, m); @@ -251,7 +251,7 @@ class lia2pb_tactic : public tactic { rational a(1); unsigned num_bits = u.get_num_bits(); for (unsigned i = 0; i < num_bits; i++) { - app * x_prime = m.mk_fresh_const(0, m_util.mk_int()); + app * x_prime = m.mk_fresh_const(nullptr, m_util.mk_int()); g->assert_expr(m_util.mk_le(zero, x_prime)); g->assert_expr(m_util.mk_le(x_prime, one)); if (a.is_one()) @@ -264,14 +264,14 @@ class lia2pb_tactic : public tactic { } SASSERT(def_args.size() > 1); expr * def = m_util.mk_add(def_args.size(), def_args.c_ptr()); - expr_dependency * dep = 0; + expr_dependency * dep = nullptr; if (m_produce_unsat_cores) { dep = m.mk_join(m_bm.lower_dep(x), m_bm.upper_dep(x)); - if (dep != 0) + if (dep != nullptr) m_new_deps.push_back(dep); } TRACE("lia2pb", tout << mk_ismt2_pp(x, m) << " -> " << dep << "\n";); - subst.insert(x, def, 0, dep); + subst.insert(x, def, nullptr, dep); if (m_produce_models) { mc1->insert(to_app(x)->get_decl(), def); } @@ -287,7 +287,7 @@ class lia2pb_tactic : public tactic { unsigned size = g->size(); for (unsigned idx = 0; idx < size; idx++) { expr * curr = g->form(idx); - expr_dependency * dep = 0; + expr_dependency * dep = nullptr; m_rw(curr, new_curr, new_pr); if (m_produce_unsat_cores) { dep = m.mk_join(m_rw.get_used_dependencies(), g->dep(idx)); diff --git a/src/tactic/arith/linear_equation.cpp b/src/tactic/arith/linear_equation.cpp index ed158b778..5db0a4cf9 100644 --- a/src/tactic/arith/linear_equation.cpp +++ b/src/tactic/arith/linear_equation.cpp @@ -174,7 +174,7 @@ linear_equation * linear_equation_manager::mk(unsigned sz, mpz * as, var * xs, b } sz = j; if (sz <= 1) - return 0; + return nullptr; } else { DEBUG_CODE({ @@ -265,7 +265,7 @@ linear_equation * linear_equation_manager::mk(mpz const & b1, linear_equation co m.del(new_a); SASSERT(m_int_buffer.size() == m_var_buffer.size()); if (m_int_buffer.empty()) - return 0; + return nullptr; return mk_core(m_int_buffer.size(), m_int_buffer.c_ptr(), m_var_buffer.c_ptr()); } diff --git a/src/tactic/arith/nla2bv_tactic.cpp b/src/tactic/arith/nla2bv_tactic.cpp index 08eb97c4b..9a5c33ce6 100644 --- a/src/tactic/arith/nla2bv_tactic.cpp +++ b/src/tactic/arith/nla2bv_tactic.cpp @@ -75,7 +75,7 @@ class nla2bv_tactic : public tactic { m_vars(m), m_defs(m), m_trail(m), - m_fmc(0) { + m_fmc(nullptr) { m_default_bv_size = m_num_bits = p.get_uint("nla2bv_bv_size", 4); } @@ -408,14 +408,14 @@ class nla2bv_tactic : public tactic { } ~scoped_set_imp() { - m_owner.m_imp = 0; + m_owner.m_imp = nullptr; } }; public: nla2bv_tactic(params_ref const & p): m_params(p), - m_imp(0) { + m_imp(nullptr) { } tactic * translate(ast_manager & m) override { @@ -449,7 +449,7 @@ public: SASSERT(g->is_well_sorted()); fail_if_proof_generation("nla2bv", g); fail_if_unsat_core_generation("nla2bv", g); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); imp proc(g->m(), m_params); scoped_set_imp setter(*this, proc); diff --git a/src/tactic/arith/normalize_bounds_tactic.cpp b/src/tactic/arith/normalize_bounds_tactic.cpp index a9eeb3744..b7cc09e25 100644 --- a/src/tactic/arith/normalize_bounds_tactic.cpp +++ b/src/tactic/arith/normalize_bounds_tactic.cpp @@ -85,7 +85,7 @@ class normalize_bounds_tactic : public tactic { model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; bool produce_models = in->models_enabled(); bool produce_proofs = in->proofs_enabled(); tactic_report report("normalize-bounds", *in); @@ -98,8 +98,8 @@ class normalize_bounds_tactic : public tactic { return; } - extension_model_converter * mc1 = 0; - filter_model_converter * mc2 = 0; + extension_model_converter * mc1 = nullptr; + filter_model_converter * mc2 = nullptr; if (produce_models) { mc1 = alloc(extension_model_converter, m); mc2 = alloc(filter_model_converter, m); @@ -116,7 +116,7 @@ class normalize_bounds_tactic : public tactic { if (is_target(x, val)) { num_norm_bounds++; sort * s = m.get_sort(x); - app * x_prime = m.mk_fresh_const(0, s); + app * x_prime = m.mk_fresh_const(nullptr, s); expr * def = m_util.mk_add(x_prime, m_util.mk_numeral(val, s)); subst.insert(x, def); if (produce_models) { diff --git a/src/tactic/arith/pb2bv_model_converter.cpp b/src/tactic/arith/pb2bv_model_converter.cpp index df5bd5745..5dc4c1737 100644 --- a/src/tactic/arith/pb2bv_model_converter.cpp +++ b/src/tactic/arith/pb2bv_model_converter.cpp @@ -43,7 +43,7 @@ pb2bv_model_converter::pb2bv_model_converter(ast_manager & _m, obj_mapget_arity() == 0); m.inc_ref(d); - m_c2bit.push_back(func_decl_pair(d, static_cast(0))); + m_c2bit.push_back(func_decl_pair(d, static_cast(nullptr))); } } } @@ -71,7 +71,7 @@ void pb2bv_model_converter::operator()(model_ref & md, unsigned goal_idx) { for (; it != end; ++it) { if (it->second) { expr * val = md->get_const_interp(it->second); - if (val == 0 || m.is_false(val)) { + if (val == nullptr || m.is_false(val)) { /* false's and don't cares get the integer 0 solution*/ md->register_decl(it->first, a_util.mk_numeral(rational(0), true)); } diff --git a/src/tactic/arith/pb2bv_tactic.cpp b/src/tactic/arith/pb2bv_tactic.cpp index 05b91cf53..170a10f91 100644 --- a/src/tactic/arith/pb2bv_tactic.cpp +++ b/src/tactic/arith/pb2bv_tactic.cpp @@ -216,7 +216,7 @@ private: } bool get_subst(expr * s, expr * & t, proof * & t_pr) { - t_pr = 0; + t_pr = nullptr; if (owner.is_constraint_core(s)) { owner.convert(to_app(s), m_saved_res, true, false); t = m_saved_res; @@ -328,12 +328,12 @@ private: func_decl * fd = x->get_decl(); obj_map & const2lit = sign ? m_not_const2bit : m_const2bit; - expr * r = 0; + expr * r = nullptr; const2lit.find(fd, r); - if (r != 0) + if (r != nullptr) return r; - r = m.mk_fresh_const(0, m.mk_bool_sort()); + r = m.mk_fresh_const(nullptr, m.mk_bool_sort()); expr * not_r = m.mk_not(r); m_const2bit.insert(fd, r); m_not_const2bit.insert(fd, not_r); @@ -490,7 +490,7 @@ private: for (unsigned j = 0; j < i; j++) m_clause.push_back(monomial(numeral(1), m_p[j].m_lit)); - app * new_var = m.mk_fresh_const(0, m_arith_util.mk_int()); + app * new_var = m.mk_fresh_const(nullptr, m_arith_util.mk_int()); m_temporary_ints.push_back(new_var); m_clause.push_back(monomial(numeral(1), lit(new_var, true))); @@ -895,7 +895,7 @@ private: fail_if_proof_generation("pb2bv", g); m_produce_models = g->models_enabled(); m_produce_unsat_cores = g->unsat_core_enabled(); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); tactic_report report("pb2bv", *g); m_bm.reset(); m_rw.reset(); m_new_deps.reset(); @@ -946,7 +946,7 @@ private: } for (unsigned idx = 0; idx < size; idx++) - g->update(idx, new_exprs[idx].get(), 0, (m_produce_unsat_cores) ? new_deps[idx].get() : g->dep(idx)); + g->update(idx, new_exprs[idx].get(), nullptr, (m_produce_unsat_cores) ? new_deps[idx].get() : g->dep(idx)); if (m_produce_models) { filter_model_converter * mc1 = alloc(filter_model_converter, m); diff --git a/src/tactic/arith/propagate_ineqs_tactic.cpp b/src/tactic/arith/propagate_ineqs_tactic.cpp index cbb29f6b4..38bb38330 100644 --- a/src/tactic/arith/propagate_ineqs_tactic.cpp +++ b/src/tactic/arith/propagate_ineqs_tactic.cpp @@ -354,7 +354,7 @@ struct propagate_ineqs_tactic::imp { void find_ite_bounds(expr * root) { TRACE("find_ite_bounds_bug", display_bounds(tout);); expr * n = root; - expr * target = 0; + expr * target = nullptr; expr * c, * t, * e; expr * x, * y; bool has_l, has_u; @@ -374,7 +374,7 @@ struct propagate_ineqs_tactic::imp { break; } else if (is_x_minus_y_eq_0(n, x, y)) { - n = 0; + n = nullptr; } else { break; @@ -394,7 +394,7 @@ struct propagate_ineqs_tactic::imp { break; } - if (target == 0) { + if (target == nullptr) { target = x; if (lower(y, curr, curr_strict)) { has_l = true; @@ -448,7 +448,7 @@ struct propagate_ineqs_tactic::imp { if (!has_l && !has_u) break; - if (n == 0) { + if (n == nullptr) { TRACE("find_ite_bounds", tout << "found bounds for: " << mk_ismt2_pp(target, m) << "\n"; tout << "has_l: " << has_l << " " << nm.to_string(l_min) << " l_strict: " << l_strict << "\n"; tout << "has_u: " << has_u << " " << nm.to_string(u_max) << " u_strict: " << u_strict << "\n"; @@ -484,7 +484,7 @@ struct propagate_ineqs_tactic::imp { m_new_goal->inc_depth(); r = m_new_goal.get(); if (!collect_bounds(*g)) { - m_new_goal = 0; + m_new_goal = nullptr; r = g; return; // nothing to be done } @@ -534,7 +534,7 @@ void propagate_ineqs_tactic::operator()(goal_ref const & g, SASSERT(g->is_well_sorted()); fail_if_proof_generation("propagate-ineqs", g); fail_if_unsat_core_generation("propagate-ineqs", g); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); goal_ref r; (*m_imp)(g.get(), r); result.push_back(r.get()); diff --git a/src/tactic/arith/purify_arith_tactic.cpp b/src/tactic/arith/purify_arith_tactic.cpp index 38ea0a2b9..0774c036d 100644 --- a/src/tactic/arith/purify_arith_tactic.cpp +++ b/src/tactic/arith/purify_arith_tactic.cpp @@ -170,8 +170,8 @@ struct purify_arith_proc { } std::pair pair; if (!m_sin_cos.find(to_app(theta), pair)) { - pair.first = m().mk_fresh_const(0, u().mk_real()); - pair.second = m().mk_fresh_const(0, u().mk_real()); + pair.first = m().mk_fresh_const(nullptr, u().mk_real()); + pair.second = m().mk_fresh_const(nullptr, u().mk_real()); m_sin_cos.insert(to_app(theta), pair); m_pinned.push_back(pair.first); m_pinned.push_back(pair.second); @@ -214,7 +214,7 @@ struct purify_arith_proc { bool elim_inverses() const { return m_owner.m_elim_inverses; } expr * mk_fresh_var(bool is_int) { - expr * r = m().mk_fresh_const(0, is_int ? u().mk_int() : u().mk_real()); + expr * r = m().mk_fresh_const(nullptr, is_int ? u().mk_int() : u().mk_real()); m_new_vars.push_back(r); return r; } @@ -241,7 +241,7 @@ struct purify_arith_proc { } void mk_def_proof(expr * k, expr * def, proof_ref & result_pr) { - result_pr = 0; + result_pr = nullptr; if (produce_proofs()) { expr * eq = m().mk_eq(k, def); proof * pr1 = m().mk_def_intro(eq); @@ -691,7 +691,7 @@ struct purify_arith_proc { }; void process_quantifier(quantifier * q, expr_ref & result, proof_ref & result_pr) { - result_pr = 0; + result_pr = nullptr; rw r(*this); expr_ref new_body(m()); proof_ref new_body_pr(m()); @@ -761,7 +761,7 @@ struct purify_arith_proc { sz = r.cfg().m_new_cnstrs.size(); TRACE("purify_arith", tout << r.cfg().m_new_cnstrs << "\n";); for (unsigned i = 0; i < sz; i++) { - m_goal.assert_expr(r.cfg().m_new_cnstrs.get(i), m_produce_proofs ? r.cfg().m_new_cnstr_prs.get(i) : 0, 0); + m_goal.assert_expr(r.cfg().m_new_cnstrs.get(i), m_produce_proofs ? r.cfg().m_new_cnstr_prs.get(i) : nullptr, nullptr); } // add filter_model_converter to eliminate auxiliary variables from model @@ -830,7 +830,7 @@ public: expr_dependency_ref & core) override { try { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("purify-arith", *g); TRACE("purify_arith", g->display(tout);); bool produce_proofs = g->proofs_enabled(); diff --git a/src/tactic/arith/recover_01_tactic.cpp b/src/tactic/arith/recover_01_tactic.cpp index cf2beacb2..b1666eb7b 100644 --- a/src/tactic/arith/recover_01_tactic.cpp +++ b/src/tactic/arith/recover_01_tactic.cpp @@ -70,7 +70,7 @@ class recover_01_tactic : public tactic { bool save_clause(expr * c) { if (!m.is_or(c)) return false; - func_decl * x = 0; + func_decl * x = nullptr; app * cls = to_app(c); if (cls->get_num_args() <= 1 || cls->get_num_args() >= m_cls_max_size) return false; @@ -84,7 +84,7 @@ class recover_01_tactic : public tactic { else if (m.is_not(lit, arg) && is_uninterp_const(arg)) { // negative literal } - else if (x == 0 && m.is_eq(lit, lhs, rhs)) { + else if (x == nullptr && m.is_eq(lit, lhs, rhs)) { // x = k literal if (is_uninterp_const(lhs) && m_util.is_numeral(rhs)) { x = to_app(lhs)->get_decl(); @@ -101,7 +101,7 @@ class recover_01_tactic : public tactic { } } - if (x != 0) { + if (x != nullptr) { var2clauses::obj_map_entry * entry = m_var2clauses.insert_if_not_there2(x, ptr_vector()); if (entry->get_data().m_value.empty() || entry->get_data().m_value.back()->get_num_args() == cls->get_num_args()) { entry->get_data().m_value.push_back(cls); @@ -134,7 +134,7 @@ class recover_01_tactic : public tactic { } } } - return 0; + return nullptr; } // Find coeff (the k of literal (x = k)) of clause cls. @@ -199,7 +199,7 @@ class recover_01_tactic : public tactic { SASSERT(is_uninterp_const(atom)); expr * var; if (!bool2int.find(atom, var)) { - var = m.mk_fresh_const(0, m_util.mk_int()); + var = m.mk_fresh_const(nullptr, m_util.mk_int()); new_goal->assert_expr(m_util.mk_le(m_util.mk_numeral(rational(0), true), var)); new_goal->assert_expr(m_util.mk_le(var, m_util.mk_numeral(rational(1), true))); expr * bool_def = m.mk_eq(var, m_util.mk_numeral(rational(1), true)); @@ -225,7 +225,7 @@ class recover_01_tactic : public tactic { if (clauses.size() < expected_num_clauses) // using < instead of != because we tolerate duplicates return false; app * zero_cls = find_zero_cls(x, clauses); - if (zero_cls == 0) + if (zero_cls == nullptr) return false; buffer found; // marks which idx were found @@ -302,7 +302,7 @@ class recover_01_tactic : public tactic { fail_if_proof_generation("recover-01", g); fail_if_unsat_core_generation("recover-01", g); m_produce_models = g->models_enabled(); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); tactic_report report("recover-01", *g); bool saved = false; @@ -357,7 +357,7 @@ class recover_01_tactic : public tactic { if (!recovered) { result.push_back(g.get()); - mc = 0; + mc = nullptr; return; } diff --git a/src/tactic/bv/bit_blaster_model_converter.cpp b/src/tactic/bv/bit_blaster_model_converter.cpp index 2a1ddcd4a..027938752 100644 --- a/src/tactic/bv/bit_blaster_model_converter.cpp +++ b/src/tactic/bv/bit_blaster_model_converter.cpp @@ -118,7 +118,7 @@ struct bit_blaster_model_converter : public model_converter { func_decl * bit_decl = to_app(bit)->get_decl(); expr * bit_val = old_model->get_const_interp(bit_decl); // remark: if old_model does not assign bit_val, then assume it is false. - if (bit_val != 0 && m().is_true(bit_val)) + if (bit_val != nullptr && m().is_true(bit_val)) val++; } } @@ -133,7 +133,7 @@ struct bit_blaster_model_converter : public model_converter { func_decl * bit_decl = to_app(bit)->get_decl(); expr * bit_val = old_model->get_const_interp(bit_decl); // remark: if old_model does not assign bit_val, then assume it is false. - if (bit_val != 0 && !util.is_zero(bit_val)) + if (bit_val != nullptr && !util.is_zero(bit_val)) val++; } } diff --git a/src/tactic/bv/bit_blaster_tactic.cpp b/src/tactic/bv/bit_blaster_tactic.cpp index a44f32044..a8f302752 100644 --- a/src/tactic/bv/bit_blaster_tactic.cpp +++ b/src/tactic/bv/bit_blaster_tactic.cpp @@ -55,7 +55,7 @@ class bit_blaster_tactic : public tactic { model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; bool proofs_enabled = g->proofs_enabled(); if (proofs_enabled && m_blast_quant) @@ -90,7 +90,7 @@ class bit_blaster_tactic : public tactic { if (change && g->models_enabled()) mc = mk_bit_blaster_model_converter(m(), m_rewriter->const2bits()); else - mc = 0; + mc = nullptr; g->inc_depth(); result.push_back(g.get()); TRACE("after_bit_blaster", g->display(tout); if (mc) mc->display(tout); tout << "\n";); @@ -113,7 +113,7 @@ public: tactic * translate(ast_manager & m) override { SASSERT(!m_rewriter); // assume translation isn't used where rewriter is external. - return alloc(bit_blaster_tactic, m, 0, m_params); + return alloc(bit_blaster_tactic, m, nullptr, m_params); } ~bit_blaster_tactic() override { @@ -161,7 +161,7 @@ public: tactic * mk_bit_blaster_tactic(ast_manager & m, params_ref const & p) { - return clean(alloc(bit_blaster_tactic, m, 0, p)); + return clean(alloc(bit_blaster_tactic, m, nullptr, p)); } tactic * mk_bit_blaster_tactic(ast_manager & m, bit_blaster_rewriter* rw, params_ref const & p) { diff --git a/src/tactic/bv/bv1_blaster_tactic.cpp b/src/tactic/bv/bv1_blaster_tactic.cpp index 196835c51..e82948c16 100644 --- a/src/tactic/bv/bv1_blaster_tactic.cpp +++ b/src/tactic/bv/bv1_blaster_tactic.cpp @@ -106,7 +106,7 @@ class bv1_blaster_tactic : public tactic { sort * b = butil().mk_sort(1); ptr_buffer bits; for (unsigned i = 0; i < bv_size; i++) { - bits.push_back(m().mk_fresh_const(0, b)); + bits.push_back(m().mk_fresh_const(nullptr, b)); } r = butil().mk_concat(bits.size(), bits.c_ptr()); m_saved.push_back(r); @@ -253,7 +253,7 @@ class bv1_blaster_tactic : public tactic { } 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 (num == 0 && f->get_family_id() == null_family_id && butil().is_bv_sort(f->get_range())) { mk_const(f, result); return BR_DONE; @@ -383,7 +383,7 @@ class bv1_blaster_tactic : public tactic { model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; if (!is_target(*g)) throw tactic_exception("bv1 blaster cannot be applied to goal"); diff --git a/src/tactic/bv/bv_bound_chk_tactic.cpp b/src/tactic/bv/bv_bound_chk_tactic.cpp index 2d717c0ae..48201501e 100644 --- a/src/tactic/bv/bv_bound_chk_tactic.cpp +++ b/src/tactic/bv/bv_bound_chk_tactic.cpp @@ -68,7 +68,7 @@ struct bv_bound_chk_rewriter_cfg : public default_rewriter_cfg { } br_status reduce_app_core(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) { - result_pr = 0; + result_pr = nullptr; const family_id fid = f->get_family_id(); if (fid != m_b_rw.get_fid()) return BR_FAILED; bv_bounds bvb(m()); @@ -206,7 +206,7 @@ void bv_bound_chk_tactic::operator()(goal_ref const & g, fail_if_proof_generation("bv-bound-chk", g); fail_if_unsat_core_generation("bv-bound-chk", g); TRACE("bv-bound-chk", g->display(tout << "before:"); tout << std::endl;); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); m_imp->operator()(g); g->inc_depth(); result.push_back(g.get()); diff --git a/src/tactic/bv/bv_bounds_tactic.cpp b/src/tactic/bv/bv_bounds_tactic.cpp index 0628b4013..2cd6a5a1b 100644 --- a/src/tactic/bv/bv_bounds_tactic.cpp +++ b/src/tactic/bv/bv_bounds_tactic.cpp @@ -194,7 +194,7 @@ namespace { bool is_bound(expr *e, expr*& v, interval& b) const { uint64 n; - expr *lhs = 0, *rhs = 0; + expr *lhs = nullptr, *rhs = nullptr; unsigned sz; if (m_bv.is_bv_ule(e, lhs, rhs)) { @@ -382,7 +382,7 @@ namespace { } interval ctx, intr; - result = 0; + result = nullptr; if (b.is_full() && b.tight) { result = m.mk_true(); @@ -561,7 +561,7 @@ namespace { bool is_bound(expr *e, expr*& v, interval& b) const { uint64 n; - expr *lhs = 0, *rhs = 0; + expr *lhs = nullptr, *rhs = nullptr; unsigned sz = 0; if (m_bv.is_bv_ule(e, lhs, rhs)) { diff --git a/src/tactic/bv/bv_size_reduction_tactic.cpp b/src/tactic/bv/bv_size_reduction_tactic.cpp index 2c70e554f..3bcb2e02b 100644 --- a/src/tactic/bv/bv_size_reduction_tactic.cpp +++ b/src/tactic/bv/bv_size_reduction_tactic.cpp @@ -184,8 +184,8 @@ struct bv_size_reduction_tactic::imp { return; TRACE("before_bv_size_reduction", g.display(tout);); m_produce_models = g.models_enabled(); - mc = 0; - m_mc = 0; + mc = nullptr; + m_mc = nullptr; unsigned num_reduced = 0; { tactic_report report("bv-size-reduction", g); @@ -211,11 +211,11 @@ struct bv_size_reduction_tactic::imp { unsigned bv_sz = m_util.get_bv_size(v); numeral l = m_util.norm(it->m_value, bv_sz, true); obj_map::obj_map_entry * entry = m_signed_uppers.find_core(v); - if (entry != 0) { + if (entry != nullptr) { numeral u = m_util.norm(entry->get_data().m_value, bv_sz, true); TRACE("bv_size_reduction", tout << l << " <= " << v->get_decl()->get_name() << " <= " << u << "\n";); - expr * new_def = 0; - app * new_const = 0; + expr * new_def = nullptr; + app * new_const = nullptr; if (l > u) { g.assert_expr(m.mk_false()); return; @@ -235,7 +235,7 @@ struct bv_size_reduction_tactic::imp { unsigned i_nb = l_nb; TRACE("bv_size_reduction", tout << " l <= " << v->get_decl()->get_name() << " <= u <= 0 " << " --> " << i_nb << " bits\n";); if (i_nb < v_nb) { - new_const = m.mk_fresh_const(0, m_util.mk_sort(i_nb)); + new_const = m.mk_fresh_const(nullptr, m_util.mk_sort(i_nb)); new_def = m_util.mk_concat(m_util.mk_numeral(numeral(-1), v_nb - i_nb), new_const); } } @@ -245,7 +245,7 @@ struct bv_size_reduction_tactic::imp { unsigned i_nb = ((l_nb > u_nb) ? l_nb : u_nb) + 1; TRACE("bv_size_reduction", tout << " l <= " << v->get_decl()->get_name() << " <= 0 <= u " << " --> " << i_nb << " bits\n";); if (i_nb < v_nb) { - new_const = m.mk_fresh_const(0, m_util.mk_sort(i_nb)); + new_const = m.mk_fresh_const(nullptr, m_util.mk_sort(i_nb)); new_def = m_util.mk_sign_extend(v_nb - i_nb, new_const); } } @@ -256,7 +256,7 @@ struct bv_size_reduction_tactic::imp { unsigned v_nb = m_util.get_bv_size(v); TRACE("bv_size_reduction", tout << l << " <= " << v->get_decl()->get_name() << " <= " << u << " --> " << u_nb << " bits\n";); if (u_nb < v_nb) { - new_const = m.mk_fresh_const(0, m_util.mk_sort(u_nb)); + new_const = m.mk_fresh_const(nullptr, m_util.mk_sort(u_nb)); new_def = m_util.mk_concat(m_util.mk_numeral(numeral(0), v_nb - u_nb), new_const); } } @@ -365,8 +365,8 @@ struct bv_size_reduction_tactic::imp { if (m_fmc) { mc = concat(m_fmc.get(), mc.get()); } - m_mc = 0; - m_fmc = 0; + m_mc = nullptr; + m_fmc = nullptr; } report_tactic_progress(":bv-reduced", num_reduced); TRACE("after_bv_size_reduction", g.display(tout); if (m_mc) m_mc->display(tout);); @@ -390,7 +390,7 @@ void bv_size_reduction_tactic::operator()(goal_ref const & g, SASSERT(g->is_well_sorted()); fail_if_proof_generation("bv-size-reduction", g); fail_if_unsat_core_generation("bv-size-reduction", g); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); m_imp->operator()(*(g.get()), mc); g->inc_depth(); result.push_back(g.get()); diff --git a/src/tactic/bv/bvarray2uf_rewriter.cpp b/src/tactic/bv/bvarray2uf_rewriter.cpp index b92092739..a0f80f38b 100644 --- a/src/tactic/bv/bvarray2uf_rewriter.cpp +++ b/src/tactic/bv/bvarray2uf_rewriter.cpp @@ -37,8 +37,8 @@ bvarray2uf_rewriter_cfg::bvarray2uf_rewriter_cfg(ast_manager & m, params_ref con m_bindings(m), m_bv_util(m), m_array_util(m), - m_emc(0), - m_fmc(0), + m_emc(nullptr), + m_fmc(nullptr), extra_assertions(m) { updt_params(p); // We need to make sure that the mananger has the BV and array plugins loaded. @@ -108,7 +108,7 @@ func_decl_ref bvarray2uf_rewriter_cfg::mk_uf_for_array(expr * e) { if (m_array_util.is_as_array(e)) return func_decl_ref(static_cast(to_app(e)->get_decl()->get_parameter(0).get_ast()), m_manager); else { - func_decl * bv_f = 0; + func_decl * bv_f = nullptr; if (!m_arrays_fs.find(e, bv_f)) { sort * domain = get_index_sort(e); sort * range = get_value_sort(e); @@ -184,7 +184,7 @@ br_status bvarray2uf_rewriter_cfg::reduce_app(func_decl * f, unsigned num, expr func_decl_ref itefd(m_manager); e = m_manager.mk_ite(c, f_ta, f_fa); - func_decl * bv_f = 0; + func_decl * bv_f = nullptr; if (!m_arrays_fs.find(f_a, bv_f)) { sort * domain = get_index_sort(args[1]); sort * range = get_value_sort(args[1]); diff --git a/src/tactic/bv/bvarray2uf_tactic.cpp b/src/tactic/bv/bvarray2uf_tactic.cpp index 844d64429..6287181b1 100644 --- a/src/tactic/bv/bvarray2uf_tactic.cpp +++ b/src/tactic/bv/bvarray2uf_tactic.cpp @@ -61,7 +61,7 @@ class bvarray2uf_tactic : public tactic { { SASSERT(g->is_well_sorted()); tactic_report report("bvarray2uf", *g); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); fail_if_unsat_core_generation("bvarray2uf", g); TRACE("bvarray2uf", tout << "Before: " << std::endl; g->display(tout); ); diff --git a/src/tactic/bv/dt2bv_tactic.cpp b/src/tactic/bv/dt2bv_tactic.cpp index 62093d191..8f164a921 100644 --- a/src/tactic/bv/dt2bv_tactic.cpp +++ b/src/tactic/bv/dt2bv_tactic.cpp @@ -122,7 +122,7 @@ public: model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; bool produce_proofs = g->proofs_enabled(); tactic_report report("dt2bv", *g); unsigned size = g->size(); diff --git a/src/tactic/bv/elim_small_bv_tactic.cpp b/src/tactic/bv/elim_small_bv_tactic.cpp index f5f0c2b88..17887d495 100644 --- a/src/tactic/bv/elim_small_bv_tactic.cpp +++ b/src/tactic/bv/elim_small_bv_tactic.cpp @@ -52,7 +52,7 @@ class elim_small_bv_tactic : public tactic { m_bindings(_m), m_num_eliminated(0) { updt_params(p); - m_goal = 0; + m_goal = nullptr; m_max_steps = UINT_MAX; } @@ -77,13 +77,13 @@ class elim_small_bv_tactic : public tactic { expr_ref res(m); expr_ref_vector substitution(m); - substitution.resize(num_decls, 0); + substitution.resize(num_decls, nullptr); substitution[num_decls - idx - 1] = replacement; // (VAR 0) is in the first position of substitution; (VAR num_decls-1) is in the last position. for (unsigned i = 0; i < max_var_idx_p1; i++) - substitution.push_back(0); + substitution.push_back(nullptr); // (VAR num_decls) ... (VAR num_decls+sz-1); are in positions num_decls .. num_decls+sz-1 @@ -175,7 +175,7 @@ class elim_small_bv_tactic : public tactic { TRACE("elim_small_bv", tout << "elimination result: " << mk_ismt2_pp(result, m) << std::endl; ); - result_pr = 0; // proofs NIY + result_pr = nullptr; // proofs NIY m_bindings.shrink(old_sz); return true; } @@ -230,7 +230,7 @@ class elim_small_bv_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("elim-small-bv", *g); bool produce_proofs = g->proofs_enabled(); fail_if_proof_generation("elim-small-bv", g); diff --git a/src/tactic/bv/max_bv_sharing_tactic.cpp b/src/tactic/bv/max_bv_sharing_tactic.cpp index 0b7d0d345..8054cfdd8 100644 --- a/src/tactic/bv/max_bv_sharing_tactic.cpp +++ b/src/tactic/bv/max_bv_sharing_tactic.cpp @@ -84,7 +84,7 @@ class max_bv_sharing_tactic : public tactic { return m().mk_app(f, arg1, arg2); if (s.contains(expr_pair(arg2, arg1))) return m().mk_app(f, arg2, arg1); - return 0; + return nullptr; } struct ref_count_lt { @@ -106,10 +106,10 @@ class max_bv_sharing_tactic : public tactic { ptr_buffer _args; bool first = false; - expr * num = 0; + expr * num = nullptr; for (unsigned i = 0; i < num_args; i++) { expr * arg = args[i]; - if (num == 0 && m_util.is_numeral(arg)) { + if (num == nullptr && m_util.is_numeral(arg)) { if (i == 0) first = true; num = arg; } @@ -128,7 +128,7 @@ class max_bv_sharing_tactic : public tactic { for (unsigned i = 0; i < num_args - 1; i++) { for (unsigned j = i + 1; j < num_args; j++) { expr * r = reuse(s, f, _args[i], _args[j]); - if (r != 0) { + if (r != nullptr) { TRACE("bv_sharing_detail", tout << "reusing args: " << i << " " << j << "\n";); _args[i] = r; SASSERT(num_args > 1); @@ -186,7 +186,7 @@ class max_bv_sharing_tactic : public tactic { } num_args = j; if (num_args == 1) { - if (num == 0) { + if (num == nullptr) { result = _args[0]; } else { @@ -209,7 +209,7 @@ class max_bv_sharing_tactic : public tactic { case OP_BMUL: case OP_BOR: case OP_BXOR: - result_pr = 0; + result_pr = nullptr; return reduce_ac_app(f, num, args, result); default: return BR_FAILED; @@ -242,7 +242,7 @@ class max_bv_sharing_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("max-bv-sharing", *g); bool produce_proofs = g->proofs_enabled(); diff --git a/src/tactic/converter.h b/src/tactic/converter.h index 924971d27..d50458cf1 100644 --- a/src/tactic/converter.h +++ b/src/tactic/converter.h @@ -84,11 +84,11 @@ protected: template T * translate_core(ast_translation & translator) { - T * t1 = m_c1 ? m_c1->translate(translator) : 0; + T * t1 = m_c1 ? m_c1->translate(translator) : nullptr; ptr_buffer t2s; unsigned num = m_c2s.size(); for (unsigned i = 0; i < num; i++) - t2s.push_back(m_c2s[i] ? m_c2s[i]->translate(translator) : 0); + t2s.push_back(m_c2s[i] ? m_c2s[i]->translate(translator) : nullptr); return alloc(T2, t1, num, t2s.c_ptr(), m_szs.c_ptr()); } diff --git a/src/tactic/core/blast_term_ite_tactic.cpp b/src/tactic/core/blast_term_ite_tactic.cpp index 27d907b63..4082659df 100644 --- a/src/tactic/core/blast_term_ite_tactic.cpp +++ b/src/tactic/core/blast_term_ite_tactic.cpp @@ -120,7 +120,7 @@ class blast_term_ite_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("blast-term-ite", *g); bool produce_proofs = g->proofs_enabled(); diff --git a/src/tactic/core/cofactor_elim_term_ite.cpp b/src/tactic/core/cofactor_elim_term_ite.cpp index b90be82b5..2b3cb8414 100644 --- a/src/tactic/core/cofactor_elim_term_ite.cpp +++ b/src/tactic/core/cofactor_elim_term_ite.cpp @@ -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::iterator it = occs.begin(); obj_map::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 * has_term_ite = 0): + cofactor_rw_cfg(ast_manager & _m, imp & owner, obj_hashtable * 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 m_cfg; public: - cofactor_rw(ast_manager & m, imp & owner, obj_hashtable * has_term_ite = 0): + cofactor_rw(ast_manager & m, imp & owner, obj_hashtable * has_term_ite = nullptr): rewriter_tpl(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; } diff --git a/src/tactic/core/cofactor_term_ite_tactic.cpp b/src/tactic/core/cofactor_term_ite_tactic.cpp index 64c2c0f66..30486358d 100644 --- a/src/tactic/core/cofactor_term_ite_tactic.cpp +++ b/src/tactic/core/cofactor_term_ite_tactic.cpp @@ -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)); } } @@ -63,7 +63,7 @@ public: fail_if_proof_generation("cofactor-term-ite", g); fail_if_unsat_core_generation("cofactor-term-ite", g); tactic_report report("cofactor-term-ite", *g); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; process(*(g.get())); g->inc_depth(); result.push_back(g.get()); diff --git a/src/tactic/core/collect_statistics_tactic.cpp b/src/tactic/core/collect_statistics_tactic.cpp index 166fb6036..0e08395ad 100644 --- a/src/tactic/core/collect_statistics_tactic.cpp +++ b/src/tactic/core/collect_statistics_tactic.cpp @@ -66,7 +66,7 @@ public: void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override { - mc = 0; + mc = nullptr; tactic_report report("collect-statistics", *g); collect_proc cp(m, m_stats); diff --git a/src/tactic/core/ctx_simplify_tactic.cpp b/src/tactic/core/ctx_simplify_tactic.cpp index 89bdcca1c..6ad9c0812 100644 --- a/src/tactic/core/ctx_simplify_tactic.cpp +++ b/src/tactic/core/ctx_simplify_tactic.cpp @@ -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 << ""; 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_star(t, r, 0, nullptr)); // TODO :-) g.update(i, r, new_pr, g.dep(i)); } } @@ -625,7 +625,7 @@ void ctx_simplify_tactic::operator()(goal_ref const & in, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; (*m_imp)(*(in.get())); in->inc_depth(); result.push_back(in.get()); diff --git a/src/tactic/core/der_tactic.cpp b/src/tactic/core/der_tactic.cpp index d4c20a065..f809f2a74 100644 --- a/src/tactic/core/der_tactic.cpp +++ b/src/tactic/core/der_tactic.cpp @@ -78,7 +78,7 @@ public: model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; (*m_imp)(*(in.get())); in->inc_depth(); result.push_back(in.get()); diff --git a/src/tactic/core/distribute_forall_tactic.cpp b/src/tactic/core/distribute_forall_tactic.cpp index 9a5ef0c48..d8f613044 100644 --- a/src/tactic/core/distribute_forall_tactic.cpp +++ b/src/tactic/core/distribute_forall_tactic.cpp @@ -93,7 +93,7 @@ class distribute_forall_tactic : public tactic { rw * m_rw; public: - distribute_forall_tactic():m_rw(0) {} + distribute_forall_tactic():m_rw(nullptr) {} tactic * translate(ast_manager & m) override { return alloc(distribute_forall_tactic); @@ -109,7 +109,7 @@ public: bool produce_proofs = g->proofs_enabled(); rw r(m, produce_proofs); m_rw = &r; - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); tactic_report report("distribute-forall", *g); expr_ref new_curr(m); @@ -131,7 +131,7 @@ public: result.push_back(g.get()); TRACE("distribute-forall", g->display(tout);); SASSERT(g->is_well_sorted()); - m_rw = 0; + m_rw = nullptr; } void cleanup() override {} diff --git a/src/tactic/core/dom_simplify_tactic.cpp b/src/tactic/core/dom_simplify_tactic.cpp index 2099eebf0..e8d3150af 100644 --- a/src/tactic/core/dom_simplify_tactic.cpp +++ b/src/tactic/core/dom_simplify_tactic.cpp @@ -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 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)) { @@ -189,7 +189,7 @@ void dom_simplify_tactic::operator()( model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("dom-simplify", *in.get()); simplify_goal(*(in.get())); @@ -207,7 +207,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); @@ -262,7 +262,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)) { @@ -380,9 +380,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_star(g.form(i), r, 0, nullptr)); } g.update(i, r, new_pr, g.dep(i)); } @@ -400,9 +400,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_star(g.form(i), r, 0, nullptr)); } g.update(i, r, new_pr, g.dep(i)); } @@ -448,14 +448,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; } diff --git a/src/tactic/core/dom_simplify_tactic.h b/src/tactic/core/dom_simplify_tactic.h index 2b114bb71..9e1a41f8d 100644 --- a/src/tactic/core/dom_simplify_tactic.h +++ b/src/tactic/core/dom_simplify_tactic.h @@ -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 const & tree(expr * e); diff --git a/src/tactic/core/elim_term_ite_tactic.cpp b/src/tactic/core/elim_term_ite_tactic.cpp index 522aa90c6..7691d3398 100644 --- a/src/tactic/core/elim_term_ite_tactic.cpp +++ b/src/tactic/core/elim_term_ite_tactic.cpp @@ -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; } @@ -105,7 +105,7 @@ class elim_term_ite_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("elim-term-ite", *g); bool produce_proofs = g->proofs_enabled(); m_rw.cfg().m_produce_models = g->models_enabled(); diff --git a/src/tactic/core/elim_uncnstr_tactic.cpp b/src/tactic/core/elim_uncnstr_tactic.cpp index a702ab18f..476ea03dd 100644 --- a/src/tactic/core/elim_uncnstr_tactic.cpp +++ b/src/tactic/core/elim_uncnstr_tactic.cpp @@ -95,7 +95,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); @@ -220,7 +220,7 @@ class elim_uncnstr_tactic : public tactic { t = arg1; } else { - return 0; + return nullptr; } sort * s = m().get_sort(arg1); @@ -243,14 +243,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. @@ -267,7 +267,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) { @@ -299,7 +299,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])) { @@ -310,7 +310,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; @@ -320,7 +320,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; @@ -330,13 +330,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; } } @@ -353,7 +353,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)) @@ -368,9 +368,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)) { @@ -378,8 +378,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; @@ -407,7 +407,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; @@ -422,7 +422,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; @@ -432,7 +432,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) { @@ -450,13 +450,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; @@ -482,12 +482,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; @@ -523,14 +523,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; @@ -553,7 +553,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 @@ -593,7 +593,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) { @@ -630,7 +630,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]); @@ -641,9 +641,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; } } @@ -660,7 +660,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; @@ -673,7 +673,7 @@ class elim_uncnstr_tactic : public tactic { return r; } default: - return 0; + return nullptr; } } @@ -700,7 +700,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; @@ -730,7 +730,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) { @@ -745,7 +745,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); @@ -758,7 +758,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; @@ -806,7 +806,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()); @@ -821,7 +821,7 @@ class elim_uncnstr_tactic : public tactic { model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; bool produce_models = g->models_enabled(); bool produce_proofs = g->proofs_enabled(); @@ -867,7 +867,7 @@ class elim_uncnstr_tactic : public tactic { } if (!modified) { if (round == 0) { - mc = 0; + mc = nullptr; } else { app_ref_vector & fresh_vars = m_rw->cfg().m_fresh_vars; @@ -879,11 +879,11 @@ class elim_uncnstr_tactic : public tactic { mc = concat(fmc, m_mc.get()); } else { - mc = 0; + mc = nullptr; } } - m_mc = 0; - m_rw = 0; + m_mc = nullptr; + m_rw = nullptr; TRACE("elim_uncnstr", if (mc) mc->display(tout);); result.push_back(g.get()); g->inc_depth(); diff --git a/src/tactic/core/injectivity_tactic.cpp b/src/tactic/core/injectivity_tactic.cpp index e4c6408bd..342f16212 100644 --- a/src/tactic/core/injectivity_tactic.cpp +++ b/src/tactic/core/injectivity_tactic.cpp @@ -149,7 +149,7 @@ class injectivity_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(goal->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("injectivity", *goal); fail_if_unsat_core_generation("injectivity", goal); // TODO: Support UNSAT cores fail_if_proof_generation("injectivity", goal); diff --git a/src/tactic/core/nnf_tactic.cpp b/src/tactic/core/nnf_tactic.cpp index 1f2454d5e..4641023ad 100644 --- a/src/tactic/core/nnf_tactic.cpp +++ b/src/tactic/core/nnf_tactic.cpp @@ -33,13 +33,13 @@ 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";); } @@ -60,7 +60,7 @@ public: expr_dependency_ref & core) override { TRACE("nnf", tout << "params: " << m_params << "\n"; g->display(tout);); SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("nnf", *g); bool produce_proofs = g->proofs_enabled(); @@ -89,9 +89,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()); diff --git a/src/tactic/core/occf_tactic.cpp b/src/tactic/core/occf_tactic.cpp index 69e5e8fb2..519a4c580 100644 --- a/src/tactic/core/occf_tactic.cpp +++ b/src/tactic/core/occf_tactic.cpp @@ -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->insert(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; } } @@ -133,14 +133,14 @@ class occf_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; 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 new_lits; @@ -160,17 +160,17 @@ class occf_tactic : public tactic { m_mc = alloc(filter_model_converter, m); mc = 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 { @@ -182,9 +182,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()); diff --git a/src/tactic/core/pb_preprocess_tactic.cpp b/src/tactic/core/pb_preprocess_tactic.cpp index 5f128d378..8dfad6fe2 100644 --- a/src/tactic/core/pb_preprocess_tactic.cpp +++ b/src/tactic/core/pb_preprocess_tactic.cpp @@ -148,7 +148,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); - pc = 0; core = 0; + pc = nullptr; core = nullptr; if (g->proofs_enabled()) { throw tactic_exception("pb-preprocess does not support proofs"); @@ -250,7 +250,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; } } @@ -328,12 +328,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";); } } @@ -578,8 +578,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);); } @@ -651,7 +651,7 @@ private: } } } - m_r.set_substitution(0); + m_r.set_substitution(nullptr); } bool subsumes(expr_ref_vector const& args1, diff --git a/src/tactic/core/propagate_values_tactic.cpp b/src/tactic/core/propagate_values_tactic.cpp index 39333226b..e2a6e18de 100644 --- a/src/tactic/core/propagate_values_tactic.cpp +++ b/src/tactic/core/propagate_values_tactic.cpp @@ -38,7 +38,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); } @@ -92,7 +92,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(); } @@ -141,7 +141,7 @@ class propagate_values_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("propagate-values", *g); m_goal = g.get(); @@ -210,7 +210,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);); - m_goal = 0; + m_goal = nullptr; } }; diff --git a/src/tactic/core/reduce_args_tactic.cpp b/src/tactic/core/reduce_args_tactic.cpp index a7aadedbe..333e2638c 100644 --- a/src/tactic/core/reduce_args_tactic.cpp +++ b/src/tactic/core/reduce_args_tactic.cpp @@ -104,7 +104,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); } @@ -341,7 +341,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) @@ -357,7 +357,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 domain; @@ -401,7 +401,7 @@ struct reduce_args_tactic::imp { for (; it != end; ++it) { func_decl * f = it->m_key; arg2func * map = it->m_value; - expr * def = 0; + expr * def = nullptr; SASSERT(decl2args.contains(f)); bit_vector & bv = decl2args.find(f); new_vars.reset(); @@ -419,7 +419,7 @@ struct reduce_args_tactic::imp { f_mc->insert(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 { @@ -494,7 +494,7 @@ void reduce_args_tactic::operator()(goal_ref const & g, SASSERT(g->is_well_sorted()); fail_if_proof_generation("reduce-args", g); fail_if_unsat_core_generation("reduce-args", g); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); m_imp->operator()(*(g.get()), mc); g->inc_depth(); result.push_back(g.get()); diff --git a/src/tactic/core/simplify_tactic.cpp b/src/tactic/core/simplify_tactic.cpp index de1fcc99c..842e1127d 100644 --- a/src/tactic/core/simplify_tactic.cpp +++ b/src/tactic/core/simplify_tactic.cpp @@ -101,7 +101,7 @@ void simplify_tactic::operator()(goal_ref const & in, (*m_imp)(*(in.get())); in->inc_depth(); result.push_back(in.get()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; } catch (rewriter_exception & ex) { throw tactic_exception(ex.msg()); diff --git a/src/tactic/core/solve_eqs_tactic.cpp b/src/tactic/core/solve_eqs_tactic.cpp index a6346185f..9253b7172 100644 --- a/src/tactic/core/solve_eqs_tactic.cpp +++ b/src/tactic/core/solve_eqs_tactic.cpp @@ -53,12 +53,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) { updt_params(p); - if (m_r == 0) + if (m_r == nullptr) m_r = mk_default_expr_replacer(m); } @@ -98,7 +98,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 { @@ -333,7 +333,7 @@ class solve_eqs_tactic : public tactic { } bool solve(expr * f, app_ref & var, expr_ref & def, proof_ref & pr) { - expr* arg1 = 0, *arg2 = 0; + expr* arg1 = nullptr, *arg2 = nullptr; if (m().is_eq(f, arg1, arg2)) { if (trivial_solve(arg1, arg2, var, def, pr)) return true; @@ -393,7 +393,7 @@ 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(); @@ -499,7 +499,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); @@ -513,7 +513,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); @@ -587,9 +587,9 @@ class solve_eqs_tactic : public tactic { for (unsigned idx = 0; idx < size; idx++) { checkpoint(); expr * v = m_ordered_vars[idx]; - 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); @@ -645,7 +645,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; } @@ -681,10 +681,10 @@ 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) + if (mc.get() == nullptr) mc = alloc(gmc, m()); for (app* v : m_ordered_vars) { - expr * def = 0; + expr * def = nullptr; proof * pr; expr_dependency * dep; m_norm_subst->find(v, def, pr, dep); @@ -748,7 +748,7 @@ class solve_eqs_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("solve_eqs", *g); m_produce_models = g->models_enabled(); m_produce_proofs = g->proofs_enabled(); @@ -768,7 +768,7 @@ class solve_eqs_tactic : public tactic { normalize(); substitute(*(g.get())); if (g->inconsistent()) { - mc = 0; + mc = nullptr; break; } save_elim_vars(mc); @@ -823,7 +823,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 @@ -844,7 +844,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)); diff --git a/src/tactic/core/solve_eqs_tactic.h b/src/tactic/core/solve_eqs_tactic.h index 084942ed2..a84ffdd43 100644 --- a/src/tactic/core/solve_eqs_tactic.h +++ b/src/tactic/core/solve_eqs_tactic.h @@ -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)") diff --git a/src/tactic/core/split_clause_tactic.cpp b/src/tactic/core/split_clause_tactic.cpp index 5986ca392..37d9e902e 100644 --- a/src/tactic/core/split_clause_tactic.cpp +++ b/src/tactic/core/split_clause_tactic.cpp @@ -111,7 +111,7 @@ public: SASSERT(in->is_well_sorted()); tactic_report report("split-clause", *in); TRACE("before_split_clause", in->display(tout);); - pc = 0; mc = 0; core = 0; + pc = nullptr; mc = nullptr; core = nullptr; ast_manager & m = in->m(); unsigned cls_pos = select_clause(m, in); if (cls_pos == UINT_MAX) { @@ -131,7 +131,7 @@ public: else subgoal_i = alloc(goal, *in); expr * lit_i = cls->get_arg(i); - 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); diff --git a/src/tactic/core/symmetry_reduce_tactic.cpp b/src/tactic/core/symmetry_reduce_tactic.cpp index 1bc3fde60..81f626f38 100644 --- a/src/tactic/core/symmetry_reduce_tactic.cpp +++ b/src/tactic/core/symmetry_reduce_tactic.cpp @@ -88,7 +88,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) {} @@ -475,7 +475,7 @@ private: T.reset(); ptr_vector todo; todo.push_back(fml); - app* t = 0; + app* t = nullptr; while (!todo.empty()) { fml = todo.back(); todo.pop_back(); @@ -490,24 +490,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; } @@ -641,7 +641,7 @@ void symmetry_reduce_tactic::operator()(goal_ref const & g, expr_dependency_ref & core) { fail_if_proof_generation("symmetry_reduce", g); fail_if_unsat_core_generation("symmetry_reduce", g); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); (*m_imp)(*(g.get())); g->inc_depth(); result.push_back(g.get()); diff --git a/src/tactic/core/tseitin_cnf_tactic.cpp b/src/tactic/core/tseitin_cnf_tactic.cpp index af0143488..6efce9d4e 100644 --- a/src/tactic/core/tseitin_cnf_tactic.cpp +++ b/src/tactic/core/tseitin_cnf_tactic.cpp @@ -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->insert(v->get_decl()); @@ -804,7 +804,7 @@ class tseitin_cnf_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("tseitin-cnf", *g); fail_if_proof_generation("tseitin-cnf", g); m_produce_models = g->models_enabled(); @@ -819,12 +819,12 @@ class tseitin_cnf_tactic : public tactic { if (m_produce_models) m_mc = alloc(filter_model_converter, m); 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()); @@ -838,14 +838,14 @@ 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); } if (m_produce_models && !m_fresh_vars.empty()) mc = m_mc.get(); else - mc = 0; + mc = nullptr; g->inc_depth(); result.push_back(g.get()); TRACE("tseitin_cnf", g->display(tout);); diff --git a/src/tactic/fpa/fpa2bv_model_converter.h b/src/tactic/fpa/fpa2bv_model_converter.h index cf26f53db..9fad9259d 100644 --- a/src/tactic/fpa/fpa2bv_model_converter.h +++ b/src/tactic/fpa/fpa2bv_model_converter.h @@ -55,7 +55,7 @@ public: protected: fpa2bv_model_converter(ast_manager & m) : m(m), - m_bv2fp(0) {} + m_bv2fp(nullptr) {} void convert(model_core * mc, model * float_mdl); }; diff --git a/src/tactic/fpa/fpa2bv_tactic.cpp b/src/tactic/fpa/fpa2bv_tactic.cpp index 7cd4a404c..3c656c6b8 100644 --- a/src/tactic/fpa/fpa2bv_tactic.cpp +++ b/src/tactic/fpa/fpa2bv_tactic.cpp @@ -56,7 +56,7 @@ class fpa2bv_tactic : public tactic { m_produce_models = g->models_enabled(); m_produce_unsat_cores = g->unsat_core_enabled(); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); tactic_report report("fpa2bv", *g); m_rw.reset(); diff --git a/src/tactic/goal.cpp b/src/tactic/goal.cpp index ea8d14bd0..a8c2452e6 100644 --- a/src/tactic/goal.cpp +++ b/src/tactic/goal.cpp @@ -137,10 +137,10 @@ void goal::push_back(expr * f, proof * pr, expr_dependency * d) { } void goal::quick_process(bool save_first, expr_ref& f, expr_dependency * d) { - expr* g = 0; + expr* g = nullptr; if (!m().is_and(f) && !(m().is_not(f, g) && m().is_or(g))) { if (!save_first) { - push_back(f, 0, d); + push_back(f, nullptr, d); } return; } @@ -184,7 +184,7 @@ void goal::quick_process(bool save_first, expr_ref& f, expr_dependency * d) { save_first = false; } else { - push_back(curr, 0, d); + push_back(curr, nullptr, d); } } } @@ -253,7 +253,7 @@ void goal::assert_expr(expr * f, proof * pr, expr_dependency * d) { } void goal::assert_expr(expr * f, expr_dependency * d) { - assert_expr(f, proofs_enabled() ? m().mk_asserted(f) : 0, d); + assert_expr(f, proofs_enabled() ? m().mk_asserted(f) : nullptr, d); } void goal::get_formulas(ptr_vector & result) { @@ -289,7 +289,7 @@ void goal::update(unsigned i, expr * f, proof * pr, expr_dependency * d) { quick_process(true, fr, d); if (!m_inconsistent) { if (m().is_false(fr)) { - push_back(f, 0, d); + push_back(f, nullptr, d); } else { m().set(m_forms, i, fr); @@ -575,7 +575,7 @@ void goal::elim_redundancies() { if (neg_lits.is_marked(atom)) continue; if (pos_lits.is_marked(atom)) { - proof * p = 0; + proof * p = nullptr; if (proofs_enabled()) { proof * prs[2] = { pr(get_idx(atom)), pr(i) }; p = m().mk_unit_resolution(2, prs); @@ -592,7 +592,7 @@ void goal::elim_redundancies() { if (pos_lits.is_marked(f)) continue; if (neg_lits.is_marked(f)) { - proof * p = 0; + proof * p = nullptr; if (proofs_enabled()) { proof * prs[2] = { pr(get_not_idx(f)), pr(i) }; p = m().mk_unit_resolution(2, prs); diff --git a/src/tactic/goal.h b/src/tactic/goal.h index c9de9c037..529ece72c 100644 --- a/src/tactic/goal.h +++ b/src/tactic/goal.h @@ -107,17 +107,17 @@ public: void assert_expr(expr * f, proof * pr, expr_dependency * d); void assert_expr(expr * f, expr_dependency * d); void assert_expr(expr * f, expr * d) { assert_expr(f, m().mk_leaf(d)); } - void assert_expr(expr * f) { assert_expr(f, static_cast(0)); } + void assert_expr(expr * f) { assert_expr(f, static_cast(nullptr)); } unsigned size() const { return m().size(m_forms); } unsigned num_exprs() const; expr * form(unsigned i) const { return m().get(m_forms, i); } - proof * pr(unsigned i) const { return proofs_enabled() ? static_cast(m().get(m_proofs, i)) : 0; } - expr_dependency * dep(unsigned i) const { return unsat_core_enabled() ? m().get(m_dependencies, i) : 0; } + proof * pr(unsigned i) const { return proofs_enabled() ? static_cast(m().get(m_proofs, i)) : nullptr; } + expr_dependency * dep(unsigned i) const { return unsat_core_enabled() ? m().get(m_dependencies, i) : nullptr; } - void update(unsigned i, expr * f, proof * pr = 0, expr_dependency * dep = 0); + void update(unsigned i, expr * f, proof * pr = nullptr, expr_dependency * dep = nullptr); void get_formulas(ptr_vector & result); diff --git a/src/tactic/model_converter.cpp b/src/tactic/model_converter.cpp index 351fbcce7..b295a98b7 100644 --- a/src/tactic/model_converter.cpp +++ b/src/tactic/model_converter.cpp @@ -47,9 +47,9 @@ public: }; model_converter * concat(model_converter * mc1, model_converter * mc2) { - if (mc1 == 0) + if (mc1 == nullptr) return mc2; - if (mc2 == 0) + if (mc2 == nullptr) return mc1; return alloc(concat_model_converter, mc1, mc2); } @@ -114,7 +114,7 @@ model_converter * concat(model_converter * mc1, unsigned num, model_converter * return concat(mc1, mc2s[0]); unsigned i; for (i = 0; i < num; i++) { - if (mc2s[i] != 0) + if (mc2s[i] != nullptr) break; } if (i == num) { @@ -162,14 +162,14 @@ public: }; model_converter * model2model_converter(model * m) { - if (m == 0) - return 0; + if (m == nullptr) + return nullptr; return alloc(model2mc, m); } model_converter * model_and_labels2model_converter(model * m, buffer & r) { - if (m == 0) - return 0; + if (m == nullptr) + return nullptr; return alloc(model2mc, m, r); } diff --git a/src/tactic/nlsat_smt/nl_purify_tactic.cpp b/src/tactic/nlsat_smt/nl_purify_tactic.cpp index 828758caa..745b0352d 100644 --- a/src/tactic/nlsat_smt/nl_purify_tactic.cpp +++ b/src/tactic/nlsat_smt/nl_purify_tactic.cpp @@ -131,7 +131,7 @@ public: m_interface_cache.insert(arg, arg); return arg; } - r = m.mk_fresh_const(0, u().mk_real()); + r = m.mk_fresh_const(nullptr, u().mk_real()); m_new_reals.push_back(to_app(r)); m_owner.m_fmc->insert(to_app(r)->get_decl()); m_interface_cache.insert(arg, r); @@ -156,7 +156,7 @@ public: void mk_interface_bool(func_decl * f, unsigned num, expr* const* args, expr_ref& result, proof_ref& pr) { expr_ref old_pred(m.mk_app(f, num, args), m); polarity_t pol = m_polarities.find(old_pred); - result = m.mk_fresh_const(0, m.mk_bool_sort()); + result = m.mk_fresh_const(nullptr, m.mk_bool_sort()); m_polarities.insert(result, pol); m_new_preds.push_back(to_app(result)); m_owner.m_fmc->insert(to_app(result)->get_decl()); @@ -425,8 +425,8 @@ private: void core2result(expr_dependency_ref & lcore, goal_ref const& g, goal_ref_buffer& result) { result.reset(); - proof * pr = 0; - lcore = 0; + proof * pr = nullptr; + lcore = nullptr; g->reset(); obj_hashtable::iterator it = m_used_asms.begin(), end = m_used_asms.end(); for (; it != end; ++it) { @@ -488,7 +488,7 @@ private: nums.push_back(r); if (num2var.find(r, v)) { if (!m_eq_pairs.find(v, w, pred)) { - pred = m.mk_fresh_const(0, m.mk_bool_sort()); + pred = m.mk_fresh_const(nullptr, m.mk_bool_sort()); m_eq_preds.push_back(pred); m_eq_values.push_back(l_true); m_fmc->insert(to_app(pred)->get_decl()); @@ -558,7 +558,7 @@ private: } void translate(expr_safe_replace& num2num, expr* e, expr_ref& result) { - result = 0; + result = nullptr; if (e) { num2num(e, result); } @@ -699,9 +699,9 @@ public: m(m), m_util(m), m_params(p), - m_fmc(0), + m_fmc(nullptr), m_nl_tac(mk_nlsat_tactic(m, p)), - m_nl_g(0), + m_nl_g(nullptr), m_solver(mk_smt_solver(m, p, symbol::null)), m_eq_preds(m), m_new_reals(m), @@ -754,7 +754,7 @@ public: TRACE("nlsat_smt", g->display(tout);); m_produce_proofs = g->proofs_enabled(); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; fail_if_proof_generation("qfufnra-purify", g); // fail_if_unsat_core_generation("qfufnra-purify", g); diff --git a/src/tactic/portfolio/bounded_int2bv_solver.cpp b/src/tactic/portfolio/bounded_int2bv_solver.cpp index 7b82772c5..170780ab0 100644 --- a/src/tactic/portfolio/bounded_int2bv_solver.cpp +++ b/src/tactic/portfolio/bounded_int2bv_solver.cpp @@ -167,7 +167,7 @@ public: // translate bit-vector consequences back to integer values for (unsigned i = 0; i < consequences.size(); ++i) { - expr* a = 0, *b = 0, *u = 0, *v = 0; + expr* a = nullptr, *b = nullptr, *u = nullptr, *v = nullptr; func_decl* f; rational num; unsigned bvsize; diff --git a/src/tactic/portfolio/enum2bv_solver.cpp b/src/tactic/portfolio/enum2bv_solver.cpp index 029914b88..3f4a20774 100644 --- a/src/tactic/portfolio/enum2bv_solver.cpp +++ b/src/tactic/portfolio/enum2bv_solver.cpp @@ -114,7 +114,7 @@ public: // translate enumeration constants to bit-vectors. for (unsigned i = 0; i < vars.size(); ++i) { - func_decl* f = 0; + func_decl* f = nullptr; if (is_app(vars[i]) && is_uninterp_const(vars[i]) && m_rewriter.enum2bv().find(to_app(vars[i])->get_decl(), f)) { bvars.push_back(m.mk_const(f)); } @@ -126,7 +126,7 @@ public: // translate bit-vector consequences back to enumeration types for (unsigned i = 0; i < consequences.size(); ++i) { - expr* a = 0, *b = 0, *u = 0, *v = 0; + expr* a = nullptr, *b = nullptr, *u = nullptr, *v = nullptr; func_decl* f; rational num; unsigned bvsize; diff --git a/src/tactic/portfolio/smt_strategic_solver.cpp b/src/tactic/portfolio/smt_strategic_solver.cpp index aa699695e..e436b6143 100644 --- a/src/tactic/portfolio/smt_strategic_solver.cpp +++ b/src/tactic/portfolio/smt_strategic_solver.cpp @@ -104,7 +104,7 @@ tactic * mk_tactic_for_logic(ast_manager & m, params_ref const & p, symbol const static solver* mk_special_solver_for_logic(ast_manager & m, params_ref const & p, symbol const& logic) { if ((logic == "QF_FD" || logic == "SAT") && !m.proofs_enabled()) return mk_fd_solver(m, p); - return 0; + return nullptr; } static solver* mk_solver_for_logic(ast_manager & m, params_ref const & p, symbol const& logic) { diff --git a/src/tactic/probe.cpp b/src/tactic/probe.cpp index c9863c9b1..dcd1dc500 100644 --- a/src/tactic/probe.cpp +++ b/src/tactic/probe.cpp @@ -411,7 +411,7 @@ class num_consts_probe : public probe { family_id m_fid; unsigned m_counter; proc(ast_manager & _m, bool b, char const * family):m(_m), m_bool(b), m_counter(0) { - if (family != 0) + if (family != nullptr) m_fid = m.mk_family_id(family); else m_fid = null_family_id; @@ -454,11 +454,11 @@ public: }; probe * mk_num_consts_probe() { - return alloc(num_consts_probe, false, 0); + return alloc(num_consts_probe, false, nullptr); } probe * mk_num_bool_consts_probe() { - return alloc(num_consts_probe, true, 0); + return alloc(num_consts_probe, true, nullptr); } probe * mk_num_arith_consts_probe() { diff --git a/src/tactic/proof_converter.cpp b/src/tactic/proof_converter.cpp index 5ac48def0..26a87fe04 100644 --- a/src/tactic/proof_converter.cpp +++ b/src/tactic/proof_converter.cpp @@ -38,9 +38,9 @@ public: }; proof_converter * concat(proof_converter * pc1, proof_converter * pc2) { - if (pc1 == 0) + if (pc1 == nullptr) return pc2; - if (pc2 == 0) + if (pc2 == nullptr) return pc1; return alloc(concat_proof_converter, pc1, pc2); } @@ -97,7 +97,7 @@ proof_converter * concat(proof_converter * pc1, unsigned num, proof_converter * return concat(pc1, pc2s[0]); unsigned i; for (i = 0; i < num; i++) { - if (pc2s[i] != 0) + if (pc2s[i] != nullptr) break; } if (i == num) { @@ -128,8 +128,8 @@ public: }; proof_converter * proof2proof_converter(ast_manager & m, proof * pr) { - if (pr == 0) - return 0; + if (pr == nullptr) + return nullptr; return alloc(proof2pc, m, pr); } @@ -155,7 +155,7 @@ void apply(ast_manager & m, proof_converter_ref & pc1, proof_converter_ref_buffe for (unsigned i = 0; i < sz; i++) { proof_ref pr(m); SASSERT(pc2s[i]); // proof production is enabled - pc2s[i]->operator()(m, 0, 0, pr); + pc2s[i]->operator()(m, 0, nullptr, pr); prs.push_back(pr); } (*pc1)(m, sz, prs.c_ptr(), result); diff --git a/src/tactic/replace_proof_converter.cpp b/src/tactic/replace_proof_converter.cpp index 98f28bb1b..ba74452cf 100644 --- a/src/tactic/replace_proof_converter.cpp +++ b/src/tactic/replace_proof_converter.cpp @@ -39,7 +39,7 @@ public: replace_map(ast_manager& m): map_proc(m) {} void insert(expr* src, expr* dst) { - m_map.insert(src, dst, 0); + m_map.insert(src, dst, nullptr); } void operator()(var* v) { visit(v); } diff --git a/src/tactic/sine_filter.cpp b/src/tactic/sine_filter.cpp index 4aecc0274..88792e955 100644 --- a/src/tactic/sine_filter.cpp +++ b/src/tactic/sine_filter.cpp @@ -53,7 +53,7 @@ public: model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; TRACE("sine", g->display(tout);); TRACE("sine", tout << g->size();); @@ -62,7 +62,7 @@ public: TRACE("sine", tout << new_forms.size();); g->reset(); for (unsigned i = 0; i < new_forms.size(); i++) { - g->assert_expr(new_forms.get(i), 0, 0); + g->assert_expr(new_forms.get(i), nullptr, nullptr); } g->inc_depth(); g->updt_prec(goal::OVER); diff --git a/src/tactic/sls/bvsls_opt_engine.cpp b/src/tactic/sls/bvsls_opt_engine.cpp index 502bcbde6..37454ca72 100644 --- a/src/tactic/sls/bvsls_opt_engine.cpp +++ b/src/tactic/sls/bvsls_opt_engine.cpp @@ -43,7 +43,7 @@ bvsls_opt_engine::optimization_result bvsls_opt_engine::optimize( m_hard_tracker.initialize(m_assertions); setup_opt_tracker(objective, _maximize); - if (initial_model.get() != 0) { + if (initial_model.get() != nullptr) { TRACE("sls_opt", tout << "Initial model provided: " << std::endl; for (unsigned i = 0; i < initial_model->get_num_constants(); i++) { func_decl * fd = initial_model->get_constant(i); diff --git a/src/tactic/sls/sls_engine.cpp b/src/tactic/sls/sls_engine.cpp index 4e1c6a693..7836ab70f 100644 --- a/src/tactic/sls/sls_engine.cpp +++ b/src/tactic/sls/sls_engine.cpp @@ -537,7 +537,7 @@ bailout: void sls_engine::operator()(goal_ref const & g, model_converter_ref & mc) { if (g->inconsistent()) { - mc = 0; + mc = nullptr; return; } @@ -565,7 +565,7 @@ void sls_engine::operator()(goal_ref const & g, model_converter_ref & mc) { g->reset(); } else - mc = 0; + mc = nullptr; } lbool sls_engine::operator()() { diff --git a/src/tactic/sls/sls_tactic.cpp b/src/tactic/sls/sls_tactic.cpp index aaf4c24c0..fa9ea4e4a 100644 --- a/src/tactic/sls/sls_tactic.cpp +++ b/src/tactic/sls/sls_tactic.cpp @@ -65,7 +65,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; result.reset(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); TRACE("sls", g->display(tout);); tactic_report report("sls", *g); diff --git a/src/tactic/sls/sls_tracker.h b/src/tactic/sls/sls_tracker.h index 15f06f096..b730e78da 100644 --- a/src/tactic/sls/sls_tracker.h +++ b/src/tactic/sls/sls_tracker.h @@ -40,7 +40,7 @@ class sls_tracker { mpz m_zero, m_one, m_two; struct value_score { - value_score() : m(0), value(unsynch_mpz_manager::mk_z(0)), score(0.0), score_prune(0.0), has_pos_occ(0), has_neg_occ(0), distance(0), touched(1) {}; + value_score() : m(nullptr), value(unsynch_mpz_manager::mk_z(0)), score(0.0), score_prune(0.0), has_pos_occ(0), has_neg_occ(0), distance(0), touched(1) {}; value_score(value_score && other) : m(other.m), value(std::move(other.value)), @@ -1038,7 +1038,7 @@ public: if (m_mpz_manager.neq(get_value(as[0]), m_one)) return as[0]; else - return 0; + return nullptr; } m_temp_constants.reset(); @@ -1061,7 +1061,7 @@ public: } } if (pos == static_cast(-1)) - return 0; + return nullptr; m_touched++; m_scores.find(as[pos]).touched++; @@ -1082,7 +1082,7 @@ public: for (unsigned i = 0; i < sz; i++) if (m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i; if (pos == static_cast(-1)) - return 0; + return nullptr; } m_last_pos = pos; @@ -1092,7 +1092,7 @@ public: expr * get_new_unsat_assertion(ptr_vector const & as) { unsigned sz = as.size(); if (sz == 1) - return 0; + return nullptr; m_temp_constants.reset(); unsigned cnt_unsat = 0, pos = -1; @@ -1100,7 +1100,7 @@ public: if ((i != m_last_pos) && m_mpz_manager.neq(get_value(as[i]), m_one) && (get_random_uint(16) % ++cnt_unsat == 0)) pos = i; if (pos == static_cast(-1)) - return 0; + return nullptr; return as[pos]; } }; diff --git a/src/tactic/smtlogics/qfufbv_tactic.cpp b/src/tactic/smtlogics/qfufbv_tactic.cpp index 1d3f251a4..bc2f55061 100644 --- a/src/tactic/smtlogics/qfufbv_tactic.cpp +++ b/src/tactic/smtlogics/qfufbv_tactic.cpp @@ -58,7 +58,7 @@ public: model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override { - mc = 0; + mc = nullptr; ast_manager& m(g->m()); tactic_report report("qfufbv_ackr", *g); fail_if_unsat_core_generation("qfufbv_ackr", g); @@ -111,7 +111,7 @@ private: bool m_inc_use_sat; solver* setup_sat() { - solver * sat(NULL); + solver * sat(nullptr); if (m_use_sat) { if (m_inc_use_sat) { sat = mk_inc_sat_solver(m_m, m_p); diff --git a/src/tactic/tactic.cpp b/src/tactic/tactic.cpp index 7ccd44e7d..da063de39 100644 --- a/src/tactic/tactic.cpp +++ b/src/tactic/tactic.cpp @@ -53,7 +53,7 @@ tactic_report::tactic_report(char const * id, goal const & g) { if (get_verbosity_level() >= TACTIC_VERBOSITY_LVL) m_imp = alloc(imp, id, g); else - m_imp = 0; + m_imp = nullptr; } tactic_report::~tactic_report() { @@ -74,9 +74,9 @@ void skip_tactic::operator()(goal_ref const & in, expr_dependency_ref & core) { result.reset(); result.push_back(in.get()); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; } tactic * mk_skip_tactic() { @@ -179,9 +179,9 @@ lbool check_sat(tactic & t, goal_ref & g, model_ref & md, labels_vec & labels, p bool models_enabled = g->models_enabled(); bool proofs_enabled = g->proofs_enabled(); bool cores_enabled = g->unsat_core_enabled(); - md = 0; - pr = 0; - core = 0; + md = nullptr; + pr = nullptr; + core = nullptr; ast_manager & m = g->m(); goal_ref_buffer r; model_converter_ref mc; diff --git a/src/tactic/tactical.cpp b/src/tactic/tactical.cpp index fe0c7385f..8aa2f400a 100644 --- a/src/tactic/tactical.cpp +++ b/src/tactic/tactical.cpp @@ -122,9 +122,9 @@ public: proof_converter_ref pc1; expr_dependency_ref core1(m); result.reset(); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; m_t1->operator()(in, r1, mc1, pc1, core1); SASSERT(!is_decided(r1) || (!pc1 && !core1)); // the pc and core of decided goals is 0 unsigned r1_size = r1.size(); @@ -176,7 +176,7 @@ public: // pc2 and core2 must be 0. SASSERT(!pc2); SASSERT(!core2); - if (models_enabled) mc_buffer.push_back(0); + if (models_enabled) mc_buffer.push_back(nullptr); if (proofs_enabled) pc_buffer.push_back(proof2proof_converter(m, r2[0]->pr(0))); if (models_enabled || proofs_enabled) sz_buffer.push_back(0); if (cores_enabled) core = m.mk_join(core.get(), r2[0]->dep(0)); @@ -200,7 +200,7 @@ public: apply(m, pc1, pc_buffer, pr); SASSERT(cores_enabled || core == 0); in->assert_expr(m.mk_false(), pr, core); - core = 0; + core = nullptr; result.push_back(in.get()); SASSERT(!mc); SASSERT(!pc); SASSERT(!core); } @@ -380,9 +380,9 @@ public: for (i = 0; i < sz; i++) { tactic * t = m_ts[i]; result.reset(); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; SASSERT(sz > 0); if (i < sz - 1) { try { @@ -536,8 +536,8 @@ public: for (unsigned k = 0; k < _result.size(); k++) { result.push_back(_result[k]->translate(translator)); } - mc = _mc ? _mc->translate(translator) : 0; - pc = _pc ? _pc->translate(translator) : 0; + mc = _mc ? _mc->translate(translator) : nullptr; + pc = _pc ? _pc->translate(translator) : nullptr; expr_dependency_translation td(translator); core = td(_core); } @@ -562,7 +562,7 @@ public: } } if (finished_id == UINT_MAX) { - mc = 0; + mc = nullptr; switch (ex_kind) { case ERROR_EX: throw z3_error(error_code); case TACTIC_EX: throw tactic_exception(ex_msg.c_str()); @@ -626,9 +626,9 @@ public: proof_converter_ref pc1; expr_dependency_ref core1(m); result.reset(); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; m_t1->operator()(in, r1, mc1, pc1, core1); SASSERT(!is_decided(r1) || (!pc1 && !core1)); // the pc and core of decided goals is 0 unsigned r1_size = r1.size(); @@ -759,7 +759,7 @@ public: result.push_back(r2[0]->translate(translator)); if (models_enabled) { // mc2 contains the actual model - mc2 = mc2 ? mc2->translate(translator) : 0; + mc2 = mc2 ? mc2->translate(translator) : nullptr; model_ref md; md = alloc(model, m); apply(mc2, md, 0); @@ -776,12 +776,12 @@ public: SASSERT(!pc2); SASSERT(!core2); - if (models_enabled) mc_buffer.set(i, 0); + if (models_enabled) mc_buffer.set(i, nullptr); if (proofs_enabled) { proof * pr = r2[0]->pr(0); pc_buffer.push_back(proof2proof_converter(m, pr)); } - if (cores_enabled && r2[0]->dep(0) != 0) { + if (cores_enabled && r2[0]->dep(0) != nullptr) { expr_dependency_ref * new_dep = alloc(expr_dependency_ref, new_m); *new_dep = r2[0]->dep(0); core_buffer.set(i, new_dep); @@ -815,12 +815,12 @@ public: if (found_solution) return; - core = 0; + core = nullptr; sbuffer sz_buffer; for (unsigned i = 0; i < r1_size; i++) { ast_translation translator(*(managers[i]), m, false); goal_ref_buffer * r = goals_vect[i]; - if (r != 0) { + if (r != nullptr) { for (unsigned k = 0; k < r->size(); k++) { result.push_back((*r)[k]->translate(translator)); } @@ -829,12 +829,12 @@ public: else { sz_buffer.push_back(0); } - if (mc_buffer[i] != 0) + if (mc_buffer[i] != nullptr) mc_buffer.set(i, mc_buffer[i]->translate(translator)); - if (pc_buffer[i] != 0) + if (pc_buffer[i] != nullptr) pc_buffer.set(i, pc_buffer[i]->translate(translator)); expr_dependency_translation td(translator); - if (core_buffer[i] != 0) { + if (core_buffer[i] != nullptr) { expr_dependency_ref curr_core(m); curr_core = td(*(core_buffer[i])); core = m.mk_join(curr_core, core); @@ -850,7 +850,7 @@ public: apply(m, pc1, pc_buffer, pr); SASSERT(cores_enabled || core == 0); in->assert_expr(m.mk_false(), pr, core); - core = 0; + core = nullptr; result.push_back(in.get()); SASSERT(!mc); SASSERT(!pc); SASSERT(!core); } @@ -936,9 +936,9 @@ class repeat_tactical : public unary_tactical { // TODO: implement a non-recursive version. if (depth > m_max_depth) { result.push_back(in.get()); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; return; } @@ -952,9 +952,9 @@ class repeat_tactical : public unary_tactical { proof_converter_ref pc1; expr_dependency_ref core1(m); result.reset(); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; { goal orig_in(in->m(), proofs_enabled, models_enabled, cores_enabled); orig_in.copy_from(*(in.get())); @@ -1014,7 +1014,7 @@ class repeat_tactical : public unary_tactical { SASSERT(is_decided_unsat(r2)); SASSERT(!pc2); SASSERT(!core2); - if (models_enabled) mc_buffer.push_back(0); + if (models_enabled) mc_buffer.push_back(nullptr); if (proofs_enabled) pc_buffer.push_back(proof2proof_converter(m, r2[0]->pr(0))); if (models_enabled || proofs_enabled) sz_buffer.push_back(0); if (cores_enabled) core = m.mk_join(core.get(), r2[0]->dep(0)); @@ -1038,7 +1038,7 @@ class repeat_tactical : public unary_tactical { apply(m, pc1, pc_buffer, pr); SASSERT(cores_enabled || core == 0); in->assert_expr(m.mk_false(), pr, core); - core = 0; + core = nullptr; result.push_back(in.get()); SASSERT(!mc); SASSERT(!pc); SASSERT(!core); } @@ -1087,9 +1087,9 @@ public: m_t->operator()(in, result, mc, pc, core); if (result.size() > m_threshold) { result.reset(); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; throw tactic_exception("failed-if-branching tactical"); } }; @@ -1282,9 +1282,9 @@ public: model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) override { - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; if (m_p->operator()(*(in.get())).is_true()) { throw tactic_exception("fail-if tactic"); } @@ -1314,7 +1314,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { if (in->proofs_enabled()) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); result.push_back(in.get()); } @@ -1336,7 +1336,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { if (in->unsat_core_enabled()) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); result.push_back(in.get()); } @@ -1358,7 +1358,7 @@ public: proof_converter_ref & pc, expr_dependency_ref & core) override { if (in->models_enabled()) { - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); result.push_back(in.get()); } diff --git a/src/tactic/ufbv/macro_finder_tactic.cpp b/src/tactic/ufbv/macro_finder_tactic.cpp index 88b1e6a67..5917136b6 100644 --- a/src/tactic/ufbv/macro_finder_tactic.cpp +++ b/src/tactic/ufbv/macro_finder_tactic.cpp @@ -43,7 +43,7 @@ class macro_finder_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("macro-finder", *g); bool produce_proofs = g->proofs_enabled(); @@ -66,8 +66,8 @@ class macro_finder_tactic : public tactic { g->reset(); for (unsigned i = 0; i < new_forms.size(); i++) g->assert_expr(new_forms.get(i), - produce_proofs ? new_proofs.get(i) : 0, - unsat_core_enabled ? new_deps.get(i) : 0); + produce_proofs ? new_proofs.get(i) : nullptr, + unsat_core_enabled ? new_deps.get(i) : nullptr); extension_model_converter * evmc = alloc(extension_model_converter, mm.get_manager()); unsigned num = mm.get_num_macros(); diff --git a/src/tactic/ufbv/quasi_macros_tactic.cpp b/src/tactic/ufbv/quasi_macros_tactic.cpp index e9d081c53..7fbc3c7a5 100644 --- a/src/tactic/ufbv/quasi_macros_tactic.cpp +++ b/src/tactic/ufbv/quasi_macros_tactic.cpp @@ -41,7 +41,7 @@ class quasi_macros_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("quasi-macros", *g); bool produce_proofs = g->proofs_enabled(); @@ -78,8 +78,8 @@ class quasi_macros_tactic : public tactic { g->reset(); for (unsigned i = 0; i < new_forms.size(); i++) g->assert_expr(forms.get(i), - produce_proofs ? proofs.get(i) : 0, - produce_unsat_cores ? deps.get(i) : 0); + produce_proofs ? proofs.get(i) : nullptr, + produce_unsat_cores ? deps.get(i) : nullptr); extension_model_converter * evmc = alloc(extension_model_converter, mm.get_manager()); unsigned num = mm.get_num_macros(); diff --git a/src/tactic/ufbv/ufbv_rewriter_tactic.cpp b/src/tactic/ufbv/ufbv_rewriter_tactic.cpp index 3dcc6d9a1..eed72a71e 100644 --- a/src/tactic/ufbv/ufbv_rewriter_tactic.cpp +++ b/src/tactic/ufbv/ufbv_rewriter_tactic.cpp @@ -37,7 +37,7 @@ class ufbv_rewriter_tactic : public tactic { proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("ufbv-rewriter", *g); fail_if_unsat_core_generation("ufbv-rewriter", g); @@ -58,9 +58,9 @@ class ufbv_rewriter_tactic : public tactic { g->reset(); for (unsigned i = 0; i < new_forms.size(); i++) - g->assert_expr(new_forms.get(i), produce_proofs ? new_proofs.get(i) : 0, 0); + g->assert_expr(new_forms.get(i), produce_proofs ? new_proofs.get(i) : nullptr, nullptr); - mc = 0; // CMW: Remark: The demodulator could potentially remove all references to a variable. + mc = nullptr; // CMW: Remark: The demodulator could potentially remove all references to a variable. g->inc_depth(); result.push_back(g.get()); diff --git a/src/test/check_assumptions.cpp b/src/test/check_assumptions.cpp index 020b3e277..d1d81245e 100644 --- a/src/test/check_assumptions.cpp +++ b/src/test/check_assumptions.cpp @@ -20,13 +20,13 @@ void tst_check_assumptions() reg_decl_plugins(mgr); sort_ref b(mgr.mk_bool_sort(), mgr); - func_decl_ref pPred(mgr.mk_func_decl(symbol("p"), 0, static_cast(0), b), mgr); - func_decl_ref qPred(mgr.mk_func_decl(symbol("q"), 0, static_cast(0), b), mgr); - func_decl_ref rPred(mgr.mk_func_decl(symbol("r"), 0, static_cast(0), b), mgr); + func_decl_ref pPred(mgr.mk_func_decl(symbol("p"), 0, static_cast(nullptr), b), mgr); + func_decl_ref qPred(mgr.mk_func_decl(symbol("q"), 0, static_cast(nullptr), b), mgr); + func_decl_ref rPred(mgr.mk_func_decl(symbol("r"), 0, static_cast(nullptr), b), mgr); - app_ref p(mgr.mk_app(pPred,0,static_cast(0)), mgr); - app_ref q(mgr.mk_app(qPred,0,static_cast(0)), mgr); - app_ref r(mgr.mk_app(rPred,0,static_cast(0)), mgr); + app_ref p(mgr.mk_app(pPred,0,static_cast(nullptr)), mgr); + app_ref q(mgr.mk_app(qPred,0,static_cast(nullptr)), mgr); + app_ref r(mgr.mk_app(rPred,0,static_cast(nullptr)), mgr); app_ref pOqOr(mgr.mk_or(p,q,r), mgr); app_ref np(mgr.mk_not(p), mgr); diff --git a/src/test/cnf_backbones.cpp b/src/test/cnf_backbones.cpp index 3e9a106b5..27d175298 100644 --- a/src/test/cnf_backbones.cpp +++ b/src/test/cnf_backbones.cpp @@ -11,7 +11,7 @@ Copyright (c) 2017 Microsoft Corporation #include "sat/sat_solver.h" #include "util/gparams.h" -static sat::solver * g_solver = 0; +static sat::solver * g_solver = nullptr; static clock_t g_start_time; static void display_statistics() { @@ -228,8 +228,8 @@ static void cnf_backbones(bool use_chunk, char const* file_name) { params_ref p = gparams::get_module("sat"); p.set_bool("produce_models", true); reslimit limit; - sat::solver solver(p, limit, 0); - sat::solver solver2(p, limit, 0); + sat::solver solver(p, limit, nullptr); + sat::solver solver2(p, limit, nullptr); g_solver = &solver; if (file_name) { diff --git a/src/test/ddnf.cpp b/src/test/ddnf.cpp index c9eb6aa08..003e5bdb8 100644 --- a/src/test/ddnf.cpp +++ b/src/test/ddnf.cpp @@ -26,7 +26,7 @@ void read_nums(std::istream& is, unsigned & x, unsigned& y) { std::getline(is, line); } -static char const* g_file = 0; +static char const* g_file = nullptr; void create_forwarding( diff --git a/src/test/escaped.cpp b/src/test/escaped.cpp index fe8f733bf..9bc2aecec 100644 --- a/src/test/escaped.cpp +++ b/src/test/escaped.cpp @@ -30,6 +30,6 @@ void tst_escaped() { std::cout << "[" << escaped("\n") << "]\n"; std::cout << "[" << escaped("", true) << "]\n"; std::cout << "[" << escaped("") << "]\n"; - std::cout << "[" << escaped(0, true) << "]\n"; - std::cout << "[" << escaped(0) << "]\n"; + std::cout << "[" << escaped(nullptr, true) << "]\n"; + std::cout << "[" << escaped(nullptr) << "]\n"; } diff --git a/src/test/expr_rand.cpp b/src/test/expr_rand.cpp index e52bfbc1a..ecf0cbe4d 100644 --- a/src/test/expr_rand.cpp +++ b/src/test/expr_rand.cpp @@ -25,8 +25,8 @@ void tst_expr_arith(unsigned num_files) { er.initialize_arith(20); family_id fid = m.mk_family_id("arith"); - sort* int_ty = m.mk_sort(fid, INT_SORT, 0, 0); - sort* real_ty = m.mk_sort(fid, REAL_SORT, 0, 0); + sort* int_ty = m.mk_sort(fid, INT_SORT, 0, nullptr); + sort* real_ty = m.mk_sort(fid, REAL_SORT, 0, nullptr); er.initialize_array(3, int_ty, int_ty); er.initialize_array(3, int_ty, real_ty); diff --git a/src/test/fuzzing/expr_rand.cpp b/src/test/fuzzing/expr_rand.cpp index 1d425e9e1..a15c8e0e1 100644 --- a/src/test/fuzzing/expr_rand.cpp +++ b/src/test/fuzzing/expr_rand.cpp @@ -35,7 +35,7 @@ void expr_rand::add_func_decl(func_decl* f) { void expr_rand::add_expr(expr* t) { sort* s = m_manager.get_sort(t); - expr_ref_vector* vals = 0; + expr_ref_vector* vals = nullptr; if (!m_nodes.find(s, vals)) { vals = alloc(expr_ref_vector, m_manager); m_nodes.insert(s, vals); @@ -71,7 +71,7 @@ func_decl* expr_rand::choose_func_decl() { } expr* expr_rand::choose_expr(sort* s) { - expr_ref_vector* vals = 0; + expr_ref_vector* vals = nullptr; if (!m_nodes.find(s, vals)) { add_var(s); if (!m_nodes.find(s, vals)) { @@ -86,14 +86,14 @@ expr* expr_rand::choose_expr(sort* s) { void expr_rand::initialize_arith(unsigned num_vars) { arith_util u(m_manager); family_id afid = m_manager.mk_family_id("arith"); - sort* i_ty = m_manager.mk_sort(afid, INT_SORT, 0, 0); + sort* i_ty = m_manager.mk_sort(afid, INT_SORT, 0, nullptr); for(unsigned i = 0; i < num_vars; ++i) { add_var(i_ty); } sort* is[2] = { i_ty, i_ty }; decl_kind kinds[7] = {OP_ADD, OP_MUL, OP_SUB, OP_LE, OP_LT, OP_GE, OP_GT }; for (unsigned i = 0; i < 7; ++i) { - add_func_decl(m_manager.mk_func_decl(afid, kinds[i], 0, 0, 2, is)); + add_func_decl(m_manager.mk_func_decl(afid, kinds[i], 0, nullptr, 2, is)); } add_expr(u.mk_numeral(rational(0), true)); @@ -137,37 +137,37 @@ void expr_rand::initialize_bv(unsigned num_vars) { sort* s = m_manager.mk_sort(bvfid, BV_SORT, 1, ¶m); sort* ss[3] = { s, s, s }; - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BNEG, 0, 0, 1, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BADD, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSUB, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BMUL, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSDIV, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BUDIV, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSREM, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BUREM, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSMOD, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_ULEQ, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_SLEQ, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_UGEQ, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_SGEQ, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_ULT, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_SLT, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_UGT, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_SGT, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BAND, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BOR, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BNOT, 0, 0, 1, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BXOR, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BXNOR, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BNAND, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BCOMP, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BREDAND, 0, 0, 1, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BREDOR, 0, 0, 1, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSHL, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BLSHR, 0, 0, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bvfid, OP_BASHR, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BNEG, 0, nullptr, 1, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BADD, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSUB, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BMUL, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSDIV, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BUDIV, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSREM, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BUREM, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSMOD, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_ULEQ, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_SLEQ, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_UGEQ, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_SGEQ, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_ULT, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_SLT, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_UGT, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_SGT, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BAND, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BOR, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BNOT, 0, nullptr, 1, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BXOR, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BXNOR, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BNAND, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BCOMP, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BREDAND, 0, nullptr, 1, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BREDOR, 0, nullptr, 1, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BSHL, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BLSHR, 0, nullptr, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_BASHR, 0, nullptr, 2, ss)); - add_func_decl(m_manager.mk_func_decl(bfid, OP_EQ, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bfid, OP_EQ, 0, nullptr, 2, ss)); add_func_decl(m_manager.mk_func_decl(bvfid, OP_ROTATE_LEFT, 1, &p1, 1, ss)); add_func_decl(m_manager.mk_func_decl(bvfid, OP_ROTATE_RIGHT, 1, &p1, 1, ss)); @@ -182,22 +182,22 @@ void expr_rand::initialize_bv(unsigned num_vars) { // OP_CONCAT: { sort* ss[2] = { b8, b8 }; - add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, nullptr, 2, ss)); ss[0] = b16; ss[1] = b8; - add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, nullptr, 2, ss)); ss[0] = b8; ss[1] = b16; - add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, nullptr, 2, ss)); ss[0] = b16; ss[1] = b16; - add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, nullptr, 2, ss)); ss[0] = b24; ss[1] = b8; - add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, nullptr, 2, ss)); ss[0] = b8; ss[1] = b24; - add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(bvfid, OP_CONCAT, 0, nullptr, 2, ss)); } @@ -246,8 +246,8 @@ void expr_rand::initialize_array(unsigned num_vars, sort* dom, sort* rng) { sort* a = m_manager.mk_sort(afid, ARRAY_SORT, 2, ps); sort* ss[3] = { a, dom, rng }; - add_func_decl(m_manager.mk_func_decl(afid, OP_STORE, 0, 0, 3, ss)); - add_func_decl(m_manager.mk_func_decl(afid, OP_SELECT, 0, 0, 2, ss)); + add_func_decl(m_manager.mk_func_decl(afid, OP_STORE, 0, nullptr, 3, ss)); + add_func_decl(m_manager.mk_func_decl(afid, OP_SELECT, 0, nullptr, 2, ss)); for (unsigned i = 0; i < num_vars; ++i) { add_var(a); @@ -258,14 +258,14 @@ void expr_rand::initialize_basic(unsigned amplification) { family_id bfid = m_manager.get_basic_family_id(); sort* bools[2] = { m_manager.mk_bool_sort(), m_manager.mk_bool_sort() }; for (unsigned i = 0; i < amplification; ++i) { - add_func_decl(m_manager.mk_func_decl(bfid, OP_OR, 0, 0, 2, bools)); - add_func_decl(m_manager.mk_func_decl(bfid, OP_NOT, 0, 0, 1, bools)); + add_func_decl(m_manager.mk_func_decl(bfid, OP_OR, 0, nullptr, 2, bools)); + add_func_decl(m_manager.mk_func_decl(bfid, OP_NOT, 0, nullptr, 1, bools)); } map_t::iterator it = m_nodes.begin(); map_t::iterator end = m_nodes.end(); for (; it != end; ++it) { sort* s = it->m_key; sort* ites[3] = { bools[0], s, s }; - add_func_decl(m_manager.mk_func_decl(bfid, OP_ITE, 0, 0, 3, ites)); + add_func_decl(m_manager.mk_func_decl(bfid, OP_ITE, 0, nullptr, 3, ites)); } } diff --git a/src/test/get_consequences.cpp b/src/test/get_consequences.cpp index 6d600f594..767b07b6d 100644 --- a/src/test/get_consequences.cpp +++ b/src/test/get_consequences.cpp @@ -61,12 +61,12 @@ void test2() { datatype_decl_plugin & dt = *(static_cast(m.get_plugin(m.get_family_id("datatype")))); sort_ref_vector new_sorts(m); - constructor_decl* R = mk_constructor_decl(symbol("R"), symbol("is-R"), 0, 0); - constructor_decl* G = mk_constructor_decl(symbol("G"), symbol("is-G"), 0, 0); - constructor_decl* B = mk_constructor_decl(symbol("B"), symbol("is-B"), 0, 0); + constructor_decl* R = mk_constructor_decl(symbol("R"), symbol("is-R"), 0, nullptr); + constructor_decl* G = mk_constructor_decl(symbol("G"), symbol("is-G"), 0, nullptr); + constructor_decl* B = mk_constructor_decl(symbol("B"), symbol("is-B"), 0, nullptr); constructor_decl* constrs[3] = { R, G, B }; datatype_decl * enum_sort = mk_datatype_decl(dtutil, symbol("RGB"), 0, nullptr, 3, constrs); - VERIFY(dt.mk_datatypes(1, &enum_sort, 0, nullptr, new_sorts)); + VERIFY(dt.mk_datatypes(1, &enum_sort, 0, nullptr, new_sorts)); sort* rgb = new_sorts[0].get(); expr_ref x = mk_const(m, "x", rgb), y = mk_const(m, "y", rgb), z = mk_const(m, "z", rgb); @@ -89,7 +89,7 @@ void test2() { fd_solver->push(); fd_solver->assert_expr(m.mk_not(m.mk_eq(x, g))); - VERIFY(l_false == fd_solver->check_sat(0,0)); + VERIFY(l_false == fd_solver->check_sat(0,nullptr)); fd_solver->pop(1); VERIFY(l_true == fd_solver->get_consequences(asms, vars, conseq)); @@ -101,7 +101,7 @@ void test2() { fd_solver->get_model(mr); model_smt2_pp(std::cout << "model:\n", m, *mr.get(), 0); - VERIFY(l_true == fd_solver->check_sat(0,0)); + VERIFY(l_true == fd_solver->check_sat(0,nullptr)); fd_solver->get_model(mr); ENSURE(mr.get()); model_smt2_pp(std::cout, m, *mr.get(), 0); diff --git a/src/test/hilbert_basis.cpp b/src/test/hilbert_basis.cpp index 7329b1d3d..bf059ee10 100644 --- a/src/test/hilbert_basis.cpp +++ b/src/test/hilbert_basis.cpp @@ -210,7 +210,7 @@ expr_ref hilbert_basis_validate::mk_validate(hilbert_basis& hb) { } -hilbert_basis* g_hb = 0; +hilbert_basis* g_hb = nullptr; static double g_start_time; static void display_statistics(hilbert_basis& hb) { diff --git a/src/test/list.cpp b/src/test/list.cpp index 4cfa16801..956477237 100644 --- a/src/test/list.cpp +++ b/src/test/list.cpp @@ -27,10 +27,10 @@ static void tst1() { list * l2 = new (r) list(20, l1); list * l3 = new (r) list(30); list * l4 = new (r) list(40, l3); - ENSURE(append(r, l1, static_cast *>(0)) == l1); - ENSURE(append(r, l2, static_cast *>(0)) == l2); - ENSURE(append(r, static_cast *>(0), l2) == l2); - ENSURE(append(r, static_cast *>(0), static_cast *>(0)) == 0); + ENSURE(append(r, l1, static_cast *>(nullptr)) == l1); + ENSURE(append(r, l2, static_cast *>(nullptr)) == l2); + ENSURE(append(r, static_cast *>(nullptr), l2) == l2); + ENSURE(append(r, static_cast *>(nullptr), static_cast *>(nullptr)) == nullptr); TRACE("list", display(tout, l2->begin(), l2->end()); tout << "\n";); list * l5 = append(r, l4, l2); TRACE("list", display(tout, l5->begin(), l5->end()); tout << "\n";); diff --git a/src/test/main.cpp b/src/test/main.cpp index 98be722e3..ccdc77ec9 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -77,11 +77,11 @@ void display_usage() { void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& test_all) { int i = 1; while (i < argc) { - char * arg = argv[i], *eq_pos = 0; + char * arg = argv[i], *eq_pos = nullptr; if (arg[0] == '-' || arg[0] == '/') { char * opt_name = arg + 1; - char * opt_arg = 0; + char * opt_arg = nullptr; char * colon = strchr(arg, ':'); if (colon) { opt_arg = colon + 1; @@ -96,7 +96,7 @@ void parse_cmd_line_args(int argc, char ** argv, bool& do_display_usage, bool& t else if (strcmp(opt_name, "v") == 0) { if (!opt_arg) error("option argument (/v:level) is missing."); - long lvl = strtol(opt_arg, 0, 10); + long lvl = strtol(opt_arg, nullptr, 10); set_verbosity_level(lvl); } else if (strcmp(opt_name, "w") == 0) { diff --git a/src/test/nlsat.cpp b/src/test/nlsat.cpp index 19add1fab..1d69c8078 100644 --- a/src/test/nlsat.cpp +++ b/src/test/nlsat.cpp @@ -293,7 +293,7 @@ static void tst5() { bool is_even[1] = { false }; nlsat::bool_var b = s.mk_ineq_atom(nlsat::atom::GT, 1, _p, is_even); nlsat::atom * a = s.bool_var2atom(b); - ENSURE(a != 0); + ENSURE(a != nullptr); scoped_anum zero(am); am.set(zero, 0); as.set(0, zero); diff --git a/src/test/old_interval.cpp b/src/test/old_interval.cpp index 4ab8b0dd0..7ef9cdc87 100644 --- a/src/test/old_interval.cpp +++ b/src/test/old_interval.cpp @@ -120,10 +120,10 @@ class interval_tester { interval singleton(int i) { return interval(m, rational(i)); } interval all() { return interval(m); } - interval l(int i, bool o = false, size_t idx = 0) { return interval(m, rational(i), o, true, idx == 0 ? 0 : m.mk_leaf(reinterpret_cast(idx))); } - interval r(int i, bool o = false, size_t idx = 0) { return interval(m, rational(i), o, false, idx == 0 ? 0 : m.mk_leaf(reinterpret_cast(idx))); } + interval l(int i, bool o = false, size_t idx = 0) { return interval(m, rational(i), o, true, idx == 0 ? nullptr : m.mk_leaf(reinterpret_cast(idx))); } + interval r(int i, bool o = false, size_t idx = 0) { return interval(m, rational(i), o, false, idx == 0 ? nullptr : m.mk_leaf(reinterpret_cast(idx))); } interval b(int l, int u, bool lo = false, bool uo = false, size_t idx_l = 0, size_t idx_u = 0) { - return interval(m, rational(l), lo, idx_l == 0 ? 0 : m.mk_leaf(reinterpret_cast(idx_l)), rational(u), uo, idx_u == 0 ? 0 : m.mk_leaf(reinterpret_cast(idx_u))); + return interval(m, rational(l), lo, idx_l == 0 ? nullptr : m.mk_leaf(reinterpret_cast(idx_l)), rational(u), uo, idx_u == 0 ? nullptr : m.mk_leaf(reinterpret_cast(idx_u))); } void bugs() { diff --git a/src/test/pb2bv.cpp b/src/test/pb2bv.cpp index 632b2d642..35c444bae 100644 --- a/src/test/pb2bv.cpp +++ b/src/test/pb2bv.cpp @@ -151,10 +151,10 @@ static void test_solver_semantics(ast_manager& m, expr_ref_vector const& vars, v std::cout << fml1 << " " << fml2 << "\n"; th_rw(fml2, result2, proof); ENSURE(m.is_true(result2) || m.is_false(result2)); - lbool res = slv->check_sat(0,0); + lbool res = slv->check_sat(0,nullptr); VERIFY(res == l_true); slv->assert_expr(m.is_true(result2) ? m.mk_not(result1) : result1.get()); - res = slv->check_sat(0,0); + res = slv->check_sat(0,nullptr); VERIFY(res == l_false); } } diff --git a/src/test/pdr.cpp b/src/test/pdr.cpp index 7e2f1a5ad..45d9eea7e 100644 --- a/src/test/pdr.cpp +++ b/src/test/pdr.cpp @@ -103,7 +103,7 @@ struct test_model_search { unsigned level = 4; for(unsigned n = 0; n < 100; ++n) { state = mk_state(states, rand); - model_node* root = alloc(model_node, 0, state, pt, level); + model_node* root = alloc(model_node, nullptr, state, pt, level); search.set_root(root); add_tree(root, false); search.display(std::cout); diff --git a/src/test/polynorm.cpp b/src/test/polynorm.cpp index 22df91b45..ef01bd27d 100644 --- a/src/test/polynorm.cpp +++ b/src/test/polynorm.cpp @@ -172,7 +172,7 @@ static expr_ref mk_mul(arith_util& arith, unsigned num_args, expr* const* args) static void nf(expr_ref& term) { ast_manager& m = term.get_manager(); - expr *e1 = 0, *e2 = 0; + expr *e1 = nullptr, *e2 = nullptr; th_rewriter rw(m); arith_util arith(m); diff --git a/src/test/sat_user_scope.cpp b/src/test/sat_user_scope.cpp index 10abb44c3..703cf7e3a 100644 --- a/src/test/sat_user_scope.cpp +++ b/src/test/sat_user_scope.cpp @@ -55,7 +55,7 @@ static void init_vars(sat::solver& s) { static void check_coherence(sat::solver& s1, trail_t& t) { params_ref p; reslimit rlim; - sat::solver s2(p, rlim, 0); + sat::solver s2(p, rlim, nullptr); init_vars(s2); sat::literal_vector cls; for (unsigned i = 0; i < t.size(); ++i) { @@ -81,7 +81,7 @@ void tst_sat_user_scope() { trail_t trail; params_ref p; reslimit rlim; - sat::solver s(p, rlim, 0); // incremental solver + sat::solver s(p, rlim, nullptr); // incremental solver init_vars(s); while (true) { for (unsigned i = 0; i < s_num_frames; ++i) { diff --git a/src/test/smt2print_parse.cpp b/src/test/smt2print_parse.cpp index 80a57c7d5..9a8d7b788 100644 --- a/src/test/smt2print_parse.cpp +++ b/src/test/smt2print_parse.cpp @@ -12,7 +12,7 @@ Copyright (c) 2015 Microsoft Corporation void test_print(Z3_context ctx, Z3_ast a) { Z3_set_ast_print_mode(ctx, Z3_PRINT_SMTLIB2_COMPLIANT); - char const* spec1 = Z3_benchmark_to_smtlib_string(ctx, "test", 0, 0, 0, 0, 0, a); + char const* spec1 = Z3_benchmark_to_smtlib_string(ctx, "test", nullptr, nullptr, nullptr, 0, nullptr, a); std::cout << "spec1: benchmark->string\n" << spec1 << "\n"; std::cout << "attempting to parse spec1...\n"; @@ -20,29 +20,29 @@ void test_print(Z3_context ctx, Z3_ast a) { Z3_parse_smtlib2_string(ctx, spec1, 0, + nullptr, + nullptr, 0, - 0, - 0, - 0, - 0); + nullptr, + nullptr); std::cout << "parse successful, converting ast->string\n"; char const* spec2 = Z3_ast_to_string(ctx, b); std::cout << "spec2: string->ast->string\n" << spec2 << "\n"; } void test_parseprint(char const* spec) { - Z3_context ctx = Z3_mk_context(0); + Z3_context ctx = Z3_mk_context(nullptr); std::cout << "spec:\n" << spec << "\n"; Z3_ast a = Z3_parse_smtlib2_string(ctx, spec, 0, + nullptr, + nullptr, 0, - 0, - 0, - 0, - 0); + nullptr, + nullptr); std::cout << "done parsing\n"; diff --git a/src/test/sorting_network.cpp b/src/test/sorting_network.cpp index 1062057f6..12964c192 100644 --- a/src/test/sorting_network.cpp +++ b/src/test/sorting_network.cpp @@ -28,7 +28,7 @@ struct ast_ext { return m.mk_implies(a, b); } UNREACHABLE(); - return 0; + return nullptr; } T mk_default() { return m.mk_false(); diff --git a/src/test/theory_pb.cpp b/src/test/theory_pb.cpp index 8fcbde706..7010b96d0 100644 --- a/src/test/theory_pb.cpp +++ b/src/test/theory_pb.cpp @@ -148,7 +148,7 @@ void tst_theory_pb() { ctx.push(); smt::literal l = smt::theory_pb::assert_ge(ctx, k+1, lits.size(), lits.c_ptr()); if (l != smt::false_literal) { - ctx.assign(l, 0, false); + ctx.assign(l, nullptr, false); TRACE("pb", tout << "assign: " << l << "\n"; ctx.display(tout);); VERIFY(l_false == ctx.check()); @@ -160,7 +160,7 @@ void tst_theory_pb() { ctx.push(); smt::literal l = smt::theory_pb::assert_ge(ctx, k, lits.size(), lits.c_ptr()); ENSURE(l != smt::false_literal); - ctx.assign(l, 0, false); + ctx.assign(l, nullptr, false); TRACE("pb", ctx.display(tout);); VERIFY(l_true == ctx.check()); ctx.pop(1); diff --git a/src/test/udoc_relation.cpp b/src/test/udoc_relation.cpp index 5f1bd7b36..4555d4ef0 100644 --- a/src/test/udoc_relation.cpp +++ b/src/test/udoc_relation.cpp @@ -89,7 +89,7 @@ class udoc_tester { for (unsigned i = 0; i < num_diff; ++i) { t = mk_rand_tbv(dm, result->pos()); if (dm.tbvm().equals(*t, result->pos())) { - return 0; + return nullptr; } if (!result->neg().is_empty() && dm.tbvm().equals(*t, result->neg()[0])) { @@ -278,7 +278,7 @@ public: t1->to_formula(t10); expr_ref delta0(m); delta->to_formula(delta0); - rel_union union_fn = p.mk_union_fn(*t1, *t2, 0); + rel_union union_fn = p.mk_union_fn(*t1, *t2, nullptr); t1->display(std::cout << "t1 before:"); std::cout << "\n"; (*union_fn)(*t1, *t2, delta); @@ -840,7 +840,7 @@ public: void set_random(udoc_relation& r, unsigned num_vals) { unsigned num_bits = r.get_dm().num_tbits(); udoc_relation* full = mk_full(r.get_signature()); - rel_union union_fn = p.mk_union_fn(r, r, 0); + rel_union union_fn = p.mk_union_fn(r, r, nullptr); (*union_fn)(r, *full); doc_manager& dm = r.get_dm(); ENSURE(r.get_udoc().size() == 1); @@ -905,8 +905,8 @@ public: void apply_filter(udoc_relation& t, app* cond) { udoc_relation* full = mk_full(t.get_signature()); - rel_union union_fn = p.mk_union_fn(t, *full, 0); - (*union_fn)(t, *full, 0); + rel_union union_fn = p.mk_union_fn(t, *full, nullptr); + (*union_fn)(t, *full, nullptr); expr_ref fml0(m); t.to_formula(fml0); rel_mut fint = p.mk_filter_interpreted_fn(t, cond); diff --git a/src/test/var_subst.cpp b/src/test/var_subst.cpp index 169b1e131..09535ae8c 100644 --- a/src/test/var_subst.cpp +++ b/src/test/var_subst.cpp @@ -27,7 +27,7 @@ Revision History: namespace find_q { struct proc { quantifier * m_q; - proc():m_q(0) {} + proc():m_q(nullptr) {} void operator()(var * n) {} void operator()(app * n) {} void operator()(quantifier * n) { m_q = n; } diff --git a/src/util/array.h b/src/util/array.h index f0c084b30..cf82e123c 100644 --- a/src/util/array.h +++ b/src/util/array.h @@ -74,7 +74,7 @@ public: typedef T * iterator; typedef const T * const_iterator; - array():m_data(0) {} + array():m_data(nullptr) {} /** \brief Store the array in the given chunk of memory (mem). @@ -123,7 +123,7 @@ public: if (CallDestructors) destroy_elements(); a.deallocate(space(size()), raw_ptr()); - m_data = 0; + m_data = nullptr; } } @@ -148,7 +148,7 @@ public: } unsigned size() const { - if (m_data == 0) { + if (m_data == nullptr) { return 0; } return static_cast(reinterpret_cast(m_data)[SIZE_IDX]); diff --git a/src/util/bit_vector.h b/src/util/bit_vector.h index 2d42e35a2..5f21d2e59 100644 --- a/src/util/bit_vector.h +++ b/src/util/bit_vector.h @@ -62,7 +62,7 @@ public: bit_vector(): m_num_bits(0), m_capacity(0), - m_data(0) { + m_data(nullptr) { } bit_vector(unsigned reserve_num_bits) : @@ -75,7 +75,7 @@ public: bit_vector(bit_vector const & source): m_num_bits(source.m_num_bits), m_capacity(source.m_capacity), - m_data(0) { + m_data(nullptr) { if (source.m_data) { m_data = alloc_svect(unsigned, m_capacity); memcpy(m_data, source.m_data, m_capacity * sizeof(unsigned)); diff --git a/src/util/chashtable.h b/src/util/chashtable.h index 69c48207a..9bc5988e5 100644 --- a/src/util/chashtable.h +++ b/src/util/chashtable.h @@ -106,13 +106,13 @@ protected: SASSERT(target_it < target + target_slots); if (target_it->is_free()) { target_it->m_data = list_it->m_data; - target_it->m_next = 0; + target_it->m_next = nullptr; used_slots++; } else { SASSERT((get_hash(target_it->m_data) & target_mask) == idx); if (target_cellar == target_end) - return 0; // the cellar is too small... + return nullptr; // the cellar is too small... SASSERT(target_cellar >= target + target_slots); SASSERT(target_cellar < target_end); *target_cellar = *target_it; @@ -123,7 +123,7 @@ protected: SASSERT(!target_it->is_free()); list_it = list_it->m_next; } - while (list_it != 0); + while (list_it != nullptr); } } #if 0 @@ -164,13 +164,13 @@ protected: cell * next_cell = copy_table(m_table, m_slots, m_capacity, new_table, new_slots, new_capacity, m_used_slots); - if (next_cell != 0) { + if (next_cell != nullptr) { delete_table(); m_table = new_table; m_capacity = new_capacity; m_slots = new_slots; m_next_cell = next_cell; - m_free_cell = 0; + m_free_cell = nullptr; CASSERT("chashtable", check_invariant()); return; } @@ -180,11 +180,11 @@ protected: } bool has_free_cells() const { - return m_free_cell != 0 || m_next_cell < m_table + m_capacity; + return m_free_cell != nullptr || m_next_cell < m_table + m_capacity; } cell * get_free_cell() { - if (m_free_cell != 0) { + if (m_free_cell != nullptr) { cell * c = m_free_cell; m_free_cell = c->m_next; return c; @@ -211,7 +211,7 @@ protected: m_used_slots = 0; m_size = 0; m_next_cell = m_table + slots; - m_free_cell = 0; + m_free_cell = nullptr; } public: @@ -281,7 +281,7 @@ public: m_size++; m_used_slots++; c->m_data = d; - c->m_next = 0; + c->m_next = nullptr; CASSERT("chashtable_bug", check_invariant()); return; } @@ -297,7 +297,7 @@ public: CHS_CODE(m_collisions++;); it = it->m_next; } - while (it != 0); + while (it != nullptr); // d is not in the table. m_size++; cell * new_c = get_free_cell(); @@ -320,7 +320,7 @@ public: m_size++; m_used_slots++; c->m_data = d; - c->m_next = 0; + c->m_next = nullptr; CASSERT("chashtable_bug", check_invariant()); return c->m_data; } @@ -335,7 +335,7 @@ public: CHS_CODE(m_collisions++;); it = it->m_next; } - while (it != 0); + while (it != nullptr); // d is not in the table. m_size++; cell * new_c = get_free_cell(); @@ -358,7 +358,7 @@ public: m_size++; m_used_slots++; c->m_data = d; - c->m_next = 0; + c->m_next = nullptr; CASSERT("chashtable_bug", check_invariant()); return true; } @@ -373,7 +373,7 @@ public: CHS_CODE(m_collisions++;); it = it->m_next; } - while (it != 0); + while (it != nullptr); // d is not in the table. m_size++; cell * new_c = get_free_cell(); @@ -399,7 +399,7 @@ public: CHS_CODE(const_cast(this)->m_collisions++;); c = c->m_next; } - while (c != 0); + while (c != nullptr); return false; } @@ -409,7 +409,7 @@ public: unsigned idx = h & mask; cell * c = m_table + idx; if (c->is_free()) - return 0; + return nullptr; do { if (equals(c->m_data, d)) { return &(c->m_data); @@ -417,8 +417,8 @@ public: CHS_CODE(const_cast(this)->m_collisions++;); c = c->m_next; } - while (c != 0); - return 0; + while (c != nullptr); + return nullptr; } bool find(T const & d, T & r) { @@ -436,7 +436,7 @@ public: CHS_CODE(const_cast(this)->m_collisions++;); c = c->m_next; } - while (c != 0); + while (c != nullptr); return false; } @@ -447,13 +447,13 @@ public: cell * c = m_table + idx; if (c->is_free()) return; - cell * prev = 0; + cell * prev = nullptr; do { if (equals(c->m_data, d)) { m_size--; - if (prev == 0) { + if (prev == nullptr) { cell * next = c->m_next; - if (next == 0) { + if (next == nullptr) { m_used_slots--; c->mark_free(); SASSERT(c->is_free()); @@ -474,7 +474,7 @@ public: prev = c; c = c->m_next; } - while (c != 0); + while (c != nullptr); } class iterator { @@ -490,12 +490,12 @@ public: } m_it++; } - m_list_it = 0; + m_list_it = nullptr; } public: iterator(cell * start, cell * end): m_it(start), m_end(end) { move_to_used(); } - iterator():m_it(0), m_end(0), m_list_it(0) {} + iterator():m_it(nullptr), m_end(nullptr), m_list_it(nullptr) {} T & operator*() { return m_list_it->m_data; } @@ -506,7 +506,7 @@ public: T * operator->() { return &(operator*()); } iterator & operator++() { m_list_it = m_list_it->m_next; - if (m_list_it == 0) { + if (m_list_it == nullptr) { m_it++; move_to_used(); } @@ -658,7 +658,7 @@ public: bool find(Key const & k, Value & v) const { key_value * e = m_table.find_core(key_value(k)); - if (e == 0) + if (e == nullptr) return false; v = e->m_value; return true; diff --git a/src/util/cmd_context_types.h b/src/util/cmd_context_types.h index ae64e2de6..e82536704 100644 --- a/src/util/cmd_context_types.h +++ b/src/util/cmd_context_types.h @@ -91,8 +91,8 @@ public: virtual void reset(cmd_context & ctx) {} virtual void finalize(cmd_context & ctx) {} virtual symbol get_name() const { return m_name; } - virtual char const * get_usage() const { return 0; } - virtual char const * get_descr(cmd_context & ctx) const { return 0; } + virtual char const * get_usage() const { return nullptr; } + virtual char const * get_descr(cmd_context & ctx) const { return nullptr; } virtual unsigned get_arity() const { return 0; } // command invocation diff --git a/src/util/cooperate.cpp b/src/util/cooperate.cpp index 2ae250206..2b2e7958e 100644 --- a/src/util/cooperate.cpp +++ b/src/util/cooperate.cpp @@ -28,7 +28,7 @@ struct cooperation_lock { cooperation_lock() { omp_set_nested(1); omp_init_nest_lock(&m_lock); - m_task = 0; + m_task = nullptr; m_owner_thread = -1; } ~cooperation_lock() { diff --git a/src/util/debug.cpp b/src/util/debug.cpp index 5d39e7c02..4434cb19f 100644 --- a/src/util/debug.cpp +++ b/src/util/debug.cpp @@ -41,7 +41,7 @@ void notify_assertion_violation(const char * fileName, int line, const char * co std::cerr << condition << "\n"; } -static str_hashtable* g_enabled_debug_tags = 0; +static str_hashtable* g_enabled_debug_tags = nullptr; static void init_debug_table() { if (!g_enabled_debug_tags) { @@ -51,7 +51,7 @@ static void init_debug_table() { void finalize_debug() { dealloc(g_enabled_debug_tags); - g_enabled_debug_tags = 0; + g_enabled_debug_tags = nullptr; } void enable_debug(const char * tag) { @@ -72,7 +72,7 @@ bool is_debug_enabled(const char * tag) { #ifndef _WINDOWS void invoke_gdb() { char buffer[1024]; - int * x = 0; + int * x = nullptr; for (;;) { std::cerr << "(C)ontinue, (A)bort, (S)top, (T)hrow exception, Invoke (G)DB\n"; char result; @@ -103,7 +103,7 @@ void invoke_gdb() { else { std::cerr << "error starting GDB...\n"; // forcing seg fault. - int * x = 0; + int * x = nullptr; *x = 0; } return; diff --git a/src/util/dependency.h b/src/util/dependency.h index 5055399bc..0b6772852 100644 --- a/src/util/dependency.h +++ b/src/util/dependency.h @@ -138,7 +138,7 @@ public: } dependency * mk_empty() { - return 0; + return nullptr; } dependency * mk_leaf(value const & v) { @@ -148,10 +148,10 @@ public: } dependency * mk_join(dependency * d1, dependency * d2) { - if (d1 == 0) { + if (d1 == nullptr) { return d2; } - else if (d2 == 0) { + else if (d2 == nullptr) { return d1; } else if (d1 == d2) { diff --git a/src/util/file_path.h b/src/util/file_path.h index c34c8b408..dbd8130c7 100644 --- a/src/util/file_path.h +++ b/src/util/file_path.h @@ -21,12 +21,12 @@ Revision History: #include inline char const * get_extension(char const * file_name) { - if (file_name == 0) - return 0; - char const * last_dot = 0; + if (file_name == nullptr) + return nullptr; + char const * last_dot = nullptr; for (;;) { char const * tmp = strchr(file_name, '.'); - if (tmp == 0) { + if (tmp == nullptr) { return last_dot; } last_dot = tmp + 1; diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index e71594810..12c335cdf 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -23,7 +23,7 @@ Notes: extern void gparams_register_modules(); static char const * g_old_params_names[] = { - "arith_adaptive","arith_adaptive_assertion_threshold","arith_adaptive_gcd","arith_adaptive_propagation_threshold","arith_add_binary_bounds","arith_blands_rule_threshold","arith_branch_cut_ratio","arith_dump_lemmas","arith_eager_eq_axioms","arith_eager_gcd","arith_eq_bounds","arith_euclidean_solver","arith_expand_eqs","arith_force_simplex","arith_gcd_test","arith_ignore_int","arith_lazy_adapter","arith_lazy_pivoting","arith_max_lemma_size","arith_process_all_eqs","arith_propagate_eqs","arith_propagation_mode","arith_propagation_threshold","arith_prop_strategy","arith_random_initial_value","arith_random_lower","arith_random_seed","arith_random_upper","arith_reflect","arith_skip_big_coeffs","arith_small_lemma_size","arith_solver","arith_stronger_lemmas","array_always_prop_upward","array_canonize","array_cg","array_delay_exp_axiom","array_extensional","array_laziness","array_lazy_ieq","array_lazy_ieq_delay","array_solver","array_weak","async_commands","at_labels_cex","auto_config","bb_eager","bb_ext_gates","bb_quantifiers","bin_clauses","bit2int","bv2int_distribute","bv_blast_max_size","bv_cc","bv_enable_int2bv_propagation","bv_lazy_le","bv_max_sharing","bv_reflect","bv_solver","case_split","check_at_labels","check_proof","cnf_factor","cnf_mode","context_simplifier","dack","dack_eq","dack_factor","dack_gc","dack_gc_inv_decay","dack_threshold","default_qid","default_table","default_table_checked","delay_units","delay_units_threshold","der","display_config","display_dot_proof","display_error_for_visual_studio","display_features","display_proof","display_unsat_core","distribute_forall","dt_lazy_splits","dump_goal_as_smt","elim_and","elim_bounds","elim_nlarith_quantifiers","elim_quantifiers","elim_term_ite","ematching","engine","eq_propagation","hi_div0","ignore_bad_patterns","ignore_setparameter","instruction_max","inst_gen","interactive","internalizer_nnf","lemma_gc_factor","lemma_gc_half","lemma_gc_initial","lemma_gc_new_clause_activity","lemma_gc_new_clause_relevancy","lemma_gc_new_old_ratio","lemma_gc_old_clause_activity","lemma_gc_old_clause_relevancy","lemma_gc_strategy","lift_ite","lookahead_diseq","macro_finder","max_conflicts","max_counterexamples","mbqi","mbqi_force_template","mbqi_max_cexs","mbqi_max_cexs_incr","mbqi_max_iterations","mbqi_trace","minimize_lemmas","model","model_compact","model_completion","model_display_arg_sort","model_hide_unused_partitions","model_on_final_check","model_on_timeout","model_partial","model_v1","model_v2","model_validate","new_core2th_eq","ng_lift_ite","nl_arith","nl_arith_branching","nl_arith_gb","nl_arith_gb_eqs","nl_arith_gb_perturbate","nl_arith_gb_threshold","nl_arith_max_degree","nl_arith_rounds","nnf_factor","nnf_ignore_labels","nnf_mode","nnf_sk_hack","order","order_var_weight","order_weights","phase_selection","pi_arith","pi_arith_weight","pi_avoid_skolems","pi_block_looop_patterns","pi_max_multi_patterns","pi_non_nested_arith_weight","pi_nopat_weight","pi_pull_quantifiers","pi_use_database","pi_warnings","pp_bounded","pp_bv_literals","pp_bv_neg","pp_decimal","pp_decimal_precision","pp_fixed_indent","pp_flat_assoc","pp_max_depth","pp_max_indent","pp_max_num_lines","pp_max_ribbon","pp_max_width","pp_min_alias_size","pp_simplify_implies","pp_single_line","precedence","precedence_gen","pre_demodulator","pre_simplifier","pre_simplify_expr","profile_res_sub","progress_sampling_freq","proof_mode","propagate_booleans","propagate_values","pull_cheap_ite_trees","pull_nested_quantifiers","qi_conservative_final_check","qi_cost","qi_eager_threshold","qi_lazy_instantiation","qi_lazy_quick_checker","qi_lazy_threshold","qi_max_eager_multi_patterns","qi_max_instances","qi_max_lazy_multi_pattern_matching","qi_new_gen","qi_profile","qi_profile_freq","qi_promote_unsat","qi_quick_checker","quasi_macros","random_case_split_freq","random_initial_activity","random_seed","recent_lemma_threshold","reduce_args","refine_inj_axiom","relevancy","relevancy_lemma","rel_case_split_order","restart_adaptive","restart_agility_threshold","restart_factor","restart_initial","restart_strategy","restricted_quasi_macros","simplify_clauses","smtlib2_compliant","smtlib_category","smtlib_dump_lemmas","smtlib_logic","smtlib_source_info","smtlib_trace_path","soft_timeout","solver","spc_bs","spc_es","spc_factor_subsumption_index_opt","spc_initial_subsumption_index_opt","spc_max_subsumption_index_features","spc_min_func_freq_subsumption_index","spc_num_iterations","spc_trace","statistics","strong_context_simplifier","tick","trace","trace_file_name","type_check","user_theory_persist_axioms","user_theory_preprocess_axioms","verbose","warning","well_sorted_check","z3_solver_ll_pp","z3_solver_smt_pp", 0 }; + "arith_adaptive","arith_adaptive_assertion_threshold","arith_adaptive_gcd","arith_adaptive_propagation_threshold","arith_add_binary_bounds","arith_blands_rule_threshold","arith_branch_cut_ratio","arith_dump_lemmas","arith_eager_eq_axioms","arith_eager_gcd","arith_eq_bounds","arith_euclidean_solver","arith_expand_eqs","arith_force_simplex","arith_gcd_test","arith_ignore_int","arith_lazy_adapter","arith_lazy_pivoting","arith_max_lemma_size","arith_process_all_eqs","arith_propagate_eqs","arith_propagation_mode","arith_propagation_threshold","arith_prop_strategy","arith_random_initial_value","arith_random_lower","arith_random_seed","arith_random_upper","arith_reflect","arith_skip_big_coeffs","arith_small_lemma_size","arith_solver","arith_stronger_lemmas","array_always_prop_upward","array_canonize","array_cg","array_delay_exp_axiom","array_extensional","array_laziness","array_lazy_ieq","array_lazy_ieq_delay","array_solver","array_weak","async_commands","at_labels_cex","auto_config","bb_eager","bb_ext_gates","bb_quantifiers","bin_clauses","bit2int","bv2int_distribute","bv_blast_max_size","bv_cc","bv_enable_int2bv_propagation","bv_lazy_le","bv_max_sharing","bv_reflect","bv_solver","case_split","check_at_labels","check_proof","cnf_factor","cnf_mode","context_simplifier","dack","dack_eq","dack_factor","dack_gc","dack_gc_inv_decay","dack_threshold","default_qid","default_table","default_table_checked","delay_units","delay_units_threshold","der","display_config","display_dot_proof","display_error_for_visual_studio","display_features","display_proof","display_unsat_core","distribute_forall","dt_lazy_splits","dump_goal_as_smt","elim_and","elim_bounds","elim_nlarith_quantifiers","elim_quantifiers","elim_term_ite","ematching","engine","eq_propagation","hi_div0","ignore_bad_patterns","ignore_setparameter","instruction_max","inst_gen","interactive","internalizer_nnf","lemma_gc_factor","lemma_gc_half","lemma_gc_initial","lemma_gc_new_clause_activity","lemma_gc_new_clause_relevancy","lemma_gc_new_old_ratio","lemma_gc_old_clause_activity","lemma_gc_old_clause_relevancy","lemma_gc_strategy","lift_ite","lookahead_diseq","macro_finder","max_conflicts","max_counterexamples","mbqi","mbqi_force_template","mbqi_max_cexs","mbqi_max_cexs_incr","mbqi_max_iterations","mbqi_trace","minimize_lemmas","model","model_compact","model_completion","model_display_arg_sort","model_hide_unused_partitions","model_on_final_check","model_on_timeout","model_partial","model_v1","model_v2","model_validate","new_core2th_eq","ng_lift_ite","nl_arith","nl_arith_branching","nl_arith_gb","nl_arith_gb_eqs","nl_arith_gb_perturbate","nl_arith_gb_threshold","nl_arith_max_degree","nl_arith_rounds","nnf_factor","nnf_ignore_labels","nnf_mode","nnf_sk_hack","order","order_var_weight","order_weights","phase_selection","pi_arith","pi_arith_weight","pi_avoid_skolems","pi_block_looop_patterns","pi_max_multi_patterns","pi_non_nested_arith_weight","pi_nopat_weight","pi_pull_quantifiers","pi_use_database","pi_warnings","pp_bounded","pp_bv_literals","pp_bv_neg","pp_decimal","pp_decimal_precision","pp_fixed_indent","pp_flat_assoc","pp_max_depth","pp_max_indent","pp_max_num_lines","pp_max_ribbon","pp_max_width","pp_min_alias_size","pp_simplify_implies","pp_single_line","precedence","precedence_gen","pre_demodulator","pre_simplifier","pre_simplify_expr","profile_res_sub","progress_sampling_freq","proof_mode","propagate_booleans","propagate_values","pull_cheap_ite_trees","pull_nested_quantifiers","qi_conservative_final_check","qi_cost","qi_eager_threshold","qi_lazy_instantiation","qi_lazy_quick_checker","qi_lazy_threshold","qi_max_eager_multi_patterns","qi_max_instances","qi_max_lazy_multi_pattern_matching","qi_new_gen","qi_profile","qi_profile_freq","qi_promote_unsat","qi_quick_checker","quasi_macros","random_case_split_freq","random_initial_activity","random_seed","recent_lemma_threshold","reduce_args","refine_inj_axiom","relevancy","relevancy_lemma","rel_case_split_order","restart_adaptive","restart_agility_threshold","restart_factor","restart_initial","restart_strategy","restricted_quasi_macros","simplify_clauses","smtlib2_compliant","smtlib_category","smtlib_dump_lemmas","smtlib_logic","smtlib_source_info","smtlib_trace_path","soft_timeout","solver","spc_bs","spc_es","spc_factor_subsumption_index_opt","spc_initial_subsumption_index_opt","spc_max_subsumption_index_features","spc_min_func_freq_subsumption_index","spc_num_iterations","spc_trace","statistics","strong_context_simplifier","tick","trace","trace_file_name","type_check","user_theory_persist_axioms","user_theory_preprocess_axioms","verbose","warning","well_sorted_check","z3_solver_ll_pp","z3_solver_smt_pp", nullptr }; bool is_old_param_name(symbol const & name) { char const * const * it = g_old_params_names; @@ -64,7 +64,7 @@ static char const * g_params_renames[] = { "pp_bv_neg", "pp.bv_neg", "pp_max_depth", "pp.max_depth", "pp_min_alias_size", "pp.min_alias_size", - 0 }; + nullptr }; char const * get_new_param_name(symbol const & p) { char const * const * it = g_params_renames; @@ -75,7 +75,7 @@ char const * get_new_param_name(symbol const & p) { } it += 2; } - return 0; + return nullptr; } struct gparams::imp { @@ -191,7 +191,7 @@ public: return m_params; } else { - params_ref * p = 0; + params_ref * p = nullptr; if (!m_module_params.find(mod_name, p)) { p = alloc(params_ref); m_module_params.insert(mod_name, p); @@ -279,7 +279,7 @@ public: throw_unknown_parameter(param_name, d, mod_name); } else if (k == CPK_UINT) { - long val = strtol(value, 0, 10); + long val = strtol(value, nullptr, 10); ps.set_uint(param_name, static_cast(val)); } else if (k == CPK_DOUBLE) { @@ -374,7 +374,7 @@ public: throw_unknown_parameter(p, d, m); } char const * r = d.get_default(p); - if (r == 0) + if (r == nullptr) return "default"; return r; } @@ -397,7 +397,7 @@ public: } } else { - params_ref * ps = 0; + params_ref * ps = nullptr; if (m_module_params.find(m, ps) && ps->contains(p)) { r = get_value(*ps, p); } @@ -427,7 +427,7 @@ public: params_ref get_module(symbol const & module_name) { params_ref result; - params_ref * ps = 0; + params_ref * ps = nullptr; #pragma omp critical (gparams) { if (m_module_params.find(module_name, ps)) { @@ -468,7 +468,7 @@ public: dictionary::iterator end = get_module_param_descrs().end(); for (; it != end; ++it) { out << "[module] " << it->m_key; - char const * descr = 0; + char const * descr = nullptr; if (get_module_descrs().find(it->m_key, descr)) { out << ", description: " << descr; } @@ -485,7 +485,7 @@ public: dictionary::iterator end = get_module_param_descrs().end(); for (; it != end; ++it) { out << "[module] " << it->m_key; - char const * descr = 0; + char const * descr = nullptr; if (get_module_descrs().find(it->m_key, descr)) { out << ", description: " << descr; } @@ -500,14 +500,14 @@ public: #pragma omp critical (gparams) { try { - param_descrs * d = 0; + param_descrs * d = nullptr; if (!get_module_param_descrs().find(module_name, d)) { std::stringstream strm; strm << "unknown module '" << module_name << "'"; throw exception(strm.str()); } out << "[module] " << module_name; - char const * descr = 0; + char const * descr = nullptr; if (get_module_descrs().find(module_name, descr)) { out << ", description: " << descr; } @@ -566,7 +566,7 @@ public: } }; -gparams::imp * gparams::g_imp = 0; +gparams::imp * gparams::g_imp = nullptr; void gparams::reset() { SASSERT(g_imp != 0); @@ -651,9 +651,9 @@ void gparams::init() { void gparams::finalize() { TRACE("gparams", tout << "gparams::finalize()\n";); - if (g_imp != 0) { + if (g_imp != nullptr) { dealloc(g_imp); - g_imp = 0; + g_imp = nullptr; } } diff --git a/src/util/hashtable.h b/src/util/hashtable.h index fa9fef180..0421fd300 100644 --- a/src/util/hashtable.h +++ b/src/util/hashtable.h @@ -91,9 +91,9 @@ class ptr_hash_entry { T * m_ptr; public: typedef T * data; - ptr_hash_entry():m_ptr(0) {} + ptr_hash_entry():m_ptr(nullptr) {} unsigned get_hash() const { return m_hash; } - bool is_free() const { return m_ptr == 0; } + bool is_free() const { return m_ptr == nullptr; } bool is_deleted() const { return m_ptr == reinterpret_cast(1); } bool is_used() const { return m_ptr != reinterpret_cast(0) && m_ptr != reinterpret_cast(1); } T * get_data() const { return m_ptr; } @@ -101,7 +101,7 @@ public: void set_data(T * d) { m_ptr = d; } void set_hash(unsigned h) { m_hash = h; } void mark_as_deleted() { m_ptr = reinterpret_cast(1); } - void mark_as_free() { m_ptr = 0; } + void mark_as_free() { m_ptr = nullptr; } }; @@ -114,9 +114,9 @@ class ptr_addr_hash_entry : public ptr_hash_entry { T * m_ptr; public: typedef T * data; - ptr_addr_hash_entry():m_ptr(0) {} + ptr_addr_hash_entry():m_ptr(nullptr) {} unsigned get_hash() const { return get_ptr_hash(m_ptr); } - bool is_free() const { return m_ptr == 0; } + bool is_free() const { return m_ptr == nullptr; } bool is_deleted() const { return m_ptr == reinterpret_cast(1); } bool is_used() const { return m_ptr != reinterpret_cast(0) && m_ptr != reinterpret_cast(1); } T * get_data() const { return m_ptr; } @@ -145,7 +145,7 @@ protected: void delete_table() { dealloc_vect(m_table, m_capacity); - m_table = 0; + m_table = nullptr; } public: @@ -385,7 +385,7 @@ public: entry * begin = m_table + idx; entry * end = m_table + m_capacity; entry * curr = begin; - entry * del_entry = 0; + entry * del_entry = nullptr; for (; curr != end; ++curr) { INSERT_LOOP_BODY(); } @@ -441,7 +441,7 @@ public: entry * begin = m_table + idx; entry * end = m_table + m_capacity; entry * curr = begin; - entry * del_entry = 0; + entry * del_entry = nullptr; for (; curr != end; ++curr) { INSERT_LOOP_CORE_BODY(); } @@ -504,12 +504,12 @@ public: for (curr = m_table; curr != begin; ++curr) { FIND_LOOP_BODY(); } - return 0; + return nullptr; } bool find(data const & k, data & r) const { entry * e = find_core(k); - if (e != 0) { + if (e != nullptr) { r = e->get_data(); return true; } @@ -517,7 +517,7 @@ public: } bool contains(data const & e) const { - return find_core(e) != 0; + return find_core(e) != nullptr; } iterator find(data const & e) const { diff --git a/src/util/list.h b/src/util/list.h index efde5ada1..075d5a0e1 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -28,7 +28,7 @@ class list { list * m_tail; public: - list(T const & h, list * t = 0): + list(T const & h, list * t = nullptr): m_head(h), m_tail(t) { } @@ -73,7 +73,7 @@ unsigned length(list * l) { */ template list * append(region & r, list * l1, list * l2) { - if (l2 == 0) { + if (l2 == nullptr) { return l1; } ptr_buffer > buffer; diff --git a/src/util/lp/lar_core_solver.h b/src/util/lp/lar_core_solver.h index 61b0d9b38..32229cf27 100644 --- a/src/util/lp/lar_core_solver.h +++ b/src/util/lp/lar_core_solver.h @@ -481,7 +481,7 @@ public: } bool no_r_lu() const { - return m_r_solver.m_factorization == nullptr || m_r_solver.m_factorization->get_status() == LU_status::Degenerated; + return m_r_solver.m_factorization == nullptr || m_r_solver.m_factorization->get_status() == LU_status::Degenerated; } void solve_on_signature_tableau(const lar_solution_signature & signature, const vector & changes_of_basis) { diff --git a/src/util/map.h b/src/util/map.h index 3a59c8975..2ee540932 100644 --- a/src/util/map.h +++ b/src/util/map.h @@ -129,7 +129,7 @@ public: if (e) { v = e->get_data().m_value; } - return (0 != e); + return (nullptr != e); } value const& get(key const& k, value const& default_value) const { @@ -164,7 +164,7 @@ public: bool contains(key const & k) const { - return find_core(k) != 0; + return find_core(k) != nullptr; } void remove(key const & k) { diff --git a/src/util/memory_manager.cpp b/src/util/memory_manager.cpp index 44157aa65..833ac8cbd 100644 --- a/src/util/memory_manager.cpp +++ b/src/util/memory_manager.cpp @@ -342,7 +342,7 @@ void * memory::allocate(size_t s) { if (counts_exceeded) throw_alloc_counts_exceeded(); void * r = malloc(s); - if (r == 0) + if (r == nullptr) throw_out_of_memory(); *(static_cast(r)) = s; return static_cast(r) + 1; // we return a pointer to the location after the extra field @@ -370,7 +370,7 @@ void* memory::reallocate(void *p, size_t s) { if (counts_exceeded) throw_alloc_counts_exceeded(); void *r = realloc(real_p, s); - if (r == 0) + if (r == nullptr) throw_out_of_memory(); *(static_cast(r)) = s; return static_cast(r) + 1; // we return a pointer to the location after the extra field diff --git a/src/util/memory_manager.h b/src/util/memory_manager.h index 5aa512018..273fadea9 100644 --- a/src/util/memory_manager.h +++ b/src/util/memory_manager.h @@ -90,7 +90,7 @@ void deallocf(char const* file, int line, T * ptr) { template void dealloc(T * ptr) { - if (ptr == 0) return; + if (ptr == nullptr) return; ptr->~T(); memory::deallocate(ptr); } @@ -111,7 +111,7 @@ T * alloc_vect(unsigned sz) { template void dealloc_vect(T * ptr, unsigned sz) { - if (ptr == 0) return; + if (ptr == nullptr) return; T * curr = ptr; for (unsigned i = 0; i < sz; i++, curr++) curr->~T(); @@ -122,7 +122,7 @@ void dealloc_vect(T * ptr, unsigned sz) { template void dealloc_svect(T * ptr) { - if (ptr == 0) return; + if (ptr == nullptr) return; memory::deallocate(ptr); } diff --git a/src/util/mpfx.cpp b/src/util/mpfx.cpp index 24ef4dc73..e46708341 100644 --- a/src/util/mpfx.cpp +++ b/src/util/mpfx.cpp @@ -201,7 +201,7 @@ void mpfx_manager::set(mpfx & n, uint64 v) { n.m_sign = 0; unsigned * w = words(n); uint64 * _vp = &v; - unsigned * _v = 0; + unsigned * _v = nullptr; memcpy(&_v, &_vp, sizeof(unsigned*)); for (unsigned i = 0; i < m_total_sz; i++) w[i] = 0; diff --git a/src/util/mpz.h b/src/util/mpz.h index f4629958f..f4c3f6f0d 100644 --- a/src/util/mpz.h +++ b/src/util/mpz.h @@ -92,9 +92,9 @@ class mpz { friend class mpbq_manager; mpz & operator=(mpz const & other) { UNREACHABLE(); return *this; } public: - mpz(int v):m_val(v), m_ptr(0) {} - mpz():m_val(0), m_ptr(0) {} - mpz(mpz && other) : m_val(other.m_val), m_ptr(0) { + mpz(int v):m_val(v), m_ptr(nullptr) {} + mpz():m_val(0), m_ptr(nullptr) {} + mpz(mpz && other) : m_val(other.m_val), m_ptr(nullptr) { std::swap(m_ptr, other.m_ptr); } void swap(mpz & other) { @@ -333,16 +333,16 @@ public: ~mpz_manager(); - static bool is_small(mpz const & a) { return a.m_ptr == 0; } + static bool is_small(mpz const & a) { return a.m_ptr == nullptr; } static mpz mk_z(int val) { return mpz(val); } void del(mpz & a) { - if (a.m_ptr != 0) { + if (a.m_ptr != nullptr) { MPZ_BEGIN_CRITICAL(); deallocate(a.m_ptr); MPZ_END_CRITICAL(); - a.m_ptr = 0; + a.m_ptr = nullptr; } } diff --git a/src/util/obj_hashtable.h b/src/util/obj_hashtable.h index df279383b..8826e8b76 100644 --- a/src/util/obj_hashtable.h +++ b/src/util/obj_hashtable.h @@ -33,9 +33,9 @@ class obj_hash_entry { T * m_ptr; public: typedef T * data; - obj_hash_entry():m_ptr(0) {} + obj_hash_entry():m_ptr(nullptr) {} unsigned get_hash() const { return m_ptr->hash(); } - bool is_free() const { return m_ptr == 0; } + bool is_free() const { return m_ptr == nullptr; } bool is_deleted() const { return m_ptr == reinterpret_cast(1); } bool is_used() const { return m_ptr != reinterpret_cast(0) && m_ptr != reinterpret_cast(1); } T * get_data() const { return m_ptr; } @@ -43,7 +43,7 @@ public: void set_data(T * d) { m_ptr = d; } void set_hash(unsigned h) { SASSERT(h == m_ptr->hash()); } void mark_as_deleted() { m_ptr = reinterpret_cast(1); } - void mark_as_free() { m_ptr = 0; } + void mark_as_free() { m_ptr = nullptr; } }; template @@ -60,7 +60,7 @@ public: struct key_data { Key * m_key; Value m_value; - key_data():m_key(0) { + key_data():m_key(nullptr) { } key_data(Key * k): m_key(k) { @@ -85,7 +85,7 @@ public: typedef key_data data; obj_map_entry() {} unsigned get_hash() const { return m_data.hash(); } - bool is_free() const { return m_data.m_key == 0; } + bool is_free() const { return m_data.m_key == nullptr; } bool is_deleted() const { return m_data.m_key == reinterpret_cast(1); } bool is_used() const { return m_data.m_key != reinterpret_cast(0) && m_data.m_key != reinterpret_cast(1); } key_data const & get_data() const { return m_data; } @@ -93,7 +93,7 @@ public: void set_data(key_data && d) { m_data = std::move(d); } void set_hash(unsigned h) { SASSERT(h == m_data.hash()); } void mark_as_deleted() { m_data.m_key = reinterpret_cast(1); } - void mark_as_free() { m_data.m_key = 0; } + void mark_as_free() { m_data.m_key = nullptr; } }; typedef core_hashtable, default_eq > table; @@ -163,7 +163,7 @@ public: if (e) { v = e->get_data().m_value; } - return (0 != e); + return (nullptr != e); } value const & find(key * k) const { @@ -191,7 +191,7 @@ public: } bool contains(Key * k) const { - return find_core(k) != 0; + return find_core(k) != nullptr; } void remove(Key * k) { diff --git a/src/util/obj_pair_hashtable.h b/src/util/obj_pair_hashtable.h index 2addc3902..f002a7807 100644 --- a/src/util/obj_pair_hashtable.h +++ b/src/util/obj_pair_hashtable.h @@ -34,7 +34,7 @@ class obj_pair_hash_entry { public: typedef std::pair data; - obj_pair_hash_entry():m_data(static_cast(0),static_cast(0)) {} + obj_pair_hash_entry():m_data(static_cast(nullptr),static_cast(nullptr)) {} unsigned get_hash() const { return m_hash; } bool is_free() const { return m_data.first == 0; } bool is_deleted() const { return m_data.first == reinterpret_cast(1); } @@ -68,8 +68,8 @@ public: friend class entry; public: key_data(): - m_key1(0), - m_key2(0), + m_key1(nullptr), + m_key2(nullptr), m_hash(0) { } key_data(Key1 * k1, Key2 * k2): @@ -96,7 +96,7 @@ protected: typedef key_data data; entry() {} unsigned get_hash() const { return m_data.hash(); } - bool is_free() const { return m_data.m_key1 == 0; } + bool is_free() const { return m_data.m_key1 == nullptr; } bool is_deleted() const { return m_data.m_key1 == reinterpret_cast(1); } bool is_used() const { return m_data.m_key1 != reinterpret_cast(0) && m_data.m_key1 != reinterpret_cast(1); } key_data const & get_data() const { return m_data; } @@ -104,7 +104,7 @@ protected: void set_data(key_data const & d) { m_data = d; } void set_hash(unsigned h) { SASSERT(h == m_data.hash()); } void mark_as_deleted() { m_data.m_key1 = reinterpret_cast(1); } - void mark_as_free() { m_data.m_key1 = 0; } + void mark_as_free() { m_data.m_key1 = nullptr; } }; typedef core_hashtable, default_eq > table; @@ -158,11 +158,11 @@ public: if (e) { v = e->get_data().get_value(); } - return (0 != e); + return (nullptr != e); } bool contains(Key1 * k1, Key2 * k2) const { - return find_core(k1, k2) != 0; + return find_core(k1, k2) != nullptr; } void erase(Key1 * k1, Key2 * k2) { diff --git a/src/util/obj_ref.h b/src/util/obj_ref.h index 72762ea5b..409a77fc0 100644 --- a/src/util/obj_ref.h +++ b/src/util/obj_ref.h @@ -43,7 +43,7 @@ public: } explicit obj_ref(TManager & m): - m_obj(0), + m_obj(nullptr), m_manager(m) { } @@ -53,7 +53,7 @@ public: inc_ref(); } - obj_ref(obj_ref && other) : m_obj(0), m_manager(other.m_manager) { + obj_ref(obj_ref && other) : m_obj(nullptr), m_manager(other.m_manager) { std::swap(m_obj, other.m_obj); } @@ -67,9 +67,9 @@ public: T * get() const { return m_obj; } - operator bool() const { return m_obj != 0; } + operator bool() const { return m_obj != nullptr; } - bool operator!() const { return m_obj == 0; } + bool operator!() const { return m_obj == nullptr; } operator T*() const { return m_obj; } @@ -94,7 +94,7 @@ public: void reset() { dec_ref(); - m_obj = 0; + m_obj = nullptr; } void swap(obj_ref & n) { diff --git a/src/util/obj_triple_hashtable.h b/src/util/obj_triple_hashtable.h index 316b63b93..d9034c2e3 100644 --- a/src/util/obj_triple_hashtable.h +++ b/src/util/obj_triple_hashtable.h @@ -70,9 +70,9 @@ public: friend class entry; public: key_data(): - m_key1(0), - m_key2(0), - m_key3(0), + m_key1(nullptr), + m_key2(nullptr), + m_key3(nullptr), m_hash(0) { } key_data(Key1 * k1, Key2 * k2, Key3 * k3): @@ -102,7 +102,7 @@ protected: typedef key_data data; entry() {} unsigned get_hash() const { return m_data.hash(); } - bool is_free() const { return m_data.m_key1 == 0; } + bool is_free() const { return m_data.m_key1 == nullptr; } bool is_deleted() const { return m_data.m_key1 == reinterpret_cast(1); } bool is_used() const { return m_data.m_key1 != reinterpret_cast(0) && m_data.m_key1 != reinterpret_cast(1); } key_data const & get_data() const { return m_data; } @@ -110,7 +110,7 @@ protected: void set_data(key_data const & d) { m_data = d; } void set_hash(unsigned h) { SASSERT(h == m_data.hash()); } void mark_as_deleted() { m_data.m_key1 = reinterpret_cast(1); } - void mark_as_free() { m_data.m_key1 = 0; } + void mark_as_free() { m_data.m_key1 = nullptr; } }; typedef core_hashtable, default_eq > table; @@ -164,7 +164,7 @@ public: if (e) { v = e->get_data().get_value(); } - return (0 != e); + return (nullptr != e); } bool contains(Key1 * k1, Key2 * k2, Key3 * k3) const { diff --git a/src/util/optional.h b/src/util/optional.h index 5b3753ac6..d496fd322 100644 --- a/src/util/optional.h +++ b/src/util/optional.h @@ -34,14 +34,14 @@ class optional { void destroy() { if (m_initialized == 1) { dealloc(m_obj); - m_obj = 0; + m_obj = nullptr; } m_initialized = 0; } public: optional(): - m_obj(0), m_initialized(0) {} + m_obj(nullptr), m_initialized(0) {} explicit optional(const T & val) { construct(val); @@ -128,7 +128,7 @@ class optional { public: - optional():m_ptr(0) {} + optional():m_ptr(nullptr) {} explicit optional(T * val):m_ptr(val) {} @@ -140,7 +140,7 @@ public: operator bool() const { return m_ptr != 0; } - bool operator!() const { return m_ptr == 0; } + bool operator!() const { return m_ptr == nullptr; } void reset() { m_ptr = 0; } diff --git a/src/util/page.cpp b/src/util/page.cpp index 4f6cea83c..ebf246fc1 100644 --- a/src/util/page.cpp +++ b/src/util/page.cpp @@ -31,7 +31,7 @@ inline char * alloc_page(size_t s) { char * r = alloc_svect(char, s+PAGE_HEADER_ inline void del_page(char * page) { dealloc_svect(page - PAGE_HEADER_SZ); } void del_pages(char * page) { - while (page != 0) { + while (page != nullptr) { char * prev = prev_page(page); del_page(page); page = prev; diff --git a/src/util/params.cpp b/src/util/params.cpp index ee6ce6627..5e1e517c1 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -24,7 +24,7 @@ Notes: params_ref params_ref::g_empty_params_ref; std::string norm_param_name(char const * n) { - if (n == 0) + if (n == nullptr) return "_"; if (*n == ':') n++; @@ -62,9 +62,9 @@ struct param_descrs::imp { info(): m_kind(CPK_INVALID), - m_descr(0), - m_default(0), - m_module(0) { + m_descr(nullptr), + m_default(nullptr), + m_module(nullptr) { } }; @@ -130,21 +130,21 @@ struct param_descrs::imp { info i; if (m_info.find(name, i)) return i.m_module; - return 0; + return nullptr; } char const * get_descr(symbol const & name) const { info i; if (m_info.find(name, i)) return i.m_descr; - return 0; + return nullptr; } char const * get_default(symbol const & name) const { info i; if (m_info.find(name, i)) return i.m_default; - return 0; + return nullptr; } unsigned size() const { @@ -191,7 +191,7 @@ struct param_descrs::imp { out << " (" << d.m_kind << ")"; if (include_descr) out << " " << d.m_descr; - if (d.m_default != 0) + if (d.m_default != nullptr) out << " (default: " << d.m_default << ")"; out << "\n"; } @@ -510,7 +510,7 @@ params_ref::~params_ref() { } params_ref::params_ref(params_ref const & p): - m_params(0) { + m_params(nullptr) { operator=(p); } @@ -554,7 +554,7 @@ params_ref & params_ref::operator=(params_ref const & p) { } void params_ref::copy(params_ref const & src) { - if (m_params == 0) + if (m_params == nullptr) operator=(src); else { init(); @@ -563,7 +563,7 @@ void params_ref::copy(params_ref const & src) { } void params_ref::copy_core(params const * src) { - if (src == 0) + if (src == nullptr) return; svector::const_iterator it = src->m_entries.begin(); svector::const_iterator end = src->m_entries.end(); diff --git a/src/util/params.h b/src/util/params.h index bad70a318..0a68a9606 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -37,7 +37,7 @@ class params_ref { void init(); void copy_core(params const * p); public: - params_ref():m_params(0) {} + params_ref():m_params(nullptr) {} params_ref(params_ref const & p); ~params_ref(); @@ -115,8 +115,8 @@ public: param_descrs(); ~param_descrs(); void copy(param_descrs & other); - void insert(char const * name, param_kind k, char const * descr, char const * def = 0, char const* module = 0); - void insert(symbol const & name, param_kind k, char const * descr, char const * def = 0, char const* module = 0); + void insert(char const * name, param_kind k, char const * descr, char const * def = nullptr, char const* module = nullptr); + void insert(symbol const & name, param_kind k, char const * descr, char const * def = nullptr, char const* module = nullptr); bool contains(char const * name) const; bool contains(symbol const & name) const; void erase(char const * name); diff --git a/src/util/parray.h b/src/util/parray.h index 44b075db9..38d6987d0 100644 --- a/src/util/parray.h +++ b/src/util/parray.h @@ -30,7 +30,7 @@ public: typedef typename C::allocator allocator; private: static size_t capacity(value * vs) { - return vs == 0 ? 0 : (reinterpret_cast(vs))[-1]; + return vs == nullptr ? 0 : (reinterpret_cast(vs))[-1]; } value * allocate_values(size_t c) { @@ -44,7 +44,7 @@ private: } void deallocate_values(value * vs) { - if (vs == 0) + if (vs == nullptr) return; size_t c = capacity(vs); TRACE("parray_mem", tout << "deallocated values[" << c << "]: " << vs << "\n";); @@ -73,7 +73,7 @@ private: unsigned size() const { SASSERT(kind() == ROOT); return m_size; } cell * next() const { SASSERT(kind() != ROOT); return m_next; } value const & elem() const { SASSERT(kind() == SET || kind() == PUSH_BACK); return m_elem; } - cell(ckind k):m_ref_count(1), m_kind(k), m_size(0), m_values(0) {} + cell(ckind k):m_ref_count(1), m_kind(k), m_size(0), m_values(nullptr) {} }; value_manager & m_vmanager; @@ -105,7 +105,7 @@ private: void del(cell * c) { while (true) { - cell * next = 0; + cell * next = nullptr; switch (c->kind()) { case SET: case PUSH_BACK: @@ -123,7 +123,7 @@ private: TRACE("parray_mem", tout << "deallocated cell: " << c << "\n";); c->~cell(); m_allocator.deallocate(sizeof(cell), c); - if (next == 0) + if (next == nullptr) return; SASSERT(next->m_ref_count > 0); next->m_ref_count--; @@ -214,7 +214,7 @@ private: } SASSERT(r->kind() == ROOT); unsigned sz = r->m_size; - vs = 0; + vs = nullptr; copy_values(r->m_values, sz, vs); unsigned i = cs.size(); while (i > 0) { @@ -246,7 +246,7 @@ private: dec_ref(c->m_next); if (c->kind() == SET || c->kind() == PUSH_BACK) dec_ref(c->m_elem); - c->m_next = 0; + c->m_next = nullptr; c->m_kind = ROOT; c->m_size = sz; c->m_values = vs; @@ -262,7 +262,7 @@ public: bool unshared() const { return m_ref->m_ref_count == 1; } friend class parray_manager; public: - ref():m_ref(0), m_updt_counter(0) {} + ref():m_ref(nullptr), m_updt_counter(0) {} }; public: @@ -283,7 +283,7 @@ public: void del(ref & r) { dec_ref(r.m_ref); - r.m_ref = 0; + r.m_ref = nullptr; r.m_updt_counter = 0; } @@ -296,7 +296,7 @@ public: unsigned size(ref const & r) const { cell * c = r.m_ref; - if (c == 0) return 0; + if (c == nullptr) return 0; while (true) { switch (c->kind()) { case SET: @@ -397,7 +397,7 @@ public: } void push_back(ref & r, value const & v) { - if (r.m_ref == 0) + if (r.m_ref == nullptr) mk(r); if (r.root()) { if (r.unshared()) { diff --git a/src/util/plugin_manager.h b/src/util/plugin_manager.h index da7017aa1..c8908fd57 100644 --- a/src/util/plugin_manager.h +++ b/src/util/plugin_manager.h @@ -48,7 +48,7 @@ public: Plugin * get_plugin(family_id fid) const { if (fid == null_family_id) { - return 0; + return nullptr; } return m_fid2plugins.get(fid, 0); } diff --git a/src/util/prime_generator.cpp b/src/util/prime_generator.cpp index eac47f61b..dbcccaaf7 100644 --- a/src/util/prime_generator.cpp +++ b/src/util/prime_generator.cpp @@ -99,7 +99,7 @@ uint64 prime_generator::operator()(unsigned idx) { prime_generator g_prime_generator; prime_iterator::prime_iterator(prime_generator * g):m_idx(0) { - if (g == 0) { + if (g == nullptr) { m_generator = &g_prime_generator; m_global = true; } diff --git a/src/util/prime_generator.h b/src/util/prime_generator.h index 6a284c57c..2e16ebfbe 100644 --- a/src/util/prime_generator.h +++ b/src/util/prime_generator.h @@ -45,7 +45,7 @@ class prime_iterator { prime_generator * m_generator; bool m_global; public: - prime_iterator(prime_generator * g = 0); + prime_iterator(prime_generator * g = nullptr); uint64 next(); static void finalize(); /* diff --git a/src/util/rational.cpp b/src/util/rational.cpp index ce38bcaa7..e8c2d52d1 100644 --- a/src/util/rational.cpp +++ b/src/util/rational.cpp @@ -23,7 +23,7 @@ Revision History: #include #endif -synch_mpq_manager * rational::g_mpq_manager = 0; +synch_mpq_manager * rational::g_mpq_manager = nullptr; rational rational::m_zero; rational rational::m_one; rational rational::m_minus_one; @@ -80,6 +80,6 @@ void rational::finalize() { m_one.~rational(); m_minus_one.~rational(); dealloc(g_mpq_manager); - g_mpq_manager = 0; + g_mpq_manager = nullptr; } diff --git a/src/util/ref.h b/src/util/ref.h index 811aba9af..ea6b7a624 100644 --- a/src/util/ref.h +++ b/src/util/ref.h @@ -37,7 +37,7 @@ class ref { public: ref(): - m_ptr(0) { + m_ptr(nullptr) { } ref(T * ptr): @@ -64,7 +64,7 @@ public: } operator bool() const { - return m_ptr != 0; + return m_ptr != nullptr; } const T & operator*() const { @@ -100,12 +100,12 @@ public: void reset() { dec_ref(); - m_ptr = 0; + m_ptr = nullptr; } T* detach() { T* tmp = m_ptr; - m_ptr = 0; + m_ptr = nullptr; return tmp; } diff --git a/src/util/region.cpp b/src/util/region.cpp index 4e5b5f2f2..3cf3f502f 100644 --- a/src/util/region.cpp +++ b/src/util/region.cpp @@ -38,11 +38,11 @@ inline void region::allocate_page() { } region::region() { - m_curr_page = 0; - m_curr_ptr = 0; - m_curr_end_ptr = 0; - m_free_pages = 0; - m_mark = 0; + m_curr_page = nullptr; + m_curr_ptr = nullptr; + m_curr_end_ptr = nullptr; + m_free_pages = nullptr; + m_mark = nullptr; allocate_page(); } @@ -81,13 +81,13 @@ inline void region::recycle_curr_page() { } void region::reset() { - while (m_curr_page != 0) { + while (m_curr_page != nullptr) { recycle_curr_page(); } SASSERT(m_curr_page == 0); - m_curr_ptr = 0; - m_curr_end_ptr = 0; - m_mark = 0; + m_curr_ptr = nullptr; + m_curr_end_ptr = nullptr; + m_mark = nullptr; allocate_page(); } @@ -113,7 +113,7 @@ void region::pop_scope() { void region::display_mem_stats(std::ostream & out) const { unsigned n = 0; char * page = m_curr_page; - while (page != 0) { + while (page != nullptr) { n++; page = prev_page(page); } diff --git a/src/util/s_integer.cpp b/src/util/s_integer.cpp index cfaf34fff..e76781388 100644 --- a/src/util/s_integer.cpp +++ b/src/util/s_integer.cpp @@ -24,7 +24,7 @@ s_integer s_integer::m_one(1); s_integer s_integer::m_minus_one(-1); s_integer::s_integer(const char * str) { - m_val = static_cast(strtol(str, 0, 10)); + m_val = static_cast(strtol(str, nullptr, 10)); } s_integer power(const s_integer & r, unsigned p) { diff --git a/src/util/scoped_ctrl_c.cpp b/src/util/scoped_ctrl_c.cpp index 1cb3a03c4..2dbbaec9b 100644 --- a/src/util/scoped_ctrl_c.cpp +++ b/src/util/scoped_ctrl_c.cpp @@ -20,7 +20,7 @@ Revision History: #include #include "util/scoped_ctrl_c.h" -scoped_ctrl_c * scoped_ctrl_c::g_obj = 0; +scoped_ctrl_c * scoped_ctrl_c::g_obj = nullptr; void scoped_ctrl_c::on_ctrl_c(int) { if (g_obj->m_first) { diff --git a/src/util/scoped_ptr_vector.h b/src/util/scoped_ptr_vector.h index 0bd0fd47e..920ecb2c9 100644 --- a/src/util/scoped_ptr_vector.h +++ b/src/util/scoped_ptr_vector.h @@ -30,7 +30,7 @@ public: ~scoped_ptr_vector() { reset(); } void reset() { std::for_each(m_vector.begin(), m_vector.end(), delete_proc()); m_vector.reset(); } void push_back(T * ptr) { m_vector.push_back(ptr); } - void pop_back() { SASSERT(!empty()); set(size()-1, 0); m_vector.pop_back(); } + void pop_back() { SASSERT(!empty()); set(size()-1, nullptr); m_vector.pop_back(); } T * operator[](unsigned idx) const { return m_vector[idx]; } void set(unsigned idx, T * ptr) { if (m_vector[idx] == ptr) @@ -48,7 +48,7 @@ public: } else { for (unsigned i = m_vector.size(); i < sz; i++) - push_back(0); + push_back(nullptr); } } }; diff --git a/src/util/scoped_timer.cpp b/src/util/scoped_timer.cpp index 3991abd36..1ecca8ffe 100644 --- a/src/util/scoped_timer.cpp +++ b/src/util/scoped_timer.cpp @@ -157,9 +157,9 @@ struct scoped_timer::imp { m_interval = ms?ms:0xFFFFFFFF; if (pthread_attr_init(&m_attributes) != 0) throw default_exception("failed to initialize timer thread attributes"); - if (pthread_cond_init(&m_condition_var, NULL) != 0) + if (pthread_cond_init(&m_condition_var, nullptr) != 0) throw default_exception("failed to initialize timer condition variable"); - if (pthread_mutex_init(&m_mutex, NULL) != 0) + if (pthread_mutex_init(&m_mutex, nullptr) != 0) throw default_exception("failed to initialize timer mutex"); clock_serv_t host_clock; @@ -208,7 +208,7 @@ struct scoped_timer::imp { pthread_cond_signal(&m_condition_var); pthread_mutex_unlock(&m_mutex); - if (pthread_join(m_thread_id, NULL) != 0) + if (pthread_join(m_thread_id, nullptr) != 0) throw default_exception("failed to join thread"); if (pthread_mutex_destroy(&m_mutex) != 0) throw default_exception("failed to destroy pthread mutex"); @@ -248,7 +248,7 @@ scoped_timer::scoped_timer(unsigned ms, event_handler * eh) { if (ms != UINT_MAX && ms != 0) m_imp = alloc(imp, ms, eh); else - m_imp = 0; + m_imp = nullptr; } scoped_timer::~scoped_timer() { diff --git a/src/util/small_object_allocator.cpp b/src/util/small_object_allocator.cpp index 0eb7b9ec3..9f15aadaf 100644 --- a/src/util/small_object_allocator.cpp +++ b/src/util/small_object_allocator.cpp @@ -27,8 +27,8 @@ Revision History: small_object_allocator::small_object_allocator(char const * id) { for (unsigned i = 0; i < NUM_SLOTS; i++) { - m_chunks[i] = 0; - m_free_list[i] = 0; + m_chunks[i] = nullptr; + m_free_list[i] = nullptr; } DEBUG_CODE({ m_id = id; @@ -60,8 +60,8 @@ void small_object_allocator::reset() { dealloc(c); c = next; } - m_chunks[i] = 0; - m_free_list[i] = 0; + m_chunks[i] = nullptr; + m_free_list[i] = nullptr; } m_alloc_size = 0; } @@ -95,7 +95,7 @@ void small_object_allocator::deallocate(size_t size, void * p) { void * small_object_allocator::allocate(size_t size) { - if (size == 0) return 0; + if (size == 0) return nullptr; #if defined(Z3DEBUG) && !defined(_WINDOWS) // Valgrind friendly @@ -113,7 +113,7 @@ void * small_object_allocator::allocate(size_t size) { slot_id++; SASSERT(slot_id < NUM_SLOTS); SASSERT(slot_id > 0); - if (m_free_list[slot_id] != 0) { + if (m_free_list[slot_id] != nullptr) { void * r = m_free_list[slot_id]; m_free_list[slot_id] = *(reinterpret_cast(r)); return r; @@ -121,7 +121,7 @@ void * small_object_allocator::allocate(size_t size) { chunk * c = m_chunks[slot_id]; size = slot_id << PTR_ALIGNMENT; SASSERT(size >= osize); - if (c != 0) { + if (c != nullptr) { char * new_curr = c->m_curr + size; if (new_curr < c->m_data + CHUNK_SIZE) { void * r = c->m_curr; @@ -142,7 +142,7 @@ size_t small_object_allocator::get_wasted_size() const { for (unsigned slot_id = 0; slot_id < NUM_SLOTS; slot_id++) { size_t slot_obj_size = slot_id << PTR_ALIGNMENT; void ** ptr = reinterpret_cast(const_cast(this)->m_free_list[slot_id]); - while (ptr != 0) { + while (ptr != nullptr) { r += slot_obj_size; ptr = reinterpret_cast(*ptr); } @@ -154,7 +154,7 @@ size_t small_object_allocator::get_num_free_objs() const { size_t r = 0; for (unsigned slot_id = 0; slot_id < NUM_SLOTS; slot_id++) { void ** ptr = reinterpret_cast(const_cast(this)->m_free_list[slot_id]); - while (ptr != 0) { + while (ptr != nullptr) { r ++; ptr = reinterpret_cast(*ptr); } @@ -177,17 +177,17 @@ void small_object_allocator::consolidate() { ptr_vector chunks; ptr_vector free_objs; for (unsigned slot_id = 1; slot_id < NUM_SLOTS; slot_id++) { - if (m_free_list[slot_id] == 0) + if (m_free_list[slot_id] == nullptr) continue; chunks.reset(); free_objs.reset(); chunk * c = m_chunks[slot_id]; - while (c != 0) { + while (c != nullptr) { chunks.push_back(c); c = c->m_next; } char * ptr = static_cast(m_free_list[slot_id]); - while (ptr != 0) { + while (ptr != nullptr) { free_objs.push_back(ptr); ptr = *(reinterpret_cast(ptr)); } @@ -198,8 +198,8 @@ void small_object_allocator::consolidate() { SASSERT(!chunks.empty()); std::sort(chunks.begin(), chunks.end(), ptr_lt()); std::sort(free_objs.begin(), free_objs.end(), ptr_lt()); - chunk * last_chunk = 0; - void * last_free_obj = 0; + chunk * last_chunk = nullptr; + void * last_free_obj = nullptr; unsigned chunk_idx = 0; unsigned obj_idx = 0; unsigned num_chunks = chunks.size(); diff --git a/src/util/smt2_util.cpp b/src/util/smt2_util.cpp index 731c91848..8358c67ac 100644 --- a/src/util/smt2_util.cpp +++ b/src/util/smt2_util.cpp @@ -29,7 +29,7 @@ bool is_smt2_simple_symbol_char(char s) { } bool is_smt2_quoted_symbol(char const * s) { - if (s == 0) + if (s == nullptr) return false; if ('0' <= s[0] && s[0] <= '9') return true; diff --git a/src/util/stack.cpp b/src/util/stack.cpp index 81383e2fe..156436496 100644 --- a/src/util/stack.cpp +++ b/src/util/stack.cpp @@ -62,10 +62,10 @@ inline void stack::store_mark(void * ptr, bool external) { } stack::stack() { - m_curr_page = 0; - m_curr_ptr = 0; - m_curr_end_ptr = 0; - m_free_pages = 0; + m_curr_page = nullptr; + m_curr_ptr = nullptr; + m_curr_end_ptr = nullptr; + m_free_pages = nullptr; allocate_page(0); SASSERT(empty()); } diff --git a/src/util/symbol.cpp b/src/util/symbol.cpp index 8f46272f0..220711003 100644 --- a/src/util/symbol.cpp +++ b/src/util/symbol.cpp @@ -22,7 +22,7 @@ Revision History: #include "util/string_buffer.h" #include "util/z3_omp.h" -symbol symbol::m_dummy(TAG(void*, static_cast(0), 2)); +symbol symbol::m_dummy(TAG(void*, nullptr, 2)); const symbol symbol::null; /** @@ -60,7 +60,7 @@ public: } }; -internal_symbol_table* g_symbol_table = 0; +internal_symbol_table* g_symbol_table = nullptr; void initialize_symbols() { if (!g_symbol_table) { @@ -70,12 +70,12 @@ void initialize_symbols() { void finalize_symbols() { dealloc(g_symbol_table); - g_symbol_table = 0; + g_symbol_table = nullptr; } symbol::symbol(char const * d) { - if (d == 0) - m_data = 0; + if (d == nullptr) + m_data = nullptr; else m_data = g_symbol_table->get_str(d); } @@ -103,7 +103,7 @@ std::string symbol::str() const { bool symbol::contains(char ch) const { SASSERT(!is_marked()); if (GET_TAG(m_data) == 0) { - return strchr(m_data, ch) != 0; + return strchr(m_data, ch) != nullptr; } else { return false; diff --git a/src/util/symbol.h b/src/util/symbol.h index 874b258e9..6a6e93747 100644 --- a/src/util/symbol.h +++ b/src/util/symbol.h @@ -51,7 +51,7 @@ class symbol { static symbol m_dummy; public: symbol(): - m_data(0) { + m_data(nullptr) { } explicit symbol(char const * d); explicit symbol(unsigned idx): @@ -69,9 +69,9 @@ public: unsigned int get_num() const { SASSERT(is_numerical()); return UNBOXINT(m_data); } std::string str() const; friend bool operator==(symbol const & s1, char const * s2) { - if (s1.m_data == 0 && s2 == 0) + if (s1.m_data == nullptr && s2 == nullptr) return true; - if (s1.m_data == 0 || s2 == 0) + if (s1.m_data == nullptr || s2 == nullptr) return false; if (!s1.is_numerical()) return strcmp(s1.bare_str(), s2) == 0; @@ -87,7 +87,7 @@ public: return s; } unsigned hash() const { - if (m_data == 0) return 0x9e3779d9; + if (m_data == nullptr) return 0x9e3779d9; else if (is_numerical()) return get_num(); else return static_cast(reinterpret_cast(m_data)[-1]); } diff --git a/src/util/symbol_table.h b/src/util/symbol_table.h index 818cb7584..e3abd4051 100644 --- a/src/util/symbol_table.h +++ b/src/util/symbol_table.h @@ -121,7 +121,7 @@ public: bool find(symbol key, T & result) const { key_data dummy(key); hash_entry * e = m_sym_table.find_core(dummy); - if (e == 0) { + if (e == nullptr) { return false; } result = e->get_data().m_data; @@ -140,7 +140,7 @@ public: if (get_scope_level() > 0) { key_data dummy(key); hash_entry * e = m_sym_table.find_core(dummy); - if (e != 0) { + if (e != nullptr) { m_trail_stack.push_back(e->m_data); e->m_data.m_data = data; return; diff --git a/src/util/timeit.cpp b/src/util/timeit.cpp index 97df87ecd..2a78f08a3 100644 --- a/src/util/timeit.cpp +++ b/src/util/timeit.cpp @@ -49,7 +49,7 @@ timeit::timeit(bool enable, char const * msg, std::ostream & out) { if (enable) m_imp = alloc(imp, msg, out); else - m_imp = 0; + m_imp = nullptr; } timeit::~timeit() { diff --git a/src/util/timeout.cpp b/src/util/timeout.cpp index 496c5c859..283b4c206 100644 --- a/src/util/timeout.cpp +++ b/src/util/timeout.cpp @@ -27,8 +27,8 @@ Revision History: #include "util/event_handler.h" #include "util/scoped_timer.h" -scoped_timer * g_timeout = 0; -void (* g_on_timeout)() = 0; +scoped_timer * g_timeout = nullptr; +void (* g_on_timeout)() = nullptr; class g_timeout_eh : public event_handler { public: @@ -41,7 +41,7 @@ public: g_on_timeout(); if (g_timeout) delete g_timeout; - g_timeout = 0; + g_timeout = nullptr; throw z3_error(ERR_TIMEOUT); } } diff --git a/src/util/trace.cpp b/src/util/trace.cpp index d993ebd11..9571e99e6 100644 --- a/src/util/trace.cpp +++ b/src/util/trace.cpp @@ -24,7 +24,7 @@ std::ofstream tout(".z3-trace"); #endif static bool g_enable_all_trace_tags = false; -static str_hashtable* g_enabled_trace_tags = 0; +static str_hashtable* g_enabled_trace_tags = nullptr; static str_hashtable& get_enabled_trace_tags() { if (!g_enabled_trace_tags) { @@ -35,7 +35,7 @@ static str_hashtable& get_enabled_trace_tags() { void finalize_trace() { dealloc(g_enabled_trace_tags); - g_enabled_trace_tags = 0; + g_enabled_trace_tags = nullptr; } void enable_trace(const char * tag) { diff --git a/src/util/trail.h b/src/util/trail.h index adcd57860..b9f4602c7 100644 --- a/src/util/trail.h +++ b/src/util/trail.h @@ -77,7 +77,7 @@ public: } void undo(Ctx & ctx) override { - m_ptr = 0; + m_ptr = nullptr; } }; diff --git a/src/util/util.cpp b/src/util/util.cpp index b16dbe292..0b58419f8 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -40,7 +40,7 @@ std::ostream& verbose_stream() { } -static void (*g_fatal_error_handler)(int) = 0; +static void (*g_fatal_error_handler)(int) = nullptr; void fatal_error(int error_code) { if (g_fatal_error_handler) { @@ -120,7 +120,7 @@ bool product_iterator_next(unsigned n, unsigned const * sz, unsigned * it) { } char const * escaped::end() const { - if (m_str == 0) return 0; + if (m_str == nullptr) return nullptr; char const * it = m_str; char const * e = m_str; while (*it) { diff --git a/src/util/util.h b/src/util/util.h index 6d38231ba..ad427dfaf 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -222,7 +222,7 @@ template class scoped_ptr { T * m_ptr; public: - scoped_ptr(T * ptr=0): + scoped_ptr(T * ptr=nullptr): m_ptr(ptr) { } @@ -239,7 +239,7 @@ public: } operator bool() const { - return m_ptr != 0; + return m_ptr != nullptr; } const T & operator*() const { @@ -260,7 +260,7 @@ public: T * detach() { T* tmp = m_ptr; - m_ptr = 0; + m_ptr = nullptr; return tmp; } diff --git a/src/util/vector.h b/src/util/vector.h index f5792a5d3..85aeab3d3 100644 --- a/src/util/vector.h +++ b/src/util/vector.h @@ -57,7 +57,7 @@ class vector { } void expand_vector() { - if (m_data == 0) { + if (m_data == nullptr) { SZ capacity = 2; SZ * mem = reinterpret_cast(memory::allocate(sizeof(T) * capacity + sizeof(SZ) * 2)); *mem = capacity; @@ -132,12 +132,12 @@ public: typedef const T * const_iterator; vector(): - m_data(0) { + m_data(nullptr) { } vector(SZ s) { if (s == 0) { - m_data = 0; + m_data = nullptr; return; } SZ * mem = reinterpret_cast(memory::allocate(sizeof(T) * s + sizeof(SZ) * 2)); @@ -155,24 +155,24 @@ public: } vector(SZ s, T const & elem): - m_data(0) { + m_data(nullptr) { resize(s, elem); } vector(vector const & source): - m_data(0) { + m_data(nullptr) { if (source.m_data) { copy_core(source); } SASSERT(size() == source.size()); } - vector(vector&& other) : m_data(0) { + vector(vector&& other) : m_data(nullptr) { std::swap(m_data, other.m_data); } vector(SZ s, T const * data): - m_data(0) { + m_data(nullptr) { for (SZ i = 0; i < s; i++) { push_back(data[i]); } @@ -185,7 +185,7 @@ public: void finalize() { destroy(); - m_data = 0; + m_data = nullptr; } vector & operator=(vector const & source) { @@ -197,7 +197,7 @@ public: copy_core(source); } else { - m_data = 0; + m_data = nullptr; } return *this; } @@ -207,7 +207,7 @@ public: return *this; } destroy(); - m_data = 0; + m_data = nullptr; std::swap(m_data, source.m_data); return *this; } @@ -224,18 +224,18 @@ public: void clear() { reset(); } bool empty() const { - return m_data == 0 || reinterpret_cast(m_data)[SIZE_IDX] == 0; + return m_data == nullptr || reinterpret_cast(m_data)[SIZE_IDX] == 0; } SZ size() const { - if (m_data == 0) { + if (m_data == nullptr) { return 0; } return reinterpret_cast(m_data)[SIZE_IDX]; } SZ capacity() const { - if (m_data == 0) { + if (m_data == nullptr) { return 0; } return reinterpret_cast(m_data)[CAPACITY_IDX]; @@ -349,7 +349,7 @@ public: } void push_back(T const & elem) { - if (m_data == 0 || reinterpret_cast(m_data)[SIZE_IDX] == reinterpret_cast(m_data)[CAPACITY_IDX]) { + if (m_data == nullptr || reinterpret_cast(m_data)[SIZE_IDX] == reinterpret_cast(m_data)[CAPACITY_IDX]) { expand_vector(); } new (m_data + reinterpret_cast(m_data)[SIZE_IDX]) T(elem); @@ -357,7 +357,7 @@ public: } void push_back(T && elem) { - if (m_data == 0 || reinterpret_cast(m_data)[SIZE_IDX] == reinterpret_cast(m_data)[CAPACITY_IDX]) { + if (m_data == nullptr || reinterpret_cast(m_data)[SIZE_IDX] == reinterpret_cast(m_data)[CAPACITY_IDX]) { expand_vector(); } new (m_data + reinterpret_cast(m_data)[SIZE_IDX]) T(std::move(elem)); diff --git a/src/util/warning.cpp b/src/util/warning.cpp index a794b064a..6184db880 100644 --- a/src/util/warning.cpp +++ b/src/util/warning.cpp @@ -62,8 +62,8 @@ void STD_CALL myInvalidParameterHandler( static bool g_warning_msgs = true; static bool g_use_std_stdout = false; -static std::ostream* g_error_stream = 0; -static std::ostream* g_warning_stream = 0; +static std::ostream* g_error_stream = nullptr; +static std::ostream* g_warning_stream = nullptr; static bool g_show_error_msg_prefix = true; void send_warnings_to_stdout(bool flag) { From e1100af52c1ee4201cb7922e69dbffb02417fa72 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 12 Feb 2018 12:04:24 -0800 Subject: [PATCH 173/263] ensure that final model is logged by the time it is produced fix #1463 Signed-off-by: Nikolaj Bjorner --- src/opt/maxres.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opt/maxres.cpp b/src/opt/maxres.cpp index 178b87037..f0345232d 100644 --- a/src/opt/maxres.cpp +++ b/src/opt/maxres.cpp @@ -718,7 +718,7 @@ public: } } - if (upper >= m_upper) { + if (upper > m_upper) { return; } From 792fdb915f7098177e6414e25a59373d3c7b9ca7 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 12 Feb 2018 13:07:09 -0800 Subject: [PATCH 174/263] remove deprecated comments about bv2int/int2bv being treated as uninterpreted, raise in #1481 Signed-off-by: Nikolaj Bjorner --- src/api/z3_api.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 5e5b84450..ea0c1615f 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -2857,9 +2857,8 @@ extern "C" { /** \brief Create an \c n bit bit-vector from the integer argument \c t1. - NB. This function is essentially treated as uninterpreted. - So you cannot expect Z3 to precisely reflect the semantics of this function - when solving constraints with this function. + The resulting bit-vector has \c n bits, where the i'th bit (counting + from 0 to \c n-1) is 1 if \c (t1 div 2^i) mod 2 is 1. The node \c t1 must have integer sort. @@ -2874,9 +2873,6 @@ extern "C" { and in the range \ccode{[0..2^N-1]}, where N are the number of bits in \c t1. If \c is_signed is true, \c t1 is treated as a signed bit-vector. - This function is essentially treated as uninterpreted. - So you cannot expect Z3 to precisely reflect the semantics of this function - when solving constraints with this function. The node \c t1 must have a bit-vector sort. From eab7ae58bec086583f630d8d4e4a5b4b4ac294e1 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 12 Feb 2018 23:30:10 -0800 Subject: [PATCH 175/263] fix #1484 Signed-off-by: Nikolaj Bjorner --- src/cmd_context/cmd_context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 436e1b538..6d49d8883 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -320,7 +320,7 @@ bool cmd_context::macros_find(symbol const& s, unsigned n, expr*const* args, exp if (d.m_domain.size() != n) continue; bool eq = true; for (unsigned i = 0; eq && i < n; ++i) { - eq = d.m_domain[i] == m().get_sort(args[i]); + eq = m().compatible_sorts(d.m_domain[i], m().get_sort(args[i])); } if (eq) { t = d.m_body; From 7bf80c66d03f9961a0fab2317a2a610d4d712508 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 13 Feb 2018 18:51:47 +0700 Subject: [PATCH 176/263] Remove redundant void arg. While this was needed in ANSI C, it isn't in C++ and triggers a warning in clang-tidy when `modernize-redundant-void-arg` is enabled. --- src/ast/fpa/fpa2bv_converter.cpp | 2 +- src/ast/fpa/fpa2bv_converter.h | 2 +- src/ast/macros/quasi_macros.cpp | 2 +- src/smt/smt_context.h | 2 +- src/tactic/arith/nla2bv_tactic.cpp | 2 +- src/tactic/sls/bvsls_opt_engine.h | 2 +- src/tactic/sls/sls_engine.h | 4 ++-- src/tactic/tactical.cpp | 2 +- src/tactic/ufbv/ufbv_rewriter.cpp | 6 +++--- src/tactic/ufbv/ufbv_rewriter.h | 2 +- src/util/mpf.h | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp index 5e7db2ca9..033d62825 100644 --- a/src/ast/fpa/fpa2bv_converter.cpp +++ b/src/ast/fpa/fpa2bv_converter.cpp @@ -4085,7 +4085,7 @@ void fpa2bv_converter::round(sort * s, expr_ref & rm, expr_ref & sgn, expr_ref & TRACE("fpa2bv_round", tout << "ROUND = " << mk_ismt2_pp(result, m) << std::endl; ); } -void fpa2bv_converter::reset(void) { +void fpa2bv_converter::reset() { dec_ref_map_key_values(m, m_const2bv); dec_ref_map_key_values(m, m_rm_const2bv); dec_ref_map_key_values(m, m_uf2bvuf); diff --git a/src/ast/fpa/fpa2bv_converter.h b/src/ast/fpa/fpa2bv_converter.h index 062f7afe9..7637317b0 100644 --- a/src/ast/fpa/fpa2bv_converter.h +++ b/src/ast/fpa/fpa2bv_converter.h @@ -150,7 +150,7 @@ public: void mk_max(func_decl * f, unsigned num, expr * const * args, expr_ref & result); expr_ref mk_min_max_unspecified(func_decl * f, expr * x, expr * y); - void reset(void); + void reset(); void dbg_decouple(const char * prefix, expr_ref & e); expr_ref_vector m_extra_assertions; diff --git a/src/ast/macros/quasi_macros.cpp b/src/ast/macros/quasi_macros.cpp index afef6c43f..a308b5b17 100644 --- a/src/ast/macros/quasi_macros.cpp +++ b/src/ast/macros/quasi_macros.cpp @@ -91,7 +91,7 @@ public: void operator()(var * n) { m_bitset.set(n->get_idx(), true); } void operator()(quantifier * n) {} void operator()(app * n) {} - bool all_used(void) { + bool all_used() { for (unsigned i = 0; i < m_bitset.size() ; i++) if (!m_bitset.get(i)) return false; diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index b637d8082..a4581b020 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -1387,7 +1387,7 @@ namespace smt { void flush(); config_mode get_config_mode(bool use_static_features) const; virtual void setup_context(bool use_static_features); - void setup_components(void); + void setup_components(); void pop_to_base_lvl(); void pop_to_search_lvl(); #ifdef Z3DEBUG diff --git a/src/tactic/arith/nla2bv_tactic.cpp b/src/tactic/arith/nla2bv_tactic.cpp index 9a5c33ce6..256fc9b16 100644 --- a/src/tactic/arith/nla2bv_tactic.cpp +++ b/src/tactic/arith/nla2bv_tactic.cpp @@ -459,7 +459,7 @@ public: SASSERT(g->is_well_sorted()); } - void cleanup(void) override { + void cleanup() override { } }; diff --git a/src/tactic/sls/bvsls_opt_engine.h b/src/tactic/sls/bvsls_opt_engine.h index 9487130d3..3acce8f0a 100644 --- a/src/tactic/sls/bvsls_opt_engine.h +++ b/src/tactic/sls/bvsls_opt_engine.h @@ -65,7 +65,7 @@ protected: unsigned & best_const, mpz & best_value, unsigned & new_bit, move_type & move, mpz const & max_score, expr * objective); - mpz top_score(void) { + mpz top_score() { mpz res(0); obj_hashtable const & top_exprs = m_obj_tracker.get_top_exprs(); for (obj_hashtable::iterator it = top_exprs.begin(); diff --git a/src/tactic/sls/sls_engine.h b/src/tactic/sls/sls_engine.h index 0c4fb4d39..da9a8a2c8 100644 --- a/src/tactic/sls/sls_engine.h +++ b/src/tactic/sls/sls_engine.h @@ -99,7 +99,7 @@ public: // stats const & get_stats(void) { return m_stats; } void collect_statistics(statistics & st) const; - void reset_statistics(void) { m_stats.reset(); } + void reset_statistics() { m_stats.reset(); } bool full_eval(model & mdl); @@ -109,7 +109,7 @@ public: void mk_inv(unsigned bv_sz, const mpz & old_value, mpz & inverted); void mk_flip(sort * s, const mpz & old_value, unsigned bit, mpz & flipped); - lbool search(void); + lbool search(); lbool operator()(); void operator()(goal_ref const & g, model_converter_ref & mc); diff --git a/src/tactic/tactical.cpp b/src/tactic/tactical.cpp index 8aa2f400a..a9ada3a11 100644 --- a/src/tactic/tactical.cpp +++ b/src/tactic/tactical.cpp @@ -907,7 +907,7 @@ public: m_t->operator()(in, result, mc, pc, core); } - void cleanup(void) override { m_t->cleanup(); } + void cleanup() override { m_t->cleanup(); } void collect_statistics(statistics & st) const override { m_t->collect_statistics(st); } void reset_statistics() override { m_t->reset_statistics(); } void updt_params(params_ref const & p) override { m_t->updt_params(p); } diff --git a/src/tactic/ufbv/ufbv_rewriter.cpp b/src/tactic/ufbv/ufbv_rewriter.cpp index 573873c89..875ef2edb 100644 --- a/src/tactic/ufbv/ufbv_rewriter.cpp +++ b/src/tactic/ufbv/ufbv_rewriter.cpp @@ -196,14 +196,14 @@ int ufbv_rewriter::is_smaller(expr * e1, expr * e2) const { class max_var_id_proc { unsigned m_max_var_id; public: - max_var_id_proc(void):m_max_var_id(0) {} + max_var_id_proc():m_max_var_id(0) {} void operator()(var * n) { if(n->get_idx() > m_max_var_id) m_max_var_id = n->get_idx(); } void operator()(quantifier * n) {} void operator()(app * n) {} - unsigned get_max(void) { return m_max_var_id; } + unsigned get_max() { return m_max_var_id; } }; unsigned ufbv_rewriter::max_var_id(expr * e) @@ -253,7 +253,7 @@ void ufbv_rewriter::remove_fwd_idx(func_decl * f, quantifier * demodulator) { } } -bool ufbv_rewriter::check_fwd_idx_consistency(void) { +bool ufbv_rewriter::check_fwd_idx_consistency() { for (fwd_idx_map::iterator it = m_fwd_idx.begin(); it != m_fwd_idx.end() ; it++ ) { quantifier_set * set = it->m_value; SASSERT(set); diff --git a/src/tactic/ufbv/ufbv_rewriter.h b/src/tactic/ufbv/ufbv_rewriter.h index af9888751..c6e01528c 100644 --- a/src/tactic/ufbv/ufbv_rewriter.h +++ b/src/tactic/ufbv/ufbv_rewriter.h @@ -173,7 +173,7 @@ class ufbv_rewriter { void insert_fwd_idx(expr * large, expr * small, quantifier * demodulator); void remove_fwd_idx(func_decl * f, quantifier * demodulator); - bool check_fwd_idx_consistency(void); + bool check_fwd_idx_consistency(); void show_fwd_idx(std::ostream & out); bool is_demodulator(expr * e, expr_ref & large, expr_ref & small) const; bool can_rewrite(expr * n, expr * lhs); diff --git a/src/util/mpf.h b/src/util/mpf.h index e679be558..27116e2de 100644 --- a/src/util/mpf.h +++ b/src/util/mpf.h @@ -190,8 +190,8 @@ public: void mk_pinf(unsigned ebits, unsigned sbits, mpf & o); void mk_ninf(unsigned ebits, unsigned sbits, mpf & o); - unsynch_mpz_manager & mpz_manager(void) { return m_mpz_manager; } - unsynch_mpq_manager & mpq_manager(void) { return m_mpq_manager; } + unsynch_mpz_manager & mpz_manager() { return m_mpz_manager; } + unsynch_mpq_manager & mpq_manager() { return m_mpq_manager; } unsigned hash(mpf const & a) { return hash_u_u(m_mpz_manager.hash(a.significand), From 971a5eddcbb54f8942a25f400fa6d53cb5c6008d Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 13 Feb 2018 19:19:24 +0700 Subject: [PATCH 177/263] Use bool literal `false` instead of `0`. --- src/ast/fpa_decl_plugin.cpp | 2 +- src/util/hashtable.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ast/fpa_decl_plugin.cpp b/src/ast/fpa_decl_plugin.cpp index 419175a7f..c0caaa3ca 100644 --- a/src/ast/fpa_decl_plugin.cpp +++ b/src/ast/fpa_decl_plugin.cpp @@ -160,7 +160,7 @@ bool fpa_decl_plugin::is_rm_numeral(expr * n, mpf_rounding_mode & val) { return true; } - return 0; + return false; } bool fpa_decl_plugin::is_rm_numeral(expr * n) { diff --git a/src/util/hashtable.h b/src/util/hashtable.h index 0421fd300..742438814 100644 --- a/src/util/hashtable.h +++ b/src/util/hashtable.h @@ -449,7 +449,7 @@ public: INSERT_LOOP_CORE_BODY(); } UNREACHABLE(); - return 0; + return false; } bool insert_if_not_there_core(const data & e, entry * & et) { From 0ef33a98c40f76d564077e82353b43a73478c00d Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Tue, 13 Feb 2018 14:08:55 +0000 Subject: [PATCH 178/263] Revert "Fix encoding error" --- scripts/mk_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 3a719d322..03256125c 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -889,7 +889,7 @@ def is_CXX_gpp(): return is_compiler(CXX, 'g++') def is_clang_in_gpp_form(cc): - version_string = check_output([cc, '--version']) + version_string = check_output([cc, '--version']).encode('utf-8').decode('utf-8') return version_string.find('clang') != -1 def is_CXX_clangpp(): From 0bbdee810d96357bd6e87f5b2477ec4c17764156 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 14 Feb 2018 21:46:20 -0800 Subject: [PATCH 179/263] fix #1488 Signed-off-by: Nikolaj Bjorner --- src/ast/ast_pp_util.cpp | 1 + src/ast/decl_collector.cpp | 78 +++++++++++++++++++++------- src/ast/decl_collector.h | 10 ++++ src/util/top_sort.h | 101 +++++++++++++++++++++++++++++++++++++ 4 files changed, 172 insertions(+), 18 deletions(-) create mode 100644 src/util/top_sort.h diff --git a/src/ast/ast_pp_util.cpp b/src/ast/ast_pp_util.cpp index 4579f2ffc..37785e072 100644 --- a/src/ast/ast_pp_util.cpp +++ b/src/ast/ast_pp_util.cpp @@ -38,6 +38,7 @@ void ast_pp_util::collect(expr_ref_vector const& es) { void ast_pp_util::display_decls(std::ostream& out) { smt2_pp_environment_dbg env(m); ast_smt_pp pp(m); + coll.order_deps(); unsigned n = coll.get_num_sorts(); for (unsigned i = 0; i < n; ++i) { pp.display_ast_smt2(out, coll.get_sorts()[i], 0, 0, nullptr); diff --git a/src/ast/decl_collector.cpp b/src/ast/decl_collector.cpp index e000f43df..1baac4515 100644 --- a/src/ast/decl_collector.cpp +++ b/src/ast/decl_collector.cpp @@ -18,6 +18,7 @@ Revision History: --*/ #include "ast/decl_collector.h" +#include "ast/ast_pp.h" void decl_collector::visit_sort(sort * n) { family_id fid = n->get_family_id(); @@ -25,19 +26,21 @@ void decl_collector::visit_sort(sort * n) { m_sorts.push_back(n); if (fid == m_dt_fid) { m_sorts.push_back(n); - unsigned num_cnstr = m_dt_util.get_datatype_num_constructors(n); for (unsigned i = 0; i < num_cnstr; i++) { func_decl * cnstr = m_dt_util.get_datatype_constructors(n)->get(i); - m_decls.push_back(cnstr); + m_todo.push_back(cnstr); ptr_vector const & cnstr_acc = *m_dt_util.get_constructor_accessors(cnstr); unsigned num_cas = cnstr_acc.size(); for (unsigned j = 0; j < num_cas; j++) { - func_decl * accsr = cnstr_acc.get(j); - m_decls.push_back(accsr); + m_todo.push_back(cnstr_acc.get(j)); } } } + for (unsigned i = n->get_num_parameters(); i-- > 0; ) { + parameter const& p = n->get_parameter(i); + if (p.is_ast()) m_todo.push_back(p.get_ast()); + } } bool decl_collector::is_bool(sort * s) { @@ -63,43 +66,43 @@ decl_collector::decl_collector(ast_manager & m, bool preds): } void decl_collector::visit(ast* n) { - ptr_vector todo; - todo.push_back(n); - while (!todo.empty()) { - n = todo.back(); - todo.pop_back(); + datatype_util util(m()); + m_todo.push_back(n); + while (!m_todo.empty()) { + n = m_todo.back(); + m_todo.pop_back(); if (!m_visited.is_marked(n)) { m_visited.mark(n, true); switch(n->get_kind()) { case AST_APP: { app * a = to_app(n); - for (unsigned i = 0; i < a->get_num_args(); ++i) { - todo.push_back(a->get_arg(i)); + for (expr* arg : *a) { + m_todo.push_back(arg); } - todo.push_back(a->get_decl()); + m_todo.push_back(a->get_decl()); break; } case AST_QUANTIFIER: { quantifier * q = to_quantifier(n); unsigned num_decls = q->get_num_decls(); for (unsigned i = 0; i < num_decls; ++i) { - todo.push_back(q->get_decl_sort(i)); + m_todo.push_back(q->get_decl_sort(i)); } - todo.push_back(q->get_expr()); + m_todo.push_back(q->get_expr()); for (unsigned i = 0; i < q->get_num_patterns(); ++i) { - todo.push_back(q->get_pattern(i)); + m_todo.push_back(q->get_pattern(i)); } break; } - case AST_SORT: + case AST_SORT: visit_sort(to_sort(n)); break; case AST_FUNC_DECL: { func_decl * d = to_func_decl(n); for (unsigned i = 0; i < d->get_arity(); ++i) { - todo.push_back(d->get_domain(i)); + m_todo.push_back(d->get_domain(i)); } - todo.push_back(d->get_range()); + m_todo.push_back(d->get_range()); visit_func(d); break; } @@ -112,5 +115,44 @@ void decl_collector::visit(ast* n) { } } +void decl_collector::order_deps() { + top_sort st; + for (sort * s : m_sorts) st.insert(s, collect_deps(s)); + st.topological_sort(); + m_sorts.reset(); + for (sort* s : st.top_sorted()) m_sorts.push_back(s); +} + +decl_collector::sort_set* decl_collector::collect_deps(sort* s) { + sort_set* set = alloc(sort_set); + collect_deps(s, *set); + set->remove(s); + return set; +} + +void decl_collector::collect_deps(sort* s, sort_set& set) { + if (set.contains(s)) return; + set.insert(s); + if (s->is_sort_of(m_dt_util.get_family_id(), DATATYPE_SORT)) { + unsigned num_sorts = m_dt_util.get_datatype_num_parameter_sorts(s); + for (unsigned i = 0; i < num_sorts; ++i) { + set.insert(m_dt_util.get_datatype_parameter_sort(s, i)); + } + unsigned num_cnstr = m_dt_util.get_datatype_num_constructors(s); + for (unsigned i = 0; i < num_cnstr; i++) { + func_decl * cnstr = m_dt_util.get_datatype_constructors(s)->get(i); + set.insert(cnstr->get_range()); + for (unsigned j = 0; j < cnstr->get_arity(); ++j) + set.insert(cnstr->get_domain(j)); + } + } + + for (unsigned i = s->get_num_parameters(); i-- > 0; ) { + parameter const& p = s->get_parameter(i); + if (p.is_ast() && is_sort(p.get_ast())) { + set.insert(to_sort(p.get_ast())); + } + } +} diff --git a/src/ast/decl_collector.h b/src/ast/decl_collector.h index 053d6df41..041438864 100644 --- a/src/ast/decl_collector.h +++ b/src/ast/decl_collector.h @@ -20,6 +20,7 @@ Revision History: #ifndef SMT_DECL_COLLECTOR_H_ #define SMT_DECL_COLLECTOR_H_ +#include "util/top_sort.h" #include "ast/ast.h" #include "ast/datatype_decl_plugin.h" @@ -33,11 +34,17 @@ class decl_collector { family_id m_basic_fid; family_id m_dt_fid; datatype_util m_dt_util; + ptr_vector m_todo; void visit_sort(sort* n); bool is_bool(sort* s); void visit_func(func_decl* n); + typedef obj_hashtable sort_set; + sort_set* collect_deps(sort* s); + void collect_deps(top_sort& st); + void collect_deps(sort* s, sort_set& set); + public: // if preds == true, then predicates are stored in a separate collection. @@ -48,9 +55,12 @@ public: void visit(unsigned n, expr* const* es); void visit(expr_ref_vector const& es); + void order_deps(); + unsigned get_num_sorts() const { return m_sorts.size(); } unsigned get_num_decls() const { return m_decls.size(); } unsigned get_num_preds() const { return m_preds.size(); } + sort * const * get_sorts() const { return m_sorts.c_ptr(); } func_decl * const * get_func_decls() const { return m_decls.c_ptr(); } func_decl * const * get_pred_decls() const { return m_preds.c_ptr(); } diff --git a/src/util/top_sort.h b/src/util/top_sort.h new file mode 100644 index 000000000..d017d162b --- /dev/null +++ b/src/util/top_sort.h @@ -0,0 +1,101 @@ +/*++ +Copyright (c) 2018 Microsoft Corporation + +Module Name: + + top_sort.h + +Abstract: + Topological sort over objects + +Author: + + Nikolaj Bjorner (nbjorner) 2018-02-14 + +Revision History: + +--*/ + +#ifndef TOP_SORT_H_ +#define TOP_SORT_H_ + +#include "util/obj_hashtable.h" +#include "util/vector.h" +#include +#include +#include +#include "util/memory_manager.h" + + +template +class top_sort { + typedef obj_hashtable T_set; + obj_map m_partition_id; + obj_map m_dfs_num; + ptr_vector m_top_sorted; + ptr_vector m_stack_S; + ptr_vector m_stack_P; + unsigned m_next_preorder; + obj_map m_deps; + + void traverse(T* f) { + unsigned p_id = 0; + if (m_dfs_num.find(f, p_id)) { + if (!m_partition_id.contains(f)) { + while (!m_stack_P.empty() && m_partition_id[m_stack_P.back()] > p_id) { + m_stack_P.pop_back(); + } + } + } + else if (!m_deps.contains(f)) { + return; + } + else { + m_dfs_num.insert(f, m_next_preorder++); + m_stack_S.push_back(f); + m_stack_P.push_back(f); + for (T* g : *m_deps[f]) { + traverse(g); + } + if (f == m_stack_P.back()) { + + p_id = m_top_sorted.size(); + T* s_f; + do { + s_f = m_stack_S.back(); + m_stack_S.pop_back(); + m_top_sorted.push_back(s_f); + m_partition_id.insert(s_f, p_id); + } + while (s_f != f); + m_stack_P.pop_back(); + } + } + } + +public: + + ~top_sort() { + for (auto & kv : m_deps) dealloc(kv.m_value); + } + + void topological_sort() { + m_next_preorder = 0; + m_partition_id.reset(); + m_top_sorted.reset(); + for (auto & kv : m_deps) { + traverse(kv.m_key); + } + SASSERT(m_stack_S.empty()); + SASSERT(m_stack_P.empty()); + m_dfs_num.reset(); + } + + void insert(T* t, T_set* s) { + m_deps.insert(t, s); + } + + ptr_vector const& top_sorted() { return m_top_sorted; } +}; + +#endif /* TOP_SORT_H_ */ From fadcac8f6d0f119523e70cd893933466a2342298 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 15 Feb 2018 12:39:08 -0800 Subject: [PATCH 180/263] fix #1491 Signed-off-by: Nikolaj Bjorner --- src/opt/opt_context.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/opt/opt_context.cpp b/src/opt/opt_context.cpp index 2f6bad9e8..1950a199d 100644 --- a/src/opt/opt_context.cpp +++ b/src/opt/opt_context.cpp @@ -402,8 +402,8 @@ namespace opt { */ bool context::scoped_lex() { if (m_maxsat_engine == symbol("maxres")) { - for (unsigned i = 0; i < m_objectives.size(); ++i) { - if (m_objectives[i].m_type != O_MAXSMT) return true; + for (auto const& o : m_objectives) { + if (o.m_type != O_MAXSMT) return true; } return false; } @@ -413,14 +413,16 @@ namespace opt { lbool context::execute_lex() { lbool r = l_true; bool sc = scoped_lex(); - IF_VERBOSE(1, verbose_stream() << "(optsmt:lex)\n";); - for (unsigned i = 0; r == l_true && i < m_objectives.size(); ++i) { - bool is_last = i + 1 == m_objectives.size(); - r = execute(m_objectives[i], i + 1 < m_objectives.size(), sc && !is_last); + IF_VERBOSE(1, verbose_stream() << "(opt :lex)\n";); + unsigned sz = m_objectives.size(); + for (unsigned i = 0; r == l_true && i < sz; ++i) { + objective const& o = m_objectives[i]; + bool is_last = i + 1 == sz; + r = execute(o, i + 1 < sz, sc && !is_last && o.m_type != O_MAXSMT); if (r == l_true && !get_lower_as_num(i).is_finite()) { return r; } - if (r == l_true && i + 1 < m_objectives.size()) { + if (r == l_true && i + 1 < sz) { update_lower(); } } From c7063631e1dcea87928f82d93b3076809a35e2e3 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 16 Feb 2018 12:07:23 -0800 Subject: [PATCH 181/263] remove unused code Signed-off-by: Nikolaj Bjorner --- src/opt/CMakeLists.txt | 1 - src/opt/maxres.cpp | 3 - src/opt/mss.cpp | 285 ----------------------------------------- src/opt/mss.h | 57 --------- 4 files changed, 346 deletions(-) delete mode 100644 src/opt/mss.cpp delete mode 100644 src/opt/mss.h diff --git a/src/opt/CMakeLists.txt b/src/opt/CMakeLists.txt index 28a14be2e..dcb13c062 100644 --- a/src/opt/CMakeLists.txt +++ b/src/opt/CMakeLists.txt @@ -2,7 +2,6 @@ z3_add_component(opt SOURCES maxres.cpp maxsmt.cpp - mss.cpp opt_cmds.cpp opt_context.cpp opt_pareto.cpp diff --git a/src/opt/maxres.cpp b/src/opt/maxres.cpp index f0345232d..6d91e70fc 100644 --- a/src/opt/maxres.cpp +++ b/src/opt/maxres.cpp @@ -57,7 +57,6 @@ Notes: #include "opt/maxres.h" #include "ast/ast_pp.h" #include "solver/mus.h" -#include "opt/mss.h" #include "sat/sat_solver/inc_sat_solver.h" #include "opt/opt_context.h" #include "ast/pb_decl_plugin.h" @@ -90,7 +89,6 @@ private: obj_map m_asm2weight; ptr_vector m_new_core; mus m_mus; - mss m_mss; expr_ref_vector m_trail; strategy_t m_st; rational m_max_upper; @@ -121,7 +119,6 @@ public: m_index(index), m_B(m), m_asms(m), m_defs(m), m_mus(c.get_solver()), - m_mss(c.get_solver(), m), m_trail(m), m_st(st), m_correction_set_size(0), diff --git a/src/opt/mss.cpp b/src/opt/mss.cpp deleted file mode 100644 index cc0fa8d7d..000000000 --- a/src/opt/mss.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/*++ -Copyright (c) 2014 Microsoft Corporation - -Module Name: - - mss.cpp - -Abstract: - - MSS/MCS extraction. - -Author: - - Nikolaj Bjorner (nbjorner) 2014-2-8 - -Notes: - - ---*/ - -#include "solver/solver.h" -#include "opt/mss.h" -#include "ast/ast_pp.h" -#include "model/model_smt2_pp.h" - -namespace opt { - - - mss::mss(solver& s, ast_manager& m): m_s(s), m(m) { - } - - mss::~mss() { - } - - bool mss::check_result() { - lbool is_sat = m_s.check_sat(m_mss.size(), m_mss.c_ptr()); - if (is_sat == l_undef) return true; - SASSERT(m_mss.empty() || is_sat == l_true); - if (is_sat == l_false) return false; - expr_set::iterator it = m_mcs.begin(), end = m_mcs.end(); - for (; it != end; ++it) { - m_mss.push_back(*it); - is_sat = m_s.check_sat(m_mss.size(), m_mss.c_ptr()); - m_mss.pop_back(); - if (is_sat == l_undef) return true; - SASSERT(is_sat == l_false); - if (is_sat == l_true) return false; - } - return true; - } - - void mss::initialize(exprs& literals) { - expr* n; - expr_set lits, core_lits; - for (unsigned i = 0; i < literals.size(); ++i) { - n = literals[i]; - lits.insert(n); - m.is_not(n, n); - if (!is_uninterp_const(n)) { - throw default_exception("arguments have to be uninterpreted literals"); - } - } - exprs rest_core; - expr_ref tmp(m); - // - // the last core is a dummy core. It contains literals that - // did not occur in previous cores and did not evaluate to true - // in the current model. - // - for (unsigned i = 0; i < m_cores.size(); ++i) { - exprs const& core = m_cores[i]; - for (unsigned j = 0; j < core.size(); ++j) { - expr* n = core[j]; - if (!core_lits.contains(n)) { - core_lits.insert(n); - if (m_model->eval(n, tmp) && m.is_true(tmp)) { - add_mss(n); - } - else { - m_todo.push_back(n); - } - } - } - } - for (unsigned i = 0; i < literals.size(); ++i) { - expr* n = literals[i]; - if (!core_lits.contains(n)) { - if (m_model->eval(n, tmp) && m.is_true(tmp)) { - m_mss.push_back(n); - } - else { - rest_core.push_back(n); - core_lits.insert(n); - m_todo.push_back(n); - } - } - } - m_cores.push_back(rest_core); - } - - void mss::add_mss(expr* n) { - if (!m_mss_set.contains(n)) { - m_mss_set.insert(n); - m_mss.push_back(n); - } - } - - void mss::update_core(exprs& core) { - unsigned j = 0; - for (unsigned i = 0; i < core.size(); ++i) { - expr* n = core[i]; - if (!m_mss_set.contains(n)) { - if (i != j) { - core[j] = core[i]; - } - ++j; - } - } - core.resize(j); - } - - void mss::update_mss() { - expr_ref tmp(m); - unsigned j = 0; - for (unsigned i = 0; i < m_todo.size(); ++i) { - expr* n = m_todo[i]; - SASSERT(!m_mss_set.contains(n)); - if (m_mcs.contains(n)) { - continue; // remove from cores. - } - if (m_model->eval(n, tmp) && m.is_true(tmp)) { - add_mss(n); - } - else { - if (j != i) { - m_todo[j] = m_todo[i]; - } - ++j; - } - } - m_todo.resize(j); - } - - lbool mss::operator()(model* initial_model, vector const& _cores, exprs& literals, exprs& mcs) { - m_mss.reset(); - m_todo.reset(); - m_model = initial_model; - m_cores.reset(); - SASSERT(m_model); - m_cores.append(_cores); - initialize(literals); - TRACE("opt", - display_vec(tout << "lits: ", literals.size(), literals.c_ptr()); - display(tout);); - lbool is_sat = l_true; - for (unsigned i = 0; is_sat == l_true && i < m_cores.size(); ++i) { - bool has_mcs = false; - bool is_last = i + 1 < m_cores.size(); - SASSERT(check_invariant()); - update_core(m_cores[i]); // remove members of mss - is_sat = process_core(1, m_cores[i], has_mcs, is_last); - } - if (is_sat == l_true) { - SASSERT(check_invariant()); - TRACE("opt", display(tout);); - literals.reset(); - literals.append(m_mss); - mcs.reset(); - expr_set::iterator it = m_mcs.begin(), end = m_mcs.end(); - for (; it != end; ++it) { - mcs.push_back(*it); - } - SASSERT(check_result()); - } - m_mcs.reset(); - m_mss_set.reset(); - IF_VERBOSE(2, display_vec(verbose_stream() << "mcs: ", mcs.size(), mcs.c_ptr());); - return is_sat; - } - - - // - // at least one literal in core is false in current model. - // pick literals in core that are not yet in mss. - // - lbool mss::process_core(unsigned sz, exprs& core, bool& has_mcs, bool is_last) { - SASSERT(sz > 0); - if (core.empty()) { - return l_true; - } - if (m.canceled()) { - return l_undef; - } - if (sz == 1 && core.size() == 1 && is_last && !has_mcs) { - // there has to be at least one false - // literal in the core. - TRACE("opt", tout << "mcs: " << mk_pp(core[0], m) << "\n";); - m_mcs.insert(core[0]); - return l_true; - } - sz = std::min(sz, core.size()); - TRACE("opt", display_vec(tout << "process (total " << core.size() << ") :", sz, core.c_ptr());); - unsigned sz_save = m_mss.size(); - m_mss.append(sz, core.c_ptr()); - lbool is_sat = m_s.check_sat(m_mss.size(), m_mss.c_ptr()); - IF_VERBOSE(3, display_vec(verbose_stream() << "mss: ", m_mss.size(), m_mss.c_ptr());); - m_mss.resize(sz_save); - switch (is_sat) { - case l_true: - m_s.get_model(m_model); - update_mss(); - DEBUG_CODE( - for (unsigned i = 0; i < sz; ++i) { - SASSERT(m_mss_set.contains(core[i])); - }); - update_core(core); - return process_core(2*sz, core, has_mcs, is_last); - case l_false: - if (sz == 1) { - has_mcs = true; - m_mcs.insert(core[0]); - core[0] = core.back(); - core.pop_back(); - } - else { - exprs core2; - core2.append(core.size()-sz, core.c_ptr()+sz); - core.resize(sz); - is_sat = process_core(sz, core2, has_mcs, false); - if (is_sat != l_true) { - return is_sat; - } - update_core(core); - } - return process_core(1, core, has_mcs, is_last); - case l_undef: - return l_undef; - } - - return l_true; - } - - void mss::display_vec(std::ostream& out, unsigned sz, expr* const* args) const { - for (unsigned i = 0; i < sz; ++i) { - out << mk_pp(args[i], m) << " "; - } - out << "\n"; - } - - void mss::display(std::ostream& out) const { - for (unsigned i = 0; i < m_cores.size(); ++i) { - display_vec(out << "core: ", m_cores[i].size(), m_cores[i].c_ptr()); - } - expr_set::iterator it = m_mcs.begin(), end = m_mcs.end(); - out << "mcs:\n"; - for (; it != end; ++it) { - out << mk_pp(*it, m) << "\n"; - } - out << "\n"; - out << "mss:\n"; - for (unsigned i = 0; i < m_mss.size(); ++i) { - out << mk_pp(m_mss[i], m) << "\n"; - } - out << "\n"; - if (m_model) { - model_smt2_pp(out, m, *(m_model.get()), 0); - } - } - - bool mss::check_invariant() const { - if (!m_model) return true; - expr_ref tmp(m); - for (unsigned i = 0; i < m_mss.size(); ++i) { - expr* n = m_mss[i]; - if (!m_model->eval(n, tmp)) return true; - CTRACE("opt", !m.is_true(tmp), tout << mk_pp(n, m) << " |-> " << mk_pp(tmp, m) << "\n";); - SASSERT(!m.is_false(tmp)); - } - return true; - } -} - - - - diff --git a/src/opt/mss.h b/src/opt/mss.h deleted file mode 100644 index af383634a..000000000 --- a/src/opt/mss.h +++ /dev/null @@ -1,57 +0,0 @@ -/*++ -Copyright (c) 2014 Microsoft Corporation - -Module Name: - - mss.h - -Abstract: - - Maximal satisfying subset/minimal correction sets: MSS/MCS - -Author: - - Nikolaj Bjorner (nbjorner) 2014-2-8 - -Notes: - ---*/ -#ifndef MSS_H_ -#define MSS_H_ - -namespace opt { - class mss { - solver& m_s; - ast_manager& m; - typedef ptr_vector exprs; - typedef obj_hashtable expr_set; - exprs m_mss; - expr_set m_mcs; - expr_set m_mss_set; - vector m_cores; - exprs m_todo; - model_ref m_model; - public: - mss(solver& s, ast_manager& m); - ~mss(); - - lbool operator()(model* initial_model, vector const& cores, exprs& literals, exprs& mcs); - - - void get_model(model_ref& mdl) { mdl = m_model; } - - private: - void initialize(exprs& literals); - bool check_result(); - void add_mss(expr* n); - void update_mss(); - void update_core(exprs& core); - lbool process_core(unsigned sz, exprs& core, bool& has_mcs, bool is_last); - void display(std::ostream& out) const; - void display_vec(std::ostream& out, unsigned sz, expr* const* args) const; - bool check_invariant() const; - }; - -}; - -#endif From a2f907c7d168b265b2055cf179ce168914fb8dab Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 18 Feb 2018 13:20:15 -0800 Subject: [PATCH 182/263] fix #1492 Signed-off-by: Nikolaj Bjorner --- src/smt/smt_model_finder.cpp | 109 ++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 48 deletions(-) diff --git a/src/smt/smt_model_finder.cpp b/src/smt/smt_model_finder.cpp index 778337697..5e21c0dcc 100644 --- a/src/smt/smt_model_finder.cpp +++ b/src/smt/smt_model_finder.cpp @@ -914,6 +914,7 @@ namespace smt { func_interp * fi = m_model->get_func_interp(f); if (fi == nullptr) { fi = alloc(func_interp, m, f->get_arity()); + TRACE("model_finder", tout << "register " << f->get_name() << "\n";); m_model->register_decl(f, fi); SASSERT(fi->is_partial()); } @@ -1784,13 +1785,8 @@ namespace smt { return !m_cond_macros.empty(); } - macro_iterator begin_macros() const { - return m_cond_macros.begin(); - } + ptr_vector const& macros() const { return m_cond_macros; } - macro_iterator end_macros() const { - return m_cond_macros.end(); - } void set_the_one(func_decl * m) { m_the_one = m; @@ -2445,6 +2441,7 @@ namespace smt { m_model->register_decl(f, fi); } fi->set_else(f_else); + TRACE("model_finder", tout << f->get_name() << " " << mk_pp(f_else, m_manager) << "\n";); } virtual bool process(ptr_vector const & qs, ptr_vector & new_qs, ptr_vector & residue) = 0; @@ -2499,10 +2496,7 @@ namespace smt { bool process(quantifier * q, ptr_vector const & qs) { quantifier_info * qi = get_qinfo(q); - quantifier_info::macro_iterator it = qi->begin_macros(); - quantifier_info::macro_iterator end = qi->end_macros(); - for (; it != end; ++it) { - cond_macro * m = *it; + for (cond_macro* m : qi->macros()) { if (!m->satisfy_atom()) continue; func_decl * f = m->get_f(); @@ -2548,10 +2542,10 @@ namespace smt { where Q_{f_i} is the set of quantifiers that contain the function f_i. Let f_i = def_i be macros (in this solver conditions are ignored). Let Q_{f_i = def_i} be the set of quantifiers where f_i = def_i is a macro. - Then, the set Q can be satisfied using f_1 = def_1 ... f_n = d_n + Then, the set Q can be satisfied using f_1 = def_1 ... f_n = def_n when - Q_{f_1} union ... union Q_{f_n} = Q_{f_1 = def_1} ... Q_{f_n = d_n} (*) + Q_{f_1} union ... union Q_{f_n} = Q_{f_1 = def_1} ... Q_{f_n = def_n} (*) So, given a set of macros f_1 = def_1, ..., f_n = d_n, it is very easy to check whether they can be used to satisfy all quantifiers that use f_1, ..., f_n in @@ -2630,12 +2624,7 @@ namespace smt { s->insert(q); } - quantifier_set * get_q_f(func_decl * f) { - quantifier_set * s = nullptr; - m_q_f.find(f, s); - SASSERT(s != 0); - return s; - } + quantifier_set * get_q_f(func_decl * f) { return m_q_f[f]; } quantifier_set * get_q_f_def(func_decl * f, expr * def) { quantifier_set * s = nullptr; @@ -2644,12 +2633,7 @@ namespace smt { return s; } - expr_set * get_f_defs(func_decl * f) { - expr_set * s = nullptr; - m_f2defs.find(f, s); - SASSERT(s != 0); - return s; - } + expr_set * get_f_defs(func_decl * f) { return m_f2defs[f]; } void reset_q_fs() { std::for_each(m_qsets.begin(), m_qsets.end(), delete_proc()); @@ -2666,10 +2650,7 @@ namespace smt { bool is_candidate(quantifier * q) const { quantifier_info * qi = get_qinfo(q); - quantifier_info::macro_iterator it = qi->begin_macros(); - quantifier_info::macro_iterator end = qi->end_macros(); - for (; it != end; ++it) { - cond_macro * m = *it; + for (cond_macro * m : qi->macros()) { if (m->satisfy_atom() && !m_forbidden.contains(m->get_f())) return true; } @@ -2712,10 +2693,7 @@ namespace smt { if (!m_forbidden.contains(f)) insert_q_f(q, f); } - quantifier_info::macro_iterator it3 = qi->begin_macros(); - quantifier_info::macro_iterator end3 = qi->end_macros(); - for (; it3 != end3; ++it3) { - cond_macro * m = *it3; + for (cond_macro * m : qi->macros()) { if (m->satisfy_atom() && !m_forbidden.contains(m->get_f())) { insert_q_f_def(q, m->get_f(), m->get_def()); m_candidates.insert(m->get_f()); @@ -2842,11 +2820,7 @@ namespace smt { void get_candidates_from_residue(func_decl_set & candidates) { for (quantifier * q : m_residue) { quantifier_info * qi = get_qinfo(q); - - quantifier_info::macro_iterator it2 = qi->begin_macros(); - quantifier_info::macro_iterator end2 = qi->end_macros(); - for (; it2 != end2; ++it2) { - cond_macro * m = *it2; + for (cond_macro * m : qi->macros()) { func_decl * f = m->get_f(); if (m->satisfy_atom() && !m_forbidden.contains(f) && !m_fs.contains(f)) { candidates.insert(f); @@ -2875,6 +2849,7 @@ namespace smt { m_satisfied.push_scope(); m_residue.push_scope(); + TRACE("model_finder", tout << f->get_name() << " " << mk_pp(def, m_manager) << "\n";); m_fs.insert(f, def); if (update_satisfied_residue(f, def)) { @@ -2889,12 +2864,56 @@ namespace smt { } } + /** + \brief check if satisfied subset introduces a cyclic dependency. + + f_1 = def_1(f_2), ..., f_n = def_n(f_1) + */ + + expr_mark m_visited; + obj_hashtable m_acyclic; + bool is_cyclic() { + m_acyclic.reset(); + while (true) { + unsigned sz = m_acyclic.size(); + if (sz == m_fs.size()) return false; // there are no cyclic dependencies + for (auto const& kv : m_fs) { + func_decl * f = kv.m_key; + if (m_acyclic.contains(f)) continue; + if (is_acyclic(kv.m_value)) + m_acyclic.insert(f); + } + if (sz == m_acyclic.size()) return true; // no progress, so dependency cycle found. + } + } + + struct occurs {}; + struct occurs_check { + hint_solver& m_cls; + occurs_check(hint_solver& hs): m_cls(hs) {} + void operator()(app* n) { if (m_cls.m_fs.contains(n->get_decl()) && !m_cls.m_acyclic.contains(n->get_decl())) throw occurs(); } + void operator()(var* n) {} + void operator()(quantifier* n) {} + }; + bool is_acyclic(expr* def) { + m_visited.reset(); + occurs_check oc(*this); + try { + for_each_expr(oc, m_visited, def); + } + catch (occurs) { + return false; + } + return true; + } + /** \brief Try to reduce m_residue (if not empty) by selecting a function f that is a macro in the residue. */ void greedy(unsigned depth) { if (m_residue.empty()) { + if (is_cyclic()) return; TRACE("model_finder_hint", tout << "found subset that is satisfied by macros\n"; display_search_state(tout);); @@ -3007,11 +3026,11 @@ namespace smt { qi_params const * m_qi_params; bool add_macro(func_decl * f, expr * f_else) { - TRACE("non_auf_macro_solver", tout << "trying to add macro for " << f->get_name() << "\n" << mk_pp(f_else, m_manager) << "\n";); + TRACE("model_finder", tout << "trying to add macro for " << f->get_name() << "\n" << mk_pp(f_else, m_manager) << "\n";); func_decl_set * s = m_dependencies.mk_func_decl_set(); m_dependencies.collect_ng_func_decls(f_else, s); if (!m_dependencies.insert(f, s)) { - TRACE("non_auf_macro_solver", tout << "failed to add macro\n";); + TRACE("model_finder", tout << "failed to add macro\n";); return false; // cyclic dependency } set_else_interp(f, f_else); @@ -3033,10 +3052,7 @@ namespace smt { cond_macro * get_macro_for(func_decl * f, quantifier * q) { cond_macro * r = nullptr; quantifier_info * qi = get_qinfo(q); - quantifier_info::macro_iterator it = qi->begin_macros(); - quantifier_info::macro_iterator end = qi->end_macros(); - for (; it != end; ++it) { - cond_macro * m = *it; + for (cond_macro * m : qi->macros()) { if (m->get_f() == f && !m->is_hint() && is_better_macro(m, r)) r = m; } @@ -3048,13 +3064,10 @@ namespace smt { void collect_candidates(ptr_vector const & qs, obj_map & full_macros, func_decl_set & cond_macros) { for (quantifier * q : qs) { quantifier_info * qi = get_qinfo(q); - quantifier_info::macro_iterator it2 = qi->begin_macros(); - quantifier_info::macro_iterator end2 = qi->end_macros(); - for (; it2 != end2; ++it2) { - cond_macro * m = *it2; + for (cond_macro * m : qi->macros()) { if (!m->is_hint()) { func_decl * f = m->get_f(); - TRACE("non_auf_macro_solver", tout << "considering macro for: " << f->get_name() << "\n"; + TRACE("model_finder", tout << "considering macro for: " << f->get_name() << "\n"; m->display(tout); tout << "\n";); SASSERT(m_qi_params != 0); if (m->is_unconditional() && (!qi->is_auf() || m->get_weight() >= m_qi_params->m_mbqi_force_template)) { From b0997661ccfccc76e66e00740ed53249d4bf8dcc Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Mon, 19 Feb 2018 17:53:53 +0100 Subject: [PATCH 183/263] Insert sort declaration for nullary sorts declared using declare-datatype --- src/parsers/smt2/smt2parser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/parsers/smt2/smt2parser.cpp b/src/parsers/smt2/smt2parser.cpp index 0b0420873..347cbbd68 100644 --- a/src/parsers/smt2/smt2parser.cpp +++ b/src/parsers/smt2/smt2parser.cpp @@ -970,6 +970,9 @@ namespace smt2 { check_rparen_next("invalid datatype declaration, ')' expected"); } else { + if (dt_name) { + m_ctx.insert(pm().mk_psort_dt_decl(0, *dt_name)); + } parse_constructor_decls(ct_decls); } check_rparen_next("invalid datatype declaration, ')' expected"); From 7b91195770479fd4d9e85ffa3d4fc702ad26e3e0 Mon Sep 17 00:00:00 2001 From: Angus Lepper Date: Tue, 20 Feb 2018 19:37:17 +0000 Subject: [PATCH 184/263] Fix Python FiniteDomainSortRef.size() --- src/api/python/z3/z3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 641dba59c..c8ad4e0b4 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -6818,8 +6818,8 @@ class FiniteDomainSortRef(SortRef): def size(self): """Return the size of the finite domain sort""" - r = (ctype.c_ulonglong * 1)() - if Z3_get_finite_domain_sort_size(self.ctx_ref(), self.ast(), r): + r = (ctypes.c_ulonglong * 1)() + if Z3_get_finite_domain_sort_size(self.ctx_ref(), self.ast, r): return r[0] else: raise Z3Exception("Failed to retrieve finite domain sort size") From 54b00f357b8cd1277058fc1c6d88c5d7ebf977b5 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 21 Feb 2018 21:57:54 +0900 Subject: [PATCH 185/263] fix rule inlining, add WithParams to pass parameters directly to python API Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 14 +++++++++ src/muz/transforms/dl_mk_rule_inliner.cpp | 38 +++++++---------------- src/muz/transforms/dl_transforms.cpp | 20 ++++++------ 3 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 641dba59c..d303b477d 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -7447,6 +7447,20 @@ def With(t, *args, **keys): p = args2params(args, keys, t.ctx) return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx) +def WithParams(t, p): + """Return a tactic that applies tactic `t` using the given configuration options. + + >>> x, y = Ints('x y') + >>> p = ParamsRef() + >>> p.set("som", True) + >>> t = With(Tactic('simplify'), p) + >>> t((x + 1)*(y + 2) == 0) + [[2*x + y + x*y == -2]] + """ + ctx = keys.pop('ctx', None) + t = _to_tactic(t, ctx) + return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx) + def Repeat(t, max=4294967295, ctx=None): """Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached. diff --git a/src/muz/transforms/dl_mk_rule_inliner.cpp b/src/muz/transforms/dl_mk_rule_inliner.cpp index a9d2c7090..4088d607c 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.cpp +++ b/src/muz/transforms/dl_mk_rule_inliner.cpp @@ -410,15 +410,11 @@ namespace datalog { const rule_stratifier::comp_vector& comps = candidate_inlined_set->get_stratifier().get_strats(); rule_stratifier::comp_vector::const_iterator cend = comps.end(); - for (rule_stratifier::comp_vector::const_iterator it = comps.begin(); it!=cend; ++it) { - rule_stratifier::item_set * stratum = *it; + for (rule_stratifier::item_set * stratum : comps) { SASSERT(stratum->size()==1); func_decl * pred = *stratum->begin(); - - const rule_vector& pred_rules = candidate_inlined_set->get_predicate_rules(pred); - rule_vector::const_iterator iend = pred_rules.end(); - for (rule_vector::const_iterator iit = pred_rules.begin(); iit!=iend; ++iit) { - transform_rule(orig, *iit, m_inlined_rules); + for (rule * r : candidate_inlined_set->get_predicate_rules(pred)) { + transform_rule(orig, r, m_inlined_rules); } } @@ -426,7 +422,7 @@ namespace datalog { for (unsigned i = 0; i < m_inlined_rules.get_num_rules(); ++i) { rule* r = m_inlined_rules.get_rule(i); - datalog::del_rule(m_mc, *r, true); + datalog::del_rule(m_mc, *r, false); } } @@ -455,9 +451,7 @@ namespace datalog { func_decl * pred = r->get_decl(i); const rule_vector& pred_rules = m_inlined_rules.get_predicate_rules(pred); - rule_vector::const_iterator iend = pred_rules.end(); - for (rule_vector::const_iterator iit = pred_rules.begin(); iit!=iend; ++iit) { - rule * inl_rule = *iit; + for (rule * inl_rule : pred_rules) { rule_ref inl_result(m_rm); if (try_to_inline_rule(*r.get(), *inl_rule, i, inl_result)) { todo.push_back(inl_result); @@ -475,9 +469,8 @@ namespace datalog { bool something_done = false; - rule_set::iterator rend = orig.end(); - for (rule_set::iterator rit = orig.begin(); rit!=rend; ++rit) { - rule_ref r(*rit, m_rm); + for (rule* rl : orig) { + rule_ref r(rl, m_rm); func_decl * pred = r->get_decl(); // if inlining is allowed, then we are eliminating @@ -508,15 +501,10 @@ namespace datalog { bool mk_rule_inliner::is_oriented_rewriter(rule * r, rule_stratifier const& strat) { func_decl * head_pred = r->get_decl(); unsigned head_strat = strat.get_predicate_strat(head_pred); - unsigned head_arity = head_pred->get_arity(); - - unsigned pt_len = r->get_positive_tail_size(); - for (unsigned ti=0; tiget_decl(ti); - unsigned pred_strat = strat.get_predicate_strat(pred); SASSERT(pred_strat<=head_strat); @@ -855,13 +843,9 @@ namespace datalog { return nullptr; } - rule_set::iterator end = source.end(); - for (rule_set::iterator it = source.begin(); it != end; ++ it) { - if (has_quantifier(**it)) { - return nullptr; - } - } - + for (rule const* r : source) + if (has_quantifier(*r)) + return nullptr; if (m_context.get_model_converter()) { hsmc = alloc(horn_subsume_model_converter, m); diff --git a/src/muz/transforms/dl_transforms.cpp b/src/muz/transforms/dl_transforms.cpp index 95b0f6cd6..d456d95f9 100644 --- a/src/muz/transforms/dl_transforms.cpp +++ b/src/muz/transforms/dl_transforms.cpp @@ -59,7 +59,7 @@ namespace datalog { transf.register_plugin(alloc(datalog::mk_quantifier_instantiation, ctx, 37000)); if (ctx.get_params().datalog_subsumption()) { - transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 35005)); + transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 35005)); } transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 35000)); transf.register_plugin(alloc(datalog::mk_coi_filter, ctx, 34990)); @@ -67,20 +67,20 @@ namespace datalog { //and another round of inlining if (ctx.get_params().datalog_subsumption()) { - transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34975)); + transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34975)); } transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 34970)); transf.register_plugin(alloc(datalog::mk_coi_filter, ctx, 34960)); transf.register_plugin(alloc(datalog::mk_interp_tail_simplifier, ctx, 34950)); - + if (ctx.get_params().datalog_subsumption()) { - transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34940)); - transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 34930)); - transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34920)); - transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 34910)); - transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34900)); - transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 34890)); - transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34880)); + transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34940)); + transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 34930)); + transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34920)); + transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 34910)); + transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34900)); + transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 34890)); + transf.register_plugin(alloc(datalog::mk_subsumption_checker, ctx, 34880)); } else { transf.register_plugin(alloc(datalog::mk_rule_inliner, ctx, 34930)); From 7b6f51941c8bee3a8b2da29ea9ffaecd25f428dd Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 21 Feb 2018 22:18:47 +0900 Subject: [PATCH 186/263] fix build Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 2 +- src/muz/transforms/dl_mk_rule_inliner.cpp | 17 ++++------------- src/util/lp/permutation_matrix.h | 10 +++++----- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index d303b477d..fbe112e4c 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -7453,7 +7453,7 @@ def WithParams(t, p): >>> x, y = Ints('x y') >>> p = ParamsRef() >>> p.set("som", True) - >>> t = With(Tactic('simplify'), p) + >>> t = WithParams(Tactic('simplify'), p) >>> t((x + 1)*(y + 2) == 0) [[2*x + y + x*y == -2]] """ diff --git a/src/muz/transforms/dl_mk_rule_inliner.cpp b/src/muz/transforms/dl_mk_rule_inliner.cpp index 4088d607c..b1f222f6e 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.cpp +++ b/src/muz/transforms/dl_mk_rule_inliner.cpp @@ -210,8 +210,7 @@ namespace datalog { } rule_set::iterator rend = orig.end(); - for (rule_set::iterator rit = orig.begin(); rit!=rend; ++rit) { - rule * r = *rit; + for (rule * r : orig) { func_decl * head_pred = r->get_decl(); m_head_pred_ctr.inc(head_pred); @@ -283,9 +282,7 @@ namespace datalog { const rule_stratifier::comp_vector& comps = r.get_stratifier().get_strats(); - rule_stratifier::comp_vector::const_iterator cend = comps.end(); - for (rule_stratifier::comp_vector::const_iterator it = comps.begin(); it!=cend; ++it) { - rule_stratifier::item_set * stratum = *it; + for (rule_stratifier::item_set * stratum : comps) { if (stratum->size()==1) { continue; } @@ -307,9 +304,7 @@ namespace datalog { const rule_stratifier::comp_vector& comps = proposed_inlined_rules.get_stratifier().get_strats(); - rule_stratifier::comp_vector::const_iterator cend = comps.end(); - for (rule_stratifier::comp_vector::const_iterator it = comps.begin(); it!=cend; ++it) { - rule_stratifier::item_set * stratum = *it; + for (rule_stratifier::item_set * stratum : comps) { SASSERT(stratum->size()==1); func_decl * head_pred = *stratum->begin(); @@ -318,10 +313,7 @@ namespace datalog { bool is_multi_occurrence_pred = m_tail_pred_ctr.get(head_pred)>1; const rule_vector& pred_rules = proposed_inlined_rules.get_predicate_rules(head_pred); - rule_vector::const_iterator iend = pred_rules.end(); - for (rule_vector::const_iterator iit = pred_rules.begin(); iit!=iend; ++iit) { - rule * r = *iit; - + for (rule * r : pred_rules) { unsigned pt_len = r->get_positive_tail_size(); for (unsigned ti = 0; tiget_decl(ti); @@ -409,7 +401,6 @@ namespace datalog { const rule_stratifier::comp_vector& comps = candidate_inlined_set->get_stratifier().get_strats(); - rule_stratifier::comp_vector::const_iterator cend = comps.end(); for (rule_stratifier::item_set * stratum : comps) { SASSERT(stratum->size()==1); func_decl * pred = *stratum->begin(); diff --git a/src/util/lp/permutation_matrix.h b/src/util/lp/permutation_matrix.h index f080d45b9..3c89b3646 100644 --- a/src/util/lp/permutation_matrix.h +++ b/src/util/lp/permutation_matrix.h @@ -109,13 +109,13 @@ class permutation_matrix : public tail_matrix { void transpose_from_right(unsigned i, unsigned j); #ifdef Z3DEBUG - T get_elem(unsigned i, unsigned j) const{ + T get_elem(unsigned i, unsigned j) const override { return m_permutation[i] == j? numeric_traits::one() : numeric_traits::zero(); } - unsigned row_count() const{ return size(); } - unsigned column_count() const { return size(); } - virtual void set_number_of_rows(unsigned /*m*/) { } - virtual void set_number_of_columns(unsigned /*n*/) { } + unsigned row_count() const override { return size(); } + unsigned column_count() const override { return size(); } + void set_number_of_rows(unsigned /*m*/) override { } + void set_number_of_columns(unsigned /*n*/) override { } #endif void multiply_by_permutation_from_left(permutation_matrix & p); From 24f56fd74c87c6678ccff9a72e412acf6c0a1fed Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 21 Feb 2018 22:29:22 +0900 Subject: [PATCH 187/263] try another build fix Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 3 +-- src/util/lp/eta_matrix.h | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index fbe112e4c..dbf1252af 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -7457,8 +7457,7 @@ def WithParams(t, p): >>> t((x + 1)*(y + 2) == 0) [[2*x + y + x*y == -2]] """ - ctx = keys.pop('ctx', None) - t = _to_tactic(t, ctx) + t = _to_tactic(t, None) return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx) def Repeat(t, max=4294967295, ctx=None): diff --git a/src/util/lp/eta_matrix.h b/src/util/lp/eta_matrix.h index 7224fa846..89d2e641d 100644 --- a/src/util/lp/eta_matrix.h +++ b/src/util/lp/eta_matrix.h @@ -83,12 +83,12 @@ public: void apply_from_right(vector & w) override; void apply_from_right(indexed_vector & w) override; - T get_elem(unsigned i, unsigned j) const; + T get_elem(unsigned i, unsigned j) const override; #ifdef Z3DEBUG - unsigned row_count() const { return m_length; } - unsigned column_count() const { return m_length; } - void set_number_of_rows(unsigned m) { m_length = m; } - void set_number_of_columns(unsigned n) { m_length = n; } + unsigned row_count() const override { return m_length; } + unsigned column_count() const override { return m_length; } + void set_number_of_rows(unsigned m) override { m_length = m; } + void set_number_of_columns(unsigned n) override { m_length = n; } #endif void divide_by_diagonal_element() { m_column_vector.divide(m_diagonal_element); From 763c250734f3fff0226e7e9b3b4775850143f9e5 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 21 Feb 2018 22:33:44 +0900 Subject: [PATCH 188/263] try another build fix Signed-off-by: Nikolaj Bjorner --- src/util/lp/eta_matrix.h | 2 +- src/util/lp/sparse_matrix.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/lp/eta_matrix.h b/src/util/lp/eta_matrix.h index 89d2e641d..eee4a2674 100644 --- a/src/util/lp/eta_matrix.h +++ b/src/util/lp/eta_matrix.h @@ -83,7 +83,7 @@ public: void apply_from_right(vector & w) override; void apply_from_right(indexed_vector & w) override; - T get_elem(unsigned i, unsigned j) const override; + T get_elem(unsigned i, unsigned j) const; #ifdef Z3DEBUG unsigned row_count() const override { return m_length; } unsigned column_count() const override { return m_length; } diff --git a/src/util/lp/sparse_matrix.h b/src/util/lp/sparse_matrix.h index 400f2bfc0..7db526bdd 100644 --- a/src/util/lp/sparse_matrix.h +++ b/src/util/lp/sparse_matrix.h @@ -302,11 +302,11 @@ public: void solve_U_y_indexed_only(indexed_vector & y, const lp_settings&, vector & sorted_active_rows ); #ifdef Z3DEBUG - T get_elem(unsigned i, unsigned j) const { return get(i, j); } - unsigned get_number_of_rows() const { return dimension(); } - unsigned get_number_of_columns() const { return dimension(); } - virtual void set_number_of_rows(unsigned /*m*/) { } - virtual void set_number_of_columns(unsigned /*n*/) { } + T get_elem(unsigned i, unsigned j) const override { return get(i, j); } + unsigned get_number_of_rows() const override { return dimension(); } + unsigned get_number_of_columns() const override { return dimension(); } + virtual void set_number_of_rows(unsigned /*m*/) override { } + virtual void set_number_of_columns(unsigned /*n*/) override { } #endif template L dot_product_with_row (unsigned row, const vector & y) const; From d70ee71a433f4176b786b48192244cc13958881a Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 21 Feb 2018 22:38:10 +0900 Subject: [PATCH 189/263] try another build fix Signed-off-by: Nikolaj Bjorner --- src/util/lp/sparse_matrix.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/lp/sparse_matrix.h b/src/util/lp/sparse_matrix.h index 7db526bdd..400f2bfc0 100644 --- a/src/util/lp/sparse_matrix.h +++ b/src/util/lp/sparse_matrix.h @@ -302,11 +302,11 @@ public: void solve_U_y_indexed_only(indexed_vector & y, const lp_settings&, vector & sorted_active_rows ); #ifdef Z3DEBUG - T get_elem(unsigned i, unsigned j) const override { return get(i, j); } - unsigned get_number_of_rows() const override { return dimension(); } - unsigned get_number_of_columns() const override { return dimension(); } - virtual void set_number_of_rows(unsigned /*m*/) override { } - virtual void set_number_of_columns(unsigned /*n*/) override { } + T get_elem(unsigned i, unsigned j) const { return get(i, j); } + unsigned get_number_of_rows() const { return dimension(); } + unsigned get_number_of_columns() const { return dimension(); } + virtual void set_number_of_rows(unsigned /*m*/) { } + virtual void set_number_of_columns(unsigned /*n*/) { } #endif template L dot_product_with_row (unsigned row, const vector & y) const; From a4c58ec4c21b5fcb082b3ce5044e756ea7bcd38d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 22 Feb 2018 08:05:28 +0900 Subject: [PATCH 190/263] fix #1496 Signed-off-by: Nikolaj Bjorner --- src/ast/rewriter/seq_rewriter.cpp | 4 +--- src/ast/seq_decl_plugin.cpp | 8 ++------ src/muz/pdr/pdr_context.cpp | 8 ++++---- src/util/lp/dense_matrix.h | 4 ++-- src/util/lp/lu.h | 4 ++-- src/util/lp/sparse_matrix.h | 4 ++-- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/ast/rewriter/seq_rewriter.cpp b/src/ast/rewriter/seq_rewriter.cpp index 387e5d6f2..89840ea43 100644 --- a/src/ast/rewriter/seq_rewriter.cpp +++ b/src/ast/rewriter/seq_rewriter.cpp @@ -1475,9 +1475,7 @@ br_status seq_rewriter::mk_re_star(expr* a, expr_ref& result) { return BR_DONE; } if (m_util.re.is_full_char(a)) { - sort* seq_sort = nullptr; - VERIFY(m_util.is_re(a, seq_sort)); - result = m_util.re.mk_full_seq(seq_sort); + result = m_util.re.mk_full_seq(m().get_sort(a)); return BR_DONE; } if (m_util.re.is_empty(a)) { diff --git a/src/ast/seq_decl_plugin.cpp b/src/ast/seq_decl_plugin.cpp index 91aeeac3b..c9dbc78f8 100644 --- a/src/ast/seq_decl_plugin.cpp +++ b/src/ast/seq_decl_plugin.cpp @@ -671,9 +671,7 @@ func_decl * seq_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, return m.mk_func_decl(m_sigs[k]->m_name, arity, domain, rng, func_decl_info(m_family_id, k)); case _OP_REGEXP_FULL_CHAR: - if (!range) { - range = m_re; - } + if (!range) range = m_re; match(*m_sigs[k], arity, domain, range, rng); return m.mk_func_decl(symbol("re.allchar"), arity, domain, rng, func_decl_info(m_family_id, OP_RE_FULL_CHAR_SET)); @@ -690,9 +688,7 @@ func_decl * seq_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, return m.mk_func_decl(m_sigs[k]->m_name, arity, domain, range, func_decl_info(m_family_id, k)); case _OP_REGEXP_EMPTY: - if (!range) { - range = m_re; - } + if (!range) range = m_re; match(*m_sigs[k], arity, domain, range, rng); return m.mk_func_decl(symbol("re.nostr"), arity, domain, rng, func_decl_info(m_family_id, OP_RE_EMPTY_SET)); diff --git a/src/muz/pdr/pdr_context.cpp b/src/muz/pdr/pdr_context.cpp index 971ec9193..29d01d1f3 100644 --- a/src/muz/pdr/pdr_context.cpp +++ b/src/muz/pdr/pdr_context.cpp @@ -1736,6 +1736,7 @@ namespace pdr { } void context::validate_model() { + IF_VERBOSE(1, verbose_stream() << "(pdr.validate_model)\n";); std::stringstream msg; expr_ref_vector refs(m); expr_ref tmp(m); @@ -1745,11 +1746,10 @@ namespace pdr { get_level_property(m_inductive_lvl, refs, rs); inductive_property ex(m, mc, rs); ex.to_model(model); - decl2rel::iterator it = m_rels.begin(), end = m_rels.end(); var_subst vs(m, false); expr_free_vars fv; - for (; it != end; ++it) { - ptr_vector const& rules = it->m_value->rules(); + for (auto const& kv : m_rels) { + ptr_vector const& rules = kv.m_value->rules(); for (unsigned i = 0; i < rules.size(); ++i) { datalog::rule& r = *rules[i]; model->eval(r.get_head(), tmp); @@ -1916,7 +1916,7 @@ namespace pdr { verbose_stream() << ex.to_string(); }); - // upgrade invariants that are known to be inductive. + // upgrade invariants that are known to be inductive. decl2rel::iterator it = m_rels.begin (), end = m_rels.end (); for (; m_inductive_lvl > 0 && it != end; ++it) { if (it->m_value->head() != m_query_pred) { diff --git a/src/util/lp/dense_matrix.h b/src/util/lp/dense_matrix.h index 6b157ffd4..31b6617ac 100644 --- a/src/util/lp/dense_matrix.h +++ b/src/util/lp/dense_matrix.h @@ -79,8 +79,8 @@ public: void apply_from_left_to_X(vector & w, lp_settings & ); - virtual void set_number_of_rows(unsigned /*m*/) {} - virtual void set_number_of_columns(unsigned /*n*/) { } + void set_number_of_rows(unsigned /*m*/) override {} + void set_number_of_columns(unsigned /*n*/) override {} T get_elem(unsigned i, unsigned j) const { return m_values[i * m_n + j]; } diff --git a/src/util/lp/lu.h b/src/util/lp/lu.h index f9432c323..2f9a5ec38 100644 --- a/src/util/lp/lu.h +++ b/src/util/lp/lu.h @@ -74,8 +74,8 @@ public: #ifdef Z3DEBUG unsigned m_m; unsigned m_n; - virtual void set_number_of_rows(unsigned m) { m_m = m; m_n = m; } - virtual void set_number_of_columns(unsigned n) { m_m = n; m_n = n; } + void set_number_of_rows(unsigned m) override { m_m = m; m_n = m; } + void set_number_of_columns(unsigned n) override { m_m = n; m_n = n; } T m_one_over_val; T get_elem (unsigned i, unsigned j) const; diff --git a/src/util/lp/sparse_matrix.h b/src/util/lp/sparse_matrix.h index 400f2bfc0..7649e0983 100644 --- a/src/util/lp/sparse_matrix.h +++ b/src/util/lp/sparse_matrix.h @@ -305,8 +305,8 @@ public: T get_elem(unsigned i, unsigned j) const { return get(i, j); } unsigned get_number_of_rows() const { return dimension(); } unsigned get_number_of_columns() const { return dimension(); } - virtual void set_number_of_rows(unsigned /*m*/) { } - virtual void set_number_of_columns(unsigned /*n*/) { } + void set_number_of_rows(unsigned /*m*/) override { } + void set_number_of_columns(unsigned /*n*/) override { } #endif template L dot_product_with_row (unsigned row, const vector & y) const; From 919989cfe8e48adf2b4febca5868025d9ea2c8a0 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 22 Feb 2018 08:39:31 +0900 Subject: [PATCH 191/263] fix more warnings with override Signed-off-by: Nikolaj Bjorner --- src/util/lp/eta_matrix.h | 2 +- src/util/lp/sparse_matrix.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/lp/eta_matrix.h b/src/util/lp/eta_matrix.h index eee4a2674..89d2e641d 100644 --- a/src/util/lp/eta_matrix.h +++ b/src/util/lp/eta_matrix.h @@ -83,7 +83,7 @@ public: void apply_from_right(vector & w) override; void apply_from_right(indexed_vector & w) override; - T get_elem(unsigned i, unsigned j) const; + T get_elem(unsigned i, unsigned j) const override; #ifdef Z3DEBUG unsigned row_count() const override { return m_length; } unsigned column_count() const override { return m_length; } diff --git a/src/util/lp/sparse_matrix.h b/src/util/lp/sparse_matrix.h index 7649e0983..44111a9fd 100644 --- a/src/util/lp/sparse_matrix.h +++ b/src/util/lp/sparse_matrix.h @@ -162,8 +162,8 @@ public: unsigned dimension() const {return static_cast(m_row_permutation.size());} #ifdef Z3DEBUG - unsigned row_count() const {return dimension();} - unsigned column_count() const {return dimension();} + unsigned row_count() const override {return dimension();} + unsigned column_count() const override {return dimension();} #endif void init_row_headers(); @@ -302,7 +302,7 @@ public: void solve_U_y_indexed_only(indexed_vector & y, const lp_settings&, vector & sorted_active_rows ); #ifdef Z3DEBUG - T get_elem(unsigned i, unsigned j) const { return get(i, j); } + T get_elem(unsigned i, unsigned j) const override { return get(i, j); } unsigned get_number_of_rows() const { return dimension(); } unsigned get_number_of_columns() const { return dimension(); } void set_number_of_rows(unsigned /*m*/) override { } From 6ed95718ce7b7e60b30eb45c2b4b720cb2bffdf5 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 22 Feb 2018 08:53:17 +0900 Subject: [PATCH 192/263] fix more warnings with override Signed-off-by: Nikolaj Bjorner --- src/util/lp/row_eta_matrix.h | 10 +++++----- src/util/lp/square_dense_submatrix.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/util/lp/row_eta_matrix.h b/src/util/lp/row_eta_matrix.h index f6fb4537d..2bc0ac24e 100644 --- a/src/util/lp/row_eta_matrix.h +++ b/src/util/lp/row_eta_matrix.h @@ -79,11 +79,11 @@ public: void conjugate_by_permutation(permutation_matrix & p); #ifdef Z3DEBUG - T get_elem(unsigned row, unsigned col) const; - unsigned row_count() const { return m_dimension; } - unsigned column_count() const { return m_dimension; } - void set_number_of_rows(unsigned m) { m_dimension = m; } - void set_number_of_columns(unsigned n) { m_dimension = n; } + T get_elem(unsigned row, unsigned col) const override; + unsigned row_count() const override { return m_dimension; } + unsigned column_count() const override { return m_dimension; } + void set_number_of_rows(unsigned m) override { m_dimension = m; } + void set_number_of_columns(unsigned n) override { m_dimension = n; } #endif }; // end of row_eta_matrix } diff --git a/src/util/lp/square_dense_submatrix.h b/src/util/lp/square_dense_submatrix.h index a2cade85a..d43b2eadd 100644 --- a/src/util/lp/square_dense_submatrix.h +++ b/src/util/lp/square_dense_submatrix.h @@ -214,11 +214,11 @@ public: void apply_from_right(vector & w) override; #ifdef Z3DEBUG - T get_elem (unsigned i, unsigned j) const; - unsigned row_count() const { return m_parent->row_count();} - unsigned column_count() const { return row_count();} - void set_number_of_rows(unsigned) {} - void set_number_of_columns(unsigned) {}; + T get_elem (unsigned i, unsigned j) const override; + unsigned row_count() const override { return m_parent->row_count();} + unsigned column_count() const override { return row_count();} + void set_number_of_rows(unsigned) override {} + void set_number_of_columns(unsigned) override {} #endif void conjugate_by_permutation(permutation_matrix & q); }; From 41e0a1267854ef698908a1d025989108ad648c05 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 22 Feb 2018 09:22:30 +0900 Subject: [PATCH 193/263] fix build Signed-off-by: Nikolaj Bjorner --- src/util/lp/eta_matrix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/lp/eta_matrix.h b/src/util/lp/eta_matrix.h index 89d2e641d..eee4a2674 100644 --- a/src/util/lp/eta_matrix.h +++ b/src/util/lp/eta_matrix.h @@ -83,7 +83,7 @@ public: void apply_from_right(vector & w) override; void apply_from_right(indexed_vector & w) override; - T get_elem(unsigned i, unsigned j) const override; + T get_elem(unsigned i, unsigned j) const; #ifdef Z3DEBUG unsigned row_count() const override { return m_length; } unsigned column_count() const override { return m_length; } From dbe5df85c303a5b04e1922890d404f79b048e7fd Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Thu, 22 Feb 2018 08:44:50 -0800 Subject: [PATCH 194/263] fix the override warning Signed-off-by: Lev Nachmanson --- src/util/lp/dense_matrix.h | 6 +++--- src/util/lp/eta_matrix.h | 2 +- src/util/lp/lu.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/lp/dense_matrix.h b/src/util/lp/dense_matrix.h index 31b6617ac..e6663d705 100644 --- a/src/util/lp/dense_matrix.h +++ b/src/util/lp/dense_matrix.h @@ -82,10 +82,10 @@ public: void set_number_of_rows(unsigned /*m*/) override {} void set_number_of_columns(unsigned /*n*/) override {} - T get_elem(unsigned i, unsigned j) const { return m_values[i * m_n + j]; } + T get_elem(unsigned i, unsigned j) const override { return m_values[i * m_n + j]; } - unsigned row_count() const { return m_m; } - unsigned column_count() const { return m_n; } + unsigned row_count() const override { return m_m; } + unsigned column_count() const override { return m_n; } void set_elem(unsigned i, unsigned j, const T& val) { m_values[i * m_n + j] = val; } diff --git a/src/util/lp/eta_matrix.h b/src/util/lp/eta_matrix.h index eee4a2674..89d2e641d 100644 --- a/src/util/lp/eta_matrix.h +++ b/src/util/lp/eta_matrix.h @@ -83,7 +83,7 @@ public: void apply_from_right(vector & w) override; void apply_from_right(indexed_vector & w) override; - T get_elem(unsigned i, unsigned j) const; + T get_elem(unsigned i, unsigned j) const override; #ifdef Z3DEBUG unsigned row_count() const override { return m_length; } unsigned column_count() const override { return m_length; } diff --git a/src/util/lp/lu.h b/src/util/lp/lu.h index 2f9a5ec38..f2cae7961 100644 --- a/src/util/lp/lu.h +++ b/src/util/lp/lu.h @@ -78,10 +78,10 @@ public: void set_number_of_columns(unsigned n) override { m_m = n; m_n = n; } T m_one_over_val; - T get_elem (unsigned i, unsigned j) const; + T get_elem (unsigned i, unsigned j) const override; - unsigned row_count() const { return m_m; } // not defined } - unsigned column_count() const { return m_m; } // not defined } + unsigned row_count() const override { return m_m; } // not defined } + unsigned column_count() const override { return m_m; } // not defined } #endif void apply_from_left(vector & w, lp_settings &) override { w[m_i] /= m_val; From a238a0a37da800238b6ade73a2b5f5994109529a Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Thu, 22 Feb 2018 17:07:21 -0800 Subject: [PATCH 195/263] fix the build Signed-off-by: Lev Nachmanson --- src/util/lp/dense_matrix.h | 3 ++- src/util/lp/eta_matrix.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/lp/dense_matrix.h b/src/util/lp/dense_matrix.h index e6663d705..e2ee54058 100644 --- a/src/util/lp/dense_matrix.h +++ b/src/util/lp/dense_matrix.h @@ -81,8 +81,9 @@ public: void set_number_of_rows(unsigned /*m*/) override {} void set_number_of_columns(unsigned /*n*/) override {} - +#ifdef Z3DEBUG T get_elem(unsigned i, unsigned j) const override { return m_values[i * m_n + j]; } +#endif unsigned row_count() const override { return m_m; } unsigned column_count() const override { return m_n; } diff --git a/src/util/lp/eta_matrix.h b/src/util/lp/eta_matrix.h index 89d2e641d..abed6d06b 100644 --- a/src/util/lp/eta_matrix.h +++ b/src/util/lp/eta_matrix.h @@ -83,8 +83,8 @@ public: void apply_from_right(vector & w) override; void apply_from_right(indexed_vector & w) override; - T get_elem(unsigned i, unsigned j) const override; #ifdef Z3DEBUG + T get_elem(unsigned i, unsigned j) const override; unsigned row_count() const override { return m_length; } unsigned column_count() const override { return m_length; } void set_number_of_rows(unsigned m) override { m_length = m; } From c5336f8003dbc23e94156fe4641e1bd9da442cb2 Mon Sep 17 00:00:00 2001 From: Mikhail Ramalho Date: Fri, 23 Feb 2018 14:48:20 +0000 Subject: [PATCH 196/263] Convert BVULT(X,Y) into !BVULE(Y,X) Signed-off-by: Mikhail Ramalho --- src/ast/fpa/fpa2bv_converter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ast/fpa/fpa2bv_converter.cpp b/src/ast/fpa/fpa2bv_converter.cpp index 033d62825..c84af84d6 100644 --- a/src/ast/fpa/fpa2bv_converter.cpp +++ b/src/ast/fpa/fpa2bv_converter.cpp @@ -25,7 +25,7 @@ Notes: #include "ast/fpa/fpa2bv_converter.h" #include "ast/rewriter/fpa_rewriter.h" -#define BVULT(X,Y,R) { expr_ref bvult_eq(m), bvult_not(m); m_simp.mk_eq(X, Y, bvult_eq); m_simp.mk_not(bvult_eq, bvult_not); expr_ref t(m); t = m_bv_util.mk_ule(X,Y); m_simp.mk_and(t, bvult_not, R); } +#define BVULT(X,Y,R) { expr_ref t(m); t = m_bv_util.mk_ule(Y,X); m_simp.mk_not(t, R); } fpa2bv_converter::fpa2bv_converter(ast_manager & m) : m(m), From 5d0e33c9ad395fa5f0c4e43ed898b6a56f684ad3 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Fri, 23 Feb 2018 20:22:07 +0100 Subject: [PATCH 197/263] Fix assignment of family ids --- src/ast/ast.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index b524cd8d4..c27651fca 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1532,6 +1532,17 @@ void ast_manager::copy_families_plugins(ast_manager const & from) { tout << "fid: " << fid << " fidname: " << get_family_name(fid) << "\n"; }); ast_translation trans(const_cast(from), *this, false); + // Inheriting plugins can create new family ids. Since new family ids are + // assigned in the order that they are created, this can result in differing + // family ids. To avoid this, we first assign all family ids and only then inherit plugins. + for (family_id fid = 0; from.m_family_manager.has_family(fid); fid++) { + symbol fid_name = from.get_family_name(fid); + if (!m_family_manager.has_family(fid)) { + family_id new_fid = mk_family_id(fid_name); + (void)new_fid; + TRACE("copy_families_plugins", tout << "new target fid created: " << new_fid << " fid_name: " << fid_name << "\n";); + } + } for (family_id fid = 0; from.m_family_manager.has_family(fid); fid++) { SASSERT(from.is_builtin_family_id(fid) == is_builtin_family_id(fid)); SASSERT(!from.is_builtin_family_id(fid) || m_family_manager.has_family(fid)); @@ -1539,11 +1550,6 @@ void ast_manager::copy_families_plugins(ast_manager const & from) { TRACE("copy_families_plugins", tout << "copying: " << fid_name << ", src fid: " << fid << ", target has_family: " << m_family_manager.has_family(fid) << "\n"; if (m_family_manager.has_family(fid)) tout << get_family_id(fid_name) << "\n";); - if (!m_family_manager.has_family(fid)) { - family_id new_fid = mk_family_id(fid_name); - (void)new_fid; - TRACE("copy_families_plugins", tout << "new target fid created: " << new_fid << " fid_name: " << fid_name << "\n";); - } TRACE("copy_families_plugins", tout << "target fid: " << get_family_id(fid_name) << "\n";); SASSERT(fid == get_family_id(fid_name)); if (from.has_plugin(fid) && !has_plugin(fid)) { From 9279cbfbacb12332cc1cd58fd45948cccc629c23 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 24 Feb 2018 16:30:08 +0900 Subject: [PATCH 198/263] don't reinit assumptions when the solver is unsat. fixes #1502 Signed-off-by: Nikolaj Bjorner --- src/muz/transforms/dl_mk_rule_inliner.cpp | 22 ++++++++-------------- src/sat/sat_solver.cpp | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/muz/transforms/dl_mk_rule_inliner.cpp b/src/muz/transforms/dl_mk_rule_inliner.cpp index b1f222f6e..584f44303 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.cpp +++ b/src/muz/transforms/dl_mk_rule_inliner.cpp @@ -209,7 +209,6 @@ namespace datalog { rel->collect_non_empty_predicates(m_preds_with_facts); } - rule_set::iterator rend = orig.end(); for (rule * r : orig) { func_decl * head_pred = r->get_decl(); m_head_pred_ctr.inc(head_pred); @@ -257,9 +256,7 @@ namespace datalog { rule_set * mk_rule_inliner::create_allowed_rule_set(rule_set const & orig) { rule_set * res = alloc(rule_set, m_context); - unsigned rcnt = orig.get_num_rules(); - for (unsigned i=0; iget_decl())) { res->add_rule(r); } @@ -283,10 +280,10 @@ namespace datalog { const rule_stratifier::comp_vector& comps = r.get_stratifier().get_strats(); for (rule_stratifier::item_set * stratum : comps) { - if (stratum->size()==1) { + if (stratum->size() == 1) { continue; } - SASSERT(stratum->size()>1); + SASSERT(stratum->size() > 1); func_decl * first_stratum_pred = *stratum->begin(); //we're trying to break cycles by removing one predicate from each of them @@ -397,12 +394,12 @@ namespace datalog { // now we start filling in the set of the inlined rules in a topological order, // so that we inline rules into other rules - SASSERT(m_inlined_rules.get_num_rules()==0); + SASSERT(m_inlined_rules.get_num_rules() == 0); const rule_stratifier::comp_vector& comps = candidate_inlined_set->get_stratifier().get_strats(); for (rule_stratifier::item_set * stratum : comps) { - SASSERT(stratum->size()==1); + SASSERT(stratum->size() == 1); func_decl * pred = *stratum->begin(); for (rule * r : candidate_inlined_set->get_predicate_rules(pred)) { transform_rule(orig, r, m_inlined_rules); @@ -411,8 +408,7 @@ namespace datalog { TRACE("dl", tout << "inlined rules after mutual inlining:\n" << m_inlined_rules; ); - for (unsigned i = 0; i < m_inlined_rules.get_num_rules(); ++i) { - rule* r = m_inlined_rules.get_rule(i); + for (rule * r : m_inlined_rules) { datalog::del_rule(m_mc, *r, false); } } @@ -426,9 +422,7 @@ namespace datalog { rule_ref r(todo.back(), m_rm); todo.pop_back(); unsigned pt_len = r->get_positive_tail_size(); - unsigned i = 0; - for (; i < pt_len && !inlining_allowed(orig, r->get_decl(i)); ++i) {}; SASSERT(!has_quantifier(*r.get())); @@ -497,9 +491,9 @@ namespace datalog { for (unsigned ti=0; ti < pt_len; ++ti) { func_decl * pred = r->get_decl(ti); unsigned pred_strat = strat.get_predicate_strat(pred); - SASSERT(pred_strat<=head_strat); + SASSERT(pred_strat <= head_strat); - if (pred_strat==head_strat) { + if (pred_strat == head_strat) { if (pred->get_arity()>head_arity || (pred->get_arity()==head_arity && pred->get_id()>=head_pred->get_id()) ) { return false; diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index a3d190854..135a7417d 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -1139,7 +1139,7 @@ namespace sat { } void solver::reinit_assumptions() { - if (tracking_assumptions() && scope_lvl() == 0) { + if (tracking_assumptions() && scope_lvl() == 0 && !inconsistent()) { TRACE("sat", tout << m_assumptions << "\n";); push(); for (unsigned i = 0; !inconsistent() && i < m_user_scope_literals.size(); ++i) { From 7b68be75c9a2050ff43eba82f07a7a99ccaf0e84 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 25 Feb 2018 13:11:20 +0900 Subject: [PATCH 199/263] fixes to #1500 and #1457 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_seq.cpp | 144 ++++++++++++++++++++++------------------- src/smt/theory_seq.h | 6 +- 2 files changed, 81 insertions(+), 69 deletions(-) diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index e92a25159..42056ce5c 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -2346,28 +2346,31 @@ bool theory_seq::check_int_string() { bool change = false; for (unsigned i = 0; i < m_int_string.size(); ++i) { expr* e = m_int_string[i].get(), *n; - if (m_util.str.is_itos(e) && add_itos_axiom(e)) { + if (m_util.str.is_itos(e) && add_itos_val_axiom(e)) { change = true; } - else if (m_util.str.is_stoi(e, n) && add_stoi_axiom(e)) { + else if (m_util.str.is_stoi(e, n) && add_stoi_val_axiom(e)) { change = true; } } return change; } -bool theory_seq::add_stoi_axiom(expr* e) { +void theory_seq::add_stoi_axiom(expr* e) { + TRACE("seq", tout << mk_pp(e, m) << "\n";); + SASSERT(m_util.str.is_stoi(e)); + literal l = mk_simplified_literal(m_autil.mk_ge(e, arith_util(m).mk_int(-1))); + add_axiom(l); +} + +bool theory_seq::add_stoi_val_axiom(expr* e) { context& ctx = get_context(); expr* n = nullptr; rational val; TRACE("seq", tout << mk_pp(e, m) << "\n";); VERIFY(m_util.str.is_stoi(e, n)); if (!get_num_value(e, val)) { - literal l = mk_simplified_literal(m_autil.mk_ge(e, arith_util(m).mk_int(-1))); - add_axiom(l); - TRACE("seq", tout << l << " " << ctx.get_assignment(l) << "\n"; - ctx.display(tout);); - return true; + return false; } if (!m_stoi_axioms.contains(val)) { m_stoi_axioms.insert(val); @@ -2445,54 +2448,61 @@ expr_ref theory_seq::digit2int(expr* ch) { return expr_ref(mk_skolem(symbol("seq.digit2int"), ch, nullptr, nullptr, m_autil.mk_int()), m); } -bool theory_seq::add_itos_axiom(expr* e) { +void theory_seq::add_itos_axiom(expr* e) { context& ctx = get_context(); rational val; expr* n = nullptr; TRACE("seq", tout << mk_pp(e, m) << "\n";); VERIFY(m_util.str.is_itos(e, n)); - if (get_num_value(n, val)) { - if (!m_itos_axioms.contains(val)) { - m_itos_axioms.insert(val); - app_ref e1(m_util.str.mk_string(symbol(val.to_string().c_str())), m); - expr_ref n1(arith_util(m).mk_numeral(val, true), m); - // itos(n) = "25" <=> n = 25 - literal eq1 = mk_eq(n1, n , false); - literal eq2 = mk_eq(e, e1, false); - add_axiom(~eq1, eq2); - add_axiom(~eq2, eq1); - ctx.force_phase(eq1); - ctx.force_phase(eq2); + // itos(n) = "" <=> n < 0 + app_ref e1(m_util.str.mk_empty(m.get_sort(e)), m); + expr_ref zero(arith_util(m).mk_int(0), m); + literal eq1 = mk_eq(e1, e, false); + literal ge0 = mk_literal(m_autil.mk_ge(n, zero)); + // n >= 0 => itos(n) != "" + // itos(n) = "" or n >= 0 + add_axiom(~eq1, ~ge0); + add_axiom(eq1, ge0); + + // n >= 0 => stoi(itos(n)) = n + app_ref stoi(m_util.str.mk_stoi(e), m); + add_axiom(~ge0, mk_eq(stoi, n, false)); - m_trail_stack.push(insert_map(m_itos_axioms, val)); - m_trail_stack.push(push_replay(alloc(replay_axiom, m, e))); - return true; - } + // n >= 0 => itos(n) in (0-9)+ + expr_ref num_re(m); + num_re = m_util.re.mk_range(m_util.str.mk_string(symbol("0")), m_util.str.mk_string(symbol("9"))); + num_re = m_util.re.mk_plus(num_re); + app_ref in_re(m_util.re.mk_in_re(e, num_re), m); + add_axiom(~ge0, mk_literal(in_re)); +} + +bool theory_seq::add_itos_val_axiom(expr* e) { + context& ctx = get_context(); + rational val; + expr* n = nullptr; + TRACE("seq", tout << mk_pp(e, m) << "\n";); + VERIFY(m_util.str.is_itos(e, n)); + bool change = false; + + if (get_num_value(n, val) && !val.is_neg() && !m_itos_axioms.contains(val)) { + m_itos_axioms.insert(val); + app_ref e1(m_util.str.mk_string(symbol(val.to_string().c_str())), m); + expr_ref n1(arith_util(m).mk_numeral(val, true), m); + + // itos(n) = "25" <=> n = 25 + literal eq1 = mk_eq(n1, n , false); + literal eq2 = mk_eq(e, e1, false); + add_axiom(~eq1, eq2); + add_axiom(~eq2, eq1); + ctx.force_phase(eq1); + ctx.force_phase(eq2); + + m_trail_stack.push(insert_map(m_itos_axioms, val)); + m_trail_stack.push(push_replay(alloc(replay_axiom, m, e))); + change = true; } - else { - // stoi(itos(n)) = n - app_ref e2(m_util.str.mk_stoi(e), m); - if (ctx.e_internalized(e2) && ctx.get_enode(e2)->get_root() == ctx.get_enode(n)->get_root()) { - return false; - } - add_axiom(mk_eq(e2, n, false)); - -#if 1 - expr_ref num_re(m), opt_re(m); - num_re = m_util.re.mk_range(m_util.str.mk_string(symbol("0")), m_util.str.mk_string(symbol("9"))); - num_re = m_util.re.mk_plus(num_re); - opt_re = m_util.re.mk_opt(m_util.re.mk_to_re(m_util.str.mk_string(symbol("-")))); - num_re = m_util.re.mk_concat(opt_re, num_re); - app_ref in_re(m_util.re.mk_in_re(e, num_re), m); - internalize_term(in_re); - propagate_in_re(in_re, true); -#endif - m_trail_stack.push(push_replay(alloc(replay_axiom, m, e))); - return true; - } - - return false; + return change; } void theory_seq::apply_sort_cnstr(enode* n, sort* s) { @@ -3048,8 +3058,11 @@ expr_ref theory_seq::expand1(expr* e0, dependency*& eqs) { enode* n2 = ctx.get_enode(e1); res = m_util.str.mk_string(symbol(val.to_string().c_str())); #if 1 + if (val.is_neg()) { + result = e; + } // TBD remove this: using roots is unsound for propagation. - if (n1->get_root() == n2->get_root()) { + else if (n1->get_root() == n2->get_root()) { result = res; deps = m_dm.mk_join(deps, m_dm.mk_leaf(assumption(n1, n2))); } @@ -3147,6 +3160,9 @@ void theory_seq::deque_axiom(expr* n) { else if (m_util.str.is_itos(n)) { add_itos_axiom(n); } + else if (m_util.str.is_stoi(n)) { + add_stoi_axiom(n); + } } @@ -3366,9 +3382,9 @@ void theory_seq::add_itos_length_axiom(expr* len) { rational len1, len2; rational ten(10); if (get_num_value(n, len1)) { - bool neg = len1.is_neg(); - if (neg) len1.neg(); - num_char1 = neg?2:1; + if (len1.is_neg()) { + return; + } // 0 <= x < 10 // 10 <= x < 100 // 100 <= x < 1000 @@ -3387,13 +3403,12 @@ void theory_seq::add_itos_length_axiom(expr* len) { literal len_le(mk_literal(m_autil.mk_le(len, m_autil.mk_int(num_char)))); literal len_ge(mk_literal(m_autil.mk_ge(len, m_autil.mk_int(num_char)))); + literal n_ge_0(mk_literal(m_autil.mk_ge(n, m_autil.mk_int(0)))); + add_axiom(~n_ge_0, mk_literal(m_autil.mk_ge(len, m_autil.mk_int(1)))); if (num_char == 1) { - add_axiom(len_ge); - literal n_ge_0(mk_literal(m_autil.mk_ge(n, m_autil.mk_int(0)))); literal n_ge_10(mk_literal(m_autil.mk_ge(n, m_autil.mk_int(10)))); add_axiom(~n_ge_0, n_ge_10, len_le); - add_axiom(~len_le, n_ge_0); add_axiom(~len_le, ~n_ge_10); return; } @@ -3401,22 +3416,13 @@ void theory_seq::add_itos_length_axiom(expr* len) { for (unsigned i = 2; i < num_char; ++i) { hi *= ten; } - // n <= -hi or n >= hi*10 <=> len >= num_chars - // -10*hi < n < 100*hi <=> len <= num_chars - literal n_le_hi = mk_literal(m_autil.mk_le(n, m_autil.mk_numeral(-hi, true))); + // n >= hi*10 <=> len >= num_chars + // n < 100*hi <=> len <= num_chars literal n_ge_10hi = mk_literal(m_autil.mk_ge(n, m_autil.mk_numeral(ten*hi, true))); - literal n_le_m10hi = mk_literal(m_autil.mk_le(n, m_autil.mk_numeral(-ten*hi, true))); literal n_ge_100hi = mk_literal(m_autil.mk_ge(n, m_autil.mk_numeral(ten*ten*hi, true))); - add_axiom(~n_le_hi, len_ge); add_axiom(~n_ge_10hi, len_ge); - add_axiom(n_le_hi, n_ge_10hi, ~len_ge); - - add_axiom(n_le_m10hi, n_ge_100hi, len_le); - add_axiom(~n_le_m10hi, ~len_le); add_axiom(~n_ge_100hi, ~len_le); - - add_axiom(mk_literal(m_autil.mk_ge(len, m_autil.mk_int(1)))); } @@ -3729,6 +3735,7 @@ bool theory_seq::is_extract_suffix(expr* s, expr* i, expr* l) { /* 0 <= l <= len(s) => s = ey & l = len(e) + len(s) < l => s = e */ void theory_seq::add_extract_prefix_axiom(expr* e, expr* s, expr* l) { TRACE("seq", tout << mk_pp(e, m) << " " << mk_pp(s, m) << " " << mk_pp(l, m) << "\n";); @@ -3743,6 +3750,7 @@ void theory_seq::add_extract_prefix_axiom(expr* e, expr* s, expr* l) { add_axiom(~l_ge_0, ~l_le_s, mk_seq_eq(s, ey)); add_axiom(~l_ge_0, ~l_le_s, mk_eq(l, le, false)); add_axiom(~l_ge_0, ~l_le_s, mk_eq(ls_minus_l, m_util.str.mk_length(y), false)); + add_axiom(l_le_s, mk_eq(e, s, false)); } /* @@ -4214,7 +4222,9 @@ void theory_seq::relevant_eh(app* n) { m_util.str.is_extract(n) || m_util.str.is_at(n) || m_util.str.is_empty(n) || - m_util.str.is_string(n)) { + m_util.str.is_string(n) || + m_util.str.is_itos(n) || + m_util.str.is_stoi(n)) { enque_axiom(n); } diff --git a/src/smt/theory_seq.h b/src/smt/theory_seq.h index 203dae633..21aedd7e3 100644 --- a/src/smt/theory_seq.h +++ b/src/smt/theory_seq.h @@ -507,8 +507,10 @@ namespace smt { void add_elim_string_axiom(expr* n); void add_at_axiom(expr* n); void add_in_re_axiom(expr* n); - bool add_stoi_axiom(expr* n); - bool add_itos_axiom(expr* n); + void add_itos_axiom(expr* n); + void add_stoi_axiom(expr* n); + bool add_stoi_val_axiom(expr* n); + bool add_itos_val_axiom(expr* n); literal is_digit(expr* ch); expr_ref digit2int(expr* ch); void add_itos_length_axiom(expr* n); From ce1b135ec388228352d4f9f4159d185378a6ac16 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Feb 2018 14:57:17 +0900 Subject: [PATCH 200/263] address accessor inconsistencies between - and from #1506 Signed-off-by: Nikolaj Bjorner --- src/api/api_ast.cpp | 1 + src/api/python/z3/z3printer.py | 25 ++++++++++++++++++++++--- src/api/z3_api.h | 3 +++ src/ast/datatype_decl_plugin.cpp | 9 +++++++++ src/smt/smt_context.cpp | 4 +--- src/smt/theory_seq.cpp | 16 ++++++++-------- 6 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index f820b184b..3f5a0fcf1 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -1059,6 +1059,7 @@ extern "C" { switch(_d->get_decl_kind()) { case OP_DT_CONSTRUCTOR: return Z3_OP_DT_CONSTRUCTOR; case OP_DT_RECOGNISER: return Z3_OP_DT_RECOGNISER; + case OP_DT_IS: return Z3_OP_DT_IS; case OP_DT_ACCESSOR: return Z3_OP_DT_ACCESSOR; case OP_DT_UPDATE_FIELD: return Z3_OP_DT_UPDATE_FIELD; default: diff --git a/src/api/python/z3/z3printer.py b/src/api/python/z3/z3printer.py index aef71be2f..3a6b7269e 100644 --- a/src/api/python/z3/z3printer.py +++ b/src/api/python/z3/z3printer.py @@ -485,7 +485,9 @@ class PP: raise StopPPException() def pp(self, f, indent): - if f.is_string(): + if isinstance(f, str): + sef.pp_string(f, indent) + elif f.is_string(): self.pp_string(f, indent) elif f.is_indent(): self.pp(f.child, min(indent + f.indent, self.max_indent)) @@ -846,10 +848,17 @@ class Formatter: else: return seq1('MultiPattern', [ self.pp_expr(arg, d+1, xs) for arg in a.children() ]) + def pp_is(self, a, d, xs): + f = a.params()[0] + return self.pp_fdecl(f, a, d, xs) + def pp_map(self, a, d, xs): + f = z3.get_map_func(a) + return self.pp_fdecl(f, a, d, xs) + + def pp_fdecl(self, f, a, d, xs): r = [] sz = 0 - f = z3.get_map_func(a) r.append(to_format(f.name())) for child in a.children(): r.append(self.pp_expr(child, d+1, xs)) @@ -909,6 +918,8 @@ class Formatter: return self.pp_unary_param(a, d, xs) elif k == Z3_OP_EXTRACT: return self.pp_extract(a, d, xs) + elif k == Z3_OP_DT_IS: + return self.pp_is(a, d, xs) elif k == Z3_OP_ARRAY_MAP: return self.pp_map(a, d, xs) elif k == Z3_OP_CONST_ARRAY: @@ -963,6 +974,14 @@ class Formatter: else: return to_format(self.pp_unknown()) + def pp_decl(self, f): + k = f.kind() + if k == Z3_OP_DT_IS or k == Z3_OP_ARRAY_MAP: + g = f.params()[0] + r = [ to_format(g.name()) ] + return seq1(self.pp_name(f), r) + return self.pp_name(f) + def pp_seq_core(self, f, a, d, xs): self.visited = self.visited + 1 if d > self.max_depth or self.visited > self.max_visited: @@ -1054,7 +1073,7 @@ class Formatter: elif z3.is_sort(a): return self.pp_sort(a) elif z3.is_func_decl(a): - return self.pp_name(a) + return self.pp_decl(a) elif isinstance(a, z3.Goal) or isinstance(a, z3.AstVector): return self.pp_seq(a, 0, []) elif isinstance(a, z3.Solver): diff --git a/src/api/z3_api.h b/src/api/z3_api.h index ea0c1615f..500533e91 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -876,6 +876,8 @@ typedef enum - Z3_OP_DT_RECOGNISER: datatype recognizer. + - Z3_OP_DT_IS: datatype recognizer. + - Z3_OP_DT_ACCESSOR: datatype accessor. - Z3_OP_DT_UPDATE_FIELD: datatype field update. @@ -1220,6 +1222,7 @@ typedef enum { // Datatypes Z3_OP_DT_CONSTRUCTOR=0x800, Z3_OP_DT_RECOGNISER, + Z3_OP_DT_IS, Z3_OP_DT_ACCESSOR, Z3_OP_DT_UPDATE_FIELD, diff --git a/src/ast/datatype_decl_plugin.cpp b/src/ast/datatype_decl_plugin.cpp index 44752866c..722cb22b5 100644 --- a/src/ast/datatype_decl_plugin.cpp +++ b/src/ast/datatype_decl_plugin.cpp @@ -797,6 +797,7 @@ namespace datatype { if (m_constructor2recognizer.find(con, d)) return d; sort * datatype = con->get_range(); +#if 0 def const& dd = get_def(datatype); symbol r; for (constructor const* c : dd) { @@ -811,6 +812,14 @@ namespace datatype { m_asts.push_back(d); m_constructor2recognizer.insert(con, d); return d; +#else + parameter ps[1] = { parameter(con)}; + d = m.mk_func_decl(m_family_id, OP_DT_IS, 1, ps, 1, &datatype); + m_constructor2recognizer.insert(con, d); + m_asts.push_back(d); + m_asts.push_back(con); + return d; +#endif } func_decl * util::get_recognizer_constructor(func_decl * recognizer) const { diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index dd38776bc..cccc2e7fb 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -4313,9 +4313,7 @@ namespace smt { if (m_fparams.m_model_compact) m_proto_model->compress(); TRACE("mbqi_bug", tout << "after cleanup:\n"; model_pp(tout, *m_proto_model);); - } - else { - + IF_VERBOSE(11, model_pp(verbose_stream(), *m_proto_model);); } } diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 42056ce5c..12764fd9d 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -2731,13 +2731,12 @@ public: bool is_string = th.m_util.is_string(m_sort); expr_ref result(th.m); if (is_string) { - svector sbuffer; + unsigned_vector sbuffer; bv_util bv(th.m); rational val; unsigned sz; - - for (unsigned i = 0; i < m_source.size(); ++i) { - switch (m_source[i]) { + for (source_t src : m_source) { + switch (src) { case unit_source: { VERIFY(bv.is_numeral(values[j++], val, sz)); sbuffer.push_back(val.get_unsigned()); @@ -2767,12 +2766,13 @@ public: break; } } + // TRACE("seq", tout << src << " " << sbuffer << "\n";); } result = th.m_util.str.mk_string(zstring(sbuffer.size(), sbuffer.c_ptr())); } else { - for (unsigned i = 0; i < m_source.size(); ++i) { - switch (m_source[i]) { + for (source_t src : m_source) { + switch (src) { case unit_source: args.push_back(th.m_util.str.mk_unit(values[j++])); break; @@ -2814,8 +2814,8 @@ model_value_proc * theory_seq::mk_value(enode * n, model_generator & mg) { seq_value_proc* sv = alloc(seq_value_proc, *this, srt); TRACE("seq", tout << mk_pp(e, m) << "\n";); - for (unsigned i = 0; i < concats.size(); ++i) { - expr* c = concats[i], *c1; + for (expr* c : concats) { + expr *c1; TRACE("seq", tout << mk_pp(c, m) << "\n";); if (m_util.str.is_unit(c, c1)) { if (ctx.e_internalized(c1)) { From 0199c7515f82025129072a485b0879a5be026580 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Feb 2018 19:49:13 +0900 Subject: [PATCH 201/263] fix z3.py Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index b5d35bd3f..785649e3d 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -4451,7 +4451,7 @@ class Datatype: if __debug__: _z3_assert(isinstance(name, str), "String expected") _z3_assert(name != "", "Constructor name cannot be empty") - return self.declare_core(name, "is_" + name, *args) + return self.declare_core(name, "is-" + name, *args) def __repr__(self): return "Datatype(%s, %s)" % (self.name, self.constructors) @@ -4575,7 +4575,7 @@ def CreateDatatypes(*ds): cref = cref() setattr(dref, cref_name, cref) rref = dref.recognizer(j) - setattr(dref, rref.name(), rref) + setattr(dref, "is_" + cref_name, rref) for k in range(cref_arity): aref = dref.accessor(j, k) setattr(dref, aref.name(), aref) @@ -4629,16 +4629,16 @@ class DatatypeSortRef(SortRef): >>> List.num_constructors() 2 >>> List.recognizer(0) - is_cons + is(cons) >>> List.recognizer(1) - is_nil + is(nil) >>> simplify(List.is_nil(List.cons(10, List.nil))) False >>> simplify(List.is_cons(List.cons(10, List.nil))) True >>> l = Const('l', List) >>> simplify(List.is_cons(l)) - is_cons(l) + is(cons, l) """ if __debug__: _z3_assert(idx < self.num_constructors(), "Invalid recognizer index") From 5d457c95aa312c06342d6076a36133f1da812d88 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 26 Feb 2018 21:00:41 +0900 Subject: [PATCH 202/263] update registration of built-ins Signed-off-by: Nikolaj Bjorner --- src/cmd_context/cmd_context.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 6d49d8883..3462d0cac 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -2013,9 +2013,10 @@ void cmd_context::dt_eh::operator()(sort * dt, pdecl* pd) { for (func_decl * c : *m_dt_util.get_datatype_constructors(dt)) { TRACE("new_dt_eh", tout << "new constructor: " << c->get_name() << "\n";); m_owner.insert(c); - func_decl * r = m_dt_util.get_constructor_recognizer(c); - m_owner.insert(r); - TRACE("new_dt_eh", tout << "new recognizer: " << r->get_name() << "\n";); + // Don't insert recognizer any longer. It is a built-in function. + // func_decl * r = m_dt_util.get_constructor_recognizer(c); + // m_owner.insert(r); + // TRACE("new_dt_eh", tout << "new recognizer: " << r->get_name() << "\n";); for (func_decl * a : *m_dt_util.get_constructor_accessors(c)) { TRACE("new_dt_eh", tout << "new accessor: " << a->get_name() << "\n";); m_owner.insert(a); From ac9b03528acabba60810d97887b8b20a9cfdb372 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 26 Feb 2018 17:19:45 -0500 Subject: [PATCH 203/263] add re.allchar support in z3str3 --- src/smt/theory_str.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index c5058d00a..8567c6b30 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -1812,8 +1812,11 @@ namespace smt { // trivially true for any string! assert_axiom(ex); } else if (u.re.is_full_char(regex)) { - TRACE("str", tout << "ERROR: unknown regex expression " << mk_pp(regex, m) << "!" << std::endl;); - NOT_IMPLEMENTED_YET(); + // any char = any string of length 1 + expr_ref rhs(ctx.mk_eq_atom(mk_strlen(str), mk_int(1)), m); + expr_ref finalAxiom(m.mk_iff(ex, rhs), m); + SASSERT(finalAxiom); + assert_axiom(finalAxiom); } else { TRACE("str", tout << "ERROR: unknown regex expression " << mk_pp(regex, m) << "!" << std::endl;); NOT_IMPLEMENTED_YET(); @@ -6327,6 +6330,13 @@ namespace smt { make_transition(tmp, ch, tmp); } TRACE("str", tout << "re.all NFA: start = " << start << ", end = " << end << std::endl;); + } else if (u.re.is_full_char(e)) { + // effectively . (match any one character) + for (unsigned int i = 0; i < 256; ++i) { + char ch = (char)i; + make_transition(start, ch, end); + } + TRACE("str", tout << "re.allchar NFA: start = " << start << ", end = " << end << std::endl;); } else { TRACE("str", tout << "invalid regular expression" << std::endl;); m_valid = false; From b79d1a6956a6a018280993fc103aea08330cc9bc Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 28 Feb 2018 09:22:20 +0900 Subject: [PATCH 204/263] fix #1488 for smtlib basic printer Signed-off-by: Nikolaj Bjorner --- src/ast/ast_smt_pp.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ast/ast_smt_pp.cpp b/src/ast/ast_smt_pp.cpp index ace0de2cc..b7404859f 100644 --- a/src/ast/ast_smt_pp.cpp +++ b/src/ast/ast_smt_pp.cpp @@ -952,6 +952,10 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) { strm << "; " << m_attributes.c_str(); } +#if 0 + decls.display_decls(strm); +#else + decls.order_deps(); ast_mark sort_mark; for (unsigned i = 0; i < decls.get_num_sorts(); ++i) { sort* s = decls.get_sorts()[i]; @@ -978,18 +982,19 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) { strm << "\n"; } } +#endif - for (unsigned i = 0; i < m_assumptions.size(); ++i) { + for (expr* a : m_assumptions) { smt_printer p(strm, m, ql, rn, m_logic, false, true, m_simplify_implies, 1); strm << "(assert\n "; - p(m_assumptions[i].get()); + p(a); strm << ")\n"; } - for (unsigned i = 0; i < m_assumptions_star.size(); ++i) { + for (expr* a : m_assumptions_star) { smt_printer p(strm, m, ql, rn, m_logic, false, true, m_simplify_implies, 1); strm << "(assert\n "; - p(m_assumptions_star[i].get()); + p(a); strm << ")\n"; } From 30de514a8849fccec762bd5483068fc724b7029a Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 28 Feb 2018 11:59:17 +0900 Subject: [PATCH 205/263] fix topological traversal crash Signed-off-by: Nikolaj Bjorner --- src/test/heap.cpp | 17 ++++++++++------- src/util/top_sort.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/test/heap.cpp b/src/test/heap.cpp index 39353af76..08891ccaa 100644 --- a/src/test/heap.cpp +++ b/src/test/heap.cpp @@ -19,20 +19,19 @@ Revision History: #include #include "util/util.h" #include "util/heap.h" -#include "util/hashtable.h" #include "util/trace.h" +#include "util/uint_set.h" struct lt_proc { bool operator()(int v1, int v2) const { return v1 < v2; } }; typedef heap int_heap; struct int_hash_proc { unsigned operator()(int v) const { return v * 17; }}; -typedef int_hashtable > int_set; #define N 10000 static random_gen heap_rand(1); static void tst1() { int_heap h(N); - int_set t; + uint_set t; for (int i = 0; i < N * 3; i++) { int val = heap_rand() % N; if (!h.contains(val)) { @@ -41,14 +40,15 @@ static void tst1() { t.insert(val); } else { + if (!t.contains(val)) { + for (int v : t) std::cout << v << "\n"; + } ENSURE(t.contains(val)); } } ENSURE(h.check_invariant()); - int_set::iterator it = t.begin(); - int_set::iterator end = t.end(); - for (; it != end; ++it) { - ENSURE(h.contains(*it)); + for (int v : t) { + ENSURE(h.contains(v)); } while (!h.empty()) { int m1 = h.min_value(); @@ -84,6 +84,8 @@ static void dump_heap(const int_heap2 & h, std::ostream & out) { static void tst2() { int_heap2 h(N); for (int i = 0; i < N * 10; i++) { + + if (i % 1 == 0) std::cout << "i: " << i << std::endl; if (i % 1000 == 0) std::cout << "i: " << i << std::endl; int cmd = heap_rand() % 10; if (cmd <= 3) { @@ -134,6 +136,7 @@ void tst_heap() { enable_trace("heap"); unsigned i = 0; while (i < 3) { + IF_VERBOSE(1, verbose_stream() << "test\n";); heap_rand.set_seed(i++); tst1(); init_values(); diff --git a/src/util/top_sort.h b/src/util/top_sort.h index d017d162b..5f7db9c3e 100644 --- a/src/util/top_sort.h +++ b/src/util/top_sort.h @@ -42,7 +42,7 @@ class top_sort { unsigned p_id = 0; if (m_dfs_num.find(f, p_id)) { if (!m_partition_id.contains(f)) { - while (!m_stack_P.empty() && m_partition_id[m_stack_P.back()] > p_id) { + while (!m_stack_P.empty() && m_partition_id.contains(m_stack_P.back()) && m_partition_id[m_stack_P.back()] > p_id) { m_stack_P.pop_back(); } } From 00c3f4fdcd6153780b66f478918008e934de8318 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 28 Feb 2018 22:35:41 +0900 Subject: [PATCH 206/263] fix bugs found while running sample from #1112 in debug mode Signed-off-by: Nikolaj Bjorner --- src/api/api_solver.cpp | 11 ++++++----- src/cmd_context/cmd_context.cpp | 4 +++- src/cmd_context/pdecl.cpp | 3 ++- src/smt/smt_context.cpp | 1 + src/solver/combined_solver.cpp | 5 +++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index aab783afa..1b2e9dcc3 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -17,6 +17,11 @@ Revision History: --*/ #include +#include "util/scoped_ctrl_c.h" +#include "util/cancel_eh.h" +#include "util/file_path.h" +#include "util/scoped_timer.h" +#include "ast/ast_pp.h" #include "api/z3.h" #include "api/api_log_macros.h" #include "api/api_context.h" @@ -26,14 +31,10 @@ Revision History: #include "api/api_stats.h" #include "api/api_ast_vector.h" #include "solver/tactic2solver.h" -#include "util/scoped_ctrl_c.h" -#include "util/cancel_eh.h" -#include "util/file_path.h" -#include "util/scoped_timer.h" +#include "solver/smt_logics.h" #include "tactic/portfolio/smt_strategic_solver.h" #include "smt/smt_solver.h" #include "smt/smt_implied_equalities.h" -#include "solver/smt_logics.h" #include "cmd_context/cmd_context.h" #include "parsers/smt2/smt2parser.h" #include "sat/dimacs.h" diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 3462d0cac..0be458b4a 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -719,6 +719,7 @@ void cmd_context::init_manager_core(bool new_manager) { m_dt_eh = alloc(dt_eh, *this); m_pmanager->set_new_datatype_eh(m_dt_eh.get()); if (!has_logic()) { + TRACE("cmd_context", tout << "init manager\n";); // add list type only if the logic is not specified. // it prevents clashes with builtin types. insert(pm().mk_plist_decl()); @@ -1408,7 +1409,8 @@ void cmd_context::restore_assertions(unsigned old_sz) { SASSERT(m_assertions.empty()); return; } - SASSERT(old_sz <= m_assertions.size()); + if (old_sz == m_assertions.size()) return; + SASSERT(old_sz < m_assertions.size()); SASSERT(!m_interactive_mode || m_assertions.size() == m_assertion_strings.size()); restore(m(), m_assertions, old_sz); if (produce_unsat_cores()) diff --git a/src/cmd_context/pdecl.cpp b/src/cmd_context/pdecl.cpp index 3a684b867..f9ba79f6d 100644 --- a/src/cmd_context/pdecl.cpp +++ b/src/cmd_context/pdecl.cpp @@ -852,7 +852,7 @@ pdecl_manager::pdecl_manager(ast_manager & m): pdecl_manager::~pdecl_manager() { dec_ref(m_list); reset_sort_info(); - SASSERT(m_sort2psort.empty()); + SASSERT(m_sort2psort.empty()); SASSERT(m_table.empty()); } @@ -946,6 +946,7 @@ void pdecl_manager::del_decl_core(pdecl * p) { } void pdecl_manager::del_decl(pdecl * p) { + TRACE("pdecl_manager", p->display(tout); tout << "\n";); if (p->is_psort()) { psort * _p = static_cast(p); if (_p->is_sort_wrapper()) diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index cccc2e7fb..9c95ac7c3 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -3143,6 +3143,7 @@ namespace smt { push_scope(); for (unsigned i = 0; i < num_assumptions; i++) { expr * curr_assumption = assumptions[i]; + if (m_manager.is_true(curr_assumption)) continue; SASSERT(is_valid_assumption(m_manager, curr_assumption)); proof * pr = m_manager.mk_asserted(curr_assumption); internalize_assertion(curr_assumption, pr, 0); diff --git a/src/solver/combined_solver.cpp b/src/solver/combined_solver.cpp index 397f3bdb1..9d2d8aa46 100644 --- a/src/solver/combined_solver.cpp +++ b/src/solver/combined_solver.cpp @@ -18,10 +18,11 @@ Author: Notes: --*/ -#include "solver/solver.h" #include "util/scoped_timer.h" -#include "solver/combined_solver_params.hpp" #include "util/common_msgs.h" +#include "ast/ast_pp.h" +#include "solver/solver.h" +#include "solver/combined_solver_params.hpp" #define PS_VB_LVL 15 /** From a738f5af12ff14312254c7024dc253358e4b6f83 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 2 Mar 2018 20:14:59 +0900 Subject: [PATCH 207/263] fix #1512 Signed-off-by: Nikolaj Bjorner --- src/model/func_interp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/model/func_interp.cpp b/src/model/func_interp.cpp index accb45a25..2eb687dae 100644 --- a/src/model/func_interp.cpp +++ b/src/model/func_interp.cpp @@ -112,7 +112,8 @@ bool func_interp::is_fi_entry_expr(expr * e, ptr_vector & 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; From 8e09a78c269d9c0a25f784dc0cc898ab24b1182d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 2 Mar 2018 23:02:20 +0900 Subject: [PATCH 208/263] fix #1510 by reintroducing automatic declaration of recognizers Signed-off-by: Nikolaj Bjorner --- src/api/api_datatype.cpp | 10 +++++----- src/ast/datatype_decl_plugin.cpp | 27 +++++++++++---------------- src/ast/datatype_decl_plugin.h | 1 + src/cmd_context/cmd_context.cpp | 5 ++--- src/muz/pdr/pdr_prop_solver.cpp | 2 +- src/muz/spacer/spacer_util.cpp | 2 +- src/parsers/smt2/smt2parser.cpp | 2 +- src/qe/qe_datatype_plugin.cpp | 10 +++++----- src/qe/qe_datatypes.cpp | 4 ++-- src/qe/qe_lite.cpp | 2 +- src/smt/theory_datatype.cpp | 10 +++++----- 11 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/api/api_datatype.cpp b/src/api/api_datatype.cpp index df0b2317f..799e537ea 100644 --- a/src/api/api_datatype.cpp +++ b/src/api/api_datatype.cpp @@ -137,7 +137,7 @@ extern "C" { func_decl* decl = (decls)[i]; mk_c(c)->save_multiple_ast_trail(decl); enum_consts[i] = of_func_decl(decl); - decl = dt_util.get_constructor_recognizer(decl); + decl = dt_util.get_constructor_is(decl); mk_c(c)->save_multiple_ast_trail(decl); enum_testers[i] = of_func_decl(decl); } @@ -196,7 +196,7 @@ extern "C" { *nil_decl = of_func_decl(f); } if (is_nil_decl) { - f = data_util.get_constructor_recognizer(cnstrs[0]); + f = data_util.get_constructor_is(cnstrs[0]); mk_c(c)->save_multiple_ast_trail(f); *is_nil_decl = of_func_decl(f); } @@ -206,7 +206,7 @@ extern "C" { *cons_decl = of_func_decl(f); } if (is_cons_decl) { - f = data_util.get_constructor_recognizer(cnstrs[1]); + f = data_util.get_constructor_is(cnstrs[1]); mk_c(c)->save_multiple_ast_trail(f); *is_cons_decl = of_func_decl(f); } @@ -290,7 +290,7 @@ extern "C" { *constructor_decl = of_func_decl(f); } if (tester) { - func_decl* f2 = data_util.get_constructor_recognizer(f); + func_decl* f2 = data_util.get_constructor_is(f); mk_c(c)->save_multiple_ast_trail(f2); *tester = of_func_decl(f2); } @@ -497,7 +497,7 @@ extern "C" { RETURN_Z3(nullptr); } func_decl* decl = (decls)[idx]; - decl = dt_util.get_constructor_recognizer(decl); + decl = dt_util.get_constructor_is(decl); mk_c(c)->save_ast_trail(decl); RETURN_Z3(of_func_decl(decl)); Z3_CATCH_RETURN(nullptr); diff --git a/src/ast/datatype_decl_plugin.cpp b/src/ast/datatype_decl_plugin.cpp index 722cb22b5..44f824959 100644 --- a/src/ast/datatype_decl_plugin.cpp +++ b/src/ast/datatype_decl_plugin.cpp @@ -791,13 +791,20 @@ namespace datatype { return res; } + + func_decl * util::get_constructor_is(func_decl * con) { + SASSERT(is_constructor(con)); + sort * datatype = con->get_range(); + parameter ps[1] = { parameter(con)}; + return m.mk_func_decl(m_family_id, OP_DT_IS, 1, ps, 1, &datatype); + } + func_decl * util::get_constructor_recognizer(func_decl * con) { SASSERT(is_constructor(con)); func_decl * d = nullptr; if (m_constructor2recognizer.find(con, d)) return d; sort * datatype = con->get_range(); -#if 0 def const& dd = get_def(datatype); symbol r; for (constructor const* c : dd) { @@ -812,14 +819,6 @@ namespace datatype { m_asts.push_back(d); m_constructor2recognizer.insert(con, d); return d; -#else - parameter ps[1] = { parameter(con)}; - d = m.mk_func_decl(m_family_id, OP_DT_IS, 1, ps, 1, &datatype); - m_constructor2recognizer.insert(con, d); - m_asts.push_back(d); - m_asts.push_back(con); - return d; -#endif } func_decl * util::get_recognizer_constructor(func_decl * recognizer) const { @@ -1049,15 +1048,11 @@ namespace datatype { sort* s = todo.back(); todo.pop_back(); out << s->get_name() << " =\n"; - ptr_vector const& cnstrs = *get_datatype_constructors(s); - for (unsigned i = 0; i < cnstrs.size(); ++i) { - func_decl* cns = cnstrs[i]; - func_decl* rec = get_constructor_recognizer(cns); - out << " " << cns->get_name() << " :: " << rec->get_name() << " :: "; + for (func_decl * cns : cnstrs) { + out << " " << cns->get_name() << " :: "; ptr_vector const & accs = *get_constructor_accessors(cns); - for (unsigned j = 0; j < accs.size(); ++j) { - func_decl* acc = accs[j]; + for (func_decl* acc : accs) { sort* s1 = acc->get_range(); out << "(" << acc->get_name() << ": " << s1->get_name() << ") "; if (is_datatype(s1) && are_siblings(s1, s0) && !mark.is_marked(s1)) { diff --git a/src/ast/datatype_decl_plugin.h b/src/ast/datatype_decl_plugin.h index 81c2d09a5..e644ccbda 100644 --- a/src/ast/datatype_decl_plugin.h +++ b/src/ast/datatype_decl_plugin.h @@ -368,6 +368,7 @@ namespace datatype { sort* get_datatype_parameter_sort(sort * ty, unsigned idx); func_decl * get_non_rec_constructor(sort * ty); func_decl * get_constructor_recognizer(func_decl * constructor); + func_decl * get_constructor_is(func_decl * constructor); ptr_vector const * get_constructor_accessors(func_decl * constructor); func_decl * get_accessor_constructor(func_decl * accessor); func_decl * get_recognizer_constructor(func_decl * recognizer) const; diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 0be458b4a..aabe43110 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -2015,9 +2015,8 @@ void cmd_context::dt_eh::operator()(sort * dt, pdecl* pd) { for (func_decl * c : *m_dt_util.get_datatype_constructors(dt)) { TRACE("new_dt_eh", tout << "new constructor: " << c->get_name() << "\n";); m_owner.insert(c); - // Don't insert recognizer any longer. It is a built-in function. - // func_decl * r = m_dt_util.get_constructor_recognizer(c); - // m_owner.insert(r); + func_decl * r = m_dt_util.get_constructor_recognizer(c); + m_owner.insert(r); // TRACE("new_dt_eh", tout << "new recognizer: " << r->get_name() << "\n";); for (func_decl * a : *m_dt_util.get_constructor_accessors(c)) { TRACE("new_dt_eh", tout << "new accessor: " << a->get_name() << "\n";); diff --git a/src/muz/pdr/pdr_prop_solver.cpp b/src/muz/pdr/pdr_prop_solver.cpp index 801d06e50..8ebc9b9cb 100644 --- a/src/muz/pdr/pdr_prop_solver.cpp +++ b/src/muz/pdr/pdr_prop_solver.cpp @@ -133,7 +133,7 @@ namespace pdr { else if ((m.is_eq(e, c, val) && is_app(val) && dt.is_constructor(to_app(val))) || (m.is_eq(e, val, c) && is_app(val) && dt.is_constructor(to_app(val)))){ func_decl* f = to_app(val)->get_decl(); - func_decl* r = dt.get_constructor_recognizer(f); + func_decl* r = dt.get_constructor_is(f); conjs[i] = m.mk_app(r, c); ptr_vector const& acc = *dt.get_constructor_accessors(f); for (unsigned j = 0; j < acc.size(); ++j) { diff --git a/src/muz/spacer/spacer_util.cpp b/src/muz/spacer/spacer_util.cpp index cdec5d7eb..625ac4b7b 100644 --- a/src/muz/spacer/spacer_util.cpp +++ b/src/muz/spacer/spacer_util.cpp @@ -694,7 +694,7 @@ void expand_literals(ast_manager &m, expr_ref_vector& conjs) } else if ((m.is_eq(e, c, val) && is_app(val) && dt.is_constructor(to_app(val))) || (m.is_eq(e, val, c) && is_app(val) && dt.is_constructor(to_app(val)))){ func_decl* f = to_app(val)->get_decl(); - func_decl* r = dt.get_constructor_recognizer(f); + func_decl* r = dt.get_constructor_is(f); conjs[i] = m.mk_app(r, c); ptr_vector const& acc = *dt.get_constructor_accessors(f); for (unsigned j = 0; j < acc.size(); ++j) { diff --git a/src/parsers/smt2/smt2parser.cpp b/src/parsers/smt2/smt2parser.cpp index 347cbbd68..9265312d4 100644 --- a/src/parsers/smt2/smt2parser.cpp +++ b/src/parsers/smt2/smt2parser.cpp @@ -1414,7 +1414,7 @@ namespace smt2 { else { SASSERT(is_app(pattern)); func_decl * f = to_app(pattern)->get_decl(); - func_decl * r = dtutil().get_constructor_recognizer(f); + func_decl * r = dtutil().get_constructor_is(f); ptr_vector const * acc = dtutil().get_constructor_accessors(f); shifter()(t, acc->size(), tsh); for (func_decl* a : *acc) { diff --git a/src/qe/qe_datatype_plugin.cpp b/src/qe/qe_datatype_plugin.cpp index 58878d067..81a402ba4 100644 --- a/src/qe/qe_datatype_plugin.cpp +++ b/src/qe/qe_datatype_plugin.cpp @@ -261,7 +261,7 @@ namespace qe { return false; } func_decl* c = a->get_decl(); - func_decl* r = m_util.get_constructor_recognizer(c); + func_decl_ref r(m_util.get_constructor_is(c), m); ptr_vector const & acc = *m_util.get_constructor_accessors(c); SASSERT(acc.size() == a->get_num_args()); // @@ -380,7 +380,7 @@ namespace qe { } func_decl* c = l->get_decl(); ptr_vector const& acc = *m_util.get_constructor_accessors(c); - func_decl* rec = m_util.get_constructor_recognizer(c); + func_decl* rec = m_util.get_constructor_is(c); expr_ref_vector conj(m); conj.push_back(m.mk_app(rec, r)); for (unsigned i = 0; i < acc.size(); ++i) { @@ -627,7 +627,7 @@ namespace qe { // if (!has_recognizer(x, fml, r, c)) { c = m_datatype_util.get_datatype_constructors(s)->get(vl.get_unsigned()); - r = m_datatype_util.get_constructor_recognizer(c); + r = m_datatype_util.get_constructor_is(c); app* is_c = m.mk_app(r, x); // assert v => r(x) m_ctx.add_constraint(true, is_c); @@ -674,7 +674,7 @@ namespace qe { // if (!has_recognizer(x, fml, r, c)) { c = m_datatype_util.get_datatype_constructors(s)->get(vl.get_unsigned()); - r = m_datatype_util.get_constructor_recognizer(c); + r = m_datatype_util.get_constructor_is(c); app* is_c = m.mk_app(r, x); fml = m.mk_and(is_c, fml); app_ref fresh_x(m.mk_fresh_const("x", s), m); @@ -775,7 +775,7 @@ namespace qe { } c = m_datatype_util.get_datatype_constructors(s)->get(vl.get_unsigned()); - r = m_datatype_util.get_constructor_recognizer(c); + r = m_datatype_util.get_constructor_is(c); app* is_c = m.mk_app(r, x); // assert v => r(x) diff --git a/src/qe/qe_datatypes.cpp b/src/qe/qe_datatypes.cpp index db1e6ec85..770beb59d 100644 --- a/src/qe/qe_datatypes.cpp +++ b/src/qe/qe_datatypes.cpp @@ -151,7 +151,7 @@ namespace qe { return false; } func_decl* c = a->get_decl(); - func_decl* rec = dt.get_constructor_recognizer(c); + func_decl_ref rec(dt.get_constructor_is(c), m); ptr_vector const & acc = *dt.get_constructor_accessors(c); SASSERT(acc.size() == a->get_num_args()); // @@ -232,7 +232,7 @@ namespace qe { func_decl* c = to_app(l)->get_decl(); ptr_vector const& acc = *dt.get_constructor_accessors(c); if (!is_app_of(r, c)) { - lits.push_back(m.mk_app(dt.get_constructor_recognizer(c), r)); + lits.push_back(m.mk_app(dt.get_constructor_is(c), r)); } for (unsigned i = 0; i < acc.size(); ++i) { lits.push_back(m.mk_eq(to_app(l)->get_arg(i), access(c, i, acc, r))); diff --git a/src/qe/qe_lite.cpp b/src/qe/qe_lite.cpp index 8cbf6c70f..e96626479 100644 --- a/src/qe/qe_lite.cpp +++ b/src/qe/qe_lite.cpp @@ -692,7 +692,7 @@ namespace eq { } } else { - func_decl* rec = dt.get_constructor_recognizer(d); + func_decl* rec = dt.get_constructor_is(d); conjs.push_back(m.mk_app(rec, r)); ptr_vector const& acc = *dt.get_constructor_accessors(d); for (unsigned i = 0; i < acc.size(); ++i) { diff --git a/src/smt/theory_datatype.cpp b/src/smt/theory_datatype.cpp index 695d479f4..3d3d56055 100644 --- a/src/smt/theory_datatype.cpp +++ b/src/smt/theory_datatype.cpp @@ -167,7 +167,7 @@ namespace smt { func_decl * upd = n->get_decl(); func_decl * acc = to_func_decl(upd->get_parameter(0).get_ast()); func_decl * con = m_util.get_accessor_constructor(acc); - func_decl * rec = m_util.get_constructor_recognizer(con); + func_decl * rec = m_util.get_constructor_is(con); ptr_vector const & accessors = *m_util.get_constructor_accessors(con); app_ref rec_app(m.mk_app(rec, arg1), m); ctx.internalize(rec_app, false); @@ -710,7 +710,7 @@ namespace smt { literal consequent; if (!r) { ptr_vector const & constructors = *m_util.get_datatype_constructors(dt); - func_decl * rec = m_util.get_constructor_recognizer(constructors[unassigned_idx]); + func_decl * rec = m_util.get_constructor_is(constructors[unassigned_idx]); app * rec_app = get_manager().mk_app(rec, n->get_owner()); ctx.internalize(rec_app, false); consequent = literal(ctx.get_bool_var(rec_app)); @@ -751,12 +751,12 @@ namespace smt { m_stats.m_splits++; if (d->m_recognizers.empty()) { - r = m_util.get_constructor_recognizer(non_rec_c); + r = m_util.get_constructor_is(non_rec_c); } else { enode * recognizer = d->m_recognizers[non_rec_idx]; if (recognizer == nullptr) { - r = m_util.get_constructor_recognizer(non_rec_c); + r = m_util.get_constructor_is(non_rec_c); } else if (!ctx.is_relevant(recognizer)) { ctx.mark_as_relevant(recognizer); @@ -776,7 +776,7 @@ namespace smt { if (curr == nullptr) { ptr_vector const & constructors = *m_util.get_datatype_constructors(s); // found empty slot... - r = m_util.get_constructor_recognizer(constructors[idx]); + r = m_util.get_constructor_is(constructors[idx]); break; } else if (!ctx.is_relevant(curr)) { From 205d77d5919d5f3d25e68631d9a3dd2a252352b4 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 3 Mar 2018 19:26:31 -0800 Subject: [PATCH 209/263] save last model to ensure it is available fixes #1514 Signed-off-by: Nikolaj Bjorner --- src/opt/opt_solver.cpp | 7 ++++++- src/opt/opt_solver.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/opt/opt_solver.cpp b/src/opt/opt_solver.cpp index 715f45291..c5363816a 100644 --- a/src/opt/opt_solver.cpp +++ b/src/opt/opt_solver.cpp @@ -227,9 +227,13 @@ namespace opt { smt::theory_var v = m_objective_vars[i]; bool has_shared = false; inf_eps val = get_optimizer().maximize(v, blocker, has_shared); + get_model(m_model); inf_eps val2; m_valid_objectives[i] = true; TRACE("opt", tout << (has_shared?"has shared":"non-shared") << "\n";); + if (!m_models[i]) { + set_model(i); + } if (m_context.get_context().update_model(has_shared)) { if (has_shared && val != current_objective_value(i)) { decrement_value(i, val); @@ -247,7 +251,7 @@ namespace opt { tout << "objective: " << mk_pp(m_objective_terms[i].get(), m) << "\n"; tout << "maximal value: " << val << "\n"; tout << "new condition: " << blocker << "\n"; - model_smt2_pp(tout << "update model:\n", m, *m_models[i], 0); }); + if (m_models[i]) model_smt2_pp(tout << "update model:\n", m, *m_models[i], 0); }); } void opt_solver::set_model(unsigned i) { @@ -299,6 +303,7 @@ namespace opt { void opt_solver::get_model(model_ref & m) { m_context.get_model(m); + if (!m) m = m_model; else m_model = m; } proof * opt_solver::get_proof() { diff --git a/src/opt/opt_solver.h b/src/opt/opt_solver.h index 41e9dee2d..ac9884770 100644 --- a/src/opt/opt_solver.h +++ b/src/opt/opt_solver.h @@ -73,6 +73,7 @@ namespace opt { filter_model_converter& m_fm; progress_callback * m_callback; symbol m_logic; + model_ref m_model; svector m_objective_vars; vector m_objective_values; sref_vector m_models; From a64fd7145c381eed2be11d68c190b65760fb4261 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 4 Mar 2018 03:36:03 -0800 Subject: [PATCH 210/263] remove buggy legacy code, rely on pull_cheap_ite option in rewriter, #1511 Signed-off-by: Nikolaj Bjorner --- src/ast/rewriter/CMakeLists.txt | 1 - src/ast/rewriter/pull_ite_tree.cpp | 221 ------------------------- src/ast/rewriter/pull_ite_tree.h | 113 ------------- src/smt/asserted_formulas.cpp | 4 +- src/smt/asserted_formulas.h | 4 - src/smt/params/preprocessor_params.cpp | 2 +- src/smt/params/preprocessor_params.h | 4 +- src/smt/smt_setup.cpp | 2 +- 8 files changed, 5 insertions(+), 346 deletions(-) delete mode 100644 src/ast/rewriter/pull_ite_tree.cpp delete mode 100644 src/ast/rewriter/pull_ite_tree.h diff --git a/src/ast/rewriter/CMakeLists.txt b/src/ast/rewriter/CMakeLists.txt index 57924b48a..f030e2704 100644 --- a/src/ast/rewriter/CMakeLists.txt +++ b/src/ast/rewriter/CMakeLists.txt @@ -25,7 +25,6 @@ z3_add_component(rewriter pb_rewriter.cpp pb2bv_rewriter.cpp push_app_ite.cpp - pull_ite_tree.cpp quant_hoist.cpp rewriter.cpp seq_rewriter.cpp diff --git a/src/ast/rewriter/pull_ite_tree.cpp b/src/ast/rewriter/pull_ite_tree.cpp deleted file mode 100644 index 61114387c..000000000 --- a/src/ast/rewriter/pull_ite_tree.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - pull_ite_tree.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-06-22. - -Revision History: - ---*/ -#include "ast/rewriter/pull_ite_tree.h" -#include "ast/recurse_expr_def.h" -#include "ast/for_each_expr.h" -#include "ast/ast_pp.h" - -pull_ite_tree::pull_ite_tree(ast_manager & m): - m_manager(m), - m_rewriter(m), - m_cache(m) { -} - -void pull_ite_tree::cache_result(expr * n, expr * r, proof * pr) { - m_cache.insert(n, r, pr); -} - -void pull_ite_tree::visit(expr * n, bool & visited) { - if (!is_cached(n)) { - m_todo.push_back(n); - visited = false; - } -} - -bool pull_ite_tree::visit_children(expr * n) { - if (m_manager.is_ite(n)) { - bool visited = true; - visit(to_app(n)->get_arg(1), visited); - visit(to_app(n)->get_arg(2), visited); - return visited; - } - else { - return true; - } -} - -void pull_ite_tree::reduce(expr * n) { - // Remark: invoking the simplifier to build the new expression saves a lot of memory. - if (m_manager.is_ite(n)) { - expr * c = to_app(n)->get_arg(0); - expr * t_old = to_app(n)->get_arg(1); - expr * e_old = to_app(n)->get_arg(2); - expr * t = nullptr; - proof * t_pr = nullptr; - expr * e = nullptr; - proof * e_pr = nullptr; - get_cached(t_old, t, t_pr); - get_cached(e_old, e, e_pr); - expr_ref r(m_manager); - expr * args[3] = {c, t, e}; - r = m_rewriter.mk_app(to_app(n)->get_decl(), 3, args); - if (!m_manager.proofs_enabled()) { - // expr * r = m_manager.mk_ite(c, t, e); - cache_result(n, r, nullptr); - } - else { - // t_pr is a proof for (m_p ... t_old ...) == t - // e_pr is a proof for (m_p ... e_old ...) == e - expr_ref old(m_manager); - expr_ref p_t_old(m_manager); - expr_ref p_e_old(m_manager); - old = mk_p_arg(n); // (m_p ... n ...) where n is (ite c t_old e_old) - p_t_old = mk_p_arg(t_old); // (m_p ... t_old ...) - p_e_old = mk_p_arg(e_old); // (m_p ... e_old ...) - expr_ref tmp1(m_manager); - tmp1 = m_manager.mk_ite(c, p_t_old, p_e_old); // (ite c (m_p ... t_old ...) (m_p ... e_old ...)) - proof * pr1 = m_manager.mk_rewrite(old, tmp1); // proof for (m_p ... (ite c t_old e_old) ...) = (ite c (m_p ... t_old ...) (m_p ... e_old ...)) - expr_ref tmp2(m_manager); - tmp2 = m_manager.mk_ite(c, t, e); // (ite c t e) - proof * pr2 = nullptr; // it will contain a proof for (ite c (m_p ... t_old ...) (m_p ... e_old ...)) = (ite c t e) - proof * pr3 = nullptr; // it will contain a proof for (m_p ... (ite c t_old e_old) ...) = (ite c t e) - proof * proofs[2]; - unsigned num_proofs = 0; - if (t_pr != nullptr) { - proofs[num_proofs] = t_pr; - num_proofs++; - } - if (e_pr != nullptr) { - proofs[num_proofs] = e_pr; - num_proofs++; - } - if (num_proofs > 0) { - pr2 = m_manager.mk_congruence(to_app(tmp1), to_app(tmp2), num_proofs, proofs); - pr3 = m_manager.mk_transitivity(pr1, pr2); - } - else { - pr3 = pr1; - } - proof * pr4 = nullptr; // it will contain a proof for (ite c t e) = r - proof * pr5 = nullptr; // it will contain a proof for (m_p ... (ite c t_old e_old) ...) = r - if (tmp2 != r) { - pr4 = m_manager.mk_rewrite(tmp2, r); - pr5 = m_manager.mk_transitivity(pr3, pr4); - } - else { - pr5 = pr3; - } - cache_result(n, r, pr5); - } - } - else { - expr_ref r(m_manager); - m_args[m_arg_idx] = n; - r = m_rewriter.mk_app(m_p, m_args.size(), m_args.c_ptr()); - if (!m_manager.proofs_enabled()) { - // expr * r = m_manager.mk_app(m_p, m_args.size(), m_args.c_ptr()); - cache_result(n, r, nullptr); - } - else { - expr_ref old(m_manager); - proof * p; - old = mk_p_arg(n); - if (old == r) - p = nullptr; - else - p = m_manager.mk_rewrite(old, r); - cache_result(n, r, p); - } - } -} - -void pull_ite_tree::operator()(app * n, app_ref & r, proof_ref & pr) { - unsigned num_args = n->get_num_args(); - m_args.resize(num_args); - m_p = n->get_decl(); - expr * ite = nullptr; - for (unsigned i = 0; i < num_args; i++) { - expr * arg = n->get_arg(i); - if (ite) { - m_args[i] = arg; - } - else if (m_manager.is_ite(arg)) { - m_arg_idx = i; - m_args[i] = 0; - ite = arg; - } - else { - m_args[i] = arg; - } - } - if (!ite) { - r = n; - pr = nullptr; - return; - } - m_todo.push_back(ite); - while (!m_todo.empty()) { - expr * n = m_todo.back(); - if (is_cached(n)) - m_todo.pop_back(); - else if (visit_children(n)) { - m_todo.pop_back(); - reduce(n); - } - } - SASSERT(is_cached(ite)); - expr * _r = nullptr; - proof * _pr = nullptr; - get_cached(ite, _r, _pr); - r = to_app(_r); - pr = _pr; - m_cache.reset(); - m_todo.reset(); -} - - - -pull_ite_tree_cfg::pull_ite_tree_cfg(ast_manager & m): - m(m), - m_trail(m), - m_proc(m) { -} - -bool pull_ite_tree_cfg::get_subst(expr * n, expr* & r, proof* & p) { - if (is_app(n) && is_target(to_app(n))) { - app_ref tmp(m); - proof_ref pr(m); - m_proc(to_app(n), tmp, pr); - if (tmp != n) { - r = tmp; - p = pr; - m_trail.push_back(r); - m_trail.push_back(p); - return true; - } - } - return false; -} - -bool pull_cheap_ite_tree_cfg::is_target(app * n) const { - bool r = - n->get_num_args() == 2 && - n->get_family_id() != null_family_id && - m.is_bool(n) && - (m.is_value(n->get_arg(0)) || m.is_value(n->get_arg(1))) && - (m.is_term_ite(n->get_arg(0)) || m.is_term_ite(n->get_arg(1))); - TRACE("pull_ite_target", tout << mk_pp(n, m) << "\nresult: " << r << "\n";); - return r; -} - - - - - - diff --git a/src/ast/rewriter/pull_ite_tree.h b/src/ast/rewriter/pull_ite_tree.h deleted file mode 100644 index ea462315a..000000000 --- a/src/ast/rewriter/pull_ite_tree.h +++ /dev/null @@ -1,113 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - pull_ite_tree.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-06-22. - -Revision History: - ---*/ -#ifndef PULL_ITE_TREE_H_ -#define PULL_ITE_TREE_H_ - -#include "ast/ast.h" -#include "ast/rewriter/rewriter.h" -#include "ast/rewriter/th_rewriter.h" -#include "ast/expr_map.h" -#include "ast/recurse_expr.h" -#include "util/obj_hashtable.h" - -/** - \brief Functor for applying the following transformation - F[(p (ite c t1 t2) args)] = F'[(ite c t1 t2), p, args] - - F'[(ite c t1 t2), p, args] = (ite c F'[t1, p, args] F'[t2, p, args]) - F'[t, p, args] = (p t args) -*/ -class pull_ite_tree { - ast_manager & m_manager; - th_rewriter m_rewriter; - func_decl * m_p; - ptr_vector m_args; - unsigned m_arg_idx; //!< position of the ite argument - expr_map m_cache; - ptr_vector m_todo; - - bool is_cached(expr * n) const { return m_cache.contains(n); } - void get_cached(expr * n, expr * & r, proof * & p) const { m_cache.get(n, r, p); } - void cache_result(expr * n, expr * r, proof * pr); - void visit(expr * n, bool & visited); - bool visit_children(expr * n); - void reduce(expr * n); - /** - \brief Creante an application (m_p ... n ...) where n is the argument m_arg_idx and the other arguments - are in m_args. - */ - expr * mk_p_arg(expr * n) { - m_args[m_arg_idx] = n; - return m_manager.mk_app(m_p, m_args.size(), m_args.c_ptr()); - } -public: - pull_ite_tree(ast_manager & m); - /** - \brief Apply the transformation above if n contains an ite-expression. - Store the result in r. If n does not contain an ite-expression, then - store n in r. - - When proof generation is enabled, pr is a proof for n = r. - */ - void operator()(app * n, app_ref & r, proof_ref & pr); -}; - -/** - \brief Functor for applying the pull_ite_tree on subexpressions n that - satisfy the is_target virtual predicate. -*/ -class pull_ite_tree_cfg : public default_rewriter_cfg { -protected: - ast_manager& m; - expr_ref_vector m_trail; - pull_ite_tree m_proc; -public: - pull_ite_tree_cfg(ast_manager & m); - virtual ~pull_ite_tree_cfg() {} - virtual bool is_target(app * n) const = 0; - bool get_subst(expr * n, expr* & r, proof* & p); -}; - -/** - \brief Apply pull_ite_tree on predicates of the form - (p ite v) and (p v ite) - - where: - - p is an interpreted predicate - - ite is an ite-term expression - - v is a value -*/ -class pull_cheap_ite_tree_cfg : public pull_ite_tree_cfg { -public: - pull_cheap_ite_tree_cfg(ast_manager & m):pull_ite_tree_cfg(m) {} - ~pull_cheap_ite_tree_cfg() override {} - bool is_target(app * n) const override; -}; - -class pull_cheap_ite_tree_rw : public rewriter_tpl { - pull_cheap_ite_tree_cfg m_cfg; -public: - pull_cheap_ite_tree_rw(ast_manager& m): - rewriter_tpl(m, m.proofs_enabled(), m_cfg), - m_cfg(m) - {} -}; - -#endif /* PULL_ITE_TREE_H_ */ - diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 465371434..5903fefcb 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -46,7 +46,6 @@ asserted_formulas::asserted_formulas(ast_manager & m, smt_params & p): m_refine_inj_axiom(*this), m_max_bv_sharing_fn(*this), m_elim_term_ite(*this), - m_pull_cheap_ite_trees(*this), m_pull_nested_quantifiers(*this), m_elim_bvs_from_quantifiers(*this), m_cheap_quant_fourier_motzkin(*this), @@ -122,7 +121,7 @@ void asserted_formulas::set_eliminate_and(bool flag) { if (flag == m_elim_and) return; m_elim_and = flag; params_ref p; - p.set_bool("pull_cheap_ite", false); + if (m_params.m_pull_cheap_ite) p.set_bool("pull_cheap_ite", true); p.set_bool("elim_and", flag); p.set_bool("arith_ineq_lhs", true); p.set_bool("sort_sums", true); @@ -241,7 +240,6 @@ void asserted_formulas::reduce() { if (!invoke(m_nnf_cnf)) return; set_eliminate_and(true); if (!invoke(m_reduce_asserted_formulas)) return; - if (!invoke(m_pull_cheap_ite_trees)) return; if (!invoke(m_pull_nested_quantifiers)) return; if (!invoke(m_lift_ite)) return; if (!invoke(m_ng_lift_ite)) return; diff --git a/src/smt/asserted_formulas.h b/src/smt/asserted_formulas.h index a67b975eb..275687adb 100644 --- a/src/smt/asserted_formulas.h +++ b/src/smt/asserted_formulas.h @@ -26,7 +26,6 @@ Revision History: #include "ast/rewriter/bit2int.h" #include "ast/rewriter/maximize_ac_sharing.h" #include "ast/rewriter/distribute_forall.h" -#include "ast/rewriter/pull_ite_tree.h" #include "ast/rewriter/push_app_ite.h" #include "ast/rewriter/inj_axiom.h" #include "ast/rewriter/bv_elim.h" @@ -172,7 +171,6 @@ class asserted_formulas { #define MK_SIMPLIFIERF(NAME, FUNCTOR, MSG, APP, REDUCE) MK_SIMPLIFIERA(NAME, FUNCTOR, MSG, APP, (af.m), REDUCE) - MK_SIMPLIFIERF(pull_cheap_ite_trees, pull_cheap_ite_tree_rw, "pull-cheap-ite-trees", af.m_params.m_pull_cheap_ite_trees, false); MK_SIMPLIFIERF(pull_nested_quantifiers, pull_nested_quant, "pull-nested-quantifiers", af.m_params.m_pull_nested_quantifiers && af.has_quantifiers(), false); MK_SIMPLIFIERF(cheap_quant_fourier_motzkin, elim_bounds_rw, "cheap-fourier-motzkin", af.m_params.m_eliminate_bounds && af.has_quantifiers(), true); MK_SIMPLIFIERF(elim_bvs_from_quantifiers, bv_elim_rw, "eliminate-bit-vectors-from-quantifiers", af.m_params.m_bb_quantifiers, true); @@ -187,7 +185,6 @@ class asserted_formulas { refine_inj_axiom_fn m_refine_inj_axiom; max_bv_sharing_fn m_max_bv_sharing_fn; elim_term_ite_fn m_elim_term_ite; - pull_cheap_ite_trees m_pull_cheap_ite_trees; pull_nested_quantifiers m_pull_nested_quantifiers; elim_bvs_from_quantifiers m_elim_bvs_from_quantifiers; cheap_quant_fourier_motzkin m_cheap_quant_fourier_motzkin; @@ -219,7 +216,6 @@ class asserted_formulas { bool is_gt(expr* lhs, expr* rhs); void compute_depth(expr* e); unsigned depth(expr* e) { return m_expr2depth[e]; } - bool pull_cheap_ite_trees(); void init(unsigned num_formulas, expr * const * formulas, proof * const * prs); diff --git a/src/smt/params/preprocessor_params.cpp b/src/smt/params/preprocessor_params.cpp index 93ea794fa..ee4b7c2e4 100644 --- a/src/smt/params/preprocessor_params.cpp +++ b/src/smt/params/preprocessor_params.cpp @@ -41,7 +41,7 @@ void preprocessor_params::display(std::ostream & out) const { DISPLAY_PARAM(m_lift_ite); DISPLAY_PARAM(m_ng_lift_ite); - DISPLAY_PARAM(m_pull_cheap_ite_trees); + DISPLAY_PARAM(m_pull_cheap_ite); DISPLAY_PARAM(m_pull_nested_quantifiers); DISPLAY_PARAM(m_eliminate_term_ite); DISPLAY_PARAM(m_macro_finder); diff --git a/src/smt/params/preprocessor_params.h b/src/smt/params/preprocessor_params.h index dc16d6244..be7fd4c01 100644 --- a/src/smt/params/preprocessor_params.h +++ b/src/smt/params/preprocessor_params.h @@ -32,7 +32,7 @@ struct preprocessor_params : public pattern_inference_params, public bit_blaster_params { lift_ite_kind m_lift_ite; lift_ite_kind m_ng_lift_ite; // lift ite for non ground terms - bool m_pull_cheap_ite_trees; + bool m_pull_cheap_ite; bool m_pull_nested_quantifiers; bool m_eliminate_term_ite; bool m_macro_finder; @@ -54,7 +54,7 @@ public: preprocessor_params(params_ref const & p = params_ref()): m_lift_ite(LI_NONE), m_ng_lift_ite(LI_NONE), - m_pull_cheap_ite_trees(false), + m_pull_cheap_ite(false), m_pull_nested_quantifiers(false), m_eliminate_term_ite(false), m_macro_finder(false), diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index bbc91e4c6..383d98e67 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -507,7 +507,7 @@ namespace smt { m_params.m_nnf_cnf = false; if (st.m_max_ite_tree_depth > 50) { m_params.m_arith_eq2ineq = false; - m_params.m_pull_cheap_ite_trees = true; + m_params.m_pull_cheap_ite = true; m_params.m_arith_propagate_eqs = true; m_params.m_relevancy_lvl = 2; m_params.m_relevancy_lemma = false; From 534a31f74e81ab880fbb28dbf829e036d7a3957c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 4 Mar 2018 05:06:36 -0800 Subject: [PATCH 211/263] inherit solver parameters in asserted formulas rewriter. #1511 Signed-off-by: Nikolaj Bjorner --- src/smt/asserted_formulas.cpp | 4 ++++ src/smt/asserted_formulas.h | 1 + src/smt/params/preprocessor_params.cpp | 1 + src/smt/smt_context.cpp | 4 ++++ src/smt/smt_context.h | 2 ++ src/smt/smt_kernel.cpp | 10 +++------- src/test/heap.cpp | 5 ++++- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 5903fefcb..444069d8c 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -117,6 +117,10 @@ void asserted_formulas::push_assertion(expr * e, proof * pr, vector& mutexes) { return m_kernel.find_mutexes(vars, mutexes); } @@ -196,9 +195,7 @@ namespace smt { } void updt_params(params_ref const & p) { - // We don't need params2smt_params anymore. smt_params has support for reading params_ref. - // The update is performed at smt_kernel "users". - // params2smt_params(p, fparams()); + m_kernel.updt_params(p); } }; @@ -218,7 +215,6 @@ namespace smt { imp::copy(*src.m_imp, *dst.m_imp); } - bool kernel::set_logic(symbol logic) { return m_imp->set_logic(logic); } @@ -263,9 +259,9 @@ namespace smt { } void kernel::reset() { - ast_manager & _m = m(); + ast_manager & _m = m(); smt_params & fps = m_imp->fparams(); - params_ref ps = m_imp->params(); + params_ref ps = m_imp->params(); #pragma omp critical (smt_kernel) { m_imp->~imp(); diff --git a/src/test/heap.cpp b/src/test/heap.cpp index 08891ccaa..2c77b939e 100644 --- a/src/test/heap.cpp +++ b/src/test/heap.cpp @@ -21,16 +21,19 @@ Revision History: #include "util/heap.h" #include "util/trace.h" #include "util/uint_set.h" +// include "util/hashtable.h" struct lt_proc { bool operator()(int v1, int v2) const { return v1 < v2; } }; +//struct int_hash_proc { unsigned operator()(int v) const { std::cout << "hash " << v << "\n"; VERIFY(v >= 0); return v; }}; +//typedef int_hashtable > int_set; typedef heap int_heap; -struct int_hash_proc { unsigned operator()(int v) const { return v * 17; }}; #define N 10000 static random_gen heap_rand(1); static void tst1() { int_heap h(N); +// int_set t; uint_set t; for (int i = 0; i < N * 3; i++) { int val = heap_rand() % N; From eb1122c5cb434338e25b87e7d94c7c6d56be02f8 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 4 Mar 2018 21:57:08 -0800 Subject: [PATCH 212/263] delay updating parameters to ensure rewriting in asserted_formulas is applied using configuration overrides. Fixes build regression for tree_interpolation documentation test Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 2 +- src/smt/asserted_formulas.cpp | 44 +++++++++++++------------- src/smt/asserted_formulas.h | 37 +++++++++++----------- src/smt/mam.cpp | 2 +- src/smt/params/preprocessor_params.cpp | 1 - src/smt/smt_context.cpp | 2 +- src/smt/smt_relevancy.cpp | 6 ++-- src/smt/theory_seq.cpp | 1 - 8 files changed, 47 insertions(+), 48 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 785649e3d..1cfb10179 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -8266,7 +8266,7 @@ def tree_interpolant(pat,p=None,ctx=None): solver that determines satisfiability. >>> x = Int('x') - >>> y = Int('y') + >>> y = Int('y') >>> print(tree_interpolant(And(Interpolant(x < 0), Interpolant(y > 2), x == y))) [Not(x >= 0), Not(y <= 2)] diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 444069d8c..ab9bb0895 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -27,8 +27,9 @@ Revision History: #include "ast/macros/quasi_macros.h" #include "smt/asserted_formulas.h" -asserted_formulas::asserted_formulas(ast_manager & m, smt_params & p): +asserted_formulas::asserted_formulas(ast_manager & m, smt_params & sp, params_ref const& p): m(m), + m_smt_params(sp), m_params(p), m_rewriter(m), m_substitution(m), @@ -65,20 +66,20 @@ asserted_formulas::asserted_formulas(ast_manager & m, smt_params & p): } void asserted_formulas::setup() { - switch (m_params.m_lift_ite) { + switch (m_smt_params.m_lift_ite) { case LI_FULL: - m_params.m_ng_lift_ite = LI_NONE; + m_smt_params.m_ng_lift_ite = LI_NONE; break; case LI_CONSERVATIVE: - if (m_params.m_ng_lift_ite == LI_CONSERVATIVE) - m_params.m_ng_lift_ite = LI_NONE; + if (m_smt_params.m_ng_lift_ite == LI_CONSERVATIVE) + m_smt_params.m_ng_lift_ite = LI_NONE; break; default: break; } - if (m_params.m_relevancy_lvl == 0) - m_params.m_relevancy_lemma = false; + if (m_smt_params.m_relevancy_lvl == 0) + m_smt_params.m_relevancy_lemma = false; } @@ -118,24 +119,23 @@ void asserted_formulas::push_assertion(expr * e, proof * pr, vector l(m_check_missing_instances, true); rematch(false); diff --git a/src/smt/params/preprocessor_params.cpp b/src/smt/params/preprocessor_params.cpp index 57b11e7fd..ee4b7c2e4 100644 --- a/src/smt/params/preprocessor_params.cpp +++ b/src/smt/params/preprocessor_params.cpp @@ -25,7 +25,6 @@ void preprocessor_params::updt_local_params(params_ref const & _p) { m_quasi_macros = p.quasi_macros(); m_restricted_quasi_macros = p.restricted_quasi_macros(); m_pull_nested_quantifiers = p.pull_nested_quantifiers(); -// m_pull_cheap_ite = _p.get_bool("pull_cheap_ite", m_pull_cheap_ite); m_refine_inj_axiom = p.refine_inj_axioms(); } diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 513bf7665..e20eae0bd 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -45,7 +45,7 @@ namespace smt { m_fparams(p), m_params(_p), m_setup(*this, p), - m_asserted_formulas(m, p), + m_asserted_formulas(m, p, _p), m_qmanager(alloc(quantifier_manager, *this, p, _p)), m_model_generator(alloc(model_generator, m)), m_relevancy_propagator(mk_relevancy_propagator(*this)), diff --git a/src/smt/smt_relevancy.cpp b/src/smt/smt_relevancy.cpp index 9eabb8319..7db5110ee 100644 --- a/src/smt/smt_relevancy.cpp +++ b/src/smt/smt_relevancy.cpp @@ -527,7 +527,7 @@ namespace smt { } #ifdef Z3DEBUG - bool check_relevancy_app(app * n) const { + bool check_relevancy_app(app * n) const { SASSERT(is_relevant(n)); unsigned num_args = n->get_num_args(); for (unsigned i = 0; i < num_args; i++) { @@ -537,7 +537,7 @@ namespace smt { return true; } - virtual bool check_relevancy_or(app * n, bool root) const { + bool check_relevancy_or(app * n, bool root) const override { lbool val = root ? l_true : m_context.find_assignment(n); if (val == l_false) return check_relevancy_app(n); @@ -600,7 +600,7 @@ namespace smt { return true; } - bool check_relevancy(expr_ref_vector const & v) const { + bool check_relevancy(expr_ref_vector const & v) const override { SASSERT(!can_propagate()); ast_manager & m = get_manager(); unsigned sz = v.size(); diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index 12764fd9d..b90735a07 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -2449,7 +2449,6 @@ expr_ref theory_seq::digit2int(expr* ch) { } void theory_seq::add_itos_axiom(expr* e) { - context& ctx = get_context(); rational val; expr* n = nullptr; TRACE("seq", tout << mk_pp(e, m) << "\n";); From 4cc936285113df07f6492cf791f7850e933cda54 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 7 Mar 2018 13:18:39 +0700 Subject: [PATCH 213/263] Make proof_checker more const correct. --- src/ast/proofs/proof_checker.cpp | 52 ++++++++++++++++---------------- src/ast/proofs/proof_checker.h | 50 +++++++++++++++--------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/ast/proofs/proof_checker.cpp b/src/ast/proofs/proof_checker.cpp index 9ba52a402..bd50e6c2a 100644 --- a/src/ast/proofs/proof_checker.cpp +++ b/src/ast/proofs/proof_checker.cpp @@ -922,7 +922,7 @@ void proof_checker::set_false(expr_ref& e, unsigned position, expr_ref& lit) { } } -bool proof_checker::match_fact(proof* p, expr_ref& fact) { +bool proof_checker::match_fact(proof const* p, expr_ref& fact) const { if (m.is_proof(p) && m.has_fact(p)) { fact = m.get_fact(p); @@ -938,13 +938,13 @@ void proof_checker::add_premise(proof* p) { } } -bool proof_checker::match_proof(proof* p) { +bool proof_checker::match_proof(proof const* p) const { return m.is_proof(p) && m.get_num_parents(p) == 0; } -bool proof_checker::match_proof(proof* p, proof_ref& p0) { +bool proof_checker::match_proof(proof const* p, proof_ref& p0) const { if (m.is_proof(p) && m.get_num_parents(p) == 1) { p0 = m.get_parent(p, 0); @@ -953,7 +953,7 @@ bool proof_checker::match_proof(proof* p, proof_ref& p0) { return false; } -bool proof_checker::match_proof(proof* p, proof_ref& p0, proof_ref& p1) { +bool proof_checker::match_proof(proof const* p, proof_ref& p0, proof_ref& p1) const { if (m.is_proof(p) && m.get_num_parents(p) == 2) { p0 = m.get_parent(p, 0); @@ -963,7 +963,7 @@ bool proof_checker::match_proof(proof* p, proof_ref& p0, proof_ref& p1) { return false; } -bool proof_checker::match_proof(proof* p, proof_ref_vector& parents) { +bool proof_checker::match_proof(proof const* p, proof_ref_vector& parents) const { if (m.is_proof(p)) { for (unsigned i = 0; i < m.get_num_parents(p); ++i) { parents.push_back(m.get_parent(p, i)); @@ -974,7 +974,7 @@ bool proof_checker::match_proof(proof* p, proof_ref_vector& parents) { } -bool proof_checker::match_binary(expr* e, func_decl_ref& d, expr_ref& t1, expr_ref& t2) { +bool proof_checker::match_binary(expr const* e, func_decl_ref& d, expr_ref& t1, expr_ref& t2) const { if (e->get_kind() == AST_APP && to_app(e)->get_num_args() == 2) { d = to_app(e)->get_decl(); @@ -986,7 +986,7 @@ bool proof_checker::match_binary(expr* e, func_decl_ref& d, expr_ref& t1, expr_r } -bool proof_checker::match_app(expr* e, func_decl_ref& d, expr_ref_vector& terms) { +bool proof_checker::match_app(expr const* e, func_decl_ref& d, expr_ref_vector& terms) const { if (e->get_kind() == AST_APP) { d = to_app(e)->get_decl(); for (unsigned i = 0; i < to_app(e)->get_num_args(); ++i) { @@ -997,9 +997,9 @@ bool proof_checker::match_app(expr* e, func_decl_ref& d, expr_ref_vector& terms) return false; } -bool proof_checker::match_quantifier(expr* e, bool& is_univ, sort_ref_vector& sorts, expr_ref& body) { +bool proof_checker::match_quantifier(expr const* e, bool& is_univ, sort_ref_vector& sorts, expr_ref& body) const { if (is_quantifier(e)) { - quantifier* q = to_quantifier(e); + quantifier const* q = to_quantifier(e); is_univ = q->is_forall(); body = q->get_expr(); for (unsigned i = 0; i < q->get_num_decls(); ++i) { @@ -1010,7 +1010,7 @@ bool proof_checker::match_quantifier(expr* e, bool& is_univ, sort_ref_vector& so return false; } -bool proof_checker::match_op(expr* e, decl_kind k, expr_ref& t1, expr_ref& t2) { +bool proof_checker::match_op(expr const* e, decl_kind k, expr_ref& t1, expr_ref& t2) const { if (e->get_kind() == AST_APP && to_app(e)->get_family_id() == m.get_basic_family_id() && to_app(e)->get_decl_kind() == k && @@ -1022,7 +1022,7 @@ bool proof_checker::match_op(expr* e, decl_kind k, expr_ref& t1, expr_ref& t2) { return false; } -bool proof_checker::match_op(expr* e, decl_kind k, expr_ref_vector& terms) { +bool proof_checker::match_op(expr const* e, decl_kind k, expr_ref_vector& terms) const { if (e->get_kind() == AST_APP && to_app(e)->get_family_id() == m.get_basic_family_id() && to_app(e)->get_decl_kind() == k) { @@ -1035,7 +1035,7 @@ bool proof_checker::match_op(expr* e, decl_kind k, expr_ref_vector& terms) { } -bool proof_checker::match_op(expr* e, decl_kind k, expr_ref& t) { +bool proof_checker::match_op(expr const* e, decl_kind k, expr_ref& t) const { if (e->get_kind() == AST_APP && to_app(e)->get_family_id() == m.get_basic_family_id() && to_app(e)->get_decl_kind() == k && @@ -1046,39 +1046,39 @@ bool proof_checker::match_op(expr* e, decl_kind k, expr_ref& t) { return false; } -bool proof_checker::match_not(expr* e, expr_ref& t) { +bool proof_checker::match_not(expr const* e, expr_ref& t) const { return match_op(e, OP_NOT, t); } -bool proof_checker::match_or(expr* e, expr_ref_vector& terms) { +bool proof_checker::match_or(expr const* e, expr_ref_vector& terms) const { return match_op(e, OP_OR, terms); } -bool proof_checker::match_and(expr* e, expr_ref_vector& terms) { +bool proof_checker::match_and(expr const* e, expr_ref_vector& terms) const { return match_op(e, OP_AND, terms); } -bool proof_checker::match_iff(expr* e, expr_ref& t1, expr_ref& t2) { +bool proof_checker::match_iff(expr const* e, expr_ref& t1, expr_ref& t2) const { return match_op(e, OP_IFF, t1, t2); } -bool proof_checker::match_equiv(expr* e, expr_ref& t1, expr_ref& t2) { +bool proof_checker::match_equiv(expr const* e, expr_ref& t1, expr_ref& t2) const { return match_oeq(e, t1, t2) || match_eq(e, t1, t2); } -bool proof_checker::match_implies(expr* e, expr_ref& t1, expr_ref& t2) { +bool proof_checker::match_implies(expr const* e, expr_ref& t1, expr_ref& t2) const { return match_op(e, OP_IMPLIES, t1, t2); } -bool proof_checker::match_eq(expr* e, expr_ref& t1, expr_ref& t2) { +bool proof_checker::match_eq(expr const* e, expr_ref& t1, expr_ref& t2) const { return match_op(e, OP_EQ, t1, t2) || match_iff(e, t1, t2); } -bool proof_checker::match_oeq(expr* e, expr_ref& t1, expr_ref& t2) { +bool proof_checker::match_oeq(expr const* e, expr_ref& t1, expr_ref& t2) const { return match_op(e, OP_OEQ, t1, t2); } -bool proof_checker::match_negated(expr* a, expr* b) { +bool proof_checker::match_negated(expr const* a, expr* b) const { expr_ref t(m); return (match_not(a, t) && t.get() == b) || @@ -1186,14 +1186,14 @@ void proof_checker::get_hypotheses(proof* p, expr_ref_vector& ante) { } -bool proof_checker::match_nil(expr* e) const { +bool proof_checker::match_nil(expr const* e) const { return is_app(e) && to_app(e)->get_family_id() == m_hyp_fid && to_app(e)->get_decl_kind() == OP_NIL; } -bool proof_checker::match_cons(expr* e, expr_ref& a, expr_ref& b) const { +bool proof_checker::match_cons(expr const* e, expr_ref& a, expr_ref& b) const { if (is_app(e) && to_app(e)->get_family_id() == m_hyp_fid && to_app(e)->get_decl_kind() == OP_CONS) { @@ -1205,7 +1205,7 @@ bool proof_checker::match_cons(expr* e, expr_ref& a, expr_ref& b) const { } -bool proof_checker::match_atom(expr* e, expr_ref& a) const { +bool proof_checker::match_atom(expr const* e, expr_ref& a) const { if (is_app(e) && to_app(e)->get_family_id() == m_hyp_fid && to_app(e)->get_decl_kind() == OP_ATOM) { @@ -1227,7 +1227,7 @@ expr* proof_checker::mk_nil() { return m_nil.get(); } -bool proof_checker::is_hypothesis(proof* p) const { +bool proof_checker::is_hypothesis(proof const* p) const { return m.is_proof(p) && p->get_decl_kind() == PR_HYPOTHESIS; @@ -1253,7 +1253,7 @@ expr* proof_checker::mk_hyp(unsigned num_hyps, expr * const * hyps) { } } -void proof_checker::dump_proof(proof * pr) { +void proof_checker::dump_proof(proof const* pr) { if (!m_dump_lemmas) return; SASSERT(m.has_fact(pr)); diff --git a/src/ast/proofs/proof_checker.h b/src/ast/proofs/proof_checker.h index ccb815c61..ac0e31dbd 100644 --- a/src/ast/proofs/proof_checker.h +++ b/src/ast/proofs/proof_checker.h @@ -77,39 +77,39 @@ private: bool check1_spc(proof* p, expr_ref_vector& side_conditions); bool check_arith_proof(proof* p); bool check_arith_literal(bool is_pos, app* lit, rational const& coeff, expr_ref& sum, bool& is_strict); - bool match_fact(proof* p, expr_ref& fact); + bool match_fact(proof const* p, expr_ref& fact) const; void add_premise(proof* p); - bool match_proof(proof* p); - bool match_proof(proof* p, proof_ref& p0); - bool match_proof(proof* p, proof_ref& p0, proof_ref& p1); - bool match_proof(proof* p, proof_ref_vector& parents); - bool match_binary(expr* e, func_decl_ref& d, expr_ref& t1, expr_ref& t2); - bool match_op(expr* e, decl_kind k, expr_ref& t1, expr_ref& t2); - bool match_op(expr* e, decl_kind k, expr_ref& t); - bool match_op(expr* e, decl_kind k, expr_ref_vector& terms); - bool match_iff(expr* e, expr_ref& t1, expr_ref& t2); - bool match_implies(expr* e, expr_ref& t1, expr_ref& t2); - bool match_eq(expr* e, expr_ref& t1, expr_ref& t2); - bool match_oeq(expr* e, expr_ref& t1, expr_ref& t2); - bool match_not(expr* e, expr_ref& t); - bool match_or(expr* e, expr_ref_vector& terms); - bool match_and(expr* e, expr_ref_vector& terms); - bool match_app(expr* e, func_decl_ref& d, expr_ref_vector& terms); - bool match_quantifier(expr*, bool& is_univ, sort_ref_vector&, expr_ref& body); - bool match_negated(expr* a, expr* b); - bool match_equiv(expr* a, expr_ref& t1, expr_ref& t2); + bool match_proof(proof const* p) const; + bool match_proof(proof const* p, proof_ref& p0) const; + bool match_proof(proof const* p, proof_ref& p0, proof_ref& p1) const; + bool match_proof(proof const* p, proof_ref_vector& parents) const; + bool match_binary(expr const* e, func_decl_ref& d, expr_ref& t1, expr_ref& t2) const; + bool match_op(expr const* e, decl_kind k, expr_ref& t1, expr_ref& t2) const; + bool match_op(expr const* e, decl_kind k, expr_ref& t) const; + bool match_op(expr const* e, decl_kind k, expr_ref_vector& terms) const; + bool match_iff(expr const* e, expr_ref& t1, expr_ref& t2) const; + bool match_implies(expr const* e, expr_ref& t1, expr_ref& t2) const; + bool match_eq(expr const* e, expr_ref& t1, expr_ref& t2) const; + bool match_oeq(expr const* e, expr_ref& t1, expr_ref& t2) const; + bool match_not(expr const* e, expr_ref& t) const; + bool match_or(expr const* e, expr_ref_vector& terms) const; + bool match_and(expr const* e, expr_ref_vector& terms) const; + bool match_app(expr const* e, func_decl_ref& d, expr_ref_vector& terms) const; + bool match_quantifier(expr const*, bool& is_univ, sort_ref_vector&, expr_ref& body) const; + bool match_negated(expr const* a, expr* b) const; + bool match_equiv(expr const* a, expr_ref& t1, expr_ref& t2) const; void get_ors(expr* e, expr_ref_vector& ors); void get_hypotheses(proof* p, expr_ref_vector& ante); - bool match_nil(expr* e) const; - bool match_cons(expr* e, expr_ref& a, expr_ref& b) const; - bool match_atom(expr* e, expr_ref& a) const; + bool match_nil(expr const* e) const; + bool match_cons(expr const* e, expr_ref& a, expr_ref& b) const; + bool match_atom(expr const* e, expr_ref& a) const; expr* mk_nil(); expr* mk_cons(expr* a, expr* b); expr* mk_atom(expr* e); - bool is_hypothesis(proof* p) const; + bool is_hypothesis(proof const* p) const; expr* mk_hyp(unsigned num_hyps, expr * const * hyps); - void dump_proof(proof * pr); + void dump_proof(proof const* pr); void dump_proof(unsigned num_antecedents, expr * const * antecedents, expr * consequent); void set_false(expr_ref& e, unsigned idx, expr_ref& lit); From 0b54a915131526df59208def2fa097fd6fd1dbb1 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 7 Mar 2018 13:29:13 +0700 Subject: [PATCH 214/263] Force color output with Ninja. --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69a0ca123..a222551ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,6 +409,20 @@ list(APPEND Z3_DEPENDENT_LIBS ${CMAKE_THREAD_LIBS_INIT}) ################################################################################ include(${CMAKE_SOURCE_DIR}/cmake/compiler_warnings.cmake) +################################################################################ +# If using Ninja, force color output for Clang and gcc. +################################################################################ +if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja") + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics") + endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color") + endif() +endif() + ################################################################################ # Option to control what type of library we build ################################################################################ From 246941f2d30b9865229759e0d8707fc8c7de6763 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 7 Mar 2018 14:26:38 -0800 Subject: [PATCH 215/263] fix #1522 Signed-off-by: Nikolaj Bjorner --- src/ast/ast.cpp | 53 +++++++++++++++++++------------------ src/ast/ast_pp_util.cpp | 7 ++++- src/ast/ast_pp_util.h | 4 +++ src/muz/base/dl_context.cpp | 32 +++++++++++++--------- src/test/quant_elim.cpp | 2 ++ 5 files changed, 58 insertions(+), 40 deletions(-) diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index c27651fca..127967374 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1536,34 +1536,35 @@ void ast_manager::copy_families_plugins(ast_manager const & from) { // assigned in the order that they are created, this can result in differing // family ids. To avoid this, we first assign all family ids and only then inherit plugins. for (family_id fid = 0; from.m_family_manager.has_family(fid); fid++) { - symbol fid_name = from.get_family_name(fid); - if (!m_family_manager.has_family(fid)) { - family_id new_fid = mk_family_id(fid_name); - (void)new_fid; - TRACE("copy_families_plugins", tout << "new target fid created: " << new_fid << " fid_name: " << fid_name << "\n";); - } + symbol fid_name = from.get_family_name(fid); + if (!m_family_manager.has_family(fid)) { + family_id new_fid = mk_family_id(fid_name); + (void)new_fid; + TRACE("copy_families_plugins", tout << "new target fid created: " << new_fid << " fid_name: " << fid_name << "\n";); + } } for (family_id fid = 0; from.m_family_manager.has_family(fid); fid++) { - SASSERT(from.is_builtin_family_id(fid) == is_builtin_family_id(fid)); - SASSERT(!from.is_builtin_family_id(fid) || m_family_manager.has_family(fid)); - symbol fid_name = from.get_family_name(fid); - TRACE("copy_families_plugins", tout << "copying: " << fid_name << ", src fid: " << fid - << ", target has_family: " << m_family_manager.has_family(fid) << "\n"; - if (m_family_manager.has_family(fid)) tout << get_family_id(fid_name) << "\n";); - TRACE("copy_families_plugins", tout << "target fid: " << get_family_id(fid_name) << "\n";); - SASSERT(fid == get_family_id(fid_name)); - if (from.has_plugin(fid) && !has_plugin(fid)) { - decl_plugin * new_p = from.get_plugin(fid)->mk_fresh(); - register_plugin(fid, new_p); - SASSERT(new_p->get_family_id() == fid); - SASSERT(has_plugin(fid)); - } - if (from.has_plugin(fid)) { - get_plugin(fid)->inherit(from.get_plugin(fid), trans); - } - SASSERT(from.m_family_manager.has_family(fid) == m_family_manager.has_family(fid)); - SASSERT(from.get_family_id(fid_name) == get_family_id(fid_name)); - SASSERT(!from.has_plugin(fid) || has_plugin(fid)); + SASSERT(from.is_builtin_family_id(fid) == is_builtin_family_id(fid)); + SASSERT(!from.is_builtin_family_id(fid) || m_family_manager.has_family(fid)); + symbol fid_name = from.get_family_name(fid); + (void)fid_name; + TRACE("copy_families_plugins", tout << "copying: " << fid_name << ", src fid: " << fid + << ", target has_family: " << m_family_manager.has_family(fid) << "\n"; + if (m_family_manager.has_family(fid)) tout << get_family_id(fid_name) << "\n";); + TRACE("copy_families_plugins", tout << "target fid: " << get_family_id(fid_name) << "\n";); + SASSERT(fid == get_family_id(fid_name)); + if (from.has_plugin(fid) && !has_plugin(fid)) { + decl_plugin * new_p = from.get_plugin(fid)->mk_fresh(); + register_plugin(fid, new_p); + SASSERT(new_p->get_family_id() == fid); + SASSERT(has_plugin(fid)); + } + if (from.has_plugin(fid)) { + get_plugin(fid)->inherit(from.get_plugin(fid), trans); + } + SASSERT(from.m_family_manager.has_family(fid) == m_family_manager.has_family(fid)); + SASSERT(from.get_family_id(fid_name) == get_family_id(fid_name)); + SASSERT(!from.has_plugin(fid) || has_plugin(fid)); } } diff --git a/src/ast/ast_pp_util.cpp b/src/ast/ast_pp_util.cpp index 37785e072..23c9ebe51 100644 --- a/src/ast/ast_pp_util.cpp +++ b/src/ast/ast_pp_util.cpp @@ -46,13 +46,18 @@ void ast_pp_util::display_decls(std::ostream& out) { n = coll.get_num_decls(); for (unsigned i = 0; i < n; ++i) { func_decl* f = coll.get_func_decls()[i]; - if (f->get_family_id() == null_family_id) { + if (f->get_family_id() == null_family_id && !m_removed.contains(f)) { ast_smt2_pp(out, f, env); out << "\n"; } } } +void ast_pp_util::remove_decl(func_decl* f) { + m_removed.insert(f); +} + + void ast_pp_util::display_asserts(std::ostream& out, expr_ref_vector const& fmls, bool neat) { if (neat) { smt2_pp_environment_dbg env(m); diff --git a/src/ast/ast_pp_util.h b/src/ast/ast_pp_util.h index 964a862a2..1b2686511 100644 --- a/src/ast/ast_pp_util.h +++ b/src/ast/ast_pp_util.h @@ -20,9 +20,11 @@ Revision History: #define AST_PP_UTIL_H_ #include "ast/decl_collector.h" +#include "util/obj_hashtable.h" class ast_pp_util { ast_manager& m; + obj_hashtable m_removed; public: decl_collector coll; @@ -35,6 +37,8 @@ class ast_pp_util { void collect(expr_ref_vector const& es); + void remove_decl(func_decl* f); + void display_decls(std::ostream& out); void display_asserts(std::ostream& out, expr_ref_vector const& fmls, bool neat = true); diff --git a/src/muz/base/dl_context.cpp b/src/muz/base/dl_context.cpp index 47d7cc357..521cf0dc9 100644 --- a/src/muz/base/dl_context.cpp +++ b/src/muz/base/dl_context.cpp @@ -1106,6 +1106,16 @@ namespace datalog { names.push_back(m_rule_names[i]); } } + + static std::ostream& display_symbol(std::ostream& out, symbol const& nm) { + if (is_smt2_quoted_symbol(nm)) { + out << mk_smt2_quoted_symbol(nm); + } + else { + out << nm; + } + return out; + } void context::display_smt2(unsigned num_queries, expr* const* qs, std::ostream& out) { ast_manager& m = get_manager(); @@ -1148,13 +1158,13 @@ namespace datalog { if (!use_fixedpoint_extensions) { out << "(set-logic HORN)\n"; } + for (func_decl * f : rels) + visitor.remove_decl(f); visitor.display_decls(out); - func_decl_set::iterator it = rels.begin(), end = rels.end(); - for (; it != end; ++it) { - func_decl* f = *it; + + for (func_decl * f : rels) display_rel_decl(out, f); - } if (use_fixedpoint_extensions && do_declare_vars) { declare_vars(rules, fresh_names, out); @@ -1185,13 +1195,7 @@ namespace datalog { nm = symbol(s.str().c_str()); } fresh_names.add(nm); - if (is_smt2_quoted_symbol(nm)) { - out << mk_smt2_quoted_symbol(nm); - } - else { - out << nm; - } - out << ")"; + display_symbol(out, nm) << ")"; } out << ")\n"; } @@ -1219,7 +1223,8 @@ namespace datalog { PP(qfn); out << ")\n"; } - out << "(query " << fn->get_name() << ")\n"; + out << "(query "; + display_symbol(out, fn->get_name()) << ")\n"; } } else { @@ -1238,7 +1243,8 @@ namespace datalog { void context::display_rel_decl(std::ostream& out, func_decl* f) { smt2_pp_environment_dbg env(m); - out << "(declare-rel " << f->get_name() << " ("; + out << "(declare-rel "; + display_symbol(out, f->get_name()) << " ("; for (unsigned i = 0; i < f->get_arity(); ++i) { ast_smt2_pp(out, f->get_domain(i), env); if (i + 1 < f->get_arity()) { diff --git a/src/test/quant_elim.cpp b/src/test/quant_elim.cpp index 12fca706d..f376e2c1d 100644 --- a/src/test/quant_elim.cpp +++ b/src/test/quant_elim.cpp @@ -13,6 +13,7 @@ Copyright (c) 2015 Microsoft Corporation #include "ast/reg_decl_plugins.h" +#if 0 static void test_qe(ast_manager& m, lbool expected_outcome, expr* fml, char const* option) { // enable_trace("bit2int"); @@ -48,6 +49,7 @@ static void test_qe(ast_manager& m, lbool expected_outcome, expr* fml, char cons //exit(-1); } } +#endif static void test_formula(lbool expected_outcome, char const* fml) { ast_manager m; From a7caa2fd2a5b5d888956fcc0391ff034ce91b9b7 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Wed, 7 Mar 2018 18:16:11 -0500 Subject: [PATCH 216/263] remove useless get_assignments in theory_str final check --- src/smt/theory_str.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index b900f9368..e0f0909cc 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -8734,8 +8734,8 @@ namespace smt { context & ctx = get_context(); ast_manager & m = get_manager(); - expr_ref_vector assignments(m); - ctx.get_assignments(assignments); + //expr_ref_vector assignments(m); + //ctx.get_assignments(assignments); if (opt_VerifyFinalCheckProgress) { finalCheckProgressIndicator = false; From 02a969670124399e07c982b038cc861667e1b3ff Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 8 Mar 2018 11:19:00 -0500 Subject: [PATCH 217/263] fix #1521 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_arith_core.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index fe62efbf4..3393634b6 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -469,7 +469,8 @@ namespace smt { if (negated) l_conseq.neg(); TRACE("arith_axiom", tout << mk_pp(ante, m) << "\n" << mk_pp(conseq, m) << "\n"; - tout << s_ante << "\n" << s_conseq << "\n";); + tout << s_ante << "\n" << s_conseq << "\n"; + tout << l_ante << "\n" << l_conseq << "\n";); // literal lits[2] = {l_ante, l_conseq}; mk_clause(l_ante, l_conseq, 0, nullptr); @@ -589,13 +590,14 @@ namespace smt { } // - // create the term: s := to_real(to_int(x)) - x + // create the term: s := x - to_real(to_int(x)) // add the bounds 0 <= s < 1 // template void theory_arith::mk_to_int_axiom(app * n) { SASSERT(m_util.is_to_int(n)); - ast_manager & m = get_manager(); + ast_manager & m = get_manager(); + context & ctx = get_context(); expr* x = n->get_arg(0); // to_int (to_real x) = x @@ -603,11 +605,15 @@ namespace smt { mk_axiom(m.mk_false(), m.mk_eq(to_app(x)->get_arg(0), n)); return; } - expr* to_r = m_util.mk_to_real(n); - expr_ref lo(m_util.mk_le(to_r, x), m); - expr_ref hi(m_util.mk_lt(x, m_util.mk_add(to_r, m_util.mk_numeral(rational(1), false))), m); - mk_axiom(m.mk_false(), lo); - mk_axiom(m.mk_false(), hi); + expr_ref to_r(m_util.mk_to_real(n), m); + expr_ref diff(m_util.mk_add(x, m_util.mk_mul(m_util.mk_real(-1), to_r)), m); + + expr_ref lo(m_util.mk_ge(diff, m_util.mk_real(0)), m); + expr_ref hi(m_util.mk_ge(diff, m_util.mk_real(1)), m); + hi = m.mk_not(hi); + + mk_axiom(m.mk_false(), lo, false); + mk_axiom(m.mk_false(), hi, false); } template @@ -1202,7 +1208,7 @@ namespace smt { template bool theory_arith::internalize_atom(app * n, bool gate_ctx) { - TRACE("arith_internalize", tout << "internalising atom:\n" << mk_pp(n, this->get_manager()) << "\n";); + TRACE("arith_internalize", tout << "internalizing atom:\n" << mk_pp(n, this->get_manager()) << "\n";); context & ctx = get_context(); SASSERT(m_util.is_le(n) || m_util.is_ge(n) || m_util.is_is_int(n)); SASSERT(!ctx.b_internalized(n)); From bf6975122be10ec7d4e872a274bac525d33a03a9 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Thu, 8 Mar 2018 12:37:44 -0500 Subject: [PATCH 218/263] integrate contains and indexof in theory_str --- src/smt/theory_str.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index cb4a11c89..9dfd0475b 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -1284,6 +1284,21 @@ namespace smt { expr_ref finalAxiom(m.mk_and(breakdownAssert, reduceToIndex), m); SASSERT(finalAxiom); assert_axiom(finalAxiom); + + { + // heuristic: integrate with str.contains information + // (but don't introduce it if it isn't already in the instance) + expr_ref haystack(ex->get_arg(0), m), needle(ex->get_arg(1), m), startIdx(ex->get_arg(2), m); + expr_ref zeroAst(mk_int(0), m); + // (H contains N) <==> (H indexof N, i) >= 0 + expr_ref premise(u.str.mk_contains(haystack, needle), m); + ctx.internalize(premise, false); + expr_ref conclusion(m_autil.mk_ge(ex, zeroAst), m); + expr_ref containsAxiom(ctx.mk_eq_atom(premise, conclusion), m); + SASSERT(containsAxiom); + // we can't assert this during init_search as it breaks an invariant if the instance becomes inconsistent + m_delayed_axiom_setup_terms.push_back(containsAxiom); + } } void theory_str::instantiate_axiom_Indexof_extended(enode * e) { @@ -1353,6 +1368,20 @@ namespace smt { expr_ref reduceTerm(ctx.mk_eq_atom(expr, resAst), m); SASSERT(reduceTerm); assert_axiom(reduceTerm); + + { + // heuristic: integrate with str.contains information + // (but don't introduce it if it isn't already in the instance) + expr_ref haystack(expr->get_arg(0), m), needle(expr->get_arg(1), m), startIdx(expr->get_arg(2), m); + // (H contains N) <==> (H indexof N, i) >= 0 + expr_ref premise(u.str.mk_contains(haystack, needle), m); + ctx.internalize(premise, false); + expr_ref conclusion(m_autil.mk_ge(expr, zeroAst), m); + expr_ref containsAxiom(ctx.mk_eq_atom(premise, conclusion), m); + SASSERT(containsAxiom); + // we can't assert this during init_search as it breaks an invariant if the instance becomes inconsistent + m_delayed_axiom_setup_terms.push_back(containsAxiom); + } } void theory_str::instantiate_axiom_LastIndexof(enode * e) { From 878a6ca14ffd1eb9f1b26083ebb16533019cca2f Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Fri, 9 Mar 2018 14:29:22 +0700 Subject: [PATCH 219/263] Fix typos. --- CMakeLists.txt | 2 +- scripts/mk_consts_files.py | 2 +- src/api/c++/z3++.h | 2 +- src/api/dotnet/Context.cs | 10 +++++----- src/api/java/Context.java | 10 +++++----- src/api/python/z3/z3.py | 12 ++++++------ src/api/z3_fpa.h | 8 ++++---- src/api/z3_interp.h | 4 ++-- src/ast/rewriter/rewriter_def.h | 2 +- src/interp/iz3checker.cpp | 2 +- src/muz/base/fixedpoint_params.pyg | 8 ++++---- src/muz/transforms/dl_mk_array_instantiation.h | 2 +- src/muz/transforms/dl_mk_interp_tail_simplifier.h | 2 +- src/muz/transforms/dl_mk_rule_inliner.h | 2 +- src/muz/transforms/dl_mk_scale.h | 2 +- src/tactic/aig/aig.cpp | 2 +- src/tactic/tactic_exception.h | 2 +- src/tactic/tactical.h | 2 +- 18 files changed, 38 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69a0ca123..7bc60e135 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -434,7 +434,7 @@ else() endif() ################################################################################ -# Postion independent code +# Position independent code ################################################################################ # This is required because code built in the components will end up in a shared # library. If not building a shared library ``-fPIC`` isn't needed and would add diff --git a/scripts/mk_consts_files.py b/scripts/mk_consts_files.py index d0502c19d..39d4e9439 100755 --- a/scripts/mk_consts_files.py +++ b/scripts/mk_consts_files.py @@ -72,7 +72,7 @@ def main(args): if count == 0: logging.info('No files generated. You need to specific an output directory' - ' for the relevant langauge bindings') + ' for the relevant language bindings') # TODO: Add support for other bindings return 0 diff --git a/src/api/c++/z3++.h b/src/api/c++/z3++.h index 49f6cfbf3..42467cb22 100644 --- a/src/api/c++/z3++.h +++ b/src/api/c++/z3++.h @@ -989,7 +989,7 @@ namespace z3 { /** \brief sequence and regular expression operations. - + is overloaeded as sequence concatenation and regular expression union. + + is overloaded as sequence concatenation and regular expression union. concat is overloaded to handle sequences and regular expressions */ expr extract(expr const& offset, expr const& length) const { diff --git a/src/api/dotnet/Context.cs b/src/api/dotnet/Context.cs index cbd6a1bac..b3b24a6d1 100644 --- a/src/api/dotnet/Context.cs +++ b/src/api/dotnet/Context.cs @@ -2515,7 +2515,7 @@ namespace Microsoft.Z3 /// - /// Concatentate sequences. + /// Concatenate sequences. /// public SeqExpr MkConcat(params SeqExpr[] t) { @@ -3597,7 +3597,7 @@ namespace Microsoft.Z3 } /// - /// Create a tactic that fails if the goal is not triviall satisfiable (i.e., empty) + /// Create a tactic that fails if the goal is not trivially satisfiable (i.e., empty) /// or trivially unsatisfiable (i.e., contains `false'). /// public Tactic FailIfNotDecided() @@ -4656,7 +4656,7 @@ namespace Microsoft.Z3 /// Conversion of a floating-point term into a bit-vector. ///
/// - /// Produces a term that represents the conversion of the floating-poiunt term t into a + /// Produces a term that represents the conversion of the floating-point term t into a /// bit-vector term of size sz in 2's complement format (signed when signed==true). If necessary, /// the result will be rounded according to rounding mode rm. /// @@ -4677,7 +4677,7 @@ namespace Microsoft.Z3 /// Conversion of a floating-point term into a real-numbered term. /// /// - /// Produces a term that represents the conversion of the floating-poiunt term t into a + /// Produces a term that represents the conversion of the floating-point term t into a /// real number. Note that this type of conversion will often result in non-linear /// constraints over real terms. /// @@ -4696,7 +4696,7 @@ namespace Microsoft.Z3 /// /// The size of the resulting bit-vector is automatically determined. Note that /// IEEE 754-2008 allows multiple different representations of NaN. This conversion - /// knows only one NaN and it will always produce the same bit-vector represenatation of + /// knows only one NaN and it will always produce the same bit-vector representation of /// that NaN. /// /// FloatingPoint term. diff --git a/src/api/java/Context.java b/src/api/java/Context.java index ba96209b3..3c5caadee 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -1978,7 +1978,7 @@ public class Context implements AutoCloseable { } /** - * Concatentate sequences. + * Concatenate sequences. */ public SeqExpr mkConcat(SeqExpr... t) { @@ -2781,7 +2781,7 @@ public class Context implements AutoCloseable { } /** - * Create a tactic that fails if the goal is not triviall satisfiable (i.e., + * Create a tactic that fails if the goal is not trivially satisfiable (i.e., * empty) or trivially unsatisfiable (i.e., contains `false'). **/ public Tactic failIfNotDecided() @@ -3769,7 +3769,7 @@ public class Context implements AutoCloseable { * @param sz Size of the resulting bit-vector. * @param signed Indicates whether the result is a signed or unsigned bit-vector. * Remarks: - * Produces a term that represents the conversion of the floating-poiunt term t into a + * Produces a term that represents the conversion of the floating-point term t into a * bit-vector term of size sz in 2's complement format (signed when signed==true). If necessary, * the result will be rounded according to rounding mode rm. * @throws Z3Exception @@ -3786,7 +3786,7 @@ public class Context implements AutoCloseable { * Conversion of a floating-point term into a real-numbered term. * @param t FloatingPoint term * Remarks: - * Produces a term that represents the conversion of the floating-poiunt term t into a + * Produces a term that represents the conversion of the floating-point term t into a * real number. Note that this type of conversion will often result in non-linear * constraints over real terms. * @throws Z3Exception @@ -3802,7 +3802,7 @@ public class Context implements AutoCloseable { * Remarks: * The size of the resulting bit-vector is automatically determined. Note that * IEEE 754-2008 allows multiple different representations of NaN. This conversion - * knows only one NaN and it will always produce the same bit-vector represenatation of + * knows only one NaN and it will always produce the same bit-vector representation of * that NaN. * @throws Z3Exception **/ diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 1cfb10179..e68d7280d 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -2428,7 +2428,7 @@ def is_rational_value(a): return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast()) def is_algebraic_value(a): - """Return `True` if `a` is an algerbraic value of sort Real. + """Return `True` if `a` is an algebraic value of sort Real. >>> is_algebraic_value(RealVal("3/5")) False @@ -4437,7 +4437,7 @@ class Datatype: """Declare constructor named `name` with the given accessors `args`. Each accessor is a pair `(name, sort)`, where `name` is a string and `sort` a Z3 sort or a reference to the datatypes being declared. - In the followin example `List.declare('cons', ('car', IntSort()), ('cdr', List))` + In the following example `List.declare('cons', ('car', IntSort()), ('cdr', List))` declares the constructor named `cons` that builds a new List using an integer and a List. It also declares the accessors `car` and `cdr`. The accessor `car` extracts the integer of a `cons` cell, and `cdr` the list of a `cons` cell. After all constructors were declared, we use the method create() to create @@ -4457,7 +4457,7 @@ class Datatype: return "Datatype(%s, %s)" % (self.name, self.constructors) def create(self): - """Create a Z3 datatype based on the constructors declared using the mehtod `declare()`. + """Create a Z3 datatype based on the constructors declared using the method `declare()`. The function `CreateDatatypes()` must be used to define mutually recursive datatypes. @@ -8874,7 +8874,7 @@ class FPNumRef(FPRef): def isSubnormal(self): return Z3_fpa_is_numeral_subnormal(self.ctx.ref(), self.as_ast()) - """Indicates whether the numeral is postitive.""" + """Indicates whether the numeral is positive.""" def isPositive(self): return Z3_fpa_is_numeral_positive(self.ctx.ref(), self.as_ast()) @@ -9670,7 +9670,7 @@ def fpToIEEEBV(x, ctx=None): The size of the resulting bit-vector is automatically determined. Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion - knows only one NaN and it will always produce the same bit-vector represenatation of + knows only one NaN and it will always produce the same bit-vector representation of that NaN. >>> x = FP('x', FPSort(8, 24)) @@ -9845,7 +9845,7 @@ def Empty(s): raise Z3Exception("Non-sequence, non-regular expression sort passed to Empty") def Full(s): - """Create the regular expression that accepts the universal langauge + """Create the regular expression that accepts the universal language >>> e = Full(ReSort(SeqSort(IntSort()))) >>> print(e) re.all diff --git a/src/api/z3_fpa.h b/src/api/z3_fpa.h index 358a3c619..7d237c6e7 100644 --- a/src/api/z3_fpa.h +++ b/src/api/z3_fpa.h @@ -756,7 +756,7 @@ extern "C" { /** \brief Conversion of a floating-point term into an unsigned bit-vector. - Produces a term that represents the conversion of the floating-poiunt term t into a + Produces a term that represents the conversion of the floating-point term t into a bit-vector term of size sz in unsigned 2's complement format. If necessary, the result will be rounded according to rounding mode rm. @@ -772,7 +772,7 @@ extern "C" { /** \brief Conversion of a floating-point term into a signed bit-vector. - Produces a term that represents the conversion of the floating-poiunt term t into a + Produces a term that represents the conversion of the floating-point term t into a bit-vector term of size sz in signed 2's complement format. If necessary, the result will be rounded according to rounding mode rm. @@ -788,7 +788,7 @@ extern "C" { /** \brief Conversion of a floating-point term into a real-numbered term. - Produces a term that represents the conversion of the floating-poiunt term t into a + Produces a term that represents the conversion of the floating-point term t into a real number. Note that this type of conversion will often result in non-linear constraints over real terms. @@ -1011,7 +1011,7 @@ extern "C" { determined. Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion - knows only one NaN and it will always produce the same bit-vector represenatation of + knows only one NaN and it will always produce the same bit-vector representation of that NaN. def_API('Z3_mk_fpa_to_ieee_bv', AST, (_in(CONTEXT),_in(AST))) diff --git a/src/api/z3_interp.h b/src/api/z3_interp.h index bcee0e22d..2441d4339 100644 --- a/src/api/z3_interp.h +++ b/src/api/z3_interp.h @@ -98,7 +98,7 @@ extern "C" { Interpolant may not necessarily be computable from all proofs. To be sure an interpolant can be computed, the proof - must be generated by an SMT solver for which interpoaltion is + must be generated by an SMT solver for which interpolation is supported, and the premises must be expressed using only theories and operators for which interpolation is supported. @@ -199,7 +199,7 @@ extern "C" { (implies (and c1 ... cn f) v) where c1 .. cn are the children of v (which must precede v in the file) - and f is the formula assiciated to node v. The last formula in the + and f is the formula associated to node v. The last formula in the file is the root vertex, and is represented by the predicate "false". A solution to a tree interpolation problem can be thought of as a diff --git a/src/ast/rewriter/rewriter_def.h b/src/ast/rewriter/rewriter_def.h index 658fb2e05..878f4ef4c 100644 --- a/src/ast/rewriter/rewriter_def.h +++ b/src/ast/rewriter/rewriter_def.h @@ -358,7 +358,7 @@ void rewriter_tpl::process_app(app * t, frame & fr) { if (ProofGen) { NOT_IMPLEMENTED_YET(); // We do not support the use of bindings in proof generation mode. - // Thus we have to apply the subsitution here, and + // Thus we have to apply the substitution here, and // beta_reducer subst(m()); // subst.set_bindings(new_num_args, new_args); // expr_ref r2(m()); diff --git a/src/interp/iz3checker.cpp b/src/interp/iz3checker.cpp index cfea511ad..511342819 100644 --- a/src/interp/iz3checker.cpp +++ b/src/interp/iz3checker.cpp @@ -43,7 +43,7 @@ struct iz3checker : iz3base { /* HACK: for tree interpolants, we assume that uninterpreted functions are global. This is because in the current state of the tree interpolation code, symbols that appear in sibling sub-trees have to be global, and - we have no way to eliminate such function symbols. When tree interpoaltion is + we have no way to eliminate such function symbols. When tree interpolation is fixed, we can tree function symbols the same as constant symbols. */ bool is_tree; diff --git a/src/muz/base/fixedpoint_params.pyg b/src/muz/base/fixedpoint_params.pyg index 0c2f03460..753a45e06 100644 --- a/src/muz/base/fixedpoint_params.pyg +++ b/src/muz/base/fixedpoint_params.pyg @@ -33,7 +33,7 @@ def_module_params('fixedpoint', "updated relation was modified or not"), ('datalog.compile_with_widening', BOOL, False, "widening will be used to compile recursive rules"), - ('datalog.default_table_checked', BOOL, False, "if true, the detault " + + ('datalog.default_table_checked', BOOL, False, "if true, the default " + 'table will be default_table inside a wrapper that checks that its results ' + 'are the same as of default_table_checker table'), ('datalog.default_table_checker', SYMBOL, 'null', "see default_table_checked"), @@ -59,7 +59,7 @@ def_module_params('fixedpoint', ('duality.full_expand', BOOL, False, 'Fully expand derivation trees'), ('duality.no_conj', BOOL, False, 'No forced covering (conjectures)'), ('duality.feasible_edges', BOOL, True, - 'Don\'t expand definitley infeasible edges'), + 'Don\'t expand definitely infeasible edges'), ('duality.use_underapprox', BOOL, False, 'Use underapproximations'), ('duality.stratified_inlining', BOOL, False, 'Use stratified inlining'), ('duality.recursion_bound', UINT, UINT_MAX, @@ -130,7 +130,7 @@ def_module_params('fixedpoint', ('xform.magic', BOOL, False, "perform symbolic magic set transformation"), ('xform.scale', BOOL, False, - "add scaling variable to linear real arithemtic clauses"), + "add scaling variable to linear real arithmetic clauses"), ('xform.inline_linear', BOOL, True, "try linear inlining method"), ('xform.inline_eager', BOOL, True, "try eager inlining of rules"), ('xform.inline_linear_branch', BOOL, False, @@ -176,7 +176,7 @@ def_module_params('fixedpoint', ('spacer.elim_aux', BOOL, True, "Eliminate auxiliary variables in reachability facts"), ('spacer.reach_as_init', BOOL, True, "Extend initial rules with computed reachability facts"), ('spacer.blast_term_ite', BOOL, True, "Expand non-Boolean ite-terms"), - ('spacer.nondet_tie_break', BOOL, False, "Break ties in obligation queue non-deterministicly"), + ('spacer.nondet_tie_break', BOOL, False, "Break ties in obligation queue non-deterministically"), ('spacer.reach_dnf', BOOL, True, "Restrict reachability facts to DNF"), ('bmc.linear_unrolling_depth', UINT, UINT_MAX, "Maximal level to explore"), ('spacer.split_farkas_literals', BOOL, False, "Split Farkas literals"), diff --git a/src/muz/transforms/dl_mk_array_instantiation.h b/src/muz/transforms/dl_mk_array_instantiation.h index cd5715a4f..b2e80ab84 100644 --- a/src/muz/transforms/dl_mk_array_instantiation.h +++ b/src/muz/transforms/dl_mk_array_instantiation.h @@ -26,7 +26,7 @@ Implementation: 1) Dealing with multiple quantifiers -> The options fixedpoint.xform.instantiate_arrays.nb_quantifier gives the number of quantifiers per array. - 2) Inforcing the instantiation -> We suggest an option (enforce_instantiation) to enforce this abstraction. This transforms + 2) Enforcing the instantiation -> We suggest an option (enforce_instantiation) to enforce this abstraction. This transforms P(a) into P(i, a[i]). This enforces the solver to limit the space search at the cost of imprecise results. This option corresponds to fixedpoint.xform.instantiate_arrays.enforce diff --git a/src/muz/transforms/dl_mk_interp_tail_simplifier.h b/src/muz/transforms/dl_mk_interp_tail_simplifier.h index 713827588..0d4c65d11 100644 --- a/src/muz/transforms/dl_mk_interp_tail_simplifier.h +++ b/src/muz/transforms/dl_mk_interp_tail_simplifier.h @@ -53,7 +53,7 @@ namespace datalog { */ void reset(rule * r); - /** Reset subtitution and unify tail tgt_idx of the target rule and the head of the src rule */ + /** Reset substitution and unify tail tgt_idx of the target rule and the head of the src rule */ bool unify(expr * e1, expr * e2); void get_result(rule_ref & res); diff --git a/src/muz/transforms/dl_mk_rule_inliner.h b/src/muz/transforms/dl_mk_rule_inliner.h index 27b6dd418..9146343fa 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.h +++ b/src/muz/transforms/dl_mk_rule_inliner.h @@ -45,7 +45,7 @@ namespace datalog { : m(ctx.get_manager()), m_rm(ctx.get_rule_manager()), m_context(ctx), m_interp_simplifier(ctx), m_subst(m), m_unif(m), m_ready(false), m_normalize(true) {} - /** Reset subtitution and unify tail tgt_idx of the target rule and the head of the src rule */ + /** Reset substitution and unify tail tgt_idx of the target rule and the head of the src rule */ bool unify_rules(rule const& tgt, unsigned tgt_idx, rule const& src); /** diff --git a/src/muz/transforms/dl_mk_scale.h b/src/muz/transforms/dl_mk_scale.h index c171a1d06..94090ec93 100644 --- a/src/muz/transforms/dl_mk_scale.h +++ b/src/muz/transforms/dl_mk_scale.h @@ -7,7 +7,7 @@ Module Name: Abstract: - Add scale factor to linear (Real) arithemetic Horn clauses. + Add scale factor to linear (Real) arithmetic Horn clauses. The transformation replaces occurrences of isolated constants by a scale multiplied to each constant. diff --git a/src/tactic/aig/aig.cpp b/src/tactic/aig/aig.cpp index 40c68f72a..6afac32b8 100644 --- a/src/tactic/aig/aig.cpp +++ b/src/tactic/aig/aig.cpp @@ -267,7 +267,7 @@ struct aig_manager::imp { } if (b == r) { if (sign1) { - // subsitution + // substitution // not (a and b) and r --> (not a) and r IF b == r l = a; l.invert(); diff --git a/src/tactic/tactic_exception.h b/src/tactic/tactic_exception.h index 177524726..bdf2636a9 100644 --- a/src/tactic/tactic_exception.h +++ b/src/tactic/tactic_exception.h @@ -7,7 +7,7 @@ Module Name: Abstract: - Tactic expection object. + Tactic exception object. Author: diff --git a/src/tactic/tactical.h b/src/tactic/tactical.h index 169566f39..9ec2f901f 100644 --- a/src/tactic/tactical.h +++ b/src/tactic/tactical.h @@ -47,7 +47,7 @@ tactic * or_else(tactic * t1, tactic * t2, tactic * t3, tactic * t4, tactic * t5 tactic * repeat(tactic * t, unsigned max = UINT_MAX); /** - \brief Fails if \c t produeces more than \c threshold subgoals. + \brief Fails if \c t produces more than \c threshold subgoals. Otherwise, it behaves like \c t. */ tactic * fail_if_branching(tactic * t, unsigned threshold = 1); From ba603307fcb39cdc12a6d0283ddc9632ca436478 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 9 Mar 2018 05:32:01 -0500 Subject: [PATCH 220/263] remove stale deprecated annotation #1525 Signed-off-by: Nikolaj Bjorner --- src/api/z3_api.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 500533e91..f7c218963 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1477,7 +1477,6 @@ extern "C" { /*@{*/ /** - \deprecated \brief Create a configuration object for the Z3 context object. Configurations are created in order to assign parameters prior to creating @@ -1510,7 +1509,6 @@ extern "C" { Z3_config Z3_API Z3_mk_config(void); /** - \deprecated \brief Delete the given configuration object. \sa Z3_mk_config @@ -1520,7 +1518,6 @@ extern "C" { void Z3_API Z3_del_config(Z3_config c); /** - \deprecated \brief Set a configuration parameter. The following parameters can be set for @@ -1537,7 +1534,6 @@ extern "C" { /*@{*/ /** - \deprecated \brief Create a context using the given configuration. After a context is created, the configuration cannot be changed, @@ -1617,7 +1613,6 @@ extern "C" { void Z3_API Z3_dec_ref(Z3_context c, Z3_ast a); /** - \deprecated \brief Set a value of a context parameter. \sa Z3_global_param_set From ae165a539e476a032f83ce252582f7b94b644e20 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 9 Mar 2018 14:20:31 +0100 Subject: [PATCH 221/263] Fix parameter expansion when configuring Z3 --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 29408d3e7..807fba392 100755 --- a/configure +++ b/configure @@ -14,4 +14,4 @@ if ! $PYTHON -c "print('testing')" > /dev/null ; then exit 1 fi -$PYTHON scripts/mk_make.py $* +$PYTHON scripts/mk_make.py "$@" From e5a19816943fd1fdf3c93ff0ac7dfe1871fc1807 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 9 Mar 2018 15:40:35 -0500 Subject: [PATCH 222/263] disable GCC flag change to see if this affects build Signed-off-by: Nikolaj Bjorner --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f20c4fb10..62045016a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -410,17 +410,17 @@ list(APPEND Z3_DEPENDENT_LIBS ${CMAKE_THREAD_LIBS_INIT}) include(${CMAKE_SOURCE_DIR}/cmake/compiler_warnings.cmake) ################################################################################ -# If using Ninja, force color output for Clang and gcc. +# If using Ninja, force color output for Clang (and gcc, disabled to check build). ################################################################################ if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics") endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color") - endif() +# if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color") +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color") +# endif() endif() ################################################################################ From 6e87622c8a770c497cafbf972dbd96eaa34eb67c Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 10 Mar 2018 13:55:01 -0500 Subject: [PATCH 223/263] remove references to deprecated uses of PROOF_MODE #1531 Signed-off-by: Nikolaj Bjorner --- src/api/api_ast.cpp | 3 -- src/api/dotnet/Expr.cs | 38 +---------------- src/api/java/Expr.java | 55 ++----------------------- src/api/z3_api.h | 23 +---------- src/ast/ast.cpp | 31 -------------- src/ast/ast.h | 11 ++--- src/ast/proofs/proof_checker.cpp | 27 ------------ src/smt/theory_arith_core.h | 1 - src/smt/theory_str.cpp | 2 + src/tactic/core/ctx_simplify_tactic.cpp | 2 +- src/tactic/core/dom_simplify_tactic.cpp | 4 +- 11 files changed, 16 insertions(+), 181 deletions(-) diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 3f5a0fcf1..1f4a86903 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -919,7 +919,6 @@ extern "C" { case PR_REWRITE: return Z3_OP_PR_REWRITE; case PR_REWRITE_STAR: return Z3_OP_PR_REWRITE_STAR; case PR_PULL_QUANT: return Z3_OP_PR_PULL_QUANT; - case PR_PULL_QUANT_STAR: return Z3_OP_PR_PULL_QUANT_STAR; case PR_PUSH_QUANT: return Z3_OP_PR_PUSH_QUANT; case PR_ELIM_UNUSED_VARS: return Z3_OP_PR_ELIM_UNUSED_VARS; case PR_DER: return Z3_OP_PR_DER; @@ -936,9 +935,7 @@ extern "C" { case PR_IFF_OEQ: return Z3_OP_PR_IFF_OEQ; case PR_NNF_POS: return Z3_OP_PR_NNF_POS; case PR_NNF_NEG: return Z3_OP_PR_NNF_NEG; - case PR_NNF_STAR: return Z3_OP_PR_NNF_STAR; case PR_SKOLEMIZE: return Z3_OP_PR_SKOLEMIZE; - case PR_CNF_STAR: return Z3_OP_PR_CNF_STAR; case PR_MODUS_PONENS_OEQ: return Z3_OP_PR_MODUS_PONENS_OEQ; case PR_TH_LEMMA: return Z3_OP_PR_TH_LEMMA; case PR_HYPER_RESOLVE: return Z3_OP_PR_HYPER_RESOLVE; diff --git a/src/api/dotnet/Expr.cs b/src/api/dotnet/Expr.cs index 0726f9d53..9310d1e7d 100644 --- a/src/api/dotnet/Expr.cs +++ b/src/api/dotnet/Expr.cs @@ -932,7 +932,7 @@ namespace Microsoft.Z3 /// Indicates whether the term is a proof by condensed transitivity of a relation /// /// - /// Condensed transitivity proof. This proof object is only used if the parameter PROOF_MODE is 1. + /// Condensed transitivity proof. /// It combines several symmetry and transitivity proofs. /// Example: /// T1: (R a b) @@ -1035,14 +1035,11 @@ namespace Microsoft.Z3 /// /// /// A proof for rewriting an expression t into an expression s. - /// This proof object is used if the parameter PROOF_MODE is 1. /// This proof object can have n antecedents. /// The antecedents are proofs for equalities used as substitution rules. - /// The object is also used in a few cases if the parameter PROOF_MODE is 2. - /// The cases are: + /// The object is used in a few cases: /// - When applying contextual simplification (CONTEXT_SIMPLIFIER=true) /// - When converting bit-vectors to Booleans (BIT2BOOL=true) - /// - When pulling ite expression up (PULL_CHEAP_ITE_TREES=true) /// public bool IsProofRewriteStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR; } } @@ -1054,15 +1051,6 @@ namespace Microsoft.Z3 /// public bool IsProofPullQuant { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT; } } - /// - /// Indicates whether the term is a proof for pulling quantifiers out. - /// - /// - /// A proof for (iff P Q) where Q is in prenex normal form. - /// This proof object is only used if the parameter PROOF_MODE is 1. - /// This proof object has no antecedents - /// - public bool IsProofPullQuantStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; } } /// /// Indicates whether the term is a proof for pushing quantifiers in. @@ -1304,28 +1292,6 @@ namespace Microsoft.Z3 /// public bool IsProofNNFNeg { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_NEG; } } - /// - /// Indicates whether the term is a proof for (~ P Q) here Q is in negation normal form. - /// - /// - /// A proof for (~ P Q) where Q is in negation normal form. - /// - /// This proof object is only used if the parameter PROOF_MODE is 1. - /// - /// This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. - /// - public bool IsProofNNFStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_STAR; } } - - /// - /// Indicates whether the term is a proof for (~ P Q) where Q is in conjunctive normal form. - /// - /// - /// A proof for (~ P Q) where Q is in conjunctive normal form. - /// This proof object is only used if the parameter PROOF_MODE is 1. - /// This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. - /// - public bool IsProofCNFStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_CNF_STAR; } } - /// /// Indicates whether the term is a proof for a Skolemization step /// diff --git a/src/api/java/Expr.java b/src/api/java/Expr.java index 7b20b7993..db5c33e79 100644 --- a/src/api/java/Expr.java +++ b/src/api/java/Expr.java @@ -1398,8 +1398,7 @@ public class Expr extends AST /** * Indicates whether the term is a proof by condensed transitivity of a * relation - * Remarks: Condensed transitivity proof. This proof object is - * only used if the parameter PROOF_MODE is 1. It combines several symmetry + * Remarks: Condensed transitivity proof. It combines several symmetry * and transitivity proofs. Example: T1: (R a b) T2: (R c b) T3: (R c d) * [trans* T1 T2 T3]: (R a d) R must be a symmetric and transitive relation. * @@ -1506,14 +1505,11 @@ public class Expr extends AST /** * Indicates whether the term is a proof by rewriting * Remarks: A proof for - * rewriting an expression t into an expression s. This proof object is used - * if the parameter PROOF_MODE is 1. This proof object can have n + * rewriting an expression t into an expression s. This proof object can have n * antecedents. The antecedents are proofs for equalities used as - * substitution rules. The object is also used in a few cases if the - * parameter PROOF_MODE is 2. The cases are: - When applying contextual + * substitution rules. The object is used in a few cases . The cases are: - When applying contextual * simplification (CONTEXT_SIMPLIFIER=true) - When converting bit-vectors to - * Booleans (BIT2BOOL=true) - When pulling ite expression up - * (PULL_CHEAP_ITE_TREES=true) + * Booleans (BIT2BOOL=true) * @throws Z3Exception on error * @return a boolean **/ @@ -1534,17 +1530,6 @@ public class Expr extends AST return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT; } - /** - * Indicates whether the term is a proof for pulling quantifiers out. - * - * Remarks: A proof for (iff P Q) where Q is in prenex normal form. This * proof object is only used if the parameter PROOF_MODE is 1. This proof * object has no antecedents - * @throws Z3Exception on error - * @return a boolean - **/ - public boolean isProofPullQuantStar() - { - return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; - } /** * Indicates whether the term is a proof for pushing quantifiers in. @@ -1804,38 +1789,6 @@ public class Expr extends AST return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_NEG; } - /** - * Indicates whether the term is a proof for (~ P Q) here Q is in negation - * normal form. - * Remarks: A proof for (~ P Q) where Q is in negation normal - * form. - * - * This proof object is only used if the parameter PROOF_MODE is 1. - * - * This proof object may have n antecedents. Each antecedent is a - * PR_DEF_INTRO. - * @throws Z3Exception on error - * @return a boolean - **/ - public boolean isProofNNFStar() - { - return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_NNF_STAR; - } - - /** - * Indicates whether the term is a proof for (~ P Q) where Q is in - * conjunctive normal form. - * Remarks: A proof for (~ P Q) where Q is in - * conjunctive normal form. This proof object is only used if the parameter - * PROOF_MODE is 1. This proof object may have n antecedents. Each - * antecedent is a PR_DEF_INTRO. - * @throws Z3Exception on error - * @return a boolean - **/ - public boolean isProofCNFStar() - { - return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_PR_CNF_STAR; - } /** * Indicates whether the term is a proof for a Skolemization step diff --git a/src/api/z3_api.h b/src/api/z3_api.h index f7c218963..88d6aa1cf 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -459,7 +459,7 @@ typedef enum [trans T1 T2]: (R t u) } - - Z3_OP_PR_TRANSITIVITY_STAR: Condensed transitivity proof. This proof object is only used if the parameter PROOF_MODE is 1. + - Z3_OP_PR_TRANSITIVITY_STAR: Condensed transitivity proof. It combines several symmetry and transitivity proofs. Example: @@ -539,21 +539,14 @@ typedef enum } - Z3_OP_PR_REWRITE_STAR: A proof for rewriting an expression t into an expression s. - This proof object is used if the parameter PROOF_MODE is 1. This proof object can have n antecedents. The antecedents are proofs for equalities used as substitution rules. - The object is also used in a few cases if the parameter PROOF_MODE is 2. - The cases are: + The proof rule is used in a few cases. The cases are: - When applying contextual simplification (CONTEXT_SIMPLIFIER=true) - When converting bit-vectors to Booleans (BIT2BOOL=true) - - When pulling ite expression up (PULL_CHEAP_ITE_TREES=true) - Z3_OP_PR_PULL_QUANT: A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) r))). This proof object has no antecedents. - - Z3_OP_PR_PULL_QUANT_STAR: A proof for (iff P Q) where Q is in prenex normal form. - This proof object is only used if the parameter PROOF_MODE is 1. - This proof object has no antecedents. - - Z3_OP_PR_PUSH_QUANT: A proof for: \nicebox{ @@ -726,15 +719,6 @@ typedef enum [nnf-neg T1 T2 T3 T4]: (~ (not (iff s_1 s_2)) (and (or r_1 r_2) (or r_1' r_2'))) } - - Z3_OP_PR_NNF_STAR: A proof for (~ P Q) where Q is in negation normal form. - - This proof object is only used if the parameter PROOF_MODE is 1. - - This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. - - - Z3_OP_PR_CNF_STAR: A proof for (~ P Q) where Q is in conjunctive normal form. - This proof object is only used if the parameter PROOF_MODE is 1. - This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. - Z3_OP_PR_SKOLEMIZE: Proof for: @@ -1142,7 +1126,6 @@ typedef enum { Z3_OP_PR_REWRITE, Z3_OP_PR_REWRITE_STAR, Z3_OP_PR_PULL_QUANT, - Z3_OP_PR_PULL_QUANT_STAR, Z3_OP_PR_PUSH_QUANT, Z3_OP_PR_ELIM_UNUSED_VARS, Z3_OP_PR_DER, @@ -1159,8 +1142,6 @@ typedef enum { Z3_OP_PR_IFF_OEQ, Z3_OP_PR_NNF_POS, Z3_OP_PR_NNF_NEG, - Z3_OP_PR_NNF_STAR, - Z3_OP_PR_CNF_STAR, Z3_OP_PR_SKOLEMIZE, Z3_OP_PR_MODUS_PONENS_OEQ, Z3_OP_PR_TH_LEMMA, diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 127967374..7e143e1a3 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -663,7 +663,6 @@ basic_decl_plugin::basic_decl_plugin(): m_not_or_elim_decl(nullptr), m_rewrite_decl(nullptr), m_pull_quant_decl(nullptr), - m_pull_quant_star_decl(nullptr), m_push_quant_decl(nullptr), m_elim_unused_vars_decl(nullptr), m_der_decl(nullptr), @@ -827,7 +826,6 @@ func_decl * basic_decl_plugin::mk_proof_decl(basic_op_kind k, unsigned num_paren case PR_REWRITE: return mk_proof_decl("rewrite", k, 0, m_rewrite_decl); case PR_REWRITE_STAR: return mk_proof_decl("rewrite*", k, num_parents, m_rewrite_star_decls); case PR_PULL_QUANT: return mk_proof_decl("pull-quant", k, 0, m_pull_quant_decl); - case PR_PULL_QUANT_STAR: return mk_proof_decl("pull-quant*", k, 0, m_pull_quant_star_decl); case PR_PUSH_QUANT: return mk_proof_decl("push-quant", k, 0, m_push_quant_decl); case PR_ELIM_UNUSED_VARS: return mk_proof_decl("elim-unused", k, 0, m_elim_unused_vars_decl); case PR_DER: return mk_proof_decl("der", k, 0, m_der_decl); @@ -844,8 +842,6 @@ func_decl * basic_decl_plugin::mk_proof_decl(basic_op_kind k, unsigned num_paren case PR_IFF_OEQ: return mk_proof_decl("iff~", k, 1, m_iff_oeq_decl); case PR_NNF_POS: return mk_proof_decl("nnf-pos", k, num_parents, m_nnf_pos_decls); case PR_NNF_NEG: return mk_proof_decl("nnf-neg", k, num_parents, m_nnf_neg_decls); - case PR_NNF_STAR: return mk_proof_decl("nnf*", k, num_parents, m_nnf_star_decls); - case PR_CNF_STAR: return mk_proof_decl("cnf*", k, num_parents, m_cnf_star_decls); case PR_SKOLEMIZE: return mk_proof_decl("sk", k, 0, m_skolemize_decl); case PR_MODUS_PONENS_OEQ: return mk_proof_decl("mp~", k, 2, m_mp_oeq_decl); case PR_TH_LEMMA: return mk_proof_decl("th-lemma", k, num_parents, m_th_lemma_decls); @@ -949,7 +945,6 @@ void basic_decl_plugin::finalize() { DEC_REF(m_not_or_elim_decl); DEC_REF(m_rewrite_decl); DEC_REF(m_pull_quant_decl); - DEC_REF(m_pull_quant_star_decl); DEC_REF(m_push_quant_decl); DEC_REF(m_elim_unused_vars_decl); DEC_REF(m_der_decl); @@ -975,8 +970,6 @@ void basic_decl_plugin::finalize() { DEC_ARRAY_REF(m_apply_def_decls); DEC_ARRAY_REF(m_nnf_pos_decls); DEC_ARRAY_REF(m_nnf_neg_decls); - DEC_ARRAY_REF(m_nnf_star_decls); - DEC_ARRAY_REF(m_cnf_star_decls); DEC_ARRAY_REF(m_th_lemma_decls); DEC_REF(m_hyper_res_decl0); @@ -2844,12 +2837,6 @@ proof * ast_manager::mk_pull_quant(expr * e, quantifier * q) { return mk_app(m_basic_family_id, PR_PULL_QUANT, mk_iff(e, q)); } -proof * ast_manager::mk_pull_quant_star(expr * e, quantifier * q) { - if (proofs_disabled()) - return nullptr; - return mk_app(m_basic_family_id, PR_PULL_QUANT_STAR, mk_iff(e, q)); -} - proof * ast_manager::mk_push_quant(quantifier * q, expr * e) { if (proofs_disabled()) return nullptr; @@ -3094,15 +3081,6 @@ proof * ast_manager::mk_nnf_neg(expr * s, expr * t, unsigned num_proofs, proof * return mk_app(m_basic_family_id, PR_NNF_NEG, args.size(), args.c_ptr()); } -proof * ast_manager::mk_nnf_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) { - if (proofs_disabled()) - return nullptr; - ptr_buffer args; - args.append(num_proofs, (expr**) proofs); - args.push_back(mk_oeq(s, t)); - return mk_app(m_basic_family_id, PR_NNF_STAR, args.size(), args.c_ptr()); -} - proof * ast_manager::mk_skolemization(expr * q, expr * e) { if (proofs_disabled()) return nullptr; @@ -3111,15 +3089,6 @@ proof * ast_manager::mk_skolemization(expr * q, expr * e) { return mk_app(m_basic_family_id, PR_SKOLEMIZE, mk_oeq(q, e)); } -proof * ast_manager::mk_cnf_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) { - if (proofs_disabled()) - return nullptr; - ptr_buffer args; - args.append(num_proofs, (expr**) proofs); - args.push_back(mk_oeq(s, t)); - return mk_app(m_basic_family_id, PR_CNF_STAR, args.size(), args.c_ptr()); -} - proof * ast_manager::mk_and_elim(proof * p, unsigned i) { if (proofs_disabled()) return nullptr; diff --git a/src/ast/ast.h b/src/ast/ast.h index 55fea1b69..68e02d791 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -1042,11 +1042,11 @@ enum basic_op_kind { PR_UNDEF, PR_TRUE, PR_ASSERTED, PR_GOAL, PR_MODUS_PONENS, PR_REFLEXIVITY, PR_SYMMETRY, PR_TRANSITIVITY, PR_TRANSITIVITY_STAR, PR_MONOTONICITY, PR_QUANT_INTRO, PR_DISTRIBUTIVITY, PR_AND_ELIM, PR_NOT_OR_ELIM, PR_REWRITE, PR_REWRITE_STAR, PR_PULL_QUANT, - PR_PULL_QUANT_STAR, PR_PUSH_QUANT, PR_ELIM_UNUSED_VARS, PR_DER, PR_QUANT_INST, + PR_PUSH_QUANT, PR_ELIM_UNUSED_VARS, PR_DER, PR_QUANT_INST, PR_HYPOTHESIS, PR_LEMMA, PR_UNIT_RESOLUTION, PR_IFF_TRUE, PR_IFF_FALSE, PR_COMMUTATIVITY, PR_DEF_AXIOM, - PR_DEF_INTRO, PR_APPLY_DEF, PR_IFF_OEQ, PR_NNF_POS, PR_NNF_NEG, PR_NNF_STAR, PR_SKOLEMIZE, PR_CNF_STAR, + PR_DEF_INTRO, PR_APPLY_DEF, PR_IFF_OEQ, PR_NNF_POS, PR_NNF_NEG, PR_SKOLEMIZE, PR_MODUS_PONENS_OEQ, PR_TH_LEMMA, PR_HYPER_RESOLVE, LAST_BASIC_PR }; @@ -1080,7 +1080,6 @@ protected: func_decl * m_not_or_elim_decl; func_decl * m_rewrite_decl; func_decl * m_pull_quant_decl; - func_decl * m_pull_quant_star_decl; func_decl * m_push_quant_decl; func_decl * m_elim_unused_vars_decl; func_decl * m_der_decl; @@ -1106,8 +1105,6 @@ protected: ptr_vector m_apply_def_decls; ptr_vector m_nnf_pos_decls; ptr_vector m_nnf_neg_decls; - ptr_vector m_nnf_star_decls; - ptr_vector m_cnf_star_decls; ptr_vector m_th_lemma_decls; func_decl * m_hyper_res_decl0; @@ -2182,7 +2179,6 @@ public: proof * mk_oeq_rewrite(expr * s, expr * t); proof * mk_rewrite_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs); proof * mk_pull_quant(expr * e, quantifier * q); - proof * mk_pull_quant_star(expr * e, quantifier * q); proof * mk_push_quant(quantifier * q, expr * e); proof * mk_elim_unused_vars(quantifier * q, expr * r); proof * mk_der(quantifier * q, expr * r); @@ -2201,9 +2197,8 @@ public: proof * mk_nnf_pos(expr * s, expr * t, unsigned num_proofs, proof * const * proofs); proof * mk_nnf_neg(expr * s, expr * t, unsigned num_proofs, proof * const * proofs); - proof * mk_nnf_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs); proof * mk_skolemization(expr * q, expr * e); - proof * mk_cnf_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs); + proof * mk_and_elim(proof * p, unsigned i); proof * mk_not_or_elim(proof * p, unsigned i); diff --git a/src/ast/proofs/proof_checker.cpp b/src/ast/proofs/proof_checker.cpp index bd50e6c2a..0e16abd11 100644 --- a/src/ast/proofs/proof_checker.cpp +++ b/src/ast/proofs/proof_checker.cpp @@ -440,16 +440,6 @@ bool proof_checker::check1_basic(proof* p, expr_ref_vector& side_conditions) { IF_VERBOSE(0, verbose_stream() << "Expected proof of equivalence with a quantifier:\n" << mk_bounded_pp(p, m);); return false; } - case PR_PULL_QUANT_STAR: { - if (match_proof(p) && - match_fact(p, fact) && - match_iff(fact.get(), t1, t2)) { - // TBD: check the enchilada. - return true; - } - IF_VERBOSE(0, verbose_stream() << "Expected proof of equivalence:\n" << mk_bounded_pp(p, m);); - return false; - } case PR_PUSH_QUANT: { if (match_proof(p) && match_fact(p, fact) && @@ -730,10 +720,6 @@ bool proof_checker::check1_basic(proof* p, expr_ref_vector& side_conditions) { // TBD: return true; } - case PR_NNF_STAR: { - // TBD: - return true; - } case PR_SKOLEMIZE: { // (exists ?x (p ?x y)) -> (p (sk y) y) // (not (forall ?x (p ?x y))) -> (not (p (sk y) y)) @@ -755,19 +741,6 @@ bool proof_checker::check1_basic(proof* p, expr_ref_vector& side_conditions) { UNREACHABLE(); return false; } - case PR_CNF_STAR: { - for (unsigned i = 0; i < proofs.size(); ++i) { - if (match_op(proofs[i].get(), PR_DEF_INTRO, terms)) { - // ok - } - else { - UNREACHABLE(); - return false; - } - } - // coarse grain CNF conversion. - return true; - } case PR_MODUS_PONENS_OEQ: { if (match_fact(p, fact) && match_proof(p, p0, p1) && diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index 3393634b6..46388fcf4 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -597,7 +597,6 @@ namespace smt { void theory_arith::mk_to_int_axiom(app * n) { SASSERT(m_util.is_to_int(n)); ast_manager & m = get_manager(); - context & ctx = get_context(); expr* x = n->get_arg(0); // to_int (to_real x) = x diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 9dfd0475b..3335370eb 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -5595,6 +5595,8 @@ namespace smt { // merge arg0 and arg1 expr * arg0 = to_app(node)->get_arg(0); expr * arg1 = to_app(node)->get_arg(1); + SASSERT(arg0 != node); + SASSERT(arg1 != node); expr * arg0DeAlias = dealias_node(arg0, varAliasMap, concatAliasMap); expr * arg1DeAlias = dealias_node(arg1, varAliasMap, concatAliasMap); get_grounded_concats(arg0DeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); diff --git a/src/tactic/core/ctx_simplify_tactic.cpp b/src/tactic/core/ctx_simplify_tactic.cpp index 6ad9c0812..93a0b2e88 100644 --- a/src/tactic/core/ctx_simplify_tactic.cpp +++ b/src/tactic/core/ctx_simplify_tactic.cpp @@ -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, nullptr)); // 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)); } } diff --git a/src/tactic/core/dom_simplify_tactic.cpp b/src/tactic/core/dom_simplify_tactic.cpp index e8d3150af..47f96a7d9 100644 --- a/src/tactic/core/dom_simplify_tactic.cpp +++ b/src/tactic/core/dom_simplify_tactic.cpp @@ -382,7 +382,7 @@ void dom_simplify_tactic::simplify_goal(goal& g) { change |= r != g.form(i); 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, nullptr)); + 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)); } @@ -402,7 +402,7 @@ void dom_simplify_tactic::simplify_goal(goal& g) { CTRACE("simplify", r != g.form(i), tout << r << " " << mk_pp(g.form(i), m) << "\n";); 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, nullptr)); + 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)); } From 0ce200144923fe5856054bcad11c9f5471f0d791 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 10 Mar 2018 11:39:22 -0800 Subject: [PATCH 224/263] fix build Signed-off-by: Nikolaj Bjorner --- examples/tptp/tptp5.cpp | 11 ----------- scripts/mk_util.py | 9 +++++++-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/examples/tptp/tptp5.cpp b/examples/tptp/tptp5.cpp index b2736df4c..772440b42 100644 --- a/examples/tptp/tptp5.cpp +++ b/examples/tptp/tptp5.cpp @@ -1609,7 +1609,6 @@ public: display_inference(out, "rewrite", "thm", p); break; case Z3_OP_PR_PULL_QUANT: - case Z3_OP_PR_PULL_QUANT_STAR: display_inference(out, "pull_quant", "thm", p); break; case Z3_OP_PR_PUSH_QUANT: @@ -1669,12 +1668,6 @@ public: case Z3_OP_PR_NNF_NEG: display_inference(out, "nnf_neg", "sab", p); break; - case Z3_OP_PR_NNF_STAR: - display_inference(out, "nnf", "sab", p); - break; - case Z3_OP_PR_CNF_STAR: - display_inference(out, "cnf", "sab", p); - break; case Z3_OP_PR_SKOLEMIZE: display_inference(out, "skolemize", "sab", p); break; @@ -1706,10 +1699,6 @@ public: return display_hyp_inference(out, "modus_ponens", "thm", conclusion, hyp, hyp2); } case Z3_OP_PR_NNF_POS: - case Z3_OP_PR_NNF_STAR: - return display_hyp_inference(out, "nnf", "sab", conclusion, hyp); - case Z3_OP_PR_CNF_STAR: - return display_hyp_inference(out, "cnf", "sab", conclusion, hyp); case Z3_OP_PR_SKOLEMIZE: return display_hyp_inference(out, "skolemize", "sab", conclusion, hyp); case Z3_OP_PR_TRANSITIVITY: diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 03256125c..fecc207d8 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -889,8 +889,13 @@ def is_CXX_gpp(): return is_compiler(CXX, 'g++') def is_clang_in_gpp_form(cc): - version_string = check_output([cc, '--version']).encode('utf-8').decode('utf-8') - return version_string.find('clang') != -1 + str = check_output([cc, '--version']) + try: + version_string = str.encode('utf-8') + except: + version_string = str + clang = 'clang'.encode('utf-8') + return version_string.find(clang) != -1 def is_CXX_clangpp(): if is_compiler(CXX, 'g++'): From 58544925048b8559880edb20ccca385c895f1acb Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 10 Mar 2018 11:59:42 -0800 Subject: [PATCH 225/263] add stdbool.h to see whether build system breaks #1526 Signed-off-by: Nikolaj Bjorner --- src/api/z3.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/z3.h b/src/api/z3.h index 99929f33b..b29f1d6ba 100644 --- a/src/api/z3.h +++ b/src/api/z3.h @@ -21,7 +21,8 @@ Notes: #ifndef Z3_H_ #define Z3_H_ -#include +#include +#include #include "z3_macros.h" #include "z3_api.h" #include "z3_ast_containers.h" From 3d9139f6efaf9f6fb4a2f6226384a5824ae986a6 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 10 Mar 2018 12:07:55 -0800 Subject: [PATCH 226/263] bump revision Signed-off-by: Nikolaj Bjorner --- CMakeLists.txt | 2 +- scripts/mk_project.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62045016a..4d8c15493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ endif() ################################################################################ set(Z3_VERSION_MAJOR 4) set(Z3_VERSION_MINOR 6) -set(Z3_VERSION_PATCH 1) +set(Z3_VERSION_PATCH 2) set(Z3_VERSION_TWEAK 0) set(Z3_VERSION "${Z3_VERSION_MAJOR}.${Z3_VERSION_MINOR}.${Z3_VERSION_PATCH}.${Z3_VERSION_TWEAK}") set(Z3_FULL_VERSION_STR "${Z3_VERSION}") # Note this might be modified diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 8f75e97ed..2f7402760 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -9,7 +9,7 @@ from mk_util import * # Z3 Project definition def init_project_def(): - set_version(4, 6, 1, 0) + set_version(4, 6, 2, 0) add_lib('util', []) add_lib('lp', ['util'], 'util/lp') add_lib('polynomial', ['util'], 'math/polynomial') From 5651d00751a1eb40b94db86f00cb7d3ec9711c4d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 12 Mar 2018 13:21:31 -0700 Subject: [PATCH 227/263] fix #1534 Signed-off-by: Nikolaj Bjorner --- src/math/polynomial/upolynomial.cpp | 18 ++++++++---------- src/smt/theory_str.cpp | 18 ++++++++++-------- src/smt/theory_str.h | 9 +++++---- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/math/polynomial/upolynomial.cpp b/src/math/polynomial/upolynomial.cpp index f7cc16de2..cc2442981 100644 --- a/src/math/polynomial/upolynomial.cpp +++ b/src/math/polynomial/upolynomial.cpp @@ -781,17 +781,15 @@ namespace upolynomial { set(q.size(), q.c_ptr(), C); m().set(bound, p); } + else if (q.size() < C.size() || m().m().is_even(p) || m().m().is_even(bound)) { + // discard accumulated image, it was affected by unlucky primes + TRACE("mgcd", tout << "discarding image\n";); + set(q.size(), q.c_ptr(), C); + m().set(bound, p); + } else { - if (q.size() < C.size()) { - // discard accumulated image, it was affected by unlucky primes - TRACE("mgcd", tout << "discarding image\n";); - set(q.size(), q.c_ptr(), C); - m().set(bound, p); - } - else { - CRA_combine_images(q, p, C, bound); - TRACE("mgcd", tout << "new combined:\n"; display_star(tout, C); tout << "\n";); - } + CRA_combine_images(q, p, C, bound); + TRACE("mgcd", tout << "new combined:\n"; display_star(tout, C); tout << "\n";); } numeral_vector & candidate = q; get_primitive(C, candidate); diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 3335370eb..0016b8f36 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -5553,7 +5553,8 @@ namespace smt { return node; } - void theory_str::get_grounded_concats(expr* node, std::map & varAliasMap, + void theory_str::get_grounded_concats(unsigned depth, + expr* node, std::map & varAliasMap, std::map & concatAliasMap, std::map & varConstMap, std::map & concatConstMap, std::map > & varEqConcatMap, std::map, std::set > > & groundedMap) { @@ -5568,6 +5569,9 @@ namespace smt { if (groundedMap.find(node) != groundedMap.end()) { return; } + IF_VERBOSE(100, verbose_stream() << "concats " << depth << "\n"; + if (depth > 100) verbose_stream() << mk_pp(node, get_manager()) << "\n"; + ); // haven't computed grounded concats for "node" (de-aliased) // --------------------------------------------------------- @@ -5595,12 +5599,10 @@ namespace smt { // merge arg0 and arg1 expr * arg0 = to_app(node)->get_arg(0); expr * arg1 = to_app(node)->get_arg(1); - SASSERT(arg0 != node); - SASSERT(arg1 != node); expr * arg0DeAlias = dealias_node(arg0, varAliasMap, concatAliasMap); expr * arg1DeAlias = dealias_node(arg1, varAliasMap, concatAliasMap); - get_grounded_concats(arg0DeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); - get_grounded_concats(arg1DeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); + get_grounded_concats(depth + 1, arg0DeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); + get_grounded_concats(depth + 1, arg1DeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); std::map, std::set >::iterator arg0_grdItor = groundedMap[arg0DeAlias].begin(); std::map, std::set >::iterator arg1_grdItor; @@ -5650,7 +5652,7 @@ namespace smt { else if (varEqConcatMap.find(node) != varEqConcatMap.end()) { expr * eqConcat = varEqConcatMap[node].begin()->first; expr * deAliasedEqConcat = dealias_node(eqConcat, varAliasMap, concatAliasMap); - get_grounded_concats(deAliasedEqConcat, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); + get_grounded_concats(depth + 1, deAliasedEqConcat, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); std::map, std::set >::iterator grdItor = groundedMap[deAliasedEqConcat].begin(); for (; grdItor != groundedMap[deAliasedEqConcat].end(); grdItor++) { @@ -5859,8 +5861,8 @@ namespace smt { expr* strDeAlias = dealias_node(str, varAliasMap, concatAliasMap); expr* subStrDeAlias = dealias_node(subStr, varAliasMap, concatAliasMap); - get_grounded_concats(strDeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); - get_grounded_concats(subStrDeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); + get_grounded_concats(0, strDeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); + get_grounded_concats(0, subStrDeAlias, varAliasMap, concatAliasMap, varConstMap, concatConstMap, varEqConcatMap, groundedMap); // debugging print_grounded_concat(strDeAlias, groundedMap); diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index 9288bac7c..64ede71b5 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -495,10 +495,11 @@ protected: std::map & concatAliasMap, std::map & varConstMap, std::map & concatConstMap, std::map > & varEqConcatMap); expr * dealias_node(expr * node, std::map & varAliasMap, std::map & concatAliasMap); - void get_grounded_concats(expr* node, std::map & varAliasMap, - std::map & concatAliasMap, std::map & varConstMap, - std::map & concatConstMap, std::map > & varEqConcatMap, - std::map, std::set > > & groundedMap); + void get_grounded_concats(unsigned depth, + expr* node, std::map & varAliasMap, + std::map & concatAliasMap, std::map & varConstMap, + std::map & concatConstMap, std::map > & varEqConcatMap, + std::map, std::set > > & groundedMap); void print_grounded_concat(expr * node, std::map, std::set > > & groundedMap); void check_subsequence(expr* str, expr* strDeAlias, expr* subStr, expr* subStrDeAlias, expr* boolVar, std::map, std::set > > & groundedMap); From 73f7e301c3f60924a8d7e1518e714711eeb5f059 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 12 Mar 2018 17:09:55 -0400 Subject: [PATCH 228/263] preliminary refactoring to use obj_map --- src/smt/theory_str.cpp | 19 ++++++++++--------- src/smt/theory_str.h | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 3335370eb..90eb01fa8 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -4582,8 +4582,9 @@ namespace smt { std::pair key = std::make_pair(concat, unroll); expr_ref toAssert(mgr); + expr * _toAssert; - if (concat_eq_unroll_ast_map.find(key) == concat_eq_unroll_ast_map.end()) { + if (!concat_eq_unroll_ast_map.find(concat, unroll, _toAssert)) { expr_ref arg1(to_app(concat)->get_arg(0), mgr); expr_ref arg2(to_app(concat)->get_arg(1), mgr); expr_ref r1(to_app(unroll)->get_arg(0), mgr); @@ -4634,9 +4635,9 @@ namespace smt { toAssert = mgr.mk_and(opAnd1, opAnd2); m_trail.push_back(toAssert); - concat_eq_unroll_ast_map[key] = toAssert; + concat_eq_unroll_ast_map.insert(concat, unroll, toAssert); } else { - toAssert = concat_eq_unroll_ast_map[key]; + toAssert = _toAssert; } assert_axiom(toAssert); @@ -4920,7 +4921,7 @@ namespace smt { expr_ref_vector litems(m); - if (contain_pair_idx_map.find(varNode) != contain_pair_idx_map.end()) { + if (contain_pair_idx_map.contains(varNode)) { std::set >::iterator itor1 = contain_pair_idx_map[varNode].begin(); for (; itor1 != contain_pair_idx_map[varNode].end(); ++itor1) { expr * strAst = itor1->first; @@ -5057,7 +5058,7 @@ namespace smt { ast_manager & m = get_manager(); expr_ref_vector litems(m); - if (contain_pair_idx_map.find(varNode) != contain_pair_idx_map.end()) { + if (contain_pair_idx_map.contains(varNode)) { std::set >::iterator itor1 = contain_pair_idx_map[varNode].begin(); for (; itor1 != contain_pair_idx_map[varNode].end(); ++itor1) { expr * strAst = itor1->first; @@ -5125,7 +5126,7 @@ namespace smt { } bool theory_str::in_contain_idx_map(expr * n) { - return contain_pair_idx_map.find(n) != contain_pair_idx_map.end(); + return contain_pair_idx_map.contains(n); } void theory_str::check_contain_by_eq_nodes(expr * n1, expr * n2) { @@ -6456,7 +6457,7 @@ namespace smt { } else { expr_ref_vector::iterator itor = eqNodeSet.begin(); for (; itor != eqNodeSet.end(); itor++) { - if (regex_in_var_reg_str_map.find(*itor) != regex_in_var_reg_str_map.end()) { + if (regex_in_var_reg_str_map.contains(*itor)) { std::set::iterator strItor = regex_in_var_reg_str_map[*itor].begin(); for (; strItor != regex_in_var_reg_str_map[*itor].end(); strItor++) { zstring regStr = *strItor; @@ -6469,7 +6470,7 @@ namespace smt { expr * regexTerm = a_regexIn->get_arg(1); // TODO figure out regex NFA stuff - if (regex_nfa_cache.find(regexTerm) == regex_nfa_cache.end()) { + if (!regex_nfa_cache.contains(regexTerm)) { TRACE("str", tout << "regex_nfa_cache: cache miss" << std::endl;); regex_nfa_cache[regexTerm] = nfa(u, regexTerm); } else { @@ -9596,7 +9597,7 @@ namespace smt { if (low.is_neg()) { toAssert = m_autil.mk_ge(cntInUnr, mk_int(0)); } else { - if (unroll_var_map.find(unrFunc) == unroll_var_map.end()) { + if (!unroll_var_map.contains(unrFunc)) { expr_ref newVar1(mk_regex_rep_var(), mgr); expr_ref newVar2(mk_regex_rep_var(), mgr); diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index 9288bac7c..5a249f5dc 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -312,30 +312,29 @@ protected: obj_hashtable input_var_in_len; obj_map fvar_len_count_map; - std::map > fvar_lenTester_map; + obj_map > fvar_lenTester_map; obj_map lenTester_fvar_map; - std::map > > > fvar_valueTester_map; - std::map valueTester_fvar_map; + obj_map > > > fvar_valueTester_map; + obj_map valueTester_fvar_map; - std::map val_range_map; + obj_map val_range_map; // This can't be an expr_ref_vector because the constructor is wrong, // we would need to modify the allocator so we pass in ast_manager - std::map, ptr_vector > > unroll_tries_map; - std::map unroll_var_map; - std::map, expr*> concat_eq_unroll_ast_map; + obj_map, ptr_vector > > unroll_tries_map; + obj_map unroll_var_map; + obj_pair_map concat_eq_unroll_ast_map; expr_ref_vector contains_map; theory_str_contain_pair_bool_map_t contain_pair_bool_map; - //obj_map > contain_pair_idx_map; - std::map > > contain_pair_idx_map; + obj_map > > contain_pair_idx_map; std::map, expr*> regex_in_bool_map; - std::map > regex_in_var_reg_str_map; + obj_map > regex_in_var_reg_str_map; - std::map regex_nfa_cache; // Regex term --> NFA + obj_map regex_nfa_cache; // Regex term --> NFA svector char_set; std::map charSetLookupTable; From b5471e7fe06a2b7a14ccbcdb4273221f54fa8353 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 12 Mar 2018 20:04:04 -0400 Subject: [PATCH 229/263] refactor: use c++11 for (part 1) --- src/smt/theory_str.cpp | 167 ++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 95 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 90eb01fa8..139e25740 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -289,9 +289,8 @@ namespace smt { } static void cut_vars_map_copy(std::map & dest, std::map & src) { - std::map::iterator itor = src.begin(); - for (; itor != src.end(); itor++) { - dest[itor->first] = 1; + for (auto entry : src) { + dest[entry.first] = 1; } } @@ -306,9 +305,8 @@ namespace smt { return false; } - std::map::iterator itor = cut_var_map[n1].top()->vars.begin(); - for (; itor != cut_var_map[n1].top()->vars.end(); ++itor) { - if (cut_var_map[n2].top()->vars.find(itor->first) != cut_var_map[n2].top()->vars.end()) { + for (auto entry : cut_var_map[n1].top()->vars) { + if (cut_var_map[n2].top()->vars.find(entry.first) != cut_var_map[n2].top()->vars.end()) { return true; } } @@ -781,8 +779,8 @@ namespace smt { ptr_vector childrenVector; get_nodes_in_concat(concatAst, childrenVector); expr_ref_vector items(m); - for (unsigned int i = 0; i < childrenVector.size(); i++) { - items.push_back(mk_strlen(childrenVector.get(i))); + for (auto el : childrenVector) { + items.push_back(mk_strlen(el)); } expr_ref lenAssert(ctx.mk_eq_atom(concat_length, m_autil.mk_add(items.size(), items.c_ptr())), m); assert_axiom(lenAssert); @@ -802,32 +800,30 @@ namespace smt { context & ctx = get_context(); while (can_propagate()) { TRACE("str", tout << "propagating..." << std::endl;); - for (unsigned i = 0; i < m_basicstr_axiom_todo.size(); ++i) { - instantiate_basic_string_axioms(m_basicstr_axiom_todo[i]); + for (auto el : m_basicstr_axiom_todo) { + instantiate_basic_string_axioms(el); } m_basicstr_axiom_todo.reset(); TRACE("str", tout << "reset m_basicstr_axiom_todo" << std::endl;); - for (unsigned i = 0; i < m_str_eq_todo.size(); ++i) { - std::pair pair = m_str_eq_todo[i]; + for (auto pair : m_str_eq_todo) { enode * lhs = pair.first; enode * rhs = pair.second; handle_equality(lhs->get_owner(), rhs->get_owner()); } m_str_eq_todo.reset(); - for (unsigned i = 0; i < m_concat_axiom_todo.size(); ++i) { - instantiate_concat_axiom(m_concat_axiom_todo[i]); + for (auto el : m_concat_axiom_todo) { + instantiate_concat_axiom(el); } m_concat_axiom_todo.reset(); - for (unsigned i = 0; i < m_concat_eval_todo.size(); ++i) { - try_eval_concat(m_concat_eval_todo[i]); + for (auto el : m_concat_eval_todo) { + try_eval_concat(el); } m_concat_eval_todo.reset(); - for (unsigned i = 0; i < m_library_aware_axiom_todo.size(); ++i) { - enode * e = m_library_aware_axiom_todo[i]; + for (enode * e : m_library_aware_axiom_todo) { app * a = e->get_owner(); if (u.str.is_stoi(a)) { instantiate_axiom_str_to_int(e); @@ -856,10 +852,10 @@ namespace smt { } m_library_aware_axiom_todo.reset(); - for (unsigned i = 0; i < m_delayed_axiom_setup_terms.size(); ++i) { + for (auto el : m_delayed_axiom_setup_terms) { // I think this is okay - ctx.internalize(m_delayed_axiom_setup_terms[i].get(), false); - set_up_axioms(m_delayed_axiom_setup_terms[i].get()); + ctx.internalize(el, false); + set_up_axioms(el); } m_delayed_axiom_setup_terms.reset(); } @@ -2380,9 +2376,8 @@ namespace smt { } else { expr_ref_vector items(m); int pos = 0; - std::map::iterator itor = resolvedMap.begin(); - for (; itor != resolvedMap.end(); ++itor) { - items.push_back(ctx.mk_eq_atom(itor->first, itor->second)); + for (auto itor : resolvedMap) { + items.push_back(ctx.mk_eq_atom(itor.first, itor.second)); pos += 1; } expr_ref premise(mk_and(items), m); @@ -2558,8 +2553,7 @@ namespace smt { context & ctx = get_context(); // pull each literal out of the arrangement disjunction literal_vector ls; - for (unsigned i = 0; i < terms.size(); ++i) { - expr * e = terms.get(i); + for (expr * e : terms) { literal l = ctx.get_literal(e); ls.push_back(l); } @@ -2572,9 +2566,8 @@ namespace smt { if (cut_var_map.contains(node)) { if (!cut_var_map[node].empty()) { xout << "[" << cut_var_map[node].top()->level << "] "; - std::map::iterator itor = cut_var_map[node].top()->vars.begin(); - for (; itor != cut_var_map[node].top()->vars.end(); ++itor) { - xout << mk_pp(itor->first, m) << ", "; + for (auto entry : cut_var_map[node].top()->vars) { + xout << mk_pp(entry.first, m) << ", "; } xout << std::endl; } @@ -4498,8 +4491,7 @@ namespace smt { } } - for (std::list::iterator itor = overlapLen.begin(); itor != overlapLen.end(); itor++) { - unsigned int overLen = *itor; + for (unsigned int overLen : overlapLen) { zstring prefix = str1Value.extract(0, str1Len - overLen); zstring suffix = str2Value.extract(overLen, str2Len - overLen); @@ -4580,7 +4572,6 @@ namespace smt { TRACE("str", tout << "concat = " << mk_pp(concat, mgr) << ", unroll = " << mk_pp(unroll, mgr) << std::endl;); - std::pair key = std::make_pair(concat, unroll); expr_ref toAssert(mgr); expr * _toAssert; @@ -4922,10 +4913,9 @@ namespace smt { expr_ref_vector litems(m); if (contain_pair_idx_map.contains(varNode)) { - std::set >::iterator itor1 = contain_pair_idx_map[varNode].begin(); - for (; itor1 != contain_pair_idx_map[varNode].end(); ++itor1) { - expr * strAst = itor1->first; - expr * substrAst = itor1->second; + for (auto entry : contain_pair_idx_map[varNode]) { + expr * strAst = entry.first; + expr * substrAst = entry.second; expr * boolVar = nullptr; if (!contain_pair_bool_map.find(strAst, substrAst, boolVar)) { @@ -4983,23 +4973,19 @@ namespace smt { // collect eqc concat std::set eqcConcats; get_concats_in_eqc(substrAst, eqcConcats); - for (std::set::iterator concatItor = eqcConcats.begin(); - concatItor != eqcConcats.end(); concatItor++) { + for (expr * aConcat : eqcConcats) { expr_ref_vector constList(m); bool counterEgFound = false; - // get constant strings in concat - expr * aConcat = *concatItor; get_const_str_asts_in_node(aConcat, constList); - for (expr_ref_vector::iterator cstItor = constList.begin(); - cstItor != constList.end(); cstItor++) { + //for (expr_ref_vector::iterator cstItor = constList.begin(); cstItor != constList.end(); cstItor++) { + for (auto cst : constList) { zstring pieceStr; - u.str.is_string(*cstItor, pieceStr); + u.str.is_string(cst, pieceStr); if (!strConst.contains(pieceStr)) { counterEgFound = true; if (aConcat != substrAst) { litems.push_back(ctx.mk_eq_atom(substrAst, aConcat)); } - //implyR = Z3_mk_eq(ctx, boolVar, Z3_mk_false(ctx)); implyR = mk_not(m, boolVar); break; } @@ -5059,10 +5045,9 @@ namespace smt { expr_ref_vector litems(m); if (contain_pair_idx_map.contains(varNode)) { - std::set >::iterator itor1 = contain_pair_idx_map[varNode].begin(); - for (; itor1 != contain_pair_idx_map[varNode].end(); ++itor1) { - expr * strAst = itor1->first; - expr * substrAst = itor1->second; + for (auto entry : contain_pair_idx_map[varNode]) { + expr * strAst = entry.first; + expr * substrAst = entry.second; expr * boolVar = nullptr; if (!contain_pair_bool_map.find(strAst, substrAst, boolVar)) { @@ -5091,17 +5076,16 @@ namespace smt { zstring strConst; u.str.is_string(strValue, strConst); // iterate eqc (also eqc-to-be) of substr - for (expr_ref_vector::iterator itAst = willEqClass.begin(); itAst != willEqClass.end(); itAst++) { + for (auto itAst : willEqClass) { bool counterEgFound = false; - if (u.str.is_concat(to_app(*itAst))) { + if (u.str.is_concat(to_app(itAst))) { expr_ref_vector constList(m); // get constant strings in concat - app * aConcat = to_app(*itAst); + app * aConcat = to_app(itAst); get_const_str_asts_in_node(aConcat, constList); - for (expr_ref_vector::iterator cstItor = constList.begin(); - cstItor != constList.end(); cstItor++) { + for (auto cst : constList) { zstring pieceStr; - u.str.is_string(*cstItor, pieceStr); + u.str.is_string(cst, pieceStr); if (!strConst.contains(pieceStr)) { TRACE("str", tout << "Inconsistency found!" << std::endl;); counterEgFound = true; @@ -5134,12 +5118,13 @@ namespace smt { ast_manager & m = get_manager(); if (in_contain_idx_map(n1) && in_contain_idx_map(n2)) { - std::set >::iterator keysItor1 = contain_pair_idx_map[n1].begin(); - std::set >::iterator keysItor2; + //std::set >::iterator keysItor1 = contain_pair_idx_map[n1].begin(); + //std::set >::iterator keysItor2; - for (; keysItor1 != contain_pair_idx_map[n1].end(); keysItor1++) { + //for (; keysItor1 != contain_pair_idx_map[n1].end(); keysItor1++) { + for (auto key1 : contain_pair_idx_map[n1]) { // keysItor1 is on set {<.., n1>, ..., , ...} - std::pair key1 = *keysItor1; + //std::pair key1 = *keysItor1; if (key1.first == n1 && key1.second == n2) { expr_ref implyL(m); expr_ref implyR(contain_pair_bool_map[key1], m); @@ -5151,10 +5136,10 @@ namespace smt { } } - for (keysItor2 = contain_pair_idx_map[n2].begin(); - keysItor2 != contain_pair_idx_map[n2].end(); keysItor2++) { + //for (keysItor2 = contain_pair_idx_map[n2].begin(); keysItor2 != contain_pair_idx_map[n2].end(); keysItor2++) { + for (auto key2 : contain_pair_idx_map[n2]) { // keysItor2 is on set {<.., n2>, ..., , ...} - std::pair key2 = *keysItor2; + //std::pair key2 = *keysItor2; // skip if the pair is eq if (key1 == key2) { continue; @@ -5248,10 +5233,12 @@ namespace smt { // * key1.first = key2.first // check eqc(key1.second) and eqc(key2.second) // ----------------------------------------------------------- - expr_ref_vector::iterator eqItorSub1 = subAst1Eqc.begin(); - for (; eqItorSub1 != subAst1Eqc.end(); eqItorSub1++) { - expr_ref_vector::iterator eqItorSub2 = subAst2Eqc.begin(); - for (; eqItorSub2 != subAst2Eqc.end(); eqItorSub2++) { + //expr_ref_vector::iterator eqItorSub1 = subAst1Eqc.begin(); + //for (; eqItorSub1 != subAst1Eqc.end(); eqItorSub1++) { + for (auto eqSubVar1 : subAst1Eqc) { + //expr_ref_vector::iterator eqItorSub2 = subAst2Eqc.begin(); + //for (; eqItorSub2 != subAst2Eqc.end(); eqItorSub2++) { + for (auto eqSubVar2 : subAst2Eqc) { // ------------ // key1.first = key2.first /\ containPairBoolMap[] // ==> (containPairBoolMap[key1] --> containPairBoolMap[key2]) @@ -5261,11 +5248,11 @@ namespace smt { if (n1 != n2) { litems3.push_back(ctx.mk_eq_atom(n1, n2)); } - expr * eqSubVar1 = *eqItorSub1; + if (eqSubVar1 != subAst1) { litems3.push_back(ctx.mk_eq_atom(subAst1, eqSubVar1)); } - expr * eqSubVar2 = *eqItorSub2; + if (eqSubVar2 != subAst2) { litems3.push_back(ctx.mk_eq_atom(subAst2, eqSubVar2)); } @@ -5286,11 +5273,11 @@ namespace smt { if (n1 != n2) { litems4.push_back(ctx.mk_eq_atom(n1, n2)); } - expr * eqSubVar1 = *eqItorSub1; + if (eqSubVar1 != subAst1) { litems4.push_back(ctx.mk_eq_atom(subAst1, eqSubVar1)); } - expr * eqSubVar2 = *eqItorSub2; + if (eqSubVar2 != subAst2) { litems4.push_back(ctx.mk_eq_atom(subAst2, eqSubVar2)); } @@ -5398,20 +5385,18 @@ namespace smt { // * key1.second = key2.second // check eqc(key1.first) and eqc(key2.first) // ----------------------------------------------------------- - expr_ref_vector::iterator eqItorStr1 = str1Eqc.begin(); - for (; eqItorStr1 != str1Eqc.end(); eqItorStr1++) { - expr_ref_vector::iterator eqItorStr2 = str2Eqc.begin(); - for (; eqItorStr2 != str2Eqc.end(); eqItorStr2++) { + for (auto eqStrVar1 : str1Eqc) { + for (auto eqStrVar2 : str2Eqc) { { expr_ref_vector litems3(m); if (n1 != n2) { litems3.push_back(ctx.mk_eq_atom(n1, n2)); } - expr * eqStrVar1 = *eqItorStr1; + if (eqStrVar1 != str1) { litems3.push_back(ctx.mk_eq_atom(str1, eqStrVar1)); } - expr * eqStrVar2 = *eqItorStr2; + if (eqStrVar2 != str2) { litems3.push_back(ctx.mk_eq_atom(str2, eqStrVar2)); } @@ -5434,11 +5419,9 @@ namespace smt { if (n1 != n2) { litems4.push_back(ctx.mk_eq_atom(n1, n2)); } - expr * eqStrVar1 = *eqItorStr1; if (eqStrVar1 != str1) { litems4.push_back(ctx.mk_eq_atom(str1, eqStrVar1)); } - expr *eqStrVar2 = *eqItorStr2; if (eqStrVar2 != str2) { litems4.push_back(ctx.mk_eq_atom(str2, eqStrVar2)); } @@ -5484,8 +5467,7 @@ namespace smt { expr * constStrAst = (constStrAst_1 != nullptr) ? constStrAst_1 : constStrAst_2; TRACE("str", tout << "eqc of n1 is {"; - for (expr_ref_vector::iterator it = willEqClass.begin(); it != willEqClass.end(); ++it) { - expr * el = *it; + for (expr * el : willEqClass) { tout << " " << mk_pp(el, m); } tout << std::endl; @@ -5498,12 +5480,11 @@ namespace smt { // step 1: we may have constant values for Contains checks now if (constStrAst != nullptr) { - expr_ref_vector::iterator itAst = willEqClass.begin(); - for (; itAst != willEqClass.end(); itAst++) { - if (*itAst == constStrAst) { + for (auto a : willEqClass) { + if (a == constStrAst) { continue; } - check_contain_by_eqc_val(*itAst, constStrAst); + check_contain_by_eqc_val(a, constStrAst); } } else { // no concrete value to be put in eqc, solely based on context @@ -5515,9 +5496,8 @@ namespace smt { // * "EQC(M) U EQC(concat(..., "jio", ...))" as substr and // * If strAst registered has an eqc constant in the context // ------------------------------------------------------------- - expr_ref_vector::iterator itAst = willEqClass.begin(); - for (; itAst != willEqClass.end(); ++itAst) { - check_contain_by_substr(*itAst, willEqClass); + for (auto a : willEqClass) { + check_contain_by_substr(a, willEqClass); } } @@ -5534,12 +5514,8 @@ namespace smt { // (9) containPairBoolMap[] /\ m = n ==> (b1 -> b2) // ------------------------------------------ - expr_ref_vector::iterator varItor1 = willEqClass.begin(); - for (; varItor1 != willEqClass.end(); ++varItor1) { - expr * varAst1 = *varItor1; - expr_ref_vector::iterator varItor2 = varItor1; - for (; varItor2 != willEqClass.end(); ++varItor2) { - expr * varAst2 = *varItor2; + for (auto varAst1 : willEqClass) { + for (auto varAst2 : willEqClass) { check_contain_by_eq_nodes(varAst1, varAst2); } } @@ -7947,11 +7923,12 @@ namespace smt { // Step 1: get variables / concat AST appearing in the context // the thing we iterate over should just be variable_set - internal_variable_set // so we avoid computing the set difference (but this might be slower) - for(obj_hashtable::iterator it = variable_set.begin(); it != variable_set.end(); ++it) { - expr* var = *it; + for (expr* var : variable_set) { + //for(obj_hashtable::iterator it = variable_set.begin(); it != variable_set.end(); ++it) { + //expr* var = *it; if (internal_variable_set.find(var) == internal_variable_set.end()) { TRACE("str", tout << "new variable: " << mk_pp(var, m) << std::endl;); - strVarMap[*it] = 1; + strVarMap[var] = 1; } } classify_ast_by_type_in_positive_context(strVarMap, concatMap, unrollMap); From 5f7bd993de4b83d95e22921d424a7902d0480f83 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 13 Mar 2018 21:37:22 +0100 Subject: [PATCH 230/263] Add support for NetBSD Originally from David Holland . --- CMakeLists.txt | 3 +++ scripts/mk_util.py | 17 ++++++++++++++++- src/util/scoped_timer.cpp | 18 +++++++++--------- src/util/stopwatch.h | 5 +++++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d8c15493..c11c272be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,6 +240,9 @@ elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") message(STATUS "Platform: FreeBSD") list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_FREEBSD_") +elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "NetBSD") + message(STATUS "Platform: NetBSD") + list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_NetBSD_") elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD") message(STATUS "Platform: OpenBSD") list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_OPENBSD_") diff --git a/scripts/mk_util.py b/scripts/mk_util.py index fecc207d8..99de61703 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -69,6 +69,7 @@ IS_WINDOWS=False IS_LINUX=False IS_OSX=False IS_FREEBSD=False +IS_NETBSD=False IS_OPENBSD=False IS_CYGWIN=False IS_CYGWIN_MINGW=False @@ -141,6 +142,9 @@ def is_linux(): def is_freebsd(): return IS_FREEBSD +def is_netbsd(): + return IS_NETBSD + def is_openbsd(): return IS_OPENBSD @@ -604,6 +608,8 @@ elif os.name == 'posix': IS_LINUX=True elif os.uname()[0] == 'FreeBSD': IS_FREEBSD=True + elif os.uname()[0] == 'NetBSD': + IS_NETBSD=True elif os.uname()[0] == 'OpenBSD': IS_OPENBSD=True elif os.uname()[0][:6] == 'CYGWIN': @@ -1245,7 +1251,7 @@ def get_so_ext(): sysname = os.uname()[0] if sysname == 'Darwin': return 'dylib' - elif sysname == 'Linux' or sysname == 'FreeBSD' or sysname == 'OpenBSD': + elif sysname == 'Linux' or sysname == 'FreeBSD' or sysname == 'NetBSD' or sysname == 'OpenBSD': return 'so' elif sysname == 'CYGWIN' or sysname.startswith('MSYS_NT') or sysname.startswith('MINGW'): return 'dll' @@ -1795,6 +1801,8 @@ class JavaDLLComponent(Component): t = t.replace('PLATFORM', 'linux') elif IS_FREEBSD: t = t.replace('PLATFORM', 'freebsd') + elif IS_NETBSD: + t = t.replace('PLATFORM', 'netbsd') elif IS_OPENBSD: t = t.replace('PLATFORM', 'openbsd') elif IS_CYGWIN: @@ -2504,6 +2512,13 @@ def mk_config(): LDFLAGS = '%s -lrt' % LDFLAGS SLIBFLAGS = '-shared' SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS + elif sysname == 'NetBSD': + CXXFLAGS = '%s -D_NETBSD_' % CXXFLAGS + OS_DEFINES = '-D_NETBSD_' + SO_EXT = '.so' + LDFLAGS = '%s -lrt' % LDFLAGS + SLIBFLAGS = '-shared' + SLIBEXTRAFLAGS = '%s -lrt' % SLIBEXTRAFLAGS elif sysname == 'OpenBSD': CXXFLAGS = '%s -D_OPENBSD_' % CXXFLAGS OS_DEFINES = '-D_OPENBSD_' diff --git a/src/util/scoped_timer.cpp b/src/util/scoped_timer.cpp index 1ecca8ffe..a2a0cc269 100644 --- a/src/util/scoped_timer.cpp +++ b/src/util/scoped_timer.cpp @@ -33,8 +33,8 @@ Revision History: #include #include #include -#elif defined(_LINUX_) || defined(_FREEBSD_) -// Linux +#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NetBSD_) +// Linux & FreeBSD & NetBSD #include #include #include @@ -66,8 +66,8 @@ struct scoped_timer::imp { pthread_mutex_t m_mutex; pthread_cond_t m_condition_var; struct timespec m_end_time; -#elif defined(_LINUX_) || defined(_FREEBSD_) - // Linux & FreeBSD +#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_) + // Linux & FreeBSD & NetBSD pthread_t m_thread_id; pthread_mutex_t m_mutex; pthread_cond_t m_cond; @@ -104,7 +104,7 @@ struct scoped_timer::imp { return st; } -#elif defined(_LINUX_) || defined(_FREEBSD_) +#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_) static void* thread_func(void *arg) { scoped_timer::imp *st = static_cast(arg); @@ -175,8 +175,8 @@ struct scoped_timer::imp { if (pthread_create(&m_thread_id, &m_attributes, &thread_func, this) != 0) throw default_exception("failed to start timer thread"); -#elif defined(_LINUX_) || defined(_FREEBSD_) - // Linux & FreeBSD +#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_) + // Linux & FreeBSD & NetBSD m_ms = ms; m_initialized = false; m_signal_sent = false; @@ -216,8 +216,8 @@ struct scoped_timer::imp { throw default_exception("failed to destroy pthread condition variable"); if (pthread_attr_destroy(&m_attributes) != 0) throw default_exception("failed to destroy pthread attributes object"); -#elif defined(_LINUX_) || defined(_FREEBSD_) - // Linux & FreeBSD +#elif defined(_LINUX_) || defined(_FREEBSD_) || defined(_NETBSD_) + // Linux & FreeBSD & NetBSD bool init = false; // spin until timer thread has been created diff --git a/src/util/stopwatch.h b/src/util/stopwatch.h index 9ba707af0..83e03a2f7 100644 --- a/src/util/stopwatch.h +++ b/src/util/stopwatch.h @@ -134,6 +134,11 @@ public: #include +#ifndef CLOCK_PROCESS_CPUTIME_ID +/* BSD */ +# define CLOCK_PROCESS_CPUTIME_ID CLOCK_MONOTONIC +#endif + class stopwatch { unsigned long long m_time; // elapsed time in ns bool m_running; From 2b2aee3c18bee27bee94908d650596e7e5424b64 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 14 Mar 2018 07:29:26 -0700 Subject: [PATCH 231/263] remove unused operators #1530 Signed-off-by: Nikolaj Bjorner --- src/api/ml/z3.ml | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/api/ml/z3.ml b/src/api/ml/z3.ml index 120b0ddfd..5766c79f9 100644 --- a/src/api/ml/z3.ml +++ b/src/api/ml/z3.ml @@ -1402,7 +1402,6 @@ struct let is_rewrite (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_REWRITE) let is_rewrite_star (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_REWRITE_STAR) let is_pull_quant (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_PULL_QUANT) - let is_pull_quant_star (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_PULL_QUANT_STAR) let is_push_quant (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_PUSH_QUANT) let is_elim_unused_vars (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_ELIM_UNUSED_VARS) let is_der (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_DER) @@ -1419,8 +1418,6 @@ struct let is_iff_oeq (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_IFF_OEQ) let is_nnf_pos (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_NNF_POS) let is_nnf_neg (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_NNF_NEG) - let is_nnf_star (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_NNF_STAR) - let is_cnf_star (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_CNF_STAR) let is_skolemize (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_SKOLEMIZE) let is_modus_ponens_oeq (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_MODUS_PONENS_OEQ) let is_theory_lemma (x:expr) = (AST.is_app x) && (FuncDecl.get_decl_kind (Expr.get_func_decl x) = OP_PR_TH_LEMMA) From 5e2723a16ebf1603dc5a048ef98528e40d75d682 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 14 Mar 2018 09:04:08 -0700 Subject: [PATCH 232/263] java Signed-off-by: Nikolaj Bjorner --- src/api/java/Context.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/java/Context.java b/src/api/java/Context.java index ba96209b3..8720fd975 100644 --- a/src/api/java/Context.java +++ b/src/api/java/Context.java @@ -2543,14 +2543,15 @@ public class Context implements AutoCloseable { /** * Parse the given string using the SMT-LIB2 parser. * - * @return A conjunction of assertions in the scope (up to push/pop) at the - * end of the string. + * @return A conjunction of assertions. + * + * If the string contains push/pop commands, the + * set of assertions returned are the ones in the + * last scope level. **/ public BoolExpr parseSMTLIB2String(String str, Symbol[] sortNames, - Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) - + Sort[] sorts, Symbol[] declNames, FuncDecl[] decls) { - int csn = Symbol.arrayLength(sortNames); int cs = Sort.arrayLength(sorts); int cdn = Symbol.arrayLength(declNames); From 46048d51502c749e8a230e9a43e1afdeb439d2dd Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 14 Mar 2018 12:15:13 -0700 Subject: [PATCH 233/263] change lemma display utility to use updated pretty printer Signed-off-by: Nikolaj Bjorner --- src/smt/smt_context_pp.cpp | 52 ++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/src/smt/smt_context_pp.cpp b/src/smt/smt_context_pp.cpp index f5ba52128..e883e0a09 100644 --- a/src/smt/smt_context_pp.cpp +++ b/src/smt/smt_context_pp.cpp @@ -19,7 +19,7 @@ Revision History: #include "smt/smt_context.h" #include "ast/ast_ll_pp.h" #include "ast/ast_pp.h" -#include "ast/ast_smt_pp.h" +#include "ast/ast_pp_util.h" #include "util/stats.h" namespace smt { @@ -413,19 +413,23 @@ namespace smt { } void context::display_lemma_as_smt_problem(std::ostream & out, unsigned num_antecedents, literal const * antecedents, literal consequent, symbol const& logic) const { - ast_smt_pp pp(m_manager); - pp.set_benchmark_name("lemma"); - pp.set_status("unsat"); - pp.set_logic(logic); + ast_pp_util visitor(m_manager); + expr_ref_vector fmls(m_manager); + visitor.collect(fmls); + expr_ref n(m_manager); for (unsigned i = 0; i < num_antecedents; i++) { literal l = antecedents[i]; - expr_ref n(m_manager); literal2expr(l, n); - pp.add_assumption(n); + fmls.push_back(n); } - expr_ref n(m_manager); - literal2expr(~consequent, n); - pp.display_smt2(out, n); + if (consequent != false_literal) { + literal2expr(~consequent, n); + fmls.push_back(n); + } + if (logic != symbol::null) out << "(set-logic " << logic << ")\n"; + visitor.collect(fmls); + visitor.display_decls(out); + visitor.display_asserts(out, fmls, true); } static unsigned g_lemma_id = 0; @@ -448,25 +452,29 @@ namespace smt { void context::display_lemma_as_smt_problem(std::ostream & out, unsigned num_antecedents, literal const * antecedents, unsigned num_eq_antecedents, enode_pair const * eq_antecedents, literal consequent, symbol const& logic) const { - ast_smt_pp pp(m_manager); - pp.set_benchmark_name("lemma"); - pp.set_status("unsat"); - pp.set_logic(logic); + ast_pp_util visitor(m_manager); + expr_ref_vector fmls(m_manager); + visitor.collect(fmls); + expr_ref n(m_manager); for (unsigned i = 0; i < num_antecedents; i++) { literal l = antecedents[i]; - expr_ref n(m_manager); literal2expr(l, n); - pp.add_assumption(n); + fmls.push_back(n); } for (unsigned i = 0; i < num_eq_antecedents; i++) { enode_pair const & p = eq_antecedents[i]; - expr_ref eq(m_manager); - eq = m_manager.mk_eq(p.first->get_owner(), p.second->get_owner()); - pp.add_assumption(eq); + n = m_manager.mk_eq(p.first->get_owner(), p.second->get_owner()); + fmls.push_back(n); } - expr_ref n(m_manager); - literal2expr(~consequent, n); - pp.display_smt2(out, n); + if (consequent != false_literal) { + literal2expr(~consequent, n); + fmls.push_back(n); + } + + if (logic != symbol::null) out << "(set-logic " << logic << ")\n"; + visitor.collect(fmls); + visitor.display_decls(out); + visitor.display_asserts(out, fmls, true); } void context::display_lemma_as_smt_problem(unsigned num_antecedents, literal const * antecedents, From b1f05d8271e1773bb560c58daa2bf3180dacb419 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Wed, 14 Mar 2018 18:14:29 -0700 Subject: [PATCH 234/263] fix #1539 Signed-off-by: Nikolaj Bjorner --- src/api/ml/z3.mli | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/api/ml/z3.mli b/src/api/ml/z3.mli index 20a1e9c10..14d2ceac4 100644 --- a/src/api/ml/z3.mli +++ b/src/api/ml/z3.mli @@ -2458,13 +2458,6 @@ sig A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) r))). This proof object has no antecedents. *) val is_pull_quant : Expr.expr -> bool - (** Indicates whether the term is a proof for pulling quantifiers out. - - A proof for (iff P Q) where Q is in prenex normal form. - This proof object is only used if the parameter PROOF_MODE is 1. - This proof object has no antecedents *) - val is_pull_quant_star : Expr.expr -> bool - (** Indicates whether the term is a proof for pushing quantifiers in. A proof for: @@ -2658,22 +2651,6 @@ sig (and (or r_1 r_2) (or r_1' r_2'))) *) val is_nnf_neg : Expr.expr -> bool - (** Indicates whether the term is a proof for (~ P Q) here Q is in negation normal form. - - A proof for (~ P Q) where Q is in negation normal form. - - This proof object is only used if the parameter PROOF_MODE is 1. - - This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. *) - val is_nnf_star : Expr.expr -> bool - - (** Indicates whether the term is a proof for (~ P Q) where Q is in conjunctive normal form. - - A proof for (~ P Q) where Q is in conjunctive normal form. - This proof object is only used if the parameter PROOF_MODE is 1. - This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO. *) - val is_cnf_star : Expr.expr -> bool - (** Indicates whether the term is a proof for a Skolemization step Proof for: From e4cab7bc834b81c8f4d0dcf3fd62668f61e916a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Gon=C3=A7alves?= Date: Fri, 16 Mar 2018 22:04:39 +1000 Subject: [PATCH 235/263] Fix #1540 Remove extraneous function Remove extra __deepcopy__ function definition that shadows working implementation. --- src/api/python/z3/z3.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index e68d7280d..d4ff556fe 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -368,9 +368,6 @@ class AstRef(Z3PPObject): def __copy__(self): return self.translate(self.ctx) - def __deepcopy__(self): - return self.translate(self.ctx) - def hash(self): """Return a hashcode for the `self`. From 0a0b7a9635d416d117b488639666d25d6b5491be Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Fri, 16 Mar 2018 20:56:06 +0700 Subject: [PATCH 236/263] Fix minor issues in docs. --- src/api/z3_algebraic.h | 2 +- src/api/z3_api.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/z3_algebraic.h b/src/api/z3_algebraic.h index faa41bfea..49c61afef 100644 --- a/src/api/z3_algebraic.h +++ b/src/api/z3_algebraic.h @@ -31,7 +31,7 @@ extern "C" { /** @name Algebraic Numbers */ /*@{*/ /** - \brief Return Z3_TRUE if \c can be used as value in the Z3 real algebraic + \brief Return Z3_TRUE if \c a can be used as value in the Z3 real algebraic number package. def_API('Z3_algebraic_is_value', BOOL, (_in(CONTEXT), _in(AST))) diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 88d6aa1cf..87bb4d818 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -4350,7 +4350,7 @@ extern "C" { Z3_bool Z3_API Z3_is_numeral_ast(Z3_context c, Z3_ast a); /** - \brief Return true if the give AST is a real algebraic number. + \brief Return true if the given AST is a real algebraic number. def_API('Z3_is_algebraic_number', BOOL, (_in(CONTEXT), _in(AST))) */ From 86d3bbe6cb8815a20bee5ee29caff12dac9f5202 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 16 Mar 2018 07:46:27 -0700 Subject: [PATCH 237/263] added TODO markers in theory_str.h for moving to obj_map, remove include of stdbool for now Signed-off-by: Nikolaj Bjorner --- src/api/z3.h | 1 - src/smt/smt_context_pp.cpp | 50 ++++++++++++----------------------- src/smt/theory_str.cpp | 17 +++++------- src/smt/theory_str.h | 34 ++++++++---------------- src/util/obj_pair_hashtable.h | 13 +++++++++ 5 files changed, 48 insertions(+), 67 deletions(-) diff --git a/src/api/z3.h b/src/api/z3.h index b29f1d6ba..e08b0c073 100644 --- a/src/api/z3.h +++ b/src/api/z3.h @@ -22,7 +22,6 @@ Notes: #define Z3_H_ #include -#include #include "z3_macros.h" #include "z3_api.h" #include "z3_ast_containers.h" diff --git a/src/smt/smt_context_pp.cpp b/src/smt/smt_context_pp.cpp index e883e0a09..f072a1d13 100644 --- a/src/smt/smt_context_pp.cpp +++ b/src/smt/smt_context_pp.cpp @@ -43,11 +43,10 @@ namespace smt { return out << "RESOURCE_LIMIT"; case THEORY: if (!m_incomplete_theories.empty()) { - ptr_vector::const_iterator it = m_incomplete_theories.begin(); - ptr_vector::const_iterator end = m_incomplete_theories.end(); - for (bool first = true; it != end; ++it) { + bool first = true; + for (theory* th : m_incomplete_theories) { if (first) first = false; else out << " "; - out << (*it)->get_name(); + out << th->get_name(); } } else { @@ -173,12 +172,10 @@ namespace smt { void context::display_binary_clauses(std::ostream & out) const { bool first = true; - vector::const_iterator it = m_watches.begin(); - vector::const_iterator end = m_watches.end(); - for (unsigned l_idx = 0; it != end; ++it, ++l_idx) { - literal l1 = to_literal(l_idx); + unsigned l_idx = 0; + for (watch_list const& wl : m_watches) { + literal l1 = to_literal(l_idx++); literal neg_l1 = ~l1; - watch_list const & wl = *it; literal const * it2 = wl.begin_literals(); literal const * end2 = wl.end_literals(); for (; it2 != end2; ++it2) { @@ -291,10 +288,7 @@ namespace smt { } void context::display_theories(std::ostream & out) const { - ptr_vector::const_iterator it = m_theory_set.begin(); - ptr_vector::const_iterator end = m_theory_set.end(); - for (; it != end; ++it) { - theory * th = *it; + for (theory* th : m_theory_set) { th->display(out); } } @@ -393,10 +387,8 @@ namespace smt { #endif m_qmanager->collect_statistics(st); m_asserted_formulas.collect_statistics(st); - ptr_vector::const_iterator it = m_theory_set.begin(); - ptr_vector::const_iterator end = m_theory_set.end(); - for (; it != end; ++it) { - (*it)->collect_statistics(st); + for (theory* th : m_theory_set) { + th->collect_statistics(st); } } @@ -498,10 +490,7 @@ namespace smt { */ void context::display_normalized_enodes(std::ostream & out) const { out << "normalized enodes:\n"; - ptr_vector::const_iterator it = m_enodes.begin(); - ptr_vector::const_iterator end = m_enodes.end(); - for (; it != end; ++it) { - enode * n = *it; + for (enode * n : m_enodes) { out << "#"; out.width(5); out << std::left << n->get_owner_id() << " #"; @@ -532,28 +521,23 @@ namespace smt { } void context::display_enodes_lbls(std::ostream & out) const { - ptr_vector::const_iterator it = m_enodes.begin(); - ptr_vector::const_iterator end = m_enodes.end(); - for (; it != end; ++it) { - enode * n = *it; + for (enode* n : m_enodes) { n->display_lbls(out); } } void context::display_decl2enodes(std::ostream & out) const { out << "decl2enodes:\n"; - vector::const_iterator it1 = m_decl2enodes.begin(); - vector::const_iterator end1 = m_decl2enodes.end(); - for (unsigned id = 0; it1 != end1; ++it1, ++id) { - enode_vector const & v = *it1; + unsigned id = 0; + for (enode_vector const& v : m_decl2enodes) { if (!v.empty()) { out << "id " << id << " ->"; - enode_vector::const_iterator it2 = v.begin(); - enode_vector::const_iterator end2 = v.end(); - for (; it2 != end2; ++it2) - out << " #" << (*it2)->get_owner_id(); + for (enode* n : v) { + out << " #" << n->get_owner_id(); + } out << "\n"; } + ++id; } } diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 0016b8f36..30092097a 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -288,10 +288,9 @@ namespace smt { } } - static void cut_vars_map_copy(std::map & dest, std::map & src) { - std::map::iterator itor = src.begin(); - for (; itor != src.end(); itor++) { - dest[itor->first] = 1; + static void cut_vars_map_copy(obj_map & dest, obj_map & src) { + for (auto const& kv : src) { + dest.insert(kv.m_key, 1); } } @@ -306,9 +305,8 @@ namespace smt { return false; } - std::map::iterator itor = cut_var_map[n1].top()->vars.begin(); - for (; itor != cut_var_map[n1].top()->vars.end(); ++itor) { - if (cut_var_map[n2].top()->vars.find(itor->first) != cut_var_map[n2].top()->vars.end()) { + for (auto const& kv : cut_var_map[n1].top()->vars) { + if (cut_var_map[n2].top()->vars.contains(kv.m_key)) { return true; } } @@ -2572,9 +2570,8 @@ namespace smt { if (cut_var_map.contains(node)) { if (!cut_var_map[node].empty()) { xout << "[" << cut_var_map[node].top()->level << "] "; - std::map::iterator itor = cut_var_map[node].top()->vars.begin(); - for (; itor != cut_var_map[node].top()->vars.end(); ++itor) { - xout << mk_pp(itor->first, m) << ", "; + for (auto const& kv : cut_var_map[node].top()->vars) { + xout << mk_pp(kv.m_key, m) << ", "; } xout << std::endl; } diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index 64ede71b5..09d6498a4 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -77,25 +77,8 @@ public: void register_value(expr * n) override { /* Ignore */ } }; -// rather than modify obj_pair_map I inherit from it and add my own helper methods -class theory_str_contain_pair_bool_map_t : public obj_pair_map { -public: - expr * operator[](std::pair key) const { - expr * value; - bool found = this->find(key.first, key.second, value); - if (found) { - return value; - } else { - TRACE("t_str", tout << "WARNING: lookup miss in contain_pair_bool_map!" << std::endl;); - return nullptr; - } - } - - bool contains(std::pair key) const { - expr * unused; - return this->find(key.first, key.second, unused); - } -}; +// NSB: added operator[] and contains to obj_pair_hashtable +class theory_str_contain_pair_bool_map_t : public obj_pair_map {}; template class binary_search_trail : public trail { @@ -169,7 +152,7 @@ class theory_str : public theory { struct T_cut { int level; - std::map vars; + obj_map vars; T_cut() { level = -100; @@ -292,8 +275,8 @@ protected: int tmpXorVarCount; int tmpLenTestVarCount; int tmpValTestVarCount; - std::map, std::map > varForBreakConcat; - + // obj_pair_map > varForBreakConcat; + std::map, std::map > varForBreakConcat; bool avoidLoopCut; bool loopDetected; obj_map > cut_var_map; @@ -312,9 +295,11 @@ protected: obj_hashtable input_var_in_len; obj_map fvar_len_count_map; + // TBD: need to replace by obj_map for determinism std::map > fvar_lenTester_map; obj_map lenTester_fvar_map; + // TBD: need to replace by obj_map for determinism std::map > > > fvar_valueTester_map; std::map valueTester_fvar_map; @@ -322,8 +307,10 @@ protected: // This can't be an expr_ref_vector because the constructor is wrong, // we would need to modify the allocator so we pass in ast_manager + // TBD: need to replace by obj_map for determinism std::map, ptr_vector > > unroll_tries_map; std::map unroll_var_map; + // TBD: need to replace by obj_pair_map for determinism std::map, expr*> concat_eq_unroll_ast_map; expr_ref_vector contains_map; @@ -332,9 +319,10 @@ protected: //obj_map > contain_pair_idx_map; std::map > > contain_pair_idx_map; + // TBD: do a curried map for determinism. std::map, expr*> regex_in_bool_map; + // TBD: need to replace by obj_map for determinism std::map > regex_in_var_reg_str_map; - std::map regex_nfa_cache; // Regex term --> NFA svector char_set; diff --git a/src/util/obj_pair_hashtable.h b/src/util/obj_pair_hashtable.h index f002a7807..2b8924e9f 100644 --- a/src/util/obj_pair_hashtable.h +++ b/src/util/obj_pair_hashtable.h @@ -160,10 +160,23 @@ public: } return (nullptr != e); } + + Value const & find(Key1 * k1, Key2 * k2) const { + entry * e = find_core(k1, k2); + return e->get_data().get_value(); + } + + Value const& operator[](std::pair const& key) const { + return find(key.first, key.second); + } bool contains(Key1 * k1, Key2 * k2) const { return find_core(k1, k2) != nullptr; } + + bool contains(std::pair const& key) const { + return contains(key.first, key.second); + } void erase(Key1 * k1, Key2 * k2) { m_table.remove(key_data(k1, k2)); From b12a1caa0759052380d60fbd1f71a5d8436ac047 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 16 Mar 2018 09:05:44 -0700 Subject: [PATCH 238/263] fix build Signed-off-by: Nikolaj Bjorner --- src/smt/theory_str.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 30092097a..e1340c301 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -321,7 +321,7 @@ namespace smt { T_cut * varInfo = alloc(T_cut); m_cut_allocs.push_back(varInfo); varInfo->level = slevel; - varInfo->vars[node] = 1; + varInfo->vars.insert(node, 1); cut_var_map.insert(baseNode, std::stack()); cut_var_map[baseNode].push(varInfo); TRACE("str", tout << "add var info for baseNode=" << mk_pp(baseNode, get_manager()) << ", node=" << mk_pp(node, get_manager()) << " [" << slevel << "]" << std::endl;); @@ -330,7 +330,7 @@ namespace smt { T_cut * varInfo = alloc(T_cut); m_cut_allocs.push_back(varInfo); varInfo->level = slevel; - varInfo->vars[node] = 1; + varInfo->vars.insert(node, 1); cut_var_map[baseNode].push(varInfo); TRACE("str", tout << "add var info for baseNode=" << mk_pp(baseNode, get_manager()) << ", node=" << mk_pp(node, get_manager()) << " [" << slevel << "]" << std::endl;); } else { @@ -339,11 +339,11 @@ namespace smt { m_cut_allocs.push_back(varInfo); varInfo->level = slevel; cut_vars_map_copy(varInfo->vars, cut_var_map[baseNode].top()->vars); - varInfo->vars[node] = 1; + varInfo->vars.insert(node, 1); cut_var_map[baseNode].push(varInfo); TRACE("str", tout << "add var info for baseNode=" << mk_pp(baseNode, get_manager()) << ", node=" << mk_pp(node, get_manager()) << " [" << slevel << "]" << std::endl;); } else if (cut_var_map[baseNode].top()->level == slevel) { - cut_var_map[baseNode].top()->vars[node] = 1; + cut_var_map[baseNode].top()->vars.insert(node, 1); TRACE("str", tout << "add var info for baseNode=" << mk_pp(baseNode, get_manager()) << ", node=" << mk_pp(node, get_manager()) << " [" << slevel << "]" << std::endl;); } else { get_manager().raise_exception("entered illegal state during add_cut_info_one_node()"); From 5dd7e2c520b37c75bfe3c22f1e81911373e1dfed Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 16 Mar 2018 19:30:13 -0700 Subject: [PATCH 239/263] fix #1544 Signed-off-by: Nikolaj Bjorner --- src/api/z3.h | 1 - src/ast/rewriter/rewriter_def.h | 2 ++ src/model/model_evaluator.cpp | 11 +++++------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/z3.h b/src/api/z3.h index b29f1d6ba..e08b0c073 100644 --- a/src/api/z3.h +++ b/src/api/z3.h @@ -22,7 +22,6 @@ Notes: #define Z3_H_ #include -#include #include "z3_macros.h" #include "z3_api.h" #include "z3_ast_containers.h" diff --git a/src/ast/rewriter/rewriter_def.h b/src/ast/rewriter/rewriter_def.h index 878f4ef4c..dfb6542d6 100644 --- a/src/ast/rewriter/rewriter_def.h +++ b/src/ast/rewriter/rewriter_def.h @@ -194,12 +194,14 @@ bool rewriter_tpl::constant_fold(app * t, frame & fr) { result_stack().shrink(fr.m_spos); result_stack().push_back(arg); fr.m_state = REWRITE_BUILTIN; + TRACE("rewriter_step", tout << "step\n" << mk_ismt2_pp(t, m()) << "\n";); if (visit(arg, fr.m_max_depth)) { m_r = result_stack().back(); result_stack().pop_back(); result_stack().pop_back(); result_stack().push_back(m_r); cache_result(t, m_r, m_pr, fr.m_cache_result); + TRACE("rewriter_step", tout << "step 1\n" << mk_ismt2_pp(m_r, m()) << "\n";); frame_stack().pop_back(); set_new_child_flag(t); } diff --git a/src/model/model_evaluator.cpp b/src/model/model_evaluator.cpp index fd2dc7656..227e14ca6 100644 --- a/src/model/model_evaluator.cpp +++ b/src/model/model_evaluator.cpp @@ -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";); @@ -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); From aa913c564c7b41fc1a2bb3a198b91f18ff717892 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 17 Mar 2018 04:21:28 -0700 Subject: [PATCH 240/263] moving more std::map std::set to obj_*, #1529 Signed-off-by: Nikolaj Bjorner --- src/smt/theory_str.cpp | 19 ++++++++++--------- src/smt/theory_str.h | 11 +++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index e1340c301..69cf80de6 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -441,7 +441,7 @@ namespace smt { void theory_str::track_variable_scope(expr * var) { if (internal_variable_scope_levels.find(sLevel) == internal_variable_scope_levels.end()) { - internal_variable_scope_levels[sLevel] = std::set(); + internal_variable_scope_levels[sLevel] = obj_hashtable(); } internal_variable_scope_levels[sLevel].insert(var); } @@ -6468,9 +6468,9 @@ namespace smt { expr * regexTerm = a_regexIn->get_arg(1); // TODO figure out regex NFA stuff - if (regex_nfa_cache.find(regexTerm) == regex_nfa_cache.end()) { + if (!regex_nfa_cache.contains(regexTerm)) { TRACE("str", tout << "regex_nfa_cache: cache miss" << std::endl;); - regex_nfa_cache[regexTerm] = nfa(u, regexTerm); + regex_nfa_cache.insert(regexTerm, nfa(u, regexTerm)); } else { TRACE("str", tout << "regex_nfa_cache: cache hit" << std::endl;); } @@ -9286,7 +9286,7 @@ namespace smt { h++; coverAll = get_next_val_encode(options[options.size() - 1], base); } - val_range_map[val_indicator] = options[options.size() - 1]; + val_range_map.insert(val_indicator, options[options.size() - 1]); TRACE("str", tout << "value tester encoding " << "{" << std::endl; @@ -9380,7 +9380,7 @@ namespace smt { TRACE("str", tout << "no previous value testers, or none of them were in scope" << std::endl;); int tries = 0; expr * val_indicator = mk_internal_valTest_var(freeVar, len, tries); - valueTester_fvar_map[val_indicator] = freeVar; + valueTester_fvar_map.insert(val_indicator, freeVar); fvar_valueTester_map[freeVar][len].push_back(std::make_pair(sLevel, val_indicator)); print_value_tester_list(fvar_valueTester_map[freeVar][len]); return gen_val_options(freeVar, len_indicator, val_indicator, len_valueStr, tries); @@ -9430,7 +9430,7 @@ namespace smt { refresh_theory_var(valTester); } else { valTester = mk_internal_valTest_var(freeVar, len, i + 1); - valueTester_fvar_map[valTester] = freeVar; + valueTester_fvar_map.insert(valTester, freeVar); fvar_valueTester_map[freeVar][len].push_back(std::make_pair(sLevel, valTester)); print_value_tester_list(fvar_valueTester_map[freeVar][len]); } @@ -9595,7 +9595,7 @@ namespace smt { if (low.is_neg()) { toAssert = m_autil.mk_ge(cntInUnr, mk_int(0)); } else { - if (unroll_var_map.find(unrFunc) == unroll_var_map.end()) { + if (!unroll_var_map.contains(unrFunc)) { expr_ref newVar1(mk_regex_rep_var(), mgr); expr_ref newVar2(mk_regex_rep_var(), mgr); @@ -9627,8 +9627,9 @@ namespace smt { // put together toAssert = mgr.mk_and(ctx.mk_eq_atom(op0, and1), toAssert); - unroll_var_map[unrFunc] = toAssert; - } else { + unroll_var_map.insert(unrFunc, toAssert); + } + else { toAssert = unroll_var_map[unrFunc]; } } diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index 09d6498a4..508a1c905 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -286,7 +286,7 @@ protected: obj_hashtable variable_set; obj_hashtable internal_variable_set; obj_hashtable regex_variable_set; - std::map > internal_variable_scope_levels; + std::map > internal_variable_scope_levels; obj_hashtable internal_lenTest_vars; obj_hashtable internal_valTest_vars; @@ -295,21 +295,20 @@ protected: obj_hashtable input_var_in_len; obj_map fvar_len_count_map; - // TBD: need to replace by obj_map for determinism std::map > fvar_lenTester_map; obj_map lenTester_fvar_map; // TBD: need to replace by obj_map for determinism std::map > > > fvar_valueTester_map; - std::map valueTester_fvar_map; + obj_map valueTester_fvar_map; - std::map val_range_map; + obj_map val_range_map; // This can't be an expr_ref_vector because the constructor is wrong, // we would need to modify the allocator so we pass in ast_manager // TBD: need to replace by obj_map for determinism std::map, ptr_vector > > unroll_tries_map; - std::map unroll_var_map; + obj_map unroll_var_map; // TBD: need to replace by obj_pair_map for determinism std::map, expr*> concat_eq_unroll_ast_map; @@ -323,7 +322,7 @@ protected: std::map, expr*> regex_in_bool_map; // TBD: need to replace by obj_map for determinism std::map > regex_in_var_reg_str_map; - std::map regex_nfa_cache; // Regex term --> NFA + obj_map regex_nfa_cache; // Regex term --> NFA svector char_set; std::map charSetLookupTable; From 72f8e408fc39afca1f5c690b20fd86e3518ac687 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 17 Mar 2018 11:25:07 -0700 Subject: [PATCH 241/263] fix #1538 Signed-off-by: Nikolaj Bjorner --- src/smt/smt_context_pp.cpp | 6 +++--- src/smt/theory_seq.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/smt/smt_context_pp.cpp b/src/smt/smt_context_pp.cpp index f072a1d13..f4f56df5d 100644 --- a/src/smt/smt_context_pp.cpp +++ b/src/smt/smt_context_pp.cpp @@ -580,20 +580,20 @@ namespace smt { case b_justification::BIN_CLAUSE: { literal l2 = j.get_literal(); out << "bin-clause "; - display_literal(out, l2); + display_literal_verbose(out, l2); break; } case b_justification::CLAUSE: { clause * cls = j.get_clause(); out << "clause "; - if (cls) display_literals(out, cls->get_num_literals(), cls->begin_literals()); + if (cls) display_literals_verbose(out, cls->get_num_literals(), cls->begin_literals()); break; } case b_justification::JUSTIFICATION: { out << "justification " << j.get_justification()->get_from_theory() << ": "; literal_vector lits; const_cast(*m_conflict_resolution).justification2literals(j.get_justification(), lits); - display_literals(out, lits); + display_literals_verbose(out, lits); break; } default: diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index b90735a07..94841603d 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -2404,8 +2404,7 @@ bool theory_seq::add_stoi_val_axiom(expr* e) { lits.push_back(~is_digit(ith_char)); nums.push_back(digit2int(ith_char)); } - for (unsigned i = sz-1, c = 1; i > 0; c *= 10) { - --i; + for (unsigned i = sz, c = 1; i-- > 0; c *= 10) { coeff = m_autil.mk_int(c); nums[i] = m_autil.mk_mul(coeff, nums[i].get()); } @@ -2414,9 +2413,10 @@ bool theory_seq::add_stoi_val_axiom(expr* e) { lits.push_back(mk_eq(e, num, false)); ++m_stats.m_add_axiom; m_new_propagation = true; - for (unsigned i = 0; i < lits.size(); ++i) { - ctx.mark_as_relevant(lits[i]); + for (literal lit : lits) { + ctx.mark_as_relevant(lit); } + TRACE("seq", ctx.display_literals_verbose(tout, lits); tout << "\n";); ctx.mk_th_axiom(get_id(), lits.size(), lits.c_ptr()); m_stoi_axioms.insert(val); m_trail_stack.push(insert_map(m_stoi_axioms, val)); From b572639fcdfc622a7615cea821a945f5499a4f08 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 17 Mar 2018 17:49:33 -0700 Subject: [PATCH 242/263] fix #1545 Signed-off-by: Nikolaj Bjorner --- src/api/python/z3/z3.py | 27 ++++++++++++++++++++------- src/api/python/z3/z3printer.py | 4 +++- src/smt/smt_quantifier.cpp | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index d4ff556fe..36283356d 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -114,15 +114,26 @@ def _symbol2py(ctx, s): # Hack for having nary functions that can receive one argument that is the # list of arguments. +# Use this when function takes a single list of arguments def _get_args(args): - try: - if len(args) == 1 and (isinstance(args[0], tuple) or isinstance(args[0], list)): + try: + if len(args) == 1 and (isinstance(args[0], tuple) or isinstance(args[0], list)): return args[0] - elif len(args) == 1 and (isinstance(args[0], set) or isinstance(args[0], AstVector)): + elif len(args) == 1 and (isinstance(args[0], set) or isinstance(args[0], AstVector)): return [arg for arg in args[0]] + else: + return args + except: # len is not necessarily defined when args is not a sequence (use reflection?) + return args + +# Use this when function takes multiple arguments +def _get_args_ast_list(args): + try: + if isinstance(args, set) or isinstance(args, AstVector) or isinstance(args, tuple): + return [arg for arg in args] else: return args - except: # len is not necessarily defined when args is not a sequence (use reflection?) + except: return args def _to_param_value(val): @@ -7943,8 +7954,10 @@ def AtLeast(*args): return BoolRef(Z3_mk_atleast(ctx.ref(), sz, _args, k), ctx) -def _pb_args_coeffs(args): - args = _get_args(args) +def _pb_args_coeffs(args, default_ctx = None): + args = _get_args_ast_list(args) + if len(args) == 0: + return _get_ctx(default_ctx), 0, (Ast * 0)(), (ctypes.c_int * 0)() args, coeffs = zip(*args) if __debug__: _z3_assert(len(args) > 0, "Non empty list of arguments expected") @@ -7976,7 +7989,7 @@ def PbGe(args, k): ctx, sz, _args, _coeffs = _pb_args_coeffs(args) return BoolRef(Z3_mk_pbge(ctx.ref(), sz, _args, _coeffs, k), ctx) -def PbEq(args, k): +def PbEq(args, k, ctx = None): """Create a Pseudo-Boolean inequality k constraint. >>> a, b, c = Bools('a b c') diff --git a/src/api/python/z3/z3printer.py b/src/api/python/z3/z3printer.py index 3a6b7269e..8fd0c182e 100644 --- a/src/api/python/z3/z3printer.py +++ b/src/api/python/z3/z3printer.py @@ -36,7 +36,7 @@ _z3_op_to_str = { Z3_OP_CONCAT : 'Concat', Z3_OP_EXTRACT : 'Extract', Z3_OP_BV2INT : 'BV2Int', Z3_OP_ARRAY_MAP : 'Map', Z3_OP_SELECT : 'Select', Z3_OP_STORE : 'Store', Z3_OP_CONST_ARRAY : 'K', Z3_OP_ARRAY_EXT : 'Ext', - Z3_OP_PB_AT_MOST : 'AtMost', Z3_OP_PB_LE : 'PbLe', Z3_OP_PB_GE : 'PbGe' + Z3_OP_PB_AT_MOST : 'AtMost', Z3_OP_PB_LE : 'PbLe', Z3_OP_PB_GE : 'PbGe', Z3_OP_PB_EQ : 'PbEq' } # List of infix operators @@ -930,6 +930,8 @@ class Formatter: return self.pp_pbcmp(a, d, f, xs) elif k == Z3_OP_PB_GE: return self.pp_pbcmp(a, d, f, xs) + elif k == Z3_OP_PB_EQ: + return self.pp_pbcmp(a, d, f, xs) elif z3.is_pattern(a): return self.pp_pattern(a, d, xs) elif self.is_infix(k): diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index 0ca244185..1f6811a0f 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -222,7 +222,7 @@ namespace smt { final_check_status final_check_eh(bool full) { if (full) { - IF_VERBOSE(100, verbose_stream() << "(smt.final-check \"quantifiers\")\n";); + IF_VERBOSE(100, if (!m_quantifiers.empty()) verbose_stream() << "(smt.final-check \"quantifiers\")\n";); final_check_status result = m_qi_queue.final_check_eh() ? FC_DONE : FC_CONTINUE; final_check_status presult = m_plugin->final_check_eh(full); if (presult != FC_DONE) From a988d015374869c91302b45f43ff01877817d016 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 19 Mar 2018 12:25:44 -0400 Subject: [PATCH 243/263] add const to iterator loops where it can be used --- src/smt/theory_str.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 144ddb9c9..a985ca678 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -800,25 +800,25 @@ namespace smt { context & ctx = get_context(); while (can_propagate()) { TRACE("str", tout << "propagating..." << std::endl;); - for (auto el : m_basicstr_axiom_todo) { + for (auto const& el : m_basicstr_axiom_todo) { instantiate_basic_string_axioms(el); } m_basicstr_axiom_todo.reset(); TRACE("str", tout << "reset m_basicstr_axiom_todo" << std::endl;); - for (auto pair : m_str_eq_todo) { + for (auto const& pair : m_str_eq_todo) { enode * lhs = pair.first; enode * rhs = pair.second; handle_equality(lhs->get_owner(), rhs->get_owner()); } m_str_eq_todo.reset(); - for (auto el : m_concat_axiom_todo) { + for (auto const& el : m_concat_axiom_todo) { instantiate_concat_axiom(el); } m_concat_axiom_todo.reset(); - for (auto el : m_concat_eval_todo) { + for (auto const& el : m_concat_eval_todo) { try_eval_concat(el); } m_concat_eval_todo.reset(); @@ -4977,8 +4977,7 @@ namespace smt { expr_ref_vector constList(m); bool counterEgFound = false; get_const_str_asts_in_node(aConcat, constList); - //for (expr_ref_vector::iterator cstItor = constList.begin(); cstItor != constList.end(); cstItor++) { - for (auto cst : constList) { + for (auto const& cst : constList) { zstring pieceStr; u.str.is_string(cst, pieceStr); if (!strConst.contains(pieceStr)) { @@ -5118,11 +5117,7 @@ namespace smt { ast_manager & m = get_manager(); if (in_contain_idx_map(n1) && in_contain_idx_map(n2)) { - //std::set >::iterator keysItor1 = contain_pair_idx_map[n1].begin(); - //std::set >::iterator keysItor2; - - //for (; keysItor1 != contain_pair_idx_map[n1].end(); keysItor1++) { - for (auto key1 : contain_pair_idx_map[n1]) { + for (auto const& key1 : contain_pair_idx_map[n1]) { // keysItor1 is on set {<.., n1>, ..., , ...} //std::pair key1 = *keysItor1; if (key1.first == n1 && key1.second == n2) { @@ -5137,7 +5132,7 @@ namespace smt { } //for (keysItor2 = contain_pair_idx_map[n2].begin(); keysItor2 != contain_pair_idx_map[n2].end(); keysItor2++) { - for (auto key2 : contain_pair_idx_map[n2]) { + for (auto const& key2 : contain_pair_idx_map[n2]) { // keysItor2 is on set {<.., n2>, ..., , ...} //std::pair key2 = *keysItor2; // skip if the pair is eq @@ -5385,8 +5380,8 @@ namespace smt { // * key1.second = key2.second // check eqc(key1.first) and eqc(key2.first) // ----------------------------------------------------------- - for (auto eqStrVar1 : str1Eqc) { - for (auto eqStrVar2 : str2Eqc) { + for (auto const& eqStrVar1 : str1Eqc) { + for (auto const& eqStrVar2 : str2Eqc) { { expr_ref_vector litems3(m); if (n1 != n2) { @@ -6944,7 +6939,7 @@ namespace smt { } // now create a fake length tester over this finite disjunction of lengths - fvar_len_count_map[v] = 1; + fvar_len_count_map.insert(v, 1); unsigned int testNum = fvar_len_count_map[v]; expr_ref indicator(mk_internal_lenTest_var(v, testNum), m); From ebc6ec2eb5348b438b154f531791e8cab5deeb07 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 19 Mar 2018 13:33:58 -0700 Subject: [PATCH 244/263] fix #1547 by rewriting legacy recognizers to SMT-LIB2.6 style recognizers which are assumed by theory_datatype Signed-off-by: Nikolaj Bjorner --- src/ast/datatype_decl_plugin.cpp | 4 ++++ src/ast/datatype_decl_plugin.h | 1 + src/ast/rewriter/datatype_rewriter.cpp | 3 +++ src/interp/iz3interp.cpp | 12 ++++++------ src/interp/iz3translate.cpp | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/ast/datatype_decl_plugin.cpp b/src/ast/datatype_decl_plugin.cpp index 44f824959..f685c70d5 100644 --- a/src/ast/datatype_decl_plugin.cpp +++ b/src/ast/datatype_decl_plugin.cpp @@ -821,6 +821,10 @@ namespace datatype { return d; } + app* util::mk_is(func_decl * c, expr *f) { + return m.mk_app(get_constructor_is(c), 1, &f); + } + func_decl * util::get_recognizer_constructor(func_decl * recognizer) const { SASSERT(is_recognizer(recognizer)); return to_func_decl(recognizer->get_parameter(0).get_ast()); diff --git a/src/ast/datatype_decl_plugin.h b/src/ast/datatype_decl_plugin.h index e644ccbda..f32e9990d 100644 --- a/src/ast/datatype_decl_plugin.h +++ b/src/ast/datatype_decl_plugin.h @@ -362,6 +362,7 @@ namespace datatype { bool is_recognizer(app * f) const { return is_recognizer0(f) || is_is(f); } bool is_accessor(app * f) const { return is_app_of(f, m_family_id, OP_DT_ACCESSOR); } bool is_update_field(app * f) const { return is_app_of(f, m_family_id, OP_DT_UPDATE_FIELD); } + app* mk_is(func_decl * c, expr *f); ptr_vector const * get_datatype_constructors(sort * ty); unsigned get_datatype_num_constructors(sort * ty); unsigned get_datatype_num_parameter_sorts(sort * ty); diff --git a/src/ast/rewriter/datatype_rewriter.cpp b/src/ast/rewriter/datatype_rewriter.cpp index f0a95929b..194668b9c 100644 --- a/src/ast/rewriter/datatype_rewriter.cpp +++ b/src/ast/rewriter/datatype_rewriter.cpp @@ -23,6 +23,9 @@ br_status datatype_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr switch(f->get_decl_kind()) { case OP_DT_CONSTRUCTOR: return BR_FAILED; case OP_DT_RECOGNISER: + SASSERT(num_args == 1); + result = m_util.mk_is(m_util.get_recognizer_constructor(f), args[0]); + return BR_REWRITE1; case OP_DT_IS: // // simplify is_cons(cons(x,y)) -> true diff --git a/src/interp/iz3interp.cpp b/src/interp/iz3interp.cpp index 3d1d84f3c..41c968bd8 100644 --- a/src/interp/iz3interp.cpp +++ b/src/interp/iz3interp.cpp @@ -255,12 +255,12 @@ public: catch (const char *msg) { throw interpolation_failure(msg); } - catch (const iz3translation::unsupported &) { - TRACE("iz3", tout << "unsupported\n";); + catch (const iz3translation::unsupported & ex) { + TRACE("iz3", tout << "unsupported " << "\n";); throw interpolation_error(); } - catch (const iz3proof::proof_error &) { - TRACE("iz3", tout << "proof error\n";); + catch (const iz3proof::proof_error & ex) { + TRACE("iz3", tout << "proof error " << "\n";); throw interpolation_error(); } profiling::timer_stop("Proof translation"); @@ -306,8 +306,8 @@ public: catch (const char *msg) { throw interpolation_failure(msg); } - catch (const iz3translation::unsupported &) { - TRACE("iz3", tout << "unsupported\n";); + catch (const iz3translation::unsupported & ex) { + TRACE("iz3", tout << "unsupported " << "\n";); throw interpolation_error(); } catch (const iz3proof::proof_error &) { diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp index 9680ec95e..44bac0643 100644 --- a/src/interp/iz3translate.cpp +++ b/src/interp/iz3translate.cpp @@ -2029,8 +2029,8 @@ public: case PR_IFF_FALSE: { // turns ~p into p <-> false, noop for us if(is_local(con)) res = args[0]; - else - throw_unsupported(con); + else + throw_unsupported(proof); break; } case PR_COMMUTATIVITY: { From 84c30e0b60e795c212bdafa41c18d1609112fb32 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 19 Mar 2018 17:03:01 -0400 Subject: [PATCH 245/263] theory_str fixups for new collections --- src/smt/theory_str.cpp | 85 ++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 23 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index a985ca678..ec7406d8a 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -967,6 +967,15 @@ namespace smt { TRACE("str", tout << "set up basic string axioms on " << mk_pp(str->get_owner(), m) << std::endl;); + { + sort * a_sort = m.get_sort(str->get_owner()); + sort * str_sort = u.str.mk_string_sort(); + if (a_sort != str_sort) { + TRACE("str", tout << "WARNING: not setting up string axioms on non-string term " << mk_pp(str->get_owner(), m) << std::endl;); + return; + } + } + // TESTING: attempt to avoid a crash here when a variable goes out of scope if (str->get_iscope_lvl() > ctx.get_scope_level()) { TRACE("str", tout << "WARNING: skipping axiom setup on out-of-scope string term" << std::endl;); @@ -975,6 +984,7 @@ namespace smt { // generate a stronger axiom for constant strings app * a_str = str->get_owner(); + if (u.str.is_string(a_str)) { expr_ref len_str(m); len_str = mk_strlen(a_str); @@ -1202,6 +1212,12 @@ namespace smt { contains_map.push_back(ex); std::pair key = std::pair(str, substr); contain_pair_bool_map.insert(str, substr, ex); + if (!contain_pair_idx_map.contains(str)) { + contain_pair_idx_map.insert(str, std::set>()); + } + if (!contain_pair_idx_map.contains(substr)) { + contain_pair_idx_map.insert(substr, std::set>()); + } contain_pair_idx_map[str].insert(key); contain_pair_idx_map[substr].insert(key); } @@ -5824,11 +5840,10 @@ namespace smt { std::map & concatAliasMap, std::map & varConstMap, std::map & concatConstMap, std::map > & varEqConcatMap) { std::map, std::set > > groundedMap; - theory_str_contain_pair_bool_map_t::iterator containItor = contain_pair_bool_map.begin(); - for (; containItor != contain_pair_bool_map.end(); containItor++) { - expr* containBoolVar = containItor->get_value(); - expr* str = containItor->get_key1(); - expr* subStr = containItor->get_key2(); + for (auto const& kv : contain_pair_bool_map) { + expr* containBoolVar = kv.get_value(); + expr* str = kv.get_key1(); + expr* subStr = kv.get_key2(); expr* strDeAlias = dealias_node(str, varAliasMap, concatAliasMap); expr* subStrDeAlias = dealias_node(subStr, varAliasMap, concatAliasMap); @@ -6889,12 +6904,14 @@ namespace smt { if (!map_effectively_empty) { map_effectively_empty = true; - ptr_vector indicator_set = fvar_lenTester_map[v]; - for (ptr_vector::iterator it = indicator_set.begin(); it != indicator_set.end(); ++it) { - expr * indicator = *it; - if (internal_variable_set.find(indicator) != internal_variable_set.end()) { - map_effectively_empty = false; - break; + if (fvar_lenTester_map.contains(v)) { + ptr_vector indicator_set = fvar_lenTester_map[v]; + for (ptr_vector::iterator it = indicator_set.begin(); it != indicator_set.end(); ++it) { + expr * indicator = *it; + if (internal_variable_set.find(indicator) != internal_variable_set.end()) { + map_effectively_empty = false; + break; + } } } } @@ -6946,9 +6963,12 @@ namespace smt { SASSERT(indicator); m_trail.push_back(indicator); + if (!fvar_lenTester_map.contains(v)) { + fvar_lenTester_map.insert(v, ptr_vector()); + } fvar_lenTester_map[v].shrink(0); fvar_lenTester_map[v].push_back(indicator); - lenTester_fvar_map[indicator] = v; + lenTester_fvar_map.insert(indicator, v); expr_ref_vector orList(m); expr_ref_vector andList(m); @@ -7015,7 +7035,12 @@ namespace smt { } } } else { - int lenTesterCount = fvar_lenTester_map[fVar].size(); + int lenTesterCount; + if (fvar_lenTester_map.contains(fVar)) { + lenTesterCount = fvar_lenTester_map[fVar].size(); + } else { + lenTesterCount = 0; + } expr * effectiveLenInd = nullptr; zstring effectiveLenIndiStr = ""; @@ -9336,7 +9361,8 @@ namespace smt { // check whether any value tester is actually in scope TRACE("str", tout << "checking scope of previous value testers" << std::endl;); bool map_effectively_empty = true; - if (fvar_valueTester_map[freeVar].find(len) != fvar_valueTester_map[freeVar].end()) { + if (fvar_valueTester_map.contains(freeVar) && + fvar_valueTester_map[freeVar].find(len) != fvar_valueTester_map[freeVar].end()) { // there's *something* in the map, but check its scope svector > entries = fvar_valueTester_map[freeVar][len]; for (svector >::iterator it = entries.begin(); it != entries.end(); ++it) { @@ -9357,6 +9383,9 @@ namespace smt { int tries = 0; expr * val_indicator = mk_internal_valTest_var(freeVar, len, tries); valueTester_fvar_map.insert(val_indicator, freeVar); + if (!fvar_valueTester_map.contains(freeVar)) { + fvar_valueTester_map.insert(freeVar, std::map > >()); + } fvar_valueTester_map[freeVar][len].push_back(std::make_pair(sLevel, val_indicator)); print_value_tester_list(fvar_valueTester_map[freeVar][len]); return gen_val_options(freeVar, len_indicator, val_indicator, len_valueStr, tries); @@ -10240,14 +10269,16 @@ namespace smt { // assume empty and find a counterexample map_effectively_empty = true; - ptr_vector indicator_set = fvar_lenTester_map[freeVar]; - for (ptr_vector::iterator it = indicator_set.begin(); it != indicator_set.end(); ++it) { - expr * indicator = *it; - if (internal_variable_set.find(indicator) != internal_variable_set.end()) { - TRACE("str", tout <<"found active internal variable " << mk_ismt2_pp(indicator, m) - << " in fvar_lenTester_map[freeVar]" << std::endl;); - map_effectively_empty = false; - break; + if (fvar_lenTester_map.contains(freeVar)) { + ptr_vector indicator_set = fvar_lenTester_map[freeVar]; + for (ptr_vector::iterator it = indicator_set.begin(); it != indicator_set.end(); ++it) { + expr * indicator = *it; + if (internal_variable_set.find(indicator) != internal_variable_set.end()) { + TRACE("str", tout <<"found active internal variable " << mk_ismt2_pp(indicator, m) + << " in fvar_lenTester_map[freeVar]" << std::endl;); + map_effectively_empty = false; + break; + } } } CTRACE("str", map_effectively_empty, tout << "all variables in fvar_lenTester_map[freeVar] out of scope" << std::endl;); @@ -10264,6 +10295,9 @@ namespace smt { SASSERT(indicator); // since the map is "effectively empty", we can remove those variables that have left scope... + if (!fvar_lenTester_map.contains(freeVar)) { + fvar_lenTester_map.insert(freeVar, ptr_vector()); + } fvar_lenTester_map[freeVar].shrink(0); fvar_lenTester_map[freeVar].push_back(indicator); lenTester_fvar_map.insert(indicator, freeVar); @@ -10276,7 +10310,12 @@ namespace smt { expr * effectiveLenInd = nullptr; zstring effectiveLenIndiStr(""); - int lenTesterCount = (int) fvar_lenTester_map[freeVar].size(); + int lenTesterCount; + if (fvar_lenTester_map.contains(freeVar)) { + lenTesterCount = fvar_lenTester_map[freeVar].size(); + } else { + lenTesterCount = 0; + } TRACE("str", tout << lenTesterCount << " length testers in fvar_lenTester_map[" << mk_pp(freeVar, m) << "]:" << std::endl; From 5c692dc79dccb1866e5c2a402128ffe33ec14c7e Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 19 Mar 2018 18:06:42 -0400 Subject: [PATCH 246/263] fixups to theory_str indexof and axiom handling loop --- src/smt/theory_str.cpp | 190 ++++++++++++++++++++++++----------------- 1 file changed, 110 insertions(+), 80 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index ec7406d8a..534acf785 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -638,6 +638,7 @@ namespace smt { return contains; } + // note, this invokes "special-case" handling for the start index being 0 app * theory_str::mk_indexof(expr * haystack, expr * needle) { app * indexof = u.str.mk_index(haystack, needle, mk_int(0)); m_trail.push_back(indexof); @@ -823,31 +824,49 @@ namespace smt { } m_concat_eval_todo.reset(); - for (enode * e : m_library_aware_axiom_todo) { - app * a = e->get_owner(); - if (u.str.is_stoi(a)) { - instantiate_axiom_str_to_int(e); - } else if (u.str.is_itos(a)) { - instantiate_axiom_int_to_str(e); - } else if (u.str.is_at(a)) { - instantiate_axiom_CharAt(e); - } else if (u.str.is_prefix(a)) { - instantiate_axiom_prefixof(e); - } else if (u.str.is_suffix(a)) { - instantiate_axiom_suffixof(e); - } else if (u.str.is_contains(a)) { - instantiate_axiom_Contains(e); - } else if (u.str.is_index(a)) { - instantiate_axiom_Indexof(e); - } else if (u.str.is_extract(a)) { - instantiate_axiom_Substr(e); - } else if (u.str.is_replace(a)) { - instantiate_axiom_Replace(e); - } else if (u.str.is_in_re(a)) { - instantiate_axiom_RegexIn(e); + while(true) { + // Special handling: terms can recursively set up other terms + // (e.g. indexof can instantiate other indexof terms). + // - Copy the list so it can potentially be modified during setup. + // - Don't clear this list if new ones are added in the process; + // instead, set up all the new terms before proceeding. + // TODO see if any other propagate() worklists need this kind of handling + // TODO we really only need to check the new ones on each pass + unsigned start_count = m_library_aware_axiom_todo.size(); + ptr_vector axioms_tmp(m_library_aware_axiom_todo); + for (auto const& e : axioms_tmp) { + app * a = e->get_owner(); + if (u.str.is_stoi(a)) { + instantiate_axiom_str_to_int(e); + } else if (u.str.is_itos(a)) { + instantiate_axiom_int_to_str(e); + } else if (u.str.is_at(a)) { + instantiate_axiom_CharAt(e); + } else if (u.str.is_prefix(a)) { + instantiate_axiom_prefixof(e); + } else if (u.str.is_suffix(a)) { + instantiate_axiom_suffixof(e); + } else if (u.str.is_contains(a)) { + instantiate_axiom_Contains(e); + } else if (u.str.is_index(a)) { + instantiate_axiom_Indexof(e); + } else if (u.str.is_extract(a)) { + instantiate_axiom_Substr(e); + } else if (u.str.is_replace(a)) { + instantiate_axiom_Replace(e); + } else if (u.str.is_in_re(a)) { + instantiate_axiom_RegexIn(e); + } else { + TRACE("str", tout << "BUG: unhandled library-aware term " << mk_pp(e->get_owner(), get_manager()) << std::endl;); + NOT_IMPLEMENTED_YET(); + } + } + unsigned end_count = m_library_aware_axiom_todo.size(); + if (end_count > start_count) { + TRACE("str", tout << "new library-aware terms added during axiom setup -- checking again" << std::endl;); + continue; } else { - TRACE("str", tout << "BUG: unhandled library-aware term " << mk_pp(e->get_owner(), get_manager()) << std::endl;); - NOT_IMPLEMENTED_YET(); + break; } } m_library_aware_axiom_todo.reset(); @@ -1313,74 +1332,85 @@ namespace smt { } } - void theory_str::instantiate_axiom_Indexof_extended(enode * e) { + void theory_str::instantiate_axiom_Indexof_extended(enode * _e) { context & ctx = get_context(); ast_manager & m = get_manager(); - app * expr = e->get_owner(); - if (axiomatized_terms.contains(expr)) { - TRACE("str", tout << "already set up extended str.indexof axiom for " << mk_pp(expr, m) << std::endl;); + app * e = _e->get_owner(); + if (axiomatized_terms.contains(e)) { + TRACE("str", tout << "already set up extended str.indexof axiom for " << mk_pp(e, m) << std::endl;); return; } - SASSERT(expr->get_num_args() == 3); - axiomatized_terms.insert(expr); + SASSERT(e->get_num_args() == 3); + axiomatized_terms.insert(e); - TRACE("str", tout << "instantiate extended str.indexof axiom for " << mk_pp(expr, m) << std::endl;); + TRACE("str", tout << "instantiate extended str.indexof axiom for " << mk_pp(e, m) << std::endl;); - // ------------------------------------------------------------------------------- - // if (arg[2] >= length(arg[0])) // ite2 - // resAst = -1 - // else - // args[0] = prefix . suffix - // /\ indexAst = indexof(suffix, arg[1]) - // /\ args[2] = len(prefix) - // /\ if (indexAst == -1) resAst = indexAst // ite3 - // else resAst = args[2] + indexAst - // ------------------------------------------------------------------------------- + // str.indexof(H, N, i): + // i < 0 --> -1 + // i == 0 --> str.indexof(H, N, 0) + // i >= len(H) --> -1 + // 0 < i < len(H) --> + // H = hd ++ tl + // len(hd) = i + // str.indexof(tl, N, 0) - expr_ref resAst(mk_int_var("res"), m); - expr_ref indexAst(mk_int_var("index"), m); - expr_ref prefix(mk_str_var("prefix"), m); - expr_ref suffix(mk_str_var("suffix"), m); - expr_ref prefixLen(mk_strlen(prefix), m); - expr_ref zeroAst(mk_int(0), m); - expr_ref negOneAst(mk_int(-1), m); + expr * H; // "haystack" + expr * N; // "needle" + expr * i; // start index + u.str.is_index(e, H, N, i); - expr_ref ite3(m.mk_ite( - ctx.mk_eq_atom(indexAst, negOneAst), - ctx.mk_eq_atom(resAst, negOneAst), - ctx.mk_eq_atom(resAst, m_autil.mk_add(expr->get_arg(2), indexAst)) - ),m); + expr_ref minus_one(m_autil.mk_numeral(rational::minus_one(), true), m); + expr_ref zero(m_autil.mk_numeral(rational::zero(), true), m); - expr_ref_vector ite2ElseItems(m); - ite2ElseItems.push_back(ctx.mk_eq_atom(expr->get_arg(0), mk_concat(prefix, suffix))); - ite2ElseItems.push_back(ctx.mk_eq_atom(indexAst, mk_indexof(suffix, expr->get_arg(1)))); - ite2ElseItems.push_back(ctx.mk_eq_atom(expr->get_arg(2), prefixLen)); - ite2ElseItems.push_back(ite3); - expr_ref ite2Else(mk_and(ite2ElseItems), m); - SASSERT(ite2Else); + // case split - expr_ref ite2(m.mk_ite( - //m_autil.mk_ge(expr->get_arg(2), mk_strlen(expr->get_arg(0))), - m_autil.mk_ge(m_autil.mk_add(expr->get_arg(2), m_autil.mk_mul(mk_int(-1), mk_strlen(expr->get_arg(0)))), zeroAst), - ctx.mk_eq_atom(resAst, negOneAst), - ite2Else - ), m); - SASSERT(ite2); + // case 1: i < 0 + { + expr_ref premise(m_autil.mk_le(i, minus_one), m); + expr_ref conclusion(ctx.mk_eq_atom(e, minus_one), m); + assert_implication(premise, conclusion); + } - expr_ref ite1(m.mk_ite( - //m_autil.mk_lt(expr->get_arg(2), zeroAst), - mk_not(m, m_autil.mk_ge(expr->get_arg(2), zeroAst)), - ctx.mk_eq_atom(resAst, mk_indexof(expr->get_arg(0), expr->get_arg(1))), - ite2 - ), m); - SASSERT(ite1); - assert_axiom(ite1); + // case 2: i = 0 + { + expr_ref premise(ctx.mk_eq_atom(i, zero), m); + // reduction to simpler case + expr_ref conclusion(ctx.mk_eq_atom(e, mk_indexof(H, N)), m); + assert_implication(premise, conclusion); + } + // case 3: i >= len(H) + { + //expr_ref _premise(m_autil.mk_ge(i, mk_strlen(H)), m); + //expr_ref premise(_premise); + //th_rewriter rw(m); + //rw(premise); + expr_ref premise(m_autil.mk_ge(m_autil.mk_add(i, m_autil.mk_mul(minus_one, mk_strlen(H))), zero), m); + expr_ref conclusion(ctx.mk_eq_atom(e, minus_one), m); + assert_implication(premise, conclusion); + } + // case 4: 0 < i < len(H) + { + expr_ref premise1(m_autil.mk_gt(i, zero), m); + expr_ref premise2(m_autil.mk_lt(i, mk_strlen(H)), m); + expr_ref _premise(m.mk_and(premise1, premise2), m); + expr_ref premise(_premise); + th_rewriter rw(m); + rw(premise); - expr_ref reduceTerm(ctx.mk_eq_atom(expr, resAst), m); - SASSERT(reduceTerm); - assert_axiom(reduceTerm); + expr_ref hd(mk_str_var("hd"), m); + expr_ref tl(mk_str_var("tl"), m); + expr_ref_vector conclusion_terms(m); + conclusion_terms.push_back(ctx.mk_eq_atom(H, mk_concat(hd, tl))); + conclusion_terms.push_back(ctx.mk_eq_atom(mk_strlen(hd), i)); + conclusion_terms.push_back(ctx.mk_eq_atom(e, mk_indexof(tl, N))); + + expr_ref conclusion(mk_and(conclusion_terms), m); + assert_implication(premise, conclusion); + } + + /* { // heuristic: integrate with str.contains information // (but don't introduce it if it isn't already in the instance) @@ -1394,6 +1424,7 @@ namespace smt { // we can't assert this during init_search as it breaks an invariant if the instance becomes inconsistent m_delayed_axiom_setup_terms.push_back(containsAxiom); } + */ } void theory_str::instantiate_axiom_LastIndexof(enode * e) { @@ -7411,8 +7442,7 @@ namespace smt { if (is_app(ex)) { app * ap = to_app(ex); - // TODO indexof2/lastindexof - if (u.str.is_index(ap) /* || is_Indexof2(ap) || is_LastIndexof(ap) */) { + if (u.str.is_index(ap)) { m_library_aware_axiom_todo.push_back(n); } else if (u.str.is_stoi(ap)) { TRACE("str", tout << "found string-integer conversion term: " << mk_pp(ex, get_manager()) << std::endl;); From 1f4bfcb4e5a6dee0e4e5df70f288c6b9a44fd3a1 Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 19 Mar 2018 18:10:06 -0400 Subject: [PATCH 247/263] fix indexof subterm --- src/smt/theory_str.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 534acf785..16fd28d79 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -1392,7 +1392,8 @@ namespace smt { // case 4: 0 < i < len(H) { expr_ref premise1(m_autil.mk_gt(i, zero), m); - expr_ref premise2(m_autil.mk_lt(i, mk_strlen(H)), m); + //expr_ref premise2(m_autil.mk_lt(i, mk_strlen(H)), m); + expr_ref premise2(m.mk_not(m_autil.mk_ge(m_autil.mk_add(i, m_autil.mk_mul(minus_one, mk_strlen(H))), zero)), m); expr_ref _premise(m.mk_and(premise1, premise2), m); expr_ref premise(_premise); th_rewriter rw(m); From d26eddf77671dfefb4832c7455077a191751736d Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 19 Mar 2018 18:31:26 -0400 Subject: [PATCH 248/263] re-add indexof-contains heuristic --- src/smt/theory_str.cpp | 23 +++++++++++++++-------- src/smt/theory_str.h | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 16fd28d79..ec554df7b 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -50,6 +50,7 @@ namespace smt { m_factory(nullptr), m_unused_id(0), m_delayed_axiom_setup_terms(m), + m_delayed_assertions_todo(m), tmpStringVarCount(0), tmpXorVarCount(0), tmpLenTestVarCount(0), @@ -793,7 +794,8 @@ namespace smt { return !m_basicstr_axiom_todo.empty() || !m_str_eq_todo.empty() || !m_concat_axiom_todo.empty() || !m_concat_eval_todo.empty() || !m_library_aware_axiom_todo.empty() - || !m_delayed_axiom_setup_terms.empty(); + || !m_delayed_axiom_setup_terms.empty() + || (search_started && !m_delayed_assertions_todo.empty()) ; } @@ -877,6 +879,13 @@ namespace smt { set_up_axioms(el); } m_delayed_axiom_setup_terms.reset(); + + if (search_started) { + for (auto const& el : m_delayed_assertions_todo) { + assert_axiom(el); + } + m_delayed_assertions_todo.reset(); + } } } @@ -1327,8 +1336,9 @@ namespace smt { expr_ref conclusion(m_autil.mk_ge(ex, zeroAst), m); expr_ref containsAxiom(ctx.mk_eq_atom(premise, conclusion), m); SASSERT(containsAxiom); + // we can't assert this during init_search as it breaks an invariant if the instance becomes inconsistent - m_delayed_axiom_setup_terms.push_back(containsAxiom); + //m_delayed_axiom_setup_terms.push_back(containsAxiom); } } @@ -1411,21 +1421,18 @@ namespace smt { assert_implication(premise, conclusion); } - /* { // heuristic: integrate with str.contains information // (but don't introduce it if it isn't already in the instance) - expr_ref haystack(expr->get_arg(0), m), needle(expr->get_arg(1), m), startIdx(expr->get_arg(2), m); // (H contains N) <==> (H indexof N, i) >= 0 - expr_ref premise(u.str.mk_contains(haystack, needle), m); + expr_ref premise(u.str.mk_contains(H, N), m); ctx.internalize(premise, false); - expr_ref conclusion(m_autil.mk_ge(expr, zeroAst), m); + expr_ref conclusion(m_autil.mk_ge(e, zero), m); expr_ref containsAxiom(ctx.mk_eq_atom(premise, conclusion), m); SASSERT(containsAxiom); // we can't assert this during init_search as it breaks an invariant if the instance becomes inconsistent - m_delayed_axiom_setup_terms.push_back(containsAxiom); + m_delayed_assertions_todo.push_back(containsAxiom); } - */ } void theory_str::instantiate_axiom_LastIndexof(enode * e) { diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index cd491ac55..5378b05f3 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -262,6 +262,7 @@ protected: ptr_vector m_concat_axiom_todo; ptr_vector m_string_constant_length_todo; ptr_vector m_concat_eval_todo; + expr_ref_vector m_delayed_assertions_todo; // enode lists for library-aware/high-level string terms (e.g. substr, contains) ptr_vector m_library_aware_axiom_todo; From 7759d05efee280bd2360584cab43ec33a1d328ba Mon Sep 17 00:00:00 2001 From: Murphy Berzish Date: Mon, 19 Mar 2018 23:09:07 -0400 Subject: [PATCH 249/263] fix use-after-free --- src/smt/theory_str.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index ec554df7b..5a39659e8 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -803,8 +803,20 @@ namespace smt { context & ctx = get_context(); while (can_propagate()) { TRACE("str", tout << "propagating..." << std::endl;); - for (auto const& el : m_basicstr_axiom_todo) { - instantiate_basic_string_axioms(el); + while(true) { + // this can potentially recursively activate itself + unsigned start_count = m_basicstr_axiom_todo.size(); + ptr_vector axioms_tmp(m_basicstr_axiom_todo); + for (auto const& el : axioms_tmp) { + instantiate_basic_string_axioms(el); + } + unsigned end_count = m_basicstr_axiom_todo.size(); + if (end_count > start_count) { + TRACE("str", tout << "new basic string axiom terms added -- checking again" << std::endl;); + continue; + } else { + break; + } } m_basicstr_axiom_todo.reset(); TRACE("str", tout << "reset m_basicstr_axiom_todo" << std::endl;); From eb6bbd390a93b125a70e4b554b83357dca31e05d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 08:33:09 -0700 Subject: [PATCH 250/263] vsts script Signed-off-by: Nikolaj Bjorner --- scripts/vsts-vs2017.cmd | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/vsts-vs2017.cmd diff --git a/scripts/vsts-vs2017.cmd b/scripts/vsts-vs2017.cmd new file mode 100644 index 000000000..3b3a60231 --- /dev/null +++ b/scripts/vsts-vs2017.cmd @@ -0,0 +1,40 @@ +echo "Build" +md build +cd build +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat" +cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BINDINGS=True -G "NMake Makefiles" ../ +nmake +rem TBD: test error level + +echo "Test python bindings" +pushd python +python z3test.py z3 +python z3test.py z3num +popd + +echo "Build and run examples" +nmake cpp_example +examples\cpp_example_build_dir\cpp_example.exe + +nmake c_example +examples\c_example_build_dir\c_example.exe + +rem nmake java_example +rem java_example.exe + +rem nmake dotnet_example +rem dotnet_example.exe + +echo "Build and run unit tests" +nmake test-z3 +rem TBD: test error level +rem test-z3.exe -a + + +cd .. +echo "Run regression tests" +git clone https://github.com/z3prover/z3test z3test +echo "test-benchmarks" +python z3test\scripts\test_benchmarks.py build\z3.exe z3test\regressions\smt2 +echo "benchmarks tested" + From 0d13a2812ee06d2cf3c489e3b40434f5f3e0ec55 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 09:26:39 -0700 Subject: [PATCH 251/263] add error checking and command argument Signed-off-by: Nikolaj Bjorner --- scripts/vsts-vs2017.cmd | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/vsts-vs2017.cmd b/scripts/vsts-vs2017.cmd index 3b3a60231..d4c1e34b4 100644 --- a/scripts/vsts-vs2017.cmd +++ b/scripts/vsts-vs2017.cmd @@ -1,29 +1,37 @@ +rem Supply argument x64 or x86 + echo "Build" md build cd build -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat" +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars.bat" %1 cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BINDINGS=True -G "NMake Makefiles" ../ nmake -rem TBD: test error level +if ERRORLEVEL 1 exit 1 echo "Test python bindings" pushd python python z3test.py z3 +if ERRORLEVEL 1 exit 1 python z3test.py z3num +if ERRORLEVEL 1 exit 1 popd echo "Build and run examples" nmake cpp_example examples\cpp_example_build_dir\cpp_example.exe +if ERRORLEVEL 1 exit 1 nmake c_example examples\c_example_build_dir\c_example.exe +if ERRORLEVEL 1 exit 1 rem nmake java_example rem java_example.exe +if ERRORLEVEL 1 exit 1 rem nmake dotnet_example rem dotnet_example.exe +if ERRORLEVEL 1 exit 1 echo "Build and run unit tests" nmake test-z3 @@ -36,5 +44,6 @@ echo "Run regression tests" git clone https://github.com/z3prover/z3test z3test echo "test-benchmarks" python z3test\scripts\test_benchmarks.py build\z3.exe z3test\regressions\smt2 +if ERRORLEVEL 1 exit 1 echo "benchmarks tested" From db7844bef733d3f225d90988034f974945983c91 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 09:33:23 -0700 Subject: [PATCH 252/263] adding build definition Signed-off-by: Nikolaj Bjorner --- README.md | 6 +++--- scripts/vsts-vs2017.cmd | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 70956d439..899d23385 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ See the [release notes](RELEASE_NOTES) for notes on various stable releases of Z ## Build status -| Windows x86 | Windows x64 | Ubuntu x64 | Debian x64 | OSX | TravisCI | -| ----------- | ----------- | ---------- | ---------- | --- | -------- | -[![win32-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=4) | [![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/7/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=7) | [![ubuntu-x64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/3/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=3) | [![debian-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/5/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=5) | [![osx-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/2/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=2) | [![Build Status](https://travis-ci.org/Z3Prover/z3.svg?branch=master)](https://travis-ci.org/Z3Prover/z3) +| Windows x64 | Windows x86 | Windows x64 | Ubuntu x64 | Debian x64 | OSX | TravisCI | +| ----------- | ----------- | ----------- | ---------- | ---------- | --- | -------- | +[![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://z3build.visualstudio.com/Z3Build/_build/index?definitionId=2) [![win32-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=4) | [![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/7/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=7) | [![ubuntu-x64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/3/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=3) | [![debian-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/5/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=5) | [![osx-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/2/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=2) | [![Build Status](https://travis-ci.org/Z3Prover/z3.svg?branch=master)](https://travis-ci.org/Z3Prover/z3) [1]: #building-z3-on-windows-using-visual-studio-command-prompt [2]: #building-z3-using-make-and-gccclang diff --git a/scripts/vsts-vs2017.cmd b/scripts/vsts-vs2017.cmd index d4c1e34b4..fe2f55bca 100644 --- a/scripts/vsts-vs2017.cmd +++ b/scripts/vsts-vs2017.cmd @@ -3,7 +3,7 @@ rem Supply argument x64 or x86 echo "Build" md build cd build -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars.bat" %1 +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %1 cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BINDINGS=True -G "NMake Makefiles" ../ nmake if ERRORLEVEL 1 exit 1 From d8462807c3bae35368f07f954189e279ca7a3f2a Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 09:35:51 -0700 Subject: [PATCH 253/263] add missin bar Signed-off-by: Nikolaj Bjorner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 899d23385..d501c5d5c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ See the [release notes](RELEASE_NOTES) for notes on various stable releases of Z | Windows x64 | Windows x86 | Windows x64 | Ubuntu x64 | Debian x64 | OSX | TravisCI | | ----------- | ----------- | ----------- | ---------- | ---------- | --- | -------- | -[![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://z3build.visualstudio.com/Z3Build/_build/index?definitionId=2) [![win32-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=4) | [![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/7/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=7) | [![ubuntu-x64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/3/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=3) | [![debian-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/5/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=5) | [![osx-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/2/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=2) | [![Build Status](https://travis-ci.org/Z3Prover/z3.svg?branch=master)](https://travis-ci.org/Z3Prover/z3) +[![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://z3build.visualstudio.com/Z3Build/_build/index?definitionId=2) | [![win32-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=4) | [![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/7/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=7) | [![ubuntu-x64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/3/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=3) | [![debian-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/5/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=5) | [![osx-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/2/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=2) | [![Build Status](https://travis-ci.org/Z3Prover/z3.svg?branch=master)](https://travis-ci.org/Z3Prover/z3) [1]: #building-z3-on-windows-using-visual-studio-command-prompt [2]: #building-z3-using-make-and-gccclang From f7dfc39984f2f86ea31e719d2de5a371a08c8777 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 12:20:40 -0700 Subject: [PATCH 254/263] add vstsvs2013 outline Signed-off-by: Nikolaj Bjorner --- scripts/vsts-vs2013.cmd | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 scripts/vsts-vs2013.cmd diff --git a/scripts/vsts-vs2013.cmd b/scripts/vsts-vs2013.cmd new file mode 100644 index 000000000..baf9f4bb4 --- /dev/null +++ b/scripts/vsts-vs2013.cmd @@ -0,0 +1,49 @@ + +set +echo "Build" +md build +cd build +call "C:\Program Files (x86)\Microsoft Visual Studio\2013\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 +cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BINDINGS=True -G "NMake Makefiles" ../ +nmake +if ERRORLEVEL 1 exit 1 + +echo "Test python bindings" +pushd python +python z3test.py z3 +if ERRORLEVEL 1 exit 1 +python z3test.py z3num +if ERRORLEVEL 1 exit 1 +popd + +echo "Build and run examples" +nmake cpp_example +examples\cpp_example_build_dir\cpp_example.exe +if ERRORLEVEL 1 exit 1 + +nmake c_example +examples\c_example_build_dir\c_example.exe +if ERRORLEVEL 1 exit 1 + +rem nmake java_example +rem java_example.exe +if ERRORLEVEL 1 exit 1 + +rem nmake dotnet_example +rem dotnet_example.exe +if ERRORLEVEL 1 exit 1 + +echo "Build and run unit tests" +nmake test-z3 +rem TBD: test error level +rem test-z3.exe -a + + +cd .. +echo "Run regression tests" +git clone https://github.com/z3prover/z3test z3test +echo "test-benchmarks" +python z3test\scripts\test_benchmarks.py build\z3.exe z3test\regressions\smt2 +if ERRORLEVEL 1 exit 1 +echo "benchmarks tested" + From 6ee4efe93a027abc705c9cd756f2c3e4ea308602 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 12:48:21 -0700 Subject: [PATCH 255/263] remove python tests from x86 build Signed-off-by: Nikolaj Bjorner --- scripts/vsts-vs2017.cmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/vsts-vs2017.cmd b/scripts/vsts-vs2017.cmd index fe2f55bca..4ec4deca9 100644 --- a/scripts/vsts-vs2017.cmd +++ b/scripts/vsts-vs2017.cmd @@ -8,6 +8,7 @@ cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BIN nmake if ERRORLEVEL 1 exit 1 +if %1 == "x86" goto :BUILD_EXAMPLES echo "Test python bindings" pushd python python z3test.py z3 @@ -16,6 +17,7 @@ python z3test.py z3num if ERRORLEVEL 1 exit 1 popd +:BUILD_EXAMPLES echo "Build and run examples" nmake cpp_example examples\cpp_example_build_dir\cpp_example.exe From 8c4ea7983f5acc24204daab2658f6fc9d45a6015 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 12:59:42 -0700 Subject: [PATCH 256/263] use vc path in 2013 Signed-off-by: Nikolaj Bjorner --- scripts/vsts-vs2013.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/vsts-vs2013.cmd b/scripts/vsts-vs2013.cmd index baf9f4bb4..203c2668e 100644 --- a/scripts/vsts-vs2013.cmd +++ b/scripts/vsts-vs2013.cmd @@ -3,7 +3,7 @@ set echo "Build" md build cd build -call "C:\Program Files (x86)\Microsoft Visual Studio\2013\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 +call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64 cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BINDINGS=True -G "NMake Makefiles" ../ nmake if ERRORLEVEL 1 exit 1 From 931dbd5933d77ba4a63b63259a339fa03410f661 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 13:37:04 -0700 Subject: [PATCH 257/263] remove python doc test Signed-off-by: Nikolaj Bjorner --- scripts/vsts-vs2013.cmd | 14 +++---- src/smt/theory_str.cpp | 87 +++++++++++++++++----------------------- src/smt/theory_str.h | 3 +- src/util/hashtable.h | 17 ++++---- src/util/obj_hashtable.h | 3 ++ 5 files changed, 55 insertions(+), 69 deletions(-) diff --git a/scripts/vsts-vs2013.cmd b/scripts/vsts-vs2013.cmd index 203c2668e..1676f3e2d 100644 --- a/scripts/vsts-vs2013.cmd +++ b/scripts/vsts-vs2013.cmd @@ -8,13 +8,13 @@ cmake -DBUILD_DOTNET_BINDINGS=True -DBUILD_JAVA_BINDINGS=True -DBUILD_PYTHON_BIN nmake if ERRORLEVEL 1 exit 1 -echo "Test python bindings" -pushd python -python z3test.py z3 -if ERRORLEVEL 1 exit 1 -python z3test.py z3num -if ERRORLEVEL 1 exit 1 -popd +rem echo "Test python bindings" +rem pushd python +rem python z3test.py z3 +rem if ERRORLEVEL 1 exit 1 +rem python z3test.py z3num +rem if ERRORLEVEL 1 exit 1 +rem popd echo "Build and run examples" nmake cpp_example diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index 69cf80de6..f61293a5f 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -169,6 +169,8 @@ namespace smt { } void theory_str::assert_axiom(expr * _e) { + if (_e == nullptr) + return; if (opt_VerifyFinalCheckProgress) { finalCheckProgressIndicator = true; } @@ -6914,10 +6916,8 @@ namespace smt { if (!map_effectively_empty) { map_effectively_empty = true; - ptr_vector indicator_set = fvar_lenTester_map[v]; - for (ptr_vector::iterator it = indicator_set.begin(); it != indicator_set.end(); ++it) { - expr * indicator = *it; - if (internal_variable_set.find(indicator) != internal_variable_set.end()) { + for (expr * indicator : fvar_lenTester_map[v]) { + if (internal_variable_set.contains(indicator)) { map_effectively_empty = false; break; } @@ -8977,12 +8977,12 @@ namespace smt { CTRACE("str", needToAssignFreeVars, tout << "Need to assign values to the following free variables:" << std::endl; - for (std::set::iterator itx = free_variables.begin(); itx != free_variables.end(); ++itx) { - tout << mk_ismt2_pp(*itx, m) << std::endl; + for (expr* v : free_variables) { + tout << mk_ismt2_pp(v, m) << std::endl; } tout << "freeVar_map has the following entries:" << std::endl; - for (std::map::iterator fvIt = freeVar_map.begin(); fvIt != freeVar_map.end(); fvIt++) { - expr * var = fvIt->first; + for (auto const& kv : freeVar_map) { + expr * var = kv.first; tout << mk_ismt2_pp(var, m) << std::endl; } ); @@ -9360,7 +9360,7 @@ namespace smt { // check whether any value tester is actually in scope TRACE("str", tout << "checking scope of previous value testers" << std::endl;); bool map_effectively_empty = true; - if (fvar_valueTester_map[freeVar].find(len) != fvar_valueTester_map[freeVar].end()) { + if (fvar_valueTester_map[freeVar].find(len) != fvar_valueTester_map[freeVar].end()) { // there's *something* in the map, but check its scope svector > entries = fvar_valueTester_map[freeVar][len]; for (svector >::iterator it = entries.begin(); it != entries.end(); ++it) { @@ -9721,8 +9721,8 @@ namespace smt { int dist = opt_LCMUnrollStep; expr_ref_vector litems(mgr); expr_ref moreAst(mk_string("more"), mgr); - for (std::set::iterator itor = unrolls.begin(); itor != unrolls.end(); itor++) { - expr_ref item(ctx.mk_eq_atom(var, *itor), mgr); + for (expr * e : unrolls) { + expr_ref item(ctx.mk_eq_atom(var, e), mgr); TRACE("str", tout << "considering unroll " << mk_pp(item, mgr) << std::endl;); litems.push_back(item); } @@ -9731,10 +9731,8 @@ namespace smt { ptr_vector outOfScopeTesters; - for (ptr_vector::iterator it = unroll_tries_map[var][unrolls].begin(); - it != unroll_tries_map[var][unrolls].end(); ++it) { - expr * tester = *it; - bool inScope = (internal_unrollTest_vars.find(tester) != internal_unrollTest_vars.end()); + for (expr * tester : unroll_tries_map[var][unrolls]) { + bool inScope = internal_unrollTest_vars.contains(tester); TRACE("str", tout << "unroll test var " << mk_pp(tester, mgr) << (inScope ? " in scope" : " out of scope") << std::endl;); @@ -9743,12 +9741,10 @@ namespace smt { } } - for (ptr_vector::iterator it = outOfScopeTesters.begin(); - it != outOfScopeTesters.end(); ++it) { - unroll_tries_map[var][unrolls].erase(*it); + for (expr* e : outOfScopeTesters) { + unroll_tries_map[var][unrolls].erase(e); } - if (unroll_tries_map[var][unrolls].size() == 0) { unroll_tries_map[var][unrolls].push_back(mk_unroll_test_var()); } @@ -10265,9 +10261,8 @@ namespace smt { // assume empty and find a counterexample map_effectively_empty = true; ptr_vector indicator_set = fvar_lenTester_map[freeVar]; - for (ptr_vector::iterator it = indicator_set.begin(); it != indicator_set.end(); ++it) { - expr * indicator = *it; - if (internal_variable_set.find(indicator) != internal_variable_set.end()) { + for (expr * indicator : indicator_set) { + if (internal_variable_set.contains(indicator)) { TRACE("str", tout <<"found active internal variable " << mk_ismt2_pp(indicator, m) << " in fvar_lenTester_map[freeVar]" << std::endl;); map_effectively_empty = false; @@ -10437,14 +10432,14 @@ namespace smt { void theory_str::process_free_var(std::map & freeVar_map) { context & ctx = get_context(); - std::set eqcRepSet; - std::set leafVarSet; - std::map > aloneVars; + obj_hashtable eqcRepSet; + obj_hashtable leafVarSet; + std::map > aloneVars; - for (std::map::iterator fvIt = freeVar_map.begin(); fvIt != freeVar_map.end(); fvIt++) { - expr * freeVar = fvIt->first; + for (auto const& kv : freeVar_map) { + expr * freeVar = kv.first; // skip all regular expression vars - if (regex_variable_set.find(freeVar) != regex_variable_set.end()) { + if (regex_variable_set.contains(freeVar)) { continue; } @@ -10454,10 +10449,10 @@ namespace smt { get_var_in_eqc(freeVar, eqVarSet); bool duplicated = false; expr * dupVar = nullptr; - for (std::set::iterator itorEqv = eqVarSet.begin(); itorEqv != eqVarSet.end(); itorEqv++) { - if (eqcRepSet.find(*itorEqv) != eqcRepSet.end()) { + for (expr* eq : eqVarSet) { + if (eqcRepSet.contains(eq)) { duplicated = true; - dupVar = *itorEqv; + dupVar = eq; break; } } @@ -10470,13 +10465,9 @@ namespace smt { } } - for (std::set::iterator fvIt = eqcRepSet.begin(); fvIt != eqcRepSet.end(); fvIt++) { - bool standAlone = true; - expr * freeVar = *fvIt; + for (expr * freeVar : eqcRepSet) { // has length constraint initially - if (input_var_in_len.find(freeVar) != input_var_in_len.end()) { - standAlone = false; - } + bool standAlone = !input_var_in_len.contains(freeVar); // iterate parents if (standAlone) { // I hope this works! @@ -10507,25 +10498,19 @@ namespace smt { } } - for(std::set::iterator itor1 = leafVarSet.begin(); - itor1 != leafVarSet.end(); ++itor1) { - expr * toAssert = gen_len_val_options_for_free_var(*itor1, nullptr, ""); + for (expr* lv : leafVarSet) { + expr * toAssert = gen_len_val_options_for_free_var(lv, nullptr, ""); // gen_len_val_options_for_free_var() can legally return NULL, // as methods that it calls may assert their own axioms instead. - if (toAssert != nullptr) { - assert_axiom(toAssert); - } + if (toAssert) assert_axiom(toAssert); + } - for (std::map >::iterator mItor = aloneVars.begin(); - mItor != aloneVars.end(); ++mItor) { - std::set::iterator itor2 = mItor->second.begin(); - for(; itor2 != mItor->second.end(); ++itor2) { - expr * toAssert = gen_len_val_options_for_free_var(*itor2, nullptr, ""); + for (auto const& kv : aloneVars) { + for (expr* av : kv.second) { + expr * toAssert = gen_len_val_options_for_free_var(av, nullptr, ""); // same deal with returning a NULL axiom here - if(toAssert != nullptr) { - assert_axiom(toAssert); - } + if (toAssert) assert_axiom(toAssert); } } } diff --git a/src/smt/theory_str.h b/src/smt/theory_str.h index 508a1c905..0a8495b14 100644 --- a/src/smt/theory_str.h +++ b/src/smt/theory_str.h @@ -295,7 +295,8 @@ protected: obj_hashtable input_var_in_len; obj_map fvar_len_count_map; - std::map > fvar_lenTester_map; + // std::map > fvar_lenTester_map; + obj_map > fvar_lenTester_map; obj_map lenTester_fvar_map; // TBD: need to replace by obj_map for determinism diff --git a/src/util/hashtable.h b/src/util/hashtable.h index 742438814..4dc05fe4d 100644 --- a/src/util/hashtable.h +++ b/src/util/hashtable.h @@ -600,9 +600,8 @@ public: core_hashtable& operator|=(core_hashtable const& other) { if (this == &other) return *this; - iterator i = other.begin(), e = other.end(); - for (; i != e; ++i) { - insert(*i); + for (const data& d : other) { + insert(d); } return *this; } @@ -610,10 +609,9 @@ public: core_hashtable& operator&=(core_hashtable const& other) { if (this == &other) return *this; core_hashtable copy(*this); - iterator i = copy.begin(), e = copy.end(); - for (; i != e; ++i) { - if (!other.contains(*i)) { - remove(*i); + for (const data& d : copy) { + if (!other.contains(d)) { + remove(d); } } return *this; @@ -622,9 +620,8 @@ public: core_hashtable& operator=(core_hashtable const& other) { if (this == &other) return *this; reset(); - iterator i = other.begin(), e = other.end(); - for (; i != e; ++i) { - insert(*i); + for (const data& d : e) { + insert(d); } return *this; } diff --git a/src/util/obj_hashtable.h b/src/util/obj_hashtable.h index 8826e8b76..d042779a8 100644 --- a/src/util/obj_hashtable.h +++ b/src/util/obj_hashtable.h @@ -174,6 +174,9 @@ public: value & find(key * k) { obj_map_entry * e = find_core(k); + if (!e) { + e = insert_if_not_there2(k, value()); + } SASSERT(e); return e->get_data().m_value; } From 4529ad933ac92737e51fb90fbd3b9bdb9e100840 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Tue, 20 Mar 2018 15:19:05 -0700 Subject: [PATCH 258/263] add vstsmac Signed-off-by: Nikolaj Bjorner --- scripts/vsts-mac.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 scripts/vsts-mac.sh diff --git a/scripts/vsts-mac.sh b/scripts/vsts-mac.sh new file mode 100644 index 000000000..807631bba --- /dev/null +++ b/scripts/vsts-mac.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +mkdir build +CSC=/usr/bin/csc GACUTIL=/usr/bin/gacutil CXX=clang++ CC=clang python scripts/mk_make.py -x --dotnet --java --python +cd build +make + + + From 3765bde5e993d78cfbcf43a2999b45b18ed7866d Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 22 Mar 2018 20:19:08 -0700 Subject: [PATCH 259/263] updated OSX build Signed-off-by: Nikolaj Bjorner --- scripts/vsts-mac.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/vsts-mac.sh b/scripts/vsts-mac.sh index 807631bba..9be53967f 100644 --- a/scripts/vsts-mac.sh +++ b/scripts/vsts-mac.sh @@ -1,9 +1,19 @@ #!/bin/sh +cd .. mkdir build -CSC=/usr/bin/csc GACUTIL=/usr/bin/gacutil CXX=clang++ CC=clang python scripts/mk_make.py -x --dotnet --java --python +CSC=/usr/bin/csc GACUTIL=/usr/bin/gacutil CXX=clang++ CC=clang python scripts/mk_make.py --java --python cd build make +make test-z3 +make cpp_example +make c_example +# make java_example +# make python_example +./cpp_example +./test_capi - +git clone https://github.com/z3prover/z3test.git z3test +ls +python z3test/scripts/test_benchmarks.py ./z3 ./z3test/regressions/smt2 From 705439cb85d00453a2f3ed446d965de34393688e Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 22 Mar 2018 20:22:42 -0700 Subject: [PATCH 260/263] update build definition to 4 Signed-off-by: Nikolaj Bjorner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d501c5d5c..e3ef58b70 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ See the [release notes](RELEASE_NOTES) for notes on various stable releases of Z | Windows x64 | Windows x86 | Windows x64 | Ubuntu x64 | Debian x64 | OSX | TravisCI | | ----------- | ----------- | ----------- | ---------- | ---------- | --- | -------- | -[![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://z3build.visualstudio.com/Z3Build/_build/index?definitionId=2) | [![win32-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=4) | [![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/7/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=7) | [![ubuntu-x64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/3/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=3) | [![debian-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/5/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=5) | [![osx-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/2/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=2) | [![Build Status](https://travis-ci.org/Z3Prover/z3.svg?branch=master)](https://travis-ci.org/Z3Prover/z3) +[![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://z3build.visualstudio.com/Z3Build/_build/index?definitionId=4) | [![win32-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/4/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=4) | [![win64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/7/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=7) | [![ubuntu-x64-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/3/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=3) | [![debian-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/5/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=5) | [![osx-badge](https://cz3.visualstudio.com/_apis/public/build/definitions/bf14bcc7-ebd4-4240-812c-5972fa59e0ad/2/badge)](https://cz3.visualstudio.com/Z3/_build/index?definitionId=2) | [![Build Status](https://travis-ci.org/Z3Prover/z3.svg?branch=master)](https://travis-ci.org/Z3Prover/z3) [1]: #building-z3-on-windows-using-visual-studio-command-prompt [2]: #building-z3-using-make-and-gccclang From 966a8f73d33d9ed011286c6fb62fbf6f5449112f Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 23 Mar 2018 16:26:20 -0700 Subject: [PATCH 261/263] add eval feature #1553 Signed-off-by: Nikolaj Bjorner --- src/api/api_context.h | 3 +++ src/api/api_parsers.cpp | 27 +++++++++++++++++++++++++++ src/api/z3_api.h | 11 +++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/api/api_context.h b/src/api/api_context.h index 7009250cc..185eb9e0f 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -34,6 +34,7 @@ Revision History: #include "util/event_handler.h" #include "cmd_context/tactic_manager.h" #include "cmd_context/context_params.h" +#include "cmd_context/cmd_context.h" #include "api/api_polynomial.h" #include "util/hashtable.h" @@ -53,6 +54,7 @@ namespace api { context_params m_params; bool m_user_ref_count; //!< if true, the user is responsible for managing reference counters. scoped_ptr m_manager; + scoped_ptr m_cmd; add_plugins m_plugins; arith_util m_arith_util; @@ -114,6 +116,7 @@ namespace api { ast_manager & m() const { return *(m_manager.get()); } context_params & params() { return m_params; } + scoped_ptr& cmd() { return m_cmd; } bool produce_proofs() const { return m().proofs_enabled(); } bool produce_models() const { return m_params.m_model; } bool produce_unsat_cores() const { return m_params.m_unsat_core; } diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index 2e33c1a13..830bef7a8 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -117,4 +117,31 @@ extern "C" { RETURN_Z3(r); Z3_CATCH_RETURN(nullptr); } + + Z3_string Z3_API Z3_eval_smtlib2_string(Z3_context c, Z3_string str) { + Z3_TRY; + LOG_Z3_eval_smtlib2_string(c, str); + if (!mk_c(c)->cmd()) { + mk_c(c)->cmd() = alloc(cmd_context, false, &(mk_c(c)->m())); + } + scoped_ptr& ctx = mk_c(c)->cmd(); + std::string s(str); + std::istringstream is(s); + std::stringstream ous; + ctx->set_regular_stream(ous); + try { + if (!parse_smt2_commands(*ctx.get(), is)) { + mk_c(c)->m_parser_error_buffer = ous.str(); + SET_ERROR_CODE(Z3_PARSER_ERROR); + RETURN_Z3(nullptr); + } + } + catch (z3_exception& e) { + mk_c(c)->m_parser_error_buffer = e.msg(); + SET_ERROR_CODE(Z3_PARSER_ERROR); + RETURN_Z3(nullptr); + } + RETURN_Z3(mk_c(c)->mk_external_string(ous.str())); + Z3_CATCH_RETURN(nullptr); + } }; diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 87bb4d818..50ed85c70 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -5209,6 +5209,17 @@ extern "C" { Z3_func_decl const decls[]); + /** + \brief Parse and evaluate and SMT-LIB2 command sequence. The state from a previous call is saved so the next + evaluation builds on top of the previous call. + + \returns output generated from processing commands. + + def_API('Z3_eval_smtlib2_string', STRING, (_in(CONTEXT), _in(STRING),)) + */ + + Z3_string Z3_API Z3_eval_smtlib2_string(Z3_context, Z3_string str); + /** \brief Retrieve that last error message information generated from parsing. From 753f2c89ef70890253b930ec74220aafc209dcbd Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Fri, 23 Mar 2018 18:54:06 -0700 Subject: [PATCH 262/263] initialize solvers to ensure that eval mode has a solver Signed-off-by: Nikolaj Bjorner --- src/api/api_parsers.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index 830bef7a8..3af2e567c 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -21,8 +21,11 @@ Revision History: #include "api/api_context.h" #include "api/api_util.h" #include "cmd_context/cmd_context.h" +#include "smt/smt_solver.h" #include "parsers/smt2/smt2parser.h" #include "solver/solver_na2as.h" +#include "tactic/portfolio/smt_strategic_solver.h" + extern "C" { @@ -123,6 +126,7 @@ extern "C" { LOG_Z3_eval_smtlib2_string(c, str); if (!mk_c(c)->cmd()) { mk_c(c)->cmd() = alloc(cmd_context, false, &(mk_c(c)->m())); + mk_c(c)->cmd()->set_solver_factory(mk_smt_strategic_solver_factory()); } scoped_ptr& ctx = mk_c(c)->cmd(); std::string s(str); From fc719a5ee82361ffedb9ef46793e3401fdc32cc5 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 24 Mar 2018 10:37:05 -0700 Subject: [PATCH 263/263] fix diagnostic output #1553 Signed-off-by: Nikolaj Bjorner --- src/api/api_parsers.cpp | 12 +++++++----- src/cmd_context/cmd_context.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index 3af2e567c..28db62cc3 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -122,6 +122,7 @@ extern "C" { } Z3_string Z3_API Z3_eval_smtlib2_string(Z3_context c, Z3_string str) { + std::stringstream ous; Z3_TRY; LOG_Z3_eval_smtlib2_string(c, str); if (!mk_c(c)->cmd()) { @@ -131,21 +132,22 @@ extern "C" { scoped_ptr& ctx = mk_c(c)->cmd(); std::string s(str); std::istringstream is(s); - std::stringstream ous; ctx->set_regular_stream(ous); + ctx->set_diagnostic_stream(ous); try { if (!parse_smt2_commands(*ctx.get(), is)) { mk_c(c)->m_parser_error_buffer = ous.str(); SET_ERROR_CODE(Z3_PARSER_ERROR); - RETURN_Z3(nullptr); + RETURN_Z3(mk_c(c)->mk_external_string(ous.str())); } } catch (z3_exception& e) { - mk_c(c)->m_parser_error_buffer = e.msg(); + if (ous.str().empty()) ous << e.msg(); + mk_c(c)->m_parser_error_buffer = ous.str(); SET_ERROR_CODE(Z3_PARSER_ERROR); - RETURN_Z3(nullptr); + RETURN_Z3(mk_c(c)->mk_external_string(ous.str())); } RETURN_Z3(mk_c(c)->mk_external_string(ous.str())); - Z3_CATCH_RETURN(nullptr); + Z3_CATCH_RETURN(mk_c(c)->mk_external_string(ous.str())); } }; diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index d1e470c3b..90b3f6c56 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -406,6 +406,7 @@ public: void reset_user_tactics(); void set_regular_stream(char const * name) { m_regular.set(name); } void set_regular_stream(std::ostream& out) { m_regular.set(out); } + void set_diagnostic_stream(std::ostream& out) { m_diagnostic.set(out); } void set_diagnostic_stream(char const * name); std::ostream & regular_stream() override { return *m_regular; } std::ostream & diagnostic_stream() override { return *m_diagnostic; }