summaryrefslogtreecommitdiff
path: root/src/theory/strings/strings_rewriter.cpp
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2020-03-30 18:15:07 -0500
committerGitHub <noreply@github.com>2020-03-30 18:15:07 -0500
commitbc4055d4543f3b697ade38b810f7ac3cf02dc3c8 (patch)
treef66e1d9788fb9e7a5fbc1dfb98699da8f0298c92 /src/theory/strings/strings_rewriter.cpp
parent6838885b1250e0abbb1b8d56e6b400a5d7f3ca95 (diff)
Rewrites for all remaining return statements in strings rewriter (#4178)
Towards proofs for string rewrites. All return statements all now associated with an enum value. An indentation in a block of code changed in rewriteMembership.
Diffstat (limited to 'src/theory/strings/strings_rewriter.cpp')
-rw-r--r--src/theory/strings/strings_rewriter.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/theory/strings/strings_rewriter.cpp b/src/theory/strings/strings_rewriter.cpp
index 275c2e25e..28ed14095 100644
--- a/src/theory/strings/strings_rewriter.cpp
+++ b/src/theory/strings/strings_rewriter.cpp
@@ -143,6 +143,16 @@ Node StringsRewriter::rewriteStrConvert(Node node)
return node;
}
+Node StringsRewriter::rewriteStringLt(Node n)
+{
+ Assert(n.getKind() == kind::STRING_LT);
+ NodeManager* nm = NodeManager::currentNM();
+ // eliminate s < t ---> s != t AND s <= t
+ Node retNode = nm->mkNode(
+ AND, n[0].eqNode(n[1]).negate(), nm->mkNode(STRING_LEQ, n[0], n[1]));
+ return returnRewrite(n, retNode, Rewrite::STR_LT_ELIM);
+}
+
Node StringsRewriter::rewriteStringLeq(Node n)
{
Assert(n.getKind() == kind::STRING_LEQ);
@@ -241,6 +251,18 @@ Node StringsRewriter::rewriteStringToCode(Node n)
return n;
}
+Node StringsRewriter::rewriteStringIsDigit(Node n)
+{
+ Assert(n.getKind() == kind::STRING_IS_DIGIT);
+ NodeManager* nm = NodeManager::currentNM();
+ // eliminate str.is_digit(s) ----> 48 <= str.to_code(s) <= 57
+ Node t = nm->mkNode(STRING_TO_CODE, n[0]);
+ Node retNode = nm->mkNode(AND,
+ nm->mkNode(LEQ, nm->mkConst(Rational(48)), t),
+ nm->mkNode(LEQ, t, nm->mkConst(Rational(57))));
+ return returnRewrite(n, retNode, Rewrite::IS_DIGIT_ELIM);
+}
+
} // namespace strings
} // namespace theory
} // namespace CVC4
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback