CVC4_API_SOLVER_TRY_CATCH_END;
}
+Term Solver::mkConstArray(Sort sort, Term val) const
+{
+ CVC4_API_SOLVER_TRY_CATCH_BEGIN;
+ CVC4_API_ARG_CHECK_NOT_NULL(val);
+ CVC4_API_CHECK(sort.isArray()) << "Not an array sort.";
+ CVC4_API_CHECK(sort.getArrayElementSort() == val.getSort())
+ << "Value does not match element sort.";
+ Term res = mkValHelper<CVC4::ArrayStoreAll>(
+ CVC4::ArrayStoreAll(*sort.d_type, *val.d_expr));
+ return res;
+ CVC4_API_SOLVER_TRY_CATCH_END;
+}
+
Term Solver::mkPosInf(uint32_t exp, uint32_t sig) const
{
CVC4_API_SOLVER_TRY_CATCH_BEGIN;
*/
Term mkBitVector(uint32_t size, std::string& s, uint32_t base) const;
+ /**
+ * Create a constant array with the provided constant value stored at every
+ * index
+ * @param sort the sort of the constant array (must be an array sort)
+ * @param val the constant value to store (must match the sort's element sort)
+ * @return the constant array term
+ */
+ Term mkConstArray(Sort sort, Term val) const;
+
/**
* Create a positive infinity floating-point constant. Requires CVC4 to be
* compiled with SymFPU support.
void testMkBitVector();
void testMkBoolean();
void testMkConst();
+ void testMkConstArray();
void testMkEmptySet();
void testMkFalse();
void testMkFloatingPoint();
TS_ASSERT_THROWS(d_solver->mkConst(Sort(), "a"), CVC4ApiException&);
}
+void SolverBlack::testMkConstArray()
+{
+ Sort intSort = d_solver->getIntegerSort();
+ Sort arrSort = d_solver->mkArraySort(intSort, intSort);
+ Term zero = d_solver->mkReal(0);
+ Term constArr = d_solver->mkConstArray(arrSort, zero);
+
+ TS_ASSERT_THROWS_NOTHING(d_solver->mkConstArray(arrSort, zero));
+ TS_ASSERT_THROWS(d_solver->mkConstArray(arrSort, Term()), CVC4ApiException&);
+ TS_ASSERT_THROWS(d_solver->mkConstArray(arrSort, d_solver->mkBitVector(1, 1)),
+ CVC4ApiException&);
+ TS_ASSERT_THROWS(d_solver->mkConstArray(intSort, zero), CVC4ApiException&);
+}
+
void SolverBlack::testDeclareDatatype()
{
DatatypeConstructorDecl cons("cons");