ba7119071bb1fe924898265ef2555c0ac5127c0e
1 /********************* */
2 /*! \file logic_info.cpp
4 ** Original author: mdeters
5 ** Major contributors: none
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009--2012 The Analysis of Computer Systems Group (ACSys)
9 ** Courant Institute of Mathematical Sciences
10 ** New York University
11 ** See the file COPYING in the top-level source directory for licensing
12 ** information.\endverbatim
14 ** \brief A class giving information about a logic (group a theory modules
15 ** and configuration information)
17 ** A class giving information about a logic (group of theory modules and
18 ** configuration information).
25 #include "expr/kind.h"
26 #include "theory/logic_info.h"
27 #include "util/Assert.h"
30 using namespace CVC4::theory
;
34 LogicInfo::LogicInfo() :
42 for(TheoryId id
= THEORY_FIRST
; id
< THEORY_LAST
; ++id
) {
43 d_theories
[id
] = false;// ensure it's cleared
48 LogicInfo::LogicInfo(std::string logicString
) throw(IllegalArgumentException
) :
55 setLogicString(logicString
);
58 std::string
LogicInfo::getLogicString() const {
59 if(d_logicString
== "") {
60 size_t seen
= 0; // make sure we support all the active theories
66 if(d_theories
[THEORY_ARRAY
]) {
67 ss
<< (d_sharingTheories
== 1 ? "AX" : "A");
70 if(d_theories
[THEORY_UF
]) {
74 if(d_theories
[THEORY_BV
]) {
78 if(d_theories
[THEORY_DATATYPES
]) {
82 if(d_theories
[THEORY_ARITH
]) {
83 if(isDifferenceLogic()) {
84 ss
<< (areIntegersUsed() ? "I" : "");
85 ss
<< (areRealsUsed() ? "R" : "");
88 ss
<< (isLinear() ? "L" : "N");
89 ss
<< (areIntegersUsed() ? "I" : "");
90 ss
<< (areRealsUsed() ? "R" : "");
96 if(seen
!= d_sharingTheories
) {
97 Unhandled("can't extract a logic string from LogicInfo; at least one "
98 "active theory is unknown to LogicInfo::getLogicString() !");
105 d_logicString
= ss
.str();
107 return d_logicString
;
110 void LogicInfo::setLogicString(std::string logicString
) throw(IllegalArgumentException
) {
111 for(TheoryId id
= THEORY_FIRST
; id
< THEORY_LAST
; ++id
) {
112 d_theories
[id
] = false;// ensure it's cleared
114 d_sharingTheories
= 0;
116 // Below, ONLY use enableTheory()/disableTheory() rather than
117 // accessing d_theories[] directly. This makes sure to set up
120 enableTheory(THEORY_BUILTIN
);
121 enableTheory(THEORY_BOOL
);
123 const char* p
= logicString
.c_str();
124 if(!strcmp(p
, "QF_SAT") || *p
== '\0') {
125 // propositional logic only; we're done.
128 if(!strncmp(p
, "QF_", 3)) {
129 disableQuantifiers();
134 if(!strncmp(p
, "AX", 2)) {
135 enableTheory(THEORY_ARRAY
);
139 enableTheory(THEORY_ARRAY
);
142 if(!strncmp(p
, "UF", 2)) {
143 enableTheory(THEORY_UF
);
146 if(!strncmp(p
, "BV", 2)) {
147 enableTheory(THEORY_BV
);
150 if(!strncmp(p
, "DT", 2)) {
151 enableTheory(THEORY_DATATYPES
);
154 if(!strncmp(p
, "IDL", 3)) {
157 arithOnlyDifference();
159 } else if(!strncmp(p
, "RDL", 3)) {
162 arithOnlyDifference();
164 } else if(!strncmp(p
, "IRDL", 4)) {
165 // "IRDL" ?! --not very useful, but getLogicString() can produce
166 // that string, so we really had better be able to read it back in.
169 arithOnlyDifference();
171 } else if(!strncmp(p
, "LIA", 3)) {
176 } else if(!strncmp(p
, "LRA", 3)) {
181 } else if(!strncmp(p
, "LIRA", 4)) {
186 } else if(!strncmp(p
, "NIA", 3)) {
191 } else if(!strncmp(p
, "NRA", 3)) {
196 } else if(!strncmp(p
, "NIRA", 4)) {
206 err
<< "LogicInfo::setLogicString(): junk (\"" << p
<< "\") at end of logic string: " << logicString
;
207 IllegalArgument(logicString
, err
.str().c_str());
210 // ensure a getLogic() returns the same thing as was set
211 d_logicString
= logicString
;
214 void LogicInfo::enableTheory(theory::TheoryId theory
) {
215 if(!d_theories
[theory
]) {
216 if(isTrueTheory(theory
)) {
220 d_theories
[theory
] = true;
224 void LogicInfo::disableTheory(theory::TheoryId theory
) {
225 if(d_theories
[theory
]) {
226 if(isTrueTheory(theory
)) {
227 Assert(d_sharingTheories
> 0);
230 if(theory
== THEORY_BUILTIN
||
231 theory
== THEORY_BOOL
) {
235 d_theories
[theory
] = false;
239 void LogicInfo::enableIntegers() {
241 enableTheory(THEORY_ARITH
);
245 void LogicInfo::disableIntegers() {
249 disableTheory(THEORY_ARITH
);
253 void LogicInfo::enableReals() {
255 enableTheory(THEORY_ARITH
);
259 void LogicInfo::disableReals() {
263 disableTheory(THEORY_ARITH
);
267 void LogicInfo::arithOnlyDifference() {
270 d_differenceLogic
= true;
273 void LogicInfo::arithOnlyLinear() {
276 d_differenceLogic
= false;
279 void LogicInfo::arithNonLinear() {
282 d_differenceLogic
= false;
285 }/* CVC4 namespace */