def test_error(self): Yices.reset() # First with no error errcode = Yices.error_code() self.assertEqual(errcode, 0) errep = Yices.error_report() self.assertEqual(errep.code, 0) Yices.clear_error() errstr = Yices.error_string() self.assertEqual(errstr, 'no error') Yices.print_error(1) # Illegal - only scalar or uninterpreted types allowed bool_t = Types.bool_type() self.assertTrue(Types.is_bool(bool_t)) with assertRaisesRegex( self, YicesException, 'The function yices_constant failed because: invalid type in constant creation' ): Terms.constant(bool_t, 0) Yices.clear_error() errpt = Yices.error_report() self.assertEqual(Yices.error_code(), 0) self.assertEqual(Yices.error_code(), errpt.code) errstr = Yices.error_string() self.assertEqual(errstr, 'no error') Yices.print_error(1) Yices.clear_error() self.assertEqual(Yices.error_code(), 0)
def define_type(name, ytype=None): '''Tries to emulate yices type declarations''' if ytype is None: ytyp = Types.new_uninterpreted_type() elif isstr(ytype): ytyp = Types.parse_type(ytype) else: ytyp = ytype Types.set_name(ytyp, name) return ytyp
def setUp(self): # this is required for some strange reason. # seems like yices/__init__.py does not get evaluated Yices.init() self.cfg = Config() self.ctx = Context(self.cfg) self.param = Parameters() self.param.default_params_for_context(self.ctx) global bool_t, int_t, real_t bool_t = Types.bool_type() int_t = Types.int_type() real_t = Types.real_type()
def test_bv_models(self): bv_t = Types.bv_type(3) bv1 = define_const('bv1', bv_t) bv2 = define_const('bv2', bv_t) bv3 = define_const('bv3', bv_t) fmla1 = Terms.parse_term('(= bv1 (bv-add bv2 bv3))') fmla2 = Terms.parse_term('(bv-gt bv2 0b000)') fmla3 = Terms.parse_term('(bv-gt bv3 0b000)') self.ctx.assert_formula(fmla1) self.ctx.assert_formulas([fmla1, fmla2, fmla3]) self.assertEqual(self.ctx.check_context(self.param), Status.SAT) mdl1 = Model.from_context(self.ctx, 1) val1 = mdl1.get_value(bv1) self.assertEqual(val1[0], 0) self.assertEqual(val1[1], 0) self.assertEqual(val1[2], 0) val2 = mdl1.get_value(bv2) self.assertEqual(val2[0], 0) self.assertEqual(val2[1], 0) self.assertEqual(val2[2], 1) val3 = mdl1.get_value(bv3) self.assertEqual(val3[0], 0) self.assertEqual(val3[1], 0) self.assertEqual(val3[2], 1) mdl1.dispose()
def make_formulas(): tau = Types.bv_type(20) x0 = Terms.new_uninterpreted_term(tau, "x") y0 = Terms.new_uninterpreted_term(tau, "y") z0 = Terms.new_uninterpreted_term(tau, "z") f0 = Terms.bveq_atom(Terms.bvmul(x0, y0), Terms.bvconst_integer(20, 12289)) f1 = Terms.bveq_atom(Terms.bvmul(y0, z0), Terms.bvconst_integer(20, 20031)) f2 = Terms.bveq_atom(Terms.bvmul(x0, z0), Terms.bvconst_integer(20, 10227)) return [f0, f1, f2]
def test_context(self): cfg = Config() ctx = Context(cfg) stat = ctx.status() ret = ctx.push() ret = ctx.pop() ctx.reset_context() ret = ctx.enable_option("arith-elim") ret = ctx.disable_option("arith-elim") stat = ctx.status() self.assertEqual(stat, 0) ctx.reset_context() bool_t = Types.bool_type() bvar1 = Terms.new_variable(bool_t) with assertRaisesRegex(self, YicesException, 'assertion contains a free variable'): ctx.assert_formula(bvar1) bv_t = Types.bv_type(3) bvvar1 = Terms.new_uninterpreted_term(bv_t, 'x') bvvar2 = Terms.new_uninterpreted_term(bv_t, 'y') bvvar3 = Terms.new_uninterpreted_term(bv_t, 'z') fmla1 = Terms.parse_term('(= x (bv-add y z))') fmla2 = Terms.parse_term('(bv-gt y 0b000)') fmla3 = Terms.parse_term('(bv-gt z 0b000)') ctx.assert_formula(fmla1) ctx.assert_formulas([fmla1, fmla2, fmla3]) smt_stat = ctx.check_context(None) self.assertEqual(smt_stat, Status.SAT) ctx.assert_blocking_clause() ctx.stop_search() param = Parameters() param.default_params_for_context(ctx) param.set_param("dyn-ack", "true") with assertRaisesRegex(self, YicesException, 'invalid parameter'): param.set_param("foo", "bar") with assertRaisesRegex(self, YicesException, 'value not valid for parameter'): param.set_param("dyn-ack", "bar") param.dispose() ctx.dispose()
def test_function_models(self): funtype = Types.new_function_type([int_t, bool_t, real_t], real_t) ftystr = Types.to_string(funtype, 100, 80, 0) Types.print_to_fd(1, funtype, 100, 80, 0) self.assertEqual(ftystr, '(-> int bool real real)') fun1 = define_const('fun1', funtype) b1 = define_const('b1', bool_t) i1 = define_const('i1', int_t) r1 = define_const('r1', real_t) assert_formula( '(> (fun1 i1 b1 r1) (fun1 (+ i1 1) (not b1) (- r1 i1)))', self.ctx) self.assertEqual(self.ctx.check_context(self.param), Status.SAT) mdl = Model.from_context(self.ctx, 1) mdlstr = mdl.to_string(80, 100, 0) self.assertEqual( mdlstr, '(= b1 false)\n(= i1 1463)\n(= r1 -579)\n(function fun1\n (type (-> int bool real real))\n (= (fun1 1463 false -579) 1)\n (= (fun1 1464 true -2042) 0)\n (default 2))' ) fun1val = mdl.get_value(fun1) self.assertEqual(fun1val((1463, False, -579)), 1) self.assertEqual(fun1val((1464, True, -2042)), 0) self.assertEqual(fun1val((1462, True, -2041)), 2)
def test_model_from_map(self): bv_t = Types.bv_type(8) i1 = define_const('i1', int_t) r1 = define_const('r1', real_t) bv1 = define_const('bv1', bv_t) iconst1 = Terms.integer(42) rconst1 = Terms.rational(13, 131) bvconst1 = Terms.bvconst_integer(8, 134) mapping = {i1: iconst1, r1: rconst1, bv1: bvconst1} mdl = Model.from_map(mapping) mdlstr = mdl.to_string(80, 100, 0) self.assertEqual(mdlstr, '(= i1 42)\n(= r1 13/131)\n(= bv1 0b10000110)') mdl.dispose()
def test_tuple_models(self): tup_t = Types.new_tuple_type([bool_t, real_t, int_t]) t1 = define_const('t1', tup_t) assert_formula( '(ite (select t1 1) (< (select t1 2) (select t1 3)) (> (select t1 2) (select t1 3)))', self.ctx) self.assertEqual(self.ctx.check_context(self.param), Status.SAT) mdl = Model.from_context(self.ctx, 1) mdlstr = mdl.to_string(80, 100, 0) self.assertEqual(mdlstr, '(= t1 (mk-tuple false 1 0))') val = mdl.get_value(t1) self.assertEqual(val[0], False) self.assertEqual(val[1], 1) self.assertEqual(val[2], 0)
def define_const(name, ytype, defn=None): '''Tries to emulate yices define_term (see eval_define_term in yices2/src/parser_utils/term_stack2) ''' if defn is None: term = Terms.new_uninterpreted_term(ytype) Terms.set_name(term, name) return term # Have a defn if isstr(defn): term = Terms.parse_term(defn) else: term = defn term_type = Terms.type_of_term(term) if not Types.is_subtype(term_type, ytype): raise YicesException(msg='incompatible sort in definition') Terms.set_name(term, name) return term
def test_scalar_models(self): scalar_t = Types.new_scalar_type(10) sc1 = define_const('sc1', scalar_t) sc2 = define_const('sc2', scalar_t) sc3 = define_const('sc3', scalar_t) assert_formula('(/= sc1 sc2)', self.ctx) assert_formula('(/= sc1 sc3)', self.ctx) self.assertEqual(self.ctx.check_context(self.param), Status.SAT) mdl = Model.from_context(self.ctx, 1) val1 = mdl.get_scalar_value(sc1) val2 = mdl.get_scalar_value(sc2) val3 = mdl.get_scalar_value(sc3) self.assertEqual(val1, 9) self.assertEqual(val2, 8) self.assertEqual(val3, 8) self.assertEqual(Terms.is_scalar(sc1), True) sc1val = mdl.get_value_as_term(sc1) self.assertEqual(Terms.is_scalar(sc1val), True) self.assertEqual(mdl.get_value(sc1), sc1val)
def test_timeout(self): cfg = Config() cfg.default_config_for_logic('QF_NIA') ctx = Context(cfg) int_t = Types.int_type() [x, y, z] = [ Terms.new_uninterpreted_term(int_t, id) for id in ['x', 'y', 'z'] ] # x, y, z > 0 for var in [x, y, z]: ctx.assert_formula(Terms.arith_gt0_atom(var)) # x^3 + y^3 = z3 [x3, y3, z3] = [Terms.product([var, var, var]) for var in [x, y, z]] lhs = Terms.sum([x3, y3]) eq = Terms.arith_eq_atom(lhs, z3) ctx.assert_formula(eq) status = ctx.check_context(timeout=1) self.assertEqual(status, Status.INTERRUPTED) ctx.dispose() cfg.dispose()
from yices.Types import Types from yices.Terms import Terms from yices.Config import Config from yices.Context import Context from yices.Status import Status from yices.Model import Model from yices.Yices import Yices int_t = Types.int_type() #seems logical to make the terms in a grid. X = [None] * 9 for i in range(9): X[i] = [None] * 9 for j in range(9): X[i][j] = Terms.new_uninterpreted_term(int_t) #not real happy about the indexing going from 0 to 8, but #isolating access via V could make it easier to go from 1 to 9 def V(vi, vj): return X[vi][vj]
def test_terms(self): self.assertTrue(Yices.is_inited()) true_ = Terms.true() false_ = Terms.false() bool_t = Types.bool_type() int_t = Types.int_type() unint_t = Types.new_uninterpreted_type() self.assertNotEqual(true_, false_) const1 = Terms.constant(unint_t, 0) const2 = Terms.new_uninterpreted_term(unint_t) bconst1 = Terms.new_uninterpreted_term(bool_t) iconst1 = Terms.new_uninterpreted_term(int_t) var1 = Terms.new_variable(unint_t) bvar1 = Terms.new_variable(bool_t) ivar1 = Terms.new_variable(int_t) ivar2 = Terms.new_variable(int_t) ivar3 = Terms.new_variable(int_t) ivar4 = Terms.new_variable(int_t) zero = Terms.zero() int1 = Terms.integer(13) int2 = Terms.integer(17) self.assertEqual(zero, Terms.integer(0)) fun1_t = Types.new_function_type([int_t], bool_t) fun1 = Terms.new_variable(fun1_t) app1 = Terms.application(fun1, [int1]) fun2_t = Types.new_function_type([int_t, int_t], bool_t) fun2 = Terms.new_variable(fun2_t) app2 = Terms.application(fun2, [int1, int1]) fun3_t = Types.new_function_type([int_t, int_t, int_t], bool_t) fun3 = Terms.new_variable(fun3_t) app3 = Terms.application(fun3, [int1, int1, int1]) tup3_t = Types.new_tuple_type([bool_t, int_t, unint_t]) tupconst1 = Terms.new_variable(tup3_t) fun4_t = Types.new_function_type([int_t, int_t, int_t, int_t], bool_t) fun4 = Terms.new_variable(fun4_t) app4 = Terms.application(fun4, [int1, int2, iconst1, ivar1]) ite1 = Terms.ite(bconst1, int1, int2) eq1 = Terms.eq(int1, int1) neq1 = Terms.neq(int1, int1) not1 = Terms.ynot(false_) or1 = Terms.yor([false_, eq1, neq1, app4, false_]) and1 = Terms.yand([false_, eq1, neq1, app4, false_]) xor1 = Terms.xor([false_, eq1, neq1, app4, false_]) or2 = Terms.yor([or1, and1]) and2 = Terms.yand([or1, and1]) xor2 = Terms.xor([or1, and1]) or3 = Terms.yor([or1, and1, or2]) and3 = Terms.yand([or1, and1, and2]) xor3 = Terms.xor([or1, and1, xor2]) iff1 = Terms.iff(and1, or1) implies1 = Terms.implies(and1, or1) tup1 = Terms.tuple([int1, int2, iconst1, ivar1]) pair1 = Terms.tuple([eq1, xor2]) triple1 = Terms.tuple([ite1, fun4, or3]) select1 = Terms.select(2, tup1) select2 = Terms.select(2, tupconst1) tupup1 = Terms.tuple_update(tup1, 2, int2) update1 = Terms.update(fun1, [int1], false_) update2 = Terms.update(fun2, [int1, int1], false_) update3 = Terms.update(fun3, [int1, int1, int1], false_) update4 = Terms.update(fun4, [int1, int2, iconst1, ivar1], false_) distinct1 = Terms.distinct([int1, int2, iconst1, ivar1]) var2 = Terms.new_variable(unint_t) vareq = Terms.eq(var1, var2) forall1 = Terms.forall([var1, var2], vareq) exists1 = Terms.exists([var1, var2], vareq) lambda1 = Terms.ylambda([var1, var2], vareq) zero = Terms.zero() int64_1 = Terms.integer(42) rat32_1 = Terms.rational(13, 7) rat64_1 = Terms.rational(-47, 111) rat1 = Terms.parse_rational('-3/117') float1 = Terms.parse_float('-3.117e-2') add1 = Terms.add(int1, int1) sub1 = Terms.sub(int1, zero) neg1 = Terms.neg(int1) self.assertEqual(Terms.neg(zero), zero) self.assertNotEqual(neg1, int1) mul1 = Terms.mul(int1, int1) square1 = Terms.square(int1) self.assertEqual(mul1, square1) power1 = Terms.power(int1, 4) sum1 = Terms.sum([int1, int2, iconst1, ivar1]) product1 = Terms.product([int1, int2, iconst1, ivar1]) product2 = Terms.product([ivar1, ivar2, ivar3, ivar4]) div1 = Terms.division(int1, int1) idiv1 = Terms.idiv(int1, int1) imod1 = Terms.imod(int1, int1) divatom1 = Terms.divides_atom(int1, int1) intatom1 = Terms.is_int_atom(int1) abs1 = Terms.abs(neg1) self.assertEqual(abs1, int1) floor1 = Terms.floor(rat1) ceil1 = Terms.ceil(rat1) areqatom1 = Terms.arith_eq_atom(int1, zero) arneqatom1 = Terms.arith_neq_atom(int1, zero) argeqatom1 = Terms.arith_geq_atom(int1, zero) arleqatom1 = Terms.arith_leq_atom(int1, zero) argtatom1 = Terms.arith_gt_atom(int1, zero) arltatom1 = Terms.arith_lt_atom(int1, zero) areq0atom1 = Terms.arith_eq0_atom(int1) arneq0atom1 = Terms.arith_neq0_atom(int1) argeq0atom1 = Terms.arith_geq0_atom(int1) arleq0atom1 = Terms.arith_leq0_atom(int1) argt0atom1 = Terms.arith_gt0_atom(int1) arlt0atom1 = Terms.arith_lt0_atom(int1) bv_t = Types.bv_type(8) bvconstu32_1 = Terms.bvconst_integer(8, 42) bvconstu64_1 = Terms.bvconst_integer(8, 42) bvconst32_1 = Terms.bvconst_integer(8, 42) bvconst64_1 = Terms.bvconst_integer(8, 42) bvconstzero_1 = Terms.bvconst_zero(16) bvconstone_1 = Terms.bvconst_one(16) bvconstminusone_1 = Terms.bvconst_minus_one(32) bvvar1 = Terms.new_variable(bv_t) bvvar2 = Terms.new_variable(bv_t) bvvar3 = Terms.new_variable(bv_t) bvvar4 = Terms.new_variable(bv_t) bvbin1 = Terms.parse_bvbin('100101') bvhex1 = Terms.parse_bvhex('f0a1b3') bvadd1 = Terms.bvadd(bvbin1, bvbin1) bvsub1 = Terms.bvsub(bvbin1, bvbin1) bvneg1 = Terms.bvneg(bvbin1) bvmul1 = Terms.bvmul(bvbin1, bvbin1) bvsquare1 = Terms.bvsquare(bvbin1) bvpower1 = Terms.bvpower(bvbin1, 3) bvdiv1 = Terms.bvdiv(bvbin1, bvbin1) bvrem1 = Terms.bvrem(bvbin1, bvbin1) bvsdiv1 = Terms.bvsdiv(bvbin1, bvbin1) bvsrem1 = Terms.bvsrem(bvbin1, bvbin1) bvsmod1 = Terms.bvsmod(bvbin1, bvbin1) bvnot1 = Terms.bvnot(bvbin1) bvnand1 = Terms.bvnand(bvbin1, bvbin1) bvnor1 = Terms.bvnor(bvbin1, bvbin1) bvxnor1 = Terms.bvxnor(bvbin1, bvbin1) bvshl1 = Terms.bvshl(bvbin1, bvbin1) bvlshr1 = Terms.bvlshr(bvbin1, bvbin1) bvashr1 = Terms.bvashr(bvbin1, bvbin1) bvand1 = Terms.bvand([bvbin1, bvbin1, bvbin1, bvbin1]) bvor1 = Terms.bvor([bvbin1, bvbin1, bvbin1, bvbin1]) bvand2_1 = Terms.bvand([bvbin1, bvbin1]) bvor2_1 = Terms.bvor([bvbin1, bvbin1]) bvxor2_1 = Terms.bvxor([bvbin1, bvbin1]) bvand3_1 = Terms.bvand([bvbin1, bvbin1, bvbin1]) bvor3_1 = Terms.bvor([bvbin1, bvbin1, bvbin1]) bvxor3_1 = Terms.bvxor([bvbin1, bvbin1, bvbin1]) bvsum1 = Terms.bvsum([bvbin1, bvbin1, bvbin1, bvbin1]) bvsum2 = Terms.bvsum([bvvar1, bvvar2, bvvar3, bvvar4]) bvproduct1 = Terms.bvproduct([bvbin1, bvbin1, bvbin1, bvbin1]) shleft0_1 = Terms.shift_left0(bvbin1, 5) shleft1_1 = Terms.shift_left1(bvbin1, 4) shright0_1 = Terms.shift_right0(bvbin1, 3) shright1_1 = Terms.shift_right1(bvbin1, 2) ashright_1 = Terms.ashift_right(bvbin1, 1) rotleft_1 = Terms.rotate_left(bvbin1, 6) rotright_1 = Terms.rotate_right(bvbin1, 5) bvextract1 = Terms.bvextract(bvbin1, 2, 4) bvconcat2_1 = Terms.bvconcat([bvbin1, bvbin1]) bvconcat_1 = Terms.bvconcat([bvbin1, bvbin1, bvbin1, bvbin1]) bvrepeat1 = Terms.bvrepeat(bvbin1, 8) signext1 = Terms.sign_extend(bvbin1, 3) zeroext1 = Terms.zero_extend(bvbin1, 4) redand1 = Terms.redand(bvbin1) redor1 = Terms.redor(bvbin1) redcomp1 = Terms.redcomp(bvbin1, bvbin1) bvarray1 = Terms.bvarray([true_, false_, true_, false_]) bitextract1 = Terms.bitextract(bvbin1, 3) bveqatom1 = Terms.bveq_atom(bvbin1, bvbin1) bvneqatom1 = Terms.bvneq_atom(bvbin1, bvbin1) bvgeatom1 = Terms.bvge_atom(bvbin1, bvbin1) bvgtatom1 = Terms.bvgt_atom(bvbin1, bvbin1) bvleatom1 = Terms.bvle_atom(bvbin1, bvbin1) bvltatom1 = Terms.bvlt_atom(bvbin1, bvbin1) bvsgeatom1 = Terms.bvsge_atom(bvbin1, bvbin1) bvsgtatom1 = Terms.bvsgt_atom(bvbin1, bvbin1) bvsleatom1 = Terms.bvsle_atom(bvbin1, bvbin1) bvsltatom1 = Terms.bvslt_atom(bvbin1, bvbin1) ptype1 = Types.parse_type('int') self.assertEqual(ptype1, Types.int_type()) pterm1 = Terms.parse_term('42') self.assertEqual(pterm1, Terms.integer(42)) subst1 = Terms.subst( [Terms.new_variable(ptype1), Terms.new_variable(ptype1)], [Terms.integer(2), Terms.integer(3)], Terms.integer(42)) substarr1 = Terms.substs( [Terms.new_variable(ptype1), Terms.new_variable(ptype1)], [Terms.integer(2), Terms.integer(3)], [Terms.integer(2), Terms.integer(3), Terms.integer(7)]) settypename1 = Types.set_name(ptype1, 'I') self.assertTrue(settypename1) settermname1 = Terms.set_name(pterm1, 'answer') self.assertTrue(settermname1) gettype1 = Types.get_by_name('I') self.assertEqual(gettype1, ptype1) getterm1 = Terms.get_by_name('answer') self.assertEqual(getterm1, pterm1) gettypename1 = Types.get_name(ptype1) self.assertEqual(gettypename1, 'I') gettermname1 = Terms.get_name(pterm1) self.assertEqual(gettermname1, 'answer') Types.remove_name('I') Terms.remove_name('answer') Types.clear_name(ptype1) Terms.clear_name(pterm1) typeofterm1 = Terms.type_of_term(pterm1) self.assertEqual(typeofterm1, Types.int_type()) self.assertEqual(Terms.is_bool(false_), 1) self.assertEqual(Terms.is_bool(pterm1), 0) self.assertEqual(Terms.is_int(false_), 0) self.assertEqual(Terms.is_int(pterm1), 1) self.assertEqual(Terms.is_real(false_), 0) self.assertEqual(Terms.is_real(pterm1), 0) self.assertEqual(Terms.is_arithmetic(false_), 0) self.assertEqual(Terms.is_arithmetic(pterm1), 1) self.assertEqual(Terms.is_bitvector(false_), 0) self.assertEqual(Terms.is_bitvector(bvbin1), 1) self.assertEqual(Terms.is_tuple(false_), 0) self.assertEqual(Terms.is_tuple(tup1), 1) self.assertEqual(Terms.is_function(false_), 0) self.assertEqual(Terms.is_function(fun1), 1) self.assertEqual(Terms.is_scalar(false_), 0) self.assertEqual(Terms.is_scalar(fun1), 0) self.assertEqual(Terms.bitsize(bvbin1), 6) self.assertEqual(Terms.is_ground(false_), 1) self.assertEqual(Terms.is_ground(var1), 0) self.assertEqual(Terms.is_atomic(false_), 1) # or1 is atomic because it simplifies to true self.assertEqual(Terms.is_atomic(or1), 1) self.assertEqual(Terms.is_composite(false_), 0) self.assertEqual(Terms.is_composite(ite1), 1) self.assertEqual(Terms.is_composite(tup1), 1) self.assertEqual(Terms.is_projection(false_), 0) # Select1 simplifies self.assertEqual(Terms.is_projection(select1), 0) self.assertEqual(Terms.is_projection(select2), 1) self.assertEqual(Terms.is_sum(ite1), 0) self.assertEqual(Terms.is_sum(sum1), 1) self.assertEqual(Terms.is_bvsum(select1), 0) # bvsum1 simplifies since the terms are all numbers self.assertEqual(Terms.is_bvsum(bvsum1), 0) self.assertEqual(Terms.is_bvsum(bvsum2), 1) self.assertEqual(Terms.is_product(ite1), 0) self.assertEqual(Terms.is_product(product1), 0) self.assertEqual(Terms.is_product(product2), 1) self.assertEqual(Terms.constructor(true_), 0) self.assertEqual(Terms.constructor(int1), 1) self.assertEqual(Terms.constructor(bvconst32_1), 2) self.assertEqual(Terms.num_children(bvconst32_1), 0) self.assertEqual(Terms.num_children(select2), 1) self.assertEqual(Terms.num_children(tup1), 4) self.assertEqual(Terms.child(tup1, 2), iconst1) projarg1 = Terms.proj_arg(select2) self.assertEqual(Terms.proj_index(select2), 2) self.assertEqual(Terms.proj_arg(select2), tupconst1)
def test_types(self): bool_t = Types.bool_type() int_t = Types.int_type() self.assertNotEqual(bool_t, int_t) real_t = Types.real_type() self.assertNotEqual(real_t, bool_t) self.assertNotEqual(real_t, int_t) bv_t = Types.bv_type(8) scal_t = Types.new_scalar_type(12) unint_t = Types.new_uninterpreted_type() tup1_t = Types.new_tuple_type([bool_t]) tup2_t = Types.new_tuple_type([int_t, real_t]) tup3_t = Types.new_tuple_type([bv_t, scal_t, unint_t]) tup4_t = Types.new_tuple_type([bool_t, tup1_t, tup2_t, tup3_t]) fun1_t = Types.new_function_type([int_t], bool_t) fun2_t = Types.new_function_type([real_t, bv_t], scal_t) fun3_t = Types.new_function_type([tup1_t, tup2_t, tup3_t], fun1_t) fun4_t = Types.new_function_type([bool_t, tup1_t, tup2_t, tup3_t], fun3_t) self.assertTrue(Types.is_bool(bool_t)) self.assertFalse(Types.is_bool(int_t)) self.assertTrue(Types.is_int(int_t)) self.assertTrue(Types.is_real(real_t)) self.assertTrue(Types.is_arithmetic(real_t)) self.assertTrue(Types.is_bitvector(bv_t)) self.assertTrue(Types.is_tuple(tup1_t)) self.assertTrue(Types.is_function(fun4_t)) self.assertTrue(Types.is_scalar(scal_t)) self.assertTrue(Types.is_uninterpreted(unint_t)) self.assertTrue(Types.is_subtype(int_t, real_t)) self.assertFalse(Types.is_subtype(real_t, int_t)) self.assertEqual(Types.bvtype_size(bv_t), 8) self.assertEqual(Types.scalar_type_card(scal_t), 12) self.assertEqual(Types.num_children(tup3_t), 3) self.assertEqual(Types.child(tup3_t, 1), scal_t) type_v = Types.children(tup4_t) self.assertEqual(len(type_v), 4) self.assertEqual(type_v[0], bool_t) self.assertEqual(type_v[1], tup1_t) self.assertEqual(type_v[2], tup2_t) self.assertEqual(type_v[3], tup3_t)