This PR is a step towards removing SExpr class. It replaces SExpr with std::string for set-info and set-option commands.
void AstPrinter::toStreamCmdSetInfo(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const
+ const std::string& value) const
{
- out << "SetInfo(" << flag << ", " << sexpr << ')' << std::endl;
+ out << "SetInfo(" << flag << ", " << value << ')' << std::endl;
}
void AstPrinter::toStreamCmdGetInfo(std::ostream& out,
void AstPrinter::toStreamCmdSetOption(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const
+ const std::string& value) const
{
- out << "SetOption(" << flag << ", " << sexpr << ')' << std::endl;
+ out << "SetOption(" << flag << ", " << value << ')' << std::endl;
}
void AstPrinter::toStreamCmdGetOption(std::ostream& out,
/** Print set-info command */
void toStreamCmdSetInfo(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const override;
+ const std::string& value) const override;
/** Print get-info command */
void toStreamCmdGetInfo(std::ostream& out,
/** Print set-option command */
void toStreamCmdSetOption(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const override;
+ const std::string& value) const override;
/** Print get-option command */
void toStreamCmdGetOption(std::ostream& out,
void CvcPrinter::toStreamCmdSetInfo(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const
+ const std::string& value) const
{
- out << "% (set-info " << flag << ' ';
- OutputLanguage language =
- d_cvc3Mode ? language::output::LANG_CVC3 : language::output::LANG_CVC4;
- SExpr::toStream(out, sexpr, language);
- out << ')' << std::endl;
+ out << "% (set-info " << flag << ' ' << value << ')' << std::endl;
}
void CvcPrinter::toStreamCmdGetInfo(std::ostream& out,
void CvcPrinter::toStreamCmdSetOption(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const
+ const std::string& value) const
{
- out << "OPTION \"" << flag << "\" ";
- SExpr::toStream(out, sexpr, language::output::LANG_CVC4);
- out << ';' << std::endl;
+ out << "OPTION \"" << flag << "\" " << value << ';' << std::endl;
}
void CvcPrinter::toStreamCmdGetOption(std::ostream& out,
/** Print set-info command */
void toStreamCmdSetInfo(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const override;
+ const std::string& value) const override;
/** Print get-info command */
void toStreamCmdGetInfo(std::ostream& out,
/** Print set-option command */
void toStreamCmdSetOption(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const override;
+ const std::string& value) const override;
/** Print get-option command */
void toStreamCmdGetOption(std::ostream& out,
void Printer::toStreamCmdSetInfo(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const
+ const std::string& value) const
{
printUnknownCommand(out, "set-info");
}
void Printer::toStreamCmdSetOption(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const
+ const std::string& value) const
{
printUnknownCommand(out, "set-option");
}
/** Print set-info command */
virtual void toStreamCmdSetInfo(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const;
+ const std::string& value) const;
/** Print get-info command */
virtual void toStreamCmdGetInfo(std::ostream& out,
/** Print set-option command */
virtual void toStreamCmdSetOption(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const;
+ const std::string& value) const;
/** Print get-option command */
virtual void toStreamCmdGetOption(std::ostream& out,
namespace printer {
namespace smt2 {
-static OutputLanguage variantToLanguage(Variant v);
-
/** returns whether the variant is smt-lib 2.6 or greater */
bool isVariant_2_6(Variant v) { return v == smt2_6_variant; }
void Smt2Printer::toStreamCmdSetInfo(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const
+ const std::string& value) const
{
- out << "(set-info :" << flag << ' ';
- SExpr::toStream(out, sexpr, variantToLanguage(d_variant));
- out << ')' << std::endl;
+ out << "(set-info :" << flag << ' ' << value << ')' << std::endl;
}
void Smt2Printer::toStreamCmdGetInfo(std::ostream& out,
void Smt2Printer::toStreamCmdSetOption(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const
+ const std::string& value) const
{
- out << "(set-option :" << flag << ' ';
- SExpr::toStream(out, sexpr, language::output::LANG_SMTLIB_V2_5);
- out << ')' << std::endl;
+ out << "(set-option :" << flag << ' ' << value << ')' << std::endl;
}
void Smt2Printer::toStreamCmdGetOption(std::ostream& out,
return false;
}
-static OutputLanguage variantToLanguage(Variant variant)
-{
- switch(variant) {
- case smt2_0_variant:
- return language::output::LANG_SMTLIB_V2_0;
- case no_variant:
- default: return language::output::LANG_SMTLIB_V2_6;
- }
-}
-
}/* CVC4::printer::smt2 namespace */
}/* CVC4::printer namespace */
}/* CVC4 namespace */
/** Print set-info command */
void toStreamCmdSetInfo(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const override;
+ const std::string& value) const override;
/** Print get-info command */
void toStreamCmdGetInfo(std::ostream& out,
/** Print set-option command */
void toStreamCmdSetOption(std::ostream& out,
const std::string& flag,
- SExpr sexpr) const override;
+ const std::string& value) const override;
/** Print get-option command */
void toStreamCmdGetOption(std::ostream& out,
/* class SetInfoCommand */
/* -------------------------------------------------------------------------- */
-SetInfoCommand::SetInfoCommand(std::string flag, const std::string& sexpr)
- : d_flag(flag), d_sexpr(sexpr)
+SetInfoCommand::SetInfoCommand(const std::string& flag,
+ const std::string& value)
+ : d_flag(flag), d_value(value)
{
}
-std::string SetInfoCommand::getFlag() const { return d_flag; }
-const std::string& SetInfoCommand::getSExpr() const { return d_sexpr; }
+const std::string& SetInfoCommand::getFlag() const { return d_flag; }
+const std::string& SetInfoCommand::getValue() const { return d_value; }
void SetInfoCommand::invoke(api::Solver* solver, SymbolManager* sm)
{
try
{
- solver->setInfo(d_flag, d_sexpr);
+ solver->setInfo(d_flag, d_value);
d_commandStatus = CommandSuccess::instance();
}
catch (api::CVC4ApiRecoverableException&)
Command* SetInfoCommand::clone() const
{
- return new SetInfoCommand(d_flag, d_sexpr);
+ return new SetInfoCommand(d_flag, d_value);
}
std::string SetInfoCommand::getCommandName() const { return "set-info"; }
size_t dag,
OutputLanguage language) const
{
- Printer::getPrinter(language)->toStreamCmdSetInfo(out, d_flag, d_sexpr);
+ Printer::getPrinter(language)->toStreamCmdSetInfo(out, d_flag, d_value);
}
/* -------------------------------------------------------------------------- */
/* class SetOptionCommand */
/* -------------------------------------------------------------------------- */
-SetOptionCommand::SetOptionCommand(std::string flag, const std::string& sexpr)
- : d_flag(flag), d_sexpr(sexpr)
+SetOptionCommand::SetOptionCommand(const std::string& flag,
+ const std::string& value)
+ : d_flag(flag), d_value(value)
{
}
-std::string SetOptionCommand::getFlag() const { return d_flag; }
-const std::string& SetOptionCommand::getSExpr() const { return d_sexpr; }
+const std::string& SetOptionCommand::getFlag() const { return d_flag; }
+const std::string& SetOptionCommand::getValue() const { return d_value; }
void SetOptionCommand::invoke(api::Solver* solver, SymbolManager* sm)
{
try
{
- solver->setOption(d_flag, d_sexpr);
+ solver->setOption(d_flag, d_value);
d_commandStatus = CommandSuccess::instance();
}
catch (api::CVC4ApiRecoverableException&)
Command* SetOptionCommand::clone() const
{
- return new SetOptionCommand(d_flag, d_sexpr);
+ return new SetOptionCommand(d_flag, d_value);
}
std::string SetOptionCommand::getCommandName() const { return "set-option"; }
size_t dag,
OutputLanguage language) const
{
- Printer::getPrinter(language)->toStreamCmdSetOption(out, d_flag, d_sexpr);
+ Printer::getPrinter(language)->toStreamCmdSetOption(out, d_flag, d_value);
}
/* -------------------------------------------------------------------------- */
{
protected:
std::string d_flag;
- std::string d_sexpr;
+ std::string d_value;
public:
- SetInfoCommand(std::string flag, const std::string& sexpr);
+ SetInfoCommand(const std::string& flag, const std::string& value);
- std::string getFlag() const;
- const std::string& getSExpr() const;
+ const std::string& getFlag() const;
+ const std::string& getValue() const;
void invoke(api::Solver* solver, SymbolManager* sm) override;
Command* clone() const override;
{
protected:
std::string d_flag;
- std::string d_sexpr;
+ std::string d_value;
public:
- SetOptionCommand(std::string flag, const std::string& sexpr);
+ SetOptionCommand(const std::string& flag, const std::string& value);
- std::string getFlag() const;
- const std::string& getSExpr() const;
+ const std::string& getFlag() const;
+ const std::string& getValue() const;
void invoke(api::Solver* solver, SymbolManager* sm) override;
Command* clone() const override;
d_userLogic.lock();
}
-void SmtEngine::setInfo(const std::string& key, const CVC4::SExpr& value)
+void SmtEngine::setInfo(const std::string& key, const std::string& value)
{
SmtScope smts(this);
Trace("smt") << "SMT setInfo(" << key << ", " << value << ")" << endl;
- if(Dump.isOn("benchmark")) {
- if(key == "status") {
- string s = value.getValue();
+ if (Dump.isOn("benchmark"))
+ {
+ if (key == "status")
+ {
Result::Sat status =
- (s == "sat") ? Result::SAT
- : ((s == "unsat") ? Result::UNSAT : Result::SAT_UNKNOWN);
+ (value == "sat")
+ ? Result::SAT
+ : ((value == "unsat") ? Result::UNSAT : Result::SAT_UNKNOWN);
getOutputManager().getPrinter().toStreamCmdSetBenchmarkStatus(
getOutputManager().getDumpOut(), status);
- } else {
+ }
+ else
+ {
getOutputManager().getPrinter().toStreamCmdSetInfo(
getOutputManager().getDumpOut(), key, value);
}
}
- // Check for standard info keys (SMT-LIB v1, SMT-LIB v2, ...)
- if (key == "source" || key == "category" || key == "difficulty"
- || key == "notes" || key == "name" || key == "license")
+ if (key == "filename")
{
- // ignore these
- return;
- }
- else if (key == "filename")
- {
- d_state->setFilename(value.getValue());
- return;
+ d_state->setFilename(value);
}
else if (key == "smt-lib-version" && !options::inputLanguage.wasSetByUser())
{
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" ) {
+
+ if (value == "2" || value == "2.0")
+ {
ilang = language::input::LANG_SMTLIB_V2_0;
- } else if( (value.isRational() && value.getRationalValue() == Rational(5, 2)) ||
- value.getValue() == "2.5" ) {
+ }
+ else if (value == "2.5")
+ {
ilang = language::input::LANG_SMTLIB_V2_5;
- } else if( (value.isRational() && value.getRationalValue() == Rational(13, 5)) ||
- value.getValue() == "2.6" ) {
+ }
+ else if (value == "2.6")
+ {
ilang = language::input::LANG_SMTLIB_V2_6;
}
+
options::inputLanguage.set(ilang);
// also update the output language
if (!options::outputLanguage.wasSetByUser())
*options::out() << language::SetLanguage(olang);
}
}
- return;
- } else if(key == "status") {
- string s;
- if(value.isAtom()) {
- s = value.getValue();
- }
- if(s != "sat" && s != "unsat" && s != "unknown") {
- throw OptionException("argument to (set-info :status ..) must be "
- "`sat' or `unsat' or `unknown'");
- }
- d_state->notifyExpectedStatus(s);
- return;
+ }
+ else if (key == "status")
+ {
+ d_state->notifyExpectedStatus(value);
}
}
te->setUserAttribute(attr, expr, expr_values, str_value);
}
-void SmtEngine::setOption(const std::string& key, const CVC4::SExpr& value)
+void SmtEngine::setOption(const std::string& key, const std::string& value)
{
- // Always check whether the SmtEngine has been initialized (which is done
- // upon entering Assert mode the first time). No option can be set after
- // initialized.
- if (d_state->isFullyInited())
- {
- throw ModalException("SmtEngine::setOption called after initialization.");
- }
- NodeManagerScope nms(d_nodeManager);
+ NodeManagerScope nms(d_nodeManager);
Trace("smt") << "SMT setOption(" << key << ", " << value << ")" << endl;
if(Dump.isOn("benchmark")) {
}
if(key == "command-verbosity") {
- if(!value.isAtom()) {
- const vector<SExpr>& cs = value.getChildren();
- if(cs.size() == 2 &&
- (cs[0].isKeyword() || cs[0].isString()) &&
- cs[1].isInteger()) {
- string c = cs[0].getValue();
- const Integer& v = cs[1].getIntegerValue();
- if(v < 0 || v > 2) {
- throw OptionException("command-verbosity must be 0, 1, or 2");
- }
- d_commandVerbosity[c] = v;
- return;
+ size_t fstIndex = value.find(" ");
+ size_t sndIndex = value.find(" ", fstIndex + 1);
+ if (sndIndex == std::string::npos)
+ {
+ string c = value.substr(1, fstIndex - 1);
+ int v =
+ std::stoi(value.substr(fstIndex + 1, value.length() - fstIndex - 1));
+ if (v < 0 || v > 2)
+ {
+ throw OptionException("command-verbosity must be 0, 1, or 2");
}
+ d_commandVerbosity[c] = v;
+ return;
}
throw OptionException("command-verbosity value must be a tuple (command-name, integer)");
}
- if(!value.isAtom()) {
+ if (value.find(" ") != std::string::npos)
+ {
throw OptionException("bad value for :" + key);
}
- string optionarg = value.getValue();
+ std::string optionarg = value;
d_options.setOption(key, optionarg);
}
/**
* Set information about the script executing.
- * @throw OptionException, ModalException
*/
- void setInfo(const std::string& key, const CVC4::SExpr& value);
+ void setInfo(const std::string& key, const std::string& value);
/** Return true if given keyword is a valid SMT-LIB v2 get-info flag. */
bool isValidGetInfoFlag(const std::string& key) const;
* Set an aspect of the current SMT execution environment.
* @throw OptionException, ModalException
*/
- void setOption(const std::string& key, const CVC4::SExpr& value);
+ void setOption(const std::string& key, const std::string& value);
/** Set is internal subsolver.
*
Assert (!query.isNull());
initializeSubsolver(checker);
// also set the options
- checker->setOption("sygus-rr-synth-input", false);
+ checker->setOption("sygus-rr-synth-input", "false");
checker->setOption("input-language", "smt2");
// Convert bound variables to skolems. This ensures the satisfiability
// check is ground.
options::sygusRepairConstTimeout.wasSetByUser(),
options::sygusRepairConstTimeout());
// renable options disabled by sygus
- repcChecker->setOption("miniscope-quant", true);
- repcChecker->setOption("miniscope-quant-fv", true);
- repcChecker->setOption("quant-split", true);
+ repcChecker->setOption("miniscope-quant", "true");
+ repcChecker->setOption("miniscope-quant-fv", "true");
+ repcChecker->setOption("quant-split", "true");
repcChecker->assertFormula(fo_body);
// check satisfiability
Result r = repcChecker->checkSat();
void SetUp() override
{
TestSmtNoFinishInit::SetUp();
- d_smtEngine->setOption("incremental", CVC4::SExpr(false));
+ d_smtEngine->setOption("incremental", "false");
d_smtEngine->finishInit();
d_context = d_smtEngine->getContext();
d_user_context = d_smtEngine->getUserContext();
{
d_smtEngine->setLogic("QF_BV");
- d_smtEngine->setOption("bitblast", SExpr("eager"));
- d_smtEngine->setOption("incremental", SExpr("false"));
+ d_smtEngine->setOption("bitblast", "eager");
+ d_smtEngine->setOption("incremental", "false");
// Notice that this unit test uses the theory engine of a created SMT
// engine d_smtEngine. We must ensure that d_smtEngine is properly initialized
// via the following call, which constructs its underlying theory engine.
TEST_F(TestTheoryWhiteBv, mkUmulo)
{
- d_smtEngine->setOption("incremental", SExpr("true"));
+ d_smtEngine->setOption("incremental", "true");
for (uint32_t w = 1; w < 16; ++w)
{
d_smtEngine->push();
void SetUp() override
{
TestSmtNoFinishInit::SetUp();
- d_smtEngine->setOption("cegqi-full", CVC4::SExpr(true));
- d_smtEngine->setOption("produce-models", CVC4::SExpr(true));
+ d_smtEngine->setOption("cegqi-full", "true");
+ d_smtEngine->setOption("produce-models", "true");
d_smtEngine->finishInit();
d_s = d_nodeManager->mkVar("s", d_nodeManager->mkBitVectorType(4));