summaryrefslogtreecommitdiff
path: root/src/theory/quantifiers
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2020-03-06 09:24:11 -0600
committerGitHub <noreply@github.com>2020-03-06 09:24:11 -0600
commit210e6db5c6a76ee1e554426058ecf3397575f1e3 (patch)
tree98140a04acd9eedc91e2d598224ac7005d0a3540 /src/theory/quantifiers
parenta727f6314c8f2ad72d8d83eb63c413bab68d1b08 (diff)
Support default sygus grammar construction for sets (#3842)
Fixes #3645.
Diffstat (limited to 'src/theory/quantifiers')
-rw-r--r--src/theory/quantifiers/sygus/sygus_grammar_cons.cpp65
1 files changed, 50 insertions, 15 deletions
diff --git a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp
index 259f9c642..17cc6bf9e 100644
--- a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp
+++ b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp
@@ -409,7 +409,7 @@ void CegGrammarConstructor::mkSygusConstantsForType(TypeNode type,
{
ops.push_back(nm->mkConst(String("")));
}
- else if (type.isArray())
+ else if (type.isArray() || type.isSet())
{
// generate constant array over the first element of the constituent type
Node c = type.mkGroundTerm();
@@ -443,6 +443,10 @@ void CegGrammarConstructor::collectSygusGrammarTypesFor(
collectSygusGrammarTypesFor(range.getArrayIndexType(), types);
collectSygusGrammarTypesFor(range.getArrayConstituentType(), types);
}
+ else if (range.isSet())
+ {
+ collectSygusGrammarTypesFor(range.getSetElementType(), types);
+ }
else if (range.isString() )
{
// theory of strings shares the integer type
@@ -791,22 +795,17 @@ void CegGrammarConstructor::mkSygusDefaultGrammar(
{
Trace("sygus-grammar-def")
<< "...building for array type " << types[i] << "\n";
- Trace("sygus-grammar-def") << "......finding unres type for index type "
- << types[i].getArrayIndexType() << "\n";
+ TypeNode indexType = types[i].getArrayIndexType();
+ TypeNode elemType = types[i].getArrayConstituentType();
+ Trace("sygus-grammar-def")
+ << "......finding unres type for index type " << indexType << "\n";
// retrieve index and constituent unresolved types
- Assert(std::find(types.begin(), types.end(), types[i].getArrayIndexType())
- != types.end());
- unsigned i_indexType = std::distance(
- types.begin(),
- std::find(types.begin(), types.end(), types[i].getArrayIndexType()));
- TypeNode unres_indexType = unres_types[i_indexType];
- Assert(std::find(
- types.begin(), types.end(), types[i].getArrayConstituentType())
- != types.end());
+ Assert(type_to_unres.find(indexType) != type_to_unres.end());
+ TypeNode unres_indexType = type_to_unres[indexType];
+ Assert(std::find(types.begin(), types.end(), elemType) != types.end());
+ // must get this index since we add to sdt[i_constituentType] below.
unsigned i_constituentType = std::distance(
- types.begin(),
- std::find(
- types.begin(), types.end(), types[i].getArrayConstituentType()));
+ types.begin(), std::find(types.begin(), types.end(), elemType));
TypeNode unres_constituentType = unres_types[i_constituentType];
// add (store ArrayType IndexType ConstituentType)
Trace("sygus-grammar-def") << "...add for STORE\n";
@@ -824,6 +823,30 @@ void CegGrammarConstructor::mkSygusDefaultGrammar(
cargsSelect.push_back(unres_indexType);
sdts[i_constituentType].addConstructor(SELECT, cargsSelect);
}
+ else if (types[i].isSet())
+ {
+ TypeNode etype = types[i].getSetElementType();
+ // retrieve element unresolved type
+ Assert(type_to_unres.find(etype) != type_to_unres.end());
+ TypeNode unresElemType = type_to_unres[etype];
+
+ // add for singleton
+ Trace("sygus-grammar-def") << "...add for singleton" << std::endl;
+ std::vector<TypeNode> cargsSingleton;
+ cargsSingleton.push_back(unresElemType);
+ sdts[i].addConstructor(SINGLETON, cargsSingleton);
+
+ // add for union, difference, intersection
+ std::vector<Kind> bin_kinds = {UNION, INTERSECTION, SETMINUS};
+ std::vector<TypeNode> cargsBinary;
+ cargsBinary.push_back(unres_t);
+ cargsBinary.push_back(unres_t);
+ for (const Kind k : bin_kinds)
+ {
+ Trace("sygus-grammar-def") << "...add for " << k << std::endl;
+ sdts[i].addConstructor(k, cargsBinary);
+ }
+ }
else if (types[i].isDatatype())
{
Trace("sygus-grammar-def") << "...add for constructors" << std::endl;
@@ -1197,6 +1220,18 @@ void CegGrammarConstructor::mkSygusDefaultGrammar(
sdtBool.addConstructor(dt[kind].getTester(), sst.str(), cargsTester);
}
}
+ else if (types[i].isSet())
+ {
+ // add for member
+ TypeNode etype = types[i].getSetElementType();
+ Assert(type_to_unres.find(etype) != type_to_unres.end());
+ TypeNode unresElemType = type_to_unres[etype];
+ std::vector<TypeNode> cargsMember;
+ cargsMember.push_back(unresElemType);
+ cargsMember.push_back(unres_types[iuse]);
+ Trace("sygus-grammar-def") << "...for MEMBER" << std::endl;
+ sdtBool.addConstructor(MEMBER, cargsMember);
+ }
}
// add Boolean connectives, if not in a degenerate case of (recursively)
// having only constant constructors
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback