]> git.unchartedbackwaters.co.uk Git - francis/stp.git/commitdiff
This makes SimplifyTerm idempotent. My hope is that this will reduce the number of...
authortrevor_hansen <trevor_hansen@e59a4935-1847-0410-ae03-e826735625c1>
Fri, 11 Jun 2010 02:04:18 +0000 (02:04 +0000)
committertrevor_hansen <trevor_hansen@e59a4935-1847-0410-ae03-e826735625c1>
Fri, 11 Jun 2010 02:04:18 +0000 (02:04 +0000)
This patch adds an assertion function that isn't enabled.

git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@830 e59a4935-1847-0410-ae03-e826735625c1

src/simplifier/simplifier.cpp
src/simplifier/simplifier.h

index 100fef064e8f3f0a2753718441f9ed6333e15af6..183adbe2be2fa00b452ec0deb1567026e8a5f5e7 100644 (file)
@@ -230,6 +230,31 @@ namespace BEEV
     return out;
   }
 
+  // I like simplify to have been run on all the nodes.
+  void Simplifier::checkIfInSimplifyMap(const ASTNode& n, ASTNodeSet visited)
+  {
+         if (n.isConstant() || (n.GetKind() == SYMBOL))
+                 return;
+
+         if (visited.find(n) != visited.end())
+                 return;
+
+         if (SimplifyMap->find(n) == SimplifyMap->end())
+         {
+                 cerr << "not found";
+                 cerr << n;
+                 assert(false);
+         }
+
+         for(int i =0; i < n.Degree();i++)
+         {
+                 checkIfInSimplifyMap(n[i],visited);
+         }
+
+         visited.insert(n);
+  }
+
+
   // The SimplifyMaps on entry to the topLevel functions may contain
   // useful entries.  E.g. The BVSolver calls SimplifyTerm()
   ASTNode Simplifier::SimplifyFormula_TopLevel(const ASTNode& b, 
@@ -238,6 +263,8 @@ namespace BEEV
   {
     _bm->GetRunTimes()->start(RunTimes::SimplifyTopLevel);
     ASTNode out = SimplifyFormula(b, pushNeg, VarConstMap);
+    ASTNodeSet visited;
+    //checkIfInSimplifyMap(out,visited);
     ResetSimplifyMaps();
     _bm->GetRunTimes()->stop(RunTimes::SimplifyTopLevel);
     return out;
@@ -351,7 +378,6 @@ namespace BEEV
         break;
       }
 
-    //memoize
     UpdateSimplifyMap(b, output, pushNeg, VarConstMap);
     UpdateSimplifyMap(a, output, pushNeg, VarConstMap);
     return output;
@@ -2665,6 +2691,8 @@ namespace BEEV
       }
     assert(!output.IsNull());
 
+    if (inputterm != output)
+       output = SimplifyTerm(output);
     //memoize
     UpdateSimplifyMap(inputterm, output, false, VarConstMap);
     //cerr << "SimplifyTerm: output" << output << endl;
index 99d431b7a117838ed39ca719d4ab5b4d8bd39248..928b25cf974a615bdba5d5c2c7c82ba2cd4d94bf 100644 (file)
@@ -50,6 +50,8 @@ namespace BEEV
     STPMgr * _bm;
 
     NodeFactory * nf;
+
+    void checkIfInSimplifyMap(const ASTNode& n, ASTNodeSet visited);
   public:
       
     /****************************************************************