bv-to-int: change order of passes (#5208)
authoryoni206 <yoni206@users.noreply.github.com>
Tue, 6 Oct 2020 20:47:58 +0000 (13:47 -0700)
committerGitHub <noreply@github.com>
Tue, 6 Oct 2020 20:47:58 +0000 (15:47 -0500)
Closes #5095 and replaces #5110.
There are two tests in #5095 that produce two different assertion failures when using bv-to-int.
The first happens because the substitution map wasn't applied after the pass.
The second happens because div (that is introduced in the pass) is not rewritten using witness.
Both problems are solved by making sure that apply-substs, theory-preprocess and ite-removal are executed after bv-to-int.
The two tests from #5095 are included as regressions.

src/smt/process_assertions.cpp
test/regress/CMakeLists.txt
test/regress/regress2/bv_to_int_5095.smt2 [new file with mode: 0644]
test/regress/regress2/bv_to_int_5095_2.smt2 [new file with mode: 0644]

index 971288b67513c70a8b2ba4c8a3e3f22d1e8df68b..719165048c1f10b02cff3abc1007409fc7696a7a 100644 (file)
@@ -201,16 +201,6 @@ bool ProcessAssertions::apply(Assertions& as)
     d_passes["bv-intro-pow2"]->apply(&assertions);
   }
 
-  // Since this pass is not robust for the information tracking necessary for
-  // unsat cores, it's only applied if we are not doing unsat core computation
-  if (!options::unsatCores())
-  {
-    d_passes["apply-substs"]->apply(&assertions);
-  }
-
-  // Assertions MUST BE guaranteed to be rewritten by this point
-  d_passes["rewrite"]->apply(&assertions);
-
   // Lift bit-vectors of size 1 to bool
   if (options::bitvectorToBool())
   {
@@ -219,8 +209,22 @@ bool ProcessAssertions::apply(Assertions& as)
   if (options::solveBVAsInt() != options::SolveBVAsIntMode::OFF)
   {
     d_passes["bv-to-int"]->apply(&assertions);
+    // after running bv-to-int, we need to immediately run
+    // theory-preprocess and ite-removal so that newlly created
+    // terms and assertions are normalized (e.g., div is expanded).
+    d_passes["theory-preprocess"]->apply(&assertions);
   }
 
+  // Since this pass is not robust for the information tracking necessary for
+  // unsat cores, it's only applied if we are not doing unsat core computation
+  if (!options::unsatCores())
+  {
+    d_passes["apply-substs"]->apply(&assertions);
+  }
+
+  // Assertions MUST BE guaranteed to be rewritten by this point
+  d_passes["rewrite"]->apply(&assertions);
+
   // Convert non-top-level Booleans to bit-vectors of size 1
   if (options::boolToBitvector() != options::BoolToBVMode::OFF)
   {
index 7d29db744b09860e0abab3f7d5c1ef71da5227e7..5d4501309d42cbe7455b514d7049dde8c420b7b1 100644 (file)
@@ -2103,6 +2103,8 @@ set(regress_2_tests
   regress2/bug812.smt2
   regress2/bv/opStructure_MBA_6.scrambled.min.smt2
   regress2/bv_to_int2.smt2
+  regress2/bv_to_int_5095.smt2
+  regress2/bv_to_int_5095_2.smt2
   regress2/bv_to_int_ashr.smt2
   regress2/bv_to_int_bitwise.smt2
   regress2/bv_to_int_bvmul1.smt2
diff --git a/test/regress/regress2/bv_to_int_5095.smt2 b/test/regress/regress2/bv_to_int_5095.smt2
new file mode 100644 (file)
index 0000000..bec9761
--- /dev/null
@@ -0,0 +1,10 @@
+; EXPECT: sat
+(set-logic QF_BV)
+(set-option :solve-bv-as-int sum)
+(set-option :incremental true)
+(declare-fun _substvar_27_ () Bool)
+(declare-const bv_40-3 (_ BitVec 40))
+(assert (= bv_40-3 (_ bv0 40)))
+(push 1)
+(assert _substvar_27_)
+(check-sat)
\ No newline at end of file
diff --git a/test/regress/regress2/bv_to_int_5095_2.smt2 b/test/regress/regress2/bv_to_int_5095_2.smt2
new file mode 100644 (file)
index 0000000..54dfa09
--- /dev/null
@@ -0,0 +1,6 @@
+; EXPECT: sat
+; COMMAND --solve-bv-as-int=sum
+(set-logic BV)
+(declare-const bv_42-0 (_ BitVec 42))
+(assert (exists ((q28 (_ BitVec 42))) (distinct (bvudiv bv_42-0 bv_42-0) q28)))
+(check-sat)
\ No newline at end of file