BV: Fix querying equality status in lazy bit-blaster. (#4618)
authorAina Niemetz <aina.niemetz@gmail.com>
Tue, 16 Jun 2020 16:06:34 +0000 (09:06 -0700)
committerGitHub <noreply@github.com>
Tue, 16 Jun 2020 16:06:34 +0000 (09:06 -0700)
Fixes #4076.

In the lazy bit-blaster, when querying the equality status, if the SAT
solver has a full model, it is queried for the model values of the
operands of the equality. However, the check if the bit-blaster has a
full model did not consider the case where no assertions have yet been
added, which leads to querying values of bits that are still unassigned
in the SAT solver.

Co-authored-by: <mathias.preiner@gmail.com>
src/theory/bv/bitblast/lazy_bitblaster.cpp
test/regress/CMakeLists.txt
test/regress/regress0/bv/issue-4076.smt2 [new file with mode: 0644]

index 463ffae79ee20f02011e67730ab2b10f6b741e17..163d2e78a7c3aa5c7eaeab2709c405cf789228ab 100644 (file)
@@ -440,11 +440,13 @@ void TLazyBitblaster::MinisatNotify::safePoint(ResourceManager::Resource r)
 EqualityStatus TLazyBitblaster::getEqualityStatus(TNode a, TNode b)
 {
   int numAssertions = d_bv->numAssertions();
+  bool has_full_model =
+      numAssertions != 0 && d_fullModelAssertionLevel.get() == numAssertions;
+
   Debug("bv-equality-status")
       << "TLazyBitblaster::getEqualityStatus " << a << " = " << b << "\n";
   Debug("bv-equality-status")
-      << "BVSatSolver has full model? "
-      << (d_fullModelAssertionLevel.get() == numAssertions) << "\n";
+      << "BVSatSolver has full model? " << has_full_model << "\n";
 
   // First check if it trivially rewrites to false/true
   Node a_eq_b =
@@ -453,7 +455,7 @@ EqualityStatus TLazyBitblaster::getEqualityStatus(TNode a, TNode b)
   if (a_eq_b == utils::mkFalse()) return theory::EQUALITY_FALSE;
   if (a_eq_b == utils::mkTrue()) return theory::EQUALITY_TRUE;
 
-  if (d_fullModelAssertionLevel.get() != numAssertions)
+  if (!has_full_model)
   {
     return theory::EQUALITY_UNKNOWN;
   }
index f225c2ed6cb10dce311375d56c3edf9572b00012..93d6a3ef8a44e06522b2319864a91695764cb369 100644 (file)
@@ -361,6 +361,7 @@ set(regress_0_tests
   regress0/bv/fuzz41.smtv1.smt2
   regress0/bv/issue3621.smt2
   regress0/bv/issue-4075.smt2
+  regress0/bv/issue-4076.smt2
   regress0/bv/issue-4130.smt2
   regress0/bv/int_to_bv_err_on_demand_1.smt2
   regress0/bv/mul-neg-unsat.smt2
diff --git a/test/regress/regress0/bv/issue-4076.smt2 b/test/regress/regress0/bv/issue-4076.smt2
new file mode 100644 (file)
index 0000000..3a80dc5
--- /dev/null
@@ -0,0 +1,15 @@
+; COMMAND-LINE: --incremental
+; EXPECT: sat
+; EXPECT: sat
+(set-logic ALL)
+(set-option :produce-models true)
+(declare-fun a ((_ BitVec 2)) Int)
+(declare-fun b (Int) (_ BitVec 2))
+(declare-const c Int)
+(declare-const d Int)
+(assert (= (a #b01) 1))
+(assert(= 0 (a (bvlshr (b c) (b d)))))
+(push)
+(check-sat)
+(pop)
+(check-sat)