]> git.unchartedbackwaters.co.uk Git - francis/stp.git/commitdiff
Improvement to the utility code for building rewrites.
authortrevor_hansen <trevor_hansen@e59a4935-1847-0410-ae03-e826735625c1>
Sun, 18 Mar 2012 05:53:52 +0000 (05:53 +0000)
committertrevor_hansen <trevor_hansen@e59a4935-1847-0410-ae03-e826735625c1>
Sun, 18 Mar 2012 05:53:52 +0000 (05:53 +0000)
git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@1600 e59a4935-1847-0410-ae03-e826735625c1

src/util/find_rewrites/rewrite.cpp
src/util/find_rewrites/rewrite_rule.h

index ba8fd19fbf6713ae37002a2aae4f7cef63949779..4ef16702ff62887ffb57cb576357fca4657c8053 100644 (file)
@@ -702,6 +702,7 @@ doIte(ASTNode a)
 void
 do_write_out(int ignore)
 {
+  difficulty_cache.clear();
   force_writeout = true;
 }
 
@@ -927,9 +928,12 @@ findRewrites(ASTVec& expressions, const vector<VariableAssignment>& values, cons
 
   if (values.size() > 0)
     {
-      if (values.size() > 10)
+      const int old_size = values.size();
+      if (old_size > 10)
         removeDuplicates(expressions);
 
+      discarded += (old_size - values.size());
+
       // Put the functions in buckets based on their results on the values.
       HASHMAP<uint64_t, ASTVec> map;
       for (int i = 0; i < expressions.size(); i++)
@@ -1020,17 +1024,30 @@ findRewrites(ASTVec& expressions, const vector<VariableAssignment>& values, cons
               if (!r)
                 continue;
 
-              cout << "Discovered a new rule.";
-              cout << f << t;
-              cout << getDifficulty(f) << " to " << getDifficulty(t) << endl;
-
               Rewrite_rule rr(mgr, f, t, checktime);
 
-              if (!rr.timedCheck(10000))
+              VariableAssignment bad;
+              if (!rr.timedCheck(10000,bad))
                 {
+                  vector<VariableAssignment> ass;
+                  ass.push_back(bad);
+
                   cout << "Rule failed extended verification.";
-                  continue;
+
+                  // If it can fit into an unsigned. Split the list on it.
+                  if (sizeof(unsigned int) * 8 > bad.getV().GetValueWidth())
+                    {
+                      findRewrites(equiv, ass, depth + 1);
+                      return;
+                    }
+                  else
+                    continue;
                 }
+
+              cout << "Discovered a new rule.";
+              cout << f << t;
+              cout << getDifficulty(f) << " to " << getDifficulty(t) << endl;
+
               cout << "Verified Rule to: " << rr.getVerifiedToBits() << " bits" << endl;
               cout << "------";
 
@@ -1040,10 +1057,11 @@ findRewrites(ASTVec& expressions, const vector<VariableAssignment>& values, cons
               // Sometimes it doesn't. Not sure why..
               assert(t == rewrite_system.rewriteNode(f));
 
-
               equiv[i] = rewrite_system.rewriteNode(equiv[i]);
               equiv[j] = rewrite_system.rewriteNode(equiv[j]);
 
+              if (equiv[i] == equiv[j])
+                equiv[j]= mgr->ASTUndefined;
             }
           else if (!bad)
             {
@@ -1856,7 +1874,8 @@ expandRules(int timeout_ms, const char* fileName = "")
 
   for (Rewrite_system::RewriteRuleContainer::iterator it = rewrite_system.begin(); it != rewrite_system.end(); it++)
     {
-      if ((*it).timedCheck(timeout_ms))
+      VariableAssignment bad;
+      if ((*it).timedCheck(timeout_ms,bad))
         {
           it->writeOut(cout); // omit failed.
           cerr << getDifficulty(it->getFrom()) << " " << getDifficulty(it->getTo());
index 44a9eb741f511a351d179f980751b8451bbabb94..6508cbcbe1203e24feb73a72993a737592b6666f 100644 (file)
@@ -136,10 +136,8 @@ public:
 
   // Tests for the timeout amount of time. FALSE if a bad instance was found. Otherwise true.
   bool
-  timedCheck(int timeout_ms)
+  timedCheck(int timeout_ms, VariableAssignment& bad)
   {
-    VariableAssignment assignment;
-
     mgr->soft_timeout_expired = false;
     itimerval timeout;
     signal(SIGVTALRM, soft_time_out);
@@ -153,7 +151,7 @@ public:
     int checked_to = 0;
 
     // Start it verifying where we left off..
-    for (int i = std::max(bits, getVerifiedToBits() + 1); i < 1024; i++)
+    for (int new_bitwidth = std::max(bits, getVerifiedToBits() + 1); new_bitwidth < 1024; new_bitwidth++)
       {
         //cout << i << " ";
         ASTVec children;
@@ -161,18 +159,18 @@ public:
         children.push_back(to);
 
         const ASTNode n = mgr->hashingNodeFactory->CreateNode(EQ, children);
-        const ASTNode& widened = widen(n, i);
+        const ASTNode& widened = widen(n, new_bitwidth);
         if (widened == mgr->ASTUndefined)
           {
             cout << "cannot widen";
             cerr << from << to;
           }
 
-        bool result = isConstant(widened, assignment, i);
+        bool result = isConstant(widened, bad, new_bitwidth);
         if (!result && !mgr->soft_timeout_expired)
           {
             // not a constant, and not timed out!
-            cerr << "FAILED:" << endl << i << from << to;
+            cerr << "FAILED:" << endl << new_bitwidth << from << to;
             writeOut(cerr);
 
             // The timer might not have expired yet.
@@ -183,7 +181,7 @@ public:
         if (mgr->soft_timeout_expired)
           break;
 
-        checked_to = i;
+        checked_to = new_bitwidth;
       }
 
     if (getVerifiedToBits() <= checked_to)