sets stronger equality propagator
authorKshitij Bansal <kshitij@cs.nyu.edu>
Thu, 28 Aug 2014 18:29:00 +0000 (14:29 -0400)
committerKshitij Bansal <kshitij@cs.nyu.edu>
Tue, 7 Oct 2014 22:27:23 +0000 (18:27 -0400)
src/theory/sets/options
src/theory/sets/theory_sets_private.cpp
src/theory/sets/theory_sets_private.h

index 7cb3eb677915a9c6416e8154954f988214bfa449..ac040881a63b7d2d91739c1c369efe60eb0503ea 100644 (file)
@@ -14,4 +14,7 @@ option setsEagerLemmas --sets-eager-lemmas bool :default true
 option setsCare1 --sets-care1 bool :default false
  generate one lemma at a time for care graph
 
+option setsPropFull --sets-prop-full bool :default false
+ agressive propagation
+
 endmodule
index 4125fd193b763c5cf6d3b5359815eb8725aa846f..bfcb477cbd72745539359f579b198ac4c55cd1d6 100644 (file)
@@ -483,9 +483,9 @@ void TheorySetsPrivate::dumpAssertionsHumanified() const
         FORIT(jt, (*kt).second.first) {
           TNode x = (*jt);
           if(x.isConst() || numbering.find(d_equalityEngine.getRepresentative(x)) == numbering.end()) {
-            Trace(tag) << x;
+            Trace(tag) << x << ", ";
           } else {
-            Trace(tag) << "x" << numbering[d_equalityEngine.getRepresentative(x)] << ", ";
+            Trace(tag) << "t" << numbering[d_equalityEngine.getRepresentative(x)] << ", ";
           }
         }
         Trace(tag) << std::endl;
@@ -495,9 +495,9 @@ void TheorySetsPrivate::dumpAssertionsHumanified() const
         FORIT(jt, (*kt).second.second) {
           TNode x = (*jt);
           if(x.isConst() || numbering.find(d_equalityEngine.getRepresentative(x)) == numbering.end()) {
-            Trace(tag) << x;
+            Trace(tag) << x << ", ";
           } else {
-            Trace(tag) << "x" << numbering[d_equalityEngine.getRepresentative(x)] << ", ";
+            Trace(tag) << "t" << numbering[d_equalityEngine.getRepresentative(x)] << ", ";
           }
         }
         Trace(tag) << std::endl;
@@ -515,6 +515,8 @@ void TheorySetsPrivate::computeCareGraph() {
     dumpAssertionsHumanified();
   }
 
+  CVC4_UNUSED unsigned edgesAddedCnt = 0;
+
   unsigned i_st = 0;
   if(options::setsCare1()) { i_st = d_ccg_i; }
   for (unsigned i = i_st; i < d_external.d_sharedTerms.size(); ++ i) {
@@ -546,6 +548,15 @@ void TheorySetsPrivate::computeCareGraph() {
         break;
       case EQUALITY_TRUE_IN_MODEL:
         d_external.addCarePair(a, b);
+        if(Trace.isOn("sharing")) {
+          ++edgesAddedCnt;
+        }
+       if(Debug.isOn("sets-care")) {
+         Debug("sets-care") << "[sets-care] Requesting split between" << a << " and "
+                            << b << "." << std::endl << "[sets-care] " 
+                            << "  Both current have value "
+                            << d_external.d_valuation.getModelValue(a) << std::endl;
+       }
       case EQUALITY_FALSE_IN_MODEL:
         if(Trace.isOn("sets-care-performance-test")) {
           // TODO: delete these lines, only for performance testing for now
@@ -566,6 +577,7 @@ void TheorySetsPrivate::computeCareGraph() {
       }
     }
   }
+  Trace("sharing") << "TheorySetsPrivate::computeCareGraph(): size = " << edgesAddedCnt << std::endl;
 }
 
 EqualityStatus TheorySetsPrivate::getEqualityStatus(TNode a, TNode b) {
@@ -1075,8 +1087,42 @@ TheorySetsPrivate::~TheorySetsPrivate()
     Assert(d_scrutinize != NULL);
     delete d_scrutinize;
   }
-}
+}/* TheorySetsPrivate::~TheorySetsPrivate() */
+
+void TheorySetsPrivate::propagate(Theory::Effort effort) {
+  if(effort != Theory::EFFORT_FULL || !options::setsPropFull()) {
+    return;
+  }
+
+  // build a model
+  Trace("sets-prop-full") << "[sets-prop-full] propagate(FULL_EFFORT)" << std::endl;
+  dumpAssertionsHumanified();
+
+  const CDNodeSet& terms = (d_termInfoManager->d_terms);
+  for(typeof(terms.begin()) it = terms.begin(); it != terms.end(); ++it) {
+    Node node = (*it);
+    Kind k = node.getKind();
+    if(k == kind::UNION && node[0].getKind() == kind::SINGLETON ) {
+
+      if(holds(MEMBER(node[0][0], node[1]))) {
+        Trace("sets-prop-full") << "[sets-prop-full] " << MEMBER(node[0][0], node[1])
+                                << " => " << EQUAL(node[1], node) << std::endl;
+        learnLiteral(EQUAL(node[1], node), MEMBER(node[0][0], node[1]));
+      }
 
+    } else if(k == kind::UNION && node[1].getKind() == kind::SINGLETON ) {
+
+      if(holds(MEMBER(node[1][0], node[0]))) {
+        Trace("sets-prop-full") << "[sets-prop-full] " << MEMBER(node[1][0], node[0])
+                                << " => " << EQUAL(node[0], node) << std::endl;
+        learnLiteral(EQUAL(node[0], node), MEMBER(node[1][0], node[0]));
+      }
+
+    }
+  }
+
+  finishPropagation();
+}
 
 bool TheorySetsPrivate::propagate(TNode literal) {
   Debug("sets-prop") << " propagate(" << literal  << ")" << std::endl;
@@ -1094,13 +1140,14 @@ bool TheorySetsPrivate::propagate(TNode literal) {
   }
 
   return ok;
-}/* TheorySetsPropagate::propagate(TNode) */
+}/* TheorySetsPrivate::propagate(TNode) */
 
 
 void TheorySetsPrivate::setMasterEqualityEngine(eq::EqualityEngine* eq) {
   d_equalityEngine.setMasterEqualityEngine(eq);
 }
 
+
 void TheorySetsPrivate::conflict(TNode a, TNode b)
 {
   if (a.getKind() == kind::CONST_BOOLEAN) {
@@ -1139,6 +1186,7 @@ Node TheorySetsPrivate::explain(TNode literal)
   return mkAnd(assumptions);
 }
 
+
 void TheorySetsPrivate::preRegisterTerm(TNode node)
 {
   Debug("sets") << "TheorySetsPrivate::preRegisterTerm(" << node << ")"
index 72c041d491e87cad3259eef475c2d0b96c0b6b25..e5f160fdaee02c8596ff707c636ea6f2dce3df41 100644 (file)
@@ -66,7 +66,7 @@ public:
 
   void preRegisterTerm(TNode node);
 
-  void propagate(Theory::Effort) { /* we don't depend on this call */ }
+  void propagate(Theory::Effort);
 
 private:
   TheorySets& d_external;
@@ -112,8 +112,9 @@ private:
     TheorySetsPrivate& d_theory;
     context::Context* d_context;
     eq::EqualityEngine* d_eqEngine;
-
+  public:
     CDNodeSet d_terms;
+  private:
     std::hash_map<TNode, TheorySetsTermInfo*, TNodeHashFunction> d_info;
 
     void mergeLists(CDTNodeList* la, const CDTNodeList* lb) const;