From ef7915858bca5e759ee0a34df2ae976e7e507bef Mon Sep 17 00:00:00 2001
From: Nikolaj Bjorner <nbjorner@microsoft.com>
Date: Mon, 24 Aug 2015 16:27:07 -0700
Subject: [PATCH] add filter to detect circumventing the default semantics of
 bit-vector division with the use of the sat-based bit-vector solver. Provides
 a way to fix issue #190

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
---
 src/ast/rewriter/bv_rewriter.h       | 2 ++
 src/tactic/bv/bv1_blaster_tactic.cpp | 3 +++
 src/tactic/probe.cpp                 | 3 +++
 3 files changed, 8 insertions(+)

diff --git a/src/ast/rewriter/bv_rewriter.h b/src/ast/rewriter/bv_rewriter.h
index 26c5a33d5..1c9b44b52 100644
--- a/src/ast/rewriter/bv_rewriter.h
+++ b/src/ast/rewriter/bv_rewriter.h
@@ -168,6 +168,8 @@ public:
     }
 
     br_status mk_eq_core(expr * lhs, expr * rhs, expr_ref & result);
+
+    bool hi_div0() const { return m_hi_div0; }
 };
 
 #endif
diff --git a/src/tactic/bv/bv1_blaster_tactic.cpp b/src/tactic/bv/bv1_blaster_tactic.cpp
index 5f20015ca..f6a6017de 100644
--- a/src/tactic/bv/bv1_blaster_tactic.cpp
+++ b/src/tactic/bv/bv1_blaster_tactic.cpp
@@ -28,6 +28,7 @@ Notes:
 #include"rewriter_def.h"
 #include"for_each_expr.h"
 #include"cooperate.h"
+#include"bv_rewriter.h"
 
 class bv1_blaster_tactic : public tactic {
 
@@ -491,6 +492,8 @@ tactic * mk_bv1_blaster_tactic(ast_manager & m, params_ref const & p) {
 class is_qfbv_eq_probe : public probe {
 public:
     virtual result operator()(goal const & g) {
+        bv_rewriter rw(g.m());
+        if (!rw.hi_div0()) return false;
         bv1_blaster_tactic t(g.m());
         return t.is_target(g);
 
diff --git a/src/tactic/probe.cpp b/src/tactic/probe.cpp
index 0fdd49a6b..dd27691d3 100644
--- a/src/tactic/probe.cpp
+++ b/src/tactic/probe.cpp
@@ -23,6 +23,7 @@ Revision History:
 #include"arith_decl_plugin.h"
 #include"bv_decl_plugin.h"
 #include"goal_util.h"
+#include"bv_rewriter.h"
 
 class memory_probe : public probe {
 public:
@@ -303,6 +304,8 @@ public:
 class is_qfbv_probe : public probe {
 public:
     virtual result operator()(goal const & g) {
+        bv_rewriter rw(g.m());
+        if (!rw.hi_div0()) return false;
         return !test<is_non_qfbv_predicate>(g);
     }
 };