#include "theory/ee_manager_central.h"
+#include "options/arith_options.h"
+#include "options/theory_options.h"
#include "smt/env.h"
#include "theory/quantifiers_engine.h"
#include "theory/shared_solver.h"
std::map<TheoryId, EeSetupInfo> esiMap;
// set of theories that need equality engines
std::unordered_set<TheoryId> eeTheories;
- const LogicInfo& logicInfo = d_te.getLogicInfo();
+ const LogicInfo& linfo = logicInfo();
for (TheoryId theoryId = theory::THEORY_FIRST;
theoryId != theory::THEORY_LAST;
++theoryId)
// if the logic has a theory that does not use central equality engine,
// we can't use the central equality engine for the master equality
// engine
- if (theoryId != THEORY_QUANTIFIERS && logicInfo.isTheoryEnabled(theoryId)
- && !Theory::usesCentralEqualityEngine(theoryId))
+ if (theoryId != THEORY_QUANTIFIERS && linfo.isTheoryEnabled(theoryId)
+ && !usesCentralEqualityEngine(options(), theoryId))
{
Trace("ee-central") << "Must use separate master equality engine due to "
<< theoryId << std::endl;
// initialize the master equality engine, which may be the central equality
// engine
- if (logicInfo.isQuantified())
+ if (linfo.isQuantified())
{
// construct the master equality engine
Assert(d_masterEqualityEngine == nullptr);
eq::EqualityEngineNotify* notify = esi.d_notify;
d_theoryNotify[theoryId] = notify;
// split on whether integrated, or whether asked for master
- if (t->usesCentralEqualityEngine())
+ if (usesCentralEqualityEngine(options(), t->getId()))
{
Trace("ee-central") << "...uses central" << std::endl;
// the theory uses the central equality engine
eet.d_usedEe = &d_centralEqualityEngine;
- if (logicInfo.isTheoryEnabled(theoryId))
+ if (linfo.isTheoryEnabled(theoryId))
{
// add to vectors for the kinds of notifications
if (esi.needsNotifyNewClass())
}
}
+bool EqEngineManagerCentral::usesCentralEqualityEngine(const Options& opts,
+ TheoryId id)
+{
+ Assert(opts.theory.eeMode == options::EqEngineMode::CENTRAL);
+ if (id == THEORY_BUILTIN)
+ {
+ return true;
+ }
+ if (id == THEORY_ARITH)
+ {
+ // conditional on whether we are using the equality solver
+ return opts.arith.arithEqSolver;
+ }
+ return id == THEORY_UF || id == THEORY_DATATYPES || id == THEORY_BAGS
+ || id == THEORY_FP || id == THEORY_SETS || id == THEORY_STRINGS
+ || id == THEORY_SEP || id == THEORY_ARRAYS || id == THEORY_BV;
+}
+
void EqEngineManagerCentral::notifyBuildingModel() {}
EqEngineManagerCentral::CentralNotifyClass::CentralNotifyClass(
#include "smt/logic_exception.h"
#include "theory/combination_care_graph.h"
#include "theory/decision_manager.h"
+#include "theory/ee_manager_central.h"
#include "theory/partition_generator.h"
#include "theory/quantifiers/first_order_model.h"
#include "theory/quantifiers_engine.h"
#endif
#define CVC5_FOR_EACH_THEORY_STATEMENT(THEORY) \
if (theory::TheoryTraits<THEORY>::isParametric \
- && d_logicInfo.isTheoryEnabled(THEORY)) \
+ && isTheoryEnabled(THEORY)) \
{ \
paraTheories.push_back(theoryOf(THEORY)); \
}
}
// initialize the quantifiers engine
- if (d_logicInfo.isQuantified())
+ if (logicInfo().isQuantified())
{
// get the quantifiers engine, which is initialized by the quantifiers
// theory
// finish initializing the quantifiers engine, which must come before
// initializing theory combination, since quantifiers engine may have a
// special model builder object
- if (d_logicInfo.isQuantified())
+ if (logicInfo().isQuantified())
{
d_quantEngine->finishInit(this);
}
TheoryEngine::TheoryEngine(Env& env)
: EnvObj(env),
d_propEngine(nullptr),
- d_logicInfo(env.getLogicInfo()),
d_pnm(d_env.isTheoryProofProducing() ? d_env.getProofNodeManager()
: nullptr),
d_lazyProof(
for (TheoryId theoryId = THEORY_FIRST; theoryId < THEORY_LAST; ++theoryId) {
Theory* theory = d_theoryTable[theoryId];
- if (theory && d_logicInfo.isTheoryEnabled(theoryId)) {
+ if (theory && isTheoryEnabled(theoryId))
+ {
Trace(tag) << "--------------------------------------------" << endl;
Trace(tag) << "Assertions of " << theory->getId() << ": " << endl;
{
}
}
- if (d_logicInfo.isSharingEnabled()) {
+ if (logicInfo().isSharingEnabled())
+ {
Trace(tag) << "Shared terms of " << theory->getId() << ": " << endl;
context::CDList<TNode>::const_iterator
it = theory->shared_terms_begin(),
#endif
#define CVC5_FOR_EACH_THEORY_STATEMENT(THEORY) \
if (theory::TheoryTraits<THEORY>::hasCheck \
- && d_logicInfo.isTheoryEnabled(THEORY)) \
+ && isTheoryEnabled(THEORY)) \
{ \
theoryOf(THEORY)->check(effort); \
if (d_inConflict) \
propagate(effort);
// We do combination if all has been processed and we are in fullcheck
- if (Theory::fullEffort(effort) && d_logicInfo.isSharingEnabled()
+ if (Theory::fullEffort(effort) && logicInfo().isSharingEnabled()
&& !d_factsAsserted && !needCheck() && !d_inConflict)
{
// Do the combination
TimerStat::CodeTimer combineTheoriesTimer(d_combineTheoriesTime);
d_tc->combineTheories();
}
- if(d_logicInfo.isQuantified()){
+ if (logicInfo().isQuantified())
+ {
d_quantEngine->notifyCombineTheories();
}
}
for (TheoryId theoryId = THEORY_FIRST; theoryId < THEORY_LAST; ++theoryId) {
if( theoryId!=THEORY_QUANTIFIERS ){
Theory* theory = d_theoryTable[theoryId];
- if (theory && d_logicInfo.isTheoryEnabled(theoryId)) {
+ if (theory && isTheoryEnabled(theoryId))
+ {
if( theory->needsCheckLastEffort() ){
if (!d_tc->buildModel())
{
}
if (!d_inConflict)
{
- if(d_logicInfo.isQuantified()) {
+ if (logicInfo().isQuantified())
+ {
// quantifiers engine must check at last call effort
d_quantEngine->check(Theory::EFFORT_LAST_CALL);
}
#endif
#define CVC5_FOR_EACH_THEORY_STATEMENT(THEORY) \
if (theory::TheoryTraits<THEORY>::hasPropagate \
- && d_logicInfo.isTheoryEnabled(THEORY)) \
+ && isTheoryEnabled(THEORY)) \
{ \
theoryOf(THEORY)->propagate(effort); \
}
return d_tc->buildModel();
}
+bool TheoryEngine::isTheoryEnabled(theory::TheoryId theoryId) const
+{
+ return logicInfo().isTheoryEnabled(theoryId);
+}
+
+theory::TheoryId TheoryEngine::theoryExpPropagation(theory::TheoryId tid) const
+{
+ if (options().theory.eeMode == options::EqEngineMode::CENTRAL)
+ {
+ if (EqEngineManagerCentral::usesCentralEqualityEngine(options(), tid)
+ && Theory::expUsingCentralEqualityEngine(tid))
+ {
+ return THEORY_BUILTIN;
+ }
+ }
+ return tid;
+}
+
bool TheoryEngine::presolve() {
// Reset the interrupt flag
d_interrupted = false;
#endif
#define CVC5_FOR_EACH_THEORY_STATEMENT(THEORY) \
if (theory::TheoryTraits<THEORY>::hasNotifyRestart \
- && d_logicInfo.isTheoryEnabled(THEORY)) \
+ && isTheoryEnabled(THEORY)) \
{ \
theoryOf(THEORY)->notifyRestart(); \
}
Trace("theory::solve") << "TheoryEngine::solve(" << literal << "): solving with " << theoryOf(atom)->getId() << endl;
theory::TheoryId tid = d_env.theoryOf(atom);
- if (!d_logicInfo.isTheoryEnabled(tid) && tid != THEORY_SAT_SOLVER)
+ if (!isTheoryEnabled(tid) && tid != THEORY_SAT_SOLVER)
{
stringstream ss;
- ss << "The logic was specified as " << d_logicInfo.getLogicString()
+ ss << "The logic was specified as " << logicInfo().getLogicString()
<< ", which doesn't include " << tid
<< ", but got a preprocessing-time fact for that theory." << endl
<< "The fact:" << endl
Trace("theory::assertToTheory") << "TheoryEngine::assertToTheory(" << assertion << ", " << originalAssertion << "," << toTheoryId << ", " << fromTheoryId << ")" << endl;
Assert(toTheoryId != fromTheoryId);
- if(toTheoryId != THEORY_SAT_SOLVER &&
- ! d_logicInfo.isTheoryEnabled(toTheoryId)) {
+ if (toTheoryId != THEORY_SAT_SOLVER
+ && !isTheoryEnabled(toTheoryId))
+ {
stringstream ss;
- ss << "The logic was specified as " << d_logicInfo.getLogicString()
+ ss << "The logic was specified as " << logicInfo().getLogicString()
<< ", which doesn't include " << toTheoryId
<< ", but got an asserted fact to that theory." << endl
<< "The fact:" << endl
}
// If sharing is disabled, things are easy
- if (!d_logicInfo.isSharingEnabled()) {
+ if (!logicInfo().isSharingEnabled())
+ {
Assert(assertion == originalAssertion);
if (fromTheoryId == THEORY_SAT_SOLVER) {
// Send to the apropriate theory
// determine the actual theory that will process/explain the fact, which is
// THEORY_BUILTIN if the theory uses the central equality engine
- TheoryId toTheoryIdProp = (Theory::expUsingCentralEqualityEngine(toTheoryId))
- ? THEORY_BUILTIN
- : toTheoryId;
+ TheoryId toTheoryIdProp = theoryExpPropagation(toTheoryId);
// If sending to the shared solver, it's also simple
if (toTheoryId == THEORY_BUILTIN) {
if (markPropagation(
bool polarity = literal.getKind() != kind::NOT;
TNode atom = polarity ? literal : literal[0];
- if (d_logicInfo.isSharingEnabled()) {
+ if (logicInfo().isSharingEnabled())
+ {
// If any shared terms, it's time to do sharing work
d_sharedSolver->preNotifySharedFact(atom);
/* to */ d_env.theoryOf(atom),
/* from */ THEORY_SAT_SOLVER);
}
- } else {
+ }
+ else
+ {
// Assert the fact to the appropriate theory directly
assertToTheory(literal,
literal,
bool polarity = literal.getKind() != kind::NOT;
TNode atom = polarity ? literal : literal[0];
- if (d_logicInfo.isSharingEnabled() && atom.getKind() == kind::EQUAL) {
+ if (logicInfo().isSharingEnabled() && atom.getKind() == kind::EQUAL)
+ {
if (d_propEngine->isSatLiteral(literal)) {
// We propagate SAT literals to SAT
assertToTheory(literal, literal, /* to */ THEORY_SAT_SOLVER, /* from */ theory);
// Assert to the shared terms database
assertToTheory(literal, literal, /* to */ THEORY_BUILTIN, /* from */ theory);
}
- } else {
+ }
+ else
+ {
// Just send off to the SAT solver
Assert(d_propEngine->isSatLiteral(literal));
assertToTheory(literal, literal, /* to */ THEORY_SAT_SOLVER, /* from */ theory);
return !d_inConflict;
}
-const LogicInfo& TheoryEngine::getLogicInfo() const { return d_logicInfo; }
-
theory::EqualityStatus TheoryEngine::getEqualityStatus(TNode a, TNode b)
{
Assert(a.getType() == b.getType());
TNode atom = polarity ? node : node[0];
// If we're not in shared mode, explanations are simple
- if (!d_logicInfo.isSharingEnabled())
+ if (!logicInfo().isSharingEnabled())
{
Trace("theory::explain")
<< "TheoryEngine::getExplanation: sharing is NOT enabled. "
markInConflict();
// In the multiple-theories case, we need to reconstruct the conflict
- if (d_logicInfo.isSharingEnabled()) {
+ if (logicInfo().isSharingEnabled())
+ {
// Create the workplace for explanations
std::vector<NodeTheoryPair> vec;
vec.push_back(
tconf.debugCheckClosed("te-proof-debug", "TheoryEngine::conflict:sharing");
}
lemma(tconf, LemmaProperty::REMOVABLE);
- } else {
+ }
+ else
+ {
// When only one theory, the conflict should need no processing
Assert(properConflict(conflict));
// pass the trust node that was sent from the theory
Node conclusion = explanationVector[0].d_node;
// if the theory explains using the central equality engine, we always start
// with THEORY_BUILTIN.
- if (Theory::expUsingCentralEqualityEngine(explanationVector[0].d_theory))
- {
- explanationVector[0].d_theory = THEORY_BUILTIN;
- }
+ explanationVector[0].d_theory =
+ theoryExpPropagation(explanationVector[0].d_theory);
std::shared_ptr<LazyCDProof> lcp;
if (isProofEnabled())
{
}
for(TheoryId theoryId = THEORY_FIRST; theoryId < THEORY_LAST; ++theoryId) {
Theory* theory = d_theoryTable[theoryId];
- if(theory && d_logicInfo.isTheoryEnabled(theoryId)) {
+ if (theory && isTheoryEnabled(theoryId))
+ {
for (context::CDList<Assertion>::const_iterator
it = theory->facts_begin(),
it_end = theory->facts_end();