CVC5_API_TRY_CATCH_END;
}
-bool Sort::isParametricDatatype() const
-{
- CVC5_API_TRY_CATCH_BEGIN;
- //////// all checks before this line
- if (!d_type->isDatatype()) return false;
- return d_type->isParametricDatatype();
- ////////
- CVC5_API_TRY_CATCH_END;
-}
-
bool Sort::isConstructor() const
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK_NOT_NULL;
CVC5_API_CHECK_DOMAIN_SORTS(params);
- CVC5_API_CHECK(isParametricDatatype() || isSortConstructor())
+ CVC5_API_CHECK(d_type->isParametricDatatype() || d_type->isSortConstructor())
<< "Expected parametric datatype or sort constructor sort.";
- CVC5_API_CHECK(!isParametricDatatype()
+ CVC5_API_CHECK(!d_type->isParametricDatatype()
|| d_type->getNumChildren() == params.size() + 1)
<< "Arity mismatch for instantiated parametric datatype";
CVC5_API_CHECK(!isSortConstructor()
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK_NOT_NULL;
- CVC5_API_CHECK(isFloatingPoint()) << "Not a floating-point sort.";
+ CVC5_API_CHECK(d_type->isFloatingPoint()) << "Not a floating-point sort.";
//////// all checks before this line
return d_type->getFloatingPointExponentSize();
////////
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK_NOT_NULL;
- CVC5_API_CHECK(isFloatingPoint()) << "Not a floating-point sort.";
+ CVC5_API_CHECK(d_type->isFloatingPoint()) << "Not a floating-point sort.";
//////// all checks before this line
return d_type->getFloatingPointSignificandSize();
////////
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK_NOT_NULL;
- CVC5_API_CHECK(isParametricDatatype()) << "Not a parametric datatype sort.";
+ CVC5_API_CHECK(d_type->isParametricDatatype())
+ << "Not a parametric datatype sort.";
//////// all checks before this line
return typeNodeVectorToSorts(d_solver, d_type->getParamTypes());
////////
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK_NOT_NULL;
- CVC5_API_CHECK(isDatatype()) << "Not a datatype sort.";
+ CVC5_API_CHECK(d_type->isDatatype()) << "Not a datatype sort.";
//////// all checks before this line
return d_type->isParametricDatatype() ? d_type->getNumChildren() - 1 : 0;
////////
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK_NOT_NULL;
- CVC5_API_CHECK(isTuple()) << "Not a tuple sort.";
+ CVC5_API_CHECK(d_type->isTuple()) << "Not a tuple sort.";
//////// all checks before this line
return typeNodeVectorToSorts(d_solver, d_type->getTupleTypes());
////////
*/
bool isDatatype() const;
- /**
- * Is this a parametric datatype sort? A parametric datatype sort is either
- * one that is returned by a call to Solver::mkDatatypeSort() or
- * Solver::mkDatatypeSorts() for a parametric datatype, or an instantiated
- * datatype sort returned by Sort::instantiate() for parametric datatype
- * sort `s`.
- * @return true if the sort is a parametric datatype sort
- */
- bool isParametricDatatype() const;
-
/**
* Is this a constructor sort?
* @return true if the sort is a constructor sort
private native boolean isDatatype(long pointer);
- /**
- * Is this a parametric datatype sort?
- * @return true if the sort is a parametric datatype sort
- */
- public boolean isParametricDatatype()
- {
- return isParametricDatatype(pointer);
- }
-
- private native boolean isParametricDatatype(long pointer);
-
/**
* Is this a constructor sort?
* @return true if the sort is a constructor sort
CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false));
}
-/*
- * Class: io_github_cvc5_api_Sort
- * Method: isParametricDatatype
- * Signature: (J)Z
- */
-JNIEXPORT jboolean JNICALL Java_io_github_cvc5_api_Sort_isParametricDatatype(
- JNIEnv* env, jobject, jlong pointer)
-{
- CVC5_JAVA_API_TRY_CATCH_BEGIN;
- Sort* current = reinterpret_cast<Sort*>(pointer);
- return static_cast<jboolean>(current->isParametricDatatype());
- CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false));
-}
-
/*
* Class: io_github_cvc5_api_Sort
* Method: isConstructor
bint isBitVector() except +
bint isFloatingPoint() except +
bint isDatatype() except +
- bint isParametricDatatype() except +
bint isConstructor() except +
bint isSelector() except +
bint isTester() except +
"""
return self.csort.isDatatype()
- def isParametricDatatype(self):
- """
- Is this a parametric datatype sort?
-
- :return: True if the sort is a parametric datatype sort.
- """
- return self.csort.isParametricDatatype()
-
def isConstructor(self):
"""
Is this a constructor sort?
}
if (p.second.isDatatype())
{
- PrettyCheckArgument(
- p.second.isParametricDatatype(), name, "expected parametric datatype");
+ PrettyCheckArgument(p.second.getDatatype().isParametric(),
+ name,
+ "expected parametric datatype");
return p.second.instantiate(params);
}
bool isSortConstructor = p.second.isSortConstructor();
if (isDeclared(name, SYM_SORT)) {
throw ParserException(name + " already declared");
}
- if (t.isParametricDatatype())
+ if (dt.isParametric())
{
- std::vector<api::Sort> paramTypes = t.getDatatypeParamSorts();
+ std::vector<api::Sort> paramTypes = dt.getParameters();
defineType(name, paramTypes, t);
}
else
{
// Type ascriptions only have an effect on the node structure if this is a
// parametric datatype.
- if (s.isParametricDatatype())
+ // get the datatype that t belongs to
+ api::Sort etyped = etype.getConstructorCodomainSort();
+ api::Datatype d = etyped.getDatatype();
+ // Note that we check whether the datatype is parametric, and not whether
+ // etyped is a parametric datatype, since e.g. the smt2 parser constructs
+ // an arbitrary instantitated constructor term before it is resolved.
+ // Hence, etyped is an instantiated datatype type, but we correctly
+ // check if its datatype is parametric.
+ if (d.isParametric())
{
- // get the datatype that t belongs to
- api::Sort etyped = etype.getConstructorCodomainSort();
- api::Datatype d = etyped.getDatatype();
// lookup by name
api::DatatypeConstructor dc = d.getConstructor(t.toString());
// ask the constructor for the specialized constructor term
{
std::stringstream ss;
ss << "Type ascription on constructor not satisfied, term " << t
- << " expected sort " << s << " but has sort "
- << t.getSort().getConstructorCodomainSort();
+ << " expected sort " << s << " but has sort " << etyped;
parseError(ss.str());
}
return t;
ASSERT_NO_THROW(Sort().isDatatype());
}
-TEST_F(TestApiBlackSort, isParametricDatatype)
-{
- Sort param_dt_sort = create_param_datatype_sort();
- ASSERT_TRUE(param_dt_sort.isParametricDatatype());
- ASSERT_NO_THROW(Sort().isParametricDatatype());
-}
-
TEST_F(TestApiBlackSort, isConstructor)
{
Sort dt_sort = create_datatype_sort();
assertDoesNotThrow(() -> d_solver.getNullSort().isDatatype());
}
- @Test void isParametricDatatype() throws CVC5ApiException
- {
- Sort param_dt_sort = create_param_datatype_sort();
- assertTrue(param_dt_sort.isParametricDatatype());
- assertDoesNotThrow(() -> d_solver.getNullSort().isParametricDatatype());
- }
-
@Test void isConstructor() throws CVC5ApiException
{
Sort dt_sort = create_datatype_sort();
Sort(solver).isDatatype()
-def test_is_parametric_datatype(solver):
- param_dt_sort = create_param_datatype_sort(solver)
- assert param_dt_sort.isParametricDatatype()
- Sort(solver).isParametricDatatype()
-
-
def test_is_constructor(solver):
dt_sort = create_datatype_sort(solver)
dt = dt_sort.getDatatype()