mv default care graph function inside the theory implementation
authorKshitij Bansal <kshitij@cs.nyu.edu>
Mon, 23 Jun 2014 15:41:23 +0000 (11:41 -0400)
committerKshitij Bansal <kshitij@cs.nyu.edu>
Wed, 25 Jun 2014 17:42:38 +0000 (13:42 -0400)
src/theory/sets/theory_sets.cpp
src/theory/sets/theory_sets.h
src/theory/sets/theory_sets_private.cpp
src/theory/sets/theory_sets_private.h

index c230b9ac56e8b4c21f0a22769ddea07c7767e591..5d5e1f9eeeebb0cf907427e4257a8cf8a5108d0e 100644 (file)
@@ -34,10 +34,6 @@ TheorySets::~TheorySets() {
   delete d_internal;
 }
 
-void TheorySets::setMasterEqualityEngine(eq::EqualityEngine* eq) {
-  d_internal->setMasterEqualityEngine(eq);
-}
-
 void TheorySets::addSharedTerm(TNode n) {
   d_internal->addSharedTerm(n);
 }
@@ -50,8 +46,8 @@ void TheorySets::collectModelInfo(TheoryModel* m, bool fullModel) {
   d_internal->collectModelInfo(m, fullModel);
 }
 
-void TheorySets::propagate(Effort e) {
-  d_internal->propagate(e);
+void TheorySets::computeCareGraph() {
+  d_internal->computeCareGraph();
 }
 
 Node TheorySets::explain(TNode node) {
@@ -59,7 +55,15 @@ Node TheorySets::explain(TNode node) {
 }
 
 void TheorySets::preRegisterTerm(TNode node) {
-  return d_internal->preRegisterTerm(node);
+  d_internal->preRegisterTerm(node);
+}
+
+void TheorySets::propagate(Effort e) {
+  d_internal->propagate(e);
+}
+
+void TheorySets::setMasterEqualityEngine(eq::EqualityEngine* eq) {
+  d_internal->setMasterEqualityEngine(eq);
 }
 
 }/* CVC4::theory::sets namespace */
index 6ff41d5f5092f8e5de96248c31c5824e0da73767..84d91de72b7187cdc9b711b11346ae5dec99261a 100644 (file)
@@ -48,14 +48,14 @@ public:
 
   ~TheorySets();
 
-  void setMasterEqualityEngine(eq::EqualityEngine* eq);
-  
   void addSharedTerm(TNode);
 
   void check(Effort);
 
   void collectModelInfo(TheoryModel*, bool fullModel);
 
+  void computeCareGraph();
+
   Node explain(TNode);
 
   std::string identify() const { return "THEORY_SETS"; }
@@ -64,6 +64,8 @@ public:
 
   void propagate(Effort);
 
+  void setMasterEqualityEngine(eq::EqualityEngine* eq);
+
 };/* class TheorySets */
 
 }/* CVC4::theory::sets namespace */
index c06f1bd5ea5fa0fe9946f7003afedd21c27fb281..0a7ecd14e5d00ea1c0e0ebe011adc26a2cdf2c3e 100644 (file)
@@ -408,6 +408,42 @@ void TheorySetsPrivate::learnLiteral(TNode atom, bool polarity, Node reason) {
 }/*TheorySetsPrivate::learnLiteral(...)*/
 
 
+/************************ Sharing ************************/
+/************************ Sharing ************************/
+/************************ Sharing ************************/
+
+void TheorySetsPrivate::addSharedTerm(TNode n) {
+  Debug("sets") << "[sets] ThoerySetsPrivate::addSharedTerm( " << n << ")" << std::endl;
+  d_equalityEngine.addTriggerTerm(n, THEORY_SETS);
+}
+
+
+void TheorySetsPrivate::computeCareGraph() {
+  Debug("sharing") << "Theory::computeCareGraph<" << d_external.identify() << ">()" << endl;
+  for (unsigned i = 0; i < d_external.d_sharedTerms.size(); ++ i) {
+    TNode a = d_external.d_sharedTerms[i];
+    TypeNode aType = a.getType();
+    for (unsigned j = i + 1; j < d_external.d_sharedTerms.size(); ++ j) {
+      TNode b = d_external.d_sharedTerms[j];
+      if (b.getType() != aType) {
+        // We don't care about the terms of different types
+        continue;
+      }
+      switch (d_external.d_valuation.getEqualityStatus(a, b)) {
+      case EQUALITY_TRUE_AND_PROPAGATED:
+      case EQUALITY_FALSE_AND_PROPAGATED:
+        // If we know about it, we should have propagated it, so we can skip
+        break;
+      default:
+        // Let's split on it
+        d_external.addCarePair(a, b);
+        break;
+      }
+    }
+  }
+}
+
+
 /******************** Model generation ********************/
 /******************** Model generation ********************/
 /******************** Model generation ********************/
@@ -886,11 +922,6 @@ void TheorySetsPrivate::setMasterEqualityEngine(eq::EqualityEngine* eq) {
   d_equalityEngine.setMasterEqualityEngine(eq);
 }
 
-void TheorySetsPrivate::addSharedTerm(TNode n) {
-  Debug("sets") << "[sets] ThoerySetsPrivate::addSharedTerm( " << n << ")" << std::endl;
-  d_equalityEngine.addTriggerTerm(n, THEORY_SETS);
-}
-
 void TheorySetsPrivate::conflict(TNode a, TNode b)
 {
   if (a.getKind() == kind::CONST_BOOLEAN) {
index 90dec7c0be1d7d79d64e28bb6591ed035c5a5558..e5d7beb2cd4eb669d23dddf1228beb275b7524aa 100644 (file)
@@ -56,6 +56,8 @@ public:
 
   void collectModelInfo(TheoryModel*, bool fullModel);
 
+  void computeCareGraph();
+
   Node explain(TNode);
 
   void preRegisterTerm(TNode node);