Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.
/ CVC4-archived Public archive

Commit

Permalink
Add rewrite for str.replace_re. (#4601)
Browse files Browse the repository at this point in the history
This was discovered due to a proof checking abnormality, where the checker surprisingly succeeded in proving that the reduced form for a str.replace_re was equivalent for 2 different sets of skolems after rewriting.
  • Loading branch information
ajreynol authored Jun 12, 2020
1 parent ad87bbc commit 4d547e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/theory/strings/rewrites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const char* toString(Rewrite r)
case Rewrite::RPL_X_Y_X_SIMP: return "RPL_X_Y_X_SIMP";
case Rewrite::REPLACE_RE_EVAL: return "REPLACE_RE_EVAL";
case Rewrite::REPLACE_RE_ALL_EVAL: return "REPLACE_RE_ALL_EVAL";
case Rewrite::REPLACE_RE_EMP_RE: return "REPLACE_RE_EMP_RE";
case Rewrite::SPLIT_EQ: return "SPLIT_EQ";
case Rewrite::SPLIT_EQ_STRIP_L: return "SPLIT_EQ_STRIP_L";
case Rewrite::SPLIT_EQ_STRIP_R: return "SPLIT_EQ_STRIP_R";
Expand Down
1 change: 1 addition & 0 deletions src/theory/strings/rewrites.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ enum class Rewrite : uint32_t
RPL_X_Y_X_SIMP,
REPLACE_RE_EVAL,
REPLACE_RE_ALL_EVAL,
REPLACE_RE_EMP_RE,
SPLIT_EQ,
SPLIT_EQ_STRIP_L,
SPLIT_EQ_STRIP_R,
Expand Down
7 changes: 7 additions & 0 deletions src/theory/strings/sequences_rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,13 @@ Node SequencesRewriter::rewriteReplaceRe(Node node)
return returnRewrite(node, x, Rewrite::REPLACE_RE_EVAL);
}
}
// str.replace_re( x, y, z ) ---> z ++ x if "" in y ---> true
String emptyStr("");
if (RegExpEntail::testConstStringInRegExp(emptyStr, 0, y))
{
Node ret = nm->mkNode(STRING_CONCAT, z, x);
return returnRewrite(node, ret, Rewrite::REPLACE_RE_EMP_RE);
}
return node;
}

Expand Down

0 comments on commit 4d547e5

Please sign in to comment.