From: Andrew Reynolds Date: Mon, 7 Feb 2022 18:17:13 +0000 (-0600) Subject: Fix indexof_re reduction (#8065) X-Git-Tag: cvc5-1.0.0~447 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f4b167eb29e2716e996450d844a8bd4de626d7f6;p=cvc5.git Fix indexof_re reduction (#8065) Fixes https://github.com/cvc5/cvc5/issues/6654. Note that this regression now answers unknown with `--ext-rewrite-quant`; the regression without this option is added. --- diff --git a/src/theory/strings/theory_strings_preprocess.cpp b/src/theory/strings/theory_strings_preprocess.cpp index 97dbd2b3f..56dcbe25c 100644 --- a/src/theory/strings/theory_strings_preprocess.cpp +++ b/src/theory/strings/theory_strings_preprocess.cpp @@ -298,11 +298,14 @@ Node StringsPreprocess::reduce(Node t, validLen, nm->mkNode(STRING_IN_REGEXP, nm->mkNode(STRING_SUBSTR, s, skk, l), r)); // skk != -1 => - // exists l. (0 <= l < len(s) - skk) ^ in_re(substr(s, skk, l), r)) - Node match = - nm->mkNode(OR, - retNegOne, - utils::mkForallInternal(bvll, matchBody.negate()).negate()); + // skk >= n ^ exists l. (0 <= l < len(s) - skk) ^ in_re(substr(s, skk, l), + // r)) + Node match = nm->mkNode( + OR, + retNegOne, + nm->mkNode(AND, + nm->mkNode(GEQ, skk, n), + utils::mkForallInternal(bvll, matchBody.negate()).negate())); // assert: // IF: n > len(s) OR 0 > n @@ -313,7 +316,8 @@ Node StringsPreprocess::reduce(Node t, // n <= i < ite(skk = -1, len(s), skk) ^ 0 < l <= len(s) - i => // ~in_re(substr(s, i, l), r)) ^ // (skk != -1 => - // exists l. 0 <= l <= len(s) - skk ^ in_re(substr(s, skk, l), r)) + // skk >= n ^ exists l. 0 <= l <= len(s) - skk ^ in_re(substr(s, + // skk, l), r)) // // Note that this reduction relies on eager reduction lemmas being sent to // properly limit the range of skk. diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index 1d231ea88..7698b19aa 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -2404,6 +2404,7 @@ set(regress_1_tests regress1/strings/issue6653-4-rre.smt2 regress1/strings/issue6653-rre.smt2 regress1/strings/issue6653-rre-small.smt2 + regress1/strings/issue6654-indexof_re_red.smt2 regress1/strings/issue6766-re-elim-bv.smt2 regress1/strings/issue6777-seq-nth-eval-cm.smt2 regress1/strings/issue6913.smt2 diff --git a/test/regress/regress1/strings/issue6654-indexof_re_red.smt2 b/test/regress/regress1/strings/issue6654-indexof_re_red.smt2 new file mode 100644 index 000000000..73607e424 --- /dev/null +++ b/test/regress/regress1/strings/issue6654-indexof_re_red.smt2 @@ -0,0 +1,8 @@ +; COMMAND-LINE: --strings-exp +; EXPECT: sat +(set-logic ALL) +(declare-fun a () String) +(declare-fun b () String) +(assert (= b (str.replace_re a (str.to_re "A") "A"))) +(assert (not (str.prefixof (str.++ b b) a))) +(check-sat)