Make sure conflicts are not rewritten (in arithmetic) (#5219)
authorGereon Kremer <gereon.kremer@cs.rwth-aachen.de>
Wed, 7 Oct 2020 14:13:41 +0000 (16:13 +0200)
committerGitHub <noreply@github.com>
Wed, 7 Oct 2020 14:13:41 +0000 (09:13 -0500)
The arithmetic inference manager did rewrite conflicts, which lead to nodes from the conflict not being assumptions (but rewritten assumptions) triggering an assertion. This rewrite is now removed.
Furthermore rewrites triggering the same assertion within the icp subsolver have been refactored to avoid this issue.

src/theory/arith/bound_inference.cpp
src/theory/arith/inference_id.cpp
src/theory/arith/inference_manager.cpp
src/theory/arith/nl/icp/icp_solver.cpp
test/regress/CMakeLists.txt
test/regress/regress0/arith/issue5219-conflict-rewrite.smt2 [new file with mode: 0644]

index 5a1c3096600581043df49bf145d26311330580e7..7cae40bbb9dd1b594b806f42a0a3d4d211d26ff6 100644 (file)
@@ -15,6 +15,7 @@
 #include "theory/arith/bound_inference.h"
 
 #include "theory/arith/normal_form.h"
+#include "theory/rewriter.h"
 
 namespace CVC4 {
 namespace theory {
@@ -95,7 +96,7 @@ const std::map<Node, Bounds>& BoundInference::get() const { return d_bounds; }
 bool BoundInference::add(const Node& n)
 {
   // Parse the node as a comparison
-  auto comp = Comparison::parseNormalForm(n);
+  auto comp = Comparison::parseNormalForm(Rewriter::rewrite(n));
   auto dec = comp.decompose(true);
   if (std::get<0>(dec).isVariable())
   {
index d984e09f28e8bcd5440836a19ebe99a6676bd2f9..a0dc19d81f6216b6d8ff30ae57d898712fe5039d 100644 (file)
@@ -42,6 +42,8 @@ const char* toString(InferenceId i)
     case InferenceId::NL_IAND_VALUE_REFINE: return "IAND_VALUE_REFINE";
     case InferenceId::NL_CAD_CONFLICT: return "CAD_CONFLICT";
     case InferenceId::NL_CAD_EXCLUDED_INTERVAL: return "CAD_EXCLUDED_INTERVAL";
+    case InferenceId::NL_ICP_CONFLICT: return "ICP_CONFLICT";
+    case InferenceId::NL_ICP_PROPAGATION: return "ICP_PROPAGATION";
     default: return "?";
   }
 }
index 77f042d4df732a53fcf51cd6ad15528e43a241b5..656b5ed0dde8c9d46011015808a43536075c3b9e 100644 (file)
@@ -95,7 +95,7 @@ void InferenceManager::addConflict(const Node& conf, InferenceId inftype)
 {
   Trace("arith::infman") << "Adding conflict: " << inftype << " " << conf
                          << std::endl;
-  conflict(Rewriter::rewrite(conf));
+  conflict(conf);
 }
 
 bool InferenceManager::hasUsed() const
index 43905d802c98cfa1f5432b7e2bf0e9e8e0526ee2..7f97d51b6e5d3d7f29e6729b0321fe94ae08f437 100644 (file)
@@ -77,7 +77,8 @@ std::vector<Node> ICPSolver::collectVariables(const Node& n) const
 
 std::vector<Candidate> ICPSolver::constructCandidates(const Node& n)
 {
-  auto comp = Comparison::parseNormalForm(n).decompose(false);
+  auto comp =
+      Comparison::parseNormalForm(Rewriter::rewrite(n)).decompose(false);
   Kind k = std::get<1>(comp);
   if (k == Kind::DISTINCT)
   {
@@ -305,13 +306,12 @@ void ICPSolver::reset(const std::vector<Node>& assertions)
   d_state.reset();
   for (const auto& n : assertions)
   {
-    Node tmp = Rewriter::rewrite(n);
-    Trace("nl-icp") << "Adding " << tmp << std::endl;
-    if (tmp.getKind() != Kind::CONST_BOOLEAN)
+    Trace("nl-icp") << "Adding " << n << std::endl;
+    if (n.getKind() != Kind::CONST_BOOLEAN)
     {
-      if (!d_state.d_bounds.add(tmp))
+      if (!d_state.d_bounds.add(n))
       {
-        addCandidate(tmp);
+        addCandidate(n);
       }
     }
   }
index 5d4501309d42cbe7455b514d7049dde8c420b7b1..cc5c911ff40fb7ca9c126de5274ed64355e01461 100644 (file)
@@ -49,6 +49,7 @@ set(regress_0_tests
   regress0/arith/issue3683.smt2
   regress0/arith/issue4367.smt2
   regress0/arith/issue4525.smt2
+  regress0/arith/issue5219-conflict-rewrite.smt2
   regress0/arith/ite-lift.smt2
   regress0/arith/leq.01.smtv1.smt2
   regress0/arith/miplib.cvc
diff --git a/test/regress/regress0/arith/issue5219-conflict-rewrite.smt2 b/test/regress/regress0/arith/issue5219-conflict-rewrite.smt2
new file mode 100644 (file)
index 0000000..3c8a949
--- /dev/null
@@ -0,0 +1,8 @@
+; REQUIRES: poly
+; COMMAND-LINE: --theoryof-mode=term --nl-ext --nl-icp
+; EXPECT: unknown
+(set-logic QF_NRA)
+(declare-fun x () Real)
+(declare-fun y () Real)
+(assert (and (< 1 y) (= y (+ x (* x x)))))
+(check-sat)