diff --git a/CMakeLists.txt b/CMakeLists.txt index 69a0ca123..c11c272be 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 @@ -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_") @@ -409,6 +412,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, 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() +endif() + ################################################################################ # Option to control what type of library we build ################################################################################ @@ -434,7 +451,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/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 "$@" 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_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/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') diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 3a719d322..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': @@ -889,8 +895,13 @@ def is_CXX_gpp(): return is_compiler(CXX, 'g++') def is_clang_in_gpp_form(cc): - version_string = check_output([cc, '--version']) - 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++'): @@ -1240,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' @@ -1790,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: @@ -2499,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/ackermannization/ackermannize_bv_tactic.cpp b/src/ackermannization/ackermannize_bv_tactic.cpp index 82ef19274..73034622e 100644 --- a/src/ackermannization/ackermannize_bv_tactic.cpp +++ b/src/ackermannization/ackermannize_bv_tactic.cpp @@ -27,14 +27,14 @@ 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) { - mc = 0; + expr_dependency_ref & core) override { + 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()); @@ -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..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); @@ -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_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 a7c021913..f5b90de1b 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); @@ -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/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..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) \ @@ -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[]) { @@ -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..1f4a86903 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) { @@ -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; @@ -1059,6 +1056,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: @@ -1233,17 +1231,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_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.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_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_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 397e2a8af..5e0082f09 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -45,14 +45,14 @@ 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) {} - 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,8 +73,8 @@ 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) { - expr* r = 0; + void reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result) override { + expr* r = nullptr; if (m_reduce_app) { m_reduce_app(m_state, f, num_args, args, &r); result = r; @@ -85,12 +85,12 @@ 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); } } - 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) { @@ -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 c8dbc4180..35458f902 100644 --- a/src/api/api_datalog.h +++ b/src/api/api_datalog.h @@ -37,8 +37,8 @@ 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) {} - virtual ~Z3_fixedpoint_ref() { dealloc(m_datalog); } + Z3_fixedpoint_ref(api::context& c): api::object(c), m_datalog(nullptr) {} + ~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_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..799e537ea 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); } } @@ -137,13 +137,13 @@ 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); } 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); @@ -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); } @@ -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); } @@ -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); } @@ -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); + decl = dt_util.get_constructor_is(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 4e9729df5..fa2ea61cf 100644 --- a/src/api/api_goal.h +++ b/src/api/api_goal.h @@ -24,11 +24,11 @@ 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); } 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 64427cfb8..fa94e9728 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); } @@ -34,8 +34,8 @@ 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) {} - virtual ~Z3_func_interp_ref() {} + Z3_func_interp_ref(api::context& c, model * m): api::object(c), m_model(m), m_func_interp(nullptr) {} + ~Z3_func_interp_ref() override {} }; inline Z3_func_interp_ref * to_func_interp(Z3_func_interp s) { return reinterpret_cast(s); } @@ -46,8 +46,8 @@ 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) {} - virtual ~Z3_func_entry_ref() {} + 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 {} }; inline Z3_func_entry_ref * to_func_entry(Z3_func_entry s) { return reinterpret_cast(s); } 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 0d96a6719..2712eef6f 100644 --- a/src/api/api_opt.cpp +++ b/src/api/api_opt.cpp @@ -35,8 +35,8 @@ 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(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); } inline Z3_optimize of_optimize(Z3_optimize_ref * 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..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" @@ -57,7 +58,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 +70,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 +81,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 +92,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 +100,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 +111,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 +119,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 +138,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 +191,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 +209,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 +289,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 +335,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 +376,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 +398,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 +415,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 +435,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 +459,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 4f344a00d..90d1c2c65 100644 --- a/src/api/api_solver.h +++ b/src/api/api_solver.h @@ -26,8 +26,8 @@ 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) {} - virtual ~Z3_solver_ref() {} + 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 {} }; 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.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 fd2f05185..d33f3afe2 100644 --- a/src/api/api_tactic.h +++ b/src/api/api_tactic.h @@ -29,22 +29,22 @@ 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); } 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; @@ -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..848d935c5 100644 --- a/src/api/api_util.h +++ b/src/api/api_util.h @@ -88,22 +88,22 @@ 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); } 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; 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); } 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/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/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/Context.java b/src/api/java/Context.java index ba96209b3..c45dce933 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) { @@ -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); @@ -2781,7 +2782,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 +3770,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 +3787,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 +3803,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/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/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) 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: diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index 641dba59c..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`. @@ -2428,7 +2425,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 +4434,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 @@ -4451,13 +4448,13 @@ 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) 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. @@ -4575,7 +4572,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 +4626,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") @@ -6818,8 +6815,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") @@ -7447,6 +7444,19 @@ 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 = WithParams(Tactic('simplify'), p) + >>> t((x + 1)*(y + 2) == 0) + [[2*x + y + x*y == -2]] + """ + 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): """Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached. @@ -8253,7 +8263,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)] @@ -8861,7 +8871,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()) @@ -9657,7 +9667,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)) @@ -9832,7 +9842,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/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.h b/src/api/z3.h index 99929f33b..e08b0c073 100644 --- a/src/api/z3.h +++ b/src/api/z3.h @@ -21,7 +21,7 @@ Notes: #ifndef Z3_H_ #define Z3_H_ -#include +#include #include "z3_macros.h" #include "z3_api.h" #include "z3_ast_containers.h" 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 5e5b84450..87bb4d818 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: @@ -876,6 +860,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. @@ -1140,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, @@ -1157,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, @@ -1220,6 +1203,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, @@ -1474,7 +1458,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 @@ -1507,7 +1490,6 @@ extern "C" { Z3_config Z3_API Z3_mk_config(void); /** - \deprecated \brief Delete the given configuration object. \sa Z3_mk_config @@ -1517,7 +1499,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 @@ -1534,7 +1515,6 @@ extern "C" { /*@{*/ /** - \deprecated \brief Create a context using the given configuration. After a context is created, the configuration cannot be changed, @@ -1614,7 +1594,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 @@ -2857,9 +2836,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 +2852,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. @@ -4375,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))) */ 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/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/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.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 911bb3f27..beaccfbd3 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 { @@ -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..7e143e1a3 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,48 @@ 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_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 +789,7 @@ func_decl * basic_decl_plugin::mk_proof_decl(basic_op_kind k, unsigned num_param } default: UNREACHABLE(); - return 0; + return 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,15 +842,13 @@ 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); case PR_HYPER_RESOLVE: return mk_proof_decl("hyper-res", k, num_parents, m_hyper_res_decl0); default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -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); @@ -1067,10 +1060,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 +1103,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 +1127,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 +1161,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 +1169,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 +1184,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 +1205,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 +1223,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 +1232,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 +1240,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 +1267,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 +1300,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 +1312,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 +1329,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 +1354,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 +1420,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 +1469,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; } } @@ -1532,32 +1525,39 @@ 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++) { - 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";); - 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)) { - 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)); + 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); + (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)); } } @@ -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) { @@ -2837,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; @@ -3087,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; @@ -3104,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 7a662a193..68e02d791 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. @@ -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; @@ -1129,7 +1126,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 +1135,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 +1185,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 +1207,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 +1227,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 +1260,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 +1289,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; }; @@ -1497,14 +1494,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 +1520,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 +1555,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 +1667,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 +1678,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 +1697,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 +1713,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 +1724,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 +1743,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 +1801,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 +1822,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 +1876,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 +2054,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); } // ----------------------------------- @@ -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,16 +2197,15 @@ 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); 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; @@ -2467,9 +2462,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_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..23c9ebe51 100644 --- a/src/ast/ast_pp_util.cpp +++ b/src/ast/ast_pp_util.cpp @@ -38,20 +38,26 @@ 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, 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) { 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/ast/ast_printer.cpp b/src/ast/ast_printer.cpp index b5cf60ee9..536e1af92 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); + mk_smt2_format(n, env(), params_ref(), 0, nullptr, 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.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 3e8b1aa39..69b8d67f9 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, @@ -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..b7404859f 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) { @@ -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"; } 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_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/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 a4ea7af80..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 { @@ -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.cpp b/src/ast/datatype_decl_plugin.cpp index 91e636ed7..44f824959 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; } @@ -791,9 +791,17 @@ 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 = 0; + func_decl * d = nullptr; if (m_constructor2recognizer.find(con, d)) return d; sort * datatype = con->get_range(); @@ -848,7 +856,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 +900,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 +970,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 { @@ -1040,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 515ca6e20..e644ccbda 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]; } }; }; @@ -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); }; @@ -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(); } @@ -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; @@ -398,7 +399,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/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/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 75969d385..03b9d1fd8 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); } }; @@ -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/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/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 322b9402a..5a4cac477 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; } }; @@ -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 6c2a02989..40df437ea 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); @@ -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"), @@ -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, @@ -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 2bacae12a..f1c2b1a14 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); 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 9d8576203..9b9f0b427 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), @@ -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)); @@ -4097,7 +4097,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); @@ -4115,7 +4115,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_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/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..c0caaa3ca 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)) @@ -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) { @@ -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 4e86c9d3f..c914bb6c7 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 { @@ -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..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; @@ -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, vector 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; }; @@ -210,7 +210,7 @@ bool defined_names::impl::mk_name(expr * e, expr_ref & new_def, proof_ref & new_ TRACE("mk_definition_bug", tout << "name for expression is already cached..., returning false...\n";); n = n_ptr; if (m_manager.proofs_enabled()) { - proof * pr_ptr = 0; + proof * pr_ptr = nullptr; m_expr2proof.find(e, pr_ptr); SASSERT(pr_ptr); pr = pr_ptr; diff --git a/src/ast/normal_forms/name_exprs.cpp b/src/ast/normal_forms/name_exprs.cpp index 7cc2719c9..3e5503ea7 100644 --- a/src/ast/normal_forms/name_exprs.cpp +++ b/src/ast/normal_forms/name_exprs.cpp @@ -38,8 +38,8 @@ class name_exprs_core : public name_exprs { m_pred(pred), m_r(m), m_pr(m), - m_def_exprs(0), - m_def_proofs(0) { + m_def_exprs(nullptr), + m_def_proofs(nullptr) { } void gen_name_for_expr(expr * n, expr * & t, proof * & t_pr) { @@ -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 { } }; @@ -127,9 +127,9 @@ class name_nested_formulas : public name_exprs_core { ast_manager & m_manager; expr * m_root; - pred(ast_manager & m):m_manager(m), m_root(0) {} + pred(ast_manager & m):m_manager(m), m_root(nullptr) {} - 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/normal_forms/nnf.cpp b/src/ast/normal_forms/nnf.cpp index 6fc65543d..11461680d 100644 --- a/src/ast/normal_forms/nnf.cpp +++ b/src/ast/normal_forms/nnf.cpp @@ -82,7 +82,7 @@ class skolemizer { expr_ref_vector args(m()); for (unsigned i = 0; i < sz; i++) { sort * s = uv.get(i); - if (s != 0) { + if (s != nullptr) { sorts.push_back(s); args.push_back(m().mk_var(i, s)); } @@ -105,10 +105,10 @@ class skolemizer { // for (unsigned i = 0; i < sz; i++) { sort * s = uv.get(i); - if (s != 0) + if (s != nullptr) substitution.push_back(m().mk_var(i, s)); else - substitution.push_back(0); + substitution.push_back(nullptr); } // // (VAR num_decls) ... (VAR num_decls+sz-1) @@ -137,7 +137,7 @@ class skolemizer { } } s(body, substitution.size(), substitution.c_ptr(), r); - p = 0; + p = nullptr; if (m().proofs_enabled()) { if (q->is_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 7fdb592aa..ea4049e13 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; + return nullptr; } - 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.cpp b/src/ast/proofs/proof_checker.cpp index 5126198c6..0e16abd11 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; } } @@ -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,16 +720,12 @@ 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)) 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)) { @@ -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) && @@ -823,7 +796,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); @@ -922,7 +895,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 +911,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 +926,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 +936,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 +947,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 +959,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 +970,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 +983,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 +995,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 +1008,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 +1019,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) || @@ -1099,7 +1072,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); @@ -1186,14 +1159,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 +1178,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,14 +1200,14 @@ 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; } 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 +1218,7 @@ expr* proof_checker::mk_hyp(unsigned num_hyps, expr * const * hyps) { } } } - if (result == 0) { + if (result == nullptr) { return mk_nil(); } else { @@ -1253,7 +1226,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 ce2684c51..ac0e31dbd 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); @@ -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); 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/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/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 fd263efb2..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) @@ -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)); @@ -550,8 +550,8 @@ bool bv_bounds::add_neg_bound(app * v, numeral a, 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 4a7226fa7..fcd173a12 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)); @@ -109,7 +109,7 @@ inline bool bv_bounds::in_range(app *v, 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 56f895b8a..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 @@ -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 @@ -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/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/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 70e12dced..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; @@ -90,29 +90,29 @@ 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) { - result_dep = 0; + void operator()(expr * t, expr_ref & result, proof_ref & result_pr, expr_dependency_ref & result_dep) override { + 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; } } - 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/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 c0ee0d09f..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); @@ -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/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 deleted file mode 100644 index 651744bf9..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 = 0; - proof * t_pr = 0; - expr * e = 0; - proof * e_pr = 0; - 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, 0); - } - 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 = 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 * proofs[2]; - unsigned num_proofs = 0; - if (t_pr != 0) { - proofs[num_proofs] = t_pr; - num_proofs++; - } - if (e_pr != 0) { - 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 = 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 - 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, 0); - } - else { - expr_ref old(m_manager); - proof * p; - old = mk_p_arg(n); - if (old == r) - p = 0; - 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 = 0; - 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 = 0; - 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 = 0; - proof * _pr = 0; - 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 3ff0a716d..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) {} - virtual ~pull_cheap_ite_tree_cfg() {} - virtual bool is_target(app * n) const; -}; - -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/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/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.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.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/rewriter_def.h b/src/ast/rewriter/rewriter_def.h index 5a3b930c8..dfb6542d6 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); } @@ -194,16 +194,18 @@ 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); } - m_r = 0; + m_r = nullptr; return true; } } @@ -255,7 +257,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 +280,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 +320,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; } } @@ -358,7 +360,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()); @@ -407,11 +409,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 +516,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 +552,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 +658,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 +723,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 ec3e72cc4..89840ea43 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()); @@ -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,11 @@ 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; - 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)) { - 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 +1557,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 +1881,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..c9dbc78f8 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()); @@ -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)); @@ -819,7 +815,7 @@ func_decl * seq_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, } default: UNREACHABLE(); - return 0; + return nullptr; } } @@ -921,7 +917,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 +974,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 2e3b3fd24..8bd4d2807 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; } @@ -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 572abc8fe..0c9c5360c 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -49,14 +49,14 @@ 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) { + if (c == nullptr) { std::string err_msg("unknown command '"); err_msg = err_msg + s.bare_str() + "'"; throw cmd_exception(err_msg); @@ -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,15 +101,15 @@ 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) { - if (!ctx.is_model_available() || ctx.get_check_sat_result() == 0) + 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() == nullptr) throw cmd_exception("model is not available"); model_ref m; if (m_index > 0 && ctx.get_opt()) { @@ -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,32 +760,32 @@ 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) + 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()); @@ -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; } }; @@ -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 ec2eea032..aabe43110 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) { @@ -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; @@ -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)) { @@ -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; @@ -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()); @@ -741,7 +742,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 +772,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 +862,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 +906,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 +924,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 +937,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 +959,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 +967,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 +978,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 +1033,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 +1067,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 +1080,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 +1174,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 +1243,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 +1256,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 +1280,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 +1289,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 +1306,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 +1317,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 +1363,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); @@ -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()) @@ -1418,7 +1420,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 +1558,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 +1780,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 +1832,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 +1892,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 +1903,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 +1915,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 +1940,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 { @@ -2015,7 +2017,7 @@ void cmd_context::dt_eh::operator()(sort * dt, pdecl* pd) { 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";); + // 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); diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 212de585a..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; @@ -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 { @@ -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 { @@ -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; @@ -306,8 +306,8 @@ protected: public: - cmd_context(bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); - ~cmd_context(); + 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; } solver_factory &get_solver_factory() { return *m_solver_factory; } @@ -352,9 +352,9 @@ 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; } - 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/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/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..d4004fca8 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; + m_target = nullptr; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { - if (m_target == 0) return CPK_EXPR; + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { + if (m_target == nullptr) 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..465bcb956 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 = nullptr; } + 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) { - if (m_t1 == 0) + 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 = 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 == nullptr) 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 = nullptr; m_args.reset(); } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { - if (m_q == 0) return CPK_EXPR; + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { + if (m_q == nullptr) 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..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,37 +162,37 @@ 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) {} - 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) { - m_ctx = 0; + void finalize(cmd_context & ctx) override { + m_ctx = nullptr; } - virtual void failure_cleanup(cmd_context & ctx) { - m_ctx = 0; + void failure_cleanup(cmd_context & ctx) override { + m_ctx = nullptr; } - 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; + m_ctx = nullptr; } }; @@ -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; + m_target = nullptr; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { - if (m_target == 0) return CPK_EXPR; + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { + if (m_target == nullptr) 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..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"); @@ -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.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 6d676d6f9..79517219d 100644 --- a/src/cmd_context/parametric_cmd.h +++ b/src/cmd_context/parametric_cmd.h @@ -30,49 +30,49 @@ public: params_ref m_params; 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(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; 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..f9ba79f6d 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; } /** @@ -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(); } @@ -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())); } @@ -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()); } @@ -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,20 +844,20 @@ 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"); } pdecl_manager::~pdecl_manager() { dec_ref(m_list); reset_sort_info(); - SASSERT(m_sort2psort.empty()); + SASSERT(m_sort2psort.empty()); SASSERT(m_table.empty()); } 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); } @@ -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()) @@ -1010,7 +1011,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 +1020,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 c72020827..12e6399fe 100644 --- a/src/cmd_context/pdecl.h +++ b/src/cmd_context/pdecl.h @@ -64,20 +64,20 @@ 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) {} - virtual bool is_psort() const { return true; } - virtual void finalize(pdecl_manager & m); - virtual ~psort() {} + 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 {} virtual void cache(pdecl_manager & m, sort * const * s, sort * r); 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; 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,17 +98,17 @@ 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; } - 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; } 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; }; @@ -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) {} @@ -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..de548562e 100644 --- a/src/cmd_context/simplify_cmd.cpp +++ b/src/cmd_context/simplify_cmd.cpp @@ -36,13 +36,13 @@ 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); } 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; } @@ -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,25 +66,25 @@ 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; + m_target = nullptr; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { - if (m_target == 0) return CPK_EXPR; + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { + if (m_target == nullptr) 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) { - if (m_target == 0) + void execute(cmd_context & ctx) override { + 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 cbc90c62c..32a92ea59 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -55,20 +55,20 @@ class declare_tactic_cmd : public cmd { public: declare_tactic_cmd(): cmd("declare-tactic"), - m_decl(0) { + m_decl(nullptr) { } - 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 = nullptr; } + 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; + m_tactic = nullptr; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { - if (m_tactic == 0) return CPK_SEXPR; + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { + if (m_tactic == nullptr) 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"); } @@ -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 e8f36a0cd..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,15 +247,15 @@ namespace Duality { lbool interpolate_tree(TermTree *assumptions, TermTree *&interpolants, model &_model, - TermTree *goals = 0, - bool weak = false) + TermTree *goals = nullptr, + 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; } @@ -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,23 +715,23 @@ 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. */ 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); + Term Eval(Edge *e, const Term& t); /** Return the fact derived at node p in a counterexample. */ 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); @@ -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); @@ -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)) @@ -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;} @@ -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; @@ -1313,28 +1313,28 @@ 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); 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 = nullptr, unsigned *core_size = nullptr, expr *core = nullptr) override; - virtual lbool ls_interpolate_tree(TermTree *assumptions, + lbool ls_interpolate_tree(TermTree *assumptions, TermTree *&interpolants, model &_model, - TermTree *goals = 0, - bool weak = false); + TermTree *goals = nullptr, + 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_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 b6dd42f00..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){ @@ -1491,16 +1491,16 @@ 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) + RPFP::Term RPFP::Eval(Edge *e, const Term& t) { Term tl = Localize(e, t); 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) @@ -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 6053295b5..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; @@ -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(); @@ -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 @@ -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); } @@ -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 @@ -828,7 +828,7 @@ namespace Duality { } } - bool IsResultRecursionBounded(){ + bool IsResultRecursionBounded() override { return recursionBounded; } @@ -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; @@ -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); @@ -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; @@ -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()){ @@ -3088,7 +3088,7 @@ namespace Duality { LocalHeuristic(RPFP *_rpfp) : Heuristic(_rpfp) { - old_node = 0; + old_node = nullptr; } void SetOldNode(RPFP::Node *_old_node){ @@ -3099,8 +3099,8 @@ 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){ - if(old_node == 0){ + void ChooseExpand(const std::set &choices, std::set &best, bool, bool) override { + if(old_node == nullptr){ 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/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..511342819 --- 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; @@ -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 0ad751326..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; @@ -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,9 +285,9 @@ 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; + return is_app(_ast) ? to_app(_ast)->get_decl() : nullptr; } std::string string_of_symbol(symb s){ @@ -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/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/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 old mode 100755 new mode 100644 index 32b76b224..9680ec95e --- 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); } }; @@ -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 e71475e45..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; @@ -1611,9 +1611,9 @@ 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 + Iproof::node Ipf = translate_main(proof,nullptr); // 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/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/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/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 ace5381b8..3c6ecd1cb 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(); @@ -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 9baa0beac..d6d4366db 100644 --- a/src/math/hilbert/hilbert_basis.cpp +++ b/src/math/hilbert/hilbert_basis.cpp @@ -174,8 +174,8 @@ class hilbert_basis::value_index2 { struct checker : public ht::check_value { hilbert_basis* hb; offset_t m_value; - checker(): hb(0) {} - virtual bool operator()(unsigned const& v) { + 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 9484c3c83..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; @@ -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 @@ -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 51d8489e3..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); @@ -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() { @@ -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; @@ -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); @@ -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()); @@ -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) { @@ -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(); @@ -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/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/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/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..cc2442981 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; } @@ -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/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/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/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 8f2d933e2..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; } }; @@ -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); } }; @@ -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.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.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 3574787d8..bb129fee7 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); @@ -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; } } @@ -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); @@ -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 6a7bc11e8..1f5f87eef 100644 --- a/src/math/subpaving/tactic/subpaving_tactic.cpp +++ b/src/math/subpaving/tactic/subpaving_tactic.cpp @@ -40,9 +40,9 @@ class subpaving_tactic : public tactic { ast_manager & m() const { return m_inv.get_manager(); } - virtual void operator()(std::ostream & out, subpaving::var x) const { - expr * t = m_inv.get(x, 0); - if (t != 0) + void operator()(std::ostream & out, subpaving::var x) const override { + 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(); @@ -216,44 +216,44 @@ 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); 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 @@ -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/model/func_interp.cpp b/src/model/func_interp.cpp index e458cc4b0..2eb687dae 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) { @@ -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; @@ -183,13 +184,13 @@ func_entry * func_interp::get_entry(expr * const * args) const { if (curr->eq_args(m(), m_arity, args)) return curr; } - return 0; + return nullptr; } void func_interp::insert_entry(expr * const * args, expr * r) { reset_interp_cache(); func_entry * entry = get_entry(args); - if (entry != 0) { + if (entry != nullptr) { entry->set_result(m_manager, r); return; } @@ -219,7 +220,7 @@ void func_interp::insert_new_entry(expr * const * args, expr * r) { } bool func_interp::eval_else(expr * const * args, expr_ref & result) const { - if (m_else == 0) + if (m_else == nullptr) return false; var_subst s(m_manager, false); SASSERT(!s.std_order()); // (VAR 0) <- args[0], (VAR 1) <- args[1], ... @@ -232,9 +233,9 @@ bool func_interp::eval_else(expr * const * args, expr_ref & result) const { */ expr * func_interp::get_max_occ_result() const { if (m_entries.empty()) - return 0; + return nullptr; obj_map 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 +258,7 @@ expr * func_interp::get_max_occ_result() const { \brief Remove entries e such that e.get_result() == m_else. */ void func_interp::compress() { - if (m_else == 0 || m_entries.empty()) + if (m_else == nullptr || m_entries.empty()) return; // nothing to be done if (!is_ground(m_else)) return; // forall entries e in m_entries e.get_result() is ground @@ -284,8 +285,8 @@ void func_interp::compress() { } expr * func_interp::get_interp_core() const { - if (m_else == 0) - return 0; + if (m_else == nullptr) + return nullptr; expr * r = m_else; ptr_buffer vars; ptr_vector::const_iterator it = m_entries.begin(); @@ -313,10 +314,10 @@ expr * func_interp::get_interp_core() const { } expr * func_interp::get_interp() const { - if (m_interp != 0) + if (m_interp != nullptr) return m_interp; expr * r = get_interp_core(); - if (r != 0) { + if (r != nullptr) { const_cast(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 7ac1300de..486b1e92e 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -93,13 +93,13 @@ bool model::eval(expr * e, expr_ref & result, bool model_completion) { struct model::value_proc : public some_value_proc { model & m_model; value_proc(model & m):m_model(m) {} - virtual expr * operator()(sort * s) { - ptr_vector * u = 0; + expr * operator()(sort * s) override { + 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.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/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..227e14ca6 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; } @@ -187,14 +187,14 @@ struct evaluator_cfg : public default_rewriter_cfg { TRACE("model_evaluator", tout << "reduce_app " << f->get_name() << "\n"; for (unsigned i = 0; i < num; i++) tout << mk_ismt2_pp(args[i], m) << "\n"; tout << "---->\n" << mk_ismt2_pp(result, m) << "\n";); - return BR_DONE; + return BR_REWRITE1; } if (st == BR_FAILED && !m.is_builtin_family_id(fid)) st = evaluate_partial_theory_func(f, num, args, result, result_pr); if (st == BR_DONE && is_app(result)) { app* a = to_app(result); if (evaluate(a->get_decl(), a->get_num_args(), a->get_args(), result)) { - return BR_DONE; + return BR_REWRITE1; } } CTRACE("model_evaluator", st != BR_FAILED, tout << result << "\n";); @@ -224,7 +224,7 @@ struct evaluator_cfg : public default_rewriter_cfg { func_interp * fi = m_model.get_func_interp(f); - if (fi != 0) { + if (fi != nullptr) { TRACE_MACRO; if (fi->is_partial()) { if (m_model_completion) { @@ -262,8 +262,8 @@ struct evaluator_cfg : public default_rewriter_cfg { expr_ref & result, proof_ref & result_pr) { SASSERT(f != 0); SASSERT(!m.is_builtin_family_id(f->get_family_id())); - result = 0; - result_pr = 0; + result = nullptr; + result_pr = nullptr; func_interp * fi = m_model.get_func_interp(f); if (fi) { @@ -382,7 +382,7 @@ struct evaluator_cfg : public default_rewriter_cfg { continue; } table2.insert(stores2[i].c_ptr()); - expr * const* args = 0; + expr * const* args = nullptr; expr* val = stores2[i][arity]; if (table1.find(stores2[i].c_ptr(), args)) { switch (compare(args[arity], val)) { @@ -399,12 +399,11 @@ struct evaluator_cfg : public default_rewriter_cfg { } } } - args_table::iterator it = table1.begin(), end = table1.end(); - for (; it != end; ++it) { - switch (compare((*it)[arity], else2)) { + for (auto const& t : table1) { + switch (compare((t)[arity], else2)) { case l_true: break; case l_false: result = m.mk_false(); return BR_DONE; - default: conj.push_back(m.mk_eq((*it)[arity], else2)); break; + default: conj.push_back(m.mk_eq((t)[arity], else2)); break; } } result = mk_and(conj); 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 78860bdde..521cf0dc9 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; @@ -154,14 +154,14 @@ 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)) {} - 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() { @@ -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(); @@ -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/muz/base/dl_context.h b/src/muz/base/dl_context.h index 0fb68d396..f37826feb 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); } }; @@ -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 715964e3a..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++; @@ -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); } @@ -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/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/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/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.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/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.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/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.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/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..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), @@ -494,27 +494,27 @@ public: { } - virtual bool parse_file(char const * filename) { + 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); } } - virtual bool parse_string(char const * string) { + bool parse_string(char const * string) override { 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); } @@ -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); @@ -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 2610f821c..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,12 +164,12 @@ public: cmd("rule"), m_dl_ctx(dl_ctx), m_arg_idx(0), - m_t(0), + m_t(nullptr), 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); } @@ -206,19 +206,19 @@ public: dl_query_cmd(dl_context * dl_ctx): parametric_cmd("query"), m_dl_ctx(dl_ctx), - m_target(0) { + m_target(nullptr) { } - 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 { - if (m_target == 0) return CPK_FUNC_DECL; + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { + if (m_target == nullptr) 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,14 +229,14 @@ 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; + m_target = nullptr; } - virtual void execute(cmd_context& ctx) { - if (m_target == 0) { + void execute(cmd_context& ctx) override { + if (m_target == nullptr) { throw cmd_exception("invalid query command, argument expected"); } if (m_dl_ctx->collect_query(m_target)) { @@ -318,10 +318,10 @@ public: } dlctx.cleanup(); print_statistics(ctx); - m_target = 0; + m_target = nullptr; } - 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,19 +460,19 @@ 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); + 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); } @@ -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(); } }; @@ -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/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..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()); @@ -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_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..29d01d1f3 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); @@ -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) { @@ -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_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_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_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_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..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) { @@ -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_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/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 ddda295cd..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); @@ -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(); @@ -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 { @@ -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(); @@ -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( @@ -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); @@ -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 { @@ -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; @@ -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 { @@ -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; @@ -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 { @@ -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()); @@ -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 { @@ -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(); @@ -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 { @@ -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()); @@ -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; } @@ -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(); @@ -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; } /* @@ -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()); @@ -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/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..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)); } }; @@ -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; @@ -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; } }; @@ -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,21 +1022,21 @@ 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: /** 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; } }; @@ -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; - virtual table_base * complement(func_decl* p, const table_element * func_columns = 0) const; - virtual bool empty() const; + table_base * clone() const override; + virtual table_base * complement(func_decl* p, const table_element * func_columns = nullptr) 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..60358db48 100644 --- a/src/muz/rel/dl_bound_relation.cpp +++ b/src/muz/rel/dl_bound_relation.cpp @@ -79,11 +79,11 @@ 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(); - 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); } @@ -104,10 +104,10 @@ 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())); + 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; } @@ -124,10 +124,10 @@ 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())); + 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; } @@ -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");); @@ -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 { @@ -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]); } @@ -209,14 +209,14 @@ 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 { 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, @@ -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)) && @@ -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; @@ -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 3dec9d313..6c613a472 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 nullptr; } #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..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";); @@ -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)); @@ -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); } @@ -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); @@ -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); } @@ -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)); @@ -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); @@ -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); @@ -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); } @@ -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); @@ -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); } @@ -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)); @@ -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); } @@ -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(); @@ -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 { @@ -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(); @@ -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 { @@ -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(); @@ -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 { @@ -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); @@ -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 { @@ -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)); @@ -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 412dd2dbc..7bd4cf12d 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 = nullptr) 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.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 6ac33ae91..d7bdcad34 100644 --- a/src/muz/rel/dl_compiler.h +++ b/src/muz/rel/dl_compiler.h @@ -93,11 +93,11 @@ 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; } - virtual void notify(instruction * i) { + 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 ff9bef40e..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); } @@ -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(); @@ -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); } @@ -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; @@ -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,10 +295,10 @@ 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); } - 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(); @@ -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()); } @@ -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); @@ -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); @@ -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); @@ -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); } @@ -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); @@ -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_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..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); @@ -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(); @@ -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); @@ -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(); @@ -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); } @@ -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(); @@ -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; } @@ -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(); @@ -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; i1) { @@ -1192,7 +1192,7 @@ namespace datalog { relation_mutator_fn * finite_product_relation_plugin::mk_filter_identical_fn(const relation_base & rb, unsigned col_cnt, const unsigned * identical_cols) { if(&rb.get_plugin()!=this) { - return 0; + return nullptr; } return alloc(filter_identical_fn, get(rb), col_cnt, identical_cols); } @@ -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) { @@ -1238,7 +1238,7 @@ namespace datalog { relation_mutator_fn * finite_product_relation_plugin::mk_filter_equal_fn(const relation_base & rb, const relation_element & value, unsigned col) { if(&rb.get_plugin()!=this) { - return 0; + return nullptr; } return alloc(filter_equal_fn, get(rb), value, col); } @@ -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(); @@ -1357,7 +1357,7 @@ namespace datalog { unsigned rel_cnt = r.m_others.size(); 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 { @@ -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..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() { @@ -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,17 +268,17 @@ 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); + 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; } - 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)) { @@ -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; @@ -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"); @@ -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 e14d242bb..75f9e7e42 100644 --- a/src/muz/rel/dl_interval_relation.cpp +++ b/src/muz/rel/dl_interval_relation.cpp @@ -59,11 +59,11 @@ 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(); - 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); } @@ -84,10 +84,10 @@ 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())); + 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; } @@ -104,10 +104,10 @@ 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())); + 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); } } @@ -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");); @@ -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); } @@ -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]; @@ -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); } @@ -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)); @@ -279,7 +279,7 @@ namespace datalog { if(check_kind(r)) { return alloc(filter_equal_fn, get_manager(), value, col); } - return 0; + return nullptr; } @@ -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);); } @@ -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_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..53d099532 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()); @@ -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; } } @@ -75,13 +75,13 @@ 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); 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; } } @@ -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())); } @@ -124,7 +124,7 @@ namespace datalog { return alloc(project_fn, t.get_signature(), col_cnt, removed_cols); } else { - return 0; + return nullptr; } } @@ -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())); } @@ -150,7 +150,7 @@ namespace datalog { return alloc(rename_fn, t.get_signature(), col_cnt, removed_cols); } else { - return 0; + return nullptr; } } @@ -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)); } @@ -175,7 +175,7 @@ namespace datalog { return alloc(filter_identical_fn, col_cnt, identical_cols); } else { - return 0; + return nullptr; } } @@ -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)); } @@ -201,7 +201,7 @@ namespace datalog { return alloc(filter_interpreted_fn, cond); } else { - return 0; + return nullptr; } } @@ -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)); @@ -229,7 +229,7 @@ namespace datalog { return alloc(filter_by_negation_fn, joined_col_cnt, t_cols, negated_cols); } else { - return 0; + return nullptr; } } @@ -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)); } @@ -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 6752e5a5a..7e5991a7a 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 = nullptr) 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..1a1a47f74 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]); } 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()) { @@ -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; @@ -296,9 +296,9 @@ 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) {} - 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(); @@ -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()); } @@ -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(); @@ -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); } @@ -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,10 +382,10 @@ 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; + 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())) { @@ -418,9 +418,9 @@ 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; + 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 @@ -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)) { @@ -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(); @@ -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(); } @@ -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); } @@ -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); @@ -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_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.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_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.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_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..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(); @@ -444,16 +444,16 @@ 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(); - 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; } @@ -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()); @@ -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,17 +625,17 @@ 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() { + ~aligned_union_fn() override { unsigned sz = m_unions.size(); for(unsigned i=0; i 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]); @@ -748,11 +748,11 @@ namespace datalog { } - 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 { 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) { @@ -783,7 +783,7 @@ namespace datalog { : m_single_rel_idx(single_rel_idx), m_inner_union_fun(inner_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 { TRACE("dl", tgt.display(tout); _src.display(tout); ); product_relation const& src = get(_src); (*m_inner_union_fun)(tgt, src[m_single_rel_idx], 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, @@ -834,9 +834,9 @@ namespace datalog { mutator_fn(unsigned sz, relation_mutator_fn** muts): m_mutators(sz, muts) {} - ~mutator_fn() { dealloc_ptr_vector_content(m_mutators); } + ~mutator_fn() override { dealloc_ptr_vector_content(m_mutators); } - virtual void operator()(relation_base & _r) { + void operator()(relation_base & _r) override { TRACE("dl", _r.display(tout);); product_relation& r = get(_r); SASSERT(m_mutators.size() == r.size()); @@ -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 { @@ -911,9 +911,9 @@ namespace datalog { } } - ~filter_interpreted_fn() { dealloc_ptr_vector_content(m_mutators); } + ~filter_interpreted_fn() override { dealloc_ptr_vector_content(m_mutators); } - void operator()(relation_base& _r) { + void operator()(relation_base& _r) override { TRACE("dl", _r.display(tout);); product_relation const& r = get(_r); for (unsigned i = 0; i < m_attach.size(); ++i) { @@ -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_product_relation.h b/src/muz/rel/dl_product_relation.h index 002fe5289..a872bc969 100644 --- a/src/muz/rel/dl_product_relation.h +++ b/src/muz/rel/dl_product_relation.h @@ -59,37 +59,37 @@ namespace datalog { product_relation_plugin(relation_manager& m); - virtual void initialize(family_id fid); + void initialize(family_id fid) override; - virtual bool can_handle_signature(const relation_signature & s); - virtual bool can_handle_signature(const relation_signature & s, family_id kind); + bool can_handle_signature(const relation_signature & s) override; + bool can_handle_signature(const relation_signature & s, family_id kind) override; static symbol get_name() { return symbol("product_relation"); } family_id get_relation_kind(const relation_signature & sig, const rel_spec & spec); - virtual relation_base * mk_empty(const relation_signature & s); - virtual relation_base * mk_empty(const relation_signature & s, family_id kind); + relation_base * mk_empty(const relation_signature & s) 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); - virtual relation_base * mk_full(func_decl* p, const relation_signature & s, family_id kind); + relation_base * mk_full(func_decl* p, const relation_signature & s) override; + relation_base * mk_full(func_decl* p, const relation_signature & s, family_id kind) override; 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_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_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_product_relation(relation_base const& r); @@ -154,15 +154,15 @@ namespace datalog { product_relation(product_relation_plugin& p, relation_signature const& s); product_relation(product_relation_plugin& p, relation_signature const& s, unsigned num_relations, relation_base** relations); - ~product_relation(); + ~product_relation() override; - virtual bool empty() const; - virtual void add_fact(const relation_fact & f); - virtual bool contains_fact(const relation_fact & f) const; - virtual product_relation * clone() const; - virtual product_relation * complement(func_decl* p) const; - virtual void display(std::ostream & out) const; - virtual void to_formula(expr_ref& fml) const; + bool empty() const override; + void add_fact(const relation_fact & f) override; + bool contains_fact(const relation_fact & f) const override; + product_relation * clone() const override; + product_relation * complement(func_decl* p) const override; + void display(std::ostream & out) const override; + void to_formula(expr_ref& fml) const override; product_relation_plugin& get_plugin() const; unsigned size() const { return m_relations.size(); } @@ -175,7 +175,7 @@ namespace datalog { */ bool try_get_single_non_transparent(unsigned & idx) const; - virtual bool is_precise() const { + bool is_precise() const override { for (unsigned i = 0; i < m_relations.size(); ++i) { if (!m_relations[i]->is_precise()) { return false; diff --git a/src/muz/rel/dl_relation_manager.cpp b/src/muz/rel/dl_relation_manager.cpp index 1eb973776..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 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); @@ -686,9 +686,9 @@ namespace datalog { */ default_relation_join_project_fn(join_fn * join, unsigned removed_col_cnt, const unsigned * removed_cols) - : m_join(join), m_project(0), m_removed_cols(removed_col_cnt, removed_cols) {} + : m_join(join), m_project(nullptr), 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"); @@ -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()); } @@ -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; iget_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); } @@ -1402,7 +1402,7 @@ namespace datalog { m_free_vars(m_condition); } - virtual bool should_remove(const table_fact & f) const { + bool should_remove(const table_fact & f) const override { expr_ref_vector& args = const_cast(m_args); args.reset(); @@ -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; } @@ -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) { @@ -1502,11 +1502,11 @@ 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()); } - 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); @@ -1603,12 +1603,12 @@ 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)); } - 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(); @@ -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)); } }; @@ -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_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 7e274cbef..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); } @@ -294,12 +294,12 @@ 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); - 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); } @@ -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(); @@ -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()); } @@ -439,13 +439,13 @@ 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(); - 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); @@ -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); @@ -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); } @@ -600,12 +600,12 @@ 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); - 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_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..779172b0d 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; } @@ -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; @@ -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; } @@ -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) { @@ -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; iget_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";); @@ -826,7 +826,7 @@ namespace datalog { m_removed_cols.push_back(UINT_MAX); } - virtual table_base * operator()(const table_base & tb1, const table_base & tb2) { + table_base * operator()(const table_base & tb1, const table_base & tb2) override { const sparse_table & t1 = get(tb1); const sparse_table & t2 = get(tb2); @@ -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); @@ -882,7 +882,7 @@ namespace datalog { class sparse_table_plugin::union_fn : public table_union_fn { public: - virtual void operator()(table_base & tgt0, const table_base & src0, table_base * delta0) { + void operator()(table_base & tgt0, const table_base & src0, table_base * delta0) override { verbose_action _va("union"); sparse_table & tgt = get(tgt0); const sparse_table & src = get(src0); @@ -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); } @@ -941,7 +941,7 @@ namespace datalog { SASSERT(r_idx == m_removed_col_cnt); } - virtual table_base * operator()(const table_base & tb) { + table_base * operator()(const table_base & tb) override { verbose_action _va("project"); const sparse_table & t = get(tb); @@ -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); } @@ -985,7 +985,7 @@ namespace datalog { m_key.push_back(val); } - virtual table_base * operator()(const table_base & tb) { + table_base * operator()(const table_base & tb) override { verbose_action _va("select_equal_and_project"); const sparse_table & t = get(tb); @@ -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); } @@ -1072,7 +1072,7 @@ namespace datalog { } } - virtual table_base * operator()(const table_base & tb) { + table_base * operator()(const table_base & tb) override { verbose_action _va("rename"); const sparse_table & t = get(tb); @@ -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); } @@ -1210,7 +1210,7 @@ namespace datalog { } } - virtual void operator()(table_base & tgt0, const table_base & neg0) { + void operator()(table_base & tgt0, const table_base & neg0) override { sparse_table & tgt = get(tgt0); const sparse_table & neg = get(neg0); @@ -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); } @@ -1310,7 +1310,7 @@ namespace datalog { m_s2_cols.append(src2_cols); } - virtual void operator()(table_base & _t, const table_base & _s1, const table_base& _s2) { + void operator()(table_base & _t, const table_base & _s1, const table_base& _s2) override { verbose_action _va("negated_join"); sparse_table& t = get(_t); @@ -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_sparse_table.h b/src/muz/rel/dl_sparse_table.h index d3481dc7f..a9f3b31a4 100644 --- a/src/muz/rel/dl_sparse_table.h +++ b/src/muz/rel/dl_sparse_table.h @@ -69,39 +69,39 @@ namespace datalog { typedef sparse_table table; sparse_table_plugin(relation_manager & manager); - ~sparse_table_plugin(); + ~sparse_table_plugin() override; - virtual bool can_handle_signature(const table_signature & s) + bool can_handle_signature(const table_signature & s) override { return s.size()>0; } - 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..71ffd88f3 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); @@ -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); } @@ -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..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); @@ -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()); @@ -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); @@ -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()); @@ -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); @@ -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()); @@ -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); @@ -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()); @@ -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(), @@ -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()); @@ -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/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/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 c8a489d69..956244b4f 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; + return nullptr; } - virtual void to_formula(expr_ref& fml) const { + void to_formula(expr_ref& fml) const override { if (empty()) { fml = m.mk_false(); } @@ -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) { @@ -514,11 +514,11 @@ 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(); - 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); } @@ -540,10 +540,10 @@ 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())); + 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; } @@ -559,10 +559,10 @@ 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())); + 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); } @@ -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); @@ -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); } @@ -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(); @@ -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); } @@ -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(); @@ -768,7 +768,7 @@ namespace datalog { if (check_kind(r)) { return alloc(filter_equal_fn, get_manager(), value, col); } - return 0; + return nullptr; } @@ -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);); } @@ -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/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.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/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/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 febabb36d..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); @@ -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");); @@ -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); } @@ -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(); @@ -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); } @@ -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(); @@ -487,20 +487,20 @@ 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 { 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); 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); } @@ -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(); @@ -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; @@ -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())); @@ -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); } @@ -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)); @@ -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 { @@ -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; @@ -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 && @@ -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:");); @@ -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); } @@ -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(); @@ -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 15918d80d..01b2e8b43 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; } @@ -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; @@ -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_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_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.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_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.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_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_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 9f4f4e4fe..753bb43b8 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); } @@ -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_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/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_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_util.cpp b/src/muz/spacer/spacer_util.cpp index 83042cd6d..625ac4b7b 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; } @@ -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/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/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.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/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.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_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..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 @@ -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..a9461c1e3 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(); @@ -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_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.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_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.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_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.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 a8a7393cd..0d4c65d11 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. @@ -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); @@ -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..a17aecd15 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()); @@ -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_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.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_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.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_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.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_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..744efdb93 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(); @@ -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_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.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_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.cpp b/src/muz/transforms/dl_mk_rule_inliner.cpp index f1a4eb32b..584f44303 100644 --- a/src/muz/transforms/dl_mk_rule_inliner.cpp +++ b/src/muz/transforms/dl_mk_rule_inliner.cpp @@ -209,9 +209,7 @@ namespace datalog { rel->collect_non_empty_predicates(m_preds_with_facts); } - 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); @@ -258,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,13 +279,11 @@ 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; - if (stratum->size()==1) { + for (rule_stratifier::item_set * stratum : comps) { + 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 @@ -307,9 +301,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 +310,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); @@ -405,28 +394,22 @@ 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(); - 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; - SASSERT(stratum->size()==1); + 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); } } 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); - datalog::del_rule(m_mc, *r, true); + for (rule * r : m_inlined_rules) { + datalog::del_rule(m_mc, *r, false); } } @@ -439,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())); @@ -455,9 +436,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 +454,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,19 +486,14 @@ 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); + 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; @@ -549,16 +522,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 +539,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 +549,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 +564,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,16 +825,12 @@ 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; - } - } - + for (rule const* r : source) + if (has_quantifier(*r)) + return nullptr; if (m_context.get_model_converter()) { hsmc = alloc(horn_subsume_model_converter, m); @@ -893,7 +862,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 55b9b9487..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); /** @@ -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; } @@ -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), @@ -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..49a8ff423 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,9 +95,9 @@ 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; + 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_scale.h b/src/muz/transforms/dl_mk_scale.h index 10a5ea8b2..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. @@ -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.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_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..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; } @@ -271,17 +271,17 @@ 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; + return nullptr; } }; @@ -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,9 +391,9 @@ 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; + 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_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.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_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.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/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/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)); 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_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 12b063759..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 { - if (m_proc == 0) + std::ostream& operator()(std::ostream & out, var x) const override { + 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(); @@ -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 @@ -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 6d7e1c767..133652c1d 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); } }; @@ -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 9de7215e3..92c6e0ffb 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 @@ -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,39 +204,39 @@ 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; } - 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/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 9d32d48e3..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), @@ -243,7 +240,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 +440,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 +485,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 +521,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 +530,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) { @@ -718,7 +715,7 @@ public: } } - if (upper >= m_upper) { + if (upper > m_upper) { return; } @@ -820,7 +817,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 +841,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 +861,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/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/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 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..1950a199d 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) { @@ -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(); } } @@ -435,7 +437,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 +555,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 +927,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 +970,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 +1386,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 372c6672c..6af106ef3 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 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; } - 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() != nullptr; } + 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 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; } + 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.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_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.cpp b/src/opt/opt_solver.cpp index 49b48e68f..c5363816a 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) { @@ -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) { @@ -261,7 +265,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); @@ -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() { @@ -316,7 +321,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 +345,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/opt_solver.h b/src/opt/opt_solver.h index 4bd23c120..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; @@ -85,28 +86,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/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..9265312d4 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"); @@ -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"); @@ -999,13 +1002,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 +1021,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 +1194,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 +1206,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 +1214,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 +1226,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 } } @@ -1411,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) { @@ -1761,7 +1764,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 +1854,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 +2053,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 +2152,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 +2177,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 +2358,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 +2577,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 +2807,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 +2826,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 +2926,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 +2991,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/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/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 4f07b59dd..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) { @@ -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); } }; /** @@ -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); @@ -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 {} }; /** @@ -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 e28f6ae4f..c71e942a1 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(); @@ -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), @@ -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,13 +815,13 @@ 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); 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) { @@ -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..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; @@ -1383,7 +1383,7 @@ namespace qe { m_rewriter.updt_params(params); } - virtual ~quant_elim_plugin() { + ~quant_elim_plugin() override { reset(); } @@ -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); @@ -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); } @@ -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)); @@ -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 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) 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(); } @@ -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 6946f9566..1027f0b61 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; @@ -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.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..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), @@ -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: @@ -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; } @@ -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,8 +2478,8 @@ public: return false; } - virtual void assign(contains_app& x, expr* fml, rational const& vl) { - nlarith::branch_conditions *brs = 0; + void assign(contains_app& x, expr* fml, rational const& vl) override { + nlarith::branch_conditions *brs = nullptr; VERIFY (m_cache.find(x.x(), fml, brs)); SASSERT(vl.is_unsigned()); SASSERT(vl.get_unsigned() < brs->size()); @@ -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,8 +2515,8 @@ public: return true; } - virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) { - nlarith::branch_conditions *brs = 0; + void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) override { + nlarith::branch_conditions *brs = nullptr; VERIFY (m_cache.find(x.x(), fml, brs)); SASSERT(vl.is_unsigned()); SASSERT(vl.get_unsigned() < brs->size()); @@ -2534,8 +2534,8 @@ public: } - virtual unsigned get_weight(contains_app& x, expr* fml) { - obj_map* weights = 0; + unsigned get_weight(contains_app& x, expr* fml) override { + obj_map* weights = nullptr; unsigned weight = 0; if (!m_weights.find(fml, weights)) { weights = alloc(weight_m); @@ -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.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_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..fba76a7e6 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; @@ -65,11 +65,11 @@ 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; } - 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..603004020 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,24 +54,24 @@ 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); 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; } - 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..f708d5223 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; + m_target = nullptr; } - virtual cmd_arg_kind next_arg_kind(cmd_context & ctx) const { - if (m_target == 0) return CPK_EXPR; + cmd_arg_kind next_arg_kind(cmd_context & ctx) const override { + if (m_target == nullptr) 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..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) { @@ -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; } @@ -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; } @@ -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,14 +620,14 @@ 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. // 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); @@ -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";); // @@ -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); @@ -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,14 +768,14 @@ 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; } 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) @@ -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";); } @@ -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; @@ -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_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_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..8d688d80c 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(); @@ -107,11 +107,11 @@ namespace qe { subst_large_domain(x, eqs, uv, fml); } if (def) { - *def = 0; // TBD + *def = nullptr; // TBD } } - virtual bool solve(conj_enum& conjs, expr* fml) { return false; } + bool solve(conj_enum& conjs, expr* fml) override { return false; } private: @@ -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 3975945cb..e96626479 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 @@ -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 @@ -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); } } @@ -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) { @@ -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); @@ -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_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 250ffff4a..4c56b74a7 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 = nullptr, expr* l2 = nullptr, expr* l3 = nullptr) 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); @@ -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) { @@ -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,11 +325,11 @@ 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]); } - 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 5d1a74813..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); } @@ -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..f463a62e5 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); @@ -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,22 +1196,22 @@ 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) { 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,12 +1219,12 @@ 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); expr_ref fml(m); - mc = 0; pc = 0; core = 0; + mc = nullptr; pc = nullptr; core = nullptr; in->get_formulas(fmls); @@ -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_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..135a7417d 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; } @@ -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) { 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 191c49294..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), @@ -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,10 +103,10 @@ 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) { + if (weights != nullptr) { for (unsigned i = 0; i < sz; ++i) m_weights.push_back(weights[i]); } init_preprocess(); @@ -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; @@ -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); @@ -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; + return nullptr; } - 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]; } @@ -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 1f9dd91d1..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; } }; @@ -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; @@ -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 4a6171f70..4bb644a43 100644 --- a/src/sat/tactic/sat_tactic.cpp +++ b/src/sat/tactic/sat_tactic.cpp @@ -34,17 +34,17 @@ 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()); } - 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; + 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,33 +158,33 @@ class sat_tactic : public tactic { public: sat_tactic(ast_manager & m, params_ref const & p): - m_imp(0), + m_imp(nullptr), m_params(p) { } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(sat_tactic, m, m_params); } - virtual ~sat_tactic() { + ~sat_tactic() override { SASSERT(m_imp == 0); } - virtual void updt_params(params_ref const & p) { + void updt_params(params_ref const & p) override { m_params = p; } - virtual void collect_param_descrs(param_descrs & r) { + void collect_param_descrs(param_descrs & r) override { goal2sat::collect_param_descrs(r); sat2goal::collect_param_descrs(r); sat::solver::collect_param_descrs(r); } - void operator()(goal_ref const & g, - goal_ref_buffer & result, - 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/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 95f9e1eb3..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) { @@ -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) { @@ -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 307bdc671..593eb1d71 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)) @@ -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..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), @@ -46,7 +47,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), @@ -66,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; } @@ -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); } @@ -118,21 +118,24 @@ void asserted_formulas::push_assertion(expr * e, proof * pr, vector(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 baa8129bb..a006c9dd5 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); } @@ -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 c979e476e..d31cbc905 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);); @@ -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; } @@ -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) @@ -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 @@ -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,18 +3812,18 @@ 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(); } - 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; @@ -3924,7 +3924,7 @@ namespace smt { } #ifdef Z3DEBUG - virtual bool check_missing_instances() { + bool check_missing_instances() override { TRACE("missing_instance", tout << "checking for missing instances...\n";); flet l(m_check_missing_instances, true); rematch(false); @@ -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/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/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/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/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.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/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.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/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.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/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.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 e81c63306..77452d424 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 { } }; /** @@ -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); @@ -133,13 +133,13 @@ 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) { - value_set * set = 0; - expr * result = 0; + expr * get_some_value(sort * s) override { + value_set * set = nullptr; + expr * result = nullptr; if (m_sort2value_set.find(s, set) && !set->m_values.empty()) result = *(set->m_values.begin()); else @@ -147,8 +147,8 @@ public: return result; } - virtual bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { - value_set * set = 0; + bool get_some_values(sort * s, expr_ref & v1, expr_ref & v2) override { + value_set * set = nullptr; if (m_sort2value_set.find(s, set)) { switch (set->m_values.size()) { case 0: @@ -176,12 +176,12 @@ 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; + 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,14 +195,14 @@ public: result = mk_value(next, s, is_new); next++; if (has_max && next > max_size + start) { - return 0; + return nullptr; } } SASSERT(result != 0); 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/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 136805e43..d66849338 100644 --- a/src/smt/smt2_extra_cmds.cpp +++ b/src/smt/smt2_extra_cmds.cpp @@ -23,23 +23,23 @@ Notes: 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) { + 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; } + 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 = nullptr; } + void finalize(cmd_context & ctx) override { reset(ctx); } }; void install_smt2_extra_cmds(cmd_context & 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 6aef5f0a9..5c51b906f 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]; @@ -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"; @@ -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]; @@ -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); @@ -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"; @@ -747,19 +747,19 @@ 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(); } - 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]; @@ -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"; @@ -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_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 375ff7e6f..e20eae0bd 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -45,13 +45,13 @@ 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)), 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), @@ -132,6 +132,10 @@ namespace smt { return !m_manager.limit().inc(); } + void context::updt_params(params_ref const& p) { + m_params.append(p); + m_asserted_formulas.updt_params(p); + } void context::copy(context& src_ctx, context& dst_ctx) { ast_manager& dst_m = dst_ctx.get_manager(); @@ -176,7 +180,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 +236,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; } @@ -476,7 +480,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); } }; @@ -741,9 +745,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 +802,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 +830,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 +1027,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 +1047,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 +1071,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 +1095,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 +1132,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(); @@ -1451,7 +1455,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(); } @@ -1646,11 +1650,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 +2416,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 +2536,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 +2590,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 +2602,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 +2855,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 +2909,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 +2922,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 +2933,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 +2941,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) { @@ -2951,7 +2955,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); } }; @@ -2966,7 +2970,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 +3088,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 { @@ -3143,6 +3147,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); @@ -3404,7 +3409,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 +3871,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 +3944,7 @@ namespace smt { } } #endif - justification * js = 0; + justification * js = nullptr; if (m_manager.proofs_enabled()) { js = alloc(justification_proof_wrapper, *this, pr, false); } @@ -4131,7 +4136,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(); } }; @@ -4271,7 +4276,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); } @@ -4313,21 +4318,19 @@ 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);); } } 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 55d8f03f2..abfc8c499 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. } } }; @@ -262,6 +262,8 @@ namespace smt { return m_params; } + void updt_params(params_ref const& p); + bool get_cancel_flag(); region & get_region() { @@ -514,12 +516,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 { @@ -746,7 +748,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 +757,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; @@ -822,17 +824,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". @@ -1387,7 +1389,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 @@ -1460,7 +1462,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 +1484,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_context_pp.cpp b/src/smt/smt_context_pp.cpp index f5ba52128..f072a1d13 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 { @@ -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); } } @@ -413,19 +405,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 +444,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, @@ -490,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() << " #"; @@ -524,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/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_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_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 c38ef4e4a..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. } @@ -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(); } @@ -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); } } @@ -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.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 0af8e61ff..8354c8860 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; } }; @@ -255,39 +255,39 @@ 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) {} - 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 { 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) {} - 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"; } }; 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) {} - 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"; } }; /** @@ -322,16 +322,16 @@ 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) {} - 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 { @@ -341,25 +341,25 @@ 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) {} - 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 { 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) {} - 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 { @@ -371,12 +371,12 @@ 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) {} - 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"; } }; /** @@ -392,21 +392,21 @@ 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); - 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_kernel.cpp b/src/smt/smt_kernel.cpp index a7948725c..846d0235d 100644 --- a/src/smt/smt_kernel.cpp +++ b/src/smt/smt_kernel.cpp @@ -123,7 +123,6 @@ namespace smt { return m_kernel.preferred_sat(asms, cores); } - lbool find_mutexes(expr_ref_vector const& vars, 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/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 f443d671b..5e21c0dcc 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() { @@ -566,14 +566,14 @@ namespace smt { } } - virtual expr * eval(expr * n, bool model_completion) { - expr * r = 0; + expr * eval(expr * n, bool model_completion) override { + 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,8 +912,9 @@ 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()); + TRACE("model_finder", tout << "register " << f->get_name() << "\n";); m_model->register_decl(f, fi); SASSERT(fi->is_partial()); } @@ -1013,10 +1014,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 +1040,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; } @@ -1134,24 +1135,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 +1171,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 +1194,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 +1223,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 +1319,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 +1332,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 } @@ -1384,31 +1385,31 @@ 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: 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 +1429,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 +1462,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 +1483,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 +1497,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 +1509,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 +1523,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 +1541,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 +1559,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 +1590,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 +1607,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); } @@ -1656,7 +1657,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 +1737,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) { @@ -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; @@ -1850,30 +1846,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 +2385,7 @@ namespace smt { m_array_util(m), m_arith_util(m), m_bv_util(m), - m_info(0) { + m_info(nullptr) { } @@ -2416,7 +2412,7 @@ namespace smt { collect_macro_candidates(q); - m_info = 0; + m_info = nullptr; } }; @@ -2431,7 +2427,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,11 +2436,12 @@ 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); } 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; @@ -2453,7 +2450,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() {} @@ -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(); @@ -2524,7 +2518,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)) @@ -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 @@ -2596,7 +2590,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 +2601,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 +2613,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); @@ -2630,26 +2624,16 @@ namespace smt { s->insert(q); } - quantifier_set * get_q_f(func_decl * f) { - quantifier_set * s = 0; - 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 = 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; - 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()); @@ -2762,7 +2740,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): @@ -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);); @@ -2957,7 +2976,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 +3007,7 @@ namespace smt { m_satisfied(ev_handler(this)) { } - virtual ~hint_solver() { + ~hint_solver() override { reset(); } @@ -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); @@ -3020,7 +3039,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,12 +3050,9 @@ 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(); - 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)) { @@ -3094,14 +3107,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); @@ -3115,7 +3128,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; @@ -3139,7 +3152,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 +3170,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 +3195,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 +3361,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 +3381,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 +3412,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 ee133482d..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; } @@ -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..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,17 +408,17 @@ 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) { } - 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_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 00457c643..7db5110ee 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,33 +154,33 @@ 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); } 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); @@ -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,12 +325,12 @@ 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)) { 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); @@ -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; } @@ -487,18 +487,18 @@ namespace smt { } relevancy_ehs * ehs = get_handlers(n); - while (ehs != 0) { + while (ehs != nullptr) { ehs->head()->operator()(*this, n); ehs = ehs->tail(); } } } - 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(); @@ -510,13 +510,13 @@ 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(); } } - 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++) { @@ -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/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_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; diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index 1f9ad3ef7..d813f249a 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); + m_context.get_relevant_labels(nullptr, 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/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 edc4b4ff5..417922858 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) { - - mc = 0; pc = 0; core = 0; + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { + mc = nullptr; pc = nullptr; core = nullptr; reduce(*(in.get())); in->inc_depth(); result.push_back(in.get()); } - virtual void cleanup() { + void cleanup() override { reset_statistics(); m_solver.reset(); } @@ -127,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()); } @@ -141,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) {} }; @@ -194,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 57ac7b34b..14a9c3e11 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -47,17 +47,17 @@ 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";); } - 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; } @@ -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); @@ -144,14 +144,14 @@ 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; + 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/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..5040f1034 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); @@ -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())); @@ -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_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 b00648c36..46388fcf4 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; } @@ -469,10 +469,11 @@ 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, 0); + mk_clause(l_ante, l_conseq, 0, nullptr); if (ctx.relevancy()) { if (l_ante == false_literal) { ctx.mark_as_relevant(l_conseq); @@ -589,13 +590,13 @@ 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(); expr* x = n->get_arg(0); // to_int (to_real x) = x @@ -603,11 +604,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 +1207,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)); @@ -1347,8 +1352,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 +2347,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 +2621,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 +2629,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 +2666,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 +2677,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 +2727,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 +2739,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 +2814,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 +2849,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 +2981,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 +3174,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 +3294,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 +3393,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 4f15a6156..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(); @@ -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; } }; /** @@ -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 87b811e8f..ba6648dac 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. @@ -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.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..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,11 +824,11 @@ namespace smt { m_sort(s), m_num_entries(0), m_dim(0), - m_else(0), + m_else(nullptr), 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. @@ -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_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.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_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..873d1692d 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; } @@ -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 @@ -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; @@ -408,17 +408,17 @@ 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()); } - 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); @@ -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); @@ -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..f2e0f5bed 100644 --- a/src/smt/theory_bv.h +++ b/src/smt/theory_bv.h @@ -52,22 +52,22 @@ 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) {} - virtual ~bit_atom() {} - virtual bool is_bit() const { return true; } + bit_atom():m_occs(nullptr) {} + ~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..3d3d56055 100644 --- a/src/smt/theory_datatype.cpp +++ b/src/smt/theory_datatype.cpp @@ -30,10 +30,10 @@ 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. - virtual theory_id get_from_theory() const { return null_theory_id; } + theory_id get_from_theory() const override { return null_theory_id; } }; @@ -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); @@ -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) { @@ -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()); } @@ -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 @@ -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)); @@ -747,16 +747,16 @@ 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()) { - 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 == 0) { - r = m_util.get_constructor_recognizer(non_rec_c); + if (recognizer == nullptr) { + r = m_util.get_constructor_is(non_rec_c); } else if (!ctx.is_relevant(recognizer)) { ctx.mark_as_relevant(recognizer); @@ -773,10 +773,10 @@ 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]); + r = m_util.get_constructor_is(constructors[idx]); break; } else if (!ctx.is_relevant(curr)) { @@ -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 20fa371fa..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) { } }; @@ -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_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 1ad239e58..6090b2f5f 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); @@ -234,85 +234,85 @@ 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) { } - 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; + return nullptr; } // 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_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 ea02121d9..285c03946 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,11 +74,11 @@ 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; + app* result = nullptr; expr* n = m_node->get_owner(); sort* s = m_th.m().get_sort(n); func_decl* r, *v; @@ -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 { } @@ -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_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..b7aaff68a 100644 --- a/src/smt/theory_fpa.cpp +++ b/src/smt/theory_fpa.cpp @@ -32,13 +32,13 @@ 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); 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_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..f475a8279 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(); } }; @@ -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; @@ -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); } }; @@ -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_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..aca617daa 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); @@ -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; @@ -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(); } }; @@ -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; @@ -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); } @@ -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())); } @@ -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()); @@ -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; } }; @@ -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) { - return 0; + expr * get_fresh_value(sort * s) override { + return nullptr; } - 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..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() { @@ -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..b90735a07 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(); @@ -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); } @@ -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 = 0; + 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); @@ -2426,7 +2429,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,57 +2445,63 @@ 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(); +void theory_seq::add_itos_axiom(expr* e) { 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)) { - 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) { @@ -2656,7 +2665,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)); @@ -2691,7 +2700,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 +2713,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,27 +2723,26 @@ 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; 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()); 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)) { @@ -2757,12 +2765,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; @@ -2804,8 +2813,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)) { @@ -2848,7 +2857,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 +2953,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); @@ -3048,8 +3057,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))); } @@ -3074,7 +3086,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); @@ -3147,6 +3159,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); + } } @@ -3204,7 +3219,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 +3304,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 +3334,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 +3350,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 +3373,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)); @@ -3366,9 +3381,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 +3402,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,29 +3415,20 @@ 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)))); } 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 +3437,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 +3445,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 +3479,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 +3511,7 @@ static T* get_th_arith(context& ctx, theory_id afid, expr* e) { return dynamic_cast(th); } else { - return 0; + return nullptr; } } @@ -3566,7 +3571,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 +3643,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); @@ -3729,6 +3734,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 +3749,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)); } /* @@ -3769,7 +3776,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 +3805,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 +3861,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 +3934,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 +3973,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); @@ -4214,7 +4221,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); } @@ -4231,7 +4240,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 +4321,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 +4333,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 +4354,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 +4410,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 +4421,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 +4433,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 +4454,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 +4482,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 +4544,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 +4554,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 +4573,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 +4600,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 +4611,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 +4629,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 +4691,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 +4701,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 +4755,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 +4787,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 +4812,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 +4857,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 46f803f5b..21aedd7e3 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; @@ -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 @@ -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); @@ -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); @@ -531,7 +533,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); @@ -584,7 +586,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..93b4be173 100644 --- a/src/smt/theory_seq_empty.h +++ b/src/smt/theory_seq_empty.h @@ -63,18 +63,18 @@ 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); } - 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; } - 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; @@ -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,9 +120,9 @@ namespace smt { return u.str.mk_unit(v); } UNREACHABLE(); - return 0; + return nullptr; } - 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(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()); } + 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.cpp b/src/smt/theory_str.cpp index 56a54f964..69cf80de6 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; } } @@ -323,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;); @@ -332,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 { @@ -341,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()"); @@ -443,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); } @@ -458,7 +456,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 +615,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); @@ -641,7 +639,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 @@ -659,7 +656,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 +702,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 +767,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); @@ -844,14 +841,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 +1222,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 +1260,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,26 +1276,42 @@ 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); 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_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 @@ -1327,7 +1343,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( @@ -1350,6 +1366,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) { @@ -1424,9 +1454,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)) { @@ -1812,8 +1842,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(); @@ -2001,7 +2034,7 @@ namespace smt { } } // give up - return NULL; + return nullptr; } // trace code helper @@ -2091,7 +2124,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 +2195,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); @@ -2537,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; } @@ -2846,8 +2878,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 +2910,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 +2952,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 +3052,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 +3422,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 +3456,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 +3790,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 +4350,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 +4394,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 +4706,7 @@ namespace smt { return dynamic_cast(th); } else { - return 0; + return nullptr; } } @@ -4846,7 +4878,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 +4923,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 +5060,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 +5477,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 +5493,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) { @@ -5518,7 +5550,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) { @@ -5533,6 +5566,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) // --------------------------------------------------------- @@ -5562,8 +5598,8 @@ namespace smt { expr * arg1 = to_app(node)->get_arg(1); 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; @@ -5613,7 +5649,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++) { @@ -5822,8 +5858,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); @@ -6327,6 +6363,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; @@ -6405,9 +6448,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(); @@ -6425,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;); } @@ -6615,7 +6658,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 +6903,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 +7035,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 +7060,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 +7305,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 +7960,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 +7991,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 +8083,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 +8099,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 +8237,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 +8254,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 +8262,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 +8316,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); @@ -8721,8 +8764,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; @@ -8952,7 +8995,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 +9079,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 +9117,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 +9138,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); } } @@ -9243,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; @@ -9337,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); @@ -9381,20 +9424,20 @@ 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); } 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]); } return gen_val_options(freeVar, len_indicator, valTester, len_valueStr, i + 1); } - return NULL; + return nullptr; } } @@ -9552,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); @@ -9584,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]; } } @@ -9627,14 +9671,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 +10104,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 +10120,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 +10188,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 +10298,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 +10399,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 +10453,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 +10461,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 +10509,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 +10521,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 +10535,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 +10553,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 +10600,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 +10615,7 @@ namespace smt { if (hasEqc) { return to_app(n_eqc); } else { - return NULL; + return nullptr; } } @@ -10586,7 +10630,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 03fd31162..508a1c905 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; @@ -66,36 +66,19 @@ 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; } - 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 -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 NULL; - } - } - - 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 { @@ -104,8 +87,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()) { @@ -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; @@ -303,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; @@ -315,15 +298,18 @@ protected: 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; expr_ref_vector contains_map; @@ -332,10 +318,11 @@ 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 + obj_map regex_nfa_cache; // Regex term --> NFA svector char_set; std::map charSetLookupTable; @@ -447,7 +434,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); @@ -495,10 +482,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); @@ -616,10 +604,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 +616,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..64aa9f2c5 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; + return nullptr; } - 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_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 739a22c71..f2266a36f 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 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 { } + 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/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/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..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 /** @@ -84,12 +85,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 +103,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 +136,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 +147,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 +173,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 +181,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 +214,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 +259,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 +344,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/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/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..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); @@ -92,21 +92,21 @@ 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) { - pc = 0; mc = 0; core = 0; + 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 = 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); @@ -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.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/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..5c3c6bc7a 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(); } @@ -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 { @@ -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/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..6afac32b8 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); @@ -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(); @@ -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 37ffc6124..391d4b412 100644 --- a/src/tactic/aig/aig_tactic.cpp +++ b/src/tactic/aig/aig_tactic.cpp @@ -37,16 +37,16 @@ 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); } - 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."); } @@ -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 { @@ -90,19 +90,19 @@ 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; + mc = nullptr; pc = nullptr; core = nullptr; operator()(g); g->inc_depth(); 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..5d64fff95 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() { @@ -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; @@ -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..bf5381a5b 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); } @@ -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); } } @@ -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/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 d2453eba2..b86628f0b 100644 --- a/src/tactic/arith/card2bv_tactic.cpp +++ b/src/tactic/arith/card2bv_tactic.cpp @@ -36,29 +36,29 @@ 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(); + 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); @@ -101,7 +101,7 @@ public: SASSERT(g->is_well_sorted()); } - virtual void cleanup() { + void cleanup() override { } }; 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 6344c4c51..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); } } } @@ -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..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); @@ -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..46c6f1e1c 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,26 +134,26 @@ 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; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("elim01", *g); @@ -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..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) {} @@ -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,21 +136,20 @@ 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; + mc = nullptr; pc = nullptr; core = nullptr; m_trail.reset(); m_fd.reset(); m_max.reset(); @@ -176,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); @@ -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..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(); @@ -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 7ff7bd835..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(); @@ -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); @@ -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); @@ -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..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; @@ -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(); @@ -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; } } @@ -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..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) {} @@ -148,23 +148,23 @@ 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; + mc = nullptr; pc = nullptr; core = nullptr; m_01s->reset(); tactic_report report("cardinality-intro", *g); @@ -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..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)); @@ -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/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 6f5f49aee..256fc9b16 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,28 +408,28 @@ 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) { } - 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,15 +441,15 @@ 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); - 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); @@ -459,7 +459,7 @@ public: SASSERT(g->is_well_sorted()); } - virtual void cleanup(void) { + void cleanup() override { } }; diff --git a/src/tactic/arith/normalize_bounds_tactic.cpp b/src/tactic/arith/normalize_bounds_tactic.cpp index 2b3ff5ab0..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) { @@ -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.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_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..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); @@ -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..38bb38330 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) { @@ -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 7e89794ce..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 @@ -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,14 +823,14 @@ 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; + mc = nullptr; pc = nullptr; core = nullptr; tactic_report report("purify-arith", *g); TRACE("purify_arith", g->display(tout);); bool produce_proofs = g->proofs_enabled(); @@ -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..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; } @@ -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..027938752 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) { @@ -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++; } } @@ -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..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";); @@ -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); + return alloc(bit_blaster_tactic, m, nullptr, 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); @@ -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 e7e374184..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"); @@ -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..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()); @@ -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 { @@ -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 a279e441b..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)) { @@ -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; @@ -382,7 +382,7 @@ namespace { } interval ctx, intr; - result = 0; + result = nullptr; if (b.is_full() && b.tight) { result = m.mk_true(); @@ -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(); } }; @@ -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)) { @@ -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..3bcb2e02b 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) { @@ -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 87f43ae8d..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); ); @@ -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..8f164a921 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,22 +107,22 @@ 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) { - mc = 0; pc = 0; core = 0; + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { + mc = nullptr; pc = nullptr; core = nullptr; bool produce_proofs = g->proofs_enabled(); tactic_report report("dt2bv", *g); unsigned size = g->size(); @@ -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..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); @@ -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..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(); @@ -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..d50458cf1 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); @@ -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()); } @@ -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..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(); @@ -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_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 65cdef147..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)); } } @@ -46,24 +46,24 @@ 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); 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()); @@ -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..0e08395ad 100644 --- a/src/tactic/core/collect_statistics_tactic.cpp +++ b/src/tactic/core/collect_statistics_tactic.cpp @@ -51,22 +51,22 @@ 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) { - mc = 0; + void operator()(goal_ref const & g, goal_ref_buffer & result, + model_converter_ref & mc, proof_converter_ref & pc, + expr_dependency_ref & core) override { + mc = nullptr; tactic_report report("collect-statistics", *g); collect_proc cp(m, m_stats); @@ -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..93a0b2e88 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; }; @@ -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(t, r)); 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/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..f809f2a74 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) { - mc = 0; pc = 0; core = 0; + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { + mc = nullptr; pc = nullptr; core = nullptr; (*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..d8f613044 100644 --- a/src/tactic/core/distribute_forall_tactic.cpp +++ b/src/tactic/core/distribute_forall_tactic.cpp @@ -93,23 +93,23 @@ class distribute_forall_tactic : public tactic { rw * m_rw; public: - distribute_forall_tactic():m_rw(0) {} + distribute_forall_tactic():m_rw(nullptr) {} - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(distribute_forall_tactic); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - 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(); 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,10 +131,10 @@ public: result.push_back(g.get()); TRACE("distribute-forall", g->display(tout);); SASSERT(g->is_well_sorted()); - m_rw = 0; + m_rw = nullptr; } - virtual void cleanup() {} + void cleanup() override {} }; tactic * mk_distribute_forall_tactic(ast_manager & m, params_ref const & p) { diff --git a/src/tactic/core/dom_simplify_tactic.cpp b/src/tactic/core/dom_simplify_tactic.cpp index 2099eebf0..47f96a7d9 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(g.form(i), r)); } 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(g.form(i), r)); } 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 56eea8d9a..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); @@ -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..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(); @@ -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..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(); @@ -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..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); @@ -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..4641023ad 100644 --- a/src/tactic/core/nnf_tactic.cpp +++ b/src/tactic/core/nnf_tactic.cpp @@ -33,34 +33,34 @@ class nnf_tactic : public tactic { } ~set_nnf() { - m_owner.m_nnf = 0; + m_owner.m_nnf = nullptr; } }; public: nnf_tactic(params_ref const & p): m_params(p), - m_nnf(0) { + m_nnf(nullptr) { TRACE("nnf", tout << "nnf_tactic constructor: " << p << "\n";); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return alloc(nnf_tactic, m_params); } - virtual ~nnf_tactic() {} + ~nnf_tactic() override {} - virtual void updt_params(params_ref const & p) { m_params = p; } + void updt_params(params_ref const & p) override { m_params = p; } - virtual void collect_param_descrs(param_descrs & r) { nnf::get_param_descrs(r); } + void collect_param_descrs(param_descrs & r) override { nnf::get_param_descrs(r); } - virtual void operator()(goal_ref const & g, - goal_ref_buffer & result, - 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; + 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()); @@ -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 6d9d63971..519a4c580 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. @@ -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()); @@ -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/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. diff --git a/src/tactic/core/pb_preprocess_tactic.cpp b/src/tactic/core/pb_preprocess_tactic.cpp index 6a0d7205b..8dfad6fe2 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,20 +136,19 @@ 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; + pc = nullptr; core = nullptr; if (g->proofs_enabled()) { throw tactic_exception("pb-preprocess does not support proofs"); @@ -251,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; } } @@ -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(); @@ -329,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";); } } @@ -579,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);); } @@ -652,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 607ecbd79..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; } }; @@ -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..333e2638c 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) { @@ -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/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..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); @@ -790,40 +790,40 @@ 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; 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 @@ -833,18 +833,18 @@ 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; } }; 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 7a2df81b5..37d9e902e 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,32 +86,32 @@ 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);); - 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); @@ -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..81f626f38 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 { @@ -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 dbfc748b0..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);); @@ -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..9fad9259d 100644 --- a/src/tactic/fpa/fpa2bv_model_converter.h +++ b/src/tactic/fpa/fpa2bv_model_converter.h @@ -33,29 +33,29 @@ 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) : 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 6d90b46ea..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(); @@ -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/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/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..b295a98b7 100644 --- a/src/tactic/model_converter.cpp +++ b/src/tactic/model_converter.cpp @@ -23,33 +23,33 @@ 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); } }; 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); } @@ -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); } }; @@ -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) { @@ -132,44 +132,44 @@ 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); } }; 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 c99ea545a..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), @@ -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,17 +744,17 @@ 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);); 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 58078e106..170780ab0 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) { @@ -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; @@ -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..3f4a20774 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); @@ -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; @@ -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..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) { @@ -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..dcd1dc500 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); } }; @@ -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; @@ -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; @@ -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() { @@ -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..26a87fe04 100644 --- a/src/tactic/proof_converter.cpp +++ b/src/tactic/proof_converter.cpp @@ -23,24 +23,24 @@ 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); } }; 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); } @@ -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); } }; @@ -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) { @@ -111,25 +111,25 @@ 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"; } }; 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/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.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/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..88792e955 100644 --- a/src/tactic/sine_filter.cpp +++ b/src/tactic/sine_filter.cpp @@ -38,22 +38,22 @@ 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) { - mc = 0; pc = 0; core = 0; + void operator()(goal_ref const & g, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { + 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); @@ -73,7 +73,7 @@ public: mc = fmc; } - virtual void cleanup() { + void cleanup() override { } private: 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/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.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_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/sls/sls_tactic.cpp b/src/tactic/sls/sls_tactic.cpp index 19937e8b0..fa9ea4e4a 100644 --- a/src/tactic/sls/sls_tactic.cpp +++ b/src/tactic/sls/sls_tactic.cpp @@ -42,30 +42,30 @@ 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(); + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); TRACE("sls", g->display(tout);); tactic_report report("sls", *g); @@ -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/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/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..bc2f55061 100644 --- a/src/tactic/smtlogics/qfufbv_tactic.cpp +++ b/src/tactic/smtlogics/qfufbv_tactic.cpp @@ -51,14 +51,14 @@ 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) { - mc = 0; + expr_dependency_ref & core) override { + mc = nullptr; ast_manager& m(g->m()); tactic_report report("qfufbv_ackr", *g); fail_if_unsat_core_generation("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: @@ -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 6c4ca7476..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() { @@ -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); @@ -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/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..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: @@ -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..a9ada3a11 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(); @@ -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); } @@ -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,22 +367,22 @@ 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; 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 { @@ -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; @@ -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()); @@ -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; @@ -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); } @@ -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() 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 @@ -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); } @@ -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,22 +1079,22 @@ 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(); - mc = 0; - pc = 0; - core = 0; + mc = nullptr; + pc = nullptr; + core = nullptr; throw tactic_exception("failed-if-branching tactical"); } }; - 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,27 +1271,27 @@ 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) { - mc = 0; - pc = 0; - core = 0; + void operator()(goal_ref const & in, + goal_ref_buffer & result, + model_converter_ref & mc, + proof_converter_ref & pc, + expr_dependency_ref & core) override { + mc = nullptr; + pc = nullptr; + core = nullptr; if (m_p->operator()(*(in.get())).is_true()) { throw tactic_exception("fail-if tactic"); } result.push_back(in.get()); } - virtual tactic * translate(ast_manager & m) { + tactic * translate(ast_manager & m) override { return this; } }; @@ -1308,13 +1308,13 @@ 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; + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); result.push_back(in.get()); } @@ -1323,20 +1323,20 @@ 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; + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); result.push_back(in.get()); } @@ -1345,20 +1345,20 @@ 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; + mc = nullptr; pc = nullptr; core = nullptr; result.reset(); result.push_back(in.get()); } @@ -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/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); diff --git a/src/tactic/ufbv/macro_finder_tactic.cpp b/src/tactic/ufbv/macro_finder_tactic.cpp index 3a482f37c..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(); @@ -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..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(); @@ -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.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/tactic/ufbv/ufbv_rewriter_tactic.cpp b/src/tactic/ufbv/ufbv_rewriter_tactic.cpp index 615593317..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()); @@ -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/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/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/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/heap.cpp b/src/test/heap.cpp index 39353af76..2c77b939e 100644 --- a/src/test/heap.cpp +++ b/src/test/heap.cpp @@ -19,20 +19,22 @@ Revision History: #include #include "util/util.h" #include "util/heap.h" -#include "util/hashtable.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; }}; -typedef int_hashtable > int_set; #define N 10000 static random_gen heap_rand(1); static void tst1() { int_heap h(N); - int_set t; +// 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 +43,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 +87,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 +139,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/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/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; 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/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/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/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/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..742438814 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(); } @@ -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) { @@ -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/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/dense_matrix.h b/src/util/lp/dense_matrix.h index 6b157ffd4..e2ee54058 100644 --- a/src/util/lp/dense_matrix.h +++ b/src/util/lp/dense_matrix.h @@ -79,13 +79,14 @@ 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 {} +#ifdef Z3DEBUG + T get_elem(unsigned i, unsigned j) const override { return m_values[i * m_n + j]; } +#endif - T get_elem(unsigned i, unsigned j) const { 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 6c30e2146..abed6d06b 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,15 +80,15 @@ 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 - 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; } + 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; } + void set_number_of_columns(unsigned n) override { m_length = n; } #endif void divide_by_diagonal_element() { m_column_vector.divide(m_diagonal_element); 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_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/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..f2cae7961 100644 --- a/src/util/lp/lu.h +++ b/src/util/lp/lu.h @@ -67,31 +67,31 @@ 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); #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; + 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 &) { + 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/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), diff --git a/src/util/lp/permutation_matrix.h b/src/util/lp/permutation_matrix.h index 7cf64a5c7..3c89b3646 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); @@ -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); diff --git a/src/util/lp/row_eta_matrix.h b/src/util/lp/row_eta_matrix.h index c287e263a..2bc0ac24e 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,16 +74,16 @@ 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 - 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/sparse_matrix.h b/src/util/lp/sparse_matrix.h index 400f2bfc0..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,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); } + 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(); } - 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; diff --git a/src/util/lp/square_dense_submatrix.h b/src/util/lp/square_dense_submatrix.h index 3e88e8114..d43b2eadd 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,18 +207,18 @@ 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; - 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); }; 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/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), 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.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/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/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..2b8924e9f 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,24 @@ public: if (e) { v = e->get_data().get_value(); } - return (0 != e); + 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) != 0; + 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) { 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..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); @@ -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; @@ -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; @@ -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"); @@ -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 @@ -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/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; 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 67995c2aa..283b4c206 100644 --- a/src/util/timeout.cpp +++ b/src/util/timeout.cpp @@ -27,12 +27,12 @@ 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: - 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"; @@ -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/top_sort.h b/src/util/top_sort.h new file mode 100644 index 000000000..5f7db9c3e --- /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.contains(m_stack_P.back()) && 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_ */ 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 bba71fb00..b9f4602c7 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,8 +76,8 @@ public: SASSERT(m_ptr == 0); } - virtual void undo(Ctx & ctx) { - m_ptr = 0; + void undo(Ctx & ctx) override { + m_ptr = nullptr; } }; @@ -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) { 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) { 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