logic_info.h
Go to the documentation of this file.
/********************* */
#include "cvc4_public.h"
#ifndef __CVC4__LOGIC_INFO_H
#define __CVC4__LOGIC_INFO_H
#include <string>
#include <vector>
#include "expr/kind.h"
namespace CVC4 {
class CVC4_PUBLIC LogicInfo {
mutable std::string d_logicString;
std::vector<bool> d_theories;
size_t d_sharingTheories;
// for arithmetic
bool d_integers;
bool d_reals;
bool d_linear;
bool d_differenceLogic;
bool d_cardinalityConstraints;
bool d_locked;
static inline bool isTrueTheory(theory::TheoryId theory) {
switch(theory) {
case theory::THEORY_BUILTIN:
case theory::THEORY_BOOL:
case theory::THEORY_QUANTIFIERS:
return false;
default:
return true;
}
}
public:
LogicInfo();
LogicInfo(std::string logicString) throw(IllegalArgumentException);
LogicInfo(const char* logicString) throw(IllegalArgumentException);
// ACCESSORS
std::string getLogicString() const;
bool isSharingEnabled() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
return d_sharingTheories > 1;
}
bool isTheoryEnabled(theory::TheoryId theory) const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
return d_theories[theory];
}
bool isQuantified() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
return isTheoryEnabled(theory::THEORY_QUANTIFIERS);
}
bool hasEverything() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
LogicInfo everything;
everything.lock();
return *this == everything;
}
bool hasNothing() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
LogicInfo nothing("");
nothing.lock();
return *this == nothing;
}
bool isPure(theory::TheoryId theory) const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
// the third and fourth conjucts are really just to rule out the misleading
// case where you ask isPure(THEORY_BOOL) and get true even in e.g. QF_LIA
return isTheoryEnabled(theory) && !isSharingEnabled() &&
( !isTrueTheory(theory) || d_sharingTheories == 1 ) &&
( isTrueTheory(theory) || d_sharingTheories == 0 );
}
// these are for arithmetic
bool areIntegersUsed() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
CheckArgument(isTheoryEnabled(theory::THEORY_ARITH), *this, "Arithmetic not used in this LogicInfo; cannot ask whether integers are used");
return d_integers;
}
bool areRealsUsed() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
CheckArgument(isTheoryEnabled(theory::THEORY_ARITH), *this, "Arithmetic not used in this LogicInfo; cannot ask whether reals are used");
return d_reals;
}
bool isLinear() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
CheckArgument(isTheoryEnabled(theory::THEORY_ARITH), *this, "Arithmetic not used in this LogicInfo; cannot ask whether it's linear");
return d_linear || d_differenceLogic;
}
bool isDifferenceLogic() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
CheckArgument(isTheoryEnabled(theory::THEORY_ARITH), *this, "Arithmetic not used in this LogicInfo; cannot ask whether it's difference logic");
return d_differenceLogic;
}
bool hasCardinalityConstraints() const {
CheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried");
return d_cardinalityConstraints;
}
// MUTATORS
void setLogicString(std::string logicString) throw(IllegalArgumentException);
void enableEverything();
void disableEverything();
void enableTheory(theory::TheoryId theory);
void disableTheory(theory::TheoryId theory);
void enableQuantifiers() {
enableTheory(theory::THEORY_QUANTIFIERS);
}
void disableQuantifiers() {
disableTheory(theory::THEORY_QUANTIFIERS);
}
// these are for arithmetic
void enableIntegers();
void disableIntegers();
void enableReals();
void disableReals();
void arithOnlyDifference();
void arithOnlyLinear();
void arithNonLinear();
// LOCKING FUNCTIONALITY
void lock() { d_locked = true; }
bool isLocked() const { return d_locked; }
LogicInfo getUnlockedCopy() const;
// COMPARISON
bool operator==(const LogicInfo& other) const {
CheckArgument(isLocked() && other.isLocked(), *this, "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;
}
}
CheckArgument(d_sharingTheories == other.d_sharingTheories, *this, "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;
}
}
bool operator!=(const LogicInfo& other) const {
return !(*this == other);
}
bool operator>(const LogicInfo& other) const {
return *this >= other && *this != other;
}
bool operator<(const LogicInfo& other) const {
return *this <= other && *this != other;
}
bool operator<=(const LogicInfo& other) const {
CheckArgument(isLocked() && other.isLocked(), *this, "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;
}
}
CheckArgument(d_sharingTheories <= other.d_sharingTheories, *this, "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;
}
}
bool operator>=(const LogicInfo& other) const {
CheckArgument(isLocked() && other.isLocked(), *this, "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;
}
}
CheckArgument(d_sharingTheories >= other.d_sharingTheories, *this, "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;
}
}
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 */
CVC4::IllegalArgumentException
Definition exception.h:79
CVC4::LogicInfo
A LogicInfo instance describes a collection of theory modules and some basic configuration about them...
Definition logic_info.h:45
CVC4::LogicInfo::operator<
bool operator<(const LogicInfo &other) const
Is this LogicInfo "less than" (does it contain strictly less) the other?
Definition logic_info.h:287
CVC4::LogicInfo::disableReals
void disableReals()
Disable the use of reals in this logic.
CVC4::LogicInfo::getLogicString
std::string getLogicString() const
Get an SMT-LIB-like logic string.
CVC4::LogicInfo::isSharingEnabled
bool isSharingEnabled() const
Is sharing enabled for this logic?
Definition logic_info.h:106
CVC4::LogicInfo::arithNonLinear
void arithNonLinear()
Permit nonlinear arithmetic in this logic.
CVC4::LogicInfo::isDifferenceLogic
bool isDifferenceLogic() const
Does this logic only permit difference reasoning? (implies linear)
Definition logic_info.h:174
CVC4::LogicInfo::LogicInfo
LogicInfo()
Constructs a LogicInfo for the most general logic (quantifiers, all background theory modules,...
CVC4::LogicInfo::isQuantified
bool isQuantified() const
Is this a quantified logic?
Definition logic_info.h:118
CVC4::LogicInfo::arithOnlyDifference
void arithOnlyDifference()
Only permit difference arithmetic in this logic.
CVC4::LogicInfo::hasEverything
bool hasEverything() const
Is this the all-inclusive logic?
Definition logic_info.h:124
CVC4::LogicInfo::hasCardinalityConstraints
bool hasCardinalityConstraints() const
Does this logic allow cardinality constraints?
Definition logic_info.h:180
CVC4::LogicInfo::isComparableTo
bool isComparableTo(const LogicInfo &other) const
Are two LogicInfos comparable? That is, is one of <= or > true?
Definition logic_info.h:330
CVC4::LogicInfo::operator>
bool operator>(const LogicInfo &other) const
Is this LogicInfo "greater than" (does it contain everything and more) the other?
Definition logic_info.h:283
CVC4::LogicInfo::operator!=
bool operator!=(const LogicInfo &other) const
Are these two LogicInfos disequal?
Definition logic_info.h:279
CVC4::LogicInfo::isPure
bool isPure(theory::TheoryId theory) const
Is this a pure logic (only one "true" background theory).
Definition logic_info.h:144
CVC4::LogicInfo::arithOnlyLinear
void arithOnlyLinear()
Only permit linear arithmetic in this logic.
CVC4::LogicInfo::operator<=
bool operator<=(const LogicInfo &other) const
Is this LogicInfo "less than or equal" the other?
Definition logic_info.h:291
CVC4::LogicInfo::operator==
bool operator==(const LogicInfo &other) const
Are these two LogicInfos equal?
Definition logic_info.h:260
CVC4::LogicInfo::isLinear
bool isLinear() const
Does this logic only linear arithmetic?
Definition logic_info.h:168
CVC4::LogicInfo::getUnlockedCopy
LogicInfo getUnlockedCopy() const
Get a copy of this LogicInfo that is identical, but unlocked.
CVC4::LogicInfo::LogicInfo
LogicInfo(const char *logicString)
Construct a LogicInfo from an SMT-LIB-like logic string.
CVC4::LogicInfo::operator>=
bool operator>=(const LogicInfo &other) const
Is this LogicInfo "greater than or equal" the other?
Definition logic_info.h:310
CVC4::LogicInfo::enableQuantifiers
void enableQuantifiers()
Quantifiers are a special case, since two theory modules handle them.
Definition logic_info.h:220
CVC4::LogicInfo::areRealsUsed
bool areRealsUsed() const
Are reals in this logic?
Definition logic_info.h:162
CVC4::LogicInfo::lock
void lock()
Lock this LogicInfo, disabling further mutation and allowing queries.
Definition logic_info.h:251
CVC4::LogicInfo::setLogicString
void setLogicString(std::string logicString)
Initialize the LogicInfo with an SMT-LIB-like logic string.
CVC4::LogicInfo::enableEverything
void enableEverything()
Enable all functionality.
CVC4::LogicInfo::isTheoryEnabled
bool isTheoryEnabled(theory::TheoryId theory) const
Is the given theory module active in this logic?
Definition logic_info.h:112
CVC4::LogicInfo::enableTheory
void enableTheory(theory::TheoryId theory)
Enable the given theory module.
CVC4::LogicInfo::disableTheory
void disableTheory(theory::TheoryId theory)
Disable the given theory module.
CVC4::LogicInfo::isLocked
bool isLocked() const
Check whether this LogicInfo is locked, disallowing further mutation.
Definition logic_info.h:253
CVC4::LogicInfo::LogicInfo
LogicInfo(std::string logicString)
Construct a LogicInfo from an SMT-LIB-like logic string.
CVC4::LogicInfo::disableIntegers
void disableIntegers()
Disable the use of integers in this logic.
CVC4::LogicInfo::hasNothing
bool hasNothing() const
Is this the all-exclusive logic? (Here, that means propositional logic)
Definition logic_info.h:132
CVC4::LogicInfo::areIntegersUsed
bool areIntegersUsed() const
Are integers in this logic?
Definition logic_info.h:156
CVC4::LogicInfo::disableEverything
void disableEverything()
Disable all functionality.
CVC4::LogicInfo::enableReals
void enableReals()
Enable the use of reals in this logic.
CVC4::LogicInfo::disableQuantifiers
void disableQuantifiers()
Quantifiers are a special case, since two theory modules handle them.
Definition logic_info.h:227
CVC4::LogicInfo::enableIntegers
void enableIntegers()
Enable the use of integers in this logic.
cvc4_public.h
Macros that should be defined everywhere during the building of the libraries and driver binary,...
CVC4_PUBLIC
#define CVC4_PUBLIC
Definition cvc4_public.h:30
kind.h
CVC4::theory::TheoryId
TheoryId
Definition kind.h:591
CVC4
Definition expr.h:106
CVC4::operator<<
std::ostream & operator<<(std::ostream &out, const TypeCheckingException &e)
CVC4::CheckArgument
void CheckArgument(bool cond, const T &arg, const char *fmt,...)
Definition exception.h:140