with_portfolio=no
fi
AM_CONDITIONAL([CVC4_BUILD_PCVC4], [test "$with_portfolio" = yes])
+if test "$with_portfolio" = yes; then
+ CVC4CPPFLAGS="${CVC4CPPFLAGS:+$CVC4CPPFLAGS }-DCVC4_PORTFOLIO"
+fi
# Whether to build compatibility library
CVC4_BUILD_LIBCOMPAT=yes
#include "smt/smt_engine.h"
#include "smt/bad_option_exception.h"
#include "util/output.h"
+#include "util/dump.h"
#include "util/sexpr.h"
#include "expr/node.h"
#include "printer/printer.h"
return new EmptyCommand(d_name);
}
+Command* EmptyCommand::clone() const {
+ return new EmptyCommand(d_name);
+}
+
/* class AssertCommand */
AssertCommand::AssertCommand(const BoolExpr& e) throw() :
return new AssertCommand(d_expr.exportTo(exprManager, variableMap));
}
+Command* AssertCommand::clone() const {
+ return new AssertCommand(d_expr);
+}
+
/* class PushCommand */
void PushCommand::invoke(SmtEngine* smtEngine) throw() {
}
Command* PushCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- return new PushCommand;
+ return new PushCommand();
+}
+
+Command* PushCommand::clone() const {
+ return new PushCommand();
}
/* class PopCommand */
return new PopCommand();
}
+Command* PopCommand::clone() const {
+ return new PopCommand();
+}
+
/* class CheckSatCommand */
CheckSatCommand::CheckSatCommand(const BoolExpr& expr) throw() :
return c;
}
+Command* CheckSatCommand::clone() const {
+ CheckSatCommand* c = new CheckSatCommand(d_expr);
+ c->d_result = d_result;
+ return c;
+}
+
/* class QueryCommand */
QueryCommand::QueryCommand(const BoolExpr& e) throw() :
return c;
}
+Command* QueryCommand::clone() const {
+ QueryCommand* c = new QueryCommand(d_expr);
+ c->d_result = d_result;
+ return c;
+}
+
/* class QuitCommand */
QuitCommand::QuitCommand() throw() {
return new QuitCommand();
}
+Command* QuitCommand::clone() const {
+ return new QuitCommand();
+}
+
/* class CommentCommand */
CommentCommand::CommentCommand(std::string comment) throw() : d_comment(comment) {
return new CommentCommand(d_comment);
}
+Command* CommentCommand::clone() const {
+ return new CommentCommand(d_comment);
+}
+
/* class CommandSequence */
CommandSequence::CommandSequence() throw() :
d_commandSequence.push_back(cmd);
}
+void CommandSequence::clear() throw() {
+ d_commandSequence.clear();
+}
+
void CommandSequence::invoke(SmtEngine* smtEngine) throw() {
for(; d_index < d_commandSequence.size(); ++d_index) {
d_commandSequence[d_index]->invoke(smtEngine);
return seq;
}
+Command* CommandSequence::clone() const {
+ CommandSequence* seq = new CommandSequence();
+ for(const_iterator i = begin(); i != end(); ++i) {
+ seq->addCommand((*i)->clone());
+ }
+ seq->d_index = d_index;
+ return seq;
+}
+
CommandSequence::const_iterator CommandSequence::end() const throw() {
return d_commandSequence.end();
}
}
void DeclareFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
- Dump("declarations") << *this << endl;
+ Dump("declarations") << *this;
}
Command* DeclareFunctionCommand::exportTo(ExprManager* exprManager,
d_type.exportTo(exprManager, variableMap));
}
+Command* DeclareFunctionCommand::clone() const {
+ return new DeclareFunctionCommand(d_symbol, d_type);
+}
+
/* class DeclareTypeCommand */
DeclareTypeCommand::DeclareTypeCommand(const std::string& id, size_t arity, Type t) throw() :
}
void DeclareTypeCommand::invoke(SmtEngine* smtEngine) throw() {
- Dump("declarations") << *this << endl;
+ Dump("declarations") << *this;
}
Command* DeclareTypeCommand::exportTo(ExprManager* exprManager,
d_type.exportTo(exprManager, variableMap));
}
+Command* DeclareTypeCommand::clone() const {
+ return new DeclareTypeCommand(d_symbol, d_arity, d_type);
+}
+
/* class DefineTypeCommand */
DefineTypeCommand::DefineTypeCommand(const std::string& id,
}
void DefineTypeCommand::invoke(SmtEngine* smtEngine) throw() {
- Dump("declarations") << *this << endl;
+ Dump("declarations") << *this;
d_commandStatus = CommandSuccess::instance();
}
return new DefineTypeCommand(d_symbol, params, type);
}
+Command* DefineTypeCommand::clone() const {
+ return new DefineTypeCommand(d_symbol, d_params, d_type);
+}
+
/* class DefineFunctionCommand */
DefineFunctionCommand::DefineFunctionCommand(const std::string& id,
}
void DefineFunctionCommand::invoke(SmtEngine* smtEngine) throw() {
- //Dump("declarations") << *this << endl; -- done by SmtEngine
+ //Dump("declarations") << *this; -- done by SmtEngine
try {
if(!d_func.isNull()) {
smtEngine->defineFunction(d_func, d_formals, d_formula);
return new DefineFunctionCommand(d_symbol, func, formals, formula);
}
+Command* DefineFunctionCommand::clone() const {
+ return new DefineFunctionCommand(d_symbol, d_func, d_formals, d_formula);
+}
+
/* class DefineNamedFunctionCommand */
DefineNamedFunctionCommand::DefineNamedFunctionCommand(const std::string& id,
return new DefineNamedFunctionCommand(d_symbol, func, formals, formula);
}
+Command* DefineNamedFunctionCommand::clone() const {
+ return new DefineNamedFunctionCommand(d_symbol, d_func, d_formals, d_formula);
+}
+
/* class Simplify */
SimplifyCommand::SimplifyCommand(Expr term) throw() :
return c;
}
+Command* SimplifyCommand::clone() const {
+ SimplifyCommand* c = new SimplifyCommand(d_term);
+ c->d_result = d_result;
+ return c;
+}
+
/* class GetValueCommand */
GetValueCommand::GetValueCommand(Expr term) throw() :
return c;
}
+Command* GetValueCommand::clone() const {
+ GetValueCommand* c = new GetValueCommand(d_term);
+ c->d_result = d_result;
+ return c;
+}
+
/* class GetAssignmentCommand */
GetAssignmentCommand::GetAssignmentCommand() throw() {
}
Command* GetAssignmentCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetAssignmentCommand* c = new GetAssignmentCommand;
+ GetAssignmentCommand* c = new GetAssignmentCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetAssignmentCommand::clone() const {
+ GetAssignmentCommand* c = new GetAssignmentCommand();
c->d_result = d_result;
return c;
}
}
Command* GetProofCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetProofCommand* c = new GetProofCommand;
+ GetProofCommand* c = new GetProofCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetProofCommand::clone() const {
+ GetProofCommand* c = new GetProofCommand();
c->d_result = d_result;
return c;
}
}
Command* GetAssertionsCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- GetAssertionsCommand* c = new GetAssertionsCommand;
+ GetAssertionsCommand* c = new GetAssertionsCommand();
+ c->d_result = d_result;
+ return c;
+}
+
+Command* GetAssertionsCommand::clone() const {
+ GetAssertionsCommand* c = new GetAssertionsCommand();
c->d_result = d_result;
return c;
}
}
Command* SetBenchmarkStatusCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- SetBenchmarkStatusCommand* c = new SetBenchmarkStatusCommand(d_status);
- return c;
+ return new SetBenchmarkStatusCommand(d_status);
+}
+
+Command* SetBenchmarkStatusCommand::clone() const {
+ return new SetBenchmarkStatusCommand(d_status);
}
/* class SetBenchmarkLogicCommand */
}
Command* SetBenchmarkLogicCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- SetBenchmarkLogicCommand* c = new SetBenchmarkLogicCommand(d_logic);
- return c;
+ return new SetBenchmarkLogicCommand(d_logic);
+}
+
+Command* SetBenchmarkLogicCommand::clone() const {
+ return new SetBenchmarkLogicCommand(d_logic);
}
/* class SetInfoCommand */
}
Command* SetInfoCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- SetInfoCommand* c = new SetInfoCommand(d_flag, d_sexpr);
- return c;
+ return new SetInfoCommand(d_flag, d_sexpr);
+}
+
+Command* SetInfoCommand::clone() const {
+ return new SetInfoCommand(d_flag, d_sexpr);
}
/* class GetInfoCommand */
return c;
}
+Command* GetInfoCommand::clone() const {
+ GetInfoCommand* c = new GetInfoCommand(d_flag);
+ c->d_result = d_result;
+ return c;
+}
+
/* class SetOptionCommand */
SetOptionCommand::SetOptionCommand(std::string flag, const SExpr& sexpr) throw() :
}
Command* SetOptionCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- SetOptionCommand* c = new SetOptionCommand(d_flag, d_sexpr);
- return c;
+ return new SetOptionCommand(d_flag, d_sexpr);
+}
+
+Command* SetOptionCommand::clone() const {
+ return new SetOptionCommand(d_flag, d_sexpr);
}
/* class GetOptionCommand */
return c;
}
+Command* GetOptionCommand::clone() const {
+ GetOptionCommand* c = new GetOptionCommand(d_flag);
+ c->d_result = d_result;
+ return c;
+}
+
/* class DatatypeDeclarationCommand */
DatatypeDeclarationCommand::DatatypeDeclarationCommand(const DatatypeType& datatype) throw() :
}
void DatatypeDeclarationCommand::invoke(SmtEngine* smtEngine) throw() {
- Dump("declarations") << *this << endl;
+ Dump("declarations") << *this;
d_commandStatus = CommandSuccess::instance();
}
Command* DatatypeDeclarationCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- std::cout << "We currently do not support exportTo with Datatypes" << std::endl;
- exit(1);
+ Warning() << "We currently do not support exportTo with Datatypes" << std::endl;
return NULL;
}
+
+Command* DatatypeDeclarationCommand::clone() const {
+ return new DatatypeDeclarationCommand(d_datatypes);
+}
+
/* output stream insertion operator for benchmark statuses */
std::ostream& operator<<(std::ostream& out,
BenchmarkStatus status) throw() {
*/
virtual Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) = 0;
+ /**
+ * Clone this Command (make a shallow copy).
+ */
+ virtual Command* clone() const = 0;
+
protected:
class ExportTransformer {
ExprManager* d_exprManager;
std::string getName() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class EmptyCommand */
class CVC4_PUBLIC AssertCommand : public Command {
BoolExpr getExpr() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class AssertCommand */
class CVC4_PUBLIC PushCommand : public Command {
~PushCommand() throw() {}
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class PushCommand */
class CVC4_PUBLIC PopCommand : public Command {
~PopCommand() throw() {}
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class PopCommand */
class CVC4_PUBLIC DeclarationDefinitionCommand : public Command {
Type getType() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class DeclareFunctionCommand */
class CVC4_PUBLIC DeclareTypeCommand : public DeclarationDefinitionCommand {
Type getType() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class DeclareTypeCommand */
class CVC4_PUBLIC DefineTypeCommand : public DeclarationDefinitionCommand {
Type getType() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class DefineTypeCommand */
class CVC4_PUBLIC DefineFunctionCommand : public DeclarationDefinitionCommand {
Expr getFormula() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class DefineFunctionCommand */
/**
const std::vector<Expr>& formals, Expr formula) throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class DefineNamedFunctionCommand */
class CVC4_PUBLIC CheckSatCommand : public Command {
Result getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class CheckSatCommand */
class CVC4_PUBLIC QueryCommand : public Command {
Result getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class QueryCommand */
// this is TRANSFORM in the CVC presentation language
Expr getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class SimplifyCommand */
class CVC4_PUBLIC GetValueCommand : public Command {
Expr getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class GetValueCommand */
class CVC4_PUBLIC GetAssignmentCommand : public Command {
SExpr getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class GetAssignmentCommand */
class CVC4_PUBLIC GetProofCommand : public Command {
Proof* getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class GetProofCommand */
class CVC4_PUBLIC GetAssertionsCommand : public Command {
std::string getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class GetAssertionsCommand */
class CVC4_PUBLIC SetBenchmarkStatusCommand : public Command {
BenchmarkStatus getStatus() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class SetBenchmarkStatusCommand */
class CVC4_PUBLIC SetBenchmarkLogicCommand : public Command {
std::string getLogic() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class SetBenchmarkLogicCommand */
class CVC4_PUBLIC SetInfoCommand : public Command {
SExpr getSExpr() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class SetInfoCommand */
class CVC4_PUBLIC GetInfoCommand : public Command {
std::string getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class GetInfoCommand */
class CVC4_PUBLIC SetOptionCommand : public Command {
SExpr getSExpr() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class SetOptionCommand */
class CVC4_PUBLIC GetOptionCommand : public Command {
std::string getResult() const throw();
void printResult(std::ostream& out) const throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class GetOptionCommand */
class CVC4_PUBLIC DatatypeDeclarationCommand : public Command {
const std::vector<DatatypeType>& getDatatypes() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class DatatypeDeclarationCommand */
class CVC4_PUBLIC QuitCommand : public Command {
~QuitCommand() throw() {}
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class QuitCommand */
class CVC4_PUBLIC CommentCommand : public Command {
std::string getComment() const throw();
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class CommentCommand */
class CVC4_PUBLIC CommandSequence : public Command {
~CommandSequence() throw();
void addCommand(Command* cmd) throw();
+ void clear() throw();
void invoke(SmtEngine* smtEngine) throw();
void invoke(SmtEngine* smtEngine, std::ostream& out) throw();
iterator end() throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
};/* class CommandSequence */
class CVC4_PUBLIC DeclarationSequence : public CommandSequence {
#include "util/configuration.h"
#include "util/options.h"
#include "util/output.h"
+#include "util/dump.h"
#include "util/result.h"
#include "util/stats.h"
#include "util/configuration.h"
#include "util/options.h"
#include "util/output.h"
+#include "util/dump.h"
#include "util/result.h"
#include "util/stats.h"
Debug("cnf") << "Inserting into stream " << c << endl;
if(Dump.isOn("clauses")) {
if(c.size() == 1) {
- Dump("clauses") << AssertCommand(BoolExpr(getNode(c[0]).toExpr())) << endl;
+ Dump("clauses") << AssertCommand(BoolExpr(getNode(c[0]).toExpr()));
} else {
Assert(c.size() > 1);
NodeBuilder<> b(kind::OR);
b << getNode(c[i]);
}
Node n = b;
- Dump("clauses") << AssertCommand(BoolExpr(n.toExpr())) << endl;
+ Dump("clauses") << AssertCommand(BoolExpr(n.toExpr()));
}
}
d_satSolver->addClause(c, d_removable);
for (int l = trail_lim.size() - level; l > 0; --l) {
context->pop();
if(Dump.isOn("state")) {
- Dump("state") << PopCommand() << std::endl;
+ Dump("state") << PopCommand();
}
}
for (int c = trail.size()-1; c >= trail_lim[level]; c--){
inline bool Solver::addClause (Lit p, Lit q, bool removable) { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); return addClause_(add_tmp, removable); }
inline bool Solver::addClause (Lit p, Lit q, Lit r, bool removable) { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); return addClause_(add_tmp, removable); }
inline bool Solver::locked (const Clause& c) const { return value(c[0]) == l_True && isPropagatedBy(var(c[0]), c); }
-inline void Solver::newDecisionLevel() { trail_lim.push(trail.size()); context->push(); if(Dump.isOn("state")) { Dump("state") << CVC4::PushCommand() << std::endl; } }
+inline void Solver::newDecisionLevel() { trail_lim.push(trail.size()); context->push(); if(Dump.isOn("state")) { Dump("state") << CVC4::PushCommand(); } }
inline int Solver::decisionLevel () const { return trail_lim.size(); }
inline uint32_t Solver::abstractLevel (Var x) const { return 1 << (level(x) & 31); }
Debug("prop::lemmas") << "assertLemma(" << node << ")" << endl;
if(!d_inCheckSat && Dump.isOn("learned")) {
- Dump("learned") << AssertCommand(BoolExpr(node.toExpr())) << endl;
+ Dump("learned") << AssertCommand(BoolExpr(node.toExpr()));
} else if(Dump.isOn("lemmas")) {
- Dump("lemmas") << AssertCommand(BoolExpr(node.toExpr())) << endl;
+ Dump("lemmas") << AssertCommand(BoolExpr(node.toExpr()));
}
//TODO This comment is now false
void SmtEngine::shutdown() {
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << QuitCommand() << endl;
+ Dump("benchmark") << QuitCommand();
}
// check to see if a postsolve() is pending
}
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << SetBenchmarkLogicCommand(s) << endl;
+ Dump("benchmark") << SetBenchmarkLogicCommand(s);
}
setLogicInternal(s);
throw(BadOptionException, ModalException) {
Trace("smt") << "SMT setInfo(" << key << ", " << value << ")" << endl;
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << SetInfoCommand(key, value) << endl;
+ Dump("benchmark") << SetInfoCommand(key, value);
}
// Check for CVC4-specific info keys (prefixed with "cvc4-" or "cvc4_")
throw(BadOptionException, ModalException) {
Trace("smt") << "SMT setOption(" << key << ", " << value << ")" << endl;
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << SetOptionCommand(key, value) << endl;
+ Dump("benchmark") << SetOptionCommand(key, value);
}
if(key == ":print-success") {
throw(BadOptionException) {
Trace("smt") << "SMT getOption(" << key << ")" << endl;
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << GetOptionCommand(key) << endl;
+ Dump("benchmark") << GetOptionCommand(key);
}
if(key == ":print-success") {
return SExpr("true");
Trace("smt") << "SMT defineFunction(" << func << ")" << endl;
if(Dump.isOn("declarations")) {
stringstream ss;
- ss << Expr::setlanguage(Expr::setlanguage::getLanguage(Dump("declarations")))
+ ss << Expr::setlanguage(Expr::setlanguage::getLanguage(Dump.getStream()))
<< func;
- Dump("declarations") << DefineFunctionCommand(ss.str(), func, formals, formula)
- << endl;
+ Dump("declarations") << DefineFunctionCommand(ss.str(), func, formals, formula);
}
NodeManagerScope nms(d_nodeManager);
// Push the simplified assertions to the dump output stream
for (unsigned i = 0; i < d_assertionsToCheck.size(); ++ i) {
Dump("assertions")
- << AssertCommand(BoolExpr(d_assertionsToCheck[i].toExpr())) << endl;
+ << AssertCommand(BoolExpr(d_assertionsToCheck[i].toExpr()));
}
}
// Dump the query if requested
if(Dump.isOn("benchmark")) {
// the expr already got dumped out if assertion-dumping is on
- Dump("benchmark") << CheckSatCommand() << endl;
+ Dump("benchmark") << CheckSatCommand();
}
// Pop the context
// Dump the query if requested
if(Dump.isOn("benchmark")) {
// the expr already got dumped out if assertion-dumping is on
- Dump("benchmark") << CheckSatCommand() << endl;
+ Dump("benchmark") << CheckSatCommand();
}
// Pop the context
}
Trace("smt") << "SMT simplify(" << e << ")" << endl;
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << SimplifyCommand(e) << endl;
+ Dump("benchmark") << SimplifyCommand(e);
}
return d_private->applySubstitutions(e).toExpr();
}
Trace("smt") << "SMT getValue(" << e << ")" << endl;
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << GetValueCommand(e) << endl;
+ Dump("benchmark") << GetValueCommand(e);
}
if(!Options::current()->produceModels) {
const char* msg =
Trace("smt") << "SMT getAssignment()" << endl;
NodeManagerScope nms(d_nodeManager);
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << GetAssignmentCommand() << endl;
+ Dump("benchmark") << GetAssignmentCommand();
}
if(!Options::current()->produceAssignments) {
const char* msg =
Trace("smt") << "SMT getProof()" << endl;
NodeManagerScope nms(d_nodeManager);
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << GetProofCommand() << endl;
+ Dump("benchmark") << GetProofCommand();
}
#ifdef CVC4_PROOF
if(!Options::current()->proof) {
vector<Expr> SmtEngine::getAssertions()
throw(ModalException, AssertionException) {
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << GetAssertionsCommand() << endl;
+ Dump("benchmark") << GetAssertionsCommand();
}
NodeManagerScope nms(d_nodeManager);
Trace("smt") << "SMT getAssertions()" << endl;
Trace("smt") << "SMT push()" << endl;
d_private->processAssertions();
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << PushCommand() << endl;
+ Dump("benchmark") << PushCommand();
}
if(!Options::current()->incrementalSolving) {
throw ModalException("Cannot push when not solving incrementally (use --incremental)");
NodeManagerScope nms(d_nodeManager);
Trace("smt") << "SMT pop()" << endl;
if(Dump.isOn("benchmark")) {
- Dump("benchmark") << PopCommand() << endl;
+ Dump("benchmark") << PopCommand();
}
if(!Options::current()->incrementalSolving) {
throw ModalException("Cannot pop when not solving incrementally (use --incremental)");
NodeManager* nm = NodeManager::currentNM();
TypeNode ixType = a.getType()[0];
Node k = nm->mkVar(ixType);
- if(Dump.isOn("declarations")) {
- stringstream kss;
- kss << Expr::setlanguage(Expr::setlanguage::getLanguage(Dump("declarations"))) << k;
- string ks = kss.str();
- Dump("declarations")
- << CommentCommand(ks + " is an extensional lemma index variable "
- "from the theory of arrays") << endl
- << DeclareFunctionCommand(ks, ixType.toType()) << endl;
- }
+ Dump.declareVar(k.toExpr(), "an extensional lemma index variable from the theory of arrays");
Node eq = nm->mkNode(kind::EQUAL, a, b);
Node ak = nm->mkNode(kind::SELECT, a, k);
Node bk = nm->mkNode(kind::SELECT, b, k);
#include "context/cdlist.h"
#include "context/cdo.h"
#include "util/options.h"
+#include "util/dump.h"
#include <string>
#include <iostream>
d_factsHead = d_factsHead + 1;
Trace("theory") << "Theory::get() => " << fact << " (" << d_facts.size() - d_factsHead << " left)" << std::endl;
if(Dump.isOn("state")) {
- Dump("state") << AssertCommand(fact.assertion.toExpr()) << std::endl;
+ Dump("state") << AssertCommand(fact.assertion.toExpr());
}
return fact;
if(Dump.isOn("missed-t-conflicts")) {
Dump("missed-t-conflicts")
- << CommentCommand("Completeness check for T-conflicts; expect sat") << endl
- << CheckSatCommand() << endl;
+ << CommentCommand("Completeness check for T-conflicts; expect sat")
+ << CheckSatCommand();
}
Debug("theory") << "TheoryEngine::check(" << effort << "): running propagation after the initial check" << std::endl;
++i) {
if(d_hasPropagated.find(*i) == d_hasPropagated.end()) {
Dump("missed-t-propagations")
- << CommentCommand("Completeness check for T-propagations; expect invalid") << endl
- << QueryCommand((*i).toExpr()) << endl;
+ << CommentCommand("Completeness check for T-propagations; expect invalid")
+ << QueryCommand((*i).toExpr());
}
}
}
d_propEngine->checkTime();
if(Dump.isOn("t-propagations")) {
- Dump("t-propagations") << CommentCommand("negation of theory propagation: expect valid") << std::endl
- << QueryCommand(literal.toExpr()) << std::endl;
+ Dump("t-propagations") << CommentCommand("negation of theory propagation: expect valid")
+ << QueryCommand(literal.toExpr());
}
if(Dump.isOn("missed-t-propagations")) {
d_hasPropagated.insert(literal);
Assert(!explanation.isNull());
if(Dump.isOn("t-explanations")) {
- Dump("t-explanations") << CommentCommand(std::string("theory explanation from ") + theoryOf(atom)->identify() + ": expect valid") << std::endl
- << QueryCommand(explanation.impNode(node).toExpr()) << std::endl;
+ Dump("t-explanations") << CommentCommand(std::string("theory explanation from ") + theoryOf(atom)->identify() + ": expect valid")
+ << QueryCommand(explanation.impNode(node).toExpr());
}
Assert(properExplanation(node, explanation));
d_inConflict = true;
if(Dump.isOn("t-conflicts")) {
- Dump("t-conflicts") << CommentCommand("theory conflict: expect unsat") << std::endl
- << CheckSatCommand(conflict.toExpr()) << std::endl;
+ Dump("t-conflicts") << CommentCommand("theory conflict: expect unsat")
+ << CheckSatCommand(conflict.toExpr());
}
if (d_sharedTermsExist) {
theory::LemmaStatus lemma(TNode node, bool negated, bool removable) {
if(Dump.isOn("t-lemmas")) {
Dump("t-lemmas") << CommentCommand("theory lemma: expect valid")
- << std::endl
- << QueryCommand(node.toExpr()) << std::endl;
+ << QueryCommand(node.toExpr());
}
// Share with other portfolio threads
ntuple.h \
recursion_breaker.h \
subrange_bound.h \
+ dump.h \
+ dump.cpp \
predicate.h \
predicate.cpp \
cardinality.h \
--- /dev/null
+/********************* */
+/*! \file dump.cpp
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009-2012 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief Dump utility classes and functions
+ **
+ ** Dump utility classes and functions.
+ **/
+
+#include "util/dump.h"
+
+using namespace std;
+
+namespace CVC4 {
+
+DumpC DumpChannel CVC4_PUBLIC;
+
+}/* CVC4 namespace */
--- /dev/null
+/********************* */
+/*! \file dump.h
+ ** \verbatim
+ ** Original author: mdeters
+ ** Major contributors: none
+ ** Minor contributors (to current version): none
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009-2012 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.\endverbatim
+ **
+ ** \brief Dump utility classes and functions
+ **
+ ** Dump utility classes and functions.
+ **/
+
+#include "cvc4_public.h"
+
+#ifndef __CVC4__DUMP_H
+#define __CVC4__DUMP_H
+
+#include "util/output.h"
+#include "expr/command.h"
+
+namespace CVC4 {
+
+class CVC4_PUBLIC CVC4dumpstream {
+
+#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
+ std::ostream* d_os;
+#endif /* CVC4_DUMPING && !CVC4_MUZZLE */
+
+#ifdef CVC4_PORTFOLIO
+ CommandSequence* d_commands;
+#endif /* CVC4_PORTFOLIO */
+
+public:
+ CVC4dumpstream() throw()
+#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE) && defined(CVC4_PORTFOLIO)
+ : d_os(NULL), d_commands(NULL)
+#elif defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
+ : d_os(NULL)
+#elif defined(CVC4_PORTFOLIO)
+ : d_commands(NULL)
+#endif /* CVC4_PORTFOLIO */
+ { }
+
+ CVC4dumpstream(std::ostream& os, CommandSequence& commands) throw()
+#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE) && defined(CVC4_PORTFOLIO)
+ : d_os(&os), d_commands(&commands)
+#elif defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
+ : d_os(&os)
+#elif defined(CVC4_PORTFOLIO)
+ : d_commands(&commands)
+#endif /* CVC4_PORTFOLIO */
+ { }
+
+ CVC4dumpstream& operator<<(const Command& c) {
+#if defined(CVC4_DUMPING) && !defined(CVC4_MUZZLE)
+ if(d_os != NULL) {
+ (*d_os) << c << std::endl;
+ }
+#endif
+#if defined(CVC4_PORTFOLIO)
+ if(d_commands != NULL) {
+ d_commands->addCommand(c.clone());
+ }
+#endif
+ return *this;
+ }
+};/* class CVC4dumpstream */
+
+/** The dump class */
+class CVC4_PUBLIC DumpC {
+ std::set<std::string> d_tags;
+ CommandSequence d_commands;
+
+public:
+ CVC4dumpstream operator()(const char* tag) {
+ if(!d_tags.empty() && d_tags.find(std::string(tag)) != d_tags.end()) {
+ return CVC4dumpstream(getStream(), d_commands);
+ } else {
+ return CVC4dumpstream();
+ }
+ }
+ CVC4dumpstream operator()(std::string tag) {
+ if(!d_tags.empty() && d_tags.find(tag) != d_tags.end()) {
+ return CVC4dumpstream(getStream(), d_commands);
+ } else {
+ return CVC4dumpstream();
+ }
+ }
+
+ void clear() { d_commands.clear(); }
+ const CommandSequence& getCommands() const { return d_commands; }
+
+ void declareVar(Expr e, std::string comment) {
+ if(isOn("declarations")) {
+ std::stringstream ss;
+ ss << Expr::setlanguage(Expr::setlanguage::getLanguage(getStream())) << e;
+ std::string s = ss.str();
+ CVC4dumpstream(getStream(), d_commands)
+ << CommentCommand(s + " is " + comment)
+ << DeclareFunctionCommand(s, e.getType());
+ }
+ }
+
+ bool on (const char* tag) { d_tags.insert(std::string(tag)); return true; }
+ bool on (std::string tag) { d_tags.insert(tag); return true; }
+ bool off(const char* tag) { d_tags.erase (std::string(tag)); return false; }
+ bool off(std::string tag) { d_tags.erase (tag); return false; }
+ bool off() { d_tags.clear(); return false; }
+
+ bool isOn(const char* tag) { return d_tags.find(std::string(tag)) != d_tags.end(); }
+ bool isOn(std::string tag) { return d_tags.find(tag) != d_tags.end(); }
+
+ std::ostream& setStream(std::ostream& os) { DumpOut.setStream(os); return os; }
+ std::ostream& getStream() { return DumpOut.getStream(); }
+};/* class DumpC */
+
+/** The dump singleton */
+extern DumpC DumpChannel CVC4_PUBLIC;
+
+#define Dump ::CVC4::DumpChannel
+
+}/* CVC4 namespace */
+
+#endif /* __CVC4__DUMP_H */
// Make the skolem to represent the ITE
Node skolem = nodeManager->mkVar(nodeType);
- if(Dump.isOn("declarations")) {
- stringstream kss;
- kss << Expr::setlanguage(Expr::setlanguage::getLanguage(Dump("declarations"))) << skolem;
- string ks = kss.str();
- Dump("declarations") << CommentCommand(ks + " is a variable introduced due to term-level ITE removal") << endl
- << DeclareFunctionCommand(ks, nodeType.toType()) << endl;
- }
+ Dump.declareVar(skolem.toExpr(), "a variable introduced due to term-level ITE removal");
// The new assertion
Node newAssertion =
#include <vector>
#include "expr/node.h"
+#include "util/dump.h"
namespace CVC4 {
#include "util/language.h"
#include "util/options.h"
#include "util/output.h"
+#include "util/dump.h"
#include "cvc4autoconfig.h"
if(optarg == NULL || *optarg == '\0') {
throw OptionException(string("Bad file name for --dump-to"));
} else if(!strcmp(optarg, "-")) {
- Dump.setStream(DumpC::dump_cout);
+ Dump.setStream(DumpOutC::dump_cout);
} else {
ostream* dumpTo = new ofstream(optarg, ofstream::out | ofstream::trunc);
if(!*dumpTo) {
NoticeC NoticeChannel CVC4_PUBLIC (&cout);
ChatC ChatChannel CVC4_PUBLIC (&cout);
TraceC TraceChannel CVC4_PUBLIC (&cout);
-std::ostream DumpC::dump_cout(cout.rdbuf());// copy cout stream buffer
-DumpC DumpChannel CVC4_PUBLIC (&DumpC::dump_cout);
+std::ostream DumpOutC::dump_cout(cout.rdbuf());// copy cout stream buffer
+DumpOutC DumpOutChannel CVC4_PUBLIC (&DumpOutC::dump_cout);
#ifndef CVC4_MUZZLE
# ifdef CVC4_DUMPING
-int DumpC::printf(const char* tag, const char* fmt, ...) {
+int DumpOutC::printf(const char* tag, const char* fmt, ...) {
if(d_tags.find(string(tag)) == d_tags.end()) {
return 0;
}
return retval;
}
-int DumpC::printf(std::string tag, const char* fmt, ...) {
+int DumpOutC::printf(std::string tag, const char* fmt, ...) {
if(d_tags.find(tag) == d_tags.end()) {
return 0;
}
};/* class TraceC */
/** The dump output class */
-class CVC4_PUBLIC DumpC {
+class CVC4_PUBLIC DumpOutC {
std::set<std::string> d_tags;
std::ostream* d_os;
* unlimited). */
static std::ostream dump_cout;
- explicit DumpC(std::ostream* os) : d_os(os) {}
+ explicit DumpOutC(std::ostream* os) : d_os(os) {}
int printf(const char* tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
int printf(std::string tag, const char* fmt, ...) __attribute__ ((format(printf, 3, 4)));
std::ostream& setStream(std::ostream& os) { d_os = &os; return os; }
std::ostream& getStream() { return *d_os; }
-};/* class DumpC */
+};/* class DumpOutC */
/** The debug output singleton */
extern DebugC DebugChannel CVC4_PUBLIC;
/** The trace output singleton */
extern TraceC TraceChannel CVC4_PUBLIC;
/** The dump output singleton */
-extern DumpC DumpChannel CVC4_PUBLIC;
+extern DumpOutC DumpOutChannel CVC4_PUBLIC;
#ifdef CVC4_MUZZLE
# define Notice ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::NoticeChannel
# define Chat ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::ChatChannel
# define Trace ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::TraceChannel
-# define Dump ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DumpChannel
+# define DumpOut ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DumpOutChannel
inline int DebugC::printf(const char* tag, const char* fmt, ...) { return 0; }
inline int DebugC::printf(std::string tag, const char* fmt, ...) { return 0; }
inline int ChatC::printf(const char* fmt, ...) { return 0; }
inline int TraceC::printf(const char* tag, const char* fmt, ...) { return 0; }
inline int TraceC::printf(std::string tag, const char* fmt, ...) { return 0; }
-inline int DumpC::printf(const char* tag, const char* fmt, ...) { return 0; }
-inline int DumpC::printf(std::string tag, const char* fmt, ...) { return 0; }
+inline int DumpOutC::printf(const char* tag, const char* fmt, ...) { return 0; }
+inline int DumpOutC::printf(std::string tag, const char* fmt, ...) { return 0; }
#else /* CVC4_MUZZLE */
inline int TraceC::printf(std::string tag, const char* fmt, ...) { return 0; }
# endif /* CVC4_TRACING */
# ifdef CVC4_DUMPING
-# define Dump ::CVC4::DumpChannel
+# define DumpOut ::CVC4::DumpOutChannel
# else /* CVC4_DUMPING */
-# define Dump ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DumpChannel
-inline int DumpC::printf(const char* tag, const char* fmt, ...) { return 0; }
-inline int DumpC::printf(std::string tag, const char* fmt, ...) { return 0; }
+# define DumpOut ::CVC4::__cvc4_true() ? ::CVC4::nullCvc4Stream : ::CVC4::DumpOutChannel
+inline int DumpOutC::printf(const char* tag, const char* fmt, ...) { return 0; }
+inline int DumpOutC::printf(std::string tag, const char* fmt, ...) { return 0; }
# endif /* CVC4_DUMPING */
#endif /* CVC4_MUZZLE */