#include "smt/model.h"
#include "smt/smt_engine.h"
#include "smt/smt_engine_scope.h"
-#include "util/sexpr.h"
#include "util/unsafe_interrupt_exception.h"
#include "util/utility.h"
// of whether terms is empty.
std::vector<api::Term> values = solver->getValue(terms);
Assert(values.size() == names.size());
- std::vector<SExpr> sexprs;
+ std::vector<api::Term> sexprs;
for (size_t i = 0, nterms = terms.size(); i < nterms; i++)
{
- std::vector<SExpr> ss;
- ss.emplace_back(SExpr::Keyword(names[i]));
- ss.emplace_back(SExpr::Keyword(values[i].toString()));
- sexprs.emplace_back(ss);
+ // Treat the expression name as a variable name as opposed to a string
+ // constant to avoid printing double quotes around the name.
+ api::Term name = solver->mkVar(solver->getBooleanSort(), names[i]);
+ sexprs.push_back(solver->mkTerm(api::SEXPR, name, values[i]));
}
- d_result = SExpr(sexprs);
+ d_result = solver->mkTerm(api::SEXPR, sexprs);
d_commandStatus = CommandSuccess::instance();
}
catch (api::CVC4ApiRecoverableException& e)
}
}
-SExpr GetAssignmentCommand::getResult() const { return d_result; }
+api::Term GetAssignmentCommand::getResult() const { return d_result; }
void GetAssignmentCommand::printResult(std::ostream& out,
uint32_t verbosity) const
{
NodeManagerScope nms(getNodeManager());
Trace("smt") << "SMT setOption(" << key << ", " << value << ")" << endl;
- if(Dump.isOn("benchmark")) {
+ if (Dump.isOn("benchmark"))
+ {
getPrinter().toStreamCmdSetOption(
getOutputManager().getDumpOut(), key, value);
}
- if(key == "command-verbosity") {
+ if (key == "command-verbosity")
+ {
size_t fstIndex = value.find(" ");
size_t sndIndex = value.find(" ", fstIndex + 1);
if (sndIndex == std::string::npos)
d_commandVerbosity[c] = v;
return;
}
- throw OptionException("command-verbosity value must be a tuple (command-name, integer)");
+ throw OptionException(
+ "command-verbosity value must be a tuple (command-name integer)");
}
if (value.find(" ") != std::string::npos)
bool SmtEngine::isInternalSubsolver() const { return d_isInternalSubsolver; }
-CVC4::SExpr SmtEngine::getOption(const std::string& key) const
+Node SmtEngine::getOption(const std::string& key) const
{
NodeManagerScope nms(getNodeManager());
+ NodeManager* nm = d_env->getNodeManager();
Trace("smt") << "SMT getOption(" << key << ")" << endl;
- if(key.length() >= 18 &&
- key.compare(0, 18, "command-verbosity:") == 0) {
- map<string, Integer>::const_iterator i = d_commandVerbosity.find(key.c_str() + 18);
- if(i != d_commandVerbosity.end()) {
- return SExpr((*i).second);
+ if (key.length() >= 18 && key.compare(0, 18, "command-verbosity:") == 0)
+ {
+ map<string, Integer>::const_iterator i =
+ d_commandVerbosity.find(key.c_str() + 18);
+ if (i != d_commandVerbosity.end())
+ {
+ return nm->mkConst(Rational(i->second));
}
i = d_commandVerbosity.find("*");
- if(i != d_commandVerbosity.end()) {
- return SExpr((*i).second);
+ if (i != d_commandVerbosity.end())
+ {
+ return nm->mkConst(Rational(i->second));
}
- return SExpr(Integer(2));
+ return nm->mkConst(Rational(2));
}
- if(Dump.isOn("benchmark")) {
+ if (Dump.isOn("benchmark"))
+ {
getPrinter().toStreamCmdGetOption(d_outMgr.getDumpOut(), key);
}
- if(key == "command-verbosity") {
- vector<SExpr> result;
- SExpr defaultVerbosity;
- for(map<string, Integer>::const_iterator i = d_commandVerbosity.begin();
- i != d_commandVerbosity.end();
- ++i) {
- vector<SExpr> v;
- v.push_back(SExpr((*i).first));
- v.push_back(SExpr((*i).second));
- if((*i).first == "*") {
+ if (key == "command-verbosity")
+ {
+ vector<Node> result;
+ Node defaultVerbosity;
+ for (map<string, Integer>::const_iterator i = d_commandVerbosity.begin();
+ i != d_commandVerbosity.end();
+ ++i)
+ {
+ // treat the command name as a variable name as opposed to a string
+ // constant to avoid printing double quotes around the name
+ Node name = nm->mkBoundVar(i->first, nm->integerType());
+ Node value = nm->mkConst(Rational(i->second));
+ if ((*i).first == "*")
+ {
// put the default at the end of the SExpr
- defaultVerbosity = SExpr(v);
- } else {
- result.push_back(SExpr(v));
+ defaultVerbosity = nm->mkNode(Kind::SEXPR, name, value);
+ }
+ else
+ {
+ result.push_back(nm->mkNode(Kind::SEXPR, name, value));
}
}
- // put the default at the end of the SExpr
- if(!defaultVerbosity.isAtom()) {
- result.push_back(defaultVerbosity);
- } else {
- // ensure the default is always listed
- vector<SExpr> v;
- v.push_back(SExpr("*"));
- v.push_back(SExpr(Integer(2)));
- result.push_back(SExpr(v));
+ // ensure the default is always listed
+ if (defaultVerbosity.isNull())
+ {
+ defaultVerbosity = nm->mkNode(Kind::SEXPR,
+ nm->mkBoundVar("*", nm->integerType()),
+ nm->mkConst(Rational(2)));
}
- return SExpr(result);
+ result.push_back(defaultVerbosity);
+ return nm->mkNode(Kind::SEXPR, result);
}
- return SExpr::parseAtom(getOptions().getOption(key));
+ // parse atom string
+ std::string atom = getOptions().getOption(key);
+
+ if (atom == "true")
+ {
+ return nm->mkConst<bool>(true);
+ }
+ else if (atom == "false")
+ {
+ return nm->mkConst<bool>(false);
+ }
+ try
+ {
+ Integer z(atom);
+ return nm->mkConst(Rational(z));
+ }
+ catch (std::invalid_argument&)
+ {
+ // Fall through to the next case
+ }
+ return nm->mkConst(String(atom));
}
Options& SmtEngine::getOptions() { return d_env->d_options; }