diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/theory/strings/theory_strings_rewriter.cpp | 3 | ||||
-rw-r--r-- | src/theory/strings/theory_strings_rewriter.h | 30 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp index 78def9c0a..4ab81da7c 100644 --- a/src/theory/strings/theory_strings_rewriter.cpp +++ b/src/theory/strings/theory_strings_rewriter.cpp @@ -31,6 +31,7 @@ using namespace CVC4::theory; using namespace CVC4::theory::strings; Node TheoryStringsRewriter::simpleRegexpConsume( std::vector< Node >& mchildren, std::vector< Node >& children, int dir ){ + NodeManager* nm = NodeManager::currentNM(); unsigned tmin = dir<0 ? 0 : dir; unsigned tmax = dir<0 ? 1 : dir; //try to remove off front and back @@ -61,7 +62,7 @@ Node TheoryStringsRewriter::simpleRegexpConsume( std::vector< Node >& mchildren, if( index==0 ){ mchildren.push_back( s ); }else{ - children.push_back( s ); + children.push_back(nm->mkNode(STRING_TO_REGEXP, s)); } } do_next = true; diff --git a/src/theory/strings/theory_strings_rewriter.h b/src/theory/strings/theory_strings_rewriter.h index 8befb5e0f..4c78a1945 100644 --- a/src/theory/strings/theory_strings_rewriter.h +++ b/src/theory/strings/theory_strings_rewriter.h @@ -28,7 +28,35 @@ namespace theory { namespace strings { class TheoryStringsRewriter { -private: + private: + /** simple regular expression consume + * + * This method is called when we are rewriting a membership of the form + * s1 ++ ... ++ sn in r1 ++ ... ++ rm + * We have that mchildren consists of the strings s1...sn, and children + * consists of the regular expressions r1...rm. + * + * This method tries to strip off parts of the concatenation terms. It updates + * the vectors such that the resulting vectors are such that the membership + * mchildren[n'...n''] in children[m'...m''] is equivalent to the input + * membership. The argument dir indicates the direction to consider, where + * 0 means strip off the front, 1 off the back, and < 0 off of both. + * + * If this method returns the false node, then we have inferred that the input + * membership is equivalent to false. Otherwise, it returns the null node. + * + * For example, given input + * mchildren = { "ab", x }, children = { [["a"]], ([["cd"]])* } and dir = 0, + * this method updates: + * mchildren = { "b", x }, children = { ("cd")* } + * and returns null. + * + * For example, given input + * { x, "abb", x }, { [[x]], ["a"..."b"], allchar, [[y]], [[x]]} and dir=-1, + * this method updates: + * { "b" }, { [[y]] } + * where [[.]] denotes str.to.re, and returns null. + */ static Node simpleRegexpConsume( std::vector< Node >& mchildren, std::vector< Node >& children, int dir = -1 ); static bool isConstRegExp( TNode t ); static bool testConstStringInRegExp( CVC4::String &s, unsigned int index_start, TNode r ); |