diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2019-08-02 13:56:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-02 13:56:39 -0500 |
commit | 12bad5f9c981dd1a328dd769176e87e39a041f91 (patch) | |
tree | a677cef3e87318ae088ac4896710d5a081688931 /src/theory | |
parent | daeab65ac6c6715a3e0c2f6fc0e61b1a7925b932 (diff) |
Support default sygus grammar for strings (#3148)
Diffstat (limited to 'src/theory')
-rw-r--r-- | src/theory/quantifiers/sygus/ce_guided_single_inv.cpp | 16 | ||||
-rw-r--r-- | src/theory/quantifiers/sygus/sygus_grammar_cons.cpp | 31 |
2 files changed, 44 insertions, 3 deletions
diff --git a/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp b/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp index 00d040af5..3fbb4eaee 100644 --- a/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp +++ b/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp @@ -363,17 +363,27 @@ void CegSingleInv::finishInit(bool syntaxRestricted) d_single_inv_arg_sk.begin(), d_single_inv_arg_sk.end()); Trace("cegqi-si") << "Single invocation formula is : " << d_single_inv << std::endl; - if( options::cbqiPreRegInst() && d_single_inv.getKind()==FORALL ){ + // check whether we can handle this quantified formula + CegHandledStatus status = CegInstantiator::isCbqiQuant(d_single_inv); + if( status<CEG_HANDLED ) + { + Trace("cegqi-si") << "...do not invoke single invocation techniques since the quantified formula does not have a handled counterexample-guided instantiation strategy!" << std::endl; + d_single_invocation = false; + d_single_inv = Node::null(); + } + else if( options::cbqiPreRegInst() && d_single_inv.getKind()==FORALL ){ //just invoke the presolve now d_cinst->presolve( d_single_inv ); } - }else{ + } + if( !d_single_invocation ) + { d_single_inv = Node::null(); Trace("cegqi-si") << "Formula is not single invocation." << std::endl; if (options::cegqiSingleInvAbort()) { std::stringstream ss; - ss << "Property is not single invocation." << std::endl; + ss << "Property is not handled by single invocation." << std::endl; throw LogicException(ss.str()); } } diff --git a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp index bcd0d709e..bb8da59da 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp +++ b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp @@ -420,6 +420,12 @@ void CegGrammarConstructor::collectSygusGrammarTypesFor( collectSygusGrammarTypesFor( TypeNode::fromType(arrayType.getConstituentType()), types); } + else if (range.isString() ) + { + // theory of strings shares the integer type + TypeNode intType = NodeManager::currentNM()->integerType(); + collectSygusGrammarTypesFor(intType,types); + } } } } @@ -670,6 +676,31 @@ void CegGrammarConstructor::mkSygusDefaultGrammar( weights[i].push_back(-1); } } + else if (types[i].isString()) + { + // concatenation + ops[i].push_back(nm->operatorOf(STRING_CONCAT).toExpr()); + cnames[i].push_back(kindToString(STRING_CONCAT)); + cargs[i].push_back(std::vector<Type>()); + cargs[i].back().push_back(unres_t); + cargs[i].back().push_back(unres_t); + pcs[i].push_back(nullptr); + weights[i].push_back(-1); + // length + TypeNode intType = nm->integerType(); + Assert(std::find(types.begin(),types.end(),intType)!=types.end()); + unsigned i_intType = std::distance( + types.begin(), + std::find(types.begin(), + types.end(), + intType)); + ops[i_intType].push_back(nm->operatorOf(STRING_LENGTH).toExpr()); + cnames[i_intType].push_back(kindToString(STRING_LENGTH)); + cargs[i_intType].push_back(std::vector<Type>()); + cargs[i_intType].back().push_back(unres_t); + pcs[i_intType].push_back(nullptr); + weights[i_intType].push_back(-1); + } else if (types[i].isArray()) { ArrayType arrayType = static_cast<ArrayType>(types[i].toType()); |