case Rewrite::RE_IN_SIGMA_STAR: return "RE_IN_SIGMA_STAR";
case Rewrite::RE_IN_CHAR_MODULUS_STAR: return "RE_IN_CHAR_MODULUS_STAR";
case Rewrite::RE_LOOP: return "RE_LOOP";
+ case Rewrite::RE_LOOP_NONE: return "RE_LOOP_NONE";
case Rewrite::RE_LOOP_STAR: return "RE_LOOP_STAR";
case Rewrite::RE_OR_ALL: return "RE_OR_ALL";
case Rewrite::RE_SIMPLE_CONSUME: return "RE_SIMPLE_CONSUME";
Node SequencesRewriter::rewriteLoopRegExp(TNode node)
{
Assert(node.getKind() == REGEXP_LOOP);
- Node retNode = node;
+ uint32_t l = utils::getLoopMinOccurrences(node);
+ uint32_t u = utils::getLoopMaxOccurrences(node);
Node r = node[0];
- if (r.getKind() == REGEXP_STAR)
+ Node retNode = node;
+
+ NodeManager* nm = NodeManager::currentNM();
+ if (u < l)
+ {
+ // ((_ re.loop l u) r) --> re.none if u < l
+ std::vector<Node> nvec;
+ retNode = nm->mkNode(REGEXP_NONE, nvec);
+ return returnRewrite(node, retNode, Rewrite::RE_LOOP_NONE);
+ }
+ else if (r.getKind() == REGEXP_STAR)
{
return returnRewrite(node, r, Rewrite::RE_LOOP_STAR);
}
- NodeManager* nm = NodeManager::currentNM();
- cvc5::Rational rMaxInt(String::maxSize());
- uint32_t l = utils::getLoopMinOccurrences(node);
+
std::vector<Node> vec_nodes;
for (unsigned i = 0; i < l; i++)
{
vec_nodes.size() == 0
? nm->mkNode(STRING_TO_REGEXP, nm->mkConst(String("")))
: vec_nodes.size() == 1 ? r : nm->mkNode(REGEXP_CONCAT, vec_nodes);
- uint32_t u = utils::getLoopMaxOccurrences(node);
- if (u < l)
- {
- std::vector<Node> nvec;
- retNode = nm->mkNode(REGEXP_NONE, nvec);
- }
- else if (u == l)
+ if (u == l)
{
retNode = n;
}
regress0/strings/parser-syms.cvc.smt2
regress0/strings/proj-issue316-regexp-ite.smt2
regress0/strings/proj-issue390-update-rev-rewrite.smt2
+ regress0/strings/proj-issue409-re-loop-none.smt2
regress0/strings/re_diff.smt2
regress0/strings/re-in-rewrite.smt2
regress0/strings/re-syntax.smt2