<< "DTypeConstructor::getSpecializedConstructorType: expected datatype, "
"got "
<< returnType;
+ TypeNode ctn = d_constructor.getType();
const DType& dt = DType::datatypeOf(d_constructor);
- Assert(dt.isParametric());
+ if (!dt.isParametric())
+ {
+ // if the datatype is not parametric, then no specialization is needed
+ return ctn;
+ }
TypeNode dtt = dt.getTypeNode();
TypeMatcher m(dtt);
m.doMatching(dtt, returnType);
std::vector<TypeNode> subst;
m.getMatches(subst);
std::vector<TypeNode> params = dt.getParameters();
- return d_constructor.getType().substitute(
+ return ctn.substitute(
params.begin(), params.end(), subst.begin(), subst.end());
}
DECLARE_DATATYPES_TOK : { PARSER_STATE->v2_6() || PARSER_STATE->sygus() }?'declare-datatypes';
DECLARE_CODATATYPES_2_5_TOK : { !( PARSER_STATE->v2_6() || PARSER_STATE->sygus() ) }?'declare-codatatypes';
DECLARE_CODATATYPES_TOK : { PARSER_STATE->v2_6() || PARSER_STATE->sygus() }?'declare-codatatypes';
-PAR_TOK : { PARSER_STATE->v2_6() }?'par';
+PAR_TOK : { PARSER_STATE->v2_6() || PARSER_STATE->sygus() }?'par';
COMPREHENSION_TOK : { PARSER_STATE->isTheoryEnabled(theory::THEORY_SETS) }?'comprehension';
TESTER_TOK : { ( PARSER_STATE->v2_6() || PARSER_STATE->sygus() ) && PARSER_STATE->isTheoryEnabled(theory::THEORY_DATATYPES) }?'is';
MATCH_TOK : { ( PARSER_STATE->v2_6() || PARSER_STATE->sygus() ) && PARSER_STATE->isTheoryEnabled(theory::THEORY_DATATYPES) }?'match';
const DType& dt = range.getDType();
for (unsigned i = 0, size = dt.getNumConstructors(); i < size; ++i)
{
- for (unsigned j = 0, size_args = dt[i].getNumArgs(); j < size_args;
- ++j)
+ // get the specialized constructor type, which accounts for
+ // parametric datatypes
+ TypeNode ctn = dt[i].getSpecializedConstructorType(range);
+ std::vector<TypeNode> argTypes = ctn.getArgTypes();
+ for (size_t j = 0, nargs = argTypes.size(); j < nargs; ++j)
{
- TypeNode tn = dt[i][j].getRangeType();
- collectSygusGrammarTypesFor(tn, types);
+ collectSygusGrammarTypesFor(argTypes[j], types);
}
}
}
{
Trace("sygus-grammar-def") << "...for " << dt[l].getName() << std::endl;
Node cop = dt[l].getConstructor();
+ TypeNode tspec = dt[l].getSpecializedConstructorType(types[i]);
+ // must specialize if a parametric datatype
+ if (dt.isParametric())
+ {
+ cop = nm->mkNode(
+ APPLY_TYPE_ASCRIPTION, nm->mkConst(AscriptionType(tspec)), cop);
+ }
if (dt[l].getNumArgs() == 0)
{
// Nullary constructors are interpreted as terms, not operators.
}
std::vector<TypeNode> cargsCons;
Trace("sygus-grammar-def") << "...add for selectors" << std::endl;
- for (unsigned j = 0, size_j = dt[l].getNumArgs(); j < size_j; ++j)
+ // iterate over the arguments of the specialized constructor type,
+ // which accounts for parametric datatypes
+ std::vector<TypeNode> tsargs = tspec.getArgTypes();
+ TypeNode selDomain = type_to_unres[types[i]];
+ for (unsigned j = 0, size_j = tsargs.size(); j < size_j; ++j)
{
Trace("sygus-grammar-def")
<< "...for " << dt[l][j].getName() << std::endl;
- TypeNode crange = dt[l][j].getRangeType();
+ TypeNode crange = tsargs[j];
Assert(type_to_unres.find(crange) != type_to_unres.end());
cargsCons.push_back(type_to_unres[crange]);
// add to the selector type the selector operator
Assert(std::find(types.begin(), types.end(), crange) != types.end());
unsigned i_selType = std::distance(
types.begin(), std::find(types.begin(), types.end(), crange));
- TypeNode arg_type = dt[l][j].getType();
- arg_type = arg_type.getSelectorDomainType();
- Assert(type_to_unres.find(arg_type) != type_to_unres.end());
std::vector<TypeNode> cargsSel;
- cargsSel.push_back(type_to_unres[arg_type]);
+ cargsSel.push_back(selDomain);
Node sel = dt[l][j].getSelector();
sdts[i_selType].addConstructor(sel, dt[l][j].getName(), cargsSel);
}