CVC5_API_TRY_CATCH_END;
}
-bool Sort::isComparableTo(const Sort& s) const
-{
- CVC5_API_TRY_CATCH_BEGIN;
- CVC5_API_ARG_CHECK_SOLVER("sort", s);
- //////// all checks before this line
- return d_type->isComparableTo(*s.d_type);
- ////////
- CVC5_API_TRY_CATCH_END;
-}
-
Datatype Sort::getDatatype() const
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK_NOT_NULL;
CVC5_API_CHECK_TERM(term);
CVC5_API_CHECK_TERM(replacement);
- CVC5_API_CHECK(term.getSort().isComparableTo(replacement.getSort()))
- << "Expecting terms of comparable sort in substitute";
+ CVC5_API_CHECK(term.getSort() == replacement.getSort())
+ << "Expecting terms of the same sort in substitute";
//////// all checks before this line
return Term(
d_solver,
CVC5_API_CHECK_NOT_NULL;
CVC5_API_CHECK(terms.size() == replacements.size())
<< "Expecting vectors of the same arity in substitute";
- CVC5_API_TERM_CHECK_TERMS_WITH_TERMS_COMPARABLE_TO(terms, replacements);
+ CVC5_API_TERM_CHECK_TERMS_WITH_TERMS_SORT_EQUAL_TO(terms, replacements);
//////// all checks before this line
std::vector<Node> nodes = Term::termVectorToNodes(terms);
std::vector<Node> nodeReplacements = Term::termVectorToNodes(replacements);
*/
bool isSubsortOf(const Sort& s) const;
- /**
- * Is this sort comparable to the given sort (i.e., do they share
- * a common ancestor in the subsort tree)?
- * @return true if this sort is comparable to s
- */
- bool isComparableTo(const Sort& s) const;
-
/**
* @return the underlying datatype of a datatype sort
*/
* Term check for member functions of classes other than class Solver.
* Check if each term in both the given container is not null, associated with
* the solver object this object is associated with, and their sorts are
- * pairwise comparable to.
+ * pairwise equal.
*/
-#define CVC5_API_TERM_CHECK_TERMS_WITH_TERMS_COMPARABLE_TO(terms1, terms2) \
+#define CVC5_API_TERM_CHECK_TERMS_WITH_TERMS_SORT_EQUAL_TO(terms1, terms2) \
do \
{ \
size_t i = 0; \
this->d_solver == t2.d_solver, "term", terms2, i) \
<< "a term associated with the solver this object is associated " \
"with"; \
- CVC5_API_CHECK(t1.getSort().isComparableTo(t2.getSort())) \
- << "Expecting terms of comparable sort at index " << i; \
+ CVC5_API_CHECK(t1.getSort() == t2.getSort()) \
+ << "Expecting terms of the same sort at index " << i; \
i += 1; \
} \
} while (0)
private native boolean isSubsortOf(long pointer, long sortPointer);
- /**
- * Is this sort comparable to the given sort (i.e., do they share
- * a common ancestor in the subsort tree)?
- * @return true if this sort is comparable to s
- */
- public boolean isComparableTo(Sort s)
- {
- return isComparableTo(pointer, s.getPointer());
- }
-
- private native boolean isComparableTo(long pointer, long sortPointer);
-
/**
* @return the underlying datatype of a datatype sort
*/
CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false));
}
-/*
- * Class: io_github_cvc5_api_Sort
- * Method: isComparableTo
- * Signature: (JJ)Z
- */
-JNIEXPORT jboolean JNICALL Java_io_github_cvc5_api_Sort_isComparableTo(
- JNIEnv* env, jobject, jlong pointer, jlong sortPointer)
-{
- CVC5_JAVA_API_TRY_CATCH_BEGIN;
- Sort* current = reinterpret_cast<Sort*>(pointer);
- Sort* sort = reinterpret_cast<Sort*>(sortPointer);
- return static_cast<jboolean>(current->isComparableTo(*sort));
- CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false));
-}
-
/*
* Class: io_github_cvc5_api_Sort
* Method: getDatatype
bint isFirstClass() except +
bint isFunctionLike() except +
bint isSubsortOf(Sort s) except +
- bint isComparableTo(Sort s) except +
Datatype getDatatype() except +
Sort instantiate(const vector[Sort]& params) except +
Sort substitute(const vector[Sort] & es, const vector[Sort] & reps) except +
"""
return self.csort.isSubsortOf(sort.csort)
- def isComparableTo(self, Sort sort):
- """
- Is this sort comparable to the given sort
- (i.e., do they share a common ancestor in the subsort tree)?
-
- :return: True if this sort is comparable to s
- """
- return self.csort.isComparableTo(sort.csort)
-
def getDatatype(self):
"""
:return: the underlying datatype of a datatype sort
}
api::Term constVal = args[0];
- if (!p.d_type.getArrayElementSort().isComparableTo(constVal.getSort()))
+ if (p.d_type.getArrayElementSort() != constVal.getSort())
{
std::stringstream ss;
ss << "type mismatch inside array constant term:" << std::endl
)
(define-fun nilPState () PState
- (mkPState nilSL ((as const (Array State Real)) 0))
+ (mkPState nilSL ((as const (Array State Real)) 0.0))
)
(define-fun-rec appendStateToPState ((s State) (r Real) (p PState)) PState
(let ((pstates (states p)))
ASSERT_NE(pairIntInt, pairRealInt);
ASSERT_NE(pairIntReal, pairRealInt);
- ASSERT_TRUE(pairRealReal.isComparableTo(pairRealReal));
- ASSERT_FALSE(pairIntReal.isComparableTo(pairRealReal));
- ASSERT_FALSE(pairRealInt.isComparableTo(pairRealReal));
- ASSERT_FALSE(pairIntInt.isComparableTo(pairRealReal));
- ASSERT_FALSE(pairRealReal.isComparableTo(pairRealInt));
- ASSERT_FALSE(pairIntReal.isComparableTo(pairRealInt));
- ASSERT_TRUE(pairRealInt.isComparableTo(pairRealInt));
- ASSERT_FALSE(pairIntInt.isComparableTo(pairRealInt));
- ASSERT_FALSE(pairRealReal.isComparableTo(pairIntReal));
- ASSERT_TRUE(pairIntReal.isComparableTo(pairIntReal));
- ASSERT_FALSE(pairRealInt.isComparableTo(pairIntReal));
- ASSERT_FALSE(pairIntInt.isComparableTo(pairIntReal));
- ASSERT_FALSE(pairRealReal.isComparableTo(pairIntInt));
- ASSERT_FALSE(pairIntReal.isComparableTo(pairIntInt));
- ASSERT_FALSE(pairRealInt.isComparableTo(pairIntInt));
- ASSERT_TRUE(pairIntInt.isComparableTo(pairIntInt));
-
ASSERT_TRUE(pairRealReal.isSubsortOf(pairRealReal));
ASSERT_FALSE(pairIntReal.isSubsortOf(pairRealReal));
ASSERT_FALSE(pairRealInt.isSubsortOf(pairRealReal));
ASSERT_NO_THROW(Sort().isSubsortOf(Sort()));
}
-TEST_F(TestApiBlackSort, isComparableTo)
-{
- ASSERT_TRUE(
- d_solver.getIntegerSort().isComparableTo(d_solver.getIntegerSort()));
- ASSERT_TRUE(d_solver.getIntegerSort().isComparableTo(d_solver.getRealSort()));
- ASSERT_FALSE(
- d_solver.getIntegerSort().isComparableTo(d_solver.getBooleanSort()));
- ASSERT_NO_THROW(Sort().isComparableTo(Sort()));
-}
-
TEST_F(TestApiBlackSort, getDatatype)
{
Sort dtypeSort = create_datatype_sort();
Sort realSort = d_solver.getRealSort();
ASSERT_TRUE(intSort.isSubsortOf(realSort));
ASSERT_FALSE(realSort.isSubsortOf(intSort));
- ASSERT_TRUE(intSort.isComparableTo(realSort));
- ASSERT_TRUE(realSort.isComparableTo(intSort));
Sort arraySortII = d_solver.mkArraySort(intSort, intSort);
Sort arraySortIR = d_solver.mkArraySort(intSort, realSort);
- ASSERT_FALSE(arraySortII.isComparableTo(intSort));
- // we do not support subtyping for arrays
- ASSERT_FALSE(arraySortII.isComparableTo(arraySortIR));
Sort setSortI = d_solver.mkSetSort(intSort);
Sort setSortR = d_solver.mkSetSort(realSort);
// we don't support subtyping for sets
- ASSERT_FALSE(setSortI.isComparableTo(setSortR));
ASSERT_FALSE(setSortI.isSubsortOf(setSortR));
- ASSERT_FALSE(setSortR.isComparableTo(setSortI));
ASSERT_FALSE(setSortR.isSubsortOf(setSortI));
}
assertNotEquals(pairIntInt, pairRealInt);
assertNotEquals(pairIntReal, pairRealInt);
- assertTrue(pairRealReal.isComparableTo(pairRealReal));
- assertFalse(pairIntReal.isComparableTo(pairRealReal));
- assertFalse(pairRealInt.isComparableTo(pairRealReal));
- assertFalse(pairIntInt.isComparableTo(pairRealReal));
- assertFalse(pairRealReal.isComparableTo(pairRealInt));
- assertFalse(pairIntReal.isComparableTo(pairRealInt));
- assertTrue(pairRealInt.isComparableTo(pairRealInt));
- assertFalse(pairIntInt.isComparableTo(pairRealInt));
- assertFalse(pairRealReal.isComparableTo(pairIntReal));
- assertTrue(pairIntReal.isComparableTo(pairIntReal));
- assertFalse(pairRealInt.isComparableTo(pairIntReal));
- assertFalse(pairIntInt.isComparableTo(pairIntReal));
- assertFalse(pairRealReal.isComparableTo(pairIntInt));
- assertFalse(pairIntReal.isComparableTo(pairIntInt));
- assertFalse(pairRealInt.isComparableTo(pairIntInt));
- assertTrue(pairIntInt.isComparableTo(pairIntInt));
-
assertTrue(pairRealReal.isSubsortOf(pairRealReal));
assertFalse(pairIntReal.isSubsortOf(pairRealReal));
assertFalse(pairRealInt.isSubsortOf(pairRealReal));
assertDoesNotThrow(() -> d_solver.getNullSort().isSubsortOf(d_solver.getNullSort()));
}
- @Test void isComparableTo()
- {
- assertTrue(d_solver.getIntegerSort().isComparableTo(d_solver.getIntegerSort()));
- assertTrue(d_solver.getIntegerSort().isComparableTo(d_solver.getRealSort()));
- assertFalse(d_solver.getIntegerSort().isComparableTo(d_solver.getBooleanSort()));
- assertDoesNotThrow(() -> d_solver.getNullSort().isComparableTo(d_solver.getNullSort()));
- }
-
@Test void getDatatype() throws CVC5ApiException
{
Sort dtypeSort = create_datatype_sort();
Sort realSort = d_solver.getRealSort();
assertTrue(intSort.isSubsortOf(realSort));
assertFalse(realSort.isSubsortOf(intSort));
- assertTrue(intSort.isComparableTo(realSort));
- assertTrue(realSort.isComparableTo(intSort));
Sort arraySortII = d_solver.mkArraySort(intSort, intSort);
Sort arraySortIR = d_solver.mkArraySort(intSort, realSort);
- assertFalse(arraySortII.isComparableTo(intSort));
- // we do not support subtyping for arrays
- assertFalse(arraySortII.isComparableTo(arraySortIR));
Sort setSortI = d_solver.mkSetSort(intSort);
Sort setSortR = d_solver.mkSetSort(realSort);
// we don't support subtyping for sets
- assertFalse(setSortI.isComparableTo(setSortR));
assertFalse(setSortI.isSubsortOf(setSortR));
- assertFalse(setSortR.isComparableTo(setSortI));
assertFalse(setSortR.isSubsortOf(setSortI));
}
assert pairIntInt != pairRealInt
assert pairIntReal != pairRealInt
- assert pairRealReal.isComparableTo(pairRealReal)
- assert not pairIntReal.isComparableTo(pairRealReal)
- assert not pairRealInt.isComparableTo(pairRealReal)
- assert not pairIntInt.isComparableTo(pairRealReal)
- assert not pairRealReal.isComparableTo(pairRealInt)
- assert not pairIntReal.isComparableTo(pairRealInt)
- assert pairRealInt.isComparableTo(pairRealInt)
- assert not pairIntInt.isComparableTo(pairRealInt)
- assert not pairRealReal.isComparableTo(pairIntReal)
- assert pairIntReal.isComparableTo(pairIntReal)
- assert not pairRealInt.isComparableTo(pairIntReal)
- assert not pairIntInt.isComparableTo(pairIntReal)
- assert not pairRealReal.isComparableTo(pairIntInt)
- assert not pairIntReal.isComparableTo(pairIntInt)
- assert not pairRealInt.isComparableTo(pairIntInt)
- assert pairIntInt.isComparableTo(pairIntInt)
-
assert pairRealReal.isSubsortOf(pairRealReal)
assert not pairIntReal.isSubsortOf(pairRealReal)
assert not pairRealInt.isSubsortOf(pairRealReal)
Sort(solver).isSubsortOf(Sort(solver))
-def test_is_comparable_to(solver):
- assert solver.getIntegerSort().isComparableTo(solver.getIntegerSort())
- assert solver.getIntegerSort().isComparableTo(solver.getRealSort())
- assert not solver.getIntegerSort().isComparableTo(solver.getBooleanSort())
- Sort(solver).isComparableTo(Sort(solver))
-
-
def test_get_datatype(solver):
dtypeSort = create_datatype_sort(solver)
dtypeSort.getDatatype()
realSort = solver.getRealSort()
assert intSort.isSubsortOf(realSort)
assert not realSort.isSubsortOf(intSort)
- assert intSort.isComparableTo(realSort)
- assert realSort.isComparableTo(intSort)
arraySortII = solver.mkArraySort(intSort, intSort)
arraySortIR = solver.mkArraySort(intSort, realSort)
- assert not arraySortII.isComparableTo(intSort)
- # we do not support subtyping for arrays
- assert not arraySortII.isComparableTo(arraySortIR)
setSortI = solver.mkSetSort(intSort)
setSortR = solver.mkSetSort(realSort)
# we don't support subtyping for sets
- assert not setSortI.isComparableTo(setSortR)
assert not setSortI.isSubsortOf(setSortR)
- assert not setSortR.isComparableTo(setSortI)
assert not setSortR.isSubsortOf(setSortI)