summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorajreynol <andrew.j.reynolds@gmail.com>2018-06-19 12:31:50 -0500
committerajreynol <andrew.j.reynolds@gmail.com>2018-06-19 12:31:50 -0500
commit9e760bef9ef0fb8244965dac845820a8dffde21e (patch)
tree5b2ae440e44097118005ccd80522884c1d6520f7
parentdfbdb6bf7890fa642d64a76acaa95d3ab1f8e32f (diff)
Fix, empty-subs rewrite.
-rw-r--r--src/theory/strings/theory_strings_rewriter.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp
index c1c06b8df..15729916d 100644
--- a/src/theory/strings/theory_strings_rewriter.cpp
+++ b/src/theory/strings/theory_strings_rewriter.cpp
@@ -2156,6 +2156,24 @@ Node TheoryStringsRewriter::rewriteReplace( Node node ) {
return returnRewrite(node, ret, "rpl-const-find");
}
}
+
+ if( node[0].isConst() )
+ {
+ // str.replace( "", x, t ) ---> str.replace( "", x, t{x->""} )
+ CVC4::String s = node[0].getConst<String>();
+ if( s.empty() )
+ {
+ TNode v = node[1];
+ TNode s = node[0];
+ Node sn2 = node[2].substitute(v,s);
+ if( sn2!=node[2] )
+ {
+ Node ret = nm->mkNode( STRING_STRREPL, node[0], node[1], sn2 );
+ Trace("ajr-temp") << "rew : " << node << " -> " << ret << std::endl;
+ return returnRewrite(node, ret, "repl-empty-subs");
+ }
+ }
+ }
if (node[0] == node[2])
{
@@ -2356,6 +2374,8 @@ Node TheoryStringsRewriter::rewriteReplace( Node node ) {
cmp_con = Rewriter::rewrite( cmp_con );
if( cmp_con.isConst() && !cmp_con.getConst<bool>() )
{
+ cmp_con = nm->mkNode(STRING_STRCTN, node[0], node[1][2]);
+ cmp_con = Rewriter::rewrite( cmp_con );
invSuccess = cmp_con.isConst() && !cmp_con.getConst<bool>();
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback