Fix string ext inference for rewrites that introduce negation (#2618)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Thu, 11 Oct 2018 05:31:57 +0000 (00:31 -0500)
committerGitHub <noreply@github.com>
Thu, 11 Oct 2018 05:31:57 +0000 (00:31 -0500)
src/theory/strings/theory_strings.cpp
test/regress/CMakeLists.txt
test/regress/Makefile.tests
test/regress/regress1/strings/timeout-no-resp.smt2 [new file with mode: 0644]

index 26ff9188f25acde1f27ad8b31e360e47981d0775..fb25e1348729f49034dc6806dbda2e7a5be5be67 100644 (file)
@@ -1778,18 +1778,21 @@ void TheoryStrings::checkExtfInference( Node n, Node nr, ExtfInfoTmp& in, int ef
           Node conc =
               nm->mkNode(STRING_STRCTN, pol ? nr[1] : onr, pol ? onr : nr[1]);
           conc = Rewriter::rewrite(conc);
+          conc = conc.negate();
           bool do_infer = false;
-          if (conc.getKind() == EQUAL)
+          bool pol = conc.getKind() != NOT;
+          Node lit = pol ? conc : conc[0];
+          if (lit.getKind() == EQUAL)
           {
-            do_infer = !areDisequal(conc[0], conc[1]);
+            do_infer = pol ? !areEqual(lit[0], lit[1])
+                           : !areDisequal(lit[0], lit[1]);
           }
           else
           {
-            do_infer = !areEqual(conc, d_false);
+            do_infer = !areEqual(lit, pol ? d_true : d_false);
           }
           if (do_infer)
           {
-            conc = conc.negate();
             std::vector<Node> exp_c;
             exp_c.insert(exp_c.end(), in.d_exp.begin(), in.d_exp.end());
             Node ofrom = d_extf_info_tmp[nr[0]].d_ctn_from[opol][i];
index bfcd640b9a4efc620da5f24f9e658ce49724a43d..902ddf0f92918b116eb2b2b93df5aa488b9772dd 100644 (file)
@@ -1548,6 +1548,7 @@ set(regress_1_tests
   regress1/strings/strings-lt-simple.smt2
   regress1/strings/strip-endpt-sound.smt2
   regress1/strings/substr001.smt2
+  regress1/strings/timeout-no-resp.smt2
   regress1/strings/type002.smt2
   regress1/strings/type003.smt2
   regress1/strings/username_checker_min.smt2
index fc080f0e0859b94607f149bd171c016c707dd865..91f33721a7e448b64b306675a15a0a63bb2c6952 100644 (file)
@@ -1545,6 +1545,7 @@ REG1_TESTS = \
        regress1/strings/strings-lt-simple.smt2 \
        regress1/strings/strip-endpt-sound.smt2 \
        regress1/strings/substr001.smt2 \
+       regress1/strings/timeout-no-resp.smt2 \
        regress1/strings/type002.smt2 \
        regress1/strings/type003.smt2 \
        regress1/strings/username_checker_min.smt2 \
diff --git a/test/regress/regress1/strings/timeout-no-resp.smt2 b/test/regress/regress1/strings/timeout-no-resp.smt2
new file mode 100644 (file)
index 0000000..65608da
--- /dev/null
@@ -0,0 +1,7 @@
+(set-logic SLIA)
+(set-info :status sat)
+(set-option :strings-exp true)
+(declare-const x String)
+(declare-const y String)
+(assert (not (= (str.replace "A" (str.replace x "A" y) x) (str.replace "A" x (str.replace x y x)))))
+(check-sat)
\ No newline at end of file