summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2012-08-03 22:15:33 +0000
committerMorgan Deters <mdeters@gmail.com>2012-08-03 22:15:33 +0000
commit8af4e7b765815a89671ac2c62554b773d4dda290 (patch)
treeb40f53d82e16d41510ff52d82a991598df6583dc /src
parent39a66fe81b66498c82d1638c58c3c4ccc8f586db (diff)
Comparisons for LogicInfos, and associated tests
Diffstat (limited to 'src')
-rw-r--r--src/theory/logic_info.cpp18
-rw-r--r--src/theory/logic_info.h86
2 files changed, 104 insertions, 0 deletions
diff --git a/src/theory/logic_info.cpp b/src/theory/logic_info.cpp
index d0c1e4b6a..9660986cf 100644
--- a/src/theory/logic_info.cpp
+++ b/src/theory/logic_info.cpp
@@ -61,6 +61,20 @@ LogicInfo::LogicInfo(std::string logicString) throw(IllegalArgumentException) :
lock();
}
+LogicInfo::LogicInfo(const char* logicString) throw(IllegalArgumentException) :
+ d_logicString(""),
+ d_theories(),
+ d_sharingTheories(0),
+ d_integers(false),
+ d_reals(false),
+ d_linear(false),
+ d_differenceLogic(false),
+ d_locked(false) {
+
+ setLogicString(logicString);
+ lock();
+}
+
std::string LogicInfo::getLogicString() const {
Assert(d_locked, "This LogicInfo isn't locked yet, and cannot be queried");
if(d_logicString == "") {
@@ -329,4 +343,8 @@ LogicInfo LogicInfo::getUnlockedCopy() const {
}
}
+std::ostream& operator<<(std::ostream& out, const LogicInfo& logic) {
+ return out << logic.getLogicString();
+}
+
}/* CVC4 namespace */
diff --git a/src/theory/logic_info.h b/src/theory/logic_info.h
index 33a059bb9..7fa6e157f 100644
--- a/src/theory/logic_info.h
+++ b/src/theory/logic_info.h
@@ -87,6 +87,13 @@ public:
*/
LogicInfo(std::string logicString) throw(IllegalArgumentException);
+ /**
+ * Construct a LogicInfo from an SMT-LIB-like logic string.
+ * Throws an IllegalArgumentException if the logic string cannot
+ * be interpreted.
+ */
+ LogicInfo(const char* logicString) throw(IllegalArgumentException);
+
// ACCESSORS
/**
@@ -224,8 +231,87 @@ public:
/** Get a copy of this LogicInfo that is identical, but unlocked */
LogicInfo getUnlockedCopy() const;
+ // COMPARISON
+
+ /** Are these two LogicInfos equal? */
+ bool operator==(const LogicInfo& other) const {
+ Assert(isLocked() && other.isLocked(), "This LogicInfo isn't locked yet, and cannot be queried");
+ for(theory::TheoryId id = theory::THEORY_FIRST; id < theory::THEORY_LAST; ++id) {
+ if(d_theories[id] != other.d_theories[id]) {
+ return false;
+ }
+ }
+ Assert(d_sharingTheories == other.d_sharingTheories, "LogicInfo internal inconsistency");
+ if(isTheoryEnabled(theory::THEORY_ARITH)) {
+ return
+ d_integers == other.d_integers &&
+ d_reals == other.d_reals &&
+ d_linear == other.d_linear &&
+ d_differenceLogic == other.d_differenceLogic;
+ } else {
+ return true;
+ }
+ }
+ /** Are these two LogicInfos disequal? */
+ bool operator!=(const LogicInfo& other) const {
+ return !(*this == other);
+ }
+ /** Is this LogicInfo "greater than" (does it contain everything and more) the other? */
+ bool operator>(const LogicInfo& other) const {
+ return *this >= other && *this != other;
+ }
+ /** Is this LogicInfo "less than" (does it contain strictly less) the other? */
+ bool operator<(const LogicInfo& other) const {
+ return *this <= other && *this != other;
+ }
+ /** Is this LogicInfo "less than or equal" the other? */
+ bool operator<=(const LogicInfo& other) const {
+ Assert(isLocked() && other.isLocked(), "This LogicInfo isn't locked yet, and cannot be queried");
+ for(theory::TheoryId id = theory::THEORY_FIRST; id < theory::THEORY_LAST; ++id) {
+ if(d_theories[id] && !other.d_theories[id]) {
+ return false;
+ }
+ }
+ Assert(d_sharingTheories <= other.d_sharingTheories, "LogicInfo internal inconsistency");
+ if(isTheoryEnabled(theory::THEORY_ARITH) && other.isTheoryEnabled(theory::THEORY_ARITH)) {
+ return
+ (!d_integers || other.d_integers) &&
+ (!d_reals || other.d_reals) &&
+ (d_linear || !other.d_linear) &&
+ (d_differenceLogic || !other.d_differenceLogic);
+ } else {
+ return true;
+ }
+ }
+ /** Is this LogicInfo "greater than or equal" the other? */
+ bool operator>=(const LogicInfo& other) const {
+ Assert(isLocked() && other.isLocked(), "This LogicInfo isn't locked yet, and cannot be queried");
+ for(theory::TheoryId id = theory::THEORY_FIRST; id < theory::THEORY_LAST; ++id) {
+ if(!d_theories[id] && other.d_theories[id]) {
+ return false;
+ }
+ }
+ Assert(d_sharingTheories >= other.d_sharingTheories, "LogicInfo internal inconsistency");
+ if(isTheoryEnabled(theory::THEORY_ARITH) && other.isTheoryEnabled(theory::THEORY_ARITH)) {
+ return
+ (d_integers || !other.d_integers) &&
+ (d_reals || !other.d_reals) &&
+ (!d_linear || other.d_linear) &&
+ (!d_differenceLogic || other.d_differenceLogic);
+ } else {
+ return true;
+ }
+ }
+
+ /** Are two LogicInfos comparable? That is, is one of <= or > true? */
+ bool isComparableTo(const LogicInfo& other) const {
+ return *this <= other || *this >= other;
+ }
+
};/* class LogicInfo */
+std::ostream& operator<<(std::ostream& out, const LogicInfo& logic) CVC4_PUBLIC;
+
}/* CVC4 namespace */
#endif /* __CVC4__LOGIC_INFO_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback