From: Andres Noetzli Date: Tue, 30 Apr 2019 19:32:50 +0000 (-0700) Subject: Fix concat-find regexp elimination (#2983) X-Git-Tag: cvc5-1.0.0~4157 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d998d5e4213503e0913581d57c09ad486cded5c1;p=cvc5.git Fix concat-find regexp elimination (#2983) --- diff --git a/src/theory/strings/regexp_elim.cpp b/src/theory/strings/regexp_elim.cpp index afffce2c8..b6a997629 100644 --- a/src/theory/strings/regexp_elim.cpp +++ b/src/theory/strings/regexp_elim.cpp @@ -347,10 +347,10 @@ Node RegExpElimination::eliminateConcat(Node atom) for (unsigned r = 0; r < 2; r++) { unsigned index = r == 0 ? 0 : nchildren - 1; - Assert(children[index + (r == 0 ? 1 : -1)].getKind() != STRING_TO_REGEXP); Node c = children[index]; if (c.getKind() == STRING_TO_REGEXP) { + Assert(children[index + (r == 0 ? 1 : -1)].getKind() != STRING_TO_REGEXP); Node s = c[0]; Node lens = nm->mkNode(STRING_LENGTH, s); Node sss = r == 0 ? d_zero : nm->mkNode(MINUS, lenx, lens); @@ -375,9 +375,9 @@ Node RegExpElimination::eliminateConcat(Node atom) rexpElimChildren.push_back(c); } } - Assert(rexpElimChildren.size() + sConstraints.size() == nchildren); if (!sConstraints.empty()) { + Assert(rexpElimChildren.size() + sConstraints.size() == nchildren); Node ss = nm->mkNode(STRING_SUBSTR, x, sStartIndex, sLength); Assert(!rexpElimChildren.empty()); Node regElim = @@ -412,7 +412,7 @@ Node RegExpElimination::eliminateConcat(Node atom) Node bound = nm->mkNode(AND, nm->mkNode(LEQ, d_zero, k), - nm->mkNode(LT, k, nm->mkNode(MINUS, lenx, lens))); + nm->mkNode(LEQ, k, nm->mkNode(MINUS, lenx, lens))); echildren.push_back(bound); } Node substrEq = nm->mkNode(STRING_SUBSTR, x, k, lens).eqNode(s); diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index d8adbb59e..714459a85 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -1537,6 +1537,7 @@ set(regress_1_tests regress1/strings/issue2060.smt2 regress1/strings/issue2429-code.smt2 regress1/strings/issue2981.smt2 + regress1/strings/issue2982.smt2 regress1/strings/kaluza-fl.smt2 regress1/strings/loop002.smt2 regress1/strings/loop003.smt2 diff --git a/test/regress/regress1/strings/issue2982.smt2 b/test/regress/regress1/strings/issue2982.smt2 new file mode 100644 index 000000000..41be8d1fd --- /dev/null +++ b/test/regress/regress1/strings/issue2982.smt2 @@ -0,0 +1,23 @@ +; COMMAND-LINE: --strings-exp --re-elim --re-elim-agg +; EXPECT: unsat +(set-logic QF_SLIA) + +(declare-fun var_0 () String) +(declare-fun var_1 () String) +(declare-fun var_2 () String) +(declare-fun var_3 () String) +(declare-fun var_4 () String) +(declare-fun var_5 () String) +(declare-fun var_6 () String) +(declare-fun var_7 () String) +(declare-fun var_8 () String) +(declare-fun var_9 () String) +(declare-fun var_10 () String) +(declare-fun var_11 () String) +(declare-fun var_12 () String) + +(assert (str.in.re (str.++ var_7 "z" var_7 ) (re.* (str.to.re "z")))) +(assert (str.in.re var_7 (re.* (re.range "a" "u")))) +(assert (not (str.in.re (str.++ "a" var_7 "z" "a" var_7 ) (re.++ (re.* (re.union (str.to.re "z") (re.++ (str.to.re "a") (re.++ (re.* (str.to.re "a")) (str.to.re "z"))))) (re.++ (str.to.re "a") (re.* (str.to.re "a"))))))) +(assert (and (<= (str.len var_7) 0 ) (<= 0 (str.len var_7)))) +(check-sat)