<< "Arity mismatch for instantiated sort constructor";
//////// all checks before this line
std::vector<internal::TypeNode> tparams = sortVectorToTypeNodes(params);
- if (d_type->isDatatype())
- {
- return Sort(d_solver, d_type->instantiateParametricDatatype(tparams));
- }
- Assert(d_type->isUninterpretedSortConstructor());
- return Sort(d_solver, d_solver->getNodeManager()->mkSort(*d_type, tparams));
+ return Sort(d_solver, d_type->instantiate(tparams));
////////
CVC5_API_TRY_CATCH_END;
}
{
Assert(isResolved());
Assert(!d_self.isNull() && d_self.isParametricDatatype());
- return d_self.instantiateParametricDatatype(params);
+ return d_self.instantiate(params);
}
const DTypeConstructor& DType::operator[](size_t index) const
if (paramTypes[i].getUninterpretedSortConstructorArity()
== origChildren.size())
{
- TypeNode tn = paramTypes[i].instantiateSortConstructor(origChildren);
+ TypeNode tn = paramTypes[i].instantiate(origChildren);
if (range == tn)
{
- TypeNode tret =
- paramReplacements[i].instantiateParametricDatatype(children);
+ TypeNode tret = paramReplacements[i].instantiate(children);
return tret;
}
}
<< "type is " << p.second << std::endl;
}
cvc5::Sort instantiation = isUninterpretedSortConstructor
- ? p.second.instantiate(params)
- : p.second.substitute(p.first, params);
+ ? p.second.instantiate(params)
+ : p.second.substitute(p.first, params);
Trace("sort") << "instance is " << instantiation << std::endl;
return instantiation;
for(size_t i = 1; i < getNumChildren(); ++i) {
v.push_back((*this)[i].getBaseType());
}
- return (*this)[0].getDType().getTypeNode().instantiateParametricDatatype(v);
+ return (*this)[0].getDType().getTypeNode().instantiate(v);
}
return *this;
}
|| (isUninterpretedSort() && getNumChildren() > 0);
}
-TypeNode TypeNode::instantiateParametricDatatype(
- const std::vector<TypeNode>& params) const
+TypeNode TypeNode::instantiate(const std::vector<TypeNode>& params) const
{
- AssertArgument(getKind() == kind::PARAMETRIC_DATATYPE, *this);
- AssertArgument(params.size() == getNumChildren() - 1, *this);
NodeManager* nm = NodeManager::currentNM();
- TypeNode cons = nm->mkTypeConst((*this)[0].getConst<DatatypeIndexConstant>());
- std::vector<TypeNode> paramsNodes;
- paramsNodes.push_back(cons);
- for (const TypeNode& t : params)
+ if (getKind() == kind::PARAMETRIC_DATATYPE)
{
- paramsNodes.push_back(t);
+ Assert(params.size() == getNumChildren() - 1);
+ TypeNode cons =
+ nm->mkTypeConst((*this)[0].getConst<DatatypeIndexConstant>());
+ std::vector<TypeNode> paramsNodes;
+ paramsNodes.push_back(cons);
+ for (const TypeNode& t : params)
+ {
+ paramsNodes.push_back(t);
+ }
+ return nm->mkTypeNode(kind::PARAMETRIC_DATATYPE, paramsNodes);
}
- return nm->mkTypeNode(kind::PARAMETRIC_DATATYPE, paramsNodes);
+ Assert(isUninterpretedSortConstructor());
+ return nm->mkSort(*this, params);
}
uint64_t TypeNode::getUninterpretedSortConstructorArity() const
return getAttribute(expr::VarNameAttr());
}
-TypeNode TypeNode::instantiateSortConstructor(
- const std::vector<TypeNode>& params) const
+bool TypeNode::isParameterInstantiatedDatatype(size_t n) const
{
- Assert(isUninterpretedSortConstructor());
- return NodeManager::currentNM()->mkSort(*this, params);
-}
-
-/** Is this an instantiated datatype parameter */
-bool TypeNode::isParameterInstantiatedDatatype(unsigned n) const {
- AssertArgument(getKind() == kind::PARAMETRIC_DATATYPE, *this);
+ Assert(getKind() == kind::PARAMETRIC_DATATYPE);
const DType& dt = (*this)[0].getDType();
- AssertArgument(n < dt.getNumParameters(), *this);
+ Assert(n < dt.getNumParameters());
return dt.getParameter(n) != (*this)[n + 1];
}
bool isSygusDatatype() const;
/**
- * Get instantiated datatype type. The type on which this method is called
- * should be a parametric datatype whose parameter list is the same size as
- * argument params. This constructs the instantiated version of this
- * parametric datatype, e.g. passing (par (A) (List A)), { Int } ) to this
- * method returns (List Int).
+ * Instantiate parametric type (parametric datatype or uninterpreted sort
+ * constructor type).
+ *
+ * The parameter list of this type must be the same size as the list of
+ * argument parameters `params`.
+ *
+ * If this TypeNode is a parametric datatype, this constructs the
+ * instantiated version of this parametric datatype. For example, passing
+ * (par (A) (List A)), { Int } ) to this method returns (List Int).
+ *
+ * If this is an uninterpreted sort constructor type, this constructs the
+ * instantiated version of this sort constructor. For example, for a sort
+ * constructor declared via (declare-sort U 2), passing { Int, Int } will
+ * generate the instantiated sort (U Int Int).
*/
- TypeNode instantiateParametricDatatype(
- const std::vector<TypeNode>& params) const;
+ TypeNode instantiate(const std::vector<TypeNode>& params) const;
/** Is this an instantiated datatype parameter */
- bool isParameterInstantiatedDatatype(unsigned n) const;
+ bool isParameterInstantiatedDatatype(size_t n) const;
/** Is this a constructor type */
bool isConstructor() const;
*/
std::string getName() const;
- /**
- * Instantiate a sort constructor type. The type on which this method is
- * called should be a sort constructor type whose parameter list is the
- * same size as argument params. This constructs the instantiated version of
- * this sort constructor. For example, this is a sort constructor, e.g.
- * declared via (declare-sort U 2), then calling this method with
- * { Int, Int } will generate the instantiated sort (U Int Int).
- */
- TypeNode instantiateSortConstructor(
- const std::vector<TypeNode>& params) const;
-
/** Get the most general base type of the type */
TypeNode getBaseType() const;
}
std::vector<TypeNode> instTypes;
m.getMatches(instTypes);
- TypeNode range = t.instantiateParametricDatatype(instTypes);
+ TypeNode range = t.instantiate(instTypes);
Trace("typecheck-idt") << "Return " << range << std::endl;
return range;
}