// e.g. x++y = x++z ---> y = z, "AB" ++ x = "A" ++ y --> "B" ++ x = y
Node s1 = utils::mkConcat(c[0], stype);
Node s2 = utils::mkConcat(c[1], stype);
- new_ret = s1.eqNode(s2);
- node = returnRewrite(node, new_ret, Rewrite::STR_EQ_UNIFY);
+ if (s1 != node[0] || s2 != node[1])
+ {
+ new_ret = s1.eqNode(s2);
+ // We generally don't apply the extended equality rewriter if the
+ // original node was an equality but we may be able to do additional
+ // rewriting here, e.g.,
+ // x++y = "" --> x = "" and y = ""
+ return returnRewrite(node, new_ret, Rewrite::STR_EQ_UNIFY, true);
+ }
}
// ------- homogeneous constants
// e.g.
// "AA" = y ++ x ---> "AA" = x ++ y if x < y
// "AAA" = y ++ "A" ++ z ---> "AA" = y ++ z
+ //
+ // We generally don't apply the extended equality rewriter if the
+ // original node was an equality but we may be able to do additional
+ // rewriting here.
new_ret = lhs.eqNode(ss);
- node = returnRewrite(node, new_ret, Rewrite::STR_EQ_HOMOG_CONST);
+ return returnRewrite(node, new_ret, Rewrite::STR_EQ_HOMOG_CONST, true);
}
}
}
return node;
}
-Node SequencesRewriter::returnRewrite(Node node, Node ret, Rewrite r)
+Node SequencesRewriter::returnRewrite(Node node,
+ Node ret,
+ Rewrite r,
+ bool rewriteEqAgain)
{
Trace("strings-rewrite") << "Rewrite " << node << " to " << ret << " by " << r
<< "." << std::endl;
{
ret = nm->mkNode(NOT, rewriteEqualityExt(ret[0]));
}
- else if (retk == EQUAL && node.getKind() != EQUAL)
+ else if (retk == EQUAL && (rewriteEqAgain || node.getKind() != EQUAL))
{
Trace("strings-rewrite")
<< "Apply extended equality rewrite on " << ret << std::endl;
* The rewrite r indicates the justification for the rewrite, which is printed
* by this function for debugging.
*
- * If node is not an equality and ret is an equality, this method applies
- * an additional rewrite step (rewriteEqualityExt) that performs
- * additional rewrites on ret, after which we return the result of this call.
- * Otherwise, this method simply returns ret.
- */
- Node returnRewrite(Node node, Node ret, Rewrite r);
+ * If node is not an equality (or rewriteEq is true) and ret is an equality,
+ * this method applies an additional rewrite step (rewriteEqualityExt) that
+ * performs additional rewrites on ret, after which we return the result of
+ * this call. Otherwise, this method simply returns ret.
+ */
+ Node returnRewrite(Node node,
+ Node ret,
+ Rewrite r,
+ bool rewriteEqAgain = false);
public:
RewriteResponse postRewrite(TNode node) override;
regress0/strings/issue6604-re-elim.smt2
regress0/strings/issue6643-ctn-decompose-conflict.smt2
regress0/strings/issue6681-split-eq-strip-l.smt2
+ regress0/strings/issue6834-str-eq-const-nhomog.smt2
regress0/strings/itos-entail.smt2
regress0/strings/large-model.smt2
regress0/strings/leadingzero001.smt2