From: Tianyi Liang Date: Mon, 22 Dec 2014 22:22:42 +0000 (-0600) Subject: bug fix for constant regular expression model building X-Git-Tag: cvc5-1.0.0~6457^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0b91c01cca013379265e798501a01cad5823c1b0;p=cvc5.git bug fix for constant regular expression model building --- diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp index f394047fa..67b055d33 100644 --- a/src/theory/strings/theory_strings.cpp +++ b/src/theory/strings/theory_strings.cpp @@ -479,6 +479,8 @@ void TheoryStrings::preRegisterTerm(TNode n) { case kind::STRING_IN_REGEXP: { d_out->requirePhase(n, true); d_equalityEngine.addTriggerPredicate(n); + d_equalityEngine.addTerm(n[0]); + d_equalityEngine.addTerm(n[1]); break; } //case kind::STRING_SUBSTR_TOTAL: diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp index 56f6a2ef0..f6c12a2e1 100644 --- a/src/theory/strings/theory_strings_rewriter.cpp +++ b/src/theory/strings/theory_strings_rewriter.cpp @@ -395,6 +395,20 @@ Node TheoryStringsRewriter::rewriteMembership(TNode node) { retNode = one.eqNode(NodeManager::currentNM()->mkNode(kind::STRING_LENGTH, x)); } else if(node[1].getKind() == kind::REGEXP_STAR && node[1][0].getKind() == kind::REGEXP_SIGMA) { retNode = NodeManager::currentNM()->mkConst( true ); + } else if(node[1].getKind() == kind::REGEXP_CONCAT) { + //opt + bool flag = true; + for(unsigned i=0; imkConst( ::CVC4::Rational( node[1].getNumChildren() ) ); + retNode = num.eqNode(NodeManager::currentNM()->mkNode(kind::STRING_LENGTH, x)); + } + // } else if(node[1].getKind() == kind::STRING_TO_REGEXP) { retNode = x.eqNode(node[1][0]); } else if(x != node[0]) { @@ -702,7 +716,7 @@ RewriteResponse TheoryStringsRewriter::preRewrite(TNode node) { retNode = prerewriteConcatRegExp(node); } else if(node.getKind() == kind::REGEXP_UNION) { retNode = prerewriteOrRegExp(node); - }else if(node.getKind() == kind::REGEXP_INTER) { + } else if(node.getKind() == kind::REGEXP_INTER) { retNode = prerewriteAndRegExp(node); } else if(node.getKind() == kind::REGEXP_STAR) { if(node[0].getKind() == kind::REGEXP_STAR) { diff --git a/src/theory/theory_model.cpp b/src/theory/theory_model.cpp index 1c62717c8..cb50bf355 100644 --- a/src/theory/theory_model.cpp +++ b/src/theory/theory_model.cpp @@ -198,9 +198,13 @@ Node TheoryModel::getModelValue(TNode n, bool hasBoundVars) const } if (!d_equalityEngine->hasTerm(n)) { - // Unknown term - return first enumerated value for this type - TypeEnumerator te(n.getType()); - ret = *te; + if(n.getType().isRegExp()) { + ret = Rewriter::rewrite(ret); + } else { + // Unknown term - return first enumerated value for this type + TypeEnumerator te(n.getType()); + ret = *te; + } d_modelCache[n] = ret; return ret; }