return false;
}
- Theory::Set theories;
-
TheoryId currentTheoryId = Theory::theoryOf(current);
TheoryId parentTheoryId = Theory::theoryOf(parent);
- // Remember the theories interested in this term
- d_theories[parent] = theories = Theory::setInsert(currentTheoryId, d_theories[parent]);
- // Check if there are multiple of those
- d_multipleTheories = d_multipleTheories || Theory::setRemove(parentTheoryId, theories);
+ d_theories = Theory::setInsert(currentTheoryId, d_theories);
+ d_theories = Theory::setInsert(parentTheoryId, d_theories);
- theories = (*find).second;
- if (Theory::setContains(currentTheoryId, theories)) {
+ Theory::Set visitedTheories = (*find).second;
+ if (Theory::setContains(currentTheoryId, visitedTheories)) {
// The current theory has already visited it, so now it depends on the parent
- Debug("register::internal") << (Theory::setContains(parentTheoryId, theories) ? "2:true" : "2:false") << std::endl;
- return Theory::setContains(parentTheoryId, theories);
+ Debug("register::internal") << (Theory::setContains(parentTheoryId, visitedTheories) ? "2:true" : "2:false") << std::endl;
+ return Theory::setContains(parentTheoryId, visitedTheories);
} else {
// If the current theory is not registered, it still needs to be visited
Debug("register::internal") << "3:false" << std::endl;
void PreRegisterVisitor::visit(TNode current, TNode parent) {
- Theory::Set theories;
-
Debug("register") << "PreRegisterVisitor::visit(" << current << "," << parent << ")" << std::endl;
if (Debug.isOn("register::internal")) {
Debug("register::internal") << toString() << std::endl;
TheoryId currentTheoryId = Theory::theoryOf(current);
TheoryId parentTheoryId = Theory::theoryOf(parent);
- // Remember the theories interested in this term
- d_theories[parent] = theories = Theory::setInsert(currentTheoryId, d_theories[parent]);
- // If there are theories other than the parent itself, we are in multi-theory case
- d_multipleTheories = d_multipleTheories || Theory::setRemove(parentTheoryId, theories);
-
- theories = d_visited[current];
- Debug("register::internal") << "PreRegisterVisitor::visit(" << current << "," << parent << "): previously registered with " << Theory::setToString(theories) << std::endl;
- if (!Theory::setContains(currentTheoryId, theories)) {
- d_visited[current] = theories = Theory::setInsert(currentTheoryId, theories);
+ Theory::Set visitedTheories = d_visited[current];
+ Debug("register::internal") << "PreRegisterVisitor::visit(" << current << "," << parent << "): previously registered with " << Theory::setToString(visitedTheories) << std::endl;
+ if (!Theory::setContains(currentTheoryId, visitedTheories)) {
+ visitedTheories = Theory::setInsert(currentTheoryId, visitedTheories);
+ d_visited[current] = visitedTheories;
d_engine->theoryOf(currentTheoryId)->preRegisterTerm(current);
Debug("register::internal") << "PreRegisterVisitor::visit(" << current << "," << parent << "): adding " << currentTheoryId << std::endl;
}
- if (!Theory::setContains(parentTheoryId, theories)) {
- d_visited[current] = theories = Theory::setInsert(parentTheoryId, theories);
+ if (!Theory::setContains(parentTheoryId, visitedTheories)) {
+ visitedTheories = Theory::setInsert(parentTheoryId, visitedTheories);
+ d_visited[current] = visitedTheories;
d_engine->theoryOf(parentTheoryId)->preRegisterTerm(current);
Debug("register::internal") << "PreRegisterVisitor::visit(" << current << "," << parent << "): adding " << parentTheoryId << std::endl;
}
- Debug("register::internal") << "PreRegisterVisitor::visit(" << current << "," << parent << "): now registered with " << Theory::setToString(theories) << std::endl;
+ Debug("register::internal") << "PreRegisterVisitor::visit(" << current << "," << parent << "): now registered with " << Theory::setToString(visitedTheories) << std::endl;
Assert(d_visited.find(current) != d_visited.end());
Assert(alreadyVisited(current, parent));
}
bool PreRegisterVisitor::done(TNode node) {
-// <<<<<<< .working
-// d_engine->markActive(d_theories[node]);
-// =======
-// >>>>>>> .merge-right.r3396
- return d_multipleTheories;
+ // We have multiple theories if removing the node theory from others is non-empty
+ return Theory::setRemove(Theory::theoryOf(node), d_theories);
}
std::string SharedTermsVisitor::toString() const {
class TheoryEngine;
/**
- * Visitor that calls the apropriate theory to preregister the term.
+ * Visitor that calls the appropriate theory to pre-register the term. The visitor also keeps track
+ * of the sets of theories that are involved in the terms, so that it can say if there are multiple
+ * theories involved.
+ *
+ * A sub-term has been visited if the theories of both the parent and the term itself have already
+ * visited this term.
+ *
+ * Computation of the set of theories in the original term are computed in the alreadyVisited method
+ * so as no to skip any theories.
*/
class PreRegisterVisitor {
TNodeToTheorySetMap d_visited;
/**
- * Map from terms to the theories that have have a sub-term in it.
+ * A set of all theories in the term
*/
- TNodeToTheorySetMap d_theories;
+ theory::Theory::Set d_theories;
/**
* Is true if the term we're traversing involves multiple theories.
PreRegisterVisitor(TheoryEngine* engine, context::Context* context)
: d_engine(engine)
, d_visited(context)
- , d_theories(context)
+ , d_theories(0)
, d_multipleTheories(false)
{}
if(Dump.isOn("missed-t-propagations")) {
d_possiblePropagations.push_back(preprocessed);
}
- //<<<<<<< .working
d_preregisterQueue.push(preprocessed);
if (!d_inPreregister) {
if (multipleTheories) {
// Collect the shared terms if there are multipe theories
NodeVisitor<SharedTermsVisitor>::run(d_sharedTermsVisitor, preprocessed);
- // Mark the multiple theories flag
- //d_sharedTermsExist = true;
}
}
+
// Leaving pre-register
d_inPreregister = false;
}
-// =======
- // Pre-register the terms in the atom
- // bool multipleTheories = NodeVisitor<PreRegisterVisitor>::run(d_preRegistrationVisitor, preprocessed);
- // if (multipleTheories) {
- // // Collect the shared terms if there are multipe theories
- // NodeVisitor<SharedTermsVisitor>::run(d_sharedTermsVisitor, preprocessed);
- // //>>>>>>> .merge-right.r3396
- // }
}
void TheoryEngine::printAssertions(const char* tag) {