/* Arrays -------------------------------------------------------------- */
{SELECT, CVC4::Kind::SELECT},
{STORE, CVC4::Kind::STORE},
- {STORE_ALL, CVC4::Kind::STORE_ALL},
+ {CONST_ARRAY, CVC4::Kind::STORE_ALL},
/* Datatypes ----------------------------------------------------------- */
{APPLY_SELECTOR, CVC4::Kind::APPLY_SELECTOR},
{APPLY_CONSTRUCTOR, CVC4::Kind::APPLY_CONSTRUCTOR},
/* Arrays ---------------------------------------------------------- */
{CVC4::Kind::SELECT, SELECT},
{CVC4::Kind::STORE, STORE},
- {CVC4::Kind::STORE_ALL, STORE_ALL},
+ {CVC4::Kind::STORE_ALL, CONST_ARRAY},
/* Datatypes ------------------------------------------------------- */
{CVC4::Kind::APPLY_SELECTOR, APPLY_SELECTOR},
{CVC4::Kind::APPLY_CONSTRUCTOR, APPLY_CONSTRUCTOR},
return d_expr->isConst();
}
+Term Term::getConstArrayBase() const
+{
+ CVC4_API_CHECK_NOT_NULL;
+ // CONST_ARRAY kind maps to STORE_ALL internal kind
+ CVC4_API_CHECK(d_expr->getKind() == CVC4::Kind::STORE_ALL)
+ << "Expecting a CONST_ARRAY Term when calling getConstArrayBase()";
+ return Term(d_solver, d_expr->getConst<ArrayStoreAll>().getExpr());
+}
+
Term Term::notTerm() const
{
CVC4_API_CHECK_NOT_NULL;
*/
bool isConst() const;
+ /**
+ * Return the base (element stored at all indices) of a constant array
+ * throws an exception if the kind is not CONST_ARRAY
+ * @return the base value
+ */
+ Term getConstArrayBase() const;
+
/**
* Boolean negation.
* @return the Boolean negation of this term
* conditions when there is a chain of equalities connecting two constant
* arrays, the solver doesn't know what to do and aborts (Issue #1667).
*/
- STORE_ALL,
+ CONST_ARRAY,
#if 0
/* array table function (internal-only symbol) */
ARR_TABLE_FUN,
bint hasOp() except +
Op getOp() except +
bint isNull() except +
+ Term getConstArrayBase() except +
Term notTerm() except +
Term andTerm(const Term& t) except +
Term orTerm(const Term& t) except +
def isNull(self):
return self.cterm.isNull()
+ def getConstArrayBase(self):
+ cdef Term term = Term()
+ term.cterm = self.cterm.getConstArrayBase()
+ return term
+
def notTerm(self):
cdef Term term = Term()
term.cterm = self.cterm.notTerm()
| LPAREN_TOK AS_TOK
( CONST_TOK sortSymbol[type, CHECK_DECLARED]
{
- p.d_kind = api::STORE_ALL;
+ p.d_kind = api::CONST_ARRAY;
PARSER_STATE->parseOpApplyTypeAscription(p, type);
}
| identifier[p]
Debug("parser") << "parseOpApplyTypeAscription : " << p << " " << type
<< std::endl;
// (as const (Array T1 T2))
- if (p.d_kind == api::STORE_ALL)
+ if (p.d_kind == api::CONST_ARRAY)
{
if (!type.isArray())
{
// Second phase: apply the arguments to the parse op
const Options& opts = d_solver->getExprManager()->getOptions();
// handle special cases
- if (p.d_kind == api::STORE_ALL && !p.d_type.isNull())
+ if (p.d_kind == api::CONST_ARRAY && !p.d_type.isNull())
{
if (args.size() != 1)
{
void testTermChildren();
void testSubstitute();
void testIsConst();
+ void testConstArray();
private:
Solver d_solver;
Term tnull;
TS_ASSERT_THROWS(tnull.isConst(), CVC4ApiException&);
}
+
+void TermBlack::testConstArray()
+{
+ Sort intsort = d_solver.getIntegerSort();
+ Sort arrsort = d_solver.mkArraySort(intsort, intsort);
+ Term a = d_solver.mkConst(arrsort, "a");
+ Term one = d_solver.mkReal(1);
+ Term constarr = d_solver.mkConstArray(arrsort, one);
+
+ TS_ASSERT(!a.isConst());
+ TS_ASSERT(constarr.isConst());
+
+ TS_ASSERT_EQUALS(constarr.getKind(), CONST_ARRAY);
+ TS_ASSERT_EQUALS(constarr.getConstArrayBase(), one);
+ TS_ASSERT_THROWS(a.getConstArrayBase(), CVC4ApiException&);
+}