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";
notifications:
email:
on_success: change
- on_failure: always
\ No newline at end of file
+ on_failure: always
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
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])
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 ;;
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=
> "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
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..."
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
--- /dev/null
+#!/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}
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module $id "options/$dir_options.h" $camel
+
+endmodule
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module $id "theory/$dir/options.h" $camel
-
-endmodule
+++ /dev/null
-#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 */
**/
#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;
#include "word.h"
#include "sha1.hpp"
-#include "expr/command.h"
+#include "smt_util/command.h"
#include <boost/uuid/sha1.hpp>
#include "word.h"
#include "sha1.hpp"
-#include "expr/command.h"
+#include "smt_util/command.h"
#include <boost/uuid/sha1.hpp>
** \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;
** \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;
** \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;
** \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;
** \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;
** \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;
** \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;
** \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;
** 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;
-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
libcvc4_la_SOURCES = \
git_versioninfo.cpp \
svn_versioninfo.cpp \
+ context/backtrackable.h \
context/context.cpp \
context/context.h \
context/context_mm.cpp \
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 \
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 \
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 \
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 \
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 \
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 \
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 \
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 \
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 \
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 \
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 \
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 \
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
$(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)( \
(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' | \
-(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' | \
--- /dev/null
+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
--- /dev/null
+/********************* */
+/*! \file cvc4_assert.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 Assertion utility classes, functions, and exceptions.
+ **
+ ** Assertion utility classes, functions, and exceptions. Implementation.
+ **/
+
+#include <new>
+#include <cstdarg>
+#include <cstdio>
+
+#include "base/cvc4_assert.h"
+#include "base/output.h"
+
+using namespace std;
+
+namespace CVC4 {
+
+#ifdef CVC4_DEBUG
+CVC4_THREADLOCAL(const char*) s_debugLastException = NULL;
+#endif /* CVC4_DEBUG */
+
+void AssertionException::construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line, const char* fmt,
+ va_list args) {
+ // try building the exception msg with a smallish buffer first,
+ // then with a larger one if sprintf tells us to.
+ int n = 512;
+ char* buf;
+
+ for(;;) {
+ buf = new char[n];
+
+ int size;
+ if(extra == NULL) {
+ size = snprintf(buf, n, "%s\n%s\n%s:%d\n",
+ header, function, file, line);
+ } else {
+ size = snprintf(buf, n, "%s\n%s\n%s:%d:\n\n %s\n",
+ header, function, file, line, extra);
+ }
+
+ if(size < n) {
+ va_list args_copy;
+ va_copy(args_copy, args);
+ size += vsnprintf(buf + size, n - size, fmt, args_copy);
+ va_end(args_copy);
+
+ if(size < n) {
+ break;
+ }
+ }
+
+ if(size >= n) {
+ // try again with a buffer that's large enough
+ n = size + 1;
+ delete [] buf;
+ }
+ }
+
+ setMessage(string(buf));
+
+#ifdef CVC4_DEBUG
+ if(s_debugLastException == NULL) {
+ // we leak buf[] but only in debug mode with assertions failing
+ s_debugLastException = buf;
+ }
+#else /* CVC4_DEBUG */
+ delete [] buf;
+#endif /* CVC4_DEBUG */
+}
+
+void AssertionException::construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line) {
+ // try building the exception msg with a smallish buffer first,
+ // then with a larger one if sprintf tells us to.
+ int n = 256;
+ char* buf;
+
+ for(;;) {
+ buf = new char[n];
+
+ int size;
+ if(extra == NULL) {
+ size = snprintf(buf, n, "%s.\n%s\n%s:%d\n",
+ header, function, file, line);
+ } else {
+ size = snprintf(buf, n, "%s.\n%s\n%s:%d:\n\n %s\n",
+ header, function, file, line, extra);
+ }
+
+ if(size < n) {
+ break;
+ } else {
+ // try again with a buffer that's large enough
+ n = size + 1;
+ delete [] buf;
+ }
+ }
+
+ setMessage(string(buf));
+
+#ifdef CVC4_DEBUG
+ // we leak buf[] but only in debug mode with assertions failing
+ if(s_debugLastException == NULL) {
+ s_debugLastException = buf;
+ }
+#else /* CVC4_DEBUG */
+ delete [] buf;
+#endif /* CVC4_DEBUG */
+}
+
+#ifdef CVC4_DEBUG
+
+/**
+ * Special assertion failure handling in debug mode; in non-debug
+ * builds, the exception is thrown from the macro. We factor out this
+ * additional logic so as not to bloat the code at every Assert()
+ * expansion.
+ *
+ * Note this name is prefixed with "debug" because it is included in
+ * debug builds only; in debug builds, it handles all assertion
+ * failures (even those that exist in non-debug builds).
+ */
+void debugAssertionFailed(const AssertionException& thisException,
+ const char* propagatingException) {
+ static CVC4_THREADLOCAL(bool) alreadyFired = false;
+
+ if(__builtin_expect( ( !std::uncaught_exception() ), true ) || alreadyFired) {
+ throw thisException;
+ }
+
+ alreadyFired = true;
+
+ // propagatingException is the propagating exception, but can be
+ // NULL if the propagating exception is not a CVC4::Exception.
+ Warning() << "===========================================" << std::endl
+ << "An assertion failed during stack unwinding:" << std::endl;
+ if(propagatingException != NULL) {
+ Warning() << "The propagating exception is:" << std::endl
+ << propagatingException << std::endl
+ << "===========================================" << std::endl;
+ Warning() << "The newly-thrown exception is:" << std::endl;
+ } else {
+ Warning() << "The propagating exception is unknown." << std::endl;
+ }
+ Warning() << thisException << std::endl
+ << "===========================================" << std::endl;
+
+ terminate();
+}
+
+#endif /* CVC4_DEBUG */
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file cvc4_assert.h
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: none
+ ** Minor contributors (to current version): ACSYS
+ ** 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 Assertion utility classes, functions, exceptions, and macros.
+ **
+ ** Assertion utility classes, functions, exceptions, and macros.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__ASSERT_H
+#define __CVC4__ASSERT_H
+
+#include <string>
+#include <sstream>
+#include <cstdio>
+#include <cstdlib>
+#include <cstdarg>
+
+#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.
+// Tim : Disabling this and moving it into cvc4_assert.cpp
+//#include "util/output.h"
+
+namespace CVC4 {
+
+class AssertionException : public Exception {
+protected:
+ void construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line, const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ construct(header, extra, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ void construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line, const char* fmt, va_list args);
+
+ void construct(const char* header, const char* extra,
+ const char* function, const char* file,
+ unsigned line);
+
+ AssertionException() : Exception() {}
+
+public:
+ AssertionException(const char* extra, const char* function,
+ const char* file, unsigned line,
+ const char* fmt, ...) :
+ Exception() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Assertion failure", extra, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ AssertionException(const char* extra, const char* function,
+ const char* file, unsigned line) :
+ Exception() {
+ construct("Assertion failure", extra, function, file, line);
+ }
+};/* class AssertionException */
+
+class UnreachableCodeException : public AssertionException {
+protected:
+ UnreachableCodeException() : AssertionException() {}
+
+public:
+ UnreachableCodeException(const char* function, const char* file,
+ unsigned line, const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Unreachable code reached",
+ NULL, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ UnreachableCodeException(const char* function, const char* file,
+ unsigned line) :
+ AssertionException() {
+ construct("Unreachable code reached", NULL, function, file, line);
+ }
+};/* class UnreachableCodeException */
+
+class UnhandledCaseException : public UnreachableCodeException {
+protected:
+ UnhandledCaseException() : UnreachableCodeException() {}
+
+public:
+ UnhandledCaseException(const char* function, const char* file,
+ unsigned line, const char* fmt, ...) :
+ UnreachableCodeException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Unhandled case encountered",
+ NULL, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ template <class T>
+ UnhandledCaseException(const char* function, const char* file,
+ unsigned line, T theCase) :
+ UnreachableCodeException() {
+ std::stringstream sb;
+ sb << theCase;
+ construct("Unhandled case encountered",
+ NULL, function, file, line, "The case was: %s", sb.str().c_str());
+ }
+
+ UnhandledCaseException(const char* function, const char* file,
+ unsigned line) :
+ UnreachableCodeException() {
+ construct("Unhandled case encountered", NULL, function, file, line);
+ }
+};/* class UnhandledCaseException */
+
+class UnimplementedOperationException : public AssertionException {
+protected:
+ UnimplementedOperationException() : AssertionException() {}
+
+public:
+ UnimplementedOperationException(const char* function, const char* file,
+ unsigned line, const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Unimplemented code encountered",
+ NULL, function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ UnimplementedOperationException(const char* function, const char* file,
+ unsigned line) :
+ AssertionException() {
+ construct("Unimplemented code encountered", NULL, function, file, line);
+ }
+};/* class UnimplementedOperationException */
+
+class AssertArgumentException : public AssertionException {
+protected:
+ AssertArgumentException() : AssertionException() {}
+
+public:
+ AssertArgumentException(const char* argDesc, const char* function,
+ const char* file, unsigned line,
+ const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument" ).c_str(),
+ function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ AssertArgumentException(const char* argDesc, const char* function,
+ const char* file, unsigned line) :
+ AssertionException() {
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument" ).c_str(),
+ function, file, line);
+ }
+
+ AssertArgumentException(const char* condStr, const char* argDesc,
+ const char* function, const char* file,
+ unsigned line, const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument; expected " +
+ condStr + " to hold" ).c_str(),
+ function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ AssertArgumentException(const char* condStr, const char* argDesc,
+ const char* function, const char* file,
+ unsigned line) :
+ AssertionException() {
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument; expected " +
+ condStr + " to hold" ).c_str(),
+ function, file, line);
+ }
+};/* class AssertArgumentException */
+
+class InternalErrorException : public AssertionException {
+protected:
+ InternalErrorException() : AssertionException() {}
+
+public:
+ InternalErrorException(const char* function, const char* file, unsigned line) :
+ AssertionException() {
+ construct("Internal error detected", "",
+ function, file, line);
+ }
+
+ InternalErrorException(const char* function, const char* file, unsigned line,
+ const char* fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Internal error detected", "",
+ function, file, line, fmt, args);
+ va_end(args);
+ }
+
+ InternalErrorException(const char* function, const char* file, unsigned line,
+ std::string fmt, ...) :
+ AssertionException() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Internal error detected", "",
+ function, file, line, fmt.c_str(), args);
+ va_end(args);
+ }
+
+};/* class InternalErrorException */
+
+#ifdef CVC4_DEBUG
+
+extern CVC4_THREADLOCAL(const char*) s_debugLastException;
+
+/**
+ * Special assertion failure handling in debug mode; in non-debug
+ * builds, the exception is thrown from the macro. We factor out this
+ * additional logic so as not to bloat the code at every Assert()
+ * expansion.
+ *
+ * Note this name is prefixed with "debug" because it is included in
+ * debug builds only; in debug builds, it handles all assertion
+ * failures (even those that exist in non-debug builds).
+ */
+void debugAssertionFailed(const AssertionException& thisException, const char* lastException);
+
+// If we're currently handling an exception, print a warning instead;
+// otherwise std::terminate() is called by the runtime and we lose
+// details of the exception
+# define AlwaysAssert(cond, msg...) \
+ do { \
+ if(__builtin_expect( ( ! (cond) ), false )) { \
+ /* save the last assertion failure */ \
+ const char* lastException = ::CVC4::s_debugLastException; \
+ ::CVC4::AssertionException exception(#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
+ ::CVC4::debugAssertionFailed(exception, lastException); \
+ } \
+ } while(0)
+
+#else /* CVC4_DEBUG */
+// These simpler (but less useful) versions for non-debug builds fails
+// will terminate() if thrown during stack unwinding.
+# define AlwaysAssert(cond, msg...) \
+ do { \
+ if(__builtin_expect( ( ! (cond) ), false )) { \
+ throw ::CVC4::AssertionException(#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
+ } \
+ } while(0)
+#endif /* CVC4_DEBUG */
+
+#define Unreachable(msg...) \
+ throw ::CVC4::UnreachableCodeException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
+#define Unhandled(msg...) \
+ throw ::CVC4::UnhandledCaseException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
+#define Unimplemented(msg...) \
+ throw ::CVC4::UnimplementedOperationException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
+#define InternalError(msg...) \
+ throw ::CVC4::InternalErrorException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
+#define IllegalArgument(arg, msg...) \
+ throw ::CVC4::IllegalArgumentException("", #arg, __PRETTY_FUNCTION__, ## msg)
+#define CheckArgument(cond, arg, msg...) \
+ do { \
+ if(__builtin_expect( ( ! (cond) ), false )) { \
+ throw ::CVC4::IllegalArgumentException(#cond, #arg, __PRETTY_FUNCTION__, ## msg); \
+ } \
+ } while(0)
+#define AlwaysAssertArgument(cond, arg, msg...) \
+ do { \
+ if(__builtin_expect( ( ! (cond) ), false )) { \
+ throw ::CVC4::AssertArgumentException(#cond, #arg, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
+ } \
+ } while(0)
+
+#ifdef CVC4_ASSERTIONS
+# define Assert(cond, msg...) AlwaysAssert(cond, ## msg)
+# define AssertArgument(cond, arg, msg...) AlwaysAssertArgument(cond, arg, ## msg)
+# define DebugCheckArgument(cond, arg, msg...) CheckArgument(cond, arg, ## msg)
+#else /* ! CVC4_ASSERTIONS */
+# define Assert(cond, msg...) /*__builtin_expect( ( cond ), true )*/
+# define AssertArgument(cond, arg, msg...) /*__builtin_expect( ( cond ), true )*/
+# define DebugCheckArgument(cond, arg, msg...) /*__builtin_expect( ( cond ), true )*/
+#endif /* CVC4_ASSERTIONS */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__ASSERT_H */
--- /dev/null
+/********************* */
+/*! \file exception.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 CVC4's exception base class and some associated utilities
+ **
+ ** CVC4's exception base class and some associated utilities.
+ **/
+
+#include "base/exception.h"
+#include <string>
+#include <cstdio>
+#include <cstdlib>
+#include <cstdarg>
+
+#include "base/cvc4_assert.h"
+
+using namespace std;
+
+#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) {
+ // try building the exception msg with a smallish buffer first,
+ // then with a larger one if sprintf tells us to.
+ int n = 512;
+ char* buf;
+
+ for(;;) {
+ buf = new char[n];
+
+ int size;
+ if(extra == NULL) {
+ size = snprintf(buf, n, "%s\n%s\n",
+ header, function);
+ } else {
+ size = snprintf(buf, n, "%s\n%s\n\n %s\n",
+ header, function, extra);
+ }
+
+ if(size < n) {
+ va_list args_copy;
+ va_copy(args_copy, args);
+ size += vsnprintf(buf + size, n - size, fmt, args_copy);
+ va_end(args_copy);
+
+ if(size < n) {
+ break;
+ }
+ }
+
+ if(size >= n) {
+ // try again with a buffer that's large enough
+ n = size + 1;
+ delete [] buf;
+ }
+ }
+
+ setMessage(string(buf));
+
+#ifdef CVC4_DEBUG
+ if(s_debugLastException == NULL) {
+ // we leak buf[] but only in debug mode with assertions failing
+ s_debugLastException = buf;
+ }
+#else /* CVC4_DEBUG */
+ delete [] buf;
+#endif /* CVC4_DEBUG */
+}
+
+void IllegalArgumentException::construct(const char* header, const char* extra,
+ const char* function) {
+ // try building the exception msg with a smallish buffer first,
+ // then with a larger one if sprintf tells us to.
+ int n = 256;
+ char* buf;
+
+ for(;;) {
+ buf = new char[n];
+
+ int size;
+ if(extra == NULL) {
+ size = snprintf(buf, n, "%s.\n%s\n",
+ header, function);
+ } else {
+ size = snprintf(buf, n, "%s.\n%s\n\n %s\n",
+ header, function, extra);
+ }
+
+ if(size < n) {
+ break;
+ } else {
+ // try again with a buffer that's large enough
+ n = size + 1;
+ delete [] buf;
+ }
+ }
+
+ setMessage(string(buf));
+
+#ifdef CVC4_DEBUG
+ if(s_debugLastException == NULL) {
+ // we leak buf[] but only in debug mode with assertions failing
+ s_debugLastException = buf;
+ }
+#else /* CVC4_DEBUG */
+ delete [] buf;
+#endif /* CVC4_DEBUG */
+}
+
+} /* namespace CVC4 */
--- /dev/null
+/********************* */
+/*! \file exception.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 CVC4's exception base class and some associated utilities
+ **
+ ** CVC4's exception base class and some associated utilities.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__EXCEPTION_H
+#define __CVC4__EXCEPTION_H
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <stdexcept>
+#include <exception>
+#include <cstdlib>
+#include <cstdarg>
+
+namespace CVC4 {
+
+class CVC4_PUBLIC Exception : public std::exception {
+protected:
+ std::string d_msg;
+
+public:
+ // Constructors
+ Exception() throw() : d_msg("Unknown exception") {}
+ Exception(const std::string& msg) throw() : d_msg(msg) {}
+ Exception(const char* msg) throw() : d_msg(msg) {}
+
+ // Destructor
+ virtual ~Exception() throw() {}
+
+ // NON-VIRTUAL METHOD for setting and printing the error message
+ void setMessage(const std::string& msg) throw() { d_msg = msg; }
+ std::string getMessage() const throw() { return d_msg; }
+
+ // overridden from base class std::exception
+ virtual const char* what() const throw() { return d_msg.c_str(); }
+
+ /**
+ * Get this exception as a string. Note that
+ * cout << ex.toString();
+ * is subtly different from
+ * cout << ex;
+ * which is equivalent to
+ * ex.toStream(cout);
+ * That is because with the latter two, the output language (and
+ * other preferences) for exprs on the stream is respected. In
+ * toString(), there is no stream, so the parameters are default
+ * and you'll get exprs and types printed using the AST language.
+ */
+ std::string toString() const throw() {
+ std::stringstream ss;
+ toStream(ss);
+ return ss.str();
+ }
+
+ /**
+ * Printing: feel free to redefine toStream(). When overridden in
+ * a derived class, it's recommended that this method print the
+ * type of exception before the actual message.
+ */
+ virtual void toStream(std::ostream& os) const throw() { os << d_msg; }
+
+};/* class Exception */
+
+class CVC4_PUBLIC IllegalArgumentException : public Exception {
+protected:
+ IllegalArgumentException() : Exception() {}
+
+ void construct(const char* header, const char* extra,
+ const char* function, const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ construct(header, extra, function, fmt, args);
+ va_end(args);
+ }
+
+ void construct(const char* header, const char* extra,
+ const char* function, const char* fmt, va_list args);
+
+ void construct(const char* header, const char* extra,
+ const char* function);
+
+public:
+ IllegalArgumentException(const char* condStr, const char* argDesc,
+ const char* function, const char* fmt, ...) :
+ Exception() {
+ va_list args;
+ va_start(args, fmt);
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument"
+ + (*condStr == '\0' ? std::string() :
+ ( std::string("; expected ") +
+ condStr + " to hold" )) ).c_str(),
+ function, fmt, args);
+ va_end(args);
+ }
+
+ IllegalArgumentException(const char* condStr, const char* argDesc,
+ const char* function) :
+ Exception() {
+ construct("Illegal argument detected",
+ ( std::string("`") + argDesc + "' is a bad argument"
+ + (*condStr == '\0' ? std::string() :
+ ( std::string("; expected ") +
+ condStr + " to hold" )) ).c_str(),
+ function);
+ }
+};/* class IllegalArgumentException */
+
+inline std::ostream& operator<<(std::ostream& os, const Exception& e) throw() CVC4_PUBLIC;
+inline std::ostream& operator<<(std::ostream& os, const Exception& e) throw() {
+ e.toStream(os);
+ return os;
+}
+
+}/* CVC4 namespace */
+
+#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && !defined(__BUILDING_STATISTICS_FOR_EXPORT)
+# include "base/cvc4_assert.h"
+#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST) && !__BUILDING_STATISTICS_FOR_EXPORT */
+
+namespace CVC4 {
+
+#ifndef CheckArgument
+template <class T> inline void CheckArgument(bool cond, const T& arg, const char* fmt, ...) CVC4_PUBLIC;
+template <class T> inline void CheckArgument(bool cond, const T& arg, const char* fmt, ...) {
+ if(__builtin_expect( ( !cond ), false )) { \
+ throw ::CVC4::IllegalArgumentException("", "", ""); \
+ } \
+}
+template <class T> inline void CheckArgument(bool cond, const T& arg) CVC4_PUBLIC;
+template <class T> inline void CheckArgument(bool cond, const T& arg) {
+ if(__builtin_expect( ( !cond ), false )) { \
+ throw ::CVC4::IllegalArgumentException("", "", ""); \
+ } \
+}
+#endif /* CheckArgument */
+
+#ifndef DebugCheckArgument
+template <class T> inline void DebugCheckArgument(bool cond, const T& arg, const char* fmt, ...) CVC4_PUBLIC;
+template <class T> inline void DebugCheckArgument(bool cond, const T& arg, const char* fmt, ...) {
+ if(__builtin_expect( ( !cond ), false )) { \
+ throw ::CVC4::IllegalArgumentException("", "", ""); \
+ } \
+}
+template <class T> inline void DebugCheckArgument(bool cond, const T& arg) CVC4_PUBLIC;
+template <class T> inline void DebugCheckArgument(bool cond, const T& arg) {
+ if(__builtin_expect( ( !cond ), false )) { \
+ throw ::CVC4::IllegalArgumentException("", "", ""); \
+ } \
+}
+#endif /* DebugCheckArgument */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__EXCEPTION_H */
--- /dev/null
+%{
+#include "base/exception.h"
+%}
+
+%ignore CVC4::operator<<(std::ostream&, const Exception&) throw();
+%ignore CVC4::Exception::Exception(const char*) throw();
+%typemap(javabase) CVC4::Exception "java.lang.RuntimeException";
+
+%rename(CVC4IllegalArgumentException) CVC4::IllegalArgumentException;
+
+%include "base/exception.h"
--- /dev/null
+/********************* */
+/*! \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 */
--- /dev/null
+/********************* */
+/*! \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 */
--- /dev/null
+/********************* */
+/*! \file modal_exception.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 An exception that is thrown when an interactive-only
+ ** feature while CVC4 is being used in a non-interactive setting
+ **
+ ** An exception that is thrown when an interactive-only feature while
+ ** CVC4 is being used in a non-interactive setting (for example, the
+ ** "(get-assertions)" command in an SMT-LIBv2 script).
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__SMT__MODAL_EXCEPTION_H
+#define __CVC4__SMT__MODAL_EXCEPTION_H
+
+#include "base/exception.h"
+
+namespace CVC4 {
+
+class CVC4_PUBLIC ModalException : public CVC4::Exception {
+public:
+ ModalException() :
+ Exception("Feature used while operating in "
+ "incorrect state") {
+ }
+
+ ModalException(const std::string& msg) :
+ Exception(msg) {
+ }
+
+ ModalException(const char* msg) :
+ Exception(msg) {
+ }
+};/* class ModalException */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__SMT__MODAL_EXCEPTION_H */
--- /dev/null
+%{
+#include "base/modal_exception.h"
+%}
+
+%ignore CVC4::ModalException::ModalException(const char*);
+
+%include "base/modal_exception.h"
--- /dev/null
+/********************* */
+/*! \file output.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 Output utility classes and functions
+ **
+ ** Output utility classes and functions.
+ **/
+
+#include "base/output.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace CVC4 {
+
+/* Definitions of the declared globals from output.h... */
+
+null_streambuf null_sb;
+ostream null_os(&null_sb);
+
+NullC nullCvc4Stream CVC4_PUBLIC;
+
+const std::string CVC4ostream::s_tab = " ";
+const int CVC4ostream::s_indentIosIndex = ios_base::xalloc();
+
+DebugC DebugChannel CVC4_PUBLIC (&cout);
+WarningC WarningChannel CVC4_PUBLIC (&cerr);
+MessageC MessageChannel CVC4_PUBLIC (&cout);
+NoticeC NoticeChannel CVC4_PUBLIC (&null_os);
+ChatC ChatChannel CVC4_PUBLIC (&null_os);
+TraceC TraceChannel CVC4_PUBLIC (&cout);
+std::ostream DumpOutC::dump_cout(cout.rdbuf());// copy cout stream buffer
+DumpOutC DumpOutChannel CVC4_PUBLIC (&DumpOutC::dump_cout);
+
+#ifndef CVC4_MUZZLE
+
+# if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
+
+int DebugC::printf(const char* tag, const char* fmt, ...) {
+ if(d_tags.find(string(tag)) == d_tags.end()) {
+ return 0;
+ }
+
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+int DebugC::printf(std::string tag, const char* fmt, ...) {
+ if(d_tags.find(tag) == d_tags.end()) {
+ return 0;
+ }
+
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+# endif /* CVC4_DEBUG && CVC4_TRACING */
+
+int WarningC::printf(const char* fmt, ...) {
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+int MessageC::printf(const char* fmt, ...) {
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+int NoticeC::printf(const char* fmt, ...) {
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+int ChatC::printf(const char* fmt, ...) {
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+# ifdef CVC4_TRACING
+
+int TraceC::printf(const char* tag, const char* fmt, ...) {
+ if(d_tags.find(string(tag)) == d_tags.end()) {
+ return 0;
+ }
+
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+int TraceC::printf(std::string tag, const char* fmt, ...) {
+ if(d_tags.find(tag) == d_tags.end()) {
+ return 0;
+ }
+
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+# endif /* CVC4_TRACING */
+
+# ifdef CVC4_DUMPING
+
+int DumpOutC::printf(const char* tag, const char* fmt, ...) {
+ if(d_tags.find(string(tag)) == d_tags.end()) {
+ return 0;
+ }
+
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+int DumpOutC::printf(std::string tag, const char* fmt, ...) {
+ if(d_tags.find(tag) == d_tags.end()) {
+ return 0;
+ }
+
+ // chop off output after 1024 bytes
+ char buf[1024];
+ va_list vl;
+ va_start(vl, fmt);
+ int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
+ va_end(vl);
+ *d_os << buf;
+ return retval;
+}
+
+# endif /* CVC4_DUMPING */
+
+#endif /* ! CVC4_MUZZLE */
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file output.h
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: none
+ ** Minor contributors (to current version): Tim King, Dejan Jovanovic
+ ** 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 Output utility classes and functions
+ **
+ ** Output utility classes and functions.
+ **/
+
+#include "cvc4_private_library.h"
+
+#ifndef __CVC4__OUTPUT_H
+#define __CVC4__OUTPUT_H
+
+#include <ios>
+#include <iostream>
+#include <streambuf>
+#include <string>
+#include <cstdio>
+#include <cstdarg>
+#include <set>
+#include <utility>
+
+namespace CVC4 {
+
+template <class T, class U>
+std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) CVC4_PUBLIC;
+
+template <class T, class U>
+std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) {
+ return out << "[" << p.first << "," << p.second << "]";
+}
+
+/**
+ * A utility class to provide (essentially) a "/dev/null" streambuf.
+ * If debugging support is compiled in, but debugging for
+ * e.g. "parser" is off, then Debug("parser") returns a stream
+ * attached to a null_streambuf instance so that output is directed to
+ * the bit bucket.
+ */
+class CVC4_PUBLIC null_streambuf : public std::streambuf {
+public:
+ /* Overriding overflow() just ensures that EOF isn't returned on the
+ * stream. Perhaps this is not so critical, but recommended; this
+ * way the output stream looks like it's functioning, in a non-error
+ * state. */
+ int overflow(int c) { return c; }
+};/* class null_streambuf */
+
+/** A null stream-buffer singleton */
+extern null_streambuf null_sb;
+/** A null output stream singleton */
+extern std::ostream null_os CVC4_PUBLIC;
+
+class CVC4_PUBLIC CVC4ostream {
+ static const std::string s_tab;
+ static const int s_indentIosIndex;
+
+ /** The underlying ostream */
+ std::ostream* d_os;
+ /** Are we in the first column? */
+ bool d_firstColumn;
+
+ /** The endl manipulator (why do we need to keep this?) */
+ std::ostream& (*const d_endl)(std::ostream&);
+
+ // do not allow use
+ CVC4ostream& operator=(const CVC4ostream&);
+
+public:
+ CVC4ostream() :
+ d_os(NULL),
+ d_firstColumn(false),
+ d_endl(&std::endl) {
+ }
+ explicit CVC4ostream(std::ostream* os) :
+ d_os(os),
+ d_firstColumn(true),
+ d_endl(&std::endl) {
+ }
+
+ void pushIndent() {
+ if(d_os != NULL) {
+ ++d_os->iword(s_indentIosIndex);
+ }
+ }
+ void popIndent() {
+ if(d_os != NULL) {
+ long& indent = d_os->iword(s_indentIosIndex);
+ if(indent > 0) {
+ --indent;
+ }
+ }
+ }
+
+ CVC4ostream& flush() {
+ if(d_os != NULL) {
+ d_os->flush();
+ }
+ return *this;
+ }
+
+ bool isConnected() { return d_os != NULL; }
+ operator std::ostream&() { return isConnected() ? *d_os : null_os; }
+
+ template <class T>
+ CVC4ostream& operator<<(T const& t) CVC4_PUBLIC;
+
+ // support manipulators, endl, etc..
+ CVC4ostream& operator<<(std::ostream& (*pf)(std::ostream&)) {
+ if(d_os != NULL) {
+ d_os = &(*d_os << pf);
+
+ if(pf == d_endl) {
+ d_firstColumn = true;
+ }
+ }
+ return *this;
+ }
+ CVC4ostream& operator<<(std::ios& (*pf)(std::ios&)) {
+ if(d_os != NULL) {
+ d_os = &(*d_os << pf);
+ }
+ return *this;
+ }
+ CVC4ostream& operator<<(std::ios_base& (*pf)(std::ios_base&)) {
+ if(d_os != NULL) {
+ d_os = &(*d_os << pf);
+ }
+ return *this;
+ }
+ CVC4ostream& operator<<(CVC4ostream& (*pf)(CVC4ostream&)) {
+ return pf(*this);
+ }
+};/* class CVC4ostream */
+
+inline CVC4ostream& push(CVC4ostream& stream) {
+ stream.pushIndent();
+ return stream;
+}
+
+inline CVC4ostream& pop(CVC4ostream& stream) {
+ stream.popIndent();
+ return stream;
+}
+
+template <class T>
+CVC4ostream& CVC4ostream::operator<<(T const& t) {
+ if(d_os != NULL) {
+ if(d_firstColumn) {
+ d_firstColumn = false;
+ long indent = d_os->iword(s_indentIosIndex);
+ for(long i = 0; i < indent; ++i) {
+ d_os = &(*d_os << s_tab);
+ }
+ }
+ d_os = &(*d_os << t);
+ }
+ return *this;
+}
+
+/**
+ * Does nothing; designed for compilation of non-debug/non-trace
+ * builds. None of these should ever be called in such builds, but we
+ * offer this to the compiler so it doesn't complain.
+ */
+class CVC4_PUBLIC NullC {
+public:
+ operator bool() { return false; }
+ operator CVC4ostream() { return CVC4ostream(); }
+ operator std::ostream&() { return null_os; }
+};/* class NullC */
+
+extern NullC nullCvc4Stream CVC4_PUBLIC;
+
+/** The debug output class */
+class CVC4_PUBLIC DebugC {
+ std::set<std::string> d_tags;
+ std::ostream* d_os;
+
+public:
+ explicit DebugC(std::ostream* os) : d_os(os) {}
+
+ int printf(const char* tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
+ int printf(std::string tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
+
+ CVC4ostream operator()(const char* tag) {
+ if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
+ return CVC4ostream(d_os);
+ } else {
+ return CVC4ostream();
+ }
+ }
+ CVC4ostream operator()(std::string tag) {
+ if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
+ return CVC4ostream(d_os);
+ } else {
+ return CVC4ostream();
+ }
+ }
+
+ bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
+ bool on (std::string tag) { d_tags.insert(tag); return true; }
+ bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
+ bool off(std::string tag) { d_tags.erase (tag); return false; }
+ bool off() { d_tags.clear(); return false; }
+
+ bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
+ bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
+
+ std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
+ std::ostream& getStream() { return *d_os; }
+};/* class DebugC */
+
+/** The warning output class */
+class CVC4_PUBLIC WarningC {
+ std::set< std::pair<const char*, size_t> > d_alreadyWarned;
+ std::ostream* d_os;
+
+public:
+ explicit WarningC(std::ostream* os) : d_os(os) {}
+
+ int printf(const char* fmt, ...) __attribute__ ((format(printf, 2, 3)));
+
+ CVC4ostream operator()() { return CVC4ostream(d_os); }
+
+ std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
+ std::ostream& getStream() { return *d_os; }
+
+ bool isOn() const { return d_os != &null_os; }
+
+ // This function supports the WarningOnce() macro, which allows you
+ // to easily indicate that a warning should be emitted, but only
+ // once for a given run of CVC4.
+ bool warnOnce(const char* file, size_t line) {
+ std::pair<const char*, size_t> pr = std::make_pair(file, line);
+ if(d_alreadyWarned.find(pr) != d_alreadyWarned.end()) {
+ // signal caller not to warn again
+ return false;
+ }
+
+ // okay warn this time, but don't do it again
+ d_alreadyWarned.insert(pr);
+ return true;
+ }
+
+};/* class WarningC */
+
+/** The message output class */
+class CVC4_PUBLIC MessageC {
+ std::ostream* d_os;
+
+public:
+ explicit MessageC(std::ostream* os) : d_os(os) {}
+
+ int printf(const char* fmt, ...) __attribute__ ((format(printf, 2, 3)));
+
+ CVC4ostream operator()() { return CVC4ostream(d_os); }
+
+ std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
+ std::ostream& getStream() { return *d_os; }
+
+ bool isOn() const { return d_os != &null_os; }
+};/* class MessageC */
+
+/** The notice output class */
+class CVC4_PUBLIC NoticeC {
+ std::ostream* d_os;
+
+public:
+ explicit NoticeC(std::ostream* os) : d_os(os) {}
+
+ int printf(const char* fmt, ...) __attribute__ ((format(printf, 2, 3)));
+
+ CVC4ostream operator()() { return CVC4ostream(d_os); }
+
+ std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
+ std::ostream& getStream() { return *d_os; }
+
+ bool isOn() const { return d_os != &null_os; }
+};/* class NoticeC */
+
+/** The chat output class */
+class CVC4_PUBLIC ChatC {
+ std::ostream* d_os;
+
+public:
+ explicit ChatC(std::ostream* os) : d_os(os) {}
+
+ int printf(const char* fmt, ...) __attribute__ ((format(printf, 2, 3)));
+
+ CVC4ostream operator()() { return CVC4ostream(d_os); }
+
+ std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
+ std::ostream& getStream() { return *d_os; }
+
+ bool isOn() const { return d_os != &null_os; }
+};/* class ChatC */
+
+/** The trace output class */
+class CVC4_PUBLIC TraceC {
+ std::ostream* d_os;
+ std::set<std::string> d_tags;
+
+public:
+ explicit TraceC(std::ostream* os) : d_os(os) {}
+
+ int printf(const char* tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
+ int printf(std::string tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
+
+ CVC4ostream operator()(const char* tag) {
+ if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
+ return CVC4ostream(d_os);
+ } else {
+ return CVC4ostream();
+ }
+ }
+
+ CVC4ostream operator()(std::string tag) {
+ if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
+ return CVC4ostream(d_os);
+ } else {
+ return CVC4ostream();
+ }
+ }
+
+ bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
+ bool on (std::string tag) { d_tags.insert(tag); return true; }
+ bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
+ bool off(std::string tag) { d_tags.erase (tag); return false; }
+ bool off() { d_tags.clear(); return false; }
+
+ bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
+ bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
+
+ std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
+ std::ostream& getStream() { return *d_os; }
+};/* class TraceC */
+
+/** The dump output class */
+class CVC4_PUBLIC DumpOutC {
+ std::set<std::string> d_tags;
+ std::ostream* d_os;
+
+public:
+ /**
+ * A copy of cout for use by the dumper. This is important because
+ * it has different settings (e.g., the expr printing depth is always
+ * unlimited). */
+ static std::ostream dump_cout;
+
+ explicit DumpOutC(std::ostream* os) : d_os(os) {}
+
+ int printf(const char* tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
+ int printf(std::string tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
+
+ CVC4ostream operator()(const char* tag) {
+ if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
+ return CVC4ostream(d_os);
+ } else {
+ return CVC4ostream();
+ }
+ }
+ CVC4ostream operator()(std::string tag) {
+ if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
+ return CVC4ostream(d_os);
+ } else {
+ return CVC4ostream();
+ }
+ }
+
+ bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
+ bool on (std::string tag) { d_tags.insert(tag); return true; }
+ bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
+ bool off(std::string tag) { d_tags.erase (tag); return false; }
+ bool off() { d_tags.clear(); return false; }
+
+ bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
+ bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
+
+ std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
+ std::ostream& getStream() { return *d_os; }
+};/* class DumpOutC */
+
+/** The debug output singleton */
+extern DebugC DebugChannel CVC4_PUBLIC;
+/** The warning output singleton */
+extern WarningC WarningChannel CVC4_PUBLIC;
+/** The message output singleton */
+extern MessageC MessageChannel CVC4_PUBLIC;
+/** The notice output singleton */
+extern NoticeC NoticeChannel CVC4_PUBLIC;
+/** The chat output singleton */
+extern ChatC ChatChannel CVC4_PUBLIC;
+/** The trace output singleton */
+extern TraceC TraceChannel CVC4_PUBLIC;
+/** The dump output singleton */
+extern DumpOutC DumpOutChannel CVC4_PUBLIC;
+
+#ifdef CVC4_MUZZLE
+
+# define Debug ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DebugChannel
+# define Warning ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::WarningChannel
+# define WarningOnce ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::WarningChannel
+# define Message ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::MessageChannel
+# define Notice ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::NoticeChannel
+# define Chat ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::ChatChannel
+# define Trace ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::TraceChannel
+# define DumpOut ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DumpOutChannel
+
+inline int DebugC::printf(const char* tag, const char* fmt, ...) { return 0; }
+inline int DebugC::printf(std::string tag, const char* fmt, ...) { return 0; }
+inline int WarningC::printf(const char* fmt, ...) { return 0; }
+inline int MessageC::printf(const char* fmt, ...) { return 0; }
+inline int NoticeC::printf(const char* fmt, ...) { return 0; }
+inline int ChatC::printf(const char* fmt, ...) { return 0; }
+inline int TraceC::printf(const char* tag, const char* fmt, ...) { return 0; }
+inline int TraceC::printf(std::string tag, const char* fmt, ...) { return 0; }
+inline int DumpOutC::printf(const char* tag, const char* fmt, ...) { return 0; }
+inline int DumpOutC::printf(std::string tag, const char* fmt, ...) { return 0; }
+
+#else /* CVC4_MUZZLE */
+
+# if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
+# define Debug ::CVC4::DebugChannel
+# else /* CVC4_DEBUG && CVC4_TRACING */
+# define Debug ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DebugChannel
+inline int DebugC::printf(const char* tag, const char* fmt, ...) { return 0; }
+inline int DebugC::printf(std::string tag, const char* fmt, ...) { return 0; }
+# endif /* CVC4_DEBUG && CVC4_TRACING */
+# define Warning (! ::CVC4::WarningChannel.isOn()) ? ::CVC4::nullCvc4Stream : ::CVC4::WarningChannel
+# define WarningOnce (! ::CVC4::WarningChannel.isOn() || ! ::CVC4::WarningChannel.warnOnce(__FILE__,__LINE__)) ? ::CVC4::nullCvc4Stream : ::CVC4::WarningChannel
+# define Message (! ::CVC4::MessageChannel.isOn()) ? ::CVC4::nullCvc4Stream : ::CVC4::MessageChannel
+# define Notice (! ::CVC4::NoticeChannel.isOn()) ? ::CVC4::nullCvc4Stream : ::CVC4::NoticeChannel
+# define Chat (! ::CVC4::ChatChannel.isOn()) ? ::CVC4::nullCvc4Stream : ::CVC4::ChatChannel
+# ifdef CVC4_TRACING
+# define Trace ::CVC4::TraceChannel
+# else /* CVC4_TRACING */
+# define Trace ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::TraceChannel
+inline int TraceC::printf(const char* tag, const char* fmt, ...) { return 0; }
+inline int TraceC::printf(std::string tag, const char* fmt, ...) { return 0; }
+# endif /* CVC4_TRACING */
+# ifdef CVC4_DUMPING
+# define DumpOut ::CVC4::DumpOutChannel
+# else /* CVC4_DUMPING */
+# define DumpOut ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DumpOutChannel
+inline int DumpOutC::printf(const char* tag, const char* fmt, ...) { return 0; }
+inline int DumpOutC::printf(std::string tag, const char* fmt, ...) { return 0; }
+# endif /* CVC4_DUMPING */
+
+#endif /* CVC4_MUZZLE */
+
+// Disallow e.g. !Debug("foo").isOn() forms
+// because the ! will apply before the ? .
+// If a compiler error has directed you here,
+// just parenthesize it e.g. !(Debug("foo").isOn())
+class __cvc4_true {
+ void operator!() CVC4_UNUSED;
+ void operator~() CVC4_UNUSED;
+ void operator-() CVC4_UNUSED;
+ void operator+() CVC4_UNUSED;
+public:
+ inline operator bool() { return true; }
+};/* __cvc4_true */
+
+#if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
+
+class CVC4_PUBLIC ScopedDebug {
+ std::string d_tag;
+ bool d_oldSetting;
+
+public:
+
+ ScopedDebug(std::string tag, bool newSetting = true) :
+ d_tag(tag) {
+ d_oldSetting = Debug.isOn(d_tag);
+ if(newSetting) {
+ Debug.on(d_tag);
+ } else {
+ Debug.off(d_tag);
+ }
+ }
+
+ ScopedDebug(const char* tag, bool newSetting = true) :
+ d_tag(tag) {
+ d_oldSetting = Debug.isOn(d_tag);
+ if(newSetting) {
+ Debug.on(d_tag);
+ } else {
+ Debug.off(d_tag);
+ }
+ }
+
+ ~ScopedDebug() {
+ if(d_oldSetting) {
+ Debug.on(d_tag);
+ } else {
+ Debug.off(d_tag);
+ }
+ }
+};/* class ScopedDebug */
+
+#else /* CVC4_DEBUG && CVC4_TRACING */
+
+class CVC4_PUBLIC ScopedDebug {
+public:
+ ScopedDebug(std::string tag, bool newSetting = true) {}
+ ScopedDebug(const char* tag, bool newSetting = true) {}
+};/* class ScopedDebug */
+
+#endif /* CVC4_DEBUG && CVC4_TRACING */
+
+#ifdef CVC4_TRACING
+
+class CVC4_PUBLIC ScopedTrace {
+ std::string d_tag;
+ bool d_oldSetting;
+
+public:
+
+ ScopedTrace(std::string tag, bool newSetting = true) :
+ d_tag(tag) {
+ d_oldSetting = Trace.isOn(d_tag);
+ if(newSetting) {
+ Trace.on(d_tag);
+ } else {
+ Trace.off(d_tag);
+ }
+ }
+
+ ScopedTrace(const char* tag, bool newSetting = true) :
+ d_tag(tag) {
+ d_oldSetting = Trace.isOn(d_tag);
+ if(newSetting) {
+ Trace.on(d_tag);
+ } else {
+ Trace.off(d_tag);
+ }
+ }
+
+ ~ScopedTrace() {
+ if(d_oldSetting) {
+ Trace.on(d_tag);
+ } else {
+ Trace.off(d_tag);
+ }
+ }
+};/* class ScopedTrace */
+
+#else /* CVC4_TRACING */
+
+class CVC4_PUBLIC ScopedTrace {
+public:
+ ScopedTrace(std::string tag, bool newSetting = true) {}
+ ScopedTrace(const char* tag, bool newSetting = true) {}
+};/* class ScopedTrace */
+
+#endif /* CVC4_TRACING */
+
+/**
+ * Pushes an indentation level on construction, pop on destruction.
+ * Useful for tracing recursive functions especially, but also can be
+ * used for clearly separating different phases of an algorithm,
+ * or iterations of a loop, or... etc.
+ */
+class CVC4_PUBLIC IndentedScope {
+ CVC4ostream d_out;
+public:
+ inline IndentedScope(CVC4ostream out);
+ inline ~IndentedScope();
+};/* class IndentedScope */
+
+#if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
+inline IndentedScope::IndentedScope(CVC4ostream out) : d_out(out) { d_out << push; }
+inline IndentedScope::~IndentedScope() { d_out << pop; }
+#else /* CVC4_DEBUG && CVC4_TRACING */
+inline IndentedScope::IndentedScope(CVC4ostream out) {}
+inline IndentedScope::~IndentedScope() {}
+#endif /* CVC4_DEBUG && CVC4_TRACING */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__OUTPUT_H */
--- /dev/null
+/********************* */
+/*! \file tls.h.in
+ ** \verbatim
+ ** Original author: ACSYS
+ ** 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 Header to define CVC4_THREAD whether or not TLS is
+ ** supported by the compiler/runtime platform
+ **
+ ** Header to define CVC4_THREAD whether or not TLS is supported by
+ ** the compiler/runtime platform. If not, an implementation based on
+ ** pthread_getspecific() / pthread_setspecific() is given.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__TLS_H
+#define __CVC4__TLS_H
+
+// A bit obnoxious: we have to take varargs to support multi-argument
+// template types in the threadlocals.
+// E.g. "CVC4_THREADLOCAL(hash_set<type, hasher>*)" fails otherwise,
+// due to the embedded comma.
+#if @CVC4_TLS_SUPPORTED@
+# define CVC4_THREADLOCAL(__type...) @CVC4_TLS@ __type
+# define CVC4_THREADLOCAL_PUBLIC(__type...) @CVC4_TLS@ CVC4_PUBLIC __type
+# define CVC4_THREADLOCAL_TYPE(__type...) __type
+#else
+# include <pthread.h>
+# define CVC4_THREADLOCAL(__type...) ::CVC4::ThreadLocal< __type >
+# define CVC4_THREADLOCAL_PUBLIC(__type...) CVC4_PUBLIC ::CVC4::ThreadLocal< __type >
+# define CVC4_THREADLOCAL_TYPE(__type...) ::CVC4::ThreadLocal< __type >
+
+namespace CVC4 {
+
+template <class T, bool small>
+class ThreadLocalImpl;
+
+template <class T>
+class ThreadLocalImpl<T, true> {
+ pthread_key_t d_key;
+
+ static void cleanup(void*) {
+ }
+
+public:
+ ThreadLocalImpl() {
+ pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
+ }
+
+ ThreadLocalImpl(const T& t) {
+ pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
+ pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(t)));
+ }
+
+ ThreadLocalImpl(const ThreadLocalImpl& tl) {
+ pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
+ pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(static_cast<const T&>(tl))));
+ }
+
+ ThreadLocalImpl& operator=(const T& t) {
+ pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(t)));
+ return *this;
+ }
+ ThreadLocalImpl& operator=(const ThreadLocalImpl& tl) {
+ pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(static_cast<const T&>(tl))));
+ return *this;
+ }
+
+ operator T() const {
+ return static_cast<T>(reinterpret_cast<size_t>(pthread_getspecific(d_key)));
+ }
+};/* class ThreadLocalImpl<T, true> */
+
+template <class T>
+class ThreadLocalImpl<T*, true> {
+ pthread_key_t d_key;
+
+ static void cleanup(void*) {
+ }
+
+public:
+ ThreadLocalImpl() {
+ pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
+ }
+
+ ThreadLocalImpl(const T* t) {
+ pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
+ pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(t)));
+ }
+
+ ThreadLocalImpl(const ThreadLocalImpl& tl) {
+ pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
+ pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(static_cast<const T*>(tl))));
+ }
+
+ ThreadLocalImpl& operator=(const T* t) {
+ pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(t)));
+ return *this;
+ }
+ ThreadLocalImpl& operator=(const ThreadLocalImpl& tl) {
+ pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(static_cast<const T*>(tl))));
+ return *this;
+ }
+
+ operator T*() const {
+ return static_cast<T*>(pthread_getspecific(d_key));
+ }
+
+ T operator*() {
+ return *static_cast<T*>(pthread_getspecific(d_key));
+ }
+ T* operator->() {
+ return static_cast<T*>(pthread_getspecific(d_key));
+ }
+};/* class ThreadLocalImpl<T*, true> */
+
+template <class T>
+class ThreadLocalImpl<T, false> {
+};/* class ThreadLocalImpl<T, false> */
+
+template <class T>
+class ThreadLocal : public ThreadLocalImpl<T, sizeof(T) <= sizeof(void*)> {
+ typedef ThreadLocalImpl<T, sizeof(T) <= sizeof(void*)> super;
+
+public:
+ ThreadLocal() : super() {}
+ ThreadLocal(const T& t) : super(t) {}
+ ThreadLocal(const ThreadLocal<T>& tl) : super(tl) {}
+
+ ThreadLocal<T>& operator=(const T& t) {
+ return static_cast< ThreadLocal<T>& >(super::operator=(t));
+ }
+ ThreadLocal<T>& operator=(const ThreadLocal<T>& tl) {
+ return static_cast< ThreadLocal<T>& >(super::operator=(tl));
+ }
+};/* class ThreadLocal<T> */
+
+template <class T>
+class ThreadLocal<T*> : public ThreadLocalImpl<T*, sizeof(T*) <= sizeof(void*)> {
+ typedef ThreadLocalImpl<T*, sizeof(T*) <= sizeof(void*)> super;
+
+public:
+ ThreadLocal() : super() {}
+ ThreadLocal(T* t) : super(t) {}
+ ThreadLocal(const ThreadLocal<T*>& tl) : super(tl) {}
+
+ ThreadLocal<T*>& operator=(T* t) {
+ return static_cast< ThreadLocal<T*>& >(super::operator=(t));
+ }
+ ThreadLocal<T*>& operator=(const ThreadLocal<T*>& tl) {
+ return static_cast< ThreadLocal<T*>& >(super::operator=(tl));
+ }
+ // special operators for pointers
+ T& operator*() {
+ return *static_cast<T*>(*this);
+ }
+ const T& operator*() const {
+ return *static_cast<const T*>(*this);
+ }
+ T* operator->() {
+ return static_cast<T*>(*this);
+ }
+ const T* operator->() const {
+ return static_cast<const T*>(*this);
+ }
+ T* operator++() {
+ T* p = *this;
+ *this = ++p;
+ return p;
+ }
+ T* operator++(int) {
+ T* p = *this;
+ *this = p + 1;
+ return p;
+ }
+ T* operator--() {
+ T* p = *this;
+ *this = --p;
+ return p;
+ }
+ T* operator--(int) {
+ T* p = *this;
+ *this = p - 1;
+ return p;
+ }
+};/* class ThreadLocal<T*> */
+
+}/* CVC4 namespace */
+
+#endif /* @CVC4_TLS_SUPPORTED@ */
+
+#endif /* __CVC4__TLS_H */
#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
#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;
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);
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;
#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;
--- /dev/null
+/********************* */
+/*! \file backtrackable.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 Contains a backtrackable list
+ **
+ ** Contains a backtrackable list.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__UTIL__BACKTRACKABLE_H
+#define __CVC4__UTIL__BACKTRACKABLE_H
+
+#include <cstdlib>
+#include <vector>
+#include "context/cdo.h"
+
+namespace CVC4 {
+
+template <class T> class List;
+template <class T> class List_iterator;
+template <class T> class Backtracker;
+
+template <class T>
+class ListNode {
+private:
+ T data;
+ ListNode<T>* next;
+
+ bool empty;
+ ListNode(const T& t, ListNode<T>* n, bool e = false) : data(t), next(n), empty(e) {}
+ ~ListNode() {
+ // maybe set to NULL
+ delete next;
+ }
+
+ friend class List<T>;
+ friend class List_iterator<T>;
+};/* class ListNode<T> */
+
+template <class T>
+class List_iterator : public std::iterator <std::forward_iterator_tag, T> {
+ friend class List<T>;
+
+public:
+ const T& operator*();
+ List_iterator<T>& operator++();
+ List_iterator<T> operator++(int);
+ bool operator!=(const List_iterator<T> & other) const;
+
+private:
+ const ListNode<T>* pointee;
+ List_iterator(const ListNode<T>* p) : pointee(p) {}
+
+};/* class List_iterator<T> */
+
+template <class T>
+const T& List_iterator<T>::operator*() {
+ return pointee->data;
+}
+
+template <class T>
+List_iterator<T>& List_iterator<T>::operator++() {
+ Assert(pointee != NULL);
+ pointee = pointee->next;
+ while(pointee != NULL && pointee->empty ) {
+ pointee = pointee->next;
+ }
+ return *this;
+}
+
+template <class T>
+List_iterator<T> List_iterator<T>::operator++(int) {
+ List_iterator<T> it = *this;
+ ++*this;
+ return it;
+}
+
+template <class T>
+bool List_iterator<T>::operator!=(const List_iterator<T>& other) const {
+ return (this->pointee != other.pointee);
+}
+
+// !! for the backtracking to work the lists must be allocated on the heap
+// therefore the hashmap from TNode to List<TNode> should store pointers!
+template <class T>
+class List {
+ ListNode<T>* head;
+ ListNode<T>* tail;
+ ListNode<T>* ptr_to_head;
+ bool uninitialized;
+ Backtracker<T>* bck;
+ List (const List&) {}
+public:
+ List(Backtracker<T>* b) : ptr_to_head(NULL), uninitialized(true), bck(b) {
+ head = tail = (ListNode<T>*)calloc(1,sizeof(ListNode<T>));
+ head->next = NULL;
+ head->empty = true;
+ }
+ ~List() {delete head;}
+ bool empty() {
+ bck->checkConsistency();
+ return head == NULL;
+ }
+ void append(const T& d);
+ //typedef List_iterator<T> iterator;
+ typedef List_iterator<T> const_iterator;
+
+ const_iterator begin() {
+ bck->checkConsistency();
+ if(head->empty) {
+ ListNode<T>* temp = head;
+ // if the head is empty return the first non-empty element or NULL
+ while(temp != NULL && temp->empty ) {
+ temp = temp->next;
+ }
+ return List_iterator<T>(temp);
+ }
+ return List_iterator<T>(head);
+ }
+
+ const_iterator end() {
+ bck->checkConsistency();
+ return List_iterator<T>(NULL);
+ }
+ void concat(List<T>* other);
+ void unconcat(List<T>* other);
+};/* class List */
+
+template <class T>
+void List<T>::append (const T& d) {
+ bck->checkConsistency();
+
+ if(uninitialized) {
+ new(head)ListNode<T> (d, head->next);
+ //head->data = d;
+ head->empty = false;
+ //Assert(tail == head); FIXME: do I need this because this list might be empty but append to another one
+ uninitialized = false;
+
+ } else {
+ ListNode<T>* new_node = new ListNode<T>(d, head);
+ head = new_node;
+ }
+
+ if(ptr_to_head != NULL) {
+ ptr_to_head->next = head;
+ }
+}
+
+template <class T>
+void List<T>::concat (List<T>* other) {
+ bck->checkConsistency();
+ bck->notifyConcat(this, other);
+ Assert(tail->next==NULL);
+ tail->next = other->head;
+ Assert(other->ptr_to_head == NULL);
+ other->ptr_to_head = tail;
+ tail = other->tail;
+}
+
+template <class T>
+void List<T>::unconcat(List<T>* other) {
+ // we do not need to check consistency since this is only called by the
+ // Backtracker when we are inconsistent
+ Assert(other->ptr_to_head != NULL);
+ other->ptr_to_head->next = NULL;
+ tail = other->ptr_to_head;
+ other->ptr_to_head = NULL;
+}
+
+/* Backtrackable Table */
+
+template <class T>
+class Backtracker {
+ friend class List<T>;
+ std::vector<std::pair<List<T>*,List<T>*> > undo_stack;
+
+ int curr_level;
+ context::CDO<int> pop_level;
+
+ void checkConsistency();
+ void notifyConcat(List<T>* a, List<T>* b);
+public:
+ Backtracker(context::Context* c) : undo_stack(), curr_level(0), pop_level(c, 0) {}
+ ~Backtracker() {}
+
+};/* class Backtrackable */
+
+template <class T> void Backtracker<T>::notifyConcat(List<T>* a, List<T>* b) {
+ curr_level++;
+ pop_level.set(pop_level.get()+1);
+ undo_stack.push_back( std::make_pair(a, b));
+}
+
+template <class T> void Backtracker<T>::checkConsistency() {
+ if( curr_level == pop_level || pop_level == -1) {
+ return;
+ }
+ Assert(curr_level > pop_level);
+
+ while (curr_level > pop_level) {
+ curr_level--;
+ List<T>* l1 = undo_stack[curr_level].first;
+ List<T>* l2 = undo_stack[curr_level].second;
+ l1->unconcat(l2);
+ undo_stack.pop_back();
+ }
+ Assert(curr_level == pop_level);
+}
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__UTIL__BACKTRACKABLE_H */
#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 {
#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 {
#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 {
#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
#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 {
#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 {
#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 {
#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 {
#include <iostream>
#include <vector>
+#include "base/cvc4_assert.h"
#include "context/context.h"
-#include "util/cvc4_assert.h"
+
namespace CVC4 {
namespace context {
#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 {
#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 {
#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"
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;
#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"
--- /dev/null
+/********************* */
+/*! \file decision_attributes.h
+ ** \verbatim
+ ** Original author: Kshitij Bansal
+ ** 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 Rewriter attributes
+ **
+ ** Rewriter attributes.
+ **/
+
+#include "cvc4_private.h"
+
+#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 {
+namespace attr {
+ struct DecisionWeightTag {};
+}/* CVC4::decision::attr namespace */
+
+typedef expr::Attribute<attr::DecisionWeightTag, DecisionWeight> DecisionWeightAttr;
+
+}/* CVC4::decision namespace */
+}/* CVC4 namespace */
+
+#endif /* __CVC4__DECISION__DECISION_ATTRIBUTES_H */
**
** 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;
#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;
+++ /dev/null
-/********************* */
-/*! \file decision_mode.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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "decision/decision_mode.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, decision::DecisionMode mode) {
- switch(mode) {
- case decision::DECISION_STRATEGY_INTERNAL:
- out << "DECISION_STRATEGY_INTERNAL";
- break;
- case decision::DECISION_STRATEGY_JUSTIFICATION:
- out << "DECISION_STRATEGY_JUSTIFICATION";
- break;
- default:
- out << "DecisionMode:UNKNOWN![" << unsigned(mode) << "]";
- }
-
- return out;
-}
-
-}/* CVC4 namespace */
-
+++ /dev/null
-/********************* */
-/*! \file decision_mode.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__SMT__DECISION_MODE_H
-#define __CVC4__SMT__DECISION_MODE_H
-
-#include <iostream>
-
-namespace CVC4 {
-namespace decision {
-
-/** Enumeration of decision strategies */
-enum DecisionMode {
-
- /**
- * Decision engine doesn't do anything. Use sat solver's internal
- * heuristics
- */
- DECISION_STRATEGY_INTERNAL,
-
- /**
- * Use the justification heuristic
- */
- DECISION_STRATEGY_JUSTIFICATION,
-
- /**
- * Use may-relevancy.
- */
- DECISION_STRATEGY_RELEVANCY
-
-};/* enum DecisionMode */
-
-
-/** Enumeration of combining functions for computing internal weights */
-enum DecisionWeightInternal {
- DECISION_WEIGHT_INTERNAL_OFF,
- DECISION_WEIGHT_INTERNAL_MAX,
- DECISION_WEIGHT_INTERNAL_SUM,
- DECISION_WEIGHT_INTERNAL_USR1
-};/* enum DecisionInternalWeight */
-
-}/* CVC4::decision namespace */
-
-std::ostream& operator<<(std::ostream& out, decision::DecisionMode mode) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__SMT__DECISION_MODE_H */
#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 {
**
** 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,
}
DecisionWeight JustificationHeuristic::getWeight(TNode n) {
- if(!n.hasAttribute(theory::DecisionWeightAttr()) ) {
+ if(!n.hasAttribute(DecisionWeightAttr()) ) {
DecisionWeightInternal combiningFn =
options::decisionWeightInternal();
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) {
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;
}
return noSplitter ? NO_SPLITTER : DONT_KNOW;
}
+
+} /* namespace CVC4 */
#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 {
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module DECISION "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"
- 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"
- ignore all nodes greater than threshold in first attempt to pick decision
-
-expert-option decisionUseWeight --decision-use-weight bool :default false
- use the weight nodes (locally, by looking at children) to direct recursive search
-
-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"
- computer weights of internal nodes using children: off, max, sum, usr1 (meaning evolving)
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \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 */
-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 \
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 \
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 \
--- /dev/null
+/********************* */
+/*! \file array.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 Array types.
+ **
+ ** Array types.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__ARRAY_H
+#define __CVC4__ARRAY_H
+
+// we get ArrayType right now by #including type.h.
+// array.h is still useful for the auto-generated kinds #includes.
+#include "expr/type.h"
+
+#endif /* __CVC4__ARRAY_H */
--- /dev/null
+%{
+#include "expr/array.h"
+%}
+
+%include "expr/array.h"
--- /dev/null
+/********************* */
+/*! \file array_store_all.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 Representation of a constant array (an array in which the
+ ** element is the same for all indices)
+ **
+ ** Representation of a constant array (an array in which the element is
+ ** the same for all indices).
+ **/
+
+#include "expr/array_store_all.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) {
+ return out << "__array_store_all__(" << asa.getType() << ", " << asa.getExpr() << ')';
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file array_store_all.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 Representation of a constant array (an array in which the
+ ** element is the same for all indices)
+ **
+ ** Representation of a constant array (an array in which the element is
+ ** the same for all indices).
+ **/
+
+#include "cvc4_public.h"
+
+#pragma once
+
+namespace CVC4 {
+ // messy; Expr needs ArrayStoreAll (because it's the payload of a
+ // CONSTANT-kinded expression), and ArrayStoreAll needs Expr.
+ class CVC4_PUBLIC ArrayStoreAll;
+}/* CVC4 namespace */
+
+#include "expr/expr.h"
+#include "expr/type.h"
+#include <iostream>
+
+namespace CVC4 {
+
+class CVC4_PUBLIC ArrayStoreAll {
+ const ArrayType d_type;
+ const Expr d_expr;
+
+public:
+
+ ArrayStoreAll(ArrayType type, Expr expr) throw(IllegalArgumentException) :
+ d_type(type),
+ d_expr(expr) {
+
+ // this check is stronger than the assertion check in the expr manager that ArrayTypes are actually array types
+ // because this check is done in production builds too
+ CheckArgument(type.isArray(), type, "array store-all constants can only be created for array types, not `%s'", type.toString().c_str());
+
+ CheckArgument(expr.getType().isComparableTo(type.getConstituentType()), expr, "expr type `%s' does not match constituent type of array type `%s'", expr.getType().toString().c_str(), type.toString().c_str());
+ CheckArgument(expr.isConst(), expr, "ArrayStoreAll requires a constant expression");
+ }
+
+ ~ArrayStoreAll() throw() {
+ }
+
+ ArrayType getType() const throw() {
+ return d_type;
+ }
+ Expr getExpr() const throw() {
+ return d_expr;
+ }
+
+ bool operator==(const ArrayStoreAll& asa) const throw() {
+ return d_type == asa.d_type && d_expr == asa.d_expr;
+ }
+ bool operator!=(const ArrayStoreAll& asa) const throw() {
+ return !(*this == asa);
+ }
+
+ bool operator<(const ArrayStoreAll& asa) const throw() {
+ return d_type < asa.d_type ||
+ (d_type == asa.d_type && d_expr < asa.d_expr);
+ }
+ bool operator<=(const ArrayStoreAll& asa) const throw() {
+ return d_type < asa.d_type ||
+ (d_type == asa.d_type && d_expr <= asa.d_expr);
+ }
+ bool operator>(const ArrayStoreAll& asa) const throw() {
+ return !(*this <= asa);
+ }
+ bool operator>=(const ArrayStoreAll& asa) const throw() {
+ return !(*this < asa);
+ }
+
+};/* class ArrayStoreAll */
+
+std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) CVC4_PUBLIC;
+
+/**
+ * Hash function for the ArrayStoreAll constants.
+ */
+struct CVC4_PUBLIC ArrayStoreAllHashFunction {
+ inline size_t operator()(const ArrayStoreAll& asa) const {
+ return TypeHashFunction()(asa.getType()) * ExprHashFunction()(asa.getExpr());
+ }
+};/* struct ArrayStoreAllHashFunction */
+
+}/* CVC4 namespace */
--- /dev/null
+%{
+#include "expr/array_store_all.h"
+%}
+
+%rename(equals) CVC4::ArrayStoreAll::operator==(const ArrayStoreAll&) const;
+%ignore CVC4::ArrayStoreAll::operator!=(const ArrayStoreAll&) const;
+%rename(less) CVC4::ArrayStoreAll::operator<(const ArrayStoreAll&) const;
+%rename(lessEqual) CVC4::ArrayStoreAll::operator<=(const ArrayStoreAll&) const;
+%rename(greater) CVC4::ArrayStoreAll::operator>(const ArrayStoreAll&) const;
+%rename(greaterEqual) CVC4::ArrayStoreAll::operator>=(const ArrayStoreAll&) const;
+
+%rename(apply) CVC4::ArrayStoreAllHashFunction::operator()(const ArrayStoreAll&) const;
+
+%ignore CVC4::operator<<(std::ostream&, const ArrayStoreAll&);
+
+%include "expr/type.i"
+%include "expr/array_store_all.h"
--- /dev/null
+/********************* */
+/*! \file ascription_type.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 A class representing a type ascription
+ **
+ ** A class representing a parameter for the type ascription operator.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__ASCRIPTION_TYPE_H
+#define __CVC4__ASCRIPTION_TYPE_H
+
+#include "expr/type.h"
+
+namespace CVC4 {
+
+/**
+ * A class used to parameterize a type ascription. For example,
+ * "nil :: list<nat>" is an expression of kind APPLY_TYPE_ASCRIPTION.
+ * The parameter is an ASCRIPTION_TYPE-kinded expression with an
+ * AscriptionType payload. (Essentially, all of this is a way to
+ * coerce a Type into the expression tree.)
+ */
+class CVC4_PUBLIC AscriptionType {
+ Type d_type;
+public:
+ AscriptionType(Type t) throw() : d_type(t) {}
+ Type getType() const throw() { return d_type; }
+ bool operator==(const AscriptionType& other) const throw() {
+ return d_type == other.d_type;
+ }
+ bool operator!=(const AscriptionType& other) const throw() {
+ return d_type != other.d_type;
+ }
+};/* class AscriptionType */
+
+/**
+ * A hash function for type ascription operators.
+ */
+struct CVC4_PUBLIC AscriptionTypeHashFunction {
+ inline size_t operator()(const AscriptionType& at) const {
+ return TypeHashFunction()(at.getType());
+ }
+};/* struct AscriptionTypeHashFunction */
+
+/** An output routine for AscriptionTypes */
+inline std::ostream& operator<<(std::ostream& out, AscriptionType at) {
+ out << at.getType();
+ return out;
+}
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__ASCRIPTION_TYPE_H */
--- /dev/null
+%{
+#include "expr/ascription_type.h"
+%}
+
+%rename(equals) CVC4::AscriptionType::operator==(const AscriptionType&) const;
+%ignore CVC4::AscriptionType::operator!=(const AscriptionType&) const;
+
+%rename(apply) CVC4::AscriptionTypeHashFunction::operator()(const AscriptionType&) const;
+
+%ignore CVC4::operator<<(std::ostream&, AscriptionType);
+
+%include "expr/ascription_type.h"
**
** 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 {
--- /dev/null
+/********************* */
+/*! \file chain.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_public.h"
+
+#ifndef __CVC4__CHAIN_H
+#define __CVC4__CHAIN_H
+
+#include "expr/kind.h"
+#include <iostream>
+
+namespace CVC4 {
+
+/** A class to represent a chained, built-in operator. */
+class CVC4_PUBLIC Chain {
+ Kind d_kind;
+public:
+ explicit Chain(Kind k) : d_kind(k) { }
+ bool operator==(const Chain& ch) const { return d_kind == ch.d_kind; }
+ bool operator!=(const Chain& ch) const { return d_kind != ch.d_kind; }
+ Kind getOperator() const { return d_kind; }
+};/* class Chain */
+
+inline std::ostream& operator<<(std::ostream& out, const Chain& ch) CVC4_PUBLIC;
+inline std::ostream& operator<<(std::ostream& out, const Chain& ch) {
+ return out << ch.getOperator();
+}
+
+struct CVC4_PUBLIC ChainHashFunction {
+ size_t operator()(const Chain& ch) const {
+ return kind::KindHashFunction()(ch.getOperator());
+ }
+};/* struct ChainHashFunction */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__CHAIN_H */
--- /dev/null
+%{
+#include "expr/chain.h"
+%}
+
+%rename(equals) CVC4::Chain::operator==(const Chain&) const;
+%ignore CVC4::Chain::operator!=(const Chain&) const;
+
+%ignore CVC4::operator<<(std::ostream&, const Chain&);
+
+%rename(apply) CVC4::ChainHashFunction::operator()(const CVC4::Chain&) const;
+
+%include "expr/chain.h"
+++ /dev/null
-/********************* */
-/*! \file command.cpp
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: none
- ** Minor contributors (to current version): Kshitij Bansal, Dejan Jovanovic, Andrew Reynolds, Francois Bobot
- ** 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 command objects.
- **
- ** Implementation of command objects.
- **/
-
-#include <iostream>
-#include <vector>
-#include <utility>
-#include <iterator>
-#include <sstream>
-#include <exception>
-
-#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 "expr/node.h"
-#include "printer/printer.h"
-
-using namespace std;
-
-namespace CVC4 {
-
-const int CommandPrintSuccess::s_iosIndex = std::ios_base::xalloc();
-const CommandSuccess* CommandSuccess::s_instance = new CommandSuccess();
-const CommandInterrupted* CommandInterrupted::s_instance = new CommandInterrupted();
-
-std::ostream& operator<<(std::ostream& out, const Command& c) throw() {
- c.toStream(out,
- Node::setdepth::getDepth(out),
- Node::printtypes::getPrintTypes(out),
- Node::dag::getDag(out),
- Node::setlanguage::getLanguage(out));
- return out;
-}
-
-ostream& operator<<(ostream& out, const Command* c) throw() {
- if(c == NULL) {
- out << "null";
- } else {
- out << *c;
- }
- return out;
-}
-
-std::ostream& operator<<(std::ostream& out, const CommandStatus& s) throw() {
- s.toStream(out, Node::setlanguage::getLanguage(out));
- return out;
-}
-
-ostream& operator<<(ostream& out, const CommandStatus* s) throw() {
- if(s == NULL) {
- out << "null";
- } else {
- out << *s;
- }
- return out;
-}
-
-/* class Command */
-
-Command::Command() throw() : d_commandStatus(NULL), d_muted(false) {
-}
-
-Command::Command(const Command& cmd) {
- d_commandStatus = (cmd.d_commandStatus == NULL) ? NULL : &cmd.d_commandStatus->clone();
- d_muted = cmd.d_muted;
-}
-
-Command::~Command() throw() {
- if(d_commandStatus != NULL && d_commandStatus != CommandSuccess::instance()) {
- delete d_commandStatus;
- }
-}
-
-bool Command::ok() const throw() {
- // either we haven't run the command yet, or it ran successfully
- return d_commandStatus == NULL || dynamic_cast<const CommandSuccess*>(d_commandStatus) != NULL;
-}
-
-bool Command::fail() const throw() {
- return d_commandStatus != NULL && dynamic_cast<const CommandFailure*>(d_commandStatus) != NULL;
-}
-
-bool Command::interrupted() const throw() {
- return d_commandStatus != NULL && dynamic_cast<const CommandInterrupted*>(d_commandStatus) != NULL;
-}
-
-void Command::invoke(SmtEngine* smtEngine, std::ostream& out) throw() {
- invoke(smtEngine);
- if(!(isMuted() && ok())) {
- printResult(out, smtEngine->getOption("command-verbosity:" + getCommandName()).getIntegerValue().toUnsignedInt());
- }
-}
-
-std::string Command::toString() const throw() {
- std::stringstream ss;
- toStream(ss);
- return ss.str();
-}
-
-void Command::toStream(std::ostream& out, int toDepth, bool types, size_t dag,
- OutputLanguage language) const throw() {
- Printer::getPrinter(language)->toStream(out, this, toDepth, types, dag);
-}
-
-void CommandStatus::toStream(std::ostream& out, OutputLanguage language) const throw() {
- Printer::getPrinter(language)->toStream(out, this);
-}
-
-void Command::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(d_commandStatus != NULL) {
- if((!ok() && verbosity >= 1) || verbosity >= 2) {
- out << *d_commandStatus;
- }
- }
-}
-
-/* class EmptyCommand */
-
-EmptyCommand::EmptyCommand(std::string name) throw() :
- d_name(name) {
-}
-
-std::string EmptyCommand::getName() const throw() {
- return d_name;
-}
-
-void EmptyCommand::invoke(SmtEngine* smtEngine) throw() {
- /* empty commands have no implementation */
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* EmptyCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new EmptyCommand(d_name);
-}
-
-Command* EmptyCommand::clone() const {
- return new EmptyCommand(d_name);
-}
-
-std::string EmptyCommand::getCommandName() const throw() {
- return "empty";
-}
-
-/* class EchoCommand */
-
-EchoCommand::EchoCommand(std::string output) throw() :
- d_output(output) {
-}
-
-std::string EchoCommand::getOutput() const throw() {
- return d_output;
-}
-
-void EchoCommand::invoke(SmtEngine* smtEngine) throw() {
- /* we don't have an output stream here, nothing to do */
- d_commandStatus = CommandSuccess::instance();
-}
-
-void EchoCommand::invoke(SmtEngine* smtEngine, std::ostream& out) throw() {
- out << d_output << std::endl;
- d_commandStatus = CommandSuccess::instance();
- printResult(out, smtEngine->getOption("command-verbosity:" + getCommandName()).getIntegerValue().toUnsignedInt());
-}
-
-Command* EchoCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new EchoCommand(d_output);
-}
-
-Command* EchoCommand::clone() const {
- return new EchoCommand(d_output);
-}
-
-std::string EchoCommand::getCommandName() const throw() {
- return "echo";
-}
-
-/* class AssertCommand */
-
-AssertCommand::AssertCommand(const Expr& e, bool inUnsatCore) throw() :
- d_expr(e), d_inUnsatCore(inUnsatCore) {
-}
-
-Expr AssertCommand::getExpr() const throw() {
- return d_expr;
-}
-
-void AssertCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- smtEngine->assertFormula(d_expr, d_inUnsatCore);
- d_commandStatus = CommandSuccess::instance();
- } catch(UnsafeInterruptException& e) {
- d_commandStatus = new CommandInterrupted();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* AssertCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new AssertCommand(d_expr.exportTo(exprManager, variableMap), d_inUnsatCore);
-}
-
-Command* AssertCommand::clone() const {
- return new AssertCommand(d_expr, d_inUnsatCore);
-}
-
-std::string AssertCommand::getCommandName() const throw() {
- return "assert";
-}
-
-/* class PushCommand */
-
-void PushCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- smtEngine->push();
- d_commandStatus = CommandSuccess::instance();
- } catch(UnsafeInterruptException& e) {
- d_commandStatus = new CommandInterrupted();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* PushCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new PushCommand();
-}
-
-Command* PushCommand::clone() const {
- return new PushCommand();
-}
-
-std::string PushCommand::getCommandName() const throw() {
- return "push";
-}
-
-/* class PopCommand */
-
-void PopCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- smtEngine->pop();
- d_commandStatus = CommandSuccess::instance();
- } catch(UnsafeInterruptException& e) {
- d_commandStatus = new CommandInterrupted();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* PopCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new PopCommand();
-}
-
-Command* PopCommand::clone() const {
- return new PopCommand();
-}
-
-std::string PopCommand::getCommandName() const throw() {
- return "pop";
-}
-
-/* class CheckSatCommand */
-
-CheckSatCommand::CheckSatCommand() throw() :
- d_expr() {
-}
-
-CheckSatCommand::CheckSatCommand(const Expr& expr, bool inUnsatCore) throw() :
- d_expr(expr), d_inUnsatCore(inUnsatCore) {
-}
-
-Expr CheckSatCommand::getExpr() const throw() {
- return d_expr;
-}
-
-void CheckSatCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_result = smtEngine->checkSat(d_expr);
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Result CheckSatCommand::getResult() const throw() {
- return d_result;
-}
-
-void CheckSatCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- out << d_result << endl;
- }
-}
-
-Command* CheckSatCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- CheckSatCommand* c = new CheckSatCommand(d_expr.exportTo(exprManager, variableMap), d_inUnsatCore);
- c->d_result = d_result;
- return c;
-}
-
-Command* CheckSatCommand::clone() const {
- CheckSatCommand* c = new CheckSatCommand(d_expr, d_inUnsatCore);
- c->d_result = d_result;
- return c;
-}
-
-std::string CheckSatCommand::getCommandName() const throw() {
- return "check-sat";
-}
-
-/* class QueryCommand */
-
-QueryCommand::QueryCommand(const Expr& e, bool inUnsatCore) throw() :
- d_expr(e), d_inUnsatCore(inUnsatCore) {
-}
-
-Expr QueryCommand::getExpr() const throw() {
- return d_expr;
-}
-
-void QueryCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_result = smtEngine->query(d_expr);
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Result QueryCommand::getResult() const throw() {
- return d_result;
-}
-
-void QueryCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- out << d_result << endl;
- }
-}
-
-Command* QueryCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- QueryCommand* c = new QueryCommand(d_expr.exportTo(exprManager, variableMap), d_inUnsatCore);
- c->d_result = d_result;
- return c;
-}
-
-Command* QueryCommand::clone() const {
- QueryCommand* c = new QueryCommand(d_expr, d_inUnsatCore);
- c->d_result = d_result;
- return c;
-}
-
-std::string QueryCommand::getCommandName() const throw() {
- return "query";
-}
-
-/* class ResetCommand */
-
-void ResetCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- smtEngine->reset();
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* ResetCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new ResetCommand();
-}
-
-Command* ResetCommand::clone() const {
- return new ResetCommand();
-}
-
-std::string ResetCommand::getCommandName() const throw() {
- return "reset";
-}
-
-/* class ResetAssertionsCommand */
-
-void ResetAssertionsCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- smtEngine->resetAssertions();
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* ResetAssertionsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new ResetAssertionsCommand();
-}
-
-Command* ResetAssertionsCommand::clone() const {
- return new ResetAssertionsCommand();
-}
-
-std::string ResetAssertionsCommand::getCommandName() const throw() {
- return "reset-assertions";
-}
-
-/* class QuitCommand */
-
-void QuitCommand::invoke(SmtEngine* smtEngine) throw() {
- Dump("benchmark") << *this;
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* QuitCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new QuitCommand();
-}
-
-Command* QuitCommand::clone() const {
- return new QuitCommand();
-}
-
-std::string QuitCommand::getCommandName() const throw() {
- return "exit";
-}
-
-/* class CommentCommand */
-
-CommentCommand::CommentCommand(std::string comment) throw() : d_comment(comment) {
-}
-
-std::string CommentCommand::getComment() const throw() {
- return d_comment;
-}
-
-void CommentCommand::invoke(SmtEngine* smtEngine) throw() {
- Dump("benchmark") << *this;
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* CommentCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new CommentCommand(d_comment);
-}
-
-Command* CommentCommand::clone() const {
- return new CommentCommand(d_comment);
-}
-
-std::string CommentCommand::getCommandName() const throw() {
- return "comment";
-}
-
-/* class CommandSequence */
-
-CommandSequence::CommandSequence() throw() :
- d_index(0) {
-}
-
-CommandSequence::~CommandSequence() throw() {
- for(unsigned i = d_index; i < d_commandSequence.size(); ++i) {
- delete d_commandSequence[i];
- }
-}
-
-void CommandSequence::addCommand(Command* cmd) throw() {
- d_commandSequence.push_back(cmd);
-}
-
-void CommandSequence::clear() throw() {
- d_commandSequence.clear();
-}
-
-void CommandSequence::invoke(SmtEngine* smtEngine) throw() {
- for(; d_index < d_commandSequence.size(); ++d_index) {
- d_commandSequence[d_index]->invoke(smtEngine);
- if(! d_commandSequence[d_index]->ok()) {
- // abort execution
- d_commandStatus = d_commandSequence[d_index]->getCommandStatus();
- return;
- }
- delete d_commandSequence[d_index];
- }
-
- AlwaysAssert(d_commandStatus == NULL);
- d_commandStatus = CommandSuccess::instance();
-}
-
-void CommandSequence::invoke(SmtEngine* smtEngine, std::ostream& out) throw() {
- for(; d_index < d_commandSequence.size(); ++d_index) {
- d_commandSequence[d_index]->invoke(smtEngine, out);
- if(! d_commandSequence[d_index]->ok()) {
- // abort execution
- d_commandStatus = d_commandSequence[d_index]->getCommandStatus();
- return;
- }
- delete d_commandSequence[d_index];
- }
-
- AlwaysAssert(d_commandStatus == NULL);
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* CommandSequence::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- CommandSequence* seq = new CommandSequence();
- for(iterator i = begin(); i != end(); ++i) {
- Command* cmd_to_export = *i;
- Command* cmd = cmd_to_export->exportTo(exprManager, variableMap);
- seq->addCommand(cmd);
- Debug("export") << "[export] so far converted: " << seq << endl;
- }
- seq->d_index = d_index;
- return seq;
-}
-
-Command* CommandSequence::clone() const {
- CommandSequence* seq = new CommandSequence();
- for(const_iterator i = begin(); i != end(); ++i) {
- seq->addCommand((*i)->clone());
- }
- seq->d_index = d_index;
- return seq;
-}
-
-CommandSequence::const_iterator CommandSequence::begin() const throw() {
- return d_commandSequence.begin();
-}
-
-CommandSequence::const_iterator CommandSequence::end() const throw() {
- return d_commandSequence.end();
-}
-
-CommandSequence::iterator CommandSequence::begin() throw() {
- return d_commandSequence.begin();
-}
-
-CommandSequence::iterator CommandSequence::end() throw() {
- return d_commandSequence.end();
-}
-
-std::string CommandSequence::getCommandName() const throw() {
- return "sequence";
-}
-
-/* class DeclarationSequenceCommand */
-
-/* class DeclarationDefinitionCommand */
-
-DeclarationDefinitionCommand::DeclarationDefinitionCommand(const std::string& id) throw() :
- d_symbol(id) {
-}
-
-std::string DeclarationDefinitionCommand::getSymbol() const throw() {
- return d_symbol;
-}
-
-/* class DeclareFunctionCommand */
-
-DeclareFunctionCommand::DeclareFunctionCommand(const std::string& id, Expr func, Type t) throw() :
- DeclarationDefinitionCommand(id),
- d_func(func),
- d_type(t),
- d_printInModel(true),
- d_printInModelSetByUser(false){
-}
-
-Expr DeclareFunctionCommand::getFunction() const throw() {
- return d_func;
-}
-
-Type DeclareFunctionCommand::getType() const throw() {
- return d_type;
-}
-
-bool DeclareFunctionCommand::getPrintInModel() const throw() {
- return d_printInModel;
-}
-
-bool DeclareFunctionCommand::getPrintInModelSetByUser() const throw() {
- return d_printInModelSetByUser;
-}
-
-void DeclareFunctionCommand::setPrintInModel( bool p ) {
- d_printInModel = p;
- d_printInModelSetByUser = true;
-}
-
-void DeclareFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* DeclareFunctionCommand::exportTo(ExprManager* exprManager,
- ExprManagerMapCollection& variableMap) {
- DeclareFunctionCommand * dfc = new DeclareFunctionCommand(d_symbol, d_func.exportTo(exprManager, variableMap),
- d_type.exportTo(exprManager, variableMap));
- dfc->d_printInModel = d_printInModel;
- dfc->d_printInModelSetByUser = d_printInModelSetByUser;
- return dfc;
-}
-
-Command* DeclareFunctionCommand::clone() const {
- DeclareFunctionCommand * dfc = new DeclareFunctionCommand(d_symbol, d_func, d_type);
- dfc->d_printInModel = d_printInModel;
- dfc->d_printInModelSetByUser = d_printInModelSetByUser;
- return dfc;
-}
-
-std::string DeclareFunctionCommand::getCommandName() const throw() {
- return "declare-fun";
-}
-
-/* class DeclareTypeCommand */
-
-DeclareTypeCommand::DeclareTypeCommand(const std::string& id, size_t arity, Type t) throw() :
- DeclarationDefinitionCommand(id),
- d_arity(arity),
- d_type(t) {
-}
-
-size_t DeclareTypeCommand::getArity() const throw() {
- return d_arity;
-}
-
-Type DeclareTypeCommand::getType() const throw() {
- return d_type;
-}
-
-void DeclareTypeCommand::invoke(SmtEngine* smtEngine) throw() {
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* DeclareTypeCommand::exportTo(ExprManager* exprManager,
- ExprManagerMapCollection& variableMap) {
- return new DeclareTypeCommand(d_symbol, d_arity,
- d_type.exportTo(exprManager, variableMap));
-}
-
-Command* DeclareTypeCommand::clone() const {
- return new DeclareTypeCommand(d_symbol, d_arity, d_type);
-}
-
-std::string DeclareTypeCommand::getCommandName() const throw() {
- return "declare-sort";
-}
-
-/* class DefineTypeCommand */
-
-DefineTypeCommand::DefineTypeCommand(const std::string& id,
- Type t) throw() :
- DeclarationDefinitionCommand(id),
- d_params(),
- d_type(t) {
-}
-
-DefineTypeCommand::DefineTypeCommand(const std::string& id,
- const std::vector<Type>& params,
- Type t) throw() :
- DeclarationDefinitionCommand(id),
- d_params(params),
- d_type(t) {
-}
-
-const std::vector<Type>& DefineTypeCommand::getParameters() const throw() {
- return d_params;
-}
-
-Type DefineTypeCommand::getType() const throw() {
- return d_type;
-}
-
-void DefineTypeCommand::invoke(SmtEngine* smtEngine) throw() {
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* DefineTypeCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- vector<Type> params;
- transform(d_params.begin(), d_params.end(), back_inserter(params),
- ExportTransformer(exprManager, variableMap));
- Type type = d_type.exportTo(exprManager, variableMap);
- return new DefineTypeCommand(d_symbol, params, type);
-}
-
-Command* DefineTypeCommand::clone() const {
- return new DefineTypeCommand(d_symbol, d_params, d_type);
-}
-
-std::string DefineTypeCommand::getCommandName() const throw() {
- return "define-sort";
-}
-
-/* class DefineFunctionCommand */
-
-DefineFunctionCommand::DefineFunctionCommand(const std::string& id,
- Expr func,
- Expr formula) throw() :
- DeclarationDefinitionCommand(id),
- d_func(func),
- d_formals(),
- d_formula(formula) {
-}
-
-DefineFunctionCommand::DefineFunctionCommand(const std::string& id,
- Expr func,
- const std::vector<Expr>& formals,
- Expr formula) throw() :
- DeclarationDefinitionCommand(id),
- d_func(func),
- d_formals(formals),
- d_formula(formula) {
-}
-
-Expr DefineFunctionCommand::getFunction() const throw() {
- return d_func;
-}
-
-const std::vector<Expr>& DefineFunctionCommand::getFormals() const throw() {
- return d_formals;
-}
-
-Expr DefineFunctionCommand::getFormula() const throw() {
- return d_formula;
-}
-
-void DefineFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- if(!d_func.isNull()) {
- smtEngine->defineFunction(d_func, d_formals, d_formula);
- }
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* DefineFunctionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- Expr func = d_func.exportTo(exprManager, variableMap, /* flags = */ ExprManager::VAR_FLAG_DEFINED);
- vector<Expr> formals;
- transform(d_formals.begin(), d_formals.end(), back_inserter(formals),
- ExportTransformer(exprManager, variableMap));
- Expr formula = d_formula.exportTo(exprManager, variableMap);
- return new DefineFunctionCommand(d_symbol, func, formals, formula);
-}
-
-Command* DefineFunctionCommand::clone() const {
- return new DefineFunctionCommand(d_symbol, d_func, d_formals, d_formula);
-}
-
-std::string DefineFunctionCommand::getCommandName() const throw() {
- return "define-fun";
-}
-
-/* class DefineNamedFunctionCommand */
-
-DefineNamedFunctionCommand::DefineNamedFunctionCommand(const std::string& id,
- Expr func,
- const std::vector<Expr>& formals,
- Expr formula) throw() :
- DefineFunctionCommand(id, func, formals, formula) {
-}
-
-void DefineNamedFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
- this->DefineFunctionCommand::invoke(smtEngine);
- if(!d_func.isNull() && d_func.getType().isBoolean()) {
- smtEngine->addToAssignment(d_func.getExprManager()->mkExpr(kind::APPLY, d_func));
- }
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* DefineNamedFunctionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- Expr func = d_func.exportTo(exprManager, variableMap);
- vector<Expr> formals;
- transform(d_formals.begin(), d_formals.end(), back_inserter(formals),
- ExportTransformer(exprManager, variableMap));
- Expr formula = d_formula.exportTo(exprManager, variableMap);
- return new DefineNamedFunctionCommand(d_symbol, func, formals, formula);
-}
-
-Command* DefineNamedFunctionCommand::clone() const {
- return new DefineNamedFunctionCommand(d_symbol, d_func, d_formals, d_formula);
-}
-
-/* class SetUserAttribute */
-
-SetUserAttributeCommand::SetUserAttributeCommand( const std::string& attr, Expr expr ) throw() :
- d_attr( attr ), d_expr( expr ){
-}
-
-SetUserAttributeCommand::SetUserAttributeCommand( const std::string& attr, Expr expr,
- std::vector<Expr>& values ) throw() :
- d_attr( attr ), d_expr( expr ){
- d_expr_values.insert( d_expr_values.begin(), values.begin(), values.end() );
-}
-
-SetUserAttributeCommand::SetUserAttributeCommand( const std::string& attr, Expr expr,
- const std::string& value ) throw() :
- d_attr( attr ), d_expr( expr ), d_str_value( value ){
-}
-
-void SetUserAttributeCommand::invoke(SmtEngine* smtEngine) throw(){
- try {
- if(!d_expr.isNull()) {
- smtEngine->setUserAttribute( d_attr, d_expr, d_expr_values, d_str_value );
- }
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* SetUserAttributeCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap){
- Expr expr = d_expr.exportTo(exprManager, variableMap);
- SetUserAttributeCommand * c = new SetUserAttributeCommand( d_attr, expr, d_str_value );
- c->d_expr_values.insert( c->d_expr_values.end(), d_expr_values.begin(), d_expr_values.end() );
- return c;
-}
-
-Command* SetUserAttributeCommand::clone() const{
- SetUserAttributeCommand * c = new SetUserAttributeCommand( d_attr, d_expr, d_str_value );
- c->d_expr_values.insert( c->d_expr_values.end(), d_expr_values.begin(), d_expr_values.end() );
- return c;
-}
-
-std::string SetUserAttributeCommand::getCommandName() const throw() {
- return "set-user-attribute";
-}
-
-/* class SimplifyCommand */
-
-SimplifyCommand::SimplifyCommand(Expr term) throw() :
- d_term(term) {
-}
-
-Expr SimplifyCommand::getTerm() const throw() {
- return d_term;
-}
-
-void SimplifyCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_result = smtEngine->simplify(d_term);
- d_commandStatus = CommandSuccess::instance();
- } catch(UnsafeInterruptException& e) {
- d_commandStatus = new CommandInterrupted();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Expr SimplifyCommand::getResult() const throw() {
- return d_result;
-}
-
-void SimplifyCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- out << d_result << endl;
- }
-}
-
-Command* SimplifyCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- SimplifyCommand* c = new SimplifyCommand(d_term.exportTo(exprManager, variableMap));
- c->d_result = d_result.exportTo(exprManager, variableMap);
- return c;
-}
-
-Command* SimplifyCommand::clone() const {
- SimplifyCommand* c = new SimplifyCommand(d_term);
- c->d_result = d_result;
- return c;
-}
-
-std::string SimplifyCommand::getCommandName() const throw() {
- return "simplify";
-}
-
-/* class ExpandDefinitionsCommand */
-
-ExpandDefinitionsCommand::ExpandDefinitionsCommand(Expr term) throw() :
- d_term(term) {
-}
-
-Expr ExpandDefinitionsCommand::getTerm() const throw() {
- return d_term;
-}
-
-void ExpandDefinitionsCommand::invoke(SmtEngine* smtEngine) throw() {
- d_result = smtEngine->expandDefinitions(d_term);
- d_commandStatus = CommandSuccess::instance();
-}
-
-Expr ExpandDefinitionsCommand::getResult() const throw() {
- return d_result;
-}
-
-void ExpandDefinitionsCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- out << d_result << endl;
- }
-}
-
-Command* ExpandDefinitionsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- ExpandDefinitionsCommand* c = new ExpandDefinitionsCommand(d_term.exportTo(exprManager, variableMap));
- c->d_result = d_result.exportTo(exprManager, variableMap);
- return c;
-}
-
-Command* ExpandDefinitionsCommand::clone() const {
- ExpandDefinitionsCommand* c = new ExpandDefinitionsCommand(d_term);
- c->d_result = d_result;
- return c;
-}
-
-std::string ExpandDefinitionsCommand::getCommandName() const throw() {
- return "expand-definitions";
-}
-
-/* class GetValueCommand */
-
-GetValueCommand::GetValueCommand(Expr term) throw() :
- d_terms() {
- d_terms.push_back(term);
-}
-
-GetValueCommand::GetValueCommand(const std::vector<Expr>& terms) throw() :
- d_terms(terms) {
- CheckArgument(terms.size() >= 1, terms, "cannot get-value of an empty set of terms");
-}
-
-const std::vector<Expr>& GetValueCommand::getTerms() const throw() {
- return d_terms;
-}
-
-void GetValueCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- vector<Expr> result;
- ExprManager* em = smtEngine->getExprManager();
- NodeManager* nm = NodeManager::fromExprManager(em);
- for(std::vector<Expr>::const_iterator i = d_terms.begin(); i != d_terms.end(); ++i) {
- Assert(nm == NodeManager::fromExprManager((*i).getExprManager()));
- smt::SmtScope scope(smtEngine);
- Node request = Node::fromExpr(options::expandDefinitions() ? smtEngine->expandDefinitions(*i) : *i);
- Node value = Node::fromExpr(smtEngine->getValue(*i));
- if(value.getType().isInteger() && request.getType() == nm->realType()) {
- // Need to wrap in special marker so that output printers know this
- // is an integer-looking constant that really should be output as
- // a rational. Necessary for SMT-LIB standards compliance, but ugly.
- value = nm->mkNode(kind::APPLY_TYPE_ASCRIPTION,
- nm->mkConst(AscriptionType(em->realType())), value);
- }
- result.push_back(nm->mkNode(kind::SEXPR, request, value).toExpr());
- }
- d_result = em->mkExpr(kind::SEXPR, result);
- d_commandStatus = CommandSuccess::instance();
- } catch(UnsafeInterruptException& e) {
- d_commandStatus = new CommandInterrupted();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Expr GetValueCommand::getResult() const throw() {
- return d_result;
-}
-
-void GetValueCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- Expr::dag::Scope scope(out, false);
- out << d_result << endl;
- }
-}
-
-Command* GetValueCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- vector<Expr> exportedTerms;
- for(std::vector<Expr>::const_iterator i = d_terms.begin(); i != d_terms.end(); ++i) {
- exportedTerms.push_back((*i).exportTo(exprManager, variableMap));
- }
- GetValueCommand* c = new GetValueCommand(exportedTerms);
- c->d_result = d_result.exportTo(exprManager, variableMap);
- return c;
-}
-
-Command* GetValueCommand::clone() const {
- GetValueCommand* c = new GetValueCommand(d_terms);
- c->d_result = d_result;
- return c;
-}
-
-std::string GetValueCommand::getCommandName() const throw() {
- return "get-value";
-}
-
-/* class GetAssignmentCommand */
-
-GetAssignmentCommand::GetAssignmentCommand() throw() {
-}
-
-void GetAssignmentCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_result = smtEngine->getAssignment();
- d_commandStatus = CommandSuccess::instance();
- } catch(UnsafeInterruptException& e) {
- d_commandStatus = new CommandInterrupted();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-SExpr GetAssignmentCommand::getResult() const throw() {
- return d_result;
-}
-
-void GetAssignmentCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- out << d_result << endl;
- }
-}
-
-Command* GetAssignmentCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetAssignmentCommand* c = new GetAssignmentCommand();
- c->d_result = d_result;
- return c;
-}
-
-Command* GetAssignmentCommand::clone() const {
- GetAssignmentCommand* c = new GetAssignmentCommand();
- c->d_result = d_result;
- return c;
-}
-
-std::string GetAssignmentCommand::getCommandName() const throw() {
- return "get-assignment";
-}
-
-/* class GetModelCommand */
-
-GetModelCommand::GetModelCommand() throw() {
-}
-
-void GetModelCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_result = smtEngine->getModel();
- d_smtEngine = smtEngine;
- d_commandStatus = CommandSuccess::instance();
- } catch(UnsafeInterruptException& e) {
- d_commandStatus = new CommandInterrupted();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-/* Model is private to the library -- for now
-Model* GetModelCommand::getResult() const throw() {
- return d_result;
-}
-*/
-
-void GetModelCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- out << *d_result;
- }
-}
-
-Command* GetModelCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetModelCommand* c = new GetModelCommand();
- c->d_result = d_result;
- c->d_smtEngine = d_smtEngine;
- return c;
-}
-
-Command* GetModelCommand::clone() const {
- GetModelCommand* c = new GetModelCommand();
- c->d_result = d_result;
- c->d_smtEngine = d_smtEngine;
- return c;
-}
-
-std::string GetModelCommand::getCommandName() const throw() {
- return "get-model";
-}
-
-/* class GetProofCommand */
-
-GetProofCommand::GetProofCommand() throw() {
-}
-
-void GetProofCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_result = smtEngine->getProof();
- d_commandStatus = CommandSuccess::instance();
- } catch(UnsafeInterruptException& e) {
- d_commandStatus = new CommandInterrupted();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Proof* GetProofCommand::getResult() const throw() {
- return d_result;
-}
-
-void GetProofCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- d_result->toStream(out);
- }
-}
-
-Command* GetProofCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetProofCommand* c = new GetProofCommand();
- c->d_result = d_result;
- return c;
-}
-
-Command* GetProofCommand::clone() const {
- GetProofCommand* c = new GetProofCommand();
- c->d_result = d_result;
- return c;
-}
-
-std::string GetProofCommand::getCommandName() const throw() {
- return "get-proof";
-}
-
-/* class GetInstantiationsCommand */
-
-GetInstantiationsCommand::GetInstantiationsCommand() throw() {
-}
-
-void GetInstantiationsCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_smtEngine = smtEngine;
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-//Instantiations* GetInstantiationsCommand::getResult() const throw() {
-// return d_result;
-//}
-
-void GetInstantiationsCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- d_smtEngine->printInstantiations(out);
- }
-}
-
-Command* GetInstantiationsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetInstantiationsCommand* c = new GetInstantiationsCommand();
- //c->d_result = d_result;
- c->d_smtEngine = d_smtEngine;
- return c;
-}
-
-Command* GetInstantiationsCommand::clone() const {
- GetInstantiationsCommand* c = new GetInstantiationsCommand();
- //c->d_result = d_result;
- c->d_smtEngine = d_smtEngine;
- return c;
-}
-
-std::string GetInstantiationsCommand::getCommandName() const throw() {
- return "get-instantiations";
-}
-
-/* class GetSynthSolutionCommand */
-
-GetSynthSolutionCommand::GetSynthSolutionCommand() throw() {
-}
-
-void GetSynthSolutionCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_smtEngine = smtEngine;
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-void GetSynthSolutionCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- d_smtEngine->printSynthSolution(out);
- }
-}
-
-Command* GetSynthSolutionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetSynthSolutionCommand* c = new GetSynthSolutionCommand();
- c->d_smtEngine = d_smtEngine;
- return c;
-}
-
-Command* GetSynthSolutionCommand::clone() const {
- GetSynthSolutionCommand* c = new GetSynthSolutionCommand();
- c->d_smtEngine = d_smtEngine;
- return c;
-}
-
-std::string GetSynthSolutionCommand::getCommandName() const throw() {
- return "get-instantiations";
-}
-
-/* class GetUnsatCoreCommand */
-
-GetUnsatCoreCommand::GetUnsatCoreCommand() throw() {
-}
-
-GetUnsatCoreCommand::GetUnsatCoreCommand(const std::map<Expr, std::string>& names) throw() : d_names(names) {
-}
-
-void GetUnsatCoreCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- d_result = smtEngine->getUnsatCore();
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-void GetUnsatCoreCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- d_result.toStream(out, d_names);
- }
-}
-
-const UnsatCore& GetUnsatCoreCommand::getUnsatCore() const throw() {
- // of course, this will be empty if the command hasn't been invoked yet
- return d_result;
-}
-
-Command* GetUnsatCoreCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetUnsatCoreCommand* c = new GetUnsatCoreCommand(d_names);
- c->d_result = d_result;
- return c;
-}
-
-Command* GetUnsatCoreCommand::clone() const {
- GetUnsatCoreCommand* c = new GetUnsatCoreCommand(d_names);
- c->d_result = d_result;
- return c;
-}
-
-std::string GetUnsatCoreCommand::getCommandName() const throw() {
- return "get-unsat-core";
-}
-
-/* class GetAssertionsCommand */
-
-GetAssertionsCommand::GetAssertionsCommand() throw() {
-}
-
-void GetAssertionsCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- stringstream ss;
- const vector<Expr> v = smtEngine->getAssertions();
- ss << "(\n";
- copy( v.begin(), v.end(), ostream_iterator<Expr>(ss, "\n") );
- ss << ")\n";
- d_result = ss.str();
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-std::string GetAssertionsCommand::getResult() const throw() {
- return d_result;
-}
-
-void GetAssertionsCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else {
- out << d_result;
- }
-}
-
-Command* GetAssertionsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetAssertionsCommand* c = new GetAssertionsCommand();
- c->d_result = d_result;
- return c;
-}
-
-Command* GetAssertionsCommand::clone() const {
- GetAssertionsCommand* c = new GetAssertionsCommand();
- c->d_result = d_result;
- return c;
-}
-
-std::string GetAssertionsCommand::getCommandName() const throw() {
- return "get-assertions";
-}
-
-/* class SetBenchmarkStatusCommand */
-
-SetBenchmarkStatusCommand::SetBenchmarkStatusCommand(BenchmarkStatus status) throw() :
- d_status(status) {
-}
-
-BenchmarkStatus SetBenchmarkStatusCommand::getStatus() const throw() {
- return d_status;
-}
-
-void SetBenchmarkStatusCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- stringstream ss;
- ss << d_status;
- SExpr status = ss.str();
- smtEngine->setInfo("status", status);
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* SetBenchmarkStatusCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new SetBenchmarkStatusCommand(d_status);
-}
-
-Command* SetBenchmarkStatusCommand::clone() const {
- return new SetBenchmarkStatusCommand(d_status);
-}
-
-std::string SetBenchmarkStatusCommand::getCommandName() const throw() {
- return "set-info";
-}
-
-/* class SetBenchmarkLogicCommand */
-
-SetBenchmarkLogicCommand::SetBenchmarkLogicCommand(std::string logic) throw() :
- d_logic(logic) {
-}
-
-std::string SetBenchmarkLogicCommand::getLogic() const throw() {
- return d_logic;
-}
-
-void SetBenchmarkLogicCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- smtEngine->setLogic(d_logic);
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* SetBenchmarkLogicCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new SetBenchmarkLogicCommand(d_logic);
-}
-
-Command* SetBenchmarkLogicCommand::clone() const {
- return new SetBenchmarkLogicCommand(d_logic);
-}
-
-std::string SetBenchmarkLogicCommand::getCommandName() const throw() {
- return "set-logic";
-}
-
-/* class SetInfoCommand */
-
-SetInfoCommand::SetInfoCommand(std::string flag, const SExpr& sexpr) throw() :
- d_flag(flag),
- d_sexpr(sexpr) {
-}
-
-std::string SetInfoCommand::getFlag() const throw() {
- return d_flag;
-}
-
-SExpr SetInfoCommand::getSExpr() const throw() {
- return d_sexpr;
-}
-
-void SetInfoCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- smtEngine->setInfo(d_flag, d_sexpr);
- d_commandStatus = CommandSuccess::instance();
- } catch(UnrecognizedOptionException&) {
- // As per SMT-LIB spec, silently accept unknown set-info keys
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* SetInfoCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new SetInfoCommand(d_flag, d_sexpr);
-}
-
-Command* SetInfoCommand::clone() const {
- return new SetInfoCommand(d_flag, d_sexpr);
-}
-
-std::string SetInfoCommand::getCommandName() const throw() {
- return "set-info";
-}
-
-/* class GetInfoCommand */
-
-GetInfoCommand::GetInfoCommand(std::string flag) throw() :
- d_flag(flag) {
-}
-
-std::string GetInfoCommand::getFlag() const throw() {
- return d_flag;
-}
-
-void GetInfoCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- vector<SExpr> v;
- v.push_back(SExpr(SExpr::Keyword(string(":") + d_flag)));
- v.push_back(smtEngine->getInfo(d_flag));
- stringstream ss;
- if(d_flag == "all-options" || d_flag == "all-statistics") {
- ss << PrettySExprs(true);
- }
- ss << SExpr(v);
- d_result = ss.str();
- d_commandStatus = CommandSuccess::instance();
- } catch(UnrecognizedOptionException&) {
- d_commandStatus = new CommandUnsupported();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-std::string GetInfoCommand::getResult() const throw() {
- return d_result;
-}
-
-void GetInfoCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else if(d_result != "") {
- out << d_result << endl;
- }
-}
-
-Command* GetInfoCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetInfoCommand* c = new GetInfoCommand(d_flag);
- c->d_result = d_result;
- return c;
-}
-
-Command* GetInfoCommand::clone() const {
- GetInfoCommand* c = new GetInfoCommand(d_flag);
- c->d_result = d_result;
- return c;
-}
-
-std::string GetInfoCommand::getCommandName() const throw() {
- return "get-info";
-}
-
-/* class SetOptionCommand */
-
-SetOptionCommand::SetOptionCommand(std::string flag, const SExpr& sexpr) throw() :
- d_flag(flag),
- d_sexpr(sexpr) {
-}
-
-std::string SetOptionCommand::getFlag() const throw() {
- return d_flag;
-}
-
-SExpr SetOptionCommand::getSExpr() const throw() {
- return d_sexpr;
-}
-
-void SetOptionCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- smtEngine->setOption(d_flag, d_sexpr);
- d_commandStatus = CommandSuccess::instance();
- } catch(UnrecognizedOptionException&) {
- d_commandStatus = new CommandUnsupported();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* SetOptionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new SetOptionCommand(d_flag, d_sexpr);
-}
-
-Command* SetOptionCommand::clone() const {
- return new SetOptionCommand(d_flag, d_sexpr);
-}
-
-std::string SetOptionCommand::getCommandName() const throw() {
- return "set-option";
-}
-
-/* class GetOptionCommand */
-
-GetOptionCommand::GetOptionCommand(std::string flag) throw() :
- d_flag(flag) {
-}
-
-std::string GetOptionCommand::getFlag() const throw() {
- return d_flag;
-}
-
-void GetOptionCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- SExpr res = smtEngine->getOption(d_flag);
- stringstream ss;
- ss << res;
- d_result = ss.str();
- d_commandStatus = CommandSuccess::instance();
- } catch(UnrecognizedOptionException&) {
- d_commandStatus = new CommandUnsupported();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-std::string GetOptionCommand::getResult() const throw() {
- return d_result;
-}
-
-void GetOptionCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
- if(! ok()) {
- this->Command::printResult(out, verbosity);
- } else if(d_result != "") {
- out << d_result << endl;
- }
-}
-
-Command* GetOptionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetOptionCommand* c = new GetOptionCommand(d_flag);
- c->d_result = d_result;
- return c;
-}
-
-Command* GetOptionCommand::clone() const {
- GetOptionCommand* c = new GetOptionCommand(d_flag);
- c->d_result = d_result;
- return c;
-}
-
-std::string GetOptionCommand::getCommandName() const throw() {
- return "get-option";
-}
-
-/* class DatatypeDeclarationCommand */
-
-DatatypeDeclarationCommand::DatatypeDeclarationCommand(const DatatypeType& datatype) throw() :
- d_datatypes() {
- d_datatypes.push_back(datatype);
-}
-
-DatatypeDeclarationCommand::DatatypeDeclarationCommand(const std::vector<DatatypeType>& datatypes) throw() :
- d_datatypes(datatypes) {
-}
-
-const std::vector<DatatypeType>&
-DatatypeDeclarationCommand::getDatatypes() const throw() {
- return d_datatypes;
-}
-
-void DatatypeDeclarationCommand::invoke(SmtEngine* smtEngine) throw() {
- d_commandStatus = CommandSuccess::instance();
-}
-
-Command* DatatypeDeclarationCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- throw ExportUnsupportedException
- ("export of DatatypeDeclarationCommand unsupported");
-}
-
-Command* DatatypeDeclarationCommand::clone() const {
- return new DatatypeDeclarationCommand(d_datatypes);
-}
-
-std::string DatatypeDeclarationCommand::getCommandName() const throw() {
- return "declare-datatypes";
-}
-
-/* class RewriteRuleCommand */
-
-RewriteRuleCommand::RewriteRuleCommand(const std::vector<Expr>& vars,
- const std::vector<Expr>& guards,
- Expr head, Expr body,
- const Triggers& triggers) throw() :
- d_vars(vars), d_guards(guards), d_head(head), d_body(body), d_triggers(triggers) {
-}
-
-RewriteRuleCommand::RewriteRuleCommand(const std::vector<Expr>& vars,
- Expr head, Expr body) throw() :
- d_vars(vars), d_head(head), d_body(body) {
-}
-
-const std::vector<Expr>& RewriteRuleCommand::getVars() const throw() {
- return d_vars;
-}
-
-const std::vector<Expr>& RewriteRuleCommand::getGuards() const throw() {
- return d_guards;
-}
-
-Expr RewriteRuleCommand::getHead() const throw() {
- return d_head;
-}
-
-Expr RewriteRuleCommand::getBody() const throw() {
- return d_body;
-}
-
-const RewriteRuleCommand::Triggers& RewriteRuleCommand::getTriggers() const throw() {
- return d_triggers;
-}
-
-void RewriteRuleCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- ExprManager* em = smtEngine->getExprManager();
- /** build vars list */
- Expr vars = em->mkExpr(kind::BOUND_VAR_LIST, d_vars);
- /** build guards list */
- Expr guards;
- if(d_guards.size() == 0) guards = em->mkConst<bool>(true);
- else if(d_guards.size() == 1) guards = d_guards[0];
- else guards = em->mkExpr(kind::AND,d_guards);
- /** build expression */
- Expr expr;
- if( d_triggers.empty() ){
- expr = em->mkExpr(kind::RR_REWRITE,vars,guards,d_head,d_body);
- } else {
- /** build triggers list */
- std::vector<Expr> vtriggers;
- vtriggers.reserve(d_triggers.size());
- for(Triggers::const_iterator i = d_triggers.begin(),
- end = d_triggers.end(); i != end; ++i){
- vtriggers.push_back(em->mkExpr(kind::INST_PATTERN,*i));
- }
- Expr triggers = em->mkExpr(kind::INST_PATTERN_LIST,vtriggers);
- expr = em->mkExpr(kind::RR_REWRITE,vars,guards,d_head,d_body,triggers);
- }
- smtEngine->assertFormula(expr);
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* RewriteRuleCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- /** Convert variables */
- VExpr vars; vars.reserve(d_vars.size());
- for(VExpr::iterator i = d_vars.begin(), end = d_vars.end();
- i == end; ++i){
- vars.push_back(i->exportTo(exprManager, variableMap));
- };
- /** Convert guards */
- VExpr guards; guards.reserve(d_guards.size());
- for(VExpr::iterator i = d_guards.begin(), end = d_guards.end();
- i == end; ++i){
- guards.push_back(i->exportTo(exprManager, variableMap));
- };
- /** Convert triggers */
- Triggers triggers; triggers.resize(d_triggers.size());
- for(size_t i = 0, end = d_triggers.size();
- i < end; ++i){
- triggers[i].reserve(d_triggers[i].size());
- for(VExpr::iterator j = d_triggers[i].begin(), jend = d_triggers[i].end();
- j == jend; ++i){
- triggers[i].push_back(j->exportTo(exprManager, variableMap));
- };
- };
- /** Convert head and body */
- Expr head = d_head.exportTo(exprManager, variableMap);
- Expr body = d_body.exportTo(exprManager, variableMap);
- /** Create the converted rules */
- return new RewriteRuleCommand(vars, guards, head, body, triggers);
-}
-
-Command* RewriteRuleCommand::clone() const {
- return new RewriteRuleCommand(d_vars, d_guards, d_head, d_body, d_triggers);
-}
-
-std::string RewriteRuleCommand::getCommandName() const throw() {
- return "rewrite-rule";
-}
-
-/* class PropagateRuleCommand */
-
-PropagateRuleCommand::PropagateRuleCommand(const std::vector<Expr>& vars,
- const std::vector<Expr>& guards,
- const std::vector<Expr>& heads,
- Expr body,
- const Triggers& triggers,
- bool deduction) throw() :
- d_vars(vars), d_guards(guards), d_heads(heads), d_body(body), d_triggers(triggers), d_deduction(deduction) {
-}
-
-PropagateRuleCommand::PropagateRuleCommand(const std::vector<Expr>& vars,
- const std::vector<Expr>& heads,
- Expr body,
- bool deduction) throw() :
- d_vars(vars), d_heads(heads), d_body(body), d_deduction(deduction) {
-}
-
-const std::vector<Expr>& PropagateRuleCommand::getVars() const throw() {
- return d_vars;
-}
-
-const std::vector<Expr>& PropagateRuleCommand::getGuards() const throw() {
- return d_guards;
-}
-
-const std::vector<Expr>& PropagateRuleCommand::getHeads() const throw() {
- return d_heads;
-}
-
-Expr PropagateRuleCommand::getBody() const throw() {
- return d_body;
-}
-
-const PropagateRuleCommand::Triggers& PropagateRuleCommand::getTriggers() const throw() {
- return d_triggers;
-}
-
-bool PropagateRuleCommand::isDeduction() const throw() {
- return d_deduction;
-}
-
-void PropagateRuleCommand::invoke(SmtEngine* smtEngine) throw() {
- try {
- ExprManager* em = smtEngine->getExprManager();
- /** build vars list */
- Expr vars = em->mkExpr(kind::BOUND_VAR_LIST, d_vars);
- /** build guards list */
- Expr guards;
- if(d_guards.size() == 0) guards = em->mkConst<bool>(true);
- else if(d_guards.size() == 1) guards = d_guards[0];
- else guards = em->mkExpr(kind::AND,d_guards);
- /** build heads list */
- Expr heads;
- if(d_heads.size() == 1) heads = d_heads[0];
- else heads = em->mkExpr(kind::AND,d_heads);
- /** build expression */
- Expr expr;
- if( d_triggers.empty() ){
- expr = em->mkExpr(kind::RR_REWRITE,vars,guards,heads,d_body);
- } else {
- /** build triggers list */
- std::vector<Expr> vtriggers;
- vtriggers.reserve(d_triggers.size());
- for(Triggers::const_iterator i = d_triggers.begin(),
- end = d_triggers.end(); i != end; ++i){
- vtriggers.push_back(em->mkExpr(kind::INST_PATTERN,*i));
- }
- Expr triggers = em->mkExpr(kind::INST_PATTERN_LIST,vtriggers);
- expr = em->mkExpr(kind::RR_REWRITE,vars,guards,heads,d_body,triggers);
- }
- smtEngine->assertFormula(expr);
- d_commandStatus = CommandSuccess::instance();
- } catch(exception& e) {
- d_commandStatus = new CommandFailure(e.what());
- }
-}
-
-Command* PropagateRuleCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- /** Convert variables */
- VExpr vars; vars.reserve(d_vars.size());
- for(VExpr::iterator i = d_vars.begin(), end = d_vars.end();
- i == end; ++i){
- vars.push_back(i->exportTo(exprManager, variableMap));
- };
- /** Convert guards */
- VExpr guards; guards.reserve(d_guards.size());
- for(VExpr::iterator i = d_guards.begin(), end = d_guards.end();
- i == end; ++i){
- guards.push_back(i->exportTo(exprManager, variableMap));
- };
- /** Convert heads */
- VExpr heads; heads.reserve(d_heads.size());
- for(VExpr::iterator i = d_heads.begin(), end = d_heads.end();
- i == end; ++i){
- heads.push_back(i->exportTo(exprManager, variableMap));
- };
- /** Convert triggers */
- Triggers triggers; triggers.resize(d_triggers.size());
- for(size_t i = 0, end = d_triggers.size();
- i < end; ++i){
- triggers[i].reserve(d_triggers[i].size());
- for(VExpr::iterator j = d_triggers[i].begin(), jend = d_triggers[i].end();
- j == jend; ++i){
- triggers[i].push_back(j->exportTo(exprManager, variableMap));
- };
- };
- /** Convert head and body */
- Expr body = d_body.exportTo(exprManager, variableMap);
- /** Create the converted rules */
- return new PropagateRuleCommand(vars, guards, heads, body, triggers);
-}
-
-Command* PropagateRuleCommand::clone() const {
- return new PropagateRuleCommand(d_vars, d_guards, d_heads, d_body, d_triggers);
-}
-
-std::string PropagateRuleCommand::getCommandName() const throw() {
- return "propagate-rule";
-}
-
-/* output stream insertion operator for benchmark statuses */
-std::ostream& operator<<(std::ostream& out,
- BenchmarkStatus status) throw() {
- switch(status) {
-
- case SMT_SATISFIABLE:
- return out << "sat";
-
- case SMT_UNSATISFIABLE:
- return out << "unsat";
-
- case SMT_UNKNOWN:
- return out << "unknown";
-
- default:
- return out << "BenchmarkStatus::[UNKNOWNSTATUS!]";
- }
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file command.h
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: none
- ** Minor contributors (to current version): Kshitij Bansal, Christopher L. Conway, Dejan Jovanovic, Francois Bobot, Andrew Reynolds
- ** 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 the command pattern on SmtEngines.
- **
- ** Implementation of the command pattern on SmtEngines. Command
- ** objects are generated by the parser (typically) to implement the
- ** commands in parsed input (see Parser::parseNextCommand()), or by
- ** client code.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__COMMAND_H
-#define __CVC4__COMMAND_H
-
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <vector>
-#include <map>
-
-#include "expr/expr.h"
-#include "expr/type.h"
-#include "expr/variable_type_map.h"
-#include "util/result.h"
-#include "util/sexpr.h"
-#include "util/datatype.h"
-#include "util/proof.h"
-#include "util/unsat_core.h"
-
-namespace CVC4 {
-
-class SmtEngine;
-class Command;
-class CommandStatus;
-class Model;
-
-std::ostream& operator<<(std::ostream&, const Command&) throw() CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream&, const Command*) throw() CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream&, const CommandStatus&) throw() CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream&, const CommandStatus*) throw() CVC4_PUBLIC;
-
-/** The status an SMT benchmark can have */
-enum BenchmarkStatus {
- /** Benchmark is satisfiable */
- SMT_SATISFIABLE,
- /** Benchmark is unsatisfiable */
- SMT_UNSATISFIABLE,
- /** The status of the benchmark is unknown */
- SMT_UNKNOWN
-};/* enum BenchmarkStatus */
-
-std::ostream& operator<<(std::ostream& out,
- BenchmarkStatus status) throw() CVC4_PUBLIC;
-
-/**
- * IOStream manipulator to print success messages or not.
- *
- * out << Command::printsuccess(false) << CommandSuccess();
- *
- * prints nothing, but
- *
- * out << Command::printsuccess(true) << CommandSuccess();
- *
- * prints a success message (in a manner appropriate for the current
- * output language).
- */
-class CVC4_PUBLIC CommandPrintSuccess {
- /**
- * The allocated index in ios_base for our depth setting.
- */
- static const int s_iosIndex;
-
- /**
- * The default setting, for ostreams that haven't yet had a
- * setdepth() applied to them.
- */
- static const int s_defaultPrintSuccess = false;
-
- /**
- * When this manipulator is used, the setting is stored here.
- */
- bool d_printSuccess;
-
-public:
- /**
- * Construct a CommandPrintSuccess with the given setting.
- */
- CommandPrintSuccess(bool printSuccess) throw() : d_printSuccess(printSuccess) {}
-
- inline void applyPrintSuccess(std::ostream& out) throw() {
- out.iword(s_iosIndex) = d_printSuccess;
- }
-
- static inline bool getPrintSuccess(std::ostream& out) throw() {
- return out.iword(s_iosIndex);
- }
-
- static inline void setPrintSuccess(std::ostream& out, bool printSuccess) throw() {
- out.iword(s_iosIndex) = printSuccess;
- }
-
- /**
- * Set the print-success 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_oldPrintSuccess;
-
- public:
-
- inline Scope(std::ostream& out, bool printSuccess) throw() :
- d_out(out),
- d_oldPrintSuccess(CommandPrintSuccess::getPrintSuccess(out)) {
- CommandPrintSuccess::setPrintSuccess(out, printSuccess);
- }
-
- inline ~Scope() throw() {
- CommandPrintSuccess::setPrintSuccess(d_out, d_oldPrintSuccess);
- }
-
- };/* class CommandPrintSuccess::Scope */
-
-};/* class CommandPrintSuccess */
-
-/**
- * Sets the default print-success setting when pretty-printing an Expr
- * to an ostream. Use like this:
- *
- * // let out be an ostream, e an Expr
- * out << Expr::setdepth(n) << e << endl;
- *
- * The depth stays permanently (until set again) with the stream.
- */
-inline std::ostream& operator<<(std::ostream& out, CommandPrintSuccess cps) throw() CVC4_PUBLIC;
-inline std::ostream& operator<<(std::ostream& out, CommandPrintSuccess cps) throw() {
- cps.applyPrintSuccess(out);
- return out;
-}
-
-class CVC4_PUBLIC CommandStatus {
-protected:
- // shouldn't construct a CommandStatus (use a derived class)
- CommandStatus() throw() {}
-public:
- virtual ~CommandStatus() throw() {}
- void toStream(std::ostream& out,
- OutputLanguage language = language::output::LANG_AUTO) const throw();
- virtual CommandStatus& clone() const = 0;
-};/* class CommandStatus */
-
-class CVC4_PUBLIC CommandSuccess : public CommandStatus {
- static const CommandSuccess* s_instance;
-public:
- static const CommandSuccess* instance() throw() { return s_instance; }
- CommandStatus& clone() const { return const_cast<CommandSuccess&>(*this); }
-};/* class CommandSuccess */
-
-class CVC4_PUBLIC CommandInterrupted : public CommandStatus {
- static const CommandInterrupted* s_instance;
-public:
- static const CommandInterrupted* instance() throw() { return s_instance; }
- CommandStatus& clone() const { return const_cast<CommandInterrupted&>(*this); }
-};/* class CommandInterrupted */
-
-class CVC4_PUBLIC CommandUnsupported : public CommandStatus {
-public:
- CommandStatus& clone() const { return *new CommandUnsupported(*this); }
-};/* class CommandSuccess */
-
-class CVC4_PUBLIC CommandFailure : public CommandStatus {
- std::string d_message;
-public:
- CommandFailure(std::string message) throw() : d_message(message) {}
- CommandFailure& clone() const { return *new CommandFailure(*this); }
- ~CommandFailure() throw() {}
- std::string getMessage() const throw() { return d_message; }
-};/* class CommandFailure */
-
-class CVC4_PUBLIC Command {
-protected:
- /**
- * This field contains a command status if the command has been
- * invoked, or NULL if it has not. This field is either a
- * dynamically-allocated pointer, or it's a pointer to the singleton
- * CommandSuccess instance. Doing so is somewhat asymmetric, but
- * it avoids the need to dynamically allocate memory in the common
- * case of a successful command.
- */
- const CommandStatus* d_commandStatus;
-
- /**
- * True if this command is "muted"---i.e., don't print "success" on
- * successful execution.
- */
- bool d_muted;
-
-public:
- typedef CommandPrintSuccess printsuccess;
-
- Command() throw();
- Command(const Command& cmd);
-
- virtual ~Command() throw();
-
- virtual void invoke(SmtEngine* smtEngine) throw() = 0;
- virtual void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
-
- virtual void toStream(std::ostream& out, int toDepth = -1, bool types = false, size_t dag = 1,
- OutputLanguage language = language::output::LANG_AUTO) const throw();
-
- std::string toString() const throw();
-
- virtual std::string getCommandName() const throw() = 0;
-
- /**
- * If false, instruct this Command not to print a success message.
- */
- void setMuted(bool muted) throw() { d_muted = muted; }
-
- /**
- * Determine whether this Command will print a success message.
- */
- bool isMuted() throw() { return d_muted; }
-
- /**
- * Either the command hasn't run yet, or it completed successfully
- * (CommandSuccess, not CommandUnsupported or CommandFailure).
- */
- bool ok() const throw();
-
- /**
- * The command completed in a failure state (CommandFailure, not
- * CommandSuccess or CommandUnsupported).
- */
- bool fail() const throw();
-
- /**
- * The command was ran but was interrupted due to resource limiting.
- */
- bool interrupted() const throw();
-
- /** Get the command status (it's NULL if we haven't run yet). */
- const CommandStatus* getCommandStatus() const throw() { return d_commandStatus; }
-
- virtual void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
-
- /**
- * Maps this Command into one for a different ExprManager, using
- * variableMap for the translation and extending it with any new
- * mappings.
- */
- virtual Command* exportTo(ExprManager* exprManager,
- ExprManagerMapCollection& variableMap) = 0;
-
- /**
- * Clone this Command (make a shallow copy).
- */
- virtual Command* clone() const = 0;
-
-protected:
- class ExportTransformer {
- ExprManager* d_exprManager;
- ExprManagerMapCollection& d_variableMap;
- public:
- ExportTransformer(ExprManager* exprManager, ExprManagerMapCollection& variableMap) :
- d_exprManager(exprManager),
- d_variableMap(variableMap) {
- }
- Expr operator()(Expr e) {
- return e.exportTo(d_exprManager, d_variableMap);
- }
- Type operator()(Type t) {
- return t.exportTo(d_exprManager, d_variableMap);
- }
- };/* class Command::ExportTransformer */
-};/* class Command */
-
-/**
- * EmptyCommands are the residue of a command after the parser handles
- * them (and there's nothing left to do).
- */
-class CVC4_PUBLIC EmptyCommand : public Command {
-protected:
- std::string d_name;
-public:
- EmptyCommand(std::string name = "") throw();
- ~EmptyCommand() throw() {}
- std::string getName() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class EmptyCommand */
-
-class CVC4_PUBLIC EchoCommand : public Command {
-protected:
- std::string d_output;
-public:
- EchoCommand(std::string output = "") throw();
- ~EchoCommand() throw() {}
- std::string getOutput() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class EchoCommand */
-
-class CVC4_PUBLIC AssertCommand : public Command {
-protected:
- Expr d_expr;
- bool d_inUnsatCore;
-public:
- AssertCommand(const Expr& e, bool inUnsatCore = true) throw();
- ~AssertCommand() throw() {}
- Expr getExpr() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class AssertCommand */
-
-class CVC4_PUBLIC PushCommand : public Command {
-public:
- ~PushCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class PushCommand */
-
-class CVC4_PUBLIC PopCommand : public Command {
-public:
- ~PopCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class PopCommand */
-
-class CVC4_PUBLIC DeclarationDefinitionCommand : public Command {
-protected:
- std::string d_symbol;
-public:
- DeclarationDefinitionCommand(const std::string& id) throw();
- ~DeclarationDefinitionCommand() throw() {}
- virtual void invoke(SmtEngine* smtEngine) throw() = 0;
- std::string getSymbol() const throw();
-};/* class DeclarationDefinitionCommand */
-
-class CVC4_PUBLIC DeclareFunctionCommand : public DeclarationDefinitionCommand {
-protected:
- Expr d_func;
- Type d_type;
- bool d_printInModel;
- bool d_printInModelSetByUser;
-public:
- DeclareFunctionCommand(const std::string& id, Expr func, Type type) throw();
- ~DeclareFunctionCommand() throw() {}
- Expr getFunction() const throw();
- Type getType() const throw();
- bool getPrintInModel() const throw();
- bool getPrintInModelSetByUser() const throw();
- void setPrintInModel( bool p );
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class DeclareFunctionCommand */
-
-class CVC4_PUBLIC DeclareTypeCommand : public DeclarationDefinitionCommand {
-protected:
- size_t d_arity;
- Type d_type;
-public:
- DeclareTypeCommand(const std::string& id, size_t arity, Type t) throw();
- ~DeclareTypeCommand() throw() {}
- size_t getArity() const throw();
- Type getType() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class DeclareTypeCommand */
-
-class CVC4_PUBLIC DefineTypeCommand : public DeclarationDefinitionCommand {
-protected:
- std::vector<Type> d_params;
- Type d_type;
-public:
- DefineTypeCommand(const std::string& id, Type t) throw();
- DefineTypeCommand(const std::string& id, const std::vector<Type>& params, Type t) throw();
- ~DefineTypeCommand() throw() {}
- const std::vector<Type>& getParameters() const throw();
- Type getType() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class DefineTypeCommand */
-
-class CVC4_PUBLIC DefineFunctionCommand : public DeclarationDefinitionCommand {
-protected:
- Expr d_func;
- std::vector<Expr> d_formals;
- Expr d_formula;
-public:
- DefineFunctionCommand(const std::string& id, Expr func, Expr formula) throw();
- DefineFunctionCommand(const std::string& id, Expr func,
- const std::vector<Expr>& formals, Expr formula) throw();
- ~DefineFunctionCommand() throw() {}
- Expr getFunction() const throw();
- const std::vector<Expr>& getFormals() const throw();
- Expr getFormula() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class DefineFunctionCommand */
-
-/**
- * This differs from DefineFunctionCommand only in that it instructs
- * the SmtEngine to "remember" this function for later retrieval with
- * getAssignment(). Used for :named attributes in SMT-LIBv2.
- */
-class CVC4_PUBLIC DefineNamedFunctionCommand : public DefineFunctionCommand {
-public:
- DefineNamedFunctionCommand(const std::string& id, Expr func,
- const std::vector<Expr>& formals, Expr formula) throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
-};/* class DefineNamedFunctionCommand */
-
-/**
- * The command when an attribute is set by a user. In SMT-LIBv2 this is done
- * via the syntax (! expr :attr)
- */
-class CVC4_PUBLIC SetUserAttributeCommand : public Command {
-protected:
- std::string d_attr;
- Expr d_expr;
- std::vector<Expr> d_expr_values;
- std::string d_str_value;
-public:
- SetUserAttributeCommand( const std::string& attr, Expr expr ) throw();
- SetUserAttributeCommand( const std::string& attr, Expr expr, std::vector<Expr>& values ) throw();
- SetUserAttributeCommand( const std::string& attr, Expr expr, const std::string& value ) throw();
- ~SetUserAttributeCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class SetUserAttributeCommand */
-
-class CVC4_PUBLIC CheckSatCommand : public Command {
-protected:
- Expr d_expr;
- Result d_result;
- bool d_inUnsatCore;
-public:
- CheckSatCommand() throw();
- CheckSatCommand(const Expr& expr, bool inUnsatCore = true) throw();
- ~CheckSatCommand() throw() {}
- Expr getExpr() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Result getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class CheckSatCommand */
-
-class CVC4_PUBLIC QueryCommand : public Command {
-protected:
- Expr d_expr;
- Result d_result;
- bool d_inUnsatCore;
-public:
- QueryCommand(const Expr& e, bool inUnsatCore = true) throw();
- ~QueryCommand() throw() {}
- Expr getExpr() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Result getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class QueryCommand */
-
-// this is TRANSFORM in the CVC presentation language
-class CVC4_PUBLIC SimplifyCommand : public Command {
-protected:
- Expr d_term;
- Expr d_result;
-public:
- SimplifyCommand(Expr term) throw();
- ~SimplifyCommand() throw() {}
- Expr getTerm() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Expr getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class SimplifyCommand */
-
-class CVC4_PUBLIC ExpandDefinitionsCommand : public Command {
-protected:
- Expr d_term;
- Expr d_result;
-public:
- ExpandDefinitionsCommand(Expr term) throw();
- ~ExpandDefinitionsCommand() throw() {}
- Expr getTerm() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Expr getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class ExpandDefinitionsCommand */
-
-class CVC4_PUBLIC GetValueCommand : public Command {
-protected:
- std::vector<Expr> d_terms;
- Expr d_result;
-public:
- GetValueCommand(Expr term) throw();
- GetValueCommand(const std::vector<Expr>& terms) throw();
- ~GetValueCommand() throw() {}
- const std::vector<Expr>& getTerms() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Expr getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetValueCommand */
-
-class CVC4_PUBLIC GetAssignmentCommand : public Command {
-protected:
- SExpr d_result;
-public:
- GetAssignmentCommand() throw();
- ~GetAssignmentCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- SExpr getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetAssignmentCommand */
-
-class CVC4_PUBLIC GetModelCommand : public Command {
-protected:
- Model* d_result;
- SmtEngine* d_smtEngine;
-public:
- GetModelCommand() throw();
- ~GetModelCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- // Model is private to the library -- for now
- //Model* getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetModelCommand */
-
-class CVC4_PUBLIC GetProofCommand : public Command {
-protected:
- Proof* d_result;
-public:
- GetProofCommand() throw();
- ~GetProofCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- Proof* getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetProofCommand */
-
-class CVC4_PUBLIC GetInstantiationsCommand : public Command {
-protected:
- //Instantiations* d_result;
- SmtEngine* d_smtEngine;
-public:
- GetInstantiationsCommand() throw();
- ~GetInstantiationsCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- //Instantiations* getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetInstantiationsCommand */
-
-class CVC4_PUBLIC GetSynthSolutionCommand : public Command {
-protected:
- SmtEngine* d_smtEngine;
-public:
- GetSynthSolutionCommand() throw();
- ~GetSynthSolutionCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetSynthSolutionCommand */
-
-class CVC4_PUBLIC GetUnsatCoreCommand : public Command {
-protected:
- UnsatCore d_result;
- std::map<Expr, std::string> d_names;
-public:
- GetUnsatCoreCommand() throw();
- GetUnsatCoreCommand(const std::map<Expr, std::string>& names) throw();
- ~GetUnsatCoreCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- const UnsatCore& getUnsatCore() const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetUnsatCoreCommand */
-
-class CVC4_PUBLIC GetAssertionsCommand : public Command {
-protected:
- std::string d_result;
-public:
- GetAssertionsCommand() throw();
- ~GetAssertionsCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- std::string getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetAssertionsCommand */
-
-class CVC4_PUBLIC SetBenchmarkStatusCommand : public Command {
-protected:
- BenchmarkStatus d_status;
-public:
- SetBenchmarkStatusCommand(BenchmarkStatus status) throw();
- ~SetBenchmarkStatusCommand() throw() {}
- BenchmarkStatus getStatus() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class SetBenchmarkStatusCommand */
-
-class CVC4_PUBLIC SetBenchmarkLogicCommand : public Command {
-protected:
- std::string d_logic;
-public:
- SetBenchmarkLogicCommand(std::string logic) throw();
- ~SetBenchmarkLogicCommand() throw() {}
- std::string getLogic() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class SetBenchmarkLogicCommand */
-
-class CVC4_PUBLIC SetInfoCommand : public Command {
-protected:
- std::string d_flag;
- SExpr d_sexpr;
-public:
- SetInfoCommand(std::string flag, const SExpr& sexpr) throw();
- ~SetInfoCommand() throw() {}
- std::string getFlag() const throw();
- SExpr getSExpr() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class SetInfoCommand */
-
-class CVC4_PUBLIC GetInfoCommand : public Command {
-protected:
- std::string d_flag;
- std::string d_result;
-public:
- GetInfoCommand(std::string flag) throw();
- ~GetInfoCommand() throw() {}
- std::string getFlag() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- std::string getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetInfoCommand */
-
-class CVC4_PUBLIC SetOptionCommand : public Command {
-protected:
- std::string d_flag;
- SExpr d_sexpr;
-public:
- SetOptionCommand(std::string flag, const SExpr& sexpr) throw();
- ~SetOptionCommand() throw() {}
- std::string getFlag() const throw();
- SExpr getSExpr() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class SetOptionCommand */
-
-class CVC4_PUBLIC GetOptionCommand : public Command {
-protected:
- std::string d_flag;
- std::string d_result;
-public:
- GetOptionCommand(std::string flag) throw();
- ~GetOptionCommand() throw() {}
- std::string getFlag() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- std::string getResult() const throw();
- void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class GetOptionCommand */
-
-class CVC4_PUBLIC DatatypeDeclarationCommand : public Command {
-private:
- std::vector<DatatypeType> d_datatypes;
-public:
- DatatypeDeclarationCommand(const DatatypeType& datatype) throw();
- ~DatatypeDeclarationCommand() throw() {}
- DatatypeDeclarationCommand(const std::vector<DatatypeType>& datatypes) throw();
- const std::vector<DatatypeType>& getDatatypes() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class DatatypeDeclarationCommand */
-
-class CVC4_PUBLIC RewriteRuleCommand : public Command {
-public:
- typedef std::vector< std::vector< Expr > > Triggers;
-protected:
- typedef std::vector< Expr > VExpr;
- VExpr d_vars;
- VExpr d_guards;
- Expr d_head;
- Expr d_body;
- Triggers d_triggers;
-public:
- RewriteRuleCommand(const std::vector<Expr>& vars,
- const std::vector<Expr>& guards,
- Expr head,
- Expr body,
- const Triggers& d_triggers) throw();
- RewriteRuleCommand(const std::vector<Expr>& vars,
- Expr head,
- Expr body) throw();
- ~RewriteRuleCommand() throw() {}
- const std::vector<Expr>& getVars() const throw();
- const std::vector<Expr>& getGuards() const throw();
- Expr getHead() const throw();
- Expr getBody() const throw();
- const Triggers& getTriggers() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class RewriteRuleCommand */
-
-class CVC4_PUBLIC PropagateRuleCommand : public Command {
-public:
- typedef std::vector< std::vector< Expr > > Triggers;
-protected:
- typedef std::vector< Expr > VExpr;
- VExpr d_vars;
- VExpr d_guards;
- VExpr d_heads;
- Expr d_body;
- Triggers d_triggers;
- bool d_deduction;
-public:
- PropagateRuleCommand(const std::vector<Expr>& vars,
- const std::vector<Expr>& guards,
- const std::vector<Expr>& heads,
- Expr body,
- const Triggers& d_triggers,
- /* true if we want a deduction rule */
- bool d_deduction = false) throw();
- PropagateRuleCommand(const std::vector<Expr>& vars,
- const std::vector<Expr>& heads,
- Expr body,
- bool d_deduction = false) throw();
- ~PropagateRuleCommand() throw() {}
- const std::vector<Expr>& getVars() const throw();
- const std::vector<Expr>& getGuards() const throw();
- const std::vector<Expr>& getHeads() const throw();
- Expr getBody() const throw();
- const Triggers& getTriggers() const throw();
- bool isDeduction() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class PropagateRuleCommand */
-
-class CVC4_PUBLIC ResetCommand : public Command {
-public:
- ResetCommand() throw() {}
- ~ResetCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class ResetCommand */
-
-class CVC4_PUBLIC ResetAssertionsCommand : public Command {
-public:
- ResetAssertionsCommand() throw() {}
- ~ResetAssertionsCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class ResetAssertionsCommand */
-
-class CVC4_PUBLIC QuitCommand : public Command {
-public:
- QuitCommand() throw() {}
- ~QuitCommand() throw() {}
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class QuitCommand */
-
-class CVC4_PUBLIC CommentCommand : public Command {
- std::string d_comment;
-public:
- CommentCommand(std::string comment) throw();
- ~CommentCommand() throw() {}
- std::string getComment() const throw();
- void invoke(SmtEngine* smtEngine) throw();
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class CommentCommand */
-
-class CVC4_PUBLIC CommandSequence : public Command {
-private:
- /** All the commands to be executed (in sequence) */
- std::vector<Command*> d_commandSequence;
- /** Next command to be executed */
- unsigned int d_index;
-public:
- CommandSequence() throw();
- ~CommandSequence() throw();
-
- void addCommand(Command* cmd) throw();
- void clear() throw();
-
- void invoke(SmtEngine* smtEngine) throw();
- void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
-
- typedef std::vector<Command*>::iterator iterator;
- typedef std::vector<Command*>::const_iterator const_iterator;
-
- const_iterator begin() const throw();
- const_iterator end() const throw();
-
- iterator begin() throw();
- iterator end() throw();
-
- Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
- Command* clone() const;
- std::string getCommandName() const throw();
-};/* class CommandSequence */
-
-class CVC4_PUBLIC DeclarationSequence : public CommandSequence {
-public:
- ~DeclarationSequence() throw() {}
-};/* class DeclarationSequence */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__COMMAND_H */
+++ /dev/null
-%{
-#include "expr/command.h"
-
-#ifdef SWIGJAVA
-
-#include "bindings/java_iterator_adapter.h"
-#include "bindings/java_stream_adapters.h"
-
-#endif /* SWIGJAVA */
-%}
-
-%ignore CVC4::operator<<(std::ostream&, const Command&) throw();
-%ignore CVC4::operator<<(std::ostream&, const Command*) throw();
-%ignore CVC4::operator<<(std::ostream&, const CommandStatus&) throw();
-%ignore CVC4::operator<<(std::ostream&, const CommandStatus*) throw();
-%ignore CVC4::operator<<(std::ostream&, BenchmarkStatus status) throw();
-%ignore CVC4::operator<<(std::ostream&, CommandPrintSuccess) throw();
-
-%ignore CVC4::GetProofCommand;
-%ignore CVC4::CommandPrintSuccess::Scope;
-
-#ifdef SWIGJAVA
-
-// Instead of CommandSequence::begin() and end(), create an
-// iterator() method on the Java side that returns a Java-style
-// Iterator.
-%ignore CVC4::CommandSequence::begin();
-%ignore CVC4::CommandSequence::end();
-%ignore CVC4::CommandSequence::begin() const;
-%ignore CVC4::CommandSequence::end() const;
-%extend CVC4::CommandSequence {
- CVC4::JavaIteratorAdapter<CVC4::CommandSequence> iterator() {
- return CVC4::JavaIteratorAdapter<CVC4::CommandSequence>(*$self);
- }
-}
-
-// CommandSequence is "iterable" on the Java side
-%typemap(javainterfaces) CVC4::CommandSequence "java.lang.Iterable<edu.nyu.acsys.CVC4.Command>";
-
-// the JavaIteratorAdapter should not be public, and implements Iterator
-%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> "class";
-%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> "java.util.Iterator<edu.nyu.acsys.CVC4.Command>";
-// add some functions to the Java side (do it here because there's no way to do these in C++)
-%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> "
- public void remove() {
- throw new java.lang.UnsupportedOperationException();
- }
-
- public edu.nyu.acsys.CVC4.Command next() {
- if(hasNext()) {
- return getNext();
- } else {
- throw new java.util.NoSuchElementException();
- }
- }
-"
-// getNext() just allows C++ iterator access from Java-side next(), make it private
-%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::CommandSequence>::getNext() "private";
-
-// map the types appropriately
-%typemap(jni) CVC4::CommandSequence::const_iterator::value_type "jobject";
-%typemap(jtype) CVC4::CommandSequence::const_iterator::value_type "edu.nyu.acsys.CVC4.Command";
-%typemap(jstype) CVC4::CommandSequence::const_iterator::value_type "edu.nyu.acsys.CVC4.Command";
-%typemap(javaout) CVC4::CommandSequence::const_iterator::value_type { return $jnicall; }
-
-#endif /* SWIGJAVA */
-
-%include "expr/command.h"
-
-#ifdef SWIGJAVA
-
-%include "bindings/java_iterator_adapter.h"
-%include "bindings/java_stream_adapters.h"
-
-%template(JavaIteratorAdapter_CommandSequence) CVC4::JavaIteratorAdapter<CVC4::CommandSequence>;
-
-#endif /* SWIGJAVA */
--- /dev/null
+/********************* */
+/*! \file datatype.cpp
+ ** \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 A class representing a Datatype definition
+ **
+ ** A class representing a Datatype definition for the theory of
+ ** inductive datatypes.
+ **/
+#include "expr/datatype.h"
+
+#include <string>
+#include <sstream>
+
+#include "base/cvc4_assert.h"
+#include "expr/attribute.h"
+#include "expr/expr_manager.h"
+#include "expr/expr_manager_scope.h"
+#include "expr/matcher.h"
+#include "expr/node.h"
+#include "expr/node_manager.h"
+#include "expr/type.h"
+
+using namespace std;
+
+namespace CVC4 {
+
+namespace expr {
+ namespace attr {
+ struct DatatypeIndexTag {};
+ struct DatatypeConsIndexTag {};
+ struct DatatypeFiniteTag {};
+ struct DatatypeFiniteComputedTag {};
+ }/* CVC4::expr::attr namespace */
+}/* CVC4::expr namespace */
+
+typedef expr::Attribute<expr::attr::DatatypeIndexTag, uint64_t> DatatypeIndexAttr;
+typedef expr::Attribute<expr::attr::DatatypeConsIndexTag, uint64_t> DatatypeConsIndexAttr;
+typedef expr::Attribute<expr::attr::DatatypeFiniteTag, bool> DatatypeFiniteAttr;
+typedef expr::Attribute<expr::attr::DatatypeFiniteComputedTag, bool> DatatypeFiniteComputedAttr;
+
+const Datatype& Datatype::datatypeOf(Expr item) {
+ ExprManagerScope ems(item);
+ TypeNode t = Node::fromExpr(item).getType();
+ switch(t.getKind()) {
+ case kind::CONSTRUCTOR_TYPE:
+ return DatatypeType(t[t.getNumChildren() - 1].toType()).getDatatype();
+ case kind::SELECTOR_TYPE:
+ case kind::TESTER_TYPE:
+ return DatatypeType(t[0].toType()).getDatatype();
+ default:
+ Unhandled("arg must be a datatype constructor, selector, or tester");
+ }
+}
+
+size_t Datatype::indexOf(Expr item) {
+ ExprManagerScope ems(item);
+ CheckArgument(item.getType().isConstructor() ||
+ item.getType().isTester() ||
+ item.getType().isSelector(),
+ item,
+ "arg must be a datatype constructor, selector, or tester");
+ TNode n = Node::fromExpr(item);
+ if( item.getKind()==kind::APPLY_TYPE_ASCRIPTION ){
+ return indexOf( item[0] );
+ }else{
+ Assert(n.hasAttribute(DatatypeIndexAttr()));
+ return n.getAttribute(DatatypeIndexAttr());
+ }
+}
+
+size_t Datatype::cindexOf(Expr item) {
+ ExprManagerScope ems(item);
+ CheckArgument(item.getType().isSelector(),
+ item,
+ "arg must be a datatype selector");
+ TNode n = Node::fromExpr(item);
+ if( item.getKind()==kind::APPLY_TYPE_ASCRIPTION ){
+ return cindexOf( item[0] );
+ }else{
+ Assert(n.hasAttribute(DatatypeConsIndexAttr()));
+ return n.getAttribute(DatatypeConsIndexAttr());
+ }
+}
+
+void Datatype::resolve(ExprManager* em,
+ const std::map<std::string, DatatypeType>& resolutions,
+ const std::vector<Type>& placeholders,
+ const std::vector<Type>& replacements,
+ const std::vector< SortConstructorType >& paramTypes,
+ const std::vector< DatatypeType >& paramReplacements)
+ throw(IllegalArgumentException, DatatypeResolutionException) {
+
+ CheckArgument(em != NULL, em, "cannot resolve a Datatype with a NULL expression manager");
+ CheckArgument(!d_resolved, this, "cannot resolve a Datatype twice");
+ CheckArgument(resolutions.find(d_name) != resolutions.end(), resolutions,
+ "Datatype::resolve(): resolutions doesn't contain me!");
+ CheckArgument(placeholders.size() == replacements.size(), placeholders,
+ "placeholders and replacements must be the same size");
+ CheckArgument(paramTypes.size() == paramReplacements.size(), paramTypes,
+ "paramTypes and paramReplacements must be the same size");
+ CheckArgument(getNumConstructors() > 0, *this, "cannot resolve a Datatype that has no constructors");
+ DatatypeType self = (*resolutions.find(d_name)).second;
+ CheckArgument(&self.getDatatype() == this, resolutions, "Datatype::resolve(): resolutions doesn't contain me!");
+ d_resolved = true;
+ size_t index = 0;
+ for(std::vector<DatatypeConstructor>::iterator i = d_constructors.begin(), i_end = d_constructors.end(); i != i_end; ++i) {
+ (*i).resolve(em, self, resolutions, placeholders, replacements, paramTypes, paramReplacements, index);
+ Node::fromExpr((*i).d_constructor).setAttribute(DatatypeIndexAttr(), index);
+ Node::fromExpr((*i).d_tester).setAttribute(DatatypeIndexAttr(), index++);
+ }
+ d_self = self;
+
+ d_involvesExt = false;
+ for(const_iterator i = begin(); i != end(); ++i) {
+ if( (*i).involvesExternalType() ){
+ d_involvesExt = true;
+ break;
+ }
+ }
+}
+
+void Datatype::addConstructor(const DatatypeConstructor& c) {
+ CheckArgument(!d_resolved, this,
+ "cannot add a constructor to a finalized Datatype");
+ d_constructors.push_back(c);
+}
+
+
+void Datatype::setSygus( Type st, Expr bvl, bool allow_const, bool allow_all ){
+ CheckArgument(!d_resolved, this,
+ "cannot set sygus type to a finalized Datatype");
+ d_sygus_type = st;
+ d_sygus_bvl = bvl;
+ d_sygus_allow_const = allow_const || allow_all;
+ d_sygus_allow_all = allow_all;
+}
+
+
+Cardinality Datatype::getCardinality() const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), this, "this datatype is not yet resolved");
+ std::vector< Type > processing;
+ computeCardinality( processing );
+ return d_card;
+}
+
+Cardinality Datatype::computeCardinality( std::vector< Type >& processing ) const throw(IllegalArgumentException){
+ CheckArgument(isResolved(), this, "this datatype is not yet resolved");
+ if( std::find( processing.begin(), processing.end(), d_self )!=processing.end() ){
+ d_card = Cardinality::INTEGERS;
+ }else{
+ processing.push_back( d_self );
+ Cardinality c = 0;
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ c += (*i).computeCardinality( processing );
+ }
+ d_card = c;
+ processing.pop_back();
+ }
+ return d_card;
+}
+
+bool Datatype::isRecursiveSingleton() const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), this, "this datatype is not yet resolved");
+ if( d_card_rec_singleton==0 ){
+ Assert( d_card_u_assume.empty() );
+ std::vector< Type > processing;
+ if( computeCardinalityRecSingleton( processing, d_card_u_assume ) ){
+ d_card_rec_singleton = 1;
+ }else{
+ d_card_rec_singleton = -1;
+ }
+ if( d_card_rec_singleton==1 ){
+ Trace("dt-card") << "Datatype " << getName() << " is recursive singleton, dependent upon " << d_card_u_assume.size() << " uninterpreted sorts: " << std::endl;
+ for( unsigned i=0; i<d_card_u_assume.size(); i++ ){
+ Trace("dt-card") << " " << d_card_u_assume [i] << std::endl;
+ }
+ Trace("dt-card") << std::endl;
+ }
+ }
+ return d_card_rec_singleton==1;
+}
+
+unsigned Datatype::getNumRecursiveSingletonArgTypes() const throw(IllegalArgumentException) {
+ return d_card_u_assume.size();
+}
+Type Datatype::getRecursiveSingletonArgType( unsigned i ) const throw(IllegalArgumentException) {
+ return d_card_u_assume[i];
+}
+
+bool Datatype::computeCardinalityRecSingleton( std::vector< Type >& processing, std::vector< Type >& u_assume ) const throw(IllegalArgumentException){
+ if( std::find( processing.begin(), processing.end(), d_self )!=processing.end() ){
+ return true;
+ }else{
+ if( d_card_rec_singleton==0 ){
+ //if not yet computed
+ if( d_constructors.size()==1 ){
+ bool success = false;
+ processing.push_back( d_self );
+ for(unsigned i = 0; i<d_constructors[0].getNumArgs(); i++ ) {
+ Type t = ((SelectorType)d_constructors[0][i].getType()).getRangeType();
+ //if it is an uninterpreted sort, then we depend on it having cardinality one
+ if( t.isSort() ){
+ if( std::find( u_assume.begin(), u_assume.end(), t )==u_assume.end() ){
+ u_assume.push_back( t );
+ }
+ //if it is a datatype, recurse
+ }else if( t.isDatatype() ){
+ const Datatype & dt = ((DatatypeType)t).getDatatype();
+ if( !dt.computeCardinalityRecSingleton( processing, u_assume ) ){
+ return false;
+ }else{
+ success = true;
+ }
+ //if it is a builtin type, it must have cardinality one
+ }else if( !t.getCardinality().isOne() ){
+ return false;
+ }
+ }
+ processing.pop_back();
+ return success;
+ }else{
+ return false;
+ }
+ }else if( d_card_rec_singleton==-1 ){
+ return false;
+ }else{
+ for( unsigned i=0; i<d_card_u_assume.size(); i++ ){
+ if( std::find( u_assume.begin(), u_assume.end(), d_card_u_assume[i] )==u_assume.end() ){
+ u_assume.push_back( d_card_u_assume[i] );
+ }
+ }
+ return true;
+ }
+ }
+}
+
+bool Datatype::isFinite() const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), this, "this datatype is not yet resolved");
+
+ // we're using some internals, so we have to set up this library context
+ ExprManagerScope ems(d_self);
+
+ TypeNode self = TypeNode::fromType(d_self);
+
+ // is this already in the cache ?
+ if(self.getAttribute(DatatypeFiniteComputedAttr())) {
+ return self.getAttribute(DatatypeFiniteAttr());
+ }
+
+ Cardinality c = 0;
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ if(! (*i).isFinite()) {
+ self.setAttribute(DatatypeFiniteComputedAttr(), true);
+ self.setAttribute(DatatypeFiniteAttr(), false);
+ return false;
+ }
+ }
+ self.setAttribute(DatatypeFiniteComputedAttr(), true);
+ self.setAttribute(DatatypeFiniteAttr(), true);
+ return true;
+}
+
+bool Datatype::isWellFounded() const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), this, "this datatype is not yet resolved");
+ if( d_well_founded==0 ){
+ // we're using some internals, so we have to set up this library context
+ ExprManagerScope ems(d_self);
+ std::vector< Type > processing;
+ if( computeWellFounded( processing ) ){
+ d_well_founded = 1;
+ }else{
+ d_well_founded = -1;
+ }
+ }
+ return d_well_founded==1;
+}
+
+bool Datatype::computeWellFounded( std::vector< Type >& processing ) const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), this, "this datatype is not yet resolved");
+ if( std::find( processing.begin(), processing.end(), d_self )!=processing.end() ){
+ return d_isCo;
+ }else{
+ processing.push_back( d_self );
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ if( (*i).computeWellFounded( processing ) ){
+ processing.pop_back();
+ return true;
+ }else{
+ Trace("dt-wf") << "Constructor " << (*i).getName() << " is not well-founded." << std::endl;
+ }
+ }
+ processing.pop_back();
+ Trace("dt-wf") << "Datatype " << getName() << " is not well-founded." << std::endl;
+ return false;
+ }
+}
+
+Expr Datatype::mkGroundTerm( Type t ) const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), this, "this datatype is not yet resolved");
+ ExprManagerScope ems(d_self);
+
+
+ // is this already in the cache ?
+ std::map< Type, Expr >::iterator it = d_ground_term.find( t );
+ if( it != d_ground_term.end() ){
+ Debug("datatypes") << "\nin cache: " << d_self << " => " << it->second << std::endl;
+ return it->second;
+ } else {
+ std::vector< Type > processing;
+ Expr groundTerm = computeGroundTerm( t, processing );
+ if(!groundTerm.isNull() ) {
+ // we found a ground-term-constructing constructor!
+ d_ground_term[t] = groundTerm;
+ Debug("datatypes") << "constructed: " << getName() << " => " << groundTerm << std::endl;
+ }
+ if( groundTerm.isNull() ){
+ if( !d_isCo ){
+ // if we get all the way here, we aren't well-founded
+ CheckArgument(false, *this, "datatype is not well-founded, cannot construct a ground term!");
+ }else{
+ return groundTerm;
+ }
+ }else{
+ return groundTerm;
+ }
+ }
+}
+
+Expr getSubtermWithType( Expr e, Type t, bool isTop ){
+ if( !isTop && e.getType()==t ){
+ return e;
+ }else{
+ for( unsigned i=0; i<e.getNumChildren(); i++ ){
+ Expr se = getSubtermWithType( e[i], t, false );
+ if( !se.isNull() ){
+ return se;
+ }
+ }
+ return Expr();
+ }
+}
+
+Expr Datatype::computeGroundTerm( Type t, std::vector< Type >& processing ) const throw(IllegalArgumentException) {
+ if( std::find( processing.begin(), processing.end(), d_self )==processing.end() ){
+ processing.push_back( d_self );
+ for( unsigned r=0; r<2; r++ ){
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ //do nullary constructors first
+ if( ((*i).getNumArgs()==0)==(r==0)){
+ Debug("datatypes") << "Try constructing for " << (*i).getName() << ", processing = " << processing.size() << std::endl;
+ Expr e = (*i).computeGroundTerm( t, processing, d_ground_term );
+ if( !e.isNull() ){
+ //must check subterms for the same type to avoid infinite loops in type enumeration
+ Expr se = getSubtermWithType( e, t, true );
+ if( !se.isNull() ){
+ Debug("datatypes") << "Take subterm " << se << std::endl;
+ e = se;
+ }
+ processing.pop_back();
+ return e;
+ }else{
+ Debug("datatypes") << "...failed." << std::endl;
+ }
+ }
+ }
+ }
+ processing.pop_back();
+ }else{
+ Debug("datatypes") << "...already processing " << t << std::endl;
+ }
+ return Expr();
+}
+
+DatatypeType Datatype::getDatatypeType() const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), *this, "Datatype must be resolved to get its DatatypeType");
+ CheckArgument(!d_self.isNull(), *this);
+ return DatatypeType(d_self);
+}
+
+DatatypeType Datatype::getDatatypeType(const std::vector<Type>& params)
+ const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), *this, "Datatype must be resolved to get its DatatypeType");
+ CheckArgument(!d_self.isNull() && DatatypeType(d_self).isParametric(), this);
+ return DatatypeType(d_self).instantiate(params);
+}
+
+bool Datatype::operator==(const Datatype& other) const throw() {
+ // two datatypes are == iff the name is the same and they have
+ // exactly matching constructors (in the same order)
+
+ if(this == &other) {
+ return true;
+ }
+
+ if(isResolved() != other.isResolved()) {
+ return false;
+ }
+
+ if( d_name != other.d_name ||
+ getNumConstructors() != other.getNumConstructors() ) {
+ return false;
+ }
+ for(const_iterator i = begin(), j = other.begin(); i != end(); ++i, ++j) {
+ Assert(j != other.end());
+ // two constructors are == iff they have the same name, their
+ // constructors and testers are equal and they have exactly
+ // matching args (in the same order)
+ if((*i).getName() != (*j).getName() ||
+ (*i).getNumArgs() != (*j).getNumArgs()) {
+ return false;
+ }
+ // testing equivalence of constructors and testers is harder b/c
+ // this constructor might not be resolved yet; only compare them
+ // if they are both resolved
+ Assert(isResolved() == !(*i).d_constructor.isNull() &&
+ isResolved() == !(*i).d_tester.isNull() &&
+ (*i).d_constructor.isNull() == (*j).d_constructor.isNull() &&
+ (*i).d_tester.isNull() == (*j).d_tester.isNull());
+ if(!(*i).d_constructor.isNull() && (*i).d_constructor != (*j).d_constructor) {
+ return false;
+ }
+ if(!(*i).d_tester.isNull() && (*i).d_tester != (*j).d_tester) {
+ return false;
+ }
+ for(DatatypeConstructor::const_iterator k = (*i).begin(), l = (*j).begin(); k != (*i).end(); ++k, ++l) {
+ Assert(l != (*j).end());
+ if((*k).getName() != (*l).getName()) {
+ return false;
+ }
+ // testing equivalence of selectors is harder b/c args might not
+ // be resolved yet
+ Assert(isResolved() == (*k).isResolved() &&
+ (*k).isResolved() == (*l).isResolved());
+ if((*k).isResolved()) {
+ // both are resolved, so simply compare the selectors directly
+ if((*k).d_selector != (*l).d_selector) {
+ return false;
+ }
+ } else {
+ // neither is resolved, so compare their (possibly unresolved)
+ // types; we don't know if they'll be resolved the same way,
+ // so we can't ever say unresolved types are equal
+ if(!(*k).d_selector.isNull() && !(*l).d_selector.isNull()) {
+ if((*k).d_selector.getType() != (*l).d_selector.getType()) {
+ return false;
+ }
+ } else {
+ if((*k).isUnresolvedSelf() && (*l).isUnresolvedSelf()) {
+ // Fine, the selectors are equal if the rest of the
+ // enclosing datatypes are equal...
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+
+const DatatypeConstructor& Datatype::operator[](size_t index) const {
+ CheckArgument(index < getNumConstructors(), index, "index out of bounds");
+ return d_constructors[index];
+}
+
+const DatatypeConstructor& Datatype::operator[](std::string name) const {
+ for(const_iterator i = begin(); i != end(); ++i) {
+ if((*i).getName() == name) {
+ return *i;
+ }
+ }
+ CheckArgument(false, name, "No such constructor `%s' of datatype `%s'", name.c_str(), d_name.c_str());
+}
+
+Expr Datatype::getConstructor(std::string name) const {
+ return (*this)[name].getConstructor();
+}
+
+Type Datatype::getSygusType() const {
+ return d_sygus_type;
+}
+
+Expr Datatype::getSygusVarList() const {
+ return d_sygus_bvl;
+}
+
+bool Datatype::getSygusAllowConst() const {
+ return d_sygus_allow_const;
+}
+
+bool Datatype::getSygusAllowAll() const {
+ return d_sygus_allow_const;
+}
+
+bool Datatype::involvesExternalType() const{
+ return d_involvesExt;
+}
+
+void DatatypeConstructor::resolve(ExprManager* em, DatatypeType self,
+ const std::map<std::string, DatatypeType>& resolutions,
+ const std::vector<Type>& placeholders,
+ const std::vector<Type>& replacements,
+ const std::vector< SortConstructorType >& paramTypes,
+ const std::vector< DatatypeType >& paramReplacements, size_t cindex)
+ throw(IllegalArgumentException, DatatypeResolutionException) {
+
+ CheckArgument(em != NULL, em, "cannot resolve a Datatype with a NULL expression manager");
+ CheckArgument(!isResolved(),
+ "cannot resolve a Datatype constructor twice; "
+ "perhaps the same constructor was added twice, "
+ "or to two datatypes?");
+
+ // we're using some internals, so we have to set up this library context
+ ExprManagerScope ems(*em);
+
+ NodeManager* nm = NodeManager::fromExprManager(em);
+ TypeNode selfTypeNode = TypeNode::fromType(self);
+ size_t index = 0;
+ for(std::vector<DatatypeConstructorArg>::iterator i = d_args.begin(), i_end = d_args.end(); i != i_end; ++i) {
+ if((*i).d_selector.isNull()) {
+ // the unresolved type wasn't created here; do name resolution
+ string typeName = (*i).d_name.substr((*i).d_name.find('\0') + 1);
+ (*i).d_name.resize((*i).d_name.find('\0'));
+ if(typeName == "") {
+ (*i).d_selector = nm->mkSkolem((*i).d_name, nm->mkSelectorType(selfTypeNode, selfTypeNode), "is a selector", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
+ } else {
+ map<string, DatatypeType>::const_iterator j = resolutions.find(typeName);
+ if(j == resolutions.end()) {
+ stringstream msg;
+ msg << "cannot resolve type \"" << typeName << "\" "
+ << "in selector \"" << (*i).d_name << "\" "
+ << "of constructor \"" << d_name << "\"";
+ throw DatatypeResolutionException(msg.str());
+ } else {
+ (*i).d_selector = nm->mkSkolem((*i).d_name, nm->mkSelectorType(selfTypeNode, TypeNode::fromType((*j).second)), "is a selector", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
+ }
+ }
+ } else {
+ // the type for the selector already exists; may need
+ // complex-type substitution
+ Type range = (*i).d_selector.getType();
+ if(!placeholders.empty()) {
+ range = range.substitute(placeholders, replacements);
+ }
+ if(!paramTypes.empty() ) {
+ range = doParametricSubstitution( range, paramTypes, paramReplacements );
+ }
+ (*i).d_selector = nm->mkSkolem((*i).d_name, nm->mkSelectorType(selfTypeNode, TypeNode::fromType(range)), "is a selector", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
+ }
+ Node::fromExpr((*i).d_selector).setAttribute(DatatypeConsIndexAttr(), cindex);
+ Node::fromExpr((*i).d_selector).setAttribute(DatatypeIndexAttr(), index++);
+ (*i).d_resolved = true;
+ }
+
+ Assert(index == getNumArgs());
+
+ // Set constructor/tester last, since DatatypeConstructor::isResolved()
+ // returns true when d_tester is not the null Expr. If something
+ // fails above, we want Constuctor::isResolved() to remain "false".
+ // Further, mkConstructorType() iterates over the selectors, so
+ // should get the results of any resolutions we did above.
+ d_tester = nm->mkSkolem(getTesterName(), nm->mkTesterType(selfTypeNode), "is a tester", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
+ d_constructor = nm->mkSkolem(getName(), nm->mkConstructorType(*this, selfTypeNode), "is a constructor", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
+ // associate constructor with all selectors
+ for(std::vector<DatatypeConstructorArg>::iterator i = d_args.begin(), i_end = d_args.end(); i != i_end; ++i) {
+ (*i).d_constructor = d_constructor;
+ }
+}
+
+Type DatatypeConstructor::doParametricSubstitution( Type range,
+ const std::vector< SortConstructorType >& paramTypes,
+ const std::vector< DatatypeType >& paramReplacements ) {
+ TypeNode typn = TypeNode::fromType( range );
+ if(typn.getNumChildren() == 0) {
+ return range;
+ } else {
+ std::vector< Type > origChildren;
+ std::vector< Type > children;
+ for(TypeNode::const_iterator i = typn.begin(), iend = typn.end();i != iend; ++i) {
+ origChildren.push_back( (*i).toType() );
+ children.push_back( doParametricSubstitution( (*i).toType(), paramTypes, paramReplacements ) );
+ }
+ for( unsigned i = 0; i < paramTypes.size(); ++i ) {
+ if( paramTypes[i].getArity() == origChildren.size() ) {
+ Type tn = paramTypes[i].instantiate( origChildren );
+ if( range == tn ) {
+ return paramReplacements[i].instantiate( children );
+ }
+ }
+ }
+ NodeBuilder<> nb(typn.getKind());
+ for( unsigned i = 0; i < children.size(); ++i ) {
+ nb << TypeNode::fromType( children[i] );
+ }
+ return nb.constructTypeNode().toType();
+ }
+}
+
+DatatypeConstructor::DatatypeConstructor(std::string name) :
+ // We don't want to introduce a new data member, because eventually
+ // we're going to be a constant stuffed inside a node. So we stow
+ // the tester name away inside the constructor name until
+ // resolution.
+ d_name(name + '\0' + "is_" + name), // default tester name is "is_FOO"
+ d_tester(),
+ d_args() {
+ CheckArgument(name != "", name, "cannot construct a datatype constructor without a name");
+}
+
+DatatypeConstructor::DatatypeConstructor(std::string name, std::string tester) :
+ // We don't want to introduce a new data member, because eventually
+ // we're going to be a constant stuffed inside a node. So we stow
+ // the tester name away inside the constructor name until
+ // resolution.
+ d_name(name + '\0' + tester),
+ d_tester(),
+ d_args() {
+ CheckArgument(name != "", name, "cannot construct a datatype constructor without a name");
+ CheckArgument(!tester.empty(), tester, "cannot construct a datatype constructor without a tester");
+}
+
+void DatatypeConstructor::setSygus( Expr op, Expr let_body, std::vector< Expr >& let_args, unsigned num_let_input_args ){
+ d_sygus_op = op;
+ d_sygus_let_body = let_body;
+ d_sygus_let_args.insert( d_sygus_let_args.end(), let_args.begin(), let_args.end() );
+ d_sygus_num_let_input_args = num_let_input_args;
+}
+
+
+void DatatypeConstructor::addArg(std::string selectorName, Type selectorType) {
+ // We don't want to introduce a new data member, because eventually
+ // we're going to be a constant stuffed inside a node. So we stow
+ // the selector type away inside a var until resolution (when we can
+ // create the proper selector type)
+ CheckArgument(!isResolved(), this, "cannot modify a finalized Datatype constructor");
+ CheckArgument(!selectorType.isNull(), selectorType, "cannot add a null selector type");
+
+ // we're using some internals, so we have to set up this library context
+ ExprManagerScope ems(selectorType);
+
+ Expr type = NodeManager::currentNM()->mkSkolem("unresolved_" + selectorName, TypeNode::fromType(selectorType), "is an unresolved selector type placeholder", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
+ Debug("datatypes") << type << endl;
+ d_args.push_back(DatatypeConstructorArg(selectorName, type));
+}
+
+void DatatypeConstructor::addArg(std::string selectorName, DatatypeUnresolvedType selectorType) {
+ // We don't want to introduce a new data member, because eventually
+ // we're going to be a constant stuffed inside a node. So we stow
+ // the selector type away after a NUL in the name string until
+ // resolution (when we can create the proper selector type)
+ CheckArgument(!isResolved(), this, "cannot modify a finalized Datatype constructor");
+ CheckArgument(selectorType.getName() != "", selectorType, "cannot add a null selector type");
+ d_args.push_back(DatatypeConstructorArg(selectorName + '\0' + selectorType.getName(), Expr()));
+}
+
+void DatatypeConstructor::addArg(std::string selectorName, DatatypeSelfType) {
+ // We don't want to introduce a new data member, because eventually
+ // we're going to be a constant stuffed inside a node. So we mark
+ // the name string with a NUL to indicate that we have a
+ // self-selecting selector until resolution (when we can create the
+ // proper selector type)
+ CheckArgument(!isResolved(), this, "cannot modify a finalized Datatype constructor");
+ d_args.push_back(DatatypeConstructorArg(selectorName + '\0', Expr()));
+}
+
+std::string DatatypeConstructor::getName() const throw() {
+ return d_name.substr(0, d_name.find('\0'));
+}
+
+std::string DatatypeConstructor::getTesterName() const throw() {
+ return d_name.substr(d_name.find('\0') + 1);
+}
+
+Expr DatatypeConstructor::getConstructor() const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ return d_constructor;
+}
+
+Type DatatypeConstructor::getSpecializedConstructorType(Type returnType) const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ ExprManagerScope ems(d_constructor);
+ const Datatype& dt = Datatype::datatypeOf(d_constructor);
+ CheckArgument(dt.isParametric(), this, "this datatype constructor is not parametric");
+ DatatypeType dtt = dt.getDatatypeType();
+ Matcher m(dtt);
+ m.doMatching( TypeNode::fromType(dtt), TypeNode::fromType(returnType) );
+ vector<Type> subst;
+ m.getMatches(subst);
+ vector<Type> params = dt.getParameters();
+ return d_constructor.getType().substitute(params, subst);
+}
+
+Expr DatatypeConstructor::getTester() const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ return d_tester;
+}
+
+Expr DatatypeConstructor::getSygusOp() const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ return d_sygus_op;
+}
+
+Expr DatatypeConstructor::getSygusLetBody() const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ return d_sygus_let_body;
+}
+
+unsigned DatatypeConstructor::getNumSygusLetArgs() const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ return d_sygus_let_args.size();
+}
+
+Expr DatatypeConstructor::getSygusLetArg( unsigned i ) const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ return d_sygus_let_args[i];
+}
+
+unsigned DatatypeConstructor::getNumSygusLetInputArgs() const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ return d_sygus_num_let_input_args;
+}
+
+bool DatatypeConstructor::isSygusIdFunc() const {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+ return d_sygus_let_args.size()==1 && d_sygus_let_args[0]==d_sygus_let_body;
+}
+
+Cardinality DatatypeConstructor::getCardinality() const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+
+ Cardinality c = 1;
+
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ c *= SelectorType((*i).getSelector().getType()).getRangeType().getCardinality();
+ }
+
+ return c;
+}
+
+/** compute the cardinality of this datatype */
+Cardinality DatatypeConstructor::computeCardinality( std::vector< Type >& processing ) const throw(IllegalArgumentException){
+ Cardinality c = 1;
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ Type t = SelectorType((*i).getSelector().getType()).getRangeType();
+ if( t.isDatatype() ){
+ const Datatype& dt = ((DatatypeType)t).getDatatype();
+ c *= dt.computeCardinality( processing );
+ }else{
+ c *= t.getCardinality();
+ }
+ }
+ return c;
+}
+
+bool DatatypeConstructor::computeWellFounded( std::vector< Type >& processing ) const throw(IllegalArgumentException){
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ Type t = SelectorType((*i).getSelector().getType()).getRangeType();
+ if( t.isDatatype() ){
+ const Datatype& dt = ((DatatypeType)t).getDatatype();
+ if( !dt.computeWellFounded( processing ) ){
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+
+bool DatatypeConstructor::isFinite() const throw(IllegalArgumentException) {
+ CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
+
+ // we're using some internals, so we have to set up this library context
+ ExprManagerScope ems(d_constructor);
+
+ TNode self = Node::fromExpr(d_constructor);
+
+ // is this already in the cache ?
+ if(self.getAttribute(DatatypeFiniteComputedAttr())) {
+ return self.getAttribute(DatatypeFiniteAttr());
+ }
+
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ if(! SelectorType((*i).getSelector().getType()).getRangeType().getCardinality().isFinite()) {
+ self.setAttribute(DatatypeFiniteComputedAttr(), true);
+ self.setAttribute(DatatypeFiniteAttr(), false);
+ return false;
+ }
+ }
+
+ self.setAttribute(DatatypeFiniteComputedAttr(), true);
+ self.setAttribute(DatatypeFiniteAttr(), true);
+ return true;
+}
+
+Expr DatatypeConstructor::computeGroundTerm( Type t, std::vector< Type >& processing, std::map< Type, Expr >& gt ) const throw(IllegalArgumentException) {
+// we're using some internals, so we have to set up this library context
+ ExprManagerScope ems(d_constructor);
+
+ std::vector<Expr> groundTerms;
+ groundTerms.push_back(getConstructor());
+
+ // for each selector, get a ground term
+ std::vector< Type > instTypes;
+ std::vector< Type > paramTypes;
+ if( DatatypeType(t).isParametric() ){
+ paramTypes = DatatypeType(t).getDatatype().getParameters();
+ instTypes = DatatypeType(t).getParamTypes();
+ }
+ for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
+ Type selType = SelectorType((*i).getSelector().getType()).getRangeType();
+ if( DatatypeType(t).isParametric() ){
+ selType = selType.substitute( paramTypes, instTypes );
+ }
+ Expr arg;
+ if( selType.isDatatype() ){
+ std::map< Type, Expr >::iterator itgt = gt.find( selType );
+ if( itgt != gt.end() ){
+ arg = itgt->second;
+ }else{
+ const Datatype & dt = DatatypeType(selType).getDatatype();
+ arg = dt.computeGroundTerm( selType, processing );
+ }
+ }else{
+ arg = selType.mkGroundTerm();
+ }
+ if( arg.isNull() ){
+ Debug("datatypes") << "...unable to construct arg of " << (*i).getName() << std::endl;
+ return Expr();
+ }else{
+ Debug("datatypes") << "...constructed arg " << arg.getType() << std::endl;
+ groundTerms.push_back(arg);
+ }
+ }
+
+ Expr groundTerm = getConstructor().getExprManager()->mkExpr(kind::APPLY_CONSTRUCTOR, groundTerms);
+ if( groundTerm.getType()!=t ){
+ Assert( Datatype::datatypeOf( d_constructor ).isParametric() );
+ //type is ambiguous, must apply type ascription
+ Debug("datatypes-gt") << "ambiguous type for " << groundTerm << ", ascribe to " << t << std::endl;
+ groundTerms[0] = getConstructor().getExprManager()->mkExpr(kind::APPLY_TYPE_ASCRIPTION,
+ getConstructor().getExprManager()->mkConst(AscriptionType(getSpecializedConstructorType(t))),
+ groundTerms[0]);
+ groundTerm = getConstructor().getExprManager()->mkExpr(kind::APPLY_CONSTRUCTOR, groundTerms);
+ }
+ return groundTerm;
+}
+
+
+const DatatypeConstructorArg& DatatypeConstructor::operator[](size_t index) const {
+ CheckArgument(index < getNumArgs(), index, "index out of bounds");
+ return d_args[index];
+}
+
+const DatatypeConstructorArg& DatatypeConstructor::operator[](std::string name) const {
+ for(const_iterator i = begin(); i != end(); ++i) {
+ if((*i).getName() == name) {
+ return *i;
+ }
+ }
+ CheckArgument(false, name, "No such arg `%s' of constructor `%s'", name.c_str(), d_name.c_str());
+}
+
+Expr DatatypeConstructor::getSelector(std::string name) const {
+ return (*this)[name].getSelector();
+}
+
+bool DatatypeConstructor::involvesExternalType() const{
+ for(const_iterator i = begin(); i != end(); ++i) {
+ if(! SelectorType((*i).getSelector().getType()).getRangeType().isDatatype()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+DatatypeConstructorArg::DatatypeConstructorArg(std::string name, Expr selector) :
+ d_name(name),
+ d_selector(selector),
+ d_resolved(false) {
+ CheckArgument(name != "", name, "cannot construct a datatype constructor arg without a name");
+}
+
+std::string DatatypeConstructorArg::getName() const throw() {
+ string name = d_name;
+ const size_t nul = name.find('\0');
+ if(nul != string::npos) {
+ name.resize(nul);
+ }
+ return name;
+}
+
+Expr DatatypeConstructorArg::getSelector() const {
+ CheckArgument(isResolved(), this, "cannot get a selector for an unresolved datatype constructor");
+ return d_selector;
+}
+
+Expr DatatypeConstructorArg::getConstructor() const {
+ CheckArgument(isResolved(), this,
+ "cannot get a associated constructor for argument of an unresolved datatype constructor");
+ return d_constructor;
+}
+
+SelectorType DatatypeConstructorArg::getType() const {
+ return getSelector().getType();
+}
+
+bool DatatypeConstructorArg::isUnresolvedSelf() const throw() {
+ return d_selector.isNull() && d_name.size() == d_name.find('\0') + 1;
+}
+
+static const int s_printDatatypeNamesOnly = std::ios_base::xalloc();
+
+std::string DatatypeConstructorArg::getTypeName() const {
+ Type t;
+ if(isResolved()) {
+ t = SelectorType(d_selector.getType()).getRangeType();
+ } else {
+ if(d_selector.isNull()) {
+ string typeName = d_name.substr(d_name.find('\0') + 1);
+ return (typeName == "") ? "[self]" : typeName;
+ } else {
+ t = d_selector.getType();
+ }
+ }
+
+ // Unfortunately, in the case of complex selector types, we can
+ // enter nontrivial recursion here. Make sure that doesn't happen.
+ stringstream ss;
+ ss << Expr::setlanguage(language::output::LANG_CVC4);
+ ss.iword(s_printDatatypeNamesOnly) = 1;
+ t.toStream(ss);
+ return ss.str();
+}
+
+std::ostream& operator<<(std::ostream& os, const Datatype& dt) {
+ // These datatype things are recursive! Be very careful not to
+ // print an infinite chain of them.
+ long& printNameOnly = os.iword(s_printDatatypeNamesOnly);
+ Debug("datatypes-output") << "printNameOnly is " << printNameOnly << std::endl;
+ if(printNameOnly) {
+ return os << dt.getName();
+ }
+
+ class Scope {
+ long& d_ref;
+ long d_oldValue;
+ public:
+ Scope(long& ref, long value) : d_ref(ref), d_oldValue(ref) { d_ref = value; }
+ ~Scope() { d_ref = d_oldValue; }
+ } scope(printNameOnly, 1);
+ // when scope is destructed, the value pops back
+
+ Debug("datatypes-output") << "printNameOnly is now " << printNameOnly << std::endl;
+
+ // can only output datatypes in the CVC4 native language
+ Expr::setlanguage::Scope ls(os, language::output::LANG_CVC4);
+
+ os << "DATATYPE " << dt.getName();
+ if(dt.isParametric()) {
+ os << '[';
+ for(size_t i = 0; i < dt.getNumParameters(); ++i) {
+ if(i > 0) {
+ os << ',';
+ }
+ os << dt.getParameter(i);
+ }
+ os << ']';
+ }
+ os << " =" << endl;
+ Datatype::const_iterator i = dt.begin(), i_end = dt.end();
+ if(i != i_end) {
+ os << " ";
+ do {
+ os << *i << endl;
+ if(++i != i_end) {
+ os << "| ";
+ }
+ } while(i != i_end);
+ }
+ os << "END;" << endl;
+
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const DatatypeConstructor& ctor) {
+ // can only output datatypes in the CVC4 native language
+ Expr::setlanguage::Scope ls(os, language::output::LANG_CVC4);
+
+ os << ctor.getName();
+
+ DatatypeConstructor::const_iterator i = ctor.begin(), i_end = ctor.end();
+ if(i != i_end) {
+ os << "(";
+ do {
+ os << *i;
+ if(++i != i_end) {
+ os << ", ";
+ }
+ } while(i != i_end);
+ os << ")";
+ }
+
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const DatatypeConstructorArg& arg) {
+ // can only output datatypes in the CVC4 native language
+ Expr::setlanguage::Scope ls(os, language::output::LANG_CVC4);
+
+ os << arg.getName() << ": " << arg.getTypeName();
+
+ return os;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file datatype.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 A class representing a Datatype definition
+ **
+ ** A class representing a Datatype definition for the theory of
+ ** inductive datatypes.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__DATATYPE_H
+#define __CVC4__DATATYPE_H
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <map>
+
+namespace CVC4 {
+ // messy; Expr needs Datatype (because it's the payload of a
+ // CONSTANT-kinded expression), and Datatype needs Expr.
+ class CVC4_PUBLIC Datatype;
+}/* CVC4 namespace */
+
+#include "base/exception.h"
+#include "expr/expr.h"
+#include "expr/type.h"
+#include "util/hash.h"
+
+
+namespace CVC4 {
+
+class CVC4_PUBLIC ExprManager;
+
+class CVC4_PUBLIC DatatypeConstructor;
+class CVC4_PUBLIC DatatypeConstructorArg;
+
+class CVC4_PUBLIC DatatypeConstructorIterator {
+ const std::vector<DatatypeConstructor>* d_v;
+ size_t d_i;
+
+ friend class Datatype;
+
+ DatatypeConstructorIterator(const std::vector<DatatypeConstructor>& v, bool start) : d_v(&v), d_i(start ? 0 : v.size()) {
+ }
+
+public:
+ typedef const DatatypeConstructor& value_type;
+ const DatatypeConstructor& operator*() const { return (*d_v)[d_i]; }
+ const DatatypeConstructor* operator->() const { return &(*d_v)[d_i]; }
+ DatatypeConstructorIterator& operator++() { ++d_i; return *this; }
+ DatatypeConstructorIterator operator++(int) { DatatypeConstructorIterator i(*this); ++d_i; return i; }
+ bool operator==(const DatatypeConstructorIterator& other) const { return d_v == other.d_v && d_i == other.d_i; }
+ bool operator!=(const DatatypeConstructorIterator& other) const { return d_v != other.d_v || d_i != other.d_i; }
+};/* class DatatypeConstructorIterator */
+
+class CVC4_PUBLIC DatatypeConstructorArgIterator {
+ const std::vector<DatatypeConstructorArg>* d_v;
+ size_t d_i;
+
+ friend class DatatypeConstructor;
+
+ DatatypeConstructorArgIterator(const std::vector<DatatypeConstructorArg>& v, bool start) : d_v(&v), d_i(start ? 0 : v.size()) {
+ }
+
+public:
+ typedef const DatatypeConstructorArg& value_type;
+ const DatatypeConstructorArg& operator*() const { return (*d_v)[d_i]; }
+ const DatatypeConstructorArg* operator->() const { return &(*d_v)[d_i]; }
+ DatatypeConstructorArgIterator& operator++() { ++d_i; return *this; }
+ DatatypeConstructorArgIterator operator++(int) { DatatypeConstructorArgIterator i(*this); ++d_i; return i; }
+ bool operator==(const DatatypeConstructorArgIterator& other) const { return d_v == other.d_v && d_i == other.d_i; }
+ bool operator!=(const DatatypeConstructorArgIterator& other) const { return d_v != other.d_v || d_i != other.d_i; }
+};/* class DatatypeConstructorArgIterator */
+
+/**
+ * An exception that is thrown when a datatype resolution fails.
+ */
+class CVC4_PUBLIC DatatypeResolutionException : public Exception {
+public:
+ inline DatatypeResolutionException(std::string msg);
+};/* class DatatypeResolutionException */
+
+/**
+ * A holder type (used in calls to DatatypeConstructor::addArg())
+ * to allow a Datatype to refer to itself. Self-typed fields of
+ * Datatypes will be properly typed when a Type is created for the
+ * Datatype by the ExprManager (which calls Datatype::resolve()).
+ */
+class CVC4_PUBLIC DatatypeSelfType {
+};/* class DatatypeSelfType */
+
+/**
+ * An unresolved type (used in calls to
+ * DatatypeConstructor::addArg()) to allow a Datatype to refer to
+ * itself or to other mutually-recursive Datatypes. Unresolved-type
+ * fields of Datatypes will be properly typed when a Type is created
+ * for the Datatype by the ExprManager (which calls
+ * Datatype::resolve()).
+ */
+class CVC4_PUBLIC DatatypeUnresolvedType {
+ std::string d_name;
+public:
+ inline DatatypeUnresolvedType(std::string name);
+ inline std::string getName() const throw();
+};/* class DatatypeUnresolvedType */
+
+/**
+ * A Datatype constructor argument (i.e., a Datatype field).
+ */
+class CVC4_PUBLIC DatatypeConstructorArg {
+
+ std::string d_name;
+ Expr d_selector;
+ /** the constructor associated with this selector */
+ Expr d_constructor;
+ bool d_resolved;
+
+ DatatypeConstructorArg(std::string name, Expr selector);
+ friend class DatatypeConstructor;
+ friend class Datatype;
+
+ bool isUnresolvedSelf() const throw();
+
+public:
+
+ /** Get the name of this constructor argument. */
+ std::string getName() const throw();
+
+ /**
+ * Get the selector for this constructor argument; this call is
+ * only permitted after resolution.
+ */
+ Expr getSelector() const;
+
+ /**
+ * Get the associated constructor for this constructor argument;
+ * this call is only permitted after resolution.
+ */
+ Expr getConstructor() const;
+
+ /**
+ * Get the type of the selector for this constructor argument;
+ * this call is only permitted after resolution.
+ */
+ SelectorType getType() const;
+
+ /**
+ * Get the name of the type of this constructor argument
+ * (Datatype field). Can be used for not-yet-resolved Datatypes
+ * (in which case the name of the unresolved type, or "[self]"
+ * for a self-referential type is returned).
+ */
+ std::string getTypeName() const;
+
+ /**
+ * Returns true iff this constructor argument has been resolved.
+ */
+ bool isResolved() const throw();
+
+};/* class DatatypeConstructorArg */
+
+/**
+ * A constructor for a Datatype.
+ */
+class CVC4_PUBLIC DatatypeConstructor {
+public:
+
+ /** The type for iterators over constructor arguments. */
+ typedef DatatypeConstructorArgIterator iterator;
+ /** The (const) type for iterators over constructor arguments. */
+ typedef DatatypeConstructorArgIterator const_iterator;
+
+private:
+
+ std::string d_name;
+ Expr d_constructor;
+ Expr d_tester;
+ std::vector<DatatypeConstructorArg> d_args;
+ /** the operator associated with this constructor (for sygus) */
+ Expr d_sygus_op;
+ Expr d_sygus_let_body;
+ std::vector< Expr > d_sygus_let_args;
+ unsigned d_sygus_num_let_input_args;
+
+ void resolve(ExprManager* em, DatatypeType self,
+ const std::map<std::string, DatatypeType>& resolutions,
+ const std::vector<Type>& placeholders,
+ const std::vector<Type>& replacements,
+ const std::vector< SortConstructorType >& paramTypes,
+ const std::vector< DatatypeType >& paramReplacements, size_t cindex)
+ throw(IllegalArgumentException, DatatypeResolutionException);
+ friend class Datatype;
+
+ /** Helper function for resolving parametric datatypes.
+ This replaces instances of the SortConstructorType produced for unresolved
+ parametric datatypes, with the corresponding resolved DatatypeType. For example, take
+ the parametric definition of a list, list[T] = cons(car : T, cdr : list[T]) | null.
+ If "range" is the unresolved parametric datatype:
+ DATATYPE list = cons(car: SORT_TAG_1, cdr: SORT_TAG_2(SORT_TAG_1)) | null END;,
+ this function will return the resolved type:
+ DATATYPE list = cons(car: SORT_TAG_1, cdr: (list PARAMETERIC_DATATYPE SORT_TAG_1)) | null END;
+ */
+ Type doParametricSubstitution(Type range,
+ const std::vector< SortConstructorType >& paramTypes,
+ const std::vector< DatatypeType >& paramReplacements);
+
+ /** compute the cardinality of this datatype */
+ Cardinality computeCardinality( std::vector< Type >& processing ) const throw(IllegalArgumentException);
+ /** compute whether this datatype is well-founded */
+ bool computeWellFounded( std::vector< Type >& processing ) const throw(IllegalArgumentException);
+ /** compute ground term */
+ Expr computeGroundTerm( Type t, std::vector< Type >& processing, std::map< Type, Expr >& gt ) const throw(IllegalArgumentException);
+public:
+ /**
+ * Create a new Datatype constructor with the given name for the
+ * constructor and the same name (prefixed with "is_") for the
+ * tester. The actual constructor and tester (meaning, the Exprs
+ * representing operators for these entities) aren't created until
+ * resolution time.
+ */
+ explicit DatatypeConstructor(std::string name);
+
+ /**
+ * Create a new Datatype constructor with the given name for the
+ * constructor and the given name for the tester. The actual
+ * constructor and tester aren't created until resolution time.
+ */
+ DatatypeConstructor(std::string name, std::string tester);
+
+ /** set sygus */
+ void setSygus( Expr op, Expr let_body, std::vector< Expr >& let_args, unsigned num_let_input_argus );
+
+ /**
+ * Add an argument (i.e., a data field) of the given name and type
+ * to this Datatype constructor. Selector names need not be unique;
+ * they are for convenience and pretty-printing only.
+ */
+ void addArg(std::string selectorName, Type selectorType);
+
+ /**
+ * Add an argument (i.e., a data field) of the given name to this
+ * Datatype constructor that refers to an as-yet-unresolved
+ * Datatype (which may be mutually-recursive). Selector names need
+ * not be unique; they are for convenience and pretty-printing only.
+ */
+ void addArg(std::string selectorName, DatatypeUnresolvedType selectorType);
+
+ /**
+ * Add a self-referential (i.e., a data field) of the given name
+ * to this Datatype constructor that refers to the enclosing
+ * Datatype. For example, using the familiar "nat" Datatype, to
+ * create the "pred" field for "succ" constructor, one uses
+ * succ::addArg("pred", DatatypeSelfType())---the actual Type
+ * cannot be passed because the Datatype is still under
+ * construction. Selector names need not be unique; they are for
+ * convenience and pretty-printing only.
+ *
+ * This is a special case of
+ * DatatypeConstructor::addArg(std::string, DatatypeUnresolvedType).
+ */
+ void addArg(std::string selectorName, DatatypeSelfType);
+
+ /** Get the name of this Datatype constructor. */
+ std::string getName() const throw();
+
+ /**
+ * Get the constructor operator of this Datatype constructor. The
+ * Datatype must be resolved.
+ */
+ Expr getConstructor() const;
+
+ /**
+ * Get the tester operator of this Datatype constructor. The
+ * Datatype must be resolved.
+ */
+ Expr getTester() const;
+
+ /** get sygus op */
+ Expr getSygusOp() const;
+ /** get sygus let body */
+ Expr getSygusLetBody() const;
+ /** get number of sygus let args */
+ unsigned getNumSygusLetArgs() const;
+ /** get sygus let arg */
+ Expr getSygusLetArg( unsigned i ) const;
+ /** get number of let arguments that should be printed as arguments to let */
+ unsigned getNumSygusLetInputArgs() const;
+ /** is this a sygus identity function */
+ bool isSygusIdFunc() const;
+
+ /**
+ * Get the tester name for this Datatype constructor.
+ */
+ std::string getTesterName() const throw();
+
+ /**
+ * Get the number of arguments (so far) of this Datatype constructor.
+ */
+ inline size_t getNumArgs() const throw();
+
+ /**
+ * Get the specialized constructor type for a parametric
+ * constructor; this call is only permitted after resolution.
+ * Given a (concrete) returnType, the constructor's concrete
+ * type in this parametric datatype is returned.
+ *
+ * For instance, if the datatype is list[T], with constructor
+ * "cons[T]" of type "T -> list[T] -> list[T]", then calling
+ * this function with "list[int]" will return the concrete
+ * "cons" constructor type for lists of int---namely,
+ * "int -> list[int] -> list[int]".
+ */
+ Type getSpecializedConstructorType(Type returnType) const;
+
+ /**
+ * Return the cardinality of this constructor (the product of the
+ * cardinalities of its arguments).
+ */
+ Cardinality getCardinality() const throw(IllegalArgumentException);
+
+ /**
+ * Return true iff this constructor is finite (it is nullary or
+ * each of its argument types are finite). This function can
+ * only be called for resolved constructors.
+ */
+ bool isFinite() const throw(IllegalArgumentException);
+
+ /**
+ * Returns true iff this Datatype constructor has already been
+ * resolved.
+ */
+ inline bool isResolved() const throw();
+
+ /** Get the beginning iterator over DatatypeConstructor args. */
+ inline iterator begin() throw();
+ /** Get the ending iterator over DatatypeConstructor args. */
+ inline iterator end() throw();
+ /** Get the beginning const_iterator over DatatypeConstructor args. */
+ inline const_iterator begin() const throw();
+ /** Get the ending const_iterator over DatatypeConstructor args. */
+ inline const_iterator end() const throw();
+
+ /** Get the ith DatatypeConstructor arg. */
+ const DatatypeConstructorArg& operator[](size_t index) const;
+
+ /**
+ * Get the DatatypeConstructor arg named. This is a linear search
+ * through the arguments, so in the case of multiple,
+ * similarly-named arguments, the first is returned.
+ */
+ const DatatypeConstructorArg& operator[](std::string name) const;
+
+ /**
+ * Get the selector named. This is a linear search
+ * through the arguments, so in the case of multiple,
+ * similarly-named arguments, the selector for the first
+ * is returned.
+ */
+ Expr getSelector(std::string name) const;
+
+ /**
+ * Get whether this datatype involves an external type. If so,
+ * then we will pose additional requirements for sharing.
+ */
+ bool involvesExternalType() const;
+
+};/* class DatatypeConstructor */
+
+/**
+ * The representation of an inductive datatype.
+ *
+ * This is far more complicated than it first seems. Consider this
+ * datatype definition:
+ *
+ * DATATYPE nat =
+ * succ(pred: nat)
+ * | zero
+ * END;
+ *
+ * You cannot define "nat" until you have a Type for it, but you
+ * cannot have a Type for it until you fill in the type of the "pred"
+ * selector, which needs the Type. So we have a chicken-and-egg
+ * problem. It's even more complicated when we have mutual recursion
+ * between datatypes, since the CVC presentation language does not
+ * require forward-declarations. Here, we define trees of lists that
+ * contain trees of lists (etc):
+ *
+ * DATATYPE
+ * tree = node(left: tree, right: tree) | leaf(list),
+ * list = cons(car: tree, cdr: list) | nil
+ * END;
+ *
+ * Note that while parsing the "tree" definition, we have to take it
+ * on faith that "list" is a valid type. We build Datatype objects to
+ * describe "tree" and "list", and their constructors and constructor
+ * arguments, but leave any unknown types (including self-references)
+ * in an "unresolved" state. After parsing the whole DATATYPE block,
+ * we create a DatatypeType through
+ * ExprManager::mkMutualDatatypeTypes(). The ExprManager creates a
+ * DatatypeType for each, but before "releasing" this type into the
+ * wild, it does a round of in-place "resolution" on each Datatype by
+ * calling Datatype::resolve() with a map of string -> DatatypeType to
+ * allow the datatype to construct the necessary testers and
+ * selectors.
+ *
+ * An additional point to make is that we want to ease the burden on
+ * both the parser AND the users of the CVC4 API, so this class takes
+ * on the task of generating its own selectors and testers, for
+ * instance. That means that, after reifying the Datatype with the
+ * ExprManager, the parser needs to go through the (now-resolved)
+ * Datatype and request the constructor, selector, and tester terms.
+ * See src/parser/parser.cpp for how this is done. For API usage
+ * ideas, see test/unit/util/datatype_black.h.
+ *
+ * Datatypes may also be defined parametrically, such as this example:
+ *
+ * DATATYPE
+ * list[T] = cons(car : T, cdr : list[T]) | null,
+ * tree = node(children : list[tree]) | leaf
+ * END;
+ *
+ * Here, the definition of the parametric datatype list, where T is a type variable.
+ * In other words, this defines a family of types list[C] where C is any concrete
+ * type. Datatypes can be parameterized over multiple type variables using the
+ * syntax sym[ T1, ..., Tn ] = ...,
+ *
+ */
+class CVC4_PUBLIC Datatype {
+ friend class DatatypeConstructor;
+public:
+ /**
+ * Get the datatype of a constructor, selector, or tester operator.
+ */
+ static const Datatype& datatypeOf(Expr item) CVC4_PUBLIC;
+
+ /**
+ * Get the index of a constructor or tester in its datatype, or the
+ * index of a selector in its constructor. (Zero is always the
+ * first index.)
+ */
+ static size_t indexOf(Expr item) CVC4_PUBLIC;
+
+ /**
+ * Get the index of constructor corresponding to selector. (Zero is
+ * always the first index.)
+ */
+ static size_t cindexOf(Expr item) CVC4_PUBLIC;
+
+ /** The type for iterators over constructors. */
+ typedef DatatypeConstructorIterator iterator;
+ /** The (const) type for iterators over constructors. */
+ typedef DatatypeConstructorIterator const_iterator;
+
+private:
+ std::string d_name;
+ std::vector<Type> d_params;
+ bool d_isCo;
+ std::vector<DatatypeConstructor> d_constructors;
+ bool d_resolved;
+ Type d_self;
+ bool d_involvesExt;
+ /** information for sygus */
+ Type d_sygus_type;
+ Expr d_sygus_bvl;
+ bool d_sygus_allow_const;
+ bool d_sygus_allow_all;
+
+ // "mutable" because computing the cardinality can be expensive,
+ // and so it's computed just once, on demand---this is the cache
+ mutable Cardinality d_card;
+
+ // is this type a recursive singleton type
+ mutable int d_card_rec_singleton;
+ // if d_card_rec_singleton is true,
+ // infinite cardinality depends on at least one of the following uninterpreted sorts having cardinality > 1
+ mutable std::vector< Type > d_card_u_assume;
+ // is this well-founded
+ mutable int d_well_founded;
+ // ground term for this datatype
+ mutable std::map< Type, Expr > d_ground_term;
+
+ /**
+ * Datatypes refer to themselves, recursively, and we have a
+ * chicken-and-egg problem. The DatatypeType around the Datatype
+ * cannot exist until the Datatype is finalized, and the Datatype
+ * cannot refer to the DatatypeType representing itself until it
+ * exists. resolve() is called by the ExprManager when a Type is
+ * ultimately requested of the Datatype specification (that is, when
+ * ExprManager::mkDatatypeType() or ExprManager::mkMutualDatatypeTypes()
+ * is called). Has the effect of freezing the object, too; that is,
+ * addConstructor() will fail after a call to resolve().
+ *
+ * The basic goal of resolution is to assign constructors, selectors,
+ * and testers. To do this, any UnresolvedType/SelfType references
+ * must be cleared up. This is the purpose of the "resolutions" map;
+ * it includes any mutually-recursive datatypes that are currently
+ * under resolution. The four vectors come in two pairs (so, really
+ * they are two maps). placeholders->replacements give type variables
+ * that should be resolved in the case of parametric datatypes.
+ *
+ * @param em the ExprManager at play
+ * @param resolutions a map of strings to DatatypeTypes currently under resolution
+ * @param placeholders the types in these Datatypes under resolution that must be replaced
+ * @param replacements the corresponding replacements
+ * @param paramTypes the sort constructors in these Datatypes under resolution that must be replaced
+ * @param paramReplacements the corresponding (parametric) DatatypeTypes
+ */
+ void resolve(ExprManager* em,
+ const std::map<std::string, DatatypeType>& resolutions,
+ const std::vector<Type>& placeholders,
+ const std::vector<Type>& replacements,
+ const std::vector< SortConstructorType >& paramTypes,
+ const std::vector< DatatypeType >& paramReplacements)
+ throw(IllegalArgumentException, DatatypeResolutionException);
+ friend class ExprManager;// for access to resolve()
+
+ /** compute the cardinality of this datatype */
+ Cardinality computeCardinality( std::vector< Type >& processing ) const throw(IllegalArgumentException);
+ /** compute whether this datatype is a recursive singleton */
+ bool computeCardinalityRecSingleton( std::vector< Type >& processing, std::vector< Type >& u_assume ) const throw(IllegalArgumentException);
+ /** compute whether this datatype is well-founded */
+ bool computeWellFounded( std::vector< Type >& processing ) const throw(IllegalArgumentException);
+ /** compute ground term */
+ Expr computeGroundTerm( Type t, std::vector< Type >& processing ) const throw(IllegalArgumentException);
+public:
+
+ /** Create a new Datatype of the given name. */
+ inline explicit Datatype(std::string name, bool isCo = false);
+
+ /**
+ * Create a new Datatype of the given name, with the given
+ * parameterization.
+ */
+ inline Datatype(std::string name, const std::vector<Type>& params, bool isCo = false);
+
+ /**
+ * Add a constructor to this Datatype. Constructor names need not
+ * be unique; they are for convenience and pretty-printing only.
+ */
+ void addConstructor(const DatatypeConstructor& c);
+
+ /** set the sygus information of this datatype
+ * st : the builtin type for this grammar
+ * bvl : the list of arguments for the synth-fun
+ * allow_const : whether all constants are (implicitly) included in the grammar
+ */
+ void setSygus( Type st, Expr bvl, bool allow_const, bool allow_all );
+
+ /** Get the name of this Datatype. */
+ inline std::string getName() const throw();
+
+ /** Get the number of constructors (so far) for this Datatype. */
+ inline size_t getNumConstructors() const throw();
+
+ /** Is this datatype parametric? */
+ inline bool isParametric() const throw();
+
+ /** Get the nubmer of type parameters */
+ inline size_t getNumParameters() const throw();
+
+ /** Get parameter */
+ inline Type getParameter( unsigned int i ) const;
+
+ /** Get parameters */
+ inline std::vector<Type> getParameters() const;
+
+ /** is this a co-datatype? */
+ inline bool isCodatatype() const;
+
+ /** is this a sygus datatype? */
+ inline bool isSygus() const;
+
+ /**
+ * Return the cardinality of this datatype (the sum of the
+ * cardinalities of its constructors). The Datatype must be
+ * resolved.
+ */
+ Cardinality getCardinality() const throw(IllegalArgumentException);
+
+ /**
+ * Return true iff this Datatype is finite (all constructors are
+ * finite, i.e., there are finitely many ground terms). If the
+ * datatype is not well-founded, this function returns false. The
+ * Datatype must be resolved or an exception is thrown.
+ */
+ bool isFinite() const throw(IllegalArgumentException);
+
+ /**
+ * Return true iff this datatype is well-founded (there exist ground
+ * terms). The Datatype must be resolved or an exception is thrown.
+ */
+ bool isWellFounded() const throw(IllegalArgumentException);
+
+ /**
+ * Return true iff this datatype is a recursive singleton
+ */
+ bool isRecursiveSingleton() const throw(IllegalArgumentException);
+
+
+ /** get number of recursive singleton argument types */
+ unsigned getNumRecursiveSingletonArgTypes() const throw(IllegalArgumentException);
+ Type getRecursiveSingletonArgType( unsigned i ) const throw(IllegalArgumentException);
+
+ /**
+ * Construct and return a ground term of this Datatype. The
+ * Datatype must be both resolved and well-founded, or else an
+ * exception is thrown.
+ */
+ Expr mkGroundTerm( Type t ) const throw(IllegalArgumentException);
+
+ /**
+ * Get the DatatypeType associated to this Datatype. Can only be
+ * called post-resolution.
+ */
+ DatatypeType getDatatypeType() const throw(IllegalArgumentException);
+
+ /**
+ * Get the DatatypeType associated to this (parameterized) Datatype. Can only be
+ * called post-resolution.
+ */
+ DatatypeType getDatatypeType(const std::vector<Type>& params) const throw(IllegalArgumentException);
+
+ /**
+ * Return true iff the two Datatypes are the same.
+ *
+ * We need == for mkConst(Datatype) to properly work---since if the
+ * Datatype Expr requested is the same as an already-existing one,
+ * we need to return that one. For that, we have a hash and
+ * operator==. We provide != for symmetry. We don't provide
+ * operator<() etc. because given two Datatype Exprs, you could
+ * simply compare those rather than the (bare) Datatypes. This
+ * means, though, that Datatype cannot be stored in a sorted list or
+ * RB tree directly, so maybe we can consider adding these
+ * comparison operators later on.
+ */
+ bool operator==(const Datatype& other) const throw();
+ /** Return true iff the two Datatypes are not the same. */
+ inline bool operator!=(const Datatype& other) const throw();
+
+ /** Return true iff this Datatype has already been resolved. */
+ inline bool isResolved() const throw();
+
+ /** Get the beginning iterator over DatatypeConstructors. */
+ inline iterator begin() throw();
+ /** Get the ending iterator over DatatypeConstructors. */
+ inline iterator end() throw();
+ /** Get the beginning const_iterator over DatatypeConstructors. */
+ inline const_iterator begin() const throw();
+ /** Get the ending const_iterator over DatatypeConstructors. */
+ inline const_iterator end() const throw();
+
+ /** Get the ith DatatypeConstructor. */
+ const DatatypeConstructor& operator[](size_t index) const;
+
+ /**
+ * Get the DatatypeConstructor named. This is a linear search
+ * through the constructors, so in the case of multiple,
+ * similarly-named constructors, the first is returned.
+ */
+ const DatatypeConstructor& operator[](std::string name) const;
+
+ /**
+ * Get the constructor operator for the named constructor.
+ * This is a linear search through the constructors, so in
+ * the case of multiple, similarly-named constructors, the
+ * first is returned.
+ *
+ * This Datatype must be resolved.
+ */
+ Expr getConstructor(std::string name) const;
+
+ /** get sygus type */
+ Type getSygusType() const;
+ /** get sygus var list */
+ Expr getSygusVarList() const;
+ /** does it allow constants */
+ bool getSygusAllowConst() const;
+ /** does it allow constants */
+ bool getSygusAllowAll() const;
+
+ /**
+ * Get whether this datatype involves an external type. If so,
+ * then we will pose additional requirements for sharing.
+ */
+ bool involvesExternalType() const;
+
+};/* class Datatype */
+
+/**
+ * A hash function for Datatypes. Needed to store them in hash sets
+ * and hash maps.
+ */
+struct CVC4_PUBLIC DatatypeHashFunction {
+ inline size_t operator()(const Datatype& dt) const {
+ return StringHashFunction()(dt.getName());
+ }
+ inline size_t operator()(const Datatype* dt) const {
+ return StringHashFunction()(dt->getName());
+ }
+ inline size_t operator()(const DatatypeConstructor& dtc) const {
+ return StringHashFunction()(dtc.getName());
+ }
+ inline size_t operator()(const DatatypeConstructor* dtc) const {
+ return StringHashFunction()(dtc->getName());
+ }
+};/* struct DatatypeHashFunction */
+
+// FUNCTION DECLARATIONS FOR OUTPUT STREAMS
+
+std::ostream& operator<<(std::ostream& os, const Datatype& dt) CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream& os, const DatatypeConstructor& ctor) CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream& os, const DatatypeConstructorArg& arg) CVC4_PUBLIC;
+
+// INLINE FUNCTIONS
+
+inline DatatypeResolutionException::DatatypeResolutionException(std::string msg) :
+ Exception(msg) {
+}
+
+inline DatatypeUnresolvedType::DatatypeUnresolvedType(std::string name) :
+ d_name(name) {
+}
+
+inline std::string DatatypeUnresolvedType::getName() const throw() {
+ return d_name;
+}
+
+inline Datatype::Datatype(std::string name, bool isCo) :
+ d_name(name),
+ d_params(),
+ d_isCo(isCo),
+ d_constructors(),
+ d_resolved(false),
+ d_self(),
+ d_involvesExt(false),
+ d_card(CardinalityUnknown()),
+ d_card_rec_singleton(0),
+ d_well_founded(0) {
+}
+
+inline Datatype::Datatype(std::string name, const std::vector<Type>& params, bool isCo) :
+ d_name(name),
+ d_params(params),
+ d_isCo(isCo),
+ d_constructors(),
+ d_resolved(false),
+ d_self(),
+ d_involvesExt(false),
+ d_card(CardinalityUnknown()),
+ d_card_rec_singleton(0),
+ d_well_founded(0) {
+}
+
+inline std::string Datatype::getName() const throw() {
+ return d_name;
+}
+
+inline size_t Datatype::getNumConstructors() const throw() {
+ return d_constructors.size();
+}
+
+inline bool Datatype::isParametric() const throw() {
+ return d_params.size() > 0;
+}
+
+inline size_t Datatype::getNumParameters() const throw() {
+ return d_params.size();
+}
+
+inline Type Datatype::getParameter( unsigned int i ) const {
+ CheckArgument(isParametric(), this, "cannot get type parameter of a non-parametric datatype");
+ CheckArgument(i < d_params.size(), i, "type parameter index out of range for datatype");
+ return d_params[i];
+}
+
+inline std::vector<Type> Datatype::getParameters() const {
+ CheckArgument(isParametric(), this, "cannot get type parameters of a non-parametric datatype");
+ return d_params;
+}
+
+inline bool Datatype::isCodatatype() const {
+ return d_isCo;
+}
+
+inline bool Datatype::isSygus() const {
+ return !d_sygus_type.isNull();
+}
+
+inline bool Datatype::operator!=(const Datatype& other) const throw() {
+ return !(*this == other);
+}
+
+inline bool Datatype::isResolved() const throw() {
+ return d_resolved;
+}
+
+inline Datatype::iterator Datatype::begin() throw() {
+ return iterator(d_constructors, true);
+}
+
+inline Datatype::iterator Datatype::end() throw() {
+ return iterator(d_constructors, false);
+}
+
+inline Datatype::const_iterator Datatype::begin() const throw() {
+ return const_iterator(d_constructors, true);
+}
+
+inline Datatype::const_iterator Datatype::end() const throw() {
+ return const_iterator(d_constructors, false);
+}
+
+inline bool DatatypeConstructor::isResolved() const throw() {
+ return !d_tester.isNull();
+}
+
+inline size_t DatatypeConstructor::getNumArgs() const throw() {
+ return d_args.size();
+}
+
+inline bool DatatypeConstructorArg::isResolved() const throw() {
+ // We could just write:
+ //
+ // return !d_selector.isNull() && d_selector.getType().isSelector();
+ //
+ // HOWEVER, this causes problems in ExprManager tear-down, because
+ // the attributes are removed before the pool is purged. When the
+ // pool is purged, this triggers an equality test between Datatypes,
+ // and this triggers a call to isResolved(), which breaks because
+ // d_selector has no type after attributes are stripped.
+ //
+ // This problem, coupled with the fact that this function is called
+ // _often_, means we should just use a boolean flag.
+ //
+ return d_resolved;
+}
+
+inline DatatypeConstructor::iterator DatatypeConstructor::begin() throw() {
+ return iterator(d_args, true);
+}
+
+inline DatatypeConstructor::iterator DatatypeConstructor::end() throw() {
+ return iterator(d_args, false);
+}
+
+inline DatatypeConstructor::const_iterator DatatypeConstructor::begin() const throw() {
+ return const_iterator(d_args, true);
+}
+
+inline DatatypeConstructor::const_iterator DatatypeConstructor::end() const throw() {
+ return const_iterator(d_args, false);
+}
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__DATATYPE_H */
--- /dev/null
+%{
+#include "expr/datatype.h"
+
+#ifdef SWIGJAVA
+
+#include "bindings/java_iterator_adapter.h"
+#include "bindings/java_stream_adapters.h"
+
+#endif /* SWIGJAVA */
+%}
+
+%extend std::vector< CVC4::Datatype > {
+ /* These member functions have slightly different signatures in
+ * different swig language packages. The underlying issue is that
+ * DatatypeConstructor doesn't have a default constructor */
+#if defined(SWIGOCAML) || defined(SWIGPERL) || defined(SWIGTCL)
+ %ignore vector(unsigned int size = 0);
+ %ignore set( int i, const CVC4::Datatype &x );
+ %ignore to_array();
+#endif /* SWIGOCAML || SWIGPERL || SWIGTCL */
+ %ignore vector(size_type);// java/python/perl/others?
+ %ignore resize(size_type);// java/python/perl/others?
+ %ignore set(int i, const CVC4::Datatype& x);
+ %ignore to_array();
+};
+%template(vectorDatatype) std::vector< CVC4::Datatype >;
+
+%extend std::vector< CVC4::DatatypeConstructor > {
+ /* These member functions have slightly different signatures in
+ * different swig language packages. The underlying issue is that
+ * DatatypeConstructor doesn't have a default constructor */
+#if defined(SWIGOCAML) || defined(SWIGPERL) || defined(SWIGTCL)
+ %ignore vector(unsigned int size = 0);
+ %ignore set( int i, const CVC4::DatatypeConstructor &x );
+ %ignore to_array();
+#endif /* SWIGOCAML || SWIGPERL || SWIGTCL */
+ %ignore vector(size_type);// java/python/perl/others?
+ %ignore resize(size_type);// java/python/perl/others?
+ %ignore set(int i, const CVC4::Datatype::Constructor& x);
+ %ignore to_array();
+};
+//%template(vectorDatatypeConstructor) std::vector< CVC4::DatatypeConstructor >;
+
+%rename(equals) CVC4::Datatype::operator==(const Datatype&) const;
+%ignore CVC4::Datatype::operator!=(const Datatype&) const;
+
+%ignore CVC4::Datatype::begin();
+%ignore CVC4::Datatype::end();
+%ignore CVC4::Datatype::begin() const;
+%ignore CVC4::Datatype::end() const;
+
+%rename(get) CVC4::Datatype::operator[](size_t) const;
+%rename(get) CVC4::Datatype::operator[](std::string) const;
+
+%rename(apply) CVC4::DatatypeHashFunction::operator()(const Datatype&) const;
+%ignore CVC4::DatatypeHashFunction::operator()(const Datatype*) const;
+%rename(apply) CVC4::DatatypeHashFunction::operator()(const DatatypeConstructor&) const;
+%ignore CVC4::DatatypeHashFunction::operator()(const DatatypeConstructor*) const;
+
+%ignore CVC4::DatatypeConstructor::begin();
+%ignore CVC4::DatatypeConstructor::end();
+%ignore CVC4::DatatypeConstructor::begin() const;
+%ignore CVC4::DatatypeConstructor::end() const;
+
+%rename(get) CVC4::DatatypeConstructor::operator[](size_t) const;
+%rename(get) CVC4::DatatypeConstructor::operator[](std::string) const;
+
+%ignore CVC4::operator<<(std::ostream&, const Datatype&);
+%ignore CVC4::operator<<(std::ostream&, const DatatypeConstructor&);
+%ignore CVC4::operator<<(std::ostream&, const DatatypeConstructorArg&);
+
+%ignore CVC4::DatatypeConstructorIterator;
+%ignore CVC4::DatatypeConstructorArgIterator;
+
+%feature("valuewrapper") CVC4::DatatypeUnresolvedType;
+%feature("valuewrapper") CVC4::DatatypeConstructor;
+
+#ifdef SWIGJAVA
+
+// Instead of Datatype::begin() and end(), create an
+// iterator() method on the Java side that returns a Java-style
+// Iterator.
+%extend CVC4::Datatype {
+ CVC4::JavaIteratorAdapter<CVC4::Datatype> iterator() {
+ return CVC4::JavaIteratorAdapter<CVC4::Datatype>(*$self);
+ }
+
+ std::string toString() const {
+ std::stringstream ss;
+ ss << *$self;
+ return ss.str();
+ }
+}
+%extend CVC4::DatatypeConstructor {
+ CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor> iterator() {
+ return CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor>(*$self);
+ }
+
+ std::string toString() const {
+ std::stringstream ss;
+ ss << *$self;
+ return ss.str();
+ }
+}
+%extend CVC4::DatatypeConstructorArg {
+ std::string toString() const {
+ std::stringstream ss;
+ ss << *$self;
+ return ss.str();
+ }
+}
+
+// Datatype is "iterable" on the Java side
+%typemap(javainterfaces) CVC4::Datatype "java.lang.Iterable<DatatypeConstructor>";
+%typemap(javainterfaces) CVC4::DatatypeConstructor "java.lang.Iterable<DatatypeConstructorArg>";
+
+// the JavaIteratorAdapter should not be public, and implements Iterator
+%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::Datatype> "class";
+%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor> "class";
+%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::Datatype> "java.util.Iterator<DatatypeConstructor>";
+%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor> "java.util.Iterator<DatatypeConstructorArg>";
+// add some functions to the Java side (do it here because there's no way to do these in C++)
+%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::Datatype> "
+ public void remove() {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ public DatatypeConstructor next() {
+ if(hasNext()) {
+ return getNext();
+ } else {
+ throw new java.util.NoSuchElementException();
+ }
+ }
+"
+%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor> "
+ public void remove() {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ public DatatypeConstructorArg next() {
+ if(hasNext()) {
+ return getNext();
+ } else {
+ throw new java.util.NoSuchElementException();
+ }
+ }
+"
+// getNext() just allows C++ iterator access from Java-side next(), make it private
+%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::Datatype>::getNext() "private";
+%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor>::getNext() "private";
+
+// map the types appropriately.
+%typemap(jni) CVC4::Datatype::iterator::value_type "jobject";
+%typemap(jtype) CVC4::Datatype::iterator::value_type "edu.nyu.acsys.CVC4.DatatypeConstructor";
+%typemap(jstype) CVC4::Datatype::iterator::value_type "edu.nyu.acsys.CVC4.DatatypeConstructor";
+%typemap(javaout) CVC4::Datatype::iterator::value_type { return $jnicall; }
+%typemap(jni) CVC4::DatatypeConstructor::iterator::value_type "jobject";
+%typemap(jtype) CVC4::DatatypeConstructor::iterator::value_type "edu.nyu.acsys.CVC4.DatatypeConstructorArg";
+%typemap(jstype) CVC4::DatatypeConstructor::iterator::value_type "edu.nyu.acsys.CVC4.DatatypeConstructorArg";
+%typemap(javaout) CVC4::DatatypeConstructor::iterator::value_type { return $jnicall; }
+
+#endif /* SWIGJAVA */
+
+%include "expr/datatype.h"
+
+#ifdef SWIGJAVA
+
+%include "bindings/java_iterator_adapter.h"
+%include "bindings/java_stream_adapters.h"
+
+%template(JavaIteratorAdapter_Datatype) CVC4::JavaIteratorAdapter<CVC4::Datatype>;
+%template(JavaIteratorAdapter_DatatypeConstructor) CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor>;
+
+#endif /* SWIGJAVA */
--- /dev/null
+/********************* */
+/*! \file emptyset.cpp
+ ** \verbatim
+ ** Original author: Kshitij Bansal
+ ** 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 "expr/emptyset.h"
+
+#include <iostream>
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, const EmptySet& asa) {
+ return out << "emptyset(" << asa.getType() << ')';
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file emptyset.h
+ ** \verbatim
+ ** Original author: Kshitij Bansal
+ ** 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 ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "cvc4_public.h"
+
+#pragma once
+
+namespace CVC4 {
+ // messy; Expr needs EmptySet (because it's the payload of a
+ // CONSTANT-kinded expression), and EmptySet needs Expr.
+ class CVC4_PUBLIC EmptySet;
+}/* CVC4 namespace */
+
+#include "expr/expr.h"
+#include "expr/type.h"
+#include <iostream>
+
+namespace CVC4 {
+
+class CVC4_PUBLIC EmptySet {
+
+ const SetType d_type;
+
+ EmptySet() { }
+public:
+
+ /**
+ * Constructs an emptyset of the specified type. Note that the argument
+ * is the type of the set itself, NOT the type of the elements.
+ */
+ EmptySet(SetType setType):d_type(setType) { }
+
+
+ ~EmptySet() throw() {
+ }
+
+ SetType getType() const { return d_type; }
+
+ bool operator==(const EmptySet& es) const throw() {
+ return d_type == es.d_type;
+ }
+ bool operator!=(const EmptySet& es) const throw() {
+ return !(*this == es);
+ }
+
+ bool operator<(const EmptySet& es) const throw() {
+ return d_type < es.d_type;
+ }
+ bool operator<=(const EmptySet& es) const throw() {
+ return d_type <= es.d_type;
+ }
+ bool operator>(const EmptySet& es) const throw() {
+ return !(*this <= es);
+ }
+ bool operator>=(const EmptySet& es) const throw() {
+ return !(*this < es);
+ }
+
+};/* class EmptySet */
+
+std::ostream& operator<<(std::ostream& out, const EmptySet& es) CVC4_PUBLIC;
+
+struct CVC4_PUBLIC EmptySetHashFunction {
+ inline size_t operator()(const EmptySet& es) const {
+ return TypeHashFunction()(es.getType());
+ }
+};/* struct EmptySetHashFunction */
+
+}/* CVC4 namespace */
--- /dev/null
+%{
+#include "expr/emptyset.h"
+%}
+
+%rename(equals) CVC4::EmptySet::operator==(const EmptySet&) const;
+%ignore CVC4::EmptySet::operator!=(const EmptySet&) const;
+
+%rename(less) CVC4::EmptySet::operator<(const EmptySet&) const;
+%rename(lessEqual) CVC4::EmptySet::operator<=(const EmptySet&) const;
+%rename(greater) CVC4::EmptySet::operator>(const EmptySet&) const;
+%rename(greaterEqual) CVC4::EmptySet::operator>=(const EmptySet&) const;
+
+%rename(apply) CVC4::EmptySetHashFunction::operator()(const EmptySet&) const;
+
+%ignore CVC4::operator<<(std::ostream& out, const EmptySet& es);
+
+%include "expr/emptyset.h"
** 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
#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}
// 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 {
** 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>
#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 {
${getConst_instantiations}
-#line 938 "${template}"
+#line 939 "${template}"
namespace expr {
#include <iostream>
#include <sstream>
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
namespace kind {
--- /dev/null
+/********************* */
+/*! \file matcher.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 A class representing a type matcher
+ **
+ ** A class representing a type matcher.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__MATCHER_H
+#define __CVC4__MATCHER_H
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <map>
+
+#include "base/cvc4_assert.h"
+#include "expr/node.h"
+#include "expr/type_node.h"
+
+namespace CVC4 {
+
+class Matcher {
+private:
+ std::vector< TypeNode > d_types;
+ std::vector< TypeNode > d_match;
+public:
+ Matcher(){}
+ Matcher( DatatypeType dt ){
+ addTypesFromDatatype( dt );
+ }
+ ~Matcher(){}
+
+ void addTypesFromDatatype( DatatypeType dt ){
+ std::vector< Type > argTypes = dt.getParamTypes();
+ addTypes( argTypes );
+ Debug("typecheck-idt") << "instantiating matcher for " << dt << std::endl;
+ for(unsigned i = 0; i < argTypes.size(); ++i) {
+ if(dt.isParameterInstantiated(i)) {
+ Debug("typecheck-idt") << "++ instantiate param " << i << " : " << d_types[i] << std::endl;
+ d_match[i] = d_types[i];
+ }
+ }
+ }
+ void addType( Type t ){
+ d_types.push_back( TypeNode::fromType( t ) );
+ d_match.push_back( TypeNode::null() );
+ }
+ void addTypes( std::vector< Type > types ){
+ for( int i=0; i<(int)types.size(); i++ ){
+ addType( types[i] );
+ }
+ }
+
+ bool doMatching( TypeNode pattern, TypeNode tn ){
+ Debug("typecheck-idt") << "doMatching() : " << pattern << " : " << tn << std::endl;
+ std::vector< TypeNode >::iterator i = std::find( d_types.begin(), d_types.end(), pattern );
+ if( i!=d_types.end() ){
+ int index = i - d_types.begin();
+ if( !d_match[index].isNull() ){
+ Debug("typecheck-idt") << "check subtype " << tn << " " << d_match[index] << std::endl;
+ TypeNode tnn = TypeNode::leastCommonTypeNode( tn, d_match[index] );
+ //recognize subtype relation
+ if( !tnn.isNull() ){
+ d_match[index] = tnn;
+ return true;
+ }else{
+ return false;
+ }
+ }else{
+ d_match[ i - d_types.begin() ] = tn;
+ return true;
+ }
+ }else if( pattern==tn ){
+ return true;
+ }else if( pattern.getKind()!=tn.getKind() || pattern.getNumChildren()!=tn.getNumChildren() ){
+ return false;
+ }else{
+ for( int i=0; i<(int)pattern.getNumChildren(); i++ ){
+ if( !doMatching( pattern[i], tn[i] ) ){
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ TypeNode getMatch( unsigned int i ){ return d_match[i]; }
+ void getTypes( std::vector<Type>& types ) {
+ types.clear();
+ for( int i=0; i<(int)d_match.size(); i++ ){
+ types.push_back( d_types[i].toType() );
+ }
+ }
+ void getMatches( std::vector<Type>& types ) {
+ types.clear();
+ for( int i=0; i<(int)d_match.size(); i++ ){
+ if(d_match[i].isNull()) {
+ types.push_back( d_types[i].toType() );
+ } else {
+ types.push_back( d_match[i].toType() );
+ }
+ }
+ }
+};/* class Matcher */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__MATCHER_H */
#include <iostream>
+#include "base/cvc4_assert.h"
#include "expr/kind.h"
-#include "util/cvc4_assert.h"
namespace CVC4 {
**
** 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 {
#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"
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 {
#include "expr/node.h"
#include "expr/node_manager.h"
-#include "expr/options.h"
+#include "options/expr_options.h"
namespace CVC4 {
**
** 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;
#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 {
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";
}
#include <iterator>
-#include "util/cvc4_assert.h"
+#include "base/cvc4_assert.h"
#include "expr/node.h"
namespace CVC4 {
** 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;
#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 {
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module EXPR "expr/options.h" Expression package
-
-option defaultExprDepth --default-expr-depth=N int :default 0 :predicate CVC4::expr::setDefaultExprDepth :predicate-include "expr/options_handlers.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"
- 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"
- print types with variables when printing exprs
-
-option earlyTypeChecking --eager-type-checking/--lazy-type-checking bool :default USE_EARLY_TYPE_CHECKING_BY_DEFAULT
- type check expressions immediately on creation (debug builds only)
-/type check expressions only when necessary (default)
-
-# --no-type-checking will override any --early-type-checking or --lazy-type-checking option
-# --lazy-type-checking is linked because earlyTypeChecking should be set false too
-option typeChecking /--no-type-checking bool :default DO_SEMANTIC_CHECKS_BY_DEFAULT :link /--lazy-type-checking
- never type check expressions
-
-option biasedITERemoval --biased-ites bool :default false
- try the new remove ite pass that is biased against term ites appearing
-
-endmodule
-
+++ /dev/null
-/********************* */
-/*! \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 */
#include <sstream>
#include <string>
+#include "base/cvc4_assert.h"
#include "expr/pickle_data.h"
#include "expr/expr.h"
#include "expr/node.h"
#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 <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"
#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 {
#include "expr/variable_type_map.h"
#include "expr/expr.h"
-#include "util/exception.h"
+#include "base/exception.h"
#include <exception>
#include <stack>
--- /dev/null
+/********************* */
+/*! \file predicate.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 Representation of predicates for predicate subtyping
+ **
+ ** Simple class to represent predicates for predicate subtyping.
+ ** 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"
+
+
+using namespace std;
+
+namespace CVC4 {
+
+Predicate::Predicate(Expr e, Expr w) throw(IllegalArgumentException) : d_predicate(e), d_witness(w) {
+ CheckArgument(! e.isNull(), e, "Predicate cannot be null");
+ CheckArgument(e.getType().isPredicate(), e, "Expression given is not predicate");
+ CheckArgument(FunctionType(e.getType()).getArgTypes().size() == 1, e, "Expression given is not predicate of a single argument");
+}
+
+Predicate::operator Expr() const {
+ return d_predicate;
+}
+
+bool Predicate::operator==(const Predicate& p) const {
+ return d_predicate == p.d_predicate && d_witness == p.d_witness;
+}
+
+std::ostream&
+operator<<(std::ostream& out, const Predicate& p) {
+ out << p.d_predicate;
+ if(! p.d_witness.isNull()) {
+ out << " : " << p.d_witness;
+ }
+ return out;
+}
+
+size_t PredicateHashFunction::operator()(const Predicate& p) const {
+ ExprHashFunction h;
+ return h(p.d_witness) * 5039 + h(p.d_predicate);
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file predicate.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 Representation of predicates for predicate subtyping
+ **
+ ** Simple class to represent predicates for predicate subtyping.
+ ** Instances of this class are carried as the payload of
+ ** the CONSTANT-metakinded SUBTYPE_TYPE types.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__PREDICATE_H
+#define __CVC4__PREDICATE_H
+
+#include "base/exception.h"
+
+namespace CVC4 {
+
+class Predicate;
+
+std::ostream& operator<<(std::ostream& out, const Predicate& p) CVC4_PUBLIC;
+
+struct CVC4_PUBLIC PredicateHashFunction {
+ size_t operator()(const Predicate& p) const;
+};/* class 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 {
+
+class CVC4_PUBLIC Predicate {
+
+ Expr d_predicate;
+ Expr d_witness;
+
+public:
+
+ Predicate(Expr e, Expr w = Expr()) throw(IllegalArgumentException);
+
+ operator Expr() const;
+
+ bool operator==(const Predicate& p) const;
+
+ friend std::ostream& CVC4::operator<<(std::ostream& out, const Predicate& p);
+ friend size_t PredicateHashFunction::operator()(const Predicate& p) const;
+
+};/* class Predicate */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__PREDICATE_H */
--- /dev/null
+%{
+#include "expr/predicate.h"
+%}
+
+%rename(equals) CVC4::Predicate::operator==(const Predicate&) const;
+%rename(toExpr) CVC4::Predicate::operator Expr() const;
+
+%rename(apply) CVC4::PredicateHashFunction::operator()(const Predicate&) const;
+
+%ignore CVC4::operator<<(std::ostream&, const Predicate&);
+
+%include "expr/predicate.h"
--- /dev/null
+/********************* */
+/*! \file record.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 A class representing a record definition
+ **
+ ** A class representing a record definition.
+ **/
+
+#include "expr/record.h"
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& os, const Record& r) {
+ os << "[# ";
+ bool first = true;
+ for(Record::iterator i = r.begin(); i != r.end(); ++i) {
+ if(!first) {
+ os << ", ";
+ }
+ os << (*i).first << ":" << (*i).second;
+ first = false;
+ }
+ os << " #]";
+
+ return os;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file record.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 A class representing a Record definition
+ **
+ ** A class representing a Record definition.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__RECORD_H
+#define __CVC4__RECORD_H
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <utility>
+#include "util/hash.h"
+
+namespace CVC4 {
+
+class CVC4_PUBLIC Record;
+
+// operators for record select and update
+
+class CVC4_PUBLIC RecordSelect {
+ std::string d_field;
+public:
+ RecordSelect(const std::string& field) throw() : d_field(field) { }
+ std::string getField() const throw() { return d_field; }
+ bool operator==(const RecordSelect& t) const throw() { return d_field == t.d_field; }
+ bool operator!=(const RecordSelect& t) const throw() { return d_field != t.d_field; }
+};/* class RecordSelect */
+
+class CVC4_PUBLIC RecordUpdate {
+ std::string d_field;
+public:
+ RecordUpdate(const std::string& field) throw() : d_field(field) { }
+ std::string getField() const throw() { return d_field; }
+ bool operator==(const RecordUpdate& t) const throw() { return d_field == t.d_field; }
+ bool operator!=(const RecordUpdate& t) const throw() { return d_field != t.d_field; }
+};/* class RecordUpdate */
+
+struct CVC4_PUBLIC RecordSelectHashFunction {
+ inline size_t operator()(const RecordSelect& t) const {
+ return StringHashFunction()(t.getField());
+ }
+};/* struct RecordSelectHashFunction */
+
+struct CVC4_PUBLIC RecordUpdateHashFunction {
+ inline size_t operator()(const RecordUpdate& t) const {
+ return StringHashFunction()(t.getField());
+ }
+};/* struct RecordUpdateHashFunction */
+
+std::ostream& operator<<(std::ostream& out, const RecordSelect& t) CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream& out, const RecordUpdate& t) CVC4_PUBLIC;
+
+inline std::ostream& operator<<(std::ostream& out, const RecordSelect& t) {
+ return out << "[" << t.getField() << "]";
+}
+
+inline std::ostream& operator<<(std::ostream& out, const RecordUpdate& t) {
+ return out << "[" << t.getField() << "]";
+}
+
+}/* CVC4 namespace */
+
+#warning "TODO: Address circular dependence in Record."
+#include "expr/expr.h"
+#include "expr/type.h"
+
+namespace CVC4 {
+
+// now an actual record definition
+
+class CVC4_PUBLIC Record {
+ std::vector< std::pair<std::string, Type> > d_fields;
+
+public:
+
+ typedef std::vector< std::pair<std::string, Type> >::const_iterator const_iterator;
+ typedef const_iterator iterator;
+
+ Record(const std::vector< std::pair<std::string, Type> >& fields) :
+ d_fields(fields) {
+ }
+
+ const_iterator find(std::string name) const {
+ const_iterator i;
+ for(i = begin(); i != end(); ++i) {
+ if((*i).first == name) {
+ break;
+ }
+ }
+ return i;
+ }
+
+ size_t getIndex(std::string name) const {
+ const_iterator i = find(name);
+ CheckArgument(i != end(), name, "requested field `%s' does not exist in record", name.c_str());
+ return i - begin();
+ }
+
+ size_t getNumFields() const {
+ return d_fields.size();
+ }
+
+ const_iterator begin() const {
+ return d_fields.begin();
+ }
+
+ const_iterator end() const {
+ return d_fields.end();
+ }
+
+ std::pair<std::string, Type> operator[](size_t index) const {
+ CheckArgument(index < d_fields.size(), index, "index out of bounds for record type");
+ return d_fields[index];
+ }
+
+ bool operator==(const Record& r) const {
+ return d_fields == r.d_fields;
+ }
+
+ bool operator!=(const Record& r) const {
+ return !(*this == r);
+ }
+
+};/* class Record */
+
+struct CVC4_PUBLIC RecordHashFunction {
+ inline size_t operator()(const Record& r) const {
+ size_t n = 0;
+ for(Record::iterator i = r.begin(); i != r.end(); ++i) {
+ n = (n << 3) ^ TypeHashFunction()((*i).second);
+ }
+ return n;
+ }
+};/* struct RecordHashFunction */
+
+std::ostream& operator<<(std::ostream& os, const Record& r) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__RECORD_H */
--- /dev/null
+%{
+#include "expr/record.h"
+
+#ifdef SWIGJAVA
+
+#include "bindings/java_iterator_adapter.h"
+#include "bindings/java_stream_adapters.h"
+
+#endif /* SWIGJAVA */
+%}
+
+%rename(equals) CVC4::RecordSelect::operator==(const RecordSelect&) const;
+%ignore CVC4::RecordSelect::operator!=(const RecordSelect&) const;
+
+%rename(equals) CVC4::RecordUpdate::operator==(const RecordUpdate&) const;
+%ignore CVC4::RecordUpdate::operator!=(const RecordUpdate&) const;
+
+%rename(equals) CVC4::Record::operator==(const Record&) const;
+%ignore CVC4::Record::operator!=(const Record&) const;
+%rename(getField) CVC4::Record::operator[](size_t) const;
+
+%rename(apply) CVC4::RecordHashFunction::operator()(const Record&) const;
+%rename(apply) CVC4::RecordSelectHashFunction::operator()(const RecordSelect&) const;
+%rename(apply) CVC4::RecordUpdateHashFunction::operator()(const RecordUpdate&) const;
+
+%ignore CVC4::operator<<(std::ostream&, const Record&);
+%ignore CVC4::operator<<(std::ostream&, const RecordSelect&);
+%ignore CVC4::operator<<(std::ostream&, const RecordUpdate&);
+
+#ifdef SWIGJAVA
+
+// These Object arrays are always of two elements, the first is a String and the second a
+// Type. (On the C++ side, it is a std::pair<std::string, Type>.)
+%typemap(jni) std::pair<std::string, CVC4::Type> "jobjectArray";
+%typemap(jtype) std::pair<std::string, CVC4::Type> "java.lang.Object[]";
+%typemap(jstype) std::pair<std::string, CVC4::Type> "java.lang.Object[]";
+%typemap(javaout) std::pair<std::string, CVC4::Type> { return $jnicall; }
+%typemap(out) std::pair<std::string, CVC4::Type> {
+ $result = jenv->NewObjectArray(2, jenv->FindClass("java/lang/Object"), $null);
+ jenv->SetObjectArrayElement($result, 0, jenv->NewStringUTF($1.first.c_str()));
+ jclass clazz = jenv->FindClass("edu/nyu/acsys/CVC4/Type");
+ jmethodID methodid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
+ jenv->SetObjectArrayElement($result, 1, jenv->NewObject(clazz, methodid, reinterpret_cast<long>(new CVC4::Type($1.second)), true));
+ };
+
+// Instead of Record::begin() and end(), create an
+// iterator() method on the Java side that returns a Java-style
+// Iterator.
+%ignore CVC4::Record::begin() const;
+%ignore CVC4::Record::end() const;
+%extend CVC4::Record {
+ CVC4::Type find(std::string name) const {
+ CVC4::Record::const_iterator i;
+ for(i = $self->begin(); i != $self->end(); ++i) {
+ if((*i).first == name) {
+ return (*i).second;
+ }
+ }
+ return CVC4::Type();
+ }
+
+ CVC4::JavaIteratorAdapter<CVC4::Record> iterator() {
+ return CVC4::JavaIteratorAdapter<CVC4::Record>(*$self);
+ }
+}
+
+// Record is "iterable" on the Java side
+%typemap(javainterfaces) CVC4::Record "java.lang.Iterable<Object[]>";
+
+// the JavaIteratorAdapter should not be public, and implements Iterator
+%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::Record> "class";
+%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::Record> "java.util.Iterator<Object[]>";
+// add some functions to the Java side (do it here because there's no way to do these in C++)
+%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::Record> "
+ public void remove() {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ public Object[] next() {
+ if(hasNext()) {
+ return getNext();
+ } else {
+ throw new java.util.NoSuchElementException();
+ }
+ }
+"
+// getNext() just allows C++ iterator access from Java-side next(), make it private
+%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::Record>::getNext() "private";
+
+// map the types appropriately. for records, the "payload" of the iterator is an Object[].
+// These Object arrays are always of two elements, the first is a String and the second a
+// Type. (On the C++ side, it is a std::pair<std::string, SExpr>.)
+%typemap(jni) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
+%typemap(jtype) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
+%typemap(jstype) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
+%typemap(javaout) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
+%typemap(out) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
+
+#endif /* SWIGJAVA */
+
+%include "expr/record.h"
+
+#ifdef SWIGJAVA
+
+%include "bindings/java_iterator_adapter.h"
+%include "bindings/java_stream_adapters.h"
+
+%template(JavaIteratorAdapter_Record) CVC4::JavaIteratorAdapter<CVC4::Record>;
+
+#endif /* SWIGJAVA */
--- /dev/null
+/********************* */
+/*! \file resource_manager.cpp
+** \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 Manages and updates various resource and time limits.
+**
+** Manages and updates various resource and time limits.
+**/
+#include "expr/resource_manager.h"
+
+#include "base/output.h"
+#include "options/smt_options.h"
+#include "smt/smt_engine_scope.h"
+#include "theory/rewriter.h"
+
+#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;
+ // keep track of when it was set, even if it's disabled (i.e. == 0)
+ d_wall_time = wallTime;
+ if (d_wall_time) {
+ // Wall time
+ gettimeofday(&d_wall_limit, NULL);
+ Trace("limit") << "Timer::set(): it's " << d_wall_limit.tv_sec << "," << d_wall_limit.tv_usec << std::endl;
+ d_wall_limit.tv_sec += millis / 1000;
+ d_wall_limit.tv_usec += (millis % 1000) * 1000;
+ if(d_wall_limit.tv_usec > 1000000) {
+ ++d_wall_limit.tv_sec;
+ d_wall_limit.tv_usec -= 1000000;
+ }
+ Trace("limit") << "Timer::set(): limit is at " << d_wall_limit.tv_sec << "," << d_wall_limit.tv_usec << std::endl;
+ } else {
+ // CPU time
+ d_cpu_start_time = ((double)clock())/(CLOCKS_PER_SEC *0.001);
+ d_cpu_limit = d_cpu_start_time + d_ms;
+ }
+}
+
+/** Return the milliseconds elapsed since last set(). */
+uint64_t Timer::elapsedWall() const {
+ Assert (d_wall_time);
+ timeval tv;
+ gettimeofday(&tv, NULL);
+ Trace("limit") << "Timer::elapsedWallTime(): it's now " << tv.tv_sec << "," << tv.tv_usec << std::endl;
+ tv.tv_sec -= d_wall_limit.tv_sec - d_ms / 1000;
+ tv.tv_usec -= d_wall_limit.tv_usec - (d_ms % 1000) * 1000;
+ Trace("limit") << "Timer::elapsedWallTime(): elapsed time is " << tv.tv_sec << "," << tv.tv_usec << std::endl;
+ return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+}
+
+uint64_t Timer::elapsedCPU() const {
+ Assert (!d_wall_time);
+ clock_t elapsed = ((double)clock())/(CLOCKS_PER_SEC *0.001)- d_cpu_start_time;
+ Trace("limit") << "Timer::elapsedCPUTime(): elapsed time is " << elapsed << " ms" <<std::endl;
+ return elapsed;
+}
+
+uint64_t Timer::elapsed() const {
+ if (d_wall_time)
+ return elapsedWall();
+ return elapsedCPU();
+}
+
+bool Timer::expired() const {
+ if (!on()) return false;
+
+ if (d_wall_time) {
+ timeval tv;
+ gettimeofday(&tv, NULL);
+ Debug("limit") << "Timer::expired(): current wall time is " << tv.tv_sec << "," << tv.tv_usec << std::endl;
+ Debug("limit") << "Timer::expired(): limit wall time is " << d_wall_limit.tv_sec << "," << d_wall_limit.tv_usec << std::endl;
+ if(d_wall_limit.tv_sec < tv.tv_sec ||
+ (d_wall_limit.tv_sec == tv.tv_sec && d_wall_limit.tv_usec <= tv.tv_usec)) {
+ Debug("limit") << "Timer::expired(): OVER LIMIT!" << std::endl;
+ return true;
+ }
+ Debug("limit") << "Timer::expired(): within limit" << std::endl;
+ return false;
+ }
+
+ // cpu time
+ double current = ((double)clock())/(CLOCKS_PER_SEC*0.001);
+ Debug("limit") << "Timer::expired(): current cpu time is " << current << std::endl;
+ Debug("limit") << "Timer::expired(): limit cpu time is " << d_cpu_limit << std::endl;
+ if (current >= d_cpu_limit) {
+ Debug("limit") << "Timer::expired(): OVER LIMIT!" << current << std::endl;
+ return true;
+ }
+ return false;
+}
+
+const uint64_t ResourceManager::s_resourceCount = 1000;
+
+ResourceManager::ResourceManager()
+ : d_cumulativeTimer()
+ , d_perCallTimer()
+ , d_timeBudgetCumulative(0)
+ , d_timeBudgetPerCall(0)
+ , d_resourceBudgetCumulative(0)
+ , d_resourceBudgetPerCall(0)
+ , d_cumulativeTimeUsed(0)
+ , d_cumulativeResourceUsed(0)
+ , d_thisCallResourceUsed(0)
+ , d_thisCallTimeBudget(0)
+ , d_thisCallResourceBudget(0)
+ , d_isHardLimit()
+ , d_on(false)
+ , d_cpuTime(false)
+ , d_spendResourceCalls(0)
+{}
+
+
+void ResourceManager::setResourceLimit(uint64_t units, bool cumulative) {
+ d_on = true;
+ if(cumulative) {
+ Trace("limit") << "ResourceManager: setting cumulative resource limit to " << units << endl;
+ d_resourceBudgetCumulative = (units == 0) ? 0 : (d_cumulativeResourceUsed + units);
+ d_thisCallResourceBudget = d_resourceBudgetCumulative;
+ } else {
+ Trace("limit") << "ResourceManager: setting per-call resource limit to " << units << endl;
+ d_resourceBudgetPerCall = units;
+ }
+}
+
+void ResourceManager::setTimeLimit(uint64_t millis, bool cumulative) {
+ d_on = true;
+ if(cumulative) {
+ Trace("limit") << "ResourceManager: setting cumulative time limit to " << millis << " ms" << endl;
+ d_timeBudgetCumulative = (millis == 0) ? 0 : (d_cumulativeTimeUsed + millis);
+ d_cumulativeTimer.set(millis, !d_cpuTime);
+ } else {
+ Trace("limit") << "ResourceManager: setting per-call time limit to " << millis << " ms" << endl;
+ d_timeBudgetPerCall = millis;
+ // perCall timer will be set in beginCall
+ }
+
+}
+
+uint64_t ResourceManager::getResourceUsage() const {
+ return d_cumulativeResourceUsed;
+}
+
+uint64_t ResourceManager::getTimeUsage() const {
+ if (d_timeBudgetCumulative) {
+ return d_cumulativeTimer.elapsed();
+ }
+ return d_cumulativeTimeUsed;
+}
+
+uint64_t ResourceManager::getResourceRemaining() const {
+ if (d_thisCallResourceBudget <= d_thisCallResourceUsed)
+ return 0;
+ return d_thisCallResourceBudget - d_thisCallResourceUsed;
+}
+
+uint64_t ResourceManager::getTimeRemaining() const {
+ uint64_t time_passed = d_cumulativeTimer.elapsed();
+ if (time_passed >= d_thisCallTimeBudget)
+ return 0;
+ return d_thisCallTimeBudget - time_passed;
+}
+
+void ResourceManager::spendResource(unsigned ammount) throw (UnsafeInterruptException) {
+ ++d_spendResourceCalls;
+ d_cumulativeResourceUsed += ammount;
+ if (!d_on) return;
+
+ Debug("limit") << "ResourceManager::spendResource()" << std::endl;
+ d_thisCallResourceUsed += ammount;
+ if(out()) {
+ Trace("limit") << "ResourceManager::spendResource: interrupt!" << std::endl;
+ Trace("limit") << " on call " << d_spendResourceCalls << std::endl;
+ if (outOfTime()) {
+ Trace("limit") << "ResourceManager::spendResource: elapsed time" << d_cumulativeTimer.elapsed() << std::endl;
+ }
+
+ if (d_isHardLimit) {
+ if (smt::smtEngineInScope()) {
+ theory::Rewriter::clearCaches();
+ }
+ throw UnsafeInterruptException();
+ }
+
+ // interrupt it next time resources are checked
+ if (smt::smtEngineInScope()) {
+ smt::currentSmtEngine()->interrupt();
+ }
+ }
+}
+
+void ResourceManager::beginCall() {
+
+ d_perCallTimer.set(d_timeBudgetPerCall, !d_cpuTime);
+ d_thisCallResourceUsed = 0;
+ if (!d_on) return;
+
+ if (cumulativeLimitOn()) {
+ if (d_resourceBudgetCumulative) {
+ d_thisCallResourceBudget = d_resourceBudgetCumulative <= d_cumulativeResourceUsed ? 0 :
+ d_resourceBudgetCumulative - d_cumulativeResourceUsed;
+ }
+
+ if (d_timeBudgetCumulative) {
+
+ AlwaysAssert(d_cumulativeTimer.on());
+ // timer was on since the option was set
+ d_cumulativeTimeUsed = d_cumulativeTimer.elapsed();
+ d_thisCallTimeBudget = d_timeBudgetCumulative <= d_cumulativeTimeUsed? 0 :
+ d_timeBudgetCumulative - d_cumulativeTimeUsed;
+ d_cumulativeTimer.set(d_thisCallTimeBudget, d_cpuTime);
+ }
+ // we are out of resources so we shouldn't update the
+ // budget for this call to the per call budget
+ if (d_thisCallTimeBudget == 0 ||
+ d_thisCallResourceUsed == 0)
+ return;
+ }
+
+ if (perCallLimitOn()) {
+ // take min of what's left and per-call budget
+ if (d_resourceBudgetPerCall) {
+ d_thisCallResourceBudget = d_thisCallResourceBudget < d_resourceBudgetPerCall && d_thisCallResourceBudget != 0 ? d_thisCallResourceBudget : d_resourceBudgetPerCall;
+ }
+
+ if (d_timeBudgetPerCall) {
+ d_thisCallTimeBudget = d_thisCallTimeBudget < d_timeBudgetPerCall && d_thisCallTimeBudget != 0 ? d_thisCallTimeBudget : d_timeBudgetPerCall;
+ }
+ }
+}
+
+void ResourceManager::endCall() {
+ uint64_t usedInCall = d_perCallTimer.elapsed();
+ d_perCallTimer.set(0);
+ d_cumulativeTimeUsed += usedInCall;
+}
+
+bool ResourceManager::cumulativeLimitOn() const {
+ return d_timeBudgetCumulative || d_resourceBudgetCumulative;
+}
+
+bool ResourceManager::perCallLimitOn() const {
+ return d_timeBudgetPerCall || d_resourceBudgetPerCall;
+}
+
+bool ResourceManager::outOfResources() const {
+ // resource limiting not enabled
+ if (d_resourceBudgetPerCall == 0 &&
+ d_resourceBudgetCumulative == 0)
+ return false;
+
+ return getResourceRemaining() == 0;
+}
+
+bool ResourceManager::outOfTime() const {
+ if (d_timeBudgetPerCall == 0 &&
+ d_timeBudgetCumulative == 0)
+ return false;
+
+ return d_cumulativeTimer.expired() || d_perCallTimer.expired();
+}
+
+void ResourceManager::useCPUTime(bool cpu) {
+ Trace("limit") << "ResourceManager::useCPUTime("<< cpu <<")\n";
+ d_cpuTime = cpu;
+}
+
+void ResourceManager::setHardLimit(bool value) {
+ Trace("limit") << "ResourceManager::setHardLimit("<< value <<")\n";
+ d_isHardLimit = value;
+}
+
+void ResourceManager::enable(bool on) {
+ Trace("limit") << "ResourceManager::enable("<< on <<")\n";
+ d_on = on;
+}
+
+} /* namespace CVC4 */
--- /dev/null
+/********************* */
+/*! \file resource_manager.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 Manages and updates various resource and time limits
+**
+** Manages and updates various resource and time limits.
+**/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__RESOURCE_MANAGER_H
+#define __CVC4__RESOURCE_MANAGER_H
+
+#include <cstddef>
+#include <sys/time.h>
+
+#include "base/exception.h"
+#include "util/unsafe_interrupt_exception.h"
+
+namespace CVC4 {
+
+/**
+ * A helper class to keep track of a time budget and signal
+ * the PropEngine when the budget expires.
+ */
+class CVC4_PUBLIC Timer {
+
+ uint64_t d_ms;
+ timeval d_wall_limit;
+ clock_t d_cpu_start_time;
+ clock_t d_cpu_limit;
+
+ bool d_wall_time;
+
+ /** Return the milliseconds elapsed since last set() cpu time. */
+ uint64_t elapsedCPU() const;
+ /** Return the milliseconds elapsed since last set() wall time. */
+ uint64_t elapsedWall() const;
+
+public:
+
+ /** Construct a Timer. */
+ Timer()
+ : d_ms(0)
+ , d_cpu_start_time(0)
+ , d_cpu_limit(0)
+ , d_wall_time(true)
+ {}
+
+ /** Is the timer currently active? */
+ bool on() const {
+ return d_ms != 0;
+ }
+
+ /** Set a millisecond timer (0==off). */
+ void set(uint64_t millis, bool wall_time = true);
+ /** Return the milliseconds elapsed since last set() wall/cpu time
+ depending on d_wall_time*/
+ uint64_t elapsed() const;
+ bool expired() const;
+
+};/* class Timer */
+
+
+class CVC4_PUBLIC ResourceManager {
+
+ Timer d_cumulativeTimer;
+ Timer d_perCallTimer;
+
+ /** A user-imposed cumulative time budget, in milliseconds. 0 = no limit. */
+ uint64_t d_timeBudgetCumulative;
+ /** A user-imposed per-call time budget, in milliseconds. 0 = no limit. */
+ uint64_t d_timeBudgetPerCall;
+ /** A user-imposed cumulative resource budget. 0 = no limit. */
+ uint64_t d_resourceBudgetCumulative;
+ /** A user-imposed per-call resource budget. 0 = no limit. */
+ uint64_t d_resourceBudgetPerCall;
+
+ /** The number of milliseconds used. */
+ uint64_t d_cumulativeTimeUsed;
+ /** The amount of resource used. */
+ uint64_t d_cumulativeResourceUsed;
+
+ /** The ammount of resource used during this call. */
+ uint64_t d_thisCallResourceUsed;
+
+ /**
+ * The ammount of resource budget for this call (min between per call
+ * budget and left-over cumulative budget.
+ */
+ uint64_t d_thisCallTimeBudget;
+ uint64_t d_thisCallResourceBudget;
+
+ bool d_isHardLimit;
+ bool d_on;
+ bool d_cpuTime;
+ uint64_t d_spendResourceCalls;
+
+ /** Counter indicating how often to check resource manager in loops */
+ static const uint64_t s_resourceCount;
+
+public:
+
+ ResourceManager();
+
+ bool limitOn() const { return cumulativeLimitOn() || perCallLimitOn(); }
+ bool cumulativeLimitOn() const;
+ bool perCallLimitOn() const;
+
+ bool outOfResources() const;
+ bool outOfTime() const;
+ bool out() const { return d_on && (outOfResources() || outOfTime()); }
+
+ uint64_t getResourceUsage() const;
+ uint64_t getTimeUsage() const;
+ uint64_t getResourceRemaining() const;
+ uint64_t getTimeRemaining() const;
+
+ uint64_t getResourceBudgetForThisCall() {
+ return d_thisCallResourceBudget;
+ }
+
+ void spendResource(unsigned ammount) throw(UnsafeInterruptException);
+
+ void setHardLimit(bool value);
+ void setResourceLimit(uint64_t units, bool cumulative = false);
+ void setTimeLimit(uint64_t millis, bool cumulative = false);
+ void useCPUTime(bool cpu);
+
+ void enable(bool on);
+
+ /**
+ * Resets perCall limits to mark the start of a new call,
+ * updates budget for current call and starts the timer
+ */
+ void beginCall();
+
+ /**
+ * Marks the end of a SmtEngine check call, stops the per
+ * call timer, updates cumulative time used.
+ */
+ void endCall();
+
+ static uint64_t getFrequencyCount() { return s_resourceCount; }
+ friend class SmtEngine;
+};/* class ResourceManager */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__RESOURCE_MANAGER_H */
--- /dev/null
+%{
+#include "expr/resource_manager.h"
+%}
+
+%include "expr/resource_manager.h"
--- /dev/null
+/********************* */
+/*! \file result.cpp
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: none
+ ** Minor contributors (to current version): 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 Encapsulation of the result of a query.
+ **
+ ** Encapsulation of the result of a query.
+ **/
+#include "expr/result.h"
+
+#include <algorithm>
+#include <cctype>
+#include <iostream>
+#include <string>
+
+#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) :
+ d_sat(SAT_UNKNOWN),
+ d_validity(VALIDITY_UNKNOWN),
+ d_which(TYPE_NONE),
+ d_unknownExplanation(UNKNOWN_REASON),
+ d_inputName(inputName) {
+ string s = instr;
+ transform(s.begin(), s.end(), s.begin(), ::tolower);
+ if(s == "sat" || s == "satisfiable") {
+ d_which = TYPE_SAT;
+ d_sat = SAT;
+ } else if(s == "unsat" || s == "unsatisfiable") {
+ d_which = TYPE_SAT;
+ d_sat = UNSAT;
+ } else if(s == "valid") {
+ d_which = TYPE_VALIDITY;
+ d_validity = VALID;
+ } else if(s == "invalid") {
+ d_which = TYPE_VALIDITY;
+ d_validity = INVALID;
+ } else if(s == "incomplete") {
+ d_which = TYPE_SAT;
+ d_sat = SAT_UNKNOWN;
+ d_unknownExplanation = INCOMPLETE;
+ } else if(s == "timeout") {
+ d_which = TYPE_SAT;
+ d_sat = SAT_UNKNOWN;
+ d_unknownExplanation = TIMEOUT;
+ } else if(s == "resourceout") {
+ d_which = TYPE_SAT;
+ d_sat = SAT_UNKNOWN;
+ d_unknownExplanation = RESOURCEOUT;
+ } else if(s == "memout") {
+ d_which = TYPE_SAT;
+ d_sat = SAT_UNKNOWN;
+ d_unknownExplanation = MEMOUT;
+ } else if(s == "interrupted") {
+ d_which = TYPE_SAT;
+ d_sat = SAT_UNKNOWN;
+ d_unknownExplanation = INTERRUPTED;
+ } else if(s.size() >= 7 && s.compare(0, 7, "unknown") == 0) {
+ d_which = TYPE_SAT;
+ d_sat = SAT_UNKNOWN;
+ } else {
+ IllegalArgument(s, "expected satisfiability/validity result, "
+ "instead got `%s'", s.c_str());
+ }
+}
+
+bool Result::operator==(const Result& r) const throw() {
+ if(d_which != r.d_which) {
+ return false;
+ }
+ if(d_which == TYPE_SAT) {
+ return d_sat == r.d_sat &&
+ ( d_sat != SAT_UNKNOWN ||
+ d_unknownExplanation == r.d_unknownExplanation );
+ }
+ if(d_which == TYPE_VALIDITY) {
+ return d_validity == r.d_validity &&
+ ( d_validity != VALIDITY_UNKNOWN ||
+ d_unknownExplanation == r.d_unknownExplanation );
+ }
+ return false;
+}
+
+bool operator==(enum Result::Sat sr, const Result& r) throw() {
+ return r == sr;
+}
+
+bool operator==(enum Result::Validity vr, const Result& r) throw() {
+ return r == vr;
+}
+bool operator!=(enum Result::Sat s, const Result& r) throw(){
+ return !(s == r);
+}
+bool operator!=(enum Result::Validity v, const Result& r) throw(){
+ return !(v == r);
+}
+
+Result Result::asSatisfiabilityResult() const throw() {
+ if(d_which == TYPE_SAT) {
+ return *this;
+ }
+
+ if(d_which == TYPE_VALIDITY) {
+ switch(d_validity) {
+
+ case INVALID:
+ return Result(SAT, d_inputName);
+
+ case VALID:
+ return Result(UNSAT, d_inputName);
+
+ case VALIDITY_UNKNOWN:
+ return Result(SAT_UNKNOWN, d_unknownExplanation, d_inputName);
+
+ default:
+ Unhandled(d_validity);
+ }
+ }
+
+ // TYPE_NONE
+ return Result(SAT_UNKNOWN, NO_STATUS, d_inputName);
+}
+
+Result Result::asValidityResult() const throw() {
+ if(d_which == TYPE_VALIDITY) {
+ return *this;
+ }
+
+ if(d_which == TYPE_SAT) {
+ switch(d_sat) {
+
+ case SAT:
+ return Result(INVALID, d_inputName);
+
+ case UNSAT:
+ return Result(VALID, d_inputName);
+
+ case SAT_UNKNOWN:
+ return Result(VALIDITY_UNKNOWN, d_unknownExplanation, d_inputName);
+
+ default:
+ Unhandled(d_sat);
+ }
+ }
+
+ // TYPE_NONE
+ return Result(VALIDITY_UNKNOWN, NO_STATUS, d_inputName);
+}
+
+string Result::toString() const {
+ stringstream ss;
+ ss << *this;
+ return ss.str();
+}
+
+ostream& operator<<(ostream& out, enum Result::Sat s) {
+ switch(s) {
+ case Result::UNSAT: out << "UNSAT"; break;
+ case Result::SAT: out << "SAT"; break;
+ case Result::SAT_UNKNOWN: out << "SAT_UNKNOWN"; break;
+ default: Unhandled(s);
+ }
+ return out;
+}
+
+ostream& operator<<(ostream& out, enum Result::Validity v) {
+ switch(v) {
+ case Result::INVALID: out << "INVALID"; break;
+ case Result::VALID: out << "VALID"; break;
+ case Result::VALIDITY_UNKNOWN: out << "VALIDITY_UNKNOWN"; break;
+ default: Unhandled(v);
+ }
+ return out;
+}
+
+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;
+ case Result::TIMEOUT: out << "TIMEOUT"; break;
+ case Result::RESOURCEOUT: out << "RESOURCEOUT"; break;
+ case Result::MEMOUT: out << "MEMOUT"; break;
+ case Result::INTERRUPTED: out << "INTERRUPTED"; break;
+ case Result::NO_STATUS: out << "NO_STATUS"; break;
+ case Result::UNSUPPORTED: out << "UNSUPPORTED"; break;
+ case Result::OTHER: out << "OTHER"; break;
+ case Result::UNKNOWN_REASON: out << "UNKNOWN_REASON"; break;
+ default: Unhandled(e);
+ }
+ return out;
+}
+
+ostream& operator<<(ostream& out, const Result& 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 */
--- /dev/null
+/********************* */
+/*! \file result.h
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: none
+ ** Minor contributors (to current version): 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 Encapsulation of the result of a query.
+ **
+ ** Encapsulation of the result of a query.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__RESULT_H
+#define __CVC4__RESULT_H
+
+#include <iostream>
+#include <string>
+
+#include "base/exception.h"
+#include "options/language.h"
+
+namespace CVC4 {
+
+class Result;
+
+std::ostream& operator<<(std::ostream& out, const Result& r) CVC4_PUBLIC;
+
+/**
+ * Three-valued SMT result, with optional explanation.
+ */
+class CVC4_PUBLIC Result {
+public:
+ enum Sat {
+ UNSAT = 0,
+ SAT = 1,
+ SAT_UNKNOWN = 2
+ };
+
+ enum Validity {
+ INVALID = 0,
+ VALID = 1,
+ VALIDITY_UNKNOWN = 2
+ };
+
+ enum Type {
+ TYPE_SAT,
+ TYPE_VALIDITY,
+ TYPE_NONE
+ };
+
+ enum UnknownExplanation {
+ REQUIRES_FULL_CHECK,
+ INCOMPLETE,
+ TIMEOUT,
+ RESOURCEOUT,
+ MEMOUT,
+ INTERRUPTED,
+ NO_STATUS,
+ UNSUPPORTED,
+ OTHER,
+ UNKNOWN_REASON
+ };
+
+private:
+ enum Sat d_sat;
+ enum Validity d_validity;
+ enum Type d_which;
+ enum UnknownExplanation d_unknownExplanation;
+ std::string d_inputName;
+
+public:
+ Result() :
+ d_sat(SAT_UNKNOWN),
+ d_validity(VALIDITY_UNKNOWN),
+ d_which(TYPE_NONE),
+ d_unknownExplanation(UNKNOWN_REASON),
+ d_inputName("") {
+ }
+ Result(enum Sat s, std::string inputName = "") :
+ d_sat(s),
+ d_validity(VALIDITY_UNKNOWN),
+ d_which(TYPE_SAT),
+ d_unknownExplanation(UNKNOWN_REASON),
+ d_inputName(inputName) {
+ CheckArgument(s != SAT_UNKNOWN,
+ "Must provide a reason for satisfiability being unknown");
+ }
+ Result(enum Validity v, std::string inputName = "") :
+ d_sat(SAT_UNKNOWN),
+ d_validity(v),
+ d_which(TYPE_VALIDITY),
+ d_unknownExplanation(UNKNOWN_REASON),
+ d_inputName(inputName) {
+ CheckArgument(v != VALIDITY_UNKNOWN,
+ "Must provide a reason for validity being unknown");
+ }
+ Result(enum Sat s, enum UnknownExplanation unknownExplanation, std::string inputName = "") :
+ d_sat(s),
+ d_validity(VALIDITY_UNKNOWN),
+ d_which(TYPE_SAT),
+ d_unknownExplanation(unknownExplanation),
+ d_inputName(inputName) {
+ CheckArgument(s == SAT_UNKNOWN,
+ "improper use of unknown-result constructor");
+ }
+ Result(enum Validity v, enum UnknownExplanation unknownExplanation, std::string inputName = "") :
+ d_sat(SAT_UNKNOWN),
+ d_validity(v),
+ d_which(TYPE_VALIDITY),
+ d_unknownExplanation(unknownExplanation),
+ d_inputName(inputName) {
+ CheckArgument(v == VALIDITY_UNKNOWN,
+ "improper use of unknown-result constructor");
+ }
+ Result(const std::string& s, std::string inputName = "");
+
+ Result(const Result& r, std::string inputName) {
+ *this = r;
+ d_inputName = inputName;
+ }
+
+ enum Sat isSat() const {
+ return d_which == TYPE_SAT ? d_sat : SAT_UNKNOWN;
+ }
+ enum Validity isValid() const {
+ return d_which == TYPE_VALIDITY ? d_validity : VALIDITY_UNKNOWN;
+ }
+ bool isUnknown() const {
+ return isSat() == SAT_UNKNOWN && isValid() == VALIDITY_UNKNOWN;
+ }
+ Type getType() const {
+ return d_which;
+ }
+ bool isNull() const {
+ return d_which == TYPE_NONE;
+ }
+ enum UnknownExplanation whyUnknown() const {
+ CheckArgument( isUnknown(), this,
+ "This result is not unknown, so the reason for "
+ "being unknown cannot be inquired of it" );
+ return d_unknownExplanation;
+ }
+
+ bool operator==(const Result& r) const throw();
+ inline bool operator!=(const Result& r) const throw();
+ Result asSatisfiabilityResult() const throw();
+ Result asValidityResult() const throw();
+
+ std::string toString() const;
+
+ 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() {
+ return !(*this == r);
+}
+
+std::ostream& operator<<(std::ostream& out,
+ enum Result::Sat s) CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream& out,
+ enum Result::Validity v) CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream& out,
+ enum Result::UnknownExplanation e) CVC4_PUBLIC;
+
+bool operator==(enum Result::Sat s, const Result& r) throw() CVC4_PUBLIC;
+bool operator==(enum Result::Validity v, const Result& r) throw() CVC4_PUBLIC;
+
+bool operator!=(enum Result::Sat s, const Result& r) throw() CVC4_PUBLIC;
+bool operator!=(enum Result::Validity v, const Result& r) throw() CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__RESULT_H */
--- /dev/null
+%{
+#include "expr/result.h"
+%}
+
+%ignore CVC4::operator<<(std::ostream&, const Result& r);
+
+%rename(equals) CVC4::Result::operator==(const Result& r) const;
+%ignore CVC4::Result::operator!=(const Result& r) const;
+
+%ignore CVC4::operator<<(std::ostream&, enum Result::Sat);
+%ignore CVC4::operator<<(std::ostream&, enum Result::Validity);
+%ignore CVC4::operator<<(std::ostream&, enum Result::UnknownExplanation);
+
+%ignore CVC4::operator==(enum Result::Sat, const Result&);
+%ignore CVC4::operator!=(enum Result::Sat, const Result&);
+
+%ignore CVC4::operator==(enum Result::Validity, const Result&);
+%ignore CVC4::operator!=(enum Result::Validity, const Result&);
+
+%include "expr/result.h"
--- /dev/null
+/********************* */
+/*! \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 */
--- /dev/null
+/********************* */
+/*! \file sexpr.h
+ ** \verbatim
+ ** Original author: Christopher L. Conway
+ ** Major contributors: Tim King, Morgan Deters
+ ** Minor contributors (to current version): Dejan Jovanovic
+ ** 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.
+ ** These are used when a simple, and obvious interface for basic
+ ** expressions is appropraite.
+ **
+ ** These are quite ineffecient.
+ ** These are totally disconnected from any ExprManager.
+ ** These keep unique copies of all of their children.
+ ** These are VERY overly verbose and keep much more data than is needed.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__SEXPR_H
+#define __CVC4__SEXPR_H
+
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "base/exception.h"
+#include "options/language.h"
+#include "util/integer.h"
+#include "util/rational.h"
+
+namespace CVC4 {
+
+class CVC4_PUBLIC SExprKeyword {
+ std::string d_str;
+public:
+ SExprKeyword(const std::string& s) : d_str(s) {}
+ const std::string& getString() const { return d_str; }
+};/* class SExpr::Keyword */
+
+/**
+ * A simple S-expression. An S-expression is either an atom with a
+ * string value, or a list of other S-expressions.
+ */
+class CVC4_PUBLIC SExpr {
+
+ enum SExprTypes {
+ SEXPR_STRING,
+ SEXPR_KEYWORD,
+ SEXPR_INTEGER,
+ SEXPR_RATIONAL,
+ SEXPR_NOT_ATOM
+ } d_sexprType;
+
+ /** The value of an atomic integer-valued S-expression. */
+ CVC4::Integer d_integerValue;
+
+ /** The value of an atomic rational-valued S-expression. */
+ CVC4::Rational d_rationalValue;
+
+ /** The value of an atomic S-expression. */
+ std::string d_stringValue;
+
+ /** The children of a list S-expression. */
+ std::vector<SExpr> d_children;
+
+public:
+
+ typedef SExprKeyword Keyword;
+
+ SExpr() :
+ d_sexprType(SEXPR_STRING),
+ d_integerValue(0),
+ d_rationalValue(0),
+ d_stringValue(""),
+ d_children() {
+ }
+
+ SExpr(const CVC4::Integer& value) :
+ d_sexprType(SEXPR_INTEGER),
+ d_integerValue(value),
+ d_rationalValue(0),
+ d_stringValue(""),
+ d_children() {
+ }
+
+ SExpr(int value) :
+ d_sexprType(SEXPR_INTEGER),
+ d_integerValue(value),
+ d_rationalValue(0),
+ d_stringValue(""),
+ d_children() {
+ }
+
+ SExpr(long int value) :
+ d_sexprType(SEXPR_INTEGER),
+ d_integerValue(value),
+ d_rationalValue(0),
+ d_stringValue(""),
+ d_children() {
+ }
+
+ SExpr(unsigned int value) :
+ d_sexprType(SEXPR_INTEGER),
+ d_integerValue(value),
+ d_rationalValue(0),
+ d_stringValue(""),
+ d_children() {
+ }
+
+ SExpr(unsigned long int value) :
+ d_sexprType(SEXPR_INTEGER),
+ d_integerValue(value),
+ d_rationalValue(0),
+ d_stringValue(""),
+ d_children() {
+ }
+
+ SExpr(const CVC4::Rational& value) :
+ d_sexprType(SEXPR_RATIONAL),
+ d_integerValue(0),
+ d_rationalValue(value),
+ d_stringValue(""),
+ d_children() {
+ }
+
+ SExpr(const std::string& value) :
+ d_sexprType(SEXPR_STRING),
+ d_integerValue(0),
+ d_rationalValue(0),
+ d_stringValue(value),
+ d_children() {
+ }
+
+ /**
+ * This constructs a string expression from a const char* value.
+ * This cannot be removed in order to support SExpr("foo").
+ * Given the other constructors this SExpr("foo") converts to bool.
+ * instead of SExpr(string("foo")).
+ */
+ SExpr(const char* value) :
+ d_sexprType(SEXPR_STRING),
+ d_integerValue(0),
+ d_rationalValue(0),
+ d_stringValue(value),
+ d_children() {
+ }
+
+ /**
+ * This adds a convenience wrapper to SExpr to cast from bools.
+ * This is internally handled as the strings "true" and "false"
+ */
+ SExpr(bool value) :
+#warning "TODO: Discuss this change with Clark."
+ d_sexprType(SEXPR_KEYWORD),
+ d_integerValue(0),
+ d_rationalValue(0),
+ d_stringValue(value ? "true" : "false"),
+ d_children() {
+ }
+
+ SExpr(const Keyword& value) :
+ d_sexprType(SEXPR_KEYWORD),
+ d_integerValue(0),
+ d_rationalValue(0),
+ d_stringValue(value.getString()),
+ d_children() {
+ }
+
+ SExpr(const std::vector<SExpr>& children) :
+ d_sexprType(SEXPR_NOT_ATOM),
+ d_integerValue(0),
+ d_rationalValue(0),
+ d_stringValue(""),
+ d_children(children) {
+ }
+
+ /** Is this S-expression an atom? */
+ bool isAtom() const {
+ return d_sexprType != SEXPR_NOT_ATOM;
+ }
+
+ /** Is this S-expression an integer? */
+ bool isInteger() const {
+ return d_sexprType == SEXPR_INTEGER;
+ }
+
+ /** Is this S-expression a rational? */
+ bool isRational() const {
+ return d_sexprType == SEXPR_RATIONAL;
+ }
+
+ /** Is this S-expression a string? */
+ bool isString() const {
+ return d_sexprType == SEXPR_STRING;
+ }
+
+ /** Is this S-expression a keyword? */
+ 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
+ * error if this S-expression is not an atom.
+ */
+ std::string getValue() const;
+
+ /**
+ * Get the integer value of this S-expression. This will cause an
+ * error if this S-expression is not an integer.
+ */
+ const CVC4::Integer& getIntegerValue() const;
+
+ /**
+ * Get the rational value of this S-expression. This will cause an
+ * error if this S-expression is not a rational.
+ */
+ const CVC4::Rational& getRationalValue() const;
+
+ /**
+ * Get the children of this S-expression. This will cause an error
+ * if this S-expression is not a list.
+ */
+ const std::vector<SExpr>& getChildren() const;
+
+ /** Is this S-expression equal to another? */
+ bool operator==(const SExpr& s) const;
+
+ /** 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 */
+
+/** 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;
+ }
+
+ 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.
+ */
+std::ostream& operator<<(std::ostream& out, PrettySExprs ps);
+
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__SEXPR_H */
--- /dev/null
+%{
+#include "expr/sexpr.h"
+%}
+
+%ignore CVC4::operator<<(std::ostream&, const SExpr&);
+%ignore CVC4::operator<<(std::ostream&, SExpr::SexprTypes);
+
+// for Java and the like
+%extend CVC4::SExpr {
+ std::string toString() const { return self->getValue(); }
+};/* CVC4::SExpr */
+
+%ignore CVC4::SExpr::SExpr(int);
+%ignore CVC4::SExpr::SExpr(unsigned int);
+%ignore CVC4::SExpr::SExpr(unsigned long);
+%ignore CVC4::SExpr::SExpr(const char*);
+
+%rename(equals) CVC4::SExpr::operator==(const SExpr&) const;
+%ignore CVC4::SExpr::operator!=(const SExpr&) const;
+
+%include "expr/sexpr.h"
--- /dev/null
+/********************* */
+/*! \file statistics.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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include <typeinfo>
+
+#include "expr/statistics.h"
+#include "expr/statistics_registry.h" // for details about class Stat
+
+
+namespace CVC4 {
+
+std::string StatisticsBase::s_regDelim("::");
+
+bool StatisticsBase::StatCmp::operator()(const Stat* s1, const Stat* s2) const {
+ return s1->getName() < s2->getName();
+}
+
+StatisticsBase::iterator::value_type StatisticsBase::iterator::operator*() const {
+ return std::make_pair((*d_it)->getName(), (*d_it)->getValue());
+}
+
+StatisticsBase::StatisticsBase() :
+ d_prefix(),
+ d_stats() {
+}
+
+StatisticsBase::StatisticsBase(const StatisticsBase& stats) :
+ d_prefix(stats.d_prefix),
+ d_stats() {
+}
+
+StatisticsBase& StatisticsBase::operator=(const StatisticsBase& stats) {
+ d_prefix = stats.d_prefix;
+ return *this;
+}
+
+void Statistics::copyFrom(const StatisticsBase& stats) {
+ // This is ugly, but otherwise we have to introduce a "friend" relation for
+ // Base to its derived class (really obnoxious).
+ StatSet::const_iterator i_begin = ((const Statistics*) &stats)->d_stats.begin();
+ StatSet::const_iterator i_end = ((const Statistics*) &stats)->d_stats.end();
+ for(StatSet::const_iterator i = i_begin; i != i_end; ++i) {
+ SExprStat* p = new SExprStat((*i)->getName(), (*i)->getValue());
+ d_stats.insert(p);
+ }
+}
+
+void Statistics::clear() {
+ for(StatSet::iterator i = d_stats.begin(); i != d_stats.end(); ++i) {
+ delete *i;
+ }
+ d_stats.clear();
+}
+
+Statistics::Statistics(const StatisticsBase& stats) :
+ StatisticsBase(stats) {
+ copyFrom(stats);
+}
+
+Statistics::Statistics(const Statistics& stats) :
+ StatisticsBase(stats) {
+ copyFrom(stats);
+}
+
+Statistics::~Statistics() {
+ clear();
+}
+
+Statistics& Statistics::operator=(const StatisticsBase& stats) {
+ clear();
+ this->StatisticsBase::operator=(stats);
+ copyFrom(stats);
+
+ return *this;
+}
+
+Statistics& Statistics::operator=(const Statistics& stats) {
+ return this->operator=((const StatisticsBase&)stats);
+}
+
+StatisticsBase::const_iterator StatisticsBase::begin() const {
+ return iterator(d_stats.begin());
+}
+
+StatisticsBase::const_iterator StatisticsBase::end() const {
+ return iterator(d_stats.end());
+}
+
+void StatisticsBase::flushInformation(std::ostream &out) const {
+#ifdef CVC4_STATISTICS_ON
+ for(StatSet::iterator i = d_stats.begin();
+ i != d_stats.end();
+ ++i) {
+ Stat* s = *i;
+ if(d_prefix != "") {
+ out << d_prefix << s_regDelim;
+ }
+ s->flushStat(out);
+ out << std::endl;
+ }
+#endif /* CVC4_STATISTICS_ON */
+}
+
+SExpr StatisticsBase::getStatistic(std::string name) const {
+ SExpr value;
+ IntStat s(name, 0);
+ StatSet::iterator i = d_stats.find(&s);
+ if(i != d_stats.end()) {
+ return (*i)->getValue();
+ } else {
+ return SExpr();
+ }
+}
+
+void StatisticsBase::setPrefix(const std::string& prefix) {
+ d_prefix = prefix;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file statistics.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_public.h"
+
+#ifndef __CVC4__STATISTICS_H
+#define __CVC4__STATISTICS_H
+
+#include "expr/sexpr.h"
+
+#include <iterator>
+#include <ostream>
+#include <set>
+#include <string>
+#include <utility>
+
+namespace CVC4 {
+
+class Stat;
+
+class CVC4_PUBLIC StatisticsBase {
+protected:
+
+ static std::string s_regDelim;
+
+ /** A helper class for comparing two statistics */
+ struct StatCmp {
+ bool operator()(const Stat* s1, const Stat* s2) const;
+ };/* struct StatisticsRegistry::StatCmp */
+
+ /** A type for a set of statistics */
+ typedef std::set< Stat*, StatCmp > StatSet;
+
+ std::string d_prefix;
+
+ /** The set of statistics in this object */
+ StatSet d_stats;
+
+ StatisticsBase();
+ StatisticsBase(const StatisticsBase& stats);
+ StatisticsBase& operator=(const StatisticsBase& stats);
+
+public:
+
+ virtual ~StatisticsBase() { }
+
+ class CVC4_PUBLIC iterator : public std::iterator< std::input_iterator_tag, std::pair<std::string, SExpr> > {
+ StatSet::iterator d_it;
+
+ iterator(StatSet::iterator it) : d_it(it) { }
+
+ friend class StatisticsBase;
+
+ public:
+ iterator() : d_it() { }
+ iterator(const iterator& it) : d_it(it.d_it) { }
+ value_type operator*() const;
+ iterator& operator++() { ++d_it; return *this; }
+ iterator operator++(int) { iterator old = *this; ++d_it; return old; }
+ bool operator==(const iterator& i) const { return d_it == i.d_it; }
+ bool operator!=(const iterator& i) const { return d_it != i.d_it; }
+ };/* class StatisticsBase::iterator */
+
+ /** An iterator type over a set of statistics. */
+ typedef iterator const_iterator;
+
+ /** Set the output prefix for this set of statistics. */
+ virtual void setPrefix(const std::string& prefix);
+
+ /** Flush all statistics to the given output stream. */
+ void flushInformation(std::ostream& out) const;
+
+ /** Get the value of a named statistic. */
+ SExpr getStatistic(std::string name) const;
+
+ /**
+ * Get an iterator to the beginning of the range of the set of
+ * statistics.
+ */
+ const_iterator begin() const;
+
+ /**
+ * Get an iterator to the end of the range of the set of statistics.
+ */
+ const_iterator end() const;
+
+};/* class StatisticsBase */
+
+class CVC4_PUBLIC Statistics : public StatisticsBase {
+ void clear();
+ void copyFrom(const StatisticsBase&);
+
+public:
+
+ /**
+ * Override the copy constructor to do a "deep" copy of statistics
+ * values.
+ */
+ Statistics(const StatisticsBase& stats);
+ Statistics(const Statistics& stats);
+
+ ~Statistics();
+
+ /**
+ * Override the assignment operator to do a "deep" copy of statistics
+ * values.
+ */
+ Statistics& operator=(const StatisticsBase& stats);
+ Statistics& operator=(const Statistics& stats);
+
+};/* class Statistics */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__STATISTICS_H */
--- /dev/null
+%{
+#include "expr/statistics.h"
+
+#ifdef SWIGJAVA
+
+#include "bindings/java_iterator_adapter.h"
+#include "bindings/java_stream_adapters.h"
+
+#endif /* SWIGJAVA */
+%}
+
+%rename(assign) CVC4::Statistics::operator=(const StatisticsBase&);
+%rename(assign) CVC4::Statistics::operator=(const Statistics& stats);
+
+#ifdef SWIGJAVA
+
+// Instead of StatisticsBase::begin() and end(), create an
+// iterator() method on the Java side that returns a Java-style
+// Iterator.
+%ignore CVC4::StatisticsBase::begin();
+%ignore CVC4::StatisticsBase::end();
+%ignore CVC4::StatisticsBase::begin() const;
+%ignore CVC4::StatisticsBase::end() const;
+%extend CVC4::StatisticsBase {
+ CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> iterator() {
+ return CVC4::JavaIteratorAdapter<CVC4::StatisticsBase>(*$self);
+ }
+}
+
+// StatisticsBase is "iterable" on the Java side
+%typemap(javainterfaces) CVC4::StatisticsBase "java.lang.Iterable<Object[]>";
+
+// the JavaIteratorAdapter should not be public, and implements Iterator
+%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "class";
+%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "java.util.Iterator<Object[]>";
+// add some functions to the Java side (do it here because there's no way to do these in C++)
+%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "
+ public void remove() {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ public Object[] next() {
+ if(hasNext()) {
+ return getNext();
+ } else {
+ throw new java.util.NoSuchElementException();
+ }
+ }
+"
+// getNext() just allows C++ iterator access from Java-side next(), make it private
+%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::StatisticsBase>::getNext() "private";
+
+// map the types appropriately. for statistics, the "payload" of the iterator is an Object[].
+// These Object arrays are always of two elements, the first is a String and the second an
+// SExpr. (On the C++ side, it is a std::pair<std::string, SExpr>.)
+%typemap(jni) CVC4::StatisticsBase::const_iterator::value_type "jobjectArray";
+%typemap(jtype) CVC4::StatisticsBase::const_iterator::value_type "java.lang.Object[]";
+%typemap(jstype) CVC4::StatisticsBase::const_iterator::value_type "java.lang.Object[]";
+%typemap(javaout) CVC4::StatisticsBase::const_iterator::value_type { return $jnicall; }
+%typemap(out) CVC4::StatisticsBase::const_iterator::value_type {
+ $result = jenv->NewObjectArray(2, jenv->FindClass("java/lang/Object"), $null);
+ jenv->SetObjectArrayElement($result, 0, jenv->NewStringUTF($1.first.c_str()));
+ jclass clazz = jenv->FindClass("edu/nyu/acsys/CVC4/SExpr");
+ jmethodID methodid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
+ jenv->SetObjectArrayElement($result, 1, jenv->NewObject(clazz, methodid, reinterpret_cast<long>(new CVC4::SExpr($1.second)), true));
+ };
+
+#endif /* SWIGJAVA */
+
+%include "expr/statistics.h"
+
+#ifdef SWIGJAVA
+
+%include "bindings/java_iterator_adapter.h"
+%include "bindings/java_stream_adapters.h"
+
+%template(JavaIteratorAdapter_StatisticsBase) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase>;
+
+#endif /* SWIGJAVA */
--- /dev/null
+/********************* */
+/*! \file statistics_registry.cpp
+ ** \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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "expr/statistics_registry.h"
+
+#include "expr/expr_manager.h"
+#include "lib/clock_gettime.h"
+#include "smt/smt_engine.h"
+
+#ifndef __BUILDING_STATISTICS_FOR_EXPORT
+# include "smt/smt_engine_scope.h"
+#endif /* ! __BUILDING_STATISTICS_FOR_EXPORT */
+
+#ifdef CVC4_STATISTICS_ON
+# define __CVC4_USE_STATISTICS true
+#else
+# define __CVC4_USE_STATISTICS false
+#endif
+
+#warning "TODO: Make StatisticsRegistry non-public again."
+#warning "TODO: Make TimerStat non-public again."
+
+namespace CVC4 {
+
+namespace stats {
+
+// This is a friend of SmtEngine, just to reach in and get it.
+// this isn't a class function because then there's a cyclic
+// dependence.
+inline StatisticsRegistry* getStatisticsRegistry(SmtEngine* smt) {
+ return smt->d_statisticsRegistry;
+}
+
+inline StatisticsRegistry* getStatisticsRegistry(ExprManager* em) {
+ return em->getStatisticsRegistry();
+}
+
+}/* CVC4::stats namespace */
+
+#ifndef __BUILDING_STATISTICS_FOR_EXPORT
+
+StatisticsRegistry* StatisticsRegistry::current() {
+ return stats::getStatisticsRegistry(smt::currentSmtEngine());
+}
+
+void StatisticsRegistry::registerStat(Stat* s) throw(CVC4::IllegalArgumentException) {
+#ifdef CVC4_STATISTICS_ON
+ StatSet& stats = current()->d_stats;
+ CheckArgument(stats.find(s) == stats.end(), s,
+ "Statistic `%s' was already registered with this registry.",
+ s->getName().c_str());
+ stats.insert(s);
+#endif /* CVC4_STATISTICS_ON */
+}/* StatisticsRegistry::registerStat() */
+
+void StatisticsRegistry::unregisterStat(Stat* s) throw(CVC4::IllegalArgumentException) {
+#ifdef CVC4_STATISTICS_ON
+ StatSet& stats = current()->d_stats;
+ CheckArgument(stats.find(s) != stats.end(), s,
+ "Statistic `%s' was not registered with this registry.",
+ s->getName().c_str());
+ stats.erase(s);
+#endif /* CVC4_STATISTICS_ON */
+}/* StatisticsRegistry::unregisterStat() */
+
+#endif /* ! __BUILDING_STATISTICS_FOR_EXPORT */
+
+void StatisticsRegistry::registerStat_(Stat* s) throw(CVC4::IllegalArgumentException) {
+#ifdef CVC4_STATISTICS_ON
+ CheckArgument(d_stats.find(s) == d_stats.end(), s);
+ d_stats.insert(s);
+#endif /* CVC4_STATISTICS_ON */
+}/* StatisticsRegistry::registerStat_() */
+
+void StatisticsRegistry::unregisterStat_(Stat* s) throw(CVC4::IllegalArgumentException) {
+#ifdef CVC4_STATISTICS_ON
+ CheckArgument(d_stats.find(s) != d_stats.end(), s);
+ d_stats.erase(s);
+#endif /* CVC4_STATISTICS_ON */
+}/* StatisticsRegistry::unregisterStat_() */
+
+void StatisticsRegistry::flushStat(std::ostream &out) const {
+#ifdef CVC4_STATISTICS_ON
+ flushInformation(out);
+#endif /* CVC4_STATISTICS_ON */
+}
+
+void StatisticsRegistry::flushInformation(std::ostream &out) const {
+#ifdef CVC4_STATISTICS_ON
+ this->StatisticsBase::flushInformation(out);
+#endif /* CVC4_STATISTICS_ON */
+}
+
+void TimerStat::start() {
+ if(__CVC4_USE_STATISTICS) {
+ CheckArgument(!d_running, *this, "timer already running");
+ clock_gettime(CLOCK_MONOTONIC, &d_start);
+ d_running = true;
+ }
+}/* TimerStat::start() */
+
+void TimerStat::stop() {
+ if(__CVC4_USE_STATISTICS) {
+ CheckArgument(d_running, *this, "timer not running");
+ ::timespec end;
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ d_data += end - d_start;
+ d_running = false;
+ }
+}/* TimerStat::stop() */
+
+bool TimerStat::running() const {
+ return d_running;
+}/* TimerStat::running() */
+
+timespec TimerStat::getData() const {
+ ::timespec data = d_data;
+ if(__CVC4_USE_STATISTICS && d_running) {
+ ::timespec end;
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ data += end - d_start;
+ }
+ return data;
+}
+
+SExpr TimerStat::getValue() const {
+ ::timespec data = d_data;
+ if(__CVC4_USE_STATISTICS && d_running) {
+ ::timespec end;
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ data += end - d_start;
+ }
+ std::stringstream ss;
+ ss << std::fixed << std::setprecision(8) << data;
+ return SExpr(Rational::fromDecimal(ss.str()));
+}/* TimerStat::getValue() */
+
+RegisterStatistic::RegisterStatistic(ExprManager& em, Stat* stat) :
+ d_reg(stats::getStatisticsRegistry(&em)),
+ d_stat(stat) {
+ d_reg->registerStat_(d_stat);
+}
+
+RegisterStatistic::RegisterStatistic(SmtEngine& smt, Stat* stat) :
+ d_reg(stats::getStatisticsRegistry(&smt)),
+ d_stat(stat) {
+ d_reg->registerStat_(d_stat);
+}
+
+
+
+}/* CVC4 namespace */
+
+#undef __CVC4_USE_STATISTICS
--- /dev/null
+/********************* */
+/*! \file statistics_registry.h
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: Tim King
+ ** Minor contributors (to current version): Kshitij Bansal
+ ** 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 Statistics utility classes
+ **
+ ** Statistics utility classes, including classes for holding (and referring
+ ** to) statistics, the statistics registry, and some other associated
+ ** classes.
+ **/
+
+#include "cvc4_private_library.h"
+
+#ifndef __CVC4__STATISTICS_REGISTRY_H
+#define __CVC4__STATISTICS_REGISTRY_H
+
+#include <stdint.h>
+
+#include <cassert>
+#include <ctime>
+#include <iomanip>
+#include <map>
+#include <sstream>
+#include <vector>
+
+#include "base/exception.h"
+#include "expr/statistics.h"
+#include "lib/clock_gettime.h"
+
+namespace CVC4 {
+
+#ifdef CVC4_STATISTICS_ON
+# define __CVC4_USE_STATISTICS true
+#else
+# define __CVC4_USE_STATISTICS false
+#endif
+
+class ExprManager;
+class SmtEngine;
+
+/**
+ * The base class for all statistics.
+ *
+ * This base class keeps the name of the statistic and declares the (pure)
+ * virtual function flushInformation(). Derived classes must implement
+ * this function and pass their name to the base class constructor.
+ *
+ * This class also (statically) maintains the delimiter used to separate
+ * the name and the value when statistics are output.
+ */
+class Stat {
+protected:
+ /** The name of this statistic */
+ std::string d_name;
+
+public:
+
+ /** Nullary constructor, does nothing */
+ Stat() { }
+
+ /**
+ * Construct a statistic with the given name. Debug builds of CVC4
+ * will throw an assertion exception if the given name contains the
+ * statistic delimiter string.
+ */
+ Stat(const std::string& name) throw(CVC4::IllegalArgumentException) :
+ d_name(name) {
+ if(__CVC4_USE_STATISTICS) {
+ CheckArgument(d_name.find(", ") == std::string::npos, name,
+ "Statistics names cannot include a comma (',')");
+ }
+ }
+
+ /** Destruct a statistic. This base-class version does nothing. */
+ virtual ~Stat() {}
+
+ /**
+ * Flush the value of this statistic to an output stream. Should
+ * finish the output with an end-of-line character.
+ */
+ virtual void flushInformation(std::ostream& out) const = 0;
+
+ /**
+ * Flush the name,value pair of this statistic to an output stream.
+ * Uses the statistic delimiter string between name and value.
+ *
+ * May be redefined by a child class
+ */
+ virtual void flushStat(std::ostream& out) const {
+ if(__CVC4_USE_STATISTICS) {
+ out << d_name << ", ";
+ flushInformation(out);
+ }
+ }
+
+ /** Get the name of this statistic. */
+ const std::string& getName() const {
+ return d_name;
+ }
+
+ /** Get the value of this statistic as a string. */
+ virtual SExpr getValue() const {
+ std::stringstream ss;
+ flushInformation(ss);
+ return SExpr(ss.str());
+ }
+
+};/* class Stat */
+
+// A generic way of making a SExpr from templated stats code.
+// for example, the uint64_t version ensures that we create
+// Integer-SExprs for ReadOnlyDataStats (like those inside
+// Minisat) without having to specialize the entire
+// ReadOnlyDataStat class template.
+template <class T>
+inline SExpr mkSExpr(const T& x) {
+ std::stringstream ss;
+ ss << x;
+ return SExpr(ss.str());
+}
+
+template <>
+inline SExpr mkSExpr(const uint64_t& x) {
+ return SExpr(Integer(x));
+}
+
+template <>
+inline SExpr mkSExpr(const int64_t& x) {
+ return SExpr(Integer(x));
+}
+
+template <>
+inline SExpr mkSExpr(const int& x) {
+ return SExpr(Integer(x));
+}
+
+template <>
+inline SExpr mkSExpr(const Integer& x) {
+ return SExpr(x);
+}
+
+template <>
+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 SExpr(Rational::fromDecimal(ss.str()));
+}
+
+template <>
+inline SExpr mkSExpr(const Rational& x) {
+ return SExpr(x);
+}
+
+/**
+ * A class to represent a "read-only" data statistic of type T. Adds to
+ * the Stat base class the pure virtual function getData(), which returns
+ * type T, and flushInformation(), which outputs the statistic value to an
+ * output stream (using the same existing stream insertion operator).
+ *
+ * Template class T must have stream insertion operation defined:
+ * std::ostream& operator<<(std::ostream&, const T&)
+ */
+template <class T>
+class ReadOnlyDataStat : public Stat {
+public:
+ /** The "payload" type of this data statistic (that is, T). */
+ typedef T payload_t;
+
+ /** Construct a read-only data statistic with the given name. */
+ ReadOnlyDataStat(const std::string& name) :
+ Stat(name) {
+ }
+
+ /** Get the value of the statistic. */
+ virtual T getData() const = 0;
+
+ /** Flush the value of the statistic to the given output stream. */
+ void flushInformation(std::ostream& out) const {
+ if(__CVC4_USE_STATISTICS) {
+ out << getData();
+ }
+ }
+
+ SExpr getValue() const {
+ return mkSExpr(getData());
+ }
+
+};/* class ReadOnlyDataStat<T> */
+
+
+/**
+ * A data statistic class. This class extends a read-only data statistic
+ * with assignment (the statistic can be set as well as read). This class
+ * adds to the read-only case a pure virtual function setData(), thus
+ * providing the basic interface for a data statistic: getData() to get the
+ * statistic value, and setData() to set it.
+ *
+ * As with the read-only data statistic class, template class T must have
+ * stream insertion operation defined:
+ * std::ostream& operator<<(std::ostream&, const T&)
+ */
+template <class T>
+class DataStat : public ReadOnlyDataStat<T> {
+public:
+
+ /** Construct a data statistic with the given name. */
+ DataStat(const std::string& name) :
+ ReadOnlyDataStat<T>(name) {
+ }
+
+ /** Set the data statistic. */
+ virtual void setData(const T&) = 0;
+
+};/* class DataStat<T> */
+
+
+/**
+ * A data statistic that references a data cell of type T,
+ * implementing getData() by referencing that memory cell, and
+ * setData() by reassigning the statistic to point to the new
+ * data cell. The referenced data cell is kept as a const
+ * reference, meaning the referenced data is never actually
+ * modified by this class (it must be externally modified for
+ * a reference statistic to make sense). A common use for
+ * this type of statistic is to output a statistic that is kept
+ * outside the statistics package (for example, one that's kept
+ * by a theory implementation for internal heuristic purposes,
+ * which is important to keep even if statistics are turned off).
+ *
+ * Template class T must have an assignment operator=().
+ */
+template <class T>
+class ReferenceStat : public DataStat<T> {
+private:
+ /** The referenced data cell */
+ const T* d_data;
+
+public:
+ /**
+ * Construct a reference stat with the given name and a reference
+ * to NULL.
+ */
+ ReferenceStat(const std::string& name) :
+ DataStat<T>(name),
+ d_data(NULL) {
+ }
+
+ /**
+ * Construct a reference stat with the given name and a reference to
+ * the given data.
+ */
+ ReferenceStat(const std::string& name, const T& data) :
+ DataStat<T>(name),
+ d_data(NULL) {
+ setData(data);
+ }
+
+ /** Set this reference statistic to refer to the given data cell. */
+ void setData(const T& t) {
+ if(__CVC4_USE_STATISTICS) {
+ d_data = &t;
+ }
+ }
+
+ /** Get the value of the referenced data cell. */
+ T getData() const {
+ return *d_data;
+ }
+
+};/* class ReferenceStat<T> */
+
+
+/**
+ * A data statistic that keeps a T and sets it with setData().
+ *
+ * Template class T must have an operator=() and a copy constructor.
+ */
+template <class T>
+class BackedStat : public DataStat<T> {
+protected:
+ /** The internally-kept statistic value */
+ T d_data;
+
+public:
+
+ /** Construct a backed statistic with the given name and initial value. */
+ BackedStat(const std::string& name, const T& init) :
+ DataStat<T>(name),
+ d_data(init) {
+ }
+
+ /** Set the underlying data value to the given value. */
+ void setData(const T& t) {
+ if(__CVC4_USE_STATISTICS) {
+ d_data = t;
+ }
+ }
+
+ /** Identical to setData(). */
+ BackedStat<T>& operator=(const T& t) {
+ if(__CVC4_USE_STATISTICS) {
+ d_data = t;
+ }
+ return *this;
+ }
+
+ /** Get the underlying data value. */
+ T getData() const {
+ return d_data;
+ }
+
+};/* class BackedStat<T> */
+
+
+/**
+ * A wrapper Stat for another Stat.
+ *
+ * This type of Stat is useful in cases where a module (like the
+ * CongruenceClosure module) might keep its own statistics, but might
+ * be instantiated in many contexts by many clients. This makes such
+ * a statistic inappopriate to register with the StatisticsRegistry
+ * directly, as all would be output with the same name (and may be
+ * unregistered too quickly anyway). A WrappedStat allows the calling
+ * client (say, TheoryUF) to wrap the Stat from the client module,
+ * giving it a globally unique name.
+ */
+template <class Stat>
+class WrappedStat : public ReadOnlyDataStat<typename Stat::payload_t> {
+ typedef typename Stat::payload_t T;
+
+ const ReadOnlyDataStat<T>& d_stat;
+
+ /** Private copy constructor undefined (no copy permitted). */
+ WrappedStat(const WrappedStat&) CVC4_UNDEFINED;
+ /** Private assignment operator undefined (no copy permitted). */
+ WrappedStat<T>& operator=(const WrappedStat&) CVC4_UNDEFINED;
+
+public:
+
+ /**
+ * Construct a wrapped statistic with the given name that wraps the
+ * given statistic.
+ */
+ WrappedStat(const std::string& name, const ReadOnlyDataStat<T>& stat) :
+ ReadOnlyDataStat<T>(name),
+ d_stat(stat) {
+ }
+
+ /** Get the data of the underlying (wrapped) statistic. */
+ T getData() const {
+ return d_stat.getData();
+ }
+
+ SExpr getValue() const {
+ return d_stat.getValue();
+ }
+
+};/* class WrappedStat<T> */
+
+/**
+ * A backed integer-valued (64-bit signed) statistic.
+ * This doesn't functionally differ from its base class BackedStat<int64_t>,
+ * except for adding convenience functions for dealing with integers.
+ */
+class IntStat : public BackedStat<int64_t> {
+public:
+
+ /**
+ * Construct an integer-valued statistic with the given name and
+ * initial value.
+ */
+ IntStat(const std::string& name, int64_t init) :
+ BackedStat<int64_t>(name, init) {
+ }
+
+ /** Increment the underlying integer statistic. */
+ IntStat& operator++() {
+ if(__CVC4_USE_STATISTICS) {
+ ++d_data;
+ }
+ return *this;
+ }
+
+ /** Increment the underlying integer statistic by the given amount. */
+ IntStat& operator+=(int64_t val) {
+ if(__CVC4_USE_STATISTICS) {
+ d_data += val;
+ }
+ return *this;
+ }
+
+ /** Keep the maximum of the current statistic value and the given one. */
+ void maxAssign(int64_t val) {
+ if(__CVC4_USE_STATISTICS) {
+ if(d_data < val) {
+ d_data = val;
+ }
+ }
+ }
+
+ /** Keep the minimum of the current statistic value and the given one. */
+ void minAssign(int64_t val) {
+ if(__CVC4_USE_STATISTICS) {
+ if(d_data > val) {
+ d_data = val;
+ }
+ }
+ }
+
+ SExpr getValue() const {
+ return SExpr(Integer(d_data));
+ }
+
+};/* class IntStat */
+
+template <class T>
+class SizeStat : public Stat {
+private:
+ const T& d_sized;
+public:
+ SizeStat(const std::string&name, const T& sized) :
+ Stat(name), d_sized(sized) {}
+ ~SizeStat() {}
+
+ void flushInformation(std::ostream& out) const {
+ out << d_sized.size();
+ }
+
+ SExpr getValue() const {
+ return SExpr(Integer(d_sized.size()));
+ }
+
+};/* class SizeStat */
+
+/**
+ * The value for an AverageStat is the running average of (e1, e_2, ..., e_n),
+ * (e1 + e_2 + ... + e_n)/n,
+ * where e_i is an entry added by an addEntry(e_i) call.
+ * The value is initially always 0.
+ * (This is to avoid making parsers confused.)
+ *
+ * A call to setData() will change the running average but not reset the
+ * running count, so should generally be avoided. Call addEntry() to add
+ * an entry to the average calculation.
+ */
+class AverageStat : public BackedStat<double> {
+private:
+ /**
+ * The number of accumulations of the running average that we
+ * have seen so far.
+ */
+ uint32_t d_count;
+ double d_sum;
+
+public:
+ /** Construct an average statistic with the given name. */
+ AverageStat(const std::string& name) :
+ BackedStat<double>(name, 0.0), d_count(0), d_sum(0.0) {
+ }
+
+ /** Add an entry to the running-average calculation. */
+ void addEntry(double e) {
+ if(__CVC4_USE_STATISTICS) {
+ ++d_count;
+ d_sum += e;
+ setData(d_sum / d_count);
+ }
+ }
+
+ SExpr getValue() const {
+ std::stringstream ss;
+ ss << std::fixed << std::setprecision(8) << d_data;
+ return SExpr(Rational::fromDecimal(ss.str()));
+ }
+
+};/* class AverageStat */
+
+/** A statistic that contains a SExpr. */
+class SExprStat : public Stat {
+private:
+ SExpr d_data;
+
+public:
+
+ /**
+ * Construct a SExpr-valued statistic with the given name and
+ * initial value.
+ */
+ SExprStat(const std::string& name, const SExpr& init) :
+ Stat(name), d_data(init){}
+
+ virtual void flushInformation(std::ostream& out) const {
+ out << d_data << std::endl;
+ }
+
+ SExpr getValue() const {
+ return d_data;
+ }
+
+};/* class SExprStat */
+
+template <class T>
+class ListStat : public Stat {
+private:
+ typedef std::vector<T> List;
+ List d_list;
+public:
+
+ /**
+ * Construct an integer-valued statistic with the given name and
+ * initial value.
+ */
+ ListStat(const std::string& name) : Stat(name) {}
+ ~ListStat() {}
+
+ void flushInformation(std::ostream& out) const{
+ if(__CVC4_USE_STATISTICS) {
+ typename List::const_iterator i = d_list.begin(), end = d_list.end();
+ out << "[";
+ if(i != end){
+ out << *i;
+ ++i;
+ for(; i != end; ++i){
+ out << ", " << *i;
+ }
+ }
+ out << "]";
+ }
+ }
+
+ ListStat& operator<<(const T& val){
+ if(__CVC4_USE_STATISTICS) {
+ d_list.push_back(val);
+ }
+ return (*this);
+ }
+
+};/* class ListStat */
+
+template <class T>
+class HistogramStat : public Stat {
+private:
+ typedef std::map<T, unsigned int> Histogram;
+ Histogram d_hist;
+public:
+
+ /** Construct a histogram of a stream of entries. */
+ HistogramStat(const std::string& name) : Stat(name) {}
+ ~HistogramStat() {}
+
+ void flushInformation(std::ostream& out) const{
+ if(__CVC4_USE_STATISTICS) {
+ typename Histogram::const_iterator i = d_hist.begin();
+ typename Histogram::const_iterator end = d_hist.end();
+ out << "[";
+ while(i != end){
+ const T& key = (*i).first;
+ unsigned int count = (*i).second;
+ out << "("<<key<<" : "<<count<< ")";
+ ++i;
+ if(i != end){
+ out << ", ";
+ }
+ }
+ out << "]";
+ }
+ }
+
+ HistogramStat& operator<<(const T& val){
+ if(__CVC4_USE_STATISTICS) {
+ if(d_hist.find(val) == d_hist.end()){
+ d_hist.insert(std::make_pair(val,0));
+ }
+ d_hist[val]++;
+ }
+ return (*this);
+ }
+
+};/* class HistogramStat */
+
+/****************************************************************************/
+/* Statistics Registry */
+/****************************************************************************/
+
+/**
+ * The main statistics registry. This registry maintains the list of
+ * currently active statistics and is able to "flush" them all.
+ */
+class CVC4_PUBLIC StatisticsRegistry : public StatisticsBase, public Stat {
+private:
+
+ /** Private copy constructor undefined (no copy permitted). */
+ StatisticsRegistry(const StatisticsRegistry&) CVC4_UNDEFINED;
+
+public:
+
+ /** Construct an nameless statistics registry */
+ StatisticsRegistry() {}
+
+ /** Construct a statistics registry */
+ StatisticsRegistry(const std::string& name)
+ throw(CVC4::IllegalArgumentException) :
+ Stat(name) {
+ d_prefix = name;
+ if(__CVC4_USE_STATISTICS) {
+ CheckArgument(d_name.find(s_regDelim) == std::string::npos, name,
+ "StatisticsRegistry names cannot contain the string \"%s\"",
+ s_regDelim.c_str());
+ }
+ }
+
+ /**
+ * Set the name of this statistic registry, used as prefix during
+ * output. (This version overrides StatisticsBase::setPrefix().)
+ */
+ void setPrefix(const std::string& name) {
+ d_prefix = d_name = name;
+ }
+
+#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && !defined(__BUILDING_STATISTICS_FOR_EXPORT)
+ /** Get a pointer to the current statistics registry */
+ static StatisticsRegistry* current();
+#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST) && ! __BUILDING_STATISTICS_FOR_EXPORT */
+
+ /** Overridden to avoid the name being printed */
+ void flushStat(std::ostream &out) const;
+
+ virtual void flushInformation(std::ostream& out) const;
+
+ SExpr getValue() const {
+ std::vector<SExpr> v;
+ for(StatSet::iterator i = d_stats.begin(); i != d_stats.end(); ++i) {
+ std::vector<SExpr> w;
+ w.push_back(SExpr((*i)->getName()));
+ w.push_back((*i)->getValue());
+ v.push_back(SExpr(w));
+ }
+ return SExpr(v);
+ }
+
+#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && !defined(__BUILDING_STATISTICS_FOR_EXPORT)
+ /** Register a new statistic, making it active. */
+ static void registerStat(Stat* s) throw(CVC4::IllegalArgumentException);
+
+ /** Unregister an active statistic, making it inactive. */
+ static void unregisterStat(Stat* s) throw(CVC4::IllegalArgumentException);
+#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB) && ! __BUILDING_STATISTICS_FOR_EXPORT */
+
+ /** Register a new statistic */
+ void registerStat_(Stat* s) throw(CVC4::IllegalArgumentException);
+
+ /** Unregister a new statistic */
+ void unregisterStat_(Stat* s) throw(CVC4::IllegalArgumentException);
+
+};/* class StatisticsRegistry */
+
+}/* CVC4 namespace */
+
+/****************************************************************************/
+/* Some utility functions for timespec */
+/****************************************************************************/
+
+inline std::ostream& operator<<(std::ostream& os, const timespec& t);
+
+/** Compute the sum of two timespecs. */
+inline timespec& operator+=(timespec& a, const timespec& b) {
+ using namespace CVC4;
+ // assumes a.tv_nsec and b.tv_nsec are in range
+ const long nsec_per_sec = 1000000000L; // one thousand million
+ CheckArgument(a.tv_nsec >= 0 && a.tv_nsec < nsec_per_sec, a);
+ CheckArgument(b.tv_nsec >= 0 && b.tv_nsec < nsec_per_sec, b);
+ a.tv_sec += b.tv_sec;
+ long nsec = a.tv_nsec + b.tv_nsec;
+ assert(nsec >= 0);
+ if(nsec < 0) {
+ nsec += nsec_per_sec;
+ --a.tv_sec;
+ }
+ if(nsec >= nsec_per_sec) {
+ nsec -= nsec_per_sec;
+ ++a.tv_sec;
+ }
+ assert(nsec >= 0 && nsec < nsec_per_sec);
+ a.tv_nsec = nsec;
+ return a;
+}
+
+/** Compute the difference of two timespecs. */
+inline timespec& operator-=(timespec& a, const timespec& b) {
+ using namespace CVC4;
+ // assumes a.tv_nsec and b.tv_nsec are in range
+ const long nsec_per_sec = 1000000000L; // one thousand million
+ CheckArgument(a.tv_nsec >= 0 && a.tv_nsec < nsec_per_sec, a);
+ CheckArgument(b.tv_nsec >= 0 && b.tv_nsec < nsec_per_sec, b);
+ a.tv_sec -= b.tv_sec;
+ long nsec = a.tv_nsec - b.tv_nsec;
+ if(nsec < 0) {
+ nsec += nsec_per_sec;
+ --a.tv_sec;
+ }
+ if(nsec >= nsec_per_sec) {
+ nsec -= nsec_per_sec;
+ ++a.tv_sec;
+ }
+ assert(nsec >= 0 && nsec < nsec_per_sec);
+ a.tv_nsec = nsec;
+ return a;
+}
+
+/** Add two timespecs. */
+inline timespec operator+(const timespec& a, const timespec& b) {
+ timespec result = a;
+ return result += b;
+}
+
+/** Subtract two timespecs. */
+inline timespec operator-(const timespec& a, const timespec& b) {
+ timespec result = a;
+ return result -= b;
+}
+
+/** Compare two timespecs for equality. */
+inline bool operator==(const timespec& a, const timespec& b) {
+ // assumes a.tv_nsec and b.tv_nsec are in range
+ return a.tv_sec == b.tv_sec && a.tv_nsec == b.tv_nsec;
+}
+
+/** Compare two timespecs for disequality. */
+inline bool operator!=(const timespec& a, const timespec& b) {
+ // assumes a.tv_nsec and b.tv_nsec are in range
+ return !(a == b);
+}
+
+/** Compare two timespecs, returning true iff a < b. */
+inline bool operator<(const timespec& a, const timespec& b) {
+ // assumes a.tv_nsec and b.tv_nsec are in range
+ return a.tv_sec < b.tv_sec ||
+ (a.tv_sec == b.tv_sec && a.tv_nsec < b.tv_nsec);
+}
+
+/** Compare two timespecs, returning true iff a > b. */
+inline bool operator>(const timespec& a, const timespec& b) {
+ // assumes a.tv_nsec and b.tv_nsec are in range
+ return a.tv_sec > b.tv_sec ||
+ (a.tv_sec == b.tv_sec && a.tv_nsec > b.tv_nsec);
+}
+
+/** Compare two timespecs, returning true iff a <= b. */
+inline bool operator<=(const timespec& a, const timespec& b) {
+ // assumes a.tv_nsec and b.tv_nsec are in range
+ return !(a > b);
+}
+
+/** Compare two timespecs, returning true iff a >= b. */
+inline bool operator>=(const timespec& a, const timespec& b) {
+ // assumes a.tv_nsec and b.tv_nsec are in range
+ return !(a < b);
+}
+
+/** Output a timespec on an output stream. */
+inline std::ostream& operator<<(std::ostream& os, const timespec& t) {
+ // assumes t.tv_nsec is in range
+ return os << t.tv_sec << "."
+ << std::setfill('0') << std::setw(9) << std::right << t.tv_nsec;
+}
+
+namespace CVC4 {
+
+class CodeTimer;
+
+/**
+ * A timer statistic. The timer can be started and stopped
+ * arbitrarily, like a stopwatch; the value of the statistic at the
+ * end is the accumulated time over all (start,stop) pairs.
+ */
+class CVC4_PUBLIC TimerStat : public BackedStat<timespec> {
+
+ // strange: timespec isn't placed in 'std' namespace ?!
+ /** The last start time of this timer */
+ timespec d_start;
+
+ /** Whether this timer is currently running */
+ bool d_running;
+
+public:
+
+ typedef CVC4::CodeTimer CodeTimer;
+
+ /**
+ * Construct a timer statistic with the given name. Newly-constructed
+ * timers have a 0.0 value and are not running.
+ */
+ TimerStat(const std::string& name) :
+ BackedStat< timespec >(name, timespec()),
+ d_running(false) {
+ /* timespec is POD and so may not be initialized to zero;
+ * here, ensure it is */
+ d_data.tv_sec = d_data.tv_nsec = 0;
+ }
+
+ /** Start the timer. */
+ void start();
+
+ /**
+ * Stop the timer and update the statistic value with the
+ * accumulated time.
+ */
+ void stop();
+
+ /** If the timer is currently running */
+ bool running() const;
+
+ timespec getData() const;
+
+ SExpr getValue() const;
+
+};/* class TimerStat */
+
+/**
+ * Utility class to make it easier to call stop() at the end of a
+ * code block. When constructed, it starts the timer. When
+ * destructed, it stops the timer.
+ */
+class CodeTimer {
+ TimerStat& d_timer;
+ bool d_reentrant;
+
+ /** Private copy constructor undefined (no copy permitted). */
+ CodeTimer(const CodeTimer& timer) CVC4_UNDEFINED;
+ /** Private assignment operator undefined (no copy permitted). */
+ CodeTimer& operator=(const CodeTimer& timer) CVC4_UNDEFINED;
+
+public:
+ CodeTimer(TimerStat& timer, bool allow_reentrant = false) : d_timer(timer), d_reentrant(false) {
+ if(!allow_reentrant || !(d_reentrant = d_timer.running())) {
+ d_timer.start();
+ }
+ }
+ ~CodeTimer() {
+ if(!d_reentrant) {
+ d_timer.stop();
+ }
+ }
+};/* class CodeTimer */
+
+/**
+ * To use a statistic, you need to declare it, initialize it in your
+ * constructor, register it in your constructor, and deregister it in
+ * your destructor. Instead, this macro does it all for you (and
+ * therefore also keeps the statistic type, field name, and output
+ * string all in the same place in your class's header. Its use is
+ * like in this example, which takes the place of the declaration of a
+ * statistics field "d_checkTimer":
+ *
+ * KEEP_STATISTIC(TimerStat, d_checkTimer, "theory::uf::checkTime");
+ *
+ * If any args need to be passed to the constructor, you can specify
+ * them after the string.
+ *
+ * The macro works by creating a nested class type, derived from the
+ * statistic type you give it, which declares a registry-aware
+ * constructor/destructor pair.
+ */
+#define KEEP_STATISTIC(_StatType, _StatField, _StatName, _CtorArgs...) \
+ struct Statistic_##_StatField : public _StatType { \
+ Statistic_##_StatField() : _StatType(_StatName, ## _CtorArgs) { \
+ StatisticsRegistry::registerStat(this); \
+ } \
+ ~Statistic_##_StatField() { \
+ StatisticsRegistry::unregisterStat(this); \
+ } \
+ } _StatField
+
+/**
+ * Resource-acquisition-is-initialization idiom for statistics
+ * registry. Useful for stack-based statistics (like in the driver).
+ * Generally, for statistics kept in a member field of class, it's
+ * better to use the above KEEP_STATISTIC(), which does declaration of
+ * the member, construction of the statistic, and
+ * registration/unregistration. This RAII class only does
+ * registration and unregistration.
+ */
+class RegisterStatistic {
+
+ StatisticsRegistry* d_reg;
+ Stat* d_stat;
+
+public:
+
+#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && ! defined(__BUILDING_STATISTICS_FOR_EXPORT)
+ RegisterStatistic(Stat* stat) :
+ d_reg(StatisticsRegistry::current()),
+ d_stat(stat) {
+ if(d_reg != NULL) {
+ throw CVC4::Exception("There is no current statistics registry!");
+ }
+ StatisticsRegistry::registerStat(d_stat);
+ }
+#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST) && ! __BUILDING_STATISTICS_FOR_EXPORT */
+
+ RegisterStatistic(StatisticsRegistry* reg, Stat* stat) :
+ d_reg(reg),
+ d_stat(stat) {
+ CheckArgument(reg != NULL, reg,
+ "You need to specify a statistics registry"
+ "on which to set the statistic");
+ d_reg->registerStat_(d_stat);
+ }
+
+ RegisterStatistic(ExprManager& em, Stat* stat);
+
+ RegisterStatistic(SmtEngine& smt, Stat* stat);
+
+ ~RegisterStatistic() {
+ d_reg->unregisterStat_(d_stat);
+ }
+
+};/* class RegisterStatistic */
+
+#undef __CVC4_USE_STATISTICS
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__STATISTICS_REGISTRY_H */
**
** 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;
#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 {
#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}
--- /dev/null
+/********************* */
+/*! \file uninterpreted_constant.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 Representation of constants of uninterpreted sorts
+ **
+ ** Representation of constants of uninterpreted sorts.
+ **/
+
+#include "expr/uninterpreted_constant.h"
+
+#include <iostream>
+#include <sstream>
+#include <string>
+
+using namespace std;
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, const UninterpretedConstant& uc) {
+ stringstream ss;
+ ss << uc.getType();
+ string t = ss.str();
+ size_t i = 0;
+ // replace everything that isn't in [a-zA-Z0-9_] with an _
+ while((i = t.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_", i)) != string::npos) {
+ t.replace(i, 1, 1, '_');
+ }
+ return out << "uc_" << t << '_' << uc.getIndex();
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file uninterpreted_constant.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 Representation of constants of uninterpreted sorts
+ **
+ ** Representation of constants of uninterpreted sorts.
+ **/
+
+#include "cvc4_public.h"
+
+#pragma once
+
+#include "expr/type.h"
+#include <iostream>
+
+namespace CVC4 {
+
+class CVC4_PUBLIC UninterpretedConstant {
+ const Type d_type;
+ const Integer d_index;
+
+public:
+
+ UninterpretedConstant(Type type, Integer index) throw(IllegalArgumentException) :
+ d_type(type),
+ d_index(index) {
+ //CheckArgument(type.isSort(), type, "uninterpreted constants can only be created for uninterpreted sorts, not `%s'", type.toString().c_str());
+ CheckArgument(index >= 0, index, "index >= 0 required for uninterpreted constant index, not `%s'", index.toString().c_str());
+ }
+
+ ~UninterpretedConstant() throw() {
+ }
+
+ Type getType() const throw() {
+ return d_type;
+ }
+ const Integer& getIndex() const throw() {
+ return d_index;
+ }
+
+ bool operator==(const UninterpretedConstant& uc) const throw() {
+ return d_type == uc.d_type && d_index == uc.d_index;
+ }
+ bool operator!=(const UninterpretedConstant& uc) const throw() {
+ return !(*this == uc);
+ }
+
+ bool operator<(const UninterpretedConstant& uc) const throw() {
+ return d_type < uc.d_type ||
+ (d_type == uc.d_type && d_index < uc.d_index);
+ }
+ bool operator<=(const UninterpretedConstant& uc) const throw() {
+ return d_type < uc.d_type ||
+ (d_type == uc.d_type && d_index <= uc.d_index);
+ }
+ bool operator>(const UninterpretedConstant& uc) const throw() {
+ return !(*this <= uc);
+ }
+ bool operator>=(const UninterpretedConstant& uc) const throw() {
+ return !(*this < uc);
+ }
+
+};/* class UninterpretedConstant */
+
+std::ostream& operator<<(std::ostream& out, const UninterpretedConstant& uc) CVC4_PUBLIC;
+
+/**
+ * Hash function for the BitVector constants.
+ */
+struct CVC4_PUBLIC UninterpretedConstantHashFunction {
+ inline size_t operator()(const UninterpretedConstant& uc) const {
+ return TypeHashFunction()(uc.getType()) * IntegerHashFunction()(uc.getIndex());
+ }
+};/* struct UninterpretedConstantHashFunction */
+
+}/* CVC4 namespace */
--- /dev/null
+%{
+#include "expr/uninterpreted_constant.h"
+%}
+
+%rename(less) CVC4::UninterpretedConstant::operator<(const UninterpretedConstant&) const;
+%rename(lessEqual) CVC4::UninterpretedConstant::operator<=(const UninterpretedConstant&) const;
+%rename(greater) CVC4::UninterpretedConstant::operator>(const UninterpretedConstant&) const;
+%rename(greaterEqual) CVC4::UninterpretedConstant::operator>=(const UninterpretedConstant&) const;
+
+%rename(equals) CVC4::UninterpretedConstant::operator==(const UninterpretedConstant&) const;
+%ignore CVC4::UninterpretedConstant::operator!=(const UninterpretedConstant&) const;
+
+%rename(apply) CVC4::UninterpretedConstantHashFunction::operator()(const UninterpretedConstant&) const;
+
+%ignore CVC4::operator<<(std::ostream&, const UninterpretedConstant&);
+
+%include "expr/uninterpreted_constant.h"
#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 */
libmain.a \
@builddir@/../parser/libcvc4parser.la \
@builddir@/../libcvc4.la \
- @builddir@/../util/libstatistics.la \
$(READLINE_LIBS)
if CVC4_NEEDS_REPLACEMENT_FUNCTIONS
pcvc4_LDADD += \
libmain.a \
@builddir@/../parser/libcvc4parser.la \
@builddir@/../libcvc4.la \
- @builddir@/../util/libstatistics.la \
$(READLINE_LIBS)
if CVC4_NEEDS_REPLACEMENT_FUNCTIONS
cvc4_LDADD += \
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)
** \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 {
#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 {
** 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;
** 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;
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) ||
}
#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;
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;
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;
** 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>
# 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 {
/* 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
#endif /* HAVE_LIBREADLINE */
}/* CVC4 namespace */
-
#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 {
**
** 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;
#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
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module DRIVER "main/options.h" Driver
-
-common-option version -V --version/ bool
- identify this CVC4 binary
-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"
- show CVC4 static configuration
-
-option - --show-debug-tags void :handler CVC4::main::showDebugTags :handler-include "main/options_handlers.h"
- show all available tags for debugging
-option - --show-trace-tags void :handler CVC4::main::showTraceTags :handler-include "main/options_handlers.h"
- show all available tags for tracing
-
-expert-option earlyExit --early-exit bool :default true
- do not run destructors at exit; default on except in debug builds
-
-# 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"
- 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)
-option threadArgv std::vector<std::string> :include <vector> <string>
- Thread configuration (a string to be passed to parseOptions)
-option thread_id int :default -1
- Thread ID, for internal use in case of multi-threaded run
-option sharingFilterByLength --filter-lemma-length=N int :default -1 :read-write
- don't share (among portfolio threads) lemmas strictly longer than N
-option fallbackSequential --fallback-sequential bool :default false
- Switch to sequential mode (instead of printing an error) if it can't be solved in portfolio mode
-option incrementalParallel --incremental-parallel bool :default false :link --incremental
- Use parallel solver even in incremental mode (may print 'unknown's at times)
-
-option interactive : --interactive bool :read-write
- force interactive/non-interactive mode
-undocumented-option interactivePrompt /--no-interactive-prompt bool :default true
- turn off interactive prompting while in interactive mode
-
-# error behaviors (--immediate-exit is default in cases we support, thus no options)
-option continuedExecution --continued-execution/ bool :default false :link "--interactive --no-interactive-prompt"/
- continue executing commands, even on error
-
-option segvSpin --segv-spin bool :default false
- spin on segfault/other crash waiting for gdb
-undocumented-alias --segv-nospin = --no-segv-spin
-
-expert-option tearDownIncremental : --tear-down-incremental bool :default false
- implement PUSH/POP/multi-query by destroying and recreating SmtEngine
-
-expert-option waitToJoin --wait-to-join bool :default true
- wait for other threads to join before quitting
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \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 */
#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 {
#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 {
** \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;
{
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) {
// 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
*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();
#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 {
#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;
-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 = \
../../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 \
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 "$<" "$<" ) >"$@"
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 \
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 \
+
# 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 \
# 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 \
+ ) > "$@"
-#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
# 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
-
--- /dev/null
+/********************* */
+/*! \file arith_heuristic_pivot_rule.cpp
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: Tim King
+ ** 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 "options/arith_heuristic_pivot_rule.h"
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, ErrorSelectionRule rule) {
+ switch(rule) {
+ case MINIMUM_AMOUNT:
+ out << "MINIMUM_AMOUNT";
+ break;
+ case VAR_ORDER:
+ out << "VAR_ORDER";
+ break;
+ case MAXIMUM_AMOUNT:
+ out << "MAXIMUM_AMOUNT";
+ break;
+ default:
+ out << "ArithHeuristicPivotRule!UNKNOWN";
+ }
+
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file arith_heuristic_pivot_rule.h
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: Tim King
+ ** 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_public.h"
+
+#ifndef __CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H
+#define __CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H
+
+#include <iostream>
+
+namespace CVC4 {
+
+enum ErrorSelectionRule {
+ VAR_ORDER,
+ MINIMUM_AMOUNT,
+ MAXIMUM_AMOUNT,
+ SUM_METRIC
+};
+
+std::ostream& operator<<(std::ostream& out, ErrorSelectionRule rule) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H */
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module ARITH "options/arith_options.h" Arithmetic theory
+
+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::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.
+# If this is negative, the number of pivots done is the number of variables.
+# If this is not set by the user, different logics are free to chose different
+# defaults.
+option arithHeuristicPivots --heuristic-pivots=N int16_t :default 0 :read-write
+ the number of times to apply the heuristic pivot rule; if N < 0, this defaults to the number of variables; if this is unset, this is tuned by the logic selection
+
+# The maximum number of variable order pivots to do per invocation of simplex.
+# If this is negative, the number of pivots done is unlimited.
+# If this is not set by the user, different logics are free to chose different
+# defaults.
+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::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
+option arithSimplexCheckPeriod --simplex-check-period=N uint16_t :default 200
+ the number of pivots to do in simplex before rechecking for a conflict on all variables
+
+# This is the pivots per basic variable that can be done using heuristic choices
+# before variable order must be used.
+# If this is not set by the user, different logics are free to chose different
+# defaults.
+option arithPivotThreshold --pivot-threshold=N uint16_t :default 2 :read-write
+ sets the number of pivots using --pivot-rule per basic variable per simplex instance before using variable order
+
+option arithPropagateMaxLength --prop-row-length=N uint16_t :default 16
+ sets the maximum row length to be used in propagation
+
+option arithDioSolver /--disable-dio-solver bool :default true
+ turns off Linear Diophantine Equation solver (Griggio, JSAT 2012)
+
+# Whether to split (= x y) into (and (<= x y) (>= x y)) in
+# arithmetic preprocessing.
+option arithRewriteEq --enable-arith-rewrite-equalities/--disable-arith-rewrite-equalities bool :default false :read-write
+ turns on the preprocessing rewrite turning equalities into a conjunction of inequalities
+/turns off the preprocessing rewrite turning equalities into a conjunction of inequalities
+
+
+option arithMLTrick miplib-trick --enable-miplib-trick/--disable-miplib-trick bool :default false
+ turns on the preprocessing step of attempting to infer bounds on miplib problems
+/turns off the preprocessing step of attempting to infer bounds on miplib problems
+
+option arithMLTrickSubstitutions miplib-trick-subs --miplib-trick-subs=N unsigned :default 1
+ do substitution for miplib 'tmp' vars if defined in <= N eliminated vars
+
+option doCutAllBounded --cut-all-bounded bool :default false :read-write
+ turns on the integer solving step of periodically cutting all integer variables that have both upper and lower bounds
+/turns off the integer solving step of periodically cutting all integer variables that have both upper and lower bounds
+
+option maxCutsInContext --maxCutsInContext unsigned :default 65535
+ maximum cuts in a given context before signalling a restart
+
+option revertArithModels --revert-arith-models-on-unsat bool :default false
+ revert the arithmetic model to a known safe model on unsat if one is cached
+
+option havePenalties --fc-penalties bool :default false :read-write
+ turns on degenerate pivot penalties
+/turns off degenerate pivot penalties
+
+option useFC --use-fcsimplex bool :default false :read-write
+ use focusing and converging simplex (FMCAD 2013 submission)
+
+option useSOI --use-soi bool :default false :read-write
+ use sum of infeasibility simplex (FMCAD 2013 submission)
+
+option restrictedPivots --restrict-pivots bool :default true :read-write
+ have a pivot cap for simplex at effort levels below fullEffort
+
+option collectPivots --collect-pivot-stats bool :default false :read-write
+ collect the pivot history
+
+option useApprox --use-approx bool :default false :read-write
+ attempt to use an approximate solver
+
+option maxApproxDepth --approx-branch-depth int16_t :default 200 :read-write
+ maximum branch depth the approximate solver is allowed to take
+
+option exportDioDecompositions --dio-decomps bool :default false :read-write
+ let skolem variables for integer divisibility constraints leak from the dio solver
+
+option newProp --new-prop bool :default false :read-write
+ use the new row propagation system
+
+option arithPropAsLemmaLength --arith-prop-clauses uint16_t :default 8 :read-write
+ rows shorter than this are propagated as clauses
+
+option soiQuickExplain --soi-qe bool :default false :read-write
+ use quick explain to minimize the sum of infeasibility conflicts
+
+option rewriteDivk rewrite-divk --rewrite-divk bool :default false :read-write
+ rewrite division and mod when by a constant into linear terms
+
+option trySolveIntStandardEffort --se-solve-int bool :default false
+ attempt to use the approximate solve integer method on standard effort
+
+option replayFailureLemma --lemmas-on-replay-failure bool :default false
+ attempt to use external lemmas if approximate solve integer failed
+
+option dioSolverTurns --dio-turns int :default 10
+ turns in a row dio solver cutting gets
+
+option rrTurns --rr-turns int :default 3
+ round robin turn
+
+option dioRepeat --dio-repeat bool :default false
+ handle dio solver constraints in mass or one at a time
+
+option replayEarlyCloseDepths --replay-early-close-depth int :default 1
+ multiples of the depths to try to close the approx log eagerly
+
+option replayFailurePenalty --replay-failure-penalty int :default 100
+ number of solve integer attempts to skips after a numeric failure
+
+option replayNumericFailurePenalty --replay-num-err-penalty int :default 4194304
+ number of solve integer attempts to skips after a numeric failure
+
+option replayRejectCutSize --replay-reject-cut unsigned :default 25500
+ maximum complexity of any coefficient while replaying cuts
+
+option lemmaRejectCutSize --replay-lemma-reject-cut unsigned :default 25500
+ maximum complexity of any coefficient while outputing replaying cut lemmas
+
+option soiApproxMajorFailure --replay-soi-major-threshold double :default .01
+ threshold for a major tolerance failure by the approximate solver
+
+option soiApproxMajorFailurePen --replay-soi-major-threshold-pen int :default 50
+ threshold for a major tolerance failure by the approximate solver
+
+option soiApproxMinorFailure --replay-soi-minor-threshold double :default .0001
+ threshold for a minor tolerance failure by the approximate solver
+
+option soiApproxMinorFailurePen --replay-soi-minor-threshold-pen int :default 10
+ threshold for a minor tolerance failure by the approximate solver
+
+option ppAssertMaxSubSize --pp-assert-max-sub-size unsigned :default 2
+ threshold for substituting an equality in ppAssert
+
+option maxReplayTree --max-replay-tree int :default 512
+ threshold for attempting to replay a tree
+
+
+option pbRewrites --pb-rewrites bool :default false
+ apply pseudo boolean rewrites
+
+option pbRewriteThreshold --pb-rewrite-threshold int :default 256
+ threshold of number of pseudoboolean variables to have before doing rewrites
+
+endmodule
--- /dev/null
+/********************* */
+/*! \file arith_propagation_mode.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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "options/arith_propagation_mode.h"
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, ArithPropagationMode mode) {
+ switch(mode) {
+ case NO_PROP:
+ out << "NO_PROP";
+ break;
+ case UNATE_PROP:
+ out << "UNATE_PROP";
+ break;
+ case BOUND_INFERENCE_PROP:
+ out << "BOUND_INFERENCE_PROP";
+ break;
+ case BOTH_PROP:
+ out << "BOTH_PROP";
+ break;
+ default:
+ out << "ArithPropagationMode!UNKNOWN";
+ }
+
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file arith_propagation_mode.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_public.h"
+
+#ifndef __CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H
+#define __CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H
+
+#include <iostream>
+
+namespace CVC4 {
+
+enum ArithPropagationMode {
+ NO_PROP,
+ UNATE_PROP,
+ BOUND_INFERENCE_PROP,
+ BOTH_PROP
+};
+
+std::ostream& operator<<(std::ostream& out, ArithPropagationMode rule) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H */
--- /dev/null
+/********************* */
+/*! \file arith_unate_lemma_mode.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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "options/arith_unate_lemma_mode.h"
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, ArithUnateLemmaMode mode) {
+ switch(mode) {
+ case NO_PRESOLVE_LEMMAS:
+ out << "NO_PRESOLVE_LEMMAS";
+ break;
+ case INEQUALITY_PRESOLVE_LEMMAS:
+ out << "INEQUALITY_PRESOLVE_LEMMAS";
+ break;
+ case EQUALITY_PRESOLVE_LEMMAS:
+ out << "EQUALITY_PRESOLVE_LEMMAS";
+ break;
+ case ALL_PRESOLVE_LEMMAS:
+ out << "ALL_PRESOLVE_LEMMAS";
+ break;
+ default:
+ out << "ArithUnateLemmaMode!UNKNOWN";
+ }
+
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file arith_unate_lemma_mode.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_public.h"
+
+#ifndef __CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H
+#define __CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H
+
+#include <iostream>
+
+namespace CVC4 {
+
+typedef enum {
+ NO_PRESOLVE_LEMMAS,
+ INEQUALITY_PRESOLVE_LEMMAS,
+ EQUALITY_PRESOLVE_LEMMAS,
+ ALL_PRESOLVE_LEMMAS
+} ArithUnateLemmaMode;
+
+std::ostream& operator<<(std::ostream& out, ArithUnateLemmaMode rule) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H */
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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)
+
+option arraysLazyRIntro1 --arrays-lazy-rintro1 bool :default true :read-write
+ turn on optimization to only perform RIntro1 rule lazily (see Jovanovic/Barrett 2012: Being Careful with Theory Combination)
+
+option arraysModelBased --arrays-model-based bool :default false :read-write
+ turn on model-based array solver
+
+option arraysEagerIndexSplitting --arrays-eager-index bool :default true :read-write
+ turn on eager index splitting for generated array lemmas
+
+option arraysEagerLemmas --arrays-eager-lemmas bool :default false :read-write
+ turn on eager lemma generation for arrays
+
+option arraysConfig --arrays-config int :default 0 :read-write
+ set different array option configurations - for developers only
+
+option arraysReduceSharing --arrays-reduce-sharing bool :default false :read-write
+ use model information to reduce size of care graph for arrays
+
+option arraysPropagate --arrays-prop int :default 2 :read-write
+ propagation effort for arrays: 0 is none, 1 is some, 2 is full
+
+endmodule
--- /dev/null
+/********************* */
+/*! \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 */
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
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
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
+++ /dev/null
-/********************* */
-/*! \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 */
-
--- /dev/null
+/********************* */
+/*! \file boolean_term_conversion_mode.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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+#include "options/boolean_term_conversion_mode.h"
+
+#include <iostream>
+
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, theory::booleans::BooleanTermConversionMode mode) {
+ switch(mode) {
+ case theory::booleans::BOOLEAN_TERM_CONVERT_TO_BITVECTORS:
+ out << "BOOLEAN_TERM_CONVERT_TO_BITVECTORS";
+ break;
+ case theory::booleans::BOOLEAN_TERM_CONVERT_TO_DATATYPES:
+ out << "BOOLEAN_TERM_CONVERT_TO_DATATYPES";
+ break;
+ case theory::booleans::BOOLEAN_TERM_CONVERT_NATIVE:
+ out << "BOOLEAN_TERM_CONVERT_NATIVE";
+ break;
+ default:
+ out << "BooleanTermConversionMode!UNKNOWN";
+ }
+
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file boolean_term_conversion_mode.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__BOOLEAN_TERM_CONVERSION_MODE_H
+#define __CVC4__THEORY__BOOLEANS__BOOLEAN_TERM_CONVERSION_MODE_H
+
+#include <iostream>
+
+namespace CVC4 {
+namespace theory {
+namespace booleans {
+
+typedef enum {
+ /**
+ * Convert Boolean terms to bitvectors of size 1.
+ */
+ BOOLEAN_TERM_CONVERT_TO_BITVECTORS,
+ /**
+ * Convert Boolean terms to enumerations in the Datatypes theory.
+ */
+ BOOLEAN_TERM_CONVERT_TO_DATATYPES,
+ /**
+ * Convert Boolean terms to enumerations in the Datatypes theory IF
+ * used in a datatypes context, otherwise to a bitvector of size 1.
+ */
+ BOOLEAN_TERM_CONVERT_NATIVE
+
+} BooleanTermConversionMode;
+
+}/* CVC4::theory::booleans namespace */
+}/* CVC4::theory namespace */
+
+std::ostream& operator<<(std::ostream& out, theory::booleans::BooleanTermConversionMode mode) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__THEORY__BOOLEANS__BOOLEAN_TERM_CONVERSION_MODE_H */
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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 "options/boolean_term_conversion_mode.h" :handler CVC4::options::stringToBooleanTermConversionMode :handler-include "options/options_handler_interface.h"
+ policy for converting Boolean terms
+
+endmodule
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module BUILTIN "options/builtin_options.h" Builtin theory
+
+endmodule
--- /dev/null
+/********************* */
+/*! \file bitblast_mode.cpp
+ ** \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 Bitblast modes for bit-vector solver.
+ **
+ ** Bitblast modes for bit-vector solver.
+ **/
+
+#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";
+ break;
+ case theory::bv::BITBLAST_MODE_EAGER:
+ out << "BITBLAST_MODE_EAGER";
+ break;
+ default:
+ out << "BitblastMode:UNKNOWN![" << unsigned(mode) << "]";
+ }
+
+ return out;
+}
+
+std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode) {
+ switch(mode) {
+ case theory::bv::BITVECTOR_SLICER_ON:
+ out << "BITVECTOR_SLICER_ON";
+ break;
+ case theory::bv::BITVECTOR_SLICER_OFF:
+ out << "BITVECTOR_SLICER_OFF";
+ break;
+ case theory::bv::BITVECTOR_SLICER_AUTO:
+ out << "BITVECTOR_SLICER_AUTO";
+ break;
+ default:
+ out << "BvSlicerMode:UNKNOWN![" << unsigned(mode) << "]";
+ }
+
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file bitblast_mode.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 Bitblasting modes for bit-vector solver.
+ **
+ ** Bitblasting modes for bit-vector solver.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__THEORY__BV__BITBLAST_MODE_H
+#define __CVC4__THEORY__BV__BITBLAST_MODE_H
+
+#include <iostream>
+
+namespace CVC4 {
+namespace theory {
+namespace bv {
+
+/** Enumeration of bit-blasting modes */
+enum BitblastMode {
+
+ /**
+ * Lazy bit-blasting that separates boolean reasoning
+ * from term reasoning.
+ */
+ BITBLAST_MODE_LAZY,
+
+ /**
+ * Bit-blast eagerly to the bit-vector SAT solver.
+ */
+ BITBLAST_MODE_EAGER
+};/* enum BitblastMode */
+
+/** Enumeration of bit-vector equality slicer mode */
+enum BvSlicerMode {
+
+ /**
+ * Force the slicer on.
+ */
+ BITVECTOR_SLICER_ON,
+
+ /**
+ * Slicer off.
+ */
+ BITVECTOR_SLICER_OFF,
+
+ /**
+ * Auto enable slicer if problem has only equalities.
+ */
+ BITVECTOR_SLICER_AUTO
+
+};/* enum BvSlicerMode */
+
+
+}/* CVC4::theory::bv namespace */
+}/* CVC4::theory namespace */
+
+std::ostream& operator<<(std::ostream& out, theory::bv::BitblastMode mode) CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__THEORY__BV__BITBLAST_MODE_H */
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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::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::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::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
+
+option bitvectorPropagate --bv-propagate bool :default true :read-write :link --bitblast=lazy
+ use bit-vector propagation in the bit-blaster
+
+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::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
+ turn on the inequality solver for the bit-vector theory (only if --bitblast=lazy)
+
+option bitvectorAlgebraicSolver --bv-algebraic-solver bool :default true :read-write :link --bitblast=lazy
+ turn on the algebraic solver for the bit-vector theory (only if --bitblast=lazy)
+
+expert-option bitvectorAlgebraicBudget --bv-algebraic-budget unsigned :default 1500 :read-write :link --bv-algebraic-solver
+ the budget allowed for the algebraic solver in number of SAT conflicts
+
+# General options
+
+option bitvectorToBool --bv-to-bool bool :default false :read-write
+ lift bit-vectors of size 1 to booleans when possible
+
+option bitvectorDivByZeroConst --bv-div-zero-const bool :default false :read-write
+ always return -1 on division by zero
+
+expert-option bvExtractArithRewrite --bv-extract-arith bool :default false :read-write
+ enable rewrite pushing extract [i:0] over arithmetic operations (can blow up)
+
+expert-option bvAbstraction --bv-abstraction bool :default false :read-write
+ mcm benchmark abstraction
+
+expert-option skolemizeArguments --bv-skolemize bool :default false :read-write
+ skolemize arguments for bv abstraction (only does something if --bv-abstraction is on)
+
+expert-option bvNumFunc --bv-num-func=NUM unsigned :default 1
+ number of function symbols in conflicts that are generalized
+
+expert-option bvEagerExplanations --bv-eager-explanations bool :default false :read-write
+ compute bit-blasting propagation explanations eagerly
+
+expert-option bitvectorQuickXplain --bv-quick-xplain bool :default false
+ minimize bv conflicts using the QuickXplain algorithm
+
+expert-option bvIntroducePow2 --bv-intro-pow2 bool :default false
+ introduce bitvector powers of two as a preprocessing pass
+
+endmodule
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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.
+# For example, by default cvc4 considers cdr( nil ) = nil. If this option is set, then
+# cdr( nil ) has no set value.
+expert-option dtRewriteErrorSel --dt-rewrite-error-sel bool :default false :read-write
+ rewrite incorrectly applied selectors to arbitrary ground term
+option dtForceAssignment --dt-force-assignment bool :default false :read-write
+ force the datatypes solver to give specific values to all datatypes terms before answering sat
+option dtBinarySplit --dt-binary-split bool :default false
+ do binary splits for datatype constructor types
+option cdtBisimilar --cdt-bisimilar bool :default true
+ do bisimilarity check for co-datatypes
+option dtCyclic --dt-cyclic bool :default true
+ do cyclicity check for datatypes
+
+endmodule
--- /dev/null
+/********************* */
+/*! \file decision_mode.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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "options/decision_mode.h"
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, decision::DecisionMode mode) {
+ switch(mode) {
+ case decision::DECISION_STRATEGY_INTERNAL:
+ out << "DECISION_STRATEGY_INTERNAL";
+ break;
+ case decision::DECISION_STRATEGY_JUSTIFICATION:
+ out << "DECISION_STRATEGY_JUSTIFICATION";
+ break;
+ default:
+ out << "DecisionMode:UNKNOWN![" << unsigned(mode) << "]";
+ }
+
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file decision_mode.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__SMT__DECISION_MODE_H
+#define __CVC4__SMT__DECISION_MODE_H
+
+#include <iostream>
+
+namespace CVC4 {
+namespace decision {
+
+/** Enumeration of decision strategies */
+enum DecisionMode {
+
+ /**
+ * Decision engine doesn't do anything. Use sat solver's internal
+ * heuristics
+ */
+ DECISION_STRATEGY_INTERNAL,
+
+ /**
+ * Use the justification heuristic
+ */
+ DECISION_STRATEGY_JUSTIFICATION,
+
+ /**
+ * Use may-relevancy.
+ */
+ DECISION_STRATEGY_RELEVANCY
+
+};/* enum DecisionMode */
+
+
+/** Enumeration of combining functions for computing internal weights */
+enum DecisionWeightInternal {
+ DECISION_WEIGHT_INTERNAL_OFF,
+ DECISION_WEIGHT_INTERNAL_MAX,
+ DECISION_WEIGHT_INTERNAL_SUM,
+ DECISION_WEIGHT_INTERNAL_USR1
+};/* enum DecisionInternalWeight */
+
+}/* CVC4::decision namespace */
+
+std::ostream& operator<<(std::ostream& out, decision::DecisionMode mode) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__SMT__DECISION_MODE_H */
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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::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 "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
+ use the weight nodes (locally, by looking at children) to direct recursive search
+
+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::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
--- /dev/null
+/********************* */
+/*! \file decision_weight.h
+ ** \verbatim
+ ** Original author: Kshitij Bansal
+ ** 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 Rewriter attributes
+ **
+ ** Rewriter attributes.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__OPTIONS__DECISION_WEIGHT_H
+#define __CVC4__OPTIONS__DECISION_WEIGHT_H
+
+namespace CVC4 {
+namespace decision {
+typedef uint64_t DecisionWeight;
+}/* CVC4::decision namespace */
+}/* CVC4 namespace */
+
+#endif /* __CVC4__OPTIONS__DECISION_WEIGHT_H */
--- /dev/null
+/********************* */
+/*! \file didyoumean.cpp
+ ** \verbatim
+ ** Original author: Kshitij Bansal
+ ** 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 did-you-mean style suggestions
+ **
+ ** ``What do you mean? I don't understand.'' An attempt to be more
+ ** helpful than that. Similar to one in git.
+ **
+ ** There are no dependencies on CVC4 (except namespace).
+ **/
+
+#include "options/didyoumean.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+namespace CVC4 {
+
+vector<string> DidYouMean::getMatch(string input) {
+ /** Magic numbers */
+ const int similarityThreshold = 7;
+ const unsigned numMatchesThreshold = 10;
+
+ set< pair<int, string> > scores;
+ vector<string> ret;
+ for(typeof(d_words.begin()) it = d_words.begin(); it != d_words.end(); ++it) {
+ string s = (*it);
+ if( s == input ) {
+ // if input matches AS-IS just return that
+ ret.push_back(s);
+ return ret;
+ }
+ int score;
+ if(s.compare(0, input.size(), input) == 0) {
+ score = 0;
+ } else {
+ score = editDistance(input, s) + 1;
+ }
+ scores.insert( make_pair(score, s) );
+ }
+ int min_score = scores.begin()->first;
+ for(typeof(scores.begin()) i = scores.begin();
+ i != scores.end(); ++i) {
+
+ // add if score is overall not too big, and also not much close to
+ // the score of the best suggestion
+ if(i->first < similarityThreshold && i->first <= min_score + 1) {
+ ret.push_back(i->second);
+#ifdef DIDYOUMEAN_DEBUG
+ cout << i->second << ": " << i->first << std::endl;
+#endif
+ }
+ }
+ if(ret.size() > numMatchesThreshold ) ret.resize(numMatchesThreshold);;
+ return ret;
+}
+
+
+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;
+ const int deleteCost = 3;
+ const int switchCaseCost = 0;
+
+ int len1 = a.size();
+ int len2 = b.size();
+
+ int* C[3];
+ int ii;
+ for (ii = 0; ii < 3; ++ii) {
+ C[ii] = new int[len2+1];
+ }
+ // int C[3][len2+1]; // cost
+
+ for(int j = 0; j <= len2; ++j) {
+ C[0][j] = j * addCost;
+ }
+
+ for(int i = 1; i <= len1; ++i) {
+
+ int cur = i%3;
+ int prv = (i+2)%3;
+ int pr2 = (i+1)%3;
+
+ C[cur][0] = i * deleteCost;
+
+ for(int j = 1; j <= len2; ++j) {
+
+ C[cur][j] = 100000000; // INF
+
+ if(a[i-1] == b[j-1]) {
+ // match
+ C[cur][j] = std::min(C[cur][j], C[prv][j-1]);
+ } else if(tolower(a[i-1]) == tolower(b[j-1])){
+ // switch case
+ C[cur][j] = std::min(C[cur][j], C[prv][j-1] + switchCaseCost);
+ } else {
+ // substitute
+ C[cur][j] = std::min(C[cur][j], C[prv][j-1] + substituteCost);
+ }
+
+ // swap
+ if(i >= 2 && j >= 2 && a[i-1] == b[j-2] && a[i-2] == b[j-1]) {
+ C[cur][j] = std::min(C[cur][j], C[pr2][j-2] + swapCost);
+ }
+
+ // add
+ C[cur][j] = std::min(C[cur][j], C[cur][j-1] + addCost);
+
+ // 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
+ }
+
+ }
+ int result = C[len1%3][len2];
+ for (ii = 0; ii < 3; ++ii) {
+ delete [] C[ii];
+ }
+ return result;
+}
+
+string DidYouMean::getMatchAsString(string input, int prefixNewLines, int suffixNewLines) {
+ vector<string> matches = getMatch(input);
+ ostringstream oss;
+ if(matches.size() > 0) {
+ while(prefixNewLines --> 0) { oss << endl; }
+ if(matches.size() == 1) {
+ oss << "Did you mean this?";
+ } else {
+ oss << "Did you mean any of these?";
+ }
+ for(unsigned i = 0; i < matches.size(); ++i) {
+ oss << "\n " << matches[i];
+ }
+ while(suffixNewLines --> 0) { oss << endl; }
+ }
+ return oss.str();
+}
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file didyoumean.h
+ ** \verbatim
+ ** Original author: Kshitij Bansal
+ ** 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 did-you-mean style suggestions.
+ **
+ ** ``What do you mean? I don't understand.'' An attempt to be more
+ ** helpful than that. Similar to one in git.
+ **
+ ** There are no dependencies on CVC4 (except namespace).
+ **/
+
+#pragma once
+
+#include <vector>
+#include <set>
+#include <string>
+
+namespace CVC4 {
+
+class DidYouMean {
+ typedef std::set<std::string> Words;
+ Words d_words;
+
+public:
+ DidYouMean() {}
+ ~DidYouMean() {}
+
+ DidYouMean(Words words) : d_words(words) {}
+
+ void addWord(std::string word) {
+ d_words.insert(word);
+ }
+
+ std::vector<std::string> getMatch(std::string input);
+
+ /**
+ * This is provided to make it easier to ensure consistency of
+ * output. Returned string is empty if there are no matches.
+ */
+ std::string getMatchAsString(std::string input, int prefixNewLines = 2, int suffixNewLines = 0);
+private:
+ int editDistance(const std::string& a, const std::string& b);
+};
+
+}/*CVC4 namespace*/
--- /dev/null
+/********************* */
+/*! \file didyoumean_test.cpp
+ ** \verbatim
+ ** Original author: Kshitij Bansal
+ ** 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
+ **/
+
+// 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
+
+#include "didyoumean.h"
+#include <iostream>
+#include <boost/foreach.hpp>
+using namespace std;
+using namespace CVC4;
+
+set<string> getDebugTags();
+set<string> getOptionStrings();
+
+int main()
+{
+ string a, b;
+
+ cin >> a;
+ cout << "Matches with debug tags:" << endl;
+ vector<string> ret = DidYouMean(getDebugTags()).getMatch(a);
+ BOOST_FOREACH(string s, ret) cout << s << endl;
+ cout << "Matches with option strings:" << endl;
+ ret = DidYouMean(getOptionStrings()).getMatch(a);
+ BOOST_FOREACH(string s, ret) cout << s << endl;
+}
+
+set<string> getDebugTags()
+{
+ set<string> a;
+ a.insert("CDInsertHashMap");
+ a.insert("CDTrailHashMap");
+ a.insert("TrailHashMap");
+ a.insert("approx");
+ a.insert("approx::");
+ a.insert("approx::branch");
+ a.insert("approx::checkCutOnPad");
+ a.insert("approx::constraint");
+ a.insert("approx::gmi");
+ a.insert("approx::gmiCut");
+ a.insert("approx::guessIsConstructable");
+ a.insert("approx::lemmas");
+ a.insert("approx::mir");
+ a.insert("approx::mirCut");
+ a.insert("approx::nodelog");
+ a.insert("approx::replayAssert");
+ a.insert("approx::replayLogRec");
+ a.insert("approx::soi");
+ a.insert("approx::solveMIP");
+ a.insert("approx::sumConstraints");
+ a.insert("approx::vars");
+ a.insert("arith");
+ a.insert("arith::addSharedTerm");
+ a.insert("arith::approx::cuts");
+ a.insert("arith::arithvar");
+ a.insert("arith::asVectors");
+ a.insert("arith::bt");
+ a.insert("arith::collectModelInfo");
+ a.insert("arith::conflict");
+ a.insert("arith::congruenceManager");
+ a.insert("arith::congruences");
+ a.insert("arith::consistency");
+ a.insert("arith::consistency::comitonconflict");
+ a.insert("arith::consistency::final");
+ a.insert("arith::consistency::initial");
+ a.insert("arith::constraint");
+ a.insert("arith::dio");
+ a.insert("arith::dio::ex");
+ a.insert("arith::dio::max");
+ a.insert("arith::div");
+ a.insert("arith::dual");
+ a.insert("arith::ems");
+ a.insert("arith::eq");
+ a.insert("arith::error::mem");
+ a.insert("arith::explain");
+ a.insert("arith::explainNonbasics");
+ a.insert("arith::findModel");
+ a.insert("arith::focus");
+ a.insert("arith::hasIntegerModel");
+ a.insert("arith::importSolution");
+ a.insert("arith::ite");
+ a.insert("arith::ite::red");
+ a.insert("arith::learned");
+ a.insert("arith::lemma");
+ a.insert("arith::nf");
+ a.insert("arith::oldprop");
+ a.insert("arith::pivot");
+ a.insert("arith::preprocess");
+ a.insert("arith::preregister");
+ a.insert("arith::presolve");
+ a.insert("arith::print_assertions");
+ a.insert("arith::print_model");
+ a.insert("arith::prop");
+ a.insert("arith::resolveOutPropagated");
+ a.insert("arith::restart");
+ a.insert("arith::rewriter");
+ a.insert("arith::selectPrimalUpdate");
+ a.insert("arith::simplex:row");
+ a.insert("arith::solveInteger");
+ a.insert("arith::static");
+ a.insert("arith::subsumption");
+ a.insert("arith::tracking");
+ a.insert("arith::tracking::mid");
+ a.insert("arith::tracking::post");
+ a.insert("arith::tracking::pre");
+ a.insert("arith::unate");
+ a.insert("arith::unate::conf");
+ a.insert("arith::update");
+ a.insert("arith::update::select");
+ a.insert("arith::value");
+ a.insert("array-pf");
+ a.insert("array-types");
+ a.insert("arrays");
+ a.insert("arrays-model-based");
+ a.insert("arrays::propagate");
+ a.insert("arrays::sharing");
+ a.insert("attrgc");
+ a.insert("basicsAtBounds");
+ a.insert("bitvector");
+ a.insert("bitvector-bb");
+ a.insert("bitvector-bitblast");
+ a.insert("bitvector-expandDefinition");
+ a.insert("bitvector-model");
+ a.insert("bitvector-preregister");
+ a.insert("bitvector-rewrite");
+ a.insert("bitvector::bitblaster");
+ a.insert("bitvector::core");
+ a.insert("bitvector::explain");
+ a.insert("bitvector::propagate");
+ a.insert("bitvector::sharing");
+ a.insert("bool-flatten");
+ a.insert("bool-ite");
+ a.insert("boolean-terms");
+ a.insert("bt");
+ a.insert("builder");
+ a.insert("bv-bitblast");
+ a.insert("bv-core");
+ a.insert("bv-core-model");
+ a.insert("bv-inequality");
+ a.insert("bv-inequality-explain");
+ a.insert("bv-inequality-internal");
+ a.insert("bv-rewrite");
+ a.insert("bv-slicer");
+ a.insert("bv-slicer-eq");
+ a.insert("bv-slicer-uf");
+ a.insert("bv-subtheory-inequality");
+ a.insert("bv-to-bool");
+ a.insert("bva");
+ a.insert("bvminisat");
+ a.insert("bvminisat::explain");
+ a.insert("bvminisat::search");
+ a.insert("cbqi");
+ a.insert("cbqi-debug");
+ a.insert("cbqi-prop-as-dec");
+ a.insert("cd_set_collection");
+ a.insert("cdlist");
+ a.insert("cdlist:cmm");
+ a.insert("cdqueue");
+ a.insert("check-inst");
+ a.insert("check-model::rep-checking");
+ a.insert("circuit-prop");
+ a.insert("cnf");
+ a.insert("constructInfeasiblityFunction");
+ a.insert("context");
+ a.insert("current");
+ a.insert("datatypes");
+ a.insert("datatypes-cycle-check");
+ a.insert("datatypes-cycles");
+ a.insert("datatypes-cycles-find");
+ a.insert("datatypes-debug");
+ a.insert("datatypes-explain");
+ a.insert("datatypes-gt");
+ a.insert("datatypes-inst");
+ a.insert("datatypes-labels");
+ a.insert("datatypes-output");
+ a.insert("datatypes-parametric");
+ a.insert("datatypes-prereg");
+ a.insert("datatypes-split");
+ a.insert("decision");
+ a.insert("decision::jh");
+ a.insert("determineArithVar");
+ a.insert("diamonds");
+ a.insert("dio::push");
+ a.insert("dt");
+ a.insert("dt-enum");
+ a.insert("dt-warn");
+ a.insert("dt::propagate");
+ a.insert("dualLike");
+ a.insert("effortlevel");
+ a.insert("ensureLiteral");
+ a.insert("eq");
+ a.insert("equality");
+ a.insert("equality::backtrack");
+ a.insert("equality::disequality");
+ a.insert("equality::evaluation");
+ a.insert("equality::graph");
+ a.insert("equality::internal");
+ a.insert("equality::trigger");
+ a.insert("equalsConstant");
+ a.insert("error");
+ a.insert("estimateWithCFE");
+ a.insert("expand");
+ a.insert("export");
+ a.insert("flipdec");
+ a.insert("fmc-entry-trie");
+ a.insert("fmc-interval-model-debug");
+ a.insert("fmf-card-debug");
+ a.insert("fmf-eval-debug");
+ a.insert("fmf-eval-debug2");
+ a.insert("fmf-exit");
+ a.insert("fmf-index-order");
+ a.insert("fmf-model-complete");
+ a.insert("fmf-model-cons");
+ a.insert("fmf-model-cons-debug");
+ a.insert("fmf-model-eval");
+ a.insert("fmf-model-prefs");
+ a.insert("fmf-model-req");
+ a.insert("focusDownToJust");
+ a.insert("focusDownToLastHalf");
+ a.insert("foo");
+ a.insert("gaussianElimConstructTableRow");
+ a.insert("gc");
+ a.insert("gc:leaks");
+ a.insert("getBestImpliedBound");
+ a.insert("getCeiling");
+ a.insert("getNewDomainValue");
+ a.insert("getPropagatedLiterals");
+ a.insert("getType");
+ a.insert("glpk::loadVB");
+ a.insert("guessCoefficientsConstructTableRow");
+ a.insert("guessIsConstructable");
+ a.insert("handleBorders");
+ a.insert("includeBoundUpdate");
+ a.insert("inst");
+ a.insert("inst-engine");
+ a.insert("inst-engine-ctrl");
+ a.insert("inst-engine-debug");
+ a.insert("inst-engine-phase-req");
+ a.insert("inst-engine-stuck");
+ a.insert("inst-fmf-ei");
+ a.insert("inst-match-gen");
+ a.insert("inst-trigger");
+ a.insert("integers");
+ a.insert("interactive");
+ a.insert("intersectConstantIte");
+ a.insert("isConst");
+ a.insert("ite");
+ a.insert("ite::atom");
+ a.insert("ite::constantIteEqualsConstant");
+ a.insert("ite::print-success");
+ a.insert("ite::simpite");
+ a.insert("lemma-ites");
+ a.insert("lemmaInputChannel");
+ a.insert("literal-matching");
+ a.insert("logPivot");
+ a.insert("matrix");
+ a.insert("minisat");
+ a.insert("minisat::lemmas");
+ a.insert("minisat::pop");
+ a.insert("minisat::remove-clause");
+ a.insert("minisat::search");
+ a.insert("miplib");
+ a.insert("model");
+ a.insert("model-getvalue");
+ a.insert("nf::tmp");
+ a.insert("nm");
+ a.insert("normal-form");
+ a.insert("options");
+ a.insert("paranoid:check_tableau");
+ a.insert("parser");
+ a.insert("parser-extra");
+ a.insert("parser-idt");
+ a.insert("parser-param");
+ a.insert("partial_model");
+ a.insert("pb");
+ a.insert("pickle");
+ a.insert("pickler");
+ a.insert("pipe");
+ a.insert("portfolio::outputmode");
+ a.insert("prec");
+ a.insert("preemptGetopt");
+ a.insert("proof:sat");
+ a.insert("proof:sat:detailed");
+ a.insert("prop");
+ a.insert("prop-explain");
+ a.insert("prop-value");
+ a.insert("prop::lemmas");
+ a.insert("propagateAsDecision");
+ a.insert("properConflict");
+ a.insert("qcf-ccbe");
+ a.insert("qcf-check-inst");
+ a.insert("qcf-eval");
+ a.insert("qcf-match");
+ a.insert("qcf-match-debug");
+ a.insert("qcf-nground");
+ a.insert("qint-check-debug2");
+ a.insert("qint-debug");
+ a.insert("qint-error");
+ a.insert("qint-model-debug");
+ a.insert("qint-model-debug2");
+ a.insert("qint-var-order-debug2");
+ a.insert("quant-arith");
+ a.insert("quant-arith-debug");
+ a.insert("quant-arith-simplex");
+ a.insert("quant-datatypes");
+ a.insert("quant-datatypes-debug");
+ a.insert("quant-req-phase");
+ a.insert("quant-uf-strategy");
+ a.insert("quantifiers");
+ a.insert("quantifiers-assert");
+ a.insert("quantifiers-check");
+ a.insert("quantifiers-dec");
+ a.insert("quantifiers-engine");
+ a.insert("quantifiers-flip");
+ a.insert("quantifiers-other");
+ a.insert("quantifiers-prereg");
+ a.insert("quantifiers-presolve");
+ a.insert("quantifiers-relevance");
+ a.insert("quantifiers-sat");
+ a.insert("quantifiers-substitute-debug");
+ a.insert("quantifiers::collectModelInfo");
+ a.insert("queueConditions");
+ a.insert("rationalToCfe");
+ a.insert("recentlyViolated");
+ a.insert("register");
+ a.insert("register::internal");
+ a.insert("relevant-trigger");
+ a.insert("removeFixed");
+ a.insert("rl");
+ a.insert("sat::minisat");
+ a.insert("selectFocusImproving");
+ a.insert("set_collection");
+ a.insert("sets");
+ a.insert("sets-assert");
+ a.insert("sets-checkmodel-ignore");
+ a.insert("sets-eq");
+ a.insert("sets-learn");
+ a.insert("sets-lemma");
+ a.insert("sets-model");
+ a.insert("sets-model-details");
+ a.insert("sets-parent");
+ a.insert("sets-pending");
+ a.insert("sets-prop");
+ a.insert("sets-prop-details");
+ a.insert("sets-scrutinize");
+ a.insert("sets-terminfo");
+ a.insert("shared");
+ a.insert("shared-terms-database");
+ a.insert("shared-terms-database::assert");
+ a.insert("sharing");
+ a.insert("simple-trigger");
+ a.insert("simplify");
+ a.insert("smart-multi-trigger");
+ a.insert("smt");
+ a.insert("soi::findModel");
+ a.insert("soi::selectPrimalUpdate");
+ a.insert("solveRealRelaxation");
+ a.insert("sort");
+ a.insert("speculativeUpdate");
+ a.insert("strings");
+ a.insert("strings-explain");
+ a.insert("strings-explain-debug");
+ a.insert("strings-prereg");
+ a.insert("strings-propagate");
+ a.insert("substitution");
+ a.insert("substitution::internal");
+ a.insert("tableau");
+ a.insert("te");
+ a.insert("term-db-cong");
+ a.insert("theory");
+ a.insert("theory::assertions");
+ a.insert("theory::atoms");
+ a.insert("theory::bv::rewrite");
+ a.insert("theory::conflict");
+ a.insert("theory::explain");
+ a.insert("theory::idl");
+ a.insert("theory::idl::model");
+ a.insert("theory::internal");
+ a.insert("theory::propagate");
+ a.insert("trans-closure");
+ a.insert("treat-unknown-error");
+ a.insert("tuprec");
+ a.insert("typecheck-idt");
+ a.insert("typecheck-q");
+ a.insert("typecheck-r");
+ a.insert("uf");
+ a.insert("uf-ss");
+ a.insert("uf-ss-check-region");
+ a.insert("uf-ss-cliques");
+ a.insert("uf-ss-debug");
+ a.insert("uf-ss-disequal");
+ a.insert("uf-ss-na");
+ a.insert("uf-ss-region");
+ a.insert("uf-ss-region-debug");
+ a.insert("uf-ss-register");
+ a.insert("uf-ss-sat");
+ a.insert("uf::propagate");
+ a.insert("uf::sharing");
+ a.insert("ufgc");
+ a.insert("ufsymm");
+ a.insert("ufsymm:clauses");
+ a.insert("ufsymm:eq");
+ a.insert("ufsymm:match");
+ a.insert("ufsymm:norm");
+ a.insert("ufsymm:p");
+ a.insert("update");
+ a.insert("updateAndSignal");
+ a.insert("weak");
+ a.insert("whytheoryenginewhy");
+ return a;
+}
+
+set<string> getOptionStrings()
+{
+ const char* cmdlineOptions[] = {
+ "lang",
+ "output-lang",
+ "language",
+ "output-language",
+ "verbose",
+ "quiet",
+ "stats",
+ "no-stats",
+ "statistics",
+ "no-statistics",
+ "stats-every-query",
+ "no-stats-every-query",
+ "statistics-every-query",
+ "no-statistics-every-query",
+ "parse-only",
+ "no-parse-only",
+ "preprocess-only",
+ "no-preprocess-only",
+ "trace",
+ "debug",
+ "print-success",
+ "no-print-success",
+ "smtlib-strict",
+ "default-expr-depth",
+ "default-dag-thresh",
+ "print-expr-types",
+ "eager-type-checking",
+ "lazy-type-checking",
+ "no-type-checking",
+ "biased-ites",
+ "no-biased-ites",
+ "boolean-term-conversion-mode",
+ "theoryof-mode",
+ "use-theory",
+ "bitblast-eager",
+ "no-bitblast-eager",
+ "bitblast-share-lemmas",
+ "no-bitblast-share-lemmas",
+ "bitblast-eager-fullcheck",
+ "no-bitblast-eager-fullcheck",
+ "bv-inequality-solver",
+ "no-bv-inequality-solver",
+ "bv-core-solver",
+ "no-bv-core-solver",
+ "bv-to-bool",
+ "no-bv-to-bool",
+ "bv-propagate",
+ "no-bv-propagate",
+ "bv-eq",
+ "no-bv-eq",
+ "dt-rewrite-error-sel",
+ "no-dt-rewrite-error-sel",
+ "dt-force-assignment",
+ "unate-lemmas",
+ "arith-prop",
+ "heuristic-pivots",
+ "standard-effort-variable-order-pivots",
+ "error-selection-rule",
+ "simplex-check-period",
+ "pivot-threshold",
+ "prop-row-length",
+ "disable-dio-solver",
+ "enable-arith-rewrite-equalities",
+ "disable-arith-rewrite-equalities",
+ "enable-miplib-trick",
+ "disable-miplib-trick",
+ "miplib-trick-subs",
+ "cut-all-bounded",
+ "no-cut-all-bounded",
+ "maxCutsInContext",
+ "revert-arith-models-on-unsat",
+ "no-revert-arith-models-on-unsat",
+ "fc-penalties",
+ "no-fc-penalties",
+ "use-fcsimplex",
+ "no-use-fcsimplex",
+ "use-soi",
+ "no-use-soi",
+ "restrict-pivots",
+ "no-restrict-pivots",
+ "collect-pivot-stats",
+ "no-collect-pivot-stats",
+ "use-approx",
+ "no-use-approx",
+ "approx-branch-depth",
+ "dio-decomps",
+ "no-dio-decomps",
+ "new-prop",
+ "no-new-prop",
+ "arith-prop-clauses",
+ "soi-qe",
+ "no-soi-qe",
+ "rewrite-divk",
+ "no-rewrite-divk",
+ "se-solve-int",
+ "no-se-solve-int",
+ "lemmas-on-replay-failure",
+ "no-lemmas-on-replay-failure",
+ "dio-turns",
+ "rr-turns",
+ "dio-repeat",
+ "no-dio-repeat",
+ "replay-early-close-depth",
+ "replay-failure-penalty",
+ "replay-num-err-penalty",
+ "replay-reject-cut",
+ "replay-lemma-reject-cut",
+ "replay-soi-major-threshold",
+ "replay-soi-major-threshold-pen",
+ "replay-soi-minor-threshold",
+ "replay-soi-minor-threshold-pen",
+ "symmetry-breaker",
+ "no-symmetry-breaker",
+ "condense-function-values",
+ "no-condense-function-values",
+ "disable-uf-ss-regions",
+ "uf-ss-eager-split",
+ "no-uf-ss-eager-split",
+ "uf-ss-totality",
+ "no-uf-ss-totality",
+ "uf-ss-totality-limited",
+ "uf-ss-totality-sym-break",
+ "no-uf-ss-totality-sym-break",
+ "uf-ss-abort-card",
+ "uf-ss-explained-cliques",
+ "no-uf-ss-explained-cliques",
+ "uf-ss-simple-cliques",
+ "no-uf-ss-simple-cliques",
+ "uf-ss-deq-prop",
+ "no-uf-ss-deq-prop",
+ "disable-uf-ss-min-model",
+ "uf-ss-clique-splits",
+ "no-uf-ss-clique-splits",
+ "uf-ss-sym-break",
+ "no-uf-ss-sym-break",
+ "uf-ss-fair",
+ "no-uf-ss-fair",
+ "arrays-optimize-linear",
+ "no-arrays-optimize-linear",
+ "arrays-lazy-rintro1",
+ "no-arrays-lazy-rintro1",
+ "arrays-model-based",
+ "no-arrays-model-based",
+ "arrays-eager-index",
+ "no-arrays-eager-index",
+ "arrays-eager-lemmas",
+ "no-arrays-eager-lemmas",
+ "disable-miniscope-quant",
+ "disable-miniscope-quant-fv",
+ "disable-prenex-quant",
+ "disable-var-elim-quant",
+ "disable-ite-lift-quant",
+ "cnf-quant",
+ "no-cnf-quant",
+ "clause-split",
+ "no-clause-split",
+ "pre-skolem-quant",
+ "no-pre-skolem-quant",
+ "ag-miniscope-quant",
+ "no-ag-miniscope-quant",
+ "macros-quant",
+ "no-macros-quant",
+ "fo-prop-quant",
+ "no-fo-prop-quant",
+ "disable-smart-triggers",
+ "relevant-triggers",
+ "no-relevant-triggers",
+ "relational-triggers",
+ "no-relational-triggers",
+ "register-quant-body-terms",
+ "no-register-quant-body-terms",
+ "inst-when",
+ "eager-inst-quant",
+ "no-eager-inst-quant",
+ "full-saturate-quant",
+ "no-full-saturate-quant",
+ "literal-matching",
+ "enable-cbqi",
+ "no-enable-cbqi",
+ "cbqi-recurse",
+ "no-cbqi-recurse",
+ "user-pat",
+ "flip-decision",
+ "disable-quant-internal-reps",
+ "finite-model-find",
+ "no-finite-model-find",
+ "mbqi",
+ "mbqi-one-inst-per-round",
+ "no-mbqi-one-inst-per-round",
+ "mbqi-one-quant-per-round",
+ "no-mbqi-one-quant-per-round",
+ "fmf-inst-engine",
+ "no-fmf-inst-engine",
+ "disable-fmf-inst-gen",
+ "fmf-inst-gen-one-quant-per-round",
+ "no-fmf-inst-gen-one-quant-per-round",
+ "fmf-fresh-dc",
+ "no-fmf-fresh-dc",
+ "disable-fmf-fmc-simple",
+ "fmf-bound-int",
+ "no-fmf-bound-int",
+ "axiom-inst",
+ "quant-cf",
+ "no-quant-cf",
+ "quant-cf-mode",
+ "quant-cf-when",
+ "rewrite-rules",
+ "no-rewrite-rules",
+ "rr-one-inst-per-round",
+ "no-rr-one-inst-per-round",
+ "strings-exp",
+ "no-strings-exp",
+ "strings-lb",
+ "strings-fmf",
+ "no-strings-fmf",
+ "strings-eit",
+ "no-strings-eit",
+ "strings-alphabet-card",
+ "show-sat-solvers",
+ "random-freq",
+ "random-seed",
+ "restart-int-base",
+ "restart-int-inc",
+ "refine-conflicts",
+ "no-refine-conflicts",
+ "minisat-elimination",
+ "no-minisat-elimination",
+ "minisat-dump-dimacs",
+ "no-minisat-dump-dimacs",
+ "model-format",
+ "dump",
+ "dump-to",
+ "force-logic",
+ "simplification",
+ "no-simplification",
+ "static-learning",
+ "no-static-learning",
+ "produce-models",
+ "no-produce-models",
+ "check-models",
+ "no-check-models",
+ "dump-models",
+ "no-dump-models",
+ "proof",
+ "no-proof",
+ "check-proofs",
+ "no-check-proofs",
+ "dump-proofs",
+ "no-dump-proofs",
+ "produce-unsat-cores",
+ "no-produce-unsat-cores",
+ "produce-assignments",
+ "no-produce-assignments",
+ "interactive",
+ "no-interactive",
+ "ite-simp",
+ "no-ite-simp",
+ "on-repeat-ite-simp",
+ "no-on-repeat-ite-simp",
+ "simp-with-care",
+ "no-simp-with-care",
+ "simp-ite-compress",
+ "no-simp-ite-compress",
+ "unconstrained-simp",
+ "no-unconstrained-simp",
+ "repeat-simp",
+ "no-repeat-simp",
+ "simp-ite-hunt-zombies",
+ "sort-inference",
+ "no-sort-inference",
+ "incremental",
+ "no-incremental",
+ "abstract-values",
+ "no-abstract-values",
+ "model-u-dt-enum",
+ "no-model-u-dt-enum",
+ "tlimit",
+ "tlimit-per",
+ "rlimit",
+ "rlimit-per",
+ "rewrite-apply-to-const",
+ "no-rewrite-apply-to-const",
+ "replay",
+ "replay-log",
+ "decision",
+ "decision-threshold",
+ "decision-use-weight",
+ "no-decision-use-weight",
+ "decision-random-weight",
+ "decision-weight-internal",
+ "version",
+ "license",
+ "help",
+ "show-config",
+ "show-debug-tags",
+ "show-trace-tags",
+ "early-exit",
+ "no-early-exit",
+ "threads",
+ "threadN",
+ "filter-lemma-length",
+ "fallback-sequential",
+ "no-fallback-sequential",
+ "incremental-parallel",
+ "no-incremental-parallel",
+ "no-interactive-prompt",
+ "continued-execution",
+ "immediate-exit",
+ "segv-spin",
+ "no-segv-spin",
+ "segv-nospin",
+ "wait-to-join",
+ "no-wait-to-join",
+ "strict-parsing",
+ "no-strict-parsing",
+ "mmap",
+ "no-mmap",
+ "no-checking",
+ "no-filesystem-access",
+ "no-include-file",
+ "enable-idl-rewrite-equalities",
+ "disable-idl-rewrite-equalities",
+ "sets-propagate",
+ "no-sets-propagate",
+ "sets-eager-lemmas",
+ "no-sets-eager-lemmas",
+ NULL,
+ };/* cmdlineOptions */
+ int i = 0;
+ set<string> ret;
+ while(cmdlineOptions[i] != NULL) {
+ ret.insert(cmdlineOptions[i]);
+ i++;
+ }
+ return ret;
+}
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module EXPR "options/expr_options.h" Expression package
+
+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::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::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
+ type check expressions immediately on creation (debug builds only)
+/type check expressions only when necessary (default)
+
+# --no-type-checking will override any --early-type-checking or --lazy-type-checking option
+# --lazy-type-checking is linked because earlyTypeChecking should be set false too
+option typeChecking /--no-type-checking bool :default DO_SEMANTIC_CHECKS_BY_DEFAULT :link /--lazy-type-checking
+ never type check expressions
+
+option biasedITERemoval --biased-ites bool :default false
+ try the new remove ite pass that is biased against term ites appearing
+
+endmodule
+
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module FP "options/fp_options.h" Fp
+
+endmodule
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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)
+/disable rewriting equalities into two inequalities in IDL solver (default is disabled)
+
+endmodule
--- /dev/null
+/********************* */
+/*! \file language.cpp
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: none
+ ** Minor contributors (to current version): Francois Bobot, Andrew Reynolds
+ ** 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 Definition of input and output languages
+ **
+ ** Definition of input and output languages.
+ **/
+
+#include "options/language.h"
+
+namespace CVC4 {
+namespace language {
+
+InputLanguage toInputLanguage(OutputLanguage language) {
+ switch(language) {
+ case output::LANG_SMTLIB_V1:
+ case output::LANG_SMTLIB_V2_0:
+ case output::LANG_SMTLIB_V2_5:
+ case output::LANG_TPTP:
+ case output::LANG_CVC4:
+ case output::LANG_Z3STR:
+ case output::LANG_SYGUS:
+ // these entries directly correspond (by design)
+ return InputLanguage(int(language));
+
+ default: {
+ std::stringstream ss;
+ ss << "Cannot map output language `" << language
+ << "' to an input language.";
+ throw CVC4::Exception(ss.str());
+ }
+ }/* switch(language) */
+}/* toInputLanguage() */
+
+OutputLanguage toOutputLanguage(InputLanguage language) {
+ switch(language) {
+ case input::LANG_SMTLIB_V1:
+ case input::LANG_SMTLIB_V2_0:
+ case input::LANG_SMTLIB_V2_5:
+ case input::LANG_TPTP:
+ case input::LANG_CVC4:
+ case input::LANG_Z3STR:
+ case input::LANG_SYGUS:
+ // these entries directly correspond (by design)
+ return OutputLanguage(int(language));
+
+ default:
+ // Revert to the default (AST) language.
+ //
+ // We used to throw an exception here, but that's not quite right.
+ // We often call this while constructing exceptions, for one, and
+ // it's better to output SOMETHING related to the original
+ // exception rather than mask it with another exception. Also,
+ // the input language isn't always defined---e.g. during the
+ // initial phase of the main CVC4 driver while it determines which
+ // language is appropriate, and during unit tests. Also, when
+ // users are writing their own code against the library.
+ return output::LANG_AST;
+ }/* switch(language) */
+}/* toOutputLanguage() */
+
+OutputLanguage toOutputLanguage(std::string language) {
+ if(language == "cvc4" || language == "pl" ||
+ language == "presentation" || language == "native" ||
+ language == "LANG_CVC4") {
+ return output::LANG_CVC4;
+ } else if(language == "cvc3" || language == "LANG_CVC3") {
+ return output::LANG_CVC3;
+ } else if(language == "smtlib1" || language == "smt1" ||
+ language == "LANG_SMTLIB_V1") {
+ return output::LANG_SMTLIB_V1;
+ } else if(language == "smtlib" || language == "smt" ||
+ language == "smtlib2" || language == "smt2" ||
+ language == "smtlib2.0" || language == "smt2.0" ||
+ language == "LANG_SMTLIB_V2_0" || language == "LANG_SMTLIB_V2") {
+ return output::LANG_SMTLIB_V2_0;
+ } else if(language == "smtlib2.5" || language == "smt2.5" ||
+ language == "LANG_SMTLIB_V2_5") {
+ return output::LANG_SMTLIB_V2_5;
+ } else if(language == "tptp" || language == "LANG_TPTP") {
+ return output::LANG_TPTP;
+ } else if(language == "z3str" || language == "z3-str" ||
+ language == "LANG_Z3STR") {
+ return output::LANG_Z3STR;
+ } else if(language == "sygus" || language == "LANG_SYGUS") {
+ return output::LANG_SYGUS;
+ } else if(language == "ast" || language == "LANG_AST") {
+ return output::LANG_AST;
+ } else if(language == "auto" || language == "LANG_AUTO") {
+ return output::LANG_AUTO;
+ }
+
+ throw OptionException(std::string("unknown output language `" + language + "'"));
+}/* toOutputLanguage() */
+
+InputLanguage toInputLanguage(std::string language) {
+ if(language == "cvc4" || language == "pl" ||
+ language == "presentation" || language == "native" ||
+ language == "LANG_CVC4") {
+ return input::LANG_CVC4;
+ } else if(language == "smtlib1" || language == "smt1" ||
+ language == "LANG_SMTLIB_V1") {
+ return input::LANG_SMTLIB_V1;
+ } else if(language == "smtlib" || language == "smt" ||
+ language == "smtlib2" || language == "smt2" ||
+ language == "smtlib2.0" || language == "smt2.0" ||
+ language == "LANG_SMTLIB_V2_0" || language == "LANG_SMTLIB_V2") {
+ return input::LANG_SMTLIB_V2_0;
+ } else if(language == "smtlib2.5" || language == "smt2.5" ||
+ language == "LANG_SMTLIB_V2_5") {
+ return input::LANG_SMTLIB_V2_5;
+ } else if(language == "tptp" || language == "LANG_TPTP") {
+ return input::LANG_TPTP;
+ } else if(language == "z3str" || language == "z3-str" ||
+ language == "LANG_Z3STR") {
+ return input::LANG_Z3STR;
+ } else if(language == "sygus" || language == "LANG_SYGUS") {
+ return input::LANG_SYGUS;
+ } else if(language == "auto" || language == "LANG_AUTO") {
+ return input::LANG_AUTO;
+ }
+
+ throw OptionException(std::string("unknown input language `" + language + "'"));
+}/* toInputLanguage() */
+
+}/* CVC4::language namespace */
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file language.h
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: none
+ ** Minor contributors (to current version): Francois Bobot, Andrew Reynolds
+ ** 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 Definition of input and output languages
+ **
+ ** Definition of input and output languages.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__LANGUAGE_H
+#define __CVC4__LANGUAGE_H
+
+#include <sstream>
+#include <string>
+
+#include "base/exception.h"
+#include "options/option_exception.h"
+
+namespace CVC4 {
+namespace language {
+
+namespace input {
+
+enum CVC4_PUBLIC Language {
+ // SPECIAL "NON-LANGUAGE" LANGUAGES HAVE ENUM VALUE < 0
+
+ /** Auto-detect the language */
+ LANG_AUTO = -1,
+
+ // COMMON INPUT AND OUTPUT LANGUAGES HAVE ENUM VALUES IN [0,9]
+ // AND SHOULD CORRESPOND IN PLACEMENT WITH OUTPUTLANGUAGE
+ //
+ // EVEN IF A LANGUAGE ISN'T CURRENTLY SUPPORTED AS AN INPUT OR
+ // OUTPUT LANGUAGE, IF IT IS "IN PRINCIPLE" A COMMON LANGUAGE,
+ // INCLUDE IT HERE
+
+ /** The SMTLIB v1 input language */
+ LANG_SMTLIB_V1 = 0,
+ /** The SMTLIB v2.0 input language */
+ LANG_SMTLIB_V2_0,
+ /** The SMTLIB v2.5 input language */
+ LANG_SMTLIB_V2_5,
+ /** Backward-compatibility for enumeration naming */
+ LANG_SMTLIB_V2 = LANG_SMTLIB_V2_5,
+ /** The TPTP input language */
+ LANG_TPTP,
+ /** The CVC4 input language */
+ LANG_CVC4,
+ /** The Z3-str input language */
+ LANG_Z3STR,
+ /** The SyGuS input language */
+ LANG_SYGUS,
+
+ // START OUTPUT-ONLY LANGUAGES AT ENUM VALUE 10
+ // THESE ARE IN PRINCIPLE NOT POSSIBLE INPUT LANGUAGES
+
+ /** LANG_MAX is > any valid InputLanguage id */
+ LANG_MAX
+};/* enum Language */
+
+inline std::ostream& operator<<(std::ostream& out, Language lang) CVC4_PUBLIC;
+inline std::ostream& operator<<(std::ostream& out, Language lang) {
+ switch(lang) {
+ case LANG_AUTO:
+ out << "LANG_AUTO";
+ break;
+ case LANG_SMTLIB_V1:
+ out << "LANG_SMTLIB_V1";
+ break;
+ case LANG_SMTLIB_V2_0:
+ out << "LANG_SMTLIB_V2_0";
+ break;
+ case LANG_SMTLIB_V2_5:
+ out << "LANG_SMTLIB_V2_5";
+ break;
+ case LANG_TPTP:
+ out << "LANG_TPTP";
+ break;
+ case LANG_CVC4:
+ out << "LANG_CVC4";
+ break;
+ case LANG_Z3STR:
+ out << "LANG_Z3STR";
+ break;
+ case LANG_SYGUS:
+ out << "LANG_SYGUS";
+ break;
+ default:
+ out << "undefined_input_language";
+ }
+ return out;
+}
+
+}/* CVC4::language::input namespace */
+
+namespace output {
+
+enum CVC4_PUBLIC Language {
+ // SPECIAL "NON-LANGUAGE" LANGUAGES HAVE ENUM VALUE < 0
+
+ /** Match the output language to the input language */
+ LANG_AUTO = -1,
+
+ // COMMON INPUT AND OUTPUT LANGUAGES HAVE ENUM VALUES IN [0,9]
+ // AND SHOULD CORRESPOND IN PLACEMENT WITH INPUTLANGUAGE
+ //
+ // EVEN IF A LANGUAGE ISN'T CURRENTLY SUPPORTED AS AN INPUT OR
+ // OUTPUT LANGUAGE, IF IT IS "IN PRINCIPLE" A COMMON LANGUAGE,
+ // INCLUDE IT HERE
+
+ /** The SMTLIB v1 output language */
+ LANG_SMTLIB_V1 = input::LANG_SMTLIB_V1,
+ /** The SMTLIB v2.0 output language */
+ LANG_SMTLIB_V2_0 = input::LANG_SMTLIB_V2_0,
+ /** The SMTLIB v2.5 output language */
+ LANG_SMTLIB_V2_5 = input::LANG_SMTLIB_V2_5,
+ /** Backward-compatibility for enumeration naming */
+ LANG_SMTLIB_V2 = input::LANG_SMTLIB_V2,
+ /** The TPTP output language */
+ LANG_TPTP = input::LANG_TPTP,
+ /** The CVC4 output language */
+ LANG_CVC4 = input::LANG_CVC4,
+ /** The Z3-str output language */
+ LANG_Z3STR = input::LANG_Z3STR,
+ /** The sygus output language */
+ LANG_SYGUS = input::LANG_SYGUS,
+
+ // START OUTPUT-ONLY LANGUAGES AT ENUM VALUE 10
+ // THESE ARE IN PRINCIPLE NOT POSSIBLE INPUT LANGUAGES
+
+ /** The AST output language */
+ LANG_AST = 10,
+ /** The CVC3-compatibility output language */
+ LANG_CVC3,
+
+ /** LANG_MAX is > any valid OutputLanguage id */
+ LANG_MAX
+};/* enum Language */
+
+inline std::ostream& operator<<(std::ostream& out, Language lang) CVC4_PUBLIC;
+inline std::ostream& operator<<(std::ostream& out, Language lang) {
+ switch(lang) {
+ case LANG_SMTLIB_V1:
+ out << "LANG_SMTLIB_V1";
+ break;
+ case LANG_SMTLIB_V2_0:
+ out << "LANG_SMTLIB_V2_0";
+ break;
+ case LANG_SMTLIB_V2_5:
+ out << "LANG_SMTLIB_V2_5";
+ break;
+ case LANG_TPTP:
+ out << "LANG_TPTP";
+ break;
+ case LANG_CVC4:
+ out << "LANG_CVC4";
+ break;
+ case LANG_Z3STR:
+ out << "LANG_Z3STR";
+ break;
+ case LANG_SYGUS:
+ out << "LANG_SYGUS";
+ break;
+ case LANG_AST:
+ out << "LANG_AST";
+ break;
+ case LANG_CVC3:
+ out << "LANG_CVC3";
+ break;
+ default:
+ out << "undefined_output_language";
+ }
+ return out;
+}
+
+}/* CVC4::language::output namespace */
+
+}/* CVC4::language namespace */
+
+typedef language::input::Language InputLanguage;
+typedef language::output::Language OutputLanguage;
+
+namespace language {
+
+InputLanguage toInputLanguage(OutputLanguage language) CVC4_PUBLIC;
+OutputLanguage toOutputLanguage(InputLanguage language) CVC4_PUBLIC;
+InputLanguage toInputLanguage(std::string language) CVC4_PUBLIC;
+OutputLanguage toOutputLanguage(std::string language) CVC4_PUBLIC;
+
+}/* CVC4::language namespace */
+}/* CVC4 namespace */
+
+#endif /* __CVC4__LANGUAGE_H */
--- /dev/null
+%{
+#include "options/language.h"
+%}
+
+namespace CVC4 {
+ namespace language {
+ namespace input {
+ %ignore operator<<(std::ostream&, Language);
+ }/* CVC4::language::input namespace */
+
+ namespace output {
+ %ignore operator<<(std::ostream&, Language);
+ }/* CVC4::language::output namespace */
+ }/* CVC4::language namespace */
+}/* CVC4 namespace */
+
+// These clash in the monolithic Java namespace, so we rename them.
+%rename(InputLanguage) CVC4::language::input::Language;
+%rename(OutputLanguage) CVC4::language::output::Language;
+
+%rename(INPUT_LANG_AUTO) CVC4::language::input::LANG_AUTO;
+%rename(INPUT_LANG_SMTLIB_V1) CVC4::language::input::LANG_SMTLIB_V1;
+%rename(INPUT_LANG_SMTLIB_V2) CVC4::language::input::LANG_SMTLIB_V2;
+%rename(INPUT_LANG_SMTLIB_V2_0) CVC4::language::input::LANG_SMTLIB_V2_0;
+%rename(INPUT_LANG_SMTLIB_V2_5) CVC4::language::input::LANG_SMTLIB_V2_5;
+%rename(INPUT_LANG_TPTP) CVC4::language::input::LANG_TPTP;
+%rename(INPUT_LANG_CVC4) CVC4::language::input::LANG_CVC4;
+%rename(INPUT_LANG_MAX) CVC4::language::input::LANG_MAX;
+%rename(INPUT_LANG_Z3STR) CVC4::language::input::LANG_Z3STR;
+%rename(INPUT_LANG_SYGUS) CVC4::language::input::LANG_SYGUS;
+
+%rename(OUTPUT_LANG_AUTO) CVC4::language::output::LANG_AUTO;
+%rename(OUTPUT_LANG_SMTLIB_V1) CVC4::language::output::LANG_SMTLIB_V1;
+%rename(OUTPUT_LANG_SMTLIB_V2) CVC4::language::output::LANG_SMTLIB_V2;
+%rename(OUTPUT_LANG_SMTLIB_V2_0) CVC4::language::output::LANG_SMTLIB_V2_0;
+%rename(OUTPUT_LANG_SMTLIB_V2_5) CVC4::language::output::LANG_SMTLIB_V2_5;
+%rename(OUTPUT_LANG_TPTP) CVC4::language::output::LANG_TPTP;
+%rename(OUTPUT_LANG_CVC4) CVC4::language::output::LANG_CVC4;
+%rename(OUTPUT_LANG_AST) CVC4::language::output::LANG_AST;
+%rename(OUTPUT_LANG_MAX) CVC4::language::output::LANG_MAX;
+%rename(OUTPUT_LANG_Z3STR) CVC4::language::output::LANG_Z3STR;
+%rename(OUTPUT_LANG_SYGUS) CVC4::language::output::LANG_SYGUS;
+
+%include "options/language.h"
--- /dev/null
+
+#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 */
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module DRIVER "options/main_options.h" Driver
+
+common-option version -V --version/ bool
+ identify this CVC4 binary
+undocumented-alias --license = --version
+
+common-option help -h --help/ bool
+ full command line reference
+
+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::options::showDebugTags :handler-include "options/options_handler_interface.h"
+ show all available tags for debugging
+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
+ do not run destructors at exit; default on except in debug builds
+
+# 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::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)
+option threadArgv std::vector<std::string> :include <vector> <string>
+ Thread configuration (a string to be passed to parseOptions)
+option thread_id int :default -1
+ Thread ID, for internal use in case of multi-threaded run
+option sharingFilterByLength --filter-lemma-length=N int :default -1 :read-write
+ don't share (among portfolio threads) lemmas strictly longer than N
+option fallbackSequential --fallback-sequential bool :default false
+ Switch to sequential mode (instead of printing an error) if it can't be solved in portfolio mode
+option incrementalParallel --incremental-parallel bool :default false :link --incremental
+ Use parallel solver even in incremental mode (may print 'unknown's at times)
+
+option interactive : --interactive bool :read-write
+ force interactive/non-interactive mode
+undocumented-option interactivePrompt /--no-interactive-prompt bool :default true
+ turn off interactive prompting while in interactive mode
+
+# error behaviors (--immediate-exit is default in cases we support, thus no options)
+option continuedExecution --continued-execution/ bool :default false :link "--interactive --no-interactive-prompt"/
+ continue executing commands, even on error
+
+option segvSpin --segv-spin bool :default false
+ spin on segfault/other crash waiting for gdb
+undocumented-alias --segv-nospin = --no-segv-spin
+
+expert-option tearDownIncremental : --tear-down-incremental bool :default false
+ implement PUSH/POP/multi-query by destroying and recreating SmtEngine
+
+expert-option waitToJoin --wait-to-join bool :default true
+ wait for other threads to join before quitting
+
+endmodule
# 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.
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}
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
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
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
for handler in $handlers; do
run_handlers="$run_handlers
#line $lineno \"$kf\"
- $handler(option, optionarg, smt);"
+ $handler(option, optionarg, handler);"
done
else
run_handlers="
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\"
}"
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
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}
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}
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
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
#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
for handler in $handlers; do
run_handlers="$run_handlers
#line $lineno \"$kf\"
- $handler(\"$smtname\", optionarg, smt);
+ $handler(\"$smtname\", optionarg, handler);
"
done
fi
#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
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}
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}
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
# 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\"
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\"
#ifndef __CVC4__OPTION_EXCEPTION_H
#define __CVC4__OPTION_EXCEPTION_H
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
#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. */
/** 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() {
* 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 */
--- /dev/null
+/********************* */
+/*! \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 */
--- /dev/null
+/********************* */
+/*! \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 */
--- /dev/null
+/********************* */
+/*! \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 */
--- /dev/null
+%{
+#include "options/options_handler_interface.h"
+%}
+
+%include "options/options_handler_interface.h"
--- /dev/null
+/********************* */
+/*! \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 */
** 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"
# 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}
/** 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()) {
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");
* 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.
}
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.
* 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;
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
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module PARSER "options/parser_options.h" Parser
+
+common-option strictParsing --strict-parsing bool
+ be less tolerant of non-conforming inputs
+
+option memoryMap --mmap bool
+ memory map file input
+
+option semanticChecks /--no-checking bool :default DO_SEMANTIC_CHECKS_BY_DEFAULT :link /--no-type-checking
+ disable ALL semantic checks, including type checks
+
+option globalDeclarations global-declarations bool :default false
+ force all declarations and definitions to be global
+
+# this is to support security in the online version, and in other similar contexts
+# (--no-include-file disables filesystem access in TPTP and SMT2 parsers)
+# the name --no-include-file is legacy: it also now limits any filesystem access
+# (read or write) for example by using --dump-to (or the equivalent set-option) or
+# set-option :regular-output-channel/:diagnostic-output-channel. However, the main
+# driver is still permitted to read the input file given on the command-line if any.
+# creation/use of temp files are still permitted (but the paths aren't given by the
+# user). Also note this is only safe for the version invoked through the main driver,
+# there are ways via the API to get the CVC4 library to open a file for reading or
+# writing and thus leak information from an existing file, or overwrite an existing
+# file with malicious content.
+undocumented-option filesystemAccess /--no-filesystem-access bool :default true
+undocumented-alias --no-include-file = --no-filesystem-access
+
+endmodule
--- /dev/null
+/********************* */
+/*! \file printer_modes.cpp
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** 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 ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "options/printer_modes.h"
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, ModelFormatMode mode) {
+ switch(mode) {
+ case MODEL_FORMAT_MODE_DEFAULT:
+ out << "MODEL_FORMAT_MODE_DEFAULT";
+ break;
+ case MODEL_FORMAT_MODE_TABLE:
+ out << "MODEL_FORMAT_MODE_TABLE";
+ break;
+ default:
+ out << "ModelFormatMode:UNKNOWN![" << unsigned(mode) << "]";
+ }
+
+ return out;
+}
+
+std::ostream& operator<<(std::ostream& out, InstFormatMode mode) {
+ switch(mode) {
+ case INST_FORMAT_MODE_DEFAULT:
+ out << "INST_FORMAT_MODE_DEFAULT";
+ break;
+ case INST_FORMAT_MODE_SZS:
+ out << "INST_FORMAT_MODE_SZS";
+ break;
+ default:
+ out << "InstFormatMode:UNKNOWN![" << unsigned(mode) << "]";
+ }
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file printer_modes.h
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** 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 ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__PRINTER__MODES_H
+#define __CVC4__PRINTER__MODES_H
+
+#include <iostream>
+
+namespace CVC4 {
+
+/** Enumeration of model_format modes (how to print models from get-model command). */
+typedef enum {
+ /** default mode (print expressions in the output language format) */
+ MODEL_FORMAT_MODE_DEFAULT,
+ /** print functional values in a table format */
+ MODEL_FORMAT_MODE_TABLE,
+} ModelFormatMode;
+
+/** Enumeration of inst_format modes (how to print models from get-model command). */
+typedef enum {
+ /** default mode (print expressions in the output language format) */
+ INST_FORMAT_MODE_DEFAULT,
+ /** print as SZS proof */
+ INST_FORMAT_MODE_SZS,
+} InstFormatMode;
+
+std::ostream& operator<<(std::ostream& out, ModelFormatMode mode) CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream& out, InstFormatMode mode) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__PRINTER__MODEL_FORMAT_H */
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module PROOF "options/proof_options.h" Proof
+
+endmodule
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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)
+option satRandomSeed random-seed --random-seed=S uint32_t :default 0 :read-write
+ sets the random seed for the sat solver
+
+option satVarDecay double :default 0.95 :predicate options::less_equal(1.0) options::greater_equal(0.0)
+ variable activity decay factor for Minisat
+option satClauseDecay double :default 0.999 :predicate options::less_equal(1.0) options::greater_equal(0.0)
+ clause activity decay factor for Minisat
+option satRestartFirst --restart-int-base=N unsigned :default 25
+ sets the base restart interval for the sat solver (N=25 by default)
+option satRestartInc --restart-int-inc=F double :default 3.0 :predicate options::greater_equal(0.0)
+ sets the restart interval increase factor for the sat solver (F=3.0 by default)
+
+option sat_refine_conflicts --refine-conflicts bool :default false
+ refine theory conflict clauses (default false)
+
+option minisatUseElim --minisat-elimination bool :default true :read-write
+ use Minisat elimination
+
+option minisatDumpDimacs --minisat-dump-dimacs bool :default false
+ instead of solving minisat dumps the asserted clauses in Dimacs format
+
+endmodule
--- /dev/null
+/********************* */
+/*! \file quantifiers_modes.cpp
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** 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 ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+#include "options/quantifiers_modes.h"
+
+#include <iostream>
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, theory::quantifiers::InstWhenMode mode) {
+ switch(mode) {
+ case theory::quantifiers::INST_WHEN_PRE_FULL:
+ out << "INST_WHEN_PRE_FULL";
+ break;
+ case theory::quantifiers::INST_WHEN_FULL:
+ out << "INST_WHEN_FULL";
+ break;
+ case theory::quantifiers::INST_WHEN_FULL_LAST_CALL:
+ out << "INST_WHEN_FULL_LAST_CALL";
+ break;
+ case theory::quantifiers::INST_WHEN_LAST_CALL:
+ out << "INST_WHEN_LAST_CALL";
+ break;
+ default:
+ out << "InstWhenMode!UNKNOWN";
+ }
+
+ return out;
+}
+
+std::ostream& operator<<(std::ostream& out, theory::quantifiers::LiteralMatchMode mode) {
+ switch(mode) {
+ case theory::quantifiers::LITERAL_MATCH_NONE:
+ out << "LITERAL_MATCH_NONE";
+ break;
+ case theory::quantifiers::LITERAL_MATCH_PREDICATE:
+ out << "LITERAL_MATCH_PREDICATE";
+ break;
+ case theory::quantifiers::LITERAL_MATCH_EQUALITY:
+ out << "LITERAL_MATCH_EQUALITY";
+ break;
+ default:
+ out << "LiteralMatchMode!UNKNOWN";
+ }
+
+ return out;
+}
+
+std::ostream& operator<<(std::ostream& out, theory::quantifiers::MbqiMode mode) {
+ switch(mode) {
+ case theory::quantifiers::MBQI_GEN_EVAL:
+ out << "MBQI_GEN_EVAL";
+ break;
+ case theory::quantifiers::MBQI_NONE:
+ out << "MBQI_NONE";
+ break;
+ case theory::quantifiers::MBQI_FMC:
+ out << "MBQI_FMC";
+ break;
+ case theory::quantifiers::MBQI_ABS:
+ out << "MBQI_ABS";
+ break;
+ case theory::quantifiers::MBQI_TRUST:
+ out << "MBQI_TRUST";
+ break;
+ default:
+ out << "MbqiMode!UNKNOWN";
+ }
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file quantifiers_modes.h
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** 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 ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__BASE__QUANTIFIERS_MODES_H
+#define __CVC4__BASE__QUANTIFIERS_MODES_H
+
+#include <iostream>
+
+namespace CVC4 {
+namespace theory {
+namespace quantifiers {
+
+enum InstWhenMode {
+ /** Apply instantiation round before full effort (possibly at standard effort) */
+ INST_WHEN_PRE_FULL,
+ /** Apply instantiation round at full effort or above */
+ INST_WHEN_FULL,
+ /** Apply instantiation round at full effort, after all other theories finish, or above */
+ INST_WHEN_FULL_DELAY,
+ /** Apply instantiation round at full effort half the time, and last call always */
+ INST_WHEN_FULL_LAST_CALL,
+ /** Apply instantiation round at full effort after all other theories finish half the time, and last call always */
+ INST_WHEN_FULL_DELAY_LAST_CALL,
+ /** Apply instantiation round at last call only */
+ INST_WHEN_LAST_CALL,
+};
+
+enum LiteralMatchMode {
+ /** Do not consider polarity of patterns */
+ LITERAL_MATCH_NONE,
+ /** Consider polarity of boolean predicates only */
+ LITERAL_MATCH_PREDICATE,
+ /** Consider polarity of boolean predicates, as well as equalities */
+ LITERAL_MATCH_EQUALITY,
+};
+
+enum MbqiMode {
+ /** mbqi from CADE 24 paper */
+ MBQI_GEN_EVAL,
+ /** no mbqi */
+ MBQI_NONE,
+ /** default, mbqi from Section 5.4.2 of AJR thesis */
+ MBQI_FMC,
+ /** mbqi with integer intervals */
+ MBQI_FMC_INTERVAL,
+ /** abstract mbqi algorithm */
+ MBQI_ABS,
+ /** mbqi trust (produce no instantiations) */
+ MBQI_TRUST,
+};
+
+enum QcfWhenMode {
+ /** default, apply at full effort */
+ QCF_WHEN_MODE_DEFAULT,
+ /** apply at last call */
+ QCF_WHEN_MODE_LAST_CALL,
+ /** apply at standard effort */
+ QCF_WHEN_MODE_STD,
+ /** apply based on heuristics */
+ QCF_WHEN_MODE_STD_H,
+};
+
+enum QcfMode {
+ /** default, use qcf for conflicts only */
+ QCF_CONFLICT_ONLY,
+ /** use qcf for conflicts and propagations */
+ QCF_PROP_EQ,
+ /** use qcf for conflicts, propagations and heuristic instantiations */
+ QCF_PARTIAL,
+ /** use qcf for model checking */
+ QCF_MC,
+};
+
+enum UserPatMode {
+ /** use but do not trust */
+ USER_PAT_MODE_USE,
+ /** default, if patterns are supplied for a quantifier, use only those */
+ USER_PAT_MODE_TRUST,
+ /** resort to user patterns only when necessary */
+ USER_PAT_MODE_RESORT,
+ /** ignore user patterns */
+ USER_PAT_MODE_IGNORE,
+ /** interleave use/resort for user patterns */
+ USER_PAT_MODE_INTERLEAVE,
+};
+
+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,
+};
+
+enum CVC4_PUBLIC PrenexQuantMode {
+ /** default : prenex quantifiers without user patterns */
+ PRENEX_NO_USER_PAT,
+ /** prenex all */
+ PRENEX_ALL,
+ /** prenex none */
+ PRENEX_NONE,
+};
+
+enum CegqiFairMode {
+ /** enforce fairness by UF corresponding to datatypes size */
+ CEGQI_FAIR_UF_DT_SIZE,
+ /** enforce fairness by datatypes size */
+ CEGQI_FAIR_DT_SIZE,
+ /** enforce fairness by datatypes height bound */
+ CEGQI_FAIR_DT_HEIGHT_PRED,
+ /** do not use fair strategy for CEGQI */
+ CEGQI_FAIR_NONE,
+};
+
+enum TermDbMode {
+ /** consider all terms in master equality engine */
+ TERM_DB_ALL,
+ /** consider only relevant terms */
+ TERM_DB_RELEVANT,
+};
+
+enum IteLiftQuantMode {
+ /** do not lift ITEs in quantified formulas */
+ ITE_LIFT_QUANT_MODE_NONE,
+ /** only lift ITEs in quantified formulas if reduces the term size */
+ ITE_LIFT_QUANT_MODE_SIMPLE,
+ /** lift ITEs */
+ ITE_LIFT_QUANT_MODE_ALL,
+};
+
+enum SygusInvTemplMode {
+ /** synthesize I( x ) */
+ SYGUS_INV_TEMPL_MODE_NONE,
+ /** synthesize ( pre( x ) V I( x ) ) */
+ SYGUS_INV_TEMPL_MODE_PRE,
+ /** synthesize ( post( x ) ^ I( x ) ) */
+ SYGUS_INV_TEMPL_MODE_POST,
+};
+
+enum MacrosQuantMode {
+ /** infer all definitions */
+ MACROS_QUANT_MODE_ALL,
+ /** infer ground definitions */
+ MACROS_QUANT_MODE_GROUND,
+ /** infer ground uf definitions */
+ MACROS_QUANT_MODE_GROUND_UF,
+};
+
+}/* CVC4::theory::quantifiers namespace */
+}/* CVC4::theory namespace */
+
+std::ostream& operator<<(std::ostream& out, theory::quantifiers::InstWhenMode mode) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__BASE__QUANTIFIERS_MODES_H */
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module QUANTIFIERS "options/quantifiers_options.h" Quantifiers
+
+#### rewriter options
+
+# Whether to mini-scope quantifiers.
+# For example, forall x. ( P( x ) ^ Q( x ) ) will be rewritten to
+# ( forall x. P( x ) ) ^ ( forall x. Q( x ) )
+option miniscopeQuant --miniscope-quant bool :default true :read-write
+ miniscope quantifiers
+# Whether to mini-scope quantifiers based on formulas with no free variables.
+# For example, forall x. ( P( x ) V Q ) will be rewritten to
+# ( forall x. P( x ) ) V Q
+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 "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
+# forall y. P( c, y )
+option varElimQuant --var-elim-quant bool :default true
+ enable simple variable elimination for quantified formulas
+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 "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
+option condVarSplitQuantAgg --cond-var-split-agg-quant bool :default false
+ aggressive split quantified formulas that lead to variable eliminations
+option iteDtTesterSplitQuant --ite-dtt-split-quant bool :read-write :default false
+ split ites with dt testers as conditions
+# Whether to CNF quantifier bodies
+# option cnfQuant --cnf-quant bool :default false
+# apply CNF conversion to quantified formulas
+option nnfQuant --nnf-quant bool :default true
+ apply NNF conversion to quantified formulas
+# Whether to pre-skolemize quantifier bodies.
+# For example, forall x. ( P( x ) => (exists y. f( y ) = x) ) will be rewritten to
+# forall x. P( x ) => f( S( x ) ) = x
+option preSkolemQuant --pre-skolem-quant bool :read-write :default false
+ apply skolemization eagerly to bodies of quantified formulas
+option preSkolemQuantNested --pre-skolem-quant-nested bool :read-write :default true
+ apply skolemization to nested quantified formulass
+option preSkolemQuantAgg --pre-skolem-quant-agg bool :read-write :default true
+ apply skolemization to quantified formulas aggressively
+option aggressiveMiniscopeQuant --ag-miniscope-quant bool :default false
+ perform aggressive miniscoping for quantifiers
+option elimTautQuant --elim-taut-quant bool :default true
+ eliminate tautological disjuncts of quantified formulas
+option purifyQuant --purify-quant bool :default false
+ purify quantified formulas
+
+#### E-matching options
+
+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 "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
+
+option smartTriggers --smart-triggers bool :default true
+ enable smart triggers
+option relevantTriggers --relevant-triggers bool :default false
+ prefer triggers that are more relevant based on SInE style analysis
+option relationalTriggers --relational-triggers bool :default false
+ choose relational triggers such as x = f(y), x >= f(y)
+option purifyTriggers --purify-triggers bool :default false :read-write
+ purify triggers, e.g. f( x+1 ) becomes f( y ), x mapsto y-1
+option purifyDtTriggers --purify-dt-triggers bool :default false :read-write
+ purify dt triggers, match all constructors of correct form instead of selectors
+option pureThTriggers --pure-th-triggers bool :default false :read-write
+ use pure theory terms as single triggers
+option partialTriggers --partial-triggers bool :default false :read-write
+ use triggers that do not contain all free variables
+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 "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 "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 "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
+ maximum inst level of terms used to instantiate quantified formulas with (-1 == no limit, default)
+option instLevelInputOnly --inst-level-input-only bool :default true
+ only input terms are assigned instantiation level zero
+option internalReps --quant-internal-reps bool :default true
+ instantiate with representatives chosen by quantifiers engine
+
+option eagerInstQuant --eager-inst-quant bool :default false
+ apply quantifier instantiation eagerly
+
+option fullSaturateQuant --full-saturate-quant bool :default false :read-write
+ when all other quantifier instantiation strategies fail, instantiate with ground terms from relevant domain, then arbitrary ground terms before answering unknown
+option fullSaturateQuantRd --full-saturate-quant-rd bool :default true
+ whether to use relevant domain first for full saturation instantiation strategy
+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 "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
+
+option finiteModelFind finite-model-find --finite-model-find bool :default false :read-write
+ use finite model finding heuristic for quantifier instantiation
+
+option quantFunWellDefined --quant-fun-wd bool :default false
+ assume that function defined by quantifiers are well defined
+option fmfFunWellDefined --fmf-fun bool :default false :read-write
+ find models for recursively defined functions, assumes functions are admissible
+option fmfFunWellDefinedRelevant --fmf-fun-rlv bool :default false
+ find models for recursively defined functions, assumes functions are admissible, allows empty type when function is irrelevant
+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 "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
+option fmfOneQuantPerRound --mbqi-one-quant-per-round bool :default false
+ only add instantiations for one quantifier per round for mbqi
+
+option fmfInstEngine --fmf-inst-engine bool :default false
+ use instantiation engine in conjunction with finite model finding
+option fmfInstGen --fmf-inst-gen bool :default true
+ enable Inst-Gen instantiation techniques for finite model finding
+option fmfInstGenOneQuantPerRound --fmf-inst-gen-one-quant-per-round bool :default false
+ only perform Inst-Gen instantiation techniques on one quantifier per round
+option fmfFreshDistConst --fmf-fresh-dc bool :default false
+ use fresh distinguished representative when applying Inst-Gen techniques
+option fmfFmcSimple --fmf-fmc-simple bool :default true
+ simple models in full model check for finite model finding
+option fmfBoundInt fmf-bound-int --fmf-bound-int bool :default false :read-write
+ finite model finding on bounded integer quantification
+option fmfBoundIntLazy --fmf-bound-int-lazy bool :default false :read-write
+ enforce bounds for bounded integer quantification lazily via use of proxy variables
+
+### conflict-based instantiation options
+
+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 "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 "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
+option qcfAllConflict --qcf-all-conflict bool :read-write :default false
+ add all available conflicting instances during conflict-based instantiation
+
+option instNoEntail --inst-no-entail bool :read-write :default true
+ do not consider instances of quantified formulas that are currently entailed
+
+### rewrite rules options
+
+option quantRewriteRules --rewrite-rules bool :default false
+ use rewrite rules module
+option rrOneInstPerRound --rr-one-inst-per-round bool :default false
+ add one instance of rewrite rule per round
+
+### induction options
+
+option quantInduction --quant-ind bool :default false
+ use all available techniques for inductive reasoning
+option dtStcInduction --dt-stc-ind bool :read-write :default false
+ apply strengthening for existential quantification over datatypes based on structural induction
+option intWfInduction --int-wf-ind bool :read-write :default false
+ apply strengthening for integers based on well-founded induction
+option conjectureGen --conjecture-gen bool :read-write :default false
+ generate candidate conjectures for inductive proofs
+
+option conjectureGenPerRound --conjecture-gen-per-round=N int :default 1
+ number of conjectures to generate per instantiation round
+option conjectureNoFilter --conjecture-no-filter bool :default false
+ do not filter conjectures
+option conjectureFilterActiveTerms --conjecture-filter-active-terms bool :read-write :default true
+ filter based on active terms
+option conjectureFilterCanonical --conjecture-filter-canonical bool :read-write :default true
+ filter based on canonicity
+option conjectureFilterModel --conjecture-filter-model bool :read-write :default true
+ filter based on model
+option conjectureGenGtEnum --conjecture-gen-gt-enum=N int :default 50
+ number of ground terms to generate for model filtering
+option conjectureUeeIntro --conjecture-gen-uee-intro bool :default false
+ more aggressive merging for universal equality engine, introduces terms
+
+### synthesis options
+
+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 "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
+option cegqiSingleInvPartial --cegqi-si-partial bool :default false
+ combined techniques for synthesis conjectures that are partially single invocation
+option cegqiSingleInvReconstruct --cegqi-si-reconstruct bool :default true
+ reconstruct solutions for single invocation conjectures in original grammar
+option cegqiSingleInvReconstructConst --cegqi-si-reconstruct-const bool :default true
+ include constants when reconstruct solutions for single invocation conjectures in original grammar
+option cegqiSingleInvAbort --cegqi-si-abort bool :default false
+ abort if synthesis conjecture is not single invocation
+option cegqiSingleInvMultiInstAbort --cegqi-si-multi-inst-abort bool :default false
+ abort if synthesis conjecture is single invocation with no ITE in grammar and multiple instantiations are tried
+
+option sygusNormalForm --sygus-nf bool :default true
+ only search for sygus builtin terms that are in normal form
+option sygusNormalFormArg --sygus-nf-arg bool :default true
+ account for relationship between arguments of operations in sygus normal form
+option sygusNormalFormGlobal --sygus-nf-sym bool :default true
+ narrow sygus search space based on global state of current candidate program
+option sygusNormalFormGlobalGen --sygus-nf-sym-gen bool :default true
+ generalize lemmas for global search space narrowing
+option sygusNormalFormGlobalArg --sygus-nf-sym-arg bool :default true
+ generalize based on arguments in global search space narrowing
+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 "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
+option cbqiSplx --cbqi-splx bool :read-write :default false
+ turns on old implementation of counterexample-based quantifier instantiation
+option cbqi --cbqi bool :read-write :default false
+ turns on counterexample-based quantifier instantiation
+option recurseCbqi --cbqi-recurse bool :default true
+ turns on recursive counterexample-based quantifier instantiation
+option cbqiSat --cbqi-sat bool :read-write :default true
+ answer sat when quantifiers are asserted with counterexample-based quantifier instantiation
+option cbqiModel --cbqi-model bool :read-write :default true
+ guide instantiations by model values for counterexample-based quantifier instantiation
+option cbqiAll --cbqi-all bool :read-write :default false
+ apply counterexample-based instantiation to all quantified formulas
+option cbqiUseInfInt --cbqi-use-inf-int bool :read-write :default false
+ use integer infinity for vts in counterexample-based quantifier instantiation
+option cbqiUseInfReal --cbqi-use-inf-real bool :read-write :default false
+ use real infinity for vts in counterexample-based quantifier instantiation
+option cbqiPreRegInst --cbqi-prereg-inst bool :read-write :default false
+ preregister ground instantiations in counterexample-based quantifier instantiation
+option cbqiMinBounds --cbqi-min-bounds bool :default false
+ use minimally constrained lower/upper bound for counterexample-based quantifier instantiation
+option cbqiSymLia --cbqi-sym-lia bool :default false
+ use symbolic integer division in substitutions for counterexample-based quantifier instantiation
+option cbqiRoundUpLowerLia --cbqi-round-up-lia bool :default false
+ round up integer lower bounds in substitutions for counterexample-based quantifier instantiation
+option cbqiMidpoint --cbqi-midpoint bool :default false
+ choose substitutions based on midpoints of lower and upper bounds for counterexample-based quantifier instantiation
+option cbqiNopt --cbqi-nopt bool :default true
+ non-optimal bounds for counterexample-based quantifier instantiation
+
+### local theory extensions options
+
+option localTheoryExt --local-t-ext bool :default false
+ do instantiation based on local theory extensions
+option ltePartialInst --lte-partial-inst bool :default false
+ partially instantiate local theory quantifiers
+option lteRestrictInstClosure --lte-restrict-inst-closure bool :default false
+ treat arguments of inst closure as restricted terms for instantiation
+
+### reduction options
+
+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 "options/quantifiers_modes.h" :handler CVC4::options::stringToMacrosQuantMode :handler-include "options/options_handler_interface.h"
+ mode for quantifiers macro expansion
+
+### recursive function options
+
+#option funDefs --fun-defs bool :default false
+# enable specialized techniques for recursive function definitions
+
+### e-unification options
+
+option quantEqualityEngine --quant-ee bool :default false
+ maintain congrunce closure over universal equalities
+
+endmodule
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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
+
+option setsEagerLemmas --sets-eager-lemmas bool :default true
+ add lemmas even at regular effort
+
+expert-option setsCare1 --sets-care1 bool :default false
+ generate one lemma at a time for care graph
+
+option setsPropFull --sets-prop-full bool :default true
+ additional propagation at full effort
+
+endmodule
--- /dev/null
+/********************* */
+/*! \file simplification_mode.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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+#include "options/simplification_mode.h"
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, SimplificationMode mode) {
+ switch(mode) {
+ case SIMPLIFICATION_MODE_BATCH:
+ out << "SIMPLIFICATION_MODE_BATCH";
+ break;
+ case SIMPLIFICATION_MODE_NONE:
+ out << "SIMPLIFICATION_MODE_NONE";
+ break;
+ default:
+ out << "SimplificationMode:UNKNOWN![" << unsigned(mode) << "]";
+ }
+
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file simplification_mode.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_public.h"
+
+#ifndef __CVC4__SMT__SIMPLIFICATION_MODE_H
+#define __CVC4__SMT__SIMPLIFICATION_MODE_H
+
+#include <iostream>
+
+namespace CVC4 {
+
+/** Enumeration of simplification modes (when to simplify). */
+typedef enum {
+ /** Simplify the assertions all together once a check is requested */
+ SIMPLIFICATION_MODE_BATCH,
+ /** Don't do simplification */
+ SIMPLIFICATION_MODE_NONE
+} SimplificationMode;
+
+std::ostream& operator<<(std::ostream& out, SimplificationMode mode) CVC4_PUBLIC;
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__SMT__SIMPLIFICATION_MODE_H */
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+module SMT "options/smt_options.h" SMT layer
+
+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::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 "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::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)
+
+option doStaticLearning static-learning --static-learning bool :default true
+ use static learning (on by default)
+
+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::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::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::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::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
+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::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::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::options::beforeSearch :predicate-include "options/options_handler_interface.h"
+ support the get-assignment command
+
+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::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
+ turn on ite simplification (Kim (and Somenzi) et al., SAT 2009)
+
+option doITESimpOnRepeat --on-repeat-ite-simp bool :read-write :default false
+ do the ite simplification pass again if repeating simplification
+
+option simplifyWithCareEnabled --simp-with-care bool :default false :read-write
+ enables simplifyWithCare in ite simplificiation
+
+option compressItes --simp-ite-compress bool :default false :read-write
+ enables compressing ites after ite simplification
+
+option unconstrainedSimp --unconstrained-simp bool :default false :read-write
+ turn on unconstrained simplification (see Bruttomesso/Brummayer PhD thesis)
+
+option repeatSimp --repeat-simp bool :read-write
+ make multiple passes with nonclausal simplifier
+
+option zombieHuntThreshold --simp-ite-hunt-zombies uint32_t :default 524288
+ post ite compression enables zombie removal while the number of nodes is above this threshold
+
+option sortInference --sort-inference bool :read-write :default false
+ calculate sort inference of input problem, convert the input based on monotonic sorts
+
+common-option incrementalSolving incremental -i --incremental bool :default true
+ enable incremental solving
+
+option abstractValues abstract-values --abstract-values bool :default false
+ in models, output arrays (and in future, maybe others) using abstract values, as required by the SMT-LIB standard
+option modelUninterpDtEnum --model-u-dt-enum bool :default false
+ in models, output uninterpreted sorts as datatype enumerations
+
+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::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::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::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::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::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)
+common-option cpuTime cpu-time --cpu-time bool :default false
+ measures CPU time if set to true and wall time if false (default false)
+
+# Resource spending options for SPARK
+expert-option rewriteStep rewrite-step --rewrite-step unsigned :default 1
+ ammount of resources spent for each rewrite step
+
+expert-option theoryCheckStep theory-check-step --theory-check-step unsigned :default 1
+ ammount of resources spent for each theory check call
+
+expert-option decisionStep decision-step --decision-step unsigned :default 1
+ ammount of getNext decision calls in the decision engine
+
+expert-option bitblastStep bitblast-step --bitblast-step unsigned :default 1
+ ammount of resources spent for each bitblast step
+
+expert-option parseStep parse-step --parse-step unsigned :default 1
+ ammount of resources spent for each command/expression parsing
+
+expert-option lemmaStep lemma-step --lemma-step unsigned :default 1
+ ammount of resources spent when adding lemmas
+
+expert-option restartStep restart-step --restart-step unsigned :default 1
+ ammount of resources spent for each theory restart
+
+expert-option cnfStep cnf-step --cnf-step unsigned :default 1
+ ammount of resources spent for each call to cnf conversion
+
+expert-option preprocessStep preprocess-step --preprocess-step unsigned :default 1
+ ammount of resources spent for each preprocessing step in SmtEngine
+
+expert-option quantifierStep quantifier-step --quantifier-step unsigned :default 1
+ ammount of resources spent for quantifier instantiations
+
+expert-option satConflictStep sat-conflict-step --sat-conflict-step unsigned :default 1
+ ammount of resources spent for each sat conflict (main sat solver)
+
+expert-option bvSatConflictStep bv-sat-conflict-step --bv-sat-conflict-step unsigned :default 1
+ ammount of resources spent for each sat conflict (bitvectors)
+
+
+expert-option rewriteApplyToConst rewrite-apply-to-const --rewrite-apply-to-const bool :default false
+ 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::options::checkReplayFilename :handler-include "options/options_handler_interface.h"
+ replay decisions from file
+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 "base/lemma_input_channel_forward.h"
+ The input channel to receive notfication events for new lemmas
+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
+ Force no CPU limit when dumping models and proofs
+
+endmodule
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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
+
+# :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
+
+# :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
+ the finite model finding used by the theory of strings
+
+option stringEager strings-eager --strings-eager bool :default false
+ strings eager check
+
+option stringEIT strings-eit --strings-eit bool :default false
+ the eager intersection used by the theory of strings
+
+option stringOpt1 strings-opt1 --strings-opt1 bool :default true
+ internal option1 for strings: normal form
+
+option stringOpt2 strings-opt2 --strings-opt2 bool :default false
+ internal option2 for strings: constant regexp splitting
+
+option stringIgnNegMembership strings-inm --strings-inm bool :default false
+ internal for strings: ignore negative membership constraints (fragment checking is needed, left to users for now)
+
+#expert-option stringCharCardinality strings-alphabet-card --strings-alphabet-card=N int16_t :default 128 :read-write
+# the cardinality of the characters used by the theory of strings, default 128 (for standard ASCII) or 256 (for extended ASCII)
+
+option stringLazyPreproc strings-lazy-pp --strings-lazy-pp bool :default true
+ perform string preprocessing lazily upon assertion
+option stringLazyPreproc2 strings-lazy-pp2 --strings-lazy-pp2 bool :default true
+ perform string preprocessing lazily upon failure to reduce
+
+option stringLenGeqZ strings-len-geqz --strings-len-geqz bool :default false
+ strings length greater than zero lemmas
+
+option stringLenNorm strings-len-norm --strings-len-norm bool :default true
+ strings length normalization lemma
+option stringSplitEmp strings-sp-emp --strings-sp-emp bool :default true
+ strings split on empty string
+option stringInferSym strings-infer-sym --strings-infer-sym bool :default true
+ strings split on empty string
+option stringEagerLen strings-eager-len --strings-eager-len bool :default true
+ strings eager length lemmas
+
+
+endmodule
--- /dev/null
+#
+# 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
--- /dev/null
+
+#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 */
--- /dev/null
+/********************* */
+/*! \file theoryof_mode.h
+ ** \verbatim
+ ** Original author: Dejan Jovanovic
+ ** 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 Option selection for theoryOf() operation
+ **
+ ** Option selection for theoryOf() operation.
+ **/
+
+#include "cvc4_public.h"
+
+#pragma once
+
+#include <ostream>
+
+namespace CVC4 {
+namespace theory {
+
+/** How do we associate theories with the terms */
+enum TheoryOfMode {
+ /** Equality, variables and constants are associated with the types */
+ THEORY_OF_TYPE_BASED,
+ /** Variables are uninterpreted, constants are with the type, equalities prefer parametric */
+ THEORY_OF_TERM_BASED
+};/* enum TheoryOfMode */
+
+std::ostream& operator<<(std::ostream& out, TheoryOfMode m) throw() CVC4_PUBLIC;
+
+}/* CVC4::theory namespace */
+}/* CVC4 namespace */
+
--- /dev/null
+#
+# Option specification file for CVC4
+# See src/options/base_options for a description of this file format
+#
+
+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)
+
+option condenseFunctionValues condense-function-values --condense-function-values bool :default true
+ condense models for functions rather than explicitly representing them
+
+option ufssRegions /--disable-uf-ss-regions bool :default true
+ disable region-based method for discovering cliques and splits in uf strong solver
+option ufssEagerSplits --uf-ss-eager-split bool :default false
+ add splits eagerly for uf strong solver
+option ufssTotality --uf-ss-totality bool :default false
+ always use totality axioms for enforcing cardinality constraints
+option ufssTotalityLimited --uf-ss-totality-limited=N int :default -1
+ apply totality axioms, but only up to cardinality N (-1 == do not apply totality axioms, default)
+option ufssTotalitySymBreak --uf-ss-totality-sym-break bool :default false
+ apply symmetry breaking for totality axioms
+option ufssAbortCardinality --uf-ss-abort-card=N int :default -1
+ tells the uf strong solver a cardinality to abort at (-1 == no limit, default)
+option ufssExplainedCliques --uf-ss-explained-cliques bool :default false
+ use explained clique lemmas for uf strong solver
+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 "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
+
+option ufssSymBreak --uf-ss-sym-break bool :default false
+ finite model finding symmetry breaking techniques
+option ufssFairness --uf-ss-fair bool :default true
+ use fair strategy for finite model finding multiple sorts
+
+endmodule
--- /dev/null
+/********************* */
+/*! \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 */
+
#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;
#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 {
#include <string>
#include <cassert>
-#include "util/output.h"
+#include "base/output.h"
#include "parser/antlr_line_buffered_input.h"
namespace CVC4 {
#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
# 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 */
#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;
@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) \
({ \
#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;
#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 {
#endif /* _WIN32 */
+#include "base/exception.h"
#include "parser/memory_mapped_input_buffer.h"
-#include "util/exception.h"
namespace CVC4 {
namespace parser {
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module PARSER "parser/options.h" Parser
-
-common-option strictParsing --strict-parsing bool
- be less tolerant of non-conforming inputs
-
-option memoryMap --mmap bool
- memory map file input
-
-option semanticChecks /--no-checking bool :default DO_SEMANTIC_CHECKS_BY_DEFAULT :link /--no-type-checking
- disable ALL semantic checks, including type checks
-
-option globalDeclarations global-declarations bool :default false
- force all declarations and definitions to be global
-
-# this is to support security in the online version, and in other similar contexts
-# (--no-include-file disables filesystem access in TPTP and SMT2 parsers)
-# the name --no-include-file is legacy: it also now limits any filesystem access
-# (read or write) for example by using --dump-to (or the equivalent set-option) or
-# set-option :regular-output-channel/:diagnostic-output-channel. However, the main
-# driver is still permitted to read the input file given on the command-line if any.
-# creation/use of temp files are still permitted (but the paths aren't given by the
-# user). Also note this is only safe for the version invoked through the main driver,
-# there are ways via the API to get the CVC4 library to open a file for reading or
-# writing and thus leak information from an existing file, or overwrite an existing
-# file with malicious content.
-undocumented-option filesystemAccess /--no-filesystem-access bool :default true
-undocumented-alias --no-include-file = --no-filesystem-access
-
-endmodule
** 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;
**
** 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 {
.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;
}
#include <string>
+#include "options/language.h"
#include "parser/input.h"
-#include "util/language.h"
-
namespace CVC4 {
class ExprManager;
#include <string>
#include <sstream>
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
namespace parser {
#include <stdint.h>
-#include "expr/command.h"
+#include "smt_util/command.h"
#include "parser/parser.h"
#include "parser/antlr_tracing.h"
@parser::postinclude {
+#include <vector>
+
+#include "base/output.h"
#include "expr/expr.h"
#include "expr/kind.h"
#include "expr/type.h"
#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;
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); }
)
;
}
#include "expr/type.h"
-#include "expr/command.h"
+#include "smt_util/command.h"
#include "parser/parser.h"
#include "parser/smt1/smt1.h"
}/* @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;
@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"
/* echo */
| ECHO_TOK
( simpleSymbolicExpr[sexpr]
- { std::stringstream ss;
- ss << sexpr;
- cmd = new EchoCommand(ss.str());
- }
+ { cmd = new EchoCommand(sexpr.toString()); }
| { cmd = new EchoCommand(); }
)
| 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); }
**
** 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!
}/* @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"
@parser::postinclude {
+#include <algorithm>
+#include <iterator>
+#include <vector>
+
+#include "base/output.h"
#include "expr/expr.h"
#include "expr/kind.h"
#include "expr/type.h"
#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;
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 {
#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 {
**
** 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;
}/* CVC4::printer::ast namespace */
}/* CVC4::printer namespace */
}/* CVC4 namespace */
-
**/
#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;
}/* 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();
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 << ")";
}
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 << ";";
}
+++ /dev/null
-/********************* */
-/*! \file modes.cpp
- ** \verbatim
- ** Original author: Andrew Reynolds
- ** 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 ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "printer/modes.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, ModelFormatMode mode) {
- switch(mode) {
- case MODEL_FORMAT_MODE_DEFAULT:
- out << "MODEL_FORMAT_MODE_DEFAULT";
- break;
- case MODEL_FORMAT_MODE_TABLE:
- out << "MODEL_FORMAT_MODE_TABLE";
- break;
- default:
- out << "ModelFormatMode:UNKNOWN![" << unsigned(mode) << "]";
- }
-
- return out;
-}
-
-std::ostream& operator<<(std::ostream& out, InstFormatMode mode) {
- switch(mode) {
- case INST_FORMAT_MODE_DEFAULT:
- out << "INST_FORMAT_MODE_DEFAULT";
- break;
- case INST_FORMAT_MODE_SZS:
- out << "INST_FORMAT_MODE_SZS";
- break;
- default:
- out << "InstFormatMode:UNKNOWN![" << unsigned(mode) << "]";
- }
- return out;
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file modes.h
- ** \verbatim
- ** Original author: Andrew Reynolds
- ** 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 ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__PRINTER__MODES_H
-#define __CVC4__PRINTER__MODES_H
-
-#include <iostream>
-
-namespace CVC4 {
-
-/** Enumeration of model_format modes (how to print models from get-model command). */
-typedef enum {
- /** default mode (print expressions in the output language format) */
- MODEL_FORMAT_MODE_DEFAULT,
- /** print functional values in a table format */
- MODEL_FORMAT_MODE_TABLE,
-} ModelFormatMode;
-
-/** Enumeration of inst_format modes (how to print models from get-model command). */
-typedef enum {
- /** default mode (print expressions in the output language format) */
- INST_FORMAT_MODE_DEFAULT,
- /** print as SZS proof */
- INST_FORMAT_MODE_SZS,
-} InstFormatMode;
-
-std::ostream& operator<<(std::ostream& out, ModelFormatMode mode) CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream& out, InstFormatMode mode) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__PRINTER__MODEL_FORMAT_H */
+++ /dev/null
-#
-# 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
+++ /dev/null
-/********************* */
-/*! \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 */
**
** 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;
case LANG_SYGUS:
return new printer::smt2::Smt2Printer(printer::smt2::sygus_variant);
-
+
case LANG_AST:
return new printer::ast::AstPrinter();
}
}/* 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) {
#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 {
/** 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();
};/* 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 */
-
**
** 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;
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);
}/* CVC4::printer::smt1 namespace */
}/* CVC4::printer namespace */
}/* CVC4 namespace */
-
#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;
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();
}/* 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();
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;
}
}
}
}
}
-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() << ")";
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();
} else {
out << "(meta-info :" << c->getFlag() << " ";
}
- toStream(out, c->getSExpr());
+
+ SExpr::toStream(out, c->getSExpr(), variantToLanguage(v));
out << ")";
}
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 << ")";
}
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 */
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();
**
** 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;
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;
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 */
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 */
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module PROOF "proof/options.h" Proof
-
-endmodule
#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.
**/
#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 {
--- /dev/null
+/********************* */
+/*! \file unsat_core.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 Representation of unsat cores
+ **
+ ** Representation of unsat cores.
+ **/
+
+#include "proof/unsat_core.h"
+
+#include "printer/printer.h"
+#include "smt/smt_engine_scope.h"
+#include "smt_util/command.h"
+
+namespace CVC4 {
+
+void UnsatCore::initMessage() const {
+ Debug("core") << "UnsatCore size " << d_core.size() << std::endl;
+}
+
+UnsatCore::const_iterator UnsatCore::begin() const {
+ return d_core.begin();
+}
+
+UnsatCore::const_iterator UnsatCore::end() const {
+ return d_core.end();
+}
+
+void UnsatCore::toStream(std::ostream& out) const {
+ smt::SmtScope smts(d_smt);
+ Expr::dag::Scope scope(out, false);
+ Printer::getPrinter(options::outputLanguage())->toStream(out, *this);
+}
+
+void UnsatCore::toStream(std::ostream& out, const std::map<Expr, std::string>& names) const {
+ smt::SmtScope smts(d_smt);
+ Expr::dag::Scope scope(out, false);
+ Printer::getPrinter(options::outputLanguage())->toStream(out, *this, names);
+}
+
+std::ostream& operator<<(std::ostream& out, const UnsatCore& core) {
+ core.toStream(out);
+ return out;
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file unsat_core.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_public.h"
+
+#ifndef __CVC4__UNSAT_CORE_H
+#define __CVC4__UNSAT_CORE_H
+
+#include <iostream>
+#include <vector>
+#include "expr/expr.h"
+
+namespace CVC4 {
+
+class SmtEngine;
+class UnsatCore;
+
+std::ostream& operator<<(std::ostream& out, const UnsatCore& core) CVC4_PUBLIC;
+
+class CVC4_PUBLIC UnsatCore {
+ friend std::ostream& operator<<(std::ostream&, const UnsatCore&);
+
+ /** The SmtEngine we're associated with */
+ SmtEngine* d_smt;
+
+ std::vector<Expr> d_core;
+
+ void initMessage() const;
+
+public:
+ UnsatCore() : d_smt(NULL) {}
+
+ template <class T>
+ UnsatCore(SmtEngine* smt, T begin, T end) : d_smt(smt), d_core(begin, end) {
+ initMessage();
+ }
+
+ ~UnsatCore() {}
+
+ /** get the smt engine that this unsat core is hooked up to */
+ SmtEngine* getSmtEngine() { return d_smt; }
+
+ size_t size() const { return d_core.size(); }
+
+ typedef std::vector<Expr>::const_iterator iterator;
+ typedef std::vector<Expr>::const_iterator const_iterator;
+
+ const_iterator begin() const;
+ const_iterator end() const;
+
+ void toStream(std::ostream& out) const;
+ void toStream(std::ostream& out, const std::map<Expr, std::string>& names) const;
+
+};/* class UnsatCore */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__UNSAT_CORE_H */
--- /dev/null
+%{
+#include "proof/unsat_core.h"
+
+#ifdef SWIGJAVA
+
+#include "bindings/java_iterator_adapter.h"
+#include "bindings/java_stream_adapters.h"
+
+#endif /* SWIGJAVA */
+%}
+
+%ignore CVC4::operator<<(std::ostream&, const UnsatCore&);
+
+#ifdef SWIGJAVA
+
+// Instead of UnsatCore::begin() and end(), create an
+// iterator() method on the Java side that returns a Java-style
+// Iterator.
+%ignore CVC4::UnsatCore::begin();
+%ignore CVC4::UnsatCore::end();
+%ignore CVC4::UnsatCore::begin() const;
+%ignore CVC4::UnsatCore::end() const;
+%extend CVC4::UnsatCore {
+ CVC4::JavaIteratorAdapter<CVC4::UnsatCore> iterator() {
+ return CVC4::JavaIteratorAdapter<CVC4::UnsatCore>(*$self);
+ }
+}
+
+// UnsatCore is "iterable" on the Java side
+%typemap(javainterfaces) CVC4::UnsatCore "java.lang.Iterable<edu.nyu.acsys.CVC4.Expr>";
+
+// the JavaIteratorAdapter should not be public, and implements Iterator
+%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::UnsatCore> "class";
+%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::UnsatCore> "java.util.Iterator<edu.nyu.acsys.CVC4.Expr>";
+// add some functions to the Java side (do it here because there's no way to do these in C++)
+%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::UnsatCore> "
+ public void remove() {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ public edu.nyu.acsys.CVC4.Expr next() {
+ if(hasNext()) {
+ return getNext();
+ } else {
+ throw new java.util.NoSuchElementException();
+ }
+ }
+"
+// getNext() just allows C++ iterator access from Java-side next(), make it private
+%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::UnsatCore>::getNext() "private";
+
+// map the types appropriately
+%typemap(jni) CVC4::UnsatCore::const_iterator::value_type "jobject";
+%typemap(jtype) CVC4::UnsatCore::const_iterator::value_type "edu.nyu.acsys.CVC4.Expr";
+%typemap(jstype) CVC4::UnsatCore::const_iterator::value_type "edu.nyu.acsys.CVC4.Expr";
+%typemap(javaout) CVC4::UnsatCore::const_iterator::value_type { return $jnicall; }
+
+#endif /* SWIGJAVA */
+
+%include "proof/unsat_core.h"
+
+#ifdef SWIGJAVA
+
+%include "bindings/java_iterator_adapter.h"
+%include "bindings/java_stream_adapters.h"
+
+%template(JavaIteratorAdapter_UnsatCore) CVC4::JavaIteratorAdapter<CVC4::UnsatCore>;
+
+#endif /* SWIGJAVA */
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 {
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 {
#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 {
** 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;
#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;
#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;
#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"
**/
#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
d_statMaxLiterals.setData(d_minisat->max_literals);
d_statTotLiterals.setData(d_minisat->tot_literals);
}
+
+} /* namespace CVC4::prop */
+} /* namespace CVC4 */
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;
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module PROP "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)
-option satRandomSeed random-seed --random-seed=S uint32_t :default 0 :read-write
- sets the random seed for the sat solver
-
-option satVarDecay double :default 0.95 :predicate options::less_equal(1.0) options::greater_equal(0.0)
- variable activity decay factor for Minisat
-option satClauseDecay double :default 0.999 :predicate options::less_equal(1.0) options::greater_equal(0.0)
- clause activity decay factor for Minisat
-option satRestartFirst --restart-int-base=N unsigned :default 25
- sets the base restart interval for the sat solver (N=25 by default)
-option satRestartInc --restart-int-inc=F double :default 3.0 :predicate options::greater_equal(0.0)
- sets the restart interval increase factor for the sat solver (F=3.0 by default)
-
-option sat_refine_conflicts --refine-conflicts bool :default false
- refine theory conflict clauses (default false)
-
-option minisatUseElim --minisat-elimination bool :default true :read-write
- use Minisat elimination
-
-option minisatDumpDimacs --minisat-dump-dimacs bool :default false
- instead of solving minisat dumps the asserted clauses in Dimacs format
-
-endmodule
** 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;
#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 {
#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 {
** [[ 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 {
// 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 {
** [[ 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;
// 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 {
#ifndef __CVC4__SMT__LOGIC_EXCEPTION_H
#define __CVC4__SMT__LOGIC_EXCEPTION_H
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file modal_exception.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 An exception that is thrown when an interactive-only
- ** feature while CVC4 is being used in a non-interactive setting
- **
- ** An exception that is thrown when an interactive-only feature while
- ** CVC4 is being used in a non-interactive setting (for example, the
- ** "(get-assertions)" command in an SMT-LIBv2 script).
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__SMT__MODAL_EXCEPTION_H
-#define __CVC4__SMT__MODAL_EXCEPTION_H
-
-#include "util/exception.h"
-
-namespace CVC4 {
-
-class CVC4_PUBLIC ModalException : public CVC4::Exception {
-public:
- ModalException() :
- Exception("Feature used while operating in "
- "incorrect state") {
- }
-
- ModalException(const std::string& msg) :
- Exception(msg) {
- }
-
- ModalException(const char* msg) :
- Exception(msg) {
- }
-};/* class ModalException */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__SMT__MODAL_EXCEPTION_H */
+++ /dev/null
-%{
-#include "smt/modal_exception.h"
-%}
-
-%ignore CVC4::ModalException::ModalException(const char*);
-
-%include "smt/modal_exception.h"
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module SMT "smt/options.h" SMT layer
-
-common-option - dump --dump=MODE argument :handler CVC4::smt::dumpMode :handler-include "smt/options_handlers.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"
- 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 '""'
- 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"
- choose simplification mode, see --simplification=help
-alias --no-simplification = --simplification=none
- turn off all simplification (same as --simplification=none)
-
-option doStaticLearning static-learning --static-learning bool :default true
- use static learning (on by default)
-
-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"
- 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"
- 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"
- 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
- after UNSAT/VALID, machine-check the generated proof
-option dumpProofs --dump-proofs bool :default false :link --proof
- output proofs after every UNSAT/VALID response
-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"
- 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"
- 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"
- 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
- 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
- keep an assertions list (enables get-assertions command)
-
-option doITESimp --ite-simp bool :read-write
- turn on ite simplification (Kim (and Somenzi) et al., SAT 2009)
-
-option doITESimpOnRepeat --on-repeat-ite-simp bool :read-write :default false
- do the ite simplification pass again if repeating simplification
-
-option simplifyWithCareEnabled --simp-with-care bool :default false :read-write
- enables simplifyWithCare in ite simplificiation
-
-option compressItes --simp-ite-compress bool :default false :read-write
- enables compressing ites after ite simplification
-
-option unconstrainedSimp --unconstrained-simp bool :default false :read-write
- turn on unconstrained simplification (see Bruttomesso/Brummayer PhD thesis)
-
-option repeatSimp --repeat-simp bool :read-write
- make multiple passes with nonclausal simplifier
-
-option zombieHuntThreshold --simp-ite-hunt-zombies uint32_t :default 524288
- post ite compression enables zombie removal while the number of nodes is above this threshold
-
-option sortInference --sort-inference bool :read-write :default false
- calculate sort inference of input problem, convert the input based on monotonic sorts
-
-common-option incrementalSolving incremental -i --incremental bool :default true
- enable incremental solving
-
-option abstractValues abstract-values --abstract-values bool :default false
- in models, output arrays (and in future, maybe others) using abstract values, as required by the SMT-LIB standard
-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"
- set the regular output channel of the solver
-option - diagnostic-output-channel argument :handler CVC4::smt::setDiagnosticOutputChannel :handler-include "smt/options_handlers.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"
- 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"
- 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"
- 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"
- 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)
-common-option cpuTime cpu-time --cpu-time bool :default false
- measures CPU time if set to true and wall time if false (default false)
-
-# Resource spending options for SPARK
-expert-option rewriteStep rewrite-step --rewrite-step unsigned :default 1
- ammount of resources spent for each rewrite step
-
-expert-option theoryCheckStep theory-check-step --theory-check-step unsigned :default 1
- ammount of resources spent for each theory check call
-
-expert-option decisionStep decision-step --decision-step unsigned :default 1
- ammount of getNext decision calls in the decision engine
-
-expert-option bitblastStep bitblast-step --bitblast-step unsigned :default 1
- ammount of resources spent for each bitblast step
-
-expert-option parseStep parse-step --parse-step unsigned :default 1
- ammount of resources spent for each command/expression parsing
-
-expert-option lemmaStep lemma-step --lemma-step unsigned :default 1
- ammount of resources spent when adding lemmas
-
-expert-option restartStep restart-step --restart-step unsigned :default 1
- ammount of resources spent for each theory restart
-
-expert-option cnfStep cnf-step --cnf-step unsigned :default 1
- ammount of resources spent for each call to cnf conversion
-
-expert-option preprocessStep preprocess-step --preprocess-step unsigned :default 1
- ammount of resources spent for each preprocessing step in SmtEngine
-
-expert-option quantifierStep quantifier-step --quantifier-step unsigned :default 1
- ammount of resources spent for quantifier instantiations
-
-expert-option satConflictStep sat-conflict-step --sat-conflict-step unsigned :default 1
- ammount of resources spent for each sat conflict (main sat solver)
-
-expert-option bvSatConflictStep bv-sat-conflict-step --bv-sat-conflict-step unsigned :default 1
- ammount of resources spent for each sat conflict (bitvectors)
-
-
-expert-option rewriteApplyToConst rewrite-apply-to-const --rewrite-apply-to-const bool :default false
- 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"
- replay decisions from file
-undocumented-option replayLog --replay-log=FILE std::ostream* :handler CVC4::smt::checkReplayLogFilename :handler-include "smt/options_handlers.h"
- log decisions and propagations to file
-option replayStream ExprStream*
-
-# portfolio options
-option lemmaInputChannel LemmaInputChannel* :default NULL :include "util/lemma_input_channel.h"
- The input channel to receive notfication events for new lemmas
-option lemmaOutputChannel LemmaOutputChannel* :default NULL :include "util/lemma_output_channel.h"
- The output channel to receive notfication events for new lemmas
-
-option forceNoLimitCpuWhileDump --force-no-limit-cpu-while-dump bool :default false
- Force no CPU limit when dumping models and proofs
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \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 */
+++ /dev/null
-/********************* */
-/*! \file simplification_mode.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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "smt/simplification_mode.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, SimplificationMode mode) {
- switch(mode) {
- case SIMPLIFICATION_MODE_BATCH:
- out << "SIMPLIFICATION_MODE_BATCH";
- break;
- case SIMPLIFICATION_MODE_NONE:
- out << "SIMPLIFICATION_MODE_NONE";
- break;
- default:
- out << "SimplificationMode:UNKNOWN![" << unsigned(mode) << "]";
- }
-
- return out;
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file simplification_mode.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_public.h"
-
-#ifndef __CVC4__SMT__SIMPLIFICATION_MODE_H
-#define __CVC4__SMT__SIMPLIFICATION_MODE_H
-
-#include <iostream>
-
-namespace CVC4 {
-
-/** Enumeration of simplification modes (when to simplify). */
-typedef enum {
- /** Simplify the assertions all together once a check is requested */
- SIMPLIFICATION_MODE_BATCH,
- /** Don't do simplification */
- SIMPLIFICATION_MODE_NONE
-} SimplificationMode;
-
-std::ostream& operator<<(std::ostream& out, SimplificationMode mode) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__SMT__SIMPLIFICATION_MODE_H */
** 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;
d_needPostsolve(false),
d_earlyTheoryPP(true),
d_status(),
+ d_optionsHandler(new SmtOptionsHandler(this)),
d_private(NULL),
d_smtAttributes(NULL),
d_statisticsRegistry(NULL),
delete d_statisticsRegistry;
d_statisticsRegistry = NULL;
+ delete d_optionsHandler;
+ d_optionsHandler = NULL;
+
delete d_private;
d_private = NULL;
void SmtEngine::setDefaults() {
if(options::forceLogic.wasSetByUser()) {
- d_logic = options::forceLogic();
+ d_logic = *(options::forceLogic());
}
// set strings-exp
SmtScope smts(this);
Trace("smt") << "SMT setInfo(" << key << ", " << value << ")" << endl;
+
if(Dump.isOn("benchmark")) {
if(key == "status") {
string s = value.getValue();
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()) {
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!");
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();
}
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);
}
}
}
+
+
+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 */
#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)
class PropEngine;
}/* CVC4::prop namespace */
+namespace options {
+ class OptionsHandler;
+}/* CVC4::prop namespace */
+
namespace expr {
namespace attr {
class AttributeManager;
class SmtScope;
class BooleanTermConverter;
- void beforeSearch(std::string, bool, SmtEngine*) throw(ModalException);
ProofManager* currentProofManager();
struct CommandCleanup;
*/
std::map<std::string, Integer> d_commandVerbosity;
+ /**
+ * This responds to requests to set options.
+ */
+ options::OptionsHandler* d_optionsHandler;
+
/**
* A private utility class to 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
*/
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 */
%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"
** \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;
#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 {
--- /dev/null
+/********************* */
+/*! \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 */
--- /dev/null
+/********************* */
+/*! \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 */
+++ /dev/null
-/********************* */
-/*! \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 */
--- /dev/null
+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
+
--- /dev/null
+/********************* */
+/*! \file boolean_simplification.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 routines for Boolean simplification
+ **
+ ** Simple, commonly-used routines for Boolean simplification.
+ **/
+
+#include "smt_util/boolean_simplification.h"
+
+namespace CVC4 {
+
+bool
+BooleanSimplification::push_back_associative_commute_recursive
+ (Node n, std::vector<Node>& buffer, Kind k, Kind notK, bool negateNode)
+ throw(AssertionException) {
+ Node::iterator i = n.begin(), end = n.end();
+ for(; i != end; ++i){
+ Node child = *i;
+ if(child.getKind() == k){
+ if(! push_back_associative_commute_recursive(child, buffer, k, notK, negateNode)) {
+ return false;
+ }
+ }else if(child.getKind() == kind::NOT && child[0].getKind() == notK){
+ if(! push_back_associative_commute_recursive(child[0], buffer, notK, k, !negateNode)) {
+ return false;
+ }
+ }else{
+ if(negateNode){
+ if(child.isConst()) {
+ if((k == kind::AND && child.getConst<bool>()) ||
+ (k == kind::OR && !child.getConst<bool>())) {
+ buffer.clear();
+ buffer.push_back(negate(child));
+ return false;
+ }
+ } else {
+ buffer.push_back(negate(child));
+ }
+ }else{
+ if(child.isConst()) {
+ if((k == kind::OR && child.getConst<bool>()) ||
+ (k == kind::AND && !child.getConst<bool>())) {
+ buffer.clear();
+ buffer.push_back(child);
+ return false;
+ }
+ } else {
+ buffer.push_back(child);
+ }
+ }
+ }
+ }
+ return true;
+}/* BooleanSimplification::push_back_associative_commute_recursive() */
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file boolean_simplification.h
+ ** \verbatim
+ ** Original author: Tim King
+ ** 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 Simple routines for Boolean simplification
+ **
+ ** Simple, commonly-used routines for Boolean simplification.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__BOOLEAN_SIMPLIFICATION_H
+#define __CVC4__BOOLEAN_SIMPLIFICATION_H
+
+#include <vector>
+#include <algorithm>
+
+#include "base/cvc4_assert.h"
+#include "expr/expr_manager_scope.h"
+#include "expr/node.h"
+
+namespace CVC4 {
+
+/**
+ * A class to contain a number of useful functions for simple
+ * simplification of nodes. One never uses it as an object (and
+ * it cannot be constructed). It is used as a namespace.
+ */
+class BooleanSimplification {
+ // cannot construct one of these
+ BooleanSimplification() CVC4_UNUSED;
+ BooleanSimplification(const BooleanSimplification&) CVC4_UNUSED;
+
+ static bool push_back_associative_commute_recursive
+ (Node n, std::vector<Node>& buffer, Kind k, Kind notK, bool negateNode)
+ throw(AssertionException) CVC4_WARN_UNUSED_RESULT;
+
+public:
+
+ /**
+ * The threshold for removing duplicates. (See removeDuplicates().)
+ */
+ static const uint32_t DUPLICATE_REMOVAL_THRESHOLD = 10;
+
+ /**
+ * Remove duplicate nodes from a vector, modifying it in-place.
+ * If the vector has size >= DUPLICATE_REMOVAL_THRESHOLD, this
+ * function is a no-op.
+ */
+ static void removeDuplicates(std::vector<Node>& buffer)
+ throw(AssertionException) {
+ if(buffer.size() < DUPLICATE_REMOVAL_THRESHOLD) {
+ std::sort(buffer.begin(), buffer.end());
+ std::vector<Node>::iterator new_end =
+ std::unique(buffer.begin(), buffer.end());
+ buffer.erase(new_end, buffer.end());
+ }
+ }
+
+ /**
+ * Takes a node with kind AND, collapses all AND and (NOT OR)-kinded
+ * children of it (as far as possible---see
+ * push_back_associative_commute()), removes duplicates, and returns
+ * the resulting Node.
+ */
+ static Node simplifyConflict(Node andNode) throw(AssertionException) {
+ AssertArgument(!andNode.isNull(), andNode);
+ AssertArgument(andNode.getKind() == kind::AND, andNode);
+
+ std::vector<Node> buffer;
+ push_back_associative_commute(andNode, buffer, kind::AND, kind::OR);
+
+ removeDuplicates(buffer);
+
+ if(buffer.size() == 1) {
+ return buffer[0];
+ }
+
+ NodeBuilder<> nb(kind::AND);
+ nb.append(buffer);
+ return nb;
+ }
+
+ /**
+ * Takes a node with kind OR, collapses all OR and (NOT AND)-kinded
+ * children of it (as far as possible---see
+ * push_back_associative_commute()), removes duplicates, and returns
+ * the resulting Node.
+ */
+ static Node simplifyClause(Node orNode) throw(AssertionException) {
+ AssertArgument(!orNode.isNull(), orNode);
+ AssertArgument(orNode.getKind() == kind::OR, orNode);
+
+ std::vector<Node> buffer;
+ push_back_associative_commute(orNode, buffer, kind::OR, kind::AND);
+
+ removeDuplicates(buffer);
+
+ Assert(buffer.size() > 0);
+ if(buffer.size() == 1) {
+ return buffer[0];
+ }
+
+ NodeBuilder<> nb(kind::OR);
+ nb.append(buffer);
+ return nb;
+ }
+
+ /**
+ * Takes a node with kind IMPLIES, converts it to an OR, then
+ * simplifies the result with simplifyClause().
+ *
+ * The input doesn't actually have to be Horn, it seems, but that's
+ * the common case(?), hence the name.
+ */
+ static Node simplifyHornClause(Node implication) throw(AssertionException) {
+ AssertArgument(implication.getKind() == kind::IMPLIES, implication);
+
+ TNode left = implication[0];
+ TNode right = implication[1];
+
+ Node notLeft = negate(left);
+ Node clause = NodeBuilder<2>(kind::OR) << notLeft << right;
+
+ return simplifyClause(clause);
+ }
+
+ /**
+ * Aids in reforming a node. Takes a node of (N-ary) kind k and
+ * copies its children into an output vector, collapsing its k-kinded
+ * children into it. Also collapses negations of notK. For example:
+ *
+ * push_back_associative_commute( [OR [OR a b] [OR b c d] [NOT [AND e f]]],
+ * buffer, kind::OR, kind::AND )
+ * yields a "buffer" vector of [a b b c d e f]
+ *
+ * @param n the node to operate upon
+ * @param buffer the output vector (must be empty on entry)
+ * @param k the kind to collapse (should equal the kind of node n)
+ * @param notK the "negation" of kind k (e.g. OR's negation is AND),
+ * or kind::UNDEFINED_KIND if none.
+ * @param negateChildren true if the children of the resulting node
+ * (that is, the elements in buffer) should all be negated; you want
+ * this if e.g. you're simplifying the (OR...) in (NOT (OR...)),
+ * intending to make the result an AND.
+ */
+ static inline void
+ push_back_associative_commute(Node n, std::vector<Node>& buffer,
+ Kind k, Kind notK, bool negateChildren = false)
+ throw(AssertionException) {
+ AssertArgument(buffer.empty(), buffer);
+ AssertArgument(!n.isNull(), n);
+ AssertArgument(k != kind::UNDEFINED_KIND && k != kind::NULL_EXPR, k);
+ AssertArgument(notK != kind::NULL_EXPR, notK);
+ AssertArgument(n.getKind() == k, n,
+ "expected node to have kind %s", kindToString(k).c_str());
+
+ bool b CVC4_UNUSED =
+ push_back_associative_commute_recursive(n, buffer, k, notK, false);
+
+ if(buffer.size() == 0) {
+ // all the TRUEs for an AND (resp FALSEs for an OR) were simplified away
+ buffer.push_back(NodeManager::currentNM()->mkConst(k == kind::AND ? true : false));
+ }
+ }/* push_back_associative_commute() */
+
+ /**
+ * Negates a node, doing all the double-negation elimination
+ * that's possible.
+ *
+ * @param n the node to negate (cannot be the null node)
+ */
+ static Node negate(TNode n) throw(AssertionException) {
+ AssertArgument(!n.isNull(), n);
+
+ bool polarity = true;
+ TNode base = n;
+ while(base.getKind() == kind::NOT){
+ base = base[0];
+ polarity = !polarity;
+ }
+ if(n.isConst()) {
+ return NodeManager::currentNM()->mkConst(!n.getConst<bool>());
+ }
+ if(polarity){
+ return base.notNode();
+ }else{
+ return base;
+ }
+ }
+
+ /**
+ * Negates an Expr, doing all the double-negation elimination that's
+ * possible.
+ *
+ * @param e the Expr to negate (cannot be the null Expr)
+ */
+ static Expr negate(Expr e) throw(AssertionException) {
+ ExprManagerScope ems(e);
+ return negate(Node::fromExpr(e)).toExpr();
+ }
+
+ /**
+ * Simplify an OR, AND, or IMPLIES. This function is the identity
+ * for all other kinds.
+ */
+ inline static Node simplify(TNode n) throw(AssertionException) {
+ switch(n.getKind()) {
+ case kind::AND:
+ return simplifyConflict(n);
+
+ case kind::OR:
+ return simplifyClause(n);
+
+ case kind::IMPLIES:
+ return simplifyHornClause(n);
+
+ default:
+ return n;
+ }
+ }
+
+};/* class BooleanSimplification */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__BOOLEAN_SIMPLIFICATION_H */
--- /dev/null
+/********************* */
+/*! \file command.cpp
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: none
+ ** Minor contributors (to current version): Kshitij Bansal, Dejan Jovanovic, Andrew Reynolds, Francois Bobot
+ ** 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 command objects.
+ **
+ ** Implementation of command objects.
+ **/
+
+#include "smt_util/command.h"
+
+#include <exception>
+#include <iostream>
+#include <iterator>
+#include <sstream>
+#include <utility>
+#include <vector>
+
+#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;
+
+namespace CVC4 {
+
+const int CommandPrintSuccess::s_iosIndex = std::ios_base::xalloc();
+const CommandSuccess* CommandSuccess::s_instance = new CommandSuccess();
+const CommandInterrupted* CommandInterrupted::s_instance = new CommandInterrupted();
+
+std::ostream& operator<<(std::ostream& out, const Command& c) throw() {
+ c.toStream(out,
+ Node::setdepth::getDepth(out),
+ Node::printtypes::getPrintTypes(out),
+ Node::dag::getDag(out),
+ Node::setlanguage::getLanguage(out));
+ return out;
+}
+
+ostream& operator<<(ostream& out, const Command* c) throw() {
+ if(c == NULL) {
+ out << "null";
+ } else {
+ out << *c;
+ }
+ return out;
+}
+
+std::ostream& operator<<(std::ostream& out, const CommandStatus& s) throw() {
+ s.toStream(out, Node::setlanguage::getLanguage(out));
+ return out;
+}
+
+ostream& operator<<(ostream& out, const CommandStatus* s) throw() {
+ if(s == NULL) {
+ out << "null";
+ } else {
+ out << *s;
+ }
+ return out;
+}
+
+/* class Command */
+
+Command::Command() throw() : d_commandStatus(NULL), d_muted(false) {
+}
+
+Command::Command(const Command& cmd) {
+ d_commandStatus = (cmd.d_commandStatus == NULL) ? NULL : &cmd.d_commandStatus->clone();
+ d_muted = cmd.d_muted;
+}
+
+Command::~Command() throw() {
+ if(d_commandStatus != NULL && d_commandStatus != CommandSuccess::instance()) {
+ delete d_commandStatus;
+ }
+}
+
+bool Command::ok() const throw() {
+ // either we haven't run the command yet, or it ran successfully
+ return d_commandStatus == NULL || dynamic_cast<const CommandSuccess*>(d_commandStatus) != NULL;
+}
+
+bool Command::fail() const throw() {
+ return d_commandStatus != NULL && dynamic_cast<const CommandFailure*>(d_commandStatus) != NULL;
+}
+
+bool Command::interrupted() const throw() {
+ return d_commandStatus != NULL && dynamic_cast<const CommandInterrupted*>(d_commandStatus) != NULL;
+}
+
+void Command::invoke(SmtEngine* smtEngine, std::ostream& out) throw() {
+ invoke(smtEngine);
+ if(!(isMuted() && ok())) {
+ printResult(out, smtEngine->getOption("command-verbosity:" + getCommandName()).getIntegerValue().toUnsignedInt());
+ }
+}
+
+std::string Command::toString() const throw() {
+ std::stringstream ss;
+ toStream(ss);
+ return ss.str();
+}
+
+void Command::toStream(std::ostream& out, int toDepth, bool types, size_t dag,
+ OutputLanguage language) const throw() {
+ Printer::getPrinter(language)->toStream(out, this, toDepth, types, dag);
+}
+
+void CommandStatus::toStream(std::ostream& out, OutputLanguage language) const throw() {
+ Printer::getPrinter(language)->toStream(out, this);
+}
+
+void Command::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(d_commandStatus != NULL) {
+ if((!ok() && verbosity >= 1) || verbosity >= 2) {
+ out << *d_commandStatus;
+ }
+ }
+}
+
+/* class EmptyCommand */
+
+EmptyCommand::EmptyCommand(std::string name) throw() :
+ d_name(name) {
+}
+
+std::string EmptyCommand::getName() const throw() {
+ return d_name;
+}
+
+void EmptyCommand::invoke(SmtEngine* smtEngine) throw() {
+ /* empty commands have no implementation */
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* EmptyCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new EmptyCommand(d_name);
+}
+
+Command* EmptyCommand::clone() const {
+ return new EmptyCommand(d_name);
+}
+
+std::string EmptyCommand::getCommandName() const throw() {
+ return "empty";
+}
+
+/* class EchoCommand */
+
+EchoCommand::EchoCommand(std::string output) throw() :
+ d_output(output) {
+}
+
+std::string EchoCommand::getOutput() const throw() {
+ return d_output;
+}
+
+void EchoCommand::invoke(SmtEngine* smtEngine) throw() {
+ /* we don't have an output stream here, nothing to do */
+ d_commandStatus = CommandSuccess::instance();
+}
+
+void EchoCommand::invoke(SmtEngine* smtEngine, std::ostream& out) throw() {
+ out << d_output << std::endl;
+ d_commandStatus = CommandSuccess::instance();
+ printResult(out, smtEngine->getOption("command-verbosity:" + getCommandName()).getIntegerValue().toUnsignedInt());
+}
+
+Command* EchoCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new EchoCommand(d_output);
+}
+
+Command* EchoCommand::clone() const {
+ return new EchoCommand(d_output);
+}
+
+std::string EchoCommand::getCommandName() const throw() {
+ return "echo";
+}
+
+/* class AssertCommand */
+
+AssertCommand::AssertCommand(const Expr& e, bool inUnsatCore) throw() :
+ d_expr(e), d_inUnsatCore(inUnsatCore) {
+}
+
+Expr AssertCommand::getExpr() const throw() {
+ return d_expr;
+}
+
+void AssertCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->assertFormula(d_expr, d_inUnsatCore);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnsafeInterruptException& e) {
+ d_commandStatus = new CommandInterrupted();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* AssertCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new AssertCommand(d_expr.exportTo(exprManager, variableMap), d_inUnsatCore);
+}
+
+Command* AssertCommand::clone() const {
+ return new AssertCommand(d_expr, d_inUnsatCore);
+}
+
+std::string AssertCommand::getCommandName() const throw() {
+ return "assert";
+}
+
+/* class PushCommand */
+
+void PushCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->push();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnsafeInterruptException& e) {
+ d_commandStatus = new CommandInterrupted();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* PushCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new PushCommand();
+}
+
+Command* PushCommand::clone() const {
+ return new PushCommand();
+}
+
+std::string PushCommand::getCommandName() const throw() {
+ return "push";
+}
+
+/* class PopCommand */
+
+void PopCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->pop();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnsafeInterruptException& e) {
+ d_commandStatus = new CommandInterrupted();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* PopCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new PopCommand();
+}
+
+Command* PopCommand::clone() const {
+ return new PopCommand();
+}
+
+std::string PopCommand::getCommandName() const throw() {
+ return "pop";
+}
+
+/* class CheckSatCommand */
+
+CheckSatCommand::CheckSatCommand() throw() :
+ d_expr() {
+}
+
+CheckSatCommand::CheckSatCommand(const Expr& expr, bool inUnsatCore) throw() :
+ d_expr(expr), d_inUnsatCore(inUnsatCore) {
+}
+
+Expr CheckSatCommand::getExpr() const throw() {
+ return d_expr;
+}
+
+void CheckSatCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_result = smtEngine->checkSat(d_expr);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Result CheckSatCommand::getResult() const throw() {
+ return d_result;
+}
+
+void CheckSatCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ out << d_result << endl;
+ }
+}
+
+Command* CheckSatCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ CheckSatCommand* c = new CheckSatCommand(d_expr.exportTo(exprManager, variableMap), d_inUnsatCore);
+ c->d_result = d_result;
+ return c;
+}
+
+Command* CheckSatCommand::clone() const {
+ CheckSatCommand* c = new CheckSatCommand(d_expr, d_inUnsatCore);
+ c->d_result = d_result;
+ return c;
+}
+
+std::string CheckSatCommand::getCommandName() const throw() {
+ return "check-sat";
+}
+
+/* class QueryCommand */
+
+QueryCommand::QueryCommand(const Expr& e, bool inUnsatCore) throw() :
+ d_expr(e), d_inUnsatCore(inUnsatCore) {
+}
+
+Expr QueryCommand::getExpr() const throw() {
+ return d_expr;
+}
+
+void QueryCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_result = smtEngine->query(d_expr);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Result QueryCommand::getResult() const throw() {
+ return d_result;
+}
+
+void QueryCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ out << d_result << endl;
+ }
+}
+
+Command* QueryCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ QueryCommand* c = new QueryCommand(d_expr.exportTo(exprManager, variableMap), d_inUnsatCore);
+ c->d_result = d_result;
+ return c;
+}
+
+Command* QueryCommand::clone() const {
+ QueryCommand* c = new QueryCommand(d_expr, d_inUnsatCore);
+ c->d_result = d_result;
+ return c;
+}
+
+std::string QueryCommand::getCommandName() const throw() {
+ return "query";
+}
+
+/* class ResetCommand */
+
+void ResetCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->reset();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* ResetCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new ResetCommand();
+}
+
+Command* ResetCommand::clone() const {
+ return new ResetCommand();
+}
+
+std::string ResetCommand::getCommandName() const throw() {
+ return "reset";
+}
+
+/* class ResetAssertionsCommand */
+
+void ResetAssertionsCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->resetAssertions();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* ResetAssertionsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new ResetAssertionsCommand();
+}
+
+Command* ResetAssertionsCommand::clone() const {
+ return new ResetAssertionsCommand();
+}
+
+std::string ResetAssertionsCommand::getCommandName() const throw() {
+ return "reset-assertions";
+}
+
+/* class QuitCommand */
+
+void QuitCommand::invoke(SmtEngine* smtEngine) throw() {
+ Dump("benchmark") << *this;
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* QuitCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new QuitCommand();
+}
+
+Command* QuitCommand::clone() const {
+ return new QuitCommand();
+}
+
+std::string QuitCommand::getCommandName() const throw() {
+ return "exit";
+}
+
+/* class CommentCommand */
+
+CommentCommand::CommentCommand(std::string comment) throw() : d_comment(comment) {
+}
+
+std::string CommentCommand::getComment() const throw() {
+ return d_comment;
+}
+
+void CommentCommand::invoke(SmtEngine* smtEngine) throw() {
+ Dump("benchmark") << *this;
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* CommentCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new CommentCommand(d_comment);
+}
+
+Command* CommentCommand::clone() const {
+ return new CommentCommand(d_comment);
+}
+
+std::string CommentCommand::getCommandName() const throw() {
+ return "comment";
+}
+
+/* class CommandSequence */
+
+CommandSequence::CommandSequence() throw() :
+ d_index(0) {
+}
+
+CommandSequence::~CommandSequence() throw() {
+ for(unsigned i = d_index; i < d_commandSequence.size(); ++i) {
+ delete d_commandSequence[i];
+ }
+}
+
+void CommandSequence::addCommand(Command* cmd) throw() {
+ d_commandSequence.push_back(cmd);
+}
+
+void CommandSequence::clear() throw() {
+ d_commandSequence.clear();
+}
+
+void CommandSequence::invoke(SmtEngine* smtEngine) throw() {
+ for(; d_index < d_commandSequence.size(); ++d_index) {
+ d_commandSequence[d_index]->invoke(smtEngine);
+ if(! d_commandSequence[d_index]->ok()) {
+ // abort execution
+ d_commandStatus = d_commandSequence[d_index]->getCommandStatus();
+ return;
+ }
+ delete d_commandSequence[d_index];
+ }
+
+ AlwaysAssert(d_commandStatus == NULL);
+ d_commandStatus = CommandSuccess::instance();
+}
+
+void CommandSequence::invoke(SmtEngine* smtEngine, std::ostream& out) throw() {
+ for(; d_index < d_commandSequence.size(); ++d_index) {
+ d_commandSequence[d_index]->invoke(smtEngine, out);
+ if(! d_commandSequence[d_index]->ok()) {
+ // abort execution
+ d_commandStatus = d_commandSequence[d_index]->getCommandStatus();
+ return;
+ }
+ delete d_commandSequence[d_index];
+ }
+
+ AlwaysAssert(d_commandStatus == NULL);
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* CommandSequence::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ CommandSequence* seq = new CommandSequence();
+ for(iterator i = begin(); i != end(); ++i) {
+ Command* cmd_to_export = *i;
+ Command* cmd = cmd_to_export->exportTo(exprManager, variableMap);
+ seq->addCommand(cmd);
+ Debug("export") << "[export] so far converted: " << seq << endl;
+ }
+ seq->d_index = d_index;
+ return seq;
+}
+
+Command* CommandSequence::clone() const {
+ CommandSequence* seq = new CommandSequence();
+ for(const_iterator i = begin(); i != end(); ++i) {
+ seq->addCommand((*i)->clone());
+ }
+ seq->d_index = d_index;
+ return seq;
+}
+
+CommandSequence::const_iterator CommandSequence::begin() const throw() {
+ return d_commandSequence.begin();
+}
+
+CommandSequence::const_iterator CommandSequence::end() const throw() {
+ return d_commandSequence.end();
+}
+
+CommandSequence::iterator CommandSequence::begin() throw() {
+ return d_commandSequence.begin();
+}
+
+CommandSequence::iterator CommandSequence::end() throw() {
+ return d_commandSequence.end();
+}
+
+std::string CommandSequence::getCommandName() const throw() {
+ return "sequence";
+}
+
+/* class DeclarationSequenceCommand */
+
+/* class DeclarationDefinitionCommand */
+
+DeclarationDefinitionCommand::DeclarationDefinitionCommand(const std::string& id) throw() :
+ d_symbol(id) {
+}
+
+std::string DeclarationDefinitionCommand::getSymbol() const throw() {
+ return d_symbol;
+}
+
+/* class DeclareFunctionCommand */
+
+DeclareFunctionCommand::DeclareFunctionCommand(const std::string& id, Expr func, Type t) throw() :
+ DeclarationDefinitionCommand(id),
+ d_func(func),
+ d_type(t),
+ d_printInModel(true),
+ d_printInModelSetByUser(false){
+}
+
+Expr DeclareFunctionCommand::getFunction() const throw() {
+ return d_func;
+}
+
+Type DeclareFunctionCommand::getType() const throw() {
+ return d_type;
+}
+
+bool DeclareFunctionCommand::getPrintInModel() const throw() {
+ return d_printInModel;
+}
+
+bool DeclareFunctionCommand::getPrintInModelSetByUser() const throw() {
+ return d_printInModelSetByUser;
+}
+
+void DeclareFunctionCommand::setPrintInModel( bool p ) {
+ d_printInModel = p;
+ d_printInModelSetByUser = true;
+}
+
+void DeclareFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* DeclareFunctionCommand::exportTo(ExprManager* exprManager,
+ ExprManagerMapCollection& variableMap) {
+ DeclareFunctionCommand * dfc = new DeclareFunctionCommand(d_symbol, d_func.exportTo(exprManager, variableMap),
+ d_type.exportTo(exprManager, variableMap));
+ dfc->d_printInModel = d_printInModel;
+ dfc->d_printInModelSetByUser = d_printInModelSetByUser;
+ return dfc;
+}
+
+Command* DeclareFunctionCommand::clone() const {
+ DeclareFunctionCommand * dfc = new DeclareFunctionCommand(d_symbol, d_func, d_type);
+ dfc->d_printInModel = d_printInModel;
+ dfc->d_printInModelSetByUser = d_printInModelSetByUser;
+ return dfc;
+}
+
+std::string DeclareFunctionCommand::getCommandName() const throw() {
+ return "declare-fun";
+}
+
+/* class DeclareTypeCommand */
+
+DeclareTypeCommand::DeclareTypeCommand(const std::string& id, size_t arity, Type t) throw() :
+ DeclarationDefinitionCommand(id),
+ d_arity(arity),
+ d_type(t) {
+}
+
+size_t DeclareTypeCommand::getArity() const throw() {
+ return d_arity;
+}
+
+Type DeclareTypeCommand::getType() const throw() {
+ return d_type;
+}
+
+void DeclareTypeCommand::invoke(SmtEngine* smtEngine) throw() {
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* DeclareTypeCommand::exportTo(ExprManager* exprManager,
+ ExprManagerMapCollection& variableMap) {
+ return new DeclareTypeCommand(d_symbol, d_arity,
+ d_type.exportTo(exprManager, variableMap));
+}
+
+Command* DeclareTypeCommand::clone() const {
+ return new DeclareTypeCommand(d_symbol, d_arity, d_type);
+}
+
+std::string DeclareTypeCommand::getCommandName() const throw() {
+ return "declare-sort";
+}
+
+/* class DefineTypeCommand */
+
+DefineTypeCommand::DefineTypeCommand(const std::string& id,
+ Type t) throw() :
+ DeclarationDefinitionCommand(id),
+ d_params(),
+ d_type(t) {
+}
+
+DefineTypeCommand::DefineTypeCommand(const std::string& id,
+ const std::vector<Type>& params,
+ Type t) throw() :
+ DeclarationDefinitionCommand(id),
+ d_params(params),
+ d_type(t) {
+}
+
+const std::vector<Type>& DefineTypeCommand::getParameters() const throw() {
+ return d_params;
+}
+
+Type DefineTypeCommand::getType() const throw() {
+ return d_type;
+}
+
+void DefineTypeCommand::invoke(SmtEngine* smtEngine) throw() {
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* DefineTypeCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ vector<Type> params;
+ transform(d_params.begin(), d_params.end(), back_inserter(params),
+ ExportTransformer(exprManager, variableMap));
+ Type type = d_type.exportTo(exprManager, variableMap);
+ return new DefineTypeCommand(d_symbol, params, type);
+}
+
+Command* DefineTypeCommand::clone() const {
+ return new DefineTypeCommand(d_symbol, d_params, d_type);
+}
+
+std::string DefineTypeCommand::getCommandName() const throw() {
+ return "define-sort";
+}
+
+/* class DefineFunctionCommand */
+
+DefineFunctionCommand::DefineFunctionCommand(const std::string& id,
+ Expr func,
+ Expr formula) throw() :
+ DeclarationDefinitionCommand(id),
+ d_func(func),
+ d_formals(),
+ d_formula(formula) {
+}
+
+DefineFunctionCommand::DefineFunctionCommand(const std::string& id,
+ Expr func,
+ const std::vector<Expr>& formals,
+ Expr formula) throw() :
+ DeclarationDefinitionCommand(id),
+ d_func(func),
+ d_formals(formals),
+ d_formula(formula) {
+}
+
+Expr DefineFunctionCommand::getFunction() const throw() {
+ return d_func;
+}
+
+const std::vector<Expr>& DefineFunctionCommand::getFormals() const throw() {
+ return d_formals;
+}
+
+Expr DefineFunctionCommand::getFormula() const throw() {
+ return d_formula;
+}
+
+void DefineFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ if(!d_func.isNull()) {
+ smtEngine->defineFunction(d_func, d_formals, d_formula);
+ }
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* DefineFunctionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ Expr func = d_func.exportTo(exprManager, variableMap, /* flags = */ ExprManager::VAR_FLAG_DEFINED);
+ vector<Expr> formals;
+ transform(d_formals.begin(), d_formals.end(), back_inserter(formals),
+ ExportTransformer(exprManager, variableMap));
+ Expr formula = d_formula.exportTo(exprManager, variableMap);
+ return new DefineFunctionCommand(d_symbol, func, formals, formula);
+}
+
+Command* DefineFunctionCommand::clone() const {
+ return new DefineFunctionCommand(d_symbol, d_func, d_formals, d_formula);
+}
+
+std::string DefineFunctionCommand::getCommandName() const throw() {
+ return "define-fun";
+}
+
+/* class DefineNamedFunctionCommand */
+
+DefineNamedFunctionCommand::DefineNamedFunctionCommand(const std::string& id,
+ Expr func,
+ const std::vector<Expr>& formals,
+ Expr formula) throw() :
+ DefineFunctionCommand(id, func, formals, formula) {
+}
+
+void DefineNamedFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
+ this->DefineFunctionCommand::invoke(smtEngine);
+ if(!d_func.isNull() && d_func.getType().isBoolean()) {
+ smtEngine->addToAssignment(d_func.getExprManager()->mkExpr(kind::APPLY, d_func));
+ }
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* DefineNamedFunctionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ Expr func = d_func.exportTo(exprManager, variableMap);
+ vector<Expr> formals;
+ transform(d_formals.begin(), d_formals.end(), back_inserter(formals),
+ ExportTransformer(exprManager, variableMap));
+ Expr formula = d_formula.exportTo(exprManager, variableMap);
+ return new DefineNamedFunctionCommand(d_symbol, func, formals, formula);
+}
+
+Command* DefineNamedFunctionCommand::clone() const {
+ return new DefineNamedFunctionCommand(d_symbol, d_func, d_formals, d_formula);
+}
+
+/* class SetUserAttribute */
+
+SetUserAttributeCommand::SetUserAttributeCommand( const std::string& attr, Expr expr ) throw() :
+ d_attr( attr ), d_expr( expr ){
+}
+
+SetUserAttributeCommand::SetUserAttributeCommand( const std::string& attr, Expr expr,
+ std::vector<Expr>& values ) throw() :
+ d_attr( attr ), d_expr( expr ){
+ d_expr_values.insert( d_expr_values.begin(), values.begin(), values.end() );
+}
+
+SetUserAttributeCommand::SetUserAttributeCommand( const std::string& attr, Expr expr,
+ const std::string& value ) throw() :
+ d_attr( attr ), d_expr( expr ), d_str_value( value ){
+}
+
+void SetUserAttributeCommand::invoke(SmtEngine* smtEngine) throw(){
+ try {
+ if(!d_expr.isNull()) {
+ smtEngine->setUserAttribute( d_attr, d_expr, d_expr_values, d_str_value );
+ }
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* SetUserAttributeCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap){
+ Expr expr = d_expr.exportTo(exprManager, variableMap);
+ SetUserAttributeCommand * c = new SetUserAttributeCommand( d_attr, expr, d_str_value );
+ c->d_expr_values.insert( c->d_expr_values.end(), d_expr_values.begin(), d_expr_values.end() );
+ return c;
+}
+
+Command* SetUserAttributeCommand::clone() const{
+ SetUserAttributeCommand * c = new SetUserAttributeCommand( d_attr, d_expr, d_str_value );
+ c->d_expr_values.insert( c->d_expr_values.end(), d_expr_values.begin(), d_expr_values.end() );
+ return c;
+}
+
+std::string SetUserAttributeCommand::getCommandName() const throw() {
+ return "set-user-attribute";
+}
+
+/* class SimplifyCommand */
+
+SimplifyCommand::SimplifyCommand(Expr term) throw() :
+ d_term(term) {
+}
+
+Expr SimplifyCommand::getTerm() const throw() {
+ return d_term;
+}
+
+void SimplifyCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_result = smtEngine->simplify(d_term);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnsafeInterruptException& e) {
+ d_commandStatus = new CommandInterrupted();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Expr SimplifyCommand::getResult() const throw() {
+ return d_result;
+}
+
+void SimplifyCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ out << d_result << endl;
+ }
+}
+
+Command* SimplifyCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ SimplifyCommand* c = new SimplifyCommand(d_term.exportTo(exprManager, variableMap));
+ c->d_result = d_result.exportTo(exprManager, variableMap);
+ return c;
+}
+
+Command* SimplifyCommand::clone() const {
+ SimplifyCommand* c = new SimplifyCommand(d_term);
+ c->d_result = d_result;
+ return c;
+}
+
+std::string SimplifyCommand::getCommandName() const throw() {
+ return "simplify";
+}
+
+/* class ExpandDefinitionsCommand */
+
+ExpandDefinitionsCommand::ExpandDefinitionsCommand(Expr term) throw() :
+ d_term(term) {
+}
+
+Expr ExpandDefinitionsCommand::getTerm() const throw() {
+ return d_term;
+}
+
+void ExpandDefinitionsCommand::invoke(SmtEngine* smtEngine) throw() {
+ d_result = smtEngine->expandDefinitions(d_term);
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Expr ExpandDefinitionsCommand::getResult() const throw() {
+ return d_result;
+}
+
+void ExpandDefinitionsCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ out << d_result << endl;
+ }
+}
+
+Command* ExpandDefinitionsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ ExpandDefinitionsCommand* c = new ExpandDefinitionsCommand(d_term.exportTo(exprManager, variableMap));
+ c->d_result = d_result.exportTo(exprManager, variableMap);
+ return c;
+}
+
+Command* ExpandDefinitionsCommand::clone() const {
+ ExpandDefinitionsCommand* c = new ExpandDefinitionsCommand(d_term);
+ c->d_result = d_result;
+ return c;
+}
+
+std::string ExpandDefinitionsCommand::getCommandName() const throw() {
+ return "expand-definitions";
+}
+
+/* class GetValueCommand */
+
+GetValueCommand::GetValueCommand(Expr term) throw() :
+ d_terms() {
+ d_terms.push_back(term);
+}
+
+GetValueCommand::GetValueCommand(const std::vector<Expr>& terms) throw() :
+ d_terms(terms) {
+ CheckArgument(terms.size() >= 1, terms, "cannot get-value of an empty set of terms");
+}
+
+const std::vector<Expr>& GetValueCommand::getTerms() const throw() {
+ return d_terms;
+}
+
+void GetValueCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ vector<Expr> result;
+ ExprManager* em = smtEngine->getExprManager();
+ NodeManager* nm = NodeManager::fromExprManager(em);
+ for(std::vector<Expr>::const_iterator i = d_terms.begin(); i != d_terms.end(); ++i) {
+ Assert(nm == NodeManager::fromExprManager((*i).getExprManager()));
+ smt::SmtScope scope(smtEngine);
+ Node request = Node::fromExpr(options::expandDefinitions() ? smtEngine->expandDefinitions(*i) : *i);
+ Node value = Node::fromExpr(smtEngine->getValue(*i));
+ if(value.getType().isInteger() && request.getType() == nm->realType()) {
+ // Need to wrap in special marker so that output printers know this
+ // is an integer-looking constant that really should be output as
+ // a rational. Necessary for SMT-LIB standards compliance, but ugly.
+ value = nm->mkNode(kind::APPLY_TYPE_ASCRIPTION,
+ nm->mkConst(AscriptionType(em->realType())), value);
+ }
+ result.push_back(nm->mkNode(kind::SEXPR, request, value).toExpr());
+ }
+ d_result = em->mkExpr(kind::SEXPR, result);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnsafeInterruptException& e) {
+ d_commandStatus = new CommandInterrupted();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Expr GetValueCommand::getResult() const throw() {
+ return d_result;
+}
+
+void GetValueCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ Expr::dag::Scope scope(out, false);
+ out << d_result << endl;
+ }
+}
+
+Command* GetValueCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ vector<Expr> exportedTerms;
+ for(std::vector<Expr>::const_iterator i = d_terms.begin(); i != d_terms.end(); ++i) {
+ exportedTerms.push_back((*i).exportTo(exprManager, variableMap));
+ }
+ GetValueCommand* c = new GetValueCommand(exportedTerms);
+ c->d_result = d_result.exportTo(exprManager, variableMap);
+ return c;
+}
+
+Command* GetValueCommand::clone() const {
+ GetValueCommand* c = new GetValueCommand(d_terms);
+ c->d_result = d_result;
+ return c;
+}
+
+std::string GetValueCommand::getCommandName() const throw() {
+ return "get-value";
+}
+
+/* class GetAssignmentCommand */
+
+GetAssignmentCommand::GetAssignmentCommand() throw() {
+}
+
+void GetAssignmentCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_result = smtEngine->getAssignment();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnsafeInterruptException& e) {
+ d_commandStatus = new CommandInterrupted();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+SExpr GetAssignmentCommand::getResult() const throw() {
+ return d_result;
+}
+
+void GetAssignmentCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ out << d_result << endl;
+ }
+}
+
+Command* GetAssignmentCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetAssignmentCommand* c = new GetAssignmentCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetAssignmentCommand::clone() const {
+ GetAssignmentCommand* c = new GetAssignmentCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+std::string GetAssignmentCommand::getCommandName() const throw() {
+ return "get-assignment";
+}
+
+/* class GetModelCommand */
+
+GetModelCommand::GetModelCommand() throw() {
+}
+
+void GetModelCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_result = smtEngine->getModel();
+ d_smtEngine = smtEngine;
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnsafeInterruptException& e) {
+ d_commandStatus = new CommandInterrupted();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+/* Model is private to the library -- for now
+Model* GetModelCommand::getResult() const throw() {
+ return d_result;
+}
+*/
+
+void GetModelCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ out << *d_result;
+ }
+}
+
+Command* GetModelCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetModelCommand* c = new GetModelCommand();
+ c->d_result = d_result;
+ c->d_smtEngine = d_smtEngine;
+ return c;
+}
+
+Command* GetModelCommand::clone() const {
+ GetModelCommand* c = new GetModelCommand();
+ c->d_result = d_result;
+ c->d_smtEngine = d_smtEngine;
+ return c;
+}
+
+std::string GetModelCommand::getCommandName() const throw() {
+ return "get-model";
+}
+
+/* class GetProofCommand */
+
+GetProofCommand::GetProofCommand() throw() {
+}
+
+void GetProofCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_result = smtEngine->getProof();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnsafeInterruptException& e) {
+ d_commandStatus = new CommandInterrupted();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Proof* GetProofCommand::getResult() const throw() {
+ return d_result;
+}
+
+void GetProofCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ d_result->toStream(out);
+ }
+}
+
+Command* GetProofCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetProofCommand* c = new GetProofCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetProofCommand::clone() const {
+ GetProofCommand* c = new GetProofCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+std::string GetProofCommand::getCommandName() const throw() {
+ return "get-proof";
+}
+
+/* class GetInstantiationsCommand */
+
+GetInstantiationsCommand::GetInstantiationsCommand() throw() {
+}
+
+void GetInstantiationsCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_smtEngine = smtEngine;
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+//Instantiations* GetInstantiationsCommand::getResult() const throw() {
+// return d_result;
+//}
+
+void GetInstantiationsCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ d_smtEngine->printInstantiations(out);
+ }
+}
+
+Command* GetInstantiationsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetInstantiationsCommand* c = new GetInstantiationsCommand();
+ //c->d_result = d_result;
+ c->d_smtEngine = d_smtEngine;
+ return c;
+}
+
+Command* GetInstantiationsCommand::clone() const {
+ GetInstantiationsCommand* c = new GetInstantiationsCommand();
+ //c->d_result = d_result;
+ c->d_smtEngine = d_smtEngine;
+ return c;
+}
+
+std::string GetInstantiationsCommand::getCommandName() const throw() {
+ return "get-instantiations";
+}
+
+/* class GetSynthSolutionCommand */
+
+GetSynthSolutionCommand::GetSynthSolutionCommand() throw() {
+}
+
+void GetSynthSolutionCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_smtEngine = smtEngine;
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+void GetSynthSolutionCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ d_smtEngine->printSynthSolution(out);
+ }
+}
+
+Command* GetSynthSolutionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetSynthSolutionCommand* c = new GetSynthSolutionCommand();
+ c->d_smtEngine = d_smtEngine;
+ return c;
+}
+
+Command* GetSynthSolutionCommand::clone() const {
+ GetSynthSolutionCommand* c = new GetSynthSolutionCommand();
+ c->d_smtEngine = d_smtEngine;
+ return c;
+}
+
+std::string GetSynthSolutionCommand::getCommandName() const throw() {
+ return "get-instantiations";
+}
+
+/* class GetUnsatCoreCommand */
+
+GetUnsatCoreCommand::GetUnsatCoreCommand() throw() {
+}
+
+GetUnsatCoreCommand::GetUnsatCoreCommand(const std::map<Expr, std::string>& names) throw() : d_names(names) {
+}
+
+void GetUnsatCoreCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ d_result = smtEngine->getUnsatCore();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+void GetUnsatCoreCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ d_result.toStream(out, d_names);
+ }
+}
+
+const UnsatCore& GetUnsatCoreCommand::getUnsatCore() const throw() {
+ // of course, this will be empty if the command hasn't been invoked yet
+ return d_result;
+}
+
+Command* GetUnsatCoreCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetUnsatCoreCommand* c = new GetUnsatCoreCommand(d_names);
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetUnsatCoreCommand::clone() const {
+ GetUnsatCoreCommand* c = new GetUnsatCoreCommand(d_names);
+ c->d_result = d_result;
+ return c;
+}
+
+std::string GetUnsatCoreCommand::getCommandName() const throw() {
+ return "get-unsat-core";
+}
+
+/* class GetAssertionsCommand */
+
+GetAssertionsCommand::GetAssertionsCommand() throw() {
+}
+
+void GetAssertionsCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ stringstream ss;
+ const vector<Expr> v = smtEngine->getAssertions();
+ ss << "(\n";
+ copy( v.begin(), v.end(), ostream_iterator<Expr>(ss, "\n") );
+ ss << ")\n";
+ d_result = ss.str();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+std::string GetAssertionsCommand::getResult() const throw() {
+ return d_result;
+}
+
+void GetAssertionsCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else {
+ out << d_result;
+ }
+}
+
+Command* GetAssertionsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetAssertionsCommand* c = new GetAssertionsCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetAssertionsCommand::clone() const {
+ GetAssertionsCommand* c = new GetAssertionsCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+std::string GetAssertionsCommand::getCommandName() const throw() {
+ return "get-assertions";
+}
+
+/* class SetBenchmarkStatusCommand */
+
+SetBenchmarkStatusCommand::SetBenchmarkStatusCommand(BenchmarkStatus status) throw() :
+ d_status(status) {
+}
+
+BenchmarkStatus SetBenchmarkStatusCommand::getStatus() const throw() {
+ return d_status;
+}
+
+void SetBenchmarkStatusCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ stringstream ss;
+ ss << d_status;
+ SExpr status = SExpr(ss.str());
+ smtEngine->setInfo("status", status);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* SetBenchmarkStatusCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new SetBenchmarkStatusCommand(d_status);
+}
+
+Command* SetBenchmarkStatusCommand::clone() const {
+ return new SetBenchmarkStatusCommand(d_status);
+}
+
+std::string SetBenchmarkStatusCommand::getCommandName() const throw() {
+ return "set-info";
+}
+
+/* class SetBenchmarkLogicCommand */
+
+SetBenchmarkLogicCommand::SetBenchmarkLogicCommand(std::string logic) throw() :
+ d_logic(logic) {
+}
+
+std::string SetBenchmarkLogicCommand::getLogic() const throw() {
+ return d_logic;
+}
+
+void SetBenchmarkLogicCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->setLogic(d_logic);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* SetBenchmarkLogicCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new SetBenchmarkLogicCommand(d_logic);
+}
+
+Command* SetBenchmarkLogicCommand::clone() const {
+ return new SetBenchmarkLogicCommand(d_logic);
+}
+
+std::string SetBenchmarkLogicCommand::getCommandName() const throw() {
+ return "set-logic";
+}
+
+/* class SetInfoCommand */
+
+SetInfoCommand::SetInfoCommand(std::string flag, const SExpr& sexpr) throw() :
+ d_flag(flag),
+ d_sexpr(sexpr) {
+}
+
+std::string SetInfoCommand::getFlag() const throw() {
+ return d_flag;
+}
+
+SExpr SetInfoCommand::getSExpr() const throw() {
+ return d_sexpr;
+}
+
+void SetInfoCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->setInfo(d_flag, d_sexpr);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnrecognizedOptionException&) {
+ // As per SMT-LIB spec, silently accept unknown set-info keys
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* SetInfoCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new SetInfoCommand(d_flag, d_sexpr);
+}
+
+Command* SetInfoCommand::clone() const {
+ return new SetInfoCommand(d_flag, d_sexpr);
+}
+
+std::string SetInfoCommand::getCommandName() const throw() {
+ return "set-info";
+}
+
+/* class GetInfoCommand */
+
+GetInfoCommand::GetInfoCommand(std::string flag) throw() :
+ d_flag(flag) {
+}
+
+std::string GetInfoCommand::getFlag() const throw() {
+ return d_flag;
+}
+
+void GetInfoCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ vector<SExpr> v;
+ v.push_back(SExpr(SExpr::Keyword(string(":") + d_flag)));
+ v.push_back(smtEngine->getInfo(d_flag));
+ stringstream ss;
+ if(d_flag == "all-options" || d_flag == "all-statistics") {
+ ss << PrettySExprs(true);
+ }
+ ss << SExpr(v);
+ d_result = ss.str();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnrecognizedOptionException&) {
+ d_commandStatus = new CommandUnsupported();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+std::string GetInfoCommand::getResult() const throw() {
+ return d_result;
+}
+
+void GetInfoCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else if(d_result != "") {
+ out << d_result << endl;
+ }
+}
+
+Command* GetInfoCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetInfoCommand* c = new GetInfoCommand(d_flag);
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetInfoCommand::clone() const {
+ GetInfoCommand* c = new GetInfoCommand(d_flag);
+ c->d_result = d_result;
+ return c;
+}
+
+std::string GetInfoCommand::getCommandName() const throw() {
+ return "get-info";
+}
+
+/* class SetOptionCommand */
+
+SetOptionCommand::SetOptionCommand(std::string flag, const SExpr& sexpr) throw() :
+ d_flag(flag),
+ d_sexpr(sexpr) {
+}
+
+std::string SetOptionCommand::getFlag() const throw() {
+ return d_flag;
+}
+
+SExpr SetOptionCommand::getSExpr() const throw() {
+ return d_sexpr;
+}
+
+void SetOptionCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->setOption(d_flag, d_sexpr);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnrecognizedOptionException&) {
+ d_commandStatus = new CommandUnsupported();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* SetOptionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new SetOptionCommand(d_flag, d_sexpr);
+}
+
+Command* SetOptionCommand::clone() const {
+ return new SetOptionCommand(d_flag, d_sexpr);
+}
+
+std::string SetOptionCommand::getCommandName() const throw() {
+ return "set-option";
+}
+
+/* class GetOptionCommand */
+
+GetOptionCommand::GetOptionCommand(std::string flag) throw() :
+ d_flag(flag) {
+}
+
+std::string GetOptionCommand::getFlag() const throw() {
+ return d_flag;
+}
+
+void GetOptionCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ SExpr res = smtEngine->getOption(d_flag);
+ d_result = res.toString();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(UnrecognizedOptionException&) {
+ d_commandStatus = new CommandUnsupported();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+std::string GetOptionCommand::getResult() const throw() {
+ return d_result;
+}
+
+void GetOptionCommand::printResult(std::ostream& out, uint32_t verbosity) const throw() {
+ if(! ok()) {
+ this->Command::printResult(out, verbosity);
+ } else if(d_result != "") {
+ out << d_result << endl;
+ }
+}
+
+Command* GetOptionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ GetOptionCommand* c = new GetOptionCommand(d_flag);
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetOptionCommand::clone() const {
+ GetOptionCommand* c = new GetOptionCommand(d_flag);
+ c->d_result = d_result;
+ return c;
+}
+
+std::string GetOptionCommand::getCommandName() const throw() {
+ return "get-option";
+}
+
+/* class DatatypeDeclarationCommand */
+
+DatatypeDeclarationCommand::DatatypeDeclarationCommand(const DatatypeType& datatype) throw() :
+ d_datatypes() {
+ d_datatypes.push_back(datatype);
+}
+
+DatatypeDeclarationCommand::DatatypeDeclarationCommand(const std::vector<DatatypeType>& datatypes) throw() :
+ d_datatypes(datatypes) {
+}
+
+const std::vector<DatatypeType>&
+DatatypeDeclarationCommand::getDatatypes() const throw() {
+ return d_datatypes;
+}
+
+void DatatypeDeclarationCommand::invoke(SmtEngine* smtEngine) throw() {
+ d_commandStatus = CommandSuccess::instance();
+}
+
+Command* DatatypeDeclarationCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ throw ExportUnsupportedException
+ ("export of DatatypeDeclarationCommand unsupported");
+}
+
+Command* DatatypeDeclarationCommand::clone() const {
+ return new DatatypeDeclarationCommand(d_datatypes);
+}
+
+std::string DatatypeDeclarationCommand::getCommandName() const throw() {
+ return "declare-datatypes";
+}
+
+/* class RewriteRuleCommand */
+
+RewriteRuleCommand::RewriteRuleCommand(const std::vector<Expr>& vars,
+ const std::vector<Expr>& guards,
+ Expr head, Expr body,
+ const Triggers& triggers) throw() :
+ d_vars(vars), d_guards(guards), d_head(head), d_body(body), d_triggers(triggers) {
+}
+
+RewriteRuleCommand::RewriteRuleCommand(const std::vector<Expr>& vars,
+ Expr head, Expr body) throw() :
+ d_vars(vars), d_head(head), d_body(body) {
+}
+
+const std::vector<Expr>& RewriteRuleCommand::getVars() const throw() {
+ return d_vars;
+}
+
+const std::vector<Expr>& RewriteRuleCommand::getGuards() const throw() {
+ return d_guards;
+}
+
+Expr RewriteRuleCommand::getHead() const throw() {
+ return d_head;
+}
+
+Expr RewriteRuleCommand::getBody() const throw() {
+ return d_body;
+}
+
+const RewriteRuleCommand::Triggers& RewriteRuleCommand::getTriggers() const throw() {
+ return d_triggers;
+}
+
+void RewriteRuleCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ ExprManager* em = smtEngine->getExprManager();
+ /** build vars list */
+ Expr vars = em->mkExpr(kind::BOUND_VAR_LIST, d_vars);
+ /** build guards list */
+ Expr guards;
+ if(d_guards.size() == 0) guards = em->mkConst<bool>(true);
+ else if(d_guards.size() == 1) guards = d_guards[0];
+ else guards = em->mkExpr(kind::AND,d_guards);
+ /** build expression */
+ Expr expr;
+ if( d_triggers.empty() ){
+ expr = em->mkExpr(kind::RR_REWRITE,vars,guards,d_head,d_body);
+ } else {
+ /** build triggers list */
+ std::vector<Expr> vtriggers;
+ vtriggers.reserve(d_triggers.size());
+ for(Triggers::const_iterator i = d_triggers.begin(),
+ end = d_triggers.end(); i != end; ++i){
+ vtriggers.push_back(em->mkExpr(kind::INST_PATTERN,*i));
+ }
+ Expr triggers = em->mkExpr(kind::INST_PATTERN_LIST,vtriggers);
+ expr = em->mkExpr(kind::RR_REWRITE,vars,guards,d_head,d_body,triggers);
+ }
+ smtEngine->assertFormula(expr);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* RewriteRuleCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ /** Convert variables */
+ VExpr vars; vars.reserve(d_vars.size());
+ for(VExpr::iterator i = d_vars.begin(), end = d_vars.end();
+ i == end; ++i){
+ vars.push_back(i->exportTo(exprManager, variableMap));
+ };
+ /** Convert guards */
+ VExpr guards; guards.reserve(d_guards.size());
+ for(VExpr::iterator i = d_guards.begin(), end = d_guards.end();
+ i == end; ++i){
+ guards.push_back(i->exportTo(exprManager, variableMap));
+ };
+ /** Convert triggers */
+ Triggers triggers; triggers.resize(d_triggers.size());
+ for(size_t i = 0, end = d_triggers.size();
+ i < end; ++i){
+ triggers[i].reserve(d_triggers[i].size());
+ for(VExpr::iterator j = d_triggers[i].begin(), jend = d_triggers[i].end();
+ j == jend; ++i){
+ triggers[i].push_back(j->exportTo(exprManager, variableMap));
+ };
+ };
+ /** Convert head and body */
+ Expr head = d_head.exportTo(exprManager, variableMap);
+ Expr body = d_body.exportTo(exprManager, variableMap);
+ /** Create the converted rules */
+ return new RewriteRuleCommand(vars, guards, head, body, triggers);
+}
+
+Command* RewriteRuleCommand::clone() const {
+ return new RewriteRuleCommand(d_vars, d_guards, d_head, d_body, d_triggers);
+}
+
+std::string RewriteRuleCommand::getCommandName() const throw() {
+ return "rewrite-rule";
+}
+
+/* class PropagateRuleCommand */
+
+PropagateRuleCommand::PropagateRuleCommand(const std::vector<Expr>& vars,
+ const std::vector<Expr>& guards,
+ const std::vector<Expr>& heads,
+ Expr body,
+ const Triggers& triggers,
+ bool deduction) throw() :
+ d_vars(vars), d_guards(guards), d_heads(heads), d_body(body), d_triggers(triggers), d_deduction(deduction) {
+}
+
+PropagateRuleCommand::PropagateRuleCommand(const std::vector<Expr>& vars,
+ const std::vector<Expr>& heads,
+ Expr body,
+ bool deduction) throw() :
+ d_vars(vars), d_heads(heads), d_body(body), d_deduction(deduction) {
+}
+
+const std::vector<Expr>& PropagateRuleCommand::getVars() const throw() {
+ return d_vars;
+}
+
+const std::vector<Expr>& PropagateRuleCommand::getGuards() const throw() {
+ return d_guards;
+}
+
+const std::vector<Expr>& PropagateRuleCommand::getHeads() const throw() {
+ return d_heads;
+}
+
+Expr PropagateRuleCommand::getBody() const throw() {
+ return d_body;
+}
+
+const PropagateRuleCommand::Triggers& PropagateRuleCommand::getTriggers() const throw() {
+ return d_triggers;
+}
+
+bool PropagateRuleCommand::isDeduction() const throw() {
+ return d_deduction;
+}
+
+void PropagateRuleCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ ExprManager* em = smtEngine->getExprManager();
+ /** build vars list */
+ Expr vars = em->mkExpr(kind::BOUND_VAR_LIST, d_vars);
+ /** build guards list */
+ Expr guards;
+ if(d_guards.size() == 0) guards = em->mkConst<bool>(true);
+ else if(d_guards.size() == 1) guards = d_guards[0];
+ else guards = em->mkExpr(kind::AND,d_guards);
+ /** build heads list */
+ Expr heads;
+ if(d_heads.size() == 1) heads = d_heads[0];
+ else heads = em->mkExpr(kind::AND,d_heads);
+ /** build expression */
+ Expr expr;
+ if( d_triggers.empty() ){
+ expr = em->mkExpr(kind::RR_REWRITE,vars,guards,heads,d_body);
+ } else {
+ /** build triggers list */
+ std::vector<Expr> vtriggers;
+ vtriggers.reserve(d_triggers.size());
+ for(Triggers::const_iterator i = d_triggers.begin(),
+ end = d_triggers.end(); i != end; ++i){
+ vtriggers.push_back(em->mkExpr(kind::INST_PATTERN,*i));
+ }
+ Expr triggers = em->mkExpr(kind::INST_PATTERN_LIST,vtriggers);
+ expr = em->mkExpr(kind::RR_REWRITE,vars,guards,heads,d_body,triggers);
+ }
+ smtEngine->assertFormula(expr);
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* PropagateRuleCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ /** Convert variables */
+ VExpr vars; vars.reserve(d_vars.size());
+ for(VExpr::iterator i = d_vars.begin(), end = d_vars.end();
+ i == end; ++i){
+ vars.push_back(i->exportTo(exprManager, variableMap));
+ };
+ /** Convert guards */
+ VExpr guards; guards.reserve(d_guards.size());
+ for(VExpr::iterator i = d_guards.begin(), end = d_guards.end();
+ i == end; ++i){
+ guards.push_back(i->exportTo(exprManager, variableMap));
+ };
+ /** Convert heads */
+ VExpr heads; heads.reserve(d_heads.size());
+ for(VExpr::iterator i = d_heads.begin(), end = d_heads.end();
+ i == end; ++i){
+ heads.push_back(i->exportTo(exprManager, variableMap));
+ };
+ /** Convert triggers */
+ Triggers triggers; triggers.resize(d_triggers.size());
+ for(size_t i = 0, end = d_triggers.size();
+ i < end; ++i){
+ triggers[i].reserve(d_triggers[i].size());
+ for(VExpr::iterator j = d_triggers[i].begin(), jend = d_triggers[i].end();
+ j == jend; ++i){
+ triggers[i].push_back(j->exportTo(exprManager, variableMap));
+ };
+ };
+ /** Convert head and body */
+ Expr body = d_body.exportTo(exprManager, variableMap);
+ /** Create the converted rules */
+ return new PropagateRuleCommand(vars, guards, heads, body, triggers);
+}
+
+Command* PropagateRuleCommand::clone() const {
+ return new PropagateRuleCommand(d_vars, d_guards, d_heads, d_body, d_triggers);
+}
+
+std::string PropagateRuleCommand::getCommandName() const throw() {
+ return "propagate-rule";
+}
+
+/* output stream insertion operator for benchmark statuses */
+std::ostream& operator<<(std::ostream& out,
+ BenchmarkStatus status) throw() {
+ switch(status) {
+
+ case SMT_SATISFIABLE:
+ return out << "sat";
+
+ case SMT_UNSATISFIABLE:
+ return out << "unsat";
+
+ case SMT_UNKNOWN:
+ return out << "unknown";
+
+ default:
+ return out << "BenchmarkStatus::[UNKNOWNSTATUS!]";
+ }
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file command.h
+ ** \verbatim
+ ** Original author: Morgan Deters
+ ** Major contributors: none
+ ** Minor contributors (to current version): Kshitij Bansal, Christopher L. Conway, Dejan Jovanovic, Francois Bobot, Andrew Reynolds
+ ** 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 the command pattern on SmtEngines.
+ **
+ ** Implementation of the command pattern on SmtEngines. Command
+ ** objects are generated by the parser (typically) to implement the
+ ** commands in parsed input (see Parser::parseNextCommand()), or by
+ ** client code.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__COMMAND_H
+#define __CVC4__COMMAND_H
+
+#include <iostream>
+#include <sstream>
+#include <string>
+#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 "proof/unsat_core.h"
+#include "util/proof.h"
+
+namespace CVC4 {
+
+class SmtEngine;
+class Command;
+class CommandStatus;
+class Model;
+
+std::ostream& operator<<(std::ostream&, const Command&) throw() CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream&, const Command*) throw() CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream&, const CommandStatus&) throw() CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream&, const CommandStatus*) throw() CVC4_PUBLIC;
+
+/** The status an SMT benchmark can have */
+enum BenchmarkStatus {
+ /** Benchmark is satisfiable */
+ SMT_SATISFIABLE,
+ /** Benchmark is unsatisfiable */
+ SMT_UNSATISFIABLE,
+ /** The status of the benchmark is unknown */
+ SMT_UNKNOWN
+};/* enum BenchmarkStatus */
+
+std::ostream& operator<<(std::ostream& out,
+ BenchmarkStatus status) throw() CVC4_PUBLIC;
+
+/**
+ * IOStream manipulator to print success messages or not.
+ *
+ * out << Command::printsuccess(false) << CommandSuccess();
+ *
+ * prints nothing, but
+ *
+ * out << Command::printsuccess(true) << CommandSuccess();
+ *
+ * prints a success message (in a manner appropriate for the current
+ * output language).
+ */
+class CVC4_PUBLIC CommandPrintSuccess {
+ /**
+ * The allocated index in ios_base for our depth setting.
+ */
+ static const int s_iosIndex;
+
+ /**
+ * The default setting, for ostreams that haven't yet had a
+ * setdepth() applied to them.
+ */
+ static const int s_defaultPrintSuccess = false;
+
+ /**
+ * When this manipulator is used, the setting is stored here.
+ */
+ bool d_printSuccess;
+
+public:
+ /**
+ * Construct a CommandPrintSuccess with the given setting.
+ */
+ CommandPrintSuccess(bool printSuccess) throw() : d_printSuccess(printSuccess) {}
+
+ inline void applyPrintSuccess(std::ostream& out) throw() {
+ out.iword(s_iosIndex) = d_printSuccess;
+ }
+
+ static inline bool getPrintSuccess(std::ostream& out) throw() {
+ return out.iword(s_iosIndex);
+ }
+
+ static inline void setPrintSuccess(std::ostream& out, bool printSuccess) throw() {
+ out.iword(s_iosIndex) = printSuccess;
+ }
+
+ /**
+ * Set the print-success 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_oldPrintSuccess;
+
+ public:
+
+ inline Scope(std::ostream& out, bool printSuccess) throw() :
+ d_out(out),
+ d_oldPrintSuccess(CommandPrintSuccess::getPrintSuccess(out)) {
+ CommandPrintSuccess::setPrintSuccess(out, printSuccess);
+ }
+
+ inline ~Scope() throw() {
+ CommandPrintSuccess::setPrintSuccess(d_out, d_oldPrintSuccess);
+ }
+
+ };/* class CommandPrintSuccess::Scope */
+
+};/* class CommandPrintSuccess */
+
+/**
+ * Sets the default print-success setting when pretty-printing an Expr
+ * to an ostream. Use like this:
+ *
+ * // let out be an ostream, e an Expr
+ * out << Expr::setdepth(n) << e << endl;
+ *
+ * The depth stays permanently (until set again) with the stream.
+ */
+inline std::ostream& operator<<(std::ostream& out, CommandPrintSuccess cps) throw() CVC4_PUBLIC;
+inline std::ostream& operator<<(std::ostream& out, CommandPrintSuccess cps) throw() {
+ cps.applyPrintSuccess(out);
+ return out;
+}
+
+class CVC4_PUBLIC CommandStatus {
+protected:
+ // shouldn't construct a CommandStatus (use a derived class)
+ CommandStatus() throw() {}
+public:
+ virtual ~CommandStatus() throw() {}
+ void toStream(std::ostream& out,
+ OutputLanguage language = language::output::LANG_AUTO) const throw();
+ virtual CommandStatus& clone() const = 0;
+};/* class CommandStatus */
+
+class CVC4_PUBLIC CommandSuccess : public CommandStatus {
+ static const CommandSuccess* s_instance;
+public:
+ static const CommandSuccess* instance() throw() { return s_instance; }
+ CommandStatus& clone() const { return const_cast<CommandSuccess&>(*this); }
+};/* class CommandSuccess */
+
+class CVC4_PUBLIC CommandInterrupted : public CommandStatus {
+ static const CommandInterrupted* s_instance;
+public:
+ static const CommandInterrupted* instance() throw() { return s_instance; }
+ CommandStatus& clone() const { return const_cast<CommandInterrupted&>(*this); }
+};/* class CommandInterrupted */
+
+class CVC4_PUBLIC CommandUnsupported : public CommandStatus {
+public:
+ CommandStatus& clone() const { return *new CommandUnsupported(*this); }
+};/* class CommandSuccess */
+
+class CVC4_PUBLIC CommandFailure : public CommandStatus {
+ std::string d_message;
+public:
+ CommandFailure(std::string message) throw() : d_message(message) {}
+ CommandFailure& clone() const { return *new CommandFailure(*this); }
+ ~CommandFailure() throw() {}
+ std::string getMessage() const throw() { return d_message; }
+};/* class CommandFailure */
+
+class CVC4_PUBLIC Command {
+protected:
+ /**
+ * This field contains a command status if the command has been
+ * invoked, or NULL if it has not. This field is either a
+ * dynamically-allocated pointer, or it's a pointer to the singleton
+ * CommandSuccess instance. Doing so is somewhat asymmetric, but
+ * it avoids the need to dynamically allocate memory in the common
+ * case of a successful command.
+ */
+ const CommandStatus* d_commandStatus;
+
+ /**
+ * True if this command is "muted"---i.e., don't print "success" on
+ * successful execution.
+ */
+ bool d_muted;
+
+public:
+ typedef CommandPrintSuccess printsuccess;
+
+ Command() throw();
+ Command(const Command& cmd);
+
+ virtual ~Command() throw();
+
+ virtual void invoke(SmtEngine* smtEngine) throw() = 0;
+ virtual void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
+
+ virtual void toStream(std::ostream& out, int toDepth = -1, bool types = false, size_t dag = 1,
+ OutputLanguage language = language::output::LANG_AUTO) const throw();
+
+ std::string toString() const throw();
+
+ virtual std::string getCommandName() const throw() = 0;
+
+ /**
+ * If false, instruct this Command not to print a success message.
+ */
+ void setMuted(bool muted) throw() { d_muted = muted; }
+
+ /**
+ * Determine whether this Command will print a success message.
+ */
+ bool isMuted() throw() { return d_muted; }
+
+ /**
+ * Either the command hasn't run yet, or it completed successfully
+ * (CommandSuccess, not CommandUnsupported or CommandFailure).
+ */
+ bool ok() const throw();
+
+ /**
+ * The command completed in a failure state (CommandFailure, not
+ * CommandSuccess or CommandUnsupported).
+ */
+ bool fail() const throw();
+
+ /**
+ * The command was ran but was interrupted due to resource limiting.
+ */
+ bool interrupted() const throw();
+
+ /** Get the command status (it's NULL if we haven't run yet). */
+ const CommandStatus* getCommandStatus() const throw() { return d_commandStatus; }
+
+ virtual void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+
+ /**
+ * Maps this Command into one for a different ExprManager, using
+ * variableMap for the translation and extending it with any new
+ * mappings.
+ */
+ virtual Command* exportTo(ExprManager* exprManager,
+ ExprManagerMapCollection& variableMap) = 0;
+
+ /**
+ * Clone this Command (make a shallow copy).
+ */
+ virtual Command* clone() const = 0;
+
+protected:
+ class ExportTransformer {
+ ExprManager* d_exprManager;
+ ExprManagerMapCollection& d_variableMap;
+ public:
+ ExportTransformer(ExprManager* exprManager, ExprManagerMapCollection& variableMap) :
+ d_exprManager(exprManager),
+ d_variableMap(variableMap) {
+ }
+ Expr operator()(Expr e) {
+ return e.exportTo(d_exprManager, d_variableMap);
+ }
+ Type operator()(Type t) {
+ return t.exportTo(d_exprManager, d_variableMap);
+ }
+ };/* class Command::ExportTransformer */
+};/* class Command */
+
+/**
+ * EmptyCommands are the residue of a command after the parser handles
+ * them (and there's nothing left to do).
+ */
+class CVC4_PUBLIC EmptyCommand : public Command {
+protected:
+ std::string d_name;
+public:
+ EmptyCommand(std::string name = "") throw();
+ ~EmptyCommand() throw() {}
+ std::string getName() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class EmptyCommand */
+
+class CVC4_PUBLIC EchoCommand : public Command {
+protected:
+ std::string d_output;
+public:
+ EchoCommand(std::string output = "") throw();
+ ~EchoCommand() throw() {}
+ std::string getOutput() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class EchoCommand */
+
+class CVC4_PUBLIC AssertCommand : public Command {
+protected:
+ Expr d_expr;
+ bool d_inUnsatCore;
+public:
+ AssertCommand(const Expr& e, bool inUnsatCore = true) throw();
+ ~AssertCommand() throw() {}
+ Expr getExpr() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class AssertCommand */
+
+class CVC4_PUBLIC PushCommand : public Command {
+public:
+ ~PushCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class PushCommand */
+
+class CVC4_PUBLIC PopCommand : public Command {
+public:
+ ~PopCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class PopCommand */
+
+class CVC4_PUBLIC DeclarationDefinitionCommand : public Command {
+protected:
+ std::string d_symbol;
+public:
+ DeclarationDefinitionCommand(const std::string& id) throw();
+ ~DeclarationDefinitionCommand() throw() {}
+ virtual void invoke(SmtEngine* smtEngine) throw() = 0;
+ std::string getSymbol() const throw();
+};/* class DeclarationDefinitionCommand */
+
+class CVC4_PUBLIC DeclareFunctionCommand : public DeclarationDefinitionCommand {
+protected:
+ Expr d_func;
+ Type d_type;
+ bool d_printInModel;
+ bool d_printInModelSetByUser;
+public:
+ DeclareFunctionCommand(const std::string& id, Expr func, Type type) throw();
+ ~DeclareFunctionCommand() throw() {}
+ Expr getFunction() const throw();
+ Type getType() const throw();
+ bool getPrintInModel() const throw();
+ bool getPrintInModelSetByUser() const throw();
+ void setPrintInModel( bool p );
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class DeclareFunctionCommand */
+
+class CVC4_PUBLIC DeclareTypeCommand : public DeclarationDefinitionCommand {
+protected:
+ size_t d_arity;
+ Type d_type;
+public:
+ DeclareTypeCommand(const std::string& id, size_t arity, Type t) throw();
+ ~DeclareTypeCommand() throw() {}
+ size_t getArity() const throw();
+ Type getType() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class DeclareTypeCommand */
+
+class CVC4_PUBLIC DefineTypeCommand : public DeclarationDefinitionCommand {
+protected:
+ std::vector<Type> d_params;
+ Type d_type;
+public:
+ DefineTypeCommand(const std::string& id, Type t) throw();
+ DefineTypeCommand(const std::string& id, const std::vector<Type>& params, Type t) throw();
+ ~DefineTypeCommand() throw() {}
+ const std::vector<Type>& getParameters() const throw();
+ Type getType() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class DefineTypeCommand */
+
+class CVC4_PUBLIC DefineFunctionCommand : public DeclarationDefinitionCommand {
+protected:
+ Expr d_func;
+ std::vector<Expr> d_formals;
+ Expr d_formula;
+public:
+ DefineFunctionCommand(const std::string& id, Expr func, Expr formula) throw();
+ DefineFunctionCommand(const std::string& id, Expr func,
+ const std::vector<Expr>& formals, Expr formula) throw();
+ ~DefineFunctionCommand() throw() {}
+ Expr getFunction() const throw();
+ const std::vector<Expr>& getFormals() const throw();
+ Expr getFormula() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class DefineFunctionCommand */
+
+/**
+ * This differs from DefineFunctionCommand only in that it instructs
+ * the SmtEngine to "remember" this function for later retrieval with
+ * getAssignment(). Used for :named attributes in SMT-LIBv2.
+ */
+class CVC4_PUBLIC DefineNamedFunctionCommand : public DefineFunctionCommand {
+public:
+ DefineNamedFunctionCommand(const std::string& id, Expr func,
+ const std::vector<Expr>& formals, Expr formula) throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+};/* class DefineNamedFunctionCommand */
+
+/**
+ * The command when an attribute is set by a user. In SMT-LIBv2 this is done
+ * via the syntax (! expr :attr)
+ */
+class CVC4_PUBLIC SetUserAttributeCommand : public Command {
+protected:
+ std::string d_attr;
+ Expr d_expr;
+ std::vector<Expr> d_expr_values;
+ std::string d_str_value;
+public:
+ SetUserAttributeCommand( const std::string& attr, Expr expr ) throw();
+ SetUserAttributeCommand( const std::string& attr, Expr expr, std::vector<Expr>& values ) throw();
+ SetUserAttributeCommand( const std::string& attr, Expr expr, const std::string& value ) throw();
+ ~SetUserAttributeCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class SetUserAttributeCommand */
+
+class CVC4_PUBLIC CheckSatCommand : public Command {
+protected:
+ Expr d_expr;
+ Result d_result;
+ bool d_inUnsatCore;
+public:
+ CheckSatCommand() throw();
+ CheckSatCommand(const Expr& expr, bool inUnsatCore = true) throw();
+ ~CheckSatCommand() throw() {}
+ Expr getExpr() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Result getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class CheckSatCommand */
+
+class CVC4_PUBLIC QueryCommand : public Command {
+protected:
+ Expr d_expr;
+ Result d_result;
+ bool d_inUnsatCore;
+public:
+ QueryCommand(const Expr& e, bool inUnsatCore = true) throw();
+ ~QueryCommand() throw() {}
+ Expr getExpr() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Result getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class QueryCommand */
+
+// this is TRANSFORM in the CVC presentation language
+class CVC4_PUBLIC SimplifyCommand : public Command {
+protected:
+ Expr d_term;
+ Expr d_result;
+public:
+ SimplifyCommand(Expr term) throw();
+ ~SimplifyCommand() throw() {}
+ Expr getTerm() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Expr getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class SimplifyCommand */
+
+class CVC4_PUBLIC ExpandDefinitionsCommand : public Command {
+protected:
+ Expr d_term;
+ Expr d_result;
+public:
+ ExpandDefinitionsCommand(Expr term) throw();
+ ~ExpandDefinitionsCommand() throw() {}
+ Expr getTerm() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Expr getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class ExpandDefinitionsCommand */
+
+class CVC4_PUBLIC GetValueCommand : public Command {
+protected:
+ std::vector<Expr> d_terms;
+ Expr d_result;
+public:
+ GetValueCommand(Expr term) throw();
+ GetValueCommand(const std::vector<Expr>& terms) throw();
+ ~GetValueCommand() throw() {}
+ const std::vector<Expr>& getTerms() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Expr getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetValueCommand */
+
+class CVC4_PUBLIC GetAssignmentCommand : public Command {
+protected:
+ SExpr d_result;
+public:
+ GetAssignmentCommand() throw();
+ ~GetAssignmentCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ SExpr getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetAssignmentCommand */
+
+class CVC4_PUBLIC GetModelCommand : public Command {
+protected:
+ Model* d_result;
+ SmtEngine* d_smtEngine;
+public:
+ GetModelCommand() throw();
+ ~GetModelCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ // Model is private to the library -- for now
+ //Model* getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetModelCommand */
+
+class CVC4_PUBLIC GetProofCommand : public Command {
+protected:
+ Proof* d_result;
+public:
+ GetProofCommand() throw();
+ ~GetProofCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ Proof* getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetProofCommand */
+
+class CVC4_PUBLIC GetInstantiationsCommand : public Command {
+protected:
+ //Instantiations* d_result;
+ SmtEngine* d_smtEngine;
+public:
+ GetInstantiationsCommand() throw();
+ ~GetInstantiationsCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ //Instantiations* getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetInstantiationsCommand */
+
+class CVC4_PUBLIC GetSynthSolutionCommand : public Command {
+protected:
+ SmtEngine* d_smtEngine;
+public:
+ GetSynthSolutionCommand() throw();
+ ~GetSynthSolutionCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetSynthSolutionCommand */
+
+class CVC4_PUBLIC GetUnsatCoreCommand : public Command {
+protected:
+ UnsatCore d_result;
+ std::map<Expr, std::string> d_names;
+public:
+ GetUnsatCoreCommand() throw();
+ GetUnsatCoreCommand(const std::map<Expr, std::string>& names) throw();
+ ~GetUnsatCoreCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ const UnsatCore& getUnsatCore() const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetUnsatCoreCommand */
+
+class CVC4_PUBLIC GetAssertionsCommand : public Command {
+protected:
+ std::string d_result;
+public:
+ GetAssertionsCommand() throw();
+ ~GetAssertionsCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ std::string getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetAssertionsCommand */
+
+class CVC4_PUBLIC SetBenchmarkStatusCommand : public Command {
+protected:
+ BenchmarkStatus d_status;
+public:
+ SetBenchmarkStatusCommand(BenchmarkStatus status) throw();
+ ~SetBenchmarkStatusCommand() throw() {}
+ BenchmarkStatus getStatus() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class SetBenchmarkStatusCommand */
+
+class CVC4_PUBLIC SetBenchmarkLogicCommand : public Command {
+protected:
+ std::string d_logic;
+public:
+ SetBenchmarkLogicCommand(std::string logic) throw();
+ ~SetBenchmarkLogicCommand() throw() {}
+ std::string getLogic() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class SetBenchmarkLogicCommand */
+
+class CVC4_PUBLIC SetInfoCommand : public Command {
+protected:
+ std::string d_flag;
+ SExpr d_sexpr;
+public:
+ SetInfoCommand(std::string flag, const SExpr& sexpr) throw();
+ ~SetInfoCommand() throw() {}
+ std::string getFlag() const throw();
+ SExpr getSExpr() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class SetInfoCommand */
+
+class CVC4_PUBLIC GetInfoCommand : public Command {
+protected:
+ std::string d_flag;
+ std::string d_result;
+public:
+ GetInfoCommand(std::string flag) throw();
+ ~GetInfoCommand() throw() {}
+ std::string getFlag() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ std::string getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetInfoCommand */
+
+class CVC4_PUBLIC SetOptionCommand : public Command {
+protected:
+ std::string d_flag;
+ SExpr d_sexpr;
+public:
+ SetOptionCommand(std::string flag, const SExpr& sexpr) throw();
+ ~SetOptionCommand() throw() {}
+ std::string getFlag() const throw();
+ SExpr getSExpr() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class SetOptionCommand */
+
+class CVC4_PUBLIC GetOptionCommand : public Command {
+protected:
+ std::string d_flag;
+ std::string d_result;
+public:
+ GetOptionCommand(std::string flag) throw();
+ ~GetOptionCommand() throw() {}
+ std::string getFlag() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ std::string getResult() const throw();
+ void printResult(std::ostream& out, uint32_t verbosity = 2) const throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class GetOptionCommand */
+
+class CVC4_PUBLIC DatatypeDeclarationCommand : public Command {
+private:
+ std::vector<DatatypeType> d_datatypes;
+public:
+ DatatypeDeclarationCommand(const DatatypeType& datatype) throw();
+ ~DatatypeDeclarationCommand() throw() {}
+ DatatypeDeclarationCommand(const std::vector<DatatypeType>& datatypes) throw();
+ const std::vector<DatatypeType>& getDatatypes() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class DatatypeDeclarationCommand */
+
+class CVC4_PUBLIC RewriteRuleCommand : public Command {
+public:
+ typedef std::vector< std::vector< Expr > > Triggers;
+protected:
+ typedef std::vector< Expr > VExpr;
+ VExpr d_vars;
+ VExpr d_guards;
+ Expr d_head;
+ Expr d_body;
+ Triggers d_triggers;
+public:
+ RewriteRuleCommand(const std::vector<Expr>& vars,
+ const std::vector<Expr>& guards,
+ Expr head,
+ Expr body,
+ const Triggers& d_triggers) throw();
+ RewriteRuleCommand(const std::vector<Expr>& vars,
+ Expr head,
+ Expr body) throw();
+ ~RewriteRuleCommand() throw() {}
+ const std::vector<Expr>& getVars() const throw();
+ const std::vector<Expr>& getGuards() const throw();
+ Expr getHead() const throw();
+ Expr getBody() const throw();
+ const Triggers& getTriggers() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class RewriteRuleCommand */
+
+class CVC4_PUBLIC PropagateRuleCommand : public Command {
+public:
+ typedef std::vector< std::vector< Expr > > Triggers;
+protected:
+ typedef std::vector< Expr > VExpr;
+ VExpr d_vars;
+ VExpr d_guards;
+ VExpr d_heads;
+ Expr d_body;
+ Triggers d_triggers;
+ bool d_deduction;
+public:
+ PropagateRuleCommand(const std::vector<Expr>& vars,
+ const std::vector<Expr>& guards,
+ const std::vector<Expr>& heads,
+ Expr body,
+ const Triggers& d_triggers,
+ /* true if we want a deduction rule */
+ bool d_deduction = false) throw();
+ PropagateRuleCommand(const std::vector<Expr>& vars,
+ const std::vector<Expr>& heads,
+ Expr body,
+ bool d_deduction = false) throw();
+ ~PropagateRuleCommand() throw() {}
+ const std::vector<Expr>& getVars() const throw();
+ const std::vector<Expr>& getGuards() const throw();
+ const std::vector<Expr>& getHeads() const throw();
+ Expr getBody() const throw();
+ const Triggers& getTriggers() const throw();
+ bool isDeduction() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class PropagateRuleCommand */
+
+class CVC4_PUBLIC ResetCommand : public Command {
+public:
+ ResetCommand() throw() {}
+ ~ResetCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class ResetCommand */
+
+class CVC4_PUBLIC ResetAssertionsCommand : public Command {
+public:
+ ResetAssertionsCommand() throw() {}
+ ~ResetAssertionsCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class ResetAssertionsCommand */
+
+class CVC4_PUBLIC QuitCommand : public Command {
+public:
+ QuitCommand() throw() {}
+ ~QuitCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class QuitCommand */
+
+class CVC4_PUBLIC CommentCommand : public Command {
+ std::string d_comment;
+public:
+ CommentCommand(std::string comment) throw();
+ ~CommentCommand() throw() {}
+ std::string getComment() const throw();
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class CommentCommand */
+
+class CVC4_PUBLIC CommandSequence : public Command {
+private:
+ /** All the commands to be executed (in sequence) */
+ std::vector<Command*> d_commandSequence;
+ /** Next command to be executed */
+ unsigned int d_index;
+public:
+ CommandSequence() throw();
+ ~CommandSequence() throw();
+
+ void addCommand(Command* cmd) throw();
+ void clear() throw();
+
+ void invoke(SmtEngine* smtEngine) throw();
+ void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
+
+ typedef std::vector<Command*>::iterator iterator;
+ typedef std::vector<Command*>::const_iterator const_iterator;
+
+ const_iterator begin() const throw();
+ const_iterator end() const throw();
+
+ iterator begin() throw();
+ iterator end() throw();
+
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class CommandSequence */
+
+class CVC4_PUBLIC DeclarationSequence : public CommandSequence {
+public:
+ ~DeclarationSequence() throw() {}
+};/* class DeclarationSequence */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__COMMAND_H */
--- /dev/null
+%{
+#include "smt_util/command.h"
+
+#ifdef SWIGJAVA
+
+#include "bindings/java_iterator_adapter.h"
+#include "bindings/java_stream_adapters.h"
+
+#endif /* SWIGJAVA */
+%}
+
+%ignore CVC4::operator<<(std::ostream&, const Command&) throw();
+%ignore CVC4::operator<<(std::ostream&, const Command*) throw();
+%ignore CVC4::operator<<(std::ostream&, const CommandStatus&) throw();
+%ignore CVC4::operator<<(std::ostream&, const CommandStatus*) throw();
+%ignore CVC4::operator<<(std::ostream&, BenchmarkStatus status) throw();
+%ignore CVC4::operator<<(std::ostream&, CommandPrintSuccess) throw();
+
+%ignore CVC4::GetProofCommand;
+%ignore CVC4::CommandPrintSuccess::Scope;
+
+#ifdef SWIGJAVA
+
+// Instead of CommandSequence::begin() and end(), create an
+// iterator() method on the Java side that returns a Java-style
+// Iterator.
+%ignore CVC4::CommandSequence::begin();
+%ignore CVC4::CommandSequence::end();
+%ignore CVC4::CommandSequence::begin() const;
+%ignore CVC4::CommandSequence::end() const;
+%extend CVC4::CommandSequence {
+ CVC4::JavaIteratorAdapter<CVC4::CommandSequence> iterator() {
+ return CVC4::JavaIteratorAdapter<CVC4::CommandSequence>(*$self);
+ }
+}
+
+// CommandSequence is "iterable" on the Java side
+%typemap(javainterfaces) CVC4::CommandSequence "java.lang.Iterable<edu.nyu.acsys.CVC4.Command>";
+
+// the JavaIteratorAdapter should not be public, and implements Iterator
+%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> "class";
+%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> "java.util.Iterator<edu.nyu.acsys.CVC4.Command>";
+// add some functions to the Java side (do it here because there's no way to do these in C++)
+%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::CommandSequence> "
+ public void remove() {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ public edu.nyu.acsys.CVC4.Command next() {
+ if(hasNext()) {
+ return getNext();
+ } else {
+ throw new java.util.NoSuchElementException();
+ }
+ }
+"
+// getNext() just allows C++ iterator access from Java-side next(), make it private
+%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::CommandSequence>::getNext() "private";
+
+// map the types appropriately
+%typemap(jni) CVC4::CommandSequence::const_iterator::value_type "jobject";
+%typemap(jtype) CVC4::CommandSequence::const_iterator::value_type "edu.nyu.acsys.CVC4.Command";
+%typemap(jstype) CVC4::CommandSequence::const_iterator::value_type "edu.nyu.acsys.CVC4.Command";
+%typemap(javaout) CVC4::CommandSequence::const_iterator::value_type { return $jnicall; }
+
+#endif /* SWIGJAVA */
+
+%include "smt_util/command.h"
+
+#ifdef SWIGJAVA
+
+%include "bindings/java_iterator_adapter.h"
+%include "bindings/java_stream_adapters.h"
+
+%template(JavaIteratorAdapter_CommandSequence) CVC4::JavaIteratorAdapter<CVC4::CommandSequence>;
+
+#endif /* SWIGJAVA */
--- /dev/null
+/********************* */
+/*! \file dump.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 Dump utility classes and functions
+ **
+ ** Dump utility classes and functions.
+ **/
+#include "smt_util/dump.h"
+
+#include "base/output.h"
+
+namespace CVC4 {
+
+DumpC DumpChannel CVC4_PUBLIC;
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file dump.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 Dump utility classes and functions
+ **
+ ** Dump utility classes and functions.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__DUMP_H
+#define __CVC4__DUMP_H
+
+#include "base/output.h"
+#include "smt_util/command.h"
+
+namespace CVC4 {
+
+class CVC4_PUBLIC CVC4dumpstream {
+
+#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
+ std::ostream* d_os;
+#endif /* CVC4_DUMPING && !CVC4_MUZZLE */
+
+#ifdef CVC4_PORTFOLIO
+ CommandSequence* d_commands;
+#endif /* CVC4_PORTFOLIO */
+
+public:
+ CVC4dumpstream() throw()
+#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE) && defined(CVC4_PORTFOLIO)
+ : d_os(NULL), d_commands(NULL)
+#elif defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
+ : d_os(NULL)
+#elif defined(CVC4_PORTFOLIO)
+ : d_commands(NULL)
+#endif /* CVC4_PORTFOLIO */
+ { }
+
+ CVC4dumpstream(std::ostream& os, CommandSequence& commands) throw()
+#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE) && defined(CVC4_PORTFOLIO)
+ : d_os(&os), d_commands(&commands)
+#elif defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
+ : d_os(&os)
+#elif defined(CVC4_PORTFOLIO)
+ : d_commands(&commands)
+#endif /* CVC4_PORTFOLIO */
+ { }
+
+ CVC4dumpstream& operator<<(const Command& c) {
+#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
+ if(d_os != NULL) {
+ (*d_os) << c << std::endl;
+ }
+#endif
+#if defined(CVC4_PORTFOLIO)
+ if(d_commands != NULL) {
+ d_commands->addCommand(c.clone());
+ }
+#endif
+ return *this;
+ }
+};/* class CVC4dumpstream */
+
+/** The dump class */
+class CVC4_PUBLIC DumpC {
+ std::set<std::string> d_tags;
+ CommandSequence d_commands;
+
+public:
+ CVC4dumpstream operator()(const char* tag) {
+ if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
+ return CVC4dumpstream(getStream(), d_commands);
+ } else {
+ return CVC4dumpstream();
+ }
+ }
+ CVC4dumpstream operator()(std::string tag) {
+ if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
+ return CVC4dumpstream(getStream(), d_commands);
+ } else {
+ return CVC4dumpstream();
+ }
+ }
+
+ void clear() { d_commands.clear(); }
+ const CommandSequence& getCommands() const { return d_commands; }
+
+ bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
+ bool on (std::string tag) { d_tags.insert(tag); return true; }
+ bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
+ bool off(std::string tag) { d_tags.erase (tag); return false; }
+ bool off() { d_tags.clear(); return false; }
+
+ bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
+ bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
+
+ std::ostream& setStream(std::ostream& os) { DumpOut.setStream(os); return os; }
+ std::ostream& getStream() { return DumpOut.getStream(); }
+};/* class DumpC */
+
+/** The dump singleton */
+extern DumpC DumpChannel CVC4_PUBLIC;
+
+#define Dump ::CVC4::DumpChannel
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__DUMP_H */
--- /dev/null
+/********************* */
+/*! \file ite_removal.cpp
+ ** \verbatim
+ ** Original author: Dejan Jovanovic
+ ** Major contributors: Tim King, Morgan Deters
+ ** Minor contributors (to current version): Kshitij Bansal, Andrew Reynolds, Clark Barrett
+ ** 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 Removal of term ITEs
+ **
+ ** Removal of term ITEs.
+ **/
+#include "smt_util/ite_removal.h"
+
+#include <vector>
+
+#include "proof/proof_manager.h"
+#include "smt_util/command.h"
+#include "theory/ite_utilities.h"
+
+using namespace CVC4;
+using namespace std;
+
+namespace CVC4 {
+
+RemoveITE::RemoveITE(context::UserContext* u)
+ : d_iteCache(u)
+{
+ d_containsVisitor = new theory::ContainsTermITEVisitor();
+}
+
+RemoveITE::~RemoveITE(){
+ delete d_containsVisitor;
+}
+
+void RemoveITE::garbageCollect(){
+ d_containsVisitor->garbageCollect();
+}
+
+theory::ContainsTermITEVisitor* RemoveITE::getContainsVisitor() {
+ return d_containsVisitor;
+}
+
+size_t RemoveITE::collectedCacheSizes() const{
+ return d_containsVisitor->cache_size() + d_iteCache.size();
+}
+
+void RemoveITE::run(std::vector<Node>& output, IteSkolemMap& iteSkolemMap, bool reportDeps)
+{
+ size_t n = output.size();
+ for (unsigned i = 0, i_end = output.size(); i < i_end; ++ i) {
+ // Do this in two steps to avoid Node problems(?)
+ // Appears related to bug 512, splitting this into two lines
+ // fixes the bug on clang on Mac OS
+ Node itesRemoved = run(output[i], output, iteSkolemMap, false);
+ // In some calling contexts, not necessary to report dependence information.
+ if(reportDeps && options::unsatCores()) {
+ // new assertions have a dependence on the node
+ PROOF( ProofManager::currentPM()->addDependence(itesRemoved, output[i]); )
+ while(n < output.size()) {
+ PROOF( ProofManager::currentPM()->addDependence(output[n], output[i]); )
+ ++n;
+ }
+ }
+ output[i] = itesRemoved;
+ }
+}
+
+bool RemoveITE::containsTermITE(TNode e) const {
+ return d_containsVisitor->containsTermITE(e);
+}
+
+Node RemoveITE::run(TNode node, std::vector<Node>& output,
+ IteSkolemMap& iteSkolemMap, bool inQuant) {
+ // Current node
+ Debug("ite") << "removeITEs(" << node << ")" << endl;
+
+ if(node.isVar() || node.isConst() ||
+ (options::biasedITERemoval() && !containsTermITE(node))){
+ return Node(node);
+ }
+
+ // The result may be cached already
+ std::pair<Node, bool> cacheKey(node, inQuant);
+ NodeManager *nodeManager = NodeManager::currentNM();
+ ITECache::const_iterator i = d_iteCache.find(cacheKey);
+ if(i != d_iteCache.end()) {
+ Node cached = (*i).second;
+ Debug("ite") << "removeITEs: in-cache: " << cached << endl;
+ return cached.isNull() ? Node(node) : cached;
+ }
+
+ // Remember that we're inside a quantifier
+ if(node.getKind() == kind::FORALL || node.getKind() == kind::EXISTS) {
+ inQuant = true;
+ }
+
+ // If an ITE replace it
+ if(node.getKind() == kind::ITE) {
+ TypeNode nodeType = node.getType();
+ if(!nodeType.isBoolean() && (!inQuant || !node.hasBoundVar())) {
+ Node skolem;
+ // Make the skolem to represent the ITE
+ skolem = nodeManager->mkSkolem("termITE", nodeType, "a variable introduced due to term-level ITE removal");
+
+ // The new assertion
+ Node newAssertion =
+ nodeManager->mkNode(kind::ITE, node[0], skolem.eqNode(node[1]),
+ skolem.eqNode(node[2]));
+ Debug("ite") << "removeITEs(" << node << ") => " << newAssertion << endl;
+
+ // Attach the skolem
+ d_iteCache.insert(cacheKey, skolem);
+
+ // Remove ITEs from the new assertion, rewrite it and push it to the output
+ newAssertion = run(newAssertion, output, iteSkolemMap, inQuant);
+
+ iteSkolemMap[skolem] = output.size();
+ output.push_back(newAssertion);
+
+ // The representation is now the skolem
+ return skolem;
+ }
+ }
+
+ // If not an ITE, go deep
+ vector<Node> newChildren;
+ bool somethingChanged = false;
+ if(node.getMetaKind() == kind::metakind::PARAMETERIZED) {
+ newChildren.push_back(node.getOperator());
+ }
+ // Remove the ITEs from the children
+ for(TNode::const_iterator it = node.begin(), end = node.end(); it != end; ++it) {
+ Node newChild = run(*it, output, iteSkolemMap, inQuant);
+ somethingChanged |= (newChild != *it);
+ newChildren.push_back(newChild);
+ }
+
+ // If changes, we rewrite
+ if(somethingChanged) {
+ Node cached = nodeManager->mkNode(node.getKind(), newChildren);
+ d_iteCache.insert(cacheKey, cached);
+ return cached;
+ } else {
+ d_iteCache.insert(cacheKey, Node::null());
+ return node;
+ }
+}
+
+Node RemoveITE::replace(TNode node, bool inQuant) const {
+ if(node.isVar() || node.isConst() ||
+ (options::biasedITERemoval() && !containsTermITE(node))){
+ return Node(node);
+ }
+
+ // Check the cache
+ NodeManager *nodeManager = NodeManager::currentNM();
+ ITECache::const_iterator i = d_iteCache.find(make_pair(node, inQuant));
+ if(i != d_iteCache.end()) {
+ Node cached = (*i).second;
+ return cached.isNull() ? Node(node) : cached;
+ }
+
+ // Remember that we're inside a quantifier
+ if(node.getKind() == kind::FORALL || node.getKind() == kind::EXISTS) {
+ inQuant = true;
+ }
+
+ vector<Node> newChildren;
+ bool somethingChanged = false;
+ if(node.getMetaKind() == kind::metakind::PARAMETERIZED) {
+ newChildren.push_back(node.getOperator());
+ }
+ // Replace in children
+ for(TNode::const_iterator it = node.begin(), end = node.end(); it != end; ++it) {
+ Node newChild = replace(*it, inQuant);
+ somethingChanged |= (newChild != *it);
+ newChildren.push_back(newChild);
+ }
+
+ // If changes, we rewrite
+ if(somethingChanged) {
+ return nodeManager->mkNode(node.getKind(), newChildren);
+ } else {
+ return node;
+ }
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file ite_removal.h
+ ** \verbatim
+ ** Original author: Dejan Jovanovic
+ ** Major contributors: Kshitij Bansal, Tim King, Morgan Deters
+ ** Minor contributors (to current version): Clark Barrett
+ ** 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 Removal of term ITEs
+ **
+ ** Removal of term ITEs.
+ **/
+
+#include "cvc4_private.h"
+
+#pragma once
+
+#include <vector>
+
+#include "context/cdinsert_hashmap.h"
+#include "context/context.h"
+#include "expr/node.h"
+#include "smt_util/dump.h"
+#include "util/bool.h"
+#include "util/hash.h"
+
+namespace CVC4 {
+
+namespace theory {
+ class ContainsTermITEVisitor;
+}/* CVC4::theory namespace */
+
+typedef std::hash_map<Node, unsigned, NodeHashFunction> IteSkolemMap;
+
+class RemoveITE {
+ typedef context::CDInsertHashMap< std::pair<Node, bool>, Node, PairHashFunction<Node, bool, NodeHashFunction, BoolHashFunction> > ITECache;
+ ITECache d_iteCache;
+
+
+public:
+
+ RemoveITE(context::UserContext* u);
+ ~RemoveITE();
+
+ /**
+ * Removes the ITE nodes by introducing skolem variables. All
+ * additional assertions are pushed into assertions. iteSkolemMap
+ * contains a map from introduced skolem variables to the index in
+ * assertions containing the new Boolean ite created in conjunction
+ * with that skolem variable.
+ *
+ * With reportDeps true, report reasoning dependences to the proof
+ * manager (for unsat cores).
+ */
+ void run(std::vector<Node>& assertions, IteSkolemMap& iteSkolemMap, bool reportDeps = false);
+
+ /**
+ * Removes the ITE from the node by introducing skolem
+ * variables. All additional assertions are pushed into
+ * assertions. iteSkolemMap contains a map from introduced skolem
+ * variables to the index in assertions containing the new Boolean
+ * ite created in conjunction with that skolem variable.
+ */
+ Node run(TNode node, std::vector<Node>& additionalAssertions,
+ IteSkolemMap& iteSkolemMap, bool inQuant);
+
+ /**
+ * Substitute under node using pre-existing cache. Do not remove
+ * any ITEs not seen during previous runs.
+ */
+ Node replace(TNode node, bool inQuant = false) const;
+
+ /** Returns true if e contains a term ite. */
+ bool containsTermITE(TNode e) const;
+
+ /** Returns the collected size of the caches. */
+ size_t collectedCacheSizes() const;
+
+ /** Garbage collects non-context dependent data-structures. */
+ void garbageCollect();
+
+ /** Return the RemoveITE's containsVisitor. */
+ theory::ContainsTermITEVisitor* getContainsVisitor();
+
+private:
+ theory::ContainsTermITEVisitor* d_containsVisitor;
+
+};/* class RemoveTTE */
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file lemma_input_channel.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_public.h"
+
+#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 {
+
+class CVC4_PUBLIC LemmaInputChannel {
+public:
+ virtual ~LemmaInputChannel() throw() { }
+
+ virtual bool hasNewLemma() = 0;
+ virtual Expr getNewLemma() = 0;
+
+};/* class LemmaOutputChannel */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__LEMMA_INPUT_CHANNEL_H */
--- /dev/null
+/********************* */
+/*! \file lemma_output_channel.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 Mechanism for communication about new lemmas
+ **
+ ** This file defines an interface for use by the theory and propositional
+ ** engines to communicate new lemmas to the "outside world," for example
+ ** for lemma sharing between threads.
+ **/
+
+#include "cvc4_public.h"
+
+#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 {
+
+/**
+ * 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 {
+public:
+ virtual ~LemmaOutputChannel() throw() { }
+
+ /**
+ * Notifies this output channel that there's a new lemma.
+ * The lemma may or may not be in CNF.
+ */
+ virtual void notifyNewLemma(Expr lemma) = 0;
+};/* class LemmaOutputChannel */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__LEMMA_OUTPUT_CHANNEL_H */
--- /dev/null
+/********************* */
+/*! \file model.cpp
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** 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 implementation of Model class
+ **/
+
+#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"
+
+using namespace std;
+
+namespace CVC4 {
+
+std::ostream& operator<<(std::ostream& out, const Model& m) {
+ smt::SmtScope smts(&m.d_smt);
+ Expr::dag::Scope scope(out, false);
+ Printer::getPrinter(options::outputLanguage())->toStream(out, m);
+ return out;
+}
+
+Model::Model() :
+ d_smt(*smt::currentSmtEngine()) {
+}
+
+size_t Model::getNumCommands() const {
+ return d_smt.d_modelCommands->size() + d_smt.d_modelGlobalCommands.size();
+}
+
+const Command* Model::getCommand(size_t i) const {
+ Assert(i < getNumCommands());
+ // index the global commands first, then the locals
+ if(i < d_smt.d_modelGlobalCommands.size()) {
+ return d_smt.d_modelGlobalCommands[i];
+ } else {
+ return (*d_smt.d_modelCommands)[i - d_smt.d_modelGlobalCommands.size()];
+ }
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file model.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 Model class
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__MODEL_H
+#define __CVC4__MODEL_H
+
+#include <iostream>
+#include <vector>
+
+#include "expr/expr.h"
+#include "util/cardinality.h"
+
+namespace CVC4 {
+
+class Command;
+class SmtEngine;
+class Model;
+
+std::ostream& operator<<(std::ostream&, const Model&);
+
+class Model {
+ friend std::ostream& operator<<(std::ostream&, const Model&);
+ friend class SmtEngine;
+
+ /** the input name (file name, etc.) this model is associated to */
+ std::string d_inputName;
+
+protected:
+ /** The SmtEngine we're associated with */
+ SmtEngine& d_smt;
+
+ /** construct the base class; users cannot do this, only CVC4 internals */
+ Model();
+
+public:
+ /** virtual destructor */
+ virtual ~Model() { }
+ /** get number of commands to report */
+ size_t getNumCommands() const;
+ /** get command */
+ const Command* getCommand(size_t i) const;
+ /** get the smt engine that this model is hooked up to */
+ SmtEngine* getSmtEngine() { return &d_smt; }
+ /** get the smt engine (as a pointer-to-const) that this model is hooked up to */
+ const SmtEngine* getSmtEngine() const { return &d_smt; }
+ /** get the input name (file name, etc.) this model is associated to */
+ std::string getInputName() const { return d_inputName; }
+
+public:
+ /** get value for expression */
+ virtual Expr getValue(Expr expr) const = 0;
+ /** get cardinality for sort */
+ virtual Cardinality getCardinality(Type t) const = 0;
+};/* class Model */
+
+class ModelBuilder {
+public:
+ ModelBuilder() { }
+ virtual ~ModelBuilder() { }
+ virtual void buildModel(Model* m, bool fullModel) = 0;
+};/* class ModelBuilder */
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__MODEL_H */
--- /dev/null
+/********************* */
+/*! \file nary_builder.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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+#include "smt_util/nary_builder.h"
+
+#include "expr/metakind.h"
+
+using namespace std;
+
+namespace CVC4 {
+namespace util {
+
+Node NaryBuilder::mkAssoc(Kind kind, const std::vector<Node>& children){
+ if(children.size() == 0){
+ return zeroArity(kind);
+ }else if(children.size() == 1){
+ return children[0];
+ }else{
+ const unsigned int max = kind::metakind::getUpperBoundForKind(kind);
+ const unsigned int min = kind::metakind::getLowerBoundForKind(kind);
+
+ Assert(min <= children.size());
+
+ unsigned int numChildren = children.size();
+ NodeManager* nm = NodeManager::currentNM();
+ if( numChildren <= max ) {
+ return nm->mkNode(kind,children);
+ }
+
+ typedef std::vector<Node>::const_iterator const_iterator;
+ const_iterator it = children.begin() ;
+ const_iterator end = children.end() ;
+
+ /* The new top-level children and the children of each sub node */
+ std::vector<Node> newChildren;
+ std::vector<Node> subChildren;
+
+ while( it != end && numChildren > max ) {
+ /* Grab the next max children and make a node for them. */
+ for(const_iterator next = it + max; it != next; ++it, --numChildren ) {
+ subChildren.push_back(*it);
+ }
+ Node subNode = nm->mkNode(kind,subChildren);
+ newChildren.push_back(subNode);
+ subChildren.clear();
+ }
+
+ /* If there's children left, "top off" the Expr. */
+ if(numChildren > 0) {
+ /* If the leftovers are too few, just copy them into newChildren;
+ * otherwise make a new sub-node */
+ if(numChildren < min) {
+ for(; it != end; ++it) {
+ newChildren.push_back(*it);
+ }
+ } else {
+ for(; it != end; ++it) {
+ subChildren.push_back(*it);
+ }
+ Node subNode = nm->mkNode(kind, subChildren);
+ newChildren.push_back(subNode);
+ }
+ }
+
+ /* It's inconceivable we could have enough children for this to fail
+ * (more than 2^32, in most cases?). */
+ AlwaysAssert( newChildren.size() <= max,
+ "Too many new children in mkAssociative" );
+
+ /* It would be really weird if this happened (it would require
+ * min > 2, for one thing), but let's make sure. */
+ AlwaysAssert( newChildren.size() >= min,
+ "Too few new children in mkAssociative" );
+
+ return nm->mkNode(kind,newChildren);
+ }
+}
+
+Node NaryBuilder::zeroArity(Kind k){
+ using namespace kind;
+ NodeManager* nm = NodeManager::currentNM();
+ switch(k){
+ case AND:
+ return nm->mkConst(true);
+ case OR:
+ return nm->mkConst(false);
+ case PLUS:
+ return nm->mkConst(Rational(0));
+ case MULT:
+ return nm->mkConst(Rational(1));
+ default:
+ return Node::null();
+ }
+}
+
+
+RePairAssocCommutativeOperators::RePairAssocCommutativeOperators()
+ : d_cache()
+{}
+RePairAssocCommutativeOperators::~RePairAssocCommutativeOperators(){}
+size_t RePairAssocCommutativeOperators::size() const{ return d_cache.size(); }
+void RePairAssocCommutativeOperators::clear(){ d_cache.clear(); }
+
+bool RePairAssocCommutativeOperators::isAssociateCommutative(Kind k){
+ using namespace kind;
+ switch(k){
+ case BITVECTOR_CONCAT:
+ case BITVECTOR_AND:
+ case BITVECTOR_OR:
+ case BITVECTOR_XOR:
+ case BITVECTOR_MULT:
+ case BITVECTOR_PLUS:
+ case DISTINCT:
+ case PLUS:
+ case MULT:
+ case AND:
+ case OR:
+ return true;
+ default:
+ return false;
+ }
+}
+
+Node RePairAssocCommutativeOperators::rePairAssocCommutativeOperators(TNode n){
+ if(d_cache.find(n) != d_cache.end()){
+ return d_cache[n];
+ }
+ Node result =
+ isAssociateCommutative(n.getKind()) ?
+ case_assoccomm(n) : case_other(n);
+
+ d_cache[n] = result;
+ return result;
+}
+
+Node RePairAssocCommutativeOperators::case_assoccomm(TNode n){
+ Kind k = n.getKind();
+ Assert(isAssociateCommutative(k));
+ Assert(n.getMetaKind() != kind::metakind::PARAMETERIZED);
+ unsigned N = n.getNumChildren();
+ Assert(N >= 2);
+
+
+ Node last = rePairAssocCommutativeOperators( n[N-1]);
+ Node nextToLast = rePairAssocCommutativeOperators(n[N-2]);
+
+ NodeManager* nm = NodeManager::currentNM();
+ Node last2 = nm->mkNode(k, nextToLast, last);
+
+ if(N <= 2){
+ return last2;
+ } else{
+ Assert(N > 2);
+ Node prevRound = last2;
+ for(unsigned prevPos = N-2; prevPos > 0; --prevPos){
+ unsigned currPos = prevPos-1;
+ Node curr = rePairAssocCommutativeOperators(n[currPos]);
+ Node round = nm->mkNode(k, curr, prevRound);
+ prevRound = round;
+ }
+ return prevRound;
+ }
+}
+
+Node RePairAssocCommutativeOperators::case_other(TNode n){
+ if(n.isConst() || n.isVar()){
+ return n;
+ }
+
+ NodeBuilder<> nb(n.getKind());
+
+ if(n.getMetaKind() == kind::metakind::PARAMETERIZED) {
+ nb << n.getOperator();
+ }
+
+ // Remove the ITEs from the children
+ for(TNode::const_iterator i = n.begin(), end = n.end(); i != end; ++i) {
+ Node newChild = rePairAssocCommutativeOperators(*i);
+ nb << newChild;
+ }
+
+ Node result = (Node)nb;
+ return result;
+}
+
+}/* util namespace */
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file nary_builder.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 [[ Add one-line brief description here ]]
+ **
+ ** [[ Add lengthier description here ]]
+ ** \todo document this file
+ **/
+
+
+#include "cvc4_private.h"
+
+#pragma once
+
+#include <vector>
+#include "expr/node.h"
+
+namespace CVC4{
+namespace util {
+
+class NaryBuilder {
+public:
+ static Node mkAssoc(Kind k, const std::vector<Node>& children);
+ static Node zeroArity(Kind k);
+};/* class NaryBuilder */
+
+class RePairAssocCommutativeOperators {
+public:
+ RePairAssocCommutativeOperators();
+ ~RePairAssocCommutativeOperators();
+
+ Node rePairAssocCommutativeOperators(TNode n);
+
+ static bool isAssociateCommutative(Kind k);
+
+ size_t size() const;
+ void clear();
+private:
+ Node case_assoccomm(TNode n);
+ Node case_other(TNode n);
+
+ typedef std::hash_map<Node, Node, NodeHashFunction> NodeMap;
+ NodeMap d_cache;
+};/* class RePairAssocCommutativeOperators */
+
+}/* util namespace */
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file node_visitor.h
+ ** \verbatim
+ ** Original author: Dejan Jovanovic
+ ** Major contributors: Liana Hadarean, 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 A simple visitor for nodes
+ **
+ ** A simple visitor for nodes.
+ **/
+
+#pragma once
+
+#include "cvc4_private.h"
+
+#include <vector>
+
+#include "expr/node.h"
+
+namespace CVC4 {
+
+/**
+ * Traverses the nodes reverse-topologically (children before parents),
+ * calling the visitor in order.
+ */
+template<typename Visitor>
+class NodeVisitor {
+
+ /** For re-entry checking */
+ static CVC4_THREADLOCAL(bool) s_inRun;
+
+ /**
+ * Guard against NodeVisitor<> being re-entrant.
+ */
+ template <class T>
+ class GuardReentry {
+ T& d_guard;
+ public:
+ GuardReentry(T& guard)
+ : d_guard(guard) {
+ Assert(!d_guard);
+ d_guard = true;
+ }
+ ~GuardReentry() {
+ Assert(d_guard);
+ d_guard = false;
+ }
+ };/* class NodeVisitor<>::GuardReentry */
+
+public:
+
+ /**
+ * Element of the stack.
+ */
+ struct stack_element {
+ /** The node to be visited */
+ TNode node;
+ /** The parent of the node */
+ TNode parent;
+ /** Have the children been queued up for visitation */
+ bool children_added;
+ stack_element(TNode node, TNode parent)
+ : node(node), parent(parent), children_added(false) {}
+ };/* struct preprocess_stack_element */
+
+ /**
+ * Performs the traversal.
+ */
+ static typename Visitor::return_type run(Visitor& visitor, TNode node) {
+
+ GuardReentry<CVC4_THREADLOCAL_TYPE(bool)> guard(s_inRun);
+
+ // Notify of a start
+ visitor.start(node);
+
+ // Do a reverse-topological sort of the subexpressions
+ std::vector<stack_element> toVisit;
+ toVisit.push_back(stack_element(node, node));
+ while (!toVisit.empty()) {
+ stack_element& stackHead = toVisit.back();
+ // The current node we are processing
+ TNode current = stackHead.node;
+ TNode parent = stackHead.parent;
+
+ if (visitor.alreadyVisited(current, parent)) {
+ // If already visited, we're done
+ toVisit.pop_back();
+ } else if (stackHead.children_added) {
+ // Call the visitor
+ visitor.visit(current, parent);
+ // Done with this node, remove from the stack
+ toVisit.pop_back();
+ } else {
+ // Mark that we have added the children
+ stackHead.children_added = true;
+ // We need to add the children
+ for(TNode::iterator child_it = current.begin(); child_it != current.end(); ++ child_it) {
+ TNode childNode = *child_it;
+ if (!visitor.alreadyVisited(childNode, current)) {
+ toVisit.push_back(stack_element(childNode, current));
+ }
+ }
+ }
+ }
+
+ // Notify that we're done
+ return visitor.done(node);
+ }
+
+};/* class NodeVisitor<> */
+
+template <typename Visitor>
+CVC4_THREADLOCAL(bool) NodeVisitor<Visitor>::s_inRun = false;
+
+}/* CVC4 namespace */
** \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;
#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 {
+++ /dev/null
-/********************* */
-/*! \file arith_heuristic_pivot_rule.cpp
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: Tim King
- ** 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 "theory/arith/arith_heuristic_pivot_rule.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, ErrorSelectionRule rule) {
- switch(rule) {
- case MINIMUM_AMOUNT:
- out << "MINIMUM_AMOUNT";
- break;
- case VAR_ORDER:
- out << "VAR_ORDER";
- break;
- case MAXIMUM_AMOUNT:
- out << "MAXIMUM_AMOUNT";
- break;
- default:
- out << "ArithHeuristicPivotRule!UNKNOWN";
- }
-
- return out;
-}
-
-}/* CVC4 namespace */
-
+++ /dev/null
-/********************* */
-/*! \file arith_heuristic_pivot_rule.h
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: Tim King
- ** 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_public.h"
-
-#ifndef __CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H
-#define __CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H
-
-#include <iostream>
-
-namespace CVC4 {
-
-typedef enum {
- VAR_ORDER,
- MINIMUM_AMOUNT,
- MAXIMUM_AMOUNT,
- SUM_METRIC
-} ErrorSelectionRule;
-
-std::ostream& operator<<(std::ostream& out, ErrorSelectionRule rule) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__THEORY__ARITH__ARITH_HEURISTIC_PIVOT_RULE_H */
** \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;
+++ /dev/null
-/********************* */
-/*! \file arith_propagation_mode.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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "theory/arith/arith_propagation_mode.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, ArithPropagationMode mode) {
- switch(mode) {
- case NO_PROP:
- out << "NO_PROP";
- break;
- case UNATE_PROP:
- out << "UNATE_PROP";
- break;
- case BOUND_INFERENCE_PROP:
- out << "BOUND_INFERENCE_PROP";
- break;
- case BOTH_PROP:
- out << "BOTH_PROP";
- break;
- default:
- out << "ArithPropagationMode!UNKNOWN";
- }
-
- return out;
-}
-
-}/* CVC4 namespace */
-
+++ /dev/null
-/********************* */
-/*! \file arith_propagation_mode.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_public.h"
-
-#ifndef __CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H
-#define __CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H
-
-#include <iostream>
-
-namespace CVC4 {
-
-typedef enum {
- NO_PROP,
- UNATE_PROP,
- BOUND_INFERENCE_PROP,
- BOTH_PROP
-} ArithPropagationMode;
-
-std::ostream& operator<<(std::ostream& out, ArithPropagationMode rule) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__THEORY__ARITH__ARITH_PROPAGATION_MODE_H */
** \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 {
** \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;
#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 {
+++ /dev/null
-/********************* */
-/*! \file arith_unate_lemma_mode.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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "theory/arith/arith_unate_lemma_mode.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, ArithUnateLemmaMode mode) {
- switch(mode) {
- case NO_PRESOLVE_LEMMAS:
- out << "NO_PRESOLVE_LEMMAS";
- break;
- case INEQUALITY_PRESOLVE_LEMMAS:
- out << "INEQUALITY_PRESOLVE_LEMMAS";
- break;
- case EQUALITY_PRESOLVE_LEMMAS:
- out << "EQUALITY_PRESOLVE_LEMMAS";
- break;
- case ALL_PRESOLVE_LEMMAS:
- out << "ALL_PRESOLVE_LEMMAS";
- break;
- default:
- out << "ArithUnateLemmaMode!UNKNOWN";
- }
-
- return out;
-}
-
-}/* CVC4 namespace */
-
+++ /dev/null
-/********************* */
-/*! \file arith_unate_lemma_mode.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_public.h"
-
-#ifndef __CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H
-#define __CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H
-
-#include <iostream>
-
-namespace CVC4 {
-
-typedef enum {
- NO_PRESOLVE_LEMMAS,
- INEQUALITY_PRESOLVE_LEMMAS,
- EQUALITY_PRESOLVE_LEMMAS,
- ALL_PRESOLVE_LEMMAS
-} ArithUnateLemmaMode;
-
-std::ostream& operator<<(std::ostream& out, ArithUnateLemmaMode rule) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__THEORY__ARITH__ARITH_UNATE_LEMMA_MODE_H */
#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 {
#pragma once
#include <vector>
+
#include "util/index.h"
#include "util/rational.h"
-
namespace CVC4 {
namespace theory {
namespace arith {
}/* CVC4::theory::arith namespace */
}/* CVC4::theory namespace */
}/* CVC4 namespace */
-
** \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;
#pragma once
-#include "util/statistics_registry.h"
+#include "expr/statistics_registry.h"
#include "theory/arith/simplex.h"
#include "theory/arith/approx_simplex.h"
#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 {
#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 {
** \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 {
#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 {
** \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;
** \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;
#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 {
#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 {
** 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 {
#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 {
** \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;
** 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 {
#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 {
** [[ 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;
#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 {
#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 {
**/
-#include "theory/arith/linear_equality.h"
+#include "base/output.h"
#include "theory/arith/constraint.h"
+#include "theory/arith/linear_equality.h"
using namespace std;
#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 {
#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 {
** \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;
#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 {
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module ARITH "theory/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"
- 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"
- turns on arithmetic propagation (default is 'old', see --arith-prop=help)
-
-# The maximum number of difference pivots to do per invocation of simplex.
-# If this is negative, the number of pivots done is the number of variables.
-# If this is not set by the user, different logics are free to chose different
-# defaults.
-option arithHeuristicPivots --heuristic-pivots=N int16_t :default 0 :read-write
- the number of times to apply the heuristic pivot rule; if N < 0, this defaults to the number of variables; if this is unset, this is tuned by the logic selection
-
-# The maximum number of variable order pivots to do per invocation of simplex.
-# If this is negative, the number of pivots done is unlimited.
-# If this is not set by the user, different logics are free to chose different
-# defaults.
-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"
- 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
-option arithSimplexCheckPeriod --simplex-check-period=N uint16_t :default 200
- the number of pivots to do in simplex before rechecking for a conflict on all variables
-
-# This is the pivots per basic variable that can be done using heuristic choices
-# before variable order must be used.
-# If this is not set by the user, different logics are free to chose different
-# defaults.
-option arithPivotThreshold --pivot-threshold=N uint16_t :default 2 :read-write
- sets the number of pivots using --pivot-rule per basic variable per simplex instance before using variable order
-
-option arithPropagateMaxLength --prop-row-length=N uint16_t :default 16
- sets the maximum row length to be used in propagation
-
-option arithDioSolver /--disable-dio-solver bool :default true
- turns off Linear Diophantine Equation solver (Griggio, JSAT 2012)
-
-# Whether to split (= x y) into (and (<= x y) (>= x y)) in
-# arithmetic preprocessing.
-option arithRewriteEq --enable-arith-rewrite-equalities/--disable-arith-rewrite-equalities bool :default false :read-write
- turns on the preprocessing rewrite turning equalities into a conjunction of inequalities
-/turns off the preprocessing rewrite turning equalities into a conjunction of inequalities
-
-
-option arithMLTrick miplib-trick --enable-miplib-trick/--disable-miplib-trick bool :default false
- turns on the preprocessing step of attempting to infer bounds on miplib problems
-/turns off the preprocessing step of attempting to infer bounds on miplib problems
-
-option arithMLTrickSubstitutions miplib-trick-subs --miplib-trick-subs=N unsigned :default 1
- do substitution for miplib 'tmp' vars if defined in <= N eliminated vars
-
-option doCutAllBounded --cut-all-bounded bool :default false :read-write
- turns on the integer solving step of periodically cutting all integer variables that have both upper and lower bounds
-/turns off the integer solving step of periodically cutting all integer variables that have both upper and lower bounds
-
-option maxCutsInContext --maxCutsInContext unsigned :default 65535
- maximum cuts in a given context before signalling a restart
-
-option revertArithModels --revert-arith-models-on-unsat bool :default false
- revert the arithmetic model to a known safe model on unsat if one is cached
-
-option havePenalties --fc-penalties bool :default false :read-write
- turns on degenerate pivot penalties
-/turns off degenerate pivot penalties
-
-option useFC --use-fcsimplex bool :default false :read-write
- use focusing and converging simplex (FMCAD 2013 submission)
-
-option useSOI --use-soi bool :default false :read-write
- use sum of infeasibility simplex (FMCAD 2013 submission)
-
-option restrictedPivots --restrict-pivots bool :default true :read-write
- have a pivot cap for simplex at effort levels below fullEffort
-
-option collectPivots --collect-pivot-stats bool :default false :read-write
- collect the pivot history
-
-option useApprox --use-approx bool :default false :read-write
- attempt to use an approximate solver
-
-option maxApproxDepth --approx-branch-depth int16_t :default 200 :read-write
- maximum branch depth the approximate solver is allowed to take
-
-option exportDioDecompositions --dio-decomps bool :default false :read-write
- let skolem variables for integer divisibility constraints leak from the dio solver
-
-option newProp --new-prop bool :default false :read-write
- use the new row propagation system
-
-option arithPropAsLemmaLength --arith-prop-clauses uint16_t :default 8 :read-write
- rows shorter than this are propagated as clauses
-
-option soiQuickExplain --soi-qe bool :default false :read-write
- use quick explain to minimize the sum of infeasibility conflicts
-
-option rewriteDivk rewrite-divk --rewrite-divk bool :default false :read-write
- rewrite division and mod when by a constant into linear terms
-
-option trySolveIntStandardEffort --se-solve-int bool :default false
- attempt to use the approximate solve integer method on standard effort
-
-option replayFailureLemma --lemmas-on-replay-failure bool :default false
- attempt to use external lemmas if approximate solve integer failed
-
-option dioSolverTurns --dio-turns int :default 10
- turns in a row dio solver cutting gets
-
-option rrTurns --rr-turns int :default 3
- round robin turn
-
-option dioRepeat --dio-repeat bool :default false
- handle dio solver constraints in mass or one at a time
-
-option replayEarlyCloseDepths --replay-early-close-depth int :default 1
- multiples of the depths to try to close the approx log eagerly
-
-option replayFailurePenalty --replay-failure-penalty int :default 100
- number of solve integer attempts to skips after a numeric failure
-
-option replayNumericFailurePenalty --replay-num-err-penalty int :default 4194304
- number of solve integer attempts to skips after a numeric failure
-
-option replayRejectCutSize --replay-reject-cut unsigned :default 25500
- maximum complexity of any coefficient while replaying cuts
-
-option lemmaRejectCutSize --replay-lemma-reject-cut unsigned :default 25500
- maximum complexity of any coefficient while outputing replaying cut lemmas
-
-option soiApproxMajorFailure --replay-soi-major-threshold double :default .01
- threshold for a major tolerance failure by the approximate solver
-
-option soiApproxMajorFailurePen --replay-soi-major-threshold-pen int :default 50
- threshold for a major tolerance failure by the approximate solver
-
-option soiApproxMinorFailure --replay-soi-minor-threshold double :default .0001
- threshold for a minor tolerance failure by the approximate solver
-
-option soiApproxMinorFailurePen --replay-soi-minor-threshold-pen int :default 10
- threshold for a minor tolerance failure by the approximate solver
-
-option ppAssertMaxSubSize --pp-assert-max-sub-size unsigned :default 2
- threshold for substituting an equality in ppAssert
-
-option maxReplayTree --max-replay-tree int :default 512
- threshold for attempting to replay a tree
-
-
-option pbRewrites --pb-rewrites bool :default false
- apply pseudo boolean rewrites
-
-option pbRewriteThreshold --pb-rewrite-threshold int :default 256
- threshold of number of pseudoboolean variables to have before doing rewrites
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \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 */
** \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;
** \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 {
#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 {
}/* CVC4::theory::arith namespace */
}/* CVC4::theory namespace */
}/* CVC4 namespace */
-
**/
-#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;
#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 {
** [[ 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;
#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 {
** \todo document this file
**/
+#include "base/output.h"
#include "theory/arith/tableau.h"
using namespace std;
#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 {
}/* CVC4::theory::arith namespace */
}/* CVC4::theory namespace */
}/* CVC4 namespace */
-
** \todo document this file
**/
+#include "base/output.h"
#include "theory/arith/tableau_sizes.h"
#include "theory/arith/tableau.h"
**/
#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;
#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;
#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 {
#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 {
#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 {
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
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module ARRAYS "theory/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)
-
-option arraysLazyRIntro1 --arrays-lazy-rintro1 bool :default true :read-write
- turn on optimization to only perform RIntro1 rule lazily (see Jovanovic/Barrett 2012: Being Careful with Theory Combination)
-
-option arraysModelBased --arrays-model-based bool :default false :read-write
- turn on model-based array solver
-
-option arraysEagerIndexSplitting --arrays-eager-index bool :default true :read-write
- turn on eager index splitting for generated array lemmas
-
-option arraysEagerLemmas --arrays-eager-lemmas bool :default false :read-write
- turn on eager lemma generation for arrays
-
-option arraysConfig --arrays-config int :default 0 :read-write
- set different array option configurations - for developers only
-
-option arraysReduceSharing --arrays-reduce-sharing bool :default false :read-write
- use model information to reduce size of care graph for arrays
-
-option arraysPropagate --arrays-prop int :default 2 :read-write
- propagation effort for arrays: 0 is none, 1 is some, 2 is full
-
-endmodule
#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;
** 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;
#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 {
#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;
+++ /dev/null
-/********************* */
-/*! \file boolean_term_conversion_mode.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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include <iostream>
-#include "theory/booleans/boolean_term_conversion_mode.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, theory::booleans::BooleanTermConversionMode mode) {
- switch(mode) {
- case theory::booleans::BOOLEAN_TERM_CONVERT_TO_BITVECTORS:
- out << "BOOLEAN_TERM_CONVERT_TO_BITVECTORS";
- break;
- case theory::booleans::BOOLEAN_TERM_CONVERT_TO_DATATYPES:
- out << "BOOLEAN_TERM_CONVERT_TO_DATATYPES";
- break;
- case theory::booleans::BOOLEAN_TERM_CONVERT_NATIVE:
- out << "BOOLEAN_TERM_CONVERT_NATIVE";
- break;
- default:
- out << "BooleanTermConversionMode!UNKNOWN";
- }
-
- return out;
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file boolean_term_conversion_mode.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__BOOLEAN_TERM_CONVERSION_MODE_H
-#define __CVC4__THEORY__BOOLEANS__BOOLEAN_TERM_CONVERSION_MODE_H
-
-#include <iostream>
-
-namespace CVC4 {
-namespace theory {
-namespace booleans {
-
-typedef enum {
- /**
- * Convert Boolean terms to bitvectors of size 1.
- */
- BOOLEAN_TERM_CONVERT_TO_BITVECTORS,
- /**
- * Convert Boolean terms to enumerations in the Datatypes theory.
- */
- BOOLEAN_TERM_CONVERT_TO_DATATYPES,
- /**
- * Convert Boolean terms to enumerations in the Datatypes theory IF
- * used in a datatypes context, otherwise to a bitvector of size 1.
- */
- BOOLEAN_TERM_CONVERT_NATIVE
-
-} BooleanTermConversionMode;
-
-}/* CVC4::theory::booleans namespace */
-}/* CVC4::theory namespace */
-
-std::ostream& operator<<(std::ostream& out, theory::booleans::BooleanTermConversionMode mode) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__THEORY__BOOLEANS__BOOLEAN_TERM_CONVERSION_MODE_H */
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module BOOLEANS "theory/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"
- policy for converting Boolean terms
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \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 */
#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>
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 \
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 \
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%)" \
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module BUILTIN "theory/builtin/options.h" Builtin theory
-
-endmodule
**/
#include "theory/builtin/theory_builtin_rewriter.h"
-#include "util/chain.h"
+
+#include "expr/chain.h"
using namespace std;
#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 {
** [[ 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;
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) {
** 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 {
** 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
+++ /dev/null
-/********************* */
-/*! \file bitblast_mode.cpp
- ** \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 Bitblast modes for bit-vector solver.
- **
- ** Bitblast modes for bit-vector solver.
- **/
-
-#include "theory/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";
- break;
- case theory::bv::BITBLAST_MODE_EAGER:
- out << "BITBLAST_MODE_EAGER";
- break;
- default:
- out << "BitblastMode:UNKNOWN![" << unsigned(mode) << "]";
- }
-
- return out;
-}
-
-std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode) {
- switch(mode) {
- case theory::bv::BITVECTOR_SLICER_ON:
- out << "BITVECTOR_SLICER_ON";
- break;
- case theory::bv::BITVECTOR_SLICER_OFF:
- out << "BITVECTOR_SLICER_OFF";
- break;
- case theory::bv::BITVECTOR_SLICER_AUTO:
- out << "BITVECTOR_SLICER_AUTO";
- break;
- default:
- out << "BvSlicerMode:UNKNOWN![" << unsigned(mode) << "]";
- }
-
- return out;
-}
-
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file bitblast_mode.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 Bitblasting modes for bit-vector solver.
- **
- ** Bitblasting modes for bit-vector solver.
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__THEORY__BV__BITBLAST_MODE_H
-#define __CVC4__THEORY__BV__BITBLAST_MODE_H
-
-#include <iostream>
-
-namespace CVC4 {
-namespace theory {
-namespace bv {
-
-/** Enumeration of bit-blasting modes */
-enum BitblastMode {
-
- /**
- * Lazy bit-blasting that separates boolean reasoning
- * from term reasoning.
- */
- BITBLAST_MODE_LAZY,
-
- /**
- * Bit-blast eagerly to the bit-vector SAT solver.
- */
- BITBLAST_MODE_EAGER
-};/* enum BitblastMode */
-
-/** Enumeration of bit-vector equality slicer mode */
-enum BvSlicerMode {
-
- /**
- * Force the slicer on.
- */
- BITVECTOR_SLICER_ON,
-
- /**
- * Slicer off.
- */
- BITVECTOR_SLICER_OFF,
-
- /**
- * Auto enable slicer if problem has only equalities.
- */
- BITVECTOR_SLICER_AUTO
-
-};/* enum BvSlicerMode */
-
-
-}/* CVC4::theory::bv namespace */
-}/* CVC4::theory namespace */
-
-std::ostream& operator<<(std::ostream& out, theory::bv::BitblastMode mode) CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream& out, theory::bv::BvSlicerMode mode) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__THEORY__BV__BITBLAST_MODE_H */
#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;
** 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;
#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 {
** 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;
** 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")),
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));
}
}
}
}
d_bv->setConflict(final_conflict);
}
+
+}/* namespace CVC4::theory::bv */
+}/* namespace CVC4::theory */
+}/* namespace CVC4 */
#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;
**/
#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;
InequalitySolver::Statistics::~Statistics() {
StatisticsRegistry::unregisterStat(&d_numCallstoCheck);
}
-
**
** 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;
**/
#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 {
** 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)
, 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);
}
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;
}
// 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) {
if (!hasBBTerm(a)) {
return fullModel? utils::mkConst(utils::getSize(a), 0u) : Node();
}
-
+
Bits bits;
getBBTerm(a, bits);
Integer value(0);
(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 << " "
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; */
** 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;
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module BV "theory/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"
- 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
- 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
- abc command to run AIG simplifications (implies --bitblast-aig, default is "balance;drw")
-
-# Options for lazy bit-blasting
-
-option bitvectorPropagate --bv-propagate bool :default true :read-write :link --bitblast=lazy
- use bit-vector propagation in the bit-blaster
-
-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
- 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
- turn on the inequality solver for the bit-vector theory (only if --bitblast=lazy)
-
-option bitvectorAlgebraicSolver --bv-algebraic-solver bool :default true :read-write :link --bitblast=lazy
- turn on the algebraic solver for the bit-vector theory (only if --bitblast=lazy)
-
-expert-option bitvectorAlgebraicBudget --bv-algebraic-budget unsigned :default 1500 :read-write :link --bv-algebraic-solver
- the budget allowed for the algebraic solver in number of SAT conflicts
-
-# General options
-
-option bitvectorToBool --bv-to-bool bool :default false :read-write
- lift bit-vectors of size 1 to booleans when possible
-
-option bitvectorDivByZeroConst --bv-div-zero-const bool :default false :read-write
- always return -1 on division by zero
-
-expert-option bvExtractArithRewrite --bv-extract-arith bool :default false :read-write
- enable rewrite pushing extract [i:0] over arithmetic operations (can blow up)
-
-expert-option bvAbstraction --bv-abstraction bool :default false :read-write
- mcm benchmark abstraction
-
-expert-option skolemizeArguments --bv-skolemize bool :default false :read-write
- skolemize arguments for bv abstraction (only does something if --bv-abstraction is on)
-
-expert-option bvNumFunc --bv-num-func=NUM unsigned :default 1
- number of function symbols in conflicts that are generalized
-
-expert-option bvEagerExplanations --bv-eager-explanations bool :default false :read-write
- compute bit-blasting propagation explanations eagerly
-
-expert-option bitvectorQuickXplain --bv-quick-xplain bool :default false
- minimize bv conflicts using the QuickXplain algorithm
-
-expert-option bvIntroducePow2 --bv-intro-pow2 bool :default false
- introduce bitvector powers of two as a preprocessing pass
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \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 */
** 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;
#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
**
** [[ 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;
** 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 {
** \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 {
#pragma once
+#include "theory/rewriter.h"
#include "theory/bv/theory_bv_rewrite_rules.h"
#include "theory/bv/theory_bv_utils.h"
** \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;
>::apply(node);
return result;
}
-
-
-
#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 {
**/
#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 &&
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 &&
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;
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;
collectVariables(node[i], vars);
}
}
+
+}/* CVC4::theory::bv::utils namespace */
+}/* CVC4::theory::bv namespace */
+}/* CVC4::theory namespace */
+}/* CVC4 namespace */
#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 {
#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 {
}/* CVC4 namespace */
#endif /* __CVC4__THEORY__DATATYPES__DATATYPES_REWRITER_H */
-
**/
-#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;
#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"
namespace CVC4 {
namespace theory {
-
namespace quantifiers {
class TermDbSygus;
-}
-
+} /* namespace quantifiers */
+
namespace datatypes {
class SygusSplit
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" \
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" \
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
constant RECORD_TYPE \
::CVC4::Record \
::CVC4::RecordHashFunction \
- "util/record.h" \
+ "expr/record.h" \
"record type"
cardinality RECORD_TYPE \
"::CVC4::theory::datatypes::TupleProperties::computeCardinality(%TYPE%)" \
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
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
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module DATATYPES "theory/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.
-# For example, by default cvc4 considers cdr( nil ) = nil. If this option is set, then
-# cdr( nil ) has no set value.
-expert-option dtRewriteErrorSel --dt-rewrite-error-sel bool :default false :read-write
- rewrite incorrectly applied selectors to arbitrary ground term
-option dtForceAssignment --dt-force-assignment bool :default false :read-write
- force the datatypes solver to give specific values to all datatypes terms before answering sat
-option dtBinarySplit --dt-binary-split bool :default false
- do binary splits for datatype constructor types
-option cdtBisimilar --cdt-bisimilar bool :default true
- do bisimilarity check for co-datatypes
-option dtCyclic --dt-cyclic bool :default true
- do cyclicity check for datatypes
-
-endmodule
**
** 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;
#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 {
#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 {
+++ /dev/null
-/********************* */
-/*! \file decision_attributes.h
- ** \verbatim
- ** Original author: Kshitij Bansal
- ** 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 Rewriter attributes
- **
- ** Rewriter attributes.
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__THEORY__DECISION_ATTRIBUTES
-#define __CVC4__THEORY__DECISION_ATTRIBUTES
-
-#include "expr/attribute.h"
-
-namespace CVC4 {
-namespace decision {
-typedef uint64_t DecisionWeight;
-}
-namespace theory {
-namespace attr {
- struct DecisionWeightTag {};
-}/* CVC4::theory::attr namespace */
-
-typedef expr::Attribute<attr::DecisionWeightTag, decision::DecisionWeight> DecisionWeightAttr;
-
-}/* CVC4::theory namespace */
-}/* CVC4 namespace */
-
-#endif /* __CVC4__THEORY__DECISION_ATTRIBUTES */
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module FP "theory/fp/options.h" Fp
-
-endmodule
+++ /dev/null
-#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 */
** ]]
**/
-#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 {
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module IDL "theory/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)
-/disable rewriting equalities into two inequalities in IDL solver (default is disabled)
-
-endmodule
**/
#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;
#ifndef __CVC4__THEORY__INTERRUPTED_H
#define __CVC4__THEORY__INTERRUPTED_H
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
namespace theory {
#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 {
** 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;
#include <string>
#include <vector>
#include "expr/kind.h"
+#include "options/logic_info_forward.h"
namespace CVC4 {
}/* CVC4 namespace */
#endif /* __CVC4__LOGIC_INFO_H */
-
+++ /dev/null
-#
-# 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
+++ /dev/null
-/********************* */
-/*! \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 */
#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 {
**/
+#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;
** 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;
bool BoundedIntegers::isGroundRange(Node f, Node v) {
return isBoundVar(f,v) && !getLowerBound(f,v).hasBoundVar() && !getUpperBound(f,v).hasBoundVar();
}
-
** \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;
** \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;
#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 {
** \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;
Trace(c) << std::endl;
}
-}
\ No newline at end of file
+}
**
**/
-#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;
return false;
}
-}
\ No newline at end of file
+}
** \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;
**
** \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
#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 {
**
**/
+#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;
** \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
** \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;
**
** [[ 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;
**
** \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;
#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 {
#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;
void FullSaturation::registerQuantifier( Node q ) {
}
-
#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 {
#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;
** 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;
}
}
}
-}
\ No newline at end of file
+}
** \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;
Debug("fmf-model-cons") << " Finished constructing model for " << op << "." << std::endl;
}
}
-
-
**/
#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;
StatisticsRegistry::unregisterStat(&d_exh_inst_lemmas);
StatisticsRegistry::unregisterStat(&d_mbqi_inst_lemmas);
}
-
-
+++ /dev/null
-/********************* */
-/*! \file modes.cpp
- ** \verbatim
- ** Original author: Andrew Reynolds
- ** 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 ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include <iostream>
-#include "theory/quantifiers/modes.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, theory::quantifiers::InstWhenMode mode) {
- switch(mode) {
- case theory::quantifiers::INST_WHEN_PRE_FULL:
- out << "INST_WHEN_PRE_FULL";
- break;
- case theory::quantifiers::INST_WHEN_FULL:
- out << "INST_WHEN_FULL";
- break;
- case theory::quantifiers::INST_WHEN_FULL_LAST_CALL:
- out << "INST_WHEN_FULL_LAST_CALL";
- break;
- case theory::quantifiers::INST_WHEN_LAST_CALL:
- out << "INST_WHEN_LAST_CALL";
- break;
- default:
- out << "InstWhenMode!UNKNOWN";
- }
-
- return out;
-}
-
-std::ostream& operator<<(std::ostream& out, theory::quantifiers::LiteralMatchMode mode) {
- switch(mode) {
- case theory::quantifiers::LITERAL_MATCH_NONE:
- out << "LITERAL_MATCH_NONE";
- break;
- case theory::quantifiers::LITERAL_MATCH_PREDICATE:
- out << "LITERAL_MATCH_PREDICATE";
- break;
- case theory::quantifiers::LITERAL_MATCH_EQUALITY:
- out << "LITERAL_MATCH_EQUALITY";
- break;
- default:
- out << "LiteralMatchMode!UNKNOWN";
- }
-
- return out;
-}
-
-std::ostream& operator<<(std::ostream& out, theory::quantifiers::MbqiMode mode) {
- switch(mode) {
- case theory::quantifiers::MBQI_GEN_EVAL:
- out << "MBQI_GEN_EVAL";
- break;
- case theory::quantifiers::MBQI_NONE:
- out << "MBQI_NONE";
- break;
- case theory::quantifiers::MBQI_FMC:
- out << "MBQI_FMC";
- break;
- case theory::quantifiers::MBQI_ABS:
- out << "MBQI_ABS";
- break;
- case theory::quantifiers::MBQI_TRUST:
- out << "MBQI_TRUST";
- break;
- default:
- out << "MbqiMode!UNKNOWN";
- }
- return out;
-}
-
-}/* CVC4 namespace */
-
+++ /dev/null
-/********************* */
-/*! \file modes.h
- ** \verbatim
- ** Original author: Andrew Reynolds
- ** 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 ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__THEORY__QUANTIFIERS__MODES_H
-#define __CVC4__THEORY__QUANTIFIERS__MODES_H
-
-#include <iostream>
-
-namespace CVC4 {
-namespace theory {
-namespace quantifiers {
-
-typedef enum {
- /** Apply instantiation round before full effort (possibly at standard effort) */
- INST_WHEN_PRE_FULL,
- /** Apply instantiation round at full effort or above */
- INST_WHEN_FULL,
- /** Apply instantiation round at full effort, after all other theories finish, or above */
- INST_WHEN_FULL_DELAY,
- /** Apply instantiation round at full effort half the time, and last call always */
- INST_WHEN_FULL_LAST_CALL,
- /** Apply instantiation round at full effort after all other theories finish half the time, and last call always */
- INST_WHEN_FULL_DELAY_LAST_CALL,
- /** Apply instantiation round at last call only */
- INST_WHEN_LAST_CALL,
-} InstWhenMode;
-
-typedef enum {
- /** 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 {
- /** mbqi from CADE 24 paper */
- MBQI_GEN_EVAL,
- /** no mbqi */
- MBQI_NONE,
- /** default, mbqi from Section 5.4.2 of AJR thesis */
- MBQI_FMC,
- /** mbqi with integer intervals */
- MBQI_FMC_INTERVAL,
- /** abstract mbqi algorithm */
- MBQI_ABS,
- /** mbqi trust (produce no instantiations) */
- MBQI_TRUST,
-} MbqiMode;
-
-typedef enum {
- /** default, apply at full effort */
- QCF_WHEN_MODE_DEFAULT,
- /** apply at last call */
- QCF_WHEN_MODE_LAST_CALL,
- /** apply at standard effort */
- QCF_WHEN_MODE_STD,
- /** apply based on heuristics */
- QCF_WHEN_MODE_STD_H,
-} QcfWhenMode;
-
-typedef enum {
- /** default, use qcf for conflicts only */
- QCF_CONFLICT_ONLY,
- /** use qcf for conflicts and propagations */
- QCF_PROP_EQ,
- /** use qcf for conflicts, propagations and heuristic instantiations */
- QCF_PARTIAL,
- /** use qcf for model checking */
- QCF_MC,
-} QcfMode;
-
-typedef enum {
- /** use but do not trust */
- USER_PAT_MODE_USE,
- /** default, if patterns are supplied for a quantifier, use only those */
- USER_PAT_MODE_TRUST,
- /** resort to user patterns only when necessary */
- USER_PAT_MODE_RESORT,
- /** ignore user patterns */
- USER_PAT_MODE_IGNORE,
- /** interleave use/resort for user patterns */
- USER_PAT_MODE_INTERLEAVE,
-} UserPatMode;
-
-typedef enum {
- /** 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 {
- /** default : prenex quantifiers without user patterns */
- PRENEX_NO_USER_PAT,
- /** prenex all */
- PRENEX_ALL,
- /** prenex none */
- PRENEX_NONE,
-} PrenexQuantMode;
-
-typedef enum {
- /** enforce fairness by UF corresponding to datatypes size */
- CEGQI_FAIR_UF_DT_SIZE,
- /** enforce fairness by datatypes size */
- CEGQI_FAIR_DT_SIZE,
- /** enforce fairness by datatypes height bound */
- CEGQI_FAIR_DT_HEIGHT_PRED,
- /** do not use fair strategy for CEGQI */
- CEGQI_FAIR_NONE,
-} CegqiFairMode;
-
-typedef enum {
- /** consider all terms in master equality engine */
- TERM_DB_ALL,
- /** consider only relevant terms */
- TERM_DB_RELEVANT,
-} TermDbMode;
-
-typedef enum {
- /** 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 {
- /** 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 {
- /** 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 */
-
-std::ostream& operator<<(std::ostream& out, theory::quantifiers::InstWhenMode mode) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__THEORY__QUANTIFIERS__MODES_H */
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module QUANTIFIERS "theory/quantifiers/options.h" Quantifiers
-
-#### rewriter options
-
-# Whether to mini-scope quantifiers.
-# For example, forall x. ( P( x ) ^ Q( x ) ) will be rewritten to
-# ( forall x. P( x ) ) ^ ( forall x. Q( x ) )
-option miniscopeQuant --miniscope-quant bool :default true :read-write
- miniscope quantifiers
-# Whether to mini-scope quantifiers based on formulas with no free variables.
-# For example, forall x. ( P( x ) V Q ) will be rewritten to
-# ( forall x. P( x ) ) V Q
-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"
- 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
-# forall y. P( c, y )
-option varElimQuant --var-elim-quant bool :default true
- enable simple variable elimination for quantified formulas
-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"
- ite lifting mode for quantified formulas
-option condVarSplitQuant --cond-var-split-quant bool :default true
- split quantified formulas that lead to variable eliminations
-option condVarSplitQuantAgg --cond-var-split-agg-quant bool :default false
- aggressive split quantified formulas that lead to variable eliminations
-option iteDtTesterSplitQuant --ite-dtt-split-quant bool :read-write :default false
- split ites with dt testers as conditions
-# Whether to CNF quantifier bodies
-# option cnfQuant --cnf-quant bool :default false
-# apply CNF conversion to quantified formulas
-option nnfQuant --nnf-quant bool :default true
- apply NNF conversion to quantified formulas
-# Whether to pre-skolemize quantifier bodies.
-# For example, forall x. ( P( x ) => (exists y. f( y ) = x) ) will be rewritten to
-# forall x. P( x ) => f( S( x ) ) = x
-option preSkolemQuant --pre-skolem-quant bool :read-write :default false
- apply skolemization eagerly to bodies of quantified formulas
-option preSkolemQuantNested --pre-skolem-quant-nested bool :read-write :default true
- apply skolemization to nested quantified formulass
-option preSkolemQuantAgg --pre-skolem-quant-agg bool :read-write :default true
- apply skolemization to quantified formulas aggressively
-option aggressiveMiniscopeQuant --ag-miniscope-quant bool :default false
- perform aggressive miniscoping for quantifiers
-option elimTautQuant --elim-taut-quant bool :default true
- eliminate tautological disjuncts of quantified formulas
-option purifyQuant --purify-quant bool :default false
- purify quantified formulas
-
-#### E-matching options
-
-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"
- 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
-
-option smartTriggers --smart-triggers bool :default true
- enable smart triggers
-option relevantTriggers --relevant-triggers bool :default false
- prefer triggers that are more relevant based on SInE style analysis
-option relationalTriggers --relational-triggers bool :default false
- choose relational triggers such as x = f(y), x >= f(y)
-option purifyTriggers --purify-triggers bool :default false :read-write
- purify triggers, e.g. f( x+1 ) becomes f( y ), x mapsto y-1
-option purifyDtTriggers --purify-dt-triggers bool :default false :read-write
- purify dt triggers, match all constructors of correct form instead of selectors
-option pureThTriggers --pure-th-triggers bool :default false :read-write
- use pure theory terms as single triggers
-option partialTriggers --partial-triggers bool :default false :read-write
- use triggers that do not contain all free variables
-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"
- 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"
- 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"
- when to apply instantiation
-
-option instMaxLevel --inst-max-level=N int :read-write :default -1
- maximum inst level of terms used to instantiate quantified formulas with (-1 == no limit, default)
-option instLevelInputOnly --inst-level-input-only bool :default true
- only input terms are assigned instantiation level zero
-option internalReps --quant-internal-reps bool :default true
- instantiate with representatives chosen by quantifiers engine
-
-option eagerInstQuant --eager-inst-quant bool :default false
- apply quantifier instantiation eagerly
-
-option fullSaturateQuant --full-saturate-quant bool :default false :read-write
- when all other quantifier instantiation strategies fail, instantiate with ground terms from relevant domain, then arbitrary ground terms before answering unknown
-option fullSaturateQuantRd --full-saturate-quant-rd bool :default true
- whether to use relevant domain first for full saturation instantiation strategy
-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"
- choose literal matching mode
-
-### finite model finding options
-
-option finiteModelFind finite-model-find --finite-model-find bool :default false :read-write
- use finite model finding heuristic for quantifier instantiation
-
-option quantFunWellDefined --quant-fun-wd bool :default false
- assume that function defined by quantifiers are well defined
-option fmfFunWellDefined --fmf-fun bool :default false :read-write
- find models for recursively defined functions, assumes functions are admissible
-option fmfFunWellDefinedRelevant --fmf-fun-rlv bool :default false
- find models for recursively defined functions, assumes functions are admissible, allows empty type when function is irrelevant
-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"
- 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
-option fmfOneQuantPerRound --mbqi-one-quant-per-round bool :default false
- only add instantiations for one quantifier per round for mbqi
-
-option fmfInstEngine --fmf-inst-engine bool :default false
- use instantiation engine in conjunction with finite model finding
-option fmfInstGen --fmf-inst-gen bool :default true
- enable Inst-Gen instantiation techniques for finite model finding
-option fmfInstGenOneQuantPerRound --fmf-inst-gen-one-quant-per-round bool :default false
- only perform Inst-Gen instantiation techniques on one quantifier per round
-option fmfFreshDistConst --fmf-fresh-dc bool :default false
- use fresh distinguished representative when applying Inst-Gen techniques
-option fmfFmcSimple --fmf-fmc-simple bool :default true
- simple models in full model check for finite model finding
-option fmfBoundInt fmf-bound-int --fmf-bound-int bool :default false :read-write
- finite model finding on bounded integer quantification
-option fmfBoundIntLazy --fmf-bound-int-lazy bool :default false :read-write
- enforce bounds for bounded integer quantification lazily via use of proxy variables
-
-### conflict-based instantiation options
-
-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"
- 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"
- 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
-option qcfAllConflict --qcf-all-conflict bool :read-write :default false
- add all available conflicting instances during conflict-based instantiation
-
-option instNoEntail --inst-no-entail bool :read-write :default true
- do not consider instances of quantified formulas that are currently entailed
-
-### rewrite rules options
-
-option quantRewriteRules --rewrite-rules bool :default false
- use rewrite rules module
-option rrOneInstPerRound --rr-one-inst-per-round bool :default false
- add one instance of rewrite rule per round
-
-### induction options
-
-option quantInduction --quant-ind bool :default false
- use all available techniques for inductive reasoning
-option dtStcInduction --dt-stc-ind bool :read-write :default false
- apply strengthening for existential quantification over datatypes based on structural induction
-option intWfInduction --int-wf-ind bool :read-write :default false
- apply strengthening for integers based on well-founded induction
-option conjectureGen --conjecture-gen bool :read-write :default false
- generate candidate conjectures for inductive proofs
-
-option conjectureGenPerRound --conjecture-gen-per-round=N int :default 1
- number of conjectures to generate per instantiation round
-option conjectureNoFilter --conjecture-no-filter bool :default false
- do not filter conjectures
-option conjectureFilterActiveTerms --conjecture-filter-active-terms bool :read-write :default true
- filter based on active terms
-option conjectureFilterCanonical --conjecture-filter-canonical bool :read-write :default true
- filter based on canonicity
-option conjectureFilterModel --conjecture-filter-model bool :read-write :default true
- filter based on model
-option conjectureGenGtEnum --conjecture-gen-gt-enum=N int :default 50
- number of ground terms to generate for model filtering
-option conjectureUeeIntro --conjecture-gen-uee-intro bool :default false
- more aggressive merging for universal equality engine, introduces terms
-
-### synthesis options
-
-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"
- if and how to apply fairness for cegqi
-option cegqiSingleInv --cegqi-si bool :default false :read-write
- process single invocation synthesis conjectures
-option cegqiSingleInvPartial --cegqi-si-partial bool :default false
- combined techniques for synthesis conjectures that are partially single invocation
-option cegqiSingleInvReconstruct --cegqi-si-reconstruct bool :default true
- reconstruct solutions for single invocation conjectures in original grammar
-option cegqiSingleInvReconstructConst --cegqi-si-reconstruct-const bool :default true
- include constants when reconstruct solutions for single invocation conjectures in original grammar
-option cegqiSingleInvAbort --cegqi-si-abort bool :default false
- abort if synthesis conjecture is not single invocation
-option cegqiSingleInvMultiInstAbort --cegqi-si-multi-inst-abort bool :default false
- abort if synthesis conjecture is single invocation with no ITE in grammar and multiple instantiations are tried
-
-option sygusNormalForm --sygus-nf bool :default true
- only search for sygus builtin terms that are in normal form
-option sygusNormalFormArg --sygus-nf-arg bool :default true
- account for relationship between arguments of operations in sygus normal form
-option sygusNormalFormGlobal --sygus-nf-sym bool :default true
- narrow sygus search space based on global state of current candidate program
-option sygusNormalFormGlobalGen --sygus-nf-sym-gen bool :default true
- generalize lemmas for global search space narrowing
-option sygusNormalFormGlobalArg --sygus-nf-sym-arg bool :default true
- generalize based on arguments in global search space narrowing
-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"
- template mode for sygus invariant synthesis
-
-# approach applied to general quantified formulas
-option cbqiSplx --cbqi-splx bool :read-write :default false
- turns on old implementation of counterexample-based quantifier instantiation
-option cbqi --cbqi bool :read-write :default false
- turns on counterexample-based quantifier instantiation
-option recurseCbqi --cbqi-recurse bool :default true
- turns on recursive counterexample-based quantifier instantiation
-option cbqiSat --cbqi-sat bool :read-write :default true
- answer sat when quantifiers are asserted with counterexample-based quantifier instantiation
-option cbqiModel --cbqi-model bool :read-write :default true
- guide instantiations by model values for counterexample-based quantifier instantiation
-option cbqiAll --cbqi-all bool :read-write :default false
- apply counterexample-based instantiation to all quantified formulas
-option cbqiUseInfInt --cbqi-use-inf-int bool :read-write :default false
- use integer infinity for vts in counterexample-based quantifier instantiation
-option cbqiUseInfReal --cbqi-use-inf-real bool :read-write :default false
- use real infinity for vts in counterexample-based quantifier instantiation
-option cbqiPreRegInst --cbqi-prereg-inst bool :read-write :default false
- preregister ground instantiations in counterexample-based quantifier instantiation
-option cbqiMinBounds --cbqi-min-bounds bool :default false
- use minimally constrained lower/upper bound for counterexample-based quantifier instantiation
-option cbqiSymLia --cbqi-sym-lia bool :default false
- use symbolic integer division in substitutions for counterexample-based quantifier instantiation
-option cbqiRoundUpLowerLia --cbqi-round-up-lia bool :default false
- round up integer lower bounds in substitutions for counterexample-based quantifier instantiation
-option cbqiMidpoint --cbqi-midpoint bool :default false
- choose substitutions based on midpoints of lower and upper bounds for counterexample-based quantifier instantiation
-option cbqiNopt --cbqi-nopt bool :default true
- non-optimal bounds for counterexample-based quantifier instantiation
-
-### local theory extensions options
-
-option localTheoryExt --local-t-ext bool :default false
- do instantiation based on local theory extensions
-option ltePartialInst --lte-partial-inst bool :default false
- partially instantiate local theory quantifiers
-option lteRestrictInstClosure --lte-restrict-inst-closure bool :default false
- treat arguments of inst closure as restricted terms for instantiation
-
-### reduction options
-
-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"
- mode for quantifiers macro expansion
-
-### recursive function options
-
-#option funDefs --fun-defs bool :default false
-# enable specialized techniques for recursive function definitions
-
-### e-unification options
-
-option quantEqualityEngine --quant-ee bool :default false
- maintain congrunce closure over universal equalities
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \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 */
**
**/
+#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;
**/
#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;
**/
#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;
**/
#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;
**
**/
+#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;
#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 {
**/
#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;
out << n;
}
}
-
** 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;
#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;
#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 {
**/
#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;
**/
#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;
#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 {
** \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;
#include "expr/node.h"
#include "util/unsafe_interrupt_exception.h"
-//#include "expr/attribute.h"
-
namespace CVC4 {
namespace theory {
#pragma once
+#include "expr/node.h"
+
namespace CVC4 {
namespace expr {
namespace pattern {
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
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module SETS "theory/sets/options.h" Sets
-
-option setsPropagate --sets-propagate bool :default true
- determines whether to propagate learnt facts to Theory Engine / SAT solver
-
-option setsEagerLemmas --sets-eager-lemmas bool :default true
- add lemmas even at regular effort
-
-expert-option setsCare1 --sets-care1 bool :default false
- generate one lemma at a time for care graph
-
-option setsPropFull --sets-prop-full bool :default true
- additional propagation at full effort
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \file options_handlers.h
- ** \verbatim
- ** Original author: Kshitij Bansal
- ** 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__SETS__OPTIONS_HANDLERS_H
-#define __CVC4__THEORY__SETS__OPTIONS_HANDLERS_H
-
-namespace CVC4 {
-namespace theory {
-namespace sets {
-
-}/* CVC4::theory::sets namespace */
-}/* CVC4::theory namespace */
-}/* CVC4 namespace */
-
-#endif /* __CVC4__THEORY__SETS__OPTIONS_HANDLERS_H */
** 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;
#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 {
--- /dev/null
+/********************* */
+/*! \file sort_inference.cpp
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** Major contributors: Morgan Deters
+ ** Minor contributors (to current version): Kshitij Bansal
+ ** 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 Sort inference module
+ **
+ ** This class implements sort inference, based on a simple algorithm:
+ ** First, we assume all functions and predicates have distinct uninterpreted types.
+ ** One pass is made through the input assertions, while a union-find data structure
+ ** maintains necessary information regarding constraints on these types.
+ **/
+
+#include "theory/sort_inference.h"
+
+#include <vector>
+
+#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 std;
+
+namespace CVC4 {
+
+void SortInference::UnionFind::print(const char * c){
+ for( std::map< int, int >::iterator it = d_eqc.begin(); it != d_eqc.end(); ++it ){
+ Trace(c) << "s_" << it->first << " = s_" << it->second << ", ";
+ }
+ for( unsigned i=0; i<d_deq.size(); i++ ){
+ Trace(c) << "s_" << d_deq[i].first << " != s_" << d_deq[i].second << ", ";
+ }
+ 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 ){
+ d_eqc[ it->first ] = it->second;
+ }
+ 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 ){
+ return t;
+ }else{
+ int rt = getRepresentative( it->second );
+ d_eqc[t] = rt;
+ return rt;
+ }
+}
+
+void SortInference::UnionFind::setEqual( int t1, int t2 ){
+ if( t1!=t2 ){
+ int rt1 = getRepresentative( t1 );
+ int rt2 = getRepresentative( t2 );
+ if( rt1>rt2 ){
+ d_eqc[rt1] = rt2;
+ }else{
+ d_eqc[rt2] = rt1;
+ }
+ }
+}
+
+bool SortInference::UnionFind::isValid() {
+ for( unsigned i=0; i<d_deq.size(); i++ ){
+ if( areEqual( d_deq[i].first, d_deq[i].second ) ){
+ return false;
+ }
+ }
+ return true;
+}
+
+
+void SortInference::recordSubsort( TypeNode tn, int s ){
+ s = d_type_union_find.getRepresentative( s );
+ if( std::find( d_sub_sorts.begin(), d_sub_sorts.end(), s )==d_sub_sorts.end() ){
+ d_sub_sorts.push_back( s );
+ d_type_sub_sorts[tn].push_back( s );
+ }
+}
+
+void SortInference::printSort( const char* c, int t ){
+ int rt = d_type_union_find.getRepresentative( t );
+ if( d_type_types.find( rt )!=d_type_types.end() ){
+ Trace(c) << d_type_types[rt];
+ }else{
+ Trace(c) << "s_" << rt;
+ }
+}
+
+void SortInference::reset() {
+ d_sub_sorts.clear();
+ d_non_monotonic_sorts.clear();
+ d_type_sub_sorts.clear();
+ //reset info
+ sortCount = 1;
+ d_type_union_find.clear();
+ d_type_types.clear();
+ d_id_for_types.clear();
+ d_op_return_types.clear();
+ d_op_arg_types.clear();
+ d_var_types.clear();
+ //for rewriting
+ d_symbol_map.clear();
+ d_const_map.clear();
+}
+
+bool SortInference::simplify( std::vector< Node >& assertions ){
+ Trace("sort-inference") << "Calculating sort inference..." << std::endl;
+ //process all assertions
+ for( unsigned i=0; i<assertions.size(); i++ ){
+ Trace("sort-inference-debug") << "Process " << assertions[i] << std::endl;
+ std::map< Node, Node > var_bound;
+ process( assertions[i], var_bound );
+ }
+ for( std::map< Node, int >::iterator it = d_op_return_types.begin(); it != d_op_return_types.end(); ++it ){
+ Trace("sort-inference") << it->first << " : ";
+ TypeNode retTn = it->first.getType();
+ if( !d_op_arg_types[ it->first ].empty() ){
+ Trace("sort-inference") << "( ";
+ for( size_t i=0; i<d_op_arg_types[ it->first ].size(); i++ ){
+ recordSubsort( retTn[i], d_op_arg_types[ it->first ][i] );
+ printSort( "sort-inference", d_op_arg_types[ it->first ][i] );
+ Trace("sort-inference") << " ";
+ }
+ Trace("sort-inference") << ") -> ";
+ retTn = retTn[(int)retTn.getNumChildren()-1];
+ }
+ recordSubsort( retTn, it->second );
+ printSort( "sort-inference", it->second );
+ Trace("sort-inference") << std::endl;
+ }
+ for( std::map< Node, std::map< Node, int > >::iterator it = d_var_types.begin(); it != d_var_types.end(); ++it ){
+ Trace("sort-inference") << "Quantified formula : " << it->first << " : " << std::endl;
+ for( unsigned i=0; i<it->first[0].getNumChildren(); i++ ){
+ recordSubsort( it->first[0][i].getType(), it->second[it->first[0][i]] );
+ printSort( "sort-inference", it->second[it->first[0][i]] );
+ Trace("sort-inference") << std::endl;
+ }
+ Trace("sort-inference") << std::endl;
+ }
+
+ if( !options::ufssSymBreak() ){
+ bool rewritten = false;
+ //determine monotonicity of sorts
+ for( unsigned i=0; i<assertions.size(); i++ ){
+ Trace("sort-inference-debug") << "Process monotonicity for " << assertions[i] << std::endl;
+ std::map< Node, Node > var_bound;
+ processMonotonic( assertions[i], true, true, var_bound );
+ }
+
+ Trace("sort-inference") << "We have " << d_sub_sorts.size() << " sub-sorts : " << std::endl;
+ for( unsigned i=0; i<d_sub_sorts.size(); i++ ){
+ printSort( "sort-inference", d_sub_sorts[i] );
+ if( d_type_types.find( d_sub_sorts[i] )!=d_type_types.end() ){
+ Trace("sort-inference") << " is interpreted." << std::endl;
+ }else if( d_non_monotonic_sorts.find( d_sub_sorts[i] )==d_non_monotonic_sorts.end() ){
+ Trace("sort-inference") << " is monotonic." << std::endl;
+ }else{
+ Trace("sort-inference") << " is not monotonic." << std::endl;
+ }
+ }
+
+ //simplify all assertions by introducing new symbols wherever necessary
+ for( unsigned i=0; i<assertions.size(); i++ ){
+ Node prev = assertions[i];
+ std::map< Node, Node > var_bound;
+ Trace("sort-inference-debug") << "Rewrite " << assertions[i] << std::endl;
+ Node curr = simplify( assertions[i], var_bound );
+ Trace("sort-inference-debug") << "Done." << std::endl;
+ if( curr!=assertions[i] ){
+ curr = theory::Rewriter::rewrite( curr );
+ rewritten = true;
+ Trace("sort-inference-rewrite") << assertions << std::endl;
+ Trace("sort-inference-rewrite") << " --> " << curr << std::endl;
+ PROOF( ProofManager::currentPM()->addDependence(curr, assertions[i]); );
+ assertions[i] = curr;
+ }
+ }
+ //now, ensure constants are distinct
+ for( std::map< TypeNode, std::map< Node, Node > >::iterator it = d_const_map.begin(); it != d_const_map.end(); ++it ){
+ std::vector< Node > consts;
+ for( std::map< Node, Node >::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2 ){
+ consts.push_back( it2->second );
+ }
+ //TODO: add lemma enforcing introduced constants to be distinct
+ }
+
+ //enforce constraints based on monotonicity
+ for( std::map< TypeNode, std::vector< int > >::iterator it = d_type_sub_sorts.begin(); it != d_type_sub_sorts.end(); ++it ){
+ int nmonSort = -1;
+ for( unsigned i=0; i<it->second.size(); i++ ){
+ if( d_non_monotonic_sorts.find( it->second[i] )!=d_non_monotonic_sorts.end() ){
+ nmonSort = it->second[i];
+ break;
+ }
+ }
+ if( nmonSort!=-1 ){
+ std::vector< Node > injections;
+ TypeNode base_tn = getOrCreateTypeForId( nmonSort, it->first );
+ for( unsigned i=0; i<it->second.size(); i++ ){
+ if( it->second[i]!=nmonSort ){
+ TypeNode new_tn = getOrCreateTypeForId( it->second[i], it->first );
+ //make injection to nmonSort
+ Node a1 = mkInjection( new_tn, base_tn );
+ injections.push_back( a1 );
+ if( d_non_monotonic_sorts.find( it->second[i] )!=d_non_monotonic_sorts.end() ){
+ //also must make injection from nmonSort to this
+ Node a2 = mkInjection( base_tn, new_tn );
+ injections.push_back( a2 );
+ }
+ }
+ }
+ Trace("sort-inference-rewrite") << "Add the following injections for " << it->first << " to ensure consistency wrt non-monotonic sorts : " << std::endl;
+ for( unsigned j=0; j<injections.size(); j++ ){
+ Trace("sort-inference-rewrite") << " " << injections[j] << std::endl;
+ }
+ assertions.insert( assertions.end(), injections.begin(), injections.end() );
+ if( !injections.empty() ){
+ rewritten = true;
+ }
+ }
+ }
+ //no sub-sort information is stored
+ reset();
+ return rewritten;
+ }
+ /*
+ else if( !options::ufssSymBreak() ){
+ //just add the unit lemmas between constants
+ std::map< TypeNode, std::map< int, Node > > constants;
+ for( std::map< Node, int >::iterator it = d_op_return_types.begin(); it != d_op_return_types.end(); ++it ){
+ int rt = d_type_union_find.getRepresentative( it->second );
+ if( d_op_arg_types[ it->first ].empty() ){
+ TypeNode tn = it->first.getType();
+ if( constants[ tn ].find( rt )==constants[ tn ].end() ){
+ constants[ tn ][ rt ] = it->first;
+ }
+ }
+ }
+ //add unit lemmas for each constant
+ for( std::map< TypeNode, std::map< int, Node > >::iterator it = constants.begin(); it != constants.end(); ++it ){
+ Node first_const;
+ for( std::map< int, Node >::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2 ){
+ if( first_const.isNull() ){
+ first_const = it2->second;
+ }else{
+ Node eq = first_const.eqNode( it2->second );
+ //eq = Rewriter::rewrite( eq );
+ Trace("sort-inference-lemma") << "Sort inference lemma : " << eq << std::endl;
+ assertions.push_back( eq );
+ }
+ }
+ }
+ }
+ */
+ initialSortCount = sortCount;
+ return false;
+}
+
+void SortInference::setEqual( int t1, int t2 ){
+ if( t1!=t2 ){
+ int rt1 = d_type_union_find.getRepresentative( t1 );
+ int rt2 = d_type_union_find.getRepresentative( t2 );
+ if( rt1!=rt2 ){
+ Trace("sort-inference-debug") << "Set equal : ";
+ printSort( "sort-inference-debug", rt1 );
+ Trace("sort-inference-debug") << " ";
+ printSort( "sort-inference-debug", rt2 );
+ Trace("sort-inference-debug") << std::endl;
+ /*
+ d_type_eq_class[rt1].insert( d_type_eq_class[rt1].end(), d_type_eq_class[rt2].begin(), d_type_eq_class[rt2].end() );
+ d_type_eq_class[rt2].clear();
+ Trace("sort-inference-debug") << "EqClass : { ";
+ for( int i=0; i<(int)d_type_eq_class[rt1].size(); i++ ){
+ Trace("sort-inference-debug") << d_type_eq_class[rt1][i] << ", ";
+ }
+ Trace("sort-inference-debug") << "}" << std::endl;
+ */
+ if( rt2>rt1 ){
+ //swap
+ int swap = rt1;
+ rt1 = rt2;
+ rt2 = swap;
+ }
+ std::map< int, TypeNode >::iterator it1 = d_type_types.find( rt1 );
+ if( it1!=d_type_types.end() ){
+ if( d_type_types.find( rt2 )==d_type_types.end() ){
+ d_type_types[rt2] = it1->second;
+ d_type_types.erase( rt1 );
+ }else{
+ Trace("sort-inference-debug") << "...fail : associated with types " << d_type_types[rt1] << " and " << d_type_types[rt2] << std::endl;
+ return;
+ }
+ }
+ d_type_union_find.d_eqc[rt1] = rt2;
+ }
+ }
+}
+
+int SortInference::getIdForType( TypeNode tn ){
+ //register the return type
+ std::map< TypeNode, int >::iterator it = d_id_for_types.find( tn );
+ if( it==d_id_for_types.end() ){
+ int sc = sortCount;
+ d_type_types[ sortCount ] = tn;
+ d_id_for_types[ tn ] = sortCount;
+ sortCount++;
+ return sc;
+ }else{
+ return it->second;
+ }
+}
+
+int SortInference::process( Node n, std::map< Node, Node >& var_bound ){
+ //add to variable bindings
+ if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
+ if( d_var_types.find( n )!=d_var_types.end() ){
+ return getIdForType( n.getType() );
+ }else{
+ for( size_t i=0; i<n[0].getNumChildren(); i++ ){
+ //apply sort inference to quantified variables
+ d_var_types[n][ n[0][i] ] = sortCount;
+ sortCount++;
+
+ //type of the quantified variable must be the same
+ var_bound[ n[0][i] ] = n;
+ }
+ }
+ }
+
+ //process children
+ std::vector< Node > children;
+ std::vector< int > child_types;
+ for( size_t i=0; i<n.getNumChildren(); i++ ){
+ bool processChild = true;
+ if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
+ processChild = options::userPatternsQuant()==theory::quantifiers::USER_PAT_MODE_IGNORE ? i==1 : i>=1;
+ }
+ if( processChild ){
+ children.push_back( n[i] );
+ child_types.push_back( process( n[i], var_bound ) );
+ }
+ }
+
+ //remove from variable bindings
+ if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
+ //erase from variable bound
+ for( size_t i=0; i<n[0].getNumChildren(); i++ ){
+ var_bound.erase( n[0][i] );
+ }
+ }
+ Trace("sort-inference-debug") << "...Process " << n << std::endl;
+
+ int retType;
+ if( n.getKind()==kind::EQUAL ){
+ Trace("sort-inference-debug") << "For equality " << n << ", set equal types from : " << n[0].getType() << " " << n[1].getType() << std::endl;
+ //if original types are mixed (e.g. Int/Real), don't commit type equality in either direction
+ if( n[0].getType()!=n[1].getType() ){
+ //for now, assume the original types
+ for( unsigned i=0; i<2; i++ ){
+ int ct = getIdForType( n[i].getType() );
+ setEqual( child_types[i], ct );
+ }
+ }else{
+ //we only require that the left and right hand side must be equal
+ setEqual( child_types[0], child_types[1] );
+ }
+ //int eqType = getIdForType( n[0].getType() );
+ //setEqual( child_types[0], eqType );
+ //setEqual( child_types[1], eqType );
+ retType = getIdForType( n.getType() );
+ }else if( n.getKind()==kind::APPLY_UF ){
+ Node op = n.getOperator();
+ TypeNode tn_op = op.getType();
+ if( d_op_return_types.find( op )==d_op_return_types.end() ){
+ if( n.getType().isBoolean() ){
+ //use booleans
+ d_op_return_types[op] = getIdForType( n.getType() );
+ }else{
+ //assign arbitrary sort for return type
+ d_op_return_types[op] = sortCount;
+ sortCount++;
+ }
+ //d_type_eq_class[sortCount].push_back( op );
+ //assign arbitrary sort for argument types
+ for( size_t i=0; i<n.getNumChildren(); i++ ){
+ d_op_arg_types[op].push_back( sortCount );
+ sortCount++;
+ }
+ }
+ for( size_t i=0; i<n.getNumChildren(); i++ ){
+ //the argument of the operator must match the return type of the subterm
+ if( n[i].getType()!=tn_op[i] ){
+ //if type mismatch, assume original types
+ Trace("sort-inference-debug") << "Argument " << i << " of " << op << " " << n[i] << " has type " << n[i].getType();
+ Trace("sort-inference-debug") << ", while operator arg has type " << tn_op[i] << std::endl;
+ int ct1 = getIdForType( n[i].getType() );
+ setEqual( child_types[i], ct1 );
+ int ct2 = getIdForType( tn_op[i] );
+ setEqual( d_op_arg_types[op][i], ct2 );
+ }else{
+ setEqual( child_types[i], d_op_arg_types[op][i] );
+ }
+ }
+ //return type is the return type
+ retType = d_op_return_types[op];
+ }else{
+ std::map< Node, Node >::iterator it = var_bound.find( n );
+ if( it!=var_bound.end() ){
+ Trace("sort-inference-debug") << n << " is a bound variable." << std::endl;
+ //the return type was specified while binding
+ retType = d_var_types[it->second][n];
+ }else if( n.getKind() == kind::VARIABLE || n.getKind()==kind::SKOLEM ){
+ Trace("sort-inference-debug") << n << " is a variable." << std::endl;
+ if( d_op_return_types.find( n )==d_op_return_types.end() ){
+ //assign arbitrary sort
+ d_op_return_types[n] = sortCount;
+ sortCount++;
+ //d_type_eq_class[sortCount].push_back( n );
+ }
+ retType = d_op_return_types[n];
+ //}else if( n.isConst() ){
+ // Trace("sort-inference-debug") << n << " is a constant." << std::endl;
+ //can be any type we want
+ // retType = sortCount;
+ // sortCount++;
+ }else{
+ Trace("sort-inference-debug") << n << " is a interpreted symbol." << std::endl;
+ //it is an interpretted term
+ for( size_t i=0; i<children.size(); i++ ){
+ Trace("sort-inference-debug") << children[i] << " forced to have " << children[i].getType() << std::endl;
+ //must enforce the actual type of the operator on the children
+ int ct = getIdForType( children[i].getType() );
+ setEqual( child_types[i], ct );
+ }
+ //return type must be the actual return type
+ retType = getIdForType( n.getType() );
+ }
+ }
+ Trace("sort-inference-debug") << "...Type( " << n << " ) = ";
+ printSort("sort-inference-debug", retType );
+ Trace("sort-inference-debug") << std::endl;
+ return retType;
+}
+
+void SortInference::processMonotonic( Node n, bool pol, bool hasPol, std::map< Node, Node >& var_bound ) {
+ Trace("sort-inference-debug") << "...Process monotonic " << pol << " " << hasPol << " " << n << std::endl;
+ if( n.getKind()==kind::FORALL ){
+ for( unsigned i=0; i<n[0].getNumChildren(); i++ ){
+ var_bound[n[0][i]] = n;
+ }
+ processMonotonic( n[1], pol, hasPol, var_bound );
+ for( unsigned i=0; i<n[0].getNumChildren(); i++ ){
+ var_bound.erase( n[0][i] );
+ }
+ }else if( n.getKind()==kind::EQUAL ){
+ if( !hasPol || pol ){
+ for( unsigned i=0; i<2; i++ ){
+ if( var_bound.find( n[i] )!=var_bound.end() ){
+ int sid = getSortId( var_bound[n[i]], n[i] );
+ d_non_monotonic_sorts[sid] = true;
+ break;
+ }
+ }
+ }
+ }
+ for( unsigned i=0; i<n.getNumChildren(); i++ ){
+ bool npol = pol;
+ bool nhasPol = hasPol;
+ if( n.getKind()==kind::NOT || ( n.getKind()==kind::IMPLIES && i==0 ) ){
+ npol = !npol;
+ }
+ if( ( n.getKind()==kind::ITE && i==0 ) || n.getKind()==kind::XOR || n.getKind()==kind::IFF ){
+ nhasPol = false;
+ }
+ processMonotonic( n[i], npol, nhasPol, var_bound );
+ }
+}
+
+
+TypeNode SortInference::getOrCreateTypeForId( int t, TypeNode pref ){
+ int rt = d_type_union_find.getRepresentative( t );
+ if( d_type_types.find( rt )!=d_type_types.end() ){
+ return d_type_types[rt];
+ }else{
+ TypeNode retType;
+ //see if we can assign pref
+ if( !pref.isNull() && d_id_for_types.find( pref )==d_id_for_types.end() ){
+ retType = pref;
+ }else{
+ //must create new type
+ std::stringstream ss;
+ ss << "it_" << t << "_" << pref;
+ retType = NodeManager::currentNM()->mkSort( ss.str() );
+ }
+ Trace("sort-inference") << "-> Make type " << retType << " to correspond to ";
+ printSort("sort-inference", t );
+ Trace("sort-inference") << std::endl;
+ d_id_for_types[ retType ] = rt;
+ d_type_types[ rt ] = retType;
+ return retType;
+ }
+}
+
+TypeNode SortInference::getTypeForId( int t ){
+ int rt = d_type_union_find.getRepresentative( t );
+ if( d_type_types.find( rt )!=d_type_types.end() ){
+ return d_type_types[rt];
+ }else{
+ return TypeNode::null();
+ }
+}
+
+Node SortInference::getNewSymbol( Node old, TypeNode tn ){
+ if( tn==old.getType() ){
+ return old;
+ }else if( old.isConst() ){
+ //must make constant of type tn
+ if( d_const_map[tn].find( old )==d_const_map[tn].end() ){
+ std::stringstream ss;
+ ss << "ic_" << tn << "_" << old;
+ d_const_map[tn][ old ] = NodeManager::currentNM()->mkSkolem( ss.str(), tn, "constant created during sort inference" ); //use mkConst???
+ }
+ return d_const_map[tn][ old ];
+ }else if( old.getKind()==kind::BOUND_VARIABLE ){
+ std::stringstream ss;
+ ss << "b_" << old;
+ return NodeManager::currentNM()->mkBoundVar( ss.str(), tn );
+ }else{
+ std::stringstream ss;
+ ss << "i_" << old;
+ return NodeManager::currentNM()->mkSkolem( ss.str(), tn, "created during sort inference" );
+ }
+}
+
+Node SortInference::simplify( Node n, std::map< Node, Node >& var_bound ){
+ Trace("sort-inference-debug2") << "Simplify " << n << std::endl;
+ std::vector< Node > children;
+ if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
+ //recreate based on types of variables
+ std::vector< Node > new_children;
+ for( size_t i=0; i<n[0].getNumChildren(); i++ ){
+ TypeNode tn = getOrCreateTypeForId( d_var_types[n][ n[0][i] ], n[0][i].getType() );
+ Node v = getNewSymbol( n[0][i], tn );
+ Trace("sort-inference-debug2") << "Map variable " << n[0][i] << " to " << v << std::endl;
+ new_children.push_back( v );
+ var_bound[ n[0][i] ] = v;
+ }
+ children.push_back( NodeManager::currentNM()->mkNode( n[0].getKind(), new_children ) );
+ }
+
+ //process children
+ if( n.getMetaKind() == kind::metakind::PARAMETERIZED ){
+ children.push_back( n.getOperator() );
+ }
+ bool childChanged = false;
+ for( size_t i=0; i<n.getNumChildren(); i++ ){
+ bool processChild = true;
+ if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
+ processChild = options::userPatternsQuant()==theory::quantifiers::USER_PAT_MODE_IGNORE ? i==1 : i>=1;
+ }
+ if( processChild ){
+ Node nc = simplify( n[i], var_bound );
+ Trace("sort-inference-debug2") << "Simplify " << i << " " << n[i] << " returned " << nc << std::endl;
+ children.push_back( nc );
+ childChanged = childChanged || nc!=n[i];
+ }
+ }
+
+ //remove from variable bindings
+ if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
+ //erase from variable bound
+ for( size_t i=0; i<n[0].getNumChildren(); i++ ){
+ Trace("sort-inference-debug2") << "Remove bound for " << n[0][i] << std::endl;
+ var_bound.erase( n[0][i] );
+ }
+ return NodeManager::currentNM()->mkNode( n.getKind(), children );
+ }else if( n.getKind()==kind::EQUAL ){
+ TypeNode tn1 = children[0].getType();
+ TypeNode tn2 = children[1].getType();
+ if( !tn1.isSubtypeOf( tn2 ) && !tn2.isSubtypeOf( tn1 ) ){
+ if( children[0].isConst() ){
+ children[0] = getNewSymbol( children[0], children[1].getType() );
+ }else if( children[1].isConst() ){
+ children[1] = getNewSymbol( children[1], children[0].getType() );
+ }else{
+ Trace("sort-inference-warn") << "Sort inference created bad equality: " << children[0] << " = " << children[1] << std::endl;
+ Trace("sort-inference-warn") << " Types : " << children[0].getType() << " " << children[1].getType() << std::endl;
+ Assert( false );
+ }
+ }
+ return NodeManager::currentNM()->mkNode( kind::EQUAL, children );
+ }else if( n.getKind()==kind::APPLY_UF ){
+ Node op = n.getOperator();
+ if( d_symbol_map.find( op )==d_symbol_map.end() ){
+ //make the new operator if necessary
+ bool opChanged = false;
+ std::vector< TypeNode > argTypes;
+ for( size_t i=0; i<n.getNumChildren(); i++ ){
+ TypeNode tn = getOrCreateTypeForId( d_op_arg_types[op][i], n[i].getType() );
+ argTypes.push_back( tn );
+ if( tn!=n[i].getType() ){
+ opChanged = true;
+ }
+ }
+ TypeNode retType = getOrCreateTypeForId( d_op_return_types[op], n.getType() );
+ if( retType!=n.getType() ){
+ opChanged = true;
+ }
+ if( opChanged ){
+ std::stringstream ss;
+ ss << "io_" << op;
+ TypeNode typ = NodeManager::currentNM()->mkFunctionType( argTypes, retType );
+ d_symbol_map[op] = NodeManager::currentNM()->mkSkolem( ss.str(), typ, "op created during sort inference" );
+ Trace("setp-model") << "Function " << op << " is replaced with " << d_symbol_map[op] << std::endl;
+ d_model_replace_f[op] = d_symbol_map[op];
+ }else{
+ d_symbol_map[op] = op;
+ }
+ }
+ children[0] = d_symbol_map[op];
+ //make sure all children have been taken care of
+ for( size_t i=0; i<n.getNumChildren(); i++ ){
+ TypeNode tn = children[i+1].getType();
+ TypeNode tna = getTypeForId( d_op_arg_types[op][i] );
+ if( tn!=tna ){
+ if( n[i].isConst() ){
+ children[i+1] = getNewSymbol( n[i], tna );
+ }else{
+ Trace("sort-inference-warn") << "Sort inference created bad child: " << n << " " << n[i] << " " << tn << " " << tna << std::endl;
+ Assert( false );
+ }
+ }
+ }
+ return NodeManager::currentNM()->mkNode( kind::APPLY_UF, children );
+ }else{
+ std::map< Node, Node >::iterator it = var_bound.find( n );
+ if( it!=var_bound.end() ){
+ return it->second;
+ }else if( n.getKind() == kind::VARIABLE || n.getKind() == kind::SKOLEM ){
+ if( d_symbol_map.find( n )==d_symbol_map.end() ){
+ TypeNode tn = getOrCreateTypeForId( d_op_return_types[n], n.getType() );
+ d_symbol_map[n] = getNewSymbol( n, tn );
+ }
+ return d_symbol_map[n];
+ }else if( n.isConst() ){
+ //just return n, we will fix at higher scope
+ return n;
+ }else{
+ if( childChanged ){
+ return NodeManager::currentNM()->mkNode( n.getKind(), children );
+ }else{
+ return n;
+ }
+ }
+ }
+
+}
+
+Node SortInference::mkInjection( TypeNode tn1, TypeNode tn2 ) {
+ std::vector< TypeNode > tns;
+ tns.push_back( tn1 );
+ TypeNode typ = NodeManager::currentNM()->mkFunctionType( tns, tn2 );
+ Node f = NodeManager::currentNM()->mkSkolem( "inj", typ, "injection for monotonicity constraint" );
+ Trace("sort-inference") << "-> Make injection " << f << " from " << tn1 << " to " << tn2 << std::endl;
+ Node v1 = NodeManager::currentNM()->mkBoundVar( "?x", tn1 );
+ Node v2 = NodeManager::currentNM()->mkBoundVar( "?y", tn1 );
+ Node ret = NodeManager::currentNM()->mkNode( kind::FORALL,
+ NodeManager::currentNM()->mkNode( kind::BOUND_VAR_LIST, v1, v2 ),
+ NodeManager::currentNM()->mkNode( kind::OR,
+ NodeManager::currentNM()->mkNode( kind::APPLY_UF, f, v1 ).eqNode( NodeManager::currentNM()->mkNode( kind::APPLY_UF, f, v2 ) ).negate(),
+ v1.eqNode( v2 ) ) );
+ ret = theory::Rewriter::rewrite( ret );
+ return ret;
+}
+
+int SortInference::getSortId( Node n ) {
+ Node op = n.getKind()==kind::APPLY_UF ? n.getOperator() : n;
+ if( d_op_return_types.find( op )!=d_op_return_types.end() ){
+ return d_type_union_find.getRepresentative( d_op_return_types[op] );
+ }else{
+ return 0;
+ }
+}
+
+int SortInference::getSortId( Node f, Node v ) {
+ if( d_var_types.find( f )!=d_var_types.end() ){
+ return d_type_union_find.getRepresentative( d_var_types[f][v] );
+ }else{
+ return 0;
+ }
+}
+
+void SortInference::setSkolemVar( Node f, Node v, Node sk ){
+ Trace("sort-inference-temp") << "Set skolem var for " << f << ", variable " << v << std::endl;
+ if( isWellSortedFormula( f ) && d_var_types.find( f )==d_var_types.end() ){
+ //calculate the sort for variables if not done so already
+ std::map< Node, Node > var_bound;
+ process( f, var_bound );
+ }
+ d_op_return_types[sk] = getSortId( f, v );
+ Trace("sort-inference-temp") << "Set skolem sort id for " << sk << " to " << d_op_return_types[sk] << std::endl;
+}
+
+bool SortInference::isWellSortedFormula( Node n ) {
+ if( n.getType().isBoolean() && n.getKind()!=kind::APPLY_UF ){
+ for( unsigned i=0; i<n.getNumChildren(); i++ ){
+ if( !isWellSortedFormula( n[i] ) ){
+ return false;
+ }
+ }
+ return true;
+ }else{
+ return isWellSorted( n );
+ }
+}
+
+bool SortInference::isWellSorted( Node n ) {
+ if( getSortId( n )==0 ){
+ return false;
+ }else{
+ if( n.getKind()==kind::APPLY_UF ){
+ for( unsigned i=0; i<n.getNumChildren(); i++ ){
+ int s1 = getSortId( n[i] );
+ int s2 = d_type_union_find.getRepresentative( d_op_arg_types[ n.getOperator() ][i] );
+ if( s1!=s2 ){
+ return false;
+ }
+ if( !isWellSorted( n[i] ) ){
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
+
+void SortInference::getSortConstraints( Node n, UnionFind& uf ) {
+ if( n.getKind()==kind::APPLY_UF ){
+ for( unsigned i=0; i<n.getNumChildren(); i++ ){
+ getSortConstraints( n[i], uf );
+ uf.setEqual( getSortId( n[i] ), d_type_union_find.getRepresentative( d_op_arg_types[ n.getOperator() ][i] ) );
+ }
+ }
+}
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file sort_inference.h
+ ** \verbatim
+ ** Original author: Andrew Reynolds
+ ** 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 Pre-process step for performing sort inference
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__SORT_INFERENCE_H
+#define __CVC4__SORT_INFERENCE_H
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <map>
+#include "expr/node.h"
+#include "expr/type_node.h"
+
+namespace CVC4 {
+
+class SortInference {
+private:
+ //all subsorts
+ std::vector< int > d_sub_sorts;
+ std::map< int, bool > d_non_monotonic_sorts;
+ std::map< TypeNode, std::vector< int > > d_type_sub_sorts;
+ void recordSubsort( TypeNode tn, int s );
+public:
+ class UnionFind {
+ public:
+ UnionFind(){}
+ UnionFind( UnionFind& c ){
+ set( c );
+ }
+ std::map< int, int > d_eqc;
+ //pairs that must be disequal
+ std::vector< std::pair< int, int > > d_deq;
+ void print(const char * c);
+ void clear() { d_eqc.clear(); d_deq.clear(); }
+ void set( UnionFind& c );
+ int getRepresentative( int t );
+ void setEqual( int t1, int t2 );
+ void setDisequal( int t1, int t2 ){ d_deq.push_back( std::pair< int, int >( t1, t2 ) ); }
+ bool areEqual( int t1, int t2 ) { return getRepresentative( t1 )==getRepresentative( t2 ); }
+ bool isValid();
+ };
+private:
+ int sortCount;
+ int initialSortCount;
+ UnionFind d_type_union_find;
+ std::map< int, TypeNode > d_type_types;
+ std::map< TypeNode, int > d_id_for_types;
+ //for apply uf operators
+ std::map< Node, int > d_op_return_types;
+ std::map< Node, std::vector< int > > d_op_arg_types;
+ //for bound variables
+ std::map< Node, std::map< Node, int > > d_var_types;
+ //get representative
+ void setEqual( int t1, int t2 );
+ int getIdForType( TypeNode tn );
+ void printSort( const char* c, int t );
+ //process
+ int process( Node n, std::map< Node, Node >& var_bound );
+//for monotonicity inference
+private:
+ void processMonotonic( Node n, bool pol, bool hasPol, std::map< Node, Node >& var_bound );
+
+//for rewriting
+private:
+ //mapping from old symbols to new symbols
+ std::map< Node, Node > d_symbol_map;
+ //mapping from constants to new symbols
+ std::map< TypeNode, std::map< Node, Node > > d_const_map;
+ //helper functions for simplify
+ TypeNode getOrCreateTypeForId( int t, TypeNode pref );
+ TypeNode getTypeForId( int t );
+ Node getNewSymbol( Node old, TypeNode tn );
+ //simplify
+ Node simplify( Node n, std::map< Node, Node >& var_bound );
+ //make injection
+ Node mkInjection( TypeNode tn1, TypeNode tn2 );
+ //reset
+ void reset();
+public:
+ SortInference() : sortCount( 1 ){}
+ ~SortInference(){}
+
+ bool simplify( std::vector< Node >& assertions );
+ //get sort id for term n
+ int getSortId( Node n );
+ //get sort id for variable of quantified formula f
+ int getSortId( Node f, Node v );
+ //set that sk is the skolem variable of v for quantifier f
+ void setSkolemVar( Node f, Node v, Node sk );
+public:
+ //is well sorted
+ bool isWellSortedFormula( Node n );
+ bool isWellSorted( Node n );
+ //get constraints for being well-typed according to computed sub-types
+ void getSortConstraints( Node n, SortInference::UnionFind& uf );
+public:
+ //list of all functions and the uninterpreted symbols they were replaced with
+ std::map< Node, Node > d_model_replace_f;
+};
+
+}
+
+#endif
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module STRINGS "theory/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"
- 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"
- the alphabet contains only characters from the standard ASCII or the extended one
-
-option stringFMF strings-fmf --strings-fmf bool :default false :read-write
- the finite model finding used by the theory of strings
-
-option stringEager strings-eager --strings-eager bool :default false
- strings eager check
-
-option stringEIT strings-eit --strings-eit bool :default false
- the eager intersection used by the theory of strings
-
-option stringOpt1 strings-opt1 --strings-opt1 bool :default true
- internal option1 for strings: normal form
-
-option stringOpt2 strings-opt2 --strings-opt2 bool :default false
- internal option2 for strings: constant regexp splitting
-
-option stringIgnNegMembership strings-inm --strings-inm bool :default false
- internal for strings: ignore negative membership constraints (fragment checking is needed, left to users for now)
-
-#expert-option stringCharCardinality strings-alphabet-card --strings-alphabet-card=N int16_t :default 128 :read-write
-# the cardinality of the characters used by the theory of strings, default 128 (for standard ASCII) or 256 (for extended ASCII)
-
-option stringLazyPreproc strings-lazy-pp --strings-lazy-pp bool :default true
- perform string preprocessing lazily upon assertion
-option stringLazyPreproc2 strings-lazy-pp2 --strings-lazy-pp2 bool :default true
- perform string preprocessing lazily upon failure to reduce
-
-option stringLenGeqZ strings-len-geqz --strings-len-geqz bool :default false
- strings length greater than zero lemmas
-
-option stringLenNorm strings-len-norm --strings-len-norm bool :default true
- strings length normalization lemma
-option stringSplitEmp strings-sp-emp --strings-sp-emp bool :default true
- strings split on empty string
-option stringInferSym strings-infer-sym --strings-infer-sym bool :default true
- strings split on empty string
-option stringEagerLen strings-eager-len --strings-eager-len bool :default true
- strings eager length lemmas
-
-
-endmodule
**/
#include "theory/strings/regexp_operation.h"
+
#include "expr/kind.h"
-#include "theory/strings/options.h"
+#include "options/strings_options.h"
namespace CVC4 {
namespace theory {
** 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;
**/
#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 {
**
** 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;
**/
#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
**/
#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;
**/
#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 {
#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 {
** 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;
#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.
**
** \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;
#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"
#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 {
#pragma once
+#include "options/theory_options.h"
#include "theory/theory.h"
-#include "theory/options.h"
${theory_includes}
+++ /dev/null
-/********************* */
-/*! \file theoryof_mode.h
- ** \verbatim
- ** Original author: Dejan Jovanovic
- ** 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 Option selection for theoryOf() operation
- **
- ** Option selection for theoryOf() operation.
- **/
-
-#include "cvc4_public.h"
-
-#pragma once
-
-namespace CVC4 {
-namespace theory {
-
-/** How do we associate theories with the terms */
-enum TheoryOfMode {
- /** Equality, variables and constants are associated with the types */
- THEORY_OF_TYPE_BASED,
- /** Variables are uninterpreted, constants are with the type, equalities prefer parametric */
- THEORY_OF_TERM_BASED
-};/* enum TheoryOfMode */
-
-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();
-}
-
-}/* CVC4::theory namespace */
-}/* CVC4 namespace */
-
#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 {
#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}"
#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 {
+++ /dev/null
-#
-# Option specification file for CVC4
-# See src/options/base_options for a description of this file format
-#
-
-module UF "theory/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)
-
-option condenseFunctionValues condense-function-values --condense-function-values bool :default true
- condense models for functions rather than explicitly representing them
-
-option ufssRegions /--disable-uf-ss-regions bool :default true
- disable region-based method for discovering cliques and splits in uf strong solver
-option ufssEagerSplits --uf-ss-eager-split bool :default false
- add splits eagerly for uf strong solver
-option ufssTotality --uf-ss-totality bool :default false
- always use totality axioms for enforcing cardinality constraints
-option ufssTotalityLimited --uf-ss-totality-limited=N int :default -1
- apply totality axioms, but only up to cardinality N (-1 == do not apply totality axioms, default)
-option ufssTotalitySymBreak --uf-ss-totality-sym-break bool :default false
- apply symmetry breaking for totality axioms
-option ufssAbortCardinality --uf-ss-abort-card=N int :default -1
- tells the uf strong solver a cardinality to abort at (-1 == no limit, default)
-option ufssExplainedCliques --uf-ss-explained-cliques bool :default false
- use explained clique lemmas for uf strong solver
-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"
- 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
-
-option ufssSymBreak --uf-ss-sym-break bool :default false
- finite model finding symmetry breaking techniques
-option ufssFairness --uf-ss-fair bool :default true
- use fair strategy for finite model finding multiple sorts
-
-endmodule
+++ /dev/null
-/********************* */
-/*! \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 */
-
#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 {
**/
#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;
** \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
**/
#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"
#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 {
#include <utility>
#include "expr/node.h"
+#include "expr/statistics_registry.h"
#include "theory/substitutions.h"
-#include "util/statistics_registry.h"
namespace CVC4 {
#define __CVC4__THEORY__VALUATION_H
#include "expr/node.h"
-#include "theory/theoryof_mode.h"
+#include "options/theoryof_mode.h"
namespace CVC4 {
-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
# 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 += \
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
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 */
#pragma once
-#include "expr/type.h"
#include <iostream>
+#include "util/integer.h"
+
namespace CVC4 {
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;
+++ /dev/null
-/********************* */
-/*! \file array.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 Array types.
- **
- ** Array types.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__ARRAY_H
-#define __CVC4__ARRAY_H
-
-// we get ArrayType right now by #including type.h.
-// array.h is still useful for the auto-generated kinds #includes.
-#include "expr/type.h"
-
-#endif /* __CVC4__ARRAY_H */
+++ /dev/null
-%{
-#include "util/array.h"
-%}
-
-%include "util/array.h"
+++ /dev/null
-/********************* */
-/*! \file array_store_all.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 Representation of a constant array (an array in which the
- ** element is the same for all indices)
- **
- ** Representation of a constant array (an array in which the element is
- ** the same for all indices).
- **/
-
-#include "util/array_store_all.h"
-#include <iostream>
-
-using namespace std;
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) {
- return out << "__array_store_all__(" << asa.getType() << ", " << asa.getExpr() << ')';
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file array_store_all.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 Representation of a constant array (an array in which the
- ** element is the same for all indices)
- **
- ** Representation of a constant array (an array in which the element is
- ** the same for all indices).
- **/
-
-#include "cvc4_public.h"
-
-#pragma once
-
-namespace CVC4 {
- // messy; Expr needs ArrayStoreAll (because it's the payload of a
- // CONSTANT-kinded expression), and ArrayStoreAll needs Expr.
- class CVC4_PUBLIC ArrayStoreAll;
-}/* CVC4 namespace */
-
-#include "expr/expr.h"
-#include "expr/type.h"
-#include <iostream>
-
-namespace CVC4 {
-
-class CVC4_PUBLIC ArrayStoreAll {
- const ArrayType d_type;
- const Expr d_expr;
-
-public:
-
- ArrayStoreAll(ArrayType type, Expr expr) throw(IllegalArgumentException) :
- d_type(type),
- d_expr(expr) {
-
- // this check is stronger than the assertion check in the expr manager that ArrayTypes are actually array types
- // because this check is done in production builds too
- CheckArgument(type.isArray(), type, "array store-all constants can only be created for array types, not `%s'", type.toString().c_str());
-
- CheckArgument(expr.getType().isComparableTo(type.getConstituentType()), expr, "expr type `%s' does not match constituent type of array type `%s'", expr.getType().toString().c_str(), type.toString().c_str());
- CheckArgument(expr.isConst(), expr, "ArrayStoreAll requires a constant expression");
- }
-
- ~ArrayStoreAll() throw() {
- }
-
- ArrayType getType() const throw() {
- return d_type;
- }
- Expr getExpr() const throw() {
- return d_expr;
- }
-
- bool operator==(const ArrayStoreAll& asa) const throw() {
- return d_type == asa.d_type && d_expr == asa.d_expr;
- }
- bool operator!=(const ArrayStoreAll& asa) const throw() {
- return !(*this == asa);
- }
-
- bool operator<(const ArrayStoreAll& asa) const throw() {
- return d_type < asa.d_type ||
- (d_type == asa.d_type && d_expr < asa.d_expr);
- }
- bool operator<=(const ArrayStoreAll& asa) const throw() {
- return d_type < asa.d_type ||
- (d_type == asa.d_type && d_expr <= asa.d_expr);
- }
- bool operator>(const ArrayStoreAll& asa) const throw() {
- return !(*this <= asa);
- }
- bool operator>=(const ArrayStoreAll& asa) const throw() {
- return !(*this < asa);
- }
-
-};/* class ArrayStoreAll */
-
-std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) CVC4_PUBLIC;
-
-/**
- * Hash function for the ArrayStoreAll constants.
- */
-struct CVC4_PUBLIC ArrayStoreAllHashFunction {
- inline size_t operator()(const ArrayStoreAll& asa) const {
- return TypeHashFunction()(asa.getType()) * ExprHashFunction()(asa.getExpr());
- }
-};/* struct ArrayStoreAllHashFunction */
-
-}/* CVC4 namespace */
+++ /dev/null
-%{
-#include "util/array_store_all.h"
-%}
-
-%rename(equals) CVC4::ArrayStoreAll::operator==(const ArrayStoreAll&) const;
-%ignore CVC4::ArrayStoreAll::operator!=(const ArrayStoreAll&) const;
-%rename(less) CVC4::ArrayStoreAll::operator<(const ArrayStoreAll&) const;
-%rename(lessEqual) CVC4::ArrayStoreAll::operator<=(const ArrayStoreAll&) const;
-%rename(greater) CVC4::ArrayStoreAll::operator>(const ArrayStoreAll&) const;
-%rename(greaterEqual) CVC4::ArrayStoreAll::operator>=(const ArrayStoreAll&) const;
-
-%rename(apply) CVC4::ArrayStoreAllHashFunction::operator()(const ArrayStoreAll&) const;
-
-%ignore CVC4::operator<<(std::ostream&, const ArrayStoreAll&);
-
-%include "expr/type.i"
-%include "util/array_store_all.h"
+++ /dev/null
-/********************* */
-/*! \file ascription_type.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 A class representing a type ascription
- **
- ** A class representing a parameter for the type ascription operator.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__ASCRIPTION_TYPE_H
-#define __CVC4__ASCRIPTION_TYPE_H
-
-#include "expr/type.h"
-
-namespace CVC4 {
-
-/**
- * A class used to parameterize a type ascription. For example,
- * "nil :: list<nat>" is an expression of kind APPLY_TYPE_ASCRIPTION.
- * The parameter is an ASCRIPTION_TYPE-kinded expression with an
- * AscriptionType payload. (Essentially, all of this is a way to
- * coerce a Type into the expression tree.)
- */
-class CVC4_PUBLIC AscriptionType {
- Type d_type;
-public:
- AscriptionType(Type t) throw() : d_type(t) {}
- Type getType() const throw() { return d_type; }
- bool operator==(const AscriptionType& other) const throw() {
- return d_type == other.d_type;
- }
- bool operator!=(const AscriptionType& other) const throw() {
- return d_type != other.d_type;
- }
-};/* class AscriptionType */
-
-/**
- * A hash function for type ascription operators.
- */
-struct CVC4_PUBLIC AscriptionTypeHashFunction {
- inline size_t operator()(const AscriptionType& at) const {
- return TypeHashFunction()(at.getType());
- }
-};/* struct AscriptionTypeHashFunction */
-
-/** An output routine for AscriptionTypes */
-inline std::ostream& operator<<(std::ostream& out, AscriptionType at) {
- out << at.getType();
- return out;
-}
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__ASCRIPTION_TYPE_H */
+++ /dev/null
-%{
-#include "util/ascription_type.h"
-%}
-
-%rename(equals) CVC4::AscriptionType::operator==(const AscriptionType&) const;
-%ignore CVC4::AscriptionType::operator!=(const AscriptionType&) const;
-
-%rename(apply) CVC4::AscriptionTypeHashFunction::operator()(const AscriptionType&) const;
-
-%ignore CVC4::operator<<(std::ostream&, AscriptionType);
-
-%include "util/ascription_type.h"
+++ /dev/null
-/********************* */
-/*! \file backtrackable.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 Contains a backtrackable list
- **
- ** Contains a backtrackable list.
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__UTIL__BACKTRACKABLE_H
-#define __CVC4__UTIL__BACKTRACKABLE_H
-
-#include <cstdlib>
-#include <vector>
-#include "context/cdo.h"
-
-namespace CVC4 {
-
-template <class T> class List;
-template <class T> class List_iterator;
-template <class T> class Backtracker;
-
-template <class T>
-class ListNode {
-private:
- T data;
- ListNode<T>* next;
-
- bool empty;
- ListNode(const T& t, ListNode<T>* n, bool e = false) : data(t), next(n), empty(e) {}
- ~ListNode() {
- // maybe set to NULL
- delete next;
- }
-
- friend class List<T>;
- friend class List_iterator<T>;
-};/* class ListNode<T> */
-
-template <class T>
-class List_iterator : public std::iterator <std::forward_iterator_tag, T> {
- friend class List<T>;
-
-public:
- const T& operator*();
- List_iterator<T>& operator++();
- List_iterator<T> operator++(int);
- bool operator!=(const List_iterator<T> & other) const;
-
-private:
- const ListNode<T>* pointee;
- List_iterator(const ListNode<T>* p) : pointee(p) {}
-
-};/* class List_iterator<T> */
-
-template <class T>
-const T& List_iterator<T>::operator*() {
- return pointee->data;
-}
-
-template <class T>
-List_iterator<T>& List_iterator<T>::operator++() {
- Assert(pointee != NULL);
- pointee = pointee->next;
- while(pointee != NULL && pointee->empty ) {
- pointee = pointee->next;
- }
- return *this;
-}
-
-template <class T>
-List_iterator<T> List_iterator<T>::operator++(int) {
- List_iterator<T> it = *this;
- ++*this;
- return it;
-}
-
-template <class T>
-bool List_iterator<T>::operator!=(const List_iterator<T>& other) const {
- return (this->pointee != other.pointee);
-}
-
-// !! for the backtracking to work the lists must be allocated on the heap
-// therefore the hashmap from TNode to List<TNode> should store pointers!
-template <class T>
-class List {
- ListNode<T>* head;
- ListNode<T>* tail;
- ListNode<T>* ptr_to_head;
- bool uninitialized;
- Backtracker<T>* bck;
- List (const List&) {}
-public:
- List(Backtracker<T>* b) : ptr_to_head(NULL), uninitialized(true), bck(b) {
- head = tail = (ListNode<T>*)calloc(1,sizeof(ListNode<T>));
- head->next = NULL;
- head->empty = true;
- }
- ~List() {delete head;}
- bool empty() {
- bck->checkConsistency();
- return head == NULL;
- }
- void append(const T& d);
- //typedef List_iterator<T> iterator;
- typedef List_iterator<T> const_iterator;
-
- const_iterator begin() {
- bck->checkConsistency();
- if(head->empty) {
- ListNode<T>* temp = head;
- // if the head is empty return the first non-empty element or NULL
- while(temp != NULL && temp->empty ) {
- temp = temp->next;
- }
- return List_iterator<T>(temp);
- }
- return List_iterator<T>(head);
- }
-
- const_iterator end() {
- bck->checkConsistency();
- return List_iterator<T>(NULL);
- }
- void concat(List<T>* other);
- void unconcat(List<T>* other);
-};/* class List */
-
-template <class T>
-void List<T>::append (const T& d) {
- bck->checkConsistency();
-
- if(uninitialized) {
- new(head)ListNode<T> (d, head->next);
- //head->data = d;
- head->empty = false;
- //Assert(tail == head); FIXME: do I need this because this list might be empty but append to another one
- uninitialized = false;
-
- } else {
- ListNode<T>* new_node = new ListNode<T>(d, head);
- head = new_node;
- }
-
- if(ptr_to_head != NULL) {
- ptr_to_head->next = head;
- }
-}
-
-template <class T>
-void List<T>::concat (List<T>* other) {
- bck->checkConsistency();
- bck->notifyConcat(this, other);
- Assert(tail->next==NULL);
- tail->next = other->head;
- Assert(other->ptr_to_head == NULL);
- other->ptr_to_head = tail;
- tail = other->tail;
-}
-
-template <class T>
-void List<T>::unconcat(List<T>* other) {
- // we do not need to check consistency since this is only called by the
- // Backtracker when we are inconsistent
- Assert(other->ptr_to_head != NULL);
- other->ptr_to_head->next = NULL;
- tail = other->ptr_to_head;
- other->ptr_to_head = NULL;
-}
-
-/* Backtrackable Table */
-
-template <class T>
-class Backtracker {
- friend class List<T>;
- std::vector<std::pair<List<T>*,List<T>*> > undo_stack;
-
- int curr_level;
- context::CDO<int> pop_level;
-
- void checkConsistency();
- void notifyConcat(List<T>* a, List<T>* b);
-public:
- Backtracker(context::Context* c) : undo_stack(), curr_level(0), pop_level(c, 0) {}
- ~Backtracker() {}
-
-};/* class Backtrackable */
-
-template <class T> void Backtracker<T>::notifyConcat(List<T>* a, List<T>* b) {
- curr_level++;
- pop_level.set(pop_level.get()+1);
- undo_stack.push_back( std::make_pair(a, b));
-}
-
-template <class T> void Backtracker<T>::checkConsistency() {
- if( curr_level == pop_level || pop_level == -1) {
- return;
- }
- Assert(curr_level > pop_level);
-
- while (curr_level > pop_level) {
- curr_level--;
- List<T>* l1 = undo_stack[curr_level].first;
- List<T>* l2 = undo_stack[curr_level].second;
- l1->unconcat(l2);
- undo_stack.pop_back();
- }
- Assert(curr_level == pop_level);
-}
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__UTIL__BACKTRACKABLE_H */
#include <limits>
#include <functional>
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
#define __CVC4__BITVECTOR_H
#include <iostream>
-#include "util/exception.h"
+
+#include "base/exception.h"
#include "util/integer.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file boolean_simplification.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 routines for Boolean simplification
- **
- ** Simple, commonly-used routines for Boolean simplification.
- **/
-
-#include "util/boolean_simplification.h"
-
-namespace CVC4 {
-
-bool
-BooleanSimplification::push_back_associative_commute_recursive
- (Node n, std::vector<Node>& buffer, Kind k, Kind notK, bool negateNode)
- throw(AssertionException) {
- Node::iterator i = n.begin(), end = n.end();
- for(; i != end; ++i){
- Node child = *i;
- if(child.getKind() == k){
- if(! push_back_associative_commute_recursive(child, buffer, k, notK, negateNode)) {
- return false;
- }
- }else if(child.getKind() == kind::NOT && child[0].getKind() == notK){
- if(! push_back_associative_commute_recursive(child[0], buffer, notK, k, !negateNode)) {
- return false;
- }
- }else{
- if(negateNode){
- if(child.isConst()) {
- if((k == kind::AND && child.getConst<bool>()) ||
- (k == kind::OR && !child.getConst<bool>())) {
- buffer.clear();
- buffer.push_back(negate(child));
- return false;
- }
- } else {
- buffer.push_back(negate(child));
- }
- }else{
- if(child.isConst()) {
- if((k == kind::OR && child.getConst<bool>()) ||
- (k == kind::AND && !child.getConst<bool>())) {
- buffer.clear();
- buffer.push_back(child);
- return false;
- }
- } else {
- buffer.push_back(child);
- }
- }
- }
- }
- return true;
-}/* BooleanSimplification::push_back_associative_commute_recursive() */
-
-}/* CVC4 namespace */
-
+++ /dev/null
-/********************* */
-/*! \file boolean_simplification.h
- ** \verbatim
- ** Original author: Tim King
- ** 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 Simple routines for Boolean simplification
- **
- ** Simple, commonly-used routines for Boolean simplification.
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__BOOLEAN_SIMPLIFICATION_H
-#define __CVC4__BOOLEAN_SIMPLIFICATION_H
-
-#include <vector>
-#include <algorithm>
-
-#include "expr/expr_manager_scope.h"
-#include "expr/node.h"
-#include "util/cvc4_assert.h"
-
-namespace CVC4 {
-
-/**
- * A class to contain a number of useful functions for simple
- * simplification of nodes. One never uses it as an object (and
- * it cannot be constructed). It is used as a namespace.
- */
-class BooleanSimplification {
- // cannot construct one of these
- BooleanSimplification() CVC4_UNUSED;
- BooleanSimplification(const BooleanSimplification&) CVC4_UNUSED;
-
- static bool push_back_associative_commute_recursive
- (Node n, std::vector<Node>& buffer, Kind k, Kind notK, bool negateNode)
- throw(AssertionException) CVC4_WARN_UNUSED_RESULT;
-
-public:
-
- /**
- * The threshold for removing duplicates. (See removeDuplicates().)
- */
- static const uint32_t DUPLICATE_REMOVAL_THRESHOLD = 10;
-
- /**
- * Remove duplicate nodes from a vector, modifying it in-place.
- * If the vector has size >= DUPLICATE_REMOVAL_THRESHOLD, this
- * function is a no-op.
- */
- static void removeDuplicates(std::vector<Node>& buffer)
- throw(AssertionException) {
- if(buffer.size() < DUPLICATE_REMOVAL_THRESHOLD) {
- std::sort(buffer.begin(), buffer.end());
- std::vector<Node>::iterator new_end =
- std::unique(buffer.begin(), buffer.end());
- buffer.erase(new_end, buffer.end());
- }
- }
-
- /**
- * Takes a node with kind AND, collapses all AND and (NOT OR)-kinded
- * children of it (as far as possible---see
- * push_back_associative_commute()), removes duplicates, and returns
- * the resulting Node.
- */
- static Node simplifyConflict(Node andNode) throw(AssertionException) {
- AssertArgument(!andNode.isNull(), andNode);
- AssertArgument(andNode.getKind() == kind::AND, andNode);
-
- std::vector<Node> buffer;
- push_back_associative_commute(andNode, buffer, kind::AND, kind::OR);
-
- removeDuplicates(buffer);
-
- if(buffer.size() == 1) {
- return buffer[0];
- }
-
- NodeBuilder<> nb(kind::AND);
- nb.append(buffer);
- return nb;
- }
-
- /**
- * Takes a node with kind OR, collapses all OR and (NOT AND)-kinded
- * children of it (as far as possible---see
- * push_back_associative_commute()), removes duplicates, and returns
- * the resulting Node.
- */
- static Node simplifyClause(Node orNode) throw(AssertionException) {
- AssertArgument(!orNode.isNull(), orNode);
- AssertArgument(orNode.getKind() == kind::OR, orNode);
-
- std::vector<Node> buffer;
- push_back_associative_commute(orNode, buffer, kind::OR, kind::AND);
-
- removeDuplicates(buffer);
-
- Assert(buffer.size() > 0);
- if(buffer.size() == 1) {
- return buffer[0];
- }
-
- NodeBuilder<> nb(kind::OR);
- nb.append(buffer);
- return nb;
- }
-
- /**
- * Takes a node with kind IMPLIES, converts it to an OR, then
- * simplifies the result with simplifyClause().
- *
- * The input doesn't actually have to be Horn, it seems, but that's
- * the common case(?), hence the name.
- */
- static Node simplifyHornClause(Node implication) throw(AssertionException) {
- AssertArgument(implication.getKind() == kind::IMPLIES, implication);
-
- TNode left = implication[0];
- TNode right = implication[1];
-
- Node notLeft = negate(left);
- Node clause = NodeBuilder<2>(kind::OR) << notLeft << right;
-
- return simplifyClause(clause);
- }
-
- /**
- * Aids in reforming a node. Takes a node of (N-ary) kind k and
- * copies its children into an output vector, collapsing its k-kinded
- * children into it. Also collapses negations of notK. For example:
- *
- * push_back_associative_commute( [OR [OR a b] [OR b c d] [NOT [AND e f]]],
- * buffer, kind::OR, kind::AND )
- * yields a "buffer" vector of [a b b c d e f]
- *
- * @param n the node to operate upon
- * @param buffer the output vector (must be empty on entry)
- * @param k the kind to collapse (should equal the kind of node n)
- * @param notK the "negation" of kind k (e.g. OR's negation is AND),
- * or kind::UNDEFINED_KIND if none.
- * @param negateChildren true if the children of the resulting node
- * (that is, the elements in buffer) should all be negated; you want
- * this if e.g. you're simplifying the (OR...) in (NOT (OR...)),
- * intending to make the result an AND.
- */
- static inline void
- push_back_associative_commute(Node n, std::vector<Node>& buffer,
- Kind k, Kind notK, bool negateChildren = false)
- throw(AssertionException) {
- AssertArgument(buffer.empty(), buffer);
- AssertArgument(!n.isNull(), n);
- AssertArgument(k != kind::UNDEFINED_KIND && k != kind::NULL_EXPR, k);
- AssertArgument(notK != kind::NULL_EXPR, notK);
- AssertArgument(n.getKind() == k, n,
- "expected node to have kind %s", kindToString(k).c_str());
-
- bool b CVC4_UNUSED =
- push_back_associative_commute_recursive(n, buffer, k, notK, false);
-
- if(buffer.size() == 0) {
- // all the TRUEs for an AND (resp FALSEs for an OR) were simplified away
- buffer.push_back(NodeManager::currentNM()->mkConst(k == kind::AND ? true : false));
- }
- }/* push_back_associative_commute() */
-
- /**
- * Negates a node, doing all the double-negation elimination
- * that's possible.
- *
- * @param n the node to negate (cannot be the null node)
- */
- static Node negate(TNode n) throw(AssertionException) {
- AssertArgument(!n.isNull(), n);
-
- bool polarity = true;
- TNode base = n;
- while(base.getKind() == kind::NOT){
- base = base[0];
- polarity = !polarity;
- }
- if(n.isConst()) {
- return NodeManager::currentNM()->mkConst(!n.getConst<bool>());
- }
- if(polarity){
- return base.notNode();
- }else{
- return base;
- }
- }
-
- /**
- * Negates an Expr, doing all the double-negation elimination that's
- * possible.
- *
- * @param e the Expr to negate (cannot be the null Expr)
- */
- static Expr negate(Expr e) throw(AssertionException) {
- ExprManagerScope ems(e);
- return negate(Node::fromExpr(e)).toExpr();
- }
-
- /**
- * Simplify an OR, AND, or IMPLIES. This function is the identity
- * for all other kinds.
- */
- inline static Node simplify(TNode n) throw(AssertionException) {
- switch(n.getKind()) {
- case kind::AND:
- return simplifyConflict(n);
-
- case kind::OR:
- return simplifyClause(n);
-
- case kind::IMPLIES:
- return simplifyHornClause(n);
-
- default:
- return n;
- }
- }
-
-};/* class BooleanSimplification */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__BOOLEAN_SIMPLIFICATION_H */
#include <iostream>
#include <utility>
+#include "base/exception.h"
#include "util/integer.h"
-#include "util/exception.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file chain.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_public.h"
-
-#ifndef __CVC4__CHAIN_H
-#define __CVC4__CHAIN_H
-
-#include "expr/kind.h"
-#include <iostream>
-
-namespace CVC4 {
-
-/** A class to represent a chained, built-in operator. */
-class CVC4_PUBLIC Chain {
- Kind d_kind;
-public:
- explicit Chain(Kind k) : d_kind(k) { }
- bool operator==(const Chain& ch) const { return d_kind == ch.d_kind; }
- bool operator!=(const Chain& ch) const { return d_kind != ch.d_kind; }
- Kind getOperator() const { return d_kind; }
-};/* class Chain */
-
-inline std::ostream& operator<<(std::ostream& out, const Chain& ch) CVC4_PUBLIC;
-inline std::ostream& operator<<(std::ostream& out, const Chain& ch) {
- return out << ch.getOperator();
-}
-
-struct CVC4_PUBLIC ChainHashFunction {
- size_t operator()(const Chain& ch) const {
- return kind::KindHashFunction()(ch.getOperator());
- }
-};/* struct ChainHashFunction */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__CHAIN_H */
+++ /dev/null
-%{
-#include "util/chain.h"
-%}
-
-%rename(equals) CVC4::Chain::operator==(const Chain&) const;
-%ignore CVC4::Chain::operator!=(const Chain&) const;
-
-%ignore CVC4::operator<<(std::ostream&, const Chain&);
-
-%rename(apply) CVC4::ChainHashFunction::operator()(const CVC4::Chain&) const;
-
-%include "util/chain.h"
/* 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
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);
** 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"
* Represents the (static) configuration of CVC4.
*/
class CVC4_PUBLIC Configuration {
-
+private:
/** Private default ctor: Disallow construction of this class */
Configuration();
static bool isAssertionBuild();
- static bool isProofBuild();
-
+ static bool isProofBuild();
+
static bool isCoverageBuild();
static bool isProfilingBuild();
+++ /dev/null
-/********************* */
-/*! \file cvc4_assert.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 Assertion utility classes, functions, and exceptions.
- **
- ** Assertion utility classes, functions, and exceptions. Implementation.
- **/
-
-#include <new>
-#include <cstdarg>
-#include <cstdio>
-
-#include "util/cvc4_assert.h"
-
-using namespace std;
-
-namespace CVC4 {
-
-#ifdef CVC4_DEBUG
-CVC4_THREADLOCAL(const char*) s_debugLastException = NULL;
-#endif /* CVC4_DEBUG */
-
-void AssertionException::construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line, const char* fmt,
- va_list args) {
- // try building the exception msg with a smallish buffer first,
- // then with a larger one if sprintf tells us to.
- int n = 512;
- char* buf;
-
- for(;;) {
- buf = new char[n];
-
- int size;
- if(extra == NULL) {
- size = snprintf(buf, n, "%s\n%s\n%s:%d\n",
- header, function, file, line);
- } else {
- size = snprintf(buf, n, "%s\n%s\n%s:%d:\n\n %s\n",
- header, function, file, line, extra);
- }
-
- if(size < n) {
- va_list args_copy;
- va_copy(args_copy, args);
- size += vsnprintf(buf + size, n - size, fmt, args_copy);
- va_end(args_copy);
-
- if(size < n) {
- break;
- }
- }
-
- if(size >= n) {
- // try again with a buffer that's large enough
- n = size + 1;
- delete [] buf;
- }
- }
-
- setMessage(string(buf));
-
-#ifdef CVC4_DEBUG
- if(s_debugLastException == NULL) {
- // we leak buf[] but only in debug mode with assertions failing
- s_debugLastException = buf;
- }
-#else /* CVC4_DEBUG */
- delete [] buf;
-#endif /* CVC4_DEBUG */
-}
-
-void AssertionException::construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line) {
- // try building the exception msg with a smallish buffer first,
- // then with a larger one if sprintf tells us to.
- int n = 256;
- char* buf;
-
- for(;;) {
- buf = new char[n];
-
- int size;
- if(extra == NULL) {
- size = snprintf(buf, n, "%s.\n%s\n%s:%d\n",
- header, function, file, line);
- } else {
- size = snprintf(buf, n, "%s.\n%s\n%s:%d:\n\n %s\n",
- header, function, file, line, extra);
- }
-
- if(size < n) {
- break;
- } else {
- // try again with a buffer that's large enough
- n = size + 1;
- delete [] buf;
- }
- }
-
- setMessage(string(buf));
-
-#ifdef CVC4_DEBUG
- // we leak buf[] but only in debug mode with assertions failing
- if(s_debugLastException == NULL) {
- s_debugLastException = buf;
- }
-#else /* CVC4_DEBUG */
- delete [] buf;
-#endif /* CVC4_DEBUG */
-}
-
-#ifdef CVC4_DEBUG
-
-/**
- * Special assertion failure handling in debug mode; in non-debug
- * builds, the exception is thrown from the macro. We factor out this
- * additional logic so as not to bloat the code at every Assert()
- * expansion.
- *
- * Note this name is prefixed with "debug" because it is included in
- * debug builds only; in debug builds, it handles all assertion
- * failures (even those that exist in non-debug builds).
- */
-void debugAssertionFailed(const AssertionException& thisException,
- const char* propagatingException) {
- static CVC4_THREADLOCAL(bool) alreadyFired = false;
-
- if(__builtin_expect( ( !std::uncaught_exception() ), true ) || alreadyFired) {
- throw thisException;
- }
-
- alreadyFired = true;
-
- // propagatingException is the propagating exception, but can be
- // NULL if the propagating exception is not a CVC4::Exception.
- Warning() << "===========================================" << std::endl
- << "An assertion failed during stack unwinding:" << std::endl;
- if(propagatingException != NULL) {
- Warning() << "The propagating exception is:" << std::endl
- << propagatingException << std::endl
- << "===========================================" << std::endl;
- Warning() << "The newly-thrown exception is:" << std::endl;
- } else {
- Warning() << "The propagating exception is unknown." << std::endl;
- }
- Warning() << thisException << std::endl
- << "===========================================" << std::endl;
-
- terminate();
-}
-
-#endif /* CVC4_DEBUG */
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file cvc4_assert.h
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: none
- ** Minor contributors (to current version): ACSYS
- ** 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 Assertion utility classes, functions, exceptions, and macros.
- **
- ** Assertion utility classes, functions, exceptions, and macros.
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__ASSERT_H
-#define __CVC4__ASSERT_H
-
-#include <string>
-#include <sstream>
-#include <cstdio>
-#include <cstdlib>
-#include <cstdarg>
-
-#include "util/exception.h"
-#include "util/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"
-
-namespace CVC4 {
-
-class AssertionException : public Exception {
-protected:
- void construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line, const char* fmt, ...) {
- va_list args;
- va_start(args, fmt);
- construct(header, extra, function, file, line, fmt, args);
- va_end(args);
- }
-
- void construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line, const char* fmt, va_list args);
-
- void construct(const char* header, const char* extra,
- const char* function, const char* file,
- unsigned line);
-
- AssertionException() : Exception() {}
-
-public:
- AssertionException(const char* extra, const char* function,
- const char* file, unsigned line,
- const char* fmt, ...) :
- Exception() {
- va_list args;
- va_start(args, fmt);
- construct("Assertion failure", extra, function, file, line, fmt, args);
- va_end(args);
- }
-
- AssertionException(const char* extra, const char* function,
- const char* file, unsigned line) :
- Exception() {
- construct("Assertion failure", extra, function, file, line);
- }
-};/* class AssertionException */
-
-class UnreachableCodeException : public AssertionException {
-protected:
- UnreachableCodeException() : AssertionException() {}
-
-public:
- UnreachableCodeException(const char* function, const char* file,
- unsigned line, const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Unreachable code reached",
- NULL, function, file, line, fmt, args);
- va_end(args);
- }
-
- UnreachableCodeException(const char* function, const char* file,
- unsigned line) :
- AssertionException() {
- construct("Unreachable code reached", NULL, function, file, line);
- }
-};/* class UnreachableCodeException */
-
-class UnhandledCaseException : public UnreachableCodeException {
-protected:
- UnhandledCaseException() : UnreachableCodeException() {}
-
-public:
- UnhandledCaseException(const char* function, const char* file,
- unsigned line, const char* fmt, ...) :
- UnreachableCodeException() {
- va_list args;
- va_start(args, fmt);
- construct("Unhandled case encountered",
- NULL, function, file, line, fmt, args);
- va_end(args);
- }
-
- template <class T>
- UnhandledCaseException(const char* function, const char* file,
- unsigned line, T theCase) :
- UnreachableCodeException() {
- std::stringstream sb;
- sb << theCase;
- construct("Unhandled case encountered",
- NULL, function, file, line, "The case was: %s", sb.str().c_str());
- }
-
- UnhandledCaseException(const char* function, const char* file,
- unsigned line) :
- UnreachableCodeException() {
- construct("Unhandled case encountered", NULL, function, file, line);
- }
-};/* class UnhandledCaseException */
-
-class UnimplementedOperationException : public AssertionException {
-protected:
- UnimplementedOperationException() : AssertionException() {}
-
-public:
- UnimplementedOperationException(const char* function, const char* file,
- unsigned line, const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Unimplemented code encountered",
- NULL, function, file, line, fmt, args);
- va_end(args);
- }
-
- UnimplementedOperationException(const char* function, const char* file,
- unsigned line) :
- AssertionException() {
- construct("Unimplemented code encountered", NULL, function, file, line);
- }
-};/* class UnimplementedOperationException */
-
-class AssertArgumentException : public AssertionException {
-protected:
- AssertArgumentException() : AssertionException() {}
-
-public:
- AssertArgumentException(const char* argDesc, const char* function,
- const char* file, unsigned line,
- const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument" ).c_str(),
- function, file, line, fmt, args);
- va_end(args);
- }
-
- AssertArgumentException(const char* argDesc, const char* function,
- const char* file, unsigned line) :
- AssertionException() {
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument" ).c_str(),
- function, file, line);
- }
-
- AssertArgumentException(const char* condStr, const char* argDesc,
- const char* function, const char* file,
- unsigned line, const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument; expected " +
- condStr + " to hold" ).c_str(),
- function, file, line, fmt, args);
- va_end(args);
- }
-
- AssertArgumentException(const char* condStr, const char* argDesc,
- const char* function, const char* file,
- unsigned line) :
- AssertionException() {
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument; expected " +
- condStr + " to hold" ).c_str(),
- function, file, line);
- }
-};/* class AssertArgumentException */
-
-class InternalErrorException : public AssertionException {
-protected:
- InternalErrorException() : AssertionException() {}
-
-public:
- InternalErrorException(const char* function, const char* file, unsigned line) :
- AssertionException() {
- construct("Internal error detected", "",
- function, file, line);
- }
-
- InternalErrorException(const char* function, const char* file, unsigned line,
- const char* fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Internal error detected", "",
- function, file, line, fmt, args);
- va_end(args);
- }
-
- InternalErrorException(const char* function, const char* file, unsigned line,
- std::string fmt, ...) :
- AssertionException() {
- va_list args;
- va_start(args, fmt);
- construct("Internal error detected", "",
- function, file, line, fmt.c_str(), args);
- va_end(args);
- }
-
-};/* class InternalErrorException */
-
-#ifdef CVC4_DEBUG
-
-extern CVC4_THREADLOCAL(const char*) s_debugLastException;
-
-/**
- * Special assertion failure handling in debug mode; in non-debug
- * builds, the exception is thrown from the macro. We factor out this
- * additional logic so as not to bloat the code at every Assert()
- * expansion.
- *
- * Note this name is prefixed with "debug" because it is included in
- * debug builds only; in debug builds, it handles all assertion
- * failures (even those that exist in non-debug builds).
- */
-void debugAssertionFailed(const AssertionException& thisException, const char* lastException);
-
-// If we're currently handling an exception, print a warning instead;
-// otherwise std::terminate() is called by the runtime and we lose
-// details of the exception
-# define AlwaysAssert(cond, msg...) \
- do { \
- if(__builtin_expect( ( ! (cond) ), false )) { \
- /* save the last assertion failure */ \
- const char* lastException = ::CVC4::s_debugLastException; \
- ::CVC4::AssertionException exception(#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
- ::CVC4::debugAssertionFailed(exception, lastException); \
- } \
- } while(0)
-
-#else /* CVC4_DEBUG */
-// These simpler (but less useful) versions for non-debug builds fails
-// will terminate() if thrown during stack unwinding.
-# define AlwaysAssert(cond, msg...) \
- do { \
- if(__builtin_expect( ( ! (cond) ), false )) { \
- throw ::CVC4::AssertionException(#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
- } \
- } while(0)
-#endif /* CVC4_DEBUG */
-
-#define Unreachable(msg...) \
- throw ::CVC4::UnreachableCodeException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
-#define Unhandled(msg...) \
- throw ::CVC4::UnhandledCaseException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
-#define Unimplemented(msg...) \
- throw ::CVC4::UnimplementedOperationException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
-#define InternalError(msg...) \
- throw ::CVC4::InternalErrorException(__PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg)
-#define IllegalArgument(arg, msg...) \
- throw ::CVC4::IllegalArgumentException("", #arg, __PRETTY_FUNCTION__, ## msg)
-#define CheckArgument(cond, arg, msg...) \
- do { \
- if(__builtin_expect( ( ! (cond) ), false )) { \
- throw ::CVC4::IllegalArgumentException(#cond, #arg, __PRETTY_FUNCTION__, ## msg); \
- } \
- } while(0)
-#define AlwaysAssertArgument(cond, arg, msg...) \
- do { \
- if(__builtin_expect( ( ! (cond) ), false )) { \
- throw ::CVC4::AssertArgumentException(#cond, #arg, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## msg); \
- } \
- } while(0)
-
-#ifdef CVC4_ASSERTIONS
-# define Assert(cond, msg...) AlwaysAssert(cond, ## msg)
-# define AssertArgument(cond, arg, msg...) AlwaysAssertArgument(cond, arg, ## msg)
-# define DebugCheckArgument(cond, arg, msg...) CheckArgument(cond, arg, ## msg)
-#else /* ! CVC4_ASSERTIONS */
-# define Assert(cond, msg...) /*__builtin_expect( ( cond ), true )*/
-# define AssertArgument(cond, arg, msg...) /*__builtin_expect( ( cond ), true )*/
-# define DebugCheckArgument(cond, arg, msg...) /*__builtin_expect( ( cond ), true )*/
-#endif /* CVC4_ASSERTIONS */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__ASSERT_H */
+++ /dev/null
-/********************* */
-/*! \file datatype.cpp
- ** \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 A class representing a Datatype definition
- **
- ** A class representing a Datatype definition for the theory of
- ** inductive datatypes.
- **/
-
-#include <string>
-#include <sstream>
-
-#include "util/datatype.h"
-#include "expr/type.h"
-#include "expr/expr_manager.h"
-#include "expr/expr_manager_scope.h"
-#include "expr/node_manager.h"
-#include "expr/node.h"
-#include "expr/attribute.h"
-#include "util/matcher.h"
-#include "util/cvc4_assert.h"
-
-using namespace std;
-
-namespace CVC4 {
-
-namespace expr {
- namespace attr {
- struct DatatypeIndexTag {};
- struct DatatypeConsIndexTag {};
- struct DatatypeFiniteTag {};
- struct DatatypeFiniteComputedTag {};
- }/* CVC4::expr::attr namespace */
-}/* CVC4::expr namespace */
-
-typedef expr::Attribute<expr::attr::DatatypeIndexTag, uint64_t> DatatypeIndexAttr;
-typedef expr::Attribute<expr::attr::DatatypeConsIndexTag, uint64_t> DatatypeConsIndexAttr;
-typedef expr::Attribute<expr::attr::DatatypeFiniteTag, bool> DatatypeFiniteAttr;
-typedef expr::Attribute<expr::attr::DatatypeFiniteComputedTag, bool> DatatypeFiniteComputedAttr;
-
-const Datatype& Datatype::datatypeOf(Expr item) {
- ExprManagerScope ems(item);
- TypeNode t = Node::fromExpr(item).getType();
- switch(t.getKind()) {
- case kind::CONSTRUCTOR_TYPE:
- return DatatypeType(t[t.getNumChildren() - 1].toType()).getDatatype();
- case kind::SELECTOR_TYPE:
- case kind::TESTER_TYPE:
- return DatatypeType(t[0].toType()).getDatatype();
- default:
- Unhandled("arg must be a datatype constructor, selector, or tester");
- }
-}
-
-size_t Datatype::indexOf(Expr item) {
- ExprManagerScope ems(item);
- CheckArgument(item.getType().isConstructor() ||
- item.getType().isTester() ||
- item.getType().isSelector(),
- item,
- "arg must be a datatype constructor, selector, or tester");
- TNode n = Node::fromExpr(item);
- if( item.getKind()==kind::APPLY_TYPE_ASCRIPTION ){
- return indexOf( item[0] );
- }else{
- Assert(n.hasAttribute(DatatypeIndexAttr()));
- return n.getAttribute(DatatypeIndexAttr());
- }
-}
-
-size_t Datatype::cindexOf(Expr item) {
- ExprManagerScope ems(item);
- CheckArgument(item.getType().isSelector(),
- item,
- "arg must be a datatype selector");
- TNode n = Node::fromExpr(item);
- if( item.getKind()==kind::APPLY_TYPE_ASCRIPTION ){
- return cindexOf( item[0] );
- }else{
- Assert(n.hasAttribute(DatatypeConsIndexAttr()));
- return n.getAttribute(DatatypeConsIndexAttr());
- }
-}
-
-void Datatype::resolve(ExprManager* em,
- const std::map<std::string, DatatypeType>& resolutions,
- const std::vector<Type>& placeholders,
- const std::vector<Type>& replacements,
- const std::vector< SortConstructorType >& paramTypes,
- const std::vector< DatatypeType >& paramReplacements)
- throw(IllegalArgumentException, DatatypeResolutionException) {
-
- CheckArgument(em != NULL, em, "cannot resolve a Datatype with a NULL expression manager");
- CheckArgument(!d_resolved, this, "cannot resolve a Datatype twice");
- CheckArgument(resolutions.find(d_name) != resolutions.end(), resolutions,
- "Datatype::resolve(): resolutions doesn't contain me!");
- CheckArgument(placeholders.size() == replacements.size(), placeholders,
- "placeholders and replacements must be the same size");
- CheckArgument(paramTypes.size() == paramReplacements.size(), paramTypes,
- "paramTypes and paramReplacements must be the same size");
- CheckArgument(getNumConstructors() > 0, *this, "cannot resolve a Datatype that has no constructors");
- DatatypeType self = (*resolutions.find(d_name)).second;
- CheckArgument(&self.getDatatype() == this, resolutions, "Datatype::resolve(): resolutions doesn't contain me!");
- d_resolved = true;
- size_t index = 0;
- for(std::vector<DatatypeConstructor>::iterator i = d_constructors.begin(), i_end = d_constructors.end(); i != i_end; ++i) {
- (*i).resolve(em, self, resolutions, placeholders, replacements, paramTypes, paramReplacements, index);
- Node::fromExpr((*i).d_constructor).setAttribute(DatatypeIndexAttr(), index);
- Node::fromExpr((*i).d_tester).setAttribute(DatatypeIndexAttr(), index++);
- }
- d_self = self;
-
- d_involvesExt = false;
- for(const_iterator i = begin(); i != end(); ++i) {
- if( (*i).involvesExternalType() ){
- d_involvesExt = true;
- break;
- }
- }
-}
-
-void Datatype::addConstructor(const DatatypeConstructor& c) {
- CheckArgument(!d_resolved, this,
- "cannot add a constructor to a finalized Datatype");
- d_constructors.push_back(c);
-}
-
-
-void Datatype::setSygus( Type st, Expr bvl, bool allow_const, bool allow_all ){
- CheckArgument(!d_resolved, this,
- "cannot set sygus type to a finalized Datatype");
- d_sygus_type = st;
- d_sygus_bvl = bvl;
- d_sygus_allow_const = allow_const || allow_all;
- d_sygus_allow_all = allow_all;
-}
-
-
-Cardinality Datatype::getCardinality() const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), this, "this datatype is not yet resolved");
- std::vector< Type > processing;
- computeCardinality( processing );
- return d_card;
-}
-
-Cardinality Datatype::computeCardinality( std::vector< Type >& processing ) const throw(IllegalArgumentException){
- CheckArgument(isResolved(), this, "this datatype is not yet resolved");
- if( std::find( processing.begin(), processing.end(), d_self )!=processing.end() ){
- d_card = Cardinality::INTEGERS;
- }else{
- processing.push_back( d_self );
- Cardinality c = 0;
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- c += (*i).computeCardinality( processing );
- }
- d_card = c;
- processing.pop_back();
- }
- return d_card;
-}
-
-bool Datatype::isRecursiveSingleton() const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), this, "this datatype is not yet resolved");
- if( d_card_rec_singleton==0 ){
- Assert( d_card_u_assume.empty() );
- std::vector< Type > processing;
- if( computeCardinalityRecSingleton( processing, d_card_u_assume ) ){
- d_card_rec_singleton = 1;
- }else{
- d_card_rec_singleton = -1;
- }
- if( d_card_rec_singleton==1 ){
- Trace("dt-card") << "Datatype " << getName() << " is recursive singleton, dependent upon " << d_card_u_assume.size() << " uninterpreted sorts: " << std::endl;
- for( unsigned i=0; i<d_card_u_assume.size(); i++ ){
- Trace("dt-card") << " " << d_card_u_assume [i] << std::endl;
- }
- Trace("dt-card") << std::endl;
- }
- }
- return d_card_rec_singleton==1;
-}
-
-unsigned Datatype::getNumRecursiveSingletonArgTypes() const throw(IllegalArgumentException) {
- return d_card_u_assume.size();
-}
-Type Datatype::getRecursiveSingletonArgType( unsigned i ) const throw(IllegalArgumentException) {
- return d_card_u_assume[i];
-}
-
-bool Datatype::computeCardinalityRecSingleton( std::vector< Type >& processing, std::vector< Type >& u_assume ) const throw(IllegalArgumentException){
- if( std::find( processing.begin(), processing.end(), d_self )!=processing.end() ){
- return true;
- }else{
- if( d_card_rec_singleton==0 ){
- //if not yet computed
- if( d_constructors.size()==1 ){
- bool success = false;
- processing.push_back( d_self );
- for(unsigned i = 0; i<d_constructors[0].getNumArgs(); i++ ) {
- Type t = ((SelectorType)d_constructors[0][i].getType()).getRangeType();
- //if it is an uninterpreted sort, then we depend on it having cardinality one
- if( t.isSort() ){
- if( std::find( u_assume.begin(), u_assume.end(), t )==u_assume.end() ){
- u_assume.push_back( t );
- }
- //if it is a datatype, recurse
- }else if( t.isDatatype() ){
- const Datatype & dt = ((DatatypeType)t).getDatatype();
- if( !dt.computeCardinalityRecSingleton( processing, u_assume ) ){
- return false;
- }else{
- success = true;
- }
- //if it is a builtin type, it must have cardinality one
- }else if( !t.getCardinality().isOne() ){
- return false;
- }
- }
- processing.pop_back();
- return success;
- }else{
- return false;
- }
- }else if( d_card_rec_singleton==-1 ){
- return false;
- }else{
- for( unsigned i=0; i<d_card_u_assume.size(); i++ ){
- if( std::find( u_assume.begin(), u_assume.end(), d_card_u_assume[i] )==u_assume.end() ){
- u_assume.push_back( d_card_u_assume[i] );
- }
- }
- return true;
- }
- }
-}
-
-bool Datatype::isFinite() const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), this, "this datatype is not yet resolved");
-
- // we're using some internals, so we have to set up this library context
- ExprManagerScope ems(d_self);
-
- TypeNode self = TypeNode::fromType(d_self);
-
- // is this already in the cache ?
- if(self.getAttribute(DatatypeFiniteComputedAttr())) {
- return self.getAttribute(DatatypeFiniteAttr());
- }
-
- Cardinality c = 0;
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- if(! (*i).isFinite()) {
- self.setAttribute(DatatypeFiniteComputedAttr(), true);
- self.setAttribute(DatatypeFiniteAttr(), false);
- return false;
- }
- }
- self.setAttribute(DatatypeFiniteComputedAttr(), true);
- self.setAttribute(DatatypeFiniteAttr(), true);
- return true;
-}
-
-bool Datatype::isWellFounded() const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), this, "this datatype is not yet resolved");
- if( d_well_founded==0 ){
- // we're using some internals, so we have to set up this library context
- ExprManagerScope ems(d_self);
- std::vector< Type > processing;
- if( computeWellFounded( processing ) ){
- d_well_founded = 1;
- }else{
- d_well_founded = -1;
- }
- }
- return d_well_founded==1;
-}
-
-bool Datatype::computeWellFounded( std::vector< Type >& processing ) const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), this, "this datatype is not yet resolved");
- if( std::find( processing.begin(), processing.end(), d_self )!=processing.end() ){
- return d_isCo;
- }else{
- processing.push_back( d_self );
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- if( (*i).computeWellFounded( processing ) ){
- processing.pop_back();
- return true;
- }else{
- Trace("dt-wf") << "Constructor " << (*i).getName() << " is not well-founded." << std::endl;
- }
- }
- processing.pop_back();
- Trace("dt-wf") << "Datatype " << getName() << " is not well-founded." << std::endl;
- return false;
- }
-}
-
-Expr Datatype::mkGroundTerm( Type t ) const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), this, "this datatype is not yet resolved");
- ExprManagerScope ems(d_self);
-
-
- // is this already in the cache ?
- std::map< Type, Expr >::iterator it = d_ground_term.find( t );
- if( it != d_ground_term.end() ){
- Debug("datatypes") << "\nin cache: " << d_self << " => " << it->second << std::endl;
- return it->second;
- } else {
- std::vector< Type > processing;
- Expr groundTerm = computeGroundTerm( t, processing );
- if(!groundTerm.isNull() ) {
- // we found a ground-term-constructing constructor!
- d_ground_term[t] = groundTerm;
- Debug("datatypes") << "constructed: " << getName() << " => " << groundTerm << std::endl;
- }
- if( groundTerm.isNull() ){
- if( !d_isCo ){
- // if we get all the way here, we aren't well-founded
- CheckArgument(false, *this, "datatype is not well-founded, cannot construct a ground term!");
- }else{
- return groundTerm;
- }
- }else{
- return groundTerm;
- }
- }
-}
-
-Expr getSubtermWithType( Expr e, Type t, bool isTop ){
- if( !isTop && e.getType()==t ){
- return e;
- }else{
- for( unsigned i=0; i<e.getNumChildren(); i++ ){
- Expr se = getSubtermWithType( e[i], t, false );
- if( !se.isNull() ){
- return se;
- }
- }
- return Expr();
- }
-}
-
-Expr Datatype::computeGroundTerm( Type t, std::vector< Type >& processing ) const throw(IllegalArgumentException) {
- if( std::find( processing.begin(), processing.end(), d_self )==processing.end() ){
- processing.push_back( d_self );
- for( unsigned r=0; r<2; r++ ){
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- //do nullary constructors first
- if( ((*i).getNumArgs()==0)==(r==0)){
- Debug("datatypes") << "Try constructing for " << (*i).getName() << ", processing = " << processing.size() << std::endl;
- Expr e = (*i).computeGroundTerm( t, processing, d_ground_term );
- if( !e.isNull() ){
- //must check subterms for the same type to avoid infinite loops in type enumeration
- Expr se = getSubtermWithType( e, t, true );
- if( !se.isNull() ){
- Debug("datatypes") << "Take subterm " << se << std::endl;
- e = se;
- }
- processing.pop_back();
- return e;
- }else{
- Debug("datatypes") << "...failed." << std::endl;
- }
- }
- }
- }
- processing.pop_back();
- }else{
- Debug("datatypes") << "...already processing " << t << std::endl;
- }
- return Expr();
-}
-
-DatatypeType Datatype::getDatatypeType() const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), *this, "Datatype must be resolved to get its DatatypeType");
- CheckArgument(!d_self.isNull(), *this);
- return DatatypeType(d_self);
-}
-
-DatatypeType Datatype::getDatatypeType(const std::vector<Type>& params)
- const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), *this, "Datatype must be resolved to get its DatatypeType");
- CheckArgument(!d_self.isNull() && DatatypeType(d_self).isParametric(), this);
- return DatatypeType(d_self).instantiate(params);
-}
-
-bool Datatype::operator==(const Datatype& other) const throw() {
- // two datatypes are == iff the name is the same and they have
- // exactly matching constructors (in the same order)
-
- if(this == &other) {
- return true;
- }
-
- if(isResolved() != other.isResolved()) {
- return false;
- }
-
- if( d_name != other.d_name ||
- getNumConstructors() != other.getNumConstructors() ) {
- return false;
- }
- for(const_iterator i = begin(), j = other.begin(); i != end(); ++i, ++j) {
- Assert(j != other.end());
- // two constructors are == iff they have the same name, their
- // constructors and testers are equal and they have exactly
- // matching args (in the same order)
- if((*i).getName() != (*j).getName() ||
- (*i).getNumArgs() != (*j).getNumArgs()) {
- return false;
- }
- // testing equivalence of constructors and testers is harder b/c
- // this constructor might not be resolved yet; only compare them
- // if they are both resolved
- Assert(isResolved() == !(*i).d_constructor.isNull() &&
- isResolved() == !(*i).d_tester.isNull() &&
- (*i).d_constructor.isNull() == (*j).d_constructor.isNull() &&
- (*i).d_tester.isNull() == (*j).d_tester.isNull());
- if(!(*i).d_constructor.isNull() && (*i).d_constructor != (*j).d_constructor) {
- return false;
- }
- if(!(*i).d_tester.isNull() && (*i).d_tester != (*j).d_tester) {
- return false;
- }
- for(DatatypeConstructor::const_iterator k = (*i).begin(), l = (*j).begin(); k != (*i).end(); ++k, ++l) {
- Assert(l != (*j).end());
- if((*k).getName() != (*l).getName()) {
- return false;
- }
- // testing equivalence of selectors is harder b/c args might not
- // be resolved yet
- Assert(isResolved() == (*k).isResolved() &&
- (*k).isResolved() == (*l).isResolved());
- if((*k).isResolved()) {
- // both are resolved, so simply compare the selectors directly
- if((*k).d_selector != (*l).d_selector) {
- return false;
- }
- } else {
- // neither is resolved, so compare their (possibly unresolved)
- // types; we don't know if they'll be resolved the same way,
- // so we can't ever say unresolved types are equal
- if(!(*k).d_selector.isNull() && !(*l).d_selector.isNull()) {
- if((*k).d_selector.getType() != (*l).d_selector.getType()) {
- return false;
- }
- } else {
- if((*k).isUnresolvedSelf() && (*l).isUnresolvedSelf()) {
- // Fine, the selectors are equal if the rest of the
- // enclosing datatypes are equal...
- } else {
- return false;
- }
- }
- }
- }
- }
- return true;
-}
-
-const DatatypeConstructor& Datatype::operator[](size_t index) const {
- CheckArgument(index < getNumConstructors(), index, "index out of bounds");
- return d_constructors[index];
-}
-
-const DatatypeConstructor& Datatype::operator[](std::string name) const {
- for(const_iterator i = begin(); i != end(); ++i) {
- if((*i).getName() == name) {
- return *i;
- }
- }
- CheckArgument(false, name, "No such constructor `%s' of datatype `%s'", name.c_str(), d_name.c_str());
-}
-
-Expr Datatype::getConstructor(std::string name) const {
- return (*this)[name].getConstructor();
-}
-
-Type Datatype::getSygusType() const {
- return d_sygus_type;
-}
-
-Expr Datatype::getSygusVarList() const {
- return d_sygus_bvl;
-}
-
-bool Datatype::getSygusAllowConst() const {
- return d_sygus_allow_const;
-}
-
-bool Datatype::getSygusAllowAll() const {
- return d_sygus_allow_const;
-}
-
-bool Datatype::involvesExternalType() const{
- return d_involvesExt;
-}
-
-void DatatypeConstructor::resolve(ExprManager* em, DatatypeType self,
- const std::map<std::string, DatatypeType>& resolutions,
- const std::vector<Type>& placeholders,
- const std::vector<Type>& replacements,
- const std::vector< SortConstructorType >& paramTypes,
- const std::vector< DatatypeType >& paramReplacements, size_t cindex)
- throw(IllegalArgumentException, DatatypeResolutionException) {
-
- CheckArgument(em != NULL, em, "cannot resolve a Datatype with a NULL expression manager");
- CheckArgument(!isResolved(),
- "cannot resolve a Datatype constructor twice; "
- "perhaps the same constructor was added twice, "
- "or to two datatypes?");
-
- // we're using some internals, so we have to set up this library context
- ExprManagerScope ems(*em);
-
- NodeManager* nm = NodeManager::fromExprManager(em);
- TypeNode selfTypeNode = TypeNode::fromType(self);
- size_t index = 0;
- for(std::vector<DatatypeConstructorArg>::iterator i = d_args.begin(), i_end = d_args.end(); i != i_end; ++i) {
- if((*i).d_selector.isNull()) {
- // the unresolved type wasn't created here; do name resolution
- string typeName = (*i).d_name.substr((*i).d_name.find('\0') + 1);
- (*i).d_name.resize((*i).d_name.find('\0'));
- if(typeName == "") {
- (*i).d_selector = nm->mkSkolem((*i).d_name, nm->mkSelectorType(selfTypeNode, selfTypeNode), "is a selector", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
- } else {
- map<string, DatatypeType>::const_iterator j = resolutions.find(typeName);
- if(j == resolutions.end()) {
- stringstream msg;
- msg << "cannot resolve type \"" << typeName << "\" "
- << "in selector \"" << (*i).d_name << "\" "
- << "of constructor \"" << d_name << "\"";
- throw DatatypeResolutionException(msg.str());
- } else {
- (*i).d_selector = nm->mkSkolem((*i).d_name, nm->mkSelectorType(selfTypeNode, TypeNode::fromType((*j).second)), "is a selector", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
- }
- }
- } else {
- // the type for the selector already exists; may need
- // complex-type substitution
- Type range = (*i).d_selector.getType();
- if(!placeholders.empty()) {
- range = range.substitute(placeholders, replacements);
- }
- if(!paramTypes.empty() ) {
- range = doParametricSubstitution( range, paramTypes, paramReplacements );
- }
- (*i).d_selector = nm->mkSkolem((*i).d_name, nm->mkSelectorType(selfTypeNode, TypeNode::fromType(range)), "is a selector", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
- }
- Node::fromExpr((*i).d_selector).setAttribute(DatatypeConsIndexAttr(), cindex);
- Node::fromExpr((*i).d_selector).setAttribute(DatatypeIndexAttr(), index++);
- (*i).d_resolved = true;
- }
-
- Assert(index == getNumArgs());
-
- // Set constructor/tester last, since DatatypeConstructor::isResolved()
- // returns true when d_tester is not the null Expr. If something
- // fails above, we want Constuctor::isResolved() to remain "false".
- // Further, mkConstructorType() iterates over the selectors, so
- // should get the results of any resolutions we did above.
- d_tester = nm->mkSkolem(getTesterName(), nm->mkTesterType(selfTypeNode), "is a tester", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
- d_constructor = nm->mkSkolem(getName(), nm->mkConstructorType(*this, selfTypeNode), "is a constructor", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
- // associate constructor with all selectors
- for(std::vector<DatatypeConstructorArg>::iterator i = d_args.begin(), i_end = d_args.end(); i != i_end; ++i) {
- (*i).d_constructor = d_constructor;
- }
-}
-
-Type DatatypeConstructor::doParametricSubstitution( Type range,
- const std::vector< SortConstructorType >& paramTypes,
- const std::vector< DatatypeType >& paramReplacements ) {
- TypeNode typn = TypeNode::fromType( range );
- if(typn.getNumChildren() == 0) {
- return range;
- } else {
- std::vector< Type > origChildren;
- std::vector< Type > children;
- for(TypeNode::const_iterator i = typn.begin(), iend = typn.end();i != iend; ++i) {
- origChildren.push_back( (*i).toType() );
- children.push_back( doParametricSubstitution( (*i).toType(), paramTypes, paramReplacements ) );
- }
- for( unsigned i = 0; i < paramTypes.size(); ++i ) {
- if( paramTypes[i].getArity() == origChildren.size() ) {
- Type tn = paramTypes[i].instantiate( origChildren );
- if( range == tn ) {
- return paramReplacements[i].instantiate( children );
- }
- }
- }
- NodeBuilder<> nb(typn.getKind());
- for( unsigned i = 0; i < children.size(); ++i ) {
- nb << TypeNode::fromType( children[i] );
- }
- return nb.constructTypeNode().toType();
- }
-}
-
-DatatypeConstructor::DatatypeConstructor(std::string name) :
- // We don't want to introduce a new data member, because eventually
- // we're going to be a constant stuffed inside a node. So we stow
- // the tester name away inside the constructor name until
- // resolution.
- d_name(name + '\0' + "is_" + name), // default tester name is "is_FOO"
- d_tester(),
- d_args() {
- CheckArgument(name != "", name, "cannot construct a datatype constructor without a name");
-}
-
-DatatypeConstructor::DatatypeConstructor(std::string name, std::string tester) :
- // We don't want to introduce a new data member, because eventually
- // we're going to be a constant stuffed inside a node. So we stow
- // the tester name away inside the constructor name until
- // resolution.
- d_name(name + '\0' + tester),
- d_tester(),
- d_args() {
- CheckArgument(name != "", name, "cannot construct a datatype constructor without a name");
- CheckArgument(!tester.empty(), tester, "cannot construct a datatype constructor without a tester");
-}
-
-void DatatypeConstructor::setSygus( Expr op, Expr let_body, std::vector< Expr >& let_args, unsigned num_let_input_args ){
- d_sygus_op = op;
- d_sygus_let_body = let_body;
- d_sygus_let_args.insert( d_sygus_let_args.end(), let_args.begin(), let_args.end() );
- d_sygus_num_let_input_args = num_let_input_args;
-}
-
-
-void DatatypeConstructor::addArg(std::string selectorName, Type selectorType) {
- // We don't want to introduce a new data member, because eventually
- // we're going to be a constant stuffed inside a node. So we stow
- // the selector type away inside a var until resolution (when we can
- // create the proper selector type)
- CheckArgument(!isResolved(), this, "cannot modify a finalized Datatype constructor");
- CheckArgument(!selectorType.isNull(), selectorType, "cannot add a null selector type");
-
- // we're using some internals, so we have to set up this library context
- ExprManagerScope ems(selectorType);
-
- Expr type = NodeManager::currentNM()->mkSkolem("unresolved_" + selectorName, TypeNode::fromType(selectorType), "is an unresolved selector type placeholder", NodeManager::SKOLEM_EXACT_NAME | NodeManager::SKOLEM_NO_NOTIFY).toExpr();
- Debug("datatypes") << type << endl;
- d_args.push_back(DatatypeConstructorArg(selectorName, type));
-}
-
-void DatatypeConstructor::addArg(std::string selectorName, DatatypeUnresolvedType selectorType) {
- // We don't want to introduce a new data member, because eventually
- // we're going to be a constant stuffed inside a node. So we stow
- // the selector type away after a NUL in the name string until
- // resolution (when we can create the proper selector type)
- CheckArgument(!isResolved(), this, "cannot modify a finalized Datatype constructor");
- CheckArgument(selectorType.getName() != "", selectorType, "cannot add a null selector type");
- d_args.push_back(DatatypeConstructorArg(selectorName + '\0' + selectorType.getName(), Expr()));
-}
-
-void DatatypeConstructor::addArg(std::string selectorName, DatatypeSelfType) {
- // We don't want to introduce a new data member, because eventually
- // we're going to be a constant stuffed inside a node. So we mark
- // the name string with a NUL to indicate that we have a
- // self-selecting selector until resolution (when we can create the
- // proper selector type)
- CheckArgument(!isResolved(), this, "cannot modify a finalized Datatype constructor");
- d_args.push_back(DatatypeConstructorArg(selectorName + '\0', Expr()));
-}
-
-std::string DatatypeConstructor::getName() const throw() {
- return d_name.substr(0, d_name.find('\0'));
-}
-
-std::string DatatypeConstructor::getTesterName() const throw() {
- return d_name.substr(d_name.find('\0') + 1);
-}
-
-Expr DatatypeConstructor::getConstructor() const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- return d_constructor;
-}
-
-Type DatatypeConstructor::getSpecializedConstructorType(Type returnType) const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- ExprManagerScope ems(d_constructor);
- const Datatype& dt = Datatype::datatypeOf(d_constructor);
- CheckArgument(dt.isParametric(), this, "this datatype constructor is not parametric");
- DatatypeType dtt = dt.getDatatypeType();
- Matcher m(dtt);
- m.doMatching( TypeNode::fromType(dtt), TypeNode::fromType(returnType) );
- vector<Type> subst;
- m.getMatches(subst);
- vector<Type> params = dt.getParameters();
- return d_constructor.getType().substitute(params, subst);
-}
-
-Expr DatatypeConstructor::getTester() const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- return d_tester;
-}
-
-Expr DatatypeConstructor::getSygusOp() const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- return d_sygus_op;
-}
-
-Expr DatatypeConstructor::getSygusLetBody() const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- return d_sygus_let_body;
-}
-
-unsigned DatatypeConstructor::getNumSygusLetArgs() const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- return d_sygus_let_args.size();
-}
-
-Expr DatatypeConstructor::getSygusLetArg( unsigned i ) const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- return d_sygus_let_args[i];
-}
-
-unsigned DatatypeConstructor::getNumSygusLetInputArgs() const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- return d_sygus_num_let_input_args;
-}
-
-bool DatatypeConstructor::isSygusIdFunc() const {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
- return d_sygus_let_args.size()==1 && d_sygus_let_args[0]==d_sygus_let_body;
-}
-
-Cardinality DatatypeConstructor::getCardinality() const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
-
- Cardinality c = 1;
-
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- c *= SelectorType((*i).getSelector().getType()).getRangeType().getCardinality();
- }
-
- return c;
-}
-
-/** compute the cardinality of this datatype */
-Cardinality DatatypeConstructor::computeCardinality( std::vector< Type >& processing ) const throw(IllegalArgumentException){
- Cardinality c = 1;
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- Type t = SelectorType((*i).getSelector().getType()).getRangeType();
- if( t.isDatatype() ){
- const Datatype& dt = ((DatatypeType)t).getDatatype();
- c *= dt.computeCardinality( processing );
- }else{
- c *= t.getCardinality();
- }
- }
- return c;
-}
-
-bool DatatypeConstructor::computeWellFounded( std::vector< Type >& processing ) const throw(IllegalArgumentException){
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- Type t = SelectorType((*i).getSelector().getType()).getRangeType();
- if( t.isDatatype() ){
- const Datatype& dt = ((DatatypeType)t).getDatatype();
- if( !dt.computeWellFounded( processing ) ){
- return false;
- }
- }
- }
- return true;
-}
-
-
-bool DatatypeConstructor::isFinite() const throw(IllegalArgumentException) {
- CheckArgument(isResolved(), this, "this datatype constructor is not yet resolved");
-
- // we're using some internals, so we have to set up this library context
- ExprManagerScope ems(d_constructor);
-
- TNode self = Node::fromExpr(d_constructor);
-
- // is this already in the cache ?
- if(self.getAttribute(DatatypeFiniteComputedAttr())) {
- return self.getAttribute(DatatypeFiniteAttr());
- }
-
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- if(! SelectorType((*i).getSelector().getType()).getRangeType().getCardinality().isFinite()) {
- self.setAttribute(DatatypeFiniteComputedAttr(), true);
- self.setAttribute(DatatypeFiniteAttr(), false);
- return false;
- }
- }
-
- self.setAttribute(DatatypeFiniteComputedAttr(), true);
- self.setAttribute(DatatypeFiniteAttr(), true);
- return true;
-}
-
-Expr DatatypeConstructor::computeGroundTerm( Type t, std::vector< Type >& processing, std::map< Type, Expr >& gt ) const throw(IllegalArgumentException) {
-// we're using some internals, so we have to set up this library context
- ExprManagerScope ems(d_constructor);
-
- std::vector<Expr> groundTerms;
- groundTerms.push_back(getConstructor());
-
- // for each selector, get a ground term
- std::vector< Type > instTypes;
- std::vector< Type > paramTypes;
- if( DatatypeType(t).isParametric() ){
- paramTypes = DatatypeType(t).getDatatype().getParameters();
- instTypes = DatatypeType(t).getParamTypes();
- }
- for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) {
- Type selType = SelectorType((*i).getSelector().getType()).getRangeType();
- if( DatatypeType(t).isParametric() ){
- selType = selType.substitute( paramTypes, instTypes );
- }
- Expr arg;
- if( selType.isDatatype() ){
- std::map< Type, Expr >::iterator itgt = gt.find( selType );
- if( itgt != gt.end() ){
- arg = itgt->second;
- }else{
- const Datatype & dt = DatatypeType(selType).getDatatype();
- arg = dt.computeGroundTerm( selType, processing );
- }
- }else{
- arg = selType.mkGroundTerm();
- }
- if( arg.isNull() ){
- Debug("datatypes") << "...unable to construct arg of " << (*i).getName() << std::endl;
- return Expr();
- }else{
- Debug("datatypes") << "...constructed arg " << arg.getType() << std::endl;
- groundTerms.push_back(arg);
- }
- }
-
- Expr groundTerm = getConstructor().getExprManager()->mkExpr(kind::APPLY_CONSTRUCTOR, groundTerms);
- if( groundTerm.getType()!=t ){
- Assert( Datatype::datatypeOf( d_constructor ).isParametric() );
- //type is ambiguous, must apply type ascription
- Debug("datatypes-gt") << "ambiguous type for " << groundTerm << ", ascribe to " << t << std::endl;
- groundTerms[0] = getConstructor().getExprManager()->mkExpr(kind::APPLY_TYPE_ASCRIPTION,
- getConstructor().getExprManager()->mkConst(AscriptionType(getSpecializedConstructorType(t))),
- groundTerms[0]);
- groundTerm = getConstructor().getExprManager()->mkExpr(kind::APPLY_CONSTRUCTOR, groundTerms);
- }
- return groundTerm;
-}
-
-
-const DatatypeConstructorArg& DatatypeConstructor::operator[](size_t index) const {
- CheckArgument(index < getNumArgs(), index, "index out of bounds");
- return d_args[index];
-}
-
-const DatatypeConstructorArg& DatatypeConstructor::operator[](std::string name) const {
- for(const_iterator i = begin(); i != end(); ++i) {
- if((*i).getName() == name) {
- return *i;
- }
- }
- CheckArgument(false, name, "No such arg `%s' of constructor `%s'", name.c_str(), d_name.c_str());
-}
-
-Expr DatatypeConstructor::getSelector(std::string name) const {
- return (*this)[name].getSelector();
-}
-
-bool DatatypeConstructor::involvesExternalType() const{
- for(const_iterator i = begin(); i != end(); ++i) {
- if(! SelectorType((*i).getSelector().getType()).getRangeType().isDatatype()) {
- return true;
- }
- }
- return false;
-}
-
-DatatypeConstructorArg::DatatypeConstructorArg(std::string name, Expr selector) :
- d_name(name),
- d_selector(selector),
- d_resolved(false) {
- CheckArgument(name != "", name, "cannot construct a datatype constructor arg without a name");
-}
-
-std::string DatatypeConstructorArg::getName() const throw() {
- string name = d_name;
- const size_t nul = name.find('\0');
- if(nul != string::npos) {
- name.resize(nul);
- }
- return name;
-}
-
-Expr DatatypeConstructorArg::getSelector() const {
- CheckArgument(isResolved(), this, "cannot get a selector for an unresolved datatype constructor");
- return d_selector;
-}
-
-Expr DatatypeConstructorArg::getConstructor() const {
- CheckArgument(isResolved(), this,
- "cannot get a associated constructor for argument of an unresolved datatype constructor");
- return d_constructor;
-}
-
-SelectorType DatatypeConstructorArg::getType() const {
- return getSelector().getType();
-}
-
-bool DatatypeConstructorArg::isUnresolvedSelf() const throw() {
- return d_selector.isNull() && d_name.size() == d_name.find('\0') + 1;
-}
-
-static const int s_printDatatypeNamesOnly = std::ios_base::xalloc();
-
-std::string DatatypeConstructorArg::getTypeName() const {
- Type t;
- if(isResolved()) {
- t = SelectorType(d_selector.getType()).getRangeType();
- } else {
- if(d_selector.isNull()) {
- string typeName = d_name.substr(d_name.find('\0') + 1);
- return (typeName == "") ? "[self]" : typeName;
- } else {
- t = d_selector.getType();
- }
- }
-
- // Unfortunately, in the case of complex selector types, we can
- // enter nontrivial recursion here. Make sure that doesn't happen.
- stringstream ss;
- ss << Expr::setlanguage(language::output::LANG_CVC4);
- ss.iword(s_printDatatypeNamesOnly) = 1;
- t.toStream(ss);
- return ss.str();
-}
-
-std::ostream& operator<<(std::ostream& os, const Datatype& dt) {
- // These datatype things are recursive! Be very careful not to
- // print an infinite chain of them.
- long& printNameOnly = os.iword(s_printDatatypeNamesOnly);
- Debug("datatypes-output") << "printNameOnly is " << printNameOnly << std::endl;
- if(printNameOnly) {
- return os << dt.getName();
- }
-
- class Scope {
- long& d_ref;
- long d_oldValue;
- public:
- Scope(long& ref, long value) : d_ref(ref), d_oldValue(ref) { d_ref = value; }
- ~Scope() { d_ref = d_oldValue; }
- } scope(printNameOnly, 1);
- // when scope is destructed, the value pops back
-
- Debug("datatypes-output") << "printNameOnly is now " << printNameOnly << std::endl;
-
- // can only output datatypes in the CVC4 native language
- Expr::setlanguage::Scope ls(os, language::output::LANG_CVC4);
-
- os << "DATATYPE " << dt.getName();
- if(dt.isParametric()) {
- os << '[';
- for(size_t i = 0; i < dt.getNumParameters(); ++i) {
- if(i > 0) {
- os << ',';
- }
- os << dt.getParameter(i);
- }
- os << ']';
- }
- os << " =" << endl;
- Datatype::const_iterator i = dt.begin(), i_end = dt.end();
- if(i != i_end) {
- os << " ";
- do {
- os << *i << endl;
- if(++i != i_end) {
- os << "| ";
- }
- } while(i != i_end);
- }
- os << "END;" << endl;
-
- return os;
-}
-
-std::ostream& operator<<(std::ostream& os, const DatatypeConstructor& ctor) {
- // can only output datatypes in the CVC4 native language
- Expr::setlanguage::Scope ls(os, language::output::LANG_CVC4);
-
- os << ctor.getName();
-
- DatatypeConstructor::const_iterator i = ctor.begin(), i_end = ctor.end();
- if(i != i_end) {
- os << "(";
- do {
- os << *i;
- if(++i != i_end) {
- os << ", ";
- }
- } while(i != i_end);
- os << ")";
- }
-
- return os;
-}
-
-std::ostream& operator<<(std::ostream& os, const DatatypeConstructorArg& arg) {
- // can only output datatypes in the CVC4 native language
- Expr::setlanguage::Scope ls(os, language::output::LANG_CVC4);
-
- os << arg.getName() << ": " << arg.getTypeName();
-
- return os;
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file datatype.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 A class representing a Datatype definition
- **
- ** A class representing a Datatype definition for the theory of
- ** inductive datatypes.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__DATATYPE_H
-#define __CVC4__DATATYPE_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <map>
-
-namespace CVC4 {
- // messy; Expr needs Datatype (because it's the payload of a
- // CONSTANT-kinded expression), and Datatype needs Expr.
- class CVC4_PUBLIC Datatype;
-}/* CVC4 namespace */
-
-#include "expr/expr.h"
-#include "expr/type.h"
-#include "util/hash.h"
-#include "util/exception.h"
-
-namespace CVC4 {
-
-class CVC4_PUBLIC ExprManager;
-
-class CVC4_PUBLIC DatatypeConstructor;
-class CVC4_PUBLIC DatatypeConstructorArg;
-
-class CVC4_PUBLIC DatatypeConstructorIterator {
- const std::vector<DatatypeConstructor>* d_v;
- size_t d_i;
-
- friend class Datatype;
-
- DatatypeConstructorIterator(const std::vector<DatatypeConstructor>& v, bool start) : d_v(&v), d_i(start ? 0 : v.size()) {
- }
-
-public:
- typedef const DatatypeConstructor& value_type;
- const DatatypeConstructor& operator*() const { return (*d_v)[d_i]; }
- const DatatypeConstructor* operator->() const { return &(*d_v)[d_i]; }
- DatatypeConstructorIterator& operator++() { ++d_i; return *this; }
- DatatypeConstructorIterator operator++(int) { DatatypeConstructorIterator i(*this); ++d_i; return i; }
- bool operator==(const DatatypeConstructorIterator& other) const { return d_v == other.d_v && d_i == other.d_i; }
- bool operator!=(const DatatypeConstructorIterator& other) const { return d_v != other.d_v || d_i != other.d_i; }
-};/* class DatatypeConstructorIterator */
-
-class CVC4_PUBLIC DatatypeConstructorArgIterator {
- const std::vector<DatatypeConstructorArg>* d_v;
- size_t d_i;
-
- friend class DatatypeConstructor;
-
- DatatypeConstructorArgIterator(const std::vector<DatatypeConstructorArg>& v, bool start) : d_v(&v), d_i(start ? 0 : v.size()) {
- }
-
-public:
- typedef const DatatypeConstructorArg& value_type;
- const DatatypeConstructorArg& operator*() const { return (*d_v)[d_i]; }
- const DatatypeConstructorArg* operator->() const { return &(*d_v)[d_i]; }
- DatatypeConstructorArgIterator& operator++() { ++d_i; return *this; }
- DatatypeConstructorArgIterator operator++(int) { DatatypeConstructorArgIterator i(*this); ++d_i; return i; }
- bool operator==(const DatatypeConstructorArgIterator& other) const { return d_v == other.d_v && d_i == other.d_i; }
- bool operator!=(const DatatypeConstructorArgIterator& other) const { return d_v != other.d_v || d_i != other.d_i; }
-};/* class DatatypeConstructorArgIterator */
-
-/**
- * An exception that is thrown when a datatype resolution fails.
- */
-class CVC4_PUBLIC DatatypeResolutionException : public Exception {
-public:
- inline DatatypeResolutionException(std::string msg);
-};/* class DatatypeResolutionException */
-
-/**
- * A holder type (used in calls to DatatypeConstructor::addArg())
- * to allow a Datatype to refer to itself. Self-typed fields of
- * Datatypes will be properly typed when a Type is created for the
- * Datatype by the ExprManager (which calls Datatype::resolve()).
- */
-class CVC4_PUBLIC DatatypeSelfType {
-};/* class DatatypeSelfType */
-
-/**
- * An unresolved type (used in calls to
- * DatatypeConstructor::addArg()) to allow a Datatype to refer to
- * itself or to other mutually-recursive Datatypes. Unresolved-type
- * fields of Datatypes will be properly typed when a Type is created
- * for the Datatype by the ExprManager (which calls
- * Datatype::resolve()).
- */
-class CVC4_PUBLIC DatatypeUnresolvedType {
- std::string d_name;
-public:
- inline DatatypeUnresolvedType(std::string name);
- inline std::string getName() const throw();
-};/* class DatatypeUnresolvedType */
-
-/**
- * A Datatype constructor argument (i.e., a Datatype field).
- */
-class CVC4_PUBLIC DatatypeConstructorArg {
-
- std::string d_name;
- Expr d_selector;
- /** the constructor associated with this selector */
- Expr d_constructor;
- bool d_resolved;
-
- DatatypeConstructorArg(std::string name, Expr selector);
- friend class DatatypeConstructor;
- friend class Datatype;
-
- bool isUnresolvedSelf() const throw();
-
-public:
-
- /** Get the name of this constructor argument. */
- std::string getName() const throw();
-
- /**
- * Get the selector for this constructor argument; this call is
- * only permitted after resolution.
- */
- Expr getSelector() const;
-
- /**
- * Get the associated constructor for this constructor argument;
- * this call is only permitted after resolution.
- */
- Expr getConstructor() const;
-
- /**
- * Get the type of the selector for this constructor argument;
- * this call is only permitted after resolution.
- */
- SelectorType getType() const;
-
- /**
- * Get the name of the type of this constructor argument
- * (Datatype field). Can be used for not-yet-resolved Datatypes
- * (in which case the name of the unresolved type, or "[self]"
- * for a self-referential type is returned).
- */
- std::string getTypeName() const;
-
- /**
- * Returns true iff this constructor argument has been resolved.
- */
- bool isResolved() const throw();
-
-};/* class DatatypeConstructorArg */
-
-/**
- * A constructor for a Datatype.
- */
-class CVC4_PUBLIC DatatypeConstructor {
-public:
-
- /** The type for iterators over constructor arguments. */
- typedef DatatypeConstructorArgIterator iterator;
- /** The (const) type for iterators over constructor arguments. */
- typedef DatatypeConstructorArgIterator const_iterator;
-
-private:
-
- std::string d_name;
- Expr d_constructor;
- Expr d_tester;
- std::vector<DatatypeConstructorArg> d_args;
- /** the operator associated with this constructor (for sygus) */
- Expr d_sygus_op;
- Expr d_sygus_let_body;
- std::vector< Expr > d_sygus_let_args;
- unsigned d_sygus_num_let_input_args;
-
- void resolve(ExprManager* em, DatatypeType self,
- const std::map<std::string, DatatypeType>& resolutions,
- const std::vector<Type>& placeholders,
- const std::vector<Type>& replacements,
- const std::vector< SortConstructorType >& paramTypes,
- const std::vector< DatatypeType >& paramReplacements, size_t cindex)
- throw(IllegalArgumentException, DatatypeResolutionException);
- friend class Datatype;
-
- /** Helper function for resolving parametric datatypes.
- This replaces instances of the SortConstructorType produced for unresolved
- parametric datatypes, with the corresponding resolved DatatypeType. For example, take
- the parametric definition of a list, list[T] = cons(car : T, cdr : list[T]) | null.
- If "range" is the unresolved parametric datatype:
- DATATYPE list = cons(car: SORT_TAG_1, cdr: SORT_TAG_2(SORT_TAG_1)) | null END;,
- this function will return the resolved type:
- DATATYPE list = cons(car: SORT_TAG_1, cdr: (list PARAMETERIC_DATATYPE SORT_TAG_1)) | null END;
- */
- Type doParametricSubstitution(Type range,
- const std::vector< SortConstructorType >& paramTypes,
- const std::vector< DatatypeType >& paramReplacements);
-
- /** compute the cardinality of this datatype */
- Cardinality computeCardinality( std::vector< Type >& processing ) const throw(IllegalArgumentException);
- /** compute whether this datatype is well-founded */
- bool computeWellFounded( std::vector< Type >& processing ) const throw(IllegalArgumentException);
- /** compute ground term */
- Expr computeGroundTerm( Type t, std::vector< Type >& processing, std::map< Type, Expr >& gt ) const throw(IllegalArgumentException);
-public:
- /**
- * Create a new Datatype constructor with the given name for the
- * constructor and the same name (prefixed with "is_") for the
- * tester. The actual constructor and tester (meaning, the Exprs
- * representing operators for these entities) aren't created until
- * resolution time.
- */
- explicit DatatypeConstructor(std::string name);
-
- /**
- * Create a new Datatype constructor with the given name for the
- * constructor and the given name for the tester. The actual
- * constructor and tester aren't created until resolution time.
- */
- DatatypeConstructor(std::string name, std::string tester);
-
- /** set sygus */
- void setSygus( Expr op, Expr let_body, std::vector< Expr >& let_args, unsigned num_let_input_argus );
-
- /**
- * Add an argument (i.e., a data field) of the given name and type
- * to this Datatype constructor. Selector names need not be unique;
- * they are for convenience and pretty-printing only.
- */
- void addArg(std::string selectorName, Type selectorType);
-
- /**
- * Add an argument (i.e., a data field) of the given name to this
- * Datatype constructor that refers to an as-yet-unresolved
- * Datatype (which may be mutually-recursive). Selector names need
- * not be unique; they are for convenience and pretty-printing only.
- */
- void addArg(std::string selectorName, DatatypeUnresolvedType selectorType);
-
- /**
- * Add a self-referential (i.e., a data field) of the given name
- * to this Datatype constructor that refers to the enclosing
- * Datatype. For example, using the familiar "nat" Datatype, to
- * create the "pred" field for "succ" constructor, one uses
- * succ::addArg("pred", DatatypeSelfType())---the actual Type
- * cannot be passed because the Datatype is still under
- * construction. Selector names need not be unique; they are for
- * convenience and pretty-printing only.
- *
- * This is a special case of
- * DatatypeConstructor::addArg(std::string, DatatypeUnresolvedType).
- */
- void addArg(std::string selectorName, DatatypeSelfType);
-
- /** Get the name of this Datatype constructor. */
- std::string getName() const throw();
-
- /**
- * Get the constructor operator of this Datatype constructor. The
- * Datatype must be resolved.
- */
- Expr getConstructor() const;
-
- /**
- * Get the tester operator of this Datatype constructor. The
- * Datatype must be resolved.
- */
- Expr getTester() const;
-
- /** get sygus op */
- Expr getSygusOp() const;
- /** get sygus let body */
- Expr getSygusLetBody() const;
- /** get number of sygus let args */
- unsigned getNumSygusLetArgs() const;
- /** get sygus let arg */
- Expr getSygusLetArg( unsigned i ) const;
- /** get number of let arguments that should be printed as arguments to let */
- unsigned getNumSygusLetInputArgs() const;
- /** is this a sygus identity function */
- bool isSygusIdFunc() const;
-
- /**
- * Get the tester name for this Datatype constructor.
- */
- std::string getTesterName() const throw();
-
- /**
- * Get the number of arguments (so far) of this Datatype constructor.
- */
- inline size_t getNumArgs() const throw();
-
- /**
- * Get the specialized constructor type for a parametric
- * constructor; this call is only permitted after resolution.
- * Given a (concrete) returnType, the constructor's concrete
- * type in this parametric datatype is returned.
- *
- * For instance, if the datatype is list[T], with constructor
- * "cons[T]" of type "T -> list[T] -> list[T]", then calling
- * this function with "list[int]" will return the concrete
- * "cons" constructor type for lists of int---namely,
- * "int -> list[int] -> list[int]".
- */
- Type getSpecializedConstructorType(Type returnType) const;
-
- /**
- * Return the cardinality of this constructor (the product of the
- * cardinalities of its arguments).
- */
- Cardinality getCardinality() const throw(IllegalArgumentException);
-
- /**
- * Return true iff this constructor is finite (it is nullary or
- * each of its argument types are finite). This function can
- * only be called for resolved constructors.
- */
- bool isFinite() const throw(IllegalArgumentException);
-
- /**
- * Returns true iff this Datatype constructor has already been
- * resolved.
- */
- inline bool isResolved() const throw();
-
- /** Get the beginning iterator over DatatypeConstructor args. */
- inline iterator begin() throw();
- /** Get the ending iterator over DatatypeConstructor args. */
- inline iterator end() throw();
- /** Get the beginning const_iterator over DatatypeConstructor args. */
- inline const_iterator begin() const throw();
- /** Get the ending const_iterator over DatatypeConstructor args. */
- inline const_iterator end() const throw();
-
- /** Get the ith DatatypeConstructor arg. */
- const DatatypeConstructorArg& operator[](size_t index) const;
-
- /**
- * Get the DatatypeConstructor arg named. This is a linear search
- * through the arguments, so in the case of multiple,
- * similarly-named arguments, the first is returned.
- */
- const DatatypeConstructorArg& operator[](std::string name) const;
-
- /**
- * Get the selector named. This is a linear search
- * through the arguments, so in the case of multiple,
- * similarly-named arguments, the selector for the first
- * is returned.
- */
- Expr getSelector(std::string name) const;
-
- /**
- * Get whether this datatype involves an external type. If so,
- * then we will pose additional requirements for sharing.
- */
- bool involvesExternalType() const;
-
-};/* class DatatypeConstructor */
-
-/**
- * The representation of an inductive datatype.
- *
- * This is far more complicated than it first seems. Consider this
- * datatype definition:
- *
- * DATATYPE nat =
- * succ(pred: nat)
- * | zero
- * END;
- *
- * You cannot define "nat" until you have a Type for it, but you
- * cannot have a Type for it until you fill in the type of the "pred"
- * selector, which needs the Type. So we have a chicken-and-egg
- * problem. It's even more complicated when we have mutual recursion
- * between datatypes, since the CVC presentation language does not
- * require forward-declarations. Here, we define trees of lists that
- * contain trees of lists (etc):
- *
- * DATATYPE
- * tree = node(left: tree, right: tree) | leaf(list),
- * list = cons(car: tree, cdr: list) | nil
- * END;
- *
- * Note that while parsing the "tree" definition, we have to take it
- * on faith that "list" is a valid type. We build Datatype objects to
- * describe "tree" and "list", and their constructors and constructor
- * arguments, but leave any unknown types (including self-references)
- * in an "unresolved" state. After parsing the whole DATATYPE block,
- * we create a DatatypeType through
- * ExprManager::mkMutualDatatypeTypes(). The ExprManager creates a
- * DatatypeType for each, but before "releasing" this type into the
- * wild, it does a round of in-place "resolution" on each Datatype by
- * calling Datatype::resolve() with a map of string -> DatatypeType to
- * allow the datatype to construct the necessary testers and
- * selectors.
- *
- * An additional point to make is that we want to ease the burden on
- * both the parser AND the users of the CVC4 API, so this class takes
- * on the task of generating its own selectors and testers, for
- * instance. That means that, after reifying the Datatype with the
- * ExprManager, the parser needs to go through the (now-resolved)
- * Datatype and request the constructor, selector, and tester terms.
- * See src/parser/parser.cpp for how this is done. For API usage
- * ideas, see test/unit/util/datatype_black.h.
- *
- * Datatypes may also be defined parametrically, such as this example:
- *
- * DATATYPE
- * list[T] = cons(car : T, cdr : list[T]) | null,
- * tree = node(children : list[tree]) | leaf
- * END;
- *
- * Here, the definition of the parametric datatype list, where T is a type variable.
- * In other words, this defines a family of types list[C] where C is any concrete
- * type. Datatypes can be parameterized over multiple type variables using the
- * syntax sym[ T1, ..., Tn ] = ...,
- *
- */
-class CVC4_PUBLIC Datatype {
- friend class DatatypeConstructor;
-public:
- /**
- * Get the datatype of a constructor, selector, or tester operator.
- */
- static const Datatype& datatypeOf(Expr item) CVC4_PUBLIC;
-
- /**
- * Get the index of a constructor or tester in its datatype, or the
- * index of a selector in its constructor. (Zero is always the
- * first index.)
- */
- static size_t indexOf(Expr item) CVC4_PUBLIC;
-
- /**
- * Get the index of constructor corresponding to selector. (Zero is
- * always the first index.)
- */
- static size_t cindexOf(Expr item) CVC4_PUBLIC;
-
- /** The type for iterators over constructors. */
- typedef DatatypeConstructorIterator iterator;
- /** The (const) type for iterators over constructors. */
- typedef DatatypeConstructorIterator const_iterator;
-
-private:
- std::string d_name;
- std::vector<Type> d_params;
- bool d_isCo;
- std::vector<DatatypeConstructor> d_constructors;
- bool d_resolved;
- Type d_self;
- bool d_involvesExt;
- /** information for sygus */
- Type d_sygus_type;
- Expr d_sygus_bvl;
- bool d_sygus_allow_const;
- bool d_sygus_allow_all;
-
- // "mutable" because computing the cardinality can be expensive,
- // and so it's computed just once, on demand---this is the cache
- mutable Cardinality d_card;
-
- // is this type a recursive singleton type
- mutable int d_card_rec_singleton;
- // if d_card_rec_singleton is true,
- // infinite cardinality depends on at least one of the following uninterpreted sorts having cardinality > 1
- mutable std::vector< Type > d_card_u_assume;
- // is this well-founded
- mutable int d_well_founded;
- // ground term for this datatype
- mutable std::map< Type, Expr > d_ground_term;
-
- /**
- * Datatypes refer to themselves, recursively, and we have a
- * chicken-and-egg problem. The DatatypeType around the Datatype
- * cannot exist until the Datatype is finalized, and the Datatype
- * cannot refer to the DatatypeType representing itself until it
- * exists. resolve() is called by the ExprManager when a Type is
- * ultimately requested of the Datatype specification (that is, when
- * ExprManager::mkDatatypeType() or ExprManager::mkMutualDatatypeTypes()
- * is called). Has the effect of freezing the object, too; that is,
- * addConstructor() will fail after a call to resolve().
- *
- * The basic goal of resolution is to assign constructors, selectors,
- * and testers. To do this, any UnresolvedType/SelfType references
- * must be cleared up. This is the purpose of the "resolutions" map;
- * it includes any mutually-recursive datatypes that are currently
- * under resolution. The four vectors come in two pairs (so, really
- * they are two maps). placeholders->replacements give type variables
- * that should be resolved in the case of parametric datatypes.
- *
- * @param em the ExprManager at play
- * @param resolutions a map of strings to DatatypeTypes currently under resolution
- * @param placeholders the types in these Datatypes under resolution that must be replaced
- * @param replacements the corresponding replacements
- * @param paramTypes the sort constructors in these Datatypes under resolution that must be replaced
- * @param paramReplacements the corresponding (parametric) DatatypeTypes
- */
- void resolve(ExprManager* em,
- const std::map<std::string, DatatypeType>& resolutions,
- const std::vector<Type>& placeholders,
- const std::vector<Type>& replacements,
- const std::vector< SortConstructorType >& paramTypes,
- const std::vector< DatatypeType >& paramReplacements)
- throw(IllegalArgumentException, DatatypeResolutionException);
- friend class ExprManager;// for access to resolve()
-
- /** compute the cardinality of this datatype */
- Cardinality computeCardinality( std::vector< Type >& processing ) const throw(IllegalArgumentException);
- /** compute whether this datatype is a recursive singleton */
- bool computeCardinalityRecSingleton( std::vector< Type >& processing, std::vector< Type >& u_assume ) const throw(IllegalArgumentException);
- /** compute whether this datatype is well-founded */
- bool computeWellFounded( std::vector< Type >& processing ) const throw(IllegalArgumentException);
- /** compute ground term */
- Expr computeGroundTerm( Type t, std::vector< Type >& processing ) const throw(IllegalArgumentException);
-public:
-
- /** Create a new Datatype of the given name. */
- inline explicit Datatype(std::string name, bool isCo = false);
-
- /**
- * Create a new Datatype of the given name, with the given
- * parameterization.
- */
- inline Datatype(std::string name, const std::vector<Type>& params, bool isCo = false);
-
- /**
- * Add a constructor to this Datatype. Constructor names need not
- * be unique; they are for convenience and pretty-printing only.
- */
- void addConstructor(const DatatypeConstructor& c);
-
- /** set the sygus information of this datatype
- * st : the builtin type for this grammar
- * bvl : the list of arguments for the synth-fun
- * allow_const : whether all constants are (implicitly) included in the grammar
- */
- void setSygus( Type st, Expr bvl, bool allow_const, bool allow_all );
-
- /** Get the name of this Datatype. */
- inline std::string getName() const throw();
-
- /** Get the number of constructors (so far) for this Datatype. */
- inline size_t getNumConstructors() const throw();
-
- /** Is this datatype parametric? */
- inline bool isParametric() const throw();
-
- /** Get the nubmer of type parameters */
- inline size_t getNumParameters() const throw();
-
- /** Get parameter */
- inline Type getParameter( unsigned int i ) const;
-
- /** Get parameters */
- inline std::vector<Type> getParameters() const;
-
- /** is this a co-datatype? */
- inline bool isCodatatype() const;
-
- /** is this a sygus datatype? */
- inline bool isSygus() const;
-
- /**
- * Return the cardinality of this datatype (the sum of the
- * cardinalities of its constructors). The Datatype must be
- * resolved.
- */
- Cardinality getCardinality() const throw(IllegalArgumentException);
-
- /**
- * Return true iff this Datatype is finite (all constructors are
- * finite, i.e., there are finitely many ground terms). If the
- * datatype is not well-founded, this function returns false. The
- * Datatype must be resolved or an exception is thrown.
- */
- bool isFinite() const throw(IllegalArgumentException);
-
- /**
- * Return true iff this datatype is well-founded (there exist ground
- * terms). The Datatype must be resolved or an exception is thrown.
- */
- bool isWellFounded() const throw(IllegalArgumentException);
-
- /**
- * Return true iff this datatype is a recursive singleton
- */
- bool isRecursiveSingleton() const throw(IllegalArgumentException);
-
-
- /** get number of recursive singleton argument types */
- unsigned getNumRecursiveSingletonArgTypes() const throw(IllegalArgumentException);
- Type getRecursiveSingletonArgType( unsigned i ) const throw(IllegalArgumentException);
-
- /**
- * Construct and return a ground term of this Datatype. The
- * Datatype must be both resolved and well-founded, or else an
- * exception is thrown.
- */
- Expr mkGroundTerm( Type t ) const throw(IllegalArgumentException);
-
- /**
- * Get the DatatypeType associated to this Datatype. Can only be
- * called post-resolution.
- */
- DatatypeType getDatatypeType() const throw(IllegalArgumentException);
-
- /**
- * Get the DatatypeType associated to this (parameterized) Datatype. Can only be
- * called post-resolution.
- */
- DatatypeType getDatatypeType(const std::vector<Type>& params) const throw(IllegalArgumentException);
-
- /**
- * Return true iff the two Datatypes are the same.
- *
- * We need == for mkConst(Datatype) to properly work---since if the
- * Datatype Expr requested is the same as an already-existing one,
- * we need to return that one. For that, we have a hash and
- * operator==. We provide != for symmetry. We don't provide
- * operator<() etc. because given two Datatype Exprs, you could
- * simply compare those rather than the (bare) Datatypes. This
- * means, though, that Datatype cannot be stored in a sorted list or
- * RB tree directly, so maybe we can consider adding these
- * comparison operators later on.
- */
- bool operator==(const Datatype& other) const throw();
- /** Return true iff the two Datatypes are not the same. */
- inline bool operator!=(const Datatype& other) const throw();
-
- /** Return true iff this Datatype has already been resolved. */
- inline bool isResolved() const throw();
-
- /** Get the beginning iterator over DatatypeConstructors. */
- inline iterator begin() throw();
- /** Get the ending iterator over DatatypeConstructors. */
- inline iterator end() throw();
- /** Get the beginning const_iterator over DatatypeConstructors. */
- inline const_iterator begin() const throw();
- /** Get the ending const_iterator over DatatypeConstructors. */
- inline const_iterator end() const throw();
-
- /** Get the ith DatatypeConstructor. */
- const DatatypeConstructor& operator[](size_t index) const;
-
- /**
- * Get the DatatypeConstructor named. This is a linear search
- * through the constructors, so in the case of multiple,
- * similarly-named constructors, the first is returned.
- */
- const DatatypeConstructor& operator[](std::string name) const;
-
- /**
- * Get the constructor operator for the named constructor.
- * This is a linear search through the constructors, so in
- * the case of multiple, similarly-named constructors, the
- * first is returned.
- *
- * This Datatype must be resolved.
- */
- Expr getConstructor(std::string name) const;
-
- /** get sygus type */
- Type getSygusType() const;
- /** get sygus var list */
- Expr getSygusVarList() const;
- /** does it allow constants */
- bool getSygusAllowConst() const;
- /** does it allow constants */
- bool getSygusAllowAll() const;
-
- /**
- * Get whether this datatype involves an external type. If so,
- * then we will pose additional requirements for sharing.
- */
- bool involvesExternalType() const;
-
-};/* class Datatype */
-
-/**
- * A hash function for Datatypes. Needed to store them in hash sets
- * and hash maps.
- */
-struct CVC4_PUBLIC DatatypeHashFunction {
- inline size_t operator()(const Datatype& dt) const {
- return StringHashFunction()(dt.getName());
- }
- inline size_t operator()(const Datatype* dt) const {
- return StringHashFunction()(dt->getName());
- }
- inline size_t operator()(const DatatypeConstructor& dtc) const {
- return StringHashFunction()(dtc.getName());
- }
- inline size_t operator()(const DatatypeConstructor* dtc) const {
- return StringHashFunction()(dtc->getName());
- }
-};/* struct DatatypeHashFunction */
-
-// FUNCTION DECLARATIONS FOR OUTPUT STREAMS
-
-std::ostream& operator<<(std::ostream& os, const Datatype& dt) CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream& os, const DatatypeConstructor& ctor) CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream& os, const DatatypeConstructorArg& arg) CVC4_PUBLIC;
-
-// INLINE FUNCTIONS
-
-inline DatatypeResolutionException::DatatypeResolutionException(std::string msg) :
- Exception(msg) {
-}
-
-inline DatatypeUnresolvedType::DatatypeUnresolvedType(std::string name) :
- d_name(name) {
-}
-
-inline std::string DatatypeUnresolvedType::getName() const throw() {
- return d_name;
-}
-
-inline Datatype::Datatype(std::string name, bool isCo) :
- d_name(name),
- d_params(),
- d_isCo(isCo),
- d_constructors(),
- d_resolved(false),
- d_self(),
- d_involvesExt(false),
- d_card(CardinalityUnknown()),
- d_card_rec_singleton(0),
- d_well_founded(0) {
-}
-
-inline Datatype::Datatype(std::string name, const std::vector<Type>& params, bool isCo) :
- d_name(name),
- d_params(params),
- d_isCo(isCo),
- d_constructors(),
- d_resolved(false),
- d_self(),
- d_involvesExt(false),
- d_card(CardinalityUnknown()),
- d_card_rec_singleton(0),
- d_well_founded(0) {
-}
-
-inline std::string Datatype::getName() const throw() {
- return d_name;
-}
-
-inline size_t Datatype::getNumConstructors() const throw() {
- return d_constructors.size();
-}
-
-inline bool Datatype::isParametric() const throw() {
- return d_params.size() > 0;
-}
-
-inline size_t Datatype::getNumParameters() const throw() {
- return d_params.size();
-}
-
-inline Type Datatype::getParameter( unsigned int i ) const {
- CheckArgument(isParametric(), this, "cannot get type parameter of a non-parametric datatype");
- CheckArgument(i < d_params.size(), i, "type parameter index out of range for datatype");
- return d_params[i];
-}
-
-inline std::vector<Type> Datatype::getParameters() const {
- CheckArgument(isParametric(), this, "cannot get type parameters of a non-parametric datatype");
- return d_params;
-}
-
-inline bool Datatype::isCodatatype() const {
- return d_isCo;
-}
-
-inline bool Datatype::isSygus() const {
- return !d_sygus_type.isNull();
-}
-
-inline bool Datatype::operator!=(const Datatype& other) const throw() {
- return !(*this == other);
-}
-
-inline bool Datatype::isResolved() const throw() {
- return d_resolved;
-}
-
-inline Datatype::iterator Datatype::begin() throw() {
- return iterator(d_constructors, true);
-}
-
-inline Datatype::iterator Datatype::end() throw() {
- return iterator(d_constructors, false);
-}
-
-inline Datatype::const_iterator Datatype::begin() const throw() {
- return const_iterator(d_constructors, true);
-}
-
-inline Datatype::const_iterator Datatype::end() const throw() {
- return const_iterator(d_constructors, false);
-}
-
-inline bool DatatypeConstructor::isResolved() const throw() {
- return !d_tester.isNull();
-}
-
-inline size_t DatatypeConstructor::getNumArgs() const throw() {
- return d_args.size();
-}
-
-inline bool DatatypeConstructorArg::isResolved() const throw() {
- // We could just write:
- //
- // return !d_selector.isNull() && d_selector.getType().isSelector();
- //
- // HOWEVER, this causes problems in ExprManager tear-down, because
- // the attributes are removed before the pool is purged. When the
- // pool is purged, this triggers an equality test between Datatypes,
- // and this triggers a call to isResolved(), which breaks because
- // d_selector has no type after attributes are stripped.
- //
- // This problem, coupled with the fact that this function is called
- // _often_, means we should just use a boolean flag.
- //
- return d_resolved;
-}
-
-inline DatatypeConstructor::iterator DatatypeConstructor::begin() throw() {
- return iterator(d_args, true);
-}
-
-inline DatatypeConstructor::iterator DatatypeConstructor::end() throw() {
- return iterator(d_args, false);
-}
-
-inline DatatypeConstructor::const_iterator DatatypeConstructor::begin() const throw() {
- return const_iterator(d_args, true);
-}
-
-inline DatatypeConstructor::const_iterator DatatypeConstructor::end() const throw() {
- return const_iterator(d_args, false);
-}
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__DATATYPE_H */
+++ /dev/null
-%{
-#include "util/datatype.h"
-
-#ifdef SWIGJAVA
-
-#include "bindings/java_iterator_adapter.h"
-#include "bindings/java_stream_adapters.h"
-
-#endif /* SWIGJAVA */
-%}
-
-%extend std::vector< CVC4::Datatype > {
- /* These member functions have slightly different signatures in
- * different swig language packages. The underlying issue is that
- * DatatypeConstructor doesn't have a default constructor */
-#if defined(SWIGOCAML) || defined(SWIGPERL) || defined(SWIGTCL)
- %ignore vector(unsigned int size = 0);
- %ignore set( int i, const CVC4::Datatype &x );
- %ignore to_array();
-#endif /* SWIGOCAML || SWIGPERL || SWIGTCL */
- %ignore vector(size_type);// java/python/perl/others?
- %ignore resize(size_type);// java/python/perl/others?
- %ignore set(int i, const CVC4::Datatype& x);
- %ignore to_array();
-};
-%template(vectorDatatype) std::vector< CVC4::Datatype >;
-
-%extend std::vector< CVC4::DatatypeConstructor > {
- /* These member functions have slightly different signatures in
- * different swig language packages. The underlying issue is that
- * DatatypeConstructor doesn't have a default constructor */
-#if defined(SWIGOCAML) || defined(SWIGPERL) || defined(SWIGTCL)
- %ignore vector(unsigned int size = 0);
- %ignore set( int i, const CVC4::DatatypeConstructor &x );
- %ignore to_array();
-#endif /* SWIGOCAML || SWIGPERL || SWIGTCL */
- %ignore vector(size_type);// java/python/perl/others?
- %ignore resize(size_type);// java/python/perl/others?
- %ignore set(int i, const CVC4::Datatype::Constructor& x);
- %ignore to_array();
-};
-//%template(vectorDatatypeConstructor) std::vector< CVC4::DatatypeConstructor >;
-
-%rename(equals) CVC4::Datatype::operator==(const Datatype&) const;
-%ignore CVC4::Datatype::operator!=(const Datatype&) const;
-
-%ignore CVC4::Datatype::begin();
-%ignore CVC4::Datatype::end();
-%ignore CVC4::Datatype::begin() const;
-%ignore CVC4::Datatype::end() const;
-
-%rename(get) CVC4::Datatype::operator[](size_t) const;
-%rename(get) CVC4::Datatype::operator[](std::string) const;
-
-%rename(apply) CVC4::DatatypeHashFunction::operator()(const Datatype&) const;
-%ignore CVC4::DatatypeHashFunction::operator()(const Datatype*) const;
-%rename(apply) CVC4::DatatypeHashFunction::operator()(const DatatypeConstructor&) const;
-%ignore CVC4::DatatypeHashFunction::operator()(const DatatypeConstructor*) const;
-
-%ignore CVC4::DatatypeConstructor::begin();
-%ignore CVC4::DatatypeConstructor::end();
-%ignore CVC4::DatatypeConstructor::begin() const;
-%ignore CVC4::DatatypeConstructor::end() const;
-
-%rename(get) CVC4::DatatypeConstructor::operator[](size_t) const;
-%rename(get) CVC4::DatatypeConstructor::operator[](std::string) const;
-
-%ignore CVC4::operator<<(std::ostream&, const Datatype&);
-%ignore CVC4::operator<<(std::ostream&, const DatatypeConstructor&);
-%ignore CVC4::operator<<(std::ostream&, const DatatypeConstructorArg&);
-
-%ignore CVC4::DatatypeConstructorIterator;
-%ignore CVC4::DatatypeConstructorArgIterator;
-
-%feature("valuewrapper") CVC4::DatatypeUnresolvedType;
-%feature("valuewrapper") CVC4::DatatypeConstructor;
-
-#ifdef SWIGJAVA
-
-// Instead of Datatype::begin() and end(), create an
-// iterator() method on the Java side that returns a Java-style
-// Iterator.
-%extend CVC4::Datatype {
- CVC4::JavaIteratorAdapter<CVC4::Datatype> iterator() {
- return CVC4::JavaIteratorAdapter<CVC4::Datatype>(*$self);
- }
-
- std::string toString() const {
- std::stringstream ss;
- ss << *$self;
- return ss.str();
- }
-}
-%extend CVC4::DatatypeConstructor {
- CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor> iterator() {
- return CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor>(*$self);
- }
-
- std::string toString() const {
- std::stringstream ss;
- ss << *$self;
- return ss.str();
- }
-}
-%extend CVC4::DatatypeConstructorArg {
- std::string toString() const {
- std::stringstream ss;
- ss << *$self;
- return ss.str();
- }
-}
-
-// Datatype is "iterable" on the Java side
-%typemap(javainterfaces) CVC4::Datatype "java.lang.Iterable<DatatypeConstructor>";
-%typemap(javainterfaces) CVC4::DatatypeConstructor "java.lang.Iterable<DatatypeConstructorArg>";
-
-// the JavaIteratorAdapter should not be public, and implements Iterator
-%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::Datatype> "class";
-%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor> "class";
-%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::Datatype> "java.util.Iterator<DatatypeConstructor>";
-%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor> "java.util.Iterator<DatatypeConstructorArg>";
-// add some functions to the Java side (do it here because there's no way to do these in C++)
-%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::Datatype> "
- public void remove() {
- throw new java.lang.UnsupportedOperationException();
- }
-
- public DatatypeConstructor next() {
- if(hasNext()) {
- return getNext();
- } else {
- throw new java.util.NoSuchElementException();
- }
- }
-"
-%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor> "
- public void remove() {
- throw new java.lang.UnsupportedOperationException();
- }
-
- public DatatypeConstructorArg next() {
- if(hasNext()) {
- return getNext();
- } else {
- throw new java.util.NoSuchElementException();
- }
- }
-"
-// getNext() just allows C++ iterator access from Java-side next(), make it private
-%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::Datatype>::getNext() "private";
-%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor>::getNext() "private";
-
-// map the types appropriately.
-%typemap(jni) CVC4::Datatype::iterator::value_type "jobject";
-%typemap(jtype) CVC4::Datatype::iterator::value_type "edu.nyu.acsys.CVC4.DatatypeConstructor";
-%typemap(jstype) CVC4::Datatype::iterator::value_type "edu.nyu.acsys.CVC4.DatatypeConstructor";
-%typemap(javaout) CVC4::Datatype::iterator::value_type { return $jnicall; }
-%typemap(jni) CVC4::DatatypeConstructor::iterator::value_type "jobject";
-%typemap(jtype) CVC4::DatatypeConstructor::iterator::value_type "edu.nyu.acsys.CVC4.DatatypeConstructorArg";
-%typemap(jstype) CVC4::DatatypeConstructor::iterator::value_type "edu.nyu.acsys.CVC4.DatatypeConstructorArg";
-%typemap(javaout) CVC4::DatatypeConstructor::iterator::value_type { return $jnicall; }
-
-#endif /* SWIGJAVA */
-
-%include "util/datatype.h"
-
-#ifdef SWIGJAVA
-
-%include "bindings/java_iterator_adapter.h"
-%include "bindings/java_stream_adapters.h"
-
-%template(JavaIteratorAdapter_Datatype) CVC4::JavaIteratorAdapter<CVC4::Datatype>;
-%template(JavaIteratorAdapter_DatatypeConstructor) CVC4::JavaIteratorAdapter<CVC4::DatatypeConstructor>;
-
-#endif /* SWIGJAVA */
#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 {
+++ /dev/null
-/********************* */
-/*! \file didyoumean.cpp
- ** \verbatim
- ** Original author: Kshitij Bansal
- ** 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 did-you-mean style suggestions
- **
- ** ``What do you mean? I don't understand.'' An attempt to be more
- ** helpful than that. Similar to one in git.
- **
- ** There are no dependencies on CVC4 (except namespace).
- **/
-
-#include "didyoumean.h"
-#include <iostream>
-#include <sstream>
-using namespace std;
-using namespace CVC4;
-
-vector<string> DidYouMean::getMatch(string input) {
- /** Magic numbers */
- const int similarityThreshold = 7;
- const unsigned numMatchesThreshold = 10;
-
- set< pair<int, string> > scores;
- vector<string> ret;
- for(typeof(d_words.begin()) it = d_words.begin(); it != d_words.end(); ++it) {
- string s = (*it);
- if( s == input ) {
- // if input matches AS-IS just return that
- ret.push_back(s);
- return ret;
- }
- int score;
- if(s.compare(0, input.size(), input) == 0) {
- score = 0;
- } else {
- score = editDistance(input, s) + 1;
- }
- scores.insert( make_pair(score, s) );
- }
- int min_score = scores.begin()->first;
- for(typeof(scores.begin()) i = scores.begin();
- i != scores.end(); ++i) {
-
- // add if score is overall not too big, and also not much close to
- // the score of the best suggestion
- if(i->first < similarityThreshold && i->first <= min_score + 1) {
- ret.push_back(i->second);
-#ifdef DIDYOUMEAN_DEBUG
- cout << i->second << ": " << i->first << std::endl;
-#endif
- }
- }
- if(ret.size() > numMatchesThreshold ) ret.resize(numMatchesThreshold);;
- return ret;
-}
-
-
-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;
- const int deleteCost = 3;
- const int switchCaseCost = 0;
-
- int len1 = a.size();
- int len2 = b.size();
-
- int* C[3];
- int ii;
- for (ii = 0; ii < 3; ++ii) {
- C[ii] = new int[len2+1];
- }
- // int C[3][len2+1]; // cost
-
- for(int j = 0; j <= len2; ++j) {
- C[0][j] = j * addCost;
- }
-
- for(int i = 1; i <= len1; ++i) {
-
- int cur = i%3;
- int prv = (i+2)%3;
- int pr2 = (i+1)%3;
-
- C[cur][0] = i * deleteCost;
-
- for(int j = 1; j <= len2; ++j) {
-
- C[cur][j] = 100000000; // INF
-
- if(a[i-1] == b[j-1]) {
- // match
- C[cur][j] = std::min(C[cur][j], C[prv][j-1]);
- } else if(tolower(a[i-1]) == tolower(b[j-1])){
- // switch case
- C[cur][j] = std::min(C[cur][j], C[prv][j-1] + switchCaseCost);
- } else {
- // substitute
- C[cur][j] = std::min(C[cur][j], C[prv][j-1] + substituteCost);
- }
-
- // swap
- if(i >= 2 && j >= 2 && a[i-1] == b[j-2] && a[i-2] == b[j-1]) {
- C[cur][j] = std::min(C[cur][j], C[pr2][j-2] + swapCost);
- }
-
- // add
- C[cur][j] = std::min(C[cur][j], C[cur][j-1] + addCost);
-
- // 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
- }
-
- }
- int result = C[len1%3][len2];
- for (ii = 0; ii < 3; ++ii) {
- delete [] C[ii];
- }
- return result;
-}
-
-string DidYouMean::getMatchAsString(string input, int prefixNewLines, int suffixNewLines) {
- vector<string> matches = getMatch(input);
- ostringstream oss;
- if(matches.size() > 0) {
- while(prefixNewLines --> 0) { oss << endl; }
- if(matches.size() == 1) {
- oss << "Did you mean this?";
- } else {
- oss << "Did you mean any of these?";
- }
- for(unsigned i = 0; i < matches.size(); ++i) {
- oss << "\n " << matches[i];
- }
- while(suffixNewLines --> 0) { oss << endl; }
- }
- return oss.str();
-}
+++ /dev/null
-/********************* */
-/*! \file didyoumean.h
- ** \verbatim
- ** Original author: Kshitij Bansal
- ** 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 did-you-mean style suggestions.
- **
- ** ``What do you mean? I don't understand.'' An attempt to be more
- ** helpful than that. Similar to one in git.
- **
- ** There are no dependencies on CVC4 (except namespace).
- **/
-
-#pragma once
-
-#include <vector>
-#include <set>
-#include <string>
-
-namespace CVC4 {
-
-class DidYouMean {
- typedef std::set<std::string> Words;
- Words d_words;
-
-public:
- DidYouMean() {}
- ~DidYouMean() {}
-
- DidYouMean(Words words) : d_words(words) {}
-
- void addWord(std::string word) {
- d_words.insert(word);
- }
-
- std::vector<std::string> getMatch(std::string input);
-
- /**
- * This is provided to make it easier to ensure consistency of
- * output. Returned string is empty if there are no matches.
- */
- std::string getMatchAsString(std::string input, int prefixNewLines = 2, int suffixNewLines = 0);
-private:
- int editDistance(const std::string& a, const std::string& b);
-};
-
-}/*CVC4 namespace*/
+++ /dev/null
-/********************* */
-/*! \file didyoumean_test.cpp
- ** \verbatim
- ** Original author: Kshitij Bansal
- ** 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
- **/
-
-// Compile: g++ didyoumean_test.cpp didyoumean.cpp
-// For debug compile with -DDIDYOUMEAN_DEBUG or -DDIDYOUMEAN_DEBUG1 or both
-
-#include "didyoumean.h"
-#include <iostream>
-#include <boost/foreach.hpp>
-using namespace std;
-using namespace CVC4;
-
-set<string> getDebugTags();
-set<string> getOptionStrings();
-
-int main()
-{
- string a, b;
-
- cin >> a;
- cout << "Matches with debug tags:" << endl;
- vector<string> ret = DidYouMean(getDebugTags()).getMatch(a);
- BOOST_FOREACH(string s, ret) cout << s << endl;
- cout << "Matches with option strings:" << endl;
- ret = DidYouMean(getOptionStrings()).getMatch(a);
- BOOST_FOREACH(string s, ret) cout << s << endl;
-}
-
-set<string> getDebugTags()
-{
- set<string> a;
- a.insert("CDInsertHashMap");
- a.insert("CDTrailHashMap");
- a.insert("TrailHashMap");
- a.insert("approx");
- a.insert("approx::");
- a.insert("approx::branch");
- a.insert("approx::checkCutOnPad");
- a.insert("approx::constraint");
- a.insert("approx::gmi");
- a.insert("approx::gmiCut");
- a.insert("approx::guessIsConstructable");
- a.insert("approx::lemmas");
- a.insert("approx::mir");
- a.insert("approx::mirCut");
- a.insert("approx::nodelog");
- a.insert("approx::replayAssert");
- a.insert("approx::replayLogRec");
- a.insert("approx::soi");
- a.insert("approx::solveMIP");
- a.insert("approx::sumConstraints");
- a.insert("approx::vars");
- a.insert("arith");
- a.insert("arith::addSharedTerm");
- a.insert("arith::approx::cuts");
- a.insert("arith::arithvar");
- a.insert("arith::asVectors");
- a.insert("arith::bt");
- a.insert("arith::collectModelInfo");
- a.insert("arith::conflict");
- a.insert("arith::congruenceManager");
- a.insert("arith::congruences");
- a.insert("arith::consistency");
- a.insert("arith::consistency::comitonconflict");
- a.insert("arith::consistency::final");
- a.insert("arith::consistency::initial");
- a.insert("arith::constraint");
- a.insert("arith::dio");
- a.insert("arith::dio::ex");
- a.insert("arith::dio::max");
- a.insert("arith::div");
- a.insert("arith::dual");
- a.insert("arith::ems");
- a.insert("arith::eq");
- a.insert("arith::error::mem");
- a.insert("arith::explain");
- a.insert("arith::explainNonbasics");
- a.insert("arith::findModel");
- a.insert("arith::focus");
- a.insert("arith::hasIntegerModel");
- a.insert("arith::importSolution");
- a.insert("arith::ite");
- a.insert("arith::ite::red");
- a.insert("arith::learned");
- a.insert("arith::lemma");
- a.insert("arith::nf");
- a.insert("arith::oldprop");
- a.insert("arith::pivot");
- a.insert("arith::preprocess");
- a.insert("arith::preregister");
- a.insert("arith::presolve");
- a.insert("arith::print_assertions");
- a.insert("arith::print_model");
- a.insert("arith::prop");
- a.insert("arith::resolveOutPropagated");
- a.insert("arith::restart");
- a.insert("arith::rewriter");
- a.insert("arith::selectPrimalUpdate");
- a.insert("arith::simplex:row");
- a.insert("arith::solveInteger");
- a.insert("arith::static");
- a.insert("arith::subsumption");
- a.insert("arith::tracking");
- a.insert("arith::tracking::mid");
- a.insert("arith::tracking::post");
- a.insert("arith::tracking::pre");
- a.insert("arith::unate");
- a.insert("arith::unate::conf");
- a.insert("arith::update");
- a.insert("arith::update::select");
- a.insert("arith::value");
- a.insert("array-pf");
- a.insert("array-types");
- a.insert("arrays");
- a.insert("arrays-model-based");
- a.insert("arrays::propagate");
- a.insert("arrays::sharing");
- a.insert("attrgc");
- a.insert("basicsAtBounds");
- a.insert("bitvector");
- a.insert("bitvector-bb");
- a.insert("bitvector-bitblast");
- a.insert("bitvector-expandDefinition");
- a.insert("bitvector-model");
- a.insert("bitvector-preregister");
- a.insert("bitvector-rewrite");
- a.insert("bitvector::bitblaster");
- a.insert("bitvector::core");
- a.insert("bitvector::explain");
- a.insert("bitvector::propagate");
- a.insert("bitvector::sharing");
- a.insert("bool-flatten");
- a.insert("bool-ite");
- a.insert("boolean-terms");
- a.insert("bt");
- a.insert("builder");
- a.insert("bv-bitblast");
- a.insert("bv-core");
- a.insert("bv-core-model");
- a.insert("bv-inequality");
- a.insert("bv-inequality-explain");
- a.insert("bv-inequality-internal");
- a.insert("bv-rewrite");
- a.insert("bv-slicer");
- a.insert("bv-slicer-eq");
- a.insert("bv-slicer-uf");
- a.insert("bv-subtheory-inequality");
- a.insert("bv-to-bool");
- a.insert("bva");
- a.insert("bvminisat");
- a.insert("bvminisat::explain");
- a.insert("bvminisat::search");
- a.insert("cbqi");
- a.insert("cbqi-debug");
- a.insert("cbqi-prop-as-dec");
- a.insert("cd_set_collection");
- a.insert("cdlist");
- a.insert("cdlist:cmm");
- a.insert("cdqueue");
- a.insert("check-inst");
- a.insert("check-model::rep-checking");
- a.insert("circuit-prop");
- a.insert("cnf");
- a.insert("constructInfeasiblityFunction");
- a.insert("context");
- a.insert("current");
- a.insert("datatypes");
- a.insert("datatypes-cycle-check");
- a.insert("datatypes-cycles");
- a.insert("datatypes-cycles-find");
- a.insert("datatypes-debug");
- a.insert("datatypes-explain");
- a.insert("datatypes-gt");
- a.insert("datatypes-inst");
- a.insert("datatypes-labels");
- a.insert("datatypes-output");
- a.insert("datatypes-parametric");
- a.insert("datatypes-prereg");
- a.insert("datatypes-split");
- a.insert("decision");
- a.insert("decision::jh");
- a.insert("determineArithVar");
- a.insert("diamonds");
- a.insert("dio::push");
- a.insert("dt");
- a.insert("dt-enum");
- a.insert("dt-warn");
- a.insert("dt::propagate");
- a.insert("dualLike");
- a.insert("effortlevel");
- a.insert("ensureLiteral");
- a.insert("eq");
- a.insert("equality");
- a.insert("equality::backtrack");
- a.insert("equality::disequality");
- a.insert("equality::evaluation");
- a.insert("equality::graph");
- a.insert("equality::internal");
- a.insert("equality::trigger");
- a.insert("equalsConstant");
- a.insert("error");
- a.insert("estimateWithCFE");
- a.insert("expand");
- a.insert("export");
- a.insert("flipdec");
- a.insert("fmc-entry-trie");
- a.insert("fmc-interval-model-debug");
- a.insert("fmf-card-debug");
- a.insert("fmf-eval-debug");
- a.insert("fmf-eval-debug2");
- a.insert("fmf-exit");
- a.insert("fmf-index-order");
- a.insert("fmf-model-complete");
- a.insert("fmf-model-cons");
- a.insert("fmf-model-cons-debug");
- a.insert("fmf-model-eval");
- a.insert("fmf-model-prefs");
- a.insert("fmf-model-req");
- a.insert("focusDownToJust");
- a.insert("focusDownToLastHalf");
- a.insert("foo");
- a.insert("gaussianElimConstructTableRow");
- a.insert("gc");
- a.insert("gc:leaks");
- a.insert("getBestImpliedBound");
- a.insert("getCeiling");
- a.insert("getNewDomainValue");
- a.insert("getPropagatedLiterals");
- a.insert("getType");
- a.insert("glpk::loadVB");
- a.insert("guessCoefficientsConstructTableRow");
- a.insert("guessIsConstructable");
- a.insert("handleBorders");
- a.insert("includeBoundUpdate");
- a.insert("inst");
- a.insert("inst-engine");
- a.insert("inst-engine-ctrl");
- a.insert("inst-engine-debug");
- a.insert("inst-engine-phase-req");
- a.insert("inst-engine-stuck");
- a.insert("inst-fmf-ei");
- a.insert("inst-match-gen");
- a.insert("inst-trigger");
- a.insert("integers");
- a.insert("interactive");
- a.insert("intersectConstantIte");
- a.insert("isConst");
- a.insert("ite");
- a.insert("ite::atom");
- a.insert("ite::constantIteEqualsConstant");
- a.insert("ite::print-success");
- a.insert("ite::simpite");
- a.insert("lemma-ites");
- a.insert("lemmaInputChannel");
- a.insert("literal-matching");
- a.insert("logPivot");
- a.insert("matrix");
- a.insert("minisat");
- a.insert("minisat::lemmas");
- a.insert("minisat::pop");
- a.insert("minisat::remove-clause");
- a.insert("minisat::search");
- a.insert("miplib");
- a.insert("model");
- a.insert("model-getvalue");
- a.insert("nf::tmp");
- a.insert("nm");
- a.insert("normal-form");
- a.insert("options");
- a.insert("paranoid:check_tableau");
- a.insert("parser");
- a.insert("parser-extra");
- a.insert("parser-idt");
- a.insert("parser-param");
- a.insert("partial_model");
- a.insert("pb");
- a.insert("pickle");
- a.insert("pickler");
- a.insert("pipe");
- a.insert("portfolio::outputmode");
- a.insert("prec");
- a.insert("preemptGetopt");
- a.insert("proof:sat");
- a.insert("proof:sat:detailed");
- a.insert("prop");
- a.insert("prop-explain");
- a.insert("prop-value");
- a.insert("prop::lemmas");
- a.insert("propagateAsDecision");
- a.insert("properConflict");
- a.insert("qcf-ccbe");
- a.insert("qcf-check-inst");
- a.insert("qcf-eval");
- a.insert("qcf-match");
- a.insert("qcf-match-debug");
- a.insert("qcf-nground");
- a.insert("qint-check-debug2");
- a.insert("qint-debug");
- a.insert("qint-error");
- a.insert("qint-model-debug");
- a.insert("qint-model-debug2");
- a.insert("qint-var-order-debug2");
- a.insert("quant-arith");
- a.insert("quant-arith-debug");
- a.insert("quant-arith-simplex");
- a.insert("quant-datatypes");
- a.insert("quant-datatypes-debug");
- a.insert("quant-req-phase");
- a.insert("quant-uf-strategy");
- a.insert("quantifiers");
- a.insert("quantifiers-assert");
- a.insert("quantifiers-check");
- a.insert("quantifiers-dec");
- a.insert("quantifiers-engine");
- a.insert("quantifiers-flip");
- a.insert("quantifiers-other");
- a.insert("quantifiers-prereg");
- a.insert("quantifiers-presolve");
- a.insert("quantifiers-relevance");
- a.insert("quantifiers-sat");
- a.insert("quantifiers-substitute-debug");
- a.insert("quantifiers::collectModelInfo");
- a.insert("queueConditions");
- a.insert("rationalToCfe");
- a.insert("recentlyViolated");
- a.insert("register");
- a.insert("register::internal");
- a.insert("relevant-trigger");
- a.insert("removeFixed");
- a.insert("rl");
- a.insert("sat::minisat");
- a.insert("selectFocusImproving");
- a.insert("set_collection");
- a.insert("sets");
- a.insert("sets-assert");
- a.insert("sets-checkmodel-ignore");
- a.insert("sets-eq");
- a.insert("sets-learn");
- a.insert("sets-lemma");
- a.insert("sets-model");
- a.insert("sets-model-details");
- a.insert("sets-parent");
- a.insert("sets-pending");
- a.insert("sets-prop");
- a.insert("sets-prop-details");
- a.insert("sets-scrutinize");
- a.insert("sets-terminfo");
- a.insert("shared");
- a.insert("shared-terms-database");
- a.insert("shared-terms-database::assert");
- a.insert("sharing");
- a.insert("simple-trigger");
- a.insert("simplify");
- a.insert("smart-multi-trigger");
- a.insert("smt");
- a.insert("soi::findModel");
- a.insert("soi::selectPrimalUpdate");
- a.insert("solveRealRelaxation");
- a.insert("sort");
- a.insert("speculativeUpdate");
- a.insert("strings");
- a.insert("strings-explain");
- a.insert("strings-explain-debug");
- a.insert("strings-prereg");
- a.insert("strings-propagate");
- a.insert("substitution");
- a.insert("substitution::internal");
- a.insert("tableau");
- a.insert("te");
- a.insert("term-db-cong");
- a.insert("theory");
- a.insert("theory::assertions");
- a.insert("theory::atoms");
- a.insert("theory::bv::rewrite");
- a.insert("theory::conflict");
- a.insert("theory::explain");
- a.insert("theory::idl");
- a.insert("theory::idl::model");
- a.insert("theory::internal");
- a.insert("theory::propagate");
- a.insert("trans-closure");
- a.insert("treat-unknown-error");
- a.insert("tuprec");
- a.insert("typecheck-idt");
- a.insert("typecheck-q");
- a.insert("typecheck-r");
- a.insert("uf");
- a.insert("uf-ss");
- a.insert("uf-ss-check-region");
- a.insert("uf-ss-cliques");
- a.insert("uf-ss-debug");
- a.insert("uf-ss-disequal");
- a.insert("uf-ss-na");
- a.insert("uf-ss-region");
- a.insert("uf-ss-region-debug");
- a.insert("uf-ss-register");
- a.insert("uf-ss-sat");
- a.insert("uf::propagate");
- a.insert("uf::sharing");
- a.insert("ufgc");
- a.insert("ufsymm");
- a.insert("ufsymm:clauses");
- a.insert("ufsymm:eq");
- a.insert("ufsymm:match");
- a.insert("ufsymm:norm");
- a.insert("ufsymm:p");
- a.insert("update");
- a.insert("updateAndSignal");
- a.insert("weak");
- a.insert("whytheoryenginewhy");
- return a;
-}
-
-set<string> getOptionStrings()
-{
- const char* cmdlineOptions[] = {
- "lang",
- "output-lang",
- "language",
- "output-language",
- "verbose",
- "quiet",
- "stats",
- "no-stats",
- "statistics",
- "no-statistics",
- "stats-every-query",
- "no-stats-every-query",
- "statistics-every-query",
- "no-statistics-every-query",
- "parse-only",
- "no-parse-only",
- "preprocess-only",
- "no-preprocess-only",
- "trace",
- "debug",
- "print-success",
- "no-print-success",
- "smtlib-strict",
- "default-expr-depth",
- "default-dag-thresh",
- "print-expr-types",
- "eager-type-checking",
- "lazy-type-checking",
- "no-type-checking",
- "biased-ites",
- "no-biased-ites",
- "boolean-term-conversion-mode",
- "theoryof-mode",
- "use-theory",
- "bitblast-eager",
- "no-bitblast-eager",
- "bitblast-share-lemmas",
- "no-bitblast-share-lemmas",
- "bitblast-eager-fullcheck",
- "no-bitblast-eager-fullcheck",
- "bv-inequality-solver",
- "no-bv-inequality-solver",
- "bv-core-solver",
- "no-bv-core-solver",
- "bv-to-bool",
- "no-bv-to-bool",
- "bv-propagate",
- "no-bv-propagate",
- "bv-eq",
- "no-bv-eq",
- "dt-rewrite-error-sel",
- "no-dt-rewrite-error-sel",
- "dt-force-assignment",
- "unate-lemmas",
- "arith-prop",
- "heuristic-pivots",
- "standard-effort-variable-order-pivots",
- "error-selection-rule",
- "simplex-check-period",
- "pivot-threshold",
- "prop-row-length",
- "disable-dio-solver",
- "enable-arith-rewrite-equalities",
- "disable-arith-rewrite-equalities",
- "enable-miplib-trick",
- "disable-miplib-trick",
- "miplib-trick-subs",
- "cut-all-bounded",
- "no-cut-all-bounded",
- "maxCutsInContext",
- "revert-arith-models-on-unsat",
- "no-revert-arith-models-on-unsat",
- "fc-penalties",
- "no-fc-penalties",
- "use-fcsimplex",
- "no-use-fcsimplex",
- "use-soi",
- "no-use-soi",
- "restrict-pivots",
- "no-restrict-pivots",
- "collect-pivot-stats",
- "no-collect-pivot-stats",
- "use-approx",
- "no-use-approx",
- "approx-branch-depth",
- "dio-decomps",
- "no-dio-decomps",
- "new-prop",
- "no-new-prop",
- "arith-prop-clauses",
- "soi-qe",
- "no-soi-qe",
- "rewrite-divk",
- "no-rewrite-divk",
- "se-solve-int",
- "no-se-solve-int",
- "lemmas-on-replay-failure",
- "no-lemmas-on-replay-failure",
- "dio-turns",
- "rr-turns",
- "dio-repeat",
- "no-dio-repeat",
- "replay-early-close-depth",
- "replay-failure-penalty",
- "replay-num-err-penalty",
- "replay-reject-cut",
- "replay-lemma-reject-cut",
- "replay-soi-major-threshold",
- "replay-soi-major-threshold-pen",
- "replay-soi-minor-threshold",
- "replay-soi-minor-threshold-pen",
- "symmetry-breaker",
- "no-symmetry-breaker",
- "condense-function-values",
- "no-condense-function-values",
- "disable-uf-ss-regions",
- "uf-ss-eager-split",
- "no-uf-ss-eager-split",
- "uf-ss-totality",
- "no-uf-ss-totality",
- "uf-ss-totality-limited",
- "uf-ss-totality-sym-break",
- "no-uf-ss-totality-sym-break",
- "uf-ss-abort-card",
- "uf-ss-explained-cliques",
- "no-uf-ss-explained-cliques",
- "uf-ss-simple-cliques",
- "no-uf-ss-simple-cliques",
- "uf-ss-deq-prop",
- "no-uf-ss-deq-prop",
- "disable-uf-ss-min-model",
- "uf-ss-clique-splits",
- "no-uf-ss-clique-splits",
- "uf-ss-sym-break",
- "no-uf-ss-sym-break",
- "uf-ss-fair",
- "no-uf-ss-fair",
- "arrays-optimize-linear",
- "no-arrays-optimize-linear",
- "arrays-lazy-rintro1",
- "no-arrays-lazy-rintro1",
- "arrays-model-based",
- "no-arrays-model-based",
- "arrays-eager-index",
- "no-arrays-eager-index",
- "arrays-eager-lemmas",
- "no-arrays-eager-lemmas",
- "disable-miniscope-quant",
- "disable-miniscope-quant-fv",
- "disable-prenex-quant",
- "disable-var-elim-quant",
- "disable-ite-lift-quant",
- "cnf-quant",
- "no-cnf-quant",
- "clause-split",
- "no-clause-split",
- "pre-skolem-quant",
- "no-pre-skolem-quant",
- "ag-miniscope-quant",
- "no-ag-miniscope-quant",
- "macros-quant",
- "no-macros-quant",
- "fo-prop-quant",
- "no-fo-prop-quant",
- "disable-smart-triggers",
- "relevant-triggers",
- "no-relevant-triggers",
- "relational-triggers",
- "no-relational-triggers",
- "register-quant-body-terms",
- "no-register-quant-body-terms",
- "inst-when",
- "eager-inst-quant",
- "no-eager-inst-quant",
- "full-saturate-quant",
- "no-full-saturate-quant",
- "literal-matching",
- "enable-cbqi",
- "no-enable-cbqi",
- "cbqi-recurse",
- "no-cbqi-recurse",
- "user-pat",
- "flip-decision",
- "disable-quant-internal-reps",
- "finite-model-find",
- "no-finite-model-find",
- "mbqi",
- "mbqi-one-inst-per-round",
- "no-mbqi-one-inst-per-round",
- "mbqi-one-quant-per-round",
- "no-mbqi-one-quant-per-round",
- "fmf-inst-engine",
- "no-fmf-inst-engine",
- "disable-fmf-inst-gen",
- "fmf-inst-gen-one-quant-per-round",
- "no-fmf-inst-gen-one-quant-per-round",
- "fmf-fresh-dc",
- "no-fmf-fresh-dc",
- "disable-fmf-fmc-simple",
- "fmf-bound-int",
- "no-fmf-bound-int",
- "axiom-inst",
- "quant-cf",
- "no-quant-cf",
- "quant-cf-mode",
- "quant-cf-when",
- "rewrite-rules",
- "no-rewrite-rules",
- "rr-one-inst-per-round",
- "no-rr-one-inst-per-round",
- "strings-exp",
- "no-strings-exp",
- "strings-lb",
- "strings-fmf",
- "no-strings-fmf",
- "strings-eit",
- "no-strings-eit",
- "strings-alphabet-card",
- "show-sat-solvers",
- "random-freq",
- "random-seed",
- "restart-int-base",
- "restart-int-inc",
- "refine-conflicts",
- "no-refine-conflicts",
- "minisat-elimination",
- "no-minisat-elimination",
- "minisat-dump-dimacs",
- "no-minisat-dump-dimacs",
- "model-format",
- "dump",
- "dump-to",
- "force-logic",
- "simplification",
- "no-simplification",
- "static-learning",
- "no-static-learning",
- "produce-models",
- "no-produce-models",
- "check-models",
- "no-check-models",
- "dump-models",
- "no-dump-models",
- "proof",
- "no-proof",
- "check-proofs",
- "no-check-proofs",
- "dump-proofs",
- "no-dump-proofs",
- "produce-unsat-cores",
- "no-produce-unsat-cores",
- "produce-assignments",
- "no-produce-assignments",
- "interactive",
- "no-interactive",
- "ite-simp",
- "no-ite-simp",
- "on-repeat-ite-simp",
- "no-on-repeat-ite-simp",
- "simp-with-care",
- "no-simp-with-care",
- "simp-ite-compress",
- "no-simp-ite-compress",
- "unconstrained-simp",
- "no-unconstrained-simp",
- "repeat-simp",
- "no-repeat-simp",
- "simp-ite-hunt-zombies",
- "sort-inference",
- "no-sort-inference",
- "incremental",
- "no-incremental",
- "abstract-values",
- "no-abstract-values",
- "model-u-dt-enum",
- "no-model-u-dt-enum",
- "tlimit",
- "tlimit-per",
- "rlimit",
- "rlimit-per",
- "rewrite-apply-to-const",
- "no-rewrite-apply-to-const",
- "replay",
- "replay-log",
- "decision",
- "decision-threshold",
- "decision-use-weight",
- "no-decision-use-weight",
- "decision-random-weight",
- "decision-weight-internal",
- "version",
- "license",
- "help",
- "show-config",
- "show-debug-tags",
- "show-trace-tags",
- "early-exit",
- "no-early-exit",
- "threads",
- "threadN",
- "filter-lemma-length",
- "fallback-sequential",
- "no-fallback-sequential",
- "incremental-parallel",
- "no-incremental-parallel",
- "no-interactive-prompt",
- "continued-execution",
- "immediate-exit",
- "segv-spin",
- "no-segv-spin",
- "segv-nospin",
- "wait-to-join",
- "no-wait-to-join",
- "strict-parsing",
- "no-strict-parsing",
- "mmap",
- "no-mmap",
- "no-checking",
- "no-filesystem-access",
- "no-include-file",
- "enable-idl-rewrite-equalities",
- "disable-idl-rewrite-equalities",
- "sets-propagate",
- "no-sets-propagate",
- "sets-eager-lemmas",
- "no-sets-eager-lemmas",
- NULL,
- };/* cmdlineOptions */
- int i = 0;
- set<string> ret;
- while(cmdlineOptions[i] != NULL) {
- ret.insert(cmdlineOptions[i]);
- i++;
- }
- return ret;
-}
**/
#include "util/divisible.h"
-#include "util/exception.h"
+
+#include "base/exception.h"
using namespace std;
#define __CVC4__DIVISIBLE_H
#include <iostream>
+
+#include "base/exception.h"
#include "util/integer.h"
-#include "util/exception.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file dump.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 Dump utility classes and functions
- **
- ** Dump utility classes and functions.
- **/
-
-#include "util/dump.h"
-
-using namespace std;
-
-namespace CVC4 {
-
-DumpC DumpChannel CVC4_PUBLIC;
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file dump.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 Dump utility classes and functions
- **
- ** Dump utility classes and functions.
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__DUMP_H
-#define __CVC4__DUMP_H
-
-#include "expr/command.h"
-
-namespace CVC4 {
-
-class CVC4_PUBLIC CVC4dumpstream {
-
-#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
- std::ostream* d_os;
-#endif /* CVC4_DUMPING && !CVC4_MUZZLE */
-
-#ifdef CVC4_PORTFOLIO
- CommandSequence* d_commands;
-#endif /* CVC4_PORTFOLIO */
-
-public:
- CVC4dumpstream() throw()
-#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE) && defined(CVC4_PORTFOLIO)
- : d_os(NULL), d_commands(NULL)
-#elif defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
- : d_os(NULL)
-#elif defined(CVC4_PORTFOLIO)
- : d_commands(NULL)
-#endif /* CVC4_PORTFOLIO */
- { }
-
- CVC4dumpstream(std::ostream& os, CommandSequence& commands) throw()
-#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE) && defined(CVC4_PORTFOLIO)
- : d_os(&os), d_commands(&commands)
-#elif defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
- : d_os(&os)
-#elif defined(CVC4_PORTFOLIO)
- : d_commands(&commands)
-#endif /* CVC4_PORTFOLIO */
- { }
-
- CVC4dumpstream& operator<<(const Command& c) {
-#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
- if(d_os != NULL) {
- (*d_os) << c << std::endl;
- }
-#endif
-#if defined(CVC4_PORTFOLIO)
- if(d_commands != NULL) {
- d_commands->addCommand(c.clone());
- }
-#endif
- return *this;
- }
-};/* class CVC4dumpstream */
-
-/** The dump class */
-class CVC4_PUBLIC DumpC {
- std::set<std::string> d_tags;
- CommandSequence d_commands;
-
-public:
- CVC4dumpstream operator()(const char* tag) {
- if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
- return CVC4dumpstream(getStream(), d_commands);
- } else {
- return CVC4dumpstream();
- }
- }
- CVC4dumpstream operator()(std::string tag) {
- if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
- return CVC4dumpstream(getStream(), d_commands);
- } else {
- return CVC4dumpstream();
- }
- }
-
- void clear() { d_commands.clear(); }
- const CommandSequence& getCommands() const { return d_commands; }
-
- bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
- bool on (std::string tag) { d_tags.insert(tag); return true; }
- bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
- bool off(std::string tag) { d_tags.erase (tag); return false; }
- bool off() { d_tags.clear(); return false; }
-
- bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
- bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
-
- std::ostream& setStream(std::ostream& os) { DumpOut.setStream(os); return os; }
- std::ostream& getStream() { return DumpOut.getStream(); }
-};/* class DumpC */
-
-/** The dump singleton */
-extern DumpC DumpChannel CVC4_PUBLIC;
-
-#define Dump ::CVC4::DumpChannel
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__DUMP_H */
#ifndef __CVC4__UTIL__DYNAMIC_ARRAY_H
#define __CVC4__UTIL__DYNAMIC_ARRAY_H
-#include "util/cvc4_assert.h"
+#include "base/cvc4_assert.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file emptyset.cpp
- ** \verbatim
- ** Original author: Kshitij Bansal
- ** 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 "util/emptyset.h"
-#include <iostream>
-
-using namespace std;
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, const EmptySet& asa) {
- return out << "emptyset(" << asa.getType() << ')';
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file emptyset.h
- ** \verbatim
- ** Original author: Kshitij Bansal
- ** 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 ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "cvc4_public.h"
-
-#pragma once
-
-namespace CVC4 {
- // messy; Expr needs EmptySet (because it's the payload of a
- // CONSTANT-kinded expression), and EmptySet needs Expr.
- class CVC4_PUBLIC EmptySet;
-}/* CVC4 namespace */
-
-#include "expr/expr.h"
-#include "expr/type.h"
-#include <iostream>
-
-namespace CVC4 {
-
-class CVC4_PUBLIC EmptySet {
-
- const SetType d_type;
-
- EmptySet() { }
-public:
-
- /**
- * Constructs an emptyset of the specified type. Note that the argument
- * is the type of the set itself, NOT the type of the elements.
- */
- EmptySet(SetType setType):d_type(setType) { }
-
-
- ~EmptySet() throw() {
- }
-
- SetType getType() const { return d_type; }
-
- bool operator==(const EmptySet& es) const throw() {
- return d_type == es.d_type;
- }
- bool operator!=(const EmptySet& es) const throw() {
- return !(*this == es);
- }
-
- bool operator<(const EmptySet& es) const throw() {
- return d_type < es.d_type;
- }
- bool operator<=(const EmptySet& es) const throw() {
- return d_type <= es.d_type;
- }
- bool operator>(const EmptySet& es) const throw() {
- return !(*this <= es);
- }
- bool operator>=(const EmptySet& es) const throw() {
- return !(*this < es);
- }
-
-};/* class EmptySet */
-
-std::ostream& operator<<(std::ostream& out, const EmptySet& es) CVC4_PUBLIC;
-
-struct CVC4_PUBLIC EmptySetHashFunction {
- inline size_t operator()(const EmptySet& es) const {
- return TypeHashFunction()(es.getType());
- }
-};/* struct EmptySetHashFunction */
-
-}/* CVC4 namespace */
+++ /dev/null
-%{
-#include "util/emptyset.h"
-%}
-
-%rename(equals) CVC4::EmptySet::operator==(const EmptySet&) const;
-%ignore CVC4::EmptySet::operator!=(const EmptySet&) const;
-
-%rename(less) CVC4::EmptySet::operator<(const EmptySet&) const;
-%rename(lessEqual) CVC4::EmptySet::operator<=(const EmptySet&) const;
-%rename(greater) CVC4::EmptySet::operator>(const EmptySet&) const;
-%rename(greaterEqual) CVC4::EmptySet::operator>=(const EmptySet&) const;
-
-%rename(apply) CVC4::EmptySetHashFunction::operator()(const EmptySet&) const;
-
-%ignore CVC4::operator<<(std::ostream& out, const EmptySet& es);
-
-%include "util/emptyset.h"
+++ /dev/null
-/********************* */
-/*! \file exception.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 CVC4's exception base class and some associated utilities
- **
- ** CVC4's exception base class and some associated utilities.
- **/
-
-#include "util/exception.h"
-#include <string>
-#include <cstdio>
-#include <cstdlib>
-#include <cstdarg>
-#include "util/cvc4_assert.h"
-
-using namespace std;
-using namespace CVC4;
-
-void IllegalArgumentException::construct(const char* header, const char* extra,
- const char* function, const char* fmt,
- va_list args) {
- // try building the exception msg with a smallish buffer first,
- // then with a larger one if sprintf tells us to.
- int n = 512;
- char* buf;
-
- for(;;) {
- buf = new char[n];
-
- int size;
- if(extra == NULL) {
- size = snprintf(buf, n, "%s\n%s\n",
- header, function);
- } else {
- size = snprintf(buf, n, "%s\n%s\n\n %s\n",
- header, function, extra);
- }
-
- if(size < n) {
- va_list args_copy;
- va_copy(args_copy, args);
- size += vsnprintf(buf + size, n - size, fmt, args_copy);
- va_end(args_copy);
-
- if(size < n) {
- break;
- }
- }
-
- if(size >= n) {
- // try again with a buffer that's large enough
- n = size + 1;
- delete [] buf;
- }
- }
-
- setMessage(string(buf));
-
-#ifdef CVC4_DEBUG
- if(s_debugLastException == NULL) {
- // we leak buf[] but only in debug mode with assertions failing
- s_debugLastException = buf;
- }
-#else /* CVC4_DEBUG */
- delete [] buf;
-#endif /* CVC4_DEBUG */
-}
-
-void IllegalArgumentException::construct(const char* header, const char* extra,
- const char* function) {
- // try building the exception msg with a smallish buffer first,
- // then with a larger one if sprintf tells us to.
- int n = 256;
- char* buf;
-
- for(;;) {
- buf = new char[n];
-
- int size;
- if(extra == NULL) {
- size = snprintf(buf, n, "%s.\n%s\n",
- header, function);
- } else {
- size = snprintf(buf, n, "%s.\n%s\n\n %s\n",
- header, function, extra);
- }
-
- if(size < n) {
- break;
- } else {
- // try again with a buffer that's large enough
- n = size + 1;
- delete [] buf;
- }
- }
-
- setMessage(string(buf));
-
-#ifdef CVC4_DEBUG
- if(s_debugLastException == NULL) {
- // we leak buf[] but only in debug mode with assertions failing
- s_debugLastException = buf;
- }
-#else /* CVC4_DEBUG */
- delete [] buf;
-#endif /* CVC4_DEBUG */
-}
+++ /dev/null
-/********************* */
-/*! \file exception.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 CVC4's exception base class and some associated utilities
- **
- ** CVC4's exception base class and some associated utilities.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__EXCEPTION_H
-#define __CVC4__EXCEPTION_H
-
-#include <iostream>
-#include <string>
-#include <sstream>
-#include <stdexcept>
-#include <exception>
-#include <cstdlib>
-#include <cstdarg>
-
-namespace CVC4 {
-
-class CVC4_PUBLIC Exception : public std::exception {
-protected:
- std::string d_msg;
-
-public:
- // Constructors
- Exception() throw() : d_msg("Unknown exception") {}
- Exception(const std::string& msg) throw() : d_msg(msg) {}
- Exception(const char* msg) throw() : d_msg(msg) {}
-
- // Destructor
- virtual ~Exception() throw() {}
-
- // NON-VIRTUAL METHOD for setting and printing the error message
- void setMessage(const std::string& msg) throw() { d_msg = msg; }
- std::string getMessage() const throw() { return d_msg; }
-
- // overridden from base class std::exception
- virtual const char* what() const throw() { return d_msg.c_str(); }
-
- /**
- * Get this exception as a string. Note that
- * cout << ex.toString();
- * is subtly different from
- * cout << ex;
- * which is equivalent to
- * ex.toStream(cout);
- * That is because with the latter two, the output language (and
- * other preferences) for exprs on the stream is respected. In
- * toString(), there is no stream, so the parameters are default
- * and you'll get exprs and types printed using the AST language.
- */
- std::string toString() const throw() {
- std::stringstream ss;
- toStream(ss);
- return ss.str();
- }
-
- /**
- * Printing: feel free to redefine toStream(). When overridden in
- * a derived class, it's recommended that this method print the
- * type of exception before the actual message.
- */
- virtual void toStream(std::ostream& os) const throw() { os << d_msg; }
-
-};/* class Exception */
-
-class CVC4_PUBLIC IllegalArgumentException : public Exception {
-protected:
- IllegalArgumentException() : Exception() {}
-
- void construct(const char* header, const char* extra,
- const char* function, const char* fmt, ...) {
- va_list args;
- va_start(args, fmt);
- construct(header, extra, function, fmt, args);
- va_end(args);
- }
-
- void construct(const char* header, const char* extra,
- const char* function, const char* fmt, va_list args);
-
- void construct(const char* header, const char* extra,
- const char* function);
-
-public:
- IllegalArgumentException(const char* condStr, const char* argDesc,
- const char* function, const char* fmt, ...) :
- Exception() {
- va_list args;
- va_start(args, fmt);
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument"
- + (*condStr == '\0' ? std::string() :
- ( std::string("; expected ") +
- condStr + " to hold" )) ).c_str(),
- function, fmt, args);
- va_end(args);
- }
-
- IllegalArgumentException(const char* condStr, const char* argDesc,
- const char* function) :
- Exception() {
- construct("Illegal argument detected",
- ( std::string("`") + argDesc + "' is a bad argument"
- + (*condStr == '\0' ? std::string() :
- ( std::string("; expected ") +
- condStr + " to hold" )) ).c_str(),
- function);
- }
-};/* class IllegalArgumentException */
-
-inline std::ostream& operator<<(std::ostream& os, const Exception& e) throw() CVC4_PUBLIC;
-inline std::ostream& operator<<(std::ostream& os, const Exception& e) throw() {
- e.toStream(os);
- return os;
-}
-
-}/* CVC4 namespace */
-
-#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && !defined(__BUILDING_STATISTICS_FOR_EXPORT)
-# include "util/cvc4_assert.h"
-#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST) && !__BUILDING_STATISTICS_FOR_EXPORT */
-
-namespace CVC4 {
-
-#ifndef CheckArgument
-template <class T> inline void CheckArgument(bool cond, const T& arg, const char* fmt, ...) CVC4_PUBLIC;
-template <class T> inline void CheckArgument(bool cond, const T& arg, const char* fmt, ...) {
- if(__builtin_expect( ( !cond ), false )) { \
- throw ::CVC4::IllegalArgumentException("", "", ""); \
- } \
-}
-template <class T> inline void CheckArgument(bool cond, const T& arg) CVC4_PUBLIC;
-template <class T> inline void CheckArgument(bool cond, const T& arg) {
- if(__builtin_expect( ( !cond ), false )) { \
- throw ::CVC4::IllegalArgumentException("", "", ""); \
- } \
-}
-#endif /* CheckArgument */
-
-#ifndef DebugCheckArgument
-template <class T> inline void DebugCheckArgument(bool cond, const T& arg, const char* fmt, ...) CVC4_PUBLIC;
-template <class T> inline void DebugCheckArgument(bool cond, const T& arg, const char* fmt, ...) {
- if(__builtin_expect( ( !cond ), false )) { \
- throw ::CVC4::IllegalArgumentException("", "", ""); \
- } \
-}
-template <class T> inline void DebugCheckArgument(bool cond, const T& arg) CVC4_PUBLIC;
-template <class T> inline void DebugCheckArgument(bool cond, const T& arg) {
- if(__builtin_expect( ( !cond ), false )) { \
- throw ::CVC4::IllegalArgumentException("", "", ""); \
- } \
-}
-#endif /* DebugCheckArgument */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__EXCEPTION_H */
+++ /dev/null
-%{
-#include "util/exception.h"
-%}
-
-%ignore CVC4::operator<<(std::ostream&, const Exception&) throw();
-%ignore CVC4::Exception::Exception(const char*) throw();
-%typemap(javabase) CVC4::Exception "java.lang.RuntimeException";
-
-%rename(CVC4IllegalArgumentException) CVC4::IllegalArgumentException;
-
-%include "util/exception.h"
**
**/
-#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)
}
}/* CVC4 namespace */
-
** [[ 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; }
}; /* struct FloatingPointSizeHashFunction */
-
-
-
-
-
-
-
-
/**
* A concrete instance of the rounding mode sort
*/
}; /* struct RoundingModeHashFunction */
-
-
-
-
-
-
-
-
/**
* A concrete floating point number
*/
}
}; /* struct FloatingPointHashFunction */
-
-
-
-
-
-
/**
* The parameter type for the conversions to floating point.
*/
-
-
-
inline std::ostream& operator <<(std::ostream& os, const FloatingPointLiteral& fp) CVC4_PUBLIC;
inline std::ostream& operator <<(std::ostream& os, const FloatingPointLiteral& fp) {
fp.unfinished();
return os << "(_ to_fp " << fpcs.t.exponent() << " " << fpcs.t.significand() << ")";
}
-
-
-
}/* CVC4 namespace */
#endif /* __CVC4__FLOATINGPOINT_H */
** [[ 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 !"
#include <cln/integer_io.h>
#include <limits>
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
** 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 !"
#include <iostream>
#include <limits>
+#include "base/exception.h"
#include "util/gmp_util.h"
-#include "util/exception.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file ite_removal.cpp
- ** \verbatim
- ** Original author: Dejan Jovanovic
- ** Major contributors: Tim King, Morgan Deters
- ** Minor contributors (to current version): Kshitij Bansal, Andrew Reynolds, Clark Barrett
- ** 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 Removal of term ITEs
- **
- ** Removal of term ITEs.
- **/
-
-#include <vector>
-
-#include "util/ite_removal.h"
-#include "expr/command.h"
-#include "theory/ite_utilities.h"
-#include "proof/proof_manager.h"
-
-using namespace CVC4;
-using namespace std;
-
-namespace CVC4 {
-
-RemoveITE::RemoveITE(context::UserContext* u)
- : d_iteCache(u)
-{
- d_containsVisitor = new theory::ContainsTermITEVisitor();
-}
-
-RemoveITE::~RemoveITE(){
- delete d_containsVisitor;
-}
-
-void RemoveITE::garbageCollect(){
- d_containsVisitor->garbageCollect();
-}
-
-theory::ContainsTermITEVisitor* RemoveITE::getContainsVisitor() {
- return d_containsVisitor;
-}
-
-size_t RemoveITE::collectedCacheSizes() const{
- return d_containsVisitor->cache_size() + d_iteCache.size();
-}
-
-void RemoveITE::run(std::vector<Node>& output, IteSkolemMap& iteSkolemMap, bool reportDeps)
-{
- size_t n = output.size();
- for (unsigned i = 0, i_end = output.size(); i < i_end; ++ i) {
- // Do this in two steps to avoid Node problems(?)
- // Appears related to bug 512, splitting this into two lines
- // fixes the bug on clang on Mac OS
- Node itesRemoved = run(output[i], output, iteSkolemMap, false);
- // In some calling contexts, not necessary to report dependence information.
- if(reportDeps && options::unsatCores()) {
- // new assertions have a dependence on the node
- PROOF( ProofManager::currentPM()->addDependence(itesRemoved, output[i]); )
- while(n < output.size()) {
- PROOF( ProofManager::currentPM()->addDependence(output[n], output[i]); )
- ++n;
- }
- }
- output[i] = itesRemoved;
- }
-}
-
-bool RemoveITE::containsTermITE(TNode e) const {
- return d_containsVisitor->containsTermITE(e);
-}
-
-Node RemoveITE::run(TNode node, std::vector<Node>& output,
- IteSkolemMap& iteSkolemMap, bool inQuant) {
- // Current node
- Debug("ite") << "removeITEs(" << node << ")" << endl;
-
- if(node.isVar() || node.isConst() ||
- (options::biasedITERemoval() && !containsTermITE(node))){
- return Node(node);
- }
-
- // The result may be cached already
- std::pair<Node, bool> cacheKey(node, inQuant);
- NodeManager *nodeManager = NodeManager::currentNM();
- ITECache::const_iterator i = d_iteCache.find(cacheKey);
- if(i != d_iteCache.end()) {
- Node cached = (*i).second;
- Debug("ite") << "removeITEs: in-cache: " << cached << endl;
- return cached.isNull() ? Node(node) : cached;
- }
-
- // Remember that we're inside a quantifier
- if(node.getKind() == kind::FORALL || node.getKind() == kind::EXISTS) {
- inQuant = true;
- }
-
- // If an ITE replace it
- if(node.getKind() == kind::ITE) {
- TypeNode nodeType = node.getType();
- if(!nodeType.isBoolean() && (!inQuant || !node.hasBoundVar())) {
- Node skolem;
- // Make the skolem to represent the ITE
- skolem = nodeManager->mkSkolem("termITE", nodeType, "a variable introduced due to term-level ITE removal");
-
- // The new assertion
- Node newAssertion =
- nodeManager->mkNode(kind::ITE, node[0], skolem.eqNode(node[1]),
- skolem.eqNode(node[2]));
- Debug("ite") << "removeITEs(" << node << ") => " << newAssertion << endl;
-
- // Attach the skolem
- d_iteCache.insert(cacheKey, skolem);
-
- // Remove ITEs from the new assertion, rewrite it and push it to the output
- newAssertion = run(newAssertion, output, iteSkolemMap, inQuant);
-
- iteSkolemMap[skolem] = output.size();
- output.push_back(newAssertion);
-
- // The representation is now the skolem
- return skolem;
- }
- }
-
- // If not an ITE, go deep
- vector<Node> newChildren;
- bool somethingChanged = false;
- if(node.getMetaKind() == kind::metakind::PARAMETERIZED) {
- newChildren.push_back(node.getOperator());
- }
- // Remove the ITEs from the children
- for(TNode::const_iterator it = node.begin(), end = node.end(); it != end; ++it) {
- Node newChild = run(*it, output, iteSkolemMap, inQuant);
- somethingChanged |= (newChild != *it);
- newChildren.push_back(newChild);
- }
-
- // If changes, we rewrite
- if(somethingChanged) {
- Node cached = nodeManager->mkNode(node.getKind(), newChildren);
- d_iteCache.insert(cacheKey, cached);
- return cached;
- } else {
- d_iteCache.insert(cacheKey, Node::null());
- return node;
- }
-}
-
-Node RemoveITE::replace(TNode node, bool inQuant) const {
- if(node.isVar() || node.isConst() ||
- (options::biasedITERemoval() && !containsTermITE(node))){
- return Node(node);
- }
-
- // Check the cache
- NodeManager *nodeManager = NodeManager::currentNM();
- ITECache::const_iterator i = d_iteCache.find(make_pair(node, inQuant));
- if(i != d_iteCache.end()) {
- Node cached = (*i).second;
- return cached.isNull() ? Node(node) : cached;
- }
-
- // Remember that we're inside a quantifier
- if(node.getKind() == kind::FORALL || node.getKind() == kind::EXISTS) {
- inQuant = true;
- }
-
- vector<Node> newChildren;
- bool somethingChanged = false;
- if(node.getMetaKind() == kind::metakind::PARAMETERIZED) {
- newChildren.push_back(node.getOperator());
- }
- // Replace in children
- for(TNode::const_iterator it = node.begin(), end = node.end(); it != end; ++it) {
- Node newChild = replace(*it, inQuant);
- somethingChanged |= (newChild != *it);
- newChildren.push_back(newChild);
- }
-
- // If changes, we rewrite
- if(somethingChanged) {
- return nodeManager->mkNode(node.getKind(), newChildren);
- } else {
- return node;
- }
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file ite_removal.h
- ** \verbatim
- ** Original author: Dejan Jovanovic
- ** Major contributors: Kshitij Bansal, Tim King, Morgan Deters
- ** Minor contributors (to current version): Clark Barrett
- ** 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 Removal of term ITEs
- **
- ** Removal of term ITEs.
- **/
-
-#include "cvc4_private.h"
-
-#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 "util/bool.h"
-
-namespace CVC4 {
-
-namespace theory {
- class ContainsTermITEVisitor;
-}/* CVC4::theory namespace */
-
-typedef std::hash_map<Node, unsigned, NodeHashFunction> IteSkolemMap;
-
-class RemoveITE {
- typedef context::CDInsertHashMap< std::pair<Node, bool>, Node, PairHashFunction<Node, bool, NodeHashFunction, BoolHashFunction> > ITECache;
- ITECache d_iteCache;
-
-
-public:
-
- RemoveITE(context::UserContext* u);
- ~RemoveITE();
-
- /**
- * Removes the ITE nodes by introducing skolem variables. All
- * additional assertions are pushed into assertions. iteSkolemMap
- * contains a map from introduced skolem variables to the index in
- * assertions containing the new Boolean ite created in conjunction
- * with that skolem variable.
- *
- * With reportDeps true, report reasoning dependences to the proof
- * manager (for unsat cores).
- */
- void run(std::vector<Node>& assertions, IteSkolemMap& iteSkolemMap, bool reportDeps = false);
-
- /**
- * Removes the ITE from the node by introducing skolem
- * variables. All additional assertions are pushed into
- * assertions. iteSkolemMap contains a map from introduced skolem
- * variables to the index in assertions containing the new Boolean
- * ite created in conjunction with that skolem variable.
- */
- Node run(TNode node, std::vector<Node>& additionalAssertions,
- IteSkolemMap& iteSkolemMap, bool inQuant);
-
- /**
- * Substitute under node using pre-existing cache. Do not remove
- * any ITEs not seen during previous runs.
- */
- Node replace(TNode node, bool inQuant = false) const;
-
- /** Returns true if e contains a term ite. */
- bool containsTermITE(TNode e) const;
-
- /** Returns the collected size of the caches. */
- size_t collectedCacheSizes() const;
-
- /** Garbage collects non-context dependent data-structures. */
- void garbageCollect();
-
- /** Return the RemoveITE's containsVisitor. */
- theory::ContainsTermITEVisitor* getContainsVisitor();
-
-private:
- theory::ContainsTermITEVisitor* d_containsVisitor;
-
-};/* class RemoveTTE */
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file language.cpp
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: none
- ** Minor contributors (to current version): Francois Bobot, Andrew Reynolds
- ** 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 Definition of input and output languages
- **
- ** Definition of input and output languages.
- **/
-
-#include "util/language.h"
-
-namespace CVC4 {
-namespace language {
-
-InputLanguage toInputLanguage(OutputLanguage language) {
- switch(language) {
- case output::LANG_SMTLIB_V1:
- case output::LANG_SMTLIB_V2_0:
- case output::LANG_SMTLIB_V2_5:
- case output::LANG_TPTP:
- case output::LANG_CVC4:
- case output::LANG_Z3STR:
- case output::LANG_SYGUS:
- // these entries directly correspond (by design)
- return InputLanguage(int(language));
-
- default: {
- std::stringstream ss;
- ss << "Cannot map output language `" << language
- << "' to an input language.";
- throw CVC4::Exception(ss.str());
- }
- }/* switch(language) */
-}/* toInputLanguage() */
-
-OutputLanguage toOutputLanguage(InputLanguage language) {
- switch(language) {
- case input::LANG_SMTLIB_V1:
- case input::LANG_SMTLIB_V2_0:
- case input::LANG_SMTLIB_V2_5:
- case input::LANG_TPTP:
- case input::LANG_CVC4:
- case input::LANG_Z3STR:
- case input::LANG_SYGUS:
- // these entries directly correspond (by design)
- return OutputLanguage(int(language));
-
- default:
- // Revert to the default (AST) language.
- //
- // We used to throw an exception here, but that's not quite right.
- // We often call this while constructing exceptions, for one, and
- // it's better to output SOMETHING related to the original
- // exception rather than mask it with another exception. Also,
- // the input language isn't always defined---e.g. during the
- // initial phase of the main CVC4 driver while it determines which
- // language is appropriate, and during unit tests. Also, when
- // users are writing their own code against the library.
- return output::LANG_AST;
- }/* switch(language) */
-}/* toOutputLanguage() */
-
-OutputLanguage toOutputLanguage(std::string language) {
- if(language == "cvc4" || language == "pl" ||
- language == "presentation" || language == "native" ||
- language == "LANG_CVC4") {
- return output::LANG_CVC4;
- } else if(language == "cvc3" || language == "LANG_CVC3") {
- return output::LANG_CVC3;
- } else if(language == "smtlib1" || language == "smt1" ||
- language == "LANG_SMTLIB_V1") {
- return output::LANG_SMTLIB_V1;
- } else if(language == "smtlib" || language == "smt" ||
- language == "smtlib2" || language == "smt2" ||
- language == "smtlib2.0" || language == "smt2.0" ||
- language == "LANG_SMTLIB_V2_0" || language == "LANG_SMTLIB_V2") {
- return output::LANG_SMTLIB_V2_0;
- } else if(language == "smtlib2.5" || language == "smt2.5" ||
- language == "LANG_SMTLIB_V2_5") {
- return output::LANG_SMTLIB_V2_5;
- } else if(language == "tptp" || language == "LANG_TPTP") {
- return output::LANG_TPTP;
- } else if(language == "z3str" || language == "z3-str" ||
- language == "LANG_Z3STR") {
- return output::LANG_Z3STR;
- } else if(language == "sygus" || language == "LANG_SYGUS") {
- return output::LANG_SYGUS;
- } else if(language == "ast" || language == "LANG_AST") {
- return output::LANG_AST;
- } else if(language == "auto" || language == "LANG_AUTO") {
- return output::LANG_AUTO;
- }
-
- throw OptionException(std::string("unknown output language `" + language + "'"));
-}/* toOutputLanguage() */
-
-InputLanguage toInputLanguage(std::string language) {
- if(language == "cvc4" || language == "pl" ||
- language == "presentation" || language == "native" ||
- language == "LANG_CVC4") {
- return input::LANG_CVC4;
- } else if(language == "smtlib1" || language == "smt1" ||
- language == "LANG_SMTLIB_V1") {
- return input::LANG_SMTLIB_V1;
- } else if(language == "smtlib" || language == "smt" ||
- language == "smtlib2" || language == "smt2" ||
- language == "smtlib2.0" || language == "smt2.0" ||
- language == "LANG_SMTLIB_V2_0" || language == "LANG_SMTLIB_V2") {
- return input::LANG_SMTLIB_V2_0;
- } else if(language == "smtlib2.5" || language == "smt2.5" ||
- language == "LANG_SMTLIB_V2_5") {
- return input::LANG_SMTLIB_V2_5;
- } else if(language == "tptp" || language == "LANG_TPTP") {
- return input::LANG_TPTP;
- } else if(language == "z3str" || language == "z3-str" ||
- language == "LANG_Z3STR") {
- return input::LANG_Z3STR;
- } else if(language == "sygus" || language == "LANG_SYGUS") {
- return input::LANG_SYGUS;
- } else if(language == "auto" || language == "LANG_AUTO") {
- return input::LANG_AUTO;
- }
-
- throw OptionException(std::string("unknown input language `" + language + "'"));
-}/* toInputLanguage() */
-
-}/* CVC4::language namespace */
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file language.h
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: none
- ** Minor contributors (to current version): Francois Bobot, Andrew Reynolds
- ** 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 Definition of input and output languages
- **
- ** Definition of input and output languages.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__LANGUAGE_H
-#define __CVC4__LANGUAGE_H
-
-#include <sstream>
-#include <string>
-
-#include "util/exception.h"
-#include "options/option_exception.h"
-
-namespace CVC4 {
-namespace language {
-
-namespace input {
-
-enum CVC4_PUBLIC Language {
- // SPECIAL "NON-LANGUAGE" LANGUAGES HAVE ENUM VALUE < 0
-
- /** Auto-detect the language */
- LANG_AUTO = -1,
-
- // COMMON INPUT AND OUTPUT LANGUAGES HAVE ENUM VALUES IN [0,9]
- // AND SHOULD CORRESPOND IN PLACEMENT WITH OUTPUTLANGUAGE
- //
- // EVEN IF A LANGUAGE ISN'T CURRENTLY SUPPORTED AS AN INPUT OR
- // OUTPUT LANGUAGE, IF IT IS "IN PRINCIPLE" A COMMON LANGUAGE,
- // INCLUDE IT HERE
-
- /** The SMTLIB v1 input language */
- LANG_SMTLIB_V1 = 0,
- /** The SMTLIB v2.0 input language */
- LANG_SMTLIB_V2_0,
- /** The SMTLIB v2.5 input language */
- LANG_SMTLIB_V2_5,
- /** Backward-compatibility for enumeration naming */
- LANG_SMTLIB_V2 = LANG_SMTLIB_V2_5,
- /** The TPTP input language */
- LANG_TPTP,
- /** The CVC4 input language */
- LANG_CVC4,
- /** The Z3-str input language */
- LANG_Z3STR,
- /** The SyGuS input language */
- LANG_SYGUS,
-
- // START OUTPUT-ONLY LANGUAGES AT ENUM VALUE 10
- // THESE ARE IN PRINCIPLE NOT POSSIBLE INPUT LANGUAGES
-
- /** LANG_MAX is > any valid InputLanguage id */
- LANG_MAX
-};/* enum Language */
-
-inline std::ostream& operator<<(std::ostream& out, Language lang) CVC4_PUBLIC;
-inline std::ostream& operator<<(std::ostream& out, Language lang) {
- switch(lang) {
- case LANG_AUTO:
- out << "LANG_AUTO";
- break;
- case LANG_SMTLIB_V1:
- out << "LANG_SMTLIB_V1";
- break;
- case LANG_SMTLIB_V2_0:
- out << "LANG_SMTLIB_V2_0";
- break;
- case LANG_SMTLIB_V2_5:
- out << "LANG_SMTLIB_V2_5";
- break;
- case LANG_TPTP:
- out << "LANG_TPTP";
- break;
- case LANG_CVC4:
- out << "LANG_CVC4";
- break;
- case LANG_Z3STR:
- out << "LANG_Z3STR";
- break;
- case LANG_SYGUS:
- out << "LANG_SYGUS";
- break;
- default:
- out << "undefined_input_language";
- }
- return out;
-}
-
-}/* CVC4::language::input namespace */
-
-namespace output {
-
-enum CVC4_PUBLIC Language {
- // SPECIAL "NON-LANGUAGE" LANGUAGES HAVE ENUM VALUE < 0
-
- /** Match the output language to the input language */
- LANG_AUTO = -1,
-
- // COMMON INPUT AND OUTPUT LANGUAGES HAVE ENUM VALUES IN [0,9]
- // AND SHOULD CORRESPOND IN PLACEMENT WITH INPUTLANGUAGE
- //
- // EVEN IF A LANGUAGE ISN'T CURRENTLY SUPPORTED AS AN INPUT OR
- // OUTPUT LANGUAGE, IF IT IS "IN PRINCIPLE" A COMMON LANGUAGE,
- // INCLUDE IT HERE
-
- /** The SMTLIB v1 output language */
- LANG_SMTLIB_V1 = input::LANG_SMTLIB_V1,
- /** The SMTLIB v2.0 output language */
- LANG_SMTLIB_V2_0 = input::LANG_SMTLIB_V2_0,
- /** The SMTLIB v2.5 output language */
- LANG_SMTLIB_V2_5 = input::LANG_SMTLIB_V2_5,
- /** Backward-compatibility for enumeration naming */
- LANG_SMTLIB_V2 = input::LANG_SMTLIB_V2,
- /** The TPTP output language */
- LANG_TPTP = input::LANG_TPTP,
- /** The CVC4 output language */
- LANG_CVC4 = input::LANG_CVC4,
- /** The Z3-str output language */
- LANG_Z3STR = input::LANG_Z3STR,
- /** The sygus output language */
- LANG_SYGUS = input::LANG_SYGUS,
-
- // START OUTPUT-ONLY LANGUAGES AT ENUM VALUE 10
- // THESE ARE IN PRINCIPLE NOT POSSIBLE INPUT LANGUAGES
-
- /** The AST output language */
- LANG_AST = 10,
- /** The CVC3-compatibility output language */
- LANG_CVC3,
-
- /** LANG_MAX is > any valid OutputLanguage id */
- LANG_MAX
-};/* enum Language */
-
-inline std::ostream& operator<<(std::ostream& out, Language lang) CVC4_PUBLIC;
-inline std::ostream& operator<<(std::ostream& out, Language lang) {
- switch(lang) {
- case LANG_SMTLIB_V1:
- out << "LANG_SMTLIB_V1";
- break;
- case LANG_SMTLIB_V2_0:
- out << "LANG_SMTLIB_V2_0";
- break;
- case LANG_SMTLIB_V2_5:
- out << "LANG_SMTLIB_V2_5";
- break;
- case LANG_TPTP:
- out << "LANG_TPTP";
- break;
- case LANG_CVC4:
- out << "LANG_CVC4";
- break;
- case LANG_Z3STR:
- out << "LANG_Z3STR";
- break;
- case LANG_SYGUS:
- out << "LANG_SYGUS";
- break;
- case LANG_AST:
- out << "LANG_AST";
- break;
- case LANG_CVC3:
- out << "LANG_CVC3";
- break;
- default:
- out << "undefined_output_language";
- }
- return out;
-}
-
-}/* CVC4::language::output namespace */
-
-}/* CVC4::language namespace */
-
-typedef language::input::Language InputLanguage;
-typedef language::output::Language OutputLanguage;
-
-namespace language {
-
-InputLanguage toInputLanguage(OutputLanguage language) CVC4_PUBLIC;
-OutputLanguage toOutputLanguage(InputLanguage language) CVC4_PUBLIC;
-InputLanguage toInputLanguage(std::string language) CVC4_PUBLIC;
-OutputLanguage toOutputLanguage(std::string language) CVC4_PUBLIC;
-
-}/* CVC4::language namespace */
-}/* CVC4 namespace */
-
-#endif /* __CVC4__LANGUAGE_H */
+++ /dev/null
-%{
-#include "util/language.h"
-%}
-
-namespace CVC4 {
- namespace language {
- namespace input {
- %ignore operator<<(std::ostream&, Language);
- }/* CVC4::language::input namespace */
-
- namespace output {
- %ignore operator<<(std::ostream&, Language);
- }/* CVC4::language::output namespace */
- }/* CVC4::language namespace */
-}/* CVC4 namespace */
-
-// These clash in the monolithic Java namespace, so we rename them.
-%rename(InputLanguage) CVC4::language::input::Language;
-%rename(OutputLanguage) CVC4::language::output::Language;
-
-%rename(INPUT_LANG_AUTO) CVC4::language::input::LANG_AUTO;
-%rename(INPUT_LANG_SMTLIB_V1) CVC4::language::input::LANG_SMTLIB_V1;
-%rename(INPUT_LANG_SMTLIB_V2) CVC4::language::input::LANG_SMTLIB_V2;
-%rename(INPUT_LANG_SMTLIB_V2_0) CVC4::language::input::LANG_SMTLIB_V2_0;
-%rename(INPUT_LANG_SMTLIB_V2_5) CVC4::language::input::LANG_SMTLIB_V2_5;
-%rename(INPUT_LANG_TPTP) CVC4::language::input::LANG_TPTP;
-%rename(INPUT_LANG_CVC4) CVC4::language::input::LANG_CVC4;
-%rename(INPUT_LANG_MAX) CVC4::language::input::LANG_MAX;
-%rename(INPUT_LANG_Z3STR) CVC4::language::input::LANG_Z3STR;
-%rename(INPUT_LANG_SYGUS) CVC4::language::input::LANG_SYGUS;
-
-%rename(OUTPUT_LANG_AUTO) CVC4::language::output::LANG_AUTO;
-%rename(OUTPUT_LANG_SMTLIB_V1) CVC4::language::output::LANG_SMTLIB_V1;
-%rename(OUTPUT_LANG_SMTLIB_V2) CVC4::language::output::LANG_SMTLIB_V2;
-%rename(OUTPUT_LANG_SMTLIB_V2_0) CVC4::language::output::LANG_SMTLIB_V2_0;
-%rename(OUTPUT_LANG_SMTLIB_V2_5) CVC4::language::output::LANG_SMTLIB_V2_5;
-%rename(OUTPUT_LANG_TPTP) CVC4::language::output::LANG_TPTP;
-%rename(OUTPUT_LANG_CVC4) CVC4::language::output::LANG_CVC4;
-%rename(OUTPUT_LANG_AST) CVC4::language::output::LANG_AST;
-%rename(OUTPUT_LANG_MAX) CVC4::language::output::LANG_MAX;
-%rename(OUTPUT_LANG_Z3STR) CVC4::language::output::LANG_Z3STR;
-%rename(OUTPUT_LANG_SYGUS) CVC4::language::output::LANG_SYGUS;
-
-%include "util/language.h"
+++ /dev/null
-/********************* */
-/*! \file lemma_input_channel.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_public.h"
-
-#ifndef __CVC4__LEMMA_INPUT_CHANNEL_H
-#define __CVC4__LEMMA_INPUT_CHANNEL_H
-
-#include "expr/expr.h"
-
-namespace CVC4 {
-
-class CVC4_PUBLIC LemmaInputChannel {
-public:
- virtual ~LemmaInputChannel() throw() { }
-
- virtual bool hasNewLemma() = 0;
- virtual Expr getNewLemma() = 0;
-
-};/* class LemmaOutputChannel */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__LEMMA_INPUT_CHANNEL_H */
+++ /dev/null
-/********************* */
-/*! \file lemma_output_channel.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 Mechanism for communication about new lemmas
- **
- ** This file defines an interface for use by the theory and propositional
- ** engines to communicate new lemmas to the "outside world," for example
- ** for lemma sharing between threads.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__LEMMA_OUTPUT_CHANNEL_H
-#define __CVC4__LEMMA_OUTPUT_CHANNEL_H
-
-#include "expr/expr.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 {
-public:
- virtual ~LemmaOutputChannel() throw() { }
-
- /**
- * Notifies this output channel that there's a new lemma.
- * The lemma may or may not be in CNF.
- */
- virtual void notifyNewLemma(Expr lemma) = 0;
-};/* class LemmaOutputChannel */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__LEMMA_OUTPUT_CHANNEL_H */
+++ /dev/null
-/********************* */
-/*! \file matcher.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 A class representing a type matcher
- **
- ** A class representing a type matcher.
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__MATCHER_H
-#define __CVC4__MATCHER_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <map>
-#include "util/cvc4_assert.h"
-#include "expr/node.h"
-#include "expr/type_node.h"
-
-namespace CVC4 {
-
-class Matcher {
-private:
- std::vector< TypeNode > d_types;
- std::vector< TypeNode > d_match;
-public:
- Matcher(){}
- Matcher( DatatypeType dt ){
- addTypesFromDatatype( dt );
- }
- ~Matcher(){}
-
- void addTypesFromDatatype( DatatypeType dt ){
- std::vector< Type > argTypes = dt.getParamTypes();
- addTypes( argTypes );
- Debug("typecheck-idt") << "instantiating matcher for " << dt << std::endl;
- for(unsigned i = 0; i < argTypes.size(); ++i) {
- if(dt.isParameterInstantiated(i)) {
- Debug("typecheck-idt") << "++ instantiate param " << i << " : " << d_types[i] << std::endl;
- d_match[i] = d_types[i];
- }
- }
- }
- void addType( Type t ){
- d_types.push_back( TypeNode::fromType( t ) );
- d_match.push_back( TypeNode::null() );
- }
- void addTypes( std::vector< Type > types ){
- for( int i=0; i<(int)types.size(); i++ ){
- addType( types[i] );
- }
- }
-
- bool doMatching( TypeNode pattern, TypeNode tn ){
- Debug("typecheck-idt") << "doMatching() : " << pattern << " : " << tn << std::endl;
- std::vector< TypeNode >::iterator i = std::find( d_types.begin(), d_types.end(), pattern );
- if( i!=d_types.end() ){
- int index = i - d_types.begin();
- if( !d_match[index].isNull() ){
- Debug("typecheck-idt") << "check subtype " << tn << " " << d_match[index] << std::endl;
- TypeNode tnn = TypeNode::leastCommonTypeNode( tn, d_match[index] );
- //recognize subtype relation
- if( !tnn.isNull() ){
- d_match[index] = tnn;
- return true;
- }else{
- return false;
- }
- }else{
- d_match[ i - d_types.begin() ] = tn;
- return true;
- }
- }else if( pattern==tn ){
- return true;
- }else if( pattern.getKind()!=tn.getKind() || pattern.getNumChildren()!=tn.getNumChildren() ){
- return false;
- }else{
- for( int i=0; i<(int)pattern.getNumChildren(); i++ ){
- if( !doMatching( pattern[i], tn[i] ) ){
- return false;
- }
- }
- return true;
- }
- }
-
- TypeNode getMatch( unsigned int i ){ return d_match[i]; }
- void getTypes( std::vector<Type>& types ) {
- types.clear();
- for( int i=0; i<(int)d_match.size(); i++ ){
- types.push_back( d_types[i].toType() );
- }
- }
- void getMatches( std::vector<Type>& types ) {
- types.clear();
- for( int i=0; i<(int)d_match.size(); i++ ){
- if(d_match[i].isNull()) {
- types.push_back( d_types[i].toType() );
- } else {
- types.push_back( d_match[i].toType() );
- }
- }
- }
-};/* class Matcher */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__MATCHER_H */
#pragma once
#include <ostream>
-#include "util/exception.h"
+
+#include "base/exception.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file model.cpp
- ** \verbatim
- ** Original author: Andrew Reynolds
- ** 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 implementation of Model class
- **/
-
-#include "util/model.h"
-#include "expr/command.h"
-#include "smt/smt_engine_scope.h"
-#include "smt/command_list.h"
-#include "printer/printer.h"
-
-#include <vector>
-
-using namespace std;
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, const Model& m) {
- smt::SmtScope smts(&m.d_smt);
- Expr::dag::Scope scope(out, false);
- Printer::getPrinter(options::outputLanguage())->toStream(out, m);
- return out;
-}
-
-Model::Model() :
- d_smt(*smt::currentSmtEngine()) {
-}
-
-size_t Model::getNumCommands() const {
- return d_smt.d_modelCommands->size() + d_smt.d_modelGlobalCommands.size();
-}
-
-const Command* Model::getCommand(size_t i) const {
- Assert(i < getNumCommands());
- // index the global commands first, then the locals
- if(i < d_smt.d_modelGlobalCommands.size()) {
- return d_smt.d_modelGlobalCommands[i];
- } else {
- return (*d_smt.d_modelCommands)[i - d_smt.d_modelGlobalCommands.size()];
- }
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file model.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 Model class
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__MODEL_H
-#define __CVC4__MODEL_H
-
-#include <iostream>
-#include <vector>
-
-#include "expr/expr.h"
-#include "util/cardinality.h"
-
-namespace CVC4 {
-
-class Command;
-class SmtEngine;
-class Model;
-
-std::ostream& operator<<(std::ostream&, const Model&);
-
-class Model {
- friend std::ostream& operator<<(std::ostream&, const Model&);
- friend class SmtEngine;
-
- /** the input name (file name, etc.) this model is associated to */
- std::string d_inputName;
-
-protected:
- /** The SmtEngine we're associated with */
- SmtEngine& d_smt;
-
- /** construct the base class; users cannot do this, only CVC4 internals */
- Model();
-
-public:
- /** virtual destructor */
- virtual ~Model() { }
- /** get number of commands to report */
- size_t getNumCommands() const;
- /** get command */
- const Command* getCommand(size_t i) const;
- /** get the smt engine that this model is hooked up to */
- SmtEngine* getSmtEngine() { return &d_smt; }
- /** get the smt engine (as a pointer-to-const) that this model is hooked up to */
- const SmtEngine* getSmtEngine() const { return &d_smt; }
- /** get the input name (file name, etc.) this model is associated to */
- std::string getInputName() const { return d_inputName; }
-
-public:
- /** get value for expression */
- virtual Expr getValue(Expr expr) const = 0;
- /** get cardinality for sort */
- virtual Cardinality getCardinality(Type t) const = 0;
-};/* class Model */
-
-class ModelBuilder {
-public:
- ModelBuilder() { }
- virtual ~ModelBuilder() { }
- virtual void buildModel(Model* m, bool fullModel) = 0;
-};/* class ModelBuilder */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__MODEL_H */
+++ /dev/null
-/********************* */
-/*! \file nary_builder.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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-
-#include "util/nary_builder.h"
-#include "expr/metakind.h"
-using namespace std;
-
-namespace CVC4 {
-namespace util {
-
-Node NaryBuilder::mkAssoc(Kind kind, const std::vector<Node>& children){
- if(children.size() == 0){
- return zeroArity(kind);
- }else if(children.size() == 1){
- return children[0];
- }else{
- const unsigned int max = kind::metakind::getUpperBoundForKind(kind);
- const unsigned int min = kind::metakind::getLowerBoundForKind(kind);
-
- Assert(min <= children.size());
-
- unsigned int numChildren = children.size();
- NodeManager* nm = NodeManager::currentNM();
- if( numChildren <= max ) {
- return nm->mkNode(kind,children);
- }
-
- typedef std::vector<Node>::const_iterator const_iterator;
- const_iterator it = children.begin() ;
- const_iterator end = children.end() ;
-
- /* The new top-level children and the children of each sub node */
- std::vector<Node> newChildren;
- std::vector<Node> subChildren;
-
- while( it != end && numChildren > max ) {
- /* Grab the next max children and make a node for them. */
- for(const_iterator next = it + max; it != next; ++it, --numChildren ) {
- subChildren.push_back(*it);
- }
- Node subNode = nm->mkNode(kind,subChildren);
- newChildren.push_back(subNode);
- subChildren.clear();
- }
-
- /* If there's children left, "top off" the Expr. */
- if(numChildren > 0) {
- /* If the leftovers are too few, just copy them into newChildren;
- * otherwise make a new sub-node */
- if(numChildren < min) {
- for(; it != end; ++it) {
- newChildren.push_back(*it);
- }
- } else {
- for(; it != end; ++it) {
- subChildren.push_back(*it);
- }
- Node subNode = nm->mkNode(kind, subChildren);
- newChildren.push_back(subNode);
- }
- }
-
- /* It's inconceivable we could have enough children for this to fail
- * (more than 2^32, in most cases?). */
- AlwaysAssert( newChildren.size() <= max,
- "Too many new children in mkAssociative" );
-
- /* It would be really weird if this happened (it would require
- * min > 2, for one thing), but let's make sure. */
- AlwaysAssert( newChildren.size() >= min,
- "Too few new children in mkAssociative" );
-
- return nm->mkNode(kind,newChildren);
- }
-}
-
-Node NaryBuilder::zeroArity(Kind k){
- using namespace kind;
- NodeManager* nm = NodeManager::currentNM();
- switch(k){
- case AND:
- return nm->mkConst(true);
- case OR:
- return nm->mkConst(false);
- case PLUS:
- return nm->mkConst(Rational(0));
- case MULT:
- return nm->mkConst(Rational(1));
- default:
- return Node::null();
- }
-}
-
-
-RePairAssocCommutativeOperators::RePairAssocCommutativeOperators()
- : d_cache()
-{}
-RePairAssocCommutativeOperators::~RePairAssocCommutativeOperators(){}
-size_t RePairAssocCommutativeOperators::size() const{ return d_cache.size(); }
-void RePairAssocCommutativeOperators::clear(){ d_cache.clear(); }
-
-bool RePairAssocCommutativeOperators::isAssociateCommutative(Kind k){
- using namespace kind;
- switch(k){
- case BITVECTOR_CONCAT:
- case BITVECTOR_AND:
- case BITVECTOR_OR:
- case BITVECTOR_XOR:
- case BITVECTOR_MULT:
- case BITVECTOR_PLUS:
- case DISTINCT:
- case PLUS:
- case MULT:
- case AND:
- case OR:
- return true;
- default:
- return false;
- }
-}
-
-Node RePairAssocCommutativeOperators::rePairAssocCommutativeOperators(TNode n){
- if(d_cache.find(n) != d_cache.end()){
- return d_cache[n];
- }
- Node result =
- isAssociateCommutative(n.getKind()) ?
- case_assoccomm(n) : case_other(n);
-
- d_cache[n] = result;
- return result;
-}
-
-Node RePairAssocCommutativeOperators::case_assoccomm(TNode n){
- Kind k = n.getKind();
- Assert(isAssociateCommutative(k));
- Assert(n.getMetaKind() != kind::metakind::PARAMETERIZED);
- unsigned N = n.getNumChildren();
- Assert(N >= 2);
-
-
- Node last = rePairAssocCommutativeOperators( n[N-1]);
- Node nextToLast = rePairAssocCommutativeOperators(n[N-2]);
-
- NodeManager* nm = NodeManager::currentNM();
- Node last2 = nm->mkNode(k, nextToLast, last);
-
- if(N <= 2){
- return last2;
- } else{
- Assert(N > 2);
- Node prevRound = last2;
- for(unsigned prevPos = N-2; prevPos > 0; --prevPos){
- unsigned currPos = prevPos-1;
- Node curr = rePairAssocCommutativeOperators(n[currPos]);
- Node round = nm->mkNode(k, curr, prevRound);
- prevRound = round;
- }
- return prevRound;
- }
-}
-
-Node RePairAssocCommutativeOperators::case_other(TNode n){
- if(n.isConst() || n.isVar()){
- return n;
- }
-
- NodeBuilder<> nb(n.getKind());
-
- if(n.getMetaKind() == kind::metakind::PARAMETERIZED) {
- nb << n.getOperator();
- }
-
- // Remove the ITEs from the children
- for(TNode::const_iterator i = n.begin(), end = n.end(); i != end; ++i) {
- Node newChild = rePairAssocCommutativeOperators(*i);
- nb << newChild;
- }
-
- Node result = (Node)nb;
- return result;
-}
-
-}/* util namespace */
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file nary_builder.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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-
-#include "cvc4_private.h"
-
-#pragma once
-
-#include <vector>
-#include "expr/node.h"
-
-namespace CVC4{
-namespace util {
-
-class NaryBuilder {
-public:
- static Node mkAssoc(Kind k, const std::vector<Node>& children);
- static Node zeroArity(Kind k);
-};/* class NaryBuilder */
-
-class RePairAssocCommutativeOperators {
-public:
- RePairAssocCommutativeOperators();
- ~RePairAssocCommutativeOperators();
-
- Node rePairAssocCommutativeOperators(TNode n);
-
- static bool isAssociateCommutative(Kind k);
-
- size_t size() const;
- void clear();
-private:
- Node case_assoccomm(TNode n);
- Node case_other(TNode n);
-
- typedef std::hash_map<Node, Node, NodeHashFunction> NodeMap;
- NodeMap d_cache;
-};/* class RePairAssocCommutativeOperators */
-
-}/* util namespace */
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file node_visitor.h
- ** \verbatim
- ** Original author: Dejan Jovanovic
- ** Major contributors: Liana Hadarean, 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 A simple visitor for nodes
- **
- ** A simple visitor for nodes.
- **/
-
-#pragma once
-
-#include "cvc4_private.h"
-
-#include <vector>
-#include "expr/node.h"
-
-namespace CVC4 {
-
-/**
- * Traverses the nodes reverse-topologically (children before parents),
- * calling the visitor in order.
- */
-template<typename Visitor>
-class NodeVisitor {
-
- /** For re-entry checking */
- static CVC4_THREADLOCAL(bool) s_inRun;
-
- /**
- * Guard against NodeVisitor<> being re-entrant.
- */
- template <class T>
- class GuardReentry {
- T& d_guard;
- public:
- GuardReentry(T& guard)
- : d_guard(guard) {
- Assert(!d_guard);
- d_guard = true;
- }
- ~GuardReentry() {
- Assert(d_guard);
- d_guard = false;
- }
- };/* class NodeVisitor<>::GuardReentry */
-
-public:
-
- /**
- * Element of the stack.
- */
- struct stack_element {
- /** The node to be visited */
- TNode node;
- /** The parent of the node */
- TNode parent;
- /** Have the children been queued up for visitation */
- bool children_added;
- stack_element(TNode node, TNode parent)
- : node(node), parent(parent), children_added(false) {}
- };/* struct preprocess_stack_element */
-
- /**
- * Performs the traversal.
- */
- static typename Visitor::return_type run(Visitor& visitor, TNode node) {
-
- GuardReentry<CVC4_THREADLOCAL_TYPE(bool)> guard(s_inRun);
-
- // Notify of a start
- visitor.start(node);
-
- // Do a reverse-topological sort of the subexpressions
- std::vector<stack_element> toVisit;
- toVisit.push_back(stack_element(node, node));
- while (!toVisit.empty()) {
- stack_element& stackHead = toVisit.back();
- // The current node we are processing
- TNode current = stackHead.node;
- TNode parent = stackHead.parent;
-
- if (visitor.alreadyVisited(current, parent)) {
- // If already visited, we're done
- toVisit.pop_back();
- } else if (stackHead.children_added) {
- // Call the visitor
- visitor.visit(current, parent);
- // Done with this node, remove from the stack
- toVisit.pop_back();
- } else {
- // Mark that we have added the children
- stackHead.children_added = true;
- // We need to add the children
- for(TNode::iterator child_it = current.begin(); child_it != current.end(); ++ child_it) {
- TNode childNode = *child_it;
- if (!visitor.alreadyVisited(childNode, current)) {
- toVisit.push_back(stack_element(childNode, current));
- }
- }
- }
- }
-
- // Notify that we're done
- return visitor.done(node);
- }
-
-};/* class NodeVisitor<> */
-
-template <typename Visitor>
-CVC4_THREADLOCAL(bool) NodeVisitor<Visitor>::s_inRun = false;
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file output.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 Output utility classes and functions
- **
- ** Output utility classes and functions.
- **/
-
-#include "util/output.h"
-
-#include <iostream>
-
-using namespace std;
-
-namespace CVC4 {
-
-/* Definitions of the declared globals from output.h... */
-
-null_streambuf null_sb;
-ostream null_os(&null_sb);
-
-NullC nullCvc4Stream CVC4_PUBLIC;
-
-const std::string CVC4ostream::s_tab = " ";
-const int CVC4ostream::s_indentIosIndex = ios_base::xalloc();
-
-DebugC DebugChannel CVC4_PUBLIC (&cout);
-WarningC WarningChannel CVC4_PUBLIC (&cerr);
-MessageC MessageChannel CVC4_PUBLIC (&cout);
-NoticeC NoticeChannel CVC4_PUBLIC (&null_os);
-ChatC ChatChannel CVC4_PUBLIC (&null_os);
-TraceC TraceChannel CVC4_PUBLIC (&cout);
-std::ostream DumpOutC::dump_cout(cout.rdbuf());// copy cout stream buffer
-DumpOutC DumpOutChannel CVC4_PUBLIC (&DumpOutC::dump_cout);
-
-#ifndef CVC4_MUZZLE
-
-# if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
-
-int DebugC::printf(const char* tag, const char* fmt, ...) {
- if(d_tags.find(string(tag)) == d_tags.end()) {
- return 0;
- }
-
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-int DebugC::printf(std::string tag, const char* fmt, ...) {
- if(d_tags.find(tag) == d_tags.end()) {
- return 0;
- }
-
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-# endif /* CVC4_DEBUG && CVC4_TRACING */
-
-int WarningC::printf(const char* fmt, ...) {
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-int MessageC::printf(const char* fmt, ...) {
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-int NoticeC::printf(const char* fmt, ...) {
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-int ChatC::printf(const char* fmt, ...) {
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-# ifdef CVC4_TRACING
-
-int TraceC::printf(const char* tag, const char* fmt, ...) {
- if(d_tags.find(string(tag)) == d_tags.end()) {
- return 0;
- }
-
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-int TraceC::printf(std::string tag, const char* fmt, ...) {
- if(d_tags.find(tag) == d_tags.end()) {
- return 0;
- }
-
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-# endif /* CVC4_TRACING */
-
-# ifdef CVC4_DUMPING
-
-int DumpOutC::printf(const char* tag, const char* fmt, ...) {
- if(d_tags.find(string(tag)) == d_tags.end()) {
- return 0;
- }
-
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-int DumpOutC::printf(std::string tag, const char* fmt, ...) {
- if(d_tags.find(tag) == d_tags.end()) {
- return 0;
- }
-
- // chop off output after 1024 bytes
- char buf[1024];
- va_list vl;
- va_start(vl, fmt);
- int retval = vsnprintf(buf, sizeof(buf), fmt, vl);
- va_end(vl);
- *d_os << buf;
- return retval;
-}
-
-# endif /* CVC4_DUMPING */
-
-#endif /* ! CVC4_MUZZLE */
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file output.h
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: none
- ** Minor contributors (to current version): Tim King, Dejan Jovanovic
- ** 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 Output utility classes and functions
- **
- ** Output utility classes and functions.
- **/
-
-#include "cvc4_private_library.h"
-
-#ifndef __CVC4__OUTPUT_H
-#define __CVC4__OUTPUT_H
-
-#include <ios>
-#include <iostream>
-#include <streambuf>
-#include <string>
-#include <cstdio>
-#include <cstdarg>
-#include <set>
-#include <utility>
-
-namespace CVC4 {
-
-template <class T, class U>
-std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) CVC4_PUBLIC;
-
-template <class T, class U>
-std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) {
- return out << "[" << p.first << "," << p.second << "]";
-}
-
-/**
- * A utility class to provide (essentially) a "/dev/null" streambuf.
- * If debugging support is compiled in, but debugging for
- * e.g. "parser" is off, then Debug("parser") returns a stream
- * attached to a null_streambuf instance so that output is directed to
- * the bit bucket.
- */
-class CVC4_PUBLIC null_streambuf : public std::streambuf {
-public:
- /* Overriding overflow() just ensures that EOF isn't returned on the
- * stream. Perhaps this is not so critical, but recommended; this
- * way the output stream looks like it's functioning, in a non-error
- * state. */
- int overflow(int c) { return c; }
-};/* class null_streambuf */
-
-/** A null stream-buffer singleton */
-extern null_streambuf null_sb;
-/** A null output stream singleton */
-extern std::ostream null_os CVC4_PUBLIC;
-
-class CVC4_PUBLIC CVC4ostream {
- static const std::string s_tab;
- static const int s_indentIosIndex;
-
- /** The underlying ostream */
- std::ostream* d_os;
- /** Are we in the first column? */
- bool d_firstColumn;
-
- /** The endl manipulator (why do we need to keep this?) */
- std::ostream& (*const d_endl)(std::ostream&);
-
- // do not allow use
- CVC4ostream& operator=(const CVC4ostream&);
-
-public:
- CVC4ostream() :
- d_os(NULL),
- d_firstColumn(false),
- d_endl(&std::endl) {
- }
- explicit CVC4ostream(std::ostream* os) :
- d_os(os),
- d_firstColumn(true),
- d_endl(&std::endl) {
- }
-
- void pushIndent() {
- if(d_os != NULL) {
- ++d_os->iword(s_indentIosIndex);
- }
- }
- void popIndent() {
- if(d_os != NULL) {
- long& indent = d_os->iword(s_indentIosIndex);
- if(indent > 0) {
- --indent;
- }
- }
- }
-
- CVC4ostream& flush() {
- if(d_os != NULL) {
- d_os->flush();
- }
- return *this;
- }
-
- bool isConnected() { return d_os != NULL; }
- operator std::ostream&() { return isConnected() ? *d_os : null_os; }
-
- template <class T>
- CVC4ostream& operator<<(T const& t) CVC4_PUBLIC;
-
- // support manipulators, endl, etc..
- CVC4ostream& operator<<(std::ostream& (*pf)(std::ostream&)) {
- if(d_os != NULL) {
- d_os = &(*d_os << pf);
-
- if(pf == d_endl) {
- d_firstColumn = true;
- }
- }
- return *this;
- }
- CVC4ostream& operator<<(std::ios& (*pf)(std::ios&)) {
- if(d_os != NULL) {
- d_os = &(*d_os << pf);
- }
- return *this;
- }
- CVC4ostream& operator<<(std::ios_base& (*pf)(std::ios_base&)) {
- if(d_os != NULL) {
- d_os = &(*d_os << pf);
- }
- return *this;
- }
- CVC4ostream& operator<<(CVC4ostream& (*pf)(CVC4ostream&)) {
- return pf(*this);
- }
-};/* class CVC4ostream */
-
-inline CVC4ostream& push(CVC4ostream& stream) {
- stream.pushIndent();
- return stream;
-}
-
-inline CVC4ostream& pop(CVC4ostream& stream) {
- stream.popIndent();
- return stream;
-}
-
-template <class T>
-CVC4ostream& CVC4ostream::operator<<(T const& t) {
- if(d_os != NULL) {
- if(d_firstColumn) {
- d_firstColumn = false;
- long indent = d_os->iword(s_indentIosIndex);
- for(long i = 0; i < indent; ++i) {
- d_os = &(*d_os << s_tab);
- }
- }
- d_os = &(*d_os << t);
- }
- return *this;
-}
-
-/**
- * Does nothing; designed for compilation of non-debug/non-trace
- * builds. None of these should ever be called in such builds, but we
- * offer this to the compiler so it doesn't complain.
- */
-class CVC4_PUBLIC NullC {
-public:
- operator bool() { return false; }
- operator CVC4ostream() { return CVC4ostream(); }
- operator std::ostream&() { return null_os; }
-};/* class NullC */
-
-extern NullC nullCvc4Stream CVC4_PUBLIC;
-
-/** The debug output class */
-class CVC4_PUBLIC DebugC {
- std::set<std::string> d_tags;
- std::ostream* d_os;
-
-public:
- explicit DebugC(std::ostream* os) : d_os(os) {}
-
- int printf(const char* tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
- int printf(std::string tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
-
- CVC4ostream operator()(const char* tag) {
- if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
- return CVC4ostream(d_os);
- } else {
- return CVC4ostream();
- }
- }
- CVC4ostream operator()(std::string tag) {
- if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
- return CVC4ostream(d_os);
- } else {
- return CVC4ostream();
- }
- }
-
- bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
- bool on (std::string tag) { d_tags.insert(tag); return true; }
- bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
- bool off(std::string tag) { d_tags.erase (tag); return false; }
- bool off() { d_tags.clear(); return false; }
-
- bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
- bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
-
- std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
- std::ostream& getStream() { return *d_os; }
-};/* class DebugC */
-
-/** The warning output class */
-class CVC4_PUBLIC WarningC {
- std::set< std::pair<const char*, size_t> > d_alreadyWarned;
- std::ostream* d_os;
-
-public:
- explicit WarningC(std::ostream* os) : d_os(os) {}
-
- int printf(const char* fmt, ...) __attribute__ ((format(printf, 2, 3)));
-
- CVC4ostream operator()() { return CVC4ostream(d_os); }
-
- std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
- std::ostream& getStream() { return *d_os; }
-
- bool isOn() const { return d_os != &null_os; }
-
- // This function supports the WarningOnce() macro, which allows you
- // to easily indicate that a warning should be emitted, but only
- // once for a given run of CVC4.
- bool warnOnce(const char* file, size_t line) {
- std::pair<const char*, size_t> pr = std::make_pair(file, line);
- if(d_alreadyWarned.find(pr) != d_alreadyWarned.end()) {
- // signal caller not to warn again
- return false;
- }
-
- // okay warn this time, but don't do it again
- d_alreadyWarned.insert(pr);
- return true;
- }
-
-};/* class WarningC */
-
-/** The message output class */
-class CVC4_PUBLIC MessageC {
- std::ostream* d_os;
-
-public:
- explicit MessageC(std::ostream* os) : d_os(os) {}
-
- int printf(const char* fmt, ...) __attribute__ ((format(printf, 2, 3)));
-
- CVC4ostream operator()() { return CVC4ostream(d_os); }
-
- std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
- std::ostream& getStream() { return *d_os; }
-
- bool isOn() const { return d_os != &null_os; }
-};/* class MessageC */
-
-/** The notice output class */
-class CVC4_PUBLIC NoticeC {
- std::ostream* d_os;
-
-public:
- explicit NoticeC(std::ostream* os) : d_os(os) {}
-
- int printf(const char* fmt, ...) __attribute__ ((format(printf, 2, 3)));
-
- CVC4ostream operator()() { return CVC4ostream(d_os); }
-
- std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
- std::ostream& getStream() { return *d_os; }
-
- bool isOn() const { return d_os != &null_os; }
-};/* class NoticeC */
-
-/** The chat output class */
-class CVC4_PUBLIC ChatC {
- std::ostream* d_os;
-
-public:
- explicit ChatC(std::ostream* os) : d_os(os) {}
-
- int printf(const char* fmt, ...) __attribute__ ((format(printf, 2, 3)));
-
- CVC4ostream operator()() { return CVC4ostream(d_os); }
-
- std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
- std::ostream& getStream() { return *d_os; }
-
- bool isOn() const { return d_os != &null_os; }
-};/* class ChatC */
-
-/** The trace output class */
-class CVC4_PUBLIC TraceC {
- std::ostream* d_os;
- std::set<std::string> d_tags;
-
-public:
- explicit TraceC(std::ostream* os) : d_os(os) {}
-
- int printf(const char* tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
- int printf(std::string tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
-
- CVC4ostream operator()(const char* tag) {
- if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
- return CVC4ostream(d_os);
- } else {
- return CVC4ostream();
- }
- }
-
- CVC4ostream operator()(std::string tag) {
- if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
- return CVC4ostream(d_os);
- } else {
- return CVC4ostream();
- }
- }
-
- bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
- bool on (std::string tag) { d_tags.insert(tag); return true; }
- bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
- bool off(std::string tag) { d_tags.erase (tag); return false; }
- bool off() { d_tags.clear(); return false; }
-
- bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
- bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
-
- std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
- std::ostream& getStream() { return *d_os; }
-};/* class TraceC */
-
-/** The dump output class */
-class CVC4_PUBLIC DumpOutC {
- std::set<std::string> d_tags;
- std::ostream* d_os;
-
-public:
- /**
- * A copy of cout for use by the dumper. This is important because
- * it has different settings (e.g., the expr printing depth is always
- * unlimited). */
- static std::ostream dump_cout;
-
- explicit DumpOutC(std::ostream* os) : d_os(os) {}
-
- int printf(const char* tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
- int printf(std::string tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
-
- CVC4ostream operator()(const char* tag) {
- if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
- return CVC4ostream(d_os);
- } else {
- return CVC4ostream();
- }
- }
- CVC4ostream operator()(std::string tag) {
- if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
- return CVC4ostream(d_os);
- } else {
- return CVC4ostream();
- }
- }
-
- bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
- bool on (std::string tag) { d_tags.insert(tag); return true; }
- bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
- bool off(std::string tag) { d_tags.erase (tag); return false; }
- bool off() { d_tags.clear(); return false; }
-
- bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
- bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
-
- std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
- std::ostream& getStream() { return *d_os; }
-};/* class DumpOutC */
-
-/** The debug output singleton */
-extern DebugC DebugChannel CVC4_PUBLIC;
-/** The warning output singleton */
-extern WarningC WarningChannel CVC4_PUBLIC;
-/** The message output singleton */
-extern MessageC MessageChannel CVC4_PUBLIC;
-/** The notice output singleton */
-extern NoticeC NoticeChannel CVC4_PUBLIC;
-/** The chat output singleton */
-extern ChatC ChatChannel CVC4_PUBLIC;
-/** The trace output singleton */
-extern TraceC TraceChannel CVC4_PUBLIC;
-/** The dump output singleton */
-extern DumpOutC DumpOutChannel CVC4_PUBLIC;
-
-#ifdef CVC4_MUZZLE
-
-# define Debug ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DebugChannel
-# define Warning ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::WarningChannel
-# define WarningOnce ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::WarningChannel
-# define Message ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::MessageChannel
-# define Notice ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::NoticeChannel
-# define Chat ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::ChatChannel
-# define Trace ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::TraceChannel
-# define DumpOut ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DumpOutChannel
-
-inline int DebugC::printf(const char* tag, const char* fmt, ...) { return 0; }
-inline int DebugC::printf(std::string tag, const char* fmt, ...) { return 0; }
-inline int WarningC::printf(const char* fmt, ...) { return 0; }
-inline int MessageC::printf(const char* fmt, ...) { return 0; }
-inline int NoticeC::printf(const char* fmt, ...) { return 0; }
-inline int ChatC::printf(const char* fmt, ...) { return 0; }
-inline int TraceC::printf(const char* tag, const char* fmt, ...) { return 0; }
-inline int TraceC::printf(std::string tag, const char* fmt, ...) { return 0; }
-inline int DumpOutC::printf(const char* tag, const char* fmt, ...) { return 0; }
-inline int DumpOutC::printf(std::string tag, const char* fmt, ...) { return 0; }
-
-#else /* CVC4_MUZZLE */
-
-# if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
-# define Debug ::CVC4::DebugChannel
-# else /* CVC4_DEBUG && CVC4_TRACING */
-# define Debug ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DebugChannel
-inline int DebugC::printf(const char* tag, const char* fmt, ...) { return 0; }
-inline int DebugC::printf(std::string tag, const char* fmt, ...) { return 0; }
-# endif /* CVC4_DEBUG && CVC4_TRACING */
-# define Warning (! ::CVC4::WarningChannel.isOn()) ? ::CVC4::nullCvc4Stream : ::CVC4::WarningChannel
-# define WarningOnce (! ::CVC4::WarningChannel.isOn() || ! ::CVC4::WarningChannel.warnOnce(__FILE__,__LINE__)) ? ::CVC4::nullCvc4Stream : ::CVC4::WarningChannel
-# define Message (! ::CVC4::MessageChannel.isOn()) ? ::CVC4::nullCvc4Stream : ::CVC4::MessageChannel
-# define Notice (! ::CVC4::NoticeChannel.isOn()) ? ::CVC4::nullCvc4Stream : ::CVC4::NoticeChannel
-# define Chat (! ::CVC4::ChatChannel.isOn()) ? ::CVC4::nullCvc4Stream : ::CVC4::ChatChannel
-# ifdef CVC4_TRACING
-# define Trace ::CVC4::TraceChannel
-# else /* CVC4_TRACING */
-# define Trace ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::TraceChannel
-inline int TraceC::printf(const char* tag, const char* fmt, ...) { return 0; }
-inline int TraceC::printf(std::string tag, const char* fmt, ...) { return 0; }
-# endif /* CVC4_TRACING */
-# ifdef CVC4_DUMPING
-# define DumpOut ::CVC4::DumpOutChannel
-# else /* CVC4_DUMPING */
-# define DumpOut ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DumpOutChannel
-inline int DumpOutC::printf(const char* tag, const char* fmt, ...) { return 0; }
-inline int DumpOutC::printf(std::string tag, const char* fmt, ...) { return 0; }
-# endif /* CVC4_DUMPING */
-
-#endif /* CVC4_MUZZLE */
-
-// Disallow e.g. !Debug("foo").isOn() forms
-// because the ! will apply before the ? .
-// If a compiler error has directed you here,
-// just parenthesize it e.g. !(Debug("foo").isOn())
-class __cvc4_true {
- void operator!() CVC4_UNUSED;
- void operator~() CVC4_UNUSED;
- void operator-() CVC4_UNUSED;
- void operator+() CVC4_UNUSED;
-public:
- inline operator bool() { return true; }
-};/* __cvc4_true */
-
-#if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
-
-class CVC4_PUBLIC ScopedDebug {
- std::string d_tag;
- bool d_oldSetting;
-
-public:
-
- ScopedDebug(std::string tag, bool newSetting = true) :
- d_tag(tag) {
- d_oldSetting = Debug.isOn(d_tag);
- if(newSetting) {
- Debug.on(d_tag);
- } else {
- Debug.off(d_tag);
- }
- }
-
- ScopedDebug(const char* tag, bool newSetting = true) :
- d_tag(tag) {
- d_oldSetting = Debug.isOn(d_tag);
- if(newSetting) {
- Debug.on(d_tag);
- } else {
- Debug.off(d_tag);
- }
- }
-
- ~ScopedDebug() {
- if(d_oldSetting) {
- Debug.on(d_tag);
- } else {
- Debug.off(d_tag);
- }
- }
-};/* class ScopedDebug */
-
-#else /* CVC4_DEBUG && CVC4_TRACING */
-
-class CVC4_PUBLIC ScopedDebug {
-public:
- ScopedDebug(std::string tag, bool newSetting = true) {}
- ScopedDebug(const char* tag, bool newSetting = true) {}
-};/* class ScopedDebug */
-
-#endif /* CVC4_DEBUG && CVC4_TRACING */
-
-#ifdef CVC4_TRACING
-
-class CVC4_PUBLIC ScopedTrace {
- std::string d_tag;
- bool d_oldSetting;
-
-public:
-
- ScopedTrace(std::string tag, bool newSetting = true) :
- d_tag(tag) {
- d_oldSetting = Trace.isOn(d_tag);
- if(newSetting) {
- Trace.on(d_tag);
- } else {
- Trace.off(d_tag);
- }
- }
-
- ScopedTrace(const char* tag, bool newSetting = true) :
- d_tag(tag) {
- d_oldSetting = Trace.isOn(d_tag);
- if(newSetting) {
- Trace.on(d_tag);
- } else {
- Trace.off(d_tag);
- }
- }
-
- ~ScopedTrace() {
- if(d_oldSetting) {
- Trace.on(d_tag);
- } else {
- Trace.off(d_tag);
- }
- }
-};/* class ScopedTrace */
-
-#else /* CVC4_TRACING */
-
-class CVC4_PUBLIC ScopedTrace {
-public:
- ScopedTrace(std::string tag, bool newSetting = true) {}
- ScopedTrace(const char* tag, bool newSetting = true) {}
-};/* class ScopedTrace */
-
-#endif /* CVC4_TRACING */
-
-/**
- * Pushes an indentation level on construction, pop on destruction.
- * Useful for tracing recursive functions especially, but also can be
- * used for clearly separating different phases of an algorithm,
- * or iterations of a loop, or... etc.
- */
-class CVC4_PUBLIC IndentedScope {
- CVC4ostream d_out;
-public:
- inline IndentedScope(CVC4ostream out);
- inline ~IndentedScope();
-};/* class IndentedScope */
-
-#if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
-inline IndentedScope::IndentedScope(CVC4ostream out) : d_out(out) { d_out << push; }
-inline IndentedScope::~IndentedScope() { d_out << pop; }
-#else /* CVC4_DEBUG && CVC4_TRACING */
-inline IndentedScope::IndentedScope(CVC4ostream out) {}
-inline IndentedScope::~IndentedScope() {}
-#endif /* CVC4_DEBUG && CVC4_TRACING */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__OUTPUT_H */
+++ /dev/null
-/********************* */
-/*! \file predicate.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 Representation of predicates for predicate subtyping
- **
- ** Simple class to represent predicates for predicate subtyping.
- ** Instances of this class are carried as the payload of
- ** the CONSTANT-metakinded SUBTYPE_TYPE types.
- **/
-
-#include "expr/expr.h"
-#include "util/predicate.h"
-#include "util/cvc4_assert.h"
-
-using namespace std;
-
-namespace CVC4 {
-
-Predicate::Predicate(Expr e, Expr w) throw(IllegalArgumentException) : d_predicate(e), d_witness(w) {
- CheckArgument(! e.isNull(), e, "Predicate cannot be null");
- CheckArgument(e.getType().isPredicate(), e, "Expression given is not predicate");
- CheckArgument(FunctionType(e.getType()).getArgTypes().size() == 1, e, "Expression given is not predicate of a single argument");
-}
-
-Predicate::operator Expr() const {
- return d_predicate;
-}
-
-bool Predicate::operator==(const Predicate& p) const {
- return d_predicate == p.d_predicate && d_witness == p.d_witness;
-}
-
-std::ostream&
-operator<<(std::ostream& out, const Predicate& p) {
- out << p.d_predicate;
- if(! p.d_witness.isNull()) {
- out << " : " << p.d_witness;
- }
- return out;
-}
-
-size_t PredicateHashFunction::operator()(const Predicate& p) const {
- ExprHashFunction h;
- return h(p.d_witness) * 5039 + h(p.d_predicate);
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file predicate.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 Representation of predicates for predicate subtyping
- **
- ** Simple class to represent predicates for predicate subtyping.
- ** Instances of this class are carried as the payload of
- ** the CONSTANT-metakinded SUBTYPE_TYPE types.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__PREDICATE_H
-#define __CVC4__PREDICATE_H
-
-#include "util/exception.h"
-
-namespace CVC4 {
-
-class Predicate;
-
-std::ostream& operator<<(std::ostream& out, const Predicate& p) CVC4_PUBLIC;
-
-struct CVC4_PUBLIC PredicateHashFunction {
- size_t operator()(const Predicate& p) const;
-};/* class PredicateHashFunction */
-
-}/* CVC4 namespace */
-
-#include "expr/expr.h"
-
-namespace CVC4 {
-
-class CVC4_PUBLIC Predicate {
-
- Expr d_predicate;
- Expr d_witness;
-
-public:
-
- Predicate(Expr e, Expr w = Expr()) throw(IllegalArgumentException);
-
- operator Expr() const;
-
- bool operator==(const Predicate& p) const;
-
- friend std::ostream& CVC4::operator<<(std::ostream& out, const Predicate& p);
- friend size_t PredicateHashFunction::operator()(const Predicate& p) const;
-
-};/* class Predicate */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__PREDICATE_H */
+++ /dev/null
-%{
-#include "util/predicate.h"
-%}
-
-%rename(equals) CVC4::Predicate::operator==(const Predicate&) const;
-%rename(toExpr) CVC4::Predicate::operator Expr() const;
-
-%rename(apply) CVC4::PredicateHashFunction::operator()(const Predicate&) const;
-
-%ignore CVC4::operator<<(std::ostream&, const Predicate&);
-
-%include "util/predicate.h"
**
** 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 !"
#include <cln/dfloat.h>
#include <cln/real.h>
-#include "util/exception.h"
+#include "base/exception.h"
#include "util/integer.h"
namespace CVC4 {
}/* CVC4 namespace */
#endif /* __CVC4__RATIONAL_H */
-
**
** 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 !"
#include <gmp.h>
#include <string>
+#include "base/exception.h"
#include "util/integer.h"
-#include "util/exception.h"
namespace CVC4 {
}/* CVC4 namespace */
#endif /* __CVC4__RATIONAL_H */
-
+++ /dev/null
-/********************* */
-/*! \file record.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 A class representing a record definition
- **
- ** A class representing a record definition.
- **/
-
-#include "util/record.h"
-
-using namespace std;
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& os, const Record& r) {
- os << "[# ";
- bool first = true;
- for(Record::iterator i = r.begin(); i != r.end(); ++i) {
- if(!first) {
- os << ", ";
- }
- os << (*i).first << ":" << (*i).second;
- first = false;
- }
- os << " #]";
-
- return os;
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file record.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 A class representing a Record definition
- **
- ** A class representing a Record definition.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__RECORD_H
-#define __CVC4__RECORD_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <utility>
-#include "util/hash.h"
-
-namespace CVC4 {
-
-class CVC4_PUBLIC Record;
-
-// operators for record select and update
-
-class CVC4_PUBLIC RecordSelect {
- std::string d_field;
-public:
- RecordSelect(const std::string& field) throw() : d_field(field) { }
- std::string getField() const throw() { return d_field; }
- bool operator==(const RecordSelect& t) const throw() { return d_field == t.d_field; }
- bool operator!=(const RecordSelect& t) const throw() { return d_field != t.d_field; }
-};/* class RecordSelect */
-
-class CVC4_PUBLIC RecordUpdate {
- std::string d_field;
-public:
- RecordUpdate(const std::string& field) throw() : d_field(field) { }
- std::string getField() const throw() { return d_field; }
- bool operator==(const RecordUpdate& t) const throw() { return d_field == t.d_field; }
- bool operator!=(const RecordUpdate& t) const throw() { return d_field != t.d_field; }
-};/* class RecordUpdate */
-
-struct CVC4_PUBLIC RecordSelectHashFunction {
- inline size_t operator()(const RecordSelect& t) const {
- return StringHashFunction()(t.getField());
- }
-};/* struct RecordSelectHashFunction */
-
-struct CVC4_PUBLIC RecordUpdateHashFunction {
- inline size_t operator()(const RecordUpdate& t) const {
- return StringHashFunction()(t.getField());
- }
-};/* struct RecordUpdateHashFunction */
-
-std::ostream& operator<<(std::ostream& out, const RecordSelect& t) CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream& out, const RecordUpdate& t) CVC4_PUBLIC;
-
-inline std::ostream& operator<<(std::ostream& out, const RecordSelect& t) {
- return out << "[" << t.getField() << "]";
-}
-
-inline std::ostream& operator<<(std::ostream& out, const RecordUpdate& t) {
- return out << "[" << t.getField() << "]";
-}
-
-}/* CVC4 namespace */
-
-#include "expr/expr.h"
-#include "expr/type.h"
-
-namespace CVC4 {
-
-// now an actual record definition
-
-class CVC4_PUBLIC Record {
- std::vector< std::pair<std::string, Type> > d_fields;
-
-public:
-
- typedef std::vector< std::pair<std::string, Type> >::const_iterator const_iterator;
- typedef const_iterator iterator;
-
- Record(const std::vector< std::pair<std::string, Type> >& fields) :
- d_fields(fields) {
- }
-
- const_iterator find(std::string name) const {
- const_iterator i;
- for(i = begin(); i != end(); ++i) {
- if((*i).first == name) {
- break;
- }
- }
- return i;
- }
-
- size_t getIndex(std::string name) const {
- const_iterator i = find(name);
- CheckArgument(i != end(), name, "requested field `%s' does not exist in record", name.c_str());
- return i - begin();
- }
-
- size_t getNumFields() const {
- return d_fields.size();
- }
-
- const_iterator begin() const {
- return d_fields.begin();
- }
-
- const_iterator end() const {
- return d_fields.end();
- }
-
- std::pair<std::string, Type> operator[](size_t index) const {
- CheckArgument(index < d_fields.size(), index, "index out of bounds for record type");
- return d_fields[index];
- }
-
- bool operator==(const Record& r) const {
- return d_fields == r.d_fields;
- }
-
- bool operator!=(const Record& r) const {
- return !(*this == r);
- }
-
-};/* class Record */
-
-struct CVC4_PUBLIC RecordHashFunction {
- inline size_t operator()(const Record& r) const {
- size_t n = 0;
- for(Record::iterator i = r.begin(); i != r.end(); ++i) {
- n = (n << 3) ^ TypeHashFunction()((*i).second);
- }
- return n;
- }
-};/* struct RecordHashFunction */
-
-std::ostream& operator<<(std::ostream& os, const Record& r) CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__RECORD_H */
+++ /dev/null
-%{
-#include "util/record.h"
-
-#ifdef SWIGJAVA
-
-#include "bindings/java_iterator_adapter.h"
-#include "bindings/java_stream_adapters.h"
-
-#endif /* SWIGJAVA */
-%}
-
-%rename(equals) CVC4::RecordSelect::operator==(const RecordSelect&) const;
-%ignore CVC4::RecordSelect::operator!=(const RecordSelect&) const;
-
-%rename(equals) CVC4::RecordUpdate::operator==(const RecordUpdate&) const;
-%ignore CVC4::RecordUpdate::operator!=(const RecordUpdate&) const;
-
-%rename(equals) CVC4::Record::operator==(const Record&) const;
-%ignore CVC4::Record::operator!=(const Record&) const;
-%rename(getField) CVC4::Record::operator[](size_t) const;
-
-%rename(apply) CVC4::RecordHashFunction::operator()(const Record&) const;
-%rename(apply) CVC4::RecordSelectHashFunction::operator()(const RecordSelect&) const;
-%rename(apply) CVC4::RecordUpdateHashFunction::operator()(const RecordUpdate&) const;
-
-%ignore CVC4::operator<<(std::ostream&, const Record&);
-%ignore CVC4::operator<<(std::ostream&, const RecordSelect&);
-%ignore CVC4::operator<<(std::ostream&, const RecordUpdate&);
-
-#ifdef SWIGJAVA
-
-// These Object arrays are always of two elements, the first is a String and the second a
-// Type. (On the C++ side, it is a std::pair<std::string, Type>.)
-%typemap(jni) std::pair<std::string, CVC4::Type> "jobjectArray";
-%typemap(jtype) std::pair<std::string, CVC4::Type> "java.lang.Object[]";
-%typemap(jstype) std::pair<std::string, CVC4::Type> "java.lang.Object[]";
-%typemap(javaout) std::pair<std::string, CVC4::Type> { return $jnicall; }
-%typemap(out) std::pair<std::string, CVC4::Type> {
- $result = jenv->NewObjectArray(2, jenv->FindClass("java/lang/Object"), $null);
- jenv->SetObjectArrayElement($result, 0, jenv->NewStringUTF($1.first.c_str()));
- jclass clazz = jenv->FindClass("edu/nyu/acsys/CVC4/Type");
- jmethodID methodid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
- jenv->SetObjectArrayElement($result, 1, jenv->NewObject(clazz, methodid, reinterpret_cast<long>(new CVC4::Type($1.second)), true));
- };
-
-// Instead of Record::begin() and end(), create an
-// iterator() method on the Java side that returns a Java-style
-// Iterator.
-%ignore CVC4::Record::begin() const;
-%ignore CVC4::Record::end() const;
-%extend CVC4::Record {
- CVC4::Type find(std::string name) const {
- CVC4::Record::const_iterator i;
- for(i = $self->begin(); i != $self->end(); ++i) {
- if((*i).first == name) {
- return (*i).second;
- }
- }
- return CVC4::Type();
- }
-
- CVC4::JavaIteratorAdapter<CVC4::Record> iterator() {
- return CVC4::JavaIteratorAdapter<CVC4::Record>(*$self);
- }
-}
-
-// Record is "iterable" on the Java side
-%typemap(javainterfaces) CVC4::Record "java.lang.Iterable<Object[]>";
-
-// the JavaIteratorAdapter should not be public, and implements Iterator
-%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::Record> "class";
-%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::Record> "java.util.Iterator<Object[]>";
-// add some functions to the Java side (do it here because there's no way to do these in C++)
-%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::Record> "
- public void remove() {
- throw new java.lang.UnsupportedOperationException();
- }
-
- public Object[] next() {
- if(hasNext()) {
- return getNext();
- } else {
- throw new java.util.NoSuchElementException();
- }
- }
-"
-// getNext() just allows C++ iterator access from Java-side next(), make it private
-%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::Record>::getNext() "private";
-
-// map the types appropriately. for records, the "payload" of the iterator is an Object[].
-// These Object arrays are always of two elements, the first is a String and the second a
-// Type. (On the C++ side, it is a std::pair<std::string, SExpr>.)
-%typemap(jni) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
-%typemap(jtype) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
-%typemap(jstype) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
-%typemap(javaout) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
-%typemap(out) CVC4::Record::const_iterator::value_type = std::pair<std::string, CVC4::Type>;
-
-#endif /* SWIGJAVA */
-
-%include "util/record.h"
-
-#ifdef SWIGJAVA
-
-%include "bindings/java_iterator_adapter.h"
-%include "bindings/java_stream_adapters.h"
-
-%template(JavaIteratorAdapter_Record) CVC4::JavaIteratorAdapter<CVC4::Record>;
-
-#endif /* SWIGJAVA */
**/
#include "util/regexp.h"
-#include <iostream>
+
#include <iomanip>
+#include <iostream>
using namespace std;
#include <set>
#include <sstream>
#include <cassert>
-//#include "util/integer.h"
-#include "util/exception.h"
+
+#include "base/exception.h"
#include "util/hash.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file resource_manager.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 Manages and updates various resource and time limits.
-**
-** Manages and updates various resource and time limits.
-**/
-
-#include "util/resource_manager.h"
-#include "util/output.h"
-#include "smt/smt_engine_scope.h"
-#include "smt/options.h"
-#include "theory/rewriter.h"
-
-using namespace CVC4;
-using namespace std;
-
-void Timer::set(uint64_t millis, bool wallTime) {
- d_ms = millis;
- Trace("limit") << "Timer::set(" << d_ms << ")" << std::endl;
- // keep track of when it was set, even if it's disabled (i.e. == 0)
- d_wall_time = wallTime;
- if (d_wall_time) {
- // Wall time
- gettimeofday(&d_wall_limit, NULL);
- Trace("limit") << "Timer::set(): it's " << d_wall_limit.tv_sec << "," << d_wall_limit.tv_usec << std::endl;
- d_wall_limit.tv_sec += millis / 1000;
- d_wall_limit.tv_usec += (millis % 1000) * 1000;
- if(d_wall_limit.tv_usec > 1000000) {
- ++d_wall_limit.tv_sec;
- d_wall_limit.tv_usec -= 1000000;
- }
- Trace("limit") << "Timer::set(): limit is at " << d_wall_limit.tv_sec << "," << d_wall_limit.tv_usec << std::endl;
- } else {
- // CPU time
- d_cpu_start_time = ((double)clock())/(CLOCKS_PER_SEC *0.001);
- d_cpu_limit = d_cpu_start_time + d_ms;
- }
-}
-
-/** Return the milliseconds elapsed since last set(). */
-uint64_t Timer::elapsedWall() const {
- Assert (d_wall_time);
- timeval tv;
- gettimeofday(&tv, NULL);
- Trace("limit") << "Timer::elapsedWallTime(): it's now " << tv.tv_sec << "," << tv.tv_usec << std::endl;
- tv.tv_sec -= d_wall_limit.tv_sec - d_ms / 1000;
- tv.tv_usec -= d_wall_limit.tv_usec - (d_ms % 1000) * 1000;
- Trace("limit") << "Timer::elapsedWallTime(): elapsed time is " << tv.tv_sec << "," << tv.tv_usec << std::endl;
- return tv.tv_sec * 1000 + tv.tv_usec / 1000;
-}
-
-uint64_t Timer::elapsedCPU() const {
- Assert (!d_wall_time);
- clock_t elapsed = ((double)clock())/(CLOCKS_PER_SEC *0.001)- d_cpu_start_time;
- Trace("limit") << "Timer::elapsedCPUTime(): elapsed time is " << elapsed << " ms" <<std::endl;
- return elapsed;
-}
-
-uint64_t Timer::elapsed() const {
- if (d_wall_time)
- return elapsedWall();
- return elapsedCPU();
-}
-
-bool Timer::expired() const {
- if (!on()) return false;
-
- if (d_wall_time) {
- timeval tv;
- gettimeofday(&tv, NULL);
- Debug("limit") << "Timer::expired(): current wall time is " << tv.tv_sec << "," << tv.tv_usec << std::endl;
- Debug("limit") << "Timer::expired(): limit wall time is " << d_wall_limit.tv_sec << "," << d_wall_limit.tv_usec << std::endl;
- if(d_wall_limit.tv_sec < tv.tv_sec ||
- (d_wall_limit.tv_sec == tv.tv_sec && d_wall_limit.tv_usec <= tv.tv_usec)) {
- Debug("limit") << "Timer::expired(): OVER LIMIT!" << std::endl;
- return true;
- }
- Debug("limit") << "Timer::expired(): within limit" << std::endl;
- return false;
- }
-
- // cpu time
- double current = ((double)clock())/(CLOCKS_PER_SEC*0.001);
- Debug("limit") << "Timer::expired(): current cpu time is " << current << std::endl;
- Debug("limit") << "Timer::expired(): limit cpu time is " << d_cpu_limit << std::endl;
- if (current >= d_cpu_limit) {
- Debug("limit") << "Timer::expired(): OVER LIMIT!" << current << std::endl;
- return true;
- }
- return false;
-}
-
-const uint64_t ResourceManager::s_resourceCount = 1000;
-
-ResourceManager::ResourceManager()
- : d_cumulativeTimer()
- , d_perCallTimer()
- , d_timeBudgetCumulative(0)
- , d_timeBudgetPerCall(0)
- , d_resourceBudgetCumulative(0)
- , d_resourceBudgetPerCall(0)
- , d_cumulativeTimeUsed(0)
- , d_cumulativeResourceUsed(0)
- , d_thisCallResourceUsed(0)
- , d_thisCallTimeBudget(0)
- , d_thisCallResourceBudget(0)
- , d_isHardLimit()
- , d_on(false)
- , d_cpuTime(false)
- , d_spendResourceCalls(0)
-{}
-
-
-void ResourceManager::setResourceLimit(uint64_t units, bool cumulative) {
- d_on = true;
- if(cumulative) {
- Trace("limit") << "ResourceManager: setting cumulative resource limit to " << units << endl;
- d_resourceBudgetCumulative = (units == 0) ? 0 : (d_cumulativeResourceUsed + units);
- d_thisCallResourceBudget = d_resourceBudgetCumulative;
- } else {
- Trace("limit") << "ResourceManager: setting per-call resource limit to " << units << endl;
- d_resourceBudgetPerCall = units;
- }
-}
-
-void ResourceManager::setTimeLimit(uint64_t millis, bool cumulative) {
- d_on = true;
- if(cumulative) {
- Trace("limit") << "ResourceManager: setting cumulative time limit to " << millis << " ms" << endl;
- d_timeBudgetCumulative = (millis == 0) ? 0 : (d_cumulativeTimeUsed + millis);
- d_cumulativeTimer.set(millis, !d_cpuTime);
- } else {
- Trace("limit") << "ResourceManager: setting per-call time limit to " << millis << " ms" << endl;
- d_timeBudgetPerCall = millis;
- // perCall timer will be set in beginCall
- }
-
-}
-
-uint64_t ResourceManager::getResourceUsage() const {
- return d_cumulativeResourceUsed;
-}
-
-uint64_t ResourceManager::getTimeUsage() const {
- if (d_timeBudgetCumulative) {
- return d_cumulativeTimer.elapsed();
- }
- return d_cumulativeTimeUsed;
-}
-
-uint64_t ResourceManager::getResourceRemaining() const {
- if (d_thisCallResourceBudget <= d_thisCallResourceUsed)
- return 0;
- return d_thisCallResourceBudget - d_thisCallResourceUsed;
-}
-
-uint64_t ResourceManager::getTimeRemaining() const {
- uint64_t time_passed = d_cumulativeTimer.elapsed();
- if (time_passed >= d_thisCallTimeBudget)
- return 0;
- return d_thisCallTimeBudget - time_passed;
-}
-
-void ResourceManager::spendResource(unsigned ammount) throw (UnsafeInterruptException) {
- ++d_spendResourceCalls;
- d_cumulativeResourceUsed += ammount;
- if (!d_on) return;
-
- Debug("limit") << "ResourceManager::spendResource()" << std::endl;
- d_thisCallResourceUsed += ammount;
- if(out()) {
- Trace("limit") << "ResourceManager::spendResource: interrupt!" << std::endl;
- Trace("limit") << " on call " << d_spendResourceCalls << std::endl;
- if (outOfTime()) {
- Trace("limit") << "ResourceManager::spendResource: elapsed time" << d_cumulativeTimer.elapsed() << std::endl;
- }
-
- if (d_isHardLimit) {
- if (smt::smtEngineInScope()) {
- theory::Rewriter::clearCaches();
- }
- throw UnsafeInterruptException();
- }
-
- // interrupt it next time resources are checked
- if (smt::smtEngineInScope()) {
- smt::currentSmtEngine()->interrupt();
- }
- }
-}
-
-void ResourceManager::beginCall() {
-
- d_perCallTimer.set(d_timeBudgetPerCall, !d_cpuTime);
- d_thisCallResourceUsed = 0;
- if (!d_on) return;
-
- if (cumulativeLimitOn()) {
- if (d_resourceBudgetCumulative) {
- d_thisCallResourceBudget = d_resourceBudgetCumulative <= d_cumulativeResourceUsed ? 0 :
- d_resourceBudgetCumulative - d_cumulativeResourceUsed;
- }
-
- if (d_timeBudgetCumulative) {
-
- AlwaysAssert(d_cumulativeTimer.on());
- // timer was on since the option was set
- d_cumulativeTimeUsed = d_cumulativeTimer.elapsed();
- d_thisCallTimeBudget = d_timeBudgetCumulative <= d_cumulativeTimeUsed? 0 :
- d_timeBudgetCumulative - d_cumulativeTimeUsed;
- d_cumulativeTimer.set(d_thisCallTimeBudget, d_cpuTime);
- }
- // we are out of resources so we shouldn't update the
- // budget for this call to the per call budget
- if (d_thisCallTimeBudget == 0 ||
- d_thisCallResourceUsed == 0)
- return;
- }
-
- if (perCallLimitOn()) {
- // take min of what's left and per-call budget
- if (d_resourceBudgetPerCall) {
- d_thisCallResourceBudget = d_thisCallResourceBudget < d_resourceBudgetPerCall && d_thisCallResourceBudget != 0 ? d_thisCallResourceBudget : d_resourceBudgetPerCall;
- }
-
- if (d_timeBudgetPerCall) {
- d_thisCallTimeBudget = d_thisCallTimeBudget < d_timeBudgetPerCall && d_thisCallTimeBudget != 0 ? d_thisCallTimeBudget : d_timeBudgetPerCall;
- }
- }
-}
-
-void ResourceManager::endCall() {
- uint64_t usedInCall = d_perCallTimer.elapsed();
- d_perCallTimer.set(0);
- d_cumulativeTimeUsed += usedInCall;
-}
-
-bool ResourceManager::cumulativeLimitOn() const {
- return d_timeBudgetCumulative || d_resourceBudgetCumulative;
-}
-
-bool ResourceManager::perCallLimitOn() const {
- return d_timeBudgetPerCall || d_resourceBudgetPerCall;
-}
-
-bool ResourceManager::outOfResources() const {
- // resource limiting not enabled
- if (d_resourceBudgetPerCall == 0 &&
- d_resourceBudgetCumulative == 0)
- return false;
-
- return getResourceRemaining() == 0;
-}
-
-bool ResourceManager::outOfTime() const {
- if (d_timeBudgetPerCall == 0 &&
- d_timeBudgetCumulative == 0)
- return false;
-
- return d_cumulativeTimer.expired() || d_perCallTimer.expired();
-}
-
-void ResourceManager::useCPUTime(bool cpu) {
- Trace("limit") << "ResourceManager::useCPUTime("<< cpu <<")\n";
- d_cpuTime = cpu;
-}
-
-void ResourceManager::setHardLimit(bool value) {
- Trace("limit") << "ResourceManager::setHardLimit("<< value <<")\n";
- d_isHardLimit = value;
-}
-
-void ResourceManager::enable(bool on) {
- Trace("limit") << "ResourceManager::enable("<< on <<")\n";
- d_on = on;
-}
+++ /dev/null
-/********************* */
-/*! \file resource_manager.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 Manages and updates various resource and time limits
-**
-** Manages and updates various resource and time limits.
-**/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__RESOURCE_MANAGER_H
-#define __CVC4__RESOURCE_MANAGER_H
-
-#include <cstddef>
-#include <sys/time.h>
-
-#include "util/exception.h"
-#include "util/unsafe_interrupt_exception.h"
-
-namespace CVC4 {
-
-/**
- * A helper class to keep track of a time budget and signal
- * the PropEngine when the budget expires.
- */
-class CVC4_PUBLIC Timer {
-
- uint64_t d_ms;
- timeval d_wall_limit;
- clock_t d_cpu_start_time;
- clock_t d_cpu_limit;
-
- bool d_wall_time;
-
- /** Return the milliseconds elapsed since last set() cpu time. */
- uint64_t elapsedCPU() const;
- /** Return the milliseconds elapsed since last set() wall time. */
- uint64_t elapsedWall() const;
-
-public:
-
- /** Construct a Timer. */
- Timer()
- : d_ms(0)
- , d_cpu_start_time(0)
- , d_cpu_limit(0)
- , d_wall_time(true)
- {}
-
- /** Is the timer currently active? */
- bool on() const {
- return d_ms != 0;
- }
-
- /** Set a millisecond timer (0==off). */
- void set(uint64_t millis, bool wall_time = true);
- /** Return the milliseconds elapsed since last set() wall/cpu time
- depending on d_wall_time*/
- uint64_t elapsed() const;
- bool expired() const;
-
-};/* class Timer */
-
-
-class CVC4_PUBLIC ResourceManager {
-
- Timer d_cumulativeTimer;
- Timer d_perCallTimer;
-
- /** A user-imposed cumulative time budget, in milliseconds. 0 = no limit. */
- uint64_t d_timeBudgetCumulative;
- /** A user-imposed per-call time budget, in milliseconds. 0 = no limit. */
- uint64_t d_timeBudgetPerCall;
- /** A user-imposed cumulative resource budget. 0 = no limit. */
- uint64_t d_resourceBudgetCumulative;
- /** A user-imposed per-call resource budget. 0 = no limit. */
- uint64_t d_resourceBudgetPerCall;
-
- /** The number of milliseconds used. */
- uint64_t d_cumulativeTimeUsed;
- /** The amount of resource used. */
- uint64_t d_cumulativeResourceUsed;
-
- /** The ammount of resource used during this call. */
- uint64_t d_thisCallResourceUsed;
-
- /**
- * The ammount of resource budget for this call (min between per call
- * budget and left-over cumulative budget.
- */
- uint64_t d_thisCallTimeBudget;
- uint64_t d_thisCallResourceBudget;
-
- bool d_isHardLimit;
- bool d_on;
- bool d_cpuTime;
- uint64_t d_spendResourceCalls;
-
- /** Counter indicating how often to check resource manager in loops */
- static const uint64_t s_resourceCount;
-
-public:
-
- ResourceManager();
-
- bool limitOn() const { return cumulativeLimitOn() || perCallLimitOn(); }
- bool cumulativeLimitOn() const;
- bool perCallLimitOn() const;
-
- bool outOfResources() const;
- bool outOfTime() const;
- bool out() const { return d_on && (outOfResources() || outOfTime()); }
-
- uint64_t getResourceUsage() const;
- uint64_t getTimeUsage() const;
- uint64_t getResourceRemaining() const;
- uint64_t getTimeRemaining() const;
-
- uint64_t getResourceBudgetForThisCall() {
- return d_thisCallResourceBudget;
- }
-
- void spendResource(unsigned ammount) throw(UnsafeInterruptException);
-
- void setHardLimit(bool value);
- void setResourceLimit(uint64_t units, bool cumulative = false);
- void setTimeLimit(uint64_t millis, bool cumulative = false);
- void useCPUTime(bool cpu);
-
- void enable(bool on);
-
- /**
- * Resets perCall limits to mark the start of a new call,
- * updates budget for current call and starts the timer
- */
- void beginCall();
-
- /**
- * Marks the end of a SmtEngine check call, stops the per
- * call timer, updates cumulative time used.
- */
- void endCall();
-
- static uint64_t getFrequencyCount() { return s_resourceCount; }
- friend class SmtEngine;
-};/* class ResourceManager */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__RESOURCE_MANAGER_H */
+++ /dev/null
-%{
-#include "util/resource_manager.h"
-%}
-
-%include "util/resource_manager.h"
+++ /dev/null
-/********************* */
-/*! \file result.cpp
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: none
- ** Minor contributors (to current version): 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 Encapsulation of the result of a query.
- **
- ** Encapsulation of the result of a query.
- **/
-
-#include <iostream>
-#include <algorithm>
-#include <string>
-#include <cctype>
-
-#include "util/result.h"
-#include "util/cvc4_assert.h"
-#include "printer/printer.h"
-
-using namespace std;
-
-namespace CVC4 {
-
-Result::Result(const std::string& instr, std::string inputName) :
- d_sat(SAT_UNKNOWN),
- d_validity(VALIDITY_UNKNOWN),
- d_which(TYPE_NONE),
- d_unknownExplanation(UNKNOWN_REASON),
- d_inputName(inputName) {
- string s = instr;
- transform(s.begin(), s.end(), s.begin(), ::tolower);
- if(s == "sat" || s == "satisfiable") {
- d_which = TYPE_SAT;
- d_sat = SAT;
- } else if(s == "unsat" || s == "unsatisfiable") {
- d_which = TYPE_SAT;
- d_sat = UNSAT;
- } else if(s == "valid") {
- d_which = TYPE_VALIDITY;
- d_validity = VALID;
- } else if(s == "invalid") {
- d_which = TYPE_VALIDITY;
- d_validity = INVALID;
- } else if(s == "incomplete") {
- d_which = TYPE_SAT;
- d_sat = SAT_UNKNOWN;
- d_unknownExplanation = INCOMPLETE;
- } else if(s == "timeout") {
- d_which = TYPE_SAT;
- d_sat = SAT_UNKNOWN;
- d_unknownExplanation = TIMEOUT;
- } else if(s == "resourceout") {
- d_which = TYPE_SAT;
- d_sat = SAT_UNKNOWN;
- d_unknownExplanation = RESOURCEOUT;
- } else if(s == "memout") {
- d_which = TYPE_SAT;
- d_sat = SAT_UNKNOWN;
- d_unknownExplanation = MEMOUT;
- } else if(s == "interrupted") {
- d_which = TYPE_SAT;
- d_sat = SAT_UNKNOWN;
- d_unknownExplanation = INTERRUPTED;
- } else if(s.size() >= 7 && s.compare(0, 7, "unknown") == 0) {
- d_which = TYPE_SAT;
- d_sat = SAT_UNKNOWN;
- } else {
- IllegalArgument(s, "expected satisfiability/validity result, "
- "instead got `%s'", s.c_str());
- }
-}
-
-bool Result::operator==(const Result& r) const throw() {
- if(d_which != r.d_which) {
- return false;
- }
- if(d_which == TYPE_SAT) {
- return d_sat == r.d_sat &&
- ( d_sat != SAT_UNKNOWN ||
- d_unknownExplanation == r.d_unknownExplanation );
- }
- if(d_which == TYPE_VALIDITY) {
- return d_validity == r.d_validity &&
- ( d_validity != VALIDITY_UNKNOWN ||
- d_unknownExplanation == r.d_unknownExplanation );
- }
- return false;
-}
-
-bool operator==(enum Result::Sat sr, const Result& r) throw() {
- return r == sr;
-}
-
-bool operator==(enum Result::Validity vr, const Result& r) throw() {
- return r == vr;
-}
-bool operator!=(enum Result::Sat s, const Result& r) throw(){
- return !(s == r);
-}
-bool operator!=(enum Result::Validity v, const Result& r) throw(){
- return !(v == r);
-}
-
-Result Result::asSatisfiabilityResult() const throw() {
- if(d_which == TYPE_SAT) {
- return *this;
- }
-
- if(d_which == TYPE_VALIDITY) {
- switch(d_validity) {
-
- case INVALID:
- return Result(SAT, d_inputName);
-
- case VALID:
- return Result(UNSAT, d_inputName);
-
- case VALIDITY_UNKNOWN:
- return Result(SAT_UNKNOWN, d_unknownExplanation, d_inputName);
-
- default:
- Unhandled(d_validity);
- }
- }
-
- // TYPE_NONE
- return Result(SAT_UNKNOWN, NO_STATUS, d_inputName);
-}
-
-Result Result::asValidityResult() const throw() {
- if(d_which == TYPE_VALIDITY) {
- return *this;
- }
-
- if(d_which == TYPE_SAT) {
- switch(d_sat) {
-
- case SAT:
- return Result(INVALID, d_inputName);
-
- case UNSAT:
- return Result(VALID, d_inputName);
-
- case SAT_UNKNOWN:
- return Result(VALIDITY_UNKNOWN, d_unknownExplanation, d_inputName);
-
- default:
- Unhandled(d_sat);
- }
- }
-
- // TYPE_NONE
- return Result(VALIDITY_UNKNOWN, NO_STATUS, d_inputName);
-}
-
-string Result::toString() const {
- stringstream ss;
- ss << *this;
- return ss.str();
-}
-
-ostream& operator<<(ostream& out, enum Result::Sat s) {
- switch(s) {
- case Result::UNSAT: out << "UNSAT"; break;
- case Result::SAT: out << "SAT"; break;
- case Result::SAT_UNKNOWN: out << "SAT_UNKNOWN"; break;
- default: Unhandled(s);
- }
- return out;
-}
-
-ostream& operator<<(ostream& out, enum Result::Validity v) {
- switch(v) {
- case Result::INVALID: out << "INVALID"; break;
- case Result::VALID: out << "VALID"; break;
- case Result::VALIDITY_UNKNOWN: out << "VALIDITY_UNKNOWN"; break;
- default: Unhandled(v);
- }
- return out;
-}
-
-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;
- case Result::TIMEOUT: out << "TIMEOUT"; break;
- case Result::RESOURCEOUT: out << "RESOURCEOUT"; break;
- case Result::MEMOUT: out << "MEMOUT"; break;
- case Result::INTERRUPTED: out << "INTERRUPTED"; break;
- case Result::NO_STATUS: out << "NO_STATUS"; break;
- case Result::UNSUPPORTED: out << "UNSUPPORTED"; break;
- case Result::OTHER: out << "OTHER"; break;
- case Result::UNKNOWN_REASON: out << "UNKNOWN_REASON"; break;
- default: Unhandled(e);
- }
- return out;
-}
-
-ostream& operator<<(ostream& out, const Result& r) {
- Printer::getPrinter(Node::setlanguage::getLanguage(out))->toStream(out, r);
- return out;
-}/* operator<<(ostream&, const Result&) */
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file result.h
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: none
- ** Minor contributors (to current version): 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 Encapsulation of the result of a query.
- **
- ** Encapsulation of the result of a query.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__RESULT_H
-#define __CVC4__RESULT_H
-
-#include <iostream>
-#include <string>
-
-#include "util/exception.h"
-
-namespace CVC4 {
-
-class Result;
-
-std::ostream& operator<<(std::ostream& out, const Result& r) CVC4_PUBLIC;
-
-/**
- * Three-valued SMT result, with optional explanation.
- */
-class CVC4_PUBLIC Result {
-public:
- enum Sat {
- UNSAT = 0,
- SAT = 1,
- SAT_UNKNOWN = 2
- };
-
- enum Validity {
- INVALID = 0,
- VALID = 1,
- VALIDITY_UNKNOWN = 2
- };
-
- enum Type {
- TYPE_SAT,
- TYPE_VALIDITY,
- TYPE_NONE
- };
-
- enum UnknownExplanation {
- REQUIRES_FULL_CHECK,
- INCOMPLETE,
- TIMEOUT,
- RESOURCEOUT,
- MEMOUT,
- INTERRUPTED,
- NO_STATUS,
- UNSUPPORTED,
- OTHER,
- UNKNOWN_REASON
- };
-
-private:
- enum Sat d_sat;
- enum Validity d_validity;
- enum Type d_which;
- enum UnknownExplanation d_unknownExplanation;
- std::string d_inputName;
-
-public:
- Result() :
- d_sat(SAT_UNKNOWN),
- d_validity(VALIDITY_UNKNOWN),
- d_which(TYPE_NONE),
- d_unknownExplanation(UNKNOWN_REASON),
- d_inputName("") {
- }
- Result(enum Sat s, std::string inputName = "") :
- d_sat(s),
- d_validity(VALIDITY_UNKNOWN),
- d_which(TYPE_SAT),
- d_unknownExplanation(UNKNOWN_REASON),
- d_inputName(inputName) {
- CheckArgument(s != SAT_UNKNOWN,
- "Must provide a reason for satisfiability being unknown");
- }
- Result(enum Validity v, std::string inputName = "") :
- d_sat(SAT_UNKNOWN),
- d_validity(v),
- d_which(TYPE_VALIDITY),
- d_unknownExplanation(UNKNOWN_REASON),
- d_inputName(inputName) {
- CheckArgument(v != VALIDITY_UNKNOWN,
- "Must provide a reason for validity being unknown");
- }
- Result(enum Sat s, enum UnknownExplanation unknownExplanation, std::string inputName = "") :
- d_sat(s),
- d_validity(VALIDITY_UNKNOWN),
- d_which(TYPE_SAT),
- d_unknownExplanation(unknownExplanation),
- d_inputName(inputName) {
- CheckArgument(s == SAT_UNKNOWN,
- "improper use of unknown-result constructor");
- }
- Result(enum Validity v, enum UnknownExplanation unknownExplanation, std::string inputName = "") :
- d_sat(SAT_UNKNOWN),
- d_validity(v),
- d_which(TYPE_VALIDITY),
- d_unknownExplanation(unknownExplanation),
- d_inputName(inputName) {
- CheckArgument(v == VALIDITY_UNKNOWN,
- "improper use of unknown-result constructor");
- }
- Result(const std::string& s, std::string inputName = "");
-
- Result(const Result& r, std::string inputName) {
- *this = r;
- d_inputName = inputName;
- }
-
- enum Sat isSat() const {
- return d_which == TYPE_SAT ? d_sat : SAT_UNKNOWN;
- }
- enum Validity isValid() const {
- return d_which == TYPE_VALIDITY ? d_validity : VALIDITY_UNKNOWN;
- }
- bool isUnknown() const {
- return isSat() == SAT_UNKNOWN && isValid() == VALIDITY_UNKNOWN;
- }
- Type getType() const {
- return d_which;
- }
- bool isNull() const {
- return d_which == TYPE_NONE;
- }
- enum UnknownExplanation whyUnknown() const {
- CheckArgument( isUnknown(), this,
- "This result is not unknown, so the reason for "
- "being unknown cannot be inquired of it" );
- return d_unknownExplanation;
- }
-
- bool operator==(const Result& r) const throw();
- inline bool operator!=(const Result& r) const throw();
- Result asSatisfiabilityResult() const throw();
- Result asValidityResult() const throw();
-
- std::string toString() const;
-
- std::string getInputName() const { return d_inputName; }
-
-};/* class Result */
-
-inline bool Result::operator!=(const Result& r) const throw() {
- return !(*this == r);
-}
-
-std::ostream& operator<<(std::ostream& out,
- enum Result::Sat s) CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream& out,
- enum Result::Validity v) CVC4_PUBLIC;
-std::ostream& operator<<(std::ostream& out,
- enum Result::UnknownExplanation e) CVC4_PUBLIC;
-
-bool operator==(enum Result::Sat s, const Result& r) throw() CVC4_PUBLIC;
-bool operator==(enum Result::Validity v, const Result& r) throw() CVC4_PUBLIC;
-
-bool operator!=(enum Result::Sat s, const Result& r) throw() CVC4_PUBLIC;
-bool operator!=(enum Result::Validity v, const Result& r) throw() CVC4_PUBLIC;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__RESULT_H */
+++ /dev/null
-%{
-#include "util/result.h"
-%}
-
-%ignore CVC4::operator<<(std::ostream&, const Result& r);
-
-%rename(equals) CVC4::Result::operator==(const Result& r) const;
-%ignore CVC4::Result::operator!=(const Result& r) const;
-
-%ignore CVC4::operator<<(std::ostream&, enum Result::Sat);
-%ignore CVC4::operator<<(std::ostream&, enum Result::Validity);
-%ignore CVC4::operator<<(std::ostream&, enum Result::UnknownExplanation);
-
-%ignore CVC4::operator==(enum Result::Sat, const Result&);
-%ignore CVC4::operator!=(enum Result::Sat, const Result&);
-
-%ignore CVC4::operator==(enum Result::Validity, const Result&);
-%ignore CVC4::operator!=(enum Result::Validity, const Result&);
-
-%include "util/result.h"
+++ /dev/null
-/********************* */
-/*! \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.
- **/
-
-#include <iostream>
-#include <vector>
-
-#include "util/sexpr.h"
-#include "util/cvc4_assert.h"
-#include "printer/printer.h"
-#include "expr/expr.h"
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, const SExpr& sexpr) {
- Printer::getPrinter(Expr::setlanguage::getLanguage(out))->toStream(out, sexpr);
- return out;
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file sexpr.h
- ** \verbatim
- ** Original author: Christopher L. Conway
- ** Major contributors: Tim King, Morgan Deters
- ** Minor contributors (to current version): Dejan Jovanovic
- ** 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.
- ** These are used when a simple, and obvious interface for basic
- ** expressions is appropraite.
- **
- ** These are quite ineffecient.
- ** These are totally disconnected from any ExprManager.
- ** These keep unique copies of all of their children.
- ** These are VERY overly verbose and keep much more data than is needed.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__SEXPR_H
-#define __CVC4__SEXPR_H
-
-#include <vector>
-#include <string>
-#include <iomanip>
-#include <sstream>
-
-#include "util/integer.h"
-#include "util/rational.h"
-#include "util/exception.h"
-
-namespace CVC4 {
-
-class CVC4_PUBLIC SExprKeyword {
- std::string d_str;
-public:
- SExprKeyword(const std::string& s) : d_str(s) {}
- const std::string& getString() const { return d_str; }
-};/* class SExpr::Keyword */
-
-/**
- * A simple S-expression. An S-expression is either an atom with a
- * string value, or a list of other S-expressions.
- */
-class CVC4_PUBLIC SExpr {
-
- enum SExprTypes {
- SEXPR_STRING,
- SEXPR_KEYWORD,
- SEXPR_INTEGER,
- SEXPR_RATIONAL,
- SEXPR_NOT_ATOM
- } d_sexprType;
-
- /** The value of an atomic integer-valued S-expression. */
- CVC4::Integer d_integerValue;
-
- /** The value of an atomic rational-valued S-expression. */
- CVC4::Rational d_rationalValue;
-
- /** The value of an atomic S-expression. */
- std::string d_stringValue;
-
- /** The children of a list S-expression. */
- std::vector<SExpr> d_children;
-
-public:
-
- typedef SExprKeyword Keyword;
-
- SExpr() :
- d_sexprType(SEXPR_STRING),
- d_integerValue(0),
- d_rationalValue(0),
- d_stringValue(""),
- d_children() {
- }
-
- SExpr(const CVC4::Integer& value) :
- d_sexprType(SEXPR_INTEGER),
- d_integerValue(value),
- d_rationalValue(0),
- d_stringValue(""),
- d_children() {
- }
-
- SExpr(int value) :
- d_sexprType(SEXPR_INTEGER),
- d_integerValue(value),
- d_rationalValue(0),
- d_stringValue(""),
- d_children() {
- }
-
- SExpr(long int value) :
- d_sexprType(SEXPR_INTEGER),
- d_integerValue(value),
- d_rationalValue(0),
- d_stringValue(""),
- d_children() {
- }
-
- SExpr(unsigned int value) :
- d_sexprType(SEXPR_INTEGER),
- d_integerValue(value),
- d_rationalValue(0),
- d_stringValue(""),
- d_children() {
- }
-
- SExpr(unsigned long int value) :
- d_sexprType(SEXPR_INTEGER),
- d_integerValue(value),
- d_rationalValue(0),
- d_stringValue(""),
- d_children() {
- }
-
- SExpr(const CVC4::Rational& value) :
- d_sexprType(SEXPR_RATIONAL),
- d_integerValue(0),
- d_rationalValue(value),
- d_stringValue(""),
- d_children() {
- }
-
- SExpr(const std::string& value) :
- d_sexprType(SEXPR_STRING),
- d_integerValue(0),
- d_rationalValue(0),
- d_stringValue(value),
- d_children() {
- }
-
- /**
- * This constructs a string expression from a const char* value.
- * This cannot be removed in order to support SExpr("foo").
- * Given the other constructors this SExpr("foo") converts to bool.
- * instead of SExpr(string("foo")).
- */
- SExpr(const char* value) :
- d_sexprType(SEXPR_STRING),
- d_integerValue(0),
- d_rationalValue(0),
- d_stringValue(value),
- d_children() {
- }
-
- /**
- * This adds a convenience wrapper to SExpr to cast from bools.
- * This is internally handled as the strings "true" and "false"
- */
- SExpr(bool value) :
- d_sexprType(SEXPR_STRING),
- d_integerValue(0),
- d_rationalValue(0),
- d_stringValue(value ? "true" : "false"),
- d_children() {
- }
-
- SExpr(const Keyword& value) :
- d_sexprType(SEXPR_KEYWORD),
- d_integerValue(0),
- d_rationalValue(0),
- d_stringValue(value.getString()),
- d_children() {
- }
-
- SExpr(const std::vector<SExpr>& children) :
- d_sexprType(SEXPR_NOT_ATOM),
- d_integerValue(0),
- d_rationalValue(0),
- d_stringValue(""),
- d_children(children) {
- }
-
- /** Is this S-expression an atom? */
- bool isAtom() const;
-
- /** Is this S-expression an integer? */
- bool isInteger() const;
-
- /** Is this S-expression a rational? */
- bool isRational() const;
-
- /** Is this S-expression a string? */
- bool isString() const;
-
- /** Is this S-expression a keyword? */
- bool isKeyword() const;
-
- /**
- * Get the string value of this S-expression. This will cause an
- * error if this S-expression is not an atom.
- */
- std::string getValue() const;
-
- /**
- * Get the integer value of this S-expression. This will cause an
- * error if this S-expression is not an integer.
- */
- const CVC4::Integer& getIntegerValue() const;
-
- /**
- * Get the rational value of this S-expression. This will cause an
- * error if this S-expression is not a rational.
- */
- const CVC4::Rational& getRationalValue() const;
-
- /**
- * Get the children of this S-expression. This will cause an error
- * if this S-expression is not a list.
- */
- const std::vector<SExpr>& getChildren() const;
-
- /** Is this S-expression equal to another? */
- bool operator==(const SExpr& s) const;
-
- /** Is this S-expression different from another? */
- bool operator!=(const SExpr& s) const;
-
-};/* 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();
- }
- case SEXPR_STRING:
- case SEXPR_KEYWORD:
- return d_stringValue;
- case SEXPR_NOT_ATOM:
- return std::string();
- }
- 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;
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__SEXPR_H */
+++ /dev/null
-%{
-#include "util/sexpr.h"
-%}
-
-%ignore CVC4::operator<<(std::ostream&, const SExpr&);
-%ignore CVC4::operator<<(std::ostream&, SExpr::SexprTypes);
-
-// for Java and the like
-%extend CVC4::SExpr {
- std::string toString() const { return self->getValue(); }
-};/* CVC4::SExpr */
-
-%ignore CVC4::SExpr::SExpr(int);
-%ignore CVC4::SExpr::SExpr(unsigned int);
-%ignore CVC4::SExpr::SExpr(unsigned long);
-%ignore CVC4::SExpr::SExpr(const char*);
-
-%rename(equals) CVC4::SExpr::operator==(const SExpr&) const;
-%ignore CVC4::SExpr::operator!=(const SExpr&) const;
-
-%include "util/sexpr.h"
--- /dev/null
+/********************* */
+/*! \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 */
--- /dev/null
+/********************* */
+/*! \file smt2_quote_string.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 Quotes a string if necessary for smt2.
+ **
+ ** Quotes a string if necessary for smt2.
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__UTIL__SMT2_QUOTE_STRING_H
+#define __CVC4__UTIL__SMT2_QUOTE_STRING_H
+
+#include <string>
+
+namespace CVC4 {
+
+/**
+ * SMT-LIB 2 quoting for symbols
+ */
+std::string quoteSymbol(const std::string& s);
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__UTIL__SMT2_QUOTE_STRING_H */
+++ /dev/null
-/********************* */
-/*! \file sort_inference.cpp
- ** \verbatim
- ** Original author: Andrew Reynolds
- ** Major contributors: Morgan Deters
- ** Minor contributors (to current version): Kshitij Bansal
- ** 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 Sort inference module
- **
- ** This class implements sort inference, based on a simple algorithm:
- ** First, we assume all functions and predicates have distinct uninterpreted types.
- ** One pass is made through the input assertions, while a union-find data structure
- ** maintains necessary information regarding constraints on these types.
- **/
-
-#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 "proof/proof_manager.h"
-
-using namespace CVC4;
-using namespace std;
-
-namespace CVC4 {
-
-void SortInference::UnionFind::print(const char * c){
- for( std::map< int, int >::iterator it = d_eqc.begin(); it != d_eqc.end(); ++it ){
- Trace(c) << "s_" << it->first << " = s_" << it->second << ", ";
- }
- for( unsigned i=0; i<d_deq.size(); i++ ){
- Trace(c) << "s_" << d_deq[i].first << " != s_" << d_deq[i].second << ", ";
- }
- 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 ){
- d_eqc[ it->first ] = it->second;
- }
- 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 ){
- return t;
- }else{
- int rt = getRepresentative( it->second );
- d_eqc[t] = rt;
- return rt;
- }
-}
-void SortInference::UnionFind::setEqual( int t1, int t2 ){
- if( t1!=t2 ){
- int rt1 = getRepresentative( t1 );
- int rt2 = getRepresentative( t2 );
- if( rt1>rt2 ){
- d_eqc[rt1] = rt2;
- }else{
- d_eqc[rt2] = rt1;
- }
- }
-}
-bool SortInference::UnionFind::isValid() {
- for( unsigned i=0; i<d_deq.size(); i++ ){
- if( areEqual( d_deq[i].first, d_deq[i].second ) ){
- return false;
- }
- }
- return true;
-}
-
-
-void SortInference::recordSubsort( TypeNode tn, int s ){
- s = d_type_union_find.getRepresentative( s );
- if( std::find( d_sub_sorts.begin(), d_sub_sorts.end(), s )==d_sub_sorts.end() ){
- d_sub_sorts.push_back( s );
- d_type_sub_sorts[tn].push_back( s );
- }
-}
-
-void SortInference::printSort( const char* c, int t ){
- int rt = d_type_union_find.getRepresentative( t );
- if( d_type_types.find( rt )!=d_type_types.end() ){
- Trace(c) << d_type_types[rt];
- }else{
- Trace(c) << "s_" << rt;
- }
-}
-
-void SortInference::reset() {
- d_sub_sorts.clear();
- d_non_monotonic_sorts.clear();
- d_type_sub_sorts.clear();
- //reset info
- sortCount = 1;
- d_type_union_find.clear();
- d_type_types.clear();
- d_id_for_types.clear();
- d_op_return_types.clear();
- d_op_arg_types.clear();
- d_var_types.clear();
- //for rewriting
- d_symbol_map.clear();
- d_const_map.clear();
-}
-
-bool SortInference::simplify( std::vector< Node >& assertions ){
- Trace("sort-inference") << "Calculating sort inference..." << std::endl;
- //process all assertions
- for( unsigned i=0; i<assertions.size(); i++ ){
- Trace("sort-inference-debug") << "Process " << assertions[i] << std::endl;
- std::map< Node, Node > var_bound;
- process( assertions[i], var_bound );
- }
- for( std::map< Node, int >::iterator it = d_op_return_types.begin(); it != d_op_return_types.end(); ++it ){
- Trace("sort-inference") << it->first << " : ";
- TypeNode retTn = it->first.getType();
- if( !d_op_arg_types[ it->first ].empty() ){
- Trace("sort-inference") << "( ";
- for( size_t i=0; i<d_op_arg_types[ it->first ].size(); i++ ){
- recordSubsort( retTn[i], d_op_arg_types[ it->first ][i] );
- printSort( "sort-inference", d_op_arg_types[ it->first ][i] );
- Trace("sort-inference") << " ";
- }
- Trace("sort-inference") << ") -> ";
- retTn = retTn[(int)retTn.getNumChildren()-1];
- }
- recordSubsort( retTn, it->second );
- printSort( "sort-inference", it->second );
- Trace("sort-inference") << std::endl;
- }
- for( std::map< Node, std::map< Node, int > >::iterator it = d_var_types.begin(); it != d_var_types.end(); ++it ){
- Trace("sort-inference") << "Quantified formula : " << it->first << " : " << std::endl;
- for( unsigned i=0; i<it->first[0].getNumChildren(); i++ ){
- recordSubsort( it->first[0][i].getType(), it->second[it->first[0][i]] );
- printSort( "sort-inference", it->second[it->first[0][i]] );
- Trace("sort-inference") << std::endl;
- }
- Trace("sort-inference") << std::endl;
- }
-
- if( !options::ufssSymBreak() ){
- bool rewritten = false;
- //determine monotonicity of sorts
- for( unsigned i=0; i<assertions.size(); i++ ){
- Trace("sort-inference-debug") << "Process monotonicity for " << assertions[i] << std::endl;
- std::map< Node, Node > var_bound;
- processMonotonic( assertions[i], true, true, var_bound );
- }
-
- Trace("sort-inference") << "We have " << d_sub_sorts.size() << " sub-sorts : " << std::endl;
- for( unsigned i=0; i<d_sub_sorts.size(); i++ ){
- printSort( "sort-inference", d_sub_sorts[i] );
- if( d_type_types.find( d_sub_sorts[i] )!=d_type_types.end() ){
- Trace("sort-inference") << " is interpreted." << std::endl;
- }else if( d_non_monotonic_sorts.find( d_sub_sorts[i] )==d_non_monotonic_sorts.end() ){
- Trace("sort-inference") << " is monotonic." << std::endl;
- }else{
- Trace("sort-inference") << " is not monotonic." << std::endl;
- }
- }
-
- //simplify all assertions by introducing new symbols wherever necessary
- for( unsigned i=0; i<assertions.size(); i++ ){
- Node prev = assertions[i];
- std::map< Node, Node > var_bound;
- Trace("sort-inference-debug") << "Rewrite " << assertions[i] << std::endl;
- Node curr = simplify( assertions[i], var_bound );
- Trace("sort-inference-debug") << "Done." << std::endl;
- if( curr!=assertions[i] ){
- curr = theory::Rewriter::rewrite( curr );
- rewritten = true;
- Trace("sort-inference-rewrite") << assertions << std::endl;
- Trace("sort-inference-rewrite") << " --> " << curr << std::endl;
- PROOF( ProofManager::currentPM()->addDependence(curr, assertions[i]); );
- assertions[i] = curr;
- }
- }
- //now, ensure constants are distinct
- for( std::map< TypeNode, std::map< Node, Node > >::iterator it = d_const_map.begin(); it != d_const_map.end(); ++it ){
- std::vector< Node > consts;
- for( std::map< Node, Node >::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2 ){
- consts.push_back( it2->second );
- }
- //TODO: add lemma enforcing introduced constants to be distinct
- }
-
- //enforce constraints based on monotonicity
- for( std::map< TypeNode, std::vector< int > >::iterator it = d_type_sub_sorts.begin(); it != d_type_sub_sorts.end(); ++it ){
- int nmonSort = -1;
- for( unsigned i=0; i<it->second.size(); i++ ){
- if( d_non_monotonic_sorts.find( it->second[i] )!=d_non_monotonic_sorts.end() ){
- nmonSort = it->second[i];
- break;
- }
- }
- if( nmonSort!=-1 ){
- std::vector< Node > injections;
- TypeNode base_tn = getOrCreateTypeForId( nmonSort, it->first );
- for( unsigned i=0; i<it->second.size(); i++ ){
- if( it->second[i]!=nmonSort ){
- TypeNode new_tn = getOrCreateTypeForId( it->second[i], it->first );
- //make injection to nmonSort
- Node a1 = mkInjection( new_tn, base_tn );
- injections.push_back( a1 );
- if( d_non_monotonic_sorts.find( it->second[i] )!=d_non_monotonic_sorts.end() ){
- //also must make injection from nmonSort to this
- Node a2 = mkInjection( base_tn, new_tn );
- injections.push_back( a2 );
- }
- }
- }
- Trace("sort-inference-rewrite") << "Add the following injections for " << it->first << " to ensure consistency wrt non-monotonic sorts : " << std::endl;
- for( unsigned j=0; j<injections.size(); j++ ){
- Trace("sort-inference-rewrite") << " " << injections[j] << std::endl;
- }
- assertions.insert( assertions.end(), injections.begin(), injections.end() );
- if( !injections.empty() ){
- rewritten = true;
- }
- }
- }
- //no sub-sort information is stored
- reset();
- return rewritten;
- }
- /*
- else if( !options::ufssSymBreak() ){
- //just add the unit lemmas between constants
- std::map< TypeNode, std::map< int, Node > > constants;
- for( std::map< Node, int >::iterator it = d_op_return_types.begin(); it != d_op_return_types.end(); ++it ){
- int rt = d_type_union_find.getRepresentative( it->second );
- if( d_op_arg_types[ it->first ].empty() ){
- TypeNode tn = it->first.getType();
- if( constants[ tn ].find( rt )==constants[ tn ].end() ){
- constants[ tn ][ rt ] = it->first;
- }
- }
- }
- //add unit lemmas for each constant
- for( std::map< TypeNode, std::map< int, Node > >::iterator it = constants.begin(); it != constants.end(); ++it ){
- Node first_const;
- for( std::map< int, Node >::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2 ){
- if( first_const.isNull() ){
- first_const = it2->second;
- }else{
- Node eq = first_const.eqNode( it2->second );
- //eq = Rewriter::rewrite( eq );
- Trace("sort-inference-lemma") << "Sort inference lemma : " << eq << std::endl;
- assertions.push_back( eq );
- }
- }
- }
- }
- */
- initialSortCount = sortCount;
- return false;
-}
-
-void SortInference::setEqual( int t1, int t2 ){
- if( t1!=t2 ){
- int rt1 = d_type_union_find.getRepresentative( t1 );
- int rt2 = d_type_union_find.getRepresentative( t2 );
- if( rt1!=rt2 ){
- Trace("sort-inference-debug") << "Set equal : ";
- printSort( "sort-inference-debug", rt1 );
- Trace("sort-inference-debug") << " ";
- printSort( "sort-inference-debug", rt2 );
- Trace("sort-inference-debug") << std::endl;
- /*
- d_type_eq_class[rt1].insert( d_type_eq_class[rt1].end(), d_type_eq_class[rt2].begin(), d_type_eq_class[rt2].end() );
- d_type_eq_class[rt2].clear();
- Trace("sort-inference-debug") << "EqClass : { ";
- for( int i=0; i<(int)d_type_eq_class[rt1].size(); i++ ){
- Trace("sort-inference-debug") << d_type_eq_class[rt1][i] << ", ";
- }
- Trace("sort-inference-debug") << "}" << std::endl;
- */
- if( rt2>rt1 ){
- //swap
- int swap = rt1;
- rt1 = rt2;
- rt2 = swap;
- }
- std::map< int, TypeNode >::iterator it1 = d_type_types.find( rt1 );
- if( it1!=d_type_types.end() ){
- if( d_type_types.find( rt2 )==d_type_types.end() ){
- d_type_types[rt2] = it1->second;
- d_type_types.erase( rt1 );
- }else{
- Trace("sort-inference-debug") << "...fail : associated with types " << d_type_types[rt1] << " and " << d_type_types[rt2] << std::endl;
- return;
- }
- }
- d_type_union_find.d_eqc[rt1] = rt2;
- }
- }
-}
-
-int SortInference::getIdForType( TypeNode tn ){
- //register the return type
- std::map< TypeNode, int >::iterator it = d_id_for_types.find( tn );
- if( it==d_id_for_types.end() ){
- int sc = sortCount;
- d_type_types[ sortCount ] = tn;
- d_id_for_types[ tn ] = sortCount;
- sortCount++;
- return sc;
- }else{
- return it->second;
- }
-}
-
-int SortInference::process( Node n, std::map< Node, Node >& var_bound ){
- //add to variable bindings
- if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
- if( d_var_types.find( n )!=d_var_types.end() ){
- return getIdForType( n.getType() );
- }else{
- for( size_t i=0; i<n[0].getNumChildren(); i++ ){
- //apply sort inference to quantified variables
- d_var_types[n][ n[0][i] ] = sortCount;
- sortCount++;
-
- //type of the quantified variable must be the same
- var_bound[ n[0][i] ] = n;
- }
- }
- }
-
- //process children
- std::vector< Node > children;
- std::vector< int > child_types;
- for( size_t i=0; i<n.getNumChildren(); i++ ){
- bool processChild = true;
- if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
- processChild = options::userPatternsQuant()==theory::quantifiers::USER_PAT_MODE_IGNORE ? i==1 : i>=1;
- }
- if( processChild ){
- children.push_back( n[i] );
- child_types.push_back( process( n[i], var_bound ) );
- }
- }
-
- //remove from variable bindings
- if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
- //erase from variable bound
- for( size_t i=0; i<n[0].getNumChildren(); i++ ){
- var_bound.erase( n[0][i] );
- }
- }
- Trace("sort-inference-debug") << "...Process " << n << std::endl;
-
- int retType;
- if( n.getKind()==kind::EQUAL ){
- Trace("sort-inference-debug") << "For equality " << n << ", set equal types from : " << n[0].getType() << " " << n[1].getType() << std::endl;
- //if original types are mixed (e.g. Int/Real), don't commit type equality in either direction
- if( n[0].getType()!=n[1].getType() ){
- //for now, assume the original types
- for( unsigned i=0; i<2; i++ ){
- int ct = getIdForType( n[i].getType() );
- setEqual( child_types[i], ct );
- }
- }else{
- //we only require that the left and right hand side must be equal
- setEqual( child_types[0], child_types[1] );
- }
- //int eqType = getIdForType( n[0].getType() );
- //setEqual( child_types[0], eqType );
- //setEqual( child_types[1], eqType );
- retType = getIdForType( n.getType() );
- }else if( n.getKind()==kind::APPLY_UF ){
- Node op = n.getOperator();
- TypeNode tn_op = op.getType();
- if( d_op_return_types.find( op )==d_op_return_types.end() ){
- if( n.getType().isBoolean() ){
- //use booleans
- d_op_return_types[op] = getIdForType( n.getType() );
- }else{
- //assign arbitrary sort for return type
- d_op_return_types[op] = sortCount;
- sortCount++;
- }
- //d_type_eq_class[sortCount].push_back( op );
- //assign arbitrary sort for argument types
- for( size_t i=0; i<n.getNumChildren(); i++ ){
- d_op_arg_types[op].push_back( sortCount );
- sortCount++;
- }
- }
- for( size_t i=0; i<n.getNumChildren(); i++ ){
- //the argument of the operator must match the return type of the subterm
- if( n[i].getType()!=tn_op[i] ){
- //if type mismatch, assume original types
- Trace("sort-inference-debug") << "Argument " << i << " of " << op << " " << n[i] << " has type " << n[i].getType();
- Trace("sort-inference-debug") << ", while operator arg has type " << tn_op[i] << std::endl;
- int ct1 = getIdForType( n[i].getType() );
- setEqual( child_types[i], ct1 );
- int ct2 = getIdForType( tn_op[i] );
- setEqual( d_op_arg_types[op][i], ct2 );
- }else{
- setEqual( child_types[i], d_op_arg_types[op][i] );
- }
- }
- //return type is the return type
- retType = d_op_return_types[op];
- }else{
- std::map< Node, Node >::iterator it = var_bound.find( n );
- if( it!=var_bound.end() ){
- Trace("sort-inference-debug") << n << " is a bound variable." << std::endl;
- //the return type was specified while binding
- retType = d_var_types[it->second][n];
- }else if( n.getKind() == kind::VARIABLE || n.getKind()==kind::SKOLEM ){
- Trace("sort-inference-debug") << n << " is a variable." << std::endl;
- if( d_op_return_types.find( n )==d_op_return_types.end() ){
- //assign arbitrary sort
- d_op_return_types[n] = sortCount;
- sortCount++;
- //d_type_eq_class[sortCount].push_back( n );
- }
- retType = d_op_return_types[n];
- //}else if( n.isConst() ){
- // Trace("sort-inference-debug") << n << " is a constant." << std::endl;
- //can be any type we want
- // retType = sortCount;
- // sortCount++;
- }else{
- Trace("sort-inference-debug") << n << " is a interpreted symbol." << std::endl;
- //it is an interpretted term
- for( size_t i=0; i<children.size(); i++ ){
- Trace("sort-inference-debug") << children[i] << " forced to have " << children[i].getType() << std::endl;
- //must enforce the actual type of the operator on the children
- int ct = getIdForType( children[i].getType() );
- setEqual( child_types[i], ct );
- }
- //return type must be the actual return type
- retType = getIdForType( n.getType() );
- }
- }
- Trace("sort-inference-debug") << "...Type( " << n << " ) = ";
- printSort("sort-inference-debug", retType );
- Trace("sort-inference-debug") << std::endl;
- return retType;
-}
-
-void SortInference::processMonotonic( Node n, bool pol, bool hasPol, std::map< Node, Node >& var_bound ) {
- Trace("sort-inference-debug") << "...Process monotonic " << pol << " " << hasPol << " " << n << std::endl;
- if( n.getKind()==kind::FORALL ){
- for( unsigned i=0; i<n[0].getNumChildren(); i++ ){
- var_bound[n[0][i]] = n;
- }
- processMonotonic( n[1], pol, hasPol, var_bound );
- for( unsigned i=0; i<n[0].getNumChildren(); i++ ){
- var_bound.erase( n[0][i] );
- }
- }else if( n.getKind()==kind::EQUAL ){
- if( !hasPol || pol ){
- for( unsigned i=0; i<2; i++ ){
- if( var_bound.find( n[i] )!=var_bound.end() ){
- int sid = getSortId( var_bound[n[i]], n[i] );
- d_non_monotonic_sorts[sid] = true;
- break;
- }
- }
- }
- }
- for( unsigned i=0; i<n.getNumChildren(); i++ ){
- bool npol = pol;
- bool nhasPol = hasPol;
- if( n.getKind()==kind::NOT || ( n.getKind()==kind::IMPLIES && i==0 ) ){
- npol = !npol;
- }
- if( ( n.getKind()==kind::ITE && i==0 ) || n.getKind()==kind::XOR || n.getKind()==kind::IFF ){
- nhasPol = false;
- }
- processMonotonic( n[i], npol, nhasPol, var_bound );
- }
-}
-
-
-TypeNode SortInference::getOrCreateTypeForId( int t, TypeNode pref ){
- int rt = d_type_union_find.getRepresentative( t );
- if( d_type_types.find( rt )!=d_type_types.end() ){
- return d_type_types[rt];
- }else{
- TypeNode retType;
- //see if we can assign pref
- if( !pref.isNull() && d_id_for_types.find( pref )==d_id_for_types.end() ){
- retType = pref;
- }else{
- //must create new type
- std::stringstream ss;
- ss << "it_" << t << "_" << pref;
- retType = NodeManager::currentNM()->mkSort( ss.str() );
- }
- Trace("sort-inference") << "-> Make type " << retType << " to correspond to ";
- printSort("sort-inference", t );
- Trace("sort-inference") << std::endl;
- d_id_for_types[ retType ] = rt;
- d_type_types[ rt ] = retType;
- return retType;
- }
-}
-
-TypeNode SortInference::getTypeForId( int t ){
- int rt = d_type_union_find.getRepresentative( t );
- if( d_type_types.find( rt )!=d_type_types.end() ){
- return d_type_types[rt];
- }else{
- return TypeNode::null();
- }
-}
-
-Node SortInference::getNewSymbol( Node old, TypeNode tn ){
- if( tn==old.getType() ){
- return old;
- }else if( old.isConst() ){
- //must make constant of type tn
- if( d_const_map[tn].find( old )==d_const_map[tn].end() ){
- std::stringstream ss;
- ss << "ic_" << tn << "_" << old;
- d_const_map[tn][ old ] = NodeManager::currentNM()->mkSkolem( ss.str(), tn, "constant created during sort inference" ); //use mkConst???
- }
- return d_const_map[tn][ old ];
- }else if( old.getKind()==kind::BOUND_VARIABLE ){
- std::stringstream ss;
- ss << "b_" << old;
- return NodeManager::currentNM()->mkBoundVar( ss.str(), tn );
- }else{
- std::stringstream ss;
- ss << "i_" << old;
- return NodeManager::currentNM()->mkSkolem( ss.str(), tn, "created during sort inference" );
- }
-}
-
-Node SortInference::simplify( Node n, std::map< Node, Node >& var_bound ){
- Trace("sort-inference-debug2") << "Simplify " << n << std::endl;
- std::vector< Node > children;
- if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
- //recreate based on types of variables
- std::vector< Node > new_children;
- for( size_t i=0; i<n[0].getNumChildren(); i++ ){
- TypeNode tn = getOrCreateTypeForId( d_var_types[n][ n[0][i] ], n[0][i].getType() );
- Node v = getNewSymbol( n[0][i], tn );
- Trace("sort-inference-debug2") << "Map variable " << n[0][i] << " to " << v << std::endl;
- new_children.push_back( v );
- var_bound[ n[0][i] ] = v;
- }
- children.push_back( NodeManager::currentNM()->mkNode( n[0].getKind(), new_children ) );
- }
-
- //process children
- if( n.getMetaKind() == kind::metakind::PARAMETERIZED ){
- children.push_back( n.getOperator() );
- }
- bool childChanged = false;
- for( size_t i=0; i<n.getNumChildren(); i++ ){
- bool processChild = true;
- if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
- processChild = options::userPatternsQuant()==theory::quantifiers::USER_PAT_MODE_IGNORE ? i==1 : i>=1;
- }
- if( processChild ){
- Node nc = simplify( n[i], var_bound );
- Trace("sort-inference-debug2") << "Simplify " << i << " " << n[i] << " returned " << nc << std::endl;
- children.push_back( nc );
- childChanged = childChanged || nc!=n[i];
- }
- }
-
- //remove from variable bindings
- if( n.getKind()==kind::FORALL || n.getKind()==kind::EXISTS ){
- //erase from variable bound
- for( size_t i=0; i<n[0].getNumChildren(); i++ ){
- Trace("sort-inference-debug2") << "Remove bound for " << n[0][i] << std::endl;
- var_bound.erase( n[0][i] );
- }
- return NodeManager::currentNM()->mkNode( n.getKind(), children );
- }else if( n.getKind()==kind::EQUAL ){
- TypeNode tn1 = children[0].getType();
- TypeNode tn2 = children[1].getType();
- if( !tn1.isSubtypeOf( tn2 ) && !tn2.isSubtypeOf( tn1 ) ){
- if( children[0].isConst() ){
- children[0] = getNewSymbol( children[0], children[1].getType() );
- }else if( children[1].isConst() ){
- children[1] = getNewSymbol( children[1], children[0].getType() );
- }else{
- Trace("sort-inference-warn") << "Sort inference created bad equality: " << children[0] << " = " << children[1] << std::endl;
- Trace("sort-inference-warn") << " Types : " << children[0].getType() << " " << children[1].getType() << std::endl;
- Assert( false );
- }
- }
- return NodeManager::currentNM()->mkNode( kind::EQUAL, children );
- }else if( n.getKind()==kind::APPLY_UF ){
- Node op = n.getOperator();
- if( d_symbol_map.find( op )==d_symbol_map.end() ){
- //make the new operator if necessary
- bool opChanged = false;
- std::vector< TypeNode > argTypes;
- for( size_t i=0; i<n.getNumChildren(); i++ ){
- TypeNode tn = getOrCreateTypeForId( d_op_arg_types[op][i], n[i].getType() );
- argTypes.push_back( tn );
- if( tn!=n[i].getType() ){
- opChanged = true;
- }
- }
- TypeNode retType = getOrCreateTypeForId( d_op_return_types[op], n.getType() );
- if( retType!=n.getType() ){
- opChanged = true;
- }
- if( opChanged ){
- std::stringstream ss;
- ss << "io_" << op;
- TypeNode typ = NodeManager::currentNM()->mkFunctionType( argTypes, retType );
- d_symbol_map[op] = NodeManager::currentNM()->mkSkolem( ss.str(), typ, "op created during sort inference" );
- Trace("setp-model") << "Function " << op << " is replaced with " << d_symbol_map[op] << std::endl;
- d_model_replace_f[op] = d_symbol_map[op];
- }else{
- d_symbol_map[op] = op;
- }
- }
- children[0] = d_symbol_map[op];
- //make sure all children have been taken care of
- for( size_t i=0; i<n.getNumChildren(); i++ ){
- TypeNode tn = children[i+1].getType();
- TypeNode tna = getTypeForId( d_op_arg_types[op][i] );
- if( tn!=tna ){
- if( n[i].isConst() ){
- children[i+1] = getNewSymbol( n[i], tna );
- }else{
- Trace("sort-inference-warn") << "Sort inference created bad child: " << n << " " << n[i] << " " << tn << " " << tna << std::endl;
- Assert( false );
- }
- }
- }
- return NodeManager::currentNM()->mkNode( kind::APPLY_UF, children );
- }else{
- std::map< Node, Node >::iterator it = var_bound.find( n );
- if( it!=var_bound.end() ){
- return it->second;
- }else if( n.getKind() == kind::VARIABLE || n.getKind() == kind::SKOLEM ){
- if( d_symbol_map.find( n )==d_symbol_map.end() ){
- TypeNode tn = getOrCreateTypeForId( d_op_return_types[n], n.getType() );
- d_symbol_map[n] = getNewSymbol( n, tn );
- }
- return d_symbol_map[n];
- }else if( n.isConst() ){
- //just return n, we will fix at higher scope
- return n;
- }else{
- if( childChanged ){
- return NodeManager::currentNM()->mkNode( n.getKind(), children );
- }else{
- return n;
- }
- }
- }
-
-}
-
-Node SortInference::mkInjection( TypeNode tn1, TypeNode tn2 ) {
- std::vector< TypeNode > tns;
- tns.push_back( tn1 );
- TypeNode typ = NodeManager::currentNM()->mkFunctionType( tns, tn2 );
- Node f = NodeManager::currentNM()->mkSkolem( "inj", typ, "injection for monotonicity constraint" );
- Trace("sort-inference") << "-> Make injection " << f << " from " << tn1 << " to " << tn2 << std::endl;
- Node v1 = NodeManager::currentNM()->mkBoundVar( "?x", tn1 );
- Node v2 = NodeManager::currentNM()->mkBoundVar( "?y", tn1 );
- Node ret = NodeManager::currentNM()->mkNode( kind::FORALL,
- NodeManager::currentNM()->mkNode( kind::BOUND_VAR_LIST, v1, v2 ),
- NodeManager::currentNM()->mkNode( kind::OR,
- NodeManager::currentNM()->mkNode( kind::APPLY_UF, f, v1 ).eqNode( NodeManager::currentNM()->mkNode( kind::APPLY_UF, f, v2 ) ).negate(),
- v1.eqNode( v2 ) ) );
- ret = theory::Rewriter::rewrite( ret );
- return ret;
-}
-
-int SortInference::getSortId( Node n ) {
- Node op = n.getKind()==kind::APPLY_UF ? n.getOperator() : n;
- if( d_op_return_types.find( op )!=d_op_return_types.end() ){
- return d_type_union_find.getRepresentative( d_op_return_types[op] );
- }else{
- return 0;
- }
-}
-
-int SortInference::getSortId( Node f, Node v ) {
- if( d_var_types.find( f )!=d_var_types.end() ){
- return d_type_union_find.getRepresentative( d_var_types[f][v] );
- }else{
- return 0;
- }
-}
-
-void SortInference::setSkolemVar( Node f, Node v, Node sk ){
- Trace("sort-inference-temp") << "Set skolem var for " << f << ", variable " << v << std::endl;
- if( isWellSortedFormula( f ) && d_var_types.find( f )==d_var_types.end() ){
- //calculate the sort for variables if not done so already
- std::map< Node, Node > var_bound;
- process( f, var_bound );
- }
- d_op_return_types[sk] = getSortId( f, v );
- Trace("sort-inference-temp") << "Set skolem sort id for " << sk << " to " << d_op_return_types[sk] << std::endl;
-}
-
-bool SortInference::isWellSortedFormula( Node n ) {
- if( n.getType().isBoolean() && n.getKind()!=kind::APPLY_UF ){
- for( unsigned i=0; i<n.getNumChildren(); i++ ){
- if( !isWellSortedFormula( n[i] ) ){
- return false;
- }
- }
- return true;
- }else{
- return isWellSorted( n );
- }
-}
-
-bool SortInference::isWellSorted( Node n ) {
- if( getSortId( n )==0 ){
- return false;
- }else{
- if( n.getKind()==kind::APPLY_UF ){
- for( unsigned i=0; i<n.getNumChildren(); i++ ){
- int s1 = getSortId( n[i] );
- int s2 = d_type_union_find.getRepresentative( d_op_arg_types[ n.getOperator() ][i] );
- if( s1!=s2 ){
- return false;
- }
- if( !isWellSorted( n[i] ) ){
- return false;
- }
- }
- }
- return true;
- }
-}
-
-void SortInference::getSortConstraints( Node n, UnionFind& uf ) {
- if( n.getKind()==kind::APPLY_UF ){
- for( unsigned i=0; i<n.getNumChildren(); i++ ){
- getSortConstraints( n[i], uf );
- uf.setEqual( getSortId( n[i] ), d_type_union_find.getRepresentative( d_op_arg_types[ n.getOperator() ][i] ) );
- }
- }
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file sort_inference.h
- ** \verbatim
- ** Original author: Andrew Reynolds
- ** 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 Pre-process step for performing sort inference
- **/
-
-#include "cvc4_private.h"
-
-#ifndef __CVC4__SORT_INFERENCE_H
-#define __CVC4__SORT_INFERENCE_H
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <map>
-#include "expr/node.h"
-#include "expr/type_node.h"
-
-namespace CVC4 {
-
-class SortInference {
-private:
- //all subsorts
- std::vector< int > d_sub_sorts;
- std::map< int, bool > d_non_monotonic_sorts;
- std::map< TypeNode, std::vector< int > > d_type_sub_sorts;
- void recordSubsort( TypeNode tn, int s );
-public:
- class UnionFind {
- public:
- UnionFind(){}
- UnionFind( UnionFind& c ){
- set( c );
- }
- std::map< int, int > d_eqc;
- //pairs that must be disequal
- std::vector< std::pair< int, int > > d_deq;
- void print(const char * c);
- void clear() { d_eqc.clear(); d_deq.clear(); }
- void set( UnionFind& c );
- int getRepresentative( int t );
- void setEqual( int t1, int t2 );
- void setDisequal( int t1, int t2 ){ d_deq.push_back( std::pair< int, int >( t1, t2 ) ); }
- bool areEqual( int t1, int t2 ) { return getRepresentative( t1 )==getRepresentative( t2 ); }
- bool isValid();
- };
-private:
- int sortCount;
- int initialSortCount;
- UnionFind d_type_union_find;
- std::map< int, TypeNode > d_type_types;
- std::map< TypeNode, int > d_id_for_types;
- //for apply uf operators
- std::map< Node, int > d_op_return_types;
- std::map< Node, std::vector< int > > d_op_arg_types;
- //for bound variables
- std::map< Node, std::map< Node, int > > d_var_types;
- //get representative
- void setEqual( int t1, int t2 );
- int getIdForType( TypeNode tn );
- void printSort( const char* c, int t );
- //process
- int process( Node n, std::map< Node, Node >& var_bound );
-//for monotonicity inference
-private:
- void processMonotonic( Node n, bool pol, bool hasPol, std::map< Node, Node >& var_bound );
-
-//for rewriting
-private:
- //mapping from old symbols to new symbols
- std::map< Node, Node > d_symbol_map;
- //mapping from constants to new symbols
- std::map< TypeNode, std::map< Node, Node > > d_const_map;
- //helper functions for simplify
- TypeNode getOrCreateTypeForId( int t, TypeNode pref );
- TypeNode getTypeForId( int t );
- Node getNewSymbol( Node old, TypeNode tn );
- //simplify
- Node simplify( Node n, std::map< Node, Node >& var_bound );
- //make injection
- Node mkInjection( TypeNode tn1, TypeNode tn2 );
- //reset
- void reset();
-public:
- SortInference() : sortCount( 1 ){}
- ~SortInference(){}
-
- bool simplify( std::vector< Node >& assertions );
- //get sort id for term n
- int getSortId( Node n );
- //get sort id for variable of quantified formula f
- int getSortId( Node f, Node v );
- //set that sk is the skolem variable of v for quantifier f
- void setSkolemVar( Node f, Node v, Node sk );
-public:
- //is well sorted
- bool isWellSortedFormula( Node n );
- bool isWellSorted( Node n );
- //get constraints for being well-typed according to computed sub-types
- void getSortConstraints( Node n, SortInference::UnionFind& uf );
-public:
- //list of all functions and the uninterpreted symbols they were replaced with
- std::map< Node, Node > d_model_replace_f;
-};
-
-}
-
-#endif
+++ /dev/null
-/********************* */
-/*! \file statistics.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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "util/statistics.h"
-#include "util/statistics_registry.h" // for details about class Stat
-
-#include <typeinfo>
-
-namespace CVC4 {
-
-std::string StatisticsBase::s_regDelim("::");
-
-bool StatisticsBase::StatCmp::operator()(const Stat* s1, const Stat* s2) const {
- return s1->getName() < s2->getName();
-}
-
-StatisticsBase::iterator::value_type StatisticsBase::iterator::operator*() const {
- return std::make_pair((*d_it)->getName(), (*d_it)->getValue());
-}
-
-StatisticsBase::StatisticsBase() :
- d_prefix(),
- d_stats() {
-}
-
-StatisticsBase::StatisticsBase(const StatisticsBase& stats) :
- d_prefix(stats.d_prefix),
- d_stats() {
-}
-
-StatisticsBase& StatisticsBase::operator=(const StatisticsBase& stats) {
- d_prefix = stats.d_prefix;
- return *this;
-}
-
-void Statistics::copyFrom(const StatisticsBase& stats) {
- // This is ugly, but otherwise we have to introduce a "friend" relation for
- // Base to its derived class (really obnoxious).
- StatSet::const_iterator i_begin = ((const Statistics*) &stats)->d_stats.begin();
- StatSet::const_iterator i_end = ((const Statistics*) &stats)->d_stats.end();
- for(StatSet::const_iterator i = i_begin; i != i_end; ++i) {
- SExprStat* p = new SExprStat((*i)->getName(), (*i)->getValue());
- d_stats.insert(p);
- }
-}
-
-void Statistics::clear() {
- for(StatSet::iterator i = d_stats.begin(); i != d_stats.end(); ++i) {
- delete *i;
- }
- d_stats.clear();
-}
-
-Statistics::Statistics(const StatisticsBase& stats) :
- StatisticsBase(stats) {
- copyFrom(stats);
-}
-
-Statistics::Statistics(const Statistics& stats) :
- StatisticsBase(stats) {
- copyFrom(stats);
-}
-
-Statistics::~Statistics() {
- clear();
-}
-
-Statistics& Statistics::operator=(const StatisticsBase& stats) {
- clear();
- this->StatisticsBase::operator=(stats);
- copyFrom(stats);
-
- return *this;
-}
-
-Statistics& Statistics::operator=(const Statistics& stats) {
- return this->operator=((const StatisticsBase&)stats);
-}
-
-StatisticsBase::const_iterator StatisticsBase::begin() const {
- return iterator(d_stats.begin());
-}
-
-StatisticsBase::const_iterator StatisticsBase::end() const {
- return iterator(d_stats.end());
-}
-
-void StatisticsBase::flushInformation(std::ostream &out) const {
-#ifdef CVC4_STATISTICS_ON
- for(StatSet::iterator i = d_stats.begin();
- i != d_stats.end();
- ++i) {
- Stat* s = *i;
- if(d_prefix != "") {
- out << d_prefix << s_regDelim;
- }
- s->flushStat(out);
- out << std::endl;
- }
-#endif /* CVC4_STATISTICS_ON */
-}
-
-SExpr StatisticsBase::getStatistic(std::string name) const {
- SExpr value;
- IntStat s(name, 0);
- StatSet::iterator i = d_stats.find(&s);
- if(i != d_stats.end()) {
- return (*i)->getValue();
- } else {
- return SExpr();
- }
-}
-
-void StatisticsBase::setPrefix(const std::string& prefix) {
- d_prefix = prefix;
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file statistics.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_public.h"
-
-#ifndef __CVC4__STATISTICS_H
-#define __CVC4__STATISTICS_H
-
-#include "util/sexpr.h"
-
-#include <string>
-#include <ostream>
-#include <set>
-#include <iterator>
-#include <utility>
-
-namespace CVC4 {
-
-class Stat;
-
-class CVC4_PUBLIC StatisticsBase {
-protected:
-
- static std::string s_regDelim;
-
- /** A helper class for comparing two statistics */
- struct StatCmp {
- bool operator()(const Stat* s1, const Stat* s2) const;
- };/* struct StatisticsRegistry::StatCmp */
-
- /** A type for a set of statistics */
- typedef std::set< Stat*, StatCmp > StatSet;
-
- std::string d_prefix;
-
- /** The set of statistics in this object */
- StatSet d_stats;
-
- StatisticsBase();
- StatisticsBase(const StatisticsBase& stats);
- StatisticsBase& operator=(const StatisticsBase& stats);
-
-public:
-
- virtual ~StatisticsBase() { }
-
- class CVC4_PUBLIC iterator : public std::iterator< std::input_iterator_tag, std::pair<std::string, SExpr> > {
- StatSet::iterator d_it;
-
- iterator(StatSet::iterator it) : d_it(it) { }
-
- friend class StatisticsBase;
-
- public:
- iterator() : d_it() { }
- iterator(const iterator& it) : d_it(it.d_it) { }
- value_type operator*() const;
- iterator& operator++() { ++d_it; return *this; }
- iterator operator++(int) { iterator old = *this; ++d_it; return old; }
- bool operator==(const iterator& i) const { return d_it == i.d_it; }
- bool operator!=(const iterator& i) const { return d_it != i.d_it; }
- };/* class StatisticsBase::iterator */
-
- /** An iterator type over a set of statistics. */
- typedef iterator const_iterator;
-
- /** Set the output prefix for this set of statistics. */
- virtual void setPrefix(const std::string& prefix);
-
- /** Flush all statistics to the given output stream. */
- void flushInformation(std::ostream& out) const;
-
- /** Get the value of a named statistic. */
- SExpr getStatistic(std::string name) const;
-
- /**
- * Get an iterator to the beginning of the range of the set of
- * statistics.
- */
- const_iterator begin() const;
-
- /**
- * Get an iterator to the end of the range of the set of statistics.
- */
- const_iterator end() const;
-
-};/* class StatisticsBase */
-
-class CVC4_PUBLIC Statistics : public StatisticsBase {
- void clear();
- void copyFrom(const StatisticsBase&);
-
-public:
-
- /**
- * Override the copy constructor to do a "deep" copy of statistics
- * values.
- */
- Statistics(const StatisticsBase& stats);
- Statistics(const Statistics& stats);
-
- ~Statistics();
-
- /**
- * Override the assignment operator to do a "deep" copy of statistics
- * values.
- */
- Statistics& operator=(const StatisticsBase& stats);
- Statistics& operator=(const Statistics& stats);
-
-};/* class Statistics */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__STATISTICS_H */
+++ /dev/null
-%{
-#include "util/statistics.h"
-
-#ifdef SWIGJAVA
-
-#include "bindings/java_iterator_adapter.h"
-#include "bindings/java_stream_adapters.h"
-
-#endif /* SWIGJAVA */
-%}
-
-%rename(assign) CVC4::Statistics::operator=(const StatisticsBase&);
-%rename(assign) CVC4::Statistics::operator=(const Statistics& stats);
-
-#ifdef SWIGJAVA
-
-// Instead of StatisticsBase::begin() and end(), create an
-// iterator() method on the Java side that returns a Java-style
-// Iterator.
-%ignore CVC4::StatisticsBase::begin();
-%ignore CVC4::StatisticsBase::end();
-%ignore CVC4::StatisticsBase::begin() const;
-%ignore CVC4::StatisticsBase::end() const;
-%extend CVC4::StatisticsBase {
- CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> iterator() {
- return CVC4::JavaIteratorAdapter<CVC4::StatisticsBase>(*$self);
- }
-}
-
-// StatisticsBase is "iterable" on the Java side
-%typemap(javainterfaces) CVC4::StatisticsBase "java.lang.Iterable<Object[]>";
-
-// the JavaIteratorAdapter should not be public, and implements Iterator
-%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "class";
-%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "java.util.Iterator<Object[]>";
-// add some functions to the Java side (do it here because there's no way to do these in C++)
-%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase> "
- public void remove() {
- throw new java.lang.UnsupportedOperationException();
- }
-
- public Object[] next() {
- if(hasNext()) {
- return getNext();
- } else {
- throw new java.util.NoSuchElementException();
- }
- }
-"
-// getNext() just allows C++ iterator access from Java-side next(), make it private
-%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::StatisticsBase>::getNext() "private";
-
-// map the types appropriately. for statistics, the "payload" of the iterator is an Object[].
-// These Object arrays are always of two elements, the first is a String and the second an
-// SExpr. (On the C++ side, it is a std::pair<std::string, SExpr>.)
-%typemap(jni) CVC4::StatisticsBase::const_iterator::value_type "jobjectArray";
-%typemap(jtype) CVC4::StatisticsBase::const_iterator::value_type "java.lang.Object[]";
-%typemap(jstype) CVC4::StatisticsBase::const_iterator::value_type "java.lang.Object[]";
-%typemap(javaout) CVC4::StatisticsBase::const_iterator::value_type { return $jnicall; }
-%typemap(out) CVC4::StatisticsBase::const_iterator::value_type {
- $result = jenv->NewObjectArray(2, jenv->FindClass("java/lang/Object"), $null);
- jenv->SetObjectArrayElement($result, 0, jenv->NewStringUTF($1.first.c_str()));
- jclass clazz = jenv->FindClass("edu/nyu/acsys/CVC4/SExpr");
- jmethodID methodid = jenv->GetMethodID(clazz, "<init>", "(JZ)V");
- jenv->SetObjectArrayElement($result, 1, jenv->NewObject(clazz, methodid, reinterpret_cast<long>(new CVC4::SExpr($1.second)), true));
- };
-
-#endif /* SWIGJAVA */
-
-%include "util/statistics.h"
-
-#ifdef SWIGJAVA
-
-%include "bindings/java_iterator_adapter.h"
-%include "bindings/java_stream_adapters.h"
-
-%template(JavaIteratorAdapter_StatisticsBase) CVC4::JavaIteratorAdapter<CVC4::StatisticsBase>;
-
-#endif /* SWIGJAVA */
+++ /dev/null
-/********************* */
-/*! \file statistics_registry.cpp
- ** \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 [[ Add one-line brief description here ]]
- **
- ** [[ Add lengthier description here ]]
- ** \todo document this file
- **/
-
-#include "util/statistics_registry.h"
-#include "expr/expr_manager.h"
-#include "lib/clock_gettime.h"
-#include "smt/smt_engine.h"
-
-#ifndef __BUILDING_STATISTICS_FOR_EXPORT
-# include "smt/smt_engine_scope.h"
-#endif /* ! __BUILDING_STATISTICS_FOR_EXPORT */
-
-#ifdef CVC4_STATISTICS_ON
-# define __CVC4_USE_STATISTICS true
-#else
-# define __CVC4_USE_STATISTICS false
-#endif
-
-namespace CVC4 {
-
-namespace stats {
-
-// This is a friend of SmtEngine, just to reach in and get it.
-// this isn't a class function because then there's a cyclic
-// dependence.
-inline StatisticsRegistry* getStatisticsRegistry(SmtEngine* smt) {
- return smt->d_statisticsRegistry;
-}
-
-inline StatisticsRegistry* getStatisticsRegistry(ExprManager* em) {
- return em->getStatisticsRegistry();
-}
-
-}/* CVC4::stats namespace */
-
-#ifndef __BUILDING_STATISTICS_FOR_EXPORT
-
-StatisticsRegistry* StatisticsRegistry::current() {
- return stats::getStatisticsRegistry(smt::currentSmtEngine());
-}
-
-void StatisticsRegistry::registerStat(Stat* s) throw(CVC4::IllegalArgumentException) {
-#ifdef CVC4_STATISTICS_ON
- StatSet& stats = current()->d_stats;
- CheckArgument(stats.find(s) == stats.end(), s,
- "Statistic `%s' was already registered with this registry.",
- s->getName().c_str());
- stats.insert(s);
-#endif /* CVC4_STATISTICS_ON */
-}/* StatisticsRegistry::registerStat() */
-
-void StatisticsRegistry::unregisterStat(Stat* s) throw(CVC4::IllegalArgumentException) {
-#ifdef CVC4_STATISTICS_ON
- StatSet& stats = current()->d_stats;
- CheckArgument(stats.find(s) != stats.end(), s,
- "Statistic `%s' was not registered with this registry.",
- s->getName().c_str());
- stats.erase(s);
-#endif /* CVC4_STATISTICS_ON */
-}/* StatisticsRegistry::unregisterStat() */
-
-#endif /* ! __BUILDING_STATISTICS_FOR_EXPORT */
-
-void StatisticsRegistry::registerStat_(Stat* s) throw(CVC4::IllegalArgumentException) {
-#ifdef CVC4_STATISTICS_ON
- CheckArgument(d_stats.find(s) == d_stats.end(), s);
- d_stats.insert(s);
-#endif /* CVC4_STATISTICS_ON */
-}/* StatisticsRegistry::registerStat_() */
-
-void StatisticsRegistry::unregisterStat_(Stat* s) throw(CVC4::IllegalArgumentException) {
-#ifdef CVC4_STATISTICS_ON
- CheckArgument(d_stats.find(s) != d_stats.end(), s);
- d_stats.erase(s);
-#endif /* CVC4_STATISTICS_ON */
-}/* StatisticsRegistry::unregisterStat_() */
-
-void StatisticsRegistry::flushStat(std::ostream &out) const {
-#ifdef CVC4_STATISTICS_ON
- flushInformation(out);
-#endif /* CVC4_STATISTICS_ON */
-}
-
-void StatisticsRegistry::flushInformation(std::ostream &out) const {
-#ifdef CVC4_STATISTICS_ON
- this->StatisticsBase::flushInformation(out);
-#endif /* CVC4_STATISTICS_ON */
-}
-
-void TimerStat::start() {
- if(__CVC4_USE_STATISTICS) {
- CheckArgument(!d_running, *this, "timer already running");
- clock_gettime(CLOCK_MONOTONIC, &d_start);
- d_running = true;
- }
-}/* TimerStat::start() */
-
-void TimerStat::stop() {
- if(__CVC4_USE_STATISTICS) {
- CheckArgument(d_running, *this, "timer not running");
- ::timespec end;
- clock_gettime(CLOCK_MONOTONIC, &end);
- d_data += end - d_start;
- d_running = false;
- }
-}/* TimerStat::stop() */
-
-bool TimerStat::running() const {
- return d_running;
-}/* TimerStat::running() */
-
-timespec TimerStat::getData() const {
- ::timespec data = d_data;
- if(__CVC4_USE_STATISTICS && d_running) {
- ::timespec end;
- clock_gettime(CLOCK_MONOTONIC, &end);
- data += end - d_start;
- }
- return data;
-}
-
-SExpr TimerStat::getValue() const {
- ::timespec data = d_data;
- if(__CVC4_USE_STATISTICS && d_running) {
- ::timespec end;
- clock_gettime(CLOCK_MONOTONIC, &end);
- data += end - d_start;
- }
- std::stringstream ss;
- ss << std::fixed << std::setprecision(8) << data;
- return SExpr(Rational::fromDecimal(ss.str()));
-}/* TimerStat::getValue() */
-
-RegisterStatistic::RegisterStatistic(ExprManager& em, Stat* stat) :
- d_reg(stats::getStatisticsRegistry(&em)),
- d_stat(stat) {
- d_reg->registerStat_(d_stat);
-}
-
-RegisterStatistic::RegisterStatistic(SmtEngine& smt, Stat* stat) :
- d_reg(stats::getStatisticsRegistry(&smt)),
- d_stat(stat) {
- d_reg->registerStat_(d_stat);
-}
-
-}/* CVC4 namespace */
-
-#undef __CVC4_USE_STATISTICS
+++ /dev/null
-/********************* */
-/*! \file statistics_registry.h
- ** \verbatim
- ** Original author: Morgan Deters
- ** Major contributors: Tim King
- ** Minor contributors (to current version): Kshitij Bansal
- ** 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 Statistics utility classes
- **
- ** Statistics utility classes, including classes for holding (and referring
- ** to) statistics, the statistics registry, and some other associated
- ** classes.
- **/
-
-#include "cvc4_private_library.h"
-
-#ifndef __CVC4__STATISTICS_REGISTRY_H
-#define __CVC4__STATISTICS_REGISTRY_H
-
-#include "util/statistics.h"
-#include "util/exception.h"
-#include "lib/clock_gettime.h"
-
-#include <sstream>
-#include <iomanip>
-#include <ctime>
-#include <vector>
-#include <map>
-#include <stdint.h>
-#include <cassert>
-
-namespace CVC4 {
-
-#ifdef CVC4_STATISTICS_ON
-# define __CVC4_USE_STATISTICS true
-#else
-# define __CVC4_USE_STATISTICS false
-#endif
-
-class ExprManager;
-class SmtEngine;
-
-/**
- * The base class for all statistics.
- *
- * This base class keeps the name of the statistic and declares the (pure)
- * virtual function flushInformation(). Derived classes must implement
- * this function and pass their name to the base class constructor.
- *
- * This class also (statically) maintains the delimiter used to separate
- * the name and the value when statistics are output.
- */
-class Stat {
-protected:
- /** The name of this statistic */
- std::string d_name;
-
-public:
-
- /** Nullary constructor, does nothing */
- Stat() { }
-
- /**
- * Construct a statistic with the given name. Debug builds of CVC4
- * will throw an assertion exception if the given name contains the
- * statistic delimiter string.
- */
- Stat(const std::string& name) throw(CVC4::IllegalArgumentException) :
- d_name(name) {
- if(__CVC4_USE_STATISTICS) {
- CheckArgument(d_name.find(", ") == std::string::npos, name,
- "Statistics names cannot include a comma (',')");
- }
- }
-
- /** Destruct a statistic. This base-class version does nothing. */
- virtual ~Stat() {}
-
- /**
- * Flush the value of this statistic to an output stream. Should
- * finish the output with an end-of-line character.
- */
- virtual void flushInformation(std::ostream& out) const = 0;
-
- /**
- * Flush the name,value pair of this statistic to an output stream.
- * Uses the statistic delimiter string between name and value.
- *
- * May be redefined by a child class
- */
- virtual void flushStat(std::ostream& out) const {
- if(__CVC4_USE_STATISTICS) {
- out << d_name << ", ";
- flushInformation(out);
- }
- }
-
- /** Get the name of this statistic. */
- const std::string& getName() const {
- return d_name;
- }
-
- /** Get the value of this statistic as a string. */
- virtual SExpr getValue() const {
- std::stringstream ss;
- flushInformation(ss);
- return ss.str();
- }
-
-};/* class Stat */
-
-// A generic way of making a SExpr from templated stats code.
-// for example, the uint64_t version ensures that we create
-// Integer-SExprs for ReadOnlyDataStats (like those inside
-// Minisat) without having to specialize the entire
-// ReadOnlyDataStat class template.
-template <class T>
-inline SExpr mkSExpr(const T& x) {
- std::stringstream ss;
- ss << x;
- return ss.str();
-}
-
-template <>
-inline SExpr mkSExpr(const uint64_t& x) {
- return Integer(x);
-}
-
-template <>
-inline SExpr mkSExpr(const int64_t& x) {
- return Integer(x);
-}
-
-template <>
-inline SExpr mkSExpr(const int& x) {
- return Integer(x);
-}
-
-template <>
-inline SExpr mkSExpr(const Integer& x) {
- return x;
-}
-
-template <>
-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());
-}
-
-template <>
-inline SExpr mkSExpr(const Rational& x) {
- return x;
-}
-
-/**
- * A class to represent a "read-only" data statistic of type T. Adds to
- * the Stat base class the pure virtual function getData(), which returns
- * type T, and flushInformation(), which outputs the statistic value to an
- * output stream (using the same existing stream insertion operator).
- *
- * Template class T must have stream insertion operation defined:
- * std::ostream& operator<<(std::ostream&, const T&)
- */
-template <class T>
-class ReadOnlyDataStat : public Stat {
-public:
- /** The "payload" type of this data statistic (that is, T). */
- typedef T payload_t;
-
- /** Construct a read-only data statistic with the given name. */
- ReadOnlyDataStat(const std::string& name) :
- Stat(name) {
- }
-
- /** Get the value of the statistic. */
- virtual T getData() const = 0;
-
- /** Flush the value of the statistic to the given output stream. */
- void flushInformation(std::ostream& out) const {
- if(__CVC4_USE_STATISTICS) {
- out << getData();
- }
- }
-
- SExpr getValue() const {
- return mkSExpr(getData());
- }
-
-};/* class ReadOnlyDataStat<T> */
-
-
-/**
- * A data statistic class. This class extends a read-only data statistic
- * with assignment (the statistic can be set as well as read). This class
- * adds to the read-only case a pure virtual function setData(), thus
- * providing the basic interface for a data statistic: getData() to get the
- * statistic value, and setData() to set it.
- *
- * As with the read-only data statistic class, template class T must have
- * stream insertion operation defined:
- * std::ostream& operator<<(std::ostream&, const T&)
- */
-template <class T>
-class DataStat : public ReadOnlyDataStat<T> {
-public:
-
- /** Construct a data statistic with the given name. */
- DataStat(const std::string& name) :
- ReadOnlyDataStat<T>(name) {
- }
-
- /** Set the data statistic. */
- virtual void setData(const T&) = 0;
-
-};/* class DataStat<T> */
-
-
-/**
- * A data statistic that references a data cell of type T,
- * implementing getData() by referencing that memory cell, and
- * setData() by reassigning the statistic to point to the new
- * data cell. The referenced data cell is kept as a const
- * reference, meaning the referenced data is never actually
- * modified by this class (it must be externally modified for
- * a reference statistic to make sense). A common use for
- * this type of statistic is to output a statistic that is kept
- * outside the statistics package (for example, one that's kept
- * by a theory implementation for internal heuristic purposes,
- * which is important to keep even if statistics are turned off).
- *
- * Template class T must have an assignment operator=().
- */
-template <class T>
-class ReferenceStat : public DataStat<T> {
-private:
- /** The referenced data cell */
- const T* d_data;
-
-public:
- /**
- * Construct a reference stat with the given name and a reference
- * to NULL.
- */
- ReferenceStat(const std::string& name) :
- DataStat<T>(name),
- d_data(NULL) {
- }
-
- /**
- * Construct a reference stat with the given name and a reference to
- * the given data.
- */
- ReferenceStat(const std::string& name, const T& data) :
- DataStat<T>(name),
- d_data(NULL) {
- setData(data);
- }
-
- /** Set this reference statistic to refer to the given data cell. */
- void setData(const T& t) {
- if(__CVC4_USE_STATISTICS) {
- d_data = &t;
- }
- }
-
- /** Get the value of the referenced data cell. */
- T getData() const {
- return *d_data;
- }
-
-};/* class ReferenceStat<T> */
-
-
-/**
- * A data statistic that keeps a T and sets it with setData().
- *
- * Template class T must have an operator=() and a copy constructor.
- */
-template <class T>
-class BackedStat : public DataStat<T> {
-protected:
- /** The internally-kept statistic value */
- T d_data;
-
-public:
-
- /** Construct a backed statistic with the given name and initial value. */
- BackedStat(const std::string& name, const T& init) :
- DataStat<T>(name),
- d_data(init) {
- }
-
- /** Set the underlying data value to the given value. */
- void setData(const T& t) {
- if(__CVC4_USE_STATISTICS) {
- d_data = t;
- }
- }
-
- /** Identical to setData(). */
- BackedStat<T>& operator=(const T& t) {
- if(__CVC4_USE_STATISTICS) {
- d_data = t;
- }
- return *this;
- }
-
- /** Get the underlying data value. */
- T getData() const {
- return d_data;
- }
-
-};/* class BackedStat<T> */
-
-
-/**
- * A wrapper Stat for another Stat.
- *
- * This type of Stat is useful in cases where a module (like the
- * CongruenceClosure module) might keep its own statistics, but might
- * be instantiated in many contexts by many clients. This makes such
- * a statistic inappopriate to register with the StatisticsRegistry
- * directly, as all would be output with the same name (and may be
- * unregistered too quickly anyway). A WrappedStat allows the calling
- * client (say, TheoryUF) to wrap the Stat from the client module,
- * giving it a globally unique name.
- */
-template <class Stat>
-class WrappedStat : public ReadOnlyDataStat<typename Stat::payload_t> {
- typedef typename Stat::payload_t T;
-
- const ReadOnlyDataStat<T>& d_stat;
-
- /** Private copy constructor undefined (no copy permitted). */
- WrappedStat(const WrappedStat&) CVC4_UNDEFINED;
- /** Private assignment operator undefined (no copy permitted). */
- WrappedStat<T>& operator=(const WrappedStat&) CVC4_UNDEFINED;
-
-public:
-
- /**
- * Construct a wrapped statistic with the given name that wraps the
- * given statistic.
- */
- WrappedStat(const std::string& name, const ReadOnlyDataStat<T>& stat) :
- ReadOnlyDataStat<T>(name),
- d_stat(stat) {
- }
-
- /** Get the data of the underlying (wrapped) statistic. */
- T getData() const {
- return d_stat.getData();
- }
-
- SExpr getValue() const {
- return d_stat.getValue();
- }
-
-};/* class WrappedStat<T> */
-
-/**
- * A backed integer-valued (64-bit signed) statistic.
- * This doesn't functionally differ from its base class BackedStat<int64_t>,
- * except for adding convenience functions for dealing with integers.
- */
-class IntStat : public BackedStat<int64_t> {
-public:
-
- /**
- * Construct an integer-valued statistic with the given name and
- * initial value.
- */
- IntStat(const std::string& name, int64_t init) :
- BackedStat<int64_t>(name, init) {
- }
-
- /** Increment the underlying integer statistic. */
- IntStat& operator++() {
- if(__CVC4_USE_STATISTICS) {
- ++d_data;
- }
- return *this;
- }
-
- /** Increment the underlying integer statistic by the given amount. */
- IntStat& operator+=(int64_t val) {
- if(__CVC4_USE_STATISTICS) {
- d_data += val;
- }
- return *this;
- }
-
- /** Keep the maximum of the current statistic value and the given one. */
- void maxAssign(int64_t val) {
- if(__CVC4_USE_STATISTICS) {
- if(d_data < val) {
- d_data = val;
- }
- }
- }
-
- /** Keep the minimum of the current statistic value and the given one. */
- void minAssign(int64_t val) {
- if(__CVC4_USE_STATISTICS) {
- if(d_data > val) {
- d_data = val;
- }
- }
- }
-
- SExpr getValue() const {
- return SExpr(Integer(d_data));
- }
-
-};/* class IntStat */
-
-template <class T>
-class SizeStat : public Stat {
-private:
- const T& d_sized;
-public:
- SizeStat(const std::string&name, const T& sized) :
- Stat(name), d_sized(sized) {}
- ~SizeStat() {}
-
- void flushInformation(std::ostream& out) const {
- out << d_sized.size();
- }
-
- SExpr getValue() const {
- return SExpr(Integer(d_sized.size()));
- }
-
-};/* class SizeStat */
-
-/**
- * The value for an AverageStat is the running average of (e1, e_2, ..., e_n),
- * (e1 + e_2 + ... + e_n)/n,
- * where e_i is an entry added by an addEntry(e_i) call.
- * The value is initially always 0.
- * (This is to avoid making parsers confused.)
- *
- * A call to setData() will change the running average but not reset the
- * running count, so should generally be avoided. Call addEntry() to add
- * an entry to the average calculation.
- */
-class AverageStat : public BackedStat<double> {
-private:
- /**
- * The number of accumulations of the running average that we
- * have seen so far.
- */
- uint32_t d_count;
- double d_sum;
-
-public:
- /** Construct an average statistic with the given name. */
- AverageStat(const std::string& name) :
- BackedStat<double>(name, 0.0), d_count(0), d_sum(0.0) {
- }
-
- /** Add an entry to the running-average calculation. */
- void addEntry(double e) {
- if(__CVC4_USE_STATISTICS) {
- ++d_count;
- d_sum += e;
- setData(d_sum / d_count);
- }
- }
-
- SExpr getValue() const {
- std::stringstream ss;
- ss << std::fixed << std::setprecision(8) << d_data;
- return SExpr(Rational::fromDecimal(ss.str()));
- }
-
-};/* class AverageStat */
-
-/** A statistic that contains a SExpr. */
-class SExprStat : public BackedStat<SExpr> {
-public:
-
- /**
- * Construct a SExpr-valued statistic with the given name and
- * initial value.
- */
- SExprStat(const std::string& name, const SExpr& init) :
- BackedStat<SExpr>(name, init) {
- }
-
- SExpr getValue() const {
- return d_data;
- }
-
-};/* class SExprStat */
-
-template <class T>
-class ListStat : public Stat {
-private:
- typedef std::vector<T> List;
- List d_list;
-public:
-
- /**
- * Construct an integer-valued statistic with the given name and
- * initial value.
- */
- ListStat(const std::string& name) : Stat(name) {}
- ~ListStat() {}
-
- void flushInformation(std::ostream& out) const{
- if(__CVC4_USE_STATISTICS) {
- typename List::const_iterator i = d_list.begin(), end = d_list.end();
- out << "[";
- if(i != end){
- out << *i;
- ++i;
- for(; i != end; ++i){
- out << ", " << *i;
- }
- }
- out << "]";
- }
- }
-
- ListStat& operator<<(const T& val){
- if(__CVC4_USE_STATISTICS) {
- d_list.push_back(val);
- }
- return (*this);
- }
-
-};/* class ListStat */
-
-template <class T>
-class HistogramStat : public Stat {
-private:
- typedef std::map<T, unsigned int> Histogram;
- Histogram d_hist;
-public:
-
- /** Construct a histogram of a stream of entries. */
- HistogramStat(const std::string& name) : Stat(name) {}
- ~HistogramStat() {}
-
- void flushInformation(std::ostream& out) const{
- if(__CVC4_USE_STATISTICS) {
- typename Histogram::const_iterator i = d_hist.begin();
- typename Histogram::const_iterator end = d_hist.end();
- out << "[";
- while(i != end){
- const T& key = (*i).first;
- unsigned int count = (*i).second;
- out << "("<<key<<" : "<<count<< ")";
- ++i;
- if(i != end){
- out << ", ";
- }
- }
- out << "]";
- }
- }
-
- HistogramStat& operator<<(const T& val){
- if(__CVC4_USE_STATISTICS) {
- if(d_hist.find(val) == d_hist.end()){
- d_hist.insert(std::make_pair(val,0));
- }
- d_hist[val]++;
- }
- return (*this);
- }
-
-};/* class HistogramStat */
-
-/****************************************************************************/
-/* Statistics Registry */
-/****************************************************************************/
-
-/**
- * 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 {
-private:
-
- /** Private copy constructor undefined (no copy permitted). */
- StatisticsRegistry(const StatisticsRegistry&) CVC4_UNDEFINED;
-
-public:
-
- /** Construct an nameless statistics registry */
- StatisticsRegistry() {}
-
- /** Construct a statistics registry */
- StatisticsRegistry(const std::string& name)
- throw(CVC4::IllegalArgumentException) :
- Stat(name) {
- d_prefix = name;
- if(__CVC4_USE_STATISTICS) {
- CheckArgument(d_name.find(s_regDelim) == std::string::npos, name,
- "StatisticsRegistry names cannot contain the string \"%s\"",
- s_regDelim.c_str());
- }
- }
-
- /**
- * Set the name of this statistic registry, used as prefix during
- * output. (This version overrides StatisticsBase::setPrefix().)
- */
- void setPrefix(const std::string& name) {
- d_prefix = d_name = name;
- }
-
-#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && !defined(__BUILDING_STATISTICS_FOR_EXPORT)
- /** Get a pointer to the current statistics registry */
- static StatisticsRegistry* current();
-#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST) && ! __BUILDING_STATISTICS_FOR_EXPORT */
-
- /** Overridden to avoid the name being printed */
- void flushStat(std::ostream &out) const;
-
- virtual void flushInformation(std::ostream& out) const;
-
- SExpr getValue() const {
- 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((*i)->getValue());
- v.push_back(SExpr(w));
- }
- return SExpr(v);
- }
-
-#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && !defined(__BUILDING_STATISTICS_FOR_EXPORT)
- /** Register a new statistic, making it active. */
- static void registerStat(Stat* s) throw(CVC4::IllegalArgumentException);
-
- /** Unregister an active statistic, making it inactive. */
- static void unregisterStat(Stat* s) throw(CVC4::IllegalArgumentException);
-#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB) && ! __BUILDING_STATISTICS_FOR_EXPORT */
-
- /** Register a new statistic */
- void registerStat_(Stat* s) throw(CVC4::IllegalArgumentException);
-
- /** Unregister a new statistic */
- void unregisterStat_(Stat* s) throw(CVC4::IllegalArgumentException);
-
-};/* class StatisticsRegistry */
-
-}/* CVC4 namespace */
-
-/****************************************************************************/
-/* Some utility functions for timespec */
-/****************************************************************************/
-
-inline std::ostream& operator<<(std::ostream& os, const timespec& t);
-
-/** Compute the sum of two timespecs. */
-inline timespec& operator+=(timespec& a, const timespec& b) {
- using namespace CVC4;
- // assumes a.tv_nsec and b.tv_nsec are in range
- const long nsec_per_sec = 1000000000L; // one thousand million
- CheckArgument(a.tv_nsec >= 0 && a.tv_nsec < nsec_per_sec, a);
- CheckArgument(b.tv_nsec >= 0 && b.tv_nsec < nsec_per_sec, b);
- a.tv_sec += b.tv_sec;
- long nsec = a.tv_nsec + b.tv_nsec;
- assert(nsec >= 0);
- if(nsec < 0) {
- nsec += nsec_per_sec;
- --a.tv_sec;
- }
- if(nsec >= nsec_per_sec) {
- nsec -= nsec_per_sec;
- ++a.tv_sec;
- }
- assert(nsec >= 0 && nsec < nsec_per_sec);
- a.tv_nsec = nsec;
- return a;
-}
-
-/** Compute the difference of two timespecs. */
-inline timespec& operator-=(timespec& a, const timespec& b) {
- using namespace CVC4;
- // assumes a.tv_nsec and b.tv_nsec are in range
- const long nsec_per_sec = 1000000000L; // one thousand million
- CheckArgument(a.tv_nsec >= 0 && a.tv_nsec < nsec_per_sec, a);
- CheckArgument(b.tv_nsec >= 0 && b.tv_nsec < nsec_per_sec, b);
- a.tv_sec -= b.tv_sec;
- long nsec = a.tv_nsec - b.tv_nsec;
- if(nsec < 0) {
- nsec += nsec_per_sec;
- --a.tv_sec;
- }
- if(nsec >= nsec_per_sec) {
- nsec -= nsec_per_sec;
- ++a.tv_sec;
- }
- assert(nsec >= 0 && nsec < nsec_per_sec);
- a.tv_nsec = nsec;
- return a;
-}
-
-/** Add two timespecs. */
-inline timespec operator+(const timespec& a, const timespec& b) {
- timespec result = a;
- return result += b;
-}
-
-/** Subtract two timespecs. */
-inline timespec operator-(const timespec& a, const timespec& b) {
- timespec result = a;
- return result -= b;
-}
-
-/** Compare two timespecs for equality. */
-inline bool operator==(const timespec& a, const timespec& b) {
- // assumes a.tv_nsec and b.tv_nsec are in range
- return a.tv_sec == b.tv_sec && a.tv_nsec == b.tv_nsec;
-}
-
-/** Compare two timespecs for disequality. */
-inline bool operator!=(const timespec& a, const timespec& b) {
- // assumes a.tv_nsec and b.tv_nsec are in range
- return !(a == b);
-}
-
-/** Compare two timespecs, returning true iff a < b. */
-inline bool operator<(const timespec& a, const timespec& b) {
- // assumes a.tv_nsec and b.tv_nsec are in range
- return a.tv_sec < b.tv_sec ||
- (a.tv_sec == b.tv_sec && a.tv_nsec < b.tv_nsec);
-}
-
-/** Compare two timespecs, returning true iff a > b. */
-inline bool operator>(const timespec& a, const timespec& b) {
- // assumes a.tv_nsec and b.tv_nsec are in range
- return a.tv_sec > b.tv_sec ||
- (a.tv_sec == b.tv_sec && a.tv_nsec > b.tv_nsec);
-}
-
-/** Compare two timespecs, returning true iff a <= b. */
-inline bool operator<=(const timespec& a, const timespec& b) {
- // assumes a.tv_nsec and b.tv_nsec are in range
- return !(a > b);
-}
-
-/** Compare two timespecs, returning true iff a >= b. */
-inline bool operator>=(const timespec& a, const timespec& b) {
- // assumes a.tv_nsec and b.tv_nsec are in range
- return !(a < b);
-}
-
-/** Output a timespec on an output stream. */
-inline std::ostream& operator<<(std::ostream& os, const timespec& t) {
- // assumes t.tv_nsec is in range
- return os << t.tv_sec << "."
- << std::setfill('0') << std::setw(9) << std::right << t.tv_nsec;
-}
-
-namespace CVC4 {
-
-class CodeTimer;
-
-/**
- * A timer statistic. The timer can be started and stopped
- * 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> {
-
- // strange: timespec isn't placed in 'std' namespace ?!
- /** The last start time of this timer */
- timespec d_start;
-
- /** Whether this timer is currently running */
- bool d_running;
-
-public:
-
- typedef CVC4::CodeTimer CodeTimer;
-
- /**
- * Construct a timer statistic with the given name. Newly-constructed
- * timers have a 0.0 value and are not running.
- */
- TimerStat(const std::string& name) :
- BackedStat< timespec >(name, timespec()),
- d_running(false) {
- /* timespec is POD and so may not be initialized to zero;
- * here, ensure it is */
- d_data.tv_sec = d_data.tv_nsec = 0;
- }
-
- /** Start the timer. */
- void start();
-
- /**
- * Stop the timer and update the statistic value with the
- * accumulated time.
- */
- void stop();
-
- /** If the timer is currently running */
- bool running() const;
-
- timespec getData() const;
-
- SExpr getValue() const;
-
-};/* class TimerStat */
-
-/**
- * Utility class to make it easier to call stop() at the end of a
- * code block. When constructed, it starts the timer. When
- * destructed, it stops the timer.
- */
-class CodeTimer {
- TimerStat& d_timer;
- bool d_reentrant;
-
- /** Private copy constructor undefined (no copy permitted). */
- CodeTimer(const CodeTimer& timer) CVC4_UNDEFINED;
- /** Private assignment operator undefined (no copy permitted). */
- CodeTimer& operator=(const CodeTimer& timer) CVC4_UNDEFINED;
-
-public:
- CodeTimer(TimerStat& timer, bool allow_reentrant = false) : d_timer(timer), d_reentrant(false) {
- if(!allow_reentrant || !(d_reentrant = d_timer.running())) {
- d_timer.start();
- }
- }
- ~CodeTimer() {
- if(!d_reentrant) {
- d_timer.stop();
- }
- }
-};/* class CodeTimer */
-
-/**
- * To use a statistic, you need to declare it, initialize it in your
- * constructor, register it in your constructor, and deregister it in
- * your destructor. Instead, this macro does it all for you (and
- * therefore also keeps the statistic type, field name, and output
- * string all in the same place in your class's header. Its use is
- * like in this example, which takes the place of the declaration of a
- * statistics field "d_checkTimer":
- *
- * KEEP_STATISTIC(TimerStat, d_checkTimer, "theory::uf::checkTime");
- *
- * If any args need to be passed to the constructor, you can specify
- * them after the string.
- *
- * The macro works by creating a nested class type, derived from the
- * statistic type you give it, which declares a registry-aware
- * constructor/destructor pair.
- */
-#define KEEP_STATISTIC(_StatType, _StatField, _StatName, _CtorArgs...) \
- struct Statistic_##_StatField : public _StatType { \
- Statistic_##_StatField() : _StatType(_StatName, ## _CtorArgs) { \
- StatisticsRegistry::registerStat(this); \
- } \
- ~Statistic_##_StatField() { \
- StatisticsRegistry::unregisterStat(this); \
- } \
- } _StatField
-
-/**
- * Resource-acquisition-is-initialization idiom for statistics
- * registry. Useful for stack-based statistics (like in the driver).
- * Generally, for statistics kept in a member field of class, it's
- * better to use the above KEEP_STATISTIC(), which does declaration of
- * the member, construction of the statistic, and
- * registration/unregistration. This RAII class only does
- * registration and unregistration.
- */
-class RegisterStatistic {
-
- StatisticsRegistry* d_reg;
- Stat* d_stat;
-
-public:
-
-#if (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST)) && ! defined(__BUILDING_STATISTICS_FOR_EXPORT)
- RegisterStatistic(Stat* stat) :
- d_reg(StatisticsRegistry::current()),
- d_stat(stat) {
- if(d_reg != NULL) {
- throw CVC4::Exception("There is no current statistics registry!");
- }
- StatisticsRegistry::registerStat(d_stat);
- }
-#endif /* (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST) && ! __BUILDING_STATISTICS_FOR_EXPORT */
-
- RegisterStatistic(StatisticsRegistry* reg, Stat* stat) :
- d_reg(reg),
- d_stat(stat) {
- CheckArgument(reg != NULL, reg,
- "You need to specify a statistics registry"
- "on which to set the statistic");
- d_reg->registerStat_(d_stat);
- }
-
- RegisterStatistic(ExprManager& em, Stat* stat);
-
- RegisterStatistic(SmtEngine& smt, Stat* stat);
-
- ~RegisterStatistic() {
- d_reg->unregisterStat_(d_stat);
- }
-
-};/* class RegisterStatistic */
-
-#undef __CVC4_USE_STATISTICS
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__STATISTICS_REGISTRY_H */
#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 {
/**
+++ /dev/null
-/********************* */
-/*! \file tls.h.in
- ** \verbatim
- ** Original author: ACSYS
- ** 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 Header to define CVC4_THREAD whether or not TLS is
- ** supported by the compiler/runtime platform
- **
- ** Header to define CVC4_THREAD whether or not TLS is supported by
- ** the compiler/runtime platform. If not, an implementation based on
- ** pthread_getspecific() / pthread_setspecific() is given.
- **/
-
-#include "cvc4_public.h"
-
-#ifndef __CVC4__TLS_H
-#define __CVC4__TLS_H
-
-// A bit obnoxious: we have to take varargs to support multi-argument
-// template types in the threadlocals.
-// E.g. "CVC4_THREADLOCAL(hash_set<type, hasher>*)" fails otherwise,
-// due to the embedded comma.
-#if @CVC4_TLS_SUPPORTED@
-# define CVC4_THREADLOCAL(__type...) @CVC4_TLS@ __type
-# define CVC4_THREADLOCAL_PUBLIC(__type...) @CVC4_TLS@ CVC4_PUBLIC __type
-# define CVC4_THREADLOCAL_TYPE(__type...) __type
-#else
-# include <pthread.h>
-# define CVC4_THREADLOCAL(__type...) ::CVC4::ThreadLocal< __type >
-# define CVC4_THREADLOCAL_PUBLIC(__type...) CVC4_PUBLIC ::CVC4::ThreadLocal< __type >
-# define CVC4_THREADLOCAL_TYPE(__type...) ::CVC4::ThreadLocal< __type >
-
-namespace CVC4 {
-
-template <class T, bool small>
-class ThreadLocalImpl;
-
-template <class T>
-class ThreadLocalImpl<T, true> {
- pthread_key_t d_key;
-
- static void cleanup(void*) {
- }
-
-public:
- ThreadLocalImpl() {
- pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
- }
-
- ThreadLocalImpl(const T& t) {
- pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
- pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(t)));
- }
-
- ThreadLocalImpl(const ThreadLocalImpl& tl) {
- pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
- pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(static_cast<const T&>(tl))));
- }
-
- ThreadLocalImpl& operator=(const T& t) {
- pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(t)));
- return *this;
- }
- ThreadLocalImpl& operator=(const ThreadLocalImpl& tl) {
- pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(static_cast<const T&>(tl))));
- return *this;
- }
-
- operator T() const {
- return static_cast<T>(reinterpret_cast<size_t>(pthread_getspecific(d_key)));
- }
-};/* class ThreadLocalImpl<T, true> */
-
-template <class T>
-class ThreadLocalImpl<T*, true> {
- pthread_key_t d_key;
-
- static void cleanup(void*) {
- }
-
-public:
- ThreadLocalImpl() {
- pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
- }
-
- ThreadLocalImpl(const T* t) {
- pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
- pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(t)));
- }
-
- ThreadLocalImpl(const ThreadLocalImpl& tl) {
- pthread_key_create(&d_key, ThreadLocalImpl::cleanup);
- pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(static_cast<const T*>(tl))));
- }
-
- ThreadLocalImpl& operator=(const T* t) {
- pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(t)));
- return *this;
- }
- ThreadLocalImpl& operator=(const ThreadLocalImpl& tl) {
- pthread_setspecific(d_key, const_cast<void*>(reinterpret_cast<const void*>(static_cast<const T*>(tl))));
- return *this;
- }
-
- operator T*() const {
- return static_cast<T*>(pthread_getspecific(d_key));
- }
-
- T operator*() {
- return *static_cast<T*>(pthread_getspecific(d_key));
- }
- T* operator->() {
- return static_cast<T*>(pthread_getspecific(d_key));
- }
-};/* class ThreadLocalImpl<T*, true> */
-
-template <class T>
-class ThreadLocalImpl<T, false> {
-};/* class ThreadLocalImpl<T, false> */
-
-template <class T>
-class ThreadLocal : public ThreadLocalImpl<T, sizeof(T) <= sizeof(void*)> {
- typedef ThreadLocalImpl<T, sizeof(T) <= sizeof(void*)> super;
-
-public:
- ThreadLocal() : super() {}
- ThreadLocal(const T& t) : super(t) {}
- ThreadLocal(const ThreadLocal<T>& tl) : super(tl) {}
-
- ThreadLocal<T>& operator=(const T& t) {
- return static_cast< ThreadLocal<T>& >(super::operator=(t));
- }
- ThreadLocal<T>& operator=(const ThreadLocal<T>& tl) {
- return static_cast< ThreadLocal<T>& >(super::operator=(tl));
- }
-};/* class ThreadLocal<T> */
-
-template <class T>
-class ThreadLocal<T*> : public ThreadLocalImpl<T*, sizeof(T*) <= sizeof(void*)> {
- typedef ThreadLocalImpl<T*, sizeof(T*) <= sizeof(void*)> super;
-
-public:
- ThreadLocal() : super() {}
- ThreadLocal(T* t) : super(t) {}
- ThreadLocal(const ThreadLocal<T*>& tl) : super(tl) {}
-
- ThreadLocal<T*>& operator=(T* t) {
- return static_cast< ThreadLocal<T*>& >(super::operator=(t));
- }
- ThreadLocal<T*>& operator=(const ThreadLocal<T*>& tl) {
- return static_cast< ThreadLocal<T*>& >(super::operator=(tl));
- }
- // special operators for pointers
- T& operator*() {
- return *static_cast<T*>(*this);
- }
- const T& operator*() const {
- return *static_cast<const T*>(*this);
- }
- T* operator->() {
- return static_cast<T*>(*this);
- }
- const T* operator->() const {
- return static_cast<const T*>(*this);
- }
- T* operator++() {
- T* p = *this;
- *this = ++p;
- return p;
- }
- T* operator++(int) {
- T* p = *this;
- *this = p + 1;
- return p;
- }
- T* operator--() {
- T* p = *this;
- *this = --p;
- return p;
- }
- T* operator--(int) {
- T* p = *this;
- *this = p - 1;
- return p;
- }
-};/* class ThreadLocal<T*> */
-
-}/* CVC4 namespace */
-
-#endif /* @CVC4_TLS_SUPPORTED@ */
-
-#endif /* __CVC4__TLS_H */
+++ /dev/null
-/********************* */
-/*! \file uninterpreted_constant.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 Representation of constants of uninterpreted sorts
- **
- ** Representation of constants of uninterpreted sorts.
- **/
-
-#include "util/uninterpreted_constant.h"
-#include <iostream>
-#include <sstream>
-#include <string>
-
-using namespace std;
-
-namespace CVC4 {
-
-std::ostream& operator<<(std::ostream& out, const UninterpretedConstant& uc) {
- stringstream ss;
- ss << uc.getType();
- string t = ss.str();
- size_t i = 0;
- // replace everything that isn't in [a-zA-Z0-9_] with an _
- while((i = t.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_", i)) != string::npos) {
- t.replace(i, 1, 1, '_');
- }
- return out << "uc_" << t << '_' << uc.getIndex();
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file uninterpreted_constant.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 Representation of constants of uninterpreted sorts
- **
- ** Representation of constants of uninterpreted sorts.
- **/
-
-#include "cvc4_public.h"
-
-#pragma once
-
-#include "expr/type.h"
-#include <iostream>
-
-namespace CVC4 {
-
-class CVC4_PUBLIC UninterpretedConstant {
- const Type d_type;
- const Integer d_index;
-
-public:
-
- UninterpretedConstant(Type type, Integer index) throw(IllegalArgumentException) :
- d_type(type),
- d_index(index) {
- //CheckArgument(type.isSort(), type, "uninterpreted constants can only be created for uninterpreted sorts, not `%s'", type.toString().c_str());
- CheckArgument(index >= 0, index, "index >= 0 required for uninterpreted constant index, not `%s'", index.toString().c_str());
- }
-
- ~UninterpretedConstant() throw() {
- }
-
- Type getType() const throw() {
- return d_type;
- }
- const Integer& getIndex() const throw() {
- return d_index;
- }
-
- bool operator==(const UninterpretedConstant& uc) const throw() {
- return d_type == uc.d_type && d_index == uc.d_index;
- }
- bool operator!=(const UninterpretedConstant& uc) const throw() {
- return !(*this == uc);
- }
-
- bool operator<(const UninterpretedConstant& uc) const throw() {
- return d_type < uc.d_type ||
- (d_type == uc.d_type && d_index < uc.d_index);
- }
- bool operator<=(const UninterpretedConstant& uc) const throw() {
- return d_type < uc.d_type ||
- (d_type == uc.d_type && d_index <= uc.d_index);
- }
- bool operator>(const UninterpretedConstant& uc) const throw() {
- return !(*this <= uc);
- }
- bool operator>=(const UninterpretedConstant& uc) const throw() {
- return !(*this < uc);
- }
-
-};/* class UninterpretedConstant */
-
-std::ostream& operator<<(std::ostream& out, const UninterpretedConstant& uc) CVC4_PUBLIC;
-
-/**
- * Hash function for the BitVector constants.
- */
-struct CVC4_PUBLIC UninterpretedConstantHashFunction {
- inline size_t operator()(const UninterpretedConstant& uc) const {
- return TypeHashFunction()(uc.getType()) * IntegerHashFunction()(uc.getIndex());
- }
-};/* struct UninterpretedConstantHashFunction */
-
-}/* CVC4 namespace */
+++ /dev/null
-%{
-#include "util/uninterpreted_constant.h"
-%}
-
-%rename(less) CVC4::UninterpretedConstant::operator<(const UninterpretedConstant&) const;
-%rename(lessEqual) CVC4::UninterpretedConstant::operator<=(const UninterpretedConstant&) const;
-%rename(greater) CVC4::UninterpretedConstant::operator>(const UninterpretedConstant&) const;
-%rename(greaterEqual) CVC4::UninterpretedConstant::operator>=(const UninterpretedConstant&) const;
-
-%rename(equals) CVC4::UninterpretedConstant::operator==(const UninterpretedConstant&) const;
-%ignore CVC4::UninterpretedConstant::operator!=(const UninterpretedConstant&) const;
-
-%rename(apply) CVC4::UninterpretedConstantHashFunction::operator()(const UninterpretedConstant&) const;
-
-%ignore CVC4::operator<<(std::ostream&, const UninterpretedConstant&);
-
-%include "util/uninterpreted_constant.h"
/********************* */
-/*! \file modal_exception.h
+/*! \file unsafe_interrupt_exception.h
** \verbatim
** Original author: Liana Hadarean
** Major contributors: none
#ifndef __CVC4__UNSAFE_INTERRUPT_EXCEPTION_H
#define __CVC4__UNSAFE_INTERRUPT_EXCEPTION_H
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
+++ /dev/null
-/********************* */
-/*! \file unsat_core.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 Representation of unsat cores
- **
- ** Representation of unsat cores.
- **/
-
-#include "util/unsat_core.h"
-#include "expr/command.h"
-#include "smt/smt_engine_scope.h"
-#include "printer/printer.h"
-
-namespace CVC4 {
-
-void UnsatCore::initMessage() const {
- Debug("core") << "UnsatCore size " << d_core.size() << std::endl;
-}
-
-UnsatCore::const_iterator UnsatCore::begin() const {
- return d_core.begin();
-}
-
-UnsatCore::const_iterator UnsatCore::end() const {
- return d_core.end();
-}
-
-void UnsatCore::toStream(std::ostream& out) const {
- smt::SmtScope smts(d_smt);
- Expr::dag::Scope scope(out, false);
- Printer::getPrinter(options::outputLanguage())->toStream(out, *this);
-}
-
-void UnsatCore::toStream(std::ostream& out, const std::map<Expr, std::string>& names) const {
- smt::SmtScope smts(d_smt);
- Expr::dag::Scope scope(out, false);
- Printer::getPrinter(options::outputLanguage())->toStream(out, *this, names);
-}
-
-std::ostream& operator<<(std::ostream& out, const UnsatCore& core) {
- core.toStream(out);
- return out;
-}
-
-}/* CVC4 namespace */
+++ /dev/null
-/********************* */
-/*! \file unsat_core.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_public.h"
-
-#ifndef __CVC4__UNSAT_CORE_H
-#define __CVC4__UNSAT_CORE_H
-
-#include <iostream>
-#include <vector>
-#include "expr/expr.h"
-
-namespace CVC4 {
-
-class SmtEngine;
-class UnsatCore;
-
-std::ostream& operator<<(std::ostream& out, const UnsatCore& core) CVC4_PUBLIC;
-
-class CVC4_PUBLIC UnsatCore {
- friend std::ostream& operator<<(std::ostream&, const UnsatCore&);
-
- /** The SmtEngine we're associated with */
- SmtEngine* d_smt;
-
- std::vector<Expr> d_core;
-
- void initMessage() const;
-
-public:
- UnsatCore() : d_smt(NULL) {}
-
- template <class T>
- UnsatCore(SmtEngine* smt, T begin, T end) : d_smt(smt), d_core(begin, end) {
- initMessage();
- }
-
- ~UnsatCore() {}
-
- /** get the smt engine that this unsat core is hooked up to */
- SmtEngine* getSmtEngine() { return d_smt; }
-
- size_t size() const { return d_core.size(); }
-
- typedef std::vector<Expr>::const_iterator iterator;
- typedef std::vector<Expr>::const_iterator const_iterator;
-
- const_iterator begin() const;
- const_iterator end() const;
-
- void toStream(std::ostream& out) const;
- void toStream(std::ostream& out, const std::map<Expr, std::string>& names) const;
-
-};/* class UnsatCore */
-
-}/* CVC4 namespace */
-
-#endif /* __CVC4__UNSAT_CORE_H */
+++ /dev/null
-%{
-#include "util/unsat_core.h"
-
-#ifdef SWIGJAVA
-
-#include "bindings/java_iterator_adapter.h"
-#include "bindings/java_stream_adapters.h"
-
-#endif /* SWIGJAVA */
-%}
-
-%ignore CVC4::operator<<(std::ostream&, const UnsatCore&);
-
-#ifdef SWIGJAVA
-
-// Instead of UnsatCore::begin() and end(), create an
-// iterator() method on the Java side that returns a Java-style
-// Iterator.
-%ignore CVC4::UnsatCore::begin();
-%ignore CVC4::UnsatCore::end();
-%ignore CVC4::UnsatCore::begin() const;
-%ignore CVC4::UnsatCore::end() const;
-%extend CVC4::UnsatCore {
- CVC4::JavaIteratorAdapter<CVC4::UnsatCore> iterator() {
- return CVC4::JavaIteratorAdapter<CVC4::UnsatCore>(*$self);
- }
-}
-
-// UnsatCore is "iterable" on the Java side
-%typemap(javainterfaces) CVC4::UnsatCore "java.lang.Iterable<edu.nyu.acsys.CVC4.Expr>";
-
-// the JavaIteratorAdapter should not be public, and implements Iterator
-%typemap(javaclassmodifiers) CVC4::JavaIteratorAdapter<CVC4::UnsatCore> "class";
-%typemap(javainterfaces) CVC4::JavaIteratorAdapter<CVC4::UnsatCore> "java.util.Iterator<edu.nyu.acsys.CVC4.Expr>";
-// add some functions to the Java side (do it here because there's no way to do these in C++)
-%typemap(javacode) CVC4::JavaIteratorAdapter<CVC4::UnsatCore> "
- public void remove() {
- throw new java.lang.UnsupportedOperationException();
- }
-
- public edu.nyu.acsys.CVC4.Expr next() {
- if(hasNext()) {
- return getNext();
- } else {
- throw new java.util.NoSuchElementException();
- }
- }
-"
-// getNext() just allows C++ iterator access from Java-side next(), make it private
-%javamethodmodifiers CVC4::JavaIteratorAdapter<CVC4::UnsatCore>::getNext() "private";
-
-// map the types appropriately
-%typemap(jni) CVC4::UnsatCore::const_iterator::value_type "jobject";
-%typemap(jtype) CVC4::UnsatCore::const_iterator::value_type "edu.nyu.acsys.CVC4.Expr";
-%typemap(jstype) CVC4::UnsatCore::const_iterator::value_type "edu.nyu.acsys.CVC4.Expr";
-%typemap(javaout) CVC4::UnsatCore::const_iterator::value_type { return $jnicall; }
-
-#endif /* SWIGJAVA */
-
-%include "util/unsat_core.h"
-
-#ifdef SWIGJAVA
-
-%include "bindings/java_iterator_adapter.h"
-%include "bindings/java_stream_adapters.h"
-
-%template(JavaIteratorAdapter_UnsatCore) CVC4::JavaIteratorAdapter<CVC4::UnsatCore>;
-
-#endif /* SWIGJAVA */
#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;
** 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;
#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;
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;
return r == Result::VALID ? 0 : 1;
}
-
-
#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;
#include <cxxtest/TestSuite.h>
+#include "base/cvc4_assert.h"
#include "context/cdhashmap.h"
-#include "util/cvc4_assert.h"
using namespace std;
using namespace CVC4;
#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;
#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;
#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;
#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;
#include "expr/expr_manager.h"
#include "expr/expr.h"
-#include "util/exception.h"
+#include "base/exception.h"
using namespace CVC4;
using namespace CVC4::kind;
#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;
private:
Options opts;
+ smt::SmtOptionsHandler* d_handler;
ExprManager* d_em;
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]);
delete c_bool_and;
delete b_bool;
delete a_bool;
+ delete d_handler;
delete d_em;
} catch(Exception e) {
#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;
private:
Options opts;
+ smt::SmtOptionsHandler* d_handler;
NodeManager* d_nodeManager;
NodeManagerScope* d_scope;
TypeNode* d_booleanType;
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]);
delete d_booleanType;
delete d_scope;
delete d_nodeManager;
+ delete d_handler;
}
bool imp(bool a, bool b) const {
#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;
#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;
#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;
#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;
#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;
#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;
#include <sys/time.h>
#include <sys/resource.h>
-#include "util/cvc4_assert.h"
+#include "base/cvc4_assert.h"
namespace CVC4 {
namespace test {
#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;
**/
#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;
/* #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;
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() );
}
};/* class LogicInfoWhite */
-
** \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;
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);
#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;
#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;
#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"
#include <string>
#include <cstring>
-#include "util/cvc4_assert.h"
+#include "base/cvc4_assert.h"
using namespace CVC4;
using namespace std;
** 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;
}
};/* class BooleanSimplificationBlack */
-
** 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;
#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"
#include <iostream>
#include <sstream>
-#include "util/exception.h"
+#include "base/exception.h"
using namespace CVC4;
using namespace std;
**/
#include <cxxtest/TestSuite.h>
-#include <sstream>
+
#include <limits>
+#include <sstream>
#include "util/integer.h"
#include <iostream>
#include <sstream>
-#include "util/output.h"
+#include "base/output.h"
using namespace CVC4;
using namespace std;
#include <string>
#include <ctime>
-#include "util/statistics_registry.h"
+#include "expr/statistics_registry.h"
using namespace CVC4;
using namespace std;
** 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;
}
};/* class SubrangeBoundWhite */
-