1 /********************* */
4 ** Top contributors (to current version):
5 ** Morgan Deters, Andrew Reynolds, Tim King
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief A class giving information about a logic (group a theory modules
13 ** and configuration information)
15 ** A class giving information about a logic (group of theory modules and
16 ** configuration information).
19 #include "cvc4_public.h"
21 #ifndef CVC4__LOGIC_INFO_H
22 #define CVC4__LOGIC_INFO_H
26 #include "expr/kind.h"
31 * A LogicInfo instance describes a collection of theory modules and some
32 * basic configuration about them. Conceptually, it provides a background
33 * context for all operations in CVC4. Typically, when CVC4's SmtEngine
34 * is created, it is issued a setLogic() command indicating features of the
35 * assertions and queries to follow---for example, whether quantifiers are
36 * used, whether integers or reals (or both) will be used, etc.
38 * Most places in CVC4 will only ever need to access a const reference to an
39 * instance of this class. Such an instance is generally set by the SmtEngine
40 * when setLogic() is called. However, mutating member functions are also
41 * provided by this class so that it can be used as a more general mechanism
42 * (e.g., for communicating to the SmtEngine which theories should be used,
43 * rather than having to provide an SMT-LIB string).
45 class CVC4_PUBLIC LogicInfo
{
46 mutable std::string d_logicString
; /**< an SMT-LIB-like logic string */
47 std::vector
<bool> d_theories
; /**< set of active theories */
48 size_t d_sharingTheories
; /**< count of theories that need sharing */
50 /** are integers used in this logic? */
52 /** are reals used in this logic? */
54 /** transcendentals in this logic? */
55 bool d_transcendentals
;
56 /** linear-only arithmetic in this logic? */
58 /** difference-only arithmetic in this logic? */
59 bool d_differenceLogic
;
60 /** cardinality constraints in this logic? */
61 bool d_cardinalityConstraints
;
62 /** higher-order constraints in this logic? */
65 bool d_locked
; /**< is this LogicInfo instance locked (and thus immutable)? */
68 * Returns true iff this is a "true" theory (one that must be worried
71 static inline bool isTrueTheory(theory::TheoryId theory
) {
73 case theory::THEORY_BUILTIN
:
74 case theory::THEORY_BOOL
:
75 case theory::THEORY_QUANTIFIERS
:
85 * Constructs a LogicInfo for the most general logic (quantifiers, all
86 * background theory modules, ...).
91 * Construct a LogicInfo from an SMT-LIB-like logic string.
92 * Throws an IllegalArgumentException if the logic string cannot
95 LogicInfo(std::string logicString
);
98 * Construct a LogicInfo from an SMT-LIB-like logic string.
99 * Throws an IllegalArgumentException if the logic string cannot
102 LogicInfo(const char* logicString
);
107 * Get an SMT-LIB-like logic string. These are only guaranteed to
108 * be SMT-LIB-compliant if an SMT-LIB-compliant string was used in
109 * the constructor and no mutating functions were called.
111 std::string
getLogicString() const;
113 /** Is sharing enabled for this logic? */
114 bool isSharingEnabled() const;
116 /** Is the given theory module active in this logic? */
117 bool isTheoryEnabled(theory::TheoryId theory
) const;
119 /** Is this a quantified logic? */
120 bool isQuantified() const;
122 /** Is this the all-inclusive logic? */
123 bool hasEverything() const;
125 /** Is this the all-exclusive logic? (Here, that means propositional logic) */
126 bool hasNothing() const;
129 * Is this a pure logic (only one "true" background theory). Quantifiers
130 * can exist in such logics though; to test for quantifier-free purity,
131 * use "isPure(theory) && !isQuantified()".
133 bool isPure(theory::TheoryId theory
) const;
135 // these are for arithmetic
137 /** Are integers in this logic? */
138 bool areIntegersUsed() const;
140 /** Are reals in this logic? */
141 bool areRealsUsed() const;
143 /** Are transcendentals in this logic? */
144 bool areTranscendentalsUsed() const;
146 /** Does this logic only linear arithmetic? */
147 bool isLinear() const;
149 /** Does this logic only permit difference reasoning? (implies linear) */
150 bool isDifferenceLogic() const;
152 /** Does this logic allow cardinality constraints? */
153 bool hasCardinalityConstraints() const;
155 /** Is this a higher order logic? */
156 bool isHigherOrder() const;
161 * Initialize the LogicInfo with an SMT-LIB-like logic string.
162 * Throws an IllegalArgumentException if the string can't be
165 void setLogicString(std::string logicString
);
168 * Enable all functionality. All theories, plus quantifiers, will be
171 void enableEverything();
174 * Disable all functionality. The result will be a LogicInfo with
175 * the BUILTIN and BOOLEAN theories enabled only ("QF_SAT").
177 void disableEverything();
180 * Enable the given theory module.
182 void enableTheory(theory::TheoryId theory
);
185 * Disable the given theory module. THEORY_BUILTIN and THEORY_BOOL cannot
186 * be disabled (and if given here, the request will be silently ignored).
188 void disableTheory(theory::TheoryId theory
);
191 * Quantifiers are a special case, since two theory modules handle them.
193 void enableQuantifiers() {
194 enableTheory(theory::THEORY_QUANTIFIERS
);
198 * Quantifiers are a special case, since two theory modules handle them.
200 void disableQuantifiers() {
201 disableTheory(theory::THEORY_QUANTIFIERS
);
205 * Enable everything that is needed for sygus with respect to this logic info.
206 * This means enabling quantifiers, datatypes, UF, integers, and higher order.
210 // these are for arithmetic
212 /** Enable the use of integers in this logic. */
213 void enableIntegers();
214 /** Disable the use of integers in this logic. */
215 void disableIntegers();
216 /** Enable the use of reals in this logic. */
218 /** Disable the use of reals in this logic. */
220 /** Enable the use of transcendentals in this logic. */
221 void arithTranscendentals();
222 /** Only permit difference arithmetic in this logic. */
223 void arithOnlyDifference();
224 /** Only permit linear arithmetic in this logic. */
225 void arithOnlyLinear();
226 /** Permit nonlinear arithmetic in this logic. */
227 void arithNonLinear();
229 // for cardinality constraints
231 /** Enable the use of cardinality constraints in this logic. */
232 void enableCardinalityConstraints();
233 /** Disable the use of cardinality constraints in this logic. */
234 void disableCardinalityConstraints();
238 /** Enable the use of higher-order in this logic. */
239 void enableHigherOrder();
240 /** Disable the use of higher-order in this logic. */
241 void disableHigherOrder();
243 // LOCKING FUNCTIONALITY
245 /** Lock this LogicInfo, disabling further mutation and allowing queries */
246 void lock() { d_locked
= true; }
247 /** Check whether this LogicInfo is locked, disallowing further mutation */
248 bool isLocked() const { return d_locked
; }
249 /** Get a copy of this LogicInfo that is identical, but unlocked */
250 LogicInfo
getUnlockedCopy() const;
254 /** Are these two LogicInfos equal? */
255 bool operator==(const LogicInfo
& other
) const;
257 /** Are these two LogicInfos disequal? */
258 bool operator!=(const LogicInfo
& other
) const {
259 return !(*this == other
);
262 /** Is this LogicInfo "greater than" (does it contain everything and more) the other? */
263 bool operator>(const LogicInfo
& other
) const {
264 return *this >= other
&& *this != other
;
267 /** Is this LogicInfo "less than" (does it contain strictly less) the other? */
268 bool operator<(const LogicInfo
& other
) const {
269 return *this <= other
&& *this != other
;
271 /** Is this LogicInfo "less than or equal" the other? */
272 bool operator<=(const LogicInfo
& other
) const;
274 /** Is this LogicInfo "greater than or equal" the other? */
275 bool operator>=(const LogicInfo
& other
) const;
277 /** Are two LogicInfos comparable? That is, is one of <= or > true? */
278 bool isComparableTo(const LogicInfo
& other
) const {
279 return *this <= other
|| *this >= other
;
282 };/* class LogicInfo */
284 std::ostream
& operator<<(std::ostream
& out
, const LogicInfo
& logic
) CVC4_PUBLIC
;
286 }/* CVC4 namespace */
288 #endif /* CVC4__LOGIC_INFO_H */