From c6bd31e01d0de893a4b301a5134babcd5c442750 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 10:05:13 -0800 Subject: [PATCH 01/34] working on new global parameter setting framework Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 5edace6cb..4bbaa80a8 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1601,8 +1601,10 @@ def mk_mem_initializer_cpp(cnames, path): fullname = '%s/mem_initializer.cpp' % path fout = open(fullname, 'w') fout.write('// Automatically generated file.\n') - initializer_pat = re.compile('[ \t]*ADD_INITIALIZER\(\'([^\']*)\'\)') - finalizer_pat = re.compile('[ \t]*ADD_FINALIZER\(\'([^\']*)\'\)') + initializer_pat = re.compile('[ \t]*ADD_INITIALIZER\(\'([^\']*)\'\)') + # ADD_INITIALIZER with priority + initializer_prio_pat = re.compile('[ \t]*ADD_INITIALIZER\(\'([^\']*)\',[ \t]*(-?[0-9]*)\)') + finalizer_pat = re.compile('[ \t]*ADD_FINALIZER\(\'([^\']*)\'\)') for cname in cnames: c = get_component(cname) h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) @@ -1615,15 +1617,22 @@ def mk_mem_initializer_cpp(cnames, path): if not added_include: added_include = True fout.write('#include"%s"\n' % h_file) - initializer_cmds.append(m.group(1)) + initializer_cmds.append((m.group(1), 0)) + m = initializer_prio_pat.match(line) + if m: + if not added_include: + added_include = True + fout.write('#include"%s"\n' % h_file) + initializer_cmds.append((m.group(1), int(m.group(2)))) m = finalizer_pat.match(line) if m: if not added_include: added_include = True fout.write('#include"%s"\n' % h_file) finalizer_cmds.append(m.group(1)) + initializer_cmds.sort(key=lambda tup: tup[1]) fout.write('void mem_initialize() {\n') - for cmd in initializer_cmds: + for (cmd, prio) in initializer_cmds: fout.write(cmd) fout.write('\n') fout.write('}\n') From c3055207ed7577199a39e1310f5319c8af30aca3 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 10:30:16 -0800 Subject: [PATCH 02/34] updated release notes Signed-off-by: Leonardo de Moura --- RELEASE_NOTES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 8fab69938..617b44bd0 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -18,6 +18,8 @@ Version 4.3.2 - Java bindings. To enable them, we must use the option `--java` when executing the `mk_make.py` script. Example: `python scripts/mk_make.py --java +- Fixed crash when parsing incorrect formulas. The crash was introduced when support for "arithmetic coercions" was added in Z3 4.3.0. + Version 4.3.1 ============= From cf28cbab0af8293fe5110ebbf5d8377b8ce40ec4 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 17:19:12 -0800 Subject: [PATCH 03/34] saved params work Signed-off-by: Leonardo de Moura --- .gitignore | 1 + RELEASE_NOTES | 2 +- scripts/mk_util.py | 53 +++- src/api/api_ast.cpp | 4 +- src/api/api_config_params.cpp | 7 +- src/api/api_datalog.cpp | 4 +- src/api/api_solver.cpp | 12 +- src/api/api_tactic.cpp | 4 +- src/ast/normal_forms/nnf.cpp | 26 +- src/ast/normal_forms/nnf.h | 3 + src/ast/pp.cpp | 18 ++ src/ast/pp.h | 6 + src/ast/rewriter/arith_rewriter.cpp | 48 ++-- src/ast/rewriter/array_rewriter.cpp | 8 +- .../bit_blaster/bit_blaster_rewriter.cpp | 12 +- src/ast/rewriter/bool_rewriter.cpp | 25 +- src/ast/rewriter/bv_rewriter.cpp | 32 +-- src/ast/rewriter/poly_rewriter_def.h | 18 +- src/ast/rewriter/th_rewriter.cpp | 22 +- src/ast/rewriter/th_rewriter.h | 4 +- src/cmd_context/basic_cmds.cpp | 51 +--- src/cmd_context/cmd_context.cpp | 22 +- src/cmd_context/cmd_context.h | 5 + src/cmd_context/eval_cmd.cpp | 2 +- src/cmd_context/extra_cmds/dbg_cmds.cpp | 24 +- src/cmd_context/extra_cmds/subpaving_cmds.cpp | 2 +- src/cmd_context/parametric_cmd.cpp | 9 +- src/cmd_context/simplify_cmd.cpp | 18 +- src/cmd_context/tactic_cmds.cpp | 42 +-- .../arith_simplifier_params.cpp | 4 +- src/front_end_params/bit_blaster_params.h | 4 +- src/front_end_params/bv_simplifier_params.h | 4 +- src/front_end_params/cnf_params.cpp | 4 +- src/front_end_params/dyn_ack_params.cpp | 12 +- src/front_end_params/front_end_params.cpp | 54 ++-- src/front_end_params/model_params.cpp | 10 +- src/front_end_params/nnf_params.cpp | 8 +- .../params2front_end_params.cpp | 58 ++-- src/front_end_params/parser_params.cpp | 4 +- .../pattern_inference_params.cpp | 20 +- src/front_end_params/preprocessor_params.h | 36 +-- src/front_end_params/qi_params.h | 42 +-- src/front_end_params/smt_params.cpp | 112 ++++---- src/front_end_params/theory_arith_params.cpp | 88 +++---- src/front_end_params/theory_array_params.h | 20 +- src/front_end_params/theory_bv_params.h | 12 +- src/front_end_params/theory_datatype_params.h | 2 +- src/math/polynomial/algebraic_numbers.cpp | 24 +- src/math/polynomial/algebraic_numbers.h | 3 + src/math/polynomial/polynomial.cpp | 12 +- src/math/polynomial/polynomial.h | 3 + src/math/subpaving/subpaving_t_def.h | 32 +-- .../subpaving/tactic/subpaving_tactic.cpp | 24 +- src/model/model_evaluator.cpp | 12 +- src/muz_qe/datalog_parser.cpp | 2 +- src/muz_qe/dl_bmc_engine.cpp | 2 +- src/muz_qe/dl_cmds.cpp | 14 +- src/muz_qe/dl_context.cpp | 70 ++--- src/muz_qe/dl_context.h | 36 +-- src/muz_qe/dl_mk_array_blast.cpp | 2 +- src/muz_qe/dl_mk_bit_blast.cpp | 6 +- src/muz_qe/dl_mk_rule_inliner.cpp | 6 +- src/muz_qe/dl_smt_relation.cpp | 2 +- src/muz_qe/horn_tactic.cpp | 4 +- src/muz_qe/pdr_context.cpp | 26 +- src/muz_qe/pdr_dl_interface.cpp | 52 ++-- src/muz_qe/pdr_interpolant_provider.cpp | 2 +- src/muz_qe/pdr_prop_solver.cpp | 2 +- src/muz_qe/pdr_reachable_cache.cpp | 2 +- src/muz_qe/pdr_smt_context_manager.cpp | 2 +- src/muz_qe/qe.cpp | 10 +- src/muz_qe/qe_cmd.cpp | 8 +- src/muz_qe/qe_lite.cpp | 14 +- src/muz_qe/qe_sat_tactic.cpp | 16 +- src/muz_qe/qe_tactic.cpp | 4 +- src/nlsat/nlsat_solver.cpp | 32 +-- src/nlsat/tactic/goal2nlsat.cpp | 6 +- src/nlsat/tactic/qfnra_nlsat_tactic.cpp | 8 +- src/sat/sat_asymm_branch.cpp | 12 +- src/sat/sat_config.cpp | 86 +++--- src/sat/sat_probing.cpp | 10 +- src/sat/sat_scc.cpp | 4 +- src/sat/sat_simplifier.cpp | 64 ++--- src/sat/sat_solver.cpp | 2 +- src/sat/tactic/goal2sat.cpp | 12 +- src/sat/tactic/sat_tactic.cpp | 2 +- src/shell/datalog_frontend.cpp | 12 +- src/shell/dimacs_frontend.cpp | 2 +- src/shell/main.cpp | 15 +- src/smt/arith_eq_solver.cpp | 4 +- src/smt/smt_implied_equalities.cpp | 6 +- src/smt/tactic/smt_tactic.cpp | 12 +- src/tactic/aig/aig_tactic.cpp | 8 +- src/tactic/arith/add_bounds_tactic.cpp | 8 +- src/tactic/arith/bound_propagator.cpp | 12 +- src/tactic/arith/bv2int_rewriter.cpp | 2 +- src/tactic/arith/diff_neq_tactic.cpp | 4 +- src/tactic/arith/factor_tactic.cpp | 4 +- src/tactic/arith/fm_tactic.cpp | 32 +-- src/tactic/arith/lia2pb_tactic.cpp | 12 +- src/tactic/arith/nla2bv_tactic.cpp | 12 +- src/tactic/arith/normalize_bounds_tactic.cpp | 4 +- src/tactic/arith/pb2bv_tactic.cpp | 10 +- src/tactic/arith/purify_arith_tactic.cpp | 16 +- src/tactic/arith/recover_01_tactic.cpp | 4 +- src/tactic/bv/bit_blaster_tactic.cpp | 10 +- src/tactic/bv/bv1_blaster_tactic.cpp | 6 +- src/tactic/bv/max_bv_sharing_tactic.cpp | 8 +- src/tactic/core/cofactor_elim_term_ite.cpp | 2 +- src/tactic/core/ctx_simplify_tactic.cpp | 10 +- src/tactic/core/elim_term_ite_tactic.cpp | 4 +- src/tactic/core/elim_uncnstr_tactic.cpp | 4 +- src/tactic/core/nnf_tactic.cpp | 2 +- src/tactic/core/propagate_values_tactic.cpp | 4 +- src/tactic/core/simplify_tactic.cpp | 2 +- src/tactic/core/solve_eqs_tactic.cpp | 12 +- src/tactic/core/split_clause_tactic.cpp | 4 +- src/tactic/core/tseitin_cnf_tactic.cpp | 26 +- src/tactic/fpa/fpa2bv_rewriter.h | 4 +- src/tactic/fpa/qffpa_tactic.cpp | 2 +- src/tactic/sls/sls_tactic.cpp | 48 ++-- src/tactic/smtlogics/qfnra_tactic.cpp | 2 +- src/tactic/smtlogics/quant_tactics.cpp | 2 +- src/tactic/ufbv/macro_finder_tactic.cpp | 4 +- src/test/dl_product_relation.cpp | 2 +- src/util/double_manager.h | 2 +- src/util/gparams.cpp | 249 ++++++++++++++++++ src/util/gparams.h | 122 +++++++++ src/util/params.cpp | 88 ++++++- src/util/params.h | 11 +- 130 files changed, 1469 insertions(+), 948 deletions(-) create mode 100644 src/util/gparams.cpp create mode 100644 src/util/gparams.h diff --git a/.gitignore b/.gitignore index a26ee7565..3fe56e9f3 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ config.status configure install_tactic.cpp mem_initializer.cpp +gparams_register_modules.cpp scripts/config-debug.mk scripts/config-release.mk src/api/api_commands.cpp diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 617b44bd0..4c74b41a5 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -16,7 +16,7 @@ Version 4.3.2 - Fixed incorrect result returned by Z3_solver_get_num_scopes. (Thanks to Herman Venter). This bug was introduced in Z3 4.3.0 -- Java bindings. To enable them, we must use the option `--java` when executing the `mk_make.py` script. Example: `python scripts/mk_make.py --java +- Java bindings. To enable them, we must use the option `--java` when executing the `mk_make.py` script. Example: `python scripts/mk_make.py --java` - Fixed crash when parsing incorrect formulas. The crash was introduced when support for "arithmetic coercions" was added in Z3 4.3.0. diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 4bbaa80a8..0c40d9a56 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1418,6 +1418,7 @@ def mk_auto_src(): mk_pat_db() mk_all_install_tactic_cpps() mk_all_mem_initializer_cpps() + mk_all_gparams_register_modules() # TODO: delete after src/ast/pattern/expr_pattern_match # database.smt ==> database.h @@ -1594,7 +1595,7 @@ def mk_all_install_tactic_cpps(): # This file implements the procedures # void mem_initialize() # void mem_finalize() -# This procedures are invoked by the Z3 memory_manager +# These procedures are invoked by the Z3 memory_manager def mk_mem_initializer_cpp(cnames, path): initializer_cmds = [] finalizer_cmds = [] @@ -1653,6 +1654,56 @@ def mk_all_mem_initializer_cpps(): cnames.append(c.name) mk_mem_initializer_cpp(cnames, c.src_dir) +# Generate an mem_initializer.cpp at path. +# This file implements the procedure +# void gparams_register_modules() +# This procedure is invoked by gparams::init() +def mk_gparams_register_modules(cnames, path): + cmds = [] + mod_cmds = [] + fullname = '%s/gparams_register_modules.cpp' % path + fout = open(fullname, 'w') + fout.write('// Automatically generated file.\n') + fout.write('#include"gparams.h"\n') + reg_pat = re.compile('[ \t]*REG_PARAMS\(\'([^\']*)\'\)') + reg_mod_pat = re.compile('[ \t]*REG_MODULE_PARAMS\(\'([^\']*)\', *\'([^\']*)\'\)') + for cname in cnames: + c = get_component(cname) + h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) + for h_file in h_files: + added_include = False + fin = open("%s/%s" % (c.src_dir, h_file), 'r') + for line in fin: + m = reg_pat.match(line) + if m: + if not added_include: + added_include = True + fout.write('#include"%s"\n' % h_file) + cmds.append((m.group(1))) + m = reg_mod_pat.match(line) + if m: + if not added_include: + added_include = True + fout.write('#include"%s"\n' % h_file) + mod_cmds.append((m.group(1), m.group(2))) + fout.write('void gparams_register_modules() {\n') + for code in cmds: + fout.write('{ param_descrs d; %s(*d); gparams::register_global(d); }\n' % code) + for (mod, code) in mod_cmds: + fout.write('{ param_descrs * d = alloc(param_descrs); %s(*d); gparams::register_module("%s", d); }\n' % (code, mod)) + fout.write('}\n') + if VERBOSE: + print "Generated '%s'" % fullname + +def mk_all_gparams_register_modules(): + if not ONLY_MAKEFILES: + for c in get_components(): + if c.require_mem_initializer(): + cnames = [] + cnames.extend(c.deps) + cnames.append(c.name) + mk_gparams_register_modules(cnames, c.src_dir) + # Generate a .def based on the files at c.export_files slot. def mk_def_file(c): pat1 = re.compile(".*Z3_API.*") diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index aeddf63c3..1503b387f 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -674,8 +674,8 @@ extern "C" { ast_manager & m = mk_c(c)->m(); expr * a = to_expr(_a); params_ref p = to_param_ref(_p); - unsigned timeout = p.get_uint(":timeout", UINT_MAX); - bool use_ctrl_c = p.get_bool(":ctrl-c", false); + unsigned timeout = p.get_uint("timeout", UINT_MAX); + bool use_ctrl_c = p.get_bool("ctrl_c", false); th_rewriter m_rw(m, p); expr_ref result(m); cancel_eh eh(m_rw); diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 07e043726..550212cf9 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -21,6 +21,7 @@ Revision History: #include"pp.h" #include"api_log_macros.h" #include"api_util.h" +#include"cmd_context.h" #include"symbol.h" namespace api { @@ -41,8 +42,6 @@ namespace api { }; -extern std::string smt_keyword2opt_name(symbol const & opt); - extern "C" { Z3_config Z3_API Z3_mk_config() { LOG_Z3_mk_config(); @@ -62,7 +61,7 @@ extern "C" { api::config_params* p = reinterpret_cast(c); if (param_id != 0 && param_id[0] == ':') { // Allow SMT2 style paramater names such as :model, :relevancy, etc - std::string new_param_id = smt_keyword2opt_name(symbol(param_id)); + std::string new_param_id = smt2_keyword_to_param(symbol(param_id)); p->m_ini.set_param_value(new_param_id.c_str(), param_value); } else { @@ -91,7 +90,7 @@ extern "C" { } if (param_id != 0 && param_id[0] == ':') { // Allow SMT2 style paramater names such as :model, :relevancy, etc - std::string new_param_id = smt_keyword2opt_name(symbol(param_id)); + std::string new_param_id = smt2_keyword_to_param(symbol(param_id)); ini.set_param_value(new_param_id.c_str(), param_value); } else { diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 0200a4405..3c434600b 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -265,7 +265,7 @@ extern "C" { RESET_ERROR_CODE(); lbool r = l_undef; cancel_eh eh(*to_fixedpoint_ref(d)); - unsigned timeout = to_fixedpoint(d)->m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", UINT_MAX); api::context::set_interruptable(*(mk_c(c)), eh); { scoped_timer timer(timeout, &eh); @@ -289,7 +289,7 @@ extern "C" { LOG_Z3_fixedpoint_query_relations(c, d, num_relations, relations); RESET_ERROR_CODE(); lbool r = l_undef; - unsigned timeout = to_fixedpoint(d)->m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", UINT_MAX); cancel_eh eh(*to_fixedpoint_ref(d)); api::context::set_interruptable(*(mk_c(c)), eh); { diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index 790ca8f59..a85e8d83a 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -37,8 +37,8 @@ extern "C" { ast_manager & m = mk_c(c)->m(); Z3_solver_ref * s = to_solver(_s); s->m_solver->set_produce_proofs(m.proofs_enabled()); - s->m_solver->set_produce_unsat_cores(s->m_params.get_bool(":unsat-core", false)); - s->m_solver->set_produce_models(s->m_params.get_bool(":model", true)); + s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", false)); + s->m_solver->set_produce_models(s->m_params.get_bool("model", true)); s->m_solver->set_front_end_params(mk_c(c)->fparams()); s->m_solver->updt_params(s->m_params); s->m_solver->init(m, s->m_logic); @@ -127,8 +127,8 @@ extern "C" { LOG_Z3_solver_set_params(c, s, p); RESET_ERROR_CODE(); if (to_solver(s)->m_initialized) { - bool old_model = to_solver(s)->m_params.get_bool(":model", true); - bool new_model = to_param_ref(p).get_bool(":model", true); + bool old_model = to_solver(s)->m_params.get_bool("model", true); + bool new_model = to_param_ref(p).get_bool("model", true); if (old_model != new_model) to_solver_ref(s)->set_produce_models(new_model); to_solver_ref(s)->updt_params(to_param_ref(p)); @@ -238,8 +238,8 @@ extern "C" { } } expr * const * _assumptions = to_exprs(assumptions); - unsigned timeout = to_solver(s)->m_params.get_uint(":timeout", UINT_MAX); - bool use_ctrl_c = to_solver(s)->m_params.get_bool(":ctrl-c", false); + unsigned timeout = to_solver(s)->m_params.get_uint("timeout", UINT_MAX); + bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false); cancel_eh eh(*to_solver_ref(s)); api::context::set_interruptable(*(mk_c(c)), eh); lbool result; diff --git a/src/api/api_tactic.cpp b/src/api/api_tactic.cpp index ff55923a4..5bce218e6 100644 --- a/src/api/api_tactic.cpp +++ b/src/api/api_tactic.cpp @@ -404,8 +404,8 @@ extern "C" { Z3_apply_result_ref * ref = alloc(Z3_apply_result_ref, mk_c(c)->m()); mk_c(c)->save_object(ref); - unsigned timeout = p.get_uint(":timeout", UINT_MAX); - bool use_ctrl_c = p.get_bool(":ctrl-c", false); + unsigned timeout = p.get_uint("timeout", UINT_MAX); + bool use_ctrl_c = p.get_bool("ctrl_c", false); cancel_eh eh(*to_tactic_ref(t)); to_tactic_ref(t)->updt_params(p); diff --git a/src/ast/normal_forms/nnf.cpp b/src/ast/normal_forms/nnf.cpp index 4d8849178..d525fa167 100644 --- a/src/ast/normal_forms/nnf.cpp +++ b/src/ast/normal_forms/nnf.cpp @@ -122,11 +122,11 @@ public: } void updt_params(params_ref const & p) { - m_sk_hack_enabled = p.get_bool(":nnf-sk-hack", false); + m_sk_hack_enabled = p.get_bool("sk_hack", false); } static void get_param_descrs(param_descrs & r) { - r.insert(":nnf-sk-hack", CPK_BOOL, "(default: false) hack for VCC"); + r.insert("sk_hack", CPK_BOOL, "(default: false) hack for VCC"); } ast_manager & m() const { return m_manager; } @@ -264,7 +264,7 @@ struct nnf::imp { } void updt_local_params(params_ref const & p) { - symbol mode_sym = p.get_sym(":nnf-mode", m_skolem); + symbol mode_sym = p.get_sym("mode", m_skolem); if (mode_sym == m_skolem) m_mode = NNF_SKOLEM; else if (mode_sym == "full") @@ -276,18 +276,18 @@ struct nnf::imp { TRACE("nnf", tout << "nnf-mode: " << m_mode << " " << mode_sym << "\n" << p << "\n";); - m_ignore_labels = p.get_bool(":nnf-ignore-labels", false); - m_skolemize = p.get_bool(":skolemize", true); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_ignore_labels = p.get_bool("ignore_labels", false); + m_skolemize = p.get_bool("skolemize", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } static void get_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":nnf-mode", CPK_SYMBOL, + r.insert("mode", CPK_SYMBOL, "(default: skolem) NNF translation mode: skolem (skolem normal form), quantifiers (skolem normal form + quantifiers in NNF), full"); - r.insert(":nnf-ignore-labels", CPK_BOOL, + r.insert("ignore_labels", CPK_BOOL, "(default: false) remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); - r.insert(":skolemize", CPK_BOOL, + r.insert("skolemize", CPK_BOOL, "(default: true) skolemize (existential force) quantifiers"); skolemizer::get_param_descrs(r); } @@ -884,15 +884,15 @@ nnf::nnf(ast_manager & m, defined_names & n, params_ref const & p) { nnf::nnf(ast_manager & m, defined_names & n, nnf_params & np) { params_ref p; if (np.m_nnf_mode == NNF_FULL) - p.set_sym(":nnf-mode", symbol("full")); + p.set_sym("mode", symbol("full")); else if (np.m_nnf_mode == NNF_QUANT) - p.set_sym(":nnf-mode", symbol("quantifiers")); + p.set_sym("mode", symbol("quantifiers")); if (np.m_nnf_ignore_labels) - p.set_bool(":nnf-ignore-labels", true); + p.set_bool("ignore_labels", true); if (np.m_nnf_sk_hack) - p.set_bool(":nnf-sk-hack", true); + p.set_bool("sk_hack", true); m_imp = alloc(imp, m, n, p); } diff --git a/src/ast/normal_forms/nnf.h b/src/ast/normal_forms/nnf.h index 685083ff7..96807afc0 100644 --- a/src/ast/normal_forms/nnf.h +++ b/src/ast/normal_forms/nnf.h @@ -41,6 +41,9 @@ public: ); void updt_params(params_ref const & p); + /* + REG_MODULE_PARAMS('nnf', 'nnf::get_param_descrs') + */ static void get_param_descrs(param_descrs & r); void cancel() { set_cancel(true); } diff --git a/src/ast/pp.cpp b/src/ast/pp.cpp index 43f19e166..d05776e78 100644 --- a/src/ast/pp.cpp +++ b/src/ast/pp.cpp @@ -19,6 +19,24 @@ Revision History: #include"pp.h" using namespace format_ns; +void pp_param_descrs(param_descrs & p) { + p.insert("max_indent", CPK_UINT, "max. indentation in pretty printer"); + p.insert("max_num_lines", CPK_UINT, "max. number of lines to be displayed in pretty printer"); + p.insert("max_width", CPK_UINT, "max. width in pretty printer"); + p.insert("max_ribbon", CPK_UINT, "max. ribbon (width - indentation) in pretty printer"); + p.insert("max_depth", CPK_UINT, "max. term depth (when pretty printing SMT2 terms/formulas)"); + p.insert("min_alias_size", CPK_UINT, "min. size for creating an alias for a shared term (when pretty printing SMT2 terms/formulas)"); + p.insert("decimal", CPK_BOOL, "pretty print real numbers using decimal notation (the output may be truncated). Z3 adds a '?' if the value is not precise"); + p.insert("decimal_precision", CPK_BOOL, "maximum number of decimal places to be used when pp.decimal=true"); + p.insert("bv_literals", CPK_BOOL, "use Bit-Vector literals (e.g, #x0F and #b0101) during pretty printing"); + p.insert("bv_neg", CPK_BOOL, "use bvneg when displaying Bit-Vector literals where the most significant bit is 1"); + p.insert("flat_assoc", CPK_BOOL, "flat associative operators (when pretty printing SMT2 terms/formulas)"); + p.insert("fixed_indent", CPK_BOOL, "use a fixed indentation for applications"); + p.insert("single_line", CPK_BOOL, "ignore line breaks when true"); + p.insert("bounded", CPK_BOOL, "ignore characters exceeding max widht"); + p.insert("simplify_implies", CPK_BOOL, "simplify nested implications for pretty printing"); +} + pp_params g_pp_params; void set_pp_default_params(pp_params const & p) { diff --git a/src/ast/pp.h b/src/ast/pp.h index 43c1de7b7..13afcb07c 100644 --- a/src/ast/pp.h +++ b/src/ast/pp.h @@ -21,6 +21,12 @@ Revision History: #include"format.h" #include"pp_params.h" +#include"params.h" + +/* + REG_MODULE_PARAMS('pp', 'pp_param_descrs') +*/ +void pp_param_descrs(param_descrs & d); void set_pp_default_params(pp_params const & p); void register_pp_params(ini_params & p); diff --git a/src/ast/rewriter/arith_rewriter.cpp b/src/ast/rewriter/arith_rewriter.cpp index 3efc14abe..f5fdcf8af 100644 --- a/src/ast/rewriter/arith_rewriter.cpp +++ b/src/ast/rewriter/arith_rewriter.cpp @@ -22,18 +22,18 @@ Notes: #include"ast_pp.h" void arith_rewriter::updt_local_params(params_ref const & p) { - m_arith_lhs = p.get_bool(":arith-lhs", false); - m_gcd_rounding = p.get_bool(":gcd-rounding", false); - m_eq2ineq = p.get_bool(":eq2ineq", false); - m_elim_to_real = p.get_bool(":elim-to-real", false); - m_push_to_real = p.get_bool(":push-to-real", true); - m_anum_simp = p.get_bool(":algebraic-number-evaluator", true); - m_max_degree = p.get_uint(":max-degree", 64); - m_expand_power = p.get_bool(":expand-power", false); - m_mul2power = p.get_bool(":mul-to-power", false); - m_elim_rem = p.get_bool(":elim-rem", false); - m_expand_tan = p.get_bool(":expand-tan", false); - set_sort_sums(p.get_bool(":sort-sums", false)); // set here to avoid collision with bvadd + m_arith_lhs = p.get_bool("arith_lhs", false); + m_gcd_rounding = p.get_bool("gcd_rounding", false); + m_eq2ineq = p.get_bool("eq2ineq", false); + m_elim_to_real = p.get_bool("elim_to_real", false); + m_push_to_real = p.get_bool("push_to_real", true); + m_anum_simp = p.get_bool("algebraic_number_evaluator", true); + m_max_degree = p.get_uint("max_degree", 64); + m_expand_power = p.get_bool("expand_power", false); + m_mul2power = p.get_bool("mul_to_power", false); + m_elim_rem = p.get_bool("elim_rem", false); + m_expand_tan = p.get_bool("expand_tan", false); + set_sort_sums(p.get_bool("sort_sums", false)); // set here to avoid collision with bvadd } void arith_rewriter::updt_params(params_ref const & p) { @@ -43,18 +43,18 @@ void arith_rewriter::updt_params(params_ref const & p) { void arith_rewriter::get_param_descrs(param_descrs & r) { poly_rewriter::get_param_descrs(r); - r.insert(":algebraic-number-evaluator", CPK_BOOL, "(default: true) simplify/evaluate expressions containing (algebraic) irrational numbers."); - r.insert(":mul-to-power", CPK_BOOL, "(default: false) collpase (* t ... t) into (^ t k), it is ignored if :expand-power is true."); - r.insert(":expand-power", CPK_BOOL, "(default: false) expand (^ t k) into (* t ... t) if 1 < k <= :max-degree."); - r.insert(":expand-tan", CPK_BOOL, "(default: false) replace (tan x) with (/ (sin x) (cos x))."); - r.insert(":max-degree", CPK_UINT, "(default: 64) max degree of algebraic numbers (and power operators) processed by simplifier."); - r.insert(":eq2ineq", CPK_BOOL, "(default: false) split arithmetic equalities into two inequalities."); - r.insert(":sort-sums", CPK_BOOL, "(default: false) sort the arguments of + application."); - r.insert(":gcd-rounding", CPK_BOOL, "(default: false) use gcd rounding on integer arithmetic atoms."); - r.insert(":arith-lhs", CPK_BOOL, "(default: false) all monomials are moved to the left-hand-side, and the right-hand-side is just a constant."); - r.insert(":elim-to-real", CPK_BOOL, "(default: false) eliminate to_real from arithmetic predicates that contain only integers."); - r.insert(":push-to-real", CPK_BOOL, "(default: true) distribute to_real over * and +."); - r.insert(":elim-rem", CPK_BOOL, "(default: false) replace (rem x y) with (ite (>= y 0) (mod x y) (- (mod x y)))."); + r.insert("algebraic_number_evaluator", CPK_BOOL, "(default: true) simplify/evaluate expressions containing (algebraic) irrational numbers."); + r.insert("mul_to_power", CPK_BOOL, "(default: false) collpase (* t ... t) into (^ t k), it is ignored if expand_power is true."); + r.insert("expand_power", CPK_BOOL, "(default: false) expand (^ t k) into (* t ... t) if 1 < k <= max_degree."); + r.insert("expand_tan", CPK_BOOL, "(default: false) replace (tan x) with (/ (sin x) (cos x))."); + r.insert("max_degree", CPK_UINT, "(default: 64) max degree of algebraic numbers (and power operators) processed by simplifier."); + r.insert("eq2ineq", CPK_BOOL, "(default: false) split arithmetic equalities into two inequalities."); + r.insert("sort_sums", CPK_BOOL, "(default: false) sort the arguments of + application."); + r.insert("gcd_rounding", CPK_BOOL, "(default: false) use gcd rounding on integer arithmetic atoms."); + r.insert("arith_lhs", CPK_BOOL, "(default: false) all monomials are moved to the left-hand-side, and the right-hand-side is just a constant."); + r.insert("elim_to_real", CPK_BOOL, "(default: false) eliminate to_real from arithmetic predicates that contain only integers."); + r.insert("push_to_real", CPK_BOOL, "(default: true) distribute to_real over * and +."); + r.insert("elim_rem", CPK_BOOL, "(default: false) replace (rem x y) with (ite (>= y 0) (mod x y) (- (mod x y)))."); } br_status arith_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/array_rewriter.cpp b/src/ast/rewriter/array_rewriter.cpp index 268f4dca0..ac93e0f87 100644 --- a/src/ast/rewriter/array_rewriter.cpp +++ b/src/ast/rewriter/array_rewriter.cpp @@ -21,13 +21,13 @@ Notes: #include"ast_pp.h" void array_rewriter::updt_params(params_ref const & p) { - m_sort_store = p.get_bool(":sort-store", false); - m_expand_select_store = p.get_bool(":expand-select-store", false); + m_sort_store = p.get_bool("sort_store", false); + m_expand_select_store = p.get_bool("expand_select_store", false); } void array_rewriter::get_param_descrs(param_descrs & r) { - r.insert(":expand-select-store", CPK_BOOL, "(default: false) replace a (select (store ...) ...) term by an if-then-else term."); - r.insert(":sort-store", CPK_BOOL, "(default: false) sort nested stores when the indices are known to be different."); + r.insert("expand_select_store", CPK_BOOL, "(default: false) replace a (select (store ...) ...) term by an if-then-else term."); + r.insert("sort_store", CPK_BOOL, "(default: false) sort nested stores when the indices are known to be different."); } br_status array_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp b/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp index c64ea56d0..1fd83e91f 100644 --- a/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp +++ b/src/ast/rewriter/bit_blaster/bit_blaster_rewriter.cpp @@ -125,12 +125,12 @@ struct blaster_rewriter_cfg : public default_rewriter_cfg { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_blast_add = p.get_bool(":blast-add", true); - m_blast_mul = p.get_bool(":blast-mul", true); - m_blast_full = p.get_bool(":blast-full", false); - m_blast_quant = p.get_bool(":blast-quant", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_blast_add = p.get_bool("blast_add", true); + m_blast_mul = p.get_bool("blast_mul", true); + m_blast_full = p.get_bool("blast_full", false); + m_blast_quant = p.get_bool("blast_quant", false); m_blaster.set_max_memory(m_max_memory); } diff --git a/src/ast/rewriter/bool_rewriter.cpp b/src/ast/rewriter/bool_rewriter.cpp index b7fe296c4..b3f422fe5 100644 --- a/src/ast/rewriter/bool_rewriter.cpp +++ b/src/ast/rewriter/bool_rewriter.cpp @@ -20,21 +20,22 @@ Notes: #include"rewriter_def.h" void bool_rewriter::updt_params(params_ref const & p) { - m_flat = p.get_bool(":flat", true); - m_elim_and = p.get_bool(":elim-and", false); - m_local_ctx = p.get_bool(":local-ctx", false); - m_local_ctx_limit = p.get_uint(":local-ctx-limit", UINT_MAX); - m_blast_distinct = p.get_bool(":blast-distinct", false); - m_ite_extra_rules = p.get_bool(":ite-extra-rules", false); + m_flat = p.get_bool("flat", true); + m_elim_and = p.get_bool("elim_and", false); + m_local_ctx = p.get_bool("local_ctx", false); + m_local_ctx_limit = p.get_uint("local_ctx_limit", UINT_MAX); + m_blast_distinct = p.get_bool("blast_distinct", false); + m_ite_extra_rules = p.get_bool("ite_extra_rules", false); } void bool_rewriter::get_param_descrs(param_descrs & r) { - r.insert(":ite-extra-rules", CPK_BOOL, "(default: false) extra ite simplifications, these additional simplifications may reduce size locally but increase globally."); - r.insert(":flat", CPK_BOOL, "(default: true) create nary applications for and,or,+,*,bvadd,bvmul,bvand,bvor,bvxor."); - r.insert(":elim-and", CPK_BOOL, "(default: false) conjunctions are rewritten using negation and disjunctions."); - r.insert(":local-ctx", CPK_BOOL, "(default: false) perform local (i.e., cheap) context simplifications."); - r.insert(":local-ctx-limit", CPK_UINT, "(default: inf) limit for applying local context simplifier."); - r.insert(":blast-distinct", CPK_BOOL, "(default: false) expand a distinct predicate into a quadratic number of disequalities."); + r.insert("ite_extra_rules", CPK_BOOL, + "(default: false) extra ite simplifications, these additional simplifications may reduce size locally but increase globally."); + r.insert("flat", CPK_BOOL, "(default: true) create nary applications for and,or,+,*,bvadd,bvmul,bvand,bvor,bvxor."); + r.insert("elim_and", CPK_BOOL, "(default: false) conjunctions are rewritten using negation and disjunctions."); + r.insert("local_ctx", CPK_BOOL, "(default: false) perform local (i.e., cheap) context simplifications."); + r.insert("local_ctx_limit", CPK_UINT, "(default: inf) limit for applying local context simplifier."); + r.insert("blast_distinct", CPK_BOOL, "(default: false) expand a distinct predicate into a quadratic number of disequalities."); } br_status bool_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) { diff --git a/src/ast/rewriter/bv_rewriter.cpp b/src/ast/rewriter/bv_rewriter.cpp index adef6a5b0..fbc1f7c11 100644 --- a/src/ast/rewriter/bv_rewriter.cpp +++ b/src/ast/rewriter/bv_rewriter.cpp @@ -54,14 +54,14 @@ app * mk_extract_proc::operator()(unsigned high, unsigned low, expr * arg) { } void bv_rewriter::updt_local_params(params_ref const & p) { - m_hi_div0 = p.get_bool(":hi-div0", true); - m_elim_sign_ext = p.get_bool(":elim-sign-ext", true); - m_mul2concat = p.get_bool(":mul2concat", false); - m_bit2bool = p.get_bool(":bit2bool", true); - m_blast_eq_value = p.get_bool(":blast-eq-value", false); - m_mkbv2num = p.get_bool(":mkbv2num", false); - m_split_concat_eq = p.get_bool(":split-concat-eq", false); - m_udiv2mul = p.get_bool(":udiv2mul", false); + m_hi_div0 = p.get_bool("hi_div0", true); + m_elim_sign_ext = p.get_bool("elim_sign_ext", true); + m_mul2concat = p.get_bool("mul2concat", false); + m_bit2bool = p.get_bool("bit2bool", true); + m_blast_eq_value = p.get_bool("blast_eq_value", false); + m_mkbv2num = p.get_bool("mkbv2num", false); + m_split_concat_eq = p.get_bool("split_concat_eq", false); + m_udiv2mul = p.get_bool("udiv2mul", false); } void bv_rewriter::updt_params(params_ref const & p) { @@ -71,15 +71,15 @@ void bv_rewriter::updt_params(params_ref const & p) { void bv_rewriter::get_param_descrs(param_descrs & r) { poly_rewriter::get_param_descrs(r); - r.insert(":udiv2mul", CPK_BOOL, "(default: false) convert constant udiv to mul."); - r.insert(":split-concat-eq", CPK_BOOL, "(default: false) split equalities of the form (= (concat t1 t2) t3)."); - r.insert(":bit2bool", CPK_BOOL, "(default: true) try to convert bit-vector terms of size 1 into Boolean terms."); - r.insert(":blast-eq-value", CPK_BOOL, "(default: false) blast (some) Bit-vector equalities into bits."); - r.insert(":elim-sign-ext", CPK_BOOL, "(default: true) expand sign-ext operator using concat and extract."); - r.insert(":hi-div0", CPK_BOOL, "(default: true) use the 'hardware interpretation' for division by zero (for bit-vector terms)."); - r.insert(":mul2concat", CPK_BOOL, "(default: false) replace multiplication by a power of two into a concatenation."); + r.insert("udiv2mul", CPK_BOOL, "(default: false) convert constant udiv to mul."); + r.insert("split_concat_eq", CPK_BOOL, "(default: false) split equalities of the form (= (concat t1 t2) t3)."); + r.insert("bit2bool", CPK_BOOL, "(default: true) try to convert bit-vector terms of size 1 into Boolean terms."); + r.insert("blast_eq_value", CPK_BOOL, "(default: false) blast (some) Bit-vector equalities into bits."); + r.insert("elim_sign_ext", CPK_BOOL, "(default: true) expand sign-ext operator using concat and extract."); + r.insert("hi_div0", CPK_BOOL, "(default: true) use the 'hardware interpretation' for division by zero (for bit-vector terms)."); + r.insert("mul2concat", CPK_BOOL, "(default: false) replace multiplication by a power of two into a concatenation."); #ifndef _EXTERNAL_RELEASE - r.insert(":mkbv2num", CPK_BOOL, "(default: false) convert (mkbv [true/false]*) into a numeral"); + r.insert("mkbv2num", CPK_BOOL, "(default: false) convert (mkbv [true/false]*) into a numeral"); #endif } diff --git a/src/ast/rewriter/poly_rewriter_def.h b/src/ast/rewriter/poly_rewriter_def.h index e942b453a..e6c8a653c 100644 --- a/src/ast/rewriter/poly_rewriter_def.h +++ b/src/ast/rewriter/poly_rewriter_def.h @@ -27,19 +27,19 @@ char const * poly_rewriter::g_ste_blowup_msg = "sum of monomials blowup" template void poly_rewriter::updt_params(params_ref const & p) { - m_flat = p.get_bool(":flat", true); - m_som = p.get_bool(":som", false); - m_hoist_mul = p.get_bool(":hoist-mul", false); - m_hoist_cmul = p.get_bool(":hoist-cmul", false); - m_som_blowup = p.get_uint(":som-blowup", UINT_MAX); + m_flat = p.get_bool("flat", true); + m_som = p.get_bool("som", false); + m_hoist_mul = p.get_bool("hoist_mul", false); + m_hoist_cmul = p.get_bool("hoist_cmul", false); + m_som_blowup = p.get_uint("som_blowup", UINT_MAX); } template void poly_rewriter::get_param_descrs(param_descrs & r) { - r.insert(":som", CPK_BOOL, "(default: false) put polynomials in som-of-monomials form."); - r.insert(":som-blowup", CPK_UINT, "(default: infty) maximum number of monomials generated when putting a polynomial in sum-of-monomials normal form"); - r.insert(":hoist-mul", CPK_BOOL, "(default: false) hoist multiplication over summation to minimize number of multiplications"); - r.insert(":hoist-cmul", CPK_BOOL, "(default: false) hoist constant multiplication over summation to minimize number of multiplications"); + r.insert("som", CPK_BOOL, "(default: false) put polynomials in som-of-monomials form."); + r.insert("som_blowup", CPK_UINT, "(default: infty) maximum number of monomials generated when putting a polynomial in sum-of-monomials normal form"); + r.insert("hoist_mul", CPK_BOOL, "(default: false) hoist multiplication over summation to minimize number of multiplications"); + r.insert("hoist_cmul", CPK_BOOL, "(default: false) hoist constant multiplication over summation to minimize number of multiplications"); } template diff --git a/src/ast/rewriter/th_rewriter.cpp b/src/ast/rewriter/th_rewriter.cpp index ee55d53e7..da4dd3860 100644 --- a/src/ast/rewriter/th_rewriter.cpp +++ b/src/ast/rewriter/th_rewriter.cpp @@ -57,13 +57,13 @@ struct th_rewriter_cfg : public default_rewriter_cfg { ast_manager & m() const { return m_b_rw.m(); } void updt_local_params(params_ref const & p) { - m_flat = p.get_bool(":flat", true); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_pull_cheap_ite = p.get_bool(":pull-cheap-ite", false); - m_cache_all = p.get_bool(":cache-all", false); - m_push_ite_arith = p.get_bool(":push-ite-arith", false); - m_push_ite_bv = p.get_bool(":push-ite-bv", false); + m_flat = p.get_bool("flat", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_pull_cheap_ite = p.get_bool("pull_cheap_ite", false); + m_cache_all = p.get_bool("cache_all", false); + m_push_ite_arith = p.get_bool("push_ite_arith", false); + m_push_ite_bv = p.get_bool("push_ite_bv", false); } void updt_params(params_ref const & p) { @@ -695,10 +695,10 @@ void th_rewriter::get_param_descrs(param_descrs & r) { array_rewriter::get_param_descrs(r); insert_max_memory(r); insert_max_steps(r); - r.insert(":push-ite-arith", CPK_BOOL, "(default: false) push if-then-else over arithmetic terms."); - r.insert(":push-ite-bv", CPK_BOOL, "(default: false) push if-then-else over bit-vector terms."); - r.insert(":pull-cheap-ite", CPK_BOOL, "(default: false) pull if-then-else terms when cheap."); - r.insert(":cache-all", CPK_BOOL, "(default: false) cache all intermediate results."); + r.insert("push_ite_arith", CPK_BOOL, "(default: false) push if-then-else over arithmetic terms."); + r.insert("push_ite_bv", CPK_BOOL, "(default: false) push if-then-else over bit-vector terms."); + r.insert("pull_cheap_ite", CPK_BOOL, "(default: false) pull if-then-else terms when cheap."); + r.insert("cache_all", CPK_BOOL, "(default: false) cache all intermediate results."); } th_rewriter::~th_rewriter() { diff --git a/src/ast/rewriter/th_rewriter.h b/src/ast/rewriter/th_rewriter.h index 1b77c42c7..19a89d286 100644 --- a/src/ast/rewriter/th_rewriter.h +++ b/src/ast/rewriter/th_rewriter.h @@ -37,7 +37,9 @@ public: void updt_params(params_ref const & p); static void get_param_descrs(param_descrs & r); - + /* + REG_MODULE_PARAMS('simplify', 'th_rewriter::get_param_descrs') + */ unsigned get_cache_size() const; unsigned get_num_steps() const; diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index 4c24b5ae6..1960cd22a 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -28,6 +28,7 @@ Notes: #include"simplify_cmd.h" #include"eval_cmd.h" #include"front_end_params.h" +#include"gparams.h" class help_cmd : public cmd { svector m_cmds; @@ -219,25 +220,6 @@ UNARY_CMD(pp_cmd, "display", "", "display the given term.", CPK_EXPR, expr UNARY_CMD(echo_cmd, "echo", "", "display the given string", CPK_STRING, char const *, ctx.regular_stream() << arg << std::endl;); -/** - \brief Convert a keyword into an internal Z3 option name -*/ -std::string smt_keyword2opt_name(symbol const & opt) { - std::string r; - SASSERT(opt.bare_str()[0] == ':'); - r = opt.bare_str() + 1; - unsigned sz = static_cast(r.size()); - for (unsigned i = 0; i < sz; i++) { - char curr = r[i]; - if ('a' <= curr && curr <= 'z') - r[i] = 'A' + (curr - 'a'); - else if (curr == '-') - r[i] = '_'; - } - TRACE("smt2_opt_name", tout << opt << " -> '" << r << "'\n";); - return r; -} - class set_get_option_cmd : public cmd { protected: symbol m_true; @@ -259,7 +241,6 @@ protected: symbol m_numeral_as_real; symbol m_error_behavior; symbol m_int_real_coercions; - ini_params m_ini; bool is_builtin_option(symbol const & s) const { return @@ -289,10 +270,7 @@ public: m_global_decls(":global-decls"), m_numeral_as_real(":numeral-as-real"), m_error_behavior(":error-behavior"), - m_int_real_coercions(":int-real-coercions"), - m_ini(false) { - params.register_params(m_ini); - register_pp_params(m_ini); + m_int_real_coercions(":int-real-coercions") { } virtual ~set_get_option_cmd() {} @@ -324,22 +302,11 @@ class set_option_cmd : public set_get_option_cmd { } void set_param(cmd_context & ctx, char const * value) { - m_ini.freeze(ctx.has_manager()); - std::string internal_opt = smt_keyword2opt_name(m_option); try { - std::string old_value; - if (!m_ini.get_param_value(internal_opt.c_str(), old_value)) { - m_unsupported = true; - return; - } - m_ini.set_param_value(internal_opt.c_str(), value); + gparams::set(m_option, value); } - catch (set_get_param_exception ex) { - std::string msg = "error setting '"; - msg += m_option.str(); - msg += "', "; - msg += ex.get_msg(); - throw cmd_exception(msg); + catch (gparams::exception ex) { + throw cmd_exception(ex.msg()); } } @@ -545,12 +512,10 @@ public: print_bool(ctx, ctx.m().int_real_coercions()); } else { - std::string iopt = smt_keyword2opt_name(opt); - std::string r; - if (m_ini.get_param_value(iopt.c_str(), r)) { - ctx.regular_stream() << r << std::endl; + try { + std::string val = gparams::get_value(opt); } - else { + catch (gparams::exception ex) { ctx.print_unsupported(opt); } } diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index afcac48ac..d14ce3076 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -39,6 +39,22 @@ Notes: #include"model_evaluator.h" #include"for_each_expr.h" +std::string smt2_keyword_to_param(symbol const & opt) { + std::string r; + SASSERT(opt.bare_str()[0] == ':'); + r = opt.bare_str() + 1; + unsigned sz = static_cast(r.size()); + for (unsigned i = 0; i < sz; i++) { + char curr = r[i]; + if ('A' <= curr && curr <= 'Z') + r[i] = curr - 'A' + 'a'; + else if (curr == '-') + r[i] = '_'; + } + TRACE("smt2_keyword_to_param", tout << opt << " -> '" << r << "'\n";); + return r; +} + func_decls::func_decls(ast_manager & m, func_decl * f): m_decls(TAG(func_decl*, f, 0)) { m.inc_ref(f); @@ -1400,9 +1416,9 @@ void cmd_context::validate_model() { get_check_sat_result()->get_model(md); SASSERT(md.get() != 0); params_ref p; - p.set_uint(":max-degree", UINT_MAX); // evaluate algebraic numbers of any degree. - p.set_uint(":sort-store", true); - p.set_bool(":model-completion", true); + p.set_uint("max_degree", UINT_MAX); // evaluate algebraic numbers of any degree. + p.set_uint("sort_store", true); + p.set_bool("model_completion", true); model_evaluator evaluator(*(md.get()), p); contains_array_op_proc contains_array(m()); { diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 5f83e0224..6688f66d9 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -37,6 +37,11 @@ Notes: #include"progress_callback.h" #include"scoped_ptr_vector.h" +/** + \brief Auxiliary function for converting SMT2 keywords into Z3 internal parameter names. +*/ +std::string smt2_keyword_to_param(symbol const & k); + struct front_end_params; class func_decls { diff --git a/src/cmd_context/eval_cmd.cpp b/src/cmd_context/eval_cmd.cpp index fe9c738a2..7ebe2f54f 100644 --- a/src/cmd_context/eval_cmd.cpp +++ b/src/cmd_context/eval_cmd.cpp @@ -62,7 +62,7 @@ public: SASSERT(last_result); last_result->get_model(md); expr_ref r(ctx.m()); - unsigned timeout = m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = m_params.get_uint("timeout", UINT_MAX); model_evaluator ev(*(md.get()), m_params); cancel_eh eh(ev); { diff --git a/src/cmd_context/extra_cmds/dbg_cmds.cpp b/src/cmd_context/extra_cmds/dbg_cmds.cpp index b7b4f058d..509b5ff2e 100644 --- a/src/cmd_context/extra_cmds/dbg_cmds.cpp +++ b/src/cmd_context/extra_cmds/dbg_cmds.cpp @@ -141,8 +141,8 @@ public: UNARY_CMD(bool_rewriter_cmd, "dbg-bool-rewriter", "", "apply the Boolean rewriter to the given term", CPK_EXPR, expr *, { expr_ref t(ctx.m()); params_ref p; - p.set_bool(":flat", false); - SASSERT(p.get_bool(":flat", true) == false); + p.set_bool("flat", false); + SASSERT(p.get_bool("flat", true) == false); bool_rewriter_star r(ctx.m(), p); r(arg, t); ctx.display(ctx.regular_stream(), t); @@ -153,7 +153,7 @@ UNARY_CMD(bool_frewriter_cmd, "dbg-bool-flat-rewriter", "", "apply the Boo expr_ref t(ctx.m()); { params_ref p; - p.set_bool(":flat", true); + p.set_bool("flat", true); bool_rewriter_star r(ctx.m(), p); r(arg, t); } @@ -165,8 +165,8 @@ UNARY_CMD(elim_and_cmd, "dbg-elim-and", "", "apply the Boolean rewriter (e expr_ref t(ctx.m()); { params_ref p; - p.set_bool(":flat", true); - p.set_bool(":elim-and", true); + p.set_bool("flat", true); + p.set_bool("elim_and", true); bool_rewriter_star r(ctx.m(), p); r(arg, t); } @@ -208,15 +208,15 @@ UNARY_CMD(some_value_cmd, "dbg-some-value", "", "retrieve some value of th void tst_params(cmd_context & ctx) { params_ref p1; params_ref p2; - p1.set_uint(":val", 100); + p1.set_uint("val", 100); p2 = p1; - SASSERT(p2.get_uint(":val", 0) == 100); - p2.set_uint(":val", 200); - SASSERT(p2.get_uint(":val", 0) == 200); - SASSERT(p1.get_uint(":val", 0) == 100); + SASSERT(p2.get_uint("val", 0) == 100); + p2.set_uint("val", 200); + SASSERT(p2.get_uint("val", 0) == 200); + SASSERT(p1.get_uint("val", 0) == 100); p2 = p1; - SASSERT(p2.get_uint(":val", 0) == 100); - SASSERT(p1.get_uint(":val", 0) == 100); + SASSERT(p2.get_uint("val", 0) == 100); + SASSERT(p1.get_uint("val", 0) == 100); ctx.regular_stream() << "worked" << std::endl; } diff --git a/src/cmd_context/extra_cmds/subpaving_cmds.cpp b/src/cmd_context/extra_cmds/subpaving_cmds.cpp index 9b84ddf68..632f558dc 100644 --- a/src/cmd_context/extra_cmds/subpaving_cmds.cpp +++ b/src/cmd_context/extra_cmds/subpaving_cmds.cpp @@ -31,7 +31,7 @@ static void to_subpaving(cmd_context & ctx, expr * t) { expr2var e2v(m); expr2subpaving e2s(m, *s, &e2v); params_ref p; - p.set_bool(":mul-to-power", true); + p.set_bool("mul_to_power", true); th_rewriter simp(m, p); expr_ref t_s(m); simp(t, t_s); diff --git a/src/cmd_context/parametric_cmd.cpp b/src/cmd_context/parametric_cmd.cpp index bc06d3ee6..f028c3b9d 100644 --- a/src/cmd_context/parametric_cmd.cpp +++ b/src/cmd_context/parametric_cmd.cpp @@ -16,6 +16,7 @@ Notes: --*/ #include +#include"cmd_context.h" #include"parametric_cmd.h" char const * parametric_cmd::get_descr(cmd_context & ctx) const { @@ -37,13 +38,15 @@ cmd_arg_kind parametric_cmd::next_arg_kind(cmd_context & ctx) const { void parametric_cmd::set_next_arg(cmd_context & ctx, symbol const & s) { if (m_last == symbol::null) { - m_last = s; + m_last = symbol(smt2_keyword_to_param(s).c_str()); if (pdescrs(ctx).get_kind(m_last.bare_str()) == CPK_INVALID) throw cmd_exception("invalid keyword argument"); return; } - m_params.set_sym(m_last.bare_str(), s); - m_last = symbol::null; + else { + m_params.set_sym(m_last.bare_str(), s); + m_last = symbol::null; + } } param_descrs const & parametric_cmd::pdescrs(cmd_context & ctx) const { diff --git a/src/cmd_context/simplify_cmd.cpp b/src/cmd_context/simplify_cmd.cpp index 089eb353b..3a1828a51 100644 --- a/src/cmd_context/simplify_cmd.cpp +++ b/src/cmd_context/simplify_cmd.cpp @@ -40,9 +40,9 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { th_rewriter::get_param_descrs(p); insert_timeout(p); - p.insert(":print", CPK_BOOL, "(default: true) print the simplified term."); - p.insert(":print-proofs", CPK_BOOL, "(default: false) print a proof showing the original term is equal to the resultant one."); - p.insert(":print-statistics", CPK_BOOL, "(default: false) print statistics."); + p.insert("print", CPK_BOOL, "(default: true) print the simplified term."); + p.insert("print_proofs", CPK_BOOL, "(default: false) print a proof showing the original term is equal to the resultant one."); + p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } virtual ~simplify_cmd() { @@ -67,12 +67,12 @@ public: throw cmd_exception("invalid simplify command, argument expected"); expr_ref r(ctx.m()); proof_ref pr(ctx.m()); - if (m_params.get_bool(":som", false)) - m_params.set_bool(":flat", true); + if (m_params.get_bool("som", false)) + m_params.set_bool("flat", true); th_rewriter s(ctx.m(), m_params); unsigned cache_sz; unsigned num_steps = 0; - unsigned timeout = m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = m_params.get_uint("timeout", UINT_MAX); bool failed = false; cancel_eh eh(s); { @@ -94,17 +94,17 @@ public: num_steps = s.get_num_steps(); s.cleanup(); } - if (m_params.get_bool(":print", true)) { + if (m_params.get_bool("print", true)) { ctx.display(ctx.regular_stream(), r); ctx.regular_stream() << std::endl; } - if (!failed && m_params.get_bool(":print-proofs", false)) { + if (!failed && m_params.get_bool("print_proofs", false)) { ast_smt_pp pp(ctx.m()); pp.set_logic(ctx.get_logic().str().c_str()); pp.display_expr_smt2(ctx.regular_stream(), pr.get()); ctx.regular_stream() << std::endl; } - if (m_params.get_bool(":print-statistics", false)) { + if (m_params.get_bool("print_statistics", false)) { shared_occs s1(ctx.m()); if (!failed) s1(r); diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index 32adb5f47..b911e3634 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -153,7 +153,7 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { insert_timeout(p); insert_max_memory(p); - p.insert(":print-statistics", CPK_BOOL, "(default: false) print statistics."); + p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } void display_statistics(cmd_context & ctx, tactic * t) { @@ -180,9 +180,9 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { 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."); + 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) { @@ -192,7 +192,7 @@ public: tref->set_front_end_params(ctx.params()); tref->set_logic(ctx.get_logic()); ast_manager & m = ctx.m(); - unsigned timeout = p.get_uint(":timeout", UINT_MAX); + unsigned timeout = p.get_uint("timeout", UINT_MAX); goal_ref g = alloc(goal, m, ctx.produce_proofs(), ctx.produce_models(), ctx.produce_unsat_cores()); assert_exprs_from(ctx, *g); TRACE("check_sat_using", g->display(tout);); @@ -241,7 +241,7 @@ public: ptr_vector core_elems; m.linearize(core, core_elems); result->m_core.append(core_elems.size(), core_elems.c_ptr()); - if (p.get_bool(":print-unsat-core", false)) { + if (p.get_bool("print_unsat_core", false)) { ctx.regular_stream() << "(unsat-core"; ptr_vector::const_iterator it = core_elems.begin(); ptr_vector::const_iterator end = core_elems.end(); @@ -255,7 +255,7 @@ public: if (ctx.produce_models() && md) { result->m_model = md; - if (p.get_bool(":print-model", false)) { + if (p.get_bool("print_model", false)) { ctx.regular_stream() << "(model " << std::endl; model_smt2_pp(ctx.regular_stream(), ctx, *md, 2); ctx.regular_stream() << ")" << std::endl; @@ -266,12 +266,12 @@ public: if (ctx.produce_proofs() && pr) { result->m_proof = pr; - if (p.get_bool(":print-proof", false)) { + if (p.get_bool("print_proof", false)) { ctx.regular_stream() << mk_ismt2_pp(pr, m) << "\n"; } } - if (p.get_bool(":print-statistics", false)) + if (p.get_bool("print_statistics", false)) display_statistics(ctx, tref.get()); } }; @@ -285,14 +285,14 @@ public: virtual char const * get_main_descr() const { 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) { - p.insert(":print", CPK_BOOL, "(default: true) print resultant goals."); + 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."); + p.insert("print_proof", CPK_BOOL, "(default: false) print proof associated with each assertion."); #endif - p.insert(":print-model-converter", CPK_BOOL, "(default: false) print model converter."); - p.insert(":print-benchmark", CPK_BOOL, "(default: false) display resultant goals as a SMT2 benchmark."); + p.insert("print_model_converter", CPK_BOOL, "(default: false) print model converter."); + p.insert("print_benchmark", CPK_BOOL, "(default: false) display resultant goals as a SMT2 benchmark."); #ifndef _EXTERNAL_RELEASE - p.insert(":print-dependencies", CPK_BOOL, "(default: false) print dependencies when displaying the resultant set of goals."); + p.insert("print_dependencies", CPK_BOOL, "(default: false) print dependencies when displaying the resultant set of goals."); #endif exec_given_tactic_cmd::init_pdescrs(ctx, p); } @@ -307,7 +307,7 @@ public: goal_ref g = alloc(goal, m, ctx.produce_proofs(), ctx.produce_models(), ctx.produce_unsat_cores()); assert_exprs_from(ctx, *g); - unsigned timeout = p.get_uint(":timeout", UINT_MAX); + unsigned timeout = p.get_uint("timeout", UINT_MAX); goal_ref_buffer result_goals; model_converter_ref mc; @@ -330,8 +330,8 @@ public: } } - if (!failed && p.get_bool(":print", true)) { - bool print_dependencies = p.get_bool(":print-dependencies", false); + if (!failed && p.get_bool("print", true)) { + bool print_dependencies = p.get_bool("print_dependencies", false); ctx.regular_stream() << "(goals\n"; unsigned sz = result_goals.size(); for (unsigned i = 0; i < sz; i++) { @@ -344,12 +344,12 @@ public: } #ifndef _EXTERNAL_RELEASE - if (!failed && ctx.produce_proofs() && p.get_bool(":print-proof", false)) { + if (!failed && ctx.produce_proofs() && p.get_bool("print_proof", false)) { // TODO } #endif - if (!failed && p.get_bool(":print-benchmark", false)) { + if (!failed && p.get_bool("print_benchmark", false)) { unsigned num_goals = result_goals.size(); SASSERT(num_goals > 0); if (num_goals == 1) { @@ -381,10 +381,10 @@ public: } } - if (!failed && mc && p.get_bool(":print-model-converter", false)) + if (!failed && mc && p.get_bool("print_model_converter", false)) mc->display(ctx.regular_stream()); - if (p.get_bool(":print-statistics", false)) + if (p.get_bool("print_statistics", false)) display_statistics(ctx, tref.get()); } } diff --git a/src/front_end_params/arith_simplifier_params.cpp b/src/front_end_params/arith_simplifier_params.cpp index 0c2f5c710..21808bc1e 100644 --- a/src/front_end_params/arith_simplifier_params.cpp +++ b/src/front_end_params/arith_simplifier_params.cpp @@ -20,7 +20,7 @@ Revision History: #include"arith_simplifier_params.h" void arith_simplifier_params::register_params(ini_params & p) { - p.register_bool_param("ARITH_EXPAND_EQS", m_arith_expand_eqs); - p.register_bool_param("ARITH_PROCESS_ALL_EQS", m_arith_process_all_eqs); + p.register_bool_param("arith_expand_eqs", m_arith_expand_eqs); + p.register_bool_param("arith_process_all_eqs", m_arith_process_all_eqs); } diff --git a/src/front_end_params/bit_blaster_params.h b/src/front_end_params/bit_blaster_params.h index 8196774ca..ab183d7fc 100644 --- a/src/front_end_params/bit_blaster_params.h +++ b/src/front_end_params/bit_blaster_params.h @@ -29,8 +29,8 @@ struct bit_blaster_params { m_bb_quantifiers(false) { } void register_params(ini_params & p) { - p.register_bool_param("BB_EXT_GATES", m_bb_ext_gates, "use extended gates during bit-blasting"); - p.register_bool_param("BB_QUANTIFIERS", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers"); + p.register_bool_param("bb_ext_gates", m_bb_ext_gates, "use extended gates during bit-blasting"); + p.register_bool_param("bb_quantifiers", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers"); } }; diff --git a/src/front_end_params/bv_simplifier_params.h b/src/front_end_params/bv_simplifier_params.h index a6ff749c4..50dedfd22 100644 --- a/src/front_end_params/bv_simplifier_params.h +++ b/src/front_end_params/bv_simplifier_params.h @@ -30,8 +30,8 @@ struct bv_simplifier_params { m_bv2int_distribute(true) { } void register_params(ini_params & p) { - p.register_bool_param("HI_DIV0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted."); - p.register_bool_param("BV2INT_DISTRIBUTE", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators."); + p.register_bool_param("hi_div0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted."); + p.register_bool_param("bv2int_distribute", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators."); } }; diff --git a/src/front_end_params/cnf_params.cpp b/src/front_end_params/cnf_params.cpp index 57d02e8db..fffd698a6 100644 --- a/src/front_end_params/cnf_params.cpp +++ b/src/front_end_params/cnf_params.cpp @@ -20,7 +20,7 @@ Revision History: #include"cnf_params.h" void cnf_params::register_params(ini_params & p) { - p.register_unsigned_param("CNF_FACTOR", m_cnf_factor, "the maximum number of clauses that can be created when converting a subformula"); - p.register_int_param("CNF_MODE", 0, 3, reinterpret_cast(m_cnf_mode), "CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - 0 + opportunistic, 3 - full"); + p.register_unsigned_param("cnf_factor", m_cnf_factor, "the maximum number of clauses that can be created when converting a subformula"); + p.register_int_param("cnf_mode", 0, 3, reinterpret_cast(m_cnf_mode), "CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - 0 + opportunistic, 3 - full"); } diff --git a/src/front_end_params/dyn_ack_params.cpp b/src/front_end_params/dyn_ack_params.cpp index b4d0546a9..90a0bb17b 100644 --- a/src/front_end_params/dyn_ack_params.cpp +++ b/src/front_end_params/dyn_ack_params.cpp @@ -19,13 +19,13 @@ Revision History: #include"dyn_ack_params.h" void dyn_ack_params::register_params(ini_params & p) { - p.register_int_param("DACK", 0, 2, reinterpret_cast(m_dack), + p.register_int_param("dack", 0, 2, reinterpret_cast(m_dack), "0 - disable dynamic ackermannization, 1 - expand Leibniz's axiom if a congruence is the root of a conflict, 2 - expand Leibniz's axiom if a congruence is used during conflict resolution."); - p.register_bool_param("DACK_EQ", m_dack_eq, "enable dynamic ackermannization for transtivity of equalities"); - p.register_unsigned_param("DACK_THRESHOLD", m_dack_threshold, "number of times the congruence rule must be used before Leibniz's axiom is expanded"); - p.register_double_param("DACK_FACTOR", m_dack_factor, "number of instance per conflict"); - p.register_unsigned_param("DACK_GC", m_dack_gc, "Dynamic ackermannization garbage collection frequency (per conflict)."); - p.register_double_param("DACK_GC_INV_DECAY", m_dack_gc_inv_decay); + p.register_bool_param("dack_eq", m_dack_eq, "enable dynamic ackermannization for transtivity of equalities"); + p.register_unsigned_param("dack_threshold", m_dack_threshold, "number of times the congruence rule must be used before Leibniz's axiom is expanded"); + p.register_double_param("dack_factor", m_dack_factor, "number of instance per conflict"); + p.register_unsigned_param("dack_gc", m_dack_gc, "Dynamic ackermannization garbage collection frequency (per conflict)."); + p.register_double_param("dack_gc_inv_decay", m_dack_gc_inv_decay); } diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 7aea7e7ee..9d05a3fc3 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -25,62 +25,62 @@ void front_end_params::register_params(ini_params & p) { parser_params::register_params(p); arith_simplifier_params::register_params(p); model_params::register_params(p); - p.register_bool_param("AT_LABELS_CEX", m_at_labels_cex, + p.register_bool_param("at_labels_cex", m_at_labels_cex, "only use labels that contain '@' when building multiple counterexamples"); - p.register_bool_param("CHECK_AT_LABELS", m_check_at_labels, + p.register_bool_param("check_at_labels", m_check_at_labels, "check that labels containing '@' are used correctly to only produce unique counter examples"); - p.register_bool_param("DEFAULT_QID", m_default_qid, "create a default quantifier id based on its position, the id is used to report profiling information (see QI_PROFILE)"); + p.register_bool_param("default_qid", m_default_qid, "create a default quantifier id based on its position, the id is used to report profiling information (see QI_PROFILE)"); - p.register_bool_param("TYPE_CHECK", m_well_sorted_check, "enable/disable type checker"); - p.register_bool_param("WELL_SORTED_CHECK", m_well_sorted_check, "enable/disable type checker"); - p.register_bool_param("INTERACTIVE", m_interactive, "enable interactive mode using Simplify input format"); - p.register_unsigned_param("SOFT_TIMEOUT", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); - p.register_double_param("INSTRUCTION_MAX", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); - p.register_bool_param("AUTO_CONFIG", m_auto_config, "use heuristics to set Z3 configuration parameters, it is only available for the SMT-LIB input format"); - p.register_int_param("PROOF_MODE", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); - p.register_bool_param("TRACE", m_trace, "enable tracing for the Axiom Profiler tool"); - p.register_string_param("TRACE_FILE_NAME", m_trace_file_name, "tracing file name"); - p.register_bool_param("ASYNC_COMMANDS", m_async_commands, "enable/disable support for asynchronous commands in the Simplify front-end."); - p.register_bool_param("DISPLAY_CONFIG", m_display_config, "display configuration used by Z3"); + p.register_bool_param("type_check", m_well_sorted_check, "enable/disable type checker"); + p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); + p.register_bool_param("interactive", m_interactive, "enable interactive mode using Simplify input format"); + p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); + p.register_double_param("instruction_max", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); + p.register_bool_param("auto_config", m_auto_config, "use heuristics to set Z3 configuration parameters, it is only available for the SMT-LIB input format"); + p.register_int_param("proof_mode", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); + p.register_bool_param("trace", m_trace, "enable tracing for the Axiom Profiler tool"); + p.register_string_param("trace_file_name", m_trace_file_name, "tracing file name"); + p.register_bool_param("async_commands", m_async_commands, "enable/disable support for asynchronous commands in the Simplify front-end."); + p.register_bool_param("display_config", m_display_config, "display configuration used by Z3"); #ifdef _WINDOWS // The non-windows memory manager does not have access to memory sizes. - p.register_unsigned_param("MEMORY_HIGH_WATERMARK", m_memory_high_watermark, + p.register_unsigned_param("memory_high_watermark", m_memory_high_watermark, "set high watermark for memory consumption (in megabytes)"); - p.register_unsigned_param("MEMORY_MAX_SIZE", m_memory_max_size, + p.register_unsigned_param("memory_max_size", m_memory_max_size, "set hard upper limit for memory consumption (in megabytes)"); #endif #ifndef _EXTERNAL_RELEASE // external users should not have access to it. - p.register_bool_param("PREPROCESS", m_preprocess); + p.register_bool_param("preprocess", m_preprocess); #endif - p.register_bool_param("USER_THEORY_PREPROCESS_AXIOMS", + p.register_bool_param("user_theory_preprocess_axioms", m_user_theory_preprocess_axioms, "Apply full pre-processing to user theory axioms", true); - p.register_bool_param("USER_THEORY_PERSIST_AXIOMS", + p.register_bool_param("user_theory_persist_axioms", m_user_theory_persist_axioms, "Persist user axioms to the base level", true); - p.register_bool_param("SMTLIB2_COMPLIANT", m_smtlib2_compliant); + p.register_bool_param("smtlib2_compliant", m_smtlib2_compliant); - p.register_bool_param("IGNORE_BAD_PATTERNS", m_ignore_bad_patterns); + p.register_bool_param("ignore_bad_patterns", m_ignore_bad_patterns); PRIVATE_PARAMS({ - p.register_bool_param("IGNORE_CHECKSAT", m_ignore_checksat); - p.register_bool_param("DEBUG_REF_COUNT", m_debug_ref_count); - p.register_bool_param("IGNORE_USER_PATTERNS", m_ignore_user_patterns); - p.register_bool_param("INCREMENTAL_CORE_ASSERT", m_incremental_core_assert); - DEBUG_CODE(p.register_int_param("COPY_PARAMS", m_copy_params);); + p.register_bool_param("ignore_checksat", m_ignore_checksat); + p.register_bool_param("debug_ref_count", m_debug_ref_count); + p.register_bool_param("ignore_user_patterns", m_ignore_user_patterns); + p.register_bool_param("incremental_core_assert", m_incremental_core_assert); + DEBUG_CODE(p.register_int_param("copy_params", m_copy_params);); }); // temporary hack until strategic_solver is ported to new tactic framework PRIVATE_PARAMS({ - p.register_bool_param("NLSAT", m_nlsat); + p.register_bool_param("nlsat", m_nlsat); }); } diff --git a/src/front_end_params/model_params.cpp b/src/front_end_params/model_params.cpp index df6420b7a..a859684d8 100644 --- a/src/front_end_params/model_params.cpp +++ b/src/front_end_params/model_params.cpp @@ -20,14 +20,14 @@ Revision History: #include"model_params.h" void model_params::register_params(ini_params & p) { - p.register_bool_param("MODEL_PARTIAL", m_model_partial, "enable/disable partial function interpretations", true); - p.register_bool_param("MODEL_V1", m_model_v1_pp, + p.register_bool_param("model_partial", m_model_partial, "enable/disable partial function interpretations", true); + p.register_bool_param("model_v1", m_model_v1_pp, "use Z3 version 1.x pretty printer", true); - p.register_bool_param("MODEL_V2", m_model_v2_pp, + p.register_bool_param("model_v2", m_model_v2_pp, "use Z3 version 2.x (x <= 16) pretty printer", true); - p.register_bool_param("MODEL_COMPACT", m_model_compact, + p.register_bool_param("model_compact", m_model_compact, "try to compact function graph (i.e., function interpretations that are lookup tables", true); - p.register_bool_param("MODEL_COMPLETION", m_model_completion, + p.register_bool_param("model_completion", m_model_completion, "assigns an interptetation to symbols that do not have one in the current model, when evaluating expressions in the current model", true); } diff --git a/src/front_end_params/nnf_params.cpp b/src/front_end_params/nnf_params.cpp index 044ca155e..351997f98 100644 --- a/src/front_end_params/nnf_params.cpp +++ b/src/front_end_params/nnf_params.cpp @@ -19,8 +19,8 @@ Revision History: #include"nnf_params.h" void nnf_params::register_params(ini_params & p) { - p.register_unsigned_param("NNF_FACTOR", m_nnf_factor, "the maximum growth factor during NNF translation (auxiliary definitions are introduced if the threshold is reached)"); - p.register_int_param("NNF_MODE", 0, 3, reinterpret_cast(m_nnf_mode), "NNF translation mode: 0 - skolem normal form, 1 - 0 + quantifiers in NNF, 2 - 1 + opportunistic, 3 - full"); - p.register_bool_param("NNF_IGNORE_LABELS", m_nnf_ignore_labels, "remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); - p.register_bool_param("NNF_SK_HACK", m_nnf_sk_hack, "hack for VCC"); + p.register_unsigned_param("nnf_factor", m_nnf_factor, "the maximum growth factor during NNF translation (auxiliary definitions are introduced if the threshold is reached)"); + p.register_int_param("nnf_mode", 0, 3, reinterpret_cast(m_nnf_mode), "NNF translation mode: 0 - skolem normal form, 1 - 0 + quantifiers in NNF, 2 - 1 + opportunistic, 3 - full"); + p.register_bool_param("nnf_ignore_labels", m_nnf_ignore_labels, "remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); + p.register_bool_param("nnf_sk_hack", m_nnf_sk_hack, "hack for VCC"); } diff --git a/src/front_end_params/params2front_end_params.cpp b/src/front_end_params/params2front_end_params.cpp index a2bae371c..4c5866786 100644 --- a/src/front_end_params/params2front_end_params.cpp +++ b/src/front_end_params/params2front_end_params.cpp @@ -27,28 +27,28 @@ Revision History: the new strategy framework. */ void params2front_end_params(params_ref const & s, front_end_params & t) { - t.m_relevancy_lvl = s.get_uint(":relevancy", t.m_relevancy_lvl); + t.m_relevancy_lvl = s.get_uint("relevancy", t.m_relevancy_lvl); TRACE("qi_cost", s.display(tout); tout << "\n";); - t.m_qi_cost = s.get_str(":qi-cost", t.m_qi_cost.c_str()); - t.m_mbqi = s.get_bool(":mbqi", t.m_mbqi); - t.m_mbqi_max_iterations = s.get_uint(":mbqi-max-iterations", t.m_mbqi_max_iterations); - t.m_random_seed = s.get_uint(":random-seed", t.m_random_seed); - t.m_model = s.get_bool(":produce-models", t.m_model); - if (s.get_bool(":produce-proofs", false)) + t.m_qi_cost = s.get_str("qi_cost", t.m_qi_cost.c_str()); + t.m_mbqi = s.get_bool("mbqi", t.m_mbqi); + t.m_mbqi_max_iterations = s.get_uint("mbqi_max_iterations", t.m_mbqi_max_iterations); + t.m_random_seed = s.get_uint("random_seed", t.m_random_seed); + t.m_model = s.get_bool("produce_models", t.m_model); + if (s.get_bool("produce_proofs", false)) t.m_proof_mode = PGM_FINE; - t.m_well_sorted_check = s.get_bool(":check-sorts", t.m_well_sorted_check); - t.m_qi_eager_threshold = s.get_double(":qi-eager-threshold", t.m_qi_eager_threshold); - t.m_qi_lazy_threshold = s.get_double(":qi-lazy-threshold", t.m_qi_lazy_threshold); - t.m_preprocess = s.get_bool(":preprocess", t.m_preprocess); - t.m_hi_div0 = s.get_bool(":hi-div0", t.m_hi_div0); - t.m_auto_config = s.get_bool(":auto-config", t.m_auto_config); - t.m_array_simplify = s.get_bool(":array-old-simplifier", t.m_array_simplify); - t.m_arith_branch_cut_ratio = s.get_uint(":arith-branch-cut-ratio", t.m_arith_branch_cut_ratio); - t.m_arith_expand_eqs = s.get_bool(":arith-expand-eqs", t.m_arith_expand_eqs); + t.m_well_sorted_check = s.get_bool("check_sorts", t.m_well_sorted_check); + t.m_qi_eager_threshold = s.get_double("qi_eager_threshold", t.m_qi_eager_threshold); + t.m_qi_lazy_threshold = s.get_double("qi_lazy_threshold", t.m_qi_lazy_threshold); + t.m_preprocess = s.get_bool("preprocess", t.m_preprocess); + t.m_hi_div0 = s.get_bool("hi_div0", t.m_hi_div0); + t.m_auto_config = s.get_bool("auto_config", t.m_auto_config); + t.m_array_simplify = s.get_bool("array_old_simplifier", t.m_array_simplify); + t.m_arith_branch_cut_ratio = s.get_uint("arith_branch_cut_ratio", t.m_arith_branch_cut_ratio); + t.m_arith_expand_eqs = s.get_bool("arith_expand_eqs", t.m_arith_expand_eqs); - if (s.get_bool(":arith-greatest-error-pivot", false)) + if (s.get_bool("arith_greatest_error_pivot", false)) t.m_arith_pivot_strategy = ARITH_PIVOT_GREATEST_ERROR; - else if (s.get_bool(":arith-least-error-pivot", false)) + else if (s.get_bool("arith_least_error_pivot", false)) t.m_arith_pivot_strategy = ARITH_PIVOT_LEAST_ERROR; } @@ -59,22 +59,22 @@ void params2front_end_params(params_ref const & s, front_end_params & t) { */ void front_end_params2params(front_end_params const & s, params_ref & t) { if (s.m_model) - t.set_bool(":produce-models", true); + t.set_bool("produce_models", true); if (!s.m_hi_div0) - t.set_bool(":hi-div0", false); + t.set_bool("hi_div0", false); } /** \brief Bridge for using params_ref with smt::context. */ void solver_front_end_params_descrs(param_descrs & r) { - r.insert(":hi-div0", CPK_BOOL, "(default: true) if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted"); - r.insert(":relevancy", CPK_UINT, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant"); - r.insert(":mbqi", CPK_BOOL, "model based quantifier instantiation (MBQI)"); - r.insert(":mbqi-max-iterations", CPK_UINT, "maximum number of rounds of MBQI"); - r.insert(":random-seed", CPK_UINT, "random seed for smt solver"); - r.insert(":qi-eager-threshold", CPK_DOUBLE, "threshold for eager quantifier instantiation"); - r.insert(":qi-lazy-threshold", CPK_DOUBLE, "threshold for lazy quantifier instantiation"); - r.insert(":auto_config", CPK_BOOL, "use heuristics to automatically configure smt solver"); - r.insert(":arith-branch-cut-ratio", CPK_UINT, "branch&bound / gomory cut ratio"); + r.insert("hi_div0", CPK_BOOL, "(default: true) if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted"); + r.insert("relevancy", CPK_UINT, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant"); + r.insert("mbqi", CPK_BOOL, "model based quantifier instantiation (MBQI)"); + r.insert("mbqi_max_iterations", CPK_UINT, "maximum number of rounds of MBQI"); + r.insert("random_seed", CPK_UINT, "random seed for smt solver"); + r.insert("qi_eager_threshold", CPK_DOUBLE, "threshold for eager quantifier instantiation"); + r.insert("qi_lazy_threshold", CPK_DOUBLE, "threshold for lazy quantifier instantiation"); + r.insert("auto_config", CPK_BOOL, "use heuristics to automatically configure smt solver"); + r.insert("arith_branch_cut_ratio", CPK_UINT, "branch&bound / gomory cut ratio"); } diff --git a/src/front_end_params/parser_params.cpp b/src/front_end_params/parser_params.cpp index 000885fa5..3edd03fb0 100644 --- a/src/front_end_params/parser_params.cpp +++ b/src/front_end_params/parser_params.cpp @@ -6,8 +6,8 @@ parser_params::parser_params() : } void parser_params::register_params(ini_params & p) { - p.register_bool_param("DUMP_GOAL_AS_SMT", m_dump_goal_as_smt, "write goal back to output in SMT format"); - p.register_bool_param("DISPLAY_ERROR_FOR_VISUAL_STUDIO", m_display_error_for_vs, "display error messages in Visual Studio format"); + p.register_bool_param("dump_goal_as_smt", m_dump_goal_as_smt, "write goal back to output in SMT format"); + p.register_bool_param("display_error_for_visual_studio", m_display_error_for_vs, "display error messages in Visual Studio format"); } diff --git a/src/front_end_params/pattern_inference_params.cpp b/src/front_end_params/pattern_inference_params.cpp index 176fdd8c2..4b0d4c964 100644 --- a/src/front_end_params/pattern_inference_params.cpp +++ b/src/front_end_params/pattern_inference_params.cpp @@ -19,19 +19,19 @@ Revision History: #include"pattern_inference_params.h" void pattern_inference_params::register_params(ini_params & p) { - p.register_unsigned_param("PI_MAX_MULTI_PATTERNS", m_pi_max_multi_patterns, + p.register_unsigned_param("pi_max_multi_patterns", m_pi_max_multi_patterns, "when patterns are not provided, the prover uses a heuristic to infer them. This option sets the threshold on the number of extra multi-patterns that can be created. By default, the prover creates at most one multi-pattern when there is no unary pattern"); - p.register_bool_param("PI_BLOCK_LOOP_PATTERNS", m_pi_block_loop_patterns, + p.register_bool_param("pi_block_loop_patterns", m_pi_block_loop_patterns, "block looping patterns during pattern inference"); - p.register_int_param("PI_ARITH", 0, 2, reinterpret_cast(m_pi_arith), + p.register_int_param("pi_arith", 0, 2, reinterpret_cast(m_pi_arith), "0 - do not infer patterns with arithmetic terms, 1 - use patterns with arithmetic terms if there is no other pattern, 2 - always use patterns with arithmetic terms."); - p.register_bool_param("PI_USE_DATABASE", m_pi_use_database); - p.register_unsigned_param("PI_ARITH_WEIGHT", m_pi_arith_weight, "default weight for quantifiers where the only available pattern has nested arithmetic terms."); - p.register_unsigned_param("PI_NON_NESTED_ARITH_WEIGHT", m_pi_non_nested_arith_weight, "default weight for quantifiers where the only available pattern has non nested arithmetic terms."); - p.register_bool_param("PI_PULL_QUANTIFIERS", m_pi_pull_quantifiers, "pull nested quantifiers, if no pattern was found."); - p.register_int_param("PI_NOPAT_WEIGHT", m_pi_nopat_weight, "set weight of quantifiers without patterns, if negative the weight is not changed."); - p.register_bool_param("PI_AVOID_SKOLEMS", m_pi_avoid_skolems); - p.register_bool_param("PI_WARNINGS", m_pi_warnings, "enable/disable warning messages in the pattern inference module."); + p.register_bool_param("pi_use_database", m_pi_use_database); + p.register_unsigned_param("pi_arith_weight", m_pi_arith_weight, "default weight for quantifiers where the only available pattern has nested arithmetic terms."); + p.register_unsigned_param("pi_non_nested_arith_weight", m_pi_non_nested_arith_weight, "default weight for quantifiers where the only available pattern has non nested arithmetic terms."); + p.register_bool_param("pi_pull_quantifiers", m_pi_pull_quantifiers, "pull nested quantifiers, if no pattern was found."); + p.register_int_param("pi_nopat_weight", m_pi_nopat_weight, "set weight of quantifiers without patterns, if negative the weight is not changed."); + p.register_bool_param("pi_avoid_skolems", m_pi_avoid_skolems); + p.register_bool_param("pi_warnings", m_pi_warnings, "enable/disable warning messages in the pattern inference module."); } diff --git a/src/front_end_params/preprocessor_params.h b/src/front_end_params/preprocessor_params.h index 4b32feb60..89bd01b48 100644 --- a/src/front_end_params/preprocessor_params.h +++ b/src/front_end_params/preprocessor_params.h @@ -84,25 +84,25 @@ public: pattern_inference_params::register_params(p); bit_blaster_params::register_params(p); bv_simplifier_params::register_params(p); - p.register_int_param("LIFT_ITE", 0, 2, reinterpret_cast(m_lift_ite), "ite term lifting: 0 - no lifting, 1 - conservative, 2 - full"); - p.register_int_param("NG_LIFT_ITE", 0, 2, reinterpret_cast(m_ng_lift_ite), "ite (non-ground) term lifting: 0 - no lifting, 1 - conservative, 2 - full"); - p.register_bool_param("ELIM_TERM_ITE", m_eliminate_term_ite, "eliminate term if-then-else in the preprocessor"); - p.register_bool_param("ELIM_AND", m_eliminate_and, "represent (and a b) as (not (or (not a) (not b)))"); - p.register_bool_param("MACRO_FINDER", m_macro_finder, "try to find universally quantified formulas that can be viewed as macros"); - p.register_bool_param("PROPAGATE_VALUES", m_propagate_values, "propagate values during preprocessing step"); - p.register_bool_param("PROPAGATE_BOOLEANS", m_propagate_booleans, "propagate boolean values during preprocessing step"); - p.register_bool_param("PULL_CHEAP_ITE_TREES", m_pull_cheap_ite_trees); - p.register_bool_param("PULL_NESTED_QUANTIFIERS", m_pull_nested_quantifiers, "eliminate nested quantifiers by moving nested quantified variables to the outermost quantifier, it is unnecessary if the formula is converted into CNF"); - p.register_bool_param("REFINE_INJ_AXIOM", m_refine_inj_axiom); - p.register_bool_param("ELIM_BOUNDS", m_eliminate_bounds, "cheap Fourier-Motzkin"); + p.register_int_param("lift_ite", 0, 2, reinterpret_cast(m_lift_ite), "ite term lifting: 0 - no lifting, 1 - conservative, 2 - full"); + p.register_int_param("ng_lift_ite", 0, 2, reinterpret_cast(m_ng_lift_ite), "ite (non-ground) term lifting: 0 - no lifting, 1 - conservative, 2 - full"); + p.register_bool_param("elim_term_ite", m_eliminate_term_ite, "eliminate term if-then-else in the preprocessor"); + p.register_bool_param("elim_and", m_eliminate_and, "represent (and a b) as (not (or (not a) (not b)))"); + p.register_bool_param("macro_finder", m_macro_finder, "try to find universally quantified formulas that can be viewed as macros"); + p.register_bool_param("propagate_values", m_propagate_values, "propagate values during preprocessing step"); + p.register_bool_param("propagate_booleans", m_propagate_booleans, "propagate boolean values during preprocessing step"); + p.register_bool_param("pull_cheap_ite_trees", m_pull_cheap_ite_trees); + p.register_bool_param("pull_nested_quantifiers", m_pull_nested_quantifiers, "eliminate nested quantifiers by moving nested quantified variables to the outermost quantifier, it is unnecessary if the formula is converted into CNF"); + p.register_bool_param("refine_inj_axiom", m_refine_inj_axiom); + p.register_bool_param("elim_bounds", m_eliminate_bounds, "cheap Fourier-Motzkin"); - p.register_bool_param("BIT2INT", m_simplify_bit2int, "hoist bit2int conversions over arithmetical expressions"); - p.register_bool_param("DISTRIBUTE_FORALL", m_distribute_forall); - p.register_bool_param("REDUCE_ARGS", m_reduce_args); - p.register_bool_param("QUASI_MACROS", m_quasi_macros); - p.register_bool_param("RESTRICTED_QUASI_MACROS", m_restricted_quasi_macros); - p.register_bool_param("BV_MAX_SHARING", m_max_bv_sharing); - p.register_bool_param("PRE_SIMPLIFIER", m_pre_simplifier); + p.register_bool_param("bit2int", m_simplify_bit2int, "hoist bit2int conversions over arithmetical expressions"); + p.register_bool_param("distribute_forall", m_distribute_forall); + p.register_bool_param("reduce_args", m_reduce_args); + p.register_bool_param("quasi_macros", m_quasi_macros); + p.register_bool_param("restricted_quasi_macros", m_restricted_quasi_macros); + p.register_bool_param("bv_max_sharing", m_max_bv_sharing); + p.register_bool_param("pre_simplifier", m_pre_simplifier); } }; diff --git a/src/front_end_params/qi_params.h b/src/front_end_params/qi_params.h index bd41de12c..aee2c4d3d 100644 --- a/src/front_end_params/qi_params.h +++ b/src/front_end_params/qi_params.h @@ -107,31 +107,31 @@ struct qi_params { } void register_params(ini_params & p) { - p.register_unsigned_param("QI_MAX_EAGER_MULTI_PATTERNS", m_qi_max_eager_multipatterns, + p.register_unsigned_param("qi_max_eager_multi_patterns", m_qi_max_eager_multipatterns, "Specify the number of extra multi patterns that are processed eagerly. By default, the prover use at most one multi-pattern eagerly when there is no unary pattern. This value should be smaller than or equal to PI_MAX_MULTI_PATTERNS"); - p.register_unsigned_param("QI_MAX_LAZY_MULTI_PATTERN_MATCHING", m_qi_max_lazy_multipattern_matching, "Maximum number of rounds of matching in a branch for delayed multipatterns. A multipattern is delayed based on the value of QI_MAX_EAGER_MULTI_PATTERNS"); - p.register_string_param("QI_COST", m_qi_cost, "The cost function for quantifier instantiation"); - p.register_string_param("QI_NEW_GEN", m_qi_new_gen, "The function for calculating the generation of newly constructed terms"); - p.register_double_param("QI_EAGER_THRESHOLD", m_qi_eager_threshold, "Threshold for eager quantifier instantiation"); - p.register_double_param("QI_LAZY_THRESHOLD", m_qi_lazy_threshold, "Threshold for lazy quantifier instantiation"); - p.register_bool_param("QI_PROFILE", m_qi_profile); - p.register_unsigned_param("QI_PROFILE_FREQ", m_qi_profile_freq); - p.register_int_param("QI_QUICK_CHECKER", 0, 2, reinterpret_cast(m_qi_quick_checker), "0 - do not use (cheap) model checker, 1 - instantiate instances unsatisfied by current model, 2 - 1 + instantiate instances not satisfied by current model"); - p.register_bool_param("QI_LAZY_QUICK_CHECKER", m_qi_lazy_quick_checker); - p.register_bool_param("QI_PROMOTE_UNSAT", m_qi_promote_unsat); - p.register_unsigned_param("QI_MAX_INSTANCES", m_qi_max_instances); - p.register_bool_param("QI_LAZY_INSTANTIATION", m_qi_lazy_instantiation); - p.register_bool_param("QI_CONSERVATIVE_FINAL_CHECK", m_qi_conservative_final_check); + p.register_unsigned_param("qi_max_lazy_multi_pattern_matching", m_qi_max_lazy_multipattern_matching, "Maximum number of rounds of matching in a branch for delayed multipatterns. A multipattern is delayed based on the value of QI_MAX_EAGER_MULTI_PATTERNS"); + p.register_string_param("qi_cost", m_qi_cost, "The cost function for quantifier instantiation"); + p.register_string_param("qi_new_gen", m_qi_new_gen, "The function for calculating the generation of newly constructed terms"); + p.register_double_param("qi_eager_threshold", m_qi_eager_threshold, "Threshold for eager quantifier instantiation"); + p.register_double_param("qi_lazy_threshold", m_qi_lazy_threshold, "Threshold for lazy quantifier instantiation"); + p.register_bool_param("qi_profile", m_qi_profile); + p.register_unsigned_param("qi_profile_freq", m_qi_profile_freq); + p.register_int_param("qi_quick_checker", 0, 2, reinterpret_cast(m_qi_quick_checker), "0 - do not use (cheap) model checker, 1 - instantiate instances unsatisfied by current model, 2 - 1 + instantiate instances not satisfied by current model"); + p.register_bool_param("qi_lazy_quick_checker", m_qi_lazy_quick_checker); + p.register_bool_param("qi_promote_unsat", m_qi_promote_unsat); + p.register_unsigned_param("qi_max_instances", m_qi_max_instances); + p.register_bool_param("qi_lazy_instantiation", m_qi_lazy_instantiation); + p.register_bool_param("qi_conservative_final_check", m_qi_conservative_final_check); - p.register_bool_param("MBQI", m_mbqi, "Model Based Quantifier Instantiation (MBQI)"); - p.register_unsigned_param("MBQI_MAX_CEXS", m_mbqi_max_cexs, "Initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation", true); - p.register_unsigned_param("MBQI_MAX_CEXS_INCR", m_mbqi_max_cexs_incr, "Increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI", true); - p.register_unsigned_param("MBQI_MAX_ITERATIONS", m_mbqi_max_iterations, "Maximum number of rounds of MBQI", true); - p.register_bool_param("MBQI_TRACE", m_mbqi_trace, "Generate tracing messages for Model Based Quantifier Instantiation (MBQI). It will display a message before every round of MBQI, and the quantifiers that were not satisfied.", true); - p.register_unsigned_param("MBQI_FORCE_TEMPLATE", m_mbqi_force_template, "Some quantifiers can be used as templates for building interpretations for functions. Z3 uses heuristics to decide whether a quantifier will be used as a template or not. Quantifiers with weight >= MBQI_FORCE_TEMPLATE are forced to be used as a template", true); + p.register_bool_param("mbqi", m_mbqi, "Model Based Quantifier Instantiation (MBQI)"); + p.register_unsigned_param("mbqi_max_cexs", m_mbqi_max_cexs, "Initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation", true); + p.register_unsigned_param("mbqi_max_cexs_incr", m_mbqi_max_cexs_incr, "Increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI", true); + p.register_unsigned_param("mbqi_max_iterations", m_mbqi_max_iterations, "Maximum number of rounds of MBQI", true); + p.register_bool_param("mbqi_trace", m_mbqi_trace, "Generate tracing messages for Model Based Quantifier Instantiation (MBQI). It will display a message before every round of MBQI, and the quantifiers that were not satisfied.", true); + p.register_unsigned_param("mbqi_force_template", m_mbqi_force_template, "Some quantifiers can be used as templates for building interpretations for functions. Z3 uses heuristics to decide whether a quantifier will be used as a template or not. Quantifiers with weight >= MBQI_FORCE_TEMPLATE are forced to be used as a template", true); - p.register_bool_param("INST_GEN", m_instgen, "Enable Instantiation Generation solver (disables other quantifier reasoning)", false); + p.register_bool_param("inst_gen", m_instgen, "Enable Instantiation Generation solver (disables other quantifier reasoning)", false); } }; diff --git a/src/front_end_params/smt_params.cpp b/src/front_end_params/smt_params.cpp index 0c4a0c844..14db6020a 100644 --- a/src/front_end_params/smt_params.cpp +++ b/src/front_end_params/smt_params.cpp @@ -27,82 +27,82 @@ void smt_params::register_params(ini_params & p) { theory_bv_params::register_params(p); theory_datatype_params::register_params(p); - p.register_bool_param("CHECK_PROOF", m_check_proof); - p.register_bool_param("DISPLAY_PROOF", m_display_proof); - p.register_bool_param("DISPLAY_DOT_PROOF", m_display_dot_proof); - p.register_bool_param("DISPLAY_UNSAT_CORE", m_display_unsat_core); - p.register_bool_param("INTERNALIZER_NNF", m_internalizer_nnf); - p.register_bool_param("EQ_PROPAGATION", m_eq_propagation); - p.register_bool_param("BIN_CLAUSES", m_binary_clause_opt); - p.register_unsigned_param("RELEVANCY", m_relevancy_lvl, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant", true); - p.register_bool_param("RELEVANCY_LEMMA", m_relevancy_lemma, "true if lemmas are used to propagate relevancy"); - p.register_unsigned_param("RANDOM_SEED", m_random_seed, "random seed for Z3"); - p.register_percentage_param("RANDOM_CASE_SPLIT_FREQ", m_random_var_freq, "frequency of random case splits"); - p.register_int_param("PHASE_SELECTION", 0, 6, reinterpret_cast(m_phase_selection), "phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences"); - p.register_bool_param("MINIMIZE_LEMMAS", m_minimize_lemmas, "enable/disable lemma minimization algorithm"); - p.register_unsigned_param("MAX_CONFLICTS", m_max_conflicts, "maximum number of conflicts"); + p.register_bool_param("check_proof", m_check_proof); + p.register_bool_param("display_proof", m_display_proof); + p.register_bool_param("display_dot_proof", m_display_dot_proof); + p.register_bool_param("display_unsat_core", m_display_unsat_core); + p.register_bool_param("internalizer_nnf", m_internalizer_nnf); + p.register_bool_param("eq_propagation", m_eq_propagation); + p.register_bool_param("bin_clauses", m_binary_clause_opt); + p.register_unsigned_param("relevancy", m_relevancy_lvl, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant", true); + p.register_bool_param("relevancy_lemma", m_relevancy_lemma, "true if lemmas are used to propagate relevancy"); + p.register_unsigned_param("random_seed", m_random_seed, "random seed for Z3"); + p.register_percentage_param("random_case_split_freq", m_random_var_freq, "frequency of random case splits"); + p.register_int_param("phase_selection", 0, 6, reinterpret_cast(m_phase_selection), "phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences"); + p.register_bool_param("minimize_lemmas", m_minimize_lemmas, "enable/disable lemma minimization algorithm"); + p.register_unsigned_param("max_conflicts", m_max_conflicts, "maximum number of conflicts"); - p.register_unsigned_param("RECENT_LEMMA_THRESHOLD", m_recent_lemmas_size); - p.register_unsigned_param("TICK", m_tick); + p.register_unsigned_param("recent_lemma_threshold", m_recent_lemmas_size); + p.register_unsigned_param("tick", m_tick); PRIVATE_PARAMS({ - p.register_bool_param("THEORY_RESOLVE", m_theory_resolve, "Apply theory resolution to produce auxiliary conflict clauses", true); + p.register_bool_param("theory_resolve", m_theory_resolve, "Apply theory resolution to produce auxiliary conflict clauses", true); }); - p.register_int_param("RESTART_STRATEGY", 0, 4, reinterpret_cast(m_restart_strategy), "0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic"); - p.register_unsigned_param("RESTART_INITIAL", m_restart_initial, + p.register_int_param("restart_strategy", 0, 4, reinterpret_cast(m_restart_strategy), "0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic"); + p.register_unsigned_param("restart_initial", m_restart_initial, "inital restart frequency in number of conflicts, it is also the unit for the luby sequence"); - p.register_double_param("RESTART_FACTOR", m_restart_factor, "when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold"); - p.register_bool_param("RESTART_ADAPTIVE", m_restart_adaptive, "disable restarts based on the search 'agility'"); - p.register_percentage_param("RESTART_AGILITY_THRESHOLD", m_restart_agility_threshold); + p.register_double_param("restart_factor", m_restart_factor, "when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold"); + p.register_bool_param("restart_adaptive", m_restart_adaptive, "disable restarts based on the search 'agility'"); + p.register_percentage_param("restart_agility_threshold", m_restart_agility_threshold); - p.register_int_param("LEMMA_GC_STRATEGY", 0, 2, reinterpret_cast(m_lemma_gc_strategy), "0 - fixed, 1 - geometric, 2 - at every restart"); - p.register_bool_param("LEMMA_GC_HALF", m_lemma_gc_half, "true for simple gc algorithm (delete approx. half of the clauses)"); - p.register_unsigned_param("LEMMA_GC_INITIAL", m_lemma_gc_initial, "lemma initial gc frequency (in number of conflicts), used by fixed or geometric strategies"); - p.register_double_param("LEMMA_GC_FACTOR", m_lemma_gc_factor, "used by geometric strategy"); - p.register_unsigned_param("LEMMA_GC_NEW_OLD_RATIO", m_new_old_ratio); - p.register_unsigned_param("LEMMA_GC_NEW_CLAUSE_ACTIVITY", m_new_clause_activity); - p.register_unsigned_param("LEMMA_GC_OLD_CLAUSE_ACTIVITY", m_old_clause_activity); - p.register_unsigned_param("LEMMA_GC_NEW_CLAUSE_RELEVANCY", m_new_clause_relevancy); - p.register_unsigned_param("LEMMA_GC_OLD_CLAUSE_RELEVANCY", m_old_clause_activity); + p.register_int_param("lemma_gc_strategy", 0, 2, reinterpret_cast(m_lemma_gc_strategy), "0 - fixed, 1 - geometric, 2 - at every restart"); + p.register_bool_param("lemma_gc_half", m_lemma_gc_half, "true for simple gc algorithm (delete approx. half of the clauses)"); + p.register_unsigned_param("lemma_gc_initial", m_lemma_gc_initial, "lemma initial gc frequency (in number of conflicts), used by fixed or geometric strategies"); + p.register_double_param("lemma_gc_factor", m_lemma_gc_factor, "used by geometric strategy"); + p.register_unsigned_param("lemma_gc_new_old_ratio", m_new_old_ratio); + p.register_unsigned_param("lemma_gc_new_clause_activity", m_new_clause_activity); + p.register_unsigned_param("lemma_gc_old_clause_activity", m_old_clause_activity); + p.register_unsigned_param("lemma_gc_new_clause_relevancy", m_new_clause_relevancy); + p.register_unsigned_param("lemma_gc_old_clause_relevancy", m_old_clause_activity); - p.register_bool_param("SIMPLIFY_CLAUSES", m_simplify_clauses); + p.register_bool_param("simplify_clauses", m_simplify_clauses); - p.register_int_param("RANDOM_INITIAL_ACTIVITY", 0, 2, reinterpret_cast(m_random_initial_activity)); + p.register_int_param("random_initial_activity", 0, 2, reinterpret_cast(m_random_initial_activity)); PRIVATE_PARAMS({ - p.register_double_param("INV_DECAY", m_inv_decay); - p.register_unsigned_param("PHASE_CACHING_ON_DURATION", m_phase_caching_on); - p.register_unsigned_param("PHASE_CACHING_OFF_DURATION", m_phase_caching_off); + p.register_double_param("inv_decay", m_inv_decay); + p.register_unsigned_param("phase_caching_on_duration", m_phase_caching_on); + p.register_unsigned_param("phase_caching_off_duration", m_phase_caching_off); }); - p.register_bool_param("SMTLIB_DUMP_LEMMAS", m_smtlib_dump_lemmas); - p.register_string_param("SMTLIB_LOGIC", m_smtlib_logic, "Name used for the :logic field when generating SMT-LIB benchmarks"); - p.register_bool_param("DISPLAY_FEATURES", m_display_features); + p.register_bool_param("smtlib_dump_lemmas", m_smtlib_dump_lemmas); + p.register_string_param("smtlib_logic", m_smtlib_logic, "Name used for the :logic field when generating SMT-LIB benchmarks"); + p.register_bool_param("display_features", m_display_features); - p.register_bool_param("NEW_CORE2TH_EQ", m_new_core2th_eq); - p.register_bool_param("EMATCHING", m_ematching, "E-Matching based quantifier instantiation"); + p.register_bool_param("new_core2th_eq", m_new_core2th_eq); + p.register_bool_param("ematching", m_ematching, "E-Matching based quantifier instantiation"); - p.register_bool_param("PROFILE_RES_SUB", m_profile_res_sub); + p.register_bool_param("profile_res_sub", m_profile_res_sub); #ifndef _EXTERNAL_RELEASE - p.register_bool_param("DISPLAY_BOOL_VAR2EXPR", m_display_bool_var2expr); - p.register_bool_param("DISPLAY_LL_BOOL_VAR2EXPR", m_display_ll_bool_var2expr); - p.register_bool_param("ABORT_AFTER_PREPROC", m_abort_after_preproc, "abort after preprocessing step, this flag is only useful for debugging purposes"); - p.register_bool_param("DISPLAY_INSTALLED_THEORIES", m_display_installed_theories, "display theories installed at smt::context", true); + p.register_bool_param("display_bool_var2expr", m_display_bool_var2expr); + p.register_bool_param("display_ll_bool_var2expr", m_display_ll_bool_var2expr); + p.register_bool_param("abort_after_preproc", m_abort_after_preproc, "abort after preprocessing step, this flag is only useful for debugging purposes"); + p.register_bool_param("display_installed_theories", m_display_installed_theories, "display theories installed at smt::context", true); #endif - p.register_int_param("CASE_SPLIT", 0, 5, reinterpret_cast(m_case_split_strategy), "0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal"); - p.register_unsigned_param("REL_CASE_SPLIT_ORDER", 0, 2, m_rel_case_split_order, "structural (relevancy) splitting order: 0 - left-to-right (default), 1 - random, 2 - right-to-left"); - p.register_bool_param("LOOKAHEAD_DISEQ", m_lookahead_diseq); + p.register_int_param("case_split", 0, 5, reinterpret_cast(m_case_split_strategy), "0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal"); + p.register_unsigned_param("rel_case_split_order", 0, 2, m_rel_case_split_order, "structural (relevancy) splitting order: 0 - left-to-right (default), 1 - random, 2 - right-to-left"); + p.register_bool_param("lookahead_diseq", m_lookahead_diseq); - p.register_bool_param("DELAY_UNITS", m_delay_units); - p.register_unsigned_param("DELAY_UNITS_THRESHOLD", m_delay_units_threshold); + p.register_bool_param("delay_units", m_delay_units); + p.register_unsigned_param("delay_units_threshold", m_delay_units_threshold); - p.register_bool_param("MODEL", m_model, "enable/disable model construction", true); - p.register_bool_param("MODEL_VALIDATE", m_model_validate, "validate the model", true); - p.register_bool_param("MODEL_ON_TIMEOUT", m_model_on_timeout, "after hitting soft-timeout or memory high watermark, generate a candidate model", true); - p.register_bool_param("MODEL_ON_FINAL_CHECK", m_model_on_final_check, "display candidate model (in the standard output) whenever Z3 hits a final check", true); + p.register_bool_param("model", m_model, "enable/disable model construction", true); + p.register_bool_param("model_validate", m_model_validate, "validate the model", true); + p.register_bool_param("model_on_timeout", m_model_on_timeout, "after hitting soft-timeout or memory high watermark, generate a candidate model", true); + p.register_bool_param("model_on_final_check", m_model_on_final_check, "display candidate model (in the standard output) whenever Z3 hits a final check", true); - p.register_unsigned_param("PROGRESS_SAMPLING_FREQ", m_progress_sampling_freq, "frequency for progress output in miliseconds"); + p.register_unsigned_param("progress_sampling_freq", m_progress_sampling_freq, "frequency for progress output in miliseconds"); } diff --git a/src/front_end_params/theory_arith_params.cpp b/src/front_end_params/theory_arith_params.cpp index 2d77b6e73..49a654dbf 100644 --- a/src/front_end_params/theory_arith_params.cpp +++ b/src/front_end_params/theory_arith_params.cpp @@ -21,56 +21,56 @@ Revision History: void theory_arith_params::register_params(ini_params & p) { #ifdef _EXTERNAL_RELEASE - p.register_int_param("ARITH_SOLVER", 0, 3, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination"); + p.register_int_param("arith_solver", 0, 3, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination"); #else - p.register_int_param("ARITH_SOLVER", 0, 4, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination, 4 - model guided arith_solver"); + p.register_int_param("arith_solver", 0, 4, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination, 4 - model guided arith_solver"); #endif - p.register_bool_param("ARITH_FORCE_SIMPLEX", m_arith_auto_config_simplex, "force Z3 to use simplex solver."); - p.register_unsigned_param("ARITH_BLANDS_RULE_THRESHOLD", m_arith_blands_rule_threshold); - p.register_bool_param("ARITH_PROPAGATE_EQS", m_arith_propagate_eqs); - p.register_int_param("ARITH_PROPAGATION_MODE", 0, 2, reinterpret_cast(m_arith_bound_prop)); - p.register_bool_param("ARITH_STRONGER_LEMMAS", m_arith_stronger_lemmas); - p.register_bool_param("ARITH_SKIP_BIG_COEFFS", m_arith_skip_rows_with_big_coeffs); - p.register_unsigned_param("ARITH_MAX_LEMMA_SIZE", m_arith_max_lemma_size); - p.register_unsigned_param("ARITH_SMALL_LEMMA_SIZE", m_arith_small_lemma_size); - p.register_bool_param("ARITH_REFLECT", m_arith_reflect); - p.register_bool_param("ARITH_IGNORE_INT", m_arith_ignore_int); - p.register_unsigned_param("ARITH_LAZY_PIVOTING", m_arith_lazy_pivoting_lvl); - p.register_unsigned_param("ARITH_RANDOM_SEED", m_arith_random_seed); - p.register_bool_param("ARITH_RANDOM_INITIAL_VALUE", m_arith_random_initial_value); - p.register_int_param("ARITH_RANDOM_LOWER", m_arith_random_lower); - p.register_int_param("ARITH_RANDOM_UPPER", m_arith_random_upper); - p.register_bool_param("ARITH_ADAPTIVE", m_arith_adaptive); - p.register_double_param("ARITH_ADAPTIVE_ASSERTION_THRESHOLD", m_arith_adaptive_assertion_threshold, "Delay arithmetic atoms if the num-arith-conflicts/total-conflicts < threshold"); - p.register_double_param("ARITH_ADAPTIVE_PROPAGATION_THRESHOLD", m_arith_adaptive_propagation_threshold, "Disable arithmetic theory propagation if the num-arith-conflicts/total-conflicts < threshold"); - p.register_bool_param("ARITH_DUMP_LEMMAS", m_arith_dump_lemmas); - p.register_bool_param("ARITH_EAGER_EQ_AXIOMS", m_arith_eager_eq_axioms); - p.register_unsigned_param("ARITH_BRANCH_CUT_RATIO", m_arith_branch_cut_ratio); + p.register_bool_param("arith_force_simplex", m_arith_auto_config_simplex, "force Z3 to use simplex solver."); + p.register_unsigned_param("arith_blands_rule_threshold", m_arith_blands_rule_threshold); + p.register_bool_param("arith_propagate_eqs", m_arith_propagate_eqs); + p.register_int_param("arith_propagation_mode", 0, 2, reinterpret_cast(m_arith_bound_prop)); + p.register_bool_param("arith_stronger_lemmas", m_arith_stronger_lemmas); + p.register_bool_param("arith_skip_big_coeffs", m_arith_skip_rows_with_big_coeffs); + p.register_unsigned_param("arith_max_lemma_size", m_arith_max_lemma_size); + p.register_unsigned_param("arith_small_lemma_size", m_arith_small_lemma_size); + p.register_bool_param("arith_reflect", m_arith_reflect); + p.register_bool_param("arith_ignore_int", m_arith_ignore_int); + p.register_unsigned_param("arith_lazy_pivoting", m_arith_lazy_pivoting_lvl); + p.register_unsigned_param("arith_random_seed", m_arith_random_seed); + p.register_bool_param("arith_random_initial_value", m_arith_random_initial_value); + p.register_int_param("arith_random_lower", m_arith_random_lower); + p.register_int_param("arith_random_upper", m_arith_random_upper); + p.register_bool_param("arith_adaptive", m_arith_adaptive); + p.register_double_param("arith_adaptive_assertion_threshold", m_arith_adaptive_assertion_threshold, "Delay arithmetic atoms if the num-arith-conflicts/total-conflicts < threshold"); + p.register_double_param("arith_adaptive_propagation_threshold", m_arith_adaptive_propagation_threshold, "Disable arithmetic theory propagation if the num-arith-conflicts/total-conflicts < threshold"); + p.register_bool_param("arith_dump_lemmas", m_arith_dump_lemmas); + p.register_bool_param("arith_eager_eq_axioms", m_arith_eager_eq_axioms); + p.register_unsigned_param("arith_branch_cut_ratio", m_arith_branch_cut_ratio); - p.register_bool_param("ARITH_ADD_BINARY_BOUNDS", m_arith_add_binary_bounds); - p.register_unsigned_param("ARITH_PROP_STRATEGY", 0, 1, reinterpret_cast(m_arith_propagation_strategy), "Propagation strategy: 0 - use agility measures based on ration of theory conflicts, 1 - propagate proportional to ratio of theory conflicts (default)"); + p.register_bool_param("arith_add_binary_bounds", m_arith_add_binary_bounds); + p.register_unsigned_param("arith_prop_strategy", 0, 1, reinterpret_cast(m_arith_propagation_strategy), "Propagation strategy: 0 - use agility measures based on ration of theory conflicts, 1 - propagate proportional to ratio of theory conflicts (default)"); - p.register_bool_param("ARITH_EQ_BOUNDS", m_arith_eq_bounds); - p.register_bool_param("ARITH_LAZY_ADAPTER", m_arith_lazy_adapter); - p.register_bool_param("ARITH_GCD_TEST", m_arith_gcd_test); - p.register_bool_param("ARITH_EAGER_GCD", m_arith_eager_gcd); - p.register_bool_param("ARITH_ADAPTIVE_GCD", m_arith_adaptive_gcd); - p.register_unsigned_param("ARITH_PROPAGATION_THRESHOLD", m_arith_propagation_threshold); + p.register_bool_param("arith_eq_bounds", m_arith_eq_bounds); + p.register_bool_param("arith_lazy_adapter", m_arith_lazy_adapter); + p.register_bool_param("arith_gcd_test", m_arith_gcd_test); + p.register_bool_param("arith_eager_gcd", m_arith_eager_gcd); + p.register_bool_param("arith_adaptive_gcd", m_arith_adaptive_gcd); + p.register_unsigned_param("arith_propagation_threshold", m_arith_propagation_threshold); - p.register_bool_param("NL_ARITH", m_nl_arith, "enable/disable non linear arithmetic support. This option is ignored when ARITH_SOLVER != 2."); - p.register_bool_param("NL_ARITH_GB", m_nl_arith_gb, "enable/disable Grobner Basis computation. This option is ignored when NL_ARITH=false"); - p.register_bool_param("NL_ARITH_GB_EQS", m_nl_arith_gb_eqs, "enable/disable equations in the Grobner Basis to be copied to the Simplex tableau."); - p.register_bool_param("NL_ARITH_GB_PERTURBATE", m_nl_arith_gb_perturbate, "enable/disable perturbation of the variable order in GB when searching for new polynomials."); - p.register_unsigned_param("NL_ARITH_GB_THRESHOLD", m_nl_arith_gb_threshold, "Grobner basis computation can be very expensive. This is a threshold on the number of new equalities that can be generated."); - p.register_bool_param("NL_ARITH_BRANCHING", m_nl_arith_branching, "enable/disable branching on integer variables in non linear clusters"); - p.register_unsigned_param("NL_ARITH_ROUNDS", m_nl_arith_rounds, "threshold for number of (nested) final checks for non linear arithmetic."); - p.register_unsigned_param("NL_ARITH_MAX_DEGREE", m_nl_arith_max_degree, "max degree for internalizing new monomials."); + p.register_bool_param("nl_arith", m_nl_arith, "enable/disable non linear arithmetic support. This option is ignored when ARITH_SOLVER != 2."); + p.register_bool_param("nl_arith_gb", m_nl_arith_gb, "enable/disable Grobner Basis computation. This option is ignored when NL_ARITH=false"); + p.register_bool_param("nl_arith_gb_eqs", m_nl_arith_gb_eqs, "enable/disable equations in the Grobner Basis to be copied to the Simplex tableau."); + p.register_bool_param("nl_arith_gb_perturbate", m_nl_arith_gb_perturbate, "enable/disable perturbation of the variable order in GB when searching for new polynomials."); + p.register_unsigned_param("nl_arith_gb_threshold", m_nl_arith_gb_threshold, "Grobner basis computation can be very expensive. This is a threshold on the number of new equalities that can be generated."); + p.register_bool_param("nl_arith_branching", m_nl_arith_branching, "enable/disable branching on integer variables in non linear clusters"); + p.register_unsigned_param("nl_arith_rounds", m_nl_arith_rounds, "threshold for number of (nested) final checks for non linear arithmetic."); + p.register_unsigned_param("nl_arith_max_degree", m_nl_arith_max_degree, "max degree for internalizing new monomials."); PRIVATE_PARAMS({ - p.register_bool_param("ARITH_FIXNUM", m_arith_fixnum); - p.register_bool_param("ARITH_INT_ONLY", m_arith_int_only); - p.register_bool_param("ARITH_ENUM_CONST_MOD", m_arith_enum_const_mod, "Create axioms for the finite set of equalities for (mod x k) where k is a positive numeral constant"); - p.register_bool_param("ARITH_INT_EQ_BRANCHING", m_arith_int_eq_branching, "Determine branch predicates based on integer equation solving"); + p.register_bool_param("arith_fixnum", m_arith_fixnum); + p.register_bool_param("arith_int_only", m_arith_int_only); + p.register_bool_param("arith_enum_const_mod", m_arith_enum_const_mod, "Create axioms for the finite set of equalities for (mod x k) where k is a positive numeral constant"); + p.register_bool_param("arith_int_eq_branching", m_arith_int_eq_branching, "Determine branch predicates based on integer equation solving"); }); - p.register_bool_param("ARITH_EUCLIDEAN_SOLVER", m_arith_euclidean_solver, ""); + p.register_bool_param("arith_euclidean_solver", m_arith_euclidean_solver, ""); } diff --git a/src/front_end_params/theory_array_params.h b/src/front_end_params/theory_array_params.h index 9e93fefbe..3d45ebcf5 100644 --- a/src/front_end_params/theory_array_params.h +++ b/src/front_end_params/theory_array_params.h @@ -56,17 +56,17 @@ struct theory_array_params { } void register_params(ini_params & p) { - p.register_int_param("ARRAY_SOLVER", 0, 3, reinterpret_cast(m_array_mode), "0 - no array, 1 - simple, 2 - model based, 3 - full"); - p.register_bool_param("ARRAY_WEAK", m_array_weak); - p.register_bool_param("ARRAY_EXTENSIONAL", m_array_extensional); - p.register_unsigned_param("ARRAY_LAZINESS", m_array_laziness); - p.register_bool_param("ARRAY_DELAY_EXP_AXIOM", m_array_delay_exp_axiom); - p.register_bool_param("ARRAY_CG", m_array_cg); - p.register_bool_param("ARRAY_ALWAYS_PROP_UPWARD", m_array_always_prop_upward, + p.register_int_param("array_solver", 0, 3, reinterpret_cast(m_array_mode), "0 - no array, 1 - simple, 2 - model based, 3 - full"); + p.register_bool_param("array_weak", m_array_weak); + p.register_bool_param("array_extensional", m_array_extensional); + p.register_unsigned_param("array_laziness", m_array_laziness); + p.register_bool_param("array_delay_exp_axiom", m_array_delay_exp_axiom); + p.register_bool_param("array_cg", m_array_cg); + p.register_bool_param("array_always_prop_upward", m_array_always_prop_upward, "Disable the built-in filter upwards propagation"); - p.register_bool_param("ARRAY_LAZY_IEQ", m_array_lazy_ieq); - p.register_unsigned_param("ARRAY_LAZY_IEQ_DELAY", m_array_lazy_ieq_delay); - p.register_bool_param("ARRAY_CANONIZE", m_array_canonize_simplify, + p.register_bool_param("array_lazy_ieq", m_array_lazy_ieq); + p.register_unsigned_param("array_lazy_ieq_delay", m_array_lazy_ieq_delay); + p.register_bool_param("array_canonize", m_array_canonize_simplify, "Normalize arrays into normal form during simplification"); } }; diff --git a/src/front_end_params/theory_bv_params.h b/src/front_end_params/theory_bv_params.h index 38e1e263f..6bf5ac868 100644 --- a/src/front_end_params/theory_bv_params.h +++ b/src/front_end_params/theory_bv_params.h @@ -41,12 +41,12 @@ struct theory_bv_params { m_bv_blast_max_size(INT_MAX), m_bv_enable_int2bv2int(false) {} void register_params(ini_params & p) { - p.register_int_param("BV_SOLVER", 0, 2, reinterpret_cast(m_bv_mode), "0 - no bv, 1 - simple"); - p.register_unsigned_param("BV_BLAST_MAX_SIZE", m_bv_blast_max_size, "Maximal size for bit-vectors to blast"); - p.register_bool_param("BV_REFLECT", m_bv_reflect); - p.register_bool_param("BV_LAZY_LE", m_bv_lazy_le); - p.register_bool_param("BV_CC", m_bv_cc, "enable congruence closure for BV operators"); - p.register_bool_param("BV_ENABLE_INT2BV_PROPAGATION", m_bv_enable_int2bv2int, + p.register_int_param("bv_solver", 0, 2, reinterpret_cast(m_bv_mode), "0 - no bv, 1 - simple"); + p.register_unsigned_param("bv_blast_max_size", m_bv_blast_max_size, "Maximal size for bit-vectors to blast"); + p.register_bool_param("bv_reflect", m_bv_reflect); + p.register_bool_param("bv_lazy_le", m_bv_lazy_le); + p.register_bool_param("bv_cc", m_bv_cc, "enable congruence closure for BV operators"); + p.register_bool_param("bv_enable_int2bv_propagation", m_bv_enable_int2bv2int, "enable full (potentially expensive) propagation for int2bv and bv2int"); } }; diff --git a/src/front_end_params/theory_datatype_params.h b/src/front_end_params/theory_datatype_params.h index 000c4da07..33b2c1814 100644 --- a/src/front_end_params/theory_datatype_params.h +++ b/src/front_end_params/theory_datatype_params.h @@ -29,7 +29,7 @@ struct theory_datatype_params { } void register_params(ini_params & p) { - p.register_unsigned_param("DT_LAZY_SPLITS", m_dt_lazy_splits, "How lazy datatype splits are performed: 0- eager, 1- lazy for infinite types, 2- lazy"); + p.register_unsigned_param("dt_lazy_splits", m_dt_lazy_splits, "How lazy datatype splits are performed: 0- eager, 1- lazy for infinite types, 2- lazy"); } }; diff --git a/src/math/polynomial/algebraic_numbers.cpp b/src/math/polynomial/algebraic_numbers.cpp index f7de4054c..c35e0d368 100644 --- a/src/math/polynomial/algebraic_numbers.cpp +++ b/src/math/polynomial/algebraic_numbers.cpp @@ -57,12 +57,12 @@ namespace algebraic_numbers { typedef upolynomial::factors factors; void manager::get_param_descrs(param_descrs & r) { - r.insert(":algebraic-zero-accuracy", CPK_UINT, "(default: 0) one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)."); - r.insert(":algebraic-min-mag", CPK_UINT, "(default: 16) Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16"); - r.insert(":algebraic-factor", CPK_BOOL, "(default: true) use polynomial factorization to simplify polynomials representing algebraic numbers."); - r.insert(":algebraic-factor-max-prime", CPK_UINT, "(default: 31), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); - r.insert(":algebraic-factor-num-primes", CPK_UINT, "(default: 1), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); - r.insert(":algebraic-factor-search-size", CPK_UINT, "(default: 5000), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); + r.insert("zero_accuracy", CPK_UINT, "(default: 0) one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)."); + r.insert("min_mag", CPK_UINT, "(default: 16) Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16"); + r.insert("factor", CPK_BOOL, "(default: true) use polynomial factorization to simplify polynomials representing algebraic numbers."); + r.insert("factor_max_prime", CPK_UINT, "(default: 31), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); + r.insert("factor_num_primes", CPK_UINT, "(default: 1), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); + r.insert("factor_search_size", CPK_UINT, "(default: 5000), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); } struct manager::imp { @@ -157,12 +157,12 @@ namespace algebraic_numbers { } void updt_params(params_ref const & p) { - m_min_magnitude = -static_cast(p.get_uint(":algebraic-min-mag", 16)); - m_factor = p.get_bool(":algebraic-factor", true); // use polynomial factorization - m_factor_params.m_max_p = p.get_uint(":algebraic-factor-max-prime", 31); - m_factor_params.m_p_trials = p.get_uint(":algebraic-factor-num-primes", 1); - m_factor_params.m_max_search_size = p.get_uint(":algebraic-factor-max-search-size", 5000); - m_zero_accuracy = -static_cast(p.get_uint(":algebraic-zero-accuracy", 0)); + m_min_magnitude = -static_cast(p.get_uint("min_mag", 16)); + m_factor = p.get_bool("factor", true); // use polynomial factorization + m_factor_params.m_max_p = p.get_uint("factor_max_prime", 31); + m_factor_params.m_p_trials = p.get_uint("factor_num_primes", 1); + m_factor_params.m_max_search_size = p.get_uint("factor_max_search_size", 5000); + m_zero_accuracy = -static_cast(p.get_uint("zero_accuracy", 0)); } unsynch_mpq_manager & qm() { diff --git a/src/math/polynomial/algebraic_numbers.h b/src/math/polynomial/algebraic_numbers.h index 4735a875b..0db3ee68c 100644 --- a/src/math/polynomial/algebraic_numbers.h +++ b/src/math/polynomial/algebraic_numbers.h @@ -60,6 +60,9 @@ namespace algebraic_numbers { manager(unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0); ~manager(); + /* + REG_MODULE_PARAMS('algebraic', 'algebraic_numbers::manager::get_param_descrs') + */ static void get_param_descrs(param_descrs & r); static void collect_param_descrs(param_descrs & r) { get_param_descrs(r); } diff --git a/src/math/polynomial/polynomial.cpp b/src/math/polynomial/polynomial.cpp index 1b5c7965f..4e14c5661 100644 --- a/src/math/polynomial/polynomial.cpp +++ b/src/math/polynomial/polynomial.cpp @@ -50,15 +50,15 @@ namespace polynomial { } void factor_params::updt_params(params_ref const & p) { - m_max_p = p.get_uint(":factor-max-prime", UINT_MAX); - m_p_trials = p.get_uint(":factor-num-primes", 1); - m_max_search_size = p.get_uint(":factor-max-search-size", UINT_MAX); + m_max_p = p.get_uint("max_prime", UINT_MAX); + m_p_trials = p.get_uint("num_primes", 1); + m_max_search_size = p.get_uint("max_search_size", UINT_MAX); } void factor_params::get_param_descrs(param_descrs & r) { - r.insert(":factor-max-search-size", CPK_UINT, "(default: infty) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); - r.insert(":factor-max-prime", CPK_UINT, "(default: infty) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); - r.insert(":factor-num-primes", CPK_UINT, "(default: 1) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); + r.insert("max_search_size", CPK_UINT, "(default: infty) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); + r.insert("max_prime", CPK_UINT, "(default: infty) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); + r.insert("num_primes", CPK_UINT, "(default: 1) Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); } typedef ptr_vector monomial_vector; diff --git a/src/math/polynomial/polynomial.h b/src/math/polynomial/polynomial.h index f6370e5fa..7cefe6f56 100644 --- a/src/math/polynomial/polynomial.h +++ b/src/math/polynomial/polynomial.h @@ -90,6 +90,9 @@ namespace polynomial { factor_params(); factor_params(unsigned max_p, unsigned p_trials, unsigned max_search_size); void updt_params(params_ref const & p); + /* + REG_MODULE_PARAMS('factor', polynomial::factor_params::get_param_descrs') + */ static void get_param_descrs(param_descrs & r); }; diff --git a/src/math/subpaving/subpaving_t_def.h b/src/math/subpaving/subpaving_t_def.h index 7c80de75c..c215ddf98 100644 --- a/src/math/subpaving/subpaving_t_def.h +++ b/src/math/subpaving/subpaving_t_def.h @@ -474,7 +474,7 @@ void context_t::del(interval & a) { template void context_t::updt_params(params_ref const & p) { - unsigned epsilon = p.get_uint(":epsilon", 20); + unsigned epsilon = p.get_uint("epsilon", 20); if (epsilon != 0) { nm().set(m_epsilon, static_cast(epsilon)); nm().inv(m_epsilon); @@ -485,18 +485,18 @@ void context_t::updt_params(params_ref const & p) { m_zero_epsilon = true; } - unsigned max_power = p.get_uint(":max-bound", 10); + unsigned max_power = p.get_uint("max_bound", 10); nm().set(m_max_bound, 10); nm().power(m_max_bound, max_power, m_max_bound); nm().set(m_minus_max_bound, m_max_bound); nm().neg(m_minus_max_bound); - m_max_depth = p.get_uint(":max-depth", 128); - m_max_nodes = p.get_uint(":max-nodes", 8192); + m_max_depth = p.get_uint("max_depth", 128); + m_max_nodes = p.get_uint("max_nodes", 8192); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); - unsigned prec = p.get_uint(":nth-root-precision", 8192); + unsigned prec = p.get_uint("nth_root_precision", 8192); if (prec == 0) prec = 1; nm().set(m_nth_root_prec, static_cast(prec)); @@ -505,20 +505,20 @@ void context_t::updt_params(params_ref const & p) { template void context_t::collect_param_descrs(param_descrs & d) { - d.insert(":max-nodes", CPK_UINT, "(default: 8192) maximum number of nodes in the subpaving tree."); - d.insert(":max-depth", CPK_UINT, "(default: 128) maximum depth of the subpaving tree."); - d.insert(":epsilon", CPK_UINT, "(default: 20) value k s.t. a new lower (upper) bound for x is propagated only new-lower(x) > lower(k) + 1/k * max(min(upper(x) - lower(x), |lower|), 1) (new-upper(x) < upper(x) - 1/k * max(min(upper(x) - lower(x), |lower|), 1)). If k = 0, then this restriction is ignored."); - d.insert(":max-bound", CPK_UINT, "(default 10) value k s.t. a new upper (lower) bound for x is propagated only if upper(x) > -10^k or lower(x) = -oo (lower(x) < 10^k or upper(x) = oo)"); - d.insert(":nth-root-precision", CPK_UINT, "(default 8192) value k s.t. 1/k is the precision for computing the nth root in the subpaving module."); + d.insert("max_nodes", CPK_UINT, "(default: 8192) maximum number of nodes in the subpaving tree."); + d.insert("max_depth", CPK_UINT, "(default: 128) maximum depth of the subpaving tree."); + d.insert("epsilon", CPK_UINT, "(default: 20) value k s.t. a new lower (upper) bound for x is propagated only new-lower(x) > lower(k) + 1/k * max(min(upper(x) - lower(x), |lower|), 1) (new-upper(x) < upper(x) - 1/k * max(min(upper(x) - lower(x), |lower|), 1)). If k = 0, then this restriction is ignored."); + d.insert("max_bound", CPK_UINT, "(default 10) value k s.t. a new upper (lower) bound for x is propagated only if upper(x) > -10^k or lower(x) = -oo (lower(x) < 10^k or upper(x) = oo)"); + d.insert("nth_root_precision", CPK_UINT, "(default 8192) value k s.t. 1/k is the precision for computing the nth root in the subpaving module."); } template void context_t::display_params(std::ostream & out) const { - out << ":max-nodes " << m_max_nodes << "\n"; - out << ":max-depth " << m_max_depth << "\n"; - out << ":epsilon " << nm().to_rational_string(m_epsilon) << "\n"; - out << ":max-bound " << nm().to_rational_string(m_max_bound) << "\n"; - out << ":max-memory " << m_max_memory << "\n"; + out << "max_nodes " << m_max_nodes << "\n"; + out << "max_depth " << m_max_depth << "\n"; + out << "epsilon " << nm().to_rational_string(m_epsilon) << "\n"; + out << "max_bound " << nm().to_rational_string(m_max_bound) << "\n"; + out << "max_memory " << m_max_memory << "\n"; } template diff --git a/src/math/subpaving/tactic/subpaving_tactic.cpp b/src/math/subpaving/tactic/subpaving_tactic.cpp index 7bbff4b0b..d03bacebb 100644 --- a/src/math/subpaving/tactic/subpaving_tactic.cpp +++ b/src/math/subpaving/tactic/subpaving_tactic.cpp @@ -81,14 +81,14 @@ class subpaving_tactic : public tactic { void collect_param_descrs(param_descrs & r) { m_ctx->collect_param_descrs(r); // #ifndef _EXTERNAL_RELEASE - r.insert(":numeral", CPK_SYMBOL, "(default: mpq) options: mpq, mpf, hwf, mpff, mpfx."); - r.insert(":print-nodes", CPK_BOOL, "(default: false) display subpaving tree leaves."); + r.insert("numeral", CPK_SYMBOL, "(default: mpq) options: mpq, mpf, hwf, mpff, mpfx."); + r.insert("print_nodes", CPK_BOOL, "(default: false) display subpaving tree leaves."); // #endif } void updt_params(params_ref const & p) { - m_display = p.get_bool(":print-nodes", false); - symbol engine = p.get_sym(":numeral", symbol("mpq")); + m_display = p.get_bool("print_nodes", false); + symbol engine = p.get_sym("numeral", symbol("mpq")); engine_kind new_kind; if (engine == "mpq") new_kind = MPQ; @@ -293,16 +293,16 @@ tactic * mk_subpaving_tactic_core(ast_manager & m, params_ref const & p) { tactic * mk_subpaving_tactic(ast_manager & m, params_ref const & p) { params_ref simp_p = p; - simp_p.set_bool(":arith-lhs", true); - simp_p.set_bool(":expand-power", true); - simp_p.set_uint(":max-power", UINT_MAX); - simp_p.set_bool(":som", true); - simp_p.set_bool(":eq2ineq", true); - simp_p.set_bool(":elim-and", true); - simp_p.set_bool(":blast-distinct", true); + simp_p.set_bool("arith_lhs", true); + simp_p.set_bool("expand_power", true); + simp_p.set_uint("max_power", UINT_MAX); + simp_p.set_bool("som", true); + simp_p.set_bool("eq2ineq", true); + simp_p.set_bool("elim_and", true); + simp_p.set_bool("blast_distinct", true); params_ref simp2_p = p; - simp2_p.set_bool(":mul-to-power", true); + simp2_p.set_bool("mul_to_power", true); return and_then(using_params(mk_simplify_tactic(m, p), simp_p), diff --git a/src/model/model_evaluator.cpp b/src/model/model_evaluator.cpp index 258590121..beed0061e 100644 --- a/src/model/model_evaluator.cpp +++ b/src/model/model_evaluator.cpp @@ -60,10 +60,10 @@ struct evaluator_cfg : public default_rewriter_cfg { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_model_completion = p.get_bool(":model-completion", false); - m_cache = p.get_bool(":cache", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_model_completion = p.get_bool("model_completion", false); + m_cache = p.get_bool("cache", true); } ast_manager & m() const { return m_model.get_manager(); } @@ -232,8 +232,8 @@ void model_evaluator::updt_params(params_ref const & p) { void model_evaluator::get_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":model-completion", CPK_BOOL, "(default: false) assigns an interpretation to symbols that are not intepreted by the model."); - r.insert(":cache", CPK_BOOL, "(default: true) cache intermediate results."); + r.insert("model_completion", CPK_BOOL, "(default: false) assigns an interpretation to symbols that are not intepreted by the model."); + r.insert("cache", CPK_BOOL, "(default: true) cache intermediate results."); } void model_evaluator::set_model_completion(bool f) { diff --git a/src/muz_qe/datalog_parser.cpp b/src/muz_qe/datalog_parser.cpp index f527bb25a..a1bfc629d 100644 --- a/src/muz_qe/datalog_parser.cpp +++ b/src/muz_qe/datalog_parser.cpp @@ -1162,7 +1162,7 @@ public: : dparser(ctx, ctx.get_manager()), m_bool_sort(ctx.get_manager()), m_short_sort(ctx.get_manager()), - m_use_map_names(ctx.get_params().get_bool(":use-map-names", true)) { + m_use_map_names(ctx.get_params().get_bool("use_map_names", true)) { } ~wpa_parser_impl() { reset_dealloc_values(m_sort_contents); diff --git a/src/muz_qe/dl_bmc_engine.cpp b/src/muz_qe/dl_bmc_engine.cpp index 02791bc6f..e88e04c5a 100644 --- a/src/muz_qe/dl_bmc_engine.cpp +++ b/src/muz_qe/dl_bmc_engine.cpp @@ -71,7 +71,7 @@ namespace datalog { m_ctx.set_output_predicate(m_query_pred); m_ctx.apply_default_transformation(mc, m_pc); - if (m_ctx.get_params().get_bool(":slice", true)) { + if (m_ctx.get_params().get_bool("slice", true)) { datalog::rule_transformer transformer(m_ctx); datalog::mk_slice* slice = alloc(datalog::mk_slice, m_ctx); transformer.register_plugin(slice); diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index e19b9fef8..28e699c7c 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -210,7 +210,7 @@ public: datalog::context& dlctx = m_dl_ctx->dlctx(); set_background(ctx); dlctx.updt_params(m_params); - unsigned timeout = m_params.get_uint(":timeout", UINT_MAX); + unsigned timeout = m_params.get_uint("timeout", UINT_MAX); cancel_eh eh(dlctx); lbool status = l_undef; { @@ -266,9 +266,9 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { m_dl_ctx->dlctx().collect_params(p); insert_timeout(p); - p.insert(":print-answer", CPK_BOOL, "(default: false) print answer instance(s) to query."); - p.insert(":print-certificate", CPK_BOOL, "(default: false) print certificate for reachability or non-reachability."); - p.insert(":print-statistics", CPK_BOOL, "(default: false) print statistics."); + p.insert("print_answer", CPK_BOOL, "(default: false) print answer instance(s) to query."); + p.insert("print_certificate", CPK_BOOL, "(default: false) print certificate for reachability or non-reachability."); + p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } @@ -283,7 +283,7 @@ private: } void print_answer(cmd_context& ctx) { - if (m_params.get_bool(":print-answer", false)) { + if (m_params.get_bool("print_answer", false)) { datalog::context& dlctx = m_dl_ctx->dlctx(); ast_manager& m = ctx.m(); expr_ref query_result(dlctx.get_answer_as_formula(), m); @@ -298,7 +298,7 @@ private: } void print_statistics(cmd_context& ctx) { - if (m_params.get_bool(":print-statistics", false)) { + if (m_params.get_bool("print_statistics", false)) { statistics st; datalog::context& dlctx = m_dl_ctx->dlctx(); unsigned long long max_mem = memory::get_max_used_memory(); @@ -312,7 +312,7 @@ private: } void print_certificate(cmd_context& ctx) { - if (m_params.get_bool(":print-certificate", false)) { + if (m_params.get_bool("print_certificate", false)) { datalog::context& dlctx = m_dl_ctx->dlctx(); if (!dlctx.display_certificate(ctx.regular_stream())) { throw cmd_exception("certificates are not supported for the selected engine"); diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index ec78f8e92..9fbc93248 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -960,55 +960,55 @@ namespace datalog { } void context::collect_params(param_descrs& p) { - p.insert(":engine", CPK_SYMBOL, "(default: automatically configured) select 'datalog', PDR 'pdr' engine."); - p.insert(":bit-blast", CPK_BOOL, "(default: false) bit-blast bit-vectors (for PDR engine)."); - p.insert(":default-table", CPK_SYMBOL, "default table implementation: 'sparse' (default), 'hashtable', 'bitvector', 'interval'"); - p.insert(":default-relation", CPK_SYMBOL, "default relation implementation: 'external_relation', 'pentagon'"); + p.insert("engine", CPK_SYMBOL, "(default: automatically configured) select 'datalog', PDR 'pdr' engine."); + p.insert("bit_blast", CPK_BOOL, "(default: false) bit-blast bit-vectors (for PDR engine)."); + p.insert("default_table", CPK_SYMBOL, "default table implementation: 'sparse' (default), 'hashtable', 'bitvector', 'interval'"); + p.insert("default_relation", CPK_SYMBOL, "default relation implementation: 'external_relation', 'pentagon'"); - p.insert(":generate-explanations", CPK_BOOL, "if true, signature of relations will be extended to contain explanations for facts"); - p.insert(":explanations-on-relation-level", CPK_BOOL, "if true, explanations are generated as history of each relation, " - "rather than per fact (:generate-explanations must be set to true for this option to have any effect)"); + p.insert("generate_explanations", CPK_BOOL, "if true, signature of relations will be extended to contain explanations for facts"); + p.insert("explanations_on_relation_level", CPK_BOOL, "if true, explanations are generated as history of each relation, " + "rather than per fact (generate_explanations must be set to true for this option to have any effect)"); - p.insert(":magic-sets-for-queries", CPK_BOOL, "magic set transformation will be used for queries"); - p.insert(":unbound-compressor", CPK_BOOL, "auxiliary relations will be introduced to avoid unbound variables in rule heads"); - p.insert(":similarity-compressor", CPK_BOOL, "rules that differ only in values of constants will be merged into a single rule"); - p.insert(":similarity-compressor-threshold", CPK_UINT, "if :dl-similiaryt-compressor is on, this value determines how many " + p.insert("magic_sets_for_queries", CPK_BOOL, "magic set transformation will be used for queries"); + p.insert("unbound_compressor", CPK_BOOL, "auxiliary relations will be introduced to avoid unbound variables in rule heads"); + p.insert("similarity_compressor", CPK_BOOL, "rules that differ only in values of constants will be merged into a single rule"); + p.insert("similarity_compressor_threshold", CPK_UINT, "if dl_similiaryt_compressor is on, this value determines how many " "similar rules there must be in order for them to be merged"); - p.insert(":all-or-nothing-deltas", CPK_BOOL, "compile rules so that it is enough for the delta relation in union and widening " + p.insert("all_or_nothing_deltas", CPK_BOOL, "compile rules so that it is enough for the delta relation in union and widening " "operations to determine only whether the updated relation was modified or not"); - p.insert(":compile-with-widening", CPK_BOOL, "widening will be used to compile recursive rules"); - p.insert(":eager-emptiness-checking", CPK_BOOL, "emptiness of affected relations will be checked after each instruction, " + p.insert("compile_with_widening", CPK_BOOL, "widening will be used to compile recursive rules"); + p.insert("eager_emptiness_checking", CPK_BOOL, "emptiness of affected relations will be checked after each instruction, " "so that we may ommit unnecessary instructions"); - p.insert(":default-table-checked", CPK_BOOL, - "if true, the detault table will be :default-table inside a wrapper that checks that " - "its results are the same as of :default-table-checker table"); + p.insert("default_table_checked", CPK_BOOL, + "if true, the detault table will be default_table inside a wrapper that checks that " + "its results are the same as of default_table_checker table"); - p.insert(":initial-restart-timeout", CPK_UINT, "length of saturation run before the first restart (in ms); zero means no restarts"); - p.insert(":restart-timeout-quotient", CPK_UINT, "restart timeout will be multiplied by this number after each restart"); - p.insert(":use-map-names", CPK_BOOL, "use names from map files when displaying tuples"); + p.insert("initial_restart_timeout", CPK_UINT, "length of saturation run before the first restart (in ms); zero means no restarts"); + p.insert("restart_timeout_quotient", CPK_UINT, "restart timeout will be multiplied by this number after each restart"); + p.insert("use_map_names", CPK_BOOL, "use names from map files when displaying tuples"); - p.insert(":output-profile", CPK_BOOL, "determines whether profile informations should be output when outputting Datalog rules or instructions"); - p.insert(":output-tuples", CPK_BOOL, "determines whether tuples for output predicates should be output"); - p.insert(":profile-timeout-milliseconds", CPK_UINT, "instructions and rules that took less than the threshold will not be printed when printed the instruction/rule list"); + p.insert("output_profile", CPK_BOOL, "determines whether profile informations should be output when outputting Datalog rules or instructions"); + p.insert("output_tuples", CPK_BOOL, "determines whether tuples for output predicates should be output"); + p.insert("profile_timeout_milliseconds", CPK_UINT, "instructions and rules that took less than the threshold will not be printed when printed the instruction/rule list"); - p.insert(":print-with-fixedpoint-extensions", CPK_BOOL, "(default true) use SMT-LIB2 fixedpoint extensions, instead of pure SMT2, when printing rules"); - p.insert(":print-low-level-smt2", CPK_BOOL, "(default false) use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"); + p.insert("print_with_fixedpoint_extensions", CPK_BOOL, "(default true) use SMT-LIB2 fixedpoint extensions, instead of pure SMT2, when printing rules"); + p.insert("print_low_level_smt2", CPK_BOOL, "(default false) use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"); PRIVATE_PARAMS( - p.insert(":dbg-fpr-nonempty-relation-signature", CPK_BOOL, + p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL, "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " "by putting in half of the table columns, if it would have been empty otherwise"); - p.insert(":smt-relation-ground-recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); + p.insert("smt_relation_ground_recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); ); - p.insert(":fix-unbound-vars", CPK_BOOL, "fix unbound variables in tail"); - p.insert(":default-table-checker", CPK_SYMBOL, "see :default-table-checked"); - p.insert(":inline-linear", CPK_BOOL, "(default true) try linear inlining method"); - p.insert(":inline-eager", CPK_BOOL, "(default true) try eager inlining of rules"); - PRIVATE_PARAMS(p.insert(":inline-linear-branch", CPK_BOOL, "try linear inlining method with potential expansion");); + p.insert("fix_unbound_vars", CPK_BOOL, "fix unbound variables in tail"); + p.insert("default_table_checker", CPK_SYMBOL, "see default_table_checked"); + p.insert("inline_linear", CPK_BOOL, "(default true) try linear inlining method"); + p.insert("inline_eager", CPK_BOOL, "(default true) try eager inlining of rules"); + PRIVATE_PARAMS(p.insert("inline_linear_branch", CPK_BOOL, "try linear inlining method with potential expansion");); pdr::dl_interface::collect_params(p); bmc::collect_params(p); @@ -1189,7 +1189,7 @@ namespace datalog { }; void context::configure_engine() { - symbol e = m_params.get_sym(":engine", symbol()); + symbol e = m_params.get_sym("engine", symbol()); if (e == symbol("datalog")) { m_engine = DATALOG_ENGINE; @@ -1650,8 +1650,8 @@ namespace datalog { expr_ref fml(m); expr_ref_vector rules(m); svector names; - bool use_fixedpoint_extensions = m_params.get_bool(":print-with-fixedpoint-extensions", true); - bool print_low_level = m_params.get_bool(":print-low-level-smt2", false); + bool use_fixedpoint_extensions = m_params.get_bool("print_with_fixedpoint_extensions", true); + bool print_low_level = m_params.get_bool("print_low_level_smt2", false); #define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env, params); diff --git a/src/muz_qe/dl_context.h b/src/muz_qe/dl_context.h index 229bbc474..fe94dd3cc 100644 --- a/src/muz_qe/dl_context.h +++ b/src/muz_qe/dl_context.h @@ -156,25 +156,25 @@ namespace datalog { var_subst & get_var_subst() { return m_var_subst; } dl_decl_util & get_decl_util() { return m_decl_util; } - bool output_profile() const { return m_params.get_bool(":output-profile", false); } - bool fix_unbound_vars() const { return m_params.get_bool(":fix-unbound-vars", false); } - symbol default_table() const { return m_params.get_sym(":default-table", symbol("sparse")); } - symbol default_relation() const { return m_params.get_sym(":default-relation", external_relation_plugin::get_name()); } - symbol default_table_checker() const { return m_params.get_sym(":default-table-checker", symbol("sparse")); } - bool default_table_checked() const { return m_params.get_bool(":default-table-checked", false); } - bool dbg_fpr_nonempty_relation_signature() const { return m_params.get_bool(":dbg-fpr-nonempty-relation-signatures", false); } - unsigned dl_profile_milliseconds_threshold() const { return m_params.get_uint(":profile-milliseconds-threshold", 0); } - bool all_or_nothing_deltas() const { return m_params.get_bool(":all-or-nothing-deltas", false); } - bool compile_with_widening() const { return m_params.get_bool(":compile-with-widening", false); } - bool unbound_compressor() const { return m_params.get_bool(":unbound-compressor", true); } - bool similarity_compressor() const { return m_params.get_bool(":similarity-compressor", true); } - unsigned similarity_compressor_threshold() const { return m_params.get_uint(":similarity-compressor-threshold", 11); } + bool output_profile() const { return m_params.get_bool("output_profile", false); } + bool fix_unbound_vars() const { return m_params.get_bool("fix_unbound_vars", false); } + symbol default_table() const { return m_params.get_sym("default_table", symbol("sparse")); } + symbol default_relation() const { return m_params.get_sym("default_relation", external_relation_plugin::get_name()); } + symbol default_table_checker() const { return m_params.get_sym("default_table_checker", symbol("sparse")); } + bool default_table_checked() const { return m_params.get_bool("default_table_checked", false); } + bool dbg_fpr_nonempty_relation_signature() const { return m_params.get_bool("dbg_fpr_nonempty_relation_signatures", false); } + unsigned dl_profile_milliseconds_threshold() const { return m_params.get_uint("profile_milliseconds_threshold", 0); } + bool all_or_nothing_deltas() const { return m_params.get_bool("all_or_nothing_deltas", false); } + bool compile_with_widening() const { return m_params.get_bool("compile_with_widening", false); } + bool unbound_compressor() const { return m_params.get_bool("unbound_compressor", true); } + bool similarity_compressor() const { return m_params.get_bool("similarity_compressor", true); } + unsigned similarity_compressor_threshold() const { return m_params.get_uint("similarity_compressor_threshold", 11); } unsigned soft_timeout() const { return m_fparams.m_soft_timeout; } - unsigned initial_restart_timeout() const { return m_params.get_uint(":initial-restart-timeout", 0); } - bool generate_explanations() const { return m_params.get_bool(":generate-explanations", false); } - bool explanations_on_relation_level() const { return m_params.get_bool(":explanations-on-relation-level", false); } - bool magic_sets_for_queries() const { return m_params.get_bool(":magic-sets-for-queries", false); } - bool eager_emptiness_checking() const { return m_params.get_bool(":eager-emptiness-checking", true); } + unsigned initial_restart_timeout() const { return m_params.get_uint("initial_restart_timeout", 0); } + bool generate_explanations() const { return m_params.get_bool("generate_explanations", false); } + bool explanations_on_relation_level() const { return m_params.get_bool("explanations_on_relation_level", false); } + bool magic_sets_for_queries() const { return m_params.get_bool("magic_sets_for_queries", false); } + bool eager_emptiness_checking() const { return m_params.get_bool("eager_emptiness_checking", true); } void register_finite_sort(sort * s, sort_kind k); diff --git a/src/muz_qe/dl_mk_array_blast.cpp b/src/muz_qe/dl_mk_array_blast.cpp index d63528db3..a5259ba8a 100644 --- a/src/muz_qe/dl_mk_array_blast.cpp +++ b/src/muz_qe/dl_mk_array_blast.cpp @@ -30,7 +30,7 @@ namespace datalog { a(m), rm(ctx.get_rule_manager()), m_rewriter(m, m_params){ - m_params.set_bool(":expand-select-store",true); + m_params.set_bool("expand_select_store",true); m_rewriter.updt_params(m_params); } diff --git a/src/muz_qe/dl_mk_bit_blast.cpp b/src/muz_qe/dl_mk_bit_blast.cpp index 9c503360c..c523315d9 100644 --- a/src/muz_qe/dl_mk_bit_blast.cpp +++ b/src/muz_qe/dl_mk_bit_blast.cpp @@ -165,14 +165,14 @@ namespace datalog { m_rules(ctx.get_rule_manager()), m_blaster(ctx.get_manager(), m_params), m_rewriter(ctx.get_manager(), ctx, m_rules) { - m_params.set_bool(":blast-full", true); - m_params.set_bool(":blast-quant", true); + m_params.set_bool("blast_full", true); + m_params.set_bool("blast_quant", true); m_blaster.updt_params(m_params); } rule_set * operator()(rule_set const & source, model_converter_ref& mc, proof_converter_ref& pc) { // TODO mc, pc - if (!m_context.get_params().get_bool(":bit-blast", false)) { + if (!m_context.get_params().get_bool("bit_blast", false)) { return 0; } if (m_context.get_engine() != PDR_ENGINE) { diff --git a/src/muz_qe/dl_mk_rule_inliner.cpp b/src/muz_qe/dl_mk_rule_inliner.cpp index 1d3d62020..cfe532fb6 100644 --- a/src/muz_qe/dl_mk_rule_inliner.cpp +++ b/src/muz_qe/dl_mk_rule_inliner.cpp @@ -751,7 +751,7 @@ namespace datalog { valid.resize(sz, true); params_ref const& params = m_context.get_params(); - bool allow_branching = params.get_bool(":inline-linear-branch", false); + bool allow_branching = params.get_bool("inline_linear_branch", false); for (unsigned i = 0; i < sz; ++i) { @@ -867,7 +867,7 @@ namespace datalog { scoped_ptr res = alloc(rule_set, m_context); - if (params.get_bool(":inline-eager", true)) { + if (params.get_bool("inline_eager", true)) { TRACE("dl", source.display(tout << "before eager inlining\n");); plan_inlining(source); something_done = transform_rules(source, *res); @@ -879,7 +879,7 @@ namespace datalog { TRACE("dl", res->display(tout << "after eager inlining\n");); } - if (params.get_bool(":inline-linear", true) && inline_linear(res)) { + if (params.get_bool("inline_linear", true) && inline_linear(res)) { something_done = true; } diff --git a/src/muz_qe/dl_smt_relation.cpp b/src/muz_qe/dl_smt_relation.cpp index 55d3f7199..348c63e1c 100644 --- a/src/muz_qe/dl_smt_relation.cpp +++ b/src/muz_qe/dl_smt_relation.cpp @@ -533,7 +533,7 @@ namespace datalog { IF_VERBOSE(10, verbose_stream() << "Computing delta...\n"; ); - if (params.get_bool(":smt-relation-ground-recursive", false)) { + if (params.get_bool("smt_relation_ground_recursive", false)) { // ensure R is ground. Simplify S using assumption not R if (!is_ground(rInst)) { proof_ref pr(m); diff --git a/src/muz_qe/horn_tactic.cpp b/src/muz_qe/horn_tactic.cpp index 59e9e6fec..dd6a2c2d3 100644 --- a/src/muz_qe/horn_tactic.cpp +++ b/src/muz_qe/horn_tactic.cpp @@ -161,9 +161,9 @@ class horn_tactic : public tactic { bool produce_proofs = g->proofs_enabled(); if (produce_proofs) { - if (!m_ctx.get_params().get_bool(":generate-proof-trace", true)) { + if (!m_ctx.get_params().get_bool("generate_proof_trace", true)) { params_ref params = m_ctx.get_params(); - params.set_bool(":generate-proof-trace", true); + params.set_bool("generate_proof_trace", true); updt_params(params); } } diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index 2f43d518c..3b3ee61a1 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1098,7 +1098,7 @@ namespace pdr { m_pm(m_fparams, m_params, m), m_query_pred(m), m_query(0), - m_search(m_params.get_bool(":bfs-model-search", true)), + m_search(m_params.get_bool("bfs_model_search", true)), m_last_result(l_undef), m_inductive_lvl(0), m_cancel(false) @@ -1323,7 +1323,7 @@ namespace pdr { }; void context::validate() { - if (!m_params.get_bool(":validate-result", false)) { + if (!m_params.get_bool("validate_result", false)) { return; } switch(m_last_result) { @@ -1414,12 +1414,12 @@ namespace pdr { void context::init_core_generalizers(datalog::rule_set& rules) { reset_core_generalizers(); classifier_proc classify(m, rules); - bool use_mc = m_params.get_bool(":use-multicore-generalizer", false); + bool use_mc = m_params.get_bool("use_multicore_generalizer", false); if (use_mc) { m_core_generalizers.push_back(alloc(core_multi_generalizer, *this, 0)); } - if (m_params.get_bool(":use-farkas", true) && !classify.is_bool()) { - if (m_params.get_bool(":inline-proof-mode", true)) { + if (m_params.get_bool("use_farkas", true) && !classify.is_bool()) { + if (m_params.get_bool("inline_proof_mode", true)) { m.toggle_proof_mode(PGM_FINE); m_fparams.m_proof_mode = PGM_FINE; m_fparams.m_arith_bound_prop = BP_NONE; @@ -1435,13 +1435,13 @@ namespace pdr { m_core_generalizers.push_back(alloc(core_farkas_generalizer, *this, m, m_fparams)); } } - if (!use_mc && m_params.get_bool(":use-inductive-generalizer", true)) { + if (!use_mc && m_params.get_bool("use_inductive_generalizer", true)) { m_core_generalizers.push_back(alloc(core_bool_inductive_generalizer, *this, 0)); } - if (m_params.get_bool(":use-interpolants", false)) { + if (m_params.get_bool("use_interpolants", false)) { m_core_generalizers.push_back(alloc(core_interpolant_generalizer, *this)); } - if (m_params.get_bool(":inductive-reachability-check", false)) { + if (m_params.get_bool("inductive_reachability_check", false)) { m_core_generalizers.push_back(alloc(core_induction_generalizer, *this)); } } @@ -1553,7 +1553,7 @@ namespace pdr { \brief Retrieve satisfying assignment with explanation. */ expr_ref context::mk_sat_answer() const { - if (m_params.get_bool(":generate-proof-trace", false)) { + if (m_params.get_bool("generate_proof_trace", false)) { proof_ref pr = get_proof(); return expr_ref(pr.get(), m); } @@ -1674,7 +1674,7 @@ namespace pdr { n.pt().add_property(ncore, uses_level?n.level():infty_level); } CASSERT("pdr",n.level() == 0 || check_invariant(n.level()-1)); - m_search.backtrack_level(!found_invariant && m_params.get_bool(":flexible-trace", false), n); + m_search.backtrack_level(!found_invariant && m_params.get_bool("flexible_trace", false), n); break; } case l_undef: { @@ -1696,7 +1696,7 @@ namespace pdr { } void context::propagate(unsigned max_prop_lvl) { - if (m_params.get_bool(":simplify-formulas-pre", false)) { + if (m_params.get_bool("simplify_formulas_pre", false)) { simplify_formulas(); } for (unsigned lvl = 0; lvl <= max_prop_lvl; lvl++) { @@ -1715,7 +1715,7 @@ namespace pdr { throw inductive_exception(); } } - if (m_params.get_bool(":simplify-formulas-post", false)) { + if (m_params.get_bool("simplify_formulas_post", false)) { simplify_formulas(); } } @@ -1763,7 +1763,7 @@ namespace pdr { */ void context::create_children(model_node& n) { SASSERT(n.level() > 0); - bool use_model_generalizer = m_params.get_bool(":use-model-generalizer", false); + bool use_model_generalizer = m_params.get_bool("use_model_generalizer", false); datalog::scoped_no_proof _sc(m); pred_transformer& pt = n.pt(); diff --git a/src/muz_qe/pdr_dl_interface.cpp b/src/muz_qe/pdr_dl_interface.cpp index b047aaae0..6cbc3b78d 100644 --- a/src/muz_qe/pdr_dl_interface.cpp +++ b/src/muz_qe/pdr_dl_interface.cpp @@ -108,13 +108,13 @@ lbool dl_interface::query(expr * query) { model_converter_ref mc = datalog::mk_skip_model_converter(); proof_converter_ref pc; - if (m_ctx.get_params().get_bool(":generate-proof-trace", false)) { + if (m_ctx.get_params().get_bool("generate_proof_trace", false)) { pc = datalog::mk_skip_proof_converter(); } m_ctx.set_output_predicate(query_pred); m_ctx.apply_default_transformation(mc, pc); - if (m_ctx.get_params().get_bool(":slice", true)) { + if (m_ctx.get_params().get_bool("slice", true)) { datalog::rule_transformer transformer(m_ctx); datalog::mk_slice* slice = alloc(datalog::mk_slice, m_ctx); transformer.register_plugin(slice); @@ -133,10 +133,10 @@ lbool dl_interface::query(expr * query) { } } - if (m_ctx.get_params().get_uint(":unfold-rules",0) > 0) { - unsigned num_unfolds = m_ctx.get_params().get_uint(":unfold-rules", 0); + if (m_ctx.get_params().get_uint("unfold_rules",0) > 0) { + unsigned num_unfolds = m_ctx.get_params().get_uint("unfold_rules", 0); datalog::rule_transformer transformer1(m_ctx), transformer2(m_ctx); - if (m_ctx.get_params().get_uint(":coalesce-rules", false)) { + if (m_ctx.get_params().get_uint("coalesce_rules", false)) { transformer1.register_plugin(alloc(datalog::mk_coalesce, m_ctx)); m_ctx.transform_rules(transformer1, mc, pc); } @@ -198,7 +198,7 @@ expr_ref dl_interface::get_cover_delta(int level, func_decl* pred_orig) { } void dl_interface::add_cover(int level, func_decl* pred, expr* property) { - if (m_ctx.get_params().get_bool(":slice", true)) { + if (m_ctx.get_params().get_bool("slice", true)) { throw default_exception("Covers are incompatible with slicing. Disable slicing before using covers"); } m_context->add_cover(level, pred, property); @@ -248,28 +248,28 @@ proof_ref dl_interface::get_proof() { } void dl_interface::collect_params(param_descrs& p) { - p.insert(":bfs-model-search", CPK_BOOL, "PDR: (default true) use BFS strategy for expanding model search"); - p.insert(":use-farkas", CPK_BOOL, "PDR: (default true) use lemma generator based on Farkas (for linear real arithmetic)"); - p.insert(":generate-proof-trace", CPK_BOOL, "PDR: (default false) trace for 'sat' answer as proof object"); - p.insert(":inline-proofs", CPK_BOOL, "PDR: (default true) run PDR with proof mode turned on and extract " + p.insert("bfs_model_search", CPK_BOOL, "PDR: (default true) use BFS strategy for expanding model search"); + p.insert("use_farkas", CPK_BOOL, "PDR: (default true) use lemma generator based on Farkas (for linear real arithmetic)"); + p.insert("generate_proof_trace", CPK_BOOL, "PDR: (default false) trace for 'sat' answer as proof object"); + p.insert("inline_proofs", CPK_BOOL, "PDR: (default true) run PDR with proof mode turned on and extract " "Farkas coefficients directly (instead of creating a separate proof object when extracting coefficients)"); - p.insert(":flexible-trace", CPK_BOOL, "PDR: (default false) allow PDR generate long counter-examples " + p.insert("flexible_trace", CPK_BOOL, "PDR: (default false) allow PDR generate long counter-examples " "by extending candidate trace within search area"); - p.insert(":unfold-rules", CPK_UINT, "PDR: (default 0) unfold rules statically using iterative squarring"); - p.insert(":use-model-generalizer", CPK_BOOL, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"); - p.insert(":validate-result", CPK_BOOL, "PDR (default false) validate result (by proof checking or model checking)"); - PRIVATE_PARAMS(p.insert(":use-multicore-generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states");); - PRIVATE_PARAMS(p.insert(":use-inductive-generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening");); - PRIVATE_PARAMS(p.insert(":use-interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation");); - PRIVATE_PARAMS(p.insert(":dump-interpolants", CPK_BOOL, "PDR: (default false) display interpolants");); - PRIVATE_PARAMS(p.insert(":cache-mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search");); - PRIVATE_PARAMS(p.insert(":inductive-reachability-check", CPK_BOOL, + p.insert("unfold_rules", CPK_UINT, "PDR: (default 0) unfold rules statically using iterative squarring"); + p.insert("use_model_generalizer", CPK_BOOL, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"); + p.insert("validate_result", CPK_BOOL, "PDR (default false) validate result (by proof checking or model checking)"); + PRIVATE_PARAMS(p.insert("use_multicore_generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states");); + PRIVATE_PARAMS(p.insert("use_inductive_generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening");); + PRIVATE_PARAMS(p.insert("use_interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation");); + PRIVATE_PARAMS(p.insert("dump_interpolants", CPK_BOOL, "PDR: (default false) display interpolants");); + PRIVATE_PARAMS(p.insert("cache_mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search");); + PRIVATE_PARAMS(p.insert("inductive_reachability_check", CPK_BOOL, "PDR: (default false) assume negation of the cube on the previous level when " "checking for reachability (not only during cube weakening)");); - PRIVATE_PARAMS(p.insert(":max-num-contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create");); - PRIVATE_PARAMS(p.insert(":try-minimize-core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)");); - p.insert(":simplify-formulas-pre", CPK_BOOL, "PDR: (default false) simplify derived formulas before inductive propagation"); - p.insert(":simplify-formulas-post", CPK_BOOL, "PDR: (default false) simplify derived formulas after inductive propagation"); - p.insert(":slice", CPK_BOOL, "PDR: (default true) simplify clause set using slicing"); - p.insert(":coalesce-rules", CPK_BOOL, "BMC: (default false) coalesce rules"); + PRIVATE_PARAMS(p.insert("max_num_contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create");); + PRIVATE_PARAMS(p.insert("try_minimize_core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)");); + p.insert("simplify_formulas_pre", CPK_BOOL, "PDR: (default false) simplify derived formulas before inductive propagation"); + p.insert("simplify_formulas_post", CPK_BOOL, "PDR: (default false) simplify derived formulas after inductive propagation"); + p.insert("slice", CPK_BOOL, "PDR: (default true) simplify clause set using slicing"); + p.insert("coalesce_rules", CPK_BOOL, "BMC: (default false) coalesce rules"); } diff --git a/src/muz_qe/pdr_interpolant_provider.cpp b/src/muz_qe/pdr_interpolant_provider.cpp index 85655c737..bcea5cbc4 100644 --- a/src/muz_qe/pdr_interpolant_provider.cpp +++ b/src/muz_qe/pdr_interpolant_provider.cpp @@ -318,7 +318,7 @@ lbool interpolant_provider_impl::get_interpolant(expr * f1, expr * f2, expr_ref& throw default_exception("invalid interpolator output"); } res = *ait; - if (m_params.get_bool(":dump-interpolants", false)) { + if (m_params.get_bool("dump_interpolants", false)) { interpolant_provider::output_interpolant(m, f1, f2, res); } return l_true; diff --git a/src/muz_qe/pdr_prop_solver.cpp b/src/muz_qe/pdr_prop_solver.cpp index d70675d80..4fd036f48 100644 --- a/src/muz_qe/pdr_prop_solver.cpp +++ b/src/muz_qe/pdr_prop_solver.cpp @@ -212,7 +212,7 @@ namespace pdr { m(pm.get_manager()), m_pm(pm), m_name(name), - m_try_minimize_core(pm.get_params().get_bool(":try-minimize-core", false)), + m_try_minimize_core(pm.get_params().get_bool("try_minimize_core", false)), m_ctx(pm.mk_fresh()), m_pos_level_atoms(m), m_neg_level_atoms(m), diff --git a/src/muz_qe/pdr_reachable_cache.cpp b/src/muz_qe/pdr_reachable_cache.cpp index ed9926f85..f248f4d86 100644 --- a/src/muz_qe/pdr_reachable_cache.cpp +++ b/src/muz_qe/pdr_reachable_cache.cpp @@ -27,7 +27,7 @@ namespace pdr { m_ctx(0), m_ref_holder(m), m_disj_connector(m), - m_cache_mode((datalog::PDR_CACHE_MODE)params.get_uint(":cache-mode",0)) { + m_cache_mode((datalog::PDR_CACHE_MODE)params.get_uint("cache_mode",0)) { if (m_cache_mode == datalog::CONSTRAINT_CACHE) { m_ctx = pm.mk_fresh(); m_ctx->assert_expr(m_pm.get_background()); diff --git a/src/muz_qe/pdr_smt_context_manager.cpp b/src/muz_qe/pdr_smt_context_manager.cpp index d79192769..c9dcf7b4e 100644 --- a/src/muz_qe/pdr_smt_context_manager.cpp +++ b/src/muz_qe/pdr_smt_context_manager.cpp @@ -96,7 +96,7 @@ namespace pdr { smt_context_manager::smt_context_manager(front_end_params& fp, params_ref const& p, ast_manager& m): m_fparams(fp), m(m), - m_max_num_contexts(p.get_uint(":max-num-contexts", 500)), + m_max_num_contexts(p.get_uint("max_num_contexts", 500)), m_num_contexts(0), m_predicate_list(m) { } diff --git a/src/muz_qe/qe.cpp b/src/muz_qe/qe.cpp index a01500fe3..3b854b250 100644 --- a/src/muz_qe/qe.cpp +++ b/src/muz_qe/qe.cpp @@ -1340,7 +1340,7 @@ namespace qe { m_nnf(m, get_is_relevant(), get_mk_atom()) { params_ref params; - params.set_bool(":gcd-rounding", true); + params.set_bool("gcd_rounding", true); m_rewriter.updt_params(params); } @@ -2010,7 +2010,7 @@ namespace qe { } void updt_params(params_ref const& p) { - m_eliminate_variables_as_block = p.get_bool(":eliminate-variables-as-block", m_eliminate_variables_as_block); + 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) { @@ -2194,7 +2194,7 @@ namespace qe { } void expr_quant_elim::updt_params(params_ref const& p) { - bool r = p.get_bool(":use-neq-qe", m_use_new_qe); + bool r = p.get_bool("use_neq_qe", m_use_new_qe); if (r != m_use_new_qe) { dealloc(m_qe); m_qe = 0; @@ -2205,9 +2205,9 @@ namespace qe { } void expr_quant_elim::collect_param_descrs(param_descrs& r) { - r.insert(":eliminate-variables-as-block", CPK_BOOL, + r.insert("eliminate_variables_as_block", CPK_BOOL, "(default: true) eliminate variables as a block (true) or one at a time (false)"); - // r.insert(":use-new-qe", CPK_BOOL, "(default: true) invoke quantifier engine based on abstracted solver"); + // r.insert("use_new_qe", CPK_BOOL, "(default: true) invoke quantifier engine based on abstracted solver"); } void expr_quant_elim::init_qe() { diff --git a/src/muz_qe/qe_cmd.cpp b/src/muz_qe/qe_cmd.cpp index 218224c51..ef8d1c058 100644 --- a/src/muz_qe/qe_cmd.cpp +++ b/src/muz_qe/qe_cmd.cpp @@ -16,8 +16,8 @@ public: virtual void init_pdescrs(cmd_context & ctx, param_descrs & p) { insert_timeout(p); - p.insert(":print", CPK_BOOL, "(default: true) print the simplified term."); - p.insert(":print-statistics", CPK_BOOL, "(default: false) print statistics."); + p.insert("print", CPK_BOOL, "(default: true) print the simplified term."); + p.insert("print_statistics", CPK_BOOL, "(default: false) print statistics."); } virtual ~qe_cmd() { @@ -45,11 +45,11 @@ public: qe(m_target, result, pr); - if (m_params.get_bool(":print", true)) { + if (m_params.get_bool("print", true)) { ctx.display(ctx.regular_stream(), result); ctx.regular_stream() << std::endl; } - if (m_params.get_bool(":print-statistics", false)) { + if (m_params.get_bool("print_statistics", false)) { statistics st; qe.collect_statistics(st); st.display(ctx.regular_stream()); diff --git a/src/muz_qe/qe_lite.cpp b/src/muz_qe/qe_lite.cpp index 6baa7ad80..9c9f54830 100644 --- a/src/muz_qe/qe_lite.cpp +++ b/src/muz_qe/qe_lite.cpp @@ -1048,13 +1048,13 @@ namespace fm { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_fm_real_only = p.get_bool(":fm-real-only", true); - m_fm_limit = p.get_uint(":fm-limit", 5000000); - m_fm_cutoff1 = p.get_uint(":fm-cutoff1", 8); - m_fm_cutoff2 = p.get_uint(":fm-cutoff2", 256); - m_fm_extra = p.get_uint(":fm-extra", 0); - m_fm_occ = p.get_bool(":fm-occ", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_fm_real_only = p.get_bool("fm_real_only", true); + m_fm_limit = p.get_uint("fm_limit", 5000000); + m_fm_cutoff1 = p.get_uint("fm_cutoff1", 8); + m_fm_cutoff2 = p.get_uint("fm_cutoff2", 256); + m_fm_extra = p.get_uint("fm_extra", 0); + m_fm_occ = p.get_bool("fm_occ", false); } void set_cancel(bool f) { diff --git a/src/muz_qe/qe_sat_tactic.cpp b/src/muz_qe/qe_sat_tactic.cpp index 1480a8ca0..5f73e4a30 100644 --- a/src/muz_qe/qe_sat_tactic.cpp +++ b/src/muz_qe/qe_sat_tactic.cpp @@ -301,17 +301,17 @@ namespace qe { virtual void cleanup() {} virtual void updt_params(params_ref const & p) { - 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); - m_ctx_simplify_local_param = p.get_bool(":strong-context-simplify-local", m_ctx_simplify_local_param); + 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); + m_ctx_simplify_local_param = p.get_bool("strong_context_simplify_local", m_ctx_simplify_local_param); } virtual void collect_param_descrs(param_descrs & r) { - 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"); - r.insert(":strong-context-simplify-local", CPK_BOOL, "(default: false) use strong context simplifier locally on the new formula only"); + 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"); + r.insert("strong_context_simplify_local", CPK_BOOL, "(default: false) use strong context simplifier locally on the new formula only"); } diff --git a/src/muz_qe/qe_tactic.cpp b/src/muz_qe/qe_tactic.cpp index f17d15d6a..971d677ea 100644 --- a/src/muz_qe/qe_tactic.cpp +++ b/src/muz_qe/qe_tactic.cpp @@ -36,7 +36,7 @@ class qe_tactic : public tactic { } void updt_params(params_ref const & p) { - m_fparams.m_nlquant_elim = p.get_bool(":qe-nonlinear", false); + m_fparams.m_nlquant_elim = p.get_bool("qe_nonlinear", false); m_qe.updt_params(p); } @@ -113,7 +113,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { - r.insert(":qe-nonlinear", CPK_BOOL, "(default: false) enable virtual term substitution."); + r.insert("qe_nonlinear", CPK_BOOL, "(default: false) enable virtual term substitution."); m_imp->collect_param_descrs(r); } diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index 837e76ecd..d76d584f7 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -198,15 +198,15 @@ namespace nlsat { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_lazy = p.get_uint(":lazy", 0); - m_simplify_cores = p.get_bool(":simplify-conflicts", true); - bool min_cores = p.get_bool(":minimize-conflicts", false); - m_reorder = p.get_bool(":reorder", true); - m_randomize = p.get_bool(":randomize", true); - m_max_conflicts = p.get_uint(":max-conflicts", UINT_MAX); - m_random_order = p.get_bool(":shuffle-vars", false); - m_random_seed = p.get_uint(":seed", 0); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_lazy = p.get_uint("lazy", 0); + m_simplify_cores = p.get_bool("simplify_conflicts", true); + bool min_cores = p.get_bool("minimize_conflicts", false); + m_reorder = p.get_bool("reorder", true); + m_randomize = p.get_bool("randomize", true); + m_max_conflicts = p.get_uint("max_conflicts", UINT_MAX); + m_random_order = p.get_bool("shuffle_vars", false); + m_random_seed = p.get_uint("seed", 0); m_ism.set_seed(m_random_seed); m_explain.set_simplify_cores(m_simplify_cores); m_explain.set_minimize_cores(min_cores); @@ -2572,13 +2572,13 @@ namespace nlsat { void solver::collect_param_descrs(param_descrs & d) { insert_max_memory(d); algebraic_numbers::manager::collect_param_descrs(d); - d.insert(":max-conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); - d.insert(":shuffle-vars", CPK_BOOL, "(default: false) use a variable order."); - d.insert(":seed", CPK_UINT, "(default: 0) random seed."); - d.insert(":randomize", CPK_BOOL, "(default: true) randomize selection of a witness in nlsat."); - d.insert(":reorder", CPK_BOOL, "(default: true) reorder variables."); - d.insert(":lazy", CPK_UINT, "(default: 0) how lazy the solver is."); - d.insert(":simplify-conflicts", CPK_BOOL, "(default: true) simplify conflicts using equalities before resolving them in nlsat solver."); + d.insert("max_conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); + d.insert("shuffle_vars", CPK_BOOL, "(default: false) use a variable order."); + d.insert("seed", CPK_UINT, "(default: 0) random seed."); + d.insert("randomize", CPK_BOOL, "(default: true) randomize selection of a witness in nlsat."); + d.insert("reorder", CPK_BOOL, "(default: true) reorder variables."); + d.insert("lazy", CPK_UINT, "(default: 0) how lazy the solver is."); + d.insert("simplify_conflicts", CPK_BOOL, "(default: true) simplify conflicts using equalities before resolving them in nlsat solver."); } unsynch_mpq_manager & solver::qm() { diff --git a/src/nlsat/tactic/goal2nlsat.cpp b/src/nlsat/tactic/goal2nlsat.cpp index 75e3c4a40..1af98c7e8 100644 --- a/src/nlsat/tactic/goal2nlsat.cpp +++ b/src/nlsat/tactic/goal2nlsat.cpp @@ -77,8 +77,8 @@ struct goal2nlsat::imp { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_factor = p.get_bool(":factor", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_factor = p.get_bool("factor", true); m_fparams.updt_params(p); } @@ -293,7 +293,7 @@ goal2nlsat::~goal2nlsat() { void goal2nlsat::collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":factor", CPK_BOOL, "(default: true) factor polynomials."); + r.insert("factor", CPK_BOOL, "(default: true) factor polynomials."); polynomial::factor_params::get_param_descrs(r); } diff --git a/src/nlsat/tactic/qfnra_nlsat_tactic.cpp b/src/nlsat/tactic/qfnra_nlsat_tactic.cpp index 7bb6bd019..b05636541 100644 --- a/src/nlsat/tactic/qfnra_nlsat_tactic.cpp +++ b/src/nlsat/tactic/qfnra_nlsat_tactic.cpp @@ -31,13 +31,13 @@ Notes: tactic * mk_qfnra_nlsat_tactic(ast_manager & m, params_ref const & p) { params_ref main_p = p; - main_p.set_bool(":elim-and", true); - main_p.set_bool(":blast-distinct", true); + main_p.set_bool("elim_and", true); + main_p.set_bool("blast_distinct", true); params_ref purify_p = p; - purify_p.set_bool(":complete", false); // temporary hack, solver does not support uninterpreted functions for encoding (div0 x) applications. So, we replace it application of this kind with an uninterpreted function symbol. + purify_p.set_bool("complete", false); // temporary hack, solver does not support uninterpreted functions for encoding (div0 x) applications. So, we replace it application of this kind with an uninterpreted function symbol. tactic * factor; - if (p.get_bool(":factor", true)) + if (p.get_bool("factor", true)) factor = mk_factor_tactic(m, p); else factor = mk_skip_tactic(); diff --git a/src/sat/sat_asymm_branch.cpp b/src/sat/sat_asymm_branch.cpp index bc2a7120d..a7209306a 100644 --- a/src/sat/sat_asymm_branch.cpp +++ b/src/sat/sat_asymm_branch.cpp @@ -194,17 +194,17 @@ namespace sat { } void asymm_branch::updt_params(params_ref const & p) { - m_asymm_branch = p.get_bool(":asymm-branch", true); - m_asymm_branch_rounds = p.get_uint(":asymm-branch-rounds", 32); - m_asymm_branch_limit = p.get_uint(":asymm-branch-limit", 100000000); + m_asymm_branch = p.get_bool("asymm_branch", true); + m_asymm_branch_rounds = p.get_uint("asymm_branch_rounds", 32); + m_asymm_branch_limit = p.get_uint("asymm_branch_limit", 100000000); if (m_asymm_branch_limit > INT_MAX) m_asymm_branch_limit = INT_MAX; } void asymm_branch::collect_param_descrs(param_descrs & d) { - d.insert(":asymm-branch", CPK_BOOL, "(default: true) asymmetric branching."); - d.insert(":asymm-branch-rounds", CPK_UINT, "(default: 32) maximum number of rounds of asymmetric branching."); - d.insert(":asymm-branch-limit", CPK_UINT, "approx. maximum number of literals visited during asymmetric branching."); + d.insert("asymm_branch", CPK_BOOL, "(default: true) asymmetric branching."); + d.insert("asymm_branch_rounds", CPK_UINT, "(default: 32) maximum number of rounds of asymmetric branching."); + d.insert("asymm_branch_limit", CPK_UINT, "approx. maximum number of literals visited during asymmetric branching."); } void asymm_branch::collect_statistics(statistics & st) { diff --git a/src/sat/sat_config.cpp b/src/sat/sat_config.cpp index 48aa270e4..e30569d89 100644 --- a/src/sat/sat_config.cpp +++ b/src/sat/sat_config.cpp @@ -22,24 +22,24 @@ Revision History: namespace sat { config::config(params_ref const & p): - m_always_true("always-true"), - m_always_false("always-false"), + m_always_true("always_true"), + m_always_false("always_false"), m_caching("caching"), m_random("random"), m_geometric("geometric"), m_luby("luby"), - m_dyn_psm("dyn-psm"), + m_dyn_psm("dyn_psm"), m_psm("psm"), m_glue("glue"), - m_glue_psm("glue-psm"), - m_psm_glue("psm-glue") { + m_glue_psm("glue_psm"), + m_psm_glue("psm_glue") { updt_params(p); } void config::updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); - symbol s = p.get_sym(":restart", m_luby); + symbol s = p.get_sym("restart", m_luby); if (s == m_luby) m_restart = RS_LUBY; else if (s == m_geometric) @@ -47,7 +47,7 @@ namespace sat { else throw sat_param_exception("invalid restart strategy"); - s = p.get_sym(":phase", m_caching); + s = p.get_sym("phase", m_caching); if (s == m_always_false) m_phase = PS_ALWAYS_FALSE; else if (s == m_always_true) @@ -59,29 +59,29 @@ namespace sat { else throw sat_param_exception("invalid phase selection strategy"); - m_phase_caching_on = p.get_uint(":phase-caching-on", 400); - m_phase_caching_off = p.get_uint(":phase-caching-off", 100); + m_phase_caching_on = p.get_uint("phase_caching_on", 400); + m_phase_caching_off = p.get_uint("phase_caching_off", 100); - m_restart_initial = p.get_uint(":restart-initial", 100); - m_restart_factor = p.get_double(":restart-factor", 1.5); + m_restart_initial = p.get_uint("restart_initial", 100); + m_restart_factor = p.get_double("restart_factor", 1.5); - m_random_freq = p.get_double(":random-freq", 0.01); + m_random_freq = p.get_double("random_freq", 0.01); - m_burst_search = p.get_uint(":burst-search", 100); + m_burst_search = p.get_uint("burst_search", 100); - m_max_conflicts = p.get_uint(":max-conflicts", UINT_MAX); + m_max_conflicts = p.get_uint("max_conflicts", UINT_MAX); - m_simplify_mult1 = p.get_uint(":simplify-mult1", 300); - m_simplify_mult2 = p.get_double(":simplify-mult2", 1.5); - m_simplify_max = p.get_uint(":simplify-max", 500000); + m_simplify_mult1 = p.get_uint("simplify_mult1", 300); + m_simplify_mult2 = p.get_double("simplify_mult2", 1.5); + m_simplify_max = p.get_uint("simplify_max", 500000); - s = p.get_sym(":gc-strategy", m_glue_psm); + s = p.get_sym("gc_strategy", m_glue_psm); if (s == m_dyn_psm) { m_gc_strategy = GC_DYN_PSM; - m_gc_initial = p.get_uint(":gc-initial", 500); - m_gc_increment = p.get_uint(":gc-increment", 100); - m_gc_small_lbd = p.get_uint(":gc-small-lbd", 3); - m_gc_k = p.get_uint(":gc-k", 7); + m_gc_initial = p.get_uint("gc_initial", 500); + m_gc_increment = p.get_uint("gc_increment", 100); + m_gc_small_lbd = p.get_uint("gc_small_lbd", 3); + m_gc_k = p.get_uint("gc_k", 7); if (m_gc_k > 255) m_gc_k = 255; } @@ -96,31 +96,31 @@ namespace sat { m_gc_strategy = GC_PSM_GLUE; else throw sat_param_exception("invalid gc strategy"); - m_gc_initial = p.get_uint(":gc-initial", 20000); - m_gc_increment = p.get_uint(":gc-increment", 500); + m_gc_initial = p.get_uint("gc_initial", 20000); + m_gc_increment = p.get_uint("gc_increment", 500); } - m_minimize_lemmas = p.get_bool(":minimize-lemmas", true); - m_dyn_sub_res = p.get_bool(":dyn-sub-res", true); + m_minimize_lemmas = p.get_bool("minimize_lemmas", true); + m_dyn_sub_res = p.get_bool("dyn_sub_res", true); } void config::collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":phase", CPK_SYMBOL, "(default: caching) phase selection strategy: always-false, always-true, caching, random."); - r.insert(":phase-caching-on", CPK_UINT, "(default: 400)"); - r.insert(":phase-caching-off", CPK_UINT, "(default: 100)"); - r.insert(":restart", CPK_SYMBOL, "(default: luby) restart strategy: luby or geometric."); - r.insert(":restart-initial", CPK_UINT, "(default: 100) initial restart (number of conflicts)."); - r.insert(":restart-factor", CPK_DOUBLE, "(default: 1.5) restart increment factor for geometric strategy."); - r.insert(":random-freq", CPK_DOUBLE, "(default: 0.01) frequency of random case splits."); - r.insert(":burst-search", CPK_UINT, "(default: 100) number of conflicts before first global simplification."); - r.insert(":max-conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); - r.insert(":gc-strategy", CPK_SYMBOL, "(default: glue-psm) garbage collection strategy: psm, glue, glue-psm, dyn-psm."); - r.insert(":gc-initial", CPK_UINT, "(default: 20000) learned clauses garbage collection frequence."); - r.insert(":gc-increment", CPK_UINT, "(default: 500) increment to the garbage collection threshold."); - r.insert(":gc-small-lbd", CPK_UINT, "(default: 3) learned clauses with small LBD are never deleted (only used in dyn-psm)."); - r.insert(":gc-k", CPK_UINT, "(default: 7) learned clauses that are inactive for k gc rounds are permanently deleted (only used in dyn-psm)."); - r.insert(":minimize-lemmas", CPK_BOOL, "(default: true) minimize learned clauses."); - r.insert(":dyn-sub-res", CPK_BOOL, "(default: true) dynamic subsumption resolution for minimizing learned clauses."); + r.insert("phase", CPK_SYMBOL, "(default: caching) phase selection strategy: always_false, always_true, caching, random."); + r.insert("phase_caching_on", CPK_UINT, "(default: 400)"); + r.insert("phase_caching_off", CPK_UINT, "(default: 100)"); + r.insert("restart", CPK_SYMBOL, "(default: luby) restart strategy: luby or geometric."); + r.insert("restart_initial", CPK_UINT, "(default: 100) initial restart (number of conflicts)."); + r.insert("restart_factor", CPK_DOUBLE, "(default: 1.5) restart increment factor for geometric strategy."); + r.insert("random_freq", CPK_DOUBLE, "(default: 0.01) frequency of random case splits."); + r.insert("burst_search", CPK_UINT, "(default: 100) number of conflicts before first global simplification."); + r.insert("max_conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); + r.insert("gc_strategy", CPK_SYMBOL, "(default: glue_psm) garbage collection strategy: psm, glue, glue_psm, dyn_psm."); + r.insert("gc_initial", CPK_UINT, "(default: 20000) learned clauses garbage collection frequence."); + r.insert("gc_increment", CPK_UINT, "(default: 500) increment to the garbage collection threshold."); + r.insert("gc_small_lbd", CPK_UINT, "(default: 3) learned clauses with small LBD are never deleted (only used in dyn_psm)."); + r.insert("gc_k", CPK_UINT, "(default: 7) learned clauses that are inactive for k gc rounds are permanently deleted (only used in dyn_psm)."); + r.insert("minimize_lemmas", CPK_BOOL, "(default: true) minimize learned clauses."); + r.insert("dyn_sub_res", CPK_BOOL, "(default: true) dynamic subsumption resolution for minimizing learned clauses."); } }; diff --git a/src/sat/sat_probing.cpp b/src/sat/sat_probing.cpp index f51b16033..f9741cd7b 100644 --- a/src/sat/sat_probing.cpp +++ b/src/sat/sat_probing.cpp @@ -243,11 +243,11 @@ namespace sat { } void probing::updt_params(params_ref const & p) { - m_probing = p.get_bool(":probing", true); - m_probing_limit = p.get_uint(":probing-limit", 5000000); - m_probing_cache = p.get_bool(":probing-cache", true); - m_probing_binary = p.get_bool(":probing-binary", true); - m_probing_cache_limit = megabytes_to_bytes(p.get_uint(":probing-chache-limit", 1024)); + m_probing = p.get_bool("probing", true); + m_probing_limit = p.get_uint("probing_limit", 5000000); + m_probing_cache = p.get_bool("probing_cache", true); + m_probing_binary = p.get_bool("probing_binary", true); + m_probing_cache_limit = megabytes_to_bytes(p.get_uint("probing_chache_limit", 1024)); } void probing::collect_param_descrs(param_descrs & d) { diff --git a/src/sat/sat_scc.cpp b/src/sat/sat_scc.cpp index 5e351290f..f2598119f 100644 --- a/src/sat/sat_scc.cpp +++ b/src/sat/sat_scc.cpp @@ -231,11 +231,11 @@ namespace sat { } void scc::updt_params(params_ref const & p) { - m_scc = p.get_bool(":scc", true); + m_scc = p.get_bool("scc", true); } void scc::collect_param_descrs(param_descrs & d) { - d.insert(":scc", CPK_BOOL, "(default: true) eliminate Boolean variables by computing strongly connected components."); + d.insert("scc", CPK_BOOL, "(default: true) eliminate Boolean variables by computing strongly connected components."); } }; diff --git a/src/sat/sat_simplifier.cpp b/src/sat/sat_simplifier.cpp index 3f3015967..8a1713647 100644 --- a/src/sat/sat_simplifier.cpp +++ b/src/sat/sat_simplifier.cpp @@ -1431,44 +1431,44 @@ namespace sat { } void simplifier::updt_params(params_ref const & p) { - m_elim_blocked_clauses = p.get_bool(":elim-blocked-clauses", false); - m_elim_blocked_clauses_at = p.get_uint(":elim-blocked-clauses-at", 2); - m_blocked_clause_limit = p.get_uint(":blocked-clause-limit", 100000000); - m_resolution = p.get_bool(":resolution", true); - m_res_limit = p.get_uint(":resolution-limit", 500000000); - m_res_occ_cutoff = p.get_uint(":res-occ-cutoff", 10); - m_res_occ_cutoff1 = p.get_uint(":res-occ-cutoff-range1", 8); - m_res_occ_cutoff2 = p.get_uint(":res-occ-cutoff-range2", 5); - m_res_occ_cutoff3 = p.get_uint(":res-occ-cutoff-range3", 3); - m_res_lit_cutoff1 = p.get_uint(":res-lit-cutoff-range1", 700); - m_res_lit_cutoff2 = p.get_uint(":res-lit-cutoff-range2", 400); - m_res_lit_cutoff3 = p.get_uint(":res-lit-cutoff-range3", 300); - m_res_cls_cutoff1 = p.get_uint(":res-cls-cutoff1", 100000); - m_res_cls_cutoff2 = p.get_uint(":res-cls-cutoff2", 700000); - m_subsumption = p.get_bool(":subsumption", true); - m_subsumption_limit = p.get_uint(":subsumption-limit", 100000000); + m_elim_blocked_clauses = p.get_bool("elim_blocked_clauses", false); + m_elim_blocked_clauses_at = p.get_uint("elim_blocked_clauses_at", 2); + m_blocked_clause_limit = p.get_uint("blocked_clause_limit", 100000000); + m_resolution = p.get_bool("resolution", true); + m_res_limit = p.get_uint("resolution_limit", 500000000); + m_res_occ_cutoff = p.get_uint("res_occ_cutoff", 10); + m_res_occ_cutoff1 = p.get_uint("res_occ_cutoff_range1", 8); + m_res_occ_cutoff2 = p.get_uint("res_occ_cutoff_range2", 5); + m_res_occ_cutoff3 = p.get_uint("res_occ_cutoff_range3", 3); + m_res_lit_cutoff1 = p.get_uint("res_lit_cutoff_range1", 700); + m_res_lit_cutoff2 = p.get_uint("res_lit_cutoff_range2", 400); + m_res_lit_cutoff3 = p.get_uint("res_lit_cutoff_range3", 300); + m_res_cls_cutoff1 = p.get_uint("res_cls_cutoff1", 100000); + m_res_cls_cutoff2 = p.get_uint("res_cls_cutoff2", 700000); + m_subsumption = p.get_bool("subsumption", true); + m_subsumption_limit = p.get_uint("subsumption_limit", 100000000); } void simplifier::collect_param_descrs(param_descrs & r) { - r.insert(":elim-blocked-clauses", CPK_BOOL, "(default: false) eliminate blocked clauses."); - r.insert(":elim-blocked-clauses-at", CPK_UINT, "(default: 2) eliminate blocked clauses only once at the given simplification round."); - r.insert(":blocked-clause-limit", CPK_UINT, "(default: 100000000) maximum number of literals visited during blocked clause elimination."); - r.insert(":resolution", CPK_BOOL, "(default: true) eliminate boolean variables using resolution."); - r.insert(":resolution-limit", CPK_UINT, "(default: 500000000) approx. maximum number of literals visited during variable elimination."); - r.insert(":res-occ-cutoff", CPK_UINT, "(default: 10) first cutoff (on number of positive/negative occurrences) for Boolean variable elimination."); - r.insert(":res-occ-cutoff-range1", CPK_UINT, "(default: 8) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing less than :res-cls-cutoff1 clauses."); - r.insert(":res-occ-cutoff-range2", CPK_UINT, "(default: 5) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than :res-cls-cutoff1 and less than :res-cls-cutoff2."); - r.insert(":res-occ-cutoff-range3", CPK_UINT, "(default: 3) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than :res-cls-cutoff2."); + r.insert("elim_blocked_clauses", CPK_BOOL, "(default: false) eliminate blocked clauses."); + r.insert("elim_blocked_clauses_at", CPK_UINT, "(default: 2) eliminate blocked clauses only once at the given simplification round."); + r.insert("blocked_clause_limit", CPK_UINT, "(default: 100000000) maximum number of literals visited during blocked clause elimination."); + r.insert("resolution", CPK_BOOL, "(default: true) eliminate boolean variables using resolution."); + r.insert("resolution_limit", CPK_UINT, "(default: 500000000) approx. maximum number of literals visited during variable elimination."); + r.insert("res_occ_cutoff", CPK_UINT, "(default: 10) first cutoff (on number of positive/negative occurrences) for Boolean variable elimination."); + r.insert("res_occ_cutoff_range1", CPK_UINT, "(default: 8) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing less than res_cls_cutoff1 clauses."); + r.insert("res_occ_cutoff_range2", CPK_UINT, "(default: 5) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than res_cls_cutoff1 and less than res_cls_cutoff2."); + r.insert("res_occ_cutoff_range3", CPK_UINT, "(default: 3) second cutoff (number of positive/negative occurrences) for Boolean variable elimination, for problems containing more than res_cls_cutoff2."); - r.insert(":res-lit-cutoff-range1", CPK_UINT, "(default: 700) second cutoff (total number of literals) for Boolean variable elimination, for problems containing less than :res-cls-cutoff1 clauses."); - r.insert(":res-lit-cutoff-range2", CPK_UINT, "(default: 400) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than :res-cls-cutoff1 and less than :res-cls-cutoff2."); - r.insert(":res-lit-cutoff-range3", CPK_UINT, "(default: 300) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than :res-cls-cutoff2."); + r.insert("res_lit_cutoff_range1", CPK_UINT, "(default: 700) second cutoff (total number of literals) for Boolean variable elimination, for problems containing less than res_cls_cutoff1 clauses."); + r.insert("res_lit_cutoff_range2", CPK_UINT, "(default: 400) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than res_cls_cutoff1 and less than res_cls_cutoff2."); + r.insert("res_lit_cutoff_range3", CPK_UINT, "(default: 300) second cutoff (total number of literals) for Boolean variable elimination, for problems containing more than res_cls_cutoff2."); - r.insert(":res-cls-cutoff1", CPK_UINT, "(default: 100000000) limit1 - total number of problems clauses for the second cutoff of Boolean variable elimination."); - r.insert(":res-cls-cutoff2", CPK_UINT, "(default: 700000000) limit2 - total number of problems clauses for the second cutoff of Boolean variable elimination."); + r.insert("res_cls_cutoff1", CPK_UINT, "(default: 100000000) limit1 - total number of problems clauses for the second cutoff of Boolean variable elimination."); + r.insert("res_cls_cutoff2", CPK_UINT, "(default: 700000000) limit2 - total number of problems clauses for the second cutoff of Boolean variable elimination."); - r.insert(":subsumption", CPK_BOOL, "(default: true) eliminate subsumed clauses."); - r.insert(":subsumption-limit", CPK_UINT, "(default: 100000000) approx. maximum number of literals visited during subsumption (and subsumption resolution)."); + r.insert("subsumption", CPK_BOOL, "(default: true) eliminate subsumed clauses."); + r.insert("subsumption_limit", CPK_UINT, "(default: 100000000) approx. maximum number of literals visited during subsumption (and subsumption resolution)."); } void simplifier::collect_statistics(statistics & st) { diff --git a/src/sat/sat_solver.cpp b/src/sat/sat_solver.cpp index 0322e80c5..399fb2c61 100644 --- a/src/sat/sat_solver.cpp +++ b/src/sat/sat_solver.cpp @@ -1909,7 +1909,7 @@ namespace sat { m_asymm_branch.updt_params(p); m_probing.updt_params(p); m_scc.updt_params(p); - m_rand.set_seed(p.get_uint(":random-seed", 0)); + m_rand.set_seed(p.get_uint("random_seed", 0)); } void solver::collect_param_descrs(param_descrs & d) { diff --git a/src/sat/tactic/goal2sat.cpp b/src/sat/tactic/goal2sat.cpp index b6c2e39cf..16184e2bc 100644 --- a/src/sat/tactic/goal2sat.cpp +++ b/src/sat/tactic/goal2sat.cpp @@ -67,8 +67,8 @@ struct goal2sat::imp { } void updt_params(params_ref const & p) { - m_ite_extra = p.get_bool(":ite-extra", true); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_ite_extra = p.get_bool("ite_extra", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } void throw_op_not_handled() { @@ -420,7 +420,7 @@ goal2sat::goal2sat():m_imp(0) { void goal2sat::collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":ite-extra", CPK_BOOL, "(default: true) add redundant clauses (that improve unit propagation) when encoding if-then-else formulas"); + r.insert("ite_extra", CPK_BOOL, "(default: true) add redundant clauses (that improve unit propagation) when encoding if-then-else formulas"); } struct goal2sat::scoped_set_imp { @@ -575,8 +575,8 @@ struct sat2goal::imp { } void updt_params(params_ref const & p) { - m_learned = p.get_bool(":learned", false); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_learned = p.get_bool("learned", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } void checkpoint() { @@ -676,7 +676,7 @@ sat2goal::sat2goal():m_imp(0) { void sat2goal::collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":learned", CPK_BOOL, "(default: false) collect also learned clauses."); + r.insert("learned", CPK_BOOL, "(default: false) collect also learned clauses."); } struct sat2goal::scoped_set_imp { diff --git a/src/sat/tactic/sat_tactic.cpp b/src/sat/tactic/sat_tactic.cpp index 015eb6c66..d48994861 100644 --- a/src/sat/tactic/sat_tactic.cpp +++ b/src/sat/tactic/sat_tactic.cpp @@ -210,7 +210,7 @@ tactic * mk_sat_tactic(ast_manager & m, params_ref const & p) { tactic * mk_sat_preprocessor_tactic(ast_manager & m, params_ref const & p) { params_ref p_aux; - p_aux.set_uint(":max-conflicts", 0); + p_aux.set_uint("max_conflicts", 0); tactic * t = clean(using_params(mk_sat_tactic(m, p), p_aux)); t->updt_params(p); return t; diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index 14dcc91c3..d422db708 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -72,8 +72,8 @@ static void display_statistics( code.process_all_costs(); { params_ref p(ctx.get_params()); - p.set_bool(":output-profile", true); - p.set_uint(":profile-milliseconds-threshold", 100); + p.set_bool("output_profile", true); + p.set_uint("profile_milliseconds_threshold", 100); ctx.updt_params(p); out << "--------------\n"; @@ -132,9 +132,9 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); params_ref params; - params.set_sym(":engine", symbol("datalog")); - params.set_sym(":default-table", dl_params.m_default_table); - params.set_bool(":default-table-checked", dl_params.m_default_table_checked); + params.set_sym("engine", symbol("datalog")); + params.set_sym("default_table", dl_params.m_default_table); + params.set_bool("default_table_checked", dl_params.m_default_table_checked); datalog::context ctx(m, front_end_params, params); size_t watermark = front_end_params.m_memory_high_watermark; @@ -252,7 +252,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ TRACE("dl_compiler", ctx.display(tout); rules_code.display(ctx, tout);); - if (ctx.get_params().get_bool(":output-tuples", true)) { + if (ctx.get_params().get_bool("output_tuples", true)) { ctx.display_output_facts(std::cout); } diff --git a/src/shell/dimacs_frontend.cpp b/src/shell/dimacs_frontend.cpp index cf64ed110..2dbb0adf8 100644 --- a/src/shell/dimacs_frontend.cpp +++ b/src/shell/dimacs_frontend.cpp @@ -69,7 +69,7 @@ unsigned read_dimacs(char const * file_name, front_end_params & front_end_params register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); params_ref p; - p.set_bool(":produce-models", front_end_params.m_model); + p.set_bool("produce_models", front_end_params.m_model); sat::solver solver(p, 0); g_solver = &solver; diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 6dc5a7ebe..d6e7b1bf1 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -32,6 +32,7 @@ Revision History: #include"timeout.h" #include"z3_exception.h" #include"error_codes.h" +#include"gparams.h" typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_Z3_LOG } input_kind; @@ -76,8 +77,7 @@ void display_usage() { std::cout << " " << OPT << "version prints version number of Z3.\n"; std::cout << " " << OPT << "v:level be verbose, where is the verbosity level.\n"; std::cout << " " << OPT << "nw disable warning messages.\n"; - std::cout << " " << OPT << "ini:file configuration file.\n"; - std::cout << " " << OPT << "ini? display all available INI file parameters.\n"; + std::cout << " " << OPT << "params display all available parameters.\n"; std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. @@ -285,13 +285,8 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "nw") == 0) { enable_warning_messages(false); } - else if (strcmp(opt_name, "ini") == 0) { - if (!opt_arg) - error("option argument (/ini:file) is missing."); - read_ini_file(opt_arg); - } - else if (strcmp(opt_name, "ini?") == 0) { - display_ini_help(); + else if (strcmp(opt_name, "params") == 0) { + gparams::display(std::cout); exit(0); } else if (strcmp(opt_name, "geninidoc") == 0) { @@ -327,7 +322,7 @@ void parse_cmd_line_args(int argc, char ** argv) { char * key = argv[i]; *eq_pos = 0; char * value = eq_pos+1; - g_params->set_param_value(key, value); + gparams::set(key, value); } else { if (g_front_end_params->m_interactive) { diff --git a/src/smt/arith_eq_solver.cpp b/src/smt/arith_eq_solver.cpp index 417f8022b..41a61bf73 100644 --- a/src/smt/arith_eq_solver.cpp +++ b/src/smt/arith_eq_solver.cpp @@ -26,8 +26,8 @@ arith_eq_solver::arith_eq_solver(ast_manager & m, params_ref const& p): m_util(m), m_arith_rewriter(m) { - m_params.set_bool(":gcd-rounding", true); - // m_params.set_bool(":sum", true); + m_params.set_bool("gcd_rounding", true); + // m_params.set_bool("sum", true); m_arith_rewriter.updt_params(m_params); } diff --git a/src/smt/smt_implied_equalities.cpp b/src/smt/smt_implied_equalities.cpp index 91784f5f5..c6f28d4b2 100644 --- a/src/smt/smt_implied_equalities.cpp +++ b/src/smt/smt_implied_equalities.cpp @@ -197,7 +197,7 @@ namespace smt { s_stats_val_eq_timer.start(); params_ref p; - p.set_bool(":produce-models", false); + p.set_bool("produce_models", false); m_solver.updt_params(p); for (unsigned i = 0; i < terms.size(); ++i) { @@ -232,7 +232,7 @@ namespace smt { } m_stats_val_eq_timer.stop(); s_stats_val_eq_timer.stop(); - p.set_bool(":produce-models", true); + p.set_bool("produce_models", true); m_solver.updt_params(p); @@ -325,7 +325,7 @@ namespace smt { lbool operator()(unsigned num_terms, expr* const* terms, unsigned* class_ids) { params_ref p; - p.set_bool(":produce-models", true); + p.set_bool("produce_models", true); m_solver.updt_params(p); sort2term_ids termids; stopwatch timer; diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index 84587b6c9..1551c765c 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -60,8 +60,8 @@ public: } void updt_params_core(params_ref const & p) { - m_candidate_models = p.get_bool(":candidate-models", false); - m_fail_if_inconclusive = p.get_bool(":fail-if-inconclusive", true); + m_candidate_models = p.get_bool("candidate_models", false); + m_fail_if_inconclusive = p.get_bool("fail_if_inconclusive", true); } virtual void updt_params(params_ref const & p) { @@ -69,12 +69,12 @@ public: updt_params_core(p); m_params_ref = p; params2front_end_params(m_params_ref, fparams()); - SASSERT(p.get_bool(":auto_config", fparams().m_auto_config) == fparams().m_auto_config); + SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); } virtual void collect_param_descrs(param_descrs & r) { - 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."); + 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."); solver_front_end_params_descrs(r); } @@ -315,7 +315,7 @@ tactic * mk_smt_tactic(params_ref const & p) { tactic * mk_smt_tactic_using(bool auto_config, params_ref const & _p) { params_ref p = _p; - p.set_bool(":auto-config", auto_config); + p.set_bool("auto_config", auto_config); tactic * r = mk_smt_tactic(p); TRACE("smt_tactic", tout << "auto_config: " << auto_config << "\nr: " << r << "\np: " << p << "\n";); return using_params(r, p); diff --git a/src/tactic/aig/aig_tactic.cpp b/src/tactic/aig/aig_tactic.cpp index 617db0b8c..dc577eb73 100644 --- a/src/tactic/aig/aig_tactic.cpp +++ b/src/tactic/aig/aig_tactic.cpp @@ -62,14 +62,14 @@ public: } virtual void updt_params(params_ref const & p) { - 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); + 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) { insert_max_memory(r); - r.insert(":aig-per-assertion", CPK_BOOL, "(default: true) process one assertion at a time."); + r.insert("aig_per_assertion", CPK_BOOL, "(default: true) process one assertion at a time."); } void operator()(goal_ref const & g) { diff --git a/src/tactic/arith/add_bounds_tactic.cpp b/src/tactic/arith/add_bounds_tactic.cpp index 81e9c26cf..d396359a3 100644 --- a/src/tactic/arith/add_bounds_tactic.cpp +++ b/src/tactic/arith/add_bounds_tactic.cpp @@ -70,8 +70,8 @@ class add_bounds_tactic : public tactic { } void updt_params(params_ref const & p) { - m_lower = p.get_rat(":add-bound-lower", rational(-2)); - m_upper = p.get_rat(":add-bound-upper", rational(2)); + m_lower = p.get_rat("add_bound_lower", rational(-2)); + m_upper = p.get_rat("add_bound_upper", rational(2)); } void set_cancel(bool f) { @@ -159,8 +159,8 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - 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."); + 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, diff --git a/src/tactic/arith/bound_propagator.cpp b/src/tactic/arith/bound_propagator.cpp index 40c2ed49b..dbd7c5f69 100644 --- a/src/tactic/arith/bound_propagator.cpp +++ b/src/tactic/arith/bound_propagator.cpp @@ -116,15 +116,15 @@ void bound_propagator::del_constraint(constraint & c) { } void bound_propagator::updt_params(params_ref const & p) { - m_max_refinements = p.get_uint(":bound-max-refinements", 16); - m_threshold = p.get_double(":bound-threshold", 0.05); - m_small_interval = p.get_double(":bound-small-interval", 128); - m_strict2double = p.get_double(":strict2double", 0.00001); + m_max_refinements = p.get_uint("bound_max_refinements", 16); + m_threshold = p.get_double("bound_threshold", 0.05); + m_small_interval = p.get_double("bound_small_interval", 128); + m_strict2double = p.get_double("strict2double", 0.00001); } void bound_propagator::get_param_descrs(param_descrs & r) { - r.insert(":bound-max-refinements", CPK_UINT, "(default: 16) maximum number of bound refinements (per round) for unbounded variables."); - r.insert(":bound-threshold", CPK_DOUBLE, "(default: 0.05) bound propagation improvement threshold ratio."); + r.insert("bound_max_refinements", CPK_UINT, "(default: 16) maximum number of bound refinements (per round) for unbounded variables."); + r.insert("bound_threshold", CPK_DOUBLE, "(default: 0.05) bound propagation improvement threshold ratio."); } void bound_propagator::collect_statistics(statistics & st) const { diff --git a/src/tactic/arith/bv2int_rewriter.cpp b/src/tactic/arith/bv2int_rewriter.cpp index e8ddf18c9..0965f36f2 100644 --- a/src/tactic/arith/bv2int_rewriter.cpp +++ b/src/tactic/arith/bv2int_rewriter.cpp @@ -21,7 +21,7 @@ Notes: #include "ast_pp.h" void bv2int_rewriter_ctx::update_params(params_ref const& p) { - m_max_size = p.get_uint(":max-bv-size", UINT_MAX); + m_max_size = p.get_uint("max_bv_size", UINT_MAX); } struct lt_rational { diff --git a/src/tactic/arith/diff_neq_tactic.cpp b/src/tactic/arith/diff_neq_tactic.cpp index 93ac6912d..b534c8295 100644 --- a/src/tactic/arith/diff_neq_tactic.cpp +++ b/src/tactic/arith/diff_neq_tactic.cpp @@ -62,7 +62,7 @@ class diff_neq_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_k = rational(p.get_uint(":diff-neq-max-k", 1024)); + m_max_k = rational(p.get_uint("diff_neq_max_k", 1024)); m_max_neg_k = -m_max_k; if (m_max_k >= rational(INT_MAX/2)) m_max_k = rational(INT_MAX/2); @@ -374,7 +374,7 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":diff-neq-max-k", CPK_UINT, "(default: 1024) maximum variable upper bound for diff neq solver."); + 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 { diff --git a/src/tactic/arith/factor_tactic.cpp b/src/tactic/arith/factor_tactic.cpp index 2cfbc9ef8..752f6681d 100644 --- a/src/tactic/arith/factor_tactic.cpp +++ b/src/tactic/arith/factor_tactic.cpp @@ -40,7 +40,7 @@ class factor_tactic : public tactic { } void updt_params(params_ref const & p) { - m_split_factors = p.get_bool(":split-factors", true); + m_split_factors = p.get_bool("split_factors", true); m_fparams.updt_params(p); } @@ -311,7 +311,7 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":split-factors", CPK_BOOL, + 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); } diff --git a/src/tactic/arith/fm_tactic.cpp b/src/tactic/arith/fm_tactic.cpp index 4796e7f39..c4b7cbaf3 100644 --- a/src/tactic/arith/fm_tactic.cpp +++ b/src/tactic/arith/fm_tactic.cpp @@ -792,13 +792,13 @@ class fm_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_fm_real_only = p.get_bool(":fm-real-only", true); - m_fm_limit = p.get_uint(":fm-limit", 5000000); - m_fm_cutoff1 = p.get_uint(":fm-cutoff1", 8); - m_fm_cutoff2 = p.get_uint(":fm-cutoff2", 256); - m_fm_extra = p.get_uint(":fm-extra", 0); - m_fm_occ = p.get_bool(":fm-occ", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_fm_real_only = p.get_bool("fm_real_only", true); + m_fm_limit = p.get_uint("fm_limit", 5000000); + m_fm_cutoff1 = p.get_uint("fm_cutoff1", 8); + m_fm_cutoff2 = p.get_uint("fm_cutoff2", 256); + m_fm_extra = p.get_uint("fm_extra", 0); + m_fm_occ = p.get_bool("fm_occ", false); } void set_cancel(bool f) { @@ -1668,12 +1668,12 @@ public: virtual void collect_param_descrs(param_descrs & r) { 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."); - r.insert(":fm-occ", CPK_BOOL, "(default: false) consider inequalities occurring in clauses for FM."); - r.insert(":fm-limit", CPK_UINT, "(default: 5000000) maximum number of constraints, monomials, clauses visited during FM."); - r.insert(":fm-cutoff1", CPK_UINT, "(default: 8) first cutoff for FM based on maximum number of lower/upper occurrences."); - r.insert(":fm-cutoff2", CPK_UINT, "(default: 256) second cutoff for FM based on num_lower * num_upper occurrences."); - r.insert(":fm-extra", CPK_UINT, "(default: 0) max. increase on the number of inequalities for each FM variable elimination step."); + r.insert("fm_real_only", CPK_BOOL, "(default: true) consider only real variables for fourier-motzkin elimination."); + r.insert("fm_occ", CPK_BOOL, "(default: false) consider inequalities occurring in clauses for FM."); + r.insert("fm_limit", CPK_UINT, "(default: 5000000) maximum number of constraints, monomials, clauses visited during FM."); + r.insert("fm_cutoff1", CPK_UINT, "(default: 8) first cutoff for FM based on maximum number of lower/upper occurrences."); + r.insert("fm_cutoff2", CPK_UINT, "(default: 256) second cutoff for FM based on num_lower * num_upper occurrences."); + r.insert("fm_extra", CPK_UINT, "(default: 0) max. increase on the number of inequalities for each FM variable elimination step."); } virtual void set_cancel(bool f) { @@ -1707,9 +1707,9 @@ public: tactic * mk_fm_tactic(ast_manager & m, params_ref const & p) { params_ref s_p = p; - s_p.set_bool(":arith-lhs", true); - s_p.set_bool(":elim-and", true); - s_p.set_bool(":som", true); + s_p.set_bool("arith_lhs", true); + s_p.set_bool("elim_and", true); + s_p.set_bool("som", true); return and_then(using_params(mk_simplify_tactic(m, s_p), s_p), clean(alloc(fm_tactic, m, p))); } diff --git a/src/tactic/arith/lia2pb_tactic.cpp b/src/tactic/arith/lia2pb_tactic.cpp index 871614c1b..6fee55e4b 100644 --- a/src/tactic/arith/lia2pb_tactic.cpp +++ b/src/tactic/arith/lia2pb_tactic.cpp @@ -50,9 +50,9 @@ class lia2pb_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_partial_lia2pb = p.get_bool(":lia2pb-partial", false); - m_max_bits = p.get_uint(":lia2pb-max-bits", 32); - m_total_bits = p.get_uint(":lia2pb-total-bits", 2048); + m_partial_lia2pb = p.get_bool("lia2pb_partial", false); + m_max_bits = p.get_uint("lia2pb_max_bits", 32); + m_total_bits = p.get_uint("lia2pb_total_bits", 2048); } void updt_params(params_ref const & p) { @@ -325,9 +325,9 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - 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."); + 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, diff --git a/src/tactic/arith/nla2bv_tactic.cpp b/src/tactic/arith/nla2bv_tactic.cpp index a9033bcd3..188ea7d70 100644 --- a/src/tactic/arith/nla2bv_tactic.cpp +++ b/src/tactic/arith/nla2bv_tactic.cpp @@ -68,7 +68,7 @@ class nla2bv_tactic : public tactic { m_is_sat_preserving(true), m_arith(m), m_bv(m), - m_bv2real(m, rational(p.get_uint(":nla2bv-root",2)), rational(p.get_uint(":nla2bv-divisor",2)), p.get_uint(":nla2bv-max-bv-size", UINT_MAX)), + m_bv2real(m, rational(p.get_uint("nla2bv_root",2)), rational(p.get_uint("nla2bv_divisor",2)), p.get_uint("nla2bv_max_bv_size", UINT_MAX)), m_bv2int_ctx(m, p), m_bounds(m), m_subst(m), @@ -76,7 +76,7 @@ class nla2bv_tactic : public tactic { m_defs(m), m_trail(m), m_fmc(0) { - m_default_bv_size = m_num_bits = p.get_uint(":nla2bv-bv-size", 4); + m_default_bv_size = m_num_bits = p.get_uint("nla2bv_bv_size", 4); } ~imp() {} @@ -436,10 +436,10 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - 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."); - r.insert(":nla2bv-divisor", CPK_UINT, "(default: 2) nla2bv tactic parameter."); + 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."); + r.insert("nla2bv_divisor", CPK_UINT, "(default: 2) nla2bv tactic parameter."); } /** diff --git a/src/tactic/arith/normalize_bounds_tactic.cpp b/src/tactic/arith/normalize_bounds_tactic.cpp index f7aa968ef..a62b311b5 100644 --- a/src/tactic/arith/normalize_bounds_tactic.cpp +++ b/src/tactic/arith/normalize_bounds_tactic.cpp @@ -44,7 +44,7 @@ class normalize_bounds_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_normalize_int_only = p.get_bool(":norm-int-only", true); + m_normalize_int_only = p.get_bool("norm_int_only", true); } void updt_params(params_ref const & p) { @@ -173,7 +173,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_produce_models(r); - r.insert(":norm-int-only", CPK_BOOL, "(default: true) normalize only the bounds of integer constants."); + r.insert("norm_int_only", CPK_BOOL, "(default: true) normalize only the bounds of integer constants."); } virtual void operator()(goal_ref const & in, diff --git a/src/tactic/arith/pb2bv_tactic.cpp b/src/tactic/arith/pb2bv_tactic.cpp index 36cc801dc..8790ca5a7 100644 --- a/src/tactic/arith/pb2bv_tactic.cpp +++ b/src/tactic/arith/pb2bv_tactic.cpp @@ -863,15 +863,15 @@ private: } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_all_clauses_limit = p.get_uint(":pb2bv-all-clauses-limit", 8); - m_cardinality_limit = p.get_uint(":pb2bv-cardinality-limit", UINT_MAX); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_all_clauses_limit = p.get_uint("pb2bv_all_clauses_limit", 8); + m_cardinality_limit = p.get_uint("pb2bv_cardinality_limit", UINT_MAX); } void collect_param_descrs(param_descrs & r) { insert_max_memory(r); - r.insert(":pb2bv-all-clauses-limit", CPK_UINT, "(default: 8) maximum number of literals for using equivalent CNF encoding of PB constraint."); - r.insert(":pb2bv-cardinality-limit", CPK_UINT, "(default: inf) limit for using arc-consistent cardinality constraint encoding."); + r.insert("pb2bv_all_clauses_limit", CPK_UINT, "(default: 8) maximum number of literals for using equivalent CNF encoding of PB constraint."); + r.insert("pb2bv_cardinality_limit", CPK_UINT, "(default: inf) limit for using arc-consistent cardinality constraint encoding."); } void set_cancel(bool f) { diff --git a/src/tactic/arith/purify_arith_tactic.cpp b/src/tactic/arith/purify_arith_tactic.cpp index 4bea07269..d6ed86c08 100644 --- a/src/tactic/arith/purify_arith_tactic.cpp +++ b/src/tactic/arith/purify_arith_tactic.cpp @@ -856,11 +856,11 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":complete", CPK_BOOL, + r.insert("complete", CPK_BOOL, "(default: true) add constraints to make sure that any interpretation of a underspecified arithmetic operators is a functio. The result will include additional uninterpreted functions/constants: /0, div0, mod0, 0^0, neg-root"); - r.insert(":elim-root-objects", CPK_BOOL, + r.insert("elim_root_objects", CPK_BOOL, "(default: true) eliminate root objects."); - r.insert(":elim-inverses", CPK_BOOL, + r.insert("elim_inverses", CPK_BOOL, "(default: true) eliminate inverse trigonometric functions (asin, acos, atan)."); th_rewriter::get_param_descrs(r); } @@ -876,9 +876,9 @@ public: tactic_report report("purify-arith", *g); bool produce_proofs = g->proofs_enabled(); bool produce_models = g->models_enabled(); - bool elim_root_objs = m_params.get_bool(":elim-root-objects", true); - bool elim_inverses = m_params.get_bool(":elim-inverses", true); - bool complete = m_params.get_bool(":complete", true); + bool elim_root_objs = m_params.get_bool("elim_root_objects", true); + bool elim_inverses = m_params.get_bool("elim_inverses", true); + bool complete = m_params.get_bool("complete", true); purify_arith_proc proc(m_util, m_aux_decls, produce_proofs, elim_root_objs, elim_inverses, complete); proc(*(g.get()), mc, produce_models); @@ -902,10 +902,10 @@ public: tactic * mk_purify_arith_tactic(ast_manager & m, params_ref const & p) { params_ref elim_rem_p = p; - elim_rem_p.set_bool(":elim-rem", true); + elim_rem_p.set_bool("elim-rem", true); params_ref skolemize_p; - skolemize_p.set_bool(":skolemize", false); + skolemize_p.set_bool("skolemize", false); return and_then(using_params(mk_snf_tactic(m, skolemize_p), skolemize_p), using_params(mk_simplify_tactic(m, elim_rem_p), elim_rem_p), diff --git a/src/tactic/arith/recover_01_tactic.cpp b/src/tactic/arith/recover_01_tactic.cpp index a42bedc44..3b1a86345 100644 --- a/src/tactic/arith/recover_01_tactic.cpp +++ b/src/tactic/arith/recover_01_tactic.cpp @@ -58,7 +58,7 @@ class recover_01_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_cls_max_size = p.get_uint(":recover-01-max-bits", 10); + m_cls_max_size = p.get_uint("recover_01_max_bits", 10); } void updt_params(params_ref const & p) { @@ -408,7 +408,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { 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."); + 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, diff --git a/src/tactic/bv/bit_blaster_tactic.cpp b/src/tactic/bv/bit_blaster_tactic.cpp index 63d534cbb..0330141cb 100644 --- a/src/tactic/bv/bit_blaster_tactic.cpp +++ b/src/tactic/bv/bit_blaster_tactic.cpp @@ -36,7 +36,7 @@ class bit_blaster_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_blast_quant = p.get_bool(":blast-quant", false); + m_blast_quant = p.get_bool("blast_quant", false); } void updt_params(params_ref const & p) { @@ -120,10 +120,10 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":blast-mul", CPK_BOOL, "(default: true) bit-blast multipliers (and dividers, remainders)."); - r.insert(":blast-add", CPK_BOOL, "(default: true) bit-blast adders."); - r.insert(":blast-quant", CPK_BOOL, "(default: false) bit-blast quantified variables."); - 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."); + r.insert("blast_mul", CPK_BOOL, "(default: true) bit-blast multipliers (and dividers, remainders)."); + r.insert("blast_add", CPK_BOOL, "(default: true) bit-blast adders."); + r.insert("blast_quant", CPK_BOOL, "(default: false) bit-blast quantified variables."); + 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, diff --git a/src/tactic/bv/bv1_blaster_tactic.cpp b/src/tactic/bv/bv1_blaster_tactic.cpp index 77ab1be31..8dcaf2112 100644 --- a/src/tactic/bv/bv1_blaster_tactic.cpp +++ b/src/tactic/bv/bv1_blaster_tactic.cpp @@ -63,9 +63,9 @@ class bv1_blaster_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_produce_models = p.get_bool(":produce-models", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_produce_models = p.get_bool("produce_models", false); } bool rewrite_patterns() const { UNREACHABLE(); return false; } diff --git a/src/tactic/bv/max_bv_sharing_tactic.cpp b/src/tactic/bv/max_bv_sharing_tactic.cpp index 462c9f3e2..251e2b754 100644 --- a/src/tactic/bv/max_bv_sharing_tactic.cpp +++ b/src/tactic/bv/max_bv_sharing_tactic.cpp @@ -55,9 +55,9 @@ class max_bv_sharing_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_max_args = p.get_uint(":max-args", 128); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_max_args = p.get_uint("max_args", 128); } bool max_steps_exceeded(unsigned num_steps) const { @@ -298,7 +298,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":max-args", CPK_UINT, + r.insert("max_args", CPK_UINT, "(default: 128) maximum number of arguments (per application) that will be considered by the greedy (quadratic) heuristic."); } diff --git a/src/tactic/core/cofactor_elim_term_ite.cpp b/src/tactic/core/cofactor_elim_term_ite.cpp index b39d82201..78d532357 100644 --- a/src/tactic/core/cofactor_elim_term_ite.cpp +++ b/src/tactic/core/cofactor_elim_term_ite.cpp @@ -304,7 +304,7 @@ struct cofactor_elim_term_ite::imp { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } void set_cancel(bool f) { diff --git a/src/tactic/core/ctx_simplify_tactic.cpp b/src/tactic/core/ctx_simplify_tactic.cpp index 91334fd5c..cca21b90e 100644 --- a/src/tactic/core/ctx_simplify_tactic.cpp +++ b/src/tactic/core/ctx_simplify_tactic.cpp @@ -90,10 +90,10 @@ struct ctx_simplify_tactic::imp { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); - m_max_depth = p.get_uint(":max-depth", 1024); - m_bail_on_blowup = p.get_bool(":bail-on-blowup", false); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); + m_max_depth = p.get_uint("max_depth", 1024); + m_bail_on_blowup = p.get_bool("bail_on_blowup", false); } void checkpoint() { @@ -519,7 +519,7 @@ void ctx_simplify_tactic::updt_params(params_ref const & p) { void ctx_simplify_tactic::get_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":max-depth", CPK_UINT, "(default: 1024) maximum term depth."); + r.insert("max_depth", CPK_UINT, "(default: 1024) maximum term depth."); } void ctx_simplify_tactic::operator()(goal_ref const & in, diff --git a/src/tactic/core/elim_term_ite_tactic.cpp b/src/tactic/core/elim_term_ite_tactic.cpp index 4f04859ac..456bad5e0 100644 --- a/src/tactic/core/elim_term_ite_tactic.cpp +++ b/src/tactic/core/elim_term_ite_tactic.cpp @@ -72,7 +72,7 @@ class elim_term_ite_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } }; @@ -160,7 +160,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { insert_max_memory(r); insert_max_steps(r); - r.insert(":max-args", CPK_UINT, + r.insert("max_args", CPK_UINT, "(default: 128) maximum number of arguments (per application) that will be considered by the greedy (quadratic) heuristic."); } diff --git a/src/tactic/core/elim_uncnstr_tactic.cpp b/src/tactic/core/elim_uncnstr_tactic.cpp index 7d15bc7c0..d1dca296a 100644 --- a/src/tactic/core/elim_uncnstr_tactic.cpp +++ b/src/tactic/core/elim_uncnstr_tactic.cpp @@ -881,8 +881,8 @@ class elim_uncnstr_tactic : public tactic { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); } ast_manager & m() { return m_manager; } diff --git a/src/tactic/core/nnf_tactic.cpp b/src/tactic/core/nnf_tactic.cpp index 157c7078e..fdaf03d55 100644 --- a/src/tactic/core/nnf_tactic.cpp +++ b/src/tactic/core/nnf_tactic.cpp @@ -120,7 +120,7 @@ tactic * mk_snf_tactic(ast_manager & m, params_ref const & p) { tactic * mk_nnf_tactic(ast_manager & m, params_ref const & p) { params_ref new_p(p); - new_p.set_sym(":nnf-mode", symbol("full")); + new_p.set_sym("nnf_mode", symbol("full")); TRACE("nnf", tout << "mk_nnf: " << new_p << "\n";); return using_params(mk_snf_tactic(m, p), new_p); } diff --git a/src/tactic/core/propagate_values_tactic.cpp b/src/tactic/core/propagate_values_tactic.cpp index 9ab597dfa..6d9e6ccbd 100644 --- a/src/tactic/core/propagate_values_tactic.cpp +++ b/src/tactic/core/propagate_values_tactic.cpp @@ -44,7 +44,7 @@ class propagate_values_tactic : public tactic { } void updt_params_core(params_ref const & p) { - m_max_rounds = p.get_uint(":max-rounds", 4); + m_max_rounds = p.get_uint("max_rounds", 4); } void updt_params(params_ref const & p) { @@ -237,7 +237,7 @@ public: virtual void collect_param_descrs(param_descrs & r) { th_rewriter::get_param_descrs(r); - r.insert(":max-rounds", CPK_UINT, "(default: 2) maximum number of rounds."); + r.insert("max_rounds", CPK_UINT, "(default: 2) maximum number of rounds."); } virtual void operator()(goal_ref const & in, diff --git a/src/tactic/core/simplify_tactic.cpp b/src/tactic/core/simplify_tactic.cpp index 0408f8c8d..95db962a7 100644 --- a/src/tactic/core/simplify_tactic.cpp +++ b/src/tactic/core/simplify_tactic.cpp @@ -138,7 +138,7 @@ tactic * mk_simplify_tactic(ast_manager & m, params_ref const & p) { tactic * mk_elim_and_tactic(ast_manager & m, params_ref const & p) { params_ref xp = p; - xp.set_bool(":elim-and", true); + xp.set_bool("elim_and", true); return using_params(mk_simplify_tactic(m, xp), xp); } diff --git a/src/tactic/core/solve_eqs_tactic.cpp b/src/tactic/core/solve_eqs_tactic.cpp index aa8fb03c2..995940406 100644 --- a/src/tactic/core/solve_eqs_tactic.cpp +++ b/src/tactic/core/solve_eqs_tactic.cpp @@ -71,9 +71,9 @@ class solve_eqs_tactic : public tactic { ast_manager & m() const { return m_manager; } void updt_params(params_ref const & p) { - m_ite_solver = p.get_bool(":ite-solver", true); - m_theory_solver = p.get_bool(":theory-solver", true); - m_max_occs = p.get_uint(":solve-eqs-max-occs", UINT_MAX); + m_ite_solver = p.get_bool("ite_solver", true); + m_theory_solver = p.get_bool("theory_solver", true); + m_max_occs = p.get_uint("solve_eqs_max_occs", UINT_MAX); } void set_cancel(bool f) { @@ -732,9 +732,9 @@ public: } virtual void collect_param_descrs(param_descrs & r) { - 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."); + 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, diff --git a/src/tactic/core/split_clause_tactic.cpp b/src/tactic/core/split_clause_tactic.cpp index f259ca8ad..5699aa178 100644 --- a/src/tactic/core/split_clause_tactic.cpp +++ b/src/tactic/core/split_clause_tactic.cpp @@ -96,11 +96,11 @@ public: } virtual void updt_params(params_ref const & p) { - m_largest_clause = p.get_bool(":split-largest-clause", false); + m_largest_clause = p.get_bool("split_largest_clause", false); } virtual void collect_param_descrs(param_descrs & r) { - r.insert(":split-largest-clause", CPK_BOOL, "(default: false) split the largest clause in the goal."); + r.insert("split_largest_clause", CPK_BOOL, "(default: false) split the largest clause in the goal."); } virtual void operator()(goal_ref const & in, diff --git a/src/tactic/core/tseitin_cnf_tactic.cpp b/src/tactic/core/tseitin_cnf_tactic.cpp index 2a4f3df2e..b6c4b0655 100644 --- a/src/tactic/core/tseitin_cnf_tactic.cpp +++ b/src/tactic/core/tseitin_cnf_tactic.cpp @@ -122,12 +122,12 @@ class tseitin_cnf_tactic : public tactic { } void updt_params(params_ref const & p) { - m_common_patterns = p.get_bool(":common-patterns", true); - m_distributivity = p.get_bool(":distributivity", true); - m_distributivity_blowup = p.get_uint(":distributivity-blowup", 32); - m_ite_chains = p.get_bool(":ite-chains", true); - m_ite_extra = p.get_bool(":ite-extra", true); - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); + m_common_patterns = p.get_bool("common_patterns", true); + m_distributivity = p.get_bool("distributivity", true); + m_distributivity_blowup = p.get_uint("distributivity_blowup", 32); + m_ite_chains = p.get_bool("ite_chains", true); + m_ite_extra = p.get_bool("ite_extra", true); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); } void push_frame(app * n) { m_frame_stack.push_back(frame(n)); } @@ -881,11 +881,11 @@ public: virtual void collect_param_descrs(param_descrs & r) { 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"); - r.insert(":distributivity-blowup", CPK_UINT, "(default: 32) maximum overhead for applying distributivity during CNF encoding"); - r.insert("ite-chaing", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by identifing if-then-else chains"); - r.insert(":ite-extra", CPK_BOOL, "(default: true) add redundant clauses (that improve unit propagation) when encoding if-then-else formulas"); + 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"); + r.insert("distributivity_blowup", CPK_UINT, "(default: 32) maximum overhead for applying distributivity during CNF encoding"); + r.insert("ite_chaing", CPK_BOOL, "(default: true) minimize the number of auxiliary variables during CNF encoding by identifing if-then-else chains"); + 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, @@ -934,8 +934,8 @@ tactic * mk_tseitin_cnf_core_tactic(ast_manager & m, params_ref const & p) { tactic * mk_tseitin_cnf_tactic(ast_manager & m, params_ref const & p) { params_ref simp_p = p; - simp_p.set_bool(":elim-and", true); - simp_p.set_bool(":blast-distinct", true); + simp_p.set_bool("elim_and", true); + simp_p.set_bool("blast_distinct", true); return or_else(mk_tseitin_cnf_core_tactic(m, p), and_then(using_params(mk_simplify_tactic(m, p), simp_p), mk_tseitin_cnf_core_tactic(m, p))); diff --git a/src/tactic/fpa/fpa2bv_rewriter.h b/src/tactic/fpa/fpa2bv_rewriter.h index 62c6f1a2d..02a667f18 100644 --- a/src/tactic/fpa/fpa2bv_rewriter.h +++ b/src/tactic/fpa/fpa2bv_rewriter.h @@ -54,8 +54,8 @@ struct fpa2bv_rewriter_cfg : public default_rewriter_cfg { } void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint(":max-memory", UINT_MAX)); - m_max_steps = p.get_uint(":max-steps", UINT_MAX); + m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_max_steps = p.get_uint("max_steps", UINT_MAX); } bool max_steps_exceeded(unsigned num_steps) const { diff --git a/src/tactic/fpa/qffpa_tactic.cpp b/src/tactic/fpa/qffpa_tactic.cpp index d034000c4..f3c913ccc 100644 --- a/src/tactic/fpa/qffpa_tactic.cpp +++ b/src/tactic/fpa/qffpa_tactic.cpp @@ -26,7 +26,7 @@ Notes: tactic * mk_qffpa_tactic(ast_manager & m, params_ref const & p) { params_ref sat_simp_p = p; - sat_simp_p .set_bool(":elim-and", true); + sat_simp_p .set_bool("elim_and", true); return and_then(mk_simplify_tactic(m, p), mk_fpa2bv_tactic(m, p), diff --git a/src/tactic/sls/sls_tactic.cpp b/src/tactic/sls/sls_tactic.cpp index 0ad845095..290a0ad35 100644 --- a/src/tactic/sls/sls_tactic.cpp +++ b/src/tactic/sls/sls_tactic.cpp @@ -1363,16 +1363,16 @@ class sls_tactic : public tactic { static void collect_param_descrs(param_descrs & r) { insert_produce_models(r); - r.insert(":sls-restarts", CPK_UINT, "(default: infty) # of SLS restarts."); - r.insert(":random-seed", CPK_UINT, "(default: 0) random seed."); - r.insert(":plateau-limit", CPK_UINT, "(default: 100) SLS plateau limit."); + r.insert("sls_restarts", CPK_UINT, "(default: infty) # of SLS restarts."); + r.insert("random_seed", CPK_UINT, "(default: 0) random seed."); + r.insert("plateau_limit", CPK_UINT, "(default: 100) SLS plateau limit."); } void updt_params(params_ref const & p) { - m_produce_models = p.get_bool(":produce-models", false); - m_max_restarts = p.get_uint(":sls-restarts", -1); - m_tracker.set_random_seed(p.get_uint(":random-seed", 0)); - m_plateau_limit = p.get_uint(":plateau-limit", 100); + m_produce_models = p.get_bool("produce_models", false); + m_max_restarts = p.get_uint("sls_restarts", -1); + m_tracker.set_random_seed(p.get_uint("random_seed", 0)); + m_plateau_limit = p.get_uint("plateau_limit", 100); } void checkpoint() { @@ -1854,28 +1854,28 @@ tactic * mk_sls_tactic(ast_manager & m, params_ref const & p) { tactic * mk_preamble(ast_manager & m, params_ref const & p) { params_ref main_p; - main_p.set_bool(":elim-and", true); - // main_p.set_bool(":pull-cheap-ite", true); - main_p.set_bool(":push-ite-bv", true); - main_p.set_bool(":blast-distinct", true); - // main_p.set_bool(":udiv2mul", true); - main_p.set_bool(":hi-div0", true); + main_p.set_bool("elim_and", true); + // main_p.set_bool("pull-cheap_ite", true); + main_p.set_bool("push_ite_bv", true); + main_p.set_bool("blast_distinct", true); + // main_p.set_bool("udiv2mul", true); + main_p.set_bool("hi_div0", true); params_ref simp2_p = p; - simp2_p.set_bool(":som", true); - simp2_p.set_bool(":pull-cheap-ite", true); - simp2_p.set_bool(":push-ite-bv", false); - simp2_p.set_bool(":local-ctx", true); - simp2_p.set_uint(":local-ctx-limit", 10000000); + simp2_p.set_bool("som", true); + simp2_p.set_bool("pull_cheap_ite", true); + simp2_p.set_bool("push_ite_bv", false); + simp2_p.set_bool("local_ctx", true); + simp2_p.set_uint("local_ctx_limit", 10000000); params_ref hoist_p; - hoist_p.set_bool(":hoist-mul", true); - // hoist_p.set_bool(":hoist-cmul", true); - hoist_p.set_bool(":som", false); + hoist_p.set_bool("hoist_mul", true); + // hoist_p.set_bool("hoist_cmul", true); + hoist_p.set_bool("som", false); params_ref gaussian_p; // conservative gaussian elimination. - gaussian_p.set_uint(":gaussian-max-occs", 2); + gaussian_p.set_uint("gaussian_max_occs", 2); return and_then(and_then(mk_simplify_tactic(m), mk_propagate_values_tactic(m), @@ -1890,8 +1890,8 @@ tactic * mk_preamble(ast_manager & m, params_ref const & p) { tactic * mk_qfbv_sls_tactic(ast_manager & m, params_ref const & p) { params_ref sls_p(p); - sls_p.set_uint(":sls-restarts", 10000); - sls_p.set_uint(":plateau-limit", 100); + sls_p.set_uint("sls_restarts", 10000); + sls_p.set_uint("plateau_limit", 100); tactic * t = and_then(mk_preamble(m, p), using_params(mk_sls_tactic(m, p), sls_p)); diff --git a/src/tactic/smtlogics/qfnra_tactic.cpp b/src/tactic/smtlogics/qfnra_tactic.cpp index d13d9e198..a2877eefa 100644 --- a/src/tactic/smtlogics/qfnra_tactic.cpp +++ b/src/tactic/smtlogics/qfnra_tactic.cpp @@ -25,7 +25,7 @@ Notes: static tactic * mk_qfnra_sat_solver(ast_manager& m, params_ref const& p, unsigned bv_size) { params_ref nra2sat_p = p; - nra2sat_p.set_uint(":nla2bv-max-bv-size", p.get_uint(":nla2bv-max-bv-size", bv_size)); + nra2sat_p.set_uint(":nla2bv-max-bv-size", p.get_uint("nla2bv_max_bv_size", bv_size)); return and_then(mk_nla2bv_tactic(m, nra2sat_p), mk_smt_tactic(), diff --git a/src/tactic/smtlogics/quant_tactics.cpp b/src/tactic/smtlogics/quant_tactics.cpp index 157202442..4bb896c74 100644 --- a/src/tactic/smtlogics/quant_tactics.cpp +++ b/src/tactic/smtlogics/quant_tactics.cpp @@ -72,7 +72,7 @@ tactic * mk_uflra_tactic(ast_manager & m, params_ref const & p) { tactic * mk_auflia_tactic(ast_manager & m, params_ref const & p) { params_ref qi_p; qi_p.set_str(":qi-cost", "0"); - TRACE("qi_cost", qi_p.display(tout); tout << "\n" << qi_p.get_str(":qi-cost", "") << "\n";); + TRACE("qi_cost", qi_p.display(tout); tout << "\n" << qi_p.get_str("qi_cost", "") << "\n";); tactic * st = and_then(mk_no_solve_eq_preprocessor(m), or_else(and_then(fail_if(mk_gt(mk_num_exprs_probe(), mk_const_probe(static_cast(128)))), using_params(mk_smt_tactic(), qi_p), diff --git a/src/tactic/ufbv/macro_finder_tactic.cpp b/src/tactic/ufbv/macro_finder_tactic.cpp index 3872a3a2e..14a42ec51 100644 --- a/src/tactic/ufbv/macro_finder_tactic.cpp +++ b/src/tactic/ufbv/macro_finder_tactic.cpp @@ -102,7 +102,7 @@ class macro_finder_tactic : public tactic { } void updt_params(params_ref const & p) { - m_elim_and = p.get_bool(":elim-and", false); + m_elim_and = p.get_bool("elim_and", false); } }; @@ -131,7 +131,7 @@ public: 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."); + r.insert("elim_and", CPK_BOOL, "(default: false) eliminate conjunctions during (internal) calls to the simplifier."); } virtual void operator()(goal_ref const & in, diff --git a/src/test/dl_product_relation.cpp b/src/test/dl_product_relation.cpp index 2711f3e00..ac895dacf 100644 --- a/src/test/dl_product_relation.cpp +++ b/src/test/dl_product_relation.cpp @@ -128,7 +128,7 @@ namespace datalog { dl_decl_util dl_util(m); relation_manager & rmgr = ctx.get_rmanager(); - relation_plugin & rel_plugin = *ctx.get_rmanager().get_relation_plugin(params.get_sym(":default-relation", symbol("sparse"))); + relation_plugin & rel_plugin = *ctx.get_rmanager().get_relation_plugin(params.get_sym("default_relation", symbol("sparse"))); SASSERT(&rel_plugin); finite_product_relation_plugin plg(rel_plugin, rmgr); diff --git a/src/util/double_manager.h b/src/util/double_manager.h index a6a72cc6f..5334e60df 100644 --- a/src/util/double_manager.h +++ b/src/util/double_manager.h @@ -40,7 +40,7 @@ public: double_manager(params_ref const & p = params_ref()) { updt_params(p); } void updt_params(params_ref const & p) { - m_zero_tolerance = p.get_double(":zero-tolerance", 0.00000001); + m_zero_tolerance = p.get_double("zero_tolerance", 0.00000001); } static void reset(double & a) { a = 0.0; } diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp new file mode 100644 index 000000000..556e84734 --- /dev/null +++ b/src/util/gparams.cpp @@ -0,0 +1,249 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + gparams.cpp + +Abstract: + + Global parameter management. + +Author: + + Leonardo (leonardo) 2012-11-29 + +Notes: + +--*/ +#include"gparams.h" +#include"dictionary.h" + +extern void gparams_register_modules(); + +struct gparams::imp { + dictionary m_module_param_descrs; + param_descrs m_param_descrs; + dictionary m_module_params; + params_ref m_params; + params_ref m_empty; +public: + imp() { + } + + ~imp() { + { + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + dealloc(it->m_value); + } + } + { + dictionary::iterator it = m_module_params.begin(); + dictionary::iterator end = m_module_params.end(); + for (; it != end; ++it) { + dealloc(it->m_value); + } + } + } + + void register_global(param_descrs & d) { + m_param_descrs.copy(d); + } + + void register_module(char const * module_name, param_descrs * d) { + symbol s(module_name); + param_descrs * old_d; + if (m_module_param_descrs.find(s, old_d)) { + old_d->copy(*d); + dealloc(d); + } + else { + m_module_param_descrs.insert(s, d); + } + } + + void display(std::ostream & out, unsigned indent, bool smt2_style) { + m_param_descrs.display(out, indent, smt2_style); + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + out << "[module] " << it->m_key << "\n"; + it->m_value->display(out, indent + 4, smt2_style); + } + } + + void normalize(char const * name, /* out */ symbol & mod_name, /* out */ symbol & param_name) { + if (*name == ':') + name++; + std::string tmp = name; + unsigned n = tmp.size(); + for (unsigned i = 0; i < n; i++) { + if (tmp[i] >= 'A' && tmp[i] <= 'Z') + tmp[i] = tmp[i] - 'A' + 'a'; + else if (tmp[i] == '-') + tmp[i] = '_'; + } + for (unsigned i = 0; i < n; i++) { + if (tmp[i] == '.') { + param_name = tmp.substr(i+1).c_str(); + tmp.resize(i); + mod_name = tmp.c_str(); + return; + } + } + param_name = tmp.c_str(); + mod_name = symbol::null; + } + + params_ref & get_params(symbol const & mod_name) { + if (mod_name == symbol::null) { + return m_params; + } + else { + params_ref * p; + if (m_module_params.find(mod_name, p)) { + return *p; + } + else { + p = alloc(params_ref); + m_module_params.insert(mod_name, p); + return *p; + } + } + } + + void set(param_descrs const & d, symbol const & param_name, char const * value, symbol const & mod_name) { + param_kind k = d.get_kind(param_name); + params_ref & ps = get_params(mod_name); + if (k == CPK_INVALID) { + if (mod_name == symbol::null) + throw default_exception("unknown parameter '%s'", param_name.bare_str()); + else + throw default_exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + } + else if (k == CPK_UINT) { + long val = strtol(value, 0, 10); + ps.set_uint(param_name, static_cast(val)); + } + else if (k == CPK_BOOL) { + if (strcmp(value, "true") == 0) { + ps.set_bool(param_name, true); + } + else if (strcmp(value, "false") == 0) { + ps.set_bool(param_name, false); + } + else { + if (mod_name == symbol::null) + throw default_exception("invalid value '%s' for Boolean parameter '%s'", value, param_name.bare_str()); + else + throw default_exception("invalid value '%s' for Boolean parameter '%s' at module '%s'", value, param_name.bare_str(), mod_name.bare_str()); + } + } + else if (k == CPK_SYMBOL) { + ps.set_sym(param_name, symbol(value)); + } + else if (k == CPK_STRING) { + ps.set_str(param_name, value); + } + else { + if (mod_name == symbol::null) + throw default_exception("unsupported parameter type '%s'", param_name.bare_str()); + else + throw default_exception("unsupported parameter type '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + } + } + + void set(char const * name, char const * value) { + symbol m, p; + normalize(name, m, p); + if (m == symbol::null) { + set(m_param_descrs, p, value, m); + } + else { + param_descrs * d; + if (m_module_param_descrs.find(m, d)) { + set(*d, p, value, m); + } + else { + throw default_exception("invalid parameter, unknown module '%s'", m.bare_str()); + } + } + } + + std::string get_value(char const * name) { + + } + + + params_ref const & get_module(symbol const & module_name) { + params_ref * ps = 0; + if (m_module_params.find(module_name, ps)) { + return *ps; + } + else { + return m_empty; + } + } + + params_ref const & get() { + return m_params; + } + +}; + +gparams::imp * gparams::g_imp = 0; + +void gparams::set(char const * name, char const * value) { + SASSERT(g_imp != 0); + g_imp->set(name, value); +} + +std::string gparams::get_value(char const * name) { + SASSERT(g_imp != 0); + g_imp->get_value(name); +} + +void gparams::register_global(param_descrs & d) { + SASSERT(g_imp != 0); + g_imp->register_global(d); +} + +void gparams::register_module(char const * module_name, param_descrs * d) { + SASSERT(g_imp != 0); + g_imp->register_module(module_name, d); +} + +params_ref const & gparams::get_module(char const * module_name) { + return get_module(symbol(module_name)); +} + +params_ref const & gparams::get_module(symbol const & module_name) { + SASSERT(g_imp != 0); + return g_imp->get_module(module_name); +} + +params_ref const & gparams::get() { + SASSERT(g_imp != 0); + return g_imp->get(); +} + +void gparams::display(std::ostream & out, unsigned indent, bool smt2_style) { + SASSERT(g_imp != 0); + g_imp->display(out, indent, smt2_style); +} + +void gparams::init() { + g_imp = alloc(imp); + gparams_register_modules(); +} + +void gparams::finalize() { + if (g_imp != 0) { + dealloc(g_imp); + g_imp = 0; + } +} + + diff --git a/src/util/gparams.h b/src/util/gparams.h new file mode 100644 index 000000000..e02a8daa8 --- /dev/null +++ b/src/util/gparams.h @@ -0,0 +1,122 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + gparams.h + +Abstract: + + Global parameter management. + +Author: + + Leonardo (leonardo) 2012-11-29 + +Notes: + +--*/ +#ifndef _GPARAMS_H_ +#define _GPARAMS_H_ + +#include"params.h" + +class gparams { + struct imp; + static imp * g_imp; + typedef z3_exception exception; +public: + /** + \brief Set a global parameter \c name with \c value. + + The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'. + The character '.' is used a delimiter (more later). + + The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. + Thus, the following parameter names are considered equivalent: "auto-config" and "AUTO_CONFIG". + + This function can be used to set parameters for a specific Z3 module. + This can be done by using .. + For example: + set_global_param('pp.decimal', 'true') + will set the parameter "decimal" in the module "pp" to true. + + An exception is thrown if the the parameter name is unknown, or if the value is incorrect. + */ + static void set(char const * name, char const * value); + + /** + \brief Auxiliary method used to implement get-option in SMT 2.0 front-end. + + If the parameter is not set, then it just returns 'default'. + + An exception is thrown if the the parameter name is unknown. + */ + static std::string get_value(char const * name); + + /** + \brief Register additional global parameters + + This is an auxiliary function used by our automatic code generator. + Example: the directive REG_PARAMS('collect_param_descrs') + "tells" the automatic code generator how to register the additional global parameters. + */ + static void register_global(param_descrs & d); + + /** + \brief Register parameter descriptions for a Z3 module. + The parameters of a given Z3 module can only be set using #set_global_param if + they are registered in this module using this function. + + This is an auxiliary function used by our automatic code generator. + Each module will contain directives (in comments) such as + Example: the directive REG_MODULE_PARAMS('nlsat', 'nlsat::solver::collect_param_descrs') + "tells" the automatic code generator how to register the parameters for the given + module. + */ + static void register_module(char const * module_name, param_descrs * d); + + /** + \brief Retrieves the parameters associated with the given module. + + Example: + // The following command sets the parameter "decimal" in the module "pp" to true. + set_global_param("pp.decimal", "true"); + ... + // The following command will return the global parameters that were set for the module "pp". + // In this example "p" will contain "decimal" -> true after executing this function. + params_ref const & p = get_module_params("pp") + */ + static params_ref const & get_module(char const * module_name); + static params_ref const & get_module(symbol const & module_name); + + /** + \brief Return the global parameter set (i.e., parameters that are not associated with any particular module). + */ + static params_ref const & get(); + + /** + \brief Dump information about available parameters in the given output stream. + */ + static void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false); + + /** + \brief Initialize the global parameter management module. + + Remark: I set a priority in the initialization, because this module must be initialized + after the core modules such as symbol. + ADD_INITIALIZER('gparams::init();', 1) + */ + static void init(); + + /** + \brief Finalize the global parameter management module. + + ADD_FINALIZER('gparams::finalize();'); + */ + static void finalize(); +}; + + + +#endif diff --git a/src/util/params.cpp b/src/util/params.cpp index ae7f0c830..b143a82dd 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -60,7 +60,7 @@ struct param_descrs::imp { bool operator()(symbol const & s1, symbol const & s2) const { return strcmp(s1.bare_str(), s2.bare_str()) < 0; } }; - void display(std::ostream & out, unsigned indent) const { + void display(std::ostream & out, unsigned indent, bool smt2_style) const { svector names; dictionary::iterator it = m_info.begin(); dictionary::iterator end = m_info.end(); @@ -72,7 +72,20 @@ struct param_descrs::imp { svector::iterator end2 = names.end(); for (; it2 != end2; ++it2) { for (unsigned i = 0; i < indent; i++) out << " "; - out << *it2; + if (smt2_style) + out << ':'; + char const * s = it2->bare_str(); + unsigned n = strlen(s); + for (unsigned i = 0; i < n; i++) { + if (smt2_style && s[i] == '_') + out << '-'; + else if (!smt2_style && s[i] == '-') + out << '_'; + else if (s[i] >= 'A' && s[i] <= 'Z') + out << (s[i] - 'A' + 'a'); + else + out << s[i]; + } info d; d.second = 0; m_info.find(*it2, d); @@ -80,6 +93,15 @@ struct param_descrs::imp { out << " (" << d.first << ") " << d.second << "\n"; } } + + void copy(param_descrs & other) { + dictionary::iterator it = other.m_imp->m_info.begin(); + dictionary::iterator end = other.m_imp->m_info.end(); + for (; it != end; ++it) { + insert(it->m_key, it->m_value.first, it->m_value.second); + } + } + }; param_descrs::param_descrs() { @@ -90,6 +112,10 @@ param_descrs::~param_descrs() { dealloc(m_imp); } +void param_descrs::copy(param_descrs & other) { + m_imp->copy(other); +} + void param_descrs::insert(symbol const & name, param_kind k, char const * descr) { m_imp->insert(name, k, descr); } @@ -122,28 +148,28 @@ symbol param_descrs::get_param_name(unsigned i) const { return m_imp->get_param_name(i); } -void param_descrs::display(std::ostream & out, unsigned indent) const { - return m_imp->display(out, indent); +void param_descrs::display(std::ostream & out, unsigned indent, bool smt2_style) const { + return m_imp->display(out, indent, smt2_style); } void insert_max_memory(param_descrs & r) { - r.insert(":max-memory", CPK_UINT, "(default: infty) maximum amount of memory in megabytes."); + r.insert("max_memory", CPK_UINT, "(default: infty) maximum amount of memory in megabytes."); } void insert_max_steps(param_descrs & r) { - r.insert(":max-steps", CPK_UINT, "(default: infty) maximum number of steps."); + r.insert("max_steps", CPK_UINT, "(default: infty) maximum number of steps."); } void insert_produce_models(param_descrs & r) { - r.insert(":produce-models", CPK_BOOL, "(default: false) model generation."); + r.insert("produce_models", CPK_BOOL, "(default: false) model generation."); } void insert_produce_proofs(param_descrs & r) { - r.insert(":produce-proofs", CPK_BOOL, "(default: false) proof generation."); + r.insert("produce_proofs", CPK_BOOL, "(default: false) proof generation."); } void insert_timeout(param_descrs & r) { - r.insert(":timeout", CPK_UINT, "(default: infty) timeout in milliseconds."); + r.insert("timeout", CPK_UINT, "(default: infty) timeout in milliseconds."); } class params { @@ -255,6 +281,39 @@ public: } out << ")"; } + + void display(std::ostream & out, symbol const & k) const { + svector::const_iterator it = m_entries.begin(); + svector::const_iterator end = m_entries.end(); + for (; it != end; ++it) { + if (it->first != k) + continue; + switch (it->second.m_kind) { + case CPK_BOOL: + out << it->second.m_bool_value; + return; + case CPK_UINT: + out << it->second.m_uint_value; + return; + case CPK_DOUBLE: + out << it->second.m_double_value; + return; + case CPK_NUMERAL: + out << *(it->second.m_rat_value); + return; + case CPK_SYMBOL: + out << symbol::mk_symbol_from_c_ptr(it->second.m_sym_value); + return; + case CPK_STRING: + out << it->second.m_str_value; + return; + default: + out << "internal"; + return; + } + } + out << "default"; + } }; params_ref::~params_ref() { @@ -274,6 +333,17 @@ void params_ref::display(std::ostream & out) const { out << "(params)"; } +void params_ref::display(std::ostream & out, char const * k) const { + display(out, symbol(k)); +} + +void params_ref::display(std::ostream & out, symbol const & k) const { + if (m_params) + m_params->display(out, k); + else + out << "default"; +} + void params_ref::validate(param_descrs const & p) const { if (m_params) m_params->validate(p); diff --git a/src/util/params.h b/src/util/params.h index 66c4e7c7a..f587ed862 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -79,6 +79,14 @@ public: void display(std::ostream & out) const; void validate(param_descrs const & p) const; + + /* + \brief Display the value of the given parameter. + + It displays 'default' if k is not in the parameter set. + */ + void display(std::ostream & out, char const * k); + void display(std::ostream & out, symbol const & k); }; inline std::ostream & operator<<(std::ostream & out, params_ref const & ref) { @@ -92,13 +100,14 @@ class param_descrs { public: param_descrs(); ~param_descrs(); + void copy(param_descrs & other); void insert(char const * name, param_kind k, char const * descr); void insert(symbol const & name, param_kind k, char const * descr); void erase(char const * name); void erase(symbol const & name); param_kind get_kind(char const * name) const; param_kind get_kind(symbol const & name) const; - void display(std::ostream & out, unsigned indent = 0) const; + void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false) const; unsigned size() const; symbol get_param_name(unsigned idx) const; }; From 722cce0cff4b27ef7e4319fd5216a4715ac9bd56 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Thu, 29 Nov 2012 17:52:07 -0800 Subject: [PATCH 04/34] checkpoint Signed-off-by: Leonardo de Moura --- src/util/gparams.cpp | 15 +++++++++++++-- src/util/gparams.h | 5 ++++- src/util/params.h | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 556e84734..27fdd828b 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -173,7 +173,8 @@ public: } std::string get_value(char const * name) { - + // TODO + return ""; } @@ -200,9 +201,19 @@ void gparams::set(char const * name, char const * value) { g_imp->set(name, value); } +void gparams::set(symbol const & name, char const * value) { + SASSERT(g_imp != 0); + g_imp->set(name.bare_str(), value); +} + std::string gparams::get_value(char const * name) { SASSERT(g_imp != 0); - g_imp->get_value(name); + return g_imp->get_value(name); +} + +std::string gparams::get_value(symbol const & name) { + SASSERT(g_imp != 0); + return g_imp->get_value(name.bare_str()); } void gparams::register_global(param_descrs & d) { diff --git a/src/util/gparams.h b/src/util/gparams.h index e02a8daa8..7112e67f9 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -24,8 +24,9 @@ Notes: class gparams { struct imp; static imp * g_imp; - typedef z3_exception exception; public: + typedef default_exception exception; + /** \brief Set a global parameter \c name with \c value. @@ -44,6 +45,7 @@ public: An exception is thrown if the the parameter name is unknown, or if the value is incorrect. */ static void set(char const * name, char const * value); + static void set(symbol const & name, char const * value); /** \brief Auxiliary method used to implement get-option in SMT 2.0 front-end. @@ -53,6 +55,7 @@ public: An exception is thrown if the the parameter name is unknown. */ static std::string get_value(char const * name); + static std::string get_value(symbol const & name); /** \brief Register additional global parameters diff --git a/src/util/params.h b/src/util/params.h index f587ed862..616f316bd 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -85,8 +85,8 @@ public: It displays 'default' if k is not in the parameter set. */ - void display(std::ostream & out, char const * k); - void display(std::ostream & out, symbol const & k); + void display(std::ostream & out, char const * k) const; + void display(std::ostream & out, symbol const & k) const; }; inline std::ostream & operator<<(std::ostream & out, params_ref const & ref) { From caf14b96d4aca73435440da7ed39cb67d2d99563 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 11:30:20 -0800 Subject: [PATCH 05/34] moving to gparams... Signed-off-by: Leonardo de Moura --- src/api/api_config_params.cpp | 66 ++++++++--------------------------- src/api/api_config_params.h | 2 -- 2 files changed, 14 insertions(+), 54 deletions(-) diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 550212cf9..7a0303234 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -23,21 +23,14 @@ Revision History: #include"api_util.h" #include"cmd_context.h" #include"symbol.h" +#include"gparams.h" namespace api { - config_params::config_params(): - m_ini(false /* do not abort on errors */) { - register_verbosity_level(m_ini); - register_warning(m_ini); - m_params.register_params(m_ini); - register_pp_params(m_ini); + config_params::config_params() { } config_params::config_params(front_end_params const & p):m_params(p) { - register_verbosity_level(m_ini); - register_warning(m_ini); - register_pp_params(m_ini); } }; @@ -56,66 +49,35 @@ extern "C" { } void Z3_API Z3_set_param_value(Z3_config c, char const * param_id, char const * param_value) { + // REMARK: we don't need Z3_config anymore try { LOG_Z3_set_param_value(c, param_id, param_value); - api::config_params* p = reinterpret_cast(c); - if (param_id != 0 && param_id[0] == ':') { - // Allow SMT2 style paramater names such as :model, :relevancy, etc - std::string new_param_id = smt2_keyword_to_param(symbol(param_id)); - p->m_ini.set_param_value(new_param_id.c_str(), param_value); - } - else { - p->m_ini.set_param_value(param_id, param_value); - } + gparams::set(param_id, param_value); } - catch (set_get_param_exception & ex) { + catch (gparams::exception & ex) { // The error handler was not set yet. // Just throw a warning. std::ostringstream buffer; - buffer << "Error setting " << param_id << ", " << ex.get_msg(); + buffer << "Error setting " << param_id << ", " << ex.msg(); warning_msg(buffer.str().c_str()); } } void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value) { + Z3_TRY; LOG_Z3_update_param_value(c, param_id, param_value); RESET_ERROR_CODE(); - ini_params ini; - mk_c(c)->fparams().register_params(ini); - register_pp_params(ini); - register_verbosity_level(ini); - register_warning(ini); - if (mk_c(c)->has_solver()) { - ini.freeze(); - } - if (param_id != 0 && param_id[0] == ':') { - // Allow SMT2 style paramater names such as :model, :relevancy, etc - std::string new_param_id = smt2_keyword_to_param(symbol(param_id)); - ini.set_param_value(new_param_id.c_str(), param_value); - } - else { - ini.set_param_value(param_id, param_value); - } - memory::set_high_watermark(static_cast(mk_c(c)->fparams().m_memory_high_watermark)*1024*1024); - memory::set_max_size(static_cast(mk_c(c)->fparams().m_memory_max_size)*1024*1024); + gparams::set(param_id, param_value); + // TODO: set memory limits + // memory::set_high_watermark(static_cast(mk_c(c)->fparams().m_memory_high_watermark)*1024*1024); + // memory::set_max_size(static_cast(mk_c(c)->fparams().m_memory_max_size)*1024*1024); + Z3_CATCH; } Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) { LOG_Z3_get_param_value(c, param_id, param_value); - ini_params ini; - mk_c(c)->fparams().register_params(ini); - register_verbosity_level(ini); - register_pp_params(ini); - register_warning(ini); - std::string param_value_s; - if (!ini.get_param_value(param_id, param_value_s)) { - if (param_value) *param_value = 0; - return false; - } - if (param_value) { - *param_value = mk_c(c)->mk_external_string(param_value_s); - } - return true; + // TODO: we don't really have support for that anymore. + return false; } }; diff --git a/src/api/api_config_params.h b/src/api/api_config_params.h index 22e713c50..99ded289d 100644 --- a/src/api/api_config_params.h +++ b/src/api/api_config_params.h @@ -18,14 +18,12 @@ Revision History: #ifndef _API_CONFIG_PARAMS_H_ #define _API_CONFIG_PARAMS_H_ -#include"ini_file.h" #include"front_end_params.h" namespace api { class config_params { public: - ini_params m_ini; front_end_params m_params; config_params(); config_params(front_end_params const & p); From 9246a7a6733104f067478eb1c26a16c85426dce3 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 13:14:42 -0800 Subject: [PATCH 06/34] checkpoint Signed-off-by: Leonardo de Moura --- src/util/params.cpp | 138 +++++++++++++++++++++++++++++++++++++++----- src/util/params.h | 18 ++++-- 2 files changed, 138 insertions(+), 18 deletions(-) diff --git a/src/util/params.cpp b/src/util/params.cpp index b143a82dd..264149e4b 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -22,18 +22,35 @@ Notes: #include"dictionary.h" struct param_descrs::imp { - typedef std::pair info; + struct info { + param_kind m_kind; + char const * m_descr; + char const * m_default; + + info(param_kind k, char const * descr, char const * def): + m_kind(k), + m_descr(descr), + m_default(def) { + } + + info(): + m_kind(CPK_INVALID), + m_descr(0), + m_default(0) { + } + }; + dictionary m_info; svector m_names; - void insert(symbol const & name, param_kind k, char const * descr) { + void insert(symbol const & name, param_kind k, char const * descr, char const * def) { SASSERT(!name.is_numerical()); info i; if (m_info.find(name, i)) { - SASSERT(i.first == k); + SASSERT(i.m_kind == k); return; } - m_info.insert(name, info(k, descr)); + m_info.insert(name, info(k, descr, def)); m_names.push_back(name); } @@ -44,10 +61,24 @@ struct param_descrs::imp { param_kind get_kind(symbol const & name) const { info i; if (m_info.find(name, i)) - return i.first; + return i.m_kind; return CPK_INVALID; } + char const * get_descr(symbol const & name) const { + info i; + if (m_info.find(name, i)) + return i.m_descr; + return 0; + } + + char const * get_default(symbol const & name) const { + info i; + if (m_info.find(name, i)) + return i.m_default; + return 0; + } + unsigned size() const { return m_names.size(); } @@ -87,10 +118,12 @@ struct param_descrs::imp { out << s[i]; } info d; - d.second = 0; m_info.find(*it2, d); - SASSERT(d.second); - out << " (" << d.first << ") " << d.second << "\n"; + SASSERT(d.m_descr); + out << " (" << d.m_kind << ") " << d.m_descr; + if (d.m_default != 0) + out << " (default: " << d.m_default << ")"; + out << "\n"; } } @@ -98,7 +131,7 @@ struct param_descrs::imp { dictionary::iterator it = other.m_imp->m_info.begin(); dictionary::iterator end = other.m_imp->m_info.end(); for (; it != end; ++it) { - insert(it->m_key, it->m_value.first, it->m_value.second); + insert(it->m_key, it->m_value.m_kind, it->m_value.m_descr, it->m_value.m_default); } } @@ -116,12 +149,28 @@ void param_descrs::copy(param_descrs & other) { m_imp->copy(other); } -void param_descrs::insert(symbol const & name, param_kind k, char const * descr) { - m_imp->insert(name, k, descr); +void param_descrs::insert(symbol const & name, param_kind k, char const * descr, char const * def) { + m_imp->insert(name, k, descr, def); } -void param_descrs::insert(char const * name, param_kind k, char const * descr) { - insert(symbol(name), k, descr); +void param_descrs::insert(char const * name, param_kind k, char const * descr, char const * def) { + insert(symbol(name), k, descr, def); +} + +char const * param_descrs::get_descr(char const * name) const { + return get_descr(symbol(name)); +} + +char const * param_descrs::get_descr(symbol const & name) const { + return m_imp->get_descr(name); +} + +char const * param_descrs::get_default(char const * name) const { + return get_default(symbol(name)); +} + +char const * param_descrs::get_default(symbol const & name) const { + return m_imp->get_default(name); } void param_descrs::erase(symbol const & name) { @@ -235,6 +284,12 @@ public: symbol get_sym(symbol const & k, symbol const & _default) const; symbol get_sym(char const * k, symbol const & _default) const; + bool get_bool(char const * k, params_ref const & fallback, bool _default) const; + unsigned get_uint(char const * k, params_ref const & fallback, unsigned _default) const; + double get_double(char const * k, params_ref const & fallback, double _default) const; + char const * get_str(char const * k, params_ref const & fallback, char const * _default) const; + symbol get_sym(char const * k, params_ref const & fallback, symbol const & _default) const; + // setters void set_bool(symbol const & k, bool v); void set_bool(char const * k, bool v); @@ -372,7 +427,7 @@ void params_ref::copy_core(params const * src) { return; svector::const_iterator it = src->m_entries.begin(); svector::const_iterator end = src->m_entries.end(); - for (; it != end; ++it) { + for (; it != end; ++it) { switch (it->second.m_kind) { case CPK_BOOL: m_params->set_bool(it->first, it->second.m_bool_value); @@ -440,6 +495,26 @@ symbol params_ref::get_sym(char const * k, symbol const & _default) const { return m_params ? m_params->get_sym(k, _default) : _default; } +bool params_ref::get_bool(char const * k, params_ref const & fallback, bool _default) const { + return m_params ? m_params->get_bool(k, fallback, _default) : fallback.get_bool(k, _default); +} + +unsigned params_ref::get_uint(char const * k, params_ref const & fallback, unsigned _default) const { + return m_params ? m_params->get_uint(k, fallback, _default) : fallback.get_uint(k, _default); +} + +double params_ref::get_double(char const * k, params_ref const & fallback, double _default) const { + return m_params ? m_params->get_double(k, fallback, _default) : fallback.get_double(k, _default); +} + +char const * params_ref::get_str(char const * k, params_ref const & fallback, char const * _default) const { + return m_params ? m_params->get_str(k, fallback, _default) : fallback.get_str(k, _default); +} + +symbol params_ref::get_sym(char const * k, params_ref const & fallback, symbol const & _default) const { + return m_params ? m_params->get_sym(k, fallback, _default) : fallback.get_sym(k, _default); +} + bool params_ref::empty() const { if (!m_params) return true; @@ -684,6 +759,41 @@ symbol params::get_sym(char const * k, symbol const & _default) const { GET_VALUE(return symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);, CPK_SYMBOL); } +#define GET_VALUE2(MATCH_CODE, KIND) { \ + if (!empty()) { \ + TRAVERSE_CONST_ENTRIES(if (it->first == k && it->second.m_kind == KIND) { \ + MATCH_CODE \ + }); \ + } \ +} + +#define GET_SIMPLE_VALUE2(FIELD_NAME, KIND) GET_VALUE2(return it->second.FIELD_NAME;, KIND) + +bool params::get_bool(char const * k, params_ref const & fallback, bool _default) const { + GET_SIMPLE_VALUE2(m_bool_value, CPK_BOOL); + return fallback.get_bool(k, _default); +} + +unsigned params::get_uint(char const * k, params_ref const & fallback, unsigned _default) const { + GET_SIMPLE_VALUE2(m_uint_value, CPK_UINT); + return fallback.get_uint(k, _default); +} + +double params::get_double(char const * k, params_ref const & fallback, double _default) const { + GET_SIMPLE_VALUE2(m_double_value, CPK_DOUBLE); + return fallback.get_double(k, _default); +} + +char const * params::get_str(char const * k, params_ref const & fallback, char const * _default) const { + GET_SIMPLE_VALUE2(m_str_value, CPK_STRING); + return fallback.get_str(k, _default); +} + +symbol params::get_sym(char const * k, params_ref const & fallback, symbol const & _default) const { + GET_VALUE2(return symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);, CPK_SYMBOL); + return fallback.get_sym(k, _default); +} + #define SET_VALUE(MATCH_CODE, ADD_CODE) { \ TRAVERSE_ENTRIES(if (it->first == k) { \ MATCH_CODE \ diff --git a/src/util/params.h b/src/util/params.h index 616f316bd..747b23e39 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -38,10 +38,10 @@ public: params_ref & operator=(params_ref const & p); - // copy params from p + // copy params from src void copy(params_ref const & src); void append(params_ref const & src) { copy(src); } - + bool get_bool(symbol const & k, bool _default) const; bool get_bool(char const * k, bool _default) const; unsigned get_uint(symbol const & k, unsigned _default) const; @@ -55,6 +55,12 @@ public: symbol get_sym(symbol const & k, symbol const & _default) const; symbol get_sym(char const * k, symbol const & _default) const; + bool get_bool(char const * k, params_ref const & fallback, bool _default) const; + unsigned get_uint(char const * k, params_ref const & fallback, unsigned _default) const; + double get_double(char const * k, params_ref const & fallback, double _default) const; + char const * get_str(char const * k, params_ref const & fallback, char const * _default) const; + symbol get_sym(char const * k, params_ref const & fallback, symbol const & _default) const; + bool empty() const; bool contains(symbol const & k) const; bool contains(char const * k) const; @@ -101,12 +107,16 @@ public: param_descrs(); ~param_descrs(); void copy(param_descrs & other); - void insert(char const * name, param_kind k, char const * descr); - void insert(symbol const & name, param_kind k, char const * descr); + void insert(char const * name, param_kind k, char const * descr, char const * def = 0); + void insert(symbol const & name, param_kind k, char const * descr, char const * def = 0); void erase(char const * name); void erase(symbol const & name); param_kind get_kind(char const * name) const; param_kind get_kind(symbol const & name) const; + char const * get_descr(char const * name) const; + char const * get_descr(symbol const & name) const; + char const * get_default(char const * name) const; + char const * get_default(symbol const & name) const; void display(std::ostream & out, unsigned indent = 0, bool smt2_style=false) const; unsigned size() const; symbol get_param_name(unsigned idx) const; From 4f9442864a846d5b934157a6c6b38e696fc0c04d Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 15:31:40 -0800 Subject: [PATCH 07/34] auto generation of parameter helper Signed-off-by: Leonardo de Moura --- .gitignore | 2 + scripts/mk_util.py | 97 ++++++++++++++++++++++++++++++++++++-- src/nlsat/nlsat_params.pyg | 13 +++++ src/nlsat/nlsat_solver.cpp | 33 ++++++------- 4 files changed, 123 insertions(+), 22 deletions(-) create mode 100644 src/nlsat/nlsat_params.pyg diff --git a/.gitignore b/.gitignore index 3fe56e9f3..3d6e631f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *~ *.pyc +# .hpp files are automatically generated +*.hpp .z3-trace # OCaml generated files *.a diff --git a/scripts/mk_util.py b/scripts/mk_util.py index e449f9c0f..782990cd7 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1420,11 +1420,102 @@ def mk_makefile(): # Generate automatically generated source code def mk_auto_src(): if not ONLY_MAKEFILES: + exec_pyg_scripts() mk_pat_db() mk_all_install_tactic_cpps() mk_all_mem_initializer_cpps() mk_all_gparams_register_modules() +UINT = 0 +BOOL = 1 +DOUBLE = 2 +STRING = 3 +SYMBOL = 4 +UINT_MAX = 4294967295 +CURR_PYG = None + +def get_curr_pyg(): + return CURR_PYG + +TYPE2CPK = { UINT : 'CPK_UINT', BOOL : 'CPK_BOOL', DOUBLE : 'CPK_DOUBLE', STRING : 'CPK_STRING', SYMBOL : 'CPK_SYMBOL' } +TYPE2CTYPE = { UINT : 'unsigned', BOOL : 'bool', DOUBLE : 'double', STRING : 'char const *', SYMBOL : 'symbol' } +TYPE2GETTER = { UINT : 'get_uint', BOOL : 'get_bool', DOUBLE : 'get_double', STRING : 'get_str', SYMBOL : 'get_sym' } + +def pyg_default(p): + if p[1] == BOOL: + if p[2]: + return "true" + else: + return "false" + return p[2] + +def pyg_default_as_c_literal(p): + if p[1] == BOOL: + if p[2]: + return "true" + else: + return "false" + elif p[1] == STRING: + return '"%s"' % p[2] + elif p[1] == SYMBOL: + return 'symbol("%s")' % p[2] + return p[2] + +def def_module_params(module_name, export, params): + pyg = get_curr_pyg() + hpp = '%shpp' % pyg[:len(pyg)-3] + out = open(hpp, 'w') + out.write('// Automatically generated file\n') + out.write('#include"params.h"\n') + if export: + out.write('#include"gparams.h"\n') + out.write('struct %s_params {\n' % module_name) + out.write(' params_ref const & p;\n') + if export: + out.write(' params_ref const & g;\n') + out.write(' %s_params(params_ref const & _p = params_ref()):\n' % module_name) + out.write(' p(_p)') + if export: + out.write(', g(gparams::get_module("%s"))' % module_name) + out.write(' {}\n') + out.write(' static void collect_param_descrs(param_descrs & d) {\n') + for param in params: + out.write(' d.insert("%s", %s, "%s", "%s");\n' % (param[0], TYPE2CPK[param[1]], param[3], pyg_default(param))) + out.write(' }\n') + if export: + out.write(' /*\n') + out.write(" REG_MODULE_PARAMS('%s', '%s_params::collect_param_descrs')\n" % (module_name, module_name)) + out.write(' */\n') + # Generated accessors + for param in params: + if export: + out.write(' %s %s() const { return p.%s("%s", g, %s); }\n' % + (TYPE2CTYPE[param[1]], param[0], TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) + else: + out.write(' %s %s() const { return p.%s("%s", %s); }\n' % + (TYPE2CTYPE[param[1]], param[0], TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) + out.write('};\n') + if is_verbose(): + print "Generated '%s'" % hpp + +def max_memory_param(): + return ('max_memory', UINT, UINT_MAX, 'maximum amount of memory in megabytes.') + +PYG_GLOBALS = { 'UINT' : UINT, 'BOOL' : BOOL, 'DOUBLE' : DOUBLE, 'STRING' : STRING, 'SYMBOL' : SYMBOL, + 'UINT_MAX' : UINT_MAX, + 'max_memory_param' : max_memory_param, + 'def_module_params' : def_module_params } + +# Execute python auxiliary scripts that generate extra code for Z3. +def exec_pyg_scripts(): + global CURR_PYG + for root, dirs, files in os.walk('src'): + for f in files: + if f.endswith('.pyg'): + script = os.path.join(root, f) + CURR_PYG = script + execfile(script, PYG_GLOBALS) + # TODO: delete after src/ast/pattern/expr_pattern_match # database.smt ==> database.h def mk_pat_db(): @@ -1548,7 +1639,7 @@ def mk_install_tactic_cpp(cnames, path): probe_pat = re.compile('[ \t]*ADD_PROBE\(.*\)') for cname in cnames: c = get_component(cname) - h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) + h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(c.src_dir)) for h_file in h_files: added_include = False fin = open("%s/%s" % (c.src_dir, h_file), 'r') @@ -1613,7 +1704,7 @@ def mk_mem_initializer_cpp(cnames, path): finalizer_pat = re.compile('[ \t]*ADD_FINALIZER\(\'([^\']*)\'\)') for cname in cnames: c = get_component(cname) - h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) + h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(c.src_dir)) for h_file in h_files: added_include = False fin = open("%s/%s" % (c.src_dir, h_file), 'r') @@ -1674,7 +1765,7 @@ def mk_gparams_register_modules(cnames, path): reg_mod_pat = re.compile('[ \t]*REG_MODULE_PARAMS\(\'([^\']*)\', *\'([^\']*)\'\)') for cname in cnames: c = get_component(cname) - h_files = filter(lambda f: f.endswith('.h'), os.listdir(c.src_dir)) + h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(c.src_dir)) for h_file in h_files: added_include = False fin = open("%s/%s" % (c.src_dir, h_file), 'r') diff --git a/src/nlsat/nlsat_params.pyg b/src/nlsat/nlsat_params.pyg new file mode 100644 index 000000000..2728e1180 --- /dev/null +++ b/src/nlsat/nlsat_params.pyg @@ -0,0 +1,13 @@ + +def_module_params('nlsat', + export=True, + params=(max_memory_param(), + ('lazy', UINT, 0, "how lazy the solver is."), + ('reorder', BOOL, True, "reorder variables."), + ('simplify_conflicts', BOOL, True, "simplify conflicts using equalities before resolving them in nlsat solver."), + ('minimize_conflicts', BOOL, False, "minimize conflicts"), + ('randomize', BOOL, True, "randomize selection of a witness in nlsat."), + ('max_conflicts', UINT, UINT_MAX, "maximum number of conflicts."), + ('shuffle_vars', BOOL, False, "use a random variable order."), + ('seed', UINT, 0, "random seed."))) + diff --git a/src/nlsat/nlsat_solver.cpp b/src/nlsat/nlsat_solver.cpp index d76d584f7..341431556 100644 --- a/src/nlsat/nlsat_solver.cpp +++ b/src/nlsat/nlsat_solver.cpp @@ -31,6 +31,7 @@ Revision History: #include"dependency.h" #include"polynomial_cache.h" #include"permutation.h" +#include"nlsat_params.hpp" #define NLSAT_EXTRA_VERBOSE @@ -197,20 +198,21 @@ namespace nlsat { mk_clause(1, &true_lit, false, 0); } - void updt_params(params_ref const & p) { - m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); - m_lazy = p.get_uint("lazy", 0); - m_simplify_cores = p.get_bool("simplify_conflicts", true); - bool min_cores = p.get_bool("minimize_conflicts", false); - m_reorder = p.get_bool("reorder", true); - m_randomize = p.get_bool("randomize", true); - m_max_conflicts = p.get_uint("max_conflicts", UINT_MAX); - m_random_order = p.get_bool("shuffle_vars", false); - m_random_seed = p.get_uint("seed", 0); + void updt_params(params_ref const & _p) { + nlsat_params p(_p); + m_max_memory = p.max_memory(); + m_lazy = p.lazy(); + m_simplify_cores = p.simplify_conflicts(); + bool min_cores = p.minimize_conflicts(); + m_reorder = p.reorder(); + m_randomize = p.randomize(); + m_max_conflicts = p.max_conflicts(); + m_random_order = p.shuffle_vars(); + m_random_seed = p.seed(); m_ism.set_seed(m_random_seed); m_explain.set_simplify_cores(m_simplify_cores); m_explain.set_minimize_cores(min_cores); - m_am.updt_params(p); + m_am.updt_params(p.p); } void set_cancel(bool f) { @@ -2570,15 +2572,8 @@ namespace nlsat { } void solver::collect_param_descrs(param_descrs & d) { - insert_max_memory(d); algebraic_numbers::manager::collect_param_descrs(d); - d.insert("max_conflicts", CPK_UINT, "(default: inf) maximum number of conflicts."); - d.insert("shuffle_vars", CPK_BOOL, "(default: false) use a variable order."); - d.insert("seed", CPK_UINT, "(default: 0) random seed."); - d.insert("randomize", CPK_BOOL, "(default: true) randomize selection of a witness in nlsat."); - d.insert("reorder", CPK_BOOL, "(default: true) reorder variables."); - d.insert("lazy", CPK_UINT, "(default: 0) how lazy the solver is."); - d.insert("simplify_conflicts", CPK_BOOL, "(default: true) simplify conflicts using equalities before resolving them in nlsat solver."); + nlsat_params::collect_param_descrs(d); } unsynch_mpq_manager & solver::qm() { From 3e6bddbad1d8e7886b13abaadfcabef416df7acc Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 17:20:45 -0800 Subject: [PATCH 08/34] converted pp_params Signed-off-by: Leonardo de Moura --- src/api/api_ast.cpp | 7 ++- src/ast/ast_pp.h | 2 +- src/ast/ast_printer.cpp | 8 +-- src/ast/ast_smt2_pp.cpp | 50 ++++++++++----- src/ast/ast_smt2_pp.h | 29 ++++----- src/ast/pp.cpp | 61 ++++++------------- src/ast/pp.h | 14 +---- src/ast/pp_params.cpp | 57 ----------------- src/ast/pp_params.h | 46 -------------- src/ast/pp_params.pyg | 17 ++++++ src/ast/substitution/substitution_tree.cpp | 4 +- src/cmd_context/cmd_context.cpp | 11 ++-- .../extra_cmds/polynomial_cmds.cpp | 8 ++- src/front_end_params/front_end_params.h | 1 - src/model/model_pp.cpp | 3 +- src/model/model_smt2_pp.cpp | 4 +- src/muz_qe/dl_context.cpp | 8 +-- src/muz_qe/pdr_manager.cpp | 4 +- src/shell/main.cpp | 1 - src/tactic/fpa/fpa2bv_converter.cpp | 2 +- 20 files changed, 114 insertions(+), 223 deletions(-) delete mode 100644 src/ast/pp_params.cpp delete mode 100644 src/ast/pp_params.h create mode 100644 src/ast/pp_params.pyg diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 1503b387f..45892bac3 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -36,6 +36,7 @@ Revision History: #include"scoped_ctrl_c.h" #include"cancel_eh.h" #include"scoped_timer.h" +#include"pp_params.hpp" extern "C" { @@ -833,7 +834,8 @@ extern "C" { break; case Z3_PRINT_SMTLIB_COMPLIANT: { ast_smt_pp pp(mk_c(c)->m()); - pp.set_simplify_implies(get_pp_default_params().m_pp_simplify_implies); + pp_params params; + pp.set_simplify_implies(params.simplify_implies()); ast* a1 = to_ast(a); pp.set_logic(mk_c(c)->fparams().m_smtlib_logic.c_str()); if (!is_expr(a1)) { @@ -886,7 +888,8 @@ extern "C" { pp.set_logic(logic); pp.set_status(status); pp.add_attributes(attributes); - pp.set_simplify_implies(get_pp_default_params().m_pp_simplify_implies); + pp_params params; + pp.set_simplify_implies(params.simplify_implies()); for (unsigned i = 0; i < num_assumptions; ++i) { pp.add_assumption(to_expr(assumptions[i])); } diff --git a/src/ast/ast_pp.h b/src/ast/ast_pp.h index d99fb7670..7e7bdfc4e 100644 --- a/src/ast/ast_pp.h +++ b/src/ast/ast_pp.h @@ -24,7 +24,7 @@ Revision History: #include"ast_smt2_pp.h" struct mk_pp : public mk_ismt2_pp { - mk_pp(ast * t, ast_manager & m, pp_params 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 = 0): 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): diff --git a/src/ast/ast_printer.cpp b/src/ast/ast_printer.cpp index 33ddcb709..8d6ed91f7 100644 --- a/src/ast/ast_printer.cpp +++ b/src/ast/ast_printer.cpp @@ -33,14 +33,14 @@ public: virtual void display(std::ostream & out, func_decl * f, unsigned indent = 0) const { out << f->get_name(); } - virtual void pp(sort * s, format_ns::format_ref & r) const { mk_smt2_format(s, env(), get_pp_default_params(), r); } - virtual void pp(func_decl * f, format_ns::format_ref & r) const { mk_smt2_format(f, env(), get_pp_default_params(), r); } + 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 { sbuffer buf; - mk_smt2_format(n, env(), get_pp_default_params(), 0, 0, r, buf); + mk_smt2_format(n, env(), params_ref(), 0, 0, r, buf); } virtual void pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const { - mk_smt2_format(n, env(), get_pp_default_params(), num_vars, var_prefix, r, var_names); + 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 { NOT_IMPLEMENTED_YET(); diff --git a/src/ast/ast_smt2_pp.cpp b/src/ast/ast_smt2_pp.cpp index dcc7a1a0d..afe301ddf 100644 --- a/src/ast/ast_smt2_pp.cpp +++ b/src/ast/ast_smt2_pp.cpp @@ -24,6 +24,7 @@ Revision History: #include"ast_ll_pp.h" #include"ast_pp.h" #include"algebraic_numbers.h" +#include"pp_params.hpp" using namespace format_ns; #define ALIAS_PREFIX "a" @@ -376,7 +377,6 @@ typedef app_ref_vector format_ref_vector; class smt2_printer { ast_manager & m_manager; - pp_params const & m_params; smt2_pp_environment & m_env; shared_occs m_soccs; @@ -421,6 +421,16 @@ class smt2_printer { string_buffer<> m_next_name_buffer; + // Config + bool m_pp_decimal; + unsigned m_pp_decimal_precision; + bool m_pp_bv_lits; + bool m_pp_bv_neg; + unsigned m_pp_max_depth; + unsigned m_pp_min_alias_size; + bool m_pp_flat_assoc; + + symbol next_name(char const * prefix, unsigned & idx) { while (true) { m_next_name_buffer.reset(); @@ -508,10 +518,10 @@ class smt2_printer { void pp_const(app * c) { format * f; if (m_env.get_autil().is_numeral(c) || m_env.get_autil().is_irrational_algebraic_numeral(c)) { - f = m_env.pp_arith_literal(c, m_params.m_pp_decimal, m_params.m_pp_decimal_precision); + f = m_env.pp_arith_literal(c, m_pp_decimal, m_pp_decimal_precision); } else if (m_env.get_bvutil().is_numeral(c)) { - f = m_env.pp_bv_literal(c, m_params.m_pp_bv_lits, m_params.m_pp_bv_neg); + f = m_env.pp_bv_literal(c, m_pp_bv_lits, m_pp_bv_neg); } else if (m_env.get_futil().is_value(c)) { f = m_env.pp_float_literal(c); @@ -584,8 +594,8 @@ class smt2_printer { m_format_stack.shrink(fr.m_spos); m_info_stack.shrink(fr.m_spos); if (fr.m_use_alias && m_root != t && - ((f_info.m_depth >= m_params.m_pp_max_depth) || - ((f_info.m_weight >= m_params.m_pp_min_alias_size || is_quantifier(t)) && m_soccs.is_shared(t)))) { + ((f_info.m_depth >= m_pp_max_depth) || + ((f_info.m_weight >= m_pp_min_alias_size || is_quantifier(t)) && m_soccs.is_shared(t)))) { symbol a = next_alias(); TRACE("smt2_pp", tout << "a: " << a << " depth: " << f_info.m_depth << ", weight: " << f_info.m_weight << ", lvl: " << f_info.m_lvl << " t: #" << t->get_id() << "\n" << mk_ll_pp(t, m()) @@ -602,7 +612,7 @@ class smt2_printer { } bool flat_assoc(app * t, frame const & fr) { - if (!m_params.m_pp_flat_assoc) + if (!m_pp_flat_assoc) return false; func_decl * f = t->get_decl(); if (f->is_associative() && m_frame_stack.size() >= 2 && !m_soccs.is_shared(t)) { @@ -943,9 +953,8 @@ class smt2_printer { } public: - smt2_printer(smt2_pp_environment & env, pp_params const & params): + smt2_printer(smt2_pp_environment & env, params_ref const & params): m_manager(env.get_manager()), - m_params(params), m_env(env), m_soccs(m_manager), m_root(0), @@ -953,6 +962,15 @@ public: m_next_alias_idx(1), m_format_stack(fm()) { init_expr2alias_stack(); + + pp_params p(params); + m_pp_decimal = p.decimal(); + m_pp_decimal_precision = p.decimal_precision(); + m_pp_bv_lits = p.bv_literals(); + m_pp_bv_neg = p.bv_neg(); + m_pp_max_depth = p.max_depth(); + m_pp_min_alias_size = p.min_alias_size(); + m_pp_flat_assoc = p.flat_assoc(); } ~smt2_printer() { @@ -1003,24 +1021,24 @@ public: }; -void mk_smt2_format(expr * n, smt2_pp_environment & env, pp_params const & p, +void mk_smt2_format(expr * n, smt2_pp_environment & env, params_ref const & p, unsigned num_vars, char const * var_prefix, format_ref & r, sbuffer & var_names) { smt2_printer pr(env, p); pr(n, num_vars, var_prefix, r, var_names); } -void mk_smt2_format(sort * s, smt2_pp_environment & env, pp_params const & p, format_ref & r) { +void mk_smt2_format(sort * s, smt2_pp_environment & env, params_ref const & p, format_ref & r) { smt2_printer pr(env, p); pr(s, r); } -void mk_smt2_format(func_decl * f, smt2_pp_environment & env, pp_params const & p, format_ref & r) { +void mk_smt2_format(func_decl * f, smt2_pp_environment & env, params_ref const & p, format_ref & r) { smt2_printer pr(env, p); pr(f, r); } -std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & env, pp_params const & p, unsigned indent, +std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & env, params_ref const & p, unsigned indent, unsigned num_vars, char const * var_prefix) { ast_manager & m = env.get_manager(); format_ref r(fm(m)); @@ -1032,7 +1050,7 @@ std::ostream & ast_smt2_pp(std::ostream & out, expr * n, smt2_pp_environment & e return out; } -std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & env, pp_params const & p, unsigned indent) { +std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & env, params_ref const & p, unsigned indent) { ast_manager & m = env.get_manager(); format_ref r(fm(m)); sbuffer var_names; @@ -1043,7 +1061,7 @@ std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & e return out; } -std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, pp_params const & p, unsigned indent) { +std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, params_ref const & p, unsigned indent) { ast_manager & m = env.get_manager(); format_ref r(fm(m)); sbuffer var_names; @@ -1054,7 +1072,7 @@ std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environmen return out; } -mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, pp_params const & p, unsigned indent, unsigned num_vars, char const * var_prefix): +mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent, unsigned num_vars, char const * var_prefix): m_ast(t), m_manager(m), m_params(p), @@ -1066,7 +1084,7 @@ mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, pp_params const & p, unsigned mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, unsigned indent, unsigned num_vars, char const * var_prefix): m_ast(t), m_manager(m), - m_params(get_pp_default_params()), + m_params(m_empty), m_indent(indent), m_num_vars(num_vars), m_var_prefix(var_prefix) { diff --git a/src/ast/ast_smt2_pp.h b/src/ast/ast_smt2_pp.h index 048dd8d67..aa84d6e03 100644 --- a/src/ast/ast_smt2_pp.h +++ b/src/ast/ast_smt2_pp.h @@ -23,7 +23,7 @@ Revision History: #define _AST_SMT2_PP_H_ #include"format.h" -#include"pp_params.h" +#include"params.h" #include"arith_decl_plugin.h" #include"bv_decl_plugin.h" #include"array_decl_plugin.h" @@ -82,28 +82,29 @@ public: virtual bool uses(symbol const & s) const { return false; } }; -void mk_smt2_format(expr * n, smt2_pp_environment & env, pp_params const & p, +void mk_smt2_format(expr * n, smt2_pp_environment & env, params_ref const & p, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names); -void mk_smt2_format(sort * s, smt2_pp_environment & env, pp_params const & p, format_ns::format_ref & r); -void mk_smt2_format(func_decl * f, smt2_pp_environment & env, pp_params const & p, format_ns::format_ref & r); +void mk_smt2_format(sort * s, smt2_pp_environment & env, params_ref const & p, format_ns::format_ref & r); +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, pp_params const & p, unsigned indent = 0, +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); -std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & env, pp_params const & p, unsigned indent = 0); -std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, pp_params const & p, unsigned indent = 0); +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); /** \brief Internal wrapper (for debugging purposes only) */ struct mk_ismt2_pp { - ast * m_ast; - ast_manager & m_manager; - pp_params const & m_params; - unsigned m_indent; - unsigned m_num_vars; - char const * m_var_prefix; - mk_ismt2_pp(ast * t, ast_manager & m, pp_params const & p, unsigned indent = 0, unsigned num_vars = 0, char const * var_prefix = 0); + ast * m_ast; + ast_manager & m_manager; + params_ref m_empty; + params_ref const & m_params; + 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); }; diff --git a/src/ast/pp.cpp b/src/ast/pp.cpp index d05776e78..13247127d 100644 --- a/src/ast/pp.cpp +++ b/src/ast/pp.cpp @@ -17,40 +17,9 @@ Revision History: --*/ #include"pp.h" +#include"pp_params.hpp" using namespace format_ns; -void pp_param_descrs(param_descrs & p) { - p.insert("max_indent", CPK_UINT, "max. indentation in pretty printer"); - p.insert("max_num_lines", CPK_UINT, "max. number of lines to be displayed in pretty printer"); - p.insert("max_width", CPK_UINT, "max. width in pretty printer"); - p.insert("max_ribbon", CPK_UINT, "max. ribbon (width - indentation) in pretty printer"); - p.insert("max_depth", CPK_UINT, "max. term depth (when pretty printing SMT2 terms/formulas)"); - p.insert("min_alias_size", CPK_UINT, "min. size for creating an alias for a shared term (when pretty printing SMT2 terms/formulas)"); - p.insert("decimal", CPK_BOOL, "pretty print real numbers using decimal notation (the output may be truncated). Z3 adds a '?' if the value is not precise"); - p.insert("decimal_precision", CPK_BOOL, "maximum number of decimal places to be used when pp.decimal=true"); - p.insert("bv_literals", CPK_BOOL, "use Bit-Vector literals (e.g, #x0F and #b0101) during pretty printing"); - p.insert("bv_neg", CPK_BOOL, "use bvneg when displaying Bit-Vector literals where the most significant bit is 1"); - p.insert("flat_assoc", CPK_BOOL, "flat associative operators (when pretty printing SMT2 terms/formulas)"); - p.insert("fixed_indent", CPK_BOOL, "use a fixed indentation for applications"); - p.insert("single_line", CPK_BOOL, "ignore line breaks when true"); - p.insert("bounded", CPK_BOOL, "ignore characters exceeding max widht"); - p.insert("simplify_implies", CPK_BOOL, "simplify nested implications for pretty printing"); -} - -pp_params g_pp_params; - -void set_pp_default_params(pp_params const & p) { - g_pp_params = p; -} - -void register_pp_params(ini_params & p) { - g_pp_params.register_params(p); -} - -pp_params const & get_pp_default_params() { - return g_pp_params; -} - static std::pair space_upto_line_break(ast_manager & m, format * f) { unsigned r; SASSERT(f->get_family_id() == fm(m).get_family_id("format")); @@ -87,7 +56,15 @@ inline bool fits(ast_manager & m, format * f, unsigned space_left) { return s <= space_left; } -void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { +void pp(std::ostream & out, format * f, ast_manager & m, params_ref const & _p) { + pp_params p(_p); + unsigned max_width = p.max_width(); + unsigned max_ribbon = p.max_ribbon(); + unsigned max_num_lines = p.max_num_lines(); + unsigned max_indent = p.max_indent(); + bool bounded = p.bounded(); + bool single_line = p.single_line(); + unsigned pos = 0; unsigned ribbon_pos = 0; unsigned line = 0; @@ -98,7 +75,7 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { todo.push_back(std::make_pair(f, 0)); app_ref space(mk_string(m, " "), fm(m)); while (!todo.empty()) { - if (line >= p.m_pp_max_num_lines) + if (line >= max_num_lines) return; std::pair pair = todo.back(); format * f = pair.first; @@ -107,10 +84,10 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { SASSERT(f->get_family_id() == fm(m).get_family_id("format")); switch (f->get_decl_kind()) { case OP_STRING: - if (p.m_pp_bounded && pos > p.m_pp_max_width) + if (bounded && pos > max_width) break; len = static_cast(strlen(f->get_decl()->get_parameter(0).get_symbol().bare_str())); - if (p.m_pp_bounded && pos + len > p.m_pp_max_width) { + if (bounded && pos + len > max_width) { out << "..."; break; } @@ -121,7 +98,7 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { case OP_INDENT: todo.push_back(std::make_pair(to_app(f->get_arg(0)), std::min(indent + f->get_decl()->get_parameter(0).get_int(), - p.m_pp_max_indent))); + max_indent))); break; case OP_COMPOSE: i = f->get_num_args(); @@ -131,7 +108,7 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { } break; case OP_CHOICE: - space_left = std::min(p.m_pp_max_width - pos, p.m_pp_max_ribbon - pos); + space_left = std::min(max_width - pos, max_ribbon - pos); if (space_left > 0 && fits(m, to_app(f->get_arg(0)), space_left)) todo.push_back(std::make_pair(to_app(f->get_arg(0)), indent)); else @@ -139,14 +116,14 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { break; case OP_LINE_BREAK: case OP_LINE_BREAK_EXT: - if (p.m_pp_single_line) { + if (single_line) { todo.push_back(std::make_pair(space, indent)); break; } pos = indent; ribbon_pos = 0; line++; - if (line < p.m_pp_max_num_lines) { + if (line < max_num_lines) { out << "\n"; for (unsigned i = 0; i < indent; i++) out << " "; @@ -160,7 +137,3 @@ void pp(std::ostream & out, format * f, ast_manager & m, pp_params const & p) { } } -void pp(std::ostream & out, format_ns::format * f, ast_manager & m) { - pp(out, f, m, g_pp_params); -} - diff --git a/src/ast/pp.h b/src/ast/pp.h index 13afcb07c..f567afa4a 100644 --- a/src/ast/pp.h +++ b/src/ast/pp.h @@ -20,21 +20,9 @@ Revision History: #define _PP_H_ #include"format.h" -#include"pp_params.h" #include"params.h" -/* - REG_MODULE_PARAMS('pp', 'pp_param_descrs') -*/ -void pp_param_descrs(param_descrs & d); - -void set_pp_default_params(pp_params const & p); -void register_pp_params(ini_params & p); - -pp_params const & get_pp_default_params(); - -void pp(std::ostream & out, format_ns::format * f, ast_manager & m, pp_params const & p); -void pp(std::ostream & out, format_ns::format * f, ast_manager & m); +void pp(std::ostream & out, format_ns::format * f, ast_manager & m, params_ref const & p = params_ref()); #endif /* _PP_H_ */ diff --git a/src/ast/pp_params.cpp b/src/ast/pp_params.cpp deleted file mode 100644 index 0cf3e455d..000000000 --- a/src/ast/pp_params.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - pp_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-20. - -Revision History: - ---*/ - -#include"pp_params.h" - -pp_params::pp_params(): - m_pp_max_indent(UINT_MAX), - m_pp_max_num_lines(UINT_MAX), - m_pp_max_width(80), - m_pp_max_ribbon(80), - m_pp_max_depth(5), - m_pp_min_alias_size(10), - m_pp_decimal(false), - m_pp_decimal_precision(10), - m_pp_bv_lits(true), - m_pp_bv_neg(false), - m_pp_flat_assoc(true), - m_pp_fixed_indent(false), - m_pp_single_line(false), - m_pp_bounded(false), - m_pp_simplify_implies(false) { -} - -void pp_params::register_params(ini_params & p) { - p.register_unsigned_param("PP_MAX_INDENT", m_pp_max_indent, "max. indentation in pretty printer", true); - p.register_unsigned_param("PP_MAX_NUM_LINES", m_pp_max_num_lines, "max. number of lines to be displayed in pretty printer", true); - p.register_unsigned_param("PP_MAX_WIDTH", m_pp_max_width, "max. width in pretty printer", true); - p.register_unsigned_param("PP_MAX_RIBBON", m_pp_max_ribbon, "max. ribbon (width - indentation) in pretty printer", true); - p.register_unsigned_param("PP_MAX_DEPTH", m_pp_max_depth, "max. term depth (when pretty printing SMT2 terms/formulas)", true); - p.register_unsigned_param("PP_MIN_ALIAS_SIZE", m_pp_min_alias_size, "min. size for creating an alias for a shared term (when pretty printing SMT2 terms/formulas)", true); - p.register_bool_param("PP_DECIMAL", m_pp_decimal, "pretty print real numbers using decimal notation (the output may be truncated). Z3 adds a '?' if the value is not precise", true); - p.register_unsigned_param("PP_DECIMAL_PRECISION", m_pp_decimal_precision, "maximum number of decimal places to be used when PP_DECIMAL=true", true); - p.register_bool_param("PP_BV_LITERALS", m_pp_bv_lits, "use Bit-Vector literals (e.g, #x0F and #b0101) during pretty printing", true); - p.register_bool_param("PP_BV_NEG", m_pp_bv_neg, "use bvneg when displaying Bit-Vector literals where the most significant bit is 1", true); - p.register_bool_param("PP_FLAT_ASSOC", m_pp_flat_assoc, "flat associative operators (when pretty printing SMT2 terms/formulas)", true); - p.register_bool_param("PP_FIXED_INDENT", m_pp_fixed_indent, "use a fixed indentation for applications", true); - p.register_bool_param("PP_SINGLE_LINE", m_pp_single_line, "ignore line breaks when true", true); - p.register_bool_param("PP_BOUNDED", m_pp_bounded, "ignore characters exceeding max widht", true); - p.register_bool_param("PP_SIMPLIFY_IMPLIES", m_pp_simplify_implies, "simplify nested implications for pretty printing", true); -} - diff --git a/src/ast/pp_params.h b/src/ast/pp_params.h deleted file mode 100644 index 970f97968..000000000 --- a/src/ast/pp_params.h +++ /dev/null @@ -1,46 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - pp_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-20. - -Revision History: - ---*/ -#ifndef _PP_PARAMS_H_ -#define _PP_PARAMS_H_ - -#include"ini_file.h" - -struct pp_params { - unsigned m_pp_max_indent; // max. indentation - unsigned m_pp_max_num_lines; // max. num. lines - unsigned m_pp_max_width; // max. width - unsigned m_pp_max_ribbon; // max. ribbon: width - indentation - unsigned m_pp_max_depth; - unsigned m_pp_min_alias_size; - bool m_pp_decimal; // display reals using decimals - unsigned m_pp_decimal_precision; // max. number of decimal places - bool m_pp_bv_lits; - bool m_pp_bv_neg; // use bvneg to display bit-vector literals which the most significant bit is 1 - bool m_pp_flat_assoc; - bool m_pp_fixed_indent; - bool m_pp_single_line; // ignore line breaks if true - bool m_pp_bounded; // ignore characters exceeding max width. - bool m_pp_simplify_implies; // simplify nested implications during pretty printing - - pp_params(); - void register_params(ini_params & p); -}; - -#endif /* _PP_PARAMS_H_ */ - diff --git a/src/ast/pp_params.pyg b/src/ast/pp_params.pyg new file mode 100644 index 000000000..57d6e185d --- /dev/null +++ b/src/ast/pp_params.pyg @@ -0,0 +1,17 @@ +def_module_params('pp', + export=True, + params=(('max_indent', UINT, UINT_MAX, 'max. indentation in pretty printer'), + ('max_num_lines', UINT, UINT_MAX, 'max. number of lines to be displayed in pretty printer'), + ('max_width', UINT, 80, 'max. width in pretty printer'), + ('max_ribbon', UINT, 80, 'max. ribbon (width - indentation) in pretty printer'), + ('max_depth', UINT, 5, 'max. term depth (when pretty printing SMT2 terms/formulas)'), + ('min_alias_size', UINT, 10, 'min. size for creating an alias for a shared term (when pretty printing SMT2 terms/formulas)'), + ('decimal', BOOL, False, 'pretty print real numbers using decimal notation (the output may be truncated). Z3 adds a ? if the value is not precise'), + ('decimal_precision', UINT, 10, 'maximum number of decimal places to be used when pp.decimal=true'), + ('bv_literals', BOOL, True, 'use Bit-Vector literals (e.g, #x0F and #b0101) during pretty printing'), + ('bv_neg', BOOL, False, 'use bvneg when displaying Bit-Vector literals where the most significant bit is 1'), + ('flat_assoc', BOOL, True, 'flat associative operators (when pretty printing SMT2 terms/formulas)'), + ('fixed_indent', BOOL, False, 'use a fixed indentation for applications'), + ('single_line', BOOL, False, 'ignore line breaks when true'), + ('bounded', BOOL, False, 'ignore characters exceeding max widht'), + ('simplify_implies', BOOL, True, 'simplify nested implications for pretty printing'))) diff --git a/src/ast/substitution/substitution_tree.cpp b/src/ast/substitution/substitution_tree.cpp index 81b2f7be6..037d51e32 100644 --- a/src/ast/substitution/substitution_tree.cpp +++ b/src/ast/substitution/substitution_tree.cpp @@ -607,8 +607,8 @@ void substitution_tree::display(std::ostream & out, node * n, unsigned delta) co out << " "; display(out, n->m_subst); if (n->m_leaf) { - pp_params p; - p.m_pp_single_line = true; + params_ref p; + p.set_bool("single_line", true); out << " ==> "; out << mk_pp(n->m_expr, m_manager, p); out << "\n"; diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index d14ce3076..5dcc4268c 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -1536,8 +1536,7 @@ cmd_context::pp_env & cmd_context::get_pp_env() const { } void cmd_context::pp(expr * n, unsigned num_vars, char const * var_prefix, format_ns::format_ref & r, sbuffer & var_names) const { - mk_smt2_format(n, get_pp_env(), get_pp_default_params(), - num_vars, var_prefix, r, var_names); + mk_smt2_format(n, get_pp_env(), params_ref(), num_vars, var_prefix, r, var_names); } void cmd_context::pp(expr * n, format_ns::format_ref & r) const { @@ -1546,7 +1545,7 @@ void cmd_context::pp(expr * n, format_ns::format_ref & r) const { } void cmd_context::pp(func_decl * f, format_ns::format_ref & r) const { - mk_smt2_format(f, get_pp_env(), get_pp_default_params(), r); + mk_smt2_format(f, get_pp_env(), params_ref(), r); } void cmd_context::display(std::ostream & out, sort * s, unsigned indent) const { @@ -1554,7 +1553,7 @@ void cmd_context::display(std::ostream & out, sort * s, unsigned indent) const { f = pp(s); if (indent > 0) f = format_ns::mk_indent(m(), indent, f); - ::pp(out, f.get(), m(), get_pp_default_params()); + ::pp(out, f.get(), m()); } void cmd_context::display(std::ostream & out, expr * n, unsigned indent, unsigned num_vars, char const * var_prefix, sbuffer & var_names) const { @@ -1562,7 +1561,7 @@ void cmd_context::display(std::ostream & out, expr * n, unsigned indent, unsigne pp(n, num_vars, var_prefix, f, var_names); if (indent > 0) f = format_ns::mk_indent(m(), indent, f); - ::pp(out, f.get(), m(), get_pp_default_params()); + ::pp(out, f.get(), m()); } void cmd_context::display(std::ostream & out, expr * n, unsigned indent) const { @@ -1575,7 +1574,7 @@ void cmd_context::display(std::ostream & out, func_decl * d, unsigned indent) co pp(d, f); if (indent > 0) f = format_ns::mk_indent(m(), indent, f); - ::pp(out, f.get(), m(), get_pp_default_params()); + ::pp(out, f.get(), m()); } void cmd_context::dump_assertions(std::ostream & out) const { diff --git a/src/cmd_context/extra_cmds/polynomial_cmds.cpp b/src/cmd_context/extra_cmds/polynomial_cmds.cpp index 7b37b750e..e68789dac 100644 --- a/src/cmd_context/extra_cmds/polynomial_cmds.cpp +++ b/src/cmd_context/extra_cmds/polynomial_cmds.cpp @@ -26,10 +26,10 @@ Notes: #include"parametric_cmd.h" #include"mpq.h" #include"algebraic_numbers.h" -#include"pp.h" -#include"pp_params.h" #include"polynomial_var2value.h" #include"expr2var.h" +#include"pp.h" +#include"pp_params.hpp" static void to_poly(cmd_context & ctx, expr * t) { polynomial::numeral_manager nm; @@ -145,9 +145,11 @@ class poly_isolate_roots_cmd : public cmd { scoped_anum_vector rs(m_am); m_am.isolate_roots(m_p, m_x2v, rs); ctx.regular_stream() << "(roots"; + pp_params params; + bool pp_decimal = params.decimal(); for (unsigned i = 0; i < rs.size(); i++) { ctx.regular_stream() << std::endl; - if (!get_pp_default_params().m_pp_decimal) + if (!pp_decimal) m_am.display_root_smt2(ctx.regular_stream(), rs[i]); else m_am.display_decimal(ctx.regular_stream(), rs[i]); diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index f9e62cd01..b87265c01 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -23,7 +23,6 @@ Revision History: #include"ast.h" #include"preprocessor_params.h" #include"smt_params.h" -#include"pp_params.h" #include"parser_params.h" #include"arith_simplifier_params.h" #include"model_params.h" diff --git a/src/model/model_pp.cpp b/src/model/model_pp.cpp index a8e8a0880..b968c7184 100644 --- a/src/model/model_pp.cpp +++ b/src/model/model_pp.cpp @@ -85,8 +85,7 @@ static void display_functions(std::ostream & out, model_core const & md) { if (fi->is_partial()) out << " #unspecified"; else { - pp_params const & params = get_pp_default_params(); - out << " " << mk_ismt2_pp(fi->get_else(), m, params, 5, arity, "x"); + out << " " << mk_ismt2_pp(fi->get_else(), m, params_ref(), 5, arity, "x"); } for (unsigned j = 0; j < num_entries; j++) out << ")"; diff --git a/src/model/model_smt2_pp.cpp b/src/model/model_smt2_pp.cpp index 1a639b5f1..929668638 100644 --- a/src/model/model_smt2_pp.cpp +++ b/src/model/model_smt2_pp.cpp @@ -128,7 +128,7 @@ static void pp_uninterp_sorts(std::ostream & out, ast_printer_context & ctx, mod format_ref f_card(fm(m)); f_card = mk_indent(m, indent, mk_seq1(m, f_args, f_args+2, f2f(), "forall")); pp_indent(out, indent); - pp(out, f_card, m, get_pp_default_params()); + pp(out, f_card, m); out << "\n"; pp_indent(out, indent); out << ";; -----------\n"; @@ -284,7 +284,7 @@ static void pp_funs(std::ostream & out, ast_printer_context & ctx, model_core co body.get(), mk_string(m, ")"))))); pp_indent(out, indent); - pp(out, def.get(), m, get_pp_default_params()); + pp(out, def.get(), m); out << "\n"; } } diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 4a9bba27c..3a2844964 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -1672,12 +1672,11 @@ namespace datalog { bool print_low_level = m_params.get_bool("print_low_level_smt2", false); bool do_declare_vars = m_params.get_bool("print_with_variable_declarations", true); -#define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env, params); +#define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env); get_rules_as_formulas(rules, names); smt2_pp_environment_dbg env(m); - pp_params params; mk_fresh_name fresh_names; collect_free_funcs(num_axioms, axioms, visited, visitor, fresh_names); collect_free_funcs(rules.size(), rules.c_ptr(), visited, visitor, fresh_names); @@ -1719,7 +1718,7 @@ namespace datalog { func_decl* f = *it; out << "(declare-rel " << f->get_name() << " ("; for (unsigned i = 0; i < f->get_arity(); ++i) { - ast_smt2_pp(out, f->get_domain(i), env, params); + ast_smt2_pp(out, f->get_domain(i), env); if (i + 1 < f->get_arity()) { out << " "; } @@ -1796,7 +1795,6 @@ namespace datalog { // smt2_pp_environment_dbg env(m); var_subst vsubst(m, false); - pp_params param; expr_ref_vector fresh_vars(m), subst(m); expr_ref res(m); @@ -1839,7 +1837,7 @@ namespace datalog { symbol name = fresh_names.next(); fresh_vars.push_back(m.mk_const(name, s)); out << "(declare-var " << name << " "; - ast_smt2_pp(out, s, env, param); + ast_smt2_pp(out, s, env); out << ")\n"; } subst.push_back(fresh_vars[vars[max_var]].get()); diff --git a/src/muz_qe/pdr_manager.cpp b/src/muz_qe/pdr_manager.cpp index ad53f45db..9536d8f36 100644 --- a/src/muz_qe/pdr_manager.cpp +++ b/src/muz_qe/pdr_manager.cpp @@ -29,7 +29,6 @@ Revision History: #include "model_smt2_pp.h" #include "model_converter.h" - namespace pdr { class collect_decls_proc { @@ -143,11 +142,10 @@ namespace pdr { } } smt2_pp_environment_dbg env(m); - pp_params params; func_decl_set::iterator it = aux_decls.begin(), end = aux_decls.end(); for (; it != end; ++it) { func_decl* f = *it; - ast_smt2_pp(out, f, env, params); + ast_smt2_pp(out, f, env); out << "\n"; } diff --git a/src/shell/main.cpp b/src/shell/main.cpp index d6e7b1bf1..56882a02b 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -127,7 +127,6 @@ void init_params() { g_extra_params = new extra_params(); register_verbosity_level(*g_params); register_warning(*g_params); - register_pp_params(*g_params); g_front_end_params->register_params(*g_params); g_extra_params->register_params(*g_params); g_params_initialized = true; diff --git a/src/tactic/fpa/fpa2bv_converter.cpp b/src/tactic/fpa/fpa2bv_converter.cpp index 77ff50e9b..62cc76266 100644 --- a/src/tactic/fpa/fpa2bv_converter.cpp +++ b/src/tactic/fpa/fpa2bv_converter.cpp @@ -105,7 +105,7 @@ void fpa2bv_converter::mk_value(func_decl * f, unsigned num, expr * const * args mk_triple(bv_sgn, bv_sig, biased_exp, result); TRACE("fpa2bv_dbg", tout << "value of [" << sign << " " << m_mpz_manager.to_string(sig) << " " << exp << "] is " - << mk_ismt2_pp(result, m) << std::endl;); + << mk_ismt2_pp(result, m) << std::endl;); } } From 6195ed7c662f2ff02f0975091ec3ec1f31f16ddd Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 18:16:02 -0800 Subject: [PATCH 09/34] checkpoint Signed-off-by: Leonardo de Moura --- scripts/mk_project.py | 2 +- src/ast/normal_forms/cnf.cpp | 19 ++-- src/ast/normal_forms/cnf.h | 26 +++++- src/ast/normal_forms/cnf_params.pyg | 4 + src/ast/normal_forms/nnf.cpp | 101 +++++++++++---------- src/ast/normal_forms/nnf.h | 2 - src/ast/normal_forms/nnf_params.pyg | 8 ++ src/front_end_params/cnf_params.cpp | 26 ------ src/front_end_params/cnf_params.h | 56 ------------ src/front_end_params/nnf_params.cpp | 26 ------ src/front_end_params/nnf_params.h | 74 --------------- src/front_end_params/preprocessor_params.h | 6 +- src/front_end_params/smt_params.cpp | 1 - src/front_end_params/smt_params.h | 2 - src/smt/asserted_formulas.cpp | 82 ++++------------- src/smt/smt_context.h | 4 - src/smt/smt_internalizer.cpp | 7 +- 17 files changed, 120 insertions(+), 326 deletions(-) create mode 100644 src/ast/normal_forms/cnf_params.pyg create mode 100644 src/ast/normal_forms/nnf_params.pyg delete mode 100644 src/front_end_params/cnf_params.cpp delete mode 100644 src/front_end_params/cnf_params.h delete mode 100644 src/front_end_params/nnf_params.cpp delete mode 100644 src/front_end_params/nnf_params.h diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 6fff2abba..27120c89d 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -18,6 +18,7 @@ def init_project_def(): add_lib('subpaving', ['interval'], 'math/subpaving') add_lib('ast', ['util', 'polynomial']) add_lib('rewriter', ['ast', 'polynomial'], 'ast/rewriter') + add_lib('normal_forms', ['rewriter'], 'ast/normal_forms') add_lib('model', ['rewriter']) add_lib('tactic', ['ast', 'model']) add_lib('substitution', ['ast'], 'ast/substitution') @@ -30,7 +31,6 @@ def init_project_def(): # Simplifier module will be deleted in the future. # It has been replaced with rewriter module. add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier') - add_lib('normal_forms', ['rewriter', 'front_end_params'], 'ast/normal_forms') add_lib('core_tactics', ['tactic', 'normal_forms'], 'tactic/core') add_lib('sat_tactic', ['tactic', 'sat'], 'sat/tactic') add_lib('arith_tactics', ['core_tactics', 'sat'], 'tactic/arith') diff --git a/src/ast/normal_forms/cnf.cpp b/src/ast/normal_forms/cnf.cpp index d454c7f00..2a58b16a6 100644 --- a/src/ast/normal_forms/cnf.cpp +++ b/src/ast/normal_forms/cnf.cpp @@ -17,6 +17,7 @@ Revision History: --*/ #include"cnf.h" +#include"cnf_params.hpp" #include"var_subst.h" #include"ast_util.h" #include"ast_pp.h" @@ -159,7 +160,7 @@ inline bool cnf::is_too_expensive(approx_nat approx_result_size, ptr_buffer f_args; flat_args(n->get_decl(), new_args, f_args); TRACE("cnf_or", for (unsigned i = 0; i < f_args.size(); i++) tout << mk_pp(f_args[i], m_manager) << "\n";); approx_nat result_size = approx_result_size_for_disj(f_args); TRACE("cnf_or", tout << mk_pp(n, m_manager) << "\napprox. result: " << result_size << "\n";); - if (m_params.m_cnf_mode != CNF_OPPORTUNISTIC || result_size < m_params.m_cnf_factor) { + if (m_cnf_mode != CNF_OPPORTUNISTIC || result_size < m_cnf_factor) { expr_ref_buffer cheap_args(m_manager); proof_ref_buffer cheap_args_pr(m_manager); if (is_too_expensive(result_size, f_args)) { @@ -354,7 +355,7 @@ void cnf::reduce1_and(app * n, bool in_q) { get_args(n, in_q, new_args, new_arg_prs); app * r; proof * pr = 0; - if (in_q || m_params.m_cnf_mode == CNF_OPPORTUNISTIC || m_params.m_cnf_mode == CNF_FULL) { + if (in_q || m_cnf_mode == CNF_OPPORTUNISTIC || m_cnf_mode == CNF_FULL) { ptr_buffer f_args; flat_args(n->get_decl(), new_args, f_args); r = m_manager.mk_and(f_args.size(), f_args.c_ptr()); @@ -379,7 +380,7 @@ void cnf::reduce1_label(app * n, bool in_q) { expr * new_arg; proof * new_arg_pr; get_cached(n->get_arg(0), true, new_arg, new_arg_pr); - if (in_q || m_params.m_cnf_mode == CNF_FULL) { + if (in_q || m_cnf_mode == CNF_FULL) { // TODO: in the current implementation, labels are removed during CNF translation. // This is satisfactory for Boogie, since it does not use labels inside quantifiers, // and we only need CNF_QUANT for Superposition Calculus. @@ -439,8 +440,7 @@ void cnf::reduce1_quantifier(quantifier * q, bool in_q) { TRACE("cnf_quant", tout << mk_pp(q, m_manager) << "\n" << mk_pp(r, m_manager) << "\n";); } -cnf::cnf(ast_manager & m, defined_names & n, cnf_params & params): - m_params(params), +cnf::cnf(ast_manager & m, defined_names & n, params_ref const & params): m_manager(m), m_defined_names(n), m_pull(m), @@ -448,6 +448,9 @@ cnf::cnf(ast_manager & m, defined_names & n, cnf_params & params): m_todo_defs(m), m_todo_proofs(m), m_coarse_proofs(m) { + cnf_params p(params); + m_cnf_mode = static_cast(p.mode()); + m_cnf_factor = p.factor(); } cnf::~cnf() { @@ -488,7 +491,7 @@ void cnf::reduce(expr * n, expr_ref & r, proof_ref & pr) { } void cnf::operator()(expr * n, expr_ref_vector & new_defs, proof_ref_vector & new_def_proofs, expr_ref & r, proof_ref & pr) { - if (m_params.m_cnf_mode == CNF_DISABLED) { + if (m_cnf_mode == CNF_DISABLED) { r = n; pr = m_manager.mk_reflexivity(n); return; diff --git a/src/ast/normal_forms/cnf.h b/src/ast/normal_forms/cnf.h index 60c2d2410..8aa390c48 100644 --- a/src/ast/normal_forms/cnf.h +++ b/src/ast/normal_forms/cnf.h @@ -19,11 +19,29 @@ Revision History: #ifndef _CNF_H_ #define _CNF_H_ -#include"cnf_params.h" #include"pull_quant.h" #include"nnf.h" #include"approx_nat.h" +/** + \brief CNF translation mode. The cheapest mode is CNF_QUANT, and + the most expensive is CNF_FULL. +*/ +enum cnf_mode { + CNF_DISABLED, /* CNF translator is disabled. + This mode is sufficient when using E-matching. + */ + CNF_QUANT, /* A subformula is put into CNF if it is inside of a + quantifier. + + This mode is sufficient when using Superposition + Calculus. + */ + CNF_OPPORTUNISTIC, /* a subformula is also put in CNF if it is cheap. */ + CNF_FULL /* Everything is put into CNF, new names are introduced + if it is too expensive. */ +}; + /** \brief Entry into the todo list of the CNF translator. It is also used as the key in the CNF cache. */ @@ -71,7 +89,6 @@ public: */ class cnf { typedef std::pair expr_bool_pair; - cnf_params & m_params; ast_manager & m_manager; defined_names & m_defined_names; pull_quant m_pull; @@ -83,6 +100,9 @@ class cnf { ptr_vector m_result_def_proofs; proof_ref_vector m_coarse_proofs; + cnf_mode m_cnf_mode; + unsigned m_cnf_factor; + void cache_result(expr * e, bool in_q, expr * r, proof * pr); void get_cached(expr * n, bool in_q, expr * & r, proof * & pr) const { m_cache.get(cnf_entry(n, true, in_q), r, pr); } bool is_cached(expr * n, bool in_q) const { return m_cache.contains(cnf_entry(n, true, in_q)); } @@ -105,7 +125,7 @@ class cnf { void reduce(expr * n, expr_ref & r, proof_ref & pr); public: - cnf(ast_manager & m, defined_names & n, cnf_params & params); + cnf(ast_manager & m, defined_names & n, params_ref const & p = params_ref()); ~cnf(); void operator()(expr * n, // [IN] expression that should be put into CNF expr_ref_vector & new_defs, // [OUT] new definitions diff --git a/src/ast/normal_forms/cnf_params.pyg b/src/ast/normal_forms/cnf_params.pyg new file mode 100644 index 000000000..3383f674a --- /dev/null +++ b/src/ast/normal_forms/cnf_params.pyg @@ -0,0 +1,4 @@ +def_module_params('cnf', + export=True, + params=(('mode', UINT, 0, 'CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - opportunistic, 3 - full'), + ('factor', UINT, 4, 'the maximum number of clauses that can be created when converting a subformula'))) diff --git a/src/ast/normal_forms/nnf.cpp b/src/ast/normal_forms/nnf.cpp index d525fa167..8e0065071 100644 --- a/src/ast/normal_forms/nnf.cpp +++ b/src/ast/normal_forms/nnf.cpp @@ -18,6 +18,7 @@ Notes: --*/ #include"nnf.h" +#include"nnf_params.hpp" #include"warning.h" #include"used_vars.h" #include"well_sorted.h" @@ -29,6 +30,40 @@ Notes: #include"ast_smt2_pp.h" +/** + \brief NNF translation mode. The cheapest mode is NNF_SKOLEM, and + the most expensive is NNF_FULL. +*/ +enum nnf_mode { + NNF_SKOLEM, /* A subformula is put into NNF only if it contains + quantifiers or labels. The result of the + transformation will be in skolem normal form. + If a formula is too expensive to be put into NNF, + then nested quantifiers and labels are renamed. + + This mode is sufficient when using E-matching. + */ + NNF_QUANT, /* A subformula is put into NNF if it contains + quantifiers, labels, or is in the scope of a + quantifier. The result of the transformation will be + in skolem normal form, and the body of quantifiers + will be in NNF. If a ground formula is too expensive to + be put into NNF, then nested quantifiers and labels + are renamed. + + This mode is sufficient when using Superposition + Calculus. + + Remark: If the problem does not contain quantifiers, + then NNF_QUANT is identical to NNF_SKOLEM. + */ + NNF_OPPORTUNISTIC, /* Similar to NNF_QUANT, but a subformula is + also put into NNF, if it is + cheap. Otherwise, the nested quantifiers and + labels are renamed. */ + NNF_FULL /* Everything is put into NNF. */ +}; + class skolemizer { typedef act_cache cache; @@ -113,20 +148,16 @@ class skolemizer { } public: - skolemizer(ast_manager & m, params_ref const & p): + skolemizer(ast_manager & m): m_manager(m), m_sk_hack("sk_hack"), + m_sk_hack_enabled(false), m_cache(m), m_cache_pr(m) { - updt_params(p); } - void updt_params(params_ref const & p) { - m_sk_hack_enabled = p.get_bool("sk_hack", false); - } - - static void get_param_descrs(param_descrs & r) { - r.insert("sk_hack", CPK_BOOL, "(default: false) hack for VCC"); + void set_sk_hack(bool f) { + m_sk_hack_enabled = f; } ast_manager & m() const { return m_manager; } @@ -220,8 +251,6 @@ struct nnf::imp { name_exprs * m_name_nested_formulas; name_exprs * m_name_quant; - symbol m_skolem; - volatile bool m_cancel; unsigned long long m_max_memory; // in bytes @@ -231,10 +260,9 @@ struct nnf::imp { m_todo_defs(m), m_todo_proofs(m), m_result_pr_stack(m), - m_skolemizer(m, p), - m_skolem("skolem"), + m_skolemizer(m), m_cancel(false) { - updt_local_params(p); + updt_params(p); for (unsigned i = 0; i < 4; i++) { m_cache[i] = alloc(act_cache, m); if (m.proofs_enabled()) @@ -258,14 +286,10 @@ struct nnf::imp { del_name_exprs(m_name_quant); } - void updt_params(params_ref const & p) { - updt_local_params(p); - m_skolemizer.updt_params(p); - } - - void updt_local_params(params_ref const & p) { - symbol mode_sym = p.get_sym("mode", m_skolem); - if (mode_sym == m_skolem) + void updt_params(params_ref const & _p) { + nnf_params p(_p); + symbol mode_sym = p.mode(); + if (mode_sym == "skolem") m_mode = NNF_SKOLEM; else if (mode_sym == "full") m_mode = NNF_FULL; @@ -273,23 +297,17 @@ struct nnf::imp { m_mode = NNF_QUANT; else throw nnf_params_exception("invalid NNF mode"); + + TRACE("nnf", tout << "nnf-mode: " << m_mode << " " << mode_sym << "\n" << _p << "\n";); - TRACE("nnf", tout << "nnf-mode: " << m_mode << " " << mode_sym << "\n" << p << "\n";); - - m_ignore_labels = p.get_bool("ignore_labels", false); - m_skolemize = p.get_bool("skolemize", true); - m_max_memory = megabytes_to_bytes(p.get_uint("max_memory", UINT_MAX)); + m_ignore_labels = p.ignore_labels(); + m_skolemize = p.skolemize(); + m_max_memory = megabytes_to_bytes(p.max_memory()); + m_skolemizer.set_sk_hack(p.sk_hack()); } static void get_param_descrs(param_descrs & r) { - insert_max_memory(r); - r.insert("mode", CPK_SYMBOL, - "(default: skolem) NNF translation mode: skolem (skolem normal form), quantifiers (skolem normal form + quantifiers in NNF), full"); - r.insert("ignore_labels", CPK_BOOL, - "(default: false) remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); - r.insert("skolemize", CPK_BOOL, - "(default: true) skolemize (existential force) quantifiers"); - skolemizer::get_param_descrs(r); + nnf_params::collect_param_descrs(r); } void reset() { @@ -881,21 +899,6 @@ nnf::nnf(ast_manager & m, defined_names & n, params_ref const & p) { m_imp = alloc(imp, m, n, p); } -nnf::nnf(ast_manager & m, defined_names & n, nnf_params & np) { - params_ref p; - if (np.m_nnf_mode == NNF_FULL) - p.set_sym("mode", symbol("full")); - else if (np.m_nnf_mode == NNF_QUANT) - p.set_sym("mode", symbol("quantifiers")); - - if (np.m_nnf_ignore_labels) - p.set_bool("ignore_labels", true); - - if (np.m_nnf_sk_hack) - p.set_bool("sk_hack", true); - m_imp = alloc(imp, m, n, p); -} - nnf::~nnf() { dealloc(m_imp); } diff --git a/src/ast/normal_forms/nnf.h b/src/ast/normal_forms/nnf.h index 96807afc0..e8296e933 100644 --- a/src/ast/normal_forms/nnf.h +++ b/src/ast/normal_forms/nnf.h @@ -21,7 +21,6 @@ Notes: #define _NNF_H_ #include"ast.h" -#include"nnf_params.h" #include"params.h" #include"defined_names.h" @@ -30,7 +29,6 @@ class nnf { imp * m_imp; public: nnf(ast_manager & m, defined_names & n, params_ref const & p = params_ref()); - nnf(ast_manager & m, defined_names & n, nnf_params & params); // for backward compatibility ~nnf(); void operator()(expr * n, // [IN] expression that should be put into NNF diff --git a/src/ast/normal_forms/nnf_params.pyg b/src/ast/normal_forms/nnf_params.pyg new file mode 100644 index 000000000..6fab28f11 --- /dev/null +++ b/src/ast/normal_forms/nnf_params.pyg @@ -0,0 +1,8 @@ +def_module_params('nnf', + export=True, + params=(max_memory_param(), + ('sk_hack', BOOL, False, 'hack for VCC'), + ('mode', SYMBOL, 'skolem', + 'NNF translation mode: skolem (skolem normal form), quantifiers (skolem normal form + quantifiers in NNF), full'), + ('ignore_labels', BOOL, False, 'remove/ignore labels in the input formula, this option is ignored if proofs are enabled'), + ('skolemize', BOOL, True, 'skolemize (existential force) quantifiers'))) diff --git a/src/front_end_params/cnf_params.cpp b/src/front_end_params/cnf_params.cpp deleted file mode 100644 index fffd698a6..000000000 --- a/src/front_end_params/cnf_params.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - cnf_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-23. - -Revision History: - ---*/ - -#include"cnf_params.h" - -void cnf_params::register_params(ini_params & p) { - p.register_unsigned_param("cnf_factor", m_cnf_factor, "the maximum number of clauses that can be created when converting a subformula"); - p.register_int_param("cnf_mode", 0, 3, reinterpret_cast(m_cnf_mode), "CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - 0 + opportunistic, 3 - full"); -} - diff --git a/src/front_end_params/cnf_params.h b/src/front_end_params/cnf_params.h deleted file mode 100644 index f694e1716..000000000 --- a/src/front_end_params/cnf_params.h +++ /dev/null @@ -1,56 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - cnf_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-23. - -Revision History: - ---*/ -#ifndef _CNF_PARAMS_H_ -#define _CNF_PARAMS_H_ - -#include"ini_file.h" - -/** - \brief CNF translation mode. The cheapest mode is CNF_QUANT, and - the most expensive is CNF_FULL. -*/ -enum cnf_mode { - CNF_DISABLED, /* CNF translator is disabled. - This mode is sufficient when using E-matching. - */ - CNF_QUANT, /* A subformula is put into CNF if it is inside of a - quantifier. - - This mode is sufficient when using Superposition - Calculus. - */ - CNF_OPPORTUNISTIC, /* a subformula is also put in CNF if it is cheap. */ - CNF_FULL /* Everything is put into CNF, new names are introduced - if it is too expensive. */ -}; - -struct cnf_params { - cnf_mode m_cnf_mode; - unsigned m_cnf_factor; - cnf_params(): - m_cnf_mode(CNF_DISABLED), - m_cnf_factor(4) { - } - - void register_params(ini_params & p); -}; - - -#endif /* _CNF_PARAMS_H_ */ - diff --git a/src/front_end_params/nnf_params.cpp b/src/front_end_params/nnf_params.cpp deleted file mode 100644 index 351997f98..000000000 --- a/src/front_end_params/nnf_params.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - nnf_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-14. - -Revision History: - ---*/ -#include"nnf_params.h" - -void nnf_params::register_params(ini_params & p) { - p.register_unsigned_param("nnf_factor", m_nnf_factor, "the maximum growth factor during NNF translation (auxiliary definitions are introduced if the threshold is reached)"); - p.register_int_param("nnf_mode", 0, 3, reinterpret_cast(m_nnf_mode), "NNF translation mode: 0 - skolem normal form, 1 - 0 + quantifiers in NNF, 2 - 1 + opportunistic, 3 - full"); - p.register_bool_param("nnf_ignore_labels", m_nnf_ignore_labels, "remove/ignore labels in the input formula, this option is ignored if proofs are enabled"); - p.register_bool_param("nnf_sk_hack", m_nnf_sk_hack, "hack for VCC"); -} diff --git a/src/front_end_params/nnf_params.h b/src/front_end_params/nnf_params.h deleted file mode 100644 index f759a93ac..000000000 --- a/src/front_end_params/nnf_params.h +++ /dev/null @@ -1,74 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - nnf_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-14. - -Revision History: - ---*/ -#ifndef _NNF_PARAMS_H_ -#define _NNF_PARAMS_H_ - -#include"ini_file.h" - -/** - \brief NNF translation mode. The cheapest mode is NNF_SKOLEM, and - the most expensive is NNF_FULL. -*/ -enum nnf_mode { - NNF_SKOLEM, /* A subformula is put into NNF only if it contains - quantifiers or labels. The result of the - transformation will be in skolem normal form. - If a formula is too expensive to be put into NNF, - then nested quantifiers and labels are renamed. - - This mode is sufficient when using E-matching. - */ - NNF_QUANT, /* A subformula is put into NNF if it contains - quantifiers, labels, or is in the scope of a - quantifier. The result of the transformation will be - in skolem normal form, and the body of quantifiers - will be in NNF. If a ground formula is too expensive to - be put into NNF, then nested quantifiers and labels - are renamed. - - This mode is sufficient when using Superposition - Calculus. - - Remark: If the problem does not contain quantifiers, - then NNF_QUANT is identical to NNF_SKOLEM. - */ - NNF_OPPORTUNISTIC, /* Similar to NNF_QUANT, but a subformula is - also put into NNF, if it is - cheap. Otherwise, the nested quantifiers and - labels are renamed. */ - NNF_FULL /* Everything is put into NNF. */ -}; - -struct nnf_params { - nnf_mode m_nnf_mode; - unsigned m_nnf_factor; - bool m_nnf_ignore_labels; - bool m_nnf_sk_hack; - nnf_params(): - m_nnf_mode(NNF_SKOLEM), - m_nnf_factor(4), - m_nnf_ignore_labels(false), - m_nnf_sk_hack(false) { - } - - void register_params(ini_params & p); -}; - -#endif /* _NNF_PARAMS_H_ */ - diff --git a/src/front_end_params/preprocessor_params.h b/src/front_end_params/preprocessor_params.h index 89bd01b48..00466bc02 100644 --- a/src/front_end_params/preprocessor_params.h +++ b/src/front_end_params/preprocessor_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _PREPROCESSOR_PARAMS_H_ #define _PREPROCESSOR_PARAMS_H_ -#include"nnf_params.h" -#include"cnf_params.h" #include"pattern_inference_params.h" #include"bit_blaster_params.h" #include"bv_simplifier_params.h" @@ -31,7 +29,7 @@ enum lift_ite_kind { LI_FULL }; -struct preprocessor_params : public nnf_params, public cnf_params, public pattern_inference_params, +struct preprocessor_params : public pattern_inference_params, public bit_blaster_params, public bv_simplifier_params { lift_ite_kind m_lift_ite; lift_ite_kind m_ng_lift_ite; // lift ite for non ground terms @@ -79,8 +77,6 @@ public: } void register_params(ini_params & p) { - nnf_params::register_params(p); - cnf_params::register_params(p); pattern_inference_params::register_params(p); bit_blaster_params::register_params(p); bv_simplifier_params::register_params(p); diff --git a/src/front_end_params/smt_params.cpp b/src/front_end_params/smt_params.cpp index 14db6020a..74e279ff8 100644 --- a/src/front_end_params/smt_params.cpp +++ b/src/front_end_params/smt_params.cpp @@ -31,7 +31,6 @@ void smt_params::register_params(ini_params & p) { p.register_bool_param("display_proof", m_display_proof); p.register_bool_param("display_dot_proof", m_display_dot_proof); p.register_bool_param("display_unsat_core", m_display_unsat_core); - p.register_bool_param("internalizer_nnf", m_internalizer_nnf); p.register_bool_param("eq_propagation", m_eq_propagation); p.register_bool_param("bin_clauses", m_binary_clause_opt); p.register_unsigned_param("relevancy", m_relevancy_lvl, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant", true); diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 20a150c64..5c62c49e3 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -72,7 +72,6 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith bool m_display_dot_proof; bool m_display_unsat_core; bool m_check_proof; - bool m_internalizer_nnf; bool m_eq_propagation; bool m_binary_clause_opt; unsigned m_relevancy_lvl; @@ -193,7 +192,6 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith m_display_dot_proof(false), m_display_unsat_core(false), m_check_proof(false), - m_internalizer_nnf(false), m_eq_propagation(true), m_binary_clause_opt(true), m_relevancy_lvl(2), diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 15b49ee32..c548eca94 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -25,12 +25,12 @@ Revision History: #include"bv_simplifier_plugin.h" #include"for_each_expr.h" #include"well_sorted.h" +#include"pull_quant.h" #include"pull_ite_tree.h" #include"push_app_ite.h" #include"elim_term_ite.h" #include"pattern_inference.h" #include"nnf.h" -#include"cnf.h" #include"bv_elim.h" #include"inj_axiom.h" #include"der.h" @@ -86,22 +86,6 @@ void asserted_formulas::setup() { if (m_params.m_relevancy_lvl == 0) m_params.m_relevancy_lemma = false; - - switch (m_params.m_cnf_mode) { - case CNF_QUANT: - if (m_params.m_nnf_mode == NNF_SKOLEM) - m_params.m_nnf_mode = NNF_QUANT; - break; - case CNF_OPPORTUNISTIC: - if (m_params.m_nnf_mode == NNF_SKOLEM) - m_params.m_nnf_mode = NNF_QUANT; - break; - case CNF_FULL: - m_params.m_nnf_mode = NNF_FULL; - break; - default: - break; - } } void asserted_formulas::setup_simplifier_plugins(simplifier & s, basic_simplifier_plugin * & bsimp, arith_simplifier_plugin * & asimp, bv_simplifier_plugin * & bvsimp) { @@ -439,13 +423,10 @@ void asserted_formulas::apply_quasi_macros() { } void asserted_formulas::nnf_cnf() { - IF_IVERBOSE(10, verbose_stream() << "applying nnf&cnf...\n";); - nnf apply_nnf(m_manager, m_defined_names, m_params); - cnf apply_cnf(m_manager, m_defined_names, m_params); + IF_IVERBOSE(10, verbose_stream() << "applying nnf...\n";); + nnf apply_nnf(m_manager, m_defined_names); expr_ref_vector new_exprs(m_manager); proof_ref_vector new_prs(m_manager); - expr_ref_vector cnf_todo(m_manager); - proof_ref_vector cnf_todo_prs(m_manager); expr_ref_vector push_todo(m_manager); proof_ref_vector push_todo_prs(m_manager); @@ -456,60 +437,33 @@ void asserted_formulas::nnf_cnf() { expr * n = m_asserted_formulas.get(i); TRACE("nnf_bug", tout << "processing:\n" << mk_pp(n, m_manager) << "\n";); proof * pr = m_asserted_formula_prs.get(i, 0); - cnf_todo.reset(); - cnf_todo_prs.reset(); expr_ref r1(m_manager); proof_ref pr1(m_manager); CASSERT("well_sorted",is_well_sorted(m_manager, n)); - apply_nnf(n, cnf_todo, cnf_todo_prs, r1, pr1); + apply_nnf(n, push_todo, push_todo_prs, r1, pr1); CASSERT("well_sorted",is_well_sorted(m_manager, r1)); pr = m_manager.mk_modus_ponens(pr, pr1); - cnf_todo.push_back(r1); - cnf_todo_prs.push_back(pr); + push_todo.push_back(r1); + push_todo_prs.push_back(pr); if (canceled()) { return; } - - unsigned sz1 = cnf_todo.size(); - for (unsigned j = 0; j < sz1; j++) { - push_todo.reset(); - push_todo_prs.reset(); - + unsigned sz2 = push_todo.size(); + for (unsigned k = 0; k < sz2; k++) { + expr * n = push_todo.get(k); + proof * pr = 0; + m_simplifier(n, r1, pr1); + CASSERT("well_sorted",is_well_sorted(m_manager, r1)); if (canceled()) { return; } - - expr * n = cnf_todo.get(j); - proof * pr = m_manager.proofs_enabled() ? cnf_todo_prs.get(j) : 0; - - CASSERT("well_sorted",is_well_sorted(m_manager, n)); - apply_cnf(n, push_todo, push_todo_prs, r1, pr1); - CASSERT("well_sorted",is_well_sorted(m_manager, r1)); - - push_todo.push_back(r1); - - if (m_manager.proofs_enabled()) { - pr = m_manager.mk_modus_ponens(pr, pr1); - push_todo_prs.push_back(pr); - } - - unsigned sz2 = push_todo.size(); - for (unsigned k = 0; k < sz2; k++) { - expr * n = push_todo.get(k); - proof * pr = 0; - m_simplifier(n, r1, pr1); - CASSERT("well_sorted",is_well_sorted(m_manager, r1)); - if (canceled()) { - return; - } - - if (m_manager.proofs_enabled()) - pr = m_manager.mk_modus_ponens(push_todo_prs.get(k), pr1); - else - pr = 0; - push_assertion(r1, pr, new_exprs, new_prs); - } + + if (m_manager.proofs_enabled()) + pr = m_manager.mk_modus_ponens(push_todo_prs.get(k), pr1); + else + pr = 0; + push_assertion(r1, pr, new_exprs, new_prs); } } swap_asserted_formulas(new_exprs, new_prs); diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index b44d42fc8..132718e9a 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -654,10 +654,6 @@ namespace smt { protected: unsigned m_generation; //!< temporary variable used during internalization - bool expand_pos_def_only() const { - return m_fparams.m_nnf_mode == NNF_FULL && m_fparams.m_internalizer_nnf; - } - public: bool binary_clause_opt_enabled() const { return !m_manager.proofs_enabled() && m_fparams.m_binary_clause_opt; diff --git a/src/smt/smt_internalizer.cpp b/src/smt/smt_internalizer.cpp index 86b1641bc..0cfe5b1de 100644 --- a/src/smt/smt_internalizer.cpp +++ b/src/smt/smt_internalizer.cpp @@ -1566,9 +1566,7 @@ namespace smt { mk_gate_clause(~l, l_arg); buffer.push_back(~l_arg); } - if (!expand_pos_def_only()) { - mk_gate_clause(buffer.size(), buffer.c_ptr()); - } + mk_gate_clause(buffer.size(), buffer.c_ptr()); } void context::mk_or_cnstr(app * n) { @@ -1578,8 +1576,7 @@ namespace smt { unsigned num_args = n->get_num_args(); for (unsigned i = 0; i < num_args; i++) { literal l_arg = get_literal(n->get_arg(i)); - if (!expand_pos_def_only()) - mk_gate_clause(l, ~l_arg); + mk_gate_clause(l, ~l_arg); buffer.push_back(l_arg); } mk_gate_clause(buffer.size(), buffer.c_ptr()); From be5f93320123c198997e1a5567a1417d0f020e74 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Fri, 30 Nov 2012 18:20:07 -0800 Subject: [PATCH 10/34] removed dead module Signed-off-by: Leonardo de Moura --- src/ast/normal_forms/cnf.cpp | 527 ---------------------------- src/ast/normal_forms/cnf.h | 141 -------- src/ast/normal_forms/cnf_params.pyg | 4 - 3 files changed, 672 deletions(-) delete mode 100644 src/ast/normal_forms/cnf.cpp delete mode 100644 src/ast/normal_forms/cnf.h delete mode 100644 src/ast/normal_forms/cnf_params.pyg diff --git a/src/ast/normal_forms/cnf.cpp b/src/ast/normal_forms/cnf.cpp deleted file mode 100644 index 2a58b16a6..000000000 --- a/src/ast/normal_forms/cnf.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - cnf.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-01-23. - -Revision History: - ---*/ -#include"cnf.h" -#include"cnf_params.hpp" -#include"var_subst.h" -#include"ast_util.h" -#include"ast_pp.h" -#include"ast_ll_pp.h" - -unsigned cnf_entry::hash() const { - unsigned a = m_node->get_id(); - unsigned b = m_polarity; - unsigned c = m_in_q; - mix(a,b,c); - return c; -} - -bool cnf_entry::operator==(cnf_entry const & k) const { - return m_node == k.m_node && m_polarity == k.m_polarity && m_in_q == k.m_in_q; -} - -cnf_cache::cnf_cache(ast_manager & m): - m_manager(m) { -} - -void cnf_cache::insert(cnf_entry const & k, expr * r, proof * pr) { - SASSERT(!m_cache.contains(k)); - m_manager.inc_ref(r); - m_manager.inc_ref(pr); - m_cache.insert(k, expr_proof_pair(r, pr)); -} - -void cnf_cache::reset() { - cache::iterator it = m_cache.begin(); - cache::iterator end = m_cache.end(); - for (; it != end; ++it) { - expr_proof_pair & pair = (*it).m_value; - m_manager.dec_ref(pair.first); - m_manager.dec_ref(pair.second); - } - m_cache.reset(); -} - -void cnf::cache_result(expr * e, bool in_q, expr * r, proof * pr) { - SASSERT(r); - TRACE("cnf", tout << "caching result for: " << e->get_id() << " " << r->get_id() << "\n";); - m_cache.insert(cnf_entry(e, true, in_q), r, pr); -} - -void cnf::visit(expr * n, bool in_q, bool & visited) { - if (!is_cached(n, in_q)) { - m_todo.push_back(std::make_pair(n, in_q)); - visited = false; - } -} - -bool cnf::visit_children(expr * n, bool in_q) { - bool visited = true; - switch(n->get_kind()) { - case AST_APP: - if (m_manager.is_or(n) || m_manager.is_and(n) || m_manager.is_label(n)) { - unsigned j = to_app(n)->get_num_args(); - while (j > 0) { - --j; - visit(to_app(n)->get_arg(j), in_q, visited); - } - } - break; - case AST_QUANTIFIER: - visit(to_quantifier(n)->get_expr(), true, visited); - break; - default: - break; - } - return visited; -} - -void cnf::reduce1(expr * n, bool in_q) { - switch(n->get_kind()) { - case AST_APP: - if (m_manager.is_or(n)) - reduce1_or(to_app(n), in_q); - else if (m_manager.is_and(n)) - reduce1_and(to_app(n), in_q); - else if (m_manager.is_label(n)) - reduce1_label(to_app(n), in_q); - else - cache_result(n, in_q, n, 0); - break; - case AST_QUANTIFIER: - reduce1_quantifier(to_quantifier(n), in_q); - break; - default: - cache_result(n, in_q, n, 0); - break; - } -} - -void cnf::get_args(app * n, bool in_q, ptr_buffer & new_args, ptr_buffer & new_arg_prs) { - unsigned num = n->get_num_args(); - for (unsigned i = 0; i < num; i++) { - expr * new_arg = 0; - proof * new_arg_pr = 0; - get_cached(n->get_arg(i), in_q, new_arg, new_arg_pr); - SASSERT(new_arg); - new_args.push_back(new_arg); - if (new_arg_pr) - new_arg_prs.push_back(new_arg_pr); - } -} - -void cnf::flat_args(func_decl * d, ptr_buffer const & args, ptr_buffer & flat_args) { - ptr_buffer::const_iterator it = args.begin(); - ptr_buffer::const_iterator end = args.end(); - for (; it != end; ++it) { - expr * arg = *it; - if (is_app_of(arg, d)) - flat_args.append(to_app(arg)->get_num_args(), to_app(arg)->get_args()); - else - flat_args.push_back(arg); - } -} - -/** - \brief Return the approximated size of distributing OR over AND on - (OR args[0] .... args[sz-1]) -*/ -approx_nat cnf::approx_result_size_for_disj(ptr_buffer const & args) { - approx_nat r(1); - ptr_buffer::const_iterator it = args.begin(); - ptr_buffer::const_iterator end = args.end(); - for (; it != end; ++it) { - expr * arg = *it; - if (m_manager.is_and(arg)) - r *= to_app(arg)->get_num_args(); - } - return r; -} - -/** - \brief Return true if it is too expensive to process the disjunction of args -*/ -inline bool cnf::is_too_expensive(approx_nat approx_result_size, ptr_buffer const & args) { - // (OR A (AND B C)) is always considered cheap. - if (args.size() == 2 && (!m_manager.is_and(args[0]) || !m_manager.is_and(args[1]))) - return false; - return !(approx_result_size < m_cnf_factor); -} - -/** - \brief Create a (positive) name for the expressions of the form (AND ...) in args. - Store the result in new_args. -*/ -void cnf::name_args(ptr_buffer const & args, expr_ref_buffer & new_args, proof_ref_buffer & new_arg_prs) { - ptr_buffer::const_iterator it = args.begin(); - ptr_buffer::const_iterator end = args.end(); - for (; it != end; ++it) { - expr * arg = *it; - if (m_manager.is_and(arg)) { - expr_ref new_def(m_manager); - proof_ref new_def_pr(m_manager); - app_ref new_arg(m_manager); - proof_ref new_arg_pr(m_manager); - - if (m_defined_names.mk_pos_name(to_app(arg), new_def, new_def_pr, new_arg, new_arg_pr)) { - m_todo_defs.push_back(new_def); - if (m_manager.proofs_enabled()) - m_todo_proofs.push_back(new_def_pr); - } - new_args.push_back(new_arg); - - if (m_manager.fine_grain_proofs()) - new_arg_prs.push_back(new_arg_pr); - else - m_coarse_proofs.push_back(new_arg_pr); - } - else - new_args.push_back(arg); - } -} - -void cnf::distribute(app * n, app * & r, proof * & pr) { - SASSERT(m_manager.is_or(n)); - buffer sz; - buffer it; - ptr_buffer new_args; - unsigned num = n->get_num_args(); - for (unsigned i = 0; i < num; i++) { - expr * arg = n->get_arg(i); - it.push_back(0); - if (m_manager.is_and(arg)) - sz.push_back(to_app(arg)->get_num_args()); - else - sz.push_back(1); - } - - do { - ptr_buffer lits; - for (unsigned i = 0; i < num; i++) { - expr * arg = n->get_arg(i); - if (m_manager.is_and(arg)) { - SASSERT(it[i] < to_app(arg)->get_num_args()); - lits.push_back(to_app(arg)->get_arg(it[i])); - } - else { - SASSERT(it[i] == 0); - lits.push_back(arg); - } - } - app * n = m_manager.mk_or(lits.size(), lits.c_ptr()); - new_args.push_back(n); - } - while (product_iterator_next(sz.size(), sz.c_ptr(), it.c_ptr())); - SASSERT(!new_args.empty()); - if (new_args.size() == 1) - r = to_app(new_args[0]); - else - r = m_manager.mk_and(new_args.size(), new_args.c_ptr()); - pr = 0; - if (m_manager.fine_grain_proofs() && r != n) - pr = m_manager.mk_iff_oeq(m_manager.mk_distributivity(n, r)); -} - -void cnf::push_quant(quantifier * q, expr * & r, proof * & pr) { - SASSERT(is_forall(q)); - expr * e = q->get_expr(); - pr = 0; - if (m_manager.is_and(e)) { - expr_ref_buffer new_args(m_manager); - unsigned num = to_app(e)->get_num_args(); - for (unsigned i = 0; i < num; i++) { - quantifier_ref aux(m_manager); - aux = m_manager.update_quantifier(q, 0, 0, 0, 0, to_app(e)->get_arg(i)); - expr_ref new_arg(m_manager); - elim_unused_vars(m_manager, aux, new_arg); - new_args.push_back(new_arg); - } - r = m_manager.mk_and(new_args.size(), new_args.c_ptr()); - if (m_manager.fine_grain_proofs()) - pr = m_manager.mk_iff_oeq(m_manager.mk_push_quant(q, r)); - } - else { - r = q; - } -} - -void cnf::reduce1_or(app * n, bool in_q) { - ptr_buffer new_args; - ptr_buffer new_arg_prs; - get_args(n, in_q, new_args, new_arg_prs); - expr * r; - proof * pr = 0; - if (in_q || m_cnf_mode == CNF_OPPORTUNISTIC || m_cnf_mode == CNF_FULL) { - ptr_buffer f_args; - flat_args(n->get_decl(), new_args, f_args); - TRACE("cnf_or", for (unsigned i = 0; i < f_args.size(); i++) tout << mk_pp(f_args[i], m_manager) << "\n";); - approx_nat result_size = approx_result_size_for_disj(f_args); - TRACE("cnf_or", tout << mk_pp(n, m_manager) << "\napprox. result: " << result_size << "\n";); - if (m_cnf_mode != CNF_OPPORTUNISTIC || result_size < m_cnf_factor) { - expr_ref_buffer cheap_args(m_manager); - proof_ref_buffer cheap_args_pr(m_manager); - if (is_too_expensive(result_size, f_args)) { - name_args(f_args, cheap_args, cheap_args_pr); - } - else { - cheap_args.append(f_args.size(), f_args.c_ptr()); - } - - app_ref r1(m_manager); - r1 = m_manager.mk_or(cheap_args.size(), cheap_args.c_ptr()); - - // Proof gen support --------------------------- - // r1 is (OR cheap_args) it is only built if proofs are enabled. - // p1 is a proof for (= n r1) - proof * p1 = 0; - if (m_manager.fine_grain_proofs()) { - proof * prs[3]; - app * r[2]; - r[0] = m_manager.mk_or(new_args.size(), new_args.c_ptr()); - prs[0] = n == r[0] ? 0 : m_manager.mk_oeq_congruence(n, r[0], new_arg_prs.size(), new_arg_prs.c_ptr()); - r[1] = m_manager.mk_or(f_args.size(), f_args.c_ptr()); - prs[1] = r[0] == r[1] ? 0 : m_manager.mk_iff_oeq(m_manager.mk_rewrite(r[0], r[1])); - prs[2] = r[1] == r1 ? 0 : m_manager.mk_oeq_congruence(r[1], r1, cheap_args_pr.size(), cheap_args_pr.c_ptr()); - p1 = m_manager.mk_transitivity(3, prs); - } - // -------------------------------------------- - - expr_ref r2(m_manager); - proof_ref p2(m_manager); - m_pull.pull_quant2(r1, r2, p2); - - if (is_quantifier(r2)) { - expr * e = to_quantifier(r2)->get_expr(); - SASSERT(m_manager.is_or(e)); - app * d_r; - proof * d_pr; - distribute(to_app(e), d_r, d_pr); - quantifier_ref r3(m_manager); - r3 = m_manager.update_quantifier(to_quantifier(r2), d_r); - proof * push_pr; - push_quant(r3, r, push_pr); - if (m_manager.fine_grain_proofs()) { - // p1 is a proof of n == r1 - // p2 is a proof of r1 == r2 - p2 = p2 == 0 ? 0 : m_manager.mk_iff_oeq(p2); - proof * p3 = r2 == r3 ? 0 : m_manager.mk_oeq_quant_intro(to_quantifier(r2), r3, d_pr); - CTRACE("cnf_or", p1, tout << "p1:\n" << mk_pp(m_manager.get_fact(p1), m_manager) << "\n";); - CTRACE("cnf_or", p2, tout << "p2:\n" << mk_pp(m_manager.get_fact(p2), m_manager) << "\n";); - CTRACE("cnf_or", p3, tout << "p3:\n" << mk_pp(m_manager.get_fact(p3), m_manager) << "\n";); - TRACE("cnf_or", tout << "r2 == r3: " << (r2 == r3) << "\n" - << mk_pp(r2, m_manager) << "\n" << mk_pp(r3, m_manager) << "\n";); - pr = m_manager.mk_transitivity(p1, p2, p3, push_pr); - } - cache_result(n, in_q, r, pr); - } - else { - SASSERT(p2 == 0); - SASSERT(r1 == r2); - SASSERT(m_manager.is_or(r2)); - app * r3; - distribute(to_app(r2), r3, pr); - r = r3; - pr = m_manager.mk_transitivity(p1, pr); - cache_result(n, in_q, r, pr); - } - return; - } - } - - r = m_manager.mk_or(new_args.size(), new_args.c_ptr()); - if (m_manager.fine_grain_proofs() && n != r) - pr = m_manager.mk_oeq_congruence(n, to_app(r), new_arg_prs.size(), new_arg_prs.c_ptr()); - cache_result(n, in_q, r, pr); -} - -void cnf::reduce1_and(app * n, bool in_q) { - ptr_buffer new_args; - ptr_buffer new_arg_prs; - get_args(n, in_q, new_args, new_arg_prs); - app * r; - proof * pr = 0; - if (in_q || m_cnf_mode == CNF_OPPORTUNISTIC || m_cnf_mode == CNF_FULL) { - ptr_buffer f_args; - flat_args(n->get_decl(), new_args, f_args); - r = m_manager.mk_and(f_args.size(), f_args.c_ptr()); - if (m_manager.fine_grain_proofs() && n != r) { - app * r0 = m_manager.mk_and(new_args.size(), new_args.c_ptr()); - proof * p0 = r0 == n ? 0 : m_manager.mk_oeq_congruence(n, r0, new_arg_prs.size(), new_arg_prs.c_ptr()); - proof * p1 = r0 == r ? 0 : m_manager.mk_iff_oeq(m_manager.mk_rewrite(r0, r)); - pr = m_manager.mk_transitivity(p0, p1); - } - } - else { - r = m_manager.mk_and(new_args.size(), new_args.c_ptr()); - if (m_manager.fine_grain_proofs() && n != r) - pr = m_manager.mk_oeq_congruence(n, r, new_arg_prs.size(), new_arg_prs.c_ptr()); - } - cache_result(n, in_q, r, pr); -} - -void cnf::reduce1_label(app * n, bool in_q) { - expr * r; - proof * pr = 0; - expr * new_arg; - proof * new_arg_pr; - get_cached(n->get_arg(0), true, new_arg, new_arg_pr); - if (in_q || m_cnf_mode == CNF_FULL) { - // TODO: in the current implementation, labels are removed during CNF translation. - // This is satisfactory for Boogie, since it does not use labels inside quantifiers, - // and we only need CNF_QUANT for Superposition Calculus. - r = new_arg; - if (m_manager.fine_grain_proofs()) { - proof * p0 = m_manager.mk_iff_oeq(m_manager.mk_rewrite(n, n->get_arg(0))); - pr = m_manager.mk_transitivity(p0, new_arg_pr); - } - } - else { - r = m_manager.mk_app(n->get_decl(), new_arg); - if (m_manager.fine_grain_proofs() && n != r) - pr = m_manager.mk_oeq_congruence(n, to_app(r), 1, &new_arg_pr); - } - cache_result(n, in_q, r, pr); -} - -void cnf::reduce1_quantifier(quantifier * q, bool in_q) { - expr * new_expr; - proof * new_expr_pr; - get_cached(q->get_expr(), true, new_expr, new_expr_pr); - expr_ref r(m_manager); - proof_ref pr(m_manager); - if (m_manager.is_and(new_expr) && q->is_forall()) { - quantifier_ref q1(m_manager); - q1 = m_manager.update_quantifier(q, new_expr); - expr_ref q2(m_manager); - proof_ref p2(m_manager); - m_pull.pull_quant2(q1, q2, p2); - expr * q3; - proof * p3; - push_quant(to_quantifier(q2), q3, p3); - r = q3; - if (m_manager.fine_grain_proofs()) { - proof * p1 = q == q1 ? 0 : m_manager.mk_oeq_quant_intro(q, q1, new_expr_pr); - p2 = p2 == 0 ? 0 : m_manager.mk_iff_oeq(p2); - pr = m_manager.mk_transitivity(p1, p2, p3); - } - } - else if ((m_manager.is_or(new_expr) || is_forall(new_expr)) && q->is_forall()) { - quantifier_ref q1(m_manager); - q1 = m_manager.update_quantifier(q, new_expr); - m_pull.pull_quant2(q1, r, pr); - if (m_manager.fine_grain_proofs()) { - pr = pr == 0 ? 0 : m_manager.mk_iff_oeq(pr); - proof * p1 = q == q1 ? 0 : m_manager.mk_oeq_quant_intro(q, q1, new_expr_pr); - pr = m_manager.mk_transitivity(p1, pr); - } - } - else { - r = m_manager.update_quantifier(q, new_expr); - if (m_manager.fine_grain_proofs() && r != q) - pr = q == r ? 0 : m_manager.mk_oeq_quant_intro(q, to_quantifier(r), new_expr_pr); - } - - cache_result(q, in_q, r, pr); - TRACE("cnf_quant", tout << mk_pp(q, m_manager) << "\n" << mk_pp(r, m_manager) << "\n";); -} - -cnf::cnf(ast_manager & m, defined_names & n, params_ref const & params): - m_manager(m), - m_defined_names(n), - m_pull(m), - m_cache(m), - m_todo_defs(m), - m_todo_proofs(m), - m_coarse_proofs(m) { - cnf_params p(params); - m_cnf_mode = static_cast(p.mode()); - m_cnf_factor = p.factor(); -} - -cnf::~cnf() { -} - -void cnf::reduce(expr * n, expr_ref & r, proof_ref & pr) { - m_coarse_proofs.reset(); - m_todo.reset(); - m_todo.push_back(expr_bool_pair(n, false)); - while (!m_todo.empty()) { - expr_bool_pair pair = m_todo.back(); - expr * n = pair.first; - bool in_q = pair.second; - if (is_cached(n, in_q)) { - m_todo.pop_back(); - } - else if (visit_children(n, in_q)) { - m_todo.pop_back(); - reduce1(n, in_q); - } - } - expr * r2; - proof * pr2; - get_cached(n, false, r2, pr2); - r = r2; - switch (m_manager.proof_mode()) { - case PGM_DISABLED: - pr = m_manager.mk_undef_proof(); - break; - case PGM_COARSE: - remove_duplicates(m_coarse_proofs); - pr = n == r2 ? m_manager.mk_reflexivity(n) : m_manager.mk_cnf_star(n, r2, m_coarse_proofs.size(), m_coarse_proofs.c_ptr()); - break; - case PGM_FINE: - pr = pr2 == 0 ? m_manager.mk_reflexivity(n) : pr2; - break; - } -} - -void cnf::operator()(expr * n, expr_ref_vector & new_defs, proof_ref_vector & new_def_proofs, expr_ref & r, proof_ref & pr) { - if (m_cnf_mode == CNF_DISABLED) { - r = n; - pr = m_manager.mk_reflexivity(n); - return; - } - - reset(); - reduce(n, r, pr); - for (unsigned i = 0; i < m_todo_defs.size(); i++) { - expr_ref dr(m_manager); - proof_ref dpr(m_manager); - reduce(m_todo_defs.get(i), dr, dpr); - m_result_defs.push_back(dr); - if (m_manager.proofs_enabled()) { - proof * new_pr = m_manager.mk_modus_ponens(m_todo_proofs.get(i), dpr); - m_result_def_proofs.push_back(new_pr); - } - else - m_result_def_proofs.push_back(m_manager.mk_undef_proof()); - } - std::reverse(m_result_defs.begin(), m_result_defs.end()); - new_defs.append(m_result_defs.size(), m_result_defs.c_ptr()); - std::reverse(m_result_def_proofs.begin(), m_result_def_proofs.end()); - new_def_proofs.append(m_result_def_proofs.size(), m_result_def_proofs.c_ptr()); -} - -void cnf::reset() { - m_cache.reset(); - m_todo.reset(); - m_todo_defs.reset(); - m_todo_proofs.reset(); - m_result_defs.reset(); - m_result_def_proofs.reset(); -} diff --git a/src/ast/normal_forms/cnf.h b/src/ast/normal_forms/cnf.h deleted file mode 100644 index 8aa390c48..000000000 --- a/src/ast/normal_forms/cnf.h +++ /dev/null @@ -1,141 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - cnf.h - -Abstract: - - CNF translation - -Author: - - Leonardo de Moura (leonardo) 2008-01-17. - -Revision History: - ---*/ -#ifndef _CNF_H_ -#define _CNF_H_ - -#include"pull_quant.h" -#include"nnf.h" -#include"approx_nat.h" - -/** - \brief CNF translation mode. The cheapest mode is CNF_QUANT, and - the most expensive is CNF_FULL. -*/ -enum cnf_mode { - CNF_DISABLED, /* CNF translator is disabled. - This mode is sufficient when using E-matching. - */ - CNF_QUANT, /* A subformula is put into CNF if it is inside of a - quantifier. - - This mode is sufficient when using Superposition - Calculus. - */ - CNF_OPPORTUNISTIC, /* a subformula is also put in CNF if it is cheap. */ - CNF_FULL /* Everything is put into CNF, new names are introduced - if it is too expensive. */ -}; - -/** - \brief Entry into the todo list of the CNF translator. It is also used as the key in the CNF cache. -*/ -struct cnf_entry { - expr * m_node; - bool m_polarity:1; - bool m_in_q:1; - cnf_entry():m_node(0), m_polarity(false), m_in_q(false) {} - cnf_entry(expr * n, bool p, bool in_q):m_node(n), m_polarity(p), m_in_q(in_q) {} - unsigned hash() const; - bool operator==(cnf_entry const & k) const; -}; - -/** - \brief Cache for CNF transformation. It is a mapping from (expr, polarity, in_q) -> (expr, proof) -*/ -class cnf_cache { -public: - typedef std::pair expr_proof_pair; - - typedef map, default_eq > cache; - - ast_manager & m_manager; - cache m_cache; - -public: - cnf_cache(ast_manager & m); - ~cnf_cache() { reset(); } - void insert(cnf_entry const & k, expr * r, proof * pr); - bool contains(cnf_entry const & k) const { return m_cache.contains(k); } - void get(cnf_entry const & k, expr * & r, proof * & pr) const { expr_proof_pair tmp; m_cache.find(k, tmp); r = tmp.first; pr = tmp.second; } - void reset(); -}; - -/** - \brief Functor for converting expressions into CNF. The functor can - optionally process subformulas nested in quantifiers. New names may be - introduced for subformulas that are too expensive to be put into CNF. - - NNF translation must be applied before converting to CNF. - - - To use CNF_QUANT, we must use at least NNF_QUANT - - To use CNF_OPPORTUNISTIC, we must use at least NNF_QUANT - - To use CNF_FULL, we must use NNF_FULL -*/ -class cnf { - typedef std::pair expr_bool_pair; - ast_manager & m_manager; - defined_names & m_defined_names; - pull_quant m_pull; - cnf_cache m_cache; - svector m_todo; - expr_ref_vector m_todo_defs; - proof_ref_vector m_todo_proofs; - ptr_vector m_result_defs; - ptr_vector m_result_def_proofs; - proof_ref_vector m_coarse_proofs; - - cnf_mode m_cnf_mode; - unsigned m_cnf_factor; - - void cache_result(expr * e, bool in_q, expr * r, proof * pr); - void get_cached(expr * n, bool in_q, expr * & r, proof * & pr) const { m_cache.get(cnf_entry(n, true, in_q), r, pr); } - bool is_cached(expr * n, bool in_q) const { return m_cache.contains(cnf_entry(n, true, in_q)); } - - void visit(expr * n, bool in_q, bool & visited); - bool visit_children(expr * n, bool in_q); - - void get_args(app * n, bool in_q, ptr_buffer & new_args, ptr_buffer & new_arg_prs); - void flat_args(func_decl * d, ptr_buffer const & args, ptr_buffer & flat_args); - approx_nat approx_result_size_for_disj(ptr_buffer const & args); - bool is_too_expensive(approx_nat approx_result_size, ptr_buffer const & args); - void name_args(ptr_buffer const & args, expr_ref_buffer & new_args, proof_ref_buffer & new_arg_prs); - void distribute(app * arg, app * & r, proof * & pr); - void push_quant(quantifier * q, expr * & r, proof * & pr); - void reduce1(expr * n, bool in_q); - void reduce1_or(app * n, bool in_q); - void reduce1_and(app * n, bool in_q); - void reduce1_label(app * n, bool in_q); - void reduce1_quantifier(quantifier * q, bool in_q); - - void reduce(expr * n, expr_ref & r, proof_ref & pr); -public: - cnf(ast_manager & m, defined_names & n, params_ref const & p = params_ref()); - ~cnf(); - void operator()(expr * n, // [IN] expression that should be put into CNF - expr_ref_vector & new_defs, // [OUT] new definitions - proof_ref_vector & new_def_proofs, // [OUT] proofs of the new definitions - expr_ref & r, // [OUT] resultant expression - proof_ref & p // [OUT] proof for (~ n r) - ); - - void reset(); -}; - -#endif /* _CNF_H_ */ - diff --git a/src/ast/normal_forms/cnf_params.pyg b/src/ast/normal_forms/cnf_params.pyg deleted file mode 100644 index 3383f674a..000000000 --- a/src/ast/normal_forms/cnf_params.pyg +++ /dev/null @@ -1,4 +0,0 @@ -def_module_params('cnf', - export=True, - params=(('mode', UINT, 0, 'CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - opportunistic, 3 - full'), - ('factor', UINT, 4, 'the maximum number of clauses that can be created when converting a subformula'))) From f78e595b566cbb9d6f5d55311a046268dd97c98c Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Sat, 1 Dec 2012 15:51:33 +0000 Subject: [PATCH 11/34] Added QF_FPABV logic, default tactic, and the asIEEEBV conversion function. Signed-off-by: Christoph M. Wintersteiger --- src/ast/float_decl_plugin.cpp | 30 +++++++++++-- src/ast/float_decl_plugin.h | 9 +++- src/ast/rewriter/float_rewriter.cpp | 5 +++ src/ast/rewriter/float_rewriter.h | 2 + src/cmd_context/cmd_context.cpp | 6 ++- src/tactic/fpa/fpa2bv_converter.cpp | 45 +++++++++++++++++-- src/tactic/fpa/fpa2bv_converter.h | 1 + src/tactic/fpa/fpa2bv_rewriter.h | 1 + src/tactic/fpa/qffpa_tactic.h | 1 + src/tactic/portfolio/smt_strategic_solver.cpp | 1 + 10 files changed, 90 insertions(+), 11 deletions(-) diff --git a/src/ast/float_decl_plugin.cpp b/src/ast/float_decl_plugin.cpp index 7cf8f32bd..dbe7d5232 100644 --- a/src/ast/float_decl_plugin.cpp +++ b/src/ast/float_decl_plugin.cpp @@ -348,13 +348,13 @@ func_decl * float_decl_plugin::mk_to_float(decl_kind k, unsigned num_parameters, // When the bv_decl_plugin is installed, then we know how to convert 3 bit-vectors into a float! sort * fp = mk_float_sort(domain[2]->get_parameter(0).get_int(), domain[1]->get_parameter(0).get_int()+1); symbol name("asFloat"); - return m_manager->mk_func_decl(name, arity, domain, fp, func_decl_info(m_family_id, k, num_parameters, parameters)); - } + return m_manager->mk_func_decl(name, arity, domain, fp, func_decl_info(m_family_id, k, num_parameters, parameters)); + } else { // .. Otherwise we only know how to convert rationals/reals. if (!(num_parameters == 2 && parameters[0].is_int() && parameters[1].is_int())) m_manager->raise_exception("expecting two integer parameters to asFloat"); - if (arity != 2 && arity != 3) + if (arity != 2 && arity != 3) m_manager->raise_exception("invalid number of arguments to asFloat operator"); if (!is_rm_sort(domain[0]) || domain[1] != m_real_sort) m_manager->raise_exception("sort mismatch"); @@ -373,6 +373,23 @@ func_decl * float_decl_plugin::mk_to_float(decl_kind k, unsigned num_parameters, } } +func_decl * float_decl_plugin::mk_to_ieee_bv(decl_kind k, unsigned num_parameters, parameter const * parameters, + unsigned arity, sort * const * domain, sort * range) { + if (!m_bv_plugin) + m_manager->raise_exception("asIEEEBV unsupported; use a logic with BV support"); + if (arity != 1) + m_manager->raise_exception("invalid number of arguments to asIEEEBV"); + if (!is_float_sort(domain[0])) + m_manager->raise_exception("sort mismatch"); + + // When the bv_decl_plugin is installed, then we know how to convert a float to an IEEE bit-vector. + unsigned float_sz = domain[0]->get_parameter(0).get_int() + domain[0]->get_parameter(1).get_int(); + parameter ps[] = { parameter(float_sz) }; + sort * bv_srt = m_bv_plugin->mk_sort(m_bv_fid, 1, ps); + symbol name("asIEEEBV"); + return m_manager->mk_func_decl(name, 1, domain, bv_srt, func_decl_info(m_family_id, k, num_parameters, parameters)); +} + func_decl * float_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned arity, sort * const * domain, sort * range) { switch (k) { @@ -420,6 +437,8 @@ func_decl * float_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters return mk_rm_unary_decl(k, num_parameters, parameters, arity, domain, range); case OP_FLOAT_FUSED_MA: return mk_fused_ma(k, num_parameters, parameters, arity, domain, range); + case OP_TO_IEEE_BV: + return mk_to_ieee_bv(k, num_parameters, parameters, arity, domain, range); default: m_manager->raise_exception("unsupported floating point operator"); return 0; @@ -462,7 +481,10 @@ void float_decl_plugin::get_op_names(svector & op_names, symbol co op_names.push_back(builtin_name("min", OP_FLOAT_MIN)); op_names.push_back(builtin_name("max", OP_FLOAT_MAX)); - op_names.push_back(builtin_name("asFloat", OP_TO_FLOAT)); + op_names.push_back(builtin_name("asFloat", OP_TO_FLOAT)); + + if (m_bv_plugin) + op_names.push_back(builtin_name("asIEEEBV", OP_TO_IEEE_BV)); } void float_decl_plugin::get_sort_names(svector & sort_names, symbol const & logic) { diff --git a/src/ast/float_decl_plugin.h b/src/ast/float_decl_plugin.h index 416275306..c4503349b 100644 --- a/src/ast/float_decl_plugin.h +++ b/src/ast/float_decl_plugin.h @@ -67,6 +67,7 @@ enum float_op_kind { OP_FLOAT_IS_SIGN_MINUS, OP_TO_FLOAT, + OP_TO_IEEE_BV, LAST_FLOAT_OP }; @@ -118,6 +119,8 @@ class float_decl_plugin : public decl_plugin { unsigned arity, sort * const * domain, sort * range); func_decl * mk_to_float(decl_kind k, unsigned num_parameters, parameter const * parameters, unsigned arity, sort * const * domain, sort * range); + func_decl * mk_to_ieee_bv(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); unsigned mk_id(mpf const & v); @@ -159,7 +162,7 @@ class float_util { ast_manager & m_manager; float_decl_plugin * m_plugin; family_id m_fid; - arith_util m_a_util; + arith_util m_a_util; public: float_util(ast_manager & m); ~float_util(); @@ -209,7 +212,7 @@ public: bool is_to_float(expr * n) { return is_app_of(n, m_fid, OP_TO_FLOAT); } - app * mk_to_float(expr * arg1, expr * arg2) { return m().mk_app(m_fid, OP_TO_FLOAT, arg1, arg2); } + app * mk_to_float(expr * arg1, expr * arg2) { return m().mk_app(m_fid, OP_TO_FLOAT, arg1, arg2); } app * mk_add(expr * arg1, expr * arg2, expr * arg3) { return m().mk_app(m_fid, OP_FLOAT_ADD, arg1, arg2, arg3); } app * mk_mul(expr * arg1, expr * arg2, expr * arg3) { return m().mk_app(m_fid, OP_FLOAT_MUL, arg1, arg2, arg3); } app * mk_sub(expr * arg1, expr * arg2, expr * arg3) { return m().mk_app(m_fid, OP_FLOAT_SUB, arg1, arg2, arg3); } @@ -238,6 +241,8 @@ public: app * mk_is_sign_minus(expr * arg1) { return m().mk_app(m_fid, OP_FLOAT_IS_SIGN_MINUS, arg1); } bool is_uminus(expr * a) { return is_app_of(a, m_fid, OP_FLOAT_UMINUS); } + + app * mk_to_ieee_bv(expr * arg1) { return m().mk_app(m_fid, OP_TO_IEEE_BV, arg1); } }; #endif diff --git a/src/ast/rewriter/float_rewriter.cpp b/src/ast/rewriter/float_rewriter.cpp index ad0709423..9678af216 100644 --- a/src/ast/rewriter/float_rewriter.cpp +++ b/src/ast/rewriter/float_rewriter.cpp @@ -59,6 +59,7 @@ br_status float_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * c case OP_FLOAT_IS_NZERO: SASSERT(num_args == 1); st = mk_is_nzero(args[0], result); break; case OP_FLOAT_IS_PZERO: SASSERT(num_args == 1); st = mk_is_pzero(args[0], result); break; case OP_FLOAT_IS_SIGN_MINUS: SASSERT(num_args == 1); st = mk_is_sign_minus(args[0], result); break; + case OP_TO_IEEE_BV: SASSERT(num_args == 1); st = mk_to_ieee_bv(args[0], result); break; } return st; } @@ -439,3 +440,7 @@ br_status float_rewriter::mk_eq_core(expr * arg1, expr * arg2, expr_ref & result return BR_FAILED; } + +br_status float_rewriter::mk_to_ieee_bv(expr * arg1, expr_ref & result) { + return BR_FAILED; +} \ No newline at end of file diff --git a/src/ast/rewriter/float_rewriter.h b/src/ast/rewriter/float_rewriter.h index e4258895d..7c86a5bc3 100644 --- a/src/ast/rewriter/float_rewriter.h +++ b/src/ast/rewriter/float_rewriter.h @@ -67,6 +67,8 @@ public: br_status mk_is_nzero(expr * arg1, expr_ref & result); br_status mk_is_pzero(expr * arg1, expr_ref & result); br_status mk_is_sign_minus(expr * arg1, expr_ref & result); + + br_status mk_to_ieee_bv(expr * arg1, expr_ref & result); }; #endif diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index afcac48ac..9ec11d085 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -460,6 +460,7 @@ bool cmd_context::logic_has_arith_core(symbol const & s) const { s == "LIA" || s == "LRA" || s == "QF_FPA" || + s == "QF_FPABV" || s == "HORN"; } @@ -478,6 +479,7 @@ bool cmd_context::logic_has_bv_core(symbol const & s) const { s == "QF_ABV" || s == "QF_AUFBV" || s == "QF_BVRE" || + s == "QF_FPABV" || s == "HORN"; } @@ -502,7 +504,7 @@ bool cmd_context::logic_has_seq() const { } bool cmd_context::logic_has_floats() const { - return !has_logic() || m_logic == "QF_FPA"; + return !has_logic() || m_logic == "QF_FPA" || m_logic == "QF_FPABV"; } bool cmd_context::logic_has_array_core(symbol const & s) const { @@ -599,7 +601,7 @@ bool cmd_context::supported_logic(symbol const & s) const { logic_has_arith_core(s) || logic_has_bv_core(s) || logic_has_array_core(s) || logic_has_seq_core(s) || logic_has_horn(s) || - s == "QF_FPA"; + s == "QF_FPA" || s == "QF_FPABV"; } void cmd_context::set_logic(symbol const & s) { diff --git a/src/tactic/fpa/fpa2bv_converter.cpp b/src/tactic/fpa/fpa2bv_converter.cpp index 77ff50e9b..21d5a2d23 100644 --- a/src/tactic/fpa/fpa2bv_converter.cpp +++ b/src/tactic/fpa/fpa2bv_converter.cpp @@ -1399,6 +1399,13 @@ void fpa2bv_converter::mk_to_float(func_decl * f, unsigned num, expr * const * a } } +void fpa2bv_converter::mk_to_ieee_bv(func_decl * f, unsigned num, expr * const * args, expr_ref & result) { + SASSERT(num == 1); + expr * sgn, * s, * e; + split(args[0], sgn, s, e); + result = m_bv_util.mk_concat(m_bv_util.mk_concat(sgn, s), e); +} + void fpa2bv_converter::split(expr * e, expr * & sgn, expr * & sig, expr * & exp) const { SASSERT(is_app_of(e, m_plugin->get_family_id(), OP_TO_FLOAT)); SASSERT(to_app(e)->get_num_args() == 3); @@ -2035,7 +2042,8 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) { tout << bv_mdl->get_constant(i)->get_name() << " --> " << mk_ismt2_pp(bv_mdl->get_const_interp(bv_mdl->get_constant(i)), m) << std::endl; ); - + + obj_hashtable seen; for (obj_map::iterator it = m_const2bv.begin(); it != m_const2bv.end(); @@ -2053,6 +2061,10 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) { expr * sig = bv_mdl->get_const_interp(to_app(a->get_arg(1))->get_decl()); expr * exp = bv_mdl->get_const_interp(to_app(a->get_arg(2))->get_decl()); + seen.insert(to_app(a->get_arg(0))->get_decl()); + seen.insert(to_app(a->get_arg(1))->get_decl()); + seen.insert(to_app(a->get_arg(2))->get_decl()); + if (!sgn && !sig && !exp) continue; @@ -2080,7 +2092,7 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) { fu.fm().set(fp_val, ebits, sbits, !mpqm.is_zero(sgn_q.to_mpq()), sig_z, exp_z); float_mdl->register_decl(var, fu.mk_value(fp_val)); - + mpzm.del(sig_z); } @@ -2104,9 +2116,36 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) { case BV_RM_TO_POSITIVE: float_mdl->register_decl(var, fu.mk_round_toward_positive()); break; case BV_RM_TO_ZERO: default: float_mdl->register_decl(var, fu.mk_round_toward_zero()); - } + } + seen.insert(var); } } fu.fm().del(fp_val); + + // Keep all the non-float constants. + unsigned sz = bv_mdl->get_num_constants(); + for (unsigned i = 0; i < sz; i++) + { + func_decl * c = bv_mdl->get_constant(i); + if (seen.contains(c)) + continue; + float_mdl->register_decl(c, bv_mdl->get_const_interp(c)); + } + + // And keep everything else + sz = bv_mdl->get_num_functions(); + for (unsigned i = 0; i < sz; i++) + { + func_decl * c = bv_mdl->get_function(i); + float_mdl->register_decl(c, bv_mdl->get_const_interp(c)); + } + + sz = bv_mdl->get_num_uninterpreted_sorts(); + for (unsigned i = 0; i < sz; i++) + { + sort * s = bv_mdl->get_uninterpreted_sort(i); + ptr_vector u = bv_mdl->get_universe(s); + float_mdl->register_usort(s, u.size(), u.c_ptr()); + } } diff --git a/src/tactic/fpa/fpa2bv_converter.h b/src/tactic/fpa/fpa2bv_converter.h index 291120e92..1ee374941 100644 --- a/src/tactic/fpa/fpa2bv_converter.h +++ b/src/tactic/fpa/fpa2bv_converter.h @@ -100,6 +100,7 @@ public: void mk_is_sign_minus(func_decl * f, unsigned num, expr * const * args, expr_ref & result); void mk_to_float(func_decl * f, unsigned num, expr * const * args, expr_ref & result); + void mk_to_ieee_bv(func_decl * f, unsigned num, expr * const * args, expr_ref & result); fpa2bv_model_converter * mk_model_converter(); diff --git a/src/tactic/fpa/fpa2bv_rewriter.h b/src/tactic/fpa/fpa2bv_rewriter.h index 62c6f1a2d..91682c6e1 100644 --- a/src/tactic/fpa/fpa2bv_rewriter.h +++ b/src/tactic/fpa/fpa2bv_rewriter.h @@ -129,6 +129,7 @@ struct fpa2bv_rewriter_cfg : public default_rewriter_cfg { case OP_FLOAT_IS_PZERO: m_conv.mk_is_pzero(f, num, args, result); return BR_DONE; case OP_FLOAT_IS_SIGN_MINUS: m_conv.mk_is_sign_minus(f, num, args, result); return BR_DONE; case OP_TO_FLOAT: m_conv.mk_to_float(f, num, args, result); return BR_DONE; + case OP_TO_IEEE_BV: m_conv.mk_to_ieee_bv(f, num, args, result); return BR_DONE; default: TRACE("fpa2bv", tout << "unsupported operator: " << f->get_name() << "\n"; for (unsigned i = 0; i < num; i++) tout << mk_ismt2_pp(args[i], m()) << std::endl;); diff --git a/src/tactic/fpa/qffpa_tactic.h b/src/tactic/fpa/qffpa_tactic.h index 660565463..8ca2183c1 100644 --- a/src/tactic/fpa/qffpa_tactic.h +++ b/src/tactic/fpa/qffpa_tactic.h @@ -27,6 +27,7 @@ class tactic; tactic * mk_qffpa_tactic(ast_manager & m, params_ref const & p = params_ref()); /* ADD_TACTIC("qffpa", "(try to) solve goal using the tactic for QF_FPA.", "mk_qffpa_tactic(m, p)") + ADD_TACTIC("qffpabv", "(try to) solve goal using the tactic for QF_FPABV (floats+bit-vectors).", "mk_qffpa_tactic(m, p)") */ #endif diff --git a/src/tactic/portfolio/smt_strategic_solver.cpp b/src/tactic/portfolio/smt_strategic_solver.cpp index 4cf530b1e..7a274a830 100644 --- a/src/tactic/portfolio/smt_strategic_solver.cpp +++ b/src/tactic/portfolio/smt_strategic_solver.cpp @@ -79,6 +79,7 @@ static void init(strategic_solver * s) { s->set_tactic_for(symbol("UFBV"), alloc(ufbv_fct)); s->set_tactic_for(symbol("BV"), alloc(ufbv_fct)); s->set_tactic_for(symbol("QF_FPA"), alloc(qffpa_fct)); + s->set_tactic_for(symbol("QF_FPABV"), alloc(qffpa_fct)); s->set_tactic_for(symbol("HORN"), alloc(horn_fct)); } From 589f096e6ea077df8a6dd938c15aa877c73d6ee6 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 15:54:34 -0800 Subject: [PATCH 12/34] working on new parameter framework Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 2 +- src/api/api_config_params.cpp | 62 ++++--- src/api/api_datalog.cpp | 2 +- src/api/api_model.cpp | 7 +- src/api/api_parsers.cpp | 4 +- src/api/python/z3.py | 50 +++--- src/api/z3_api.h | 95 +++++++---- src/ast/pattern/expr_pattern_match.cpp | 3 +- src/cmd_context/basic_cmds.cpp | 6 +- src/cmd_context/cmd_context.cpp | 18 +- src/cmd_context/cmd_context.h | 8 +- src/front_end_params/README | 9 + src/front_end_params/front_end_params.cpp | 23 --- src/front_end_params/front_end_params.h | 35 +--- src/front_end_params/model_params.cpp | 35 ---- src/front_end_params/model_params.h | 43 ----- src/front_end_params/parser_params.cpp | 14 -- src/front_end_params/parser_params.h | 33 ---- src/front_end_params/smt_params.cpp | 12 ++ src/front_end_params/smt_params.h | 18 +- src/parsers/smt/smtlib_solver.cpp | 10 +- src/parsers/smt2/smt2parser.cpp | 26 ++- src/parsers/smt2/smt2parser.h | 2 +- src/parsers/smt2/smt2scanner.cpp | 9 +- src/parsers/smt2/smt2scanner.h | 4 +- src/parsers/util/parser_params.pyg | 6 + src/shell/main.cpp | 16 +- src/shell/smtlib_frontend.cpp | 2 +- src/smt/proto_model/proto_model.cpp | 8 +- src/smt/proto_model/proto_model.h | 9 +- src/smt/smt_model_generator.cpp | 3 +- src/util/gparams.cpp | 190 ++++++++++++++++------ src/util/gparams.h | 8 +- src/util/memory_manager.cpp | 25 ++- src/util/params.cpp | 14 +- src/util/params.h | 2 + 36 files changed, 436 insertions(+), 377 deletions(-) create mode 100644 src/front_end_params/README delete mode 100644 src/front_end_params/model_params.cpp delete mode 100644 src/front_end_params/model_params.h delete mode 100644 src/front_end_params/parser_params.cpp delete mode 100644 src/front_end_params/parser_params.h create mode 100644 src/parsers/util/parser_params.pyg diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 782990cd7..1df3c082e 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1472,7 +1472,7 @@ def def_module_params(module_name, export, params): out.write('struct %s_params {\n' % module_name) out.write(' params_ref const & p;\n') if export: - out.write(' params_ref const & g;\n') + out.write(' params_ref g;\n') out.write(' %s_params(params_ref const & _p = params_ref()):\n' % module_name) out.write(' p(_p)') if export: diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 7a0303234..6adcced44 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -36,9 +36,45 @@ namespace api { }; extern "C" { + void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value) { + memory::initialize(UINT_MAX); + LOG_Z3_global_param_set(param_id, param_value); + try { + gparams::set(param_id, param_value); + } + catch (z3_exception & ex) { + // The error handler is only available for contexts + // Just throw a warning. + std::ostringstream buffer; + buffer << "Error setting " << param_id << ", " << ex.msg(); + warning_msg(buffer.str().c_str()); + } + } + + std::string g_Z3_global_param_get_buffer; + + 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; + try { + g_Z3_global_param_get_buffer = gparams::get_value(param_id); + *param_value = g_Z3_global_param_get_buffer.c_str(); + return Z3_TRUE; + } + catch (z3_exception & ex) { + // The error handler is only available for contexts + // Just throw a warning. + std::ostringstream buffer; + buffer << "Error setting " << param_id << ", " << ex.msg(); + warning_msg(buffer.str().c_str()); + return Z3_FALSE; + } + } + Z3_config Z3_API Z3_mk_config() { + memory::initialize(UINT_MAX); LOG_Z3_mk_config(); - memory::initialize(0); Z3_config r = reinterpret_cast(alloc(api::config_params)); RETURN_Z3(r); } @@ -49,35 +85,19 @@ extern "C" { } void Z3_API Z3_set_param_value(Z3_config c, char const * param_id, char const * param_value) { - // REMARK: we don't need Z3_config anymore - try { - LOG_Z3_set_param_value(c, param_id, param_value); - gparams::set(param_id, param_value); - } - catch (gparams::exception & ex) { - // The error handler was not set yet. - // Just throw a warning. - std::ostringstream buffer; - buffer << "Error setting " << param_id << ", " << ex.msg(); - warning_msg(buffer.str().c_str()); - } + LOG_Z3_set_param_value(c, param_id, param_value); + // PARAM-TODO save the parameter } void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value) { - Z3_TRY; LOG_Z3_update_param_value(c, param_id, param_value); RESET_ERROR_CODE(); - gparams::set(param_id, param_value); - // TODO: set memory limits - // memory::set_high_watermark(static_cast(mk_c(c)->fparams().m_memory_high_watermark)*1024*1024); - // memory::set_max_size(static_cast(mk_c(c)->fparams().m_memory_max_size)*1024*1024); - Z3_CATCH; + // NOOP in the current version } Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) { LOG_Z3_get_param_value(c, param_id, param_value); - // TODO: we don't really have support for that anymore. - return false; + return Z3_FALSE; } }; diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 3c434600b..34ca9627a 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -344,7 +344,7 @@ extern "C" { std::istream& s) { ast_manager& m = mk_c(c)->m(); dl_collected_cmds coll(m); - cmd_context ctx(&mk_c(c)->fparams(), false, &m); + cmd_context ctx(false, &m); install_dl_collect_cmds(coll, ctx); ctx.set_ignore_check(true); if (!parse_smt2_commands(ctx, s)) { diff --git a/src/api/api_model.cpp b/src/api/api_model.cpp index a6ada4ae6..80577efee 100644 --- a/src/api/api_model.cpp +++ b/src/api/api_model.cpp @@ -25,6 +25,7 @@ Revision History: #include"model.h" #include"model_v2_pp.h" #include"model_smt2_pp.h" +#include"model_params.hpp" extern "C" { @@ -488,7 +489,8 @@ extern "C" { Z3_model m, Z3_ast t, Z3_ast * v) { - return Z3_model_eval(c, m, t, mk_c(c)->fparams().m_model_completion, v); + model_params p; + return Z3_model_eval(c, m, t, p.completion(), v); } Z3_bool Z3_API Z3_eval_func_decl(Z3_context c, @@ -660,7 +662,8 @@ extern "C" { result.resize(result.size()-1); } else { - model_v2_pp(buffer, *(to_model_ref(m)), mk_c(c)->fparams().m_model_partial); + model_params p; + model_v2_pp(buffer, *(to_model_ref(m)), p.partial()); result = buffer.str(); } return mk_c(c)->mk_external_string(result); diff --git a/src/api/api_parsers.cpp b/src/api/api_parsers.cpp index b6d18096f..69ca1fc81 100644 --- a/src/api/api_parsers.cpp +++ b/src/api/api_parsers.cpp @@ -296,7 +296,7 @@ extern "C" { Z3_symbol const decl_names[], Z3_func_decl const decls[]) { Z3_TRY; - cmd_context ctx(&mk_c(c)->fparams(), false, &(mk_c(c)->m())); + cmd_context ctx(false, &(mk_c(c)->m())); ctx.set_ignore_check(true); if (exec) { ctx.set_solver(alloc(z3_context_solver, *mk_c(c))); @@ -362,7 +362,7 @@ extern "C" { Z3_symbol decl_names[], Z3_func_decl decls[]) { Z3_TRY; - cmd_context ctx(&mk_c(c)->fparams(), false, &(mk_c(c)->m())); + cmd_context ctx(false, &(mk_c(c)->m())); std::string s(str); std::istringstream is(s); // No logging for this one, since it private. diff --git a/src/api/python/z3.py b/src/api/python/z3.py index 94031cce6..b03cf1fd8 100644 --- a/src/api/python/z3.py +++ b/src/api/python/z3.py @@ -169,28 +169,6 @@ class Context: """ Z3_interrupt(self.ref()) - def set(self, *args, **kws): - """Set global configuration options. - - Z3 command line options can be set using this method. - The option names can be specified in different ways: - - >>> ctx = Context() - >>> ctx.set('WELL_SORTED_CHECK', True) - >>> ctx.set(':well-sorted-check', True) - >>> ctx.set(well_sorted_check=True) - """ - if __debug__: - _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.") - for key, value in kws.iteritems(): - Z3_update_param_value(self.ctx, str(key).upper(), _to_param_value(value)) - prev = None - for a in args: - if prev == None: - prev = a - else: - Z3_update_param_value(self.ctx, str(prev), _to_param_value(a)) - prev = None # Global Z3 context _main_ctx = None @@ -221,15 +199,37 @@ def _get_ctx(ctx): return ctx def set_option(*args, **kws): - """Update parameters of the global context `main_ctx()`, and global configuration options of Z3Py. See `Context.set()`. - + """Set Z3 global (or module) parameters. + >>> set_option(precision=10) """ + if __debug__: + _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.") new_kws = {} for k, v in kws.iteritems(): if not set_pp_option(k, v): new_kws[k] = v - main_ctx().set(*args, **new_kws) + for key, value in new_kws.iteritems(): + Z3_global_param_set(str(key).upper(), _to_param_value(value)) + prev = None + for a in args: + if prev == None: + prev = a + else: + Z3_global_param_set(str(prev), _to_param_value(a)) + prev = None + +def get_option(name): + """Return the value of a Z3 global (or module) parameter + + >>> get_option('nlsat.reorder') + true + """ + ptr = (ctypes.c_char_p * 1)() + if Z3_global_param_get(str(name), ptr): + r = str(ptr[0]) + return r + raise Z3Exception("failed to retrieve value for '%s'" % name) ######################################### # diff --git a/src/api/z3_api.h b/src/api/z3_api.h index 9570af43b..a0c6434c2 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1233,25 +1233,82 @@ extern "C" { #endif // CAMLIDL #ifdef CorML3 + /** + @name Configuration + */ + + /*@{*/ + /** + \brief Set a global (or module) parameter. + This setting is shared by all Z3 contexts. + + When a Z3 module is initialized it will use the value of these parameters + when Z3_params objects are not provided. + + The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'. + The character '.' is a delimiter (more later). + + The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. + Thus, the following parameter names are considered equivalent: "pp.decimal-precision" and "PP.DECIMAL_PRECISION". + + This function can be used to set parameters for a specific Z3 module. + This can be done by using .. + For example: + Z3_global_param_set('pp.decimal', 'true') + will set the parameter "decimal" in the module "pp" to true. + + def_API('Z3_global_param_set', VOID, (_in(STRING), _in(STRING))) + */ + void Z3_API Z3_global_param_set(__in Z3_string param_id, __in Z3_string param_value); + + /** + \brief Get a global (or module) parameter. + + Returns \mlonly \c None \endmlonly \conly \c Z3_FALSE + if the parameter value does not exist. + + \sa Z3_global_param_set + + The caller must invoke #Z3_global_param_del_value to delete the value returned at \c param_value. + + \remark This function cannot be invoked simultaneously from different threads without synchronization. + The result string stored in param_value is stored in shared location. + + def_API('Z3_global_param_get', BOOL, (_in(STRING), _out(STRING))) + */ + Z3_bool_opt Z3_API Z3_global_param_get(__in Z3_string param_id, __out_opt Z3_string_ptr param_value); + + /*@}*/ + /** @name Create configuration */ /*@{*/ /** - \brief Create a configuration. + \brief Create a configuration object for the Z3 context object. Configurations are created in order to assign parameters prior to creating - contexts for Z3 interaction. For example, if the users wishes to use model + contexts for Z3 interaction. For example, if the users wishes to use proof generation, then call: - \ccode{Z3_set_param_value(cfg\, "MODEL"\, "true")} + \ccode{Z3_set_param_value(cfg\, "proof"\, "true")} \mlonly \remark Consider using {!mk_context_x} instead of using explicit configuration objects. The function {!mk_context_x} receives an array of string pairs. This array represents the configuration options. \endmlonly + \remark In previous versions of Z3, the \c Z3_config was used to store + global and module configurations. Now, we should use \c Z3_global_param_set. + + The following parameters can be set: + + - proof (Boolean) Enable proof generation + - debug_ref_count (Boolean) Enable debug support for Z3_ast reference counting + - trace (Boolean) Tracing support for VCC + - trace_file_name (String) Trace out file for VCC traces + \sa Z3_set_param_value \sa Z3_del_config @@ -1271,18 +1328,14 @@ extern "C" { /** \brief Set a configuration parameter. - The list of all configuration parameters can be obtained using the Z3 executable: - - \verbatim - z3.exe -ini? - \endverbatim + The following parameters can be set for \sa Z3_mk_config def_API('Z3_set_param_value', VOID, (_in(CONFIG), _in(STRING), _in(STRING))) */ void Z3_API Z3_set_param_value(__in Z3_config c, __in Z3_string param_id, __in Z3_string param_value); - + /*@}*/ #endif @@ -1367,33 +1420,19 @@ extern "C" { #endif /** - \brief Update a mutable configuration parameter. + \brief This is a deprecated function. This is a NOOP in the current version of Z3. - The list of all configuration parameters can be obtained using the Z3 executable: - - \verbatim - z3.exe -ini? - \endverbatim - - Only a few configuration parameters are mutable once the context is created. - The error handler is invoked when trying to modify an immutable parameter. - - \conly \sa Z3_set_param_value - \mlonly \sa Z3_mk_context \endmlonly + \deprecated Use #Z3_global_param_set. def_API('Z3_update_param_value', VOID, (_in(CONTEXT), _in(STRING), _in(STRING))) */ void Z3_API Z3_update_param_value(__in Z3_context c, __in Z3_string param_id, __in Z3_string param_value); /** - \brief Get a configuration parameter. + \brief This is a deprecated function. This is a NOOP in the current version of Z3. + It always return Z3_FALSE. - Returns \mlonly \c None \endmlonly \conly \c Z3_FALSE - if the parameter value does not exist. - - \conly \sa Z3_mk_config - \conly \sa Z3_set_param_value - \mlonly \sa Z3_mk_context \endmlonly + \deprecated Use #Z3_global_param_get def_API('Z3_get_param_value', BOOL, (_in(CONTEXT), _in(STRING), _out(STRING))) */ diff --git a/src/ast/pattern/expr_pattern_match.cpp b/src/ast/pattern/expr_pattern_match.cpp index 25be8dbf0..a446ae538 100644 --- a/src/ast/pattern/expr_pattern_match.cpp +++ b/src/ast/pattern/expr_pattern_match.cpp @@ -388,8 +388,7 @@ expr_pattern_match::initialize(char const * spec_string) { m_instrs.push_back(instr(BACKTRACK)); std::istringstream is(spec_string); - front_end_params p; - cmd_context ctx(&p, true, &m_manager); + cmd_context ctx(true, &m_manager); VERIFY(parse_smt2_commands(ctx, is)); ptr_vector::const_iterator it = ctx.begin_assertions(); diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index 1960cd22a..43507ed3f 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -29,6 +29,7 @@ Notes: #include"eval_cmd.h" #include"front_end_params.h" #include"gparams.h" +#include"model_params.hpp" class help_cmd : public cmd { svector m_cmds; @@ -104,9 +105,10 @@ ATOMIC_CMD(get_model_cmd, "get-model", "retrieve model for the last check-sat co throw cmd_exception("model is not available"); model_ref m; ctx.get_check_sat_result()->get_model(m); - if (ctx.params().m_model_v1_pp || ctx.params().m_model_v2_pp) { + model_params p; + if (p.v1() || p.v2()) { std::ostringstream buffer; - model_v2_pp(buffer, *m, ctx.params().m_model_partial); + model_v2_pp(buffer, *m, p.partial()); ctx.regular_stream() << "\"" << escaped(buffer.str().c_str(), true) << "\"" << std::endl; } else { ctx.regular_stream() << "(model " << std::endl; diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 5dcc4268c..cd8c81387 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -316,10 +316,9 @@ public: } }; -cmd_context::cmd_context(front_end_params * params, bool main_ctx, ast_manager * m, symbol const & l): +cmd_context::cmd_context(bool main_ctx, ast_manager * m, symbol const & l): m_main_ctx(main_ctx), - m_params(params == 0 ? alloc(front_end_params) : params), - m_params_owner(params == 0), + m_fparams(alloc(front_end_params)), m_logic(l), m_interactive_mode(false), m_global_decls(false), // :global-decls is false by default. @@ -359,9 +358,7 @@ cmd_context::~cmd_context() { finalize_probes(); m_solver = 0; m_check_sat_result = 0; - if (m_params_owner) { - dealloc(m_params); - } + dealloc(m_fparams); } void cmd_context::set_produce_models(bool f) { @@ -382,10 +379,6 @@ void cmd_context::set_produce_proofs(bool f) { params().m_proof_mode = f ? PGM_FINE : PGM_DISABLED; } -bool cmd_context::is_smtlib2_compliant() const { - return params().m_smtlib2_compliant; -} - bool cmd_context::produce_models() const { return params().m_model; } @@ -599,8 +592,9 @@ void cmd_context::init_manager() { m_manager = alloc(ast_manager, params().m_proof_mode, params().m_trace_stream); m_pmanager = alloc(pdecl_manager, *m_manager); init_manager_core(true); - if (params().m_smtlib2_compliant) - m_manager->enable_int_real_coercions(false); + // PARAM-TODO + // if (params().m_smtlib2_compliant) + // m_manager->enable_int_real_coercions(false); } void cmd_context::init_external_manager() { diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 6688f66d9..1b15c0b60 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -138,8 +138,7 @@ public: protected: bool m_main_ctx; - front_end_params * m_params; - bool m_params_owner; + front_end_params * m_fparams; symbol m_logic; bool m_interactive_mode; bool m_global_decls; @@ -251,9 +250,8 @@ protected: void print_unsupported_info(symbol const& s) { if (s != symbol::null) diagnostic_stream() << "; " << s << std::endl;} public: - cmd_context(front_end_params * params = 0, bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); + cmd_context(bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); ~cmd_context(); - bool is_smtlib2_compliant() const; void set_logic(symbol const & s); bool has_logic() const { return m_logic != symbol::null; } symbol const & get_logic() const { return m_logic; } @@ -290,7 +288,7 @@ public: virtual ast_manager & get_ast_manager() { 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; } - front_end_params & params() const { return *m_params; } + front_end_params & params() const { return *m_fparams; } void set_solver(solver * s); solver * get_solver() const { return m_solver.get(); } diff --git a/src/front_end_params/README b/src/front_end_params/README new file mode 100644 index 000000000..1ab0a2463 --- /dev/null +++ b/src/front_end_params/README @@ -0,0 +1,9 @@ +This directory contains the "remains" of the old parameter setting +infrastructure used by Z3. Old code (mostly `smt::context`) is still +based on the front_end_params structure. However, we removed support +for the old INI file infrastructure. Instead, we have functions for +setting the fields of front_end_params using parameter sets +(params_ref). Moreover, many of the parameters in front_end_params +are now "hidden". That is, they can't be set from the command line or +using the command `set-option`. + diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 9d05a3fc3..d30ec825d 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -22,9 +22,7 @@ void front_end_params::register_params(ini_params & p) { p.register_param_vector(m_param_vector.get()); preprocessor_params::register_params(p); smt_params::register_params(p); - parser_params::register_params(p); arith_simplifier_params::register_params(p); - model_params::register_params(p); p.register_bool_param("at_labels_cex", m_at_labels_cex, "only use labels that contain '@' when building multiple counterexamples"); p.register_bool_param("check_at_labels", m_check_at_labels, @@ -33,14 +31,12 @@ void front_end_params::register_params(ini_params & p) { p.register_bool_param("type_check", m_well_sorted_check, "enable/disable type checker"); p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); - p.register_bool_param("interactive", m_interactive, "enable interactive mode using Simplify input format"); p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); p.register_double_param("instruction_max", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); p.register_bool_param("auto_config", m_auto_config, "use heuristics to set Z3 configuration parameters, it is only available for the SMT-LIB input format"); p.register_int_param("proof_mode", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); p.register_bool_param("trace", m_trace, "enable tracing for the Axiom Profiler tool"); p.register_string_param("trace_file_name", m_trace_file_name, "tracing file name"); - p.register_bool_param("async_commands", m_async_commands, "enable/disable support for asynchronous commands in the Simplify front-end."); p.register_bool_param("display_config", m_display_config, "display configuration used by Z3"); #ifdef _WINDOWS @@ -51,29 +47,10 @@ void front_end_params::register_params(ini_params & p) { "set hard upper limit for memory consumption (in megabytes)"); #endif -#ifndef _EXTERNAL_RELEASE - // external users should not have access to it. - p.register_bool_param("preprocess", m_preprocess); -#endif - - p.register_bool_param("user_theory_preprocess_axioms", - m_user_theory_preprocess_axioms, - "Apply full pre-processing to user theory axioms", - true); - - p.register_bool_param("user_theory_persist_axioms", - m_user_theory_persist_axioms, - "Persist user axioms to the base level", - true); - - p.register_bool_param("smtlib2_compliant", m_smtlib2_compliant); - - p.register_bool_param("ignore_bad_patterns", m_ignore_bad_patterns); PRIVATE_PARAMS({ p.register_bool_param("ignore_checksat", m_ignore_checksat); p.register_bool_param("debug_ref_count", m_debug_ref_count); - p.register_bool_param("ignore_user_patterns", m_ignore_user_patterns); p.register_bool_param("incremental_core_assert", m_incremental_core_assert); DEBUG_CODE(p.register_int_param("copy_params", m_copy_params);); }); diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index b87265c01..505052450 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -23,22 +23,15 @@ Revision History: #include"ast.h" #include"preprocessor_params.h" #include"smt_params.h" -#include"parser_params.h" #include"arith_simplifier_params.h" -#include"model_params.h" -struct front_end_params : public preprocessor_params, public smt_params, public parser_params, - public arith_simplifier_params, public model_params - { +struct front_end_params : public preprocessor_params, public smt_params, + public arith_simplifier_params { ref m_param_vector; - unsigned m_max_num_cex; // maximum number of counterexamples bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. bool m_default_qid; - bool m_interactive; bool m_well_sorted_check; - bool m_ignore_bad_patterns; - bool m_ignore_user_patterns; bool m_incremental_core_assert; // assert conditions to the core incrementally unsigned m_soft_timeout; double m_instr_out; @@ -46,32 +39,26 @@ struct front_end_params : public preprocessor_params, public smt_params, public unsigned m_memory_max_size; proof_gen_mode m_proof_mode; bool m_auto_config; - bool m_smtlib2_compliant; #ifdef Z3DEBUG int m_copy_params; // used for testing copy params... Invoke method copy_params(m_copy_params) in main.cpp when diff -1. #endif - bool m_preprocess; // temporary hack for disabling all preprocessing.. + bool m_ignore_checksat; // abort before checksat... for internal debugging bool m_debug_ref_count; bool m_trace; std::string m_trace_file_name; std::fstream* m_trace_stream; - bool m_async_commands; bool m_display_config; - bool m_user_theory_preprocess_axioms; - bool m_user_theory_persist_axioms; bool m_nlsat; // temporary hack until strategic_solver is ported to new tactic framework + bool m_dump_goal_as_smt; + front_end_params(): m_param_vector(alloc(param_vector, this)), - m_max_num_cex(1), m_at_labels_cex(false), m_check_at_labels(false), m_default_qid(false), - m_interactive(false), m_well_sorted_check(true), - m_ignore_bad_patterns(true), - m_ignore_user_patterns(false), m_incremental_core_assert(true), m_soft_timeout(0), m_instr_out(0.0), @@ -83,25 +70,17 @@ struct front_end_params : public preprocessor_params, public smt_params, public #else m_auto_config(false), #endif -#if 0 - m_smtlib2_compliant(true), -#else - m_smtlib2_compliant(false), -#endif #ifdef Z3DEBUG m_copy_params(-1), #endif - m_preprocess(true), // temporary hack for disabling all preprocessing.. m_ignore_checksat(false), m_debug_ref_count(false), m_trace(false), m_trace_file_name("z3.log"), m_trace_stream(NULL), - m_async_commands(true), m_display_config(false), - m_user_theory_preprocess_axioms(false), - m_user_theory_persist_axioms(false), - m_nlsat(false) { + m_nlsat(false), + m_dump_goal_as_smt(false) { } void register_params(ini_params & p); diff --git a/src/front_end_params/model_params.cpp b/src/front_end_params/model_params.cpp deleted file mode 100644 index a859684d8..000000000 --- a/src/front_end_params/model_params.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - model_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-08-23. - -Revision History: - ---*/ - -#include"model_params.h" - -void model_params::register_params(ini_params & p) { - p.register_bool_param("model_partial", m_model_partial, "enable/disable partial function interpretations", true); - p.register_bool_param("model_v1", m_model_v1_pp, - "use Z3 version 1.x pretty printer", true); - p.register_bool_param("model_v2", m_model_v2_pp, - "use Z3 version 2.x (x <= 16) pretty printer", true); - p.register_bool_param("model_compact", m_model_compact, - "try to compact function graph (i.e., function interpretations that are lookup tables", true); - p.register_bool_param("model_completion", m_model_completion, - "assigns an interptetation to symbols that do not have one in the current model, when evaluating expressions in the current model", true); - -} - - diff --git a/src/front_end_params/model_params.h b/src/front_end_params/model_params.h deleted file mode 100644 index 2718d4e5f..000000000 --- a/src/front_end_params/model_params.h +++ /dev/null @@ -1,43 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - model_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-08-23. - -Revision History: - ---*/ -#ifndef _MODEL_PARAMS_H_ -#define _MODEL_PARAMS_H_ - -#include"ini_file.h" - -struct model_params { - bool m_model_partial; - bool m_model_compact; - bool m_model_v1_pp; - bool m_model_v2_pp; - bool m_model_completion; - - model_params(): - m_model_partial(false), - m_model_compact(false), - m_model_v1_pp(false), - m_model_v2_pp(false), - m_model_completion(false) { - } - - void register_params(ini_params & p); -}; - -#endif /* _MODEL_PARAMS_H_ */ - diff --git a/src/front_end_params/parser_params.cpp b/src/front_end_params/parser_params.cpp deleted file mode 100644 index 3edd03fb0..000000000 --- a/src/front_end_params/parser_params.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "parser_params.h" - -parser_params::parser_params() : - m_dump_goal_as_smt(false), - m_display_error_for_vs(false) { -} - -void parser_params::register_params(ini_params & p) { - p.register_bool_param("dump_goal_as_smt", m_dump_goal_as_smt, "write goal back to output in SMT format"); - p.register_bool_param("display_error_for_visual_studio", m_display_error_for_vs, "display error messages in Visual Studio format"); -} - - - diff --git a/src/front_end_params/parser_params.h b/src/front_end_params/parser_params.h deleted file mode 100644 index eaab4fd81..000000000 --- a/src/front_end_params/parser_params.h +++ /dev/null @@ -1,33 +0,0 @@ -/*++ -Copyright (c) 2008 Microsoft Corporation - -Module Name: - - parser_params.h - -Abstract: - - - -Author: - - Nikolaj Bjorner (nbjorner) 2008-04-21. - -Revision History: - ---*/ -#ifndef _PARSER_PARAMS_H_ -#define _PARSER_PARAMS_H_ - -#include"ini_file.h" - -struct parser_params { - bool m_dump_goal_as_smt; // re-print goal as SMT benchmark. - bool m_display_error_for_vs; // print error in vs format. - - parser_params(); - void register_params(ini_params & p); -}; - -#endif /* _PARSER_PARAMS_H_ */ - diff --git a/src/front_end_params/smt_params.cpp b/src/front_end_params/smt_params.cpp index 74e279ff8..737b369b4 100644 --- a/src/front_end_params/smt_params.cpp +++ b/src/front_end_params/smt_params.cpp @@ -103,5 +103,17 @@ void smt_params::register_params(ini_params & p) { p.register_bool_param("model_on_final_check", m_model_on_final_check, "display candidate model (in the standard output) whenever Z3 hits a final check", true); p.register_unsigned_param("progress_sampling_freq", m_progress_sampling_freq, "frequency for progress output in miliseconds"); + + + p.register_bool_param("user_theory_preprocess_axioms", + m_user_theory_preprocess_axioms, + "Apply full pre-processing to user theory axioms", + true); + + p.register_bool_param("user_theory_persist_axioms", + m_user_theory_persist_axioms, + "Persist user axioms to the base level", + true); + } diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 5c62c49e3..c6b34a2d3 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -169,6 +169,7 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith // // ----------------------------------- bool m_model; + bool m_model_compact; bool m_model_validate; bool m_model_on_timeout; bool m_model_on_final_check; @@ -187,6 +188,15 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith // ----------------------------------- bool m_display_installed_theories; + // ----------------------------------- + // + // From front_end_params + // + // ----------------------------------- + bool m_preprocess; // temporary hack for disabling all preprocessing.. + bool m_user_theory_preprocess_axioms; + bool m_user_theory_persist_axioms; + smt_params(): m_display_proof(false), m_display_dot_proof(false), @@ -241,11 +251,17 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith m_display_ll_bool_var2expr(false), m_abort_after_preproc(false), m_model(true), + m_model_compact(false), m_model_validate(false), m_model_on_timeout(false), m_model_on_final_check(false), m_progress_sampling_freq(0), - m_display_installed_theories(false) { + m_display_installed_theories(false), + m_preprocess(true), // temporary hack for disabling all preprocessing.. + m_user_theory_preprocess_axioms(false), + m_user_theory_persist_axioms(false) + { + } void register_params(ini_params & p); diff --git a/src/parsers/smt/smtlib_solver.cpp b/src/parsers/smt/smtlib_solver.cpp index dd54de350..ddcdb56c8 100644 --- a/src/parsers/smt/smtlib_solver.cpp +++ b/src/parsers/smt/smtlib_solver.cpp @@ -28,6 +28,8 @@ Revision History: #include"solver.h" #include"smt_strategic_solver.h" #include"cmd_context.h" +#include"model_params.hpp" +#include"parser_params.hpp" namespace smtlib { @@ -35,8 +37,9 @@ namespace smtlib { m_ast_manager(params.m_proof_mode, params.m_trace_stream), m_params(params), m_ctx(0), - m_parser(parser::create(m_ast_manager, params.m_ignore_user_patterns)), m_error_code(0) { + parser_params ps; + m_parser = parser::create(m_ast_manager, ps.ignore_user_patterns()); m_parser->initialize_smtlib(); } @@ -82,7 +85,7 @@ namespace smtlib { // Hack: it seems SMT-LIB allow benchmarks without any :formula benchmark.add_formula(m_ast_manager.mk_true()); } - m_ctx = alloc(cmd_context, &m_params, true, &m_ast_manager, benchmark.get_logic()); + m_ctx = alloc(cmd_context, true, &m_ast_manager, benchmark.get_logic()); m_ctx->set_solver(mk_smt_strategic_solver(false)); theory::expr_iterator fit = benchmark.begin_formulas(); theory::expr_iterator fend = benchmark.end_formulas(); @@ -105,7 +108,8 @@ namespace smtlib { model_ref md; if (r->status() != l_false) r->get_model(md); if (md.get() != 0 && m_params.m_model) { - model_v2_pp(std::cout, *(md.get()), m_params.m_model_partial); + model_params p; + model_v2_pp(std::cout, *(md.get()), p.partial()); } } else { diff --git a/src/parsers/smt2/smt2parser.cpp b/src/parsers/smt2/smt2parser.cpp index f288c526e..c0c8d5bc5 100644 --- a/src/parsers/smt2/smt2parser.cpp +++ b/src/parsers/smt2/smt2parser.cpp @@ -28,7 +28,7 @@ Revision History: #include"rewriter.h" #include"has_free_vars.h" #include"ast_smt2_pp.h" -#include"front_end_params.h" +#include"parser_params.hpp" namespace smt2 { typedef cmd_exception parser_exception; @@ -106,9 +106,14 @@ namespace smt2 { ast_manager & m() const { return m_ctx.m(); } pdecl_manager & pm() const { return m_ctx.pm(); } sexpr_manager & sm() const { return m_ctx.sm(); } + + bool m_ignore_user_patterns; + bool m_ignore_bad_patterns; + bool m_display_error_for_vs; - bool ignore_user_patterns() const { return m_ctx.params().m_ignore_user_patterns; } - bool ignore_bad_patterns() const { return m_ctx.params().m_ignore_bad_patterns; } + bool ignore_user_patterns() const { return m_ignore_user_patterns; } + bool ignore_bad_patterns() const { return m_ignore_bad_patterns; } + bool use_vs_format() const { return m_display_error_for_vs; } struct psort_frame { psort_decl * m_decl; @@ -383,8 +388,6 @@ namespace smt2 { void check_int(char const * msg) { if (!curr_is_int()) throw parser_exception(msg); } void check_float(char const * msg) { if (!curr_is_float()) throw parser_exception(msg); } - bool use_vs_format() const { return m_ctx.params().m_display_error_for_vs; } - void error(unsigned line, unsigned pos, char const * msg) { if (use_vs_format()) { m_ctx.diagnostic_stream() << "Z3(" << line << ", " << pos << "): ERROR: " << msg; @@ -2354,9 +2357,9 @@ namespace smt2 { } public: - parser(cmd_context & ctx, std::istream & is, bool interactive): + parser(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & _p): m_ctx(ctx), - m_scanner(ctx, is, interactive), + m_scanner(ctx, is, interactive, _p), m_curr(scanner::NULL_TOKEN), m_curr_cmd(0), m_num_bindings(0), @@ -2393,6 +2396,11 @@ namespace smt2 { m_num_open_paren(0) { // the following assertion does not hold if ctx was already attached to an AST manager before the parser object is created. // SASSERT(!m_ctx.has_manager()); + + parser_params p(_p); + m_ignore_user_patterns = p.ignore_user_patterns(); + m_ignore_bad_patterns = p.ignore_bad_patterns(); + m_display_error_for_vs = p.error_for_visual_studio(); } ~parser() { @@ -2487,8 +2495,8 @@ namespace smt2 { }; }; -bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive) { - smt2::parser p(ctx, is, interactive); +bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive, params_ref const & ps) { + smt2::parser p(ctx, is, interactive, ps); return p(); } diff --git a/src/parsers/smt2/smt2parser.h b/src/parsers/smt2/smt2parser.h index a7264ff63..d230e5ae0 100644 --- a/src/parsers/smt2/smt2parser.h +++ b/src/parsers/smt2/smt2parser.h @@ -21,6 +21,6 @@ Revision History: #include"cmd_context.h" -bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive = false); +bool parse_smt2_commands(cmd_context & ctx, std::istream & is, bool interactive = false, params_ref const & p = params_ref()); #endif diff --git a/src/parsers/smt2/smt2scanner.cpp b/src/parsers/smt2/smt2scanner.cpp index b350796fc..e2b2030ac 100644 --- a/src/parsers/smt2/smt2scanner.cpp +++ b/src/parsers/smt2/smt2scanner.cpp @@ -17,6 +17,7 @@ Revision History: --*/ #include"smt2scanner.h" +#include"parser_params.hpp" namespace smt2 { @@ -241,7 +242,7 @@ namespace smt2 { } } - scanner::scanner(cmd_context & ctx, std::istream& stream, bool interactive): + scanner::scanner(cmd_context & ctx, std::istream& stream, bool interactive, params_ref const & _p): m_ctx(ctx), m_interactive(interactive), m_spos(0), @@ -253,6 +254,10 @@ namespace smt2 { m_bend(0), m_stream(stream), m_cache_input(false) { + + parser_params p(_p); + m_smtlib2_compliant = p.smt2_compliant(); + for (int i = 0; i < 256; ++i) { m_normalized[i] = (char) i; } @@ -325,7 +330,7 @@ namespace smt2 { case '#': return read_bv_literal(); case '-': - if (m_ctx.is_smtlib2_compliant()) + if (m_smtlib2_compliant) return read_symbol(); else return read_signed_number(); diff --git a/src/parsers/smt2/smt2scanner.h b/src/parsers/smt2/smt2scanner.h index 015f05fa1..c63a09ff1 100644 --- a/src/parsers/smt2/smt2scanner.h +++ b/src/parsers/smt2/smt2scanner.h @@ -55,6 +55,8 @@ namespace smt2 { svector m_cache; svector m_cache_result; + bool m_smtlib2_compliant; + char curr() const { return m_curr; } void new_line() { m_line++; m_spos = 0; } void next(); @@ -74,7 +76,7 @@ namespace smt2 { EOF_TOKEN }; - scanner(cmd_context & ctx, std::istream& stream, bool interactive = false); + scanner(cmd_context & ctx, std::istream& stream, bool interactive = false, params_ref const & p = params_ref()); ~scanner() {} diff --git a/src/parsers/util/parser_params.pyg b/src/parsers/util/parser_params.pyg new file mode 100644 index 000000000..fa8f17a00 --- /dev/null +++ b/src/parsers/util/parser_params.pyg @@ -0,0 +1,6 @@ +def_module_params('parser', + export=True, + params=(('ignore_user_patterns', BOOL, False, 'ignore patterns provided by the user'), + ('ignore_bad_patterns', BOOL, True, 'ignore malformed patterns'), + ('error_for_visual_studio', BOOL, False, 'display error messages in Visual Studio format'), + ('smt2_compliant', BOOL, False, 'enable/disable SMT-LIB 2.0 compliance'))) diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 56882a02b..bc3953c1e 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -77,7 +77,7 @@ void display_usage() { std::cout << " " << OPT << "version prints version number of Z3.\n"; std::cout << " " << OPT << "v:level be verbose, where is the verbosity level.\n"; std::cout << " " << OPT << "nw disable warning messages.\n"; - std::cout << " " << OPT << "params display all available parameters.\n"; + std::cout << " " << OPT << "ps display all available parameters.\n"; std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. @@ -184,10 +184,7 @@ void parse_cmd_line_args(int argc, char ** argv) { if (i < argc - 1) g_aux_input_file += " "; } - if (g_front_end_params->m_interactive) { - warning_msg("ignoring input file in interactive mode."); - } - else if (g_input_file) { + if (g_input_file) { warning_msg("input file was already specified."); } else { @@ -284,7 +281,7 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "nw") == 0) { enable_warning_messages(false); } - else if (strcmp(opt_name, "params") == 0) { + else if (strcmp(opt_name, "ps") == 0) { gparams::display(std::cout); exit(0); } @@ -324,10 +321,7 @@ void parse_cmd_line_args(int argc, char ** argv) { gparams::set(key, value); } else { - if (g_front_end_params->m_interactive) { - warning_msg("ignoring input file in interactive mode."); - } - else if (g_input_file) { + if (g_input_file) { warning_msg("input file was already specified."); } else { @@ -389,7 +383,7 @@ int main(int argc, char ** argv) { if (g_input_file && g_standard_input) { error("using standard input to read formula."); } - if (!g_input_file && !g_front_end_params->m_interactive && !g_standard_input) { + if (!g_input_file && !g_standard_input) { error("input file was not specified."); } diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index 08b070183..c9dcc3fa2 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -97,7 +97,7 @@ unsigned read_smtlib2_commands(char const* file_name, front_end_params& front_en g_start_time = clock(); register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); - cmd_context ctx(&front_end_params); + cmd_context ctx; // temporary hack until strategic_solver is ported to new tactic framework if (front_end_params.m_nlsat) { diff --git a/src/smt/proto_model/proto_model.cpp b/src/smt/proto_model/proto_model.cpp index 4cedea228..34742e3a0 100644 --- a/src/smt/proto_model/proto_model.cpp +++ b/src/smt/proto_model/proto_model.cpp @@ -17,6 +17,7 @@ Revision History: --*/ #include"proto_model.h" +#include"model_params.hpp" #include"ast_pp.h" #include"ast_ll_pp.h" #include"var_subst.h" @@ -26,15 +27,16 @@ Revision History: #include"model_v2_pp.h" #include"basic_simplifier_plugin.h" -proto_model::proto_model(ast_manager & m, simplifier & s, model_params const & p): +proto_model::proto_model(ast_manager & m, simplifier & s, params_ref const & p): model_core(m), - m_params(p), m_asts(m), m_simplifier(s), m_afid(m.get_family_id(symbol("array"))) { register_factory(alloc(basic_factory, m)); m_user_sort_factory = alloc(user_sort_factory, m); register_factory(m_user_sort_factory); + + m_model_partial = model_params(p).partial(); } void proto_model::reset_finterp() { @@ -620,7 +622,7 @@ void proto_model::complete_partial_func(func_decl * f) { \brief Set the (else) field of function interpretations... */ void proto_model::complete_partial_funcs() { - if (m_params.m_model_partial) + if (m_model_partial) return; // m_func_decls may be "expanded" when we invoke get_some_value. diff --git a/src/smt/proto_model/proto_model.h b/src/smt/proto_model/proto_model.h index bd5609f33..d16586698 100644 --- a/src/smt/proto_model/proto_model.h +++ b/src/smt/proto_model/proto_model.h @@ -29,16 +29,15 @@ Revision History: #define _PROTO_MODEL_H_ #include"model_core.h" -#include"model_params.h" #include"value_factory.h" #include"plugin_manager.h" #include"simplifier.h" #include"arith_decl_plugin.h" #include"func_decl_dependencies.h" #include"model.h" +#include"params.h" class proto_model : public model_core { - model_params const & m_params; ast_ref_vector m_asts; plugin_manager m_factories; user_sort_factory * m_user_sort_factory; @@ -47,6 +46,8 @@ class proto_model : public model_core { func_decl_set m_aux_decls; ptr_vector m_tmp; + bool m_model_partial; + void reset_finterp(); expr * mk_some_interp_for(func_decl * d); @@ -60,11 +61,9 @@ class proto_model : public model_core { public: - proto_model(ast_manager & m, simplifier & s, model_params const & p); + proto_model(ast_manager & m, simplifier & s, params_ref const & p = params_ref()); virtual ~proto_model(); - model_params const & get_model_params() const { return m_params; } - void register_factory(value_factory * f) { m_factories.register_plugin(f); } bool eval(expr * e, expr_ref & result, bool model_completion = false); diff --git a/src/smt/smt_model_generator.cpp b/src/smt/smt_model_generator.cpp index 1c441ad11..d14abc31a 100644 --- a/src/smt/smt_model_generator.cpp +++ b/src/smt/smt_model_generator.cpp @@ -48,7 +48,8 @@ namespace smt { void model_generator::init_model() { SASSERT(!m_model); - m_model = alloc(proto_model, m_manager, m_context->get_simplifier(), m_context->get_fparams()); + // PARAM-TODO + m_model = alloc(proto_model, m_manager, m_context->get_simplifier()); // , m_context->get_fparams()); ptr_vector::const_iterator it = m_context->begin_theories(); ptr_vector::const_iterator end = m_context->end_theories(); for (; it != end; ++it) { diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 27fdd828b..426789bb4 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -26,7 +26,6 @@ struct gparams::imp { param_descrs m_param_descrs; dictionary m_module_params; params_ref m_params; - params_ref m_empty; public: imp() { } @@ -49,28 +48,37 @@ public: } void register_global(param_descrs & d) { - m_param_descrs.copy(d); + #pragma omp critical (gparams) + { + m_param_descrs.copy(d); + } } void register_module(char const * module_name, param_descrs * d) { - symbol s(module_name); - param_descrs * old_d; - if (m_module_param_descrs.find(s, old_d)) { - old_d->copy(*d); - dealloc(d); - } - else { - m_module_param_descrs.insert(s, d); + #pragma omp critical (gparams) + { + symbol s(module_name); + param_descrs * old_d; + if (m_module_param_descrs.find(s, old_d)) { + old_d->copy(*d); + dealloc(d); + } + else { + m_module_param_descrs.insert(s, d); + } } } void display(std::ostream & out, unsigned indent, bool smt2_style) { - m_param_descrs.display(out, indent, smt2_style); - dictionary::iterator it = m_module_param_descrs.begin(); - dictionary::iterator end = m_module_param_descrs.end(); - for (; it != end; ++it) { - out << "[module] " << it->m_key << "\n"; - it->m_value->display(out, indent + 4, smt2_style); + #pragma omp critical (gparams) + { + m_param_descrs.display(out, indent, smt2_style); + dictionary::iterator it = m_module_param_descrs.begin(); + dictionary::iterator end = m_module_param_descrs.end(); + for (; it != end; ++it) { + out << "[module] " << it->m_key << "\n"; + it->m_value->display(out, indent + 4, smt2_style); + } } } @@ -102,15 +110,13 @@ public: return m_params; } else { - params_ref * p; - if (m_module_params.find(mod_name, p)) { - return *p; - } - else { + params_ref * p = 0; + if (!m_module_params.find(mod_name, p)) { p = alloc(params_ref); m_module_params.insert(mod_name, p); - return *p; } + SASSERT(p != 0); + return *p; } } @@ -119,9 +125,9 @@ public: params_ref & ps = get_params(mod_name); if (k == CPK_INVALID) { if (mod_name == symbol::null) - throw default_exception("unknown parameter '%s'", param_name.bare_str()); + throw exception("unknown parameter '%s'", param_name.bare_str()); else - throw default_exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + throw exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); } else if (k == CPK_UINT) { long val = strtol(value, 0, 10); @@ -136,9 +142,9 @@ public: } else { if (mod_name == symbol::null) - throw default_exception("invalid value '%s' for Boolean parameter '%s'", value, param_name.bare_str()); + throw exception("invalid value '%s' for Boolean parameter '%s'", value, param_name.bare_str()); else - throw default_exception("invalid value '%s' for Boolean parameter '%s' at module '%s'", value, param_name.bare_str(), mod_name.bare_str()); + throw exception("invalid value '%s' for Boolean parameter '%s' at module '%s'", value, param_name.bare_str(), mod_name.bare_str()); } } else if (k == CPK_SYMBOL) { @@ -149,47 +155,125 @@ public: } else { if (mod_name == symbol::null) - throw default_exception("unsupported parameter type '%s'", param_name.bare_str()); + throw exception("unsupported parameter type '%s'", param_name.bare_str()); else - throw default_exception("unsupported parameter type '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + throw exception("unsupported parameter type '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); } } void set(char const * name, char const * value) { - symbol m, p; - normalize(name, m, p); - if (m == symbol::null) { - set(m_param_descrs, p, value, m); - } - else { - param_descrs * d; - if (m_module_param_descrs.find(m, d)) { - set(*d, p, value, m); + bool error = false; + std::string error_msg; + #pragma omp critical (gparams) + { + try { + symbol m, p; + normalize(name, m, p); + if (m == symbol::null) { + set(m_param_descrs, p, value, m); + } + else { + param_descrs * d; + if (m_module_param_descrs.find(m, d)) { + set(*d, p, value, m); + } + else { + throw exception("invalid parameter, unknown module '%s'", m.bare_str()); + } + } } - else { - throw default_exception("invalid parameter, unknown module '%s'", m.bare_str()); + catch (exception & ex) { + // Exception cannot cross critical section boundaries. + error = true; + error_msg = ex.msg(); } } + if (error) + throw exception(error_msg); + } + + std::string get_value(params_ref const & ps, symbol const & p) { + std::ostringstream buffer; + ps.display(buffer, p); + return buffer.str(); + } + + std::string get_default(param_descrs const & d, symbol const & p, symbol const & m) { + if (!d.contains(p)) { + if (m == symbol::null) + throw exception("unknown parameter '%s'", p.bare_str()); + else + throw exception("unknown parameter '%s' at module '%s'", p.bare_str(), m.bare_str()); + } + char const * r = d.get_default(p); + if (r == 0) + return "default"; + return r; } std::string get_value(char const * name) { - // TODO - return ""; + std::string r; + bool error = false; + std::string error_msg; + #pragma omp critical (gparams) + { + try { + symbol m, p; + normalize(name, m, p); + if (m == symbol::null) { + if (m_params.contains(p)) { + r = get_value(m_params, p); + } + else { + r = get_default(m_param_descrs, p, m); + } + } + else { + params_ref * ps = 0; + if (m_module_params.find(m, ps) && ps->contains(p)) { + r = get_value(*ps, p); + } + else { + param_descrs * d; + if (m_module_param_descrs.find(m, d)) { + r = get_default(*d, p, m); + } + else { + throw exception("unknown module '%s'", m.bare_str()); + } + } + } + } + catch (exception & ex) { + // Exception cannot cross critical section boundaries. + error = true; + error_msg = ex.msg(); + } + } + if (error) + throw exception(error_msg); + return r; } - - params_ref const & get_module(symbol const & module_name) { + params_ref get_module(symbol const & module_name) { + params_ref result; params_ref * ps = 0; - if (m_module_params.find(module_name, ps)) { - return *ps; - } - else { - return m_empty; + #pragma omp critical (gparams) + { + if (m_module_params.find(module_name, ps)) { + result = *ps; + } } + return result; } - params_ref const & get() { - return m_params; + params_ref get() { + params_ref result; + #pragma omp critical (gparams) + { + result = m_params; + } + return result; } }; @@ -226,16 +310,16 @@ void gparams::register_module(char const * module_name, param_descrs * d) { g_imp->register_module(module_name, d); } -params_ref const & gparams::get_module(char const * module_name) { +params_ref gparams::get_module(char const * module_name) { return get_module(symbol(module_name)); } -params_ref const & gparams::get_module(symbol const & module_name) { +params_ref gparams::get_module(symbol const & module_name) { SASSERT(g_imp != 0); return g_imp->get_module(module_name); } -params_ref const & gparams::get() { +params_ref gparams::get() { SASSERT(g_imp != 0); return g_imp->get(); } diff --git a/src/util/gparams.h b/src/util/gparams.h index 7112e67f9..04e1f6051 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -31,7 +31,7 @@ public: \brief Set a global parameter \c name with \c value. The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'. - The character '.' is used a delimiter (more later). + The character '.' is a delimiter (more later). The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. Thus, the following parameter names are considered equivalent: "auto-config" and "AUTO_CONFIG". @@ -90,13 +90,13 @@ public: // In this example "p" will contain "decimal" -> true after executing this function. params_ref const & p = get_module_params("pp") */ - static params_ref const & get_module(char const * module_name); - static params_ref const & get_module(symbol const & module_name); + static params_ref get_module(char const * module_name); + static params_ref get_module(symbol const & module_name); /** \brief Return the global parameter set (i.e., parameters that are not associated with any particular module). */ - static params_ref const & get(); + static params_ref get(); /** \brief Dump information about available parameters in the given output stream. diff --git a/src/util/memory_manager.cpp b/src/util/memory_manager.cpp index b6eb648d9..be08fe50f 100644 --- a/src/util/memory_manager.cpp +++ b/src/util/memory_manager.cpp @@ -1,9 +1,9 @@ #include #include +#include #include"trace.h" #include"memory_manager.h" #include"error_codes.h" - // The following two function are automatically generated by the mk_make.py script. // The script collects ADD_INITIALIZER and ADD_FINALIZER commands in the .h files. // For example, rational.h contains @@ -27,6 +27,7 @@ out_of_memory_error::out_of_memory_error():z3_error(ERR_MEMOUT) { } volatile bool g_memory_out_of_memory = false; +bool g_memory_initialized = false; long long g_memory_alloc_size = 0; long long g_memory_max_size = 0; long long g_memory_max_used_size = 0; @@ -70,8 +71,20 @@ mem_usage_report g_info; #endif void memory::initialize(size_t max_size) { + bool initialize = false; + #pragma omp critical (z3_memory_manager) + { + // only update the maximum size if max_size != UINT_MAX + if (max_size != UINT_MAX) + g_memory_max_size = max_size; + if (!g_memory_initialized) { + g_memory_initialized = true; + initialize = true; + } + } + if (!initialize) + return; g_memory_out_of_memory = false; - g_memory_max_size = max_size; mem_initialize(); } @@ -108,8 +121,12 @@ void memory::set_max_size(size_t max_size) { static bool g_finalizing = false; void memory::finalize() { - g_finalizing = true; - mem_finalize(); + if (g_memory_initialized) { + g_finalizing = true; + mem_finalize(); + g_memory_initialized = false; + g_finalizing = false; + } } unsigned long long memory::get_allocation_size() { diff --git a/src/util/params.cpp b/src/util/params.cpp index 264149e4b..4f2a73e99 100644 --- a/src/util/params.cpp +++ b/src/util/params.cpp @@ -57,6 +57,10 @@ struct param_descrs::imp { void erase(symbol const & name) { m_info.erase(name); } + + bool contains(symbol const & name) const { + return m_info.contains(name); + } param_kind get_kind(symbol const & name) const { info i; @@ -157,6 +161,14 @@ void param_descrs::insert(char const * name, param_kind k, char const * descr, c insert(symbol(name), k, descr, def); } +bool param_descrs::contains(char const * name) const { + return contains(symbol(name)); +} + +bool param_descrs::contains(symbol const & name) const { + return m_imp->contains(name); +} + char const * param_descrs::get_descr(char const * name) const { return get_descr(symbol(name)); } @@ -345,7 +357,7 @@ public: continue; switch (it->second.m_kind) { case CPK_BOOL: - out << it->second.m_bool_value; + out << (it->second.m_bool_value?"true":"false"); return; case CPK_UINT: out << it->second.m_uint_value; diff --git a/src/util/params.h b/src/util/params.h index 747b23e39..68f4c967b 100644 --- a/src/util/params.h +++ b/src/util/params.h @@ -109,6 +109,8 @@ public: void copy(param_descrs & other); void insert(char const * name, param_kind k, char const * descr, char const * def = 0); void insert(symbol const & name, param_kind k, char const * descr, char const * def = 0); + bool contains(char const * name) const; + bool contains(symbol const & name) const; void erase(char const * name); void erase(symbol const & name); param_kind get_kind(char const * name) const; From 823dd6ca47e8ed64aa9d828ab55845718bb5e86c Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 15:54:53 -0800 Subject: [PATCH 13/34] missing file Signed-off-by: Leonardo de Moura --- src/model/model_params.pyg | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/model/model_params.pyg diff --git a/src/model/model_params.pyg b/src/model/model_params.pyg new file mode 100644 index 000000000..689519e6c --- /dev/null +++ b/src/model/model_params.pyg @@ -0,0 +1,9 @@ +def_module_params('model', + export=True, + params=(('validate', BOOL, False, 'validate models produced by Z3'), + ('partial', BOOL, False, 'enable/disable partial function interpretations'), + ('v1', BOOL, False, 'use Z3 version 1.x pretty printer'), + ('v2', BOOL, False, 'use Z3 version 2.x (x <= 16) pretty printer'), + ('compact', BOOL, False, 'try to compact function graph (i.e., function interpretations that are lookup tables)'), + ('completion', BOOL, False, 'assigns an interptetation to symbols that do not have one in the current model, when evaluating expressions in the current model'))) + From 9374a4e20ae1bcabcaacbd1408a2ab728886f462 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 16:30:39 -0800 Subject: [PATCH 14/34] removed ini_file Signed-off-by: Leonardo de Moura --- src/cmd_context/cmd_context.cpp | 5 - .../arith_simplifier_params.cpp | 3 +- .../arith_simplifier_params.h | 4 - src/front_end_params/bit_blaster_params.h | 4 +- src/front_end_params/bv_simplifier_params.h | 4 +- src/front_end_params/dyn_ack_params.cpp | 3 +- src/front_end_params/dyn_ack_params.h | 3 - src/front_end_params/front_end_params.cpp | 10 +- src/front_end_params/front_end_params.h | 25 - .../pattern_inference_params.cpp | 3 +- .../pattern_inference_params.h | 4 - src/front_end_params/preprocessor_params.h | 3 + src/front_end_params/qi_params.h | 7 +- src/front_end_params/smt_params.cpp | 2 + src/front_end_params/smt_params.h | 7 +- src/front_end_params/theory_arith_params.cpp | 2 + src/front_end_params/theory_arith_params.h | 4 +- src/front_end_params/theory_array_params.h | 5 +- src/front_end_params/theory_bv_params.h | 4 +- src/front_end_params/theory_datatype_params.h | 4 +- src/muz_qe/dl_cmds.cpp | 6 +- src/muz_qe/dl_context.cpp | 16 +- src/muz_qe/pdr_dl_interface.cpp | 22 +- src/shell/datalog_frontend.cpp | 8 +- src/shell/datalog_frontend.h | 2 +- src/shell/main.cpp | 55 +- src/shell/smtlib_frontend.cpp | 1 - src/smt/smt_context.cpp | 6 - src/smt/smt_context.h | 2 - src/smt/smt_setup.cpp | 1 - src/test/ini_file.cpp | 50 - src/test/main.cpp | 1 - src/util/ini_file.cpp | 1564 ----------------- src/util/ini_file.h | 117 -- src/util/instruction_count.cpp | 41 - src/util/instruction_count.h | 43 - src/util/util.cpp | 6 +- src/util/warning.cpp | 6 +- 38 files changed, 82 insertions(+), 1971 deletions(-) delete mode 100644 src/test/ini_file.cpp delete mode 100644 src/util/ini_file.cpp delete mode 100644 src/util/ini_file.h delete mode 100644 src/util/instruction_count.cpp delete mode 100644 src/util/instruction_count.h diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index cd8c81387..984e5db0c 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -1295,11 +1295,6 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions return; IF_VERBOSE(100, verbose_stream() << "check-sat..." << std::endl;); TRACE("before_check_sat", dump_assertions(tout);); - if (params().m_ignore_checksat) { - m_check_sat_result = 0; - regular_stream() << "unknown" << std::endl; - return; - } if (!has_manager()) init_manager(); if (m_solver) { diff --git a/src/front_end_params/arith_simplifier_params.cpp b/src/front_end_params/arith_simplifier_params.cpp index 21808bc1e..8cf07b915 100644 --- a/src/front_end_params/arith_simplifier_params.cpp +++ b/src/front_end_params/arith_simplifier_params.cpp @@ -19,8 +19,9 @@ Revision History: #include"arith_simplifier_params.h" +#if 0 void arith_simplifier_params::register_params(ini_params & p) { p.register_bool_param("arith_expand_eqs", m_arith_expand_eqs); p.register_bool_param("arith_process_all_eqs", m_arith_process_all_eqs); } - +#endif diff --git a/src/front_end_params/arith_simplifier_params.h b/src/front_end_params/arith_simplifier_params.h index 3e44b5a6e..f1b22b09a 100644 --- a/src/front_end_params/arith_simplifier_params.h +++ b/src/front_end_params/arith_simplifier_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _ARITH_SIMPLIFIER_PARAMS_H_ #define _ARITH_SIMPLIFIER_PARAMS_H_ -#include"ini_file.h" - struct arith_simplifier_params { bool m_arith_expand_eqs; bool m_arith_process_all_eqs; @@ -29,8 +27,6 @@ struct arith_simplifier_params { m_arith_expand_eqs(false), m_arith_process_all_eqs(false) { } - - void register_params(ini_params & p); }; #endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/front_end_params/bit_blaster_params.h b/src/front_end_params/bit_blaster_params.h index ab183d7fc..653c8fc74 100644 --- a/src/front_end_params/bit_blaster_params.h +++ b/src/front_end_params/bit_blaster_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _BIT_BLASTER_PARAMS_H_ #define _BIT_BLASTER_PARAMS_H_ -#include"ini_file.h" - struct bit_blaster_params { bool m_bb_ext_gates; bool m_bb_quantifiers; @@ -28,10 +26,12 @@ struct bit_blaster_params { m_bb_ext_gates(false), m_bb_quantifiers(false) { } +#if 0 void register_params(ini_params & p) { p.register_bool_param("bb_ext_gates", m_bb_ext_gates, "use extended gates during bit-blasting"); p.register_bool_param("bb_quantifiers", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers"); } +#endif }; #endif /* _BIT_BLASTER_PARAMS_H_ */ diff --git a/src/front_end_params/bv_simplifier_params.h b/src/front_end_params/bv_simplifier_params.h index 50dedfd22..887940e36 100644 --- a/src/front_end_params/bv_simplifier_params.h +++ b/src/front_end_params/bv_simplifier_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _BV_SIMPLIFIER_PARAMS_H_ #define _BV_SIMPLIFIER_PARAMS_H_ -#include"ini_file.h" - struct bv_simplifier_params { bool m_hi_div0; //!< if true, uses the hardware interpretation for div0, mod0, ... if false, div0, mod0, ... are considered uninterpreted. bool m_bv2int_distribute; //!< if true allows downward propagation of bv2int. @@ -29,10 +27,12 @@ struct bv_simplifier_params { m_hi_div0(true), m_bv2int_distribute(true) { } +#if 0 void register_params(ini_params & p) { p.register_bool_param("hi_div0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted."); p.register_bool_param("bv2int_distribute", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators."); } +#endif }; #endif /* _BV_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/front_end_params/dyn_ack_params.cpp b/src/front_end_params/dyn_ack_params.cpp index 90a0bb17b..2e94c376d 100644 --- a/src/front_end_params/dyn_ack_params.cpp +++ b/src/front_end_params/dyn_ack_params.cpp @@ -18,6 +18,7 @@ Revision History: --*/ #include"dyn_ack_params.h" +#if 0 void dyn_ack_params::register_params(ini_params & p) { p.register_int_param("dack", 0, 2, reinterpret_cast(m_dack), "0 - disable dynamic ackermannization, 1 - expand Leibniz's axiom if a congruence is the root of a conflict, 2 - expand Leibniz's axiom if a congruence is used during conflict resolution."); @@ -27,5 +28,5 @@ void dyn_ack_params::register_params(ini_params & p) { p.register_unsigned_param("dack_gc", m_dack_gc, "Dynamic ackermannization garbage collection frequency (per conflict)."); p.register_double_param("dack_gc_inv_decay", m_dack_gc_inv_decay); } - +#endif diff --git a/src/front_end_params/dyn_ack_params.h b/src/front_end_params/dyn_ack_params.h index c5325195e..9f7ce578c 100644 --- a/src/front_end_params/dyn_ack_params.h +++ b/src/front_end_params/dyn_ack_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _DYN_ACK_PARAMS_H_ #define _DYN_ACK_PARAMS_H_ -#include"ini_file.h" - enum dyn_ack_strategy { DACK_DISABLED, DACK_ROOT, // congruence is the root of the conflict @@ -45,7 +43,6 @@ public: m_dack_gc_inv_decay(0.8) { } - void register_params(ini_params & p); }; diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index d30ec825d..49c3f042e 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -18,8 +18,9 @@ Revision History: --*/ #include"front_end_params.h" +#if 0 + void front_end_params::register_params(ini_params & p) { - p.register_param_vector(m_param_vector.get()); preprocessor_params::register_params(p); smt_params::register_params(p); arith_simplifier_params::register_params(p); @@ -27,8 +28,6 @@ void front_end_params::register_params(ini_params & p) { "only use labels that contain '@' when building multiple counterexamples"); p.register_bool_param("check_at_labels", m_check_at_labels, "check that labels containing '@' are used correctly to only produce unique counter examples"); - p.register_bool_param("default_qid", m_default_qid, "create a default quantifier id based on its position, the id is used to report profiling information (see QI_PROFILE)"); - p.register_bool_param("type_check", m_well_sorted_check, "enable/disable type checker"); p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); @@ -49,10 +48,7 @@ void front_end_params::register_params(ini_params & p) { PRIVATE_PARAMS({ - p.register_bool_param("ignore_checksat", m_ignore_checksat); p.register_bool_param("debug_ref_count", m_debug_ref_count); - p.register_bool_param("incremental_core_assert", m_incremental_core_assert); - DEBUG_CODE(p.register_int_param("copy_params", m_copy_params);); }); // temporary hack until strategic_solver is ported to new tactic framework @@ -61,6 +57,8 @@ void front_end_params::register_params(ini_params & p) { }); } +#endif + void front_end_params::open_trace_file() { if (m_trace) { m_trace_stream = alloc(std::fstream, m_trace_file_name.c_str(), std::ios_base::out); diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index 505052450..d033ba911 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -19,7 +19,6 @@ Revision History: #ifndef _FRONT_END_PARAMS_H_ #define _FRONT_END_PARAMS_H_ -#include"ini_file.h" #include"ast.h" #include"preprocessor_params.h" #include"smt_params.h" @@ -27,23 +26,14 @@ Revision History: struct front_end_params : public preprocessor_params, public smt_params, public arith_simplifier_params { - ref m_param_vector; bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. - bool m_default_qid; bool m_well_sorted_check; - bool m_incremental_core_assert; // assert conditions to the core incrementally - unsigned m_soft_timeout; - double m_instr_out; unsigned m_memory_high_watermark; unsigned m_memory_max_size; proof_gen_mode m_proof_mode; bool m_auto_config; -#ifdef Z3DEBUG - int m_copy_params; // used for testing copy params... Invoke method copy_params(m_copy_params) in main.cpp when diff -1. -#endif - bool m_ignore_checksat; // abort before checksat... for internal debugging bool m_debug_ref_count; bool m_trace; std::string m_trace_file_name; @@ -54,14 +44,9 @@ struct front_end_params : public preprocessor_params, public smt_params, bool m_dump_goal_as_smt; front_end_params(): - m_param_vector(alloc(param_vector, this)), m_at_labels_cex(false), m_check_at_labels(false), - m_default_qid(false), m_well_sorted_check(true), - m_incremental_core_assert(true), - m_soft_timeout(0), - m_instr_out(0.0), m_memory_high_watermark(0), m_memory_max_size(0), m_proof_mode(PGM_DISABLED), @@ -70,10 +55,6 @@ struct front_end_params : public preprocessor_params, public smt_params, #else m_auto_config(false), #endif -#ifdef Z3DEBUG - m_copy_params(-1), -#endif - m_ignore_checksat(false), m_debug_ref_count(false), m_trace(false), m_trace_file_name("z3.log"), @@ -83,16 +64,10 @@ struct front_end_params : public preprocessor_params, public smt_params, m_dump_goal_as_smt(false) { } - void register_params(ini_params & p); - void open_trace_file(); void close_trace_file(); - void copy_params(unsigned idx) { - m_param_vector->copy_params(this, idx); - } - bool has_auto_config(unsigned idx) { return m_auto_config; } private: diff --git a/src/front_end_params/pattern_inference_params.cpp b/src/front_end_params/pattern_inference_params.cpp index 4b0d4c964..cfc0df4f1 100644 --- a/src/front_end_params/pattern_inference_params.cpp +++ b/src/front_end_params/pattern_inference_params.cpp @@ -18,6 +18,7 @@ Revision History: --*/ #include"pattern_inference_params.h" +#if 0 void pattern_inference_params::register_params(ini_params & p) { p.register_unsigned_param("pi_max_multi_patterns", m_pi_max_multi_patterns, "when patterns are not provided, the prover uses a heuristic to infer them. This option sets the threshold on the number of extra multi-patterns that can be created. By default, the prover creates at most one multi-pattern when there is no unary pattern"); @@ -33,5 +34,5 @@ void pattern_inference_params::register_params(ini_params & p) { p.register_bool_param("pi_avoid_skolems", m_pi_avoid_skolems); p.register_bool_param("pi_warnings", m_pi_warnings, "enable/disable warning messages in the pattern inference module."); } - +#endif diff --git a/src/front_end_params/pattern_inference_params.h b/src/front_end_params/pattern_inference_params.h index 79d7b4d87..7108e5589 100644 --- a/src/front_end_params/pattern_inference_params.h +++ b/src/front_end_params/pattern_inference_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _PATTERN_INFERENCE_PARAMS_H_ #define _PATTERN_INFERENCE_PARAMS_H_ -#include"ini_file.h" - enum arith_pattern_inference_kind { AP_NO, // do not infer patterns with arithmetic terms AP_CONSERVATIVE, // only infer patterns with arithmetic terms if there is no other option @@ -51,8 +49,6 @@ struct pattern_inference_params { m_pi_avoid_skolems(true), m_pi_warnings(false) { } - - void register_params(ini_params & p); }; #endif /* _PATTERN_INFERENCE_PARAMS_H_ */ diff --git a/src/front_end_params/preprocessor_params.h b/src/front_end_params/preprocessor_params.h index 00466bc02..b84aebe1a 100644 --- a/src/front_end_params/preprocessor_params.h +++ b/src/front_end_params/preprocessor_params.h @@ -76,6 +76,7 @@ public: m_nlquant_elim(false) { } +#if 0 void register_params(ini_params & p) { pattern_inference_params::register_params(p); bit_blaster_params::register_params(p); @@ -100,6 +101,8 @@ public: p.register_bool_param("bv_max_sharing", m_max_bv_sharing); p.register_bool_param("pre_simplifier", m_pre_simplifier); } +#endif + }; #endif /* _PREPROCESSOR_PARAMS_H_ */ diff --git a/src/front_end_params/qi_params.h b/src/front_end_params/qi_params.h index aee2c4d3d..1a8edb3a8 100644 --- a/src/front_end_params/qi_params.h +++ b/src/front_end_params/qi_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _QI_PARAMS_H_ #define _QI_PARAMS_H_ -#include"ini_file.h" +#include"util.h" enum quick_checker_mode { MC_NO, // do not use (cheap) model checking based instantiation @@ -105,7 +105,8 @@ struct qi_params { m_mbqi_force_template(10), m_instgen(false) { } - + +#if 0 void register_params(ini_params & p) { p.register_unsigned_param("qi_max_eager_multi_patterns", m_qi_max_eager_multipatterns, "Specify the number of extra multi patterns that are processed eagerly. By default, the prover use at most one multi-pattern eagerly when there is no unary pattern. This value should be smaller than or equal to PI_MAX_MULTI_PATTERNS"); @@ -133,6 +134,8 @@ struct qi_params { p.register_bool_param("inst_gen", m_instgen, "Enable Instantiation Generation solver (disables other quantifier reasoning)", false); } +#endif + }; #endif /* _QI_PARAMS_H_ */ diff --git a/src/front_end_params/smt_params.cpp b/src/front_end_params/smt_params.cpp index 737b369b4..77d3660e6 100644 --- a/src/front_end_params/smt_params.cpp +++ b/src/front_end_params/smt_params.cpp @@ -19,6 +19,7 @@ Revision History: #include"smt_params.h" #include"trace.h" +#if 0 void smt_params::register_params(ini_params & p) { dyn_ack_params::register_params(p); qi_params::register_params(p); @@ -117,3 +118,4 @@ void smt_params::register_params(ini_params & p) { } +#endif diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index c6b34a2d3..804049315 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -19,7 +19,6 @@ Revision History: #ifndef _SMT_PARAMS_H_ #define _SMT_PARAMS_H_ -#include"ini_file.h" #include"dyn_ack_params.h" #include"qi_params.h" #include"theory_arith_params.h" @@ -196,6 +195,7 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith bool m_preprocess; // temporary hack for disabling all preprocessing.. bool m_user_theory_preprocess_axioms; bool m_user_theory_persist_axioms; + unsigned m_soft_timeout; smt_params(): m_display_proof(false), @@ -259,12 +259,11 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith m_display_installed_theories(false), m_preprocess(true), // temporary hack for disabling all preprocessing.. m_user_theory_preprocess_axioms(false), - m_user_theory_persist_axioms(false) + m_user_theory_persist_axioms(false), + m_soft_timeout(0) { } - - void register_params(ini_params & p); }; #endif /* _SMT_PARAMS_H_ */ diff --git a/src/front_end_params/theory_arith_params.cpp b/src/front_end_params/theory_arith_params.cpp index 49a654dbf..8dde26e94 100644 --- a/src/front_end_params/theory_arith_params.cpp +++ b/src/front_end_params/theory_arith_params.cpp @@ -19,6 +19,7 @@ Revision History: #include"theory_arith_params.h" +#if 0 void theory_arith_params::register_params(ini_params & p) { #ifdef _EXTERNAL_RELEASE p.register_int_param("arith_solver", 0, 3, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination"); @@ -74,3 +75,4 @@ void theory_arith_params::register_params(ini_params & p) { p.register_bool_param("arith_euclidean_solver", m_arith_euclidean_solver, ""); } +#endif diff --git a/src/front_end_params/theory_arith_params.h b/src/front_end_params/theory_arith_params.h index 290049037..01163dd0a 100644 --- a/src/front_end_params/theory_arith_params.h +++ b/src/front_end_params/theory_arith_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _THEORY_ARITH_PARAMS_H_ #define _THEORY_ARITH_PARAMS_H_ -#include"ini_file.h" +#include enum arith_solver_id { AS_NO_ARITH, @@ -150,8 +150,6 @@ struct theory_arith_params { m_nl_arith_rounds(1024), m_arith_euclidean_solver(false) { } - - void register_params(ini_params & p); }; #endif /* _THEORY_ARITH_PARAMS_H_ */ diff --git a/src/front_end_params/theory_array_params.h b/src/front_end_params/theory_array_params.h index 3d45ebcf5..e33bc2566 100644 --- a/src/front_end_params/theory_array_params.h +++ b/src/front_end_params/theory_array_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _THEORY_ARRAY_PARAMS_H_ #define _THEORY_ARRAY_PARAMS_H_ -#include"ini_file.h" - enum array_solver_id { AR_NO_ARRAY, AR_SIMPLE, @@ -55,6 +53,7 @@ struct theory_array_params { m_array_simplify(true) { } +#if 0 void register_params(ini_params & p) { p.register_int_param("array_solver", 0, 3, reinterpret_cast(m_array_mode), "0 - no array, 1 - simple, 2 - model based, 3 - full"); p.register_bool_param("array_weak", m_array_weak); @@ -69,6 +68,8 @@ struct theory_array_params { p.register_bool_param("array_canonize", m_array_canonize_simplify, "Normalize arrays into normal form during simplification"); } +#endif + }; diff --git a/src/front_end_params/theory_bv_params.h b/src/front_end_params/theory_bv_params.h index 6bf5ac868..18a3bac77 100644 --- a/src/front_end_params/theory_bv_params.h +++ b/src/front_end_params/theory_bv_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _THEORY_BV_PARAMS_H_ #define _THEORY_BV_PARAMS_H_ -#include"ini_file.h" - enum bv_solver_id { BS_NO_BV, BS_BLASTER @@ -40,6 +38,7 @@ struct theory_bv_params { m_bv_cc(false), m_bv_blast_max_size(INT_MAX), m_bv_enable_int2bv2int(false) {} +#if 0 void register_params(ini_params & p) { p.register_int_param("bv_solver", 0, 2, reinterpret_cast(m_bv_mode), "0 - no bv, 1 - simple"); p.register_unsigned_param("bv_blast_max_size", m_bv_blast_max_size, "Maximal size for bit-vectors to blast"); @@ -49,6 +48,7 @@ struct theory_bv_params { p.register_bool_param("bv_enable_int2bv_propagation", m_bv_enable_int2bv2int, "enable full (potentially expensive) propagation for int2bv and bv2int"); } +#endif }; #endif /* _THEORY_BV_PARAMS_H_ */ diff --git a/src/front_end_params/theory_datatype_params.h b/src/front_end_params/theory_datatype_params.h index 33b2c1814..8f914ac7b 100644 --- a/src/front_end_params/theory_datatype_params.h +++ b/src/front_end_params/theory_datatype_params.h @@ -19,8 +19,6 @@ Revision History: #ifndef _THEORY_DATATYPE_PARAMS_H_ #define _THEORY_DATATYPE_PARAMS_H_ -#include"ini_file.h" - struct theory_datatype_params { unsigned m_dt_lazy_splits; @@ -28,9 +26,11 @@ struct theory_datatype_params { m_dt_lazy_splits(1) { } +#if 0 void register_params(ini_params & p) { p.register_unsigned_param("dt_lazy_splits", m_dt_lazy_splits, "How lazy datatype splits are performed: 0- eager, 1- lazy for infinite types, 2- lazy"); } +#endif }; diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index 28e699c7c..d89b8d80d 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -472,8 +472,10 @@ static void install_dl_cmds_aux(cmd_context& ctx, dl_collected_cmds* collected_c ctx.insert(alloc(dl_query_cmd, dl_ctx)); ctx.insert(alloc(dl_declare_rel_cmd, dl_ctx)); ctx.insert(alloc(dl_declare_var_cmd, dl_ctx)); - PRIVATE_PARAMS(ctx.insert(alloc(dl_push_cmd, dl_ctx));); // not exposed to keep command-extensions simple. - PRIVATE_PARAMS(ctx.insert(alloc(dl_pop_cmd, dl_ctx));); +#ifndef _EXTERNAL_RELEASE + ctx.insert(alloc(dl_push_cmd, dl_ctx)); // not exposed to keep command-extensions simple. + ctx.insert(alloc(dl_pop_cmd, dl_ctx)); +#endif } void install_dl_cmds(cmd_context & ctx) { diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 3a2844964..631e1266c 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -997,19 +997,19 @@ namespace datalog { p.insert("print_low_level_smt2", CPK_BOOL, "(default false) use (faster) low-level SMT2 printer (the printer is scalable but the result may not be as readable)"); p.insert("print_with_variable_declarations", CPK_BOOL, "(default true) use variable declarations when displaying rules (instead of attempting to use original names)"); - PRIVATE_PARAMS( - p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL, - "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " - "by putting in half of the table columns, if it would have been empty otherwise"); - - p.insert("smt_relation_ground_recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); - ); +#ifndef _EXTERNAL_RELEASE + p.insert("dbg_fpr_nonempty_relation_signature", CPK_BOOL, + "if true, finite_product_relation will attempt to avoid creating inner relation with empty signature " + "by putting in half of the table columns, if it would have been empty otherwise"); + p.insert("smt_relation_ground_recursive", CPK_BOOL, "Ensure recursive relation is ground in union"); + p.insert("inline_linear_branch", CPK_BOOL, "try linear inlining method with potential expansion"); +#endif p.insert("fix_unbound_vars", CPK_BOOL, "fix unbound variables in tail"); p.insert("default_table_checker", CPK_SYMBOL, "see default_table_checked"); p.insert("inline_linear", CPK_BOOL, "(default true) try linear inlining method"); p.insert("inline_eager", CPK_BOOL, "(default true) try eager inlining of rules"); - PRIVATE_PARAMS(p.insert("inline_linear_branch", CPK_BOOL, "try linear inlining method with potential expansion");); + pdr::dl_interface::collect_params(p); bmc::collect_params(p); diff --git a/src/muz_qe/pdr_dl_interface.cpp b/src/muz_qe/pdr_dl_interface.cpp index 6cbc3b78d..cee6cf747 100644 --- a/src/muz_qe/pdr_dl_interface.cpp +++ b/src/muz_qe/pdr_dl_interface.cpp @@ -258,16 +258,18 @@ void dl_interface::collect_params(param_descrs& p) { p.insert("unfold_rules", CPK_UINT, "PDR: (default 0) unfold rules statically using iterative squarring"); p.insert("use_model_generalizer", CPK_BOOL, "PDR: (default false) use model for backwards propagation (instead of symbolic simulation)"); p.insert("validate_result", CPK_BOOL, "PDR (default false) validate result (by proof checking or model checking)"); - PRIVATE_PARAMS(p.insert("use_multicore_generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states");); - PRIVATE_PARAMS(p.insert("use_inductive_generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening");); - PRIVATE_PARAMS(p.insert("use_interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation");); - PRIVATE_PARAMS(p.insert("dump_interpolants", CPK_BOOL, "PDR: (default false) display interpolants");); - PRIVATE_PARAMS(p.insert("cache_mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search");); - PRIVATE_PARAMS(p.insert("inductive_reachability_check", CPK_BOOL, - "PDR: (default false) assume negation of the cube on the previous level when " - "checking for reachability (not only during cube weakening)");); - PRIVATE_PARAMS(p.insert("max_num_contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create");); - PRIVATE_PARAMS(p.insert("try_minimize_core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)");); +#ifndef _EXTERNAL_RELEASE + p.insert("use_multicore_generalizer", CPK_BOOL, "PDR: (default false) extract multiple cores for blocking states"); + p.insert("use_inductive_generalizer", CPK_BOOL, "PDR: (default true) generalize lemmas using induction strengthening"); + p.insert("use_interpolants", CPK_BOOL, "PDR: (default false) use iZ3 interpolation for lemma generation"); + p.insert("dump_interpolants", CPK_BOOL, "PDR: (default false) display interpolants"); + p.insert("cache_mode", CPK_UINT, "PDR: use no (0 - default) symbolic (1) or explicit cache (2) for model search"); + p.insert("inductive_reachability_check", CPK_BOOL, + "PDR: (default false) assume negation of the cube on the previous level when " + "checking for reachability (not only during cube weakening)"); + p.insert("max_num_contexts", CPK_UINT, "PDR: (default 500) maximal number of contexts to create"); + p.insert("try_minimize_core", CPK_BOOL, "PDR: (default false) try to reduce core size (before inductive minimization)"); +#endif p.insert("simplify_formulas_pre", CPK_BOOL, "PDR: (default false) simplify derived formulas before inductive propagation"); p.insert("simplify_formulas_post", CPK_BOOL, "PDR: (default false) simplify derived formulas after inductive propagation"); p.insert("slice", CPK_BOOL, "PDR: (default true) simplify clause set using slicing"); diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index d422db708..4bfe2a545 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -50,10 +50,10 @@ datalog_params::datalog_params(): m_default_table_checked(false) {} -void datalog_params::register_params(ini_params& p) { - p.register_symbol_param("DEFAULT_TABLE", m_default_table, "Datalog engine: default table (sparse)"); - p.register_bool_param("DEFAULT_TABLE_CHECKED", m_default_table_checked, "Wrap default table with a sanity checker"); -} +// void datalog_params::register_params(ini_params& p) { +// p.register_symbol_param("DEFAULT_TABLE", m_default_table, "Datalog engine: default table (sparse)"); +// p.register_bool_param("DEFAULT_TABLE_CHECKED", m_default_table_checked, "Wrap default table with a sanity checker"); +// } static void display_statistics( std::ostream& out, diff --git a/src/shell/datalog_frontend.h b/src/shell/datalog_frontend.h index 898a7fd97..7e08fce0e 100644 --- a/src/shell/datalog_frontend.h +++ b/src/shell/datalog_frontend.h @@ -23,7 +23,7 @@ struct datalog_params { symbol m_default_table; bool m_default_table_checked; datalog_params(); - virtual void register_params(ini_params& p); + // virtual void register_params(ini_params& p); }; unsigned read_datalog(char const * file, datalog_params const& dl_params, front_end_params & front_end_params); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index bc3953c1e..5434206cc 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -109,13 +109,13 @@ public: virtual ~extra_params() {} - virtual void register_params(ini_params & p) { - datalog_params::register_params(p); - p.register_bool_param("STATISTICS", m_statistics, "display statistics"); - } + // PARAM-TODO + // virtual void register_params(ini_params & p) { + // datalog_params::register_params(p); + // p.register_bool_param("STATISTICS", m_statistics, "display statistics"); + // } }; -ini_params* g_params = 0; extra_params* g_extra_params = 0; bool g_params_initialized = false; @@ -123,12 +123,12 @@ void init_params() { if (!g_params_initialized) { z3_bound_num_procs(); g_front_end_params = new front_end_params(); - g_params = new ini_params(); + // g_params = new ini_params(); g_extra_params = new extra_params(); - register_verbosity_level(*g_params); - register_warning(*g_params); - g_front_end_params->register_params(*g_params); - g_extra_params->register_params(*g_params); + // register_verbosity_level(*g_params); + // register_warning(*g_params); + // g_front_end_params->register_params(*g_params); + // g_extra_params->register_params(*g_params); g_params_initialized = true; } } @@ -137,37 +137,11 @@ void del_params() { if (g_front_end_params != NULL) g_front_end_params->close_trace_file(); delete g_extra_params; - delete g_params; delete g_front_end_params; g_extra_params = 0; - g_params = 0; g_front_end_params = 0; } - -void read_ini_file(const char * file_name) { - std::ifstream in(file_name); - if (in.bad() || in.fail()) { - std::cerr << "Error: failed to open init file \"" << file_name << "\".\n"; - exit(ERR_INI_FILE); - } - g_params->read_ini_file(in); -} - -void display_ini_help() { - g_params->display_params(std::cout); -} - -void display_config() { - if (g_front_end_params->m_display_config) { - display_ini_help(); - } -} - -void display_ini_doc() { - g_params->display_params_documentation(std::cout); -} - void parse_cmd_line_args(int argc, char ** argv) { int i = 1; char * eq_pos = 0; @@ -285,10 +259,6 @@ void parse_cmd_line_args(int argc, char ** argv) { gparams::display(std::cout); exit(0); } - else if (strcmp(opt_name, "geninidoc") == 0) { - display_ini_doc(); - exit(0); - } #ifdef _TRACE else if (strcmp(opt_name, "tr") == 0) { if (!opt_arg) @@ -375,11 +345,6 @@ int main(int argc, char ** argv) { memory::set_high_watermark(static_cast(g_front_end_params->m_memory_high_watermark) * 1024 * 1024); memory::set_max_size(static_cast(g_front_end_params->m_memory_max_size) * 1024 * 1024); g_front_end_params->open_trace_file(); - DEBUG_CODE( - if (g_front_end_params->m_copy_params != -1) { - g_front_end_params->copy_params(g_front_end_params->m_copy_params); - TRACE("copy_params", g_params->display_params(tout);); - }); if (g_input_file && g_standard_input) { error("using standard input to read formula."); } diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index c9dcc3fa2..759f5cee2 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -40,7 +40,6 @@ static smtlib::solver* g_solver = 0; static cmd_context * g_cmd_context = 0; static void display_statistics() { - display_config(); clock_t end_time = clock(); if ((g_solver || g_cmd_context) && g_display_statistics) { std::cout.flush(); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 9ab21ccc5..c51a1ebc1 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -3103,7 +3103,6 @@ namespace smt { m_next_progress_sample = 0; TRACE("literal_occ", display_literal_num_occs(tout);); m_timer.start(); - m_instr.start(); } void context::end_search() { @@ -3359,11 +3358,6 @@ namespace smt { return true; } - if (m_instr.is_instruction_maxed(m_fparams.m_instr_out)) { - m_last_search_failure = TIMEOUT; - return true; - } - if (m_progress_callback) { m_progress_callback->fast_progress_sample(); if (m_fparams.m_progress_sampling_freq > 0 && m_timer.ms_timeout(m_next_progress_sample + 1)) { diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index 132718e9a..204a56827 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -47,7 +47,6 @@ Revision History: #include"proto_model.h" #include"model.h" #include"timer.h" -#include"instruction_count.h" #include"statistics.h" #include"progress_callback.h" @@ -77,7 +76,6 @@ namespace smt { setup m_setup; volatile bool m_cancel_flag; timer m_timer; - instruction_count m_instr; asserted_formulas m_asserted_formulas; scoped_ptr m_qmanager; scoped_ptr m_model_generator; diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index bd9196056..67c94808e 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -55,7 +55,6 @@ namespace smt { case CFG_LOGIC: setup_default(); break; case CFG_AUTO: setup_auto_config(); break; } - TRACE("setup", ini_params p; m_params.register_params(p); p.display_params(tout);); } void setup::setup_default() { diff --git a/src/test/ini_file.cpp b/src/test/ini_file.cpp deleted file mode 100644 index d3114c037..000000000 --- a/src/test/ini_file.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - ini_file.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#include -#include"ini_file.h" -#include"debug.h" - -static void tst1() { - ini_params p; - int p1; - p.register_int_param("ipar1", 0, 100, p1); - int p2; - p.register_int_param("ipar2", -100, 100, p2); - bool p3; - p.register_bool_param("bpar1", p3); - bool p4; - p.register_bool_param("bpar2", p4); - unsigned p5; - p.register_unsigned_param("upar1", 0, 100, p5); - double p6; - p.register_percentage_param("ppar1", p6); - std::istringstream in("ipar1 = 100 ipar2=-30 bpar1 = true ;; COMMENT\n bpar2 = false upar1=30 ppar1 = 10"); - p.read_ini_file(in); - SASSERT(p1 == 100); - SASSERT(p2 == -30); - SASSERT(p3); - SASSERT(!p4); - SASSERT(p5 == 30); - SASSERT(p6 == 0.1); -} - -void tst_ini_file() { - tst1(); -} - diff --git a/src/test/main.cpp b/src/test/main.cpp index acbea0761..bee889ea2 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -140,7 +140,6 @@ int main(int argc, char ** argv) { TST(diff_logic); TST(uint_set); TST_ARGV(expr_rand); - TST(ini_file); TST(list); TST(small_object_allocator); TST(timeout); diff --git a/src/util/ini_file.cpp b/src/util/ini_file.cpp deleted file mode 100644 index 48279a2ea..000000000 --- a/src/util/ini_file.cpp +++ /dev/null @@ -1,1564 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - ini_file.cpp - -Abstract: - - Configuration file support. - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#include"ini_file.h" -#include"util.h" -#include"trace.h" -#include"str_hashtable.h" -#include"map.h" -#include"string_buffer.h" -#include"symbol_table.h" -#include"error_codes.h" -#include - -template -class value_vector_map { - void * m_owner; - map *, ptr_hash, ptr_eq > m_mapping; - ptr_vector m_domain; - ptr_vector > m_range; - unsigned m_max_size; -public: - value_vector_map(void * owner):m_owner(owner), m_max_size(0) {} - - ~value_vector_map() { - std::for_each(m_range.begin(), m_range.end(), delete_proc >()); - } - - void insert(T * ptr, T const & value) { - SASSERT(reinterpret_cast(ptr) >= reinterpret_cast(m_owner)); - vector * vect; - if (m_mapping.find(ptr, vect)) { - vect->push_back(value); - if (vect->size() > m_max_size) - m_max_size = vect->size(); - return; - } - vect = alloc(vector); - m_range.push_back(vect); - m_domain.push_back(ptr); - vect->push_back(value); - if (m_max_size == 0) - m_max_size = 1; - m_mapping.insert(ptr, vect); - } - - void copy_params(void * curr_owner, unsigned idx) { - typename ptr_vector::iterator it = m_domain.begin(); - typename ptr_vector::iterator end = m_domain.end(); - for (; it != end; ++it) { - T * ptr = *it; - vector * vect = 0; - m_mapping.find(ptr, vect); - SASSERT(vect != 0); - if (idx < vect->size()) { - // BIG HACK - SASSERT(reinterpret_cast(ptr) >= reinterpret_cast(m_owner)); - size_t offset = reinterpret_cast(ptr) - reinterpret_cast(m_owner); - T * curr_ptr = reinterpret_cast(reinterpret_cast(curr_owner) + offset); - *curr_ptr = vect->operator[](idx); - } - } - } - - unsigned size(void) const { return m_max_size; } -}; - -struct param_vector_imp { - value_vector_map m_bool_params; - value_vector_map m_unsigned_params; - value_vector_map m_int_params; - value_vector_map m_double_params; - value_vector_map m_string_params; - value_vector_map m_symbol_params; - value_vector_map > m_symbol_list_params; - value_vector_map > m_symbol_nat_list_params; - - param_vector_imp(void * owner): - m_bool_params(owner), - m_unsigned_params(owner), - m_int_params(owner), - m_double_params(owner), - m_string_params(owner), - m_symbol_params(owner), - m_symbol_list_params(owner), - m_symbol_nat_list_params(owner) { - } - - void insert_bool_param(bool * value_ptr, bool value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_bool_params.insert(value_ptr, value); - } - - void insert_unsigned_param(unsigned * value_ptr, unsigned value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_unsigned_params.insert(value_ptr, value); - } - - void insert_int_param(int * value_ptr, int value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_int_params.insert(value_ptr, value); - } - - void insert_double_param(double * value_ptr, double value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_double_params.insert(value_ptr, value); - } - - void insert_string_param(std::string * value_ptr, std::string const & value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_string_params.insert(value_ptr, value); - } - - void insert_symbol_param(symbol * value_ptr, symbol const & value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> " << value << "\n";); - m_symbol_params.insert(value_ptr, value); - } - - void insert_symbol_list_param(svector * value_ptr, svector const & value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> "; display(tout, value.begin(), value.end()); tout << "\n";); - m_symbol_list_params.insert(value_ptr, value); - } - - void insert_symbol_nat_list_param(svector * value_ptr, svector const & value) { - TRACE("param_vector", tout << "insert: " << value_ptr << " -> "; display(tout, value.begin(), value.end()); tout << "\n";); - m_symbol_nat_list_params.insert(value_ptr, value); - } - - void copy_params(void * curr_owner, unsigned idx) { - m_bool_params.copy_params(curr_owner, idx); - m_unsigned_params.copy_params(curr_owner, idx); - m_int_params.copy_params(curr_owner, idx); - m_double_params.copy_params(curr_owner, idx); - m_string_params.copy_params(curr_owner, idx); - m_symbol_params.copy_params(curr_owner, idx); - m_symbol_list_params.copy_params(curr_owner, idx); - m_symbol_nat_list_params.copy_params(curr_owner, idx); - } - - unsigned size(void) const { - unsigned ret = 0; - ret = std::max(ret, m_bool_params.size()); - ret = std::max(ret, m_unsigned_params.size()); - ret = std::max(ret, m_int_params.size()); - ret = std::max(ret, m_double_params.size()); - ret = std::max(ret, m_string_params.size()); - ret = std::max(ret, m_symbol_params.size()); - ret = std::max(ret, m_symbol_list_params.size()); - ret = std::max(ret, m_symbol_nat_list_params.size()); - return ret; - } -}; - - -param_vector::param_vector(void * owner): - m_ref_count(0) { - m_imp = alloc(param_vector_imp, owner); -} - -param_vector::~param_vector() { - dealloc(m_imp); -} - -void param_vector::inc_ref() { - m_ref_count++; -} - -void param_vector::dec_ref() { - SASSERT(m_ref_count > 0); - m_ref_count--; - if (m_ref_count == 0) - dealloc(this); -} - -void param_vector::copy_params(void * curr_owner, unsigned idx) { - m_imp->copy_params(curr_owner, idx); -} - -unsigned param_vector::size(void) const -{ - return m_imp->size(); -} - -enum itoken { - ITK_NULL, ITK_ID, ITK_NUM, ITK_DOUBLE, ITK_STRING, ITK_BAD_STRING, ITK_TRUE, ITK_FALSE, ITK_COMMA, ITK_LP, ITK_RP, ITK_LCB, ITK_RCB, ITK_CLN, ITK_EQ, ITK_BAD_ID, ITK_EOS, ITK_LAST -}; - -class ini_reserved_symbols { - typedef map str2token; - str2token m_str2token; - -public: - ini_reserved_symbols() { - m_str2token.insert("true", ITK_TRUE); - m_str2token.insert("false", ITK_FALSE); - } - - itoken string2itoken(char const * str) { - str2token::entry * e = m_str2token.find_core(const_cast(str)); - if (e) - return e->get_data().m_value; - else - return ITK_ID; - } -}; - -static char const * g_itoken2string[] = { - "", - "", - "", - "", - "", - "", - "true", - "false", - ",", - "(", - ")", - "{", - "}", - ":", - "=", - "", - "" -}; - -COMPILE_TIME_ASSERT(sizeof(g_itoken2string)/sizeof(char const*) == ITK_LAST); - -inline static const char * itoken2string(itoken t) { - return g_itoken2string[t]; -} - -inline itoken string2itoken(ini_reserved_symbols& reserved, char const * str) { - itoken r = reserved.string2itoken(str); - TRACE("token", tout << str << " -> " << itoken2string(r) << "\n";); - return r; -} - -class ini_lexer { - std::istream & m_input; - char m_curr_char; - int m_line; - int m_pos; - int m_tok_pos; - string_buffer<> m_buffer; - ini_reserved_symbols m_ini_reserved; -public: - bool eos() const { - return m_curr_char == EOF; - } - - void next() { - m_curr_char = m_input.get(); - m_pos++; - } - - void save_and_next() { - m_buffer << m_curr_char; - next(); - } - - ini_lexer(std::istream & input): - m_input(input), - m_line(1), - m_pos(0), - m_tok_pos(0), - m_ini_reserved() { - next(); - } - - itoken read_num() { - while (isdigit(m_curr_char)) { - save_and_next(); - } - if (m_curr_char == '.') { - save_and_next(); - while (isdigit(m_curr_char)) { - save_and_next(); - } - if (m_curr_char == 'e' || m_curr_char == 'E' || m_curr_char == 'd' || m_curr_char == 'D') { - save_and_next(); - if (m_curr_char == '-') { - save_and_next(); - } - while (isdigit(m_curr_char)) { - save_and_next(); - } - } - return ITK_DOUBLE; - } - return ITK_NUM; - } - - itoken read_id() { - while (!eos() && (isalpha(m_curr_char) || isdigit(m_curr_char) || m_curr_char == '_')) { - save_and_next(); - } - return string2itoken(m_ini_reserved, m_buffer.c_str()); - } - - itoken read_string() { - m_tok_pos = m_pos; - next(); - while (m_curr_char != '"' && m_curr_char != '\'') { - if (m_input.eof()) { - return ITK_BAD_STRING; - } - if (m_curr_char == '\n') { - return ITK_BAD_STRING; - } - if (m_curr_char == '\\') { - next(); // do not save the '\' - switch (m_curr_char) { - case 't': - m_buffer << '\t'; - next(); - break; - case 'n': - m_buffer << '\n'; - next(); - break; - case '\n': - m_buffer << '\n'; - next(); - break; - default: - if (!isdigit(m_curr_char)) { - save_and_next(); /* handles \\, \", \', and \? */ - } - else { /* \xxx */ - int c = 0; - int i = 0; - do { - c = 10*c + (m_curr_char-'0'); - next(); - } - while (++i<3 && isdigit(m_curr_char)); - if (c > UCHAR_MAX) { - return ITK_BAD_STRING; - } - m_buffer << static_cast(c); - } - } - } - else { - save_and_next(); - } - } - next(); - return ITK_STRING; - } - - itoken next_token() { - for(;;) { - if (eos()) { - return ITK_EOS; - } - - m_buffer.reset(); - switch (m_curr_char) { - case ';': // comment - while (m_curr_char != '\n' && !eos()) { - next(); - } - break; - case '\n': - next(); - m_line++; - break; - case '=': - m_tok_pos = m_pos; - next(); - return ITK_EQ; - case '\'': - case '\"': - return read_string(); - case '{': - m_tok_pos = m_pos; - next(); - return ITK_LCB; - case '}': - m_tok_pos = m_pos; - next(); - return ITK_RCB; - case '(': - m_tok_pos = m_pos; - next(); - return ITK_LP; - case ')': - m_tok_pos = m_pos; - next(); - return ITK_RP; - case ',': - m_tok_pos = m_pos; - next(); - return ITK_COMMA; - case ':': - m_tok_pos = m_pos; - next(); - return ITK_CLN; - default: - if (isspace(m_curr_char)) { - next(); - break; - } - else if (isdigit(m_curr_char)) { - m_tok_pos = m_pos; - save_and_next(); - return read_num(); - } - else { - char old = m_curr_char; - m_tok_pos = m_pos; - save_and_next(); - TRACE("ini_lexer", tout << "old: " << static_cast(old) << " " << old << "\n";); - if (old == '-' && isdigit(m_curr_char)) { - return read_num(); - } - else if (old == '_' || isalpha(old)) { - return read_id(); - } - else { - return ITK_BAD_ID; - } - } - } - } - } - - char const * get_token_data() const { - return m_buffer.c_str(); - } - - unsigned get_token_pos() const { - return m_tok_pos; - } -}; - - -enum ini_param_kind { - IPK_BOOL, - IPK_INT, - IPK_UNSIGNED, - IPK_DOUBLE, - IPK_PERCENTAGE, - IPK_STRING, - IPK_SYMBOL, - IPK_SYMBOL_LIST, - IPK_SYMBOL_NAT_LIST -}; - - -struct ini_param_info { - ini_param_kind m_kind; - bool m_is_mutable; - - char const * m_description; - union { - struct { - int m_int_min; - int m_int_max; - int * m_int_val; - }; - struct { - unsigned m_uint_min; - unsigned m_uint_max; - unsigned * m_uint_val; - }; - bool * m_bool_val; - double * m_double_val; - double * m_perc_val; - symbol * m_sym_val; - std::string * m_str_val; - svector * m_sym_list_val; - svector * m_sym_nat_list_val; - }; - - ini_param_info(char const * descr = 0): - m_kind(IPK_BOOL), - m_is_mutable(false), - m_description(descr), - m_bool_val(0) { - } - - ini_param_info(int min, int max, int * val, char const * descr, bool is_mutable): - m_kind(IPK_INT), - m_is_mutable(is_mutable), - m_description(descr), - m_int_min(min), - m_int_max(max), - m_int_val(val) { - } - - ini_param_info(unsigned min, unsigned max, unsigned * val, char const * descr, bool is_mutable): - m_kind(IPK_UNSIGNED), - m_is_mutable(is_mutable), - m_description(descr), - m_uint_min(min), - m_uint_max(max), - m_uint_val(val) { - } - - ini_param_info(bool * val, char const * descr, bool is_mutable): - m_kind(IPK_BOOL), - m_is_mutable(is_mutable), - m_description(descr), - m_bool_val(val) { - } - - ini_param_info(bool perc, double * val, char const * descr, bool is_mutable): - m_kind(perc ? IPK_PERCENTAGE : IPK_DOUBLE), - m_is_mutable(is_mutable), - m_description(descr), - m_perc_val(val) { - } - - ini_param_info(svector * val, char const * descr, bool is_mutable): - m_kind(IPK_SYMBOL_LIST), - m_is_mutable(is_mutable), - m_description(descr), - m_sym_list_val(val) { - } - - ini_param_info(svector * val, char const * descr, bool is_mutable): - m_kind(IPK_SYMBOL_NAT_LIST), - m_is_mutable(is_mutable), - m_description(descr), - m_sym_nat_list_val(val) { - } - - ini_param_info(symbol * s, char const * descr, bool is_mutable): - m_kind(IPK_SYMBOL), - m_is_mutable(is_mutable), - m_description(descr), - m_sym_val(s) { - } - - ini_param_info(std::string * str, char const * descr, bool is_mutable): - m_kind(IPK_STRING), - m_is_mutable(is_mutable), - m_description(descr), - m_str_val(str) { - } - -}; - -struct ini_params_imp { - bool m_abort_on_error; - ini_reserved_symbols m_ini_reserved; - ref m_param_vector; - symbol_table m_param_info; - bool m_is_frozen; - - ini_params_imp(bool abort_on_error): m_abort_on_error(abort_on_error), m_is_frozen(false) {} - - void freeze(bool f) { m_is_frozen = f; } - - void register_param_vector(param_vector * pv) { - m_param_vector = pv; - } - - void register_bool_param(symbol param_name, bool & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - void register_unsigned_param(symbol param_name, unsigned min, unsigned max, unsigned & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(min, max, &value, descr, is_mutable)); - } - - void register_int_param(symbol param_name, int min, int max, int & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(min, max, &value, descr, is_mutable)); - } - - void register_percentage_param(symbol param_name, double & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(true, &value, descr, is_mutable)); - } - - void register_double_param(symbol param_name, double & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(false, &value, descr, is_mutable)); - } - - void register_string_param(symbol param_name, std::string & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - void register_symbol_param(symbol param_name, symbol & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - void register_symbol_list_param(symbol param_name, svector & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - void register_symbol_nat_list_param(symbol param_name, svector & value, char const * descr, bool is_mutable) { - SASSERT(!m_param_info.contains(param_name)); - m_param_info.insert(param_name, ini_param_info(&value, descr, is_mutable)); - } - - struct symbol_lt_proc { - bool operator()(const symbol & s1, const symbol & s2) const { - return strcmp(s1.bare_str(), s2.bare_str()) < 0; - } - }; - - void display_param_help(char const* param_id, std::ostream& out) const { - ini_param_info info; - if (m_param_info.find(symbol(param_id), info)) { - display_param_info(out, info); - } - else { - out << "option " << param_id << " does not exist"; - } - } - - void display_param_info(std::ostream& out, ini_param_info& info) const { - switch (info.m_kind) { - case IPK_BOOL: - out << " boolean"; - out << ", default: " << (*info.m_bool_val ? "true" : "false"); - break; - case IPK_INT: - out << " integer"; - if (info.m_int_min > INT_MIN) { - out << ", min: " << info.m_int_min; - } - if (info.m_int_max < INT_MAX) { - out << ", max: " << info.m_int_max; - } - out << ", default: " << *info.m_int_val; - break; - case IPK_UNSIGNED: - out << " unsigned integer"; - if (info.m_uint_min > 0) { - out << ", min: " << info.m_uint_min; - } - if (info.m_uint_max < INT_MAX) { - out << ", max: " << info.m_uint_max; - } - out << ", default: " << *info.m_uint_val; - break; - case IPK_DOUBLE: - out << " double"; - out << ", default: " << *info.m_double_val; - break; - case IPK_PERCENTAGE: - out << " percentage"; - out << ", default: " << *info.m_perc_val; - break; - case IPK_SYMBOL: - out << " symbol"; - out << ", default: " << *info.m_sym_val; - break; - case IPK_STRING: - out << " string"; - out << ", default: " << *info.m_str_val; - break; - case IPK_SYMBOL_LIST: - out << " list of symbols (strings)"; - break; - case IPK_SYMBOL_NAT_LIST: - out << " list of pairs: symbols(strings) x unsigned"; - break; - } - if (info.m_description) { - out << ", " << info.m_description << "."; - } - out << "\n"; - } - - void display_params(std::ostream & out) const { - svector params; - m_param_info.get_dom(params); - std::sort(params.begin(), params.end(), symbol_lt_proc()); - svector::iterator it = params.begin(); - svector::iterator end = params.end(); - for (; it != end; ++it) { - out << *it << ":"; - ini_param_info info; - m_param_info.find(*it, info); - display_param_info(out, info); - } - } - - void display_params_documentation(std::ostream & out) const { - out << "// AUTOMATICALLY GENERATED FILE - DO NOT EDIT\n\n" - << "/**\n" - << " \\page config INI parameters\n\n"; - svector params; - m_param_info.get_dom(params); - std::sort(params.begin(), params.end(), symbol_lt_proc()); - svector::iterator it = params.begin(); - svector::iterator end = params.end(); - for (; it != end; ++it) { - out << "- \\c " << *it << ":"; - ini_param_info info; - m_param_info.find(*it, info); - switch (info.m_kind) { - case IPK_BOOL: - out << " \\em boolean"; - out << ", default: " << (*info.m_bool_val ? "\\c true" : "\\c false"); - break; - case IPK_INT: - out << " \\em integer"; - if (info.m_int_min > INT_MIN) { - out << ", min: \\c " << info.m_int_min; - } - if (info.m_int_max < INT_MAX) { - out << ", max: \\c " << info.m_int_max; - } - out << ", default: \\c " << *info.m_int_val; - break; - case IPK_UNSIGNED: - out << " \\em unsigned \\em integer"; - if (info.m_uint_min > 0) { - out << ", min: \\c " << info.m_uint_min; - } - if (info.m_uint_max < INT_MAX) { - out << ", max: \\c " << info.m_uint_max; - } - out << ", default: \\c " << *info.m_uint_val; - break; - case IPK_DOUBLE: - out << " \\em double"; - out << ", default: \\c " << *info.m_double_val; - break; - case IPK_PERCENTAGE: - out << " \\em percentage"; - out << ", default: \\c " << *info.m_perc_val; - break; - case IPK_STRING: - out << " \\em string"; - out << ", default: " << *info.m_str_val; - break; - case IPK_SYMBOL: - out << " \\em symbol"; - out << ", default: " << *info.m_sym_val; - break; - case IPK_SYMBOL_LIST: - out << " \\em list \\em of \\em symbols \\em (strings)"; - break; - case IPK_SYMBOL_NAT_LIST: - out << " \\em list \\em of \\em pairs: \\em symbols(strings) \\em x \\em unsigned"; - break; - } - if (info.m_description) { - out << ", " << info.m_description << "."; - } - out << "\n\n"; - } - out << "*/\n"; - } - - void error(char const * param_id, char const * msg) { - if (m_abort_on_error) { - verbose_stream() << "Error setting '" << param_id << "', reason: " << msg << "\n"; - throw z3_error(ERR_INI_FILE); - } - else { - throw set_get_param_exception(param_id, msg); - } - } - - symbol trim(char const * param_id) { - string_buffer<> m_buffer; - while (*param_id != 0 && !isspace(*param_id)) { - m_buffer.append(*param_id); - param_id++; - } - return symbol(m_buffer.c_str()); - } - - void set_param_value(char const * param_id, char const * param_value) { - TRACE("param_value", tout << param_id << " " << param_value << "\n";); - if (param_value == 0) { - error(param_id, "invalid (null) option"); - } - symbol s(param_id); - ini_param_info info; - if (!m_param_info.find(s, info)) { - s = trim(param_id); - if (!m_param_info.find(s, info)) - error(param_id, "unknown option."); - } - if (!info.m_is_mutable && m_is_frozen) { - error(param_id, "option value cannot be modified after initialization"); - } - switch (info.m_kind) { - case IPK_BOOL: - parse_bool_param(param_id, info, param_value); - break; - case IPK_INT: - parse_int_param(param_id, info, param_value); - break; - case IPK_UNSIGNED: - parse_uint_param(param_id, info, param_value); - break; - case IPK_DOUBLE: - parse_double_param(param_id, info, param_value); - break; - case IPK_PERCENTAGE: - parse_perc_param(param_id, info, param_value); - break; - case IPK_STRING: - parse_string_param(param_id, info, param_value); - break; - case IPK_SYMBOL: - // TODO: not used so far - *info.m_sym_val = param_value; - break; - case IPK_SYMBOL_LIST: - error(param_id, "this option can only be set in an INI file"); - break; - case IPK_SYMBOL_NAT_LIST: - error(param_id, "this option can only be set in an INI file"); - break; - default: - UNREACHABLE(); - } - } - - - bool get_param_value(char const * param_id, std::string& param_value) { - TRACE("param_value", tout << param_id << "\n";); - std::ostringstream buffer; - symbol s(param_id); - ini_param_info info; - if (!m_param_info.find(s, info)) { - s = trim(param_id); - if (!m_param_info.find(s, info)) { - return false; - } - } - switch (info.m_kind) { - case IPK_BOOL: - buffer << ((*info.m_bool_val)?"true":"false"); - break; - case IPK_INT: - buffer << (*info.m_int_val); - break; - case IPK_UNSIGNED: - buffer << (*info.m_uint_val); - break; - case IPK_DOUBLE: - buffer << (*info.m_double_val); - break; - case IPK_PERCENTAGE: - buffer << (*info.m_perc_val); - break; - case IPK_STRING: - buffer << (*info.m_str_val); - break; - case IPK_SYMBOL: - buffer << (info.m_sym_val->str()); - break; - case IPK_SYMBOL_LIST: - error(param_id, "this option cannot be retrieved"); - break; - case IPK_SYMBOL_NAT_LIST: - error(param_id, "this option cannot be retrieved"); - break; - default: - UNREACHABLE(); - } - param_value = buffer.str(); - return true; - } - - string_buffer<> m_buffer; - - char const * get_token_data() const { - return m_buffer.c_str(); - } - - void save_and_next(char const * & in) { - m_buffer.append(*in); - ++in; - } - - itoken read_num(char const * & in) { - while (isdigit(*in)) { - save_and_next(in); - } - TRACE("read_num", tout << "1. read_num: " << m_buffer.c_str() << ", *in: " << *in << "\n";); - if (*in == '.') { - save_and_next(in); - while (isdigit(*in)) { - save_and_next(in); - } - TRACE("read_num", tout << "2. read_num: " << m_buffer.c_str() << ", *in: " << *in << "\n";); - if (*in == 'e' || *in == 'E' || *in == 'd' || *in == 'D') { - save_and_next(in); - if (*in == '-') { - save_and_next(in); - } - while (isdigit(*in)) { - save_and_next(in); - } - } - return ITK_DOUBLE; - } - return ITK_NUM; - } - - itoken read_id(char const * & in) { - while (!*in == 0 && (isalpha(*in) || isdigit(*in) || *in == '_')) { - save_and_next(in); - } - return string2itoken(m_ini_reserved, m_buffer.c_str()); - } - - itoken read_string(char const * & in) { - ++in; - while (*in != '"' && *in != '\'') { - TRACE("read_string", tout << *in << "\n";); - if (*in == 0) - return ITK_BAD_STRING; - if (*in == '\n') - return ITK_BAD_STRING; - if (*in == '\\') { - ++in; - switch (*in) { - case 't': - m_buffer << '\t'; - ++in; - break; - case 'n': - m_buffer << '\n'; - ++in; - break; - case '\n': - m_buffer << '\n'; - ++in; - break; - default: - if (!isdigit(*in)) { - save_and_next(in); /* handles \\, \", \', and \? */ - } - else { /* \xxx */ - int c = 0; - int i = 0; - do { - c = 10*c + (*in-'0'); - ++in; - } - while (++i<3 && isdigit(*in)); - if (c > UCHAR_MAX) - return ITK_BAD_STRING; - m_buffer << static_cast(c); - } - } - } - else { - save_and_next(in); - } - } - ++in; - return ITK_STRING; - } - - itoken next_token(char const * & in) { - for(;;) { - if (*in == 0) - return ITK_EOS; - m_buffer.reset(); - switch (*in) { - case '{': - in++; - return ITK_LCB; - case '}': - in++; - return ITK_RCB; - case ',': - in++; - return ITK_COMMA; - case '"': - case '\'': - TRACE("read_string", tout << "found \"\n";); - return read_string(in); - default: - if (isspace(*in)) { - in++; - break; - } - else if (isdigit(*in)) { - TRACE("read_num", tout << "found is_digit\n";); - return read_num(in); - } - else { - char old = *in; - save_and_next(in); - if (old == '-' && isdigit(*in)) { - return read_num(in); - } - else if (old == '_' || isalpha(old)) { - return read_id(in); - } - else { - return ITK_BAD_ID; - } - } - } - } - } - - bool end_of_list(char const * param_id, char const * & param_value) { - switch (next_token(param_value)) { - case ITK_COMMA: - return false; - case ITK_RCB: - return true; - default: - error(param_id, "boolean value (true/false) expected"); - } - return false; - } - - void parse_bool_param(char const * param_id, ini_param_info & info, char const * param_value) { - switch (next_token(param_value)) { - case ITK_TRUE: - *info.m_bool_val = true; - break; - case ITK_FALSE: - *info.m_bool_val = false; - break; - default: - error(param_id, "boolean value (true/false) expected"); - } - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - switch (next_token(param_value)) { - case ITK_TRUE: - m_param_vector->m_imp->insert_bool_param(info.m_bool_val, true); - break; - case ITK_FALSE: - m_param_vector->m_imp->insert_bool_param(info.m_bool_val, false); - break; - default: - error(param_id, "boolean value (true/false) expected"); - } - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_int_param(char const * param_id, ini_param_info & info, char const * param_value) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < info.m_int_min || val > info.m_int_max) - error(param_id, "integer out of bounds"); - *info.m_int_val = val; - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < info.m_int_min || val > info.m_int_max) - error(param_id, "integer out of bounds"); - m_param_vector->m_imp->insert_int_param(info.m_int_val, val); - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_uint_param(char const * param_id, ini_param_info & info, char const * param_value) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - unsigned val = static_cast(strtol(get_token_data(), 0, 10)); - - if (val < info.m_uint_min || val > info.m_uint_max) - error(param_id, "unsigned out of bounds"); - *info.m_uint_val = val; - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - unsigned val = static_cast(strtol(get_token_data(), 0, 10)); - if (val < info.m_uint_min || val > info.m_uint_max) - error(param_id, "unsigned out of bounds"); - m_param_vector->m_imp->insert_unsigned_param(info.m_uint_val, val); - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_double_param(char const * param_id, ini_param_info & info, char const * param_value) { - itoken k = next_token(param_value); - if (k != ITK_NUM && k != ITK_DOUBLE) - error(param_id, "float expected"); - char * aux; - *info.m_double_val = strtod(get_token_data(), &aux); - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - k = next_token(param_value); - if (k != ITK_NUM && k != ITK_DOUBLE) - error(param_id, "float expected"); - m_param_vector->m_imp->insert_double_param(info.m_double_val, strtod(get_token_data(), &aux)); - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_perc_param(char const * param_id, ini_param_info & info, char const * param_value) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < 0 || val > 100) - error(param_id, "integer between 0 and 100 expected"); - *info.m_perc_val = static_cast(val)/100.0; - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - if (next_token(param_value) != ITK_NUM) - error(param_id, "integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < 0 || val > 100) - error(param_id, "integer between 0 and 100 expected"); - m_param_vector->m_imp->insert_double_param(info.m_perc_val, static_cast(val)/100.0); - if (end_of_list(param_id, param_value)) - return; - } - } - } - - void parse_string_param(char const * param_id, ini_param_info & info, char const * param_value) { - if (next_token(param_value) != ITK_STRING) - error(param_id, "string expected"); - *info.m_str_val = get_token_data(); - if (m_param_vector.get() && next_token(param_value) == ITK_LCB) { - for (;;) { - if (next_token(param_value) != ITK_STRING) - error(param_id, "string expected"); - m_param_vector->m_imp->insert_string_param(info.m_str_val, get_token_data()); - if (end_of_list(param_id, param_value)) - return; - } - } - } -}; - -class ini_parser { - ini_lexer m_lexer; - ini_params_imp * m_params; - itoken m_curr_token; - - void error(unsigned pos, char const * msg) { - if (m_params->m_abort_on_error) { - verbose_stream() << "Error INI file [position: " << pos << "]: " << msg << "\n"; - throw z3_error(ERR_INI_FILE); - } - else { - throw ini_parser_exception(pos, msg); - } - } - - void error(char const * msg) { - error(m_lexer.get_token_pos(), msg); - } - - itoken get_curr_token() { - if (m_curr_token == ITK_NULL) { - m_curr_token = m_lexer.next_token(); - } - SASSERT(m_curr_token != ITK_NULL); - return m_curr_token; - } - - void next() { - if (m_curr_token == ITK_NULL) { - m_lexer.next_token(); - } - else { - m_curr_token = ITK_NULL; - } - } - - char const * get_token_data() { - if (m_curr_token == ITK_NULL) { - get_curr_token(); - } - SASSERT(m_curr_token != ITK_NULL); - return m_lexer.get_token_data(); - } - - bool test_next(itoken expected) { - if (get_curr_token() == expected) { - next(); - return true; - } - else { - return false; - } - } - - void check(itoken expected) { - if (!test_next(expected)) { - string_buffer<> msg; - msg << "unexpected token '" << itoken2string(get_curr_token()) - << "', '" << itoken2string(expected) << "' expected."; - error(msg.c_str()); - } - } - -public: - ini_parser(std::istream & in, ini_params_imp * p): - m_lexer(in), - m_params(p), - m_curr_token(ITK_NULL) { - } - - void parse_param() { - symbol s(get_token_data()); - check(ITK_ID); - ini_param_info info; - if (!m_params->m_param_info.find(s, info)) { - error("unknown option."); - } - check(ITK_EQ); - switch (info.m_kind) { - case IPK_BOOL: - parse_bool_param(info); - break; - case IPK_INT: - parse_int_param(info); - break; - case IPK_UNSIGNED: - parse_uint_param(info); - break; - case IPK_DOUBLE: - parse_double_param(info); - break; - case IPK_PERCENTAGE: - parse_perc_param(info); - break; - case IPK_STRING: - parse_string_param(info); - break; - case IPK_SYMBOL: - // TODO: add support for VAL{VAL,...,VAL} - *info.m_sym_val = get_token_data(); - check(ITK_STRING); - break; - case IPK_SYMBOL_NAT_LIST: - parse_symbol_nat_list(info); - break; - case IPK_SYMBOL_LIST: - parse_symbol_list(info); - break; - default: - UNREACHABLE(); - } - } - - bool end_of_list() { - switch (get_curr_token()) { - case ITK_COMMA: - next(); - return false; - case ITK_RCB: - next(); - return true; - default: - error("boolean value expected"); - } - return false; - } - - void parse_bool_param(ini_param_info & info) { - if (get_curr_token() != ITK_TRUE && get_curr_token() != ITK_FALSE) - error("boolean value expected"); - *info.m_bool_val = get_curr_token() == ITK_TRUE; - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_TRUE && get_curr_token() != ITK_FALSE) - error("boolean value expected"); - m_params->m_param_vector->m_imp->insert_bool_param(info.m_bool_val, get_curr_token() == ITK_TRUE); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_int_param(ini_param_info & info) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < info.m_int_min || val > info.m_int_max) - error("integer out of bounds"); - *info.m_int_val = val; - next(); - TRACE("int_param", tout << "val: " << val << "\n";); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < info.m_int_min || val > info.m_int_max) - error("integer out of bounds"); - m_params->m_param_vector->m_imp->insert_int_param(info.m_int_val, val); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_uint_param(ini_param_info & info) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - long val = strtol(get_token_data(), 0, 10); - if (val < static_cast(info.m_uint_min) || val > static_cast(info.m_uint_max)) - error("integer out of bounds"); - *info.m_uint_val = val; - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - long val = strtol(get_token_data(), 0, 10); - if (val < static_cast(info.m_uint_min) || val > static_cast(info.m_uint_max)) - error("integer out of bounds"); - m_params->m_param_vector->m_imp->insert_unsigned_param(info.m_uint_val, val); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_double_param(ini_param_info & info) { - if (get_curr_token() != ITK_NUM && get_curr_token() != ITK_DOUBLE) - error("float expected"); - char * aux; - *info.m_double_val = strtod(get_token_data(), &aux); - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_NUM && get_curr_token() != ITK_DOUBLE) - error("float expected"); - m_params->m_param_vector->m_imp->insert_double_param(info.m_double_val, strtod(get_token_data(), &aux)); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_perc_param(ini_param_info & info) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < 0 || val > 100) - error("integer between 0 and 100 expected"); - *info.m_perc_val = static_cast(val)/100.0; - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_NUM) - error("integer expected"); - int val = strtol(get_token_data(), 0, 10); - if (val < 0 || val > 100) - error("integer between 0 and 100 expected"); - m_params->m_param_vector->m_imp->insert_double_param(info.m_perc_val, static_cast(val)/100.0); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_string_param(ini_param_info & info) { - if (get_curr_token() != ITK_STRING) - error("string expected"); - *info.m_str_val = get_token_data(); - next(); - if (m_params->m_param_vector.get() && get_curr_token() == ITK_LCB) { - next(); - for (;;) { - if (get_curr_token() != ITK_STRING) - error("string expected"); - m_params->m_param_vector->m_imp->insert_string_param(info.m_str_val, get_token_data()); - next(); - if (end_of_list()) - return; - } - } - } - - void parse_s_list(svector & result) { - check(ITK_LP); - for (;;) { - symbol s(get_token_data()); - result.push_back(s); - check(ITK_ID); - if (!test_next(ITK_COMMA)) { - check(ITK_RP); - return; - } - } - } - - void parse_symbol_list(ini_param_info & info) { - parse_s_list(*(info.m_sym_list_val)); - if (m_params->m_param_vector.get() && test_next(ITK_LCB)) { - for (;;) { - svector lst; - parse_s_list(lst); - m_params->m_param_vector->m_imp->insert_symbol_list_param(info.m_sym_list_val, lst); - if (!test_next(ITK_COMMA)) { - check(ITK_RCB); - return; - } - } - } - } - - void parse_sn_list(svector & result) { - check(ITK_LP); - for (;;) { - symbol s(get_token_data()); - check(ITK_ID); - check(ITK_CLN); - unsigned val = strtol(get_token_data(), 0, 10); - check(ITK_NUM); - result.push_back(std::make_pair(s, val)); - if (!test_next(ITK_COMMA)) { - check(ITK_RP); - return; - } - } - } - - void parse_symbol_nat_list(ini_param_info & info) { - parse_sn_list(*(info.m_sym_nat_list_val)); - if (m_params->m_param_vector.get() && test_next(ITK_LCB)) { - for (;;) { - svector lst; - parse_sn_list(lst); - m_params->m_param_vector->m_imp->insert_symbol_nat_list_param(info.m_sym_nat_list_val, lst); - if (!test_next(ITK_COMMA)) { - check(ITK_RCB); - return; - } - } - } - } - - void parse() { - while (get_curr_token() != ITK_EOS) { - parse_param(); - } - } -}; - -ini_params::ini_params(bool abort_on_error) { - m_imp = alloc(ini_params_imp, abort_on_error); -} - -ini_params::~ini_params() { - dealloc(m_imp); -} - -void ini_params::register_bool_param(char const * param_name, bool & value, char const * descr, bool is_mutable) { - m_imp->register_bool_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_unsigned_param(char const * param_name, unsigned min, unsigned max, unsigned & value, char const * descr, bool is_mutable) { - m_imp->register_unsigned_param(symbol(param_name), min, max, value, descr, is_mutable); -} - -void ini_params::register_int_param(char const * param_name, int min, int max, int & value, char const * descr, bool is_mutable) { - m_imp->register_int_param(symbol(param_name), min, max, value, descr, is_mutable); -} - -void ini_params::register_double_param(char const * param_name, double & value, char const * descr, bool is_mutable) { - m_imp->register_double_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_percentage_param(char const * param_name, double & value, char const * descr, bool is_mutable) { - m_imp->register_percentage_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_string_param(char const * param_name, std::string & value, char const * descr, bool is_mutable) { - m_imp->register_string_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_symbol_param(char const * param_name, symbol & value, char const * descr, bool is_mutable) { - m_imp->register_symbol_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_symbol_list_param(char const * param_name, svector & value, char const * descr, bool is_mutable) { - m_imp->register_symbol_list_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_symbol_nat_list_param(char const * param_name, svector & value, char const * descr, bool is_mutable) { - m_imp->register_symbol_nat_list_param(symbol(param_name), value, descr, is_mutable); -} - -void ini_params::register_param_vector(param_vector * pv) { - m_imp->register_param_vector(pv); -} - -void ini_params::read_ini_file(std::istream & in) { - ini_parser p(in, m_imp); - p.parse(); -} - -void ini_params::display_params(std::ostream & out) const { - m_imp->display_params(out); -} - -void ini_params::display_parameter_help(char const* param_id, std::ostream & out) const { - m_imp->display_param_help(param_id, out); -} - -void ini_params::display_params_documentation(std::ostream & out) const { - m_imp->display_params_documentation(out); -} - -void ini_params::set_param_value(char const * param_id, char const * param_value) { - m_imp->set_param_value(param_id, param_value); -} -bool ini_params::get_param_value(char const * param_id, std::string& param_value) { - return m_imp->get_param_value(param_id, param_value); -} - -void ini_params::freeze(bool f) { - m_imp->freeze(f); -} - - - diff --git a/src/util/ini_file.h b/src/util/ini_file.h deleted file mode 100644 index cb884b916..000000000 --- a/src/util/ini_file.h +++ /dev/null @@ -1,117 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - ini_file.h - -Abstract: - - Configuration file support. - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#ifndef _INI_FILE_H_ -#define _INI_FILE_H_ - -#include -#include -#include - -#include"symbol.h" -#include"vector.h" -#include"ref.h" - -#ifdef _EXTERNAL_RELEASE -#define PRIVATE_PARAMS(CODE) ((void) 0) -#else -#define PRIVATE_PARAMS(CODE) { CODE } -#endif - -struct param_vector_imp; -struct ini_params_imp; -class ini_parser; - -typedef std::pair symbol_nat_pair; - -inline std::ostream & operator<<(std::ostream & out, symbol_nat_pair const & p) { - out << p.first << ":" << p.second; - return out; -} - -/** - \brief Support for multiple values for a parameter. The values are used to configure - different cores. -*/ -class param_vector { - unsigned m_ref_count; - param_vector_imp * m_imp; - friend struct ini_params_imp; - friend class ini_parser; -public: - // TODO: onwer is a big hack - param_vector(void * owner); - ~param_vector(); - void inc_ref(); - void dec_ref(); - void copy_params(void * curr_owner, unsigned idx); - unsigned size(void) const; -}; - -class set_get_param_exception { - std::string m_id; - std::string m_msg; -public: - set_get_param_exception(char const * id, char const * msg):m_id(id), m_msg(msg) {} - char const * get_param_id() const { return m_id.c_str(); } - char const * get_msg() const { return m_msg.c_str(); } -}; - -class ini_parser_exception { - unsigned m_pos; - std::string m_msg; -public: - ini_parser_exception(unsigned pos, char const * msg):m_pos(pos), m_msg(msg) {} - unsigned get_pos() const { return m_pos; } - char const * get_msg() const { return m_msg.c_str(); } -}; - -class ini_params { - ini_params_imp * m_imp; -public: - ini_params(bool abort_on_error = true); - ~ini_params(); - void freeze(bool f = true); - void register_bool_param(char const * param_name, bool & value, char const * descr = 0, bool is_mutable = false); - void register_unsigned_param(char const * param_name, unsigned min, unsigned max, unsigned & value, char const * descr = 0, bool is_mutable = false); - void register_unsigned_param(char const * param_name, unsigned & value, char const * descr = 0, bool is_mutable = false) { - register_unsigned_param(param_name, 0, INT_MAX, value, descr, is_mutable); - } - void register_int_param(char const * param_name, int min, int max, int & value, char const * descr = 0, bool is_mutable = false); - void register_int_param(char const * param_name, int & value, char const * descr = 0, bool is_mutable = false) { - register_int_param(param_name, INT_MIN, INT_MAX, value, descr, is_mutable); - } - void register_double_param(char const * param_name, double & value, char const * descr = 0,bool is_mutable = false); - void register_percentage_param(char const * param_name, double & value, char const * descr = 0, bool is_mutable = false); - void register_string_param(char const * param_name, std::string & value, char const * descr = 0, bool is_mutable = false); - void register_symbol_param(char const * param_name, symbol & value, char const * descr = 0, bool is_mutable = false); - void register_symbol_list_param(char const * param_name, svector & value, char const * descr = 0, bool is_mutable = false); - void register_symbol_nat_list_param(char const * param_name, svector & value, char const * descr = 0, bool is_mutable = false); - void register_param_vector(param_vector * pv); - - void read_ini_file(std::istream & in); - void display_params(std::ostream & out) const; - void display_parameter_help(char const* param_id, std::ostream & out) const; - void set_param_value(char const * param_id, char const * param_value); - void set_param_mutable(char const * param_id); - bool get_param_value(char const * param_id, std::string& param_value); - void display_params_documentation(std::ostream & out) const; -}; - -#endif /* _INI_FILE_H_ */ - diff --git a/src/util/instruction_count.cpp b/src/util/instruction_count.cpp deleted file mode 100644 index 6dd5bcb85..000000000 --- a/src/util/instruction_count.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifdef _WINDOWS -#include -#endif -#include "instruction_count.h" - -#ifdef _WINDOWS -typedef BOOL (WINAPI *QTCP)(HANDLE, PULONG64); -static QTCP QTCP_proc; -BOOL WINAPI dummy_qtcp(HANDLE h, PULONG64 u) -{ - *u = 0; - return 0; -} - -inline void check_handler() -{ - if (!QTCP_proc) { - QTCP_proc = (QTCP) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "QueryThreadCycleTime"); - if (!QTCP_proc) - QTCP_proc = &dummy_qtcp; - } -} -#endif - -void instruction_count::start() { - m_count = 0; -#ifdef _WINDOWS - check_handler(); - QTCP_proc(GetCurrentThread(), &m_count); -#endif -} - -double instruction_count::get_num_instructions() { - unsigned long long current = 0; -#ifdef _WINDOWS - check_handler(); - QTCP_proc(GetCurrentThread(), ¤t); -#endif - return static_cast(current - m_count); -} - diff --git a/src/util/instruction_count.h b/src/util/instruction_count.h deleted file mode 100644 index 29fa0c45b..000000000 --- a/src/util/instruction_count.h +++ /dev/null @@ -1,43 +0,0 @@ -/*++ -Copyright (c) 2009 Microsoft Corporation - -Module Name: - - instruction_count.h - -Abstract: - - - -Author: - - Nikolaj Bjorner (nbjorner) 2009-03-04. - -Revision History: - ---*/ -#ifndef _INSTRUCTION_COUNT_H_ -#define _INSTRUCTION_COUNT_H_ - - -/** - \brief Wrapper for an instruction counter. -*/ -class instruction_count { - unsigned long long m_count; -public: - instruction_count() : m_count(0) {} - - ~instruction_count() {} - - void start(); - - double get_num_instructions(); - - bool is_instruction_maxed(double max_instr) { - return max_instr > 0.0 && get_num_instructions() > max_instr; - } -}; - -#endif /* _INSTRUcTION_COUNT_H_ */ - diff --git a/src/util/util.cpp b/src/util/util.cpp index c2795b637..3e5ced813 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -18,7 +18,6 @@ Revision History: --*/ #include"util.h" -#include"ini_file.h" unsigned g_verbosity_level = 0; @@ -30,8 +29,9 @@ unsigned get_verbosity_level() { return g_verbosity_level; } -void register_verbosity_level(ini_params & p) { - p.register_unsigned_param("VERBOSE", g_verbosity_level, "be verbose, where the value is the verbosity level", true); +void register_verbosity_level() { + // PARAM-TODO + // p.register_unsigned_param("VERBOSE", g_verbosity_level, "be verbose, where the value is the verbosity level", true); } static std::ostream* g_verbose_stream = &std::cerr; diff --git a/src/util/warning.cpp b/src/util/warning.cpp index 4ab54f203..19c0dac90 100644 --- a/src/util/warning.cpp +++ b/src/util/warning.cpp @@ -23,7 +23,6 @@ Revision History: #include "util.h" #include "buffer.h" #include "vector.h" -#include "ini_file.h" #ifdef _WINDOWS #define PRF sprintf_s @@ -83,8 +82,9 @@ void set_warning_stream(std::ostream* strm) { g_warning_stream = strm; } -void register_warning(ini_params & p) { - p.register_bool_param("WARNING", g_warning_msgs, "enable/disable warning messages", true); +void register_warning() { + // PARAM-TODO + // p.register_bool_param("WARNING", g_warning_msgs, "enable/disable warning messages", true); } void disable_error_msg_prefix() { From 29cf179364d59e75f15a9a5947c7bbfb7a2f89d2 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 17:03:14 -0800 Subject: [PATCH 15/34] more reorg Signed-off-by: Leonardo de Moura --- src/api/api_solver.cpp | 1 - src/ast/pattern/expr_pattern_match.cpp | 1 - src/ast/pattern/expr_pattern_match.h | 1 - src/cmd_context/cmd_context.cpp | 2 -- src/cmd_context/tactic_cmds.cpp | 1 - src/front_end_params/front_end_params.cpp | 4 ---- src/front_end_params/front_end_params.h | 12 +----------- src/front_end_params/preprocessor_params.h | 6 +++++- src/front_end_params/smt_params.h | 16 +++++++++++++--- src/shell/smtlib_frontend.cpp | 13 +++---------- src/smt/smt_model_generator.cpp | 2 +- src/smt/smt_solver.cpp | 15 +++++---------- src/smt/tactic/smt_tactic.cpp | 17 +++-------------- src/solver/solver.h | 9 --------- src/solver/strategic_solver.cpp | 2 -- src/solver/strategic_solver.h | 2 -- src/solver/tactic2solver.cpp | 2 -- src/solver/tactic2solver.h | 2 -- src/tactic/tactic.h | 1 - src/tactic/tactical.cpp | 13 ------------- 20 files changed, 31 insertions(+), 91 deletions(-) diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index a85e8d83a..31901d360 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -39,7 +39,6 @@ extern "C" { s->m_solver->set_produce_proofs(m.proofs_enabled()); s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", false)); s->m_solver->set_produce_models(s->m_params.get_bool("model", true)); - s->m_solver->set_front_end_params(mk_c(c)->fparams()); s->m_solver->updt_params(s->m_params); s->m_solver->init(m, s->m_logic); s->m_initialized = true; diff --git a/src/ast/pattern/expr_pattern_match.cpp b/src/ast/pattern/expr_pattern_match.cpp index a446ae538..86cad58f8 100644 --- a/src/ast/pattern/expr_pattern_match.cpp +++ b/src/ast/pattern/expr_pattern_match.cpp @@ -36,7 +36,6 @@ Notes: #include"ast_pp.h" #include"cmd_context.h" #include"smt2parser.h" -#include"front_end_params.h" expr_pattern_match::expr_pattern_match(ast_manager & manager): m_manager(manager), m_precompiled(manager) { diff --git a/src/ast/pattern/expr_pattern_match.h b/src/ast/pattern/expr_pattern_match.h index 45295e627..555d6a67e 100644 --- a/src/ast/pattern/expr_pattern_match.h +++ b/src/ast/pattern/expr_pattern_match.h @@ -22,7 +22,6 @@ Notes: #include"ast.h" #include"map.h" -#include"front_end_params.h" class expr_pattern_match { diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 3fd52f9d0..42abd2b2c 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -1301,7 +1301,6 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions init_manager(); if (m_solver) { m_check_sat_result = m_solver.get(); // solver itself stores the result. - m_solver->set_front_end_params(params()); m_solver->set_progress_callback(this); scoped_watch sw(*this); cancel_eh eh(*m_solver); @@ -1445,7 +1444,6 @@ void cmd_context::validate_model() { void cmd_context::set_solver(solver * s) { m_check_sat_result = 0; m_solver = s; - m_solver->set_front_end_params(params()); if (has_manager() && s != 0) { m_solver->set_produce_unsat_cores(m_produce_unsat_cores); m_solver->set_produce_models(params().m_model); diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index b911e3634..d44ef196d 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -189,7 +189,6 @@ public: params_ref p = ps(); front_end_params2params(ctx.params(), p); tactic_ref tref = using_params(sexpr2tactic(ctx, m_tactic), p); - tref->set_front_end_params(ctx.params()); tref->set_logic(ctx.get_logic()); ast_manager & m = ctx.m(); unsigned timeout = p.get_uint("timeout", UINT_MAX); diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 49c3f042e..0d51d94fb 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -51,10 +51,6 @@ void front_end_params::register_params(ini_params & p) { p.register_bool_param("debug_ref_count", m_debug_ref_count); }); - // temporary hack until strategic_solver is ported to new tactic framework - PRIVATE_PARAMS({ - p.register_bool_param("nlsat", m_nlsat); - }); } #endif diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index d033ba911..626f51a19 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -20,14 +20,9 @@ Revision History: #define _FRONT_END_PARAMS_H_ #include"ast.h" -#include"preprocessor_params.h" #include"smt_params.h" -#include"arith_simplifier_params.h" -struct front_end_params : public preprocessor_params, public smt_params, - public arith_simplifier_params { - bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. - bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. +struct front_end_params : public smt_params { bool m_well_sorted_check; unsigned m_memory_high_watermark; unsigned m_memory_max_size; @@ -39,13 +34,9 @@ struct front_end_params : public preprocessor_params, public smt_params, std::string m_trace_file_name; std::fstream* m_trace_stream; bool m_display_config; - bool m_nlsat; // temporary hack until strategic_solver is ported to new tactic framework - bool m_dump_goal_as_smt; front_end_params(): - m_at_labels_cex(false), - m_check_at_labels(false), m_well_sorted_check(true), m_memory_high_watermark(0), m_memory_max_size(0), @@ -60,7 +51,6 @@ struct front_end_params : public preprocessor_params, public smt_params, m_trace_file_name("z3.log"), m_trace_stream(NULL), m_display_config(false), - m_nlsat(false), m_dump_goal_as_smt(false) { } diff --git a/src/front_end_params/preprocessor_params.h b/src/front_end_params/preprocessor_params.h index b84aebe1a..e4b20b87a 100644 --- a/src/front_end_params/preprocessor_params.h +++ b/src/front_end_params/preprocessor_params.h @@ -22,6 +22,7 @@ Revision History: #include"pattern_inference_params.h" #include"bit_blaster_params.h" #include"bv_simplifier_params.h" +#include"arith_simplifier_params.h" enum lift_ite_kind { LI_NONE, @@ -30,7 +31,9 @@ enum lift_ite_kind { }; struct preprocessor_params : public pattern_inference_params, - public bit_blaster_params, public bv_simplifier_params { + public bit_blaster_params, + public bv_simplifier_params, + public arith_simplifier_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; @@ -81,6 +84,7 @@ public: pattern_inference_params::register_params(p); bit_blaster_params::register_params(p); bv_simplifier_params::register_params(p); + arith_simplifier_params::register_params(p); p.register_int_param("lift_ite", 0, 2, reinterpret_cast(m_lift_ite), "ite term lifting: 0 - no lifting, 1 - conservative, 2 - full"); p.register_int_param("ng_lift_ite", 0, 2, reinterpret_cast(m_ng_lift_ite), "ite (non-ground) term lifting: 0 - no lifting, 1 - conservative, 2 - full"); p.register_bool_param("elim_term_ite", m_eliminate_term_ite, "eliminate term if-then-else in the preprocessor"); diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 804049315..6e7755458 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -25,6 +25,7 @@ Revision History: #include"theory_array_params.h" #include"theory_bv_params.h" #include"theory_datatype_params.h" +#include"preprocessor_params.h" enum phase_selection { PS_ALWAYS_FALSE, @@ -65,7 +66,12 @@ enum case_split_strategy { CS_RELEVANCY_GOAL, // based on relevancy and the current goal }; -struct smt_params : public dyn_ack_params, public qi_params, public theory_arith_params, public theory_array_params, public theory_bv_params, +struct smt_params : public preprocessor_params, + public dyn_ack_params, + public qi_params, + public theory_arith_params, + public theory_array_params, + public theory_bv_params, public theory_datatype_params { bool m_display_proof; bool m_display_dot_proof; @@ -196,7 +202,9 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith bool m_user_theory_preprocess_axioms; bool m_user_theory_persist_axioms; unsigned m_soft_timeout; - + bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. + bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. + smt_params(): m_display_proof(false), m_display_dot_proof(false), @@ -260,7 +268,9 @@ struct smt_params : public dyn_ack_params, public qi_params, public theory_arith m_preprocess(true), // temporary hack for disabling all preprocessing.. m_user_theory_preprocess_axioms(false), m_user_theory_persist_axioms(false), - m_soft_timeout(0) + m_soft_timeout(0), + m_at_labels_cex(false), + m_check_at_labels(false) { } diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index 759f5cee2..c95b90098 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -98,16 +98,9 @@ unsigned read_smtlib2_commands(char const* file_name, front_end_params& front_en signal(SIGINT, on_ctrl_c); cmd_context ctx; - // temporary hack until strategic_solver is ported to new tactic framework - if (front_end_params.m_nlsat) { - tactic_factory2solver * s = alloc(tactic_factory2solver); - s->set_tactic(alloc(qfnra_nlsat_fct)); - ctx.set_solver(s); - } - else { - solver * s = mk_smt_strategic_solver(false); - ctx.set_solver(s); - } + solver * s = mk_smt_strategic_solver(false); + ctx.set_solver(s); + install_dl_cmds(ctx); install_dbg_cmds(ctx); install_polynomial_cmds(ctx); diff --git a/src/smt/smt_model_generator.cpp b/src/smt/smt_model_generator.cpp index d14abc31a..cf22c3e3a 100644 --- a/src/smt/smt_model_generator.cpp +++ b/src/smt/smt_model_generator.cpp @@ -48,7 +48,7 @@ namespace smt { void model_generator::init_model() { SASSERT(!m_model); - // PARAM-TODO + // PARAM-TODO smt_params ---> params_ref m_model = alloc(proto_model, m_manager, m_context->get_simplifier()); // , m_context->get_fparams()); ptr_vector::const_iterator it = m_context->begin_theories(); ptr_vector::const_iterator end = m_context->end_theories(); diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index 888e1b34c..8807e1e2b 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -24,22 +24,19 @@ Notes: namespace smt { class solver : public solver_na2as { - front_end_params * m_params; + front_end_params m_params; smt::kernel * m_context; progress_callback * m_callback; public: - solver():m_params(0), m_context(0), m_callback(0) {} + solver():m_context(0), m_callback(0) {} virtual ~solver() { if (m_context != 0) dealloc(m_context); } - virtual void set_front_end_params(front_end_params & p) { - m_params = &p; - } - virtual void updt_params(params_ref const & p) { + // PARAM-TODO copy p --> m_params if (m_context == 0) return; m_context->updt_params(p); @@ -49,8 +46,7 @@ namespace smt { if (m_context == 0) { ast_manager m; reg_decl_plugins(m); - front_end_params p; - smt::kernel s(m, p); + smt::kernel s(m, m_params); s.collect_param_descrs(r); } else { @@ -59,11 +55,10 @@ namespace smt { } virtual void init_core(ast_manager & m, symbol const & logic) { - SASSERT(m_params); reset(); #pragma omp critical (solver) { - m_context = alloc(smt::kernel, m, *m_params); + m_context = alloc(smt::kernel, m, m_params); if (m_callback) m_context->set_progress_callback(m_callback); } diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index 1551c765c..c75e0d56b 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -24,7 +24,7 @@ Notes: #include"rewriter_types.h" class smt_tactic : public tactic { - scoped_ptr m_params; + front_end_params m_params; params_ref m_params_ref; statistics m_stats; std::string m_failure; @@ -52,11 +52,7 @@ public: } front_end_params & fparams() { - if (!m_params) { - m_params = alloc(front_end_params); - params2front_end_params(m_params_ref, fparams()); - } - return *m_params; + return m_params; } void updt_params_core(params_ref const & p) { @@ -68,6 +64,7 @@ public: TRACE("smt_tactic", tout << this << "\nupdt_params: " << p << "\n";); updt_params_core(p); m_params_ref = p; + // PARAM-TODO update params2front_end_params p ---> m_params params2front_end_params(m_params_ref, fparams()); SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); } @@ -97,14 +94,6 @@ public: m_stats.reset(); } - // for backward compatibility - virtual void set_front_end_params(front_end_params & p) { - m_params = alloc(front_end_params, p); - SASSERT(m_params.get() == &fparams()); - // must propagate the params_ref to fparams - params2front_end_params(m_params_ref, fparams()); - } - virtual void set_logic(symbol const & l) { m_logic = l; } diff --git a/src/solver/solver.h b/src/solver/solver.h index 6f9887c1a..f26a5c5f4 100644 --- a/src/solver/solver.h +++ b/src/solver/solver.h @@ -41,15 +41,6 @@ struct front_end_params; class solver : public check_sat_result { public: virtual ~solver() {} - - /** - \brief This method is invoked to allow the solver to access the front_end_params (environment parameters). - - \warning This method is used for backward compatibility. The first solver implemented in Z3 used - front_end_params to store its configuration parameters. - */ - virtual void set_front_end_params(front_end_params & p) {} - /** \brief Update the solver internal settings. */ diff --git a/src/solver/strategic_solver.cpp b/src/solver/strategic_solver.cpp index b6eb98b42..8968f862a 100644 --- a/src/solver/strategic_solver.cpp +++ b/src/solver/strategic_solver.cpp @@ -191,7 +191,6 @@ void strategic_solver::init_inc_solver() { m_inc_solver->set_produce_proofs(m_produce_proofs); m_inc_solver->set_produce_models(m_produce_models); m_inc_solver->set_produce_unsat_cores(m_produce_unsat_cores); - m_inc_solver->set_front_end_params(*m_fparams); m_inc_solver->init(m(), m_logic); unsigned sz = get_num_assertions(); if (m_produce_unsat_cores) { @@ -329,7 +328,6 @@ struct strategic_solver::mk_tactic { params_ref p; front_end_params2params(*s->m_fparams, p); tactic * tct = (*f)(m, p); - tct->set_front_end_params(*s->m_fparams); tct->set_logic(s->m_logic); if (s->m_callback) tct->set_progress_callback(s->m_callback); diff --git a/src/solver/strategic_solver.h b/src/solver/strategic_solver.h index e903e9bd0..7cdda80d5 100644 --- a/src/solver/strategic_solver.h +++ b/src/solver/strategic_solver.h @@ -118,8 +118,6 @@ public: void set_inc_unknown_behavior(inc_unknown_behavior b) { m_inc_unknown_behavior = b; } void force_tactic(bool f) { m_force_tactic = f; } - virtual void set_front_end_params(front_end_params & p) { m_fparams = &p; } - virtual void updt_params(params_ref const & p); virtual void collect_param_descrs(param_descrs & r); diff --git a/src/solver/tactic2solver.cpp b/src/solver/tactic2solver.cpp index 63308bd27..0dd55a26b 100644 --- a/src/solver/tactic2solver.cpp +++ b/src/solver/tactic2solver.cpp @@ -107,8 +107,6 @@ lbool tactic2solver_core::check_sat_core(unsigned num_assumptions, expr * const return l_undef; tactic & t = *(m_ctx->m_tactic); simple_check_sat_result & result = *(m_ctx->m_result); - if (m_fparams) - t.set_front_end_params(*m_fparams); goal_ref g = alloc(goal, m, m_produce_proofs, m_produce_models, m_produce_unsat_cores); t.set_logic(m_ctx->m_logic); unsigned sz = m_ctx->m_assertions.size(); diff --git a/src/solver/tactic2solver.h b/src/solver/tactic2solver.h index 8cf3551b4..854956d80 100644 --- a/src/solver/tactic2solver.h +++ b/src/solver/tactic2solver.h @@ -54,8 +54,6 @@ public: virtual tactic * get_tactic(ast_manager & m, params_ref const & p) = 0; - virtual void set_front_end_params(front_end_params & p) { m_fparams = &p; } - virtual void updt_params(params_ref const & p); virtual void collect_param_descrs(param_descrs & r); diff --git a/src/tactic/tactic.h b/src/tactic/tactic.h index cb2c3f515..015b5fe0a 100644 --- a/src/tactic/tactic.h +++ b/src/tactic/tactic.h @@ -92,7 +92,6 @@ public: virtual void reset() { cleanup(); } // for backward compatibility - virtual void set_front_end_params(front_end_params & p) {} virtual void set_logic(symbol const & l) {} virtual void set_progress_callback(progress_callback * callback) {} diff --git a/src/tactic/tactical.cpp b/src/tactic/tactical.cpp index 30e05bd26..0d61f0916 100644 --- a/src/tactic/tactical.cpp +++ b/src/tactic/tactical.cpp @@ -87,11 +87,6 @@ public: m_t2->reset(); } - virtual void set_front_end_params(front_end_params & p) { - m_t1->set_front_end_params(p); - m_t2->set_front_end_params(p); - } - virtual void set_logic(symbol const & l) { m_t1->set_logic(l); m_t2->set_logic(l); @@ -380,13 +375,6 @@ public: (*it)->reset(); } - virtual void set_front_end_params(front_end_params & p) { - ptr_vector::iterator it = m_ts.begin(); - ptr_vector::iterator end = m_ts.end(); - for (; it != end; ++it) - (*it)->set_front_end_params(p); - } - virtual void set_logic(symbol const & l) { ptr_vector::iterator it = m_ts.begin(); ptr_vector::iterator end = m_ts.end(); @@ -992,7 +980,6 @@ public: 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 set_front_end_params(front_end_params & p) { m_t->set_front_end_params(p); } 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(); } From 92acd6d4ee5d5ac62414e8f012f3e27582f4db6e Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 18:19:02 -0800 Subject: [PATCH 16/34] removed front_end_params from cmd_context Signed-off-by: Leonardo de Moura --- scripts/mk_project.py | 14 ++++---- src/cmd_context/basic_cmds.cpp | 21 ++++++------ src/cmd_context/cmd_context.cpp | 60 ++++++++++++++++++++------------- src/cmd_context/cmd_context.h | 6 ++-- src/cmd_context/tactic_cmds.cpp | 3 -- src/muz_qe/dl_cmds.cpp | 4 ++- src/solver/strategic_solver.cpp | 19 +++++------ src/solver/strategic_solver.h | 5 +-- src/solver/tactic2solver.cpp | 3 -- src/solver/tactic2solver.h | 3 +- 10 files changed, 71 insertions(+), 67 deletions(-) diff --git a/scripts/mk_project.py b/scripts/mk_project.py index 27120c89d..ac6f44a83 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -25,22 +25,22 @@ def init_project_def(): add_lib('parser_util', ['ast'], 'parsers/util') add_lib('grobner', ['ast'], 'math/grobner') add_lib('euclid', ['util'], 'math/euclid') - # Front-end-params module still contain a lot of parameters for smt solver component. - # This should be fixed - add_lib('front_end_params', ['ast']) - # Simplifier module will be deleted in the future. - # It has been replaced with rewriter module. - add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier') add_lib('core_tactics', ['tactic', 'normal_forms'], 'tactic/core') add_lib('sat_tactic', ['tactic', 'sat'], 'sat/tactic') add_lib('arith_tactics', ['core_tactics', 'sat'], 'tactic/arith') add_lib('nlsat_tactic', ['nlsat', 'sat_tactic', 'arith_tactics'], 'nlsat/tactic') add_lib('subpaving_tactic', ['core_tactics', 'subpaving'], 'math/subpaving/tactic') add_lib('aig_tactic', ['tactic'], 'tactic/aig') - add_lib('solver', ['model', 'tactic', 'front_end_params']) + add_lib('solver', ['model', 'tactic']) add_lib('cmd_context', ['solver', 'rewriter']) add_lib('extra_cmds', ['cmd_context', 'subpaving_tactic', 'arith_tactics'], 'cmd_context/extra_cmds') add_lib('smt2parser', ['cmd_context', 'parser_util'], 'parsers/smt2') + # Front-end-params module still contain a lot of parameters for smt solver component. + # This should be fixed + add_lib('front_end_params', ['ast']) + # Simplifier module will be deleted in the future. + # It has been replaced with rewriter module. + add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier') add_lib('pattern', ['normal_forms', 'smt2parser', 'simplifier'], 'ast/pattern') add_lib('macros', ['simplifier', 'front_end_params'], 'ast/macros') add_lib('proof_checker', ['rewriter', 'front_end_params'], 'ast/proof_checker') diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index 43507ed3f..d3861257b 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -27,7 +27,6 @@ Notes: #include"cmd_util.h" #include"simplify_cmd.h" #include"eval_cmd.h" -#include"front_end_params.h" #include"gparams.h" #include"model_params.hpp" @@ -159,7 +158,7 @@ public: }; ATOMIC_CMD(get_proof_cmd, "get-proof", "retrieve proof", { - if (ctx.params().m_proof_mode == PGM_DISABLED) + if (!ctx.produce_proofs()) throw cmd_exception("proof construction is not enabled, use command (set-option :produce-proofs true)"); if (!ctx.has_manager() || ctx.cs_state() != cmd_context::css_unsat) @@ -253,7 +252,7 @@ protected: } public: - set_get_option_cmd(char const * name, front_end_params & params): + set_get_option_cmd(char const * name): cmd(name), m_true("true"), m_false("false"), @@ -375,8 +374,8 @@ class set_option_cmd : public set_get_option_cmd { } public: - set_option_cmd(front_end_params & params): - set_get_option_cmd("set-option", params), + set_option_cmd(): + set_get_option_cmd("set-option"), m_unsupported(false) { } @@ -454,8 +453,8 @@ class get_option_cmd : public set_get_option_cmd { } public: - get_option_cmd(front_end_params & params): - set_get_option_cmd("get-option", params) { + 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."; } @@ -476,13 +475,13 @@ public: print_bool(ctx, ctx.interactive_mode()); } else if (opt == m_produce_proofs) { - print_bool(ctx, ctx.params().m_proof_mode != PGM_DISABLED); + print_bool(ctx, ctx.produce_proofs()); } else if (opt == m_produce_unsat_cores) { print_bool(ctx, ctx.produce_unsat_cores()); } else if (opt == m_produce_models) { - print_bool(ctx, ctx.params().m_model); + print_bool(ctx, ctx.produce_models()); } else if (opt == m_produce_assignments) { print_bool(ctx, ctx.produce_assignments()); @@ -711,8 +710,8 @@ void install_basic_cmds(cmd_context & ctx) { ctx.insert(alloc(get_assertions_cmd)); ctx.insert(alloc(get_proof_cmd)); ctx.insert(alloc(get_unsat_core_cmd)); - ctx.insert(alloc(set_option_cmd, ctx.params())); - ctx.insert(alloc(get_option_cmd, ctx.params())); + ctx.insert(alloc(set_option_cmd)); + ctx.insert(alloc(get_option_cmd)); ctx.insert(alloc(get_info_cmd)); ctx.insert(alloc(set_info_cmd)); ctx.insert(alloc(builtin_cmd, "assert", "", "assert term.")); diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 42abd2b2c..7a06f30bf 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -16,7 +16,6 @@ Notes: --*/ #include -#include"front_end_params.h" #include"tptr.h" #include"cmd_context.h" #include"func_decl_dependencies.h" @@ -318,7 +317,6 @@ public: cmd_context::cmd_context(bool main_ctx, ast_manager * m, symbol const & l): m_main_ctx(main_ctx), - m_fparams(alloc(front_end_params)), m_logic(l), m_interactive_mode(false), m_global_decls(false), // :global-decls is false by default. @@ -358,11 +356,11 @@ cmd_context::~cmd_context() { finalize_probes(); m_solver = 0; m_check_sat_result = 0; - dealloc(m_fparams); } void cmd_context::set_produce_models(bool f) { - params().m_model = f; + // PARAM-TODO + // params().m_model = f; if (m_solver) m_solver->set_produce_models(f); } @@ -374,19 +372,35 @@ void cmd_context::set_produce_unsat_cores(bool f) { } void cmd_context::set_produce_proofs(bool f) { + // PARAM-TODO // can only be set before initialization SASSERT(!has_manager()); - params().m_proof_mode = f ? PGM_FINE : PGM_DISABLED; + // params().m_proof_mode = f ? PGM_FINE : PGM_DISABLED; } bool cmd_context::produce_models() const { - return params().m_model; + // PARAM-TODO + // return params().m_model; + return true; } bool cmd_context::produce_proofs() const { - return params().m_proof_mode != PGM_DISABLED; + // PARAM-TODO + // return params().m_proof_mode != PGM_DISABLED; + return false; } +bool cmd_context::well_sorted_check_enabled() const { + // PARAM-TODO + return true; +} + +bool cmd_context::validate_model_enabled() const { + // PARAM-TODO + return false; +} + + cmd_context::check_sat_state cmd_context::cs_state() const { if (m_check_sat_result.get() == 0) return css_clear; @@ -579,9 +593,9 @@ void cmd_context::init_manager_core(bool new_manager) { insert(pm().mk_plist_decl()); } if (m_solver) { - m_solver->set_produce_unsat_cores(m_produce_unsat_cores); - m_solver->set_produce_models(params().m_model); - m_solver->set_produce_proofs(params().m_proof_mode == PGM_FINE); + m_solver->set_produce_unsat_cores(produce_unsat_cores()); + m_solver->set_produce_models(produce_models()); + m_solver->set_produce_proofs(produce_proofs()); m_solver->init(m(), m_logic); } m_check_logic.set_logic(m(), m_logic); @@ -591,7 +605,7 @@ void cmd_context::init_manager() { SASSERT(m_manager == 0); SASSERT(m_pmanager == 0); m_check_sat_result = 0; - m_manager = alloc(ast_manager, params().m_proof_mode, params().m_trace_stream); + m_manager = alloc(ast_manager, produce_proofs() ? PGM_FINE : PGM_DISABLED); // PARAM-TODO , params().m_trace_stream); m_pmanager = alloc(pdecl_manager, *m_manager); init_manager_core(true); // PARAM-TODO @@ -855,7 +869,7 @@ object_ref * cmd_context::find_object_ref(symbol const & s) const { return r; } -#define CHECK_SORT(T) if (params().m_well_sorted_check) m().check_sorts_core(T) +#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); @@ -895,13 +909,13 @@ void cmd_context::mk_app(symbol const & s, unsigned num_args, expr * const * arg return; } SASSERT(num_args > 0); - TRACE("macro_bug", tout << "m_well_sorted_check: " << params().m_well_sorted_check << "\n"; + TRACE("macro_bug", tout << "well_sorted_check_enabled(): " << well_sorted_check_enabled() << "\n"; tout << "s: " << s << "\n"; tout << "body:\n" << mk_ismt2_pp(_m.second, m()) << "\n"; tout << "args:\n"; for (unsigned i = 0; i < num_args; i++) tout << mk_ismt2_pp(args[i], m()) << "\n" << mk_pp(m().get_sort(args[i]), m()) << "\n";); var_subst subst(m()); subst(_m.second, num_args, args, result); - if (params().m_well_sorted_check && !is_well_sorted(m(), result)) + if (well_sorted_check_enabled() && !is_well_sorted(m(), result)) throw cmd_exception("invalid macro application, sort mismatch ", s); return; } @@ -930,7 +944,7 @@ void cmd_context::mk_app(symbol const & s, unsigned num_args, expr * const * arg func_decl * f = fs.find(m(), num_args, args, range); if (f == 0) throw cmd_exception("unknown constant ", s); - if (params().m_well_sorted_check) + if (well_sorted_check_enabled()) m().check_sort(f, num_args, args); result = m().mk_app(f, num_args, args); return; @@ -1151,7 +1165,7 @@ void cmd_context::assert_expr(expr * t) { m_check_sat_result = 0; m().inc_ref(t); m_assertions.push_back(t); - if (m_produce_unsat_cores) + if (produce_unsat_cores()) m_assertion_names.push_back(0); if (m_solver) m_solver->assert_expr(t); @@ -1160,7 +1174,7 @@ void cmd_context::assert_expr(expr * t) { void cmd_context::assert_expr(symbol const & name, expr * t) { if (!m_check_logic(t)) throw cmd_exception(m_check_logic.get_last_error()); - if (!m_produce_unsat_cores || name == symbol::null) { + if (!produce_unsat_cores() || name == symbol::null) { assert_expr(t); return; } @@ -1266,7 +1280,7 @@ void cmd_context::restore_assertions(unsigned old_sz) { SASSERT(old_sz <= m_assertions.size()); SASSERT(!m_interactive_mode || m_assertions.size() == m_assertion_strings.size()); restore(m(), m_assertions, old_sz); - if (m_produce_unsat_cores) + if (produce_unsat_cores()) restore(m(), m_assertion_names, old_sz); if (m_interactive_mode) m_assertion_strings.shrink(old_sz); @@ -1398,7 +1412,7 @@ struct contains_array_op_proc { \brief Check if the current model satisfies the quantifier free formulas. */ void cmd_context::validate_model() { - if (!params().m_model_validate) + if (!validate_model_enabled()) return; if (!is_model_available()) return; @@ -1445,9 +1459,9 @@ void cmd_context::set_solver(solver * s) { m_check_sat_result = 0; m_solver = s; if (has_manager() && s != 0) { - m_solver->set_produce_unsat_cores(m_produce_unsat_cores); - m_solver->set_produce_models(params().m_model); - m_solver->set_produce_proofs(params().m_proof_mode == PGM_FINE); + m_solver->set_produce_unsat_cores(produce_unsat_cores()); + m_solver->set_produce_models(produce_models()); + m_solver->set_produce_proofs(produce_proofs()); m_solver->init(m(), m_logic); // assert formulas and create scopes in the new solver. unsigned lim = 0; @@ -1502,7 +1516,7 @@ void cmd_context::display_assertions() { } bool cmd_context::is_model_available() const { - if (params().m_model && + if (produce_models() && has_manager() && (cs_state() == css_sat || cs_state() == css_unknown)) { model_ref md; diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index 1b15c0b60..c2acba0dc 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -42,8 +42,6 @@ Notes: */ std::string smt2_keyword_to_param(symbol const & k); -struct front_end_params; - class func_decls { func_decl * m_decls; public: @@ -138,7 +136,6 @@ public: protected: bool m_main_ctx; - front_end_params * m_fparams; symbol m_logic; bool m_interactive_mode; bool m_global_decls; @@ -274,6 +271,8 @@ public: bool produce_models() const; bool produce_proofs() const; bool produce_unsat_cores() const { return m_produce_unsat_cores; } + bool well_sorted_check_enabled() const; + bool validate_model_enabled() const; void set_produce_models(bool flag); void set_produce_unsat_cores(bool flag); void set_produce_proofs(bool flag); @@ -288,7 +287,6 @@ public: virtual ast_manager & get_ast_manager() { 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; } - front_end_params & params() const { return *m_fparams; } void set_solver(solver * s); solver * get_solver() const { return m_solver.get(); } diff --git a/src/cmd_context/tactic_cmds.cpp b/src/cmd_context/tactic_cmds.cpp index d44ef196d..ba1193b20 100644 --- a/src/cmd_context/tactic_cmds.cpp +++ b/src/cmd_context/tactic_cmds.cpp @@ -24,7 +24,6 @@ Notes: #include"scoped_ctrl_c.h" #include"cancel_eh.h" #include"model_smt2_pp.h" -#include"params2front_end_params.h" #include"ast_smt2_pp.h" #include"tactic.h" #include"tactical.h" @@ -187,7 +186,6 @@ public: virtual void execute(cmd_context & ctx) { params_ref p = ps(); - front_end_params2params(ctx.params(), p); tactic_ref tref = using_params(sexpr2tactic(ctx, m_tactic), p); tref->set_logic(ctx.get_logic()); ast_manager & m = ctx.m(); @@ -298,7 +296,6 @@ public: virtual void execute(cmd_context & ctx) { params_ref p = ps(); - front_end_params2params(ctx.params(), p); tactic_ref tref = using_params(sexpr2tactic(ctx, m_tactic), p); { tactic & t = *(tref.get()); diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index d89b8d80d..deb4dc7ec 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -33,6 +33,8 @@ Notes: class dl_context { + // PARAM-TODO temp HACK: added m_params field because cmd_context does not have front_end_params anymore + front_end_params m_params; cmd_context & m_cmd; dl_collected_cmds* m_collected_cmds; unsigned m_ref_count; @@ -62,7 +64,7 @@ public: void init() { ast_manager& m = m_cmd.m(); if (!m_context) { - m_context = alloc(datalog::context, m, m_cmd.params()); + m_context = alloc(datalog::context, m, m_params); } if (!m_decl_plugin) { symbol name("datalog_relation"); diff --git a/src/solver/strategic_solver.cpp b/src/solver/strategic_solver.cpp index 8968f862a..8ce098c51 100644 --- a/src/solver/strategic_solver.cpp +++ b/src/solver/strategic_solver.cpp @@ -18,8 +18,6 @@ Notes: --*/ #include"strategic_solver.h" #include"scoped_timer.h" -#include"front_end_params.h" -#include"params2front_end_params.h" #include"ast_smt2_pp.h" // minimum verbosity level for portfolio verbose messages @@ -33,7 +31,6 @@ strategic_solver::ctx::ctx(ast_manager & m): strategic_solver::strategic_solver(): m_manager(0), - m_fparams(0), m_force_tactic(false), m_inc_mode(false), m_check_sat_executed(false), @@ -50,6 +47,7 @@ strategic_solver::strategic_solver(): m_produce_proofs = false; m_produce_models = false; m_produce_unsat_cores = false; + m_auto_config = true; } strategic_solver::~strategic_solver() { @@ -99,11 +97,12 @@ void strategic_solver::set_inc_solver(solver * s) { void strategic_solver::updt_params(params_ref const & p) { if (m_inc_solver) m_inc_solver->updt_params(p); - if (m_fparams) - params2front_end_params(p, *m_fparams); + m_params = p; + m_auto_config = p.get_bool("auto_config", true); + // PARAM-TODO + // PROOFS, MODELS, UNSATCORES } - void strategic_solver::collect_param_descrs(param_descrs & r) { if (m_inc_solver) m_inc_solver->collect_param_descrs(r); @@ -323,10 +322,8 @@ struct aux_timeout_eh : public event_handler { struct strategic_solver::mk_tactic { strategic_solver * m_solver; - mk_tactic(strategic_solver * s, tactic_factory * f):m_solver(s) { + mk_tactic(strategic_solver * s, tactic_factory * f, params_ref const & p):m_solver(s) { ast_manager & m = s->m(); - params_ref p; - front_end_params2params(*s->m_fparams, p); tactic * tct = (*f)(m, p); tct->set_logic(s->m_logic); if (s->m_callback) @@ -374,7 +371,7 @@ lbool strategic_solver::check_sat(unsigned num_assumptions, expr * const * assum reset_results(); m_check_sat_executed = true; if (num_assumptions > 0 || // assumptions were provided - (!m_fparams->m_auto_config && !m_force_tactic) // auto config and force_tactic are turned off + (!m_auto_config && !m_force_tactic) // auto config and force_tactic are turned off ) { // must use incremental solver return check_sat_with_assumptions(num_assumptions, assumptions); @@ -438,7 +435,7 @@ lbool strategic_solver::check_sat(unsigned num_assumptions, expr * const * assum TRACE("strategic_solver", tout << "using goal...\n"; g->display_with_dependencies(tout);); - mk_tactic tct_maker(this, factory); + mk_tactic tct_maker(this, factory, m_params); SASSERT(m_curr_tactic); proof_ref pr(m()); diff --git a/src/solver/strategic_solver.h b/src/solver/strategic_solver.h index 7cdda80d5..1883a88cd 100644 --- a/src/solver/strategic_solver.h +++ b/src/solver/strategic_solver.h @@ -23,7 +23,6 @@ Notes: #include"tactic.h" class progress_callback; -struct front_end_params; /** \brief Implementation of the solver API that supports: @@ -57,7 +56,7 @@ public: private: ast_manager * m_manager; - front_end_params * m_fparams; + params_ref m_params; symbol m_logic; bool m_force_tactic; // use tactics even when auto_config = false bool m_inc_mode; @@ -93,6 +92,8 @@ private: bool m_produce_models; bool m_produce_unsat_cores; + bool m_auto_config; + progress_callback * m_callback; void reset_results(); diff --git a/src/solver/tactic2solver.cpp b/src/solver/tactic2solver.cpp index 0dd55a26b..e630f9c78 100644 --- a/src/solver/tactic2solver.cpp +++ b/src/solver/tactic2solver.cpp @@ -20,7 +20,6 @@ Notes: --*/ #include"tactic2solver.h" -#include"params2front_end_params.h" #include"ast_smt2_pp.h" tactic2solver_core::ctx::ctx(ast_manager & m, symbol const & logic): @@ -94,8 +93,6 @@ lbool tactic2solver_core::check_sat_core(unsigned num_assumptions, expr * const SASSERT(m_ctx); ast_manager & m = m_ctx->m(); params_ref p = m_params; - if (m_fparams) - front_end_params2params(*m_fparams, p); #pragma omp critical (tactic2solver_core) { m_ctx->m_tactic = get_tactic(m, p); diff --git a/src/solver/tactic2solver.h b/src/solver/tactic2solver.h index 854956d80..0a057b04b 100644 --- a/src/solver/tactic2solver.h +++ b/src/solver/tactic2solver.h @@ -43,13 +43,12 @@ class tactic2solver_core : public solver_na2as { ast_manager & m() const { return m_assertions.m(); } }; scoped_ptr m_ctx; - front_end_params * m_fparams; params_ref m_params; bool m_produce_models; bool m_produce_proofs; bool m_produce_unsat_cores; public: - tactic2solver_core():m_ctx(0), m_fparams(0), m_produce_models(false), m_produce_proofs(false), m_produce_unsat_cores(false) {} + tactic2solver_core():m_ctx(0), m_produce_models(false), m_produce_proofs(false), m_produce_unsat_cores(false) {} virtual ~tactic2solver_core(); virtual tactic * get_tactic(ast_manager & m, params_ref const & p) = 0; From 29ec68284b554cb6bc507322d7e8b3a3ef0976e6 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 18:34:53 -0800 Subject: [PATCH 17/34] Added better error message when old parameter name is used Signed-off-by: Leonardo de Moura --- src/api/api_context.cpp | 1 - src/api/api_context.h | 1 - src/front_end_params/front_end_params.h | 4 --- src/util/gparams.cpp | 38 +++++++++++++++++++------ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index ba8d2ae64..11fb28a02 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -90,7 +90,6 @@ namespace api { context::context(config_params * p, bool user_ref_count): m_params(p ? p->m_params : front_end_params()), - m_param_ini(m_params), m_user_ref_count(user_ref_count), m_manager(m_params.m_proof_mode, m_params.m_trace_stream), m_plugins(m_manager), diff --git a/src/api/api_context.h b/src/api/api_context.h index 3da506b54..76c601d60 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -53,7 +53,6 @@ namespace api { struct add_plugins { add_plugins(ast_manager & m); }; front_end_params m_params; - param_ini m_param_ini; bool m_user_ref_count; //!< if true, the user is responsible for managing referenc counters. ast_manager m_manager; add_plugins m_plugins; diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index 626f51a19..c3fa9fa95 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -41,11 +41,7 @@ struct front_end_params : public smt_params { m_memory_high_watermark(0), m_memory_max_size(0), m_proof_mode(PGM_DISABLED), -#if defined(SMTCOMP) || defined(_EXTERNAL_RELEASE) m_auto_config(true), -#else - m_auto_config(false), -#endif m_debug_ref_count(false), m_trace(false), m_trace_file_name("z3.log"), diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 426789bb4..e7b2a52eb 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -21,6 +21,19 @@ Notes: extern void gparams_register_modules(); +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 }; + +bool is_old_param_name(symbol const & name) { + char const * const * it = g_old_params_names; + while (*it) { + if (name == *it) + return true; + it++; + } + return false; +} + struct gparams::imp { dictionary m_module_param_descrs; param_descrs m_param_descrs; @@ -120,14 +133,26 @@ public: } } + void throw_unknown_parameter(symbol const & param_name, symbol const & mod_name) { + if (mod_name == symbol::null) { + if (is_old_param_name(param_name)) { + throw exception("unknown parameter '%s', this is an old parameter name, invoke 'z3 -ps' to obtain the new parameter list", + param_name.bare_str()); + } + else { + throw exception("unknown parameter '%s'", param_name.bare_str()); + } + } + else { + throw exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + } + } + void set(param_descrs const & d, symbol const & param_name, char const * value, symbol const & mod_name) { param_kind k = d.get_kind(param_name); params_ref & ps = get_params(mod_name); if (k == CPK_INVALID) { - if (mod_name == symbol::null) - throw exception("unknown parameter '%s'", param_name.bare_str()); - else - throw exception("unknown parameter '%s' at module '%s'", param_name.bare_str(), mod_name.bare_str()); + throw_unknown_parameter(param_name, mod_name); } else if (k == CPK_UINT) { long val = strtol(value, 0, 10); @@ -200,10 +225,7 @@ public: std::string get_default(param_descrs const & d, symbol const & p, symbol const & m) { if (!d.contains(p)) { - if (m == symbol::null) - throw exception("unknown parameter '%s'", p.bare_str()); - else - throw exception("unknown parameter '%s' at module '%s'", p.bare_str(), m.bare_str()); + throw_unknown_parameter(p, m); } char const * r = d.get_default(p); if (r == 0) From 9bd4fd969ac859c4bcfb48727d96a37359950596 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 18:50:26 -0800 Subject: [PATCH 18/34] cleanning Signed-off-by: Leonardo de Moura --- src/front_end_params/front_end_params.cpp | 1 - src/front_end_params/front_end_params.h | 6 +----- src/front_end_params/smt_params.h | 6 +++--- src/shell/dimacs_frontend.cpp | 8 +++----- src/shell/dimacs_frontend.h | 2 +- src/shell/main.cpp | 20 ++------------------ 6 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 0d51d94fb..32692180f 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -36,7 +36,6 @@ void front_end_params::register_params(ini_params & p) { p.register_int_param("proof_mode", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); p.register_bool_param("trace", m_trace, "enable tracing for the Axiom Profiler tool"); p.register_string_param("trace_file_name", m_trace_file_name, "tracing file name"); - p.register_bool_param("display_config", m_display_config, "display configuration used by Z3"); #ifdef _WINDOWS // The non-windows memory manager does not have access to memory sizes. diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index c3fa9fa95..2c7dbfa2e 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -33,8 +33,6 @@ struct front_end_params : public smt_params { bool m_trace; std::string m_trace_file_name; std::fstream* m_trace_stream; - bool m_display_config; - bool m_dump_goal_as_smt; front_end_params(): m_well_sorted_check(true), @@ -45,9 +43,7 @@ struct front_end_params : public smt_params { m_debug_ref_count(false), m_trace(false), m_trace_file_name("z3.log"), - m_trace_stream(NULL), - m_display_config(false), - m_dump_goal_as_smt(false) { + m_trace_stream(NULL) { } void open_trace_file(); diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 6e7755458..24479de16 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -204,6 +204,7 @@ struct smt_params : public preprocessor_params, unsigned m_soft_timeout; bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. + bool m_dump_goal_as_smt; smt_params(): m_display_proof(false), @@ -270,9 +271,8 @@ struct smt_params : public preprocessor_params, m_user_theory_persist_axioms(false), m_soft_timeout(0), m_at_labels_cex(false), - m_check_at_labels(false) - { - + m_check_at_labels(false), + m_dump_goal_as_smt(false) { } }; diff --git a/src/shell/dimacs_frontend.cpp b/src/shell/dimacs_frontend.cpp index 2dbb0adf8..0acd222dd 100644 --- a/src/shell/dimacs_frontend.cpp +++ b/src/shell/dimacs_frontend.cpp @@ -22,7 +22,6 @@ Revision History: #include"timeout.h" #include"dimacs.h" #include"sat_solver.h" -#include"front_end_params.h" extern bool g_display_statistics; static sat::solver * g_solver = 0; @@ -64,12 +63,12 @@ static void display_model(sat::solver const & s) { std::cout << "\n"; } -unsigned read_dimacs(char const * file_name, front_end_params & front_end_params) { +unsigned read_dimacs(char const * file_name) { g_start_time = clock(); register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); params_ref p; - p.set_bool("produce_models", front_end_params.m_model); + p.set_bool("produce_models", true); sat::solver solver(p, 0); g_solver = &solver; @@ -90,8 +89,7 @@ unsigned read_dimacs(char const * file_name, front_end_params & front_end_params switch (r) { case l_true: std::cout << "sat\n"; - if (front_end_params.m_model) - display_model(solver); + display_model(solver); break; case l_undef: std::cout << "unknown\n"; diff --git a/src/shell/dimacs_frontend.h b/src/shell/dimacs_frontend.h index 22ab63529..9521c8256 100644 --- a/src/shell/dimacs_frontend.h +++ b/src/shell/dimacs_frontend.h @@ -19,7 +19,7 @@ Revision History: #ifndef _DIMACS_FRONTEND_H_ #define _DIMACS_FRONTEND_H_ -unsigned read_dimacs(char const * benchmark_file, front_end_params & front_end_params); +unsigned read_dimacs(char const * benchmark_file); #endif /* _DATALOG_FRONTEND_H_ */ diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 5434206cc..b08d02812 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -77,7 +77,7 @@ void display_usage() { std::cout << " " << OPT << "version prints version number of Z3.\n"; std::cout << " " << OPT << "v:level be verbose, where is the verbosity level.\n"; std::cout << " " << OPT << "nw disable warning messages.\n"; - std::cout << " " << OPT << "ps display all available parameters.\n"; + std::cout << " " << OPT << "ps display Z3 global (and module) parameters.\n"; std::cout << " --" << " all remaining arguments are assumed to be part of the input file name. This option allows Z3 to read files with strange names such as: -foo.smt2.\n"; std::cout << "\nResources:\n"; // timeout and memout are now available on Linux and OSX too. @@ -87,8 +87,6 @@ void display_usage() { // std::cout << "\nOutput:\n"; std::cout << " " << OPT << "st display statistics.\n"; - std::cout << "\nSearch heuristics:\n"; - std::cout << " " << OPT << "rs:num random seed.\n"; #if defined(Z3DEBUG) || defined(_TRACE) std::cout << "\nDebugging support:\n"; #endif @@ -226,20 +224,6 @@ void parse_cmd_line_args(int argc, char ** argv) { } g_front_end_params->m_relevancy_lvl = strtol(opt_arg, 0, 10); } - else if (strcmp(opt_name, "rd") == 0) { - if (!opt_arg) { - error("optional argument (/rd:num) is missing."); - } - g_front_end_params->m_random_var_freq = static_cast(strtol(opt_arg, 0, 10)) / 100.0; - } - else if (strcmp(opt_name, "rs") == 0) { - if (!opt_arg) { - error("optional argument (/rs:num) is missing."); - } - long seed = strtol(opt_arg, 0, 10); - g_front_end_params->m_random_seed = seed; - g_front_end_params->m_arith_random_seed = seed; - } else if (strcmp(opt_name, "T") == 0) { if (!opt_arg) error("option argument (/T:timeout) is missing."); @@ -382,7 +366,7 @@ int main(int argc, char ** argv) { return_value = read_smtlib2_commands(g_input_file, *g_front_end_params); break; case IN_DIMACS: - return_value = read_dimacs(g_input_file, *g_front_end_params); + return_value = read_dimacs(g_input_file); break; case IN_DATALOG: read_datalog(g_input_file, *g_extra_params, *g_front_end_params); From 02e763bb6bbd5796670eba9603490f16a9164673 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 20:56:40 -0800 Subject: [PATCH 19/34] env params Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 2 +- src/api/api_config_params.cpp | 2 ++ src/cmd_context/cmd_context.cpp | 2 +- src/shell/main.cpp | 16 ++--------- src/smt/asserted_formulas.cpp | 49 ++++++++++++++++----------------- src/smt/smt_context.cpp | 45 +++++++++++++++--------------- src/smt/smt_quantifier.cpp | 2 +- src/smt/smt_setup.cpp | 4 +-- src/util/env_params.cpp | 36 ++++++++++++++++++++++++ src/util/env_params.h | 32 +++++++++++++++++++++ src/util/gparams.cpp | 6 ++++ src/util/timeit.cpp | 6 ++-- src/util/util.cpp | 5 ---- src/util/util.h | 2 -- src/util/warning.h | 4 --- 15 files changed, 133 insertions(+), 80 deletions(-) create mode 100644 src/util/env_params.cpp create mode 100644 src/util/env_params.h diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 1df3c082e..277a7e702 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1784,7 +1784,7 @@ def mk_gparams_register_modules(cnames, path): mod_cmds.append((m.group(1), m.group(2))) fout.write('void gparams_register_modules() {\n') for code in cmds: - fout.write('{ param_descrs d; %s(*d); gparams::register_global(d); }\n' % code) + fout.write('{ param_descrs d; %s(d); gparams::register_global(d); }\n' % code) for (mod, code) in mod_cmds: fout.write('{ param_descrs * d = alloc(param_descrs); %s(*d); gparams::register_module("%s", d); }\n' % (code, mod)) fout.write('}\n') diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index 6adcced44..c14e68919 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -24,6 +24,7 @@ Revision History: #include"cmd_context.h" #include"symbol.h" #include"gparams.h" +#include"env_params.h" namespace api { @@ -41,6 +42,7 @@ extern "C" { LOG_Z3_global_param_set(param_id, param_value); try { gparams::set(param_id, param_value); + env_params::updt_params(); } catch (z3_exception & ex) { // The error handler is only available for contexts diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 7a06f30bf..984a535c7 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -1309,7 +1309,7 @@ void cmd_context::pop(unsigned n) { void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions) { if (m_ignore_check) return; - IF_VERBOSE(100, verbose_stream() << "check-sat..." << std::endl;); + IF_VERBOSE(100, verbose_stream() << "(started \"check-sat\")" << std::endl;); TRACE("before_check_sat", dump_assertions(tout);); if (!has_manager()) init_manager(); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index b08d02812..90473c21f 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -33,6 +33,7 @@ Revision History: #include"z3_exception.h" #include"error_codes.h" #include"gparams.h" +#include"env_params.h" typedef enum { IN_UNSPECIFIED, IN_SMTLIB, IN_SMTLIB_2, IN_DATALOG, IN_DIMACS, IN_Z3_LOG } input_kind; @@ -106,12 +107,6 @@ public: } virtual ~extra_params() {} - - // PARAM-TODO - // virtual void register_params(ini_params & p) { - // datalog_params::register_params(p); - // p.register_bool_param("STATISTICS", m_statistics, "display statistics"); - // } }; extra_params* g_extra_params = 0; @@ -123,8 +118,6 @@ void init_params() { g_front_end_params = new front_end_params(); // g_params = new ini_params(); g_extra_params = new extra_params(); - // register_verbosity_level(*g_params); - // register_warning(*g_params); // g_front_end_params->register_params(*g_params); // g_extra_params->register_params(*g_params); g_params_initialized = true; @@ -304,9 +297,6 @@ class global_state_initialiser { public: global_state_initialiser() { memory::initialize(0); -#if defined(_WINDOWS) && defined(_Z3_BUILD_PARALLEL_SMT) - memory::mem->set_threaded_mode(true); -#endif init_params(); } @@ -326,8 +316,8 @@ int main(int argc, char ** argv) { global_state_initialiser global_state; memory::exit_when_out_of_memory(true, "ERROR: out of memory"); parse_cmd_line_args(argc, argv); - memory::set_high_watermark(static_cast(g_front_end_params->m_memory_high_watermark) * 1024 * 1024); - memory::set_max_size(static_cast(g_front_end_params->m_memory_max_size) * 1024 * 1024); + env_params::updt_params(); + g_front_end_params->open_trace_file(); if (g_input_file && g_standard_input) { error("using standard input to read formula."); diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index c548eca94..513aa7634 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -248,7 +248,6 @@ void asserted_formulas::reduce() { if (m_macro_manager.has_macros()) expand_macros(); TRACE("before_reduce", display(tout);); - IF_VERBOSE(10000, verbose_stream() << "total size: " << get_total_size() << "\n";); CASSERT("well_sorted", check_well_sorted()); #define INVOKE(COND, FUNC) if (COND) { FUNC; IF_VERBOSE(10000, verbose_stream() << "total size: " << get_total_size() << "\n";); } TRACE("reduce_step_ll", ast_mark visited; display_ll(tout, visited);); TRACE("reduce_step", display(tout << #FUNC << " ");); CASSERT("well_sorted",check_well_sorted()); if (inconsistent() || canceled()) { TRACE("after_reduce", display(tout);); TRACE("after_reduce_ll", ast_mark visited; display_ll(tout, visited);); return; } @@ -280,7 +279,7 @@ void asserted_formulas::reduce() { CASSERT("well_sorted",check_well_sorted()); - IF_VERBOSE(10, verbose_stream() << "simplifier done.\n";); + IF_VERBOSE(10, verbose_stream() << "(smt.simplifier-done)\n";); TRACE("after_reduce", display(tout);); TRACE("after_reduce_ll", ast_mark visited; display_ll(tout, visited);); TRACE("macros", m_macro_manager.display(tout);); @@ -288,7 +287,7 @@ void asserted_formulas::reduce() { } void asserted_formulas::eliminate_and() { - IF_IVERBOSE(10, verbose_stream() << "eliminating and...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.eliminating-and)\n";); set_eliminate_and(true); reduce_asserted_formulas(); TRACE("after_elim_and", display(tout);); @@ -393,19 +392,19 @@ void asserted_formulas::find_macros_core() { } void asserted_formulas::find_macros() { - IF_IVERBOSE(10, verbose_stream() << "trying to find macros...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.find-macros)\n";); TRACE("before_find_macros", display(tout);); find_macros_core(); TRACE("after_find_macros", display(tout);); } void asserted_formulas::expand_macros() { - IF_IVERBOSE(10, verbose_stream() << "expanding macros...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.expand-macros)\n";); find_macros_core(); } void asserted_formulas::apply_quasi_macros() { - IF_IVERBOSE(10, verbose_stream() << "finding quasi macros...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.find-quasi-macros)\n";); TRACE("before_quasi_macros", display(tout);); expr_ref_vector new_exprs(m_manager); proof_ref_vector new_prs(m_manager); @@ -423,7 +422,7 @@ void asserted_formulas::apply_quasi_macros() { } void asserted_formulas::nnf_cnf() { - IF_IVERBOSE(10, verbose_stream() << "applying nnf...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.nnf)\n";); nnf apply_nnf(m_manager, m_defined_names); expr_ref_vector new_exprs(m_manager); proof_ref_vector new_prs(m_manager); @@ -471,7 +470,7 @@ void asserted_formulas::nnf_cnf() { #define MK_SIMPLE_SIMPLIFIER(NAME, FUNCTOR_DEF, LABEL, MSG) \ void asserted_formulas::NAME() { \ - IF_IVERBOSE(10, verbose_stream() << MSG << "...\n";); \ + IF_IVERBOSE(10, verbose_stream() << "(smt." << MSG << ")\n";); \ TRACE(LABEL, tout << "before:\n"; display(tout);); \ FUNCTOR_DEF; \ expr_ref_vector new_exprs(m_manager); \ @@ -503,16 +502,16 @@ void asserted_formulas::NAME() { TRACE(LABEL, display(tout);); \ } -MK_SIMPLE_SIMPLIFIER(apply_distribute_forall, distribute_forall functor(m_manager, *m_bsimp), "distribute_forall", "distribute forall"); +MK_SIMPLE_SIMPLIFIER(apply_distribute_forall, distribute_forall functor(m_manager, *m_bsimp), "distribute_forall", "distribute-forall"); void asserted_formulas::reduce_and_solve() { - IF_IVERBOSE(10, verbose_stream() << "reducing...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.reducing)\n";); flush_cache(); // collect garbage reduce_asserted_formulas(); } void asserted_formulas::infer_patterns() { - IF_IVERBOSE(10, verbose_stream() << "pattern inference...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.pattern-inference)\n";); TRACE("before_pattern_inference", display(tout);); pattern_inference infer(m_manager, m_params); expr_ref_vector new_exprs(m_manager); @@ -546,7 +545,7 @@ void asserted_formulas::commit() { } void asserted_formulas::eliminate_term_ite() { - IF_IVERBOSE(10, verbose_stream() << "eliminating ite term...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.eliminating-ite-term)\n";); TRACE("before_elim_term_ite", display(tout);); elim_term_ite elim(m_manager, m_defined_names); expr_ref_vector new_exprs(m_manager); @@ -583,7 +582,7 @@ void asserted_formulas::eliminate_term_ite() { } void asserted_formulas::propagate_values() { - IF_IVERBOSE(10, verbose_stream() << "constant propagation...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.constant-propagation)\n";); TRACE("propagate_values", tout << "before:\n"; display(tout);); flush_cache(); bool found = false; @@ -661,7 +660,7 @@ void asserted_formulas::propagate_booleans() { flush_cache(); while (cont) { TRACE("propagate_booleans", tout << "before:\n"; display(tout);); - IF_IVERBOSE(10, verbose_stream() << "boolean propagation...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.propagate-booleans)\n";); cont = false; unsigned i = m_asserted_qhead; unsigned sz = m_asserted_formulas.size(); @@ -704,7 +703,7 @@ void asserted_formulas::propagate_booleans() { #define MK_SIMPLIFIER(NAME, FUNCTOR, TAG, MSG, REDUCE) \ bool asserted_formulas::NAME() { \ - IF_IVERBOSE(10, verbose_stream() << MSG << "...\n";); \ + IF_IVERBOSE(10, verbose_stream() << "(smt." << MSG << ")\n";); \ TRACE(TAG, ast_mark visited; display_ll(tout, visited);); \ FUNCTOR; \ bool changed = false; \ @@ -741,9 +740,9 @@ bool asserted_formulas::NAME() { \ return changed; \ } -MK_SIMPLIFIER(pull_cheap_ite_trees, pull_cheap_ite_tree_star functor(m_manager, m_simplifier), "pull_cheap_ite_trees", "pull cheap ite trees", false); +MK_SIMPLIFIER(pull_cheap_ite_trees, pull_cheap_ite_tree_star functor(m_manager, m_simplifier), "pull_cheap_ite_trees", "pull-cheap-ite-trees", false); -MK_SIMPLIFIER(pull_nested_quantifiers, pull_nested_quant functor(m_manager), "pull_nested_quantifiers", "pull nested quantifiers", false); +MK_SIMPLIFIER(pull_nested_quantifiers, pull_nested_quant functor(m_manager), "pull_nested_quantifiers", "pull-nested-quantifiers", false); proof * asserted_formulas::get_inconsistency_proof() const { if (!inconsistent()) @@ -761,7 +760,7 @@ proof * asserted_formulas::get_inconsistency_proof() const { } void asserted_formulas::refine_inj_axiom() { - IF_IVERBOSE(10, verbose_stream() << "refining injectivity...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.refine-injectivity)\n";); TRACE("inj_axiom", display(tout);); unsigned i = m_asserted_qhead; unsigned sz = m_asserted_formulas.size(); @@ -783,9 +782,9 @@ void asserted_formulas::refine_inj_axiom() { TRACE("inj_axiom", display(tout);); } -MK_SIMPLIFIER(apply_bit2int, bit2int& functor = m_bit2int, "bit2int", "propagate bit-vector over integers", true); +MK_SIMPLIFIER(apply_bit2int, bit2int& functor = m_bit2int, "bit2int", "propagate-bit-vector-over-integers", true); -MK_SIMPLIFIER(cheap_quant_fourier_motzkin, elim_bounds_star functor(m_manager), "elim_bounds", "cheap fourier-motzkin", true); +MK_SIMPLIFIER(cheap_quant_fourier_motzkin, elim_bounds_star functor(m_manager), "elim_bounds", "cheap-fourier-motzkin", true); // MK_SIMPLIFIER(quant_elim, qe::expr_quant_elim_star1 &functor = m_quant_elim, // "quantifiers", "quantifier elimination procedures", true); @@ -795,11 +794,11 @@ bool asserted_formulas::quant_elim() { return false; } -MK_SIMPLIFIER(elim_bvs_from_quantifiers, bv_elim_star functor(m_manager), "bv_elim", "eliminate bit-vectors from quantifiers", true); +MK_SIMPLIFIER(elim_bvs_from_quantifiers, bv_elim_star functor(m_manager), "bv_elim", "eliminate-bit-vectors-from-quantifiers", true); #define LIFT_ITE(NAME, FUNCTOR, MSG) \ void asserted_formulas::NAME() { \ - IF_IVERBOSE(10, verbose_stream() << MSG;); \ + IF_IVERBOSE(10, verbose_stream() << "(smt." << MSG << ")\n";); \ TRACE("lift_ite", display(tout);); \ FUNCTOR; \ unsigned i = m_asserted_qhead; \ @@ -822,8 +821,8 @@ void asserted_formulas::NAME() { reduce_and_solve(); \ } -LIFT_ITE(lift_ite, push_app_ite functor(m_simplifier, m_params.m_lift_ite == LI_CONSERVATIVE), "lifting ite...\n"); -LIFT_ITE(ng_lift_ite, ng_push_app_ite functor(m_simplifier, m_params.m_ng_lift_ite == LI_CONSERVATIVE), "lifting ng ite...\n"); +LIFT_ITE(lift_ite, push_app_ite functor(m_simplifier, m_params.m_lift_ite == LI_CONSERVATIVE), "lifting ite"); +LIFT_ITE(ng_lift_ite, ng_push_app_ite functor(m_simplifier, m_params.m_ng_lift_ite == LI_CONSERVATIVE), "lifting ng ite"); unsigned asserted_formulas::get_total_size() const { expr_mark visited; @@ -835,7 +834,7 @@ unsigned asserted_formulas::get_total_size() const { } void asserted_formulas::max_bv_sharing() { - IF_IVERBOSE(10, verbose_stream() << "maximizing bv sharing...\n";); + IF_IVERBOSE(10, verbose_stream() << "(smt.maximizing-bv-sharing)\n";); TRACE("bv_sharing", display(tout);); unsigned i = m_asserted_qhead; unsigned sz = m_asserted_formulas.size(); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index c51a1ebc1..1aae1c62a 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -2488,7 +2488,7 @@ namespace smt { SASSERT(check_clauses(m_lemmas)); SASSERT(check_clauses(m_aux_clauses)); - IF_VERBOSE(2, verbose_stream() << "simplifying clause set... "; verbose_stream().flush();); + IF_VERBOSE(2, verbose_stream() << "(smt.simplifying-clause-set"; verbose_stream().flush();); // m_simp_counter is used to balance the cost of simplify_clause. // @@ -2503,8 +2503,7 @@ namespace smt { // the field m_simp_qhead is used to check whether there are // new assigned literals at the base level. m_simp_qhead = m_assigned_literals.size(); - - unsigned num_clauses = m_aux_clauses.size() + m_lemmas.size(); + unsigned num_del_clauses = 0; SASSERT(m_scope_lvl == m_base_lvl); @@ -2519,7 +2518,7 @@ namespace smt { num_del_clauses += simplify_clauses(m_lemmas, bs.m_lemmas_lim); } TRACE("simp_counter", tout << "simp_counter: " << m_simp_counter << " scope_lvl: " << m_scope_lvl << "\n";); - IF_VERBOSE(2, verbose_stream() << "num. deleted clauses: " << num_del_clauses << " (out of " << num_clauses << ")" << std::endl;); + IF_VERBOSE(2, verbose_stream() << " :num-deleted-clauses " << num_del_clauses << ")" << std::endl;); TRACE("simplify_clauses_detail", tout << "after:\n"; display_clauses(tout, m_lemmas);); SASSERT(check_clauses(m_lemmas) && check_clauses(m_aux_clauses)); } @@ -2551,7 +2550,7 @@ namespace smt { SASSERT(start_at <= sz); if (start_at + m_fparams.m_recent_lemmas_size >= sz) return; - IF_VERBOSE(2, verbose_stream() << "deleting inactive lemmas... "; verbose_stream().flush();); + IF_VERBOSE(2, verbose_stream() << "(smt.delete-inactive-lemmas"; verbose_stream().flush();); SASSERT (m_fparams.m_recent_lemmas_size < sz); unsigned end_at = sz - m_fparams.m_recent_lemmas_size; SASSERT(start_at < end_at); @@ -2595,7 +2594,7 @@ namespace smt { cls->set_activity(cls->get_activity() / m_fparams.m_clause_decay); } } - IF_VERBOSE(2, verbose_stream() << "num. deleted clauses: " << num_del_cls << " (out of " << sz << ")" << std::endl;); + IF_VERBOSE(2, verbose_stream() << " :num-deleted-clauses " << num_del_cls << ")" << std::endl;); } /** @@ -2606,7 +2605,7 @@ namespace smt { depends on which group the clauses is in. */ void context::del_inactive_lemmas2() { - IF_VERBOSE(2, verbose_stream() << "deleting inactive clauses... "; verbose_stream().flush();); + IF_VERBOSE(2, verbose_stream() << "(smt.delete-inactive-clauses "; verbose_stream().flush();); unsigned sz = m_lemmas.size(); unsigned start_at = m_base_lvl == 0 ? 0 : m_base_scopes[m_base_lvl - 1].m_lemmas_lim; SASSERT(start_at <= sz); @@ -2645,7 +2644,7 @@ namespace smt { } SASSERT(j <= sz); m_lemmas.shrink(j); - IF_VERBOSE(2, verbose_stream() << "num. deleted clauses: " << num_del_cls << " (out of " << sz << ")" << std::endl;); + IF_VERBOSE(2, verbose_stream() << " :num-deleted-clauses " << num_del_cls << ")" << std::endl;); } /** @@ -2786,7 +2785,7 @@ namespace smt { } void context::assert_expr(expr * e, proof * pr) { - timeit tt(get_verbosity_level() >= 100, "simplifying"); + timeit tt(get_verbosity_level() >= 100, "smt.simplifying"); assert_expr_core(e, pr); } @@ -2800,7 +2799,7 @@ namespace smt { void context::internalize_assertions() { TRACE("internalize_assertions", tout << "internalize_assertions()...\n";); - timeit tt(get_verbosity_level() >= 100, "preprocessing"); + timeit tt(get_verbosity_level() >= 100, "smt.preprocessing"); reduce_assertions(); if (!m_asserted_formulas.inconsistent()) { unsigned sz = m_asserted_formulas.get_num_formulas(); @@ -3158,7 +3157,7 @@ namespace smt { exit(1); } #endif - timeit tt(get_verbosity_level() >= 100, "searching"); + timeit tt(get_verbosity_level() >= 100, "smt.stats"); scoped_mk_model smk(*this); SASSERT(at_search_level()); TRACE("search", display(tout); display_enodes_lbls(tout);); @@ -3166,7 +3165,7 @@ namespace smt { init_search(); flet l(m_searching, true); TRACE("after_init_search", display(tout);); - IF_VERBOSE(2, verbose_stream() << "searching...\n";); + IF_VERBOSE(2, verbose_stream() << "(smt.searching)\n";); TRACE("search_lite", tout << "searching...\n";); lbool status = l_undef; unsigned curr_lvl = m_scope_lvl; @@ -3215,16 +3214,16 @@ namespace smt { inc_limits(); if (force_restart || !m_fparams.m_restart_adaptive || m_agility < m_fparams.m_restart_agility_threshold) { SASSERT(!inconsistent()); - IF_VERBOSE(1, verbose_stream() << "restarting... propagations: " << m_stats.m_num_propagations - << ", decisions: " << m_stats.m_num_decisions - << ", conflicts: " << m_stats.m_num_conflicts << ", restart: " << m_restart_threshold; + IF_VERBOSE(1, verbose_stream() << "(smt.restarting :propagations " << m_stats.m_num_propagations + << " :decisions " << m_stats.m_num_decisions + << " :conflicts " << m_stats.m_num_conflicts << " :restart " << m_restart_threshold; if (m_fparams.m_restart_strategy == RS_IN_OUT_GEOMETRIC) { - verbose_stream() << ", restart-outer: " << m_restart_outer_threshold; + verbose_stream() << " :restart-outer " << m_restart_outer_threshold; } if (m_fparams.m_restart_adaptive) { - verbose_stream() << ", agility: " << m_agility; + verbose_stream() << " :agility " << m_agility; } - verbose_stream() << std::endl; verbose_stream().flush();); + verbose_stream() << ")" << std::endl; verbose_stream().flush();); // execute the restart m_stats.m_num_restarts++; if (m_scope_lvl > curr_lvl) { @@ -3259,12 +3258,12 @@ namespace smt { void context::tick(unsigned & counter) const { counter++; if (counter > m_fparams.m_tick) { - IF_VERBOSE(3, verbose_stream() << "working..."; - verbose_stream() << " num. conflicts: " << m_num_conflicts; + IF_VERBOSE(3, verbose_stream() << "(smt.working"; + verbose_stream() << " :conflicts " << m_num_conflicts; // verbose_stream() << " lemma avg. activity: " << get_lemma_avg_activity(); if (m_fparams.m_restart_adaptive) - verbose_stream() << " agility: " << m_agility; - verbose_stream() << std::endl; verbose_stream().flush();); + verbose_stream() << " :agility " << m_agility; + verbose_stream() << ")" << std::endl; verbose_stream().flush();); TRACE("assigned_literals_per_lvl", display_num_assigned_literals_per_lvl(tout); tout << "\n";); counter = 0; } @@ -3410,7 +3409,7 @@ namespace smt { final_check_status ok; if (m_final_check_idx < num_th) { theory * th = m_theory_set[m_final_check_idx]; - IF_VERBOSE(100, verbose_stream() << "final check '" << th->get_name() << "' ...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.final-check \"" << th->get_name() << "\")\n";); ok = th->final_check_eh(); TRACE("final_check_step", tout << "final check '" << th->get_name() << " ok: " << ok << " inconsistent " << inconsistent() << "\n";); if (ok == FC_GIVEUP) { diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index c11f226ed..e6d81d3d2 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -211,7 +211,7 @@ namespace smt { final_check_status final_check_eh(bool full) { if (full) { - IF_VERBOSE(100, verbose_stream() << "final check 'quantifiers'...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.final-check \"quantifiers\")\n";); final_check_status result = m_qi_queue.final_check_eh() ? FC_DONE : FC_CONTINUE; final_check_status presult = m_plugin->final_check_eh(full); if (presult != FC_DONE) diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index 67c94808e..ac080ccaa 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -118,7 +118,7 @@ namespace smt { void setup::setup_auto_config() { static_features st(m_manager); - IF_VERBOSE(100, verbose_stream() << "configuring...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.configuring)\n";); TRACE("setup", tout << "setup, logic: " << m_logic << "\n";); // HACK: do not collect features for QF_BV and QF_AUFBV... since they do not use them... if (m_logic == "QF_BV") { @@ -128,7 +128,7 @@ namespace smt { setup_QF_AUFBV(); } else { - IF_VERBOSE(100, verbose_stream() << "collecting features...\n";); + IF_VERBOSE(100, verbose_stream() << "(smt.collecting-features)\n";); st.collect(m_context.get_num_asserted_formulas(), m_context.get_asserted_formulas()); IF_VERBOSE(1000, st.display_primitive(verbose_stream());); if (m_logic == "QF_UF") diff --git a/src/util/env_params.cpp b/src/util/env_params.cpp new file mode 100644 index 000000000..cf1d31b85 --- /dev/null +++ b/src/util/env_params.cpp @@ -0,0 +1,36 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + env_params.cpp + +Abstract: + + Goodies for updating environment parameters. + +Author: + + Leonardo (leonardo) 2012-12-01 + +Notes: + +--*/ +#include"env_params.h" +#include"params.h" +#include"gparams.h" +#include"util.h" +#include"memory_manager.h" + +void env_params::updt_params() { + params_ref p = gparams::get(); + set_verbosity_level(p.get_uint("verbose", 0)); + enable_warning_messages(p.get_bool("warning", true)); + memory::set_max_size(p.get_uint("memory_max_size", 0)); +} + +void env_params::collect_param_descrs(param_descrs & d) { + d.insert("verbose", CPK_UINT, "be verbose, where the value is the verbosity level", "0"); + d.insert("warning", CPK_BOOL, "enable/disable warning messages", "true"); + d.insert("memory_max_size", CPK_UINT, "set hard upper limit for memory consumption (in megabytes), if 0 then there is no bound.", "0"); +} diff --git a/src/util/env_params.h b/src/util/env_params.h new file mode 100644 index 000000000..8b5fa7005 --- /dev/null +++ b/src/util/env_params.h @@ -0,0 +1,32 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + env_params.h + +Abstract: + + Goodies for updating environment parameters. + +Author: + + Leonardo (leonardo) 2012-12-01 + +Notes: + +--*/ +#ifndef _ENV_PARAMS_H_ +#define _ENV_PARAMS_H_ + +class param_descrs; + +struct env_params { + static void updt_params(); + static void collect_param_descrs(param_descrs & p); + /* + REG_PARAMS('env_params::collect_param_descrs') + */ +}; + +#endif diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index e7b2a52eb..29377eb8d 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -18,6 +18,7 @@ Notes: --*/ #include"gparams.h" #include"dictionary.h" +#include"trace.h" extern void gparams_register_modules(); @@ -291,6 +292,7 @@ public: params_ref get() { params_ref result; + TRACE("gparams", tout << "get() m_params: " << m_params << "\n";); #pragma omp critical (gparams) { result = m_params; @@ -303,6 +305,7 @@ public: gparams::imp * gparams::g_imp = 0; void gparams::set(char const * name, char const * value) { + TRACE("gparams", tout << "setting [" << name << "] <- '" << value << "'\n";); SASSERT(g_imp != 0); g_imp->set(name, value); } @@ -342,6 +345,7 @@ params_ref gparams::get_module(symbol const & module_name) { } params_ref gparams::get() { + TRACE("gparams", tout << "gparams::get()\n";); SASSERT(g_imp != 0); return g_imp->get(); } @@ -352,11 +356,13 @@ void gparams::display(std::ostream & out, unsigned indent, bool smt2_style) { } void gparams::init() { + TRACE("gparams", tout << "gparams::init()\n";); g_imp = alloc(imp); gparams_register_modules(); } void gparams::finalize() { + TRACE("gparams", tout << "gparams::finalize()\n";); if (g_imp != 0) { dealloc(g_imp); g_imp = 0; diff --git a/src/util/timeit.cpp b/src/util/timeit.cpp index 975dd3127..5246beced 100644 --- a/src/util/timeit.cpp +++ b/src/util/timeit.cpp @@ -38,9 +38,9 @@ struct timeit::imp { ~imp() { m_watch.stop(); double end_memory = static_cast(memory::get_allocation_size())/static_cast(1024*1024); - m_out << m_msg << ", time: " << std::fixed << std::setprecision(2) << m_watch.get_seconds() - << " secs, memory: (before " << std::fixed << std::setprecision(2) << m_start_memory - << ", after " << std::fixed << std::setprecision(2) << end_memory << ")" + m_out << "(" << m_msg << " :time " << std::fixed << std::setprecision(2) << m_watch.get_seconds() + << " :before-memory " << std::fixed << std::setprecision(2) << m_start_memory + << " :after-memory " << std::fixed << std::setprecision(2) << end_memory << ")" << std::endl; } }; diff --git a/src/util/util.cpp b/src/util/util.cpp index 3e5ced813..eb9acb385 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -29,11 +29,6 @@ unsigned get_verbosity_level() { return g_verbosity_level; } -void register_verbosity_level() { - // PARAM-TODO - // p.register_unsigned_param("VERBOSE", g_verbosity_level, "be verbose, where the value is the verbosity level", true); -} - static std::ostream* g_verbose_stream = &std::cerr; void set_verbose_stream(std::ostream& str) { diff --git a/src/util/util.h b/src/util/util.h index 5e51d8ef1..945d259f9 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -157,8 +157,6 @@ struct delete_proc { void set_verbosity_level(unsigned lvl); unsigned get_verbosity_level(); -class ini_params; -void register_verbosity_level(ini_params & p); std::ostream& verbose_stream(); void set_verbose_stream(std::ostream& str); diff --git a/src/util/warning.h b/src/util/warning.h index 6800c1f95..a556bfb60 100644 --- a/src/util/warning.h +++ b/src/util/warning.h @@ -21,8 +21,6 @@ Revision History: #include #include -class ini_params; - void send_warnings_to_stdout(bool flag); void enable_warning_messages(bool flag); @@ -33,8 +31,6 @@ void set_warning_stream(std::ostream* strm); void warning_msg(const char * msg, ...); -void register_warning(ini_params & p); - void disable_error_msg_prefix(); void format2ostream(std::ostream& out, char const* fmt, va_list args); From f15de18c4a6041d8f752f0606f2c30f903a00db7 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 22:53:55 -0800 Subject: [PATCH 20/34] context params Signed-off-by: Leonardo de Moura --- src/cmd_context/basic_cmds.cpp | 3 + src/cmd_context/cmd_context.cpp | 49 +++++----- src/cmd_context/cmd_context.h | 7 +- src/cmd_context/context_params.cpp | 114 ++++++++++++++++++++++ src/cmd_context/context_params.h | 52 ++++++++++ src/front_end_params/front_end_params.cpp | 5 - src/shell/datalog_frontend.h | 1 - src/shell/main.cpp | 3 - src/solver/strategic_solver.cpp | 2 - src/util/env_params.cpp | 2 +- src/util/gparams.cpp | 4 +- 11 files changed, 204 insertions(+), 38 deletions(-) create mode 100644 src/cmd_context/context_params.cpp create mode 100644 src/cmd_context/context_params.h diff --git a/src/cmd_context/basic_cmds.cpp b/src/cmd_context/basic_cmds.cpp index d3861257b..df9efc4dd 100644 --- a/src/cmd_context/basic_cmds.cpp +++ b/src/cmd_context/basic_cmds.cpp @@ -29,6 +29,7 @@ Notes: #include"eval_cmd.h" #include"gparams.h" #include"model_params.hpp" +#include"env_params.h" class help_cmd : public cmd { svector m_cmds; @@ -305,6 +306,8 @@ class set_option_cmd : public set_get_option_cmd { void set_param(cmd_context & ctx, char const * value) { try { gparams::set(m_option, value); + env_params::updt_params(); + ctx.params().updt_params(); } catch (gparams::exception ex) { throw cmd_exception(ex.msg()); diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 984a535c7..1a018a41d 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -359,48 +359,43 @@ cmd_context::~cmd_context() { } void cmd_context::set_produce_models(bool f) { - // PARAM-TODO - // params().m_model = f; if (m_solver) m_solver->set_produce_models(f); + m_params.m_model = f; } void cmd_context::set_produce_unsat_cores(bool f) { // can only be set before initialization SASSERT(!has_manager()); - m_produce_unsat_cores = f; + m_params.m_unsat_core = f; } void cmd_context::set_produce_proofs(bool f) { - // PARAM-TODO // can only be set before initialization SASSERT(!has_manager()); - // params().m_proof_mode = f ? PGM_FINE : PGM_DISABLED; + m_params.m_proof = f; } bool cmd_context::produce_models() const { - // PARAM-TODO - // return params().m_model; - return true; + return m_params.m_model; } bool cmd_context::produce_proofs() const { - // PARAM-TODO - // return params().m_proof_mode != PGM_DISABLED; - return false; + return m_params.m_proof; +} + +bool cmd_context::produce_unsat_cores() const { + return m_params.m_unsat_core; } bool cmd_context::well_sorted_check_enabled() const { - // PARAM-TODO - return true; + return m_params.m_well_sorted_check; } bool cmd_context::validate_model_enabled() const { - // PARAM-TODO - return false; + return m_params.m_validate_model; } - cmd_context::check_sat_state cmd_context::cs_state() const { if (m_check_sat_result.get() == 0) return css_clear; @@ -593,10 +588,7 @@ void cmd_context::init_manager_core(bool new_manager) { insert(pm().mk_plist_decl()); } if (m_solver) { - m_solver->set_produce_unsat_cores(produce_unsat_cores()); - m_solver->set_produce_models(produce_models()); - m_solver->set_produce_proofs(produce_proofs()); - m_solver->init(m(), m_logic); + init_solver_options(m_solver.get()); } m_check_logic.set_logic(m(), m_logic); } @@ -1455,14 +1447,23 @@ void cmd_context::validate_model() { } } +void cmd_context::init_solver_options(solver * s) { + m_solver->set_produce_unsat_cores(produce_unsat_cores()); + m_solver->set_produce_models(produce_models()); + m_solver->set_produce_proofs(produce_proofs()); + m_solver->init(m(), m_logic); + if (!m_params.m_auto_config) { + params_ref p; + p.set_bool("auto_config", false); + m_solver->updt_params(p); + } +} + void cmd_context::set_solver(solver * s) { m_check_sat_result = 0; m_solver = s; if (has_manager() && s != 0) { - m_solver->set_produce_unsat_cores(produce_unsat_cores()); - m_solver->set_produce_models(produce_models()); - m_solver->set_produce_proofs(produce_proofs()); - m_solver->init(m(), m_logic); + init_solver_options(s); // assert formulas and create scopes in the new solver. unsigned lim = 0; svector::iterator it = m_scopes.begin(); diff --git a/src/cmd_context/cmd_context.h b/src/cmd_context/cmd_context.h index c2acba0dc..ae517b0c2 100644 --- a/src/cmd_context/cmd_context.h +++ b/src/cmd_context/cmd_context.h @@ -36,6 +36,7 @@ Notes: #include"check_logic.h" #include"progress_callback.h" #include"scoped_ptr_vector.h" +#include"context_params.h" /** \brief Auxiliary function for converting SMT2 keywords into Z3 internal parameter names. @@ -135,6 +136,7 @@ public: }; protected: + context_params m_params; bool m_main_ctx; symbol m_logic; bool m_interactive_mode; @@ -246,9 +248,12 @@ protected: void print_unsupported_msg() { regular_stream() << "unsupported" << std::endl; } void print_unsupported_info(symbol const& s) { if (s != symbol::null) diagnostic_stream() << "; " << s << std::endl;} + void init_solver_options(solver * s); + public: cmd_context(bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null); ~cmd_context(); + context_params & params() { return m_params; } void set_logic(symbol const & s); bool has_logic() const { return m_logic != symbol::null; } symbol const & get_logic() const { return m_logic; } @@ -270,7 +275,7 @@ public: void set_random_seed(unsigned s) { m_random_seed = s; } bool produce_models() const; bool produce_proofs() const; - bool produce_unsat_cores() const { return m_produce_unsat_cores; } + bool produce_unsat_cores() const; bool well_sorted_check_enabled() const; bool validate_model_enabled() const; void set_produce_models(bool flag); diff --git a/src/cmd_context/context_params.cpp b/src/cmd_context/context_params.cpp new file mode 100644 index 000000000..c7efa0d8d --- /dev/null +++ b/src/cmd_context/context_params.cpp @@ -0,0 +1,114 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + context_params.cpp + +Abstract: + + Goodies for managing context parameters in the cmd_context and + api_context + +Author: + + Leonardo (leonardo) 2012-12-01 + +Notes: + +--*/ +#include"context_params.h" +#include"gparams.h" +#include"params.h" + +context_params::context_params() { + updt_params(); +} + +void context_params::set_bool(bool & opt, char const * param, char const * value) { + if (strcmp(value, "true") == 0) { + opt = true; + } + else if (strcmp(value, "false") == 0) { + opt = false; + } + else { + throw default_exception("invalid value '%s' for Boolean parameter '%s'", value, param); + } +} + +void context_params::set(char const * param, char const * value) { + std::string p = param; + unsigned n = p.size(); + for (unsigned i = 0; i < n; i++) { + if (p[i] >= 'A' && p[i] <= 'Z') + p[i] = p[i] - 'A' + 'a'; + else if (p[i] == '-') + p[i] = '_'; + } + if (p == "timeout") { + long val = strtol(value, 0, 10); + m_timeout = static_cast(val); + } + else if (p == "type_check" || p == "well_sorted_check") { + set_bool(m_well_sorted_check, param, value); + } + else if (p == "auto_config") { + set_bool(m_auto_config, param, value); + } + else if (p == "proof") { + set_bool(m_proof, param, value); + } + else if (p == "model") { + set_bool(m_model, param, value); + } + else if (p == "validate_model") { + set_bool(m_validate_model, param, value); + } + else if (p == "trace") { + set_bool(m_trace, param, value); + } + else if (p == "trace_file_name") { + m_trace_file_name = value; + } + else if (p == "unsat_core") { + set_bool(m_unsat_core, param, value); + } + else if (p == "debug_ref_count") { + set_bool(m_debug_ref_count, param, value); + } + else { + throw default_exception("unknown parameter '%s'", p.c_str()); + } +} + +void context_params::updt_params() { + updt_params(gparams::get()); +} + +void context_params::updt_params(params_ref const & p) { + m_timeout = p.get_uint("timeout", UINT_MAX); + m_well_sorted_check = p.get_bool("type_check", p.get_bool("well_sorted_check", true)); + m_auto_config = p.get_bool("auto_config", true); + m_proof = p.get_bool("proof", false); + m_model = p.get_bool("model", true); + m_validate_model = p.get_bool("validate_model", false); + m_trace = p.get_bool("trace", false); + m_trace_file_name = p.get_str("trace_file_name", "z3.log"); + m_unsat_core = p.get_bool("unsat_core", false); + m_debug_ref_count = p.get_bool("debug_ref_count", false); +} + +void context_params::collect_param_descrs(param_descrs & d) { + d.insert("timeout", CPK_UINT, "default timeout (in milliseconds) used for solvers", "4294967295"); + d.insert("well_sorted_check", CPK_BOOL, "type checker", "true"); + d.insert("type_check", CPK_BOOL, "type checker (alias for well_sorted_check)", "true"); + d.insert("auto_config", CPK_BOOL, "use heuristics to automatically select solver and configure it", "true"); + d.insert("proof", CPK_BOOL, "proof generation, it must be enabled when the Z3 context is created", "false"); + d.insert("model", CPK_BOOL, "model generation for solvers, this parameter can be overwritten when creating a solver", "true"); + d.insert("validate_model", CPK_BOOL, "validate models produced by solvers", "false"); + d.insert("trace", CPK_BOOL, "trace generation for VCC", "false"); + d.insert("trace_file_name", CPK_STRING, "trace out file name (see option 'trace')", "z3.log"); + d.insert("unsat_core", CPK_BOOL, "unsat-core generation for solvers, this parameter can be overwritten when creating a solver, not every solver in Z3 supports unsat core generation", "false"); + d.insert("debug_ref_count", CPK_BOOL, "debug support for AST reference counting", "false"); +} diff --git a/src/cmd_context/context_params.h b/src/cmd_context/context_params.h new file mode 100644 index 000000000..556c3bd3f --- /dev/null +++ b/src/cmd_context/context_params.h @@ -0,0 +1,52 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + context_params.h + +Abstract: + + Goodies for managing context parameters in the cmd_context and + api_context + +Author: + + Leonardo (leonardo) 2012-12-01 + +Notes: + +--*/ +#ifndef _CONTEXT_PARAMS_H_ +#define _CONTEXT_PARAMS_H_ + +#include"params.h" + +class context_params { + void set_bool(bool & opt, char const * param, char const * value); + +public: + bool m_auto_config; + bool m_proof; + bool m_debug_ref_count; + bool m_trace; + std::string m_trace_file_name; + bool m_well_sorted_check; + bool m_model; + bool m_validate_model; + bool m_unsat_core; + unsigned m_timeout; + bool m_statistics; + + context_params(); + void set(char const * param, char const * value); + void updt_params(); + void updt_params(params_ref const & p); + static void collect_param_descrs(param_descrs & d); + /* + REG_PARAMS('context_params::collect_param_descrs') + */ +}; + + +#endif diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index 32692180f..f00c21d56 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -32,10 +32,6 @@ void front_end_params::register_params(ini_params & p) { p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); p.register_double_param("instruction_max", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); - p.register_bool_param("auto_config", m_auto_config, "use heuristics to set Z3 configuration parameters, it is only available for the SMT-LIB input format"); - p.register_int_param("proof_mode", 0, 2, reinterpret_cast(m_proof_mode), "select proof generation mode: 0 - disabled, 1 - coarse grain, 2 - fine grain"); - p.register_bool_param("trace", m_trace, "enable tracing for the Axiom Profiler tool"); - p.register_string_param("trace_file_name", m_trace_file_name, "tracing file name"); #ifdef _WINDOWS // The non-windows memory manager does not have access to memory sizes. @@ -47,7 +43,6 @@ void front_end_params::register_params(ini_params & p) { PRIVATE_PARAMS({ - p.register_bool_param("debug_ref_count", m_debug_ref_count); }); } diff --git a/src/shell/datalog_frontend.h b/src/shell/datalog_frontend.h index 7e08fce0e..bf4194ef4 100644 --- a/src/shell/datalog_frontend.h +++ b/src/shell/datalog_frontend.h @@ -23,7 +23,6 @@ struct datalog_params { symbol m_default_table; bool m_default_table_checked; datalog_params(); - // virtual void register_params(ini_params& p); }; unsigned read_datalog(char const * file, datalog_params const& dl_params, front_end_params & front_end_params); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 90473c21f..9cef54628 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -116,10 +116,7 @@ void init_params() { if (!g_params_initialized) { z3_bound_num_procs(); g_front_end_params = new front_end_params(); - // g_params = new ini_params(); g_extra_params = new extra_params(); - // g_front_end_params->register_params(*g_params); - // g_extra_params->register_params(*g_params); g_params_initialized = true; } } diff --git a/src/solver/strategic_solver.cpp b/src/solver/strategic_solver.cpp index 8ce098c51..40d77066e 100644 --- a/src/solver/strategic_solver.cpp +++ b/src/solver/strategic_solver.cpp @@ -99,8 +99,6 @@ void strategic_solver::updt_params(params_ref const & p) { m_inc_solver->updt_params(p); m_params = p; m_auto_config = p.get_bool("auto_config", true); - // PARAM-TODO - // PROOFS, MODELS, UNSATCORES } void strategic_solver::collect_param_descrs(param_descrs & r) { diff --git a/src/util/env_params.cpp b/src/util/env_params.cpp index cf1d31b85..a76c2308b 100644 --- a/src/util/env_params.cpp +++ b/src/util/env_params.cpp @@ -24,7 +24,7 @@ Notes: void env_params::updt_params() { params_ref p = gparams::get(); - set_verbosity_level(p.get_uint("verbose", 0)); + set_verbosity_level(p.get_uint("verbose", get_verbosity_level())); enable_warning_messages(p.get_bool("warning", true)); memory::set_max_size(p.get_uint("memory_max_size", 0)); } diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 29377eb8d..85b648a55 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -86,7 +86,9 @@ public: void display(std::ostream & out, unsigned indent, bool smt2_style) { #pragma omp critical (gparams) { - m_param_descrs.display(out, indent, smt2_style); + out << "Global parameters\n"; + m_param_descrs.display(out, indent + 4, smt2_style); + out << "\n"; dictionary::iterator it = m_module_param_descrs.begin(); dictionary::iterator end = m_module_param_descrs.end(); for (; it != end; ++it) { From 1c15e078a40c3b47016959cde4998c02366ec35d Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 1 Dec 2012 23:00:06 -0800 Subject: [PATCH 21/34] cleanup Signed-off-by: Leonardo de Moura --- src/util/warning.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/util/warning.cpp b/src/util/warning.cpp index 19c0dac90..0a1ac9bbc 100644 --- a/src/util/warning.cpp +++ b/src/util/warning.cpp @@ -82,11 +82,6 @@ void set_warning_stream(std::ostream* strm) { g_warning_stream = strm; } -void register_warning() { - // PARAM-TODO - // p.register_bool_param("WARNING", g_warning_msgs, "enable/disable warning messages", true); -} - void disable_error_msg_prefix() { g_show_error_msg_prefix = false; } From 80405dbd627b7fb14c15343301359c238dd7cbba Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 08:12:15 -0800 Subject: [PATCH 22/34] added context_params to API Signed-off-by: Leonardo de Moura --- src/api/api_ast.cpp | 2 +- src/api/api_config_params.cpp | 35 +++++++++++++++++++---------------- src/api/api_config_params.h | 34 ---------------------------------- src/api/api_context.cpp | 35 +++++++++-------------------------- src/api/api_context.h | 32 ++++++++++++++++---------------- src/api/api_datalog.cpp | 4 ++-- src/api/api_solver.cpp | 17 ++++++++++++----- src/api/z3_api.h | 15 ++++++++++----- 8 files changed, 69 insertions(+), 105 deletions(-) delete mode 100644 src/api/api_config_params.h diff --git a/src/api/api_ast.cpp b/src/api/api_ast.cpp index 45892bac3..c604927fd 100644 --- a/src/api/api_ast.cpp +++ b/src/api/api_ast.cpp @@ -675,7 +675,7 @@ extern "C" { ast_manager & m = mk_c(c)->m(); expr * a = to_expr(_a); params_ref p = to_param_ref(_p); - unsigned timeout = p.get_uint("timeout", UINT_MAX); + unsigned timeout = p.get_uint("timeout", mk_c(c)->get_timeout()); bool use_ctrl_c = p.get_bool("ctrl_c", false); th_rewriter m_rw(m, p); expr_ref result(m); diff --git a/src/api/api_config_params.cpp b/src/api/api_config_params.cpp index c14e68919..908900043 100644 --- a/src/api/api_config_params.cpp +++ b/src/api/api_config_params.cpp @@ -17,7 +17,6 @@ Revision History: --*/ #include"z3.h" #include"api_context.h" -#include"api_config_params.h" #include"pp.h" #include"api_log_macros.h" #include"api_util.h" @@ -25,16 +24,7 @@ Revision History: #include"symbol.h" #include"gparams.h" #include"env_params.h" - -namespace api { - - config_params::config_params() { - } - - config_params::config_params(front_end_params const & p):m_params(p) { - } - -}; +#include"context_params.h" extern "C" { void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value) { @@ -68,7 +58,7 @@ extern "C" { // The error handler is only available for contexts // Just throw a warning. std::ostringstream buffer; - buffer << "Error setting " << param_id << ", " << ex.msg(); + buffer << "Error setting " << param_id << ": " << ex.msg(); warning_msg(buffer.str().c_str()); return Z3_FALSE; } @@ -77,28 +67,41 @@ extern "C" { Z3_config Z3_API Z3_mk_config() { memory::initialize(UINT_MAX); LOG_Z3_mk_config(); - Z3_config r = reinterpret_cast(alloc(api::config_params)); + Z3_config r = reinterpret_cast(alloc(context_params)); RETURN_Z3(r); } void Z3_API Z3_del_config(Z3_config c) { LOG_Z3_del_config(c); - dealloc((reinterpret_cast(c))); + dealloc((reinterpret_cast(c))); } void Z3_API Z3_set_param_value(Z3_config c, char const * param_id, char const * param_value) { LOG_Z3_set_param_value(c, param_id, param_value); - // PARAM-TODO save the parameter + try { + context_params * p = reinterpret_cast(c); + p->set(param_id, param_value); + } + catch (z3_exception & ex) { + // The error handler is only available for contexts + // Just throw a warning. + std::ostringstream buffer; + buffer << "Error setting " << param_id << ": " << ex.msg(); + warning_msg(buffer.str().c_str()); + } } void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value) { + Z3_TRY; LOG_Z3_update_param_value(c, param_id, param_value); RESET_ERROR_CODE(); - // NOOP in the current version + mk_c(c)->params().set(param_id, param_value); + Z3_CATCH; } Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) { LOG_Z3_get_param_value(c, param_id, param_value); + // TODO return Z3_FALSE; } diff --git a/src/api/api_config_params.h b/src/api/api_config_params.h deleted file mode 100644 index 99ded289d..000000000 --- a/src/api/api_config_params.h +++ /dev/null @@ -1,34 +0,0 @@ -/*++ -Copyright (c) 2012 Microsoft Corporation - -Module Name: - - api_config_params.h - -Abstract: - Configuration parameters - -Author: - - Leonardo de Moura (leonardo) 2012-02-29. - -Revision History: - ---*/ -#ifndef _API_CONFIG_PARAMS_H_ -#define _API_CONFIG_PARAMS_H_ - -#include"front_end_params.h" - -namespace api { - - class config_params { - public: - front_end_params m_params; - config_params(); - config_params(front_end_params const & p); - }; - -}; - -#endif diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 11fb28a02..02069e06d 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -18,7 +18,6 @@ Revision History: --*/ #include"api_context.h" -#include"api_config_params.h" #include"smtparser.h" #include"version.h" #include"ast_pp.h" @@ -54,14 +53,6 @@ namespace api { return static_cast(f); } - context::param_ini::param_ini(front_end_params & p) : m_params(p) { - p.open_trace_file(); - } - - context::param_ini::~param_ini() { - m_params.close_trace_file(); - } - context::add_plugins::add_plugins(ast_manager & m) { reg_decl_plugins(m); } @@ -88,10 +79,10 @@ namespace api { } } - context::context(config_params * p, bool user_ref_count): - m_params(p ? p->m_params : front_end_params()), + context::context(context_params * p, bool user_ref_count): + m_params(*p), m_user_ref_count(user_ref_count), - m_manager(m_params.m_proof_mode, m_params.m_trace_stream), + m_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED), // PARAM-TODO , _fparams.m_proof_mode, m_fparams.m_trace_stream), m_plugins(m_manager), m_arith_util(m_manager), m_bv_util(m_manager), @@ -114,8 +105,6 @@ namespace api { // // Configuration parameter settings. // - memory::set_high_watermark(static_cast(m_params.m_memory_high_watermark)*1024*1024); - memory::set_max_size(static_cast(m_params.m_memory_max_size)*1024*1024); if (m_params.m_debug_ref_count) { m_manager.debug_ref_count(); } @@ -334,7 +323,8 @@ namespace api { smt::kernel & context::get_smt_kernel() { if (!m_solver) { - m_solver = alloc(smt::kernel, m_manager, m_params); + // PARAM-TODO: copy config_params -> fparams + m_solver = alloc(smt::kernel, m_manager, m_fparams); } return *m_solver; } @@ -419,15 +409,15 @@ extern "C" { Z3_context Z3_API Z3_mk_context(Z3_config c) { LOG_Z3_mk_context(c); - memory::initialize(0); - Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), false)); + memory::initialize(UINT_MAX); + Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), false)); RETURN_Z3(r); } Z3_context Z3_API Z3_mk_context_rc(Z3_config c) { LOG_Z3_mk_context_rc(c); - memory::initialize(0); - Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), true)); + memory::initialize(UINT_MAX); + Z3_context r = reinterpret_cast(alloc(api::context, reinterpret_cast(c), true)); RETURN_Z3(r); } @@ -573,11 +563,4 @@ ast_manager & Z3_API Z3_get_manager(__in Z3_context c) { return mk_c(c)->m(); } -front_end_params& Z3_API Z3_get_parameters(__in Z3_context c) { - return mk_c(c)->fparams(); -} -Z3_context Z3_mk_context_from_params(front_end_params const& p) { - api::config_params cp(p); - return reinterpret_cast(alloc(api::context, &cp)); -} diff --git a/src/api/api_context.h b/src/api/api_context.h index 76c601d60..df0f488af 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -31,28 +31,19 @@ Revision History: #include"front_end_params.h" #include"event_handler.h" #include"tactic_manager.h" +#include"context_params.h" namespace smtlib { class parser; }; namespace api { - class config_params; - Z3_search_failure mk_Z3_search_failure(smt::failure f); class context : public tactic_manager { - class param_ini { - front_end_params & m_params; - public: - param_ini(front_end_params & p); - ~param_ini(); - }; - struct add_plugins { add_plugins(ast_manager & m); }; - - front_end_params m_params; + context_params m_params; bool m_user_ref_count; //!< if true, the user is responsible for managing referenc counters. ast_manager m_manager; add_plugins m_plugins; @@ -61,8 +52,11 @@ namespace api { bv_util m_bv_util; datalog::dl_decl_util m_datalog_util; + // Support for old solver API + front_end_params m_fparams; smt::kernel * m_solver; // General purpose solver for backward compatibility - + // ------------------------------- + ast_ref_vector m_last_result; //!< used when m_user_ref_count == true ast_ref_vector m_ast_trail; //!< used when m_user_ref_count == false unsigned_vector m_ast_lim; @@ -102,11 +96,16 @@ namespace api { // // ------------------------ - context(config_params * p, bool user_ref_count = false); + context(context_params * p, bool user_ref_count = false); ~context(); - - front_end_params & fparams() { return m_params; } ast_manager & m() { return m_manager; } + + context_params & params() { return m_params; } + bool produce_proofs() const { return m_manager.proofs_enabled(); } + bool produce_models() const { return m_params.m_model; } + bool produce_unsat_cores() const { return m_params.m_unsat_core; } + bool use_auto_config() const { return m_params.m_auto_config; } + unsigned get_timeout() const { return m_params.m_timeout; } arith_util & autil() { return m_arith_util; } bv_util & bvutil() { return m_bv_util; } datalog::dl_decl_util & datalog_util() { return m_datalog_util; } @@ -167,12 +166,13 @@ namespace api { static void out_of_memory_handler(void * _ctx); void check_sorts(ast * n); + // ------------------------ // // Solver interface for backward compatibility // // ------------------------ - + front_end_params & fparams() { return m_fparams; } bool has_solver() const { return m_solver != 0; } smt::kernel & get_smt_kernel(); void assert_cnstr(expr * a); diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 34ca9627a..4c54a4332 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -265,7 +265,7 @@ extern "C" { RESET_ERROR_CODE(); lbool r = l_undef; cancel_eh eh(*to_fixedpoint_ref(d)); - unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", UINT_MAX); + unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); api::context::set_interruptable(*(mk_c(c)), eh); { scoped_timer timer(timeout, &eh); @@ -289,7 +289,7 @@ extern "C" { LOG_Z3_fixedpoint_query_relations(c, d, num_relations, relations); RESET_ERROR_CODE(); lbool r = l_undef; - unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", UINT_MAX); + unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); cancel_eh eh(*to_fixedpoint_ref(d)); api::context::set_interruptable(*(mk_c(c)), eh); { diff --git a/src/api/api_solver.cpp b/src/api/api_solver.cpp index 31901d360..67d083704 100644 --- a/src/api/api_solver.cpp +++ b/src/api/api_solver.cpp @@ -36,10 +36,17 @@ extern "C" { static void init_solver_core(Z3_context c, Z3_solver _s) { ast_manager & m = mk_c(c)->m(); Z3_solver_ref * s = to_solver(_s); - s->m_solver->set_produce_proofs(m.proofs_enabled()); - s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", false)); - s->m_solver->set_produce_models(s->m_params.get_bool("model", true)); - s->m_solver->updt_params(s->m_params); + s->m_solver->set_produce_proofs(mk_c(c)->produce_proofs()); + s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", mk_c(c)->produce_unsat_cores())); + s->m_solver->set_produce_models(s->m_params.get_bool("model", mk_c(c)->produce_models())); + if (!mk_c(c)->use_auto_config()) { + params_ref p = s->m_params; + p.set_bool("auto_config", false); + s->m_solver->updt_params(p); + } + else { + s->m_solver->updt_params(s->m_params); + } s->m_solver->init(m, s->m_logic); s->m_initialized = true; } @@ -237,7 +244,7 @@ extern "C" { } } expr * const * _assumptions = to_exprs(assumptions); - unsigned timeout = to_solver(s)->m_params.get_uint("timeout", UINT_MAX); + unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout()); bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false); cancel_eh eh(*to_solver_ref(s)); api::context::set_interruptable(*(mk_c(c)), eh); diff --git a/src/api/z3_api.h b/src/api/z3_api.h index a0c6434c2..16bf9193c 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -1308,6 +1308,12 @@ extern "C" { - debug_ref_count (Boolean) Enable debug support for Z3_ast reference counting - trace (Boolean) Tracing support for VCC - trace_file_name (String) Trace out file for VCC traces + - timeout (unsigned) default timeout (in milliseconds) used for solvers + - well_sorted_check type checker + - auto_config use heuristics to automatically select solver and configure it + - model model generation for solvers, this parameter can be overwritten when creating a solver + - validate_model validate models produced by solvers + - unsat_core unsat-core generation for solvers, this parameter can be overwritten when creating a solver \sa Z3_set_param_value \sa Z3_del_config @@ -1420,19 +1426,18 @@ extern "C" { #endif /** - \brief This is a deprecated function. This is a NOOP in the current version of Z3. + \brief Set a value of a context parameter. - \deprecated Use #Z3_global_param_set. + \sa Use #Z3_global_param_set. def_API('Z3_update_param_value', VOID, (_in(CONTEXT), _in(STRING), _in(STRING))) */ void Z3_API Z3_update_param_value(__in Z3_context c, __in Z3_string param_id, __in Z3_string param_value); /** - \brief This is a deprecated function. This is a NOOP in the current version of Z3. - It always return Z3_FALSE. + \brief Return the value of a context parameter. - \deprecated Use #Z3_global_param_get + \sa Use #Z3_global_param_get def_API('Z3_get_param_value', BOOL, (_in(CONTEXT), _in(STRING), _out(STRING))) */ From 288a96610f446aa01da0ba8aa72b070b6d26eba8 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 09:08:47 -0800 Subject: [PATCH 23/34] ported VCC trace streams Signed-off-by: Leonardo de Moura --- src/api/api_context.cpp | 2 +- src/ast/ast.cpp | 51 ++++++++++++++++++----- src/ast/ast.h | 9 +++- src/cmd_context/cmd_context.cpp | 4 +- src/front_end_params/front_end_params.cpp | 16 ------- src/front_end_params/front_end_params.h | 12 +----- src/parsers/smt/smtlib_solver.cpp | 8 ++-- src/parsers/smt/smtlib_solver.h | 6 +-- src/shell/main.cpp | 7 +--- src/shell/smtlib_frontend.cpp | 6 +-- src/shell/smtlib_frontend.h | 10 +---- src/smt/mam.cpp | 33 +++++++-------- src/smt/mam.h | 8 ++-- src/smt/qi_queue.cpp | 35 +++++++--------- src/smt/qi_queue.h | 3 +- src/smt/smt_case_split_queue.cpp | 13 ++---- src/smt/smt_conflict_resolution.cpp | 23 +++++----- src/smt/smt_context.cpp | 39 ++++++++--------- src/smt/smt_context_pp.cpp | 3 +- src/smt/smt_internalizer.cpp | 8 ++-- src/smt/smt_quantifier.cpp | 13 +++--- 21 files changed, 149 insertions(+), 160 deletions(-) diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 02069e06d..2d242f9b0 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -82,7 +82,7 @@ namespace api { context::context(context_params * p, bool user_ref_count): m_params(*p), m_user_ref_count(user_ref_count), - m_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED), // PARAM-TODO , _fparams.m_proof_mode, m_fparams.m_trace_stream), + m_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED, m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0), m_plugins(m_manager), m_arith_util(m_manager), m_bv_util(m_manager), diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 67f07e414..ae82dcadf 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -1196,13 +1196,36 @@ decl_plugin * user_sort_plugin::mk_fresh() { // // ----------------------------------- -ast_manager::ast_manager(proof_gen_mode m, std::ostream *trace_stream, bool is_format_manager): +ast_manager::ast_manager(proof_gen_mode m, char const * trace_file, bool is_format_manager): m_alloc("ast_manager"), m_expr_array_manager(*this, m_alloc), m_expr_dependency_manager(*this, m_alloc), m_expr_dependency_array_manager(*this, m_alloc), m_proof_mode(m), - m_trace_stream(trace_stream) { + m_trace_stream(0), + m_trace_stream_owner(false) { + + if (trace_file) { + m_trace_stream = alloc(std::fstream, trace_file, std::ios_base::out); + m_trace_stream_owner = true; + } + + if (!is_format_manager) + m_format_manager = alloc(ast_manager, PGM_DISABLED, m_trace_stream, true); + else + m_format_manager = 0; + init(); +} + +ast_manager::ast_manager(proof_gen_mode m, std::fstream * trace_stream, bool is_format_manager): + m_alloc("ast_manager"), + m_expr_array_manager(*this, m_alloc), + m_expr_dependency_manager(*this, m_alloc), + m_expr_dependency_array_manager(*this, m_alloc), + m_proof_mode(m), + m_trace_stream(trace_stream), + m_trace_stream_owner(false) { + if (!is_format_manager) m_format_manager = alloc(ast_manager, PGM_DISABLED, trace_stream, true); else @@ -1216,9 +1239,10 @@ ast_manager::ast_manager(ast_manager const & src, bool disable_proofs): m_expr_dependency_manager(*this, m_alloc), m_expr_dependency_array_manager(*this, m_alloc), m_proof_mode(disable_proofs ? PGM_DISABLED : src.m_proof_mode), - m_trace_stream(src.m_trace_stream) { + m_trace_stream(src.m_trace_stream), + m_trace_stream_owner(false) { SASSERT(!src.is_format_manager()); - m_format_manager = 0; + m_format_manager = alloc(ast_manager, PGM_DISABLED, m_trace_stream, true); init(); copy_families_plugins(src); } @@ -1256,6 +1280,7 @@ void ast_manager::init() { ast_manager::~ast_manager() { SASSERT(is_format_manager() || !m_family_manager.has_family(symbol("format"))); + dec_ref(m_bool_sort); dec_ref(m_proof_sort); dec_ref(m_true); @@ -1294,6 +1319,13 @@ ast_manager::~ast_manager() { #endif if (m_format_manager != 0) 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; + } } void ast_manager::compact_memory() { @@ -1873,8 +1905,8 @@ app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const new_node = new (mem) app(decl, num_args, args); r = register_node(new_node); } -#ifndef SMTCOMP - if (m_trace_stream != NULL && r == new_node) { + + if (m_trace_stream && r == new_node) { *m_trace_stream << "[mk-app] #" << r->get_id() << " "; if (r->get_num_args() == 0 && r->get_decl()->get_name() == "int") { ast_ll_pp(*m_trace_stream, *this, r); @@ -1887,7 +1919,7 @@ app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const *m_trace_stream << "\n"; } } -#endif + return r; } @@ -2064,8 +2096,7 @@ quantifier * ast_manager::mk_quantifier(bool forall, unsigned num_decls, sort * num_no_patterns, no_patterns); quantifier * r = register_node(new_node); -#ifndef SMTCOMP - if (m_trace_stream != NULL && r == new_node) { + if (m_trace_stream && r == new_node) { *m_trace_stream << "[mk-quant] #" << r->get_id() << " " << qid; for (unsigned i = 0; i < num_patterns; ++i) { *m_trace_stream << " #" << patterns[i]->get_id(); @@ -2073,7 +2104,7 @@ quantifier * ast_manager::mk_quantifier(bool forall, unsigned num_decls, sort * *m_trace_stream << " #" << body->get_id() << "\n"; } -#endif + return r; } diff --git a/src/ast/ast.h b/src/ast/ast.h index 8453598f2..2a0872721 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -1350,7 +1350,8 @@ protected: unsigned m_fresh_id; bool m_debug_ref_count; u_map m_debug_free_indices; - std::ostream* m_trace_stream; + std::fstream* m_trace_stream; + bool m_trace_stream_owner; #ifdef Z3DEBUG bool slow_not_contains(ast const * n); #endif @@ -1361,10 +1362,14 @@ protected: bool coercion_needed(func_decl * decl, unsigned num_args, expr * const * args); public: - ast_manager(proof_gen_mode = PGM_DISABLED, std::ostream * trace_stream = NULL, bool is_format_manager = false); + ast_manager(proof_gen_mode = PGM_DISABLED, char const * trace_file = 0, 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(); + bool has_trace_stream() const { return m_trace_stream != 0; } + std::ostream & trace_stream() { SASSERT(has_trace_stream()); return *m_trace_stream; } + void enable_int_real_coercions(bool f) { m_int_real_coercions = f; } bool int_real_coercions() const { return m_int_real_coercions; } diff --git a/src/cmd_context/cmd_context.cpp b/src/cmd_context/cmd_context.cpp index 1a018a41d..19fbdcd3c 100644 --- a/src/cmd_context/cmd_context.cpp +++ b/src/cmd_context/cmd_context.cpp @@ -597,7 +597,9 @@ void cmd_context::init_manager() { SASSERT(m_manager == 0); SASSERT(m_pmanager == 0); m_check_sat_result = 0; - m_manager = alloc(ast_manager, produce_proofs() ? PGM_FINE : PGM_DISABLED); // PARAM-TODO , params().m_trace_stream); + m_manager = alloc(ast_manager, + produce_proofs() ? PGM_FINE : PGM_DISABLED, + m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0); m_pmanager = alloc(pdecl_manager, *m_manager); init_manager_core(true); // PARAM-TODO diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp index f00c21d56..367c983c3 100644 --- a/src/front_end_params/front_end_params.cpp +++ b/src/front_end_params/front_end_params.cpp @@ -49,19 +49,3 @@ void front_end_params::register_params(ini_params & p) { #endif -void front_end_params::open_trace_file() { - if (m_trace) { - m_trace_stream = alloc(std::fstream, m_trace_file_name.c_str(), std::ios_base::out); - } -} - -void front_end_params::close_trace_file() { - if (m_trace_stream != NULL) { - std::fstream &tmp = *m_trace_stream; - m_trace_stream = NULL; - tmp << "[eof]\n"; - tmp.close(); - // do not delete it, this might be called from a Ctrl-C signal handler - // and there might be someone writing to it - } -} diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h index 2c7dbfa2e..9bf5dd69c 100644 --- a/src/front_end_params/front_end_params.h +++ b/src/front_end_params/front_end_params.h @@ -30,9 +30,6 @@ struct front_end_params : public smt_params { bool m_auto_config; bool m_debug_ref_count; - bool m_trace; - std::string m_trace_file_name; - std::fstream* m_trace_stream; front_end_params(): m_well_sorted_check(true), @@ -40,16 +37,9 @@ struct front_end_params : public smt_params { m_memory_max_size(0), m_proof_mode(PGM_DISABLED), m_auto_config(true), - m_debug_ref_count(false), - m_trace(false), - m_trace_file_name("z3.log"), - m_trace_stream(NULL) { + m_debug_ref_count(false) { } - void open_trace_file(); - - void close_trace_file(); - bool has_auto_config(unsigned idx) { return m_auto_config; } private: diff --git a/src/parsers/smt/smtlib_solver.cpp b/src/parsers/smt/smtlib_solver.cpp index ddcdb56c8..ef28216bf 100644 --- a/src/parsers/smt/smtlib_solver.cpp +++ b/src/parsers/smt/smtlib_solver.cpp @@ -33,9 +33,9 @@ Revision History: namespace smtlib { - solver::solver(front_end_params & params): - m_ast_manager(params.m_proof_mode, params.m_trace_stream), - m_params(params), + solver::solver(): + m_ast_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED, + m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0), m_ctx(0), m_error_code(0) { parser_params ps; @@ -103,7 +103,7 @@ namespace smtlib { check_sat_result * r = m_ctx->get_check_sat_result(); if (r != 0) { proof * pr = r->get_proof(); - if (pr != 0 && m_params.m_display_proof) + if (pr != 0 && m_params.m_proof) std::cout << mk_ll_pp(pr, m_ast_manager, false, false); model_ref md; if (r->status() != l_false) r->get_model(md); diff --git a/src/parsers/smt/smtlib_solver.h b/src/parsers/smt/smtlib_solver.h index a84f2c98f..4e9815d38 100644 --- a/src/parsers/smt/smtlib_solver.h +++ b/src/parsers/smt/smtlib_solver.h @@ -20,20 +20,20 @@ Revision History: #define _SMTLIB_SOLVER_H_ #include"smtparser.h" -#include"front_end_params.h" +#include"context_params.h" #include"lbool.h" class cmd_context; namespace smtlib { class solver { + context_params m_params; ast_manager m_ast_manager; - front_end_params & m_params; cmd_context * m_ctx; scoped_ptr m_parser; unsigned m_error_code; public: - solver(front_end_params & params); + solver(); ~solver(); bool solve_smt(char const * benchmark_file); bool solve_smt_string(char const * benchmark_string); diff --git a/src/shell/main.cpp b/src/shell/main.cpp index 9cef54628..ecbaf8887 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -122,8 +122,6 @@ void init_params() { } void del_params() { - if (g_front_end_params != NULL) - g_front_end_params->close_trace_file(); delete g_extra_params; delete g_front_end_params; g_extra_params = 0; @@ -315,7 +313,6 @@ int main(int argc, char ** argv) { parse_cmd_line_args(argc, argv); env_params::updt_params(); - g_front_end_params->open_trace_file(); if (g_input_file && g_standard_input) { error("using standard input to read formula."); } @@ -346,11 +343,11 @@ int main(int argc, char ** argv) { } switch (g_input_kind) { case IN_SMTLIB: - return_value = read_smtlib_file(g_input_file, *g_front_end_params); + return_value = read_smtlib_file(g_input_file); break; case IN_SMTLIB_2: memory::exit_when_out_of_memory(true, "(error \"out of memory\")"); - return_value = read_smtlib2_commands(g_input_file, *g_front_end_params); + return_value = read_smtlib2_commands(g_input_file); break; case IN_DIMACS: return_value = read_dimacs(g_input_file); diff --git a/src/shell/smtlib_frontend.cpp b/src/shell/smtlib_frontend.cpp index c95b90098..1551329c6 100644 --- a/src/shell/smtlib_frontend.cpp +++ b/src/shell/smtlib_frontend.cpp @@ -67,11 +67,11 @@ static void on_ctrl_c(int) { raise(SIGINT); } -unsigned read_smtlib_file(char const * benchmark_file, front_end_params & front_end_params) { +unsigned read_smtlib_file(char const * benchmark_file) { g_start_time = clock(); register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); - smtlib::solver solver(front_end_params); + smtlib::solver solver; g_solver = &solver; bool ok = true; @@ -92,7 +92,7 @@ unsigned read_smtlib_file(char const * benchmark_file, front_end_params & front_ return solver.get_error_code(); } -unsigned read_smtlib2_commands(char const* file_name, front_end_params& front_end_params) { +unsigned read_smtlib2_commands(char const * file_name) { g_start_time = clock(); register_on_timeout_proc(on_timeout); signal(SIGINT, on_ctrl_c); diff --git a/src/shell/smtlib_frontend.h b/src/shell/smtlib_frontend.h index 0db1571e4..d83944119 100644 --- a/src/shell/smtlib_frontend.h +++ b/src/shell/smtlib_frontend.h @@ -21,14 +21,8 @@ Revision History: #include"front_end_params.h" -unsigned read_smtlib_file(char const * benchmark_file, front_end_params & front_end_params); - -unsigned read_smtlib_commands(char const* command_file, front_end_params& front_end_params); -unsigned read_smtlib2_commands(char const* command_file, front_end_params& front_end_params); - -#ifdef _Z3_BUILD_PARALLEL_MPI -unsigned start_mpi_subordinate(front_end_params& front_end_params); -#endif +unsigned read_smtlib_file(char const * benchmark_file); +unsigned read_smtlib2_commands(char const * command_file); #endif /* _SMTLIB_FRONTEND_H_ */ diff --git a/src/smt/mam.cpp b/src/smt/mam.cpp index ba97d8939..24b8e2e7c 100644 --- a/src/smt/mam.cpp +++ b/src/smt/mam.cpp @@ -1824,7 +1824,6 @@ namespace smt { backtrack_stack m_backtrack_stack; unsigned m_top; const instruction * m_pc; - std::ostream* m_trace_stream; // auxiliary temporary variables unsigned m_max_generation; // the maximum generation of an app enode processed. @@ -1855,10 +1854,9 @@ namespace smt { void update_max_generation(enode * n) { m_max_generation = std::max(m_max_generation, n->get_generation()); -#ifndef SMTCOMP - if (m_trace_stream != NULL) + + if (m_ast_manager.has_trace_stream()) m_used_enodes.push_back(n); -#endif } // We have to provide the number of expected arguments because we have flat-assoc applications such as +. @@ -1965,12 +1963,11 @@ namespace smt { #define INIT_ARGS_SIZE 16 public: - interpreter(context & ctx, mam & m, bool use_filters, std::ostream *trace_stream): + interpreter(context & ctx, mam & m, bool use_filters): m_context(ctx), m_ast_manager(ctx.get_manager()), m_mam(m), - m_use_filters(use_filters), - m_trace_stream(trace_stream) { + m_use_filters(use_filters) { m_args.resize(INIT_ARGS_SIZE, 0); } @@ -2266,12 +2263,12 @@ namespace smt { m_pattern_instances.reset(); m_pattern_instances.push_back(n); m_max_generation = n->get_generation(); -#ifndef SMTCOMP - if (m_trace_stream != NULL) { + + if (m_ast_manager.has_trace_stream()) { m_used_enodes.reset(); m_used_enodes.push_back(n); } -#endif + m_pc = t->get_root(); m_registers[0] = n; m_top = 0; @@ -2638,10 +2635,10 @@ namespace smt { } backtrack_point & bp = m_backtrack_stack[m_top - 1]; m_max_generation = bp.m_old_max_generation; -#ifndef SMTCOMP - if (m_trace_stream != NULL) + + if (m_ast_manager.has_trace_stream()) m_used_enodes.shrink(bp.m_old_used_enodes_size); -#endif + TRACE("mam_int", tout << "backtrack top: " << bp.m_instr << " " << *(bp.m_instr) << "\n";); #ifdef _PROFILE_MAM if (bp.m_instr->m_opcode != CHOOSE) // CHOOSE has a different status. It is a control flow backtracking. @@ -3759,14 +3756,14 @@ namespace smt { } public: - mam_impl(context & ctx, bool use_filters, std::ostream *trace): - mam(ctx, trace), + mam_impl(context & ctx, bool use_filters): + mam(ctx), m_ast_manager(ctx.get_manager()), m_use_filters(use_filters), m_trail_stack(*this), m_ct_manager(m_lbl_hasher, m_trail_stack), m_compiler(ctx, m_ct_manager, m_lbl_hasher, use_filters), - m_interpreter(ctx, *this, use_filters, trace), + 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), @@ -3980,8 +3977,8 @@ namespace smt { } }; - mam * mk_mam(context & ctx, std::ostream *trace) { - return alloc(mam_impl, ctx, true, trace); + mam * mk_mam(context & ctx) { + return alloc(mam_impl, ctx, true); } }; diff --git a/src/smt/mam.h b/src/smt/mam.h index cee6f6e2f..c9f813150 100644 --- a/src/smt/mam.h +++ b/src/smt/mam.h @@ -29,11 +29,9 @@ namespace smt { class mam { protected: context & m_context; - std::ostream * m_trace_stream; public: - mam(context & ctx, std::ostream *trace): - m_context(ctx), - m_trace_stream(trace) { + mam(context & ctx): + m_context(ctx) { } virtual ~mam() { @@ -68,7 +66,7 @@ namespace smt { #endif }; - mam * mk_mam(context & ctx, std::ostream *trace); + mam * mk_mam(context & ctx); }; #endif /* _MAM_H_ */ diff --git a/src/smt/qi_queue.cpp b/src/smt/qi_queue.cpp index a2a2cc9de..9394dae34 100644 --- a/src/smt/qi_queue.cpp +++ b/src/smt/qi_queue.cpp @@ -26,7 +26,7 @@ Revision History: namespace smt { - qi_queue::qi_queue(quantifier_manager & qm, context & ctx, qi_params & params, std::ostream *trace_stream): + qi_queue::qi_queue(quantifier_manager & qm, context & ctx, qi_params & params): m_qm(qm), m_context(ctx), m_manager(m_context.get_manager()), @@ -37,7 +37,6 @@ namespace smt { m_parser(m_manager), m_evaluator(m_manager), m_subst(m_manager), - m_trace_stream(trace_stream), m_instances(m_manager) { init_parser_vars(); m_vals.resize(15, 0.0f); @@ -173,25 +172,23 @@ namespace smt { } void qi_queue::display_instance_profile(fingerprint * f, quantifier * q, unsigned num_bindings, enode * const * bindings, unsigned proof_id, unsigned generation) { -#ifndef SMTCOMP - if (m_trace_stream != NULL) { - *m_trace_stream << "[instance] "; + if (m_manager.has_trace_stream()) { + m_manager.trace_stream() << "[instance] "; #if 1 - *m_trace_stream << static_cast(f); + m_manager.trace_stream() << static_cast(f); #else for (unsigned i = 0; i < num_bindings; i++) { // I don't want to use mk_pp because it creates expressions for pretty printing. // This nasty side-effect may change the behavior of Z3. - *m_trace_stream << " #" << bindings[i]->get_owner_id(); + m_manager.trace_stream() << " #" << bindings[i]->get_owner_id(); } #endif if (m_manager.proofs_enabled()) - *m_trace_stream << " #" << proof_id; - *m_trace_stream << " ; " << generation; - *m_trace_stream << "\n"; + m_manager.trace_stream() << " #" << proof_id; + m_manager.trace_stream() << " ; " << generation; + m_manager.trace_stream() << "\n"; } -#endif } void qi_queue::instantiate(entry & ent) { @@ -224,10 +221,10 @@ namespace smt { TRACE("qi_queue_bug", tout << "new instance after simplification:\n" << mk_pp(s_instance, m_manager) << "\n";); if (m_manager.is_true(s_instance)) { TRACE("checker", tout << "reduced to true, before:\n" << mk_ll_pp(instance, m_manager);); -#ifndef SMTCOMP - if (m_trace_stream != NULL) - *m_trace_stream << "[end-of-instance]\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[end-of-instance]\n"; + return; } quantifier_stat * stat = m_qm.get_stat(q); @@ -308,10 +305,10 @@ namespace smt { } } }); -#ifndef SMTCOMP - if (m_trace_stream != NULL) - *m_trace_stream << "[end-of-instance]\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[end-of-instance]\n"; + } void qi_queue::push_scope() { diff --git a/src/smt/qi_queue.h b/src/smt/qi_queue.h index 43d57d84f..1060f083b 100644 --- a/src/smt/qi_queue.h +++ b/src/smt/qi_queue.h @@ -53,7 +53,6 @@ namespace smt { cached_var_subst m_subst; svector m_vals; double m_eager_cost_threshold; - std::ostream * m_trace_stream; struct entry { fingerprint * m_qb; float m_cost; @@ -81,7 +80,7 @@ namespace smt { void display_instance_profile(fingerprint * f, quantifier * q, unsigned num_bindings, enode * const * bindings, unsigned proof_id, unsigned generation); public: - qi_queue(quantifier_manager & qm, context & ctx, qi_params & params, std::ostream *trace); + qi_queue(quantifier_manager & qm, context & ctx, qi_params & params); ~qi_queue(); void setup(); /** diff --git a/src/smt/smt_case_split_queue.cpp b/src/smt/smt_case_split_queue.cpp index 66d08e9fc..808284224 100644 --- a/src/smt/smt_case_split_queue.cpp +++ b/src/smt/smt_case_split_queue.cpp @@ -395,8 +395,8 @@ namespace smt { if ((is_or && val == l_true) || (is_and && val == l_false)) { expr * undef_child = 0; if (!has_child_assigned_to(m_context, to_app(curr), val, undef_child, m_params.m_rel_case_split_order)) { - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; + if (m_manager.has_trace_stream()) { + m_manager.trace_stream() << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; } TRACE("case_split", tout << "found AND/OR candidate: #" << curr->get_id() << " #" << undef_child->get_id() << "\n";); literal l = m_context.get_literal(undef_child); @@ -851,8 +851,8 @@ namespace smt { if ((is_or && val == l_true) || (is_and && val == l_false)) { expr * undef_child = 0; if (!has_child_assigned_to(m_context, to_app(curr), val, undef_child, m_params.m_rel_case_split_order)) { - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; + if (m_manager.has_trace_stream()) { + m_manager.trace_stream() << "[decide-and-or] #" << curr->get_id() << " #" << undef_child->get_id() << "\n"; } TRACE("case_split", tout << "found AND/OR candidate: #" << curr->get_id() << " #" << undef_child->get_id() << "\n";); literal l = m_context.get_literal(undef_child); @@ -900,11 +900,6 @@ namespace smt { // does the push after calling us m_priority_queue2.insert(idx); e.m_last_decided = -1; - /* - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[generation] #" << e.m_expr->get_id() << " " << e.m_generation << "\n"; - } - */ return; } } diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index 2bc32e217..071275dd4 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -304,13 +304,13 @@ namespace smt { if (th) th->conflict_resolution_eh(to_app(n), var); } -#ifndef SMTCOMP - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[resolve-lit] " << m_conflict_lvl - lvl << " "; - m_ctx.display_literal(*m_params.m_trace_stream, ~antecedent); - *m_params.m_trace_stream << "\n"; + + if (get_manager().has_trace_stream()) { + get_manager().trace_stream() << "[resolve-lit] " << m_conflict_lvl - lvl << " "; + m_ctx.display_literal(get_manager().trace_stream(), ~antecedent); + get_manager().trace_stream() << "\n"; } -#endif + if (lvl == m_conflict_lvl) { num_marks++; } @@ -478,13 +478,12 @@ namespace smt { } do { -#ifndef SMTCOMP - if (m_params.m_trace_stream != NULL) { - *m_params.m_trace_stream << "[resolve-process] "; - m_ctx.display_literal(*m_params.m_trace_stream, ~consequent); - *m_params.m_trace_stream << "\n"; + + if (get_manager().has_trace_stream()) { + get_manager().trace_stream() << "[resolve-process] "; + m_ctx.display_literal(get_manager().trace_stream(), ~consequent); + get_manager().trace_stream() << "\n"; } -#endif TRACE("conflict", tout << "processing consequent: "; m_ctx.display_literal(tout, consequent); tout << "\n"; tout << "num_marks: " << num_marks << ", js kind: " << js.get_kind() << "\n";); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 1aae1c62a..3fb8398b4 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -190,11 +190,10 @@ namespace smt { TRACE("phase_selection", tout << "saving phase, is_pos: " << d.m_phase << " l: " << l << "\n";); if (d.is_atom() && (m_fparams.m_relevancy_lvl == 0 || (m_fparams.m_relevancy_lvl == 1 && !d.is_quantifier()) || is_relevant_core(bool_var2expr(l.var())))) m_atom_propagation_queue.push_back(l); -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) + + if (m_manager.has_trace_stream()) trace_assign(l, j, decision); m_case_split_queue->assign_lit_eh(l); -#endif } bool context::bcp() { @@ -1789,10 +1788,10 @@ namespace smt { \brief Create an internal backtracking point */ void context::push_scope() { -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) - *m_fparams.m_trace_stream << "[push] " << m_scope_lvl << "\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[push] " << m_scope_lvl << "\n"; + m_scope_lvl++; m_region.push_scope(); m_scopes.push_back(scope()); @@ -2237,10 +2236,10 @@ namespace smt { \warning This method will not invoke reset_cache_generation. */ unsigned context::pop_scope_core(unsigned num_scopes) { -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) - *m_fparams.m_trace_stream << "[pop] " << num_scopes << " " << m_scope_lvl << "\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[pop] " << num_scopes << " " << m_scope_lvl << "\n"; + TRACE("context", tout << "backtracking: " << num_scopes << "\n";); TRACE("pop_scope_detail", display(tout);); SASSERT(num_scopes > 0); @@ -2927,10 +2926,8 @@ namespace smt { Return true if succeeded. */ bool context::check_preamble(bool reset_cancel) { -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) - *m_fparams.m_trace_stream << "[begin-check] " << m_scope_lvl << "\n"; -#endif + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[begin-check] " << m_scope_lvl << "\n"; if (reset_cancel) { m_cancel_flag = false; @@ -3534,13 +3531,13 @@ namespace smt { tout << ", ilvl: " << get_intern_level(l.var()) << "\n" << mk_pp(bool_var2expr(l.var()), m_manager) << "\n"; }); -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) { - *m_fparams.m_trace_stream << "[conflict] "; - display_literals(*m_fparams.m_trace_stream, num_lits, lits); - *m_fparams.m_trace_stream << "\n"; + + if (m_manager.has_trace_stream()) { + m_manager.trace_stream() << "[conflict] "; + display_literals(m_manager.trace_stream(), num_lits, lits); + m_manager.trace_stream() << "\n"; } -#endif + #ifdef Z3DEBUG expr_ref_vector expr_lits(m_manager); svector expr_signs; diff --git a/src/smt/smt_context_pp.cpp b/src/smt/smt_context_pp.cpp index 4bc5dfd74..9ce684440 100644 --- a/src/smt/smt_context_pp.cpp +++ b/src/smt/smt_context_pp.cpp @@ -583,7 +583,8 @@ namespace smt { } void context::trace_assign(literal l, b_justification j, bool decision) const { - std::ostream & out = *m_fparams.m_trace_stream; + SASSERT(m_manager.has_trace_stream()); + std::ostream & out = m_manager.trace_stream(); out << "[assign] "; display_literal(out, l); if (decision) diff --git a/src/smt/smt_internalizer.cpp b/src/smt/smt_internalizer.cpp index 0cfe5b1de..556222c33 100644 --- a/src/smt/smt_internalizer.cpp +++ b/src/smt/smt_internalizer.cpp @@ -952,10 +952,10 @@ namespace smt { tout << "is_true_eq: " << e->is_true_eq() << " in cg_table: " << m_cg_table.contains_ptr(e) << " is_cgr: " << e->is_cgr() << "\n"; }); -#ifndef SMTCOMP - if (m_fparams.m_trace_stream != NULL) - *m_fparams.m_trace_stream << "[attach-enode] #" << n->get_id() << " " << m_generation << "\n"; -#endif + + if (m_manager.has_trace_stream()) + m_manager.trace_stream() << "[attach-enode] #" << n->get_id() << " " << m_generation << "\n"; + return e; } diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index e6d81d3d2..14e63b982 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -45,13 +45,16 @@ namespace smt { m_wrapper(wrapper), m_context(ctx), m_params(p), - m_qi_queue(m_wrapper, ctx, p, p.m_trace_stream), + m_qi_queue(m_wrapper, ctx, p), m_qstat_gen(ctx.get_manager(), ctx.get_region()), m_plugin(plugin) { m_num_instances = 0; m_qi_queue.setup(); } + bool has_trace_stream() const { return m_context.get_manager().has_trace_stream(); } + std::ostream & trace_stream() { return m_context.get_manager().trace_stream(); } + quantifier_stat * get_stat(quantifier * q) const { return m_quantifier_stat.find(q); } @@ -112,8 +115,8 @@ namespace smt { get_stat(q)->update_max_generation(max_generation); fingerprint * f = m_context.add_fingerprint(q, q->get_id(), num_bindings, bindings); if (f) { - if (m_params.m_trace_stream != NULL) { - std::ostream & out = *m_params.m_trace_stream; + if (has_trace_stream()) { + std::ostream & out = trace_stream(); out << "[new-match] " << static_cast(f) << " #" << q->get_id(); for (unsigned i = 0; i < num_bindings; i++) { // I don't want to use mk_pp because it creates expressions for pretty printing. @@ -418,8 +421,8 @@ namespace smt { m_fparams = &(m_context->get_fparams()); ast_manager & m = m_context->get_manager(); - m_mam = mk_mam(*m_context, m_fparams->m_trace_stream); - m_lazy_mam = mk_mam(*m_context, m_fparams->m_trace_stream); + m_mam = mk_mam(*m_context); + m_lazy_mam = mk_mam(*m_context); m_model_finder = alloc(model_finder, m, m_context->get_simplifier()); m_model_checker = alloc(model_checker, m, *m_fparams, *(m_model_finder.get())); From ffb7e26c75eef09d871b3e43600e7ba00ff87637 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 10:05:29 -0800 Subject: [PATCH 24/34] removed front-end-params Signed-off-by: Leonardo de Moura --- src/api/api_context.h | 6 +- src/api/api_datalog.cpp | 2 +- src/api/api_datalog.h | 4 +- src/ast/proof_checker/proof_checker.cpp | 2 +- src/cmd_context/context_params.h | 1 - src/front_end_params/front_end_params.cpp | 51 -------------- src/front_end_params/front_end_params.h | 51 -------------- .../params2front_end_params.h | 31 --------- ...t_end_params.cpp => params2smt_params.cpp} | 13 ++-- src/front_end_params/params2smt_params.h | 31 +++++++++ src/front_end_params/smt_params.h | 23 ++++++- src/muz_qe/dl_bmc_engine.h | 2 +- src/muz_qe/dl_cmds.cpp | 4 +- src/muz_qe/dl_context.cpp | 2 +- src/muz_qe/dl_context.h | 8 +-- src/muz_qe/dl_smt_relation.cpp | 12 ++-- src/muz_qe/dl_smt_relation.h | 4 +- src/muz_qe/horn_tactic.cpp | 2 +- src/muz_qe/nlarith_util.cpp | 2 +- src/muz_qe/pdr_context.cpp | 2 +- src/muz_qe/pdr_context.h | 6 +- src/muz_qe/pdr_farkas_learner.cpp | 10 +-- src/muz_qe/pdr_farkas_learner.h | 8 +-- src/muz_qe/pdr_generalizers.cpp | 2 +- src/muz_qe/pdr_generalizers.h | 2 +- src/muz_qe/pdr_interpolant_provider.cpp | 2 +- src/muz_qe/pdr_manager.cpp | 2 +- src/muz_qe/pdr_manager.h | 6 +- src/muz_qe/pdr_prop_solver.cpp | 2 +- src/muz_qe/pdr_prop_solver.h | 2 +- src/muz_qe/pdr_quantifiers.cpp | 2 +- src/muz_qe/pdr_smt_context_manager.cpp | 4 +- src/muz_qe/pdr_smt_context_manager.h | 4 +- src/muz_qe/pdr_util.cpp | 2 +- src/muz_qe/qe.cpp | 16 ++--- src/muz_qe/qe.h | 10 +-- src/muz_qe/qe_arith_plugin.cpp | 6 +- src/muz_qe/qe_cmd.cpp | 2 +- src/muz_qe/qe_sat_tactic.cpp | 2 +- src/muz_qe/qe_tactic.cpp | 2 +- src/muz_qe/unit_subsumption_tactic.cpp | 2 +- src/muz_qe/vsubst_tactic.cpp | 6 +- src/parsers/smt/smtparser.cpp | 1 - src/shell/datalog_frontend.cpp | 22 +++--- src/shell/datalog_frontend.h | 2 +- src/shell/main.cpp | 68 ++----------------- src/shell/smtlib_frontend.h | 2 - src/smt/asserted_formulas.cpp | 2 +- src/smt/asserted_formulas.h | 6 +- src/smt/expr_context_simplifier.cpp | 2 +- src/smt/expr_context_simplifier.h | 6 +- src/smt/smt_case_split_queue.cpp | 14 ++-- src/smt/smt_case_split_queue.h | 2 +- src/smt/smt_conflict_resolution.cpp | 4 +- src/smt/smt_conflict_resolution.h | 8 +-- src/smt/smt_context.cpp | 4 +- src/smt/smt_context.h | 8 +-- src/smt/smt_kernel.cpp | 14 ++-- src/smt/smt_kernel.h | 4 +- src/smt/smt_model_checker.cpp | 2 +- src/smt/smt_model_checker.h | 6 +- src/smt/smt_quantifier.cpp | 10 +-- src/smt/smt_quantifier.h | 4 +- src/smt/smt_setup.cpp | 2 +- src/smt/smt_setup.h | 6 +- src/smt/smt_solver.cpp | 4 +- src/smt/tactic/ctx_solver_simplify_tactic.cpp | 4 +- src/smt/tactic/smt_tactic.cpp | 14 ++-- src/smt/theory_diff_logic.h | 6 +- src/smt/theory_instgen.cpp | 10 +-- src/smt/theory_instgen.h | 4 +- src/smt/user_plugin/user_smt_theory.cpp | 2 +- src/smt/user_plugin/user_smt_theory.h | 4 +- src/solver/solver.h | 2 - src/tactic/tactic.h | 1 - src/test/arith_simplifier_plugin.cpp | 4 +- src/test/check_assumptions.cpp | 4 +- src/test/datalog_parser.cpp | 6 +- src/test/dl_context.cpp | 6 +- src/test/dl_product_relation.cpp | 6 +- src/test/dl_query.cpp | 8 +-- src/test/dl_relation.cpp | 4 +- src/test/dl_smt_relation.cpp | 2 +- src/test/dl_table.cpp | 2 +- src/test/model_retrieval.cpp | 4 +- src/test/quant_elim.cpp | 4 +- src/test/quant_solve.cpp | 11 ++- src/test/smt_context.cpp | 2 +- src/test/substitution.cpp | 4 +- src/test/theory_dl.cpp | 2 +- src/util/env_params.cpp | 4 +- 91 files changed, 264 insertions(+), 412 deletions(-) delete mode 100644 src/front_end_params/front_end_params.cpp delete mode 100644 src/front_end_params/front_end_params.h delete mode 100644 src/front_end_params/params2front_end_params.h rename src/front_end_params/{params2front_end_params.cpp => params2smt_params.cpp} (89%) create mode 100644 src/front_end_params/params2smt_params.h diff --git a/src/api/api_context.h b/src/api/api_context.h index df0f488af..a126f0790 100644 --- a/src/api/api_context.h +++ b/src/api/api_context.h @@ -28,7 +28,7 @@ Revision History: #include"datatype_decl_plugin.h" #include"dl_decl_plugin.h" #include"smt_kernel.h" -#include"front_end_params.h" +#include"smt_params.h" #include"event_handler.h" #include"tactic_manager.h" #include"context_params.h" @@ -53,7 +53,7 @@ namespace api { datalog::dl_decl_util m_datalog_util; // Support for old solver API - front_end_params m_fparams; + smt_params m_fparams; smt::kernel * m_solver; // General purpose solver for backward compatibility // ------------------------------- @@ -172,7 +172,7 @@ namespace api { // Solver interface for backward compatibility // // ------------------------ - front_end_params & fparams() { return m_fparams; } + smt_params & fparams() { return m_fparams; } bool has_solver() const { return m_solver != 0; } smt::kernel & get_smt_kernel(); void assert_cnstr(expr * a); diff --git a/src/api/api_datalog.cpp b/src/api/api_datalog.cpp index 4c54a4332..9b7093d1e 100644 --- a/src/api/api_datalog.cpp +++ b/src/api/api_datalog.cpp @@ -32,7 +32,7 @@ Revision History: namespace api { - fixedpoint_context::fixedpoint_context(ast_manager& m, front_end_params& p) : + fixedpoint_context::fixedpoint_context(ast_manager& m, smt_params& p) : m_state(0), m_reduce_app(0), m_reduce_assign(0), diff --git a/src/api/api_datalog.h b/src/api/api_datalog.h index 97bedfc9b..1dc0a9cbd 100644 --- a/src/api/api_datalog.h +++ b/src/api/api_datalog.h @@ -21,7 +21,7 @@ Revision History: #include"z3.h" #include"ast.h" -#include"front_end_params.h" +#include"smt_params.h" #include"dl_external_relation.h" #include"dl_decl_plugin.h" #include"smt_kernel.h" @@ -40,7 +40,7 @@ namespace api { datalog::context m_context; ast_ref_vector m_trail; public: - fixedpoint_context(ast_manager& m, front_end_params& p); + fixedpoint_context(ast_manager& m, smt_params& p); virtual ~fixedpoint_context() {} family_id get_family_id() const { return const_cast(m_context).get_decl_util().get_family_id(); } void set_state(void* state); diff --git a/src/ast/proof_checker/proof_checker.cpp b/src/ast/proof_checker/proof_checker.cpp index 8a064a315..bef0fea9c 100644 --- a/src/ast/proof_checker/proof_checker.cpp +++ b/src/ast/proof_checker/proof_checker.cpp @@ -4,7 +4,7 @@ // include "spc_decl_plugin.h" #include "ast_smt_pp.h" #include "arith_decl_plugin.h" -#include "front_end_params.h" +#include "smt_params.h" #include "th_rewriter.h" #include "var_subst.h" diff --git a/src/cmd_context/context_params.h b/src/cmd_context/context_params.h index 556c3bd3f..0fe4da93e 100644 --- a/src/cmd_context/context_params.h +++ b/src/cmd_context/context_params.h @@ -36,7 +36,6 @@ public: bool m_validate_model; bool m_unsat_core; unsigned m_timeout; - bool m_statistics; context_params(); void set(char const * param, char const * value); diff --git a/src/front_end_params/front_end_params.cpp b/src/front_end_params/front_end_params.cpp deleted file mode 100644 index 367c983c3..000000000 --- a/src/front_end_params/front_end_params.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - front_end_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#include"front_end_params.h" - -#if 0 - -void front_end_params::register_params(ini_params & p) { - preprocessor_params::register_params(p); - smt_params::register_params(p); - arith_simplifier_params::register_params(p); - p.register_bool_param("at_labels_cex", m_at_labels_cex, - "only use labels that contain '@' when building multiple counterexamples"); - p.register_bool_param("check_at_labels", m_check_at_labels, - "check that labels containing '@' are used correctly to only produce unique counter examples"); - p.register_bool_param("type_check", m_well_sorted_check, "enable/disable type checker"); - p.register_bool_param("well_sorted_check", m_well_sorted_check, "enable/disable type checker"); - p.register_unsigned_param("soft_timeout", m_soft_timeout, "set approximate timeout for each solver query (milliseconds), the value 0 represents no timeout", true); - p.register_double_param("instruction_max", m_instr_out, "set the (approximate) maximal number of instructions per invocation of check", true); - -#ifdef _WINDOWS - // The non-windows memory manager does not have access to memory sizes. - p.register_unsigned_param("memory_high_watermark", m_memory_high_watermark, - "set high watermark for memory consumption (in megabytes)"); - p.register_unsigned_param("memory_max_size", m_memory_max_size, - "set hard upper limit for memory consumption (in megabytes)"); -#endif - - - PRIVATE_PARAMS({ - }); - -} - -#endif - diff --git a/src/front_end_params/front_end_params.h b/src/front_end_params/front_end_params.h deleted file mode 100644 index 9bf5dd69c..000000000 --- a/src/front_end_params/front_end_params.h +++ /dev/null @@ -1,51 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - front_end_params.h - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2007-05-10. - -Revision History: - ---*/ -#ifndef _FRONT_END_PARAMS_H_ -#define _FRONT_END_PARAMS_H_ - -#include"ast.h" -#include"smt_params.h" - -struct front_end_params : public smt_params { - bool m_well_sorted_check; - unsigned m_memory_high_watermark; - unsigned m_memory_max_size; - proof_gen_mode m_proof_mode; - bool m_auto_config; - - bool m_debug_ref_count; - - front_end_params(): - m_well_sorted_check(true), - m_memory_high_watermark(0), - m_memory_max_size(0), - m_proof_mode(PGM_DISABLED), - m_auto_config(true), - m_debug_ref_count(false) { - } - - bool has_auto_config(unsigned idx) { return m_auto_config; } - -private: - - front_end_params& operator=(front_end_params const& other); -}; - -#endif /* _FRONT_END_PARAMS_H_ */ - diff --git a/src/front_end_params/params2front_end_params.h b/src/front_end_params/params2front_end_params.h deleted file mode 100644 index 936928d4a..000000000 --- a/src/front_end_params/params2front_end_params.h +++ /dev/null @@ -1,31 +0,0 @@ -/*++ -Copyright (c) 2011 Microsoft Corporation - -Module Name: - - params2front_end_params.h - -Abstract: - - Backward compatibility utilities for parameter setting - -Author: - - Leonardo de Moura (leonardo) 2011-05-19. - -Revision History: - ---*/ -#ifndef _PARAMS2FRONT_END_PARAMS_H_ -#define _PARAMS2FRONT_END_PARAMS_H_ - -class params_ref; -struct front_end_params; - -void params2front_end_params(params_ref const & s, front_end_params & t); - -void front_end_params2params(front_end_params const & s, params_ref & t); - -void solver_front_end_params_descrs(param_descrs & r); - -#endif diff --git a/src/front_end_params/params2front_end_params.cpp b/src/front_end_params/params2smt_params.cpp similarity index 89% rename from src/front_end_params/params2front_end_params.cpp rename to src/front_end_params/params2smt_params.cpp index 4c5866786..b01d9478a 100644 --- a/src/front_end_params/params2front_end_params.cpp +++ b/src/front_end_params/params2smt_params.cpp @@ -3,7 +3,7 @@ Copyright (c) 2011 Microsoft Corporation Module Name: - params2front_end_params.h + params2smt_params.h Abstract: @@ -16,17 +16,17 @@ Author: Revision History: --*/ -#include"front_end_params.h" +#include"smt_params.h" #include"params.h" /** - Update front_end_params using s. + Update smt_params using s. Only the most frequently used options are updated. This function is mainly used to allow smt::context to be used in the new strategy framework. */ -void params2front_end_params(params_ref const & s, front_end_params & t) { +void params2smt_params(params_ref const & s, smt_params & t) { t.m_relevancy_lvl = s.get_uint("relevancy", t.m_relevancy_lvl); TRACE("qi_cost", s.display(tout); tout << "\n";); t.m_qi_cost = s.get_str("qi_cost", t.m_qi_cost.c_str()); @@ -36,7 +36,6 @@ void params2front_end_params(params_ref const & s, front_end_params & t) { t.m_model = s.get_bool("produce_models", t.m_model); if (s.get_bool("produce_proofs", false)) t.m_proof_mode = PGM_FINE; - t.m_well_sorted_check = s.get_bool("check_sorts", t.m_well_sorted_check); t.m_qi_eager_threshold = s.get_double("qi_eager_threshold", t.m_qi_eager_threshold); t.m_qi_lazy_threshold = s.get_double("qi_lazy_threshold", t.m_qi_lazy_threshold); t.m_preprocess = s.get_bool("preprocess", t.m_preprocess); @@ -57,7 +56,7 @@ void params2front_end_params(params_ref const & s, front_end_params & t) { It also copies the model construction parameter. Thus, model construction can be enabled at the command line. */ -void front_end_params2params(front_end_params const & s, params_ref & t) { +void smt_params2params(smt_params const & s, params_ref & t) { if (s.m_model) t.set_bool("produce_models", true); if (!s.m_hi_div0) @@ -67,7 +66,7 @@ void front_end_params2params(front_end_params const & s, params_ref & t) { /** \brief Bridge for using params_ref with smt::context. */ -void solver_front_end_params_descrs(param_descrs & r) { +void solver_smt_params_descrs(param_descrs & r) { r.insert("hi_div0", CPK_BOOL, "(default: true) if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted"); r.insert("relevancy", CPK_UINT, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant"); r.insert("mbqi", CPK_BOOL, "model based quantifier instantiation (MBQI)"); diff --git a/src/front_end_params/params2smt_params.h b/src/front_end_params/params2smt_params.h new file mode 100644 index 000000000..d4f60cb64 --- /dev/null +++ b/src/front_end_params/params2smt_params.h @@ -0,0 +1,31 @@ +/*++ +Copyright (c) 2011 Microsoft Corporation + +Module Name: + + params2smt_params.h + +Abstract: + + Backward compatibility utilities for parameter setting + +Author: + + Leonardo de Moura (leonardo) 2011-05-19. + +Revision History: + +--*/ +#ifndef _PARAMS2SMT_PARAMS_H_ +#define _PARAMS2SMT_PARAMS_H_ + +class params_ref; +struct smt_params; + +void params2smt_params(params_ref const & s, smt_params & t); + +void smt_params2params(smt_params const & s, params_ref & t); + +void solver_smt_params_descrs(param_descrs & r); + +#endif diff --git a/src/front_end_params/smt_params.h b/src/front_end_params/smt_params.h index 24479de16..68e5a596d 100644 --- a/src/front_end_params/smt_params.h +++ b/src/front_end_params/smt_params.h @@ -19,6 +19,7 @@ Revision History: #ifndef _SMT_PARAMS_H_ #define _SMT_PARAMS_H_ +#include"ast.h" #include"dyn_ack_params.h" #include"qi_params.h" #include"theory_arith_params.h" @@ -205,6 +206,24 @@ struct smt_params : public preprocessor_params, bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples. bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples. bool m_dump_goal_as_smt; + proof_gen_mode m_proof_mode; + bool m_auto_config; + +#if 0 + unsigned m_memory_high_watermark; + unsigned m_memory_max_size; + + bool m_auto_config; + + bool m_debug_ref_count; + + m_well_sorted_check(true), + m_memory_high_watermark(0), + m_memory_max_size(0), + + m_auto_config(true), + m_debug_ref_count(false) { +#endif smt_params(): m_display_proof(false), @@ -272,7 +291,9 @@ struct smt_params : public preprocessor_params, m_soft_timeout(0), m_at_labels_cex(false), m_check_at_labels(false), - m_dump_goal_as_smt(false) { + m_dump_goal_as_smt(false), + m_proof_mode(PGM_DISABLED), + m_auto_config(true) { } }; diff --git a/src/muz_qe/dl_bmc_engine.h b/src/muz_qe/dl_bmc_engine.h index 5de54f843..bd330fa22 100644 --- a/src/muz_qe/dl_bmc_engine.h +++ b/src/muz_qe/dl_bmc_engine.h @@ -32,7 +32,7 @@ namespace datalog { class bmc { context& m_ctx; ast_manager& m; - front_end_params m_fparams; + smt_params m_fparams; smt::kernel m_solver; obj_map m_pred2sort; obj_map m_sort2pred; diff --git a/src/muz_qe/dl_cmds.cpp b/src/muz_qe/dl_cmds.cpp index deb4dc7ec..f45165709 100644 --- a/src/muz_qe/dl_cmds.cpp +++ b/src/muz_qe/dl_cmds.cpp @@ -33,8 +33,8 @@ Notes: class dl_context { - // PARAM-TODO temp HACK: added m_params field because cmd_context does not have front_end_params anymore - front_end_params m_params; + // PARAM-TODO temp HACK: added m_params field because cmd_context does not have smt_params anymore + smt_params m_params; cmd_context & m_cmd; dl_collected_cmds* m_collected_cmds; unsigned m_ref_count; diff --git a/src/muz_qe/dl_context.cpp b/src/muz_qe/dl_context.cpp index 1e139813b..3b7ad6ffc 100644 --- a/src/muz_qe/dl_context.cpp +++ b/src/muz_qe/dl_context.cpp @@ -226,7 +226,7 @@ namespace datalog { // // ----------------------------------- - context::context(ast_manager & m, front_end_params& fp, params_ref const& pa): + context::context(ast_manager & m, smt_params& fp, params_ref const& pa): m(m), m_fparams(fp), m_params(pa), diff --git a/src/muz_qe/dl_context.h b/src/muz_qe/dl_context.h index fe94dd3cc..9078bc693 100644 --- a/src/muz_qe/dl_context.h +++ b/src/muz_qe/dl_context.h @@ -24,7 +24,7 @@ Revision History: #undef max #endif #include"arith_decl_plugin.h" -#include"front_end_params.h" +#include"smt_params.h" #include"map.h" #include"th_rewriter.h" #include"str_hashtable.h" @@ -78,7 +78,7 @@ namespace datalog { typedef vector > fact_vector; ast_manager & m; - front_end_params& m_fparams; + smt_params& m_fparams; params_ref m_params; dl_decl_util m_decl_util; th_rewriter m_rewriter; @@ -122,7 +122,7 @@ namespace datalog { public: - context(ast_manager & m, front_end_params& params, params_ref const& p = params_ref()); + context(ast_manager & m, smt_params& params, params_ref const& p = params_ref()); ~context(); void reset(); @@ -149,7 +149,7 @@ namespace datalog { relation_manager & get_rmanager() { return m_rmanager; } const relation_manager & get_rmanager() const { return m_rmanager; } rule_manager & get_rule_manager() { return m_rule_manager; } - front_end_params & get_fparams() const { return m_fparams; } + smt_params & get_fparams() const { return m_fparams; } params_ref const& get_params() const { return m_params; } DL_ENGINE get_engine() { configure_engine(); return m_engine; } th_rewriter& get_rewriter() { return m_rewriter; } diff --git a/src/muz_qe/dl_smt_relation.cpp b/src/muz_qe/dl_smt_relation.cpp index 348c63e1c..ee465a7d8 100644 --- a/src/muz_qe/dl_smt_relation.cpp +++ b/src/muz_qe/dl_smt_relation.cpp @@ -129,7 +129,7 @@ namespace datalog { } IF_VERBOSE(10, verbose_stream() << "Checking emptiness...\n"; ); - front_end_params& params = get_plugin().get_fparams(); + smt_params& params = get_plugin().get_fparams(); // [Leo]: asserted_formulas do not have support for der. // We should use the tactics der. // flet flet2(params.m_der, true); @@ -182,7 +182,7 @@ namespace datalog { expr_ref fml_free(m), fml_inst(m); fml_free = m.mk_and(facts, m.mk_not(get_relation())); instantiate(fml_free, fml_inst); - front_end_params& params = get_plugin().get_fparams(); + smt_params& params = get_plugin().get_fparams(); // [Leo]: asserted_formulas do not have support for qe nor der. // We should use the tactics qe and der. // BTW, qe at asserted_formulas was disabled when we moved to codeplex, but the field m_quant_elim was not deleted. @@ -239,7 +239,7 @@ namespace datalog { void smt_relation::display_finite(std::ostream & out) const { ast_manager& m = get_manager(); - front_end_params& params = get_plugin().get_fparams(); + smt_params& params = get_plugin().get_fparams(); expr* r = get_relation(); expr_ref tmp(m); expr_ref_vector values(m), eqs(m); @@ -524,7 +524,7 @@ namespace datalog { expr_ref rInst(m), srcInst(m), tmp(m), tmp1(m); expr_ref notR(m), srcGround(m); - front_end_params& fparams = get(r).get_plugin().get_fparams(); + smt_params& fparams = get(r).get_plugin().get_fparams(); params_ref const& params = get(r).get_plugin().get_params(); get(r).instantiate(get(r).get_relation(), rInst); @@ -730,8 +730,8 @@ namespace datalog { return symbol(m_counter++); } - front_end_params& smt_relation_plugin::get_fparams() { - return const_cast(get_manager().get_context().get_fparams()); + smt_params& smt_relation_plugin::get_fparams() { + return const_cast(get_manager().get_context().get_fparams()); } params_ref const& smt_relation_plugin::get_params() { diff --git a/src/muz_qe/dl_smt_relation.h b/src/muz_qe/dl_smt_relation.h index 99de2ad83..a1bab918f 100644 --- a/src/muz_qe/dl_smt_relation.h +++ b/src/muz_qe/dl_smt_relation.h @@ -20,7 +20,7 @@ Revision History: #define _DL_SMT_RELATION_H_ #include "dl_base.h" -#include "front_end_params.h" +#include "smt_params.h" #include "params.h" namespace datalog { @@ -70,7 +70,7 @@ namespace datalog { symbol fresh_name(); - front_end_params& get_fparams(); + smt_params& get_fparams(); params_ref const& get_params(); diff --git a/src/muz_qe/horn_tactic.cpp b/src/muz_qe/horn_tactic.cpp index 8632f333b..1dec1b4fe 100644 --- a/src/muz_qe/horn_tactic.cpp +++ b/src/muz_qe/horn_tactic.cpp @@ -26,7 +26,7 @@ class horn_tactic : public tactic { struct imp { ast_manager& m; datalog::context m_ctx; - front_end_params m_fparams; + smt_params m_fparams; imp(ast_manager & m, params_ref const & p): m(m), diff --git a/src/muz_qe/nlarith_util.cpp b/src/muz_qe/nlarith_util.cpp index 039b57acf..5f8a24e99 100644 --- a/src/muz_qe/nlarith_util.cpp +++ b/src/muz_qe/nlarith_util.cpp @@ -72,7 +72,7 @@ namespace nlarith { bool m_enable_linear; app_ref m_zero; app_ref m_one; - front_end_params m_params; + smt_params m_params; basic_simplifier_plugin m_bs; arith_simplifier_plugin m_rw; arith_rewriter m_rw1; diff --git a/src/muz_qe/pdr_context.cpp b/src/muz_qe/pdr_context.cpp index cb00dbeab..bb3d0f6be 100644 --- a/src/muz_qe/pdr_context.cpp +++ b/src/muz_qe/pdr_context.cpp @@ -1087,7 +1087,7 @@ namespace pdr { // context context::context( - front_end_params& fparams, + smt_params& fparams, params_ref const& params, ast_manager& m ) diff --git a/src/muz_qe/pdr_context.h b/src/muz_qe/pdr_context.h index a201ac03b..77c3f48a9 100644 --- a/src/muz_qe/pdr_context.h +++ b/src/muz_qe/pdr_context.h @@ -285,7 +285,7 @@ namespace pdr { void reset() { memset(this, 0, sizeof(*this)); } }; - front_end_params& m_fparams; + smt_params& m_fparams; params_ref const& m_params; ast_manager& m; datalog::context* m_context; @@ -343,13 +343,13 @@ namespace pdr { We check whether there is some reachable state of the relation checked_relation. */ context( - front_end_params& fparams, + smt_params& fparams, params_ref const& params, ast_manager& m); ~context(); - front_end_params& get_fparams() const { return m_fparams; } + smt_params& get_fparams() const { return m_fparams; } params_ref const& get_params() const { return m_params; } ast_manager& get_manager() const { return m; } manager& get_pdr_manager() { return m_pm; } diff --git a/src/muz_qe/pdr_farkas_learner.cpp b/src/muz_qe/pdr_farkas_learner.cpp index 3206c64da..46de8f212 100644 --- a/src/muz_qe/pdr_farkas_learner.cpp +++ b/src/muz_qe/pdr_farkas_learner.cpp @@ -244,7 +244,7 @@ namespace pdr { } }; - farkas_learner::farkas_learner(front_end_params& params, ast_manager& outer_mgr) + farkas_learner::farkas_learner(smt_params& params, ast_manager& outer_mgr) : m_proof_params(get_proof_params(params)), m_pr(PROOF_MODE), p2o(m_pr, outer_mgr), @@ -254,8 +254,8 @@ namespace pdr { m_ctx = alloc(smt::kernel, m_pr, m_proof_params); } - front_end_params farkas_learner::get_proof_params(front_end_params& orig_params) { - front_end_params res(orig_params); + smt_params farkas_learner::get_proof_params(smt_params& orig_params) { + smt_params res(orig_params); res.m_proof_mode = PROOF_MODE; res.m_arith_bound_prop = BP_NONE; // temp hack to fix the build @@ -796,7 +796,7 @@ namespace pdr { void farkas_learner::test() { - front_end_params params; + smt_params params; enable_trace("farkas_learner"); bool res; @@ -883,7 +883,7 @@ namespace pdr { end = p->get_benchmark()->end_formulas(); B = m.mk_and(static_cast(end-it), it); - front_end_params params; + smt_params params; pdr::farkas_learner fl(params, m); expr_ref_vector lemmas(m); bool res = fl.get_lemma_guesses(A, B, lemmas); diff --git a/src/muz_qe/pdr_farkas_learner.h b/src/muz_qe/pdr_farkas_learner.h index 56cb3640c..809f4cd7e 100644 --- a/src/muz_qe/pdr_farkas_learner.h +++ b/src/muz_qe/pdr_farkas_learner.h @@ -26,7 +26,7 @@ Revision History: #include "smt_kernel.h" #include "bool_rewriter.h" #include "pdr_util.h" -#include "front_end_params.h" +#include "smt_params.h" #include "tactic.h" namespace pdr { @@ -39,12 +39,12 @@ class farkas_learner { typedef obj_hashtable expr_set; - front_end_params m_proof_params; + smt_params m_proof_params; ast_manager m_pr; scoped_ptr m_ctx; - static front_end_params get_proof_params(front_end_params& orig_params); + static smt_params get_proof_params(smt_params& orig_params); // // all ast objects passed to private functions have m_proof_mgs as their ast_manager @@ -72,7 +72,7 @@ class farkas_learner { static void test(); public: - farkas_learner(front_end_params& params, ast_manager& m); + farkas_learner(smt_params& params, ast_manager& m); /** All ast objects have the ast_manager which was passed as diff --git a/src/muz_qe/pdr_generalizers.cpp b/src/muz_qe/pdr_generalizers.cpp index 3105485e0..31bb132c4 100644 --- a/src/muz_qe/pdr_generalizers.cpp +++ b/src/muz_qe/pdr_generalizers.cpp @@ -103,7 +103,7 @@ namespace pdr { // weaken predecessor. // - core_farkas_generalizer::core_farkas_generalizer(context& ctx, ast_manager& m, front_end_params& p): + core_farkas_generalizer::core_farkas_generalizer(context& ctx, ast_manager& m, smt_params& p): core_generalizer(ctx), m_farkas_learner(p, m) {} diff --git a/src/muz_qe/pdr_generalizers.h b/src/muz_qe/pdr_generalizers.h index 3b9851ca5..543e6d985 100644 --- a/src/muz_qe/pdr_generalizers.h +++ b/src/muz_qe/pdr_generalizers.h @@ -36,7 +36,7 @@ namespace pdr { class core_farkas_generalizer : public core_generalizer { farkas_learner m_farkas_learner; public: - core_farkas_generalizer(context& ctx, ast_manager& m, front_end_params& p); + 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; diff --git a/src/muz_qe/pdr_interpolant_provider.cpp b/src/muz_qe/pdr_interpolant_provider.cpp index bcea5cbc4..de1c62d79 100644 --- a/src/muz_qe/pdr_interpolant_provider.cpp +++ b/src/muz_qe/pdr_interpolant_provider.cpp @@ -306,7 +306,7 @@ lbool interpolant_provider_impl::get_interpolant(expr * f1, expr * f2, expr_ref& return l_undef; } - front_end_params dummy_params; + smt_params dummy_params; cmd_context cctx(&dummy_params, false, &m); for_each_expr(used_symbol_inserter(cctx), f1); diff --git a/src/muz_qe/pdr_manager.cpp b/src/muz_qe/pdr_manager.cpp index 9536d8f36..598d8c850 100644 --- a/src/muz_qe/pdr_manager.cpp +++ b/src/muz_qe/pdr_manager.cpp @@ -166,7 +166,7 @@ namespace pdr { return res; } - manager::manager(front_end_params& fparams, params_ref const& params, ast_manager& manager) : + manager::manager(smt_params& fparams, params_ref const& params, ast_manager& manager) : m(manager), m_fparams(fparams), m_params(params), diff --git a/src/muz_qe/pdr_manager.h b/src/muz_qe/pdr_manager.h index 85f2116e9..58b4ffc53 100644 --- a/src/muz_qe/pdr_manager.h +++ b/src/muz_qe/pdr_manager.h @@ -78,7 +78,7 @@ namespace pdr { class manager { ast_manager& m; - front_end_params& m_fparams; + smt_params& m_fparams; params_ref const& m_params; mutable bool_rewriter m_brwr; @@ -110,11 +110,11 @@ namespace pdr { void add_new_state(func_decl * s); public: - manager(front_end_params& fparams, params_ref const& params, + manager(smt_params& fparams, params_ref const& params, ast_manager & manager); ast_manager& get_manager() const { return m; } - front_end_params& get_fparams() const { return m_fparams; } + smt_params& get_fparams() const { return m_fparams; } params_ref const& get_params() const { return m_params; } bool_rewriter& get_brwr() const { return m_brwr; } diff --git a/src/muz_qe/pdr_prop_solver.cpp b/src/muz_qe/pdr_prop_solver.cpp index 4fd036f48..5d0bd4e28 100644 --- a/src/muz_qe/pdr_prop_solver.cpp +++ b/src/muz_qe/pdr_prop_solver.cpp @@ -24,7 +24,7 @@ Revision History: #include "ast_smt2_pp.h" #include "dl_util.h" #include "model_pp.h" -#include "front_end_params.h" +#include "smt_params.h" #include "datatype_decl_plugin.h" #include "bv_decl_plugin.h" #include "pdr_farkas_learner.h" diff --git a/src/muz_qe/pdr_prop_solver.h b/src/muz_qe/pdr_prop_solver.h index fcbfbd536..165a37845 100644 --- a/src/muz_qe/pdr_prop_solver.h +++ b/src/muz_qe/pdr_prop_solver.h @@ -35,7 +35,7 @@ namespace pdr { class prop_solver { private: - front_end_params& m_fparams; + smt_params& m_fparams; ast_manager& m; manager& m_pm; symbol m_name; diff --git a/src/muz_qe/pdr_quantifiers.cpp b/src/muz_qe/pdr_quantifiers.cpp index 7922b76c9..1cb4a5c95 100644 --- a/src/muz_qe/pdr_quantifiers.cpp +++ b/src/muz_qe/pdr_quantifiers.cpp @@ -206,7 +206,7 @@ namespace pdr { datalog::scoped_fine_proof _scp(m); expr_ref_vector fmls(m); - front_end_params fparams; + smt_params fparams; fparams.m_proof_mode = PGM_FINE; fparams.m_mbqi = true; diff --git a/src/muz_qe/pdr_smt_context_manager.cpp b/src/muz_qe/pdr_smt_context_manager.cpp index c9dcf7b4e..704967686 100644 --- a/src/muz_qe/pdr_smt_context_manager.cpp +++ b/src/muz_qe/pdr_smt_context_manager.cpp @@ -21,7 +21,7 @@ Revision History: #include "has_free_vars.h" #include "ast_pp.h" #include -#include "front_end_params.h" +#include "smt_params.h" namespace pdr { @@ -93,7 +93,7 @@ namespace pdr { return m_context.get_proof(); } - smt_context_manager::smt_context_manager(front_end_params& fp, params_ref const& p, ast_manager& m): + smt_context_manager::smt_context_manager(smt_params& fp, params_ref const& p, ast_manager& m): m_fparams(fp), m(m), m_max_num_contexts(p.get_uint("max_num_contexts", 500)), diff --git a/src/muz_qe/pdr_smt_context_manager.h b/src/muz_qe/pdr_smt_context_manager.h index 31fb8ccb3..342100ed0 100644 --- a/src/muz_qe/pdr_smt_context_manager.h +++ b/src/muz_qe/pdr_smt_context_manager.h @@ -88,7 +88,7 @@ namespace pdr { }; class smt_context_manager { - front_end_params& m_fparams; + smt_params& m_fparams; ast_manager& m; unsigned m_max_num_contexts; ptr_vector m_contexts; @@ -96,7 +96,7 @@ namespace pdr { app_ref_vector m_predicate_list; func_decl_set m_predicate_set; public: - smt_context_manager(front_end_params& fp, params_ref const& p, ast_manager& m); + smt_context_manager(smt_params& fp, params_ref const& p, ast_manager& m); ~smt_context_manager(); smt_context* mk_fresh(); void collect_statistics(statistics& st) const; diff --git a/src/muz_qe/pdr_util.cpp b/src/muz_qe/pdr_util.cpp index db11b5b20..934a038d2 100644 --- a/src/muz_qe/pdr_util.cpp +++ b/src/muz_qe/pdr_util.cpp @@ -30,7 +30,7 @@ Notes: #include "bool_rewriter.h" #include "dl_util.h" #include "for_each_expr.h" -#include "front_end_params.h" +#include "smt_params.h" #include "model.h" #include "model_v2_pp.h" #include "ref_vector.h" diff --git a/src/muz_qe/qe.cpp b/src/muz_qe/qe.cpp index 3b854b250..bb65f8bf8 100644 --- a/src/muz_qe/qe.cpp +++ b/src/muz_qe/qe.cpp @@ -1319,7 +1319,7 @@ namespace qe { public: - quant_elim_plugin(ast_manager& m, quant_elim& qe, front_end_params& p): + quant_elim_plugin(ast_manager& m, quant_elim& qe, smt_params& p): m(m), m_qe(qe), m_rewriter(m), @@ -1959,7 +1959,7 @@ namespace qe { class quant_elim_new : public quant_elim { ast_manager& m; - front_end_params& m_fparams; + smt_params& m_fparams; expr_ref m_assumption; bool m_produce_models; ptr_vector m_plugins; @@ -1968,7 +1968,7 @@ namespace qe { bool m_eliminate_variables_as_block; public: - quant_elim_new(ast_manager& m, front_end_params& p) : + quant_elim_new(ast_manager& m, smt_params& p) : m(m), m_fparams(p), m_assumption(m), @@ -2165,7 +2165,7 @@ namespace qe { // ------------------------------------------------ // expr_quant_elim - expr_quant_elim::expr_quant_elim(ast_manager& m, front_end_params const& fp, params_ref const& p): + expr_quant_elim::expr_quant_elim(ast_manager& m, smt_params const& fp, params_ref const& p): m(m), m_fparams(fp), m_params(p), @@ -2212,7 +2212,7 @@ namespace qe { void expr_quant_elim::init_qe() { if (!m_qe) { - m_qe = alloc(quant_elim_new, m, const_cast(m_fparams)); + m_qe = alloc(quant_elim_new, m, const_cast(m_fparams)); } } @@ -2399,7 +2399,7 @@ namespace qe { cache_result(q, r, pr); } - expr_quant_elim_star1::expr_quant_elim_star1(ast_manager& m, front_end_params const& p): + expr_quant_elim_star1::expr_quant_elim_star1(ast_manager& m, smt_params const& p): simplifier(m), m_quant_elim(m, p), m_assumption(m.mk_true()) { } @@ -2437,7 +2437,7 @@ namespace qe { class simplify_solver_context : public i_solver_context { ast_manager& m; - front_end_params m_fparams; + smt_params m_fparams; app_ref_vector* m_vars; expr_ref* m_fml; ptr_vector m_contains; @@ -2612,7 +2612,7 @@ namespace qe { } void simplify_exists(app_ref_vector& vars, expr_ref& fml) { - front_end_params params; + smt_params params; ast_manager& m = fml.get_manager(); simplify_solver_context ctx(m); ctx.solve(fml, vars); diff --git a/src/muz_qe/qe.h b/src/muz_qe/qe.h index 4ca098f73..1697a5cbd 100644 --- a/src/muz_qe/qe.h +++ b/src/muz_qe/qe.h @@ -22,7 +22,7 @@ Revision History: #define __QE_H__ #include "ast.h" -#include "front_end_params.h" +#include "smt_params.h" #include "statistics.h" #include "lbool.h" #include "expr_functors.h" @@ -221,7 +221,7 @@ namespace qe { qe_solver_plugin* mk_array_plugin(i_solver_context& ctx); - qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, front_end_params& p); + qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, smt_params& p); class def_vector { func_decl_ref_vector m_vars; @@ -275,7 +275,7 @@ namespace qe { class expr_quant_elim { ast_manager& m; - front_end_params const& m_fparams; + smt_params const& m_fparams; params_ref m_params; expr_ref_vector m_trail; obj_map m_visited; @@ -283,7 +283,7 @@ namespace qe { expr* m_assumption; bool m_use_new_qe; public: - expr_quant_elim(ast_manager& m, front_end_params const& fp, params_ref const& p = params_ref()); + expr_quant_elim(ast_manager& m, smt_params const& fp, params_ref const& p = params_ref()); ~expr_quant_elim(); void operator()(expr* assumption, expr* fml, expr_ref& result); @@ -331,7 +331,7 @@ namespace qe { virtual void reduce1_quantifier(quantifier * q); virtual bool is_target(quantifier * q) const { return q->get_num_patterns() == 0 && q->get_num_no_patterns() == 0; } public: - expr_quant_elim_star1(ast_manager & m, front_end_params const& p); + expr_quant_elim_star1(ast_manager & m, smt_params const& p); virtual ~expr_quant_elim_star1() {} void collect_statistics(statistics & st) const { diff --git a/src/muz_qe/qe_arith_plugin.cpp b/src/muz_qe/qe_arith_plugin.cpp index 14cb5ee53..69c036639 100644 --- a/src/muz_qe/qe_arith_plugin.cpp +++ b/src/muz_qe/qe_arith_plugin.cpp @@ -98,7 +98,7 @@ namespace qe { bool_rewriter m_bool_rewriter; arith_rewriter m_arith_rewriter; - arith_qe_util(ast_manager& m, front_end_params& p, i_solver_context& ctx) : + arith_qe_util(ast_manager& m, smt_params& p, i_solver_context& ctx) : m(m), m_ctx(ctx), m_arith(m), @@ -1511,7 +1511,7 @@ public: subst_cache m_subst; public: - arith_plugin(i_solver_context& ctx, ast_manager& m, front_end_params& p): + arith_plugin(i_solver_context& ctx, ast_manager& m, smt_params& p): qe_solver_plugin(m, m.get_family_id("arith"), ctx), m_util(m, p, ctx), m_trail(m) @@ -2562,7 +2562,7 @@ public: }; - qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, front_end_params& p) { + qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, smt_params& p) { if (p.m_nlquant_elim) { return alloc(nlarith_plugin, ctx, ctx.get_manager(), produce_models); } diff --git a/src/muz_qe/qe_cmd.cpp b/src/muz_qe/qe_cmd.cpp index ef8d1c058..6f001c9da 100644 --- a/src/muz_qe/qe_cmd.cpp +++ b/src/muz_qe/qe_cmd.cpp @@ -38,7 +38,7 @@ public: } virtual void execute(cmd_context & ctx) { - front_end_params par; + smt_params par; proof_ref pr(ctx.m()); qe::expr_quant_elim_star1 qe(ctx.m(), par); expr_ref result(ctx.m()); diff --git a/src/muz_qe/qe_sat_tactic.cpp b/src/muz_qe/qe_sat_tactic.cpp index 5f73e4a30..f33de6382 100644 --- a/src/muz_qe/qe_sat_tactic.cpp +++ b/src/muz_qe/qe_sat_tactic.cpp @@ -59,7 +59,7 @@ namespace qe { ast_manager& m; expr_ref m_false; volatile bool m_cancel; - front_end_params m_fparams; + smt_params m_fparams; params_ref m_params; unsigned m_extrapolate_strategy_param; bool m_projection_mode_param; diff --git a/src/muz_qe/qe_tactic.cpp b/src/muz_qe/qe_tactic.cpp index 971d677ea..5b522e041 100644 --- a/src/muz_qe/qe_tactic.cpp +++ b/src/muz_qe/qe_tactic.cpp @@ -24,7 +24,7 @@ Revision History: class qe_tactic : public tactic { struct imp { ast_manager & m; - front_end_params m_fparams; + smt_params m_fparams; volatile bool m_cancel; qe::expr_quant_elim m_qe; diff --git a/src/muz_qe/unit_subsumption_tactic.cpp b/src/muz_qe/unit_subsumption_tactic.cpp index cd43e73e3..1fb71490d 100644 --- a/src/muz_qe/unit_subsumption_tactic.cpp +++ b/src/muz_qe/unit_subsumption_tactic.cpp @@ -21,7 +21,7 @@ Author: struct unit_subsumption_tactic : public tactic { ast_manager& m; params_ref m_params; - front_end_params m_fparams; + smt_params m_fparams; volatile bool m_cancel; smt::context m_context; expr_ref_vector m_clauses; diff --git a/src/muz_qe/vsubst_tactic.cpp b/src/muz_qe/vsubst_tactic.cpp index 83e1c448b..b84202ee9 100644 --- a/src/muz_qe/vsubst_tactic.cpp +++ b/src/muz_qe/vsubst_tactic.cpp @@ -45,7 +45,7 @@ Notes: #include"arith_decl_plugin.h" #include"for_each_expr.h" #include"extension_model_converter.h" -#include"params2front_end_params.h" +#include"params2smt_params.h" #include"ast_smt2_pp.h" class vsubst_tactic : public tactic { @@ -93,8 +93,8 @@ class vsubst_tactic : public tactic { throw tactic_exception("there are no real variables"); } - front_end_params params; - params2front_end_params(p, params); + smt_params params; + params2smt_params(p, params); params.m_model = false; flet fl1(params.m_nlquant_elim, true); flet fl2(params.m_nl_arith_gb, false); diff --git a/src/parsers/smt/smtparser.cpp b/src/parsers/smt/smtparser.cpp index 53dffb28c..d3b2feeb7 100644 --- a/src/parsers/smt/smtparser.cpp +++ b/src/parsers/smt/smtparser.cpp @@ -37,7 +37,6 @@ Revision History: #include"var_subst.h" #include"well_sorted.h" #include"str_hashtable.h" -#include"front_end_params.h" #include"stopwatch.h" class id_param_info { diff --git a/src/shell/datalog_frontend.cpp b/src/shell/datalog_frontend.cpp index 4bfe2a545..c4aab9111 100644 --- a/src/shell/datalog_frontend.cpp +++ b/src/shell/datalog_frontend.cpp @@ -25,7 +25,7 @@ Revision History: #undef min #undef max #endif -#include"front_end_params.h" +#include"smt_params.h" #include"datalog_parser.h" #include"arith_decl_plugin.h" #include"dl_compiler.h" @@ -43,7 +43,7 @@ static datalog::context * g_ctx = 0; static datalog::rule_set * g_orig_rules; static datalog::instruction_block * g_code; static datalog::execution_context * g_ectx; -static front_end_params * g_params; +static smt_params * g_params; datalog_params::datalog_params(): m_default_table("sparse"), @@ -61,7 +61,7 @@ static void display_statistics( datalog::rule_set& orig_rules, datalog::instruction_block& code, datalog::execution_context& ex_ctx, - front_end_params& params, + smt_params& params, bool verbose ) { @@ -125,8 +125,10 @@ static void on_ctrl_c(int) { } -unsigned read_datalog(char const * file, datalog_params const& dl_params, front_end_params & front_end_params) { +unsigned read_datalog(char const * file) { IF_VERBOSE(1, verbose_stream() << "Z3 Datalog Engine\n";); + datalog_params dl_params; + smt_params s_params; ast_manager m; g_overall_time.start(); register_on_timeout_proc(on_timeout); @@ -136,11 +138,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ params.set_sym("default_table", dl_params.m_default_table); params.set_bool("default_table_checked", dl_params.m_default_table_checked); - datalog::context ctx(m, front_end_params, params); - size_t watermark = front_end_params.m_memory_high_watermark; - if (watermark == 0) { - memory::set_high_watermark(static_cast(UINT_MAX)); - } + datalog::context ctx(m, s_params, params); datalog::relation_manager & rmgr = ctx.get_rmanager(); datalog::relation_plugin & inner_plg = *rmgr.get_relation_plugin(symbol("tr_hashtable")); SASSERT(&inner_plg); @@ -190,7 +188,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ g_orig_rules = &original_rules; g_code = &rules_code; g_ectx = &ex_ctx; - g_params = &front_end_params; + g_params = &s_params; try { g_piece_timer.reset(); @@ -262,7 +260,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ original_rules, rules_code, ex_ctx, - front_end_params, + s_params, false); } @@ -274,7 +272,7 @@ unsigned read_datalog(char const * file, datalog_params const& dl_params, front_ original_rules, rules_code, ex_ctx, - front_end_params, + s_params, true); return ERR_MEMOUT; } diff --git a/src/shell/datalog_frontend.h b/src/shell/datalog_frontend.h index bf4194ef4..e53e35c89 100644 --- a/src/shell/datalog_frontend.h +++ b/src/shell/datalog_frontend.h @@ -25,7 +25,7 @@ struct datalog_params { datalog_params(); }; -unsigned read_datalog(char const * file, datalog_params const& dl_params, front_end_params & front_end_params); +unsigned read_datalog(char const * file); #endif /* _DATALOG_FRONTEND_H_ */ diff --git a/src/shell/main.cpp b/src/shell/main.cpp index ecbaf8887..fb205c872 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -41,7 +41,6 @@ std::string g_aux_input_file; char const * g_input_file = 0; bool g_standard_input = false; input_kind g_input_kind = IN_UNSPECIFIED; -front_end_params * g_front_end_params = 0; bool g_display_statistics = false; bool g_display_istatistics = false; @@ -98,36 +97,7 @@ void display_usage() { std::cout << " " << OPT << "dbg:tag enable assertions tagged with .\n"; #endif } - -class extra_params : public datalog_params { - bool & m_statistics; -public: - extra_params(): - m_statistics(g_display_statistics) { - } - - virtual ~extra_params() {} -}; - -extra_params* g_extra_params = 0; -bool g_params_initialized = false; - -void init_params() { - if (!g_params_initialized) { - z3_bound_num_procs(); - g_front_end_params = new front_end_params(); - g_extra_params = new extra_params(); - g_params_initialized = true; - } -} - -void del_params() { - delete g_extra_params; - delete g_front_end_params; - g_extra_params = 0; - g_front_end_params = 0; -} - + void parse_cmd_line_args(int argc, char ** argv) { int i = 1; char * eq_pos = 0; @@ -200,18 +170,9 @@ void parse_cmd_line_args(int argc, char ** argv) { long lvl = strtol(opt_arg, 0, 10); set_verbosity_level(lvl); } - else if (strcmp(opt_name, "vldt") == 0) { - g_front_end_params->m_model_validate = true; - } else if (strcmp(opt_name, "file") == 0) { g_input_file = opt_arg; } - else if (strcmp(opt_name, "r") == 0) { - if (!opt_arg) { - error("optional argument (/r:level) is missing."); - } - g_front_end_params->m_relevancy_lvl = strtol(opt_arg, 0, 10); - } else if (strcmp(opt_name, "T") == 0) { if (!opt_arg) error("option argument (/T:timeout) is missing."); @@ -221,8 +182,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); - g_front_end_params->m_soft_timeout = tm*1000; + gparams::set("timeout", opt_arg); } else if (strcmp(opt_name, "nw") == 0) { enable_warning_messages(false); @@ -248,7 +208,7 @@ void parse_cmd_line_args(int argc, char ** argv) { else if (strcmp(opt_name, "memory") == 0) { if (!opt_arg) error("option argument (/memory:val) is missing."); - g_front_end_params->m_memory_high_watermark = strtoul(opt_arg, 0, 10); + gparams::set("memory_max_size", opt_arg); } else { std::cerr << "Error: invalid command line option: " << arg << "\n"; @@ -288,27 +248,10 @@ char const * get_extension(char const * file_name) { } } -class global_state_initialiser { -public: - global_state_initialiser() { - memory::initialize(0); - init_params(); - } - - void reset() { - del_params(); - memory::finalize(); - } - - ~global_state_initialiser() { - reset(); - } -}; - int main(int argc, char ** argv) { try{ unsigned return_value = 0; - global_state_initialiser global_state; + memory::initialize(0); memory::exit_when_out_of_memory(true, "ERROR: out of memory"); parse_cmd_line_args(argc, argv); env_params::updt_params(); @@ -353,7 +296,7 @@ int main(int argc, char ** argv) { return_value = read_dimacs(g_input_file); break; case IN_DATALOG: - read_datalog(g_input_file, *g_extra_params, *g_front_end_params); + read_datalog(g_input_file); break; case IN_Z3_LOG: replay_z3_log(g_input_file); @@ -361,7 +304,6 @@ int main(int argc, char ** argv) { default: UNREACHABLE(); } - global_state.reset(); #ifdef _WINDOWS _CrtDumpMemoryLeaks(); #endif diff --git a/src/shell/smtlib_frontend.h b/src/shell/smtlib_frontend.h index d83944119..2c5eed70c 100644 --- a/src/shell/smtlib_frontend.h +++ b/src/shell/smtlib_frontend.h @@ -19,8 +19,6 @@ Revision History: #ifndef _SMTLIB_FRONTEND_H_ #define _SMTLIB_FRONTEND_H_ -#include"front_end_params.h" - unsigned read_smtlib_file(char const * benchmark_file); unsigned read_smtlib2_commands(char const * command_file); diff --git a/src/smt/asserted_formulas.cpp b/src/smt/asserted_formulas.cpp index 513aa7634..6da2c15f5 100644 --- a/src/smt/asserted_formulas.cpp +++ b/src/smt/asserted_formulas.cpp @@ -40,7 +40,7 @@ Revision History: #include"distribute_forall.h" #include"quasi_macros.h" -asserted_formulas::asserted_formulas(ast_manager & m, front_end_params & p): +asserted_formulas::asserted_formulas(ast_manager & m, smt_params & p): m_manager(m), m_params(p), m_pre_simplifier(m), diff --git a/src/smt/asserted_formulas.h b/src/smt/asserted_formulas.h index 23be4ae7c..e888a974e 100644 --- a/src/smt/asserted_formulas.h +++ b/src/smt/asserted_formulas.h @@ -19,7 +19,7 @@ Revision History: #ifndef _ASSERTED_FORMULAS_H_ #define _ASSERTED_FORMULAS_H_ -#include"front_end_params.h" +#include"smt_params.h" #include"simplifier.h" #include"basic_simplifier_plugin.h" #include"static_features.h" @@ -36,7 +36,7 @@ class bv_simplifier_plugin; class asserted_formulas { ast_manager & m_manager; - front_end_params & m_params; + smt_params & m_params; simplifier m_pre_simplifier; simplifier m_simplifier; basic_simplifier_plugin * m_bsimp; @@ -100,7 +100,7 @@ class asserted_formulas { bool canceled() { return m_cancel_flag; } public: - asserted_formulas(ast_manager & m, front_end_params & p); + asserted_formulas(ast_manager & m, smt_params & p); ~asserted_formulas(); void setup(); diff --git a/src/smt/expr_context_simplifier.cpp b/src/smt/expr_context_simplifier.cpp index 8fd5b41bb..b23bb3bdc 100644 --- a/src/smt/expr_context_simplifier.cpp +++ b/src/smt/expr_context_simplifier.cpp @@ -310,7 +310,7 @@ bool expr_context_simplifier::is_false(expr* e) const { // it occurs in the context (on the path) where it was inserted. // -expr_strong_context_simplifier::expr_strong_context_simplifier(front_end_params& p, ast_manager& m): +expr_strong_context_simplifier::expr_strong_context_simplifier(smt_params& p, ast_manager& m): m_manager(m), m_params(p), m_arith(m), m_id(0), m_fn(0,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()); diff --git a/src/smt/expr_context_simplifier.h b/src/smt/expr_context_simplifier.h index 6e13dcf43..2c1f32ddc 100644 --- a/src/smt/expr_context_simplifier.h +++ b/src/smt/expr_context_simplifier.h @@ -22,7 +22,7 @@ Revision History: #include "ast.h" #include "obj_hashtable.h" #include "basic_simplifier_plugin.h" -#include "front_end_params.h" +#include "smt_params.h" #include "smt_kernel.h" #include "arith_decl_plugin.h" @@ -57,7 +57,7 @@ private: class expr_strong_context_simplifier { ast_manager& m_manager; - front_end_params & m_params; + smt_params & m_params; arith_util m_arith; unsigned m_id; func_decl_ref m_fn; @@ -70,7 +70,7 @@ class expr_strong_context_simplifier { bool is_forced(expr* e, expr* v); public: - expr_strong_context_simplifier(front_end_params& p, ast_manager& m); + expr_strong_context_simplifier(smt_params& p, ast_manager& m); void operator()(expr* e, expr_ref& result) { simplify(e, result); } void operator()(expr_ref& result) { simplify(result.get(), result); } void push() { m_solver.push(); } diff --git a/src/smt/smt_case_split_queue.cpp b/src/smt/smt_case_split_queue.cpp index 808284224..7a03224cf 100644 --- a/src/smt/smt_case_split_queue.cpp +++ b/src/smt/smt_case_split_queue.cpp @@ -278,7 +278,7 @@ namespace smt { }; typedef int_hashtable > bool_var_set; context & m_context; - front_end_params &m_params; + smt_params &m_params; ast_manager & m_manager; ptr_vector m_queue; unsigned m_head; @@ -287,7 +287,7 @@ namespace smt { unsigned m_head2; svector m_scopes; public: - rel_case_split_queue(context & ctx, front_end_params & p): + rel_case_split_queue(context & ctx, smt_params & p): m_context(ctx), m_params(p), m_manager(ctx.get_manager()), @@ -465,14 +465,14 @@ namespace smt { typedef int_hashtable > bool_var_set; context & m_context; ast_manager & m_manager; - front_end_params &m_params; + smt_params &m_params; ptr_vector m_queue; unsigned m_head; int m_bs_num_bool_vars; //!< Number of boolean variable before starting to search. bool_var_act_queue m_delayed_queue; svector m_scopes; public: - rel_act_case_split_queue(context & ctx, front_end_params & p): + rel_act_case_split_queue(context & ctx, smt_params & p): m_context(ctx), m_manager(ctx.get_manager()), m_params(p), @@ -694,7 +694,7 @@ namespace smt { typedef int_hashtable > bool_var_set; context & m_context; - front_end_params & m_params; + smt_params & m_params; ast_manager & m_manager; ptr_vector m_queue; unsigned m_head; @@ -714,7 +714,7 @@ namespace smt { public: - rel_goal_case_split_queue(context & ctx, front_end_params & p): + rel_goal_case_split_queue(context & ctx, smt_params & p): m_context(ctx), m_params(p), m_manager(ctx.get_manager()), @@ -1088,7 +1088,7 @@ namespace smt { }; - case_split_queue * mk_case_split_queue(context & ctx, front_end_params & p) { + case_split_queue * mk_case_split_queue(context & ctx, smt_params & p) { if (p.m_relevancy_lvl < 2 && (p.m_case_split_strategy == CS_RELEVANCY || p.m_case_split_strategy == CS_RELEVANCY_ACTIVITY || p.m_case_split_strategy == CS_RELEVANCY_GOAL)) { warning_msg("relevacy must be enabled to use option CASE_SPLIT=3, 4 or 5"); diff --git a/src/smt/smt_case_split_queue.h b/src/smt/smt_case_split_queue.h index 106b97e38..d78739df1 100644 --- a/src/smt/smt_case_split_queue.h +++ b/src/smt/smt_case_split_queue.h @@ -48,7 +48,7 @@ namespace smt { virtual ~case_split_queue() {} }; - case_split_queue * mk_case_split_queue(context & ctx, front_end_params & p); + case_split_queue * mk_case_split_queue(context & ctx, smt_params & p); }; #endif /* _SMT_CASE_SPLIT_QUEUE_H_ */ diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index 071275dd4..d34aa2ec8 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -32,7 +32,7 @@ namespace smt { conflict_resolution::conflict_resolution(ast_manager & m, context & ctx, dyn_ack_manager & dyn_ack_manager, - front_end_params const & params, + smt_params const & params, literal_vector const & assigned_literals, vector & watches ): @@ -1419,7 +1419,7 @@ namespace smt { conflict_resolution * mk_conflict_resolution(ast_manager & m, context & ctx, dyn_ack_manager & dack_manager, - front_end_params const & params, + smt_params const & params, literal_vector const & assigned_literals, vector & watches) { return alloc(conflict_resolution, m, ctx, dack_manager, params, assigned_literals, watches); diff --git a/src/smt/smt_conflict_resolution.h b/src/smt/smt_conflict_resolution.h index 5287b4e26..a55b331dc 100644 --- a/src/smt/smt_conflict_resolution.h +++ b/src/smt/smt_conflict_resolution.h @@ -25,7 +25,7 @@ Revision History: #include"smt_enode.h" #include"dyn_ack.h" #include"obj_pair_hashtable.h" -#include"front_end_params.h" +#include"smt_params.h" #include"obj_pair_hashtable.h" #include"map.h" #include"watch_list.h" @@ -46,7 +46,7 @@ namespace smt { typedef obj_pair_set enode_pair_set; ast_manager & m_manager; - front_end_params const & m_params; + smt_params const & m_params; context & m_ctx; dyn_ack_manager & m_dyn_ack_manager; literal_vector const & m_assigned_literals; @@ -204,7 +204,7 @@ namespace smt { conflict_resolution(ast_manager & m, context & ctx, dyn_ack_manager & dack_manager, - front_end_params const & params, + smt_params const & params, literal_vector const & assigned_literals, vector & watches ); @@ -266,7 +266,7 @@ namespace smt { conflict_resolution * mk_conflict_resolution(ast_manager & m, context & ctx, dyn_ack_manager & dack_manager, - front_end_params const & params, + smt_params const & params, literal_vector const & assigned_literals, vector & watches ); diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index 3fb8398b4..a7623832f 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -39,7 +39,7 @@ Revision History: namespace smt { - context::context(ast_manager & m, front_end_params & p, params_ref const & _p): + context::context(ast_manager & m, smt_params & p, params_ref const & _p): m_manager(m), m_fparams(p), m_params(_p), @@ -102,7 +102,7 @@ namespace smt { flush(); } - context * context::mk_fresh(symbol const * l, front_end_params * p) { + 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); // copy missing simplifier_plugins diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index 204a56827..7940b17be 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -71,7 +71,7 @@ namespace smt { protected: ast_manager & m_manager; - front_end_params & m_fparams; + smt_params & m_fparams; params_ref m_params; setup m_setup; volatile bool m_cancel_flag; @@ -220,7 +220,7 @@ namespace smt { return m_asserted_formulas.get_simplifier(); } - front_end_params & get_fparams() { + smt_params & get_fparams() { return m_fparams; } @@ -1314,7 +1314,7 @@ namespace smt { void assert_expr_core(expr * e, proof * pr); public: - context(ast_manager & m, front_end_params & fp, params_ref const & p = params_ref()); + context(ast_manager & m, smt_params & fp, params_ref const & p = params_ref()); virtual ~context(); @@ -1325,7 +1325,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, front_end_params * p = 0); + context * mk_fresh(symbol const * l = 0, smt_params * p = 0); app * mk_eq_atom(expr * lhs, expr * rhs); diff --git a/src/smt/smt_kernel.cpp b/src/smt/smt_kernel.cpp index 9d87b1363..977f0ee4a 100644 --- a/src/smt/smt_kernel.cpp +++ b/src/smt/smt_kernel.cpp @@ -19,7 +19,7 @@ Revision History: #include"smt_kernel.h" #include"smt_context.h" #include"ast_smt2_pp.h" -#include"params2front_end_params.h" +#include"params2smt_params.h" namespace smt { @@ -27,12 +27,12 @@ namespace smt { smt::context m_kernel; params_ref m_params; - imp(ast_manager & m, front_end_params & fp, params_ref const & p): + imp(ast_manager & m, smt_params & fp, params_ref const & p): m_kernel(m, fp, p), m_params(p) { } - front_end_params & fparams() { + smt_params & fparams() { return m_kernel.get_fparams(); } @@ -179,11 +179,11 @@ namespace smt { } void updt_params(params_ref const & p) { - params2front_end_params(p, fparams()); + params2smt_params(p, fparams()); } }; - kernel::kernel(ast_manager & m, front_end_params & fp, params_ref const & p) { + kernel::kernel(ast_manager & m, smt_params & fp, params_ref const & p) { m_imp = alloc(imp, m, fp, p); } @@ -237,7 +237,7 @@ namespace smt { void kernel::reset() { ast_manager & _m = m(); - front_end_params & fps = m_imp->fparams(); + smt_params & fps = m_imp->fparams(); params_ref ps = m_imp->params(); #pragma omp critical (smt_kernel) { @@ -343,7 +343,7 @@ namespace smt { } void kernel::collect_param_descrs(param_descrs & d) { - solver_front_end_params_descrs(d); + solver_smt_params_descrs(d); } context & kernel::get_context() { diff --git a/src/smt/smt_kernel.h b/src/smt/smt_kernel.h index 4c381e113..37b044af1 100644 --- a/src/smt/smt_kernel.h +++ b/src/smt/smt_kernel.h @@ -34,7 +34,7 @@ Revision History: #include"statistics.h" #include"smt_failure.h" -struct front_end_params; +struct smt_params; class progress_callback; namespace smt { @@ -46,7 +46,7 @@ namespace smt { struct imp; imp * m_imp; public: - kernel(ast_manager & m, front_end_params & fp, params_ref const & p = params_ref()); + kernel(ast_manager & m, smt_params & fp, params_ref const & p = params_ref()); ~kernel(); diff --git a/src/smt/smt_model_checker.cpp b/src/smt/smt_model_checker.cpp index 58921bb35..704c272ee 100644 --- a/src/smt/smt_model_checker.cpp +++ b/src/smt/smt_model_checker.cpp @@ -281,7 +281,7 @@ namespace smt { void model_checker::init_aux_context() { if (!m_fparams) { - m_fparams = alloc(front_end_params, m_context->get_fparams()); + m_fparams = alloc(smt_params, m_context->get_fparams()); m_fparams->m_relevancy_lvl = 0; // no relevancy since the model checking problems are quantifier free } if (!m_aux_context) { diff --git a/src/smt/smt_model_checker.h b/src/smt/smt_model_checker.h index fca576090..5af7859ce 100644 --- a/src/smt/smt_model_checker.h +++ b/src/smt/smt_model_checker.h @@ -24,7 +24,7 @@ Revision History: #include"ast.h" #include"obj_hashtable.h" #include"qi_params.h" -#include"front_end_params.h" +#include"smt_params.h" #include"region.h" class proto_model; @@ -39,9 +39,9 @@ namespace smt { class model_checker { ast_manager & m_manager; qi_params const & m_params; - // copy of front_end_params for auxiliary context. + // copy of smt_params for auxiliary context. // the idea is to use a different configuration for the aux context (e.g., disable relevancy) - scoped_ptr m_fparams; + scoped_ptr m_fparams; quantifier_manager * m_qm; context * m_context; // owner of the model checker obj_map const * m_root2value; // temp field to store mapping received in the check method. diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index 14e63b982..799dd3c49 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -33,7 +33,7 @@ namespace smt { struct quantifier_manager::imp { quantifier_manager & m_wrapper; context & m_context; - front_end_params & m_params; + smt_params & m_params; qi_queue m_qi_queue; obj_map m_quantifier_stat; quantifier_stat_gen m_qstat_gen; @@ -41,7 +41,7 @@ namespace smt { scoped_ptr m_plugin; unsigned m_num_instances; - imp(quantifier_manager & wrapper, context & ctx, front_end_params & p, quantifier_manager_plugin * plugin): + imp(quantifier_manager & wrapper, context & ctx, smt_params & p, quantifier_manager_plugin * plugin): m_wrapper(wrapper), m_context(ctx), m_params(p), @@ -242,7 +242,7 @@ namespace smt { }; - quantifier_manager::quantifier_manager(context & ctx, front_end_params & fp, params_ref const & p) { + quantifier_manager::quantifier_manager(context & ctx, smt_params & fp, params_ref const & p) { m_imp = alloc(imp, *this, ctx, fp, mk_default_plugin()); m_imp->m_plugin->set_manager(*this); } @@ -355,7 +355,7 @@ namespace smt { #pragma omp critical (quantifier_manager) { context & ctx = m_imp->m_context; - front_end_params & p = m_imp->m_params; + smt_params & p = m_imp->m_params; quantifier_manager_plugin * plugin = m_imp->m_plugin->mk_fresh(); dealloc(m_imp); m_imp = alloc(imp, *this, ctx, p, plugin); @@ -395,7 +395,7 @@ namespace smt { // The default plugin uses E-matching, MBQI and quick-checker class default_qm_plugin : public quantifier_manager_plugin { quantifier_manager * m_qm; - front_end_params * m_fparams; + smt_params * m_fparams; context * m_context; scoped_ptr m_mam; scoped_ptr m_lazy_mam; diff --git a/src/smt/smt_quantifier.h b/src/smt/smt_quantifier.h index 3873c9737..19113229c 100644 --- a/src/smt/smt_quantifier.h +++ b/src/smt/smt_quantifier.h @@ -25,7 +25,7 @@ Revision History: #include"smt_types.h" class proto_model; -struct front_end_params; +struct smt_params; namespace smt { class quantifier_manager_plugin; @@ -35,7 +35,7 @@ namespace smt { struct imp; imp * m_imp; public: - quantifier_manager(context & ctx, front_end_params & fp, params_ref const & p); + quantifier_manager(context & ctx, smt_params & fp, params_ref const & p); ~quantifier_manager(); context & get_context() const; diff --git a/src/smt/smt_setup.cpp b/src/smt/smt_setup.cpp index ac080ccaa..f088870a4 100644 --- a/src/smt/smt_setup.cpp +++ b/src/smt/smt_setup.cpp @@ -33,7 +33,7 @@ Revision History: namespace smt { - setup::setup(context & c, front_end_params & params): + setup::setup(context & c, smt_params & params): m_context(c), m_manager(c.get_manager()), m_params(params), diff --git a/src/smt/smt_setup.h b/src/smt/smt_setup.h index 5c017a498..e0188537e 100644 --- a/src/smt/smt_setup.h +++ b/src/smt/smt_setup.h @@ -20,7 +20,7 @@ Revision History: #define _SMT_SETUP_H_ #include"ast.h" -#include"front_end_params.h" +#include"smt_params.h" struct static_features; namespace smt { @@ -42,7 +42,7 @@ namespace smt { class setup { context & m_context; ast_manager & m_manager; - front_end_params & m_params; + smt_params & m_params; symbol m_logic; bool m_already_configured; void setup_auto_config(); @@ -96,7 +96,7 @@ namespace smt { void setup_i_arith(); void setup_mi_arith(); public: - setup(context & c, front_end_params & params); + setup(context & c, smt_params & params); void mark_already_configured() { m_already_configured = true; } bool already_configured() const { return m_already_configured; } bool set_logic(symbol logic) { diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index 8807e1e2b..ad653a968 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -19,12 +19,12 @@ Notes: #include"solver_na2as.h" #include"smt_kernel.h" #include"reg_decl_plugins.h" -#include"front_end_params.h" +#include"smt_params.h" namespace smt { class solver : public solver_na2as { - front_end_params m_params; + smt_params m_params; smt::kernel * m_context; progress_callback * m_callback; public: diff --git a/src/smt/tactic/ctx_solver_simplify_tactic.cpp b/src/smt/tactic/ctx_solver_simplify_tactic.cpp index e5b625661..25c41c2a2 100644 --- a/src/smt/tactic/ctx_solver_simplify_tactic.cpp +++ b/src/smt/tactic/ctx_solver_simplify_tactic.cpp @@ -19,7 +19,7 @@ Notes: #include"ctx_solver_simplify_tactic.h" #include"arith_decl_plugin.h" -#include"front_end_params.h" +#include"smt_params.h" #include"smt_kernel.h" #include"ast_pp.h" #include"mk_simplified_app.h" @@ -28,7 +28,7 @@ Notes: class ctx_solver_simplify_tactic : public tactic { ast_manager& m; params_ref m_params; - front_end_params m_front_p; + smt_params m_front_p; smt::kernel m_solver; arith_util m_arith; mk_simplified_app m_mk_app; diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index c75e0d56b..a8694363c 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -19,12 +19,12 @@ Notes: #include"tactic.h" #include"tactical.h" #include"smt_kernel.h" -#include"front_end_params.h" -#include"params2front_end_params.h" +#include"smt_params.h" +#include"params2smt_params.h" #include"rewriter_types.h" class smt_tactic : public tactic { - front_end_params m_params; + smt_params m_params; params_ref m_params_ref; statistics m_stats; std::string m_failure; @@ -51,7 +51,7 @@ public: SASSERT(m_ctx == 0); } - front_end_params & fparams() { + smt_params & fparams() { return m_params; } @@ -64,15 +64,15 @@ public: TRACE("smt_tactic", tout << this << "\nupdt_params: " << p << "\n";); updt_params_core(p); m_params_ref = p; - // PARAM-TODO update params2front_end_params p ---> m_params - params2front_end_params(m_params_ref, fparams()); + // PARAM-TODO update params2smt_params p ---> m_params + params2smt_params(m_params_ref, fparams()); SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); } virtual void collect_param_descrs(param_descrs & r) { 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."); - solver_front_end_params_descrs(r); + solver_smt_params_descrs(r); } virtual void set_cancel(bool f) { diff --git a/src/smt/theory_diff_logic.h b/src/smt/theory_diff_logic.h index 80d729001..264ab9b2d 100644 --- a/src/smt/theory_diff_logic.h +++ b/src/smt/theory_diff_logic.h @@ -32,7 +32,7 @@ Revision History: #include"arith_decl_plugin.h" #include"smt_justification.h" #include"map.h" -#include"front_end_params.h" +#include"smt_params.h" #include"arith_eq_adapter.h" #include"smt_model_generator.h" #include"numeral_factory.h" @@ -251,7 +251,7 @@ namespace smt { } }; - front_end_params & m_params; + smt_params & m_params; arith_util m_util; arith_eq_adapter m_arith_eq_adapter; theory_diff_logic_statistics m_stats; @@ -305,7 +305,7 @@ namespace smt { void del_clause_eh(clause* cls); public: - theory_diff_logic(ast_manager& m, front_end_params & params): + theory_diff_logic(ast_manager& m, smt_params & params): theory(m.get_family_id("arith")), m_params(params), m_util(m), diff --git a/src/smt/theory_instgen.cpp b/src/smt/theory_instgen.cpp index f631fd04c..68e04aab0 100644 --- a/src/smt/theory_instgen.cpp +++ b/src/smt/theory_instgen.cpp @@ -230,12 +230,12 @@ namespace smt { class clause_subsumption { ast_manager& m; grounder m_grounder; - front_end_params m_params; + smt_params m_params; context m_ctx; quantifier_ref_vector m_assumptions; unsigned_vector m_limit; public: - clause_subsumption(ast_manager& m, front_end_params& p): + clause_subsumption(ast_manager& m, smt_params& p): m(m), m_grounder(m), m_params(p), m_ctx(m,m_params), m_assumptions(m) { m_params.m_instgen = false; } @@ -1131,7 +1131,7 @@ namespace smt { }; ast_manager& m_manager; - front_end_params& m_params; + smt_params& m_params; fo_clause_internalizer m_internalizer; instantiator m_instantiator; clause_subsumption m_subsumer; @@ -1184,7 +1184,7 @@ namespace smt { public: - theory_instgen_impl(ast_manager& m, front_end_params& p): + theory_instgen_impl(ast_manager& m, smt_params& p): theory_instgen(m.get_family_id("inst_gen")), m_manager(m), m_params(p), @@ -1277,7 +1277,7 @@ namespace smt { }; - theory_instgen* mk_theory_instgen(ast_manager& m, front_end_params& p) { + theory_instgen* mk_theory_instgen(ast_manager& m, smt_params& p) { return alloc(theory_instgen_impl, m, p); } diff --git a/src/smt/theory_instgen.h b/src/smt/theory_instgen.h index 076dad748..c32636e9b 100644 --- a/src/smt/theory_instgen.h +++ b/src/smt/theory_instgen.h @@ -25,7 +25,7 @@ Revision History: #define _THEORY_INST_GEN_H_ #include "smt_theory.h" -#include "front_end_params.h" +#include "smt_params.h" namespace smt { @@ -37,7 +37,7 @@ namespace smt { virtual char const * get_name() const { return "instgen"; } }; - theory_instgen* mk_theory_instgen(ast_manager& m, front_end_params& p); + theory_instgen* mk_theory_instgen(ast_manager& m, smt_params& p); }; diff --git a/src/smt/user_plugin/user_smt_theory.cpp b/src/smt/user_plugin/user_smt_theory.cpp index d95346469..ab4cc62c4 100644 --- a/src/smt/user_plugin/user_smt_theory.cpp +++ b/src/smt/user_plugin/user_smt_theory.cpp @@ -44,7 +44,7 @@ namespace smt { {} }; - user_theory::user_theory(ast_manager & m, front_end_params const& p, void * ext_context, void * ext_data, char const * name, family_id fid, user_decl_plugin * dp, user_simplifier_plugin * sp): + user_theory::user_theory(ast_manager & m, smt_params const& p, void * ext_context, void * ext_data, char const * name, family_id fid, user_decl_plugin * dp, user_simplifier_plugin * sp): theory(fid), m_params(p), m_ext_context(ext_context), diff --git a/src/smt/user_plugin/user_smt_theory.h b/src/smt/user_plugin/user_smt_theory.h index 3dd664738..56851b768 100644 --- a/src/smt/user_plugin/user_smt_theory.h +++ b/src/smt/user_plugin/user_smt_theory.h @@ -43,7 +43,7 @@ namespace smt { typedef union_find th_union_find; typedef std::pair var_pair; - front_end_params const& m_params; + smt_params const& m_params; void * m_ext_context; void * m_ext_data; std::string m_name; @@ -134,7 +134,7 @@ namespace smt { void assert_axiom_core(app* axiom); public: - user_theory(ast_manager & m, front_end_params const& p, void * ext_context, void * ext_data, char const * name, family_id fid, user_decl_plugin * dp, user_simplifier_plugin * sp); + user_theory(ast_manager & m, smt_params const& p, void * ext_context, void * ext_data, char const * name, family_id fid, user_decl_plugin * dp, user_simplifier_plugin * sp); virtual ~user_theory(); virtual theory * mk_fresh(context * new_ctx); diff --git a/src/solver/solver.h b/src/solver/solver.h index f26a5c5f4..5cd3da52b 100644 --- a/src/solver/solver.h +++ b/src/solver/solver.h @@ -23,8 +23,6 @@ Notes: #include"progress_callback.h" #include"params.h" -struct front_end_params; - /** \brief Abstract interface for making solvers available in the Z3 API and front-ends such as SMT 2.0 and (legacy) SMT 1.0. diff --git a/src/tactic/tactic.h b/src/tactic/tactic.h index 015b5fe0a..80de1bcd0 100644 --- a/src/tactic/tactic.h +++ b/src/tactic/tactic.h @@ -29,7 +29,6 @@ Notes: #include"tactic_exception.h" #include"lbool.h" -struct front_end_params; class progress_callback; typedef ptr_buffer goal_buffer; diff --git a/src/test/arith_simplifier_plugin.cpp b/src/test/arith_simplifier_plugin.cpp index 0ea1c2675..59f4996ce 100644 --- a/src/test/arith_simplifier_plugin.cpp +++ b/src/test/arith_simplifier_plugin.cpp @@ -1,5 +1,5 @@ #include "arith_eq_solver.h" -#include "front_end_params.h" +#include "smt_params.h" typedef rational numeral; typedef vector row; @@ -24,7 +24,7 @@ static void test_solve_integer_equations( } void tst_arith_simplifier_plugin() { - front_end_params params; + smt_params params; ast_manager m; arith_eq_solver asimp(m); diff --git a/src/test/check_assumptions.cpp b/src/test/check_assumptions.cpp index e6a5433e9..872af714c 100644 --- a/src/test/check_assumptions.cpp +++ b/src/test/check_assumptions.cpp @@ -1,5 +1,5 @@ #include "memory_manager.h" -#include "front_end_params.h" +#include "smt_params.h" #include "ast.h" #include "arith_decl_plugin.h" #include "bv_decl_plugin.h" @@ -9,7 +9,7 @@ void tst_check_assumptions() { memory::initialize(0); - front_end_params params; + smt_params params; ast_manager mgr; reg_decl_plugins(mgr); diff --git a/src/test/datalog_parser.cpp b/src/test/datalog_parser.cpp index 2d8a04225..64ee4201e 100644 --- a/src/test/datalog_parser.cpp +++ b/src/test/datalog_parser.cpp @@ -2,7 +2,7 @@ #include "ast_pp.h" #include "arith_decl_plugin.h" #include "dl_context.h" -#include "front_end_params.h" +#include "smt_params.h" #include "reg_decl_plugins.h" using namespace datalog; @@ -10,7 +10,7 @@ using namespace datalog; static void dparse_string(char const* str) { ast_manager m; - front_end_params params; + smt_params params; reg_decl_plugins(m); context ctx(m, params); @@ -37,7 +37,7 @@ static void dparse_string(char const* str) { static void dparse_file(char const* file) { ast_manager m; - front_end_params params; + smt_params params; reg_decl_plugins(m); context ctx(m, params); diff --git a/src/test/dl_context.cpp b/src/test/dl_context.cpp index b2530b9da..c004c531f 100644 --- a/src/test/dl_context.cpp +++ b/src/test/dl_context.cpp @@ -2,7 +2,7 @@ #include "ast_pp.h" #include "arith_decl_plugin.h" #include "dl_context.h" -#include "front_end_params.h" +#include "smt_params.h" using namespace datalog; @@ -27,7 +27,7 @@ static void dl_context_simple_query_test(params_ref & params) { ast_manager m; dl_decl_util decl_util(m); - front_end_params fparams; + smt_params fparams; context ctx(m, fparams); ctx.updt_params(params); @@ -49,7 +49,7 @@ static void dl_context_simple_query_test(params_ref & params) { void dl_context_saturate_file(params_ref & params, const char * f) { ast_manager m; dl_decl_util decl_util(m); - front_end_params fparams; + smt_params fparams; context ctx(m, fparams); ctx.updt_params(params); diff --git a/src/test/dl_product_relation.cpp b/src/test/dl_product_relation.cpp index ac895dacf..4b67b32af 100644 --- a/src/test/dl_product_relation.cpp +++ b/src/test/dl_product_relation.cpp @@ -19,7 +19,7 @@ namespace datalog { }; - void test_functional_columns(front_end_params fparams, params_ref& params) { + void test_functional_columns(smt_params fparams, params_ref& params) { ast_manager m; context ctx(m, fparams); ctx.updt_params(params); @@ -121,7 +121,7 @@ namespace datalog { } } - void test_finite_product_relation(front_end_params fparams, params_ref& params) { + void test_finite_product_relation(smt_params fparams, params_ref& params) { ast_manager m; context ctx(m, fparams); ctx.updt_params(params); @@ -338,7 +338,7 @@ namespace datalog { using namespace datalog; void tst_dl_product_relation() { - front_end_params fparams; + smt_params fparams; params_ref params; test_functional_columns(fparams, params); diff --git a/src/test/dl_query.cpp b/src/test/dl_query.cpp index 2cca7cce6..712ae386a 100644 --- a/src/test/dl_query.cpp +++ b/src/test/dl_query.cpp @@ -2,7 +2,7 @@ #include "ast_pp.h" #include "dl_table_relation.h" #include "dl_context.h" -#include "front_end_params.h" +#include "smt_params.h" #include "stopwatch.h" #include "reg_decl_plugins.h" @@ -43,7 +43,7 @@ void dl_query_ask_for_last_arg(context & ctx, func_decl * pred, relation_fact & } } -void dl_query_test(ast_manager & m, front_end_params & fparams, params_ref& params, +void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params, context & ctx_b, char const* problem_file, unsigned test_count, bool use_magic_sets) { @@ -124,7 +124,7 @@ void dl_query_test(ast_manager & m, front_end_params & fparams, params_ref& para } } -void dl_query_test_wpa(front_end_params & fparams, params_ref& params) { +void dl_query_test_wpa(smt_params & fparams, params_ref& params) { params.set_bool(":magic-sets-for-queries", true); ast_manager m; reg_decl_plugins(m); @@ -183,7 +183,7 @@ void dl_query_test_wpa(front_end_params & fparams, params_ref& params) { } void tst_dl_query() { - front_end_params fparams; + smt_params fparams; params_ref params; params.set_sym(":default-table", symbol("sparse")); params.set_sym(":default-relation", symbol("tr_sparse")); diff --git a/src/test/dl_relation.cpp b/src/test/dl_relation.cpp index 095751cb6..fe8ba1730 100644 --- a/src/test/dl_relation.cpp +++ b/src/test/dl_relation.cpp @@ -8,7 +8,7 @@ namespace datalog { static void test_interval_relation() { - front_end_params params; + smt_params params; ast_manager ast_m; context ctx(ast_m, params); arith_util autil(ast_m); @@ -111,7 +111,7 @@ namespace datalog { std::cout << "bound relation\n"; - front_end_params params; + smt_params params; ast_manager ast_m; context ctx(ast_m, params); arith_util autil(ast_m); diff --git a/src/test/dl_smt_relation.cpp b/src/test/dl_smt_relation.cpp index fa66a89c9..bae1784b0 100644 --- a/src/test/dl_smt_relation.cpp +++ b/src/test/dl_smt_relation.cpp @@ -14,7 +14,7 @@ namespace datalog { arith_util a(m); sort* int_sort = a.mk_int(); sort* real_sort = a.mk_real(); - front_end_params params; + smt_params params; context ctx(m, params); relation_manager & rm = ctx.get_rmanager(); relation_signature sig1; diff --git a/src/test/dl_table.cpp b/src/test/dl_table.cpp index a29ef48d8..6383dc1ab 100644 --- a/src/test/dl_table.cpp +++ b/src/test/dl_table.cpp @@ -24,7 +24,7 @@ static void test_table(mk_table_fn mk_table) { sig.push_back(4); sig.push_back(8); sig.push_back(4); - front_end_params params; + smt_params params; ast_manager ast_m; datalog::context ctx(ast_m, params); datalog::relation_manager & m = ctx.get_rmanager(); diff --git a/src/test/model_retrieval.cpp b/src/test/model_retrieval.cpp index 0a0b8a0dc..da6c3ddd0 100644 --- a/src/test/model_retrieval.cpp +++ b/src/test/model_retrieval.cpp @@ -1,6 +1,6 @@ #include "ast.h" -#include "front_end_params.h" +#include "smt_params.h" #include "smt_context.h" #include "arith_decl_plugin.h" #include "bv_decl_plugin.h" @@ -11,7 +11,7 @@ void tst_model_retrieval() { memory::initialize(0); - front_end_params params; + smt_params params; params.m_model = true; diff --git a/src/test/quant_elim.cpp b/src/test/quant_elim.cpp index 0f1ddfabd..4e750c34e 100644 --- a/src/test/quant_elim.cpp +++ b/src/test/quant_elim.cpp @@ -1,5 +1,5 @@ #include "ast.h" -#include "front_end_params.h" +#include "smt_params.h" #include "simplifier.h" #include "qe.h" #include "basic_simplifier_plugin.h" @@ -33,7 +33,7 @@ static void test_qe(ast_manager& m, lbool expected_outcome, expr* fml, char cons // enable_trace("bv_bit_prop"); simplifier simp(m); - front_end_params params; + smt_params params; // params.m_quant_elim = true; std::cout << mk_pp(fml, m) << "\n"; diff --git a/src/test/quant_solve.cpp b/src/test/quant_solve.cpp index bae63f129..36b354b44 100644 --- a/src/test/quant_solve.cpp +++ b/src/test/quant_solve.cpp @@ -1,5 +1,5 @@ #include "ast.h" -#include "front_end_params.h" +#include "smt_params.h" #include "qe.h" #include "arith_decl_plugin.h" #include "ast_pp.h" @@ -28,7 +28,7 @@ static void validate_quant_solution(ast_manager& m, expr* fml, expr* guard, qe:: (*rep)(fml1); expr_ref tmp(m); tmp = m.mk_not(m.mk_implies(guard, fml1)); - front_end_params fp; + smt_params fp; smt::kernel solver(m, fp); solver.assert_expr(tmp); lbool res = solver.check(); @@ -63,7 +63,7 @@ static void validate_quant_solutions(app* x, expr* fml, expr_ref_vector& guards) std::cout << mk_pp(fml2, m) << "\n"; tmp = m.mk_not(m.mk_iff(fml2, tmp)); std::cout << mk_pp(tmp, m) << "\n"; - front_end_params fp; + smt_params fp; smt::kernel solver(m, fp); solver.assert_expr(tmp); lbool res = solver.check(); @@ -78,7 +78,7 @@ static void validate_quant_solutions(app* x, expr* fml, expr_ref_vector& guards) static void test_quant_solver(ast_manager& m, unsigned sz, app*const* xs, expr* fml, bool validate) { - front_end_params params; + smt_params params; qe::expr_quant_elim qe(m, params); qe::guarded_defs defs(m); bool success = qe.solve_for_vars(sz, xs, fml, defs); @@ -98,8 +98,7 @@ static void test_quant_solver(ast_manager& m, unsigned sz, app*const* xs, expr* static expr_ref parse_fml(ast_manager& m, char const* str) { expr_ref result(m); - front_end_params fp; - cmd_context ctx(&fp, false, &m); + cmd_context ctx(false, &m); ctx.set_ignore_check(true); std::ostringstream buffer; buffer << "(declare-const x Int)\n" diff --git a/src/test/smt_context.cpp b/src/test/smt_context.cpp index 853bde068..49ada8ebd 100644 --- a/src/test/smt_context.cpp +++ b/src/test/smt_context.cpp @@ -3,7 +3,7 @@ void tst_smt_context() { - front_end_params params; + smt_params params; ast_manager m; reg_decl_plugins(m); diff --git a/src/test/substitution.cpp b/src/test/substitution.cpp index 38f85bb11..889666972 100644 --- a/src/test/substitution.cpp +++ b/src/test/substitution.cpp @@ -1,5 +1,5 @@ #include "expr_substitution.h" -#include "front_end_params.h" +#include "smt_params.h" #include "substitution.h" #include "unifier.h" #include "bv_decl_plugin.h" @@ -10,7 +10,7 @@ void tst_substitution() { memory::initialize(0); - front_end_params params; + smt_params params; params.m_model = true; enable_trace("subst_bug"); diff --git a/src/test/theory_dl.cpp b/src/test/theory_dl.cpp index d07ec34af..9521a8932 100644 --- a/src/test/theory_dl.cpp +++ b/src/test/theory_dl.cpp @@ -6,7 +6,7 @@ void tst_theory_dl() { ast_manager m; - front_end_params params; + smt_params params; params.m_model = true; datalog::dl_decl_util u(m); smt::context ctx(m, params); diff --git a/src/util/env_params.cpp b/src/util/env_params.cpp index a76c2308b..28d80d92d 100644 --- a/src/util/env_params.cpp +++ b/src/util/env_params.cpp @@ -27,10 +27,12 @@ void env_params::updt_params() { set_verbosity_level(p.get_uint("verbose", get_verbosity_level())); enable_warning_messages(p.get_bool("warning", true)); memory::set_max_size(p.get_uint("memory_max_size", 0)); + memory::set_high_watermark(p.get_uint("memory_high_watermark", 0)); } void env_params::collect_param_descrs(param_descrs & d) { d.insert("verbose", CPK_UINT, "be verbose, where the value is the verbosity level", "0"); d.insert("warning", CPK_BOOL, "enable/disable warning messages", "true"); - d.insert("memory_max_size", CPK_UINT, "set hard upper limit for memory consumption (in megabytes), if 0 then there is no bound.", "0"); + d.insert("memory_max_size", CPK_UINT, "set hard upper limit for memory consumption (in megabytes), if 0 then there is no limit", "0"); + d.insert("memory_high_watermark", CPK_UINT, "set high watermark for memory consumption (in megabytes), if 0 then there is no limit", "0"); } From 6107e8d9ce0ac487740e92546a155370c028f164 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 10:47:04 -0800 Subject: [PATCH 25/34] moved old params files Signed-off-by: Leonardo de Moura --- scripts/mk_project.py | 14 +++---- .../pattern}/pattern_inference_params.h | 0 src/ast/proof_checker/proof_checker.cpp | 1 - .../bit_blaster}/bit_blaster_params.h | 0 .../simplifier}/arith_simplifier_params.h | 0 src/ast/simplifier/array_simplifier_params.h | 33 ++++++++++++++++ .../simplifier/array_simplifier_plugin.cpp | 2 +- src/ast/simplifier/array_simplifier_plugin.h | 6 +-- .../simplifier}/bv_simplifier_params.h | 6 --- .../arith_simplifier_params.cpp | 27 ------------- .../pattern_inference_params.cpp | 38 ------------------- src/{front_end_params => smt/params}/README | 0 .../params}/dyn_ack_params.cpp | 0 .../params}/dyn_ack_params.h | 0 .../params}/params2smt_params.cpp | 0 .../params}/params2smt_params.h | 0 .../params}/preprocessor_params.h | 0 .../params}/qi_params.h | 0 .../params}/smt_params.cpp | 0 .../params}/smt_params.h | 0 .../params}/theory_arith_params.cpp | 0 .../params}/theory_arith_params.h | 0 .../params}/theory_array_params.h | 10 ++--- .../params}/theory_bv_params.h | 0 .../params}/theory_datatype_params.h | 0 25 files changed, 47 insertions(+), 90 deletions(-) rename src/{front_end_params => ast/pattern}/pattern_inference_params.h (100%) rename src/{front_end_params => ast/rewriter/bit_blaster}/bit_blaster_params.h (100%) rename src/{front_end_params => ast/simplifier}/arith_simplifier_params.h (100%) create mode 100644 src/ast/simplifier/array_simplifier_params.h rename src/{front_end_params => ast/simplifier}/bv_simplifier_params.h (61%) delete mode 100644 src/front_end_params/arith_simplifier_params.cpp delete mode 100644 src/front_end_params/pattern_inference_params.cpp rename src/{front_end_params => smt/params}/README (100%) rename src/{front_end_params => smt/params}/dyn_ack_params.cpp (100%) rename src/{front_end_params => smt/params}/dyn_ack_params.h (100%) rename src/{front_end_params => smt/params}/params2smt_params.cpp (100%) rename src/{front_end_params => smt/params}/params2smt_params.h (100%) rename src/{front_end_params => smt/params}/preprocessor_params.h (100%) rename src/{front_end_params => smt/params}/qi_params.h (100%) rename src/{front_end_params => smt/params}/smt_params.cpp (100%) rename src/{front_end_params => smt/params}/smt_params.h (100%) rename src/{front_end_params => smt/params}/theory_arith_params.cpp (100%) rename src/{front_end_params => smt/params}/theory_arith_params.h (100%) rename src/{front_end_params => smt/params}/theory_array_params.h (88%) rename src/{front_end_params => smt/params}/theory_bv_params.h (100%) rename src/{front_end_params => smt/params}/theory_datatype_params.h (100%) diff --git a/scripts/mk_project.py b/scripts/mk_project.py index ac6f44a83..707d067e2 100644 --- a/scripts/mk_project.py +++ b/scripts/mk_project.py @@ -35,17 +35,15 @@ def init_project_def(): add_lib('cmd_context', ['solver', 'rewriter']) add_lib('extra_cmds', ['cmd_context', 'subpaving_tactic', 'arith_tactics'], 'cmd_context/extra_cmds') add_lib('smt2parser', ['cmd_context', 'parser_util'], 'parsers/smt2') - # Front-end-params module still contain a lot of parameters for smt solver component. - # This should be fixed - add_lib('front_end_params', ['ast']) + add_lib('proof_checker', ['rewriter'], 'ast/proof_checker') # Simplifier module will be deleted in the future. # It has been replaced with rewriter module. - add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier') + add_lib('simplifier', ['rewriter'], 'ast/simplifier') + add_lib('macros', ['simplifier'], 'ast/macros') add_lib('pattern', ['normal_forms', 'smt2parser', 'simplifier'], 'ast/pattern') - add_lib('macros', ['simplifier', 'front_end_params'], 'ast/macros') - add_lib('proof_checker', ['rewriter', 'front_end_params'], 'ast/proof_checker') - add_lib('bit_blaster', ['rewriter', 'simplifier', 'front_end_params'], 'ast/rewriter/bit_blaster') - add_lib('proto_model', ['model', 'simplifier', 'front_end_params'], 'smt/proto_model') + add_lib('bit_blaster', ['rewriter', 'simplifier'], 'ast/rewriter/bit_blaster') + add_lib('smt_params', ['ast', 'simplifier', 'pattern', 'bit_blaster'], 'smt/params') + add_lib('proto_model', ['model', 'simplifier', 'smt_params'], 'smt/proto_model') add_lib('smt', ['bit_blaster', 'macros', 'normal_forms', 'cmd_context', 'proto_model', 'substitution', 'grobner', 'euclid', 'proof_checker', 'pattern', 'parser_util']) add_lib('user_plugin', ['smt'], 'smt/user_plugin') diff --git a/src/front_end_params/pattern_inference_params.h b/src/ast/pattern/pattern_inference_params.h similarity index 100% rename from src/front_end_params/pattern_inference_params.h rename to src/ast/pattern/pattern_inference_params.h diff --git a/src/ast/proof_checker/proof_checker.cpp b/src/ast/proof_checker/proof_checker.cpp index bef0fea9c..240504048 100644 --- a/src/ast/proof_checker/proof_checker.cpp +++ b/src/ast/proof_checker/proof_checker.cpp @@ -4,7 +4,6 @@ // include "spc_decl_plugin.h" #include "ast_smt_pp.h" #include "arith_decl_plugin.h" -#include "smt_params.h" #include "th_rewriter.h" #include "var_subst.h" diff --git a/src/front_end_params/bit_blaster_params.h b/src/ast/rewriter/bit_blaster/bit_blaster_params.h similarity index 100% rename from src/front_end_params/bit_blaster_params.h rename to src/ast/rewriter/bit_blaster/bit_blaster_params.h diff --git a/src/front_end_params/arith_simplifier_params.h b/src/ast/simplifier/arith_simplifier_params.h similarity index 100% rename from src/front_end_params/arith_simplifier_params.h rename to src/ast/simplifier/arith_simplifier_params.h diff --git a/src/ast/simplifier/array_simplifier_params.h b/src/ast/simplifier/array_simplifier_params.h new file mode 100644 index 000000000..8b9f3e37e --- /dev/null +++ b/src/ast/simplifier/array_simplifier_params.h @@ -0,0 +1,33 @@ +/*++ +Copyright (c) 2006 Microsoft Corporation + +Module Name: + + array_simplifier_params.h + +Abstract: + + This file was created during code reorg. + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#ifndef _ARRAY_SIMPLIFIER_PARAMS_H_ +#define _ARRAY_SIMPLIFIER_PARAMS_H_ + +struct array_simplifier_params { + bool m_array_canonize_simplify; + bool m_array_simplify; // temporary hack for disabling array simplifier plugin. + + array_simplifier_params(): + m_array_canonize_simplify(false), + m_array_simplify(true) { + } +}; + +#endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */ + diff --git a/src/ast/simplifier/array_simplifier_plugin.cpp b/src/ast/simplifier/array_simplifier_plugin.cpp index 8654db275..75c3cdbce 100644 --- a/src/ast/simplifier/array_simplifier_plugin.cpp +++ b/src/ast/simplifier/array_simplifier_plugin.cpp @@ -33,7 +33,7 @@ array_simplifier_plugin::array_simplifier_plugin( ast_manager & m, basic_simplifier_plugin& s, simplifier& simp, - theory_array_params const& p) : + array_simplifier_params const& p) : simplifier_plugin(symbol("array"),m), m_util(m), m_simp(s), diff --git a/src/ast/simplifier/array_simplifier_plugin.h b/src/ast/simplifier/array_simplifier_plugin.h index fffa18c3f..572da9a17 100644 --- a/src/ast/simplifier/array_simplifier_plugin.h +++ b/src/ast/simplifier/array_simplifier_plugin.h @@ -24,7 +24,7 @@ Revision History: #include"array_decl_plugin.h" #include"simplifier_plugin.h" #include"basic_simplifier_plugin.h" -#include"theory_array_params.h" +#include"array_simplifier_params.h" #include"simplifier.h" #include"obj_hashtable.h" #include"lbool.h" @@ -71,7 +71,7 @@ class array_simplifier_plugin : public simplifier_plugin { array_util m_util; basic_simplifier_plugin& m_simp; simplifier& m_simplifier; - theory_array_params const& m_params; + array_simplifier_params const& m_params; select_cache m_select_cache; ptr_vector m_tmp; ptr_vector m_tmp2; @@ -100,7 +100,7 @@ class array_simplifier_plugin : public simplifier_plugin { public: - array_simplifier_plugin(ast_manager & m, basic_simplifier_plugin& s, simplifier& simp, theory_array_params const& p); + array_simplifier_plugin(ast_manager & m, basic_simplifier_plugin& s, simplifier& simp, array_simplifier_params const& p); virtual ~array_simplifier_plugin(); virtual bool reduce(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result); diff --git a/src/front_end_params/bv_simplifier_params.h b/src/ast/simplifier/bv_simplifier_params.h similarity index 61% rename from src/front_end_params/bv_simplifier_params.h rename to src/ast/simplifier/bv_simplifier_params.h index 887940e36..4bec70285 100644 --- a/src/front_end_params/bv_simplifier_params.h +++ b/src/ast/simplifier/bv_simplifier_params.h @@ -27,12 +27,6 @@ struct bv_simplifier_params { m_hi_div0(true), m_bv2int_distribute(true) { } -#if 0 - void register_params(ini_params & p) { - p.register_bool_param("hi_div0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted."); - p.register_bool_param("bv2int_distribute", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators."); - } -#endif }; #endif /* _BV_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/front_end_params/arith_simplifier_params.cpp b/src/front_end_params/arith_simplifier_params.cpp deleted file mode 100644 index 8cf07b915..000000000 --- a/src/front_end_params/arith_simplifier_params.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - arith_simplifier_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-05-09. - -Revision History: - ---*/ - -#include"arith_simplifier_params.h" - -#if 0 -void arith_simplifier_params::register_params(ini_params & p) { - p.register_bool_param("arith_expand_eqs", m_arith_expand_eqs); - p.register_bool_param("arith_process_all_eqs", m_arith_process_all_eqs); -} -#endif diff --git a/src/front_end_params/pattern_inference_params.cpp b/src/front_end_params/pattern_inference_params.cpp deleted file mode 100644 index cfc0df4f1..000000000 --- a/src/front_end_params/pattern_inference_params.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/*++ -Copyright (c) 2006 Microsoft Corporation - -Module Name: - - pattern_inference_params.cpp - -Abstract: - - - -Author: - - Leonardo de Moura (leonardo) 2008-03-24. - -Revision History: - ---*/ -#include"pattern_inference_params.h" - -#if 0 -void pattern_inference_params::register_params(ini_params & p) { - p.register_unsigned_param("pi_max_multi_patterns", m_pi_max_multi_patterns, - "when patterns are not provided, the prover uses a heuristic to infer them. This option sets the threshold on the number of extra multi-patterns that can be created. By default, the prover creates at most one multi-pattern when there is no unary pattern"); - p.register_bool_param("pi_block_loop_patterns", m_pi_block_loop_patterns, - "block looping patterns during pattern inference"); - p.register_int_param("pi_arith", 0, 2, reinterpret_cast(m_pi_arith), - "0 - do not infer patterns with arithmetic terms, 1 - use patterns with arithmetic terms if there is no other pattern, 2 - always use patterns with arithmetic terms."); - p.register_bool_param("pi_use_database", m_pi_use_database); - p.register_unsigned_param("pi_arith_weight", m_pi_arith_weight, "default weight for quantifiers where the only available pattern has nested arithmetic terms."); - p.register_unsigned_param("pi_non_nested_arith_weight", m_pi_non_nested_arith_weight, "default weight for quantifiers where the only available pattern has non nested arithmetic terms."); - p.register_bool_param("pi_pull_quantifiers", m_pi_pull_quantifiers, "pull nested quantifiers, if no pattern was found."); - p.register_int_param("pi_nopat_weight", m_pi_nopat_weight, "set weight of quantifiers without patterns, if negative the weight is not changed."); - p.register_bool_param("pi_avoid_skolems", m_pi_avoid_skolems); - p.register_bool_param("pi_warnings", m_pi_warnings, "enable/disable warning messages in the pattern inference module."); -} -#endif - diff --git a/src/front_end_params/README b/src/smt/params/README similarity index 100% rename from src/front_end_params/README rename to src/smt/params/README diff --git a/src/front_end_params/dyn_ack_params.cpp b/src/smt/params/dyn_ack_params.cpp similarity index 100% rename from src/front_end_params/dyn_ack_params.cpp rename to src/smt/params/dyn_ack_params.cpp diff --git a/src/front_end_params/dyn_ack_params.h b/src/smt/params/dyn_ack_params.h similarity index 100% rename from src/front_end_params/dyn_ack_params.h rename to src/smt/params/dyn_ack_params.h diff --git a/src/front_end_params/params2smt_params.cpp b/src/smt/params/params2smt_params.cpp similarity index 100% rename from src/front_end_params/params2smt_params.cpp rename to src/smt/params/params2smt_params.cpp diff --git a/src/front_end_params/params2smt_params.h b/src/smt/params/params2smt_params.h similarity index 100% rename from src/front_end_params/params2smt_params.h rename to src/smt/params/params2smt_params.h diff --git a/src/front_end_params/preprocessor_params.h b/src/smt/params/preprocessor_params.h similarity index 100% rename from src/front_end_params/preprocessor_params.h rename to src/smt/params/preprocessor_params.h diff --git a/src/front_end_params/qi_params.h b/src/smt/params/qi_params.h similarity index 100% rename from src/front_end_params/qi_params.h rename to src/smt/params/qi_params.h diff --git a/src/front_end_params/smt_params.cpp b/src/smt/params/smt_params.cpp similarity index 100% rename from src/front_end_params/smt_params.cpp rename to src/smt/params/smt_params.cpp diff --git a/src/front_end_params/smt_params.h b/src/smt/params/smt_params.h similarity index 100% rename from src/front_end_params/smt_params.h rename to src/smt/params/smt_params.h diff --git a/src/front_end_params/theory_arith_params.cpp b/src/smt/params/theory_arith_params.cpp similarity index 100% rename from src/front_end_params/theory_arith_params.cpp rename to src/smt/params/theory_arith_params.cpp diff --git a/src/front_end_params/theory_arith_params.h b/src/smt/params/theory_arith_params.h similarity index 100% rename from src/front_end_params/theory_arith_params.h rename to src/smt/params/theory_arith_params.h diff --git a/src/front_end_params/theory_array_params.h b/src/smt/params/theory_array_params.h similarity index 88% rename from src/front_end_params/theory_array_params.h rename to src/smt/params/theory_array_params.h index e33bc2566..c1ae8ce32 100644 --- a/src/front_end_params/theory_array_params.h +++ b/src/smt/params/theory_array_params.h @@ -19,6 +19,8 @@ Revision History: #ifndef _THEORY_ARRAY_PARAMS_H_ #define _THEORY_ARRAY_PARAMS_H_ +#include"array_simplifier_params.h" + enum array_solver_id { AR_NO_ARRAY, AR_SIMPLE, @@ -26,7 +28,7 @@ enum array_solver_id { AR_FULL }; -struct theory_array_params { +struct theory_array_params : public array_simplifier_params { array_solver_id m_array_mode; bool m_array_weak; bool m_array_extensional; @@ -36,8 +38,6 @@ struct theory_array_params { bool m_array_always_prop_upward; bool m_array_lazy_ieq; unsigned m_array_lazy_ieq_delay; - bool m_array_canonize_simplify; - bool m_array_simplify; // temporary hack for disabling array simplifier plugin. theory_array_params(): m_array_mode(AR_FULL), @@ -48,9 +48,7 @@ struct theory_array_params { m_array_cg(false), m_array_always_prop_upward(true), // UPWARDs filter is broken... TODO: fix it m_array_lazy_ieq(false), - m_array_lazy_ieq_delay(10), - m_array_canonize_simplify(false), - m_array_simplify(true) { + m_array_lazy_ieq_delay(10) { } #if 0 diff --git a/src/front_end_params/theory_bv_params.h b/src/smt/params/theory_bv_params.h similarity index 100% rename from src/front_end_params/theory_bv_params.h rename to src/smt/params/theory_bv_params.h diff --git a/src/front_end_params/theory_datatype_params.h b/src/smt/params/theory_datatype_params.h similarity index 100% rename from src/front_end_params/theory_datatype_params.h rename to src/smt/params/theory_datatype_params.h From 6a220c8b58929c6d3461774cbef17edc55ae9afb Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 11:27:39 -0800 Subject: [PATCH 26/34] moved old params files Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 277a7e702..c2cbb3f33 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1461,19 +1461,22 @@ def pyg_default_as_c_literal(p): return 'symbol("%s")' % p[2] return p[2] -def def_module_params(module_name, export, params): +def def_module_params(module_name, export, params, class_name=None): pyg = get_curr_pyg() + print os.path.split(get_curr_pyg) hpp = '%shpp' % pyg[:len(pyg)-3] out = open(hpp, 'w') + if class_name == None: + class_name = '%s_params' % module_name out.write('// Automatically generated file\n') out.write('#include"params.h"\n') if export: out.write('#include"gparams.h"\n') - out.write('struct %s_params {\n' % module_name) + out.write('struct %s {\n' % class_name) out.write(' params_ref const & p;\n') if export: out.write(' params_ref g;\n') - out.write(' %s_params(params_ref const & _p = params_ref()):\n' % module_name) + out.write(' %s(params_ref const & _p = params_ref()):\n' % class_name) out.write(' p(_p)') if export: out.write(', g(gparams::get_module("%s"))' % module_name) @@ -1484,7 +1487,7 @@ def def_module_params(module_name, export, params): out.write(' }\n') if export: out.write(' /*\n') - out.write(" REG_MODULE_PARAMS('%s', '%s_params::collect_param_descrs')\n" % (module_name, module_name)) + out.write(" REG_MODULE_PARAMS('%s', '%s::collect_param_descrs')\n" % (module_name, class_name)) out.write(' */\n') # Generated accessors for param in params: From 8d62c95a5476067b36d80cf7102d2c776dad9a2e Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 11:31:38 -0800 Subject: [PATCH 27/34] fixed mk_make Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index c2cbb3f33..452a915d1 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1463,11 +1463,11 @@ def pyg_default_as_c_literal(p): def def_module_params(module_name, export, params, class_name=None): pyg = get_curr_pyg() - print os.path.split(get_curr_pyg) - hpp = '%shpp' % pyg[:len(pyg)-3] - out = open(hpp, 'w') + dirname = os.path.split(get_curr_pyg())[0] if class_name == None: class_name = '%s_params' % module_name + hpp = os.path.join(dirname, '%s.hpp' % class_name) + out = open(hpp, 'w') out.write('// Automatically generated file\n') out.write('#include"params.h"\n') if export: From c82b8174d8d1894c3b0f412234aab2fb63368b20 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 12:08:58 -0800 Subject: [PATCH 28/34] fixed win compilation bug Signed-off-by: Leonardo de Moura --- src/muz_qe/pdr_interpolant_provider.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/muz_qe/pdr_interpolant_provider.cpp b/src/muz_qe/pdr_interpolant_provider.cpp index de1c62d79..7c9afd74a 100644 --- a/src/muz_qe/pdr_interpolant_provider.cpp +++ b/src/muz_qe/pdr_interpolant_provider.cpp @@ -306,8 +306,7 @@ lbool interpolant_provider_impl::get_interpolant(expr * f1, expr * f2, expr_ref& return l_undef; } - smt_params dummy_params; - cmd_context cctx(&dummy_params, false, &m); + cmd_context cctx(false, &m); for_each_expr(used_symbol_inserter(cctx), f1); parse_smt2_commands(cctx, std::istringstream(res_text), false); From 32854c677c3270f3b83c2bb64ca39ca195dd40bf Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 12:10:06 -0800 Subject: [PATCH 29/34] exposed old simplifier parameters Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 7 +++++-- src/ast/simplifier/arith_simplifier_params.h | 15 +++++++++++---- .../simplifier/arith_simplifier_params_helper.pyg | 6 ++++++ src/ast/simplifier/array_simplifier_params.h | 13 ++++++++++--- .../simplifier/array_simplifier_params_helper.pyg | 6 ++++++ src/ast/simplifier/bv_simplifier_params.h | 13 ++++++++++--- .../simplifier/bv_simplifier_params_helper.pyg | 6 ++++++ 7 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 src/ast/simplifier/arith_simplifier_params_helper.pyg create mode 100644 src/ast/simplifier/array_simplifier_params_helper.pyg create mode 100644 src/ast/simplifier/bv_simplifier_params_helper.pyg diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 452a915d1..4ce41040b 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1461,6 +1461,9 @@ def pyg_default_as_c_literal(p): return 'symbol("%s")' % p[2] return p[2] +def to_c_method(s): + return s.replace('.', '_') + def def_module_params(module_name, export, params, class_name=None): pyg = get_curr_pyg() dirname = os.path.split(get_curr_pyg())[0] @@ -1493,10 +1496,10 @@ def def_module_params(module_name, export, params, class_name=None): for param in params: if export: out.write(' %s %s() const { return p.%s("%s", g, %s); }\n' % - (TYPE2CTYPE[param[1]], param[0], TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) + (TYPE2CTYPE[param[1]], to_c_method(param[0]), TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) else: out.write(' %s %s() const { return p.%s("%s", %s); }\n' % - (TYPE2CTYPE[param[1]], param[0], TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) + (TYPE2CTYPE[param[1]], to_c_method(param[0]), TYPE2GETTER[param[1]], param[0], pyg_default_as_c_literal(param))) out.write('};\n') if is_verbose(): print "Generated '%s'" % hpp diff --git a/src/ast/simplifier/arith_simplifier_params.h b/src/ast/simplifier/arith_simplifier_params.h index f1b22b09a..5a00f6337 100644 --- a/src/ast/simplifier/arith_simplifier_params.h +++ b/src/ast/simplifier/arith_simplifier_params.h @@ -19,13 +19,20 @@ Revision History: #ifndef _ARITH_SIMPLIFIER_PARAMS_H_ #define _ARITH_SIMPLIFIER_PARAMS_H_ -struct arith_simplifier_params { +#include"arith_simplifier_params_helper.hpp" + +struct arith_simplifier_params { bool m_arith_expand_eqs; bool m_arith_process_all_eqs; - arith_simplifier_params(): - m_arith_expand_eqs(false), - m_arith_process_all_eqs(false) { + arith_simplifier_params(params_ref const & p = params_ref()) { + updt_params(p); + } + + void updt_params(params_ref const & _p) { + arith_simplifier_params_helper p(_p); + m_arith_expand_eqs = p.arith_expand_eqs(); + m_arith_process_all_eqs = p.arith_process_all_eqs(); } }; diff --git a/src/ast/simplifier/arith_simplifier_params_helper.pyg b/src/ast/simplifier/arith_simplifier_params_helper.pyg new file mode 100644 index 000000000..9cd79bebc --- /dev/null +++ b/src/ast/simplifier/arith_simplifier_params_helper.pyg @@ -0,0 +1,6 @@ +def_module_params(class_name='arith_simplifier_params_helper', + module_name="old_simplify", # Parameters will be in the old_simplify module + export=True, + params=( + ('arith.expand_eqs', BOOL, False, 'expand equalities into two inequalities'), + ('arith.process_all_eqs', BOOL, False, 'put all equations in the form (= t c), where c is a numeral'))) diff --git a/src/ast/simplifier/array_simplifier_params.h b/src/ast/simplifier/array_simplifier_params.h index 8b9f3e37e..6c203ed63 100644 --- a/src/ast/simplifier/array_simplifier_params.h +++ b/src/ast/simplifier/array_simplifier_params.h @@ -19,13 +19,20 @@ Revision History: #ifndef _ARRAY_SIMPLIFIER_PARAMS_H_ #define _ARRAY_SIMPLIFIER_PARAMS_H_ +#include"array_simplifier_params_helper.hpp" + struct array_simplifier_params { bool m_array_canonize_simplify; bool m_array_simplify; // temporary hack for disabling array simplifier plugin. - array_simplifier_params(): - m_array_canonize_simplify(false), - m_array_simplify(true) { + array_simplifier_params(params_ref const & p = params_ref()) { + updt_params(p); + } + + void updt_params(params_ref const & _p) { + array_simplifier_params_helper p(_p); + m_array_canonize_simplify = p.array_canonize(); + m_array_simplify = p.array_simplify(); } }; diff --git a/src/ast/simplifier/array_simplifier_params_helper.pyg b/src/ast/simplifier/array_simplifier_params_helper.pyg new file mode 100644 index 000000000..93c184c23 --- /dev/null +++ b/src/ast/simplifier/array_simplifier_params_helper.pyg @@ -0,0 +1,6 @@ +def_module_params(class_name='array_simplifier_params_helper', + module_name="old_simplify", # Parameters will be in the old_simplify module + export=True, + params=( + ('array.canonize', BOOL, False, 'normalize array terms into normal form during simplification'), + ('array.simplify', BOOL, True, 'enable/disable array simplifications'))) diff --git a/src/ast/simplifier/bv_simplifier_params.h b/src/ast/simplifier/bv_simplifier_params.h index 4bec70285..85d969d48 100644 --- a/src/ast/simplifier/bv_simplifier_params.h +++ b/src/ast/simplifier/bv_simplifier_params.h @@ -19,13 +19,20 @@ Revision History: #ifndef _BV_SIMPLIFIER_PARAMS_H_ #define _BV_SIMPLIFIER_PARAMS_H_ +#include"bv_simplifier_params_helper.hpp" + struct bv_simplifier_params { bool m_hi_div0; //!< if true, uses the hardware interpretation for div0, mod0, ... if false, div0, mod0, ... are considered uninterpreted. bool m_bv2int_distribute; //!< if true allows downward propagation of bv2int. - bv_simplifier_params(): - m_hi_div0(true), - m_bv2int_distribute(true) { + bv_simplifier_params(params_ref const & p = params_ref()) { + updt_params(p); + } + + void updt_params(params_ref const & _p) { + bv_simplifier_params_helper p(_p); + m_hi_div0 = p.bv_hi_div0(); + m_bv2int_distribute = p.bv_bv2int_distribute(); } }; diff --git a/src/ast/simplifier/bv_simplifier_params_helper.pyg b/src/ast/simplifier/bv_simplifier_params_helper.pyg new file mode 100644 index 000000000..24bc86150 --- /dev/null +++ b/src/ast/simplifier/bv_simplifier_params_helper.pyg @@ -0,0 +1,6 @@ +def_module_params(class_name='bv_simplifier_params_helper', + module_name="old_simplify", # Parameters will be in the old_simplify module + export=True, + params=( + ('bv.hi_div0', BOOL, True, 'if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero; otherwise, these operations are considered uninterpreted'), + ('bv.bv2int_distribute', BOOL, True, 'if true, then int2bv is distributed over arithmetical operators'))) From 624115ea6deddb2c0dc6f800dbe7f8fa0bd1b95b Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 12:24:27 -0800 Subject: [PATCH 30/34] exposed pattern inference params Signed-off-by: Leonardo de Moura --- src/ast/pattern/pattern_inference_params.h | 27 ++++++++++++------- .../pattern_inference_params_helper.pyg | 11 ++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 src/ast/pattern/pattern_inference_params_helper.pyg diff --git a/src/ast/pattern/pattern_inference_params.h b/src/ast/pattern/pattern_inference_params.h index 7108e5589..59faa150f 100644 --- a/src/ast/pattern/pattern_inference_params.h +++ b/src/ast/pattern/pattern_inference_params.h @@ -19,6 +19,8 @@ Revision History: #ifndef _PATTERN_INFERENCE_PARAMS_H_ #define _PATTERN_INFERENCE_PARAMS_H_ +#include"pattern_inference_params_helper.hpp" + enum arith_pattern_inference_kind { AP_NO, // do not infer patterns with arithmetic terms AP_CONSERVATIVE, // only infer patterns with arithmetic terms if there is no other option @@ -37,17 +39,22 @@ struct pattern_inference_params { bool m_pi_avoid_skolems; bool m_pi_warnings; - pattern_inference_params(): - m_pi_max_multi_patterns(0), - m_pi_block_loop_patterns(true), - m_pi_arith(AP_CONSERVATIVE), - m_pi_use_database(false), - m_pi_arith_weight(5), - m_pi_non_nested_arith_weight(10), - m_pi_pull_quantifiers(true), + pattern_inference_params(params_ref const & p = params_ref()): m_pi_nopat_weight(-1), - m_pi_avoid_skolems(true), - m_pi_warnings(false) { + m_pi_avoid_skolems(true) { + updt_params(p); + } + + void updt_params(params_ref const & _p) { + pattern_inference_params_helper p(_p); + m_pi_max_multi_patterns = p.max_multi_patterns(); + m_pi_block_loop_patterns = p.block_loop_patterns(); + m_pi_arith = static_cast(p.arith()); + m_pi_use_database = p.use_database(); + m_pi_arith_weight = p.arith_weight(); + m_pi_non_nested_arith_weight = p.non_nested_arith_weight(); + m_pi_pull_quantifiers = p.pull_quantifiers(); + m_pi_warnings = p.warnings(); } }; diff --git a/src/ast/pattern/pattern_inference_params_helper.pyg b/src/ast/pattern/pattern_inference_params_helper.pyg new file mode 100644 index 000000000..cc9699b01 --- /dev/null +++ b/src/ast/pattern/pattern_inference_params_helper.pyg @@ -0,0 +1,11 @@ +def_module_params(class_name='pattern_inference_params_helper', + module_name='pi', + export=True, + params=(('max_multi_patterns', UINT, 0, 'when patterns are not provided, the prover uses a heuristic to infer them, this option sets the threshold on the number of extra multi-patterns that can be created; by default, the prover creates at most one multi-pattern when there is no unary pattern'), + ('block_loop_patterns', BOOL, True, 'block looping patterns during pattern inference'), + ('arith', UINT, 1, '0 - do not infer patterns with arithmetic terms, 1 - use patterns with arithmetic terms if there is no other pattern, 2 - always use patterns with arithmetic terms'), + ('use_database', BOOL, True, 'use pattern database'), + ('arith_weight', UINT, 5, 'default weight for quantifiers where the only available pattern has nested arithmetic terms'), + ('non_nested_arith_weight', UINT, 10, 'default weight for quantifiers where the only available pattern has non nested arithmetic terms'), + ('pull_quantifiers', BOOL, True, 'pull nested quantifiers, if no pattern was found'), + ('warnings', BOOL, False, 'enable/disable warning messages in the pattern inference module'))) From 1871bef6e1bff67405e85dd9d944e10fd3e847f3 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 12:47:20 -0800 Subject: [PATCH 31/34] cleaned algebraic params Signed-off-by: Leonardo de Moura --- src/math/polynomial/algebraic.pyg | 9 +++++++++ src/math/polynomial/algebraic_numbers.cpp | 23 ++++++++++------------- src/math/polynomial/algebraic_numbers.h | 3 --- src/model/model_params.pyg | 3 +-- 4 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 src/math/polynomial/algebraic.pyg diff --git a/src/math/polynomial/algebraic.pyg b/src/math/polynomial/algebraic.pyg new file mode 100644 index 000000000..5e6c288f8 --- /dev/null +++ b/src/math/polynomial/algebraic.pyg @@ -0,0 +1,9 @@ +def_module_params('algebraic', + export=True, + params=(('zero_accuracy', UINT, 0, 'one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)'), + ('min_mag', UINT, 16, 'Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16'), + ('factor', BOOL, True, 'use polynomial factorization to simplify polynomials representing algebraic numbers'), + ('factor_max_prime', UINT, 31, 'parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step'), + ('factor_num_primes', UINT, 1, 'parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)\'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching'), + ('factor_search_size', UINT, 5000, 'parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space'))) + diff --git a/src/math/polynomial/algebraic_numbers.cpp b/src/math/polynomial/algebraic_numbers.cpp index c35e0d368..90ad6ea9d 100644 --- a/src/math/polynomial/algebraic_numbers.cpp +++ b/src/math/polynomial/algebraic_numbers.cpp @@ -25,6 +25,7 @@ Notes: #include"scoped_ptr_vector.h" #include"mpbqi.h" #include"timeit.h" +#include"algebraic_params.hpp" namespace algebraic_numbers { @@ -57,12 +58,7 @@ namespace algebraic_numbers { typedef upolynomial::factors factors; void manager::get_param_descrs(param_descrs & r) { - r.insert("zero_accuracy", CPK_UINT, "(default: 0) one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)."); - r.insert("min_mag", CPK_UINT, "(default: 16) Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16"); - r.insert("factor", CPK_BOOL, "(default: true) use polynomial factorization to simplify polynomials representing algebraic numbers."); - r.insert("factor_max_prime", CPK_UINT, "(default: 31), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter limits the maximum prime number p to be used in the first step."); - r.insert("factor_num_primes", CPK_UINT, "(default: 1), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. The search space may be reduced by factoring the polynomial in different GF(p)'s. This parameter specify the maximum number of finite factorizations to be considered, before lifiting and searching."); - r.insert("factor_search_size", CPK_UINT, "(default: 5000), parameter for the polynomial factorization procedure in the algebraic number module. Z3 polynomial factorization is composed of three steps: factorization in GF(p), lifting and search. This parameter can be used to limit the search space."); + algebraic_params::collect_param_descrs(r); } struct manager::imp { @@ -156,13 +152,14 @@ namespace algebraic_numbers { #endif } - void updt_params(params_ref const & p) { - m_min_magnitude = -static_cast(p.get_uint("min_mag", 16)); - m_factor = p.get_bool("factor", true); // use polynomial factorization - m_factor_params.m_max_p = p.get_uint("factor_max_prime", 31); - m_factor_params.m_p_trials = p.get_uint("factor_num_primes", 1); - m_factor_params.m_max_search_size = p.get_uint("factor_max_search_size", 5000); - m_zero_accuracy = -static_cast(p.get_uint("zero_accuracy", 0)); + void updt_params(params_ref const & _p) { + algebraic_params p(_p); + m_min_magnitude = -static_cast(p.min_mag()); + m_factor = p.factor(); + m_factor_params.m_max_p = p.factor_max_prime(); + m_factor_params.m_p_trials = p.factor_num_primes(); + m_factor_params.m_max_search_size = p.factor_search_size(); + m_zero_accuracy = -static_cast(p.zero_accuracy()); } unsynch_mpq_manager & qm() { diff --git a/src/math/polynomial/algebraic_numbers.h b/src/math/polynomial/algebraic_numbers.h index 0db3ee68c..4735a875b 100644 --- a/src/math/polynomial/algebraic_numbers.h +++ b/src/math/polynomial/algebraic_numbers.h @@ -60,9 +60,6 @@ namespace algebraic_numbers { manager(unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0); ~manager(); - /* - REG_MODULE_PARAMS('algebraic', 'algebraic_numbers::manager::get_param_descrs') - */ static void get_param_descrs(param_descrs & r); static void collect_param_descrs(param_descrs & r) { get_param_descrs(r); } diff --git a/src/model/model_params.pyg b/src/model/model_params.pyg index 689519e6c..977538163 100644 --- a/src/model/model_params.pyg +++ b/src/model/model_params.pyg @@ -1,7 +1,6 @@ def_module_params('model', export=True, - params=(('validate', BOOL, False, 'validate models produced by Z3'), - ('partial', BOOL, False, 'enable/disable partial function interpretations'), + params=(('partial', BOOL, False, 'enable/disable partial function interpretations'), ('v1', BOOL, False, 'use Z3 version 1.x pretty printer'), ('v2', BOOL, False, 'use Z3 version 2.x (x <= 16) pretty printer'), ('compact', BOOL, False, 'try to compact function graph (i.e., function interpretations that are lookup tables)'), From fa53b1eb92f4ca9d822c9fd119b94fab88c49b18 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 13:15:56 -0800 Subject: [PATCH 32/34] added module descriptions Signed-off-by: Leonardo de Moura --- scripts/mk_util.py | 11 ++++++- src/ast/normal_forms/nnf_params.pyg | 1 + src/ast/pattern/pattern_inference_params.cpp | 32 +++++++++++++++++++ src/ast/pattern/pattern_inference_params.h | 14 ++------ .../pattern_inference_params_helper.pyg | 1 + src/ast/pp_params.pyg | 1 + .../simplifier/arith_simplifier_params.cpp | 26 +++++++++++++++ src/ast/simplifier/arith_simplifier_params.h | 8 ++--- .../arith_simplifier_params_helper.pyg | 1 + .../simplifier/array_simplifier_params.cpp | 26 +++++++++++++++ src/ast/simplifier/array_simplifier_params.h | 10 ++---- src/ast/simplifier/bv_simplifier_params.cpp | 26 +++++++++++++++ src/ast/simplifier/bv_simplifier_params.h | 8 ++--- src/math/polynomial/algebraic.pyg | 1 + src/nlsat/nlsat_params.pyg | 1 + src/util/gparams.cpp | 20 +++++++++++- src/util/gparams.h | 5 +++ 17 files changed, 159 insertions(+), 33 deletions(-) create mode 100644 src/ast/pattern/pattern_inference_params.cpp create mode 100644 src/ast/simplifier/arith_simplifier_params.cpp create mode 100644 src/ast/simplifier/array_simplifier_params.cpp create mode 100644 src/ast/simplifier/bv_simplifier_params.cpp diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 4ce41040b..2906b11fe 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1464,7 +1464,7 @@ def pyg_default_as_c_literal(p): def to_c_method(s): return s.replace('.', '_') -def def_module_params(module_name, export, params, class_name=None): +def def_module_params(module_name, export, params, class_name=None, description=None): pyg = get_curr_pyg() dirname = os.path.split(get_curr_pyg())[0] if class_name == None: @@ -1491,6 +1491,8 @@ def def_module_params(module_name, export, params, class_name=None): if export: out.write(' /*\n') out.write(" REG_MODULE_PARAMS('%s', '%s::collect_param_descrs')\n" % (module_name, class_name)) + if description != None: + out.write(" REG_MODULE_DESCRIPTION('%s', '%s')\n" % (module_name, description)) out.write(' */\n') # Generated accessors for param in params: @@ -1763,12 +1765,14 @@ def mk_all_mem_initializer_cpps(): def mk_gparams_register_modules(cnames, path): cmds = [] mod_cmds = [] + mod_descrs = [] fullname = '%s/gparams_register_modules.cpp' % path fout = open(fullname, 'w') fout.write('// Automatically generated file.\n') fout.write('#include"gparams.h"\n') reg_pat = re.compile('[ \t]*REG_PARAMS\(\'([^\']*)\'\)') reg_mod_pat = re.compile('[ \t]*REG_MODULE_PARAMS\(\'([^\']*)\', *\'([^\']*)\'\)') + reg_mod_descr_pat = re.compile('[ \t]*REG_MODULE_DESCRIPTION\(\'([^\']*)\', *\'([^\']*)\'\)') for cname in cnames: c = get_component(cname) h_files = filter(lambda f: f.endswith('.h') or f.endswith('.hpp'), os.listdir(c.src_dir)) @@ -1788,11 +1792,16 @@ def mk_gparams_register_modules(cnames, path): added_include = True fout.write('#include"%s"\n' % h_file) mod_cmds.append((m.group(1), m.group(2))) + m = reg_mod_descr_pat.match(line) + if m: + mod_descrs.append((m.group(1), m.group(2))) fout.write('void gparams_register_modules() {\n') for code in cmds: fout.write('{ param_descrs d; %s(d); gparams::register_global(d); }\n' % code) for (mod, code) in mod_cmds: fout.write('{ param_descrs * d = alloc(param_descrs); %s(*d); gparams::register_module("%s", d); }\n' % (code, mod)) + for (mod, descr) in mod_descrs: + fout.write('gparams::register_module_descr("%s", "%s");\n' % (mod, descr)) fout.write('}\n') if VERBOSE: print "Generated '%s'" % fullname diff --git a/src/ast/normal_forms/nnf_params.pyg b/src/ast/normal_forms/nnf_params.pyg index 6fab28f11..aac8fbb86 100644 --- a/src/ast/normal_forms/nnf_params.pyg +++ b/src/ast/normal_forms/nnf_params.pyg @@ -1,4 +1,5 @@ def_module_params('nnf', + description='negation normal form', export=True, params=(max_memory_param(), ('sk_hack', BOOL, False, 'hack for VCC'), diff --git a/src/ast/pattern/pattern_inference_params.cpp b/src/ast/pattern/pattern_inference_params.cpp new file mode 100644 index 000000000..8adbdb9f1 --- /dev/null +++ b/src/ast/pattern/pattern_inference_params.cpp @@ -0,0 +1,32 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + pattern_inference_params.h + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"pattern_inference_params.h" +#include"pattern_inference_params_helper.hpp" + +void pattern_inference_params::updt_params(params_ref const & _p) { + pattern_inference_params_helper p(_p); + m_pi_max_multi_patterns = p.max_multi_patterns(); + m_pi_block_loop_patterns = p.block_loop_patterns(); + m_pi_arith = static_cast(p.arith()); + m_pi_use_database = p.use_database(); + m_pi_arith_weight = p.arith_weight(); + m_pi_non_nested_arith_weight = p.non_nested_arith_weight(); + m_pi_pull_quantifiers = p.pull_quantifiers(); + m_pi_warnings = p.warnings(); +} diff --git a/src/ast/pattern/pattern_inference_params.h b/src/ast/pattern/pattern_inference_params.h index 59faa150f..dc9f0cb9b 100644 --- a/src/ast/pattern/pattern_inference_params.h +++ b/src/ast/pattern/pattern_inference_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _PATTERN_INFERENCE_PARAMS_H_ #define _PATTERN_INFERENCE_PARAMS_H_ -#include"pattern_inference_params_helper.hpp" +#include"params.h" enum arith_pattern_inference_kind { AP_NO, // do not infer patterns with arithmetic terms @@ -45,17 +45,7 @@ struct pattern_inference_params { updt_params(p); } - void updt_params(params_ref const & _p) { - pattern_inference_params_helper p(_p); - m_pi_max_multi_patterns = p.max_multi_patterns(); - m_pi_block_loop_patterns = p.block_loop_patterns(); - m_pi_arith = static_cast(p.arith()); - m_pi_use_database = p.use_database(); - m_pi_arith_weight = p.arith_weight(); - m_pi_non_nested_arith_weight = p.non_nested_arith_weight(); - m_pi_pull_quantifiers = p.pull_quantifiers(); - m_pi_warnings = p.warnings(); - } + void updt_params(params_ref const & _p); }; #endif /* _PATTERN_INFERENCE_PARAMS_H_ */ diff --git a/src/ast/pattern/pattern_inference_params_helper.pyg b/src/ast/pattern/pattern_inference_params_helper.pyg index cc9699b01..5d64e8e52 100644 --- a/src/ast/pattern/pattern_inference_params_helper.pyg +++ b/src/ast/pattern/pattern_inference_params_helper.pyg @@ -1,5 +1,6 @@ def_module_params(class_name='pattern_inference_params_helper', module_name='pi', + description='pattern inference (heuristics) for universal formulas (without annotation)', export=True, params=(('max_multi_patterns', UINT, 0, 'when patterns are not provided, the prover uses a heuristic to infer them, this option sets the threshold on the number of extra multi-patterns that can be created; by default, the prover creates at most one multi-pattern when there is no unary pattern'), ('block_loop_patterns', BOOL, True, 'block looping patterns during pattern inference'), diff --git a/src/ast/pp_params.pyg b/src/ast/pp_params.pyg index 57d6e185d..75b2baddd 100644 --- a/src/ast/pp_params.pyg +++ b/src/ast/pp_params.pyg @@ -1,5 +1,6 @@ def_module_params('pp', export=True, + description='pretty printer', params=(('max_indent', UINT, UINT_MAX, 'max. indentation in pretty printer'), ('max_num_lines', UINT, UINT_MAX, 'max. number of lines to be displayed in pretty printer'), ('max_width', UINT, 80, 'max. width in pretty printer'), diff --git a/src/ast/simplifier/arith_simplifier_params.cpp b/src/ast/simplifier/arith_simplifier_params.cpp new file mode 100644 index 000000000..a3fabe02f --- /dev/null +++ b/src/ast/simplifier/arith_simplifier_params.cpp @@ -0,0 +1,26 @@ +/*++ +Copyright (c) 2006 Microsoft Corporation + +Module Name: + + arith_simplifier_params.cpp + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"arith_simplifier_params.h" +#include"arith_simplifier_params_helper.hpp" + +void arith_simplifier_params::updt_params(params_ref const & _p) { + arith_simplifier_params_helper p(_p); + m_arith_expand_eqs = p.arith_expand_eqs(); + m_arith_process_all_eqs = p.arith_process_all_eqs(); +} diff --git a/src/ast/simplifier/arith_simplifier_params.h b/src/ast/simplifier/arith_simplifier_params.h index 5a00f6337..109f73307 100644 --- a/src/ast/simplifier/arith_simplifier_params.h +++ b/src/ast/simplifier/arith_simplifier_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _ARITH_SIMPLIFIER_PARAMS_H_ #define _ARITH_SIMPLIFIER_PARAMS_H_ -#include"arith_simplifier_params_helper.hpp" +#include"params.h" struct arith_simplifier_params { bool m_arith_expand_eqs; @@ -29,11 +29,7 @@ struct arith_simplifier_params { updt_params(p); } - void updt_params(params_ref const & _p) { - arith_simplifier_params_helper p(_p); - m_arith_expand_eqs = p.arith_expand_eqs(); - m_arith_process_all_eqs = p.arith_process_all_eqs(); - } + void updt_params(params_ref const & _p); }; #endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/ast/simplifier/arith_simplifier_params_helper.pyg b/src/ast/simplifier/arith_simplifier_params_helper.pyg index 9cd79bebc..49a7cf3d2 100644 --- a/src/ast/simplifier/arith_simplifier_params_helper.pyg +++ b/src/ast/simplifier/arith_simplifier_params_helper.pyg @@ -1,5 +1,6 @@ def_module_params(class_name='arith_simplifier_params_helper', module_name="old_simplify", # Parameters will be in the old_simplify module + description="old simplification (stack) still used in the smt module", export=True, params=( ('arith.expand_eqs', BOOL, False, 'expand equalities into two inequalities'), diff --git a/src/ast/simplifier/array_simplifier_params.cpp b/src/ast/simplifier/array_simplifier_params.cpp new file mode 100644 index 000000000..bffff44d9 --- /dev/null +++ b/src/ast/simplifier/array_simplifier_params.cpp @@ -0,0 +1,26 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + array_simplifier_params.cpp + +Abstract: + + This file was created during code reorg. + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"array_simplifier_params.h" +#include"array_simplifier_params_helper.hpp" + +void array_simplifier_params::updt_params(params_ref const & _p) { + array_simplifier_params_helper p(_p); + m_array_canonize_simplify = p.array_canonize(); + m_array_simplify = p.array_simplify(); +} diff --git a/src/ast/simplifier/array_simplifier_params.h b/src/ast/simplifier/array_simplifier_params.h index 6c203ed63..2f6fa720b 100644 --- a/src/ast/simplifier/array_simplifier_params.h +++ b/src/ast/simplifier/array_simplifier_params.h @@ -1,5 +1,5 @@ /*++ -Copyright (c) 2006 Microsoft Corporation +Copyright (c) 2012 Microsoft Corporation Module Name: @@ -19,7 +19,7 @@ Revision History: #ifndef _ARRAY_SIMPLIFIER_PARAMS_H_ #define _ARRAY_SIMPLIFIER_PARAMS_H_ -#include"array_simplifier_params_helper.hpp" +#include"params.h" struct array_simplifier_params { bool m_array_canonize_simplify; @@ -29,11 +29,7 @@ struct array_simplifier_params { updt_params(p); } - void updt_params(params_ref const & _p) { - array_simplifier_params_helper p(_p); - m_array_canonize_simplify = p.array_canonize(); - m_array_simplify = p.array_simplify(); - } + void updt_params(params_ref const & _p); }; #endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/ast/simplifier/bv_simplifier_params.cpp b/src/ast/simplifier/bv_simplifier_params.cpp new file mode 100644 index 000000000..aa9dcfc2d --- /dev/null +++ b/src/ast/simplifier/bv_simplifier_params.cpp @@ -0,0 +1,26 @@ +/*++ +Copyright (c) 2006 Microsoft Corporation + +Module Name: + + bv_simplifier_params.cpp + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"bv_simplifier_params.h" +#include"bv_simplifier_params_helper.hpp" + +void bv_simplifier_params::updt_params(params_ref const & _p) { + bv_simplifier_params_helper p(_p); + m_hi_div0 = p.bv_hi_div0(); + m_bv2int_distribute = p.bv_bv2int_distribute(); +} diff --git a/src/ast/simplifier/bv_simplifier_params.h b/src/ast/simplifier/bv_simplifier_params.h index 85d969d48..5f5832235 100644 --- a/src/ast/simplifier/bv_simplifier_params.h +++ b/src/ast/simplifier/bv_simplifier_params.h @@ -19,7 +19,7 @@ Revision History: #ifndef _BV_SIMPLIFIER_PARAMS_H_ #define _BV_SIMPLIFIER_PARAMS_H_ -#include"bv_simplifier_params_helper.hpp" +#include"params.h" struct bv_simplifier_params { bool m_hi_div0; //!< if true, uses the hardware interpretation for div0, mod0, ... if false, div0, mod0, ... are considered uninterpreted. @@ -29,11 +29,7 @@ struct bv_simplifier_params { updt_params(p); } - void updt_params(params_ref const & _p) { - bv_simplifier_params_helper p(_p); - m_hi_div0 = p.bv_hi_div0(); - m_bv2int_distribute = p.bv_bv2int_distribute(); - } + void updt_params(params_ref const & _p); }; #endif /* _BV_SIMPLIFIER_PARAMS_H_ */ diff --git a/src/math/polynomial/algebraic.pyg b/src/math/polynomial/algebraic.pyg index 5e6c288f8..92a2f10df 100644 --- a/src/math/polynomial/algebraic.pyg +++ b/src/math/polynomial/algebraic.pyg @@ -1,4 +1,5 @@ def_module_params('algebraic', + description='real algebraic number package', export=True, params=(('zero_accuracy', UINT, 0, 'one of the most time-consuming operations in the real algebraic number module is determining the sign of a polynomial evaluated at a sample point with non-rational algebraic number values. Let k be the value of this option. If k is 0, Z3 uses precise computation. Otherwise, the result of a polynomial evaluation is considered to be 0 if Z3 can show it is inside the interval (-1/2^k, 1/2^k)'), ('min_mag', UINT, 16, 'Z3 represents algebraic numbers using a (square-free) polynomial p and an isolating interval (which contains one and only one root of p). This interval may be refined during the computations. This parameter specifies whether to cache the value of a refined interval or not. It says the minimal size of an interval for caching purposes is 1/2^16'), diff --git a/src/nlsat/nlsat_params.pyg b/src/nlsat/nlsat_params.pyg index 2728e1180..4faad3379 100644 --- a/src/nlsat/nlsat_params.pyg +++ b/src/nlsat/nlsat_params.pyg @@ -1,5 +1,6 @@ def_module_params('nlsat', + description='nonlinear solver', export=True, params=(max_memory_param(), ('lazy', UINT, 0, "how lazy the solver is."), diff --git a/src/util/gparams.cpp b/src/util/gparams.cpp index 85b648a55..8a5532ee0 100644 --- a/src/util/gparams.cpp +++ b/src/util/gparams.cpp @@ -37,6 +37,7 @@ bool is_old_param_name(symbol const & name) { struct gparams::imp { dictionary m_module_param_descrs; + dictionary m_module_descrs; param_descrs m_param_descrs; dictionary m_module_params; params_ref m_params; @@ -83,6 +84,13 @@ public: } } + void register_module_descr(char const * module_name, char const * descr) { + #pragma omp critical (gparams) + { + m_module_descrs.insert(symbol(module_name), descr); + } + } + void display(std::ostream & out, unsigned indent, bool smt2_style) { #pragma omp critical (gparams) { @@ -92,7 +100,12 @@ public: dictionary::iterator it = m_module_param_descrs.begin(); dictionary::iterator end = m_module_param_descrs.end(); for (; it != end; ++it) { - out << "[module] " << it->m_key << "\n"; + out << "[module] " << it->m_key; + char const * descr = 0; + if (m_module_descrs.find(it->m_key, descr)) { + out << ", description: " << descr; + } + out << "\n"; it->m_value->display(out, indent + 4, smt2_style); } } @@ -337,6 +350,11 @@ void gparams::register_module(char const * module_name, param_descrs * d) { g_imp->register_module(module_name, d); } +void gparams::register_module_descr(char const * module_name, char const * descr) { + SASSERT(g_imp != 0); + g_imp->register_module_descr(module_name, descr); +} + params_ref gparams::get_module(char const * module_name) { return get_module(symbol(module_name)); } diff --git a/src/util/gparams.h b/src/util/gparams.h index 04e1f6051..2a784a239 100644 --- a/src/util/gparams.h +++ b/src/util/gparams.h @@ -79,6 +79,11 @@ public: */ static void register_module(char const * module_name, param_descrs * d); + /** + \brief Add a (small) description to the given module. + */ + static void register_module_descr(char const * module_name, char const * descr); + /** \brief Retrieves the parameters associated with the given module. From 5057257e403effd753da5197d8dac0a6cc6f8bf3 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 13:18:33 -0800 Subject: [PATCH 33/34] removed unnecessary README Signed-off-by: Leonardo de Moura --- src/smt/params/README | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/smt/params/README diff --git a/src/smt/params/README b/src/smt/params/README deleted file mode 100644 index 1ab0a2463..000000000 --- a/src/smt/params/README +++ /dev/null @@ -1,9 +0,0 @@ -This directory contains the "remains" of the old parameter setting -infrastructure used by Z3. Old code (mostly `smt::context`) is still -based on the front_end_params structure. However, we removed support -for the old INI file infrastructure. Instead, we have functions for -setting the fields of front_end_params using parameter sets -(params_ref). Moreover, many of the parameters in front_end_params -are now "hidden". That is, they can't be set from the command line or -using the command `set-option`. - From 773f82a44cabd15b064da23b23690c8e3c007dd6 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sun, 2 Dec 2012 14:47:34 -0800 Subject: [PATCH 34/34] connected smt_params with new parameter infrastructure Signed-off-by: Leonardo de Moura --- src/api/api_context.cpp | 2 +- src/smt/params/preprocessor_params.cpp | 32 +++++++ src/smt/params/preprocessor_params.h | 32 +------ src/smt/params/qi_params.cpp | 37 ++++++++ src/smt/params/qi_params.h | 39 +------- src/smt/params/smt_params.cpp | 126 ++++++------------------- src/smt/params/smt_params.h | 26 ++--- src/smt/params/smt_params_helper.pyg | 38 ++++++++ src/smt/params/theory_arith_params.cpp | 71 +++----------- src/smt/params/theory_arith_params.h | 6 +- src/smt/params/theory_bv_params.cpp | 25 +++++ src/smt/params/theory_bv_params.h | 21 ++--- src/smt/smt_kernel.cpp | 4 +- src/smt/smt_solver.cpp | 2 +- src/smt/tactic/smt_tactic.cpp | 6 +- 15 files changed, 211 insertions(+), 256 deletions(-) create mode 100644 src/smt/params/preprocessor_params.cpp create mode 100644 src/smt/params/qi_params.cpp create mode 100644 src/smt/params/smt_params_helper.pyg create mode 100644 src/smt/params/theory_bv_params.cpp diff --git a/src/api/api_context.cpp b/src/api/api_context.cpp index 2d242f9b0..f197e8ad8 100644 --- a/src/api/api_context.cpp +++ b/src/api/api_context.cpp @@ -323,7 +323,7 @@ namespace api { smt::kernel & context::get_smt_kernel() { if (!m_solver) { - // PARAM-TODO: copy config_params -> fparams + m_fparams.updt_params(m_params); m_solver = alloc(smt::kernel, m_manager, m_fparams); } return *m_solver; diff --git a/src/smt/params/preprocessor_params.cpp b/src/smt/params/preprocessor_params.cpp new file mode 100644 index 000000000..375fef787 --- /dev/null +++ b/src/smt/params/preprocessor_params.cpp @@ -0,0 +1,32 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + preprocessor_params.h + +Abstract: + + Preprocess AST before adding them to the logical context + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"preprocessor_params.h" +#include"smt_params_helper.hpp" + +void preprocessor_params::updt_local_params(params_ref const & _p) { + smt_params_helper p(_p); + m_macro_finder = p.macro_finder(); +} + +void preprocessor_params::updt_params(params_ref const & p) { + pattern_inference_params::updt_params(p); + bv_simplifier_params::updt_params(p); + arith_simplifier_params::updt_params(p); + updt_local_params(p); +} diff --git a/src/smt/params/preprocessor_params.h b/src/smt/params/preprocessor_params.h index e4b20b87a..d53f26318 100644 --- a/src/smt/params/preprocessor_params.h +++ b/src/smt/params/preprocessor_params.h @@ -56,7 +56,7 @@ struct preprocessor_params : public pattern_inference_params, bool m_nlquant_elim; public: - preprocessor_params(): + 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), @@ -77,36 +77,12 @@ public: m_max_bv_sharing(true), m_pre_simplifier(true), m_nlquant_elim(false) { + updt_local_params(p); } -#if 0 - void register_params(ini_params & p) { - pattern_inference_params::register_params(p); - bit_blaster_params::register_params(p); - bv_simplifier_params::register_params(p); - arith_simplifier_params::register_params(p); - p.register_int_param("lift_ite", 0, 2, reinterpret_cast(m_lift_ite), "ite term lifting: 0 - no lifting, 1 - conservative, 2 - full"); - p.register_int_param("ng_lift_ite", 0, 2, reinterpret_cast(m_ng_lift_ite), "ite (non-ground) term lifting: 0 - no lifting, 1 - conservative, 2 - full"); - p.register_bool_param("elim_term_ite", m_eliminate_term_ite, "eliminate term if-then-else in the preprocessor"); - p.register_bool_param("elim_and", m_eliminate_and, "represent (and a b) as (not (or (not a) (not b)))"); - p.register_bool_param("macro_finder", m_macro_finder, "try to find universally quantified formulas that can be viewed as macros"); - p.register_bool_param("propagate_values", m_propagate_values, "propagate values during preprocessing step"); - p.register_bool_param("propagate_booleans", m_propagate_booleans, "propagate boolean values during preprocessing step"); - p.register_bool_param("pull_cheap_ite_trees", m_pull_cheap_ite_trees); - p.register_bool_param("pull_nested_quantifiers", m_pull_nested_quantifiers, "eliminate nested quantifiers by moving nested quantified variables to the outermost quantifier, it is unnecessary if the formula is converted into CNF"); - p.register_bool_param("refine_inj_axiom", m_refine_inj_axiom); - p.register_bool_param("elim_bounds", m_eliminate_bounds, "cheap Fourier-Motzkin"); - - p.register_bool_param("bit2int", m_simplify_bit2int, "hoist bit2int conversions over arithmetical expressions"); - p.register_bool_param("distribute_forall", m_distribute_forall); - p.register_bool_param("reduce_args", m_reduce_args); - p.register_bool_param("quasi_macros", m_quasi_macros); - p.register_bool_param("restricted_quasi_macros", m_restricted_quasi_macros); - p.register_bool_param("bv_max_sharing", m_max_bv_sharing); - p.register_bool_param("pre_simplifier", m_pre_simplifier); - } -#endif + void updt_local_params(params_ref const & p); + void updt_params(params_ref const & p); }; #endif /* _PREPROCESSOR_PARAMS_H_ */ diff --git a/src/smt/params/qi_params.cpp b/src/smt/params/qi_params.cpp new file mode 100644 index 000000000..f5506d35b --- /dev/null +++ b/src/smt/params/qi_params.cpp @@ -0,0 +1,37 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + qi_params.cpp + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"qi_params.h" +#include"smt_params_helper.hpp" + +void qi_params::updt_params(params_ref const & _p) { + smt_params_helper p(_p); + m_mbqi = p.mbqi(); + m_mbqi_max_cexs = p.mbqi_max_cexs(); + m_mbqi_max_cexs_incr = p.mbqi_max_cexs_incr(); + m_mbqi_max_iterations = p.mbqi_max_iterations(); + m_mbqi_trace = p.mbqi_trace(); + m_mbqi_force_template = p.mbqi_force_template(); + m_qi_profile = p.qi_profile(); + m_qi_profile_freq = p.qi_profile_freq(); + m_qi_max_instances = p.qi_max_instances(); + m_qi_eager_threshold = p.qi_eager_threshold(); + m_qi_lazy_threshold = p.qi_lazy_threshold(); + m_qi_cost = p.qi_cost(); + m_qi_max_eager_multipatterns = p.qi_max_multi_patterns(); +} diff --git a/src/smt/params/qi_params.h b/src/smt/params/qi_params.h index 1a8edb3a8..b0a21e75b 100644 --- a/src/smt/params/qi_params.h +++ b/src/smt/params/qi_params.h @@ -20,6 +20,7 @@ Revision History: #define _QI_PARAMS_H_ #include"util.h" +#include"params.h" enum quick_checker_mode { MC_NO, // do not use (cheap) model checking based instantiation @@ -53,7 +54,7 @@ struct qi_params { bool m_instgen; - qi_params(): + qi_params(params_ref const & p = params_ref()): /* The "weight 0" performance bug ------------------------------ @@ -93,49 +94,17 @@ struct qi_params { m_qi_max_instances(UINT_MAX), m_qi_lazy_instantiation(false), m_qi_conservative_final_check(false), -#ifdef _EXTERNAL_RELEASE m_mbqi(true), // enabled by default -#else - m_mbqi(false), // to avoid Rustan whining that the models are not partial anymore. -#endif m_mbqi_max_cexs(1), m_mbqi_max_cexs_incr(1), m_mbqi_max_iterations(1000), m_mbqi_trace(false), m_mbqi_force_template(10), m_instgen(false) { + updt_params(p); } -#if 0 - void register_params(ini_params & p) { - p.register_unsigned_param("qi_max_eager_multi_patterns", m_qi_max_eager_multipatterns, - "Specify the number of extra multi patterns that are processed eagerly. By default, the prover use at most one multi-pattern eagerly when there is no unary pattern. This value should be smaller than or equal to PI_MAX_MULTI_PATTERNS"); - p.register_unsigned_param("qi_max_lazy_multi_pattern_matching", m_qi_max_lazy_multipattern_matching, "Maximum number of rounds of matching in a branch for delayed multipatterns. A multipattern is delayed based on the value of QI_MAX_EAGER_MULTI_PATTERNS"); - p.register_string_param("qi_cost", m_qi_cost, "The cost function for quantifier instantiation"); - p.register_string_param("qi_new_gen", m_qi_new_gen, "The function for calculating the generation of newly constructed terms"); - p.register_double_param("qi_eager_threshold", m_qi_eager_threshold, "Threshold for eager quantifier instantiation"); - p.register_double_param("qi_lazy_threshold", m_qi_lazy_threshold, "Threshold for lazy quantifier instantiation"); - p.register_bool_param("qi_profile", m_qi_profile); - p.register_unsigned_param("qi_profile_freq", m_qi_profile_freq); - p.register_int_param("qi_quick_checker", 0, 2, reinterpret_cast(m_qi_quick_checker), "0 - do not use (cheap) model checker, 1 - instantiate instances unsatisfied by current model, 2 - 1 + instantiate instances not satisfied by current model"); - p.register_bool_param("qi_lazy_quick_checker", m_qi_lazy_quick_checker); - p.register_bool_param("qi_promote_unsat", m_qi_promote_unsat); - p.register_unsigned_param("qi_max_instances", m_qi_max_instances); - p.register_bool_param("qi_lazy_instantiation", m_qi_lazy_instantiation); - p.register_bool_param("qi_conservative_final_check", m_qi_conservative_final_check); - - - p.register_bool_param("mbqi", m_mbqi, "Model Based Quantifier Instantiation (MBQI)"); - p.register_unsigned_param("mbqi_max_cexs", m_mbqi_max_cexs, "Initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation", true); - p.register_unsigned_param("mbqi_max_cexs_incr", m_mbqi_max_cexs_incr, "Increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI", true); - p.register_unsigned_param("mbqi_max_iterations", m_mbqi_max_iterations, "Maximum number of rounds of MBQI", true); - p.register_bool_param("mbqi_trace", m_mbqi_trace, "Generate tracing messages for Model Based Quantifier Instantiation (MBQI). It will display a message before every round of MBQI, and the quantifiers that were not satisfied.", true); - p.register_unsigned_param("mbqi_force_template", m_mbqi_force_template, "Some quantifiers can be used as templates for building interpretations for functions. Z3 uses heuristics to decide whether a quantifier will be used as a template or not. Quantifiers with weight >= MBQI_FORCE_TEMPLATE are forced to be used as a template", true); - - p.register_bool_param("inst_gen", m_instgen, "Enable Instantiation Generation solver (disables other quantifier reasoning)", false); - } -#endif - + void updt_params(params_ref const & p); }; #endif /* _QI_PARAMS_H_ */ diff --git a/src/smt/params/smt_params.cpp b/src/smt/params/smt_params.cpp index 77d3660e6..70f0ad811 100644 --- a/src/smt/params/smt_params.cpp +++ b/src/smt/params/smt_params.cpp @@ -17,105 +17,33 @@ Revision History: --*/ #include"smt_params.h" -#include"trace.h" - -#if 0 -void smt_params::register_params(ini_params & p) { - dyn_ack_params::register_params(p); - qi_params::register_params(p); - theory_arith_params::register_params(p); - theory_array_params::register_params(p); - theory_bv_params::register_params(p); - theory_datatype_params::register_params(p); - - p.register_bool_param("check_proof", m_check_proof); - p.register_bool_param("display_proof", m_display_proof); - p.register_bool_param("display_dot_proof", m_display_dot_proof); - p.register_bool_param("display_unsat_core", m_display_unsat_core); - p.register_bool_param("eq_propagation", m_eq_propagation); - p.register_bool_param("bin_clauses", m_binary_clause_opt); - p.register_unsigned_param("relevancy", m_relevancy_lvl, "relevancy propagation heuristic: 0 - disabled, 1 - relevancy is tracked by only affects quantifier instantiation, 2 - relevancy is tracked, and an atom is only asserted if it is relevant", true); - p.register_bool_param("relevancy_lemma", m_relevancy_lemma, "true if lemmas are used to propagate relevancy"); - p.register_unsigned_param("random_seed", m_random_seed, "random seed for Z3"); - p.register_percentage_param("random_case_split_freq", m_random_var_freq, "frequency of random case splits"); - p.register_int_param("phase_selection", 0, 6, reinterpret_cast(m_phase_selection), "phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences"); - p.register_bool_param("minimize_lemmas", m_minimize_lemmas, "enable/disable lemma minimization algorithm"); - p.register_unsigned_param("max_conflicts", m_max_conflicts, "maximum number of conflicts"); - - p.register_unsigned_param("recent_lemma_threshold", m_recent_lemmas_size); - p.register_unsigned_param("tick", m_tick); - - PRIVATE_PARAMS({ - p.register_bool_param("theory_resolve", m_theory_resolve, "Apply theory resolution to produce auxiliary conflict clauses", true); - }); - - p.register_int_param("restart_strategy", 0, 4, reinterpret_cast(m_restart_strategy), "0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic"); - p.register_unsigned_param("restart_initial", m_restart_initial, - "inital restart frequency in number of conflicts, it is also the unit for the luby sequence"); - p.register_double_param("restart_factor", m_restart_factor, "when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold"); - p.register_bool_param("restart_adaptive", m_restart_adaptive, "disable restarts based on the search 'agility'"); - p.register_percentage_param("restart_agility_threshold", m_restart_agility_threshold); - - p.register_int_param("lemma_gc_strategy", 0, 2, reinterpret_cast(m_lemma_gc_strategy), "0 - fixed, 1 - geometric, 2 - at every restart"); - p.register_bool_param("lemma_gc_half", m_lemma_gc_half, "true for simple gc algorithm (delete approx. half of the clauses)"); - p.register_unsigned_param("lemma_gc_initial", m_lemma_gc_initial, "lemma initial gc frequency (in number of conflicts), used by fixed or geometric strategies"); - p.register_double_param("lemma_gc_factor", m_lemma_gc_factor, "used by geometric strategy"); - p.register_unsigned_param("lemma_gc_new_old_ratio", m_new_old_ratio); - p.register_unsigned_param("lemma_gc_new_clause_activity", m_new_clause_activity); - p.register_unsigned_param("lemma_gc_old_clause_activity", m_old_clause_activity); - p.register_unsigned_param("lemma_gc_new_clause_relevancy", m_new_clause_relevancy); - p.register_unsigned_param("lemma_gc_old_clause_relevancy", m_old_clause_activity); - - p.register_bool_param("simplify_clauses", m_simplify_clauses); - - p.register_int_param("random_initial_activity", 0, 2, reinterpret_cast(m_random_initial_activity)); - - PRIVATE_PARAMS({ - - p.register_double_param("inv_decay", m_inv_decay); - p.register_unsigned_param("phase_caching_on_duration", m_phase_caching_on); - p.register_unsigned_param("phase_caching_off_duration", m_phase_caching_off); - }); - - p.register_bool_param("smtlib_dump_lemmas", m_smtlib_dump_lemmas); - p.register_string_param("smtlib_logic", m_smtlib_logic, "Name used for the :logic field when generating SMT-LIB benchmarks"); - p.register_bool_param("display_features", m_display_features); - - p.register_bool_param("new_core2th_eq", m_new_core2th_eq); - p.register_bool_param("ematching", m_ematching, "E-Matching based quantifier instantiation"); - - p.register_bool_param("profile_res_sub", m_profile_res_sub); -#ifndef _EXTERNAL_RELEASE - p.register_bool_param("display_bool_var2expr", m_display_bool_var2expr); - p.register_bool_param("display_ll_bool_var2expr", m_display_ll_bool_var2expr); - p.register_bool_param("abort_after_preproc", m_abort_after_preproc, "abort after preprocessing step, this flag is only useful for debugging purposes"); - p.register_bool_param("display_installed_theories", m_display_installed_theories, "display theories installed at smt::context", true); -#endif - p.register_int_param("case_split", 0, 5, reinterpret_cast(m_case_split_strategy), "0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal"); - p.register_unsigned_param("rel_case_split_order", 0, 2, m_rel_case_split_order, "structural (relevancy) splitting order: 0 - left-to-right (default), 1 - random, 2 - right-to-left"); - p.register_bool_param("lookahead_diseq", m_lookahead_diseq); - - p.register_bool_param("delay_units", m_delay_units); - p.register_unsigned_param("delay_units_threshold", m_delay_units_threshold); - - p.register_bool_param("model", m_model, "enable/disable model construction", true); - p.register_bool_param("model_validate", m_model_validate, "validate the model", true); - p.register_bool_param("model_on_timeout", m_model_on_timeout, "after hitting soft-timeout or memory high watermark, generate a candidate model", true); - p.register_bool_param("model_on_final_check", m_model_on_final_check, "display candidate model (in the standard output) whenever Z3 hits a final check", true); - - p.register_unsigned_param("progress_sampling_freq", m_progress_sampling_freq, "frequency for progress output in miliseconds"); - - - p.register_bool_param("user_theory_preprocess_axioms", - m_user_theory_preprocess_axioms, - "Apply full pre-processing to user theory axioms", - true); - - p.register_bool_param("user_theory_persist_axioms", - m_user_theory_persist_axioms, - "Persist user axioms to the base level", - true); +#include"smt_params_helper.hpp" +void smt_params::updt_local_params(params_ref const & _p) { + smt_params_helper p(_p); + m_auto_config = p.auto_config(); + m_ematching = p.ematching(); + m_phase_selection = static_cast(p.phase_selection()); + m_restart_strategy = static_cast(p.restart_strategy()); + m_restart_factor = p.restart_factor(); + m_case_split_strategy = static_cast(p.case_split()); + m_delay_units = p.delay_units(); + m_delay_units_threshold = p.delay_units_threshold(); +} + +void smt_params::updt_params(params_ref const & p) { + preprocessor_params::updt_params(p); + qi_params::updt_params(p); + theory_arith_params::updt_params(p); + theory_bv_params::updt_params(p); + updt_local_params(p); +} + +void smt_params::updt_params(context_params const & p) { + m_auto_config = p.m_auto_config; + m_soft_timeout = p.m_timeout; + m_model = p.m_model; + m_model_validate = p.m_validate_model; + m_proof_mode = p.m_proof ? PGM_FINE : PGM_DISABLED; } -#endif diff --git a/src/smt/params/smt_params.h b/src/smt/params/smt_params.h index 68e5a596d..ec057239a 100644 --- a/src/smt/params/smt_params.h +++ b/src/smt/params/smt_params.h @@ -27,6 +27,7 @@ Revision History: #include"theory_bv_params.h" #include"theory_datatype_params.h" #include"preprocessor_params.h" +#include"context_params.h" enum phase_selection { PS_ALWAYS_FALSE, @@ -209,23 +210,7 @@ struct smt_params : public preprocessor_params, proof_gen_mode m_proof_mode; bool m_auto_config; -#if 0 - unsigned m_memory_high_watermark; - unsigned m_memory_max_size; - - bool m_auto_config; - - bool m_debug_ref_count; - - m_well_sorted_check(true), - m_memory_high_watermark(0), - m_memory_max_size(0), - - m_auto_config(true), - m_debug_ref_count(false) { -#endif - - smt_params(): + smt_params(params_ref const & p = params_ref()): m_display_proof(false), m_display_dot_proof(false), m_display_unsat_core(false), @@ -294,7 +279,14 @@ struct smt_params : public preprocessor_params, m_dump_goal_as_smt(false), m_proof_mode(PGM_DISABLED), m_auto_config(true) { + updt_local_params(p); } + + void updt_local_params(params_ref const & p); + + void updt_params(params_ref const & p); + + void updt_params(context_params const & p); }; #endif /* _SMT_PARAMS_H_ */ diff --git a/src/smt/params/smt_params_helper.pyg b/src/smt/params/smt_params_helper.pyg new file mode 100644 index 000000000..8db95a581 --- /dev/null +++ b/src/smt/params/smt_params_helper.pyg @@ -0,0 +1,38 @@ +def_module_params(module_name='smt', + class_name='smt_params_helper', + description='smt solver based on lazy smt', + export=True, + params=(('auto_config', BOOL, True, 'automatically configure solver'), + ('macro_finder', BOOL, False, 'try to find universally quantified formulas that can be viewed as macros'), + ('ematching', BOOL, True, 'E-Matching based quantifier instantiation'), + ('phase_selection', UINT, 4, 'phase selection heuristic: 0 - always false, 1 - always true, 2 - phase caching, 3 - phase caching conservative, 4 - phase caching conservative 2, 5 - random, 6 - number of occurrences'), + ('restart_strategy', UINT, 1, '0 - geometric, 1 - inner-outer-geometric, 2 - luby, 3 - fixed, 4 - arithmetic'), + ('restart_factor', DOUBLE, 1.1, 'when using geometric (or inner-outer-geometric) progression of restarts, it specifies the constant used to multiply the currect restart threshold'), + ('case_split', UINT, 1, '0 - case split based on variable activity, 1 - similar to 0, but delay case splits created during the search, 2 - similar to 0, but cache the relevancy, 3 - case split based on relevancy (structural splitting), 4 - case split on relevancy and activity, 5 - case split on relevancy and current goal'), + ('delay_units', BOOL, False, 'if true then z3 will not restart when a unit clause is learned'), + ('delay_units_threshold', UINT, 32, 'maximum number of learned unit clauses before restarting, ingored if delay_units is false'), + ('mbqi', BOOL, True, 'model based quantifier instantiation (MBQI)'), + ('mbqi.max_cexs', UINT, 1, 'initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation'), + ('mbqi.max_cexs_incr', UINT, 0, 'increment for MBQI_MAX_CEXS, the increment is performed after each round of MBQI'), + ('mbqi.max_iterations', UINT, 1000, 'maximum number of rounds of MBQI'), + ('mbqi.trace', BOOL, False, 'generate tracing messages for Model Based Quantifier Instantiation (MBQI). It will display a message before every round of MBQI, and the quantifiers that were not satisfied'), + ('mbqi.force_template', UINT, 10, 'some quantifiers can be used as templates for building interpretations for functions. Z3 uses heuristics to decide whether a quantifier will be used as a template or not. Quantifiers with weight >= mbqi.force_template are forced to be used as a template'), + ('qi.profile', BOOL, False, 'profile quantifier instantiation'), + ('qi.profile_freq', UINT, UINT_MAX, 'how frequent results are reported by qi.profile'), + ('qi.max_instances', UINT, UINT_MAX, 'maximum number of quantifier instantiations'), + ('qi.eager_threshold', DOUBLE, 10.0, 'threshold for eager quantifier instantiation'), + ('qi.lazy_threshold', DOUBLE, 20.0, 'threshold for lazy quantifier instantiation'), + ('qi.cost', STRING, '(+ weight generation)', 'expression specifying what is the cost of a given quantifier instantiation'), + ('qi.max_multi_patterns', UINT, 0, 'specify the number of extra multi patterns'), + ('bv.reflect', BOOL, True, 'create enode for every bit-vector term'), + ('arith.random_initial_value', BOOL, False, 'use random initial values in the simplex-based procedure for linear arithmetic'), + ('arith.solver', UINT, 2, 'arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination'), + ('arith.nl', BOOL, True, '(incomplete) nonlinear arithmetic support based on Groebner basis and interval propagation'), + ('arith.nl.gb', BOOL, True, 'groebner Basis computation, this option is ignored when arith.nl=false'), + ('arith.nl.branching', BOOL, True, 'branching on integer variables in non linear clusters'), + ('arith.nl.rounds', UINT, 1024, 'threshold for number of (nested) final checks for non linear arithmetic'), + ('arith.euclidean_solver', BOOL, False, 'eucliean solver for linear integer arithmetic'), + ('arith.propagate_eqs', BOOL, True, 'propagate (cheap) equalities'), + ('arith.branch_cut_ratio', UINT, 2, 'branch/cut ratio for linear integer arithmetic'), + ('arith.int_eq_branch', BOOL, False, 'branching using derived integer equations'), + ('arith.ignore_int', BOOL, False, 'treat integer variables as real'))) diff --git a/src/smt/params/theory_arith_params.cpp b/src/smt/params/theory_arith_params.cpp index 8dde26e94..5a1101524 100644 --- a/src/smt/params/theory_arith_params.cpp +++ b/src/smt/params/theory_arith_params.cpp @@ -16,63 +16,22 @@ Author: Revision History: --*/ - #include"theory_arith_params.h" +#include"smt_params_helper.hpp" -#if 0 -void theory_arith_params::register_params(ini_params & p) { -#ifdef _EXTERNAL_RELEASE - p.register_int_param("arith_solver", 0, 3, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination"); -#else - p.register_int_param("arith_solver", 0, 4, reinterpret_cast(m_arith_mode), "select arithmetic solver: 0 - no solver, 1 - bellman-ford based solver (diff. logic only), 2 - simplex based solver, 3 - floyd-warshall based solver (diff. logic only) and no theory combination, 4 - model guided arith_solver"); -#endif - p.register_bool_param("arith_force_simplex", m_arith_auto_config_simplex, "force Z3 to use simplex solver."); - p.register_unsigned_param("arith_blands_rule_threshold", m_arith_blands_rule_threshold); - p.register_bool_param("arith_propagate_eqs", m_arith_propagate_eqs); - p.register_int_param("arith_propagation_mode", 0, 2, reinterpret_cast(m_arith_bound_prop)); - p.register_bool_param("arith_stronger_lemmas", m_arith_stronger_lemmas); - p.register_bool_param("arith_skip_big_coeffs", m_arith_skip_rows_with_big_coeffs); - p.register_unsigned_param("arith_max_lemma_size", m_arith_max_lemma_size); - p.register_unsigned_param("arith_small_lemma_size", m_arith_small_lemma_size); - p.register_bool_param("arith_reflect", m_arith_reflect); - p.register_bool_param("arith_ignore_int", m_arith_ignore_int); - p.register_unsigned_param("arith_lazy_pivoting", m_arith_lazy_pivoting_lvl); - p.register_unsigned_param("arith_random_seed", m_arith_random_seed); - p.register_bool_param("arith_random_initial_value", m_arith_random_initial_value); - p.register_int_param("arith_random_lower", m_arith_random_lower); - p.register_int_param("arith_random_upper", m_arith_random_upper); - p.register_bool_param("arith_adaptive", m_arith_adaptive); - p.register_double_param("arith_adaptive_assertion_threshold", m_arith_adaptive_assertion_threshold, "Delay arithmetic atoms if the num-arith-conflicts/total-conflicts < threshold"); - p.register_double_param("arith_adaptive_propagation_threshold", m_arith_adaptive_propagation_threshold, "Disable arithmetic theory propagation if the num-arith-conflicts/total-conflicts < threshold"); - p.register_bool_param("arith_dump_lemmas", m_arith_dump_lemmas); - p.register_bool_param("arith_eager_eq_axioms", m_arith_eager_eq_axioms); - p.register_unsigned_param("arith_branch_cut_ratio", m_arith_branch_cut_ratio); - - p.register_bool_param("arith_add_binary_bounds", m_arith_add_binary_bounds); - p.register_unsigned_param("arith_prop_strategy", 0, 1, reinterpret_cast(m_arith_propagation_strategy), "Propagation strategy: 0 - use agility measures based on ration of theory conflicts, 1 - propagate proportional to ratio of theory conflicts (default)"); - - p.register_bool_param("arith_eq_bounds", m_arith_eq_bounds); - p.register_bool_param("arith_lazy_adapter", m_arith_lazy_adapter); - p.register_bool_param("arith_gcd_test", m_arith_gcd_test); - p.register_bool_param("arith_eager_gcd", m_arith_eager_gcd); - p.register_bool_param("arith_adaptive_gcd", m_arith_adaptive_gcd); - p.register_unsigned_param("arith_propagation_threshold", m_arith_propagation_threshold); - - p.register_bool_param("nl_arith", m_nl_arith, "enable/disable non linear arithmetic support. This option is ignored when ARITH_SOLVER != 2."); - p.register_bool_param("nl_arith_gb", m_nl_arith_gb, "enable/disable Grobner Basis computation. This option is ignored when NL_ARITH=false"); - p.register_bool_param("nl_arith_gb_eqs", m_nl_arith_gb_eqs, "enable/disable equations in the Grobner Basis to be copied to the Simplex tableau."); - p.register_bool_param("nl_arith_gb_perturbate", m_nl_arith_gb_perturbate, "enable/disable perturbation of the variable order in GB when searching for new polynomials."); - p.register_unsigned_param("nl_arith_gb_threshold", m_nl_arith_gb_threshold, "Grobner basis computation can be very expensive. This is a threshold on the number of new equalities that can be generated."); - p.register_bool_param("nl_arith_branching", m_nl_arith_branching, "enable/disable branching on integer variables in non linear clusters"); - p.register_unsigned_param("nl_arith_rounds", m_nl_arith_rounds, "threshold for number of (nested) final checks for non linear arithmetic."); - p.register_unsigned_param("nl_arith_max_degree", m_nl_arith_max_degree, "max degree for internalizing new monomials."); - PRIVATE_PARAMS({ - p.register_bool_param("arith_fixnum", m_arith_fixnum); - p.register_bool_param("arith_int_only", m_arith_int_only); - p.register_bool_param("arith_enum_const_mod", m_arith_enum_const_mod, "Create axioms for the finite set of equalities for (mod x k) where k is a positive numeral constant"); - p.register_bool_param("arith_int_eq_branching", m_arith_int_eq_branching, "Determine branch predicates based on integer equation solving"); - }); - p.register_bool_param("arith_euclidean_solver", m_arith_euclidean_solver, ""); +void theory_arith_params::updt_params(params_ref const & _p) { + smt_params_helper p(_p); + m_arith_random_initial_value = p.arith_random_initial_value(); + m_arith_mode = static_cast(p.arith_solver()); + m_nl_arith = p.arith_nl(); + m_nl_arith_gb = p.arith_nl_gb(); + m_nl_arith_branching = p.arith_nl_branching(); + m_nl_arith_rounds = p.arith_nl_rounds(); + m_arith_euclidean_solver = p.arith_euclidean_solver(); + m_arith_propagate_eqs = p.arith_propagate_eqs(); + m_arith_branch_cut_ratio = p.arith_branch_cut_ratio(); + m_arith_int_eq_branching = p.arith_int_eq_branch(); + m_arith_ignore_int = p.arith_ignore_int(); } -#endif + diff --git a/src/smt/params/theory_arith_params.h b/src/smt/params/theory_arith_params.h index 01163dd0a..52fef8ca4 100644 --- a/src/smt/params/theory_arith_params.h +++ b/src/smt/params/theory_arith_params.h @@ -20,6 +20,7 @@ Revision History: #define _THEORY_ARITH_PARAMS_H_ #include +#include"params.h" enum arith_solver_id { AS_NO_ARITH, @@ -104,7 +105,7 @@ struct theory_arith_params { bool m_arith_euclidean_solver; - theory_arith_params(): + theory_arith_params(params_ref const & p = params_ref()): m_arith_mode(AS_ARITH), m_arith_auto_config_simplex(false), m_arith_blands_rule_threshold(1000), @@ -149,7 +150,10 @@ struct theory_arith_params { m_nl_arith_branching(true), m_nl_arith_rounds(1024), m_arith_euclidean_solver(false) { + updt_params(p); } + + void updt_params(params_ref const & p); }; #endif /* _THEORY_ARITH_PARAMS_H_ */ diff --git a/src/smt/params/theory_bv_params.cpp b/src/smt/params/theory_bv_params.cpp new file mode 100644 index 000000000..c2a31c59d --- /dev/null +++ b/src/smt/params/theory_bv_params.cpp @@ -0,0 +1,25 @@ +/*++ +Copyright (c) 2012 Microsoft Corporation + +Module Name: + + theory_bv_params.cpp + +Abstract: + + + +Author: + + Leonardo de Moura (leonardo) 2012-12-02. + +Revision History: + +--*/ +#include"theory_bv_params.h" +#include"smt_params_helper.hpp" + +void theory_bv_params::updt_params(params_ref const & _p) { + smt_params_helper p(_p); + m_bv_reflect = p.bv_reflect(); +} diff --git a/src/smt/params/theory_bv_params.h b/src/smt/params/theory_bv_params.h index 18a3bac77..a3052b4e9 100644 --- a/src/smt/params/theory_bv_params.h +++ b/src/smt/params/theory_bv_params.h @@ -19,6 +19,8 @@ Revision History: #ifndef _THEORY_BV_PARAMS_H_ #define _THEORY_BV_PARAMS_H_ +#include"params.h" + enum bv_solver_id { BS_NO_BV, BS_BLASTER @@ -31,24 +33,17 @@ struct theory_bv_params { bool m_bv_cc; unsigned m_bv_blast_max_size; bool m_bv_enable_int2bv2int; - theory_bv_params(): + theory_bv_params(params_ref const & p = params_ref()): m_bv_mode(BS_BLASTER), m_bv_reflect(true), m_bv_lazy_le(false), m_bv_cc(false), m_bv_blast_max_size(INT_MAX), - m_bv_enable_int2bv2int(false) {} -#if 0 - void register_params(ini_params & p) { - p.register_int_param("bv_solver", 0, 2, reinterpret_cast(m_bv_mode), "0 - no bv, 1 - simple"); - p.register_unsigned_param("bv_blast_max_size", m_bv_blast_max_size, "Maximal size for bit-vectors to blast"); - p.register_bool_param("bv_reflect", m_bv_reflect); - p.register_bool_param("bv_lazy_le", m_bv_lazy_le); - p.register_bool_param("bv_cc", m_bv_cc, "enable congruence closure for BV operators"); - p.register_bool_param("bv_enable_int2bv_propagation", m_bv_enable_int2bv2int, - "enable full (potentially expensive) propagation for int2bv and bv2int"); - } -#endif + m_bv_enable_int2bv2int(false) { + updt_params(p); + } + + void updt_params(params_ref const & p); }; #endif /* _THEORY_BV_PARAMS_H_ */ diff --git a/src/smt/smt_kernel.cpp b/src/smt/smt_kernel.cpp index 977f0ee4a..23687af8c 100644 --- a/src/smt/smt_kernel.cpp +++ b/src/smt/smt_kernel.cpp @@ -179,7 +179,9 @@ namespace smt { } void updt_params(params_ref const & p) { - params2smt_params(p, fparams()); + // 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()); } }; diff --git a/src/smt/smt_solver.cpp b/src/smt/smt_solver.cpp index ad653a968..2aa4ee28f 100644 --- a/src/smt/smt_solver.cpp +++ b/src/smt/smt_solver.cpp @@ -36,7 +36,7 @@ namespace smt { } virtual void updt_params(params_ref const & p) { - // PARAM-TODO copy p --> m_params + m_params.updt_params(p); if (m_context == 0) return; m_context->updt_params(p); diff --git a/src/smt/tactic/smt_tactic.cpp b/src/smt/tactic/smt_tactic.cpp index a8694363c..20b6585e1 100644 --- a/src/smt/tactic/smt_tactic.cpp +++ b/src/smt/tactic/smt_tactic.cpp @@ -24,7 +24,7 @@ Notes: #include"rewriter_types.h" class smt_tactic : public tactic { - smt_params m_params; + smt_params m_params; params_ref m_params_ref; statistics m_stats; std::string m_failure; @@ -63,9 +63,7 @@ public: virtual void updt_params(params_ref const & p) { TRACE("smt_tactic", tout << this << "\nupdt_params: " << p << "\n";); updt_params_core(p); - m_params_ref = p; - // PARAM-TODO update params2smt_params p ---> m_params - params2smt_params(m_params_ref, fparams()); + fparams().updt_params(p); SASSERT(p.get_bool("auto_config", fparams().m_auto_config) == fparams().m_auto_config); }