From: Andrew Reynolds Date: Fri, 19 Feb 2021 14:43:22 +0000 (-0600) Subject: Fix rewrite for contains over replace (#5924) X-Git-Tag: cvc5-1.0.0~2259 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=00479d03cdeac3e864a1930dddb16c71c5bf2ce9;p=cvc5.git Fix rewrite for contains over replace (#5924) Fixes model soundness issue (fixes #5915). --- diff --git a/src/theory/strings/sequences_rewriter.cpp b/src/theory/strings/sequences_rewriter.cpp index 2a30727ba..be1bd9045 100644 --- a/src/theory/strings/sequences_rewriter.cpp +++ b/src/theory/strings/sequences_rewriter.cpp @@ -2206,7 +2206,7 @@ Node SequencesRewriter::rewriteContains(Node node) // if (str.contains z w) ---> false and (str.len w) = 1 if (StringsEntail::checkLengthOne(node[1])) { - Node ctn = d_stringsEntail.checkContains(node[1], node[0][2]); + Node ctn = d_stringsEntail.checkContains(node[0][2], node[1]); if (!ctn.isNull() && !ctn.getConst()) { Node empty = Word::mkEmptyWord(stype); @@ -2558,7 +2558,7 @@ Node SequencesRewriter::rewriteReplace(Node node) // check if contains definitely does (or does not) hold Node cmp_con = nm->mkNode(kind::STRING_STRCTN, node[0], node[1]); Node cmp_conr = Rewriter::rewrite(cmp_con); - if (!d_stringsEntail.checkContains(node[0], node[1]).isNull()) + if (cmp_conr.isConst()) { if (cmp_conr.getConst()) { diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index d455bb85b..fa4628de7 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -1115,6 +1115,7 @@ set(regress_0_tests regress0/strings/issue5767-eager-pp.smt2 regress0/strings/issue5771-eager-pp.smt2 regress0/strings/issue5816-re-kind.smt2 + regress0/strings/issue5915-repl-ctn-rewrite.smt2 regress0/strings/itos-entail.smt2 regress0/strings/large-model.smt2 regress0/strings/leadingzero001.smt2 diff --git a/test/regress/regress0/strings/issue5915-repl-ctn-rewrite.smt2 b/test/regress/regress0/strings/issue5915-repl-ctn-rewrite.smt2 new file mode 100644 index 000000000..42326da28 --- /dev/null +++ b/test/regress/regress0/strings/issue5915-repl-ctn-rewrite.smt2 @@ -0,0 +1,9 @@ +; COMMAND-LINE: --strings-exp +; EXPECT: unsat +(set-logic ALL) +(set-info :status unsat) +(declare-fun x () String) +(declare-fun y () String) +(declare-fun z () Int) +(assert (= (str.replace (str.replace x "B" (str.++ "B" "B")) "B" (str.++ y "B")) (str.++ y "B"))) +(check-sat)