diff options
512 files changed, 6485 insertions, 5254 deletions
diff --git a/.travis.yml b/.travis.yml index 5ee1410f1..08b7b0241 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,18 +54,18 @@ script: exit 1; } makeDistcheck() { - make -j2 distcheck CVC4_REGRESSION_ARGS='--no-early-exit' DISTCHECK_CONFIGURE_FLAGS="CXXTEST=$HOME/cxxtest" || + make V=1 -j2 distcheck CVC4_REGRESSION_ARGS='--no-early-exit' DISTCHECK_CONFIGURE_FLAGS="CXXTEST=$HOME/cxxtest" || error "DISTCHECK (WITH NEWTHEORY TESTS) FAILED"; } makeCheck() { - make -j2 check CVC4_REGRESSION_ARGS='--no-early-exit' || error "BUILD/TEST FAILED"; + make V=1 -j2 check CVC4_REGRESSION_ARGS='--no-early-exit' || error "BUILD/TEST FAILED"; } makeCheckPortfolio() { - make check BINARY=pcvc4 CVC4_REGRESSION_ARGS='--fallback-sequential --no-early-exit' RUN_REGRESSION_ARGS= || + make check V=1 BINARY=pcvc4 CVC4_REGRESSION_ARGS='--fallback-sequential --no-early-exit' RUN_REGRESSION_ARGS= || error "PORTFOLIO TEST FAILED"; } makeExamples() { - make -j2 examples || error "COULD NOT BUILD EXAMPLES${normal}"; + make V=1 -j2 examples || error "COULD NOT BUILD EXAMPLES${normal}"; } addNewTheoryTest() { contrib/new-theory test_newtheory || error "NEWTHEORY FAILED"; @@ -101,4 +101,4 @@ matrix: notifications: email: on_success: change - on_failure: always
\ No newline at end of file + on_failure: always @@ -13,7 +13,7 @@ The core designers and authors of CVC4 are: Morgan Deters, New York University Liana Hadarean, New York University & Mentor Graphics Corporation Dejan Jovanovic, New York University & SRI International - Tim King, New York University + Tim King, New York University, Universite Joseph Fourier & Google, Inc. Tianyi Liang, The University of Iowa Andrew Reynolds, The University of Iowa & EPFL Cesare Tinelli, The University of Iowa diff --git a/configure.ac b/configure.ac index fe3d7b8d9..c3c29db38 100644 --- a/configure.ac +++ b/configure.ac @@ -1410,9 +1410,9 @@ if test -n "$CVC4_LANGUAGE_BINDINGS"; then fi fi -CVC4_CONFIG_FILE_ONLY_IF_CHANGED([src/util/rational.h]) +CVC4_CONFIG_FILE_ONLY_IF_CHANGED([src/base/tls.h]) CVC4_CONFIG_FILE_ONLY_IF_CHANGED([src/util/integer.h]) -CVC4_CONFIG_FILE_ONLY_IF_CHANGED([src/util/tls.h]) +CVC4_CONFIG_FILE_ONLY_IF_CHANGED([src/util/rational.h]) CVC4_CONFIG_FILE_ONLY_IF_CHANGED([doc/cvc4.1_template]) CVC4_CONFIG_FILE_ONLY_IF_CHANGED([doc/cvc4.5]) diff --git a/contrib/depgraph b/contrib/depgraph index e85bcd694..2c4eba595 100755 --- a/contrib/depgraph +++ b/contrib/depgraph @@ -88,6 +88,7 @@ for path in $paths; do if [ -n "$target" -a "$target" != "$package" ]; then continue; fi for inc in $incs; do case "$inc" in + base/tls.h) inc=base/tls.h.in ;; expr/expr.h) inc=expr/expr_template.h ;; expr/expr_manager.h) inc=expr/expr_manager_template.h ;; expr/kind.h) inc=expr/kind_template.h ;; @@ -95,7 +96,6 @@ for path in $paths; do theory/theoryof_table.h) inc=theory/theoryof_table_template.h ;; util/integer.h) inc=util/integer.h.in ;; util/rational.h) inc=util/rational.h.in ;; - util/tls.h) inc=util/tls.h.in ;; cvc4autoconfig.h) inc=cvc4autoconfig.h.in ;; esac incpath= diff --git a/contrib/new-theory b/contrib/new-theory index 8f9714372..0d9e45647 100755 --- a/contrib/new-theory +++ b/contrib/new-theory @@ -119,6 +119,15 @@ function copyaltskel { > "src/theory/$dir/$dest" } +function copyoptions { + src="$1" + dest="`echo "$src" | sed "s/DIR/$dir/g"`" + echo "Creating src/options/$dest..." + sed "s/\$dir/$dir/g;s/\$camel/$camel/g;s/\$id/$id/g;s/\$alt_id/$alt_id/g" \ + contrib/optionsskel/$src \ + > "src/options/$dest" +} + # copy files from the skeleton, with proper replacements if $alternate; then alternate01=1 @@ -131,6 +140,11 @@ else copyskel "$file" done fi +# Copy the options file independently +for file in `ls contrib/optionsskel`; do + copyoptions "$file" +done + echo echo "Adding $dir to THEORIES to src/Makefile.theories..." @@ -158,19 +172,18 @@ perl -e ' while(<>) { if(!/\\$/) { chomp; print "$_ \\\n\ttheory/'"$dir"'/theory_'"$dir"'.h \\\n\ttheory/'"$dir"'/theory_'"$dir"'.cpp \\\n\ttheory/'"$dir"'/theory_'"$dir"'_rewriter.h \\\n\ttheory/'"$dir"'/theory_'"$dir"'_type_rules.h\n"; last; } else { print; } } } while(<>) { print; last if /^EXTRA_DIST = /; } - while(<>) { if(!/\\$/) { chomp; print "$_ \\\n\ttheory/'"$dir"'/kinds \\\n\ttheory/'"$dir"'/options_handlers.h\n"; last; } else { print; } } + while(<>) { if(!/\\$/) { chomp; print "$_ \\\n\ttheory/'"$dir"'/kinds\n"; last; } else { print; } } while(<>) { print; }' src/Makefile.am > src/Makefile.am.new-theory if ! mv -f src/Makefile.am.new-theory src/Makefile.am; then echo "ERROR: cannot replace src/Makefile.am !" >&2 exit 1 fi -echo "Adding ../theory/$dir/options.cpp to OPTIONS_FILES_SRCS" -echo " and nodist_liboptions_la_SOURCES to src/options/Makefile.am..." -if grep -q '^ \.\./theory/'"$dir"'/options\.cpp\>' src/options/Makefile.am &>/dev/null; then +echo "Adding ${dir}_options to src/options/Makefile.am..." +if grep -q '^ ${dir}_options' src/options/Makefile.am &>/dev/null; then echo "NOTE: src/options/Makefile.am already seems to link to $dir option files" else - awk '!/^OPTIONS_FILES_SRCS = \\|^nodist_liboptions_la_SOURCES = / {print$0} /^OPTIONS_FILES_SRCS = \\|^nodist_liboptions_la_SOURCES = / {while(/\\ *$/){print $0;getline} print $0,"\\";print "\t../theory/'"$dir"'/options.cpp","\\";print "\t../theory/'"$dir"'/options.h";}' src/options/Makefile.am > src/options/Makefile.am.new-theory + awk -v name="$dir" -f contrib/new-theory.awk src/options/Makefile.am > src/options/Makefile.am.new-theory if ! cp -f src/options/Makefile.am src/options/Makefile.am~; then echo "ERROR: cannot copy src/options/Makefile.am !" >&2 exit 1 diff --git a/contrib/new-theory.awk b/contrib/new-theory.awk new file mode 100755 index 000000000..6c523f259 --- /dev/null +++ b/contrib/new-theory.awk @@ -0,0 +1,17 @@ +#!/bin/awk -v name=theory_new -f +# + +# The do nothing rule +!/^OPTIONS_SRC_FILES = \\|^OPTIONS_TEMPS = \\|^OPTIONS_OPTIONS_FILES = \\|^OPTIONS_SEDS = \\|^OPTIONS_HEADS = \\|^OPTIONS_CPPS = \\/ {print$0} +# Add the name to the correct locations. +/^OPTIONS_SRC_FILES = \\/{print $0; printf "\t%s_options \\\n", name;} +/^OPTIONS_TEMPS = \\/{print $0; printf "\t%s_options.tmp \\\n", name;} +/^OPTIONS_OPTIONS_FILES = \\/{print $0; printf "\t%s_options.options \\\n", name;} +/^OPTIONS_SEDS = \\/{print $0; printf "\t%s_options.sed \\\n", name;} +/^OPTIONS_HEADS = \\/{print $0; printf "\t%s_options.h \\\n", name;} +/^OPTIONS_CPPS = \\/{print $0; printf "\t%s_options.cpp \\\n", name;} +# Add the rule for name_options. +END{printf "%s_options:;\n", name} +# Add the rules for name_options.tmp +END{printf ".PHONY: %s_options.tmp\n", name} +END{printf "%s_options.tmp:\n\techo \"$@\" \"$(@:.tmp=)\"\n\t$(AM_V_GEN)(cp \"@srcdir@/$(@:.tmp=)\" \"$@\" || true)\n", name} diff --git a/contrib/theoryskel/options b/contrib/optionsskel/DIR_options index f627dc4a0..de160df6d 100644 --- a/contrib/theoryskel/options +++ b/contrib/optionsskel/DIR_options @@ -3,6 +3,6 @@ # See src/options/base_options for a description of this file format # -module $id "theory/$dir/options.h" $camel +module $id "options/$dir_options.h" $camel endmodule diff --git a/contrib/theoryskel/options_handlers.h b/contrib/theoryskel/options_handlers.h deleted file mode 100644 index d384e84d9..000000000 --- a/contrib/theoryskel/options_handlers.h +++ /dev/null @@ -1,14 +0,0 @@ -#include "cvc4_private.h" - -#ifndef __CVC4__THEORY__$id__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__$id__OPTIONS_HANDLERS_H - -namespace CVC4 { -namespace theory { -namespace $dir { - -}/* CVC4::theory::$dir namespace */ -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__THEORY__$id__OPTIONS_HANDLERS_H */ diff --git a/examples/api/datatypes.cpp b/examples/api/datatypes.cpp index 463cf9534..3da8cfa4a 100644 --- a/examples/api/datatypes.cpp +++ b/examples/api/datatypes.cpp @@ -15,8 +15,8 @@ **/ #include <iostream> +#include "options/language.h" // for use with make examples #include "smt/smt_engine.h" // for use with make examples -#include "util/language.h" // for use with make examples //#include <cvc4/cvc4.h> // To follow the wiki using namespace CVC4; diff --git a/examples/hashsmt/sha1_collision.cpp b/examples/hashsmt/sha1_collision.cpp index ad3705a94..e23be29bf 100644 --- a/examples/hashsmt/sha1_collision.cpp +++ b/examples/hashsmt/sha1_collision.cpp @@ -29,7 +29,7 @@ #include "word.h" #include "sha1.hpp" -#include "expr/command.h" +#include "smt_util/command.h" #include <boost/uuid/sha1.hpp> diff --git a/examples/hashsmt/sha1_inversion.cpp b/examples/hashsmt/sha1_inversion.cpp index 51267ba06..fadc6ecb9 100644 --- a/examples/hashsmt/sha1_inversion.cpp +++ b/examples/hashsmt/sha1_inversion.cpp @@ -29,7 +29,7 @@ #include "word.h" #include "sha1.hpp" -#include "expr/command.h" +#include "smt_util/command.h" #include <boost/uuid/sha1.hpp> diff --git a/examples/nra-translate/normalize.cpp b/examples/nra-translate/normalize.cpp index 2dd450c4e..d4aecbba9 100644 --- a/examples/nra-translate/normalize.cpp +++ b/examples/nra-translate/normalize.cpp @@ -15,20 +15,19 @@ ** \todo document this file **/ -#include <string> +#include <cassert> #include <iostream> +#include <map> +#include <string> #include <typeinfo> -#include <cassert> #include <vector> -#include <map> - -#include "options/options.h" #include "expr/expr.h" -#include "expr/command.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" #include "smt/smt_engine.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/examples/nra-translate/smt2info.cpp b/examples/nra-translate/smt2info.cpp index a2c12f05d..d59f9f4c4 100644 --- a/examples/nra-translate/smt2info.cpp +++ b/examples/nra-translate/smt2info.cpp @@ -15,18 +15,17 @@ ** \todo document this file **/ -#include <string> +#include <cassert> #include <iostream> +#include <string> #include <typeinfo> -#include <cassert> #include <vector> - -#include "options/options.h" #include "expr/expr.h" -#include "expr/command.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/examples/nra-translate/smt2todreal.cpp b/examples/nra-translate/smt2todreal.cpp index 4413c480a..97c5c5d04 100644 --- a/examples/nra-translate/smt2todreal.cpp +++ b/examples/nra-translate/smt2todreal.cpp @@ -15,19 +15,19 @@ ** \todo document this file **/ -#include <string> +#include <cassert> #include <iostream> +#include <map> +#include <string> #include <typeinfo> -#include <cassert> #include <vector> -#include <map> -#include "options/options.h" #include "expr/expr.h" -#include "expr/command.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" #include "smt/smt_engine.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/examples/nra-translate/smt2toisat.cpp b/examples/nra-translate/smt2toisat.cpp index eae77e1ce..9c94cdd43 100644 --- a/examples/nra-translate/smt2toisat.cpp +++ b/examples/nra-translate/smt2toisat.cpp @@ -15,20 +15,19 @@ ** \todo document this file **/ -#include <string> +#include <cassert> #include <iostream> +#include <map> +#include <string> #include <typeinfo> -#include <cassert> #include <vector> -#include <map> - -#include "options/options.h" #include "expr/expr.h" -#include "expr/command.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" #include "smt/smt_engine.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/examples/nra-translate/smt2tomathematica.cpp b/examples/nra-translate/smt2tomathematica.cpp index 3158243a5..86aaf786f 100644 --- a/examples/nra-translate/smt2tomathematica.cpp +++ b/examples/nra-translate/smt2tomathematica.cpp @@ -15,19 +15,18 @@ ** \todo document this file **/ -#include <string> +#include <cassert> #include <iostream> +#include <map> +#include <string> #include <typeinfo> -#include <cassert> #include <vector> -#include <map> - -#include "options/options.h" #include "expr/expr.h" -#include "expr/command.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/examples/nra-translate/smt2toqepcad.cpp b/examples/nra-translate/smt2toqepcad.cpp index cb4855a38..058fa8e0d 100644 --- a/examples/nra-translate/smt2toqepcad.cpp +++ b/examples/nra-translate/smt2toqepcad.cpp @@ -15,18 +15,18 @@ ** \todo document this file **/ -#include <string> +#include <cassert> #include <iostream> +#include <map> +#include <string> #include <typeinfo> -#include <cassert> #include <vector> -#include <map> -#include "options/options.h" #include "expr/expr.h" -#include "expr/command.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/examples/nra-translate/smt2toredlog.cpp b/examples/nra-translate/smt2toredlog.cpp index 71d7229af..1ebd6ea59 100644 --- a/examples/nra-translate/smt2toredlog.cpp +++ b/examples/nra-translate/smt2toredlog.cpp @@ -15,20 +15,19 @@ ** \todo document this file **/ -#include <string> +#include <cassert> #include <iostream> +#include <map> +#include <string> #include <typeinfo> -#include <cassert> #include <vector> -#include <map> - -#include "options/options.h" #include "expr/expr.h" -#include "expr/command.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" #include "smt/smt_engine.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/examples/sets-translate/sets_translate.cpp b/examples/sets-translate/sets_translate.cpp index acf0fcafe..c33ccb367 100644 --- a/examples/sets-translate/sets_translate.cpp +++ b/examples/sets-translate/sets_translate.cpp @@ -15,20 +15,19 @@ ** \todo document this file **/ -#include <string> +#include <boost/algorithm/string.hpp> // include Boost, a C++ library +#include <cassert> #include <iostream> +#include <string> #include <typeinfo> -#include <cassert> #include <vector> -#include <boost/algorithm/string.hpp> // include Boost, a C++ library - -#include "options/options.h" #include "expr/expr.h" -#include "theory/logic_info.h" -#include "expr/command.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" +#include "smt_util/command.h" +#include "theory/logic_info.h" using namespace std; using namespace CVC4; diff --git a/examples/translator.cpp b/examples/translator.cpp index 7aa969e06..522d88573 100644 --- a/examples/translator.cpp +++ b/examples/translator.cpp @@ -15,18 +15,19 @@ ** CVC4's input languages to one of its output languages. **/ -#include <iostream> +#include <cerrno> +#include <cstdlib> +#include <cstring> #include <fstream> #include <getopt.h> -#include <cstring> -#include <cstdlib> -#include <cerrno> -#include "smt/smt_engine.h" -#include "util/language.h" -#include "expr/command.h" +#include <iostream> + #include "expr/expr.h" -#include "parser/parser_builder.h" +#include "options/language.h" #include "parser/parser.h" +#include "parser/parser_builder.h" +#include "smt/smt_engine.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/src/Makefile.am b/src/Makefile.am index fe38ddf71..773acf67e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,7 +19,7 @@ AM_CPPFLAGS = \ -I@builddir@ -I@srcdir@/include -I@srcdir@ -I@top_srcdir@/proofs/lfsc_checker AM_CXXFLAGS = -Wall -Wno-unknown-pragmas -Wno-parentheses $(FLAG_VISIBILITY_HIDDEN) -SUBDIRS = lib options expr util prop/minisat prop/bvminisat . parser compat bindings main +SUBDIRS = lib base options util expr smt_util prop/minisat prop/bvminisat . parser compat bindings main # The THEORIES list has been moved to Makefile.theories include @top_srcdir@/src/Makefile.theories @@ -33,6 +33,7 @@ nodist_EXTRA_libcvc4_la_SOURCES = dummy.cpp libcvc4_la_SOURCES = \ git_versioninfo.cpp \ svn_versioninfo.cpp \ + context/backtrackable.h \ context/context.cpp \ context/context.h \ context/context_mm.cpp \ @@ -56,20 +57,16 @@ libcvc4_la_SOURCES = \ context/stacking_map.h \ context/stacking_vector.h \ context/cddense_set.h \ - decision/decision_mode.h \ - decision/decision_mode.cpp \ + decision/decision_attributes.h \ decision/decision_engine.h \ decision/decision_engine.cpp \ decision/decision_strategy.h \ decision/justification_heuristic.h \ decision/justification_heuristic.cpp \ - decision/options_handlers.h \ printer/printer.h \ printer/printer.cpp \ printer/dagification_visitor.h \ printer/dagification_visitor.cpp \ - printer/modes.h \ - printer/modes.cpp \ printer/ast/ast_printer.h \ printer/ast/ast_printer.cpp \ printer/smt1/smt1_printer.h \ @@ -80,7 +77,6 @@ libcvc4_la_SOURCES = \ printer/cvc/cvc_printer.cpp \ printer/tptp/tptp_printer.h \ printer/tptp/tptp_printer.cpp \ - printer/options_handlers.h \ proof/proof.h \ proof/sat_proof.h \ proof/sat_proof.cpp \ @@ -90,6 +86,8 @@ libcvc4_la_SOURCES = \ proof/theory_proof.cpp \ proof/proof_manager.h \ proof/proof_manager.cpp \ + proof/unsat_core.cpp \ + proof/unsat_core.h \ prop/registrar.h \ prop/prop_engine.cpp \ prop/prop_engine.h \ @@ -106,31 +104,29 @@ libcvc4_la_SOURCES = \ smt/smt_engine.h \ smt/model_postprocessor.cpp \ smt/model_postprocessor.h \ + smt/smt_options_handler.cpp \ + smt/smt_options_handler.h \ smt/smt_engine_scope.cpp \ smt/smt_engine_scope.h \ smt/command_list.cpp \ smt/command_list.h \ - smt/modal_exception.h \ smt/boolean_terms.h \ smt/boolean_terms.cpp \ smt/logic_exception.h \ smt/logic_request.h \ smt/logic_request.cpp \ - smt/simplification_mode.h \ - smt/simplification_mode.cpp \ - smt/options_handlers.h \ - theory/decision_attributes.h \ theory/logic_info.h \ theory/logic_info.cpp \ theory/output_channel.h \ theory/interrupted.h \ + theory/sort_inference.cpp \ + theory/sort_inference.h \ theory/type_enumerator.h \ theory/theory_engine.h \ theory/theory_engine.cpp \ theory/theory_test_utils.h \ theory/theory.h \ theory/theory.cpp \ - theory/theoryof_mode.h \ theory/theory_registrar.h \ theory/rewriter.h \ theory/rewriter_attributes.h \ @@ -155,7 +151,6 @@ libcvc4_la_SOURCES = \ theory/rep_set.cpp \ theory/atom_requests.h \ theory/atom_requests.cpp \ - theory/options_handlers.h \ theory/uf/theory_uf.h \ theory/uf/theory_uf.cpp \ theory/uf/theory_uf_type_rules.h \ @@ -169,7 +164,6 @@ libcvc4_la_SOURCES = \ theory/uf/theory_uf_strong_solver.cpp \ theory/uf/theory_uf_model.h \ theory/uf/theory_uf_model.cpp \ - theory/uf/options_handlers.h \ theory/bv/theory_bv_utils.h \ theory/bv/theory_bv_utils.cpp \ theory/bv/type_enumerator.h \ @@ -211,9 +205,6 @@ libcvc4_la_SOURCES = \ theory/bv/bv_quick_check.cpp \ theory/bv/bv_subtheory_algebraic.h \ theory/bv/bv_subtheory_algebraic.cpp \ - theory/bv/options_handlers.h \ - theory/bv/bitblast_mode.h \ - theory/bv/bitblast_mode.cpp \ theory/bv/bitblast_utils.h \ theory/bv/bvintropow2.h \ theory/bv/bvintropow2.cpp \ @@ -241,7 +232,6 @@ libcvc4_la_SOURCES = \ theory/datatypes/datatypes_sygus.cpp \ theory/sets/expr_patterns.h \ theory/sets/normal_form.h \ - theory/sets/options_handlers.h \ theory/sets/scrutinize.h \ theory/sets/term_info.h \ theory/sets/theory_sets.cpp \ @@ -289,8 +279,6 @@ libcvc4_la_SOURCES = \ theory/quantifiers/inst_match.cpp \ theory/quantifiers/model_engine.h \ theory/quantifiers/model_engine.cpp \ - theory/quantifiers/modes.cpp \ - theory/quantifiers/modes.h \ theory/quantifiers/term_database.h \ theory/quantifiers/term_database.cpp \ theory/quantifiers/first_order_model.h \ @@ -345,7 +333,6 @@ libcvc4_la_SOURCES = \ theory/quantifiers/quant_equality_engine.cpp \ theory/quantifiers/ceg_instantiator.h \ theory/quantifiers/ceg_instantiator.cpp \ - theory/quantifiers/options_handlers.h \ theory/arith/theory_arith_type_rules.h \ theory/arith/type_enumerator.h \ theory/arith/arithvar.h \ @@ -404,17 +391,10 @@ libcvc4_la_SOURCES = \ theory/arith/theory_arith_private.cpp \ theory/arith/dio_solver.h \ theory/arith/dio_solver.cpp \ - theory/arith/arith_heuristic_pivot_rule.h \ - theory/arith/arith_heuristic_pivot_rule.cpp \ - theory/arith/arith_unate_lemma_mode.h \ - theory/arith/arith_unate_lemma_mode.cpp \ - theory/arith/arith_propagation_mode.h \ - theory/arith/arith_propagation_mode.cpp \ theory/arith/pseudoboolean_proc.h \ theory/arith/pseudoboolean_proc.cpp \ theory/arith/cut_log.h \ theory/arith/cut_log.cpp \ - theory/arith/options_handlers.h \ theory/booleans/type_enumerator.h \ theory/booleans/theory_bool.h \ theory/booleans/theory_bool.cpp \ @@ -423,9 +403,6 @@ libcvc4_la_SOURCES = \ theory/booleans/theory_bool_rewriter.cpp \ theory/booleans/circuit_propagator.h \ theory/booleans/circuit_propagator.cpp \ - theory/booleans/boolean_term_conversion_mode.h \ - theory/booleans/boolean_term_conversion_mode.cpp \ - theory/booleans/options_handlers.h \ theory/fp/theory_fp.h \ theory/fp/theory_fp.cpp \ theory/fp/theory_fp_rewriter.h \ @@ -433,15 +410,16 @@ libcvc4_la_SOURCES = \ theory/fp/theory_fp_type_rules.h nodist_libcvc4_la_SOURCES = \ - smt/smt_options.cpp \ theory/rewriter_tables.h \ theory/theory_traits.h \ theory/type_enumerator.cpp libcvc4_la_LIBADD = \ + @builddir@/base/libbase.la \ @builddir@/options/liboptions.la \ @builddir@/util/libutil.la \ @builddir@/expr/libexpr.la \ + @builddir@/smt_util/libsmtutil.la \ @builddir@/prop/minisat/libminisat.la \ @builddir@/prop/bvminisat/libbvminisat.la if CVC4_PROOF @@ -484,42 +462,40 @@ CLEANFILES = \ $(top_builddir)/src/.subdirs EXTRA_DIST = \ + Makefile.theories \ + cvc4.i \ + include/cvc4.h \ + include/cvc4_private.h \ include/cvc4_private_library.h \ + include/cvc4_public.h \ include/cvc4parser_private.h \ include/cvc4parser_public.h \ - include/cvc4_private.h \ - include/cvc4_public.h \ - include/cvc4.h \ - cvc4.i \ mksubdirs \ - Makefile.theories \ - smt/smt_options_template.cpp \ - smt/modal_exception.i \ smt/logic_exception.i \ smt/smt_engine.i \ - theory/logic_info.i \ - theory/rewriter_tables_template.h \ - theory/theory_traits_template.h \ - theory/type_enumerator_template.cpp \ - theory/mktheorytraits \ - theory/mkrewriter \ - theory/uf/kinds \ - theory/bv/kinds \ - theory/idl/kinds \ - theory/builtin/kinds \ - theory/datatypes/kinds \ - theory/sets/kinds \ - theory/strings/kinds \ - theory/arrays/kinds \ - theory/quantifiers/kinds \ + proof/unsat_core.i \ theory/arith/kinds \ + theory/arrays/kinds \ theory/booleans/kinds \ - theory/example/ecdata.h \ + theory/builtin/kinds \ + theory/bv/kinds \ + theory/datatypes/kinds \ theory/example/ecdata.cpp \ - theory/example/theory_uf_tim.h \ + theory/example/ecdata.h \ theory/example/theory_uf_tim.cpp \ + theory/example/theory_uf_tim.h \ theory/fp/kinds \ - theory/fp/options_handlers.h + theory/idl/kinds \ + theory/logic_info.i \ + theory/mkrewriter \ + theory/mktheorytraits \ + theory/quantifiers/kinds \ + theory/rewriter_tables_template.h \ + theory/sets/kinds \ + theory/strings/kinds \ + theory/theory_traits_template.h \ + theory/type_enumerator_template.cpp \ + theory/uf/kinds svn_versioninfo.cpp: svninfo $(AM_V_GEN)( \ @@ -581,7 +557,7 @@ install-data-local: (echo include/cvc4.h; \ echo include/cvc4_public.h; \ echo include/cvc4parser_public.h; \ - echo util/tls.h; \ + echo base/tls.h; \ echo util/integer.h; \ echo util/rational.h; \ find * -name '*.h' | \ @@ -614,7 +590,7 @@ uninstall-local: -(echo include/cvc4.h; \ echo include/cvc4_public.h; \ echo include/cvc4parser_public.h; \ - echo util/tls.h; \ + echo base/tls.h; \ echo util/integer.h; \ echo util/rational.h; \ find * -name '*.h' | \ diff --git a/src/base/Makefile.am b/src/base/Makefile.am new file mode 100644 index 000000000..b03b61aee --- /dev/null +++ b/src/base/Makefile.am @@ -0,0 +1,40 @@ +AM_CPPFLAGS = \ + -D__BUILDING_CVC4LIB \ + -I@builddir@/.. -I@srcdir@/../include -I@srcdir@/.. +AM_CXXFLAGS = -Wall -Wno-unknown-pragmas $(FLAG_VISIBILITY_HIDDEN) + +noinst_LTLIBRARIES = libbase.la + +# Do not list built sources (like tls.h) here! +# Rather, list them under BUILT_SOURCES, and their .in versions under +# EXTRA_DIST. Otherwise, they're packaged up in the tarball, which is +# no good---they belong in the configured builds/ directory. If they +# end up in the source directory, they build the cvc4 that was +# configured at the time of the "make dist", which (1) may not be the +# configuration that the user wants, and (2) might cause link errors. +libbase_la_SOURCES = \ + Makefile.am \ + Makefile.in \ + cvc4_assert.cpp \ + cvc4_assert.h \ + exception.cpp \ + exception.h \ + lemma_input_channel_forward.h \ + lemma_output_channel_forward.h \ + modal_exception.h \ + output.cpp \ + output.h + + + +BUILT_SOURCES = \ + tls.h + +EXTRA_DIST = \ + exception.i \ + modal_exception.i \ + tls.h.in + +DISTCLEANFILES = \ + tls.h.tmp \ + tls.h diff --git a/src/util/cvc4_assert.cpp b/src/base/cvc4_assert.cpp index 3db285182..6e51845dd 100644 --- a/src/util/cvc4_assert.cpp +++ b/src/base/cvc4_assert.cpp @@ -18,7 +18,8 @@ #include <cstdarg> #include <cstdio> -#include "util/cvc4_assert.h" +#include "base/cvc4_assert.h" +#include "base/output.h" using namespace std; diff --git a/src/util/cvc4_assert.h b/src/base/cvc4_assert.h index cc854278b..6dca5c81d 100644 --- a/src/util/cvc4_assert.h +++ b/src/base/cvc4_assert.h @@ -25,12 +25,14 @@ #include <cstdlib> #include <cstdarg> -#include "util/exception.h" -#include "util/tls.h" +#include "base/exception.h" +#include "base/tls.h" + // output.h not strictly needed for this header, but it _is_ needed to // actually _use_ anything in this header, so let's include it. -#include "util/output.h" +// Tim : Disabling this and moving it into cvc4_assert.cpp +//#include "util/output.h" namespace CVC4 { diff --git a/src/util/exception.cpp b/src/base/exception.cpp index ab510c27d..d8eee50bc 100644 --- a/src/util/exception.cpp +++ b/src/base/exception.cpp @@ -14,16 +14,19 @@ ** CVC4's exception base class and some associated utilities. **/ -#include "util/exception.h" +#include "base/exception.h" #include <string> #include <cstdio> #include <cstdlib> #include <cstdarg> -#include "util/cvc4_assert.h" + +#include "base/cvc4_assert.h" using namespace std; -using namespace CVC4; +#warning "TODO: Remove the second definition of CheckArgument and DebugCheckArgument." + +namespace CVC4 { void IllegalArgumentException::construct(const char* header, const char* extra, const char* function, const char* fmt, va_list args) { @@ -113,3 +116,5 @@ void IllegalArgumentException::construct(const char* header, const char* extra, delete [] buf; #endif /* CVC4_DEBUG */ } + +} /* namespace CVC4 */ diff --git a/src/util/exception.h b/src/base/exception.h index 937729f0c..78bb160cc 100644 --- a/src/util/exception.h +++ b/src/base/exception.h @@ -130,7 +130,7 @@ inline std::ostream& operator<<(std::ostream& os, const Exception& e) throw() { }/* CVC4 namespace */ #if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && !defined(__BUILDING_STATISTICS_FOR_EXPORT) -# include "util/cvc4_assert.h" +# include "base/cvc4_assert.h" #endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST) && !__BUILDING_STATISTICS_FOR_EXPORT */ namespace CVC4 { diff --git a/src/util/exception.i b/src/base/exception.i index 422f34b10..083670567 100644 --- a/src/util/exception.i +++ b/src/base/exception.i @@ -1,5 +1,5 @@ %{ -#include "util/exception.h" +#include "base/exception.h" %} %ignore CVC4::operator<<(std::ostream&, const Exception&) throw(); @@ -8,4 +8,4 @@ %rename(CVC4IllegalArgumentException) CVC4::IllegalArgumentException; -%include "util/exception.h" +%include "base/exception.h" diff --git a/src/base/lemma_input_channel_forward.h b/src/base/lemma_input_channel_forward.h new file mode 100644 index 000000000..f74e24b4a --- /dev/null +++ b/src/base/lemma_input_channel_forward.h @@ -0,0 +1,30 @@ +/********************* */ +/*! \file lemma_input_channel_forward.h + ** \verbatim + ** Original author: Tim King + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Forward declaration of LemmaInputChannel. + ** + ** This forward declaration of LemmaInputChannel is needed for the option + ** lemmaInputChannel (defined in smt_options) can be a LemmaInputChannel* + ** without including expr.h. + **/ + +#include "cvc4_public.h" + +#ifndef __CVC4__LEMMA_INPUT_CHANNEL_FORWARD_H +#define __CVC4__LEMMA_INPUT_CHANNEL_FORWARD_H + +namespace CVC4 { + +class CVC4_PUBLIC LemmaInputChannel; + +}/* CVC4 namespace */ + +#endif /* __CVC4__LEMMA_INPUT_CHANNEL_FORWARD_H */ diff --git a/src/base/lemma_output_channel_forward.h b/src/base/lemma_output_channel_forward.h new file mode 100644 index 000000000..c53bcc36f --- /dev/null +++ b/src/base/lemma_output_channel_forward.h @@ -0,0 +1,35 @@ +/********************* */ +/*! \file lemma_output_channel_forward.h + ** \verbatim + ** Original author: Tim King + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Forward declaration of the LemmaOutputChannel + ** + ** This forward declaration of LemmaOutputChannel is needed for the option + ** lemmaOutputChannel (defined in smt_options) can be a LemmaInputChannel* + ** without including expr.h. + **/ + +#include "cvc4_public.h" + +#ifndef __CVC4__LEMMA_OUTPUT_CHANNEL_FORWARD_H +#define __CVC4__LEMMA_OUTPUT_CHANNEL_FORWARD_H + +namespace CVC4 { + +/** + * This interface describes a mechanism for the propositional and theory + * engines to communicate with the "outside world" about new lemmas being + * discovered. + */ +class CVC4_PUBLIC LemmaOutputChannel; + +}/* CVC4 namespace */ + +#endif /* __CVC4__LEMMA_OUTPUT_CHANNEL_FORWARD_H */ diff --git a/src/smt/modal_exception.h b/src/base/modal_exception.h index 11e78ab19..44f133372 100644 --- a/src/smt/modal_exception.h +++ b/src/base/modal_exception.h @@ -22,7 +22,7 @@ #ifndef __CVC4__SMT__MODAL_EXCEPTION_H #define __CVC4__SMT__MODAL_EXCEPTION_H -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { diff --git a/src/base/modal_exception.i b/src/base/modal_exception.i new file mode 100644 index 000000000..7df4c8f83 --- /dev/null +++ b/src/base/modal_exception.i @@ -0,0 +1,7 @@ +%{ +#include "base/modal_exception.h" +%} + +%ignore CVC4::ModalException::ModalException(const char*); + +%include "base/modal_exception.h" diff --git a/src/util/output.cpp b/src/base/output.cpp index 462043805..be0f10fda 100644 --- a/src/util/output.cpp +++ b/src/base/output.cpp @@ -14,7 +14,7 @@ ** Output utility classes and functions. **/ -#include "util/output.h" +#include "base/output.h" #include <iostream> diff --git a/src/util/output.h b/src/base/output.h index 0974591db..0974591db 100644 --- a/src/util/output.h +++ b/src/base/output.h diff --git a/src/util/tls.h.in b/src/base/tls.h.in index 88969e250..88969e250 100644 --- a/src/util/tls.h.in +++ b/src/base/tls.h.in diff --git a/src/bindings/swig.h b/src/bindings/swig.h index 790873ef6..9bece4ecd 100644 --- a/src/bindings/swig.h +++ b/src/bindings/swig.h @@ -26,8 +26,8 @@ #endif /* SWIG_VERSION */ %import "cvc4_public.h" -#warning Working around a SWIG segfault in C++ template parsing. -//%import "util/tls.h" +#warning "Working around a SWIG segfault in C++ template parsing." +//%import "base/tls.h" #define CVC4_THREADLOCAL(__type...) __type #define CVC4_THREADLOCAL_PUBLIC(__type...) CVC4_PUBLIC __type #define CVC4_THREADLOCAL_TYPE(__type...) __type diff --git a/src/compat/cvc3_compat.cpp b/src/compat/cvc3_compat.cpp index 08146760f..35211a49a 100644 --- a/src/compat/cvc3_compat.cpp +++ b/src/compat/cvc3_compat.cpp @@ -16,30 +16,29 @@ #include "compat/cvc3_compat.h" -#include "expr/kind.h" -#include "expr/command.h" +#include <algorithm> +#include <cassert> +#include <iostream> +#include <iterator> +#include <sstream> +#include <string> -#include "util/rational.h" -#include "util/integer.h" +#include "base/output.h" +#include "expr/kind.h" +#include "expr/predicate.h" +#include "expr/sexpr.h" +#include "options/expr_options.h" +#include "options/parser_options.h" +#include "options/smt_options.h" +#include "parser/parser.h" +#include "parser/parser_builder.h" +#include "smt_util/command.h" #include "util/bitvector.h" #include "util/hash.h" +#include "util/integer.h" +#include "util/rational.h" #include "util/subrange_bound.h" -#include "util/predicate.h" -#include "util/output.h" - -#include "parser/parser.h" -#include "parser/parser_builder.h" - -#include "parser/options.h" -#include "smt/options.h" -#include "expr/options.h" -#include <iostream> -#include <string> -#include <sstream> -#include <algorithm> -#include <iterator> -#include <cassert> using namespace std; @@ -2498,8 +2497,8 @@ void ValidityChecker::loadFile(const std::string& fileName, CVC4::Options opts = d_em->getOptions(); stringstream langss; langss << lang; - d_smt->setOption("input-language", langss.str()); - d_smt->setOption("interactive-mode", string(interactive ? "true" : "false")); + d_smt->setOption("input-language", CVC4::SExpr(langss.str())); + d_smt->setOption("interactive-mode", CVC4::SExpr(interactive ? true : false)); CVC4::parser::ParserBuilder parserBuilder(d_em, fileName, opts); CVC4::parser::Parser* p = parserBuilder.build(); p->useDeclarationsFrom(d_parserContext); @@ -2513,8 +2512,8 @@ void ValidityChecker::loadFile(std::istream& is, CVC4::Options opts = d_em->getOptions(); stringstream langss; langss << lang; - d_smt->setOption("input-language", langss.str()); - d_smt->setOption("interactive-mode", string(interactive ? "true" : "false")); + d_smt->setOption("input-language", CVC4::SExpr(langss.str())); + d_smt->setOption("interactive-mode", CVC4::SExpr(interactive ? true : false)); CVC4::parser::ParserBuilder parserBuilder(d_em, "[stream]", opts); CVC4::parser::Parser* p = parserBuilder.withStreamInput(is).build(); d_parserContext = p; diff --git a/src/compat/cvc3_compat.h b/src/compat/cvc3_compat.h index 0fa4a7ce5..5fefa6871 100644 --- a/src/compat/cvc3_compat.h +++ b/src/compat/cvc3_compat.h @@ -48,23 +48,19 @@ #define _cvc3__include__queryresult_h_ #define _cvc3__include__formula_value_h_ -#include "expr/expr_manager.h" +#include <stdlib.h> +#include <map> +#include <utility> + +#include "base/exception.h" #include "expr/expr.h" +#include "expr/expr_manager.h" #include "expr/type.h" - +#include "parser/parser.h" #include "smt/smt_engine.h" - -#include "util/rational.h" -#include "util/integer.h" - -#include "util/exception.h" #include "util/hash.h" - -#include "parser/parser.h" - -#include <stdlib.h> -#include <map> -#include <utility> +#include "util/integer.h" +#include "util/rational.h" //class CInterface; diff --git a/src/util/backtrackable.h b/src/context/backtrackable.h index 5492dd8b5..5492dd8b5 100644 --- a/src/util/backtrackable.h +++ b/src/context/backtrackable.h diff --git a/src/context/cdchunk_list.h b/src/context/cdchunk_list.h index 8c2e4066e..62a87ffcc 100644 --- a/src/context/cdchunk_list.h +++ b/src/context/cdchunk_list.h @@ -24,9 +24,10 @@ #include <iterator> #include <memory> +#include "base/cvc4_assert.h" #include "context/context.h" #include "context/context_mm.h" -#include "util/cvc4_assert.h" + namespace CVC4 { namespace context { diff --git a/src/context/cdhashmap.h b/src/context/cdhashmap.h index 338c46b0d..51fd3b411 100644 --- a/src/context/cdhashmap.h +++ b/src/context/cdhashmap.h @@ -95,12 +95,12 @@ #ifndef __CVC4__CONTEXT__CDHASHMAP_H #define __CVC4__CONTEXT__CDHASHMAP_H -#include <vector> -#include <iterator> #include <ext/hash_map> +#include <iterator> +#include <vector> +#include "base/cvc4_assert.h" #include "context/context.h" -#include "util/cvc4_assert.h" #include "context/cdhashmap_forward.h" namespace CVC4 { diff --git a/src/context/cdhashset.h b/src/context/cdhashset.h index 76bab5a94..533a09a0a 100644 --- a/src/context/cdhashset.h +++ b/src/context/cdhashset.h @@ -19,9 +19,10 @@ #ifndef __CVC4__CONTEXT__CDHASHSET_H #define __CVC4__CONTEXT__CDHASHSET_H +#include "base/cvc4_assert.h" #include "context/context.h" #include "context/cdinsert_hashmap.h" -#include "util/cvc4_assert.h" + namespace CVC4 { namespace context { diff --git a/src/context/cdinsert_hashmap.h b/src/context/cdinsert_hashmap.h index 1c8f94143..b65784ddf 100644 --- a/src/context/cdinsert_hashmap.h +++ b/src/context/cdinsert_hashmap.h @@ -33,16 +33,17 @@ #include "cvc4_private.h" -#include "context/context.h" -#include "context/cdinsert_hashmap_forward.h" -#include <utility> -#include <ext/hash_map> +#include <boost/static_assert.hpp> #include <deque> -#include "util/cvc4_assert.h" -#include "util/output.h" +#include <ext/hash_map> +#include <utility> +#include "base/cvc4_assert.h" +#include "base/output.h" +#include "context/context.h" +#include "context/cdinsert_hashmap_forward.h" #include "expr/node.h" -#include <boost/static_assert.hpp> + #pragma once diff --git a/src/context/cdlist.h b/src/context/cdlist.h index 7c673a4be..dbc00bd69 100644 --- a/src/context/cdlist.h +++ b/src/context/cdlist.h @@ -20,17 +20,16 @@ #ifndef __CVC4__CONTEXT__CDLIST_H #define __CVC4__CONTEXT__CDLIST_H +#include <boost/static_assert.hpp> #include <iterator> #include <memory> #include <string> #include <sstream> +#include "base/cvc4_assert.h" #include "context/context.h" #include "context/context_mm.h" #include "context/cdlist_forward.h" -#include "util/cvc4_assert.h" - -#include <boost/static_assert.hpp> namespace CVC4 { namespace context { diff --git a/src/context/cdo.h b/src/context/cdo.h index 5fa0a4d8b..486626ae5 100644 --- a/src/context/cdo.h +++ b/src/context/cdo.h @@ -19,8 +19,9 @@ #ifndef __CVC4__CONTEXT__CDO_H #define __CVC4__CONTEXT__CDO_H +#include "base/cvc4_assert.h" #include "context/context.h" -#include "util/cvc4_assert.h" + namespace CVC4 { namespace context { diff --git a/src/context/cdtrail_hashmap.h b/src/context/cdtrail_hashmap.h index f4220ef43..befd396a9 100644 --- a/src/context/cdtrail_hashmap.h +++ b/src/context/cdtrail_hashmap.h @@ -44,17 +44,16 @@ #pragma once -#include "context/context.h" -#include "context/cdtrail_hashmap_forward.h" -#include <utility> +#include <boost/static_assert.hpp> #include <ext/hash_map> #include <deque> -#include "util/cvc4_assert.h" -#include "util/output.h" +#include <utility> +#include "base/cvc4_assert.h" +#include "base/output.h" +#include "context/context.h" +#include "context/cdtrail_hashmap_forward.h" #include "expr/node.h" -#include <boost/static_assert.hpp> - namespace CVC4 { namespace context { diff --git a/src/context/cdvector.h b/src/context/cdvector.h index 30699670f..fe8f77c6d 100644 --- a/src/context/cdvector.h +++ b/src/context/cdvector.h @@ -20,11 +20,11 @@ #ifndef __CVC4__CONTEXT__CDVECTOR_H #define __CVC4__CONTEXT__CDVECTOR_H -#include "context/context.h" -#include "context/cdlist.h" -#include "util/cvc4_assert.h" #include <vector> +#include "base/cvc4_assert.h" +#include "context/context.h" +#include "context/cdlist.h" namespace CVC4 { namespace context { diff --git a/src/context/context.cpp b/src/context/context.cpp index c427e89c9..99a98e63f 100644 --- a/src/context/context.cpp +++ b/src/context/context.cpp @@ -18,8 +18,9 @@ #include <iostream> #include <vector> +#include "base/cvc4_assert.h" #include "context/context.h" -#include "util/cvc4_assert.h" + namespace CVC4 { namespace context { diff --git a/src/context/context.h b/src/context/context.h index 9c631b202..b88f36786 100644 --- a/src/context/context.h +++ b/src/context/context.h @@ -26,8 +26,10 @@ #include <new> #include <typeinfo> +#include "base/cvc4_assert.h" +#include "base/output.h" #include "context/context_mm.h" -#include "util/cvc4_assert.h" + namespace CVC4 { namespace context { diff --git a/src/context/context_mm.cpp b/src/context/context_mm.cpp index e7b234a95..f30413650 100644 --- a/src/context/context_mm.cpp +++ b/src/context/context_mm.cpp @@ -19,9 +19,10 @@ #include <vector> #include <deque> #include <new> + +#include "base/cvc4_assert.h" +#include "base/output.h" #include "context/context_mm.h" -#include "util/cvc4_assert.h" -#include "util/output.h" namespace CVC4 { namespace context { diff --git a/src/cvc4.i b/src/cvc4.i index d845c1a27..ad042d398 100644 --- a/src/cvc4.i +++ b/src/cvc4.i @@ -48,12 +48,17 @@ using namespace CVC4; #include <typeinfo> #include <cassert> -#include "util/sexpr.h" -#include "util/exception.h" -#include "expr/type.h" +#include "base/exception.h" +#include "base/modal_exception.h" +#include "expr/datatype.h" #include "expr/expr.h" -#include "util/datatype.h" -#include "expr/command.h" +#include "expr/sexpr.h" +#include "expr/type.h" +#include "options/option_exception.h" +#include "smt_util/command.h" +#include "util/integer.h" +#include "util/bitvector.h" +#include "util/unsafe_interrupt_exception.h" #ifdef SWIGJAVA #include "bindings/java_stream_adapters.h" @@ -143,17 +148,21 @@ std::set<JavaInputStreamAdapter*> CVC4::JavaInputStreamAdapter::s_adapters; assert(status == 0); %} -%typemap(throws) ModalException = Exception; -%typemap(throws) LogicException = Exception; -%typemap(throws) OptionException = Exception; -%typemap(throws) IllegalArgumentException = Exception; -%typemap(throws) AssertionException = Exception; +%typemap(throws) CVC4::ModalException = CVC4::Exception; +%typemap(throws) CVC4::LogicException = CVC4::Exception; +%typemap(throws) CVC4::OptionException = CVC4::Exception; +%typemap(throws) CVC4::IllegalArgumentException = CVC4::Exception; +%typemap(throws) CVC4::AssertionException = CVC4::Exception; %typemap(throws) CVC4::TypeCheckingException = CVC4::Exception; %typemap(throws) CVC4::ScopeException = CVC4::Exception; %typemap(throws) CVC4::IllegalArgumentException = CVC4::Exception; +%typemap(throws) IllegalArgumentException = Exception; %typemap(throws) CVC4::AssertionException = CVC4::Exception; + +// TIM: Really unclear why both of these are required %typemap(throws) CVC4::UnsafeInterruptException = CVC4::Exception; +%typemap(throws) UnsafeInterruptException = CVC4::Exception; %typemap(throws) CVC4::parser::InputStreamException = CVC4::Exception; %typemap(throws) CVC4::parser::ParserException = CVC4::Exception; @@ -293,53 +302,60 @@ std::set<JavaInputStreamAdapter*> CVC4::JavaInputStreamAdapter::s_adapters; #endif /* SWIGJAVA */ -%include "util/exception.i" +// TIM: +// At the moment, the header includes seem to need to follow a special order. +// I don't know why. I am following the build order +%include "base/exception.i" %include "util/unsafe_interrupt_exception.i" %include "util/integer.i" %include "util/rational.i" -//%include "util/floatingpoint.i" -%include "util/language.i" -%include "util/cardinality.i" -%include "util/bool.i" -%include "util/sexpr.i" -%include "options/options.i" -%include "util/statistics.i" -%include "util/result.i" +%include "options/language.i" %include "util/configuration.i" +%include "util/bool.i" +%include "util/cardinality.i" +%include "base/modal_exception.i" +%include "expr/sexpr.i" + %include "util/bitvector.i" -%include "util/subrange_bound.i" -%include "util/array.i" -%include "util/array_store_all.i" -%include "util/predicate.i" -%include "util/hash.i" -%include "expr/type.i" -%include "util/ascription_type.i" -%include "util/emptyset.i" -%include "util/datatype.i" -%include "util/tuple.i" -%include "util/record.i" -%include "util/regexp.i" -%include "util/uninterpreted_constant.i" + +%include "util/hash.i" %include "util/proof.i" -%include "util/resource_manager.i" -%include "util/unsat_core.i" +%include "util/regexp.i" +%include "util/subrange_bound.i" +%include "util/tuple.i" +//%include "util/floatingpoint.i" +%include "expr/uninterpreted_constant.i" +%include "expr/statistics.i" +%include "expr/array_store_all.i" +%include "expr/ascription_type.i" +%include "expr/emptyset.i" +%include "expr/datatype.i" +%include "expr/predicate.i" +%include "expr/record.i" +%include "expr/resource_manager.i" +%include "expr/result.i" +%include "proof/unsat_core.i" + +// TIM: +// Have these before the rest of expr/. +// Again, no clue why. +%include "expr/array.i" %include "expr/kind.i" +%include "expr/type.i" + +// TIM: +// The remainder of the includes: %include "expr/expr.i" -%include "expr/command.i" -%include "expr/symbol_table.i" %include "expr/expr_manager.i" %include "expr/expr_stream.i" +%include "expr/symbol_table.i" %include "expr/variable_type_map.i" - -%include "theory/logic_info.i" - -%include "smt/smt_engine.i" -%include "smt/modal_exception.i" -%include "smt/logic_exception.i" - -%include "options/options.i" %include "options/option_exception.i" - +%include "options/options.i" %include "parser/cvc4parser.i" +%include "smt/logic_exception.i" +%include "smt/smt_engine.i" +%include "smt_util/command.i" +%include "theory/logic_info.i" diff --git a/src/theory/decision_attributes.h b/src/decision/decision_attributes.h index 1ea1bb21d..03229ac84 100644 --- a/src/theory/decision_attributes.h +++ b/src/decision/decision_attributes.h @@ -16,23 +16,21 @@ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__DECISION_ATTRIBUTES -#define __CVC4__THEORY__DECISION_ATTRIBUTES +#ifndef __CVC4__DECISION__DECISION_ATTRIBUTES_H +#define __CVC4__DECISION__DECISION_ATTRIBUTES_H +#include "options/decision_weight.h" #include "expr/attribute.h" namespace CVC4 { namespace decision { -typedef uint64_t DecisionWeight; -} -namespace theory { namespace attr { struct DecisionWeightTag {}; -}/* CVC4::theory::attr namespace */ +}/* CVC4::decision::attr namespace */ -typedef expr::Attribute<attr::DecisionWeightTag, decision::DecisionWeight> DecisionWeightAttr; +typedef expr::Attribute<attr::DecisionWeightTag, DecisionWeight> DecisionWeightAttr; -}/* CVC4::theory namespace */ +}/* CVC4::decision namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__DECISION_ATTRIBUTES */ +#endif /* __CVC4__DECISION__DECISION_ATTRIBUTES_H */ diff --git a/src/decision/decision_engine.cpp b/src/decision/decision_engine.cpp index d7d463d79..12400a3b1 100644 --- a/src/decision/decision_engine.cpp +++ b/src/decision/decision_engine.cpp @@ -13,15 +13,14 @@ ** ** Decision engine **/ - #include "decision/decision_engine.h" -#include "decision/justification_heuristic.h" +#include "decision/decision_attributes.h" +#include "decision/justification_heuristic.h" #include "expr/node.h" -#include "decision/options.h" -#include "decision/decision_mode.h" - -#include "smt/options.h" +#include "options/decision_mode.h" +#include "options/decision_options.h" +#include "options/smt_options.h" using namespace std; diff --git a/src/decision/decision_engine.h b/src/decision/decision_engine.h index ffcf2db63..7f1b7fbe2 100644 --- a/src/decision/decision_engine.h +++ b/src/decision/decision_engine.h @@ -21,16 +21,14 @@ #include <vector> +#include "base/output.h" #include "decision/decision_strategy.h" - #include "expr/node.h" #include "prop/cnf_stream.h" #include "prop/prop_engine.h" #include "prop/sat_solver_types.h" -#include "theory/decision_attributes.h" -#include "util/ite_removal.h" -#include "util/output.h" #include "smt/smt_engine_scope.h" +#include "smt_util/ite_removal.h" using namespace std; using namespace CVC4::prop; diff --git a/src/decision/decision_strategy.h b/src/decision/decision_strategy.h index 94db110c2..210628afc 100644 --- a/src/decision/decision_strategy.h +++ b/src/decision/decision_strategy.h @@ -20,7 +20,7 @@ #define __CVC4__DECISION__DECISION_STRATEGY_H #include "prop/sat_solver_types.h" -#include "util/ite_removal.h" +#include "smt_util/ite_removal.h" namespace CVC4 { diff --git a/src/decision/justification_heuristic.cpp b/src/decision/justification_heuristic.cpp index 082f3cdbf..68c7379ce 100644 --- a/src/decision/justification_heuristic.cpp +++ b/src/decision/justification_heuristic.cpp @@ -16,17 +16,16 @@ ** ** It needs access to the simplified but non-clausal formula. **/ - #include "justification_heuristic.h" -#include "expr/node_manager.h" #include "expr/kind.h" +#include "expr/node_manager.h" +#include "options/decision_options.h" #include "theory/rewriter.h" -#include "decision/options.h" -#include "util/ite_removal.h" +#include "smt_util/ite_removal.h" -using namespace CVC4; +namespace CVC4 { JustificationHeuristic::JustificationHeuristic(CVC4::DecisionEngine* de, context::UserContext *uc, @@ -297,7 +296,7 @@ DecisionWeight JustificationHeuristic::getWeightPolarized(TNode n, bool polarity } DecisionWeight JustificationHeuristic::getWeight(TNode n) { - if(!n.hasAttribute(theory::DecisionWeightAttr()) ) { + if(!n.hasAttribute(DecisionWeightAttr()) ) { DecisionWeightInternal combiningFn = options::decisionWeightInternal(); @@ -305,7 +304,7 @@ DecisionWeight JustificationHeuristic::getWeight(TNode n) { if(combiningFn == DECISION_WEIGHT_INTERNAL_OFF || n.getNumChildren() == 0) { if(options::decisionRandomWeight() != 0) { - n.setAttribute(theory::DecisionWeightAttr(), rand() % options::decisionRandomWeight()); + n.setAttribute(DecisionWeightAttr(), rand() % options::decisionRandomWeight()); } } else if(combiningFn == DECISION_WEIGHT_INTERNAL_MAX) { @@ -313,21 +312,21 @@ DecisionWeight JustificationHeuristic::getWeight(TNode n) { DecisionWeight dW = 0; for(TNode::iterator i=n.begin(); i != n.end(); ++i) dW = max(dW, getWeight(*i)); - n.setAttribute(theory::DecisionWeightAttr(), dW); + n.setAttribute(DecisionWeightAttr(), dW); } else if(combiningFn == DECISION_WEIGHT_INTERNAL_SUM || combiningFn == DECISION_WEIGHT_INTERNAL_USR1) { DecisionWeight dW = 0; for(TNode::iterator i=n.begin(); i != n.end(); ++i) dW = max(dW, getWeight(*i)); - n.setAttribute(theory::DecisionWeightAttr(), dW); + n.setAttribute(DecisionWeightAttr(), dW); } else { Unreachable(); } } - return n.getAttribute(theory::DecisionWeightAttr()); + return n.getAttribute(DecisionWeightAttr()); } typedef vector<TNode> ChildList; @@ -711,3 +710,5 @@ JustificationHeuristic::SearchResult JustificationHeuristic::handleEmbeddedITEs( } return noSplitter ? NO_SPLITTER : DONT_KNOW; } + +} /* namespace CVC4 */ diff --git a/src/decision/justification_heuristic.h b/src/decision/justification_heuristic.h index e1ed431d1..5b0deca1b 100644 --- a/src/decision/justification_heuristic.h +++ b/src/decision/justification_heuristic.h @@ -23,17 +23,16 @@ #ifndef __CVC4__DECISION__JUSTIFICATION_HEURISTIC #define __CVC4__DECISION__JUSTIFICATION_HEURISTIC -#include "decision_engine.h" -#include "decision_strategy.h" - +#include "context/cdhashmap.h" #include "context/cdhashset.h" #include "context/cdlist.h" -#include "context/cdhashmap.h" +#include "decision/decision_attributes.h" +#include "decision/decision_engine.h" +#include "decision/decision_strategy.h" #include "expr/node.h" #include "prop/sat_solver_types.h" namespace CVC4 { - namespace decision { class JustificationHeuristic : public ITEDecisionStrategy { diff --git a/src/decision/options_handlers.h b/src/decision/options_handlers.h deleted file mode 100644 index 723fb243c..000000000 --- a/src/decision/options_handlers.h +++ /dev/null @@ -1,76 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: Kshitij Bansal - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Custom handlers and predicates for DecisionEngine options - ** - ** Custom handlers and predicates for DecisionEngine options. - **/ - -#include "cvc4_private.h" - -#ifndef __CVC4__DECISION__OPTIONS_HANDLERS_H -#define __CVC4__DECISION__OPTIONS_HANDLERS_H - -#include "decision/decision_mode.h" -#include "main/options.h" - -namespace CVC4 { -namespace decision { - -static const std::string 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\ -"; - -inline DecisionMode stringToDecisionMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - options::decisionStopOnly.set(false); - - if(optarg == "internal") { - return DECISION_STRATEGY_INTERNAL; - } else if(optarg == "justification") { - return DECISION_STRATEGY_JUSTIFICATION; - } else if(optarg == "justification-stoponly") { - options::decisionStopOnly.set(true); - return DECISION_STRATEGY_JUSTIFICATION; - } else if(optarg == "help") { - puts(decisionModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --decision: `") + - optarg + "'. Try --decision help."); - } -} - -inline DecisionWeightInternal stringToDecisionWeightInternal(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "off") - return DECISION_WEIGHT_INTERNAL_OFF; - else if(optarg == "max") - return DECISION_WEIGHT_INTERNAL_MAX; - else if(optarg == "sum") - return DECISION_WEIGHT_INTERNAL_SUM; - else if(optarg == "usr1") - return DECISION_WEIGHT_INTERNAL_USR1; - else - throw OptionException(std::string("--decision-weight-internal must be off, max or sum.")); -} - -}/* CVC4::decision namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__DECISION__OPTIONS_HANDLERS_H */ diff --git a/src/expr/Makefile.am b/src/expr/Makefile.am index c5a032abc..dc6ad5833 100644 --- a/src/expr/Makefile.am +++ b/src/expr/Makefile.am @@ -3,41 +3,75 @@ AM_CPPFLAGS = \ -I@builddir@/.. -I@srcdir@/../include -I@srcdir@/.. AM_CXXFLAGS = -Wall -Wno-unknown-pragmas $(FLAG_VISIBILITY_HIDDEN) +#noinst_LTLIBRARIES = libexpr.la libstatistics.la noinst_LTLIBRARIES = libexpr.la +# libstatistics_la_CPPFLAGS = $(CPPFLAGS) $(AM_CPPFLAGS) -D__BUILDING_STATISTICS_FOR_EXPORT +# libstatistics_la_SOURCES = \ +# statistics_registry.h \ +# statistics_registry.cpp + +# EXTRA_libstatistics_la_DEPENDENCIES = \ +# builts + +# For some reason statistics were in libutil. No idea why though. libexpr_la_SOURCES = \ - node.h \ + statistics.cpp \ + statistics.h \ + statistics_registry.cpp \ + statistics_registry.h \ + array.h \ + array_store_all.cpp \ + array_store_all.h \ + ascription_type.h \ + attribute.h \ + attribute.cpp \ + attribute_internals.h \ + attribute_unique_id.h \ + convenience_node_builders.h \ + chain.h \ + emptyset.cpp \ + emptyset.h \ + expr_manager_scope.h \ + expr_stream.h \ + kind_map.h \ + matcher.h \ node.cpp \ - type_node.h \ - type_node.cpp \ + node.h \ node_builder.h \ - convenience_node_builders.h \ - type.h \ - type.cpp \ - node_value.h \ - node_value.cpp \ - node_manager.h \ node_manager.cpp \ + node_manager.h \ node_manager_attributes.h \ - type_checker.h \ - attribute_unique_id.h \ - attribute.h \ - attribute_internals.h \ - attribute.cpp \ - command.h \ - command.cpp \ - symbol_table.h \ - symbol_table.cpp \ - expr_manager_scope.h \ node_self_iterator.h \ - variable_type_map.h \ - pickle_data.h \ + node_self_iterator.h \ + node_value.cpp \ + node_value.h \ pickle_data.cpp \ - pickler.h \ + pickle_data.h \ pickler.cpp \ - node_self_iterator.h \ - expr_stream.h \ - kind_map.h + pickler.h \ + resource_manager.cpp \ + resource_manager.h \ + sexpr.cpp \ + sexpr.h \ + symbol_table.cpp \ + symbol_table.h \ + type.cpp \ + type.h \ + type_checker.h \ + type_node.cpp \ + type_node.h \ + variable_type_map.h \ + datatype.h \ + datatype.cpp \ + predicate.h \ + predicate.cpp \ + record.cpp \ + record.h \ + result.cpp \ + result.h \ + uninterpreted_constant.cpp \ + uninterpreted_constant.h nodist_libexpr_la_SOURCES = \ kind.h \ @@ -50,6 +84,12 @@ nodist_libexpr_la_SOURCES = \ type_checker.cpp EXTRA_DIST = \ + array.i \ + chain.i \ + array_store_all.i \ + ascription_type.i \ + datatype.i \ + emptyset.i \ kind_template.h \ metakind_template.h \ type_properties_template.h \ @@ -58,18 +98,23 @@ EXTRA_DIST = \ expr_template.h \ expr_template.cpp \ type_checker_template.cpp \ - options_handlers.h \ mkkind \ mkmetakind \ mkexpr \ expr_stream.i \ expr_manager.i \ symbol_table.i \ - command.i \ + statistics.i \ type.i \ kind.i \ expr.i \ - variable_type_map.i + resource_manager.i \ + sexpr.i \ + record.i \ + result.i \ + predicate.i \ + variable_type_map.i \ + uninterpreted_constant.i BUILT_SOURCES = \ kind.h \ diff --git a/src/util/array.h b/src/expr/array.h index ab554171f..ab554171f 100644 --- a/src/util/array.h +++ b/src/expr/array.h diff --git a/src/expr/array.i b/src/expr/array.i new file mode 100644 index 000000000..4acd7bf0c --- /dev/null +++ b/src/expr/array.i @@ -0,0 +1,5 @@ +%{ +#include "expr/array.h" +%} + +%include "expr/array.h" diff --git a/src/util/array_store_all.cpp b/src/expr/array_store_all.cpp index dfd021e75..62c8ec978 100644 --- a/src/util/array_store_all.cpp +++ b/src/expr/array_store_all.cpp @@ -16,7 +16,8 @@ ** the same for all indices). **/ -#include "util/array_store_all.h" +#include "expr/array_store_all.h" + #include <iostream> using namespace std; diff --git a/src/util/array_store_all.h b/src/expr/array_store_all.h index b1d624266..b1d624266 100644 --- a/src/util/array_store_all.h +++ b/src/expr/array_store_all.h diff --git a/src/util/array_store_all.i b/src/expr/array_store_all.i index aee550314..b66e4a178 100644 --- a/src/util/array_store_all.i +++ b/src/expr/array_store_all.i @@ -1,5 +1,5 @@ %{ -#include "util/array_store_all.h" +#include "expr/array_store_all.h" %} %rename(equals) CVC4::ArrayStoreAll::operator==(const ArrayStoreAll&) const; @@ -14,4 +14,4 @@ %ignore CVC4::operator<<(std::ostream&, const ArrayStoreAll&); %include "expr/type.i" -%include "util/array_store_all.h" +%include "expr/array_store_all.h" diff --git a/src/util/ascription_type.h b/src/expr/ascription_type.h index 42906e557..42906e557 100644 --- a/src/util/ascription_type.h +++ b/src/expr/ascription_type.h diff --git a/src/util/ascription_type.i b/src/expr/ascription_type.i index fe8856bcc..57d8f97fe 100644 --- a/src/util/ascription_type.i +++ b/src/expr/ascription_type.i @@ -1,5 +1,5 @@ %{ -#include "util/ascription_type.h" +#include "expr/ascription_type.h" %} %rename(equals) CVC4::AscriptionType::operator==(const AscriptionType&) const; @@ -9,4 +9,4 @@ %ignore CVC4::operator<<(std::ostream&, AscriptionType); -%include "util/ascription_type.h" +%include "expr/ascription_type.h" diff --git a/src/expr/attribute.cpp b/src/expr/attribute.cpp index 63ea770ca..cd5b35384 100644 --- a/src/expr/attribute.cpp +++ b/src/expr/attribute.cpp @@ -13,14 +13,13 @@ ** ** AttributeManager implementation. **/ +#include <utility> +#include "base/output.h" #include "expr/attribute.h" #include "expr/node_value.h" -#include "util/output.h" #include "smt/smt_engine.h" -#include <utility> - using namespace std; namespace CVC4 { diff --git a/src/util/chain.h b/src/expr/chain.h index e052a2ed8..e052a2ed8 100644 --- a/src/util/chain.h +++ b/src/expr/chain.h diff --git a/src/util/chain.i b/src/expr/chain.i index 1c97a527f..8de1665ce 100644 --- a/src/util/chain.i +++ b/src/expr/chain.i @@ -1,5 +1,5 @@ %{ -#include "util/chain.h" +#include "expr/chain.h" %} %rename(equals) CVC4::Chain::operator==(const Chain&) const; @@ -9,4 +9,4 @@ %rename(apply) CVC4::ChainHashFunction::operator()(const CVC4::Chain&) const; -%include "util/chain.h" +%include "expr/chain.h" diff --git a/src/util/datatype.cpp b/src/expr/datatype.cpp index a53759c08..c758fe297 100644 --- a/src/util/datatype.cpp +++ b/src/expr/datatype.cpp @@ -14,19 +14,19 @@ ** A class representing a Datatype definition for the theory of ** inductive datatypes. **/ +#include "expr/datatype.h" #include <string> #include <sstream> -#include "util/datatype.h" -#include "expr/type.h" +#include "base/cvc4_assert.h" +#include "expr/attribute.h" #include "expr/expr_manager.h" #include "expr/expr_manager_scope.h" -#include "expr/node_manager.h" +#include "expr/matcher.h" #include "expr/node.h" -#include "expr/attribute.h" -#include "util/matcher.h" -#include "util/cvc4_assert.h" +#include "expr/node_manager.h" +#include "expr/type.h" using namespace std; diff --git a/src/util/datatype.h b/src/expr/datatype.h index 85668cd55..c1ec475e5 100644 --- a/src/util/datatype.h +++ b/src/expr/datatype.h @@ -31,10 +31,11 @@ namespace CVC4 { class CVC4_PUBLIC Datatype; }/* CVC4 namespace */ +#include "base/exception.h" #include "expr/expr.h" #include "expr/type.h" #include "util/hash.h" -#include "util/exception.h" + namespace CVC4 { diff --git a/src/util/datatype.i b/src/expr/datatype.i index 403fb31bc..a7456df38 100644 --- a/src/util/datatype.i +++ b/src/expr/datatype.i @@ -1,5 +1,5 @@ %{ -#include "util/datatype.h" +#include "expr/datatype.h" #ifdef SWIGJAVA @@ -162,7 +162,7 @@ #endif /* SWIGJAVA */ -%include "util/datatype.h" +%include "expr/datatype.h" #ifdef SWIGJAVA diff --git a/src/util/emptyset.cpp b/src/expr/emptyset.cpp index 7905f11fb..69e34b848 100644 --- a/src/util/emptyset.cpp +++ b/src/expr/emptyset.cpp @@ -15,10 +15,9 @@ ** \todo document this file **/ -#include "util/emptyset.h" -#include <iostream> +#include "expr/emptyset.h" -using namespace std; +#include <iostream> namespace CVC4 { diff --git a/src/util/emptyset.h b/src/expr/emptyset.h index 4b3bb204f..4b3bb204f 100644 --- a/src/util/emptyset.h +++ b/src/expr/emptyset.h diff --git a/src/util/emptyset.i b/src/expr/emptyset.i index ce4f3a4b7..ada3dd583 100644 --- a/src/util/emptyset.i +++ b/src/expr/emptyset.i @@ -1,5 +1,5 @@ %{ -#include "util/emptyset.h" +#include "expr/emptyset.h" %} %rename(equals) CVC4::EmptySet::operator==(const EmptySet&) const; @@ -14,4 +14,4 @@ %ignore CVC4::operator<<(std::ostream& out, const EmptySet& es); -%include "util/emptyset.h" +%include "expr/emptyset.h" diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp index 91387bc41..e7088a395 100644 --- a/src/expr/expr_manager_template.cpp +++ b/src/expr/expr_manager_template.cpp @@ -14,14 +14,15 @@ ** Public-facing expression manager interface, implementation. **/ -#include "expr/node_manager.h" #include "expr/expr_manager.h" -#include "expr/variable_type_map.h" -#include "options/options.h" -#include "util/statistics_registry.h" #include <map> +#include "expr/node_manager.h" +#include "expr/statistics_registry.h" +#include "expr/variable_type_map.h" +#include "options/options.h" + ${includes} // This is a hack, but an important one: if there's an error, the diff --git a/src/expr/expr_manager_template.h b/src/expr/expr_manager_template.h index d7c89ecdc..31983d5a9 100644 --- a/src/expr/expr_manager_template.h +++ b/src/expr/expr_manager_template.h @@ -21,12 +21,11 @@ #include <vector> +#include "expr/expr.h" #include "expr/kind.h" #include "expr/type.h" -#include "expr/expr.h" +#include "expr/statistics.h" #include "util/subrange_bound.h" -#include "util/statistics.h" -#include "util/sexpr.h" ${includes} @@ -34,7 +33,7 @@ ${includes} // compiler directs the user to the template file instead of the // generated one. We don't want the user to modify the generated one, // since it'll get overwritten on a later build. -#line 38 "${template}" +#line 37 "${template}" namespace CVC4 { diff --git a/src/expr/expr_template.cpp b/src/expr/expr_template.cpp index 47042b458..0739e3355 100644 --- a/src/expr/expr_template.cpp +++ b/src/expr/expr_template.cpp @@ -14,11 +14,11 @@ ** Public-facing expression interface, implementation. **/ +#include "base/cvc4_assert.h" #include "expr/expr.h" #include "expr/node.h" #include "expr/expr_manager_scope.h" #include "expr/variable_type_map.h" -#include "util/cvc4_assert.h" #include "expr/node_manager_attributes.h" #include <vector> diff --git a/src/expr/expr_template.h b/src/expr/expr_template.h index ae0fad897..f609d8990 100644 --- a/src/expr/expr_template.h +++ b/src/expr/expr_template.h @@ -26,21 +26,22 @@ ${includes} #ifndef __CVC4__EXPR_H #define __CVC4__EXPR_H -#include <string> +#include <stdint.h> #include <iostream> #include <iterator> -#include <stdint.h> -#include "util/exception.h" -#include "util/language.h" +#include <string> + +#include "base/exception.h" +#include "options/expr_options.h" +#include "options/language.h" #include "util/hash.h" -#include "expr/options.h" // This is a hack, but an important one: if there's an error, the // compiler directs the user to the template file instead of the // generated one. We don't want the user to modify the generated one, // since it'll get overwritten on a later build. -#line 44 "${template}" +#line 45 "${template}" namespace CVC4 { @@ -934,7 +935,7 @@ public: ${getConst_instantiations} -#line 938 "${template}" +#line 939 "${template}" namespace expr { diff --git a/src/expr/kind_template.h b/src/expr/kind_template.h index f93df4132..c2ccb6b5e 100644 --- a/src/expr/kind_template.h +++ b/src/expr/kind_template.h @@ -22,7 +22,7 @@ #include <iostream> #include <sstream> -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { namespace kind { diff --git a/src/util/matcher.h b/src/expr/matcher.h index 107891a54..92b1ce109 100644 --- a/src/util/matcher.h +++ b/src/expr/matcher.h @@ -23,7 +23,8 @@ #include <string> #include <vector> #include <map> -#include "util/cvc4_assert.h" + +#include "base/cvc4_assert.h" #include "expr/node.h" #include "expr/type_node.h" diff --git a/src/expr/metakind_template.h b/src/expr/metakind_template.h index 73f48ba04..539db1c91 100644 --- a/src/expr/metakind_template.h +++ b/src/expr/metakind_template.h @@ -21,8 +21,8 @@ #include <iostream> +#include "base/cvc4_assert.h" #include "expr/kind.h" -#include "util/cvc4_assert.h" namespace CVC4 { diff --git a/src/expr/node.cpp b/src/expr/node.cpp index deceda840..2b5c0a2c8 100644 --- a/src/expr/node.cpp +++ b/src/expr/node.cpp @@ -13,14 +13,15 @@ ** ** Reference-counted encapsulation of a pointer to node information. **/ - #include "expr/node.h" -#include "expr/attribute.h" -#include "util/output.h" #include <iostream> #include <cstring> +#include "base/output.h" +#include "expr/attribute.h" + + using namespace std; namespace CVC4 { diff --git a/src/expr/node.h b/src/expr/node.h index 2a884d35a..384dbcc03 100644 --- a/src/expr/node.h +++ b/src/expr/node.h @@ -30,15 +30,15 @@ #include <functional> #include <stdint.h> +#include "base/cvc4_assert.h" +#include "base/exception.h" +#include "base/output.h" #include "expr/type.h" #include "expr/kind.h" #include "expr/metakind.h" #include "expr/expr.h" -#include "util/cvc4_assert.h" +#include "options/language.h" #include "util/configuration.h" -#include "util/output.h" -#include "util/exception.h" -#include "util/language.h" #include "util/utility.h" #include "util/hash.h" diff --git a/src/expr/node_builder.h b/src/expr/node_builder.h index bea51b576..e1a083a78 100644 --- a/src/expr/node_builder.h +++ b/src/expr/node_builder.h @@ -169,11 +169,12 @@ namespace CVC4 { class NodeManager; }/* CVC4 namespace */ +#include "base/cvc4_assert.h" +#include "base/output.h" #include "expr/kind.h" #include "expr/metakind.h" -#include "util/cvc4_assert.h" #include "expr/node_value.h" -#include "util/output.h" + namespace CVC4 { @@ -751,7 +752,7 @@ public: #include "expr/node.h" #include "expr/node_manager.h" -#include "expr/options.h" +#include "options/expr_options.h" namespace CVC4 { diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp index dad21e90a..1b9bfcd10 100644 --- a/src/expr/node_manager.cpp +++ b/src/expr/node_manager.cpp @@ -15,24 +15,23 @@ ** ** Reviewed by Chris Conway, Apr 5 2010 (bug #65). **/ - #include "expr/node_manager.h" -#include "expr/node_manager_attributes.h" - -#include "expr/attribute.h" -#include "util/cvc4_assert.h" -#include "options/options.h" -#include "smt/options.h" -#include "util/statistics_registry.h" -#include "util/resource_manager.h" -#include "util/tls.h" - -#include "expr/type_checker.h" #include <algorithm> +#include <ext/hash_set> #include <stack> #include <utility> -#include <ext/hash_set> + +#include "base/cvc4_assert.h" +#include "base/tls.h" +#include "expr/attribute.h" +#include "expr/node_manager_attributes.h" +#include "expr/type_checker.h" +#include "options/options.h" +#include "options/smt_options.h" +#include "expr/resource_manager.h" +#include "expr/statistics_registry.h" + using namespace std; using namespace CVC4::expr; diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h index f52c7732f..390af8967 100644 --- a/src/expr/node_manager.h +++ b/src/expr/node_manager.h @@ -32,11 +32,11 @@ #include <string> #include <ext/hash_set> +#include "base/tls.h" #include "expr/kind.h" #include "expr/metakind.h" #include "expr/node_value.h" #include "util/subrange_bound.h" -#include "util/tls.h" #include "options/options.h" namespace CVC4 { @@ -940,24 +940,25 @@ public: class NodeManagerScope { /** The old NodeManager, to be restored on destruction. */ NodeManager* d_oldNodeManager; - + Options::OptionsScope d_optionsScope; public: - NodeManagerScope(NodeManager* nm) : - d_oldNodeManager(NodeManager::s_current) { + NodeManagerScope(NodeManager* nm) + : d_oldNodeManager(NodeManager::s_current) + , d_optionsScope(nm ? nm->d_options : NULL) { // There are corner cases where nm can be NULL and it's ok. // For example, if you write { Expr e; }, then when the null // Expr is destructed, there's no active node manager. //Assert(nm != NULL); NodeManager::s_current = nm; - Options::s_current = nm ? nm->d_options : NULL; + //Options::s_current = nm ? nm->d_options : NULL; Debug("current") << "node manager scope: " << NodeManager::s_current << "\n"; } ~NodeManagerScope() { NodeManager::s_current = d_oldNodeManager; - Options::s_current = d_oldNodeManager ? d_oldNodeManager->d_options : NULL; + //Options::s_current = d_oldNodeManager ? d_oldNodeManager->d_options : NULL; Debug("current") << "node manager scope: " << "returning to " << NodeManager::s_current << "\n"; } diff --git a/src/expr/node_self_iterator.h b/src/expr/node_self_iterator.h index 401cc6152..77fc05e3b 100644 --- a/src/expr/node_self_iterator.h +++ b/src/expr/node_self_iterator.h @@ -21,7 +21,7 @@ #include <iterator> -#include "util/cvc4_assert.h" +#include "base/cvc4_assert.h" #include "expr/node.h" namespace CVC4 { diff --git a/src/expr/node_value.cpp b/src/expr/node_value.cpp index 6b48fd9b7..dbe7d09eb 100644 --- a/src/expr/node_value.cpp +++ b/src/expr/node_value.cpp @@ -17,15 +17,16 @@ ** cvc4::Node rather than by pointer; cvc4::Node maintains the ** reference count on NodeValue instances and **/ - #include "expr/node_value.h" -#include "expr/node.h" + +#include <sstream> + #include "expr/kind.h" #include "expr/metakind.h" -#include "util/language.h" +#include "expr/node.h" +#include "options/language.h" #include "options/options.h" #include "printer/printer.h" -#include <sstream> using namespace std; diff --git a/src/expr/node_value.h b/src/expr/node_value.h index 785f8909f..c39c14604 100644 --- a/src/expr/node_value.h +++ b/src/expr/node_value.h @@ -26,12 +26,13 @@ #ifndef __CVC4__EXPR__NODE_VALUE_H #define __CVC4__EXPR__NODE_VALUE_H -#include "expr/kind.h" -#include "util/language.h" - #include <stdint.h> -#include <string> + #include <iterator> +#include <string> + +#include "expr/kind.h" +#include "options/language.h" namespace CVC4 { diff --git a/src/expr/options_handlers.h b/src/expr/options_handlers.h deleted file mode 100644 index e2a92ade7..000000000 --- a/src/expr/options_handlers.h +++ /dev/null @@ -1,69 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: none - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Custom handlers and predicates for expression package options - ** - ** Custom handlers and predicates for expression package options. - **/ - -#include "cvc4_private.h" - -#ifndef __CVC4__EXPR__OPTIONS_HANDLERS_H -#define __CVC4__EXPR__OPTIONS_HANDLERS_H - -#include "util/output.h" -#include "util/dump.h" - -namespace CVC4 { -namespace expr { - -inline void setDefaultExprDepth(std::string option, int depth, SmtEngine* smt) { - if(depth < -1) { - throw OptionException("--default-expr-depth requires a positive argument, or -1."); - } - - Debug.getStream() << Expr::setdepth(depth); - Trace.getStream() << Expr::setdepth(depth); - Notice.getStream() << Expr::setdepth(depth); - Chat.getStream() << Expr::setdepth(depth); - Message.getStream() << Expr::setdepth(depth); - Warning.getStream() << Expr::setdepth(depth); - // intentionally exclude Dump stream from this list -} - -inline void setDefaultDagThresh(std::string option, int dag, SmtEngine* smt) { - if(dag < 0) { - throw OptionException("--default-dag-thresh requires a nonnegative argument."); - } - - Debug.getStream() << Expr::dag(dag); - Trace.getStream() << Expr::dag(dag); - Notice.getStream() << Expr::dag(dag); - Chat.getStream() << Expr::dag(dag); - Message.getStream() << Expr::dag(dag); - Warning.getStream() << Expr::dag(dag); - Dump.getStream() << Expr::dag(dag); -} - -inline void setPrintExprTypes(std::string option, SmtEngine* smt) { - Debug.getStream() << Expr::printtypes(true); - Trace.getStream() << Expr::printtypes(true); - Notice.getStream() << Expr::printtypes(true); - Chat.getStream() << Expr::printtypes(true); - Message.getStream() << Expr::printtypes(true); - Warning.getStream() << Expr::printtypes(true); - // intentionally exclude Dump stream from this list -} - -}/* CVC4::expr namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__EXPR__OPTIONS_HANDLERS_H */ diff --git a/src/expr/pickle_data.cpp b/src/expr/pickle_data.cpp index 6f47f9207..e273bcece 100644 --- a/src/expr/pickle_data.cpp +++ b/src/expr/pickle_data.cpp @@ -22,6 +22,7 @@ #include <sstream> #include <string> +#include "base/cvc4_assert.h" #include "expr/pickle_data.h" #include "expr/expr.h" #include "expr/node.h" @@ -29,7 +30,6 @@ #include "expr/node_value.h" #include "expr/expr_manager_scope.h" #include "expr/variable_type_map.h" -#include "util/cvc4_assert.h" #include "expr/kind.h" #include "expr/metakind.h" diff --git a/src/expr/pickler.cpp b/src/expr/pickler.cpp index 20e8859e3..d0501ca2b 100644 --- a/src/expr/pickler.cpp +++ b/src/expr/pickler.cpp @@ -20,6 +20,8 @@ #include <sstream> #include <string> +#include "base/cvc4_assert.h" +#include "base/output.h" #include "expr/pickler.h" #include "expr/pickle_data.h" #include "expr/expr.h" @@ -28,10 +30,8 @@ #include "expr/node_value.h" #include "expr/expr_manager_scope.h" #include "expr/variable_type_map.h" -#include "util/cvc4_assert.h" #include "expr/kind.h" #include "expr/metakind.h" -#include "util/output.h" namespace CVC4 { namespace expr { diff --git a/src/expr/pickler.h b/src/expr/pickler.h index 8c3da5f40..cf1754d93 100644 --- a/src/expr/pickler.h +++ b/src/expr/pickler.h @@ -23,7 +23,7 @@ #include "expr/variable_type_map.h" #include "expr/expr.h" -#include "util/exception.h" +#include "base/exception.h" #include <exception> #include <stack> diff --git a/src/util/predicate.cpp b/src/expr/predicate.cpp index 787d329aa..b88951bf9 100644 --- a/src/util/predicate.cpp +++ b/src/expr/predicate.cpp @@ -15,10 +15,11 @@ ** Instances of this class are carried as the payload of ** the CONSTANT-metakinded SUBTYPE_TYPE types. **/ +#include "expr/predicate.h" +#include "base/cvc4_assert.h" #include "expr/expr.h" -#include "util/predicate.h" -#include "util/cvc4_assert.h" + using namespace std; diff --git a/src/util/predicate.h b/src/expr/predicate.h index 5ead2f090..cc3e8b576 100644 --- a/src/util/predicate.h +++ b/src/expr/predicate.h @@ -21,7 +21,7 @@ #ifndef __CVC4__PREDICATE_H #define __CVC4__PREDICATE_H -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { @@ -35,6 +35,8 @@ struct CVC4_PUBLIC PredicateHashFunction { }/* CVC4 namespace */ +// TIM: This needs to be here due to a circular dependency. +#warning "TODO: Track down the circular dependence on expr.h." #include "expr/expr.h" namespace CVC4 { diff --git a/src/util/predicate.i b/src/expr/predicate.i index eedbb2e83..aa80a98b5 100644 --- a/src/util/predicate.i +++ b/src/expr/predicate.i @@ -1,5 +1,5 @@ %{ -#include "util/predicate.h" +#include "expr/predicate.h" %} %rename(equals) CVC4::Predicate::operator==(const Predicate&) const; @@ -9,4 +9,4 @@ %ignore CVC4::operator<<(std::ostream&, const Predicate&); -%include "util/predicate.h" +%include "expr/predicate.h" diff --git a/src/util/record.cpp b/src/expr/record.cpp index ea9b5495a..dfcba0d46 100644 --- a/src/util/record.cpp +++ b/src/expr/record.cpp @@ -14,9 +14,7 @@ ** A class representing a record definition. **/ -#include "util/record.h" - -using namespace std; +#include "expr/record.h" namespace CVC4 { diff --git a/src/util/record.h b/src/expr/record.h index 5689a4209..a255649da 100644 --- a/src/util/record.h +++ b/src/expr/record.h @@ -74,6 +74,7 @@ inline std::ostream& operator<<(std::ostream& out, const RecordUpdate& t) { }/* CVC4 namespace */ +#warning "TODO: Address circular dependence in Record." #include "expr/expr.h" #include "expr/type.h" diff --git a/src/util/record.i b/src/expr/record.i index 0cc1bc579..283f01106 100644 --- a/src/util/record.i +++ b/src/expr/record.i @@ -1,5 +1,5 @@ %{ -#include "util/record.h" +#include "expr/record.h" #ifdef SWIGJAVA @@ -98,7 +98,7 @@ #endif /* SWIGJAVA */ -%include "util/record.h" +%include "expr/record.h" #ifdef SWIGJAVA diff --git a/src/util/resource_manager.cpp b/src/expr/resource_manager.cpp index 22496a433..f36200282 100644 --- a/src/util/resource_manager.cpp +++ b/src/expr/resource_manager.cpp @@ -1,5 +1,5 @@ /********************* */ -/*! \file resource_manager.h +/*! \file resource_manager.cpp ** \verbatim ** Original author: Liana Hadarean ** Major contributors: none @@ -13,16 +13,20 @@ ** ** Manages and updates various resource and time limits. **/ +#include "expr/resource_manager.h" -#include "util/resource_manager.h" -#include "util/output.h" +#include "base/output.h" +#include "options/smt_options.h" #include "smt/smt_engine_scope.h" -#include "smt/options.h" #include "theory/rewriter.h" -using namespace CVC4; +#warning "TODO: Break the dependence of the ResourceManager on the theory" +#warning "rewriter and scope. Move this file back into util/ afterwards." + using namespace std; +namespace CVC4 { + void Timer::set(uint64_t millis, bool wallTime) { d_ms = millis; Trace("limit") << "Timer::set(" << d_ms << ")" << std::endl; @@ -283,3 +287,5 @@ void ResourceManager::enable(bool on) { Trace("limit") << "ResourceManager::enable("<< on <<")\n"; d_on = on; } + +} /* namespace CVC4 */ diff --git a/src/util/resource_manager.h b/src/expr/resource_manager.h index e84917db0..c4ad35564 100644 --- a/src/util/resource_manager.h +++ b/src/expr/resource_manager.h @@ -22,7 +22,7 @@ #include <cstddef> #include <sys/time.h> -#include "util/exception.h" +#include "base/exception.h" #include "util/unsafe_interrupt_exception.h" namespace CVC4 { diff --git a/src/expr/resource_manager.i b/src/expr/resource_manager.i new file mode 100644 index 000000000..77edbd8c3 --- /dev/null +++ b/src/expr/resource_manager.i @@ -0,0 +1,5 @@ +%{ +#include "expr/resource_manager.h" +%} + +%include "expr/resource_manager.h" diff --git a/src/util/result.cpp b/src/expr/result.cpp index 91b671262..95e382b98 100644 --- a/src/util/result.cpp +++ b/src/expr/result.cpp @@ -13,18 +13,20 @@ ** ** Encapsulation of the result of a query. **/ +#include "expr/result.h" -#include <iostream> #include <algorithm> -#include <string> #include <cctype> +#include <iostream> +#include <string> -#include "util/result.h" -#include "util/cvc4_assert.h" -#include "printer/printer.h" +#include "base/cvc4_assert.h" +#include "expr/node.h" using namespace std; +#warning "TODO: Move Node::setLanguage out of Node and into util/. Then move Result back into util/." + namespace CVC4 { Result::Result(const std::string& instr, std::string inputName) : @@ -185,8 +187,7 @@ ostream& operator<<(ostream& out, enum Result::Validity v) { return out; } -ostream& operator<<(ostream& out, - enum Result::UnknownExplanation e) { +ostream& operator<<(ostream& out, enum Result::UnknownExplanation e) { switch(e) { case Result::REQUIRES_FULL_CHECK: out << "REQUIRES_FULL_CHECK"; break; case Result::INCOMPLETE: out << "INCOMPLETE"; break; @@ -204,8 +205,91 @@ ostream& operator<<(ostream& out, } ostream& operator<<(ostream& out, const Result& r) { - Printer::getPrinter(Node::setlanguage::getLanguage(out))->toStream(out, r); + r.toStream(out, Node::setlanguage::getLanguage(out)); return out; }/* operator<<(ostream&, const Result&) */ + +void Result::toStreamDefault(std::ostream& out) const throw() { + if(getType() == Result::TYPE_SAT) { + switch(isSat()) { + case Result::UNSAT: + out << "unsat"; + break; + case Result::SAT: + out << "sat"; + break; + case Result::SAT_UNKNOWN: + out << "unknown"; + if(whyUnknown() != Result::UNKNOWN_REASON) { + out << " (" << whyUnknown() << ")"; + } + break; + } + } else { + switch(isValid()) { + case Result::INVALID: + out << "invalid"; + break; + case Result::VALID: + out << "valid"; + break; + case Result::VALIDITY_UNKNOWN: + out << "unknown"; + if(whyUnknown() != Result::UNKNOWN_REASON) { + out << " (" << whyUnknown() << ")"; + } + break; + } + } +}/* Result::toStreamDefault() */ + + +void Result::toStreamSmt2(ostream& out) const throw(){ + if(getType() == Result::TYPE_SAT && isSat() == Result::SAT_UNKNOWN) { + out << "unknown"; + } else { + toStreamDefault(out); + } +} + +void Result::toStreamTptp(std::ostream& out) const throw() { + out << "% SZS status "; + if(isSat() == Result::SAT) { + out << "Satisfiable"; + } else if(isSat() == Result::UNSAT) { + out << "Unsatisfiable"; + } else if(isValid() == Result::VALID) { + out << "Theorem"; + } else if(isValid() == Result::INVALID) { + out << "CounterSatisfiable"; + } else { + out << "GaveUp"; + } + out << " for " << getInputName(); +} + +void Result::toStream(std::ostream& out, OutputLanguage language) const throw() { + switch(language) { + case language::output::LANG_SMTLIB_V2_0: + case language::output::LANG_SMTLIB_V2_5: + case language::output::LANG_SYGUS: + case language::output::LANG_Z3STR: + toStreamSmt2(out); + break; + case language::output::LANG_TPTP: + toStreamTptp(out); + break; + case language::output::LANG_AST: + case language::output::LANG_AUTO: + case language::output::LANG_CVC3: + case language::output::LANG_CVC4: + case language::output::LANG_MAX: + case language::output::LANG_SMTLIB_V1: + default: + toStreamDefault(out); + break; + }; +} + }/* CVC4 namespace */ diff --git a/src/util/result.h b/src/expr/result.h index 8c804daa7..74697eba6 100644 --- a/src/util/result.h +++ b/src/expr/result.h @@ -22,7 +22,8 @@ #include <iostream> #include <string> -#include "util/exception.h" +#include "base/exception.h" +#include "options/language.h" namespace CVC4 { @@ -155,6 +156,32 @@ public: std::string getInputName() const { return d_inputName; } + /** + * Write a Result out to a stream in this language. + */ + void toStream(std::ostream& out, OutputLanguage language) const throw(); + + /** + * This is mostly the same the default + * If getType() == Result::TYPE_SAT && isSat() == Result::SAT_UNKNOWN, + * + */ + void toStreamSmt2(std::ostream& out) const throw(); + + /** + * Write a Result out to a stream in the Tptp format + */ + void toStreamTptp(std::ostream& out) const throw(); + + /** + * Write a Result out to a stream. + * + * The default implementation writes a reasonable string in lowercase + * for sat, unsat, valid, invalid, or unknown results. This behavior + * is overridable by each Printer, since sometimes an output language + * has a particular preference for how results should appear. + */ + void toStreamDefault(std::ostream& out) const throw(); };/* class Result */ inline bool Result::operator!=(const Result& r) const throw() { diff --git a/src/util/result.i b/src/expr/result.i index b77bfd881..becbe9aa9 100644 --- a/src/util/result.i +++ b/src/expr/result.i @@ -1,5 +1,5 @@ %{ -#include "util/result.h" +#include "expr/result.h" %} %ignore CVC4::operator<<(std::ostream&, const Result& r); @@ -17,4 +17,4 @@ %ignore CVC4::operator==(enum Result::Validity, const Result&); %ignore CVC4::operator!=(enum Result::Validity, const Result&); -%include "util/result.h" +%include "expr/result.h" diff --git a/src/expr/sexpr.cpp b/src/expr/sexpr.cpp new file mode 100644 index 000000000..a321f85aa --- /dev/null +++ b/src/expr/sexpr.cpp @@ -0,0 +1,233 @@ +/********************* */ +/*! \file sexpr.cpp + ** \verbatim + ** Original author: Morgan Deters + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Simple representation of S-expressions + ** + ** Simple representation of S-expressions. + ** + ** SExprs have their own language specific printing procedures. The reason for + ** this being implemented on SExpr and not on the Printer class is that the + ** Printer class lives in libcvc4. It has to currently as it prints fairly + ** complicated objects, like Model, which in turn uses SmtEngine pointers. + ** However, SExprs need to be printed by Statistics. To get the output consistent + ** with the previous version, the printing of SExprs in different languages is + ** handled in the SExpr class and the libexpr library. + **/ + +#include "expr/sexpr.h" + +#include <iostream> +#include <sstream> +#include <vector> + +#include "base/cvc4_assert.h" +#include "expr/expr.h" +#include "util/smt2_quote_string.h" + + +namespace CVC4 { + +const int PrettySExprs::s_iosIndex = std::ios_base::xalloc(); + +std::ostream& operator<<(std::ostream& out, PrettySExprs ps) { + ps.applyPrettySExprs(out); + return out; +} + +std::string SExpr::toString() const { + std::stringstream ss; + ss << (*this); + return ss.str(); +} + +std::ostream& operator<<(std::ostream& out, const SExpr& sexpr) { + SExpr::toStream(out, sexpr); + return out; +} + +void SExpr::toStream(std::ostream& out, const SExpr& sexpr) throw() { + toStream(out, sexpr, Expr::setlanguage::getLanguage(out)); +} + +void SExpr::toStream(std::ostream& out, const SExpr& sexpr, OutputLanguage language) throw() { + toStream(out, sexpr, language, PrettySExprs::getPrettySExprs(out) ? 2 : 0); +} + +void SExpr::toStream(std::ostream& out, const SExpr& sexpr, OutputLanguage language, int indent) throw() { + if( sexpr.isKeyword() && languageQuotesKeywords(language) ){ + out << quoteSymbol(sexpr.getValue()); + } else { + toStreamRec(out, sexpr, language, indent); + } +} + + +void SExpr::toStreamRec(std::ostream& out, const SExpr& sexpr, OutputLanguage language, int indent) throw() { + if(sexpr.isInteger()) { + out << sexpr.getIntegerValue(); + } else if(sexpr.isRational()) { + out << std::fixed << sexpr.getRationalValue().getDouble(); + } else if(sexpr.isKeyword()) { + out << sexpr.getValue(); + } else if(sexpr.isString()) { + std::string s = sexpr.getValue(); + // escape backslash and quote + for(size_t i = 0; i < s.length(); ++i) { + if(s[i] == '"') { + s.replace(i, 1, "\\\""); + ++i; + } else if(s[i] == '\\') { + s.replace(i, 1, "\\\\"); + ++i; + } + } + out << "\"" << s << "\""; + } else { + const std::vector<SExpr>& kids = sexpr.getChildren(); + out << (indent > 0 && kids.size() > 1 ? "( " : "("); + bool first = true; + for(std::vector<SExpr>::const_iterator i = kids.begin(); i != kids.end(); ++i) { + if(first) { + first = false; + } else { + if(indent > 0) { + out << "\n" << std::string(indent, ' '); + } else { + out << ' '; + } + } + toStreamRec(out, *i, language, indent <= 0 || indent > 2 ? 0 : indent + 2); + } + if(indent > 0 && kids.size() > 1) { + out << '\n'; + if(indent > 2) { + out << std::string(indent - 2, ' '); + } + } + out << ')'; + } +}/* toStreamRec() */ + + +bool SExpr::languageQuotesKeywords(OutputLanguage language) { + switch(language) { + case language::output::LANG_SMTLIB_V1: + case language::output::LANG_SMTLIB_V2_0: + case language::output::LANG_SMTLIB_V2_5: + case language::output::LANG_SYGUS: + case language::output::LANG_TPTP: + case language::output::LANG_Z3STR: + return true; + case language::output::LANG_AST: + case language::output::LANG_CVC3: + case language::output::LANG_CVC4: + default: + return false; + }; +} + + + +std::string SExpr::getValue() const { + CheckArgument( isAtom(), this ); + switch(d_sexprType) { + case SEXPR_INTEGER: + return d_integerValue.toString(); + case SEXPR_RATIONAL: { + // We choose to represent rationals as decimal strings rather than + // "numerator/denominator." Perhaps an additional SEXPR_DECIMAL + // could be added if we need both styles, even if it's backed by + // the same Rational object. + std::stringstream ss; + ss << std::fixed << d_rationalValue.getDouble(); + return ss.str(); + } + case SEXPR_STRING: + case SEXPR_KEYWORD: + return d_stringValue; + case SEXPR_NOT_ATOM: + return std::string(); + } + return std::string(); + +} + +const CVC4::Integer& SExpr::getIntegerValue() const { + CheckArgument( isInteger(), this ); + return d_integerValue; +} + +const CVC4::Rational& SExpr::getRationalValue() const { + CheckArgument( isRational(), this ); + return d_rationalValue; +} + +const std::vector<SExpr>& SExpr::getChildren() const { + CheckArgument( !isAtom(), this ); + return d_children; +} + +bool SExpr::operator==(const SExpr& s) const { + return d_sexprType == s.d_sexprType && + d_integerValue == s.d_integerValue && + d_rationalValue == s.d_rationalValue && + d_stringValue == s.d_stringValue && + d_children == s.d_children; +} + +bool SExpr::operator!=(const SExpr& s) const { + return !(*this == s); +} + + +SExpr SExpr::parseAtom(const std::string& atom) { + if(atom == "true"){ + return SExpr(true); + } else if(atom == "false"){ + return SExpr(false); + } else { + try { + Integer z(atom); + return SExpr(z); + }catch(std::invalid_argument&){ + // Fall through to the next case + } + try { + Rational q(atom); + return SExpr(q); + }catch(std::invalid_argument&){ + // Fall through to the next case + } + return SExpr(atom); + } +} + +SExpr SExpr::parseListOfAtoms(const std::vector<std::string>& atoms) { + std::vector<SExpr> parsedAtoms; + typedef std::vector<std::string>::const_iterator const_iterator; + for(const_iterator i = atoms.begin(), i_end=atoms.end(); i != i_end; ++i){ + parsedAtoms.push_back(parseAtom(*i)); + } + return SExpr(parsedAtoms); +} + +SExpr SExpr::parseListOfListOfAtoms(const std::vector< std::vector<std::string> >& atoms_lists) { + std::vector<SExpr> parsedListsOfAtoms; + typedef std::vector< std::vector<std::string> >::const_iterator const_iterator; + for(const_iterator i = atoms_lists.begin(), i_end = atoms_lists.end(); i != i_end; ++i){ + parsedListsOfAtoms.push_back(parseListOfAtoms(*i)); + } + return SExpr(parsedListsOfAtoms); +} + + + +}/* CVC4 namespace */ diff --git a/src/util/sexpr.h b/src/expr/sexpr.h index a121b5195..f30045c68 100644 --- a/src/util/sexpr.h +++ b/src/expr/sexpr.h @@ -26,14 +26,15 @@ #ifndef __CVC4__SEXPR_H #define __CVC4__SEXPR_H -#include <vector> -#include <string> #include <iomanip> #include <sstream> +#include <string> +#include <vector> +#include "base/exception.h" +#include "options/language.h" #include "util/integer.h" #include "util/rational.h" -#include "util/exception.h" namespace CVC4 { @@ -157,7 +158,8 @@ public: * This is internally handled as the strings "true" and "false" */ SExpr(bool value) : - d_sexprType(SEXPR_STRING), +#warning "TODO: Discuss this change with Clark." + d_sexprType(SEXPR_KEYWORD), d_integerValue(0), d_rationalValue(0), d_stringValue(value ? "true" : "false"), @@ -181,19 +183,36 @@ public: } /** Is this S-expression an atom? */ - bool isAtom() const; + bool isAtom() const { + return d_sexprType != SEXPR_NOT_ATOM; + } /** Is this S-expression an integer? */ - bool isInteger() const; + bool isInteger() const { + return d_sexprType == SEXPR_INTEGER; + } /** Is this S-expression a rational? */ - bool isRational() const; + bool isRational() const { + return d_sexprType == SEXPR_RATIONAL; + } /** Is this S-expression a string? */ - bool isString() const; + bool isString() const { + return d_sexprType == SEXPR_STRING; + } /** Is this S-expression a keyword? */ - bool isKeyword() const; + bool isKeyword() const { + return d_sexprType == SEXPR_KEYWORD; + } + + /** + * This wraps the toStream() printer. + * NOTE: toString() and getValue() may differ on Keywords based on + * the current language set in expr. + */ + std::string toString() const; /** * Get the string value of this S-expression. This will cause an @@ -225,79 +244,139 @@ public: /** Is this S-expression different from another? */ bool operator!=(const SExpr& s) const; + + /** + * This returns the best match in the following order: + * match atom with + * "true", "false" -> SExpr(value) + * | is and integer -> as integer + * | is a rational -> as rational + * | _ -> SExpr() + */ + static SExpr parseAtom(const std::string& atom); + + /** + * Parses a list of atoms. + */ + static SExpr parseListOfAtoms(const std::vector<std::string>& atoms); + + /** + * Parses a list of list of atoms. + */ + static SExpr parseListOfListOfAtoms(const std::vector< std::vector<std::string> >& atoms_lists); + + + /** + * Outputs the SExpr onto the ostream out. This version reads defaults to the + * OutputLanguage, Expr::setlanguage::getLanguage(out). The indent level is + * set to 2 if PrettySExprs::getPrettySExprs() is on and is 0 otherwise. + */ + static void toStream(std::ostream& out, const SExpr& sexpr) throw(); + + /** + * Outputs the SExpr onto the ostream out. This version sets the indent level + * to 2 if PrettySExprs::getPrettySExprs() is on. + */ + static void toStream(std::ostream& out, const SExpr& sexpr, OutputLanguage language) throw(); + + /** + * Outputs the SExpr onto the ostream out. + * If the languageQuotesKeywords(language), then a top level keyword, " X", + * that needs quoting according to the SMT2 language standard is printed with + * quotes, "| X|". + * Otherwise this prints using toStreamRec(). + * + * TIM: Keywords that are children are not currently quoted. This seems + * incorrect but I am just reproduicing the old behavior even if it does not make + * sense. + */ + static void toStream(std::ostream& out, const SExpr& sexpr, OutputLanguage language, int indent) throw(); + +private: + + /** + * Simple printer for SExpr to an ostream. + * The current implementation is language independent. + */ + static void toStreamRec(std::ostream& out, const SExpr& sexpr, OutputLanguage language, int indent) throw(); + + + /** Returns true if this language quotes Keywords when printing. */ + static bool languageQuotesKeywords(OutputLanguage language); + };/* class SExpr */ -inline bool SExpr::isAtom() const { - return d_sexprType != SEXPR_NOT_ATOM; -} - -inline bool SExpr::isInteger() const { - return d_sexprType == SEXPR_INTEGER; -} - -inline bool SExpr::isRational() const { - return d_sexprType == SEXPR_RATIONAL; -} - -inline bool SExpr::isString() const { - return d_sexprType == SEXPR_STRING; -} - -inline bool SExpr::isKeyword() const { - return d_sexprType == SEXPR_KEYWORD; -} - -inline std::string SExpr::getValue() const { - CheckArgument( isAtom(), this ); - switch(d_sexprType) { - case SEXPR_INTEGER: - return d_integerValue.toString(); - case SEXPR_RATIONAL: { - // We choose to represent rationals as decimal strings rather than - // "numerator/denominator." Perhaps an additional SEXPR_DECIMAL - // could be added if we need both styles, even if it's backed by - // the same Rational object. - std::stringstream ss; - ss << std::fixed << d_rationalValue.getDouble(); - return ss.str(); +/** Prints an SExpr. */ +std::ostream& operator<<(std::ostream& out, const SExpr& sexpr) CVC4_PUBLIC; + +/** + * IOStream manipulator to pretty-print SExprs. + */ +class CVC4_PUBLIC PrettySExprs { + /** + * The allocated index in ios_base for our setting. + */ + static const int s_iosIndex; + + /** + * When this manipulator is used, the setting is stored here. + */ + bool d_prettySExprs; + +public: + /** + * Construct a PrettySExprs with the given setting. + */ + PrettySExprs(bool prettySExprs) : d_prettySExprs(prettySExprs) {} + + inline void applyPrettySExprs(std::ostream& out) { + out.iword(s_iosIndex) = d_prettySExprs; } - case SEXPR_STRING: - case SEXPR_KEYWORD: - return d_stringValue; - case SEXPR_NOT_ATOM: - return std::string(); + + static inline bool getPrettySExprs(std::ostream& out) { + return out.iword(s_iosIndex); } - return std::string(); -} - -inline const CVC4::Integer& SExpr::getIntegerValue() const { - CheckArgument( isInteger(), this ); - return d_integerValue; -} - -inline const CVC4::Rational& SExpr::getRationalValue() const { - CheckArgument( isRational(), this ); - return d_rationalValue; -} - -inline const std::vector<SExpr>& SExpr::getChildren() const { - CheckArgument( !isAtom(), this ); - return d_children; -} - -inline bool SExpr::operator==(const SExpr& s) const { - return d_sexprType == s.d_sexprType && - d_integerValue == s.d_integerValue && - d_rationalValue == s.d_rationalValue && - d_stringValue == s.d_stringValue && - d_children == s.d_children; -} - -inline bool SExpr::operator!=(const SExpr& s) const { - return !(*this == s); -} -std::ostream& operator<<(std::ostream& out, const SExpr& sexpr) CVC4_PUBLIC; + static inline void setPrettySExprs(std::ostream& out, bool prettySExprs) { + out.iword(s_iosIndex) = prettySExprs; + } + + /** + * Set the pretty-sexprs state on the output stream for the current + * stack scope. This makes sure the old state is reset on the + * stream after normal OR exceptional exit from the scope, using the + * RAII C++ idiom. + */ + class Scope { + std::ostream& d_out; + bool d_oldPrettySExprs; + + public: + + inline Scope(std::ostream& out, bool prettySExprs) : + d_out(out), + d_oldPrettySExprs(PrettySExprs::getPrettySExprs(out)) { + PrettySExprs::setPrettySExprs(out, prettySExprs); + } + + inline ~Scope() { + PrettySExprs::setPrettySExprs(d_out, d_oldPrettySExprs); + } + + };/* class PrettySExprs::Scope */ + +};/* class PrettySExprs */ + +/** + * Sets the default pretty-sexprs setting for an ostream. Use like this: + * + * // let out be an ostream, s an SExpr + * out << PrettySExprs(true) << s << endl; + * + * The setting stays permanently (until set again) with the stream. + */ +std::ostream& operator<<(std::ostream& out, PrettySExprs ps); + }/* CVC4 namespace */ diff --git a/src/util/sexpr.i b/src/expr/sexpr.i index 4c89c5019..f6229782e 100644 --- a/src/util/sexpr.i +++ b/src/expr/sexpr.i @@ -1,5 +1,5 @@ %{ -#include "util/sexpr.h" +#include "expr/sexpr.h" %} %ignore CVC4::operator<<(std::ostream&, const SExpr&); @@ -18,4 +18,4 @@ %rename(equals) CVC4::SExpr::operator==(const SExpr&) const; %ignore CVC4::SExpr::operator!=(const SExpr&) const; -%include "util/sexpr.h" +%include "expr/sexpr.h" diff --git a/src/util/statistics.cpp b/src/expr/statistics.cpp index ff31e7b4b..e5d3f6e69 100644 --- a/src/util/statistics.cpp +++ b/src/expr/statistics.cpp @@ -15,11 +15,12 @@ ** \todo document this file **/ -#include "util/statistics.h" -#include "util/statistics_registry.h" // for details about class Stat - #include <typeinfo> +#include "expr/statistics.h" +#include "expr/statistics_registry.h" // for details about class Stat + + namespace CVC4 { std::string StatisticsBase::s_regDelim("::"); diff --git a/src/util/statistics.h b/src/expr/statistics.h index a7088f5c5..425404692 100644 --- a/src/util/statistics.h +++ b/src/expr/statistics.h @@ -20,12 +20,12 @@ #ifndef __CVC4__STATISTICS_H #define __CVC4__STATISTICS_H -#include "util/sexpr.h" +#include "expr/sexpr.h" -#include <string> +#include <iterator> #include <ostream> #include <set> -#include <iterator> +#include <string> #include <utility> namespace CVC4 { diff --git a/src/util/statistics.i b/src/expr/statistics.i index bd3a4eeb9..990f465f5 100644 --- a/src/util/statistics.i +++ b/src/expr/statistics.i @@ -1,5 +1,5 @@ %{ -#include "util/statistics.h" +#include "expr/statistics.h" #ifdef SWIGJAVA @@ -67,7 +67,7 @@ #endif /* SWIGJAVA */ -%include "util/statistics.h" +%include "expr/statistics.h" #ifdef SWIGJAVA diff --git a/src/util/statistics_registry.cpp b/src/expr/statistics_registry.cpp index 097869bc7..c1db992c5 100644 --- a/src/util/statistics_registry.cpp +++ b/src/expr/statistics_registry.cpp @@ -15,7 +15,8 @@ ** \todo document this file **/ -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" + #include "expr/expr_manager.h" #include "lib/clock_gettime.h" #include "smt/smt_engine.h" @@ -30,6 +31,9 @@ # define __CVC4_USE_STATISTICS false #endif +#warning "TODO: Make StatisticsRegistry non-public again." +#warning "TODO: Make TimerStat non-public again." + namespace CVC4 { namespace stats { @@ -157,6 +161,8 @@ RegisterStatistic::RegisterStatistic(SmtEngine& smt, Stat* stat) : d_reg->registerStat_(d_stat); } + + }/* CVC4 namespace */ #undef __CVC4_USE_STATISTICS diff --git a/src/util/statistics_registry.h b/src/expr/statistics_registry.h index b9e3eaf8b..89efe4021 100644 --- a/src/util/statistics_registry.h +++ b/src/expr/statistics_registry.h @@ -21,17 +21,18 @@ #ifndef __CVC4__STATISTICS_REGISTRY_H #define __CVC4__STATISTICS_REGISTRY_H -#include "util/statistics.h" -#include "util/exception.h" -#include "lib/clock_gettime.h" +#include <stdint.h> -#include <sstream> -#include <iomanip> +#include <cassert> #include <ctime> -#include <vector> +#include <iomanip> #include <map> -#include <stdint.h> -#include <cassert> +#include <sstream> +#include <vector> + +#include "base/exception.h" +#include "expr/statistics.h" +#include "lib/clock_gettime.h" namespace CVC4 { @@ -108,7 +109,7 @@ public: virtual SExpr getValue() const { std::stringstream ss; flushInformation(ss); - return ss.str(); + return SExpr(ss.str()); } };/* class Stat */ @@ -122,27 +123,27 @@ template <class T> inline SExpr mkSExpr(const T& x) { std::stringstream ss; ss << x; - return ss.str(); + return SExpr(ss.str()); } template <> inline SExpr mkSExpr(const uint64_t& x) { - return Integer(x); + return SExpr(Integer(x)); } template <> inline SExpr mkSExpr(const int64_t& x) { - return Integer(x); + return SExpr(Integer(x)); } template <> inline SExpr mkSExpr(const int& x) { - return Integer(x); + return SExpr(Integer(x)); } template <> inline SExpr mkSExpr(const Integer& x) { - return x; + return SExpr(x); } template <> @@ -150,12 +151,12 @@ inline SExpr mkSExpr(const double& x) { // roundabout way to get a Rational from a double std::stringstream ss; ss << std::fixed << std::setprecision(8) << x; - return Rational::fromDecimal(ss.str()); + return SExpr(Rational::fromDecimal(ss.str())); } template <> inline SExpr mkSExpr(const Rational& x) { - return x; + return SExpr(x); } /** @@ -483,7 +484,10 @@ public: };/* class AverageStat */ /** A statistic that contains a SExpr. */ -class SExprStat : public BackedStat<SExpr> { +class SExprStat : public Stat { +private: + SExpr d_data; + public: /** @@ -491,7 +495,10 @@ public: * initial value. */ SExprStat(const std::string& name, const SExpr& init) : - BackedStat<SExpr>(name, init) { + Stat(name), d_data(init){} + + virtual void flushInformation(std::ostream& out) const { + out << d_data << std::endl; } SExpr getValue() const { @@ -587,7 +594,7 @@ public: * The main statistics registry. This registry maintains the list of * currently active statistics and is able to "flush" them all. */ -class StatisticsRegistry : public StatisticsBase, public Stat { +class CVC4_PUBLIC StatisticsRegistry : public StatisticsBase, public Stat { private: /** Private copy constructor undefined (no copy permitted). */ @@ -632,7 +639,7 @@ public: std::vector<SExpr> v; for(StatSet::iterator i = d_stats.begin(); i != d_stats.end(); ++i) { std::vector<SExpr> w; - w.push_back((*i)->getName()); + w.push_back(SExpr((*i)->getName())); w.push_back((*i)->getValue()); v.push_back(SExpr(w)); } @@ -774,7 +781,7 @@ class CodeTimer; * arbitrarily, like a stopwatch; the value of the statistic at the * end is the accumulated time over all (start,stop) pairs. */ -class TimerStat : public BackedStat<timespec> { +class CVC4_PUBLIC TimerStat : public BackedStat<timespec> { // strange: timespec isn't placed in 'std' namespace ?! /** The last start time of this timer */ diff --git a/src/expr/type.cpp b/src/expr/type.cpp index 46705a849..327be72eb 100644 --- a/src/expr/type.cpp +++ b/src/expr/type.cpp @@ -13,16 +13,16 @@ ** ** Implementation of expression types. **/ +#include "expr/type.h" #include <iostream> #include <string> #include <vector> +#include "base/exception.h" #include "expr/node_manager.h" #include "expr/node_manager_attributes.h" -#include "expr/type.h" #include "expr/type_node.h" -#include "util/exception.h" using namespace std; diff --git a/src/expr/type_node.h b/src/expr/type_node.h index 0f5e020d8..ce006a4f1 100644 --- a/src/expr/type_node.h +++ b/src/expr/type_node.h @@ -27,9 +27,9 @@ #include <iostream> #include <stdint.h> +#include "base/cvc4_assert.h" #include "expr/kind.h" #include "expr/metakind.h" -#include "util/cvc4_assert.h" #include "util/cardinality.h" namespace CVC4 { diff --git a/src/expr/type_properties_template.h b/src/expr/type_properties_template.h index b54fd8809..bc780a7e5 100644 --- a/src/expr/type_properties_template.h +++ b/src/expr/type_properties_template.h @@ -21,13 +21,13 @@ #line 23 "${template}" +#include <sstream> + +#include "base/cvc4_assert.h" +#include "options/language.h" #include "expr/type_node.h" -#include "util/cvc4_assert.h" #include "expr/kind.h" #include "expr/expr.h" -#include "util/language.h" - -#include <sstream> ${type_properties_includes} diff --git a/src/util/uninterpreted_constant.cpp b/src/expr/uninterpreted_constant.cpp index f0d9a42d2..d41ab1045 100644 --- a/src/util/uninterpreted_constant.cpp +++ b/src/expr/uninterpreted_constant.cpp @@ -14,7 +14,8 @@ ** Representation of constants of uninterpreted sorts. **/ -#include "util/uninterpreted_constant.h" +#include "expr/uninterpreted_constant.h" + #include <iostream> #include <sstream> #include <string> diff --git a/src/util/uninterpreted_constant.h b/src/expr/uninterpreted_constant.h index 13a80a19d..13a80a19d 100644 --- a/src/util/uninterpreted_constant.h +++ b/src/expr/uninterpreted_constant.h diff --git a/src/util/uninterpreted_constant.i b/src/expr/uninterpreted_constant.i index 9a49f0642..1636eba5b 100644 --- a/src/util/uninterpreted_constant.i +++ b/src/expr/uninterpreted_constant.i @@ -1,5 +1,5 @@ %{ -#include "util/uninterpreted_constant.h" +#include "expr/uninterpreted_constant.h" %} %rename(less) CVC4::UninterpretedConstant::operator<(const UninterpretedConstant&) const; @@ -14,4 +14,4 @@ %ignore CVC4::operator<<(std::ostream&, const UninterpretedConstant&); -%include "util/uninterpreted_constant.h" +%include "expr/uninterpreted_constant.h" diff --git a/src/include/cvc4.h b/src/include/cvc4.h index 77fcbad41..d41fce056 100644 --- a/src/include/cvc4.h +++ b/src/include/cvc4.h @@ -18,20 +18,17 @@ #ifndef __CVC4__CVC4_H #define __CVC4__CVC4_H -#include <cvc4/smt/smt_engine.h> - -#include <cvc4/expr/expr_manager.h> +#include <cvc4/base/exception.h> +#include <cvc4/expr/datatype.h> #include <cvc4/expr/expr.h> -#include <cvc4/expr/command.h> - -#include <cvc4/util/datatype.h> -#include <cvc4/util/integer.h> -#include <cvc4/util/rational.h> -#include <cvc4/util/exception.h> +#include <cvc4/expr/expr_manager.h> #include <cvc4/options/options.h> -#include <cvc4/util/configuration.h> - #include <cvc4/parser/parser.h> #include <cvc4/parser/parser_builder.h> +#include <cvc4/smt/smt_engine.h> +#include <cvc4/smt_util/command.h> +#include <cvc4/util/configuration.h> +#include <cvc4/util/integer.h> +#include <cvc4/util/rational.h> #endif /* __CVC4__CVC4_H */ diff --git a/src/main/Makefile.am b/src/main/Makefile.am index 3ac0db7cb..478d3f3ee 100644 --- a/src/main/Makefile.am +++ b/src/main/Makefile.am @@ -30,7 +30,6 @@ pcvc4_LDADD = \ libmain.a \ @builddir@/../parser/libcvc4parser.la \ @builddir@/../libcvc4.la \ - @builddir@/../util/libstatistics.la \ $(READLINE_LIBS) if CVC4_NEEDS_REPLACEMENT_FUNCTIONS pcvc4_LDADD += \ @@ -55,7 +54,6 @@ cvc4_LDADD = \ libmain.a \ @builddir@/../parser/libcvc4parser.la \ @builddir@/../libcvc4.la \ - @builddir@/../util/libstatistics.la \ $(READLINE_LIBS) if CVC4_NEEDS_REPLACEMENT_FUNCTIONS cvc4_LDADD += \ @@ -80,8 +78,6 @@ smt2_tokens.h: @srcdir@/../parser/smt2/Smt2.g tptp_tokens.h: @srcdir@/../parser/tptp/Tptp.g $(AM_V_GEN)grep "'[a-zA-Z][a-zA-Z0-9_-][a-zA-Z0-9_-]*'" $^ | sed 's/.*'\''\([a-zA-Z0-9_-]*\)'\''.*/"\1",/' | sort -u >$@ -EXTRA_DIST = \ - options_handlers.h clean-local: rm -f $(BUILT_SOURCES) diff --git a/src/main/command_executor.cpp b/src/main/command_executor.cpp index 460274515..0b53c3cbe 100644 --- a/src/main/command_executor.cpp +++ b/src/main/command_executor.cpp @@ -12,22 +12,22 @@ ** \brief An additional layer between commands and invoking them. **/ -#include <iostream> -#include <string> - #include "main/command_executor.h" -#include "expr/command.h" - -#include "main/main.h" - -#include "main/options.h" -#include "smt/options.h" -#include "printer/options.h" #ifndef __WIN32__ # include <sys/resource.h> #endif /* ! __WIN32__ */ +#include <iostream> +#include <string> + +#include "main/main.h" +#include "options/main_options.h" +#include "options/printer_options.h" +#include "options/smt_options.h" +#include "smt_util/command.h" + + namespace CVC4 { namespace main { diff --git a/src/main/command_executor.h b/src/main/command_executor.h index 9fe6347be..49d18a153 100644 --- a/src/main/command_executor.h +++ b/src/main/command_executor.h @@ -15,14 +15,14 @@ #ifndef __CVC4__MAIN__COMMAND_EXECUTOR_H #define __CVC4__MAIN__COMMAND_EXECUTOR_H +#include <iostream> +#include <string> + #include "expr/expr_manager.h" -#include "smt/smt_engine.h" -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" #include "options/options.h" -#include "expr/command.h" - -#include <string> -#include <iostream> +#include "smt/smt_engine.h" +#include "smt_util/command.h" namespace CVC4 { namespace main { diff --git a/src/main/command_executor_portfolio.cpp b/src/main/command_executor_portfolio.cpp index f0d87cdf2..bb6487bf0 100644 --- a/src/main/command_executor_portfolio.cpp +++ b/src/main/command_executor_portfolio.cpp @@ -15,27 +15,28 @@ ** threads. **/ -#include <boost/thread.hpp> -#include <boost/thread/condition.hpp> +#include "main/command_executor_portfolio.h" + +#if HAVE_UNISTD_H +# include <unistd.h> +#endif /* HAVE_UNISTD_H */ + #include <boost/exception_ptr.hpp> #include <boost/lexical_cast.hpp> +#include <boost/thread.hpp> +#include <boost/thread/condition.hpp> #include <string> -#include "expr/command.h" +#include "cvc4autoconfig.h" #include "expr/pickler.h" -#include "main/command_executor_portfolio.h" #include "main/main.h" -#include "main/options.h" #include "main/portfolio.h" +#include "options/main_options.h" #include "options/options.h" -#include "smt/options.h" -#include "printer/options.h" - -#include "cvc4autoconfig.h" +#include "options/printer_options.h" +#include "options/smt_options.h" +#include "smt_util/command.h" -#if HAVE_UNISTD_H -# include <unistd.h> -#endif /* HAVE_UNISTD_H */ using namespace std; diff --git a/src/main/driver_unified.cpp b/src/main/driver_unified.cpp index c29ba55a4..df78df0f3 100644 --- a/src/main/driver_unified.cpp +++ b/src/main/driver_unified.cpp @@ -13,39 +13,38 @@ ** sequential and portfolio versions **/ +#include <stdio.h> +#include <unistd.h> + #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <new> -#include <unistd.h> - -#include <stdio.h> -#include <unistd.h> +#include "base/output.h" #include "cvc4autoconfig.h" -#include "main/main.h" -#include "main/interactive_shell.h" -#include "main/options.h" -#include "parser/parser.h" -#include "parser/parser_builder.h" -#include "parser/parser_exception.h" #include "expr/expr_manager.h" -#include "expr/command.h" -#include "util/configuration.h" -#include "options/options.h" -#include "theory/quantifiers/options.h" +#include "expr/result.h" +#include "expr/statistics_registry.h" #include "main/command_executor.h" #ifdef PORTFOLIO_BUILD # include "main/command_executor_portfolio.h" #endif -#include "main/options.h" -#include "smt/options.h" -#include "util/output.h" -#include "util/result.h" -#include "util/statistics_registry.h" +#include "main/interactive_shell.h" +#include "main/main.h" +#include "options/main_options.h" +#include "options/options.h" +#include "options/quantifiers_options.h" +#include "options/smt_options.h" +#include "parser/parser.h" +#include "parser/parser_builder.h" +#include "parser/parser_exception.h" +#include "smt/smt_options_handler.h" +#include "smt_util/command.h" +#include "util/configuration.h" using namespace std; using namespace CVC4; @@ -130,8 +129,11 @@ int runCvc4(int argc, char* argv[], Options& opts) { progPath = argv[0]; +#warning "TODO: Check that the SmtEngine pointer should be NULL with Kshitij." + smt::SmtOptionsHandler optionsHandler(NULL); + // Parse the options - vector<string> filenames = opts.parseOptions(argc, argv); + vector<string> filenames = opts.parseOptions(argc, argv, &optionsHandler); # ifndef PORTFOLIO_BUILD if( opts.wasSetByUser(options::threads) || @@ -302,7 +304,7 @@ int runCvc4(int argc, char* argv[], Options& opts) { } #ifndef PORTFOLIO_BUILD if(!opts.wasSetByUser(options::incrementalSolving)) { - cmd = new SetOptionCommand("incremental", true); + cmd = new SetOptionCommand("incremental", SExpr(true)); cmd->setMuted(true); pExecutor->doCommand(cmd); delete cmd; @@ -349,7 +351,7 @@ int runCvc4(int argc, char* argv[], Options& opts) { throw OptionException("--tear-down-incremental incompatible with --incremental"); } - cmd = new SetOptionCommand("incremental", false); + cmd = new SetOptionCommand("incremental", SExpr(false)); cmd->setMuted(true); pExecutor->doCommand(cmd); delete cmd; @@ -488,7 +490,7 @@ int runCvc4(int argc, char* argv[], Options& opts) { delete parser; } else { if(!opts.wasSetByUser(options::incrementalSolving)) { - cmd = new SetOptionCommand("incremental", false); + cmd = new SetOptionCommand("incremental", SExpr(false)); cmd->setMuted(true); pExecutor->doCommand(cmd); delete cmd; diff --git a/src/main/interactive_shell.cpp b/src/main/interactive_shell.cpp index 3b237f6a4..da2813e24 100644 --- a/src/main/interactive_shell.cpp +++ b/src/main/interactive_shell.cpp @@ -14,31 +14,17 @@ ** This file is the implementation for the CVC4 interactive shell. ** The shell supports the readline library. **/ +#include "main/interactive_shell.h" -#include <iostream> +#include <algorithm> +#include <cassert> #include <cstdlib> -#include <vector> -#include <string> +#include <iostream> #include <set> -#include <algorithm> -#include <utility> - -#include "cvc4autoconfig.h" - -#include "main/interactive_shell.h" - -#include "expr/command.h" -#include "parser/input.h" -#include "parser/parser.h" -#include "parser/parser_builder.h" -#include "options/options.h" -#include "smt/options.h" -#include "main/options.h" -#include "util/language.h" -#include "util/output.h" - #include <string.h> -#include <cassert> +#include <string> +#include <utility> +#include <vector> #if HAVE_LIBREADLINE # include <readline/readline.h> @@ -48,6 +34,19 @@ # endif /* HAVE_EXT_STDIO_FILEBUF_H */ #endif /* HAVE_LIBREADLINE */ + +#include "base/output.h" +#include "cvc4autoconfig.h" +#include "options/language.h" +#include "options/main_options.h" +#include "options/options.h" +#include "options/smt_options.h" +#include "parser/input.h" +#include "parser/parser.h" +#include "parser/parser_builder.h" +#include "theory/logic_info.h" +#include "smt_util/command.h" + using namespace std; namespace CVC4 { @@ -99,7 +98,7 @@ InteractiveShell::InteractiveShell(ExprManager& exprManager, /* Create parser with bogus input. */ d_parser = parserBuilder.withStringInput("").build(); if(d_options.wasSetByUser(options::forceLogic)) { - d_parser->forceLogic(d_options[options::forceLogic].getLogicString()); + d_parser->forceLogic(d_options[options::forceLogic]->getLogicString()); } #if HAVE_LIBREADLINE @@ -401,4 +400,3 @@ char* commandGenerator(const char* text, int state) { #endif /* HAVE_LIBREADLINE */ }/* CVC4 namespace */ - diff --git a/src/main/interactive_shell.h b/src/main/interactive_shell.h index ef55919a1..1b1031776 100644 --- a/src/main/interactive_shell.h +++ b/src/main/interactive_shell.h @@ -18,9 +18,9 @@ #include <iostream> #include <string> -#include "util/language.h" -#include "util/unsafe_interrupt_exception.h" +#include "options/language.h" #include "options/options.h" +#include "util/unsafe_interrupt_exception.h" namespace CVC4 { diff --git a/src/main/main.cpp b/src/main/main.cpp index 1c825bc35..36a339d94 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -13,30 +13,29 @@ ** ** Main driver for CVC4 executable. **/ +#include "main/main.h" #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> - #include <stdio.h> #include <unistd.h> -#include "main/main.h" -#include "main/interactive_shell.h" +#include "base/output.h" +#include "expr/expr_manager.h" +#include "expr/result.h" +#include "expr/statistics.h" #include "main/command_executor.h" +#include "main/interactive_shell.h" +#include "options/language.h" +#include "options/main_options.h" #include "parser/parser.h" #include "parser/parser_builder.h" #include "parser/parser_exception.h" -#include "expr/expr_manager.h" #include "smt/smt_engine.h" -#include "expr/command.h" +#include "smt_util/command.h" #include "util/configuration.h" -#include "main/options.h" -#include "util/output.h" -#include "util/result.h" -#include "util/statistics.h" -#include "util/language.h" using namespace std; using namespace CVC4; diff --git a/src/main/main.h b/src/main/main.h index a2e813c6c..7dda429af 100644 --- a/src/main/main.h +++ b/src/main/main.h @@ -17,14 +17,14 @@ #include <exception> #include <string> -#include "options/options.h" +#include "base/exception.h" +#include "base/tls.h" +#include "cvc4autoconfig.h" #include "expr/expr_manager.h" +#include "expr/statistics.h" +#include "expr/statistics_registry.h" +#include "options/options.h" #include "smt/smt_engine.h" -#include "util/exception.h" -#include "util/statistics.h" -#include "util/tls.h" -#include "util/statistics_registry.h" -#include "cvc4autoconfig.h" #ifndef __CVC4__MAIN__MAIN_H #define __CVC4__MAIN__MAIN_H diff --git a/src/main/options_handlers.h b/src/main/options_handlers.h deleted file mode 100644 index 00f192d2f..000000000 --- a/src/main/options_handlers.h +++ /dev/null @@ -1,115 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: none - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Custom handlers and predicates for main driver options - ** - ** Custom handlers and predicates for main driver options. - **/ - -#include "cvc4_private.h" - -#ifndef __CVC4__MAIN__OPTIONS_HANDLERS_H -#define __CVC4__MAIN__OPTIONS_HANDLERS_H - -namespace CVC4 { -namespace main { - -inline void showConfiguration(std::string option, SmtEngine* smt) { - fputs(Configuration::about().c_str(), stdout); - printf("\n"); - printf("version : %s\n", Configuration::getVersionString().c_str()); - if(Configuration::isGitBuild()) { - const char* branchName = Configuration::getGitBranchName(); - if(*branchName == '\0') { - branchName = "-"; - } - printf("scm : git [%s %s%s]\n", - branchName, - std::string(Configuration::getGitCommit()).substr(0, 8).c_str(), - Configuration::hasGitModifications() ? - " (with modifications)" : ""); - } else if(Configuration::isSubversionBuild()) { - printf("scm : svn [%s r%u%s]\n", - Configuration::getSubversionBranchName(), - Configuration::getSubversionRevision(), - Configuration::hasSubversionModifications() ? - " (with modifications)" : ""); - } else { - printf("scm : no\n"); - } - printf("\n"); - printf("library : %u.%u.%u\n", - Configuration::getVersionMajor(), - Configuration::getVersionMinor(), - Configuration::getVersionRelease()); - printf("\n"); - printf("debug code : %s\n", Configuration::isDebugBuild() ? "yes" : "no"); - printf("statistics : %s\n", Configuration::isStatisticsBuild() ? "yes" : "no"); - printf("replay : %s\n", Configuration::isReplayBuild() ? "yes" : "no"); - printf("tracing : %s\n", Configuration::isTracingBuild() ? "yes" : "no"); - printf("dumping : %s\n", Configuration::isDumpingBuild() ? "yes" : "no"); - printf("muzzled : %s\n", Configuration::isMuzzledBuild() ? "yes" : "no"); - printf("assertions : %s\n", Configuration::isAssertionBuild() ? "yes" : "no"); - printf("proof : %s\n", Configuration::isProofBuild() ? "yes" : "no"); - printf("coverage : %s\n", Configuration::isCoverageBuild() ? "yes" : "no"); - printf("profiling : %s\n", Configuration::isProfilingBuild() ? "yes" : "no"); - printf("competition: %s\n", Configuration::isCompetitionBuild() ? "yes" : "no"); - printf("\n"); - printf("cudd : %s\n", Configuration::isBuiltWithCudd() ? "yes" : "no"); - printf("cln : %s\n", Configuration::isBuiltWithCln() ? "yes" : "no"); - printf("gmp : %s\n", Configuration::isBuiltWithGmp() ? "yes" : "no"); - printf("glpk : %s\n", Configuration::isBuiltWithGlpk() ? "yes" : "no"); - printf("abc : %s\n", Configuration::isBuiltWithAbc() ? "yes" : "no"); - printf("readline : %s\n", Configuration::isBuiltWithReadline() ? "yes" : "no"); - printf("tls : %s\n", Configuration::isBuiltWithTlsSupport() ? "yes" : "no"); - exit(0); -} - -inline void showDebugTags(std::string option, SmtEngine* smt) { - if(Configuration::isDebugBuild() && Configuration::isTracingBuild()) { - printf("available tags:"); - unsigned ntags = Configuration::getNumDebugTags(); - char const* const* tags = Configuration::getDebugTags(); - for(unsigned i = 0; i < ntags; ++ i) { - printf(" %s", tags[i]); - } - printf("\n"); - } else if(! Configuration::isDebugBuild()) { - throw OptionException("debug tags not available in non-debug builds"); - } else { - throw OptionException("debug tags not available in non-tracing builds"); - } - exit(0); -} - -inline void showTraceTags(std::string option, SmtEngine* smt) { - if(Configuration::isTracingBuild()) { - printf("available tags:"); - unsigned ntags = Configuration::getNumTraceTags(); - char const* const* tags = Configuration::getTraceTags(); - for (unsigned i = 0; i < ntags; ++ i) { - printf(" %s", tags[i]); - } - printf("\n"); - } else { - throw OptionException("trace tags not available in non-tracing build"); - } - exit(0); -} - -inline void threadN(std::string option, SmtEngine* smt) { - throw OptionException(option + " is not a real option by itself. Use e.g. --thread0=\"--random-seed=10 --random-freq=0.02\" --thread1=\"--random-seed=20 --random-freq=0.05\""); -} - -}/* CVC4::main namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__MAIN__OPTIONS_HANDLERS_H */ diff --git a/src/main/portfolio.cpp b/src/main/portfolio.cpp index 51b4779cc..884c3eda7 100644 --- a/src/main/portfolio.cpp +++ b/src/main/portfolio.cpp @@ -19,11 +19,12 @@ #include <boost/thread/condition.hpp> #include <boost/exception_ptr.hpp> -#include "smt/smt_engine.h" -#include "util/output.h" -#include "util/result.h" -#include "util/statistics_registry.h" +#include "base/output.h" +#include "expr/result.h" +#include "expr/statistics_registry.h" #include "options/options.h" +#include "smt/smt_engine.h" + namespace CVC4 { diff --git a/src/main/portfolio.h b/src/main/portfolio.h index f89c8f548..5a730c005 100644 --- a/src/main/portfolio.h +++ b/src/main/portfolio.h @@ -19,10 +19,10 @@ #include <boost/function.hpp> #include <utility> -#include "smt/smt_engine.h" -#include "expr/command.h" +#include "expr/statistics_registry.h" #include "options/options.h" -#include "util/statistics_registry.h" +#include "smt/smt_engine.h" +#include "smt_util/command.h" namespace CVC4 { diff --git a/src/main/portfolio_util.cpp b/src/main/portfolio_util.cpp index 7a4beb0d0..6b5fe4723 100644 --- a/src/main/portfolio_util.cpp +++ b/src/main/portfolio_util.cpp @@ -12,13 +12,16 @@ ** \brief Code relevant only for portfolio builds **/ +#include <unistd.h> + #include <cassert> #include <vector> -#include <unistd.h> + +#include "options/main_options.h" #include "options/options.h" -#include "main/options.h" -#include "prop/options.h" -#include "smt/options.h" +#include "options/prop_options.h" +#include "options/smt_options.h" +#include "smt/smt_options_handler.h" using namespace std; @@ -28,6 +31,9 @@ vector<Options> parseThreadSpecificOptions(Options opts) { vector<Options> threadOptions; +#warning "TODO: Check that the SmtEngine pointer should be NULL with Kshitij." + smt::SmtOptionsHandler optionsHandler(NULL); + unsigned numThreads = opts[options::threads]; for(unsigned i = 0; i < numThreads; ++i) { @@ -37,7 +43,7 @@ vector<Options> parseThreadSpecificOptions(Options opts) // Set thread identifier tOpts.set(options::thread_id, i); - if(i < opts[options::threadArgv].size() && + if(i < opts[options::threadArgv].size() && !opts[options::threadArgv][i].empty()) { // separate out the thread's individual configuration string @@ -60,7 +66,7 @@ vector<Options> parseThreadSpecificOptions(Options opts) *vp++ = NULL; if(targc > 1) { // this is necessary in case you do e.g. --thread0=" " try { - tOpts.parseOptions(targc, targv); + tOpts.parseOptions(targc, targv, &optionsHandler); } catch(OptionException& e) { stringstream ss; ss << optid << ": " << e.getMessage(); diff --git a/src/main/portfolio_util.h b/src/main/portfolio_util.h index 8ae730506..d6d6a2d02 100644 --- a/src/main/portfolio_util.h +++ b/src/main/portfolio_util.h @@ -17,12 +17,12 @@ #include <queue> +#include "base/output.h" #include "expr/pickler.h" +#include "options/main_options.h" +#include "smt_util/lemma_input_channel.h" +#include "smt_util/lemma_output_channel.h" #include "util/channel.h" -#include "util/lemma_input_channel.h" -#include "util/lemma_output_channel.h" -#include "util/output.h" -#include "main/options.h" namespace CVC4 { diff --git a/src/main/util.cpp b/src/main/util.cpp index f0cab25fa..86272ee53 100644 --- a/src/main/util.cpp +++ b/src/main/util.cpp @@ -28,15 +28,14 @@ #endif /* __WIN32__ */ -#include "util/exception.h" -#include "options/options.h" -#include "util/statistics.h" -#include "util/tls.h" -#include "smt/smt_engine.h" - +#include "base/exception.h" +#include "base/tls.h" #include "cvc4autoconfig.h" -#include "main/main.h" +#include "expr/statistics.h" #include "main/command_executor.h" +#include "main/main.h" +#include "options/options.h" +#include "smt/smt_engine.h" using CVC4::Exception; using namespace std; diff --git a/src/options/Makefile.am b/src/options/Makefile.am index 0d4b970d8..d871bfb0a 100644 --- a/src/options/Makefile.am +++ b/src/options/Makefile.am @@ -1,65 +1,177 @@ -OPTIONS_FILES_SRCS = \ - base_options.cpp \ - base_options.h \ - ../expr/options.cpp \ - ../expr/options.h \ - ../theory/booleans/options.cpp \ - ../theory/booleans/options.h \ - ../theory/options.cpp \ - ../theory/options.h \ - ../theory/bv/options.cpp \ - ../theory/bv/options.h \ - ../theory/datatypes/options.cpp \ - ../theory/datatypes/options.h \ - ../theory/builtin/options.cpp \ - ../theory/builtin/options.h \ - ../theory/arith/options.cpp \ - ../theory/arith/options.h \ - ../theory/uf/options.cpp \ - ../theory/uf/options.h \ - ../theory/arrays/options.cpp \ - ../theory/arrays/options.h \ - ../theory/quantifiers/options.cpp \ - ../theory/quantifiers/options.h \ - ../theory/strings/options.cpp \ - ../theory/strings/options.h \ - ../prop/options.cpp \ - ../prop/options.h \ - ../proof/options.cpp \ - ../proof/options.h \ - ../printer/options.cpp \ - ../printer/options.h \ - ../smt/options.cpp \ - ../smt/options.h \ - ../decision/options.cpp \ - ../decision/options.h \ - ../main/options.cpp \ - ../main/options.h \ - ../parser/options.cpp \ - ../parser/options.h \ - ../theory/idl/options.cpp \ - ../theory/idl/options.h \ - ../theory/sets/options.cpp \ - ../theory/sets/options.h \ - ../theory/fp/options.cpp \ - ../theory/fp/options.h - -OPTIONS_FILES = \ - $(patsubst %.cpp,%,$(filter %.cpp,$(OPTIONS_FILES_SRCS))) - -OPTIONS_CPPS = \ - $(filter %.cpp,$(OPTIONS_FILES_SRCS)) - -OPTIONS_HEADS = \ - $(filter %.h,$(OPTIONS_FILES_SRCS)) +# How options are built: +# Step 1: Copy the X_options source file into builddir as X_options.tmp. +# X_options.tmp is a .PHONY rule to force this step to always be done. +# Step 2: Compare X_options.tmp to X_options.options. +# If they are different, overwrite "X_options.options". +# This is the file that we use to generate options from. +# This is always up to dat with X_options. The change in name is just +# to keep Makefile stage more explicit. +# Step 3: Generate X_options.sed from X_options.options using mkoptions. +# Step 4: Generate X_options.h from X_options.sed +# Step 5: Generate X_options.cpp from X_options.sed. +# This stage also waits for X_options.h as otherwise it cannot compile. +# + +OPTIONS_SRC_FILES = \ + arith_options \ + arrays_options \ + base_options \ + booleans_options \ + builtin_options \ + bv_options \ + datatypes_options \ + decision_options \ + expr_options \ + fp_options \ + idl_options \ + main_options \ + parser_options \ + printer_options \ + proof_options \ + prop_options \ + quantifiers_options \ + sets_options \ + smt_options \ + strings_options \ + theory_options \ + uf_options + +OPTIONS_TEMPS = \ + arith_options.tmp \ + arrays_options.tmp \ + base_options.tmp \ + booleans_options.tmp \ + builtin_options.tmp \ + bv_options.tmp \ + datatypes_options.tmp \ + decision_options.tmp \ + expr_options.tmp \ + fp_options.tmp \ + idl_options.tmp \ + main_options.tmp \ + parser_options.tmp \ + printer_options.tmp \ + proof_options.tmp \ + prop_options.tmp \ + quantifiers_options.tmp \ + sets_options.tmp \ + smt_options.tmp \ + strings_options.tmp \ + theory_options.tmp \ + uf_options.tmp + +OPTIONS_OPTIONS_FILES = \ + arith_options.options \ + arrays_options.options \ + base_options.options \ + booleans_options.options \ + builtin_options.options \ + bv_options.options \ + datatypes_options.options \ + decision_options.options \ + expr_options.options \ + fp_options.options \ + idl_options.options \ + main_options.options \ + parser_options.options \ + printer_options.options \ + proof_options.options \ + prop_options.options \ + quantifiers_options.options \ + sets_options.options \ + smt_options.options \ + strings_options.options \ + theory_options.options \ + uf_options.options OPTIONS_SEDS = \ - $(patsubst %,%.sed,$(OPTIONS_FILES)) + arith_options.sed \ + arrays_options.sed \ + base_options.sed \ + booleans_options.sed \ + builtin_options.sed \ + bv_options.sed \ + datatypes_options.sed \ + decision_options.sed \ + expr_options.sed \ + fp_options.sed \ + idl_options.sed \ + main_options.sed \ + parser_options.sed \ + printer_options.sed \ + proof_options.sed \ + prop_options.sed \ + quantifiers_options.sed \ + sets_options.sed \ + smt_options.sed \ + strings_options.sed \ + theory_options.sed \ + uf_options.sed -OPTIONS_OBJ = \ - $(patsubst %.cpp,%.$(OBJEXT),$(OPTIONS_CPP)) +OPTIONS_HEADS = \ + arith_options.h \ + arrays_options.h \ + base_options.h \ + booleans_options.h \ + builtin_options.h \ + bv_options.h \ + datatypes_options.h \ + decision_options.h \ + expr_options.h \ + fp_options.h \ + idl_options.h \ + main_options.h \ + parser_options.h \ + printer_options.h \ + proof_options.h \ + prop_options.h \ + quantifiers_options.h \ + sets_options.h \ + smt_options.h \ + strings_options.h \ + theory_options.h \ + uf_options.h +OPTIONS_CPPS = \ + arith_options.cpp \ + arrays_options.cpp \ + base_options.cpp \ + booleans_options.cpp \ + builtin_options.cpp \ + bv_options.cpp \ + datatypes_options.cpp \ + decision_options.cpp \ + expr_options.cpp \ + fp_options.cpp \ + idl_options.cpp \ + main_options.cpp \ + parser_options.cpp \ + printer_options.cpp \ + proof_options.cpp \ + prop_options.cpp \ + quantifiers_options.cpp \ + sets_options.cpp \ + smt_options.cpp \ + strings_options.cpp \ + theory_options.cpp \ + uf_options.cpp + + +CPP_TEMPLATE_FILES = \ + base_options_template.h \ + base_options_template.cpp \ + options_holder_template.h \ + options_template.cpp \ + options_handler_get_option_template.cpp \ + options_handler_set_option_template.cpp +CPP_TEMPLATE_SEDS = \ + base_options_template.h.sed \ + base_options_template.cpp.sed \ + options_holder_template.h.sed \ + options_template.cpp.sed \ + options_handler_get_option_template.cpp.sed \ + options_handler_set_option_template.cpp.sed DOCUMENTATION_FILES = \ @@ -68,19 +180,17 @@ DOCUMENTATION_FILES = \ ../../doc/SmtEngine.3cvc \ ../../doc/options.3cvc -TEMPLATE_FILES = \ - base_options_template.h \ - base_options_template.cpp \ - options_holder_template.h \ - options_template.cpp \ - ../smt/smt_options_template.cpp \ +DOCUMENTATION_TEMPLATE_FILES = \ ../../doc/cvc4.1_template \ ../../doc/libcvc4.3_template \ ../../doc/SmtEngine.3cvc_template \ ../../doc/options.3cvc_template -TEMPLATE_SEDS = \ - $(patsubst %,%.sed,$(TEMPLATE_FILES)) +DOCUMENTATION_TEMPLATE_SEDS = \ + ../../doc/cvc4.1_template.sed \ + ../../doc/libcvc4.3_template.sed \ + ../../doc/SmtEngine.3cvc_template.sed \ + ../../doc/options.3cvc_template.sed AM_CPPFLAGS = \ -D__BUILDING_CVC4LIB \ @@ -90,63 +200,98 @@ AM_CXXFLAGS = -Wall $(FLAG_VISIBILITY_HIDDEN) noinst_LTLIBRARIES = liboptions.la liboptions_la_SOURCES = \ + 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 \ + boolean_term_conversion_mode.cpp \ + boolean_term_conversion_mode.h \ + bv_bitblast_mode.cpp \ + bv_bitblast_mode.h \ + decision_mode.cpp \ + decision_mode.h \ + decision_weight.h \ + didyoumean.cpp \ + didyoumean.h \ + language.cpp \ + language.h \ + logic_info_forward.h \ + option_exception.h \ options.h \ - base_options_handlers.h \ - option_exception.h + options_handler_interface.cpp \ + options_handler_interface.h \ + printer_modes.cpp \ + printer_modes.h \ + quantifiers_modes.cpp \ + quantifiers_modes.h \ + simplification_mode.cpp \ + simplification_mode.h \ + theoryof_mode.cpp \ + theoryof_mode.h \ + ufss_mode.h + nodist_liboptions_la_SOURCES = \ options.cpp \ options_holder.h \ - $(OPTIONS_FILES_SRCS) + $(OPTIONS_HEADS) \ + $(OPTIONS_CPPS) \ + options_handler_get_option.cpp \ + options_handler_set_option.cpp BUILT_SOURCES = \ - exprs-builts \ - ../smt/smt_options.cpp \ + $(CPP_TEMPLATE_SEDS) \ + $(DOCUMENTATION_FILES) \ + $(DOCUMENTATION_TEMPLATE_SEDS) \ + $(OPTIONS_CPPS) \ + $(OPTIONS_HEADS) \ + $(OPTIONS_OPTIONS_FILES) \ + $(OPTIONS_SEDS) \ options.cpp \ + options_handler_get_option.cpp \ + options_handler_set_option.cpp \ options_holder.h \ - $(OPTIONS_FILES_SRCS) \ - $(OPTIONS_SEDS) \ - summary.sed \ - $(TEMPLATE_SEDS) - + summary.sed -# The documentation files are added to BUILT_SOURCES to get the files to -# be built. Alternative suggestions for building these files would be -# appreciated. +# listing {Debug,Trace}_tags too ensures that make doesn't auto-remove it +# after building (if it does, we don't get the "cached" effect with +# the .tmp files below, and we have to re-compile and re-link each +# time, even when there are no changes). BUILT_SOURCES += \ - $(DOCUMENTATION_FILES) - + Debug_tags.h \ + Debug_tags \ + Trace_tags.h \ + Trace_tags CLEANFILES = \ - $(OPTIONS_FILES_SRCS) \ $(BUILT_SOURCES) \ - $(DOCUMENTATION_FILES) + $(DOCUMENTATION_FILES) \ + $(OPTIONS_TEMPS) EXTRA_DIST = \ - mkoptions \ - base_options_template.h \ + $(DOCUMENTATION_FILES) \ + $(OPTIONS_CPPS) \ + $(OPTIONS_HEADS) \ + $(OPTIONS_SRC_FILES) \ base_options_template.cpp \ - options_template.cpp \ - options_holder_template.h \ - options.i \ - option_exception.i \ - $(OPTIONS_FILES) \ + base_options_template.h \ + language.i \ + mkoptions \ mktagheaders \ mktags \ - $(DOCUMENTATION_FILES) + option_exception.i \ + options.i \ + options_handler_get_option_template.cpp \ + options_handler_interface.i \ + options_handler_set_option_template.cpp \ + options_holder_template.h \ + options_template.cpp -# listing {Debug,Trace}_tags too ensures that make doesn't auto-remove it -# after building (if it does, we don't get the "cached" effect with -# the .tmp files below, and we have to re-compile and re-link each -# time, even when there are no changes). -BUILT_SOURCES += \ - Debug_tags.h \ - Debug_tags \ - Trace_tags.h \ - Trace_tags - %_tags.h: %_tags mktagheaders $(AM_V_at)chmod +x @srcdir@/mktagheaders $(AM_V_GEN)( @srcdir@/mktagheaders "$<" "$<" ) >"$@" @@ -175,52 +320,72 @@ MOSTLYCLEANFILES = \ Debug_tags.h \ Trace_tags.h -# mkoptions template-sed template-file (options-file)* -# mkoptions apply-sed-files-to-template sed-file template-file filename +# Make sure the implicit rules never mistake a _template.cpp or _template.h file for source file. +options_holder_template.h options_template.cpp options_handler_get_option_template.cpp options_handler_set_option_template.cpp base_options_template.h base_options_template.cpp :; + +# Make sure the implicit rules never mistake X_options for the -o file for a +# CPP file. +arith_options arrays_options base_options booleans_options builtin_options bv_options datatypes_options decision_options expr_options fp_options idl_options main_options parser_options printer_options proof_options prop_options quantifiers_options sets_options smt_options strings_options theory_options uf_options:; -$(OPTIONS_FILES):; -options_holder_template.h options_template.cpp ../smt/smt_options_template.cpp base_options_template.h base_options_template.cpp :; +# These are phony to force them to be made everytime. +.PHONY: arith_options.tmp arrays_options.tmp base_options.tmp booleans_options.tmp builtin_options.tmp bv_options.tmp datatypes_options.tmp decision_options.tmp expr_options.tmp fp_options.tmp idl_options.tmp main_options.tmp parser_options.tmp printer_options.tmp proof_options.tmp prop_options.tmp quantifiers_options.tmp sets_options.tmp smt_options.tmp strings_options.tmp theory_options.tmp uf_options.tmp + +# Make is happier being listed explictly. Not sure why. +arith_options.tmp arrays_options.tmp base_options.tmp booleans_options.tmp builtin_options.tmp bv_options.tmp datatypes_options.tmp decision_options.tmp expr_options.tmp fp_options.tmp idl_options.tmp main_options.tmp parser_options.tmp printer_options.tmp proof_options.tmp prop_options.tmp quantifiers_options.tmp sets_options.tmp smt_options.tmp strings_options.tmp theory_options.tmp uf_options.tmp: + echo "$@" "$(@:.tmp=)" + $(AM_V_GEN)(cp "@srcdir@/$(@:.tmp=)" "$@" || true) +#TIM: +#The (... || true) here is to make distcheck not fail. + +%_options.options: %_options.tmp + $(AM_V_GEN)\ + diff -q "$^" "$@" &>/dev/null || mv "$^" "$@" || true -$(TEMPLATE_SEDS) : %.sed : % mkoptions + +# This bit is kinda tricky. +# We use the updating of %_options.options to signal that the options file updated. +# However, we use the original file in src to generate the file. +%_options.sed: %_options.options mkoptions + $(AM_V_at)chmod +x @srcdir@/mkoptions + $(AM_V_GEN)(@srcdir@/mkoptions module-sed "@srcdir@/$(@:.sed=)" ) > "$@" + + +$(CPP_TEMPLATE_SEDS): %.sed : % mkoptions # echo "template seds" # echo "$@" # echo $(TEMPLATE_SEDS) $(AM_V_at)chmod +x @srcdir@/mkoptions $(AM_V_GEN)(@srcdir@/mkoptions template-sed "$<" ) > "$@" - -$(OPTIONS_SEDS) : %.sed : % mkoptions -# echo "sedheads" +$(DOCUMENTATION_TEMPLATE_SEDS): %.sed : % mkoptions +# echo "template seds" # echo "$@" -# echo $(OPTIONS_SEDS) +# echo $(TEMPLATE_SEDS) $(AM_V_at)chmod +x @srcdir@/mkoptions - $(AM_V_at)mkdir -p `dirname "$@"` - $(AM_V_GEN)(@srcdir@/mkoptions module-sed "$<" ) > "$@" + $(AM_V_GEN)(@srcdir@/mkoptions template-sed "$<" ) > "$@" -$(OPTIONS_HEADS) : %.h : %.sed mkoptions base_options_template.h base_options_template.h.sed +%_options.h : %_options.sed mkoptions base_options_template.h base_options_template.h.sed # echo heads # echo "$@" # echo $(OPTIONS_HEADS) $(AM_V_at)chmod +x @srcdir@/mkoptions - $(AM_V_at)mkdir -p `dirname "$@"` $(AM_V_GEN)(@srcdir@/mkoptions apply-sed-files-to-template \ @srcdir@/base_options_template.h \ base_options_template.h.sed \ "$<" \ ) > "$@" -summary.sed : mkoptions $(OPTIONS_FILES) +summary.sed : mkoptions $(OPTIONS_OPTIONS_FILES) $(AM_V_at)chmod +x @srcdir@/mkoptions $(AM_V_GEN)(@srcdir@/mkoptions summary-sed \ - $(foreach o,$(OPTIONS_FILES),"$(srcdir)/$(o)") \ + $(OPTIONS_OPTIONS_FILES) \ ) > summary.sed # mkoptions apply-sed-to-template sed-file template-file -options_holder.h : options_holder_template.h options_holder_template.h.sed summary.sed mkoptions -# echo "$(OPTIONS_FILES)" +options_holder.h : options_holder_template.h options_holder_template.h.sed summary.sed mkoptions $(OPTIONS_HEADS) $(AM_V_at)chmod +x @srcdir@/mkoptions $(AM_V_GEN)(@srcdir@/mkoptions apply-sed-files-to-template \ @srcdir@/options_holder_template.h \ @@ -228,19 +393,9 @@ options_holder.h : options_holder_template.h options_holder_template.h.sed summa summary.sed \ ) > "$@" -gen-heads-stamp : $(OPTIONS_HEADS) options_holder.h -.PHONY : gen-heads-stamp - - -# Bit of a hack here. The .h file needs to always be built before the .cpp file is compiled. -$(OPTIONS_CPPS) : %.cpp : %.sed mkoptions base_options_template.cpp base_options_template.cpp.sed gen-heads-stamp -# echo "cpps" -# echo "$@" -# echo "$<" -# echo $(OPTIONS_CPPS) -# echo $(OPTIONS_FILES_SRCS) +# Make sure not to match with "options.cpp" too. +%_options.cpp: %_options.sed %_options.h mkoptions options_holder.h base_options_template.cpp base_options_template.cpp.sed $(AM_V_at)chmod +x @srcdir@/mkoptions - $(AM_V_at)mkdir -p `dirname "$@"` $(AM_V_GEN)(@srcdir@/mkoptions apply-sed-files-to-template \ @srcdir@/base_options_template.cpp \ base_options_template.cpp.sed \ @@ -249,9 +404,9 @@ $(OPTIONS_CPPS) : %.cpp : %.sed mkoptions base_options_template.cpp base_options + # mkoptions apply-sed-to-template sed-file template-file -options.cpp : options_template.cpp options_template.cpp.sed mkoptions summary.sed gen-heads-stamp -# echo "$(OPTIONS_FILES)" +options.cpp : options_template.cpp options_template.cpp.sed mkoptions summary.sed $(OPTIONS_HEADS) options_holder.h $(AM_V_at)chmod +x @srcdir@/mkoptions $(AM_V_GEN)(@srcdir@/mkoptions apply-sed-files-to-template \ @srcdir@/options_template.cpp \ @@ -261,15 +416,21 @@ options.cpp : options_template.cpp options_template.cpp.sed mkoptions summary.se # mkoptions apply-sed-to-template sed-file template-file -../smt/smt_options.cpp : ../smt/smt_options_template.cpp ../smt/smt_options_template.cpp.sed mkoptions summary.sed gen-heads-stamp -# echo "$(OPTIONS_FILES)" +options_handler_get_option.cpp : options_handler_get_option_template.cpp options_handler_get_option_template.cpp.sed mkoptions summary.sed $(OPTIONS_HEADS) $(AM_V_at)chmod +x @srcdir@/mkoptions $(AM_V_GEN)(@srcdir@/mkoptions apply-sed-files-to-template \ - @srcdir@/../smt/smt_options_template.cpp \ - @builddir@/../smt/smt_options_template.cpp.sed \ + @srcdir@/options_handler_get_option_template.cpp \ + @builddir@/options_handler_get_option_template.cpp.sed \ summary.sed \ ) > "$@" +options_handler_set_option.cpp : options_handler_set_option_template.cpp options_handler_set_option_template.cpp.sed mkoptions summary.sed $(OPTIONS_HEADS) + $(AM_V_at)chmod +x @srcdir@/mkoptions + $(AM_V_GEN)(@srcdir@/mkoptions apply-sed-files-to-template \ + @srcdir@/options_handler_set_option_template.cpp \ + @builddir@/options_handler_set_option_template.cpp.sed \ + summary.sed \ + ) > "$@" @@ -285,7 +446,7 @@ $(DOCUMENTATION_FILES) : % : %_template %_template.sed mkoptions summary.sed -#options-stamp: options_holder_template.h options_template.cpp ../smt/smt_options_template.cpp base_options_template.h base_options_template.cpp mkoptions $(OPTIONS_FILE_SRCS) +#options-stamp: options_holder_template.h options_template.cpp smt_options_template.cpp base_options_template.h base_options_template.cpp mkoptions $(OPTIONS_FILE_SRCS) # This rule is ugly. It's needed to ensure that automake's dependence @@ -294,65 +455,3 @@ $(DOCUMENTATION_FILES) : % : %_template %_template.sed mkoptions summary.sed # fails. %.Plo:; $(MKDIR_P) "$(dir $@)" && : > "$@" -# Tim: -# This is insanely ugly and brittle! -# *Any* proposal to clean this up is welcomed! -# We are overloading automake's default distclean here. We have to overload -# distclean because otherwise it deletes the dependency directory -# "src/expr/.deps", then when running make distclean in src/expr it attempts to -# include .Plo files "defined in src/expr/.deps". -# An example from src/expr/Makefile.ina : -# @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/attribute.Plo@am__quote@ -# The include must fail because this make file deleted that directory and -# distclean cannot proceed. So we override distclean to only remove -# "-rm -rf ./$(DEPDIR)". We then do manual massaging to finish up removing the -# extra files. To reproduce this, you can comment out the distclean below, run -# a distcheck and repeat this process. -# Why was this not a problem before? I do not know. -MANUAL_RM = \ - $(CLEANFILES) \ - ../main/.dirstamp \ - ../expr/.dirstamp \ - ../options/options.lo \ - ../options/base_options.lo \ - ../options/.libs/options.o \ - ../options/.libs/base_options.o \ - ../options/.libs/liboptions.a \ - ../options/Trace_tags.tmp \ - ../options/Debug_tags.tmp \ - ../options/liboptions.la \ - ../parser/.dirstamp \ - ../expr/.deps/options.Plo \ - ../main/.deps/options.Plo \ - ../parser/.deps/options.Plo \ - ../prop/options.lo \ - ../decision/options.lo \ - ../printer/options.lo \ - ../proof/options.lo \ - ../smt/options.lo \ - ../theory/arith/options.lo \ - ../theory/arrays/options.lo \ - ../theory/booleans/options.lo \ - ../theory/builtin/options.lo \ - ../theory/bv/options.lo \ - ../theory/datatypes/options.lo \ - ../theory/fp/options.lo \ - ../theory/idl/options.lo \ - ../theory/quantifiers/options.lo \ - ../theory/sets/options.lo \ - ../theory/strings/options.lo \ - ../theory/test_newalttheory/options.lo \ - ../theory/test_newtheory/options.lo \ - ../theory/uf/options.lo \ - ../theory/options.lo - - - -distclean: - -rm -rf ./$(DEPDIR) - -rm -f Makefile - -rm -f $(MANUAL_RM) - -.PHONY: exprs-builts -exprs-builts:; $(AM_V_at)[ "$(FROM_EXPR)" != 1 ] && $(MAKE) -C ../expr builts || true - diff --git a/src/theory/arith/arith_heuristic_pivot_rule.cpp b/src/options/arith_heuristic_pivot_rule.cpp index 8ef2385c7..ff5f2102a 100644 --- a/src/theory/arith/arith_heuristic_pivot_rule.cpp +++ b/src/options/arith_heuristic_pivot_rule.cpp @@ -15,7 +15,7 @@ ** \todo document this file **/ -#include "theory/arith/arith_heuristic_pivot_rule.h" +#include "options/arith_heuristic_pivot_rule.h" namespace CVC4 { @@ -38,4 +38,3 @@ std::ostream& operator<<(std::ostream& out, ErrorSelectionRule rule) { } }/* CVC4 namespace */ - diff --git a/src/theory/arith/arith_heuristic_pivot_rule.h b/src/options/arith_heuristic_pivot_rule.h index a64a7c846..e44b8105b 100644 --- a/src/theory/arith/arith_heuristic_pivot_rule.h +++ b/src/options/arith_heuristic_pivot_rule.h @@ -24,12 +24,12 @@ namespace CVC4 { -typedef enum { +enum ErrorSelectionRule { VAR_ORDER, MINIMUM_AMOUNT, MAXIMUM_AMOUNT, SUM_METRIC -} ErrorSelectionRule; +}; std::ostream& operator<<(std::ostream& out, ErrorSelectionRule rule) CVC4_PUBLIC; diff --git a/src/theory/arith/options b/src/options/arith_options index ea9658eb3..9737d5382 100644 --- a/src/theory/arith/options +++ b/src/options/arith_options @@ -3,12 +3,12 @@ # See src/options/base_options for a description of this file format # -module ARITH "theory/arith/options.h" Arithmetic theory +module ARITH "options/arith_options.h" Arithmetic theory -option arithUnateLemmaMode --unate-lemmas=MODE ArithUnateLemmaMode :handler CVC4::theory::arith::stringToArithUnateLemmaMode :default ALL_PRESOLVE_LEMMAS :handler-include "theory/arith/options_handlers.h" :include "theory/arith/arith_unate_lemma_mode.h" +option arithUnateLemmaMode --unate-lemmas=MODE ArithUnateLemmaMode :handler CVC4::options::stringToArithUnateLemmaMode :default ALL_PRESOLVE_LEMMAS :handler-include "options/options_handler_interface.h" :include "options/arith_unate_lemma_mode.h" determines which lemmas to add before solving (default is 'all', see --unate-lemmas=help) -option arithPropagationMode --arith-prop=MODE ArithPropagationMode :handler CVC4::theory::arith::stringToArithPropagationMode :default BOTH_PROP :handler-include "theory/arith/options_handlers.h" :include "theory/arith/arith_propagation_mode.h" +option arithPropagationMode --arith-prop=MODE ArithPropagationMode :handler CVC4::options::stringToArithPropagationMode :default BOTH_PROP :handler-include "options/options_handler_interface.h" :include "options/arith_propagation_mode.h" turns on arithmetic propagation (default is 'old', see --arith-prop=help) # The maximum number of difference pivots to do per invocation of simplex. @@ -25,7 +25,7 @@ option arithHeuristicPivots --heuristic-pivots=N int16_t :default 0 :read-write expert-option arithStandardCheckVarOrderPivots --standard-effort-variable-order-pivots=N int16_t :default -1 :read-write limits the number of pivots in a single invocation of check() at a non-full effort level using Bland's pivot rule -option arithErrorSelectionRule --error-selection-rule=RULE ErrorSelectionRule :handler CVC4::theory::arith::stringToErrorSelectionRule :default MINIMUM_AMOUNT :handler-include "theory/arith/options_handlers.h" :include "theory/arith/arith_heuristic_pivot_rule.h" +option arithErrorSelectionRule --error-selection-rule=RULE ErrorSelectionRule :handler CVC4::options::stringToErrorSelectionRule :default MINIMUM_AMOUNT :handler-include "options/options_handler_interface.h" :include "options/arith_heuristic_pivot_rule.h" change the pivot rule for the basic variable (default is 'min', see --pivot-rule help) # The number of pivots before simplex rechecks every basic variable for a conflict diff --git a/src/theory/arith/arith_propagation_mode.cpp b/src/options/arith_propagation_mode.cpp index 119761906..7f18a0356 100644 --- a/src/theory/arith/arith_propagation_mode.cpp +++ b/src/options/arith_propagation_mode.cpp @@ -15,7 +15,7 @@ ** \todo document this file **/ -#include "theory/arith/arith_propagation_mode.h" +#include "options/arith_propagation_mode.h" namespace CVC4 { @@ -41,4 +41,3 @@ std::ostream& operator<<(std::ostream& out, ArithPropagationMode mode) { } }/* CVC4 namespace */ - diff --git a/src/theory/arith/arith_propagation_mode.h b/src/options/arith_propagation_mode.h index fe8f8c9cc..fa89496f0 100644 --- a/src/theory/arith/arith_propagation_mode.h +++ b/src/options/arith_propagation_mode.h @@ -24,12 +24,12 @@ namespace CVC4 { -typedef enum { +enum ArithPropagationMode { NO_PROP, UNATE_PROP, BOUND_INFERENCE_PROP, BOTH_PROP -} ArithPropagationMode; +}; std::ostream& operator<<(std::ostream& out, ArithPropagationMode rule) CVC4_PUBLIC; diff --git a/src/theory/arith/arith_unate_lemma_mode.cpp b/src/options/arith_unate_lemma_mode.cpp index bb6066bb4..55fd8a01f 100644 --- a/src/theory/arith/arith_unate_lemma_mode.cpp +++ b/src/options/arith_unate_lemma_mode.cpp @@ -15,7 +15,7 @@ ** \todo document this file **/ -#include "theory/arith/arith_unate_lemma_mode.h" +#include "options/arith_unate_lemma_mode.h" namespace CVC4 { @@ -41,4 +41,3 @@ std::ostream& operator<<(std::ostream& out, ArithUnateLemmaMode mode) { } }/* CVC4 namespace */ - diff --git a/src/theory/arith/arith_unate_lemma_mode.h b/src/options/arith_unate_lemma_mode.h index 5e1362bcb..5e1362bcb 100644 --- a/src/theory/arith/arith_unate_lemma_mode.h +++ b/src/options/arith_unate_lemma_mode.h diff --git a/src/theory/arrays/options b/src/options/arrays_options index 8ed80c1f1..096d773ca 100644 --- a/src/theory/arrays/options +++ b/src/options/arrays_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module ARRAYS "theory/arrays/options.h" Arrays theory +module ARRAYS "options/arrays_options.h" Arrays theory option arraysOptimizeLinear --arrays-optimize-linear bool :default true :read-write turn on optimization for linear array terms (see de Moura FMCAD 09 arrays paper) diff --git a/src/options/base_handlers.h b/src/options/base_handlers.h new file mode 100644 index 000000000..b37dde5c6 --- /dev/null +++ b/src/options/base_handlers.h @@ -0,0 +1,85 @@ +/********************* */ +/*! \file base_handlers.h + ** \verbatim + ** Original author: Morgan Deters + ** Major contributors: Kshitij Bansal + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** 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__BASE_HANDLERS_H +#define __CVC4__BASE_HANDLERS_H + +#include <iostream> +#include <string> +#include <sstream> + +namespace CVC4 { +namespace options { + +template <template <class U> class Cmp> +class comparator { + long d_lbound; + double d_dbound; + bool d_hasLbound; + +public: + comparator(int i) throw() : d_lbound(i), d_dbound(0.0), d_hasLbound(true) {} + comparator(long l) throw() : d_lbound(l), d_dbound(0.0), d_hasLbound(true) {} + comparator(double d) throw() : d_lbound(0), d_dbound(d), d_hasLbound(false) {} + + template <class T> + void operator()(std::string option, const T& value, OptionsHandler* handler) { + if((d_hasLbound && !(Cmp<T>()(value, T(d_lbound)))) || + (!d_hasLbound && !(Cmp<T>()(value, T(d_dbound))))) { + std::stringstream ss; + ss << option << ": " << value << " is not a legal setting"; + throw OptionException(ss.str()); + } + } +};/* class comparator */ + +struct greater : public comparator<std::greater> { + greater(int i) throw() : comparator<std::greater>(i) {} + greater(long l) throw() : comparator<std::greater>(l) {} + greater(double d) throw() : comparator<std::greater>(d) {} +};/* struct greater */ + +struct greater_equal : public comparator<std::greater_equal> { + greater_equal(int i) throw() : comparator<std::greater_equal>(i) {} + greater_equal(long l) throw() : comparator<std::greater_equal>(l) {} + greater_equal(double d) throw() : comparator<std::greater_equal>(d) {} +};/* struct greater_equal */ + +struct less : public comparator<std::less> { + less(int i) throw() : comparator<std::less>(i) {} + less(long l) throw() : comparator<std::less>(l) {} + less(double d) throw() : comparator<std::less>(d) {} +};/* struct less */ + +struct less_equal : public comparator<std::less_equal> { + less_equal(int i) throw() : comparator<std::less_equal>(i) {} + less_equal(long l) throw() : comparator<std::less_equal>(l) {} + less_equal(double d) throw() : comparator<std::less_equal>(d) {} +};/* struct less_equal */ + +struct not_equal : public comparator<std::not_equal_to> { + not_equal(int i) throw() : comparator<std::not_equal_to>(i) {} + not_equal(long l) throw() : comparator<std::not_equal_to>(l) {} + not_equal(double d) throw() : comparator<std::not_equal_to>(d) {} +};/* struct not_equal_to */ + +}/* CVC4::options namespace */ +}/* CVC4 namespace */ + +#endif /* __CVC4__BASE_HANDLERS_H */ diff --git a/src/options/base_options b/src/options/base_options index ed94e68f6..588220817 100644 --- a/src/options/base_options +++ b/src/options/base_options @@ -85,9 +85,9 @@ option in std::istream* :default &std::cin :include <iostream> option out std::ostream* :default &std::cout :include <iostream> option err std::ostream* :default &std::cerr :include <iostream> -common-option inputLanguage input-language -L --lang=LANG InputLanguage :handler CVC4::options::stringToInputLanguage :include "util/language.h" :default language::input::LANG_AUTO :read-write +common-option inputLanguage input-language -L --lang=LANG InputLanguage :handler CVC4::options::stringToInputLanguage :include "options/language.h" :default language::input::LANG_AUTO :read-write force input language (default is "auto"; see --lang help) -common-option outputLanguage output-language --output-lang=LANG OutputLanguage :handler CVC4::options::stringToOutputLanguage :include "util/language.h" :default language::output::LANG_AUTO :read-write +common-option outputLanguage output-language --output-lang=LANG OutputLanguage :handler CVC4::options::stringToOutputLanguage :include "options/language.h" :default language::output::LANG_AUTO :read-write force output language (default is "auto"; see --output-lang help) option languageHelp bool @@ -96,14 +96,14 @@ option languageHelp bool undocumented-alias --language=L = --lang=L undocumented-alias --output-language=L = --output-lang=L -option verbosity verbosity int :read-write :default 0 :predicate CVC4::options::setVerbosity :predicate-include "options/base_options_handlers.h" +option verbosity verbosity int :read-write :default 0 :predicate CVC4::options::setVerbosity :predicate-include "options/base_handlers.h" the verbosity level of CVC4 common-option - -v --verbose void :handler CVC4::options::increaseVerbosity increase verbosity (may be repeated) common-option - -q --quiet void :handler CVC4::options::decreaseVerbosity decrease verbosity (may be repeated) -common-option statistics statistics --stats bool :predicate CVC4::smt::statsEnabledBuild :predicate-include "smt/options_handlers.h" +common-option statistics statistics --stats bool :predicate CVC4::options::statsEnabledBuild :predicate-include "options/options_handler_interface.h" give statistics on exit undocumented-alias --statistics = --stats undocumented-alias --no-statistics = --no-stats @@ -128,7 +128,7 @@ option - trace -t --trace=TAG argument :handler CVC4::options::addTraceTag option - debug -d --debug=TAG argument :handler CVC4::options::addDebugTag debug something (e.g. -d arith), can repeat -option printSuccess print-success --print-success bool :predicate CVC4::options::setPrintSuccess :predicate-include "options/base_options_handlers.h" +option printSuccess print-success --print-success bool :predicate CVC4::options::setPrintSuccess :predicate-include "options/options_handler_interface.h" print the "success" output required of SMT-LIBv2 alias --smtlib-strict = --lang=smt2 --output-lang=smt2 --strict-parsing --default-expr-depth=-1 --print-success --incremental --abstract-values diff --git a/src/options/base_options_handlers.h b/src/options/base_options_handlers.h deleted file mode 100644 index ac3194f29..000000000 --- a/src/options/base_options_handlers.h +++ /dev/null @@ -1,241 +0,0 @@ -/********************* */ -/*! \file base_options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: Kshitij Bansal - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** 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__BASE_OPTIONS_HANDLERS_H -#define __CVC4__BASE_OPTIONS_HANDLERS_H - -#include <iostream> -#include <string> -#include <sstream> - -#include "expr/command.h" -#include "util/didyoumean.h" -#include "util/language.h" - -namespace CVC4 { -namespace options { - -inline void setVerbosity(std::string option, int value, SmtEngine* smt) throw(OptionException) { - if(Configuration::isMuzzledBuild()) { - DebugChannel.setStream(CVC4::null_os); - TraceChannel.setStream(CVC4::null_os); - NoticeChannel.setStream(CVC4::null_os); - ChatChannel.setStream(CVC4::null_os); - MessageChannel.setStream(CVC4::null_os); - WarningChannel.setStream(CVC4::null_os); - } else { - if(value < 2) { - ChatChannel.setStream(CVC4::null_os); - } else { - ChatChannel.setStream(std::cout); - } - if(value < 1) { - NoticeChannel.setStream(CVC4::null_os); - } else { - NoticeChannel.setStream(std::cout); - } - if(value < 0) { - MessageChannel.setStream(CVC4::null_os); - WarningChannel.setStream(CVC4::null_os); - } else { - MessageChannel.setStream(std::cout); - WarningChannel.setStream(std::cerr); - } - } -} - -inline void increaseVerbosity(std::string option, SmtEngine* smt) { - options::verbosity.set(options::verbosity() + 1); - setVerbosity(option, options::verbosity(), smt); -} - -inline void decreaseVerbosity(std::string option, SmtEngine* smt) { - options::verbosity.set(options::verbosity() - 1); - setVerbosity(option, options::verbosity(), smt); -} - -inline OutputLanguage stringToOutputLanguage(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "help") { - options::languageHelp.set(true); - return language::output::LANG_AUTO; - } - - try { - return language::toOutputLanguage(optarg); - } catch(OptionException& oe) { - throw OptionException("Error in " + option + ": " + oe.getMessage() + "\nTry --output-language help"); - } - - Unreachable(); -} - -inline InputLanguage stringToInputLanguage(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "help") { - options::languageHelp.set(true); - return language::input::LANG_AUTO; - } - - try { - return language::toInputLanguage(optarg); - } catch(OptionException& oe) { - throw OptionException("Error in " + option + ": " + oe.getMessage() + "\nTry --language help"); - } - - Unreachable(); -} - -inline std::string suggestTags(char const* const* validTags, std::string inputTag, - char const* const* additionalTags = NULL) -{ - DidYouMean didYouMean; - - const char* opt; - for(size_t i = 0; (opt = validTags[i]) != NULL; ++i) { - didYouMean.addWord(validTags[i]); - } - if(additionalTags != NULL) { - for(size_t i = 0; (opt = additionalTags[i]) != NULL; ++i) { - didYouMean.addWord(additionalTags[i]); - } - } - - return didYouMean.getMatchAsString(inputTag); -} - -inline void addTraceTag(std::string option, std::string optarg, SmtEngine* smt) { - if(Configuration::isTracingBuild()) { - if(!Configuration::isTraceTag(optarg.c_str())) { - - if(optarg == "help") { - printf("available tags:"); - unsigned ntags = Configuration::getNumTraceTags(); - char const* const* tags = Configuration::getTraceTags(); - for(unsigned i = 0; i < ntags; ++ i) { - printf(" %s", tags[i]); - } - printf("\n"); - exit(0); - } - - throw OptionException(std::string("trace tag ") + optarg + - std::string(" not available.") + - suggestTags(Configuration::getTraceTags(), optarg) ); - } - } else { - throw OptionException("trace tags not available in non-tracing builds"); - } - Trace.on(optarg); -} - -inline void addDebugTag(std::string option, std::string optarg, SmtEngine* smt) { - if(Configuration::isDebugBuild() && Configuration::isTracingBuild()) { - if(!Configuration::isDebugTag(optarg.c_str()) && - !Configuration::isTraceTag(optarg.c_str())) { - - if(optarg == "help") { - printf("available tags:"); - unsigned ntags = Configuration::getNumDebugTags(); - char const* const* tags = Configuration::getDebugTags(); - for(unsigned i = 0; i < ntags; ++ i) { - printf(" %s", tags[i]); - } - printf("\n"); - exit(0); - } - - throw OptionException(std::string("debug tag ") + optarg + - std::string(" not available.") + - suggestTags(Configuration::getDebugTags(), optarg, Configuration::getTraceTags()) ); - } - } else if(! Configuration::isDebugBuild()) { - throw OptionException("debug tags not available in non-debug builds"); - } else { - throw OptionException("debug tags not available in non-tracing builds"); - } - Debug.on(optarg); - Trace.on(optarg); -} - -inline void setPrintSuccess(std::string option, bool value, SmtEngine* smt) { - Debug.getStream() << Command::printsuccess(value); - Trace.getStream() << Command::printsuccess(value); - Notice.getStream() << Command::printsuccess(value); - Chat.getStream() << Command::printsuccess(value); - Message.getStream() << Command::printsuccess(value); - Warning.getStream() << Command::printsuccess(value); - *options::out() << Command::printsuccess(value); -} - -template <template <class U> class Cmp> -class comparator { - long d_lbound; - double d_dbound; - bool d_hasLbound; - -public: - comparator(int i) throw() : d_lbound(i), d_dbound(0.0), d_hasLbound(true) {} - comparator(long l) throw() : d_lbound(l), d_dbound(0.0), d_hasLbound(true) {} - comparator(double d) throw() : d_lbound(0), d_dbound(d), d_hasLbound(false) {} - - template <class T> - void operator()(std::string option, const T& value, SmtEngine* smt) { - if((d_hasLbound && !(Cmp<T>()(value, T(d_lbound)))) || - (!d_hasLbound && !(Cmp<T>()(value, T(d_dbound))))) { - std::stringstream ss; - ss << option << ": " << value << " is not a legal setting"; - throw OptionException(ss.str()); - } - } -};/* class comparator */ - -struct greater : public comparator<std::greater> { - greater(int i) throw() : comparator<std::greater>(i) {} - greater(long l) throw() : comparator<std::greater>(l) {} - greater(double d) throw() : comparator<std::greater>(d) {} -};/* struct greater */ - -struct greater_equal : public comparator<std::greater_equal> { - greater_equal(int i) throw() : comparator<std::greater_equal>(i) {} - greater_equal(long l) throw() : comparator<std::greater_equal>(l) {} - greater_equal(double d) throw() : comparator<std::greater_equal>(d) {} -};/* struct greater_equal */ - -struct less : public comparator<std::less> { - less(int i) throw() : comparator<std::less>(i) {} - less(long l) throw() : comparator<std::less>(l) {} - less(double d) throw() : comparator<std::less>(d) {} -};/* struct less */ - -struct less_equal : public comparator<std::less_equal> { - less_equal(int i) throw() : comparator<std::less_equal>(i) {} - less_equal(long l) throw() : comparator<std::less_equal>(l) {} - less_equal(double d) throw() : comparator<std::less_equal>(d) {} -};/* struct less_equal */ - -struct not_equal : public comparator<std::not_equal_to> { - not_equal(int i) throw() : comparator<std::not_equal_to>(i) {} - not_equal(long l) throw() : comparator<std::not_equal_to>(l) {} - not_equal(double d) throw() : comparator<std::not_equal_to>(d) {} -};/* struct not_equal_to */ - -}/* CVC4::options namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__BASE_OPTIONS_HANDLERS_H */ - diff --git a/src/theory/booleans/boolean_term_conversion_mode.cpp b/src/options/boolean_term_conversion_mode.cpp index b8647eb3c..efeb3ab16 100644 --- a/src/theory/booleans/boolean_term_conversion_mode.cpp +++ b/src/options/boolean_term_conversion_mode.cpp @@ -14,9 +14,10 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ +#include "options/boolean_term_conversion_mode.h" #include <iostream> -#include "theory/booleans/boolean_term_conversion_mode.h" + namespace CVC4 { diff --git a/src/theory/booleans/boolean_term_conversion_mode.h b/src/options/boolean_term_conversion_mode.h index 5671dea13..5671dea13 100644 --- a/src/theory/booleans/boolean_term_conversion_mode.h +++ b/src/options/boolean_term_conversion_mode.h diff --git a/src/theory/booleans/options b/src/options/booleans_options index 6c571f30e..2e2cbee1f 100644 --- a/src/theory/booleans/options +++ b/src/options/booleans_options @@ -3,9 +3,9 @@ # See src/options/base_options for a description of this file format # -module BOOLEANS "theory/booleans/options.h" Boolean theory +module BOOLEANS "options/booleans_options.h" Boolean theory -option booleanTermConversionMode boolean-term-conversion-mode --boolean-term-conversion-mode=MODE CVC4::theory::booleans::BooleanTermConversionMode :default CVC4::theory::booleans::BOOLEAN_TERM_CONVERT_TO_BITVECTORS :include "theory/booleans/boolean_term_conversion_mode.h" :handler CVC4::theory::booleans::stringToBooleanTermConversionMode :handler-include "theory/booleans/options_handlers.h" +option booleanTermConversionMode boolean-term-conversion-mode --boolean-term-conversion-mode=MODE CVC4::theory::booleans::BooleanTermConversionMode :default CVC4::theory::booleans::BOOLEAN_TERM_CONVERT_TO_BITVECTORS :include "options/boolean_term_conversion_mode.h" :handler CVC4::options::stringToBooleanTermConversionMode :handler-include "options/options_handler_interface.h" policy for converting Boolean terms endmodule diff --git a/src/theory/builtin/options b/src/options/builtin_options index 699f361c9..ea4229b67 100644 --- a/src/theory/builtin/options +++ b/src/options/builtin_options @@ -3,6 +3,6 @@ # See src/options/base_options for a description of this file format # -module BUILTIN "theory/builtin/options.h" Builtin theory +module BUILTIN "options/builtin_options.h" Builtin theory endmodule diff --git a/src/theory/bv/bitblast_mode.cpp b/src/options/bv_bitblast_mode.cpp index 51c0290af..9576134f6 100644 --- a/src/theory/bv/bitblast_mode.cpp +++ b/src/options/bv_bitblast_mode.cpp @@ -14,14 +14,14 @@ ** Bitblast modes for bit-vector solver. **/ -#include "theory/bv/bitblast_mode.h" +#include "options/bv_bitblast_mode.h" namespace CVC4 { std::ostream& operator<<(std::ostream& out, theory::bv::BitblastMode mode) { switch(mode) { case theory::bv::BITBLAST_MODE_LAZY: - out << "BITBLAST_MODE_LAZY"; + out << "BITBLAST_MODE_LAZY"; break; case theory::bv::BITBLAST_MODE_EAGER: out << "BITBLAST_MODE_EAGER"; @@ -36,7 +36,7 @@ std::ostream& operator<<(std::ostream& out, theory::bv::BitblastMode mode) { std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode) { switch(mode) { case theory::bv::BITVECTOR_SLICER_ON: - out << "BITVECTOR_SLICER_ON"; + out << "BITVECTOR_SLICER_ON"; break; case theory::bv::BITVECTOR_SLICER_OFF: out << "BITVECTOR_SLICER_OFF"; @@ -51,5 +51,4 @@ std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode) { return out; } - }/* CVC4 namespace */ diff --git a/src/theory/bv/bitblast_mode.h b/src/options/bv_bitblast_mode.h index 89ecdc381..89ecdc381 100644 --- a/src/theory/bv/bitblast_mode.h +++ b/src/options/bv_bitblast_mode.h diff --git a/src/theory/bv/options b/src/options/bv_options index eba4608d2..73790b562 100644 --- a/src/theory/bv/options +++ b/src/options/bv_options @@ -3,18 +3,18 @@ # See src/options/base_options for a description of this file format # -module BV "theory/bv/options.h" Bitvector theory +module BV "options/bv_options.h" Bitvector theory # Option to set the bit-blasting mode (lazy, eager) -option bitblastMode bitblast --bitblast=MODE CVC4::theory::bv::BitblastMode :handler CVC4::theory::bv::stringToBitblastMode :default CVC4::theory::bv::BITBLAST_MODE_LAZY :read-write :include "theory/bv/bitblast_mode.h" :handler-include "theory/bv/options_handlers.h" +option bitblastMode bitblast --bitblast=MODE CVC4::theory::bv::BitblastMode :handler CVC4::options::stringToBitblastMode :default CVC4::theory::bv::BITBLAST_MODE_LAZY :read-write :include "options/bv_bitblast_mode.h" :handler-include "options/options_handler_interface.h" choose bitblasting mode, see --bitblast=help # Options for eager bit-blasting -option bitvectorAig --bitblast-aig bool :default false :predicate CVC4::theory::bv::abcEnabledBuild CVC4::theory::bv::setBitblastAig :predicate-include "theory/bv/options_handlers.h" :read-write +option bitvectorAig --bitblast-aig bool :default false :predicate CVC4::options::abcEnabledBuild CVC4::options::setBitblastAig :predicate-include "options/options_handler_interface.h" :read-write bitblast by first converting to AIG (implies --bitblast=eager) -expert-option bitvectorAigSimplifications --bv-aig-simp=COMMAND std::string :default "" :predicate CVC4::theory::bv::abcEnabledBuild :read-write :link --bitblast-aig :link-smt bitblast-aig +expert-option bitvectorAigSimplifications --bv-aig-simp=COMMAND std::string :default "" :predicate CVC4::options::abcEnabledBuild :read-write :link --bitblast-aig :link-smt bitblast-aig abc command to run AIG simplifications (implies --bitblast-aig, default is "balance;drw") # Options for lazy bit-blasting @@ -25,7 +25,7 @@ option bitvectorPropagate --bv-propagate bool :default true :read-write :link -- option bitvectorEqualitySolver --bv-eq-solver bool :default true :read-write :link --bitblast=lazy use the equality engine for the bit-vector theory (only if --bitblast=lazy) -option bitvectorEqualitySlicer --bv-eq-slicer=MODE CVC4::theory::bv::BvSlicerMode :handler CVC4::theory::bv::stringToBvSlicerMode :default CVC4::theory::bv::BITVECTOR_SLICER_OFF :read-write :include "theory/bv/bitblast_mode.h" :handler-include "theory/bv/options_handlers.h" :read-write :link --bv-eq-solver +option bitvectorEqualitySlicer --bv-eq-slicer=MODE CVC4::theory::bv::BvSlicerMode :handler CVC4::options::stringToBvSlicerMode :default CVC4::theory::bv::BITVECTOR_SLICER_OFF :read-write :include "options/bv_bitblast_mode.h" :handler-include "options/options_handler_interface.h" :read-write :link --bv-eq-solver turn on the slicing equality solver for the bit-vector theory (only if --bitblast=lazy) option bitvectorInequalitySolver --bv-inequality-solver bool :default true :read-write :link --bitblast=lazy diff --git a/src/theory/datatypes/options b/src/options/datatypes_options index 6da0fe244..ba700a594 100644 --- a/src/theory/datatypes/options +++ b/src/options/datatypes_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module DATATYPES "theory/datatypes/options.h" Datatypes theory +module DATATYPES "options/datatypes_options.h" Datatypes theory # How to handle selectors applied to incorrect constructors. If this option is set, # then we do not rewrite such a selector term to an arbitrary ground term. diff --git a/src/decision/decision_mode.cpp b/src/options/decision_mode.cpp index 912089179..168637e64 100644 --- a/src/decision/decision_mode.cpp +++ b/src/options/decision_mode.cpp @@ -15,7 +15,7 @@ ** \todo document this file **/ -#include "decision/decision_mode.h" +#include "options/decision_mode.h" namespace CVC4 { @@ -35,4 +35,3 @@ std::ostream& operator<<(std::ostream& out, decision::DecisionMode mode) { } }/* CVC4 namespace */ - diff --git a/src/decision/decision_mode.h b/src/options/decision_mode.h index fb01c587b..fb01c587b 100644 --- a/src/decision/decision_mode.h +++ b/src/options/decision_mode.h diff --git a/src/decision/options b/src/options/decision_options index 1f0b137cb..35a1de1e9 100644 --- a/src/decision/options +++ b/src/options/decision_options @@ -3,16 +3,16 @@ # See src/options/base_options for a description of this file format # -module DECISION "decision/options.h" Decision heuristics +module DECISION "options/decision_options.h" Decision heuristics # When/whether to use any decision strategies -option decisionMode decision-mode --decision=MODE decision::DecisionMode :handler CVC4::decision::stringToDecisionMode :default decision::DECISION_STRATEGY_INTERNAL :read-write :include "decision/decision_mode.h" :handler-include "decision/options_handlers.h" +option decisionMode decision-mode --decision=MODE decision::DecisionMode :handler CVC4::options::stringToDecisionMode :default decision::DECISION_STRATEGY_INTERNAL :read-write :include "options/decision_mode.h" :handler-include "options/options_handler_interface.h" choose decision mode, see --decision=help # only use DE to determine when to stop, not to make decisions option decisionStopOnly bool -expert-option decisionThreshold --decision-threshold=N decision::DecisionWeight :default 0 :include "theory/decision_attributes.h" +expert-option decisionThreshold --decision-threshold=N decision::DecisionWeight :default 0 :include "options/decision_weight.h" ignore all nodes greater than threshold in first attempt to pick decision expert-option decisionUseWeight --decision-use-weight bool :default false @@ -21,7 +21,7 @@ expert-option decisionUseWeight --decision-use-weight bool :default false expert-option decisionRandomWeight --decision-random-weight=N int :default 0 assign random weights to nodes between 0 and N-1 (0: disable) -expert-option decisionWeightInternal --decision-weight-internal=HOW decision::DecisionWeightInternal :handler CVC4::decision::stringToDecisionWeightInternal :default decision::DECISION_WEIGHT_INTERNAL_OFF :handler-include "decision/options_handlers.h" +expert-option decisionWeightInternal --decision-weight-internal=HOW decision::DecisionWeightInternal :handler CVC4::options::stringToDecisionWeightInternal :default decision::DECISION_WEIGHT_INTERNAL_OFF :handler-include "options/options_handler_interface.h" computer weights of internal nodes using children: off, max, sum, usr1 (meaning evolving) endmodule diff --git a/src/theory/sets/options_handlers.h b/src/options/decision_weight.h index f0af6e7a3..42f1d5b6d 100644 --- a/src/theory/sets/options_handlers.h +++ b/src/options/decision_weight.h @@ -1,31 +1,28 @@ /********************* */ -/*! \file options_handlers.h +/*! \file decision_weight.h ** \verbatim ** Original author: Kshitij Bansal - ** Major contributors: none + ** Major contributors: Morgan Deters ** Minor contributors (to current version): none ** This file is part of the CVC4 project. ** Copyright (c) 2009-2014 New York University and The University of Iowa ** See the file COPYING in the top-level source directory for licensing ** information.\endverbatim ** - ** \brief [[ Add one-line brief description here ]] + ** \brief Rewriter attributes ** - ** [[ Add lengthier description here ]] - ** \todo document this file + ** Rewriter attributes. **/ #include "cvc4_private.h" -#ifndef __CVC4__THEORY__SETS__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__SETS__OPTIONS_HANDLERS_H +#ifndef __CVC4__OPTIONS__DECISION_WEIGHT_H +#define __CVC4__OPTIONS__DECISION_WEIGHT_H namespace CVC4 { -namespace theory { -namespace sets { - -}/* CVC4::theory::sets namespace */ -}/* CVC4::theory namespace */ +namespace decision { +typedef uint64_t DecisionWeight; +}/* CVC4::decision namespace */ }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__SETS__OPTIONS_HANDLERS_H */ +#endif /* __CVC4__OPTIONS__DECISION_WEIGHT_H */ diff --git a/src/util/didyoumean.cpp b/src/options/didyoumean.cpp index dd8941033..573ee913f 100644 --- a/src/util/didyoumean.cpp +++ b/src/options/didyoumean.cpp @@ -17,11 +17,13 @@ ** There are no dependencies on CVC4 (except namespace). **/ -#include "didyoumean.h" +#include "options/didyoumean.h" + #include <iostream> #include <sstream> + using namespace std; -using namespace CVC4; +namespace CVC4 { vector<string> DidYouMean::getMatch(string input) { /** Magic numbers */ @@ -67,7 +69,7 @@ int DidYouMean::editDistance(const std::string& a, const std::string& b) { // input string: a // desired string: b - + const int swapCost = 0; const int substituteCost = 2; const int addCost = 1; @@ -121,7 +123,7 @@ int DidYouMean::editDistance(const std::string& a, const std::string& b) // delete C[cur][j] = std::min(C[cur][j], C[prv][j] + deleteCost); - + #ifdef DIDYOUMEAN_DEBUG1 std::cout << "C[" << cur << "][" << 0 << "] = " << C[cur][0] << std::endl; #endif @@ -152,3 +154,4 @@ string DidYouMean::getMatchAsString(string input, int prefixNewLines, int suffix } return oss.str(); } +}/* CVC4 namespace */ diff --git a/src/util/didyoumean.h b/src/options/didyoumean.h index 18a1101cf..2615f4d0a 100644 --- a/src/util/didyoumean.h +++ b/src/options/didyoumean.h @@ -34,11 +34,11 @@ public: ~DidYouMean() {} DidYouMean(Words words) : d_words(words) {} - + void addWord(std::string word) { d_words.insert(word); } - + std::vector<std::string> getMatch(std::string input); /** diff --git a/src/util/didyoumean_test.cpp b/src/options/didyoumean_test.cpp index 0c46d5ffe..af3daa689 100644 --- a/src/util/didyoumean_test.cpp +++ b/src/options/didyoumean_test.cpp @@ -15,6 +15,7 @@ ** \todo document this file **/ +// This is not built as a part of CVC4 and is not built by Makefile.am. // Compile: g++ didyoumean_test.cpp didyoumean.cpp // For debug compile with -DDIDYOUMEAN_DEBUG or -DDIDYOUMEAN_DEBUG1 or both diff --git a/src/expr/options b/src/options/expr_options index b4608832f..fc92c75a6 100644 --- a/src/expr/options +++ b/src/options/expr_options @@ -3,18 +3,18 @@ # See src/options/base_options for a description of this file format # -module EXPR "expr/options.h" Expression package +module EXPR "options/expr_options.h" Expression package -option defaultExprDepth --default-expr-depth=N int :default 0 :predicate CVC4::expr::setDefaultExprDepth :predicate-include "expr/options_handlers.h" +option defaultExprDepth --default-expr-depth=N int :default 0 :predicate CVC4::options::setDefaultExprDepth :predicate-include "options/options_handler_interface.h" print exprs to depth N (0 == default, -1 == no limit) undocumented-alias --expr-depth=N = --default-expr-depth=N -option defaultDagThresh default-dag-thresh --default-dag-thresh=N int :default 1 :predicate CVC4::expr::setDefaultDagThresh :predicate-include "expr/options_handlers.h" +option defaultDagThresh default-dag-thresh --default-dag-thresh=N int :default 1 :predicate CVC4::options::setDefaultDagThresh :predicate-include "options/options_handler_interface.h" dagify common subexprs appearing > N times (1 == default, 0 == don't dagify) undocumented-alias --dag-thresh=N = --default-dag-thresh=N undocumented-alias --dag-threshold=N = --default-dag-thresh=N -option - --print-expr-types void :handler CVC4::expr::setPrintExprTypes :handler-include "expr/options_handlers.h" +option - --print-expr-types void :handler CVC4::options::setPrintExprTypes :handler-include "options/options_handler_interface.h" print types with variables when printing exprs option earlyTypeChecking --eager-type-checking/--lazy-type-checking bool :default USE_EARLY_TYPE_CHECKING_BY_DEFAULT diff --git a/src/theory/fp/options b/src/options/fp_options index 3fee94d1d..977e868d9 100644 --- a/src/theory/fp/options +++ b/src/options/fp_options @@ -3,6 +3,6 @@ # See src/options/base_options for a description of this file format # -module FP "theory/fp/options.h" Fp +module FP "options/fp_options.h" Fp endmodule diff --git a/src/theory/idl/options b/src/options/idl_options index c1c9edcef..9d4d2a442 100644 --- a/src/theory/idl/options +++ b/src/options/idl_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module IDL "theory/idl/options.h" Idl +module IDL "options/idl_options.h" Idl option idlRewriteEq --enable-idl-rewrite-equalities/--disable-idl-rewrite-equalities bool :default false :read-write enable rewriting equalities into two inequalities in IDL solver (default is disabled) diff --git a/src/util/language.cpp b/src/options/language.cpp index 193db09e8..7558c6927 100644 --- a/src/util/language.cpp +++ b/src/options/language.cpp @@ -14,7 +14,7 @@ ** Definition of input and output languages. **/ -#include "util/language.h" +#include "options/language.h" namespace CVC4 { namespace language { diff --git a/src/util/language.h b/src/options/language.h index 05574880f..d400b4afb 100644 --- a/src/util/language.h +++ b/src/options/language.h @@ -22,7 +22,7 @@ #include <sstream> #include <string> -#include "util/exception.h" +#include "base/exception.h" #include "options/option_exception.h" namespace CVC4 { diff --git a/src/util/language.i b/src/options/language.i index ac20db33a..d14368ca0 100644 --- a/src/util/language.i +++ b/src/options/language.i @@ -1,5 +1,5 @@ %{ -#include "util/language.h" +#include "options/language.h" %} namespace CVC4 { @@ -41,4 +41,4 @@ namespace CVC4 { %rename(OUTPUT_LANG_Z3STR) CVC4::language::output::LANG_Z3STR; %rename(OUTPUT_LANG_SYGUS) CVC4::language::output::LANG_SYGUS; -%include "util/language.h" +%include "options/language.h" diff --git a/src/options/logic_info_forward.h b/src/options/logic_info_forward.h new file mode 100644 index 000000000..8c31a3675 --- /dev/null +++ b/src/options/logic_info_forward.h @@ -0,0 +1,9 @@ + +#ifndef __CVC4__OPTIONS_LOGIC_INFO_FORWARD_H +#define __CVC4__OPTIONS_LOGIC_INFO_FORWARD_H + +namespace CVC4 { +class LogicInfo; +}/* CVC4 namespace */ + +#endif /* __CVC4__OPTIONS_LOGIC_INFO_FORWARD_H */ diff --git a/src/main/options b/src/options/main_options index f523ea499..b468c9284 100644 --- a/src/main/options +++ b/src/options/main_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module DRIVER "main/options.h" Driver +module DRIVER "options/main_options.h" Driver common-option version -V --version/ bool identify this CVC4 binary @@ -12,12 +12,12 @@ undocumented-alias --license = --version common-option help -h --help/ bool full command line reference -common-option - --show-config void :handler CVC4::main::showConfiguration :handler-include "main/options_handlers.h" +common-option - --show-config void :handler CVC4::options::showConfiguration :handler-include "options/options_handler_interface.h" show CVC4 static configuration -option - --show-debug-tags void :handler CVC4::main::showDebugTags :handler-include "main/options_handlers.h" +option - --show-debug-tags void :handler CVC4::options::showDebugTags :handler-include "options/options_handler_interface.h" show all available tags for debugging -option - --show-trace-tags void :handler CVC4::main::showTraceTags :handler-include "main/options_handlers.h" +option - --show-trace-tags void :handler CVC4::options::showTraceTags :handler-include "options/options_handler_interface.h" show all available tags for tracing expert-option earlyExit --early-exit bool :default true @@ -26,7 +26,7 @@ expert-option earlyExit --early-exit bool :default true # portfolio options option threads --threads=N unsigned :default 2 :predicate options::greater(0) Total number of threads for portfolio -option - --threadN=string void :handler CVC4::main::threadN :handler-include "main/options_handlers.h" +option - --threadN=string void :handler CVC4::options::threadN :handler-include "options/options_handler_interface.h" configures portfolio thread N (0..#threads-1) option threadStackSize --thread-stack=N unsigned :default 0 stack size for worker threads in MB (0 means use Boost/thread lib default) diff --git a/src/options/mkoptions b/src/options/mkoptions index 54c731a70..05280baa8 100755 --- a/src/options/mkoptions +++ b/src/options/mkoptions @@ -12,11 +12,12 @@ # mkoptions template-sed template-file # mkoptions apply-sed-files-to-template template-file (sed-file)* # -# The primary purpose of this script is to create options.{h,cpp} +# The primary purpose of this script is to create options/*_options.{h,cpp} # from template files and a list of options. This additionally generates -# the several documentation files, smt/smt_options.{h,cpp}, and -# options_holder.{h,cpp}. This script can in broad terms be thought of -# as an interpreter for a domain specific language within bash. +# the several documentation files, option_handler_get_option.cpp, +# option_handler_set_option.cpp, and options_holder.{h,cpp}. This script can in +# broad terms be thought of as an interpreter for a domain specific language +# within bash. # # The process for generating the files is as follows. # 1) Scan all of the option files that are of interest. @@ -534,11 +535,11 @@ template <> bool Options::wasSetByUser(options::${internal}__option_t) const;" if [ "$type" = bool ]; then module_specializations="${module_specializations} #line $lineno \"$kf\" -template <> void Options::assignBool(options::${internal}__option_t, std::string option, bool value, SmtEngine* smt);" +template <> void Options::assignBool(options::${internal}__option_t, std::string option, bool value, options::OptionsHandler* handler);" elif [ "$internal" != - ]; then module_specializations="${module_specializations} #line $lineno \"$kf\" -template <> void Options::assign(options::${internal}__option_t, std::string option, std::string value, SmtEngine* smt);" +template <> void Options::assign(options::${internal}__option_t, std::string option, std::string value, options::OptionsHandler* handler);" fi module_accessors="${module_accessors} @@ -604,7 +605,7 @@ template <> bool Options::wasSetByUser(options::${internal}__option_t) const { r while [ $i -lt ${#smt_links[@]} ]; do run_smt_links="$run_smt_links #line $lineno \"$kf\" - smt->setOption(std::string(\"${smt_links[$i]}\"), SExpr(${smt_links[$(($i+1))]}));" + handler->setOption(std::string(\"${smt_links[$i]}\"), (${smt_links[$(($i+1))]}));" i=$((i+2)) done fi @@ -625,13 +626,13 @@ template <> bool Options::wasSetByUser(options::${internal}__option_t) const { r for predicate in $predicates; do run_handlers="$run_handlers #line $lineno \"$kf\" - $predicate(option, b, smt);" + $predicate(option, b, handler);" done fi if [ -n "$run_handlers" ]; then all_custom_handlers="${all_custom_handlers} #line $lineno \"$kf\" -template <> void runBoolPredicates(options::${internal}__option_t, std::string option, bool b, SmtEngine* smt) { +template <> void runBoolPredicates(options::${internal}__option_t, std::string option, bool b, options::OptionsHandler* handler) { $run_handlers }" fi @@ -640,7 +641,7 @@ template <> void runBoolPredicates(options::${internal}__option_t, std::string o if [ "$type" = bool ]; then all_modules_option_handlers="${all_modules_option_handlers}${cases} #line $lineno \"$kf\" - assignBool(options::$internal, option, true, NULL);$run_links + assignBool(options::$internal, option, true, handler);$run_links break; " elif [ -n "$expect_arg" -a "$internal" != - ]; then @@ -649,7 +650,7 @@ template <> void runBoolPredicates(options::${internal}__option_t, std::string o for handler in $handlers; do run_handlers="$run_handlers #line $lineno \"$kf\" - $handler(option, optionarg, smt);" + $handler(option, optionarg, handler);" done else run_handlers=" @@ -660,12 +661,12 @@ template <> void runBoolPredicates(options::${internal}__option_t, std::string o for predicate in $predicates; do run_handlers="$run_handlers #line $lineno \"$kf\" - $predicate(option, retval, smt);" + $predicate(option, retval, handler);" done fi all_custom_handlers="${all_custom_handlers} #line $lineno \"$kf\" -template <> options::${internal}__option_t::type runHandlerAndPredicates(options::${internal}__option_t, std::string option, std::string optionarg, SmtEngine* smt) { +template <> options::${internal}__option_t::type runHandlerAndPredicates(options::${internal}__option_t, std::string option, std::string optionarg, options::OptionsHandler* handler) { #line $lineno \"$kf\" options::${internal}__option_t::type retval = $run_handlers #line $lineno \"$kf\" @@ -673,7 +674,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options }" all_modules_option_handlers="${all_modules_option_handlers}${cases} #line $lineno \"$kf\" - assign(options::$internal, option, optionarg, NULL);$run_links + assign(options::$internal, option, optionarg, handler);$run_links break; " elif [ -n "$expect_arg" ]; then @@ -685,7 +686,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options for handler in $handlers; do run_handlers="$run_handlers #line $lineno \"$kf\" - $handler(option, optionarg, smt);" + $handler(option, optionarg, handler);" done fi all_modules_option_handlers="${all_modules_option_handlers}${cases} @@ -702,7 +703,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options for handler in $handlers; do run_handlers="$run_handlers #line $lineno \"$kf\" - $handler(option, smt);" + $handler(option, handler);" done fi all_modules_option_handlers="${all_modules_option_handlers}${cases} @@ -716,7 +717,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options if [ "$type" = bool ]; then all_modules_option_handlers="${all_modules_option_handlers}${cases_alternate} #line $lineno \"$kf\" - assignBool(options::$internal, option, false, NULL);$run_links_alternate + assignBool(options::$internal, option, false, handler);$run_links_alternate break; " else @@ -733,54 +734,33 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options bool) all_modules_get_options="${all_modules_get_options:+$all_modules_get_options #line $lineno \"$kf\" - }{ std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(SExpr::Keyword(d_holder->$internal ? \"true\" : \"false\")); opts.push_back(v); }" + }{ std::vector<std::string> v; v.push_back(\"$smtname\"); v.push_back(std::string(d_holder->$internal ? \"true\" : \"false\")); opts.push_back(v); }" smt_getoption_handlers="${smt_getoption_handlers} #line $lineno \"$kf\" if(key == \"$smtname\") { #line $lineno \"$kf\" - return SExprKeyword(options::$internal() ? \"true\" : \"false\"); + return std::string(options::$internal() ? \"true\" : \"false\"); }";; - int|unsigned|int*_t|uint*_t|unsigned\ long|long|CVC4::Integer) + int|unsigned|int*_t|uint*_t|unsigned\ long|long|float|double) all_modules_get_options="${all_modules_get_options:+$all_modules_get_options #line $lineno \"$kf\" - }{ std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(d_holder->$internal); opts.push_back(v); }" + }{ std::stringstream ss; ss << std::fixed << std::setprecision(8); ss << d_holder->$internal; std::vector<std::string> v; v.push_back(\"$smtname\"); v.push_back(ss.str()); opts.push_back(v); }" smt_getoption_handlers="${smt_getoption_handlers} #line $lineno \"$kf\" if(key == \"$smtname\") { #line $lineno \"$kf\" - return SExpr(Integer(options::$internal())); - }";; - float|double) - all_modules_get_options="${all_modules_get_options:+$all_modules_get_options -#line $lineno \"$kf\" - }{ std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(Rational::fromDouble(d_holder->$internal)); opts.push_back(v); }" - smt_getoption_handlers="${smt_getoption_handlers} -#line $lineno \"$kf\" - if(key == \"$smtname\") { -#line $lineno \"$kf\" - stringstream ss; ss << std::fixed << options::$internal(); - return SExpr(Rational::fromDecimal(ss.str())); - }";; - CVC4::Rational) - all_modules_get_options="${all_modules_get_options:+$all_modules_get_options -#line $lineno \"$kf\" - }{ std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(d_holder->$internal); opts.push_back(v); }" - smt_getoption_handlers="${smt_getoption_handlers} -#line $lineno \"$kf\" - if(key == \"$smtname\") { -#line $lineno \"$kf\" - return SExpr(options::$internal()); + std::stringstream ss; ss << std::fixed << std::setprecision(8); ss << options::$internal(); return ss.str(); }";; *) all_modules_get_options="${all_modules_get_options:+$all_modules_get_options #line $lineno \"$kf\" - }{ std::stringstream ss; ss << d_holder->$internal; std::vector<SExpr> v; v.push_back(\"$smtname\"); v.push_back(ss.str()); opts.push_back(v); }" + }{ std::stringstream ss; ss << d_holder->$internal; std::vector<std::string> v; v.push_back(\"$smtname\"); v.push_back(ss.str()); opts.push_back(v); }" smt_getoption_handlers="${smt_getoption_handlers} #line $lineno \"$kf\" if(key == \"$smtname\") { #line $lineno \"$kf\" - stringstream ss; ss << options::$internal(); - return SExpr(ss.str()); + std::stringstream ss; ss << options::$internal(); + return ss.str(); }";; esac fi @@ -790,7 +770,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options #line $lineno \"$kf\" if(key == \"$smtname\") { #line $lineno \"$kf\" - Options::current()->assignBool(options::$internal, \"$smtname\", optionarg == \"true\", smt);$run_smt_links + Options::current()->assignBool(options::$internal, \"$smtname\", optionarg == \"true\", handler);$run_smt_links return; }" elif [ -n "$expect_arg" -a "$internal" != - ]; then @@ -799,7 +779,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options for handler in $handlers; do run_handlers="$run_handlers #line $lineno \"$kf\" - $handler(\"$smtname\", optionarg, smt); + $handler(\"$smtname\", optionarg, handler); " done fi @@ -807,7 +787,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options #line $lineno \"$kf\" if(key == \"$smtname\") { #line $lineno \"$kf\" - Options::current()->assign(options::$internal, \"$smtname\", optionarg, smt);$run_smt_links + Options::current()->assign(options::$internal, \"$smtname\", optionarg, handler);$run_smt_links return; }" elif [ -n "$expect_arg" ]; then @@ -815,7 +795,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options for handler in $handlers; do run_handlers="$run_handlers #line $lineno \"$kf\" - $handler(\"$smtname\", optionarg, smt); + $handler(\"$smtname\", optionarg, handler); " done smt_setoption_handlers="${smt_setoption_handlers} @@ -830,7 +810,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options for handler in $handlers; do run_handlers="$run_handlers #line $lineno \"$kf\" - $handler(\"$smtname\", smt); + $handler(\"$smtname\", handler); " done smt_setoption_handlers="${smt_setoption_handlers} @@ -853,23 +833,15 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options fi all_modules_get_options="${all_modules_get_options:+$all_modules_get_options #line $lineno \"$kf\" - }{ std::vector<SExpr> v; v.push_back(\"$getoption_name\"); v.push_back(SExpr::Keyword((${inv}d_holder->$internal) ? \"true\" : \"false\")); opts.push_back(v); }";; - int|unsigned|int*_t|uint*_t|unsigned\ long|long|CVC4::Integer) + }{ std::vector<std::string> v; v.push_back(\"$getoption_name\"); v.push_back(std::string((${inv}d_holder->$internal) ? \"true\" : \"false\")); opts.push_back(v); }";; + int|unsigned|int*_t|uint*_t|unsigned\ long|long|float|double) all_modules_get_options="${all_modules_get_options:+$all_modules_get_options #line $lineno \"$kf\" - }{ std::vector<SExpr> v; v.push_back(\"$long_option\"); v.push_back(d_holder->$internal); opts.push_back(v); }";; - float|double) - all_modules_get_options="${all_modules_get_options:+$all_modules_get_options -#line $lineno \"$kf\" - }{ std::vector<SExpr> v; v.push_back(\"$long_option\"); v.push_back(Rational::fromDouble(d_holder->$internal)); opts.push_back(v); }";; - CVC4::Rational) - all_modules_get_options="${all_modules_get_options:+$all_modules_get_options -#line $lineno \"$kf\" - }{ std::vector<SExpr> v; v.push_back(\"$long_option\"); v.push_back(d_holder->$internal); opts.push_back(v); }";; + }{ std::stringstream ss; ss << std::fixed << std::setprecision(8); ss << d_holder->$internal; std::vector<std::string> v; v.push_back(\"$long_option\"); v.push_back(ss.str()); opts.push_back(v); }";; *) all_modules_get_options="${all_modules_get_options:+$all_modules_get_options #line $lineno \"$kf\" - }{ std::stringstream ss; ss << d_holder->$internal; std::vector<SExpr> v; v.push_back(\"$long_option\"); v.push_back(ss.str()); opts.push_back(v); }";; + }{ std::stringstream ss; ss << std::fixed << std::setprecision(8); ss << d_holder->$internal; std::vector<std::string> v; v.push_back(\"$long_option\"); v.push_back(ss.str()); opts.push_back(v); }";; esac fi @@ -877,9 +849,9 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options # emit assignBool/assign all_custom_handlers="${all_custom_handlers} #line $lineno \"$kf\" -template <> void Options::assignBool(options::${internal}__option_t, std::string option, bool value, SmtEngine* smt) { +template <> void Options::assignBool(options::${internal}__option_t, std::string option, bool value, options::OptionsHandler* handler) { #line $lineno \"$kf\" - runBoolPredicates(options::$internal, option, value, smt); + runBoolPredicates(options::$internal, option, value, handler); #line $lineno \"$kf\" d_holder->$internal = value; #line $lineno \"$kf\" @@ -890,9 +862,9 @@ template <> void Options::assignBool(options::${internal}__option_t, std::string elif [ -n "$expect_arg" -a "$internal" != - ] && [ -n "$cases" -o -n "$cases_alternate" -o -n "$smtname" ]; then all_custom_handlers="${all_custom_handlers} #line $lineno \"$kf\" -template <> void Options::assign(options::${internal}__option_t, std::string option, std::string value, SmtEngine* smt) { +template <> void Options::assign(options::${internal}__option_t, std::string option, std::string value, options::OptionsHandler* handler) { #line $lineno \"$kf\" - d_holder->$internal = runHandlerAndPredicates(options::$internal, option, value, smt); + d_holder->$internal = runHandlerAndPredicates(options::$internal, option, value, handler); #line $lineno \"$kf\" d_holder->${internal}__setByUser__ = true; #line $lineno \"$kf\" diff --git a/src/options/option_exception.h b/src/options/option_exception.h index a90b96367..c57414026 100644 --- a/src/options/option_exception.h +++ b/src/options/option_exception.h @@ -19,7 +19,7 @@ #ifndef __CVC4__OPTION_EXCEPTION_H #define __CVC4__OPTION_EXCEPTION_H -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { diff --git a/src/options/options.h b/src/options/options.h index 95c0fc331..fc3bf40ac 100644 --- a/src/options/options.h +++ b/src/options/options.h @@ -24,21 +24,18 @@ #include <string> #include <vector> +#include "base/tls.h" #include "options/option_exception.h" -#include "util/language.h" -#include "util/tls.h" -#include "util/sexpr.h" namespace CVC4 { namespace options { struct OptionsHolder; + class OptionsHandler; }/* CVC4::options namespace */ +// Forward declaration for smt_options class ExprStream; -class NodeManager; -class NodeManagerScope; -class SmtEngine; class CVC4_PUBLIC Options { /** The struct that holds all option values. */ @@ -49,16 +46,27 @@ class CVC4_PUBLIC Options { /** Low-level assignment function for options */ template <class T> - void assign(T, std::string option, std::string value, SmtEngine* smt); + void assign(T, std::string option, std::string value, options::OptionsHandler* handler); /** Low-level assignment function for bool-valued options */ template <class T> - void assignBool(T, std::string option, bool value, SmtEngine* smt); + void assignBool(T, std::string option, bool value, options::OptionsHandler* handler); - friend class NodeManager; - friend class NodeManagerScope; - friend class SmtEngine; + friend class options::OptionsHandler; public: + class CVC4_PUBLIC OptionsScope { + private: + Options* d_oldOptions; + public: + OptionsScope(Options* newOptions) : + d_oldOptions(Options::s_current) + { + Options::s_current = newOptions; + } + ~OptionsScope(){ + Options::s_current = d_oldOptions; + } + }; /** Return true if current Options are null */ static inline bool isCurrentNull() { @@ -145,12 +153,12 @@ public: * The return value is what's left of the command line (that is, the * non-option arguments). */ - std::vector<std::string> parseOptions(int argc, char* argv[]) throw(OptionException); + std::vector<std::string> parseOptions(int argc, char* argv[], options::OptionsHandler* handler) throw(OptionException); /** * Get the setting for all options. */ - SExpr getOptions() const throw(); + std::vector< std::vector<std::string> > getOptions() const throw(); };/* class Options */ diff --git a/src/options/options_handler_get_option_template.cpp b/src/options/options_handler_get_option_template.cpp new file mode 100644 index 000000000..b5da8c68d --- /dev/null +++ b/src/options/options_handler_get_option_template.cpp @@ -0,0 +1,54 @@ +/********************* */ +/*! \file option_handler_get_option_template.cpp + ** \verbatim + ** Original author: Morgan Deters + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Implementation of OptionsHandler::getOption. + ** + ** This template file is expanded into the cpp implementation of + ** OptionsHandler::setOption. The file is essentially the contents + ** of the ${smt_getoption_handlers} variable in the options/mkoptions + ** script. This variable depends on all options files. To generate this file, + ** first generate options/summary.sed. + **/ + +#include <iomanip> +#include <string> +#include <sstream> + + +#include "base/output.h" +#include "base/modal_exception.h" +#include "options/option_exception.h" +#include "options/options_handler_interface.h" + + +${include_all_option_headers} +${option_handler_includes} + +#line 31 "${template}" + +using namespace std; + +namespace CVC4 { +namespace options { + +std::string OptionsHandler::getOption(const std::string& key) const + throw(OptionException) { + Trace("options") << "SMT getOption(" << key << ")" << endl; + + ${smt_getoption_handlers} + +#line 57 "${template}" + + throw UnrecognizedOptionException(key); +} + +}/* options namespace */ +}/* CVC4 namespace */ diff --git a/src/options/options_handler_interface.cpp b/src/options/options_handler_interface.cpp new file mode 100644 index 000000000..d803fced0 --- /dev/null +++ b/src/options/options_handler_interface.cpp @@ -0,0 +1,362 @@ +/********************* */ +/*! \file options_handler_interface.cpp + ** \verbatim + ** Original author: Tim King + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Interface for custom handlers and predicates options. + ** + ** Interface for custom handlers and predicates options. + **/ + +#include "options/options_handler_interface.h" + +#include <ostream> +#include <string> + +#include "base/cvc4_assert.h" +#include "base/exception.h" +#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/boolean_term_conversion_mode.h" +#include "options/bv_bitblast_mode.h" +#include "options/decision_mode.h" +#include "options/language.h" +#include "options/option_exception.h" +#include "options/printer_modes.h" +#include "options/quantifiers_modes.h" +#include "options/simplification_mode.h" +#include "options/theoryof_mode.h" +#include "options/ufss_mode.h" + +namespace CVC4 { +namespace options { + +static const char* s_third_argument_warning = + "We no longer support passing the third argument to the setting an option as NULL."; + +// theory/arith/options_handlers.h +ArithUnateLemmaMode stringToArithUnateLemmaMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToArithUnateLemmaMode(option, optarg); +} +ArithPropagationMode stringToArithPropagationMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToArithPropagationMode(option, optarg); +} +ErrorSelectionRule stringToErrorSelectionRule(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToErrorSelectionRule(option, optarg); +} + +// theory/quantifiers/options_handlers.h +theory::quantifiers::InstWhenMode stringToInstWhenMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToInstWhenMode(option, optarg); +} +void checkInstWhenMode(std::string option, theory::quantifiers::InstWhenMode mode, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->checkInstWhenMode(option, mode); +} +theory::quantifiers::LiteralMatchMode stringToLiteralMatchMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToLiteralMatchMode(option, optarg); +} +void checkLiteralMatchMode(std::string option, theory::quantifiers::LiteralMatchMode mode, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->checkLiteralMatchMode(option, mode); +} +theory::quantifiers::MbqiMode stringToMbqiMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToMbqiMode(option, optarg); +} +void checkMbqiMode(std::string option, theory::quantifiers::MbqiMode mode, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->checkMbqiMode(option, mode); +} +theory::quantifiers::QcfWhenMode stringToQcfWhenMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToQcfWhenMode(option, optarg); +} +theory::quantifiers::QcfMode stringToQcfMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToQcfMode(option, optarg); +} +theory::quantifiers::UserPatMode stringToUserPatMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToUserPatMode(option, optarg); +} +theory::quantifiers::TriggerSelMode stringToTriggerSelMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToTriggerSelMode(option, optarg); +} +theory::quantifiers::PrenexQuantMode stringToPrenexQuantMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToPrenexQuantMode(option, optarg); +} +theory::quantifiers::CegqiFairMode stringToCegqiFairMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToCegqiFairMode(option, optarg); +} +theory::quantifiers::TermDbMode stringToTermDbMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler-> stringToTermDbMode(option, optarg); +} +theory::quantifiers::IteLiftQuantMode stringToIteLiftQuantMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToIteLiftQuantMode(option, optarg); +} +theory::quantifiers::SygusInvTemplMode stringToSygusInvTemplMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToSygusInvTemplMode(option, optarg); +} +theory::quantifiers::MacrosQuantMode stringToMacrosQuantMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToMacrosQuantMode(option, optarg); +} + + +// theory/bv/options_handlers.h +void abcEnabledBuild(std::string option, bool value, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->abcEnabledBuild(option, value); +} +void abcEnabledBuild(std::string option, std::string value, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->abcEnabledBuild(option, value); +} +theory::bv::BitblastMode stringToBitblastMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToBitblastMode(option, optarg); +} +theory::bv::BvSlicerMode stringToBvSlicerMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToBvSlicerMode(option, optarg); +} +void setBitblastAig(std::string option, bool arg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setBitblastAig(option, arg); +} + + +// theory/booleans/options_handlers.h +theory::booleans::BooleanTermConversionMode stringToBooleanTermConversionMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToBooleanTermConversionMode( option, optarg); +} + +// theory/uf/options_handlers.h +theory::uf::UfssMode stringToUfssMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToUfssMode(option, optarg); +} + +// theory/options_handlers.h +theory::TheoryOfMode stringToTheoryOfMode(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToTheoryOfMode(option, optarg); +} +void useTheory(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->useTheory(option, optarg); +} + +// printer/options_handlers.h +ModelFormatMode stringToModelFormatMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToModelFormatMode(option, optarg); +} + +InstFormatMode stringToInstFormatMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToInstFormatMode(option, optarg); +} + + +// decision/options_handlers.h +decision::DecisionMode stringToDecisionMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToDecisionMode(option, optarg); +} + +decision::DecisionWeightInternal stringToDecisionWeightInternal(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToDecisionWeightInternal(option, optarg); +} + + +/* options/base_options_handlers.h */ +void setVerbosity(std::string option, int value, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setVerbosity(option, value); +} +void increaseVerbosity(std::string option, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->increaseVerbosity(option); +} +void decreaseVerbosity(std::string option, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->decreaseVerbosity(option); +} + +OutputLanguage stringToOutputLanguage(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToOutputLanguage(option, optarg); +} + +InputLanguage stringToInputLanguage(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToInputLanguage(option, optarg); +} + +void addTraceTag(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->addTraceTag(option, optarg); +} + +void addDebugTag(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->addDebugTag(option, optarg); +} + +void setPrintSuccess(std::string option, bool value, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setPrintSuccess(option, value); +} + + +/* main/options_handlers.h */ +void showConfiguration(std::string option, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->showConfiguration(option); +} + +void showDebugTags(std::string option, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->showDebugTags(option); +} + +void showTraceTags(std::string option, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->showTraceTags(option); +} + +void threadN(std::string option, OptionsHandler* handler){ + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->threadN(option); +} + +/* expr/options_handlers.h */ +void setDefaultExprDepth(std::string option, int depth, OptionsHandler* handler){ + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setDefaultExprDepth(option, depth); +} + +void setDefaultDagThresh(std::string option, int dag, OptionsHandler* handler){ + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setDefaultDagThresh(option, dag); +} + +void setPrintExprTypes(std::string option, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setPrintExprTypes(option); +} + + +/* smt/options_handlers.h */ +void dumpMode(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->dumpMode(option, optarg); +} + +LogicInfo* stringToLogicInfo(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException){ + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToLogicInfo(option, optarg); +} + +SimplificationMode stringToSimplificationMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException){ + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->stringToSimplificationMode(option, optarg); +} + +// ensure we haven't started search yet +void beforeSearch(std::string option, bool value, OptionsHandler* handler) throw(ModalException){ + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->beforeSearch(option, value); +} + +void setProduceAssertions(std::string option, bool value, OptionsHandler* handler) throw() { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setProduceAssertions(option, value); +} + +// ensure we are a proof-enabled build of CVC4 +void proofEnabledBuild(std::string option, bool value, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->proofEnabledBuild(option, value); +} + +void dumpToFile(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->dumpToFile(option, optarg); +} + +void setRegularOutputChannel(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setRegularOutputChannel(option, optarg); +} + +void setDiagnosticOutputChannel(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + handler->setDiagnosticOutputChannel(option, optarg); +} + +std::string checkReplayFilename(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->checkReplayFilename(option, optarg); +} + +std::ostream* checkReplayLogFilename(std::string option, std::string optarg, OptionsHandler* handler) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->checkReplayLogFilename(option, optarg); +} + +// ensure we are a stats-enabled build of CVC4 +void statsEnabledBuild(std::string option, bool value, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->statsEnabledBuild(option, value); +} + +unsigned long tlimitHandler(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->tlimitHandler(option, optarg); +} + +unsigned long tlimitPerHandler(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler-> tlimitPerHandler(option, optarg); +} + +unsigned long rlimitHandler(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->rlimitHandler(option, optarg); +} + +unsigned long rlimitPerHandler(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException) { + CheckArgument(handler != NULL, handler, s_third_argument_warning); + return handler->rlimitPerHandler(option, optarg); +} + + + +OptionsHandler::OptionsHandler() { } + +}/* CVC4::options namespace */ +}/* CVC4 namespace */ diff --git a/src/options/options_handler_interface.h b/src/options/options_handler_interface.h new file mode 100644 index 000000000..98575a313 --- /dev/null +++ b/src/options/options_handler_interface.h @@ -0,0 +1,275 @@ +/********************* */ +/*! \file options_handler_interface.h + ** \verbatim + ** Original author: Tim King + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Interface for custom handlers and predicates options. + ** + ** Interface for custom handlers and predicates options. + **/ + +#include "cvc4_private.h" + +#ifndef __CVC4__OPTIONS__OPTIONS_HANDLER_INTERFACE_H +#define __CVC4__OPTIONS__OPTIONS_HANDLER_INTERFACE_H + +#include <ostream> +#include <string> + +#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/boolean_term_conversion_mode.h" +#include "options/bv_bitblast_mode.h" +#include "options/decision_mode.h" +#include "options/language.h" +#include "options/option_exception.h" +#include "options/printer_modes.h" +#include "options/quantifiers_modes.h" +#include "options/simplification_mode.h" +#include "options/theoryof_mode.h" +#include "options/ufss_mode.h" + +namespace CVC4 { +class LogicInfo; +}/* CVC4 namespace */ + +namespace CVC4 { +namespace options { + +class OptionsHandler { +public: + OptionsHandler(); + virtual ~OptionsHandler() {} + + void setOption(const std::string& key, const std::string& optionarg) throw(OptionException, ModalException); + + std::string getOption(const std::string& key) const throw(OptionException); + + // DONE + // decision/options_handlers.h + // expr/options_handlers.h + // main/options_handlers.h + // options/base_options_handlers.h + // printer/options_handlers.h + // smt/options_handlers.h + // theory/options_handlers.h + // theory/booleans/options_handlers.h + // theory/uf/options_handlers.h + // theory/bv/options_handlers.h + // theory/quantifiers/options_handlers.h + // theory/arith/options_handlers.h + + + // theory/arith/options_handlers.h + virtual ArithUnateLemmaMode stringToArithUnateLemmaMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual ArithPropagationMode stringToArithPropagationMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual ErrorSelectionRule stringToErrorSelectionRule(std::string option, std::string optarg) throw(OptionException) = 0; + + // theory/quantifiers/options_handlers.h + virtual theory::quantifiers::InstWhenMode stringToInstWhenMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual void checkInstWhenMode(std::string option, theory::quantifiers::InstWhenMode mode) throw(OptionException) = 0; + virtual theory::quantifiers::LiteralMatchMode stringToLiteralMatchMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual void checkLiteralMatchMode(std::string option, theory::quantifiers::LiteralMatchMode mode) throw(OptionException) = 0; + virtual theory::quantifiers::MbqiMode stringToMbqiMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual void checkMbqiMode(std::string option, theory::quantifiers::MbqiMode mode) throw(OptionException) = 0; + virtual theory::quantifiers::QcfWhenMode stringToQcfWhenMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::QcfMode stringToQcfMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::UserPatMode stringToUserPatMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::TriggerSelMode stringToTriggerSelMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::PrenexQuantMode stringToPrenexQuantMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::CegqiFairMode stringToCegqiFairMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::TermDbMode stringToTermDbMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::IteLiftQuantMode stringToIteLiftQuantMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::SygusInvTemplMode stringToSygusInvTemplMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::quantifiers::MacrosQuantMode stringToMacrosQuantMode(std::string option, std::string optarg) throw(OptionException) = 0; + + // theory/bv/options_handlers.h + virtual void abcEnabledBuild(std::string option, bool value) throw(OptionException) = 0; + virtual void abcEnabledBuild(std::string option, std::string value) throw(OptionException) = 0; + virtual theory::bv::BitblastMode stringToBitblastMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual theory::bv::BvSlicerMode stringToBvSlicerMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual void setBitblastAig(std::string option, bool arg) throw(OptionException) = 0; + + + // theory/booleans/options_handlers.h + virtual theory::booleans::BooleanTermConversionMode stringToBooleanTermConversionMode(std::string option, std::string optarg) throw(OptionException) = 0; + + // theory/uf/options_handlers.h + virtual theory::uf::UfssMode stringToUfssMode(std::string option, std::string optarg) throw(OptionException) = 0; + + // theory/options_handlers.h + virtual theory::TheoryOfMode stringToTheoryOfMode(std::string option, std::string optarg) = 0; + virtual void useTheory(std::string option, std::string optarg) = 0; + + + // printer/options_handlers.h + virtual ModelFormatMode stringToModelFormatMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual InstFormatMode stringToInstFormatMode(std::string option, std::string optarg) throw(OptionException) = 0; + + // decision/options_handlers.h + virtual decision::DecisionMode stringToDecisionMode(std::string option, std::string optarg) throw(OptionException) = 0; + virtual decision::DecisionWeightInternal stringToDecisionWeightInternal(std::string option, std::string optarg) throw(OptionException) = 0; + + + /* smt/options_handlers.h */ + virtual void dumpMode(std::string option, std::string optarg) = 0; + virtual LogicInfo* stringToLogicInfo(std::string option, std::string optarg) throw(OptionException) = 0; + virtual SimplificationMode stringToSimplificationMode(std::string option, std::string optarg) throw(OptionException) = 0; + + virtual void beforeSearch(std::string option, bool value) throw(ModalException) = 0; + virtual void setProduceAssertions(std::string option, bool value) throw() = 0; + virtual void proofEnabledBuild(std::string option, bool value) throw(OptionException) = 0; + virtual void dumpToFile(std::string option, std::string optarg) = 0; + virtual void setRegularOutputChannel(std::string option, std::string optarg) = 0; + virtual void setDiagnosticOutputChannel(std::string option, std::string optarg) = 0; + virtual std::string checkReplayFilename(std::string option, std::string optarg) = 0; + virtual std::ostream* checkReplayLogFilename(std::string option, std::string optarg) = 0; + virtual void statsEnabledBuild(std::string option, bool value) throw(OptionException) = 0; + virtual unsigned long tlimitHandler(std::string option, std::string optarg) throw(OptionException) = 0; + virtual unsigned long tlimitPerHandler(std::string option, std::string optarg) throw(OptionException) = 0; + virtual unsigned long rlimitHandler(std::string option, std::string optarg) throw(OptionException) = 0; + virtual unsigned long rlimitPerHandler(std::string option, std::string optarg) throw(OptionException) = 0; + + /* expr/options_handlers.h */ + virtual void setDefaultExprDepth(std::string option, int depth) = 0; + virtual void setDefaultDagThresh(std::string option, int dag) = 0; + virtual void setPrintExprTypes(std::string option) = 0; + + /* main/options_handlers.h */ + virtual void showConfiguration(std::string option) = 0; + virtual void showDebugTags(std::string option) = 0; + virtual void showTraceTags(std::string option) = 0; + virtual void threadN(std::string option) = 0; + + /* options/base_options_handlers.h */ + virtual void setVerbosity(std::string option, int value) throw(OptionException) = 0; + virtual void increaseVerbosity(std::string option) = 0; + virtual void decreaseVerbosity(std::string option) = 0; + virtual OutputLanguage stringToOutputLanguage(std::string option, std::string optarg) throw(OptionException) = 0; + virtual InputLanguage stringToInputLanguage(std::string option, std::string optarg) throw(OptionException) = 0; + virtual void addTraceTag(std::string option, std::string optarg) = 0; + virtual void addDebugTag(std::string option, std::string optarg) = 0; + virtual void setPrintSuccess(std::string option, bool value) = 0; +}; /* class OptionHandler */ + +// theory/arith/options_handlers.h +ArithUnateLemmaMode stringToArithUnateLemmaMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +ArithPropagationMode stringToArithPropagationMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +ErrorSelectionRule stringToErrorSelectionRule(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + +// theory/quantifiers/options_handlers.h +theory::quantifiers::InstWhenMode stringToInstWhenMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +void checkInstWhenMode(std::string option, theory::quantifiers::InstWhenMode mode, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::LiteralMatchMode stringToLiteralMatchMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +void checkLiteralMatchMode(std::string option, theory::quantifiers::LiteralMatchMode mode, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::MbqiMode stringToMbqiMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +void checkMbqiMode(std::string option, theory::quantifiers::MbqiMode mode, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::QcfWhenMode stringToQcfWhenMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::QcfMode stringToQcfMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::UserPatMode stringToUserPatMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::TriggerSelMode stringToTriggerSelMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::PrenexQuantMode stringToPrenexQuantMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::CegqiFairMode stringToCegqiFairMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::TermDbMode stringToTermDbMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::IteLiftQuantMode stringToIteLiftQuantMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::SygusInvTemplMode stringToSygusInvTemplMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::quantifiers::MacrosQuantMode stringToMacrosQuantMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + + +// theory/bv/options_handlers.h +void abcEnabledBuild(std::string option, bool value, OptionsHandler* handler) throw(OptionException); +void abcEnabledBuild(std::string option, std::string value, OptionsHandler* handler) throw(OptionException); +theory::bv::BitblastMode stringToBitblastMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +theory::bv::BvSlicerMode stringToBvSlicerMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +void setBitblastAig(std::string option, bool arg, OptionsHandler* handler) throw(OptionException); + +// theory/booleans/options_handlers.h +theory::booleans::BooleanTermConversionMode stringToBooleanTermConversionMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + +// theory/uf/options_handlers.h +theory::uf::UfssMode stringToUfssMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + + +// theory/options_handlers.h +theory::TheoryOfMode stringToTheoryOfMode(std::string option, std::string optarg, OptionsHandler* handler); +void useTheory(std::string option, std::string optarg, OptionsHandler* handler); + +// printer/options_handlers.h +ModelFormatMode stringToModelFormatMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +InstFormatMode stringToInstFormatMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + +// decision/options_handlers.h +decision::DecisionMode stringToDecisionMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +decision::DecisionWeightInternal stringToDecisionWeightInternal(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + + +/* options/base_options_handlers.h */ +void setVerbosity(std::string option, int value, OptionsHandler* handler) throw(OptionException); +void increaseVerbosity(std::string option, OptionsHandler* handler); +void decreaseVerbosity(std::string option, OptionsHandler* handler); +OutputLanguage stringToOutputLanguage(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +InputLanguage stringToInputLanguage(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); +void addTraceTag(std::string option, std::string optarg, OptionsHandler* handler); +void addDebugTag(std::string option, std::string optarg, OptionsHandler* handler); +void setPrintSuccess(std::string option, bool value, OptionsHandler* handler); + +/* main/options_handlers.h */ +void showConfiguration(std::string option, OptionsHandler* handler); +void showDebugTags(std::string option, OptionsHandler* handler); +void showTraceTags(std::string option, OptionsHandler* handler); +void threadN(std::string option, OptionsHandler* handler); + +/* expr/options_handlers.h */ +void setDefaultExprDepth(std::string option, int depth, OptionsHandler* handler); +void setDefaultDagThresh(std::string option, int dag, OptionsHandler* handler); +void setPrintExprTypes(std::string option, OptionsHandler* handler); + +/* smt/options_handlers.h */ +void dumpMode(std::string option, std::string optarg, OptionsHandler* handler); + +LogicInfo* stringToLogicInfo(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + +SimplificationMode stringToSimplificationMode(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + +// ensure we haven't started search yet +void beforeSearch(std::string option, bool value, OptionsHandler* handler) throw(ModalException); + +void setProduceAssertions(std::string option, bool value, OptionsHandler* handler) throw(); + +// ensure we are a proof-enabled build of CVC4 +void proofEnabledBuild(std::string option, bool value, OptionsHandler* handler) throw(OptionException); + +void dumpToFile(std::string option, std::string optarg, OptionsHandler* handler); + +void setRegularOutputChannel(std::string option, std::string optarg, OptionsHandler* handler); + +void setDiagnosticOutputChannel(std::string option, std::string optarg, OptionsHandler* handler); + +std::string checkReplayFilename(std::string option, std::string optarg, OptionsHandler* handler); + +std::ostream* checkReplayLogFilename(std::string option, std::string optarg, OptionsHandler* handler); + +// ensure we are a stats-enabled build of CVC4 +void statsEnabledBuild(std::string option, bool value, OptionsHandler* handler) throw(OptionException); + +unsigned long tlimitHandler(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + +unsigned long tlimitPerHandler(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + +unsigned long rlimitHandler(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + +unsigned long rlimitPerHandler(std::string option, std::string optarg, OptionsHandler* handler) throw(OptionException); + + +}/* CVC4::options namespace */ +}/* CVC4 namespace */ + +#endif /* __CVC4__OPTIONS__OPTIONS_HANDLER_INTERFACE_H */ diff --git a/src/options/options_handler_interface.i b/src/options/options_handler_interface.i new file mode 100644 index 000000000..b7076a0b8 --- /dev/null +++ b/src/options/options_handler_interface.i @@ -0,0 +1,5 @@ +%{ +#include "options/options_handler_interface.h" +%} + +%include "options/options_handler_interface.h" diff --git a/src/options/options_handler_set_option_template.cpp b/src/options/options_handler_set_option_template.cpp new file mode 100644 index 000000000..86821bc0a --- /dev/null +++ b/src/options/options_handler_set_option_template.cpp @@ -0,0 +1,53 @@ +/********************* */ +/*! \file option_handler_set_option_template.cpp + ** \verbatim + ** Original author: Morgan Deters + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Implementation of OptionsHandler::setOption. + ** + ** This template file is expanded into the cpp implementation of + ** OptionsHandler::setOption. The file is essentially the contents + ** of the ${smt_setoption_handlers} variable in the options/mkoptions + ** script. This variable depends on all options files. To generate this file, + ** first generate options/summary.sed. + **/ + +#include <string> +#include <sstream> + +#include "base/output.h" +#include "base/modal_exception.h" +#include "options/option_exception.h" +#include "options/options_handler_interface.h" + + +${include_all_option_headers} +${option_handler_includes} + +#line 31 "${template}" + +using namespace std; + +namespace CVC4 { +namespace options { + +void OptionsHandler::setOption(const std::string& key, const std::string& optionarg) + throw(OptionException, ModalException) { + options::OptionsHandler* const handler = this; + Trace("options") << "SMT setOption(" << key << ", " << optionarg << ")" << endl; + + ${smt_setoption_handlers} + +#line 44 "${template}" + + throw UnrecognizedOptionException(key); +} + +}/* options namespace */ +}/* CVC4 namespace */ diff --git a/src/options/options_template.cpp b/src/options/options_template.cpp index a9721ad20..ecf42ac58 100644 --- a/src/options/options_template.cpp +++ b/src/options/options_template.cpp @@ -14,6 +14,8 @@ ** Contains code for handling command-line options **/ +#warning "TODO: Remove ExprStream forward declaration from options.h." + #if !defined(_BSD_SOURCE) && defined(__MINGW32__) && !defined(__MINGW64__) // force use of optreset; mingw32 croaks on argv-switching otherwise # include "cvc4autoconfig.h" @@ -34,32 +36,35 @@ extern int optreset; # undef _BSD_SOURCE #endif /* CVC4_IS_NOT_REALLY_BSD */ +#include <unistd.h> +#include <string.h> +#include <stdint.h> +#include <time.h> + #include <cstdio> #include <cstdlib> +#include <cstring> +#include <iomanip> #include <new> #include <string> #include <sstream> #include <limits> -#include <unistd.h> -#include <string.h> -#include <stdint.h> -#include <time.h> -#include "expr/expr.h" -#include "util/configuration.h" -#include "util/didyoumean.h" -#include "util/exception.h" -#include "util/language.h" -#include "util/tls.h" +#include "base/cvc4_assert.h" +#include "base/exception.h" +#include "base/output.h" +#include "base/tls.h" +#include "options/didyoumean.h" +#include "options/language.h" +#include "options/options_handler_interface.h" ${include_all_option_headers} #line 58 "${template}" -#include "util/output.h" #include "options/options_holder.h" #include "cvc4autoconfig.h" -#include "options/base_options_handlers.h" +#include "options/base_handlers.h" ${option_handler_includes} @@ -90,11 +95,29 @@ struct OptionHandler { /** Variant for integral C++ types */ template <class T> struct OptionHandler<T, true, true> { - static T handle(std::string option, std::string optionarg) { + static bool stringToInt(T& t, const std::string& str) { + std::istringstream ss(str); + ss >> t; + char tmp; + return !(ss.fail() || ss.get(tmp)); + } + + static bool containsMinus(const std::string& str) { + return str.find('-') != std::string::npos; + } + + static T handle(const std::string& option, const std::string& optionarg) { try { - Integer i(optionarg, 10); + T i; + bool success = stringToInt(i, optionarg); - if(! std::numeric_limits<T>::is_signed && i < 0) { + if(!success){ + throw OptionException(option + ": failed to parse "+ optionarg +" as an integer of the appropraite type."); + } + + // Depending in the platform unsigned numbers with '-' signs may parse. + // Reject these by looking for any minus if it is not signed. + if( (! std::numeric_limits<T>::is_signed) && containsMinus(optionarg) ) { // unsigned type but user gave negative argument throw OptionException(option + " requires a nonnegative argument"); } else if(i < std::numeric_limits<T>::min()) { @@ -109,11 +132,13 @@ struct OptionHandler<T, true, true> { throw OptionException(ss.str()); } - if(std::numeric_limits<T>::is_signed) { - return T(i.getLong()); - } else { - return T(i.getUnsignedLong()); - } + return i; + + // if(std::numeric_limits<T>::is_signed) { + // return T(i.getLong()); + // } else { + // return T(i.getUnsignedLong()); + // } } catch(std::invalid_argument&) { // user gave something other than an integer throw OptionException(option + " requires an integer argument"); @@ -183,7 +208,7 @@ std::string handleOption<std::string>(std::string option, std::string optionarg) * If a user specifies a :handler or :predicates, it overrides this. */ template <class T> -typename T::type runHandlerAndPredicates(T, std::string option, std::string optionarg, SmtEngine* smt) { +typename T::type runHandlerAndPredicates(T, std::string option, std::string optionarg, options::OptionsHandler* handler) { // By default, parse the option argument in a way appropriate for its type. // E.g., for "unsigned int" options, ensure that the provided argument is // a nonnegative integer that fits in the unsigned int type. @@ -192,7 +217,7 @@ typename T::type runHandlerAndPredicates(T, std::string option, std::string opti } template <class T> -void runBoolPredicates(T, std::string option, bool b, SmtEngine* smt) { +void runBoolPredicates(T, std::string option, bool b, options::OptionsHandler* handler) { // By default, nothing to do for bool. Users add things with // :predicate in options files to provide custom checking routines // that can throw exceptions. @@ -380,11 +405,10 @@ public: * The return value is what's left of the command line (that is, the * non-option arguments). */ -std::vector<std::string> Options::parseOptions(int argc, char* main_argv[]) throw(OptionException) { +std::vector<std::string> Options::parseOptions(int argc, char* main_argv[], options::OptionsHandler* const handler) throw(OptionException) { options::OptionsGuard guard(&s_current, this); const char *progName = main_argv[0]; - SmtEngine* const smt = NULL; Debug("options") << "main_argv == " << main_argv << std::endl; @@ -606,14 +630,14 @@ std::vector<std::string> Options::suggestSmtOptions(const std::string& optionNam return suggestions; } -SExpr Options::getOptions() const throw() { - std::vector<SExpr> opts; +std::vector< std::vector<std::string> > Options::getOptions() const throw() { + std::vector< std::vector<std::string> > opts; ${all_modules_get_options} #line 614 "${template}" - return SExpr(opts); + return opts; } #undef USE_EARLY_TYPE_CHECKING_BY_DEFAULT diff --git a/src/parser/options b/src/options/parser_options index 66e95889f..e91c735fe 100644 --- a/src/parser/options +++ b/src/options/parser_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module PARSER "parser/options.h" Parser +module PARSER "options/parser_options.h" Parser common-option strictParsing --strict-parsing bool be less tolerant of non-conforming inputs diff --git a/src/printer/modes.cpp b/src/options/printer_modes.cpp index 01b7fc833..b698ed07d 100644 --- a/src/printer/modes.cpp +++ b/src/options/printer_modes.cpp @@ -1,5 +1,5 @@ /********************* */ -/*! \file modes.cpp +/*! \file printer_modes.cpp ** \verbatim ** Original author: Andrew Reynolds ** Major contributors: Morgan Deters @@ -15,7 +15,7 @@ ** \todo document this file **/ -#include "printer/modes.h" +#include "options/printer_modes.h" namespace CVC4 { diff --git a/src/printer/modes.h b/src/options/printer_modes.h index 849e0d149..f18799aaa 100644 --- a/src/printer/modes.h +++ b/src/options/printer_modes.h @@ -1,5 +1,5 @@ /********************* */ -/*! \file modes.h +/*! \file printer_modes.h ** \verbatim ** Original author: Andrew Reynolds ** Major contributors: Morgan Deters diff --git a/src/options/printer_options b/src/options/printer_options new file mode 100644 index 000000000..7491570c6 --- /dev/null +++ b/src/options/printer_options @@ -0,0 +1,14 @@ +# +# Option specification file for CVC4 +# See src/options/base_options for a description of this file format +# + +module PRINTER "options/printer_options.h" Printing + +option modelFormatMode --model-format=MODE ModelFormatMode :handler CVC4::options::stringToModelFormatMode :default MODEL_FORMAT_MODE_DEFAULT :read-write :include "options/printer_modes.h" :handler-include "options/options_handler_interface.h" + print format mode for models, see --model-format=help + +option instFormatMode --inst-format=MODE InstFormatMode :handler CVC4::options::stringToInstFormatMode :default INST_FORMAT_MODE_DEFAULT :read-write :include "options/printer_modes.h" :handler-include "options/options_handler_interface.h" + print format mode for instantiations, see --inst-format=help + +endmodule diff --git a/src/proof/options b/src/options/proof_options index af4ffeb93..7feb00b0d 100644 --- a/src/proof/options +++ b/src/options/proof_options @@ -3,6 +3,6 @@ # See src/options/base_options for a description of this file format # -module PROOF "proof/options.h" Proof +module PROOF "options/proof_options.h" Proof endmodule diff --git a/src/prop/options b/src/options/prop_options index 65bb44de6..3c3198147 100644 --- a/src/prop/options +++ b/src/options/prop_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module PROP "prop/options.h" SAT layer +module PROP "options/prop_options.h" SAT layer option satRandomFreq random-frequency --random-freq=P double :default 0.0 :predicate options::greater_equal(0.0) options::less_equal(1.0) sets the frequency of random decisions in the sat solver (P=0.0 by default) diff --git a/src/theory/quantifiers/modes.cpp b/src/options/quantifiers_modes.cpp index 253f23561..e87f00d65 100644 --- a/src/theory/quantifiers/modes.cpp +++ b/src/options/quantifiers_modes.cpp @@ -1,5 +1,5 @@ /********************* */ -/*! \file modes.cpp +/*! \file quantifiers_modes.cpp ** \verbatim ** Original author: Andrew Reynolds ** Major contributors: Morgan Deters @@ -14,9 +14,9 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ +#include "options/quantifiers_modes.h" #include <iostream> -#include "theory/quantifiers/modes.h" namespace CVC4 { @@ -83,4 +83,3 @@ std::ostream& operator<<(std::ostream& out, theory::quantifiers::MbqiMode mode) } }/* CVC4 namespace */ - diff --git a/src/theory/quantifiers/modes.h b/src/options/quantifiers_modes.h index 01d3f0c22..540db38ec 100644 --- a/src/theory/quantifiers/modes.h +++ b/src/options/quantifiers_modes.h @@ -1,5 +1,5 @@ /********************* */ -/*! \file modes.h +/*! \file quantifiers_modes.h ** \verbatim ** Original author: Andrew Reynolds ** Major contributors: Morgan Deters @@ -17,8 +17,8 @@ #include "cvc4_public.h" -#ifndef __CVC4__THEORY__QUANTIFIERS__MODES_H -#define __CVC4__THEORY__QUANTIFIERS__MODES_H +#ifndef __CVC4__BASE__QUANTIFIERS_MODES_H +#define __CVC4__BASE__QUANTIFIERS_MODES_H #include <iostream> @@ -26,7 +26,7 @@ namespace CVC4 { namespace theory { namespace quantifiers { -typedef enum { +enum InstWhenMode { /** Apply instantiation round before full effort (possibly at standard effort) */ INST_WHEN_PRE_FULL, /** Apply instantiation round at full effort or above */ @@ -39,18 +39,18 @@ typedef enum { INST_WHEN_FULL_DELAY_LAST_CALL, /** Apply instantiation round at last call only */ INST_WHEN_LAST_CALL, -} InstWhenMode; +}; -typedef enum { +enum LiteralMatchMode { /** Do not consider polarity of patterns */ LITERAL_MATCH_NONE, /** Consider polarity of boolean predicates only */ LITERAL_MATCH_PREDICATE, /** Consider polarity of boolean predicates, as well as equalities */ LITERAL_MATCH_EQUALITY, -} LiteralMatchMode; +}; -typedef enum { +enum MbqiMode { /** mbqi from CADE 24 paper */ MBQI_GEN_EVAL, /** no mbqi */ @@ -63,9 +63,9 @@ typedef enum { MBQI_ABS, /** mbqi trust (produce no instantiations) */ MBQI_TRUST, -} MbqiMode; +}; -typedef enum { +enum QcfWhenMode { /** default, apply at full effort */ QCF_WHEN_MODE_DEFAULT, /** apply at last call */ @@ -74,9 +74,9 @@ typedef enum { QCF_WHEN_MODE_STD, /** apply based on heuristics */ QCF_WHEN_MODE_STD_H, -} QcfWhenMode; +}; -typedef enum { +enum QcfMode { /** default, use qcf for conflicts only */ QCF_CONFLICT_ONLY, /** use qcf for conflicts and propagations */ @@ -85,9 +85,9 @@ typedef enum { QCF_PARTIAL, /** use qcf for model checking */ QCF_MC, -} QcfMode; +}; -typedef enum { +enum UserPatMode { /** use but do not trust */ USER_PAT_MODE_USE, /** default, if patterns are supplied for a quantifier, use only those */ @@ -98,27 +98,27 @@ typedef enum { USER_PAT_MODE_IGNORE, /** interleave use/resort for user patterns */ USER_PAT_MODE_INTERLEAVE, -} UserPatMode; +}; -typedef enum { +enum TriggerSelMode { /** default for trigger selection */ TRIGGER_SEL_DEFAULT, /** only consider minimal terms for triggers */ TRIGGER_SEL_MIN, /** only consider maximal terms for triggers */ TRIGGER_SEL_MAX, -} TriggerSelMode; +}; -typedef enum CVC4_PUBLIC { +enum CVC4_PUBLIC PrenexQuantMode { /** default : prenex quantifiers without user patterns */ PRENEX_NO_USER_PAT, /** prenex all */ PRENEX_ALL, /** prenex none */ PRENEX_NONE, -} PrenexQuantMode; +}; -typedef enum { +enum CegqiFairMode { /** enforce fairness by UF corresponding to datatypes size */ CEGQI_FAIR_UF_DT_SIZE, /** enforce fairness by datatypes size */ @@ -127,41 +127,41 @@ typedef enum { CEGQI_FAIR_DT_HEIGHT_PRED, /** do not use fair strategy for CEGQI */ CEGQI_FAIR_NONE, -} CegqiFairMode; +}; -typedef enum { +enum TermDbMode { /** consider all terms in master equality engine */ TERM_DB_ALL, /** consider only relevant terms */ TERM_DB_RELEVANT, -} TermDbMode; +}; -typedef enum { +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, -} IteLiftQuantMode; +}; -typedef enum { +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, -} SygusInvTemplMode; +}; -typedef enum { +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, -} MacrosQuantMode; +}; }/* CVC4::theory::quantifiers namespace */ }/* CVC4::theory namespace */ @@ -170,4 +170,4 @@ std::ostream& operator<<(std::ostream& out, theory::quantifiers::InstWhenMode mo }/* CVC4 namespace */ -#endif /* __CVC4__THEORY__QUANTIFIERS__MODES_H */ +#endif /* __CVC4__BASE__QUANTIFIERS_MODES_H */ diff --git a/src/theory/quantifiers/options b/src/options/quantifiers_options index 065da0d5a..5bc20f9a8 100644 --- a/src/theory/quantifiers/options +++ b/src/options/quantifiers_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module QUANTIFIERS "theory/quantifiers/options.h" Quantifiers +module QUANTIFIERS "options/quantifiers_options.h" Quantifiers #### rewriter options @@ -19,7 +19,7 @@ option miniscopeQuantFreeVar --miniscope-quant-fv bool :default true :read-write miniscope quantifiers for ground subformulas option quantSplit --quant-split bool :default true apply splitting to quantified formulas based on variable disjoint disjuncts -option prenexQuant --prenex-quant=MODE CVC4::theory::quantifiers::PrenexQuantMode :default CVC4::theory::quantifiers::PRENEX_NO_USER_PAT :include "theory/quantifiers/modes.h" :read-write :handler CVC4::theory::quantifiers::stringToPrenexQuantMode :handler-include "theory/quantifiers/options_handlers.h" +option prenexQuant --prenex-quant=MODE CVC4::theory::quantifiers::PrenexQuantMode :default CVC4::theory::quantifiers::PRENEX_NO_USER_PAT :include "options/quantifiers_modes.h" :read-write :handler CVC4::options::stringToPrenexQuantMode :handler-include "options/options_handler_interface.h" prenex mode for quantified formulas # Whether to variable-eliminate quantifiers. # For example, forall x y. ( P( x, y ) V x != c ) will be rewritten to @@ -29,7 +29,7 @@ option varElimQuant --var-elim-quant bool :default true option dtVarExpandQuant --dt-var-exp-quant bool :default true expand datatype variables bound to one constructor in quantifiers #ite lift mode for quantified formulas -option iteLiftQuant --ite-lift-quant=MODE CVC4::theory::quantifiers::IteLiftQuantMode :default CVC4::theory::quantifiers::ITE_LIFT_QUANT_MODE_SIMPLE :include "theory/quantifiers/modes.h" :read-write :handler CVC4::theory::quantifiers::stringToIteLiftQuantMode :handler-include "theory/quantifiers/options_handlers.h" +option iteLiftQuant --ite-lift-quant=MODE CVC4::theory::quantifiers::IteLiftQuantMode :default CVC4::theory::quantifiers::ITE_LIFT_QUANT_MODE_SIMPLE :include "options/quantifiers_modes.h" :read-write :handler CVC4::options::stringToIteLiftQuantMode :handler-include "options/options_handler_interface.h" ite lifting mode for quantified formulas option condVarSplitQuant --cond-var-split-quant bool :default true split quantified formulas that lead to variable eliminations @@ -63,7 +63,7 @@ option purifyQuant --purify-quant bool :default false option eMatching --e-matching bool :read-write :default true whether to do heuristic E-matching -option termDbMode --term-db-mode CVC4::theory::quantifiers::TermDbMode :default CVC4::theory::quantifiers::TERM_DB_ALL :read-write :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToTermDbMode :handler-include "theory/quantifiers/options_handlers.h" +option termDbMode --term-db-mode CVC4::theory::quantifiers::TermDbMode :default CVC4::theory::quantifiers::TERM_DB_ALL :read-write :include "options/quantifiers_modes.h" :handler CVC4::options::stringToTermDbMode :handler-include "options/options_handler_interface.h" which ground terms to consider for instantiation option registerQuantBodyTerms --register-quant-body-terms bool :default false consider ground terms within bodies of quantified formulas for matching @@ -86,14 +86,14 @@ option multiTriggerWhenSingle --multi-trigger-when-single bool :default false select multi triggers when single triggers exist option multiTriggerPriority --multi-trigger-priority bool :default false only try multi triggers if single triggers give no instantiations -option triggerSelMode --trigger-sel CVC4::theory::quantifiers::TriggerSelMode :default CVC4::theory::quantifiers::TRIGGER_SEL_DEFAULT :read-write :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToTriggerSelMode :handler-include "theory/quantifiers/options_handlers.h" +option triggerSelMode --trigger-sel CVC4::theory::quantifiers::TriggerSelMode :default CVC4::theory::quantifiers::TRIGGER_SEL_DEFAULT :read-write :include "options/quantifiers_modes.h" :handler CVC4::options::stringToTriggerSelMode :handler-include "options/options_handler_interface.h" selection mode for triggers -option userPatternsQuant --user-pat=MODE CVC4::theory::quantifiers::UserPatMode :default CVC4::theory::quantifiers::USER_PAT_MODE_TRUST :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToUserPatMode :handler-include "theory/quantifiers/options_handlers.h" +option userPatternsQuant --user-pat=MODE CVC4::theory::quantifiers::UserPatMode :default CVC4::theory::quantifiers::USER_PAT_MODE_TRUST :include "options/quantifiers_modes.h" :handler CVC4::options::stringToUserPatMode :handler-include "options/options_handler_interface.h" policy for handling user-provided patterns for quantifier instantiation option incrementTriggers --increment-triggers bool :default true generate additional triggers as needed during search -option instWhenMode --inst-when=MODE CVC4::theory::quantifiers::InstWhenMode :default CVC4::theory::quantifiers::INST_WHEN_FULL_LAST_CALL :read-write :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToInstWhenMode :handler-include "theory/quantifiers/options_handlers.h" :predicate CVC4::theory::quantifiers::checkInstWhenMode :predicate-include "theory/quantifiers/options_handlers.h" +option instWhenMode --inst-when=MODE CVC4::theory::quantifiers::InstWhenMode :default CVC4::theory::quantifiers::INST_WHEN_FULL_LAST_CALL :read-write :include "options/quantifiers_modes.h" :handler CVC4::options::stringToInstWhenMode :handler-include "options/options_handler_interface.h" :predicate CVC4::options::checkInstWhenMode :predicate-include "options/options_handler_interface.h" when to apply instantiation option instMaxLevel --inst-max-level=N int :read-write :default -1 @@ -113,7 +113,7 @@ option fullSaturateQuantRd --full-saturate-quant-rd bool :default true option fullSaturateInst --fs-inst bool :default false interleave full saturate instantiation with other techniques -option literalMatchMode --literal-matching=MODE CVC4::theory::quantifiers::LiteralMatchMode :default CVC4::theory::quantifiers::LITERAL_MATCH_NONE :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToLiteralMatchMode :handler-include "theory/quantifiers/options_handlers.h" :predicate CVC4::theory::quantifiers::checkLiteralMatchMode :predicate-include "theory/quantifiers/options_handlers.h" +option literalMatchMode --literal-matching=MODE CVC4::theory::quantifiers::LiteralMatchMode :default CVC4::theory::quantifiers::LITERAL_MATCH_NONE :include "options/quantifiers_modes.h" :handler CVC4::options::stringToLiteralMatchMode :handler-include "options/options_handler_interface.h" :predicate CVC4::options::checkLiteralMatchMode :predicate-include "options/options_handler_interface.h" choose literal matching mode ### finite model finding options @@ -130,7 +130,7 @@ option fmfFunWellDefinedRelevant --fmf-fun-rlv bool :default false option fmfEmptySorts --fmf-empty-sorts bool :default false allow finite model finding to assume sorts that do not occur in ground assertions are empty -option mbqiMode --mbqi=MODE CVC4::theory::quantifiers::MbqiMode :read-write :default CVC4::theory::quantifiers::MBQI_FMC :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToMbqiMode :handler-include "theory/quantifiers/options_handlers.h" :predicate CVC4::theory::quantifiers::checkMbqiMode :predicate-include "theory/quantifiers/options_handlers.h" +option mbqiMode --mbqi=MODE CVC4::theory::quantifiers::MbqiMode :read-write :default CVC4::theory::quantifiers::MBQI_FMC :include "options/quantifiers_modes.h" :handler CVC4::options::stringToMbqiMode :handler-include "options/options_handler_interface.h" :predicate CVC4::options::checkMbqiMode :predicate-include "options/options_handler_interface.h" choose mode for model-based quantifier instantiation option fmfOneInstPerRound --mbqi-one-inst-per-round bool :read-write :default false only add one instantiation per quantifier per round for mbqi @@ -156,9 +156,9 @@ option fmfBoundIntLazy --fmf-bound-int-lazy bool :default false :read-write option quantConflictFind --quant-cf bool :read-write :default true enable conflict find mechanism for quantifiers -option qcfMode --quant-cf-mode=MODE CVC4::theory::quantifiers::QcfMode :default CVC4::theory::quantifiers::QCF_PROP_EQ :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToQcfMode :handler-include "theory/quantifiers/options_handlers.h" +option qcfMode --quant-cf-mode=MODE CVC4::theory::quantifiers::QcfMode :default CVC4::theory::quantifiers::QCF_PROP_EQ :include "options/quantifiers_modes.h" :handler CVC4::options::stringToQcfMode :handler-include "options/options_handler_interface.h" what effort to apply conflict find mechanism -option qcfWhenMode --quant-cf-when=MODE CVC4::theory::quantifiers::QcfWhenMode :default CVC4::theory::quantifiers::QCF_WHEN_MODE_DEFAULT :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToQcfWhenMode :handler-include "theory/quantifiers/options_handlers.h" +option qcfWhenMode --quant-cf-when=MODE CVC4::theory::quantifiers::QcfWhenMode :default CVC4::theory::quantifiers::QCF_WHEN_MODE_DEFAULT :include "options/quantifiers_modes.h" :handler CVC4::options::stringToQcfWhenMode :handler-include "options/options_handler_interface.h" when to invoke conflict find mechanism for quantifiers option qcfTConstraint --qcf-tconstraint bool :read-write :default false enable entailment checks for t-constraints in qcf algorithm @@ -205,7 +205,7 @@ option conjectureUeeIntro --conjecture-gen-uee-intro bool :default false option ceGuidedInst --cegqi bool :default false :read-write counterexample-guided quantifier instantiation -option ceGuidedInstFair --cegqi-fair=MODE CVC4::theory::quantifiers::CegqiFairMode :default CVC4::theory::quantifiers::CEGQI_FAIR_DT_SIZE :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToCegqiFairMode :handler-include "theory/quantifiers/options_handlers.h" +option ceGuidedInstFair --cegqi-fair=MODE CVC4::theory::quantifiers::CegqiFairMode :default CVC4::theory::quantifiers::CEGQI_FAIR_DT_SIZE :include "options/quantifiers_modes.h" :handler CVC4::options::stringToCegqiFairMode :handler-include "options/options_handler_interface.h" if and how to apply fairness for cegqi option cegqiSingleInv --cegqi-si bool :default false :read-write process single invocation synthesis conjectures @@ -233,7 +233,7 @@ option sygusNormalFormGlobalArg --sygus-nf-sym-arg bool :default true option sygusNormalFormGlobalContent --sygus-nf-sym-content bool :default true generalize based on content in global search space narrowing -option sygusInvTemplMode --sygus-inv-templ=MODE CVC4::theory::quantifiers::SygusInvTemplMode :default CVC4::theory::quantifiers::SYGUS_INV_TEMPL_MODE_NONE :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToSygusInvTemplMode :handler-include "theory/quantifiers/options_handlers.h" +option sygusInvTemplMode --sygus-inv-templ=MODE CVC4::theory::quantifiers::SygusInvTemplMode :default CVC4::theory::quantifiers::SYGUS_INV_TEMPL_MODE_NONE :include "options/quantifiers_modes.h" :handler CVC4::options::stringToSygusInvTemplMode :handler-include "options/options_handler_interface.h" template mode for sygus invariant synthesis # approach applied to general quantified formulas @@ -281,7 +281,7 @@ option quantAlphaEquiv --quant-alpha-equiv bool :default true infer alpha equivalence between quantified formulas option macrosQuant --macros-quant bool :read-write :default false perform quantifiers macro expansion -option macrosQuantMode --macros-quant-mode=MODE CVC4::theory::quantifiers::MacrosQuantMode :default CVC4::theory::quantifiers::MACROS_QUANT_MODE_GROUND_UF :include "theory/quantifiers/modes.h" :handler CVC4::theory::quantifiers::stringToMacrosQuantMode :handler-include "theory/quantifiers/options_handlers.h" +option macrosQuantMode --macros-quant-mode=MODE CVC4::theory::quantifiers::MacrosQuantMode :default CVC4::theory::quantifiers::MACROS_QUANT_MODE_GROUND_UF :include "options/quantifiers_modes.h" :handler CVC4::options::stringToMacrosQuantMode :handler-include "options/options_handler_interface.h" mode for quantifiers macro expansion ### recursive function options diff --git a/src/theory/sets/options b/src/options/sets_options index 6f4b5129d..67bed5fe7 100644 --- a/src/theory/sets/options +++ b/src/options/sets_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module SETS "theory/sets/options.h" Sets +module SETS "options/sets_options.h" Sets option setsPropagate --sets-propagate bool :default true determines whether to propagate learnt facts to Theory Engine / SAT solver diff --git a/src/smt/simplification_mode.cpp b/src/options/simplification_mode.cpp index be46badfc..08f961c15 100644 --- a/src/smt/simplification_mode.cpp +++ b/src/options/simplification_mode.cpp @@ -15,7 +15,7 @@ ** \todo document this file **/ -#include "smt/simplification_mode.h" +#include "options/simplification_mode.h" namespace CVC4 { diff --git a/src/smt/simplification_mode.h b/src/options/simplification_mode.h index b0b78d318..b0b78d318 100644 --- a/src/smt/simplification_mode.h +++ b/src/options/simplification_mode.h diff --git a/src/smt/options b/src/options/smt_options index 7c725e508..f658d929a 100644 --- a/src/smt/options +++ b/src/options/smt_options @@ -3,17 +3,17 @@ # See src/options/base_options for a description of this file format # -module SMT "smt/options.h" SMT layer +module SMT "options/smt_options.h" SMT layer -common-option - dump --dump=MODE argument :handler CVC4::smt::dumpMode :handler-include "smt/options_handlers.h" +common-option - dump --dump=MODE argument :handler CVC4::options::dumpMode :handler-include "options/options_handler_interface.h" dump preprocessed assertions, etc., see --dump=help -common-option - dump-to --dump-to=FILE argument :handler CVC4::smt::dumpToFile :handler-include "smt/options_handlers.h" +common-option - dump-to --dump-to=FILE argument :handler CVC4::options::dumpToFile :handler-include "options/options_handler_interface.h" all dumping goes to FILE (instead of stdout) -expert-option forceLogic force-logic --force-logic=LOGIC LogicInfo :include "theory/logic_info.h" :handler CVC4::smt::stringToLogicInfo :handler-include "smt/options_handlers.h" :default '""' +expert-option forceLogic force-logic --force-logic=LOGIC LogicInfo* :include "options/logic_info_forward.h" :handler CVC4::options::stringToLogicInfo :handler-include "options/options_handler_interface.h" :default NULL set the logic, and override all further user attempts to change it -option simplificationMode simplification-mode --simplification=MODE SimplificationMode :handler CVC4::smt::stringToSimplificationMode :default SIMPLIFICATION_MODE_BATCH :read-write :include "smt/simplification_mode.h" :handler-include "smt/options_handlers.h" +option simplificationMode simplification-mode --simplification=MODE SimplificationMode :handler CVC4::options::stringToSimplificationMode :default SIMPLIFICATION_MODE_BATCH :read-write :include "options/simplification_mode.h" :handler-include "options/options_handler_interface.h" choose simplification mode, see --simplification=help alias --no-simplification = --simplification=none turn off all simplification (same as --simplification=none) @@ -23,15 +23,15 @@ option doStaticLearning static-learning --static-learning bool :default true option expandDefinitions expand-definitions bool :default false always expand symbol definitions in output -common-option produceModels produce-models -m --produce-models bool :default false :predicate CVC4::smt::beforeSearch :predicate-include "smt/smt_engine.h" +common-option produceModels produce-models -m --produce-models bool :default false :predicate CVC4::options::beforeSearch :predicate-include "options/options_handler_interface.h" support the get-value and get-model commands -option checkModels check-models --check-models bool :link --produce-models --produce-assertions :link-smt produce-models :link-smt produce-assertions :predicate CVC4::smt::beforeSearch :predicate-include "smt/options_handlers.h" +option checkModels check-models --check-models bool :link --produce-models --produce-assertions :link-smt produce-models :link-smt produce-assertions :predicate CVC4::options::beforeSearch :predicate-include "options/options_handler_interface.h" after SAT/INVALID/UNKNOWN, check that the generated model satisfies user assertions option dumpModels --dump-models bool :default false :link --produce-models output models after every SAT/INVALID/UNKNOWN response -option proof produce-proofs --proof bool :default false :predicate CVC4::smt::proofEnabledBuild CVC4::smt::beforeSearch :predicate-include "smt/options_handlers.h" +option proof produce-proofs --proof bool :default false :predicate CVC4::options::proofEnabledBuild CVC4::options::beforeSearch :predicate-include "options/options_handler_interface.h" turn on proof generation -option checkProofs check-proofs --check-proofs bool :link --proof :link-smt produce-proofs :predicate CVC4::smt::beforeSearch :predicate-include "smt/options_handlers.h" :read-write +option checkProofs check-proofs --check-proofs bool :link --proof :link-smt produce-proofs :predicate CVC4::options::beforeSearch :predicate-include "options/options_handler_interface.h" :read-write after UNSAT/VALID, machine-check the generated proof option dumpProofs --dump-proofs bool :default false :link --proof output proofs after every UNSAT/VALID response @@ -39,19 +39,19 @@ option dumpInstantiations --dump-instantiations bool :default false output instantiations of quantified formulas after every UNSAT/VALID response option dumpSynth --dump-synth bool :read-write :default false output solution for synthesis conjectures after every UNSAT/VALID response -option unsatCores produce-unsat-cores --produce-unsat-cores bool :predicate CVC4::smt::proofEnabledBuild CVC4::smt::beforeSearch :predicate-include "smt/options_handlers.h" +option unsatCores produce-unsat-cores --produce-unsat-cores bool :predicate CVC4::options::proofEnabledBuild CVC4::options::beforeSearch :predicate-include "options/options_handler_interface.h" turn on unsat core generation option checkUnsatCores check-unsat-cores --check-unsat-cores bool :link --produce-unsat-cores :link-smt produce-unsat-cores :read-write after UNSAT/VALID, produce and check an unsat core (expensive) -option dumpUnsatCores --dump-unsat-cores bool :default false :link --produce-unsat-cores :link-smt produce-unsat-cores :predicate CVC4::smt::beforeSearch :predicate-include "smt/options_handlers.h" +option dumpUnsatCores --dump-unsat-cores bool :default false :link --produce-unsat-cores :link-smt produce-unsat-cores :predicate CVC4::options::beforeSearch :predicate-include "options/options_handler_interface.h" output unsat cores after every UNSAT/VALID response -option produceAssignments produce-assignments --produce-assignments bool :default false :predicate CVC4::smt::beforeSearch :predicate-include "smt/options_handlers.h" +option produceAssignments produce-assignments --produce-assignments bool :default false :predicate CVC4::options::beforeSearch :predicate-include "options/options_handler_interface.h" support the get-assignment command -undocumented-option interactiveMode interactive-mode bool :predicate CVC4::smt::beforeSearch CVC4::smt::setProduceAssertions :predicate-include "smt/options_handlers.h" :read-write +undocumented-option interactiveMode interactive-mode bool :predicate CVC4::options::beforeSearch CVC4::options::setProduceAssertions :predicate-include "options/options_handler_interface.h" :read-write deprecated name for produce-assertions -common-option produceAssertions produce-assertions --produce-assertions bool :predicate CVC4::smt::beforeSearch CVC4::smt::setProduceAssertions :predicate-include "smt/options_handlers.h" :read-write +common-option produceAssertions produce-assertions --produce-assertions bool :predicate CVC4::options::beforeSearch CVC4::options::setProduceAssertions :predicate-include "options/options_handler_interface.h" :read-write keep an assertions list (enables get-assertions command) option doITESimp --ite-simp bool :read-write @@ -86,18 +86,18 @@ option abstractValues abstract-values --abstract-values bool :default false option modelUninterpDtEnum --model-u-dt-enum bool :default false in models, output uninterpreted sorts as datatype enumerations -option - regular-output-channel argument :handler CVC4::smt::setRegularOutputChannel :handler-include "smt/options_handlers.h" +option - regular-output-channel argument :handler CVC4::options::setRegularOutputChannel :handler-include "options/options_handler_interface.h" set the regular output channel of the solver -option - diagnostic-output-channel argument :handler CVC4::smt::setDiagnosticOutputChannel :handler-include "smt/options_handlers.h" +option - diagnostic-output-channel argument :handler CVC4::options::setDiagnosticOutputChannel :handler-include "options/options_handler_interface.h" set the diagnostic output channel of the solver -common-option cumulativeMillisecondLimit tlimit --tlimit=MS "unsigned long" :handler CVC4::smt::tlimitHandler :handler-include "smt/options_handlers.h" +common-option cumulativeMillisecondLimit tlimit --tlimit=MS "unsigned long" :handler CVC4::options::tlimitHandler :handler-include "options/options_handler_interface.h" enable time limiting (give milliseconds) -common-option perCallMillisecondLimit tlimit-per --tlimit-per=MS "unsigned long" :handler CVC4::smt::tlimitPerHandler :handler-include "smt/options_handlers.h" +common-option perCallMillisecondLimit tlimit-per --tlimit-per=MS "unsigned long" :handler CVC4::options::tlimitPerHandler :handler-include "options/options_handler_interface.h" enable time limiting per query (give milliseconds) -common-option cumulativeResourceLimit rlimit --rlimit=N "unsigned long" :handler CVC4::smt::rlimitHandler :handler-include "smt/options_handlers.h" +common-option cumulativeResourceLimit rlimit --rlimit=N "unsigned long" :handler CVC4::options::rlimitHandler :handler-include "options/options_handler_interface.h" enable resource limiting (currently, roughly the number of SAT conflicts) -common-option perCallResourceLimit reproducible-resource-limit --rlimit-per=N "unsigned long" :handler CVC4::smt::rlimitPerHandler :handler-include "smt/options_handlers.h" +common-option perCallResourceLimit reproducible-resource-limit --rlimit-per=N "unsigned long" :handler CVC4::options::rlimitPerHandler :handler-include "options/options_handler_interface.h" enable resource limiting per query common-option hardLimit hard-limit --hard-limit bool :default false the resource limit is hard potentially leaving the smtEngine in an unsafe state (should be destroyed and rebuild after resourcing out) @@ -146,16 +146,16 @@ expert-option rewriteApplyToConst rewrite-apply-to-const --rewrite-apply-to-cons eliminate function applications, rewriting e.g. f(5) to a new symbol f_5 # --replay is currently broken; don't document it for 1.0 -undocumented-option replayFilename --replay=FILE std::string :handler CVC4::smt::checkReplayFilename :handler-include "smt/options_handlers.h" +undocumented-option replayFilename --replay=FILE std::string :handler CVC4::options::checkReplayFilename :handler-include "options/options_handler_interface.h" replay decisions from file -undocumented-option replayLog --replay-log=FILE std::ostream* :handler CVC4::smt::checkReplayLogFilename :handler-include "smt/options_handlers.h" +undocumented-option replayLog --replay-log=FILE std::ostream* :handler CVC4::options::checkReplayLogFilename :handler-include "options/options_handler_interface.h" log decisions and propagations to file option replayStream ExprStream* # portfolio options -option lemmaInputChannel LemmaInputChannel* :default NULL :include "util/lemma_input_channel.h" +option lemmaInputChannel LemmaInputChannel* :default NULL :include "base/lemma_input_channel_forward.h" The input channel to receive notfication events for new lemmas -option lemmaOutputChannel LemmaOutputChannel* :default NULL :include "util/lemma_output_channel.h" +option lemmaOutputChannel LemmaOutputChannel* :default NULL :include "base/lemma_output_channel_forward.h" The output channel to receive notfication events for new lemmas option forceNoLimitCpuWhileDump --force-no-limit-cpu-while-dump bool :default false diff --git a/src/theory/strings/options b/src/options/strings_options index 59a95e5ec..6247ad3a1 100644 --- a/src/theory/strings/options +++ b/src/options/strings_options @@ -3,15 +3,17 @@ # See src/options/base_options for a description of this file format # -module STRINGS "theory/strings/options.h" Strings theory +module STRINGS "options/strings_options.h" Strings theory option stringExp strings-exp --strings-exp bool :default false :read-write experimental features in the theory of strings -option stringLB strings-lb --strings-lb=N unsigned :default 0 :predicate options::less_equal(2) :predicate-include "smt/smt_engine.h" +# :predicate-include "smt/smt_engine.h" +option stringLB strings-lb --strings-lb=N unsigned :default 0 :predicate options::less_equal(2) :predicate-include "options/base_handlers.h" the strategy of LB rule application: 0-lazy, 1-eager, 2-no -option stdASCII strings-std-ascii --strings-std-ascii bool :default true :predicate options::less_equal(2) :predicate-include "smt/smt_engine.h" +# :predicate-include "smt/smt_engine.h" +option stdASCII strings-std-ascii --strings-std-ascii bool :default true :predicate options::less_equal(2) :predicate-include "options/base_handlers.h" the alphabet contains only characters from the standard ASCII or the extended one option stringFMF strings-fmf --strings-fmf bool :default false :read-write diff --git a/src/options/theory_options b/src/options/theory_options new file mode 100644 index 000000000..f6d6d0f84 --- /dev/null +++ b/src/options/theory_options @@ -0,0 +1,15 @@ +# +# Option specification file for CVC4 +# See src/options/base_options for a description of this file format +# + +module THEORY "options/theory_options.h" Theory layer + +expert-option theoryOfMode theoryof-mode --theoryof-mode=MODE CVC4::theory::TheoryOfMode :handler CVC4::options::stringToTheoryOfMode :handler-include "options/options_handler_interface.h" :default CVC4::theory::THEORY_OF_TYPE_BASED :include "options/theoryof_mode.h" :read-write + mode for Theory::theoryof() + +option - use-theory --use-theory=NAME argument :handler CVC4::options::useTheory :handler-include "options/options_handler_interface.h" + use alternate theory implementation NAME (--use-theory=help for a list) +option theoryAlternates ::std::map<std::string,bool> :include <map> :read-write + +endmodule diff --git a/src/options/theoryof_mode.cpp b/src/options/theoryof_mode.cpp new file mode 100644 index 000000000..c05f97ede --- /dev/null +++ b/src/options/theoryof_mode.cpp @@ -0,0 +1,21 @@ + +#include "options/theoryof_mode.h" + +#include <ostream> +#include "base/cvc4_assert.h" + +namespace CVC4 { +namespace theory { + +std::ostream& operator<<(std::ostream& out, TheoryOfMode m) throw() { + 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"; + } + + Unreachable(); +} + +}/* CVC4::theory namespace */ +}/* CVC4 namespace */ diff --git a/src/theory/theoryof_mode.h b/src/options/theoryof_mode.h index c39120216..5a8723738 100644 --- a/src/theory/theoryof_mode.h +++ b/src/options/theoryof_mode.h @@ -18,6 +18,8 @@ #pragma once +#include <ostream> + namespace CVC4 { namespace theory { @@ -29,17 +31,7 @@ enum TheoryOfMode { THEORY_OF_TERM_BASED };/* enum TheoryOfMode */ -inline std::ostream& operator<<(std::ostream& out, TheoryOfMode m) throw() CVC4_PUBLIC; - -inline std::ostream& operator<<(std::ostream& out, TheoryOfMode m) throw() { - 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"; - } - - Unreachable(); -} +std::ostream& operator<<(std::ostream& out, TheoryOfMode m) throw() CVC4_PUBLIC; }/* CVC4::theory namespace */ }/* CVC4 namespace */ diff --git a/src/theory/uf/options b/src/options/uf_options index cb6ddc0fa..baea1cb41 100644 --- a/src/theory/uf/options +++ b/src/options/uf_options @@ -3,7 +3,7 @@ # See src/options/base_options for a description of this file format # -module UF "theory/uf/options.h" Uninterpreted functions theory +module UF "options/uf_options.h" Uninterpreted functions theory option ufSymmetryBreaker uf-symmetry-breaker --symmetry-breaker bool :read-write :default true use UF symmetry breaker (Deharbe et al., CADE 2011) @@ -29,7 +29,7 @@ option ufssSimpleCliques --uf-ss-simple-cliques bool :default true always use simple clique lemmas for uf strong solver option ufssDiseqPropagation --uf-ss-deq-prop bool :default false eagerly propagate disequalities for uf strong solver -option ufssMode --uf-ss=MODE CVC4::theory::uf::UfssMode :default CVC4::theory::uf::UF_SS_FULL :include "theory/uf/options_handlers.h" :handler CVC4::theory::uf::stringToUfssMode :handler-include "theory/uf/options_handlers.h" +option ufssMode --uf-ss=MODE CVC4::theory::uf::UfssMode :default CVC4::theory::uf::UF_SS_FULL :include "options/options_handler_interface.h" :handler CVC4::options::stringToUfssMode :handler-include "options/options_handler_interface.h" mode of operation for uf strong solver. option ufssCliqueSplits --uf-ss-clique-splits bool :default false use cliques instead of splitting on demand to shrink model diff --git a/src/options/ufss_mode.h b/src/options/ufss_mode.h new file mode 100644 index 000000000..25eb1d2d7 --- /dev/null +++ b/src/options/ufss_mode.h @@ -0,0 +1,40 @@ +/********************* */ +/*! \file ufss_mode.h + ** \verbatim + ** Original author: Tim King + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** 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 { + +enum UfssMode{ + /** default, use uf strong solver to find minimal models for uninterpreted sorts */ + UF_SS_FULL, + /** use uf strong solver to shrink model sizes, but do no enforce minimality */ + UF_SS_NO_MINIMAL, + /** do not use uf strong solver */ + UF_SS_NONE, +}; + +}/* CVC4::theory::uf namespace */ +}/* CVC4::theory namespace */ +}/* CVC4 namespace */ + +#endif /* __CVC4__BASE__UFSS_MODE_H */ + diff --git a/src/parser/antlr_input.cpp b/src/parser/antlr_input.cpp index 1d2dbd736..21e48b19e 100644 --- a/src/parser/antlr_input.cpp +++ b/src/parser/antlr_input.cpp @@ -18,23 +18,22 @@ #include <antlr3.h> #include <stdint.h> +#include "base/output.h" +#include "expr/type.h" #include "parser/antlr_input.h" -#include "parser/input.h" +#include "parser/antlr_line_buffered_input.h" #include "parser/bounded_token_buffer.h" #include "parser/bounded_token_factory.h" -#include "parser/antlr_line_buffered_input.h" +#include "parser/cvc/cvc_input.h" +#include "parser/input.h" #include "parser/memory_mapped_input_buffer.h" -#include "parser/parser_exception.h" #include "parser/parser.h" - -#include "expr/command.h" -#include "expr/type.h" -#include "parser/cvc/cvc_input.h" +#include "parser/parser_exception.h" #include "parser/smt1/smt1_input.h" #include "parser/smt2/smt2_input.h" #include "parser/smt2/sygus_input.h" #include "parser/tptp/tptp_input.h" -#include "util/output.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4; diff --git a/src/parser/antlr_input.h b/src/parser/antlr_input.h index 2086db714..baec46e6f 100644 --- a/src/parser/antlr_input.h +++ b/src/parser/antlr_input.h @@ -36,14 +36,14 @@ #include <vector> #include <cassert> +#include "base/output.h" #include "parser/bounded_token_buffer.h" -#include "parser/parser_exception.h" #include "parser/input.h" - +#include "parser/parser_exception.h" #include "util/bitvector.h" #include "util/integer.h" #include "util/rational.h" -#include "util/output.h" + namespace CVC4 { diff --git a/src/parser/antlr_line_buffered_input.cpp b/src/parser/antlr_line_buffered_input.cpp index 33589110f..cc1d499fb 100644 --- a/src/parser/antlr_line_buffered_input.cpp +++ b/src/parser/antlr_line_buffered_input.cpp @@ -29,7 +29,7 @@ #include <string> #include <cassert> -#include "util/output.h" +#include "base/output.h" #include "parser/antlr_line_buffered_input.h" namespace CVC4 { diff --git a/src/parser/antlr_tracing.h b/src/parser/antlr_tracing.h index a94cd4f2f..1709e99a2 100644 --- a/src/parser/antlr_tracing.h +++ b/src/parser/antlr_tracing.h @@ -23,7 +23,8 @@ #include <iostream> #include <string> -#include "util/output.h" + +#include "base/output.h" /* The ANTLR lexer generator, as of v3.2, puts Java trace commands * into our beautiful generated C lexer! How awful! This is clearly diff --git a/src/parser/cvc/Cvc.g b/src/parser/cvc/Cvc.g index 0c356ca57..460b1ee03 100644 --- a/src/parser/cvc/Cvc.g +++ b/src/parser/cvc/Cvc.g @@ -476,10 +476,10 @@ Expr addNots(ExprManager* em, size_t n, Expr e) { # define ANTLR3_INLINE_INPUT_8BIT #endif /* CVC4_COMPETITION_MODE && !CVC4_SMTCOMP_APPLICATION_TRACK */ -#include "parser/antlr_tracing.h" -#include "util/integer.h" #include "parser/antlr_input.h" +#include "parser/antlr_tracing.h" #include "parser/parser.h" +#include "util/integer.h" }/* @lexer::includes */ @@ -487,10 +487,10 @@ Expr addNots(ExprManager* em, size_t n, Expr e) { #include <stdint.h> #include <cassert> -#include "expr/command.h" +#include "parser/antlr_tracing.h" #include "parser/parser.h" +#include "smt_util/command.h" #include "util/subrange_bound.h" -#include "parser/antlr_tracing.h" namespace CVC4 { class Expr; @@ -541,16 +541,17 @@ namespace CVC4 { @parser::postinclude { +#include <sstream> +#include <string> +#include <vector> + +#include "base/output.h" #include "expr/expr.h" #include "expr/kind.h" #include "expr/type.h" #include "parser/antlr_input.h" #include "parser/parser.h" -#include "util/output.h" -#include <vector> -#include <string> -#include <sstream> #define REPEAT_COMMAND(k, CommandCtor) \ ({ \ diff --git a/src/parser/input.cpp b/src/parser/input.cpp index 09f71800b..82b6dd32f 100644 --- a/src/parser/input.cpp +++ b/src/parser/input.cpp @@ -18,10 +18,11 @@ #include "parser/parser_exception.h" #include "parser/parser.h" -#include "expr/command.h" +#include "base/output.h" +#include "smt_util/command.h" #include "expr/type.h" #include "parser/antlr_input.h" -#include "util/output.h" + using namespace std; using namespace CVC4; diff --git a/src/parser/input.h b/src/parser/input.h index 312bc92f1..dcb54d256 100644 --- a/src/parser/input.h +++ b/src/parser/input.h @@ -20,14 +20,14 @@ #define __CVC4__PARSER__INPUT_H #include <iostream> -#include <string> #include <stdio.h> +#include <string> #include <vector> +#include "options/language.h" #include "expr/expr.h" #include "expr/expr_manager.h" #include "parser/parser_exception.h" -#include "util/language.h" namespace CVC4 { diff --git a/src/parser/memory_mapped_input_buffer.cpp b/src/parser/memory_mapped_input_buffer.cpp index 9dcab2085..7be1c9aba 100644 --- a/src/parser/memory_mapped_input_buffer.cpp +++ b/src/parser/memory_mapped_input_buffer.cpp @@ -28,8 +28,8 @@ #endif /* _WIN32 */ +#include "base/exception.h" #include "parser/memory_mapped_input_buffer.h" -#include "util/exception.h" namespace CVC4 { namespace parser { diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp index d17d5d141..0e8a9e241 100644 --- a/src/parser/parser.cpp +++ b/src/parser/parser.cpp @@ -14,24 +14,26 @@ ** Parser state implementation. **/ -#include <iostream> -#include <fstream> -#include <sstream> -#include <iterator> +#include "parser/parser.h" + #include <stdint.h> + #include <cassert> +#include <fstream> +#include <iostream> +#include <iterator> +#include <sstream> -#include "parser/input.h" -#include "parser/parser.h" -#include "parser/parser_exception.h" -#include "expr/command.h" +#include "base/output.h" #include "expr/expr.h" #include "expr/kind.h" +#include "expr/resource_manager.h" #include "expr/type.h" -#include "util/output.h" -#include "util/resource_manager.h" #include "options/options.h" -#include "smt/options.h" +#include "options/smt_options.h" +#include "parser/input.h" +#include "parser/parser_exception.h" +#include "smt_util/command.h" using namespace std; using namespace CVC4::kind; diff --git a/src/parser/parser_builder.cpp b/src/parser/parser_builder.cpp index a2faec704..08e0232aa 100644 --- a/src/parser/parser_builder.cpp +++ b/src/parser/parser_builder.cpp @@ -13,20 +13,19 @@ ** ** A builder for parsers. **/ +#include "parser/parser_builder.h" #include <string> -#include "parser/parser_builder.h" +#include "expr/expr_manager.h" +#include "options/parser_options.h" +#include "options/smt_options.h" #include "parser/input.h" #include "parser/parser.h" #include "smt1/smt1.h" #include "smt2/smt2.h" #include "tptp/tptp.h" -#include "expr/expr_manager.h" -#include "parser/options.h" -#include "smt/options.h" - namespace CVC4 { namespace parser { @@ -168,7 +167,7 @@ ParserBuilder& ParserBuilder::withOptions(const Options& options) { .withParseOnly(options[options::parseOnly]) .withIncludeFile(options[options::filesystemAccess]); if(options.wasSetByUser(options::forceLogic)) { - retval = retval.withForcedLogic(options[options::forceLogic].getLogicString()); + retval = retval.withForcedLogic(options[options::forceLogic]->getLogicString()); } return retval; } diff --git a/src/parser/parser_builder.h b/src/parser/parser_builder.h index 71810bf7c..fe652286b 100644 --- a/src/parser/parser_builder.h +++ b/src/parser/parser_builder.h @@ -21,10 +21,9 @@ #include <string> +#include "options/language.h" #include "parser/input.h" -#include "util/language.h" - namespace CVC4 { class ExprManager; diff --git a/src/parser/parser_exception.h b/src/parser/parser_exception.h index 3b211371c..de47767c9 100644 --- a/src/parser/parser_exception.h +++ b/src/parser/parser_exception.h @@ -23,7 +23,7 @@ #include <string> #include <sstream> -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { namespace parser { diff --git a/src/parser/smt1/Smt1.g b/src/parser/smt1/Smt1.g index a885fe990..98825f1c3 100644 --- a/src/parser/smt1/Smt1.g +++ b/src/parser/smt1/Smt1.g @@ -63,7 +63,7 @@ options { #include <stdint.h> -#include "expr/command.h" +#include "smt_util/command.h" #include "parser/parser.h" #include "parser/antlr_tracing.h" @@ -101,6 +101,9 @@ namespace CVC4 { @parser::postinclude { +#include <vector> + +#include "base/output.h" #include "expr/expr.h" #include "expr/kind.h" #include "expr/type.h" @@ -108,9 +111,7 @@ namespace CVC4 { #include "parser/parser.h" #include "parser/smt1/smt1.h" #include "util/integer.h" -#include "util/output.h" #include "util/rational.h" -#include <vector> using namespace CVC4; using namespace CVC4::parser; @@ -573,7 +574,7 @@ annotation[CVC4::Command*& smt_command] annotatedFormulas[pats,pat] '}' | attribute[key] ( userValue[value] - { smt_command = new SetInfoCommand(key.c_str() + 1, value); } + { smt_command = new SetInfoCommand(key.c_str() + 1, SExpr(value)); } | { smt_command = new EmptyCommand(std::string("annotation: ") + key); } ) ; diff --git a/src/parser/smt1/smt1.cpp b/src/parser/smt1/smt1.cpp index 8d827b17e..01bc8901e 100644 --- a/src/parser/smt1/smt1.cpp +++ b/src/parser/smt1/smt1.cpp @@ -18,7 +18,7 @@ namespace std { } #include "expr/type.h" -#include "expr/command.h" +#include "smt_util/command.h" #include "parser/parser.h" #include "parser/smt1/smt1.h" diff --git a/src/parser/smt2/Smt2.g b/src/parser/smt2/Smt2.g index d2409ba15..8ac1fa34c 100644 --- a/src/parser/smt2/Smt2.g +++ b/src/parser/smt2/Smt2.g @@ -75,9 +75,9 @@ using namespace CVC4::parser; }/* @lexer::postinclude */ @parser::includes { -#include "expr/command.h" #include "parser/parser.h" #include "parser/antlr_tracing.h" +#include "smt_util/command.h" namespace CVC4 { class Expr; @@ -102,21 +102,22 @@ namespace CVC4 { @parser::postinclude { +#include <set> +#include <sstream> +#include <string> +#include <vector> + +#include "base/output.h" #include "expr/expr.h" #include "expr/kind.h" #include "expr/type.h" #include "parser/antlr_input.h" #include "parser/parser.h" #include "parser/smt2/smt2.h" +#include "util/floatingpoint.h" +#include "util/hash.h" #include "util/integer.h" -#include "util/output.h" #include "util/rational.h" -#include "util/hash.h" -#include "util/floatingpoint.h" -#include <vector> -#include <set> -#include <string> -#include <sstream> // \todo Review the need for this header #include "math.h" @@ -995,10 +996,7 @@ smt25Command[CVC4::Command*& cmd] /* echo */ | ECHO_TOK ( simpleSymbolicExpr[sexpr] - { std::stringstream ss; - ss << sexpr; - cmd = new EchoCommand(ss.str()); - } + { cmd = new EchoCommand(sexpr.toString()); } | { cmd = new EchoCommand(); } ) @@ -1446,12 +1444,12 @@ simpleSymbolicExprNoKeyword[CVC4::SExpr& sexpr] | HEX_LITERAL { assert( AntlrInput::tokenText($HEX_LITERAL).find("#x") == 0 ); std::string hexString = AntlrInput::tokenTextSubstr($HEX_LITERAL, 2); - sexpr = Integer(hexString, 16); + sexpr = SExpr(Integer(hexString, 16)); } | BINARY_LITERAL { assert( AntlrInput::tokenText($BINARY_LITERAL).find("#b") == 0 ); std::string binString = AntlrInput::tokenTextSubstr($BINARY_LITERAL, 2); - sexpr = Integer(binString, 2); + sexpr = SExpr(Integer(binString, 2)); } | str[s,false] { sexpr = SExpr(s); } diff --git a/src/parser/smt2/smt2.cpp b/src/parser/smt2/smt2.cpp index d3af9143a..355b58067 100644 --- a/src/parser/smt2/smt2.cpp +++ b/src/parser/smt2/smt2.cpp @@ -13,14 +13,14 @@ ** ** Definitions of SMT2 constants. **/ +#include "parser/smt2/smt2.h" + #include "expr/type.h" -#include "expr/command.h" +#include "parser/antlr_input.h" #include "parser/parser.h" #include "parser/smt1/smt1.h" -#include "parser/smt2/smt2.h" -#include "parser/antlr_input.h" - +#include "smt_util/command.h" #include "util/bitvector.h" // ANTLR defines these, which is really bad! diff --git a/src/parser/tptp/Tptp.g b/src/parser/tptp/Tptp.g index 62dcc70f5..a2bad4988 100644 --- a/src/parser/tptp/Tptp.g +++ b/src/parser/tptp/Tptp.g @@ -83,7 +83,7 @@ using namespace CVC4::parser; }/* @lexer::postinclude */ @parser::includes { -#include "expr/command.h" +#include "smt_util/command.h" #include "parser/parser.h" #include "parser/tptp/tptp.h" #include "parser/antlr_tracing.h" @@ -92,6 +92,11 @@ using namespace CVC4::parser; @parser::postinclude { +#include <algorithm> +#include <iterator> +#include <vector> + +#include "base/output.h" #include "expr/expr.h" #include "expr/kind.h" #include "expr/type.h" @@ -99,11 +104,7 @@ using namespace CVC4::parser; #include "parser/parser.h" #include "parser/tptp/tptp.h" #include "util/integer.h" -#include "util/output.h" #include "util/rational.h" -#include <vector> -#include <iterator> -#include <algorithm> using namespace CVC4; using namespace CVC4::parser; @@ -203,7 +204,7 @@ parseCommand returns [CVC4::Command* cmd = NULL] filename = filename.substr(0, filename.length() - 2); } CommandSequence* seq = new CommandSequence(); - seq->addCommand(new SetInfoCommand("name", filename)); + seq->addCommand(new SetInfoCommand("name", SExpr(filename))); if(PARSER_STATE->hasConjecture()) { seq->addCommand(new QueryCommand(MK_CONST(bool(false)))); } else { diff --git a/src/parser/tptp/tptp.h b/src/parser/tptp/tptp.h index 2cd8f4339..4fdbc236d 100644 --- a/src/parser/tptp/tptp.h +++ b/src/parser/tptp/tptp.h @@ -19,13 +19,14 @@ #ifndef __CVC4__PARSER__TPTP_H #define __CVC4__PARSER__TPTP_H -#include "parser/parser.h" -#include "expr/command.h" -#include "util/hash.h" -#include <ext/hash_set> #include <cassert> -#include "parser/options.h" +#include <ext/hash_set> + +#include "options/parser_options.h" #include "parser/antlr_input.h" +#include "parser/parser.h" +#include "smt_util/command.h" +#include "util/hash.h" namespace CVC4 { diff --git a/src/printer/ast/ast_printer.cpp b/src/printer/ast/ast_printer.cpp index c24ed8372..b26a983be 100644 --- a/src/printer/ast/ast_printer.cpp +++ b/src/printer/ast/ast_printer.cpp @@ -13,20 +13,20 @@ ** ** The pretty-printer interface for the AST output language. **/ - #include "printer/ast/ast_printer.h" -#include "expr/expr.h" // for ExprSetDepth etc.. -#include "util/language.h" // for LANG_AST -#include "expr/node_manager_attributes.h" // for VarNameAttr -#include "expr/command.h" -#include "printer/dagification_visitor.h" -#include "util/node_visitor.h" -#include "theory/substitutions.h" #include <iostream> -#include <vector> #include <string> #include <typeinfo> +#include <vector> + +#include "expr/expr.h" // for ExprSetDepth etc.. +#include "expr/node_manager_attributes.h" // for VarNameAttr +#include "options/language.h" // for LANG_AST +#include "printer/dagification_visitor.h" +#include "smt_util/command.h" +#include "smt_util/node_visitor.h" +#include "theory/substitutions.h" using namespace std; @@ -398,4 +398,3 @@ static bool tryToStream(std::ostream& out, const CommandStatus* s) throw() { }/* CVC4::printer::ast namespace */ }/* CVC4::printer namespace */ }/* CVC4 namespace */ - diff --git a/src/printer/cvc/cvc_printer.cpp b/src/printer/cvc/cvc_printer.cpp index 2e1170666..d33b97d66 100644 --- a/src/printer/cvc/cvc_printer.cpp +++ b/src/printer/cvc/cvc_printer.cpp @@ -15,25 +15,26 @@ **/ #include "printer/cvc/cvc_printer.h" -#include "expr/expr.h" // for ExprSetDepth etc.. -#include "util/language.h" // for LANG_AST -#include "expr/node_manager_attributes.h" // for VarNameAttr -#include "expr/command.h" -#include "theory/substitutions.h" -#include "smt/smt_engine.h" -#include "smt/options.h" -#include "theory/theory_model.h" -#include "theory/arrays/theory_arrays_rewriter.h" -#include "printer/dagification_visitor.h" -#include "util/node_visitor.h" -#include <iostream> -#include <vector> -#include <string> -#include <typeinfo> #include <algorithm> +#include <iostream> #include <iterator> #include <stack> +#include <string> +#include <typeinfo> +#include <vector> + +#include "expr/expr.h" // for ExprSetDepth etc.. +#include "expr/node_manager_attributes.h" // for VarNameAttr +#include "options/language.h" // for LANG_AST +#include "printer/dagification_visitor.h" +#include "options/smt_options.h" +#include "smt/smt_engine.h" +#include "smt_util/command.h" +#include "smt_util/node_visitor.h" +#include "theory/arrays/theory_arrays_rewriter.h" +#include "theory/substitutions.h" +#include "theory/theory_model.h" using namespace std; @@ -894,10 +895,6 @@ void CvcPrinter::toStream(std::ostream& out, const Command* c, }/* CvcPrinter::toStream(Command*) */ -static inline void toStream(std::ostream& out, const SExpr& sexpr) throw() { - Printer::getPrinter(language::output::LANG_CVC4)->toStream(out, sexpr); -} - template <class T> static bool tryToStream(std::ostream& out, const CommandStatus* s, bool cvc3Mode) throw(); @@ -1170,7 +1167,9 @@ static void toStream(std::ostream& out, const SetBenchmarkLogicCommand* c, bool static void toStream(std::ostream& out, const SetInfoCommand* c, bool cvc3Mode) throw() { out << "% (set-info " << c->getFlag() << " "; - toStream(out, c->getSExpr()); + OutputLanguage language = + cvc3Mode ? language::output::LANG_CVC3 : language::output::LANG_CVC4; + SExpr::toStream(out, c->getSExpr(), language); out << ")"; } @@ -1180,7 +1179,7 @@ static void toStream(std::ostream& out, const GetInfoCommand* c, bool cvc3Mode) static void toStream(std::ostream& out, const SetOptionCommand* c, bool cvc3Mode) throw() { out << "OPTION \"" << c->getFlag() << "\" "; - toStream(out, c->getSExpr()); + SExpr::toStream(out, c->getSExpr(), language::output::LANG_CVC4); out << ";"; } diff --git a/src/printer/options b/src/printer/options deleted file mode 100644 index 4daa9c77d..000000000 --- a/src/printer/options +++ /dev/null @@ -1,14 +0,0 @@ -# -# Option specification file for CVC4 -# See src/options/base_options for a description of this file format -# - -module PRINTER "printer/options.h" Printing - -option modelFormatMode --model-format=MODE ModelFormatMode :handler CVC4::printer::stringToModelFormatMode :default MODEL_FORMAT_MODE_DEFAULT :read-write :include "printer/modes.h" :handler-include "printer/options_handlers.h" - print format mode for models, see --model-format=help - -option instFormatMode --inst-format=MODE InstFormatMode :handler CVC4::printer::stringToInstFormatMode :default INST_FORMAT_MODE_DEFAULT :read-write :include "printer/modes.h" :handler-include "printer/options_handlers.h" - print format mode for instantiations, see --inst-format=help - -endmodule diff --git a/src/printer/options_handlers.h b/src/printer/options_handlers.h deleted file mode 100644 index 64b585a94..000000000 --- a/src/printer/options_handlers.h +++ /dev/null @@ -1,77 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: Andrew Reynolds - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Custom handlers and predicates for printer options - ** - ** Custom handlers and predicates for printer options. - **/ - -#include "cvc4_private.h" - -#ifndef __CVC4__PRINTER__OPTIONS_HANDLERS_H -#define __CVC4__PRINTER__OPTIONS_HANDLERS_H - -#include "printer/modes.h" - -namespace CVC4 { -namespace printer { - -static const std::string 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\ -"; - -static const std::string instFormatHelp = "\ -Inst format modes currently supported by the --model-format option:\n\ -\n\ -default \n\ -+ Print instantiations as a list in the output language format.\n\ -\n\ -szs\n\ -+ Print instantiations as SZS compliant proof.\n\ -"; - -inline ModelFormatMode stringToModelFormatMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "default") { - return MODEL_FORMAT_MODE_DEFAULT; - } else if(optarg == "table") { - return MODEL_FORMAT_MODE_TABLE; - } else if(optarg == "help") { - puts(modelFormatHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --model-format: `") + - optarg + "'. Try --model-format help."); - } -} - -inline InstFormatMode stringToInstFormatMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "default") { - return INST_FORMAT_MODE_DEFAULT; - } else if(optarg == "szs") { - return INST_FORMAT_MODE_SZS; - } else if(optarg == "help") { - puts(instFormatHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --inst-format: `") + - optarg + "'. Try --inst-format help."); - } -} -}/* CVC4::printer namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__PRINTER__OPTIONS_HANDLERS_H */ diff --git a/src/printer/printer.cpp b/src/printer/printer.cpp index 242638f82..75d625edc 100644 --- a/src/printer/printer.cpp +++ b/src/printer/printer.cpp @@ -13,25 +13,22 @@ ** ** Base of the pretty-printer interface. **/ - #include "printer/printer.h" -#include "util/language.h" +#include <string> +#include "options/language.h" +#include "printer/ast/ast_printer.h" +#include "printer/cvc/cvc_printer.h" #include "printer/smt1/smt1_printer.h" #include "printer/smt2/smt2_printer.h" #include "printer/tptp/tptp_printer.h" -#include "printer/cvc/cvc_printer.h" -#include "printer/ast/ast_printer.h" - -#include <string> using namespace std; namespace CVC4 { Printer* Printer::d_printers[language::output::LANG_MAX]; -const int PrettySExprs::s_iosIndex = std::ios_base::xalloc(); Printer* Printer::makePrinter(OutputLanguage lang) throw() { using namespace CVC4::language::output; @@ -57,7 +54,7 @@ Printer* Printer::makePrinter(OutputLanguage lang) throw() { case LANG_SYGUS: return new printer::smt2::Smt2Printer(printer::smt2::sygus_variant); - + case LANG_AST: return new printer::ast::AstPrinter(); @@ -69,89 +66,7 @@ Printer* Printer::makePrinter(OutputLanguage lang) throw() { } }/* Printer::makePrinter() */ -void Printer::toStream(std::ostream& out, const Result& r) const throw() { - if(r.getType() == Result::TYPE_SAT) { - switch(r.isSat()) { - case Result::UNSAT: - out << "unsat"; - break; - case Result::SAT: - out << "sat"; - break; - case Result::SAT_UNKNOWN: - out << "unknown"; - if(r.whyUnknown() != Result::UNKNOWN_REASON) { - out << " (" << r.whyUnknown() << ")"; - } - break; - } - } else { - switch(r.isValid()) { - case Result::INVALID: - out << "invalid"; - break; - case Result::VALID: - out << "valid"; - break; - case Result::VALIDITY_UNKNOWN: - out << "unknown"; - if(r.whyUnknown() != Result::UNKNOWN_REASON) { - out << " (" << r.whyUnknown() << ")"; - } - break; - } - } -}/* Printer::toStream() */ - -static void toStreamRec(std::ostream& out, const SExpr& sexpr, int indent) throw() { - if(sexpr.isInteger()) { - out << sexpr.getIntegerValue(); - } else if(sexpr.isRational()) { - out << fixed << sexpr.getRationalValue().getDouble(); - } else if(sexpr.isKeyword()) { - out << sexpr.getValue(); - } else if(sexpr.isString()) { - string s = sexpr.getValue(); - // escape backslash and quote - for(size_t i = 0; i < s.length(); ++i) { - if(s[i] == '"') { - s.replace(i, 1, "\\\""); - ++i; - } else if(s[i] == '\\') { - s.replace(i, 1, "\\\\"); - ++i; - } - } - out << "\"" << s << "\""; - } else { - const vector<SExpr>& kids = sexpr.getChildren(); - out << (indent > 0 && kids.size() > 1 ? "( " : "("); - bool first = true; - for(vector<SExpr>::const_iterator i = kids.begin(); i != kids.end(); ++i) { - if(first) { - first = false; - } else { - if(indent > 0) { - out << "\n" << string(indent, ' '); - } else { - out << ' '; - } - } - toStreamRec(out, *i, indent <= 0 || indent > 2 ? 0 : indent + 2); - } - if(indent > 0 && kids.size() > 1) { - out << '\n'; - if(indent > 2) { - out << string(indent - 2, ' '); - } - } - out << ')'; - } -}/* toStreamRec() */ -void Printer::toStream(std::ostream& out, const SExpr& sexpr) const throw() { - toStreamRec(out, sexpr, PrettySExprs::getPrettySExprs(out) ? 2 : 0); -}/* Printer::toStream(SExpr) */ void Printer::toStream(std::ostream& out, const Model& m) const throw() { for(size_t i = 0; i < m.getNumCommands(); ++i) { diff --git a/src/printer/printer.h b/src/printer/printer.h index 44e5ac9f4..30d33d46b 100644 --- a/src/printer/printer.h +++ b/src/printer/printer.h @@ -22,11 +22,11 @@ #include <map> #include <string> -#include "util/language.h" -#include "util/sexpr.h" -#include "util/model.h" #include "expr/node.h" -#include "expr/command.h" +#include "expr/sexpr.h" +#include "options/language.h" +#include "smt_util/command.h" +#include "smt_util/model.h" namespace CVC4 { @@ -91,18 +91,7 @@ public: /** Write a CommandStatus out to a stream with this Printer. */ virtual void toStream(std::ostream& out, const CommandStatus* s) const throw() = 0; - /** Write an SExpr out to a stream with this Printer. */ - virtual void toStream(std::ostream& out, const SExpr& sexpr) const throw(); - /** - * Write a Result out to a stream with this Printer. - * - * The default implementation writes a reasonable string in lowercase - * for sat, unsat, valid, invalid, or unknown results. This behavior - * is overridable by each Printer, since sometimes an output language - * has a particular preference for how results should appear. - */ - virtual void toStream(std::ostream& out, const Result& r) const throw(); /** Write a Model out to a stream with this Printer. */ virtual void toStream(std::ostream& out, const Model& m) const throw(); @@ -115,78 +104,6 @@ public: };/* class Printer */ -/** - * IOStream manipulator to pretty-print SExprs. - */ -class PrettySExprs { - /** - * The allocated index in ios_base for our setting. - */ - static const int s_iosIndex; - - /** - * When this manipulator is used, the setting is stored here. - */ - bool d_prettySExprs; - -public: - /** - * Construct a PrettySExprs with the given setting. - */ - PrettySExprs(bool prettySExprs) : d_prettySExprs(prettySExprs) {} - - inline void applyPrettySExprs(std::ostream& out) { - out.iword(s_iosIndex) = d_prettySExprs; - } - - static inline bool getPrettySExprs(std::ostream& out) { - return out.iword(s_iosIndex); - } - - static inline void setPrettySExprs(std::ostream& out, bool prettySExprs) { - out.iword(s_iosIndex) = prettySExprs; - } - - /** - * Set the pretty-sexprs state on the output stream for the current - * stack scope. This makes sure the old state is reset on the - * stream after normal OR exceptional exit from the scope, using the - * RAII C++ idiom. - */ - class Scope { - std::ostream& d_out; - bool d_oldPrettySExprs; - - public: - - inline Scope(std::ostream& out, bool prettySExprs) : - d_out(out), - d_oldPrettySExprs(PrettySExprs::getPrettySExprs(out)) { - PrettySExprs::setPrettySExprs(out, prettySExprs); - } - - inline ~Scope() { - PrettySExprs::setPrettySExprs(d_out, d_oldPrettySExprs); - } - - };/* class PrettySExprs::Scope */ - -};/* class PrettySExprs */ - -/** - * Sets the default pretty-sexprs setting for an ostream. Use like this: - * - * // let out be an ostream, s an SExpr - * out << PrettySExprs(true) << s << endl; - * - * The setting stays permanently (until set again) with the stream. - */ -inline std::ostream& operator<<(std::ostream& out, PrettySExprs ps) { - ps.applyPrettySExprs(out); - return out; -} - }/* CVC4 namespace */ #endif /* __CVC4__PRINTER__PRINTER_H */ - diff --git a/src/printer/smt1/smt1_printer.cpp b/src/printer/smt1/smt1_printer.cpp index 05714fbce..87880d3bc 100644 --- a/src/printer/smt1/smt1_printer.cpp +++ b/src/printer/smt1/smt1_printer.cpp @@ -13,17 +13,17 @@ ** ** The pretty-printer interface for the SMT output language. **/ - #include "printer/smt1/smt1_printer.h" -#include "expr/expr.h" // for ExprSetDepth etc.. -#include "util/language.h" // for LANG_AST -#include "expr/node_manager.h" // for VarNameAttr -#include "expr/command.h" #include <iostream> -#include <vector> #include <string> #include <typeinfo> +#include <vector> + +#include "expr/expr.h" // for ExprSetDepth etc.. +#include "expr/node_manager.h" // for VarNameAttr +#include "options/language.h" // for LANG_AST +#include "smt_util/command.h" using namespace std; @@ -45,9 +45,6 @@ void Smt1Printer::toStream(std::ostream& out, const CommandStatus* s) const thro s->toStream(out, language::output::LANG_SMTLIB_V2_5); }/* Smt1Printer::toStream() */ -void Smt1Printer::toStream(std::ostream& out, const SExpr& sexpr) const throw() { - Printer::getPrinter(language::output::LANG_SMTLIB_V2_5)->toStream(out, sexpr); -}/* Smt1Printer::toStream() */ void Smt1Printer::toStream(std::ostream& out, const Model& m) const throw() { Printer::getPrinter(language::output::LANG_SMTLIB_V2_5)->toStream(out, m); @@ -61,4 +58,3 @@ void Smt1Printer::toStream(std::ostream& out, const Model& m, const Command* c) }/* CVC4::printer::smt1 namespace */ }/* CVC4::printer namespace */ }/* CVC4 namespace */ - diff --git a/src/printer/smt2/smt2_printer.cpp b/src/printer/smt2/smt2_printer.cpp index 56ad9c35a..f93857796 100644 --- a/src/printer/smt2/smt2_printer.cpp +++ b/src/printer/smt2/smt2_printer.cpp @@ -17,22 +17,22 @@ #include "printer/smt2/smt2_printer.h" #include <iostream> -#include <vector> #include <string> #include <typeinfo> +#include <vector> -#include "util/boolean_simplification.h" +#include "expr/node_manager_attributes.h" +#include "options/language.h" +#include "options/smt_options.h" #include "printer/dagification_visitor.h" -#include "util/node_visitor.h" -#include "theory/substitutions.h" -#include "util/language.h" #include "smt/smt_engine.h" -#include "smt/options.h" -#include "expr/node_manager_attributes.h" - -#include "theory/theory_model.h" +#include "smt_util/boolean_simplification.h" +#include "smt_util/node_visitor.h" #include "theory/arrays/theory_arrays_rewriter.h" #include "theory/quantifiers/term_database.h" +#include "theory/substitutions.h" +#include "theory/theory_model.h" +#include "util/smt2_quote_string.h" using namespace std; @@ -40,6 +40,8 @@ namespace CVC4 { namespace printer { namespace smt2 { +static OutputLanguage variantToLanguage(Variant v) throw(); + static string smtKindString(Kind k) throw(); static void printBvParameterizedOp(std::ostream& out, TNode n) throw(); @@ -971,38 +973,14 @@ void Smt2Printer::toStream(std::ostream& out, const Command* c, }/* Smt2Printer::toStream(Command*) */ -static inline void toStream(std::ostream& out, const SExpr& sexpr) throw() { - Printer::getPrinter(language::output::LANG_SMTLIB_V2_5)->toStream(out, sexpr); -} - -// SMT-LIB quoting for symbols -static std::string quoteSymbol(std::string s) { - if(s.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@$%^&*_-+=<>.?/") == std::string::npos) { - // simple unquoted symbol - return s; - } - - // must quote the symbol, but it cannot contain | or \, we turn those into _ - size_t p; - while((p = s.find_first_of("\\|")) != std::string::npos) { - s = s.replace(p, 1, "_"); - } - return "|" + s + "|"; -} static std::string quoteSymbol(TNode n) { +#warning "check the old implementation. It seems off." std::stringstream ss; ss << Expr::setlanguage(language::output::LANG_SMTLIB_V2_5); - return quoteSymbol(ss.str()); + return CVC4::quoteSymbol(ss.str()); } -void Smt2Printer::toStream(std::ostream& out, const SExpr& sexpr) const throw() { - if(sexpr.isKeyword()) { - out << quoteSymbol(sexpr.getValue()); - } else { - this->Printer::toStream(out, sexpr); - } -} template <class T> static bool tryToStream(std::ostream& out, const CommandStatus* s, Variant v) throw(); @@ -1047,29 +1025,33 @@ void Smt2Printer::toStream(std::ostream& out, const Model& m, const Command* c) const theory::TheoryModel& tm = (const theory::TheoryModel&) m; if(dynamic_cast<const DeclareTypeCommand*>(c) != NULL) { TypeNode tn = TypeNode::fromType( ((const DeclareTypeCommand*)c)->getType() ); - if( options::modelUninterpDtEnum() && tn.isSort() && - tm.d_rep_set.d_type_reps.find( tn )!=tm.d_rep_set.d_type_reps.end() ){ + const std::map< TypeNode, std::vector< Node > >& type_reps = tm.d_rep_set.d_type_reps; + + std::map< TypeNode, std::vector< Node > >::const_iterator tn_iterator = type_reps.find( tn ); + if( options::modelUninterpDtEnum() && tn.isSort() && tn_iterator != type_reps.end() ){ out << "(declare-datatypes () ((" << dynamic_cast<const DeclareTypeCommand*>(c)->getSymbol() << " "; - for( size_t i=0; i<(*tm.d_rep_set.d_type_reps.find(tn)).second.size(); i++ ){ - out << "(" << (*tm.d_rep_set.d_type_reps.find(tn)).second[i] << ")"; + + for( size_t i=0, N = tn_iterator->second.size(); i < N; i++ ){ + out << "(" << (*tn_iterator).second[i] << ")"; } out << ")))" << endl; } else { if( tn.isSort() ){ //print the cardinality - if( tm.d_rep_set.d_type_reps.find( tn )!=tm.d_rep_set.d_type_reps.end() ){ - out << "; cardinality of " << tn << " is " << (*tm.d_rep_set.d_type_reps.find(tn)).second.size() << endl; + if( tn_iterator != type_reps.end() ) { + out << "; cardinality of " << tn << " is " << tn_iterator->second.size() << endl; } } out << c << endl; if( tn.isSort() ){ //print the representatives - if( tm.d_rep_set.d_type_reps.find( tn )!=tm.d_rep_set.d_type_reps.end() ){ - for( size_t i=0; i<(*tm.d_rep_set.d_type_reps.find(tn)).second.size(); i++ ){ - if( (*tm.d_rep_set.d_type_reps.find(tn)).second[i].isVar() ){ - out << "(declare-fun " << quoteSymbol((*tm.d_rep_set.d_type_reps.find(tn)).second[i]) << " () " << tn << ")" << endl; + if( tn_iterator != type_reps.end() ){ + for( size_t i = 0, N = (*tn_iterator).second.size(); i < N; i++ ){ + TNode current = (*tn_iterator).second[i]; + if( current.isVar() ){ + out << "(declare-fun " << quoteSymbol(current) << " () " << tn << ")" << endl; }else{ - out << "; rep: " << (*tm.d_rep_set.d_type_reps.find(tn)).second[i] << endl; + out << "; rep: " << current << endl; } } } @@ -1138,13 +1120,6 @@ void Smt2Printer::toStream(std::ostream& out, const Model& m, const Command* c) } } -void Smt2Printer::toStream(std::ostream& out, const Result& r) const throw() { - if(r.getType() == Result::TYPE_SAT && r.isSat() == Result::SAT_UNKNOWN) { - out << "unknown"; - } else { - Printer::toStream(out, r); - } -} static void toStream(std::ostream& out, const AssertCommand* c) throw() { out << "(assert " << c->getExpr() << ")"; @@ -1210,7 +1185,7 @@ static void toStream(std::ostream& out, const CommandSequence* c) throw() { static void toStream(std::ostream& out, const DeclareFunctionCommand* c) throw() { Type type = c->getType(); - out << "(declare-fun " << quoteSymbol(c->getSymbol()) << " ("; + out << "(declare-fun " << CVC4::quoteSymbol(c->getSymbol()) << " ("; if(type.isFunction()) { FunctionType ft = type; const vector<Type> argTypes = ft.getArgTypes(); @@ -1389,7 +1364,8 @@ static void toStream(std::ostream& out, const SetInfoCommand* c, Variant v) thro } else { out << "(meta-info :" << c->getFlag() << " "; } - toStream(out, c->getSExpr()); + + SExpr::toStream(out, c->getSExpr(), variantToLanguage(v)); out << ")"; } @@ -1399,7 +1375,7 @@ static void toStream(std::ostream& out, const GetInfoCommand* c) throw() { static void toStream(std::ostream& out, const SetOptionCommand* c) throw() { out << "(set-option :" << c->getFlag() << " "; - toStream(out, c->getSExpr()); + SExpr::toStream(out, c->getSExpr(), language::output::LANG_SMTLIB_V2_5); out << ")"; } @@ -1518,6 +1494,20 @@ static bool tryToStream(std::ostream& out, const CommandStatus* s, Variant v) th return false; } +static OutputLanguage variantToLanguage(Variant variant) throw() { + switch(variant) { + case smt2_0_variant: + return language::output::LANG_SMTLIB_V2_0; + case z3str_variant: + return language::output::LANG_Z3STR; + case sygus_variant: + return language::output::LANG_SYGUS; + case no_variant: + default: + return language::output::LANG_SMTLIB_V2_5; + } +} + }/* CVC4::printer::smt2 namespace */ }/* CVC4::printer namespace */ }/* CVC4 namespace */ diff --git a/src/printer/smt2/smt2_printer.h b/src/printer/smt2/smt2_printer.h index ba6276aa2..a57c4f8dc 100644 --- a/src/printer/smt2/smt2_printer.h +++ b/src/printer/smt2/smt2_printer.h @@ -45,7 +45,6 @@ public: void toStream(std::ostream& out, TNode n, int toDepth, bool types, size_t dag) const throw(); void toStream(std::ostream& out, const Command* c, int toDepth, bool types, size_t dag) const throw(); void toStream(std::ostream& out, const CommandStatus* s) const throw(); - void toStream(std::ostream& out, const Result& r) const throw(); void toStream(std::ostream& out, const SExpr& sexpr) const throw(); void toStream(std::ostream& out, const Model& m) const throw(); void toStream(std::ostream& out, const UnsatCore& core, const std::map<Expr, std::string>& names) const throw(); diff --git a/src/printer/tptp/tptp_printer.cpp b/src/printer/tptp/tptp_printer.cpp index 3c46a5849..923a7b3aa 100644 --- a/src/printer/tptp/tptp_printer.cpp +++ b/src/printer/tptp/tptp_printer.cpp @@ -13,17 +13,17 @@ ** ** The pretty-printer interface for the TPTP output language. **/ - #include "printer/tptp/tptp_printer.h" -#include "expr/expr.h" // for ExprSetDepth etc.. -#include "util/language.h" // for LANG_AST -#include "expr/node_manager.h" // for VarNameAttr -#include "expr/command.h" #include <iostream> -#include <vector> #include <string> #include <typeinfo> +#include <vector> + +#include "expr/expr.h" // for ExprSetDepth etc.. +#include "expr/node_manager.h" // for VarNameAttr +#include "options/language.h" // for LANG_AST +#include "smt_util/command.h" using namespace std; @@ -45,9 +45,6 @@ void TptpPrinter::toStream(std::ostream& out, const CommandStatus* s) const thro s->toStream(out, language::output::LANG_SMTLIB_V2_5); }/* TptpPrinter::toStream() */ -void TptpPrinter::toStream(std::ostream& out, const SExpr& sexpr) const throw() { - Printer::getPrinter(language::output::LANG_SMTLIB_V2_5)->toStream(out, sexpr); -}/* TptpPrinter::toStream() */ void TptpPrinter::toStream(std::ostream& out, const Model& m) const throw() { out << "% SZS output start FiniteModel for " << m.getInputName() << endl; @@ -62,21 +59,6 @@ void TptpPrinter::toStream(std::ostream& out, const Model& m, const Command* c) Unreachable(); } -void TptpPrinter::toStream(std::ostream& out, const Result& r) const throw() { - out << "% SZS status "; - if(r.isSat() == Result::SAT) { - out << "Satisfiable"; - } else if(r.isSat() == Result::UNSAT) { - out << "Unsatisfiable"; - } else if(r.isValid() == Result::VALID) { - out << "Theorem"; - } else if(r.isValid() == Result::INVALID) { - out << "CounterSatisfiable"; - } else { - out << "GaveUp"; - } - out << " for " << r.getInputName(); -} }/* CVC4::printer::tptp namespace */ }/* CVC4::printer namespace */ diff --git a/src/printer/tptp/tptp_printer.h b/src/printer/tptp/tptp_printer.h index bc0633822..90a682bcc 100644 --- a/src/printer/tptp/tptp_printer.h +++ b/src/printer/tptp/tptp_printer.h @@ -34,9 +34,7 @@ public: void toStream(std::ostream& out, TNode n, int toDepth, bool types, size_t dag) const throw(); void toStream(std::ostream& out, const Command* c, int toDepth, bool types, size_t dag) const throw(); void toStream(std::ostream& out, const CommandStatus* s) const throw(); - void toStream(std::ostream& out, const SExpr& sexpr) const throw(); void toStream(std::ostream& out, const Model& m) const throw(); - void toStream(std::ostream& out, const Result& r) const throw(); };/* class TptpPrinter */ }/* CVC4::printer::tptp namespace */ diff --git a/src/proof/proof.h b/src/proof/proof.h index 25979dc46..ae4c940a0 100644 --- a/src/proof/proof.h +++ b/src/proof/proof.h @@ -19,7 +19,7 @@ #ifndef __CVC4__PROOF__PROOF_H #define __CVC4__PROOF__PROOF_H -#include "smt/options.h" +#include "options/smt_options.h" /* Do NOT use #ifdef CVC4_PROOF to check if proofs are enabled. diff --git a/src/proof/proof_manager.cpp b/src/proof/proof_manager.cpp index 311d4afeb..88d380c4f 100644 --- a/src/proof/proof_manager.cpp +++ b/src/proof/proof_manager.cpp @@ -16,22 +16,23 @@ **/ #include "proof/proof_manager.h" -#include "util/proof.h" -#include "proof/sat_proof.h" + +#include "base/cvc4_assert.h" +#include "context/context.h" #include "proof/cnf_proof.h" +#include "proof/sat_proof.h" #include "proof/theory_proof.h" -#include "util/cvc4_assert.h" #include "smt/smt_engine.h" #include "smt/smt_engine_scope.h" +#include "smt_util/node_visitor.h" +#include "theory/arrays/theory_arrays.h" #include "theory/output_channel.h" -#include "theory/valuation.h" -#include "util/node_visitor.h" #include "theory/term_registration_visitor.h" -#include "theory/uf/theory_uf.h" #include "theory/uf/equality_engine.h" -#include "theory/arrays/theory_arrays.h" -#include "context/context.h" +#include "theory/uf/theory_uf.h" +#include "theory/valuation.h" #include "util/hash.h" +#include "util/proof.h" namespace CVC4 { diff --git a/src/util/unsat_core.cpp b/src/proof/unsat_core.cpp index 95d066c6d..4a4d13977 100644 --- a/src/util/unsat_core.cpp +++ b/src/proof/unsat_core.cpp @@ -14,10 +14,11 @@ ** Representation of unsat cores. **/ -#include "util/unsat_core.h" -#include "expr/command.h" -#include "smt/smt_engine_scope.h" +#include "proof/unsat_core.h" + #include "printer/printer.h" +#include "smt/smt_engine_scope.h" +#include "smt_util/command.h" namespace CVC4 { diff --git a/src/util/unsat_core.h b/src/proof/unsat_core.h index 644f56509..644f56509 100644 --- a/src/util/unsat_core.h +++ b/src/proof/unsat_core.h diff --git a/src/util/unsat_core.i b/src/proof/unsat_core.i index c69dade8f..cee78da06 100644 --- a/src/util/unsat_core.i +++ b/src/proof/unsat_core.i @@ -1,5 +1,5 @@ %{ -#include "util/unsat_core.h" +#include "proof/unsat_core.h" #ifdef SWIGJAVA @@ -57,7 +57,7 @@ #endif /* SWIGJAVA */ -%include "util/unsat_core.h" +%include "proof/unsat_core.h" #ifdef SWIGJAVA diff --git a/src/prop/bvminisat/core/Solver.cc b/src/prop/bvminisat/core/Solver.cc index ca7228ee8..5a37da27c 100644 --- a/src/prop/bvminisat/core/Solver.cc +++ b/src/prop/bvminisat/core/Solver.cc @@ -18,19 +18,20 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************************************/ +#include "core/Solver.h" + #include <math.h> -#include "mtl/Sort.h" -#include "core/Solver.h" #include <vector> #include <iostream> -#include "util/output.h" -#include "util/utility.h" -#include "util/exception.h" -#include "theory/bv/options.h" -#include "smt/options.h" +#include "base/exception.h" +#include "base/output.h" +#include "mtl/Sort.h" +#include "options/bv_options.h" +#include "options/smt_options.h" #include "theory/interrupted.h" +#include "util/utility.h" namespace CVC4 { namespace BVMinisat { diff --git a/src/prop/bvminisat/simp/SimpSolver.cc b/src/prop/bvminisat/simp/SimpSolver.cc index e7e489985..c5b185c95 100644 --- a/src/prop/bvminisat/simp/SimpSolver.cc +++ b/src/prop/bvminisat/simp/SimpSolver.cc @@ -18,11 +18,12 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************************************/ -#include "mtl/Sort.h" #include "simp/SimpSolver.h" + +#include "mtl/Sort.h" +#include "options/bv_options.h" +#include "options/smt_options.h" #include "utils/System.h" -#include "theory/bv/options.h" -#include "smt/options.h" namespace CVC4 { namespace BVMinisat { diff --git a/src/prop/bvminisat/simp/SimpSolver.h b/src/prop/bvminisat/simp/SimpSolver.h index 707f62e34..bef8e0a70 100644 --- a/src/prop/bvminisat/simp/SimpSolver.h +++ b/src/prop/bvminisat/simp/SimpSolver.h @@ -21,10 +21,10 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA #ifndef BVMinisat_SimpSolver_h #define BVMinisat_SimpSolver_h -#include "prop/bvminisat/mtl/Queue.h" -#include "prop/bvminisat/core/Solver.h" -#include "util/statistics_registry.h" #include "context/context.h" +#include "expr/statistics_registry.h" +#include "prop/bvminisat/core/Solver.h" +#include "prop/bvminisat/mtl/Queue.h" namespace CVC4 { namespace BVMinisat { diff --git a/src/prop/cnf_stream.cpp b/src/prop/cnf_stream.cpp index b0b135b04..ffbc67cc4 100644 --- a/src/prop/cnf_stream.cpp +++ b/src/prop/cnf_stream.cpp @@ -15,23 +15,23 @@ ** A CNF converter that takes in asserts and has the side effect ** of given an equisatisfiable stream of assertions to PropEngine. **/ +#include <queue> -#include "prop/cnf_stream.h" -#include "prop/prop_engine.h" -#include "theory/theory_engine.h" -#include "theory/theory.h" -#include "expr/node.h" -#include "util/cvc4_assert.h" -#include "util/output.h" -#include "expr/command.h" +#include "base/cvc4_assert.h" +#include "base/output.h" #include "expr/expr.h" -#include "prop/theory_proxy.h" -#include "theory/bv/options.h" +#include "expr/node.h" +#include "options/bv_options.h" #include "proof/proof_manager.h" #include "proof/sat_proof.h" +#include "prop/cnf_stream.h" #include "prop/minisat/minisat.h" +#include "prop/prop_engine.h" +#include "prop/theory_proxy.h" #include "smt/smt_engine_scope.h" -#include <queue> +#include "smt_util/command.h" +#include "theory/theory.h" +#include "theory/theory_engine.h" using namespace std; using namespace CVC4::kind; diff --git a/src/prop/minisat/core/Solver.cc b/src/prop/minisat/core/Solver.cc index 5dc618899..4c431a9b1 100644 --- a/src/prop/minisat/core/Solver.cc +++ b/src/prop/minisat/core/Solver.cc @@ -22,16 +22,15 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA #include <iostream> -#include "prop/minisat/mtl/Sort.h" -#include "prop/minisat/core/Solver.h" - -#include "prop/theory_proxy.h" -#include "prop/minisat/minisat.h" -#include "prop/options.h" -#include "util/output.h" -#include "expr/command.h" +#include "base/output.h" +#include "options/prop_options.h" #include "proof/proof_manager.h" #include "proof/sat_proof.h" +#include "prop/minisat/core/Solver.h" +#include "prop/minisat/minisat.h" +#include "prop/minisat/mtl/Sort.h" +#include "prop/theory_proxy.h" +#include "smt_util/command.h" using namespace CVC4::prop; diff --git a/src/prop/minisat/core/Solver.h b/src/prop/minisat/core/Solver.h index b5895de6e..3ed828f7c 100644 --- a/src/prop/minisat/core/Solver.h +++ b/src/prop/minisat/core/Solver.h @@ -25,16 +25,16 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA #include <iostream> -#include "prop/minisat/mtl/Vec.h" -#include "prop/minisat/mtl/Heap.h" +#include "base/output.h" +#include "context/context.h" +#include "prop/minisat/core/SolverTypes.h" #include "prop/minisat/mtl/Alg.h" +#include "prop/minisat/mtl/Heap.h" +#include "prop/minisat/mtl/Vec.h" #include "prop/minisat/utils/Options.h" -#include "prop/minisat/core/SolverTypes.h" - -#include "context/context.h" +#include "smt_util/command.h" #include "theory/theory.h" -#include "util/output.h" -#include "expr/command.h" + namespace CVC4 { class SatProof; diff --git a/src/prop/minisat/core/SolverTypes.h b/src/prop/minisat/core/SolverTypes.h index 0df5eb123..b0d78242c 100644 --- a/src/prop/minisat/core/SolverTypes.h +++ b/src/prop/minisat/core/SolverTypes.h @@ -24,7 +24,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA #define Minisat_SolverTypes_h #include <assert.h> -#include "util/output.h" +#include "base/output.h" #include "prop/minisat/mtl/IntTypes.h" #include "prop/minisat/mtl/Alg.h" #include "prop/minisat/mtl/Vec.h" diff --git a/src/prop/minisat/minisat.cpp b/src/prop/minisat/minisat.cpp index 53ab2eccf..23a740a26 100644 --- a/src/prop/minisat/minisat.cpp +++ b/src/prop/minisat/minisat.cpp @@ -17,13 +17,14 @@ **/ #include "prop/minisat/minisat.h" + +#include "options/decision_options.h" +#include "options/prop_options.h" +#include "options/smt_options.h" #include "prop/minisat/simp/SimpSolver.h" -#include "prop/options.h" -#include "smt/options.h" -#include "decision/options.h" -using namespace CVC4; -using namespace CVC4::prop; +namespace CVC4 { +namespace prop { //// DPllMinisatSatSolver @@ -270,3 +271,6 @@ void MinisatSatSolver::Statistics::init(Minisat::SimpSolver* d_minisat){ d_statMaxLiterals.setData(d_minisat->max_literals); d_statTotLiterals.setData(d_minisat->tot_literals); } + +} /* namespace CVC4::prop */ +} /* namespace CVC4 */ diff --git a/src/prop/minisat/simp/SimpSolver.cc b/src/prop/minisat/simp/SimpSolver.cc index 8408503e2..235c97e8f 100644 --- a/src/prop/minisat/simp/SimpSolver.cc +++ b/src/prop/minisat/simp/SimpSolver.cc @@ -18,11 +18,12 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **************************************************************************************************/ +#include "options/prop_options.h" +#include "proof/proof.h" #include "prop/minisat/mtl/Sort.h" #include "prop/minisat/simp/SimpSolver.h" #include "prop/minisat/utils/System.h" -#include "prop/options.h" -#include "proof/proof.h" + using namespace CVC4; using namespace CVC4::Minisat; diff --git a/src/prop/prop_engine.cpp b/src/prop/prop_engine.cpp index 794e36e2c..499cf1b56 100644 --- a/src/prop/prop_engine.cpp +++ b/src/prop/prop_engine.cpp @@ -14,31 +14,32 @@ ** Implementation of the propositional engine of CVC4. **/ -#include "prop/cnf_stream.h" #include "prop/prop_engine.h" -#include "prop/theory_proxy.h" -#include "prop/sat_solver.h" -#include "prop/sat_solver_factory.h" -#include "proof/proof_manager.h" +#include <iomanip> +#include <map> +#include <utility> + +#include "base/cvc4_assert.h" +#include "base/output.h" #include "decision/decision_engine.h" -#include "decision/options.h" +#include "expr/expr.h" +#include "expr/resource_manager.h" +#include "expr/result.h" +#include "options/decision_options.h" +#include "options/main_options.h" +#include "options/options.h" +#include "options/smt_options.h" +#include "proof/proof_manager.h" +#include "proof/proof_manager.h" +#include "prop/cnf_stream.h" +#include "prop/sat_solver.h" +#include "prop/sat_solver_factory.h" +#include "prop/theory_proxy.h" +#include "smt_util/command.h" #include "theory/theory_engine.h" #include "theory/theory_registrar.h" -#include "proof/proof_manager.h" -#include "util/cvc4_assert.h" -#include "options/options.h" -#include "smt/options.h" -#include "main/options.h" -#include "util/output.h" -#include "util/result.h" -#include "util/resource_manager.h" -#include "expr/expr.h" -#include "expr/command.h" -#include <utility> -#include <map> -#include <iomanip> using namespace std; using namespace CVC4::context; diff --git a/src/prop/prop_engine.h b/src/prop/prop_engine.h index 768f07108..57ff3c5c0 100644 --- a/src/prop/prop_engine.h +++ b/src/prop/prop_engine.h @@ -21,13 +21,14 @@ #ifndef __CVC4__PROP_ENGINE_H #define __CVC4__PROP_ENGINE_H +#include <sys/time.h> + +#include "base/modal_exception.h" #include "expr/node.h" +#include "expr/result.h" #include "options/options.h" -#include "util/result.h" -#include "util/unsafe_interrupt_exception.h" -#include "smt/modal_exception.h" #include "proof/proof_manager.h" -#include <sys/time.h> +#include "util/unsafe_interrupt_exception.h" namespace CVC4 { diff --git a/src/prop/sat_solver.h b/src/prop/sat_solver.h index 50d308541..960881844 100644 --- a/src/prop/sat_solver.h +++ b/src/prop/sat_solver.h @@ -19,12 +19,14 @@ #ifndef __CVC4__PROP__SAT_SOLVER_H #define __CVC4__PROP__SAT_SOLVER_H -#include <string> #include <stdint.h> -#include "util/statistics_registry.h" + +#include <string> + #include "context/cdlist.h" -#include "prop/sat_solver_types.h" #include "expr/node.h" +#include "expr/statistics_registry.h" +#include "prop/sat_solver_types.h" namespace CVC4 { namespace prop { diff --git a/src/prop/theory_proxy.cpp b/src/prop/theory_proxy.cpp index 9c6da703a..386b12391 100644 --- a/src/prop/theory_proxy.cpp +++ b/src/prop/theory_proxy.cpp @@ -14,19 +14,19 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ +#include "prop/theory_proxy.h" +#include "context/context.h" +#include "decision/decision_engine.h" +#include "expr/expr_stream.h" +#include "expr/statistics_registry.h" +#include "options/decision_options.h" #include "prop/cnf_stream.h" #include "prop/prop_engine.h" -#include "prop/theory_proxy.h" -#include "context/context.h" -#include "theory/theory_engine.h" +#include "smt_util/lemma_input_channel.h" +#include "smt_util/lemma_output_channel.h" #include "theory/rewriter.h" -#include "expr/expr_stream.h" -#include "decision/decision_engine.h" -#include "decision/options.h" -#include "util/lemma_input_channel.h" -#include "util/lemma_output_channel.h" -#include "util/statistics_registry.h" +#include "theory/theory_engine.h" namespace CVC4 { namespace prop { diff --git a/src/prop/theory_proxy.h b/src/prop/theory_proxy.h index 90ad558f5..413b4941d 100644 --- a/src/prop/theory_proxy.h +++ b/src/prop/theory_proxy.h @@ -23,12 +23,10 @@ // Optional blocks below will be unconditionally included #define __CVC4_USE_MINISAT -#include "theory/theory.h" -#include "util/statistics_registry.h" - #include "context/cdqueue.h" - +#include "expr/statistics_registry.h" #include "prop/sat_solver.h" +#include "theory/theory.h" namespace CVC4 { diff --git a/src/smt/boolean_terms.cpp b/src/smt/boolean_terms.cpp index 69dc06e47..f7dfdb410 100644 --- a/src/smt/boolean_terms.cpp +++ b/src/smt/boolean_terms.cpp @@ -14,21 +14,22 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ - #include "smt/boolean_terms.h" + +#include <algorithm> +#include <map> +#include <set> +#include <stack> +#include <string> + +#include "expr/kind.h" +#include "expr/node_manager_attributes.h" +#include "options/boolean_term_conversion_mode.h" +#include "options/booleans_options.h" #include "smt/smt_engine.h" #include "theory/theory_engine.h" #include "theory/theory_model.h" -#include "theory/booleans/boolean_term_conversion_mode.h" -#include "theory/booleans/options.h" -#include "expr/kind.h" -#include "expr/node_manager_attributes.h" #include "util/ntuple.h" -#include <string> -#include <algorithm> -#include <set> -#include <map> -#include <stack> using namespace std; using namespace CVC4::theory; diff --git a/src/smt/command_list.cpp b/src/smt/command_list.cpp index 18a09e7ed..3e912d338 100644 --- a/src/smt/command_list.cpp +++ b/src/smt/command_list.cpp @@ -17,8 +17,7 @@ // we include both of these to make sure they agree on the typedef #include "smt/command_list.h" #include "smt/smt_engine.h" - -#include "expr/command.h" +#include "smt_util/command.h" namespace CVC4 { namespace smt { diff --git a/src/smt/logic_exception.h b/src/smt/logic_exception.h index 8fda9b9e2..a641f8d21 100644 --- a/src/smt/logic_exception.h +++ b/src/smt/logic_exception.h @@ -22,7 +22,7 @@ #ifndef __CVC4__SMT__LOGIC_EXCEPTION_H #define __CVC4__SMT__LOGIC_EXCEPTION_H -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { diff --git a/src/smt/modal_exception.i b/src/smt/modal_exception.i deleted file mode 100644 index 15b8150cf..000000000 --- a/src/smt/modal_exception.i +++ /dev/null @@ -1,7 +0,0 @@ -%{ -#include "smt/modal_exception.h" -%} - -%ignore CVC4::ModalException::ModalException(const char*); - -%include "smt/modal_exception.h" diff --git a/src/smt/options_handlers.h b/src/smt/options_handlers.h deleted file mode 100644 index eeefd7af0..000000000 --- a/src/smt/options_handlers.h +++ /dev/null @@ -1,517 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: none - ** Minor contributors (to current version): Clark Barrett, Liana Hadarean - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Custom handlers and predicates for SmtEngine options - ** - ** Custom handlers and predicates for SmtEngine options. - **/ - -#include "cvc4_private.h" - -#ifndef __CVC4__SMT__OPTIONS_HANDLERS_H -#define __CVC4__SMT__OPTIONS_HANDLERS_H - -#include "cvc4autoconfig.h" -#include "util/configuration_private.h" -#include "util/dump.h" -#include "util/resource_manager.h" -#include "smt/modal_exception.h" -#include "smt/smt_engine.h" -#include "lib/strtok_r.h" - -#include <cerrno> -#include <cstring> -#include <sstream> - -namespace CVC4 { -namespace smt { - -static inline std::string __cvc4_errno_failreason() { -#if HAVE_STRERROR_R -#if STRERROR_R_CHAR_P - if(errno != 0) { - // GNU version of strerror_r: *might* use the given buffer, - // or might not. It returns a pointer to buf, or not. - char buf[80]; - return std::string(strerror_r(errno, buf, sizeof buf)); - } else { - return "unknown reason"; - } -#else /* STRERROR_R_CHAR_P */ - if(errno != 0) { - // XSI version of strerror_r: always uses the given buffer. - // Returns an error code. - char buf[80]; - if(strerror_r(errno, buf, sizeof buf) == 0) { - return std::string(buf); - } else { - // some error occurred while getting the error string - return "unknown reason"; - } - } else { - return "unknown reason"; - } -#endif /* STRERROR_R_CHAR_P */ -#else /* HAVE_STRERROR_R */ - return "unknown reason"; -#endif /* HAVE_STRERROR_R */ -} - -static const std::string dumpHelp = "\ -Dump modes currently supported by the --dump option:\n\ -\n\ -benchmark\n\ -+ Dump the benchmark structure (set-logic, push/pop, queries, etc.), but\n\ - does not include any declarations or assertions. Implied by all following\n\ - modes.\n\ -\n\ -declarations\n\ -+ Dump user declarations. Implied by all following modes.\n\ -\n\ -skolems\n\ -+ Dump internally-created skolem variable declarations. These can\n\ - arise from preprocessing simplifications, existential elimination,\n\ - and a number of other things. Implied by all following modes.\n\ -\n\ -assertions\n\ -+ Output the assertions after preprocessing and before clausification.\n\ - Can also specify \"assertions:pre-PASS\" or \"assertions:post-PASS\",\n\ - where PASS is one of the preprocessing passes: definition-expansion\n\ - boolean-terms constrain-subtypes substitution strings-pp skolem-quant\n\ - simplify static-learning ite-removal repeat-simplify\n\ - rewrite-apply-to-const theory-preprocessing.\n\ - PASS can also be the special value \"everything\", in which case the\n\ - assertions are printed before any preprocessing (with\n\ - \"assertions:pre-everything\") or after all preprocessing completes\n\ - (with \"assertions:post-everything\").\n\ -\n\ -clauses\n\ -+ Do all the preprocessing outlined above, and dump the CNF-converted\n\ - output\n\ -\n\ -state\n\ -+ Dump all contextual assertions (e.g., SAT decisions, propagations..).\n\ - Implied by all \"stateful\" modes below and conflicts with all\n\ - non-stateful modes below.\n\ -\n\ -t-conflicts [non-stateful]\n\ -+ Output correctness queries for all theory conflicts\n\ -\n\ -missed-t-conflicts [stateful]\n\ -+ Output completeness queries for theory conflicts\n\ -\n\ -t-propagations [stateful]\n\ -+ Output correctness queries for all theory propagations\n\ -\n\ -missed-t-propagations [stateful]\n\ -+ Output completeness queries for theory propagations (LARGE and EXPENSIVE)\n\ -\n\ -t-lemmas [non-stateful]\n\ -+ Output correctness queries for all theory lemmas\n\ -\n\ -t-explanations [non-stateful]\n\ -+ Output correctness queries for all theory explanations\n\ -\n\ -bv-rewrites [non-stateful]\n\ -+ Output correctness queries for all bitvector rewrites\n\ -\n\ -bv-abstraction [non-stateful]\n\ -+ Output correctness queries for all bv abstraction \n\ -\n\ -bv-algebraic [non-stateful]\n\ -+ Output correctness queries for bv algebraic solver. \n\ -\n\ -theory::fullcheck [non-stateful]\n \ -+ Output completeness queries for all full-check effort-level theory checks\n\ -\n\ -Dump modes can be combined with multiple uses of --dump. Generally you want\n\ -one from the assertions category (either assertions or clauses), and\n\ -perhaps one or more stateful or non-stateful modes for checking correctness\n\ -and completeness of decision procedure implementations. Stateful modes dump\n\ -the contextual assertions made by the core solver (all decisions and\n\ -propagations as assertions; that affects the validity of the resulting\n\ -correctness and completeness queries, so of course stateful and non-stateful\n\ -modes cannot be mixed in the same run.\n\ -\n\ -The --output-language option controls the language used for dumping, and\n\ -this allows you to connect CVC4 to another solver implementation via a UNIX\n\ -pipe to perform on-line checking. The --dump-to option can be used to dump\n\ -to a file.\n\ -"; - -static const std::string 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\ -"; - -inline void dumpMode(std::string option, std::string optarg, SmtEngine* smt) { -#ifdef CVC4_DUMPING - char* optargPtr = strdup(optarg.c_str()); - char* tokstr = optargPtr; - char* toksave; - while((optargPtr = strtok_r(tokstr, ",", &toksave)) != NULL) { - tokstr = NULL; - if(!strcmp(optargPtr, "benchmark")) { - } else if(!strcmp(optargPtr, "declarations")) { - } else if(!strcmp(optargPtr, "assertions")) { - Dump.on("assertions:post-everything"); - } else if(!strncmp(optargPtr, "assertions:", 11)) { - const char* p = optargPtr + 11; - if(!strncmp(p, "pre-", 4)) { - p += 4; - } else if(!strncmp(p, "post-", 5)) { - p += 5; - } else { - throw OptionException(std::string("don't know how to dump `") + - optargPtr + "'. Please consult --dump help."); - } - if(!strcmp(p, "everything")) { - } else if(!strcmp(p, "definition-expansion")) { - } else if(!strcmp(p, "boolean-terms")) { - } else if(!strcmp(p, "constrain-subtypes")) { - } else if(!strcmp(p, "substitution")) { - } else if(!strcmp(p, "strings-pp")) { - } else if(!strcmp(p, "skolem-quant")) { - } else if(!strcmp(p, "simplify")) { - } else if(!strcmp(p, "static-learning")) { - } else if(!strcmp(p, "ite-removal")) { - } else if(!strcmp(p, "repeat-simplify")) { - } else if(!strcmp(p, "rewrite-apply-to-const")) { - } else if(!strcmp(p, "theory-preprocessing")) { - } else if(!strcmp(p, "nonclausal")) { - } else if(!strcmp(p, "theorypp")) { - } else if(!strcmp(p, "itesimp")) { - } else if(!strcmp(p, "unconstrained")) { - } else if(!strcmp(p, "repeatsimp")) { - } else { - throw OptionException(std::string("don't know how to dump `") + - optargPtr + "'. Please consult --dump help."); - } - Dump.on("assertions"); - } else if(!strcmp(optargPtr, "skolems")) { - } else if(!strcmp(optargPtr, "clauses")) { - } else if(!strcmp(optargPtr, "t-conflicts") || - !strcmp(optargPtr, "t-lemmas") || - !strcmp(optargPtr, "t-explanations") || - !strcmp(optargPtr, "bv-rewrites") || - !strcmp(optargPtr, "theory::fullcheck")) { - // These are "non-state-dumping" modes. If state (SAT decisions, - // propagations, etc.) is dumped, it will interfere with the validity - // of these generated queries. - if(Dump.isOn("state")) { - throw OptionException(std::string("dump option `") + optargPtr + - "' conflicts with a previous, " - "state-dumping dump option. You cannot " - "mix stateful and non-stateful dumping modes; " - "see --dump help."); - } else { - Dump.on("no-permit-state"); - } - } else if(!strcmp(optargPtr, "state") || - !strcmp(optargPtr, "missed-t-conflicts") || - !strcmp(optargPtr, "t-propagations") || - !strcmp(optargPtr, "missed-t-propagations")) { - // These are "state-dumping" modes. If state (SAT decisions, - // propagations, etc.) is not dumped, it will interfere with the - // validity of these generated queries. - if(Dump.isOn("no-permit-state")) { - throw OptionException(std::string("dump option `") + optargPtr + - "' conflicts with a previous, " - "non-state-dumping dump option. You cannot " - "mix stateful and non-stateful dumping modes; " - "see --dump help."); - } else { - Dump.on("state"); - } - } else if(!strcmp(optargPtr, "help")) { - puts(dumpHelp.c_str()); - exit(1); - } else if(!strcmp(optargPtr, "bv-abstraction")) { - Dump.on("bv-abstraction"); - } else if(!strcmp(optargPtr, "bv-algebraic")) { - Dump.on("bv-algebraic"); - } else { - throw OptionException(std::string("unknown option for --dump: `") + - optargPtr + "'. Try --dump help."); - } - - Dump.on(optargPtr); - Dump.on("benchmark"); - if(strcmp(optargPtr, "benchmark")) { - Dump.on("declarations"); - if(strcmp(optargPtr, "declarations")) { - Dump.on("skolems"); - } - } - } - free(optargPtr); -#else /* CVC4_DUMPING */ - throw OptionException("The dumping feature was disabled in this build of CVC4."); -#endif /* CVC4_DUMPING */ -} - -inline LogicInfo stringToLogicInfo(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - try { - LogicInfo logic(optarg); - if(smt != NULL) { - smt->setLogic(logic); - } - return logic; - } catch(IllegalArgumentException& e) { - throw OptionException(std::string("invalid logic specification for --force-logic: `") + - optarg + "':\n" + e.what()); - } -} - -inline SimplificationMode stringToSimplificationMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "batch") { - return SIMPLIFICATION_MODE_BATCH; - } else if(optarg == "none") { - return SIMPLIFICATION_MODE_NONE; - } else if(optarg == "help") { - puts(simplificationHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --simplification: `") + - optarg + "'. Try --simplification help."); - } -} - -// ensure we haven't started search yet -inline void beforeSearch(std::string option, bool value, SmtEngine* smt) throw(ModalException) { - if(smt != NULL && smt->d_fullyInited) { - std::stringstream ss; - ss << "cannot change option `" << option << "' after final initialization (i.e., after logic has been set)"; - throw ModalException(ss.str()); - } -} - -inline void setProduceAssertions(std::string option, bool value, SmtEngine* smt) throw() { - options::produceAssertions.set(value); - options::interactiveMode.set(value); -} - -// ensure we are a proof-enabled build of CVC4 -inline void proofEnabledBuild(std::string option, bool value, SmtEngine* smt) throw(OptionException) { -#if !(IS_PROOFS_BUILD) - if(value) { - std::stringstream ss; - ss << "option `" << option << "' requires a proofs-enabled build of CVC4; this binary was not built with proof support"; - throw OptionException(ss.str()); - } -#endif /* IS_PROOFS_BUILD */ -} - -// This macro is used for setting :regular-output-channel and :diagnostic-output-channel -// to redirect a stream. It maintains all attributes set on the stream. -#define __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(__channel_get, __channel_set) \ - { \ - int dagSetting = expr::ExprDag::getDag(__channel_get); \ - size_t exprDepthSetting = expr::ExprSetDepth::getDepth(__channel_get); \ - bool printtypesSetting = expr::ExprPrintTypes::getPrintTypes(__channel_get); \ - OutputLanguage languageSetting = expr::ExprSetLanguage::getLanguage(__channel_get); \ - __channel_set; \ - __channel_get << Expr::dag(dagSetting); \ - __channel_get << Expr::setdepth(exprDepthSetting); \ - __channel_get << Expr::printtypes(printtypesSetting); \ - __channel_get << Expr::setlanguage(languageSetting); \ - } - -inline void dumpToFile(std::string option, std::string optarg, SmtEngine* smt) { -#ifdef CVC4_DUMPING - std::ostream* outStream = NULL; - if(optarg == "") { - throw OptionException(std::string("Bad file name for --dump-to")); - } else if(optarg == "-") { - outStream = &DumpOutC::dump_cout; - } else if(!options::filesystemAccess()) { - throw OptionException(std::string("Filesystem access not permitted")); - } else { - errno = 0; - outStream = new std::ofstream(optarg.c_str(), std::ofstream::out | std::ofstream::trunc); - if(outStream == NULL || !*outStream) { - std::stringstream ss; - ss << "Cannot open dump-to file: `" << optarg << "': " << __cvc4_errno_failreason(); - throw OptionException(ss.str()); - } - } - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Dump.getStream(), Dump.setStream(*outStream)); -#else /* CVC4_DUMPING */ - throw OptionException("The dumping feature was disabled in this build of CVC4."); -#endif /* CVC4_DUMPING */ -} - -inline void setRegularOutputChannel(std::string option, std::string optarg, SmtEngine* smt) { - std::ostream* outStream = NULL; - if(optarg == "") { - throw OptionException(std::string("Bad file name setting for regular output channel")); - } else if(optarg == "stdout") { - outStream = &std::cout; - } else if(optarg == "stderr") { - outStream = &std::cerr; - } else if(!options::filesystemAccess()) { - throw OptionException(std::string("Filesystem access not permitted")); - } else { - errno = 0; - outStream = new std::ofstream(optarg.c_str(), std::ofstream::out | std::ofstream::trunc); - if(outStream == NULL || !*outStream) { - std::stringstream ss; - ss << "Cannot open regular-output-channel file: `" << optarg << "': " << __cvc4_errno_failreason(); - throw OptionException(ss.str()); - } - } - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(*options::err(), options::err.set(outStream)); -} - -inline void setDiagnosticOutputChannel(std::string option, std::string optarg, SmtEngine* smt) { - std::ostream* outStream = NULL; - if(optarg == "") { - throw OptionException(std::string("Bad file name setting for diagnostic output channel")); - } else if(optarg == "stdout") { - outStream = &std::cout; - } else if(optarg == "stderr") { - outStream = &std::cerr; - } else if(!options::filesystemAccess()) { - throw OptionException(std::string("Filesystem access not permitted")); - } else { - errno = 0; - outStream = new std::ofstream(optarg.c_str(), std::ofstream::out | std::ofstream::trunc); - if(outStream == NULL || !*outStream) { - std::stringstream ss; - ss << "Cannot open diagnostic-output-channel file: `" << optarg << "': " << __cvc4_errno_failreason(); - throw OptionException(ss.str()); - } - } - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Debug.getStream(), Debug.setStream(*outStream)); - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Warning.getStream(), Warning.setStream(*outStream)); - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Message.getStream(), Message.setStream(*outStream)); - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Notice.getStream(), Notice.setStream(*outStream)); - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Chat.getStream(), Chat.setStream(*outStream)); - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Trace.getStream(), Trace.setStream(*outStream)); - __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(*options::err(), options::err.set(outStream)); -} - -#undef __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM - -inline std::string checkReplayFilename(std::string option, std::string optarg, SmtEngine* smt) { -#ifdef CVC4_REPLAY - if(optarg == "") { - throw OptionException(std::string("Bad file name for --replay")); - } else { - return optarg; - } -#else /* CVC4_REPLAY */ - throw OptionException("The replay feature was disabled in this build of CVC4."); -#endif /* CVC4_REPLAY */ -} - -inline std::ostream* checkReplayLogFilename(std::string option, std::string optarg, SmtEngine* smt) { -#ifdef CVC4_REPLAY - if(optarg == "") { - throw OptionException(std::string("Bad file name for --replay-log")); - } else if(optarg == "-") { - return &std::cout; - } else if(!options::filesystemAccess()) { - throw OptionException(std::string("Filesystem access not permitted")); - } else { - errno = 0; - std::ostream* replayLog = new std::ofstream(optarg.c_str(), std::ofstream::out | std::ofstream::trunc); - if(replayLog == NULL || !*replayLog) { - std::stringstream ss; - ss << "Cannot open replay-log file: `" << optarg << "': " << __cvc4_errno_failreason(); - throw OptionException(ss.str()); - } - return replayLog; - } -#else /* CVC4_REPLAY */ - throw OptionException("The replay feature was disabled in this build of CVC4."); -#endif /* CVC4_REPLAY */ -} - -// ensure we are a stats-enabled build of CVC4 -inline void statsEnabledBuild(std::string option, bool value, SmtEngine* smt) throw(OptionException) { -#ifndef CVC4_STATISTICS_ON - if(value) { - std::stringstream ss; - ss << "option `" << option << "' requires a statistics-enabled build of CVC4; this binary was not built with statistics support"; - throw OptionException(ss.str()); - } -#endif /* CVC4_STATISTICS_ON */ -} - -inline unsigned long tlimitHandler(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - unsigned long ms; - std::istringstream convert(optarg); - if (!(convert >> ms)) - throw OptionException("option `"+option+"` requires a number as an argument"); - - // make sure the resource is set if the option is updated - // if the smt engine is null the resource will be set in the - if (smt != NULL) { - ResourceManager* rm = NodeManager::fromExprManager(smt->getExprManager())->getResourceManager(); - rm->setTimeLimit(ms, true); - } - return ms; -} - -inline unsigned long tlimitPerHandler(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - unsigned long ms; - - std::istringstream convert(optarg); - if (!(convert >> ms)) - throw OptionException("option `"+option+"` requires a number as an argument"); - - if (smt != NULL) { - ResourceManager* rm = NodeManager::fromExprManager(smt->getExprManager())->getResourceManager(); - rm->setTimeLimit(ms, false); - } - return ms; -} - -inline unsigned long rlimitHandler(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - unsigned long ms; - - std::istringstream convert(optarg); - if (!(convert >> ms)) - throw OptionException("option `"+option+"` requires a number as an argument"); - - if (smt != NULL) { - ResourceManager* rm = NodeManager::fromExprManager(smt->getExprManager())->getResourceManager(); - rm->setResourceLimit(ms, true); - } - return ms; -} - -inline unsigned long rlimitPerHandler(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - unsigned long ms; - - std::istringstream convert(optarg); - if (!(convert >> ms)) - throw OptionException("option `"+option+"` requires a number as an argument"); - - if (smt != NULL) { - ResourceManager* rm = NodeManager::fromExprManager(smt->getExprManager())->getResourceManager(); - rm->setResourceLimit(ms, false); - } - return ms; -} - -}/* CVC4::smt namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__SMT__OPTIONS_HANDLERS_H */ diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp index 4136c3163..21d190d0e 100644 --- a/src/smt/smt_engine.cpp +++ b/src/smt/smt_engine.cpp @@ -14,86 +14,89 @@ ** The main entry point into the CVC4 library's SMT interface. **/ -#include <vector> -#include <string> +#include "smt/smt_engine.h" + +#include <algorithm> +#include <cctype> +#include <ext/hash_map> #include <iterator> -#include <utility> #include <sstream> #include <stack> -#include <cctype> -#include <algorithm> -#include <ext/hash_map> +#include <string> +#include <utility> +#include <vector> -#include "context/cdlist.h" +#include "options/boolean_term_conversion_mode.h" +#include "options/decision_mode.h" +#include "base/exception.h" +#include "base/modal_exception.h" +#include "options/option_exception.h" +#include "base/output.h" #include "context/cdhashset.h" +#include "context/cdlist.h" #include "context/context.h" #include "decision/decision_engine.h" -#include "decision/decision_mode.h" -#include "decision/options.h" -#include "expr/command.h" +#include "expr/attribute.h" #include "expr/expr.h" #include "expr/kind.h" #include "expr/metakind.h" -#include "expr/node_builder.h" #include "expr/node.h" +#include "expr/node_builder.h" #include "expr/node_self_iterator.h" -#include "expr/attribute.h" -#include "prop/prop_engine.h" -#include "proof/theory_proof.h" -#include "smt/modal_exception.h" -#include "smt/smt_engine.h" -#include "smt/smt_engine_scope.h" -#include "smt/model_postprocessor.h" -#include "smt/logic_request.h" -#include "theory/theory_engine.h" -#include "theory/bv/theory_bv_rewriter.h" -#include "proof/proof_manager.h" -#include "main/options.h" -#include "util/unsat_core.h" -#include "util/proof.h" -#include "util/resource_manager.h" +#include "expr/resource_manager.h" +#include "options/arith_options.h" +#include "options/arrays_options.h" +#include "options/booleans_options.h" +#include "options/booleans_options.h" +#include "options/bv_options.h" +#include "options/datatypes_options.h" +#include "options/decision_options.h" +#include "options/main_options.h" +#include "options/options_handler_interface.h" +#include "options/printer_options.h" +#include "options/prop_options.h" +#include "options/quantifiers_options.h" +#include "options/smt_options.h" +#include "options/strings_options.h" +#include "options/theory_options.h" +#include "options/uf_options.h" +#include "printer/printer.h" #include "proof/proof.h" #include "proof/proof_manager.h" -#include "util/boolean_simplification.h" -#include "util/node_visitor.h" -#include "util/configuration.h" -#include "util/configuration_private.h" -#include "util/exception.h" -#include "util/nary_builder.h" -#include "smt/command_list.h" +#include "proof/proof_manager.h" +#include "proof/unsat_core.h" +#include "proof/theory_proof.h" +#include "prop/prop_engine.h" #include "smt/boolean_terms.h" -#include "smt/options.h" -#include "options/option_exception.h" -#include "util/output.h" -#include "util/hash.h" -#include "theory/substitutions.h" -#include "theory/uf/options.h" -#include "theory/arith/options.h" -#include "theory/strings/options.h" -#include "theory/bv/options.h" -#include "theory/theory_traits.h" -#include "theory/logic_info.h" -#include "theory/options.h" +#include "smt/command_list.h" +#include "smt/logic_request.h" +#include "smt/model_postprocessor.h" +#include "smt/smt_engine_scope.h" +#include "smt/smt_options_handler.h" +#include "smt_util/command.h" +#include "smt_util/boolean_simplification.h" +#include "smt_util/ite_removal.h" +#include "smt_util/nary_builder.h" +#include "smt_util/node_visitor.h" +#include "theory/arith/pseudoboolean_proc.h" #include "theory/booleans/circuit_propagator.h" -#include "theory/booleans/boolean_term_conversion_mode.h" -#include "theory/booleans/options.h" -#include "util/ite_removal.h" -#include "theory/theory_model.h" -#include "printer/printer.h" -#include "prop/options.h" -#include "theory/arrays/options.h" -#include "util/sort_inference.h" -#include "theory/quantifiers/macros.h" +#include "theory/bv/bvintropow2.h" +#include "theory/bv/theory_bv_rewriter.h" +#include "theory/logic_info.h" +#include "theory/quantifiers/ce_guided_instantiation.h" #include "theory/quantifiers/fun_def_process.h" +#include "theory/quantifiers/macros.h" #include "theory/quantifiers/quantifiers_rewriter.h" -#include "theory/quantifiers/ce_guided_instantiation.h" -#include "theory/quantifiers/options.h" -#include "theory/datatypes/options.h" +#include "theory/sort_inference.h" #include "theory/strings/theory_strings.h" -#include "printer/options.h" - -#include "theory/arith/pseudoboolean_proc.h" -#include "theory/bv/bvintropow2.h" +#include "theory/substitutions.h" +#include "theory/theory_engine.h" +#include "theory/theory_model.h" +#include "theory/theory_traits.h" +#include "util/configuration.h" +#include "util/configuration_private.h" +#include "util/hash.h" +#include "util/proof.h" using namespace std; using namespace CVC4; @@ -712,6 +715,7 @@ SmtEngine::SmtEngine(ExprManager* em) throw() : d_needPostsolve(false), d_earlyTheoryPP(true), d_status(), + d_optionsHandler(new SmtOptionsHandler(this)), d_private(NULL), d_smtAttributes(NULL), d_statisticsRegistry(NULL), @@ -884,6 +888,9 @@ SmtEngine::~SmtEngine() throw() { delete d_statisticsRegistry; d_statisticsRegistry = NULL; + delete d_optionsHandler; + d_optionsHandler = NULL; + delete d_private; d_private = NULL; @@ -934,7 +941,7 @@ void SmtEngine::setLogicInternal() throw() { void SmtEngine::setDefaults() { if(options::forceLogic.wasSetByUser()) { - d_logic = options::forceLogic(); + d_logic = *(options::forceLogic()); } // set strings-exp @@ -1596,6 +1603,7 @@ void SmtEngine::setInfo(const std::string& key, const CVC4::SExpr& value) SmtScope smts(this); Trace("smt") << "SMT setInfo(" << key << ", " << value << ")" << endl; + if(Dump.isOn("benchmark")) { if(key == "status") { string s = value.getValue(); @@ -1700,29 +1708,29 @@ CVC4::SExpr SmtEngine::getInfo(const std::string& key) const v.push_back((*i).second); stats.push_back(v); } - return stats; + return SExpr(stats); } else if(key == "error-behavior") { // immediate-exit | continued-execution if( options::continuedExecution() || options::interactive() ) { - return SExpr::Keyword("continued-execution"); + return SExpr(SExpr::Keyword("continued-execution")); } else { - return SExpr::Keyword("immediate-exit"); + return SExpr(SExpr::Keyword("immediate-exit")); } } else if(key == "name") { - return Configuration::getName(); + return SExpr(Configuration::getName()); } else if(key == "version") { - return Configuration::getVersionString(); + return SExpr(Configuration::getVersionString()); } else if(key == "authors") { - return Configuration::about(); + return SExpr(Configuration::about()); } else if(key == "status") { // sat | unsat | unknown switch(d_status.asSatisfiabilityResult().isSat()) { case Result::SAT: - return SExpr::Keyword("sat"); + return SExpr(SExpr::Keyword("sat")); case Result::UNSAT: - return SExpr::Keyword("unsat"); + return SExpr(SExpr::Keyword("unsat")); default: - return SExpr::Keyword("unknown"); + return SExpr(SExpr::Keyword("unknown")); } } else if(key == "reason-unknown") { if(!d_status.isNull() && d_status.isUnknown()) { @@ -1730,7 +1738,7 @@ CVC4::SExpr SmtEngine::getInfo(const std::string& key) const ss << d_status.whyUnknown(); string s = ss.str(); transform(s.begin(), s.end(), s.begin(), ::tolower); - return SExpr::Keyword(s); + return SExpr(SExpr::Keyword(s)); } else { throw ModalException("Can't get-info :reason-unknown when the " "last result wasn't unknown!"); @@ -1739,7 +1747,8 @@ CVC4::SExpr SmtEngine::getInfo(const std::string& key) const return SExpr(d_userLevels.size()); } else if(key == "all-options") { // get the options, like all-statistics - return Options::current()->getOptions(); + std::vector< std::vector<std::string> > current_options = Options::current()->getOptions(); + return SExpr::parseListOfListOfAtoms(current_options); } else { throw UnrecognizedOptionException(); } @@ -4068,13 +4077,13 @@ CVC4::SExpr SmtEngine::getAssignment() throw(ModalException, UnsafeInterruptExce vector<SExpr> v; if((*i).getKind() == kind::APPLY) { Assert((*i).getNumChildren() == 0); - v.push_back(SExpr::Keyword((*i).getOperator().toString())); + v.push_back(SExpr(SExpr::Keyword((*i).getOperator().toString()))); } else { Assert((*i).isVar()); - v.push_back(SExpr::Keyword((*i).toString())); + v.push_back(SExpr(SExpr::Keyword((*i).toString()))); } - v.push_back(SExpr::Keyword(resultNode.toString())); - sexprs.push_back(v); + v.push_back(SExpr(SExpr::Keyword(resultNode.toString()))); + sexprs.push_back(SExpr(v)); } return SExpr(sexprs); } @@ -4669,4 +4678,108 @@ void SmtEngine::setPrintFuncInModel(Expr f, bool p) { } } + + +void SmtEngine::beforeSearch(SmtEngine* smt, const std::string& option) throw(ModalException) { + if(smt != NULL && smt->d_fullyInited) { + std::stringstream ss; + ss << "cannot change option `" << option << "' after final initialization (i.e., after logic has been set)"; + throw ModalException(ss.str()); + } +} + + +void SmtEngine::setOption(const std::string& key, const CVC4::SExpr& value) + throw(OptionException, ModalException) { + + NodeManagerScope nms(d_nodeManager); + Trace("smt") << "SMT setOption(" << key << ", " << value << ")" << endl; + + if(Dump.isOn("benchmark")) { + Dump("benchmark") << SetOptionCommand(key, value); + } + + if(key == "command-verbosity") { + if(!value.isAtom()) { + const vector<SExpr>& cs = value.getChildren(); + if(cs.size() == 2 && + (cs[0].isKeyword() || cs[0].isString()) && + cs[1].isInteger()) { + string c = cs[0].getValue(); + const Integer& v = cs[1].getIntegerValue(); + if(v < 0 || v > 2) { + throw OptionException("command-verbosity must be 0, 1, or 2"); + } + d_commandVerbosity[c] = v; + return; + } + } + throw OptionException("command-verbosity value must be a tuple (command-name, integer)"); + } + + if(!value.isAtom()) { + throw OptionException("bad value for :" + key); + } + + string optionarg = value.getValue(); + + d_optionsHandler->setOption(key, optionarg); +} + +CVC4::SExpr SmtEngine::getOption(const std::string& key) const + throw(OptionException) { + + NodeManagerScope nms(d_nodeManager); + + Trace("smt") << "SMT getOption(" << key << ")" << endl; + + if(key.length() >= 18 && + key.compare(0, 18, "command-verbosity:") == 0) { + map<string, Integer>::const_iterator i = d_commandVerbosity.find(key.c_str() + 18); + if(i != d_commandVerbosity.end()) { + return SExpr((*i).second); + } + i = d_commandVerbosity.find("*"); + if(i != d_commandVerbosity.end()) { + return SExpr((*i).second); + } + return SExpr(Integer(2)); + } + + if(Dump.isOn("benchmark")) { + Dump("benchmark") << GetOptionCommand(key); + } + + if(key == "command-verbosity") { + vector<SExpr> result; + SExpr defaultVerbosity; + for(map<string, Integer>::const_iterator i = d_commandVerbosity.begin(); + i != d_commandVerbosity.end(); + ++i) { + vector<SExpr> v; + v.push_back(SExpr((*i).first)); + v.push_back(SExpr((*i).second)); + if((*i).first == "*") { + // put the default at the end of the SExpr + defaultVerbosity = SExpr(v); + } else { + result.push_back(SExpr(v)); + } + } + // put the default at the end of the SExpr + if(!defaultVerbosity.isAtom()) { + result.push_back(defaultVerbosity); + } else { + // ensure the default is always listed + vector<SExpr> v; + v.push_back(SExpr("*")); + v.push_back(SExpr(Integer(2))); + result.push_back(SExpr(v)); + } + return SExpr(result); + } + + return SExpr::parseAtom(d_optionsHandler->getOption(key)); +} + }/* CVC4 namespace */ diff --git a/src/smt/smt_engine.h b/src/smt/smt_engine.h index be31d768b..c94646c40 100644 --- a/src/smt/smt_engine.h +++ b/src/smt/smt_engine.h @@ -22,22 +22,22 @@ #include <string> #include <vector> -#include "context/cdlist_forward.h" +#include "base/modal_exception.h" #include "context/cdhashmap_forward.h" #include "context/cdhashset_forward.h" +#include "context/cdlist_forward.h" #include "expr/expr.h" #include "expr/expr_manager.h" -#include "util/proof.h" -#include "util/unsat_core.h" -#include "smt/modal_exception.h" -#include "smt/logic_exception.h" +#include "expr/result.h" +#include "expr/sexpr.h" +#include "expr/statistics.h" #include "options/options.h" -#include "util/result.h" -#include "util/sexpr.h" +#include "proof/unsat_core.h" +#include "smt/logic_exception.h" +#include "theory/logic_info.h" #include "util/hash.h" +#include "util/proof.h" #include "util/unsafe_interrupt_exception.h" -#include "util/statistics.h" -#include "theory/logic_info.h" // In terms of abstraction, this is below (and provides services to) // ValidityChecker and above (and requires the services of) @@ -72,6 +72,10 @@ namespace prop { class PropEngine; }/* CVC4::prop namespace */ +namespace options { + class OptionsHandler; +}/* CVC4::prop namespace */ + namespace expr { namespace attr { class AttributeManager; @@ -93,7 +97,6 @@ namespace smt { class SmtScope; class BooleanTermConverter; - void beforeSearch(std::string, bool, SmtEngine*) throw(ModalException); ProofManager* currentProofManager(); struct CommandCleanup; @@ -264,6 +267,11 @@ class CVC4_PUBLIC SmtEngine { std::map<std::string, Integer> d_commandVerbosity; /** + * This responds to requests to set options. + */ + options::OptionsHandler* d_optionsHandler; + + /** * A private utility class to SmtEngine. */ smt::SmtEnginePrivate* d_private; @@ -354,7 +362,6 @@ class CVC4_PUBLIC SmtEngine { friend class ::CVC4::smt::SmtScope; friend class ::CVC4::smt::BooleanTermConverter; friend ::CVC4::StatisticsRegistry* ::CVC4::stats::getStatisticsRegistry(SmtEngine*); - friend void ::CVC4::smt::beforeSearch(std::string, bool, SmtEngine*) throw(ModalException); friend ProofManager* ::CVC4::smt::currentProofManager(); friend class ::CVC4::LogicRequest; // to access d_modelCommands @@ -717,6 +724,11 @@ public: */ void setPrintFuncInModel(Expr f, bool p); + + /** + * Throws a ModalException if smt is non-null and the SmtEngine has not been fully initialized. + */ + static void beforeSearch(SmtEngine* smt, const std::string& option) throw(ModalException); };/* class SmtEngine */ }/* CVC4 namespace */ diff --git a/src/smt/smt_engine.i b/src/smt/smt_engine.i index 9cf4467a8..443e4cc58 100644 --- a/src/smt/smt_engine.i +++ b/src/smt/smt_engine.i @@ -46,7 +46,6 @@ SWIGEXPORT void JNICALL Java_edu_nyu_acsys_CVC4_SmtEngine_dlRef(JNIEnv* jenv, jc %ignore CVC4::SmtEngine::setLogic(const char*); %ignore CVC4::stats::getStatisticsRegistry(SmtEngine*); -%ignore CVC4::smt::beforeSearch(std::string, bool, SmtEngine*); %ignore CVC4::smt::currentProofManager(); %include "smt/smt_engine.h" diff --git a/src/smt/smt_engine_check_proof.cpp b/src/smt/smt_engine_check_proof.cpp index d04daef92..2add88afb 100644 --- a/src/smt/smt_engine_check_proof.cpp +++ b/src/smt/smt_engine_check_proof.cpp @@ -15,16 +15,18 @@ ** \todo document this file **/ -#include "smt/smt_engine.h" -#include "util/configuration_private.h" -#include "util/statistics_registry.h" -#include "check.h" +#include <unistd.h> #include <cstdlib> #include <cstring> #include <fstream> #include <string> -#include <unistd.h> + +#include "base/output.h" +#include "check.h" +#include "expr/statistics_registry.h" +#include "smt/smt_engine.h" +#include "util/configuration_private.h" using namespace CVC4; using namespace std; diff --git a/src/smt/smt_engine_scope.h b/src/smt/smt_engine_scope.h index bc978b728..1dd69abc9 100644 --- a/src/smt/smt_engine_scope.h +++ b/src/smt/smt_engine_scope.h @@ -19,13 +19,14 @@ #pragma once +#include "base/cvc4_assert.h" +#include "base/output.h" +#include "base/tls.h" #include "expr/node_manager.h" +#include "options/smt_options.h" #include "smt/smt_engine.h" -#include "smt/options.h" #include "util/configuration_private.h" -#include "util/cvc4_assert.h" -#include "util/output.h" -#include "util/tls.h" + namespace CVC4 { diff --git a/src/smt/smt_options_handler.cpp b/src/smt/smt_options_handler.cpp new file mode 100644 index 000000000..3dc5720ab --- /dev/null +++ b/src/smt/smt_options_handler.cpp @@ -0,0 +1,1729 @@ +/********************* */ +/*! \file options_handler_interface.cpp + ** \verbatim + ** Original author: Tim King + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Interface for custom handlers and predicates options. + ** + ** Interface for custom handlers and predicates options. + **/ + +#include "smt/smt_options_handler.h" + +#include <cerrno> +#include <cstring> +#include <ostream> +#include <sstream> +#include <string> + +#include "base/modal_exception.h" +#include "base/output.h" +#include "cvc4autoconfig.h" +#include "expr/metakind.h" +#include "expr/node_manager.h" +#include "expr/resource_manager.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/boolean_term_conversion_mode.h" +#include "options/bv_bitblast_mode.h" +#include "options/bv_options.h" +#include "options/decision_mode.h" +#include "options/decision_options.h" +#include "options/didyoumean.h" +#include "options/language.h" +#include "options/main_options.h" +#include "options/option_exception.h" +#include "options/options_handler_interface.h" +#include "options/parser_options.h" +#include "options/printer_modes.h" +#include "options/quantifiers_modes.h" +#include "options/simplification_mode.h" +#include "options/smt_options.h" +#include "options/theory_options.h" +#include "options/theoryof_mode.h" +#include "options/ufss_mode.h" +#include "smt/smt_engine.h" +#include "smt_util/command.h" +#include "smt_util/dump.h" +#include "theory/logic_info.h" +#include "util/configuration.h" +#include "util/configuration_private.h" + + +#warning "TODO: Make SmtOptionsHandler non-public and refactor driver unified." + +namespace CVC4 { +namespace smt { + +SmtOptionsHandler::SmtOptionsHandler(SmtEngine* smt) + : d_smtEngine(smt) +{} + +SmtOptionsHandler::~SmtOptionsHandler(){} + +// theory/arith/options_handlers.h +const std::string SmtOptionsHandler::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 SmtOptionsHandler::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 SmtOptionsHandler::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 SmtOptionsHandler::stringToArithUnateLemmaMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::stringToArithPropagationMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::stringToErrorSelectionRule(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::s_instWhenHelp = "\ +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 SmtOptionsHandler::s_literalMatchHelp = "\ +Literal match modes currently supported by the --literal-match option:\n\ +\n\ +none (default)\n\ ++ Do not use literal matching.\n\ +\n\ +predicate\n\ ++ Consider the phase requirements of predicate literals when applying heuristic\n\ + quantifier instantiation. For example, the trigger P( x ) in the quantified \n\ + formula forall( x ). ( P( x ) V ~Q( x ) ) will only be matched with ground\n\ + terms P( t ) where P( t ) is in the equivalence class of false, and likewise\n\ + Q( x ) with Q( s ) where Q( s ) is in the equivalence class of true.\n\ +\n\ +"; + +const std::string SmtOptionsHandler::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\ +gen-ev \n\ ++ Use model-based quantifier instantiation algorithm from CADE 24 finite\n\ + model finding paper based on generalizing evaluations.\n\ +\n\ +fmc-interval \n\ ++ Same as default, but with intervals for models of integer functions.\n\ +\n\ +abs \n\ ++ Use abstract MBQI algorithm (uses disjoint sets). \n\ +\n\ +"; + +const std::string SmtOptionsHandler::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 SmtOptionsHandler::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\ +partial \n\ ++ Apply QCF algorithm to instantiate heuristically as well. \n\ +\n\ +mc \n\ ++ Apply QCF algorithm in a complete way, so that a model is ensured when it fails. \n\ +\n\ +"; + +const std::string SmtOptionsHandler::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 SmtOptionsHandler::s_triggerSelModeHelp = "\ +Trigger selection modes currently supported by the --trigger-sel option:\n\ +\n\ +default \n\ ++ Default, consider all subterms of quantified formulas for trigger selection.\n\ +\n\ +min \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\ +"; +const std::string SmtOptionsHandler::s_prenexQuantModeHelp = "\ +Prenex quantifiers modes currently supported by the --prenex-quant option:\n\ +\n\ +default \n\ ++ Default, prenex all nested quantifiers except those with user patterns.\n\ +\n\ +all \n\ ++ Prenex all nested quantifiers.\n\ +\n\ +none \n\ ++ Do no prenex nested quantifiers. \n\ +\n\ +"; + +const std::string SmtOptionsHandler::s_cegqiFairModeHelp = "\ +Modes for enforcing fairness for counterexample guided quantifier instantion, supported by --cegqi-fair:\n\ +\n\ +uf-dt-size \n\ ++ Enforce fairness using an uninterpreted function for datatypes size.\n\ +\n\ +default | dt-size \n\ ++ Default, enforce fairness using size theory 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 SmtOptionsHandler::s_termDbModeHelp = "\ +Modes for 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 SmtOptionsHandler::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 SmtOptionsHandler::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 SmtOptionsHandler::s_macrosQuantHelp = "\ +Template 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\ +"; + +theory::quantifiers::InstWhenMode SmtOptionsHandler::stringToInstWhenMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::checkInstWhenMode(std::string option, theory::quantifiers::InstWhenMode mode) throw(OptionException) { + 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 SmtOptionsHandler::stringToLiteralMatchMode(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "none") { + return theory::quantifiers::LITERAL_MATCH_NONE; + } else if(optarg == "predicate") { + return theory::quantifiers::LITERAL_MATCH_PREDICATE; + } else if(optarg == "equality") { + return theory::quantifiers::LITERAL_MATCH_EQUALITY; + } 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 SmtOptionsHandler::checkLiteralMatchMode(std::string option, theory::quantifiers::LiteralMatchMode mode) throw(OptionException) { + if(mode == theory::quantifiers::LITERAL_MATCH_EQUALITY) { + throw OptionException(std::string("Mode equality for ") + option + " is not supported in this release."); + } +} + +theory::quantifiers::MbqiMode SmtOptionsHandler::stringToMbqiMode(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "gen-ev") { + return theory::quantifiers::MBQI_GEN_EVAL; + } else if(optarg == "none") { + return theory::quantifiers::MBQI_NONE; + } else if(optarg == "default" || optarg == "fmc") { + return theory::quantifiers::MBQI_FMC; + } else if(optarg == "fmc-interval") { + return theory::quantifiers::MBQI_FMC_INTERVAL; + } else if(optarg == "abs") { + return theory::quantifiers::MBQI_ABS; + } 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 SmtOptionsHandler::checkMbqiMode(std::string option, theory::quantifiers::MbqiMode mode) throw(OptionException) {} + + +theory::quantifiers::QcfWhenMode SmtOptionsHandler::stringToQcfWhenMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::stringToQcfMode(std::string option, std::string optarg) throw(OptionException) { + 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 == "partial") { + return theory::quantifiers::QCF_PARTIAL; + } else if(optarg == "mc" ) { + return theory::quantifiers::QCF_MC; + } 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 SmtOptionsHandler::stringToUserPatMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::stringToTriggerSelMode(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "default" || optarg == "all" ) { + return theory::quantifiers::TRIGGER_SEL_DEFAULT; + } else if(optarg == "min") { + return theory::quantifiers::TRIGGER_SEL_MIN; + } else if(optarg == "max") { + return theory::quantifiers::TRIGGER_SEL_MAX; + } 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::PrenexQuantMode SmtOptionsHandler::stringToPrenexQuantMode(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "default" ) { + return theory::quantifiers::PRENEX_NO_USER_PAT; + } else if(optarg == "all") { + return theory::quantifiers::PRENEX_ALL; + } else if(optarg == "none") { + return theory::quantifiers::PRENEX_NONE; + } 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::quantifiers::CegqiFairMode SmtOptionsHandler::stringToCegqiFairMode(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "uf-dt-size" ) { + return theory::quantifiers::CEGQI_FAIR_UF_DT_SIZE; + } else if(optarg == "default" || optarg == "dt-size") { + return theory::quantifiers::CEGQI_FAIR_DT_SIZE; + } else if(optarg == "dt-height-bound" ){ + return theory::quantifiers::CEGQI_FAIR_DT_HEIGHT_PRED; + } else if(optarg == "none") { + return theory::quantifiers::CEGQI_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 SmtOptionsHandler::stringToTermDbMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::stringToIteLiftQuantMode(std::string option, std::string optarg) throw(OptionException) { + 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::SygusInvTemplMode SmtOptionsHandler::stringToSygusInvTemplMode(std::string option, std::string optarg) throw(OptionException) { + 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::MacrosQuantMode SmtOptionsHandler::stringToMacrosQuantMode(std::string option, std::string optarg) throw(OptionException) { + 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/bv/options_handlers.h +void SmtOptionsHandler::abcEnabledBuild(std::string option, bool value) throw(OptionException) { +#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 SmtOptionsHandler::abcEnabledBuild(std::string option, std::string value) throw(OptionException) { +#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 */ +} + +const std::string SmtOptionsHandler::s_bitblastingModeHelp = "\ +Bit-blasting modes currently supported by the --bitblast option:\n\ +\n\ +lazy (default)\n\ ++ Separate boolean structure and term reasoning betwen the core\n\ + SAT solver and the bv SAT solver\n\ +\n\ +eager\n\ ++ Bitblast eagerly to bv SAT solver\n\ +"; + +theory::bv::BitblastMode SmtOptionsHandler::stringToBitblastMode(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "lazy") { + if (!options::bitvectorPropagate.wasSetByUser()) { + options::bitvectorPropagate.set(true); + } + if (!options::bitvectorEqualitySolver.wasSetByUser()) { + options::bitvectorEqualitySolver.set(true); + } + if (!options::bitvectorEqualitySlicer.wasSetByUser()) { + if (options::incrementalSolving() || + options::produceModels()) { + options::bitvectorEqualitySlicer.set(theory::bv::BITVECTOR_SLICER_OFF); + } else { + options::bitvectorEqualitySlicer.set(theory::bv::BITVECTOR_SLICER_AUTO); + } + } + + if (!options::bitvectorInequalitySolver.wasSetByUser()) { + options::bitvectorInequalitySolver.set(true); + } + if (!options::bitvectorAlgebraicSolver.wasSetByUser()) { + options::bitvectorAlgebraicSolver.set(true); + } + return theory::bv::BITBLAST_MODE_LAZY; + } else if(optarg == "eager") { + + if (options::incrementalSolving() && + options::incrementalSolving.wasSetByUser()) { + throw OptionException(std::string("Eager bit-blasting does not currently support incremental mode. \n\ + Try --bitblast=lazy")); + } + if (!options::bitvectorToBool.wasSetByUser()) { + options::bitvectorToBool.set(true); + } + + if (!options::bvAbstraction.wasSetByUser() && + !options::skolemizeArguments.wasSetByUser()) { + options::bvAbstraction.set(true); + options::skolemizeArguments.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 SmtOptionsHandler::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 SmtOptionsHandler::stringToBvSlicerMode(std::string option, std::string optarg) throw(OptionException) { + 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_bitblastingModeHelp.c_str()); + exit(1); + } else { + throw OptionException(std::string("unknown option for --bv-eq-slicer: `") + + optarg + "'. Try --bv-eq-slicer=help."); + } +} + +void SmtOptionsHandler::setBitblastAig(std::string option, bool arg) throw(OptionException) { + if(arg) { + if(options::bitblastMode.wasSetByUser()) { + if(options::bitblastMode() != theory::bv::BITBLAST_MODE_EAGER) { + throw OptionException("bitblast-aig must be used with eager bitblaster"); + } + } else { + theory::bv::BitblastMode mode = stringToBitblastMode("", "eager"); + options::bitblastMode.set(mode); + } + if(!options::bitvectorAigSimplifications.wasSetByUser()) { + options::bitvectorAigSimplifications.set("balance;drw"); + } + } +} + + +// theory/booleans/options_handlers.h +const std::string SmtOptionsHandler::s_booleanTermConversionModeHelp = "\ +Boolean term conversion modes currently supported by the\n\ +--boolean-term-conversion-mode option:\n\ +\n\ +bitvectors [default]\n\ ++ Boolean terms are converted to bitvectors of size 1.\n\ +\n\ +datatypes\n\ ++ Boolean terms are converted to enumerations in the Datatype theory.\n\ +\n\ +native\n\ ++ Boolean terms are converted in a \"natural\" way depending on where they\n\ + are used. If in a datatype context, they are converted to an enumeration.\n\ + Elsewhere, they are converted to a bitvector of size 1.\n\ +"; + +theory::booleans::BooleanTermConversionMode SmtOptionsHandler::stringToBooleanTermConversionMode(std::string option, std::string optarg) throw(OptionException){ + if(optarg == "bitvectors") { + return theory::booleans::BOOLEAN_TERM_CONVERT_TO_BITVECTORS; + } else if(optarg == "datatypes") { + return theory::booleans::BOOLEAN_TERM_CONVERT_TO_DATATYPES; + } else if(optarg == "native") { + return theory::booleans::BOOLEAN_TERM_CONVERT_NATIVE; + } else if(optarg == "help") { + puts(s_booleanTermConversionModeHelp.c_str()); + exit(1); + } else { + throw OptionException(std::string("unknown option for --boolean-term-conversion-mode: `") + + optarg + "'. Try --boolean-term-conversion-mode help."); + } +} + +// theory/uf/options_handlers.h +const std::string SmtOptionsHandler::s_ufssModeHelp = "\ +UF strong solver options currently supported by the --uf-ss option:\n\ +\n\ +full \n\ ++ Default, use uf strong solver to find minimal models for uninterpreted sorts.\n\ +\n\ +no-minimal \n\ ++ Use uf strong solver to shrink model sizes, but do no enforce minimality.\n\ +\n\ +none \n\ ++ Do not use uf strong solver to shrink model sizes. \n\ +\n\ +"; + +theory::uf::UfssMode SmtOptionsHandler::stringToUfssMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::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 SmtOptionsHandler::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."); + } +} + +void SmtOptionsHandler::useTheory(std::string option, std::string optarg) { + if(optarg == "help") { + puts(theory::useTheoryHelp); + exit(1); + } + if(theory::useTheoryValidate(optarg)) { + std::map<std::string, bool> m = options::theoryAlternates(); + m[optarg] = true; + options::theoryAlternates.set(m); + } else { + throw OptionException(std::string("unknown option for ") + option + ": `" + + optarg + "'. Try --use-theory help."); + } +} + + + +// printer/options_handlers.h +const std::string SmtOptionsHandler::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 SmtOptionsHandler::s_instFormatHelp = "\ +Inst format modes currently supported by the --model-format option:\n\ +\n\ +default \n\ ++ Print instantiations as a list in the output language format.\n\ +\n\ +szs\n\ ++ Print instantiations as SZS compliant proof.\n\ +"; + +ModelFormatMode SmtOptionsHandler::stringToModelFormatMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::stringToInstFormatMode(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "default") { + return INST_FORMAT_MODE_DEFAULT; + } else if(optarg == "szs") { + return INST_FORMAT_MODE_SZS; + } else if(optarg == "help") { + puts(s_instFormatHelp.c_str()); + exit(1); + } else { + throw OptionException(std::string("unknown option for --inst-format: `") + + optarg + "'. Try --inst-format help."); + } +} + + + +// decision/options_handlers.h +const std::string SmtOptionsHandler::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 SmtOptionsHandler::stringToDecisionMode(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::stringToDecisionWeightInternal(std::string option, std::string optarg) throw(OptionException) { + 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 SmtOptionsHandler::SmtOptionsHandler::s_dumpHelp = "\ +Dump modes currently supported by the --dump option:\n\ +\n\ +benchmark\n\ ++ Dump the benchmark structure (set-logic, push/pop, queries, etc.), but\n\ + does not include any declarations or assertions. Implied by all following\n\ + modes.\n\ +\n\ +declarations\n\ ++ Dump user declarations. Implied by all following modes.\n\ +\n\ +skolems\n\ ++ Dump internally-created skolem variable declarations. These can\n\ + arise from preprocessing simplifications, existential elimination,\n\ + and a number of other things. Implied by all following modes.\n\ +\n\ +assertions\n\ ++ Output the assertions after preprocessing and before clausification.\n\ + Can also specify \"assertions:pre-PASS\" or \"assertions:post-PASS\",\n\ + where PASS is one of the preprocessing passes: definition-expansion\n\ + boolean-terms constrain-subtypes substitution strings-pp skolem-quant\n\ + simplify static-learning ite-removal repeat-simplify\n\ + rewrite-apply-to-const theory-preprocessing.\n\ + PASS can also be the special value \"everything\", in which case the\n\ + assertions are printed before any preprocessing (with\n\ + \"assertions:pre-everything\") or after all preprocessing completes\n\ + (with \"assertions:post-everything\").\n\ +\n\ +clauses\n\ ++ Do all the preprocessing outlined above, and dump the CNF-converted\n\ + output\n\ +\n\ +state\n\ ++ Dump all contextual assertions (e.g., SAT decisions, propagations..).\n\ + Implied by all \"stateful\" modes below and conflicts with all\n\ + non-stateful modes below.\n\ +\n\ +t-conflicts [non-stateful]\n\ ++ Output correctness queries for all theory conflicts\n\ +\n\ +missed-t-conflicts [stateful]\n\ ++ Output completeness queries for theory conflicts\n\ +\n\ +t-propagations [stateful]\n\ ++ Output correctness queries for all theory propagations\n\ +\n\ +missed-t-propagations [stateful]\n\ ++ Output completeness queries for theory propagations (LARGE and EXPENSIVE)\n\ +\n\ +t-lemmas [non-stateful]\n\ ++ Output correctness queries for all theory lemmas\n\ +\n\ +t-explanations [non-stateful]\n\ ++ Output correctness queries for all theory explanations\n\ +\n\ +bv-rewrites [non-stateful]\n\ ++ Output correctness queries for all bitvector rewrites\n\ +\n\ +bv-abstraction [non-stateful]\n\ ++ Output correctness queries for all bv abstraction \n\ +\n\ +bv-algebraic [non-stateful]\n\ ++ Output correctness queries for bv algebraic solver. \n\ +\n\ +theory::fullcheck [non-stateful]\n \ ++ Output completeness queries for all full-check effort-level theory checks\n\ +\n\ +Dump modes can be combined with multiple uses of --dump. Generally you want\n\ +one from the assertions category (either assertions or clauses), and\n\ +perhaps one or more stateful or non-stateful modes for checking correctness\n\ +and completeness of decision procedure implementations. Stateful modes dump\n\ +the contextual assertions made by the core solver (all decisions and\n\ +propagations as assertions; that affects the validity of the resulting\n\ +correctness and completeness queries, so of course stateful and non-stateful\n\ +modes cannot be mixed in the same run.\n\ +\n\ +The --output-language option controls the language used for dumping, and\n\ +this allows you to connect CVC4 to another solver implementation via a UNIX\n\ +pipe to perform on-line checking. The --dump-to option can be used to dump\n\ +to a file.\n\ +"; + +const std::string SmtOptionsHandler::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\ +"; + +void SmtOptionsHandler::dumpMode(std::string option, std::string optarg) { +#ifdef CVC4_DUMPING + char* optargPtr = strdup(optarg.c_str()); + char* tokstr = optargPtr; + char* toksave; + while((optargPtr = strtok_r(tokstr, ",", &toksave)) != NULL) { + tokstr = NULL; + if(!strcmp(optargPtr, "benchmark")) { + } else if(!strcmp(optargPtr, "declarations")) { + } else if(!strcmp(optargPtr, "assertions")) { + Dump.on("assertions:post-everything"); + } else if(!strncmp(optargPtr, "assertions:", 11)) { + const char* p = optargPtr + 11; + if(!strncmp(p, "pre-", 4)) { + p += 4; + } else if(!strncmp(p, "post-", 5)) { + p += 5; + } else { + throw OptionException(std::string("don't know how to dump `") + + optargPtr + "'. Please consult --dump help."); + } + if(!strcmp(p, "everything")) { + } else if(!strcmp(p, "definition-expansion")) { + } else if(!strcmp(p, "boolean-terms")) { + } else if(!strcmp(p, "constrain-subtypes")) { + } else if(!strcmp(p, "substitution")) { + } else if(!strcmp(p, "strings-pp")) { + } else if(!strcmp(p, "skolem-quant")) { + } else if(!strcmp(p, "simplify")) { + } else if(!strcmp(p, "static-learning")) { + } else if(!strcmp(p, "ite-removal")) { + } else if(!strcmp(p, "repeat-simplify")) { + } else if(!strcmp(p, "rewrite-apply-to-const")) { + } else if(!strcmp(p, "theory-preprocessing")) { + } else if(!strcmp(p, "nonclausal")) { + } else if(!strcmp(p, "theorypp")) { + } else if(!strcmp(p, "itesimp")) { + } else if(!strcmp(p, "unconstrained")) { + } else if(!strcmp(p, "repeatsimp")) { + } else { + throw OptionException(std::string("don't know how to dump `") + + optargPtr + "'. Please consult --dump help."); + } + Dump.on("assertions"); + } else if(!strcmp(optargPtr, "skolems")) { + } else if(!strcmp(optargPtr, "clauses")) { + } else if(!strcmp(optargPtr, "t-conflicts") || + !strcmp(optargPtr, "t-lemmas") || + !strcmp(optargPtr, "t-explanations") || + !strcmp(optargPtr, "bv-rewrites") || + !strcmp(optargPtr, "theory::fullcheck")) { + // These are "non-state-dumping" modes. If state (SAT decisions, + // propagations, etc.) is dumped, it will interfere with the validity + // of these generated queries. + if(Dump.isOn("state")) { + throw OptionException(std::string("dump option `") + optargPtr + + "' conflicts with a previous, " + "state-dumping dump option. You cannot " + "mix stateful and non-stateful dumping modes; " + "see --dump help."); + } else { + Dump.on("no-permit-state"); + } + } else if(!strcmp(optargPtr, "state") || + !strcmp(optargPtr, "missed-t-conflicts") || + !strcmp(optargPtr, "t-propagations") || + !strcmp(optargPtr, "missed-t-propagations")) { + // These are "state-dumping" modes. If state (SAT decisions, + // propagations, etc.) is not dumped, it will interfere with the + // validity of these generated queries. + if(Dump.isOn("no-permit-state")) { + throw OptionException(std::string("dump option `") + optargPtr + + "' conflicts with a previous, " + "non-state-dumping dump option. You cannot " + "mix stateful and non-stateful dumping modes; " + "see --dump help."); + } else { + Dump.on("state"); + } + } else if(!strcmp(optargPtr, "help")) { + puts(s_dumpHelp.c_str()); + exit(1); + } else if(!strcmp(optargPtr, "bv-abstraction")) { + Dump.on("bv-abstraction"); + } else if(!strcmp(optargPtr, "bv-algebraic")) { + Dump.on("bv-algebraic"); + } else { + throw OptionException(std::string("unknown option for --dump: `") + + optargPtr + "'. Try --dump help."); + } + + Dump.on(optargPtr); + Dump.on("benchmark"); + if(strcmp(optargPtr, "benchmark")) { + Dump.on("declarations"); + if(strcmp(optargPtr, "declarations")) { + Dump.on("skolems"); + } + } + } + free(optargPtr); +#else /* CVC4_DUMPING */ + throw OptionException("The dumping feature was disabled in this build of CVC4."); +#endif /* CVC4_DUMPING */ +} + +LogicInfo* SmtOptionsHandler::stringToLogicInfo(std::string option, std::string optarg) throw(OptionException) { + try { +#warning "TODO: Fix the blatant memory leak here." + LogicInfo* logic = new LogicInfo(optarg); + if(d_smtEngine != NULL) { + d_smtEngine->setLogic(*logic); + } + return logic; + } catch(IllegalArgumentException& e) { + throw OptionException(std::string("invalid logic specification for --force-logic: `") + + optarg + "':\n" + e.what()); + } +} + +SimplificationMode SmtOptionsHandler::stringToSimplificationMode(std::string option, std::string optarg) throw(OptionException) { + 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."); + } +} + + +void SmtOptionsHandler::beforeSearch(std::string option, bool value) throw(ModalException) { + SmtEngine::beforeSearch(d_smtEngine, option); +} + +void SmtOptionsHandler::setProduceAssertions(std::string option, bool value) throw() { + options::produceAssertions.set(value); + options::interactiveMode.set(value); +} + + +void SmtOptionsHandler::proofEnabledBuild(std::string option, bool value) throw(OptionException) { +#if !(IS_PROOFS_BUILD) + if(value) { + std::stringstream ss; + ss << "option `" << option << "' requires a proofs-enabled build of CVC4; this binary was not built with proof support"; + throw OptionException(ss.str()); + } +#endif /* IS_PROOFS_BUILD */ +} + + +// This macro is used for setting :regular-output-channel and :diagnostic-output-channel +// to redirect a stream. It maintains all attributes set on the stream. +#define __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(__channel_get, __channel_set) \ + { \ + int dagSetting = expr::ExprDag::getDag(__channel_get); \ + size_t exprDepthSetting = expr::ExprSetDepth::getDepth(__channel_get); \ + bool printtypesSetting = expr::ExprPrintTypes::getPrintTypes(__channel_get); \ + OutputLanguage languageSetting = expr::ExprSetLanguage::getLanguage(__channel_get); \ + __channel_set; \ + __channel_get << Expr::dag(dagSetting); \ + __channel_get << Expr::setdepth(exprDepthSetting); \ + __channel_get << Expr::printtypes(printtypesSetting); \ + __channel_get << Expr::setlanguage(languageSetting); \ + } + +void SmtOptionsHandler::dumpToFile(std::string option, std::string optarg) { +#ifdef CVC4_DUMPING + std::ostream* outStream = NULL; + if(optarg == "") { + throw OptionException(std::string("Bad file name for --dump-to")); + } else if(optarg == "-") { + outStream = &DumpOutC::dump_cout; + } else if(!options::filesystemAccess()) { + throw OptionException(std::string("Filesystem access not permitted")); + } else { + errno = 0; + outStream = new std::ofstream(optarg.c_str(), std::ofstream::out | std::ofstream::trunc); + if(outStream == NULL || !*outStream) { + std::stringstream ss; + ss << "Cannot open dump-to file: `" << optarg << "': " << __cvc4_errno_failreason(); + throw OptionException(ss.str()); + } + } + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Dump.getStream(), Dump.setStream(*outStream)); +#else /* CVC4_DUMPING */ + throw OptionException("The dumping feature was disabled in this build of CVC4."); +#endif /* CVC4_DUMPING */ +} + +void SmtOptionsHandler::setRegularOutputChannel(std::string option, std::string optarg) { + std::ostream* outStream = NULL; + if(optarg == "") { + throw OptionException(std::string("Bad file name setting for regular output channel")); + } else if(optarg == "stdout") { + outStream = &std::cout; + } else if(optarg == "stderr") { + outStream = &std::cerr; + } else if(!options::filesystemAccess()) { + throw OptionException(std::string("Filesystem access not permitted")); + } else { + errno = 0; + outStream = new std::ofstream(optarg.c_str(), std::ofstream::out | std::ofstream::trunc); + if(outStream == NULL || !*outStream) { + std::stringstream ss; + ss << "Cannot open regular-output-channel file: `" << optarg << "': " << __cvc4_errno_failreason(); + throw OptionException(ss.str()); + } + } + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(*options::err(), options::err.set(outStream)); +} + +void SmtOptionsHandler::setDiagnosticOutputChannel(std::string option, std::string optarg) { + std::ostream* outStream = NULL; + if(optarg == "") { + throw OptionException(std::string("Bad file name setting for diagnostic output channel")); + } else if(optarg == "stdout") { + outStream = &std::cout; + } else if(optarg == "stderr") { + outStream = &std::cerr; + } else if(!options::filesystemAccess()) { + throw OptionException(std::string("Filesystem access not permitted")); + } else { + errno = 0; + outStream = new std::ofstream(optarg.c_str(), std::ofstream::out | std::ofstream::trunc); + if(outStream == NULL || !*outStream) { + std::stringstream ss; + ss << "Cannot open diagnostic-output-channel file: `" << optarg << "': " << __cvc4_errno_failreason(); + throw OptionException(ss.str()); + } + } + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Debug.getStream(), Debug.setStream(*outStream)); + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Warning.getStream(), Warning.setStream(*outStream)); + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Message.getStream(), Message.setStream(*outStream)); + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Notice.getStream(), Notice.setStream(*outStream)); + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Chat.getStream(), Chat.setStream(*outStream)); + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(Trace.getStream(), Trace.setStream(*outStream)); + __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM__(*options::err(), options::err.set(outStream)); +} + +#undef __CVC4__SMT__OUTPUTCHANNELS__SETSTREAM + + + +std::string SmtOptionsHandler::checkReplayFilename(std::string option, std::string optarg) { +#ifdef CVC4_REPLAY + if(optarg == "") { + throw OptionException(std::string("Bad file name for --replay")); + } else { + return optarg; + } +#else /* CVC4_REPLAY */ + throw OptionException("The replay feature was disabled in this build of CVC4."); +#endif /* CVC4_REPLAY */ +} + +std::ostream* SmtOptionsHandler::checkReplayLogFilename(std::string option, std::string optarg) { +#ifdef CVC4_REPLAY + if(optarg == "") { + throw OptionException(std::string("Bad file name for --replay-log")); + } else if(optarg == "-") { + return &std::cout; + } else if(!options::filesystemAccess()) { + throw OptionException(std::string("Filesystem access not permitted")); + } else { + errno = 0; + std::ostream* replayLog = new std::ofstream(optarg.c_str(), std::ofstream::out | std::ofstream::trunc); + if(replayLog == NULL || !*replayLog) { + std::stringstream ss; + ss << "Cannot open replay-log file: `" << optarg << "': " << __cvc4_errno_failreason(); + throw OptionException(ss.str()); + } + return replayLog; + } +#else /* CVC4_REPLAY */ + throw OptionException("The replay feature was disabled in this build of CVC4."); +#endif /* CVC4_REPLAY */ +} + +void SmtOptionsHandler::statsEnabledBuild(std::string option, bool value) throw(OptionException) { +#ifndef CVC4_STATISTICS_ON + if(value) { + std::stringstream ss; + ss << "option `" << option << "' requires a statistics-enabled build of CVC4; this binary was not built with statistics support"; + throw OptionException(ss.str()); + } +#endif /* CVC4_STATISTICS_ON */ +} + +unsigned long SmtOptionsHandler::tlimitHandler(std::string option, std::string optarg) throw(OptionException) { + unsigned long ms; + std::istringstream convert(optarg); + if (!(convert >> ms)) { + throw OptionException("option `"+option+"` requires a number as an argument"); + } + + // make sure the resource is set if the option is updated + // if the smt engine is null the resource will be set in the + if (d_smtEngine != NULL) { + ResourceManager* rm = NodeManager::fromExprManager(d_smtEngine->getExprManager())->getResourceManager(); + rm->setTimeLimit(ms, true); + } + return ms; +} + +unsigned long SmtOptionsHandler::tlimitPerHandler(std::string option, std::string optarg) throw(OptionException) { + unsigned long ms; + + std::istringstream convert(optarg); + if (!(convert >> ms)) { + throw OptionException("option `"+option+"` requires a number as an argument"); + } + + if (d_smtEngine != NULL) { + ResourceManager* rm = NodeManager::fromExprManager(d_smtEngine->getExprManager())->getResourceManager(); + rm->setTimeLimit(ms, false); + } + return ms; +} + +unsigned long SmtOptionsHandler::rlimitHandler(std::string option, std::string optarg) throw(OptionException) { + unsigned long ms; + + std::istringstream convert(optarg); + if (!(convert >> ms)) { + throw OptionException("option `"+option+"` requires a number as an argument"); + } + + if (d_smtEngine != NULL) { + ResourceManager* rm = NodeManager::fromExprManager(d_smtEngine->getExprManager())->getResourceManager(); + rm->setResourceLimit(ms, true); + } + return ms; +} + +unsigned long SmtOptionsHandler::rlimitPerHandler(std::string option, std::string optarg) throw(OptionException) { + unsigned long ms; + + std::istringstream convert(optarg); + if (!(convert >> ms)) { + throw OptionException("option `"+option+"` requires a number as an argument"); + } + + // TODO: Remove check? + if (d_smtEngine != NULL) { + ResourceManager* rm = NodeManager::fromExprManager(d_smtEngine->getExprManager())->getResourceManager(); + rm->setResourceLimit(ms, false); + } + return ms; +} + + + +// expr/options_handlers.h +void SmtOptionsHandler::setDefaultExprDepth(std::string option, int depth) { + if(depth < -1) { + throw OptionException("--default-expr-depth requires a positive argument, or -1."); + } + + Debug.getStream() << Expr::setdepth(depth); + Trace.getStream() << Expr::setdepth(depth); + Notice.getStream() << Expr::setdepth(depth); + Chat.getStream() << Expr::setdepth(depth); + Message.getStream() << Expr::setdepth(depth); + Warning.getStream() << Expr::setdepth(depth); + // intentionally exclude Dump stream from this list +} + +void SmtOptionsHandler::setDefaultDagThresh(std::string option, int dag) { + if(dag < 0) { + throw OptionException("--default-dag-thresh requires a nonnegative argument."); + } + + Debug.getStream() << Expr::dag(dag); + Trace.getStream() << Expr::dag(dag); + Notice.getStream() << Expr::dag(dag); + Chat.getStream() << Expr::dag(dag); + Message.getStream() << Expr::dag(dag); + Warning.getStream() << Expr::dag(dag); + Dump.getStream() << Expr::dag(dag); +} + +void SmtOptionsHandler::setPrintExprTypes(std::string option) { + Debug.getStream() << Expr::printtypes(true); + Trace.getStream() << Expr::printtypes(true); + Notice.getStream() << Expr::printtypes(true); + Chat.getStream() << Expr::printtypes(true); + Message.getStream() << Expr::printtypes(true); + Warning.getStream() << Expr::printtypes(true); + // intentionally exclude Dump stream from this list +} + + +// main/options_handlers.h +void SmtOptionsHandler::showConfiguration(std::string option) { + fputs(Configuration::about().c_str(), stdout); + printf("\n"); + printf("version : %s\n", Configuration::getVersionString().c_str()); + if(Configuration::isGitBuild()) { + const char* branchName = Configuration::getGitBranchName(); + if(*branchName == '\0') { + branchName = "-"; + } + printf("scm : git [%s %s%s]\n", + branchName, + std::string(Configuration::getGitCommit()).substr(0, 8).c_str(), + Configuration::hasGitModifications() ? + " (with modifications)" : ""); + } else if(Configuration::isSubversionBuild()) { + printf("scm : svn [%s r%u%s]\n", + Configuration::getSubversionBranchName(), + Configuration::getSubversionRevision(), + Configuration::hasSubversionModifications() ? + " (with modifications)" : ""); + } else { + printf("scm : no\n"); + } + printf("\n"); + printf("library : %u.%u.%u\n", + Configuration::getVersionMajor(), + Configuration::getVersionMinor(), + Configuration::getVersionRelease()); + printf("\n"); + printf("debug code : %s\n", Configuration::isDebugBuild() ? "yes" : "no"); + printf("statistics : %s\n", Configuration::isStatisticsBuild() ? "yes" : "no"); + printf("replay : %s\n", Configuration::isReplayBuild() ? "yes" : "no"); + printf("tracing : %s\n", Configuration::isTracingBuild() ? "yes" : "no"); + printf("dumping : %s\n", Configuration::isDumpingBuild() ? "yes" : "no"); + printf("muzzled : %s\n", Configuration::isMuzzledBuild() ? "yes" : "no"); + printf("assertions : %s\n", Configuration::isAssertionBuild() ? "yes" : "no"); + printf("proof : %s\n", Configuration::isProofBuild() ? "yes" : "no"); + printf("coverage : %s\n", Configuration::isCoverageBuild() ? "yes" : "no"); + printf("profiling : %s\n", Configuration::isProfilingBuild() ? "yes" : "no"); + printf("competition: %s\n", Configuration::isCompetitionBuild() ? "yes" : "no"); + printf("\n"); + printf("cudd : %s\n", Configuration::isBuiltWithCudd() ? "yes" : "no"); + printf("cln : %s\n", Configuration::isBuiltWithCln() ? "yes" : "no"); + printf("gmp : %s\n", Configuration::isBuiltWithGmp() ? "yes" : "no"); + printf("glpk : %s\n", Configuration::isBuiltWithGlpk() ? "yes" : "no"); + printf("abc : %s\n", Configuration::isBuiltWithAbc() ? "yes" : "no"); + printf("readline : %s\n", Configuration::isBuiltWithReadline() ? "yes" : "no"); + printf("tls : %s\n", Configuration::isBuiltWithTlsSupport() ? "yes" : "no"); + exit(0); +} + +void SmtOptionsHandler::showDebugTags(std::string option) { + if(Configuration::isDebugBuild() && Configuration::isTracingBuild()) { + printf("available tags:"); + unsigned ntags = Configuration::getNumDebugTags(); + char const* const* tags = Configuration::getDebugTags(); + for(unsigned i = 0; i < ntags; ++ i) { + printf(" %s", tags[i]); + } + printf("\n"); + } else if(! Configuration::isDebugBuild()) { + throw OptionException("debug tags not available in non-debug builds"); + } else { + throw OptionException("debug tags not available in non-tracing builds"); + } + exit(0); +} + +void SmtOptionsHandler::showTraceTags(std::string option) { + if(Configuration::isTracingBuild()) { + printf("available tags:"); + unsigned ntags = Configuration::getNumTraceTags(); + char const* const* tags = Configuration::getTraceTags(); + for (unsigned i = 0; i < ntags; ++ i) { + printf(" %s", tags[i]); + } + printf("\n"); + } else { + throw OptionException("trace tags not available in non-tracing build"); + } + exit(0); +} + +void SmtOptionsHandler::threadN(std::string option) { + throw OptionException(option + " is not a real option by itself. Use e.g. --thread0=\"--random-seed=10 --random-freq=0.02\" --thread1=\"--random-seed=20 --random-freq=0.05\""); +} + + + +/* options/base_options_handlers.h */ +void SmtOptionsHandler::setVerbosity(std::string option, int value) throw(OptionException) { + if(Configuration::isMuzzledBuild()) { + DebugChannel.setStream(CVC4::null_os); + TraceChannel.setStream(CVC4::null_os); + NoticeChannel.setStream(CVC4::null_os); + ChatChannel.setStream(CVC4::null_os); + MessageChannel.setStream(CVC4::null_os); + WarningChannel.setStream(CVC4::null_os); + } else { + if(value < 2) { + ChatChannel.setStream(CVC4::null_os); + } else { + ChatChannel.setStream(std::cout); + } + if(value < 1) { + NoticeChannel.setStream(CVC4::null_os); + } else { + NoticeChannel.setStream(std::cout); + } + if(value < 0) { + MessageChannel.setStream(CVC4::null_os); + WarningChannel.setStream(CVC4::null_os); + } else { + MessageChannel.setStream(std::cout); + WarningChannel.setStream(std::cerr); + } + } +} + +void SmtOptionsHandler::increaseVerbosity(std::string option) { + options::verbosity.set(options::verbosity() + 1); + setVerbosity(option, options::verbosity()); +} + +void SmtOptionsHandler::decreaseVerbosity(std::string option) { + options::verbosity.set(options::verbosity() - 1); + setVerbosity(option, options::verbosity()); +} + +OutputLanguage SmtOptionsHandler::stringToOutputLanguage(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "help") { + options::languageHelp.set(true); + return language::output::LANG_AUTO; + } + + try { + return language::toOutputLanguage(optarg); + } catch(OptionException& oe) { + throw OptionException("Error in " + option + ": " + oe.getMessage() + "\nTry --output-language help"); + } + + Unreachable(); +} + +InputLanguage SmtOptionsHandler::stringToInputLanguage(std::string option, std::string optarg) throw(OptionException) { + if(optarg == "help") { + options::languageHelp.set(true); + return language::input::LANG_AUTO; + } + + try { + return language::toInputLanguage(optarg); + } catch(OptionException& oe) { + throw OptionException("Error in " + option + ": " + oe.getMessage() + "\nTry --language help"); + } + + Unreachable(); +} + +void SmtOptionsHandler::addTraceTag(std::string option, std::string optarg) { + if(Configuration::isTracingBuild()) { + if(!Configuration::isTraceTag(optarg.c_str())) { + + if(optarg == "help") { + printf("available tags:"); + unsigned ntags = Configuration::getNumTraceTags(); + char const* const* tags = Configuration::getTraceTags(); + for(unsigned i = 0; i < ntags; ++ i) { + printf(" %s", tags[i]); + } + printf("\n"); + exit(0); + } + + throw OptionException(std::string("trace tag ") + optarg + + std::string(" not available.") + + suggestTags(Configuration::getTraceTags(), optarg) ); + } + } else { + throw OptionException("trace tags not available in non-tracing builds"); + } + Trace.on(optarg); +} + +void SmtOptionsHandler::addDebugTag(std::string option, std::string optarg) { + if(Configuration::isDebugBuild() && Configuration::isTracingBuild()) { + if(!Configuration::isDebugTag(optarg.c_str()) && + !Configuration::isTraceTag(optarg.c_str())) { + + if(optarg == "help") { + printf("available tags:"); + unsigned ntags = Configuration::getNumDebugTags(); + char const* const* tags = Configuration::getDebugTags(); + for(unsigned i = 0; i < ntags; ++ i) { + printf(" %s", tags[i]); + } + printf("\n"); + exit(0); + } + + throw OptionException(std::string("debug tag ") + optarg + + std::string(" not available.") + + suggestTags(Configuration::getDebugTags(), optarg, Configuration::getTraceTags()) ); + } + } else if(! Configuration::isDebugBuild()) { + throw OptionException("debug tags not available in non-debug builds"); + } else { + throw OptionException("debug tags not available in non-tracing builds"); + } + Debug.on(optarg); + Trace.on(optarg); +} + +void SmtOptionsHandler::setPrintSuccess(std::string option, bool value) { + Debug.getStream() << Command::printsuccess(value); + Trace.getStream() << Command::printsuccess(value); + Notice.getStream() << Command::printsuccess(value); + Chat.getStream() << Command::printsuccess(value); + Message.getStream() << Command::printsuccess(value); + Warning.getStream() << Command::printsuccess(value); + *options::out() << Command::printsuccess(value); +} + + +std::string SmtOptionsHandler::suggestTags(char const* const* validTags, std::string inputTag, + char const* const* additionalTags) +{ + DidYouMean didYouMean; + + const char* opt; + for(size_t i = 0; (opt = validTags[i]) != NULL; ++i) { + didYouMean.addWord(validTags[i]); + } + if(additionalTags != NULL) { + for(size_t i = 0; (opt = additionalTags[i]) != NULL; ++i) { + didYouMean.addWord(additionalTags[i]); + } + } + + return didYouMean.getMatchAsString(inputTag); +} + +std::string SmtOptionsHandler::__cvc4_errno_failreason() { +#if HAVE_STRERROR_R +#if STRERROR_R_CHAR_P + if(errno != 0) { + // GNU version of strerror_r: *might* use the given buffer, + // or might not. It returns a pointer to buf, or not. + char buf[80]; + return std::string(strerror_r(errno, buf, sizeof buf)); + } else { + return "unknown reason"; + } +#else /* STRERROR_R_CHAR_P */ + if(errno != 0) { + // XSI version of strerror_r: always uses the given buffer. + // Returns an error code. + char buf[80]; + if(strerror_r(errno, buf, sizeof buf) == 0) { + return std::string(buf); + } else { + // some error occurred while getting the error string + return "unknown reason"; + } + } else { + return "unknown reason"; + } +#endif /* STRERROR_R_CHAR_P */ +#else /* HAVE_STRERROR_R */ + return "unknown reason"; +#endif /* HAVE_STRERROR_R */ +} + +}/* CVC4::smt namespace */ +}/* CVC4 namespace */ diff --git a/src/smt/smt_options_handler.h b/src/smt/smt_options_handler.h new file mode 100644 index 000000000..c4d27a722 --- /dev/null +++ b/src/smt/smt_options_handler.h @@ -0,0 +1,198 @@ +/********************* */ +/*! \file options_handler_interface.h + ** \verbatim + ** Original author: Tim King + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Interface for custom handlers and predicates options. + ** + ** Interface for custom handlers and predicates options. + **/ + +#include "cvc4_private.h" + +#ifndef __CVC4__SMT__SMT_OPTIONS_HANDLER_H +#define __CVC4__SMT__SMT_OPTIONS_HANDLER_H + +#include <ostream> +#include <string> + +#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/boolean_term_conversion_mode.h" +#include "options/bv_bitblast_mode.h" +#include "options/decision_mode.h" +#include "options/language.h" +#include "options/option_exception.h" +#include "options/options_handler_interface.h" +#include "options/printer_modes.h" +#include "options/quantifiers_modes.h" +#include "options/simplification_mode.h" +#include "options/theoryof_mode.h" +#include "options/ufss_mode.h" +#include "smt/smt_engine.h" +#include "theory/logic_info.h" + +namespace CVC4 { +namespace smt { + +class CVC4_PUBLIC SmtOptionsHandler : public options::OptionsHandler { +public: + SmtOptionsHandler(SmtEngine* smt); + ~SmtOptionsHandler(); + + // TODO + // theory/arith/options_handlers.h + // theory/quantifiers/options_handlers.h + // theory/bv/options_handlers.h + // theory/booleans/options_handlers.h + // theory/uf/options_handlers.h + // theory/options_handlers.h + // printer/options_handlers.h + // decision/options_handlers.h + // smt/options_handlers.h + // expr/options_handlers.h + // main/options_handlers.h + // options/base_options_handlers.h + + // theory/arith/options_handlers.h + virtual ArithUnateLemmaMode stringToArithUnateLemmaMode(std::string option, std::string optarg) throw(OptionException); + virtual ArithPropagationMode stringToArithPropagationMode(std::string option, std::string optarg) throw(OptionException); + virtual ErrorSelectionRule stringToErrorSelectionRule(std::string option, std::string optarg) throw(OptionException); + + // theory/quantifiers/options_handlers.h + virtual theory::quantifiers::InstWhenMode stringToInstWhenMode(std::string option, std::string optarg) throw(OptionException); + virtual void checkInstWhenMode(std::string option, theory::quantifiers::InstWhenMode mode) throw(OptionException); + virtual theory::quantifiers::LiteralMatchMode stringToLiteralMatchMode(std::string option, std::string optarg) throw(OptionException); + virtual void checkLiteralMatchMode(std::string option, theory::quantifiers::LiteralMatchMode mode) throw(OptionException); + virtual theory::quantifiers::MbqiMode stringToMbqiMode(std::string option, std::string optarg) throw(OptionException); + virtual void checkMbqiMode(std::string option, theory::quantifiers::MbqiMode mode) throw(OptionException); + virtual theory::quantifiers::QcfWhenMode stringToQcfWhenMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::QcfMode stringToQcfMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::UserPatMode stringToUserPatMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::TriggerSelMode stringToTriggerSelMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::PrenexQuantMode stringToPrenexQuantMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::CegqiFairMode stringToCegqiFairMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::TermDbMode stringToTermDbMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::IteLiftQuantMode stringToIteLiftQuantMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::SygusInvTemplMode stringToSygusInvTemplMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::quantifiers::MacrosQuantMode stringToMacrosQuantMode(std::string option, std::string optarg) throw(OptionException); + + // theory/bv/options_handlers.h + virtual void abcEnabledBuild(std::string option, bool value) throw(OptionException); + virtual void abcEnabledBuild(std::string option, std::string value) throw(OptionException); + virtual theory::bv::BitblastMode stringToBitblastMode(std::string option, std::string optarg) throw(OptionException); + virtual theory::bv::BvSlicerMode stringToBvSlicerMode(std::string option, std::string optarg) throw(OptionException); + virtual void setBitblastAig(std::string option, bool arg) throw(OptionException); + + + // theory/booleans/options_handlers.h + virtual theory::booleans::BooleanTermConversionMode stringToBooleanTermConversionMode(std::string option, std::string optarg) throw(OptionException); + + // theory/uf/options_handlers.h + virtual theory::uf::UfssMode stringToUfssMode(std::string option, std::string optarg) throw(OptionException); + + // theory/options_handlers.h + virtual theory::TheoryOfMode stringToTheoryOfMode(std::string option, std::string optarg); + virtual void useTheory(std::string option, std::string optarg); + + + // printer/options_handlers.h + virtual ModelFormatMode stringToModelFormatMode(std::string option, std::string optarg) throw(OptionException); + virtual InstFormatMode stringToInstFormatMode(std::string option, std::string optarg) throw(OptionException); + + // decision/options_handlers.h + virtual decision::DecisionMode stringToDecisionMode(std::string option, std::string optarg) throw(OptionException); + virtual decision::DecisionWeightInternal stringToDecisionWeightInternal(std::string option, std::string optarg) throw(OptionException); + + + // smt/options_handlers.h + virtual void dumpMode(std::string option, std::string optarg); + virtual LogicInfo* stringToLogicInfo(std::string option, std::string optarg) throw(OptionException); + virtual SimplificationMode stringToSimplificationMode(std::string option, std::string optarg) throw(OptionException); + virtual void beforeSearch(std::string option, bool value) throw(ModalException); + virtual void setProduceAssertions(std::string option, bool value) throw(); + virtual void proofEnabledBuild(std::string option, bool value) throw(OptionException); + virtual void dumpToFile(std::string option, std::string optarg); + virtual void setRegularOutputChannel(std::string option, std::string optarg); + virtual void setDiagnosticOutputChannel(std::string option, std::string optarg); + virtual std::string checkReplayFilename(std::string option, std::string optarg); + virtual std::ostream* checkReplayLogFilename(std::string option, std::string optarg); + virtual void statsEnabledBuild(std::string option, bool value) throw(OptionException); + virtual unsigned long tlimitHandler(std::string option, std::string optarg) throw(OptionException); + virtual unsigned long tlimitPerHandler(std::string option, std::string optarg) throw(OptionException); + virtual unsigned long rlimitHandler(std::string option, std::string optarg) throw(OptionException); + virtual unsigned long rlimitPerHandler(std::string option, std::string optarg) throw(OptionException); + + /* expr/options_handlers.h */ + virtual void setDefaultExprDepth(std::string option, int depth); + virtual void setDefaultDagThresh(std::string option, int dag); + virtual void setPrintExprTypes(std::string option); + + /* main/options_handlers.h */ + virtual void showConfiguration(std::string option); + virtual void showDebugTags(std::string option); + virtual void showTraceTags(std::string option); + virtual void threadN(std::string option); + + /* options/base_options_handlers.h */ + virtual void setVerbosity(std::string option, int value) throw(OptionException); + virtual void increaseVerbosity(std::string option); + virtual void decreaseVerbosity(std::string option); + virtual OutputLanguage stringToOutputLanguage(std::string option, std::string optarg) throw(OptionException); + virtual InputLanguage stringToInputLanguage(std::string option, std::string optarg) throw(OptionException) ; + virtual void addTraceTag(std::string option, std::string optarg); + virtual void addDebugTag(std::string option, std::string optarg); + virtual void setPrintSuccess(std::string option, bool value); + +private: + SmtEngine* d_smtEngine; + + /* Helper utilities */ + static std::string suggestTags(char const* const* validTags, std::string inputTag, + char const* const* additionalTags = NULL); + static std::string __cvc4_errno_failreason(); + + /* Help strings */ + static const std::string s_bitblastingModeHelp; + static const std::string s_booleanTermConversionModeHelp; + static const std::string s_bvSlicerModeHelp; + static const std::string s_cegqiFairModeHelp; + static const std::string s_decisionModeHelp; + static const std::string s_dumpHelp; + 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_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_sygusInvTemplHelp; + static const std::string s_termDbModeHelp; + static const std::string s_theoryOfModeHelp; + static const std::string s_triggerSelModeHelp; + static const std::string s_ufssModeHelp; + static const std::string s_userPatModeHelp; + static const std::string s_errorSelectionRulesHelp; + static const std::string s_arithPropagationModeHelp; + static const std::string s_arithUnateLemmasHelp; + + +}; /* class SmtOptionsHandler */ + + +}/* CVC4::smt namespace */ +}/* CVC4 namespace */ + +#endif /* __CVC4__SMT__SMT_OPTIONS_HANDLER_H */ diff --git a/src/smt/smt_options_template.cpp b/src/smt/smt_options_template.cpp deleted file mode 100644 index 376584636..000000000 --- a/src/smt/smt_options_template.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/********************* */ -/*! \file smt_options_template.cpp - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: none - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Option handling for SmtEngine - ** - ** Option handling for SmtEngine. - **/ - -#include "smt/smt_engine.h" -#include "smt/modal_exception.h" -#include "util/sexpr.h" -#include "util/dump.h" -#include "expr/command.h" -#include "expr/node_manager.h" - -#include <string> -#include <sstream> - -${include_all_option_headers} -${option_handler_includes} - -#line 31 "${template}" - -using namespace std; - -namespace CVC4 { - -void SmtEngine::setOption(const std::string& key, const CVC4::SExpr& value) - throw(OptionException, ModalException) { - - NodeManagerScope nms(d_nodeManager); - SmtEngine* const smt = this; - - Trace("smt") << "SMT setOption(" << key << ", " << value << ")" << endl; - if(Dump.isOn("benchmark")) { - Dump("benchmark") << SetOptionCommand(key, value); - } - - if(key == "command-verbosity") { - if(!value.isAtom()) { - const vector<SExpr>& cs = value.getChildren(); - if(cs.size() == 2 && - (cs[0].isKeyword() || cs[0].isString()) && - cs[1].isInteger()) { - string c = cs[0].getValue(); - const Integer& v = cs[1].getIntegerValue(); - if(v < 0 || v > 2) { - throw OptionException("command-verbosity must be 0, 1, or 2"); - } - d_commandVerbosity[c] = v; - return; - } - } - throw OptionException("command-verbosity value must be a tuple (command-name, integer)"); - } - - if(!value.isAtom()) { - throw OptionException("bad value for :" + key); - } - - string optionarg = value.getValue(); - - ${smt_setoption_handlers} - -#line 74 "${template}" - - throw UnrecognizedOptionException(key); -} - -CVC4::SExpr SmtEngine::getOption(const std::string& key) const - throw(OptionException) { - - NodeManagerScope nms(d_nodeManager); - - Trace("smt") << "SMT getOption(" << key << ")" << endl; - - if(key.length() >= 18 && - key.compare(0, 18, "command-verbosity:") == 0) { - map<string, Integer>::const_iterator i = d_commandVerbosity.find(key.c_str() + 18); - if(i != d_commandVerbosity.end()) { - return (*i).second; - } - i = d_commandVerbosity.find("*"); - if(i != d_commandVerbosity.end()) { - return (*i).second; - } - return Integer(2); - } - - if(Dump.isOn("benchmark")) { - Dump("benchmark") << GetOptionCommand(key); - } - - if(key == "command-verbosity") { - vector<SExpr> result; - SExpr defaultVerbosity; - for(map<string, Integer>::const_iterator i = d_commandVerbosity.begin(); - i != d_commandVerbosity.end(); - ++i) { - vector<SExpr> v; - v.push_back((*i).first); - v.push_back((*i).second); - if((*i).first == "*") { - // put the default at the end of the SExpr - defaultVerbosity = v; - } else { - result.push_back(v); - } - } - // put the default at the end of the SExpr - if(!defaultVerbosity.isAtom()) { - result.push_back(defaultVerbosity); - } else { - // ensure the default is always listed - vector<SExpr> v; - v.push_back("*"); - v.push_back(Integer(2)); - result.push_back(v); - } - return result; - } - - ${smt_getoption_handlers} - -#line 134 "${template}" - - throw UnrecognizedOptionException(key); -} - -}/* CVC4 namespace */ diff --git a/src/smt_util/Makefile.am b/src/smt_util/Makefile.am new file mode 100644 index 000000000..3b457f641 --- /dev/null +++ b/src/smt_util/Makefile.am @@ -0,0 +1,30 @@ +AM_CPPFLAGS = \ + -D__BUILDING_CVC4LIB \ + -I@builddir@/.. -I@srcdir@/../include -I@srcdir@/.. +AM_CXXFLAGS = -Wall -Wno-unknown-pragmas $(FLAG_VISIBILITY_HIDDEN) + +noinst_LTLIBRARIES = libsmtutil.la + +libsmtutil_la_SOURCES = \ + Makefile.am \ + Makefile.in \ + boolean_simplification.cpp \ + boolean_simplification.h \ + command.cpp \ + command.h \ + dump.h \ + dump.cpp \ + lemma_input_channel.h \ + lemma_output_channel.h \ + ite_removal.cpp \ + ite_removal.h \ + model.cpp \ + model.h \ + nary_builder.cpp \ + nary_builder.h \ + node_visitor.h + + +EXTRA_DIST = \ + command.i + diff --git a/src/util/boolean_simplification.cpp b/src/smt_util/boolean_simplification.cpp index 62ef46339..fba431350 100644 --- a/src/util/boolean_simplification.cpp +++ b/src/smt_util/boolean_simplification.cpp @@ -14,7 +14,7 @@ ** Simple, commonly-used routines for Boolean simplification. **/ -#include "util/boolean_simplification.h" +#include "smt_util/boolean_simplification.h" namespace CVC4 { @@ -63,4 +63,3 @@ BooleanSimplification::push_back_associative_commute_recursive }/* BooleanSimplification::push_back_associative_commute_recursive() */ }/* CVC4 namespace */ - diff --git a/src/util/boolean_simplification.h b/src/smt_util/boolean_simplification.h index d0ca3646f..2732eaea7 100644 --- a/src/util/boolean_simplification.h +++ b/src/smt_util/boolean_simplification.h @@ -22,9 +22,9 @@ #include <vector> #include <algorithm> +#include "base/cvc4_assert.h" #include "expr/expr_manager_scope.h" #include "expr/node.h" -#include "util/cvc4_assert.h" namespace CVC4 { diff --git a/src/expr/command.cpp b/src/smt_util/command.cpp index 1c7c1d171..464a2e0aa 100644 --- a/src/expr/command.cpp +++ b/src/smt_util/command.cpp @@ -14,24 +14,25 @@ ** Implementation of command objects. **/ +#include "smt_util/command.h" + +#include <exception> #include <iostream> -#include <vector> -#include <utility> #include <iterator> #include <sstream> -#include <exception> +#include <utility> +#include <vector> -#include "expr/command.h" -#include "smt/smt_engine.h" -#include "options/options.h" -#include "smt/options.h" -#include "smt/smt_engine_scope.h" -#include "util/output.h" -#include "util/dump.h" -#include "util/sexpr.h" -#include "util/model.h" +#include "base/output.h" #include "expr/node.h" +#include "expr/sexpr.h" +#include "options/options.h" +#include "options/smt_options.h" #include "printer/printer.h" +#include "smt/smt_engine.h" +#include "smt/smt_engine_scope.h" +#include "smt_util/dump.h" +#include "smt_util/model.h" using namespace std; @@ -1332,7 +1333,7 @@ void SetBenchmarkStatusCommand::invoke(SmtEngine* smtEngine) throw() { try { stringstream ss; ss << d_status; - SExpr status = ss.str(); + SExpr status = SExpr(ss.str()); smtEngine->setInfo("status", status); d_commandStatus = CommandSuccess::instance(); } catch(exception& e) { @@ -1530,9 +1531,7 @@ std::string GetOptionCommand::getFlag() const throw() { void GetOptionCommand::invoke(SmtEngine* smtEngine) throw() { try { SExpr res = smtEngine->getOption(d_flag); - stringstream ss; - ss << res; - d_result = ss.str(); + d_result = res.toString(); d_commandStatus = CommandSuccess::instance(); } catch(UnrecognizedOptionException&) { d_commandStatus = new CommandUnsupported(); diff --git a/src/expr/command.h b/src/smt_util/command.h index 9165961fb..b35fb7a7f 100644 --- a/src/expr/command.h +++ b/src/smt_util/command.h @@ -28,14 +28,14 @@ #include <vector> #include <map> +#include "expr/datatype.h" #include "expr/expr.h" +#include "expr/result.h" +#include "expr/sexpr.h" #include "expr/type.h" #include "expr/variable_type_map.h" -#include "util/result.h" -#include "util/sexpr.h" -#include "util/datatype.h" +#include "proof/unsat_core.h" #include "util/proof.h" -#include "util/unsat_core.h" namespace CVC4 { diff --git a/src/expr/command.i b/src/smt_util/command.i index d6cbfe272..e4744c4f4 100644 --- a/src/expr/command.i +++ b/src/smt_util/command.i @@ -1,5 +1,5 @@ %{ -#include "expr/command.h" +#include "smt_util/command.h" #ifdef SWIGJAVA @@ -65,7 +65,7 @@ #endif /* SWIGJAVA */ -%include "expr/command.h" +%include "smt_util/command.h" #ifdef SWIGJAVA diff --git a/src/util/dump.cpp b/src/smt_util/dump.cpp index 53c5eae6a..56313f4d8 100644 --- a/src/util/dump.cpp +++ b/src/smt_util/dump.cpp @@ -13,10 +13,9 @@ ** ** Dump utility classes and functions. **/ +#include "smt_util/dump.h" -#include "util/dump.h" - -using namespace std; +#include "base/output.h" namespace CVC4 { diff --git a/src/util/dump.h b/src/smt_util/dump.h index 2cf5877d4..1f4efe640 100644 --- a/src/util/dump.h +++ b/src/smt_util/dump.h @@ -19,7 +19,8 @@ #ifndef __CVC4__DUMP_H #define __CVC4__DUMP_H -#include "expr/command.h" +#include "base/output.h" +#include "smt_util/command.h" namespace CVC4 { diff --git a/src/util/ite_removal.cpp b/src/smt_util/ite_removal.cpp index 97a6338ce..0d1c7b61e 100644 --- a/src/util/ite_removal.cpp +++ b/src/smt_util/ite_removal.cpp @@ -13,13 +13,13 @@ ** ** Removal of term ITEs. **/ +#include "smt_util/ite_removal.h" #include <vector> -#include "util/ite_removal.h" -#include "expr/command.h" -#include "theory/ite_utilities.h" #include "proof/proof_manager.h" +#include "smt_util/command.h" +#include "theory/ite_utilities.h" using namespace CVC4; using namespace std; diff --git a/src/util/ite_removal.h b/src/smt_util/ite_removal.h index d71f9b13d..0cc0ea5d0 100644 --- a/src/util/ite_removal.h +++ b/src/smt_util/ite_removal.h @@ -19,12 +19,13 @@ #pragma once #include <vector> -#include "expr/node.h" -#include "util/dump.h" -#include "context/context.h" + #include "context/cdinsert_hashmap.h" -#include "util/hash.h" +#include "context/context.h" +#include "expr/node.h" +#include "smt_util/dump.h" #include "util/bool.h" +#include "util/hash.h" namespace CVC4 { diff --git a/src/util/lemma_input_channel.h b/src/smt_util/lemma_input_channel.h index 44f0b87f5..66fe06424 100644 --- a/src/util/lemma_input_channel.h +++ b/src/smt_util/lemma_input_channel.h @@ -20,6 +20,7 @@ #ifndef __CVC4__LEMMA_INPUT_CHANNEL_H #define __CVC4__LEMMA_INPUT_CHANNEL_H +#include "base/lemma_input_channel_forward.h" #include "expr/expr.h" namespace CVC4 { diff --git a/src/util/lemma_output_channel.h b/src/smt_util/lemma_output_channel.h index df7abd1e9..0fabe5721 100644 --- a/src/util/lemma_output_channel.h +++ b/src/smt_util/lemma_output_channel.h @@ -21,6 +21,7 @@ #ifndef __CVC4__LEMMA_OUTPUT_CHANNEL_H #define __CVC4__LEMMA_OUTPUT_CHANNEL_H +#include "base/lemma_output_channel_forward.h" #include "expr/expr.h" namespace CVC4 { diff --git a/src/util/model.cpp b/src/smt_util/model.cpp index c1254ab47..3f0423f49 100644 --- a/src/util/model.cpp +++ b/src/smt_util/model.cpp @@ -12,14 +12,15 @@ ** \brief implementation of Model class **/ -#include "util/model.h" -#include "expr/command.h" +#include "smt_util/model.h" + +#include <vector> + +#include "smt_util/command.h" #include "smt/smt_engine_scope.h" #include "smt/command_list.h" #include "printer/printer.h" -#include <vector> - using namespace std; namespace CVC4 { diff --git a/src/util/model.h b/src/smt_util/model.h index 98794a53d..98794a53d 100644 --- a/src/util/model.h +++ b/src/smt_util/model.h diff --git a/src/util/nary_builder.cpp b/src/smt_util/nary_builder.cpp index d89121fd7..ec012308f 100644 --- a/src/util/nary_builder.cpp +++ b/src/smt_util/nary_builder.cpp @@ -14,10 +14,10 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ +#include "smt_util/nary_builder.h" - -#include "util/nary_builder.h" #include "expr/metakind.h" + using namespace std; namespace CVC4 { diff --git a/src/util/nary_builder.h b/src/smt_util/nary_builder.h index c98e01b1b..c98e01b1b 100644 --- a/src/util/nary_builder.h +++ b/src/smt_util/nary_builder.h diff --git a/src/util/node_visitor.h b/src/smt_util/node_visitor.h index 66a58efd1..c8958b7b5 100644 --- a/src/util/node_visitor.h +++ b/src/smt_util/node_visitor.h @@ -19,6 +19,7 @@ #include "cvc4_private.h" #include <vector> + #include "expr/node.h" namespace CVC4 { diff --git a/src/theory/arith/approx_simplex.cpp b/src/theory/arith/approx_simplex.cpp index 5b3c87b3d..71ac18e84 100644 --- a/src/theory/arith/approx_simplex.cpp +++ b/src/theory/arith/approx_simplex.cpp @@ -15,17 +15,18 @@ ** \todo document this file **/ -#include "cvc4autoconfig.h" +#include <cfloat> +#include <cmath> +#include <map> +#include <math.h> +#include "base/output.h" +#include "cvc4autoconfig.h" #include "theory/arith/approx_simplex.h" -#include "theory/arith/normal_form.h" #include "theory/arith/constraint.h" #include "theory/arith/cut_log.h" #include "theory/arith/matrix.h" -#include <math.h> -#include <cmath> -#include <cfloat> -#include <map> +#include "theory/arith/normal_form.h" using namespace std; diff --git a/src/theory/arith/approx_simplex.h b/src/theory/arith/approx_simplex.h index 808b64703..064887787 100644 --- a/src/theory/arith/approx_simplex.h +++ b/src/theory/arith/approx_simplex.h @@ -19,14 +19,13 @@ #include "cvc4_private.h" #pragma once +#include <vector> -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" #include "theory/arith/arithvar.h" -#include "util/rational.h" #include "theory/arith/delta_rational.h" -//#include "theory/arith/linear_equality.h" #include "util/dense_map.h" -#include <vector> +#include "util/rational.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/arith_ite_utils.cpp b/src/theory/arith/arith_ite_utils.cpp index 2b31831e2..cd180e59e 100644 --- a/src/theory/arith/arith_ite_utils.cpp +++ b/src/theory/arith/arith_ite_utils.cpp @@ -15,15 +15,18 @@ ** \todo document this file **/ -#include "smt/options.h" #include "theory/arith/arith_ite_utils.h" -#include "theory/arith/normal_form.h" + +#include <ostream> + +#include "base/output.h" +#include "options/smt_options.h" #include "theory/arith/arith_utilities.h" +#include "theory/arith/normal_form.h" #include "theory/ite_utilities.h" -#include "theory/theory_model.h" #include "theory/rewriter.h" #include "theory/substitutions.h" -#include <ostream> +#include "theory/theory_model.h" using namespace std; diff --git a/src/theory/arith/arith_rewriter.cpp b/src/theory/arith/arith_rewriter.cpp index a85fd024f..ca286d53a 100644 --- a/src/theory/arith/arith_rewriter.cpp +++ b/src/theory/arith/arith_rewriter.cpp @@ -15,14 +15,15 @@ ** \todo document this file **/ -#include "theory/theory.h" -#include "theory/arith/normal_form.h" -#include "theory/arith/arith_rewriter.h" -#include "theory/arith/arith_utilities.h" - -#include <vector> #include <set> #include <stack> +#include <vector> + +#include "base/output.h" +#include "theory/arith/arith_rewriter.h" +#include "theory/arith/arith_utilities.h" +#include "theory/arith/normal_form.h" +#include "theory/theory.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/arith_static_learner.cpp b/src/theory/arith/arith_static_learner.cpp index a7767e38b..383c6b418 100644 --- a/src/theory/arith/arith_static_learner.cpp +++ b/src/theory/arith/arith_static_learner.cpp @@ -15,18 +15,16 @@ ** \todo document this file **/ -#include "theory/rewriter.h" +#include <vector> -#include "theory/arith/arith_utilities.h" +#include "base/output.h" +#include "expr/convenience_node_builders.h" +#include "expr/expr.h" +#include "options/arith_options.h" #include "theory/arith/arith_static_learner.h" -#include "theory/arith/options.h" - +#include "theory/arith/arith_utilities.h" #include "theory/arith/normal_form.h" - -#include "expr/expr.h" -#include "expr/convenience_node_builders.h" - -#include <vector> +#include "theory/rewriter.h" using namespace std; using namespace CVC4::kind; diff --git a/src/theory/arith/arith_static_learner.h b/src/theory/arith/arith_static_learner.h index 7a1a1a6db..2b0ee9dad 100644 --- a/src/theory/arith/arith_static_learner.h +++ b/src/theory/arith/arith_static_learner.h @@ -20,13 +20,12 @@ #ifndef __CVC4__THEORY__ARITH__ARITH_STATIC_LEARNER_H #define __CVC4__THEORY__ARITH__ARITH_STATIC_LEARNER_H +#include <set> -#include "util/statistics_registry.h" -#include "theory/arith/arith_utilities.h" - -#include "context/context.h" #include "context/cdtrail_hashmap.h" -#include <set> +#include "context/context.h" +#include "expr/statistics_registry.h" +#include "theory/arith/arith_utilities.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/arith_utilities.h b/src/theory/arith/arith_utilities.h index 9d32916cc..ffa896012 100644 --- a/src/theory/arith/arith_utilities.h +++ b/src/theory/arith/arith_utilities.h @@ -19,16 +19,17 @@ #ifndef __CVC4__THEORY__ARITH__ARITH_UTILITIES_H #define __CVC4__THEORY__ARITH__ARITH_UTILITIES_H -#include "util/rational.h" -#include "util/integer.h" -#include "util/dense_map.h" -#include "expr/node.h" -#include "theory/arith/delta_rational.h" -#include "theory/arith/arithvar.h" -#include "context/cdhashset.h" #include <ext/hash_map> #include <vector> +#include "context/cdhashset.h" +#include "expr/node.h" +#include "theory/arith/arithvar.h" +#include "theory/arith/delta_rational.h" +#include "util/dense_map.h" +#include "util/integer.h" +#include "util/rational.h" + namespace CVC4 { namespace theory { namespace arith { diff --git a/src/theory/arith/arithvar.h b/src/theory/arith/arithvar.h index dd049e94f..9e4dab4c3 100644 --- a/src/theory/arith/arithvar.h +++ b/src/theory/arith/arithvar.h @@ -22,10 +22,10 @@ #pragma once #include <vector> + #include "util/index.h" #include "util/rational.h" - namespace CVC4 { namespace theory { namespace arith { @@ -43,4 +43,3 @@ extern bool debugIsASet(const ArithVarVec& variables); }/* CVC4::theory::arith namespace */ }/* CVC4::theory namespace */ }/* CVC4 namespace */ - diff --git a/src/theory/arith/attempt_solution_simplex.cpp b/src/theory/arith/attempt_solution_simplex.cpp index 5b92a8809..737cc9e7b 100644 --- a/src/theory/arith/attempt_solution_simplex.cpp +++ b/src/theory/arith/attempt_solution_simplex.cpp @@ -15,9 +15,9 @@ ** \todo document this file **/ - +#include "base/output.h" +#include "options/arith_options.h" #include "theory/arith/attempt_solution_simplex.h" -#include "theory/arith/options.h" #include "theory/arith/constraint.h" using namespace std; diff --git a/src/theory/arith/attempt_solution_simplex.h b/src/theory/arith/attempt_solution_simplex.h index 4d94169c9..88d29f6b0 100644 --- a/src/theory/arith/attempt_solution_simplex.h +++ b/src/theory/arith/attempt_solution_simplex.h @@ -53,7 +53,7 @@ #pragma once -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" #include "theory/arith/simplex.h" #include "theory/arith/approx_simplex.h" diff --git a/src/theory/arith/bound_counts.h b/src/theory/arith/bound_counts.h index c1f0ce545..b5e0124c1 100644 --- a/src/theory/arith/bound_counts.h +++ b/src/theory/arith/bound_counts.h @@ -19,8 +19,9 @@ #pragma once #include <stdint.h> + +#include "base/cvc4_assert.h" #include "theory/arith/arithvar.h" -#include "util/cvc4_assert.h" #include "util/dense_map.h" namespace CVC4 { diff --git a/src/theory/arith/callbacks.h b/src/theory/arith/callbacks.h index 734c605c6..d180ceab5 100644 --- a/src/theory/arith/callbacks.h +++ b/src/theory/arith/callbacks.h @@ -19,12 +19,11 @@ #pragma once #include "expr/node.h" -#include "util/rational.h" - -#include "theory/arith/theory_arith_private_forward.h" #include "theory/arith/arithvar.h" #include "theory/arith/bound_counts.h" #include "theory/arith/constraint_forward.h" +#include "theory/arith/theory_arith_private_forward.h" +#include "util/rational.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/congruence_manager.cpp b/src/theory/arith/congruence_manager.cpp index 8a145ffc2..964c92eb5 100644 --- a/src/theory/arith/congruence_manager.cpp +++ b/src/theory/arith/congruence_manager.cpp @@ -14,10 +14,10 @@ ** \todo document this file **/ +#include "base/output.h" +#include "theory/arith/arith_utilities.h" #include "theory/arith/congruence_manager.h" - #include "theory/arith/constraint.h" -#include "theory/arith/arith_utilities.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/congruence_manager.h b/src/theory/arith/congruence_manager.h index 7ecfd21cf..2fc9c47ed 100644 --- a/src/theory/arith/congruence_manager.h +++ b/src/theory/arith/congruence_manager.h @@ -19,19 +19,16 @@ #pragma once +#include "context/cdlist.h" +#include "context/cdmaybe.h" +#include "context/cdo.h" +#include "context/cdtrail_queue.h" +#include "context/context.h" +#include "expr/statistics_registry.h" #include "theory/arith/arithvar.h" #include "theory/arith/constraint_forward.h" #include "theory/arith/partial_model.h" - #include "theory/uf/equality_engine.h" - -#include "context/cdo.h" -#include "context/cdlist.h" -#include "context/context.h" -#include "context/cdtrail_queue.h" -#include "context/cdmaybe.h" - -#include "util/statistics_registry.h" #include "util/dense_map.h" namespace CVC4 { diff --git a/src/theory/arith/constraint.cpp b/src/theory/arith/constraint.cpp index 4acf86d43..f13565a7f 100644 --- a/src/theory/arith/constraint.cpp +++ b/src/theory/arith/constraint.cpp @@ -15,15 +15,15 @@ ** \todo document this file **/ -#include "cvc4_private.h" -#include "theory/arith/constraint.h" -#include "theory/arith/arith_utilities.h" -#include "theory/arith/normal_form.h" +#include <ostream> +#include <algorithm> +#include "base/output.h" #include "proof/proof.h" +#include "theory/arith/arith_utilities.h" +#include "theory/arith/constraint.h" +#include "theory/arith/normal_form.h" -#include <ostream> -#include <algorithm> using namespace std; using namespace CVC4::kind; diff --git a/src/theory/arith/cut_log.cpp b/src/theory/arith/cut_log.cpp index d855caee8..d94e1c760 100644 --- a/src/theory/arith/cut_log.cpp +++ b/src/theory/arith/cut_log.cpp @@ -15,17 +15,17 @@ ** \todo document this file **/ -#include "cvc4autoconfig.h" - +#include <cmath> +#include <limits.h> +#include <map> +#include <math.h> -#include "theory/arith/cut_log.h" +#include "base/output.h" +#include "cvc4autoconfig.h" #include "theory/arith/approx_simplex.h" -#include "theory/arith/normal_form.h" #include "theory/arith/constraint.h" -#include <math.h> -#include <cmath> -#include <map> -#include <limits.h> +#include "theory/arith/cut_log.h" +#include "theory/arith/normal_form.h" using namespace std; diff --git a/src/theory/arith/cut_log.h b/src/theory/arith/cut_log.h index 9ce017488..bbed13418 100644 --- a/src/theory/arith/cut_log.h +++ b/src/theory/arith/cut_log.h @@ -20,15 +20,16 @@ #pragma once +#include <ext/hash_map> +#include <map> +#include <set> +#include <vector> + #include "expr/kind.h" -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" #include "theory/arith/arithvar.h" #include "theory/arith/constraint_forward.h" #include "util/dense_map.h" -#include <vector> -#include <map> -#include <set> -#include <ext/hash_map> namespace CVC4 { namespace theory { diff --git a/src/theory/arith/delta_rational.h b/src/theory/arith/delta_rational.h index a9d919c21..5f67847d8 100644 --- a/src/theory/arith/delta_rational.h +++ b/src/theory/arith/delta_rational.h @@ -17,14 +17,13 @@ #include "cvc4_private.h" -#include "util/integer.h" -#include "util/rational.h" -#include "util/exception.h" - +#pragma once #include <ostream> -#pragma once +#include "base/exception.h" +#include "util/integer.h" +#include "util/rational.h" namespace CVC4 { diff --git a/src/theory/arith/dio_solver.cpp b/src/theory/arith/dio_solver.cpp index 7e50dad87..f8b8e0e7b 100644 --- a/src/theory/arith/dio_solver.cpp +++ b/src/theory/arith/dio_solver.cpp @@ -14,11 +14,12 @@ ** A Diophantine equation solver for the theory of arithmetic. **/ -#include "theory/arith/dio_solver.h" -#include "theory/arith/options.h" - #include <iostream> +#include "base/output.h" +#include "options/arith_options.h" +#include "theory/arith/dio_solver.h" + using namespace std; namespace CVC4 { diff --git a/src/theory/arith/dio_solver.h b/src/theory/arith/dio_solver.h index 9b96acf48..626160b03 100644 --- a/src/theory/arith/dio_solver.h +++ b/src/theory/arith/dio_solver.h @@ -16,22 +16,22 @@ #include "cvc4_private.h" + #ifndef __CVC4__THEORY__ARITH__DIO_SOLVER_H #define __CVC4__THEORY__ARITH__DIO_SOLVER_H -#include "context/context.h" -#include "context/cdo.h" +#include <utility> +#include <vector> + +#include "base/output.h" #include "context/cdlist.h" +#include "context/cdo.h" #include "context/cdqueue.h" - +#include "context/context.h" +#include "expr/statistics_registry.h" +#include "theory/arith/normal_form.h" #include "theory/arith/partial_model.h" #include "util/rational.h" -#include "theory/arith/normal_form.h" - -#include "util/statistics_registry.h" - -#include <vector> -#include <utility> namespace CVC4 { namespace theory { diff --git a/src/theory/arith/dual_simplex.cpp b/src/theory/arith/dual_simplex.cpp index 234b33e97..32f81ded8 100644 --- a/src/theory/arith/dual_simplex.cpp +++ b/src/theory/arith/dual_simplex.cpp @@ -15,10 +15,10 @@ ** \todo document this file **/ - -#include "theory/arith/dual_simplex.h" -#include "theory/arith/options.h" +#include "base/output.h" +#include "options/arith_options.h" #include "theory/arith/constraint.h" +#include "theory/arith/dual_simplex.h" using namespace std; diff --git a/src/theory/arith/dual_simplex.h b/src/theory/arith/dual_simplex.h index 53f627081..d6bf57bb0 100644 --- a/src/theory/arith/dual_simplex.h +++ b/src/theory/arith/dual_simplex.h @@ -48,12 +48,11 @@ ** These are theory valid and are currently turned into lemmas **/ - #include "cvc4_private.h" #pragma once -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" #include "theory/arith/simplex.h" namespace CVC4 { diff --git a/src/theory/arith/error_set.h b/src/theory/arith/error_set.h index 5843e0f7b..f12e38c12 100644 --- a/src/theory/arith/error_set.h +++ b/src/theory/arith/error_set.h @@ -20,36 +20,18 @@ #pragma once +#include <vector> + +#include "expr/statistics_registry.h" +#include "options/arith_heuristic_pivot_rule.h" #include "theory/arith/arithvar.h" #include "theory/arith/bound_counts.h" +#include "theory/arith/callbacks.h" #include "theory/arith/delta_rational.h" #include "theory/arith/partial_model.h" -#include "theory/arith/arith_heuristic_pivot_rule.h" #include "theory/arith/tableau_sizes.h" -#include "theory/arith/callbacks.h" - -#include "util/statistics_registry.h" #include "util/bin_heap.h" -// #if CVC4_GCC_HAS_PB_DS_BUG -// // Unfortunate bug in some older GCCs (e.g., v4.2): -// // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36612 -// // Requires some header-hacking to work around -// # define __throw_container_error inline __throw_container_error -// # define __throw_insert_error inline __throw_insert_error -// # define __throw_join_error inline __throw_join_error -// # define __throw_resize_error inline __throw_resize_error -// # include <ext/pb_ds/exception.hpp> -// # undef __throw_container_error -// # undef __throw_insert_error -// # undef __throw_join_error -// # undef __throw_resize_error -// #endif /* CVC4_GCC_HAS_PB_DS_BUG */ - -// #include <ext/pb_ds/priority_queue.hpp> - -#include <vector> - namespace CVC4 { namespace theory { namespace arith { diff --git a/src/theory/arith/fc_simplex.cpp b/src/theory/arith/fc_simplex.cpp index d21bb8f8b..229dc379c 100644 --- a/src/theory/arith/fc_simplex.cpp +++ b/src/theory/arith/fc_simplex.cpp @@ -14,13 +14,12 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ - - #include "theory/arith/fc_simplex.h" -#include "theory/arith/options.h" -#include "theory/arith/constraint.h" -#include "util/statistics_registry.h" +#include "base/output.h" +#include "expr/statistics_registry.h" +#include "options/arith_options.h" +#include "theory/arith/constraint.h" using namespace std; diff --git a/src/theory/arith/fc_simplex.h b/src/theory/arith/fc_simplex.h index b6c0c4f62..471804003 100644 --- a/src/theory/arith/fc_simplex.h +++ b/src/theory/arith/fc_simplex.h @@ -52,10 +52,11 @@ #pragma once +#include <stdint.h> + +#include "expr/statistics_registry.h" #include "theory/arith/simplex.h" #include "util/dense_map.h" -#include "util/statistics_registry.h" -#include <stdint.h> namespace CVC4 { namespace theory { diff --git a/src/theory/arith/infer_bounds.h b/src/theory/arith/infer_bounds.h index 55486080a..770d9d1b3 100644 --- a/src/theory/arith/infer_bounds.h +++ b/src/theory/arith/infer_bounds.h @@ -19,13 +19,15 @@ #pragma once -#include "util/maybe.h" -#include "util/integer.h" -#include "util/rational.h" +#include <ostream> + #include "expr/node.h" #include "theory/arith/delta_rational.h" #include "theory/theory.h" -#include <ostream> +#include "util/integer.h" +#include "util/maybe.h" +#include "util/rational.h" + namespace CVC4 { namespace theory { diff --git a/src/theory/arith/linear_equality.cpp b/src/theory/arith/linear_equality.cpp index bd252bf49..d8888bd75 100644 --- a/src/theory/arith/linear_equality.cpp +++ b/src/theory/arith/linear_equality.cpp @@ -15,8 +15,9 @@ **/ -#include "theory/arith/linear_equality.h" +#include "base/output.h" #include "theory/arith/constraint.h" +#include "theory/arith/linear_equality.h" using namespace std; diff --git a/src/theory/arith/linear_equality.h b/src/theory/arith/linear_equality.h index 99ec6e52c..d7c9c038c 100644 --- a/src/theory/arith/linear_equality.h +++ b/src/theory/arith/linear_equality.h @@ -29,16 +29,15 @@ #pragma once -#include "theory/arith/delta_rational.h" +#include "expr/statistics_registry.h" +#include "options/arith_options.h" #include "theory/arith/arithvar.h" -#include "theory/arith/partial_model.h" -#include "theory/arith/tableau.h" #include "theory/arith/constraint_forward.h" +#include "theory/arith/delta_rational.h" +#include "theory/arith/partial_model.h" #include "theory/arith/simplex_update.h" -#include "theory/arith/options.h" - +#include "theory/arith/tableau.h" #include "util/maybe.h" -#include "util/statistics_registry.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/matrix.h b/src/theory/arith/matrix.h index 6c218eb0b..647df886f 100644 --- a/src/theory/arith/matrix.h +++ b/src/theory/arith/matrix.h @@ -19,13 +19,14 @@ #pragma once -#include "util/index.h" -#include "util/dense_map.h" -#include "theory/arith/arithvar.h" - #include <queue> -#include <vector> #include <utility> +#include <vector> + +#include "base/output.h" +#include "theory/arith/arithvar.h" +#include "util/dense_map.h" +#include "util/index.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/normal_form.cpp b/src/theory/arith/normal_form.cpp index fda34960a..e22a5e2e3 100644 --- a/src/theory/arith/normal_form.cpp +++ b/src/theory/arith/normal_form.cpp @@ -15,9 +15,11 @@ ** \todo document this file **/ +#include <list> + +#include "base/output.h" #include "theory/arith/normal_form.h" #include "theory/arith/arith_utilities.h" -#include <list> #include "theory/theory.h" using namespace std; diff --git a/src/theory/arith/normal_form.h b/src/theory/arith/normal_form.h index 97813338f..eeb56f597 100644 --- a/src/theory/arith/normal_form.h +++ b/src/theory/arith/normal_form.h @@ -20,19 +20,20 @@ #ifndef __CVC4__THEORY__ARITH__NORMAL_FORM_H #define __CVC4__THEORY__ARITH__NORMAL_FORM_H -#include "expr/node.h" -#include "expr/node_self_iterator.h" -#include "util/rational.h" -#include "theory/arith/delta_rational.h" -//#include "theory/arith/arith_utilities.h" - -#include <list> #include <algorithm> +#include <list> #if IS_SORTED_IN_GNUCXX_NAMESPACE # include <ext/algorithm> #endif /* IS_SORTED_IN_GNUCXX_NAMESPACE */ +#include "base/output.h" +#include "expr/node.h" +#include "expr/node_self_iterator.h" +#include "theory/arith/delta_rational.h" +#include "util/rational.h" + + namespace CVC4 { namespace theory { namespace arith { diff --git a/src/theory/arith/options_handlers.h b/src/theory/arith/options_handlers.h deleted file mode 100644 index 57b9661ba..000000000 --- a/src/theory/arith/options_handlers.h +++ /dev/null @@ -1,122 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: none - ** Minor contributors (to current version): Kshitij Bansal, Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Custom handlers and predicates for arithmetic options - ** - ** Custom handlers and predicates for arithmetic options. - **/ - -#include "cvc4_private.h" - -#ifndef __CVC4__THEORY__ARITH__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__ARITH__OPTIONS_HANDLERS_H - -#include <string> - -namespace CVC4 { -namespace theory { -namespace arith { - -static const std::string 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\ -"; - -static const std::string propagationModeHelp = "\ -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\ -"; - -static const std::string 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\ -"; - -inline ArithUnateLemmaMode stringToArithUnateLemmaMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - 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(arithUnateLemmasHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --unate-lemmas: `") + - optarg + "'. Try --unate-lemmas help."); - } -} - -inline ArithPropagationMode stringToArithPropagationMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - 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(propagationModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --arith-prop: `") + - optarg + "'. Try --arith-prop help."); - } -} - -inline ErrorSelectionRule stringToErrorSelectionRule(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - 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(errorSelectionRulesHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --heuristic-pivot-rule: `") + - optarg + "'. Try --heuristic-pivot-rule help."); - } -} - -}/* CVC4::theory::arith namespace */ -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__THEORY__ARITH__OPTIONS_HANDLERS_H */ diff --git a/src/theory/arith/partial_model.cpp b/src/theory/arith/partial_model.cpp index cb853953f..0124ee0f9 100644 --- a/src/theory/arith/partial_model.cpp +++ b/src/theory/arith/partial_model.cpp @@ -15,11 +15,10 @@ ** \todo document this file **/ - -#include "theory/arith/partial_model.h" -#include "util/output.h" +#include "base/output.h" #include "theory/arith/constraint.h" #include "theory/arith/normal_form.h" +#include "theory/arith/partial_model.h" using namespace std; diff --git a/src/theory/arith/pseudoboolean_proc.cpp b/src/theory/arith/pseudoboolean_proc.cpp index 829952c5e..c09b0180a 100644 --- a/src/theory/arith/pseudoboolean_proc.cpp +++ b/src/theory/arith/pseudoboolean_proc.cpp @@ -15,9 +15,10 @@ ** \todo document this file **/ -#include "theory/arith/pseudoboolean_proc.h" -#include "theory/arith/normal_form.h" +#include "base/output.h" #include "theory/arith/arith_utilities.h" +#include "theory/arith/normal_form.h" +#include "theory/arith/pseudoboolean_proc.h" #include "theory/rewriter.h" namespace CVC4 { diff --git a/src/theory/arith/pseudoboolean_proc.h b/src/theory/arith/pseudoboolean_proc.h index 665f1aa06..d1e10f695 100644 --- a/src/theory/arith/pseudoboolean_proc.h +++ b/src/theory/arith/pseudoboolean_proc.h @@ -19,17 +19,16 @@ #pragma once +#include <ext/hash_set> #include <vector> -#include "util/rational.h" -#include "util/maybe.h" -#include "expr/node.h" -#include "context/context.h" -#include "context/cdo.h" #include "context/cdhashmap.h" - +#include "context/cdo.h" +#include "context/context.h" +#include "expr/node.h" #include "theory/substitutions.h" -#include <ext/hash_set> +#include "util/maybe.h" +#include "util/rational.h" namespace CVC4 { namespace theory { @@ -107,4 +106,3 @@ private: }/* CVC4::theory::arith namespace */ }/* CVC4::theory namespace */ }/* CVC4 namespace */ - diff --git a/src/theory/arith/simplex.cpp b/src/theory/arith/simplex.cpp index 49664e0ea..24c6ce432 100644 --- a/src/theory/arith/simplex.cpp +++ b/src/theory/arith/simplex.cpp @@ -16,9 +16,10 @@ **/ -#include "theory/arith/simplex.h" -#include "theory/arith/options.h" +#include "base/output.h" +#include "options/arith_options.h" #include "theory/arith/constraint.h" +#include "theory/arith/simplex.h" using namespace std; diff --git a/src/theory/arith/simplex.h b/src/theory/arith/simplex.h index 2d7fc597a..f39006788 100644 --- a/src/theory/arith/simplex.h +++ b/src/theory/arith/simplex.h @@ -53,15 +53,14 @@ #pragma once +#include "expr/result.h" #include "theory/arith/arithvar.h" -#include "theory/arith/error_set.h" #include "theory/arith/delta_rational.h" -#include "theory/arith/tableau.h" -#include "theory/arith/partial_model.h" +#include "theory/arith/error_set.h" #include "theory/arith/linear_equality.h" - +#include "theory/arith/partial_model.h" +#include "theory/arith/tableau.h" #include "util/dense_map.h" -#include "util/result.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/soi_simplex.cpp b/src/theory/arith/soi_simplex.cpp index 0d07c5ffc..765e6a00d 100644 --- a/src/theory/arith/soi_simplex.cpp +++ b/src/theory/arith/soi_simplex.cpp @@ -14,15 +14,15 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ +#include "theory/arith/soi_simplex.h" +#include <algorithm> -#include "theory/arith/soi_simplex.h" -#include "theory/arith/options.h" +#include "base/output.h" +#include "expr/statistics_registry.h" +#include "options/arith_options.h" #include "theory/arith/constraint.h" -#include "util/statistics_registry.h" - -#include <algorithm> using namespace std; diff --git a/src/theory/arith/soi_simplex.h b/src/theory/arith/soi_simplex.h index 6dd6373d4..b08d7794b 100644 --- a/src/theory/arith/soi_simplex.h +++ b/src/theory/arith/soi_simplex.h @@ -52,10 +52,11 @@ #pragma once +#include <stdint.h> + +#include "expr/statistics_registry.h" #include "theory/arith/simplex.h" #include "util/dense_map.h" -#include "util/statistics_registry.h" -#include <stdint.h> namespace CVC4 { namespace theory { diff --git a/src/theory/arith/tableau.cpp b/src/theory/arith/tableau.cpp index 231eb1562..744dda6b7 100644 --- a/src/theory/arith/tableau.cpp +++ b/src/theory/arith/tableau.cpp @@ -15,6 +15,7 @@ ** \todo document this file **/ +#include "base/output.h" #include "theory/arith/tableau.h" using namespace std; diff --git a/src/theory/arith/tableau.h b/src/theory/arith/tableau.h index c6750f61b..77187c798 100644 --- a/src/theory/arith/tableau.h +++ b/src/theory/arith/tableau.h @@ -19,11 +19,12 @@ #pragma once -#include "util/dense_map.h" -#include "util/rational.h" +#include <vector> + #include "theory/arith/arithvar.h" #include "theory/arith/matrix.h" -#include <vector> +#include "util/dense_map.h" +#include "util/rational.h" namespace CVC4 { namespace theory { @@ -161,4 +162,3 @@ private: }/* CVC4::theory::arith namespace */ }/* CVC4::theory namespace */ }/* CVC4 namespace */ - diff --git a/src/theory/arith/tableau_sizes.cpp b/src/theory/arith/tableau_sizes.cpp index fdd9ff16a..64bae22fe 100644 --- a/src/theory/arith/tableau_sizes.cpp +++ b/src/theory/arith/tableau_sizes.cpp @@ -15,6 +15,7 @@ ** \todo document this file **/ +#include "base/output.h" #include "theory/arith/tableau_sizes.h" #include "theory/arith/tableau.h" diff --git a/src/theory/arith/theory_arith.cpp b/src/theory/arith/theory_arith.cpp index 565c69514..1e3b21b17 100644 --- a/src/theory/arith/theory_arith.cpp +++ b/src/theory/arith/theory_arith.cpp @@ -16,9 +16,10 @@ **/ #include "theory/arith/theory_arith.h" -#include "theory/arith/theory_arith_private.h" + +#include "options/smt_options.h" #include "theory/arith/infer_bounds.h" -#include "smt/options.h" +#include "theory/arith/theory_arith_private.h" using namespace std; using namespace CVC4::kind; diff --git a/src/theory/arith/theory_arith_private.cpp b/src/theory/arith/theory_arith_private.cpp index c9c45af2f..ab800f10d 100644 --- a/src/theory/arith/theory_arith_private.cpp +++ b/src/theory/arith/theory_arith_private.cpp @@ -17,71 +17,59 @@ #include "theory/arith/theory_arith_private.h" -#include "expr/node.h" -#include "expr/kind.h" -#include "expr/metakind.h" -#include "expr/node_builder.h" +#include <stdint.h> -#include "context/context.h" -#include "context/cdlist.h" +#include <map> +#include <queue> +#include <vector> + +#include "base/output.h" #include "context/cdhashset.h" #include "context/cdinsert_hashmap.h" +#include "context/cdlist.h" #include "context/cdqueue.h" - -#include "theory/valuation.h" -#include "theory/rewriter.h" - -#include "util/rational.h" -#include "util/integer.h" -#include "util/boolean_simplification.h" -#include "util/dense_map.h" -#include "util/statistics_registry.h" -#include "util/result.h" - -#include "smt/logic_request.h" +#include "context/context.h" +#include "expr/kind.h" +#include "expr/metakind.h" +#include "expr/node.h" +#include "expr/node_builder.h" +#include "expr/result.h" +#include "expr/statistics_registry.h" +#include "options/arith_options.h" +#include "options/smt_options.h" // for incrementalSolving() #include "smt/logic_exception.h" -#include "smt/options.h" // for incrementalSolving() - -#include "theory/arith/arithvar.h" -#include "theory/arith/cut_log.h" -#include "theory/arith/delta_rational.h" -#include "theory/arith/matrix.h" +#include "smt/logic_request.h" +#include "smt_util/boolean_simplification.h" +#include "theory/arith/approx_simplex.h" +#include "theory/arith/arith_ite_utils.h" +#include "theory/arith/arith_rewriter.h" #include "theory/arith/arith_rewriter.h" -#include "theory/arith/partial_model.h" -#include "theory/arith/linear_equality.h" -#include "theory/arith/simplex.h" #include "theory/arith/arith_static_learner.h" -#include "theory/arith/dio_solver.h" +#include "theory/arith/arith_utilities.h" +#include "theory/arith/arithvar.h" #include "theory/arith/congruence_manager.h" - -#include "theory/arith/approx_simplex.h" #include "theory/arith/constraint.h" - -#include "theory/ite_utilities.h" -#include "theory/arith/arith_ite_utils.h" - -#include "theory/arith/arith_utilities.h" +#include "theory/arith/constraint.h" +#include "theory/arith/cut_log.h" #include "theory/arith/delta_rational.h" -#include "theory/arith/partial_model.h" +#include "theory/arith/delta_rational.h" +#include "theory/arith/dio_solver.h" +#include "theory/arith/linear_equality.h" +#include "theory/arith/matrix.h" #include "theory/arith/matrix.h" - -#include "theory/arith/arith_rewriter.h" -#include "theory/arith/constraint.h" -#include "theory/arith/theory_arith.h" #include "theory/arith/normal_form.h" -#include "theory/theory_model.h" - -#include "theory/arith/options.h" -#include "theory/quantifiers/options.h" - - +#include "theory/arith/partial_model.h" +#include "theory/arith/partial_model.h" +#include "theory/arith/simplex.h" +#include "theory/arith/theory_arith.h" +#include "theory/ite_utilities.h" #include "theory/quantifiers/bounded_integers.h" - -#include <stdint.h> - -#include <vector> -#include <map> -#include <queue> +#include "theory/rewriter.h" +#include "theory/theory_model.h" +#include "theory/valuation.h" +#include "util/dense_map.h" +#include "util/integer.h" +#include "util/rational.h" using namespace std; using namespace CVC4::kind; diff --git a/src/theory/arith/theory_arith_private.h b/src/theory/arith/theory_arith_private.h index 4c539c60d..0c2a704e8 100644 --- a/src/theory/arith/theory_arith_private.h +++ b/src/theory/arith/theory_arith_private.h @@ -17,70 +17,56 @@ #pragma once -#include "theory/arith/theory_arith_private_forward.h" - -#include "expr/node.h" -#include "expr/kind.h" -#include "expr/metakind.h" -#include "expr/node_builder.h" +#include <map> +#include <queue> +#include <stdint.h> +#include <vector> -#include "context/context.h" -#include "context/cdlist.h" #include "context/cdhashset.h" #include "context/cdinsert_hashmap.h" +#include "context/cdlist.h" #include "context/cdqueue.h" - -#include "theory/valuation.h" -#include "theory/rewriter.h" - -#include "util/rational.h" -#include "util/integer.h" -#include "util/boolean_simplification.h" -#include "util/dense_map.h" -#include "util/statistics_registry.h" -#include "util/result.h" - +#include "context/context.h" +#include "expr/kind.h" +#include "expr/metakind.h" +#include "expr/node.h" +#include "expr/node_builder.h" +#include "expr/result.h" +#include "expr/statistics_registry.h" +#include "options/arith_options.h" #include "smt/logic_exception.h" - - - -#include "theory/arith/arithvar.h" -#include "theory/arith/delta_rational.h" -#include "theory/arith/matrix.h" +#include "smt_util/boolean_simplification.h" +#include "theory/arith/arith_rewriter.h" #include "theory/arith/arith_rewriter.h" -#include "theory/arith/partial_model.h" -#include "theory/arith/linear_equality.h" #include "theory/arith/arith_static_learner.h" -#include "theory/arith/dio_solver.h" -#include "theory/arith/congruence_manager.h" - -#include "theory/arith/simplex.h" -#include "theory/arith/dual_simplex.h" -#include "theory/arith/fc_simplex.h" -#include "theory/arith/soi_simplex.h" +#include "theory/arith/arith_utilities.h" +#include "theory/arith/arithvar.h" #include "theory/arith/attempt_solution_simplex.h" - +#include "theory/arith/congruence_manager.h" +#include "theory/arith/constraint.h" #include "theory/arith/constraint.h" - -#include "theory/arith/arith_utilities.h" #include "theory/arith/delta_rational.h" +#include "theory/arith/delta_rational.h" +#include "theory/arith/dio_solver.h" +#include "theory/arith/dual_simplex.h" +#include "theory/arith/fc_simplex.h" #include "theory/arith/infer_bounds.h" -#include "theory/arith/partial_model.h" +#include "theory/arith/linear_equality.h" +#include "theory/arith/matrix.h" #include "theory/arith/matrix.h" - -#include "theory/arith/arith_rewriter.h" -#include "theory/arith/constraint.h" -#include "theory/arith/theory_arith.h" #include "theory/arith/normal_form.h" +#include "theory/arith/partial_model.h" +#include "theory/arith/partial_model.h" +#include "theory/arith/simplex.h" +#include "theory/arith/soi_simplex.h" +#include "theory/arith/theory_arith.h" +#include "theory/arith/theory_arith_private_forward.h" +#include "theory/rewriter.h" #include "theory/theory_model.h" - -#include "theory/arith/options.h" - -#include <stdint.h> - -#include <vector> -#include <map> -#include <queue> +#include "theory/valuation.h" +#include "util/dense_map.h" +#include "util/integer.h" +#include "util/rational.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arith/type_enumerator.h b/src/theory/arith/type_enumerator.h index f661e18d3..c4501fc43 100644 --- a/src/theory/arith/type_enumerator.h +++ b/src/theory/arith/type_enumerator.h @@ -19,11 +19,11 @@ #ifndef __CVC4__THEORY__ARITH__TYPE_ENUMERATOR_H #define __CVC4__THEORY__ARITH__TYPE_ENUMERATOR_H +#include "expr/kind.h" +#include "expr/type_node.h" +#include "theory/type_enumerator.h" #include "util/integer.h" #include "util/rational.h" -#include "theory/type_enumerator.h" -#include "expr/type_node.h" -#include "expr/kind.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arrays/array_info.h b/src/theory/arrays/array_info.h index f3c6385e5..d9f77d50f 100644 --- a/src/theory/arrays/array_info.h +++ b/src/theory/arrays/array_info.h @@ -18,17 +18,18 @@ #ifndef __CVC4__THEORY__ARRAYS__ARRAY_INFO_H #define __CVC4__THEORY__ARRAYS__ARRAY_INFO_H -#include "util/backtrackable.h" -#include "context/cdlist.h" -#include "context/cdhashmap.h" -#include "expr/node.h" -#include "util/statistics_registry.h" -#include "util/ntuple.h" #include <ext/hash_set> #include <ext/hash_map> #include <iostream> #include <map> +#include "context/backtrackable.h" +#include "context/cdlist.h" +#include "context/cdhashmap.h" +#include "expr/node.h" +#include "expr/statistics_registry.h" +#include "util/ntuple.h" + namespace CVC4 { namespace theory { namespace arrays { diff --git a/src/theory/arrays/kinds b/src/theory/arrays/kinds index c18492a58..d5f313ca1 100644 --- a/src/theory/arrays/kinds +++ b/src/theory/arrays/kinds @@ -35,7 +35,7 @@ operator STORE 3 "array store; first parameter is an array term, second is the s constant STORE_ALL \ ::CVC4::ArrayStoreAll \ ::CVC4::ArrayStoreAllHashFunction \ - "util/array_store_all.h" \ + "expr/array_store_all.h" \ "array store-all; payload is an instance of the CVC4::ArrayStoreAll class (this is not supported by arrays decision procedure yet, but it is used for returned array models)" # used internally by array theory diff --git a/src/theory/arrays/static_fact_manager.cpp b/src/theory/arrays/static_fact_manager.cpp index 1743e3b30..0d04ce097 100644 --- a/src/theory/arrays/static_fact_manager.cpp +++ b/src/theory/arrays/static_fact_manager.cpp @@ -18,9 +18,9 @@ #include <iostream> -#include "theory/arrays/static_fact_manager.h" -#include "util/cvc4_assert.h" +#include "base/cvc4_assert.h" #include "expr/node.h" +#include "theory/arrays/static_fact_manager.h" using namespace std; diff --git a/src/theory/arrays/theory_arrays.cpp b/src/theory/arrays/theory_arrays.cpp index d872ab42c..5af7f02db 100644 --- a/src/theory/arrays/theory_arrays.cpp +++ b/src/theory/arrays/theory_arrays.cpp @@ -14,17 +14,18 @@ ** Implementation of the theory of arrays. **/ - #include "theory/arrays/theory_arrays.h" -#include "theory/valuation.h" -#include "expr/kind.h" + #include <map> + +#include "expr/kind.h" +#include "options/arrays_options.h" +#include "options/smt_options.h" +#include "smt/logic_exception.h" +#include "smt_util/command.h" #include "theory/rewriter.h" -#include "expr/command.h" #include "theory/theory_model.h" -#include "theory/arrays/options.h" -#include "smt/options.h" -#include "smt/logic_exception.h" +#include "theory/valuation.h" using namespace std; diff --git a/src/theory/arrays/theory_arrays.h b/src/theory/arrays/theory_arrays.h index b2e039912..717c654d2 100644 --- a/src/theory/arrays/theory_arrays.h +++ b/src/theory/arrays/theory_arrays.h @@ -19,13 +19,13 @@ #ifndef __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_H #define __CVC4__THEORY__ARRAYS__THEORY_ARRAYS_H -#include "theory/theory.h" -#include "theory/arrays/array_info.h" -#include "util/statistics_registry.h" -#include "theory/uf/equality_engine.h" #include "context/cdhashmap.h" #include "context/cdhashset.h" #include "context/cdqueue.h" +#include "expr/statistics_registry.h" +#include "theory/arrays/array_info.h" +#include "theory/theory.h" +#include "theory/uf/equality_engine.h" namespace CVC4 { namespace theory { diff --git a/src/theory/arrays/union_find.cpp b/src/theory/arrays/union_find.cpp index 9e6978c92..3f71b350e 100644 --- a/src/theory/arrays/union_find.cpp +++ b/src/theory/arrays/union_find.cpp @@ -18,9 +18,9 @@ #include <iostream> -#include "theory/arrays/union_find.h" -#include "util/cvc4_assert.h" +#include "base/cvc4_assert.h" #include "expr/node.h" +#include "theory/arrays/union_find.h" using namespace std; diff --git a/src/theory/booleans/options_handlers.h b/src/theory/booleans/options_handlers.h deleted file mode 100644 index 8cad689eb..000000000 --- a/src/theory/booleans/options_handlers.h +++ /dev/null @@ -1,65 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: none - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** 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__THEORY__BOOLEANS__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__BOOLEANS__OPTIONS_HANDLERS_H - -#include <string> - -namespace CVC4 { -namespace theory { -namespace booleans { - -static const std::string booleanTermConversionModeHelp = "\ -Boolean term conversion modes currently supported by the\n\ ---boolean-term-conversion-mode option:\n\ -\n\ -bitvectors [default]\n\ -+ Boolean terms are converted to bitvectors of size 1.\n\ -\n\ -datatypes\n\ -+ Boolean terms are converted to enumerations in the Datatype theory.\n\ -\n\ -native\n\ -+ Boolean terms are converted in a \"natural\" way depending on where they\n\ - are used. If in a datatype context, they are converted to an enumeration.\n\ - Elsewhere, they are converted to a bitvector of size 1.\n\ -"; - -inline BooleanTermConversionMode stringToBooleanTermConversionMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "bitvectors") { - return BOOLEAN_TERM_CONVERT_TO_BITVECTORS; - } else if(optarg == "datatypes") { - return BOOLEAN_TERM_CONVERT_TO_DATATYPES; - } else if(optarg == "native") { - return BOOLEAN_TERM_CONVERT_NATIVE; - } else if(optarg == "help") { - puts(booleanTermConversionModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --boolean-term-conversion-mode: `") + - optarg + "'. Try --boolean-term-conversion-mode help."); - } -} - -}/* CVC4::theory::booleans namespace */ -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__THEORY__BOOLEANS__OPTIONS_HANDLERS_H */ diff --git a/src/theory/booleans/theory_bool.cpp b/src/theory/booleans/theory_bool.cpp index 8e1661e28..a286f1605 100644 --- a/src/theory/booleans/theory_bool.cpp +++ b/src/theory/booleans/theory_bool.cpp @@ -18,7 +18,7 @@ #include "theory/booleans/theory_bool.h" #include "theory/booleans/circuit_propagator.h" #include "theory/valuation.h" -#include "util/boolean_simplification.h" +#include "smt_util/boolean_simplification.h" #include "theory/substitutions.h" #include <vector> diff --git a/src/theory/builtin/kinds b/src/theory/builtin/kinds index 44474c18a..c0f955861 100644 --- a/src/theory/builtin/kinds +++ b/src/theory/builtin/kinds @@ -266,7 +266,7 @@ well-founded SORT_TYPE \ constant UNINTERPRETED_CONSTANT \ ::CVC4::UninterpretedConstant \ ::CVC4::UninterpretedConstantHashFunction \ - "util/uninterpreted_constant.h" \ + "expr/uninterpreted_constant.h" \ "the kind of expressions representing uninterpreted constants; payload is an instance of the CVC4::UninterpretedConstant class (used in models)" typerule UNINTERPRETED_CONSTANT ::CVC4::theory::builtin::UninterpretedConstantTypeRule enumerator SORT_TYPE \ @@ -306,7 +306,7 @@ parameterized CHAIN CHAIN_OP 2: "chained operator (N-ary), turned into a conjuct constant CHAIN_OP \ ::CVC4::Chain \ ::CVC4::ChainHashFunction \ - "util/chain.h" \ + "expr/chain.h" \ "the chained operator; payload is an instance of the CVC4::Chain class" constant TYPE_CONSTANT \ @@ -339,7 +339,7 @@ typerule CHAIN_OP ::CVC4::theory::builtin::ChainedOperatorTypeRule constant SUBTYPE_TYPE \ ::CVC4::Predicate \ ::CVC4::PredicateHashFunction \ - "util/predicate.h" \ + "expr/predicate.h" \ "predicate subtype; payload is an instance of the CVC4::Predicate class" cardinality SUBTYPE_TYPE \ "::CVC4::theory::builtin::SubtypeProperties::computeCardinality(%TYPE%)" \ diff --git a/src/theory/builtin/theory_builtin_rewriter.cpp b/src/theory/builtin/theory_builtin_rewriter.cpp index 516d6a06b..e91c7e411 100644 --- a/src/theory/builtin/theory_builtin_rewriter.cpp +++ b/src/theory/builtin/theory_builtin_rewriter.cpp @@ -16,7 +16,8 @@ **/ #include "theory/builtin/theory_builtin_rewriter.h" -#include "util/chain.h" + +#include "expr/chain.h" using namespace std; diff --git a/src/theory/builtin/type_enumerator.h b/src/theory/builtin/type_enumerator.h index c9585c46f..635cf7dc7 100644 --- a/src/theory/builtin/type_enumerator.h +++ b/src/theory/builtin/type_enumerator.h @@ -19,11 +19,11 @@ #ifndef __CVC4__THEORY__BUILTIN__TYPE_ENUMERATOR_H #define __CVC4__THEORY__BUILTIN__TYPE_ENUMERATOR_H -#include "util/integer.h" -#include "util/uninterpreted_constant.h" -#include "theory/type_enumerator.h" -#include "expr/type_node.h" #include "expr/kind.h" +#include "expr/type_node.h" +#include "expr/uninterpreted_constant.h" +#include "theory/type_enumerator.h" +#include "util/integer.h" namespace CVC4 { namespace theory { diff --git a/src/theory/bv/abstraction.cpp b/src/theory/bv/abstraction.cpp index c414ac749..f05520306 100644 --- a/src/theory/bv/abstraction.cpp +++ b/src/theory/bv/abstraction.cpp @@ -12,12 +12,13 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ - #include "theory/bv/abstraction.h" + +#include "options/bv_options.h" +#include "smt_util/dump.h" #include "theory/bv/theory_bv_utils.h" #include "theory/rewriter.h" -#include "theory/bv/options.h" -#include "util/dump.h" + using namespace CVC4; using namespace CVC4::theory; @@ -28,10 +29,10 @@ using namespace std; using namespace CVC4::theory::bv::utils; bool AbstractionModule::applyAbstraction(const std::vector<Node>& assertions, std::vector<Node>& new_assertions) { - Debug("bv-abstraction") << "AbstractionModule::applyAbstraction\n"; + Debug("bv-abstraction") << "AbstractionModule::applyAbstraction\n"; TimerStat::CodeTimer abstractionTimer(d_statistics.d_abstractionTime); - + for (unsigned i = 0; i < assertions.size(); ++i) { if (assertions[i].getKind() == kind::OR) { for (unsigned j = 0; j < assertions[i].getNumChildren(); ++j) { diff --git a/src/theory/bv/abstraction.h b/src/theory/bv/abstraction.h index 2e86c834d..6b4d5a7dc 100644 --- a/src/theory/bv/abstraction.h +++ b/src/theory/bv/abstraction.h @@ -14,22 +14,22 @@ ** Bitvector theory. **/ +#include "cvc4_private.h" #ifndef __CVC4__THEORY__BV__ABSTRACTION_H #define __CVC4__THEORY__BV__ABSTRACTION_H -#include "cvc4_private.h" #include <ext/hash_map> #include <ext/hash_set> + #include "expr/node.h" +#include "expr/statistics_registry.h" #include "theory/substitutions.h" -#include "util/statistics_registry.h" namespace CVC4 { namespace theory { namespace bv { - typedef std::vector<TNode> ArgsVec; class AbstractionModule { diff --git a/src/theory/bv/aig_bitblaster.cpp b/src/theory/bv/aig_bitblaster.cpp index 6270995ef..f07bd49f7 100644 --- a/src/theory/bv/aig_bitblaster.cpp +++ b/src/theory/bv/aig_bitblaster.cpp @@ -14,11 +14,11 @@ ** Bitblaster for the lazy bv solver. **/ -#include "cvc4_private.h" #include "bitblaster_template.h" +#include "cvc4_private.h" +#include "options/bv_options.h" #include "prop/cnf_stream.h" #include "prop/sat_solver_factory.h" -#include "theory/bv/options.h" #ifdef CVC4_USE_ABC diff --git a/src/theory/bv/bitblaster_template.h b/src/theory/bv/bitblaster_template.h index d42c4a8c9..b93d0561e 100644 --- a/src/theory/bv/bitblaster_template.h +++ b/src/theory/bv/bitblaster_template.h @@ -23,12 +23,13 @@ #include "expr/node.h" #include <vector> #include <ext/hash_map> + #include "context/cdhashmap.h" #include "bitblast_strategies_template.h" +#include "expr/resource_manager.h" #include "prop/sat_solver.h" #include "theory/valuation.h" #include "theory/theory_registrar.h" -#include "util/resource_manager.h" class Abc_Obj_t_; typedef Abc_Obj_t_ Abc_Obj_t; diff --git a/src/theory/bv/bv_eager_solver.cpp b/src/theory/bv/bv_eager_solver.cpp index 0c087ddb9..66b1c4182 100644 --- a/src/theory/bv/bv_eager_solver.cpp +++ b/src/theory/bv/bv_eager_solver.cpp @@ -14,9 +14,9 @@ ** Eager bit-blasting solver. **/ -#include "theory/bv/bv_eager_solver.h" +#include "options/bv_options.h" #include "theory/bv/bitblaster_template.h" -#include "theory/bv/options.h" +#include "theory/bv/bv_eager_solver.h" using namespace std; using namespace CVC4; diff --git a/src/theory/bv/bv_quick_check.h b/src/theory/bv/bv_quick_check.h index 01d772cb9..261a0b1c4 100644 --- a/src/theory/bv/bv_quick_check.h +++ b/src/theory/bv/bv_quick_check.h @@ -22,10 +22,10 @@ #include <vector> #include <ext/hash_map> -#include "expr/node.h" #include "context/cdo.h" +#include "expr/node.h" +#include "expr/statistics_registry.h" #include "prop/sat_solver_types.h" -#include "util/statistics_registry.h" #include "theory/bv/theory_bv_utils.h" namespace CVC4 { diff --git a/src/theory/bv/bv_subtheory_algebraic.cpp b/src/theory/bv/bv_subtheory_algebraic.cpp index e6e3120f5..4531be040 100644 --- a/src/theory/bv/bv_subtheory_algebraic.cpp +++ b/src/theory/bv/bv_subtheory_algebraic.cpp @@ -14,14 +14,13 @@ ** Algebraic solver. **/ -#include "util/boolean_simplification.h" -#include "theory/theory_model.h" - -#include "theory/bv/options.h" -#include "theory/bv/theory_bv.h" -#include "theory/bv/bv_subtheory_algebraic.h" +#include "options/bv_options.h" +#include "smt_util/boolean_simplification.h" #include "theory/bv/bv_quick_check.h" +#include "theory/bv/bv_subtheory_algebraic.h" +#include "theory/bv/theory_bv.h" #include "theory/bv/theory_bv_utils.h" +#include "theory/theory_model.h" using namespace std; diff --git a/src/theory/bv/bv_subtheory_bitblast.cpp b/src/theory/bv/bv_subtheory_bitblast.cpp index 7e3ed46c8..1d0342c08 100644 --- a/src/theory/bv/bv_subtheory_bitblast.cpp +++ b/src/theory/bv/bv_subtheory_bitblast.cpp @@ -14,24 +14,24 @@ ** Algebraic solver. **/ +#include "decision/decision_attributes.h" +#include "options/decision_options.h" +#include "options/bv_options.h" +#include "theory/bv/abstraction.h" +#include "theory/bv/bitblaster_template.h" +#include "theory/bv/bv_quick_check.h" #include "theory/bv/bv_subtheory_bitblast.h" #include "theory/bv/theory_bv.h" #include "theory/bv/theory_bv_utils.h" -#include "theory/bv/bitblaster_template.h" -#include "theory/bv/bv_quick_check.h" -#include "theory/bv/options.h" -#include "theory/bv/abstraction.h" -#include "theory/decision_attributes.h" -#include "decision/options.h" - using namespace std; -using namespace CVC4; using namespace CVC4::context; -using namespace CVC4::theory; -using namespace CVC4::theory::bv; using namespace CVC4::theory::bv::utils; +namespace CVC4 { +namespace theory { +namespace bv { + BitblastSolver::BitblastSolver(context::Context* c, TheoryBV* bv) : SubtheorySolver(c, bv), d_bitblaster(new TLazyBitblaster(c, bv, "lazy")), @@ -78,8 +78,8 @@ void BitblastSolver::preRegister(TNode node) { CodeTimer weightComputationTime(d_bv->d_statistics.d_weightComputationTimer); d_bitblastQueue.push_back(node); if ((options::decisionUseWeight() || options::decisionThreshold() != 0) && - !node.hasAttribute(theory::DecisionWeightAttr())) { - node.setAttribute(theory::DecisionWeightAttr(),computeAtomWeight(node)); + !node.hasAttribute(decision::DecisionWeightAttr())) { + node.setAttribute(decision::DecisionWeightAttr(),computeAtomWeight(node)); } } } @@ -277,3 +277,7 @@ void BitblastSolver::setConflict(TNode conflict) { } d_bv->setConflict(final_conflict); } + +}/* namespace CVC4::theory::bv */ +}/* namespace CVC4::theory */ +}/* namespace CVC4 */ diff --git a/src/theory/bv/bv_subtheory_core.cpp b/src/theory/bv/bv_subtheory_core.cpp index 6ae0ffb71..ef4d24e82 100644 --- a/src/theory/bv/bv_subtheory_core.cpp +++ b/src/theory/bv/bv_subtheory_core.cpp @@ -16,12 +16,12 @@ #include "theory/bv/bv_subtheory_core.h" +#include "options/bv_options.h" +#include "options/smt_options.h" +#include "theory/bv/slicer.h" #include "theory/bv/theory_bv.h" #include "theory/bv/theory_bv_utils.h" -#include "theory/bv/slicer.h" #include "theory/theory_model.h" -#include "theory/bv/options.h" -#include "smt/options.h" using namespace std; using namespace CVC4; diff --git a/src/theory/bv/bv_subtheory_inequality.cpp b/src/theory/bv/bv_subtheory_inequality.cpp index 55dcbb03a..054e43b7c 100644 --- a/src/theory/bv/bv_subtheory_inequality.cpp +++ b/src/theory/bv/bv_subtheory_inequality.cpp @@ -15,10 +15,11 @@ **/ #include "theory/bv/bv_subtheory_inequality.h" + +#include "options/smt_options.h" #include "theory/bv/theory_bv.h" #include "theory/bv/theory_bv_utils.h" #include "theory/theory_model.h" -#include "smt/options.h" using namespace std; using namespace CVC4; @@ -232,4 +233,3 @@ InequalitySolver::Statistics::Statistics() InequalitySolver::Statistics::~Statistics() { StatisticsRegistry::unregisterStat(&d_numCallstoCheck); } - diff --git a/src/theory/bv/bv_to_bool.cpp b/src/theory/bv/bv_to_bool.cpp index 06a1d4a44..00e6f9ff8 100644 --- a/src/theory/bv/bv_to_bool.cpp +++ b/src/theory/bv/bv_to_bool.cpp @@ -13,11 +13,10 @@ ** ** Preprocessing pass that lifts bit-vectors of size 1 to booleans. **/ - - -#include "util/node_visitor.h" #include "theory/bv/bv_to_bool.h" +#include "smt_util/node_visitor.h" + using namespace std; using namespace CVC4; using namespace CVC4::theory; diff --git a/src/theory/bv/bv_to_bool.h b/src/theory/bv/bv_to_bool.h index b266b591b..46b2d5c6e 100644 --- a/src/theory/bv/bv_to_bool.h +++ b/src/theory/bv/bv_to_bool.h @@ -15,12 +15,13 @@ **/ #include "cvc4_private.h" -#include "theory/bv/theory_bv_utils.h" -#include "util/statistics_registry.h" #ifndef __CVC4__THEORY__BV__BV_TO_BOOL_H #define __CVC4__THEORY__BV__BV_TO_BOOL_H +#include "expr/statistics_registry.h" +#include "theory/bv/theory_bv_utils.h" + namespace CVC4 { namespace theory { namespace bv { diff --git a/src/theory/bv/eager_bitblaster.cpp b/src/theory/bv/eager_bitblaster.cpp index 3f076bd4c..ec2bfd9c0 100644 --- a/src/theory/bv/eager_bitblaster.cpp +++ b/src/theory/bv/eager_bitblaster.cpp @@ -9,27 +9,31 @@ ** See the file COPYING in the top-level source directory for licensing ** information.\endverbatim ** - ** \brief + ** \brief ** - ** Bitblaster for the eager bv solver. + ** Bitblaster for the eager bv solver. **/ #include "cvc4_private.h" -#include "theory/bv/bitblaster_template.h" -#include "theory/bv/options.h" -#include "theory/theory_model.h" -#include "theory/bv/theory_bv.h" +#include "options/bv_options.h" #include "prop/cnf_stream.h" #include "prop/sat_solver_factory.h" +#include "theory/bv/bitblaster_template.h" +#include "theory/bv/theory_bv.h" +#include "theory/theory_model.h" using namespace CVC4; using namespace CVC4::theory; -using namespace CVC4::theory::bv; +using namespace CVC4::theory::bv; + +namespace CVC4 { +namespace theory { +namespace bv { void BitblastingRegistrar::preRegister(Node n) { - d_bitblaster->bbAtom(n); + d_bitblaster->bbAtom(n); }; EagerBitblaster::EagerBitblaster(TheoryBV* theory_bv) @@ -38,12 +42,12 @@ EagerBitblaster::EagerBitblaster(TheoryBV* theory_bv) , d_bbAtoms() , d_variables() { - d_bitblastingRegistrar = new BitblastingRegistrar(this); + d_bitblastingRegistrar = new BitblastingRegistrar(this); d_nullContext = new context::Context(); d_satSolver = prop::SatSolverFactory::createMinisat(d_nullContext, "EagerBitblaster"); d_cnfStream = new prop::TseitinCnfStream(d_satSolver, d_bitblastingRegistrar, d_nullContext); - + MinisatEmptyNotify* notify = new MinisatEmptyNotify(); d_satSolver->setNotify(notify); } @@ -68,7 +72,7 @@ void EagerBitblaster::bbFormula(TNode node) { void EagerBitblaster::bbAtom(TNode node) { node = node.getKind() == kind::NOT? node[0] : node; if (node.getKind() == kind::BITVECTOR_BITOF) - return; + return; if (hasBBAtom(node)) { return; } @@ -83,18 +87,18 @@ void EagerBitblaster::bbAtom(TNode node) { // asserting that the atom is true iff the definition holds Node atom_definition = utils::mkNode(kind::IFF, node, atom_bb); - AlwaysAssert (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER); + AlwaysAssert (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER); storeBBAtom(node, atom_definition); d_cnfStream->convertAndAssert(atom_definition, false, false, RULE_INVALID, TNode::null()); } void EagerBitblaster::storeBBAtom(TNode atom, Node atom_bb) { // no need to store the definition for the lazy bit-blaster - d_bbAtoms.insert(atom); + d_bbAtoms.insert(atom); } bool EagerBitblaster::hasBBAtom(TNode atom) const { - return d_bbAtoms.find(atom) != d_bbAtoms.end(); + return d_bbAtoms.find(atom) != d_bbAtoms.end(); } void EagerBitblaster::bbTerm(TNode node, Bits& bits) { @@ -161,7 +165,7 @@ Node EagerBitblaster::getModelFromSatSolver(TNode a, bool fullModel) { if (!hasBBTerm(a)) { return fullModel? utils::mkConst(utils::getSize(a), 0u) : Node(); } - + Bits bits; getBBTerm(a, bits); Integer value(0); @@ -191,9 +195,9 @@ void EagerBitblaster::collectModelInfo(TheoryModel* m, bool fullModel) { (var.isVar() && var.getType().isBoolean())) { // only shared terms could not have been bit-blasted Assert (hasBBTerm(var) || isSharedTerm(var)); - + Node const_value = getModelFromSatSolver(var, fullModel); - + if(const_value != Node()) { Debug("bitvector-model") << "EagerBitblaster::collectModelInfo (assert (= " << var << " " @@ -207,3 +211,7 @@ void EagerBitblaster::collectModelInfo(TheoryModel* m, bool fullModel) { bool EagerBitblaster::isSharedTerm(TNode node) { return d_bv->d_sharedTermsSet.find(node) != d_bv->d_sharedTermsSet.end(); } + +} /* namespace CVC4::theory::bv; */ +} /* namespace CVC4::theory; */ +} /* namespace CVC4; */ diff --git a/src/theory/bv/lazy_bitblaster.cpp b/src/theory/bv/lazy_bitblaster.cpp index 59ecc7385..3c2b4ed78 100644 --- a/src/theory/bv/lazy_bitblaster.cpp +++ b/src/theory/bv/lazy_bitblaster.cpp @@ -14,17 +14,17 @@ ** Bitblaster for the lazy bv solver. **/ -#include "cvc4_private.h" #include "bitblaster_template.h" -#include "theory_bv_utils.h" -#include "theory/rewriter.h" +#include "cvc4_private.h" +#include "options/bv_options.h" #include "prop/cnf_stream.h" #include "prop/sat_solver.h" #include "prop/sat_solver_factory.h" +#include "theory/bv/abstraction.h" #include "theory/bv/theory_bv.h" -#include "theory/bv/options.h" +#include "theory/rewriter.h" #include "theory/theory_model.h" -#include "theory/bv/abstraction.h" +#include "theory_bv_utils.h" using namespace CVC4; using namespace CVC4::theory; diff --git a/src/theory/bv/options_handlers.h b/src/theory/bv/options_handlers.h deleted file mode 100644 index a7a7101d2..000000000 --- a/src/theory/bv/options_handlers.h +++ /dev/null @@ -1,160 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Liana Hadarean - ** Major contributors: none - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Custom handlers and predicates for TheoryBV options - ** - ** Custom handlers and predicates for TheoryBV options. - **/ - -#include "cvc4_private.h" - -#ifndef __CVC4__THEORY__BV__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__BV__OPTIONS_HANDLERS_H - -#include "theory/bv/bitblast_mode.h" -#include "main/options.h" - -namespace CVC4 { -namespace theory { -namespace bv { - -inline void abcEnabledBuild(std::string option, bool value, SmtEngine* smt) throw(OptionException) { -#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 */ -} - -inline void abcEnabledBuild(std::string option, std::string value, SmtEngine* smt) throw(OptionException) { -#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 */ -} - -static const std::string bitblastingModeHelp = "\ -Bit-blasting modes currently supported by the --bitblast option:\n\ -\n\ -lazy (default)\n\ -+ Separate boolean structure and term reasoning betwen the core\n\ - SAT solver and the bv SAT solver\n\ -\n\ -eager\n\ -+ Bitblast eagerly to bv SAT solver\n\ -"; - -inline BitblastMode stringToBitblastMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "lazy") { - if (!options::bitvectorPropagate.wasSetByUser()) { - options::bitvectorPropagate.set(true); - } - if (!options::bitvectorEqualitySolver.wasSetByUser()) { - options::bitvectorEqualitySolver.set(true); - } - if (!options::bitvectorEqualitySlicer.wasSetByUser()) { - if (options::incrementalSolving() || - options::produceModels()) { - options::bitvectorEqualitySlicer.set(BITVECTOR_SLICER_OFF); - } else { - options::bitvectorEqualitySlicer.set(BITVECTOR_SLICER_AUTO); - } - } - - if (!options::bitvectorInequalitySolver.wasSetByUser()) { - options::bitvectorInequalitySolver.set(true); - } - if (!options::bitvectorAlgebraicSolver.wasSetByUser()) { - options::bitvectorAlgebraicSolver.set(true); - } - return BITBLAST_MODE_LAZY; - } else if(optarg == "eager") { - - if (options::incrementalSolving() && - options::incrementalSolving.wasSetByUser()) { - throw OptionException(std::string("Eager bit-blasting does not currently support incremental mode. \n\ - Try --bitblast=lazy")); - } - - if (!options::bitvectorToBool.wasSetByUser()) { - options::bitvectorToBool.set(true); - } - - if (!options::bvAbstraction.wasSetByUser() && - !options::skolemizeArguments.wasSetByUser()) { - options::bvAbstraction.set(true); - options::skolemizeArguments.set(true); - } - return BITBLAST_MODE_EAGER; - } else if(optarg == "help") { - puts(bitblastingModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --bitblast: `") + - optarg + "'. Try --bitblast=help."); - } -} - -static const std::string 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\ -"; - -inline BvSlicerMode stringToBvSlicerMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - - if(optarg == "auto") { - return BITVECTOR_SLICER_AUTO; - } else if(optarg == "on") { - return BITVECTOR_SLICER_ON; - } else if(optarg == "off") { - return BITVECTOR_SLICER_OFF; - } else if(optarg == "help") { - puts(bitblastingModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --bv-eq-slicer: `") + - optarg + "'. Try --bv-eq-slicer=help."); - } -} - -inline void setBitblastAig(std::string option, bool arg, SmtEngine* smt) throw(OptionException) { - if(arg) { - if(options::bitblastMode.wasSetByUser()) { - if(options::bitblastMode() != BITBLAST_MODE_EAGER) { - throw OptionException("bitblast-aig must be used with eager bitblaster"); - } - } else { - options::bitblastMode.set(stringToBitblastMode("", "eager", smt)); - } - if(!options::bitvectorAigSimplifications.wasSetByUser()) { - options::bitvectorAigSimplifications.set("balance;drw"); - } - } -} - -}/* CVC4::theory::bv namespace */ -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__THEORY__BV__OPTIONS_HANDLERS_H */ diff --git a/src/theory/bv/slicer.cpp b/src/theory/bv/slicer.cpp index a7587bedf..d31ff50d1 100644 --- a/src/theory/bv/slicer.cpp +++ b/src/theory/bv/slicer.cpp @@ -14,10 +14,11 @@ ** Bitvector theory. **/ +#include "options/bv_options.h" #include "theory/bv/slicer.h" #include "theory/bv/theory_bv_utils.h" #include "theory/rewriter.h" -#include "theory/bv/options.h" + using namespace CVC4; using namespace CVC4::theory; using namespace CVC4::theory::bv; diff --git a/src/theory/bv/slicer.h b/src/theory/bv/slicer.h index 7b55054bc..5ecc2a788 100644 --- a/src/theory/bv/slicer.h +++ b/src/theory/bv/slicer.h @@ -16,17 +16,19 @@ #include "cvc4_private.h" +#include <math.h> #include <vector> #include <list> #include <ext/hash_map> -#include <math.h> -#include "util/bitvector.h" -#include "util/statistics_registry.h" -#include "util/index.h" #include "expr/node.h" +#include "expr/statistics_registry.h" #include "theory/bv/theory_bv_utils.h" +#include "util/bitvector.h" +#include "util/index.h" + + #ifndef __CVC4__THEORY__BV__SLICER_BV_H #define __CVC4__THEORY__BV__SLICER_BV_H diff --git a/src/theory/bv/theory_bv.cpp b/src/theory/bv/theory_bv.cpp index 95a483d34..4039fceec 100644 --- a/src/theory/bv/theory_bv.cpp +++ b/src/theory/bv/theory_bv.cpp @@ -11,24 +11,25 @@ ** ** [[ Add lengthier description here ]] ** \todo document this file -**/ + **/ -#include "smt/options.h" #include "theory/bv/theory_bv.h" -#include "theory/bv/theory_bv_utils.h" + +#include "options/bv_options.h" +#include "options/smt_options.h" +#include "theory/bv/abstraction.h" +#include "theory/bv/bv_eager_solver.h" +#include "theory/bv/bv_subtheory_algebraic.h" +#include "theory/bv/bv_subtheory_bitblast.h" +#include "theory/bv/bv_subtheory_core.h" +#include "theory/bv/bv_subtheory_inequality.h" #include "theory/bv/slicer.h" -#include "theory/valuation.h" -#include "theory/bv/options.h" #include "theory/bv/theory_bv_rewrite_rules_normalization.h" #include "theory/bv/theory_bv_rewrite_rules_simplification.h" -#include "theory/bv/bv_subtheory_core.h" -#include "theory/bv/bv_subtheory_inequality.h" -#include "theory/bv/bv_subtheory_algebraic.h" -#include "theory/bv/bv_subtheory_bitblast.h" -#include "theory/bv/bv_eager_solver.h" #include "theory/bv/theory_bv_rewriter.h" +#include "theory/bv/theory_bv_utils.h" #include "theory/theory_model.h" -#include "theory/bv/abstraction.h" +#include "theory/valuation.h" using namespace CVC4; using namespace CVC4::theory; diff --git a/src/theory/bv/theory_bv.h b/src/theory/bv/theory_bv.h index 193de55db..4b3649a86 100644 --- a/src/theory/bv/theory_bv.h +++ b/src/theory/bv/theory_bv.h @@ -14,18 +14,19 @@ ** Bitvector theory. **/ +#include "cvc4_private.h" + #ifndef __CVC4__THEORY__BV__THEORY_BV_H #define __CVC4__THEORY__BV__THEORY_BV_H -#include "cvc4_private.h" -#include "theory/theory.h" -#include "context/context.h" -#include "context/cdlist.h" #include "context/cdhashset.h" +#include "context/cdlist.h" +#include "context/context.h" +#include "expr/statistics_registry.h" +#include "theory/bv/bv_subtheory.h" #include "theory/bv/theory_bv_utils.h" -#include "util/statistics_registry.h" +#include "theory/theory.h" #include "util/hash.h" -#include "theory/bv/bv_subtheory.h" namespace CVC4 { namespace theory { diff --git a/src/theory/bv/theory_bv_rewrite_rules.h b/src/theory/bv/theory_bv_rewrite_rules.h index 768923ee6..f5e2a2077 100644 --- a/src/theory/bv/theory_bv_rewrite_rules.h +++ b/src/theory/bv/theory_bv_rewrite_rules.h @@ -15,15 +15,17 @@ ** \todo document this file **/ -#pragma once - #include "cvc4_private.h" -#include "theory/theory.h" + +#pragma once + +#include <sstream> + #include "context/context.h" -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" +#include "smt_util/command.h" #include "theory/bv/theory_bv_utils.h" -#include "expr/command.h" -#include <sstream> +#include "theory/theory.h" namespace CVC4 { namespace theory { diff --git a/src/theory/bv/theory_bv_rewrite_rules_normalization.h b/src/theory/bv/theory_bv_rewrite_rules_normalization.h index bc1b92dce..0911b6ccf 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_normalization.h +++ b/src/theory/bv/theory_bv_rewrite_rules_normalization.h @@ -19,6 +19,7 @@ #pragma once +#include "theory/rewriter.h" #include "theory/bv/theory_bv_rewrite_rules.h" #include "theory/bv/theory_bv_utils.h" diff --git a/src/theory/bv/theory_bv_rewriter.cpp b/src/theory/bv/theory_bv_rewriter.cpp index f2adea411..2c82943ce 100644 --- a/src/theory/bv/theory_bv_rewriter.cpp +++ b/src/theory/bv/theory_bv_rewriter.cpp @@ -15,15 +15,15 @@ ** \todo document this file **/ -#include "theory/theory.h" -#include "theory/bv/options.h" -#include "theory/bv/theory_bv_rewriter.h" +#include "options/bv_options.h" #include "theory/bv/theory_bv_rewrite_rules.h" +#include "theory/bv/theory_bv_rewrite_rules_constant_evaluation.h" #include "theory/bv/theory_bv_rewrite_rules_core.h" +#include "theory/bv/theory_bv_rewrite_rules_normalization.h" #include "theory/bv/theory_bv_rewrite_rules_operator_elimination.h" -#include "theory/bv/theory_bv_rewrite_rules_constant_evaluation.h" #include "theory/bv/theory_bv_rewrite_rules_simplification.h" -#include "theory/bv/theory_bv_rewrite_rules_normalization.h" +#include "theory/bv/theory_bv_rewriter.h" +#include "theory/theory.h" using namespace CVC4; using namespace CVC4::theory; @@ -682,6 +682,3 @@ Node TheoryBVRewriter::eliminateBVSDiv(TNode node) { >::apply(node); return result; } - - - diff --git a/src/theory/bv/theory_bv_rewriter.h b/src/theory/bv/theory_bv_rewriter.h index 3f0fa8194..7e5d429fd 100644 --- a/src/theory/bv/theory_bv_rewriter.h +++ b/src/theory/bv/theory_bv_rewriter.h @@ -20,8 +20,8 @@ #ifndef __CVC4__THEORY__BV__THEORY_BV_REWRITER_H #define __CVC4__THEORY__BV__THEORY_BV_REWRITER_H +#include "expr/statistics_registry.h" #include "theory/rewriter.h" -#include "util/statistics_registry.h" namespace CVC4 { namespace theory { diff --git a/src/theory/bv/theory_bv_utils.cpp b/src/theory/bv/theory_bv_utils.cpp index d2025b1b8..f57ccec48 100644 --- a/src/theory/bv/theory_bv_utils.cpp +++ b/src/theory/bv/theory_bv_utils.cpp @@ -16,24 +16,23 @@ **/ #include "theory/bv/theory_bv_utils.h" -#include "theory/decision_attributes.h" #include "theory/theory.h" -using namespace CVC4; -using namespace CVC4::theory; -using namespace CVC4::theory::bv; -using namespace CVC4::theory::bv::utils; +namespace CVC4 { +namespace theory { +namespace bv { +namespace utils { -bool CVC4::theory::bv::utils::isCoreTerm(TNode term, TNodeBoolMap& cache) { - term = term.getKind() == kind::NOT ? term[0] : term; - TNodeBoolMap::const_iterator it = cache.find(term); +bool isCoreTerm(TNode term, TNodeBoolMap& cache) { + term = term.getKind() == kind::NOT ? term[0] : term; + TNodeBoolMap::const_iterator it = cache.find(term); if (it != cache.end()) { return it->second; } - + if (term.getNumChildren() == 0) return true; - + if (theory::Theory::theoryOf(theory::THEORY_OF_TERM_BASED, term) == THEORY_BV) { Kind k = term.getKind(); if (k != kind::CONST_BITVECTOR && @@ -52,21 +51,21 @@ bool CVC4::theory::bv::utils::isCoreTerm(TNode term, TNodeBoolMap& cache) { return false; } } - - cache[term]= true; + + cache[term]= true; return true; } -bool CVC4::theory::bv::utils::isEqualityTerm(TNode term, TNodeBoolMap& cache) { - term = term.getKind() == kind::NOT ? term[0] : term; - TNodeBoolMap::const_iterator it = cache.find(term); +bool isEqualityTerm(TNode term, TNodeBoolMap& cache) { + term = term.getKind() == kind::NOT ? term[0] : term; + TNodeBoolMap::const_iterator it = cache.find(term); if (it != cache.end()) { return it->second; } - + if (term.getNumChildren() == 0) return true; - + if (theory::Theory::theoryOf(theory::THEORY_OF_TERM_BASED, term) == THEORY_BV) { Kind k = term.getKind(); if (k != kind::CONST_BITVECTOR && @@ -83,13 +82,13 @@ bool CVC4::theory::bv::utils::isEqualityTerm(TNode term, TNodeBoolMap& cache) { return false; } } - - cache[term]= true; + + cache[term]= true; return true; } -uint64_t CVC4::theory::bv::utils::numNodes(TNode node, NodeSet& seen) { +uint64_t numNodes(TNode node, NodeSet& seen) { if (seen.find(node) != seen.end()) return 0; @@ -101,9 +100,7 @@ uint64_t CVC4::theory::bv::utils::numNodes(TNode node, NodeSet& seen) { return size; } - - -void CVC4::theory::bv::utils::collectVariables(TNode node, NodeSet& vars) { +void collectVariables(TNode node, NodeSet& vars) { if (vars.find(node) != vars.end()) return; @@ -115,3 +112,8 @@ void CVC4::theory::bv::utils::collectVariables(TNode node, NodeSet& vars) { collectVariables(node[i], vars); } } + +}/* CVC4::theory::bv::utils namespace */ +}/* CVC4::theory::bv namespace */ +}/* CVC4::theory namespace */ +}/* CVC4 namespace */ diff --git a/src/theory/bv/type_enumerator.h b/src/theory/bv/type_enumerator.h index 1d835dd23..db98ef66b 100644 --- a/src/theory/bv/type_enumerator.h +++ b/src/theory/bv/type_enumerator.h @@ -19,11 +19,11 @@ #ifndef __CVC4__THEORY__BV__TYPE_ENUMERATOR_H #define __CVC4__THEORY__BV__TYPE_ENUMERATOR_H +#include "expr/kind.h" +#include "expr/type_node.h" +#include "theory/type_enumerator.h" #include "util/bitvector.h" #include "util/integer.h" -#include "theory/type_enumerator.h" -#include "expr/type_node.h" -#include "expr/kind.h" namespace CVC4 { namespace theory { diff --git a/src/theory/datatypes/datatypes_rewriter.h b/src/theory/datatypes/datatypes_rewriter.h index bd44f66a9..dc57f6b47 100644 --- a/src/theory/datatypes/datatypes_rewriter.h +++ b/src/theory/datatypes/datatypes_rewriter.h @@ -19,10 +19,10 @@ #ifndef __CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H #define __CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H +#include "expr/node_manager_attributes.h" +#include "options/datatypes_options.h" #include "theory/rewriter.h" -#include "theory/datatypes/options.h" #include "theory/type_enumerator.h" -#include "expr/node_manager_attributes.h" namespace CVC4 { namespace theory { @@ -625,4 +625,3 @@ public: }/* CVC4 namespace */ #endif /* __CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H */ - diff --git a/src/theory/datatypes/datatypes_sygus.cpp b/src/theory/datatypes/datatypes_sygus.cpp index 3ab29f334..5f0466d30 100644 --- a/src/theory/datatypes/datatypes_sygus.cpp +++ b/src/theory/datatypes/datatypes_sygus.cpp @@ -15,11 +15,11 @@ **/ -#include "theory/datatypes/datatypes_sygus.h" -#include "theory/datatypes/datatypes_rewriter.h" #include "expr/node_manager.h" +#include "options/quantifiers_options.h" +#include "theory/datatypes/datatypes_rewriter.h" +#include "theory/datatypes/datatypes_sygus.h" #include "theory/quantifiers/term_database.h" -#include "theory/quantifiers/options.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/src/theory/datatypes/datatypes_sygus.h b/src/theory/datatypes/datatypes_sygus.h index 4eac3d1c6..415bd6e4b 100644 --- a/src/theory/datatypes/datatypes_sygus.h +++ b/src/theory/datatypes/datatypes_sygus.h @@ -19,10 +19,11 @@ #ifndef __CVC4__THEORY__DATATYPES__DATATYPES_SYGUS_H #define __CVC4__THEORY__DATATYPES__DATATYPES_SYGUS_H -#include "expr/node.h" -#include "util/datatype.h" #include <iostream> #include <map> + +#include "expr/node.h" +#include "expr/datatype.h" #include "context/context.h" #include "context/cdchunk_list.h" #include "context/cdhashmap.h" @@ -30,11 +31,10 @@ namespace CVC4 { namespace theory { - namespace quantifiers { class TermDbSygus; -} - +} /* namespace quantifiers */ + namespace datatypes { class SygusSplit diff --git a/src/theory/datatypes/kinds b/src/theory/datatypes/kinds index a4cd0d124..749d6b58a 100644 --- a/src/theory/datatypes/kinds +++ b/src/theory/datatypes/kinds @@ -41,15 +41,15 @@ parameterized APPLY_TESTER TESTER_TYPE 1 "tester application; first parameter is constant DATATYPE_TYPE \ ::CVC4::Datatype \ "::CVC4::DatatypeHashFunction" \ - "util/datatype.h" \ + "expr/datatype.h" \ "a datatype type" cardinality DATATYPE_TYPE \ "%TYPE%.getConst<Datatype>().getCardinality()" \ - "util/datatype.h" + "expr/datatype.h" well-founded DATATYPE_TYPE \ "%TYPE%.getConst<Datatype>().isWellFounded()" \ "%TYPE%.getConst<Datatype>().mkGroundTerm(%TYPE%.toType())" \ - "util/datatype.h" + "expr/datatype.h" enumerator DATATYPE_TYPE \ "::CVC4::theory::datatypes::DatatypesEnumerator" \ @@ -58,11 +58,11 @@ enumerator DATATYPE_TYPE \ operator PARAMETRIC_DATATYPE 1: "parametric datatype" cardinality PARAMETRIC_DATATYPE \ "DatatypeType(%TYPE%.toType()).getDatatype().getCardinality()" \ - "util/datatype.h" + "expr/datatype.h" well-founded PARAMETRIC_DATATYPE \ "DatatypeType(%TYPE%.toType()).getDatatype().isWellFounded()" \ "DatatypeType(%TYPE%.toType()).getDatatype().mkGroundTerm(%TYPE%.toType())" \ - "util/datatype.h" + "expr/datatype.h" enumerator PARAMETRIC_DATATYPE \ "::CVC4::theory::datatypes::DatatypesEnumerator" \ @@ -73,7 +73,7 @@ parameterized APPLY_TYPE_ASCRIPTION ASCRIPTION_TYPE 1 \ constant ASCRIPTION_TYPE \ ::CVC4::AscriptionType \ ::CVC4::AscriptionTypeHashFunction \ - "util/ascription_type.h" \ + "expr/ascription_type.h" \ "a type parameter for type ascription; payload is an instance of the CVC4::AscriptionType class" typerule APPLY_CONSTRUCTOR ::CVC4::theory::datatypes::DatatypeConstructorTypeRule @@ -126,7 +126,7 @@ typerule TUPLE_UPDATE ::CVC4::theory::datatypes::TupleUpdateTypeRule constant RECORD_TYPE \ ::CVC4::Record \ ::CVC4::RecordHashFunction \ - "util/record.h" \ + "expr/record.h" \ "record type" cardinality RECORD_TYPE \ "::CVC4::theory::datatypes::TupleProperties::computeCardinality(%TYPE%)" \ @@ -146,7 +146,7 @@ construle RECORD ::CVC4::theory::datatypes::RecordProperties constant RECORD_SELECT_OP \ ::CVC4::RecordSelect \ ::CVC4::RecordSelectHashFunction \ - "util/record.h" \ + "expr/record.h" \ "operator for a record select; payload is an instance CVC4::RecordSelect class" parameterized RECORD_SELECT RECORD_SELECT_OP 1 "record select; first parameter is a RECORD_SELECT_OP, second is a record term to select from" typerule RECORD_SELECT ::CVC4::theory::datatypes::RecordSelectTypeRule @@ -154,7 +154,7 @@ typerule RECORD_SELECT ::CVC4::theory::datatypes::RecordSelectTypeRule constant RECORD_UPDATE_OP \ ::CVC4::RecordUpdate \ ::CVC4::RecordUpdateHashFunction \ - "util/record.h" \ + "expr/record.h" \ "operator for a record update; payload is an instance CVC4::RecordSelect class" parameterized RECORD_UPDATE RECORD_UPDATE_OP 2 "record update; first parameter is a RECORD_UPDATE_OP (which references a field), second is a record term to update, third is the element to store in the record in the given field" typerule RECORD_UPDATE ::CVC4::theory::datatypes::RecordUpdateTypeRule diff --git a/src/theory/datatypes/theory_datatypes.cpp b/src/theory/datatypes/theory_datatypes.cpp index af8e5c503..1962d2e31 100644 --- a/src/theory/datatypes/theory_datatypes.cpp +++ b/src/theory/datatypes/theory_datatypes.cpp @@ -13,26 +13,24 @@ ** ** Implementation of the theory of datatypes. **/ +#include "theory/datatypes/theory_datatypes.h" +#include <map> -#include "theory/datatypes/theory_datatypes.h" -#include "theory/valuation.h" +#include "base/cvc4_assert.h" +#include "expr/datatype.h" #include "expr/kind.h" -#include "util/datatype.h" -#include "util/cvc4_assert.h" +#include "options/datatypes_options.h" +#include "options/quantifiers_options.h" +#include "options/smt_options.h" +#include "smt/boolean_terms.h" #include "theory/datatypes/datatypes_rewriter.h" #include "theory/datatypes/theory_datatypes_type_rules.h" +#include "theory/quantifiers_engine.h" #include "theory/theory_model.h" -#include "smt/options.h" -#include "smt/boolean_terms.h" -#include "theory/datatypes/options.h" #include "theory/type_enumerator.h" +#include "theory/valuation.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers_engine.h" - - -#include <map> using namespace std; using namespace CVC4; diff --git a/src/theory/datatypes/theory_datatypes.h b/src/theory/datatypes/theory_datatypes.h index b452e02d1..bbbf799bd 100644 --- a/src/theory/datatypes/theory_datatypes.h +++ b/src/theory/datatypes/theory_datatypes.h @@ -19,16 +19,16 @@ #ifndef __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_H #define __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_H -#include "theory/theory.h" -#include "util/datatype.h" -#include "util/hash.h" -#include "theory/uf/equality_engine.h" -#include "theory/datatypes/datatypes_sygus.h" - #include <ext/hash_set> #include <iostream> #include <map> + #include "context/cdchunk_list.h" +#include "expr/datatype.h" +#include "theory/datatypes/datatypes_sygus.h" +#include "theory/theory.h" +#include "theory/uf/equality_engine.h" +#include "util/hash.h" namespace CVC4 { namespace theory { diff --git a/src/theory/datatypes/theory_datatypes_type_rules.h b/src/theory/datatypes/theory_datatypes_type_rules.h index 15d1c6c9e..23e68a6a8 100644 --- a/src/theory/datatypes/theory_datatypes_type_rules.h +++ b/src/theory/datatypes/theory_datatypes_type_rules.h @@ -19,7 +19,7 @@ #ifndef __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_TYPE_RULES_H #define __CVC4__THEORY__DATATYPES__THEORY_DATATYPES_TYPE_RULES_H -#include "util/matcher.h" +#include "expr/matcher.h" //#include "expr/attribute.h" namespace CVC4 { diff --git a/src/theory/fp/options_handlers.h b/src/theory/fp/options_handlers.h deleted file mode 100644 index f1a86e396..000000000 --- a/src/theory/fp/options_handlers.h +++ /dev/null @@ -1,14 +0,0 @@ -#include "cvc4_private.h" - -#ifndef __CVC4__THEORY__FP__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__FP__OPTIONS_HANDLERS_H - -namespace CVC4 { -namespace theory { -namespace fp { - -}/* CVC4::theory::fp namespace */ -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__THEORY__FP__OPTIONS_HANDLERS_H */ diff --git a/src/theory/fp/theory_fp_rewriter.cpp b/src/theory/fp/theory_fp_rewriter.cpp index ba9823541..59ff4692f 100644 --- a/src/theory/fp/theory_fp_rewriter.cpp +++ b/src/theory/fp/theory_fp_rewriter.cpp @@ -25,12 +25,11 @@ ** ]] **/ -#include "theory/fp/theory_fp_rewriter.h" - -#include "util/cvc4_assert.h" - #include <algorithm> +#include "base/cvc4_assert.h" +#include "theory/fp/theory_fp_rewriter.h" + namespace CVC4 { namespace theory { namespace fp { diff --git a/src/theory/idl/theory_idl.cpp b/src/theory/idl/theory_idl.cpp index 55dec35e9..427ac577c 100644 --- a/src/theory/idl/theory_idl.cpp +++ b/src/theory/idl/theory_idl.cpp @@ -16,12 +16,14 @@ **/ #include "theory/idl/theory_idl.h" -#include "theory/idl/options.h" -#include "theory/rewriter.h" #include <set> #include <queue> +#include "options/idl_options.h" +#include "theory/rewriter.h" + + using namespace std; using namespace CVC4; diff --git a/src/theory/interrupted.h b/src/theory/interrupted.h index ee7e5db12..6c59146e1 100644 --- a/src/theory/interrupted.h +++ b/src/theory/interrupted.h @@ -29,7 +29,7 @@ #ifndef __CVC4__THEORY__INTERRUPTED_H #define __CVC4__THEORY__INTERRUPTED_H -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { namespace theory { diff --git a/src/theory/ite_utilities.h b/src/theory/ite_utilities.h index d4abdbf35..27fce3071 100644 --- a/src/theory/ite_utilities.h +++ b/src/theory/ite_utilities.h @@ -22,11 +22,12 @@ #ifndef __CVC4__ITE_UTILITIES_H #define __CVC4__ITE_UTILITIES_H -#include <vector> #include <ext/hash_map> #include <ext/hash_set> +#include <vector> + #include "expr/node.h" -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" namespace CVC4 { namespace theory { diff --git a/src/theory/logic_info.cpp b/src/theory/logic_info.cpp index 1df304061..15600fefc 100644 --- a/src/theory/logic_info.cpp +++ b/src/theory/logic_info.cpp @@ -15,14 +15,17 @@ ** A class giving information about a logic (group of theory modules and ** configuration information). **/ +#include "theory/logic_info.h" #include <string> #include <cstring> #include <sstream> +#include "base/cvc4_assert.h" #include "expr/kind.h" -#include "theory/logic_info.h" -#include "util/cvc4_assert.h" + +#warning "TODO: Remove logic_info_forward.h" + using namespace std; using namespace CVC4::theory; diff --git a/src/theory/logic_info.h b/src/theory/logic_info.h index f4527648a..9cecc88b7 100644 --- a/src/theory/logic_info.h +++ b/src/theory/logic_info.h @@ -24,6 +24,7 @@ #include <string> #include <vector> #include "expr/kind.h" +#include "options/logic_info_forward.h" namespace CVC4 { @@ -338,4 +339,3 @@ std::ostream& operator<<(std::ostream& out, const LogicInfo& logic) CVC4_PUBLIC; }/* CVC4 namespace */ #endif /* __CVC4__LOGIC_INFO_H */ - diff --git a/src/theory/options b/src/theory/options deleted file mode 100644 index 9944264c8..000000000 --- a/src/theory/options +++ /dev/null @@ -1,15 +0,0 @@ -# -# Option specification file for CVC4 -# See src/options/base_options for a description of this file format -# - -module THEORY "theory/options.h" Theory layer - -expert-option theoryOfMode theoryof-mode --theoryof-mode=MODE CVC4::theory::TheoryOfMode :handler CVC4::theory::stringToTheoryOfMode :handler-include "theory/options_handlers.h" :default CVC4::theory::THEORY_OF_TYPE_BASED :include "theory/theoryof_mode.h" :read-write - mode for Theory::theoryof() - -option - use-theory --use-theory=NAME argument :handler CVC4::theory::useTheory :handler-include "theory/options_handlers.h" - use alternate theory implementation NAME (--use-theory=help for a list) -option theoryAlternates ::std::map<std::string,bool> :include <map> :read-write - -endmodule diff --git a/src/theory/options_handlers.h b/src/theory/options_handlers.h deleted file mode 100644 index 4b0cd94a5..000000000 --- a/src/theory/options_handlers.h +++ /dev/null @@ -1,69 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: none - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** See the file COPYING in the top-level source directory for licensing - ** information.\endverbatim - ** - ** \brief Custom handlers and predicates for TheoryEngine options - ** - ** Custom handlers and predicates for TheoryEngine options. - **/ - -#include "cvc4_private.h" - -#ifndef __CVC4__THEORY__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__OPTIONS_HANDLERS_H - -#include "expr/metakind.h" - -namespace CVC4 { -namespace theory { - -static const std::string 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\ -"; - -inline TheoryOfMode stringToTheoryOfMode(std::string option, std::string optarg, SmtEngine* smt) { - if(optarg == "type") { - return THEORY_OF_TYPE_BASED; - } else if(optarg == "term") { - return THEORY_OF_TERM_BASED; - } else if(optarg == "help") { - puts(theoryOfModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --theoryof-mode: `") + - optarg + "'. Try --theoryof-mode help."); - } -} - -inline void useTheory(std::string option, std::string optarg, SmtEngine* smt) { - if(optarg == "help") { - puts(useTheoryHelp); - exit(1); - } - if(useTheoryValidate(optarg)) { - std::map<std::string, bool> m = options::theoryAlternates(); - m[optarg] = true; - options::theoryAlternates.set(m); - } else { - throw OptionException(std::string("unknown option for ") + option + ": `" + - optarg + "'. Try --use-theory help."); - } -} - -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__THEORY__OPTIONS_HANDLERS_H */ diff --git a/src/theory/output_channel.h b/src/theory/output_channel.h index 2da0f0467..34a5a7dbd 100644 --- a/src/theory/output_channel.h +++ b/src/theory/output_channel.h @@ -19,10 +19,10 @@ #ifndef __CVC4__THEORY__OUTPUT_CHANNEL_H #define __CVC4__THEORY__OUTPUT_CHANNEL_H -#include "util/cvc4_assert.h" -#include "theory/interrupted.h" -#include "util/resource_manager.h" +#include "base/cvc4_assert.h" +#include "expr/resource_manager.h" #include "smt/logic_exception.h" +#include "theory/interrupted.h" namespace CVC4 { namespace theory { diff --git a/src/theory/quantifiers/ambqi_builder.cpp b/src/theory/quantifiers/ambqi_builder.cpp index f047276b0..b18676cbc 100644 --- a/src/theory/quantifiers/ambqi_builder.cpp +++ b/src/theory/quantifiers/ambqi_builder.cpp @@ -13,9 +13,9 @@ **/ +#include "options/quantifiers_options.h" #include "theory/quantifiers/ambqi_builder.h" #include "theory/quantifiers/term_database.h" -#include "theory/quantifiers/options.h" using namespace std; using namespace CVC4; diff --git a/src/theory/quantifiers/bounded_integers.cpp b/src/theory/quantifiers/bounded_integers.cpp index 2fd595a9f..ceab8394f 100644 --- a/src/theory/quantifiers/bounded_integers.cpp +++ b/src/theory/quantifiers/bounded_integers.cpp @@ -14,12 +14,12 @@ ** This class manages integer bounds for quantifiers **/ +#include "options/quantifiers_options.h" #include "theory/quantifiers/bounded_integers.h" -#include "theory/quantifiers/quant_util.h" #include "theory/quantifiers/first_order_model.h" #include "theory/quantifiers/model_engine.h" +#include "theory/quantifiers/quant_util.h" #include "theory/quantifiers/term_database.h" -#include "theory/quantifiers/options.h" using namespace CVC4; using namespace std; @@ -425,4 +425,3 @@ void BoundedIntegers::getBoundValues( Node f, Node v, RepSetIterator * rsi, Node bool BoundedIntegers::isGroundRange(Node f, Node v) { return isBoundVar(f,v) && !getLowerBound(f,v).hasBoundVar() && !getUpperBound(f,v).hasBoundVar(); } - diff --git a/src/theory/quantifiers/candidate_generator.cpp b/src/theory/quantifiers/candidate_generator.cpp index b67c4bd56..0cdb22be4 100644 --- a/src/theory/quantifiers/candidate_generator.cpp +++ b/src/theory/quantifiers/candidate_generator.cpp @@ -12,13 +12,13 @@ ** \brief Implementation of theory uf candidate generator class **/ +#include "options/quantifiers_options.h" #include "theory/quantifiers/candidate_generator.h" -#include "theory/theory_engine.h" -#include "theory/uf/theory_uf.h" -#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/inst_match.h" +#include "theory/quantifiers/term_database.h" #include "theory/quantifiers_engine.h" -#include "theory/quantifiers/options.h" +#include "theory/theory_engine.h" +#include "theory/uf/theory_uf.h" using namespace std; using namespace CVC4; diff --git a/src/theory/quantifiers/ce_guided_instantiation.cpp b/src/theory/quantifiers/ce_guided_instantiation.cpp index 398ae1ffe..81fe00674 100644 --- a/src/theory/quantifiers/ce_guided_instantiation.cpp +++ b/src/theory/quantifiers/ce_guided_instantiation.cpp @@ -12,14 +12,14 @@ ** \brief counterexample guided instantiation class ** **/ - #include "theory/quantifiers/ce_guided_instantiation.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" -#include "theory/quantifiers/first_order_model.h" + +#include "expr/datatype.h" +#include "options/quantifiers_options.h" #include "theory/datatypes/datatypes_rewriter.h" -#include "util/datatype.h" +#include "theory/quantifiers/first_order_model.h" +#include "theory/quantifiers/term_database.h" +#include "theory/theory_engine.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/src/theory/quantifiers/ce_guided_instantiation.h b/src/theory/quantifiers/ce_guided_instantiation.h index 6fcfdbc58..8274561ca 100644 --- a/src/theory/quantifiers/ce_guided_instantiation.h +++ b/src/theory/quantifiers/ce_guided_instantiation.h @@ -17,11 +17,11 @@ #ifndef __CVC4__THEORY__QUANTIFIERS__CE_GUIDED_INSTANTIATION_H #define __CVC4__THEORY__QUANTIFIERS__CE_GUIDED_INSTANTIATION_H -#include "context/cdhashmap.h" #include "context/cdchunk_list.h" -#include "theory/quantifiers_engine.h" +#include "context/cdhashmap.h" +#include "options/quantifiers_modes.h" #include "theory/quantifiers/ce_guided_single_inv.h" -#include "theory/quantifiers/modes.h" +#include "theory/quantifiers_engine.h" namespace CVC4 { namespace theory { diff --git a/src/theory/quantifiers/ce_guided_single_inv.cpp b/src/theory/quantifiers/ce_guided_single_inv.cpp index f533a2bbb..7ef23077f 100644 --- a/src/theory/quantifiers/ce_guided_single_inv.cpp +++ b/src/theory/quantifiers/ce_guided_single_inv.cpp @@ -12,18 +12,18 @@ ** \brief utility for processing single invocation synthesis conjectures ** **/ - #include "theory/quantifiers/ce_guided_single_inv.h" + +#include "expr/datatype.h" +#include "options/quantifiers_options.h" +#include "theory/datatypes/datatypes_rewriter.h" #include "theory/quantifiers/ce_guided_instantiation.h" #include "theory/quantifiers/ce_guided_single_inv_ei.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/first_order_model.h" -#include "theory/datatypes/datatypes_rewriter.h" -#include "util/datatype.h" #include "theory/quantifiers/quant_util.h" +#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/trigger.h" +#include "theory/theory_engine.h" using namespace CVC4; using namespace CVC4::kind; @@ -1186,4 +1186,4 @@ void SingleInvocationPartition::debugPrint( const char * c ) { Trace(c) << std::endl; } -}
\ No newline at end of file +} diff --git a/src/theory/quantifiers/ce_guided_single_inv_ei.cpp b/src/theory/quantifiers/ce_guided_single_inv_ei.cpp index 18252e190..f45285851 100644 --- a/src/theory/quantifiers/ce_guided_single_inv_ei.cpp +++ b/src/theory/quantifiers/ce_guided_single_inv_ei.cpp @@ -13,12 +13,12 @@ ** **/ -#include "theory/quantifiers/ce_guided_single_inv_ei.h" +#include "options/quantifiers_options.h" #include "theory/quantifiers/ce_guided_instantiation.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" +#include "theory/quantifiers/ce_guided_single_inv_ei.h" #include "theory/quantifiers/quant_util.h" +#include "theory/quantifiers/term_database.h" +#include "theory/theory_engine.h" using namespace CVC4; using namespace CVC4::kind; @@ -44,4 +44,4 @@ bool CegEntailmentInfer::getEntailedConjecture( Node& conj, Node& exp ) { return false; } -}
\ No newline at end of file +} diff --git a/src/theory/quantifiers/ce_guided_single_inv_sol.cpp b/src/theory/quantifiers/ce_guided_single_inv_sol.cpp index 8fd935368..6ba5bed02 100644 --- a/src/theory/quantifiers/ce_guided_single_inv_sol.cpp +++ b/src/theory/quantifiers/ce_guided_single_inv_sol.cpp @@ -12,18 +12,18 @@ ** \brief utility for processing single invocation synthesis conjectures ** **/ - #include "theory/quantifiers/ce_guided_single_inv_sol.h" -#include "theory/quantifiers/ce_guided_single_inv.h" + +#include "expr/datatype.h" +#include "options/quantifiers_options.h" +#include "theory/datatypes/datatypes_rewriter.h" #include "theory/quantifiers/ce_guided_instantiation.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" +#include "theory/quantifiers/ce_guided_single_inv.h" #include "theory/quantifiers/first_order_model.h" -#include "theory/datatypes/datatypes_rewriter.h" -#include "util/datatype.h" #include "theory/quantifiers/quant_util.h" +#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/trigger.h" +#include "theory/theory_engine.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/src/theory/quantifiers/ceg_instantiator.cpp b/src/theory/quantifiers/ceg_instantiator.cpp index 7c10da90c..cea90621d 100644 --- a/src/theory/quantifiers/ceg_instantiator.cpp +++ b/src/theory/quantifiers/ceg_instantiator.cpp @@ -11,16 +11,16 @@ ** ** \brief Implementation of counterexample-guided quantifier instantiation **/ - #include "theory/quantifiers/ceg_instantiator.h" -#include "theory/arith/theory_arith.h" + +#include "options/quantifiers_options.h" +#include "smt_util/ite_removal.h" #include "theory/arith/partial_model.h" +#include "theory/arith/theory_arith.h" #include "theory/arith/theory_arith_private.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/first_order_model.h" -#include "util/ite_removal.h" +#include "theory/quantifiers/term_database.h" +#include "theory/theory_engine.h" //#define MBP_STRICT_ASSERTIONS diff --git a/src/theory/quantifiers/ceg_instantiator.h b/src/theory/quantifiers/ceg_instantiator.h index 9504bd407..5b3c5263f 100644 --- a/src/theory/quantifiers/ceg_instantiator.h +++ b/src/theory/quantifiers/ceg_instantiator.h @@ -18,8 +18,8 @@ #ifndef __CVC4__CEG_INSTANTIATOR_H #define __CVC4__CEG_INSTANTIATOR_H +#include "expr/statistics_registry.h" #include "theory/quantifiers_engine.h" -#include "util/statistics_registry.h" namespace CVC4 { namespace theory { diff --git a/src/theory/quantifiers/conjecture_generator.cpp b/src/theory/quantifiers/conjecture_generator.cpp index 1cdad589b..8e083ae1e 100644 --- a/src/theory/quantifiers/conjecture_generator.cpp +++ b/src/theory/quantifiers/conjecture_generator.cpp @@ -13,12 +13,12 @@ ** **/ +#include "options/quantifiers_options.h" #include "theory/quantifiers/conjecture_generator.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" +#include "theory/quantifiers/first_order_model.h" #include "theory/quantifiers/term_database.h" #include "theory/quantifiers/trigger.h" -#include "theory/quantifiers/first_order_model.h" +#include "theory/theory_engine.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/src/theory/quantifiers/first_order_model.cpp b/src/theory/quantifiers/first_order_model.cpp index 36d055b69..095e7868e 100644 --- a/src/theory/quantifiers/first_order_model.cpp +++ b/src/theory/quantifiers/first_order_model.cpp @@ -12,13 +12,13 @@ ** \brief Implementation of model engine model class **/ +#include "options/quantifiers_options.h" +#include "theory/quantifiers/ambqi_builder.h" #include "theory/quantifiers/first_order_model.h" +#include "theory/quantifiers/full_model_check.h" #include "theory/quantifiers/model_engine.h" -#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/quantifiers_attributes.h" -#include "theory/quantifiers/full_model_check.h" -#include "theory/quantifiers/ambqi_builder.h" -#include "theory/quantifiers/options.h" +#include "theory/quantifiers/term_database.h" #define USE_INDEX_ORDERING diff --git a/src/theory/quantifiers/full_model_check.cpp b/src/theory/quantifiers/full_model_check.cpp index c3a723fce..02c6bbba8 100644 --- a/src/theory/quantifiers/full_model_check.cpp +++ b/src/theory/quantifiers/full_model_check.cpp @@ -12,9 +12,9 @@ ** \brief Implementation of full model check class **/ -#include "theory/quantifiers/full_model_check.h" +#include "options/quantifiers_options.h" #include "theory/quantifiers/first_order_model.h" -#include "theory/quantifiers/options.h" +#include "theory/quantifiers/full_model_check.h" #include "theory/quantifiers/term_database.h" using namespace std; diff --git a/src/theory/quantifiers/inst_match_generator.cpp b/src/theory/quantifiers/inst_match_generator.cpp index f4e8861dc..89c2d4868 100644 --- a/src/theory/quantifiers/inst_match_generator.cpp +++ b/src/theory/quantifiers/inst_match_generator.cpp @@ -11,15 +11,15 @@ ** ** [[ Add lengthier description here ]] ** \todo document this file -**/ - + **/ #include "theory/quantifiers/inst_match_generator.h" -#include "theory/quantifiers/trigger.h" -#include "theory/quantifiers/term_database.h" + +#include "expr/datatype.h" +#include "options/quantifiers_options.h" #include "theory/quantifiers/candidate_generator.h" +#include "theory/quantifiers/term_database.h" +#include "theory/quantifiers/trigger.h" #include "theory/quantifiers_engine.h" -#include "theory/quantifiers/options.h" -#include "util/datatype.h" using namespace std; using namespace CVC4; diff --git a/src/theory/quantifiers/inst_strategy_cbqi.cpp b/src/theory/quantifiers/inst_strategy_cbqi.cpp index eff1c0d9b..a4632398d 100644 --- a/src/theory/quantifiers/inst_strategy_cbqi.cpp +++ b/src/theory/quantifiers/inst_strategy_cbqi.cpp @@ -11,17 +11,17 @@ ** ** \brief Implementation of counterexample-guided quantifier instantiation strategies **/ - #include "theory/quantifiers/inst_strategy_cbqi.h" -#include "theory/arith/theory_arith.h" + +#include "options/quantifiers_options.h" +#include "smt_util/ite_removal.h" #include "theory/arith/partial_model.h" +#include "theory/arith/theory_arith.h" #include "theory/arith/theory_arith_private.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/first_order_model.h" +#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/trigger.h" -#include "util/ite_removal.h" +#include "theory/theory_engine.h" using namespace std; using namespace CVC4; diff --git a/src/theory/quantifiers/inst_strategy_cbqi.h b/src/theory/quantifiers/inst_strategy_cbqi.h index d14b85111..b8bc25c6a 100644 --- a/src/theory/quantifiers/inst_strategy_cbqi.h +++ b/src/theory/quantifiers/inst_strategy_cbqi.h @@ -18,11 +18,10 @@ #ifndef __CVC4__INST_STRATEGY_CBQI_H #define __CVC4__INST_STRATEGY_CBQI_H -#include "theory/quantifiers/instantiation_engine.h" +#include "expr/statistics_registry.h" #include "theory/arith/arithvar.h" #include "theory/quantifiers/ceg_instantiator.h" - -#include "util/statistics_registry.h" +#include "theory/quantifiers/instantiation_engine.h" namespace CVC4 { namespace theory { diff --git a/src/theory/quantifiers/inst_strategy_e_matching.cpp b/src/theory/quantifiers/inst_strategy_e_matching.cpp index 9237d95c2..299eb51fd 100644 --- a/src/theory/quantifiers/inst_strategy_e_matching.cpp +++ b/src/theory/quantifiers/inst_strategy_e_matching.cpp @@ -14,11 +14,11 @@ #include "theory/quantifiers/inst_strategy_e_matching.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" +#include "options/quantifiers_options.h" #include "theory/quantifiers/inst_match_generator.h" #include "theory/quantifiers/relevant_domain.h" +#include "theory/quantifiers/term_database.h" +#include "theory/theory_engine.h" using namespace std; using namespace CVC4; @@ -652,4 +652,3 @@ bool FullSaturation::process( Node f, bool fullEffort ){ void FullSaturation::registerQuantifier( Node q ) { } - diff --git a/src/theory/quantifiers/inst_strategy_e_matching.h b/src/theory/quantifiers/inst_strategy_e_matching.h index 2f7e7dcf1..a19bcca76 100644 --- a/src/theory/quantifiers/inst_strategy_e_matching.h +++ b/src/theory/quantifiers/inst_strategy_e_matching.h @@ -17,14 +17,12 @@ #ifndef __CVC4__INST_STRATEGY_E_MATCHING_H #define __CVC4__INST_STRATEGY_E_MATCHING_H -#include "theory/quantifiers_engine.h" -#include "theory/quantifiers/trigger.h" - #include "context/context.h" #include "context/context_mm.h" - -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" #include "theory/quantifiers/instantiation_engine.h" +#include "theory/quantifiers/trigger.h" +#include "theory/quantifiers_engine.h" namespace CVC4 { namespace theory { diff --git a/src/theory/quantifiers/instantiation_engine.cpp b/src/theory/quantifiers/instantiation_engine.cpp index 16cecb657..88a67e3c8 100644 --- a/src/theory/quantifiers/instantiation_engine.cpp +++ b/src/theory/quantifiers/instantiation_engine.cpp @@ -14,12 +14,12 @@ #include "theory/quantifiers/instantiation_engine.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" +#include "options/quantifiers_options.h" #include "theory/quantifiers/first_order_model.h" #include "theory/quantifiers/inst_strategy_e_matching.h" +#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/trigger.h" +#include "theory/theory_engine.h" using namespace std; using namespace CVC4; diff --git a/src/theory/quantifiers/macros.cpp b/src/theory/quantifiers/macros.cpp index 163005806..a5e3dada8 100644 --- a/src/theory/quantifiers/macros.cpp +++ b/src/theory/quantifiers/macros.cpp @@ -14,16 +14,17 @@ ** This class implements quantifiers macro definitions. **/ +#include "theory/quantifiers/macros.h" + #include <vector> -#include "theory/quantifiers/macros.h" -#include "theory/rewriter.h" +#include "options/quantifiers_modes.h" +#include "options/quantifiers_options.h" #include "proof/proof_manager.h" #include "smt/smt_engine_scope.h" -#include "theory/quantifiers/modes.h" -#include "theory/quantifiers/options.h" #include "theory/quantifiers/term_database.h" #include "theory/quantifiers/trigger.h" +#include "theory/rewriter.h" using namespace CVC4; using namespace std; @@ -485,4 +486,4 @@ void QuantifierMacros::addMacro( Node op, Node n, std::vector< Node >& opc ) { } } } -}
\ No newline at end of file +} diff --git a/src/theory/quantifiers/model_builder.cpp b/src/theory/quantifiers/model_builder.cpp index 79b995ef0..dc18548a5 100644 --- a/src/theory/quantifiers/model_builder.cpp +++ b/src/theory/quantifiers/model_builder.cpp @@ -12,18 +12,19 @@ ** \brief Implementation of model builder class **/ +#include "theory/quantifiers/model_builder.h" + +#include "options/quantifiers_options.h" +#include "theory/quantifiers/first_order_model.h" #include "theory/quantifiers/model_engine.h" +#include "theory/quantifiers/quantifiers_attributes.h" +#include "theory/quantifiers/term_database.h" +#include "theory/quantifiers/trigger.h" #include "theory/theory_engine.h" #include "theory/uf/equality_engine.h" #include "theory/uf/theory_uf.h" #include "theory/uf/theory_uf_model.h" #include "theory/uf/theory_uf_strong_solver.h" -#include "theory/quantifiers/first_order_model.h" -#include "theory/quantifiers/term_database.h" -#include "theory/quantifiers/model_builder.h" -#include "theory/quantifiers/quantifiers_attributes.h" -#include "theory/quantifiers/trigger.h" -#include "theory/quantifiers/options.h" using namespace std; using namespace CVC4; @@ -745,5 +746,3 @@ void QModelBuilderDefault::constructModelUf( FirstOrderModel* fm, Node op ){ Debug("fmf-model-cons") << " Finished constructing model for " << op << "." << std::endl; } } - - diff --git a/src/theory/quantifiers/model_engine.cpp b/src/theory/quantifiers/model_engine.cpp index f5a063eb8..6a21a50e5 100644 --- a/src/theory/quantifiers/model_engine.cpp +++ b/src/theory/quantifiers/model_engine.cpp @@ -13,16 +13,17 @@ **/ #include "theory/quantifiers/model_engine.h" + +#include "options/quantifiers_options.h" +#include "theory/quantifiers/ambqi_builder.h" +#include "theory/quantifiers/first_order_model.h" +#include "theory/quantifiers/full_model_check.h" +#include "theory/quantifiers/quantifiers_attributes.h" +#include "theory/quantifiers/term_database.h" #include "theory/theory_engine.h" #include "theory/uf/equality_engine.h" #include "theory/uf/theory_uf.h" #include "theory/uf/theory_uf_strong_solver.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/first_order_model.h" -#include "theory/quantifiers/term_database.h" -#include "theory/quantifiers/quantifiers_attributes.h" -#include "theory/quantifiers/full_model_check.h" -#include "theory/quantifiers/ambqi_builder.h" using namespace std; using namespace CVC4; @@ -335,5 +336,3 @@ ModelEngine::Statistics::~Statistics(){ StatisticsRegistry::unregisterStat(&d_exh_inst_lemmas); StatisticsRegistry::unregisterStat(&d_mbqi_inst_lemmas); } - - diff --git a/src/theory/quantifiers/options_handlers.h b/src/theory/quantifiers/options_handlers.h deleted file mode 100644 index 02a1a6cf2..000000000 --- a/src/theory/quantifiers/options_handlers.h +++ /dev/null @@ -1,480 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: Andrew Reynolds - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** 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__THEORY__QUANTIFIERS__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__QUANTIFIERS__OPTIONS_HANDLERS_H - -#include <string> - -namespace CVC4 { -namespace theory { -namespace quantifiers { - -static const std::string instWhenHelp = "\ -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\ -"; - -static const std::string literalMatchHelp = "\ -Literal match modes currently supported by the --literal-match option:\n\ -\n\ -none (default)\n\ -+ Do not use literal matching.\n\ -\n\ -predicate\n\ -+ Consider the phase requirements of predicate literals when applying heuristic\n\ - quantifier instantiation. For example, the trigger P( x ) in the quantified \n\ - formula forall( x ). ( P( x ) V ~Q( x ) ) will only be matched with ground\n\ - terms P( t ) where P( t ) is in the equivalence class of false, and likewise\n\ - Q( x ) with Q( s ) where Q( s ) is in the equivalence class of true.\n\ -\n\ -"; -static const std::string 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\ -gen-ev \n\ -+ Use model-based quantifier instantiation algorithm from CADE 24 finite\n\ - model finding paper based on generalizing evaluations.\n\ -\n\ -fmc-interval \n\ -+ Same as default, but with intervals for models of integer functions.\n\ -\n\ -abs \n\ -+ Use abstract MBQI algorithm (uses disjoint sets). \n\ -\n\ -"; -static const std::string 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\ -"; -static const std::string 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\ -partial \n\ -+ Apply QCF algorithm to instantiate heuristically as well. \n\ -\n\ -mc \n\ -+ Apply QCF algorithm in a complete way, so that a model is ensured when it fails. \n\ -\n\ -"; -static const std::string 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\ -"; -static const std::string triggerSelModeHelp = "\ -Trigger selection modes currently supported by the --trigger-sel option:\n\ -\n\ -default \n\ -+ Default, consider all subterms of quantified formulas for trigger selection.\n\ -\n\ -min \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\ -"; -static const std::string prenexQuantModeHelp = "\ -Prenex quantifiers modes currently supported by the --prenex-quant option:\n\ -\n\ -default \n\ -+ Default, prenex all nested quantifiers except those with user patterns.\n\ -\n\ -all \n\ -+ Prenex all nested quantifiers.\n\ -\n\ -none \n\ -+ Do no prenex nested quantifiers. \n\ -\n\ -"; -static const std::string cegqiFairModeHelp = "\ -Modes for enforcing fairness for counterexample guided quantifier instantion, supported by --cegqi-fair:\n\ -\n\ -uf-dt-size \n\ -+ Enforce fairness using an uninterpreted function for datatypes size.\n\ -\n\ -default | dt-size \n\ -+ Default, enforce fairness using size theory operator.\n\ -\n\ -dt-height-bound \n\ -+ Enforce fairness by height bound predicate.\n\ -\n\ -none \n\ -+ Do not enforce fairness. \n\ -\n\ -"; -static const std::string termDbModeHelp = "\ -Modes for 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\ -"; -static const std::string 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\ -"; -static const std::string 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\ -"; -static const std::string macrosQuantHelp = "\ -Template 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\ -"; - -inline InstWhenMode stringToInstWhenMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "pre-full") { - return INST_WHEN_PRE_FULL; - } else if(optarg == "full") { - return INST_WHEN_FULL; - } else if(optarg == "full-delay") { - return INST_WHEN_FULL_DELAY; - } else if(optarg == "full-last-call") { - return INST_WHEN_FULL_LAST_CALL; - } else if(optarg == "full-delay-last-call") { - return INST_WHEN_FULL_DELAY_LAST_CALL; - } else if(optarg == "last-call") { - return INST_WHEN_LAST_CALL; - } else if(optarg == "help") { - puts(instWhenHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --inst-when: `") + - optarg + "'. Try --inst-when help."); - } -} - -inline void checkInstWhenMode(std::string option, InstWhenMode mode, SmtEngine* smt) throw(OptionException) { - if(mode == INST_WHEN_PRE_FULL) { - throw OptionException(std::string("Mode pre-full for ") + option + " is not supported in this release."); - } -} - -inline LiteralMatchMode stringToLiteralMatchMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "none") { - return LITERAL_MATCH_NONE; - } else if(optarg == "predicate") { - return LITERAL_MATCH_PREDICATE; - } else if(optarg == "equality") { - return LITERAL_MATCH_EQUALITY; - } else if(optarg == "help") { - puts(literalMatchHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --literal-matching: `") + - optarg + "'. Try --literal-matching help."); - } -} - -inline void checkLiteralMatchMode(std::string option, LiteralMatchMode mode, SmtEngine* smt) throw(OptionException) { - if(mode == LITERAL_MATCH_EQUALITY) { - throw OptionException(std::string("Mode equality for ") + option + " is not supported in this release."); - } -} - -inline MbqiMode stringToMbqiMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "gen-ev") { - return MBQI_GEN_EVAL; - } else if(optarg == "none") { - return MBQI_NONE; - } else if(optarg == "default" || optarg == "fmc") { - return MBQI_FMC; - } else if(optarg == "fmc-interval") { - return MBQI_FMC_INTERVAL; - } else if(optarg == "abs") { - return MBQI_ABS; - } else if(optarg == "trust") { - return MBQI_TRUST; - } else if(optarg == "help") { - puts(mbqiModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --mbqi: `") + - optarg + "'. Try --mbqi help."); - } -} - -inline void checkMbqiMode(std::string option, MbqiMode mode, SmtEngine* smt) throw(OptionException) { - -} - -inline QcfWhenMode stringToQcfWhenMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "default") { - return QCF_WHEN_MODE_DEFAULT; - } else if(optarg == "last-call") { - return QCF_WHEN_MODE_LAST_CALL; - } else if(optarg == "std") { - return QCF_WHEN_MODE_STD; - } else if(optarg == "std-h") { - return QCF_WHEN_MODE_STD_H; - } else if(optarg == "help") { - puts(qcfWhenModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --quant-cf-when: `") + - optarg + "'. Try --quant-cf-when help."); - } -} -inline QcfMode stringToQcfMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "conflict") { - return QCF_CONFLICT_ONLY; - } else if(optarg == "default" || optarg == "prop-eq") { - return QCF_PROP_EQ; - } else if(optarg == "partial") { - return QCF_PARTIAL; - } else if(optarg == "mc" ) { - return QCF_MC; - } else if(optarg == "help") { - puts(qcfModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --quant-cf-mode: `") + - optarg + "'. Try --quant-cf-mode help."); - } -} - -inline UserPatMode stringToUserPatMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "use") { - return USER_PAT_MODE_USE; - } else if(optarg == "default" || optarg == "trust") { - return USER_PAT_MODE_TRUST; - } else if(optarg == "resort") { - return USER_PAT_MODE_RESORT; - } else if(optarg == "ignore") { - return USER_PAT_MODE_IGNORE; - } else if(optarg == "interleave") { - return USER_PAT_MODE_INTERLEAVE; - } else if(optarg == "help") { - puts(userPatModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --user-pat: `") + - optarg + "'. Try --user-pat help."); - } -} - -inline TriggerSelMode stringToTriggerSelMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "default" || optarg == "all" ) { - return TRIGGER_SEL_DEFAULT; - } else if(optarg == "min") { - return TRIGGER_SEL_MIN; - } else if(optarg == "max") { - return TRIGGER_SEL_MAX; - } else if(optarg == "help") { - puts(triggerSelModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --trigger-sel: `") + - optarg + "'. Try --trigger-sel help."); - } -} - -inline PrenexQuantMode stringToPrenexQuantMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "default" ) { - return PRENEX_NO_USER_PAT; - } else if(optarg == "all") { - return PRENEX_ALL; - } else if(optarg == "none") { - return PRENEX_NONE; - } else if(optarg == "help") { - puts(prenexQuantModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --prenex-quant: `") + - optarg + "'. Try --prenex-quant help."); - } -} - -inline CegqiFairMode stringToCegqiFairMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "uf-dt-size" ) { - return CEGQI_FAIR_UF_DT_SIZE; - } else if(optarg == "default" || optarg == "dt-size") { - return CEGQI_FAIR_DT_SIZE; - } else if(optarg == "dt-height-bound" ){ - return CEGQI_FAIR_DT_HEIGHT_PRED; - } else if(optarg == "none") { - return CEGQI_FAIR_NONE; - } else if(optarg == "help") { - puts(cegqiFairModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --cegqi-fair: `") + - optarg + "'. Try --cegqi-fair help."); - } -} - -inline TermDbMode stringToTermDbMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "all" ) { - return TERM_DB_ALL; - } else if(optarg == "relevant") { - return TERM_DB_RELEVANT; - } else if(optarg == "help") { - puts(termDbModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --term-db-mode: `") + - optarg + "'. Try --term-db-mode help."); - } -} - -inline IteLiftQuantMode stringToIteLiftQuantMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "all" ) { - return ITE_LIFT_QUANT_MODE_ALL; - } else if(optarg == "simple") { - return ITE_LIFT_QUANT_MODE_SIMPLE; - } else if(optarg == "none") { - return ITE_LIFT_QUANT_MODE_NONE; - } else if(optarg == "help") { - puts(iteLiftQuantHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --ite-lift-quant: `") + - optarg + "'. Try --ite-lift-quant help."); - } -} - -inline SygusInvTemplMode stringToSygusInvTemplMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "none" ) { - return SYGUS_INV_TEMPL_MODE_NONE; - } else if(optarg == "pre") { - return SYGUS_INV_TEMPL_MODE_PRE; - } else if(optarg == "post") { - return SYGUS_INV_TEMPL_MODE_POST; - } else if(optarg == "help") { - puts(sygusInvTemplHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --sygus-inv-templ: `") + - optarg + "'. Try --sygus-inv-templ help."); - } -} - -inline MacrosQuantMode stringToMacrosQuantMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "all" ) { - return MACROS_QUANT_MODE_ALL; - } else if(optarg == "ground") { - return MACROS_QUANT_MODE_GROUND; - } else if(optarg == "ground-uf") { - return MACROS_QUANT_MODE_GROUND_UF; - } else if(optarg == "help") { - puts(macrosQuantHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --macros-quant-mode: `") + - optarg + "'. Try --macros-quant-mode help."); - } -} - -}/* CVC4::theory::quantifiers namespace */ -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__THEORY__QUANTIFIERS__OPTIONS_HANDLERS_H */ diff --git a/src/theory/quantifiers/quant_conflict_find.cpp b/src/theory/quantifiers/quant_conflict_find.cpp index ca5d23cd1..b6256980a 100644 --- a/src/theory/quantifiers/quant_conflict_find.cpp +++ b/src/theory/quantifiers/quant_conflict_find.cpp @@ -13,14 +13,15 @@ ** **/ +#include "theory/quantifiers/quant_conflict_find.h" + #include <vector> -#include "theory/quantifiers/quant_conflict_find.h" +#include "options/quantifiers_options.h" #include "theory/quantifiers/quant_util.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" #include "theory/quantifiers/term_database.h" #include "theory/quantifiers/trigger.h" +#include "theory/theory_engine.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/src/theory/quantifiers/quantifiers_attributes.cpp b/src/theory/quantifiers/quantifiers_attributes.cpp index ef5b71f9d..8c6b30124 100644 --- a/src/theory/quantifiers/quantifiers_attributes.cpp +++ b/src/theory/quantifiers/quantifiers_attributes.cpp @@ -13,7 +13,8 @@ **/ #include "theory/quantifiers/quantifiers_attributes.h" -#include "theory/quantifiers/options.h" + +#include "options/quantifiers_options.h" #include "theory/quantifiers/term_database.h" using namespace std; diff --git a/src/theory/quantifiers/quantifiers_rewriter.cpp b/src/theory/quantifiers/quantifiers_rewriter.cpp index 1e2ac21a0..0afc8b1bb 100644 --- a/src/theory/quantifiers/quantifiers_rewriter.cpp +++ b/src/theory/quantifiers/quantifiers_rewriter.cpp @@ -13,9 +13,10 @@ **/ #include "theory/quantifiers/quantifiers_rewriter.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" + +#include "options/quantifiers_options.h" #include "theory/datatypes/datatypes_rewriter.h" +#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/trigger.h" using namespace std; diff --git a/src/theory/quantifiers/rewrite_engine.cpp b/src/theory/quantifiers/rewrite_engine.cpp index a70d36ac0..4c8050239 100644 --- a/src/theory/quantifiers/rewrite_engine.cpp +++ b/src/theory/quantifiers/rewrite_engine.cpp @@ -15,13 +15,14 @@ **/ #include "theory/quantifiers/rewrite_engine.h" -#include "theory/quantifiers/quant_util.h" + +#include "options/quantifiers_options.h" #include "theory/quantifiers/first_order_model.h" -#include "theory/quantifiers/model_engine.h" -#include "theory/quantifiers/options.h" #include "theory/quantifiers/inst_match_generator.h" -#include "theory/theory_engine.h" +#include "theory/quantifiers/model_engine.h" +#include "theory/quantifiers/quant_util.h" #include "theory/quantifiers/term_database.h" +#include "theory/theory_engine.h" using namespace CVC4; using namespace std; diff --git a/src/theory/quantifiers/symmetry_breaking.cpp b/src/theory/quantifiers/symmetry_breaking.cpp index 12b16ef06..4c8e24d08 100644 --- a/src/theory/quantifiers/symmetry_breaking.cpp +++ b/src/theory/quantifiers/symmetry_breaking.cpp @@ -13,15 +13,16 @@ ** **/ +#include "theory/quantifiers/symmetry_breaking.h" + #include <vector> -#include "theory/quantifiers/symmetry_breaking.h" -#include "theory/rewriter.h" #include "theory/quantifiers_engine.h" +#include "theory/rewriter.h" +#include "theory/sort_inference.h" #include "theory/theory_engine.h" -#include "util/sort_inference.h" -#include "theory/uf/theory_uf_strong_solver.h" #include "theory/uf/theory_uf.h" +#include "theory/uf/theory_uf_strong_solver.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/src/theory/quantifiers/symmetry_breaking.h b/src/theory/quantifiers/symmetry_breaking.h index c3ba92214..43e5ec765 100644 --- a/src/theory/quantifiers/symmetry_breaking.h +++ b/src/theory/quantifiers/symmetry_breaking.h @@ -17,20 +17,19 @@ #ifndef __CVC4__QUANT_SYMMETRY_BREAKING_H #define __CVC4__QUANT_SYMMETRY_BREAKING_H -#include "theory/theory.h" - #include <iostream> +#include <map> #include <string> #include <vector> -#include <map> -#include "expr/node.h" -#include "expr/type_node.h" -#include "util/sort_inference.h" +#include "context/cdchunk_list.h" +#include "context/cdhashmap.h" #include "context/context.h" #include "context/context_mm.h" -#include "context/cdhashmap.h" -#include "context/cdchunk_list.h" +#include "expr/node.h" +#include "expr/type_node.h" +#include "theory/sort_inference.h" +#include "theory/theory.h" namespace CVC4 { namespace theory { diff --git a/src/theory/quantifiers/term_database.cpp b/src/theory/quantifiers/term_database.cpp index 724f16947..f3bbc65cc 100644 --- a/src/theory/quantifiers/term_database.cpp +++ b/src/theory/quantifiers/term_database.cpp @@ -13,22 +13,23 @@ **/ #include "theory/quantifiers/term_database.h" -#include "theory/quantifiers_engine.h" -#include "theory/quantifiers/trigger.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers/first_order_model.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/theory_quantifiers.h" -#include "util/datatype.h" + +#include "expr/datatype.h" +#include "options/quantifiers_options.h" #include "theory/datatypes/datatypes_rewriter.h" #include "theory/quantifiers/ce_guided_instantiation.h" -#include "theory/quantifiers/rewrite_engine.h" +#include "theory/quantifiers/first_order_model.h" #include "theory/quantifiers/fun_def_engine.h" +#include "theory/quantifiers/rewrite_engine.h" +#include "theory/quantifiers/theory_quantifiers.h" +#include "theory/quantifiers/trigger.h" +#include "theory/quantifiers_engine.h" +#include "theory/theory_engine.h" //for sygus +#include "smt/smt_engine_scope.h" #include "theory/bv/theory_bv_utils.h" #include "util/bitvector.h" -#include "smt/smt_engine_scope.h" using namespace std; using namespace CVC4; @@ -2807,4 +2808,3 @@ void TermDbSygus::printSygusTerm( std::ostream& out, Node n, std::vector< Node > out << n; } } - diff --git a/src/theory/quantifiers/theory_quantifiers.cpp b/src/theory/quantifiers/theory_quantifiers.cpp index 48891732b..e9ff60137 100644 --- a/src/theory/quantifiers/theory_quantifiers.cpp +++ b/src/theory/quantifiers/theory_quantifiers.cpp @@ -14,17 +14,18 @@ ** Implementation of the theory of quantifiers. **/ - #include "theory/quantifiers/theory_quantifiers.h" -#include "theory/valuation.h" -#include "theory/quantifiers_engine.h" + + +#include "base/cvc4_assert.h" +#include "expr/kind.h" +#include "options/quantifiers_options.h" #include "theory/quantifiers/instantiation_engine.h" #include "theory/quantifiers/model_engine.h" -#include "expr/kind.h" -#include "util/cvc4_assert.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/quantifiers_attributes.h" +#include "theory/quantifiers/term_database.h" +#include "theory/quantifiers_engine.h" +#include "theory/valuation.h" using namespace std; using namespace CVC4; diff --git a/src/theory/quantifiers/theory_quantifiers.h b/src/theory/quantifiers/theory_quantifiers.h index 0f16f0e80..98f486145 100644 --- a/src/theory/quantifiers/theory_quantifiers.h +++ b/src/theory/quantifiers/theory_quantifiers.h @@ -19,15 +19,15 @@ #ifndef __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_H #define __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_H -#include "context/cdhashmap.h" -#include "theory/theory.h" -#include "util/hash.h" -#include "util/statistics_registry.h" - #include <ext/hash_set> #include <iostream> #include <map> +#include "context/cdhashmap.h" +#include "expr/statistics_registry.h" +#include "theory/theory.h" +#include "util/hash.h" + namespace CVC4 { class TheoryEngine; diff --git a/src/theory/quantifiers/theory_quantifiers_type_rules.h b/src/theory/quantifiers/theory_quantifiers_type_rules.h index 3ce0250fe..1fb8ddaf9 100644 --- a/src/theory/quantifiers/theory_quantifiers_type_rules.h +++ b/src/theory/quantifiers/theory_quantifiers_type_rules.h @@ -19,7 +19,7 @@ #ifndef __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_TYPE_RULES_H #define __CVC4__THEORY__QUANTIFIERS__THEORY_QUANTIFIERS_TYPE_RULES_H -#include "util/matcher.h" +#include "expr/matcher.h" namespace CVC4 { namespace theory { diff --git a/src/theory/quantifiers/trigger.cpp b/src/theory/quantifiers/trigger.cpp index fdfa77b02..9aee18317 100644 --- a/src/theory/quantifiers/trigger.cpp +++ b/src/theory/quantifiers/trigger.cpp @@ -13,13 +13,14 @@ **/ #include "theory/quantifiers/trigger.h" -#include "theory/theory_engine.h" -#include "theory/quantifiers_engine.h" + +#include "options/quantifiers_options.h" #include "theory/quantifiers/candidate_generator.h" -#include "theory/uf/equality_engine.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/term_database.h" #include "theory/quantifiers/inst_match_generator.h" +#include "theory/quantifiers/term_database.h" +#include "theory/quantifiers_engine.h" +#include "theory/theory_engine.h" +#include "theory/uf/equality_engine.h" using namespace std; using namespace CVC4; diff --git a/src/theory/quantifiers_engine.cpp b/src/theory/quantifiers_engine.cpp index 2c4c58900..e46c59dc0 100644 --- a/src/theory/quantifiers_engine.cpp +++ b/src/theory/quantifiers_engine.cpp @@ -13,34 +13,35 @@ **/ #include "theory/quantifiers_engine.h" -#include "theory/theory_engine.h" -#include "theory/uf/theory_uf_strong_solver.h" -#include "theory/uf/equality_engine.h" + +#include "options/quantifiers_options.h" +#include "options/uf_options.h" #include "theory/arrays/theory_arrays.h" #include "theory/datatypes/theory_datatypes.h" -#include "theory/quantifiers/quantifiers_rewriter.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/model_engine.h" -#include "theory/quantifiers/instantiation_engine.h" -#include "theory/quantifiers/first_order_model.h" -#include "theory/quantifiers/term_database.h" -#include "theory/quantifiers/trigger.h" +#include "theory/quantifiers/alpha_equivalence.h" +#include "theory/quantifiers/ambqi_builder.h" #include "theory/quantifiers/bounded_integers.h" -#include "theory/quantifiers/rewrite_engine.h" -#include "theory/quantifiers/quant_conflict_find.h" -#include "theory/quantifiers/conjecture_generator.h" #include "theory/quantifiers/ce_guided_instantiation.h" -#include "theory/quantifiers/local_theory_ext.h" -#include "theory/quantifiers/relevant_domain.h" -#include "theory/quantifiers/alpha_equivalence.h" -#include "theory/uf/options.h" -#include "theory/uf/theory_uf.h" +#include "theory/quantifiers/conjecture_generator.h" +#include "theory/quantifiers/first_order_model.h" #include "theory/quantifiers/full_model_check.h" -#include "theory/quantifiers/ambqi_builder.h" #include "theory/quantifiers/fun_def_engine.h" -#include "theory/quantifiers/quant_equality_engine.h" -#include "theory/quantifiers/inst_strategy_e_matching.h" #include "theory/quantifiers/inst_strategy_cbqi.h" +#include "theory/quantifiers/inst_strategy_e_matching.h" +#include "theory/quantifiers/instantiation_engine.h" +#include "theory/quantifiers/local_theory_ext.h" +#include "theory/quantifiers/model_engine.h" +#include "theory/quantifiers/quant_conflict_find.h" +#include "theory/quantifiers/quant_equality_engine.h" +#include "theory/quantifiers/quantifiers_rewriter.h" +#include "theory/quantifiers/relevant_domain.h" +#include "theory/quantifiers/rewrite_engine.h" +#include "theory/quantifiers/term_database.h" +#include "theory/quantifiers/trigger.h" +#include "theory/theory_engine.h" +#include "theory/uf/equality_engine.h" +#include "theory/uf/theory_uf.h" +#include "theory/uf/theory_uf_strong_solver.h" using namespace std; using namespace CVC4; diff --git a/src/theory/quantifiers_engine.h b/src/theory/quantifiers_engine.h index bbf3fad61..ba41b2ca3 100644 --- a/src/theory/quantifiers_engine.h +++ b/src/theory/quantifiers_engine.h @@ -17,20 +17,19 @@ #ifndef __CVC4__THEORY__QUANTIFIERS_ENGINE_H #define __CVC4__THEORY__QUANTIFIERS_ENGINE_H -#include "theory/theory.h" -#include "util/hash.h" -#include "theory/quantifiers/inst_match.h" -#include "theory/quantifiers/quant_util.h" -#include "theory/quantifiers/modes.h" -#include "expr/attribute.h" - -#include "util/statistics_registry.h" - #include <ext/hash_set> #include <iostream> #include <map> + #include "context/cdchunk_list.h" #include "context/cdhashset.h" +#include "expr/attribute.h" +#include "expr/statistics_registry.h" +#include "options/quantifiers_modes.h" +#include "theory/quantifiers/inst_match.h" +#include "theory/quantifiers/quant_util.h" +#include "theory/theory.h" +#include "util/hash.h" namespace CVC4 { diff --git a/src/theory/rewriter.cpp b/src/theory/rewriter.cpp index 842df69c5..758f4a913 100644 --- a/src/theory/rewriter.cpp +++ b/src/theory/rewriter.cpp @@ -15,11 +15,12 @@ ** \todo document this file **/ -#include "theory/theory.h" #include "theory/rewriter.h" + +#include "expr/resource_manager.h" +#include "theory/theory.h" #include "theory/rewriter_tables.h" #include "smt/smt_engine_scope.h" -#include "util/resource_manager.h" using namespace std; diff --git a/src/theory/rewriter.h b/src/theory/rewriter.h index 44035e7d9..5ad6adca8 100644 --- a/src/theory/rewriter.h +++ b/src/theory/rewriter.h @@ -21,8 +21,6 @@ #include "expr/node.h" #include "util/unsafe_interrupt_exception.h" -//#include "expr/attribute.h" - namespace CVC4 { namespace theory { diff --git a/src/theory/sets/expr_patterns.h b/src/theory/sets/expr_patterns.h index 86f12082a..f293d0714 100644 --- a/src/theory/sets/expr_patterns.h +++ b/src/theory/sets/expr_patterns.h @@ -18,6 +18,8 @@ #pragma once +#include "expr/node.h" + namespace CVC4 { namespace expr { namespace pattern { diff --git a/src/theory/sets/kinds b/src/theory/sets/kinds index 39e7883c6..a43902b1b 100644 --- a/src/theory/sets/kinds +++ b/src/theory/sets/kinds @@ -18,7 +18,7 @@ properties check propagate constant EMPTYSET \ ::CVC4::EmptySet \ ::CVC4::EmptySetHashFunction \ - "util/emptyset.h" \ + "expr/emptyset.h" \ "the empty set constant; payload is an instance of the CVC4::EmptySet class" # the type diff --git a/src/theory/sets/theory_sets_private.cpp b/src/theory/sets/theory_sets_private.cpp index 4054f3e21..f200397bc 100644 --- a/src/theory/sets/theory_sets_private.cpp +++ b/src/theory/sets/theory_sets_private.cpp @@ -14,18 +14,17 @@ ** Sets theory implementation. **/ +#include "theory/sets/theory_sets_private.h" + #include <boost/foreach.hpp> -#include "theory/theory_model.h" +#include "expr/emptyset.h" +#include "expr/result.h" +#include "options/sets_options.h" +#include "theory/sets/expr_patterns.h" // ONLY included here #include "theory/sets/scrutinize.h" #include "theory/sets/theory_sets.h" -#include "theory/sets/theory_sets_private.h" - -#include "theory/sets/options.h" -#include "theory/sets/expr_patterns.h" // ONLY included here - -#include "util/emptyset.h" -#include "util/result.h" +#include "theory/theory_model.h" using namespace std; using namespace CVC4::expr::pattern; diff --git a/src/theory/shared_terms_database.h b/src/theory/shared_terms_database.h index e01a407e1..fd45cca15 100644 --- a/src/theory/shared_terms_database.h +++ b/src/theory/shared_terms_database.h @@ -17,11 +17,11 @@ #pragma once +#include "context/cdhashset.h" #include "expr/node.h" +#include "expr/statistics_registry.h" #include "theory/theory.h" #include "theory/uf/equality_engine.h" -#include "util/statistics_registry.h" -#include "context/cdhashset.h" namespace CVC4 { diff --git a/src/util/sort_inference.cpp b/src/theory/sort_inference.cpp index c88d9adff..a26c0e9d7 100644 --- a/src/util/sort_inference.cpp +++ b/src/theory/sort_inference.cpp @@ -17,16 +17,16 @@ ** maintains necessary information regarding constraints on these types. **/ +#include "theory/sort_inference.h" + #include <vector> -#include "util/sort_inference.h" -#include "theory/uf/options.h" -#include "smt/options.h" -#include "theory/rewriter.h" -#include "theory/quantifiers/options.h" +#include "options/quantifiers_options.h" +#include "options/smt_options.h" +#include "options/uf_options.h" #include "proof/proof_manager.h" +#include "theory/rewriter.h" -using namespace CVC4; using namespace std; namespace CVC4 { @@ -40,6 +40,7 @@ void SortInference::UnionFind::print(const char * c){ } Trace(c) << std::endl; } + void SortInference::UnionFind::set( UnionFind& c ) { clear(); for( std::map< int, int >::iterator it = c.d_eqc.begin(); it != c.d_eqc.end(); ++it ){ @@ -47,6 +48,7 @@ void SortInference::UnionFind::set( UnionFind& c ) { } d_deq.insert( d_deq.end(), c.d_deq.begin(), c.d_deq.end() ); } + int SortInference::UnionFind::getRepresentative( int t ){ std::map< int, int >::iterator it = d_eqc.find( t ); if( it==d_eqc.end() || it->second==t ){ @@ -57,6 +59,7 @@ int SortInference::UnionFind::getRepresentative( int t ){ return rt; } } + void SortInference::UnionFind::setEqual( int t1, int t2 ){ if( t1!=t2 ){ int rt1 = getRepresentative( t1 ); @@ -68,6 +71,7 @@ void SortInference::UnionFind::setEqual( int t1, int t2 ){ } } } + bool SortInference::UnionFind::isValid() { for( unsigned i=0; i<d_deq.size(); i++ ){ if( areEqual( d_deq[i].first, d_deq[i].second ) ){ diff --git a/src/util/sort_inference.h b/src/theory/sort_inference.h index 4bb1a072e..4bb1a072e 100644 --- a/src/util/sort_inference.h +++ b/src/theory/sort_inference.h diff --git a/src/theory/strings/regexp_operation.cpp b/src/theory/strings/regexp_operation.cpp index ac4bddd73..98f03327a 100644 --- a/src/theory/strings/regexp_operation.cpp +++ b/src/theory/strings/regexp_operation.cpp @@ -15,8 +15,9 @@ **/ #include "theory/strings/regexp_operation.h" + #include "expr/kind.h" -#include "theory/strings/options.h" +#include "options/strings_options.h" namespace CVC4 { namespace theory { diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp index d4a3cf9c5..dfd3c4803 100644 --- a/src/theory/strings/theory_strings.cpp +++ b/src/theory/strings/theory_strings.cpp @@ -14,18 +14,19 @@ ** Implementation of the theory of strings. **/ - #include "theory/strings/theory_strings.h" -#include "theory/valuation.h" + +#include <cmath> + #include "expr/kind.h" -#include "theory/rewriter.h" -#include "expr/command.h" -#include "theory/theory_model.h" +#include "options/strings_options.h" #include "smt/logic_exception.h" -#include "theory/strings/options.h" -#include "theory/strings/type_enumerator.h" +#include "smt_util/command.h" +#include "theory/rewriter.h" #include "theory/strings/theory_strings_rewriter.h" -#include <cmath> +#include "theory/strings/type_enumerator.h" +#include "theory/theory_model.h" +#include "theory/valuation.h" using namespace std; using namespace CVC4::context; diff --git a/src/theory/strings/theory_strings_preprocess.cpp b/src/theory/strings/theory_strings_preprocess.cpp index 80eb89cc3..a1c93a369 100644 --- a/src/theory/strings/theory_strings_preprocess.cpp +++ b/src/theory/strings/theory_strings_preprocess.cpp @@ -15,11 +15,14 @@ **/ #include "theory/strings/theory_strings_preprocess.h" -#include "expr/kind.h" -#include "theory/strings/options.h" -#include "smt/logic_exception.h" + #include <stdint.h> + +#include "expr/kind.h" +#include "options/strings_options.h" #include "proof/proof_manager.h" +#include "smt/logic_exception.h" + namespace CVC4 { namespace theory { diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp index e0e295d40..733471288 100644 --- a/src/theory/strings/theory_strings_rewriter.cpp +++ b/src/theory/strings/theory_strings_rewriter.cpp @@ -13,11 +13,14 @@ ** ** Implementation of the theory of strings. **/ + #include "theory/strings/theory_strings_rewriter.h" -#include "theory/strings/options.h" -#include "smt/logic_exception.h" + #include <stdint.h> +#include "options/strings_options.h" +#include "smt/logic_exception.h" + using namespace std; using namespace CVC4; using namespace CVC4::kind; diff --git a/src/theory/strings/theory_strings_type_rules.h b/src/theory/strings/theory_strings_type_rules.h index 13f3b3b73..aff033338 100644 --- a/src/theory/strings/theory_strings_type_rules.h +++ b/src/theory/strings/theory_strings_type_rules.h @@ -15,7 +15,7 @@ **/ #include "cvc4_private.h" -#include "theory/strings/options.h" +#include "options/strings_options.h" #ifndef __CVC4__THEORY__STRINGS__THEORY_STRINGS_TYPE_RULES_H #define __CVC4__THEORY__STRINGS__THEORY_STRINGS_TYPE_RULES_H diff --git a/src/theory/term_registration_visitor.cpp b/src/theory/term_registration_visitor.cpp index 7ece4594d..2aa00a177 100644 --- a/src/theory/term_registration_visitor.cpp +++ b/src/theory/term_registration_visitor.cpp @@ -14,8 +14,9 @@ **/ #include "theory/term_registration_visitor.h" + +#include "options/quantifiers_options.h" #include "theory/theory_engine.h" -#include "theory/quantifiers/options.h" using namespace std; using namespace CVC4; diff --git a/src/theory/theory.cpp b/src/theory/theory.cpp index 62f2a5ec2..05795ca8f 100644 --- a/src/theory/theory.cpp +++ b/src/theory/theory.cpp @@ -15,12 +15,14 @@ **/ #include "theory/theory.h" -#include "util/cvc4_assert.h" -#include "theory/quantifiers_engine.h" -#include "theory/substitutions.h" #include <vector> +#include "base/cvc4_assert.h" +#include "theory/substitutions.h" +#include "theory/quantifiers_engine.h" + + using namespace std; namespace CVC4 { diff --git a/src/theory/theory.h b/src/theory/theory.h index 2dab434d1..5f4c80cf2 100644 --- a/src/theory/theory.h +++ b/src/theory/theory.h @@ -19,28 +19,26 @@ #ifndef __CVC4__THEORY__THEORY_H #define __CVC4__THEORY__THEORY_H -#include "expr/node.h" -//#include "expr/attribute.h" -#include "expr/command.h" -#include "smt/logic_request.h" -#include "theory/valuation.h" -#include "theory/output_channel.h" -#include "theory/logic_info.h" -#include "theory/options.h" -#include "theory/theoryof_mode.h" -#include "context/context.h" +#include <ext/hash_set> +#include <iostream> +#include <string> +#include <strings.h> + #include "context/cdlist.h" #include "context/cdo.h" -#include "options/options.h" -#include "util/statistics_registry.h" -#include "util/dump.h" +#include "context/context.h" +#include "expr/node.h" +#include "expr/statistics_registry.h" #include "lib/ffs.h" - -#include <string> -#include <iostream> - -#include <strings.h> -#include <ext/hash_set> +#include "options/options.h" +#include "options/theory_options.h" +#include "options/theoryof_mode.h" +#include "smt/logic_request.h" +#include "smt_util/command.h" +#include "smt_util/dump.h" +#include "theory/logic_info.h" +#include "theory/output_channel.h" +#include "theory/valuation.h" namespace CVC4 { diff --git a/src/theory/theory_engine.cpp b/src/theory/theory_engine.cpp index b5a2a1390..52922e2ca 100644 --- a/src/theory/theory_engine.cpp +++ b/src/theory/theory_engine.cpp @@ -14,51 +14,38 @@ ** The theory engine. **/ -#include <vector> -#include <list> +#include "theory/theory_engine.h" -#include "theory/arith/arith_ite_utils.h" +#include <list> +#include <vector> #include "decision/decision_engine.h" - #include "expr/attribute.h" #include "expr/node.h" #include "expr/node_builder.h" +#include "expr/resource_manager.h" +#include "options/bv_options.h" #include "options/options.h" -#include "util/lemma_output_channel.h" -#include "util/resource_manager.h" - -#include "theory/theory.h" -#include "theory/theory_engine.h" -#include "theory/rewriter.h" -#include "theory/theory_traits.h" - -#include "smt/logic_exception.h" - +#include "options/quantifiers_options.h" #include "proof/proof_manager.h" - -#include "util/node_visitor.h" -#include "util/ite_removal.h" - -//#include "theory/ite_simplifier.h" -//#include "theory/ite_compressor.h" +#include "proof/proof_manager.h" +#include "smt/logic_exception.h" +#include "smt_util/ite_removal.h" +#include "smt_util/lemma_output_channel.h" +#include "smt_util/node_visitor.h" +#include "theory/arith/arith_ite_utils.h" +#include "theory/bv/theory_bv_utils.h" #include "theory/ite_utilities.h" -#include "theory/unconstrained_simplifier.h" - -#include "theory/theory_model.h" - -#include "theory/quantifiers_engine.h" -#include "theory/quantifiers/theory_quantifiers.h" -#include "theory/quantifiers/options.h" -#include "theory/quantifiers/model_engine.h" #include "theory/quantifiers/first_order_model.h" - +#include "theory/quantifiers/model_engine.h" +#include "theory/quantifiers/theory_quantifiers.h" +#include "theory/quantifiers_engine.h" +#include "theory/rewriter.h" +#include "theory/theory.h" +#include "theory/theory_model.h" +#include "theory/theory_traits.h" #include "theory/uf/equality_engine.h" -//#include "theory/rewriterules/efficient_e_matching.h" -#include "theory/bv/theory_bv_utils.h" -#include "theory/bv/options.h" - -#include "proof/proof_manager.h" +#include "theory/unconstrained_simplifier.h" using namespace std; diff --git a/src/theory/theory_engine.h b/src/theory/theory_engine.h index b28a73b9d..0355256a3 100644 --- a/src/theory/theory_engine.h +++ b/src/theory/theory_engine.h @@ -23,32 +23,32 @@ #include <vector> #include <utility> +#include "base/cvc4_assert.h" +#include "context/cdhashset.h" #include "expr/node.h" -#include "expr/command.h" +#include "expr/statistics_registry.h" +#include "options/options.h" +#include "options/smt_options.h" #include "prop/prop_engine.h" -#include "context/cdhashset.h" -#include "theory/theory.h" +#include "smt_util/command.h" +#include "theory/atom_requests.h" +#include "theory/bv/bv_to_bool.h" +#include "theory/interrupted.h" +#include "theory/quantifiers/quant_conflict_find.h" #include "theory/rewriter.h" -#include "theory/substitutions.h" #include "theory/shared_terms_database.h" +#include "theory/sort_inference.h" +#include "theory/substitutions.h" #include "theory/term_registration_visitor.h" +#include "theory/theory.h" +#include "theory/uf/equality_engine.h" #include "theory/valuation.h" -#include "theory/interrupted.h" -#include "options/options.h" -#include "smt/options.h" -#include "util/statistics_registry.h" -#include "util/cvc4_assert.h" -#include "util/sort_inference.h" #include "util/unsafe_interrupt_exception.h" -#include "theory/quantifiers/quant_conflict_find.h" -#include "theory/uf/equality_engine.h" -#include "theory/bv/bv_to_bool.h" -#include "theory/atom_requests.h" namespace CVC4 { class ResourceManager; - + /** * A pair of a theory and a node. This is used to mark the flow of * propagations between theories. diff --git a/src/theory/theory_model.cpp b/src/theory/theory_model.cpp index 44e4193eb..a39d74bb0 100644 --- a/src/theory/theory_model.cpp +++ b/src/theory/theory_model.cpp @@ -11,15 +11,15 @@ ** ** \brief Implementation of model class **/ - #include "theory/theory_model.h" + +#include "options/smt_options.h" +#include "options/uf_options.h" +#include "smt/smt_engine.h" #include "theory/quantifiers_engine.h" #include "theory/theory_engine.h" #include "theory/type_enumerator.h" -#include "smt/options.h" -#include "smt/smt_engine.h" #include "theory/uf/theory_uf_model.h" -#include "theory/uf/options.h" using namespace std; using namespace CVC4; diff --git a/src/theory/theory_model.h b/src/theory/theory_model.h index e023edadd..fb2c3cd01 100644 --- a/src/theory/theory_model.h +++ b/src/theory/theory_model.h @@ -17,7 +17,7 @@ #ifndef __CVC4__THEORY__THEORY_MODEL_H #define __CVC4__THEORY__THEORY_MODEL_H -#include "util/model.h" +#include "smt_util/model.h" #include "theory/uf/equality_engine.h" #include "theory/rep_set.h" #include "theory/substitutions.h" diff --git a/src/theory/theory_test_utils.h b/src/theory/theory_test_utils.h index 6fe92eb6e..f493e253e 100644 --- a/src/theory/theory_test_utils.h +++ b/src/theory/theory_test_utils.h @@ -19,16 +19,16 @@ #ifndef __CVC4__THEORY__THEORY_TEST_UTILS_H #define __CVC4__THEORY__THEORY_TEST_UTILS_H -#include "util/cvc4_assert.h" +#include <iostream> +#include <utility> +#include <vector> + +#include "base/cvc4_assert.h" #include "expr/node.h" -#include "theory/output_channel.h" #include "theory/interrupted.h" +#include "theory/output_channel.h" #include "util/unsafe_interrupt_exception.h" -#include <vector> -#include <utility> -#include <iostream> - namespace CVC4 { namespace theory { diff --git a/src/theory/theory_traits_template.h b/src/theory/theory_traits_template.h index b052fb58f..b0e7010b7 100644 --- a/src/theory/theory_traits_template.h +++ b/src/theory/theory_traits_template.h @@ -21,8 +21,8 @@ #pragma once +#include "options/theory_options.h" #include "theory/theory.h" -#include "theory/options.h" ${theory_includes} diff --git a/src/theory/type_enumerator.h b/src/theory/type_enumerator.h index d8006a5a4..015cbb288 100644 --- a/src/theory/type_enumerator.h +++ b/src/theory/type_enumerator.h @@ -19,10 +19,10 @@ #ifndef __CVC4__THEORY__TYPE_ENUMERATOR_H #define __CVC4__THEORY__TYPE_ENUMERATOR_H -#include "util/exception.h" +#include "base/exception.h" +#include "base/cvc4_assert.h" #include "expr/node.h" #include "expr/type_node.h" -#include "util/cvc4_assert.h" namespace CVC4 { namespace theory { diff --git a/src/theory/type_enumerator_template.cpp b/src/theory/type_enumerator_template.cpp index ca2413f90..f0eafed18 100644 --- a/src/theory/type_enumerator_template.cpp +++ b/src/theory/type_enumerator_template.cpp @@ -16,10 +16,10 @@ #include <sstream> +#include "base/cvc4_assert.h" +#include "expr/kind.h" #include "theory/type_enumerator.h" -#include "expr/kind.h" -#include "util/cvc4_assert.h" ${type_enumerator_includes} #line 26 "${template}" diff --git a/src/theory/uf/equality_engine.h b/src/theory/uf/equality_engine.h index a26947ed1..f7f7f9ddd 100644 --- a/src/theory/uf/equality_engine.h +++ b/src/theory/uf/equality_engine.h @@ -19,20 +19,19 @@ #pragma once -#include <queue> #include <deque> -#include <vector> #include <ext/hash_map> +#include <queue> +#include <vector> -#include "expr/node.h" -#include "expr/kind_map.h" -#include "context/cdo.h" +#include "base/output.h" #include "context/cdhashmap.h" -#include "util/output.h" -#include "util/statistics_registry.h" +#include "context/cdo.h" +#include "expr/kind_map.h" +#include "expr/node.h" +#include "expr/statistics_registry.h" #include "theory/rewriter.h" #include "theory/theory.h" - #include "theory/uf/equality_engine_types.h" namespace CVC4 { diff --git a/src/theory/uf/options_handlers.h b/src/theory/uf/options_handlers.h deleted file mode 100644 index 8c072e232..000000000 --- a/src/theory/uf/options_handlers.h +++ /dev/null @@ -1,70 +0,0 @@ -/********************* */ -/*! \file options_handlers.h - ** \verbatim - ** Original author: Morgan Deters - ** Major contributors: Andrew Reynolds - ** Minor contributors (to current version): none - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2014 New York University and The University of Iowa - ** 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__THEORY__UF__OPTIONS_HANDLERS_H -#define __CVC4__THEORY__UF__OPTIONS_HANDLERS_H - -namespace CVC4 { -namespace theory { -namespace uf { - -typedef enum { - /** default, use uf strong solver to find minimal models for uninterpreted sorts */ - UF_SS_FULL, - /** use uf strong solver to shrink model sizes, but do no enforce minimality */ - UF_SS_NO_MINIMAL, - /** do not use uf strong solver */ - UF_SS_NONE, -} UfssMode; - -static const std::string ufssModeHelp = "\ -UF strong solver options currently supported by the --uf-ss option:\n\ -\n\ -full \n\ -+ Default, use uf strong solver to find minimal models for uninterpreted sorts.\n\ -\n\ -no-minimal \n\ -+ Use uf strong solver to shrink model sizes, but do no enforce minimality.\n\ -\n\ -none \n\ -+ Do not use uf strong solver to shrink model sizes. \n\ -\n\ -"; - -inline UfssMode stringToUfssMode(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { - if(optarg == "default" || optarg == "full" ) { - return UF_SS_FULL; - } else if(optarg == "no-minimal") { - return UF_SS_NO_MINIMAL; - } else if(optarg == "none") { - return UF_SS_NONE; - } else if(optarg == "help") { - puts(ufssModeHelp.c_str()); - exit(1); - } else { - throw OptionException(std::string("unknown option for --uf-ss: `") + - optarg + "'. Try --uf-ss help."); - } -} - -}/* CVC4::theory::uf namespace */ -}/* CVC4::theory namespace */ -}/* CVC4 namespace */ - -#endif /* __CVC4__THEORY__UF__OPTIONS_HANDLERS_H */ - diff --git a/src/theory/uf/symmetry_breaker.h b/src/theory/uf/symmetry_breaker.h index d07ef64e0..e49b4652a 100644 --- a/src/theory/uf/symmetry_breaker.h +++ b/src/theory/uf/symmetry_breaker.h @@ -48,11 +48,11 @@ #include <list> #include <vector> +#include "context/cdlist.h" +#include "context/context.h" #include "expr/node.h" #include "expr/node_builder.h" -#include "context/context.h" -#include "context/cdlist.h" -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" namespace CVC4 { namespace theory { diff --git a/src/theory/uf/theory_uf.cpp b/src/theory/uf/theory_uf.cpp index 6679b5dc2..31bee316a 100644 --- a/src/theory/uf/theory_uf.cpp +++ b/src/theory/uf/theory_uf.cpp @@ -16,12 +16,13 @@ **/ #include "theory/uf/theory_uf.h" -#include "theory/uf/options.h" -#include "smt/options.h" -#include "theory/quantifiers/options.h" -#include "theory/uf/theory_uf_strong_solver.h" + +#include "options/quantifiers_options.h" +#include "options/smt_options.h" +#include "options/uf_options.h" #include "theory/theory_model.h" #include "theory/type_enumerator.h" +#include "theory/uf/theory_uf_strong_solver.h" using namespace std; using namespace CVC4; diff --git a/src/theory/uf/theory_uf_model.cpp b/src/theory/uf/theory_uf_model.cpp index 64f06ceb7..6d0123a19 100644 --- a/src/theory/uf/theory_uf_model.cpp +++ b/src/theory/uf/theory_uf_model.cpp @@ -12,16 +12,18 @@ ** \brief Implementation of Theory UF Model **/ +#include "theory/uf/theory_uf_model.h" + +#include <stack> +#include <vector> + #include "expr/attribute.h" +#include "options/quantifiers_options.h" +#include "theory/quantifiers/term_database.h" #include "theory/theory_engine.h" -#include "theory/uf/theory_uf_model.h" #include "theory/uf/equality_engine.h" #include "theory/uf/theory_uf.h" -#include "theory/quantifiers/term_database.h" -#include "theory/quantifiers/options.h" -#include <vector> -#include <stack> #define RECONSIDER_FUNC_DEFAULT_VALUE #define USE_PARTIAL_DEFAULT_VALUES diff --git a/src/theory/uf/theory_uf_strong_solver.cpp b/src/theory/uf/theory_uf_strong_solver.cpp index 29e726da7..d617207cf 100644 --- a/src/theory/uf/theory_uf_strong_solver.cpp +++ b/src/theory/uf/theory_uf_strong_solver.cpp @@ -13,12 +13,13 @@ **/ #include "theory/uf/theory_uf_strong_solver.h" + +#include "options/uf_options.h" #include "theory/uf/theory_uf.h" #include "theory/uf/equality_engine.h" #include "theory/theory_engine.h" #include "theory/quantifiers_engine.h" #include "theory/quantifiers/term_database.h" -#include "theory/uf/options.h" #include "theory/theory_model.h" #include "theory/quantifiers/symmetry_breaking.h" diff --git a/src/theory/uf/theory_uf_strong_solver.h b/src/theory/uf/theory_uf_strong_solver.h index 3e612ff1f..dd32154d9 100644 --- a/src/theory/uf/theory_uf_strong_solver.h +++ b/src/theory/uf/theory_uf_strong_solver.h @@ -17,14 +17,12 @@ #ifndef __CVC4__THEORY_UF_STRONG_SOLVER_H #define __CVC4__THEORY_UF_STRONG_SOLVER_H -#include "theory/theory.h" - +#include "context/cdchunk_list.h" +#include "context/cdhashmap.h" #include "context/context.h" #include "context/context_mm.h" -#include "context/cdhashmap.h" -#include "context/cdchunk_list.h" - -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" +#include "theory/theory.h" namespace CVC4 { diff --git a/src/theory/unconstrained_simplifier.h b/src/theory/unconstrained_simplifier.h index e23c4853d..6c04d66e7 100644 --- a/src/theory/unconstrained_simplifier.h +++ b/src/theory/unconstrained_simplifier.h @@ -24,8 +24,8 @@ #include <utility> #include "expr/node.h" +#include "expr/statistics_registry.h" #include "theory/substitutions.h" -#include "util/statistics_registry.h" namespace CVC4 { diff --git a/src/theory/valuation.h b/src/theory/valuation.h index 540ebd8fc..c9bff14a4 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 "theory/theoryof_mode.h" +#include "options/theoryof_mode.h" namespace CVC4 { diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 59591dc3b..914d6e7d2 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -3,11 +3,10 @@ AM_CPPFLAGS = \ -I@builddir@/.. -I@srcdir@/../include -I@srcdir@/.. AM_CXXFLAGS = -Wall -Wno-unknown-pragmas $(FLAG_VISIBILITY_HIDDEN) -noinst_LTLIBRARIES = libutil.la libstatistics.la +noinst_LTLIBRARIES = libutil.la -libstatistics_la_CPPFLAGS = $(CPPFLAGS) $(AM_CPPFLAGS) -D__BUILDING_STATISTICS_FOR_EXPORT -# Do not list built sources (like integer.h, rational.h, and tls.h) here! +# Do not list built sources (like integer.h, rational.h) here! # Rather, list them under BUILT_SOURCES, and their .in versions under # EXTRA_DIST. Otherwise, they're packaged up in the tarball, which is # no good---they belong in the configured builds/ directory. If they @@ -15,102 +14,45 @@ libstatistics_la_CPPFLAGS = $(CPPFLAGS) $(AM_CPPFLAGS) -D__BUILDING_STATISTICS_F # configured at the time of the "make dist", which (1) may not be the # configuration that the user wants, and (2) might cause link errors. libutil_la_SOURCES = \ - cvc4_assert.h \ - cvc4_assert.cpp \ - backtrackable.h \ Makefile.am \ Makefile.in \ - debug.h \ - exception.h \ - exception.cpp \ - hash.h \ + abstract_value.cpp \ + abstract_value.h \ + bin_heap.h \ + bitvector.h \ bool.h \ - proof.h \ - output.cpp \ - output.h \ - result.h \ - result.cpp \ + cache.h \ + cardinality.cpp \ + cardinality.h \ + channel.h \ + configuration.cpp \ configuration.h \ configuration_private.h \ - configuration.cpp \ - bitvector.h \ - ascription_type.h \ - array.h \ - datatype.h \ - datatype.cpp \ - tuple.h \ - record.h \ - record.cpp \ - divisible.h \ + debug.h \ + dense_map.h \ divisible.cpp \ - maybe.h \ - matcher.h \ - gmp_util.h \ - sexpr.h \ - sexpr.cpp \ - statistics.h \ - statistics.cpp \ - statistics_registry.h \ - statistics_registry.cpp \ + divisible.h \ dynamic_array.h \ - language.h \ - lemma_input_channel.h \ - lemma_output_channel.h \ - dense_map.h \ - channel.h \ - language.cpp \ - ntuple.h \ - subrange_bound.h \ - dump.h \ - dump.cpp \ - predicate.h \ - predicate.cpp \ - cardinality.h \ - cardinality.cpp \ - cache.h \ - utility.h \ - boolean_simplification.h \ - boolean_simplification.cpp \ - ite_removal.h \ - ite_removal.cpp \ - nary_builder.h \ - nary_builder.cpp \ - node_visitor.h \ - chain.h \ + floatingpoint.cpp \ + floatingpoint.h \ + gmp_util.h \ + hash.h \ index.h \ - uninterpreted_constant.h \ - uninterpreted_constant.cpp \ - abstract_value.h \ - abstract_value.cpp \ - array_store_all.h \ - array_store_all.cpp \ - emptyset.h \ - emptyset.cpp \ - model.h \ - model.cpp \ - sort_inference.h \ - sort_inference.cpp \ - regexp.h \ + maybe.h \ + ntuple.h \ + proof.h \ regexp.cpp \ - bin_heap.h \ - didyoumean.h \ - didyoumean.cpp \ - unsat_core.h \ - unsat_core.cpp \ - floatingpoint.h \ - floatingpoint.cpp \ - resource_manager.h \ - resource_manager.cpp \ - unsafe_interrupt_exception.h - -libstatistics_la_SOURCES = \ - statistics_registry.h \ - statistics_registry.cpp + regexp.h \ + smt2_quote_string.cpp \ + smt2_quote_string.h \ + subrange_bound.h \ + tuple.h \ + unsafe_interrupt_exception.h \ + utility.h BUILT_SOURCES = \ rational.h \ - integer.h \ - tls.h + integer.h if CVC4_CLN_IMP libutil_la_SOURCES += \ @@ -123,53 +65,36 @@ libutil_la_SOURCES += \ integer_gmp_imp.cpp endif + EXTRA_DIST = \ - rational_cln_imp.h \ - integer_cln_imp.h \ - integer_cln_imp.cpp \ - rational_cln_imp.cpp \ - rational_gmp_imp.h \ - integer_gmp_imp.h \ - integer_gmp_imp.cpp \ - rational_gmp_imp.cpp \ - rational.h.in \ - integer.h.in \ - tls.h.in \ - integer.i \ - statistics.i \ + bitvector.i \ bool.i \ - sexpr.i \ - datatype.i \ - tuple.i \ - record.i \ - divisible.i \ cardinality.i \ - result.i \ configuration.i \ - bitvector.i \ - subrange_bound.i \ - exception.i \ - language.i \ - array.i \ - array_store_all.i \ - emptyset.i \ - ascription_type.i \ - rational.i \ + divisible.i \ + floatingpoint.i \ hash.i \ - predicate.i \ - uninterpreted_constant.i \ - chain.i \ - regexp.i \ - resource_manager.i \ - unsafe_interrupt_exception.i \ + integer.h.in \ + integer.i \ + integer_cln_imp.cpp \ + integer_cln_imp.h \ + integer_gmp_imp.cpp \ + integer_gmp_imp.h \ proof.i \ - unsat_core.i \ - floatingpoint.i + rational.h.in \ + rational.i \ + rational_cln_imp.cpp \ + rational_cln_imp.h \ + rational_gmp_imp.cpp \ + rational_gmp_imp.h \ + regexp.i \ + subrange_bound.i \ + tuple.i \ + unsafe_interrupt_exception.i + DISTCLEANFILES = \ integer.h.tmp \ rational.h.tmp \ - tls.h.tmp \ integer.h \ - rational.h \ - tls.h + rational.h diff --git a/src/util/abstract_value.cpp b/src/util/abstract_value.cpp index d99353b74..e401661eb 100644 --- a/src/util/abstract_value.cpp +++ b/src/util/abstract_value.cpp @@ -27,4 +27,9 @@ std::ostream& operator<<(std::ostream& out, const AbstractValue& val) { return out << "@" << val.getIndex(); } +AbstractValue::AbstractValue(Integer index) throw(IllegalArgumentException) : + d_index(index) { + CheckArgument(index >= 1, index, "index >= 1 required for abstract value, not `%s'", index.toString().c_str()); +} + }/* CVC4 namespace */ diff --git a/src/util/abstract_value.h b/src/util/abstract_value.h index 78a1e9975..d597edc8b 100644 --- a/src/util/abstract_value.h +++ b/src/util/abstract_value.h @@ -18,9 +18,10 @@ #pragma once -#include "expr/type.h" #include <iostream> +#include "util/integer.h" + namespace CVC4 { class CVC4_PUBLIC AbstractValue { @@ -28,13 +29,9 @@ class CVC4_PUBLIC AbstractValue { public: - AbstractValue(Integer index) throw(IllegalArgumentException) : - d_index(index) { - CheckArgument(index >= 1, index, "index >= 1 required for abstract value, not `%s'", index.toString().c_str()); - } + AbstractValue(Integer index) throw(IllegalArgumentException); - ~AbstractValue() throw() { - } + ~AbstractValue() throw() {} const Integer& getIndex() const throw() { return d_index; diff --git a/src/util/array.i b/src/util/array.i deleted file mode 100644 index 593ce9490..000000000 --- a/src/util/array.i +++ /dev/null @@ -1,5 +0,0 @@ -%{ -#include "util/array.h" -%} - -%include "util/array.h" diff --git a/src/util/bin_heap.h b/src/util/bin_heap.h index 53c2a9bb6..d057bcf84 100644 --- a/src/util/bin_heap.h +++ b/src/util/bin_heap.h @@ -26,7 +26,7 @@ #include <limits> #include <functional> -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { diff --git a/src/util/bitvector.h b/src/util/bitvector.h index 798dd63c7..762753795 100644 --- a/src/util/bitvector.h +++ b/src/util/bitvector.h @@ -21,7 +21,8 @@ #define __CVC4__BITVECTOR_H #include <iostream> -#include "util/exception.h" + +#include "base/exception.h" #include "util/integer.h" namespace CVC4 { diff --git a/src/util/cardinality.h b/src/util/cardinality.h index 113cb954c..1cb4454e0 100644 --- a/src/util/cardinality.h +++ b/src/util/cardinality.h @@ -23,8 +23,8 @@ #include <iostream> #include <utility> +#include "base/exception.h" #include "util/integer.h" -#include "util/exception.h" namespace CVC4 { diff --git a/src/util/channel.h b/src/util/channel.h index 710c3274b..39aed425b 100644 --- a/src/util/channel.h +++ b/src/util/channel.h @@ -49,15 +49,15 @@ public: /* Removes an element from the channel */ virtual T pop() = 0; - + /* */ - virtual bool empty() = 0; - + virtual bool empty() = 0; + /* */ virtual bool full() = 0; };/* class SharedChannel<T> */ -/* +/* This code is from http://live.boost.org/doc/libs/1_46_1/libs/circular_buffer/doc/circular_buffer.html#boundedbuffer @@ -76,7 +76,7 @@ public: bool push(param_type item){ // param_type represents the "best" way to pass a parameter of type value_type to a method - + boost::mutex::scoped_lock lock(m_mutex); m_not_full.wait(lock, boost::bind(&SynchronizedSharedChannel<value_type>::is_not_full, this)); m_container.push_front(item); diff --git a/src/util/configuration.cpp b/src/util/configuration.cpp index 5bd607d94..bbde7193f 100644 --- a/src/util/configuration.cpp +++ b/src/util/configuration.cpp @@ -15,15 +15,16 @@ ** Implementation of Configuration class, which provides compile-time ** configuration information about the CVC4 library. **/ +#include "util/configuration.h" -#include <string> -#include <string.h> #include <stdlib.h> +#include <string.h> + #include <sstream> +#include <string> -#include "util/configuration.h" -#include "util/configuration_private.h" #include "cvc4autoconfig.h" +#include "util/configuration_private.h" #if defined(CVC4_DEBUG) && defined(CVC4_TRACING) # include "options/Debug_tags.h" diff --git a/src/util/configuration.h b/src/util/configuration.h index c6562b3e6..818652db0 100644 --- a/src/util/configuration.h +++ b/src/util/configuration.h @@ -29,7 +29,7 @@ namespace CVC4 { * Represents the (static) configuration of CVC4. */ class CVC4_PUBLIC Configuration { - +private: /** Private default ctor: Disallow construction of this class */ Configuration(); @@ -61,8 +61,8 @@ public: static bool isAssertionBuild(); - static bool isProofBuild(); - + static bool isProofBuild(); + static bool isCoverageBuild(); static bool isProfilingBuild(); diff --git a/src/util/dense_map.h b/src/util/dense_map.h index 39cee5b9e..86b9f2553 100644 --- a/src/util/dense_map.h +++ b/src/util/dense_map.h @@ -26,10 +26,12 @@ #pragma once -#include <vector> #include <boost/integer_traits.hpp> +#include <vector> + +#include "base/cvc4_assert.h" #include "util/index.h" -#include "util/cvc4_assert.h" + namespace CVC4 { diff --git a/src/util/divisible.cpp b/src/util/divisible.cpp index ee085d25b..4a8b7a2e7 100644 --- a/src/util/divisible.cpp +++ b/src/util/divisible.cpp @@ -16,7 +16,8 @@ **/ #include "util/divisible.h" -#include "util/exception.h" + +#include "base/exception.h" using namespace std; diff --git a/src/util/divisible.h b/src/util/divisible.h index 6917bf2a6..5f62def02 100644 --- a/src/util/divisible.h +++ b/src/util/divisible.h @@ -21,8 +21,9 @@ #define __CVC4__DIVISIBLE_H #include <iostream> + +#include "base/exception.h" #include "util/integer.h" -#include "util/exception.h" namespace CVC4 { diff --git a/src/util/dynamic_array.h b/src/util/dynamic_array.h index 18b1b645b..6938748a8 100644 --- a/src/util/dynamic_array.h +++ b/src/util/dynamic_array.h @@ -20,7 +20,7 @@ #ifndef __CVC4__UTIL__DYNAMIC_ARRAY_H #define __CVC4__UTIL__DYNAMIC_ARRAY_H -#include "util/cvc4_assert.h" +#include "base/cvc4_assert.h" namespace CVC4 { diff --git a/src/util/floatingpoint.cpp b/src/util/floatingpoint.cpp index 1aed6331e..d3bb1967a 100644 --- a/src/util/floatingpoint.cpp +++ b/src/util/floatingpoint.cpp @@ -13,9 +13,10 @@ ** **/ -#include "util/cvc4_assert.h" #include "util/floatingpoint.h" +#include "base/cvc4_assert.h" + namespace CVC4 { FloatingPointSize::FloatingPointSize (unsigned _e, unsigned _s) : e(_e), s(_s) @@ -35,4 +36,3 @@ namespace CVC4 { } }/* CVC4 namespace */ - diff --git a/src/util/floatingpoint.h b/src/util/floatingpoint.h index e0678d389..132d67b1c 100644 --- a/src/util/floatingpoint.h +++ b/src/util/floatingpoint.h @@ -14,22 +14,16 @@ ** [[ This file contains the data structures used by the constant and ** parametric types of the floating point theory. ]] **/ - -#include <fenv.h> - #include "cvc4_public.h" -#include "util/bitvector.h" - - #ifndef __CVC4__FLOATINGPOINT_H #define __CVC4__FLOATINGPOINT_H +#include <fenv.h> +#include "util/bitvector.h" namespace CVC4 { - - // Inline these! inline bool CVC4_PUBLIC validExponentSize (unsigned e) { return e >= 2; } inline bool CVC4_PUBLIC validSignificandSize (unsigned s) { return s >= 2; } @@ -80,14 +74,6 @@ namespace CVC4 { }; /* struct FloatingPointSizeHashFunction */ - - - - - - - - /** * A concrete instance of the rounding mode sort */ @@ -106,14 +92,6 @@ namespace CVC4 { }; /* struct RoundingModeHashFunction */ - - - - - - - - /** * A concrete floating point number */ @@ -168,12 +146,6 @@ namespace CVC4 { } }; /* struct FloatingPointHashFunction */ - - - - - - /** * The parameter type for the conversions to floating point. */ @@ -261,9 +233,6 @@ namespace CVC4 { - - - inline std::ostream& operator <<(std::ostream& os, const FloatingPointLiteral& fp) CVC4_PUBLIC; inline std::ostream& operator <<(std::ostream& os, const FloatingPointLiteral& fp) { fp.unfinished(); @@ -285,9 +254,6 @@ namespace CVC4 { return os << "(_ to_fp " << fpcs.t.exponent() << " " << fpcs.t.significand() << ")"; } - - - }/* CVC4 namespace */ #endif /* __CVC4__FLOATINGPOINT_H */ diff --git a/src/util/integer_cln_imp.cpp b/src/util/integer_cln_imp.cpp index 02086494b..1cb4349eb 100644 --- a/src/util/integer_cln_imp.cpp +++ b/src/util/integer_cln_imp.cpp @@ -14,11 +14,13 @@ ** [[ Add lengthier description here ]] ** \todo document this file **/ - -#include "cvc4autoconfig.h" #include "util/integer.h" -#include <string> + #include <sstream> +#include <string> + +#include "cvc4autoconfig.h" + #ifndef CVC4_CLN_IMP # error "This source should only ever be built if CVC4_CLN_IMP is on !" diff --git a/src/util/integer_cln_imp.h b/src/util/integer_cln_imp.h index 9f7f4a06b..6df8d3b8e 100644 --- a/src/util/integer_cln_imp.h +++ b/src/util/integer_cln_imp.h @@ -29,7 +29,7 @@ #include <cln/integer_io.h> #include <limits> -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { diff --git a/src/util/integer_gmp_imp.cpp b/src/util/integer_gmp_imp.cpp index 2717d03f4..bde759219 100644 --- a/src/util/integer_gmp_imp.cpp +++ b/src/util/integer_gmp_imp.cpp @@ -14,11 +14,14 @@ ** A multi-precision rational constant. **/ +#include "util/integer.h" + +#include <cmath> +#include <sstream> +#include <string> + #include "cvc4autoconfig.h" #include "util/rational.h" -#include <string> -#include <sstream> -#include <cmath> #ifndef CVC4_GMP_IMP # error "This source should only ever be built if CVC4_GMP_IMP is on !" diff --git a/src/util/integer_gmp_imp.h b/src/util/integer_gmp_imp.h index d1f5050d5..0d3122cd8 100644 --- a/src/util/integer_gmp_imp.h +++ b/src/util/integer_gmp_imp.h @@ -24,8 +24,8 @@ #include <iostream> #include <limits> +#include "base/exception.h" #include "util/gmp_util.h" -#include "util/exception.h" namespace CVC4 { diff --git a/src/util/maybe.h b/src/util/maybe.h index 4d279a0c7..2fa7c2f11 100644 --- a/src/util/maybe.h +++ b/src/util/maybe.h @@ -27,7 +27,8 @@ #pragma once #include <ostream> -#include "util/exception.h" + +#include "base/exception.h" namespace CVC4 { diff --git a/src/util/rational_cln_imp.cpp b/src/util/rational_cln_imp.cpp index e5e3608cb..5044aff18 100644 --- a/src/util/rational_cln_imp.cpp +++ b/src/util/rational_cln_imp.cpp @@ -13,11 +13,12 @@ ** ** A multi-precision rational constant. **/ - -#include "cvc4autoconfig.h" #include "util/rational.h" -#include <string> + #include <sstream> +#include <string> + +#include "cvc4autoconfig.h" #ifndef CVC4_CLN_IMP # error "This source should only ever be built if CVC4_CLN_IMP is on !" diff --git a/src/util/rational_cln_imp.h b/src/util/rational_cln_imp.h index 895fc1c9b..df08770e8 100644 --- a/src/util/rational_cln_imp.h +++ b/src/util/rational_cln_imp.h @@ -33,7 +33,7 @@ #include <cln/dfloat.h> #include <cln/real.h> -#include "util/exception.h" +#include "base/exception.h" #include "util/integer.h" namespace CVC4 { @@ -369,4 +369,3 @@ CVC4_PUBLIC std::ostream& operator<<(std::ostream& os, const Rational& n); }/* CVC4 namespace */ #endif /* __CVC4__RATIONAL_H */ - diff --git a/src/util/rational_gmp_imp.cpp b/src/util/rational_gmp_imp.cpp index d7f9e2e22..f0f7d46eb 100644 --- a/src/util/rational_gmp_imp.cpp +++ b/src/util/rational_gmp_imp.cpp @@ -13,12 +13,13 @@ ** ** A multi-precision rational constant. **/ - -#include "cvc4autoconfig.h" #include "util/rational.h" -#include <string> -#include <sstream> + #include <cmath> +#include <sstream> +#include <string> + +#include "cvc4autoconfig.h" #ifndef CVC4_GMP_IMP # error "This source should only ever be built if CVC4_GMP_IMP is on !" diff --git a/src/util/rational_gmp_imp.h b/src/util/rational_gmp_imp.h index 6288be050..59145d485 100644 --- a/src/util/rational_gmp_imp.h +++ b/src/util/rational_gmp_imp.h @@ -23,8 +23,8 @@ #include <gmp.h> #include <string> +#include "base/exception.h" #include "util/integer.h" -#include "util/exception.h" namespace CVC4 { @@ -347,4 +347,3 @@ CVC4_PUBLIC std::ostream& operator<<(std::ostream& os, const Rational& n); }/* CVC4 namespace */ #endif /* __CVC4__RATIONAL_H */ - diff --git a/src/util/regexp.cpp b/src/util/regexp.cpp index 05aacc06c..25a595613 100644 --- a/src/util/regexp.cpp +++ b/src/util/regexp.cpp @@ -16,8 +16,9 @@ **/ #include "util/regexp.h" -#include <iostream> + #include <iomanip> +#include <iostream> using namespace std; diff --git a/src/util/regexp.h b/src/util/regexp.h index a91f825ec..4b26b6e91 100644 --- a/src/util/regexp.h +++ b/src/util/regexp.h @@ -25,8 +25,8 @@ #include <set> #include <sstream> #include <cassert> -//#include "util/integer.h" -#include "util/exception.h" + +#include "base/exception.h" #include "util/hash.h" namespace CVC4 { diff --git a/src/util/resource_manager.i b/src/util/resource_manager.i deleted file mode 100644 index 0f55c2bce..000000000 --- a/src/util/resource_manager.i +++ /dev/null @@ -1,5 +0,0 @@ -%{ -#include "util/resource_manager.h" -%} - -%include "util/resource_manager.h" diff --git a/src/util/smt2_quote_string.cpp b/src/util/smt2_quote_string.cpp new file mode 100644 index 000000000..68551bc0f --- /dev/null +++ b/src/util/smt2_quote_string.cpp @@ -0,0 +1,41 @@ +/********************* */ +/*! \file smt2_quote_string.cpp + ** \verbatim + ** Original author: Tim King + ** Major contributors: none + ** Minor contributors (to current version): none + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2014 New York University and The University of Iowa + ** See the file COPYING in the top-level source directory for licensing + ** information.\endverbatim + ** + ** \brief Quotes a string if necessary for smt2. + ** + ** Quotes a string if necessary for smt2. + **/ + +#include "util/smt2_quote_string.h" + +#include <string> + +namespace CVC4 { + +/** + * SMT-LIB 2 quoting for symbols + */ +std::string quoteSymbol(const std::string& s){ + if(s.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@$%^&*_-+=<>.?/") == std::string::npos) { + // simple unquoted symbol + return s; + } else { + std::string tmp(s); + // must quote the symbol, but it cannot contain | or \, we turn those into _ + size_t p; + while((p = tmp.find_first_of("\\|")) != std::string::npos) { + tmp = tmp.replace(p, 1, "_"); + } + return "|" + tmp + "|"; + } +} + +}/* CVC4 namespace */ diff --git a/src/util/sexpr.cpp b/src/util/smt2_quote_string.h index 64b898d45..577f216e2 100644 --- a/src/util/sexpr.cpp +++ b/src/util/smt2_quote_string.h @@ -1,5 +1,5 @@ /********************* */ -/*! \file sexpr.cpp +/*! \file smt2_quote_string.h ** \verbatim ** Original author: Morgan Deters ** Major contributors: none @@ -9,24 +9,25 @@ ** See the file COPYING in the top-level source directory for licensing ** information.\endverbatim ** - ** \brief Simple representation of S-expressions + ** \brief Quotes a string if necessary for smt2. ** - ** Simple representation of S-expressions. + ** Quotes a string if necessary for smt2. **/ -#include <iostream> -#include <vector> +#include "cvc4_private.h" -#include "util/sexpr.h" -#include "util/cvc4_assert.h" -#include "printer/printer.h" -#include "expr/expr.h" +#ifndef __CVC4__UTIL__SMT2_QUOTE_STRING_H +#define __CVC4__UTIL__SMT2_QUOTE_STRING_H + +#include <string> namespace CVC4 { -std::ostream& operator<<(std::ostream& out, const SExpr& sexpr) { - Printer::getPrinter(Expr::setlanguage::getLanguage(out))->toStream(out, sexpr); - return out; -} +/** + * SMT-LIB 2 quoting for symbols + */ +std::string quoteSymbol(const std::string& s); }/* CVC4 namespace */ + +#endif /* __CVC4__UTIL__SMT2_QUOTE_STRING_H */ diff --git a/src/util/subrange_bound.h b/src/util/subrange_bound.h index b90656f33..6cff7133c 100644 --- a/src/util/subrange_bound.h +++ b/src/util/subrange_bound.h @@ -20,11 +20,11 @@ #ifndef __CVC4__SUBRANGE_BOUND_H #define __CVC4__SUBRANGE_BOUND_H -#include "util/integer.h" -#include "util/exception.h" - #include <limits> +#include "base/exception.h" +#include "util/integer.h" + namespace CVC4 { /** diff --git a/src/util/unsafe_interrupt_exception.h b/src/util/unsafe_interrupt_exception.h index e19fc37ce..d7c736d64 100644 --- a/src/util/unsafe_interrupt_exception.h +++ b/src/util/unsafe_interrupt_exception.h @@ -1,5 +1,5 @@ /********************* */ -/*! \file modal_exception.h +/*! \file unsafe_interrupt_exception.h ** \verbatim ** Original author: Liana Hadarean ** Major contributors: none @@ -18,7 +18,7 @@ #ifndef __CVC4__UNSAFE_INTERRUPT_EXCEPTION_H #define __CVC4__UNSAFE_INTERRUPT_EXCEPTION_H -#include "util/exception.h" +#include "base/exception.h" namespace CVC4 { diff --git a/test/system/ouroborous.cpp b/test/system/ouroborous.cpp index 4fbabf5f1..fd06517a9 100644 --- a/test/system/ouroborous.cpp +++ b/test/system/ouroborous.cpp @@ -29,9 +29,9 @@ #include <string> #include "expr/expr.h" -#include "expr/command.h" #include "parser/parser.h" #include "parser/parser_builder.h" +#include "smt_util/command.h" using namespace CVC4; using namespace CVC4::parser; diff --git a/test/system/smt2_compliance.cpp b/test/system/smt2_compliance.cpp index f754adc0e..108e30b5c 100644 --- a/test/system/smt2_compliance.cpp +++ b/test/system/smt2_compliance.cpp @@ -14,16 +14,16 @@ ** A test of SMT-LIBv2 commands, checks for compliant output. **/ +#include <cassert> #include <iostream> #include <sstream> -#include <cassert> -#include "smt/options.h" -#include "parser/parser.h" #include "expr/expr_manager.h" -#include "expr/command.h" -#include "smt/smt_engine.h" +#include "options/smt_options.h" +#include "parser/parser.h" #include "parser/parser_builder.h" +#include "smt/smt_engine.h" +#include "smt_util/command.h" using namespace CVC4; using namespace CVC4::parser; diff --git a/test/system/statistics.cpp b/test/system/statistics.cpp index f955bd150..baa901540 100644 --- a/test/system/statistics.cpp +++ b/test/system/statistics.cpp @@ -19,8 +19,9 @@ #include <sstream> #include "expr/expr.h" +#include "expr/sexpr.h" +#include "expr/statistics.h" #include "smt/smt_engine.h" -#include "util/statistics.h" using namespace CVC4; using namespace std; @@ -53,7 +54,8 @@ int main() { cout << "stat1 " << (*i).first << " is " << stats.getStatistic((*i).first) << endl; cout << "stat2 " << (*i).first << " is " << (*i).second << endl; if(smt.getStatistic((*i).first) != (*i).second) { - cout << "SMT engine reports different value for statistic " << (*i).first << ": " << smt.getStatistic((*i).first) << endl; + cout << "SMT engine reports different value for statistic " + << (*i).first << ": " << smt.getStatistic((*i).first) << endl; exit(1); } different = different || stats.getStatistic((*i).first) != (*i).second; @@ -68,5 +70,3 @@ int main() { return r == Result::VALID ? 0 : 1; } - - diff --git a/test/unit/context/cdlist_black.h b/test/unit/context/cdlist_black.h index 5f473478c..5980972be 100644 --- a/test/unit/context/cdlist_black.h +++ b/test/unit/context/cdlist_black.h @@ -16,16 +16,14 @@ #include <cxxtest/TestSuite.h> -#include <vector> #include <iostream> - #include <limits.h> +#include <vector> -#include "memory.h" - -#include "util/exception.h" +#include "base/exception.h" #include "context/context.h" #include "context/cdlist.h" +#include "memory.h" using namespace std; using namespace CVC4::context; diff --git a/test/unit/context/cdmap_white.h b/test/unit/context/cdmap_white.h index 84b8242b4..11642c3e9 100644 --- a/test/unit/context/cdmap_white.h +++ b/test/unit/context/cdmap_white.h @@ -16,8 +16,8 @@ #include <cxxtest/TestSuite.h> +#include "base/cvc4_assert.h" #include "context/cdhashmap.h" -#include "util/cvc4_assert.h" using namespace std; using namespace CVC4; diff --git a/test/unit/context/cdo_black.h b/test/unit/context/cdo_black.h index fe04421b4..4ca01df85 100644 --- a/test/unit/context/cdo_black.h +++ b/test/unit/context/cdo_black.h @@ -16,12 +16,13 @@ #include <cxxtest/TestSuite.h> -#include <vector> #include <iostream> -#include "context/context.h" +#include <vector> + +#include "base/cvc4_assert.h" #include "context/cdlist.h" #include "context/cdo.h" -#include "util/cvc4_assert.h" +#include "context/context.h" using namespace std; using namespace CVC4; diff --git a/test/unit/context/context_black.h b/test/unit/context/context_black.h index f72cc05f4..d7148c990 100644 --- a/test/unit/context/context_black.h +++ b/test/unit/context/context_black.h @@ -16,12 +16,14 @@ #include <cxxtest/TestSuite.h> -#include <vector> #include <iostream> -#include "context/context.h" +#include <vector> + +#include "base/cvc4_assert.h" #include "context/cdlist.h" #include "context/cdo.h" -#include "util/cvc4_assert.h" +#include "context/context.h" + using namespace std; using namespace CVC4; diff --git a/test/unit/context/context_white.h b/test/unit/context/context_white.h index 7ad70f061..10f603abd 100644 --- a/test/unit/context/context_white.h +++ b/test/unit/context/context_white.h @@ -16,9 +16,9 @@ #include <cxxtest/TestSuite.h> +#include "base/cvc4_assert.h" #include "context/context.h" #include "context/cdo.h" -#include "util/cvc4_assert.h" using namespace std; using namespace CVC4; diff --git a/test/unit/expr/attribute_white.h b/test/unit/expr/attribute_white.h index 00ebc8b8d..df7e263d2 100644 --- a/test/unit/expr/attribute_white.h +++ b/test/unit/expr/attribute_white.h @@ -18,18 +18,18 @@ #include <string> -#include "expr/node_value.h" +#include "base/cvc4_assert.h" +#include "expr/attribute.h" +#include "expr/node.h" #include "expr/node_builder.h" #include "expr/node_manager.h" -#include "expr/attribute.h" #include "expr/node_manager_attributes.h" -#include "expr/node.h" +#include "expr/node_value.h" +#include "smt/smt_engine.h" +#include "smt/smt_engine_scope.h" #include "theory/theory.h" #include "theory/theory_engine.h" #include "theory/uf/theory_uf.h" -#include "util/cvc4_assert.h" -#include "smt/smt_engine.h" -#include "smt/smt_engine_scope.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/test/unit/expr/expr_manager_public.h b/test/unit/expr/expr_manager_public.h index 727abe984..040bd7161 100644 --- a/test/unit/expr/expr_manager_public.h +++ b/test/unit/expr/expr_manager_public.h @@ -21,7 +21,7 @@ #include "expr/expr_manager.h" #include "expr/expr.h" -#include "util/exception.h" +#include "base/exception.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/test/unit/expr/expr_public.h b/test/unit/expr/expr_public.h index b70c51276..a83e53780 100644 --- a/test/unit/expr/expr_public.h +++ b/test/unit/expr/expr_public.h @@ -19,9 +19,10 @@ #include <sstream> #include <string> +#include "base/exception.h" #include "expr/expr_manager.h" #include "expr/expr.h" -#include "util/exception.h" +#include "smt/smt_options_handler.h" using namespace CVC4; using namespace CVC4::kind; @@ -31,6 +32,7 @@ class ExprPublic : public CxxTest::TestSuite { private: Options opts; + smt::SmtOptionsHandler* d_handler; ExprManager* d_em; @@ -53,10 +55,12 @@ public: void setUp() { try { + d_handler = new smt::SmtOptionsHandler(NULL); + char *argv[2]; argv[0] = strdup(""); argv[1] = strdup("--output-language=ast"); - opts.parseOptions(2, argv); + opts.parseOptions(2, argv, d_handler); free(argv[0]); free(argv[1]); @@ -98,6 +102,7 @@ public: delete c_bool_and; delete b_bool; delete a_bool; + delete d_handler; delete d_em; } catch(Exception e) { diff --git a/test/unit/expr/node_black.h b/test/unit/expr/node_black.h index 7d6ee523a..3a24057b2 100644 --- a/test/unit/expr/node_black.h +++ b/test/unit/expr/node_black.h @@ -25,6 +25,7 @@ #include "expr/node_builder.h" #include "expr/node_manager.h" #include "expr/node.h" +#include "smt/smt_options_handler.h" using namespace CVC4; using namespace CVC4::kind; @@ -34,6 +35,7 @@ class NodeBlack : public CxxTest::TestSuite { private: Options opts; + smt::SmtOptionsHandler* d_handler; NodeManager* d_nodeManager; NodeManagerScope* d_scope; TypeNode* d_booleanType; @@ -42,10 +44,13 @@ private: public: void setUp() { +#warning "TODO: Discuss the effects of this change with Clark." + d_handler = new smt::SmtOptionsHandler(NULL); + char *argv[2]; argv[0] = strdup(""); argv[1] = strdup("--output-language=ast"); - opts.parseOptions(2, argv); + opts.parseOptions(2, argv, d_handler); free(argv[0]); free(argv[1]); @@ -59,6 +64,7 @@ public: delete d_booleanType; delete d_scope; delete d_nodeManager; + delete d_handler; } bool imp(bool a, bool b) const { diff --git a/test/unit/expr/node_builder_black.h b/test/unit/expr/node_builder_black.h index 9bac0d818..a7ebea2fe 100644 --- a/test/unit/expr/node_builder_black.h +++ b/test/unit/expr/node_builder_black.h @@ -20,12 +20,12 @@ #include <limits.h> #include <sstream> -#include "expr/node_builder.h" +#include "base/cvc4_assert.h" #include "expr/convenience_node_builders.h" -#include "expr/node_manager.h" -#include "expr/node.h" #include "expr/kind.h" -#include "util/cvc4_assert.h" +#include "expr/node.h" +#include "expr/node_builder.h" +#include "expr/node_manager.h" #include "util/rational.h" using namespace CVC4; diff --git a/test/unit/expr/node_manager_black.h b/test/unit/expr/node_manager_black.h index b94e6a691..781829e36 100644 --- a/test/unit/expr/node_manager_black.h +++ b/test/unit/expr/node_manager_black.h @@ -21,9 +21,8 @@ #include "expr/node_manager.h" #include "expr/node_manager_attributes.h" - -#include "util/rational.h" #include "util/integer.h" +#include "util/rational.h" using namespace CVC4; using namespace CVC4::expr; diff --git a/test/unit/expr/node_manager_white.h b/test/unit/expr/node_manager_white.h index aaa3256dd..fa44b837a 100644 --- a/test/unit/expr/node_manager_white.h +++ b/test/unit/expr/node_manager_white.h @@ -19,9 +19,8 @@ #include <string> #include "expr/node_manager.h" - -#include "util/rational.h" #include "util/integer.h" +#include "util/rational.h" using namespace CVC4; using namespace CVC4::expr; diff --git a/test/unit/expr/node_white.h b/test/unit/expr/node_white.h index 8a68db269..594a981c8 100644 --- a/test/unit/expr/node_white.h +++ b/test/unit/expr/node_white.h @@ -18,11 +18,11 @@ #include <string> -#include "expr/node_value.h" +#include "base/cvc4_assert.h" +#include "expr/node.h" #include "expr/node_builder.h" #include "expr/node_manager.h" -#include "expr/node.h" -#include "util/cvc4_assert.h" +#include "expr/node_value.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/test/unit/expr/symbol_table_black.h b/test/unit/expr/symbol_table_black.h index 2acd1ebae..2b26ad745 100644 --- a/test/unit/expr/symbol_table_black.h +++ b/test/unit/expr/symbol_table_black.h @@ -19,13 +19,13 @@ #include <sstream> #include <string> +#include "base/cvc4_assert.h" +#include "base/exception.h" #include "context/context.h" -#include "expr/symbol_table.h" -#include "expr/expr_manager.h" #include "expr/expr.h" +#include "expr/expr_manager.h" +#include "expr/symbol_table.h" #include "expr/type.h" -#include "util/cvc4_assert.h" -#include "util/exception.h" using namespace CVC4; using namespace CVC4::kind; diff --git a/test/unit/main/interactive_shell_black.h b/test/unit/main/interactive_shell_black.h index b09246d95..6c3e73d2c 100644 --- a/test/unit/main/interactive_shell_black.h +++ b/test/unit/main/interactive_shell_black.h @@ -22,9 +22,9 @@ #include "expr/expr_manager.h" #include "main/interactive_shell.h" -#include "parser/parser_builder.h" -#include "util/language.h" +#include "options/language.h" #include "options/options.h" +#include "parser/parser_builder.h" using namespace CVC4; using namespace std; diff --git a/test/unit/memory.h b/test/unit/memory.h index 2809edee7..06c4a4a44 100644 --- a/test/unit/memory.h +++ b/test/unit/memory.h @@ -29,7 +29,7 @@ #include <sys/time.h> #include <sys/resource.h> -#include "util/cvc4_assert.h" +#include "base/cvc4_assert.h" namespace CVC4 { namespace test { diff --git a/test/unit/parser/parser_black.h b/test/unit/parser/parser_black.h index 61da34460..9b700eda6 100644 --- a/test/unit/parser/parser_black.h +++ b/test/unit/parser/parser_black.h @@ -19,15 +19,16 @@ #include <cxxtest/TestSuite.h> #include <sstream> +#include "base/output.h" #include "expr/expr.h" #include "expr/expr_manager.h" +#include "options/language.h" +#include "options/options.h" #include "parser/parser.h" #include "parser/parser_builder.h" #include "parser/smt2/smt2.h" -#include "expr/command.h" -#include "options/options.h" -#include "util/output.h" -#include "util/language.h" +#include "smt_util/command.h" + using namespace CVC4; using namespace CVC4::parser; diff --git a/test/unit/parser/parser_builder_black.h b/test/unit/parser/parser_builder_black.h index c2c7cc18d..029c95ec9 100644 --- a/test/unit/parser/parser_builder_black.h +++ b/test/unit/parser/parser_builder_black.h @@ -15,18 +15,21 @@ **/ #include <cxxtest/TestSuite.h> + #include <ext/stdio_filebuf.h> -#include <fstream> -#include <iostream> #include <stdio.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> -#include "expr/command.h" +#include <fstream> +#include <iostream> + +#include "options/language.h" #include "parser/parser.h" #include "parser/parser_builder.h" -#include "util/language.h" +#include "smt_util/command.h" + typedef __gnu_cxx::stdio_filebuf<char> filebuf_gnu; diff --git a/test/unit/prop/cnf_stream_white.h b/test/unit/prop/cnf_stream_white.h index db49e2521..e705da409 100644 --- a/test/unit/prop/cnf_stream_white.h +++ b/test/unit/prop/cnf_stream_white.h @@ -18,25 +18,22 @@ /* #include <gmock/gmock.h> */ /* #include <gtest/gtest.h> */ -#include "util/cvc4_assert.h" - +#include "base/cvc4_assert.h" +#include "context/context.h" #include "expr/expr_manager.h" #include "expr/node_manager.h" -#include "context/context.h" #include "prop/cnf_stream.h" #include "prop/prop_engine.h" #include "prop/theory_proxy.h" #include "smt/smt_engine.h" #include "smt/smt_engine_scope.h" - +#include "theory/arith/theory_arith.h" +#include "theory/booleans/theory_bool.h" +#include "theory/builtin/theory_builtin.h" #include "theory/theory.h" #include "theory/theory_engine.h" #include "theory/theory_registrar.h" -#include "theory/builtin/theory_builtin.h" -#include "theory/booleans/theory_bool.h" -#include "theory/arith/theory_arith.h" - using namespace CVC4; using namespace CVC4::context; using namespace CVC4::prop; diff --git a/test/unit/theory/logic_info_white.h b/test/unit/theory/logic_info_white.h index efc7c5582..1d363ec9c 100644 --- a/test/unit/theory/logic_info_white.h +++ b/test/unit/theory/logic_info_white.h @@ -28,6 +28,8 @@ class LogicInfoWhite : public CxxTest::TestSuite { public: +#warning "This test is of questionable compatiblity with contrib/new-theory. Is the new theory id handled correctly by the Logic info." + void testSmtlibLogics() { LogicInfo info("QF_SAT"); TS_ASSERT( info.isLocked() ); @@ -1300,4 +1302,3 @@ public: } };/* class LogicInfoWhite */ - diff --git a/test/unit/theory/theory_arith_white.h b/test/unit/theory/theory_arith_white.h index 58bbe7a2b..d8615eda7 100644 --- a/test/unit/theory/theory_arith_white.h +++ b/test/unit/theory/theory_arith_white.h @@ -15,23 +15,21 @@ ** \todo document this file **/ - #include <cxxtest/TestSuite.h> -#include "theory/theory.h" -#include "theory/theory_engine.h" -#include "theory/arith/theory_arith.h" -#include "theory/quantifiers_engine.h" +#include <vector> + +#include "context/context.h" #include "expr/node.h" #include "expr/node_manager.h" -#include "context/context.h" -#include "util/rational.h" #include "smt/smt_engine.h" #include "smt/smt_engine_scope.h" - +#include "theory/arith/theory_arith.h" +#include "theory/quantifiers_engine.h" +#include "theory/theory.h" +#include "theory/theory_engine.h" #include "theory/theory_test_utils.h" - -#include <vector> +#include "util/rational.h" using namespace CVC4; using namespace CVC4::theory; @@ -103,7 +101,7 @@ public: d_em = new ExprManager(); d_nm = NodeManager::fromExprManager(d_em); d_smt = new SmtEngine(d_em); - d_smt->setOption("incremental", false); + d_smt->setOption("incremental", CVC4::SExpr(false)); d_ctxt = d_smt->d_context; d_uctxt = d_smt->d_userContext; d_scope = new SmtScope(d_smt); diff --git a/test/unit/theory/theory_engine_white.h b/test/unit/theory/theory_engine_white.h index 7440de350..d1883da9f 100644 --- a/test/unit/theory/theory_engine_white.h +++ b/test/unit/theory/theory_engine_white.h @@ -20,24 +20,24 @@ #include <cxxtest/TestSuite.h> +#include <deque> #include <iostream> #include <string> -#include <deque> -#include "theory/theory.h" -#include "theory/theory_engine.h" -#include "theory/valuation.h" -#include "theory/rewriter.h" +#include "base/cvc4_assert.h" +#include "context/context.h" +#include "expr/kind.h" #include "expr/node.h" #include "expr/node_manager.h" -#include "expr/kind.h" -#include "context/context.h" +#include "options/options.h" #include "smt/smt_engine.h" #include "smt/smt_engine_scope.h" -#include "util/rational.h" +#include "theory/rewriter.h" +#include "theory/theory.h" +#include "theory/theory_engine.h" +#include "theory/valuation.h" #include "util/integer.h" -#include "options/options.h" -#include "util/cvc4_assert.h" +#include "util/rational.h" using namespace CVC4; using namespace CVC4::theory; diff --git a/test/unit/theory/type_enumerator_white.h b/test/unit/theory/type_enumerator_white.h index d9963f78c..993021c5a 100644 --- a/test/unit/theory/type_enumerator_white.h +++ b/test/unit/theory/type_enumerator_white.h @@ -17,13 +17,13 @@ #include <cxxtest/TestSuite.h> -#include "expr/node_manager.h" +#include "expr/array_store_all.h" #include "expr/expr_manager.h" -#include "expr/type_node.h" #include "expr/kind.h" +#include "expr/node_manager.h" +#include "expr/type_node.h" +#include "options/language.h" #include "theory/type_enumerator.h" -#include "util/language.h" -#include "util/array_store_all.h" using namespace CVC4; using namespace CVC4::theory; diff --git a/test/unit/util/array_store_all_black.h b/test/unit/util/array_store_all_black.h index 433dd7601..6a75bc7fa 100644 --- a/test/unit/util/array_store_all_black.h +++ b/test/unit/util/array_store_all_black.h @@ -16,7 +16,7 @@ #include <cxxtest/TestSuite.h> -#include "util/array_store_all.h" +#include "expr/array_store_all.h" #include "expr/expr_manager.h" #include "expr/expr_manager_scope.h" #include "expr/type.h" diff --git a/test/unit/util/assert_white.h b/test/unit/util/assert_white.h index 38dfe87e6..bbc4d02b3 100644 --- a/test/unit/util/assert_white.h +++ b/test/unit/util/assert_white.h @@ -19,7 +19,7 @@ #include <string> #include <cstring> -#include "util/cvc4_assert.h" +#include "base/cvc4_assert.h" using namespace CVC4; using namespace std; diff --git a/test/unit/util/boolean_simplification_black.h b/test/unit/util/boolean_simplification_black.h index db02ce207..ac343ede8 100644 --- a/test/unit/util/boolean_simplification_black.h +++ b/test/unit/util/boolean_simplification_black.h @@ -14,15 +14,15 @@ ** Black box testing of CVC4::BooleanSimplification. **/ -#include "util/language.h" -#include "expr/node.h" -#include "expr/kind.h" -#include "expr/node_manager.h" -#include "util/boolean_simplification.h" - #include <algorithm> -#include <vector> #include <set> +#include <vector> + +#include "expr/kind.h" +#include "expr/node.h" +#include "expr/node_manager.h" +#include "options/language.h" +#include "smt_util/boolean_simplification.h" using namespace CVC4; using namespace std; @@ -214,4 +214,3 @@ public: } };/* class BooleanSimplificationBlack */ - diff --git a/test/unit/util/cardinality_public.h b/test/unit/util/cardinality_public.h index 732bb0dbb..2fcee66b6 100644 --- a/test/unit/util/cardinality_public.h +++ b/test/unit/util/cardinality_public.h @@ -14,11 +14,11 @@ ** Public-box testing of CVC4::Cardinality. **/ -#include "util/cardinality.h" -#include "util/integer.h" - -#include <string> #include <sstream> +#include <string> + +#include "util/integer.h" +#include "util/cardinality.h" using namespace CVC4; using namespace std; diff --git a/test/unit/util/datatype_black.h b/test/unit/util/datatype_black.h index ff36336ca..91a53ddc3 100644 --- a/test/unit/util/datatype_black.h +++ b/test/unit/util/datatype_black.h @@ -17,8 +17,7 @@ #include <cxxtest/TestSuite.h> #include <sstream> -#include "util/datatype.h" - +#include "expr/datatype.h" #include "expr/expr.h" #include "expr/expr_manager.h" #include "expr/expr_manager_scope.h" diff --git a/test/unit/util/exception_black.h b/test/unit/util/exception_black.h index d2ae7d3e5..c2c7f83c0 100644 --- a/test/unit/util/exception_black.h +++ b/test/unit/util/exception_black.h @@ -19,7 +19,7 @@ #include <iostream> #include <sstream> -#include "util/exception.h" +#include "base/exception.h" using namespace CVC4; using namespace std; diff --git a/test/unit/util/integer_black.h b/test/unit/util/integer_black.h index 36de17cba..510afe7b7 100644 --- a/test/unit/util/integer_black.h +++ b/test/unit/util/integer_black.h @@ -15,8 +15,9 @@ **/ #include <cxxtest/TestSuite.h> -#include <sstream> + #include <limits> +#include <sstream> #include "util/integer.h" diff --git a/test/unit/util/output_black.h b/test/unit/util/output_black.h index 0b151ef3f..87423f026 100644 --- a/test/unit/util/output_black.h +++ b/test/unit/util/output_black.h @@ -19,7 +19,7 @@ #include <iostream> #include <sstream> -#include "util/output.h" +#include "base/output.h" using namespace CVC4; using namespace std; diff --git a/test/unit/util/stats_black.h b/test/unit/util/stats_black.h index 249f9a5b1..c0e1ea7fd 100644 --- a/test/unit/util/stats_black.h +++ b/test/unit/util/stats_black.h @@ -19,7 +19,7 @@ #include <string> #include <ctime> -#include "util/statistics_registry.h" +#include "expr/statistics_registry.h" using namespace CVC4; using namespace std; diff --git a/test/unit/util/subrange_bound_white.h b/test/unit/util/subrange_bound_white.h index 71947b297..3b785ae0d 100644 --- a/test/unit/util/subrange_bound_white.h +++ b/test/unit/util/subrange_bound_white.h @@ -14,11 +14,11 @@ ** White-box testing of CVC4::SubrangeBound. **/ -#include "util/subrange_bound.h" -#include "util/integer.h" - -#include <string> #include <sstream> +#include <string> + +#include "util/integer.h" +#include "util/subrange_bound.h" using namespace CVC4; using namespace std; @@ -72,4 +72,3 @@ public: } };/* class SubrangeBoundWhite */ - |