}
}
+std::set<TypeNode> Sort::sortSetToTypeNodes(const std::set<Sort>& sorts)
+{
+ std::set<TypeNode> types;
+ for (const Sort& s : sorts)
+ {
+ types.insert(s.getTypeNode());
+ }
+ return types;
+}
+
+std::vector<TypeNode> Sort::sortVectorToTypeNodes(
+ const std::vector<Sort>& sorts)
+{
+ std::vector<TypeNode> typeNodes;
+ for (const Sort& sort : sorts)
+ {
+ typeNodes.push_back(sort.getTypeNode());
+ }
+ return typeNodes;
+}
+
+std::vector<Sort> Sort::typeNodeVectorToSorts(
+ const Solver* slv, const std::vector<TypeNode>& types)
+{
+ std::vector<Sort> sorts;
+ for (size_t i = 0, tsize = types.size(); i < tsize; i++)
+ {
+ sorts.push_back(Sort(slv, types[i]));
+ }
+ return sorts;
+}
+
/* Helpers */
/* -------------------------------------------------------------------------- */
return d_type->toString();
}
-// !!! This is only temporarily available until the parser is fully migrated
-// to the new API. !!!
-CVC4::Type Sort::getType(void) const
-{
- if (d_type->isNull()) return Type();
- NodeManagerScope scope(d_solver->getNodeManager());
- return d_type->toType();
-}
const CVC4::TypeNode& Sort::getTypeNode(void) const { return *d_type; }
/* Constructor sort ------------------------------------------------------- */
bool isCoDatatype)
: d_solver(slv)
{
- std::vector<TypeNode> tparams = sortVectorToTypeNodes(params);
+ std::vector<TypeNode> tparams = Sort::sortVectorToTypeNodes(params);
d_dtype = std::shared_ptr<CVC4::DType>(
new CVC4::DType(name, tparams, isCoDatatype));
}
d_solver->getExprManager()->mkExpr(
CVC4::kind::LAMBDA, {lbvl.d_node->toExpr(), op.d_node->toExpr()}));
}
- std::vector<TypeNode> cargst = sortVectorToTypeNodes(cargs);
+ std::vector<TypeNode> cargst = Sort::sortVectorToTypeNodes(cargs);
dt.d_dtype->addSygusConstructor(*op.d_node, ssCName.str(), cargst);
}
CVC4_API_SOLVER_CHECK_SORT(sort);
}
- std::set<TypeNode> utypes = sortSetToTypeNodes(unresolvedSorts);
+ std::set<TypeNode> utypes = Sort::sortSetToTypeNodes(unresolvedSorts);
std::vector<CVC4::TypeNode> dtypes =
getNodeManager()->mkMutualDatatypeTypes(datatypes, utypes);
- std::vector<Sort> retTypes = typeNodeVectorToSorts(this, dtypes);
+ std::vector<Sort> retTypes = Sort::typeNodeVectorToSorts(this, dtypes);
return retTypes;
CVC4_API_SOLVER_TRY_CATCH_END;
/* Helpers for converting vectors. */
/* .......................................................................... */
-std::vector<Type> Solver::sortVectorToTypes(
- const std::vector<Sort>& sorts) const
-{
- std::vector<Type> res;
- for (const Sort& s : sorts)
- {
- CVC4_API_SOLVER_CHECK_SORT(s);
- res.push_back(s.d_type->toType());
- }
- return res;
-}
-
std::vector<Expr> Solver::termVectorToExprs(
const std::vector<Term>& terms) const
{
<< "first-class sort as codomain sort for function sort";
Assert(!codomain.isFunction()); /* A function sort is not first-class. */
- std::vector<TypeNode> argTypes = sortVectorToTypeNodes(sorts);
+ std::vector<TypeNode> argTypes = Sort::sortVectorToTypeNodes(sorts);
return Sort(this,
getNodeManager()->mkFunctionType(argTypes, *codomain.d_type));
sorts[i].isFirstClass(), "parameter sort", sorts[i], i)
<< "first-class sort as parameter sort for predicate sort";
}
- std::vector<TypeNode> types = sortVectorToTypeNodes(sorts);
+ std::vector<TypeNode> types = Sort::sortVectorToTypeNodes(sorts);
return Sort(this, getNodeManager()->mkPredicateType(types));
!sorts[i].isFunctionLike(), "parameter sort", sorts[i], i)
<< "non-function-like sort as parameter sort for tuple sort";
}
- std::vector<TypeNode> typeNodes = sortVectorToTypeNodes(sorts);
+ std::vector<TypeNode> typeNodes = Sort::sortVectorToTypeNodes(sorts);
return Sort(this, getNodeManager()->mkTupleType(typeNodes));
CVC4_API_SOLVER_TRY_CATCH_END;
TypeNode type = *sort.d_type;
if (!sorts.empty())
{
- std::vector<TypeNode> types = sortVectorToTypeNodes(sorts);
+ std::vector<TypeNode> types = Sort::sortVectorToTypeNodes(sorts);
type = getNodeManager()->mkFunctionType(types, type);
}
return Term(this, d_exprMgr->mkVar(symbol, type.toType()));
return res;
}
-std::vector<Type> sortVectorToTypes(const std::vector<Sort>& sorts)
-{
- std::vector<Type> types;
- for (size_t i = 0, ssize = sorts.size(); i < ssize; i++)
- {
- types.push_back(sorts[i].getTypeNode().toType());
- }
- return types;
-}
-
-std::vector<TypeNode> sortVectorToTypeNodes(const std::vector<Sort>& sorts)
-{
- std::vector<TypeNode> typeNodes;
- for (const Sort& sort : sorts)
- {
- typeNodes.push_back(sort.getTypeNode());
- }
- return typeNodes;
-}
-
-std::set<TypeNode> sortSetToTypeNodes(const std::set<Sort>& sorts)
-{
- std::set<TypeNode> types;
- for (const Sort& s : sorts)
- {
- types.insert(s.getTypeNode());
- }
- return types;
-}
-
std::vector<Term> exprVectorToTerms(const Solver* slv,
const std::vector<Expr>& exprs)
{
return terms;
}
-std::vector<Sort> typeVectorToSorts(const Solver* slv,
- const std::vector<Type>& types)
-{
- std::vector<Sort> sorts;
- for (size_t i = 0, tsize = types.size(); i < tsize; i++)
- {
- sorts.push_back(Sort(slv, TypeNode::fromType(types[i])));
- }
- return sorts;
-}
-std::vector<Sort> typeNodeVectorToSorts(const Solver* slv,
- const std::vector<TypeNode>& types)
-{
- std::vector<Sort> sorts;
- for (size_t i = 0, tsize = types.size(); i < tsize; i++)
- {
- sorts.push_back(Sort(slv, types[i]));
- }
- return sorts;
-}
-
} // namespace api
/* -------------------------------------------------------------------------- */
class NodeTemplate;
typedef NodeTemplate<true> Node;
class Expr;
+class DatatypeDeclarationCommand;
+class DeclareFunctionCommand;
+class DeclareHeapCommand;
+class DeclareSortCommand;
+class DeclareSygusVarCommand;
+class DefineSortCommand;
class DType;
class DTypeConstructor;
class DTypeSelector;
class ExprManager;
class GetAbductCommand;
+class GetModelCommand;
class GetInterpolCommand;
class NodeManager;
class SmtEngine;
*/
class CVC4_PUBLIC Sort
{
+ friend class CVC4::DatatypeDeclarationCommand;
+ friend class CVC4::DeclareFunctionCommand;
+ friend class CVC4::DeclareHeapCommand;
+ friend class CVC4::DeclareSortCommand;
+ friend class CVC4::DeclareSygusVarCommand;
+ friend class CVC4::DefineSortCommand;
+ friend class CVC4::GetAbductCommand;
+ friend class CVC4::GetInterpolCommand;
+ friend class CVC4::GetModelCommand;
+ friend class CVC4::SynthFunCommand;
friend class DatatypeConstructor;
friend class DatatypeConstructorDecl;
+ friend class DatatypeSelector;
friend class DatatypeDecl;
friend class Op;
friend class Solver;
friend class Term;
public:
- // !!! This constructor is only temporarily public until the parser is fully
- // migrated to the new API. !!!
- /**
- * Constructor.
- * @param slv the associated solver object
- * @param t the internal type that is to be wrapped by this sort
- * @return the Sort
- */
- Sort(const Solver* slv, const CVC4::Type& t);
- Sort(const Solver* slv, const CVC4::TypeNode& t);
-
/**
* Constructor.
*/
*/
std::string toString() const;
- // !!! This is only temporarily available until the parser is fully migrated
- // to the new API. !!!
- CVC4::Type getType(void) const;
- const CVC4::TypeNode& getTypeNode(void) const;
-
/* Constructor sort ------------------------------------------------------- */
/**
std::vector<Sort> getTupleSorts() const;
private:
+ /** @return the internal wrapped TypeNode of this sort. */
+ const CVC4::TypeNode& getTypeNode(void) const;
+
+ /** Helper to convert a set of Sorts to internal TypeNodes. */
+ std::set<TypeNode> static sortSetToTypeNodes(const std::set<Sort>& sorts);
+ /* Helper to convert a vector of Sorts to internal TypeNodes. */
+ std::vector<TypeNode> static sortVectorToTypeNodes(
+ const std::vector<Sort>& sorts);
+ /** Helper to convert a vector of internal TypeNodes to Sorts. */
+ std::vector<Sort> static typeNodeVectorToSorts(
+ const Solver* slv, const std::vector<TypeNode>& types);
+
+ /**
+ * Constructor.
+ * @param slv the associated solver object
+ * @param t the internal type that is to be wrapped by this sort
+ * @return the Sort
+ */
+ Sort(const Solver* slv, const CVC4::Type& t);
+ Sort(const Solver* slv, const CVC4::TypeNode& t);
+
/**
* Helper for isNull checks. This prevents calling an API function with
* CVC4_API_CHECK_NOT_NULL
Options& getOptions(void);
private:
- /* Helper to convert a vector of internal types to sorts. */
- std::vector<Type> sortVectorToTypes(const std::vector<Sort>& vector) const;
- /* Helper to convert a vector of sorts to internal types. */
+ /* Helper to convert a vector of Terms to internal Exprs. */
std::vector<Expr> termVectorToExprs(const std::vector<Term>& vector) const;
/* Helper to check for API misuse in mkOp functions. */
void checkMkTerm(Kind kind, uint32_t nchildren) const;
// new API. !!!
std::vector<Expr> termVectorToExprs(const std::vector<Term>& terms);
std::vector<Node> termVectorToNodes(const std::vector<Term>& terms);
-std::vector<Type> sortVectorToTypes(const std::vector<Sort>& sorts);
-std::vector<TypeNode> sortVectorToTypeNodes(const std::vector<Sort>& sorts);
-std::set<TypeNode> sortSetToTypeNodes(const std::set<Sort>& sorts);
std::vector<Term> exprVectorToTerms(const Solver* slv,
const std::vector<Expr>& terms);
-std::vector<Sort> typeVectorToSorts(const Solver* slv,
- const std::vector<Type>& sorts);
-std::vector<Sort> typeNodeVectorToSorts(const Solver* slv,
- const std::vector<TypeNode>& types);
} // namespace api