d_logic(""),
d_problemExtended(false),
d_queryMade(false),
+ d_needPostsolve(false),
d_timeBudgetCumulative(0),
d_timeBudgetPerCall(0),
d_resourceBudgetCumulative(0),
if(Dump.isOn("benchmark")) {
Dump("benchmark") << QuitCommand() << endl;
}
+
+ // check to see if a postsolve() is pending
+ if(d_needPostsolve) {
+ d_theoryEngine->postsolve();
+ d_needPostsolve = false;
+ }
+
d_propEngine->shutdown();
d_theoryEngine->shutdown();
}
ensureBoolean(e);
}
+ // check to see if a postsolve() is pending
+ if(d_needPostsolve) {
+ d_theoryEngine->postsolve();
+ d_needPostsolve = false;
+ }
+
// Push the context
internalPush();
// Run the check
Result r = check().asSatisfiabilityResult();
+ d_needPostsolve = true;
// Dump the query if requested
if(Dump.isOn("benchmark")) {
// Ensure that the expression is type-checked at this point, and Boolean
ensureBoolean(e);
+ // check to see if a postsolve() is pending
+ if(d_needPostsolve) {
+ d_theoryEngine->postsolve();
+ d_needPostsolve = false;
+ }
+
// Push the context
internalPush();
// Run the check
Result r = check().asValidityResult();
+ d_needPostsolve = true;
// Dump the query if requested
if(Dump.isOn("benchmark")) {
if(!Options::current()->incrementalSolving) {
throw ModalException("Cannot push when not solving incrementally (use --incremental)");
}
+
+ // check to see if a postsolve() is pending
+ if(d_needPostsolve) {
+ d_theoryEngine->postsolve();
+ d_needPostsolve = false;
+ }
+
d_userLevels.push_back(d_userContext->getLevel());
internalPush();
Trace("userpushpop") << "SmtEngine: pushed to level "
if(d_userContext->getLevel() == 0) {
throw ModalException("Cannot pop beyond the first user frame");
}
+
+ // check to see if a postsolve() is pending
+ if(d_needPostsolve) {
+ d_theoryEngine->postsolve();
+ d_needPostsolve = false;
+ }
+
AlwaysAssert(d_userLevels.size() > 0 && d_userLevels.back() < d_userContext->getLevel());
while (d_userLevels.back() < d_userContext->getLevel()) {
internalPop();
*/
bool d_queryMade;
+ /**
+ * Internal status flag to indicate whether we've sent a theory
+ * presolve() notification and need to match it with a postsolve().
+ */
+ bool d_needPostsolve;
+
/** A user-imposed cumulative time budget, in milliseconds. 0 = no limit. */
unsigned long d_timeBudgetCumulative;
/** A user-imposed per-call time budget, in milliseconds. 0 = no limit. */
theory_has_staticLearning="false"
theory_has_notifyRestart="false"
theory_has_presolve="false"
+theory_has_postsolve="false"
theory_stable_infinite="false"
theory_finite="false"
static const bool hasStaticLearning = ${theory_has_staticLearning};
static const bool hasNotifyRestart = ${theory_has_notifyRestart};
static const bool hasPresolve = ${theory_has_presolve};
+ static const bool hasPostsolve = ${theory_has_postsolve};
};/* struct TheoryTraits<${theory_id}> */
"
# warnings about theory content and properties
dir="$(dirname "$kf")/../../"
if [ -e "$dir/$theory_header" ]; then
- for function in check propagate staticLearning notifyRestart presolve; do
+ for function in check propagate staticLearning notifyRestart presolve postsolve; do
if eval "\$theory_has_$function"; then
grep '\<'"$function"' *\((\|;\)' "$dir/$theory_header" | grep -vq '^ */\(/\|\*\)' ||
echo "$kf: warning: $theory_class has property \"$function\" in its kinds file but doesn't appear to declare the function" >&2
theory_has_staticLearning="false"
theory_has_notifyRestart="false"
theory_has_presolve="false"
+ theory_has_postsolve="false"
theory_stable_infinite="false"
theory_finite="false"
propagate) theory_has_propagate="true";;
staticLearning) theory_has_staticLearning="true";;
presolve) theory_has_presolve="true";;
+ postsolve) theory_has_postsolve="true";;
notifyRestart) theory_has_notifyRestart="true";;
*) echo "$kf:$lineno: error: unknown theory property \"$property\"" >&2; exit 1;;
esac
*/
virtual void presolve() { }
+ /**
+ * A Theory is called with postsolve exactly one time per user
+ * check-sat. postsolve() is called after the query has completed
+ * (regardless of whether sat, unsat, or unknown), and after any
+ * model-querying related to the query has been performed.
+ * After this call, the theory will not get another check() or
+ * propagate() call until presolve() is called again. A Theory
+ * cannot raise conflicts, add lemmas, or propagate literals during
+ * postsolve().
+ */
+ virtual void postsolve() { }
+
/**
* Notification sent to the theory wheneven the search restarts.
* Serves as a good time to do some clean-up work, and you can
}
// return whether we have a conflict
return false;
-}
+}/* TheoryEngine::presolve() */
+
+void TheoryEngine::postsolve() {
+ // NOTE that we don't look at d_theoryIsActive[] here (for symmetry
+ // with presolve()).
+
+ try {
+ // Definition of the statement that is to be run by every theory
+#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
+#undef CVC4_FOR_EACH_THEORY_STATEMENT
+#endif
+#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
+ if (theory::TheoryTraits<THEORY>::hasPostsolve) { \
+ reinterpret_cast<theory::TheoryTraits<THEORY>::theory_class*>(theoryOf(THEORY))->postsolve(); \
+ Assert(! d_inConflict, "conflict raised during postsolve()"); \
+ }
+
+ // Postsolve for each theory using the statement above
+ CVC4_FOR_EACH_THEORY;
+ } catch(const theory::Interrupted&) {
+ Trace("theory") << "TheoryEngine::postsolve() => interrupted" << endl;
+ }
+}/* TheoryEngine::postsolve() */
void TheoryEngine::notifyRestart() {
*/
bool presolve();
+ /**
+ * Calls postsolve() on all active theories.
+ */
+ void postsolve();
+
/**
* Calls notifyRestart() on all active theories.
*/