incorporated dejan's constant evaluation; now getting destruction seg fault
authorlianah <lianahady@gmail.com>
Thu, 21 Mar 2013 19:43:58 +0000 (15:43 -0400)
committerlianah <lianahady@gmail.com>
Thu, 21 Mar 2013 19:43:58 +0000 (15:43 -0400)
src/theory/bv/bv_subtheory.h
src/theory/bv/bv_subtheory_core.cpp
src/theory/bv/bv_subtheory_core.h
src/theory/bv/slicer.cpp
src/theory/bv/slicer.h

index 73050ea7368fa2c1b7476c34e673cf0d5bd03ae2..c442fa6dd2ba4cb9f14e339c932d1607a023130f 100644 (file)
@@ -61,7 +61,7 @@ const bool d_useSatPropagation = true;
 // forward declaration 
 class TheoryBV; 
 
-typedef context::CDQueue<TNode> AssertionQueue; 
+typedef context::CDQueue<Node> AssertionQueue; 
 /**
  * Abstract base class for bit-vector subtheory solvers
  *
index 85ae64d059e5847f1d28681593aadcfe7ebcde3b..d7dab10f985c41f4a247a4c605d323292b76cd6b 100644 (file)
@@ -32,9 +32,9 @@ CoreSolver::CoreSolver(context::Context* c, TheoryBV* bv)
   : SubtheorySolver(c, bv),
     d_notify(*this),
     d_equalityEngine(d_notify, c, "theory::bv::TheoryBV"),
-    d_assertions(c),
     d_slicer(new Slicer(c, this)),
-    d_isCoreTheory(c, true)
+    d_isCoreTheory(c, true),
+    d_reasons(c)
 {
   if (d_useEqualityEngine) {
 
@@ -124,7 +124,8 @@ bool CoreSolver::decomposeFact(TNode fact) {
 
     explanation.push_back(fact);
     Node reason = utils::mkAnd(explanation); 
-  
+    d_reasons.insert(reason);
+    
     Assert (utils::getSize(new_a) == utils::getSize(new_b) &&
             utils::getSize(new_a) == utils::getSize(a)); 
     // FIXME: do we still need to assert these? 
@@ -132,6 +133,9 @@ bool CoreSolver::decomposeFact(TNode fact) {
     Node a_eq_new_a = nm->mkNode(kind::EQUAL, a, new_a);
     Node b_eq_new_b = nm->mkNode(kind::EQUAL, b, new_b);
 
+    d_reasons.insert(a_eq_new_a);
+    d_reasons.insert(b_eq_new_b); 
+    
     bool ok = true; 
     ok = assertFactToEqualityEngine(a_eq_new_a, utils::mkTrue());
     if (!ok) return false; 
@@ -145,6 +149,7 @@ bool CoreSolver::decomposeFact(TNode fact) {
       for (unsigned i = 0; i < new_a.getNumChildren(); ++i) {
         Node eq_i = nm->mkNode(kind::EQUAL, new_a[i], new_b[i]);
         ok = assertFactToEqualityEngine(eq_i, reason);
+        d_reasons.insert(eq_i); 
         if (!ok) return false;
       }
     }
@@ -269,8 +274,8 @@ void CoreSolver::conflict(TNode a, TNode b) {
 
 void CoreSolver::collectModelInfo(TheoryModel* m) {
   if (Debug.isOn("bitvector-model")) {
-    context::CDList<TNode>::const_iterator it = d_assertions.begin();
-    for (; it!= d_assertions.end(); ++it) {
+    context::CDQueue<Node>::const_iterator it = d_assertionQueue.begin();
+    for (; it!= d_assertionQueue.end(); ++it) {
       Debug("bitvector-model") << "CoreSolver::collectModelInfo (assert "
                                << *it << ")\n";
     }
index 230817e13c712af594553068041437acc255ee69..f37cf5bf32c2d7ee82f733c1e3838b0ac1999938 100644 (file)
@@ -19,6 +19,7 @@
 #include "cvc4_private.h"
 #include "theory/bv/bv_subtheory.h"
 #include "context/cdhashmap.h"
+#include "context/cdhashset.h"
 
 namespace CVC4 {
 namespace theory {
@@ -60,11 +61,10 @@ class CoreSolver : public SubtheorySolver {
   /** Store a conflict from merging two constants */
   void conflict(TNode a, TNode b);
 
-  /** FIXME: for debugging purposes only */
-  context::CDList<TNode> d_assertions;
   Slicer* d_slicer;
   context::CDO<bool> d_isCoreTheory;
-
+  /** To make sure we keep the explanations */
+  context::CDHashSet<Node, NodeHashFunction> d_reasons; 
   bool assertFactToEqualityEngine(TNode fact, TNode reason);  
   bool decomposeFact(TNode fact);
   Node getBaseDecomposition(TNode a, std::vector<TNode>& explanation);
index 474c70052067e309d515e3c806ffad5015d0e9c0..ef87e83b60abdea3c4442ef7a94577c527fd6002 100644 (file)
@@ -521,7 +521,6 @@ void UnionFind::ensureSlicing(const ExtractTerm& term) {
 }
 
 void UnionFind::backtrack() {
-  return; 
   int size = d_undoStack.size(); 
   for (int i = size; i > (int)d_undoStackIndex.get(); --i) {
     Operation op = d_undoStack.back(); 
@@ -619,7 +618,7 @@ void Slicer::assertEquality(TNode eq) {
 }
 
 TermId Slicer::getId(TNode node) const {
-  __gnu_cxx::hash_map<TNode, TermId, TNodeHashFunction >::const_iterator it = d_nodeToId.find(node);
+  __gnu_cxx::hash_map<Node, TermId, NodeHashFunction >::const_iterator it = d_nodeToId.find(node);
   Assert (it != d_nodeToId.end());
   return it->second; 
 }
@@ -632,7 +631,7 @@ void Slicer::registerEquality(TNode eq) {
   }
 }
 
-void Slicer::getBaseDecomposition(TNode node, std::vector<Node>& decomp, std::vector<TNode>& explanation) {
+void Slicer::getBaseDecomposition(TNode node, std::vector<Node>& decomp, std::vector<Node>& explanation) {
   Debug("bv-slicer") << "Slicer::getBaseDecomposition " << node << endl;
   
   Index high = utils::getSize(node) - 1;
@@ -652,7 +651,7 @@ void Slicer::getBaseDecomposition(TNode node, std::vector<Node>& decomp, std::ve
 
   for (unsigned i = 0; i < explanation_ids.size(); ++i) {
     Assert (hasExplanation(explanation_ids[i])); 
-    TNode exp = getExplanation(explanation_ids[i]);
+    Node exp = getExplanation(explanation_ids[i]);
     explanation.push_back(exp); 
   }
   
index 6bbe2f467d7a19be435411f8b95997380ffda213..f63cf7284c0b5b5e6a3ac02420aa8e19132d7e26 100644 (file)
@@ -315,10 +315,10 @@ class CoreSolver;
 
 class Slicer {
   __gnu_cxx::hash_map<TermId, TNode, __gnu_cxx::hash<TermId> > d_idToNode;
-  __gnu_cxx::hash_map<TNode, TermId, TNodeHashFunction> d_nodeToId;
-  __gnu_cxx::hash_map<TNode, bool, TNodeHashFunction> d_coreTermCache;
-  __gnu_cxx::hash_map<TNode, ExplanationId, TNodeHashFunction> d_explanationToId;
-  std::vector<TNode> d_explanations; 
+  __gnu_cxx::hash_map<Node, TermId, NodeHashFunction> d_nodeToId;
+  __gnu_cxx::hash_map<Node, bool, NodeHashFunction> d_coreTermCache;
+  __gnu_cxx::hash_map<Node, ExplanationId, NodeHashFunction> d_explanationToId;
+  std::vector<Node> d_explanations; 
   UnionFind d_unionFind;
 
   context::CDQueue<Node> d_newSplits;