Fix issues with REWRITE_DONE in floating point rewriter (#2762)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Wed, 19 Dec 2018 17:58:52 +0000 (11:58 -0600)
committerGitHub <noreply@github.com>
Wed, 19 Dec 2018 17:58:52 +0000 (11:58 -0600)
src/theory/fp/theory_fp_rewriter.cpp
test/regress/CMakeLists.txt
test/regress/regress1/sygus/temp_input_to_synth_ic-error-121418.sy [new file with mode: 0644]

index f77291a059f54fb0d895eb27968a9a54ef5af01a..21644161e670f04e6ad4b94fdc36d39dab245c58 100644 (file)
@@ -175,8 +175,9 @@ namespace rewrite {
     if (node[0] == node[1]) {
       return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(true));
     } else if (!isPreRewrite && (node[0] > node[1])) {
-       Node normal = NodeManager::currentNM()->mkNode(kind::EQUAL,node[1],node[0]);
-       return RewriteResponse(REWRITE_DONE, normal);
+      Node normal =
+          NodeManager::currentNM()->mkNode(kind::EQUAL, node[1], node[0]);
+      return RewriteResponse(REWRITE_DONE, normal);
     } else {
       return RewriteResponse(REWRITE_DONE, node);
     }
@@ -191,7 +192,7 @@ namespace rewrite {
           (k == kind::FLOATINGPOINT_MIN_TOTAL) || (k == kind::FLOATINGPOINT_MAX_TOTAL));
 #endif
     if (node[0] == node[1]) {
-      return RewriteResponse(REWRITE_DONE, node[0]);
+      return RewriteResponse(REWRITE_AGAIN, node[0]);
     } else {
       return RewriteResponse(REWRITE_DONE, node);
     }
@@ -249,7 +250,7 @@ namespace rewrite {
        (childKind == kind::FLOATINGPOINT_ABS)) {
 
       Node rewritten = NodeManager::currentNM()->mkNode(node.getKind(),node[0][0]);
-      return RewriteResponse(REWRITE_AGAIN, rewritten);
+      return RewriteResponse(REWRITE_AGAIN_FULL, rewritten);
     } else {
       return RewriteResponse(REWRITE_DONE, node);
     } 
@@ -276,8 +277,11 @@ namespace rewrite {
     // Lift negation out of the LHS so it can be cancelled out
     if (working[0].getKind() == kind::FLOATINGPOINT_NEG) {
       NodeManager * nm = NodeManager::currentNM();
-      working = nm->mkNode(kind::FLOATINGPOINT_NEG,
-                          nm->mkNode(kind::FLOATINGPOINT_REM, working[0][0], working[1]));
+      working = nm->mkNode(
+          kind::FLOATINGPOINT_NEG,
+          nm->mkNode(kind::FLOATINGPOINT_REM, working[0][0], working[1]));
+      // in contrast to other rewrites here, this requires rewrite again full
+      return RewriteResponse(REWRITE_AGAIN_FULL, working);
     }
 
     return RewriteResponse(REWRITE_DONE, working);
index 95e4b887516b738fb330d5ebc8dfb09950237d3f..0b196855f3b58a49c9b503e453f06aade882f76e 100644 (file)
@@ -1640,6 +1640,7 @@ set(regress_1_tests
   regress1/sygus/sygus-lambda-fv.sy
   regress1/sygus/sygus-uf-ex.sy
   regress1/sygus/t8.sy
+  regress1/sygus/temp_input_to_synth_ic-error-121418.sy
   regress1/sygus/tl-type-0.sy
   regress1/sygus/tl-type-4x.sy
   regress1/sygus/tl-type.sy
diff --git a/test/regress/regress1/sygus/temp_input_to_synth_ic-error-121418.sy b/test/regress/regress1/sygus/temp_input_to_synth_ic-error-121418.sy
new file mode 100644 (file)
index 0000000..4efd903
--- /dev/null
@@ -0,0 +1,26 @@
+; REQUIRES: symfpu
+; EXPECT: unsat
+; COMMAND-LINE: --sygus-out=status
+(set-logic ALL)
+(define-sort FP () (_ FloatingPoint 3 5))
+(synth-fun IC ((t FP)) Bool
+  ((Start Bool (
+     true
+     false
+     (fp.isZero StartFP)
+     (ite Start Start Start)
+   ))
+   (StartFP FP (
+     t
+     (fp.sub StartRM StartFP StartFP)
+     (fp.max StartFP StartFP)
+   ))
+   (StartRM RoundingMode
+     (RNE))
+))
+
+(constraint (not (IC (fp #b0 #b110 #b1001) )))
+(constraint (not (IC (fp #b1 #b101 #b1101) )))
+(constraint (not (IC (fp #b1 #b001 #b0110) )))
+(constraint (IC (fp #b0 #b001 #b0001) ))
+(check-synth)