}
void ValidityChecker::reset() {
- Unimplemented("This CVC3 compatibility function not yet implemented (sorry!)");
+ // reset everything, forget everything
+ d_smt->reset();
+ delete d_parserContext;
+ d_parserContext = CVC4::parser::ParserBuilder(d_em, "<internal>").withInputLanguage(CVC4::language::input::LANG_CVC4).withStringInput("").build();
+ s_typeToExpr.clear();
+ s_exprToType.clear();
}
void ValidityChecker::logAnnotation(const Expr& annot) {
return "query";
}
-/* class QuitCommand */
+/* class ResetCommand */
+
+void ResetCommand::invoke(SmtEngine* smtEngine) throw() {
+ try {
+ smtEngine->reset();
+ d_commandStatus = CommandSuccess::instance();
+ } catch(exception& e) {
+ d_commandStatus = new CommandFailure(e.what());
+ }
+}
+
+Command* ResetCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
+ return new ResetCommand();
+}
-QuitCommand::QuitCommand() throw() {
+Command* ResetCommand::clone() const {
+ return new ResetCommand();
}
+std::string ResetCommand::getCommandName() const throw() {
+ return "reset";
+}
+
+/* class QuitCommand */
+
void QuitCommand::invoke(SmtEngine* smtEngine) throw() {
Dump("benchmark") << *this;
d_commandStatus = CommandSuccess::instance();
std::string getCommandName() const throw();
};/* class SetUserAttributeCommand */
-
class CVC4_PUBLIC CheckSatCommand : public Command {
protected:
Expr d_expr;
std::string getCommandName() const throw();
};/* class PropagateRuleCommand */
+class CVC4_PUBLIC ResetCommand : public Command {
+public:
+ ResetCommand() throw() {}
+ ~ResetCommand() throw() {}
+ void invoke(SmtEngine* smtEngine) throw();
+ Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
+ Command* clone() const;
+ std::string getCommandName() const throw();
+};/* class ResetCommand */
class CVC4_PUBLIC QuitCommand : public Command {
public:
- QuitCommand() throw();
+ QuitCommand() throw() {}
~QuitCommand() throw() {}
void invoke(SmtEngine* smtEngine) throw();
Command* exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap);
namespace CVC4 {
SymbolTable::SymbolTable() :
- d_context(new Context),
+ d_context(new Context()),
d_exprMap(new(true) CDHashMap<std::string, Expr, StringHashFunction>(d_context)),
d_typeMap(new(true) CDHashMap<std::string, pair<vector<Type>, Type>, StringHashFunction>(d_context)),
d_functions(new(true) CDHashSet<Expr, ExprHashFunction>(d_context)) {
return d_context->getLevel();
}
+void SymbolTable::reset() {
+ this->SymbolTable::~SymbolTable();
+ new(this) SymbolTable();
+}
+
}/* CVC4 namespace */
/** Get the current level of this symbol table. */
size_t getLevel() const throw();
+ /** Reset everything. */
+ void reset();
+
};/* class SymbolTable */
}/* CVC4 namespace */
{ UNSUPPORTED("POPTO_SCOPE command"); }
| RESET_TOK
- { UNSUPPORTED("RESET command"); }
+ { cmd = new ResetCommand(); }
// Datatypes can be mututally-recursive if they're in the same
// definition block, separated by a comma. So we parse everything
}
}
+ inline void reset() {
+ d_symtab->reset();
+ }
+
/**
* Set the current symbol table used by this parser.
* From now on, this parser will perform its definitions and
tryToStream<PopCommand>(out, c) ||
tryToStream<CheckSatCommand>(out, c) ||
tryToStream<QueryCommand>(out, c) ||
+ tryToStream<ResetCommand>(out, c) ||
tryToStream<QuitCommand>(out, c) ||
tryToStream<DeclarationSequence>(out, c) ||
tryToStream<CommandSequence>(out, c) ||
out << "Query(" << c->getExpr() << ')';
}
+static void toStream(std::ostream& out, const ResetCommand* c) throw() {
+ out << "Reset()";
+}
+
static void toStream(std::ostream& out, const QuitCommand* c) throw() {
out << "Quit()";
}
tryToStream<PopCommand>(out, c, d_cvc3Mode) ||
tryToStream<CheckSatCommand>(out, c, d_cvc3Mode) ||
tryToStream<QueryCommand>(out, c, d_cvc3Mode) ||
+ tryToStream<ResetCommand>(out, c, d_cvc3Mode) ||
tryToStream<QuitCommand>(out, c, d_cvc3Mode) ||
tryToStream<DeclarationSequence>(out, c, d_cvc3Mode) ||
tryToStream<CommandSequence>(out, c, d_cvc3Mode) ||
}
}
+static void toStream(std::ostream& out, const ResetCommand* c, bool cvc3Mode) throw() {
+ out << "RESET;";
+}
+
static void toStream(std::ostream& out, const QuitCommand* c, bool cvc3Mode) throw() {
//out << "EXIT;";
}
tryToStream<PopCommand>(out, c) ||
tryToStream<CheckSatCommand>(out, c) ||
tryToStream<QueryCommand>(out, c) ||
+ tryToStream<ResetCommand>(out, c) ||
tryToStream<QuitCommand>(out, c) ||
tryToStream<DeclarationSequence>(out, c) ||
tryToStream<CommandSequence>(out, c) ||
}
}
+static void toStream(std::ostream& out, const ResetCommand* c) throw() {
+ out << "(reset)";
+}
+
static void toStream(std::ostream& out, const QuitCommand* c) throw() {
out << "(exit)";
}
}
}
+void SmtEngine::reset() throw() {
+ SmtScope smts(this);
+ ExprManager *em = d_exprManager;
+ Trace("smt") << "SMT reset()" << endl;
+ if(Dump.isOn("benchmark")) {
+ Dump("benchmark") << ResetCommand();
+ }
+ this->~SmtEngine();
+ new(this) SmtEngine(em);
+}
+
+void SmtEngine::resetAssertions() throw() {
+ SmtScope smts(this);
+
+ while(!d_userLevels.empty()) {
+ pop();
+ }
+
+ // Also remember the global push/pop around everything.
+ Assert(d_userLevels.size() == 0 && d_userContext->getLevel() == 1);
+ d_context->popto(0);
+ d_userContext->popto(0);
+ d_modelGlobalCommands.clear();
+ d_userContext->push();
+ d_context->push();
+}
+
void SmtEngine::interrupt() throw(ModalException) {
if(!d_fullyInited) {
return;
*/
void pop() throw(ModalException);
+ /**
+ * Completely reset the state of the solver, as though destroyed and
+ * recreated. The result is as if newly constructed (so it still
+ * retains the same options structure and ExprManager).
+ */
+ void reset() throw();
+
+ /**
+ * Reset all assertions, global declarations, etc.
+ */
+ void resetAssertions() throw();
+
/**
* Interrupt a running query. This can be called from another thread
* or from a signal handler. Throws a ModalException if the SmtEngine