"a sequence of length one. First parameter is a SeqUnitOp. Second is a term"
operator SEQ_NTH 2 "The nth element of a sequence"
-operator SEQ_NTH_TOTAL 2 "The nth element of a sequence (internal, for responses to expand definitions only)"
# equal equal / less than / output
operator STRING_TO_REGEXP 1 "convert string to regexp"
typerule SEQ_UNIT_OP "SimpleTypeRule<RBuiltinOperator>"
typerule SEQ_UNIT ::cvc5::internal::theory::strings::SeqUnitTypeRule
typerule SEQ_NTH ::cvc5::internal::theory::strings::SeqNthTypeRule
-typerule SEQ_NTH_TOTAL ::cvc5::internal::theory::strings::SeqNthTypeRule
endtheory
{
retNode = rewriteSeqUnit(node);
}
- else if (nk == SEQ_NTH || nk == SEQ_NTH_TOTAL)
+ else if (nk == SEQ_NTH)
{
retNode = rewriteSeqNth(node);
}
return RewriteResponse(REWRITE_DONE, node);
}
-TrustNode SequencesRewriter::expandDefinition(Node node)
-{
- Trace("strings-exp-def") << "SequencesRewriter::expandDefinition : " << node
- << std::endl;
-
- if (node.getKind() == kind::SEQ_NTH)
- {
- NodeManager* nm = NodeManager::currentNM();
- Node s = node[0];
- Node n = node[1];
- // seq.nth(s, n) --> ite(0 <= n < len(s), seq.nth_total(s,n), Uf(s, n))
- Node cond = nm->mkNode(AND,
- nm->mkNode(LEQ, nm->mkConstInt(Rational(0)), n),
- nm->mkNode(LT, n, nm->mkNode(STRING_LENGTH, s)));
- Node ss = nm->mkNode(SEQ_NTH_TOTAL, s, n);
- Node uf = SkolemCache::mkSkolemSeqNth(s.getType(), "Uf");
- Node u = nm->mkNode(APPLY_UF, uf, s, n);
- Node ret = nm->mkNode(ITE, cond, ss, u);
- Trace("strings-exp-def") << "...return " << ret << std::endl;
- return TrustNode::mkTrustRewrite(node, ret, nullptr);
- }
- return TrustNode::null();
-}
-
Node SequencesRewriter::rewriteSeqNth(Node node)
{
- Assert(node.getKind() == SEQ_NTH || node.getKind() == SEQ_NTH_TOTAL);
+ Assert(node.getKind() == SEQ_NTH);
Node s = node[0];
Node i = node[1];
if (s.isConst() && i.isConst())
return returnRewrite(node, ret, Rewrite::SEQ_NTH_EVAL);
}
}
- if (node.getKind() == SEQ_NTH_TOTAL)
- {
- // return arbitrary term
- NodeManager* nm = NodeManager::currentNM();
- Node ret = nm->mkGroundValue(s.getType().getSequenceElementType());
- return returnRewrite(node, ret, Rewrite::SEQ_NTH_TOTAL_OOB);
- }
}
std::vector<Node> prefix, suffix;