toSatClause(clause, satClause);
d_notify->notify(satClause);
}
+
+ void safePoint() {
+ d_notify->safePoint();
+ }
};
BVMinisat::SimpSolver* d_minisat;
#include "util/output.h"
#include "util/utility.h"
-
+#include "util/exception.h"
#include "theory/bv/options.h"
-
+#include "theory/interrupted.h"
using namespace BVMinisat;
namespace CVC4 {
}else{
// NO CONFLICT
- if (decisionLevel() > assumptions.size() && nof_conflicts >= 0 && conflictC >= nof_conflicts || !withinBudget()){
+ bool isWithinBudget;
+ try {
+ isWithinBudget = withinBudget();
+ }
+ catch (const CVC4::theory::Interrupted& e) {
+ // do some clean-up and rethrow
+ cancelUntil(assumptions.size());
+ throw e;
+ }
+
+ if (decisionLevel() > assumptions.size() && nof_conflicts >= 0 && conflictC >= nof_conflicts ||
+ !isWithinBudget) {
// Reached bound on number of conflicts:
Debug("bvminisat::search") << OUTPUT_TAG << " restarting " << std::endl;
progress_estimate = progressEstimate();
cancelUntil(assumptions.size());
- return l_Undef; }
-
+ return l_Undef;
+ }
+
// Simplify the set of problem clauses:
if (decisionLevel() == 0 && !simplify()) {
Debug("bvminisat::search") << OUTPUT_TAG << " base level conflict, we're unsat" << std::endl;
*/
virtual void notify(vec<Lit>& learnt) = 0;
+ virtual void safePoint() = 0;
};
//=================================================================================================
inline void Solver::clearInterrupt(){ asynch_interrupt = false; }
inline void Solver::budgetOff(){ conflict_budget = propagation_budget = -1; }
inline bool Solver::withinBudget() const {
+ Assert (notify);
+ notify->safePoint();
return !asynch_interrupt &&
(conflict_budget < 0 || conflicts < (uint64_t)conflict_budget) &&
(propagation_budget < 0 || propagations < (uint64_t)propagation_budget); }
d_interrupted = true;
d_satSolver->interrupt();
+ d_theoryEngine->interrupt();
Debug("prop") << "interrupt()" << endl;
}
* Notify about a learnt clause.
*/
virtual void notify(SatClause& clause) = 0;
+ virtual void safePoint() = 0;
+
};/* class BVSatSolverInterface::Notify */
virtual void setNotify(Notify* notify) = 0;
return;
}
d_propEngine->interrupt();
+ d_theoryEngine->interrupt();
}
void SmtEngine::setResourceLimit(unsigned long units, bool cumulative) {
}
};
+void Bitblaster::MinisatNotify::safePoint() {
+ d_bv->d_out->safePoint();
+}
+
EqualityStatus Bitblaster::getEqualityStatus(TNode a, TNode b) {
// We don't want to bit-blast every possibly expensive term for the sake of equality checking
{}
bool notify(prop::SatLiteral lit);
void notify(prop::SatClause& clause);
+ void safePoint();
};
typedef __gnu_cxx::hash_map <Node, Bits, TNodeHashFunction > TermDefMap;
d_propagatedLiterals(context),
d_propagatedLiteralsIndex(context, 0),
d_combineTheoriesTime("TheoryEngine::combineTheoriesTime"),
+ d_interrupted(false),
d_inPreregister(false),
d_factsAsserted(context, false),
d_preRegistrationVisitor(this, context),
StatisticsRegistry::unregisterStat(&d_combineTheoriesTime);
}
+void TheoryEngine::interrupt() throw(ModalException) {
+ d_interrupted = true;
+}
+
void TheoryEngine::preRegister(TNode preprocessed) {
if(Dump.isOn("missed-t-propagations")) {
d_propEngine->checkTime();
+ // Reset the interrupt flag
+ d_interrupted = false;
+
#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
#undef CVC4_FOR_EACH_THEORY_STATEMENT
#endif
} \
}
-
// Do the checking
try {
}
void TheoryEngine::propagate(Theory::Effort effort) {
+ // Reset the interrupt flag
+ d_interrupted = false;
+
// Definition of the statement that is to be run by every theory
#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
#undef CVC4_FOR_EACH_THEORY_STATEMENT
theoryOf(THEORY)->propagate(effort); \
}
+ // Reset the interrupt flag
+ d_interrupted = false;
+
// Propagate for each theory using the statement above
CVC4_FOR_EACH_THEORY;
}
bool TheoryEngine::presolve() {
+ // Reset the interrupt flag
+ d_interrupted = false;
try {
// Definition of the statement that is to be run by every theory
#undef CVC4_FOR_EACH_THEORY_STATEMENT
#endif
#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
- if (theory::TheoryTraits<THEORY>::hasPresolve) { \
+ if (theory::TheoryTraits<THEORY>::hasPresolve) { \
theoryOf(THEORY)->presolve(); \
if(d_inConflict) { \
return true; \
}/* TheoryEngine::presolve() */
void TheoryEngine::postsolve() {
+ // Reset the interrupt flag
+ d_interrupted = false;
try {
// Definition of the statement that is to be run by every theory
void TheoryEngine::notifyRestart() {
+ // Reset the interrupt flag
+ d_interrupted = false;
+
// Definition of the statement that is to be run by every theory
#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
#undef CVC4_FOR_EACH_THEORY_STATEMENT
}
void TheoryEngine::ppStaticLearn(TNode in, NodeBuilder<>& learned) {
+ // Reset the interrupt flag
+ d_interrupted = false;
// Definition of the statement that is to be run by every theory
#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
}
theory::Theory::PPAssertStatus TheoryEngine::solve(TNode literal, SubstitutionMap& substitutionOut) {
+ // Reset the interrupt flag
+ d_interrupted = false;
+
TNode atom = literal.getKind() == kind::NOT ? literal[0] : literal;
Trace("theory::solve") << "TheoryEngine::solve(" << literal << "): solving with " << theoryOf(atom)->getId() << endl;
#include "theory/shared_terms_database.h"
#include "theory/term_registration_visitor.h"
#include "theory/valuation.h"
+#include "theory/interrupted.h"
#include "options/options.h"
#include "smt/options.h"
#include "util/statistics_registry.h"
#include "util/hash.h"
#include "util/cache.h"
+#include "util/cvc4_assert.h"
#include "theory/ite_simplifier.h"
#include "theory/unconstrained_simplifier.h"
#include "theory/model.h"
{
}
+ void safePoint() throw(theory::Interrupted, AssertionException) {
+ if (d_engine->d_interrupted)
+ throw theory::Interrupted();
+ }
+
void conflict(TNode conflictNode) throw(AssertionException) {
Trace("theory::conflict") << "EngineOutputChannel<" << d_theory << ">::conflict(" << conflictNode << ")" << std::endl;
++ d_statistics.conflicts;
Node d_true;
Node d_false;
+ /** Whether we were just interrupted (or not) */
+ bool d_interrupted;
+
public:
/** Constructs a theory engine */
/** Destroys a theory engine */
~TheoryEngine();
+ void interrupt() throw(ModalException);
+
/**
* Adds a theory. Only one theory per TheoryId can be present, so if
* there is another theory it will be deleted.