commandsBegin = smt1_commands;
commandsEnd = smt1_commands + sizeof(smt1_commands) / sizeof(*smt1_commands);
break;
- case output::LANG_SMTLIB_V2_0:
- case output::LANG_SMTLIB_V2_5:
- case output::LANG_SMTLIB_V2_6:
- d_historyFilename = string(getenv("HOME")) + "/.cvc4_history_smtlib2";
- commandsBegin = smt2_commands;
- commandsEnd = smt2_commands + sizeof(smt2_commands) / sizeof(*smt2_commands);
- break;
case output::LANG_TPTP:
d_historyFilename = string(getenv("HOME")) + "/.cvc4_history_tptp";
commandsBegin = tptp_commands;
commandsEnd = tptp_commands + sizeof(tptp_commands) / sizeof(*tptp_commands);
break;
default:
- std::stringstream ss;
- ss << "internal error: unhandled language " << lang;
- throw Exception(ss.str());
+ if (language::isOutputLang_smt2(lang))
+ {
+ d_historyFilename = string(getenv("HOME")) + "/.cvc4_history_smtlib2";
+ commandsBegin = smt2_commands;
+ commandsEnd =
+ smt2_commands + sizeof(smt2_commands) / sizeof(*smt2_commands);
+ }
+ else
+ {
+ std::stringstream ss;
+ ss << "internal error: unhandled language " << lang;
+ throw Exception(ss.str());
+ }
}
d_usingReadline = true;
int err = ::read_history(d_historyFilename.c_str());
line += "\n";
goto restart;
} catch(ParserException& pe) {
- if(d_options.getOutputLanguage() == output::LANG_SMTLIB_V2_0 ||
- d_options.getOutputLanguage() == output::LANG_SMTLIB_V2_5 ||
- d_options.getOutputLanguage() == output::LANG_SMTLIB_V2_6) {
+ if (language::isOutputLang_smt2(d_options.getOutputLanguage()))
+ {
d_out << "(error \"" << pe << "\")" << endl;
} else {
d_out << pe << endl;
#ifdef CVC4_COMPETITION_MODE
*opts.getOut() << "unknown" << endl;
#endif
- if(opts.getOutputLanguage() == output::LANG_SMTLIB_V2_0 ||
- opts.getOutputLanguage() == output::LANG_SMTLIB_V2_5 ||
- opts.getOutputLanguage() == output::LANG_SMTLIB_V2_6) {
+ if (language::isOutputLang_smt2(opts.getOutputLanguage()))
+ {
*opts.getOut() << "(error \"" << e << "\")" << endl;
} else {
*opts.getErr() << "CVC4 Error:" << endl << e << endl;
namespace CVC4 {
namespace language {
+/** define the end points of smt2 languages */
+namespace input {
+Language LANG_SMTLIB_V2_END = LANG_SMTLIB_V2_6_1;
+}
+namespace output {
+Language LANG_SMTLIB_V2_END = LANG_SMTLIB_V2_6_1;
+}
+
+bool isInputLang_smt2(InputLanguage lang)
+{
+ return (lang >= input::LANG_SMTLIB_V2_0 && lang <= input::LANG_SMTLIB_V2_END)
+ || lang == input::LANG_Z3STR;
+}
+
+bool isOutputLang_smt2(OutputLanguage lang)
+{
+ return (lang >= output::LANG_SMTLIB_V2_0
+ && lang <= output::LANG_SMTLIB_V2_END)
+ || lang == output::LANG_Z3STR;
+}
+
+bool isInputLang_smt2_5(InputLanguage lang, bool exact)
+{
+ return exact ? lang == input::LANG_SMTLIB_V2_5
+ : (lang >= input::LANG_SMTLIB_V2_5
+ && lang <= input::LANG_SMTLIB_V2_END);
+}
+
+bool isOutputLang_smt2_5(OutputLanguage lang, bool exact)
+{
+ return exact ? lang == output::LANG_SMTLIB_V2_5
+ : (lang >= output::LANG_SMTLIB_V2_5
+ && lang <= output::LANG_SMTLIB_V2_END);
+}
+
+bool isInputLang_smt2_6(InputLanguage lang, bool exact)
+{
+ return exact ? lang == input::LANG_SMTLIB_V2_6
+ : (lang >= input::LANG_SMTLIB_V2_6
+ && lang <= input::LANG_SMTLIB_V2_END);
+}
+
+bool isOutputLang_smt2_6(OutputLanguage lang, bool exact)
+{
+ return exact ? lang == output::LANG_SMTLIB_V2_6
+ : (lang >= output::LANG_SMTLIB_V2_6
+ && lang <= output::LANG_SMTLIB_V2_END);
+}
+
InputLanguage toInputLanguage(OutputLanguage language) {
switch(language) {
case output::LANG_SMTLIB_V1:
case output::LANG_SMTLIB_V2_0:
case output::LANG_SMTLIB_V2_5:
case output::LANG_SMTLIB_V2_6:
+ case output::LANG_SMTLIB_V2_6_1:
case output::LANG_TPTP:
case output::LANG_CVC4:
case output::LANG_Z3STR:
case input::LANG_SMTLIB_V2_0:
case input::LANG_SMTLIB_V2_5:
case input::LANG_SMTLIB_V2_6:
+ case input::LANG_SMTLIB_V2_6_1:
case input::LANG_TPTP:
case input::LANG_CVC4:
case input::LANG_Z3STR:
} else if(language == "smtlib2.6" || language == "smt2.6" ||
language == "LANG_SMTLIB_V2_6") {
return output::LANG_SMTLIB_V2_6;
+ }
+ else if (language == "smtlib2.6.1" || language == "smt2.6.1"
+ || language == "LANG_SMTLIB_V2_6_1")
+ {
+ return output::LANG_SMTLIB_V2_6_1;
} else if(language == "tptp" || language == "LANG_TPTP") {
return output::LANG_TPTP;
} else if(language == "z3str" || language == "z3-str" ||
language == "smtlib2.6" || language == "smt2.6" ||
language == "LANG_SMTLIB_V2_6" || language == "LANG_SMTLIB_V2") {
return input::LANG_SMTLIB_V2_6;
+ }
+ else if (language == "smtlib2.6.1" || language == "smt2.6.1"
+ || language == "LANG_SMTLIB_V2_6_1")
+ {
+ return input::LANG_SMTLIB_V2_6_1;
} else if(language == "tptp" || language == "LANG_TPTP") {
return input::LANG_TPTP;
} else if(language == "z3str" || language == "z3-str" ||
namespace input {
-enum CVC4_PUBLIC Language {
+enum CVC4_PUBLIC Language
+{
// SPECIAL "NON-LANGUAGE" LANGUAGES HAVE ENUM VALUE < 0
/** Auto-detect the language */
LANG_SMTLIB_V2_6,
/** Backward-compatibility for enumeration naming */
LANG_SMTLIB_V2 = LANG_SMTLIB_V2_6,
+ /** The SMTLIB v2.6 input language, with support for the strings standard */
+ LANG_SMTLIB_V2_6_1,
/** The TPTP input language */
LANG_TPTP,
/** The CVC4 input language */
/** LANG_MAX is > any valid InputLanguage id */
LANG_MAX
-};/* enum Language */
+}; /* enum Language */
inline std::ostream& operator<<(std::ostream& out, Language lang) CVC4_PUBLIC;
inline std::ostream& operator<<(std::ostream& out, Language lang) {
case LANG_SMTLIB_V2_6:
out << "LANG_SMTLIB_V2_6";
break;
+ case LANG_SMTLIB_V2_6_1: out << "LANG_SMTLIB_V2_6_1"; break;
case LANG_TPTP:
out << "LANG_TPTP";
break;
namespace output {
-enum CVC4_PUBLIC Language {
+enum CVC4_PUBLIC Language
+{
// SPECIAL "NON-LANGUAGE" LANGUAGES HAVE ENUM VALUE < 0
/** Match the output language to the input language */
LANG_SMTLIB_V2_6 = input::LANG_SMTLIB_V2_6,
/** Backward-compatibility for enumeration naming */
LANG_SMTLIB_V2 = input::LANG_SMTLIB_V2,
+ /** The SMTLIB v2.6 output language */
+ LANG_SMTLIB_V2_6_1 = input::LANG_SMTLIB_V2_6_1,
/** The TPTP output language */
LANG_TPTP = input::LANG_TPTP,
/** The CVC4 output language */
/** LANG_MAX is > any valid OutputLanguage id */
LANG_MAX
-};/* enum Language */
+}; /* enum Language */
inline std::ostream& operator<<(std::ostream& out, Language lang) CVC4_PUBLIC;
inline std::ostream& operator<<(std::ostream& out, Language lang) {
case LANG_SMTLIB_V2_5:
out << "LANG_SMTLIB_V2_5";
break;
+ case LANG_SMTLIB_V2_6: out << "LANG_SMTLIB_V2_6"; break;
+ case LANG_SMTLIB_V2_6_1: out << "LANG_SMTLIB_V2_6_1"; break;
case LANG_TPTP:
out << "LANG_TPTP";
break;
namespace language {
+/** Is the language a variant of the smtlib version 2 language? */
+bool isInputLang_smt2(InputLanguage lang) CVC4_PUBLIC;
+bool isOutputLang_smt2(OutputLanguage lang) CVC4_PUBLIC;
+
+/**
+ * Is the language smtlib 2.5 or above? If exact=true, then this method returns
+ * false if the input language is not exactly SMT-LIB 2.6.
+ */
+bool isInputLang_smt2_5(InputLanguage lang, bool exact = false) CVC4_PUBLIC;
+bool isOutputLang_smt2_5(OutputLanguage lang, bool exact = false) CVC4_PUBLIC;
+/**
+ * Is the language smtlib 2.6 or above? If exact=true, then this method returns
+ * false if the input language is not exactly SMT-LIB 2.6.
+ */
+bool isInputLang_smt2_6(InputLanguage lang, bool exact = false) CVC4_PUBLIC;
+bool isOutputLang_smt2_6(OutputLanguage lang, bool exact = false) CVC4_PUBLIC;
+
InputLanguage toInputLanguage(OutputLanguage language) CVC4_PUBLIC;
OutputLanguage toOutputLanguage(InputLanguage language) CVC4_PUBLIC;
InputLanguage toInputLanguage(std::string language) CVC4_PUBLIC;
%rename(INPUT_LANG_SMTLIB_V2_0) CVC4::language::input::LANG_SMTLIB_V2_0;
%rename(INPUT_LANG_SMTLIB_V2_5) CVC4::language::input::LANG_SMTLIB_V2_5;
%rename(INPUT_LANG_SMTLIB_V2_6) CVC4::language::input::LANG_SMTLIB_V2_6;
+%rename(INPUT_LANG_SMTLIB_V2_6_1) CVC4::language::input::LANG_SMTLIB_V2_6_1;
%rename(INPUT_LANG_TPTP) CVC4::language::input::LANG_TPTP;
%rename(INPUT_LANG_CVC4) CVC4::language::input::LANG_CVC4;
%rename(INPUT_LANG_MAX) CVC4::language::input::LANG_MAX;
%rename(OUTPUT_LANG_SMTLIB_V2_0) CVC4::language::output::LANG_SMTLIB_V2_0;
%rename(OUTPUT_LANG_SMTLIB_V2_5) CVC4::language::output::LANG_SMTLIB_V2_5;
%rename(OUTPUT_LANG_SMTLIB_V2_6) CVC4::language::output::LANG_SMTLIB_V2_6;
+%rename(OUTPUT_LANG_SMTLIB_V2_6_1) CVC4::language::output::LANG_SMTLIB_V2_6_1;
%rename(OUTPUT_LANG_TPTP) CVC4::language::output::LANG_TPTP;
%rename(OUTPUT_LANG_CVC4) CVC4::language::output::LANG_CVC4;
%rename(OUTPUT_LANG_AST) CVC4::language::output::LANG_AST;
sense of the option.\n\
";
-static const std::string languageDescription = "\
+static const std::string languageDescription =
+ "\
Languages currently supported as arguments to the -L / --lang option:\n\
auto attempt to automatically determine language\n\
cvc4 | presentation | pl CVC4 presentation language\n\
smt2.0 | smtlib2 | smtlib2.0 SMT-LIB format 2.0\n\
smt2.5 | smtlib2.5 SMT-LIB format 2.5\n\
smt2.6 | smtlib2.6 SMT-LIB format 2.6\n\
+ smt2.6.1 | smtlib2.6.1 SMT-LIB format 2.6 with support for the strings standard\n\
tptp TPTP format (cnf and fof)\n\
sygus SyGuS format\n\
\n\
smt2.0 | smtlib2.0 | smtlib2 SMT-LIB format 2.0\n\
smt2.5 | smtlib2.5 SMT-LIB format 2.5\n\
smt2.6 | smtlib2.6 SMT-LIB format 2.6\n\
+ smt2.6.1 | smtlib2.6.1 SMT-LIB format 2.6 with support for the strings standard\n\
tptp TPTP format\n\
z3str SMT-LIB 2.0 with Z3-str string constraints\n\
ast internal format (simple syntax trees)\n\
input = new Smt1Input(inputStream);
break;
- case LANG_SMTLIB_V2_0:
- case LANG_SMTLIB_V2_5:
- case LANG_SMTLIB_V2_6:
- input = new Smt2Input(inputStream, lang);
- break;
-
case LANG_SYGUS:
input = new SygusInput(inputStream);
break;
break;
default:
- std::stringstream ss;
- ss << "internal error: unhandled language " << lang << " in AntlrInput::newInput";
- throw InputStreamException(ss.str());
+ if (language::isInputLang_smt2(lang))
+ {
+ input = new Smt2Input(inputStream, lang);
+ }
+ else
+ {
+ std::stringstream ss;
+ ss << "internal error: unhandled language " << lang
+ << " in AntlrInput::newInput";
+ throw InputStreamException(ss.str());
+ }
}
return input;
case language::input::LANG_SMTLIB_V1:
parser = new Smt1(d_exprManager, input, d_strictMode, d_parseOnly);
break;
- case language::input::LANG_SMTLIB_V2_0:
- case language::input::LANG_SMTLIB_V2_5:
- case language::input::LANG_SMTLIB_V2_6:
- parser = new Smt2(d_exprManager, input, d_strictMode, d_parseOnly);
- break;
case language::input::LANG_SYGUS:
parser = new Smt2(d_exprManager, input, d_strictMode, d_parseOnly);
break;
parser = new Tptp(d_exprManager, input, d_strictMode, d_parseOnly);
break;
default:
- parser = new Parser(d_exprManager, input, d_strictMode, d_parseOnly);
+ if (language::isInputLang_smt2(d_lang))
+ {
+ parser = new Smt2(d_exprManager, input, d_strictMode, d_parseOnly);
+ }
+ else
+ {
+ parser = new Parser(d_exprManager, input, d_strictMode, d_parseOnly);
+ }
break;
}
GET_UNSAT_ASSUMPTIONS_TOK : 'get-unsat-assumptions';
GET_UNSAT_CORE_TOK : 'get-unsat-core';
EXIT_TOK : 'exit';
-RESET_TOK : { PARSER_STATE->v2_5(false) }? 'reset';
+RESET_TOK : { PARSER_STATE->v2_5() }? 'reset';
RESET_ASSERTIONS_TOK : 'reset-assertions';
ITE_TOK : 'ite';
LET_TOK : { !PARSER_STATE->sygus() }? 'let';
* will be part of the token text. Use the str[] parser rule instead.
*/
STRING_LITERAL_2_5
- : { PARSER_STATE->v2_5(false) || PARSER_STATE->sygus() }?=>
+ : { PARSER_STATE->v2_5() || PARSER_STATE->sygus() }?=>
'"' (~('"') | '""')* '"'
;
addOperator(kind::STRING_STRREPL, "str.replace" );
addOperator(kind::STRING_PREFIX, "str.prefixof" );
addOperator(kind::STRING_SUFFIX, "str.suffixof" );
- addOperator(kind::STRING_ITOS, "int.to.str" );
- addOperator(kind::STRING_STOI, "str.to.int" );
- addOperator(kind::STRING_IN_REGEXP, "str.in.re");
- addOperator(kind::STRING_TO_REGEXP, "str.to.re");
+ // at the moment, we only use this syntax for smt2.6.1
+ if (getInput()->getLanguage() == language::input::LANG_SMTLIB_V2_6_1)
+ {
+ addOperator(kind::STRING_ITOS, "str.from-int");
+ addOperator(kind::STRING_STOI, "str.to-int");
+ addOperator(kind::STRING_IN_REGEXP, "str.in-re");
+ addOperator(kind::STRING_TO_REGEXP, "str.to-re");
+ }
+ else
+ {
+ addOperator(kind::STRING_ITOS, "int.to.str");
+ addOperator(kind::STRING_STOI, "str.to.int");
+ addOperator(kind::STRING_IN_REGEXP, "str.in.re");
+ addOperator(kind::STRING_TO_REGEXP, "str.to.re");
+ }
+
addOperator(kind::REGEXP_CONCAT, "re.++");
addOperator(kind::REGEXP_UNION, "re.union");
addOperator(kind::REGEXP_INTER, "re.inter");
bool v2_0() const {
return getInput()->getLanguage() == language::input::LANG_SMTLIB_V2_0;
}
- // 2.6 is a superset of 2.5, use exact=false to query whether smt lib 2.5 or above
- bool v2_5( bool exact = true ) const {
- return exact ? getInput()->getLanguage() == language::input::LANG_SMTLIB_V2_5 :
- ( getInput()->getLanguage() >= language::input::LANG_SMTLIB_V2_5 &&
- getInput()->getLanguage() <= language::input::LANG_SMTLIB_V2 );
+ /**
+ * Are we using smtlib 2.5 or above? If exact=true, then this method returns
+ * false if the input language is not exactly SMT-LIB 2.5.
+ */
+ bool v2_5(bool exact = false) const
+ {
+ return language::isInputLang_smt2_5(getInput()->getLanguage(), exact);
}
- bool v2_6() const {
- return getInput()->getLanguage() == language::input::LANG_SMTLIB_V2_6;
+ /**
+ * Are we using smtlib 2.6 or above? If exact=true, then this method returns
+ * false if the input language is not exactly SMT-LIB 2.6.
+ */
+ bool v2_6(bool exact = false) const
+ {
+ return language::isInputLang_smt2_6(getInput()->getLanguage(), exact);
}
bool sygus() const {
return getInput()->getLanguage() == language::input::LANG_SYGUS;
}
void Smt2Input::setLanguage(InputLanguage lang) {
- CheckArgument(lang == language::input::LANG_SMTLIB_V2_0 ||
- lang == language::input::LANG_SMTLIB_V2_5 ||
- lang == language::input::LANG_SMTLIB_V2_6, lang);
+ CheckArgument(language::isInputLang_smt2(lang), lang);
d_lang = lang;
}
return unique_ptr<Printer>(
new printer::smt2::Smt2Printer(printer::smt2::smt2_6_variant));
+ case LANG_SMTLIB_V2_6_1:
+ return unique_ptr<Printer>(
+ new printer::smt2::Smt2Printer(printer::smt2::smt2_6_1_variant));
+
case LANG_TPTP:
return unique_ptr<Printer>(new printer::tptp::TptpPrinter());
static OutputLanguage variantToLanguage(Variant v);
-static string smtKindString(Kind k);
+static string smtKindString(Kind k, Variant v);
+
+/** returns whether the variant is smt-lib 2.6 or greater */
+bool isVariant_2_6(Variant v)
+{
+ return v == smt2_6_variant || v == smt2_6_1_variant;
+}
static void printBvParameterizedOp(std::ostream& out, TNode n);
static void printFpParameterizedOp(std::ostream& out, TNode n);
out << (n.getConst<bool>() ? "true" : "false");
break;
case kind::BUILTIN:
- out << smtKindString(n.getConst<Kind>());
+ out << smtKindString(n.getConst<Kind>(), d_variant);
break;
case kind::CHAIN_OP:
- out << smtKindString(n.getConst<Chain>().getOperator());
+ out << smtKindString(n.getConst<Chain>().getOperator(), d_variant);
break;
case kind::CONST_RATIONAL: {
const Rational& r = n.getConst<Rational>();
if (force_nt.isReal())
{
out << "(" << smtKindString(force_nt.isInteger() ? kind::TO_INTEGER
- : kind::TO_REAL)
+ : kind::TO_REAL,
+ d_variant)
<< " ";
toStream(out, n, toDepth, types, TypeNode::null());
out << ")";
// builtin theory
case kind::APPLY: break;
case kind::EQUAL:
- case kind::DISTINCT:
- out << smtKindString(k) << " ";
+ case kind::DISTINCT:
+ out << smtKindString(k, d_variant) << " ";
parametricTypeChildren = true;
break;
case kind::CHAIN: break;
case kind::IMPLIES:
case kind::OR:
case kind::XOR:
- case kind::ITE: out << smtKindString(k) << " "; break;
+ case kind::ITE:
+ out << smtKindString(k, d_variant) << " ";
+ break;
- // uf theory
+ // uf theory
case kind::APPLY_UF: typeChildren = true; break;
// higher-order
case kind::HO_APPLY: break;
case kind::LAMBDA:
- out << smtKindString(k) << " ";
+ out << smtKindString(k, d_variant) << " ";
break;
// arith theory
case kind::TO_REAL:
case kind::POW:
parametricTypeChildren = true;
- out << smtKindString(k) << " ";
+ out << smtKindString(k, d_variant) << " ";
break;
case kind::DIVISIBLE:
case kind::STORE: typeChildren = true;
case kind::PARTIAL_SELECT_0:
case kind::PARTIAL_SELECT_1:
- case kind::ARRAY_TYPE: out << smtKindString(k) << " "; break;
+ case kind::ARRAY_TYPE:
+ out << smtKindString(k, d_variant) << " ";
+ break;
- // string theory
+ // string theory
case kind::STRING_CONCAT:
if(d_variant == z3str_variant) {
out << "Concat ";
out << ")";
return;
}
- out << "str.in.re ";
+ out << smtKindString(k, d_variant) << " ";
break;
}
- case kind::STRING_LENGTH: out << (d_variant == z3str_variant ? "Length " : "str.len "); break;
- case kind::STRING_SUBSTR: out << "str.substr "; break;
- case kind::STRING_CHARAT: out << "str.at "; break;
- case kind::STRING_STRCTN: out << "str.contains "; break;
- case kind::STRING_STRIDOF: out << "str.indexof "; break;
- case kind::STRING_STRREPL: out << "str.replace "; break;
- case kind::STRING_PREFIX: out << "str.prefixof "; break;
- case kind::STRING_SUFFIX: out << "str.suffixof "; break;
- case kind::STRING_ITOS: out << "int.to.str "; break;
- case kind::STRING_STOI: out << "str.to.int "; break;
- case kind::STRING_TO_REGEXP: out << "str.to.re "; break;
- case kind::REGEXP_CONCAT: out << "re.++ "; break;
- case kind::REGEXP_UNION: out << "re.union "; break;
- case kind::REGEXP_INTER: out << "re.inter "; break;
- case kind::REGEXP_STAR: out << "re.* "; break;
- case kind::REGEXP_PLUS: out << "re.+ "; break;
- case kind::REGEXP_OPT: out << "re.opt "; break;
- case kind::REGEXP_RANGE: out << "re.range "; break;
- case kind::REGEXP_LOOP: out << "re.loop "; break;
- case kind::REGEXP_EMPTY: out << "re.nostr "; break;
- case kind::REGEXP_SIGMA: out << "re.allchar "; break;
+ case kind::STRING_LENGTH:
+ case kind::STRING_SUBSTR:
+ case kind::STRING_CHARAT:
+ case kind::STRING_STRCTN:
+ case kind::STRING_STRIDOF:
+ case kind::STRING_STRREPL:
+ case kind::STRING_PREFIX:
+ case kind::STRING_SUFFIX:
+ case kind::STRING_ITOS:
+ case kind::STRING_STOI:
+ case kind::STRING_TO_REGEXP:
+ case kind::REGEXP_CONCAT:
+ case kind::REGEXP_UNION:
+ case kind::REGEXP_INTER:
+ case kind::REGEXP_STAR:
+ case kind::REGEXP_PLUS:
+ case kind::REGEXP_OPT:
+ case kind::REGEXP_RANGE:
+ case kind::REGEXP_LOOP:
+ case kind::REGEXP_EMPTY:
+ case kind::REGEXP_SIGMA: out << smtKindString(k, d_variant) << " "; break;
case kind::CARDINALITY_CONSTRAINT: out << "fmf.card "; break;
case kind::CARDINALITY_VALUE: out << "fmf.card.val "; break;
case kind::TRANSPOSE:
case kind::TCLOSURE:
parametricTypeChildren = true;
- out << smtKindString(k) << " ";
+ out << smtKindString(k, d_variant) << " ";
break;
case kind::MEMBER: typeChildren = true;
case kind::SET_TYPE:
case kind::SINGLETON:
- case kind::COMPLEMENT:out << smtKindString(k) << " "; break;
+ case kind::COMPLEMENT: out << smtKindString(k, d_variant) << " "; break;
case kind::UNIVERSE_SET:out << "(as univset " << n.getType() << ")";break;
// fp theory
case kind::FLOATINGPOINT_ISNEG:
case kind::FLOATINGPOINT_ISPOS:
case kind::FLOATINGPOINT_TO_REAL:
- out << smtKindString(k) << ' '; break;
+ out << smtKindString(k, d_variant) << ' ';
+ break;
case kind::FLOATINGPOINT_TO_FP_IEEE_BITVECTOR:
case kind::FLOATINGPOINT_TO_FP_FLOATINGPOINT:
case kind::SEP_EMP:
case kind::SEP_PTO:
case kind::SEP_STAR:
- case kind::SEP_WAND: out << smtKindString(k) << " "; break;
+ case kind::SEP_WAND: out << smtKindString(k, d_variant) << " "; break;
case kind::SEP_NIL:
out << "(as sep.nil " << n.getType() << ")";
}else if( n.getKind()==kind::APPLY_TESTER ){
unsigned cindex = Datatype::indexOf(n.getOperator().toExpr());
const Datatype& dt = Datatype::datatypeOf(n.getOperator().toExpr());
- if( d_variant==smt2_6_variant ){
+ if (isVariant_2_6(d_variant))
+ {
out << "(_ is ";
toStream(out, Node::fromExpr(dt[cindex].getConstructor()), toDepth < 0 ? toDepth : toDepth - 1, types, TypeNode::null());
out << ")";
if(forceBinary && i < n.getNumChildren() - 1) {
// not going to work properly for parameterized kinds!
Assert(n.getMetaKind() != kind::metakind::PARAMETERIZED);
- out << " (" << smtKindString(n.getKind()) << ' ';
+ out << " (" << smtKindString(n.getKind(), d_variant) << ' ';
parens << ')';
++c;
} else {
}
}/* Smt2Printer::toStream(TNode) */
-static string smtKindString(Kind k)
+static string smtKindString(Kind k, Variant v)
{
switch(k) {
// builtin theory
//string theory
case kind::STRING_CONCAT: return "str.++";
- case kind::STRING_LENGTH: return "str.len";
+ case kind::STRING_LENGTH: return v == z3str_variant ? "Length" : "str.len";
case kind::STRING_SUBSTR: return "str.substr" ;
case kind::STRING_STRCTN: return "str.contains" ;
case kind::STRING_CHARAT: return "str.at" ;
case kind::STRING_STRREPL: return "str.replace" ;
case kind::STRING_PREFIX: return "str.prefixof" ;
case kind::STRING_SUFFIX: return "str.suffixof" ;
- case kind::STRING_ITOS: return "int.to.str" ;
- case kind::STRING_STOI: return "str.to.int" ;
- case kind::STRING_IN_REGEXP: return "str.in.re";
- case kind::STRING_TO_REGEXP: return "str.to.re";
+ case kind::STRING_ITOS:
+ return v == smt2_6_1_variant ? "str.from-int" : "int.to.str";
+ case kind::STRING_STOI:
+ return v == smt2_6_1_variant ? "str.to-int" : "str.to.int";
+ case kind::STRING_IN_REGEXP:
+ return v == smt2_6_1_variant ? "str.in-re" : "str.in.re";
+ case kind::STRING_TO_REGEXP:
+ return v == smt2_6_1_variant ? "str.to-re" : "str.to.re";
case kind::REGEXP_CONCAT: return "re.++";
case kind::REGEXP_UNION: return "re.union";
case kind::REGEXP_INTER: return "re.inter";
const std::vector<Node>* type_refs = model.getRepSet()->getTypeRepsOrNull(tn);
if (options::modelUninterpDtEnum() && tn.isSort() && type_refs != nullptr)
{
- if (variant == smt2_6_variant)
+ if (isVariant_2_6(variant))
{
out << "(declare-datatypes ((" << command.getSymbol() << " 0)) (";
}
out << "co";
}
out << "datatypes";
- if (v == smt2_6_variant)
+ if (isVariant_2_6(v))
{
out << " (";
for (vector<DatatypeType>::const_iterator i = datatypes.begin(),
namespace printer {
namespace smt2 {
-enum Variant {
+enum Variant
+{
no_variant,
- smt2_0_variant, // old-style 2.0 syntax, when it makes a difference
- smt2_6_variant, // new-style 2.6 syntax, when it makes a difference
- z3str_variant, // old-style 2.0 and also z3str syntax
- sygus_variant // variant for sygus
-};/* enum Variant */
-
+ smt2_0_variant, // old-style 2.0 syntax, when it makes a difference
+ smt2_6_variant, // new-style 2.6 syntax, when it makes a difference
+ smt2_6_1_variant, // new-style 2.6 syntax, when it makes a difference, with
+ // support for the string standard
+ z3str_variant, // old-style 2.0 and also z3str syntax
+ sygus_variant // variant for sygus
+}; /* enum Variant */
class Smt2Printer : public CVC4::Printer {
public:
Smt2Printer(Variant variant = no_variant) : d_variant(variant) { }
// Language-based defaults
if (!options::bitvectorDivByZeroConst.wasSetByUser())
{
- options::bitvectorDivByZeroConst.set(options::inputLanguage()
- == language::input::LANG_SMTLIB_V2_6);
+ options::bitvectorDivByZeroConst.set(
+ language::isInputLang_smt2_6(options::inputLanguage()));
}
if (options::inputLanguage() == language::input::LANG_SYGUS)
{
d_filename = value.getValue();
return;
} else if(key == "smt-lib-version") {
+ language::input::Language ilang = language::input::LANG_AUTO;
if( (value.isInteger() && value.getIntegerValue() == Integer(2)) ||
(value.isRational() && value.getRationalValue() == Rational(2)) ||
value.getValue() == "2" ||
value.getValue() == "2.0" ) {
- options::inputLanguage.set(language::input::LANG_SMTLIB_V2_0);
-
- // supported SMT-LIB version
- if(!options::outputLanguage.wasSetByUser() &&
- ( options::outputLanguage() == language::output::LANG_SMTLIB_V2_5 || options::outputLanguage() == language::output::LANG_SMTLIB_V2_6 )) {
- options::outputLanguage.set(language::output::LANG_SMTLIB_V2_0);
- *options::out() << language::SetLanguage(language::output::LANG_SMTLIB_V2_0);
- }
- return;
+ ilang = language::input::LANG_SMTLIB_V2_0;
} else if( (value.isRational() && value.getRationalValue() == Rational(5, 2)) ||
value.getValue() == "2.5" ) {
- options::inputLanguage.set(language::input::LANG_SMTLIB_V2_5);
-
- // supported SMT-LIB version
- if(!options::outputLanguage.wasSetByUser() &&
- options::outputLanguage() == language::output::LANG_SMTLIB_V2_0) {
- options::outputLanguage.set(language::output::LANG_SMTLIB_V2_5);
- *options::out() << language::SetLanguage(language::output::LANG_SMTLIB_V2_5);
- }
- return;
+ ilang = language::input::LANG_SMTLIB_V2_5;
} else if( (value.isRational() && value.getRationalValue() == Rational(13, 5)) ||
value.getValue() == "2.6" ) {
- options::inputLanguage.set(language::input::LANG_SMTLIB_V2_6);
-
- // supported SMT-LIB version
- if(!options::outputLanguage.wasSetByUser() &&
- options::outputLanguage() == language::output::LANG_SMTLIB_V2_0) {
- options::outputLanguage.set(language::output::LANG_SMTLIB_V2_6);
- *options::out() << language::SetLanguage(language::output::LANG_SMTLIB_V2_6);
+ ilang = language::input::LANG_SMTLIB_V2_6;
+ }
+ else if (value.getValue() == "2.6.1")
+ {
+ ilang = language::input::LANG_SMTLIB_V2_6_1;
+ }
+ else
+ {
+ Warning() << "Warning: unsupported smt-lib-version: " << value << endl;
+ throw UnrecognizedOptionException();
+ }
+ options::inputLanguage.set(ilang);
+ // also update the output language
+ if (!options::outputLanguage.wasSetByUser())
+ {
+ language::output::Language olang = language::toOutputLanguage(ilang);
+ if (options::outputLanguage() != olang)
+ {
+ options::outputLanguage.set(olang);
+ *options::out() << language::SetLanguage(olang);
}
- return;
}
- Warning() << "Warning: unsupported smt-lib-version: " << value << endl;
- throw UnrecognizedOptionException();
+ return;
} else if(key == "status") {
string s;
if(value.isAtom()) {
void Result::toStream(std::ostream& out, OutputLanguage language) const {
switch (language) {
- case language::output::LANG_SMTLIB_V2_0:
- case language::output::LANG_SMTLIB_V2_5:
- case language::output::LANG_SMTLIB_V2_6:
case language::output::LANG_SYGUS:
- case language::output::LANG_Z3STR:
toStreamSmt2(out);
break;
case language::output::LANG_TPTP:
toStreamTptp(out);
break;
- case language::output::LANG_AST:
- case language::output::LANG_AUTO:
- case language::output::LANG_CVC3:
- case language::output::LANG_CVC4:
- case language::output::LANG_MAX:
- case language::output::LANG_SMTLIB_V1:
default:
- toStreamDefault(out);
+ if (language::isOutputLang_smt2(language))
+ {
+ toStreamSmt2(out);
+ }
+ else
+ {
+ toStreamDefault(out);
+ }
break;
};
}
bool SExpr::languageQuotesKeywords(OutputLanguage language) {
switch (language) {
case language::output::LANG_SMTLIB_V1:
- case language::output::LANG_SMTLIB_V2_0:
- case language::output::LANG_SMTLIB_V2_5:
- case language::output::LANG_SMTLIB_V2_6:
case language::output::LANG_SYGUS:
case language::output::LANG_TPTP:
- case language::output::LANG_Z3STR:
return true;
case language::output::LANG_AST:
case language::output::LANG_CVC3:
case language::output::LANG_CVC4:
- default:
- return false;
+ default: return language::isOutputLang_smt2(language);
};
}
regress0/strings/norn-simp-rew.smt2 \
regress0/strings/repl-rewrites2.smt2 \
regress0/strings/rewrites-v2.smt2 \
+ regress0/strings/std2.6.1.smt2 \
regress0/strings/str003.smt2 \
regress0/strings/str004.smt2 \
regress0/strings/str005.smt2 \
-(set-logic ASLIA)
(set-info :smt-lib-version 2.0)
+(set-logic ASLIA)
(set-option :strings-exp true)
(set-info :status sat)
(define-fun strinre ((?s String)) Bool (str.in.re ?s (re.union re.nostr (re.++ (str.to.re "") (str.to.re "") (re.union re.nostr (re.range "*" ",") (str.to.re "\t") (re.range "*" "|") ) (re.+ (re.union re.nostr (re.++ (str.to.re "") (str.to.re "") (re.loop re.allchar 6 ) (re.opt (re.union re.nostr (re.++ (str.to.re "") (str.to.re "") ) ) ) ) ) ) ) ) ) )
(assert (not (strinre "6O\1\127\n?")))
-(check-sat)
\ No newline at end of file
+(check-sat)
+(set-info :smt-lib-version 2.5)
(set-logic ALL_SUPPORTED)
(set-info :status unsat)
(set-option :strings-exp true)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-option :strings-exp true)
(set-info :status sat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_SLIA)
(set-option :strings-exp true)
(set-info :status unsat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_SLIA)
(set-option :strings-exp true)
(set-info :status unsat)
(assert (str.in.re var_8 (re.* (re.range "a" "u"))))
(assert (str.in.re var_7 (re.* (re.range "a" "u"))))
(assert (not (str.in.re (str.++ "b" var_7 ) (re.* (re.range "a" "u")))))
-(check-sat)
\ No newline at end of file
+(check-sat)
; COMMAND-LINE: --strings-exp
; EXPECT: unsat
+(set-info :smt-lib-version 2.5)
(set-logic SLIA)
(set-info :status unsat)
(declare-fun x () String)
--- /dev/null
+; COMMAND-LINE: --strings-exp --lang=smt2.6.1
+; EXPECT: sat
+(set-logic QF_UFSLIA)
+(set-info :status sat)
+(declare-fun x () String)
+(assert (str.in-re x (str.to-re "A")))
+(declare-fun y () Int)
+(assert (= (str.to-int (str.from-int y)) y))
+(check-sat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-info :status sat)
(set-option :strings-exp true)
;should be -1
(assert (= j (str.to.int "-783914785582390527685649")))
-(check-sat)
\ No newline at end of file
+(check-sat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-option :strings-exp true)
(set-info :status unsat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-option :strings-exp true)
(set-info :status sat)
+(set-info :smt-lib-version 2.5)
(set-logic UFDTSLIA)
(set-info :status sat)
-(declare-datatypes ((T 0)) ( ((TC (TCb String))) ) )
+(declare-datatypes () ((T (TC (TCb String)))))
(declare-fun root5 () String)
(declare-fun root6 () T)
; COMMAND-LINE: --incremental --strings-exp
; EXPECT: sat
+(set-info :smt-lib-version 2.5)
(set-logic ALL)
(set-info :status sat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-option :strings-exp true)
(set-option :strings-fmf true)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-option :strings-exp true)
(set-option :strings-fmf true)
+(set-info :smt-lib-version 2.5)
(set-logic ALL)
(set-option :strings-exp true)
(set-info :status sat)
-(declare-datatype Val (
+(declare-datatypes () ((Val
(Str (str String))
- (Num (num Int))))
+ (Num (num Int)))))
(declare-const var0 Val)
(assert (=> (is-Str var0) (distinct (str.to.int (str var0)) (- 1))))
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-info :status sat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_SLIA)
(set-option :strings-exp true)
(set-info :status sat)
(assert (str.in.re var_4 (re.* (re.range "a" "u"))))
(assert (str.in.re var_3 (re.* (re.range "a" "u"))))
(assert (<= 0 (str.len var_4)))
-(check-sat)
\ No newline at end of file
+(check-sat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_SLIA)
(set-info :status unsat)
(set-option :strings-exp true)
(assert (str.in.re var_4 (re.++ (re.* (str.to.re "a")) (re.++ (str.to.re "b") (re.* (str.to.re "b"))))))
(assert (not (str.in.re (str.++ "a" var_4 "b" ) (re.++ (re.* (str.to.re "a")) (re.++ (str.to.re "b") (re.* (str.to.re "b")))))))
(assert (and (<= 0 (str.len var_4)) (not (not (exists ((v Int)) (= (* v 2 ) (+ (str.len var_4) 2 )))))))
-(check-sat)
\ No newline at end of file
+(check-sat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-info :status sat)
(set-option :strings-exp true)
+(set-info :smt-lib-version 2.5)
(set-logic QF_SLIA)
(set-option :strings-exp true)
(set-info :status sat)
(assert (str.in.re var_3 (re.* (re.range "a" "u"))))
(assert (str.in.re var_3 (re.* (str.to.re "a"))))
(assert (<= 0 (str.len var_4)))
-(check-sat)
\ No newline at end of file
+(check-sat)
+(set-info :smt-lib-version 2.5)\r
(set-logic SLIA)\r
(set-info :status sat)\r
(set-info :smt-lib-version 2.5)\r
(declare-fun s1() String)\r
(declare-fun s2() String)\r
(assert (and true (stringEval s0) (stringEval s1) (distinct s0 s1) (stringEval s2) (distinct s0 s2) (distinct s1 s2) ) )\r
-(check-sat)
\ No newline at end of file
+(check-sat)\r
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-info :status sat)
(set-option :strings-exp true)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-info :status sat)
(set-option :strings-exp true)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-info :status sat)
(set-option :strings-exp true)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-option :strings-exp true)
(set-info :status sat)
+(set-info :smt-lib-version 2.5)
(set-logic ALL)
(set-option :strings-exp true)
(set-info :status sat)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-info :status sat)
(set-option :strings-exp true)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-info :status sat)
(set-option :strings-exp true)
+(set-info :smt-lib-version 2.5)
(set-logic QF_S)
(set-option :strings-exp true)
(set-info :status unsat)