Result::Result(const std::string& instr, std::string inputName) : d_sat(SAT_UNKNOWN), d_validity(VALIDITY_UNKNOWN), d_which(TYPE_NONE), d_unknownExplanation(UNKNOWN_REASON), d_inputName(inputName) { string s = instr; transform(s.begin(), s.end(), s.begin(), ::tolower); if (s == "sat" || s == "satisfiable") { d_which = TYPE_SAT; d_sat = SAT; } else if (s == "unsat" || s == "unsatisfiable") { d_which = TYPE_SAT; d_sat = UNSAT; } else if (s == "valid") { d_which = TYPE_VALIDITY; d_validity = VALID; } else if (s == "invalid") { d_which = TYPE_VALIDITY; d_validity = INVALID; } else if (s == "incomplete") { d_which = TYPE_SAT; d_sat = SAT_UNKNOWN; d_unknownExplanation = INCOMPLETE; } else if (s == "timeout") { d_which = TYPE_SAT; d_sat = SAT_UNKNOWN; d_unknownExplanation = TIMEOUT; } else if (s == "resourceout") { d_which = TYPE_SAT; d_sat = SAT_UNKNOWN; d_unknownExplanation = RESOURCEOUT; } else if (s == "memout") { d_which = TYPE_SAT; d_sat = SAT_UNKNOWN; d_unknownExplanation = MEMOUT; } else if (s == "interrupted") { d_which = TYPE_SAT; d_sat = SAT_UNKNOWN; d_unknownExplanation = INTERRUPTED; } else if (s.size() >= 7 && s.compare(0, 7, "unknown") == 0) { d_which = TYPE_SAT; d_sat = SAT_UNKNOWN; } else { IllegalArgument(s, "expected satisfiability/validity result, " "instead got `%s'", s.c_str()); } }
void LogicInfo::setLogicString(std::string logicString) throw(IllegalArgumentException) { CheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); for(TheoryId id = THEORY_FIRST; id < THEORY_LAST; ++id) { d_theories[id] = false;// ensure it's cleared } d_sharingTheories = 0; // Below, ONLY use enableTheory()/disableTheory() rather than // accessing d_theories[] directly. This makes sure to set up // sharing properly. enableTheory(THEORY_BUILTIN); enableTheory(THEORY_BOOL); const char* p = logicString.c_str(); if(!strcmp(p, "QF_SAT") || *p == '\0') { // propositional logic only; we're done. p += 6; } else if(!strcmp(p, "QF_ALL_SUPPORTED")) { // the "all theories included" logic, no quantifiers enableEverything(); disableQuantifiers(); p += 16; } else if(!strcmp(p, "ALL_SUPPORTED")) { // the "all theories included" logic, with quantifiers enableEverything(); enableQuantifiers(); p += 13; } else { if(!strncmp(p, "QF_", 3)) { disableQuantifiers(); p += 3; } else { enableQuantifiers(); } if(!strncmp(p, "AX", 2)) { enableTheory(THEORY_ARRAY); p += 2; } else { if(*p == 'A') { enableTheory(THEORY_ARRAY); ++p; } if(!strncmp(p, "UF", 2)) { enableTheory(THEORY_UF); p += 2; } if(!strncmp(p, "BV", 2)) { enableTheory(THEORY_BV); p += 2; } if(!strncmp(p, "DT", 2)) { enableTheory(THEORY_DATATYPES); p += 2; } if(!strncmp(p, "IDL", 3)) { enableIntegers(); disableReals(); arithOnlyDifference(); p += 3; } else if(!strncmp(p, "RDL", 3)) { disableIntegers(); enableReals(); arithOnlyDifference(); p += 3; } else if(!strncmp(p, "IRDL", 4)) { // "IRDL" ?! --not very useful, but getLogicString() can produce // that string, so we really had better be able to read it back in. enableIntegers(); enableReals(); arithOnlyDifference(); p += 4; } else if(!strncmp(p, "LIA", 3)) { enableIntegers(); disableReals(); arithOnlyLinear(); p += 3; } else if(!strncmp(p, "LRA", 3)) { disableIntegers(); enableReals(); arithOnlyLinear(); p += 3; } else if(!strncmp(p, "LIRA", 4)) { enableIntegers(); enableReals(); arithOnlyLinear(); p += 4; } else if(!strncmp(p, "NIA", 3)) { enableIntegers(); disableReals(); arithNonLinear(); p += 3; } else if(!strncmp(p, "NRA", 3)) { disableIntegers(); enableReals(); arithNonLinear(); p += 3; } else if(!strncmp(p, "NIRA", 4)) { enableIntegers(); enableReals(); arithNonLinear(); p += 4; } } } if(*p != '\0') { stringstream err; err << "LogicInfo::setLogicString(): junk (\"" << p << "\") at end of logic string: " << logicString; IllegalArgument(logicString, err.str().c_str()); } // ensure a getLogic() returns the same thing as was set d_logicString = logicString; }
void LogicInfo::setLogicString(std::string logicString) { PrettyCheckArgument(!d_locked, *this, "This LogicInfo is locked, and cannot be modified"); for(TheoryId id = THEORY_FIRST; id < THEORY_LAST; ++id) { d_theories[id] = false;// ensure it's cleared } d_sharingTheories = 0; // Below, ONLY use enableTheory()/disableTheory() rather than // accessing d_theories[] directly. This makes sure to set up // sharing properly. enableTheory(THEORY_BUILTIN); enableTheory(THEORY_BOOL); const char* p = logicString.c_str(); if(*p == '\0') { // propositional logic only; we're done. } else if(!strcmp(p, "QF_SAT")) { // propositional logic only; we're done. p += 6; } else if(!strcmp(p, "SAT")) { // quantified Boolean formulas only; we're done. enableQuantifiers(); p += 3; } else if(!strcmp(p, "QF_ALL_SUPPORTED")) { // the "all theories included" logic, no quantifiers enableEverything(); disableQuantifiers(); arithNonLinear(); p += 16; } else if(!strcmp(p, "QF_ALL")) { // the "all theories included" logic, no quantifiers enableEverything(); disableQuantifiers(); arithNonLinear(); p += 6; } else if(!strcmp(p, "ALL_SUPPORTED")) { // the "all theories included" logic, with quantifiers enableEverything(); enableQuantifiers(); arithNonLinear(); p += 13; } else if(!strcmp(p, "ALL")) { // the "all theories included" logic, with quantifiers enableEverything(); enableQuantifiers(); arithNonLinear(); p += 3; } else if (!strcmp(p, "HORN")) { // the HORN logic enableEverything(); enableQuantifiers(); arithNonLinear(); p += 4; } else { if(!strncmp(p, "QF_", 3)) { disableQuantifiers(); p += 3; } else { enableQuantifiers(); } if(!strncmp(p, "AX", 2)) { enableTheory(THEORY_ARRAYS); p += 2; } else { if(*p == 'A') { enableTheory(THEORY_ARRAYS); ++p; } if(!strncmp(p, "UF", 2)) { enableTheory(THEORY_UF); p += 2; } if(!strncmp(p, "C", 1 )) { d_cardinalityConstraints = true; p += 1; } // allow BV or DT in either order if(!strncmp(p, "BV", 2)) { enableTheory(THEORY_BV); p += 2; } if(!strncmp(p, "FP", 2)) { enableTheory(THEORY_FP); p += 2; } if(!strncmp(p, "DT", 2)) { enableTheory(THEORY_DATATYPES); p += 2; } if(!d_theories[THEORY_BV] && !strncmp(p, "BV", 2)) { enableTheory(THEORY_BV); p += 2; } if(*p == 'S') { enableTheory(THEORY_STRINGS); ++p; } if(!strncmp(p, "IDL", 3)) { enableIntegers(); disableReals(); arithOnlyDifference(); p += 3; } else if(!strncmp(p, "RDL", 3)) { disableIntegers(); enableReals(); arithOnlyDifference(); p += 3; } else if(!strncmp(p, "IRDL", 4)) { // "IRDL" ?! --not very useful, but getLogicString() can produce // that string, so we really had better be able to read it back in. enableIntegers(); enableReals(); arithOnlyDifference(); p += 4; } else if(!strncmp(p, "LIA", 3)) { enableIntegers(); disableReals(); arithOnlyLinear(); p += 3; } else if(!strncmp(p, "LRA", 3)) { disableIntegers(); enableReals(); arithOnlyLinear(); p += 3; } else if(!strncmp(p, "LIRA", 4)) { enableIntegers(); enableReals(); arithOnlyLinear(); p += 4; } else if(!strncmp(p, "NIA", 3)) { enableIntegers(); disableReals(); arithNonLinear(); p += 3; } else if(!strncmp(p, "NRA", 3)) { disableIntegers(); enableReals(); arithNonLinear(); p += 3; if (*p == 'T') { arithTranscendentals(); p += 1; } } else if(!strncmp(p, "NIRA", 4)) { enableIntegers(); enableReals(); arithNonLinear(); p += 4; if (*p == 'T') { arithTranscendentals(); p += 1; } } if(!strncmp(p, "FS", 2)) { enableTheory(THEORY_SETS); p += 2; } if(!strncmp(p, "SEP", 3)) { enableTheory(THEORY_SEP); p += 3; } } } if (d_theories[THEORY_FP]) { // THEORY_BV is needed for bit-blasting. // We have to set this here rather than in expandDefinition as it // is possible to create variables without any theory specific // operations, so expandDefinition won't be called. enableTheory(THEORY_BV); } if(*p != '\0') { stringstream err; err << "LogicInfo::setLogicString(): "; if(p == logicString) { err << "cannot parse logic string: " << logicString; } else { err << "junk (\"" << p << "\") at end of logic string: " << logicString; } IllegalArgument(logicString, err.str().c_str()); } // ensure a getLogic() returns the same thing as was set d_logicString = logicString; }