Fixes cvc5/cvc5-projects#367.
Term Solver::mkTermHelper(const Op& op, const std::vector<Term>& children) const
{
- // Note: Op and children are checked in the caller to avoid double checks
- checkMkTerm(op.d_kind, children.size());
- //////// all checks before this line
-
if (!op.isIndexedHelper())
{
return mkTermHelper(op.d_kind, children);
}
+ // Note: Op and children are checked in the caller to avoid double checks
+ checkMkTerm(op.d_kind, children.size());
+ //////// all checks before this line
+
const cvc5::Kind int_kind = extToIntKind(op.d_kind);
std::vector<Node> echildren = Term::termVectorToNodes(children);
ASSERT_THROW(d_solver.mkTerm(EQUAL, v2), CVC5ApiException);
ASSERT_THROW(d_solver.mkTerm(EQUAL, v3), CVC5ApiException);
ASSERT_THROW(d_solver.mkTerm(DISTINCT, v6), CVC5ApiException);
+
+ // Test cases that are nary via the API but have arity = 2 internally
+ Sort s_bool = d_solver.getBooleanSort();
+ Term t_bool = d_solver.mkConst(s_bool, "t_bool");
+ ASSERT_NO_THROW(d_solver.mkTerm(IMPLIES, {t_bool, t_bool, t_bool}));
+ ASSERT_NO_THROW(
+ d_solver.mkTerm(d_solver.mkOp(IMPLIES), {t_bool, t_bool, t_bool}));
+ ASSERT_NO_THROW(d_solver.mkTerm(XOR, {t_bool, t_bool, t_bool}));
+ ASSERT_NO_THROW(
+ d_solver.mkTerm(d_solver.mkOp(XOR), {t_bool, t_bool, t_bool}));
+ Term t_int = d_solver.mkConst(d_solver.getIntegerSort(), "t_int");
+ ASSERT_NO_THROW(d_solver.mkTerm(DIVISION, {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(
+ d_solver.mkTerm(d_solver.mkOp(DIVISION), {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(INTS_DIVISION, {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(
+ d_solver.mkTerm(d_solver.mkOp(INTS_DIVISION), {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(MINUS, {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(d_solver.mkOp(MINUS), {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(EQUAL, {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(d_solver.mkOp(EQUAL), {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(LT, {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(d_solver.mkOp(LT), {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(GT, {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(d_solver.mkOp(GT), {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(LEQ, {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(d_solver.mkOp(LEQ), {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(GEQ, {t_int, t_int, t_int}));
+ ASSERT_NO_THROW(d_solver.mkTerm(d_solver.mkOp(GEQ), {t_int, t_int, t_int}));
+ Term t_reg = d_solver.mkConst(d_solver.getRegExpSort(), "t_reg");
+ ASSERT_NO_THROW(d_solver.mkTerm(REGEXP_DIFF, {t_reg, t_reg, t_reg}));
+ ASSERT_NO_THROW(
+ d_solver.mkTerm(d_solver.mkOp(REGEXP_DIFF), {t_reg, t_reg, t_reg}));
+ Term t_fun = d_solver.mkConst(
+ d_solver.mkFunctionSort({s_bool, s_bool, s_bool}, s_bool));
+ ASSERT_NO_THROW(d_solver.mkTerm(HO_APPLY, {t_fun, t_bool, t_bool, t_bool}));
+ ASSERT_NO_THROW(d_solver.mkTerm(d_solver.mkOp(HO_APPLY),
+ {t_fun, t_bool, t_bool, t_bool}));
}
TEST_F(TestApiBlackSolver, mkTermFromOp)
with pytest.raises(RuntimeError):
solver.mkTerm(kinds.Distinct, v6)
+ # Test cases that are nary via the API but have arity = 2 internally
+ s_bool = solver.getBooleanSort()
+ t_bool = solver.mkConst(s_boo, "t_bool")
+ solver.mkTerm(kinds.Implies, [t_bool, t_bool, t_bool])
+ solver.mkTerm(kinds.Xor, [t_bool, t_bool, t_bool])
+ solver.mkTerm(solver.mkOp(kinds.Xor), [t_bool, t_bool, t_bool])
+ t_int = solver.mkConst(solver.getIntegerSort(), "t_int")
+ solver.mkTerm(kinds.Division, [t_int, t_int, t_int])
+ solver.mkTerm(solver.mkOp(kinds.Division), [t_int, t_int, t_int])
+ solver.mkTerm(kinds.IntsDivision, [t_int, t_int, t_int])
+ solver.mkTerm(solver.mkOp(kinds.IntsDivision), [t_int, t_int, t_int])
+ solver.mkTerm(kinds.Minus, [t_int, t_int, t_int])
+ solver.mkTerm(solver.mkOp(kinds.Minus), [t_int, t_int, t_int])
+ solver.mkTerm(kinds.Equal, [t_int, t_int, t_int])
+ solver.mkTerm(solver.mkOp(kinds.Equal), [t_int, t_int, t_int])
+ solver.mkTerm(kinds.Lt, [t_int, t_int, t_int])
+ solver.mkTerm(solver.mkOp(kinds.Lt), [t_int, t_int, t_int])
+ solver.mkTerm(kinds.Gt, [t_int, t_int, t_int])
+ solver.mkTerm(solver.mkOp(kinds.Gt), [t_int, t_int, t_int])
+ solver.mkTerm(kinds.Leq, [t_int, t_int, t_int])
+ solver.mkTerm(solver.mkOp(kinds.Leq), [t_int, t_int, t_int])
+ solver.mkTerm(kinds.Geq, [t_int, t_int, t_int])
+ solver.mkTerm(solver.mkOp(kinds.Geq), [t_int, t_int, t_int])
+ t_reg = solver.mkConst(solver.getRegExpSort(), "t_reg")
+ solver.mkTerm(kinds.RegexpDiff, [t_reg, t_reg, t_reg])
+ solver.mkTerm(solver.mkOp(kinds.RegexpDiff), [t_reg, t_reg, t_reg])
+ t_fun = solver.mkConst(solver.mkFunctionSort(
+ [s_bool, s_bool, s_bool], s_bool))
+ solver.mkTerm(kinds.HoApply, [t_fun, t_bool, t_bool, t_bool])
+ solver.mkTerm(solver.mkOp(kinds.HoApply), [t_fun, t_bool, t_bool, t_bool])
def test_mk_term_from_op(solver):
bv32 = solver.mkBitVectorSort(32)