summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorTim King <taking@google.com>2015-12-14 18:51:40 -0800
committerTim King <taking@google.com>2015-12-14 18:51:40 -0800
commit90e3b73fbd1b2eb262a7a7e2e72d701c8f9e3600 (patch)
tree77af58f4233d766d31e8e032e16cc0b4833d8de2 /src/util
parent157a2ed349418611302476dce79fced1d95a4ecc (diff)
Refactoring Options Handler & Library Cycle Breaking
What to Know As a User: A number of files have moved. Users that include files in the public API in more refined ways than using #include <cvc4.h> should consult which files have moved. Note though that some files may move again after being cleaned up. A number of small tweaks have been made to the swig interfaces that may cause issues. Please file bug reports for any problems. The Problem: The build order of CVC4 used to be [roughly] specified as: options < expr < util < libcvc4 < parsers < main Each of these had their own directories and their own Makefile.am files. With the exception of the util/ directory, each of the subdirectories built exactly one convenience library. The util/ directory additionally built a statistics library. While the order above was partially correct, the build order was more complicated as options/Makefile.am executed building the sources for expr/Makefile.am as part of its BUILT_SOURCES phase. This options/Makefile.am also build the options/h and options.cpp files in other directories. There were cyclical library dependencies between the first four above libraries. All of these aspects combined to make options extremely brittle and hard to develop. Maintaining these between clang versus gcc, and bazel versus autotools has become increasing unpredictable. The Solution: To address these cyclic build problems, I am simplifying the build process. Here are the main things that have to happen: 1. util/ will be split into 3 separate directories: base, util, and smt_util. Each will have their own library and Makefile.am file. 2. Dependencies for options/ will be moved into options/. If a type appears as an option, this file will be moved into options. 3. All of the old options_handlers.h files have been refactored. 4. Some files have moved from util into expr/ to resolve cycles. Some of these moves are temporary. 5. I am removing the libstatistics library. The constraints that the CVC4 build system will eventually satisfy are: - The include order for both the .h and .cpp files for a directory must respect the order libraries are built. For example, a file in options/ cannot include from the expr/ directory. This includes built source files such as those coming from */kinds files and */options files. - The types definitions must also respect the build order. Forward type declarations will be allowed in exceptional, justified cases. - The Makefile.am for a directory cannot generate a file outside of the directory it controls. (Or call another Makefile.am except through subdirectory calls.) - One library per Makefile.am. - No extra copies of libraries will be built for the purpose of distinguishing between external and internal visibility in libraries for building parser/ or main/ libraries and binaries. Any function used by parser/ and main/ will be labeled with CVC4_PUBLIC and be in a public API. (AFAICT, libstatistics was being built exactly to skirt this.) The build order of CVC4 can now be [roughly] specified as base < options < util < expr < smt_util < libcvc4 < parsers < main The distinction between "base < options < util < expr" are currently clean. The relationship between expr and the subsequent directories/libraries are not yet clean. More details about the directories: base/ The new directory base/ contains the shared utilities that are absolutely crucial to starting cvc4. The list currently includes just: cvc4_assert.{h,cpp}, output.{h,cpp}, exception.{h,cpp}, and tls.{h, h.in, cpp}. These are things that are required everywhere. options/ The options/ directory is self contained. - It contains all of the enums that appear as options. This includes things like theory/bv/bitblast_mode.h . - There are exactly 4 classes that handled currently using forward declarations currently to this: LogicInfo, LemmaInputChannel, LemmaOutputChannel, and CommandSequence. These will all be removed from options. - Functionality of the options_handlers.h files has been moved into smt/smt_options_handler.h. The options library itself only uses an interface class defined in options/options_handler_interface.h. We are now using virtual dispatch to avoid using inlined functions as was previously done. - The */options_handlers.h files have been removed. - The generated smt/smt_options.cpp file has been be replaced by pushing the functionality that was generated into: options/options_handler_{get,set}_option_template.cpp . The non-generated functionality was moved into smt_engine.cpp. - All of the options files have been moved from their directories into options/. This means includes like theory/arith/options.h have changed to change to options/arith_options.h . util/ The util/ directory continues to contain core utility classes that may be used [almost] everywhere. The exception is that these are not used by options/ or base/. This includes things like rational and integer. These may not use anything in expr/ or libcvc4. A number of files have been moved out of this directory as they have cyclic dependencies graph with exprs and types. The build process up to this directory is currently clean. expr/ The expr/ directory continues to be the home of expressions. The major change is files moving from util/ moving into expr/. The reason for this is that these files form a cycle with files in expr/. - An example is datatype.h. This includes "expr/expr.h", "expr/type.h" while "expr/command.h" includes datatype.h. - Another example is predicate.h. This uses expr.h and is also declared in a kinds file and thus appears in kinds.h. - The rule of thumb is if expr/ pulls it in it needs to be independent of expr/, in which case it is in util/, or it is not, in which case it is pulled into expr/. - Some files do not have a strong justification currently. Result, ResourceManager and SExpr can be moved back into util/ once the iostream manipulation routines are refactored out of the Node and Expr classes. - Note the kinds files are expected to remain in the theory/ directories. These are only read in order to build sources. - This directory is not yet clean. It contains forward references into libcvc4 such as the printer. It also makes some classes used by main/ and parser CVC4_PUBLIC. smt_util/ The smt_util/ directory contains those utility classes which require exprs, but expr/ does not require them. These are mostly utilities for working with expressions and nodes. Examples include ite_removal.h, LemmaInputChannel and LemmaOutputChannel. What is up next: - A number of new #warning "TODO: ..." items have been scattered throughout the code as reminders to myself. Help with these issues is welcomed. - The expr/ directory needs to be cleaned up in a similar to options/. Before this happens statistics needs to be cleaned up.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Makefile.am177
-rw-r--r--src/util/abstract_value.cpp5
-rw-r--r--src/util/abstract_value.h11
-rw-r--r--src/util/array.h26
-rw-r--r--src/util/array.i5
-rw-r--r--src/util/array_store_all.cpp30
-rw-r--r--src/util/array_store_all.h98
-rw-r--r--src/util/array_store_all.i17
-rw-r--r--src/util/ascription_type.h63
-rw-r--r--src/util/ascription_type.i12
-rw-r--r--src/util/backtrackable.h222
-rw-r--r--src/util/bin_heap.h2
-rw-r--r--src/util/bitvector.h3
-rw-r--r--src/util/boolean_simplification.cpp66
-rw-r--r--src/util/boolean_simplification.h234
-rw-r--r--src/util/cardinality.h2
-rw-r--r--src/util/chain.h51
-rw-r--r--src/util/chain.i12
-rw-r--r--src/util/channel.h10
-rw-r--r--src/util/configuration.cpp9
-rw-r--r--src/util/configuration.h6
-rw-r--r--src/util/cvc4_assert.cpp165
-rw-r--r--src/util/cvc4_assert.h309
-rw-r--r--src/util/datatype.cpp1023
-rw-r--r--src/util/datatype.h865
-rw-r--r--src/util/datatype.i175
-rw-r--r--src/util/dense_map.h6
-rw-r--r--src/util/didyoumean.cpp154
-rw-r--r--src/util/didyoumean.h53
-rw-r--r--src/util/didyoumean_test.cpp766
-rw-r--r--src/util/divisible.cpp3
-rw-r--r--src/util/divisible.h3
-rw-r--r--src/util/dump.h116
-rw-r--r--src/util/dynamic_array.h2
-rw-r--r--src/util/emptyset.cpp29
-rw-r--r--src/util/emptyset.h83
-rw-r--r--src/util/emptyset.i17
-rw-r--r--src/util/exception.cpp115
-rw-r--r--src/util/exception.h170
-rw-r--r--src/util/exception.i11
-rw-r--r--src/util/floatingpoint.cpp4
-rw-r--r--src/util/floatingpoint.h38
-rw-r--r--src/util/integer_cln_imp.cpp8
-rw-r--r--src/util/integer_cln_imp.h2
-rw-r--r--src/util/integer_gmp_imp.cpp9
-rw-r--r--src/util/integer_gmp_imp.h2
-rw-r--r--src/util/ite_removal.cpp192
-rw-r--r--src/util/ite_removal.h92
-rw-r--r--src/util/language.cpp135
-rw-r--r--src/util/language.h202
-rw-r--r--src/util/language.i44
-rw-r--r--src/util/lemma_input_channel.h38
-rw-r--r--src/util/lemma_output_channel.h46
-rw-r--r--src/util/matcher.h118
-rw-r--r--src/util/maybe.h3
-rw-r--r--src/util/model.cpp52
-rw-r--r--src/util/model.h78
-rw-r--r--src/util/nary_builder.cpp200
-rw-r--r--src/util/nary_builder.h55
-rw-r--r--src/util/node_visitor.h119
-rw-r--r--src/util/output.cpp194
-rw-r--r--src/util/output.h590
-rw-r--r--src/util/predicate.cpp55
-rw-r--r--src/util/predicate.h62
-rw-r--r--src/util/predicate.i12
-rw-r--r--src/util/rational_cln_imp.cpp7
-rw-r--r--src/util/rational_cln_imp.h3
-rw-r--r--src/util/rational_gmp_imp.cpp9
-rw-r--r--src/util/rational_gmp_imp.h3
-rw-r--r--src/util/record.cpp38
-rw-r--r--src/util/record.h153
-rw-r--r--src/util/record.i110
-rw-r--r--src/util/regexp.cpp3
-rw-r--r--src/util/regexp.h4
-rw-r--r--src/util/resource_manager.cpp285
-rw-r--r--src/util/resource_manager.h158
-rw-r--r--src/util/resource_manager.i5
-rw-r--r--src/util/result.cpp211
-rw-r--r--src/util/result.h179
-rw-r--r--src/util/result.i20
-rw-r--r--src/util/sexpr.cpp32
-rw-r--r--src/util/sexpr.h304
-rw-r--r--src/util/sexpr.i21
-rw-r--r--src/util/smt2_quote_string.cpp41
-rw-r--r--src/util/smt2_quote_string.h (renamed from src/util/dump.cpp)20
-rw-r--r--src/util/sort_inference.cpp755
-rw-r--r--src/util/sort_inference.h116
-rw-r--r--src/util/statistics.cpp132
-rw-r--r--src/util/statistics.h129
-rw-r--r--src/util/statistics.i79
-rw-r--r--src/util/statistics_registry.cpp162
-rw-r--r--src/util/statistics_registry.h925
-rw-r--r--src/util/subrange_bound.h6
-rw-r--r--src/util/tls.h.in198
-rw-r--r--src/util/uninterpreted_constant.cpp38
-rw-r--r--src/util/uninterpreted_constant.h84
-rw-r--r--src/util/uninterpreted_constant.i17
-rw-r--r--src/util/unsafe_interrupt_exception.h4
-rw-r--r--src/util/unsat_core.cpp53
-rw-r--r--src/util/unsat_core.h72
-rw-r--r--src/util/unsat_core.i69
101 files changed, 180 insertions, 11741 deletions
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 59591dc3b..914d6e7d2 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -3,11 +3,10 @@ AM_CPPFLAGS = \
-I@builddir@/.. -I@srcdir@/../include -I@srcdir@/..
AM_CXXFLAGS = -Wall -Wno-unknown-pragmas $(FLAG_VISIBILITY_HIDDEN)
-noinst_LTLIBRARIES = libutil.la libstatistics.la
+noinst_LTLIBRARIES = libutil.la
-libstatistics_la_CPPFLAGS = $(CPPFLAGS) $(AM_CPPFLAGS) -D__BUILDING_STATISTICS_FOR_EXPORT
-# Do not list built sources (like integer.h, rational.h, and tls.h) here!
+# Do not list built sources (like integer.h, rational.h) here!
# Rather, list them under BUILT_SOURCES, and their .in versions under
# EXTRA_DIST. Otherwise, they're packaged up in the tarball, which is
# no good---they belong in the configured builds/ directory. If they
@@ -15,102 +14,45 @@ libstatistics_la_CPPFLAGS = $(CPPFLAGS) $(AM_CPPFLAGS) -D__BUILDING_STATISTICS_F
# configured at the time of the "make dist", which (1) may not be the
# configuration that the user wants, and (2) might cause link errors.
libutil_la_SOURCES = \
- cvc4_assert.h \
- cvc4_assert.cpp \
- backtrackable.h \
Makefile.am \
Makefile.in \
- debug.h \
- exception.h \
- exception.cpp \
- hash.h \
+ abstract_value.cpp \
+ abstract_value.h \
+ bin_heap.h \
+ bitvector.h \
bool.h \
- proof.h \
- output.cpp \
- output.h \
- result.h \
- result.cpp \
+ cache.h \
+ cardinality.cpp \
+ cardinality.h \
+ channel.h \
+ configuration.cpp \
configuration.h \
configuration_private.h \
- configuration.cpp \
- bitvector.h \
- ascription_type.h \
- array.h \
- datatype.h \
- datatype.cpp \
- tuple.h \
- record.h \
- record.cpp \
- divisible.h \
+ debug.h \
+ dense_map.h \
divisible.cpp \
- maybe.h \
- matcher.h \
- gmp_util.h \
- sexpr.h \
- sexpr.cpp \
- statistics.h \
- statistics.cpp \
- statistics_registry.h \
- statistics_registry.cpp \
+ divisible.h \
dynamic_array.h \
- language.h \
- lemma_input_channel.h \
- lemma_output_channel.h \
- dense_map.h \
- channel.h \
- language.cpp \
- ntuple.h \
- subrange_bound.h \
- dump.h \
- dump.cpp \
- predicate.h \
- predicate.cpp \
- cardinality.h \
- cardinality.cpp \
- cache.h \
- utility.h \
- boolean_simplification.h \
- boolean_simplification.cpp \
- ite_removal.h \
- ite_removal.cpp \
- nary_builder.h \
- nary_builder.cpp \
- node_visitor.h \
- chain.h \
+ floatingpoint.cpp \
+ floatingpoint.h \
+ gmp_util.h \
+ hash.h \
index.h \
- uninterpreted_constant.h \
- uninterpreted_constant.cpp \
- abstract_value.h \
- abstract_value.cpp \
- array_store_all.h \
- array_store_all.cpp \
- emptyset.h \
- emptyset.cpp \
- model.h \
- model.cpp \
- sort_inference.h \
- sort_inference.cpp \
- regexp.h \
+ maybe.h \
+ ntuple.h \
+ proof.h \
regexp.cpp \
- bin_heap.h \
- didyoumean.h \
- didyoumean.cpp \
- unsat_core.h \
- unsat_core.cpp \
- floatingpoint.h \
- floatingpoint.cpp \
- resource_manager.h \
- resource_manager.cpp \
- unsafe_interrupt_exception.h
-
-libstatistics_la_SOURCES = \
- statistics_registry.h \
- statistics_registry.cpp
+ regexp.h \
+ smt2_quote_string.cpp \
+ smt2_quote_string.h \
+ subrange_bound.h \
+ tuple.h \
+ unsafe_interrupt_exception.h \
+ utility.h
BUILT_SOURCES = \
rational.h \
- integer.h \
- tls.h
+ integer.h
if CVC4_CLN_IMP
libutil_la_SOURCES += \
@@ -123,53 +65,36 @@ libutil_la_SOURCES += \
integer_gmp_imp.cpp
endif
+
EXTRA_DIST = \
- rational_cln_imp.h \
- integer_cln_imp.h \
- integer_cln_imp.cpp \
- rational_cln_imp.cpp \
- rational_gmp_imp.h \
- integer_gmp_imp.h \
- integer_gmp_imp.cpp \
- rational_gmp_imp.cpp \
- rational.h.in \
- integer.h.in \
- tls.h.in \
- integer.i \
- statistics.i \
+ bitvector.i \
bool.i \
- sexpr.i \
- datatype.i \
- tuple.i \
- record.i \
- divisible.i \
cardinality.i \
- result.i \
configuration.i \
- bitvector.i \
- subrange_bound.i \
- exception.i \
- language.i \
- array.i \
- array_store_all.i \
- emptyset.i \
- ascription_type.i \
- rational.i \
+ divisible.i \
+ floatingpoint.i \
hash.i \
- predicate.i \
- uninterpreted_constant.i \
- chain.i \
- regexp.i \
- resource_manager.i \
- unsafe_interrupt_exception.i \
+ integer.h.in \
+ integer.i \
+ integer_cln_imp.cpp \
+ integer_cln_imp.h \
+ integer_gmp_imp.cpp \
+ integer_gmp_imp.h \
proof.i \
- unsat_core.i \
- floatingpoint.i
+ rational.h.in \
+ rational.i \
+ rational_cln_imp.cpp \
+ rational_cln_imp.h \
+ rational_gmp_imp.cpp \
+ rational_gmp_imp.h \
+ regexp.i \
+ subrange_bound.i \
+ tuple.i \
+ unsafe_interrupt_exception.i
+
DISTCLEANFILES = \
integer.h.tmp \
rational.h.tmp \
- tls.h.tmp \
integer.h \
- rational.h \
- tls.h
+ rational.h
diff --git a/src/util/abstract_value.cpp b/src/util/abstract_value.cpp
index d99353b74..e401661eb 100644
--- a/src/util/abstract_value.cpp
+++ b/src/util/abstract_value.cpp
@@ -27,4 +27,9 @@ std::ostream& operator<<(std::ostream& out, const AbstractValue& val) {
return out << "@" << val.getIndex();
}
+AbstractValue::AbstractValue(Integer index) throw(IllegalArgumentException) :
+ d_index(index) {
+ CheckArgument(index >= 1, index, "index >= 1 required for abstract value, not `%s'", index.toString().c_str());
+}
+
}/* CVC4 namespace */
diff --git a/src/util/abstract_value.h b/src/util/abstract_value.h
index 78a1e9975..d597edc8b 100644
--- a/src/util/abstract_value.h
+++ b/src/util/abstract_value.h
@@ -18,9 +18,10 @@
#pragma once
-#include "expr/type.h"
#include <iostream>
+#include "util/integer.h"
+
namespace CVC4 {
class CVC4_PUBLIC AbstractValue {
@@ -28,13 +29,9 @@ class CVC4_PUBLIC AbstractValue {
public:
- AbstractValue(Integer index) throw(IllegalArgumentException) :
- d_index(index) {
- CheckArgument(index >= 1, index, "index >= 1 required for abstract value, not `%s'", index.toString().c_str());
- }
+ AbstractValue(Integer index) throw(IllegalArgumentException);
- ~AbstractValue() throw() {
- }
+ ~AbstractValue() throw() {}
const Integer& getIndex() const throw() {
return d_index;
diff --git a/src/util/array.h b/src/util/array.h
deleted file mode 100644
index ab554171f..000000000
--- a/src/util/array.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/array.i b/src/util/array.i
deleted file mode 100644
index 593ce9490..000000000
--- a/src/util/array.i
+++ /dev/null
@@ -1,5 +0,0 @@
-%{
-#include "util/array.h"
-%}
-
-%include "util/array.h"
diff --git a/src/util/array_store_all.cpp b/src/util/array_store_all.cpp
deleted file mode 100644
index dfd021e75..000000000
--- a/src/util/array_store_all.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/array_store_all.h b/src/util/array_store_all.h
deleted file mode 100644
index b1d624266..000000000
--- a/src/util/array_store_all.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/array_store_all.i b/src/util/array_store_all.i
deleted file mode 100644
index aee550314..000000000
--- a/src/util/array_store_all.i
+++ /dev/null
@@ -1,17 +0,0 @@
-%{
-#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"
diff --git a/src/util/ascription_type.h b/src/util/ascription_type.h
deleted file mode 100644
index 42906e557..000000000
--- a/src/util/ascription_type.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/ascription_type.i b/src/util/ascription_type.i
deleted file mode 100644
index fe8856bcc..000000000
--- a/src/util/ascription_type.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%{
-#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"
diff --git a/src/util/backtrackable.h b/src/util/backtrackable.h
deleted file mode 100644
index 5492dd8b5..000000000
--- a/src/util/backtrackable.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/bin_heap.h b/src/util/bin_heap.h
index 53c2a9bb6..d057bcf84 100644
--- a/src/util/bin_heap.h
+++ b/src/util/bin_heap.h
@@ -26,7 +26,7 @@
#include <limits>
#include <functional>
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
diff --git a/src/util/bitvector.h b/src/util/bitvector.h
index 798dd63c7..762753795 100644
--- a/src/util/bitvector.h
+++ b/src/util/bitvector.h
@@ -21,7 +21,8 @@
#define __CVC4__BITVECTOR_H
#include <iostream>
-#include "util/exception.h"
+
+#include "base/exception.h"
#include "util/integer.h"
namespace CVC4 {
diff --git a/src/util/boolean_simplification.cpp b/src/util/boolean_simplification.cpp
deleted file mode 100644
index 62ef46339..000000000
--- a/src/util/boolean_simplification.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/********************* */
-/*! \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 */
-
diff --git a/src/util/boolean_simplification.h b/src/util/boolean_simplification.h
deleted file mode 100644
index d0ca3646f..000000000
--- a/src/util/boolean_simplification.h
+++ /dev/null
@@ -1,234 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/cardinality.h b/src/util/cardinality.h
index 113cb954c..1cb4454e0 100644
--- a/src/util/cardinality.h
+++ b/src/util/cardinality.h
@@ -23,8 +23,8 @@
#include <iostream>
#include <utility>
+#include "base/exception.h"
#include "util/integer.h"
-#include "util/exception.h"
namespace CVC4 {
diff --git a/src/util/chain.h b/src/util/chain.h
deleted file mode 100644
index e052a2ed8..000000000
--- a/src/util/chain.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/chain.i b/src/util/chain.i
deleted file mode 100644
index 1c97a527f..000000000
--- a/src/util/chain.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%{
-#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"
diff --git a/src/util/channel.h b/src/util/channel.h
index 710c3274b..39aed425b 100644
--- a/src/util/channel.h
+++ b/src/util/channel.h
@@ -49,15 +49,15 @@ public:
/* Removes an element from the channel */
virtual T pop() = 0;
-
+
/* */
- virtual bool empty() = 0;
-
+ virtual bool empty() = 0;
+
/* */
virtual bool full() = 0;
};/* class SharedChannel<T> */
-/*
+/*
This code is from
http://live.boost.org/doc/libs/1_46_1/libs/circular_buffer/doc/circular_buffer.html#boundedbuffer
@@ -76,7 +76,7 @@ public:
bool push(param_type item){
// param_type represents the "best" way to pass a parameter of type value_type to a method
-
+
boost::mutex::scoped_lock lock(m_mutex);
m_not_full.wait(lock, boost::bind(&SynchronizedSharedChannel<value_type>::is_not_full, this));
m_container.push_front(item);
diff --git a/src/util/configuration.cpp b/src/util/configuration.cpp
index 5bd607d94..bbde7193f 100644
--- a/src/util/configuration.cpp
+++ b/src/util/configuration.cpp
@@ -15,15 +15,16 @@
** Implementation of Configuration class, which provides compile-time
** configuration information about the CVC4 library.
**/
+#include "util/configuration.h"
-#include <string>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
+
#include <sstream>
+#include <string>
-#include "util/configuration.h"
-#include "util/configuration_private.h"
#include "cvc4autoconfig.h"
+#include "util/configuration_private.h"
#if defined(CVC4_DEBUG) && defined(CVC4_TRACING)
# include "options/Debug_tags.h"
diff --git a/src/util/configuration.h b/src/util/configuration.h
index c6562b3e6..818652db0 100644
--- a/src/util/configuration.h
+++ b/src/util/configuration.h
@@ -29,7 +29,7 @@ namespace CVC4 {
* Represents the (static) configuration of CVC4.
*/
class CVC4_PUBLIC Configuration {
-
+private:
/** Private default ctor: Disallow construction of this class */
Configuration();
@@ -61,8 +61,8 @@ public:
static bool isAssertionBuild();
- static bool isProofBuild();
-
+ static bool isProofBuild();
+
static bool isCoverageBuild();
static bool isProfilingBuild();
diff --git a/src/util/cvc4_assert.cpp b/src/util/cvc4_assert.cpp
deleted file mode 100644
index 3db285182..000000000
--- a/src/util/cvc4_assert.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/cvc4_assert.h b/src/util/cvc4_assert.h
deleted file mode 100644
index cc854278b..000000000
--- a/src/util/cvc4_assert.h
+++ /dev/null
@@ -1,309 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/datatype.cpp b/src/util/datatype.cpp
deleted file mode 100644
index a53759c08..000000000
--- a/src/util/datatype.cpp
+++ /dev/null
@@ -1,1023 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/datatype.h b/src/util/datatype.h
deleted file mode 100644
index 85668cd55..000000000
--- a/src/util/datatype.h
+++ /dev/null
@@ -1,865 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/datatype.i b/src/util/datatype.i
deleted file mode 100644
index 403fb31bc..000000000
--- a/src/util/datatype.i
+++ /dev/null
@@ -1,175 +0,0 @@
-%{
-#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 */
diff --git a/src/util/dense_map.h b/src/util/dense_map.h
index 39cee5b9e..86b9f2553 100644
--- a/src/util/dense_map.h
+++ b/src/util/dense_map.h
@@ -26,10 +26,12 @@
#pragma once
-#include <vector>
#include <boost/integer_traits.hpp>
+#include <vector>
+
+#include "base/cvc4_assert.h"
#include "util/index.h"
-#include "util/cvc4_assert.h"
+
namespace CVC4 {
diff --git a/src/util/didyoumean.cpp b/src/util/didyoumean.cpp
deleted file mode 100644
index dd8941033..000000000
--- a/src/util/didyoumean.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/********************* */
-/*! \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();
-}
diff --git a/src/util/didyoumean.h b/src/util/didyoumean.h
deleted file mode 100644
index 18a1101cf..000000000
--- a/src/util/didyoumean.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/********************* */
-/*! \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*/
diff --git a/src/util/didyoumean_test.cpp b/src/util/didyoumean_test.cpp
deleted file mode 100644
index 0c46d5ffe..000000000
--- a/src/util/didyoumean_test.cpp
+++ /dev/null
@@ -1,766 +0,0 @@
-/********************* */
-/*! \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;
-}
diff --git a/src/util/divisible.cpp b/src/util/divisible.cpp
index ee085d25b..4a8b7a2e7 100644
--- a/src/util/divisible.cpp
+++ b/src/util/divisible.cpp
@@ -16,7 +16,8 @@
**/
#include "util/divisible.h"
-#include "util/exception.h"
+
+#include "base/exception.h"
using namespace std;
diff --git a/src/util/divisible.h b/src/util/divisible.h
index 6917bf2a6..5f62def02 100644
--- a/src/util/divisible.h
+++ b/src/util/divisible.h
@@ -21,8 +21,9 @@
#define __CVC4__DIVISIBLE_H
#include <iostream>
+
+#include "base/exception.h"
#include "util/integer.h"
-#include "util/exception.h"
namespace CVC4 {
diff --git a/src/util/dump.h b/src/util/dump.h
deleted file mode 100644
index 2cf5877d4..000000000
--- a/src/util/dump.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/dynamic_array.h b/src/util/dynamic_array.h
index 18b1b645b..6938748a8 100644
--- a/src/util/dynamic_array.h
+++ b/src/util/dynamic_array.h
@@ -20,7 +20,7 @@
#ifndef __CVC4__UTIL__DYNAMIC_ARRAY_H
#define __CVC4__UTIL__DYNAMIC_ARRAY_H
-#include "util/cvc4_assert.h"
+#include "base/cvc4_assert.h"
namespace CVC4 {
diff --git a/src/util/emptyset.cpp b/src/util/emptyset.cpp
deleted file mode 100644
index 7905f11fb..000000000
--- a/src/util/emptyset.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/emptyset.h b/src/util/emptyset.h
deleted file mode 100644
index 4b3bb204f..000000000
--- a/src/util/emptyset.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/emptyset.i b/src/util/emptyset.i
deleted file mode 100644
index ce4f3a4b7..000000000
--- a/src/util/emptyset.i
+++ /dev/null
@@ -1,17 +0,0 @@
-%{
-#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"
diff --git a/src/util/exception.cpp b/src/util/exception.cpp
deleted file mode 100644
index ab510c27d..000000000
--- a/src/util/exception.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/********************* */
-/*! \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 */
-}
diff --git a/src/util/exception.h b/src/util/exception.h
deleted file mode 100644
index 937729f0c..000000000
--- a/src/util/exception.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/exception.i b/src/util/exception.i
deleted file mode 100644
index 422f34b10..000000000
--- a/src/util/exception.i
+++ /dev/null
@@ -1,11 +0,0 @@
-%{
-#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"
diff --git a/src/util/floatingpoint.cpp b/src/util/floatingpoint.cpp
index 1aed6331e..d3bb1967a 100644
--- a/src/util/floatingpoint.cpp
+++ b/src/util/floatingpoint.cpp
@@ -13,9 +13,10 @@
**
**/
-#include "util/cvc4_assert.h"
#include "util/floatingpoint.h"
+#include "base/cvc4_assert.h"
+
namespace CVC4 {
FloatingPointSize::FloatingPointSize (unsigned _e, unsigned _s) : e(_e), s(_s)
@@ -35,4 +36,3 @@ namespace CVC4 {
}
}/* CVC4 namespace */
-
diff --git a/src/util/floatingpoint.h b/src/util/floatingpoint.h
index e0678d389..132d67b1c 100644
--- a/src/util/floatingpoint.h
+++ b/src/util/floatingpoint.h
@@ -14,22 +14,16 @@
** [[ This file contains the data structures used by the constant and
** parametric types of the floating point theory. ]]
**/
-
-#include <fenv.h>
-
#include "cvc4_public.h"
-#include "util/bitvector.h"
-
-
#ifndef __CVC4__FLOATINGPOINT_H
#define __CVC4__FLOATINGPOINT_H
+#include <fenv.h>
+#include "util/bitvector.h"
namespace CVC4 {
-
-
// Inline these!
inline bool CVC4_PUBLIC validExponentSize (unsigned e) { return e >= 2; }
inline bool CVC4_PUBLIC validSignificandSize (unsigned s) { return s >= 2; }
@@ -80,14 +74,6 @@ namespace CVC4 {
}; /* struct FloatingPointSizeHashFunction */
-
-
-
-
-
-
-
-
/**
* A concrete instance of the rounding mode sort
*/
@@ -106,14 +92,6 @@ namespace CVC4 {
}; /* struct RoundingModeHashFunction */
-
-
-
-
-
-
-
-
/**
* A concrete floating point number
*/
@@ -168,12 +146,6 @@ namespace CVC4 {
}
}; /* struct FloatingPointHashFunction */
-
-
-
-
-
-
/**
* The parameter type for the conversions to floating point.
*/
@@ -261,9 +233,6 @@ namespace CVC4 {
-
-
-
inline std::ostream& operator <<(std::ostream& os, const FloatingPointLiteral& fp) CVC4_PUBLIC;
inline std::ostream& operator <<(std::ostream& os, const FloatingPointLiteral& fp) {
fp.unfinished();
@@ -285,9 +254,6 @@ namespace CVC4 {
return os << "(_ to_fp " << fpcs.t.exponent() << " " << fpcs.t.significand() << ")";
}
-
-
-
}/* CVC4 namespace */
#endif /* __CVC4__FLOATINGPOINT_H */
diff --git a/src/util/integer_cln_imp.cpp b/src/util/integer_cln_imp.cpp
index 02086494b..1cb4349eb 100644
--- a/src/util/integer_cln_imp.cpp
+++ b/src/util/integer_cln_imp.cpp
@@ -14,11 +14,13 @@
** [[ Add lengthier description here ]]
** \todo document this file
**/
-
-#include "cvc4autoconfig.h"
#include "util/integer.h"
-#include <string>
+
#include <sstream>
+#include <string>
+
+#include "cvc4autoconfig.h"
+
#ifndef CVC4_CLN_IMP
# error "This source should only ever be built if CVC4_CLN_IMP is on !"
diff --git a/src/util/integer_cln_imp.h b/src/util/integer_cln_imp.h
index 9f7f4a06b..6df8d3b8e 100644
--- a/src/util/integer_cln_imp.h
+++ b/src/util/integer_cln_imp.h
@@ -29,7 +29,7 @@
#include <cln/integer_io.h>
#include <limits>
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
diff --git a/src/util/integer_gmp_imp.cpp b/src/util/integer_gmp_imp.cpp
index 2717d03f4..bde759219 100644
--- a/src/util/integer_gmp_imp.cpp
+++ b/src/util/integer_gmp_imp.cpp
@@ -14,11 +14,14 @@
** A multi-precision rational constant.
**/
+#include "util/integer.h"
+
+#include <cmath>
+#include <sstream>
+#include <string>
+
#include "cvc4autoconfig.h"
#include "util/rational.h"
-#include <string>
-#include <sstream>
-#include <cmath>
#ifndef CVC4_GMP_IMP
# error "This source should only ever be built if CVC4_GMP_IMP is on !"
diff --git a/src/util/integer_gmp_imp.h b/src/util/integer_gmp_imp.h
index d1f5050d5..0d3122cd8 100644
--- a/src/util/integer_gmp_imp.h
+++ b/src/util/integer_gmp_imp.h
@@ -24,8 +24,8 @@
#include <iostream>
#include <limits>
+#include "base/exception.h"
#include "util/gmp_util.h"
-#include "util/exception.h"
namespace CVC4 {
diff --git a/src/util/ite_removal.cpp b/src/util/ite_removal.cpp
deleted file mode 100644
index 97a6338ce..000000000
--- a/src/util/ite_removal.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/ite_removal.h b/src/util/ite_removal.h
deleted file mode 100644
index d71f9b13d..000000000
--- a/src/util/ite_removal.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/language.cpp b/src/util/language.cpp
deleted file mode 100644
index 193db09e8..000000000
--- a/src/util/language.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/language.h b/src/util/language.h
deleted file mode 100644
index 05574880f..000000000
--- a/src/util/language.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/language.i b/src/util/language.i
deleted file mode 100644
index ac20db33a..000000000
--- a/src/util/language.i
+++ /dev/null
@@ -1,44 +0,0 @@
-%{
-#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"
diff --git a/src/util/lemma_input_channel.h b/src/util/lemma_input_channel.h
deleted file mode 100644
index 44f0b87f5..000000000
--- a/src/util/lemma_input_channel.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/lemma_output_channel.h b/src/util/lemma_output_channel.h
deleted file mode 100644
index df7abd1e9..000000000
--- a/src/util/lemma_output_channel.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/matcher.h b/src/util/matcher.h
deleted file mode 100644
index 107891a54..000000000
--- a/src/util/matcher.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/maybe.h b/src/util/maybe.h
index 4d279a0c7..2fa7c2f11 100644
--- a/src/util/maybe.h
+++ b/src/util/maybe.h
@@ -27,7 +27,8 @@
#pragma once
#include <ostream>
-#include "util/exception.h"
+
+#include "base/exception.h"
namespace CVC4 {
diff --git a/src/util/model.cpp b/src/util/model.cpp
deleted file mode 100644
index c1254ab47..000000000
--- a/src/util/model.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/model.h b/src/util/model.h
deleted file mode 100644
index 98794a53d..000000000
--- a/src/util/model.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/nary_builder.cpp b/src/util/nary_builder.cpp
deleted file mode 100644
index d89121fd7..000000000
--- a/src/util/nary_builder.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/nary_builder.h b/src/util/nary_builder.h
deleted file mode 100644
index c98e01b1b..000000000
--- a/src/util/nary_builder.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/node_visitor.h b/src/util/node_visitor.h
deleted file mode 100644
index 66a58efd1..000000000
--- a/src/util/node_visitor.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/output.cpp b/src/util/output.cpp
deleted file mode 100644
index 462043805..000000000
--- a/src/util/output.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/output.h b/src/util/output.h
deleted file mode 100644
index 0974591db..000000000
--- a/src/util/output.h
+++ /dev/null
@@ -1,590 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/predicate.cpp b/src/util/predicate.cpp
deleted file mode 100644
index 787d329aa..000000000
--- a/src/util/predicate.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/predicate.h b/src/util/predicate.h
deleted file mode 100644
index 5ead2f090..000000000
--- a/src/util/predicate.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/predicate.i b/src/util/predicate.i
deleted file mode 100644
index eedbb2e83..000000000
--- a/src/util/predicate.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%{
-#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"
diff --git a/src/util/rational_cln_imp.cpp b/src/util/rational_cln_imp.cpp
index e5e3608cb..5044aff18 100644
--- a/src/util/rational_cln_imp.cpp
+++ b/src/util/rational_cln_imp.cpp
@@ -13,11 +13,12 @@
**
** A multi-precision rational constant.
**/
-
-#include "cvc4autoconfig.h"
#include "util/rational.h"
-#include <string>
+
#include <sstream>
+#include <string>
+
+#include "cvc4autoconfig.h"
#ifndef CVC4_CLN_IMP
# error "This source should only ever be built if CVC4_CLN_IMP is on !"
diff --git a/src/util/rational_cln_imp.h b/src/util/rational_cln_imp.h
index 895fc1c9b..df08770e8 100644
--- a/src/util/rational_cln_imp.h
+++ b/src/util/rational_cln_imp.h
@@ -33,7 +33,7 @@
#include <cln/dfloat.h>
#include <cln/real.h>
-#include "util/exception.h"
+#include "base/exception.h"
#include "util/integer.h"
namespace CVC4 {
@@ -369,4 +369,3 @@ CVC4_PUBLIC std::ostream& operator<<(std::ostream& os, const Rational& n);
}/* CVC4 namespace */
#endif /* __CVC4__RATIONAL_H */
-
diff --git a/src/util/rational_gmp_imp.cpp b/src/util/rational_gmp_imp.cpp
index d7f9e2e22..f0f7d46eb 100644
--- a/src/util/rational_gmp_imp.cpp
+++ b/src/util/rational_gmp_imp.cpp
@@ -13,12 +13,13 @@
**
** A multi-precision rational constant.
**/
-
-#include "cvc4autoconfig.h"
#include "util/rational.h"
-#include <string>
-#include <sstream>
+
#include <cmath>
+#include <sstream>
+#include <string>
+
+#include "cvc4autoconfig.h"
#ifndef CVC4_GMP_IMP
# error "This source should only ever be built if CVC4_GMP_IMP is on !"
diff --git a/src/util/rational_gmp_imp.h b/src/util/rational_gmp_imp.h
index 6288be050..59145d485 100644
--- a/src/util/rational_gmp_imp.h
+++ b/src/util/rational_gmp_imp.h
@@ -23,8 +23,8 @@
#include <gmp.h>
#include <string>
+#include "base/exception.h"
#include "util/integer.h"
-#include "util/exception.h"
namespace CVC4 {
@@ -347,4 +347,3 @@ CVC4_PUBLIC std::ostream& operator<<(std::ostream& os, const Rational& n);
}/* CVC4 namespace */
#endif /* __CVC4__RATIONAL_H */
-
diff --git a/src/util/record.cpp b/src/util/record.cpp
deleted file mode 100644
index ea9b5495a..000000000
--- a/src/util/record.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/record.h b/src/util/record.h
deleted file mode 100644
index 5689a4209..000000000
--- a/src/util/record.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/record.i b/src/util/record.i
deleted file mode 100644
index 0cc1bc579..000000000
--- a/src/util/record.i
+++ /dev/null
@@ -1,110 +0,0 @@
-%{
-#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 */
diff --git a/src/util/regexp.cpp b/src/util/regexp.cpp
index 05aacc06c..25a595613 100644
--- a/src/util/regexp.cpp
+++ b/src/util/regexp.cpp
@@ -16,8 +16,9 @@
**/
#include "util/regexp.h"
-#include <iostream>
+
#include <iomanip>
+#include <iostream>
using namespace std;
diff --git a/src/util/regexp.h b/src/util/regexp.h
index a91f825ec..4b26b6e91 100644
--- a/src/util/regexp.h
+++ b/src/util/regexp.h
@@ -25,8 +25,8 @@
#include <set>
#include <sstream>
#include <cassert>
-//#include "util/integer.h"
-#include "util/exception.h"
+
+#include "base/exception.h"
#include "util/hash.h"
namespace CVC4 {
diff --git a/src/util/resource_manager.cpp b/src/util/resource_manager.cpp
deleted file mode 100644
index 22496a433..000000000
--- a/src/util/resource_manager.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/********************* */
-/*! \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;
-}
diff --git a/src/util/resource_manager.h b/src/util/resource_manager.h
deleted file mode 100644
index e84917db0..000000000
--- a/src/util/resource_manager.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/resource_manager.i b/src/util/resource_manager.i
deleted file mode 100644
index 0f55c2bce..000000000
--- a/src/util/resource_manager.i
+++ /dev/null
@@ -1,5 +0,0 @@
-%{
-#include "util/resource_manager.h"
-%}
-
-%include "util/resource_manager.h"
diff --git a/src/util/result.cpp b/src/util/result.cpp
deleted file mode 100644
index 91b671262..000000000
--- a/src/util/result.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/result.h b/src/util/result.h
deleted file mode 100644
index 8c804daa7..000000000
--- a/src/util/result.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/result.i b/src/util/result.i
deleted file mode 100644
index b77bfd881..000000000
--- a/src/util/result.i
+++ /dev/null
@@ -1,20 +0,0 @@
-%{
-#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"
diff --git a/src/util/sexpr.cpp b/src/util/sexpr.cpp
deleted file mode 100644
index 64b898d45..000000000
--- a/src/util/sexpr.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/sexpr.h b/src/util/sexpr.h
deleted file mode 100644
index a121b5195..000000000
--- a/src/util/sexpr.h
+++ /dev/null
@@ -1,304 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/sexpr.i b/src/util/sexpr.i
deleted file mode 100644
index 4c89c5019..000000000
--- a/src/util/sexpr.i
+++ /dev/null
@@ -1,21 +0,0 @@
-%{
-#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"
diff --git a/src/util/smt2_quote_string.cpp b/src/util/smt2_quote_string.cpp
new file mode 100644
index 000000000..68551bc0f
--- /dev/null
+++ b/src/util/smt2_quote_string.cpp
@@ -0,0 +1,41 @@
+/********************* */
+/*! \file smt2_quote_string.cpp
+ ** \verbatim
+ ** Original author: Tim King
+ ** Major contributors: none
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2014 New York University and The University of Iowa
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief Quotes a string if necessary for smt2.
+ **
+ ** Quotes a string if necessary for smt2.
+ **/
+
+#include "util/smt2_quote_string.h"
+
+#include <string>
+
+namespace CVC4 {
+
+/**
+ * SMT-LIB 2 quoting for symbols
+ */
+std::string quoteSymbol(const std::string& s){
+ if(s.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@$%^&*_-+=<>.?/") == std::string::npos) {
+ // simple unquoted symbol
+ return s;
+ } else {
+ std::string tmp(s);
+ // must quote the symbol, but it cannot contain | or \, we turn those into _
+ size_t p;
+ while((p = tmp.find_first_of("\\|")) != std::string::npos) {
+ tmp = tmp.replace(p, 1, "_");
+ }
+ return "|" + tmp + "|";
+ }
+}
+
+}/* CVC4 namespace */
diff --git a/src/util/dump.cpp b/src/util/smt2_quote_string.h
index 53c5eae6a..577f216e2 100644
--- a/src/util/dump.cpp
+++ b/src/util/smt2_quote_string.h
@@ -1,5 +1,5 @@
/********************* */
-/*! \file dump.cpp
+/*! \file smt2_quote_string.h
** \verbatim
** Original author: Morgan Deters
** Major contributors: none
@@ -9,17 +9,25 @@
** See the file COPYING in the top-level source directory for licensing
** information.\endverbatim
**
- ** \brief Dump utility classes and functions
+ ** \brief Quotes a string if necessary for smt2.
**
- ** Dump utility classes and functions.
+ ** Quotes a string if necessary for smt2.
**/
-#include "util/dump.h"
+#include "cvc4_private.h"
-using namespace std;
+#ifndef __CVC4__UTIL__SMT2_QUOTE_STRING_H
+#define __CVC4__UTIL__SMT2_QUOTE_STRING_H
+
+#include <string>
namespace CVC4 {
-DumpC DumpChannel CVC4_PUBLIC;
+/**
+ * SMT-LIB 2 quoting for symbols
+ */
+std::string quoteSymbol(const std::string& s);
}/* CVC4 namespace */
+
+#endif /* __CVC4__UTIL__SMT2_QUOTE_STRING_H */
diff --git a/src/util/sort_inference.cpp b/src/util/sort_inference.cpp
deleted file mode 100644
index c88d9adff..000000000
--- a/src/util/sort_inference.cpp
+++ /dev/null
@@ -1,755 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/sort_inference.h b/src/util/sort_inference.h
deleted file mode 100644
index 4bb1a072e..000000000
--- a/src/util/sort_inference.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/********************* */
-/*! \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
diff --git a/src/util/statistics.cpp b/src/util/statistics.cpp
deleted file mode 100644
index ff31e7b4b..000000000
--- a/src/util/statistics.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/statistics.h b/src/util/statistics.h
deleted file mode 100644
index a7088f5c5..000000000
--- a/src/util/statistics.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/statistics.i b/src/util/statistics.i
deleted file mode 100644
index bd3a4eeb9..000000000
--- a/src/util/statistics.i
+++ /dev/null
@@ -1,79 +0,0 @@
-%{
-#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 */
diff --git a/src/util/statistics_registry.cpp b/src/util/statistics_registry.cpp
deleted file mode 100644
index 097869bc7..000000000
--- a/src/util/statistics_registry.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/********************* */
-/*! \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
diff --git a/src/util/statistics_registry.h b/src/util/statistics_registry.h
deleted file mode 100644
index b9e3eaf8b..000000000
--- a/src/util/statistics_registry.h
+++ /dev/null
@@ -1,925 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/subrange_bound.h b/src/util/subrange_bound.h
index b90656f33..6cff7133c 100644
--- a/src/util/subrange_bound.h
+++ b/src/util/subrange_bound.h
@@ -20,11 +20,11 @@
#ifndef __CVC4__SUBRANGE_BOUND_H
#define __CVC4__SUBRANGE_BOUND_H
-#include "util/integer.h"
-#include "util/exception.h"
-
#include <limits>
+#include "base/exception.h"
+#include "util/integer.h"
+
namespace CVC4 {
/**
diff --git a/src/util/tls.h.in b/src/util/tls.h.in
deleted file mode 100644
index 88969e250..000000000
--- a/src/util/tls.h.in
+++ /dev/null
@@ -1,198 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/uninterpreted_constant.cpp b/src/util/uninterpreted_constant.cpp
deleted file mode 100644
index f0d9a42d2..000000000
--- a/src/util/uninterpreted_constant.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/uninterpreted_constant.h b/src/util/uninterpreted_constant.h
deleted file mode 100644
index 13a80a19d..000000000
--- a/src/util/uninterpreted_constant.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/uninterpreted_constant.i b/src/util/uninterpreted_constant.i
deleted file mode 100644
index 9a49f0642..000000000
--- a/src/util/uninterpreted_constant.i
+++ /dev/null
@@ -1,17 +0,0 @@
-%{
-#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"
diff --git a/src/util/unsafe_interrupt_exception.h b/src/util/unsafe_interrupt_exception.h
index e19fc37ce..d7c736d64 100644
--- a/src/util/unsafe_interrupt_exception.h
+++ b/src/util/unsafe_interrupt_exception.h
@@ -1,5 +1,5 @@
/********************* */
-/*! \file modal_exception.h
+/*! \file unsafe_interrupt_exception.h
** \verbatim
** Original author: Liana Hadarean
** Major contributors: none
@@ -18,7 +18,7 @@
#ifndef __CVC4__UNSAFE_INTERRUPT_EXCEPTION_H
#define __CVC4__UNSAFE_INTERRUPT_EXCEPTION_H
-#include "util/exception.h"
+#include "base/exception.h"
namespace CVC4 {
diff --git a/src/util/unsat_core.cpp b/src/util/unsat_core.cpp
deleted file mode 100644
index 95d066c6d..000000000
--- a/src/util/unsat_core.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/unsat_core.h b/src/util/unsat_core.h
deleted file mode 100644
index 644f56509..000000000
--- a/src/util/unsat_core.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/********************* */
-/*! \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 */
diff --git a/src/util/unsat_core.i b/src/util/unsat_core.i
deleted file mode 100644
index c69dade8f..000000000
--- a/src/util/unsat_core.i
+++ /dev/null
@@ -1,69 +0,0 @@
-%{
-#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 */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback