]> git.unchartedbackwaters.co.uk Git - francis/stp.git/commitdiff
Add unconstrained shift for left/right.
authortrevor_hansen <trevor_hansen@e59a4935-1847-0410-ae03-e826735625c1>
Sat, 6 Aug 2011 04:02:44 +0000 (04:02 +0000)
committertrevor_hansen <trevor_hansen@e59a4935-1847-0410-ae03-e826735625c1>
Sat, 6 Aug 2011 04:02:44 +0000 (04:02 +0000)
git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@1378 e59a4935-1847-0410-ae03-e826735625c1

src/simplifier/RemoveUnconstrained.cpp
unit_test/unc_shift.smt [new file with mode: 0644]

index 824966efd3fda7e97eaf8a566fd720926318e839..e889fd608634d3af2dacedc419b6a6bc9f218a83 100644 (file)
@@ -2,8 +2,8 @@
  * Identifies unconstrained variables and remove them from the input.
  * Robert Bruttomesso's & Robert Brummayer's dissertations describe this.
  * 
- * Nb. this isn't finished. It doesn't do READS, left shift, implies.
- * I don't think anything can be done for : bvsx, bvzx, write, bvmod.
+ * Nb. this isn't finished. It doesn't do reads / writes.
+ * I don't think anything can be done for : bvsx, bvzx.
  */
 
 #include "RemoveUnconstrained.h"
@@ -522,11 +522,41 @@ namespace BEEV
                   }
               }
               break;
+        case BVLEFTSHIFT:
+        case BVRIGHTSHIFT:
+        case BVSRSHIFT:
+             {
+                 assert(numberOfChildren == 2);
+                 if (mutable_children[0]->isUnconstrained() && mutable_children[1]->isUnconstrained())
+                  {
+                     assert(children[0] != children[1]);
+                     ASTNode v =replaceParentWithFresh(muteParent, variable_array);
+                     replace(children[1], bm.CreateZeroConst(width));
+                     replace(children[0], v);
+                  }
+              }
+             break;
+
+        case BVMOD:
+             {
+                 assert(numberOfChildren == 2);
+                 if (mutable_children[0]->isUnconstrained() && mutable_children[1]->isUnconstrained() && bm.UserFlags.isSet("unconstrained-bvmod", "0") )
+                  {
+                     assert (children[0] != children[1]);
+                     ASTNode v =replaceParentWithFresh(muteParent, variable_array);
+                     replace(children[1], bm.CreateZeroConst(width));
+                     replace(children[0], v);
+                  }
+              }
+             break;
+
+
         case BVDIV:
              {
                  assert(numberOfChildren == 2);
                  if (mutable_children[0]->isUnconstrained() && mutable_children[1]->isUnconstrained())
                   {
+                     assert (children[0] != children[1]);
                      ASTNode v =replaceParentWithFresh(muteParent, variable_array);
                      replace(children[1], bm.CreateOneConst(width));
                      replace(children[0], v);
diff --git a/unit_test/unc_shift.smt b/unit_test/unc_shift.smt
new file mode 100644 (file)
index 0000000..b5e9405
--- /dev/null
@@ -0,0 +1,21 @@
+(benchmark r
+  :status sat
+  :category { crafted }
+  :difficulty { 0 }
+  :logic QF_BV
+  :extrafuns ((x BitVec[3]))
+  :extrafuns ((y BitVec[3]))
+  
+  :extrafuns ((w BitVec[3]))
+  :extrafuns ((z BitVec[3]))
+
+  :extrafuns ((q BitVec[3]))
+  :extrafuns ((r BitVec[3]))
+
+  :assumption (= (bvshl x y )  (bv4[3]))
+  :assumption (= (bvashr w z )  (bv4[3]))
+  :assumption (= (bvshl q r )  (bv4[3]))
+
+
+    :formula true
+)