summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2012-07-14 22:53:58 +0000
committerMorgan Deters <mdeters@gmail.com>2012-07-14 22:53:58 +0000
commit4941b3c516361183b4623f5660128e4f1bcce809 (patch)
tree5a996a0778b9a78b27b041fa582ff5585b710013 /src/util
parent1c42109395b566a0068cc3ae9067fc87ab8f8e7b (diff)
Type enumerator infrastructure and uninterpreted constant support. No support yet for enumerating arrays, or for enumerating non-trivial datatypes.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Makefile.am2
-rw-r--r--src/util/uninterpreted_constant.cpp40
-rw-r--r--src/util/uninterpreted_constant.h86
3 files changed, 128 insertions, 0 deletions
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 43cc15ec9..08b5d05f5 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -74,6 +74,8 @@ libutil_la_SOURCES = \
ite_removal.cpp \
node_visitor.h \
index.h \
+ uninterpreted_constant.h \
+ uninterpreted_constant.cpp \
model.h \
model.cpp
diff --git a/src/util/uninterpreted_constant.cpp b/src/util/uninterpreted_constant.cpp
new file mode 100644
index 000000000..766d86428
--- /dev/null
+++ b/src/util/uninterpreted_constant.cpp
@@ -0,0 +1,40 @@
+/********************* */
+/*! \file uninterpreted_constant.cpp
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009-2012 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** 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
new file mode 100644
index 000000000..a6e7a7256
--- /dev/null
+++ b/src/util/uninterpreted_constant.h
@@ -0,0 +1,86 @@
+/********************* */
+/*! \file uninterpreted_constant.h
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009-2012 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** 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() :
+ 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 UninterpretedConstantHashStrategy {
+ static inline size_t hash(const UninterpretedConstant& uc) {
+ return TypeHashFunction()(uc.getType()) * IntegerHashStrategy::hash(uc.getIndex());
+ }
+};/* struct UninterpretedConstantHashStrategy */
+
+}/* CVC4 namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback