From e9499c41f405df8b42fd9ae10004b1b91a869106 Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Tue, 17 Dec 2019 13:43:44 -0800 Subject: [PATCH] Generate code for options with modes. (#3561) This commit adds support for code generation of options with modes (enums). From now on option enums can be specified in the corresponding *.toml files without the need of extra code. All option enums are now in the options namespace. --- .travis.yml | 1 + INSTALL.md | 1 + src/CMakeLists.txt | 8 - src/bindings/java/CMakeLists.txt | 2 +- src/decision/decision_engine.cpp | 5 +- src/decision/justification_heuristic.cpp | 17 +- src/expr/type_properties_template.h | 2 +- src/main/command_executor.cpp | 12 +- src/options/CMakeLists.txt | 37 +- src/options/arith_heuristic_pivot_rule.cpp | 40 - src/options/arith_heuristic_pivot_rule.h | 38 - src/options/arith_options.toml | 46 +- src/options/arith_propagation_mode.cpp | 43 - src/options/arith_propagation_mode.h | 38 - src/options/arith_unate_lemma_mode.cpp | 43 - src/options/arith_unate_lemma_mode.h | 38 - src/options/bool_to_bv_mode.cpp | 42 - src/options/bool_to_bv_mode.h | 57 - src/options/bv_bitblast_mode.cpp | 105 - src/options/bv_bitblast_mode.h | 123 -- src/options/bv_options.toml | 96 +- src/options/datatypes_modes.h | 44 - src/options/datatypes_options.toml | 22 +- src/options/decision_mode.cpp | 39 - src/options/decision_mode.h | 64 - src/options/decision_options.toml | 34 +- src/options/mkoptions.py | 540 ++--- src/options/module_template.cpp | 2 + src/options/module_template.h | 4 +- src/options/options.h | 2 +- src/options/options.i | 3 - src/options/options_handler.cpp | 1865 +---------------- src/options/options_handler.h | 181 +- src/options/options_public_functions.cpp | 3 +- src/options/printer_modes.cpp | 35 +- src/options/printer_modes.h | 27 +- src/options/printer_options.toml | 22 +- src/options/quantifiers_modes.cpp | 82 - src/options/quantifiers_modes.h | 370 ---- src/options/quantifiers_options.toml | 471 ++++- src/options/smt_modes.cpp | 36 - src/options/smt_modes.h | 73 - src/options/smt_options.toml | 57 +- src/options/strings_modes.cpp | 71 - src/options/strings_modes.h | 78 - src/options/strings_options.toml | 42 +- src/options/sygus_out_mode.h | 39 - src/options/theory_options.toml | 13 +- src/options/theoryof_mode.cpp | 36 - src/options/theoryof_mode.h | 38 - src/options/uf_options.toml | 16 +- src/options/ufss_mode.h | 50 - src/preprocessing/passes/bool_to_bv.cpp | 11 +- src/preprocessing/passes/bv_abstraction.cpp | 2 +- .../passes/quantifier_macros.cpp | 9 +- src/proof/bitvector_proof.cpp | 10 +- src/proof/clausal_bitvector_proof.cpp | 16 +- src/proof/proof_manager.cpp | 2 +- src/proof/resolution_bitvector_proof.cpp | 4 +- src/proof/theory_proof.cpp | 13 +- src/prop/bvminisat/simp/SimpSolver.cc | 42 +- src/prop/minisat/minisat.cpp | 11 +- src/smt/command.cpp | 8 +- src/smt/model_blocker.cpp | 6 +- src/smt/model_blocker.h | 5 +- src/smt/model_core_builder.cpp | 6 +- src/smt/model_core_builder.h | 10 +- src/smt/smt_engine.cpp | 163 +- src/theory/arith/attempt_solution_simplex.cpp | 2 +- src/theory/arith/dual_simplex.cpp | 6 +- src/theory/arith/error_set.cpp | 150 +- src/theory/arith/error_set.h | 27 +- src/theory/arith/fc_simplex.cpp | 3 +- src/theory/arith/nonlinear_extension.cpp | 2 +- src/theory/arith/simplex.h | 2 +- src/theory/arith/soi_simplex.cpp | 2 +- src/theory/arith/theory_arith_private.cpp | 53 +- src/theory/bv/abstraction.cpp | 5 +- src/theory/bv/bitblast/eager_bitblaster.cpp | 8 +- src/theory/bv/bv_subtheory_algebraic.cpp | 2 +- src/theory/bv/bv_subtheory_bitblast.cpp | 2 +- src/theory/bv/slicer.cpp | 12 +- src/theory/bv/theory_bv.cpp | 35 +- src/theory/bv/theory_bv_utils.cpp | 3 +- src/theory/datatypes/sygus_extension.cpp | 18 +- src/theory/datatypes/sygus_extension.h | 14 +- .../quantifiers/cegqi/ceg_bv_instantiator.cpp | 4 +- .../ematching/inst_strategy_e_matching.cpp | 59 +- .../ematching/inst_strategy_e_matching.h | 80 +- .../ematching/instantiation_engine.cpp | 3 +- src/theory/quantifiers/ematching/trigger.cpp | 57 +- src/theory/quantifiers/ematching/trigger.h | 25 +- src/theory/quantifiers/equality_query.cpp | 16 +- .../quantifiers/fmf/full_model_check.cpp | 7 +- src/theory/quantifiers/fmf/model_builder.cpp | 2 +- src/theory/quantifiers/fmf/model_engine.cpp | 4 +- .../quantifiers/quant_conflict_find.cpp | 16 +- src/theory/quantifiers/quant_split.cpp | 11 +- .../quantifiers/quantifiers_rewriter.cpp | 74 +- src/theory/quantifiers/query_generator.cpp | 6 +- .../sygus/ce_guided_single_inv.cpp | 31 +- src/theory/quantifiers/sygus/cegis.cpp | 9 +- src/theory/quantifiers/sygus/cegis_unif.cpp | 9 +- .../quantifiers/sygus/sygus_grammar_cons.cpp | 16 +- .../quantifiers/sygus/sygus_unif_rl.cpp | 8 +- .../quantifiers/sygus/synth_conjecture.cpp | 25 +- .../quantifiers/sygus/term_database_sygus.cpp | 10 +- src/theory/quantifiers/term_database.cpp | 21 +- src/theory/quantifiers_engine.cpp | 43 +- src/theory/quantifiers_engine.h | 5 +- src/theory/rewriter.cpp | 3 +- src/theory/sort_inference.cpp | 10 +- src/theory/strings/regexp_solver.cpp | 10 +- src/theory/strings/solver_state.cpp | 3 +- src/theory/strings/solver_state.h | 3 +- src/theory/strings/theory_strings.cpp | 13 +- src/theory/theory.cpp | 186 +- src/theory/theory.h | 3 +- src/theory/theory_engine.cpp | 14 +- src/theory/theory_engine.h | 12 +- src/theory/type_enumerator_template.cpp | 2 +- src/theory/uf/cardinality_extension.cpp | 29 +- src/theory/uf/theory_uf.cpp | 2 +- src/theory/valuation.cpp | 13 +- src/theory/valuation.h | 8 +- 125 files changed, 1889 insertions(+), 4780 deletions(-) delete mode 100644 src/options/arith_heuristic_pivot_rule.cpp delete mode 100644 src/options/arith_heuristic_pivot_rule.h delete mode 100644 src/options/arith_propagation_mode.cpp delete mode 100644 src/options/arith_propagation_mode.h delete mode 100644 src/options/arith_unate_lemma_mode.cpp delete mode 100644 src/options/arith_unate_lemma_mode.h delete mode 100644 src/options/bool_to_bv_mode.cpp delete mode 100644 src/options/bool_to_bv_mode.h delete mode 100644 src/options/bv_bitblast_mode.cpp delete mode 100644 src/options/bv_bitblast_mode.h delete mode 100644 src/options/datatypes_modes.h delete mode 100644 src/options/decision_mode.cpp delete mode 100644 src/options/decision_mode.h delete mode 100644 src/options/quantifiers_modes.cpp delete mode 100644 src/options/quantifiers_modes.h delete mode 100644 src/options/smt_modes.cpp delete mode 100644 src/options/smt_modes.h delete mode 100644 src/options/strings_modes.cpp delete mode 100644 src/options/strings_modes.h delete mode 100644 src/options/sygus_out_mode.h delete mode 100644 src/options/theoryof_mode.cpp delete mode 100644 src/options/theoryof_mode.h delete mode 100644 src/options/ufss_mode.h diff --git a/.travis.yml b/.travis.yml index 505c69c54..fbf0d2bb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,7 @@ script: - ccache -z - ${CC} --version - ${CXX} --version + - sudo pip install toml - | echo "travis_fold:start:load_script" normal="$(echo -e '\033[0m')" red="$normal$(echo -e '\033[01;31m')" green="$normal$(echo -e '\033[01;32m')" diff --git a/INSTALL.md b/INSTALL.md index f61342da6..491dbbb43 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -49,6 +49,7 @@ compatible. - [CMake >= 3.1](https://cmake.org) - [GNU Bash](https://www.gnu.org/software/bash/) - [Python >= 2.7](https://www.python.org) + + module [toml](https://pypi.org/project/toml/) - [GMP v4.2 (GNU Multi-Precision arithmetic library)](https://gmplib.org) - [libantlr3c v3.2 or v3.4 (ANTLR parser generator C support library)](http://www.antlr3.org/) - [Java >= 1.6](https://www.java.com) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e62507d8e..af29a761c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -894,19 +894,11 @@ install(FILES ${INCLUDE_INSTALL_DIR}/cvc4/expr) install(FILES options/argument_extender.h - options/arith_heuristic_pivot_rule.h - options/arith_propagation_mode.h - options/arith_unate_lemma_mode.h - options/datatypes_modes.h options/language.h options/option_exception.h options/options.h options/printer_modes.h - options/quantifiers_modes.h options/set_language.h - options/smt_modes.h - options/sygus_out_mode.h - options/theoryof_mode.h DESTINATION ${INCLUDE_INSTALL_DIR}/cvc4/options) install(FILES diff --git a/src/bindings/java/CMakeLists.txt b/src/bindings/java/CMakeLists.txt index b68a353ad..3ab2ed446 100644 --- a/src/bindings/java/CMakeLists.txt +++ b/src/bindings/java/CMakeLists.txt @@ -185,7 +185,7 @@ set(gen_java_files ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_CVC4__Model.java ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_CVC4__Printer.java ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_CVC4__api__Solver.java - ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_InstFormatMode.java + ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_CVC4__options__InstFormatMode.java ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_LemmaChannels.java ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_Listener.java ${CMAKE_CURRENT_BINARY_DIR}/SWIGTYPE_p_ListenerCollection__Registration.java diff --git a/src/decision/decision_engine.cpp b/src/decision/decision_engine.cpp index 679dd6cc6..dc798626e 100644 --- a/src/decision/decision_engine.cpp +++ b/src/decision/decision_engine.cpp @@ -18,7 +18,6 @@ #include "decision/decision_attributes.h" #include "decision/justification_heuristic.h" #include "expr/node.h" -#include "options/decision_mode.h" #include "options/decision_options.h" #include "options/smt_options.h" @@ -53,8 +52,8 @@ void DecisionEngine::init() Trace("decision-init") << " * options->decisionStopOnly: " << options::decisionStopOnly() << std::endl; - if(options::decisionMode() == decision::DECISION_STRATEGY_INTERNAL) { } - if(options::decisionMode() == decision::DECISION_STRATEGY_JUSTIFICATION) { + if (options::decisionMode() == options::DecisionMode::JUSTIFICATION) + { ITEDecisionStrategy* ds = new decision::JustificationHeuristic(this, d_userContext, d_satContext); enableStrategy(ds); diff --git a/src/decision/justification_heuristic.cpp b/src/decision/justification_heuristic.cpp index f7e5b84fc..a6b6cbd8f 100644 --- a/src/decision/justification_heuristic.cpp +++ b/src/decision/justification_heuristic.cpp @@ -248,7 +248,9 @@ DecisionWeight JustificationHeuristic::getWeightPolarized(TNode n, SatValue satV DecisionWeight JustificationHeuristic::getWeightPolarized(TNode n, bool polarity) { - if(options::decisionWeightInternal() != DECISION_WEIGHT_INTERNAL_USR1) { + if (options::decisionWeightInternal() + != options::DecisionWeightInternal::USR1) + { return getWeight(n); } @@ -297,10 +299,11 @@ DecisionWeight JustificationHeuristic::getWeightPolarized(TNode n, bool polarity DecisionWeight JustificationHeuristic::getWeight(TNode n) { if(!n.hasAttribute(DecisionWeightAttr()) ) { + options::DecisionWeightInternal combiningFn = + options::decisionWeightInternal(); - DecisionWeightInternal combiningFn = options::decisionWeightInternal(); - - if (combiningFn == DECISION_WEIGHT_INTERNAL_OFF || n.getNumChildren() == 0) + if (combiningFn == options::DecisionWeightInternal::OFF + || n.getNumChildren() == 0) { if (options::decisionRandomWeight() != 0) { @@ -308,15 +311,15 @@ DecisionWeight JustificationHeuristic::getWeight(TNode n) { Random::getRandom().pick(0, options::decisionRandomWeight()-1)); } } - else if (combiningFn == DECISION_WEIGHT_INTERNAL_MAX) + else if (combiningFn == options::DecisionWeightInternal::MAX) { DecisionWeight dW = 0; for (TNode::iterator i = n.begin(); i != n.end(); ++i) dW = max(dW, getWeight(*i)); n.setAttribute(DecisionWeightAttr(), dW); } - else if (combiningFn == DECISION_WEIGHT_INTERNAL_SUM - || combiningFn == DECISION_WEIGHT_INTERNAL_USR1) + else if (combiningFn == options::DecisionWeightInternal::SUM + || combiningFn == options::DecisionWeightInternal::USR1) { DecisionWeight dW = 0; for (TNode::iterator i = n.begin(); i != n.end(); ++i) diff --git a/src/expr/type_properties_template.h b/src/expr/type_properties_template.h index 6f1297f16..8e4ce797e 100644 --- a/src/expr/type_properties_template.h +++ b/src/expr/type_properties_template.h @@ -31,7 +31,7 @@ ${type_properties_includes} -#line 36 "${template}" +#line 35 "${template}" namespace CVC4 { namespace kind { diff --git a/src/main/command_executor.cpp b/src/main/command_executor.cpp index 241ca2b8f..5dbc50592 100644 --- a/src/main/command_executor.cpp +++ b/src/main/command_executor.cpp @@ -159,11 +159,13 @@ bool CommandExecutor::doCommandSingleton(Command* cmd) getterCommands.emplace_back(new GetProofCommand()); } - if (d_options.getDumpInstantiations() && - ((d_options.getInstFormatMode() != INST_FORMAT_MODE_SZS && - (res.asSatisfiabilityResult() == Result::SAT || - (res.isUnknown() && res.whyUnknown() == Result::INCOMPLETE))) || - res.asSatisfiabilityResult() == Result::UNSAT)) { + if (d_options.getDumpInstantiations() + && ((d_options.getInstFormatMode() != options::InstFormatMode::SZS + && (res.asSatisfiabilityResult() == Result::SAT + || (res.isUnknown() + && res.whyUnknown() == Result::INCOMPLETE))) + || res.asSatisfiabilityResult() == Result::UNSAT)) + { getterCommands.emplace_back(new GetInstantiationsCommand()); } diff --git a/src/options/CMakeLists.txt b/src/options/CMakeLists.txt index 70af2f056..4fb331e50 100644 --- a/src/options/CMakeLists.txt +++ b/src/options/CMakeLists.txt @@ -1,21 +1,22 @@ +# Check if the toml Python module is installed. +execute_process( + COMMAND + ${PYTHON_EXECUTABLE} -c "import toml" + RESULT_VARIABLE + RET_TOML + ERROR_QUIET +) + +if(RET_TOML) + message(FATAL_ERROR + "Could not find Python module toml. Install via `pip install toml'.") +endif() + libcvc4_add_sources( argument_extender.h argument_extender_implementation.cpp argument_extender_implementation.h - arith_heuristic_pivot_rule.cpp - arith_heuristic_pivot_rule.h - arith_propagation_mode.cpp - arith_propagation_mode.h - arith_unate_lemma_mode.cpp - arith_unate_lemma_mode.h base_handlers.h - bool_to_bv_mode.cpp - bool_to_bv_mode.h - bv_bitblast_mode.cpp - bv_bitblast_mode.h - datatypes_modes.h - decision_mode.cpp - decision_mode.h decision_weight.h didyoumean.cpp didyoumean.h @@ -31,18 +32,8 @@ libcvc4_add_sources( options_public_functions.cpp printer_modes.cpp printer_modes.h - quantifiers_modes.cpp - quantifiers_modes.h set_language.cpp set_language.h - smt_modes.cpp - smt_modes.h - strings_modes.cpp - strings_modes.h - sygus_out_mode.h - theoryof_mode.cpp - theoryof_mode.h - ufss_mode.h ) set(options_toml_files diff --git a/src/options/arith_heuristic_pivot_rule.cpp b/src/options/arith_heuristic_pivot_rule.cpp deleted file mode 100644 index 6c1312dbf..000000000 --- a/src/options/arith_heuristic_pivot_rule.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/********************* */ -/*! \file arith_heuristic_pivot_rule.cpp - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters, Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "options/arith_heuristic_pivot_rule.h" - -namespace CVC4 { - -std::ostream& operator<<(std::ostream& out, ErrorSelectionRule rule) { - switch(rule) { - case MINIMUM_AMOUNT: - out << "MINIMUM_AMOUNT"; - break; - case VAR_ORDER: - out << "VAR_ORDER"; - break; - case MAXIMUM_AMOUNT: - out << "MAXIMUM_AMOUNT"; - break; - default: - out << "ArithHeuristicPivotRule!UNKNOWN"; - } - - return out; -} - -}/* CVC4 namespace */ diff --git a/src/options/arith_heuristic_pivot_rule.h b/src/options/arith_heuristic_pivot_rule.h deleted file mode 100644 index 2caa21043..000000000 --- a/src/options/arith_heuristic_pivot_rule.h +++ /dev/null @@ -1,38 +0,0 @@ -/********************* */ -/*! \file arith_heuristic_pivot_rule.h - ** \verbatim - ** Top contributors (to current version): - ** Tim King, Morgan Deters - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "cvc4_public.h" - -#ifndef CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H -#define CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H - -#include - -namespace CVC4 { - -enum ErrorSelectionRule { - VAR_ORDER, - MINIMUM_AMOUNT, - MAXIMUM_AMOUNT, - SUM_METRIC -}; - -std::ostream& operator<<(std::ostream& out, ErrorSelectionRule rule) CVC4_PUBLIC; - -}/* CVC4 namespace */ - -#endif /* CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H */ diff --git a/src/options/arith_options.toml b/src/options/arith_options.toml index 80403ee0d..ab8164130 100644 --- a/src/options/arith_options.toml +++ b/src/options/arith_options.toml @@ -7,11 +7,21 @@ header = "options/arith_options.h" category = "regular" long = "unate-lemmas=MODE" type = "ArithUnateLemmaMode" - default = "ALL_PRESOLVE_LEMMAS" - handler = "stringToArithUnateLemmaMode" - includes = ["options/arith_unate_lemma_mode.h"] + default = "ALL" read_only = true help = "determines which lemmas to add before solving (default is 'all', see --unate-lemmas=help)" + help_mode = "Unate lemmas are generated before SAT search begins using the relationship of constant terms and polynomials." +[[option.mode.ALL]] + name = "all" + help = "A combination of inequalities and equalities." +[[option.mode.EQUALITY]] + name = "eqs" + help = "Outputs lemmas of the general forms (= p c) implies (<= p d) for c < d, or (= p c) implies (not (= p d)) for c != d." +[[option.mode.INEQUALITY]] + name = "ineqs" + help = "Outputs lemmas of the general form (<= p c) implies (<= p d) for c < d." +[[option.mode.NO]] + name = "none" [[option]] name = "arithPropagationMode" @@ -19,10 +29,22 @@ header = "options/arith_options.h" long = "arith-prop=MODE" type = "ArithPropagationMode" default = "BOTH_PROP" - handler = "stringToArithPropagationMode" - includes = ["options/arith_propagation_mode.h"] read_only = true help = "turns on arithmetic propagation (default is 'old', see --arith-prop=help)" + help_mode = "This decides on kind of propagation arithmetic attempts to do during the search." +[[option.mode.NO_PROP]] + name = "none" +[[option.mode.UNATE_PROP]] + name = "unate" + help = "Use constraints to do unate propagation." +[[option.mode.BOUND_INFERENCE_PROP]] + name = "bi" + help = "(Bounds Inference) infers bounds on basic variables using the upper and lower bounds of the non-basic variables in the tableau." +[[option.mode.BOTH_PROP]] + name = "both" + help = "Use bounds inference and unate." + + # The maximum number of difference pivots to do per invocation of simplex. # If this is negative, the number of pivots done is the number of variables. @@ -55,10 +77,20 @@ header = "options/arith_options.h" long = "error-selection-rule=RULE" type = "ErrorSelectionRule" default = "MINIMUM_AMOUNT" - handler = "stringToErrorSelectionRule" - includes = ["options/arith_heuristic_pivot_rule.h"] read_only = true help = "change the pivot rule for the basic variable (default is 'min', see --pivot-rule help)" + help_mode = "This decides on the rule used by simplex during heuristic rounds for deciding the next basic variable to select." +[[option.mode.MINIMUM_AMOUNT]] + name = "min" + help = "The minimum abs() value of the variable's violation of its bound." +[[option.mode.VAR_ORDER]] + name = "varord" + help = "The variable order." +[[option.mode.MAXIMUM_AMOUNT]] + name = "max" + help = "The maximum violation the bound." +[[option.mode.SUM_METRIC]] + name = "sum" # The number of pivots before simplex rechecks every basic variable for a conflict [[option]] diff --git a/src/options/arith_propagation_mode.cpp b/src/options/arith_propagation_mode.cpp deleted file mode 100644 index 895a01381..000000000 --- a/src/options/arith_propagation_mode.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/********************* */ -/*! \file arith_propagation_mode.cpp - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "options/arith_propagation_mode.h" - -namespace CVC4 { - -std::ostream& operator<<(std::ostream& out, ArithPropagationMode mode) { - switch(mode) { - case NO_PROP: - out << "NO_PROP"; - break; - case UNATE_PROP: - out << "UNATE_PROP"; - break; - case BOUND_INFERENCE_PROP: - out << "BOUND_INFERENCE_PROP"; - break; - case BOTH_PROP: - out << "BOTH_PROP"; - break; - default: - out << "ArithPropagationMode!UNKNOWN"; - } - - return out; -} - -}/* CVC4 namespace */ diff --git a/src/options/arith_propagation_mode.h b/src/options/arith_propagation_mode.h deleted file mode 100644 index b2c6b4c61..000000000 --- a/src/options/arith_propagation_mode.h +++ /dev/null @@ -1,38 +0,0 @@ -/********************* */ -/*! \file arith_propagation_mode.h - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters, Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "cvc4_public.h" - -#ifndef CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H -#define CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H - -#include - -namespace CVC4 { - -enum ArithPropagationMode { - NO_PROP, - UNATE_PROP, - BOUND_INFERENCE_PROP, - BOTH_PROP -}; - -std::ostream& operator<<(std::ostream& out, ArithPropagationMode rule) CVC4_PUBLIC; - -}/* CVC4 namespace */ - -#endif /* CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H */ diff --git a/src/options/arith_unate_lemma_mode.cpp b/src/options/arith_unate_lemma_mode.cpp deleted file mode 100644 index 34fbeb3b2..000000000 --- a/src/options/arith_unate_lemma_mode.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/********************* */ -/*! \file arith_unate_lemma_mode.cpp - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "options/arith_unate_lemma_mode.h" - -namespace CVC4 { - -std::ostream& operator<<(std::ostream& out, ArithUnateLemmaMode mode) { - switch(mode) { - case NO_PRESOLVE_LEMMAS: - out << "NO_PRESOLVE_LEMMAS"; - break; - case INEQUALITY_PRESOLVE_LEMMAS: - out << "INEQUALITY_PRESOLVE_LEMMAS"; - break; - case EQUALITY_PRESOLVE_LEMMAS: - out << "EQUALITY_PRESOLVE_LEMMAS"; - break; - case ALL_PRESOLVE_LEMMAS: - out << "ALL_PRESOLVE_LEMMAS"; - break; - default: - out << "ArithUnateLemmaMode!UNKNOWN"; - } - - return out; -} - -}/* CVC4 namespace */ diff --git a/src/options/arith_unate_lemma_mode.h b/src/options/arith_unate_lemma_mode.h deleted file mode 100644 index a917b83fd..000000000 --- a/src/options/arith_unate_lemma_mode.h +++ /dev/null @@ -1,38 +0,0 @@ -/********************* */ -/*! \file arith_unate_lemma_mode.h - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "cvc4_public.h" - -#ifndef CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H -#define CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H - -#include - -namespace CVC4 { - -typedef enum { - NO_PRESOLVE_LEMMAS, - INEQUALITY_PRESOLVE_LEMMAS, - EQUALITY_PRESOLVE_LEMMAS, - ALL_PRESOLVE_LEMMAS -} ArithUnateLemmaMode; - -std::ostream& operator<<(std::ostream& out, ArithUnateLemmaMode rule) CVC4_PUBLIC; - -}/* CVC4 namespace */ - -#endif /* CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H */ diff --git a/src/options/bool_to_bv_mode.cpp b/src/options/bool_to_bv_mode.cpp deleted file mode 100644 index 12fd3c1f9..000000000 --- a/src/options/bool_to_bv_mode.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/********************* */ -/*! \file bool_to_bv_mode.cpp - ** \verbatim - ** Top contributors (to current version): - ** Makai Mann - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** [[ Add lengthier description here ]] - - ** \todo document this file - -**/ - -#include "options/bool_to_bv_mode.h" - -#include - - -namespace CVC4 -{ - std::ostream& operator<<(std::ostream& out, preprocessing::passes::BoolToBVMode mode) { - switch(mode) { - case preprocessing::passes::BOOL_TO_BV_OFF: - out << "BOOL_TO_BV_OFF"; - break; - case preprocessing::passes::BOOL_TO_BV_ITE: - out << "BOOL_TO_BV_ITE"; - break; - case preprocessing::passes::BOOL_TO_BV_ALL: - out << "BOOL_TO_BV_ALL"; - break; - default: - out << "BoolToBVMode:UNKNOWN![" << unsigned(mode) << "]"; - } - - return out; - } -} // namespace CVC4 diff --git a/src/options/bool_to_bv_mode.h b/src/options/bool_to_bv_mode.h deleted file mode 100644 index 2dbd723c9..000000000 --- a/src/options/bool_to_bv_mode.h +++ /dev/null @@ -1,57 +0,0 @@ -/********************* */ -/*! \file bool_to_bv_mode.h - ** \verbatim - ** Top contributors (to current version): - ** Makai Mann - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** [[ Add lengthier description here ]] - - ** \todo document this file - -**/ - -#include "cvc4_private.h" - -#ifndef CVC4__PREPROCESSING__PASSES__BOOL_TO_BV_MODE_H -#define CVC4__PREPROCESSING__PASSES__BOOL_TO_BV_MODE_H - -#include - -namespace CVC4 { -namespace preprocessing { -namespace passes { - -/** Enumeration of bool-to-bv modes */ -enum BoolToBVMode -{ - /** - * No bool-to-bv pass - */ - BOOL_TO_BV_OFF, - - /** - * Only lower bools in condition of ITEs - * Tries to give more info to bit-vector solver - * by using bit-vector-ITEs when possible - */ - BOOL_TO_BV_ITE, - - /** - * Lower every bool beneath the top layer to be a - * bit-vector - */ - BOOL_TO_BV_ALL -}; -} -} - -std::ostream& operator<<(std::ostream& out, preprocessing::passes::BoolToBVMode mode); - -} - -#endif /* CVC4__PREPROCESSING__PASSES__BOOL_TO_BV_MODE_H */ diff --git a/src/options/bv_bitblast_mode.cpp b/src/options/bv_bitblast_mode.cpp deleted file mode 100644 index d2425831a..000000000 --- a/src/options/bv_bitblast_mode.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/********************* */ -/*! \file bv_bitblast_mode.cpp - ** \verbatim - ** Top contributors (to current version): - ** Liana Hadarean, Alex Ozdemir - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Bitblast modes for bit-vector solver. - ** - ** Bitblast modes for bit-vector solver. - **/ - -#include "options/bv_bitblast_mode.h" - -#include - -namespace CVC4 { - -std::ostream& operator<<(std::ostream& out, theory::bv::BitblastMode mode) { - switch(mode) { - case theory::bv::BITBLAST_MODE_LAZY: - out << "BITBLAST_MODE_LAZY"; - break; - case theory::bv::BITBLAST_MODE_EAGER: - out << "BITBLAST_MODE_EAGER"; - break; - default: - out << "BitblastMode:UNKNOWN![" << unsigned(mode) << "]"; - } - - return out; -} - -std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode) { - switch(mode) { - case theory::bv::BITVECTOR_SLICER_ON: - out << "BITVECTOR_SLICER_ON"; - break; - case theory::bv::BITVECTOR_SLICER_OFF: - out << "BITVECTOR_SLICER_OFF"; - break; - case theory::bv::BITVECTOR_SLICER_AUTO: - out << "BITVECTOR_SLICER_AUTO"; - break; - default: - out << "BvSlicerMode:UNKNOWN![" << unsigned(mode) << "]"; - } - - return out; -} - -std::ostream& operator<<(std::ostream& out, theory::bv::SatSolverMode solver) { - switch(solver) { - case theory::bv::SAT_SOLVER_MINISAT: - out << "SAT_SOLVER_MINISAT"; - break; - case theory::bv::SAT_SOLVER_CRYPTOMINISAT: - out << "SAT_SOLVER_CRYPTOMINISAT"; - break; - default: - out << "SatSolverMode:UNKNOWN![" << unsigned(solver) << "]"; - } - - return out; -} - -std::ostream& operator<<(std::ostream& out, theory::bv::BvProofFormat format) -{ - switch (format) - { - case theory::bv::BITVECTOR_PROOF_ER: out << "BITVECTOR_PROOF_ER"; break; - case theory::bv::BITVECTOR_PROOF_DRAT: out << "BITVECTOR_PROOF_DRAT"; break; - case theory::bv::BITVECTOR_PROOF_LRAT: out << "BITVECTOR_PROOF_LRAT"; break; - default: out << "BvProofFormat:UNKNOWN![" << unsigned(format) << "]"; - } - - return out; -} - -std::ostream& operator<<(std::ostream& out, - theory::bv::BvOptimizeSatProof level) -{ - switch (level) - { - case theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_NONE: - out << "BITVECTOR_OPTIMIZE_SAT_PROOF_NONE"; - break; - case theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF: - out << "BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF"; - break; - case theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA: - out << "BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA"; - break; - default: out << "BvOptimizeSatProof:UNKNOWN![" << unsigned(level) << "]"; - } - - return out; -} - -}/* CVC4 namespace */ - diff --git a/src/options/bv_bitblast_mode.h b/src/options/bv_bitblast_mode.h deleted file mode 100644 index 7243c38e1..000000000 --- a/src/options/bv_bitblast_mode.h +++ /dev/null @@ -1,123 +0,0 @@ -/********************* */ -/*! \file bv_bitblast_mode.h - ** \verbatim - ** Top contributors (to current version): - ** Liana Hadarean, Alex Ozdemir, Mathias Preiner - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Bitblasting modes for bit-vector solver. - ** - ** Bitblasting modes for bit-vector solver. - **/ - -#include "cvc4_private.h" - -#ifndef CVC4__THEORY__BV__BITBLAST_MODE_H -#define CVC4__THEORY__BV__BITBLAST_MODE_H - -#include - -namespace CVC4 { -namespace theory { -namespace bv { - -/** Enumeration of bit-blasting modes */ -enum BitblastMode { - - /** - * Lazy bit-blasting that separates boolean reasoning - * from term reasoning. - */ - BITBLAST_MODE_LAZY, - - /** - * Bit-blast eagerly to the bit-vector SAT solver. - */ - BITBLAST_MODE_EAGER -};/* enum BitblastMode */ - -/** Enumeration of bit-vector equality slicer mode */ -enum BvSlicerMode { - - /** - * Force the slicer on. - */ - BITVECTOR_SLICER_ON, - - /** - * Slicer off. - */ - BITVECTOR_SLICER_OFF, - - /** - * Auto enable slicer if problem has only equalities. - */ - BITVECTOR_SLICER_AUTO - -};/* enum BvSlicerMode */ - -/** Enumeration of sat solvers that can be used. */ -enum SatSolverMode -{ - SAT_SOLVER_MINISAT, - SAT_SOLVER_CRYPTOMINISAT, - SAT_SOLVER_CADICAL, -}; /* enum SatSolver */ - -/** - * When the BV solver does eager bitblasting backed by CryptoMiniSat, proofs - * can be written in a variety of formats. - */ -enum BvProofFormat -{ - /** - * Write extended resolution proofs. - */ - BITVECTOR_PROOF_ER, - /** - * Write DRAT proofs. - */ - BITVECTOR_PROOF_DRAT, - /** - * Write LRAT proofs. - */ - BITVECTOR_PROOF_LRAT, -}; - -/** - * When the BV solver does eager bit-blasting backed by DRAT-producing SAT solvers, proofs - * can be written in a variety of formats. - */ -enum BvOptimizeSatProof -{ - /** - * Do not optimize the SAT proof. - */ - BITVECTOR_OPTIMIZE_SAT_PROOF_NONE = 0, - /** - * Optimize the SAT proof, but do not shrink the formula - */ - BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF = 1, - /** - * Optimize the SAT proof and shrink the formula - */ - BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA = 2, -}; - - -}/* CVC4::theory::bv namespace */ -}/* CVC4::theory namespace */ - -std::ostream& operator<<(std::ostream& out, theory::bv::BitblastMode mode); -std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode); -std::ostream& operator<<(std::ostream& out, theory::bv::SatSolverMode mode); -std::ostream& operator<<(std::ostream& out, theory::bv::BvProofFormat format); -std::ostream& operator<<(std::ostream& out, theory::bv::BvOptimizeSatProof level); - -}/* CVC4 namespace */ - -#endif /* CVC4__THEORY__BV__BITBLAST_MODE_H */ diff --git a/src/options/bv_options.toml b/src/options/bv_options.toml index 9529b7500..00755d8a6 100644 --- a/src/options/bv_options.toml +++ b/src/options/bv_options.toml @@ -6,46 +6,72 @@ header = "options/bv_options.h" name = "bvProofFormat" category = "expert" long = "bv-proof-format=MODE" - type = "CVC4::theory::bv::BvProofFormat" - default = "CVC4::theory::bv::BITVECTOR_PROOF_ER" - handler = "stringToBvProofFormat" - predicates = ["satSolverEnabledBuild"] - includes = ["options/bv_bitblast_mode.h"] + type = "BvProofFormat" + default = "ER" + predicates = ["checkSatSolverEnabled"] help = "choose which UNSAT proof format to use, see --bv-sat-solver=help" + help_mode = "Bit-vector proof formats." +[[option.mode.ER]] + name = "er" + help = "Extended Resolution, i.e. resolution with new variable definitions." +[[option.mode.DRAT]] + name = "drat" + help = "Deletion and Resolution Asymmetric Tautology Additions." +[[option.mode.LRAT]] + name = "lrat" + help = "DRAT with unit propagation hints to accelerate checking." [[option]] name = "bvOptimizeSatProof" category = "expert" long = "bv-optimize-sat-proof=MODE" - type = "CVC4::theory::bv::BvOptimizeSatProof" - default = "CVC4::theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA" - handler = "stringToBvOptimizeSatProof" - predicates = ["satSolverEnabledBuild"] - includes = ["options/bv_bitblast_mode.h"] + type = "BvOptimizeSatProof" + default = "FORMULA" + predicates = ["checkSatSolverEnabled"] help = "enable SAT proof optimizations, see --bv-optimize-sat-proof=help" + help_mode = "SAT proof optimization level." +[[option.mode.NONE]] + name = "none" + help = "Do not optimize the SAT proof." +[[option.mode.PROOF]] + name = "proof" + help = "Use drat-trim to shrink the SAT proof." +[[option.mode.FORMULA]] + name = "formula" + help = "Use drat-trim to shrink the SAT proof and formula." [[option]] name = "bvSatSolver" smt_name = "bv-sat-solver" category = "expert" long = "bv-sat-solver=MODE" - type = "CVC4::theory::bv::SatSolverMode" - default = "CVC4::theory::bv::SAT_SOLVER_MINISAT" - handler = "stringToSatSolver" - predicates = ["satSolverEnabledBuild"] - includes = ["options/bv_bitblast_mode.h"] + type = "SatSolverMode" + default = "MINISAT" + predicates = ["checkBvSatSolver"] help = "choose which sat solver to use, see --bv-sat-solver=help" + help_mode = "SAT solver for bit-blasting backend." +[[option.mode.MINISAT]] + name = "minisat" +[[option.mode.CRYPTOMINISAT]] + name = "cryptominisat" +[[option.mode.CADICAL]] + name = "cadical" [[option]] name = "bitblastMode" smt_name = "bitblast" category = "regular" long = "bitblast=MODE" - type = "CVC4::theory::bv::BitblastMode" - default = "CVC4::theory::bv::BITBLAST_MODE_LAZY" - handler = "stringToBitblastMode" - includes = ["options/bv_bitblast_mode.h"] + type = "BitblastMode" + default = "LAZY" help = "choose bitblasting mode, see --bitblast=help" + help_mode = "Bit-blasting modes." +[[option.mode.LAZY]] + name = "lazy" + help = "Separate boolean structure and term reasoning between the core SAT solver and the bit-vector SAT solver." +[[option.mode.EAGER]] + name = "eager" + help = "Bitblast eagerly to bit-vector SAT solver." [[option]] name = "bitvectorAig" @@ -85,12 +111,20 @@ header = "options/bv_options.h" name = "bitvectorEqualitySlicer" category = "regular" long = "bv-eq-slicer=MODE" - type = "CVC4::theory::bv::BvSlicerMode" - default = "CVC4::theory::bv::BITVECTOR_SLICER_OFF" - handler = "stringToBvSlicerMode" - includes = ["options/bv_bitblast_mode.h"] + type = "BvSlicerMode" + default = "OFF" links = ["--bv-eq-solver"] help = "turn on the slicing equality solver for the bit-vector theory (only if --bitblast=lazy)" + help_mode = "Bit-vector equality slicer modes." +[[option.mode.ON]] + name = "on" + help = "Turn slicer on." +[[option.mode.OFF]] + name = "off" + help = "Turn slicer off." +[[option.mode.AUTO]] + name = "auto" + help = "Turn slicer on if input has only equalities over core symbols." [[option]] name = "bitvectorInequalitySolver" @@ -130,11 +164,19 @@ header = "options/bv_options.h" smt_name = "bool-to-bv" category = "regular" long = "bool-to-bv=MODE" - type = "CVC4::preprocessing::passes::BoolToBVMode" - default = "CVC4::preprocessing::passes::BOOL_TO_BV_OFF" - handler = "stringToBoolToBVMode" - includes = ["options/bool_to_bv_mode.h"] + type = "BoolToBVMode" + default = "OFF" help = "convert booleans to bit-vectors of size 1 at various levels of aggressiveness, see --bool-to-bv=help" + help_mode = "BoolToBV preprocessing pass modes." +[[option.mode.OFF]] + name = "off" + help = "Don't push any booleans to width one bit-vectors." +[[option.mode.ITE]] + name = "ite" + help = "Try to turn ITEs into BITVECTOR_ITE when possible. It can fail per-formula if not all sub-formulas can be turned to bit-vectors." +[[option.mode.ALL]] + name = "all" + help = "Force all booleans to be bit-vectors of width one except at the top level. Most aggressive mode." [[option]] name = "bitwiseEq" diff --git a/src/options/datatypes_modes.h b/src/options/datatypes_modes.h deleted file mode 100644 index 8d7ced9e2..000000000 --- a/src/options/datatypes_modes.h +++ /dev/null @@ -1,44 +0,0 @@ -/********************* */ -/*! \file datatypes_modes.h - ** \verbatim - ** Top contributors (to current version): - ** Andrew Reynolds - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "cvc4_public.h" - -#ifndef CVC4__BASE__DATATYPES_MODES_H -#define CVC4__BASE__DATATYPES_MODES_H - -#include - -namespace CVC4 { -namespace theory { - -enum SygusFairMode { - /** enforce fairness by direct conflict lemmas */ - SYGUS_FAIR_DIRECT, - /** enforce fairness by datatypes size */ - SYGUS_FAIR_DT_SIZE, - /** enforce fairness by datatypes height bound */ - SYGUS_FAIR_DT_HEIGHT_PRED, - /** enforce fairness by datatypes size bound */ - SYGUS_FAIR_DT_SIZE_PRED, - /** do not use fair strategy for CEGQI */ - SYGUS_FAIR_NONE, -}; - -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* CVC4__BASE__DATATYPES_MODES_H */ diff --git a/src/options/datatypes_options.toml b/src/options/datatypes_options.toml index 67829e033..7eb9d30c5 100644 --- a/src/options/datatypes_options.toml +++ b/src/options/datatypes_options.toml @@ -151,12 +151,26 @@ header = "options/datatypes_options.h" name = "sygusFair" category = "regular" long = "sygus-fair=MODE" - type = "CVC4::theory::SygusFairMode" - default = "CVC4::theory::SYGUS_FAIR_DT_SIZE" - handler = "stringToSygusFairMode" - includes = ["options/datatypes_modes.h"] + type = "SygusFairMode" + default = "DT_SIZE" read_only = true help = "if and how to apply fairness for sygus" + help_mode = "Modes for enforcing fairness for counterexample guided quantifier instantion." +[[option.mode.DIRECT]] + name = "direct" + help = "Enforce fairness using direct conflict lemmas." +[[option.mode.DT_SIZE]] + name = "dt-size" + help = "Enforce fairness using size operator." +[[option.mode.DT_HEIGHT_PRED]] + name = "dt-height-bound" + help = "Enforce fairness by height bound predicate." +[[option.mode.DT_SIZE_PRED]] + name = "dt-size-bound" + help = "Enforce fairness by size bound predicate." +[[option.mode.NONE]] + name = "none" + help = "Do not enforce fairness." [[option]] name = "sygusFairMax" diff --git a/src/options/decision_mode.cpp b/src/options/decision_mode.cpp deleted file mode 100644 index f2c37f52a..000000000 --- a/src/options/decision_mode.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/********************* */ -/*! \file decision_mode.cpp - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "options/decision_mode.h" - -#include - -namespace CVC4 { - -std::ostream& operator<<(std::ostream& out, decision::DecisionMode mode) { - switch(mode) { - case decision::DECISION_STRATEGY_INTERNAL: - out << "DECISION_STRATEGY_INTERNAL"; - break; - case decision::DECISION_STRATEGY_JUSTIFICATION: - out << "DECISION_STRATEGY_JUSTIFICATION"; - break; - default: - out << "DecisionMode:UNKNOWN![" << unsigned(mode) << "]"; - } - - return out; -} - -}/* CVC4 namespace */ diff --git a/src/options/decision_mode.h b/src/options/decision_mode.h deleted file mode 100644 index c90e0a6f0..000000000 --- a/src/options/decision_mode.h +++ /dev/null @@ -1,64 +0,0 @@ -/********************* */ -/*! \file decision_mode.h - ** \verbatim - ** Top contributors (to current version): - ** Kshitij Bansal, Morgan Deters, Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "cvc4_private.h" - -#ifndef CVC4__SMT__DECISION_MODE_H -#define CVC4__SMT__DECISION_MODE_H - -#include - -namespace CVC4 { -namespace decision { - -/** Enumeration of decision strategies */ -enum DecisionMode { - - /** - * Decision engine doesn't do anything. Use sat solver's internal - * heuristics - */ - DECISION_STRATEGY_INTERNAL, - - /** - * Use the justification heuristic - */ - DECISION_STRATEGY_JUSTIFICATION, - - /** - * Use may-relevancy. - */ - DECISION_STRATEGY_RELEVANCY - -};/* enum DecisionMode */ - - -/** Enumeration of combining functions for computing internal weights */ -enum DecisionWeightInternal { - DECISION_WEIGHT_INTERNAL_OFF, - DECISION_WEIGHT_INTERNAL_MAX, - DECISION_WEIGHT_INTERNAL_SUM, - DECISION_WEIGHT_INTERNAL_USR1 -};/* enum DecisionInternalWeight */ - -}/* CVC4::decision namespace */ - -std::ostream& operator<<(std::ostream& out, decision::DecisionMode mode); - -}/* CVC4 namespace */ - -#endif /* CVC4__SMT__DECISION_MODE_H */ diff --git a/src/options/decision_options.toml b/src/options/decision_options.toml index 5826368c8..c614ab3db 100644 --- a/src/options/decision_options.toml +++ b/src/options/decision_options.toml @@ -7,11 +7,20 @@ header = "options/decision_options.h" smt_name = "decision-mode" category = "regular" long = "decision=MODE" - type = "decision::DecisionMode" - default = "decision::DECISION_STRATEGY_INTERNAL" - handler = "stringToDecisionMode" - includes = ["options/decision_mode.h"] + type = "DecisionMode" + default = "INTERNAL" + predicates = ["setDecisionModeStopOnly"] help = "choose decision mode, see --decision=help" + help_mode = "Decision modes." +[[option.mode.INTERNAL]] + name = "internal" + help = "Use the internal decision heuristics of the SAT solver." +[[option.mode.JUSTIFICATION]] + name = "justification" + help = "An ATGP-inspired justification heuristic." +[[option.mode.RELEVANCY]] + name = "justification-stoponly" + help = "Use the justification heuristic only to stop early, not for decisions." [[option]] name = "decisionStopOnly" @@ -37,6 +46,7 @@ header = "options/decision_options.h" read_only = true help = "use the weight nodes (locally, by looking at children) to direct recursive search" + [[option]] name = "decisionRandomWeight" category = "expert" @@ -50,8 +60,16 @@ header = "options/decision_options.h" name = "decisionWeightInternal" category = "expert" long = "decision-weight-internal=HOW" - type = "decision::DecisionWeightInternal" - default = "decision::DECISION_WEIGHT_INTERNAL_OFF" - handler = "stringToDecisionWeightInternal" + type = "DecisionWeightInternal" + default = "OFF" read_only = true - help = "computer weights of internal nodes using children: off, max, sum, usr1 (meaning evolving)" + help = "compute weights of internal nodes using children: off, max, sum, usr1" + help_mode = "Decision weight internal mode." +[[option.mode.OFF]] + name = "off" +[[option.mode.MAX]] + name = "max" +[[option.mode.SUM]] + name = "sum" +[[option.mode.USR1]] + name = "usr1" diff --git a/src/options/mkoptions.py b/src/options/mkoptions.py index 8f801466c..0dab2ed76 100755 --- a/src/options/mkoptions.py +++ b/src/options/mkoptions.py @@ -46,16 +46,18 @@ import os import re import sys import textwrap +import toml ### Allowed attributes for module/option/alias MODULE_ATTR_REQ = ['id', 'name', 'header'] -MODULE_ATTR_ALL = MODULE_ATTR_REQ + ['options', 'aliases'] +MODULE_ATTR_ALL = MODULE_ATTR_REQ + ['option', 'alias'] OPTION_ATTR_REQ = ['category', 'type'] OPTION_ATTR_ALL = OPTION_ATTR_REQ + [ - 'name', 'help', 'smt_name', 'short', 'long', 'default', 'includes', - 'handler', 'predicates', 'notifies', 'links', 'read_only', 'alternate' + 'name', 'help', 'help_mode', 'smt_name', 'short', 'long', 'default', + 'includes', 'handler', 'predicates', 'notifies', 'links', 'read_only', + 'alternate', 'mode' ] ALIAS_ATTR_REQ = ['category', 'long', 'links'] @@ -226,6 +228,64 @@ TPL_IMPL_OPTION_WAS_SET_BY_USER = \ return Options::current()->wasSetByUser(*this); }}""" +# Mode templates +TPL_DECL_MODE_ENUM = \ +""" +enum class {type} +{{ + {values} +}};""" + +TPL_DECL_MODE_FUNC = \ +""" +std::ostream& +operator<<(std::ostream& out, {type} mode) CVC4_PUBLIC;""" + +TPL_IMPL_MODE_FUNC = TPL_DECL_MODE_FUNC[:-len(" CVC4_PUBLIC;")] + \ +""" +{{ + out << "{type}::"; + switch(mode) {{{cases} + default: + Unreachable(); + }} + return out; +}} +""" + +TPL_IMPL_MODE_CASE = \ +""" + case {type}::{enum}: + out << "{enum}"; + break;""" + +TPL_DECL_MODE_HANDLER = \ +""" +{type} +stringTo{type}(const std::string& option, const std::string& optarg);""" + +TPL_IMPL_MODE_HANDLER = TPL_DECL_MODE_HANDLER[:-1] + \ +""" +{{ + {cases} + else if (optarg == "help") + {{ + puts({help}); + exit(1); + }} + else + {{ + throw OptionException(std::string("unknown option for --{long}: `") + + optarg + "'. Try --{long}=help."); + }} +}} +""" + +TPL_MODE_HANDLER_CASE = \ +"""if (optarg == "{name}") + {{ + return {type}::{enum}; + }}""" class Module(object): @@ -258,7 +318,6 @@ class Option(object): self.links = [] self.read_only = False self.alternate = True # add --no- alternative long option for bool - self.lineno = None self.filename = None for (attr, val) in d.items(): assert attr in self.__dict__ @@ -275,7 +334,6 @@ class Alias(object): def __init__(self, d): self.__dict__ = dict((k, None) for k in ALIAS_ATTR_ALL) self.links = [] - self.lineno = None self.filename = None self.alternate_for = None # replaces a --no- alternative for an option for (attr, val) in d.items(): @@ -288,8 +346,19 @@ def die(msg): sys.exit('[error] {}'.format(msg)) -def perr(filename, lineno, msg): - die('parse error in {}:{}: {}'.format(filename, lineno + 1, msg)) +def perr(filename, msg, option_or_alias = None): + msg_suffix = '' + if option_or_alias: + if isinstance(option_or_alias, Option): + msg_suffix = 'option ' + if option_or_alias.name: + msg_suffix = "{} '{}' ".format(msg_suffix, option_or_alias.name) + else: + msg_suffix = "{} '{}' ".format(msg_suffix, option_or_alias.long) + else: + assert isinstance(option_or_alias, Alias) + msg_suffix = "alias '{}' ".format(option_or_alias.long) + die('parse error in {}: {}{}'.format(filename, msg, msg_suffix)) def write_file(directory, name, content): @@ -437,6 +506,29 @@ def help_format(help_msg, opts): lines.extend([' ' * width_opt + l for l in text[1:]]) return ['"{}\\n"'.format(x) for x in lines] +def help_mode_format(option): + """ + Format help message for mode options. + """ + assert option.help_mode + assert option.mode + + wrapper = textwrap.TextWrapper(width=78, break_on_hyphens=False) + text = ['{}'.format(x) for x in wrapper.wrap(option.help_mode)] + text.append('Available modes for --{} are:'.format(option.long.split('=')[0])) + + for value, attrib in option.mode.items(): + assert len(attrib) == 1 + attrib = attrib[0] + if value == option.default and attrib['name'] != "default": + text.append('+ {} (default)'.format(attrib['name'])) + else: + text.append('+ {}'.format(attrib['name'])) + if 'help' in attrib: + text.extend(' {}'.format(x) for x in wrapper.wrap(attrib['help'])) + + return '\n '.join('"{}\\n"'.format(x) for x in text) + def codegen_module(module, dst_dir, tpl_module_h, tpl_module_cpp): """ @@ -450,6 +542,8 @@ def codegen_module(module, dst_dir, tpl_module_h, tpl_module_cpp): decls = [] specs = [] inls = [] + mode_decl = [] + mode_impl = [] # *_options_.cpp accs = [] @@ -512,6 +606,38 @@ def codegen_module(module, dst_dir, tpl_module_h, tpl_module_cpp): # Global definitions defs.append('struct {name}__option_t {name};'.format(name=option.name)) + if option.mode: + values = option.mode.keys() + mode_decl.append( + TPL_DECL_MODE_ENUM.format( + type=option.type, + values=',\n '.join(values))) + mode_decl.append(TPL_DECL_MODE_FUNC.format(type=option.type)) + cases = [TPL_IMPL_MODE_CASE.format( + type=option.type, enum=x) for x in values] + mode_impl.append( + TPL_IMPL_MODE_FUNC.format( + type=option.type, + cases=''.join(cases))) + + # Generate str-to-enum handler + cases = [] + for value, attrib in option.mode.items(): + assert len(attrib) == 1 + cases.append( + TPL_MODE_HANDLER_CASE.format( + name=attrib[0]['name'], + type=option.type, + enum=value)) + assert option.long + assert cases + mode_decl.append(TPL_DECL_MODE_HANDLER.format(type=option.type)) + mode_impl.append( + TPL_IMPL_MODE_HANDLER.format( + type=option.type, + cases='\n else '.join(cases), + help=help_mode_format(option), + long=option.long.split('=')[0])) filename = os.path.splitext(os.path.split(module.header)[1])[0] write_file(dst_dir, '{}.h'.format(filename), tpl_module_h.format( @@ -522,14 +648,14 @@ def codegen_module(module, dst_dir, tpl_module_h, tpl_module_cpp): holder_spec=' \\\n'.join(holder_specs), decls='\n'.join(decls), specs='\n'.join(specs), - inls='\n'.join(inls) - )) + inls='\n'.join(inls), + modes=''.join(mode_decl))) write_file(dst_dir, '{}.cpp'.format(filename), tpl_module_cpp.format( filename=filename, accs='\n'.join(accs), - defs='\n'.join(defs) - )) + defs='\n'.join(defs), + modes=''.join(mode_impl))) def docgen(category, name, smt_name, short_name, long_name, ctype, default, @@ -676,7 +802,6 @@ def codegen_all_modules(modules, dst_dir, tpl_options, tpl_options_holder, '.TP\n.I "{} OPTIONS"'.format(module.name.upper())) man_others_int.append(man_others_smt[-1]) - for option in \ sorted(module.options, key=lambda x: x.long if x.long else x.name): assert option.type != 'void' or option.name is None @@ -696,6 +821,8 @@ def codegen_all_modules(modules, dst_dir, tpl_options, tpl_options_holder, else: handler = \ 'handler->{}(option, optionarg)'.format(option.handler) + elif option.mode: + handler = 'stringTo{}(option, optionarg)'.format(option.type) elif option.type != 'bool': handler = \ 'handleOption<{}>(option, optionarg)'.format(option.type) @@ -907,6 +1034,9 @@ def codegen_all_modules(modules, dst_dir, tpl_options, tpl_options_holder, # Default option values default = option.default if option.default else '' + # Prepend enum name + if option.mode and option.type not in default: + default = '{}::{}'.format(option.type, default) defaults.append('{}({})'.format(option.name, default)) defaults.append('{}__setByUser__(false)'.format(option.name)) @@ -1005,7 +1135,7 @@ def rstrip(suffix, s): return s[:-len(suffix)] if s.endswith(suffix) else s -def check_attribs(filename, lineno, req_attribs, valid_attribs, attribs, ctype): +def check_attribs(filename, req_attribs, valid_attribs, attribs, ctype): """ Check if for a given module/option/alias the defined attributes are valid and if all required attributes are defined. @@ -1013,30 +1143,32 @@ def check_attribs(filename, lineno, req_attribs, valid_attribs, attribs, ctype): msg_for = "" if 'name' in attribs: msg_for = " for '{}'".format(attribs['name']) + elif 'long' in attribs: + msg_for = " for '{}'".format(attribs['long']) for k in req_attribs: if k not in attribs: - perr(filename, lineno, + perr(filename, "required {} attribute '{}' not specified{}".format( ctype, k, msg_for)) for k in attribs: if k not in valid_attribs: - perr(filename, lineno, + perr(filename, "invalid {} attribute '{}' specified{}".format( ctype, k, msg_for)) -def check_unique(filename, lineno, value, cache): +def check_unique(filename, value, cache): """ Check if given name is unique in cache. """ if value in cache: - perr(filename, lineno, - "'{}' already defined in '{}' at line {}".format( - value, cache[value][0], cache[value][1])) - cache[value] = (filename, lineno + 1) + perr(filename, + "'{}' already defined in '{}'".format(value, cache[value])) + else: + cache[value] = filename -def check_long(filename, lineno, long_name, ctype=None): +def check_long(filename, option_or_alias, long_name, ctype=None): """ Check if given long option name is valid. """ @@ -1044,189 +1176,37 @@ def check_long(filename, lineno, long_name, ctype=None): if long_name is None: return if long_name.startswith('--'): - perr(filename, lineno, 'remove -- prefix from long option') + perr(filename, 'remove -- prefix from long', option_or_alias) r = r'^[0-9a-zA-Z\-=]+$' if not re.match(r, long_name): - perr(filename, lineno, - "long option '{}' does not match regex criteria '{}'".format( - long_name, r)) + perr(filename, + "long '{}' does not match regex criteria '{}'".format( + long_name, r), option_or_alias) name = long_get_option(long_name) - check_unique(filename, lineno, name, g_long_cache) + check_unique(filename, name, g_long_cache) if ctype == 'bool': - check_unique(filename, lineno, 'no-{}'.format(name), g_long_cache) - + check_unique(filename, 'no-{}'.format(name), g_long_cache) -def check_links(filename, lineno, links): +def check_links(filename, option_or_alias): """ Check if long options defined in links are valid and correctly used. """ global g_long_cache, g_long_arguments - for link in links: + for link in option_or_alias.links: long_name = lstrip('no-', lstrip('--', long_get_option(link))) if long_name not in g_long_cache: - perr(filename, lineno, - "invalid long option '{}' in links list".format(link)) + perr(filename, + "invalid long option '{}' in links list".format(link), + option_or_alias) # check if long option requires an argument if long_name in g_long_arguments and '=' not in link: - perr(filename, lineno, - "linked option '{}' requires an argument".format(link)) - - -def check_alias_attrib(filename, lineno, attrib, value): - """ - Check alias attribute values. All attribute checks that can be done while - parsing should be done here. - """ - if attrib not in ALIAS_ATTR_ALL: - perr(filename, lineno, "invalid alias attribute '{}'".format(attrib)) - if attrib == 'category': - if value not in CATEGORY_VALUES: - perr(filename, lineno, "invalid category value '{}'".format(value)) - elif attrib == 'long': - pass # Will be checked after parsing is done - elif attrib == 'links': - assert isinstance(value, list) - if not value: - perr(filename, lineno, 'links list must not be empty') - - -def check_option_attrib(filename, lineno, attrib, value): - """ - Check option attribute values. All attribute checks that can be done while - parsing should be done here. - """ - global g_smt_cache, g_name_cache, g_short_cache - - if attrib not in OPTION_ATTR_ALL: - perr(filename, lineno, "invalid option attribute '{}'".format(attrib)) - - if attrib == 'category': - if value not in CATEGORY_VALUES: - perr(filename, lineno, "invalid category value '{}'".format(value)) - elif attrib == 'type': - if not value: - perr(filename, lineno, 'type must not be empty') - elif attrib == 'long': - pass # Will be checked after parsing is done - elif attrib == 'name' and value: - r = r'^[a-zA-Z]+[0-9a-zA-Z_]*$' - if not re.match(r, value): - perr(filename, lineno, - "name '{}' does not match regex criteria '{}'".format( - value, r)) - check_unique(filename, lineno, value, g_name_cache) - elif attrib == 'smt_name' and value: - r = r'^[a-zA-Z]+[0-9a-zA-Z\-_]*$' - if not re.match(r, value): - perr(filename, lineno, - "smt_name '{}' does not match regex criteria '{}'".format( - value, r)) - check_unique(filename, lineno, value, g_smt_cache) - elif attrib == 'short' and value: - if value[0].startswith('-'): - perr(filename, lineno, 'remove - prefix from short option') - if len(value) != 1: - perr(filename, lineno, 'short option must be of length 1') - if not value.isalpha() and not value.isdigit(): - perr(filename, lineno, 'short option must be a character or a digit') - check_unique(filename, lineno, value, g_short_cache) - elif attrib == 'default': - pass - elif attrib == 'includes' and value: - if not isinstance(value, list): - perr(filename, lineno, 'expected list for includes attribute') - elif attrib == 'handler': - pass - elif attrib == 'predicates' and value: - if not isinstance(value, list): - perr(filename, lineno, 'expected list for predicates attribute') - elif attrib == 'notifies' and value: - if not isinstance(value, list): - perr(filename, lineno, 'expected list for notifies attribute') - elif attrib == 'links' and value: - if not isinstance(value, list): - perr(filename, lineno, 'expected list for links attribute') - elif attrib in ['read_only', 'alternate'] and value is not None: - if not isinstance(value, bool): - perr(filename, lineno, - "expected true/false instead of '{}' for {}".format( - value, attrib)) - - -def check_module_attrib(filename, lineno, attrib, value): - """ - Check module attribute values. All attribute checks that can be done while - parsing should be done here. - """ - global g_module_id_cache - if attrib not in MODULE_ATTR_ALL: - perr(filename, lineno, "invalid module attribute '{}'".format(attrib)) - if attrib == 'id': - if not value: - perr(filename, lineno, 'module id must not be empty') - if value in g_module_id_cache: - perr(filename, lineno, - "module id '{}' already defined in '{}' at line {}".format( - value, - g_module_id_cache[value][0], - g_module_id_cache[value][1])) - g_module_id_cache[value] = (filename, lineno) - r = r'^[A-Z]+[A-Z_]*$' - if not re.match(r, value): - perr(filename, lineno, - "module id '{}' does not match regex criteria '{}'".format( - value, r)) - elif attrib == 'name': - if not value: - perr(filename, lineno, 'module name must not be empty') - elif attrib == 'header': - if not value: - perr(filename, lineno, 'module header must not be empty') - header_name = \ - 'options/{}.h'.format(rstrip('.toml', os.path.basename(filename))) - if header_name != value: - perr(filename, lineno, - "expected module header '{}' instead of '{}'".format( - header_name, value)) - - -def parse_value(filename, lineno, attrib, val): - """ - Parse attribute values. - We only allow three types of values: - - bool (val either true/false or "true"/"false") - - string (val starting with ") - - lists (val starting with [) - """ - if val[0] == '"': - if val[-1] != '"': - perr(filename, lineno, 'missing closing " for string') - val = val.lstrip('"').rstrip('"').replace('\\"', '"') - - # for read_only/alternate we allow both true/false and "true"/"false" - if attrib in ['read_only', 'alternate']: - if val == 'true': - return True - elif val == 'false': - return False - return val if val else None - elif val[0] == '[': - try: - val_list = ast.literal_eval(val) - except SyntaxError as e: - perr(filename, lineno, 'parsing list: {}'.format(e.msg)) - return val_list - elif val == 'true': - return True - elif val == 'false': - return False - else: - perr(filename, lineno, "invalid value '{}'".format(val)) - return None + perr(filename, + "linked option '{}' requires an argument".format(link), + option_or_alias) -def parse_module(filename, file): +def parse_module(filename, module): """ Parse options module file. @@ -1235,122 +1215,51 @@ def parse_module(filename, file): toml format, we chose to implement our own parser to get better error messages. """ - module = dict() - options = [] - aliases = [] - lines = [[x.strip() for x in line.split('=', 1)] for line in file] - option = None - alias = None - option_lines = [] - alias_lines = [] - for i in range(len(lines)): - assert option is None or alias is None - line = lines[i] - # Skip comments - if line[0].startswith('#'): - continue - # Check if a new option/alias starts. - if len(line) == 1: - # Create a new option/alias object, save previously created - if line[0] in ['[[option]]', '[[alias]]']: - if option: - options.append(option) - option = None - if alias: - aliases.append(alias) - alias = None - # Create new option dict and save line number where option - # was defined. - if line[0] == '[[option]]': - assert alias is None - option = dict() - option_lines.append(i) - else: - # Create new alias dict and save line number where alias - # was defined. - assert line[0] == '[[alias]]' - assert option is None - alias = dict() - # Save line number where alias was defined - alias_lines.append(i) - elif line[0] != '': - perr(filename, i, "invalid attribute '{}'".format(line[0])) - # Parse module/option/alias attributes. - elif len(line) == 2: - attrib = line[0] - value = parse_value(filename, i, attrib, line[1]) - # All attributes we parse are part of the current option. - if option is not None: - check_option_attrib(filename, i, attrib, value) - if attrib in option: - perr(filename, i, - "duplicate option attribute '{}'".format(attrib)) - assert option is not None - option[attrib] = value - # All attributes we parse are part of the current alias. - elif alias is not None: - check_alias_attrib(filename, i, attrib, value) - if attrib in alias: - perr(filename, i, - "duplicate alias attribute '{}'".format(attrib)) - assert alias is not None - alias[attrib] = value - # All other attributes are part of the module. - else: - if attrib in module: - perr(filename, i, - "duplicate module attribute '{}'".format(attrib)) - check_module_attrib(filename, i, attrib, value) - module[attrib] = value - else: - perr(filename, i, "invalid attribute '{}'".format(line[0])) - - # Save previously parsed option/alias - if option: - options.append(option) - if alias: - aliases.append(alias) - # Check if parsed module attributes are valid and if all required # attributes are defined. - check_attribs(filename, 1, + check_attribs(filename, MODULE_ATTR_REQ, MODULE_ATTR_ALL, module, 'module') res = Module(module) - # Check parsed option/alias attributes and create option/alias objects and - # associate file name and line number with options/aliases (required for - # better error reporting). - assert len(option_lines) == len(options) - assert len(alias_lines) == len(aliases) - for i in range(len(options)): - attribs = options[i] - lineno = option_lines[i] - check_attribs(filename, lineno, - OPTION_ATTR_REQ, OPTION_ATTR_ALL, attribs, 'option') - option = Option(attribs) - if option.short and not option.long: - perr(filename, lineno, - "short option '{}' specified but no long option".format( - option.short)) - if option.type == 'bool' and option.handler: - perr(filename, lineno, - 'specifying handlers for options of type bool is not allowed') - if option.category != 'undocumented' and not option.help: - perr(filename, lineno, - 'help text is required for {} options'.format(option.category)) - option.lineno = lineno - option.filename = filename - res.options.append(option) - - for i in range(len(aliases)): - attribs = aliases[i] - lineno = alias_lines[i] - check_attribs(filename, lineno, - ALIAS_ATTR_REQ, ALIAS_ATTR_ALL, attribs, 'alias') - alias = Alias(attribs) - alias.lineno = lineno - alias.filename = filename - res.aliases.append(alias) + if 'option' in module: + for attribs in module['option']: + lineno = 0 + check_attribs(filename, + OPTION_ATTR_REQ, OPTION_ATTR_ALL, attribs, 'option') + option = Option(attribs) + if option.mode and not option.help_mode: + perr(filename, 'defines modes but no help_mode', option) + if option.mode and option.handler: + perr(filename, 'defines modes and a handler', option) + if option.mode and option.default and \ + option.default not in option.mode.keys(): + perr(filename, + "invalid default value '{}'".format(option.default), + option) + if option.short and not option.long: + perr(filename, + "short option '{}' specified but no long option".format( + option.short), + option) + if option.type == 'bool' and option.handler: + perr(filename, + 'defining handlers for bool options is not allowed', + option) + if option.category != 'undocumented' and not option.help: + perr(filename, + 'help text required for {} options'.format(option.category), + option) + option.filename = filename + res.options.append(option) + + if 'alias' in module: + for attribs in module['alias']: + lineno = 0 + check_attribs(filename, + ALIAS_ATTR_REQ, ALIAS_ATTR_ALL, attribs, 'alias') + alias = Alias(attribs) + alias.filename = filename + res.aliases.append(alias) return res @@ -1400,20 +1309,19 @@ def mkoptions_main(): # Parse files, check attributes and create module/option objects modules = [] for filename in filenames: - with open(filename, 'r') as file: - module = parse_module(filename, file) - # Check if long options are valid and unique. First populate - # g_long_cache with option.long and --no- alternatives if - # applicable. - for option in module.options: - check_long(option.filename, option.lineno, option.long, - option.type) - if option.long: - g_long_to_opt[long_get_option(option.long)] = option - # Add long option that requires an argument - if option.type not in ['bool', 'void']: - g_long_arguments.add(long_get_option(option.long)) - modules.append(module) + module = parse_module(filename, toml.load(filename)) + + # Check if long options are valid and unique. First populate + # g_long_cache with option.long and --no- alternatives if + # applicable. + for option in module.options: + check_long(filename, option, option.long, option.type) + if option.long: + g_long_to_opt[long_get_option(option.long)] = option + # Add long option that requires an argument + if option.type not in ['bool', 'void']: + g_long_arguments.add(long_get_option(option.long)) + modules.append(module) # Check if alias.long is unique and check if alias.long defines an alias # for an alternate (--no-) option for existing option . @@ -1428,7 +1336,7 @@ def mkoptions_main(): m[0].alternate = False alias.alternate_for = m[0] del g_long_cache[alias.long] - check_long(alias.filename, alias.lineno, alias.long) + check_long(alias.filename, alias, alias.long) # Add long option that requires an argument if '=' in alias.long: g_long_arguments.add(long_get_option(alias.long)) @@ -1437,9 +1345,9 @@ def mkoptions_main(): # long options are available). for module in modules: for option in module.options: - check_links(option.filename, option.lineno, option.links) + check_links(option.filename, option) for alias in module.aliases: - check_links(alias.filename, alias.lineno, alias.links) + check_links(alias.filename, alias) # Create *_options.{h,cpp} in destination directory for module in modules: diff --git a/src/options/module_template.cpp b/src/options/module_template.cpp index 46162845d..9ac94477c 100644 --- a/src/options/module_template.cpp +++ b/src/options/module_template.cpp @@ -16,6 +16,7 @@ **/ #include "options/options_holder.h" +#include "base/check.h" namespace CVC4 { @@ -26,6 +27,7 @@ namespace options { ${defs}$ +${modes}$ } // namespace options } // namespace CVC4 diff --git a/src/options/module_template.h b/src/options/module_template.h index 2ffe070d2..e3eb30fe1 100644 --- a/src/options/module_template.h +++ b/src/options/module_template.h @@ -32,8 +32,9 @@ namespace CVC4 { namespace options { -${decls}$ +${modes}$ +${decls}$ } // namespace options @@ -44,7 +45,6 @@ namespace options { ${inls}$ - } // namespace options } // namespace CVC4 diff --git a/src/options/options.h b/src/options/options.h index c321b3499..1493ceac9 100644 --- a/src/options/options.h +++ b/src/options/options.h @@ -195,7 +195,7 @@ public: // Get accessor functions. InputLanguage getInputLanguage() const; - InstFormatMode getInstFormatMode() const; + options::InstFormatMode getInstFormatMode() const; OutputLanguage getOutputLanguage() const; bool getUfHo() const; bool getCheckProofs() const; diff --git a/src/options/options.i b/src/options/options.i index 25eecaf2d..ba98c4fc4 100644 --- a/src/options/options.i +++ b/src/options/options.i @@ -2,9 +2,6 @@ #include "options/options.h" %} -%ignore CVC4::operator<<(std::ostream&, SimplificationMode); -%ignore CVC4::operator<<(std::ostream&, ArithPivotRule); - %apply char** STRING_ARRAY { char* argv[] } %include "options/options.h" %clear char* argv[]; diff --git a/src/options/options_handler.cpp b/src/options/options_handler.cpp index 35827d3b0..c99b0c7b5 100644 --- a/src/options/options_handler.cpp +++ b/src/options/options_handler.cpp @@ -29,23 +29,14 @@ #include "base/modal_exception.h" #include "base/output.h" #include "lib/strtok_r.h" -#include "options/arith_heuristic_pivot_rule.h" -#include "options/arith_propagation_mode.h" -#include "options/arith_unate_lemma_mode.h" #include "options/base_options.h" -#include "options/bv_bitblast_mode.h" #include "options/bv_options.h" -#include "options/datatypes_modes.h" -#include "options/decision_mode.h" #include "options/decision_options.h" #include "options/didyoumean.h" #include "options/language.h" #include "options/option_exception.h" -#include "options/printer_modes.h" #include "options/smt_options.h" #include "options/theory_options.h" -#include "options/theoryof_mode.h" -#include "options/ufss_mode.h" namespace CVC4 { namespace options { @@ -53,16 +44,16 @@ namespace options { // helper functions namespace { -void throwLazyBBUnsupported(theory::bv::SatSolverMode m) +void throwLazyBBUnsupported(options::SatSolverMode m) { std::string sat_solver; - if (m == theory::bv::SAT_SOLVER_CADICAL) + if (m == options::SatSolverMode::CADICAL) { sat_solver = "CaDiCaL"; } else { - Assert(m == theory::bv::SAT_SOLVER_CRYPTOMINISAT); + Assert(m == options::SatSolverMode::CRYPTOMINISAT); sat_solver = "CryptoMiniSat"; } std::string indent(25, ' '); @@ -120,1130 +111,14 @@ void OptionsHandler::notifyPrintSuccess(std::string option) { d_options->d_setPrintSuccessListeners.notify(); } -// theory/arith/options_handlers.h -const std::string OptionsHandler::s_arithUnateLemmasHelp = "\ -Unate lemmas are generated before SAT search begins using the relationship\n\ -of constant terms and polynomials.\n\ -Modes currently supported by the --unate-lemmas option:\n\ -+ none \n\ -+ ineqs \n\ - Outputs lemmas of the general form (<= p c) implies (<= p d) for c < d.\n\ -+ eqs \n\ - Outputs lemmas of the general forms\n\ - (= p c) implies (<= p d) for c < d, or\n\ - (= p c) implies (not (= p d)) for c != d.\n\ -+ all \n\ - A combination of inequalities and equalities.\n\ -"; - -const std::string OptionsHandler::s_arithPropagationModeHelp = "\ -This decides on kind of propagation arithmetic attempts to do during the search.\n\ -+ none\n\ -+ unate\n\ - use constraints to do unate propagation\n\ -+ bi (Bounds Inference)\n\ - infers bounds on basic variables using the upper and lower bounds of the\n\ - non-basic variables in the tableau.\n\ -+both\n\ -"; - -const std::string OptionsHandler::s_errorSelectionRulesHelp = "\ -This decides on the rule used by simplex during heuristic rounds\n\ -for deciding the next basic variable to select.\n\ -Heuristic pivot rules available:\n\ -+min\n\ - The minimum abs() value of the variable's violation of its bound. (default)\n\ -+max\n\ - The maximum violation the bound\n\ -+varord\n\ - The variable order\n\ -"; - -ArithUnateLemmaMode OptionsHandler::stringToArithUnateLemmaMode( - std::string option, std::string optarg) -{ - if(optarg == "all") { - return ALL_PRESOLVE_LEMMAS; - } else if(optarg == "none") { - return NO_PRESOLVE_LEMMAS; - } else if(optarg == "ineqs") { - return INEQUALITY_PRESOLVE_LEMMAS; - } else if(optarg == "eqs") { - return EQUALITY_PRESOLVE_LEMMAS; - } else if(optarg == "help") { - puts(s_arithUnateLemmasHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --unate-lemmas: `") + - optarg + "'. Try --unate-lemmas help."); - } -} - -ArithPropagationMode OptionsHandler::stringToArithPropagationMode( - std::string option, std::string optarg) -{ - if(optarg == "none") { - return NO_PROP; - } else if(optarg == "unate") { - return UNATE_PROP; - } else if(optarg == "bi") { - return BOUND_INFERENCE_PROP; - } else if(optarg == "both") { - return BOTH_PROP; - } else if(optarg == "help") { - puts(s_arithPropagationModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --arith-prop: `") + - optarg + "'. Try --arith-prop help."); - } -} - -ErrorSelectionRule OptionsHandler::stringToErrorSelectionRule( - std::string option, std::string optarg) -{ - if(optarg == "min") { - return MINIMUM_AMOUNT; - } else if(optarg == "varord") { - return VAR_ORDER; - } else if(optarg == "max") { - return MAXIMUM_AMOUNT; - } else if(optarg == "help") { - puts(s_errorSelectionRulesHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --heuristic-pivot-rule: `") + - optarg + "'. Try --heuristic-pivot-rule help."); - } -} // theory/quantifiers/options_handlers.h -const std::string OptionsHandler::s_instWhenHelp = "\ -Instantiation modes currently supported by the --inst-when option:\n\ -\n\ -full-last-call (default)\n\ -+ Alternate running instantiation rounds at full effort and last\n\ - call. In other words, interleave instantiation and theory combination.\n\ -\n\ -full\n\ -+ Run instantiation round at full effort, before theory combination.\n\ -\n\ -full-delay \n\ -+ Run instantiation round at full effort, before theory combination, after\n\ - all other theories have finished.\n\ -\n\ -full-delay-last-call \n\ -+ Alternate running instantiation rounds at full effort after all other\n\ - theories have finished, and last call. \n\ -\n\ -last-call\n\ -+ Run instantiation at last call effort, after theory combination and\n\ - and theories report sat.\n\ -\n\ -"; - -const std::string OptionsHandler::s_literalMatchHelp = "\ -Literal match modes currently supported by the --literal-match option:\n\ -\n\ -none \n\ -+ Do not use literal matching.\n\ -\n\ -use (default)\n\ -+ Consider phase requirements of triggers conservatively. For example, the\n\ - trigger P( x ) in forall( x ). ( P( x ) V ~Q( x ) ) will not be matched with\n\ - terms in the equivalence class of true, and likewise Q( x ) will not be matched\n\ - terms in the equivalence class of false. Extends to equality.\n\ -\n\ -agg-predicate \n\ -+ Consider phase requirements aggressively for predicates. In the above example,\n\ - only match P( x ) with terms that are in the equivalence class of false.\n\ -\n\ -agg \n\ -+ Consider the phase requirements aggressively for all triggers.\n\ -\n\ -"; - -const std::string OptionsHandler::s_mbqiModeHelp = - "\ -Model-based quantifier instantiation modes currently supported by the --mbqi option:\n\ -\n\ -default \n\ -+ Use algorithm from Section 5.4.2 of thesis Finite Model Finding in Satisfiability \n\ - Modulo Theories.\n\ -\n\ -none \n\ -+ Disable model-based quantifier instantiation.\n\ -\n\ -trust \n\ -+ Do not instantiate quantified formulas (incomplete technique).\n\ -\n\ -"; - -const std::string OptionsHandler::s_qcfWhenModeHelp = "\ -Quantifier conflict find modes currently supported by the --quant-cf-when option:\n\ -\n\ -default \n\ -+ Default, apply conflict finding at full effort.\n\ -\n\ -last-call \n\ -+ Apply conflict finding at last call, after theory combination and \n\ - and all theories report sat. \n\ -\n\ -std \n\ -+ Apply conflict finding at standard effort.\n\ -\n\ -std-h \n\ -+ Apply conflict finding at standard effort when heuristic says to. \n\ -\n\ -"; - -const std::string OptionsHandler::s_qcfModeHelp = "\ -Quantifier conflict find modes currently supported by the --quant-cf option:\n\ -\n\ -prop-eq \n\ -+ Default, apply QCF algorithm to propagate equalities as well as conflicts. \n\ -\n\ -conflict \n\ -+ Apply QCF algorithm to find conflicts only.\n\ -\n\ -"; - -const std::string OptionsHandler::s_userPatModeHelp = "\ -User pattern modes currently supported by the --user-pat option:\n\ -\n\ -trust \n\ -+ When provided, use only user-provided patterns for a quantified formula.\n\ -\n\ -use \n\ -+ Use both user-provided and auto-generated patterns when patterns\n\ - are provided for a quantified formula.\n\ -\n\ -resort \n\ -+ Use user-provided patterns only after auto-generated patterns saturate.\n\ -\n\ -ignore \n\ -+ Ignore user-provided patterns. \n\ -\n\ -interleave \n\ -+ Alternate between use/resort. \n\ -\n\ -"; - -const std::string OptionsHandler::s_triggerSelModeHelp = "\ -Trigger selection modes currently supported by the --trigger-sel option:\n\ -\n\ -min | default \n\ -+ Consider only minimal subterms that meet criteria for triggers.\n\ -\n\ -max \n\ -+ Consider only maximal subterms that meet criteria for triggers. \n\ -\n\ -all \n\ -+ Consider all subterms that meet criteria for triggers. \n\ -\n\ -min-s-max \n\ -+ Consider only minimal subterms that meet criteria for single triggers, maximal otherwise. \n\ -\n\ -min-s-all \n\ -+ Consider only minimal subterms that meet criteria for single triggers, all otherwise. \n\ -\n\ -"; -const std::string OptionsHandler::s_triggerActiveSelModeHelp = "\ -Trigger active selection modes currently supported by the \ ---trigger-active-sel option:\n\ -\n\ -all \n\ -+ Make all triggers active. \n\ -\n\ -min \n\ -+ Activate triggers with minimal ground terms.\n\ -\n\ -max \n\ -+ Activate triggers with maximal ground terms. \n\ -\n\ -"; -const std::string OptionsHandler::s_prenexQuantModeHelp = "\ -Prenex quantifiers modes currently supported by the --prenex-quant option:\n\ -\n\ -none \n\ -+ Do no prenex nested quantifiers. \n\ -\n\ -default | simple \n\ -+ Default, do simple prenexing of same sign quantifiers.\n\ -\n\ -dnorm \n\ -+ Prenex to disjunctive prenex normal form.\n\ -\n\ -norm \n\ -+ Prenex to prenex normal form.\n\ -\n\ -"; - -const std::string OptionsHandler::s_cegqiFairModeHelp = "\ -Modes for enforcing fairness for counterexample guided quantifier instantion, supported by --sygus-fair:\n\ -\n\ -uf-dt-size \n\ -+ Enforce fairness using an uninterpreted function for datatypes size.\n\ -\n\ -direct \n\ -+ Enforce fairness using direct conflict lemmas.\n\ -\n\ -default | dt-size \n\ -+ Default, enforce fairness using size operator.\n\ -\n\ -dt-height-bound \n\ -+ Enforce fairness by height bound predicate.\n\ -\n\ -none \n\ -+ Do not enforce fairness. \n\ -\n\ -"; - -const std::string OptionsHandler::s_termDbModeHelp = "\ -Modes for terms included in the quantifiers term database, supported by\ ---term-db-mode:\n\ -\n\ -all \n\ -+ Quantifiers module considers all ground terms.\n\ -\n\ -relevant \n\ -+ Quantifiers module considers only ground terms connected to current assertions. \n\ -\n\ -"; - -const std::string OptionsHandler::s_iteLiftQuantHelp = "\ -Modes for term database, supported by --ite-lift-quant:\n\ -\n\ -none \n\ -+ Do not lift if-then-else in quantified formulas.\n\ -\n\ -simple \n\ -+ Lift if-then-else in quantified formulas if results in smaller term size.\n\ -\n\ -all \n\ -+ Lift if-then-else in quantified formulas. \n\ -\n\ -"; - -const std::string OptionsHandler::s_cbqiBvIneqModeHelp = - "\ -Modes for handling bit-vector inequalities in counterexample-guided\ -instantiation, supported by --cbqi-bv-ineq:\n\ -\n\ -eq-slack (default) \n\ -+ Solve for the inequality using the slack value in the model, e.g.,\ - t > s becomes t = s + ( t-s )^M.\n\ -\n\ -eq-boundary \n\ -+ Solve for the boundary point of the inequality, e.g.,\ - t > s becomes t = s+1.\n\ -\n\ -keep \n\ -+ Solve for the inequality directly using side conditions for invertibility.\n\ -\n\ -"; - -const std::string OptionsHandler::s_cegqiSingleInvHelp = "\ -Modes for single invocation techniques, supported by --cegqi-si:\n\ -\n\ -none \n\ -+ Do not use single invocation techniques.\n\ -\n\ -use (default) \n\ -+ Use single invocation techniques only if grammar is not restrictive.\n\ -\n\ -all-abort \n\ -+ Always use single invocation techniques, abort if solution reconstruction will likely fail,\ - for instance, when the grammar does not have ITE and solution requires it.\n\ -\n\ -all \n\ -+ Always use single invocation techniques. \n\ -\n\ -"; - -const std::string OptionsHandler::s_cegqiSingleInvRconsHelp = - "\ -Modes for reconstruction solutions while using single invocation techniques,\ -supported by --cegqi-si-rcons:\n\ -\n\ -none \n\ -+ Do not try to reconstruct solutions in the original (user-provided) grammar\ - when using single invocation techniques. In this mode, solutions produced by\ - CVC4 may violate grammar restrictions.\n\ -\n\ -try \n\ -+ Try to reconstruct solutions in the original grammar when using single\ - invocation techniques in an incomplete (fail-fast) manner.\n\ -\n\ -all-limit \n\ -+ Try to reconstruct solutions in the original grammar, but termintate if a\ - maximum number of rounds for reconstruction is exceeded.\n\ -\n\ -all \n\ -+ Try to reconstruct solutions in the original grammar. In this mode,\ - we do not terminate until a solution is successfully reconstructed. \n\ -\n\ -"; - -const std::string OptionsHandler::s_cegisSampleHelp = - "\ -Modes for sampling with counterexample-guided inductive synthesis (CEGIS),\ -supported by --cegis-sample:\n\ -\n\ -none (default) \n\ -+ Do not use sampling with CEGIS.\n\ -\n\ -use \n\ -+ Use sampling to accelerate CEGIS. This will rule out solutions for a\ - conjecture when they are not satisfied by a sample point.\n\ -\n\ -trust \n\ -+ Trust that when a solution for a conjecture is always true under sampling,\ - then it is indeed a solution. Note this option may print out spurious\ - solutions for synthesis conjectures.\n\ -\n\ -"; - -const std::string OptionsHandler::s_sygusQueryDumpFileHelp = - "\ -Query file options supported by --sygus-query-gen-dump-files:\n\ -\n\ -none (default) \n\ -+ Do not dump query files when using --sygus-query-gen.\n\ -\n\ -all \n\ -+ Dump all query files.\n\ -\n\ -unsolved \n\ -+ Dump query files that the subsolver did not solve.\n\ -\n\ -"; - -const std::string OptionsHandler::s_sygusFilterSolHelp = - "\ -Modes for filtering sygus solutions supported by --sygus-filter-sol:\n\ -\n\ -none (default) \n\ -+ Do not filter sygus solutions.\n\ -\n\ -strong \n\ -+ Filter solutions that are logically stronger than others.\n\ -\n\ -weak \n\ -+ Filter solutions that are logically weaker than others.\n\ -\n\ -"; - -const std::string OptionsHandler::s_sygusInvTemplHelp = "\ -Template modes for sygus invariant synthesis, supported by --sygus-inv-templ:\n\ -\n\ -none \n\ -+ Synthesize invariant directly.\n\ -\n\ -pre \n\ -+ Synthesize invariant based on weakening of precondition .\n\ -\n\ -post \n\ -+ Synthesize invariant based on strengthening of postcondition. \n\ -\n\ -"; - -const std::string OptionsHandler::s_sygusActiveGenHelp = - "\ -Modes for actively-generated sygus enumerators, supported by --sygus-active-gen:\n\ -\n\ -none \n\ -+ Do not use actively-generated sygus enumerators.\n\ -\n\ -basic \n\ -+ Use basic type enumerator for actively-generated sygus enumerators.\n\ -\n\ -enum \n\ -+ Use optimized enumerator for actively-generated sygus enumerators.\n\ -\n\ -var-agnostic \n\ -+ Use sygus solver to enumerate terms that are agnostic to variables. \n\ -\n\ -auto (default) \n\ -+ Internally decide the best policy for each enumerator. \n\ -\n\ -"; - -const std::string OptionsHandler::s_sygusUnifPiHelp = - "\ -Modes for piecewise-independent unification supported by --sygus-unif-pi:\n\ -\n\ -none \n\ -+ Do not use piecewise-independent unification.\n\ -\n\ -complete \n\ -+ Use complete approach for piecewise-independent unification (see Section 3\n\ -of Barbosa et al FMCAD 2019).\n\ -\n\ -cond-enum \n\ -+ Use unconstrained condition enumeration for piecewise-independent\n\ -unification (see Section 4 of Barbosa et al FMCAD 2019).\n\ -\n\ -cond-enum-igain \n\ -+ Same as cond-enum, but additionally uses an information gain heuristic\n\ -when doing decision tree learning.\n\ -\n\ -"; - -const std::string OptionsHandler::s_sygusGrammarConsHelp = - "\ -Modes for default SyGuS grammars, supported by --sygus-grammar-cons:\n\ -\n\ -simple (default) \n\ -+ Use simple grammar construction (no symbolic terms or constants).\n\ -\n\ -any-const \n\ -+ Use symoblic constant constructors.\n\ -\n\ -any-term \n\ -+ When applicable, use constructors corresponding to any symbolic term.\n\ -This option enables a sum-of-monomials grammar for arithmetic. For all\n\ -other types, it enables symbolic constant constructors.\n\ -\n\ -any-term-concise \n\ -+ When applicable, use constructors corresponding to any symbolic term,\n\ -favoring conciseness over generality. This option is equivalent to any-term\n\ -but enables a polynomial grammar for arithmetic when not in a combined\n\ -theory.\n\ -\n\ -"; - -const std::string OptionsHandler::s_macrosQuantHelp = "\ -Modes for quantifiers macro expansion, supported by --macros-quant-mode:\n\ -\n\ -all \n\ -+ Infer definitions for functions, including those containing quantified formulas.\n\ -\n\ -ground (default) \n\ -+ Only infer ground definitions for functions.\n\ -\n\ -ground-uf \n\ -+ Only infer ground definitions for functions that result in triggers for all free variables.\n\ -\n\ -"; - -const std::string OptionsHandler::s_quantDSplitHelp = "\ -Modes for quantifiers splitting, supported by --quant-dsplit-mode:\n\ -\n\ -none \n\ -+ Never split quantified formulas.\n\ -\n\ -default \n\ -+ Split quantified formulas over some finite datatypes when finite model finding is enabled.\n\ -\n\ -agg \n\ -+ Aggressively split quantified formulas.\n\ -\n\ -"; - -const std::string OptionsHandler::s_quantRepHelp = "\ -Modes for quantifiers representative selection, supported by --quant-rep-mode:\n\ -\n\ -ee \n\ -+ Let equality engine choose representatives.\n\ -\n\ -first (default) \n\ -+ Choose terms that appear first.\n\ -\n\ -depth \n\ -+ Choose terms that are of minimal depth.\n\ -\n\ -"; - -theory::quantifiers::InstWhenMode OptionsHandler::stringToInstWhenMode( - std::string option, std::string optarg) -{ - if(optarg == "pre-full") { - return theory::quantifiers::INST_WHEN_PRE_FULL; - } else if(optarg == "full") { - return theory::quantifiers::INST_WHEN_FULL; - } else if(optarg == "full-delay") { - return theory::quantifiers::INST_WHEN_FULL_DELAY; - } else if(optarg == "full-last-call") { - return theory::quantifiers::INST_WHEN_FULL_LAST_CALL; - } else if(optarg == "full-delay-last-call") { - return theory::quantifiers::INST_WHEN_FULL_DELAY_LAST_CALL; - } else if(optarg == "last-call") { - return theory::quantifiers::INST_WHEN_LAST_CALL; - } else if(optarg == "help") { - puts(s_instWhenHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --inst-when: `") + - optarg + "'. Try --inst-when help."); - } -} - -void OptionsHandler::checkInstWhenMode(std::string option, - theory::quantifiers::InstWhenMode mode) -{ - if(mode == theory::quantifiers::INST_WHEN_PRE_FULL) { - throw OptionException(std::string("Mode pre-full for ") + option + " is not supported in this release."); - } -} - -theory::quantifiers::LiteralMatchMode OptionsHandler::stringToLiteralMatchMode( - std::string option, std::string optarg) -{ - if(optarg == "none") { - return theory::quantifiers::LITERAL_MATCH_NONE; - } else if(optarg == "use") { - return theory::quantifiers::LITERAL_MATCH_USE; - } else if(optarg == "agg-predicate") { - return theory::quantifiers::LITERAL_MATCH_AGG_PREDICATE; - } else if(optarg == "agg") { - return theory::quantifiers::LITERAL_MATCH_AGG; - } else if(optarg == "help") { - puts(s_literalMatchHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --literal-matching: `") + - optarg + "'. Try --literal-matching help."); - } -} - -void OptionsHandler::checkLiteralMatchMode( - std::string option, theory::quantifiers::LiteralMatchMode mode) -{ -} - -theory::quantifiers::MbqiMode OptionsHandler::stringToMbqiMode( - std::string option, std::string optarg) -{ - if (optarg == "none") - { - return theory::quantifiers::MBQI_NONE; - } else if(optarg == "default" || optarg == "fmc") { - return theory::quantifiers::MBQI_FMC; - } else if(optarg == "trust") { - return theory::quantifiers::MBQI_TRUST; - } else if(optarg == "help") { - puts(s_mbqiModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --mbqi: `") + - optarg + "'. Try --mbqi help."); - } -} - -void OptionsHandler::checkMbqiMode(std::string option, - theory::quantifiers::MbqiMode mode) -{ -} - -theory::quantifiers::QcfWhenMode OptionsHandler::stringToQcfWhenMode( - std::string option, std::string optarg) -{ - if(optarg == "default") { - return theory::quantifiers::QCF_WHEN_MODE_DEFAULT; - } else if(optarg == "last-call") { - return theory::quantifiers::QCF_WHEN_MODE_LAST_CALL; - } else if(optarg == "std") { - return theory::quantifiers::QCF_WHEN_MODE_STD; - } else if(optarg == "std-h") { - return theory::quantifiers::QCF_WHEN_MODE_STD_H; - } else if(optarg == "help") { - puts(s_qcfWhenModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --quant-cf-when: `") + - optarg + "'. Try --quant-cf-when help."); - } -} - -theory::quantifiers::QcfMode OptionsHandler::stringToQcfMode(std::string option, - std::string optarg) -{ - if(optarg == "conflict") { - return theory::quantifiers::QCF_CONFLICT_ONLY; - } else if(optarg == "default" || optarg == "prop-eq") { - return theory::quantifiers::QCF_PROP_EQ; - } else if(optarg == "help") { - puts(s_qcfModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --quant-cf-mode: `") + - optarg + "'. Try --quant-cf-mode help."); - } -} - -theory::quantifiers::UserPatMode OptionsHandler::stringToUserPatMode( - std::string option, std::string optarg) -{ - if(optarg == "use") { - return theory::quantifiers::USER_PAT_MODE_USE; - } else if(optarg == "default" || optarg == "trust") { - return theory::quantifiers::USER_PAT_MODE_TRUST; - } else if(optarg == "resort") { - return theory::quantifiers::USER_PAT_MODE_RESORT; - } else if(optarg == "ignore") { - return theory::quantifiers::USER_PAT_MODE_IGNORE; - } else if(optarg == "interleave") { - return theory::quantifiers::USER_PAT_MODE_INTERLEAVE; - } else if(optarg == "help") { - puts(s_userPatModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --user-pat: `") + - optarg + "'. Try --user-pat help."); - } -} - -theory::quantifiers::TriggerSelMode OptionsHandler::stringToTriggerSelMode( - std::string option, std::string optarg) -{ - if(optarg == "default" || optarg == "min") { - return theory::quantifiers::TRIGGER_SEL_MIN; - } else if(optarg == "max") { - return theory::quantifiers::TRIGGER_SEL_MAX; - } else if(optarg == "min-s-max") { - return theory::quantifiers::TRIGGER_SEL_MIN_SINGLE_MAX; - } else if(optarg == "min-s-all") { - return theory::quantifiers::TRIGGER_SEL_MIN_SINGLE_ALL; - } else if(optarg == "all") { - return theory::quantifiers::TRIGGER_SEL_ALL; - } else if(optarg == "help") { - puts(s_triggerSelModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --trigger-sel: `") + - optarg + "'. Try --trigger-sel help."); - } -} - -theory::quantifiers::TriggerActiveSelMode -OptionsHandler::stringToTriggerActiveSelMode(std::string option, - std::string optarg) -{ - if(optarg == "default" || optarg == "all") { - return theory::quantifiers::TRIGGER_ACTIVE_SEL_ALL; - } else if(optarg == "min") { - return theory::quantifiers::TRIGGER_ACTIVE_SEL_MIN; - } else if(optarg == "max") { - return theory::quantifiers::TRIGGER_ACTIVE_SEL_MAX; - } else if(optarg == "help") { - puts(s_triggerActiveSelModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --trigger-active-sel: `") + - optarg + "'. Try --trigger-active-sel help."); - } -} - -theory::quantifiers::PrenexQuantMode OptionsHandler::stringToPrenexQuantMode( - std::string option, std::string optarg) -{ - if(optarg== "default" || optarg== "simple" ) { - return theory::quantifiers::PRENEX_QUANT_SIMPLE; - } else if(optarg == "none") { - return theory::quantifiers::PRENEX_QUANT_NONE; - } else if(optarg == "dnorm") { - return theory::quantifiers::PRENEX_QUANT_DISJ_NORMAL; - } else if(optarg == "norm") { - return theory::quantifiers::PRENEX_QUANT_NORMAL; - } else if(optarg == "help") { - puts(s_prenexQuantModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --prenex-quant: `") + - optarg + "'. Try --prenex-quant help."); - } -} - -theory::SygusFairMode OptionsHandler::stringToSygusFairMode(std::string option, - std::string optarg) -{ - if(optarg == "direct") { - return theory::SYGUS_FAIR_DIRECT; - } else if(optarg == "default" || optarg == "dt-size") { - return theory::SYGUS_FAIR_DT_SIZE; - } else if(optarg == "dt-height-bound" ){ - return theory::SYGUS_FAIR_DT_HEIGHT_PRED; - } else if(optarg == "dt-size-bound" ){ - return theory::SYGUS_FAIR_DT_SIZE_PRED; - } else if(optarg == "none") { - return theory::SYGUS_FAIR_NONE; - } else if(optarg == "help") { - puts(s_cegqiFairModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --cegqi-fair: `") + - optarg + "'. Try --cegqi-fair help."); - } -} - -theory::quantifiers::TermDbMode OptionsHandler::stringToTermDbMode( - std::string option, std::string optarg) -{ - if(optarg == "all" ) { - return theory::quantifiers::TERM_DB_ALL; - } else if(optarg == "relevant") { - return theory::quantifiers::TERM_DB_RELEVANT; - } else if(optarg == "help") { - puts(s_termDbModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --term-db-mode: `") + - optarg + "'. Try --term-db-mode help."); - } -} - -theory::quantifiers::IteLiftQuantMode OptionsHandler::stringToIteLiftQuantMode( - std::string option, std::string optarg) -{ - if(optarg == "all" ) { - return theory::quantifiers::ITE_LIFT_QUANT_MODE_ALL; - } else if(optarg == "simple") { - return theory::quantifiers::ITE_LIFT_QUANT_MODE_SIMPLE; - } else if(optarg == "none") { - return theory::quantifiers::ITE_LIFT_QUANT_MODE_NONE; - } else if(optarg == "help") { - puts(s_iteLiftQuantHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --ite-lift-quant: `") + - optarg + "'. Try --ite-lift-quant help."); - } -} - -theory::quantifiers::CbqiBvIneqMode OptionsHandler::stringToCbqiBvIneqMode( - std::string option, std::string optarg) -{ - if (optarg == "eq-slack") - { - return theory::quantifiers::CBQI_BV_INEQ_EQ_SLACK; - } - else if (optarg == "eq-boundary") - { - return theory::quantifiers::CBQI_BV_INEQ_EQ_BOUNDARY; - } - else if (optarg == "keep") - { - return theory::quantifiers::CBQI_BV_INEQ_KEEP; - } - else if (optarg == "help") - { - puts(s_cbqiBvIneqModeHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --cbqi-bv-ineq: `") - + optarg - + "'. Try --cbqi-bv-ineq help."); - } -} - -theory::quantifiers::CegqiSingleInvMode -OptionsHandler::stringToCegqiSingleInvMode(std::string option, - std::string optarg) -{ - if(optarg == "none" ) { - return theory::quantifiers::CEGQI_SI_MODE_NONE; - } else if(optarg == "use" || optarg == "default") { - return theory::quantifiers::CEGQI_SI_MODE_USE; - } else if(optarg == "all") { - return theory::quantifiers::CEGQI_SI_MODE_ALL; - } else if(optarg == "help") { - puts(s_cegqiSingleInvHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --cegqi-si: `") + - optarg + "'. Try --cegqi-si help."); - } -} - -theory::quantifiers::CegqiSingleInvRconsMode -OptionsHandler::stringToCegqiSingleInvRconsMode(std::string option, - std::string optarg) -{ - if (optarg == "none") - { - return theory::quantifiers::CEGQI_SI_RCONS_MODE_NONE; - } - else if (optarg == "try") - { - return theory::quantifiers::CEGQI_SI_RCONS_MODE_TRY; - } - else if (optarg == "all") - { - return theory::quantifiers::CEGQI_SI_RCONS_MODE_ALL; - } - else if (optarg == "all-limit") - { - return theory::quantifiers::CEGQI_SI_RCONS_MODE_ALL_LIMIT; - } - else if (optarg == "help") - { - puts(s_cegqiSingleInvRconsHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --cegqi-si-rcons: `") - + optarg + "'. Try --cegqi-si-rcons help."); - } -} - -theory::quantifiers::CegisSampleMode OptionsHandler::stringToCegisSampleMode( - std::string option, std::string optarg) -{ - if (optarg == "none") - { - return theory::quantifiers::CEGIS_SAMPLE_NONE; - } - else if (optarg == "use") - { - return theory::quantifiers::CEGIS_SAMPLE_USE; - } - else if (optarg == "trust") - { - return theory::quantifiers::CEGIS_SAMPLE_TRUST; - } - else if (optarg == "help") - { - puts(s_cegisSampleHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --cegis-sample: `") - + optarg - + "'. Try --cegis-sample help."); - } -} - -theory::quantifiers::SygusQueryDumpFilesMode -OptionsHandler::stringToSygusQueryDumpFilesMode(std::string option, - std::string optarg) -{ - if (optarg == "none") - { - return theory::quantifiers::SYGUS_QUERY_DUMP_NONE; - } - else if (optarg == "all") - { - return theory::quantifiers::SYGUS_QUERY_DUMP_ALL; - } - else if (optarg == "unsolved") - { - return theory::quantifiers::SYGUS_QUERY_DUMP_UNSOLVED; - } - else if (optarg == "help") - { - puts(s_sygusQueryDumpFileHelp.c_str()); - exit(1); - } - else - { - throw OptionException( - std::string("unknown option for --sygus-query-gen-dump-files: `") - + optarg + "'. Try --sygus-query-gen-dump-files help."); - } -} -theory::quantifiers::SygusFilterSolMode -OptionsHandler::stringToSygusFilterSolMode(std::string option, - std::string optarg) +void OptionsHandler::checkInstWhenMode(std::string option, InstWhenMode mode) { - if (optarg == "none") - { - return theory::quantifiers::SYGUS_FILTER_SOL_NONE; - } - else if (optarg == "strong") - { - return theory::quantifiers::SYGUS_FILTER_SOL_STRONG; - } - else if (optarg == "weak") + if (mode == InstWhenMode::PRE_FULL) { - return theory::quantifiers::SYGUS_FILTER_SOL_WEAK; - } - else if (optarg == "help") - { - puts(s_sygusFilterSolHelp.c_str()); - exit(1); - } - else - { - throw OptionException( - std::string("unknown option for --sygus-filter-sol: `") + optarg - + "'. Try --sygus-filter-sol help."); - } -} - -theory::quantifiers::SygusInvTemplMode -OptionsHandler::stringToSygusInvTemplMode(std::string option, - std::string optarg) -{ - if(optarg == "none" ) { - return theory::quantifiers::SYGUS_INV_TEMPL_MODE_NONE; - } else if(optarg == "pre") { - return theory::quantifiers::SYGUS_INV_TEMPL_MODE_PRE; - } else if(optarg == "post") { - return theory::quantifiers::SYGUS_INV_TEMPL_MODE_POST; - } else if(optarg == "help") { - puts(s_sygusInvTemplHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --sygus-inv-templ: `") + - optarg + "'. Try --sygus-inv-templ help."); - } -} - -theory::quantifiers::SygusActiveGenMode -OptionsHandler::stringToSygusActiveGenMode(std::string option, - std::string optarg) -{ - if (optarg == "none") - { - return theory::quantifiers::SYGUS_ACTIVE_GEN_NONE; - } - else if (optarg == "basic") - { - return theory::quantifiers::SYGUS_ACTIVE_GEN_ENUM_BASIC; - } - else if (optarg == "enum") - { - return theory::quantifiers::SYGUS_ACTIVE_GEN_ENUM; - } - else if (optarg == "var-agnostic") - { - return theory::quantifiers::SYGUS_ACTIVE_GEN_VAR_AGNOSTIC; - } - else if (optarg == "auto") - { - return theory::quantifiers::SYGUS_ACTIVE_GEN_AUTO; - } - else if (optarg == "help") - { - puts(s_sygusActiveGenHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --sygus-inv-templ: `") - + optarg + "'. Try --sygus-inv-templ help."); - } -} -theory::quantifiers::SygusGrammarConsMode -OptionsHandler::stringToSygusGrammarConsMode(std::string option, - std::string optarg) -{ - if (optarg == "simple") - { - return theory::quantifiers::SYGUS_GCONS_SIMPLE; - } - else if (optarg == "any-const") - { - return theory::quantifiers::SYGUS_GCONS_ANY_CONST; - } - else if (optarg == "any-term") - { - return theory::quantifiers::SYGUS_GCONS_ANY_TERM; - } - else if (optarg == "any-term-concise") - { - return theory::quantifiers::SYGUS_GCONS_ANY_TERM_CONCISE; - } - else if (optarg == "help") - { - puts(s_sygusGrammarConsHelp.c_str()); - exit(1); - } - else - { - throw OptionException( - std::string("unknown option for --sygus-grammar-cons: `") + optarg - + "'. Try --sygus-grammar-cons help."); - } -} - -theory::quantifiers::SygusUnifPiMode OptionsHandler::stringToSygusUnifPiMode( - std::string option, std::string optarg) -{ - if (optarg == "none") - { - return theory::quantifiers::SYGUS_UNIF_PI_NONE; - } - else if (optarg == "complete") - { - return theory::quantifiers::SYGUS_UNIF_PI_COMPLETE; - } - else if (optarg == "cond-enum") - { - return theory::quantifiers::SYGUS_UNIF_PI_CENUM; - } - else if (optarg == "cond-enum-igain") - { - return theory::quantifiers::SYGUS_UNIF_PI_CENUM_IGAIN; - } - else if (optarg == "help") - { - puts(s_sygusUnifPiHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --sygus-unif-pi: `") - + optarg + "'. Try --sygus-unif-pi help."); - } -} - -theory::quantifiers::MacrosQuantMode OptionsHandler::stringToMacrosQuantMode( - std::string option, std::string optarg) -{ - if(optarg == "all" ) { - return theory::quantifiers::MACROS_QUANT_MODE_ALL; - } else if(optarg == "ground") { - return theory::quantifiers::MACROS_QUANT_MODE_GROUND; - } else if(optarg == "ground-uf") { - return theory::quantifiers::MACROS_QUANT_MODE_GROUND_UF; - } else if(optarg == "help") { - puts(s_macrosQuantHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --macros-quant-mode: `") + - optarg + "'. Try --macros-quant-mode help."); - } -} - -theory::quantifiers::QuantDSplitMode OptionsHandler::stringToQuantDSplitMode( - std::string option, std::string optarg) -{ - if(optarg == "none" ) { - return theory::quantifiers::QUANT_DSPLIT_MODE_NONE; - } else if(optarg == "default") { - return theory::quantifiers::QUANT_DSPLIT_MODE_DEFAULT; - } else if(optarg == "agg") { - return theory::quantifiers::QUANT_DSPLIT_MODE_AGG; - } else if(optarg == "help") { - puts(s_quantDSplitHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --quant-dsplit-mode: `") + - optarg + "'. Try --quant-dsplit-mode help."); - } -} - -theory::quantifiers::QuantRepMode OptionsHandler::stringToQuantRepMode( - std::string option, std::string optarg) -{ - if(optarg == "none" ) { - return theory::quantifiers::QUANT_REP_MODE_EE; - } else if(optarg == "first" || optarg == "default") { - return theory::quantifiers::QUANT_REP_MODE_FIRST; - } else if(optarg == "depth") { - return theory::quantifiers::QUANT_REP_MODE_DEPTH; - } else if(optarg == "help") { - puts(s_quantRepHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --quant-rep-mode: `") + - optarg + "'. Try --quant-rep-mode help."); + throw OptionException(std::string("Mode pre-full for ") + option + + " is not supported in this release."); } } @@ -1253,192 +128,42 @@ void OptionsHandler::abcEnabledBuild(std::string option, bool value) #ifndef CVC4_USE_ABC if(value) { std::stringstream ss; - ss << "option `" << option << "' requires an abc-enabled build of CVC4; this binary was not built with abc support"; - throw OptionException(ss.str()); - } -#endif /* CVC4_USE_ABC */ -} - -void OptionsHandler::abcEnabledBuild(std::string option, std::string value) -{ -#ifndef CVC4_USE_ABC - if(!value.empty()) { - std::stringstream ss; - ss << "option `" << option << "' requires an abc-enabled build of CVC4; this binary was not built with abc support"; - throw OptionException(ss.str()); - } -#endif /* CVC4_USE_ABC */ -} - -void OptionsHandler::satSolverEnabledBuild(std::string option, bool value) -{ -#if !defined(CVC4_USE_CRYPTOMINISAT) && !defined(CVC4_USE_CADICAL) - if (value) - { - std::stringstream ss; - ss << "option `" << option - << "' requires a CVC4 to be built with CryptoMiniSat or CaDiCaL"; - throw OptionException(ss.str()); - } -#endif -} - -void OptionsHandler::satSolverEnabledBuild(std::string option, - std::string value) -{ -#if !defined(CVC4_USE_CRYPTOMINISAT) && !defined(CVC4_USE_CADICAL) - if (!value.empty()) - { - std::stringstream ss; - ss << "option `" << option - << "' requires a CVC4 to be built with CryptoMiniSat or CaDiCaL"; - throw OptionException(ss.str()); - } -#endif -} - -const std::string OptionsHandler::s_bvSatSolverHelp = "\ -Sat solvers currently supported by the --bv-sat-solver option:\n\ -\n\ -minisat (default)\n\ -\n\ -cadical\n\ -\n\ -cryptominisat\n\ -"; - -theory::bv::SatSolverMode OptionsHandler::stringToSatSolver(std::string option, - std::string optarg) -{ - if(optarg == "minisat") { - return theory::bv::SAT_SOLVER_MINISAT; - } else if(optarg == "cryptominisat") { - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY && - options::bitblastMode.wasSetByUser()) { - throwLazyBBUnsupported(theory::bv::SAT_SOLVER_CRYPTOMINISAT); - } - if (!options::bitvectorToBool.wasSetByUser()) { - options::bitvectorToBool.set(true); - } - return theory::bv::SAT_SOLVER_CRYPTOMINISAT; - } - else if (optarg == "cadical") - { - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY - && options::bitblastMode.wasSetByUser()) - { - throwLazyBBUnsupported(theory::bv::SAT_SOLVER_CADICAL); - } - if (!options::bitvectorToBool.wasSetByUser()) - { - options::bitvectorToBool.set(true); - } - return theory::bv::SAT_SOLVER_CADICAL; - } else if(optarg == "help") { - puts(s_bvSatSolverHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --bv-sat-solver: `") + - optarg + "'. Try --bv-sat-solver=help."); - } -} - -const std::string OptionsHandler::s_bvProofFormatHelp = - "\ -Proof formats currently supported by the --bv-proof-format option:\n\ -\n\ - lrat : DRAT with unit propagation hints to accelerate checking (default)\n\ -\n\ - drat : Deletion and Resolution Asymmetric Tautology Additions \n\ -\n\ - er : Extended Resolution, i.e. resolution with new variable definitions\n\ -\n\ -This option controls which underlying UNSAT proof format is used in BV proofs.\n\ -\n\ -Note: Currently this option does nothing. BV proofs are a work in progress!\ -"; - -theory::bv::BvProofFormat OptionsHandler::stringToBvProofFormat( - std::string option, std::string optarg) -{ - if (optarg == "er") - { - return theory::bv::BITVECTOR_PROOF_ER; - } - else if (optarg == "lrat") - { - return theory::bv::BITVECTOR_PROOF_LRAT; - } - else if (optarg == "drat") - { - return theory::bv::BITVECTOR_PROOF_DRAT; - } - else if (optarg == "help") - { - puts(s_bvProofFormatHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --bv-proof-format: `") - + optarg + "'. Try --bv-proof-format=help."); + ss << "option `" << option << "' requires an abc-enabled build of CVC4; this binary was not built with abc support"; + throw OptionException(ss.str()); } +#endif /* CVC4_USE_ABC */ } -const std::string OptionsHandler::s_bvOptimizeSatProofHelp = - "\ -Optimization levels currently supported by the --bv-optimize-sat-proof option:\n\ -\n\ - none : Do not optimize the SAT proof\n\ -\n\ - proof : Use drat-trim to shrink the SAT proof\n\ -\n\ - formula : Use drat-trim to shrink the SAT proof and formula (default)\ -"; - -theory::bv::BvOptimizeSatProof OptionsHandler::stringToBvOptimizeSatProof( - std::string option, std::string optarg) +void OptionsHandler::abcEnabledBuild(std::string option, std::string value) { - if (optarg == "none") - { - return theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_NONE; - } - else if (optarg == "proof") - { - return theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF; - } - else if (optarg == "formula") - { - return theory::bv::BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA; - } - else if (optarg == "help") - { - puts(s_bvOptimizeSatProofHelp.c_str()); - exit(1); +#ifndef CVC4_USE_ABC + if(!value.empty()) { + std::stringstream ss; + ss << "option `" << option << "' requires an abc-enabled build of CVC4; this binary was not built with abc support"; + throw OptionException(ss.str()); } - else +#endif /* CVC4_USE_ABC */ +} + +void OptionsHandler::checkBvSatSolver(std::string option, SatSolverMode m) +{ + if (m == SatSolverMode::CRYPTOMINISAT || m == SatSolverMode::CADICAL) { - throw OptionException(std::string("unknown option for --bv-optimize-sat-proof: `") - + optarg + "'. Try --bv-optimize-sat-proof=help."); + if (options::bitblastMode() == options::BitblastMode::LAZY + && options::bitblastMode.wasSetByUser()) + { + throwLazyBBUnsupported(m); + } + if (!options::bitvectorToBool.wasSetByUser()) + { + options::bitvectorToBool.set(true); + } } } - -const std::string OptionsHandler::s_bitblastingModeHelp = "\ -Bit-blasting modes currently supported by the --bitblast option:\n\ -\n\ -lazy (default)\n\ -+ Separate boolean structure and term reasoning between the core\n\ - SAT solver and the bv SAT solver\n\ -\n\ -eager\n\ -+ Bitblast eagerly to bv SAT solver\n\ -"; - -theory::bv::BitblastMode OptionsHandler::stringToBitblastMode( - std::string option, std::string optarg) +void OptionsHandler::checkBitblastMode(std::string option, BitblastMode m) { - if (optarg == "lazy") + if (m == options::BitblastMode::LAZY) { if (!options::bitvectorPropagate.wasSetByUser()) { @@ -1452,11 +177,11 @@ theory::bv::BitblastMode OptionsHandler::stringToBitblastMode( { if (options::incrementalSolving() || options::produceModels()) { - options::bitvectorEqualitySlicer.set(theory::bv::BITVECTOR_SLICER_OFF); + options::bitvectorEqualitySlicer.set(options::BvSlicerMode::OFF); } else { - options::bitvectorEqualitySlicer.set(theory::bv::BITVECTOR_SLICER_AUTO); + options::bitvectorEqualitySlicer.set(options::BvSlicerMode::AUTO); } } @@ -1468,210 +193,17 @@ theory::bv::BitblastMode OptionsHandler::stringToBitblastMode( { options::bitvectorAlgebraicSolver.set(true); } - if (options::bvSatSolver() != theory::bv::SAT_SOLVER_MINISAT) + if (options::bvSatSolver() != options::SatSolverMode::MINISAT) { throwLazyBBUnsupported(options::bvSatSolver()); } - return theory::bv::BITBLAST_MODE_LAZY; } - else if (optarg == "eager") + else if (m == BitblastMode::EAGER) { if (!options::bitvectorToBool.wasSetByUser()) { options::bitvectorToBool.set(true); } - return theory::bv::BITBLAST_MODE_EAGER; - } - else if (optarg == "help") - { - puts(s_bitblastingModeHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --bitblast: `") - + optarg + "'. Try --bitblast=help."); - } -} - -const std::string OptionsHandler::s_bvSlicerModeHelp = "\ -Bit-vector equality slicer modes supported by the --bv-eq-slicer option:\n\ -\n\ -auto (default)\n\ -+ Turn slicer on if input has only equalities over core symbols\n\ -\n\ -on\n\ -+ Turn slicer on\n\ -\n\ -off\n\ -+ Turn slicer off\n\ -"; - -theory::bv::BvSlicerMode OptionsHandler::stringToBvSlicerMode( - std::string option, std::string optarg) -{ - if(optarg == "auto") { - return theory::bv::BITVECTOR_SLICER_AUTO; - } else if(optarg == "on") { - return theory::bv::BITVECTOR_SLICER_ON; - } else if(optarg == "off") { - return theory::bv::BITVECTOR_SLICER_OFF; - } else if(optarg == "help") { - puts(s_bvSlicerModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --bv-eq-slicer: `") + - optarg + "'. Try --bv-eq-slicer=help."); - } -} - -const std::string OptionsHandler::s_stringsProcessLoopModeHelp = - "Loop processing modes supported by the --strings-process-loop-mode " - "option:\n" - "\n" - "full (default)\n" - "+ Perform full processing of looping word equations\n" - "\n" - "simple (default with --strings-fmf)\n" - "+ Omit normal loop breaking\n" - "\n" - "simple-abort\n" - "+ Abort when normal loop breaking is required\n" - "\n" - "none\n" - "+ Omit loop processing\n" - "\n" - "abort\n" - "+ Abort if looping word equations are encountered\n"; - -theory::strings::ProcessLoopMode OptionsHandler::stringToStringsProcessLoopMode( - std::string option, std::string optarg) -{ - if (optarg == "full") - { - return theory::strings::ProcessLoopMode::FULL; - } - else if (optarg == "simple") - { - return theory::strings::ProcessLoopMode::SIMPLE; - } - else if (optarg == "simple-abort") - { - return theory::strings::ProcessLoopMode::SIMPLE_ABORT; - } - else if (optarg == "none") - { - return theory::strings::ProcessLoopMode::NONE; - } - else if (optarg == "abort") - { - return theory::strings::ProcessLoopMode::ABORT; - } - else if (optarg == "help") - { - puts(s_stringsProcessLoopModeHelp.c_str()); - exit(1); - } - else - { - throw OptionException( - std::string("unknown option for --strings-process-loop-mode: `") - + optarg + "'. Try --strings-process-loop-mode=help."); - } -} - -const std::string OptionsHandler::s_regExpInterModeHelp = - "\ -Regular expression intersection modes supported by the --re-inter-mode option\ -\n\ -\n\ -all \n\ -+ Compute intersections for all regular expressions.\n\ -\n\ -constant (default)\n\ -+ Compute intersections only between regular expressions that do not contain\ -re.allchar or re.range\n\ -\n\ -one-constant\n\ -+ Compute intersections only between regular expressions such that at least one\ -side does not contain re.allchar or re.range\n\ -\n\ -none\n\ -+ Do not compute intersections for regular expressions\n\ -"; - -theory::strings::RegExpInterMode OptionsHandler::stringToRegExpInterMode( - std::string option, std::string optarg) -{ - if (optarg == "all") - { - return theory::strings::RegExpInterMode::RE_INTER_ALL; - } - else if (optarg == "constant") - { - return theory::strings::RegExpInterMode::RE_INTER_CONSTANT; - } - else if (optarg == "one-constant") - { - return theory::strings::RegExpInterMode::RE_INTER_ONE_CONSTANT; - } - else if (optarg == "none") - { - return theory::strings::RegExpInterMode::RE_INTER_NONE; - } - else if (optarg == "help") - { - puts(s_regExpInterModeHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --re-inter-mode: `") - + optarg + "'. Try --re-inter-mode=help."); - } -} - -const std::string OptionsHandler::s_boolToBVModeHelp = - "\ -BoolToBV pass modes supported by the --bool-to-bv option:\n\ -\n\ -off (default)\n\ -+ Don't push any booleans to width one bit-vectors\n\ -\n\ -ite\n\ -+ Try to turn ITEs into BITVECTOR_ITE when possible. It can fail per-formula \n\ - if not all sub-formulas can be turned to bit-vectors\n\ -\n\ -all\n\ -+ Force all booleans to be bit-vectors of width one except at the top level.\n\ - Most aggressive mode\n\ -"; - -preprocessing::passes::BoolToBVMode OptionsHandler::stringToBoolToBVMode( - std::string option, std::string optarg) -{ - if (optarg == "off") - { - return preprocessing::passes::BOOL_TO_BV_OFF; - } - else if (optarg == "ite") - { - return preprocessing::passes::BOOL_TO_BV_ITE; - } - else if (optarg == "all") - { - return preprocessing::passes::BOOL_TO_BV_ALL; - } - else if (optarg == "help") - { - puts(s_boolToBVModeHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --bool-to-bv: `") - + optarg - + "'. Try --bool-to-bv=help"); } } @@ -1679,11 +211,12 @@ void OptionsHandler::setBitblastAig(std::string option, bool arg) { if(arg) { if(options::bitblastMode.wasSetByUser()) { - if(options::bitblastMode() != theory::bv::BITBLAST_MODE_EAGER) { + if (options::bitblastMode() != options::BitblastMode::EAGER) + { throw OptionException("bitblast-aig must be used with eager bitblaster"); } } else { - theory::bv::BitblastMode mode = stringToBitblastMode("", "eager"); + options::BitblastMode mode = stringToBitblastMode("", "eager"); options::bitblastMode.set(mode); } if(!options::bitvectorAigSimplifications.wasSetByUser()) { @@ -1692,68 +225,6 @@ void OptionsHandler::setBitblastAig(std::string option, bool arg) } } -// theory/uf/options_handlers.h -const std::string OptionsHandler::s_ufssModeHelp = "\ -UF with cardinality options currently supported by the --uf-ss option when\n\ -combined with finite model finding:\n\ -\n\ -full \n\ -+ Default, use UF with cardinality to find minimal models for uninterpreted\n\ -sorts.\n\ -\n\ -no-minimal \n\ -+ Use UF with cardinality to shrink models, but do no enforce minimality.\n\ -\n\ -none \n\ -+ Do not use UF with cardinality to shrink model sizes. \n\ -\n\ -"; - -theory::uf::UfssMode OptionsHandler::stringToUfssMode(std::string option, - std::string optarg) -{ - if(optarg == "default" || optarg == "full" ) { - return theory::uf::UF_SS_FULL; - } else if(optarg == "no-minimal") { - return theory::uf::UF_SS_NO_MINIMAL; - } else if(optarg == "none") { - return theory::uf::UF_SS_NONE; - } else if(optarg == "help") { - puts(s_ufssModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --uf-ss: `") + - optarg + "'. Try --uf-ss help."); - } -} - - - -// theory/options_handlers.h -const std::string OptionsHandler::s_theoryOfModeHelp = "\ -TheoryOf modes currently supported by the --theoryof-mode option:\n\ -\n\ -type (default) \n\ -+ type variables, constants and equalities by type\n\ -\n\ -term \n\ -+ type variables as uninterpreted, equalities by the parametric theory\n\ -"; - -theory::TheoryOfMode OptionsHandler::stringToTheoryOfMode(std::string option, std::string optarg) { - if(optarg == "type") { - return theory::THEORY_OF_TYPE_BASED; - } else if(optarg == "term") { - return theory::THEORY_OF_TERM_BASED; - } else if(optarg == "help") { - puts(s_theoryOfModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --theoryof-mode: `") + - optarg + "'. Try --theoryof-mode help."); - } -} - // theory/options_handlers.h std::string OptionsHandler::handleUseTheoryList(std::string option, std::string optarg) { std::string currentList = options::useTheoryList(); @@ -1768,19 +239,7 @@ void OptionsHandler::notifyUseTheoryList(std::string option) { d_options->d_useTheoryListListeners.notify(); } - - // printer/options_handlers.h -const std::string OptionsHandler::s_modelFormatHelp = "\ -Model format modes currently supported by the --model-format option:\n\ -\n\ -default \n\ -+ Print model as expressions in the output language format.\n\ -\n\ -table\n\ -+ Print functional expressions over finite domains in a table format.\n\ -"; - const std::string OptionsHandler::s_instFormatHelp = "\ Inst format modes currently supported by the --inst-format option:\n\ \n\ @@ -1791,29 +250,13 @@ szs\n\ + Print instantiations as SZS compliant proof.\n\ "; -ModelFormatMode OptionsHandler::stringToModelFormatMode(std::string option, - std::string optarg) -{ - if(optarg == "default") { - return MODEL_FORMAT_MODE_DEFAULT; - } else if(optarg == "table") { - return MODEL_FORMAT_MODE_TABLE; - } else if(optarg == "help") { - puts(s_modelFormatHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --model-format: `") + - optarg + "'. Try --model-format help."); - } -} - InstFormatMode OptionsHandler::stringToInstFormatMode(std::string option, std::string optarg) { if(optarg == "default") { - return INST_FORMAT_MODE_DEFAULT; + return InstFormatMode::DEFAULT; } else if(optarg == "szs") { - return INST_FORMAT_MODE_SZS; + return InstFormatMode::SZS; } else if(optarg == "help") { puts(s_instFormatHelp.c_str()); exit(1); @@ -1823,224 +266,10 @@ InstFormatMode OptionsHandler::stringToInstFormatMode(std::string option, } } - // decision/options_handlers.h -const std::string OptionsHandler::s_decisionModeHelp = "\ -Decision modes currently supported by the --decision option:\n\ -\n\ -internal (default)\n\ -+ Use the internal decision heuristics of the SAT solver\n\ -\n\ -justification\n\ -+ An ATGP-inspired justification heuristic\n\ -\n\ -justification-stoponly\n\ -+ Use the justification heuristic only to stop early, not for decisions\n\ -"; - -decision::DecisionMode OptionsHandler::stringToDecisionMode(std::string option, - std::string optarg) -{ - options::decisionStopOnly.set(false); - - if(optarg == "internal") { - return decision::DECISION_STRATEGY_INTERNAL; - } else if(optarg == "justification") { - return decision::DECISION_STRATEGY_JUSTIFICATION; - } else if(optarg == "justification-stoponly") { - options::decisionStopOnly.set(true); - return decision::DECISION_STRATEGY_JUSTIFICATION; - } else if(optarg == "help") { - puts(s_decisionModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --decision: `") + - optarg + "'. Try --decision help."); - } -} - -decision::DecisionWeightInternal OptionsHandler::stringToDecisionWeightInternal( - std::string option, std::string optarg) -{ - if(optarg == "off") - return decision::DECISION_WEIGHT_INTERNAL_OFF; - else if(optarg == "max") - return decision::DECISION_WEIGHT_INTERNAL_MAX; - else if(optarg == "sum") - return decision::DECISION_WEIGHT_INTERNAL_SUM; - else if(optarg == "usr1") - return decision::DECISION_WEIGHT_INTERNAL_USR1; - else - throw OptionException(std::string("--decision-weight-internal must be off, max or sum.")); -} - - -// smt/options_handlers.h -const std::string OptionsHandler::s_simplificationHelp = "\ -Simplification modes currently supported by the --simplification option:\n\ -\n\ -batch (default) \n\ -+ save up all ASSERTions; run nonclausal simplification and clausal\n\ - (MiniSat) propagation for all of them only after reaching a querying command\n\ - (CHECKSAT or QUERY or predicate SUBTYPE declaration)\n\ -\n\ -none\n\ -+ do not perform nonclausal simplification\n\ -"; - -SimplificationMode OptionsHandler::stringToSimplificationMode( - std::string option, std::string optarg) -{ - if(optarg == "batch") { - return SIMPLIFICATION_MODE_BATCH; - } else if(optarg == "none") { - return SIMPLIFICATION_MODE_NONE; - } else if(optarg == "help") { - puts(s_simplificationHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --simplification: `") + - optarg + "'. Try --simplification help."); - } -} - -const std::string OptionsHandler::s_modelCoresHelp = - "\ -Model cores modes currently supported by the --model-cores option:\n\ -\n\ -none (default) \n\ -+ do not compute model cores\n\ -\n\ -simple\n\ -+ only include a subset of variables whose values are sufficient to show the\n\ -input formula is satisfied by the given model\n\ -\n\ -non-implied\n\ -+ only include a subset of variables whose values, in addition to the values\n\ -of variables whose values are implied, are sufficient to show the input\n\ -formula is satisfied by the given model\n\ -\n\ -"; - -ModelCoresMode OptionsHandler::stringToModelCoresMode(std::string option, - std::string optarg) -{ - if (optarg == "none") - { - return MODEL_CORES_NONE; - } - else if (optarg == "simple") - { - return MODEL_CORES_SIMPLE; - } - else if (optarg == "non-implied") - { - return MODEL_CORES_NON_IMPLIED; - } - else if (optarg == "help") - { - puts(s_modelCoresHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --model-cores: `") - + optarg + "'. Try --model-cores help."); - } -} - -const std::string OptionsHandler::s_blockModelsHelp = - "\ -Blocking models modes are currently supported by the --block-models option:\n\ -\n\ -none (default) \n\ -+ do not block models\n\ -\n\ -literals\n\ -+ block models based on the SAT skeleton\n\ -\n\ -values\n\ -+ block models based on the concrete model values for the free variables.\n\ -\n\ -"; - -BlockModelsMode OptionsHandler::stringToBlockModelsMode(std::string option, - std::string optarg) -{ - if (optarg == "none") - { - return BLOCK_MODELS_NONE; - } - else if (optarg == "literals") - { - return BLOCK_MODELS_LITERALS; - } - else if (optarg == "values") - { - return BLOCK_MODELS_VALUES; - ; - } - else if (optarg == "help") - { - puts(s_blockModelsHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --block-models: `") - + optarg + "'. Try --block-models help."); - } -} - -const std::string OptionsHandler::s_sygusSolutionOutModeHelp = - "\ -Modes for sygus solution output, supported by --sygus-out:\n\ -\n\ -status \n\ -+ Print only status for check-synth calls.\n\ -\n\ -status-and-def (default) \n\ -+ Print status followed by definition corresponding to solution.\n\ -\n\ -status-or-def \n\ -+ Print status if infeasible, or definition corresponding to\n\ - solution if feasible.\n\ -\n\ -sygus-standard \n\ -+ Print based on SyGuS standard.\n\ -\n\ -"; - -SygusSolutionOutMode OptionsHandler::stringToSygusSolutionOutMode( - std::string option, std::string optarg) +void OptionsHandler::setDecisionModeStopOnly(std::string option, DecisionMode m) { - if (optarg == "status") - { - return SYGUS_SOL_OUT_STATUS; - } - else if (optarg == "status-and-def") - { - return SYGUS_SOL_OUT_STATUS_AND_DEF; - } - else if (optarg == "status-or-def") - { - return SYGUS_SOL_OUT_STATUS_OR_DEF; - } - else if (optarg == "sygus-standard") - { - return SYGUS_SOL_OUT_STANDARD; - } - else if (optarg == "help") - { - puts(s_sygusSolutionOutModeHelp.c_str()); - exit(1); - } - else - { - throw OptionException(std::string("unknown option for --sygus-out: `") - + optarg - + "'. Try --sygus-out help."); - } + options::decisionStopOnly.set(m == DecisionMode::RELEVANCY); } void OptionsHandler::setProduceAssertions(std::string option, bool value) @@ -2052,9 +281,9 @@ void OptionsHandler::setProduceAssertions(std::string option, bool value) void OptionsHandler::proofEnabledBuild(std::string option, bool value) { #ifdef CVC4_PROOF - if (value && options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER - && options::bvSatSolver() != theory::bv::SAT_SOLVER_MINISAT - && options::bvSatSolver() != theory::bv::SAT_SOLVER_CRYPTOMINISAT) + if (value && options::bitblastMode() == options::BitblastMode::EAGER + && options::bvSatSolver() != options::SatSolverMode::MINISAT + && options::bvSatSolver() != options::SatSolverMode::CRYPTOMINISAT) { throw OptionException( "Eager BV proofs only supported when MiniSat or CryptoMiniSat is used"); diff --git a/src/options/options_handler.h b/src/options/options_handler.h index 2e372a00c..a395bb453 100644 --- a/src/options/options_handler.h +++ b/src/options/options_handler.h @@ -23,24 +23,14 @@ #include #include "base/modal_exception.h" -#include "options/arith_heuristic_pivot_rule.h" -#include "options/arith_propagation_mode.h" -#include "options/arith_unate_lemma_mode.h" #include "options/base_handlers.h" -#include "options/bool_to_bv_mode.h" -#include "options/bv_bitblast_mode.h" -#include "options/datatypes_modes.h" -#include "options/decision_mode.h" +#include "options/bv_options.h" +#include "options/decision_options.h" #include "options/language.h" #include "options/option_exception.h" #include "options/options.h" #include "options/printer_modes.h" -#include "options/quantifiers_modes.h" -#include "options/smt_modes.h" -#include "options/strings_modes.h" -#include "options/sygus_out_mode.h" -#include "options/theoryof_mode.h" -#include "options/ufss_mode.h" +#include "options/quantifiers_options.h" namespace CVC4 { namespace options { @@ -70,117 +60,29 @@ public: options::less_equal(1.0)(option, value); } - // theory/arith/options_handlers.h - ArithUnateLemmaMode stringToArithUnateLemmaMode(std::string option, - std::string optarg); - ArithPropagationMode stringToArithPropagationMode(std::string option, - std::string optarg); - ErrorSelectionRule stringToErrorSelectionRule(std::string option, - std::string optarg); - // theory/quantifiers/options_handlers.h - theory::quantifiers::InstWhenMode stringToInstWhenMode(std::string option, - std::string optarg); - void checkInstWhenMode(std::string option, - theory::quantifiers::InstWhenMode mode); - theory::quantifiers::LiteralMatchMode stringToLiteralMatchMode( - std::string option, std::string optarg); - void checkLiteralMatchMode(std::string option, - theory::quantifiers::LiteralMatchMode mode); - theory::quantifiers::MbqiMode stringToMbqiMode(std::string option, - std::string optarg); - void checkMbqiMode(std::string option, theory::quantifiers::MbqiMode mode); - theory::quantifiers::QcfWhenMode stringToQcfWhenMode(std::string option, - std::string optarg); - theory::quantifiers::QcfMode stringToQcfMode(std::string option, - std::string optarg); - theory::quantifiers::UserPatMode stringToUserPatMode(std::string option, - std::string optarg); - theory::quantifiers::TriggerSelMode stringToTriggerSelMode( - std::string option, std::string optarg); - theory::quantifiers::TriggerActiveSelMode stringToTriggerActiveSelMode( - std::string option, std::string optarg); - theory::quantifiers::PrenexQuantMode stringToPrenexQuantMode( - std::string option, std::string optarg); - theory::quantifiers::TermDbMode stringToTermDbMode(std::string option, - std::string optarg); - theory::quantifiers::IteLiftQuantMode stringToIteLiftQuantMode( - std::string option, std::string optarg); - theory::quantifiers::CbqiBvIneqMode stringToCbqiBvIneqMode( - std::string option, std::string optarg); - theory::quantifiers::CegqiSingleInvMode stringToCegqiSingleInvMode( - std::string option, std::string optarg); - theory::quantifiers::CegqiSingleInvRconsMode stringToCegqiSingleInvRconsMode( - std::string option, std::string optarg); - theory::quantifiers::CegisSampleMode stringToCegisSampleMode( - std::string option, std::string optarg); - theory::quantifiers::SygusQueryDumpFilesMode stringToSygusQueryDumpFilesMode( - std::string option, std::string optarg); - theory::quantifiers::SygusFilterSolMode stringToSygusFilterSolMode( - std::string option, std::string optarg); - theory::quantifiers::SygusInvTemplMode stringToSygusInvTemplMode( - std::string option, std::string optarg); - theory::quantifiers::SygusActiveGenMode stringToSygusActiveGenMode( - std::string option, std::string optarg); - theory::quantifiers::SygusUnifPiMode stringToSygusUnifPiMode( - std::string option, std::string optarg); - theory::quantifiers::SygusGrammarConsMode stringToSygusGrammarConsMode( - std::string option, std::string optarg); - theory::quantifiers::MacrosQuantMode stringToMacrosQuantMode( - std::string option, std::string optarg); - theory::quantifiers::QuantDSplitMode stringToQuantDSplitMode( - std::string option, std::string optarg); - theory::quantifiers::QuantRepMode stringToQuantRepMode(std::string option, - std::string optarg); - theory::SygusFairMode stringToSygusFairMode(std::string option, - std::string optarg); + void checkInstWhenMode(std::string option, InstWhenMode mode); // theory/bv/options_handlers.h void abcEnabledBuild(std::string option, bool value); void abcEnabledBuild(std::string option, std::string value); - void satSolverEnabledBuild(std::string option, bool value); - void satSolverEnabledBuild(std::string option, std::string optarg); - - theory::bv::BitblastMode stringToBitblastMode(std::string option, - std::string optarg); - theory::bv::BvSlicerMode stringToBvSlicerMode(std::string option, - std::string optarg); - preprocessing::passes::BoolToBVMode stringToBoolToBVMode(std::string option, - std::string optarg); - void setBitblastAig(std::string option, bool arg); - - theory::bv::SatSolverMode stringToSatSolver(std::string option, - std::string optarg); - theory::bv::BvProofFormat stringToBvProofFormat(std::string option, - std::string optarg); - theory::bv::BvOptimizeSatProof stringToBvOptimizeSatProof(std::string option, - std::string optarg); + template void checkSatSolverEnabled(std::string option, T m); - theory::strings::ProcessLoopMode stringToStringsProcessLoopMode( - std::string option, std::string optarg); - theory::strings::RegExpInterMode stringToRegExpInterMode(std::string option, - std::string optarg); + void checkBvSatSolver(std::string option, SatSolverMode m); + void checkBitblastMode(std::string option, BitblastMode m); - // theory/uf/options_handlers.h - theory::uf::UfssMode stringToUfssMode(std::string option, std::string optarg); + void setBitblastAig(std::string option, bool arg); // theory/options_handlers.h - theory::TheoryOfMode stringToTheoryOfMode(std::string option, std::string optarg); void notifyUseTheoryList(std::string option); std::string handleUseTheoryList(std::string option, std::string optarg); - // printer/options_handlers.h - ModelFormatMode stringToModelFormatMode(std::string option, - std::string optarg); InstFormatMode stringToInstFormatMode(std::string option, std::string optarg); // decision/options_handlers.h - decision::DecisionMode stringToDecisionMode(std::string option, - std::string optarg); - decision::DecisionWeightInternal stringToDecisionWeightInternal( - std::string option, std::string optarg); + void setDecisionModeStopOnly(std::string option, DecisionMode m); /** * Throws a ModalException if this option is being set after final @@ -188,13 +90,6 @@ public: */ void notifyBeforeSearch(const std::string& option); void notifyDumpMode(std::string option); - SimplificationMode stringToSimplificationMode(std::string option, - std::string optarg); - ModelCoresMode stringToModelCoresMode(std::string option, std::string optarg); - BlockModelsMode stringToBlockModelsMode(std::string option, - std::string optarg); - SygusSolutionOutMode stringToSygusSolutionOutMode(std::string option, - std::string optarg); void setProduceAssertions(std::string option, bool value); void proofEnabledBuild(std::string option, bool value); void LFSCEnabledBuild(std::string option, bool value); @@ -244,56 +139,20 @@ public: Options* d_options; /* Help strings */ - static const std::string s_bitblastingModeHelp; - static const std::string s_bvSatSolverHelp; - static const std::string s_bvProofFormatHelp; - static const std::string s_bvOptimizeSatProofHelp; - static const std::string s_booleanTermConversionModeHelp; - static const std::string s_bvSlicerModeHelp; - static const std::string s_stringsProcessLoopModeHelp; - static const std::string s_regExpInterModeHelp; - static const std::string s_boolToBVModeHelp; - static const std::string s_cegqiFairModeHelp; - static const std::string s_decisionModeHelp; - static const std::string s_instFormatHelp ; - static const std::string s_instWhenHelp; - static const std::string s_iteLiftQuantHelp; - static const std::string s_literalMatchHelp; - static const std::string s_macrosQuantHelp; - static const std::string s_quantDSplitHelp; - static const std::string s_quantRepHelp; - static const std::string s_mbqiModeHelp; - static const std::string s_modelFormatHelp; - static const std::string s_prenexQuantModeHelp; - static const std::string s_qcfModeHelp; - static const std::string s_qcfWhenModeHelp; - static const std::string s_simplificationHelp; - static const std::string s_modelCoresHelp; - static const std::string s_blockModelsHelp; - static const std::string s_sygusSolutionOutModeHelp; - static const std::string s_cbqiBvIneqModeHelp; - static const std::string s_cegqiSingleInvHelp; - static const std::string s_cegqiSingleInvRconsHelp; - static const std::string s_cegisSampleHelp; - static const std::string s_sygusQueryDumpFileHelp; - static const std::string s_sygusFilterSolHelp; - static const std::string s_sygusInvTemplHelp; - static const std::string s_sygusActiveGenHelp; - static const std::string s_sygusUnifPiHelp; - static const std::string s_sygusGrammarConsHelp; - static const std::string s_termDbModeHelp; - static const std::string s_theoryOfModeHelp; - static const std::string s_triggerSelModeHelp; - static const std::string s_triggerActiveSelModeHelp; - static const std::string s_ufssModeHelp; - static const std::string s_userPatModeHelp; - static const std::string s_fmfBoundMinModeModeHelp; - static const std::string s_errorSelectionRulesHelp; - static const std::string s_arithPropagationModeHelp; - static const std::string s_arithUnateLemmasHelp; + static const std::string s_instFormatHelp; }; /* class OptionHandler */ +template +void OptionsHandler::checkSatSolverEnabled(std::string option, T m) +{ +#if !defined(CVC4_USE_CRYPTOMINISAT) && !defined(CVC4_USE_CADICAL) + std::stringstream ss; + ss << "option `" << option + << "' requires CVC4 to be built with CryptoMiniSat or CaDiCaL"; + throw OptionException(ss.str()); +#endif +} }/* CVC4::options namespace */ }/* CVC4 namespace */ diff --git a/src/options/options_public_functions.cpp b/src/options/options_public_functions.cpp index d3906e24d..6548150aa 100644 --- a/src/options/options_public_functions.cpp +++ b/src/options/options_public_functions.cpp @@ -43,7 +43,8 @@ InputLanguage Options::getInputLanguage() const { return (*this)[options::inputLanguage]; } -InstFormatMode Options::getInstFormatMode() const { +options::InstFormatMode Options::getInstFormatMode() const +{ return (*this)[options::instFormatMode]; } diff --git a/src/options/printer_modes.cpp b/src/options/printer_modes.cpp index b60dde467..db116dd05 100644 --- a/src/options/printer_modes.cpp +++ b/src/options/printer_modes.cpp @@ -19,33 +19,16 @@ namespace CVC4 { -std::ostream& operator<<(std::ostream& out, ModelFormatMode mode) { - switch(mode) { - case MODEL_FORMAT_MODE_DEFAULT: - out << "MODEL_FORMAT_MODE_DEFAULT"; - break; - case MODEL_FORMAT_MODE_TABLE: - out << "MODEL_FORMAT_MODE_TABLE"; - break; - default: - out << "ModelFormatMode:UNKNOWN![" << unsigned(mode) << "]"; - } - - return out; -} - -std::ostream& operator<<(std::ostream& out, InstFormatMode mode) { - switch(mode) { - case INST_FORMAT_MODE_DEFAULT: - out << "INST_FORMAT_MODE_DEFAULT"; - break; - case INST_FORMAT_MODE_SZS: - out << "INST_FORMAT_MODE_SZS"; - break; - default: - out << "InstFormatMode:UNKNOWN![" << unsigned(mode) << "]"; +std::ostream& operator<<(std::ostream& out, options::InstFormatMode mode) +{ + out << "InstFormatMode::"; + switch (mode) + { + case options::InstFormatMode::DEFAULT: out << "DEFAULT"; break; + case options::InstFormatMode::SZS: out << "SZS"; break; + default: out << "UNKNOWN![" << unsigned(mode) << "]"; } return out; } -}/* CVC4 namespace */ +} // namespace CVC4 diff --git a/src/options/printer_modes.h b/src/options/printer_modes.h index 79c57828b..10f8a4eac 100644 --- a/src/options/printer_modes.h +++ b/src/options/printer_modes.h @@ -23,26 +23,23 @@ #include namespace CVC4 { +namespace options { -/** Enumeration of model_format modes (how to print models from get-model command). */ -enum CVC4_PUBLIC ModelFormatMode { +/** Enumeration of inst_format modes (how to print models from get-model + * command). */ +enum class CVC4_PUBLIC InstFormatMode +{ /** default mode (print expressions in the output language format) */ - MODEL_FORMAT_MODE_DEFAULT, - /** print functional values in a table format */ - MODEL_FORMAT_MODE_TABLE, -}; - -/** Enumeration of inst_format modes (how to print models from get-model command). */ -enum CVC4_PUBLIC InstFormatMode { - /** default mode (print expressions in the output language format) */ - INST_FORMAT_MODE_DEFAULT, + DEFAULT, /** print as SZS proof */ - INST_FORMAT_MODE_SZS, + SZS, }; -std::ostream& operator<<(std::ostream& out, ModelFormatMode mode) CVC4_PUBLIC; -std::ostream& operator<<(std::ostream& out, InstFormatMode mode) CVC4_PUBLIC; +} // namespace options + +std::ostream& operator<<(std::ostream& out, + options::InstFormatMode mode) CVC4_PUBLIC; -}/* CVC4 namespace */ +} // namespace CVC4 #endif /* CVC4__PRINTER__MODEL_FORMAT_H */ diff --git a/src/options/printer_options.toml b/src/options/printer_options.toml index c1871259c..db2f3d6c9 100644 --- a/src/options/printer_options.toml +++ b/src/options/printer_options.toml @@ -7,20 +7,34 @@ header = "options/printer_options.h" category = "regular" long = "model-format=MODE" type = "ModelFormatMode" - default = "MODEL_FORMAT_MODE_DEFAULT" - handler = "stringToModelFormatMode" - includes = ["options/printer_modes.h"] + default = "DEFAULT" help = "print format mode for models, see --model-format=help" + help_mode = "Model format modes." +[[option.mode.DEFAULT]] + name = "default" + help = "Print model as expressions in the output language format." +[[option.mode.TABLE]] + name = "table" + help = "Print functional expressions over finite domains in a table format." [[option]] name = "instFormatMode" category = "regular" long = "inst-format=MODE" type = "InstFormatMode" - default = "INST_FORMAT_MODE_DEFAULT" + default = "InstFormatMode::DEFAULT" handler = "stringToInstFormatMode" includes = ["options/printer_modes.h"] help = "print format mode for instantiations, see --inst-format=help" +# InstFormatMode is currently exported as public so we can't auto genenerate +# the enum. +# help_mode = "Inst format modes." +#[[option.mode.DEFAULT]] +# name = "default" +# help = "Print instantiations as a list in the output language format." +#[[option.mode.SZS]] +# name = "szs" +# help = "Print instantiations as SZS compliant proof." [[option]] name = "flattenHOChains" diff --git a/src/options/quantifiers_modes.cpp b/src/options/quantifiers_modes.cpp deleted file mode 100644 index a1d012aa5..000000000 --- a/src/options/quantifiers_modes.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/********************* */ -/*! \file quantifiers_modes.cpp - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters, Andrew Reynolds - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ -#include "options/quantifiers_modes.h" - -#include - -namespace CVC4 { - -std::ostream& operator<<(std::ostream& out, theory::quantifiers::InstWhenMode mode) { - switch(mode) { - case theory::quantifiers::INST_WHEN_PRE_FULL: - out << "INST_WHEN_PRE_FULL"; - break; - case theory::quantifiers::INST_WHEN_FULL: - out << "INST_WHEN_FULL"; - break; - case theory::quantifiers::INST_WHEN_FULL_LAST_CALL: - out << "INST_WHEN_FULL_LAST_CALL"; - break; - case theory::quantifiers::INST_WHEN_LAST_CALL: - out << "INST_WHEN_LAST_CALL"; - break; - default: - out << "InstWhenMode!UNKNOWN"; - } - - return out; -} - -std::ostream& operator<<(std::ostream& out, theory::quantifiers::LiteralMatchMode mode) { - switch(mode) { - case theory::quantifiers::LITERAL_MATCH_NONE: - out << "LITERAL_MATCH_NONE"; - break; - case theory::quantifiers::LITERAL_MATCH_USE: - out << "LITERAL_MATCH_USE"; - break; - case theory::quantifiers::LITERAL_MATCH_AGG_PREDICATE: - out << "LITERAL_MATCH_AGG_PREDICATE"; - break; - case theory::quantifiers::LITERAL_MATCH_AGG: - out << "LITERAL_MATCH_AGG"; - break; - default: - out << "LiteralMatchMode!UNKNOWN"; - } - - return out; -} - -std::ostream& operator<<(std::ostream& out, theory::quantifiers::MbqiMode mode) { - switch(mode) { - case theory::quantifiers::MBQI_NONE: - out << "MBQI_NONE"; - break; - case theory::quantifiers::MBQI_FMC: - out << "MBQI_FMC"; - break; - case theory::quantifiers::MBQI_TRUST: - out << "MBQI_TRUST"; - break; - default: - out << "MbqiMode!UNKNOWN"; - } - return out; -} - -}/* CVC4 namespace */ diff --git a/src/options/quantifiers_modes.h b/src/options/quantifiers_modes.h deleted file mode 100644 index 1a256b0bc..000000000 --- a/src/options/quantifiers_modes.h +++ /dev/null @@ -1,370 +0,0 @@ -/********************* */ -/*! \file quantifiers_modes.h - ** \verbatim - ** Top contributors (to current version): - ** Andrew Reynolds, Tim King, Morgan Deters - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "cvc4_public.h" - -#ifndef CVC4__BASE__QUANTIFIERS_MODES_H -#define CVC4__BASE__QUANTIFIERS_MODES_H - -#include - -namespace CVC4 { -namespace theory { -namespace quantifiers { - -enum InstWhenMode { - /** Apply instantiation round before full effort (possibly at standard effort) */ - INST_WHEN_PRE_FULL, - /** Apply instantiation round at full effort or above */ - INST_WHEN_FULL, - /** Apply instantiation round at full effort, after all other theories finish, or above */ - INST_WHEN_FULL_DELAY, - /** Apply instantiation round at full effort half the time, and last call always */ - INST_WHEN_FULL_LAST_CALL, - /** Apply instantiation round at full effort after all other theories finish half the time, and last call always */ - INST_WHEN_FULL_DELAY_LAST_CALL, - /** Apply instantiation round at last call only */ - INST_WHEN_LAST_CALL, -}; - -enum LiteralMatchMode { - /** Do not consider polarity of patterns */ - LITERAL_MATCH_NONE, - /** Conservatively consider polarity of patterns */ - LITERAL_MATCH_USE, - /** Aggressively consider polarity of Boolean predicates */ - LITERAL_MATCH_AGG_PREDICATE, - /** Aggressively consider polarity of all terms */ - LITERAL_MATCH_AGG, -}; - -enum MbqiMode { - /** no mbqi */ - MBQI_NONE, - /** default, mbqi from Section 5.4.2 of AJR thesis */ - MBQI_FMC, - /** mbqi trust (produce no instantiations) */ - MBQI_TRUST, -}; - -enum QcfWhenMode { - /** default, apply at full effort */ - QCF_WHEN_MODE_DEFAULT, - /** apply at last call */ - QCF_WHEN_MODE_LAST_CALL, - /** apply at standard effort */ - QCF_WHEN_MODE_STD, - /** apply based on heuristics */ - QCF_WHEN_MODE_STD_H, -}; - -enum QcfMode { - /** default, use qcf for conflicts only */ - QCF_CONFLICT_ONLY, - /** use qcf for conflicts and propagations */ - QCF_PROP_EQ, - /** use qcf for conflicts, propagations and heuristic instantiations */ - QCF_PARTIAL, -}; - -/** User pattern mode. -* -* These modes determine how user provided patterns (triggers) are -* used during E-matching. The modes vary on when instantiation based on -* user-provided triggers is combined with instantiation based on -* automatically selected triggers. -*/ -enum UserPatMode -{ - /** First instantiate based on user-provided triggers. If no instantiations - * are produced, use automatically selected triggers. - */ - USER_PAT_MODE_USE, - /** Default, if triggers are supplied for a quantifier, use only those. */ - USER_PAT_MODE_TRUST, - /** Resort to user triggers only when no instantiations are - * produced by automatically selected triggers - */ - USER_PAT_MODE_RESORT, - /** Ignore user patterns. */ - USER_PAT_MODE_IGNORE, - /** Interleave use/resort modes for quantified formulas with user patterns. */ - USER_PAT_MODE_INTERLEAVE, -}; - -/** Trigger selection mode. -* -* These modes are used for determining which terms to select -* as triggers for quantified formulas, when necessary, during E-matching. -* In the following, note the following terminology. A trigger is a set of terms, -* where a single trigger is a singleton set and a multi-trigger is a set of more -* than one term. -* -* TRIGGER_SEL_MIN selects single triggers of minimal term size. -* TRIGGER_SEL_MAX selects single triggers of maximal term size. -* -* For example, consider the quantified formula : -* forall xy. P( f( g( x, y ) ) ) V Q( f( x ), y ) -* -* TRIGGER_SEL_MIN will select g( x, y ) and Q( f( x ), y ). -* TRIGGER_SEL_MAX will select P( f( g( x ) ) ) and Q( f( x ), y ). -* -* The remaining three trigger selections make a difference for multi-triggers -* only. For quantified formulas that require multi-triggers, we build a set of -* partial triggers that don't contain all variables, call this set S. Then, -* multi-triggers are built by taking a random subset of S that collectively -* contains all variables. -* -* Consider the quantified formula : -* forall xyz. P( h( x ), y ) V Q( y, z ) -* -* For TRIGGER_SEL_ALL and TRIGGER_SEL_MIN_SINGLE_ALL, -* S = { h( x ), P( h( x ), y ), Q( y, z ) }. -* For TRIGGER_SEL_MIN_SINGLE_MAX, -* S = { P( h( x ), y ), Q( y, z ) }. -* -* Furthermore, TRIGGER_SEL_MIN_SINGLE_ALL and TRIGGER_SEL_MIN_SINGLE_MAX, when -* selecting single triggers, only select terms of minimal size. -*/ -enum TriggerSelMode { - /** only consider minimal terms for triggers */ - TRIGGER_SEL_MIN, - /** only consider maximal terms for triggers */ - TRIGGER_SEL_MAX, - /** consider minimal terms for single triggers, maximal for non-single */ - TRIGGER_SEL_MIN_SINGLE_MAX, - /** consider minimal terms for single triggers, all for non-single */ - TRIGGER_SEL_MIN_SINGLE_ALL, - /** consider all terms for triggers */ - TRIGGER_SEL_ALL, -}; - -enum TriggerActiveSelMode { - /** always use all triggers */ - TRIGGER_ACTIVE_SEL_ALL, - /** only use triggers with minimal # of ground terms */ - TRIGGER_ACTIVE_SEL_MIN, - /** only use triggers with maximal # of ground terms */ - TRIGGER_ACTIVE_SEL_MAX, -}; - -enum CVC4_PUBLIC PrenexQuantMode { - /** do not prenex */ - PRENEX_QUANT_NONE, - /** prenex same sign quantifiers */ - PRENEX_QUANT_SIMPLE, - /** aggressive prenex, disjunctive prenex normal form */ - PRENEX_QUANT_DISJ_NORMAL, - /** prenex normal form */ - PRENEX_QUANT_NORMAL, -}; - -enum TermDbMode { - /** consider all terms in master equality engine */ - TERM_DB_ALL, - /** consider only relevant terms */ - TERM_DB_RELEVANT, -}; - -enum IteLiftQuantMode { - /** do not lift ITEs in quantified formulas */ - ITE_LIFT_QUANT_MODE_NONE, - /** only lift ITEs in quantified formulas if reduces the term size */ - ITE_LIFT_QUANT_MODE_SIMPLE, - /** lift ITEs */ - ITE_LIFT_QUANT_MODE_ALL, -}; - -enum CbqiBvIneqMode -{ - /** solve for inequalities using slack values in model */ - CBQI_BV_INEQ_EQ_SLACK, - /** solve for inequalities using boundary points */ - CBQI_BV_INEQ_EQ_BOUNDARY, - /** solve for inequalities directly, using side conditions */ - CBQI_BV_INEQ_KEEP, -}; - -enum CegqiSingleInvMode { - /** do not use single invocation techniques */ - CEGQI_SI_MODE_NONE, - /** use single invocation techniques */ - CEGQI_SI_MODE_USE, - /** always use single invocation techniques */ - CEGQI_SI_MODE_ALL, -}; - -/** Solution reconstruction modes for single invocation conjectures - * - * These modes indicate the policy when CVC4 solves a synthesis conjecture using - * single invocation techniques for a sygus problem with a user-specified - * grammar. - */ -enum CegqiSingleInvRconsMode -{ - /** - * Do not try to reconstruct solutions to single invocation conjectures. With - * this mode, solutions produced by CVC4 may violate grammar restrictions. - */ - CEGQI_SI_RCONS_MODE_NONE, - /** - * Try to reconstruct solution to single invocation conjectures in an - * incomplete (fail fast) way. - */ - CEGQI_SI_RCONS_MODE_TRY, - /** - * Reconstruct solutions to single invocation conjectures, but fail if we - * reach an upper limit on number of iterations in the enumeration - */ - CEGQI_SI_RCONS_MODE_ALL_LIMIT, - /** - * Reconstruct solutions to single invocation conjectures. This method - * relies on an expensive enumeration technique which only terminates when - * we succesfully reconstruct the solution, although it may not terminate. - */ - CEGQI_SI_RCONS_MODE_ALL, -}; - -enum CegisSampleMode -{ - /** do not use samples for CEGIS */ - CEGIS_SAMPLE_NONE, - /** use samples for CEGIS */ - CEGIS_SAMPLE_USE, - /** trust samples for CEGQI */ - CEGIS_SAMPLE_TRUST, -}; - -enum SygusInvTemplMode { - /** synthesize I( x ) */ - SYGUS_INV_TEMPL_MODE_NONE, - /** synthesize ( pre( x ) V I( x ) ) */ - SYGUS_INV_TEMPL_MODE_PRE, - /** synthesize ( post( x ) ^ I( x ) ) */ - SYGUS_INV_TEMPL_MODE_POST, -}; - -enum SygusActiveGenMode -{ - /** do not use actively-generated enumerators */ - SYGUS_ACTIVE_GEN_NONE, - /** use basic enumeration for actively-generated enumerators */ - SYGUS_ACTIVE_GEN_ENUM_BASIC, - /** use optimized enumeration actively-generated enumerators */ - SYGUS_ACTIVE_GEN_ENUM, - /** use variable-agnostic enumerators */ - SYGUS_ACTIVE_GEN_VAR_AGNOSTIC, - /** internally decide the best policy for each enumerator */ - SYGUS_ACTIVE_GEN_AUTO, -}; - -enum SygusQueryDumpFilesMode -{ - /** do not dump query files */ - SYGUS_QUERY_DUMP_NONE, - /** dump all query files */ - SYGUS_QUERY_DUMP_ALL, - /** dump query files that were not solved by the subsolver */ - SYGUS_QUERY_DUMP_UNSOLVED, -}; - -enum SygusFilterSolMode -{ - /** do not filter solutions */ - SYGUS_FILTER_SOL_NONE, - /** filter logically stronger solutions */ - SYGUS_FILTER_SOL_STRONG, - /** filter logically weaker solutions */ - SYGUS_FILTER_SOL_WEAK, -}; - -enum SygusGrammarConsMode -{ - /** - * Use simple default SyGuS grammar construction (no symbolic terms or - * constants). - */ - SYGUS_GCONS_SIMPLE, - /** Use "any constant" constructors in default SyGuS grammar construction. */ - SYGUS_GCONS_ANY_CONST, - /** - * When applicable, use constructors that encode any term using "any constant" - * constructors. This construction uses sum-of-monomials for arithmetic - * grammars. - */ - SYGUS_GCONS_ANY_TERM, - /** - * When applicable, use constructors that encode any term using "any constant" - * constructors in a way that prefers conciseness over generality. This - * construction uses polynomials for arithmetic grammars. - */ - SYGUS_GCONS_ANY_TERM_CONCISE, -}; - -enum MacrosQuantMode { - /** infer all definitions */ - MACROS_QUANT_MODE_ALL, - /** infer ground definitions */ - MACROS_QUANT_MODE_GROUND, - /** infer ground uf definitions */ - MACROS_QUANT_MODE_GROUND_UF, -}; - -enum QuantDSplitMode { - /** never do quantifiers splitting */ - QUANT_DSPLIT_MODE_NONE, - /** default */ - QUANT_DSPLIT_MODE_DEFAULT, - /** do quantifiers splitting aggressively */ - QUANT_DSPLIT_MODE_AGG, -}; - -enum QuantRepMode { - /** let equality engine choose representatives */ - QUANT_REP_MODE_EE, - /** default, choose representatives that appear first */ - QUANT_REP_MODE_FIRST, - /** choose representatives that have minimal depth */ - QUANT_REP_MODE_DEPTH, -}; - -/** - * Modes for piecewise-independent unification for synthesis (see Barbosa et al - * FMCAD 2019). - */ -enum SygusUnifPiMode -{ - /** do not do piecewise-independent unification for synthesis */ - SYGUS_UNIF_PI_NONE, - /** use (finite-model) complete piecewise-independent unification */ - SYGUS_UNIF_PI_COMPLETE, - /** use approach based on condition enumeration for piecewise-independent - unification */ - SYGUS_UNIF_PI_CENUM, - /** use approach based on condition enumeration with information gain - heuristics for piecewise-independent unification */ - SYGUS_UNIF_PI_CENUM_IGAIN, -}; - -}/* CVC4::theory::quantifiers namespace */ -}/* CVC4::theory namespace */ - -std::ostream& operator<<(std::ostream& out, theory::quantifiers::InstWhenMode mode) CVC4_PUBLIC; - -}/* CVC4 namespace */ - -#endif /* CVC4__BASE__QUANTIFIERS_MODES_H */ diff --git a/src/options/quantifiers_options.toml b/src/options/quantifiers_options.toml index d37c9db83..95ec636ca 100644 --- a/src/options/quantifiers_options.toml +++ b/src/options/quantifiers_options.toml @@ -36,11 +36,22 @@ header = "options/quantifiers_options.h" name = "prenexQuant" category = "regular" long = "prenex-quant=MODE" - type = "CVC4::theory::quantifiers::PrenexQuantMode" - default = "CVC4::theory::quantifiers::PRENEX_QUANT_SIMPLE" - handler = "stringToPrenexQuantMode" - includes = ["options/quantifiers_modes.h"] + type = "PrenexQuantMode" + default = "SIMPLE" help = "prenex mode for quantified formulas" + help_mode = "Prenex quantifiers modes." +[[option.mode.NONE]] + name = "none" + help = "Do no prenex nested quantifiers." +[[option.mode.SIMPLE]] + name = "simple" + help = "Do simple prenexing of same sign quantifiers." +[[option.mode.DISJ_NORMAL]] + name = "dnorm" + help = "Prenex to disjunctive prenex normal form." +[[option.mode.NORMAL]] + name = "norm" + help = "Prenex to prenex normal form." [[option]] name = "prenexQuantUser" @@ -84,11 +95,19 @@ header = "options/quantifiers_options.h" name = "iteLiftQuant" category = "regular" long = "ite-lift-quant=MODE" - type = "CVC4::theory::quantifiers::IteLiftQuantMode" - default = "CVC4::theory::quantifiers::ITE_LIFT_QUANT_MODE_SIMPLE" - handler = "stringToIteLiftQuantMode" - includes = ["options/quantifiers_modes.h"] + type = "IteLiftQuantMode" + default = "SIMPLE" help = "ite lifting mode for quantified formulas" + help_mode = "ITE lifting modes for quantified formulas." +[[option.mode.NONE]] + name = "none" + help = "Do not lift if-then-else in quantified formulas." +[[option.mode.SIMPLE]] + name = "simple" + help = "Lift if-then-else in quantified formulas if results in smaller term size." +[[option.mode.ALL]] + name = "all" + help = "Lift if-then-else in quantified formulas." [[option]] name = "condVarSplitQuant" @@ -200,11 +219,16 @@ header = "options/quantifiers_options.h" name = "termDbMode" category = "regular" long = "term-db-mode=MODE" - type = "CVC4::theory::quantifiers::TermDbMode" - default = "CVC4::theory::quantifiers::TERM_DB_ALL" - handler = "stringToTermDbMode" - includes = ["options/quantifiers_modes.h"] + type = "TermDbMode" + default = "ALL" help = "which ground terms to consider for instantiation" + help_mode = "Modes for terms included in the quantifiers term database." +[[option.mode.ALL]] + name = "all" + help = "Quantifiers module considers all ground terms." +[[option.mode.RELEVANT]] + name = "relevant" + help = "Quantifiers module considers only ground terms connected to current assertions." [[option]] name = "registerQuantBodyTerms" @@ -310,35 +334,105 @@ header = "options/quantifiers_options.h" read_only = true help = "implementation of multi triggers where maximum number of instantiations is linear wrt number of ground terms" +# Trigger selection mode. +# +# These modes are used for determining which terms to select +# as triggers for quantified formulas, when necessary, during E-matching. +# In the following, note the following terminology. A trigger is a set of terms, +# where a single trigger is a singleton set and a multi-trigger is a set of more +# than one term. +# +# MIN selects single triggers of minimal term size. +# MAX selects single triggers of maximal term size. +# +# For example, consider the quantified formula : +# forall xy. P( f( g( x, y ) ) ) V Q( f( x ), y ) +# +# MIN will select g( x, y ) and Q( f( x ), y ). +# MAX will select P( f( g( x ) ) ) and Q( f( x ), y ). +# +# The remaining three trigger selections make a difference for multi-triggers +# only. For quantified formulas that require multi-triggers, we build a set of +# partial triggers that don't contain all variables, call this set S. Then, +# multi-triggers are built by taking a random subset of S that collectively +# contains all variables. +# +# Consider the quantified formula : +# forall xyz. P( h( x ), y ) V Q( y, z ) +# +# For ALL and MIN_SINGLE_ALL, +# S = { h( x ), P( h( x ), y ), Q( y, z ) }. +# For MIN_SINGLE_MAX, +# S = { P( h( x ), y ), Q( y, z ) }. +# +# Furthermore, MIN_SINGLE_ALL and MIN_SINGLE_MAX, when +# selecting single triggers, only select terms of minimal size. +# [[option]] name = "triggerSelMode" category = "regular" long = "trigger-sel=MODE" - type = "CVC4::theory::quantifiers::TriggerSelMode" - default = "CVC4::theory::quantifiers::TRIGGER_SEL_MIN" - handler = "stringToTriggerSelMode" - includes = ["options/quantifiers_modes.h"] + type = "TriggerSelMode" + default = "MIN" help = "selection mode for triggers" + help_mode = "Trigger selection modes." +[[option.mode.MIN]] + name = "min" + help = "Consider only minimal subterms that meet criteria for triggers." +[[option.mode.MAX]] + name = "max" + help = "Consider only maximal subterms that meet criteria for triggers." +[[option.mode.MIN_SINGLE_MAX]] + name = "min-s-max" + help = "Consider only minimal subterms that meet criteria for single triggers, maximal otherwise." +[[option.mode.MIN_SINGLE_ALL]] + name = "min-s-all" + help = "Consider only minimal subterms that meet criteria for single triggers, all otherwise." +[[option.mode.ALL]] + name = "all" + help = "Consider all subterms that meet criteria for triggers." [[option]] name = "triggerActiveSelMode" category = "regular" long = "trigger-active-sel=MODE" - type = "CVC4::theory::quantifiers::TriggerActiveSelMode" - default = "CVC4::theory::quantifiers::TRIGGER_ACTIVE_SEL_ALL" - handler = "stringToTriggerActiveSelMode" - includes = ["options/quantifiers_modes.h"] + type = "TriggerActiveSelMode" + default = "ALL" help = "selection mode to activate triggers" + help_mode = "Trigger active selection modes." +[[option.mode.ALL]] + name = "all" + help = "Make all triggers active." +[[option.mode.MIN]] + name = "min" + help = "Activate triggers with minimal ground terms." +[[option.mode.MAX]] + name = "max" + help = "Activate triggers with maximal ground terms." [[option]] name = "userPatternsQuant" category = "regular" long = "user-pat=MODE" - type = "CVC4::theory::quantifiers::UserPatMode" - default = "CVC4::theory::quantifiers::USER_PAT_MODE_TRUST" - handler = "stringToUserPatMode" - includes = ["options/quantifiers_modes.h"] + type = "UserPatMode" + default = "TRUST" help = "policy for handling user-provided patterns for quantifier instantiation" + help_mode = "These modes determine how user provided patterns (triggers) are used during E-matching. The modes vary on when instantiation based on user-provided triggers is combined with instantiation based on automatically selected triggers." +[[option.mode.USE]] + name = "use" + help = "Use both user-provided and auto-generated patterns when patterns are provided for a quantified formula." +[[option.mode.TRUST]] + name = "trust" + help = "When provided, use only user-provided patterns for a quantified formula." +[[option.mode.RESORT]] + name = "resort" + help = "Use user-provided patterns only after auto-generated patterns saturate." +[[option.mode.IGNORE]] + name = "ignore" + help = "Ignore user-provided patterns." +[[option.mode.INTERLEAVE]] + name = "interleave" + help = "Alternate between use/resort." [[option]] name = "incrementTriggers" @@ -353,12 +447,29 @@ header = "options/quantifiers_options.h" name = "instWhenMode" category = "regular" long = "inst-when=MODE" - type = "CVC4::theory::quantifiers::InstWhenMode" - default = "CVC4::theory::quantifiers::INST_WHEN_FULL_LAST_CALL" - handler = "stringToInstWhenMode" + type = "InstWhenMode" + default = "FULL_LAST_CALL" predicates = ["checkInstWhenMode"] - includes = ["options/quantifiers_modes.h"] help = "when to apply instantiation" + help_mode = "Instantiation modes." +[[option.mode.PRE_FULL]] + name = "pre-full" + help = "Run instantiation round before full effort (possibly at standard effort)." +[[option.mode.FULL]] + name = "full" + help = "Run instantiation round at full effort, before theory combination." +[[option.mode.FULL_DELAY]] + name = "full-delay" + help = "Run instantiation round at full effort, before theory combination, after all other theories have finished." +[[option.mode.FULL_LAST_CALL]] + name = "full-last-call" + help = "Alternate running instantiation rounds at full effort and last call. In other words, interleave instantiation and theory combination." +[[option.mode.FULL_DELAY_LAST_CALL]] + name = "full-delay-last-call" + help = "Alternate running instantiation rounds at full effort after all other theories have finished, and last call." +[[option.mode.LAST_CALL]] + name = "last-call" + help = "Run instantiation at last call effort, after theory combination and and theories report sat." [[option]] name = "instWhenStrictInterleave" @@ -414,11 +525,19 @@ header = "options/quantifiers_options.h" name = "quantRepMode" category = "regular" long = "quant-rep-mode=MODE" - type = "CVC4::theory::quantifiers::QuantRepMode" - default = "CVC4::theory::quantifiers::QUANT_REP_MODE_FIRST" - handler = "stringToQuantRepMode" - includes = ["options/quantifiers_modes.h"] + type = "QuantRepMode" + default = "FIRST" help = "selection mode for representatives in quantifiers engine" + help_mode = "Modes for quantifiers representative selection." +[[option.mode.EE]] + name = "ee" + help = "Let equality engine choose representatives." +[[option.mode.FIRST]] + name = "first" + help = "Choose terms that appear first." +[[option.mode.DEPTH]] + name = "depth" + help = "Choose terms that are of minimal depth." [[option]] name = "fullSaturateQuant" @@ -459,13 +578,23 @@ header = "options/quantifiers_options.h" name = "literalMatchMode" category = "regular" long = "literal-matching=MODE" - type = "CVC4::theory::quantifiers::LiteralMatchMode" - default = "CVC4::theory::quantifiers::LITERAL_MATCH_USE" - handler = "stringToLiteralMatchMode" - predicates = ["checkLiteralMatchMode"] - includes = ["options/quantifiers_modes.h"] + type = "LiteralMatchMode" + default = "USE" read_only = true help = "choose literal matching mode" + help_mode = "Literal match modes." +[[option.mode.NONE]] + name = "none" + help = "Do not use literal matching." +[[option.mode.USE]] + name = "use" + help = "Consider phase requirements of triggers conservatively. For example, the trigger P( x ) in forall( x ). ( P( x ) V ~Q( x ) ) will not be matched with terms in the equivalence class of true, and likewise Q( x ) will not be matched terms in the equivalence class of false. Extends to equality." +[[option.mode.AGG_PREDICATE]] + name = "agg-predicate" + help = "Consider phase requirements aggressively for predicates. In the above example, only match P( x ) with terms that are in the equivalence class of false." +[[option.mode.AGG]] + name = "agg" + help = "Consider the phase requirements aggressively for all triggers." ### Finite model finding options @@ -516,12 +645,19 @@ header = "options/quantifiers_options.h" name = "mbqiMode" category = "regular" long = "mbqi=MODE" - type = "CVC4::theory::quantifiers::MbqiMode" - default = "CVC4::theory::quantifiers::MBQI_FMC" - handler = "stringToMbqiMode" - predicates = ["checkMbqiMode"] - includes = ["options/quantifiers_modes.h"] + type = "MbqiMode" + default = "FMC" help = "choose mode for model-based quantifier instantiation" + help_mode = "Model-based quantifier instantiation modes." +[[option.mode.NONE]] + name = "none" + help = "Disable model-based quantifier instantiation." +[[option.mode.FMC]] + name = "fmc" + help = "Use algorithm from Section 5.4.2 of thesis Finite Model Finding in Satisfiability Modulo Theories." +[[option.mode.TRUST]] + name = "trust" + help = "Do not instantiate quantified formulas (incomplete technique)." [[option]] name = "fmfOneInstPerRound" @@ -638,23 +774,42 @@ header = "options/quantifiers_options.h" name = "qcfMode" category = "regular" long = "quant-cf-mode=MODE" - type = "CVC4::theory::quantifiers::QcfMode" - default = "CVC4::theory::quantifiers::QCF_PROP_EQ" - handler = "stringToQcfMode" - includes = ["options/quantifiers_modes.h"] + type = "QcfMode" + default = "PROP_EQ" read_only = true help = "what effort to apply conflict find mechanism" + help_mode = "Quantifier conflict find modes." +[[option.mode.CONFLICT_ONLY]] + name = "conflict" + help = "Apply QCF algorithm to find conflicts only." +[[option.mode.PROP_EQ]] + name = "prop-eq" + help = "Apply QCF algorithm to propagate equalities as well as conflicts." +[[option.mode.PARTIAL]] + name = "partial" + help = "Use QCF for conflicts, propagations and heuristic instantiations." [[option]] name = "qcfWhenMode" category = "regular" long = "quant-cf-when=MODE" - type = "CVC4::theory::quantifiers::QcfWhenMode" - default = "CVC4::theory::quantifiers::QCF_WHEN_MODE_DEFAULT" - handler = "stringToQcfWhenMode" - includes = ["options/quantifiers_modes.h"] + type = "QcfWhenMode" + default = "DEFAULT" read_only = true help = "when to invoke conflict find mechanism for quantifiers" + help_mode = "Quantifier conflict find modes." +[[option.mode.DEFAULT]] + name = "default" + help = "Default, apply conflict finding at full effort." +[[option.mode.LAST_CALL]] + name = "last-call" + help = "Apply conflict finding at last call, after theory combination and and all theories report sat." +[[option.mode.STD]] + name = "std" + help = "Apply conflict finding at standard effort." +[[option.mode.STD_H]] + name = "std-h" + help = "Apply conflict finding at standard effort when heuristic says to." [[option]] name = "qcfTConstraint" @@ -888,11 +1043,19 @@ header = "options/quantifiers_options.h" name = "cegqiSingleInvMode" category = "regular" long = "cegqi-si=MODE" - type = "CVC4::theory::quantifiers::CegqiSingleInvMode" - default = "CVC4::theory::quantifiers::CEGQI_SI_MODE_NONE" - handler = "stringToCegqiSingleInvMode" - includes = ["options/quantifiers_modes.h"] + type = "CegqiSingleInvMode" + default = "NONE" help = "mode for processing single invocation synthesis conjectures" + help_mode = "Modes for single invocation techniques." +[[option.mode.NONE]] + name = "none" + help = "Do not use single invocation techniques." +[[option.mode.USE]] + name = "use" + help = "Use single invocation techniques only if grammar is not restrictive." +[[option.mode.ALL]] + name = "all" + help = "Always use single invocation techniques." [[option]] name = "cegqiSingleInvPartial" @@ -903,15 +1066,32 @@ header = "options/quantifiers_options.h" read_only = true help = "combined techniques for synthesis conjectures that are partially single invocation" +# Solution reconstruction modes for single invocation conjectures +# +# These modes indicate the policy when CVC4 solves a synthesis conjecture using +# single invocation techniques for a sygus problem with a user-specified +# grammar. +# [[option]] name = "cegqiSingleInvReconstruct" category = "regular" long = "cegqi-si-rcons=MODE" - type = "CVC4::theory::quantifiers::CegqiSingleInvRconsMode" - default = "CVC4::theory::quantifiers::CEGQI_SI_RCONS_MODE_ALL_LIMIT" - handler = "stringToCegqiSingleInvRconsMode" - includes = ["options/quantifiers_modes.h"] + type = "CegqiSingleInvRconsMode" + default = "ALL_LIMIT" help = "policy for reconstructing solutions for single invocation conjectures" + help_mode = "Modes for reconstruction solutions while using single invocation techniques." +[[option.mode.NONE]] + name = "none" + help = "Do not try to reconstruct solutions in the original (user-provided) grammar when using single invocation techniques. In this mode, solutions produced by CVC4 may violate grammar restrictions." +[[option.mode.TRY]] + name = "try" + help = "Try to reconstruct solutions in the original grammar when using single invocation techniques in an incomplete (fail-fast) manner." +[[option.mode.ALL_LIMIT]] + name = "all-limit" + help = "Try to reconstruct solutions in the original grammar, but termintate if a maximum number of rounds for reconstruction is exceeded." +[[option.mode.ALL]] + name = "all" + help = "Try to reconstruct solutions in the original grammar. In this mode, we do not terminate until a solution is successfully reconstructed." [[option]] name = "cegqiSingleInvReconstructLimit" @@ -949,16 +1129,30 @@ header = "options/quantifiers_options.h" read_only = true help = "abort if constant repair techniques are not applicable" +# Modes for piecewise-independent unification for synthesis (see Barbosa et al +# FMCAD 2019). +# [[option]] name = "sygusUnifPi" category = "regular" long = "sygus-unif-pi=MODE" - type = "CVC4::theory::quantifiers::SygusUnifPiMode" - default = "CVC4::theory::quantifiers::SYGUS_UNIF_PI_NONE" - handler = "stringToSygusUnifPiMode" - includes = ["options/quantifiers_modes.h"] + type = "SygusUnifPiMode" + default = "NONE" read_only = true help = "mode for synthesis via piecewise-indepedent unification" + help_mode = "Modes for piecewise-independent unification." +[[option.mode.NONE]] + name = "none" + help = "Do not use piecewise-independent unification." +[[option.mode.COMPLETE]] + name = "complete" + help = "Use complete approach for piecewise-independent unification (see Section 3 of Barbosa et al FMCAD 2019)" +[[option.mode.CENUM]] + name = "cond-enum" + help = "Use unconstrained condition enumeration for piecewise-independent unification (see Section 4 of Barbosa et al FMCAD 2019)." +[[option.mode.CENUM_IGAIN]] + name = "cond-enum-igain" + help = "Same as cond-enum, but additionally uses an information gain heuristic when doing decision tree learning." [[option]] name = "sygusUnifShuffleCond" @@ -1020,12 +1214,26 @@ header = "options/quantifiers_options.h" name = "sygusActiveGenMode" category = "regular" long = "sygus-active-gen=MODE" - type = "CVC4::theory::quantifiers::SygusActiveGenMode" - default = "CVC4::theory::quantifiers::SYGUS_ACTIVE_GEN_AUTO" - handler = "stringToSygusActiveGenMode" - includes = ["options/quantifiers_modes.h"] + type = "SygusActiveGenMode" + default = "AUTO" read_only = true help = "mode for actively-generated sygus enumerators" + help_mode = "Modes for actively-generated sygus enumerators." +[[option.mode.NONE]] + name = "none" + help = "Do not use actively-generated sygus enumerators." +[[option.mode.ENUM_BASIC]] + name = "basic" + help = "Use basic type enumerator for actively-generated sygus enumerators." +[[option.mode.ENUM]] + name = "enum" + help = "Use optimized enumerator for actively-generated sygus enumerators." +[[option.mode.VAR_AGNOSTIC]] + name = "var-agnostic" + help = "Use sygus solver to enumerate terms that are agnostic to variables." +[[option.mode.AUTO]] + name = "auto" + help = "Internally decide the best policy for each enumerator." [[option]] name = "sygusActiveGenEnumConsts" @@ -1075,21 +1283,40 @@ header = "options/quantifiers_options.h" name = "sygusGrammarConsMode" category = "regular" long = "sygus-grammar-cons=MODE" - type = "CVC4::theory::quantifiers::SygusGrammarConsMode" - default = "CVC4::theory::quantifiers::SYGUS_GCONS_SIMPLE" - handler = "stringToSygusGrammarConsMode" - includes = ["options/quantifiers_modes.h"] + type = "SygusGrammarConsMode" + default = "SIMPLE" help = "mode for SyGuS grammar construction" + help_mode = "Modes for default SyGuS grammars." +[[option.mode.SIMPLE]] + name = "simple" + help = "Use simple grammar construction (no symbolic terms or constants)." +[[option.mode.ANY_CONST]] + name = "any-const" + help = "Use symoblic constant constructors." +[[option.mode.ANY_TERM]] + name = "any-term" + help = "When applicable, use constructors corresponding to any symbolic term. This option enables a sum-of-monomials grammar for arithmetic. For all other types, it enables symbolic constant constructors." +[[option.mode.ANY_TERM_CONCISE]] + name = "any-term-concise" + help = "When applicable, use constructors corresponding to any symbolic term, favoring conciseness over generality. This option is equivalent to any-term but enables a polynomial grammar for arithmetic when not in a combined theory." [[option]] name = "sygusInvTemplMode" category = "regular" long = "sygus-inv-templ=MODE" - type = "CVC4::theory::quantifiers::SygusInvTemplMode" - default = "CVC4::theory::quantifiers::SYGUS_INV_TEMPL_MODE_POST" - handler = "stringToSygusInvTemplMode" - includes = ["options/quantifiers_modes.h"] + type = "SygusInvTemplMode" + default = "POST" help = "template mode for sygus invariant synthesis (weaken pre-condition, strengthen post-condition, or none)" + help_mode = "Template modes for sygus invariant synthesis." +[[option.mode.NONE]] + name = "none" + help = "Synthesize invariant directly." +[[option.mode.PRE]] + name = "pre" + help = "Synthesize invariant based on weakening of precondition." +[[option.mode.POST]] + name = "post" + help = "Synthesize invariant based on strengthening of postcondition." [[option]] name = "sygusInvTemplWhenSyntax" @@ -1188,11 +1415,19 @@ header = "options/quantifiers_options.h" name = "cegisSample" category = "regular" long = "cegis-sample=MODE" - type = "CVC4::theory::quantifiers::CegisSampleMode" - default = "CVC4::theory::quantifiers::CEGIS_SAMPLE_NONE" - handler = "stringToCegisSampleMode" - includes = ["options/quantifiers_modes.h"] + type = "CegisSampleMode" + default = "NONE" help = "mode for using samples in the counterexample-guided inductive synthesis loop" + help_mode = "Modes for sampling with counterexample-guided inductive synthesis (CEGIS)." +[[option.mode.NONE]] + name = "none" + help = "Do not use sampling with CEGIS." +[[option.mode.USE]] + name = "use" + help = "Use sampling to accelerate CEGIS. This will rule out solutions for a conjecture when they are not satisfied by a sample point." +[[option.mode.TRUST]] + name = "trust" + help = "Trust that when a solution for a conjecture is always true under sampling, then it is indeed a solution. Note this option may print out spurious solutions for synthesis conjectures." [[option]] name = "minSynthSol" @@ -1409,21 +1644,37 @@ header = "options/quantifiers_options.h" name = "sygusQueryGenDumpFiles" category = "regular" long = "sygus-query-gen-dump-files=MODE" - type = "CVC4::theory::quantifiers::SygusQueryDumpFilesMode" - default = "CVC4::theory::quantifiers::SYGUS_QUERY_DUMP_NONE" - handler = "stringToSygusQueryDumpFilesMode" - includes = ["options/quantifiers_modes.h"] + type = "SygusQueryDumpFilesMode" + default = "NONE" help = "mode for dumping external files corresponding to interesting satisfiability queries with sygus-query-gen" + help_mode = "Query file options." +[[option.mode.NONE]] + name = "none" + help = "Do not dump query files when using --sygus-query-gen." +[[option.mode.ALL]] + name = "all" + help = "Dump all query files." +[[option.mode.UNSOLVED]] + name = "unsolved" + help = "Dump query files that the subsolver did not solve." [[option]] name = "sygusFilterSolMode" category = "regular" long = "sygus-filter-sol=MODE" - type = "CVC4::theory::quantifiers::SygusFilterSolMode" - default = "CVC4::theory::quantifiers::SYGUS_FILTER_SOL_NONE" - handler = "stringToSygusFilterSolMode" - includes = ["options/quantifiers_modes.h"] + type = "SygusFilterSolMode" + default = "NONE" help = "mode for filtering sygus solutions" + help_mode = "Modes for filtering sygus solutions." +[[option.mode.NONE]] + name = "none" + help = "Do not filter sygus solutions." +[[option.mode.STRONG]] + name = "strong" + help = "Filter solutions that are logically stronger than others." +[[option.mode.WEAK]] + name = "weak" + help = "Filter solutions that are logically weaker than others." [[option]] name = "sygusFilterSolRevSubsume" @@ -1627,11 +1878,19 @@ header = "options/quantifiers_options.h" name = "cbqiBvIneqMode" category = "regular" long = "cbqi-bv-ineq=MODE" - type = "CVC4::theory::quantifiers::CbqiBvIneqMode" - default = "CVC4::theory::quantifiers::CBQI_BV_INEQ_EQ_BOUNDARY" - handler = "stringToCbqiBvIneqMode" - includes = ["options/quantifiers_modes.h"] + type = "CbqiBvIneqMode" + default = "EQ_BOUNDARY" help = "choose mode for handling bit-vector inequalities with counterexample-guided instantiation" + help_mode = "Modes for handling bit-vector inequalities in counterexample-guided instantiation." +[[option.mode.EQ_SLACK]] + name = "eq-slack" + help = "Solve for the inequality using the slack value in the model, e.g., t > s becomes t = s + ( t-s )^M." +[[option.mode.EQ_BOUNDARY]] + name = "eq-boundary" + help = "Solve for the boundary point of the inequality, e.g., t > s becomes t = s+1." +[[option.mode.KEEP]] + name = "keep" + help = "Solve for the inequality directly using side conditions for invertibility." [[option]] name = "cbqiBvRmExtract" @@ -1717,22 +1976,38 @@ header = "options/quantifiers_options.h" name = "macrosQuantMode" category = "regular" long = "macros-quant-mode=MODE" - type = "CVC4::theory::quantifiers::MacrosQuantMode" - default = "CVC4::theory::quantifiers::MACROS_QUANT_MODE_GROUND_UF" - handler = "stringToMacrosQuantMode" - includes = ["options/quantifiers_modes.h"] + type = "MacrosQuantMode" + default = "GROUND_UF" read_only = true help = "mode for quantifiers macro expansion" + help_mode = "Modes for quantifiers macro expansion." +[[option.mode.ALL]] + name = "all" + help = "Infer definitions for functions, including those containing quantified formulas." +[[option.mode.GROUND]] + name = "ground" + help = "Only infer ground definitions for functions." +[[option.mode.GROUND_UF]] + name = "ground-uf" + help = "Only infer ground definitions for functions that result in triggers for all free variables." [[option]] name = "quantDynamicSplit" category = "regular" long = "quant-dsplit-mode=MODE" - type = "CVC4::theory::quantifiers::QuantDSplitMode" - default = "CVC4::theory::quantifiers::QUANT_DSPLIT_MODE_DEFAULT" - handler = "stringToQuantDSplitMode" - includes = ["options/quantifiers_modes.h"] + type = "QuantDSplitMode" + default = "DEFAULT" help = "mode for dynamic quantifiers splitting" + help_mode = "Modes for quantifiers splitting." +[[option.mode.NONE]] + name = "none" + help = "Never split quantified formulas." +[[option.mode.DEFAULT]] + name = "default" + help = "Split quantified formulas over some finite datatypes when finite model finding is enabled." +[[option.mode.AGG]] + name = "agg" + help = "Aggressively split quantified formulas." [[option]] name = "quantAntiSkolem" diff --git a/src/options/smt_modes.cpp b/src/options/smt_modes.cpp deleted file mode 100644 index 3501da878..000000000 --- a/src/options/smt_modes.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/********************* */ -/*! \file smt_modes.cpp - ** \verbatim - ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "options/smt_modes.h" - -#include - -namespace CVC4 { - -std::ostream& operator<<(std::ostream& out, SimplificationMode mode) -{ - switch (mode) - { - case SIMPLIFICATION_MODE_BATCH: out << "SIMPLIFICATION_MODE_BATCH"; break; - case SIMPLIFICATION_MODE_NONE: out << "SIMPLIFICATION_MODE_NONE"; break; - default: out << "SimplificationMode:UNKNOWN![" << unsigned(mode) << "]"; - } - - return out; -} - -} // namespace CVC4 diff --git a/src/options/smt_modes.h b/src/options/smt_modes.h deleted file mode 100644 index d719dc243..000000000 --- a/src/options/smt_modes.h +++ /dev/null @@ -1,73 +0,0 @@ -/********************* */ -/*! \file smt_modes.h - ** \verbatim - ** Top contributors (to current version): - ** Andrew Reynolds, Morgan Deters, Dejan Jovanovic - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - -#include "cvc4_public.h" - -#ifndef CVC4__SMT__MODES_H -#define CVC4__SMT__MODES_H - -#include - -namespace CVC4 { - -/** Enumeration of simplification modes (when to simplify). */ -enum SimplificationMode -{ - /** Simplify the assertions all together once a check is requested */ - SIMPLIFICATION_MODE_BATCH, - /** Don't do simplification */ - SIMPLIFICATION_MODE_NONE -}; - -std::ostream& operator<<(std::ostream& out, - SimplificationMode mode) CVC4_PUBLIC; - -/** Enumeration of model core modes. */ -enum ModelCoresMode -{ - /** Do not compute model cores */ - MODEL_CORES_NONE, - /** - * Compute "simple" model cores that exclude variables that do not - * contribute to satisfying the input. - */ - MODEL_CORES_SIMPLE, - /** - * Compute model cores that also exclude variables whose variables are implied - * by others. - */ - MODEL_CORES_NON_IMPLIED -}; - -/** Block models modes. */ -enum BlockModelsMode -{ - /** Do not block models */ - BLOCK_MODELS_NONE, - /** - * block models based on literals truth values. - */ - BLOCK_MODELS_LITERALS, - /** - * block models based on concrete variable values in the model. - */ - BLOCK_MODELS_VALUES, -}; - -} // namespace CVC4 - -#endif /* CVC4__SMT__MODES_H */ diff --git a/src/options/smt_options.toml b/src/options/smt_options.toml index 39d09c4ea..ba62a6455 100644 --- a/src/options/smt_options.toml +++ b/src/options/smt_options.toml @@ -36,10 +36,15 @@ header = "options/smt_options.h" category = "regular" long = "simplification=MODE" type = "SimplificationMode" - default = "SIMPLIFICATION_MODE_BATCH" - handler = "stringToSimplificationMode" - includes = ["options/smt_modes.h"] + default = "BATCH" help = "choose simplification mode, see --simplification=help" + help_mode = "Simplification modes." +[[option.mode.NONE]] + name = "none" + help = "Do not perform nonclausal simplification." +[[option.mode.BATCH]] + name = "batch" + help = "Save up all ASSERTions; run nonclausal simplification and clausal (MiniSat) propagation for all of them only after reaching a querying command (CHECKSAT or QUERY or predicate SUBTYPE declaration)." [[alias]] category = "regular" @@ -101,21 +106,36 @@ header = "options/smt_options.h" category = "regular" long = "model-cores=MODE" type = "ModelCoresMode" - default = "MODEL_CORES_NONE" - handler = "stringToModelCoresMode" - includes = ["options/smt_modes.h"] + default = "NONE" help = "mode for producing model cores" - + help_mode = "Model cores modes." +[[option.mode.NONE]] + name = "none" + help = "Do not compute model cores." +[[option.mode.SIMPLE]] + name = "simple" + help = "Only include a subset of variables whose values are sufficient to show the input formula is satisfied by the given model." +[[option.mode.NON_IMPLIED]] + name = "non-implied" + help = "Only include a subset of variables whose values, in addition to the values of variables whose values are implied, are sufficient to show the input formula is satisfied by the given model." [[option]] name = "blockModelsMode" category = "regular" long = "block-models=MODE" type = "BlockModelsMode" - default = "BLOCK_MODELS_NONE" - handler = "stringToBlockModelsMode" - includes = ["options/smt_modes.h"] + default = "NONE" help = "mode for producing several models" + help_mode = "Blocking models modes." +[[option.mode.NONE]] + name = "none" + help = "Do not block models." +[[option.mode.LITERALS]] + name = "literals" + help = "Block models based on the SAT skeleton." +[[option.mode.VALUES]] + name = "valuels" + help = "Block models based on the concrete model values for the free variables." [[option]] name = "proof" @@ -163,10 +183,21 @@ header = "options/smt_options.h" category = "regular" long = "sygus-out=MODE" type = "SygusSolutionOutMode" - default = "SYGUS_SOL_OUT_STATUS_AND_DEF" - handler = "stringToSygusSolutionOutMode" - includes = ["options/sygus_out_mode.h"] + default = "STATUS_AND_DEF" help = "output mode for sygus" + help_mode = "Modes for sygus solution output." +[[option.mode.STATUS]] + name = "status" + help = "Print only status for check-synth calls." +[[option.mode.STATUS_AND_DEF]] + name = "status-and-def" + help = "Print status followed by definition corresponding to solution." +[[option.mode.STATUS_OR_DEF]] + name = "status-or-def" + help = "Print status if infeasible, or definition corresponding to solution if feasible." +[[option.mode.STANDARD]] + name = "sygus-standard" + help = "Print based on SyGuS standard." [[option]] name = "sygusPrintCallbacks" diff --git a/src/options/strings_modes.cpp b/src/options/strings_modes.cpp deleted file mode 100644 index c56c82716..000000000 --- a/src/options/strings_modes.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/********************* */ -/*! \file strings_modes.cpp - ** \verbatim - ** Top contributors (to current version): - ** Andres Noetzli - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Modes for the string solver. - **/ - -#include "options/strings_modes.h" - -#include -#include - -namespace CVC4 { - -std::ostream& operator<<(std::ostream& out, - theory::strings::ProcessLoopMode mode) -{ - switch (mode) - { - case theory::strings::ProcessLoopMode::FULL: - out << "ProcessLoopMode::FULL"; - break; - case theory::strings::ProcessLoopMode::SIMPLE: - out << "ProcessLoopMode::SIMPLE"; - break; - case theory::strings::ProcessLoopMode::SIMPLE_ABORT: - out << "ProcessLoopMode::SIMPLE_ABORT"; - break; - case theory::strings::ProcessLoopMode::NONE: - out << "ProcessLoopMode::NONE"; - break; - case theory::strings::ProcessLoopMode::ABORT: - out << "ProcessLoopMode::ABORT"; - break; - default: - out << "ProcessLoopMode:UNKNOWN![" << static_cast(mode) << "]"; - } - return out; -} - -std::ostream& operator<<(std::ostream& out, - theory::strings::RegExpInterMode mode) -{ - switch (mode) - { - case theory::strings::RegExpInterMode::RE_INTER_ALL: - out << "RegExpInterMode::RE_INTER_ALL"; - break; - case theory::strings::RegExpInterMode::RE_INTER_CONSTANT: - out << "RegExpInterMode::RE_INTER_CONSTANT"; - break; - case theory::strings::RegExpInterMode::RE_INTER_ONE_CONSTANT: - out << "RegExpInterMode::RE_INTER_ONE_CONSTANT"; - break; - case theory::strings::RegExpInterMode::RE_INTER_NONE: - out << "RegExpInterMode::RE_INTER_NONE"; - break; - default: - out << "RegExpInterMode:UNKNOWN![" << static_cast(mode) << "]"; - } - return out; -} - -} // namespace CVC4 diff --git a/src/options/strings_modes.h b/src/options/strings_modes.h deleted file mode 100644 index 7823ea8c7..000000000 --- a/src/options/strings_modes.h +++ /dev/null @@ -1,78 +0,0 @@ -/********************* */ -/*! \file strings_modes.h - ** \verbatim - ** Top contributors (to current version): - ** Andres Noetzli - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Modes for the string solver. - **/ - -#include "cvc4_private.h" - -#ifndef CVC4__THEORY__STRINGS__STRINGS_MODES_H -#define CVC4__THEORY__STRINGS__STRINGS_MODES_H - -#include - -namespace CVC4 { -namespace theory { -namespace strings { - -/** Enumeration of string processing loop modes */ -enum ProcessLoopMode -{ - /** Perform full loop processing. */ - FULL, - - /** Omit normal loop breaking. */ - SIMPLE, - - /** Abort if normal loop breaking is required. */ - SIMPLE_ABORT, - - /** Omit loop processing. */ - NONE, - - /** Abort if looping word equations are encountered. */ - ABORT -}; // enum ProcessLoopMode - -/** Enumeration of regular expression intersection modes */ -enum RegExpInterMode -{ - /** Compute intersections for all regular expressions. */ - RE_INTER_ALL, - - /** - * Compute intersections only for regular expressions without re.allchar - * and re.range. - */ - RE_INTER_CONSTANT, - - /** - * Compute intersections only between regular expressions where one side does - * not contain re.allchar and re.range. - */ - RE_INTER_ONE_CONSTANT, - - /** Do not compute intersections of regular expressions. */ - RE_INTER_NONE, -}; // enum RegExpInterMode - -} // namespace strings -} // namespace theory - -std::ostream& operator<<(std::ostream& out, - theory::strings::ProcessLoopMode mode); - -std::ostream& operator<<(std::ostream& out, - theory::strings::RegExpInterMode mode); - -} // namespace CVC4 - -#endif /* CVC4__THEORY__STRINGS__STRINGS_MODES_H */ diff --git a/src/options/strings_options.toml b/src/options/strings_options.toml index 2d8411256..3916c68f3 100644 --- a/src/options/strings_options.toml +++ b/src/options/strings_options.toml @@ -132,11 +132,26 @@ header = "options/strings_options.h" name = "stringProcessLoopMode" category = "expert" long = "strings-process-loop-mode=MODE" - type = "CVC4::theory::strings::ProcessLoopMode" - default = "CVC4::theory::strings::ProcessLoopMode::FULL" - handler = "stringToStringsProcessLoopMode" - includes = ["options/strings_modes.h"] + type = "ProcessLoopMode" + default = "FULL" help = "determines how to process looping string equations" + help_mode = "Loop processing modes." +[[option.mode.FULL]] + name = "full" + help = "Perform full processing of looping word equations." +[[option.mode.SIMPLE]] + name = "simple" + help = "Omit normal loop breaking (default with --strings-fmf)." +[[option.mode.SIMPLE_ABORT]] + name = "simple-abort" + help = "Abort when normal loop breaking is required." +[[option.mode.NONE]] + name = "none" + help = "Omit loop processing." +[[option.mode.ABORT]] + name = "abort" + help = "Abort if looping word equations are encountered." + [[option]] name = "stringInferAsLemmas" @@ -221,8 +236,19 @@ header = "options/strings_options.h" name = "stringRegExpInterMode" category = "expert" long = "re-inter-mode=MODE" - type = "CVC4::theory::strings::RegExpInterMode" - default = "CVC4::theory::strings::RE_INTER_CONSTANT" - handler = "stringToRegExpInterMode" - includes = ["options/strings_modes.h"] + type = "RegExpInterMode" + default = "CONSTANT" help = "determines which regular expressions intersections to compute" + help_mode = "Regular expression intersection modes." +[[option.mode.ALL]] + name = "all" + help = "Compute intersections for all regular expressions." +[[option.mode.CONSTANT]] + name = "constant" + help = "Compute intersections only between regular expressions that do not contain re.allchar or re.range." +[[option.mode.ONE_CONSTANT]] + name = "one-constant" + help = "Compute intersections only between regular expressions such that at least one side does not contain re.allchar or re.range." +[[option.mode.NONE]] + name = "none" + help = "Do not compute intersections for regular expressions." diff --git a/src/options/sygus_out_mode.h b/src/options/sygus_out_mode.h deleted file mode 100644 index 79480946a..000000000 --- a/src/options/sygus_out_mode.h +++ /dev/null @@ -1,39 +0,0 @@ -/********************* */ -/*! \file sygus_out_mode.h - ** \verbatim - ** Top contributors (to current version): - ** Andrew Reynolds - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Options for sygus solution output. - **/ - -#include "cvc4_public.h" - -#ifndef CVC4__SMT__SYGUS_OUT_MODE_H -#define CVC4__SMT__SYGUS_OUT_MODE_H - -#include - -namespace CVC4 { - -/** Mode for printing sygus solutions. */ -enum SygusSolutionOutMode -{ - /** print status */ - SYGUS_SOL_OUT_STATUS, - /** (default) print status and solution */ - SYGUS_SOL_OUT_STATUS_AND_DEF, - /** print status if infeasible, or solution if feasible */ - SYGUS_SOL_OUT_STATUS_OR_DEF, - /** print output specified by sygus standard */ - SYGUS_SOL_OUT_STANDARD, -}; - -} /* CVC4 namespace */ - -#endif /* CVC4__SMT__SYGUS_OUT_MODE_H */ diff --git a/src/options/theory_options.toml b/src/options/theory_options.toml index 3509f408d..13c3d5cfb 100644 --- a/src/options/theory_options.toml +++ b/src/options/theory_options.toml @@ -7,11 +7,16 @@ header = "options/theory_options.h" smt_name = "theoryof-mode" category = "expert" long = "theoryof-mode=MODE" - type = "CVC4::theory::TheoryOfMode" - default = "CVC4::theory::THEORY_OF_TYPE_BASED" - handler = "stringToTheoryOfMode" - includes = ["options/theoryof_mode.h"] + type = "TheoryOfMode" + default = "THEORY_OF_TYPE_BASED" help = "mode for Theory::theoryof()" + help_mode = "Defines how we associate theories with terms." +[[option.mode.THEORY_OF_TYPE_BASED]] + name = "type" + help = "Type variables, constants and equalities by type." +[[option.mode.THEORY_OF_TERM_BASED]] + name = "term" + help = "Type variables as uninterpreted, type constants by theory, equalities by the parametric theory." [[option]] name = "useTheoryList" diff --git a/src/options/theoryof_mode.cpp b/src/options/theoryof_mode.cpp deleted file mode 100644 index 4d8d92e17..000000000 --- a/src/options/theoryof_mode.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/********************* */ -/*! \file theoryof_mode.cpp - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters, Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief [[ Add one-line brief description here ]] - ** - ** [[ Add lengthier description here ]] - ** \todo document this file - **/ - - -#include "options/theoryof_mode.h" - -#include - -namespace CVC4 { -namespace theory { - -std::ostream& operator<<(std::ostream& out, TheoryOfMode m) -{ - switch(m) { - case THEORY_OF_TYPE_BASED: return out << "THEORY_OF_TYPE_BASED"; - case THEORY_OF_TERM_BASED: return out << "THEORY_OF_TERM_BASED"; - default: return out << "TheoryOfMode!UNKNOWN"; - } -} - -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ diff --git a/src/options/theoryof_mode.h b/src/options/theoryof_mode.h deleted file mode 100644 index 900452fbc..000000000 --- a/src/options/theoryof_mode.h +++ /dev/null @@ -1,38 +0,0 @@ -/********************* */ -/*! \file theoryof_mode.h - ** \verbatim - ** Top contributors (to current version): - ** Dejan Jovanovic, Morgan Deters, Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Option selection for theoryOf() operation - ** - ** Option selection for theoryOf() operation. - **/ - -#include "cvc4_public.h" - -#pragma once - -#include - -namespace CVC4 { -namespace theory { - -/** How do we associate theories with the terms */ -enum TheoryOfMode { - /** Equality, variables and constants are associated with the types */ - THEORY_OF_TYPE_BASED, - /** Variables are uninterpreted, constants are with the type, equalities prefer parametric */ - THEORY_OF_TERM_BASED -};/* enum TheoryOfMode */ - -std::ostream& operator<<(std::ostream& out, TheoryOfMode m) CVC4_PUBLIC; - -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - diff --git a/src/options/uf_options.toml b/src/options/uf_options.toml index 8790e4ec3..6916598ce 100644 --- a/src/options/uf_options.toml +++ b/src/options/uf_options.toml @@ -51,12 +51,20 @@ header = "options/uf_options.h" name = "ufssMode" category = "regular" long = "uf-ss=MODE" - type = "CVC4::theory::uf::UfssMode" - default = "CVC4::theory::uf::UF_SS_FULL" - handler = "stringToUfssMode" - includes = ["options/ufss_mode.h"] + type = "UfssMode" + default = "FULL" read_only = true help = "mode of operation for uf with cardinality solver." + help_mode = "UF with cardinality options currently supported by the --uf-ss option when combined with finite model finding." +[[option.mode.FULL]] + name = "full" + help = "Default, use UF with cardinality to find minimal models for uninterpreted sorts." +[[option.mode.NO_MINIMAL]] + name = "no-minimal" + help = "Use UF with cardinality to shrink models, but do no enforce minimality." +[[option.mode.NONE]] + name = "none" + help = "Do not use UF with cardinality to shrink model sizes." [[option]] name = "ufssFairness" diff --git a/src/options/ufss_mode.h b/src/options/ufss_mode.h deleted file mode 100644 index 452317b8f..000000000 --- a/src/options/ufss_mode.h +++ /dev/null @@ -1,50 +0,0 @@ -/********************* */ -/*! \file ufss_mode.h - ** \verbatim - ** Top contributors (to current version): - ** Andrew Reynolds, Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Custom handlers and predicates for TheoryUF options - ** - ** Custom handlers and predicates for TheoryUF options. - **/ - -#include "cvc4_private.h" - -#ifndef CVC4__BASE__UFSS_MODE_H -#define CVC4__BASE__UFSS_MODE_H - -namespace CVC4 { -namespace theory { -namespace uf { - -/** - * These modes determine the role of UF with cardinality when using finite model - * finding (--finite-model-find). - */ -enum UfssMode -{ - /** - * Default, use UF with cardinality to find minimal models for uninterpreted - * sorts. - */ - UF_SS_FULL, - /** - * Use UF with cardinality to shrink model sizes, but do no enforce - * minimality. - */ - UF_SS_NO_MINIMAL, - /** do not use UF with cardinality */ - UF_SS_NONE, -}; - -}/* CVC4::theory::uf namespace */ -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* CVC4__BASE__UFSS_MODE_H */ diff --git a/src/preprocessing/passes/bool_to_bv.cpp b/src/preprocessing/passes/bool_to_bv.cpp index 520e9f2a7..7787d7631 100644 --- a/src/preprocessing/passes/bool_to_bv.cpp +++ b/src/preprocessing/passes/bool_to_bv.cpp @@ -72,7 +72,7 @@ bool BoolToBV::needToRebuild(TNode n) const Node BoolToBV::lowerAssertion(const TNode& a) { - bool optionITE = options::boolToBitvector() == BOOL_TO_BV_ITE; + bool optionITE = options::boolToBitvector() == options::BoolToBVMode::ITE; NodeManager* nm = NodeManager::currentNM(); std::vector visit; visit.push_back(a); @@ -166,7 +166,7 @@ void BoolToBV::lowerNode(const TNode& n) if (!all_bv || (n.getNumChildren() == 0)) { - if ((options::boolToBitvector() == BOOL_TO_BV_ALL) + if ((options::boolToBitvector() == options::BoolToBVMode::ALL) && n.getType().isBoolean()) { if (k == kind::CONST_BOOLEAN) @@ -222,7 +222,8 @@ void BoolToBV::lowerNode(const TNode& n) } NodeBuilder<> builder(new_kind); - if ((options::boolToBitvector() == BOOL_TO_BV_ALL) && (new_kind != k)) + if ((options::boolToBitvector() == options::BoolToBVMode::ALL) + && (new_kind != k)) { ++(d_statistics.d_numTermsLowered); } @@ -259,7 +260,7 @@ BoolToBV::Statistics::Statistics() "preprocessing::passes::BoolToBV::NumTermsForcedLowered", 0) { smtStatisticsRegistry()->registerStat(&d_numIteToBvite); - if (options::boolToBitvector() == BOOL_TO_BV_ALL) + if (options::boolToBitvector() == options::BoolToBVMode::ALL) { // these statistics wouldn't be correct in the ITE mode, // because it might discard rebuilt nodes if it fails to @@ -272,7 +273,7 @@ BoolToBV::Statistics::Statistics() BoolToBV::Statistics::~Statistics() { smtStatisticsRegistry()->unregisterStat(&d_numIteToBvite); - if (options::boolToBitvector() == BOOL_TO_BV_ALL) + if (options::boolToBitvector() == options::BoolToBVMode::ALL) { smtStatisticsRegistry()->unregisterStat(&d_numTermsLowered); smtStatisticsRegistry()->unregisterStat(&d_numTermsForcedLowered); diff --git a/src/preprocessing/passes/bv_abstraction.cpp b/src/preprocessing/passes/bv_abstraction.cpp index 9c0d0ec68..d62c8a97e 100644 --- a/src/preprocessing/passes/bv_abstraction.cpp +++ b/src/preprocessing/passes/bv_abstraction.cpp @@ -53,7 +53,7 @@ PreprocessingPassResult BvAbstraction::applyInternal( } // If we are using the lazy solver and the abstraction applies, then UF // symbols were introduced. - if (options::bitblastMode() == bv::BITBLAST_MODE_LAZY && changed) + if (options::bitblastMode() == options::BitblastMode::LAZY && changed) { d_preprocContext->widenLogic(theory::THEORY_UF); } diff --git a/src/preprocessing/passes/quantifier_macros.cpp b/src/preprocessing/passes/quantifier_macros.cpp index 1d834ce60..bc2c136e4 100644 --- a/src/preprocessing/passes/quantifier_macros.cpp +++ b/src/preprocessing/passes/quantifier_macros.cpp @@ -18,7 +18,6 @@ #include -#include "options/quantifiers_modes.h" #include "options/quantifiers_options.h" #include "proof/proof_manager.h" #include "smt/smt_engine.h" @@ -70,7 +69,8 @@ void QuantifierMacros::clearMaps() } bool QuantifierMacros::simplify( std::vector< Node >& assertions, bool doRewrite ){ - unsigned rmax = options::macrosQuantMode()==MACROS_QUANT_MODE_ALL ? 2 : 1; + unsigned rmax = + options::macrosQuantMode() == options::MacrosQuantMode::ALL ? 2 : 1; for( unsigned r=0; r& args, Nod if( !containsBadOp( n_def, op, opc, visited ) ){ Trace("macros-debug") << "...does not contain bad (recursive) operator." << std::endl; //must be ground UF term if mode is GROUND_UF - if( options::macrosQuantMode()!=MACROS_QUANT_MODE_GROUND_UF || isGroundUfTerm( f, n_def ) ){ + if (options::macrosQuantMode() + != options::MacrosQuantMode::GROUND_UF + || isGroundUfTerm(f, n_def)) + { Trace("macros-debug") << "...respects ground-uf constraint." << std::endl; //now we must rewrite candidates[i] to a term of form g( x1, ..., xn ) where // x1 ... xn are distinct variables diff --git a/src/proof/bitvector_proof.cpp b/src/proof/bitvector_proof.cpp index 98f57e25f..c60cc8274 100644 --- a/src/proof/bitvector_proof.cpp +++ b/src/proof/bitvector_proof.cpp @@ -224,7 +224,7 @@ void BitVectorProof::printOwnedTerm(Expr term, void BitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + Assert(options::bitblastMode() == options::BitblastMode::EAGER) << "the BV theory should only be proving bottom directly in the eager " "bitblasting mode"; } @@ -644,8 +644,8 @@ void BitVectorProof::printBitblasting(std::ostream& os, std::ostream& paren) std::vector::const_iterator it = d_bbTerms.begin(); std::vector::const_iterator end = d_bbTerms.end(); for (; it != end; ++it) { - if (d_usedBB.find(*it) == d_usedBB.end() && - options::bitblastMode() != theory::bv::BITBLAST_MODE_EAGER) + if (d_usedBB.find(*it) == d_usedBB.end() + && options::bitblastMode() != options::BitblastMode::EAGER) continue; // Is this term has an alias, we inject it through the decl_bblast statement @@ -668,8 +668,8 @@ void BitVectorProof::printBitblasting(std::ostream& os, std::ostream& paren) ExprToExpr::const_iterator ait = d_bbAtoms.begin(); ExprToExpr::const_iterator aend = d_bbAtoms.end(); for (; ait != aend; ++ait) { - if (d_usedBB.find(ait->first) == d_usedBB.end() && - options::bitblastMode() != theory::bv::BITBLAST_MODE_EAGER) + if (d_usedBB.find(ait->first) == d_usedBB.end() + && options::bitblastMode() != options::BitblastMode::EAGER) continue; os << "(th_let_pf _ "; diff --git a/src/proof/clausal_bitvector_proof.cpp b/src/proof/clausal_bitvector_proof.cpp index bb9213b4b..6b0a57725 100644 --- a/src/proof/clausal_bitvector_proof.cpp +++ b/src/proof/clausal_bitvector_proof.cpp @@ -131,11 +131,8 @@ void ClausalBitVectorProof::optimizeDratProof() { TimerStat::CodeTimer optimizeDratProofTimer{ d_dratOptimizationStatistics.d_totalTime}; - if (options::bvOptimizeSatProof() - == theory::bv::BvOptimizeSatProof::BITVECTOR_OPTIMIZE_SAT_PROOF_PROOF - || options::bvOptimizeSatProof() - == theory::bv::BvOptimizeSatProof:: - BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA) + if (options::bvOptimizeSatProof() == options::BvOptimizeSatProof::PROOF + || options::bvOptimizeSatProof() == options::BvOptimizeSatProof::FORMULA) { Debug("bv::clausal") << "Optimizing DRAT" << std::endl; std::string formulaFilename("cvc4-dimacs-XXXXXX"); @@ -197,8 +194,7 @@ void ClausalBitVectorProof::optimizeDratProof() static_cast(d_binaryDratProof.tellp()) - startPos); } - if (options::bvOptimizeSatProof() - == theory::bv::BvOptimizeSatProof::BITVECTOR_OPTIMIZE_SAT_PROOF_FORMULA) + if (options::bvOptimizeSatProof() == options::BvOptimizeSatProof::FORMULA) { std::ifstream optFormulaStream{optFormulaFilename}; const int64_t startPos = static_cast(optFormulaStream.tellg()); @@ -339,7 +335,7 @@ void LfscClausalBitVectorProof::printBBDeclarationAndCnf(std::ostream& os, void LfscDratBitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + Assert(options::bitblastMode() == options::BitblastMode::EAGER) << "the BV theory should only be proving bottom directly in the eager " "bitblasting mode"; @@ -366,7 +362,7 @@ void LfscDratBitVectorProof::printEmptyClauseProof(std::ostream& os, void LfscLratBitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + Assert(options::bitblastMode() == options::BitblastMode::EAGER) << "the BV theory should only be proving bottom directly in the eager " "bitblasting mode"; @@ -396,7 +392,7 @@ void LfscLratBitVectorProof::printEmptyClauseProof(std::ostream& os, void LfscErBitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + Assert(options::bitblastMode() == options::BitblastMode::EAGER) << "the BV theory should only be proving bottom directly in the eager " "bitblasting mode"; diff --git a/src/proof/proof_manager.cpp b/src/proof/proof_manager.cpp index bbf5b0064..fda3f7424 100644 --- a/src/proof/proof_manager.cpp +++ b/src/proof/proof_manager.cpp @@ -798,7 +798,7 @@ void LFSCProof::toStream(std::ostream& out) const CodeTimer finalProofTimer{ ProofManager::currentPM()->getStats().d_finalProofTime}; out << ";; Printing final unsat proof \n"; - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER + if (options::bitblastMode() == options::BitblastMode::EAGER && ProofManager::getBitVectorProof()) { ProofManager::getBitVectorProof()->printEmptyClauseProof(out, paren); diff --git a/src/proof/resolution_bitvector_proof.cpp b/src/proof/resolution_bitvector_proof.cpp index f4ced1748..8d4b56d54 100644 --- a/src/proof/resolution_bitvector_proof.cpp +++ b/src/proof/resolution_bitvector_proof.cpp @@ -129,7 +129,7 @@ void ResolutionBitVectorProof::endBVConflict( void ResolutionBitVectorProof::finalizeConflicts(std::vector& conflicts) { - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + if (options::bitblastMode() == options::BitblastMode::EAGER) { Debug("pf::bv") << "Construct full proof." << std::endl; d_resolutionProof->constructProof(); @@ -513,7 +513,7 @@ void LfscResolutionBitVectorProof::printBBDeclarationAndCnf(std::ostream& os, void LfscResolutionBitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + Assert(options::bitblastMode() == options::BitblastMode::EAGER) << "the BV theory should only be proving bottom directly in the eager " "bitblasting mode"; proof::LFSCProofPrinter::printResolutionEmptyClause( diff --git a/src/proof/theory_proof.cpp b/src/proof/theory_proof.cpp index 8b9204a20..d95572820 100644 --- a/src/proof/theory_proof.cpp +++ b/src/proof/theory_proof.cpp @@ -82,23 +82,23 @@ void TheoryProofEngine::registerTheory(theory::Theory* th) { if (id == theory::THEORY_BV) { auto thBv = static_cast(th); - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER - && options::bvSatSolver() == theory::bv::SAT_SOLVER_CRYPTOMINISAT) + if (options::bitblastMode() == options::BitblastMode::EAGER + && options::bvSatSolver() == options::SatSolverMode::CRYPTOMINISAT) { proof::BitVectorProof* bvp = nullptr; switch (options::bvProofFormat()) { - case theory::bv::BvProofFormat::BITVECTOR_PROOF_DRAT: + case options::BvProofFormat::DRAT: { bvp = new proof::LfscDratBitVectorProof(thBv, this); break; } - case theory::bv::BvProofFormat::BITVECTOR_PROOF_LRAT: + case options::BvProofFormat::LRAT: { bvp = new proof::LfscLratBitVectorProof(thBv, this); break; } - case theory::bv::BvProofFormat::BITVECTOR_PROOF_ER: + case options::BvProofFormat::ER: { bvp = new proof::LfscErBitVectorProof(thBv, this); break; @@ -585,7 +585,8 @@ void LFSCTheoryProofEngine::printTheoryLemmas(const IdToSatClause& lemmas, // finalizeBvConflicts(lemmas, os, paren, map); ProofManager::getBitVectorProof()->printBBDeclarationAndCnf(os, paren, map); - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) { + if (options::bitblastMode() == options::BitblastMode::EAGER) + { Assert(lemmas.size() == 1); // nothing more to do (no combination with eager so far) return; diff --git a/src/prop/bvminisat/simp/SimpSolver.cc b/src/prop/bvminisat/simp/SimpSolver.cc index 698d2a776..9e50433ef 100644 --- a/src/prop/bvminisat/simp/SimpSolver.cc +++ b/src/prop/bvminisat/simp/SimpSolver.cc @@ -48,27 +48,27 @@ static DoubleOption opt_simp_garbage_frac(_cat, "simp-gc-frac", "The fraction of //================================================================================================= // Constructor/Destructor: - -SimpSolver::SimpSolver(CVC4::context::Context* c) : - Solver(c) - , grow (opt_grow) - , clause_lim (opt_clause_lim) - , subsumption_lim (opt_subsumption_lim) - , simp_garbage_frac (opt_simp_garbage_frac) - , use_asymm (opt_use_asymm) - , use_rcheck (opt_use_rcheck) - , use_elim (opt_use_elim && - CVC4::options::bitblastMode() == CVC4::theory::bv::BITBLAST_MODE_EAGER && - !CVC4::options::produceModels()) - , merges (0) - , asymm_lits (0) - , eliminated_vars (0) - , elimorder (1) - , use_simplification (!PROOF_ON()) - , occurs (ClauseDeleted(ca)) - , elim_heap (ElimLt(n_occ)) - , bwdsub_assigns (0) - , n_touched (0) +SimpSolver::SimpSolver(CVC4::context::Context* c) + : Solver(c), + grow(opt_grow), + clause_lim(opt_clause_lim), + subsumption_lim(opt_subsumption_lim), + simp_garbage_frac(opt_simp_garbage_frac), + use_asymm(opt_use_asymm), + use_rcheck(opt_use_rcheck), + use_elim(opt_use_elim + && CVC4::options::bitblastMode() + == CVC4::options::BitblastMode::EAGER + && !CVC4::options::produceModels()), + merges(0), + asymm_lits(0), + eliminated_vars(0), + elimorder(1), + use_simplification(!PROOF_ON()), + occurs(ClauseDeleted(ca)), + elim_heap(ElimLt(n_occ)), + bwdsub_assigns(0), + n_touched(0) { vec dummy(1,lit_Undef); diff --git a/src/prop/minisat/minisat.cpp b/src/prop/minisat/minisat.cpp index 3cdd6b654..80d767b3d 100644 --- a/src/prop/minisat/minisat.cpp +++ b/src/prop/minisat/minisat.cpp @@ -106,15 +106,18 @@ void MinisatSatSolver::initialize(context::Context* context, TheoryProxy* theory d_context = context; - if( options::decisionMode() != decision::DECISION_STRATEGY_INTERNAL ) { + if (options::decisionMode() != options::DecisionMode::INTERNAL) + { Notice() << "minisat: Incremental solving is forced on (to avoid variable elimination)" << " unless using internal decision strategy." << std::endl; } // Create the solver - d_minisat = new Minisat::SimpSolver(theoryProxy, d_context, - options::incrementalSolving() || - options::decisionMode() != decision::DECISION_STRATEGY_INTERNAL ); + d_minisat = new Minisat::SimpSolver( + theoryProxy, + d_context, + options::incrementalSolving() + || options::decisionMode() != options::DecisionMode::INTERNAL); d_statistics.init(d_minisat); } diff --git a/src/smt/command.cpp b/src/smt/command.cpp index d8301283f..17d8cbed5 100644 --- a/src/smt/command.cpp +++ b/src/smt/command.cpp @@ -868,10 +868,10 @@ void CheckSynthCommand::invoke(SmtEngine* smtEngine) d_solution.clear(); // check whether we should print the status if (d_result.asSatisfiabilityResult() != Result::UNSAT - || options::sygusOut() == SYGUS_SOL_OUT_STATUS_AND_DEF - || options::sygusOut() == SYGUS_SOL_OUT_STATUS) + || options::sygusOut() == options::SygusSolutionOutMode::STATUS_AND_DEF + || options::sygusOut() == options::SygusSolutionOutMode::STATUS) { - if (options::sygusOut() == SYGUS_SOL_OUT_STANDARD) + if (options::sygusOut() == options::SygusSolutionOutMode::STANDARD) { d_solution << "(fail)" << endl; } @@ -882,7 +882,7 @@ void CheckSynthCommand::invoke(SmtEngine* smtEngine) } // check whether we should print the solution if (d_result.asSatisfiabilityResult() == Result::UNSAT - && options::sygusOut() != SYGUS_SOL_OUT_STATUS) + && options::sygusOut() != options::SygusSolutionOutMode::STATUS) { // printing a synthesis solution is a non-constant // method, since it invokes a sophisticated algorithm diff --git a/src/smt/model_blocker.cpp b/src/smt/model_blocker.cpp index cb962ee45..6e73a61b3 100644 --- a/src/smt/model_blocker.cpp +++ b/src/smt/model_blocker.cpp @@ -25,7 +25,7 @@ namespace CVC4 { Expr ModelBlocker::getModelBlocker(const std::vector& assertions, theory::TheoryModel* m, - BlockModelsMode mode, + options::BlockModelsMode mode, const std::vector& exprToBlock) { NodeManager* nm = NodeManager::currentNM(); @@ -43,7 +43,7 @@ Expr ModelBlocker::getModelBlocker(const std::vector& assertions, } Trace("model-blocker") << "Compute model blocker, assertions:" << std::endl; Node blocker; - if (mode == BLOCK_MODELS_LITERALS) + if (mode == options::BlockModelsMode::LITERALS) { Assert(nodesToBlock.empty()); // optimization: filter out top-level unit assertions, as they cannot @@ -234,7 +234,7 @@ Expr ModelBlocker::getModelBlocker(const std::vector& assertions, } else { - Assert(mode == BLOCK_MODELS_VALUES); + Assert(mode == options::BlockModelsMode::VALUES); std::vector blockers; // if specific terms were not specified, block all variables of // the model diff --git a/src/smt/model_blocker.h b/src/smt/model_blocker.h index ca201ec66..7fc4788bb 100644 --- a/src/smt/model_blocker.h +++ b/src/smt/model_blocker.h @@ -46,7 +46,8 @@ class ModelBlocker * { t1 ... tn }; if exprToBlock is empty, then t1 ... tn are the free * variables of assertions. * - * We expect exprToBlock to be non-empty only if mode is BLOCK_MODELS_VALUES. + * We expect exprToBlock to be non-empty only if mode is + * BlockModelsMode::VALUES. * * For example, if our input is: * x > 0 ^ ( y < 0 V z < 0 V w < 0 ) @@ -61,7 +62,7 @@ class ModelBlocker static Expr getModelBlocker( const std::vector& assertions, theory::TheoryModel* m, - BlockModelsMode mode, + options::BlockModelsMode mode, const std::vector& exprToBlock = std::vector()); }; /* class TheoryModelCoreBuilder */ diff --git a/src/smt/model_core_builder.cpp b/src/smt/model_core_builder.cpp index 69cd2e7e6..3007821e5 100644 --- a/src/smt/model_core_builder.cpp +++ b/src/smt/model_core_builder.cpp @@ -22,7 +22,7 @@ namespace CVC4 { bool ModelCoreBuilder::setModelCore(const std::vector& assertions, Model* m, - ModelCoresMode mode) + options::ModelCoresMode mode) { if (Trace.isOn("model-core")) { @@ -77,12 +77,12 @@ bool ModelCoreBuilder::setModelCore(const std::vector& assertions, std::vector coreVars; std::vector impliedVars; bool minimized = false; - if (mode == MODEL_CORES_NON_IMPLIED) + if (mode == options::ModelCoresMode::NON_IMPLIED) { minimized = theory::SubstitutionMinimize::findWithImplied( formula, vars, subs, coreVars, impliedVars); } - else if (mode == MODEL_CORES_SIMPLE) + else if (mode == options::ModelCoresMode::SIMPLE) { minimized = theory::SubstitutionMinimize::find( formula, truen, vars, subs, coreVars); diff --git a/src/smt/model_core_builder.h b/src/smt/model_core_builder.h index 0c179e287..2390d61ca 100644 --- a/src/smt/model_core_builder.h +++ b/src/smt/model_core_builder.h @@ -38,10 +38,10 @@ class ModelCoreBuilder * { s1 -> m(s1), ..., sn -> m(sn) } * * The criteria for what consistutes a model core given by mode. For - * example, if mode is MODEL_CORES_SIMPLE, then a model core corresponds to a - * subset of assignments from the model that suffice to show that the set of - * assertions, interpreted conjunctively, evaluates to true under the - * substitution corresponding to the model core. + * example, if mode is ModelCoresMode::SIMPLE, then a model core + * corresponds to a subset of assignments from the model that suffice to show + * that the set of assertions, interpreted conjunctively, evaluates to true + * under the substitution corresponding to the model core. * * The model core is recorded on the model object m via calls to * m->setUsingModelCore, m->recordModelCoreSymbol, for details see @@ -56,7 +56,7 @@ class ModelCoreBuilder */ static bool setModelCore(const std::vector& assertions, Model* m, - ModelCoresMode mode); + options::ModelCoresMode mode); }; /* class TheoryModelCoreBuilder */ } // namespace CVC4 diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp index cb1445b93..3343abc29 100644 --- a/src/smt/smt_engine.cpp +++ b/src/smt/smt_engine.cpp @@ -55,7 +55,6 @@ #include "options/booleans_options.h" #include "options/bv_options.h" #include "options/datatypes_options.h" -#include "options/decision_mode.h" #include "options/decision_options.h" #include "options/language.h" #include "options/main_options.h" @@ -68,7 +67,6 @@ #include "options/sep_options.h" #include "options/set_language.h" #include "options/smt_options.h" -#include "options/strings_modes.h" #include "options/strings_options.h" #include "options/theory_options.h" #include "options/uf_options.h" @@ -1165,7 +1163,7 @@ void SmtEngine::setDefaults() { } bool is_sygus = language::isInputLangSygus(options::inputLanguage()); - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + if (options::bitblastMode() == options::BitblastMode::EAGER) { if (options::produceModels() && (d_logic.isTheoryEnabled(THEORY_ARRAYS) @@ -1313,8 +1311,8 @@ void SmtEngine::setDefaults() { if ((options::checkModels() || options::checkSynthSol() || options::produceAbducts() - || options::modelCoresMode() != MODEL_CORES_NONE - || options::blockModelsMode() != BLOCK_MODELS_NONE) + || options::modelCoresMode() != options::ModelCoresMode::NONE + || options::blockModelsMode() != options::BlockModelsMode::NONE) && !options::produceAssertions()) { Notice() << "SmtEngine: turning on produce-assertions to support " @@ -1380,7 +1378,7 @@ void SmtEngine::setDefaults() { // error if enabled explicitly if (options::unsatCores() || options::proof()) { - if (options::simplificationMode() != SIMPLIFICATION_MODE_NONE) + if (options::simplificationMode() != options::SimplificationMode::NONE) { if (options::simplificationMode.wasSetByUser()) { @@ -1390,7 +1388,7 @@ void SmtEngine::setDefaults() { Notice() << "SmtEngine: turning off simplification to support unsat " "cores/proofs" << endl; - options::simplificationMode.set(SIMPLIFICATION_MODE_NONE); + options::simplificationMode.set(options::SimplificationMode::NONE); } if (options::pbRewrites()) @@ -1445,7 +1443,7 @@ void SmtEngine::setDefaults() { options::bitvectorToBool.set(false); } - if (options::boolToBitvector() != preprocessing::passes::BOOL_TO_BV_OFF) + if (options::boolToBitvector() != options::BoolToBVMode::OFF) { if (options::boolToBitvector.wasSetByUser()) { @@ -1513,15 +1511,17 @@ void SmtEngine::setDefaults() { << d_logic.getLogicString() << "> " << (!qf_sat) << endl; // simplification=none works better for SMT LIB benchmarks with // quantifiers, not others options::simplificationMode.set(qf_sat || - // quantifiers ? SIMPLIFICATION_MODE_NONE : SIMPLIFICATION_MODE_BATCH); - options::simplificationMode.set(qf_sat ? SIMPLIFICATION_MODE_NONE - : SIMPLIFICATION_MODE_BATCH); + // quantifiers ? options::SimplificationMode::NONE : + // options::SimplificationMode::BATCH); + options::simplificationMode.set(qf_sat + ? options::SimplificationMode::NONE + : options::SimplificationMode::BATCH); } } if (options::cbqiBv() && d_logic.isQuantified()) { - if (options::boolToBitvector() != preprocessing::passes::BOOL_TO_BV_OFF) + if (options::boolToBitvector() != options::BoolToBVMode::OFF) { if (options::boolToBitvector.wasSetByUser()) { @@ -1551,7 +1551,7 @@ void SmtEngine::setDefaults() { !d_logic.isTheoryEnabled(THEORY_STRINGS) && !d_logic.isTheoryEnabled(THEORY_SETS) ) { Trace("smt") << "setting theoryof-mode to term-based" << endl; - options::theoryOfMode.set(THEORY_OF_TERM_BASED); + options::theoryOfMode.set(options::TheoryOfMode::THEORY_OF_TERM_BASED); } } @@ -1694,7 +1694,7 @@ void SmtEngine::setDefaults() { } } - if (options::boolToBitvector() == preprocessing::passes::BOOL_TO_BV_ALL + if (options::boolToBitvector() == options::BoolToBVMode::ALL && !d_logic.isTheoryEnabled(THEORY_BV)) { if (options::boolToBitvector.wasSetByUser()) @@ -1765,41 +1765,40 @@ void SmtEngine::setDefaults() { // Set decision mode based on logic (if not set by user) if(!options::decisionMode.wasSetByUser()) { - decision::DecisionMode decMode = + options::DecisionMode decMode = // sygus uses internal - is_sygus ? decision::DECISION_STRATEGY_INTERNAL : + is_sygus ? options::DecisionMode::INTERNAL : // ALL d_logic.hasEverything() - ? decision::DECISION_STRATEGY_JUSTIFICATION + ? options::DecisionMode::JUSTIFICATION : ( // QF_BV - (not d_logic.isQuantified() && d_logic.isPure(THEORY_BV)) - || - // QF_AUFBV or QF_ABV or QF_UFBV - (not d_logic.isQuantified() - && (d_logic.isTheoryEnabled(THEORY_ARRAYS) - || d_logic.isTheoryEnabled(THEORY_UF)) - && d_logic.isTheoryEnabled(THEORY_BV)) - || - // QF_AUFLIA (and may be ends up enabling - // QF_AUFLRA?) - (not d_logic.isQuantified() - && d_logic.isTheoryEnabled(THEORY_ARRAYS) - && d_logic.isTheoryEnabled(THEORY_UF) - && d_logic.isTheoryEnabled(THEORY_ARITH)) - || - // QF_LRA - (not d_logic.isQuantified() - && d_logic.isPure(THEORY_ARITH) - && d_logic.isLinear() - && !d_logic.isDifferenceLogic() - && !d_logic.areIntegersUsed()) - || - // Quantifiers - d_logic.isQuantified() || - // Strings - d_logic.isTheoryEnabled(THEORY_STRINGS) - ? decision::DECISION_STRATEGY_JUSTIFICATION - : decision::DECISION_STRATEGY_INTERNAL); + (not d_logic.isQuantified() && d_logic.isPure(THEORY_BV)) || + // QF_AUFBV or QF_ABV or QF_UFBV + (not d_logic.isQuantified() + && (d_logic.isTheoryEnabled(THEORY_ARRAYS) + || d_logic.isTheoryEnabled(THEORY_UF)) + && d_logic.isTheoryEnabled(THEORY_BV)) + || + // QF_AUFLIA (and may be ends up enabling + // QF_AUFLRA?) + (not d_logic.isQuantified() + && d_logic.isTheoryEnabled(THEORY_ARRAYS) + && d_logic.isTheoryEnabled(THEORY_UF) + && d_logic.isTheoryEnabled(THEORY_ARITH)) + || + // QF_LRA + (not d_logic.isQuantified() + && d_logic.isPure(THEORY_ARITH) + && d_logic.isLinear() + && !d_logic.isDifferenceLogic() + && !d_logic.areIntegersUsed()) + || + // Quantifiers + d_logic.isQuantified() || + // Strings + d_logic.isTheoryEnabled(THEORY_STRINGS) + ? options::DecisionMode::JUSTIFICATION + : options::DecisionMode::INTERNAL); bool stoponly = // ALL @@ -1867,20 +1866,21 @@ void SmtEngine::setDefaults() { //apply fmfBoundInt options if( options::fmfBound() ){ if (!options::mbqiMode.wasSetByUser() - || (options::mbqiMode() != quantifiers::MBQI_NONE - && options::mbqiMode() != quantifiers::MBQI_FMC)) + || (options::mbqiMode() != options::MbqiMode::NONE + && options::mbqiMode() != options::MbqiMode::FMC)) { //if bounded integers are set, use no MBQI by default - options::mbqiMode.set( quantifiers::MBQI_NONE ); + options::mbqiMode.set(options::MbqiMode::NONE); } if( ! options::prenexQuant.wasSetByUser() ){ - options::prenexQuant.set( quantifiers::PRENEX_QUANT_NONE ); + options::prenexQuant.set(options::PrenexQuantMode::NONE); } } if( options::ufHo() ){ //if higher-order, then current variants of model-based instantiation cannot be used - if( options::mbqiMode()!=quantifiers::MBQI_NONE ){ - options::mbqiMode.set( quantifiers::MBQI_NONE ); + if (options::mbqiMode() != options::MbqiMode::NONE) + { + options::mbqiMode.set(options::MbqiMode::NONE); } if (!options::hoElimStoreAx.wasSetByUser()) { @@ -1910,7 +1910,7 @@ void SmtEngine::setDefaults() { if( options::finiteModelFind() ){ //apply conservative quantifiers splitting if( !options::quantDynamicSplit.wasSetByUser() ){ - options::quantDynamicSplit.set( quantifiers::QUANT_DSPLIT_MODE_DEFAULT ); + options::quantDynamicSplit.set(options::QuantDSplitMode::DEFAULT); } //do not eliminate extended arithmetic symbols from quantified formulas if( !options::elimExtArithQuant.wasSetByUser() ){ @@ -1922,7 +1922,7 @@ void SmtEngine::setDefaults() { if( !options::instWhenMode.wasSetByUser() ){ //instantiate only on last call if( options::eMatching() ){ - options::instWhenMode.set( quantifiers::INST_WHEN_LAST_CALL ); + options::instWhenMode.set(options::InstWhenMode::LAST_CALL); } } } @@ -1960,7 +1960,8 @@ void SmtEngine::setDefaults() { options::preSkolemQuantNested.set(true); } } - if( options::cegqiSingleInvMode()!=quantifiers::CEGQI_SI_MODE_NONE ){ + if (options::cegqiSingleInvMode() != options::CegqiSingleInvMode::NONE) + { if( !options::ceGuidedInst.wasSetByUser() ){ options::ceGuidedInst.set( true ); } @@ -1969,7 +1970,7 @@ void SmtEngine::setDefaults() { if( options::ceGuidedInst() ){ //counterexample-guided instantiation for sygus if( !options::cegqiSingleInvMode.wasSetByUser() ){ - options::cegqiSingleInvMode.set( quantifiers::CEGQI_SI_MODE_USE ); + options::cegqiSingleInvMode.set(options::CegqiSingleInvMode::USE); } if( !options::quantConflictFind.wasSetByUser() ){ options::quantConflictFind.set( false ); @@ -2010,7 +2011,7 @@ void SmtEngine::setDefaults() { // if doing abduction, we should filter strong solutions if (!options::sygusFilterSolMode.wasSetByUser()) { - options::sygusFilterSolMode.set(quantifiers::SYGUS_FILTER_SOL_STRONG); + options::sygusFilterSolMode.set(options::SygusFilterSolMode::STRONG); } // we must use basic sygus algorithms, since e.g. we require checking // a sygus side condition for consistency with axioms. @@ -2042,11 +2043,11 @@ void SmtEngine::setDefaults() { } if (!options::sygusInvTemplMode.wasSetByUser()) { - options::sygusInvTemplMode.set(quantifiers::SYGUS_INV_TEMPL_MODE_NONE); + options::sygusInvTemplMode.set(options::SygusInvTemplMode::NONE); } if (!options::cegqiSingleInvMode.wasSetByUser()) { - options::cegqiSingleInvMode.set(quantifiers::CEGQI_SI_MODE_NONE); + options::cegqiSingleInvMode.set(options::CegqiSingleInvMode::NONE); } } //do not allow partial functions @@ -2120,7 +2121,7 @@ void SmtEngine::setDefaults() { } if( !options::instWhenMode.wasSetByUser() && options::cbqiModel() ){ //only instantiation should happen at last call when model is avaiable - options::instWhenMode.set( quantifiers::INST_WHEN_LAST_CALL ); + options::instWhenMode.set(options::InstWhenMode::LAST_CALL); } }else{ // only supported in pure arithmetic or pure BV @@ -2130,23 +2131,23 @@ void SmtEngine::setDefaults() { if (options::cbqiNestedQE()) { // only complete with prenex = disj_normal or normal - if (options::prenexQuant() <= quantifiers::PRENEX_QUANT_DISJ_NORMAL) + if (options::prenexQuant() <= options::PrenexQuantMode::DISJ_NORMAL) { - options::prenexQuant.set(quantifiers::PRENEX_QUANT_DISJ_NORMAL); + options::prenexQuant.set(options::PrenexQuantMode::DISJ_NORMAL); } } else if (options::globalNegate()) { if (!options::prenexQuant.wasSetByUser()) { - options::prenexQuant.set(quantifiers::PRENEX_QUANT_NONE); + options::prenexQuant.set(options::PrenexQuantMode::NONE); } } } //implied options... if( options::strictTriggers() ){ if( !options::userPatternsQuant.wasSetByUser() ){ - options::userPatternsQuant.set( quantifiers::USER_PAT_MODE_TRUST ); + options::userPatternsQuant.set(options::UserPatMode::TRUST); } } if( options::qcfMode.wasSetByUser() || options::qcfTConstraint() ){ @@ -2173,7 +2174,7 @@ void SmtEngine::setDefaults() { options::iteDtTesterSplitQuant.set( true ); } if( !options::iteLiftQuant.wasSetByUser() ){ - options::iteLiftQuant.set( quantifiers::ITE_LIFT_QUANT_MODE_ALL ); + options::iteLiftQuant.set(options::IteLiftQuantMode::ALL); } } if( options::intWfInduction() ){ @@ -2206,7 +2207,7 @@ void SmtEngine::setDefaults() { } } if( !d_logic.isTheoryEnabled(THEORY_DATATYPES) ){ - options::quantDynamicSplit.set( quantifiers::QUANT_DSPLIT_MODE_NONE ); + options::quantDynamicSplit.set(options::QuantDSplitMode::NONE); } //until bugs 371,431 are fixed @@ -2375,8 +2376,7 @@ void SmtEngine::setDefaults() { Trace("smt") << "settting stringProcessLoopMode to 'simple' since " "--strings-fmf enabled" << endl; - options::stringProcessLoopMode.set( - theory::strings::ProcessLoopMode::SIMPLE); + options::stringProcessLoopMode.set(options::ProcessLoopMode::SIMPLE); } } @@ -2952,7 +2952,7 @@ bool SmtEnginePrivate::simplifyAssertions() Trace("simplify") << "SmtEnginePrivate::simplify()" << endl; - if (options::simplificationMode() != SIMPLIFICATION_MODE_NONE) + if (options::simplificationMode() != options::SimplificationMode::NONE) { if (!options::unsatCores() && !options::fewerPreprocessingHoles()) { @@ -3016,7 +3016,7 @@ bool SmtEnginePrivate::simplifyAssertions() } if (options::repeatSimp() - && options::simplificationMode() != SIMPLIFICATION_MODE_NONE + && options::simplificationMode() != options::SimplificationMode::NONE && !options::unsatCores() && !options::fewerPreprocessingHoles()) { PreprocessingPassResult res = @@ -3292,10 +3292,11 @@ void SmtEnginePrivate::processAssertions() { d_passes["int-to-bv"]->apply(&d_assertions); } - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER && - !d_smt.d_logic.isPure(THEORY_BV) && - d_smt.d_logic.getLogicString() != "QF_UFBV" && - d_smt.d_logic.getLogicString() != "QF_ABV") { + if (options::bitblastMode() == options::BitblastMode::EAGER + && !d_smt.d_logic.isPure(THEORY_BV) + && d_smt.d_logic.getLogicString() != "QF_UFBV" + && d_smt.d_logic.getLogicString() != "QF_ABV") + { throw ModalException("Eager bit-blasting does not currently support theory combination. " "Note that in a QF_BV problem UF symbols can be introduced for division. " "Try --bv-div-zero-const to interpret division by zero as a constant."); @@ -3356,7 +3357,7 @@ void SmtEnginePrivate::processAssertions() { d_passes["bv-to-bool"]->apply(&d_assertions); } // Convert non-top-level Booleans to bit-vectors of size 1 - if (options::boolToBitvector()) + if (options::boolToBitvector() != options::BoolToBVMode::OFF) { d_passes["bool-to-bv"]->apply(&d_assertions); } @@ -3554,7 +3555,7 @@ void SmtEnginePrivate::processAssertions() { d_passes["theory-preprocess"]->apply(&d_assertions); - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + if (options::bitblastMode() == options::BitblastMode::EAGER) { d_passes["bv-eager-atoms"]->apply(&d_assertions); } @@ -4438,7 +4439,7 @@ Model* SmtEngine::getModel() { // the theory engine into "eager model building" mode. TODO #2648: revisit. d_theoryEngine->setEagerModelBuilding(); - if (options::modelCoresMode() != MODEL_CORES_NONE) + if (options::modelCoresMode() != options::ModelCoresMode::NONE) { // If we enabled model cores, we compute a model core for m based on our // (expanded) assertions using the model core builder utility @@ -4464,7 +4465,7 @@ Result SmtEngine::blockModel() TheoryModel* m = getAvailableModel("block model"); - if (options::blockModelsMode() == BLOCK_MODELS_NONE) + if (options::blockModelsMode() == options::BlockModelsMode::NONE) { std::stringstream ss; ss << "Cannot block model when block-models is set to none."; @@ -4499,7 +4500,7 @@ Result SmtEngine::blockModelValues(const std::vector& exprs) std::vector eassertsProc = getExpandedAssertions(); // we always do block model values mode here Expr eblocker = ModelBlocker::getModelBlocker( - eassertsProc, m, BLOCK_MODELS_VALUES, exprs); + eassertsProc, m, options::BlockModelsMode::VALUES, exprs); return assertFormula(eblocker); } @@ -5097,7 +5098,8 @@ const Proof& SmtEngine::getProof() void SmtEngine::printInstantiations( std::ostream& out ) { SmtScope smts(this); finalOptionsAreSet(); - if( options::instFormatMode()==INST_FORMAT_MODE_SZS ){ + if (options::instFormatMode() == options::InstFormatMode::SZS) + { out << "% SZS output start Proof for " << d_filename.c_str() << std::endl; } if( d_theoryEngine ){ @@ -5105,7 +5107,8 @@ void SmtEngine::printInstantiations( std::ostream& out ) { }else{ Assert(false); } - if( options::instFormatMode()==INST_FORMAT_MODE_SZS ){ + if (options::instFormatMode() == options::InstFormatMode::SZS) + { out << "% SZS output end Proof for " << d_filename.c_str() << std::endl; } } diff --git a/src/theory/arith/attempt_solution_simplex.cpp b/src/theory/arith/attempt_solution_simplex.cpp index 8173f2cea..983fa2b30 100644 --- a/src/theory/arith/attempt_solution_simplex.cpp +++ b/src/theory/arith/attempt_solution_simplex.cpp @@ -78,7 +78,7 @@ Result::Sat AttemptSolutionSDP::attempt(const ApproximateSimplex::Solution& sol) } } d_errorSet.reduceToSignals(); - d_errorSet.setSelectionRule(VAR_ORDER); + d_errorSet.setSelectionRule(options::ErrorSelectionRule::VAR_ORDER); static int instance = 0; ++instance; diff --git a/src/theory/arith/dual_simplex.cpp b/src/theory/arith/dual_simplex.cpp index 47a196353..bcb90f8ae 100644 --- a/src/theory/arith/dual_simplex.cpp +++ b/src/theory/arith/dual_simplex.cpp @@ -73,7 +73,7 @@ Result::Sat DualSimplexDecisionProcedure::dualFindModel(bool exactResult){ // We need to reduce this because of d_errorSet.reduceToSignals(); - d_errorSet.setSelectionRule(VAR_ORDER); + d_errorSet.setSelectionRule(options::ErrorSelectionRule::VAR_ORDER); if(processSignals()){ d_conflictVariables.purge(); @@ -121,7 +121,7 @@ Result::Sat DualSimplexDecisionProcedure::dualFindModel(bool exactResult){ if(!d_errorSet.errorEmpty() && result != Result::UNSAT){ if(exactResult){ - d_errorSet.setSelectionRule(VAR_ORDER); + d_errorSet.setSelectionRule(options::ErrorSelectionRule::VAR_ORDER); while(!d_errorSet.errorEmpty() && result != Result::UNSAT){ Assert(checkPeriod > 0); if(searchForFeasibleSolution(checkPeriod)){ @@ -129,7 +129,7 @@ Result::Sat DualSimplexDecisionProcedure::dualFindModel(bool exactResult){ } } }else if( options::arithStandardCheckVarOrderPivots() > 0){ - d_errorSet.setSelectionRule(VAR_ORDER); + d_errorSet.setSelectionRule(options::ErrorSelectionRule::VAR_ORDER); if(searchForFeasibleSolution(options::arithStandardCheckVarOrderPivots())){ result = Result::UNSAT; } diff --git a/src/theory/arith/error_set.cpp b/src/theory/arith/error_set.cpp index 80c1e03ec..12e352e4d 100644 --- a/src/theory/arith/error_set.cpp +++ b/src/theory/arith/error_set.cpp @@ -152,37 +152,43 @@ ErrorSet::Statistics::~Statistics(){ smtStatisticsRegistry()->unregisterStat(&d_enqueuesVarOrderModeDuplicates); } -ErrorSet::ErrorSet(ArithVariables& vars, TableauSizes tabSizes, BoundCountingLookup lookups): - d_variables(vars), - d_errInfo(), - d_selectionRule(VAR_ORDER), - d_focus(ComparatorPivotRule(this,d_selectionRule)), - d_outOfFocus(), - d_signals(), - d_tableauSizes(tabSizes), - d_boundLookup(lookups) +ErrorSet::ErrorSet(ArithVariables& vars, + TableauSizes tabSizes, + BoundCountingLookup lookups) + : d_variables(vars), + d_errInfo(), + d_selectionRule(options::ErrorSelectionRule::VAR_ORDER), + d_focus(ComparatorPivotRule(this, d_selectionRule)), + d_outOfFocus(), + d_signals(), + d_tableauSizes(tabSizes), + d_boundLookup(lookups) {} -ErrorSelectionRule ErrorSet::getSelectionRule() const{ +options::ErrorSelectionRule ErrorSet::getSelectionRule() const +{ return d_selectionRule; } -void ErrorSet::recomputeAmount(ErrorInformation& ei, ErrorSelectionRule rule){ +void ErrorSet::recomputeAmount(ErrorInformation& ei, + options::ErrorSelectionRule rule) +{ switch(rule){ - case MINIMUM_AMOUNT: - case MAXIMUM_AMOUNT: - ei.setAmount(computeDiff(ei.getVariable())); - break; - case SUM_METRIC: - ei.setMetric(sumMetric(ei.getVariable())); - break; - case VAR_ORDER: - //do nothing - break; + case options::ErrorSelectionRule::MINIMUM_AMOUNT: + case options::ErrorSelectionRule::MAXIMUM_AMOUNT: + ei.setAmount(computeDiff(ei.getVariable())); + break; + case options::ErrorSelectionRule::SUM_METRIC: + ei.setMetric(sumMetric(ei.getVariable())); + break; + case options::ErrorSelectionRule::VAR_ORDER: + // do nothing + break; } } -void ErrorSet::setSelectionRule(ErrorSelectionRule rule){ +void ErrorSet::setSelectionRule(options::ErrorSelectionRule rule) +{ if(rule != getSelectionRule()){ FocusSet into(ComparatorPivotRule(this, rule)); FocusSet::const_iterator iter = d_focus.begin(); @@ -202,16 +208,17 @@ void ErrorSet::setSelectionRule(ErrorSelectionRule rule){ Assert(getSelectionRule() == rule); } -ComparatorPivotRule::ComparatorPivotRule(const ErrorSet* es, ErrorSelectionRule r): - d_errorSet(es), d_rule (r) +ComparatorPivotRule::ComparatorPivotRule(const ErrorSet* es, + options::ErrorSelectionRule r) + : d_errorSet(es), d_rule(r) {} bool ComparatorPivotRule::operator()(ArithVar v, ArithVar u) const { switch(d_rule){ - case VAR_ORDER: - // This needs to be the reverse of the minVariableOrder - return v > u; - case SUM_METRIC: + case options::ErrorSelectionRule::VAR_ORDER: + // This needs to be the reverse of the minVariableOrder + return v > u; + case options::ErrorSelectionRule::SUM_METRIC: { uint32_t v_metric = d_errorSet->getMetric(v); uint32_t u_metric = d_errorSet->getMetric(u); @@ -221,7 +228,7 @@ bool ComparatorPivotRule::operator()(ArithVar v, ArithVar u) const { return v_metric > u_metric; } } - case MINIMUM_AMOUNT: + case options::ErrorSelectionRule::MINIMUM_AMOUNT: { const DeltaRational& vamt = d_errorSet->getAmount(v); const DeltaRational& uamt = d_errorSet->getAmount(u); @@ -232,7 +239,7 @@ bool ComparatorPivotRule::operator()(ArithVar v, ArithVar u) const { return cmp > 0; } } - case MAXIMUM_AMOUNT: + case options::ErrorSelectionRule::MAXIMUM_AMOUNT: { const DeltaRational& vamt = d_errorSet->getAmount(v); const DeltaRational& uamt = d_errorSet->getAmount(u); @@ -251,18 +258,18 @@ void ErrorSet::update(ErrorInformation& ei){ if(ei.inFocus()){ switch(getSelectionRule()){ - case MINIMUM_AMOUNT: - case MAXIMUM_AMOUNT: - ei.setAmount(computeDiff(ei.getVariable())); - d_focus.update(ei.getHandle(), ei.getVariable()); - break; - case SUM_METRIC: - ei.setMetric(sumMetric(ei.getVariable())); - d_focus.update(ei.getHandle(), ei.getVariable()); - break; - case VAR_ORDER: - //do nothing - break; + case options::ErrorSelectionRule::MINIMUM_AMOUNT: + case options::ErrorSelectionRule::MAXIMUM_AMOUNT: + ei.setAmount(computeDiff(ei.getVariable())); + d_focus.update(ei.getHandle(), ei.getVariable()); + break; + case options::ErrorSelectionRule::SUM_METRIC: + ei.setMetric(sumMetric(ei.getVariable())); + d_focus.update(ei.getHandle(), ei.getVariable()); + break; + case options::ErrorSelectionRule::VAR_ORDER: + // do nothing + break; } } } @@ -300,16 +307,16 @@ void ErrorSet::transitionVariableIntoError(ArithVar v) { ErrorInformation& ei = d_errInfo.get(v); switch(getSelectionRule()){ - case MINIMUM_AMOUNT: - case MAXIMUM_AMOUNT: - ei.setAmount(computeDiff(v)); - break; - case SUM_METRIC: - ei.setMetric(sumMetric(ei.getVariable())); - break; - case VAR_ORDER: - //do nothing - break; + case options::ErrorSelectionRule::MINIMUM_AMOUNT: + case options::ErrorSelectionRule::MAXIMUM_AMOUNT: + ei.setAmount(computeDiff(v)); + break; + case options::ErrorSelectionRule::SUM_METRIC: + ei.setMetric(sumMetric(ei.getVariable())); + break; + case options::ErrorSelectionRule::VAR_ORDER: + // do nothing + break; } ei.setInFocus(true); FocusSetHandle handle = d_focus.push(v); @@ -330,16 +337,16 @@ void ErrorSet::addBackIntoFocus(ArithVar v) { ErrorInformation& ei = d_errInfo.get(v); Assert(!ei.inFocus()); switch(getSelectionRule()){ - case MINIMUM_AMOUNT: - case MAXIMUM_AMOUNT: - ei.setAmount(computeDiff(v)); - break; - case SUM_METRIC: - ei.setMetric(sumMetric(v)); - break; - case VAR_ORDER: - //do nothing - break; + case options::ErrorSelectionRule::MINIMUM_AMOUNT: + case options::ErrorSelectionRule::MAXIMUM_AMOUNT: + ei.setAmount(computeDiff(v)); + break; + case options::ErrorSelectionRule::SUM_METRIC: + ei.setMetric(sumMetric(v)); + break; + case options::ErrorSelectionRule::VAR_ORDER: + // do nothing + break; } ei.setInFocus(true); @@ -428,25 +435,6 @@ DeltaRational ErrorSet::computeDiff(ArithVar v) const{ return diff; } -ostream& operator<<(ostream& out, ErrorSelectionRule rule) { - switch(rule) { - case VAR_ORDER: - out << "VAR_ORDER"; - break; - case MINIMUM_AMOUNT: - out << "MINIMUM_AMOUNT"; - break; - case MAXIMUM_AMOUNT: - out << "MAXIMUM_AMOUNT"; - break; - case SUM_METRIC: - out << "SUM_METRIC"; - break; - } - - return out; -} - void ErrorSet::debugPrint(std::ostream& out) const { static int instance = 0; ++instance; diff --git a/src/theory/arith/error_set.h b/src/theory/arith/error_set.h index 9e3e7c630..5599cd268 100644 --- a/src/theory/arith/error_set.h +++ b/src/theory/arith/error_set.h @@ -22,7 +22,7 @@ #include -#include "options/arith_heuristic_pivot_rule.h" +#include "options/arith_options.h" #include "theory/arith/arithvar.h" #include "theory/arith/bound_counts.h" #include "theory/arith/callbacks.h" @@ -69,13 +69,14 @@ class ComparatorPivotRule { private: const ErrorSet* d_errorSet; - ErrorSelectionRule d_rule; -public: + options::ErrorSelectionRule d_rule; + + public: ComparatorPivotRule(); - ComparatorPivotRule(const ErrorSet* es, ErrorSelectionRule r); + ComparatorPivotRule(const ErrorSet* es, options::ErrorSelectionRule r); bool operator()(ArithVar v, ArithVar u) const; - ErrorSelectionRule getRule() const { return d_rule; } + options::ErrorSelectionRule getRule() const { return d_rule; } }; // typedef boost::heap::d_ary_heap< @@ -225,7 +226,7 @@ private: */ ErrorInfoMap d_errInfo; - ErrorSelectionRule d_selectionRule; + options::ErrorSelectionRule d_selectionRule; /** * The ordered heap for the variables that are in ErrorSet. */ @@ -259,12 +260,12 @@ private: public: DeltaRational computeDiff(ArithVar x) const; private: - void recomputeAmount(ErrorInformation& ei, ErrorSelectionRule r); + void recomputeAmount(ErrorInformation& ei, options::ErrorSelectionRule r); - void update(ErrorInformation& ei); - void transitionVariableOutOfError(ArithVar v); - void transitionVariableIntoError(ArithVar v); - void addBackIntoFocus(ArithVar v); + void update(ErrorInformation& ei); + void transitionVariableOutOfError(ArithVar v); + void transitionVariableIntoError(ArithVar v); + void addBackIntoFocus(ArithVar v); public: @@ -291,8 +292,8 @@ public: void pushErrorInto(ArithVarVec& vec) const; void pushFocusInto(ArithVarVec& vec) const; - ErrorSelectionRule getSelectionRule() const; - void setSelectionRule(ErrorSelectionRule rule); + options::ErrorSelectionRule getSelectionRule() const; + void setSelectionRule(options::ErrorSelectionRule rule); inline ArithVar topFocusVariable() const{ Assert(!focusEmpty()); diff --git a/src/theory/arith/fc_simplex.cpp b/src/theory/arith/fc_simplex.cpp index 29177d3f4..125a24f5e 100644 --- a/src/theory/arith/fc_simplex.cpp +++ b/src/theory/arith/fc_simplex.cpp @@ -106,8 +106,7 @@ Result::Sat FCSimplexDecisionProcedure::findModel(bool exactResult){ d_errorSet.reduceToSignals(); // We must start tracking NOW - d_errorSet.setSelectionRule(SUM_METRIC); - + d_errorSet.setSelectionRule(options::ErrorSelectionRule::SUM_METRIC); if(initialProcessSignals()){ d_conflictVariables.purge(); diff --git a/src/theory/arith/nonlinear_extension.cpp b/src/theory/arith/nonlinear_extension.cpp index ff2ec412b..e8b1b3b93 100644 --- a/src/theory/arith/nonlinear_extension.cpp +++ b/src/theory/arith/nonlinear_extension.cpp @@ -583,7 +583,7 @@ unsigned NonlinearExtension::filterLemmas(std::vector& lemmas, Trace("nl-ext-et-debug") << "Check entailment of " << ch_lemma << "..." << std::endl; std::pair et = d_containing.getValuation().entailmentCheck( - THEORY_OF_TYPE_BASED, ch_lemma); + options::TheoryOfMode::THEORY_OF_TYPE_BASED, ch_lemma); Trace("nl-ext-et-debug") << "entailment test result : " << et.first << " " << et.second << std::endl; if (et.first) diff --git a/src/theory/arith/simplex.h b/src/theory/arith/simplex.h index 56a9bc95f..5bd6034d2 100644 --- a/src/theory/arith/simplex.h +++ b/src/theory/arith/simplex.h @@ -79,7 +79,7 @@ protected: DenseSet d_conflictVariables; /** The rule to use for heuristic selection mode. */ - ErrorSelectionRule d_heuristicRule; + options::ErrorSelectionRule d_heuristicRule; /** Linear equality module. */ LinearEqualityModule& d_linEq; diff --git a/src/theory/arith/soi_simplex.cpp b/src/theory/arith/soi_simplex.cpp index e50d9d060..1876f4b88 100644 --- a/src/theory/arith/soi_simplex.cpp +++ b/src/theory/arith/soi_simplex.cpp @@ -117,7 +117,7 @@ Result::Sat SumOfInfeasibilitiesSPD::findModel(bool exactResult){ d_errorSet.reduceToSignals(); // We must start tracking NOW - d_errorSet.setSelectionRule(SUM_METRIC); + d_errorSet.setSelectionRule(options::ErrorSelectionRule::SUM_METRIC); if(initialProcessSignals()){ d_conflictVariables.purge(); diff --git a/src/theory/arith/theory_arith_private.cpp b/src/theory/arith/theory_arith_private.cpp index 58636a10b..b8bdd04e1 100644 --- a/src/theory/arith/theory_arith_private.cpp +++ b/src/theory/arith/theory_arith_private.cpp @@ -3736,9 +3736,12 @@ void TheoryArithPrivate::check(Theory::Effort effortLevel){ << "post approx cuts" << endl; // This should be fine if sat or unknown - if(!emmittedConflictOrSplit && - (options::arithPropagationMode() == UNATE_PROP || - options::arithPropagationMode() == BOTH_PROP)){ + if (!emmittedConflictOrSplit + && (options::arithPropagationMode() + == options::ArithPropagationMode::UNATE_PROP + || options::arithPropagationMode() + == options::ArithPropagationMode::BOTH_PROP)) + { TimerStat::CodeTimer codeTimer(d_statistics.d_newPropTime); Assert(d_qflraStatus != Result::UNSAT); @@ -3789,7 +3792,9 @@ void TheoryArithPrivate::check(Theory::Effort effortLevel){ Debug("arith::conflict") << "unate arith conflict" << endl; } - }else{ + } + else + { TimerStat::CodeTimer codeTimer(d_statistics.d_newPropTime); d_currentPropagationList.clear(); } @@ -4109,16 +4114,21 @@ bool TheoryArithPrivate::isExtfReduced(int effort, Node n, Node on, void TheoryArithPrivate::propagate(Theory::Effort e) { // This uses model values for safety. Disable for now. - if(d_qflraStatus == Result::SAT && - (options::arithPropagationMode() == BOUND_INFERENCE_PROP || - options::arithPropagationMode() == BOTH_PROP) - && hasAnyUpdates()){ + if (d_qflraStatus == Result::SAT + && (options::arithPropagationMode() + == options::ArithPropagationMode::BOUND_INFERENCE_PROP + || options::arithPropagationMode() + == options::ArithPropagationMode::BOTH_PROP) + && hasAnyUpdates()) + { if(options::newProp()){ propagateCandidatesNew(); }else{ propagateCandidates(); } - }else{ + } + else + { clearUpdates(); } @@ -4474,19 +4484,18 @@ void TheoryArithPrivate::presolve(){ vector lemmas; if(!options::incrementalSolving()) { switch(options::arithUnateLemmaMode()){ - case NO_PRESOLVE_LEMMAS: - break; - case INEQUALITY_PRESOLVE_LEMMAS: - d_constraintDatabase.outputUnateInequalityLemmas(lemmas); - break; - case EQUALITY_PRESOLVE_LEMMAS: - d_constraintDatabase.outputUnateEqualityLemmas(lemmas); - break; - case ALL_PRESOLVE_LEMMAS: - d_constraintDatabase.outputUnateInequalityLemmas(lemmas); - d_constraintDatabase.outputUnateEqualityLemmas(lemmas); - break; - default: Unhandled() << options::arithUnateLemmaMode(); + case options::ArithUnateLemmaMode::NO: break; + case options::ArithUnateLemmaMode::INEQUALITY: + d_constraintDatabase.outputUnateInequalityLemmas(lemmas); + break; + case options::ArithUnateLemmaMode::EQUALITY: + d_constraintDatabase.outputUnateEqualityLemmas(lemmas); + break; + case options::ArithUnateLemmaMode::ALL: + d_constraintDatabase.outputUnateInequalityLemmas(lemmas); + d_constraintDatabase.outputUnateEqualityLemmas(lemmas); + break; + default: Unhandled() << options::arithUnateLemmaMode(); } } diff --git a/src/theory/bv/abstraction.cpp b/src/theory/bv/abstraction.cpp index d9de9731a..d3aeb5c37 100644 --- a/src/theory/bv/abstraction.cpp +++ b/src/theory/bv/abstraction.cpp @@ -88,7 +88,7 @@ bool AbstractionModule::applyAbstraction(const std::vector& assertions, } // if we are using the eager solver reverse the abstraction - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + if (options::bitblastMode() == options::BitblastMode::EAGER) { if (d_funcToSignature.size() == 0) { @@ -1081,7 +1081,8 @@ bool AbstractionModule::isLemmaAtom(TNode node) const { } void AbstractionModule::addInputAtom(TNode atom) { - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY) { + if (options::bitblastMode() == options::BitblastMode::LAZY) + { d_inputAtoms.insert(atom); } } diff --git a/src/theory/bv/bitblast/eager_bitblaster.cpp b/src/theory/bv/bitblast/eager_bitblaster.cpp index 9d43355cc..cd906769d 100644 --- a/src/theory/bv/bitblast/eager_bitblaster.cpp +++ b/src/theory/bv/bitblast/eager_bitblaster.cpp @@ -42,7 +42,7 @@ EagerBitblaster::EagerBitblaster(TheoryBV* theory_bv, context::Context* c) prop::SatSolver *solver = nullptr; switch (options::bvSatSolver()) { - case SAT_SOLVER_MINISAT: + case options::SatSolverMode::MINISAT: { prop::BVSatSolverInterface* minisat = prop::SatSolverFactory::createMinisat( @@ -52,11 +52,11 @@ EagerBitblaster::EagerBitblaster(TheoryBV* theory_bv, context::Context* c) solver = minisat; break; } - case SAT_SOLVER_CADICAL: + case options::SatSolverMode::CADICAL: solver = prop::SatSolverFactory::createCadical(smtStatisticsRegistry(), "EagerBitblaster"); break; - case SAT_SOLVER_CRYPTOMINISAT: + case options::SatSolverMode::CRYPTOMINISAT: solver = prop::SatSolverFactory::createCryptoMinisat( smtStatisticsRegistry(), "EagerBitblaster"); break; @@ -120,7 +120,7 @@ void EagerBitblaster::bbAtom(TNode node) Node atom_definition = NodeManager::currentNM()->mkNode(kind::EQUAL, node, atom_bb); - AlwaysAssert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER); + AlwaysAssert(options::bitblastMode() == options::BitblastMode::EAGER); storeBBAtom(node, atom_bb); d_cnfStream->convertAndAssert( atom_definition, false, false, RULE_INVALID, TNode::null()); diff --git a/src/theory/bv/bv_subtheory_algebraic.cpp b/src/theory/bv/bv_subtheory_algebraic.cpp index 6f8804042..14753deec 100644 --- a/src/theory/bv/bv_subtheory_algebraic.cpp +++ b/src/theory/bv/bv_subtheory_algebraic.cpp @@ -253,7 +253,7 @@ AlgebraicSolver::~AlgebraicSolver() {} bool AlgebraicSolver::check(Theory::Effort e) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY); + Assert(options::bitblastMode() == options::BitblastMode::LAZY); if (!Theory::fullEffort(e)) { return true; } if (!useHeuristic()) { return true; } diff --git a/src/theory/bv/bv_subtheory_bitblast.cpp b/src/theory/bv/bv_subtheory_bitblast.cpp index 94dfdee14..25fe7002e 100644 --- a/src/theory/bv/bv_subtheory_bitblast.cpp +++ b/src/theory/bv/bv_subtheory_bitblast.cpp @@ -120,7 +120,7 @@ void BitblastSolver::bitblastQueue() { bool BitblastSolver::check(Theory::Effort e) { Debug("bv-bitblast") << "BitblastSolver::check (" << e << ")\n"; - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY); + Assert(options::bitblastMode() == options::BitblastMode::LAZY); ++(d_statistics.d_numCallstoCheck); diff --git a/src/theory/bv/slicer.cpp b/src/theory/bv/slicer.cpp index 0ffd58d5a..e1732625e 100644 --- a/src/theory/bv/slicer.cpp +++ b/src/theory/bv/slicer.cpp @@ -536,10 +536,14 @@ bool Slicer::isCoreTerm(TNode node) { if (d_coreTermCache.find(node) == d_coreTermCache.end()) { Kind kind = node.getKind(); bool not_core; - if (options::bitvectorEqualitySlicer() != BITVECTOR_SLICER_OFF) { - not_core = (kind != kind::BITVECTOR_EXTRACT && kind != kind::BITVECTOR_CONCAT); - } else { - not_core = true; + if (options::bitvectorEqualitySlicer() != options::BvSlicerMode::OFF) + { + not_core = + (kind != kind::BITVECTOR_EXTRACT && kind != kind::BITVECTOR_CONCAT); + } + else + { + not_core = true; } if (not_core && kind != kind::EQUAL && diff --git a/src/theory/bv/theory_bv.cpp b/src/theory/bv/theory_bv.cpp index 23ffabcd1..afd99647b 100644 --- a/src/theory/bv/theory_bv.cpp +++ b/src/theory/bv/theory_bv.cpp @@ -77,7 +77,8 @@ TheoryBV::TheoryBV(context::Context* c, setupExtTheory(); getExtTheory()->addFunctionKind(kind::BITVECTOR_TO_NAT); getExtTheory()->addFunctionKind(kind::INT_TO_BITVECTOR); - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) { + if (options::bitblastMode() == options::BitblastMode::EAGER) + { d_eagerSolver.reset(new EagerBitblastSolver(c, this)); return; } @@ -112,7 +113,8 @@ TheoryBV::TheoryBV(context::Context* c, TheoryBV::~TheoryBV() {} void TheoryBV::setMasterEqualityEngine(eq::EqualityEngine* eq) { - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) { + if (options::bitblastMode() == options::BitblastMode::EAGER) + { return; } if (options::bitvectorEqualitySolver()) { @@ -237,7 +239,7 @@ void TheoryBV::preRegisterTerm(TNode node) { d_calledPreregister = true; Debug("bitvector-preregister") << "TheoryBV::preRegister(" << node << ")" << std::endl; - if (options::bitblastMode() == BITBLAST_MODE_EAGER) + if (options::bitblastMode() == options::BitblastMode::EAGER) { // the aig bit-blaster option is set heuristically // if bv abstraction is used @@ -325,7 +327,8 @@ void TheoryBV::check(Effort e) // we may be getting new assertions so the model cache may not be sound d_invalidateModelCache.set(true); // if we are using the eager solver - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) { + if (options::bitblastMode() == options::BitblastMode::EAGER) + { // this can only happen on an empty benchmark if (!d_eagerSolver->isInitialized()) { d_eagerSolver->initialize(); @@ -354,7 +357,6 @@ void TheoryBV::check(Effort e) return; } - if (Theory::fullEffort(e)) { ++(d_statistics.d_numCallsToCheckFullEffort); } else { @@ -521,7 +523,8 @@ bool TheoryBV::needsCheckLastEffort() { bool TheoryBV::collectModelInfo(TheoryModel* m) { Assert(!inConflict()); - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) { + if (options::bitblastMode() == options::BitblastMode::EAGER) + { if (!d_eagerSolver->collectModelInfo(m, true)) { return false; @@ -547,7 +550,8 @@ Node TheoryBV::getModelValue(TNode var) { void TheoryBV::propagate(Effort e) { Debug("bitvector") << indent() << "TheoryBV::propagate()" << std::endl; - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) { + if (options::bitblastMode() == options::BitblastMode::EAGER) + { return; } @@ -910,9 +914,9 @@ void TheoryBV::addSharedTerm(TNode t) { EqualityStatus TheoryBV::getEqualityStatus(TNode a, TNode b) { - if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + if (options::bitblastMode() == options::BitblastMode::EAGER) return EQUALITY_UNKNOWN; - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY); + Assert(options::bitblastMode() == options::BitblastMode::LAZY); for (unsigned i = 0; i < d_subtheories.size(); ++i) { EqualityStatus status = d_subtheories[i]->getEqualityStatus(a, b); if (status != EQUALITY_UNKNOWN) { @@ -975,9 +979,9 @@ void TheoryBV::ppStaticLearn(TNode in, NodeBuilder<>& learned) { bool TheoryBV::applyAbstraction(const std::vector& assertions, std::vector& new_assertions) { bool changed = d_abstractionModule->applyAbstraction(assertions, new_assertions); - if (changed && - options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER && - options::bitvectorAig()) { + if (changed && options::bitblastMode() == options::BitblastMode::EAGER + && options::bitvectorAig()) + { // disable AIG mode AlwaysAssert(!d_eagerSolver->isInitialized()); d_eagerSolver->turnOffAig(); @@ -988,9 +992,12 @@ bool TheoryBV::applyAbstraction(const std::vector& assertions, std::vector void TheoryBV::setProofLog(proof::BitVectorProof* bvp) { - if( options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER ){ + if (options::bitblastMode() == options::BitblastMode::EAGER) + { d_eagerSolver->setProofLog(bvp); - }else{ + } + else + { for( unsigned i=0; i< d_subtheories.size(); i++ ){ d_subtheories[i]->setProofLog( bvp ); } diff --git a/src/theory/bv/theory_bv_utils.cpp b/src/theory/bv/theory_bv_utils.cpp index c0df9f35c..765541150 100644 --- a/src/theory/bv/theory_bv_utils.cpp +++ b/src/theory/bv/theory_bv_utils.cpp @@ -18,6 +18,7 @@ #include +#include "options/theory_options.h" #include "theory/theory.h" namespace CVC4 { @@ -156,7 +157,7 @@ static bool isCoreEqTerm(bool iseq, TNode term, TNodeBoolMap& cache) continue; } - if (theory::Theory::theoryOf(theory::THEORY_OF_TERM_BASED, n) + if (theory::Theory::theoryOf(options::TheoryOfMode::THEORY_OF_TERM_BASED, n) == theory::THEORY_BV) { Kind k = n.getKind(); diff --git a/src/theory/datatypes/sygus_extension.cpp b/src/theory/datatypes/sygus_extension.cpp index 42fb5cd07..890b8b2b9 100644 --- a/src/theory/datatypes/sygus_extension.cpp +++ b/src/theory/datatypes/sygus_extension.cpp @@ -107,7 +107,8 @@ void SygusExtension::assertFact( Node n, bool polarity, std::vector< Node >& lem Node m = n[0]; Trace("sygus-fair") << "Have sygus bound : " << n << ", polarity=" << polarity << " on measure " << m << std::endl; registerMeasureTerm( m ); - if( options::sygusFair()==SYGUS_FAIR_DT_SIZE ){ + if (options::sygusFair() == options::SygusFairMode::DT_SIZE) + { std::map>::iterator its = d_szinfo.find(m); Assert(its != d_szinfo.end()); @@ -245,8 +246,9 @@ void SygusExtension::assertTesterInternal( int tindex, TNode n, Node exp, std::v d_szinfo.find(m); Assert(itsz != d_szinfo.end()); unsigned ssz = itsz->second->d_curr_search_size; - - if( options::sygusFair()==SYGUS_FAIR_DIRECT ){ + + if (options::sygusFair() == options::SygusFairMode::DIRECT) + { if( dt[tindex].getNumArgs()>0 ){ quantifiers::SygusTypeInfo& nti = d_tds->getTypeInfo(ntn); // consider lower bounds for size of types @@ -596,7 +598,8 @@ Node SygusExtension::getSimpleSymBreakPred(Node e, { Trace("sygus-sb-simple-debug") << " Size..." << std::endl; // fairness - if (options::sygusFair() == SYGUS_FAIR_DT_SIZE && !isAnyConstant) + if (options::sygusFair() == options::SygusFairMode::DT_SIZE + && !isAnyConstant) { Node szl = nm->mkNode(DT_SIZE, n); Node szr = nm->mkNode(DT_SIZE, utils::getInstCons(n, dt, tindex)); @@ -1335,7 +1338,7 @@ void SygusExtension::registerSizeTerm(Node e, std::vector& lemmas) d_szinfo[m]->d_anchors.push_back(e); d_anchor_to_measure_term[e] = m; NodeManager* nm = NodeManager::currentNM(); - if (options::sygusFair() == SYGUS_FAIR_DT_SIZE) + if (options::sygusFair() == options::SygusFairMode::DT_SIZE) { // update constraints on the measure term Node slem; @@ -1575,7 +1578,8 @@ void SygusExtension::check( std::vector< Node >& lemmas ) { { isExc = false; //debugging : ensure fairness was properly handled - if( options::sygusFair()==SYGUS_FAIR_DT_SIZE ){ + if (options::sygusFair() == options::SygusFairMode::DT_SIZE) + { Node prog_sz = NodeManager::currentNM()->mkNode( kind::DT_SIZE, prog ); Node prog_szv = d_td->getValuation().getModel()->getValue( prog_sz ); Node progv_sz = NodeManager::currentNM()->mkNode( kind::DT_SIZE, progv ); @@ -1768,7 +1772,7 @@ Node SygusExtension::SygusSizeDecisionStrategy::getOrMkActiveMeasureValue( Node SygusExtension::SygusSizeDecisionStrategy::mkLiteral(unsigned s) { - if (options::sygusFair() == SYGUS_FAIR_NONE) + if (options::sygusFair() == options::SygusFairMode::NONE) { return Node::null(); } diff --git a/src/theory/datatypes/sygus_extension.h b/src/theory/datatypes/sygus_extension.h index 631f11040..5f6cfa00c 100644 --- a/src/theory/datatypes/sygus_extension.h +++ b/src/theory/datatypes/sygus_extension.h @@ -304,7 +304,7 @@ private: * lemmas on getSimpleSymBreakPred, see function below), * (3) conjecture-specific symmetry breaking lemmas, see * SynthConjecture::getSymmetryBreakingPredicate, - * (4) fairness conflicts if sygusFair() is SYGUS_FAIR_DIRECT, e.g.: + * (4) fairness conflicts if sygusFair() is SygusFairMode::DIRECT, e.g.: * size( d ) <= 1 V ~is-C1( d ) V ~is-C2( d.1 ) * where C1 and C2 are non-nullary constructors. */ @@ -584,12 +584,10 @@ private: * The measure value is an integer variable v that is a (symbolic) integer * value that is constrained to be less than or equal to the current search * size. For example, if we are using the fairness strategy - * SYGUS_FAIR_DT_SIZE (see options/datatype_options.h), then we constrain: - * (DT_SYGUS_BOUND m n) <=> (v <= n) - * for all asserted fairness literals. Then, if we are enforcing fairness - * based on the maximum size, we assert: - * (DT_SIZE e) <= v - * for all enumerators e. + * SygusFairMode::DT_SIZE (see options/datatype_options.h), then we + * constrain: (DT_SYGUS_BOUND m n) <=> (v <= n) for all asserted fairness + * literals. Then, if we are enforcing fairness based on the maximum size, + * we assert: (DT_SIZE e) <= v for all enumerators e. */ Node getOrMkMeasureValue(std::vector& lemmas); /** get or make the active measure value @@ -597,7 +595,7 @@ private: * The active measure value av is an integer variable that corresponds to * the (symbolic) value of the sum of enumerators that are yet to be * registered. This is to enforce the "sum of measures" strategy. For - * example, if we are using the fairness strategy SYGUS_FAIR_DT_SIZE, + * example, if we are using the fairness strategy SygusFairMode::DT_SIZE, * then initially av is equal to the measure value v, and the constraints * (DT_SYGUS_BOUND m n) <=> (v <= n) * are added as before. When an enumerator e is registered, we add the diff --git a/src/theory/quantifiers/cegqi/ceg_bv_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_bv_instantiator.cpp index c7aaf572c..59e9aedcb 100644 --- a/src/theory/quantifiers/cegqi/ceg_bv_instantiator.cpp +++ b/src/theory/quantifiers/cegqi/ceg_bv_instantiator.cpp @@ -153,7 +153,7 @@ Node BvInstantiator::hasProcessAssertion(CegInstantiator* ci, { return Node::null(); } - else if (options::cbqiBvIneqMode() == CBQI_BV_INEQ_KEEP + else if (options::cbqiBvIneqMode() == options::CbqiBvIneqMode::KEEP || (pol && k == EQUAL)) { return lit; @@ -172,7 +172,7 @@ Node BvInstantiator::hasProcessAssertion(CegInstantiator* ci, Trace("cegqi-bv") << " " << sm << " <> " << tm << std::endl; Node ret; - if (options::cbqiBvIneqMode() == CBQI_BV_INEQ_EQ_SLACK) + if (options::cbqiBvIneqMode() == options::CbqiBvIneqMode::EQ_SLACK) { // if using slack, we convert constraints to a positive equality based on // the current model M, e.g.: diff --git a/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp b/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp index 3420f282d..40216f7c9 100644 --- a/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp +++ b/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp @@ -85,14 +85,17 @@ int InstStrategyUserPatterns::process( Node f, Theory::Effort effort, int e ){ if( e==0 ){ return STATUS_UNFINISHED; }else{ - int peffort = d_quantEngine->getInstUserPatMode()==USER_PAT_MODE_RESORT ? 2 : 1; + int peffort = + d_quantEngine->getInstUserPatMode() == options::UserPatMode::RESORT ? 2 + : 1; if( e User-provided instantiate " << f << "..." << std::endl; - if( d_quantEngine->getInstUserPatMode()==USER_PAT_MODE_RESORT ){ + if (d_quantEngine->getInstUserPatMode() == options::UserPatMode::RESORT) + { for( unsigned i=0; igetInstUserPatMode()==USER_PAT_MODE_RESORT ){ + if (d_quantEngine->getInstUserPatMode() == options::UserPatMode::RESORT) + { d_user_gen_wait[q].push_back( nodes ); - }else{ + } + else + { Trigger * t = Trigger::mkTrigger( d_quantEngine, q, nodes, true, Trigger::TR_MAKE_NEW ); if( t ){ d_user_gen[q].push_back( t ); @@ -187,11 +193,17 @@ void InstStrategyAutoGenTriggers::processResetInstantiationRound( Theory::Effort } int InstStrategyAutoGenTriggers::process( Node f, Theory::Effort effort, int e ){ - UserPatMode upMode = d_quantEngine->getInstUserPatMode(); - if( hasUserPatterns( f ) && upMode==USER_PAT_MODE_TRUST ){ + options::UserPatMode upMode = d_quantEngine->getInstUserPatMode(); + if (hasUserPatterns(f) && upMode == options::UserPatMode::TRUST) + { return STATUS_UNKNOWN; - }else{ - int peffort = ( hasUserPatterns( f ) && upMode!=USER_PAT_MODE_IGNORE && upMode!=USER_PAT_MODE_RESORT ) ? 2 : 1; + } + else + { + int peffort = (hasUserPatterns(f) && upMode != options::UserPatMode::IGNORE + && upMode != options::UserPatMode::RESORT) + ? 2 + : 1; if( egetEqualityQuery()->setLiberal( true ); //} - if( options::triggerActiveSelMode()!=TRIGGER_ACTIVE_SEL_ALL ){ + if (options::triggerActiveSelMode() != options::TriggerActiveSelMode::ALL) + { int max_score = -1; Trigger * max_trigger = NULL; for( std::map< Trigger*, bool >::iterator itt = d_auto_gen_trigger[0][f].begin(); itt != d_auto_gen_trigger[0][f].end(); ++itt ){ int score = itt->first->getActiveScore(); - if( options::triggerActiveSelMode()==TRIGGER_ACTIVE_SEL_MIN ){ + if (options::triggerActiveSelMode() + == options::TriggerActiveSelMode::MIN) + { if( score>=0 && ( scorefirst; - } - }else{ + } + } + else + { if( score>max_score ){ max_score = score; max_trigger = itt->first; @@ -241,7 +258,7 @@ int InstStrategyAutoGenTriggers::process( Node f, Theory::Effort effort, int e ) d_auto_gen_trigger[0][f][max_trigger] = true; } } - + bool hasInst = false; for( unsigned r=0; r<2; r++ ){ for( std::map< Trigger*, bool >::iterator itt = d_auto_gen_trigger[r][f].begin(); itt != d_auto_gen_trigger[r][f].end(); ++itt ){ @@ -374,20 +391,28 @@ void InstStrategyAutoGenTriggers::generateTriggers( Node f ){ }else{ Assert(Trigger::isAtomicTrigger(pat)); if( pat.getType().isBoolean() && rpoleq.isNull() ){ - if( options::literalMatchMode()==LITERAL_MATCH_USE ){ + if (options::literalMatchMode() == options::LiteralMatchMode::USE) + { pat = NodeManager::currentNM()->mkNode( EQUAL, pat, NodeManager::currentNM()->mkConst( rpol==-1 ) ).negate(); - }else if( options::literalMatchMode()!=LITERAL_MATCH_NONE ){ + } + else if (options::literalMatchMode() + != options::LiteralMatchMode::NONE) + { pat = NodeManager::currentNM()->mkNode( EQUAL, pat, NodeManager::currentNM()->mkConst( rpol==1 ) ); } }else{ Assert(!rpoleq.isNull()); if( rpol==-1 ){ - if( options::literalMatchMode()!=LITERAL_MATCH_NONE ){ + if (options::literalMatchMode() + != options::LiteralMatchMode::NONE) + { //all equivalence classes except rpoleq pat = NodeManager::currentNM()->mkNode( EQUAL, pat, rpoleq ).negate(); } }else if( rpol==1 ){ - if( options::literalMatchMode()==LITERAL_MATCH_AGG ){ + if (options::literalMatchMode() + == options::LiteralMatchMode::AGG) + { //only equivalence class rpoleq pat = NodeManager::currentNM()->mkNode( EQUAL, pat, rpoleq ); } diff --git a/src/theory/quantifiers/ematching/inst_strategy_e_matching.h b/src/theory/quantifiers/ematching/inst_strategy_e_matching.h index 1a014939f..052bc910c 100644 --- a/src/theory/quantifiers/ematching/inst_strategy_e_matching.h +++ b/src/theory/quantifiers/ematching/inst_strategy_e_matching.h @@ -54,63 +54,67 @@ public: std::string identify() const override { return std::string("UserPatterns"); } };/* class InstStrategyUserPatterns */ -class InstStrategyAutoGenTriggers : public InstStrategy { -public: - enum { +class InstStrategyAutoGenTriggers : public InstStrategy +{ + public: + enum + { RELEVANCE_NONE, RELEVANCE_DEFAULT, }; -private: + + private: /** trigger generation strategy */ - TriggerSelMode d_tr_strategy; + options::TriggerSelMode d_tr_strategy; /** regeneration */ bool d_regenerate; int d_regenerate_frequency; /** (single,multi) triggers for each quantifier */ - std::map< Node, std::map< inst::Trigger*, bool > > d_auto_gen_trigger[2]; - std::map< Node, int > d_counter; + std::map > d_auto_gen_trigger[2]; + std::map d_counter; /** single, multi triggers for each quantifier */ - std::map< Node, std::vector< Node > > d_patTerms[2]; - std::map< Node, std::map< Node, bool > > d_patReqPol; + std::map > d_patTerms[2]; + std::map > d_patReqPol; /** information about triggers */ - std::map< Node, bool > d_is_single_trigger; - std::map< Node, bool > d_single_trigger_gen; - std::map< Node, bool > d_made_multi_trigger; - //processed trigger this round - std::map< Node, std::map< inst::Trigger*, bool > > d_processed_trigger; - //instantiation no patterns - std::map< Node, std::vector< Node > > d_user_no_gen; + std::map d_is_single_trigger; + std::map d_single_trigger_gen; + std::map d_made_multi_trigger; + // processed trigger this round + std::map > d_processed_trigger; + // instantiation no patterns + std::map > d_user_no_gen; // number of trigger variables per quantifier - std::map< Node, unsigned > d_num_trigger_vars; - std::map< Node, Node > d_vc_partition[2]; - std::map< Node, Node > d_pat_to_mpat; -private: + std::map d_num_trigger_vars; + std::map d_vc_partition[2]; + std::map d_pat_to_mpat; + + private: /** process functions */ - void processResetInstantiationRound(Theory::Effort effort) override; - int process(Node q, Theory::Effort effort, int e) override; - /** generate triggers */ - void generateTriggers(Node q); - void addPatternToPool(Node q, Node pat, unsigned num_fv, Node mpat); - void addTrigger(inst::Trigger* tr, Node f); - /** has user patterns */ - bool hasUserPatterns(Node q); - /** has user patterns */ - std::map d_hasUserPatterns; + void processResetInstantiationRound(Theory::Effort effort) override; + int process(Node q, Theory::Effort effort, int e) override; + /** generate triggers */ + void generateTriggers(Node q); + void addPatternToPool(Node q, Node pat, unsigned num_fv, Node mpat); + void addTrigger(inst::Trigger* tr, Node f); + /** has user patterns */ + bool hasUserPatterns(Node q); + /** has user patterns */ + std::map d_hasUserPatterns; -public: - InstStrategyAutoGenTriggers(QuantifiersEngine* qe, QuantRelevance* qr); - ~InstStrategyAutoGenTriggers() {} + public: + InstStrategyAutoGenTriggers(QuantifiersEngine* qe, QuantRelevance* qr); + ~InstStrategyAutoGenTriggers() {} -public: + public: /** get auto-generated trigger */ - inst::Trigger* getAutoGenTrigger( Node q ); + inst::Trigger* getAutoGenTrigger(Node q); /** identify */ std::string identify() const override { return std::string("AutoGenTriggers"); } /** add pattern */ - void addUserNoPattern( Node q, Node pat ); + void addUserNoPattern(Node q, Node pat); private: /** @@ -118,9 +122,7 @@ public: * owned by the instantiation engine that owns this class. */ QuantRelevance* d_quant_rel; -};/* class InstStrategyAutoGenTriggers */ - - +}; /* class InstStrategyAutoGenTriggers */ } }/* CVC4::theory namespace */ }/* CVC4 namespace */ diff --git a/src/theory/quantifiers/ematching/instantiation_engine.cpp b/src/theory/quantifiers/ematching/instantiation_engine.cpp index 23b1ff6c9..b91a9ba63 100644 --- a/src/theory/quantifiers/ematching/instantiation_engine.cpp +++ b/src/theory/quantifiers/ematching/instantiation_engine.cpp @@ -46,7 +46,8 @@ InstantiationEngine::InstantiationEngine(QuantifiersEngine* qe) if (options::eMatching()) { // these are the instantiation strategies for E-matching // user-provided patterns - if (options::userPatternsQuant() != USER_PAT_MODE_IGNORE) { + if (options::userPatternsQuant() != options::UserPatMode::IGNORE) + { d_isup.reset(new InstStrategyUserPatterns(d_quantEngine)); d_instStrategies.push_back(d_isup.get()); } diff --git a/src/theory/quantifiers/ematching/trigger.cpp b/src/theory/quantifiers/ematching/trigger.cpp index f539bccf5..e177e24a6 100644 --- a/src/theory/quantifiers/ematching/trigger.cpp +++ b/src/theory/quantifiers/ematching/trigger.cpp @@ -429,9 +429,19 @@ bool Trigger::isSimpleTrigger( Node n ){ } //store triggers in reqPol, indicating their polarity (if any) they must appear to falsify the quantified formula -void Trigger::collectPatTerms2( Node q, Node n, std::map< Node, std::vector< Node > >& visited, std::map< Node, TriggerTermInfo >& tinfo, - quantifiers::TriggerSelMode tstrt, std::vector< Node >& exclude, std::vector< Node >& added, - bool pol, bool hasPol, bool epol, bool hasEPol, bool knowIsUsable ){ +void Trigger::collectPatTerms2(Node q, + Node n, + std::map >& visited, + std::map& tinfo, + options::TriggerSelMode tstrt, + std::vector& exclude, + std::vector& added, + bool pol, + bool hasPol, + bool epol, + bool hasEPol, + bool knowIsUsable) +{ std::map< Node, std::vector< Node > >::iterator itv = visited.find( n ); if( itv==visited.end() ){ visited[ n ].clear(); @@ -488,7 +498,10 @@ void Trigger::collectPatTerms2( Node q, Node n, std::map< Node, std::vector< Nod Assert(added2[i] != nu); // if child was not already removed if( tinfo.find( added2[i] )!=tinfo.end() ){ - if( tstrt==quantifiers::TRIGGER_SEL_MAX || ( tstrt==quantifiers::TRIGGER_SEL_MIN_SINGLE_MAX && !nu_single ) ){ + if (tstrt == options::TriggerSelMode::MAX + || (tstrt == options::TriggerSelMode::MIN_SINGLE_MAX + && !nu_single)) + { // discard all subterms // do not remove if it has smaller weight if (tinfo[nu].d_weight <= tinfo[added2[i]].d_weight) @@ -498,7 +511,9 @@ void Trigger::collectPatTerms2( Node q, Node n, std::map< Node, std::vector< Nod visited[added2[i]].clear(); tinfo.erase(added2[i]); } - }else{ + } + else + { if( tinfo[ nu ].d_fv.size()==tinfo[ added2[i] ].d_fv.size() ){ if (tinfo[nu].d_weight >= tinfo[added2[i]].d_weight) { @@ -516,9 +531,15 @@ void Trigger::collectPatTerms2( Node q, Node n, std::map< Node, std::vector< Nod } } } - if( rm_nu && ( tstrt==quantifiers::TRIGGER_SEL_MIN || ( tstrt==quantifiers::TRIGGER_SEL_MIN_SINGLE_ALL && nu_single ) ) ){ + if (rm_nu + && (tstrt == options::TriggerSelMode::MIN + || (tstrt == options::TriggerSelMode::MIN_SINGLE_ALL + && nu_single))) + { tinfo.erase( nu ); - }else{ + } + else + { if( std::find( added.begin(), added.end(), nu )==added.end() ){ added.push_back( nu ); } @@ -593,14 +614,21 @@ bool Trigger::isLocalTheoryExt( Node n, std::vector< Node >& vars, std::vector< return true; } -void Trigger::collectPatTerms( Node q, Node n, std::vector< Node >& patTerms, quantifiers::TriggerSelMode tstrt, std::vector< Node >& exclude, - std::map< Node, TriggerTermInfo >& tinfo, bool filterInst ){ +void Trigger::collectPatTerms(Node q, + Node n, + std::vector& patTerms, + options::TriggerSelMode tstrt, + std::vector& exclude, + std::map& tinfo, + bool filterInst) +{ std::map< Node, std::vector< Node > > visited; if( filterInst ){ //immediately do not consider any term t for which another term is an instance of t std::vector< Node > patTerms2; std::map< Node, TriggerTermInfo > tinfo2; - collectPatTerms( q, n, patTerms2, quantifiers::TRIGGER_SEL_ALL, exclude, tinfo2, false ); + collectPatTerms( + q, n, patTerms2, options::TriggerSelMode::ALL, exclude, tinfo2, false); std::vector< Node > temp; temp.insert( temp.begin(), patTerms2.begin(), patTerms2.end() ); filterTriggerInstances(temp); @@ -623,7 +651,8 @@ void Trigger::collectPatTerms( Node q, Node n, std::vector< Node >& patTerms, qu Trace("trigger-filter-instance") << std::endl; } } - if( tstrt==quantifiers::TRIGGER_SEL_ALL ){ + if (tstrt == options::TriggerSelMode::ALL) + { for( unsigned i=0; i& patTerms, qu patTerms.push_back( temp[i] ); } return; - }else{ + } + else + { //do not consider terms that have instances for( unsigned i=0; i& t_vars) std::map< Node, TriggerTermInfo > tinfo; // collect all patterns from n std::vector< Node > exclude; - collectPatTerms(q, n, patTerms, quantifiers::TRIGGER_SEL_ALL, exclude, tinfo); + collectPatTerms(q, n, patTerms, options::TriggerSelMode::ALL, exclude, tinfo); //collect all variables from all patterns in patTerms, add to t_vars for (const Node& pat : patTerms) { diff --git a/src/theory/quantifiers/ematching/trigger.h b/src/theory/quantifiers/ematching/trigger.h index d47ea72ee..e955543db 100644 --- a/src/theory/quantifiers/ematching/trigger.h +++ b/src/theory/quantifiers/ematching/trigger.h @@ -273,9 +273,13 @@ class Trigger { * in the vector we are returning, e.g. we do not return f( x ) if we are * also returning f( f( x ) ). TODO: revisit this (issue #1211) */ - static void collectPatTerms( Node q, Node n, std::vector< Node >& patTerms, quantifiers::TriggerSelMode tstrt, - std::vector< Node >& exclude, std::map< Node, TriggerTermInfo >& tinfo, - bool filterInst = false ); + static void collectPatTerms(Node q, + Node n, + std::vector& patTerms, + options::TriggerSelMode tstrt, + std::vector& exclude, + std::map& tinfo, + bool filterInst = false); /** Is n a usable trigger in quantified formula q? * @@ -380,9 +384,18 @@ class Trigger { * * We add the triggers we collected recursively in n into added. */ - static void collectPatTerms2( Node q, Node n, std::map< Node, std::vector< Node > >& visited, std::map< Node, TriggerTermInfo >& tinfo, - quantifiers::TriggerSelMode tstrt, std::vector< Node >& exclude, std::vector< Node >& added, - bool pol, bool hasPol, bool epol, bool hasEPol, bool knowIsUsable = false ); + static void collectPatTerms2(Node q, + Node n, + std::map >& visited, + std::map& tinfo, + options::TriggerSelMode tstrt, + std::vector& exclude, + std::vector& added, + bool pol, + bool hasPol, + bool epol, + bool hasEPol, + bool knowIsUsable = false); /** filter all nodes that have trigger instances * diff --git a/src/theory/quantifiers/equality_query.cpp b/src/theory/quantifiers/equality_query.cpp index f7fd13d4d..f72a0d1b4 100644 --- a/src/theory/quantifiers/equality_query.cpp +++ b/src/theory/quantifiers/equality_query.cpp @@ -111,9 +111,12 @@ Node EqualityQueryQuantifiersEngine::getInternalRepresentative(Node a, } } } - if( options::quantRepMode()==quantifiers::QUANT_REP_MODE_EE ){ + if (options::quantRepMode() == options::QuantRepMode::EE) + { return r; - }else{ + } + else + { TypeNode v_tn = q.isNull() ? a.getType() : q[0][index].getType(); std::map& v_int_rep = d_int_rep[v_tn]; std::map::const_iterator itir = v_int_rep.find(r); @@ -239,11 +242,14 @@ int EqualityQueryQuantifiersEngine::getRepScore(Node n, return options::instLevelInputOnly() ? -1 : 0; } }else{ - if( options::quantRepMode()==quantifiers::QUANT_REP_MODE_FIRST ){ + if (options::quantRepMode() == options::QuantRepMode::FIRST) + { //score prefers earliest use of this term as a representative return d_rep_score.find( n )==d_rep_score.end() ? -1 : d_rep_score[n]; - }else{ - Assert(options::quantRepMode() == quantifiers::QUANT_REP_MODE_DEPTH); + } + else + { + Assert(options::quantRepMode() == options::QuantRepMode::DEPTH); return quantifiers::TermUtil::getTermDepth( n ); } } diff --git a/src/theory/quantifiers/fmf/full_model_check.cpp b/src/theory/quantifiers/fmf/full_model_check.cpp index d6c939e5d..206c8f9dd 100644 --- a/src/theory/quantifiers/fmf/full_model_check.cpp +++ b/src/theory/quantifiers/fmf/full_model_check.cpp @@ -603,12 +603,15 @@ int FullModelChecker::doExhaustiveInstantiation( FirstOrderModel * fm, Node f, i d_quant_cond[f] = op; } - if( options::mbqiMode()==MBQI_NONE ){ + if (options::mbqiMode() == options::MbqiMode::NONE) + { //just exhaustive instantiate Node c = mkCondDefault( fmfmc, f ); d_quant_models[f].addEntry( fmfmc, c, d_false ); return exhaustiveInstantiate( fmfmc, f, c, -1); - }else{ + } + else + { //model check the quantifier doCheck(fmfmc, f, d_quant_models[f], f[1]); Trace("fmc") << "Definition for quantifier " << f << " is : " << std::endl; diff --git a/src/theory/quantifiers/fmf/model_builder.cpp b/src/theory/quantifiers/fmf/model_builder.cpp index caca25fde..a6e1a369c 100644 --- a/src/theory/quantifiers/fmf/model_builder.cpp +++ b/src/theory/quantifiers/fmf/model_builder.cpp @@ -37,7 +37,7 @@ QModelBuilder::QModelBuilder(context::Context* c, QuantifiersEngine* qe) d_triedLemmas(0) {} bool QModelBuilder::optUseModel() { - return options::mbqiMode()!=MBQI_NONE || options::fmfBound(); + return options::mbqiMode() != options::MbqiMode::NONE || options::fmfBound(); } bool QModelBuilder::preProcessBuildModel(TheoryModel* m) { diff --git a/src/theory/quantifiers/fmf/model_engine.cpp b/src/theory/quantifiers/fmf/model_engine.cpp index cdaaa239a..5b2931e42 100644 --- a/src/theory/quantifiers/fmf/model_engine.cpp +++ b/src/theory/quantifiers/fmf/model_engine.cpp @@ -219,9 +219,9 @@ int ModelEngine::checkModel(){ Trace("model-engine-debug") << "Do exhaustive instantiation..." << std::endl; // FMC uses two sub-effort levels - int e_max = options::mbqiMode() == MBQI_FMC + int e_max = options::mbqiMode() == options::MbqiMode::FMC ? 2 - : (options::mbqiMode() == MBQI_TRUST ? 0 : 1); + : (options::mbqiMode() == options::MbqiMode::TRUST ? 0 : 1); for( int e=0; egetNumAssertedQuantifiers(); i++ ){ diff --git a/src/theory/quantifiers/quant_conflict_find.cpp b/src/theory/quantifiers/quant_conflict_find.cpp index de46eee74..89f4f2989 100644 --- a/src/theory/quantifiers/quant_conflict_find.cpp +++ b/src/theory/quantifiers/quant_conflict_find.cpp @@ -17,6 +17,7 @@ #include "expr/node_algorithm.h" #include "options/quantifiers_options.h" +#include "options/theory_options.h" #include "smt/smt_statistics_registry.h" #include "theory/quantifiers/ematching/trigger.h" #include "theory/quantifiers/first_order_model.h" @@ -652,7 +653,9 @@ bool QuantInfo::entailmentTest( QuantConflictFind * p, Node lit, bool chEnt ) { } //check if it is entailed Trace("qcf-tconstraint-debug") << "Check entailment of " << rew << "..." << std::endl; - std::pair et = p->getQuantifiersEngine()->getTheoryEngine()->entailmentCheck(THEORY_OF_TYPE_BASED, rew ); + std::pair et = + p->getQuantifiersEngine()->getTheoryEngine()->entailmentCheck( + options::TheoryOfMode::THEORY_OF_TYPE_BASED, rew); ++(p->d_statistics.d_entailment_checks); Trace("qcf-tconstraint-debug") << "ET result : " << et.first << " " << et.second << std::endl; if( !et.first ){ @@ -1901,11 +1904,11 @@ bool QuantConflictFind::needsCheck( Theory::Effort level ) { bool performCheck = false; if( options::quantConflictFind() && !d_conflict ){ if( level==Theory::EFFORT_LAST_CALL ){ - performCheck = options::qcfWhenMode()==QCF_WHEN_MODE_LAST_CALL; + performCheck = options::qcfWhenMode() == options::QcfWhenMode::LAST_CALL; }else if( level==Theory::EFFORT_FULL ){ - performCheck = options::qcfWhenMode()==QCF_WHEN_MODE_DEFAULT; + performCheck = options::qcfWhenMode() == options::QcfWhenMode::DEFAULT; }else if( level==Theory::EFFORT_STANDARD ){ - performCheck = options::qcfWhenMode()==QCF_WHEN_MODE_STD; + performCheck = options::qcfWhenMode() == options::QcfWhenMode::STD; } } return performCheck; @@ -1956,8 +1959,9 @@ inline QuantConflictFind::Effort QcfEffortStart() { // Returns the beginning of a range of efforts. The value returned is included // in the range. inline QuantConflictFind::Effort QcfEffortEnd() { - return options::qcfMode() == QCF_PROP_EQ ? QuantConflictFind::EFFORT_PROP_EQ - : QuantConflictFind::EFFORT_CONFLICT; + return options::qcfMode() == options::QcfMode::PROP_EQ + ? QuantConflictFind::EFFORT_PROP_EQ + : QuantConflictFind::EFFORT_CONFLICT; } } // namespace diff --git a/src/theory/quantifiers/quant_split.cpp b/src/theory/quantifiers/quant_split.cpp index 32bd2b0e8..5ad01009a 100644 --- a/src/theory/quantifiers/quant_split.cpp +++ b/src/theory/quantifiers/quant_split.cpp @@ -54,11 +54,16 @@ void QuantDSplit::checkOwnership(Node q) } else { - if( options::quantDynamicSplit()==quantifiers::QUANT_DSPLIT_MODE_AGG ){ + if (options::quantDynamicSplit() == options::QuantDSplitMode::AGG) + { // split if it is a finite datatype doSplit = dt.isInterpretedFinite(tn); - }else if( options::quantDynamicSplit()==quantifiers::QUANT_DSPLIT_MODE_DEFAULT ){ - if( !d_quantEngine->isFiniteBound( q, q[0][i] ) ){ + } + else if (options::quantDynamicSplit() + == options::QuantDSplitMode::DEFAULT) + { + if (!d_quantEngine->isFiniteBound(q, q[0][i])) + { if (dt.isInterpretedFinite(tn)) { // split if goes from being unhandled -> handled by finite diff --git a/src/theory/quantifiers/quantifiers_rewriter.cpp b/src/theory/quantifiers/quantifiers_rewriter.cpp index 8d65523e1..d5bee4916 100644 --- a/src/theory/quantifiers/quantifiers_rewriter.cpp +++ b/src/theory/quantifiers/quantifiers_rewriter.cpp @@ -658,12 +658,15 @@ Node QuantifiersRewriter::computeProcessTerms2( Node body, bool hasPol, bool pol return iti->second; }else{ Node prev = ret; - if( ret.getKind()==EQUAL && options::iteLiftQuant()!=ITE_LIFT_QUANT_MODE_NONE ){ + if (ret.getKind() == EQUAL + && options::iteLiftQuant() != options::IteLiftQuantMode::NONE) + { for( size_t i=0; i<2; i++ ){ if( ret[i].getKind()==ITE ){ Node no = i==0 ? ret[1] : ret[0]; if( no.getKind()!=ITE ){ - bool doRewrite = options::iteLiftQuant()==ITE_LIFT_QUANT_MODE_ALL; + bool doRewrite = + options::iteLiftQuant() == options::IteLiftQuantMode::ALL; std::vector< Node > children; children.push_back( ret[i][0] ); for( size_t j=1; j<=2; j++ ){ @@ -1545,7 +1548,10 @@ Node QuantifiersRewriter::computePrenexAgg( Node n, bool topLevel, std::map< uns } if( containsQuantifiers( n ) ){ Node ret = n; - if( topLevel && options::prenexQuant()==PRENEX_QUANT_DISJ_NORMAL && ( n.getKind()==AND || ( n.getKind()==NOT && n[0].getKind()==OR ) ) ){ + if (topLevel + && options::prenexQuant() == options::PrenexQuantMode::DISJ_NORMAL + && (n.getKind() == AND || (n.getKind() == NOT && n[0].getKind() == OR))) + { std::vector< Node > children; Node nc = n.getKind()==NOT ? n[0] : n; for( unsigned i=0; imkNode( AND, children ); - }else if( n.getKind()==NOT ){ + } + else if (n.getKind() == NOT) + { ret = computePrenexAgg( n[0], false, visited ).negate(); - }else if( n.getKind()==FORALL ){ - /* - Node nn = computePrenexAgg( n[1], false ); - if( nn!=n[1] ){ - if( n.getNumChildren()==2 ){ - return NodeManager::currentNM()->mkNode( FORALL, n[0], nn ); - }else{ - return NodeManager::currentNM()->mkNode( FORALL, n[0], nn, n[2] ); + } + else if (n.getKind() == FORALL) + { + /* + Node nn = computePrenexAgg( n[1], false ); + if( nn!=n[1] ){ + if( n.getNumChildren()==2 ){ + return NodeManager::currentNM()->mkNode( FORALL, n[0], nn ); + }else{ + return NodeManager::currentNM()->mkNode( FORALL, n[0], nn, n[2] ); + } } - } - */ + */ std::vector< Node > children; - if( n[1].getKind()==OR && options::prenexQuant()==PRENEX_QUANT_DISJ_NORMAL ){ + if (n[1].getKind() == OR + && options::prenexQuant() == options::PrenexQuantMode::DISJ_NORMAL) + { for( unsigned i=0; i args; @@ -1600,7 +1614,9 @@ Node QuantifiersRewriter::computePrenexAgg( Node n, bool topLevel, std::map< uns } Node nb = children.size()==1 ? children[0] : NodeManager::currentNM()->mkNode( OR, children ); ret = mkForall( args, nb, iplc, true ); - }else{ + } + else + { std::vector< Node > args; std::vector< Node > nargs; Node nn = computePrenex( n, args, nargs, true, true ); @@ -1949,7 +1965,9 @@ Node QuantifiersRewriter::computeAggressiveMiniscoping( std::vector< Node >& arg } bool QuantifiersRewriter::doOperation( Node q, int computeOption, QAttributes& qa ){ - bool is_strict_trigger = qa.d_hasPattern && options::userPatternsQuant()==USER_PAT_MODE_TRUST; + bool is_strict_trigger = + qa.d_hasPattern + && options::userPatternsQuant() == options::UserPatMode::TRUST; bool is_std = qa.isStandard() && !is_strict_trigger; if (computeOption == COMPUTE_ELIM_SYMBOLS) { @@ -1966,7 +1984,7 @@ bool QuantifiersRewriter::doOperation( Node q, int computeOption, QAttributes& q else if (computeOption == COMPUTE_PROCESS_TERMS) { return options::condRewriteQuant() || options::elimExtArithQuant() - || options::iteLiftQuant() != ITE_LIFT_QUANT_MODE_NONE; + || options::iteLiftQuant() != options::IteLiftQuantMode::NONE; } else if (computeOption == COMPUTE_COND_SPLIT) { @@ -1975,7 +1993,7 @@ bool QuantifiersRewriter::doOperation( Node q, int computeOption, QAttributes& q } else if (computeOption == COMPUTE_PRENEX) { - return options::prenexQuant() != PRENEX_QUANT_NONE + return options::prenexQuant() != options::PrenexQuantMode::NONE && !options::aggressiveMiniscopeQuant() && is_std; } else if (computeOption == COMPUTE_VAR_ELIMINATION) @@ -1999,7 +2017,9 @@ Node QuantifiersRewriter::computeOperation( Node f, int computeOption, QAttribut if( computeOption==COMPUTE_ELIM_SYMBOLS ){ n = computeElimSymbols( n ); }else if( computeOption==COMPUTE_MINISCOPING ){ - if( options::prenexQuant()==PRENEX_QUANT_DISJ_NORMAL || options::prenexQuant()==PRENEX_QUANT_NORMAL ){ + if (options::prenexQuant() == options::PrenexQuantMode::DISJ_NORMAL + || options::prenexQuant() == options::PrenexQuantMode::NORMAL) + { if( !qa.d_qid_num.isNull() ){ //already processed this, return self return f; @@ -2019,10 +2039,14 @@ Node QuantifiersRewriter::computeOperation( Node f, int computeOption, QAttribut }else if( computeOption==COMPUTE_COND_SPLIT ){ n = computeCondSplit(n, args, qa); }else if( computeOption==COMPUTE_PRENEX ){ - if( options::prenexQuant()==PRENEX_QUANT_DISJ_NORMAL || options::prenexQuant()==PRENEX_QUANT_NORMAL ){ + if (options::prenexQuant() == options::PrenexQuantMode::DISJ_NORMAL + || options::prenexQuant() == options::PrenexQuantMode::NORMAL) + { //will rewrite at preprocess time return f; - }else{ + } + else + { std::vector< Node > nargs; n = computePrenex( n, args, nargs, true, false ); Assert(nargs.empty()); @@ -2267,7 +2291,9 @@ Node QuantifiersRewriter::preprocess( Node n, bool isInst ) { } } //pull all quantifiers globally - if( options::prenexQuant()==PRENEX_QUANT_DISJ_NORMAL || options::prenexQuant()==PRENEX_QUANT_NORMAL ){ + if (options::prenexQuant() == options::PrenexQuantMode::DISJ_NORMAL + || options::prenexQuant() == options::PrenexQuantMode::NORMAL) + { Trace("quantifiers-prenex") << "Prenexing : " << n << std::endl; std::map< unsigned, std::map< Node, Node > > visited; n = quantifiers::QuantifiersRewriter::computePrenexAgg( n, true, visited ); diff --git a/src/theory/quantifiers/query_generator.cpp b/src/theory/quantifiers/query_generator.cpp index 99e7b5a8c..248128c1e 100644 --- a/src/theory/quantifiers/query_generator.cpp +++ b/src/theory/quantifiers/query_generator.cpp @@ -146,7 +146,8 @@ bool QueryGenerator::addTerm(Node n, std::ostream& out) void QueryGenerator::checkQuery(Node qy, unsigned spIndex) { // external query - if (options::sygusQueryGenDumpFiles() == SYGUS_QUERY_DUMP_ALL) + if (options::sygusQueryGenDumpFiles() + == options::SygusQueryDumpFilesMode::ALL) { dumpQuery(qy, spIndex); } @@ -179,7 +180,8 @@ void QueryGenerator::checkQuery(Node qy, unsigned spIndex) ss << "but CVC4 answered unsat!" << std::endl; AlwaysAssert(false) << ss.str(); } - if (options::sygusQueryGenDumpFiles() == SYGUS_QUERY_DUMP_UNSOLVED) + if (options::sygusQueryGenDumpFiles() + == options::SygusQueryDumpFilesMode::UNSOLVED) { if (r.asSatisfiabilityResult().isSat() != Result::SAT) { diff --git a/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp b/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp index 69e0ef70a..e36047e67 100644 --- a/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp +++ b/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp @@ -109,7 +109,7 @@ void CegSingleInv::initialize(Node q) { // We are fully single invocation, set single invocation if we haven't // disabled single invocation techniques. - if (options::cegqiSingleInvMode() != CEGQI_SI_MODE_NONE) + if (options::cegqiSingleInvMode() != options::CegqiSingleInvMode::NONE) { d_single_invocation = true; return; @@ -118,25 +118,25 @@ void CegSingleInv::initialize(Node q) // We are processing without single invocation techniques, now check if // we should fix an invariant template (post-condition strengthening or // pre-condition weakening). - SygusInvTemplMode tmode = options::sygusInvTemplMode(); - if (tmode != SYGUS_INV_TEMPL_MODE_NONE) + options::SygusInvTemplMode tmode = options::sygusInvTemplMode(); + if (tmode != options::SygusInvTemplMode::NONE) { // currently only works for single predicate synthesis if (q[0].getNumChildren() > 1 || !q[0][0].getType().isPredicate()) { - tmode = SYGUS_INV_TEMPL_MODE_NONE; + tmode = options::SygusInvTemplMode::NONE; } else if (!options::sygusInvTemplWhenSyntax()) { // only use invariant templates if no syntactic restrictions if (CegGrammarConstructor::hasSyntaxRestrictions(q)) { - tmode = SYGUS_INV_TEMPL_MODE_NONE; + tmode = options::SygusInvTemplMode::NONE; } } } - if (tmode == SYGUS_INV_TEMPL_MODE_NONE) + if (tmode == options::SygusInvTemplMode::NONE) { // not processing invariant templates return; @@ -243,13 +243,13 @@ void CegSingleInv::initialize(Node q) << std::endl; if (templ.isNull()) { - if (tmode == SYGUS_INV_TEMPL_MODE_PRE) + if (tmode == options::SygusInvTemplMode::PRE) { templ = nm->mkNode(OR, d_trans_pre[prog], d_templ_arg[prog]); } else { - Assert(tmode == SYGUS_INV_TEMPL_MODE_POST); + Assert(tmode == options::SygusInvTemplMode::POST); templ = nm->mkNode(AND, d_trans_post[prog], d_templ_arg[prog]); } } @@ -269,8 +269,11 @@ void CegSingleInv::initialize(Node q) void CegSingleInv::finishInit(bool syntaxRestricted) { Trace("cegqi-si-debug") << "Single invocation: finish init" << std::endl; - // do not do single invocation if grammar is restricted and CEGQI_SI_MODE_ALL is not enabled - if( options::cegqiSingleInvMode()==CEGQI_SI_MODE_USE && d_single_invocation && syntaxRestricted ){ + // do not do single invocation if grammar is restricted and + // options::CegqiSingleInvMode::ALL is not enabled + if (options::cegqiSingleInvMode() == options::CegqiSingleInvMode::USE + && d_single_invocation && syntaxRestricted) + { d_single_invocation = false; Trace("cegqi-si") << "...grammar is restricted, do not use single invocation techniques." << std::endl; } @@ -551,17 +554,19 @@ Node CegSingleInv::reconstructToSyntax(Node s, //reconstruct the solution into sygus if necessary reconstructed = 0; - if (options::cegqiSingleInvReconstruct() != CEGQI_SI_RCONS_MODE_NONE + if (options::cegqiSingleInvReconstruct() + != options::CegqiSingleInvRconsMode::NONE && !dt.getSygusAllowAll() && !stn.isNull() && rconsSygus) { d_sol->preregisterConjecture( d_orig_conjecture ); int enumLimit = -1; - if (options::cegqiSingleInvReconstruct() == CEGQI_SI_RCONS_MODE_TRY) + if (options::cegqiSingleInvReconstruct() + == options::CegqiSingleInvRconsMode::TRY) { enumLimit = 0; } else if (options::cegqiSingleInvReconstruct() - == CEGQI_SI_RCONS_MODE_ALL_LIMIT) + == options::CegqiSingleInvRconsMode::ALL_LIMIT) { enumLimit = options::cegqiSingleInvReconstructLimit(); } diff --git a/src/theory/quantifiers/sygus/cegis.cpp b/src/theory/quantifiers/sygus/cegis.cpp index a4dc241b8..78ea5b22f 100644 --- a/src/theory/quantifiers/sygus/cegis.cpp +++ b/src/theory/quantifiers/sygus/cegis.cpp @@ -52,7 +52,7 @@ bool Cegis::initialize(Node conj, } // assign the cegis sampler if applicable - if (options::cegisSample() != CEGIS_SAMPLE_NONE) + if (options::cegisSample() != options::CegisSampleMode::NONE) { Trace("cegis-sample") << "Initialize sampler for " << d_base_body << "..." << std::endl; @@ -81,7 +81,8 @@ bool Cegis::processInitialize(Node conj, // grammar construction was not simple. bool useSymCons = false; if (options::sygusRepairConst() - || options::sygusGrammarConsMode() != SYGUS_GCONS_SIMPLE) + || options::sygusGrammarConsMode() + != options::SygusGrammarConsMode::SIMPLE) { TypeNode ctn = candidates[i].getType(); d_tds->registerSygusType(ctn); @@ -305,7 +306,7 @@ bool Cegis::constructCandidates(const std::vector& enums, return false; } - if (options::cegisSample() != CEGIS_SAMPLE_NONE && lems.empty()) + if (options::cegisSample() != options::CegisSampleMode::NONE && lems.empty()) { // if we didn't add a lemma, trying sampling to add a refinement lemma // that immediately refutes the candidate we just constructed @@ -636,7 +637,7 @@ bool Cegis::sampleAddRefinementLemma(const std::vector& candidates, Trace("cegqi-engine") << " *** Refine by sampling" << std::endl; addRefinementLemma(rlem); // if trust, we are not interested in sending out refinement lemmas - if (options::cegisSample() != CEGIS_SAMPLE_TRUST) + if (options::cegisSample() != options::CegisSampleMode::TRUST) { Node lem = nm->mkNode(OR, d_parent->getGuard().negate(), rlem); lems.push_back(lem); diff --git a/src/theory/quantifiers/sygus/cegis_unif.cpp b/src/theory/quantifiers/sygus/cegis_unif.cpp index 2bc412361..8812032ba 100644 --- a/src/theory/quantifiers/sygus/cegis_unif.cpp +++ b/src/theory/quantifiers/sygus/cegis_unif.cpp @@ -405,9 +405,9 @@ CegisUnifEnumDecisionStrategy::CegisUnifEnumDecisionStrategy( { d_initialized = false; d_tds = d_qe->getTermDatabaseSygus(); - SygusUnifPiMode mode = options::sygusUnifPi(); - d_useCondPool = - mode == SYGUS_UNIF_PI_CENUM || mode == SYGUS_UNIF_PI_CENUM_IGAIN; + options::SygusUnifPiMode mode = options::sygusUnifPi(); + d_useCondPool = mode == options::SygusUnifPiMode::CENUM + || mode == options::SygusUnifPiMode::CENUM_IGAIN; } Node CegisUnifEnumDecisionStrategy::mkLiteral(unsigned n) @@ -639,7 +639,8 @@ void CegisUnifEnumDecisionStrategy::setUpEnumerator(Node e, } Trace("cegis-unif-enum") << "* Registering new enumerator " << e << " to strategy point " << si.d_pt << "\n"; - bool useSymCons = options::sygusGrammarConsMode() != SYGUS_GCONS_SIMPLE; + bool useSymCons = + options::sygusGrammarConsMode() != options::SygusGrammarConsMode::SIMPLE; d_tds->registerEnumerator(e, si.d_pt, d_parent, erole, useSymCons); } diff --git a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp index 8c005bd3c..78fbc48f3 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp +++ b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp @@ -538,7 +538,7 @@ void CegGrammarConstructor::mkSygusDefaultGrammar( itc; // maps types to the index of its "any term" grammar construction std::map typeToGAnyTerm; - SygusGrammarConsMode sgcm = options::sygusGrammarConsMode(); + options::SygusGrammarConsMode sgcm = options::sygusGrammarConsMode(); for (unsigned i = 0, size = types.size(); i < size; ++i) { std::stringstream ss; @@ -571,15 +571,16 @@ void CegGrammarConstructor::mkSygusDefaultGrammar( { Trace("sygus-grammar-def") << "Make grammar for " << types[i] << " " << unres_types[i] << std::endl; TypeNode unres_t = unres_types[i]; - SygusGrammarConsMode tsgcm = sgcm; - if (tsgcm == SYGUS_GCONS_ANY_TERM || tsgcm == SYGUS_GCONS_ANY_TERM_CONCISE) + options::SygusGrammarConsMode tsgcm = sgcm; + if (tsgcm == options::SygusGrammarConsMode::ANY_TERM + || tsgcm == options::SygusGrammarConsMode::ANY_TERM_CONCISE) { // If the type does not support any term, we do any constant instead. // We also fall back on any constant construction if the type has no // constructors at this point (e.g. it simply encodes all constants). if (!types[i].isReal()) { - tsgcm = SYGUS_GCONS_ANY_CONST; + tsgcm = options::SygusGrammarConsMode::ANY_CONST; } else { @@ -629,7 +630,7 @@ void CegGrammarConstructor::mkSygusDefaultGrammar( //add constants std::vector consts; mkSygusConstantsForType(types[i], consts); - if (tsgcm == SYGUS_GCONS_ANY_CONST) + if (tsgcm == options::SygusGrammarConsMode::ANY_CONST) { // Use the any constant constructor. Notice that for types that don't // have constants (e.g. uninterpreted or function types), we don't add @@ -923,7 +924,8 @@ void CegGrammarConstructor::mkSygusDefaultGrammar( // the references). const SygusDatatype& sdti = sdts[i].d_sdt; // whether we will use the polynomial grammar - bool polynomialGrammar = sgcm == SYGUS_GCONS_ANY_TERM_CONCISE; + bool polynomialGrammar = + sgcm == options::SygusGrammarConsMode::ANY_TERM_CONCISE; // A set of constructor indices that will be used in the overall sum we // are constructing; indices of constructors corresponding to builtin // arithmetic operators will be excluded from this set. @@ -1198,7 +1200,7 @@ void CegGrammarConstructor::mkSygusDefaultGrammar( // TODO #1935 ITEs are added to Boolean grammars so that we can infer // unification strategies. We can do away with this if we can infer // unification strategies from and/or/not - if (k == ITE && options::sygusUnifPi() == SYGUS_UNIF_PI_NONE) + if (k == ITE && options::sygusUnifPi() == options::SygusUnifPiMode::NONE) { continue; } diff --git a/src/theory/quantifiers/sygus/sygus_unif_rl.cpp b/src/theory/quantifiers/sygus/sygus_unif_rl.cpp index 47975d4b7..2b85595cd 100644 --- a/src/theory/quantifiers/sygus/sygus_unif_rl.cpp +++ b/src/theory/quantifiers/sygus/sygus_unif_rl.cpp @@ -61,10 +61,10 @@ void SygusUnifRl::initializeCandidate( d_cand_to_hd_count[f] = 0; } // check whether we are using condition enumeration - SygusUnifPiMode mode = options::sygusUnifPi(); - d_useCondPool = - mode == SYGUS_UNIF_PI_CENUM || mode == SYGUS_UNIF_PI_CENUM_IGAIN; - d_useCondPoolIGain = mode == SYGUS_UNIF_PI_CENUM_IGAIN; + options::SygusUnifPiMode mode = options::sygusUnifPi(); + d_useCondPool = mode == options::SygusUnifPiMode::CENUM + || mode == options::SygusUnifPiMode::CENUM_IGAIN; + d_useCondPoolIGain = mode == options::SygusUnifPiMode::CENUM_IGAIN; } void SygusUnifRl::notifyEnumeration(Node e, Node v, std::vector& lemmas) diff --git a/src/theory/quantifiers/sygus/synth_conjecture.cpp b/src/theory/quantifiers/sygus/synth_conjecture.cpp index e30f9771c..03449589b 100644 --- a/src/theory/quantifiers/sygus/synth_conjecture.cpp +++ b/src/theory/quantifiers/sygus/synth_conjecture.cpp @@ -66,7 +66,7 @@ SynthConjecture::SynthConjecture(QuantifiersEngine* qe, SynthEngine* p) { d_modules.push_back(d_ceg_pbe.get()); } - if (options::sygusUnifPi() != SYGUS_UNIF_PI_NONE) + if (options::sygusUnifPi() != options::SygusUnifPiMode::NONE) { d_modules.push_back(d_ceg_cegisUnif.get()); } @@ -483,7 +483,7 @@ bool SynthConjecture::doCheck(std::vector& lems) bool sk_refine = (!isGround() || d_refine_count == 0) && constructed_cand; if (sk_refine) { - if (options::cegisSample() == CEGIS_SAMPLE_TRUST) + if (options::cegisSample() == options::CegisSampleMode::TRUST) { // we have that the current candidate passed a sample test // since we trust sampling in this mode, we assert there is no @@ -799,14 +799,17 @@ Node SynthConjecture::getEnumeratedValue(Node e, bool& activeIncomplete) // or basic. The auto mode always prefers the optimized enumerator over // the basic one. Assert(d_tds->isBasicEnumerator(e)); - if (options::sygusActiveGenMode() == SYGUS_ACTIVE_GEN_ENUM_BASIC) + if (options::sygusActiveGenMode() + == options::SygusActiveGenMode::ENUM_BASIC) { d_evg[e].reset(new EnumValGeneratorBasic(d_tds, e.getType())); } else { - Assert(options::sygusActiveGenMode() == SYGUS_ACTIVE_GEN_ENUM - || options::sygusActiveGenMode() == SYGUS_ACTIVE_GEN_AUTO); + Assert(options::sygusActiveGenMode() + == options::SygusActiveGenMode::ENUM + || options::sygusActiveGenMode() + == options::SygusActiveGenMode::AUTO); d_evg[e].reset(new SygusEnumerator(d_tds, this)); } } @@ -1061,7 +1064,8 @@ void SynthConjecture::printSynthSolution(std::ostream& out) if (status != 0 && (options::sygusRewSynth() || options::sygusQueryGen() - || options::sygusFilterSolMode() != SYGUS_FILTER_SOL_NONE)) + || options::sygusFilterSolMode() + != options::SygusFilterSolMode::NONE)) { Trace("cegqi-sol-debug") << "Run expression mining..." << std::endl; std::map::iterator its = @@ -1078,13 +1082,16 @@ void SynthConjecture::printSynthSolution(std::ostream& out) { d_exprm[prog].enableQueryGeneration(options::sygusQueryGenThresh()); } - if (options::sygusFilterSolMode() != SYGUS_FILTER_SOL_NONE) + if (options::sygusFilterSolMode() + != options::SygusFilterSolMode::NONE) { - if (options::sygusFilterSolMode() == SYGUS_FILTER_SOL_STRONG) + if (options::sygusFilterSolMode() + == options::SygusFilterSolMode::STRONG) { d_exprm[prog].enableFilterStrongSolutions(); } - else if (options::sygusFilterSolMode() == SYGUS_FILTER_SOL_WEAK) + else if (options::sygusFilterSolMode() + == options::SygusFilterSolMode::WEAK) { d_exprm[prog].enableFilterWeakSolutions(); } diff --git a/src/theory/quantifiers/sygus/term_database_sygus.cpp b/src/theory/quantifiers/sygus/term_database_sygus.cpp index 0279ca531..1fda55172 100644 --- a/src/theory/quantifiers/sygus/term_database_sygus.cpp +++ b/src/theory/quantifiers/sygus/term_database_sygus.cpp @@ -453,7 +453,7 @@ void TermDbSygus::registerEnumerator(Node e, // determine if we are actively-generated bool isActiveGen = false; - if (options::sygusActiveGenMode() != SYGUS_ACTIVE_GEN_NONE) + if (options::sygusActiveGenMode() != options::SygusActiveGenMode::NONE) { if (erole == ROLE_ENUM_MULTI_SOLUTION || erole == ROLE_ENUM_CONSTRAINED) { @@ -481,7 +481,7 @@ void TermDbSygus::registerEnumerator(Node e, { // If the enumerator is the single function-to-synthesize, if auto is // enabled, we infer whether it is better to enable active generation. - if (options::sygusActiveGenMode() == SYGUS_ACTIVE_GEN_AUTO) + if (options::sygusActiveGenMode() == options::SygusActiveGenMode::AUTO) { // We use active generation if the grammar of the enumerator does not // have ITE and is not Boolean. Experimentally, it is better to @@ -513,9 +513,9 @@ void TermDbSygus::registerEnumerator(Node e, << " returned " << isActiveGen << std::endl; // Currently, actively-generated enumerators are either basic or variable // agnostic. - bool isVarAgnostic = - isActiveGen - && options::sygusActiveGenMode() == SYGUS_ACTIVE_GEN_VAR_AGNOSTIC; + bool isVarAgnostic = isActiveGen + && options::sygusActiveGenMode() + == options::SygusActiveGenMode::VAR_AGNOSTIC; d_enum_var_agnostic[e] = isVarAgnostic; if (isVarAgnostic) { diff --git a/src/theory/quantifiers/term_database.cpp b/src/theory/quantifiers/term_database.cpp index 79279eb41..524c440ba 100644 --- a/src/theory/quantifiers/term_database.cpp +++ b/src/theory/quantifiers/term_database.cpp @@ -16,10 +16,11 @@ #include "options/base_options.h" #include "options/quantifiers_options.h" +#include "options/theory_options.h" #include "options/uf_options.h" +#include "theory/quantifiers/ematching/trigger.h" #include "theory/quantifiers/quantifiers_attributes.h" #include "theory/quantifiers/term_util.h" -#include "theory/quantifiers/ematching/trigger.h" #include "theory/quantifiers_engine.h" #include "theory/theory_engine.h" @@ -672,7 +673,8 @@ Node TermDb::evaluateTerm2(TNode n, for (unsigned j = 0; j < 2; j++) { std::pair et = te->entailmentCheck( - THEORY_OF_TYPE_BASED, j == 0 ? ret : ret.negate()); + options::TheoryOfMode::THEORY_OF_TYPE_BASED, + j == 0 ? ret : ret.negate()); if (et.first) { ret = j == 0 ? d_true : d_false; @@ -905,11 +907,16 @@ bool TermDb::hasTermCurrent( Node n, bool useMode ) { return d_has_map.find( n )!=d_has_map.end(); }else{ //return d_quantEngine->getActiveEqualityEngine()->hasTerm( n ); //some assertions are not sent to EE - if( options::termDbMode()==TERM_DB_ALL ){ + if (options::termDbMode() == options::TermDbMode::ALL) + { return true; - }else if( options::termDbMode()==TERM_DB_RELEVANT ){ + } + else if (options::termDbMode() == options::TermDbMode::RELEVANT) + { return d_has_map.find( n )!=d_has_map.end(); - }else{ + } + else + { Assert(false); return false; } @@ -1061,7 +1068,9 @@ bool TermDb::reset( Theory::Effort effort ){ } //compute has map - if( options::termDbMode()==TERM_DB_RELEVANT || options::lteRestrictInstClosure() ){ + if (options::termDbMode() == options::TermDbMode::RELEVANT + || options::lteRestrictInstClosure()) + { d_has_map.clear(); d_term_elig_eqc.clear(); eq::EqClassesIterator eqcs_i = eq::EqClassesIterator( ee ); diff --git a/src/theory/quantifiers_engine.cpp b/src/theory/quantifiers_engine.cpp index 8730e3a97..c7eafc3b8 100644 --- a/src/theory/quantifiers_engine.cpp +++ b/src/theory/quantifiers_engine.cpp @@ -160,7 +160,7 @@ class QuantifiersEnginePrivate d_lte_part_inst.reset(new quantifiers::LtePartialInst(qe, c)); modules.push_back(d_lte_part_inst.get()); } - if (options::quantDynamicSplit() != quantifiers::QUANT_DSPLIT_MODE_NONE) + if (options::quantDynamicSplit() != options::QuantDSplitMode::NONE) { d_qsplit.reset(new quantifiers::QuantDSplit(qe, c)); modules.push_back(d_qsplit.get()); @@ -273,8 +273,8 @@ QuantifiersEngine::QuantifiersEngine(context::Context* c, // if we require specialized ways of building the model if( needsBuilder ){ Trace("quant-engine-debug") << "Initialize model engine, mbqi : " << options::mbqiMode() << " " << options::fmfBound() << std::endl; - if (options::mbqiMode() == quantifiers::MBQI_FMC - || options::mbqiMode() == quantifiers::MBQI_TRUST + if (options::mbqiMode() == options::MbqiMode::FMC + || options::mbqiMode() == options::MbqiMode::TRUST || options::fmfBound()) { Trace("quant-engine-debug") << "...make fmc builder." << std::endl; @@ -1082,17 +1082,29 @@ bool QuantifiersEngine::getInstWhenNeedsCheck( Theory::Effort e ) { Trace("quant-engine-debug2") << "Get inst when needs check, counts=" << d_ierCounter << ", " << d_ierCounter_lc << std::endl; //determine if we should perform check, based on instWhenMode bool performCheck = false; - if( options::instWhenMode()==quantifiers::INST_WHEN_FULL ){ + if (options::instWhenMode() == options::InstWhenMode::FULL) + { performCheck = ( e >= Theory::EFFORT_FULL ); - }else if( options::instWhenMode()==quantifiers::INST_WHEN_FULL_DELAY ){ + } + else if (options::instWhenMode() == options::InstWhenMode::FULL_DELAY) + { performCheck = ( e >= Theory::EFFORT_FULL ) && !getTheoryEngine()->needCheck(); - }else if( options::instWhenMode()==quantifiers::INST_WHEN_FULL_LAST_CALL ){ + } + else if (options::instWhenMode() == options::InstWhenMode::FULL_LAST_CALL) + { performCheck = ( ( e==Theory::EFFORT_FULL && d_ierCounter%d_inst_when_phase!=0 ) || e==Theory::EFFORT_LAST_CALL ); - }else if( options::instWhenMode()==quantifiers::INST_WHEN_FULL_DELAY_LAST_CALL ){ + } + else if (options::instWhenMode() + == options::InstWhenMode::FULL_DELAY_LAST_CALL) + { performCheck = ( ( e==Theory::EFFORT_FULL && !getTheoryEngine()->needCheck() && d_ierCounter%d_inst_when_phase!=0 ) || e==Theory::EFFORT_LAST_CALL ); - }else if( options::instWhenMode()==quantifiers::INST_WHEN_LAST_CALL ){ + } + else if (options::instWhenMode() == options::InstWhenMode::LAST_CALL) + { performCheck = ( e >= Theory::EFFORT_LAST_CALL ); - }else{ + } + else + { performCheck = true; } if( e==Theory::EFFORT_LAST_CALL ){ @@ -1105,10 +1117,15 @@ bool QuantifiersEngine::getInstWhenNeedsCheck( Theory::Effort e ) { return performCheck; } -quantifiers::UserPatMode QuantifiersEngine::getInstUserPatMode() { - if( options::userPatternsQuant()==quantifiers::USER_PAT_MODE_INTERLEAVE ){ - return d_ierCounter%2==0 ? quantifiers::USER_PAT_MODE_USE : quantifiers::USER_PAT_MODE_RESORT; - }else{ +options::UserPatMode QuantifiersEngine::getInstUserPatMode() +{ + if (options::userPatternsQuant() == options::UserPatMode::INTERLEAVE) + { + return d_ierCounter % 2 == 0 ? options::UserPatMode::USE + : options::UserPatMode::RESORT; + } + else + { return options::userPatternsQuant(); } } diff --git a/src/theory/quantifiers_engine.h b/src/theory/quantifiers_engine.h index d1d7f1633..380e0896e 100644 --- a/src/theory/quantifiers_engine.h +++ b/src/theory/quantifiers_engine.h @@ -214,8 +214,9 @@ public: /** get needs check */ bool getInstWhenNeedsCheck( Theory::Effort e ); /** get user pat mode */ - quantifiers::UserPatMode getInstUserPatMode(); -public: + options::UserPatMode getInstUserPatMode(); + + public: /** add term to database */ void addTermToDatabase( Node n, bool withinQuant = false, bool withinInstClosure = false ); /** notification when master equality engine is updated */ diff --git a/src/theory/rewriter.cpp b/src/theory/rewriter.cpp index 44d29d819..7a99ed2d9 100644 --- a/src/theory/rewriter.cpp +++ b/src/theory/rewriter.cpp @@ -17,10 +17,11 @@ #include "theory/rewriter.h" -#include "theory/theory.h" +#include "options/theory_options.h" #include "smt/smt_engine_scope.h" #include "smt/smt_statistics_registry.h" #include "theory/rewriter_tables.h" +#include "theory/theory.h" #include "util/resource_manager.h" using namespace std; diff --git a/src/theory/sort_inference.cpp b/src/theory/sort_inference.cpp index d1ecef831..33a50960c 100644 --- a/src/theory/sort_inference.cpp +++ b/src/theory/sort_inference.cpp @@ -394,7 +394,10 @@ int SortInference::process( Node n, std::map< Node, Node >& var_bound, std::map< for( size_t i=0; i=1; + processChild = + options::userPatternsQuant() == options::UserPatMode::IGNORE + ? i == 1 + : i >= 1; } if( processChild ){ children.push_back( n[i] ); @@ -650,7 +653,10 @@ Node SortInference::simplifyNode( for( size_t i=0; i=1; + processChild = + options::userPatternsQuant() == options::UserPatMode::IGNORE + ? i == 1 + : i >= 1; } if( processChild ){ if( n.getKind()==kind::APPLY_UF ){ diff --git a/src/theory/strings/regexp_solver.cpp b/src/theory/strings/regexp_solver.cpp index b13b64f98..e4fe2cf17 100644 --- a/src/theory/strings/regexp_solver.cpp +++ b/src/theory/strings/regexp_solver.cpp @@ -374,7 +374,7 @@ bool RegExpSolver::checkEqcInclusion(std::vector& mems) bool RegExpSolver::checkEqcIntersect(const std::vector& mems) { // do not compute intersections if the re intersection mode is none - if (options::stringRegExpInterMode() == RE_INTER_NONE) + if (options::stringRegExpInterMode() == options::RegExpInterMode::NONE) { return true; } @@ -397,19 +397,21 @@ bool RegExpSolver::checkEqcIntersect(const std::vector& mems) } RegExpConstType rct = d_regexp_opr.getRegExpConstType(m[1]); if (rct == RE_C_VARIABLE - || (options::stringRegExpInterMode() == RE_INTER_CONSTANT + || (options::stringRegExpInterMode() + == options::RegExpInterMode::CONSTANT && rct != RE_C_CONRETE_CONSTANT)) { // cannot do intersection on RE with variables, or with re.allchar based // on option. continue; } - if (options::stringRegExpInterMode() == RE_INTER_ONE_CONSTANT) + if (options::stringRegExpInterMode() + == options::RegExpInterMode::ONE_CONSTANT) { if (!mi.isNull() && rcti >= RE_C_CONSTANT && rct >= RE_C_CONSTANT) { // if both have re.allchar, do not do intersection if the - // RE_INTER_ONE_CONSTANT option is set. + // options::RegExpInterMode::ONE_CONSTANT option is set. continue; } } diff --git a/src/theory/strings/solver_state.cpp b/src/theory/strings/solver_state.cpp index b69c99e8c..66ae8d6bc 100644 --- a/src/theory/strings/solver_state.cpp +++ b/src/theory/strings/solver_state.cpp @@ -284,7 +284,8 @@ void SolverState::setPendingConflictWhen(Node conf) Node SolverState::getPendingConflict() const { return d_pendingConflict; } -std::pair SolverState::entailmentCheck(TheoryOfMode mode, TNode lit) +std::pair SolverState::entailmentCheck(options::TheoryOfMode mode, + TNode lit) { return d_valuation.entailmentCheck(mode, lit); } diff --git a/src/theory/strings/solver_state.h b/src/theory/strings/solver_state.h index a2001bb3b..46d198d36 100644 --- a/src/theory/strings/solver_state.h +++ b/src/theory/strings/solver_state.h @@ -22,6 +22,7 @@ #include "context/cdo.h" #include "context/context.h" #include "expr/node.h" +#include "options/theory_options.h" #include "theory/uf/equality_engine.h" #include "theory/valuation.h" @@ -171,7 +172,7 @@ class SolverState * * This calls entailmentCheck on the Valuation object of theory of strings. */ - std::pair entailmentCheck(TheoryOfMode mode, TNode lit); + std::pair entailmentCheck(options::TheoryOfMode mode, TNode lit); /** Separate by length * * Separate the string representatives in argument n into a partition cols diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp index df2364790..7b00ed2e2 100644 --- a/src/theory/strings/theory_strings.cpp +++ b/src/theory/strings/theory_strings.cpp @@ -20,6 +20,7 @@ #include "expr/kind.h" #include "options/strings_options.h" +#include "options/theory_options.h" #include "smt/command.h" #include "smt/logic_exception.h" #include "smt/smt_statistics_registry.h" @@ -3369,7 +3370,7 @@ void TheoryStrings::processSimpleNEq(NormalForm& nfi, Node lt2 = e==0 ? length_term_j : length_term_i; Node ent_lit = Rewriter::rewrite( NodeManager::currentNM()->mkNode( kind::GT, lt1, lt2 ) ); std::pair et = d_state.entailmentCheck( - THEORY_OF_TYPE_BASED, ent_lit); + options::TheoryOfMode::THEORY_OF_TYPE_BASED, ent_lit); if( et.first ){ Trace("strings-entail") << "Strings entailment : " << ent_lit << " is entailed in the current context." << std::endl; Trace("strings-entail") << " explanation was : " << et.second << std::endl; @@ -3482,11 +3483,11 @@ TheoryStrings::ProcessLoopResult TheoryStrings::processLoop(NormalForm& nfi, int index, InferInfo& info) { - if (options::stringProcessLoopMode() == ProcessLoopMode::ABORT) + if (options::stringProcessLoopMode() == options::ProcessLoopMode::ABORT) { throw LogicException("Looping word equation encountered."); } - else if (options::stringProcessLoopMode() == ProcessLoopMode::NONE) + else if (options::stringProcessLoopMode() == options::ProcessLoopMode::NONE) { d_out->setIncomplete(); return ProcessLoopResult::SKIPPED; @@ -3629,11 +3630,13 @@ TheoryStrings::ProcessLoopResult TheoryStrings::processLoop(NormalForm& nfi, } else { - if (options::stringProcessLoopMode() == ProcessLoopMode::SIMPLE_ABORT) + if (options::stringProcessLoopMode() + == options::ProcessLoopMode::SIMPLE_ABORT) { throw LogicException("Normal looping word equation encountered."); } - else if (options::stringProcessLoopMode() == ProcessLoopMode::SIMPLE) + else if (options::stringProcessLoopMode() + == options::ProcessLoopMode::SIMPLE) { d_out->setIncomplete(); return ProcessLoopResult::SKIPPED; diff --git a/src/theory/theory.cpp b/src/theory/theory.cpp index 719239806..a159787f9 100644 --- a/src/theory/theory.cpp +++ b/src/theory/theory.cpp @@ -16,13 +16,14 @@ #include "theory/theory.h" -#include -#include #include +#include #include +#include #include "base/check.h" #include "expr/node_algorithm.h" +#include "options/theory_options.h" #include "smt/smt_statistics_registry.h" #include "theory/ext_theory.h" #include "theory/quantifiers_engine.h" @@ -90,87 +91,128 @@ Theory::~Theory() { delete d_extTheory; } -TheoryId Theory::theoryOf(TheoryOfMode mode, TNode node) { +TheoryId Theory::theoryOf(options::TheoryOfMode mode, TNode node) +{ TheoryId tid = THEORY_BUILTIN; switch(mode) { - case THEORY_OF_TYPE_BASED: - // Constants, variables, 0-ary constructors - if (node.isVar()) { - if( node.getKind() == kind::BOOLEAN_TERM_VARIABLE ){ - tid = THEORY_UF; - }else{ - tid = Theory::theoryOf(node.getType()); - } - }else if (node.isConst()) { - tid = Theory::theoryOf(node.getType()); - } else if (node.getKind() == kind::EQUAL) { - // Equality is owned by the theory that owns the domain - tid = Theory::theoryOf(node[0].getType()); - } else { - // Regular nodes are owned by the kind - tid = kindToTheoryId(node.getKind()); - } - break; - case THEORY_OF_TERM_BASED: - // Variables - if (node.isVar()) { - if (Theory::theoryOf(node.getType()) != theory::THEORY_BOOL) { - // We treat the variables as uninterpreted - tid = s_uninterpretedSortOwner; - } else { - if( node.getKind() == kind::BOOLEAN_TERM_VARIABLE ){ - //Boolean vars go to UF + case options::TheoryOfMode::THEORY_OF_TYPE_BASED: + // Constants, variables, 0-ary constructors + if (node.isVar()) + { + if (node.getKind() == kind::BOOLEAN_TERM_VARIABLE) + { tid = THEORY_UF; - }else{ - // Except for the Boolean ones - tid = THEORY_BOOL; } + else + { + tid = Theory::theoryOf(node.getType()); + } + } + else if (node.isConst()) + { + tid = Theory::theoryOf(node.getType()); } - } else if (node.isConst()) { - // Constants go to the theory of the type - tid = Theory::theoryOf(node.getType()); - } else if (node.getKind() == kind::EQUAL) { // Equality - // If one of them is an ITE, it's irelevant, since they will get replaced out anyhow - if (node[0].getKind() == kind::ITE) { + else if (node.getKind() == kind::EQUAL) + { + // Equality is owned by the theory that owns the domain tid = Theory::theoryOf(node[0].getType()); - } else if (node[1].getKind() == kind::ITE) { - tid = Theory::theoryOf(node[1].getType()); - } else { - TNode l = node[0]; - TNode r = node[1]; - TypeNode ltype = l.getType(); - TypeNode rtype = r.getType(); - if( ltype != rtype ){ - tid = Theory::theoryOf(l.getType()); - }else { - // If both sides belong to the same theory the choice is easy - TheoryId T1 = Theory::theoryOf(l); - TheoryId T2 = Theory::theoryOf(r); - if (T1 == T2) { - tid = T1; - } else { - TheoryId T3 = Theory::theoryOf(ltype); - // This is a case of - // * x*y = f(z) -> UF - // * x = c -> UF - // * f(x) = read(a, y) -> either UF or ARRAY - // at least one of the theories has to be parametric, i.e. theory of the type is different - // from the theory of the term - if (T1 == T3) { - tid = T2; - } else if (T2 == T3) { + } + else + { + // Regular nodes are owned by the kind + tid = kindToTheoryId(node.getKind()); + } + break; + case options::TheoryOfMode::THEORY_OF_TERM_BASED: + // Variables + if (node.isVar()) + { + if (Theory::theoryOf(node.getType()) != theory::THEORY_BOOL) + { + // We treat the variables as uninterpreted + tid = s_uninterpretedSortOwner; + } + else + { + if (node.getKind() == kind::BOOLEAN_TERM_VARIABLE) + { + // Boolean vars go to UF + tid = THEORY_UF; + } + else + { + // Except for the Boolean ones + tid = THEORY_BOOL; + } + } + } + else if (node.isConst()) + { + // Constants go to the theory of the type + tid = Theory::theoryOf(node.getType()); + } + else if (node.getKind() == kind::EQUAL) + { // Equality + // If one of them is an ITE, it's irelevant, since they will get + // replaced out anyhow + if (node[0].getKind() == kind::ITE) + { + tid = Theory::theoryOf(node[0].getType()); + } + else if (node[1].getKind() == kind::ITE) + { + tid = Theory::theoryOf(node[1].getType()); + } + else + { + TNode l = node[0]; + TNode r = node[1]; + TypeNode ltype = l.getType(); + TypeNode rtype = r.getType(); + if (ltype != rtype) + { + tid = Theory::theoryOf(l.getType()); + } + else + { + // If both sides belong to the same theory the choice is easy + TheoryId T1 = Theory::theoryOf(l); + TheoryId T2 = Theory::theoryOf(r); + if (T1 == T2) + { tid = T1; - } else { - // If both are parametric, we take the smaller one (arbitrary) - tid = T1 < T2 ? T1 : T2; + } + else + { + TheoryId T3 = Theory::theoryOf(ltype); + // This is a case of + // * x*y = f(z) -> UF + // * x = c -> UF + // * f(x) = read(a, y) -> either UF or ARRAY + // at least one of the theories has to be parametric, i.e. theory + // of the type is different from the theory of the term + if (T1 == T3) + { + tid = T2; + } + else if (T2 == T3) + { + tid = T1; + } + else + { + // If both are parametric, we take the smaller one (arbitrary) + tid = T1 < T2 ? T1 : T2; + } } } } } - } else { - // Regular nodes are owned by the kind - tid = kindToTheoryId(node.getKind()); - } + else + { + // Regular nodes are owned by the kind + tid = kindToTheoryId(node.getKind()); + } break; default: Unreachable(); diff --git a/src/theory/theory.h b/src/theory/theory.h index b133b878e..36db0fda8 100644 --- a/src/theory/theory.h +++ b/src/theory/theory.h @@ -33,7 +33,6 @@ #include "lib/ffs.h" #include "options/options.h" #include "options/theory_options.h" -#include "options/theoryof_mode.h" #include "smt/command.h" #include "smt/dump.h" #include "smt/logic_request.h" @@ -273,7 +272,7 @@ public: /** * Returns the ID of the theory responsible for the given node. */ - static TheoryId theoryOf(TheoryOfMode mode, TNode node); + static TheoryId theoryOf(options::TheoryOfMode mode, TNode node); /** * Returns the ID of the theory responsible for the given node. diff --git a/src/theory/theory_engine.cpp b/src/theory/theory_engine.cpp index 0a70ddab4..7549bd973 100644 --- a/src/theory/theory_engine.cpp +++ b/src/theory/theory_engine.cpp @@ -29,6 +29,7 @@ #include "options/options.h" #include "options/proof_options.h" #include "options/quantifiers_options.h" +#include "options/theory_options.h" #include "preprocessing/assertion_pipeline.h" #include "proof/cnf_proof.h" #include "proof/lemma_proof.h" @@ -2001,7 +2002,7 @@ void TheoryEngine::staticInitializeBVOptions( const std::vector& assertions) { bool useSlicer = true; - if (options::bitvectorEqualitySlicer() == bv::BITVECTOR_SLICER_ON) + if (options::bitvectorEqualitySlicer() == options::BvSlicerMode::ON) { if (!d_logicInfo.isPure(theory::THEORY_BV) || d_logicInfo.isQuantified()) throw ModalException( @@ -2016,11 +2017,11 @@ void TheoryEngine::staticInitializeBVOptions( "Slicer does not currently support model generation. Use " "--bv-eq-slicer=off"); } - else if (options::bitvectorEqualitySlicer() == bv::BITVECTOR_SLICER_OFF) + else if (options::bitvectorEqualitySlicer() == options::BvSlicerMode::OFF) { return; } - else if (options::bitvectorEqualitySlicer() == bv::BITVECTOR_SLICER_AUTO) + else if (options::bitvectorEqualitySlicer() == options::BvSlicerMode::AUTO) { if ((!d_logicInfo.isPure(theory::THEORY_BV) || d_logicInfo.isQuantified()) || options::incrementalSolving() @@ -2242,7 +2243,12 @@ void TheoryEngine::checkTheoryAssertionsWithModel(bool hardFailure) { } } -std::pair TheoryEngine::entailmentCheck(theory::TheoryOfMode mode, TNode lit, const EntailmentCheckParameters* params, EntailmentCheckSideEffects* seffects) { +std::pair TheoryEngine::entailmentCheck( + options::TheoryOfMode mode, + TNode lit, + const EntailmentCheckParameters* params, + EntailmentCheckSideEffects* seffects) +{ TNode atom = (lit.getKind() == kind::NOT) ? lit[0] : lit; if( atom.getKind()==kind::AND || atom.getKind()==kind::OR || atom.getKind()==kind::IMPLIES ){ //Boolean connective, recurse diff --git a/src/theory/theory_engine.h b/src/theory/theory_engine.h index dd34ae16b..5506b0120 100644 --- a/src/theory/theory_engine.h +++ b/src/theory/theory_engine.h @@ -23,14 +23,15 @@ #include #include #include -#include #include +#include #include "base/check.h" #include "context/cdhashset.h" #include "expr/node.h" #include "options/options.h" #include "options/smt_options.h" +#include "options/theory_options.h" #include "prop/prop_engine.h" #include "smt/command.h" #include "smt_util/lemma_channels.h" @@ -864,10 +865,13 @@ public: * Forwards an entailment check according to the given theoryOfMode. * See theory.h for documentation on entailmentCheck(). */ - std::pair entailmentCheck(theory::TheoryOfMode mode, TNode lit, const theory::EntailmentCheckParameters* params = NULL, theory::EntailmentCheckSideEffects* out = NULL); - -private: + std::pair entailmentCheck( + options::TheoryOfMode mode, + TNode lit, + const theory::EntailmentCheckParameters* params = NULL, + theory::EntailmentCheckSideEffects* out = NULL); + private: /** Default visitor for pre-registration */ PreRegisterVisitor d_preRegistrationVisitor; diff --git a/src/theory/type_enumerator_template.cpp b/src/theory/type_enumerator_template.cpp index 26d83334d..01d25860c 100644 --- a/src/theory/type_enumerator_template.cpp +++ b/src/theory/type_enumerator_template.cpp @@ -42,7 +42,7 @@ TypeEnumeratorInterface* TypeEnumerator::mkTypeEnumerator( } Unreachable(); ${mk_type_enumerator_cases} -#line 44 "${template}" +#line 46 "${template}" default: Unhandled() << "No type enumerator for type `" << type << "'"; } Unreachable(); diff --git a/src/theory/uf/cardinality_extension.cpp b/src/theory/uf/cardinality_extension.cpp index 98e330df4..34952084b 100644 --- a/src/theory/uf/cardinality_extension.cpp +++ b/src/theory/uf/cardinality_extension.cpp @@ -480,7 +480,7 @@ SortModel::SortModel(Node n, { d_cardinality_term = n; - if (options::ufssMode() == UF_SS_FULL) + if (options::ufssMode() == options::UfssMode::FULL) { // Register the strategy with the decision manager of the theory. // We are guaranteed that the decision manager is ready since we @@ -671,7 +671,7 @@ bool SortModel::areDisequal( Node a, Node b ) { /** check */ void SortModel::check( Theory::Effort level, OutputChannel* out ){ - Assert(options::ufssMode() == UF_SS_FULL); + Assert(options::ufssMode() == options::UfssMode::FULL); if( level>=Theory::EFFORT_STANDARD && d_hasCard && !d_conflict ){ Debug("uf-ss") << "CardinalityExtension: Check " << level << " " << d_type << std::endl; @@ -1314,7 +1314,7 @@ CardinalityExtension::CardinalityExtension(context::Context* c, d_min_pos_tn_master_card(c, -1), d_rel_eqc(c) { - if (options::ufssMode() == UF_SS_FULL && options::ufssFairness()) + if (options::ufssMode() == options::UfssMode::FULL && options::ufssFairness()) { // Register the strategy with the decision manager of the theory. // We are guaranteed that the decision manager is ready since we @@ -1451,7 +1451,8 @@ void CardinalityExtension::assertNode(Node n, bool isDecision) #endif bool polarity = n.getKind() != kind::NOT; TNode lit = polarity ? n : n[0]; - if( options::ufssMode()==UF_SS_FULL ){ + if (options::ufssMode() == options::UfssMode::FULL) + { if( lit.getKind()==CARDINALITY_CONSTRAINT ){ TypeNode tn = lit[0].getType(); Assert(tn.isSort()); @@ -1532,7 +1533,9 @@ void CardinalityExtension::assertNode(Node n, bool isDecision) } } } - }else{ + } + else + { if( lit.getKind()==CARDINALITY_CONSTRAINT || lit.getKind()==COMBINED_CARDINALITY_CONSTRAINT ){ // cardinality constraint from user input, set incomplete Trace("uf-ss") << "Literal " << lit << " not handled when uf ss mode is not FULL, set incomplete." << std::endl; @@ -1566,7 +1569,8 @@ bool CardinalityExtension::areDisequal(Node a, Node b) void CardinalityExtension::check(Theory::Effort level) { if( !d_conflict ){ - if( options::ufssMode()==UF_SS_FULL ){ + if (options::ufssMode() == options::UfssMode::FULL) + { Trace("uf-ss-solver") << "CardinalityExtension: check " << level << std::endl; if (level == Theory::EFFORT_FULL) @@ -1593,7 +1597,9 @@ void CardinalityExtension::check(Theory::Effort level) break; } } - }else if( options::ufssMode()==UF_SS_NO_MINIMAL ){ + } + else if (options::ufssMode() == options::UfssMode::NO_MINIMAL) + { if( level==Theory::EFFORT_FULL ){ // split on an equality between two equivalence classes (at most one per type) std::map< TypeNode, std::vector< Node > > eqc_list; @@ -1625,7 +1631,9 @@ void CardinalityExtension::check(Theory::Effort level) ++eqcs_i; } } - }else{ + } + else + { // unhandled uf ss mode Assert(false); } @@ -1664,7 +1672,8 @@ CardinalityExtension::CombinedCardinalityDecisionStrategy::identify() const void CardinalityExtension::preRegisterTerm(TNode n) { - if( options::ufssMode()==UF_SS_FULL ){ + if (options::ufssMode() == options::UfssMode::FULL) + { //initialize combined cardinality initializeCombinedCardinality(); @@ -1776,7 +1785,7 @@ void CardinalityExtension::initializeCombinedCardinality() /** check */ void CardinalityExtension::checkCombinedCardinality() { - Assert(options::ufssMode() == UF_SS_FULL); + Assert(options::ufssMode() == options::UfssMode::FULL); if( options::ufssFairness() ){ Trace("uf-ss-com-card-debug") << "Check combined cardinality, get maximum negative cardinalities..." << std::endl; int totalCombinedCard = 0; diff --git a/src/theory/uf/theory_uf.cpp b/src/theory/uf/theory_uf.cpp index 95e3f702b..4d13bf3f2 100644 --- a/src/theory/uf/theory_uf.cpp +++ b/src/theory/uf/theory_uf.cpp @@ -79,7 +79,7 @@ void TheoryUF::finishInit() { // finite model finding is enabled, and it is not disabled by // options::ufssMode(). if (getLogicInfo().isTheoryEnabled(THEORY_UF) && options::finiteModelFind() - && options::ufssMode() != UF_SS_NONE) + && options::ufssMode() != options::UfssMode::NONE) { d_thss.reset(new CardinalityExtension( getSatContext(), getUserContext(), *d_out, this)); diff --git a/src/theory/valuation.cpp b/src/theory/valuation.cpp index 83a7e3bff..4ad8c8785 100644 --- a/src/theory/valuation.cpp +++ b/src/theory/valuation.cpp @@ -14,10 +14,12 @@ ** Implementation of Valuation class. **/ -#include "expr/node.h" #include "theory/valuation.h" -#include "theory/theory_engine.h" + +#include "expr/node.h" +#include "options/theory_options.h" #include "theory/rewriter.h" +#include "theory/theory_engine.h" namespace CVC4 { namespace theory { @@ -123,7 +125,12 @@ unsigned Valuation::getAssertionLevel() const{ return d_engine->getPropEngine()->getAssertionLevel(); } -std::pair Valuation::entailmentCheck(theory::TheoryOfMode mode, TNode lit, const theory::EntailmentCheckParameters* params, theory::EntailmentCheckSideEffects* out) { +std::pair Valuation::entailmentCheck( + options::TheoryOfMode mode, + TNode lit, + const theory::EntailmentCheckParameters* params, + theory::EntailmentCheckSideEffects* out) +{ return d_engine->entailmentCheck(mode, lit, params, out); } diff --git a/src/theory/valuation.h b/src/theory/valuation.h index 89f286a5e..4667db0e9 100644 --- a/src/theory/valuation.h +++ b/src/theory/valuation.h @@ -22,7 +22,7 @@ #define CVC4__THEORY__VALUATION_H #include "expr/node.h" -#include "options/theoryof_mode.h" +#include "options/theory_options.h" namespace CVC4 { @@ -141,7 +141,11 @@ public: * Request an entailment check according to the given theoryOfMode. * See theory.h for documentation on entailmentCheck(). */ - std::pair entailmentCheck(theory::TheoryOfMode mode, TNode lit, const theory::EntailmentCheckParameters* params = NULL, theory::EntailmentCheckSideEffects* out = NULL); + std::pair entailmentCheck( + options::TheoryOfMode mode, + TNode lit, + const theory::EntailmentCheckParameters* params = NULL, + theory::EntailmentCheckSideEffects* out = NULL); /** need check ? */ bool needCheck() const; -- 2.30.2