Ejemplo n.º 1
0
vm_obj array_read(vm_obj const &, vm_obj const &, vm_obj const & a, vm_obj const & i) {
    /* TODO(Leo): handle case where n is too big */
    unsigned idx = force_to_unsigned(i);
    lean_vm_check(idx < to_array(a).size());
    parray<vm_obj> const & _a = to_array(a);
    return _a[idx];
}
Ejemplo n.º 2
0
vm_obj array_mk(vm_obj const &, vm_obj const & n, vm_obj const & fn) {
    /* TODO(Leo): handle case where n is too big */
    unsigned _n = force_to_unsigned(n);
    parray<vm_obj> a;
    for (unsigned i = 0; i < _n; ++i) {
        a.push_back(invoke(fn, mk_vm_nat(i)));
    }
    return to_obj(a);
}
Ejemplo n.º 3
0
vm_obj scope_trace(vm_obj const &, vm_obj const & line, vm_obj const & col, vm_obj const & fn) {
    pos_info_provider * pip = get_pos_info_provider();
    if (pip) {
        scope_traces_as_messages traces_as_messages(pip->get_file_name(), pos_info(force_to_unsigned(line), force_to_unsigned(col)));
        return invoke(fn, mk_vm_unit());
    } else {
        return invoke(fn, mk_vm_unit());
    }
}
Ejemplo n.º 4
0
vm_obj tactic_get_subsingleton_info(vm_obj const & fn, vm_obj const & n, vm_obj const & m, vm_obj const & s) {
    TRY;
    type_context ctx = mk_type_context_for(s, m);
    if (is_none(n)) {
        return mk_result(get_subsingleton_info(ctx, to_expr(fn)), s);
    } else {
        return mk_result(get_subsingleton_info(ctx, to_expr(fn), force_to_unsigned(get_some_value(n), 0)), s);
    }
    CATCH;
}
Ejemplo n.º 5
0
vm_obj array_iterate(vm_obj const &, vm_obj const &, vm_obj const & n,
                     vm_obj const & a, vm_obj const & b, vm_obj const & fn) {
    /* TODO(Leo): handle case where n is too big */
    unsigned _n = force_to_unsigned(n);
    parray<vm_obj> const & p = to_array(a);
    vm_obj r = b;
    for (unsigned i = 0; i < _n; i++)
        r = invoke(fn, mk_vm_nat(i), p[i], r);
    return r;
}
Ejemplo n.º 6
0
dsimp_config::dsimp_config(vm_obj const & o) {
    m_md                 = to_transparency_mode(cfield(o, 0));
    m_max_steps          = force_to_unsigned(cfield(o, 1));
    m_canonize_instances = to_bool(cfield(o, 2));
    m_single_pass        = to_bool(cfield(o, 3));
    m_fail_if_unchanged  = to_bool(cfield(o, 4));
    m_eta                = to_bool(cfield(o, 5));
    m_zeta               = to_bool(cfield(o, 6));
    m_beta               = to_bool(cfield(o, 7));
    m_proj               = to_bool(cfield(o, 8));
    m_iota               = to_bool(cfield(o, 9));
    m_unfold_reducible   = to_bool(cfield(o, 10));
    m_memoize            = to_bool(cfield(o, 11));
}
Ejemplo n.º 7
0
vm_obj array_write(vm_obj const &, vm_obj const &, vm_obj const & a, vm_obj const & i, vm_obj const & v) {
    /* TODO(Leo): handle case where n is too big */
    unsigned idx = force_to_unsigned(i);
    parray<vm_obj> const & p = to_array(a);
    lean_vm_check(idx < p.size());
    if (a.raw()->get_rc() == 1) {
        const_cast<parray<vm_obj> &>(p).set(idx, v);
        return a;
    } else {
        parray<vm_obj> new_a = p;
        new_a.set(idx, v);
        return to_obj(new_a);
    }
}
Ejemplo n.º 8
0
vm_obj array_foreach(vm_obj const &, vm_obj const & n, vm_obj const & a, vm_obj const & fn) {
    /* TODO(Leo): handle case where n is too big */
    unsigned _n = force_to_unsigned(n);
    parray<vm_obj> const & p = to_array(a);
    if (a.raw()->get_rc() == 1) {
        parray<vm_obj> & _p = const_cast<parray<vm_obj> &>(p);
        for (unsigned i = 0; i < _n; i++)
            _p.set(i, invoke(fn, mk_vm_nat(i), _p[i]));
        return a;
    } else {
        parray<vm_obj> new_a;
        for (unsigned i = 0; i < _n; i++) {
            new_a.push_back(invoke(fn, mk_vm_nat(i), p[i]));
        }
        return to_obj(new_a);
    }
}
Ejemplo n.º 9
0
vm_obj tactic_get_spec_prefix_size(vm_obj const & fn, vm_obj const & n, vm_obj const & m, vm_obj const & s) {
    TRY;
    type_context ctx = mk_type_context_for(s, m);
    return tactic::mk_success(mk_vm_nat(get_specialization_prefix_size(ctx, to_expr(fn), force_to_unsigned(n, 0))),
                             tactic::to_state(s));
    CATCH;
}
Ejemplo n.º 10
0
vm_obj mk_array(vm_obj const &, vm_obj const & n, vm_obj const & v) {
    /* TODO(Leo): handle case where n is too big */
    unsigned _n = force_to_unsigned(n);
    parray<vm_obj> a(_n, v);
    return to_obj(a);
}