This further removes Sort::isUinterpretedSortParameterized().
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK_NOT_NULL;
- CVC5_API_CHECK(isDatatype()) << "Expected datatype sort.";
+ CVC5_API_CHECK(d_type->isDatatype()) << "Expected datatype sort.";
//////// all checks before this line
return Datatype(d_solver, d_type->getDType());
////////
CVC5_API_TRY_CATCH_END;
}
+bool Sort::isInstantiated() const
+{
+ CVC5_API_TRY_CATCH_BEGIN;
+ CVC5_API_CHECK_NOT_NULL;
+ //////// all checks before this line
+ return d_type->isInstantiated();
+ ////////
+ CVC5_API_TRY_CATCH_END;
+}
+
Sort Sort::instantiate(const std::vector<Sort>& params) const
{
CVC5_API_TRY_CATCH_BEGIN;
/* Uninterpreted sort -------------------------------------------------- */
-bool Sort::isUninterpretedSortParameterized() const
-{
- CVC5_API_TRY_CATCH_BEGIN;
- CVC5_API_CHECK_NOT_NULL;
- CVC5_API_CHECK(isUninterpretedSort()) << "Not an uninterpreted sort.";
- //////// all checks before this line
-
- /* This method is not implemented in the NodeManager, since whether a
- * uninterpreted sort is parameterized is irrelevant for solving. */
- return d_type->getNumChildren() > 0;
- ////////
- CVC5_API_TRY_CATCH_END;
-}
-
std::vector<Sort> Sort::getUninterpretedSortParamSorts() const
{
CVC5_API_TRY_CATCH_BEGIN;
*/
bool isUninterpretedSortConstructor() const;
+ /**
+ * Is this an instantiated (parametric datatype or uninterpreted sort
+ * constructor) sort?
+ *
+ * An instantiated sort is a sort that has been constructed from
+ * instantiating a sort with sort arguments
+ * (see Sort::instantiate(const std::vector<Sort>&) const)).
+ *
+ * @return true if this is an instantiated sort
+ */
+ bool isInstantiated() const;
+
/**
* @return the underlying datatype of a datatype sort
*/
private native boolean isUninterpretedSortConstructor(long pointer);
+ /**
+ * Is this an instantiated (parametric datatype or uninterpreted sort
+ * constructor) sort?
+ *
+ * An instantiated sort is a sort that has been constructed from
+ * instantiating a sort with sort arguments
+ * (see Sort.instantiate()).
+ *
+ * @return true if this is an instantiated sort
+ */
+ public boolean isInstantiated()
+ {
+ return isInstantiated(pointer);
+ }
+
+ private native boolean isInstantiated(long pointer);
+
/**
* @return the underlying datatype of a datatype sort
*/
/* Uninterpreted sort -------------------------------------------------- */
- /**
- * @return true if an uninterpreted sort is parameterezied
- */
- public boolean isUninterpretedSortParameterized()
- {
- return isUninterpretedSortParameterized(pointer);
- }
-
- private native boolean isUninterpretedSortParameterized(long pointer);
-
/**
* @return the parameter sorts of an uninterpreted sort
*/
CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false));
}
+/*
+ * Class: io_github_cvc5_api_Sort
+ * Method: isInstantiated
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_io_github_cvc5_api_Sort_isInstantiated(JNIEnv* env, jobject, jlong pointer)
+{
+ CVC5_JAVA_API_TRY_CATCH_BEGIN;
+ Sort* current = reinterpret_cast<Sort*>(pointer);
+ return static_cast<jboolean>(current->isInstantiated());
+ CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false));
+}
+
/*
* Class: io_github_cvc5_api_Sort
* Method: getDatatype
CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, 0);
}
-/*
- * Class: io_github_cvc5_api_Sort
- * Method: isUninterpretedSortParameterized
- * Signature: (J)Z
- */
-JNIEXPORT jboolean JNICALL
-Java_io_github_cvc5_api_Sort_isUninterpretedSortParameterized(JNIEnv* env,
- jobject,
- jlong pointer)
-{
- CVC5_JAVA_API_TRY_CATCH_BEGIN;
- Sort* current = reinterpret_cast<Sort*>(pointer);
- return static_cast<jboolean>(current->isUninterpretedSortParameterized());
- CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false));
-}
-
/*
* Class: io_github_cvc5_api_Sort
* Method: getUninterpretedSortParamSorts
bint isSequence() except +
bint isUninterpretedSort() except +
bint isUninterpretedSortConstructor() except +
+ bint isInstantiated() except +
Datatype getDatatype() except +
Sort instantiate(const vector[Sort]& params) except +
Sort substitute(const vector[Sort] & es, const vector[Sort] & reps) except +
Sort getSetElementSort() except +
Sort getBagElementSort() except +
Sort getSequenceElementSort() except +
- bint isUninterpretedSortParameterized() except +
vector[Sort] getUninterpretedSortParamSorts() except +
size_t getUninterpretedSortConstructorArity() except +
uint32_t getBitVectorSize() except +
"""
return self.csort.isUninterpretedSortConstructor()
+ def isInstantiated(self):
+ """
+ Is this an instantiated (parametric datatype or uninterpreted sort
+ constructor) sort?
+
+ An instantiated sort is a sort that has been constructed from
+ instantiating a sort parameters with sort arguments
+ (see Sort::instantiate()).
+
+ :return: True if this is an instantiated sort.
+ """
+ return self.csort.isInstantiated()
+
def getDatatype(self):
"""
:return: the underlying datatype of a datatype sort
sort.csort = self.csort.getSequenceElementSort()
return sort
- def isUninterpretedSortParameterized(self):
- """
- :return: True if an uninterpreted sort is parameterized
- """
- return self.csort.isUninterpretedSortParameterized()
-
def getUninterpretedSortParamSorts(self):
"""
:return: the parameter sorts of an uninterpreted sort
return true;
}
+bool TypeNode::isInstantiated() const
+{
+ return isInstantiatedDatatype()
+ || (isSort() && getNumChildren() > 0);
+}
+
TypeNode TypeNode::instantiateParametricDatatype(
const std::vector<TypeNode>& params) const
{
/** Is this a fully instantiated datatype type */
bool isInstantiatedDatatype() const;
+ /**
+ * Return true if this is an instantiated parametric datatype or
+ * uninterpreted sort constructor type.
+ */
+ bool isInstantiated() const;
+
/** Is this a sygus datatype type */
bool isSygusDatatype() const;
ASSERT_THROW(
dtypeSort.instantiate(std::vector<Sort>{d_solver.getIntegerSort()}),
CVC5ApiException);
+ // instantiate uninterpreted sort constructor
+ Sort sortConsSort = d_solver.mkUninterpretedSortConstructorSort("s", 1);
+ ASSERT_NO_THROW(
+ sortConsSort.instantiate(std::vector<Sort>{d_solver.getIntegerSort()}));
+}
+
+TEST_F(TestApiBlackSort, isInstantiated)
+{
+ Sort paramDtypeSort = create_param_datatype_sort();
+ ASSERT_FALSE(paramDtypeSort.isInstantiated());
+ Sort instParamDtypeSort =
+ paramDtypeSort.instantiate(std::vector<Sort>{d_solver.getIntegerSort()});
+ ASSERT_TRUE(instParamDtypeSort.isInstantiated());
+
+ Sort sortConsSort = d_solver.mkUninterpretedSortConstructorSort("s", 1);
+ ASSERT_FALSE(sortConsSort.isInstantiated());
+ Sort instSortConsSort =
+ sortConsSort.instantiate(std::vector<Sort>{d_solver.getIntegerSort()});
+ ASSERT_TRUE(instSortConsSort.isInstantiated());
+
+ ASSERT_FALSE(d_solver.getIntegerSort().isInstantiated());
+ ASSERT_FALSE(d_solver.mkBitVectorSort(32).isInstantiated());
}
TEST_F(TestApiBlackSort, getFunctionArity)
ASSERT_THROW(bvSort.getSymbol(), CVC5ApiException);
}
-TEST_F(TestApiBlackSort, isUninterpretedSortParameterized)
-{
- Sort uSort = d_solver.mkUninterpretedSort("u");
- ASSERT_FALSE(uSort.isUninterpretedSortParameterized());
- Sort sSort = d_solver.mkUninterpretedSortConstructorSort("s", 1);
- Sort siSort = sSort.instantiate({uSort});
- ASSERT_TRUE(siSort.isUninterpretedSortParameterized());
- Sort bvSort = d_solver.mkBitVectorSort(32);
- ASSERT_THROW(bvSort.isUninterpretedSortParameterized(), CVC5ApiException);
-}
-
TEST_F(TestApiBlackSort, getUninterpretedSortParamSorts)
{
Sort uSort = d_solver.mkUninterpretedSort("u");
Sort dtypeSort = d_solver.mkDatatypeSort(dtypeSpec);
assertThrows(CVC5ApiException.class,
() -> dtypeSort.instantiate(new Sort[] {d_solver.getIntegerSort()}));
+ // instantiate uninterpreted sort constructor
+ Sort sortConsSort = d_solver.mkUninterpretedSortConstructorSort("s", 1);
+ assertDoesNotThrow(() -> sortConsSort.instantiate(new Sort[] {d_solver.getIntegerSort()}));
+ }
+
+ @Test void isInstantiated() throws CVC5ApiException
+ {
+ Sort paramDtypeSort = create_param_datatype_sort();
+ assertFalse(paramDtypeSort.isInstantiated());
+ Sort instParamDtypeSort = paramDtypeSort.instantiate(new Sort[] {d_solver.getIntegerSort()});
+ assertTrue(instParamDtypeSort.isInstantiated());
+
+ Sort sortConsSort = d_solver.mkUninterpretedSortConstructorSort("s", 1);
+ assertFalse(sortConsSort.isInstantiated());
+ Sort instSortConsSort = sortConsSort.instantiate(new Sort[] {d_solver.getIntegerSort()});
+ assertTrue(instSortConsSort.isInstantiated());
+
+ assertFalse(d_solver.getIntegerSort().isInstantiated());
+ assertFalse(d_solver.mkBitVectorSort(32).isInstantiated());
}
@Test void getFunctionArity() throws CVC5ApiException
assertThrows(CVC5ApiException.class, () -> bvSort.getSymbol());
}
- @Test void isUninterpretedSortParameterized() throws CVC5ApiException
- {
- Sort uSort = d_solver.mkUninterpretedSort("u");
- assertFalse(uSort.isUninterpretedSortParameterized());
- Sort sSort = d_solver.mkUninterpretedSortConstructorSort("s", 1);
- Sort siSort = sSort.instantiate(new Sort[] {uSort});
- assertTrue(siSort.isUninterpretedSortParameterized());
- Sort bvSort = d_solver.mkBitVectorSort(32);
- assertThrows(CVC5ApiException.class, () -> bvSort.isUninterpretedSortParameterized());
- }
-
@Test void getUninterpretedSortParamSorts() throws CVC5ApiException
{
Sort uSort = d_solver.mkUninterpretedSort("u");
dtypeSort = solver.mkDatatypeSort(dtypeSpec)
with pytest.raises(RuntimeError):
dtypeSort.instantiate([solver.getIntegerSort()])
+ # instantiate uninterpreted sort constructor
+ sortConsSort = solver.mkUninterpretedSortConstructorSort("s", 1)
+ sortConsSort.instantiate([solver.getIntegerSort()])
+def test_is_instantiated(solver):
+ paramDtypeSort = create_param_datatype_sort(solver)
+ assert not paramDtypeSort.isInstantiated()
+ instParamDtypeSort = paramDtypeSort.instantiate([solver.getIntegerSort()]);
+ assert instParamDtypeSort.isInstantiated()
+
+ sortConsSort = solver.mkUninterpretedSortConstructorSort("s", 1)
+ assert not sortConsSort.isInstantiated()
+ instSortConsSort = sortConsSort.instantiate([solver.getIntegerSort()])
+ assert instSortConsSort.isInstantiated()
+
+ assert not solver.getIntegerSort().isInstantiated()
+ assert not solver.mkBitVectorSort(32).isInstantiated()
def test_get_function_arity(solver):
funSort = solver.mkFunctionSort(solver.mkUninterpretedSort("u"),
bvSort.getSymbol()
-def test_is_uninterpreted_sort_parameterized(solver):
- uSort = solver.mkUninterpretedSort("u")
- assert not uSort.isUninterpretedSortParameterized()
- sSort = solver.mkUninterpretedSortConstructorSort("s", 1)
- siSort = sSort.instantiate([uSort])
- assert siSort.isUninterpretedSortParameterized()
- bvSort = solver.mkBitVectorSort(32)
- with pytest.raises(RuntimeError):
- bvSort.isUninterpretedSortParameterized()
-
-
def test_get_uninterpreted_sort_paramsorts(solver):
uSort = solver.mkUninterpretedSort("u")
uSort.getUninterpretedSortParamSorts()