namespace CVC4 {
- DecisionEngine::DecisionEngine(context::Context *sc,
+DecisionEngine::DecisionEngine(context::Context *sc,
context::Context *uc) :
d_enabledStrategies(),
d_needIteSkolemMap(),
d_satSolver(NULL),
d_satContext(sc),
d_userContext(uc),
- d_result(sc, SAT_VALUE_UNKNOWN)
+ d_result(sc, SAT_VALUE_UNKNOWN),
+ d_engineState(0)
{
- const Options* options = Options::current();
Trace("decision") << "Creating decision engine" << std::endl;
+}
+
+void DecisionEngine::init()
+{
+ Assert(d_engineState == 0);
+ d_engineState = 1;
+ const Options* options = Options::current();
if(options->incrementalSolving) return;
if(options->decisionMode == Options::DECISION_STRATEGY_INTERNAL) { }
}
}
+
void DecisionEngine::enableStrategy(DecisionStrategy* ds)
{
d_enabledStrategies.push_back(ds);
// Disable creating decision engine without required parameters
DecisionEngine() : d_result(NULL) {}
+
+ // init/shutdown state
+ unsigned d_engineState; // 0=pre-init; 1=init,pre-shutdown; 2=shutdown
public:
// Necessary functions
- /** Constructor, enables decision stragies based on options */
+ /** Constructor */
DecisionEngine(context::Context *sc, context::Context *uc);
/** Destructor, currently does nothing */
d_cnfStream = cs;
}
+ /* enables decision stragies based on options */
+ void init();
+
+ /**
+ * This is called by SmtEngine, at shutdown time, just before
+ * destruction. It is important because there are destruction
+ * ordering issues between some parts of the system. For now,
+ * there's nothing to do here in the DecisionEngine.
+ */
+ void shutdown() {
+ Assert(d_engineState == 1);
+ d_engineState = 2;
+
+ Trace("decision") << "Shutting down decision engine" << std::endl;
+ }
// Interface for External World to use our services
d_result = val;
}
- /**
- * This is called by SmtEngine, at shutdown time, just before
- * destruction. It is important because there are destruction
- * ordering issues between some parts of the system. For now,
- * there's nothing to do here in the DecisionEngine.
- */
- void shutdown() {
- Trace("decision") << "Shutting down decision engine" << std::endl;
- }
-
-
// External World helping us help the Strategies
/** If one of the enabled strategies needs them */
StatisticsRegistry::registerStat(&d_numAssertionsPre);
StatisticsRegistry::registerStat(&d_numAssertionsPost);
- // We have mutual dependency here, so we add the prop engine to the theory
- // engine later (it is non-essential there)
- d_theoryEngine = new TheoryEngine(d_context, d_userContext, const_cast<const LogicInfo&>(d_logic));
-
- // Add the theories
-#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
-#undef CVC4_FOR_EACH_THEORY_STATEMENT
-#endif
-#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
- d_theoryEngine->addTheory<theory::TheoryTraits<THEORY>::theory_class>(THEORY);
- CVC4_FOR_EACH_THEORY;
-
- d_decisionEngine = new DecisionEngine(d_context, d_userContext);
- d_propEngine = new PropEngine(d_theoryEngine, d_decisionEngine, d_context);
- d_theoryEngine->setPropEngine(d_propEngine);
- d_theoryEngine->setDecisionEngine(d_decisionEngine);
- // d_decisionEngine->setPropEngine(d_propEngine);
-
// global push/pop around everything, to ensure proper destruction
// of context-dependent data structures
d_userContext->push();
}
}
+void SmtEngine::finishInit() {
+ // We have mutual dependency here, so we add the prop engine to the theory
+ // engine later (it is non-essential there)
+ d_theoryEngine = new TheoryEngine(d_context, d_userContext, const_cast<const LogicInfo&>(d_logic));
+
+ // Add the theories
+#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
+#undef CVC4_FOR_EACH_THEORY_STATEMENT
+#endif
+#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
+ d_theoryEngine->addTheory<theory::TheoryTraits<THEORY>::theory_class>(THEORY);
+ CVC4_FOR_EACH_THEORY;
+
+ d_decisionEngine = new DecisionEngine(d_context, d_userContext);
+ d_propEngine = new PropEngine(d_theoryEngine, d_decisionEngine, d_context);
+ d_theoryEngine->setPropEngine(d_propEngine);
+ d_theoryEngine->setDecisionEngine(d_decisionEngine);
+ // d_decisionEngine->setPropEngine(d_propEngine);
+}
+
void SmtEngine::finalOptionsAreSet() {
if(d_fullyInited) {
return;
}
+ finishInit(); // finish initalization, creating prop
+ // engine etc.
+
AlwaysAssert( d_propEngine->getAssertionLevel() == 0,
"The PropEngine has pushed but the SmtEngine "
"hasn't finished initializing!" );
d_fullyInited = true;
d_logic.lock();
+ d_decisionEngine->init();
+
d_propEngine->assertFormula(NodeManager::currentNM()->mkConst<bool>(true));
d_propEngine->assertFormula(NodeManager::currentNM()->mkConst<bool>(false).notNode());
}
d_needPostsolve = false;
}
- d_propEngine->shutdown();
- d_theoryEngine->shutdown();
- d_decisionEngine->shutdown();
+ if(d_propEngine != NULL) d_propEngine->shutdown();
+ if(d_theoryEngine != NULL) d_theoryEngine->shutdown();
+ if(d_decisionEngine != NULL) d_decisionEngine->shutdown();
}
SmtEngine::~SmtEngine() throw() {
if (NodeManager::currentNM()->getOptions()->arithRewriteEq) {
d_earlyTheoryPP = false;
}
+ // Turn on justification heuristic of the decision engine for QF_BV and QF_AUFBV
+ if(! Options::current()->repeatSimpSetByUser) {
+ Options::DecisionMode decMode =
+ //QF_BV
+ ( !d_logic.isQuantified() &&
+ d_logic.isPure(theory::THEORY_BV)
+ ) ||
+ //QF_AUFBV
+ (!d_logic.isQuantified() &&
+ d_logic.isTheoryEnabled(theory::THEORY_ARRAY) &&
+ d_logic.isTheoryEnabled(theory::THEORY_UF) &&
+ d_logic.isTheoryEnabled(theory::THEORY_BV)
+ )
+ ? Options::DECISION_STRATEGY_JUSTIFICATION
+ : Options::DECISION_STRATEGY_INTERNAL;
+ Trace("smt") << "setting decision mode to " << decMode << std::endl;
+ NodeManager::currentNM()->getOptions()->decisionMode = decMode;
+ }
+
}
void SmtEngine::setInfo(const std::string& key, const SExpr& value)