static bool is_num(expr const & e, bool first) { buffer<expr> args; expr const & f = get_app_args(e, args); if (!is_constant(f)) return false; if (const_name(f) == get_has_one_one_name()) return args.size() == 2; else if (const_name(f) == get_has_zero_zero_name()) return first && args.size() == 2; else if (const_name(f) == get_nat_zero_name()) return first && args.size() == 0; else if (const_name(f) == get_bit0_name()) return args.size() == 3 && is_num(args[2], false); else if (const_name(f) == get_bit1_name()) return args.size() == 4 && is_num(args[3], false); return false; }
bool is_zero(expr const & e) { return is_const_app(e, get_has_zero_zero_name(), 2) || is_constant(e, get_nat_zero_name()); }
optional<expr> mk_hset_instance(type_checker & tc, io_state const & ios, list<expr> const & ctx, expr const & type) { expr trunc_index = mk_app(mk_constant(get_is_trunc_trunc_index_of_nat_name()), mk_constant(get_nat_zero_name())); level lvl = sort_level(tc.ensure_type(type).first); expr is_hset = mk_app(mk_constant(get_is_trunc_name(), {lvl}), trunc_index, type); return mk_class_instance(tc.env(), ios, ctx, tc.mk_fresh_name(), is_hset); }