// consList["cons"]) in order to get the "head" selector symbol
// to apply.
Term t2 =
- slv.mkTerm(APPLY_SELECTOR, {consList["cons"].getSelectorTerm("head"), t});
+ slv.mkTerm(APPLY_SELECTOR,
+ {consList["cons"].getSelector("head").getSelectorTerm(), t});
std::cout << "t2 is " << t2 << std::endl
<< "simplify(t2) is " << slv.simplify(t2) << std::endl
Term a = slv.mkConst(paramConsIntListSort, "a");
std::cout << "term " << a << " is of sort " << a.getSort() << std::endl;
- Term head_a = slv.mkTerm(APPLY_SELECTOR,
- {paramConsList["cons"].getSelectorTerm("head"), a});
+ Term head_a = slv.mkTerm(
+ APPLY_SELECTOR,
+ {paramConsList["cons"].getSelector("head").getSelectorTerm(), a});
std::cout
<< "head_a is " << head_a << " of sort " << head_a.getSort() << std::endl
<< "sort of cons is "
// Here we first get the DatatypeConstructor for cons (with
// consList["cons"]) in order to get the "head" selector symbol
// to apply.
- Term t2 =
- slv.mkTerm(Kind.APPLY_SELECTOR, consList.getConstructor("cons").getSelectorTerm("head"), t);
+ Term t2 = slv.mkTerm(Kind.APPLY_SELECTOR,
+ consList.getConstructor("cons").getSelector("head").getSelectorTerm(),
+ t);
System.out.println("t2 is " + t2 + "\n"
+ "simplify(t2) is " + slv.simplify(t2) + "\n");
Term a = slv.mkConst(paramConsIntListSort, "a");
System.out.println("term " + a + " is of sort " + a.getSort());
- Term head_a = slv.mkTerm(
- Kind.APPLY_SELECTOR, paramConsList.getConstructor("cons").getSelectorTerm("head"), a);
+ Term head_a = slv.mkTerm(Kind.APPLY_SELECTOR,
+ paramConsList.getConstructor("cons").getSelector("head").getSelectorTerm(),
+ a);
System.out.println("head_a is " + head_a + " of sort " + head_a.getSort() + "\n"
+ "sort of cons is " + paramConsList.getConstructor("cons").getConstructorTerm().getSort()
+ "\n");
Kind.APPLY_CONSTRUCTOR,
consList.getConstructor("cons").getConstructorTerm(),
slv.mkInteger(0),
- slv.mkTerm(Kind.APPLY_CONSTRUCTOR,
- consList.getConstructor("nil").getConstructorTerm()))
+ slv.mkTerm(
+ Kind.APPLY_CONSTRUCTOR,
+ consList.getConstructor("nil").getConstructorTerm()))
print("t is {}\nsort of cons is {}\n sort of nil is {}".format(
t,
# to apply.
t2 = slv.mkTerm(
- Kind.APPLY_SELECTOR, consList["cons"].getSelectorTerm("head"), t)
+ Kind.APPLY_SELECTOR,
+ consList["cons"].getSelector("head").getSelectorTerm(),
+ t)
print("t2 is {}\nsimplify(t2) is {}\n\n".format(t2, slv.simplify(t2)))
head_a = slv.mkTerm(
Kind.APPLY_SELECTOR,
- paramConsList["cons"].getSelectorTerm("head"),
+ paramConsList["cons"].getSelector("head").getSelectorTerm(),
a)
print("head_a is {} of sort {}".format(head_a, head_a.getSort()))
print("sort of cons is",
CVC5_API_TRY_CATCH_END;
}
-Term DatatypeConstructor::getSelectorTerm(const std::string& name) const
-{
- CVC5_API_TRY_CATCH_BEGIN;
- CVC5_API_CHECK_NOT_NULL;
- //////// all checks before this line
- return getSelector(name).getSelectorTerm();
- ////////
- CVC5_API_TRY_CATCH_END;
-}
-
DatatypeConstructor::const_iterator DatatypeConstructor::begin() const
{
return DatatypeConstructor::const_iterator(d_solver, *d_ctor, true);
* @return the first datatype selector with the given name
*/
DatatypeSelector operator[](const std::string& name) const;
- DatatypeSelector getSelector(const std::string& name) const;
-
/**
- * Get the term representation of the datatype selector with the given name.
- * This is a linear search through the arguments, so in case of multiple,
- * similarly-named arguments, the selector for the first is returned.
+ * Get the datatype selector with the given name.
+ * This is a linear search through the selectors, so in case of
+ * multiple, similarly-named selectors, the first is returned.
* @param name the name of the datatype selector
- * @return a term representing the datatype selector with the given name
+ * @return the first datatype selector with the given name
*/
- Term getSelectorTerm(const std::string& name) const;
+ DatatypeSelector getSelector(const std::string& name) const;
/**
* @return true if this DatatypeConstructor is a null object
*
* - Arity: ``2``
*
- * - ``1:`` DatatypeSelector Term (see DatatypeSelector::getSelectorTerm() const, DatatypeConstructor::getSelectorTerm(const std::string&) const)
+ * - ``1:`` DatatypeSelector Term (see DatatypeSelector::getSelectorTerm() const)
* - ``2:`` Term of the codomain Sort of the selector
*
* - Create Term of this Kind with:
}
private native long getSelector(long pointer, String name);
- /**
- * Get the term representation of the datatype selector with the given name.
- * This is a linear search through the arguments, so in case of multiple,
- * similarly-named arguments, the selector for the first is returned.
- * @param name the name of the datatype selector
- * @return a term representing the datatype selector with the given name
- */
- public Term getSelectorTerm(String name)
- {
- long termPointer = getSelectorTerm(pointer, name);
- return new Term(solver, termPointer);
- }
- private native long getSelectorTerm(long pointer, String name);
-
/**
* @return true if this DatatypeConstructor is a null object
*/
CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, 0);
}
-/*
- * Class: io_github_cvc5_DatatypeConstructor
- * Method: getSelectorTerm
- * Signature: (JLjava/lang/String;)J
- */
-JNIEXPORT jlong JNICALL
-Java_io_github_cvc5_DatatypeConstructor_getSelectorTerm(JNIEnv* env,
- jobject,
- jlong pointer,
- jstring jName)
-{
- CVC5_JAVA_API_TRY_CATCH_BEGIN;
- DatatypeConstructor* current = (DatatypeConstructor*)pointer;
- const char* s = env->GetStringUTFChars(jName, nullptr);
- std::string cName(s);
- Term* retPointer = new Term(current->getSelectorTerm(cName));
- env->ReleaseStringUTFChars(jName, s);
- return (jlong)retPointer;
- CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, 0);
-}
-
/*
* Class: io_github_cvc5_DatatypeConstructor
* Method: isNull
Term getTesterTerm() except +
size_t getNumSelectors() except +
DatatypeSelector getSelector(const string& name) except +
- Term getSelectorTerm(const string& name) except +
bint isNull() except +
string toString() except +
cppclass const_iterator:
ds.cds = self.cdc.getSelector(name.encode())
return ds
- def getSelectorTerm(self, str name):
- """
- :param name: The name of the datatype selector.
- :return: A term representing the firstdatatype selector with the
- given name.
- """
- cdef Term term = Term(self.solver)
- term.cterm = self.cdc.getSelectorTerm(name.encode())
- return term
-
def isNull(self):
"""
:return: True if this DatatypeConstructor is a null object.
// list datatype constructor and selector operator terms
Term consTerm = list.getConstructor("cons").getConstructorTerm();
Term nilTerm = list.getConstructor("nil").getConstructorTerm();
- Term headTerm1 = list["cons"].getSelectorTerm("head");
- Term headTerm2 = list["cons"].getSelector("head").getSelectorTerm();
- Term tailTerm1 = list["cons"].getSelectorTerm("tail");
- Term tailTerm2 = list["cons"]["tail"].getSelectorTerm();
+ Term headTerm = list["cons"].getSelector("head").getSelectorTerm();
+ Term tailTerm = list["cons"]["tail"].getSelectorTerm();
// mkTerm(Op op, Term term) const
ASSERT_NO_THROW(d_solver.mkTerm(APPLY_CONSTRUCTOR, {nilTerm}));
ASSERT_THROW(d_solver.mkTerm(APPLY_CONSTRUCTOR, {consTerm}),
CVC5ApiException);
ASSERT_THROW(d_solver.mkTerm(opterm1), CVC5ApiException);
- ASSERT_THROW(d_solver.mkTerm(APPLY_SELECTOR, {headTerm1}), CVC5ApiException);
+ ASSERT_THROW(d_solver.mkTerm(APPLY_SELECTOR, {headTerm}), CVC5ApiException);
ASSERT_THROW(d_solver.mkTerm(opterm1), CVC5ApiException);
ASSERT_THROW(slv.mkTerm(APPLY_CONSTRUCTOR, {nilTerm}), CVC5ApiException);
// mkTerm(Op op, Term child) const
ASSERT_NO_THROW(d_solver.mkTerm(opterm1, {a}));
ASSERT_NO_THROW(d_solver.mkTerm(opterm2, {d_solver.mkInteger(1)}));
- ASSERT_NO_THROW(d_solver.mkTerm(APPLY_SELECTOR, {headTerm1, c}));
- ASSERT_NO_THROW(d_solver.mkTerm(APPLY_SELECTOR, {tailTerm2, c}));
+ ASSERT_NO_THROW(d_solver.mkTerm(APPLY_SELECTOR, {headTerm, c}));
+ ASSERT_NO_THROW(d_solver.mkTerm(APPLY_SELECTOR, {tailTerm, c}));
ASSERT_THROW(d_solver.mkTerm(opterm2, {a}), CVC5ApiException);
ASSERT_THROW(d_solver.mkTerm(opterm1, {Term()}), CVC5ApiException);
ASSERT_THROW(
Term consTerm = consList.getConstructor("cons").getConstructorTerm();
Term nilTerm = consList.getConstructor("nil").getConstructorTerm();
- Term headTerm = consList["cons"].getSelectorTerm("head");
+ Term headTerm = consList["cons"].getSelector("head").getSelectorTerm();
Term listnil = d_solver.mkTerm(APPLY_CONSTRUCTOR, {nilTerm});
Term listcons1 = d_solver.mkTerm(APPLY_CONSTRUCTOR,
d_solver.mkTerm(APPLY_CONSTRUCTOR,
{consList.getConstructor("nil").getConstructorTerm()})});
ASSERT_NO_THROW(d_solver.simplify(dt1));
- Term dt2 = d_solver.mkTerm(APPLY_SELECTOR,
- {consList["cons"].getSelectorTerm("head"), dt1});
+ Term dt2 = d_solver.mkTerm(
+ APPLY_SELECTOR,
+ {consList["cons"].getSelector("head").getSelectorTerm(), dt1});
ASSERT_NO_THROW(d_solver.simplify(dt2));
Term b1 = d_solver.mkVar(bvSort, "b1");
Term t1507 = d_solver.mkTerm(
APPLY_CONSTRUCTOR,
{s9.getDatatype().getConstructor("_x184").getConstructorTerm(), t7});
- ASSERT_NO_THROW(d_solver.mkTerm(
- APPLY_UPDATER,
- {s9.getDatatype().getConstructor("_x186").getSelectorTerm("_x185"),
- t1507,
- t7}));
+ ASSERT_NO_THROW(d_solver.mkTerm(APPLY_UPDATER,
+ {s9.getDatatype()
+ .getConstructor("_x186")
+ .getSelector("_x185")
+ .getSelectorTerm(),
+ t1507,
+ t7}));
}
TEST_F(TestApiBlackSolver, proj_issue379)
Sort s14 = slv.mkDatatypeSorts({_dt46})[0];
Term t31 = slv.mkConst(s7, "_x100");
Term t47 = slv.mkConst(s14, "_x112");
- Term sel =
- t47.getSort().getDatatype().getConstructor("_cons64").getSelectorTerm(
- "_sel62");
+ Term sel = t47.getSort()
+ .getDatatype()
+ .getConstructor("_cons64")
+ .getSelector("_sel62")
+ .getSelectorTerm();
Term t274 = slv.mkTerm(APPLY_SELECTOR, {sel, t47});
Term t488 = slv.mkTerm(Kind::APPLY_UF, {t31, t274});
slv.assertFormula({t488});
Term nilTerm = consList.getConstructor("nil").getConstructorTerm();
Term consTerm = consList.getConstructor("cons").getConstructorTerm();
- Term headTerm = consList["cons"].getSelectorTerm("head");
+ Term headTerm = consList["cons"].getSelector("head").getSelectorTerm();
Term listnil = d_solver.mkTerm(APPLY_CONSTRUCTOR, {nilTerm});
Term listcons1 = d_solver.mkTerm(APPLY_CONSTRUCTOR,
// list datatype constructor and selector operator terms
Term consOpTerm = list.getConstructor("cons").getConstructorTerm();
Term nilOpTerm = list.getConstructor("nil").getConstructorTerm();
- Term headOpTerm = list["cons"].getSelectorTerm("head");
- Term tailOpTerm = list["cons"].getSelectorTerm("tail");
+ Term headOpTerm = list["cons"].getSelector("head").getSelectorTerm();
+ Term tailOpTerm = list["cons"].getSelector("tail").getSelectorTerm();
Term nilTerm = d_solver.mkTerm(APPLY_CONSTRUCTOR, {nilOpTerm});
Term consTerm = d_solver.mkTerm(APPLY_CONSTRUCTOR,
// list datatype constructor and selector operator terms
Term consOpTerm = list.getConstructor("cons").getConstructorTerm();
Term nilOpTerm = list.getConstructor("nil").getConstructorTerm();
- Term headOpTerm = list["cons"].getSelectorTerm("head");
- Term tailOpTerm = list["cons"].getSelectorTerm("tail");
+ Term headOpTerm = list["cons"].getSelector("head").getSelectorTerm();
+ Term tailOpTerm = list["cons"].getSelector("tail").getSelectorTerm();
Term nilTerm = d_solver.mkTerm(APPLY_CONSTRUCTOR, {nilOpTerm});
Term consTerm = d_solver.mkTerm(APPLY_CONSTRUCTOR,
// list datatype constructor and selector operator terms
Term consTerm = list.getConstructor("cons").getConstructorTerm();
Term nilTerm = list.getConstructor("nil").getConstructorTerm();
- Term headTerm1 = list.getConstructor("cons").getSelectorTerm("head");
- Term headTerm2 = list.getConstructor("cons").getSelector("head").getSelectorTerm();
- Term tailTerm1 = list.getConstructor("cons").getSelectorTerm("tail");
- Term tailTerm2 = list.getConstructor("cons").getSelector("tail").getSelectorTerm();
+ Term headTerm = list.getConstructor("cons").getSelector("head").getSelectorTerm();
+ Term tailTerm = list.getConstructor("cons").getSelector("tail").getSelectorTerm();
// mkTerm(Op op, Term term) const
assertDoesNotThrow(() -> d_solver.mkTerm(APPLY_CONSTRUCTOR, nilTerm));
assertThrows(CVC5ApiException.class, () -> d_solver.mkTerm(APPLY_SELECTOR, consTerm));
assertThrows(CVC5ApiException.class, () -> d_solver.mkTerm(APPLY_CONSTRUCTOR, consTerm));
assertThrows(CVC5ApiException.class, () -> d_solver.mkTerm(opterm1));
- assertThrows(CVC5ApiException.class, () -> d_solver.mkTerm(APPLY_SELECTOR, headTerm1));
+ assertThrows(CVC5ApiException.class, () -> d_solver.mkTerm(APPLY_SELECTOR, headTerm));
assertThrows(CVC5ApiException.class, () -> d_solver.mkTerm(opterm1));
assertThrows(CVC5ApiException.class, () -> slv.mkTerm(APPLY_CONSTRUCTOR, nilTerm));
// mkTerm(Op op, Term child) const
assertDoesNotThrow(() -> d_solver.mkTerm(opterm1, a));
assertDoesNotThrow(() -> d_solver.mkTerm(opterm2, d_solver.mkInteger(1)));
- assertDoesNotThrow(() -> d_solver.mkTerm(APPLY_SELECTOR, headTerm1, c));
- assertDoesNotThrow(() -> d_solver.mkTerm(APPLY_SELECTOR, tailTerm2, c));
+ assertDoesNotThrow(() -> d_solver.mkTerm(APPLY_SELECTOR, headTerm, c));
+ assertDoesNotThrow(() -> d_solver.mkTerm(APPLY_SELECTOR, tailTerm, c));
assertThrows(CVC5ApiException.class, () -> d_solver.mkTerm(opterm2, a));
assertThrows(CVC5ApiException.class, () -> d_solver.mkTerm(opterm1, d_solver.getNullTerm()));
assertThrows(CVC5ApiException.class,
Term consTerm = consList.getConstructor("cons").getConstructorTerm();
Term nilTerm = consList.getConstructor("nil").getConstructorTerm();
- Term headTerm = consList.getConstructor("cons").getSelectorTerm("head");
+ Term headTerm = consList.getConstructor("cons").getSelector("head").getSelectorTerm();
Term listnil = d_solver.mkTerm(APPLY_CONSTRUCTOR, nilTerm);
Term listcons1 = d_solver.mkTerm(APPLY_CONSTRUCTOR, consTerm, d_solver.mkInteger(1), listnil);
d_solver.mkTerm(APPLY_CONSTRUCTOR, consList.getConstructor("nil").getConstructorTerm()));
assertDoesNotThrow(() -> d_solver.simplify(dt1));
Term dt2 = d_solver.mkTerm(
- APPLY_SELECTOR, consList.getConstructor("cons").getSelectorTerm("head"), dt1);
+ APPLY_SELECTOR, consList.getConstructor("cons").getSelector("head").getSelectorTerm(), dt1);
assertDoesNotThrow(() -> d_solver.simplify(dt2));
Term b1 = d_solver.mkVar(bvSort, "b1");
# list datatype constructor and selector operator terms
consTerm = lis.getConstructor("cons").getConstructorTerm()
nilTerm = lis.getConstructor("nil").getConstructorTerm()
- headTerm1 = lis["cons"].getSelectorTerm("head")
- headTerm2 = lis["cons"].getSelector("head").getSelectorTerm()
- tailTerm1 = lis["cons"].getSelectorTerm("tail")
- tailTerm2 = lis["cons"]["tail"].getSelectorTerm()
+ headTerm = lis["cons"].getSelector("head").getSelectorTerm()
+ tailTerm = lis["cons"]["tail"].getSelectorTerm()
# mkTerm(Op op, Term term) const
solver.mkTerm(Kind.APPLY_CONSTRUCTOR, nilTerm)
with pytest.raises(RuntimeError):
solver.mkTerm(opterm1)
with pytest.raises(RuntimeError):
- solver.mkTerm(Kind.APPLY_SELECTOR, headTerm1)
+ solver.mkTerm(Kind.APPLY_SELECTOR, headTerm)
with pytest.raises(RuntimeError):
solver.mkTerm(opterm1)
with pytest.raises(RuntimeError):
# mkTerm(Op op, Term child) const
solver.mkTerm(opterm1, a)
solver.mkTerm(opterm2, solver.mkInteger(1))
- solver.mkTerm(Kind.APPLY_SELECTOR, headTerm1, c)
- solver.mkTerm(Kind.APPLY_SELECTOR, tailTerm2, c)
+ solver.mkTerm(Kind.APPLY_SELECTOR, headTerm, c)
+ solver.mkTerm(Kind.APPLY_SELECTOR, tailTerm, c)
with pytest.raises(RuntimeError):
solver.mkTerm(opterm2, a)
with pytest.raises(RuntimeError):
consTerm = consList.getConstructor("cons").getConstructorTerm()
nilTerm = consList.getConstructor("nil").getConstructorTerm()
- headTerm = consList["cons"].getSelectorTerm("head")
+ headTerm = consList["cons"].getSelector("head").getSelectorTerm()
listnil = solver.mkTerm(Kind.APPLY_CONSTRUCTOR, nilTerm)
listcons1 = solver.mkTerm(Kind.APPLY_CONSTRUCTOR, consTerm,
consList.getConstructor("nil").getConstructorTerm()))
solver.simplify(dt1)
dt2 = solver.mkTerm(
- Kind.APPLY_SELECTOR, consList["cons"].getSelectorTerm("head"), dt1)
+ Kind.APPLY_SELECTOR,
+ consList["cons"].getSelector("head").getSelectorTerm(),
+ dt1)
solver.simplify(dt2)
b1 = solver.mkVar(bvSort, "b1")
# list datatype constructor and selector operator terms
consOpTerm = list1.getConstructor("cons").getConstructorTerm()
nilOpTerm = list1.getConstructor("nil").getConstructorTerm()
- headOpTerm = list1["cons"].getSelectorTerm("head")
- tailOpTerm = list1["cons"].getSelectorTerm("tail")
+ headOpTerm = list1["cons"].getSelector("head").getSelectorTerm()
+ tailOpTerm = list1["cons"].getSelector("tail").getSelectorTerm()
nilTerm = solver.mkTerm(Kind.APPLY_CONSTRUCTOR, nilOpTerm)
consTerm = solver.mkTerm(Kind.APPLY_CONSTRUCTOR, consOpTerm,