This is required for migrating the parser's symbol table from Expr -> Term.
return Sort(d_solver, ConstructorType(*d_type).getRangeType());
}
+/* Selector sort ------------------------------------------------------- */
+
+Sort Sort::getSelectorDomainSort() const
+{
+ CVC4_API_CHECK(isSelector()) << "Not a selector sort: " << (*this);
+ TypeNode typeNode = TypeNode::fromType(*d_type);
+ return Sort(d_solver, typeNode.getSelectorDomainType().toType());
+}
+
+Sort Sort::getSelectorCodomainSort() const
+{
+ CVC4_API_CHECK(isSelector()) << "Not a selector sort: " << (*this);
+ TypeNode typeNode = TypeNode::fromType(*d_type);
+ return Sort(d_solver, typeNode.getSelectorRangeType().toType());
+}
+
+/* Tester sort ------------------------------------------------------- */
+
+Sort Sort::getTesterDomainSort() const
+{
+ CVC4_API_CHECK(isTester()) << "Not a tester sort: " << (*this);
+ TypeNode typeNode = TypeNode::fromType(*d_type);
+ return Sort(d_solver, typeNode.getTesterDomainType().toType());
+}
+
+Sort Sort::getTesterCodomainSort() const
+{
+ CVC4_API_CHECK(isTester()) << "Not a tester sort: " << (*this);
+ return d_solver->getBooleanSort();
+}
+
/* Function sort ------------------------------------------------------- */
size_t Sort::getFunctionArity() const
*/
Sort getConstructorCodomainSort() const;
+ /* Selector sort ------------------------------------------------------- */
+
+ /**
+ * @return the domain sort of a selector sort
+ */
+ Sort getSelectorDomainSort() const;
+
+ /**
+ * @return the codomain sort of a selector sort
+ */
+ Sort getSelectorCodomainSort() const;
+
+ /* Tester sort ------------------------------------------------------- */
+
+ /**
+ * @return the domain sort of a tester sort
+ */
+ Sort getTesterDomainSort() const;
+
+ /**
+ * @return the codomain sort of a tester sort, which is the Boolean sort
+ */
+ Sort getTesterCodomainSort() const;
+
/* Function sort ------------------------------------------------------- */
/**
return false;
}
+TypeNode TypeNode::getTesterDomainType() const
+{
+ Assert(isTester());
+ return (*this)[0];
+}
+
TypeNode TypeNode::getSequenceElementType() const
{
Assert(isSequence());
/** Get the return type (for selector types) */
TypeNode getSelectorRangeType() const;
+ /** Get the domain type (for tester types) */
+ TypeNode getTesterDomainType() const;
+
/** Get the element type (for set types) */
TypeNode getSetElementType() const;
// get tester
Term isConsTerm = dcons.getTesterTerm();
TS_ASSERT(isConsTerm.getSort().isTester());
+ TS_ASSERT(isConsTerm.getSort().getTesterDomainSort() == dtypeSort);
+ Sort booleanSort = d_solver.getBooleanSort();
+ TS_ASSERT(isConsTerm.getSort().getTesterCodomainSort() == booleanSort);
+ TS_ASSERT_THROWS(booleanSort.getTesterDomainSort(), CVC4ApiException&);
+ TS_ASSERT_THROWS(booleanSort.getTesterCodomainSort(), CVC4ApiException&);
// get selector
DatatypeSelector dselTail = dcons[1];
Term tailTerm = dselTail.getSelectorTerm();
TS_ASSERT(tailTerm.getSort().isSelector());
+ TS_ASSERT(tailTerm.getSort().getSelectorDomainSort() == dtypeSort);
+ TS_ASSERT(tailTerm.getSort().getSelectorCodomainSort() == dtypeSort);
+ TS_ASSERT_THROWS(booleanSort.getSelectorDomainSort(), CVC4ApiException&);
+ TS_ASSERT_THROWS(booleanSort.getSelectorCodomainSort(), CVC4ApiException&);
}
void SortBlack::testInstantiate()