private native long mkDatatypeSort(long pointer, long datatypeDeclPointer)
throws CVC5ApiException;
- /**
- * Create a vector of datatype sorts. The names of the datatype
- * declarations must be distinct.
- *
- * @param dtypedecls the datatype declarations from which the sort is
- * created
- * @return the datatype sorts
- * @throws CVC5ApiException
- */
- public Sort[] mkDatatypeSorts(List<DatatypeDecl> dtypedecls) throws CVC5ApiException
- {
- return mkDatatypeSorts(dtypedecls.toArray(new DatatypeDecl[0]));
- }
-
/**
* Create a vector of datatype sorts. The names of the datatype
* declarations must be distinct.
private native long mkTerm(
long pointer, long opPointer, long child1Pointer, long child2Pointer, long child3Pointer);
- /**
- * Create n-ary term of given kind from a given operator.
- * Create operators with mkOp().
- * @param op the operator
- * @param children the children of the term
- * @return the Term
- */
- public Term mkTerm(Op op, List<Term> children)
- {
- return mkTerm(op, children.toArray(new Term[0]));
- }
-
/**
* Create n-ary term of given kind from a given operator.
* Create operators with mkOp().
private native long mkDatatypeDecl(
long pointer, String name, long paramPointer, boolean isCoDatatype);
- /**
- * Create a datatype declaration.
- * Create sorts parameter with Solver::mkParamSort().
- * @param name the name of the datatype
- * @param params a list of sort parameters
- * @return the DatatypeDecl
- */
- public DatatypeDecl mkDatatypeDecl(String name, List<Sort> params)
- {
- return mkDatatypeDecl(name, params.toArray(new Sort[0]));
- }
-
/**
* Create a datatype declaration.
* Create sorts parameter with Solver::mkParamSort().
dtdecls.add(list);
AtomicReference<Sort[]> atomic = new AtomicReference<>();
- assertDoesNotThrow(() -> atomic.set(d_solver.mkDatatypeSorts(dtdecls)));
+ assertDoesNotThrow(
+ () -> atomic.set(d_solver.mkDatatypeSorts(dtdecls.toArray(new DatatypeDecl[0]))));
Sort[] dtsorts = atomic.get();
assertEquals(dtsorts.length, dtdecls.size());
for (int i = 0, ndecl = dtdecls.size(); i < ndecl; i++)
List<DatatypeDecl> dtdeclsBad = new ArrayList<>();
DatatypeDecl emptyD = d_solver.mkDatatypeDecl("emptyD");
dtdeclsBad.add(emptyD);
- assertThrows(CVC5ApiException.class, () -> d_solver.mkDatatypeSorts(dtdeclsBad));
+ assertThrows(CVC5ApiException.class,
+ () -> d_solver.mkDatatypeSorts(dtdeclsBad.toArray(new DatatypeDecl[0])));
}
@Test
dtdecls.add(list);
AtomicReference<Sort[]> atomic = new AtomicReference<>();
- assertDoesNotThrow(() -> atomic.set(d_solver.mkDatatypeSorts(dtdecls)));
+ assertDoesNotThrow(
+ () -> atomic.set(d_solver.mkDatatypeSorts(dtdecls.toArray(new DatatypeDecl[0]))));
Sort[] dtsorts = atomic.get();
assertEquals(dtsorts.length, dtdecls.size());
for (int i = 0, ndecl = dtdecls.size(); i < ndecl; i++)
Sort t2 = d_solver.mkParamSort("T2");
v.add(t1);
v.add(t2);
- DatatypeDecl pairSpec = d_solver.mkDatatypeDecl("pair", v);
+ DatatypeDecl pairSpec = d_solver.mkDatatypeDecl("pair", v.toArray(new Sort[0]));
DatatypeConstructorDecl mkpair = d_solver.mkDatatypeConstructorDecl("mk-pair");
mkpair.addSelector("first", t1);
v.clear();
v.add(d_solver.getIntegerSort());
v.add(d_solver.getIntegerSort());
- Sort pairIntInt = pairType.instantiate(v);
+ Sort pairIntInt = pairType.instantiate(v.toArray(new Sort[0]));
v.clear();
v.add(d_solver.getRealSort());
v.add(d_solver.getRealSort());
- Sort pairRealReal = pairType.instantiate(v);
+ Sort pairRealReal = pairType.instantiate(v.toArray(new Sort[0]));
v.clear();
v.add(d_solver.getRealSort());
v.add(d_solver.getIntegerSort());
- Sort pairRealInt = pairType.instantiate(v);
+ Sort pairRealInt = pairType.instantiate(v.toArray(new Sort[0]));
v.clear();
v.add(d_solver.getIntegerSort());
v.add(d_solver.getRealSort());
- Sort pairIntReal = pairType.instantiate(v);
+ Sort pairIntReal = pairType.instantiate(v.toArray(new Sort[0]));
assertNotEquals(pairIntInt, pairRealReal);
assertNotEquals(pairIntReal, pairRealReal);
void datatypeIsFinite() throws CVC5ApiException
{
List<Sort> v = new ArrayList<>();
- DatatypeDecl dtypedecl = d_solver.mkDatatypeDecl("dt", v);
+ DatatypeDecl dtypedecl = d_solver.mkDatatypeDecl("dt", v.toArray(new Sort[0]));
DatatypeConstructorDecl ctordecl = d_solver.mkDatatypeConstructorDecl("cons");
ctordecl.addSelector("sel", d_solver.getBooleanSort());
dtypedecl.addConstructor(ctordecl);
Sort p = d_solver.mkParamSort("p1");
v.add(p);
- DatatypeDecl pdtypedecl = d_solver.mkDatatypeDecl("dt", v);
+ DatatypeDecl pdtypedecl = d_solver.mkDatatypeDecl("dt", v.toArray(new Sort[0]));
DatatypeConstructorDecl pctordecl = d_solver.mkDatatypeConstructorDecl("cons");
pctordecl.addSelector("sel", p);
pdtypedecl.addConstructor(pctordecl);
dtdecls.add(ns);
// this is well-founded and has no nested recursion
AtomicReference<Sort[]> atomic = new AtomicReference<>();
- assertDoesNotThrow(() -> atomic.set(d_solver.mkDatatypeSorts(dtdecls)));
+ assertDoesNotThrow(
+ () -> atomic.set(d_solver.mkDatatypeSorts(dtdecls.toArray(new DatatypeDecl[0]))));
Sort[] dtsorts = atomic.get();
assertEquals(dtsorts.length, 3);
assertTrue(dtsorts[0].getDatatype().isWellFounded());
// dtsorts.clear();
// this is not well-founded due to non-simple recursion
- assertDoesNotThrow(() -> atomic.set(d_solver.mkDatatypeSorts(dtdecls)));
+ assertDoesNotThrow(
+ () -> atomic.set(d_solver.mkDatatypeSorts(dtdecls.toArray(new DatatypeDecl[0]))));
dtsorts = atomic.get();
assertEquals(dtsorts.length, 1);
assertTrue(
// dtsorts.clear();
// both are well-founded and have nested recursion
- assertDoesNotThrow(() -> atomic.set(d_solver.mkDatatypeSorts(dtdecls)));
+ assertDoesNotThrow(
+ () -> atomic.set(d_solver.mkDatatypeSorts(dtdecls.toArray(new DatatypeDecl[0]))));
dtsorts = atomic.get();
assertEquals(dtsorts.length, 2);
assertTrue(dtsorts[0].getDatatype().isWellFounded());
// dtsorts.clear();
// both are well-founded and have nested recursion
- assertDoesNotThrow(() -> atomic.set(d_solver.mkDatatypeSorts(dtdecls)));
+ assertDoesNotThrow(
+ () -> atomic.set(d_solver.mkDatatypeSorts(dtdecls.toArray(new DatatypeDecl[0]))));
dtsorts = atomic.get();
assertEquals(dtsorts.length, 2);
assertTrue(dtsorts[0].getDatatype().isWellFounded());
List<Sort> v = new ArrayList<>();
Sort x = d_solver.mkParamSort("X");
v.add(x);
- DatatypeDecl list5 = d_solver.mkDatatypeDecl("list5", v);
+ DatatypeDecl list5 = d_solver.mkDatatypeDecl("list5", v.toArray(new Sort[0]));
List<Sort> args = new ArrayList<>();
args.add(x);
- Sort urListX = unresList5.instantiate(args);
+ Sort urListX = unresList5.instantiate(args.toArray(new Sort[0]));
args.set(0, urListX);
- Sort urListListX = unresList5.instantiate(args);
+ Sort urListListX = unresList5.instantiate(args.toArray(new Sort[0]));
DatatypeConstructorDecl cons5 = d_solver.mkDatatypeConstructorDecl("cons5");
cons5.addSelector("car", x);
dtdecls.add(list5);
// well-founded and has nested recursion
- assertDoesNotThrow(() -> atomic.set(d_solver.mkDatatypeSorts(dtdecls)));
+ assertDoesNotThrow(
+ () -> atomic.set(d_solver.mkDatatypeSorts(dtdecls.toArray(new DatatypeDecl[0]))));
dtsorts = atomic.get();
assertEquals(dtsorts.length, 1);
assertTrue(dtsorts[0].getDatatype().isWellFounded());
List<Sort> v = new ArrayList<>();
Sort x = d_solver.mkParamSort("X");
v.add(x);
- DatatypeDecl plist = d_solver.mkDatatypeDecl("plist", v);
+ DatatypeDecl plist = d_solver.mkDatatypeDecl("plist", v.toArray(new Sort[0]));
List<Sort> args = new ArrayList<>();
args.add(x);
- Sort urListX = unresList.instantiate(args);
+ Sort urListX = unresList.instantiate(args.toArray(new Sort[0]));
DatatypeConstructorDecl pcons = d_solver.mkDatatypeConstructorDecl("pcons");
pcons.addSelector("car", x);
// make the datatype sorts
AtomicReference<Sort[]> atomic = new AtomicReference<>();
- assertDoesNotThrow(() -> atomic.set(d_solver.mkDatatypeSorts(dtdecls)));
+ assertDoesNotThrow(
+ () -> atomic.set(d_solver.mkDatatypeSorts(dtdecls.toArray(new DatatypeDecl[0]))));
Sort[] dtsorts = atomic.get();
assertEquals(dtsorts.length, 1);
Datatype d = dtsorts[0].getDatatype();
Sort isort = d_solver.getIntegerSort();
List<Sort> iargs = new ArrayList<>();
iargs.add(isort);
- Sort listInt = dtsorts[0].instantiate(iargs);
+ Sort listInt = dtsorts[0].instantiate(iargs.toArray(new Sort[0]));
AtomicReference<Term> atomicTerm = new AtomicReference<>();
// get the specialized constructor term for list[Int]
}
// testing rebuild from op and children
- assertEquals(fx, d_solver.mkTerm(fx.getOp(), children));
+ assertEquals(fx, d_solver.mkTerm(fx.getOp(), children.toArray(new Term[0])));
// Test Datatypes Ops
Sort sort = d_solver.mkParamSort("T");
rs.add(y);
es.add(y);
rs.add(one);
- assertEquals(xpy.substitute(es, rs), xpone);
+ assertEquals(xpy.substitute(es.toArray(new Term[0]), rs.toArray(new Term[0])), xpone);
// incorrect substitution due to arity
rs.remove(rs.size() - 1);
- assertThrows(CVC5ApiException.class, () -> xpy.substitute(es, rs));
+ assertThrows(CVC5ApiException.class,
+ () -> xpy.substitute(es.toArray(new Term[0]), rs.toArray(new Term[0])));
// incorrect substitution due to types
rs.add(ttrue);
- assertThrows(CVC5ApiException.class, () -> xpy.substitute(es, rs));
+ assertThrows(CVC5ApiException.class,
+ () -> xpy.substitute(es.toArray(new Term[0]), rs.toArray(new Term[0])));
// null cannot substitute
Term tnull = d_solver.getNullTerm();
assertThrows(CVC5ApiException.class, () -> xpx.substitute(x, tnull));
rs.remove(rs.size() - 1);
rs.add(tnull);
- assertThrows(CVC5ApiException.class, () -> xpy.substitute(es, rs));
+ assertThrows(CVC5ApiException.class,
+ () -> xpy.substitute(es.toArray(new Term[0]), rs.toArray(new Term[0])));
es.clear();
rs.clear();
es.add(x);
rs.add(y);
- assertThrows(CVC5ApiException.class, () -> tnull.substitute(es, rs));
+ assertThrows(CVC5ApiException.class,
+ () -> tnull.substitute(es.toArray(new Term[0]), rs.toArray(new Term[0])));
es.add(tnull);
rs.add(one);
- assertThrows(CVC5ApiException.class, () -> xpx.substitute(es, rs));
+ assertThrows(CVC5ApiException.class,
+ () -> xpx.substitute(es.toArray(new Term[0]), rs.toArray(new Term[0])));
}
@Test