chore(*): type_context ==> type_context_old
This commit is contained in:
parent
f873def910
commit
bdea7d420d
151 changed files with 1343 additions and 1343 deletions
|
|
@ -222,7 +222,7 @@ environment reduce_cmd(parser & p) {
|
|||
expr e; level_param_names ls;
|
||||
std::tie(e, ls) = parse_local_expr(p, "_reduce");
|
||||
expr r;
|
||||
type_context ctx(p.env(), p.get_options(), metavar_context(), local_context(), transparency_mode::All);
|
||||
type_context_old ctx(p.env(), p.get_options(), metavar_context(), local_context(), transparency_mode::All);
|
||||
if (whnf) {
|
||||
r = ctx.whnf(e);
|
||||
} else {
|
||||
|
|
@ -391,7 +391,7 @@ static environment init_quotient_cmd(parser & p) {
|
|||
|
||||
/*
|
||||
Temporary procedure that converts metavariables in \c e to metavar_context metavariables.
|
||||
After we convert the frontend to type_context, we will not need to use this procedure.
|
||||
After we convert the frontend to type_context_old, we will not need to use this procedure.
|
||||
*/
|
||||
static expr convert_metavars(metavar_context & mctx, expr const & e) {
|
||||
expr_map<expr> cache;
|
||||
|
|
@ -427,7 +427,7 @@ static environment unify_cmd(parser & p) {
|
|||
e2 = convert_metavars(mctx, e2);
|
||||
auto rep = p.mk_message(p.cmd_pos(), p.pos(), INFORMATION);
|
||||
rep << e1 << " =?= " << e2 << "\n";
|
||||
type_context ctx(env, p.get_options(), mctx, lctx, transparency_mode::Semireducible);
|
||||
type_context_old ctx(env, p.get_options(), mctx, lctx, transparency_mode::Semireducible);
|
||||
bool success = ctx.is_def_eq(e1, e2);
|
||||
if (success)
|
||||
rep << ctx.instantiate_mvars(e1) << " =?= " << ctx.instantiate_mvars(e2) << "\n";
|
||||
|
|
@ -453,7 +453,7 @@ static environment eval_cmd(parser & p) {
|
|||
if (has_synthetic_sorry(e))
|
||||
return p.env();
|
||||
|
||||
type_context tc(p.env(), transparency_mode::All);
|
||||
type_context_old tc(p.env(), transparency_mode::All);
|
||||
auto type = tc.infer(e);
|
||||
bool has_repr_inst = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -356,8 +356,8 @@ static void get_args_for_instantiating_lemma(unsigned arity,
|
|||
Then, copy the equation lemmas from d._main to d.
|
||||
*/
|
||||
static environment copy_equation_lemmas(environment const & env, buffer<name> const & d_names) {
|
||||
type_context ctx(env, transparency_mode::All);
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old ctx(env, transparency_mode::All);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
level_param_names lps;
|
||||
levels ls;
|
||||
buffer<expr> vals;
|
||||
|
|
@ -643,7 +643,7 @@ static expr elaborate_proof(
|
|||
bool is_rfl_lemma, expr const & final_type,
|
||||
metavar_context const & mctx, local_context const & lctx,
|
||||
parser_pos_provider pos_provider, bool use_info_manager, std::string const & file_name) {
|
||||
auto tc = std::make_shared<type_context>(decl_env, opts, mctx, lctx);
|
||||
auto tc = std::make_shared<type_context_old>(decl_env, opts, mctx, lctx);
|
||||
scope_trace_env scope2(decl_env, opts, *tc);
|
||||
scope_traces_as_messages scope2a(file_name, header_pos);
|
||||
scope_pos_info_provider scope3(pos_provider);
|
||||
|
|
@ -681,7 +681,7 @@ static void check_example(environment const & decl_env, options const & opts,
|
|||
expr const & fn, expr const & val0,
|
||||
metavar_context const & mctx, local_context const & lctx,
|
||||
parser_pos_provider pos_provider, bool use_info_manager, std::string const & file_name) {
|
||||
auto tc = std::make_shared<type_context>(decl_env, opts, mctx, lctx);
|
||||
auto tc = std::make_shared<type_context_old>(decl_env, opts, mctx, lctx);
|
||||
scope_trace_env scope2(decl_env, opts, *tc);
|
||||
scope_traces_as_messages scope2a(file_name, pos_provider.get_some_pos());
|
||||
scope_pos_info_provider scope3(pos_provider);
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ bool elaborator::try_report(std::exception const & ex, optional<expr> const & re
|
|||
auto pip = get_pos_info_provider();
|
||||
if (!pip) return false;
|
||||
|
||||
auto tc = std::make_shared<type_context>(m_env, m_opts, m_ctx.mctx(), m_ctx.lctx());
|
||||
auto tc = std::make_shared<type_context_old>(m_env, m_opts, m_ctx.mctx(), m_ctx.lctx());
|
||||
message_builder out(tc, m_env, get_global_ios(), pip->get_file_name(),
|
||||
ref ? pip->get_pos_info_or_some(*ref) : pip->get_some_pos(), ERROR);
|
||||
out.set_exception(ex);
|
||||
|
|
@ -441,7 +441,7 @@ auto elaborator::use_elim_elab_core(name const & fn) -> optional<elim_info> {
|
|||
if (is_basic_aux_recursor(m_env, fn) || inductive::is_elim_rule(m_env, fn)) {
|
||||
return optional<elim_info>(get_elim_info_for_builtin(fn));
|
||||
}
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
declaration d = m_env.get(fn);
|
||||
expr type = d.get_type();
|
||||
while (is_pi(type)) {
|
||||
|
|
@ -703,7 +703,7 @@ optional<expr> elaborator::mk_coercion(expr const & e, expr e_type, expr type, e
|
|||
}
|
||||
|
||||
bool elaborator::is_def_eq(expr const & e1, expr const & e2) {
|
||||
type_context::approximate_scope scope(m_ctx);
|
||||
type_context_old::approximate_scope scope(m_ctx);
|
||||
try {
|
||||
return m_ctx.is_def_eq(e1, e2);
|
||||
} catch (exception &) {
|
||||
|
|
@ -1585,7 +1585,7 @@ expr elaborator::visit_base_app_core(expr const & fn, arg_mask amask, buffer<exp
|
|||
(max 1 ?m) =?= ?m
|
||||
(max ?m1 1) =?= (max 1 ?m2)
|
||||
|
||||
The first one cannot be solved by type_context, and an approximate
|
||||
The first one cannot be solved by type_context_old, and an approximate
|
||||
solution is used for the second one. In the second pass, we will have
|
||||
additional information propagated from the expected_type, and these
|
||||
constraints may become trivial.
|
||||
|
|
@ -1608,11 +1608,11 @@ expr elaborator::visit_base_app_core(expr const & fn, arg_mask amask, buffer<exp
|
|||
|
||||
1 =?= (max 1 ?u)
|
||||
|
||||
which, as described above, cannot be solved by type_context.
|
||||
which, as described above, cannot be solved by type_context_old.
|
||||
However, this constraint becomes trivial after we propagate the expected type
|
||||
(list name), and we have to solve (list name) =?= (list ?m)
|
||||
*/
|
||||
type_context::full_postponed_scope scope(m_ctx, false);
|
||||
type_context_old::full_postponed_scope scope(m_ctx, false);
|
||||
flet<bool> dont_recover(m_recover_from_errors, false);
|
||||
first_pass(fn, args, *expected_type, ref, info);
|
||||
} catch (elaborator_exception & ex1) {
|
||||
|
|
@ -2127,7 +2127,7 @@ static expr instantiate_rev_locals(expr const & a, unsigned n, expr const * subs
|
|||
return replace(a, fn);
|
||||
}
|
||||
|
||||
static expr instantiate_rev_locals(expr const & e, type_context::tmp_locals const & locals) {
|
||||
static expr instantiate_rev_locals(expr const & e, type_context_old::tmp_locals const & locals) {
|
||||
return instantiate_rev_locals(e, locals.as_buffer().size(), locals.as_buffer().data());
|
||||
}
|
||||
|
||||
|
|
@ -2178,7 +2178,7 @@ expr elaborator::visit_convoy(expr const & e, optional<expr> const & expected_ty
|
|||
}
|
||||
} else {
|
||||
// User provided some typing information for the match
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr it = fn_type;
|
||||
for (unsigned i = 0; i < args.size(); i++) {
|
||||
if (!is_pi(it))
|
||||
|
|
@ -2310,7 +2310,7 @@ expr elaborator::mk_aux_meta_def(expr const & e, expr const & ref) {
|
|||
return new_c;
|
||||
}
|
||||
|
||||
static void mvar_dep_sort_aux(type_context & ctx, expr const & m,
|
||||
static void mvar_dep_sort_aux(type_context_old & ctx, expr const & m,
|
||||
name_set const & mvar_names, name_set & visited, buffer<expr> & result) {
|
||||
if (visited.contains(mlocal_name(m)))
|
||||
return;
|
||||
|
|
@ -2329,7 +2329,7 @@ static void mvar_dep_sort_aux(type_context & ctx, expr const & m,
|
|||
}
|
||||
|
||||
/* Topological sort based on dependencies. */
|
||||
static void mvar_dep_sort(type_context & ctx, buffer<expr> & mvars) {
|
||||
static void mvar_dep_sort(type_context_old & ctx, buffer<expr> & mvars) {
|
||||
name_set visited;
|
||||
buffer<expr> result;
|
||||
name_set mvar_names;
|
||||
|
|
@ -2359,7 +2359,7 @@ class validate_and_collect_lhs_mvars : public replace_visitor {
|
|||
buffer<expr> & m_unassigned_mvars;
|
||||
name_set m_collected;
|
||||
|
||||
type_context & ctx() { return m_elab.m_ctx; }
|
||||
type_context_old & ctx() { return m_elab.m_ctx; }
|
||||
|
||||
environment const & env() { return m_elab.env(); }
|
||||
|
||||
|
|
@ -2368,7 +2368,7 @@ class validate_and_collect_lhs_mvars : public replace_visitor {
|
|||
of definitions compiled using the equation compiler */
|
||||
{
|
||||
/* Try without use delta reduction */
|
||||
type_context::transparency_scope scope(ctx(), transparency_mode::None);
|
||||
type_context_old::transparency_scope scope(ctx(), transparency_mode::None);
|
||||
expr new_e = ctx().whnf(e);
|
||||
if (new_e != e) return some_expr(new_e);
|
||||
}
|
||||
|
|
@ -2517,7 +2517,7 @@ public:
|
|||
|
||||
/* Similar to instantiate_mvars, but add an inaccessible pattern annotation around metavariables
|
||||
whose value has been fixed by type inference. */
|
||||
static expr instantiate_pattern_mvars(type_context & ctx, expr const & lhs) {
|
||||
static expr instantiate_pattern_mvars(type_context_old & ctx, expr const & lhs) {
|
||||
return replace(lhs, [&](expr const & e, unsigned) {
|
||||
if (is_metavar_decl_ref(e) && ctx.is_assigned(e)) {
|
||||
expr v = ctx.instantiate_mvars(e);
|
||||
|
|
@ -2533,7 +2533,7 @@ static expr instantiate_pattern_mvars(type_context & ctx, expr const & lhs) {
|
|||
|
||||
expr elaborator::visit_equation(expr const & e, unsigned num_fns) {
|
||||
expr const & ref = e;
|
||||
type_context::tmp_locals fns(m_ctx);
|
||||
type_context_old::tmp_locals fns(m_ctx);
|
||||
expr it = e;
|
||||
for (unsigned i = 0; i < num_fns; i++) {
|
||||
if (!is_lambda(it))
|
||||
|
|
@ -2583,7 +2583,7 @@ expr elaborator::visit_equation(expr const & e, unsigned num_fns) {
|
|||
// sort using dependencies
|
||||
mvar_dep_sort(m_ctx, unassigned_mvars);
|
||||
// create local variables for each unassigned metavar
|
||||
type_context::tmp_locals new_locals(m_ctx);
|
||||
type_context_old::tmp_locals new_locals(m_ctx);
|
||||
for (expr & m : unassigned_mvars) {
|
||||
expr type = instantiate_mvars(m_ctx.infer(m));
|
||||
expr new_local = new_locals.push_local(mlocal_pp_name(m), type, binder_info());
|
||||
|
|
@ -2705,7 +2705,7 @@ elaborator::field_resolution elaborator::field_to_decl(expr const & e, expr cons
|
|||
if (is_field_notation(e)) {
|
||||
auto lhs = macro_arg(e, 0);
|
||||
if (is_constant(lhs)) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr t = whnf(s_type);
|
||||
while (is_pi(t)) {
|
||||
t = whnf(instantiate(binding_body(t), locals.push_local_from_binding(t)));
|
||||
|
|
@ -2809,7 +2809,7 @@ expr elaborator::visit_field(expr const & e, optional<expr> const & expected_typ
|
|||
|
||||
class reduce_projections_visitor : public replace_visitor {
|
||||
private:
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
protected:
|
||||
expr visit_app(expr const & e) override {
|
||||
expr e2 = replace_visitor::visit_app(e);
|
||||
|
|
@ -2820,7 +2820,7 @@ protected:
|
|||
return e2;
|
||||
}
|
||||
public:
|
||||
reduce_projections_visitor(type_context & ctx): m_ctx(ctx) {}
|
||||
reduce_projections_visitor(type_context_old & ctx): m_ctx(ctx) {}
|
||||
};
|
||||
|
||||
/* Predicated variant of `lean::instantiate_mvars`. It does not support delayed abstractions or universe mvars. */
|
||||
|
|
@ -2846,7 +2846,7 @@ class visit_structure_instance_fn {
|
|||
elaborator & m_elab;
|
||||
// note: fields needed by trace macros
|
||||
environment & m_env = m_elab.m_env;
|
||||
type_context & m_ctx = m_elab.m_ctx;
|
||||
type_context_old & m_ctx = m_elab.m_ctx;
|
||||
|
||||
// inputs
|
||||
expr m_e, m_ref = m_e;
|
||||
|
|
@ -3362,7 +3362,7 @@ expr elaborator::visit_macro(expr const & e, optional<expr> const & expected_typ
|
|||
|
||||
/* If the instance fingerprint has been set, then make sure `type` is not a local instance.
|
||||
Then, add a new local declaration to locals. */
|
||||
expr elaborator::push_local(type_context::tmp_locals & locals,
|
||||
expr elaborator::push_local(type_context_old::tmp_locals & locals,
|
||||
name const & n, expr const & type, binder_info const & binfo, expr const & /* ref */) {
|
||||
#if 0 // TODO(Leo): the following check is too restrictive
|
||||
if (m_ctx.lctx().get_instance_fingerprint() &&
|
||||
|
|
@ -3374,7 +3374,7 @@ expr elaborator::push_local(type_context::tmp_locals & locals,
|
|||
}
|
||||
|
||||
/* See method above */
|
||||
expr elaborator::push_let(type_context::tmp_locals & locals,
|
||||
expr elaborator::push_let(type_context_old::tmp_locals & locals,
|
||||
name const & n, expr const & type, expr const & value, expr const & /* ref */) {
|
||||
#if 0 // TODO(Leo): the following check is too restrictive
|
||||
if (m_ctx.lctx().get_instance_fingerprint() &&
|
||||
|
|
@ -3386,7 +3386,7 @@ expr elaborator::push_let(type_context::tmp_locals & locals,
|
|||
}
|
||||
|
||||
expr elaborator::visit_lambda(expr const & e, optional<expr> const & expected_type) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr it = e;
|
||||
expr ex;
|
||||
bool has_expected;
|
||||
|
|
@ -3431,7 +3431,7 @@ expr elaborator::visit_lambda(expr const & e, optional<expr> const & expected_ty
|
|||
}
|
||||
|
||||
expr elaborator::visit_pi(expr const & e) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr it = e;
|
||||
expr parent_it = e;
|
||||
while (is_pi(it)) {
|
||||
|
|
@ -3465,7 +3465,7 @@ expr elaborator::visit_let(expr const & e, optional<expr> const & expected_type)
|
|||
new_type = instantiate_mvars(new_type);
|
||||
new_value = instantiate_mvars(new_value);
|
||||
ensure_no_unassigned_metavars(new_value);
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr l = copy_tag(let_type(e), push_let(locals, let_name(e), new_type, new_value, ref));
|
||||
save_identifier_info(l);
|
||||
expr body = instantiate_rev_locals(let_body(e), locals);
|
||||
|
|
@ -3503,7 +3503,7 @@ expr elaborator::visit_have_expr(expr const & e, optional<expr> const & expected
|
|||
new_proof = enforce_type(new_proof, new_type, "invalid have-expression", proof);
|
||||
synthesize();
|
||||
ensure_no_unassigned_metavars(new_proof);
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr ref = binding_domain(lambda);
|
||||
push_local(locals, binding_name(lambda), new_type, binding_info(lambda), ref);
|
||||
expr body = instantiate_rev_locals(binding_body(lambda), locals);
|
||||
|
|
@ -3524,7 +3524,7 @@ expr elaborator::visit_suffices_expr(expr const & e, optional<expr> const & expe
|
|||
expr new_type = visit(type, none_expr());
|
||||
synthesize_no_tactics();
|
||||
{
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr ref = binding_domain(fn);
|
||||
push_local(locals, binding_name(fn), new_type, binding_info(fn), ref);
|
||||
expr body = instantiate_rev_locals(binding_body(fn), locals);
|
||||
|
|
@ -3797,7 +3797,7 @@ void elaborator::synthesize() {
|
|||
|
||||
void elaborator::report_error(tactic_state const & s, char const * state_header,
|
||||
char const * msg, expr const & ref) {
|
||||
auto tc = std::make_shared<type_context>(m_env, m_opts, m_ctx.mctx(), m_ctx.lctx());
|
||||
auto tc = std::make_shared<type_context_old>(m_env, m_opts, m_ctx.mctx(), m_ctx.lctx());
|
||||
auto pip = get_pos_info_provider();
|
||||
if (!pip) return;
|
||||
message_builder out(tc, m_env, get_global_ios(), pip->get_file_name(),
|
||||
|
|
@ -3857,7 +3857,7 @@ void elaborator::snapshot::restore(elaborator & e) {
|
|||
This class also transforms remaining universe metavariables
|
||||
into parameters */
|
||||
struct sanitize_param_names_fn : public replace_visitor {
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
name m_p{"u"};
|
||||
name_set m_L; /* All parameter names in the input expression. */
|
||||
unsigned m_idx{1};
|
||||
|
|
@ -3867,10 +3867,10 @@ struct sanitize_param_names_fn : public replace_visitor {
|
|||
theorem type. */
|
||||
bool m_fixed;
|
||||
|
||||
sanitize_param_names_fn(type_context & ctx, buffer<name> & new_lp_names):
|
||||
sanitize_param_names_fn(type_context_old & ctx, buffer<name> & new_lp_names):
|
||||
m_ctx(ctx), m_new_param_names(new_lp_names), m_fixed(false) {}
|
||||
|
||||
sanitize_param_names_fn(type_context & ctx, elaborator::theorem_finalization_info const & info,
|
||||
sanitize_param_names_fn(type_context_old & ctx, elaborator::theorem_finalization_info const & info,
|
||||
buffer<name> & new_lp_names):
|
||||
m_ctx(ctx), m_L(info.m_L),
|
||||
m_new_param_names(new_lp_names), m_fixed(true) {}
|
||||
|
|
@ -3932,7 +3932,7 @@ struct sanitize_param_names_fn : public replace_visitor {
|
|||
}
|
||||
};
|
||||
|
||||
/** When the output of the elaborator may contain meta-variables, we convert the type_context level meta-variables
|
||||
/** When the output of the elaborator may contain meta-variables, we convert the type_context_old level meta-variables
|
||||
into regular kernel meta-variables. */
|
||||
static expr replace_with_simple_metavars(metavar_context mctx, name_map<expr> & cache, expr const & e) {
|
||||
if (!has_expr_metavar(e)) return e;
|
||||
|
|
@ -4280,7 +4280,7 @@ static vm_obj tactic_save_type_info(vm_obj const &, vm_obj const & _e, vm_obj co
|
|||
auto pos = get_pos_info_provider()->get_pos_info(to_expr(ref));
|
||||
if (!pos) return tactic::mk_success(s);
|
||||
tactic_state_context_cache cache(s);
|
||||
type_context ctx = cache.mk_type_context();
|
||||
type_context_old ctx = cache.mk_type_context();
|
||||
try {
|
||||
expr type = ctx.infer(e);
|
||||
get_global_info_manager()->add_type_info(*pos, type);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ private:
|
|||
options m_opts;
|
||||
context_cache m_cache;
|
||||
name m_decl_name;
|
||||
type_context m_ctx;
|
||||
type_context_old m_ctx;
|
||||
info_manager m_info;
|
||||
unsigned m_aux_meta_idx = 1;
|
||||
bool m_recover_from_errors;
|
||||
|
|
@ -121,9 +121,9 @@ private:
|
|||
bool is_uvar_assigned(level const & l) const { return m_ctx.is_assigned(l); }
|
||||
bool is_mvar_assigned(expr const & e) const { return m_ctx.is_assigned(e); }
|
||||
|
||||
expr push_local(type_context::tmp_locals & locals, name const & n, expr const & type,
|
||||
expr push_local(type_context_old::tmp_locals & locals, name const & n, expr const & type,
|
||||
binder_info const & binfo, expr const & ref);
|
||||
expr push_let(type_context::tmp_locals & locals,
|
||||
expr push_let(type_context_old::tmp_locals & locals,
|
||||
name const & n, expr const & type, expr const & value, expr const & ref);
|
||||
|
||||
level mk_univ_metavar();
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class inductive_cmd_fn {
|
|||
environment m_env;
|
||||
cmd_meta m_meta_info;
|
||||
buffer<decl_attributes> m_mut_attrs;
|
||||
type_context m_ctx;
|
||||
type_context_old m_ctx;
|
||||
buffer<name> m_lp_names;
|
||||
pos_info m_pos;
|
||||
name_map<implicit_infer_kind> m_implicit_infer_map;
|
||||
|
|
@ -303,7 +303,7 @@ class inductive_cmd_fn {
|
|||
/** \brief Return the universe level of the given type, if it is not a sort, then raise an exception. */
|
||||
level get_datatype_result_level(expr d_type) {
|
||||
d_type = m_ctx.relaxed_whnf(d_type);
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
while (is_pi(d_type)) {
|
||||
d_type = instantiate(binding_body(d_type), locals.push_local_from_binding(d_type));
|
||||
d_type = m_ctx.relaxed_whnf(d_type);
|
||||
|
|
@ -325,7 +325,7 @@ class inductive_cmd_fn {
|
|||
}
|
||||
}
|
||||
|
||||
void unify_nested_occurrences(type_context & ctx, expr const & ir_type, buffer<expr> const & inds, level const & resultant_level) {
|
||||
void unify_nested_occurrences(type_context_old & ctx, expr const & ir_type, buffer<expr> const & inds, level const & resultant_level) {
|
||||
expr ty = ir_type;
|
||||
while (is_pi(ty)) {
|
||||
expr arg_ty = binding_domain(ty);
|
||||
|
|
@ -402,7 +402,7 @@ class inductive_cmd_fn {
|
|||
|
||||
/* Apply beta and zeta reduction */
|
||||
expr normalize(expr const & e) {
|
||||
type_context::transparency_scope scope(m_ctx, transparency_mode::None);
|
||||
type_context_old::transparency_scope scope(m_ctx, transparency_mode::None);
|
||||
return ::lean::normalize(m_ctx, e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public:
|
|||
|
||||
#ifdef LEAN_JSON
|
||||
void hole_info_data::report(io_state_stream const & ios, json & record) const {
|
||||
type_context ctx = mk_type_context_for(m_state);
|
||||
type_context_old ctx = mk_type_context_for(m_state);
|
||||
interactive_report_type(ios.get_environment(), ios.get_options(), ctx.infer(m_state.main()), record);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -172,7 +172,7 @@ void info_manager::add_vm_obj_format_info(pos_info pos, environment const & env,
|
|||
#ifdef LEAN_JSON
|
||||
void info_manager::get_info_record(environment const & env, options const & o, io_state const & ios, pos_info pos,
|
||||
json & record, std::function<bool (info_data const &)> pred) const {
|
||||
type_context tc(env, o);
|
||||
type_context_old tc(env, o);
|
||||
io_state_stream out = regular(env, ios, tc).update_options(o);
|
||||
get_line_info_set(pos.first).for_each([&](unsigned c, list<info_data> const & ds) {
|
||||
if (c == pos.second) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace lean {
|
|||
LEAN_THREAD_VALUE(break_at_pos_exception::token_context, g_context, break_at_pos_exception::token_context::none);
|
||||
|
||||
void interactive_report_type(environment const & env, options const & opts, expr const & e, json & j) {
|
||||
type_context tc(env);
|
||||
type_context_old tc(env);
|
||||
if (g_context == break_at_pos_exception::token_context::interactive_tactic) {
|
||||
vm_state vm(env, options());
|
||||
tactic_state s = mk_tactic_state_for(env, opts, "_interactive_report_type", local_context(), mk_true());
|
||||
|
|
@ -221,7 +221,7 @@ optional<info_data> find_hole(module_info const & m_mod_info,
|
|||
}
|
||||
|
||||
bool execute_hole_command(tactic_state s, name const & cmd_decl_name, expr const & args, json & j) {
|
||||
type_context ctx = mk_type_context_for(s);
|
||||
type_context_old ctx = mk_type_context_for(s);
|
||||
options opts = s.get_options();
|
||||
opts = opts.update_if_undef(get_pp_use_holes_name(), true);
|
||||
s = set_options(s, opts);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ void add_source_info(environment const & env, name const & d, json & record) {
|
|||
|
||||
json serialize_decl(name const & short_name, name const & long_name, environment const & env, options const & o) {
|
||||
declaration const & d = env.get(long_name);
|
||||
type_context tc(env);
|
||||
type_context_old tc(env);
|
||||
auto fmter = mk_pretty_formatter_factory()(env, o, tc);
|
||||
expr type = d.get_type();
|
||||
if (LEAN_COMPLETE_CONSUME_IMPLICIT) {
|
||||
|
|
|
|||
|
|
@ -2327,10 +2327,10 @@ expr parser::parse_expr_with_env(local_environment const & lenv, unsigned rbp) {
|
|||
class lazy_type_context : public abstract_type_context {
|
||||
environment m_env;
|
||||
options m_opts;
|
||||
std::unique_ptr<type_context> m_ctx;
|
||||
type_context & ctx() {
|
||||
std::unique_ptr<type_context_old> m_ctx;
|
||||
type_context_old & ctx() {
|
||||
if (!m_ctx)
|
||||
m_ctx.reset(new type_context(m_env, m_opts));
|
||||
m_ctx.reset(new type_context_old(m_env, m_opts));
|
||||
return *m_ctx;
|
||||
}
|
||||
public:
|
||||
|
|
@ -2609,12 +2609,12 @@ char const * parser::get_file_name() const {
|
|||
}
|
||||
|
||||
message_builder parser::mk_message(pos_info const &p, message_severity severity) const {
|
||||
std::shared_ptr<abstract_type_context> tc = std::make_shared<type_context>(env(), get_options());
|
||||
std::shared_ptr<abstract_type_context> tc = std::make_shared<type_context_old>(env(), get_options());
|
||||
return message_builder(tc, env(), ios(), get_file_name(), p, severity);
|
||||
}
|
||||
|
||||
message_builder parser::mk_message(pos_info const & start_pos, pos_info const & end_pos, message_severity severity) const {
|
||||
std::shared_ptr<abstract_type_context> tc = std::make_shared<type_context>(env(), get_options());
|
||||
std::shared_ptr<abstract_type_context> tc = std::make_shared<type_context_old>(env(), get_options());
|
||||
message_builder b(tc, env(), ios(), get_file_name(), start_pos, severity);
|
||||
b.set_end_pos(end_pos);
|
||||
return b;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static void print_axioms(parser & p, message_builder & out) {
|
|||
if (p.curr_is_identifier()) {
|
||||
name c = p.check_constant_next("invalid '#print axioms', constant expected");
|
||||
auto env = p.env();
|
||||
type_context tc(env, p.get_options());
|
||||
type_context_old tc(env, p.get_options());
|
||||
auto new_out = io_state_stream(env, p.ios(), tc, out.get_text_stream().get_channel());
|
||||
print_axioms_deps(env, new_out)(c);
|
||||
} else {
|
||||
|
|
@ -184,7 +184,7 @@ static void print_patterns(parser & p, name const & n) {
|
|||
options opts = p.get_options();
|
||||
opts = opts.update_if_undef(get_pp_metavar_args_name(), true);
|
||||
io_state new_ios(p.ios(), opts);
|
||||
type_context tc(p.env(), opts);
|
||||
type_context_old tc(p.env(), opts);
|
||||
io_state_stream out = regular(p.env(), new_ios, tc);
|
||||
out << "(multi-)patterns:\n";
|
||||
if (!is_nil(hi.m_mvars)) {
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ struct structure_cmd_fn {
|
|||
parser & m_p;
|
||||
cmd_meta m_meta_info;
|
||||
environment m_env;
|
||||
type_context m_ctx;
|
||||
type_context_old m_ctx;
|
||||
name m_namespace;
|
||||
name m_name;
|
||||
name m_given_name;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ context_cacheless::context_cacheless(abstract_context_cache const & c, bool):
|
|||
m_class_instance_max_depth(c.get_class_instance_max_depth()) {
|
||||
}
|
||||
|
||||
bool context_cacheless::is_transparent(type_context & ctx, transparency_mode m, declaration const & d) {
|
||||
bool context_cacheless::is_transparent(type_context_old & ctx, transparency_mode m, declaration const & d) {
|
||||
if (m == transparency_mode::None)
|
||||
return false;
|
||||
name const & n = d.get_name();
|
||||
|
|
@ -92,7 +92,7 @@ bool context_cacheless::is_transparent(type_context & ctx, transparency_mode m,
|
|||
return false;
|
||||
}
|
||||
|
||||
optional<declaration> context_cacheless::get_decl(type_context & ctx, transparency_mode m, name const & n) {
|
||||
optional<declaration> context_cacheless::get_decl(type_context_old & ctx, transparency_mode m, name const & n) {
|
||||
if (auto d = ctx.env().find(n)) {
|
||||
if (d->is_definition() && is_transparent(ctx, m, *d)) {
|
||||
return d;
|
||||
|
|
@ -101,15 +101,15 @@ optional<declaration> context_cacheless::get_decl(type_context & ctx, transparen
|
|||
return optional<declaration>();
|
||||
}
|
||||
|
||||
projection_info const * context_cacheless::get_proj_info(type_context & ctx, name const & n) {
|
||||
projection_info const * context_cacheless::get_proj_info(type_context_old & ctx, name const & n) {
|
||||
return get_projection_info(ctx.env(), n);
|
||||
}
|
||||
|
||||
bool context_cacheless::get_aux_recursor(type_context & ctx, name const & n) {
|
||||
bool context_cacheless::get_aux_recursor(type_context_old & ctx, name const & n) {
|
||||
return ::lean::is_aux_recursor(ctx.env(), n);
|
||||
}
|
||||
|
||||
void context_cacheless::get_unification_hints(type_context & ctx, name const & f1, name const & f2, buffer<unification_hint> & hints) {
|
||||
void context_cacheless::get_unification_hints(type_context_old & ctx, name const & f1, name const & f2, buffer<unification_hint> & hints) {
|
||||
return ::lean::get_unification_hints(ctx.env(), f1, f2, hints);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace lean {
|
|||
#define LEAN_NUM_TRANSPARENCY_MODES 5
|
||||
enum class transparency_mode { All = 0, Semireducible, Instances, Reducible, None };
|
||||
|
||||
class type_context;
|
||||
class type_context_old;
|
||||
|
||||
/* Auxiliary information that is cached by the app_builder module in
|
||||
the context_cache. */
|
||||
|
|
@ -57,12 +57,12 @@ struct app_builder_info {
|
|||
without the overhead of many caches.
|
||||
|
||||
We use contextual caches for the operations performed in the following modules:
|
||||
type_context, app_builder, fun_info and congr_lemma.
|
||||
In the type_context, we cache inferred types, whnf, type class instances,
|
||||
type_context_old, app_builder, fun_info and congr_lemma.
|
||||
In the type_context_old, we cache inferred types, whnf, type class instances,
|
||||
to cite a few.
|
||||
|
||||
This class has been added to address problems with the former `type_context_cache_manager`.
|
||||
The `type_context_cache_manager` objects were stored in thread local objects.
|
||||
This class has been added to address problems with the former `type_context_old_cache_manager`.
|
||||
The `type_context_old_cache_manager` objects were stored in thread local objects.
|
||||
The correctness of this cache relied on the fact we used to never reuse fresh names in the whole system.
|
||||
This is not true in the new name_generator refactoring (for addressing issue #1601).
|
||||
The caches for the modules app_builder, congr_lemma and fun_info have the same problem.
|
||||
|
|
@ -73,7 +73,7 @@ struct app_builder_info {
|
|||
|
||||
Here is a scenario that demonstrates the problem.
|
||||
Suppose we are executing the tactic `t1 <|> t2`.
|
||||
First, we execute `t1`, and in the process, the type_context
|
||||
First, we execute `t1`, and in the process, the type_context_old
|
||||
cache is populated with new local constants created by `t1`.
|
||||
Then `t1` fails and we execute `t2`. When, we execute `t2`
|
||||
on the initial `tactic_state` object. Thus,
|
||||
|
|
@ -84,8 +84,8 @@ struct app_builder_info {
|
|||
Here are possible implementations of this API:
|
||||
|
||||
- An "imperative" implementation using hashtables, and it is useful for modules
|
||||
that own a type_context object (e.g., elaborator).
|
||||
This implementation is also useful for the new type_context API we are going to expose in the `io` monad.
|
||||
that own a type_context_old object (e.g., elaborator).
|
||||
This implementation is also useful for the new type_context_old API we are going to expose in the `io` monad.
|
||||
|
||||
- In principle, a "functional" implementation using rb_map and rb_tree is possible.
|
||||
Then, this version could be stored in the tactic_state or local_context objects.
|
||||
|
|
@ -96,11 +96,11 @@ struct app_builder_info {
|
|||
* The token can be viewed as a reference to the cache.
|
||||
* tactic_state stores this token.
|
||||
* Thread local storage stores the "imperative" implementation and a token of its owner.
|
||||
* When we create a type_context for a tactic_state we check whether the thread local
|
||||
* When we create a type_context_old for a tactic_state we check whether the thread local
|
||||
storage contains the cache for the given tactic_state. If yes, we use it, and obtain
|
||||
a new token for it since we will perform destructive updates.
|
||||
Otherwise, we create a new one.
|
||||
* When we finish using the type_context, we update the tactic_state with the new fresh token,
|
||||
* When we finish using the type_context_old, we update the tactic_state with the new fresh token,
|
||||
and put the updated cache back into the thread local storage.
|
||||
|
||||
Remark: the thread local storage may store more than one cache.
|
||||
|
|
@ -135,8 +135,8 @@ struct app_builder_info {
|
|||
This is fine because we only use the "liberal" mode when elaborating the header of a declaration.
|
||||
|
||||
2) frozen: after elaborating the header of a declaration, we freeze the local instances that can be used to
|
||||
elaborate its body. The freeze step is also useful to speedup the type_context initialization
|
||||
(see comment in the type_context class). So, we just check if the frozen local instances are the same
|
||||
elaborate its body. The freeze step is also useful to speedup the type_context_old initialization
|
||||
(see comment in the type_context_old class). So, we just check if the frozen local instances are the same
|
||||
before starting each step. This check is performed in the method `init_local_instances`.
|
||||
|
||||
Here are some benefits of the new approach:
|
||||
|
|
@ -146,9 +146,9 @@ struct app_builder_info {
|
|||
cache.
|
||||
|
||||
- We don't need to check whether the cache is valid or not when we create a new
|
||||
type_context.
|
||||
type_context_old.
|
||||
|
||||
- It is more efficient when creating temporary type_context objects for performing
|
||||
- It is more efficient when creating temporary type_context_old objects for performing
|
||||
a single operation. In this kind of scenario, we can use the dummy cache implementation
|
||||
that doesn't cache anything.
|
||||
|
||||
|
|
@ -179,12 +179,12 @@ public:
|
|||
/* Operations for accessing environment data more efficiently.
|
||||
The default implementation provided by this class does not have any optimization. */
|
||||
|
||||
virtual optional<declaration> get_decl(type_context &, transparency_mode, name const &) = 0;
|
||||
virtual projection_info const * get_proj_info(type_context &, name const &) = 0;
|
||||
virtual bool get_aux_recursor(type_context &, name const &) = 0;
|
||||
virtual void get_unification_hints(type_context &, name const & f1, name const & f2, buffer<unification_hint> & hints) = 0;
|
||||
virtual optional<declaration> get_decl(type_context_old &, transparency_mode, name const &) = 0;
|
||||
virtual projection_info const * get_proj_info(type_context_old &, name const &) = 0;
|
||||
virtual bool get_aux_recursor(type_context_old &, name const &) = 0;
|
||||
virtual void get_unification_hints(type_context_old &, name const & f1, name const & f2, buffer<unification_hint> & hints) = 0;
|
||||
|
||||
/* Cache support for type_context module */
|
||||
/* Cache support for type_context_old module */
|
||||
|
||||
virtual optional<expr> get_infer(expr const &) = 0;
|
||||
virtual void set_infer(expr const &, expr const &) = 0;
|
||||
|
|
@ -213,54 +213,54 @@ public:
|
|||
|
||||
/* Cache support for fun_info module */
|
||||
|
||||
virtual optional<fun_info> get_fun_info(type_context &, expr const &) = 0;
|
||||
virtual void set_fun_info(type_context &, expr const &, fun_info const &) = 0;
|
||||
virtual optional<fun_info> get_fun_info(type_context_old &, expr const &) = 0;
|
||||
virtual void set_fun_info(type_context_old &, expr const &, fun_info const &) = 0;
|
||||
|
||||
virtual optional<fun_info> get_fun_info_nargs(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_fun_info_nargs(type_context &, expr const &, unsigned, fun_info const &) = 0;
|
||||
virtual optional<fun_info> get_fun_info_nargs(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_fun_info_nargs(type_context_old &, expr const &, unsigned, fun_info const &) = 0;
|
||||
|
||||
virtual optional<unsigned> get_specialization_prefix_size(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_specialization_prefix_size(type_context &, expr const &, unsigned, unsigned) = 0;
|
||||
virtual optional<unsigned> get_specialization_prefix_size(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_specialization_prefix_size(type_context_old &, expr const &, unsigned, unsigned) = 0;
|
||||
|
||||
virtual optional<ss_param_infos> get_subsingleton_info(type_context &, expr const &) = 0;
|
||||
virtual void set_subsingleton_info(type_context &, expr const &, ss_param_infos const &) = 0;
|
||||
virtual optional<ss_param_infos> get_subsingleton_info(type_context_old &, expr const &) = 0;
|
||||
virtual void set_subsingleton_info(type_context_old &, expr const &, ss_param_infos const &) = 0;
|
||||
|
||||
virtual optional<ss_param_infos> get_subsingleton_info_nargs(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_subsingleton_info_nargs(type_context &, expr const &, unsigned, ss_param_infos const &) = 0;
|
||||
virtual optional<ss_param_infos> get_subsingleton_info_nargs(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_subsingleton_info_nargs(type_context_old &, expr const &, unsigned, ss_param_infos const &) = 0;
|
||||
|
||||
virtual optional<ss_param_infos> get_specialized_subsingleton_info_nargs(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_specialization_subsingleton_info_nargs(type_context &, expr const &, unsigned, ss_param_infos const &) = 0;
|
||||
virtual optional<ss_param_infos> get_specialized_subsingleton_info_nargs(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_specialization_subsingleton_info_nargs(type_context_old &, expr const &, unsigned, ss_param_infos const &) = 0;
|
||||
|
||||
/* Cache support for congr_lemma module */
|
||||
|
||||
virtual optional<congr_lemma> get_simp_congr_lemma(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_simp_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
virtual optional<congr_lemma> get_simp_congr_lemma(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_simp_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
|
||||
virtual optional<congr_lemma> get_specialized_simp_congr_lemma(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_specialized_simp_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
virtual optional<congr_lemma> get_specialized_simp_congr_lemma(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_specialized_simp_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
|
||||
virtual optional<congr_lemma> get_congr_lemma(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
virtual optional<congr_lemma> get_congr_lemma(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
|
||||
virtual optional<congr_lemma> get_specialized_congr_lemma(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_specialized_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
virtual optional<congr_lemma> get_specialized_congr_lemma(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_specialized_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
|
||||
virtual optional<congr_lemma> get_hcongr_lemma(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_hcongr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
virtual optional<congr_lemma> get_hcongr_lemma(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_hcongr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) = 0;
|
||||
|
||||
/* Cache support for app_builder */
|
||||
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context &, expr const &, unsigned) = 0;
|
||||
virtual void set_app_builder_info(type_context &, expr const &, unsigned, app_builder_info const &) = 0;
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context_old &, expr const &, unsigned) = 0;
|
||||
virtual void set_app_builder_info(type_context_old &, expr const &, unsigned, app_builder_info const &) = 0;
|
||||
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context &, expr const &, list<bool> const &) = 0;
|
||||
virtual void set_app_builder_info(type_context &, expr const &, list<bool> const &, app_builder_info const &) = 0;
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context_old &, expr const &, list<bool> const &) = 0;
|
||||
virtual void set_app_builder_info(type_context_old &, expr const &, list<bool> const &, app_builder_info const &) = 0;
|
||||
};
|
||||
|
||||
/* Dummy implementation of the abstract_context_cache interface that does not do cache anything but configuration options. */
|
||||
class context_cacheless : public abstract_context_cache {
|
||||
protected:
|
||||
bool is_transparent(type_context & ctx, transparency_mode m, declaration const & d);
|
||||
bool is_transparent(type_context_old & ctx, transparency_mode m, declaration const & d);
|
||||
private:
|
||||
options m_options;
|
||||
bool m_unfold_lemmas;
|
||||
|
|
@ -295,12 +295,12 @@ public:
|
|||
/* Operations for accessing environment data more efficiently.
|
||||
The default implementation provided by this class does not have any optimization. */
|
||||
|
||||
virtual optional<declaration> get_decl(type_context &, transparency_mode, name const &) override;
|
||||
virtual projection_info const * get_proj_info(type_context &, name const &) override;
|
||||
virtual bool get_aux_recursor(type_context &, name const &) override;
|
||||
virtual void get_unification_hints(type_context &, name const & f1, name const & f2, buffer<unification_hint> & hints) override;
|
||||
virtual optional<declaration> get_decl(type_context_old &, transparency_mode, name const &) override;
|
||||
virtual projection_info const * get_proj_info(type_context_old &, name const &) override;
|
||||
virtual bool get_aux_recursor(type_context_old &, name const &) override;
|
||||
virtual void get_unification_hints(type_context_old &, name const & f1, name const & f2, buffer<unification_hint> & hints) override;
|
||||
|
||||
/* Cache support for type_context module */
|
||||
/* Cache support for type_context_old module */
|
||||
|
||||
virtual optional<expr> get_infer(expr const &) override { return none_expr(); }
|
||||
virtual void set_infer(expr const &, expr const &) override {}
|
||||
|
|
@ -324,48 +324,48 @@ public:
|
|||
|
||||
/* Cache support for fun_info module */
|
||||
|
||||
virtual optional<fun_info> get_fun_info(type_context &, expr const &) override { return optional<fun_info>(); }
|
||||
virtual void set_fun_info(type_context &, expr const &, fun_info const &) override {}
|
||||
virtual optional<fun_info> get_fun_info(type_context_old &, expr const &) override { return optional<fun_info>(); }
|
||||
virtual void set_fun_info(type_context_old &, expr const &, fun_info const &) override {}
|
||||
|
||||
virtual optional<fun_info> get_fun_info_nargs(type_context &, expr const &, unsigned) override { return optional<fun_info>(); }
|
||||
virtual void set_fun_info_nargs(type_context &, expr const &, unsigned, fun_info const &) override {}
|
||||
virtual optional<fun_info> get_fun_info_nargs(type_context_old &, expr const &, unsigned) override { return optional<fun_info>(); }
|
||||
virtual void set_fun_info_nargs(type_context_old &, expr const &, unsigned, fun_info const &) override {}
|
||||
|
||||
virtual optional<unsigned> get_specialization_prefix_size(type_context &, expr const &, unsigned) override { return optional<unsigned>(); }
|
||||
virtual void set_specialization_prefix_size(type_context &, expr const &, unsigned, unsigned) override {}
|
||||
virtual optional<unsigned> get_specialization_prefix_size(type_context_old &, expr const &, unsigned) override { return optional<unsigned>(); }
|
||||
virtual void set_specialization_prefix_size(type_context_old &, expr const &, unsigned, unsigned) override {}
|
||||
|
||||
virtual optional<ss_param_infos> get_subsingleton_info(type_context &, expr const &) override { return optional<ss_param_infos>(); }
|
||||
virtual void set_subsingleton_info(type_context &, expr const &, ss_param_infos const &) override {}
|
||||
virtual optional<ss_param_infos> get_subsingleton_info(type_context_old &, expr const &) override { return optional<ss_param_infos>(); }
|
||||
virtual void set_subsingleton_info(type_context_old &, expr const &, ss_param_infos const &) override {}
|
||||
|
||||
virtual optional<ss_param_infos> get_subsingleton_info_nargs(type_context &, expr const &, unsigned) override { return optional<ss_param_infos>(); }
|
||||
virtual void set_subsingleton_info_nargs(type_context &, expr const &, unsigned, ss_param_infos const &) override {}
|
||||
virtual optional<ss_param_infos> get_subsingleton_info_nargs(type_context_old &, expr const &, unsigned) override { return optional<ss_param_infos>(); }
|
||||
virtual void set_subsingleton_info_nargs(type_context_old &, expr const &, unsigned, ss_param_infos const &) override {}
|
||||
|
||||
virtual optional<ss_param_infos> get_specialized_subsingleton_info_nargs(type_context &, expr const &, unsigned) override { return optional<ss_param_infos>(); }
|
||||
virtual void set_specialization_subsingleton_info_nargs(type_context &, expr const &, unsigned, ss_param_infos const &) override {}
|
||||
virtual optional<ss_param_infos> get_specialized_subsingleton_info_nargs(type_context_old &, expr const &, unsigned) override { return optional<ss_param_infos>(); }
|
||||
virtual void set_specialization_subsingleton_info_nargs(type_context_old &, expr const &, unsigned, ss_param_infos const &) override {}
|
||||
|
||||
/* Cache support for congr_lemma module */
|
||||
|
||||
virtual optional<congr_lemma> get_simp_congr_lemma(type_context &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_simp_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
virtual optional<congr_lemma> get_simp_congr_lemma(type_context_old &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_simp_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
|
||||
virtual optional<congr_lemma> get_specialized_simp_congr_lemma(type_context &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_specialized_simp_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
virtual optional<congr_lemma> get_specialized_simp_congr_lemma(type_context_old &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_specialized_simp_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
|
||||
virtual optional<congr_lemma> get_congr_lemma(type_context &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
virtual optional<congr_lemma> get_congr_lemma(type_context_old &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
|
||||
virtual optional<congr_lemma> get_specialized_congr_lemma(type_context &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_specialized_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
virtual optional<congr_lemma> get_specialized_congr_lemma(type_context_old &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_specialized_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
|
||||
virtual optional<congr_lemma> get_hcongr_lemma(type_context &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_hcongr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
virtual optional<congr_lemma> get_hcongr_lemma(type_context_old &, expr const &, unsigned) override { return optional<congr_lemma>(); }
|
||||
virtual void set_hcongr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override {}
|
||||
|
||||
/* Cache support for app_builder */
|
||||
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context &, expr const &, unsigned) override { return optional<app_builder_info>(); }
|
||||
virtual void set_app_builder_info(type_context &, expr const &, unsigned, app_builder_info const &) override {}
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context_old &, expr const &, unsigned) override { return optional<app_builder_info>(); }
|
||||
virtual void set_app_builder_info(type_context_old &, expr const &, unsigned, app_builder_info const &) override {}
|
||||
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context &, expr const &, list<bool> const &) override { return optional<app_builder_info>(); }
|
||||
virtual void set_app_builder_info(type_context &, expr const &, list<bool> const &, app_builder_info const &) override {}
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context_old &, expr const &, list<bool> const &) override { return optional<app_builder_info>(); }
|
||||
virtual void set_app_builder_info(type_context_old &, expr const &, list<bool> const &, app_builder_info const &) override {}
|
||||
};
|
||||
|
||||
void initialize_abstract_context_cache();
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ Author: Leonardo de Moura
|
|||
|
||||
The simplifier will be the main consumer of this module.
|
||||
The simplifier will use AC matching for any simp lemma marked with the [ac_match] attribute.
|
||||
If AC matching fails, we use the matching procedure provided by type_context.
|
||||
The AC matching procedure implemented here does not subsume the matching procedure at type_context,
|
||||
If AC matching fails, we use the matching procedure provided by type_context_old.
|
||||
The AC matching procedure implemented here does not subsume the matching procedure at type_context_old,
|
||||
which performs matching modulo CIC reduction rules and has support for higher-order patterns.
|
||||
By default, all simp lemmas derived from the local context will have the [ac_match] attribute.
|
||||
The simplifier will have an option for disabling all AC matching support.
|
||||
|
|
@ -26,7 +26,7 @@ The AC matching procedure uses backtracking. The state is a tuple (Y, U, U_p, U_
|
|||
- Y is a set of auxiliary temporary metavariables
|
||||
- U is a set of (unsolved) matching constraints: p =?= t, p may contain temporary metavariables, but t doesn't
|
||||
- U_p is a set of unsolved and postponed matching constraints. We use this set for storing matching constraints that should
|
||||
be solved using using type_context full force is_def_eq procedure.
|
||||
be solved using using type_context_old full force is_def_eq procedure.
|
||||
- U_u is a set of (unsolved) universe matching constraints: p =?= u, p may contain temporary universe metavariables, but u doesn't.
|
||||
- P (partial solutions) is a mapping from temporary metavariable to a triple (op, y, t) where
|
||||
op is an AC operator, y is in Y, and t is a term and the head of t is not op.
|
||||
|
|
@ -36,15 +36,15 @@ The AC matching procedure uses backtracking. The state is a tuple (Y, U, U_p, U_
|
|||
- S_u (universe solutions) is a mapping from temporary universe metavariable to an universe term u.
|
||||
u does not contain temporary metavariables.
|
||||
|
||||
We implement the mappings P and S using arrays. We use a similar approach in type_context.
|
||||
We implement the mappings P and S using arrays. We use a similar approach in type_context_old.
|
||||
We implement U as a queue. The queue is an array and index qidx (queue head).
|
||||
This module ignores the fact that the universe operator `max` is associative and commutative.
|
||||
Non trival universe constraints are just postponed like in the type_context class.
|
||||
Non trival universe constraints are just postponed like in the type_context_old class.
|
||||
|
||||
This module does not use AC matching for implicit arguments. Matching constraints for implicit arguments
|
||||
are stored at U_p. When U is empty, we just use full force type_context is_def_eq to process the constraints
|
||||
at U_p. Note that the type_context must have access to S and S_u.
|
||||
We address this requirement by using the type_context m_eassignment and m_uassignment
|
||||
are stored at U_p. When U is empty, we just use full force type_context_old is_def_eq to process the constraints
|
||||
at U_p. Note that the type_context_old must have access to S and S_u.
|
||||
We address this requirement by using the type_context_old m_eassignment and m_uassignment
|
||||
to implement S and S_u. Similarly, we use m_postponed to implement U_u.
|
||||
|
||||
Here are the rules for processing U elements
|
||||
|
|
@ -150,7 +150,7 @@ Remark: we use + and * to denote arbitrary AC operators
|
|||
==>
|
||||
replace with p =?= s[x/t]
|
||||
|
||||
After we don't have more elements in U to process using the rules above, we process U_p and U_u constraints using type_context is_def_eq with full force.
|
||||
After we don't have more elements in U to process using the rules above, we process U_p and U_u constraints using type_context_old is_def_eq with full force.
|
||||
|
||||
Remark: in the rules above we do not have support for Pi and lambda-terms containing temporary metavariables.
|
||||
We will treat macros and (A -> B) as applications. Here (A -> B) denotes a non dependent Pi-term.
|
||||
|
|
|
|||
|
|
@ -119,11 +119,11 @@ typedef cache_compatibility_helper<app_builder_cache> app_builder_cache_helper;
|
|||
MK_THREAD_LOCAL_GET_DEF(app_builder_cache_helper, get_abch);
|
||||
|
||||
/** Return an app_builder_cache for the transparency_mode in ctx, and compatible with the environment. */
|
||||
app_builder_cache & get_app_builder_cache_for(type_context const & ctx) {
|
||||
app_builder_cache & get_app_builder_cache_for(type_context_old const & ctx) {
|
||||
return get_abch().get_cache_for(ctx);
|
||||
}
|
||||
|
||||
static level get_level_ap(type_context & ctx, expr const & A) {
|
||||
static level get_level_ap(type_context_old & ctx, expr const & A) {
|
||||
try {
|
||||
return get_level(ctx, A);
|
||||
} catch (exception &) {
|
||||
|
|
@ -147,7 +147,7 @@ static level get_level_ap(type_context & ctx, expr const & A) {
|
|||
rel.{1 2} nat (fun n : nat, vec real n) f g
|
||||
*/
|
||||
class app_builder {
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
app_builder_cache & m_cache;
|
||||
typedef app_builder_cache::key key;
|
||||
typedef app_builder_cache::entry entry;
|
||||
|
|
@ -307,7 +307,7 @@ class app_builder {
|
|||
}
|
||||
|
||||
public:
|
||||
app_builder(type_context & ctx):m_ctx(ctx), m_cache(get_app_builder_cache_for(ctx)) {}
|
||||
app_builder(type_context_old & ctx):m_ctx(ctx), m_cache(get_app_builder_cache_for(ctx)) {}
|
||||
|
||||
level get_level(expr const & A) {
|
||||
return get_level_ap(m_ctx, A);
|
||||
|
|
@ -315,7 +315,7 @@ public:
|
|||
|
||||
expr mk_app(name const & c, unsigned nargs, expr const * args) {
|
||||
lean_assert(std::all_of(args, args + nargs, [](expr const & arg) { return !has_idx_metavar(arg); }))
|
||||
type_context::tmp_mode_scope scope(m_ctx);
|
||||
type_context_old::tmp_mode_scope scope(m_ctx);
|
||||
optional<entry> e = get_entry(c, nargs);
|
||||
if (!e) {
|
||||
trace_failure(c, "failed to retrieve declaration");
|
||||
|
|
@ -358,7 +358,7 @@ public:
|
|||
}
|
||||
|
||||
expr mk_app(name const & c, unsigned mask_sz, bool const * mask, expr const * args) {
|
||||
type_context::tmp_mode_scope scope(m_ctx);
|
||||
type_context_old::tmp_mode_scope scope(m_ctx);
|
||||
unsigned nargs = get_nargs(mask_sz, mask);
|
||||
optional<entry> e = get_entry(c, mask_sz, mask);
|
||||
if (!e) {
|
||||
|
|
@ -683,7 +683,7 @@ public:
|
|||
lean_app_builder_trace(tout() << "failed to build lift_of_eq equality proof expected:\n" << H << "\n";);
|
||||
throw app_builder_exception();
|
||||
}
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr x = locals.push_local(name("A"), A);
|
||||
// motive := fun x : A, a ~ x
|
||||
expr motive = locals.mk_lambda(mk_rel(R, a, x));
|
||||
|
|
@ -823,117 +823,117 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
expr mk_app(type_context & ctx, name const & c, unsigned nargs, expr const * args, optional<transparency_mode> const & md) {
|
||||
expr mk_app(type_context_old & ctx, name const & c, unsigned nargs, expr const * args, optional<transparency_mode> const & md) {
|
||||
if (md) {
|
||||
type_context::transparency_scope _s1(ctx, *md);
|
||||
type_context::zeta_scope _s2(ctx, true);
|
||||
type_context_old::transparency_scope _s1(ctx, *md);
|
||||
type_context_old::zeta_scope _s2(ctx, true);
|
||||
return app_builder(ctx).mk_app(c, nargs, args);
|
||||
} else if (!is_at_least_semireducible(ctx.mode())) {
|
||||
type_context::transparency_scope _s1(ctx, transparency_mode::Semireducible);
|
||||
type_context::zeta_scope _s2(ctx, true);
|
||||
type_context_old::transparency_scope _s1(ctx, transparency_mode::Semireducible);
|
||||
type_context_old::zeta_scope _s2(ctx, true);
|
||||
return app_builder(ctx).mk_app(c, nargs, args);
|
||||
} else {
|
||||
return app_builder(ctx).mk_app(c, nargs, args);
|
||||
}
|
||||
}
|
||||
|
||||
expr mk_app(type_context & ctx, name const & c, unsigned mask_sz, bool const * mask, expr const * args) {
|
||||
expr mk_app(type_context_old & ctx, name const & c, unsigned mask_sz, bool const * mask, expr const * args) {
|
||||
return app_builder(ctx).mk_app(c, mask_sz, mask, args);
|
||||
}
|
||||
|
||||
expr mk_app(type_context & ctx, name const & c, unsigned total_nargs, unsigned expl_nargs, expr const * expl_args) {
|
||||
expr mk_app(type_context_old & ctx, name const & c, unsigned total_nargs, unsigned expl_nargs, expr const * expl_args) {
|
||||
return app_builder(ctx).mk_app(c, total_nargs, expl_nargs, expl_args);
|
||||
}
|
||||
|
||||
expr mk_rel(type_context & ctx, name const & n, expr const & lhs, expr const & rhs) {
|
||||
expr mk_rel(type_context_old & ctx, name const & n, expr const & lhs, expr const & rhs) {
|
||||
return app_builder(ctx).mk_rel(n, lhs, rhs);
|
||||
}
|
||||
|
||||
expr mk_eq(type_context & ctx, expr const & lhs, expr const & rhs) {
|
||||
expr mk_eq(type_context_old & ctx, expr const & lhs, expr const & rhs) {
|
||||
return app_builder(ctx).mk_eq(lhs, rhs);
|
||||
}
|
||||
|
||||
expr mk_iff(type_context & ctx, expr const & lhs, expr const & rhs) {
|
||||
expr mk_iff(type_context_old & ctx, expr const & lhs, expr const & rhs) {
|
||||
return app_builder(ctx).mk_iff(lhs, rhs);
|
||||
}
|
||||
|
||||
expr mk_heq(type_context & ctx, expr const & lhs, expr const & rhs) {
|
||||
expr mk_heq(type_context_old & ctx, expr const & lhs, expr const & rhs) {
|
||||
return app_builder(ctx).mk_heq(lhs, rhs);
|
||||
}
|
||||
|
||||
expr mk_refl(type_context & ctx, name const & relname, expr const & a) {
|
||||
expr mk_refl(type_context_old & ctx, name const & relname, expr const & a) {
|
||||
return app_builder(ctx).mk_refl(relname, a);
|
||||
}
|
||||
|
||||
expr mk_eq_refl(type_context & ctx, expr const & a) {
|
||||
expr mk_eq_refl(type_context_old & ctx, expr const & a) {
|
||||
return app_builder(ctx).mk_eq_refl(a);
|
||||
}
|
||||
|
||||
expr mk_iff_refl(type_context & ctx, expr const & a) {
|
||||
expr mk_iff_refl(type_context_old & ctx, expr const & a) {
|
||||
return app_builder(ctx).mk_iff_refl(a);
|
||||
}
|
||||
|
||||
expr mk_heq_refl(type_context & ctx, expr const & a) {
|
||||
expr mk_heq_refl(type_context_old & ctx, expr const & a) {
|
||||
return app_builder(ctx).mk_heq_refl(a);
|
||||
}
|
||||
|
||||
expr mk_symm(type_context & ctx, name const & relname, expr const & H) {
|
||||
expr mk_symm(type_context_old & ctx, name const & relname, expr const & H) {
|
||||
return app_builder(ctx).mk_symm(relname, H);
|
||||
}
|
||||
|
||||
expr mk_eq_symm(type_context & ctx, expr const & H) {
|
||||
expr mk_eq_symm(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_eq_symm(H);
|
||||
}
|
||||
|
||||
expr mk_eq_symm(type_context & ctx, expr const & a, expr const & b, expr const & H) {
|
||||
expr mk_eq_symm(type_context_old & ctx, expr const & a, expr const & b, expr const & H) {
|
||||
return app_builder(ctx).mk_eq_symm(a, b, H);
|
||||
}
|
||||
|
||||
expr mk_iff_symm(type_context & ctx, expr const & H) {
|
||||
expr mk_iff_symm(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_iff_symm(H);
|
||||
}
|
||||
|
||||
expr mk_heq_symm(type_context & ctx, expr const & H) {
|
||||
expr mk_heq_symm(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_heq_symm(H);
|
||||
}
|
||||
|
||||
expr mk_trans(type_context & ctx, name const & relname, expr const & H1, expr const & H2) {
|
||||
expr mk_trans(type_context_old & ctx, name const & relname, expr const & H1, expr const & H2) {
|
||||
return app_builder(ctx).mk_trans(relname, H1, H2);
|
||||
}
|
||||
|
||||
expr mk_eq_trans(type_context & ctx, expr const & H1, expr const & H2) {
|
||||
expr mk_eq_trans(type_context_old & ctx, expr const & H1, expr const & H2) {
|
||||
return app_builder(ctx).mk_eq_trans(H1, H2);
|
||||
}
|
||||
|
||||
expr mk_eq_trans(type_context & ctx, expr const & a, expr const & b, expr const & c, expr const & H1, expr const & H2) {
|
||||
expr mk_eq_trans(type_context_old & ctx, expr const & a, expr const & b, expr const & c, expr const & H1, expr const & H2) {
|
||||
return app_builder(ctx).mk_eq_trans(a, b, c, H1, H2);
|
||||
}
|
||||
|
||||
expr mk_iff_trans(type_context & ctx, expr const & H1, expr const & H2) {
|
||||
expr mk_iff_trans(type_context_old & ctx, expr const & H1, expr const & H2) {
|
||||
return app_builder(ctx).mk_iff_trans(H1, H2);
|
||||
}
|
||||
|
||||
expr mk_heq_trans(type_context & ctx, expr const & H1, expr const & H2) {
|
||||
expr mk_heq_trans(type_context_old & ctx, expr const & H1, expr const & H2) {
|
||||
return app_builder(ctx).mk_heq_trans(H1, H2);
|
||||
}
|
||||
|
||||
expr mk_eq_rec(type_context & ctx, expr const & C, expr const & H1, expr const & H2) {
|
||||
expr mk_eq_rec(type_context_old & ctx, expr const & C, expr const & H1, expr const & H2) {
|
||||
return app_builder(ctx).mk_eq_rec(C, H1, H2);
|
||||
}
|
||||
|
||||
expr mk_eq_drec(type_context & ctx, expr const & C, expr const & H1, expr const & H2) {
|
||||
expr mk_eq_drec(type_context_old & ctx, expr const & C, expr const & H1, expr const & H2) {
|
||||
return app_builder(ctx).mk_eq_drec(C, H1, H2);
|
||||
}
|
||||
|
||||
expr mk_eq_of_heq(type_context & ctx, expr const & H) {
|
||||
expr mk_eq_of_heq(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_eq_of_heq(H);
|
||||
}
|
||||
|
||||
expr mk_heq_of_eq(type_context & ctx, expr const & H) {
|
||||
expr mk_heq_of_eq(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_heq_of_eq(H);
|
||||
}
|
||||
|
||||
expr mk_congr_arg(type_context & ctx, expr const & f, expr const & H, bool skip_arrow_test) {
|
||||
expr mk_congr_arg(type_context_old & ctx, expr const & f, expr const & H, bool skip_arrow_test) {
|
||||
expr eq = ctx.relaxed_whnf(ctx.infer(H));
|
||||
expr pi = ctx.relaxed_whnf(ctx.infer(f));
|
||||
expr A, B, lhs, rhs;
|
||||
|
|
@ -956,7 +956,7 @@ expr mk_congr_arg(type_context & ctx, expr const & f, expr const & H, bool skip_
|
|||
return mk_app({mk_constant(get_congr_arg_name(), {lvl_1, lvl_2}), A, B, lhs, rhs, f, H});
|
||||
}
|
||||
|
||||
expr mk_congr_fun(type_context & ctx, expr const & H, expr const & a) {
|
||||
expr mk_congr_fun(type_context_old & ctx, expr const & H, expr const & a) {
|
||||
expr eq = ctx.relaxed_whnf(ctx.infer(H));
|
||||
expr pi, lhs, rhs;
|
||||
if (!is_eq(eq, pi, lhs, rhs)) {
|
||||
|
|
@ -975,7 +975,7 @@ expr mk_congr_fun(type_context & ctx, expr const & H, expr const & a) {
|
|||
return mk_app({mk_constant(get_congr_fun_name(), {lvl_1, lvl_2}), A, B, lhs, rhs, H, a});
|
||||
}
|
||||
|
||||
expr mk_congr(type_context & ctx, expr const & H1, expr const & H2, bool skip_arrow_test) {
|
||||
expr mk_congr(type_context_old & ctx, expr const & H1, expr const & H2, bool skip_arrow_test) {
|
||||
expr eq1 = ctx.relaxed_whnf(ctx.infer(H1));
|
||||
expr eq2 = ctx.relaxed_whnf(ctx.infer(H2));
|
||||
expr pi, lhs1, rhs1;
|
||||
|
|
@ -1006,47 +1006,47 @@ expr mk_congr(type_context & ctx, expr const & H1, expr const & H2, bool skip_ar
|
|||
return mk_app({mk_constant(get_congr_name(), {lvl_1, lvl_2}), A, B, lhs1, rhs1, lhs2, rhs2, H1, H2});
|
||||
}
|
||||
|
||||
expr mk_funext(type_context & ctx, expr const & lam_pf) {
|
||||
expr mk_funext(type_context_old & ctx, expr const & lam_pf) {
|
||||
// TODO(dhs): efficient version
|
||||
return mk_app(ctx, get_funext_name(), lam_pf);
|
||||
}
|
||||
|
||||
expr lift_from_eq(type_context & ctx, name const & R, expr const & H) {
|
||||
expr lift_from_eq(type_context_old & ctx, name const & R, expr const & H) {
|
||||
return app_builder(ctx).lift_from_eq(R, H);
|
||||
}
|
||||
|
||||
expr mk_iff_false_intro(type_context & ctx, expr const & H) {
|
||||
expr mk_iff_false_intro(type_context_old & ctx, expr const & H) {
|
||||
// TODO(Leo): implement custom version if bottleneck.
|
||||
return mk_app(ctx, get_iff_false_intro_name(), {H});
|
||||
}
|
||||
|
||||
expr mk_iff_true_intro(type_context & ctx, expr const & H) {
|
||||
expr mk_iff_true_intro(type_context_old & ctx, expr const & H) {
|
||||
// TODO(Leo): implement custom version if bottleneck.
|
||||
return mk_app(ctx, get_iff_true_intro_name(), {H});
|
||||
}
|
||||
|
||||
expr mk_eq_false_intro(type_context & ctx, expr const & H) {
|
||||
expr mk_eq_false_intro(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_eq_false_intro(H);
|
||||
}
|
||||
|
||||
expr mk_eq_true_intro(type_context & ctx, expr const & H) {
|
||||
expr mk_eq_true_intro(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_eq_true_intro(H);
|
||||
}
|
||||
|
||||
expr mk_not_of_eq_false(type_context & ctx, expr const & H) {
|
||||
expr mk_not_of_eq_false(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_not_of_eq_false(H);
|
||||
}
|
||||
|
||||
expr mk_of_eq_true(type_context & ctx, expr const & H) {
|
||||
expr mk_of_eq_true(type_context_old & ctx, expr const & H) {
|
||||
return app_builder(ctx).mk_of_eq_true(H);
|
||||
}
|
||||
|
||||
expr mk_neq_of_not_iff(type_context & ctx, expr const & H) {
|
||||
expr mk_neq_of_not_iff(type_context_old & ctx, expr const & H) {
|
||||
// TODO(Leo): implement custom version if bottleneck.
|
||||
return mk_app(ctx, get_neq_of_not_iff_name(), {H});
|
||||
}
|
||||
|
||||
expr mk_not_of_iff_false(type_context & ctx, expr const & H) {
|
||||
expr mk_not_of_iff_false(type_context_old & ctx, expr const & H) {
|
||||
if (is_constant(get_app_fn(H), get_iff_false_intro_name())) {
|
||||
// not_of_iff_false (iff_false_intro H) == H
|
||||
return app_arg(H);
|
||||
|
|
@ -1055,7 +1055,7 @@ expr mk_not_of_iff_false(type_context & ctx, expr const & H) {
|
|||
return mk_app(ctx, get_not_of_iff_false_name(), 2, {H});
|
||||
}
|
||||
|
||||
expr mk_of_iff_true(type_context & ctx, expr const & H) {
|
||||
expr mk_of_iff_true(type_context_old & ctx, expr const & H) {
|
||||
if (is_constant(get_app_fn(H), get_iff_true_intro_name())) {
|
||||
// of_iff_true (iff_true_intro H) == H
|
||||
return app_arg(H);
|
||||
|
|
@ -1064,79 +1064,79 @@ expr mk_of_iff_true(type_context & ctx, expr const & H) {
|
|||
return mk_app(ctx, get_of_iff_true_name(), {H});
|
||||
}
|
||||
|
||||
expr mk_false_of_true_iff_false(type_context & ctx, expr const & H) {
|
||||
expr mk_false_of_true_iff_false(type_context_old & ctx, expr const & H) {
|
||||
// TODO(Leo): implement custom version if bottleneck.
|
||||
return mk_app(ctx, get_false_of_true_iff_false_name(), {H});
|
||||
}
|
||||
|
||||
expr mk_false_of_true_eq_false(type_context & ctx, expr const & H) {
|
||||
expr mk_false_of_true_eq_false(type_context_old & ctx, expr const & H) {
|
||||
// TODO(Leo): implement custom version if bottleneck.
|
||||
return mk_app(ctx, get_false_of_true_eq_false_name(), {H});
|
||||
}
|
||||
|
||||
expr mk_not(type_context & ctx, expr const & H) {
|
||||
expr mk_not(type_context_old & ctx, expr const & H) {
|
||||
// TODO(dhs): implement custom version if bottleneck.
|
||||
return mk_app(ctx, get_not_name(), {H});
|
||||
}
|
||||
|
||||
expr mk_absurd(type_context & ctx, expr const & Hp, expr const & Hnp, expr const & b) {
|
||||
expr mk_absurd(type_context_old & ctx, expr const & Hp, expr const & Hnp, expr const & b) {
|
||||
return mk_app(ctx, get_absurd_name(), {b, Hp, Hnp});
|
||||
}
|
||||
|
||||
expr mk_partial_add(type_context & ctx, expr const & A) {
|
||||
expr mk_partial_add(type_context_old & ctx, expr const & A) {
|
||||
return app_builder(ctx).mk_partial_add(A);
|
||||
}
|
||||
|
||||
expr mk_partial_mul(type_context & ctx, expr const & A) {
|
||||
expr mk_partial_mul(type_context_old & ctx, expr const & A) {
|
||||
return app_builder(ctx).mk_partial_mul(A);
|
||||
}
|
||||
|
||||
expr mk_zero(type_context & ctx, expr const & A) {
|
||||
expr mk_zero(type_context_old & ctx, expr const & A) {
|
||||
return app_builder(ctx).mk_zero(A);
|
||||
}
|
||||
|
||||
expr mk_one(type_context & ctx, expr const & A) {
|
||||
expr mk_one(type_context_old & ctx, expr const & A) {
|
||||
return app_builder(ctx).mk_one(A);
|
||||
}
|
||||
|
||||
expr mk_partial_left_distrib(type_context & ctx, expr const & A) {
|
||||
expr mk_partial_left_distrib(type_context_old & ctx, expr const & A) {
|
||||
return app_builder(ctx).mk_partial_left_distrib(A);
|
||||
}
|
||||
|
||||
expr mk_partial_right_distrib(type_context & ctx, expr const & A) {
|
||||
expr mk_partial_right_distrib(type_context_old & ctx, expr const & A) {
|
||||
return app_builder(ctx).mk_partial_right_distrib(A);
|
||||
}
|
||||
|
||||
expr mk_ss_elim(type_context & ctx, expr const & A, expr const & ss_inst, expr const & old_e, expr const & new_e) {
|
||||
expr mk_ss_elim(type_context_old & ctx, expr const & A, expr const & ss_inst, expr const & old_e, expr const & new_e) {
|
||||
return app_builder(ctx).mk_ss_elim(A, ss_inst, old_e, new_e);
|
||||
}
|
||||
|
||||
expr mk_false_rec(type_context & ctx, expr const & c, expr const & H) {
|
||||
expr mk_false_rec(type_context_old & ctx, expr const & c, expr const & H) {
|
||||
return app_builder(ctx).mk_false_rec(c, H);
|
||||
}
|
||||
|
||||
expr mk_ite(type_context & ctx, expr const & c, expr const & t, expr const & e) {
|
||||
expr mk_ite(type_context_old & ctx, expr const & c, expr const & t, expr const & e) {
|
||||
bool mask[5] = {true, false, false, true, true};
|
||||
expr args[3] = {c, t, e};
|
||||
return mk_app(ctx, get_ite_name(), 5, mask, args);
|
||||
}
|
||||
|
||||
expr mk_id(type_context & ctx, expr const & type, expr const & h) {
|
||||
expr mk_id(type_context_old & ctx, expr const & type, expr const & h) {
|
||||
level lvl = get_level_ap(ctx, type);
|
||||
return mk_app(mk_constant(get_id_name(), {lvl}), type, h);
|
||||
}
|
||||
|
||||
expr mk_id(type_context & ctx, expr const & h) {
|
||||
expr mk_id(type_context_old & ctx, expr const & h) {
|
||||
return mk_id(ctx, ctx.infer(h), h);
|
||||
}
|
||||
|
||||
expr mk_id_rhs(type_context & ctx, expr const & h) {
|
||||
expr mk_id_rhs(type_context_old & ctx, expr const & h) {
|
||||
expr type = ctx.infer(h);
|
||||
level lvl = get_level_ap(ctx, type);
|
||||
return mk_app(mk_constant(get_id_rhs_name(), {lvl}), type, h);
|
||||
}
|
||||
|
||||
expr mk_id_delta(type_context & ctx, expr const & h) {
|
||||
expr mk_id_delta(type_context_old & ctx, expr const & h) {
|
||||
expr type = ctx.infer(h);
|
||||
level lvl = get_level_ap(ctx, type);
|
||||
return mk_app(mk_constant(get_id_delta_name(), {lvl}), type, h);
|
||||
|
|
@ -1170,7 +1170,7 @@ static bool is_eq_self_iff_true(expr const & h, expr & t) {
|
|||
}
|
||||
}
|
||||
|
||||
expr mk_eq_mpr(type_context & ctx, expr const & h1, expr const & h2) {
|
||||
expr mk_eq_mpr(type_context_old & ctx, expr const & h1, expr const & h2) {
|
||||
/*
|
||||
eq.mpr (eq.trans H (propext (@eq_self_iff_true t))) h2
|
||||
==>
|
||||
|
|
@ -1185,15 +1185,15 @@ expr mk_eq_mpr(type_context & ctx, expr const & h1, expr const & h2) {
|
|||
return mk_app(ctx, get_eq_mpr_name(), h1, h2);
|
||||
}
|
||||
|
||||
expr mk_iff_mpr(type_context & ctx, expr const & h1, expr const & h2) {
|
||||
expr mk_iff_mpr(type_context_old & ctx, expr const & h1, expr const & h2) {
|
||||
return mk_app(ctx, get_iff_mpr_name(), h1, h2);
|
||||
}
|
||||
|
||||
expr mk_eq_mp(type_context & ctx, expr const & h1, expr const & h2) {
|
||||
expr mk_eq_mp(type_context_old & ctx, expr const & h1, expr const & h2) {
|
||||
return mk_app(ctx, get_eq_mp_name(), h1, h2);
|
||||
}
|
||||
|
||||
expr mk_iff_mp(type_context & ctx, expr const & h1, expr const & h2) {
|
||||
expr mk_iff_mp(type_context_old & ctx, expr const & h1, expr const & h2) {
|
||||
return mk_app(ctx, get_iff_mp_name(), h1, h2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,78 +33,78 @@ public:
|
|||
\remark if the transparency mode is not provided, then mk_app will use Semireducible
|
||||
if the ctx.mode() is Reducible or None.
|
||||
*/
|
||||
expr mk_app(type_context & ctx, name const & c, unsigned nargs, expr const * args,
|
||||
expr mk_app(type_context_old & ctx, name const & c, unsigned nargs, expr const * args,
|
||||
optional<transparency_mode> const & md = optional<transparency_mode>());
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, std::initializer_list<expr> const & args,
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, std::initializer_list<expr> const & args,
|
||||
optional<transparency_mode> const & md = optional<transparency_mode>()) {
|
||||
return mk_app(ctx, c, args.size(), args.begin(), md);
|
||||
}
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, expr const & a1) {
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, expr const & a1) {
|
||||
return mk_app(ctx, c, {a1});
|
||||
}
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, expr const & a1, expr const & a2) {
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, expr const & a1, expr const & a2) {
|
||||
return mk_app(ctx, c, {a1, a2});
|
||||
}
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, expr const & a1, expr const & a2, expr const & a3) {
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, expr const & a1, expr const & a2, expr const & a3) {
|
||||
return mk_app(ctx, c, {a1, a2, a3});
|
||||
}
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, expr const & a1, expr const & a2, expr const & a3, expr const & a4) {
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, expr const & a1, expr const & a2, expr const & a3, expr const & a4) {
|
||||
return mk_app(ctx, c, {a1, a2, a3, a4});
|
||||
}
|
||||
|
||||
expr mk_app(type_context & ctx, name const & c, unsigned mask_sz, bool const * mask, expr const * args);
|
||||
expr mk_app(type_context_old & ctx, name const & c, unsigned mask_sz, bool const * mask, expr const * args);
|
||||
|
||||
/** \brief Shortcut for mk_app(c, total_nargs, mask, expl_nargs), where
|
||||
\c mask starts with total_nargs - expl_nargs false's followed by expl_nargs true's
|
||||
\pre total_nargs >= expl_nargs */
|
||||
expr mk_app(type_context & ctx, name const & c, unsigned total_nargs, unsigned expl_nargs, expr const * expl_args);
|
||||
expr mk_app(type_context_old & ctx, name const & c, unsigned total_nargs, unsigned expl_nargs, expr const * expl_args);
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, unsigned total_nargs, std::initializer_list<expr> const & args) {
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, unsigned total_nargs, std::initializer_list<expr> const & args) {
|
||||
return mk_app(ctx, c, total_nargs, args.size(), args.begin());
|
||||
}
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, unsigned total_nargs, expr const & a1) {
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, unsigned total_nargs, expr const & a1) {
|
||||
return mk_app(ctx, c, total_nargs, {a1});
|
||||
}
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, unsigned total_nargs, expr const & a1, expr const & a2) {
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, unsigned total_nargs, expr const & a1, expr const & a2) {
|
||||
return mk_app(ctx, c, total_nargs, {a1, a2});
|
||||
}
|
||||
|
||||
inline expr mk_app(type_context & ctx, name const & c, unsigned total_nargs, expr const & a1, expr const & a2, expr const & a3) {
|
||||
inline expr mk_app(type_context_old & ctx, name const & c, unsigned total_nargs, expr const & a1, expr const & a2, expr const & a3) {
|
||||
return mk_app(ctx, c, total_nargs, {a1, a2, a3});
|
||||
}
|
||||
|
||||
/** \brief Similar to mk_app(n, lhs, rhs), but handles eq and iff more efficiently. */
|
||||
expr mk_rel(type_context & ctx, name const & n, expr const & lhs, expr const & rhs);
|
||||
expr mk_eq(type_context & ctx, expr const & lhs, expr const & rhs);
|
||||
expr mk_iff(type_context & ctx, expr const & lhs, expr const & rhs);
|
||||
expr mk_heq(type_context & ctx, expr const & lhs, expr const & rhs);
|
||||
expr mk_rel(type_context_old & ctx, name const & n, expr const & lhs, expr const & rhs);
|
||||
expr mk_eq(type_context_old & ctx, expr const & lhs, expr const & rhs);
|
||||
expr mk_iff(type_context_old & ctx, expr const & lhs, expr const & rhs);
|
||||
expr mk_heq(type_context_old & ctx, expr const & lhs, expr const & rhs);
|
||||
|
||||
/** \brief Similar a reflexivity proof for the given relation */
|
||||
expr mk_refl(type_context & ctx, name const & relname, expr const & a);
|
||||
expr mk_eq_refl(type_context & ctx, expr const & a);
|
||||
expr mk_iff_refl(type_context & ctx, expr const & a);
|
||||
expr mk_heq_refl(type_context & ctx, expr const & a);
|
||||
expr mk_refl(type_context_old & ctx, name const & relname, expr const & a);
|
||||
expr mk_eq_refl(type_context_old & ctx, expr const & a);
|
||||
expr mk_iff_refl(type_context_old & ctx, expr const & a);
|
||||
expr mk_heq_refl(type_context_old & ctx, expr const & a);
|
||||
|
||||
/** \brief Similar a symmetry proof for the given relation */
|
||||
expr mk_symm(type_context & ctx, name const & relname, expr const & H);
|
||||
expr mk_eq_symm(type_context & ctx, expr const & H);
|
||||
expr mk_eq_symm(type_context & ctx, expr const & a, expr const & b, expr const & H);
|
||||
expr mk_iff_symm(type_context & ctx, expr const & H);
|
||||
expr mk_heq_symm(type_context & ctx, expr const & H);
|
||||
expr mk_symm(type_context_old & ctx, name const & relname, expr const & H);
|
||||
expr mk_eq_symm(type_context_old & ctx, expr const & H);
|
||||
expr mk_eq_symm(type_context_old & ctx, expr const & a, expr const & b, expr const & H);
|
||||
expr mk_iff_symm(type_context_old & ctx, expr const & H);
|
||||
expr mk_heq_symm(type_context_old & ctx, expr const & H);
|
||||
|
||||
/** \brief Similar a transitivity proof for the given relation */
|
||||
expr mk_trans(type_context & ctx, name const & relname, expr const & H1, expr const & H2);
|
||||
expr mk_eq_trans(type_context & ctx, expr const & H1, expr const & H2);
|
||||
expr mk_eq_trans(type_context & ctx, expr const & a, expr const & b, expr const & c, expr const & H1, expr const & H2);
|
||||
expr mk_iff_trans(type_context & ctx, expr const & H1, expr const & H2);
|
||||
expr mk_heq_trans(type_context & ctx, expr const & H1, expr const & H2);
|
||||
expr mk_trans(type_context_old & ctx, name const & relname, expr const & H1, expr const & H2);
|
||||
expr mk_eq_trans(type_context_old & ctx, expr const & H1, expr const & H2);
|
||||
expr mk_eq_trans(type_context_old & ctx, expr const & a, expr const & b, expr const & c, expr const & H1, expr const & H2);
|
||||
expr mk_iff_trans(type_context_old & ctx, expr const & H1, expr const & H2);
|
||||
expr mk_heq_trans(type_context_old & ctx, expr const & H1, expr const & H2);
|
||||
|
||||
/** \brief Create a (non-dependent) eq.rec application.
|
||||
C is the motive. The expected types for C, H1 and H2 are
|
||||
|
|
@ -113,7 +113,7 @@ expr mk_heq_trans(type_context & ctx, expr const & H1, expr const & H2);
|
|||
H2 : a = b
|
||||
The resultant application is
|
||||
@eq.rec A a C H1 b H2 */
|
||||
expr mk_eq_rec(type_context & ctx, expr const & C, expr const & H1, expr const & H2);
|
||||
expr mk_eq_rec(type_context_old & ctx, expr const & C, expr const & H1, expr const & H2);
|
||||
|
||||
/** \brief Create a (dependent) eq.drec application.
|
||||
C is the motive. The expected types for C, H1 and H2 are
|
||||
|
|
@ -122,79 +122,79 @@ expr mk_eq_rec(type_context & ctx, expr const & C, expr const & H1, expr const &
|
|||
H2 : a = b
|
||||
The resultant application is
|
||||
@eq.drec A a C H1 b H2 */
|
||||
expr mk_eq_drec(type_context & ctx, expr const & C, expr const & H1, expr const & H2);
|
||||
expr mk_eq_drec(type_context_old & ctx, expr const & C, expr const & H1, expr const & H2);
|
||||
|
||||
expr mk_eq_of_heq(type_context & ctx, expr const & H);
|
||||
expr mk_heq_of_eq(type_context & ctx, expr const & H);
|
||||
expr mk_eq_of_heq(type_context_old & ctx, expr const & H);
|
||||
expr mk_heq_of_eq(type_context_old & ctx, expr const & H);
|
||||
|
||||
expr mk_congr_arg(type_context & ctx, expr const & f, expr const & H, bool skip_arrow_test = false);
|
||||
expr mk_congr_fun(type_context & ctx, expr const & H, expr const & a);
|
||||
expr mk_congr(type_context & ctx, expr const & H1, expr const & H2, bool skip_arrow_test = false);
|
||||
expr mk_congr_arg(type_context_old & ctx, expr const & f, expr const & H, bool skip_arrow_test = false);
|
||||
expr mk_congr_fun(type_context_old & ctx, expr const & H, expr const & a);
|
||||
expr mk_congr(type_context_old & ctx, expr const & H1, expr const & H2, bool skip_arrow_test = false);
|
||||
|
||||
expr mk_funext(type_context & ctx, expr const & lam_pf);
|
||||
expr mk_funext(type_context_old & ctx, expr const & lam_pf);
|
||||
|
||||
/** \brief Given a reflexive relation R, and a proof H : a = b,
|
||||
build a proof for (R a b) */
|
||||
expr lift_from_eq(type_context & ctx, name const & R, expr const & H);
|
||||
expr lift_from_eq(type_context_old & ctx, name const & R, expr const & H);
|
||||
|
||||
/** \brief not p -> (p <-> false) */
|
||||
expr mk_iff_false_intro(type_context & ctx, expr const & H);
|
||||
expr mk_iff_false_intro(type_context_old & ctx, expr const & H);
|
||||
/** \brief p -> (p <-> true) */
|
||||
expr mk_iff_true_intro(type_context & ctx, expr const & H);
|
||||
expr mk_iff_true_intro(type_context_old & ctx, expr const & H);
|
||||
/** \brief (p <-> false) -> not p */
|
||||
expr mk_not_of_iff_false(type_context & ctx, expr const & H);
|
||||
expr mk_not_of_iff_false(type_context_old & ctx, expr const & H);
|
||||
/** \brief (p <-> true) -> p */
|
||||
expr mk_of_iff_true(type_context & ctx, expr const & H);
|
||||
expr mk_of_iff_true(type_context_old & ctx, expr const & H);
|
||||
/** \brief (true <-> false) -> false */
|
||||
expr mk_false_of_true_iff_false(type_context & ctx, expr const & H);
|
||||
expr mk_false_of_true_iff_false(type_context_old & ctx, expr const & H);
|
||||
/** \brief (true = false) -> false */
|
||||
expr mk_false_of_true_eq_false(type_context & ctx, expr const & H);
|
||||
expr mk_false_of_true_eq_false(type_context_old & ctx, expr const & H);
|
||||
|
||||
/** \brief not p -> (p = false) */
|
||||
expr mk_eq_false_intro(type_context & ctx, expr const & H);
|
||||
expr mk_eq_false_intro(type_context_old & ctx, expr const & H);
|
||||
/** \brief p -> (p = true) */
|
||||
expr mk_eq_true_intro(type_context & ctx, expr const & H);
|
||||
expr mk_eq_true_intro(type_context_old & ctx, expr const & H);
|
||||
/** not(p <-> q) -> not(p = q) */
|
||||
expr mk_neq_of_not_iff(type_context & ctx, expr const & H);
|
||||
expr mk_neq_of_not_iff(type_context_old & ctx, expr const & H);
|
||||
|
||||
expr mk_of_eq_true(type_context & ctx, expr const & H);
|
||||
expr mk_not_of_eq_false(type_context & ctx, expr const & H);
|
||||
expr mk_of_eq_true(type_context_old & ctx, expr const & H);
|
||||
expr mk_not_of_eq_false(type_context_old & ctx, expr const & H);
|
||||
|
||||
expr mk_not(type_context & ctx, expr const & H);
|
||||
expr mk_not(type_context_old & ctx, expr const & H);
|
||||
|
||||
/** p -> not p -> b */
|
||||
expr mk_absurd(type_context & ctx, expr const & Hp, expr const & Hnp, expr const & b);
|
||||
expr mk_absurd(type_context_old & ctx, expr const & Hp, expr const & Hnp, expr const & b);
|
||||
|
||||
expr mk_partial_add(type_context & ctx, expr const & A);
|
||||
expr mk_partial_mul(type_context & ctx, expr const & A);
|
||||
expr mk_zero(type_context & ctx, expr const & A);
|
||||
expr mk_one(type_context & ctx, expr const & A);
|
||||
expr mk_partial_left_distrib(type_context & ctx, expr const & A);
|
||||
expr mk_partial_right_distrib(type_context & ctx, expr const & A);
|
||||
expr mk_partial_add(type_context_old & ctx, expr const & A);
|
||||
expr mk_partial_mul(type_context_old & ctx, expr const & A);
|
||||
expr mk_zero(type_context_old & ctx, expr const & A);
|
||||
expr mk_one(type_context_old & ctx, expr const & A);
|
||||
expr mk_partial_left_distrib(type_context_old & ctx, expr const & A);
|
||||
expr mk_partial_right_distrib(type_context_old & ctx, expr const & A);
|
||||
|
||||
expr mk_ss_elim(type_context & ctx, expr const & A, expr const & ss_inst, expr const & old_e, expr const & new_e);
|
||||
expr mk_ss_elim(type_context_old & ctx, expr const & A, expr const & ss_inst, expr const & old_e, expr const & new_e);
|
||||
|
||||
/** \brief False elimination */
|
||||
expr mk_false_rec(type_context & ctx, expr const & c, expr const & H);
|
||||
expr mk_false_rec(type_context_old & ctx, expr const & c, expr const & H);
|
||||
|
||||
/* (if c then t else e) */
|
||||
expr mk_ite(type_context & ctx, expr const & c, expr const & t, expr const & e);
|
||||
expr mk_ite(type_context_old & ctx, expr const & c, expr const & t, expr const & e);
|
||||
|
||||
/* (@id type h) */
|
||||
expr mk_id(type_context & ctx, expr const & type, expr const & h);
|
||||
expr mk_id(type_context_old & ctx, expr const & type, expr const & h);
|
||||
/* (id h) */
|
||||
expr mk_id(type_context & ctx, expr const & h);
|
||||
expr mk_id(type_context_old & ctx, expr const & h);
|
||||
|
||||
/* (id_rhs h) */
|
||||
expr mk_id_rhs(type_context & ctx, expr const & h);
|
||||
expr mk_id_rhs(type_context_old & ctx, expr const & h);
|
||||
|
||||
/* (id_delta h) */
|
||||
expr mk_id_delta(type_context & ctx, expr const & h);
|
||||
expr mk_id_delta(type_context_old & ctx, expr const & h);
|
||||
|
||||
expr mk_iff_mp(type_context & ctx, expr const & h1, expr const & h2);
|
||||
expr mk_iff_mpr(type_context & ctx, expr const & h1, expr const & h2);
|
||||
expr mk_eq_mp(type_context & ctx, expr const & h1, expr const & h2);
|
||||
expr mk_eq_mpr(type_context & ctx, expr const & h1, expr const & h2);
|
||||
expr mk_iff_mp(type_context_old & ctx, expr const & h1, expr const & h2);
|
||||
expr mk_iff_mpr(type_context_old & ctx, expr const & h1, expr const & h2);
|
||||
expr mk_eq_mp(type_context_old & ctx, expr const & h1, expr const & h2);
|
||||
expr mk_eq_mpr(type_context_old & ctx, expr const & h1, expr const & h2);
|
||||
|
||||
void initialize_app_builder();
|
||||
void finalize_app_builder();
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ arith_instance_info_ptr mk_arith_instance_info(expr const & type, level const &
|
|||
return std::make_shared<arith_instance_info>(type, lvl);
|
||||
}
|
||||
|
||||
arith_instance::arith_instance(type_context & ctx, expr const & type, level const & level):
|
||||
arith_instance::arith_instance(type_context_old & ctx, expr const & type, level const & level):
|
||||
m_ctx(&ctx), m_info(mk_arith_instance_info(type, level)) {}
|
||||
|
||||
arith_instance::arith_instance(type_context & ctx, expr const & type):
|
||||
arith_instance::arith_instance(type_context_old & ctx, expr const & type):
|
||||
m_ctx(&ctx) {
|
||||
set_type(type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ typedef std::shared_ptr<arith_instance_info> arith_instance_info_ptr;
|
|||
arith_instance_info_ptr mk_arith_instance_info(expr const & type, level const & lvl);
|
||||
|
||||
class arith_instance {
|
||||
type_context * m_ctx;
|
||||
type_context_old * m_ctx;
|
||||
arith_instance_info_ptr m_info;
|
||||
|
||||
expr mk_structure(name const & s, optional<expr> & r);
|
||||
|
|
@ -79,11 +79,11 @@ class arith_instance {
|
|||
expr mk_pos_num(mpz const & n);
|
||||
|
||||
public:
|
||||
arith_instance(type_context & ctx, arith_instance_info_ptr const & info):m_ctx(&ctx), m_info(info) {}
|
||||
arith_instance(type_context & ctx, expr const & type, level const & level);
|
||||
arith_instance(type_context & ctx, expr const & type);
|
||||
arith_instance(type_context_old & ctx, arith_instance_info_ptr const & info):m_ctx(&ctx), m_info(info) {}
|
||||
arith_instance(type_context_old & ctx, expr const & type, level const & level);
|
||||
arith_instance(type_context_old & ctx, expr const & type);
|
||||
arith_instance(arith_instance_info_ptr const & info):m_ctx(nullptr), m_info(info) {}
|
||||
arith_instance(type_context & ctx):m_ctx(&ctx) {}
|
||||
arith_instance(type_context_old & ctx):m_ctx(&ctx) {}
|
||||
|
||||
void set_info(arith_instance_info_ptr const & info) { m_info = info; }
|
||||
/* The following method creates a fresh `arith_instance_info` for the given type.
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ buffer<expr> const & closure_helper::get_norm_closure_params() const {
|
|||
}
|
||||
|
||||
struct mk_aux_definition_fn : public closure_helper {
|
||||
mk_aux_definition_fn(type_context & ctx):closure_helper(ctx) {}
|
||||
mk_aux_definition_fn(type_context_old & ctx):closure_helper(ctx) {}
|
||||
|
||||
pair<environment, expr> operator()(name const & c, expr const & type, expr const & value, bool is_lemma, optional<bool> const & is_meta) {
|
||||
lean_assert(!is_lemma || is_meta);
|
||||
|
|
@ -189,14 +189,14 @@ struct mk_aux_definition_fn : public closure_helper {
|
|||
|
||||
pair<environment, expr> mk_aux_definition(environment const & env, metavar_context const & mctx, local_context const & lctx,
|
||||
name const & c, expr const & type, expr const & value, optional<bool> const & is_meta) {
|
||||
type_context ctx(env, options(), mctx, lctx, transparency_mode::All);
|
||||
type_context_old ctx(env, options(), mctx, lctx, transparency_mode::All);
|
||||
bool is_lemma = false;
|
||||
return mk_aux_definition_fn(ctx)(c, type, value, is_lemma, is_meta);
|
||||
}
|
||||
|
||||
pair<environment, expr> mk_aux_definition(environment const & env, metavar_context const & mctx, local_context const & lctx,
|
||||
name const & c, expr const & value, optional<bool> const & is_meta) {
|
||||
type_context ctx(env, options(), mctx, lctx, transparency_mode::All);
|
||||
type_context_old ctx(env, options(), mctx, lctx, transparency_mode::All);
|
||||
expr type = ctx.infer(value);
|
||||
bool is_lemma = false;
|
||||
return mk_aux_definition_fn(ctx)(c, type, value, is_lemma, is_meta);
|
||||
|
|
@ -204,7 +204,7 @@ pair<environment, expr> mk_aux_definition(environment const & env, metavar_conte
|
|||
|
||||
pair<environment, expr> mk_aux_lemma(environment const & env, metavar_context const & mctx, local_context const & lctx,
|
||||
name const & c, expr const & type, expr const & value) {
|
||||
type_context ctx(env, options(), mctx, lctx, transparency_mode::All);
|
||||
type_context_old ctx(env, options(), mctx, lctx, transparency_mode::All);
|
||||
bool is_lemma = true;
|
||||
optional<bool> is_meta(false);
|
||||
return mk_aux_definition_fn(ctx)(c, type, value, is_lemma, is_meta);
|
||||
|
|
@ -214,7 +214,7 @@ struct abstract_nested_proofs_fn : public replace_visitor_with_tc {
|
|||
name m_base_name;
|
||||
unsigned m_idx{1};
|
||||
|
||||
abstract_nested_proofs_fn(type_context & ctx, name const & b):
|
||||
abstract_nested_proofs_fn(type_context_old & ctx, name const & b):
|
||||
replace_visitor_with_tc(ctx),
|
||||
m_base_name(b, "_proof") {
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ struct abstract_nested_proofs_fn : public replace_visitor_with_tc {
|
|||
};
|
||||
|
||||
pair<environment, expr> abstract_nested_proofs(environment const & env, metavar_context const & mctx, local_context const & lctx, name const & base_name, expr const & e) {
|
||||
type_context ctx(env, options(), mctx, lctx, transparency_mode::Semireducible);
|
||||
type_context_old ctx(env, options(), mctx, lctx, transparency_mode::Semireducible);
|
||||
return abstract_nested_proofs_fn(ctx, base_name)(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace lean {
|
|||
All new parameters are sorted based on dependencies.
|
||||
*/
|
||||
class closure_helper {
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
name m_prefix;
|
||||
unsigned m_next_idx;
|
||||
name_set m_found_univ_params;
|
||||
|
|
@ -43,12 +43,12 @@ class closure_helper {
|
|||
buffer<expr> m_norm_params;
|
||||
|
||||
public:
|
||||
closure_helper(type_context & ctx):
|
||||
closure_helper(type_context_old & ctx):
|
||||
m_ctx(ctx),
|
||||
m_prefix("_aux_param"),
|
||||
m_next_idx(0) {}
|
||||
|
||||
type_context & ctx() { return m_ctx; }
|
||||
type_context_old & ctx() { return m_ctx; }
|
||||
|
||||
/* \pre finalize_collection has not been invoked */
|
||||
level collect(level const & l);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public:
|
|||
return *m_cache_ptr[midx].get();
|
||||
}
|
||||
|
||||
Cache & get_cache_for(type_context const & ctx) {
|
||||
Cache & get_cache_for(type_context_old const & ctx) {
|
||||
return get_cache_for(ctx.env(), ctx.mode());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Author: Leonardo de Moura
|
|||
|
||||
namespace lean {
|
||||
struct check_fn {
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
expr_struct_set m_visited;
|
||||
|
||||
void visit_constant(expr const & e) {
|
||||
|
|
@ -44,7 +44,7 @@ struct check_fn {
|
|||
}
|
||||
|
||||
void visit_binding(expr const & e, bool is_pi) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr it = e;
|
||||
while (it.kind() == e.kind()) {
|
||||
expr d = instantiate_rev(binding_domain(it), locals.size(), locals.data());
|
||||
|
|
@ -78,7 +78,7 @@ struct check_fn {
|
|||
"(use 'set_option trace.check true' for additional details)");
|
||||
}
|
||||
/* Improve performance if bottleneck */
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr local = locals.push_local_from_let(e);
|
||||
visit(instantiate(let_body(e), local));
|
||||
}
|
||||
|
|
@ -130,11 +130,11 @@ struct check_fn {
|
|||
}
|
||||
|
||||
public:
|
||||
check_fn(type_context & ctx):m_ctx(ctx) {}
|
||||
check_fn(type_context_old & ctx):m_ctx(ctx) {}
|
||||
void operator()(expr const & e) { return visit(e); }
|
||||
};
|
||||
|
||||
void check(type_context & ctx, expr const & e) {
|
||||
void check(type_context_old & ctx, expr const & e) {
|
||||
metavar_context mctx = ctx.mctx();
|
||||
check_fn checker(ctx);
|
||||
checker(e);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace lean {
|
|||
This procedure is use to check the proof-term produced by tactics such as
|
||||
rewrite.
|
||||
*/
|
||||
void check(type_context & ctx, expr const & e);
|
||||
void check(type_context_old & ctx, expr const & e);
|
||||
void initialize_check();
|
||||
void finalize_check();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,9 +254,9 @@ bool has_class_out_params(environment const & env, name const & c) {
|
|||
environment add_instance_core(environment const & env, name const & n, unsigned priority, bool persistent) {
|
||||
declaration d = env.get(n);
|
||||
expr type = d.get_type();
|
||||
type_context ctx(env, transparency_mode::All);
|
||||
type_context_old ctx(env, transparency_mode::All);
|
||||
class_state S = class_ext::get_state(env);
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
while (true) {
|
||||
type = ctx.whnf_head_pred(type, [&](expr const & e) {
|
||||
expr const & fn = get_app_fn(e);
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ optional<expr> mk_int_val_ne_proof(expr const & a, expr const & b) {
|
|||
}
|
||||
}
|
||||
|
||||
optional<expr> mk_val_ne_proof(type_context & ctx, expr const & a, expr const & b) {
|
||||
optional<expr> mk_val_ne_proof(type_context_old & ctx, expr const & a, expr const & b) {
|
||||
expr type = ctx.infer(a);
|
||||
if (ctx.is_def_eq(type, mk_nat_type()))
|
||||
return mk_nat_val_ne_proof(a, b);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ optional<expr> mk_int_val_pos_proof(expr const & a);
|
|||
optional<expr> mk_int_val_ne_proof(expr const & a, expr const & b);
|
||||
|
||||
/* Return a proof for a != b, a/b has type nat/int/char/string, and they are distinct values. */
|
||||
optional<expr> mk_val_ne_proof(type_context & ctx, expr const & a, expr const & b);
|
||||
optional<expr> mk_val_ne_proof(type_context_old & ctx, expr const & a, expr const & b);
|
||||
|
||||
void initialize_comp_val();
|
||||
void finalize_comp_val();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Author: Leonardo de Moura
|
|||
#include "kernel/environment.h"
|
||||
|
||||
namespace lean {
|
||||
class type_context;
|
||||
class type_context_old;
|
||||
class abstract_context_cache;
|
||||
/** \brief Mark sub-expressions of \c e that are computationally irrelevant. */
|
||||
expr mark_comp_irrelevant_subterms(environment const & env, abstract_context_cache & cache, expr const & e);
|
||||
|
|
@ -17,7 +17,7 @@ expr mark_comp_irrelevant(expr const & e);
|
|||
/** \brief Return true iff \c e is annotated with the comp-irrelevant annotation */
|
||||
bool is_marked_as_comp_irrelevant(expr const & e);
|
||||
/** \brief Return true iff the type of \c e is a sort or a proposition */
|
||||
bool is_comp_irrelevant(type_context & ctx, expr const & e);
|
||||
bool is_comp_irrelevant(type_context_old & ctx, expr const & e);
|
||||
void initialize_comp_irrelevant();
|
||||
void finalize_comp_irrelevant();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ compiler_step_visitor::~compiler_step_visitor() {
|
|||
}
|
||||
|
||||
expr compiler_step_visitor::visit_lambda_let(expr const & e) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr t = e;
|
||||
while (true) {
|
||||
/* Types are ignored in compilation steps. So, we do not invoke visit for d. */
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace lean {
|
|||
class compiler_step_visitor : public replace_visitor {
|
||||
protected:
|
||||
environment m_env;
|
||||
type_context m_ctx;
|
||||
type_context_old m_ctx;
|
||||
|
||||
expr visit_lambda_let(expr const & e);
|
||||
protected:
|
||||
|
|
@ -22,7 +22,7 @@ protected:
|
|||
virtual ~compiler_step_visitor();
|
||||
|
||||
environment const & env() const { return m_env; }
|
||||
type_context & ctx() { return m_ctx; }
|
||||
type_context_old & ctx() { return m_ctx; }
|
||||
|
||||
virtual expr visit_macro(expr const & e) override;
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ protected:
|
|||
}
|
||||
|
||||
virtual expr visit_local(expr const & e) override {
|
||||
/* We don't need to visit the type since we are using type_context. */
|
||||
/* We don't need to visit the type since we are using type_context_old. */
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,10 +159,10 @@ class cse_fn : public compiler_step_visitor {
|
|||
unsigned & m_counter;
|
||||
expr_struct_set const & m_common_subexprs;
|
||||
expr_struct_map<expr> m_common_subexpr_to_local;
|
||||
type_context::tmp_locals m_all_locals; /* new local declarations, it also include let-decls for common-subexprs */
|
||||
type_context_old::tmp_locals m_all_locals; /* new local declarations, it also include let-decls for common-subexprs */
|
||||
local_context const & m_lctx;
|
||||
|
||||
cse_processor(unsigned & counter, type_context & ctx, expr_struct_set const & s):
|
||||
cse_processor(unsigned & counter, type_context_old & ctx, expr_struct_set const & s):
|
||||
m_counter(counter),
|
||||
m_common_subexprs(s),
|
||||
m_all_locals(ctx),
|
||||
|
|
@ -197,10 +197,10 @@ class cse_fn : public compiler_step_visitor {
|
|||
|
||||
/* Similar to cse_processor, but has support for binding exprs (lambda and let) */
|
||||
struct cse_processor_for_binding : public cse_processor {
|
||||
type_context::tmp_locals const & m_locals;
|
||||
type_context_old::tmp_locals const & m_locals;
|
||||
buffer<expr> m_new_locals;
|
||||
|
||||
cse_processor_for_binding(unsigned & counter, type_context & ctx, type_context::tmp_locals const & locals, expr_struct_set const & s):
|
||||
cse_processor_for_binding(unsigned & counter, type_context_old & ctx, type_context_old::tmp_locals const & locals, expr_struct_set const & s):
|
||||
cse_processor(counter, ctx, s),
|
||||
m_locals(locals) {
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ class cse_fn : public compiler_step_visitor {
|
|||
};
|
||||
|
||||
expr visit_lambda_let(expr const & e) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr t = e;
|
||||
buffer<expr> let_values;
|
||||
while (true) {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
expr consume_lambdas(type_context::tmp_locals & locals, expr e) {
|
||||
expr consume_lambdas(type_context_old::tmp_locals & locals, expr e) {
|
||||
while (true) {
|
||||
expr new_e = ctx().whnf(e);
|
||||
if (is_lambda(new_e)) {
|
||||
|
|
@ -118,7 +118,7 @@ protected:
|
|||
/* Create new locals for aux.
|
||||
The operating abstract_locals creates a lambda-abstraction around aux if it uses
|
||||
local constants. */
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
buffer<expr> aux_decl_params; /* "fixed" parameters of the auxiliary recursive declaration. */
|
||||
expr aux_body = aux;
|
||||
while (is_lambda(aux_body)) {
|
||||
|
|
@ -175,7 +175,7 @@ protected:
|
|||
unsigned carity = get_constructor_arity(env(), cnames[i]);
|
||||
expr minor = aux_body_args[first_minor_idx + i];
|
||||
// tout() << ">> minor: " << minor << "\n";
|
||||
type_context::tmp_locals minor_locals(m_ctx);
|
||||
type_context_old::tmp_locals minor_locals(m_ctx);
|
||||
buffer<expr> minor_recs; /* "recursive calls" */
|
||||
lean_assert(carity >= nparams);
|
||||
buffer<bool> rec_mask;
|
||||
|
|
@ -186,7 +186,7 @@ protected:
|
|||
expr minor_local = minor_locals.push_local_from_binding(minor);
|
||||
minor = instantiate(binding_body(minor), minor_local);
|
||||
/* Check if minor_local is recursive data */
|
||||
type_context::tmp_locals aux_locals(m_ctx);
|
||||
type_context_old::tmp_locals aux_locals(m_ctx);
|
||||
expr minor_local_type = ctx().whnf(ctx().infer(minor_local));
|
||||
// tout() << ">>> minor_local_type: " << minor_local_type << "\n";
|
||||
while (is_pi(minor_local_type)) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ Author: Leonardo de Moura
|
|||
namespace lean {
|
||||
class elim_unused_lets_fn : public compiler_step_visitor {
|
||||
virtual expr visit_lambda(expr const & e) override {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr t = e;
|
||||
while (is_lambda(t)) {
|
||||
expr d = instantiate_rev(binding_domain(t), locals.size(), locals.data());
|
||||
|
|
@ -25,7 +25,7 @@ class elim_unused_lets_fn : public compiler_step_visitor {
|
|||
}
|
||||
|
||||
virtual expr visit_let(expr const & e) override {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
collected_locals used_locals;
|
||||
expr t = e;
|
||||
while (is_let(t)) {
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class erase_irrelevant_fn : public compiler_step_visitor {
|
|||
unsigned carity = get_constructor_arity(env(), cnames[i]);
|
||||
lean_assert(carity >= nparams);
|
||||
unsigned data_sz = carity - nparams;
|
||||
type_context::tmp_locals locals(ctx());
|
||||
type_context_old::tmp_locals locals(ctx());
|
||||
expr new_minor = minors[i];
|
||||
for (unsigned j = 0; j < data_sz; j++) {
|
||||
if (!is_lambda(new_minor))
|
||||
|
|
@ -242,7 +242,7 @@ class erase_irrelevant_fn : public compiler_step_visitor {
|
|||
return add_args(major, 6, args);
|
||||
}
|
||||
|
||||
expr consume_lambdas(type_context::tmp_locals & locals, expr e) {
|
||||
expr consume_lambdas(type_context_old::tmp_locals & locals, expr e) {
|
||||
while (true) {
|
||||
if (is_lambda(e)) {
|
||||
expr local = locals.push_local_from_binding(e);
|
||||
|
|
@ -272,7 +272,7 @@ class erase_irrelevant_fn : public compiler_step_visitor {
|
|||
return *g_unreachable_expr;
|
||||
lean_assert(args.size() >= basic_arity + 1);
|
||||
expr major = args[nparams + nindices + 4];
|
||||
type_context::tmp_locals locals(ctx());
|
||||
type_context_old::tmp_locals locals(ctx());
|
||||
major = consume_lambdas(locals, major);
|
||||
major = visit(major);
|
||||
major = erase_lambda_let_types(locals.mk_lambda(major));
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class eta_expand_fn : public compiler_step_visitor {
|
|||
expr type = ctx().relaxed_whnf(ctx().infer(e));
|
||||
if (!is_pi(type))
|
||||
return false;
|
||||
type_context::tmp_locals locals(ctx());
|
||||
type_context_old::tmp_locals locals(ctx());
|
||||
while (is_pi(type)) {
|
||||
expr local = locals.push_local_from_binding(type);
|
||||
type = ctx().relaxed_whnf(instantiate(binding_body(type), local));
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class inline_simple_definitions_fn : public compiler_step_visitor {
|
|||
|
||||
optional<expr> reduce_projection(expr const & e) {
|
||||
/* When trying to reduce a projection, we should only unfold reducible constants. */
|
||||
type_context::transparency_scope _(ctx(), transparency_mode::Instances);
|
||||
type_context_old::transparency_scope _(ctx(), transparency_mode::Instances);
|
||||
return ctx().reduce_projection(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class lambda_lifting_fn : public compiler_step_visitor {
|
|||
}
|
||||
|
||||
expr visit_lambda_core(expr const & e) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr t = e;
|
||||
while (is_lambda(t)) {
|
||||
lean_assert(is_neutral_expr(binding_domain(t)) || closed(binding_domain(t)));
|
||||
|
|
@ -135,7 +135,7 @@ class lambda_lifting_fn : public compiler_step_visitor {
|
|||
}
|
||||
|
||||
virtual expr visit_let(expr const & e) override {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr t = e;
|
||||
while (is_let(t)) {
|
||||
lean_assert(is_neutral_expr(let_type(t)) || closed(let_type(t)));
|
||||
|
|
@ -149,7 +149,7 @@ class lambda_lifting_fn : public compiler_step_visitor {
|
|||
}
|
||||
|
||||
expr visit_cases_on_minor(unsigned data_sz, expr e) {
|
||||
type_context::tmp_locals locals(ctx());
|
||||
type_context_old::tmp_locals locals(ctx());
|
||||
for (unsigned i = 0; i < data_sz; i++) {
|
||||
if (is_lambda(e)) {
|
||||
expr l = locals.push_local_from_binding(e);
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ mpz const & get_nat_value_value(expr const & e) {
|
|||
return static_cast<nat_value_macro const *>(macro_def(e).raw())->get_value();
|
||||
}
|
||||
|
||||
optional<expr> to_nat_value(type_context & ctx, expr const & e) {
|
||||
optional<expr> to_nat_value(type_context_old & ctx, expr const & e) {
|
||||
if (optional<mpz> v = to_num(e)) {
|
||||
expr type = ctx.whnf(ctx.infer(e));
|
||||
if (is_nat_type(type)) {
|
||||
|
|
@ -98,11 +98,11 @@ class find_nat_values_fn : public replace_visitor_with_tc {
|
|||
return replace_visitor_with_tc::visit_app(e);
|
||||
}
|
||||
public:
|
||||
find_nat_values_fn(type_context & ctx):replace_visitor_with_tc(ctx) {}
|
||||
find_nat_values_fn(type_context_old & ctx):replace_visitor_with_tc(ctx) {}
|
||||
};
|
||||
|
||||
expr find_nat_values(environment const & env, expr const & e) {
|
||||
type_context ctx(env, transparency_mode::All);
|
||||
type_context_old ctx(env, transparency_mode::All);
|
||||
return find_nat_values_fn(ctx)(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ bool is_nat_value(expr const & e);
|
|||
mpz const & get_nat_value_value(expr const & e);
|
||||
|
||||
/** \brief If \c e encodes a nat numeral, then convert it into a nat_value macro */
|
||||
optional<expr> to_nat_value(type_context & ctx, expr const & e);
|
||||
optional<expr> to_nat_value(type_context_old & ctx, expr const & e);
|
||||
|
||||
void initialize_nat_value();
|
||||
void finalize_nat_value();
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class expand_aux_fn : public compiler_step_visitor {
|
|||
expr visit_cases_on(expr const & e) {
|
||||
/* Try to reduce cases_on.
|
||||
Remark: we only unfold reducible constants. */
|
||||
type_context::transparency_scope scope(ctx(), transparency_mode::Reducible);
|
||||
type_context_old::transparency_scope scope(ctx(), transparency_mode::Reducible);
|
||||
if (auto r1 = ctx().reduce_aux_recursor(e)) {
|
||||
if (auto r2 = ctx().norm_ext(*r1)) {
|
||||
return compiler_step_visitor::visit(*r2);
|
||||
|
|
@ -113,7 +113,7 @@ class expand_aux_fn : public compiler_step_visitor {
|
|||
}
|
||||
|
||||
virtual expr visit_constant(expr const & e) override {
|
||||
type_context::nozeta_scope scope(ctx());
|
||||
type_context_old::nozeta_scope scope(ctx());
|
||||
if (should_unfold(e))
|
||||
return visit(unfold(e));
|
||||
else
|
||||
|
|
@ -121,14 +121,14 @@ class expand_aux_fn : public compiler_step_visitor {
|
|||
}
|
||||
|
||||
virtual expr visit_app(expr const & e) override {
|
||||
type_context::nozeta_scope scope(ctx());
|
||||
type_context_old::nozeta_scope scope(ctx());
|
||||
switch (get_recursor_app_kind(e)) {
|
||||
case recursor_kind::NotRecursor: {
|
||||
if (should_unfold(e))
|
||||
return visit(unfold(e));
|
||||
expr new_e;
|
||||
{
|
||||
type_context::transparency_scope scope(ctx(), transparency_mode::Reducible);
|
||||
type_context_old::transparency_scope scope(ctx(), transparency_mode::Reducible);
|
||||
new_e = copy_tag(e, ctx().whnf_head_pred(e, [&](expr const &) { return false; }));
|
||||
}
|
||||
if (is_eqp(new_e, e))
|
||||
|
|
@ -141,7 +141,7 @@ class expand_aux_fn : public compiler_step_visitor {
|
|||
case recursor_kind::Aux:
|
||||
expr new_e;
|
||||
{
|
||||
type_context::transparency_scope scope(ctx(), transparency_mode::Reducible);
|
||||
type_context_old::transparency_scope scope(ctx(), transparency_mode::Reducible);
|
||||
new_e = copy_tag(e, ctx().whnf_head_pred(e, [&](expr const & e) { return is_aux_recursor(e); }));
|
||||
}
|
||||
return compiler_step_visitor::visit(new_e);
|
||||
|
|
@ -210,9 +210,9 @@ class preprocess_fn {
|
|||
This procedure returns true if type of d is a proposition or return a type,
|
||||
and store the dummy code above in */
|
||||
bool compile_irrelevant(declaration const & d, buffer<procedure> & procs) {
|
||||
type_context ctx(m_env, transparency_mode::All);
|
||||
type_context_old ctx(m_env, transparency_mode::All);
|
||||
expr type = d.get_type();
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
while (true) {
|
||||
type = ctx.relaxed_whnf(type);
|
||||
if (!is_pi(type))
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class simp_inductive_core_fn : public compiler_step_visitor {
|
|||
protected:
|
||||
/* Return new minor premise and a flag indicating whether the body is unreachable or not */
|
||||
pair<expr, bool> visit_minor_premise(expr e, buffer<bool> const & rel_fields) {
|
||||
type_context::tmp_locals locals(ctx());
|
||||
type_context_old::tmp_locals locals(ctx());
|
||||
for (unsigned i = 0; i < rel_fields.size(); i++) {
|
||||
lean_assert(is_lambda(e));
|
||||
if (rel_fields[i]) {
|
||||
|
|
@ -251,7 +251,7 @@ class simp_inductive_fn : public simp_inductive_core_fn {
|
|||
for (unsigned i = 0; i < cnames.size(); i++) {
|
||||
unsigned carity = get_constructor_arity(env(), cnames[i]);
|
||||
unsigned data_sz = carity - nparams;
|
||||
type_context::tmp_locals locals(ctx());
|
||||
type_context_old::tmp_locals locals(ctx());
|
||||
expr new_minor = args[i+1];
|
||||
for (unsigned j = 0; j < data_sz; j++) {
|
||||
if (!is_lambda(new_minor))
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ name mk_compiler_unused_name(environment const & env, name const & prefix, char
|
|||
}
|
||||
}
|
||||
|
||||
bool is_comp_irrelevant(type_context & ctx, expr const & e) {
|
||||
bool is_comp_irrelevant(type_context_old & ctx, expr const & e) {
|
||||
expr type = ctx.whnf(ctx.infer(e));
|
||||
return is_sort(type) || ctx.is_prop(type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ Author: Leonardo de Moura
|
|||
#pragma once
|
||||
#include "kernel/environment.h"
|
||||
namespace lean {
|
||||
class type_context;
|
||||
class type_context_old;
|
||||
/** \brief Create a new name of the form prefix.suffix_idx that is not the name of a declaration and/or VM function.
|
||||
It also updates the index idx. */
|
||||
name mk_compiler_unused_name(environment const & env, name const & prefix, char const * suffix, unsigned & idx);
|
||||
|
||||
/** \brief Return true iff \c e is computationally irrelevant */
|
||||
bool is_comp_irrelevant(type_context & ctx, expr const & e);
|
||||
bool is_comp_irrelevant(type_context_old & ctx, expr const & e);
|
||||
|
||||
/** \brief Given an inductive datatype \c n, store in \c r a "bitvector" s.t.
|
||||
r[i][j] is true iff the j-th argument of the i-th minor premise of the recursor \c n.rec
|
||||
|
|
|
|||
|
|
@ -41,17 +41,17 @@ typedef cache_compatibility_helper<congr_lemma_cache> congr_lemma_cache_helper;
|
|||
/* CACHE_RESET: YES */
|
||||
MK_THREAD_LOCAL_GET_DEF(congr_lemma_cache_helper, get_clch);
|
||||
|
||||
congr_lemma_cache & get_congr_lemma_cache_for(type_context const & ctx) {
|
||||
congr_lemma_cache & get_congr_lemma_cache_for(type_context_old const & ctx) {
|
||||
return get_clch().get_cache_for(ctx);
|
||||
}
|
||||
|
||||
struct congr_lemma_manager {
|
||||
typedef expr_unsigned key;
|
||||
typedef congr_lemma result;
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
congr_lemma_cache & m_cache;
|
||||
|
||||
congr_lemma_manager(type_context & ctx):
|
||||
congr_lemma_manager(type_context_old & ctx):
|
||||
m_ctx(ctx), m_cache(get_congr_lemma_cache_for(ctx)) {}
|
||||
|
||||
expr infer(expr const & e) { return m_ctx.infer(e); }
|
||||
|
|
@ -179,7 +179,7 @@ struct congr_lemma_manager {
|
|||
how the resulting term looks like. */
|
||||
optional<result> mk_congr_simp(expr const & fn, buffer<param_info> const & pinfos, buffer<congr_arg_kind> const & kinds) {
|
||||
try {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr fn_type = relaxed_whnf(infer(fn));
|
||||
name e_name("e");
|
||||
buffer<expr> lhss;
|
||||
|
|
@ -253,7 +253,7 @@ struct congr_lemma_manager {
|
|||
optional<result> mk_congr(expr const & fn, optional<result> const & simp_lemma,
|
||||
buffer<param_info> const & pinfos, buffer<congr_arg_kind> const & kinds) {
|
||||
try {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr fn_type1 = whnf(infer(fn));
|
||||
expr fn_type2 = fn_type1;
|
||||
name e_name("e");
|
||||
|
|
@ -484,7 +484,7 @@ struct congr_lemma_manager {
|
|||
} else if (is_heq(type, A, a, B, b)) {
|
||||
return mk_heq_refl(m_ctx, a);
|
||||
} else {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
lean_assert(is_pi(type) && is_pi(binding_body(type)) && is_pi(binding_body(binding_body(type))));
|
||||
expr a = locals.push_local_from_binding(type);
|
||||
type = instantiate(binding_body(type), a);
|
||||
|
|
@ -506,7 +506,7 @@ struct congr_lemma_manager {
|
|||
|
||||
optional<result> mk_hcongr_core(expr const & fn, unsigned nargs) {
|
||||
try {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr fn_type_lhs = relaxed_whnf(infer(fn));
|
||||
expr fn_type_rhs = fn_type_lhs;
|
||||
name e_name("e");
|
||||
|
|
@ -618,35 +618,35 @@ struct congr_lemma_manager {
|
|||
}
|
||||
};
|
||||
|
||||
optional<congr_lemma> mk_congr_simp(type_context & ctx, expr const & fn) {
|
||||
optional<congr_lemma> mk_congr_simp(type_context_old & ctx, expr const & fn) {
|
||||
return congr_lemma_manager(ctx).mk_congr_simp(fn);
|
||||
}
|
||||
|
||||
optional<congr_lemma> mk_congr_simp(type_context & ctx, expr const & fn, unsigned nargs) {
|
||||
optional<congr_lemma> mk_congr_simp(type_context_old & ctx, expr const & fn, unsigned nargs) {
|
||||
return congr_lemma_manager(ctx).mk_congr_simp(fn, nargs);
|
||||
}
|
||||
|
||||
optional<congr_lemma> mk_specialized_congr_simp(type_context & ctx, expr const & a) {
|
||||
optional<congr_lemma> mk_specialized_congr_simp(type_context_old & ctx, expr const & a) {
|
||||
return congr_lemma_manager(ctx).mk_specialized_congr_simp(a);
|
||||
}
|
||||
|
||||
optional<congr_lemma> mk_congr(type_context & ctx, expr const & fn) {
|
||||
optional<congr_lemma> mk_congr(type_context_old & ctx, expr const & fn) {
|
||||
return congr_lemma_manager(ctx).mk_congr(fn);
|
||||
}
|
||||
|
||||
optional<congr_lemma> mk_congr(type_context & ctx, expr const & fn, unsigned nargs) {
|
||||
optional<congr_lemma> mk_congr(type_context_old & ctx, expr const & fn, unsigned nargs) {
|
||||
return congr_lemma_manager(ctx).mk_congr(fn, nargs);
|
||||
}
|
||||
|
||||
optional<congr_lemma> mk_specialized_congr(type_context & ctx, expr const & a) {
|
||||
optional<congr_lemma> mk_specialized_congr(type_context_old & ctx, expr const & a) {
|
||||
return congr_lemma_manager(ctx).mk_specialized_congr(a);
|
||||
}
|
||||
|
||||
optional<congr_lemma> mk_hcongr(type_context & ctx, expr const & fn) {
|
||||
optional<congr_lemma> mk_hcongr(type_context_old & ctx, expr const & fn) {
|
||||
return congr_lemma_manager(ctx).mk_hcongr(fn);
|
||||
}
|
||||
|
||||
optional<congr_lemma> mk_hcongr(type_context & ctx, expr const & fn, unsigned nargs) {
|
||||
optional<congr_lemma> mk_hcongr(type_context_old & ctx, expr const & fn, unsigned nargs) {
|
||||
return congr_lemma_manager(ctx).mk_hcongr(fn, nargs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Author: Leonardo de Moura
|
|||
#include "kernel/expr.h"
|
||||
|
||||
namespace lean {
|
||||
class type_context;
|
||||
class type_context_old;
|
||||
|
||||
enum class congr_arg_kind {
|
||||
/* It is a parameter for the congruence lemma, the parameter occurs in the left and right hand sides. */
|
||||
|
|
@ -40,18 +40,18 @@ public:
|
|||
bool all_eq_kind() const;
|
||||
};
|
||||
|
||||
optional<congr_lemma> mk_congr_simp(type_context & ctx, expr const & fn);
|
||||
optional<congr_lemma> mk_congr_simp(type_context & ctx, expr const & fn, unsigned nargs);
|
||||
optional<congr_lemma> mk_congr_simp(type_context_old & ctx, expr const & fn);
|
||||
optional<congr_lemma> mk_congr_simp(type_context_old & ctx, expr const & fn, unsigned nargs);
|
||||
/* Create a specialized theorem using (a prefix of) the arguments of the given application. */
|
||||
optional<congr_lemma> mk_specialized_congr_simp(type_context & ctx, expr const & a);
|
||||
optional<congr_lemma> mk_specialized_congr_simp(type_context_old & ctx, expr const & a);
|
||||
|
||||
optional<congr_lemma> mk_congr(type_context & ctx, expr const & fn);
|
||||
optional<congr_lemma> mk_congr(type_context & ctx, expr const & fn, unsigned nargs);
|
||||
optional<congr_lemma> mk_congr(type_context_old & ctx, expr const & fn);
|
||||
optional<congr_lemma> mk_congr(type_context_old & ctx, expr const & fn, unsigned nargs);
|
||||
/* Create a specialized theorem using (a prefix of) the arguments of the given application. */
|
||||
optional<congr_lemma> mk_specialized_congr(type_context & ctx, expr const & a);
|
||||
optional<congr_lemma> mk_specialized_congr(type_context_old & ctx, expr const & a);
|
||||
|
||||
optional<congr_lemma> mk_hcongr(type_context & ctx, expr const & fn);
|
||||
optional<congr_lemma> mk_hcongr(type_context & ctx, expr const & fn, unsigned nargs);
|
||||
optional<congr_lemma> mk_hcongr(type_context_old & ctx, expr const & fn);
|
||||
optional<congr_lemma> mk_hcongr(type_context_old & ctx, expr const & fn, unsigned nargs);
|
||||
|
||||
void initialize_congr_lemma();
|
||||
void finalize_congr_lemma();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Author: Leonardo de Moura
|
|||
#include "library/inductive_compiler/ginductive.h"
|
||||
|
||||
namespace lean {
|
||||
optional<expr> mk_constructor_eq_constructor_inconsistency_proof(type_context & ctx, expr const & e1, expr const & e2, expr const & h) {
|
||||
optional<expr> mk_constructor_eq_constructor_inconsistency_proof(type_context_old & ctx, expr const & e1, expr const & e2, expr const & h) {
|
||||
environment const & env = ctx.env();
|
||||
optional<name> c1 = is_gintro_rule_app(env, e1);
|
||||
if (!c1) return none_expr();
|
||||
|
|
@ -28,8 +28,8 @@ optional<expr> mk_constructor_eq_constructor_inconsistency_proof(type_context &
|
|||
return some_expr(pr);
|
||||
}
|
||||
|
||||
optional<expr> mk_constructor_ne_constructor_proof(type_context & ctx, expr const & e1, expr const & e2) {
|
||||
type_context::tmp_locals locals(ctx);
|
||||
optional<expr> mk_constructor_ne_constructor_proof(type_context_old & ctx, expr const & e1, expr const & e2) {
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
expr h = locals.push_local("_h", mk_eq(ctx, e1, e2));
|
||||
if (optional<expr> pr = mk_constructor_eq_constructor_inconsistency_proof(ctx, e1, e2, h))
|
||||
return some_expr(locals.mk_lambda(*pr));
|
||||
|
|
@ -37,7 +37,7 @@ optional<expr> mk_constructor_ne_constructor_proof(type_context & ctx, expr cons
|
|||
return none_expr();
|
||||
}
|
||||
|
||||
optional<expr> mk_constructor_eq_constructor_implied_core(type_context & ctx, expr const & e1, expr const & e2, expr const & h, buffer<expr_pair> & implied_pairs) {
|
||||
optional<expr> mk_constructor_eq_constructor_implied_core(type_context_old & ctx, expr const & e1, expr const & e2, expr const & h, buffer<expr_pair> & implied_pairs) {
|
||||
// TODO(Leo, Daniel): add support for generalized inductive datatypes
|
||||
// TODO(Leo): add a definition for this proof at inductive datatype declaration time?
|
||||
environment const & env = ctx.env();
|
||||
|
|
@ -88,7 +88,7 @@ optional<expr> mk_constructor_eq_constructor_implied_core(type_context & ctx, ex
|
|||
expr nct = ctx.relaxed_whnf(mk_app(ctx, nct_name, motive, e1, e2));
|
||||
if (!is_pi(nct)) return none_expr();
|
||||
expr it = binding_domain(nct);
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
buffer<expr> eq_proofs;
|
||||
for (unsigned i = 0; i < num_new_eqs; i++) {
|
||||
/* Remark: some of the hypotheses are heterogeneous, we should convert them
|
||||
|
|
@ -113,7 +113,7 @@ optional<expr> mk_constructor_eq_constructor_implied_core(type_context & ctx, ex
|
|||
return some_expr(mk_app(result_prefix, fun));
|
||||
}
|
||||
|
||||
bool mk_constructor_eq_constructor_implied_eqs(type_context & ctx, expr const & e1, expr const & e2, expr const & h, buffer<std::tuple<expr, expr, expr>> & result) {
|
||||
bool mk_constructor_eq_constructor_implied_eqs(type_context_old & ctx, expr const & e1, expr const & e2, expr const & h, buffer<std::tuple<expr, expr, expr>> & result) {
|
||||
buffer<expr_pair> implied_pairs;
|
||||
optional<expr> conj_pr = mk_constructor_eq_constructor_implied_core(ctx, e1, e2, h, implied_pairs);
|
||||
if (!conj_pr) return false;
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ Author: Leonardo de Moura
|
|||
namespace lean {
|
||||
/* If e1 and e2 are constructor applications, the constructors are different, and (h : e1 = e2), then
|
||||
return a proof for false. */
|
||||
optional<expr> mk_constructor_eq_constructor_inconsistency_proof(type_context & ctx, expr const & e1, expr const & e2, expr const & h);
|
||||
optional<expr> mk_constructor_eq_constructor_inconsistency_proof(type_context_old & ctx, expr const & e1, expr const & e2, expr const & h);
|
||||
|
||||
/* If e1 and e2 are constructor applications, the constructors are different, then
|
||||
return a proof for not (e1 = e2). */
|
||||
optional<expr> mk_constructor_ne_constructor_proof(type_context & ctx, expr const & e1, expr const & e2);
|
||||
optional<expr> mk_constructor_ne_constructor_proof(type_context_old & ctx, expr const & e1, expr const & e2);
|
||||
|
||||
/* If e1 and e2 are constructor applications for the same constructor, and (h : e1 = e2), then
|
||||
return true, and store the triples (a_i, b_i, hab_i) at result, where (hab_i : a_i = b_i)
|
||||
and a_i (b_i) are constructor fields of e1 (e2). */
|
||||
bool mk_constructor_eq_constructor_implied_eqs(type_context & ctx, expr const & e1, expr const & e2, expr const & h,
|
||||
bool mk_constructor_eq_constructor_implied_eqs(type_context_old & ctx, expr const & e1, expr const & e2, expr const & h,
|
||||
buffer<std::tuple<expr, expr, expr>> & result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,13 +66,13 @@ class mk_has_sizeof_fn {
|
|||
return mk_local(m_ngen.next(), n, ty, binder_info());
|
||||
}
|
||||
|
||||
optional<expr> mk_has_sizeof(type_context & ctx, expr const & type) {
|
||||
optional<expr> mk_has_sizeof(type_context_old & ctx, expr const & type) {
|
||||
level l = get_level(ctx, type);
|
||||
expr inst_type = mk_app(mk_constant(get_has_sizeof_name(), {l}), type);
|
||||
return ctx.mk_class_instance(inst_type);
|
||||
}
|
||||
|
||||
optional<expr> build_has_sizeof_argument_type(type_context & ctx, expr const & param) {
|
||||
optional<expr> build_has_sizeof_argument_type(type_context_old & ctx, expr const & param) {
|
||||
expr ty = ctx.relaxed_whnf(ctx.infer(param));
|
||||
buffer<expr> locals;
|
||||
while (is_pi(ty)) {
|
||||
|
|
@ -87,7 +87,7 @@ class mk_has_sizeof_fn {
|
|||
mk_app(param, locals))));
|
||||
}
|
||||
|
||||
optional<expr> is_recursive_arg(type_context & ctx, expr const & arg_ty, buffer<expr> & arg_args) {
|
||||
optional<expr> is_recursive_arg(type_context_old & ctx, expr const & arg_ty, buffer<expr> & arg_args) {
|
||||
expr it = ctx.relaxed_whnf(arg_ty);
|
||||
while (is_pi(it)) {
|
||||
expr arg_arg = mk_local_for(it);
|
||||
|
|
@ -102,7 +102,7 @@ class mk_has_sizeof_fn {
|
|||
}
|
||||
|
||||
void define_instance() {
|
||||
type_context ctx(m_env);
|
||||
type_context_old ctx(m_env);
|
||||
|
||||
auto odecls = inductive::is_inductive_decl(m_env, m_ind_name);
|
||||
if (!odecls)
|
||||
|
|
@ -123,7 +123,7 @@ class mk_has_sizeof_fn {
|
|||
|
||||
name has_sizeof_name = mk_has_sizeof_name(m_ind_name);
|
||||
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
|
||||
buffer<expr> params;
|
||||
buffer<expr> param_insts;
|
||||
|
|
@ -159,7 +159,7 @@ class mk_has_sizeof_fn {
|
|||
{
|
||||
// Create a new type context so that the [has_sizeof] instances are available for type class resolution
|
||||
local_context lctx = ctx.lctx();
|
||||
type_context ctx(m_env, options(), lctx);
|
||||
type_context_old ctx(m_env, options(), lctx);
|
||||
|
||||
expr motive;
|
||||
{
|
||||
|
|
@ -268,9 +268,9 @@ class mk_has_sizeof_fn {
|
|||
m_env = add_protected(m_env, has_sizeof_name);
|
||||
|
||||
{
|
||||
/* Create new type_context with new environment */
|
||||
/* Create new type_context_old with new environment */
|
||||
local_context lctx = ctx.lctx();
|
||||
type_context ctx(m_env, options(), lctx);
|
||||
type_context_old ctx(m_env, options(), lctx);
|
||||
expr c_has_sizeof = mk_app(mk_app(mk_constant(has_sizeof_name, lvls), params), used_param_insts);
|
||||
|
||||
// Defeq simp lemmas
|
||||
|
|
@ -289,7 +289,7 @@ class mk_has_sizeof_fn {
|
|||
expr local = mk_local_for(ir_ty);
|
||||
locals.push_back(local);
|
||||
expr candidate = mk_app(ctx, get_sizeof_name(), local);
|
||||
type_context stctx(m_env, options(), ctx.lctx(), transparency_mode::Semireducible);
|
||||
type_context_old stctx(m_env, options(), ctx.lctx(), transparency_mode::Semireducible);
|
||||
if (!stctx.is_def_eq(candidate, mk_constant(get_nat_zero_name())))
|
||||
rhs = mk_nat_add(rhs, candidate);
|
||||
ir_ty = ctx.relaxed_whnf(instantiate(binding_body(ir_ty), local));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ Author: Daniel Selsam, Leonardo de Moura
|
|||
|
||||
namespace lean {
|
||||
|
||||
static void collect_args(type_context & tctx, expr const & type, unsigned num_params,
|
||||
static void collect_args(type_context_old & tctx, expr const & type, unsigned num_params,
|
||||
buffer<expr> & params, buffer<expr> & args1, buffer<expr> & args2, buffer<expr> & new_args) {
|
||||
expr ty = tctx.relaxed_whnf(type);
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ static void collect_args(type_context & tctx, expr const & type, unsigned num_pa
|
|||
|
||||
expr mk_injective_type_core(environment const & env, name const & ir_name, expr const & ir_type, unsigned num_params, level_param_names const & lp_names, bool use_eq) {
|
||||
// The transparency needs to match the kernel since we need to be consistent with the no_confusion construction.
|
||||
type_context ctx(env, transparency_mode::All);
|
||||
type_context_old ctx(env, transparency_mode::All);
|
||||
buffer<expr> params, args1, args2, new_args;
|
||||
collect_args(ctx, ir_type, num_params, params, args1, args2, new_args);
|
||||
expr c_ir_params = mk_app(mk_constant(ir_name, param_names_to_levels(lp_names)), params);
|
||||
|
|
@ -103,7 +103,7 @@ expr mk_injective_eq_type(environment const & env, name const & ir_name, expr co
|
|||
return mk_injective_type_core(env, ir_name, ir_type, num_params, lp_names, true);
|
||||
}
|
||||
|
||||
expr prove_by_assumption(type_context & tctx, expr const & ty, expr const & eq) {
|
||||
expr prove_by_assumption(type_context_old & tctx, expr const & ty, expr const & eq) {
|
||||
if (is_eq(ty) && is_heq(tctx.infer(eq))) {
|
||||
return mk_eq_of_heq(tctx, eq);
|
||||
} else {
|
||||
|
|
@ -111,7 +111,7 @@ expr prove_by_assumption(type_context & tctx, expr const & ty, expr const & eq)
|
|||
}
|
||||
}
|
||||
|
||||
expr prove_conjuncts_core(type_context & tctx, expr const & ty, buffer<expr> const & eqs, unsigned idx) {
|
||||
expr prove_conjuncts_core(type_context_old & tctx, expr const & ty, buffer<expr> const & eqs, unsigned idx) {
|
||||
if (idx == eqs.size() - 1) {
|
||||
lean_assert(!is_and(ty));
|
||||
return prove_by_assumption(tctx, ty, eqs[idx]);
|
||||
|
|
@ -124,12 +124,12 @@ expr prove_conjuncts_core(type_context & tctx, expr const & ty, buffer<expr> con
|
|||
}
|
||||
}
|
||||
|
||||
expr prove_conjuncts(type_context & tctx, expr const & ty, buffer<expr> const & eqs) {
|
||||
expr prove_conjuncts(type_context_old & tctx, expr const & ty, buffer<expr> const & eqs) {
|
||||
return prove_conjuncts_core(tctx, ty, eqs, 0);
|
||||
}
|
||||
|
||||
expr prove_injective(environment const & env, expr const & inj_type, name const & ind_name) {
|
||||
type_context tctx(env);
|
||||
type_context_old tctx(env);
|
||||
expr ty = inj_type;
|
||||
|
||||
buffer<expr> args;
|
||||
|
|
@ -182,7 +182,7 @@ expr prove_injective(environment const & env, expr const & inj_type, name const
|
|||
}
|
||||
|
||||
expr prove_injective_arrow(environment const & env, expr const & inj_arrow_type, name const & inj_name, level_param_names const & inj_lp_names) {
|
||||
type_context tctx(env);
|
||||
type_context_old tctx(env);
|
||||
expr ty = inj_arrow_type;
|
||||
|
||||
buffer<expr> args;
|
||||
|
|
@ -209,7 +209,7 @@ expr prove_injective_arrow(environment const & env, expr const & inj_arrow_type,
|
|||
|
||||
environment mk_injective_arrow(environment const & env, name const & ir_name) {
|
||||
declaration d = env.get(mk_injective_name(ir_name));
|
||||
type_context tctx(env);
|
||||
type_context_old tctx(env);
|
||||
|
||||
name P_lp_name = mk_fresh_lp_name(d.get_univ_params());
|
||||
expr P = tctx.push_local(name("P"), mk_sort(mk_param_univ(P_lp_name)), mk_strict_implicit_binder_info());
|
||||
|
|
@ -249,7 +249,7 @@ environment mk_injective_arrow(environment const & env, name const & ir_name) {
|
|||
|
||||
expr prove_injective_eq(environment const & env, expr const & inj_eq_type, name const & inj_eq_name) {
|
||||
try {
|
||||
type_context ctx(env, transparency_mode::Semireducible);
|
||||
type_context_old ctx(env, transparency_mode::Semireducible);
|
||||
expr dummy_ref;
|
||||
tactic_state s = mk_tactic_state_for(env, options(), inj_eq_name, metavar_context(), local_context(), inj_eq_type);
|
||||
vm_obj r = tactic_evaluator(ctx, options(), dummy_ref)(mk_constant(get_tactic_mk_inj_eq_name()), s);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ context_cache::context_cache(options const & o):
|
|||
context_cache::~context_cache() {
|
||||
}
|
||||
|
||||
optional<declaration> context_cache::get_decl(type_context & ctx, transparency_mode m, name const & n) {
|
||||
optional<declaration> context_cache::get_decl(type_context_old & ctx, transparency_mode m, name const & n) {
|
||||
auto & cache = m_transparency_cache[static_cast<unsigned>(m)];
|
||||
auto it = cache.find(n);
|
||||
if (it != cache.end()) {
|
||||
|
|
@ -30,12 +30,12 @@ optional<declaration> context_cache::get_decl(type_context & ctx, transparency_m
|
|||
return r;
|
||||
}
|
||||
|
||||
projection_info const * context_cache::get_proj_info(type_context & ctx, name const & n) {
|
||||
projection_info const * context_cache::get_proj_info(type_context_old & ctx, name const & n) {
|
||||
// TODO(Leo): check if we really need a cache for get_proj_info
|
||||
return context_cacheless::get_proj_info(ctx, n);
|
||||
}
|
||||
|
||||
bool context_cache::get_aux_recursor(type_context & ctx, name const & n) {
|
||||
bool context_cache::get_aux_recursor(type_context_old & ctx, name const & n) {
|
||||
auto it = m_aux_recursor_cache.find(n);
|
||||
if (it != m_aux_recursor_cache.end())
|
||||
return it->second;
|
||||
|
|
@ -44,7 +44,7 @@ bool context_cache::get_aux_recursor(type_context & ctx, name const & n) {
|
|||
return r;
|
||||
}
|
||||
|
||||
void context_cache::get_unification_hints(type_context & ctx, name const & f1, name const & f2, buffer<unification_hint> & hints) {
|
||||
void context_cache::get_unification_hints(type_context_old & ctx, name const & f1, name const & f2, buffer<unification_hint> & hints) {
|
||||
if (!m_uhints)
|
||||
m_uhints = ::lean::get_unification_hints(ctx.env());
|
||||
::lean::get_unification_hints(*m_uhints, f1, f2, hints);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class context_cache : public context_cacheless {
|
|||
cached value for (fun {A : Type} (a : A), a) when inferring the type of
|
||||
(fun (A : Type) (a : A), a). This is wasteful in modules such as the tactic framework.
|
||||
|
||||
So, when we create a type_context_cache object we can specify whether this extra
|
||||
So, when we create a type_context_old_cache object we can specify whether this extra
|
||||
level of precision is required or not. */
|
||||
typedef expr_cond_bi_struct_map<expr> infer_cache;
|
||||
typedef expr_struct_map<expr> whnf_cache;
|
||||
|
|
@ -50,9 +50,9 @@ class context_cache : public context_cacheless {
|
|||
|
||||
\remark In Semireducible, Instances and Reducible modes, projections and theorems are considered
|
||||
opaque independently of annotations. Actually, theorems will not be treated as opaque
|
||||
IF option `type_context.unfold_lemmas` is set to true.
|
||||
IF option `type_context_old.unfold_lemmas` is set to true.
|
||||
In All mode, projections are still considered opaque,
|
||||
this is not a problem since type_context implements a custom reduction rule for projections.
|
||||
this is not a problem since type_context_old implements a custom reduction rule for projections.
|
||||
|
||||
The All mode is used for type inference where it is unacceptable to fail to infer a type.
|
||||
The Semireducible mode is used for scenarios where an `is_def_eq` is expected to succeed
|
||||
|
|
@ -68,19 +68,19 @@ class context_cache : public context_cacheless {
|
|||
|
||||
/* We use the following approach for caching type class instances.
|
||||
|
||||
Whenever a type_context object is initialized with a local_context lctx
|
||||
Whenever a type_context_old object is initialized with a local_context lctx
|
||||
|
||||
1) If lctx has an instance_fingerprint, then we compare with the instance_fingerprint
|
||||
stored in this cache, if they are equal, we keep m_local_instances,
|
||||
m_instance_cache and m_subsingleton_cache.
|
||||
|
||||
New local instances added using methods type_context::push_local and type_context::push_let will
|
||||
New local instances added using methods type_context_old::push_local and type_context_old::push_let will
|
||||
be ignored.
|
||||
|
||||
2) If lctx doesn't have one, we clear m_local_instances, m_instance_cache and m_subsingleton_cache.
|
||||
We also traverse lctx and collect the local instances.
|
||||
|
||||
The methods type_context::push_local and type_context::push_let will flush the cache
|
||||
The methods type_context_old::push_local and type_context_old::push_let will flush the cache
|
||||
whenever new local instances are pushed into the local context.
|
||||
|
||||
m_instance_cache and m_subsingleton_cache are flushed before the cache is returned to the
|
||||
|
|
@ -99,12 +99,12 @@ public:
|
|||
context_cache & operator=(context_cache const &) = delete;
|
||||
context_cache & operator=(context_cache &&) = default;
|
||||
|
||||
virtual optional<declaration> get_decl(type_context &, transparency_mode, name const &) override;
|
||||
virtual projection_info const * get_proj_info(type_context &, name const &) override;
|
||||
virtual bool get_aux_recursor(type_context &, name const &) override;
|
||||
virtual void get_unification_hints(type_context &, name const & f1, name const & f2, buffer<unification_hint> & hints) override;
|
||||
virtual optional<declaration> get_decl(type_context_old &, transparency_mode, name const &) override;
|
||||
virtual projection_info const * get_proj_info(type_context_old &, name const &) override;
|
||||
virtual bool get_aux_recursor(type_context_old &, name const &) override;
|
||||
virtual void get_unification_hints(type_context_old &, name const & f1, name const & f2, buffer<unification_hint> & hints) override;
|
||||
|
||||
/* Cache support for type_context module */
|
||||
/* Cache support for type_context_old module */
|
||||
|
||||
virtual optional<expr> get_infer(expr const &) override;
|
||||
virtual void set_infer(expr const &, expr const &) override;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ Author: Leonardo de Moura
|
|||
#include "library/defeq_canonizer.h"
|
||||
|
||||
namespace lean {
|
||||
defeq_canonizer::defeq_canonizer(type_context & ctx, state & s):
|
||||
defeq_canonizer::defeq_canonizer(type_context_old & ctx, state & s):
|
||||
m_ctx(ctx), m_state(s) {
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ optional<name> defeq_canonizer::get_head_symbol(expr type) {
|
|||
if (is_constant(fn)) {
|
||||
return optional<name>(const_name(fn));
|
||||
} else if (is_pi(type)) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr l = locals.push_local_from_binding(type);
|
||||
return get_head_symbol(instantiate(binding_body(type), l));
|
||||
} else {
|
||||
|
|
@ -99,12 +99,12 @@ expr defeq_canonizer::canonize_core(expr const & e) {
|
|||
}
|
||||
}
|
||||
|
||||
static void trace(type_context & ctx, expr const & e, expr const & r) {
|
||||
static void trace(type_context_old & ctx, expr const & e, expr const & r) {
|
||||
lean_trace("defeq_canonizer", scope_trace_env _(ctx.env(), ctx); tout() << "\n" << e << "\n==>\n" << r << "\n";);
|
||||
}
|
||||
|
||||
expr defeq_canonizer::canonize(expr const & e, bool & updated) {
|
||||
type_context::transparency_scope scope(m_ctx, transparency_mode::Instances);
|
||||
type_context_old::transparency_scope scope(m_ctx, transparency_mode::Instances);
|
||||
m_updated = &updated;
|
||||
expr r = canonize_core(e);
|
||||
trace(m_ctx, e, r);
|
||||
|
|
@ -112,7 +112,7 @@ expr defeq_canonizer::canonize(expr const & e, bool & updated) {
|
|||
}
|
||||
|
||||
expr defeq_canonizer::canonize(expr const & e) {
|
||||
type_context::transparency_scope scope(m_ctx, transparency_mode::Instances);
|
||||
type_context_old::transparency_scope scope(m_ctx, transparency_mode::Instances);
|
||||
m_updated = nullptr;
|
||||
expr r = canonize_core(e);
|
||||
trace(m_ctx, e, r);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public:
|
|||
name_map<list<expr>> m_M;
|
||||
};
|
||||
private:
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
state & m_state;
|
||||
bool * m_updated{nullptr};
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ private:
|
|||
expr canonize_core(expr const & e);
|
||||
|
||||
public:
|
||||
defeq_canonizer(type_context & ctx, state & s);
|
||||
defeq_canonizer(type_context_old & ctx, state & s);
|
||||
|
||||
expr canonize(expr const & e, bool & updated);
|
||||
expr canonize(expr const & e);
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ int discr_tree::node_cmp::operator()(node const & n1, node const & n2) const {
|
|||
}
|
||||
}
|
||||
|
||||
auto discr_tree::insert_erase_atom(type_context & ctx, node && n, edge const & e, buffer<pair<expr, bool>> & todo,
|
||||
auto discr_tree::insert_erase_atom(type_context_old & ctx, node && n, edge const & e, buffer<pair<expr, bool>> & todo,
|
||||
expr const & v, buffer<pair<node, node>> & skip, bool ins) -> node {
|
||||
node new_n = ensure_unshared(n.steal());
|
||||
if (auto child = new_n.m_ptr->m_children.find(e)) {
|
||||
|
|
@ -154,14 +154,14 @@ auto discr_tree::insert_erase_atom(type_context & ctx, node && n, edge const & e
|
|||
}
|
||||
}
|
||||
|
||||
auto discr_tree::insert_erase_star(type_context & ctx, node && n, buffer<pair<expr, bool>> & todo, expr const & v,
|
||||
auto discr_tree::insert_erase_star(type_context_old & ctx, node && n, buffer<pair<expr, bool>> & todo, expr const & v,
|
||||
buffer<pair<node, node>> & skip, bool ins) -> node {
|
||||
node new_n = ensure_unshared(n.steal());
|
||||
new_n.m_ptr->m_star_child = insert_erase(ctx, new_n.m_ptr->m_star_child.steal(), false, todo, v, skip, ins);
|
||||
return new_n;
|
||||
}
|
||||
|
||||
auto discr_tree::insert_erase_app(type_context & ctx,
|
||||
auto discr_tree::insert_erase_app(type_context_old & ctx,
|
||||
node && n, bool is_root, expr const & e, buffer<pair<expr, bool>> & todo, expr const & v,
|
||||
buffer<pair<node, node>> & skip, bool ins) -> node {
|
||||
lean_assert(is_app(e));
|
||||
|
|
@ -199,7 +199,7 @@ auto discr_tree::insert_erase_app(type_context & ctx,
|
|||
}
|
||||
}
|
||||
|
||||
auto discr_tree::insert_erase(type_context & ctx,
|
||||
auto discr_tree::insert_erase(type_context_old & ctx,
|
||||
node && n, bool is_root, buffer<pair<expr, bool>> & todo,
|
||||
expr const & v, buffer<pair<node, node>> & skip, bool ins) -> node {
|
||||
if (todo.empty()) {
|
||||
|
|
@ -241,7 +241,7 @@ auto discr_tree::insert_erase(type_context & ctx,
|
|||
lean_unreachable();
|
||||
}
|
||||
|
||||
void discr_tree::insert_erase(type_context & ctx, expr const & k, expr const & v, bool ins) {
|
||||
void discr_tree::insert_erase(type_context_old & ctx, expr const & k, expr const & v, bool ins) {
|
||||
// insert & erase operations.
|
||||
// The erase operation is not optimal because it does not eliminate dead branches from the tree.
|
||||
// If this becomes an issue, we can remove dead branches from time to time and/or reconstruct
|
||||
|
|
@ -253,7 +253,7 @@ void discr_tree::insert_erase(type_context & ctx, expr const & k, expr const & v
|
|||
lean_trace("discr_tree", tout() << "\n"; trace(););
|
||||
}
|
||||
|
||||
bool discr_tree::find_atom(type_context & ctx, node const & n, edge const & e, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn) { // NOLINT
|
||||
bool discr_tree::find_atom(type_context_old & ctx, node const & n, edge const & e, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn) { // NOLINT
|
||||
if (auto child = n.m_ptr->m_children.find(e)) {
|
||||
return find(ctx, *child, todo, fn);
|
||||
} else {
|
||||
|
|
@ -261,7 +261,7 @@ bool discr_tree::find_atom(type_context & ctx, node const & n, edge const & e, l
|
|||
}
|
||||
}
|
||||
|
||||
bool discr_tree::find_star(type_context & ctx, node const & n, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn) { // NOLINT
|
||||
bool discr_tree::find_star(type_context_old & ctx, node const & n, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn) { // NOLINT
|
||||
bool cont = true;
|
||||
n.m_ptr->m_skip.for_each([&](node const & skip_child) {
|
||||
if (cont && !find(ctx, skip_child, todo, fn))
|
||||
|
|
@ -277,7 +277,7 @@ bool discr_tree::find_star(type_context & ctx, node const & n, list<pair<expr, b
|
|||
return cont;
|
||||
}
|
||||
|
||||
bool discr_tree::find_app(type_context & ctx, node const & n, expr const & e, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn) { // NOLINT
|
||||
bool discr_tree::find_app(type_context_old & ctx, node const & n, expr const & e, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn) { // NOLINT
|
||||
lean_assert(is_app(e));
|
||||
buffer<expr> args;
|
||||
expr const & f = get_app_args(e, args);
|
||||
|
|
@ -303,7 +303,7 @@ bool discr_tree::find_app(type_context & ctx, node const & n, expr const & e, li
|
|||
}
|
||||
}
|
||||
|
||||
bool discr_tree::find(type_context & ctx, node const & n, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn) { // NOLINT
|
||||
bool discr_tree::find(type_context_old & ctx, node const & n, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn) { // NOLINT
|
||||
if (!todo) {
|
||||
bool cont = true;
|
||||
n.m_ptr->m_values.for_each([&](expr const & v) {
|
||||
|
|
@ -338,12 +338,12 @@ bool discr_tree::find(type_context & ctx, node const & n, list<pair<expr, bool>>
|
|||
lean_unreachable();
|
||||
}
|
||||
|
||||
void discr_tree::find(type_context & ctx, expr const & e, std::function<bool(expr const &)> const & fn) const { // NOLINT
|
||||
void discr_tree::find(type_context_old & ctx, expr const & e, std::function<bool(expr const &)> const & fn) const { // NOLINT
|
||||
if (m_root)
|
||||
find(ctx, m_root, to_list(mk_pair(e, false)), fn);
|
||||
}
|
||||
|
||||
void discr_tree::collect(type_context & ctx, expr const & e, buffer<expr> & r) const {
|
||||
void discr_tree::collect(type_context_old & ctx, expr const & e, buffer<expr> & r) const {
|
||||
find(ctx, e, [&](expr const & v) { r.push_back(v); return true; });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,28 +47,28 @@ private:
|
|||
};
|
||||
static void swap(node & n1, node & n2);
|
||||
static node ensure_unshared(node && n);
|
||||
static node insert_erase_atom(type_context & ctx, node && n, edge const & e, buffer<pair<expr, bool>> & todo, expr const & v, buffer<pair<node, node>> & skip, bool ins);
|
||||
static node insert_erase_star(type_context & ctx, node && n, buffer<pair<expr, bool>> & todo, expr const & v, buffer<pair<node, node>> & skip, bool ins);
|
||||
static node insert_erase_app(type_context & ctx, node && n, bool is_root, expr const & e, buffer<pair<expr, bool>> & todo, expr const & v,
|
||||
static node insert_erase_atom(type_context_old & ctx, node && n, edge const & e, buffer<pair<expr, bool>> & todo, expr const & v, buffer<pair<node, node>> & skip, bool ins);
|
||||
static node insert_erase_star(type_context_old & ctx, node && n, buffer<pair<expr, bool>> & todo, expr const & v, buffer<pair<node, node>> & skip, bool ins);
|
||||
static node insert_erase_app(type_context_old & ctx, node && n, bool is_root, expr const & e, buffer<pair<expr, bool>> & todo, expr const & v,
|
||||
buffer<pair<node, node>> & skip, bool ins);
|
||||
static node insert_erase(type_context & ctx, node && n, bool is_root, buffer<pair<expr, bool>> & todo,
|
||||
static node insert_erase(type_context_old & ctx, node && n, bool is_root, buffer<pair<expr, bool>> & todo,
|
||||
expr const & v, buffer<pair<node, node>> & skip, bool ins);
|
||||
void insert_erase(type_context & ctx, expr const & k, expr const & v, bool ins);
|
||||
void insert_erase(type_context_old & ctx, expr const & k, expr const & v, bool ins);
|
||||
|
||||
static bool find_atom(type_context & ctx, node const & n, edge const & e, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn); // NOLINT
|
||||
static bool find_star(type_context & ctx, node const & n, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn); // NOLINT
|
||||
static bool find_app(type_context & ctx, node const & n, expr const & e, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn); // NOLINT
|
||||
static bool find(type_context & ctx, node const & n, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn); // NOLINT
|
||||
static bool find_atom(type_context_old & ctx, node const & n, edge const & e, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn); // NOLINT
|
||||
static bool find_star(type_context_old & ctx, node const & n, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn); // NOLINT
|
||||
static bool find_app(type_context_old & ctx, node const & n, expr const & e, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn); // NOLINT
|
||||
static bool find(type_context_old & ctx, node const & n, list<pair<expr, bool>> todo, std::function<bool(expr const &)> const & fn); // NOLINT
|
||||
|
||||
node m_root;
|
||||
public:
|
||||
void insert(type_context & ctx, expr const & k, expr const & v) { insert_erase(ctx, k, v, true); }
|
||||
void insert(type_context & ctx, expr const & k) { insert(ctx, k, k); }
|
||||
void erase(type_context & ctx, expr const & k, expr const & v) { insert_erase(ctx, k, v, false); }
|
||||
void erase(type_context & ctx, expr const & k) { erase(ctx, k, k); }
|
||||
void insert(type_context_old & ctx, expr const & k, expr const & v) { insert_erase(ctx, k, v, true); }
|
||||
void insert(type_context_old & ctx, expr const & k) { insert(ctx, k, k); }
|
||||
void erase(type_context_old & ctx, expr const & k, expr const & v) { insert_erase(ctx, k, v, false); }
|
||||
void erase(type_context_old & ctx, expr const & k) { erase(ctx, k, k); }
|
||||
|
||||
void find(type_context & ctx, expr const & e, std::function<bool(expr const &)> const & fn) const; // NOLINT
|
||||
void collect(type_context & ctx, expr const & e, buffer<expr> & r) const;
|
||||
void find(type_context_old & ctx, expr const & e, std::function<bool(expr const &)> const & fn) const; // NOLINT
|
||||
void collect(type_context_old & ctx, expr const & e, buffer<expr> & r) const;
|
||||
|
||||
void trace() const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static bool has_nested_rec(expr const & eqns) {
|
|||
}
|
||||
|
||||
static eqn_compiler_result compile_equations_core(environment & env, elaborator & elab, metavar_context & mctx, local_context const & lctx, expr const & eqns) {
|
||||
type_context ctx(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old ctx(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
trace_compiler(tout() << "compiling\n" << eqns << "\n";);
|
||||
trace_compiler(tout() << "recursive: " << is_recursive_eqns(ctx, eqns) << "\n";);
|
||||
trace_compiler(tout() << "nested recursion: " << has_nested_rec(eqns) << "\n";);
|
||||
|
|
@ -103,8 +103,8 @@ struct pull_nested_rec_fn : public replace_visitor {
|
|||
|
||||
local_context & lctx() { return m_lctx_stack.back(); }
|
||||
|
||||
type_context mk_type_context(local_context const & lctx) {
|
||||
return type_context(m_env, m_mctx, lctx, m_elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old mk_type_context(local_context const & lctx) {
|
||||
return type_context_old(m_env, m_mctx, lctx, m_elab.get_cache(), transparency_mode::Semireducible);
|
||||
}
|
||||
|
||||
expr visit_lambda_pi_let(bool is_lam, expr const & e) {
|
||||
|
|
@ -132,7 +132,7 @@ struct pull_nested_rec_fn : public replace_visitor {
|
|||
}
|
||||
t = instantiate_rev(t, locals.size(), locals.data());
|
||||
t = visit(t);
|
||||
type_context ctx = mk_type_context(lctx());
|
||||
type_context_old ctx = mk_type_context(lctx());
|
||||
t = is_lam ? ctx.mk_lambda(locals, t) : ctx.mk_pi(locals, t);
|
||||
m_mctx = ctx.mctx();
|
||||
m_lctx_stack.pop_back();
|
||||
|
|
@ -209,7 +209,7 @@ struct pull_nested_rec_fn : public replace_visitor {
|
|||
if the recursive call will be defined using well founded recursion.
|
||||
*/
|
||||
void collect_local_props(name_set & found, buffer<expr> & R) {
|
||||
type_context ctx = mk_type_context(lctx());
|
||||
type_context_old ctx = mk_type_context(lctx());
|
||||
lctx().for_each([&](local_decl const & d) {
|
||||
if (!base_lctx().find_local_decl(d.get_name()) &&
|
||||
!found.contains(d.get_name()) &&
|
||||
|
|
@ -273,7 +273,7 @@ struct pull_nested_rec_fn : public replace_visitor {
|
|||
get_app_args(e, args);
|
||||
buffer<expr> local_deps;
|
||||
collect_locals(e, local_deps);
|
||||
type_context ctx = mk_type_context(lctx());
|
||||
type_context_old ctx = mk_type_context(lctx());
|
||||
expr val = ctx.mk_lambda(local_deps, e);
|
||||
expr val_type = ctx.infer(val);
|
||||
name fn_aux = name("_f").append_after(m_new_locals.size() + 1);
|
||||
|
|
@ -299,7 +299,7 @@ struct pull_nested_rec_fn : public replace_visitor {
|
|||
lean_assert(m_lctx_stack.size() == 1);
|
||||
local_context new_lctx = m_lctx_stack[0];
|
||||
auto r = compile_equations_core(m_env, m_elab, m_mctx, new_lctx, new_e);
|
||||
type_context ctx = mk_type_context(new_lctx);
|
||||
type_context_old ctx = mk_type_context(new_lctx);
|
||||
r.m_fns = map(r.m_fns, [&] (expr const & fn) { return replace_locals(fn, m_new_locals, m_new_values); });
|
||||
m_mctx = ctx.mctx();
|
||||
return r;
|
||||
|
|
@ -345,7 +345,7 @@ static expr compile_equations_main(environment & env, elaborator & elab,
|
|||
|
||||
expr compile_equations(environment & env, elaborator & elab, metavar_context & mctx, local_context const & lctx, expr const & eqns) {
|
||||
equations_header const & header = get_equations_header(eqns);
|
||||
type_context ctx(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old ctx(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
if (!header.m_is_meta &&
|
||||
!header.m_is_lemma &&
|
||||
!header.m_is_noncomputable &&
|
||||
|
|
@ -354,7 +354,7 @@ expr compile_equations(environment & env, elaborator & elab, metavar_context & m
|
|||
/* We compile non-meta recursive definitions as meta definitions first.
|
||||
The motivations are:
|
||||
- Clear execution cost semantics for recursive functions.
|
||||
- Auxiliary meta definition may assist recursive definition unfolding in the type_context object.
|
||||
- Auxiliary meta definition may assist recursive definition unfolding in the type_context_old object.
|
||||
*/
|
||||
equations_header aux_header = header;
|
||||
aux_header.m_is_meta = true;
|
||||
|
|
|
|||
|
|
@ -191,15 +191,15 @@ struct elim_match_fn {
|
|||
return true;
|
||||
}
|
||||
|
||||
type_context mk_type_context(local_context const & lctx) {
|
||||
return type_context(m_env, m_mctx, lctx, m_elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old mk_type_context(local_context const & lctx) {
|
||||
return type_context_old(m_env, m_mctx, lctx, m_elab.get_cache(), transparency_mode::Semireducible);
|
||||
}
|
||||
|
||||
type_context mk_type_context(expr const & mvar) {
|
||||
type_context_old mk_type_context(expr const & mvar) {
|
||||
return mk_type_context(get_local_context(mvar));
|
||||
}
|
||||
|
||||
type_context mk_type_context(problem const & P) {
|
||||
type_context_old mk_type_context(problem const & P) {
|
||||
return mk_type_context(get_local_context(P));
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ struct elim_match_fn {
|
|||
std::function<format(expr const &)> mk_pp_ctx(local_context const & lctx) {
|
||||
options opts = get_options();
|
||||
opts = opts.update(get_pp_beta_name(), false);
|
||||
type_context ctx = mk_type_context(lctx);
|
||||
type_context_old ctx = mk_type_context(lctx);
|
||||
return ::lean::mk_pp_ctx(ctx);
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ struct elim_match_fn {
|
|||
format pp_problem(problem const & P) {
|
||||
format r;
|
||||
auto pp = mk_pp_ctx(P);
|
||||
type_context ctx = mk_type_context(P);
|
||||
type_context_old ctx = mk_type_context(P);
|
||||
r += format("match") + space() + format(P.m_fn_name) + space() + format(":") + space() + pp(ctx.infer(P.m_goal));
|
||||
format v;
|
||||
bool first = true;
|
||||
|
|
@ -264,7 +264,7 @@ struct elim_match_fn {
|
|||
if (!is_constant(e)) return optional<name>();
|
||||
return is_constructor(const_name(e));
|
||||
}
|
||||
optional<name> is_constructor_app(type_context & ctx, expr const & e) const {
|
||||
optional<name> is_constructor_app(type_context_old & ctx, expr const & e) const {
|
||||
if (auto ind_type = is_constructor(get_app_fn(e))) {
|
||||
// Check that e is not a partially applied constructor.
|
||||
auto e_type = whnf_ginductive(ctx, ctx.infer(e));
|
||||
|
|
@ -321,7 +321,7 @@ struct elim_match_fn {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool is_value(type_context & ctx, expr const & e) {
|
||||
bool is_value(type_context_old & ctx, expr const & e) {
|
||||
try {
|
||||
if (!m_use_ite) return false;
|
||||
if (is_nat_int_char_string_name_value(ctx, e)) return true;
|
||||
|
|
@ -333,7 +333,7 @@ struct elim_match_fn {
|
|||
}
|
||||
}
|
||||
|
||||
bool is_finite_value(type_context & ctx, expr const & e) {
|
||||
bool is_finite_value(type_context_old & ctx, expr const & e) {
|
||||
lean_assert(is_value(ctx, e));
|
||||
return is_char_value(ctx, e);
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ struct elim_match_fn {
|
|||
unsigned get_inductive_num_params(expr const & I) const { return get_inductive_num_params(const_name(I)); }
|
||||
|
||||
/* Normalize until head is constructor or value */
|
||||
expr whnf_pattern(type_context & ctx, expr const & e) {
|
||||
expr whnf_pattern(type_context_old & ctx, expr const & e) {
|
||||
if (is_inaccessible(e)) {
|
||||
return e;
|
||||
} else if (is_value(ctx, e)) {
|
||||
|
|
@ -374,14 +374,14 @@ struct elim_match_fn {
|
|||
}
|
||||
|
||||
/* Normalize until head is constructor */
|
||||
expr whnf_constructor(type_context & ctx, expr const & e) {
|
||||
expr whnf_constructor(type_context_old & ctx, expr const & e) {
|
||||
return ctx.whnf_head_pred(e, [&](expr const & e) {
|
||||
return !is_constructor_app(ctx, e);
|
||||
});
|
||||
}
|
||||
|
||||
/* Normalize until head is an inductive datatype */
|
||||
expr whnf_inductive(type_context & ctx, expr const & e) {
|
||||
expr whnf_inductive(type_context_old & ctx, expr const & e) {
|
||||
return ctx.whnf_head_pred(e, [&](expr const & e) {
|
||||
return !is_inductive_app(e);
|
||||
});
|
||||
|
|
@ -391,7 +391,7 @@ struct elim_match_fn {
|
|||
expr it = eqn;
|
||||
it = binding_body(it); /* consume fn header */
|
||||
if (is_no_equation(it)) return optional<equation>();
|
||||
type_context ctx = mk_type_context(lctx);
|
||||
type_context_old ctx = mk_type_context(lctx);
|
||||
buffer<expr> locals;
|
||||
while (is_lambda(it)) {
|
||||
expr type = instantiate_rev(binding_domain(it), locals);
|
||||
|
|
@ -443,7 +443,7 @@ struct elim_match_fn {
|
|||
unsigned get_eqns_arity(local_context const & lctx, expr const & eqns) {
|
||||
/* Naive way to retrieve the arity of the function being defined */
|
||||
lean_assert(is_equations(eqns));
|
||||
type_context ctx = mk_type_context(lctx);
|
||||
type_context_old ctx = mk_type_context(lctx);
|
||||
unpack_eqns ues(ctx, eqns);
|
||||
return ues.get_arity_of(0);
|
||||
}
|
||||
|
|
@ -507,7 +507,7 @@ struct elim_match_fn {
|
|||
bool is_constructor_transition(problem const & P) {
|
||||
return all_equations(P, [&](equation const & eqn) {
|
||||
expr const & p = head(eqn.m_patterns);
|
||||
type_context ctx = mk_type_context(eqn.m_lctx);
|
||||
type_context_old ctx = mk_type_context(eqn.m_lctx);
|
||||
if (is_constructor_app(ctx, p))
|
||||
return true;
|
||||
return is_value(ctx, p);
|
||||
|
|
@ -541,7 +541,7 @@ struct elim_match_fn {
|
|||
if (is_local(p)) {
|
||||
has_variable = true; return true;
|
||||
}
|
||||
type_context ctx = mk_type_context(eqn.m_lctx);
|
||||
type_context_old ctx = mk_type_context(eqn.m_lctx);
|
||||
if (is_constructor_app(ctx, p)) {
|
||||
has_constructor = true; return true;
|
||||
}
|
||||
|
|
@ -569,7 +569,7 @@ struct elim_match_fn {
|
|||
if (is_local(p)) {
|
||||
has_variable = true; return true;
|
||||
} else {
|
||||
type_context ctx = mk_type_context(eqn.m_lctx);
|
||||
type_context_old ctx = mk_type_context(eqn.m_lctx);
|
||||
if (is_value(ctx, p)) {
|
||||
has_value = true;
|
||||
if (is_finite_value(ctx, p))
|
||||
|
|
@ -584,7 +584,7 @@ struct elim_match_fn {
|
|||
return false;
|
||||
if (!has_variable && has_finite_value)
|
||||
return false;
|
||||
type_context ctx = mk_type_context(P);
|
||||
type_context_old ctx = mk_type_context(P);
|
||||
/* Check whether other variables on the variable stack depend on the head. */
|
||||
expr const & v = head(P.m_var_stack);
|
||||
if (depends_on(ctx.infer(P.m_goal), v)) {
|
||||
|
|
@ -692,7 +692,7 @@ struct elim_match_fn {
|
|||
buffer<equation> R;
|
||||
for (equation const & eqn : eqns) {
|
||||
lean_assert(eqn.m_patterns);
|
||||
type_context ctx = mk_type_context(eqn.m_lctx);
|
||||
type_context_old ctx = mk_type_context(eqn.m_lctx);
|
||||
/* Remark: reverted bcf44f7020, see issue #1739 */
|
||||
/* expr pattern = whnf_constructor(ctx, head(eqn.m_patterns)); */
|
||||
/* We use ctx.relaxed_whnf to make sure we expose the kernel constructor */
|
||||
|
|
@ -740,7 +740,7 @@ struct elim_match_fn {
|
|||
equation new_eqn = eqn;
|
||||
new_eqn.m_subst = apply(eqn.m_subst, new_subst);
|
||||
/* Update patterns */
|
||||
type_context ctx = mk_type_context(eqn.m_lctx);
|
||||
type_context_old ctx = mk_type_context(eqn.m_lctx);
|
||||
for (unsigned i = nparams; i < pattern_args.size(); i++)
|
||||
pattern_args[i] = whnf_pattern(ctx, pattern_args[i]);
|
||||
new_eqn.m_patterns = to_list(pattern_args.begin() + nparams, pattern_args.end(), tail(eqn.m_patterns));
|
||||
|
|
@ -752,7 +752,7 @@ struct elim_match_fn {
|
|||
optional<list<lemma>> process_constructor_core(problem const & P, bool fail_if_subgoals) {
|
||||
trace_match(tout() << "step: constructors only\n";);
|
||||
lean_assert(is_constructor_transition(P));
|
||||
type_context ctx = mk_type_context(P);
|
||||
type_context_old ctx = mk_type_context(P);
|
||||
expr x = head(P.m_var_stack);
|
||||
/* Remark: reverted bcf44f7020, see issue #1739 */
|
||||
/* expr x_type = whnf_inductive(ctx, ctx.infer(x)); */
|
||||
|
|
@ -823,7 +823,7 @@ struct elim_match_fn {
|
|||
bool is_last = !tail(P.m_var_stack);
|
||||
expr x = head(P.m_var_stack);
|
||||
local_context lctx = get_local_context(P.m_goal);
|
||||
type_context ctx = mk_type_context(P);
|
||||
type_context_old ctx = mk_type_context(P);
|
||||
expr goal_type = ctx.infer(P.m_goal);
|
||||
expr else_goal = ctx.mk_metavar_decl(lctx, goal_type);
|
||||
buffer<expr> values;
|
||||
|
|
@ -868,7 +868,7 @@ struct elim_match_fn {
|
|||
if (is_last) break;
|
||||
} else if (is_local(p)) {
|
||||
/* Replace variable `p` with `val` in this equation */
|
||||
type_context ctx = mk_type_context(eqn.m_lctx);
|
||||
type_context_old ctx = mk_type_context(eqn.m_lctx);
|
||||
buffer<expr> from;
|
||||
buffer<expr> to;
|
||||
buffer<expr> new_vars;
|
||||
|
|
@ -918,7 +918,7 @@ struct elim_match_fn {
|
|||
equation new_eqn = eqn;
|
||||
new_eqn.m_patterns = tail(new_eqn.m_patterns);
|
||||
new_eqn.m_subst = add_subst(eqn.m_subst, p, x);
|
||||
type_context ctx = mk_type_context(eqn.m_lctx);
|
||||
type_context_old ctx = mk_type_context(eqn.m_lctx);
|
||||
new_eqn.m_hs = eqn.m_hs;
|
||||
unsigned idx = length(eqn.m_hs) + 1;
|
||||
for (unsigned i = 0; i < values.size(); i++) {
|
||||
|
|
@ -949,7 +949,7 @@ struct elim_match_fn {
|
|||
for (equation const & eqn : P.m_equations) {
|
||||
expr const & pattern = head(eqn.m_patterns);
|
||||
if (is_local(pattern)) {
|
||||
type_context ctx = mk_type_context(eqn.m_lctx);
|
||||
type_context_old ctx = mk_type_context(eqn.m_lctx);
|
||||
for_each_compatible_constructor(ctx, pattern,
|
||||
[&](expr const & c, buffer<expr> const & new_c_vars) {
|
||||
expr var = pattern;
|
||||
|
|
@ -983,7 +983,7 @@ struct elim_match_fn {
|
|||
if (!is_next_var(P)) {
|
||||
return process_variable(P);
|
||||
} else {
|
||||
type_context ctx = mk_type_context(P);
|
||||
type_context_old ctx = mk_type_context(P);
|
||||
expr x = head(P.m_var_stack);
|
||||
expr arg_type = ctx.infer(x);
|
||||
if (is_below_type(arg_type)) {
|
||||
|
|
@ -1015,7 +1015,7 @@ struct elim_match_fn {
|
|||
list<lemma> process_non_variable(problem const & P) {
|
||||
expr p = head(P.m_var_stack);
|
||||
lean_assert(!is_local(p));
|
||||
type_context ctx = mk_type_context(P);
|
||||
type_context_old ctx = mk_type_context(P);
|
||||
if (all_inaccessible(P)) {
|
||||
trace_match(tout() << "step: skip inaccessible patterns\n";);
|
||||
problem new_P;
|
||||
|
|
@ -1063,7 +1063,7 @@ struct elim_match_fn {
|
|||
|
||||
/* Create (f ... x) with the given arity, where the other arguments are inferred using
|
||||
type inference */
|
||||
expr mk_app_with_arity(type_context & ctx, name const & f, unsigned arity, expr const & x) {
|
||||
expr mk_app_with_arity(type_context_old & ctx, name const & f, unsigned arity, expr const & x) {
|
||||
buffer<bool> mask;
|
||||
mask.resize(arity - 1, false);
|
||||
mask.push_back(true);
|
||||
|
|
@ -1138,7 +1138,7 @@ struct elim_match_fn {
|
|||
expr M_1 = revert(m_env, get_options(), m_mctx, P.m_goal, to_revert, preserve_to_revert_order);
|
||||
|
||||
/* Step 2 */
|
||||
type_context ctx1 = mk_type_context(M_1);
|
||||
type_context_old ctx1 = mk_type_context(M_1);
|
||||
expr M_1_type = ctx1.relaxed_whnf(ctx1.infer(M_1));
|
||||
lean_assert(is_pi(M_1_type));
|
||||
expr x1 = ctx1.push_local(binding_name(M_1_type), binding_domain(M_1_type));
|
||||
|
|
@ -1232,9 +1232,9 @@ struct elim_match_fn {
|
|||
t =?= s
|
||||
|
||||
|
||||
Remark: we also use `id_rhs` to implement "smart reduction" at type_context.
|
||||
Remark: we also use `id_rhs` to implement "smart reduction" at type_context_old.
|
||||
*/
|
||||
type_context ctx = mk_type_context(P);
|
||||
type_context_old ctx = mk_type_context(P);
|
||||
rhs = mk_id_rhs(ctx, rhs);
|
||||
}
|
||||
m_mctx.assign(P.m_goal, rhs);
|
||||
|
|
@ -1299,7 +1299,7 @@ struct elim_match_fn {
|
|||
expr finalize_lemma(expr const & fn, lemma const & L) {
|
||||
buffer<expr> args;
|
||||
to_buffer(L.m_lhs_args, args);
|
||||
type_context ctx = mk_type_context(L.m_lctx);
|
||||
type_context_old ctx = mk_type_context(L.m_lctx);
|
||||
expr lhs = mk_app(fn, args);
|
||||
expr eq = mk_eq(ctx, lhs, L.m_rhs);
|
||||
buffer<expr> locals;
|
||||
|
|
@ -1368,7 +1368,7 @@ struct elim_match_fn {
|
|||
elim_match_result operator()(local_context const & lctx, expr const & eqns) {
|
||||
lean_assert(equations_num_fns(eqns) == 1);
|
||||
DEBUG_CODE({
|
||||
type_context ctx = mk_type_context(lctx);
|
||||
type_context_old ctx = mk_type_context(lctx);
|
||||
lean_assert(!is_recursive_eqns(ctx, eqns));
|
||||
});
|
||||
m_aux_lemmas = get_equations_header(eqns).m_aux_lemmas;
|
||||
|
|
@ -1438,7 +1438,7 @@ eqn_compiler_result mk_nonrec(environment & env, elaborator & elab, metavar_cont
|
|||
auto counter_examples = map2<expr>(R.m_counter_examples, [&] (list<expr> const & e) { return mk_app(fn, e); });
|
||||
return { {R.m_fn}, counter_examples };
|
||||
}
|
||||
type_context ctx1(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old ctx1(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
/*
|
||||
We should use the type specified at eqns instead of m_ctx.infer(R.m_fn).
|
||||
These two types must be definitionally equal, but the shape of
|
||||
|
|
@ -1455,9 +1455,9 @@ eqn_compiler_result mk_nonrec(environment & env, elaborator & elab, metavar_cont
|
|||
std::tie(env, fn) = mk_aux_definition(env, elab.get_options(), mctx, lctx, header,
|
||||
fn_name, fn_actual_name, fn_type, R.m_fn);
|
||||
unsigned eqn_idx = 1;
|
||||
type_context ctx2(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old ctx2(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
for (expr type : R.m_lemmas) {
|
||||
type_context::tmp_locals locals(ctx2);
|
||||
type_context_old::tmp_locals locals(ctx2);
|
||||
type = ctx2.relaxed_whnf(type);
|
||||
while (is_pi(type)) {
|
||||
expr local = locals.push_local_from_binding(type);
|
||||
|
|
|
|||
|
|
@ -16,15 +16,15 @@ Author: Leonardo de Moura
|
|||
|
||||
namespace lean {
|
||||
struct sigma_packer_fn {
|
||||
type_context & m_ctx;
|
||||
sigma_packer_fn(type_context & ctx):m_ctx(ctx) {}
|
||||
type_context_old & m_ctx;
|
||||
sigma_packer_fn(type_context_old & ctx):m_ctx(ctx) {}
|
||||
|
||||
expr_pair mk_sigma_domain(expr const & pi_type, buffer<expr> & out_locals, unsigned n) {
|
||||
expr type = pi_type;
|
||||
if (!is_pi(type)) type = m_ctx.relaxed_whnf(type);
|
||||
if (!is_pi(type)) throw_ill_formed_eqns();
|
||||
expr const & A = binding_domain(type);
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr a = locals.push_local_from_binding(type);
|
||||
out_locals.push_back(a);
|
||||
expr next_pi_type = instantiate(binding_body(type), a);
|
||||
|
|
@ -49,7 +49,7 @@ struct sigma_packer_fn {
|
|||
buffer<expr> locals;
|
||||
expr domain, pre_codomain;
|
||||
std::tie(domain, pre_codomain) = mk_sigma_domain(pi_type, locals, n);
|
||||
type_context::tmp_locals plocal(m_ctx);
|
||||
type_context_old::tmp_locals plocal(m_ctx);
|
||||
expr p = plocal.push_local("_p", domain);
|
||||
expr codomain = mk_codomain(pre_codomain, p, locals, n);
|
||||
return plocal.mk_pi(codomain);
|
||||
|
|
@ -123,7 +123,7 @@ struct sigma_packer_fn {
|
|||
}
|
||||
|
||||
public:
|
||||
update_apps_fn(type_context & ctx, buffer<expr> const & old_fns, unpack_eqns const & ues):
|
||||
update_apps_fn(type_context_old & ctx, buffer<expr> const & old_fns, unpack_eqns const & ues):
|
||||
replace_visitor_with_tc(ctx), m_old_fns(old_fns), m_ues(ues) {}
|
||||
};
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ struct sigma_packer_fn {
|
|||
}
|
||||
};
|
||||
|
||||
expr pack_domain(type_context & ctx, expr const & e) {
|
||||
expr pack_domain(type_context_old & ctx, expr const & e) {
|
||||
return sigma_packer_fn(ctx)(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ Author: Leonardo de Moura
|
|||
namespace lean {
|
||||
/** \brief Create a new equations object where all functions being defined are unary.
|
||||
The trick is to pack multiple arguments using a Sigma type. */
|
||||
expr pack_domain(type_context & ctx, expr const & e);
|
||||
expr pack_domain(type_context_old & ctx, expr const & e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Author: Leonardo de Moura
|
|||
namespace lean {
|
||||
#define trace_debug_mutual(Code) lean_trace(name({"debug", "eqn_compiler", "mutual"}), scope_trace_env _scope(m_ctx.env(), m_ctx); Code)
|
||||
|
||||
static expr mk_mutual_arg(type_context & ctx, expr const & e, unsigned fidx, unsigned num_fns,
|
||||
static expr mk_mutual_arg(type_context_old & ctx, expr const & e, unsigned fidx, unsigned num_fns,
|
||||
expr psum_type, unsigned i) {
|
||||
if (i == num_fns - 1) {
|
||||
return e;
|
||||
|
|
@ -36,14 +36,14 @@ static expr mk_mutual_arg(type_context & ctx, expr const & e, unsigned fidx, uns
|
|||
}
|
||||
}
|
||||
|
||||
expr mk_mutual_arg(type_context & ctx, expr const & e, unsigned fidx, unsigned num_fns, expr const & psum_type) {
|
||||
expr mk_mutual_arg(type_context_old & ctx, expr const & e, unsigned fidx, unsigned num_fns, expr const & psum_type) {
|
||||
return mk_mutual_arg(ctx, e, fidx, num_fns, psum_type, 0);
|
||||
}
|
||||
|
||||
struct pack_mutual_fn {
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
|
||||
pack_mutual_fn(type_context & ctx):m_ctx(ctx) {}
|
||||
pack_mutual_fn(type_context_old & ctx):m_ctx(ctx) {}
|
||||
|
||||
expr mk_new_domain(buffer<expr> const & domains) {
|
||||
unsigned i = domains.size();
|
||||
|
|
@ -76,7 +76,7 @@ struct pack_mutual_fn {
|
|||
/* Add major */
|
||||
cases_on = mk_app(cases_on, x);
|
||||
/* Add minors */
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr y_1 = locals.push_local("_s", args[0]);
|
||||
expr m_1 = m_ctx.mk_lambda(y_1, instantiate(codomains[i], y_1));
|
||||
expr y_2 = locals.push_local("_s", args[1]);
|
||||
|
|
@ -91,7 +91,7 @@ struct pack_mutual_fn {
|
|||
expr m_new_fn;
|
||||
expr m_new_domain;
|
||||
|
||||
replace_fns(type_context & ctx, unpack_eqns const & ues, expr const & new_fn):
|
||||
replace_fns(type_context_old & ctx, unpack_eqns const & ues, expr const & new_fn):
|
||||
replace_visitor_with_tc(ctx),
|
||||
m_ues(ues),
|
||||
m_new_fn(new_fn) {
|
||||
|
|
@ -147,7 +147,7 @@ struct pack_mutual_fn {
|
|||
f : Pi (x : psum A_1 ... (psum A_{n-1} A_n)), psum.cases_on x (fun y, B_1 y) (... (fun y, B_n y) ...)
|
||||
|
||||
remark: this module assumes the B_i's are in the same universe. */
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
buffer<expr> domains;
|
||||
buffer<expr> codomains;
|
||||
level codomains_lvl;
|
||||
|
|
@ -218,7 +218,7 @@ struct pack_mutual_fn {
|
|||
}
|
||||
};
|
||||
|
||||
expr pack_mutual(type_context & ctx, expr const & e) {
|
||||
expr pack_mutual(type_context_old & ctx, expr const & e) {
|
||||
return pack_mutual_fn(ctx)(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ Author: Leonardo de Moura
|
|||
namespace lean {
|
||||
/** \brief Create a new equations object containing a single function.
|
||||
The functions must be unary. */
|
||||
expr pack_mutual(type_context & ctx, expr const & eqns);
|
||||
expr pack_mutual(type_context_old & ctx, expr const & eqns);
|
||||
|
||||
expr mk_mutual_arg(type_context & ctx, expr const & e, unsigned fidx, unsigned num_fns, expr const & psum_type);
|
||||
expr mk_mutual_arg(type_context_old & ctx, expr const & e, unsigned fidx, unsigned num_fns, expr const & psum_type);
|
||||
|
||||
void initialize_pack_mutual();
|
||||
void finalize_pack_mutual();
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ Author: Leonardo de Moura
|
|||
#include "frontends/lean/elaborator.h"
|
||||
|
||||
namespace lean {
|
||||
#define trace_struct(Code) lean_trace(name({"eqn_compiler", "structural_rec"}), type_context ctx = mk_type_context(); scope_trace_env _scope1(m_env, ctx); Code)
|
||||
#define trace_struct(Code) lean_trace(name({"eqn_compiler", "structural_rec"}), type_context_old ctx = mk_type_context(); scope_trace_env _scope1(m_env, ctx); Code)
|
||||
#define trace_struct_aux(Code) lean_trace(name({"eqn_compiler", "structural_rec"}), scope_trace_env _scope1(m_ctx.env(), m_ctx); Code)
|
||||
#define trace_debug_struct(Code) lean_trace(name({"debug", "eqn_compiler", "structural_rec"}), type_context ctx = mk_type_context(); scope_trace_env _scope1(m_env, ctx); Code)
|
||||
#define trace_debug_struct(Code) lean_trace(name({"debug", "eqn_compiler", "structural_rec"}), type_context_old ctx = mk_type_context(); scope_trace_env _scope1(m_env, ctx); Code)
|
||||
#define trace_debug_struct_aux(Code) lean_trace(name({"debug", "eqn_compiler", "structural_rec"}), scope_trace_env _scope1(m_ctx.env(), m_ctx); Code)
|
||||
|
||||
struct structural_rec_fn {
|
||||
|
|
@ -56,8 +56,8 @@ struct structural_rec_fn {
|
|||
throw generic_exception(m_ref, strm);
|
||||
}
|
||||
|
||||
type_context mk_type_context() {
|
||||
return type_context(m_env, m_mctx, m_lctx, m_elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old mk_type_context() {
|
||||
return type_context_old(m_env, m_mctx, m_lctx, m_elab.get_cache(), transparency_mode::Semireducible);
|
||||
}
|
||||
|
||||
environment const & env() const { return m_env; }
|
||||
|
|
@ -66,13 +66,13 @@ struct structural_rec_fn {
|
|||
/** \brief Auxiliary object for checking whether recursive application are
|
||||
structurally smaller or not */
|
||||
struct check_rhs_fn {
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
expr m_lhs;
|
||||
expr m_fn;
|
||||
expr m_pattern;
|
||||
unsigned m_arg_idx;
|
||||
|
||||
check_rhs_fn(type_context & ctx, expr const & lhs, expr const & fn, expr const & pattern, unsigned arg_idx):
|
||||
check_rhs_fn(type_context_old & ctx, expr const & lhs, expr const & fn, expr const & pattern, unsigned arg_idx):
|
||||
m_ctx(ctx), m_lhs(lhs), m_fn(fn), m_pattern(pattern), m_arg_idx(arg_idx) {}
|
||||
|
||||
bool is_constructor(expr const & e) const {
|
||||
|
|
@ -160,7 +160,7 @@ struct structural_rec_fn {
|
|||
if (!check_rhs(let_value(e))) {
|
||||
return false;
|
||||
} else {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
return check_rhs(instantiate(let_body(e), locals.push_local_from_let(e)));
|
||||
}
|
||||
case expr_kind::Lambda:
|
||||
|
|
@ -168,7 +168,7 @@ struct structural_rec_fn {
|
|||
if (!check_rhs(binding_domain(e))) {
|
||||
return false;
|
||||
} else {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
return check_rhs(instantiate(binding_body(e), locals.push_local_from_binding(e)));
|
||||
}
|
||||
}
|
||||
|
|
@ -180,19 +180,19 @@ struct structural_rec_fn {
|
|||
}
|
||||
};
|
||||
|
||||
bool check_rhs(type_context & ctx, expr const & lhs, expr const & fn, expr pattern, unsigned arg_idx, expr const & rhs) {
|
||||
bool check_rhs(type_context_old & ctx, expr const & lhs, expr const & fn, expr pattern, unsigned arg_idx, expr const & rhs) {
|
||||
pattern = ctx.whnf(pattern);
|
||||
return check_rhs_fn(ctx, lhs, fn, pattern, arg_idx)(rhs);
|
||||
}
|
||||
|
||||
bool check_eq(type_context & ctx, expr const & eqn, unsigned arg_idx) {
|
||||
bool check_eq(type_context_old & ctx, expr const & eqn, unsigned arg_idx) {
|
||||
unpack_eqn ue(ctx, eqn);
|
||||
buffer<expr> args;
|
||||
expr const & fn = get_app_args(ue.lhs(), args);
|
||||
return check_rhs(ctx, ue.lhs(), fn, args[arg_idx], arg_idx, ue.rhs());
|
||||
}
|
||||
|
||||
static bool depends_on_locals(expr const & e, type_context::tmp_locals const & locals) {
|
||||
static bool depends_on_locals(expr const & e, type_context_old::tmp_locals const & locals) {
|
||||
return depends_on_any(e, locals.as_buffer().size(), locals.as_buffer().data());
|
||||
}
|
||||
|
||||
|
|
@ -200,9 +200,9 @@ struct structural_rec_fn {
|
|||
If the argument type is an indexed family, we store the position of the
|
||||
indices (in the function being defined) at m_indices_pos.
|
||||
This method also updates m_reflexive (true iff the inductive datatype is reflexive). */
|
||||
bool check_arg_type(type_context & ctx, unpack_eqns const & ues, unsigned arg_idx) {
|
||||
bool check_arg_type(type_context_old & ctx, unpack_eqns const & ues, unsigned arg_idx) {
|
||||
m_indices_pos.clear();
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
/* We can only use structural recursion on arg_idx IF
|
||||
1- Type is an inductive datatype with support for the brec_on construction.
|
||||
2- Type parameters do not depend on other arguments of the function being defined. */
|
||||
|
|
@ -311,7 +311,7 @@ struct structural_rec_fn {
|
|||
If the result is true, then m_arg_pos will contain the position of the argument,
|
||||
and m_indices_pos the position of its indices (when the type of the
|
||||
argument is an indexed family). */
|
||||
bool find_rec_arg(type_context & ctx, unpack_eqns const & ues) {
|
||||
bool find_rec_arg(type_context_old & ctx, unpack_eqns const & ues) {
|
||||
buffer<expr> const & eqns = ues.get_eqns_of(0);
|
||||
unsigned arity = ues.get_arity_of(0);
|
||||
for (unsigned i = 0; i < arity; i++) {
|
||||
|
|
@ -334,8 +334,8 @@ struct structural_rec_fn {
|
|||
|
||||
/* Return the type of the new function.
|
||||
It also sets the m_motive_type field. */
|
||||
expr mk_new_fn_motive_types(type_context & ctx, unpack_eqns const & ues) {
|
||||
type_context::tmp_locals locals(ctx);
|
||||
expr mk_new_fn_motive_types(type_context_old & ctx, unpack_eqns const & ues) {
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
expr fn = ues.get_fn(0);
|
||||
expr fn_type = ctx.infer(fn);
|
||||
unsigned arity = ues.get_arity_of(0);
|
||||
|
|
@ -419,7 +419,7 @@ struct structural_rec_fn {
|
|||
expr m_F;
|
||||
expr m_C;
|
||||
|
||||
elim_rec_apps_fn(type_context & ctx, expr const & fn,
|
||||
elim_rec_apps_fn(type_context_old & ctx, expr const & fn,
|
||||
unsigned arg_pos, buffer<unsigned> const & indices_pos, expr const & F, expr const & C):
|
||||
replace_visitor_with_tc(ctx),
|
||||
m_fn(fn), m_arg_pos(arg_pos), m_indices_pos(indices_pos), m_F(F), m_C(C) {}
|
||||
|
|
@ -522,7 +522,7 @@ struct structural_rec_fn {
|
|||
2) W have an equation (second) where the recursive argument is a variable
|
||||
(flag incomplete).
|
||||
*/
|
||||
bool must_complete_rec_arg(type_context & ctx, unpack_eqns const & ues) {
|
||||
bool must_complete_rec_arg(type_context_old & ctx, unpack_eqns const & ues) {
|
||||
if (m_arg_pos == 0) return false;
|
||||
buffer<expr> const & eqns = ues.get_eqns_of(0);
|
||||
bool has_case_analysis_before = false;
|
||||
|
|
@ -550,7 +550,7 @@ struct structural_rec_fn {
|
|||
return false;
|
||||
}
|
||||
|
||||
void update_eqs(type_context & ctx, unpack_eqns & ues, expr const & fn, expr const & new_fn) {
|
||||
void update_eqs(type_context_old & ctx, unpack_eqns & ues, expr const & fn, expr const & new_fn) {
|
||||
/* C is a temporary "abstract" motive, we use it to access the "brec_on dictionary".
|
||||
The "brec_on dictionary is an element of type below, and it is the last argument of the new function. */
|
||||
expr C = mk_local(ctx.next_name(), "_C", m_motive_type, binder_info());
|
||||
|
|
@ -579,7 +579,7 @@ struct structural_rec_fn {
|
|||
expr new_lhs = mk_app(new_fn, new_lhs_args);
|
||||
expr type = ctx.whnf(ctx.infer(new_lhs));
|
||||
lean_assert(is_pi(type));
|
||||
type_context::tmp_locals extra(ctx);
|
||||
type_context_old::tmp_locals extra(ctx);
|
||||
expr F = extra.push_local(binding_name(type), binding_domain(type));
|
||||
new_vars.push_back(F);
|
||||
new_lhs = mk_app(new_lhs, F);
|
||||
|
|
@ -606,7 +606,7 @@ struct structural_rec_fn {
|
|||
}
|
||||
|
||||
optional<expr> elim_recursion(expr const & e) {
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
unpack_eqns ues(ctx, e);
|
||||
if (ues.get_num_fns() != 1) {
|
||||
trace_struct(tout() << "structural recursion is not supported for mutually recursive functions:";
|
||||
|
|
@ -640,7 +640,7 @@ struct structural_rec_fn {
|
|||
return some_expr(new_eqns);
|
||||
}
|
||||
|
||||
expr whnf_upto_below(type_context & ctx, name const & I_name, expr const & below_type) {
|
||||
expr whnf_upto_below(type_context_old & ctx, name const & I_name, expr const & below_type) {
|
||||
name below_name(I_name, "below");
|
||||
name ibelow_name(I_name, "ibelow");
|
||||
return ctx.whnf_head_pred(below_type, [&](expr const & e) {
|
||||
|
|
@ -654,8 +654,8 @@ struct structural_rec_fn {
|
|||
}
|
||||
|
||||
expr mk_function(expr const & aux_fn) {
|
||||
type_context ctx = mk_type_context();
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old ctx = mk_type_context();
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
buffer<expr> fn_args;
|
||||
expr aux_fn_type = ctx.infer(aux_fn);
|
||||
for (unsigned i = 0; i < m_arity + 1 /* below argument */; i++) {
|
||||
|
|
@ -723,7 +723,7 @@ struct structural_rec_fn {
|
|||
unsigned m_arg_pos;
|
||||
buffer<unsigned> const & m_indices_pos;
|
||||
public:
|
||||
mk_lemma_rhs_fn(type_context & ctx, expr const & fn, expr const & F, expr const & rec_arg,
|
||||
mk_lemma_rhs_fn(type_context_old & ctx, expr const & fn, expr const & F, expr const & rec_arg,
|
||||
unsigned arg_pos, buffer<unsigned> const & indices_pos):
|
||||
replace_visitor_with_tc(ctx), m_fn(fn), m_F(F), m_lhs_rec_arg(rec_arg),
|
||||
m_arg_pos(arg_pos), m_indices_pos(indices_pos) {}
|
||||
|
|
@ -924,15 +924,15 @@ struct structural_rec_fn {
|
|||
}
|
||||
};
|
||||
|
||||
expr mk_lemma_rhs(type_context & ctx, expr const & fn, expr const & F, expr const & rec_arg, expr const & rhs) {
|
||||
expr mk_lemma_rhs(type_context_old & ctx, expr const & fn, expr const & F, expr const & rec_arg, expr const & rhs) {
|
||||
return mk_lemma_rhs_fn(ctx, fn, F, rec_arg, m_arg_pos, m_indices_pos)(rhs);
|
||||
}
|
||||
|
||||
void mk_lemmas(expr const & fn, list<expr> const & lemmas) {
|
||||
unsigned eqn_idx = 1;
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
for (expr type : lemmas) {
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
type = ctx.relaxed_whnf(type);
|
||||
while (is_pi(type)) {
|
||||
expr local = locals.push_local_from_binding(type);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ Author: Leonardo de Moura
|
|||
#include "frontends/lean/elaborator.h"
|
||||
|
||||
namespace lean {
|
||||
static expr replace_rec_apps(type_context & ctx, expr const & e) {
|
||||
static expr replace_rec_apps(type_context_old & ctx, expr const & e) {
|
||||
equations_header const & header = get_equations_header(e);
|
||||
list<name> actual_names = header.m_fn_actual_names;
|
||||
unpack_eqns ues(ctx, e);
|
||||
|
|
@ -48,7 +48,7 @@ static expr replace_rec_apps(type_context & ctx, expr const & e) {
|
|||
return r;
|
||||
}
|
||||
|
||||
static void split_rec_fns(type_context & ctx, expr const & e, buffer<expr> & result) {
|
||||
static void split_rec_fns(type_context_old & ctx, expr const & e, buffer<expr> & result) {
|
||||
equations_header const & header = get_equations_header(e);
|
||||
unpack_eqns ues(ctx, e);
|
||||
list<name> fn_names = header.m_fn_names;
|
||||
|
|
@ -87,7 +87,7 @@ static expr fix_rec_apps(expr const & e, name_map<expr> const & name2new_type,
|
|||
eqn_compiler_result unbounded_rec(environment & env, elaborator & elab,
|
||||
metavar_context & mctx, local_context const & lctx,
|
||||
expr const & e) {
|
||||
type_context ctx(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old ctx(env, mctx, lctx, elab.get_cache(), transparency_mode::Semireducible);
|
||||
|
||||
/* Replace recursive application with macro, and split mutual definition in n definitions. */
|
||||
expr e1 = replace_rec_apps(ctx, e);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static expr consume_fn_prefix(expr eq, buffer<expr> const & fns) {
|
|||
return instantiate_rev(eq, fns);
|
||||
}
|
||||
|
||||
unpack_eqns::unpack_eqns(type_context & ctx, expr const & e):
|
||||
unpack_eqns::unpack_eqns(type_context_old & ctx, expr const & e):
|
||||
m_locals(ctx) {
|
||||
lean_assert(is_equations(e));
|
||||
m_src = e;
|
||||
|
|
@ -128,7 +128,7 @@ unpack_eqns::unpack_eqns(type_context & ctx, expr const & e):
|
|||
}
|
||||
} else {
|
||||
/* noequation, guess arity using type of function */
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
expr type = ctx.relaxed_whnf(ctx.infer(m_fns[fidx]));
|
||||
unsigned arity = 0;
|
||||
while (is_pi(type)) {
|
||||
|
|
@ -161,7 +161,7 @@ expr unpack_eqns::repack() {
|
|||
return update_equations(m_src, new_eqs);
|
||||
}
|
||||
|
||||
unpack_eqn::unpack_eqn(type_context & ctx, expr const & eqn):
|
||||
unpack_eqn::unpack_eqn(type_context_old & ctx, expr const & eqn):
|
||||
m_src(eqn), m_locals(ctx) {
|
||||
expr it = eqn;
|
||||
while (is_lambda(it)) {
|
||||
|
|
@ -191,7 +191,7 @@ expr unpack_eqn::repack() {
|
|||
return copy_tag(m_src, m_locals.ctx().mk_lambda(m_vars, new_eq));
|
||||
}
|
||||
|
||||
bool is_recursive_eqns(type_context & ctx, expr const & e) {
|
||||
bool is_recursive_eqns(type_context_old & ctx, expr const & e) {
|
||||
unpack_eqns ues(ctx, e);
|
||||
for (unsigned fidx = 0; fidx < ues.get_num_fns(); fidx++) {
|
||||
buffer<expr> const & eqns = ues.get_eqns_of(fidx);
|
||||
|
|
@ -314,8 +314,8 @@ pair<environment, expr> mk_aux_definition(environment const & env, options const
|
|||
|
||||
static pair<environment, expr> abstract_rhs_nested_proofs(environment const & env, metavar_context const & mctx, local_context const & lctx,
|
||||
name const & base_name, expr const & e) {
|
||||
type_context ctx(env, options(), mctx, lctx, transparency_mode::Semireducible);
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old ctx(env, options(), mctx, lctx, transparency_mode::Semireducible);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
expr t = e;
|
||||
while (is_pi(t)) {
|
||||
expr d = instantiate_rev(binding_domain(t), locals.size(), locals.data());
|
||||
|
|
@ -368,7 +368,7 @@ static environment add_equation_lemma(environment const & env, options const & o
|
|||
return new_env;
|
||||
}
|
||||
|
||||
static expr whnf_ite(type_context & ctx, expr const & e) {
|
||||
static expr whnf_ite(type_context_old & ctx, expr const & e) {
|
||||
/* We use id_rhs as a "marker" to decide when to stop the whnf computation. */
|
||||
return ctx.whnf_head_pred(e, [&](expr const & e) {
|
||||
expr const & fn = get_app_fn(e);
|
||||
|
|
@ -383,8 +383,8 @@ static bool is_ite_eq(expr const & lhs, buffer<expr> & ite_args) {
|
|||
return is_constant(fn, get_ite_name()) && ite_args.size() == 5 && is_eq(ite_args[0]);
|
||||
}
|
||||
|
||||
static bool conservative_is_def_eq(type_context & ctx, expr const & a, expr const & b) {
|
||||
type_context::transparency_scope scope(ctx, transparency_mode::Reducible);
|
||||
static bool conservative_is_def_eq(type_context_old & ctx, expr const & a, expr const & b) {
|
||||
type_context_old::transparency_scope scope(ctx, transparency_mode::Reducible);
|
||||
return ctx.is_def_eq(a, b);
|
||||
}
|
||||
|
||||
|
|
@ -409,7 +409,7 @@ static lbool compare_values(expr const & a, expr const & b) {
|
|||
return l_undef;
|
||||
}
|
||||
|
||||
static bool quick_is_def_eq_when_values(type_context & ctx, expr const & a, expr const & b) {
|
||||
static bool quick_is_def_eq_when_values(type_context_old & ctx, expr const & a, expr const & b) {
|
||||
if (!is_local(a) && !is_local(b)) {
|
||||
if (compare_values(a, b) == l_true)
|
||||
return true;
|
||||
|
|
@ -418,7 +418,7 @@ static bool quick_is_def_eq_when_values(type_context & ctx, expr const & a, expr
|
|||
}
|
||||
|
||||
/* Try to find (H : not (c_lhs = c_rhs)) at Hs */
|
||||
static optional<expr> find_if_neg_hypothesis(type_context & ctx, expr const & c_lhs, expr const & c_rhs,
|
||||
static optional<expr> find_if_neg_hypothesis(type_context_old & ctx, expr const & c_lhs, expr const & c_rhs,
|
||||
buffer<expr> const & Hs) {
|
||||
for (expr const & H : Hs) {
|
||||
expr H_type = ctx.infer(H);
|
||||
|
|
@ -458,7 +458,7 @@ static optional<expr> find_if_neg_hypothesis(type_context & ctx, expr const & c_
|
|||
(eq.symm (g_f_eq a))
|
||||
(f_g_eq a)
|
||||
*/
|
||||
static optional<expr_pair> prove_eq_rec_invertible_aux(type_context & ctx, expr const & e) {
|
||||
static optional<expr_pair> prove_eq_rec_invertible_aux(type_context_old & ctx, expr const & e) {
|
||||
buffer<expr> rec_args;
|
||||
expr rec_fn = get_app_args(e, rec_args);
|
||||
if (!is_constant(rec_fn, get_eq_rec_name()) || rec_args.size() != 6) return optional<expr_pair>();
|
||||
|
|
@ -502,7 +502,7 @@ static optional<expr_pair> prove_eq_rec_invertible_aux(type_context & ctx, expr
|
|||
expr f_a_eq_f_a = mk_eq(ctx, f_a, f_a);
|
||||
/* (fun H : f a = f a, eq.refl (h a)) */
|
||||
expr pr_minor = mk_lambda("_H", f_a_eq_f_a, refl_h_a);
|
||||
type_context::tmp_locals aux_locals(ctx);
|
||||
type_context_old::tmp_locals aux_locals(ctx);
|
||||
expr x = aux_locals.push_local("_x", A);
|
||||
/* Remark: we cannot use mk_app(f, x) in the following line.
|
||||
Reason: f may have implicit arguments. So, app_fn(f_x) is not equal to f in general,
|
||||
|
|
@ -549,7 +549,7 @@ static optional<expr_pair> prove_eq_rec_invertible_aux(type_context & ctx, expr
|
|||
We build an auxiliary proof for (F = h a) using prove_eq_rec_invertible_aux.
|
||||
Then, we use congr_fun to build the final proof if n > 0
|
||||
*/
|
||||
static optional<expr_pair> prove_eq_rec_invertible(type_context & ctx, expr const & e) {
|
||||
static optional<expr_pair> prove_eq_rec_invertible(type_context_old & ctx, expr const & e) {
|
||||
buffer<expr> args;
|
||||
expr const & fn = get_app_args(e, args);
|
||||
if (args.size() == 6) {
|
||||
|
|
@ -582,7 +582,7 @@ static optional<expr_pair> prove_eq_rec_invertible(type_context & ctx, expr cons
|
|||
}
|
||||
}
|
||||
|
||||
static expr prove_eqn_lemma_core(type_context & ctx, buffer<expr> const & Hs, expr const & lhs, expr const & rhs, bool root) {
|
||||
static expr prove_eqn_lemma_core(type_context_old & ctx, buffer<expr> const & Hs, expr const & lhs, expr const & rhs, bool root) {
|
||||
buffer<expr> ite_args;
|
||||
expr new_lhs = whnf_ite(ctx, lhs);
|
||||
if (is_ite_eq(new_lhs, ite_args)) {
|
||||
|
|
@ -711,7 +711,7 @@ static expr prove_eqn_lemma_core(type_context & ctx, buffer<expr> const & Hs, ex
|
|||
while building the proof. However, the performance problem described in Option 2 may happen.
|
||||
*/
|
||||
if (root) {
|
||||
/* Remark: type_context currently does not have support for id_delta.
|
||||
/* Remark: type_context_old currently does not have support for id_delta.
|
||||
So, we unfold lhs before invoking ctx.is_def_eq. */
|
||||
expr lhs_body = lhs;
|
||||
if (auto b = unfold_term(ctx.env(), lhs))
|
||||
|
|
@ -731,8 +731,8 @@ static expr prove_eqn_lemma_core(type_context & ctx, buffer<expr> const & Hs, ex
|
|||
"disable lemma generation using `set_option eqn_compiler.lemmas false`)");
|
||||
}
|
||||
|
||||
static expr prove_eqn_lemma(type_context & ctx, buffer<expr> const & Hs, expr const & lhs, expr const & rhs) {
|
||||
type_context::smart_unfolding_scope S(ctx, false);
|
||||
static expr prove_eqn_lemma(type_context_old & ctx, buffer<expr> const & Hs, expr const & lhs, expr const & rhs) {
|
||||
type_context_old::smart_unfolding_scope S(ctx, false);
|
||||
if (auto new_lhs = unfold_app(ctx.env(), lhs)) {
|
||||
buffer<expr> args;
|
||||
expr fn = get_app_args(*new_lhs, args);
|
||||
|
|
@ -805,7 +805,7 @@ environment mk_equation_lemma(environment const & env, options const & opts, met
|
|||
name const & f_name, name const & f_actual_name, unsigned eqn_idx, bool is_private,
|
||||
buffer<expr> const & Hs, expr const & lhs, expr const & rhs) {
|
||||
if (!get_eqn_compiler_lemmas(opts)) return env;
|
||||
type_context ctx(env, opts, mctx, lctx, transparency_mode::Semireducible);
|
||||
type_context_old ctx(env, opts, mctx, lctx, transparency_mode::Semireducible);
|
||||
expr proof = prove_eqn_lemma(ctx, Hs, lhs, rhs);
|
||||
expr new_rhs = cleanup_equation_rhs(rhs);
|
||||
expr type = ctx.mk_pi(Hs, mk_eq(ctx, lhs, new_rhs));
|
||||
|
|
@ -818,11 +818,11 @@ environment mk_simple_equation_lemma_for(environment const & env, options const
|
|||
if (!env.find(get_eq_name())) return env;
|
||||
if (!get_eqn_compiler_lemmas(opts)) return env;
|
||||
declaration d = env.get(c_actual);
|
||||
type_context ctx(env, transparency_mode::All);
|
||||
type_context_old ctx(env, transparency_mode::All);
|
||||
expr type = d.get_type();
|
||||
expr value = d.get_value();
|
||||
expr lhs = mk_constant(c_actual, param_names_to_levels(d.get_univ_params()));
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
for (unsigned i = 0; i < arity; i++) {
|
||||
type = ctx.relaxed_whnf(type);
|
||||
value = ctx.relaxed_whnf(value);
|
||||
|
|
@ -853,7 +853,7 @@ bool is_name_value(expr const & e) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool is_nat_int_char_string_name_value(type_context & ctx, expr const & e) {
|
||||
bool is_nat_int_char_string_name_value(type_context_old & ctx, expr const & e) {
|
||||
if (is_char_value(ctx, e) || is_string_value(e) || is_name_value(e)) return true;
|
||||
if (is_signed_num(e)) {
|
||||
expr type = ctx.infer(e);
|
||||
|
|
@ -868,7 +868,7 @@ static bool is_inductive(environment const & env, expr const & e) {
|
|||
}
|
||||
|
||||
/* Normalize until head is an inductive datatype */
|
||||
static expr whnf_inductive(type_context & ctx, expr const & e) {
|
||||
static expr whnf_inductive(type_context_old & ctx, expr const & e) {
|
||||
return ctx.whnf_head_pred(e, [&](expr const & e) {
|
||||
return !is_inductive(ctx.env(), get_app_fn(e));
|
||||
});
|
||||
|
|
@ -883,7 +883,7 @@ static void get_constructors_of(environment const & env, name const & n, buffer<
|
|||
where new_vars are fresh variables and are arguments of (c A ...)
|
||||
which have not been fixed by typing constraints. Moreover, fn is only invoked if
|
||||
the type of (c A ...) matches (I A idx). */
|
||||
void for_each_compatible_constructor(type_context & ctx, expr const & var,
|
||||
void for_each_compatible_constructor(type_context_old & ctx, expr const & var,
|
||||
std::function<void(expr const &, buffer<expr> &)> const & fn) {
|
||||
lean_assert(is_local(var));
|
||||
expr var_type = whnf_inductive(ctx, ctx.infer(var));
|
||||
|
|
@ -903,7 +903,7 @@ void for_each_compatible_constructor(type_context & ctx, expr const & var,
|
|||
expr c = mk_app(mk_constant(c_name, I_ls), I_params);
|
||||
expr it = whnf_inductive(ctx, ctx.infer(c));
|
||||
{
|
||||
type_context::tmp_mode_scope scope(ctx);
|
||||
type_context_old::tmp_mode_scope scope(ctx);
|
||||
while (is_pi(it)) {
|
||||
expr new_arg = ctx.mk_tmp_mvar(binding_domain(it));
|
||||
c_vars.push_back(new_arg);
|
||||
|
|
@ -952,7 +952,7 @@ void for_each_compatible_constructor(type_context & ctx, expr const & var,
|
|||
|
||||
\remark The set of variables in t is a subset of {x_1, ..., x_{i-1}} union {y_1, ..., y_k}
|
||||
*/
|
||||
void update_telescope(type_context & ctx, buffer<expr> const & vars, expr const & var,
|
||||
void update_telescope(type_context_old & ctx, buffer<expr> const & vars, expr const & var,
|
||||
expr const & t, buffer<expr> const & t_vars, buffer<expr> & new_vars,
|
||||
buffer<expr> & from, buffer<expr> & to) {
|
||||
/* We are replacing `var` with `c` */
|
||||
|
|
@ -1021,11 +1021,11 @@ struct replace_rec_fn_macro_fn : public replace_visitor {
|
|||
};
|
||||
|
||||
environment mk_smart_unfolding_definition(environment const & env, options const & o, name const & n) {
|
||||
type_context ctx(env, o, metavar_context(), local_context());
|
||||
type_context_old ctx(env, o, metavar_context(), local_context());
|
||||
declaration const & d = env.get(n);
|
||||
expr val = d.get_value();
|
||||
levels ls = param_names_to_levels(d.get_univ_params());
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
while (is_lambda(val)) {
|
||||
val = instantiate(binding_body(val), locals.push_local_from_binding(val));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ bool get_eqn_compiler_zeta(options const & o);
|
|||
TODO(Leo): as soon as we remove the legacy code from Lean2, this
|
||||
class will be much simpler. */
|
||||
class unpack_eqns {
|
||||
type_context::tmp_locals m_locals;
|
||||
type_context_old::tmp_locals m_locals;
|
||||
expr m_src;
|
||||
buffer<expr> m_fns;
|
||||
/* m_arity[i] contains the number of arguments for each equation lhs
|
||||
|
|
@ -36,7 +36,7 @@ class unpack_eqns {
|
|||
public:
|
||||
/** \brief Extract the data stored in the equations-expression \c e.
|
||||
\pre is_equations(e) */
|
||||
unpack_eqns(type_context & ctx, expr const & e);
|
||||
unpack_eqns(type_context_old & ctx, expr const & e);
|
||||
/** \brief Re-build an equations-expression using the information
|
||||
stored at m_fns and m_eqs. */
|
||||
expr repack();
|
||||
|
|
@ -55,7 +55,7 @@ public:
|
|||
/** \brief Helper class for unpacking a single equation nested in a equations expression. */
|
||||
class unpack_eqn {
|
||||
expr m_src;
|
||||
type_context::tmp_locals m_locals;
|
||||
type_context_old::tmp_locals m_locals;
|
||||
bool m_modified_vars{false};
|
||||
buffer<expr> m_vars;
|
||||
expr m_nested_src;
|
||||
|
|
@ -63,7 +63,7 @@ class unpack_eqn {
|
|||
expr m_rhs;
|
||||
bool m_ignore_if_unused;
|
||||
public:
|
||||
unpack_eqn(type_context & ctx, expr const & eqn);
|
||||
unpack_eqn(type_context_old & ctx, expr const & eqn);
|
||||
expr add_var(name const & n, expr const & type);
|
||||
buffer<expr> & get_vars() { return m_vars; }
|
||||
expr & lhs() { return m_lhs; }
|
||||
|
|
@ -76,7 +76,7 @@ public:
|
|||
/** \brief Return true iff \c e is recursive. That is, some equation
|
||||
in the rhs has a reference to a function being defined by the
|
||||
equations. */
|
||||
bool is_recursive_eqns(type_context & ctx, expr const & e);
|
||||
bool is_recursive_eqns(type_context_old & ctx, expr const & e);
|
||||
|
||||
expr erase_inaccessible_annotations(expr const & e);
|
||||
list<expr> erase_inaccessible_annotations(list<expr> const & es);
|
||||
|
|
@ -118,14 +118,14 @@ environment mk_simple_equation_lemma_for(environment const & env, options const
|
|||
name mk_equation_name(name const & f_name, unsigned eqn_idx);
|
||||
|
||||
/* Return true iff e is a nat, int, char or string value. */
|
||||
bool is_nat_int_char_string_name_value(type_context & ctx, expr const & e);
|
||||
bool is_nat_int_char_string_name_value(type_context_old & ctx, expr const & e);
|
||||
|
||||
/* Given a variable (x : I A idx), where (I A idx) is an inductive datatype,
|
||||
for each constructor c of (I A idx), this function invokes fn(t, new_vars) where t is of the form (c A ...),
|
||||
where new_vars are fresh variables and are arguments of (c A ...)
|
||||
which have not been fixed by typing constraints. Moreover, fn is only invoked if
|
||||
the type of (c A ...) matches (I A idx). */
|
||||
void for_each_compatible_constructor(type_context & ctx, expr const & var,
|
||||
void for_each_compatible_constructor(type_context_old & ctx, expr const & var,
|
||||
std::function<void(expr const &, buffer<expr> &)> const & fn);
|
||||
|
||||
/* Given the telescope vars [x_1, ..., x_i, ..., x_n] and var := x_i,
|
||||
|
|
@ -140,12 +140,12 @@ void for_each_compatible_constructor(type_context & ctx, expr const & var,
|
|||
|
||||
The replacement will suppress entries x_j => T(x_j) if T(x_j) is equal to x_j.
|
||||
*/
|
||||
void update_telescope(type_context & ctx, buffer<expr> const & vars, expr const & var,
|
||||
void update_telescope(type_context_old & ctx, buffer<expr> const & vars, expr const & var,
|
||||
expr const & t, buffer<expr> const & t_vars, buffer<expr> & new_vars,
|
||||
buffer<expr> & from, buffer<expr> & to);
|
||||
|
||||
/* Create auxiliary definition for unfolding declaration `n`.
|
||||
See smart unfolding comment at type_context. */
|
||||
See smart unfolding comment at type_context_old. */
|
||||
environment mk_smart_unfolding_definition(environment const & env, options const & o, name const & n);
|
||||
|
||||
struct eqn_compiler_result {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ Author: Leonardo de Moura
|
|||
#include "library/equations_compiler/util.h"
|
||||
|
||||
namespace lean {
|
||||
#define trace_wf(Code) lean_trace(name({"eqn_compiler", "wf_rec"}), type_context ctx = mk_type_context(); scope_trace_env _scope1(m_env, ctx); Code)
|
||||
#define trace_debug_wf(Code) lean_trace(name({"debug", "eqn_compiler", "wf_rec"}), type_context ctx = mk_type_context(); scope_trace_env _scope1(m_env, ctx); Code)
|
||||
#define trace_wf(Code) lean_trace(name({"eqn_compiler", "wf_rec"}), type_context_old ctx = mk_type_context(); scope_trace_env _scope1(m_env, ctx); Code)
|
||||
#define trace_debug_wf(Code) lean_trace(name({"debug", "eqn_compiler", "wf_rec"}), type_context_old ctx = mk_type_context(); scope_trace_env _scope1(m_env, ctx); Code)
|
||||
#define trace_debug_wf_aux(Code) lean_trace(name({"debug", "eqn_compiler", "wf_rec"}), scope_trace_env _scope1(m_env, ctx); Code)
|
||||
|
||||
struct wf_rec_fn {
|
||||
|
|
@ -48,11 +48,11 @@ struct wf_rec_fn {
|
|||
m_env(env), m_elab(elab), m_mctx(mctx), m_lctx(lctx) {
|
||||
}
|
||||
|
||||
type_context mk_type_context(local_context const & lctx) {
|
||||
return type_context(m_env, m_mctx, lctx, m_elab.get_cache(), transparency_mode::Semireducible);
|
||||
type_context_old mk_type_context(local_context const & lctx) {
|
||||
return type_context_old(m_env, m_mctx, lctx, m_elab.get_cache(), transparency_mode::Semireducible);
|
||||
}
|
||||
|
||||
type_context mk_type_context() {
|
||||
type_context_old mk_type_context() {
|
||||
return mk_type_context(m_lctx);
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ struct wf_rec_fn {
|
|||
}
|
||||
|
||||
expr pack_domain(expr const & eqns) {
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
expr r = ::lean::pack_domain(ctx, eqns);
|
||||
m_env = ctx.env();
|
||||
m_mctx = ctx.mctx();
|
||||
|
|
@ -69,7 +69,7 @@ struct wf_rec_fn {
|
|||
}
|
||||
|
||||
expr pack_mutual(expr const & eqns) {
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
expr r = ::lean::pack_mutual(ctx, eqns);
|
||||
m_env = ctx.env();
|
||||
m_mctx = ctx.mctx();
|
||||
|
|
@ -78,7 +78,7 @@ struct wf_rec_fn {
|
|||
|
||||
void mk_wf_relation(expr const & eqns, expr const & rel_tac) {
|
||||
lean_assert(get_equations_header(eqns).m_num_fns == 1);
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
unpack_eqns ues(ctx, eqns);
|
||||
name fn_name = head(get_equations_header(eqns).m_fn_names);
|
||||
vm_obj vm_fn = to_obj(ues.get_fn(0));
|
||||
|
|
@ -119,8 +119,8 @@ struct wf_rec_fn {
|
|||
}
|
||||
|
||||
/* Return the type of the functional. */
|
||||
expr mk_new_fn_type(type_context & ctx, unpack_eqns const & ues) {
|
||||
type_context::tmp_locals locals(ctx);
|
||||
expr mk_new_fn_type(type_context_old & ctx, unpack_eqns const & ues) {
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
expr fn = ues.get_fn(0);
|
||||
expr fn_type = ctx.relaxed_whnf(ctx.infer(fn));
|
||||
lean_assert(ues.get_arity_of(0) == 1);
|
||||
|
|
@ -141,7 +141,7 @@ struct wf_rec_fn {
|
|||
expr m_x;
|
||||
expr m_F;
|
||||
|
||||
elim_rec_apps_fn(wf_rec_fn & parent, type_context & ctx, name const & fn_name, expr const & fn, expr const & x, expr const & F):
|
||||
elim_rec_apps_fn(wf_rec_fn & parent, type_context_old & ctx, name const & fn_name, expr const & fn, expr const & x, expr const & F):
|
||||
replace_visitor_with_tc(ctx), m_parent(parent), m_fn_name(fn_name), m_fn(fn), m_x(x), m_F(F) {}
|
||||
|
||||
virtual expr visit_local(expr const & e) {
|
||||
|
|
@ -215,7 +215,7 @@ struct wf_rec_fn {
|
|||
}
|
||||
};
|
||||
|
||||
void update_eqs(type_context & ctx, name const & fn_name, unpack_eqns & ues, expr const & fn, expr const & new_fn) {
|
||||
void update_eqs(type_context_old & ctx, name const & fn_name, unpack_eqns & ues, expr const & fn, expr const & new_fn) {
|
||||
buffer<expr> & eqns = ues.get_eqns_of(0);
|
||||
buffer<expr> new_eqns;
|
||||
for (expr const & eqn : eqns) {
|
||||
|
|
@ -229,7 +229,7 @@ struct wf_rec_fn {
|
|||
expr type = ctx.whnf(ctx.infer(new_lhs));
|
||||
lean_assert(is_pi(type));
|
||||
ue.lhs() = new_lhs;
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
expr F = locals.push_local_from_binding(type);
|
||||
ue.rhs() = ctx.mk_lambda(F, elim_rec_apps_fn(*this, ctx, fn_name, fn, lhs_args[0], F)(rhs));
|
||||
new_eqns.push_back(ue.repack());
|
||||
|
|
@ -238,7 +238,7 @@ struct wf_rec_fn {
|
|||
}
|
||||
|
||||
expr elim_recursion(expr const & eqns) {
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
unpack_eqns ues(ctx, eqns);
|
||||
lean_assert(ues.get_num_fns() == 1);
|
||||
expr fn = ues.get_fn(0);
|
||||
|
|
@ -255,8 +255,8 @@ struct wf_rec_fn {
|
|||
}
|
||||
|
||||
expr mk_fix(expr const & aux_fn) {
|
||||
type_context ctx = mk_type_context();
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old ctx = mk_type_context();
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
buffer<expr> fn_args;
|
||||
expr it = ctx.relaxed_whnf(ctx.infer(aux_fn));
|
||||
lean_assert(is_pi(it));
|
||||
|
|
@ -274,7 +274,7 @@ struct wf_rec_fn {
|
|||
}
|
||||
|
||||
expr mk_fix_aux_function(equations_header const & header, expr fn) {
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
fn = mk_fix(fn);
|
||||
expr fn_type = ctx.infer(fn);
|
||||
expr r;
|
||||
|
|
@ -288,7 +288,7 @@ struct wf_rec_fn {
|
|||
expr m_fn;
|
||||
expr m_F;
|
||||
|
||||
mk_lemma_rhs_fn(type_context & ctx, expr const & fn, expr const & F):
|
||||
mk_lemma_rhs_fn(type_context_old & ctx, expr const & fn, expr const & F):
|
||||
replace_visitor_with_tc(ctx), m_fn(fn), m_F(F) {}
|
||||
|
||||
virtual expr visit_local(expr const & e) override {
|
||||
|
|
@ -308,10 +308,10 @@ struct wf_rec_fn {
|
|||
}
|
||||
};
|
||||
|
||||
expr mk_lemma_rhs(type_context & ctx, expr const & fn, expr rhs) {
|
||||
expr mk_lemma_rhs(type_context_old & ctx, expr const & fn, expr rhs) {
|
||||
rhs = ctx.relaxed_whnf(rhs);
|
||||
lean_assert(is_lambda(rhs));
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
expr F = locals.push_local_from_binding(rhs);
|
||||
rhs = instantiate(binding_body(rhs), F);
|
||||
return mk_lemma_rhs_fn(ctx, fn, F)(rhs);
|
||||
|
|
@ -320,9 +320,9 @@ struct wf_rec_fn {
|
|||
void mk_lemmas(name const & fn_name, expr const & fn, list<expr> const & lemmas) {
|
||||
name const & fn_prv_name = const_name(get_app_fn(fn));
|
||||
unsigned eqn_idx = 1;
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
for (expr type : lemmas) {
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
type = ctx.relaxed_whnf(type);
|
||||
while (is_pi(type)) {
|
||||
expr local = locals.push_local_from_binding(type);
|
||||
|
|
@ -341,7 +341,7 @@ struct wf_rec_fn {
|
|||
m_mctx = ctx.mctx();
|
||||
}
|
||||
|
||||
expr_pair mk_sigma(type_context & ctx, unsigned i, buffer<expr> const & args) {
|
||||
expr_pair mk_sigma(type_context_old & ctx, unsigned i, buffer<expr> const & args) {
|
||||
lean_assert(args.size() > 0);
|
||||
if (i == args.size() - 1) {
|
||||
return mk_pair(args[i], ctx.infer(args[i]));
|
||||
|
|
@ -412,7 +412,7 @@ struct wf_rec_fn {
|
|||
unpack_eqns const & m_ues;
|
||||
buffer<expr> const & m_result_fns;
|
||||
|
||||
unpack_apps_fn(type_context & ctx, name const & packed_name, unsigned packed_num_params,
|
||||
unpack_apps_fn(type_context_old & ctx, name const & packed_name, unsigned packed_num_params,
|
||||
unpack_eqns const & ues, buffer<expr> const & result_fns):
|
||||
replace_visitor_with_tc(ctx), m_packed_name(packed_name), m_packed_num_params(packed_num_params),
|
||||
m_ues(ues), m_result_fns(result_fns) {
|
||||
|
|
@ -432,7 +432,7 @@ struct wf_rec_fn {
|
|||
equations_header const & header = get_equations_header(eqns_before_pack);
|
||||
list<name> fn_names = header.m_fn_names;
|
||||
list<name> fn_actual_names = header.m_fn_actual_names;
|
||||
type_context ctx = mk_type_context();
|
||||
type_context_old ctx = mk_type_context();
|
||||
buffer<expr> result_fns;
|
||||
expr packed_fn_type = ctx.relaxed_whnf(ctx.infer(packed_fn));
|
||||
expr packed_domain = binding_domain(packed_fn_type);
|
||||
|
|
@ -441,7 +441,7 @@ struct wf_rec_fn {
|
|||
for (unsigned fidx = 0; fidx < num_fns; fidx++) {
|
||||
unsigned arity = ues.get_arity_of(fidx);
|
||||
expr fn_type = ctx.infer(ues.get_fn(fidx));
|
||||
type_context::tmp_locals args(ctx);
|
||||
type_context_old::tmp_locals args(ctx);
|
||||
expr it = fn_type;
|
||||
for (unsigned i = 0; i < arity; i++) {
|
||||
it = ctx.relaxed_whnf(it);
|
||||
|
|
@ -477,7 +477,7 @@ struct wf_rec_fn {
|
|||
if (!packed_eqn_decl) break;
|
||||
list<level> packed_eqn_levels = param_names_to_levels(packed_eqn_decl->get_univ_params());
|
||||
expr packed_eqn_type = instantiate_type_univ_params(*packed_eqn_decl, packed_eqn_levels);
|
||||
type_context::tmp_locals args(ctx);
|
||||
type_context_old::tmp_locals args(ctx);
|
||||
expr packed_eqn = packed_eqn_type;
|
||||
while (true) {
|
||||
packed_eqn = ctx.relaxed_whnf(packed_eqn);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace lean {
|
|||
class eval_helper {
|
||||
environment m_env;
|
||||
options m_opts;
|
||||
type_context m_tc;
|
||||
type_context_old m_tc;
|
||||
buffer<vm_obj> m_args;
|
||||
vm_state m_vms;
|
||||
vm_state::profiler m_prof;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ typedef cache_compatibility_helper<fun_info_cache> fun_info_cache_helper;
|
|||
/* CACHE_RESET: YES */
|
||||
MK_THREAD_LOCAL_GET_DEF(fun_info_cache_helper, get_fich);
|
||||
|
||||
fun_info_cache & get_fun_info_cache_for(type_context const & ctx) {
|
||||
fun_info_cache & get_fun_info_cache_for(type_context_old const & ctx) {
|
||||
return get_fich().get_cache_for(ctx);
|
||||
}
|
||||
|
||||
|
|
@ -89,11 +89,11 @@ static list<unsigned> collect_deps(expr const & type, buffer<expr> const & local
|
|||
}
|
||||
|
||||
/* Store parameter info for fn in \c pinfos and return the dependencies of the resulting type. */
|
||||
static list<unsigned> get_core(type_context & ctx,
|
||||
static list<unsigned> get_core(type_context_old & ctx,
|
||||
expr const & fn, buffer<param_info> & pinfos,
|
||||
unsigned max_args) {
|
||||
expr type = ctx.relaxed_try_to_pi(ctx.infer(fn));
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
unsigned i = 0;
|
||||
while (is_pi(type)) {
|
||||
if (i == max_args)
|
||||
|
|
@ -112,7 +112,7 @@ static list<unsigned> get_core(type_context & ctx,
|
|||
return collect_deps(type, locals.as_buffer(), pinfos);
|
||||
}
|
||||
|
||||
fun_info get_fun_info(type_context & ctx, expr const & e) {
|
||||
fun_info get_fun_info(type_context_old & ctx, expr const & e) {
|
||||
fun_info_cache & cache = get_fun_info_cache_for(ctx);
|
||||
auto it = cache.m_cache_get.find(e);
|
||||
if (it != cache.m_cache_get.end())
|
||||
|
|
@ -124,7 +124,7 @@ fun_info get_fun_info(type_context & ctx, expr const & e) {
|
|||
return r;
|
||||
}
|
||||
|
||||
fun_info get_fun_info(type_context & ctx, expr const & e, unsigned nargs) {
|
||||
fun_info get_fun_info(type_context_old & ctx, expr const & e, unsigned nargs) {
|
||||
fun_info_cache & cache = get_fun_info_cache_for(ctx);
|
||||
expr_unsigned key(e, nargs);
|
||||
auto it = cache.m_cache_get_nargs.find(key);
|
||||
|
|
@ -138,10 +138,10 @@ fun_info get_fun_info(type_context & ctx, expr const & e, unsigned nargs) {
|
|||
}
|
||||
|
||||
/* Store subsingleton parameter info for fn in \c ssinfos */
|
||||
static void get_ss_core(type_context & ctx, expr const & fn, buffer<ss_param_info> & ssinfos,
|
||||
static void get_ss_core(type_context_old & ctx, expr const & fn, buffer<ss_param_info> & ssinfos,
|
||||
unsigned max_args) {
|
||||
expr type = ctx.relaxed_try_to_pi(ctx.infer(fn));
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
unsigned i = 0;
|
||||
while (is_pi(type)) {
|
||||
if (i == max_args)
|
||||
|
|
@ -162,7 +162,7 @@ static void get_ss_core(type_context & ctx, expr const & fn, buffer<ss_param_inf
|
|||
}
|
||||
}
|
||||
|
||||
ss_param_infos get_subsingleton_info(type_context & ctx, expr const & e) {
|
||||
ss_param_infos get_subsingleton_info(type_context_old & ctx, expr const & e) {
|
||||
fun_info_cache & cache = get_fun_info_cache_for(ctx);
|
||||
auto it = cache.m_ss_cache_get.find(e);
|
||||
if (it != cache.m_ss_cache_get.end())
|
||||
|
|
@ -174,7 +174,7 @@ ss_param_infos get_subsingleton_info(type_context & ctx, expr const & e) {
|
|||
return r;
|
||||
}
|
||||
|
||||
ss_param_infos get_subsingleton_info(type_context & ctx, expr const & e, unsigned nargs) {
|
||||
ss_param_infos get_subsingleton_info(type_context_old & ctx, expr const & e, unsigned nargs) {
|
||||
fun_info_cache & cache = get_fun_info_cache_for(ctx);
|
||||
expr_unsigned key(e, nargs);
|
||||
auto it = cache.m_ss_cache_get_nargs.find(key);
|
||||
|
|
@ -202,7 +202,7 @@ static bool has_nonsubsingleton_fwd_dep(unsigned i, buffer<param_info> const & p
|
|||
return false;
|
||||
}
|
||||
|
||||
static void trace_if_unsupported(type_context & ctx, expr const & fn,
|
||||
static void trace_if_unsupported(type_context_old & ctx, expr const & fn,
|
||||
buffer<expr> const & args, unsigned prefix_sz, ss_param_infos const & result) {
|
||||
lean_assert(args.size() >= length(result));
|
||||
if (!is_fun_info_trace_enabled())
|
||||
|
|
@ -248,7 +248,7 @@ static void trace_if_unsupported(type_context & ctx, expr const & fn,
|
|||
}
|
||||
}
|
||||
|
||||
unsigned get_specialization_prefix_size(type_context & ctx, expr const & fn, unsigned nargs) {
|
||||
unsigned get_specialization_prefix_size(type_context_old & ctx, expr const & fn, unsigned nargs) {
|
||||
/*
|
||||
We say a function is "cheap" if it is of the form:
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ unsigned get_specialization_prefix_size(type_context & ctx, expr const & fn, uns
|
|||
return prefix_sz;
|
||||
}
|
||||
|
||||
ss_param_infos get_specialized_subsingleton_info(type_context & ctx, expr const & a) {
|
||||
ss_param_infos get_specialized_subsingleton_info(type_context_old & ctx, expr const & a) {
|
||||
lean_assert(is_app(a));
|
||||
buffer<expr> args;
|
||||
expr const & fn = get_app_args(a, args);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Author: Leonardo de Moura
|
|||
#include "kernel/expr.h"
|
||||
|
||||
namespace lean {
|
||||
class type_context;
|
||||
class type_context_old;
|
||||
|
||||
/** \brief Function parameter information. */
|
||||
class param_info {
|
||||
|
|
@ -43,10 +43,10 @@ public:
|
|||
list<unsigned> const & get_result_deps() const { return m_result_deps; }
|
||||
};
|
||||
|
||||
fun_info get_fun_info(type_context & ctx, expr const & fn);
|
||||
fun_info get_fun_info(type_context_old & ctx, expr const & fn);
|
||||
/** \brief Return information assuming the function has only nargs.
|
||||
\pre nargs <= get_fun_info(ctx, fn).get_arity() */
|
||||
fun_info get_fun_info(type_context & ctx, expr const & fn, unsigned nargs);
|
||||
fun_info get_fun_info(type_context_old & ctx, expr const & fn, unsigned nargs);
|
||||
|
||||
/** \brief Subsingleton parameter information */
|
||||
class subsingleton_param_info {
|
||||
|
|
@ -84,8 +84,8 @@ public:
|
|||
typedef subsingleton_param_info ss_param_info;
|
||||
typedef list<ss_param_info> ss_param_infos;
|
||||
|
||||
list<ss_param_info> get_subsingleton_info(type_context & ctx, expr const & fn);
|
||||
list<ss_param_info> get_subsingleton_info(type_context & ctx, expr const & fn, unsigned nargs);
|
||||
list<ss_param_info> get_subsingleton_info(type_context_old & ctx, expr const & fn);
|
||||
list<ss_param_info> get_subsingleton_info(type_context_old & ctx, expr const & fn, unsigned nargs);
|
||||
/** \brief Return subsingleton parameter information for the function application.
|
||||
This is more precise than \c get_subsingleton_info for dependent functions.
|
||||
|
||||
|
|
@ -99,8 +99,8 @@ list<ss_param_info> get_subsingleton_info(type_context & ctx, expr const & fn, u
|
|||
|
||||
The second argument is marked as subsingleton only because the resulting information
|
||||
is taking into account the first argument. */
|
||||
list<ss_param_info> get_specialized_subsingleton_info(type_context & ctx, expr const & app);
|
||||
unsigned get_specialization_prefix_size(type_context & ctx, expr const & fn, unsigned nargs);
|
||||
list<ss_param_info> get_specialized_subsingleton_info(type_context_old & ctx, expr const & app);
|
||||
unsigned get_specialization_prefix_size(type_context_old & ctx, expr const & fn, unsigned nargs);
|
||||
|
||||
/** Clear thread local cache */
|
||||
void clear_fun_info_cache();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ optional<name> is_gintro_rule_app(environment const & env, expr const & e) {
|
|||
return optional<name>(const_name(fn));
|
||||
}
|
||||
|
||||
expr whnf_ginductive(type_context & ctx, expr const & e) {
|
||||
expr whnf_ginductive(type_context_old & ctx, expr const & e) {
|
||||
return ctx.whnf_head_pred(e, [&](expr const & e) {
|
||||
expr const & fn = get_app_fn(e);
|
||||
if (!is_constant(fn)) return true;
|
||||
|
|
@ -30,13 +30,13 @@ expr whnf_ginductive(type_context & ctx, expr const & e) {
|
|||
});
|
||||
}
|
||||
|
||||
expr whnf_gintro_rule(type_context & ctx, expr const & e) {
|
||||
expr whnf_gintro_rule(type_context_old & ctx, expr const & e) {
|
||||
return ctx.whnf_head_pred(e, [&](expr const & e) {
|
||||
return !is_gintro_rule_app(ctx.env(), e);
|
||||
});
|
||||
}
|
||||
|
||||
expr whnf_ginductive_gintro_rule(type_context & ctx, expr const & e) {
|
||||
expr whnf_ginductive_gintro_rule(type_context_old & ctx, expr const & e) {
|
||||
return ctx.whnf_head_pred(e, [&](expr const & e) {
|
||||
expr const & fn = get_app_fn(e);
|
||||
if (!is_constant(fn)) return true;
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ unsigned get_ginductive_num_indices(environment const & env, name const & ind_na
|
|||
list<name> get_ginductive_mut_ind_names(environment const & env, name const & ind_name);
|
||||
|
||||
/* Normalize \c e until it is in weak head normal form OR the head is a ginductive datatype. */
|
||||
expr whnf_ginductive(type_context & ctx, expr const & e);
|
||||
expr whnf_ginductive(type_context_old & ctx, expr const & e);
|
||||
|
||||
/* Normalize \c e until it is in weak head normal form OR the head is a ginductive intro rule (aka constructor) */
|
||||
expr whnf_gintro_rule(type_context & ctx, expr const & e);
|
||||
expr whnf_gintro_rule(type_context_old & ctx, expr const & e);
|
||||
|
||||
/* Normalize \c e until it is in weak head normal form OR the head is a ginductive intro rule (aka constructor)
|
||||
or generalized inductive datatype. */
|
||||
expr whnf_ginductive_gintro_rule(type_context & ctx, expr const & e);
|
||||
expr whnf_ginductive_gintro_rule(type_context_old & ctx, expr const & e);
|
||||
|
||||
/* Similar to is_constructor_app, but takes generalized introduction rules into account. */
|
||||
optional<name> is_gintro_rule_app(environment const & env, expr const & e);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class add_mutual_inductive_decl_fn {
|
|||
name m_basic_ind_name;
|
||||
name m_basic_prefix;
|
||||
|
||||
type_context m_tctx;
|
||||
type_context_old m_tctx;
|
||||
|
||||
buffer<expr> m_index_types;
|
||||
expr m_full_index_type;
|
||||
|
|
@ -317,7 +317,7 @@ class add_mutual_inductive_decl_fn {
|
|||
name basic_has_sizeof_name = mk_has_sizeof_name(mlocal_name(m_basic_decl.get_ind(0)));
|
||||
|
||||
for (unsigned ind_idx = 0; ind_idx < m_mut_decl.get_inds().size(); ++ind_idx) {
|
||||
type_context tctx_synth(m_env, m_opts, lctx);
|
||||
type_context_old tctx_synth(m_env, m_opts, lctx);
|
||||
|
||||
expr const & ind = m_mut_decl.get_ind(ind_idx);
|
||||
name sizeof_name = mk_sizeof_name(mlocal_name(ind));
|
||||
|
|
@ -377,7 +377,7 @@ class add_mutual_inductive_decl_fn {
|
|||
|
||||
void define_sizeof_specs(local_context const & lctx, buffer<expr> const & param_insts) {
|
||||
for (unsigned ind_idx = 0; ind_idx < m_mut_decl.get_inds().size(); ++ind_idx) {
|
||||
type_context tctx_synth(m_env, m_opts, lctx);
|
||||
type_context_old tctx_synth(m_env, m_opts, lctx);
|
||||
expr const & ind = m_mut_decl.get_ind(ind_idx);
|
||||
name sizeof_name = mk_sizeof_name(mlocal_name(ind));
|
||||
|
||||
|
|
@ -403,7 +403,7 @@ class add_mutual_inductive_decl_fn {
|
|||
expr local = mk_local_for(ir_ty);
|
||||
locals.push_back(local);
|
||||
expr candidate = mk_app(m_tctx, get_sizeof_name(), local);
|
||||
type_context stctx(m_env, options(), m_tctx.lctx(), transparency_mode::Semireducible);
|
||||
type_context_old stctx(m_env, options(), m_tctx.lctx(), transparency_mode::Semireducible);
|
||||
if (!stctx.is_def_eq(candidate, mk_constant(get_nat_zero_name())))
|
||||
rhs = mk_nat_add(rhs, candidate);
|
||||
ir_ty = tctx_synth.whnf(instantiate(binding_body(ir_ty), local));
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class add_nested_inductive_decl_fn {
|
|||
bool m_is_trusted;
|
||||
ginductive_decl m_inner_decl;
|
||||
|
||||
type_context m_tctx;
|
||||
type_context_old m_tctx;
|
||||
|
||||
expr m_nested_occ;
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ class add_nested_inductive_decl_fn {
|
|||
return is_constant(fn) && const_name(fn).is_string() && const_name(fn).get_string() == std::string("sizeof");
|
||||
}
|
||||
|
||||
static optional<expr> unfold_sizeof(type_context & tctx, expr const & e) {
|
||||
static optional<expr> unfold_sizeof(type_context_old & tctx, expr const & e) {
|
||||
buffer<expr> args;
|
||||
expr fn = get_app_args(e, args);
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ class add_nested_inductive_decl_fn {
|
|||
if (args.size() == 3 && is_constant(fn) && const_name(fn) == get_sizeof_name()) {
|
||||
// Note(dhs): *.sizeof is irreducible, and *.sizeof_inst are reduced when using transparency_mode::Instances
|
||||
// Here we want to reduce only sizeof_inst to expose the basic *.sizeof application.
|
||||
type_context::transparency_scope scope(tctx, transparency_mode::Instances);
|
||||
type_context_old::transparency_scope scope(tctx, transparency_mode::Instances);
|
||||
expr inst = tctx.whnf(args[1]);
|
||||
if (is_app(inst) && is_sizeof_app(app_arg(inst))) {
|
||||
expr new_e = mk_app(app_arg(tctx.whnf(args[1])), args[2]);
|
||||
|
|
@ -248,7 +248,7 @@ class add_nested_inductive_decl_fn {
|
|||
return none_expr();
|
||||
}
|
||||
|
||||
expr force_unfold_sizeof(type_context & ctx, expr const & e) {
|
||||
expr force_unfold_sizeof(type_context_old & ctx, expr const & e) {
|
||||
if (auto r = unfold_sizeof(ctx, e)) {
|
||||
return *r;
|
||||
} else {
|
||||
|
|
@ -256,7 +256,7 @@ class add_nested_inductive_decl_fn {
|
|||
}
|
||||
}
|
||||
|
||||
expr safe_whnf(type_context & tctx, expr const & e) {
|
||||
expr safe_whnf(type_context_old & tctx, expr const & e) {
|
||||
expr r = tctx.whnf_head_pred(e, [&](expr const & t) {
|
||||
expr fn = get_app_fn(t);
|
||||
if (!is_constant(fn))
|
||||
|
|
@ -317,7 +317,7 @@ class add_nested_inductive_decl_fn {
|
|||
}
|
||||
|
||||
expr mk_pack_injective_type(name const & pack_name, optional<unsigned> pack_arity = optional<unsigned>()) {
|
||||
type_context::tmp_locals locals(m_tctx);
|
||||
type_context_old::tmp_locals locals(m_tctx);
|
||||
buffer<expr> all_args;
|
||||
expr full_ty = m_tctx.infer(mk_constant(pack_name, m_nested_decl.get_levels()));
|
||||
expr ty = full_ty;
|
||||
|
|
@ -771,7 +771,7 @@ class add_nested_inductive_decl_fn {
|
|||
initialize_synth_lctx();
|
||||
if (!m_has_sizeof) return;
|
||||
for (unsigned ind_idx = 0; ind_idx < m_nested_decl.get_num_inds(); ++ind_idx) {
|
||||
type_context tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx);
|
||||
type_context_old tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx);
|
||||
|
||||
expr const & ind = m_nested_decl.get_ind(ind_idx);
|
||||
name inner_sizeof_name = mk_sizeof_name(mlocal_name(m_inner_decl.get_ind(ind_idx)));
|
||||
|
|
@ -837,7 +837,7 @@ class add_nested_inductive_decl_fn {
|
|||
expr c_inner_sizeof = mk_app(mk_app(mk_constant(inner_sizeof_name, m_nested_decl.get_levels()), m_inner_decl.get_params()), m_param_insts);
|
||||
|
||||
for (unsigned ir_idx = 0; ir_idx < m_nested_decl.get_num_intro_rules(ind_idx); ++ir_idx) {
|
||||
type_context tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx);
|
||||
type_context_old tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx);
|
||||
|
||||
expr ty = tctx_synth.whnf(mlocal_type(ind));
|
||||
buffer<expr> indices;
|
||||
|
|
@ -862,7 +862,7 @@ class add_nested_inductive_decl_fn {
|
|||
expr local = mk_local_for(ir_ty);
|
||||
locals.push_back(local);
|
||||
expr candidate = mk_app(tctx_synth, get_sizeof_name(), local);
|
||||
type_context stctx(m_env, options(), tctx_synth.lctx(), transparency_mode::Semireducible);
|
||||
type_context_old stctx(m_env, options(), tctx_synth.lctx(), transparency_mode::Semireducible);
|
||||
if (!stctx.is_def_eq(candidate, mk_constant(get_nat_zero_name())))
|
||||
rhs = mk_nat_add(rhs, candidate);
|
||||
ir_ty = tctx_synth.whnf(instantiate(binding_body(ir_ty), local));
|
||||
|
|
@ -880,7 +880,7 @@ class add_nested_inductive_decl_fn {
|
|||
|
||||
expr lhs_alt;
|
||||
{
|
||||
type_context ntctx(m_env, options(), tctx_synth.lctx(), transparency_mode::None);
|
||||
type_context_old ntctx(m_env, options(), tctx_synth.lctx(), transparency_mode::None);
|
||||
lhs_alt = mk_app(tctx_synth, get_sizeof_name(), ntctx.whnf(mk_app(mk_app(d_c_ir.get_value(), m_inner_decl.get_params()), locals)));
|
||||
}
|
||||
|
||||
|
|
@ -1457,7 +1457,7 @@ class add_nested_inductive_decl_fn {
|
|||
}
|
||||
|
||||
simp_result force_eq_rec(expr const & rec_fn, buffer<expr> const & rec_args) {
|
||||
// See comments above prove_eq_rec_invertible(type_context & ctx, expr const & e) at equation_compiler/util.cpp.
|
||||
// See comments above prove_eq_rec_invertible(type_context_old & ctx, expr const & e) at equation_compiler/util.cpp.
|
||||
lean_assert(is_constant(rec_fn, get_eq_rec_name()) && rec_args.size() == 6);
|
||||
expr B = rec_args[0];
|
||||
expr from = rec_args[1]; /* (f (g (f a))) */
|
||||
|
|
@ -1495,7 +1495,7 @@ class add_nested_inductive_decl_fn {
|
|||
expr f_a_eq_f_a = mk_eq(m_tctx, f_a, f_a);
|
||||
/* (fun H : f a = f a, eq.refl (h a)) */
|
||||
expr pr_minor = mk_lambda("_H", f_a_eq_f_a, refl_h_a);
|
||||
type_context::tmp_locals aux_locals(m_tctx);
|
||||
type_context_old::tmp_locals aux_locals(m_tctx);
|
||||
expr x = aux_locals.push_local("_x", A);
|
||||
/* Remark: we cannot use mk_app(f, x) in the following line.
|
||||
Reason: f may have implicit arguments. So, app_fn(f_x) is not equal to f in general,
|
||||
|
|
@ -1542,7 +1542,7 @@ class add_nested_inductive_decl_fn {
|
|||
return simplify_fn::post(e, parent);
|
||||
}
|
||||
public:
|
||||
sizeof_simplify_fn(type_context & ctx, defeq_canonizer::state & dcs, simp_lemmas const & slss, simp_config const & cfg):
|
||||
sizeof_simplify_fn(type_context_old & ctx, defeq_canonizer::state & dcs, simp_lemmas const & slss, simp_config const & cfg):
|
||||
simplify_fn(ctx, dcs, slss, list<name>(), cfg) {}
|
||||
};
|
||||
|
||||
|
|
@ -1563,8 +1563,8 @@ class add_nested_inductive_decl_fn {
|
|||
environment env = set_reducible(m_env, get_sizeof_name(), reducible_status::Irreducible, false);
|
||||
env = set_reducible(env, get_has_add_add_name(), reducible_status::Irreducible, false);
|
||||
|
||||
type_context tctx(env, m_tctx.get_options(), lctx, transparency_mode::Semireducible);
|
||||
type_context tctx_whnf(env, m_tctx.get_options(), lctx, transparency_mode::None);
|
||||
type_context_old tctx(env, m_tctx.get_options(), lctx, transparency_mode::Semireducible);
|
||||
type_context_old tctx_whnf(env, m_tctx.get_options(), lctx, transparency_mode::None);
|
||||
simp_lemmas all_lemmas = use_sizeof ? join(m_lemmas, m_nested_decl.get_sizeof_lemmas()) : m_lemmas;
|
||||
for (expr const & H : Hs) {
|
||||
expr H_type = tctx_whnf.infer(H);
|
||||
|
|
@ -1590,9 +1590,9 @@ class add_nested_inductive_decl_fn {
|
|||
lean_trace(name({"inductive_compiler", "nested", "prove"}), tout() << "[goal]: " << thm << "\n";);
|
||||
|
||||
expr ty = thm;
|
||||
// Note: type_context only used to manage locals and abstract at the end
|
||||
type_context ctx(m_env, m_tctx.get_options(), use_sizeof ? m_synth_lctx : local_context());
|
||||
type_context::tmp_locals locals(ctx);
|
||||
// Note: type_context_old only used to manage locals and abstract at the end
|
||||
type_context_old ctx(m_env, m_tctx.get_options(), use_sizeof ? m_synth_lctx : local_context());
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
|
||||
while (is_pi(ty)) {
|
||||
expr l = locals.push_local_from_binding(ty);
|
||||
|
|
@ -1644,7 +1644,7 @@ class add_nested_inductive_decl_fn {
|
|||
|
||||
void prove_primitive_pack_sizeof(buffer<expr> const & index_locals) {
|
||||
name n = mk_primitive_name(fn_type::SIZEOF_PACK);
|
||||
type_context tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx, transparency_mode::Semireducible);
|
||||
type_context_old tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx, transparency_mode::Semireducible);
|
||||
|
||||
expr x_unpacked = mk_local_pp("x_unpacked", mk_app(m_nested_occ, index_locals));
|
||||
expr lhs = force_unfold_sizeof(tctx_synth, mk_app(tctx_synth, get_sizeof_name(), mk_app(mk_app(m_primitive_pack, index_locals), x_unpacked)));
|
||||
|
|
@ -1698,7 +1698,7 @@ class add_nested_inductive_decl_fn {
|
|||
|
||||
void prove_nested_pack_sizeof(expr const & start, expr const & /* end */, expr const & nested_pack, buffer<expr> const & index_locals, unsigned nest_idx) {
|
||||
name n = mk_nested_name(fn_type::SIZEOF_PACK, nest_idx);
|
||||
type_context tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx);
|
||||
type_context_old tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx);
|
||||
|
||||
expr x_unpacked = mk_local_pp("x_unpacked", mk_app(start, index_locals));
|
||||
expr lhs = force_unfold_sizeof(tctx_synth, mk_app(tctx_synth, get_sizeof_name(), mk_app(mk_app(nested_pack, index_locals), x_unpacked)));
|
||||
|
|
@ -1732,7 +1732,7 @@ class add_nested_inductive_decl_fn {
|
|||
lean_assert(is_constant(fn) && const_name(fn) == get_eq_name());
|
||||
buffer<expr> pi_args;
|
||||
|
||||
type_context tctx(m_env, m_tctx.get_options(), transparency_mode::Semireducible);
|
||||
type_context_old tctx(m_env, m_tctx.get_options(), transparency_mode::Semireducible);
|
||||
|
||||
expr ty = safe_whnf(tctx, args[0]);
|
||||
while (is_pi(ty)) {
|
||||
|
|
@ -1782,7 +1782,7 @@ class add_nested_inductive_decl_fn {
|
|||
|
||||
void prove_pi_pack_sizeof(expr const & pi_pack, buffer<expr> const & ldeps, expr const & nested_pack_fn, expr const & arg_ty) {
|
||||
name n = mk_pi_name(fn_type::SIZEOF_PACK);
|
||||
type_context tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx, transparency_mode::Semireducible);
|
||||
type_context_old tctx_synth(m_env, m_tctx.get_options(), m_synth_lctx, transparency_mode::Semireducible);
|
||||
|
||||
expr x_unpacked = mk_local_pp("x_unpacked", arg_ty);
|
||||
expr lhs = force_unfold_sizeof(tctx_synth, mk_app(tctx_synth, get_sizeof_name(), mk_app(pi_pack, x_unpacked)));
|
||||
|
|
@ -2081,11 +2081,11 @@ class add_nested_inductive_decl_fn {
|
|||
}
|
||||
}
|
||||
public:
|
||||
assumption_simplify_fn(type_context & ctx, defeq_canonizer::state & dcs, simp_lemmas const & slss, simp_config const & cfg):
|
||||
assumption_simplify_fn(type_context_old & ctx, defeq_canonizer::state & dcs, simp_lemmas const & slss, simp_config const & cfg):
|
||||
simplify_fn(ctx, dcs, slss, list<name>(), cfg) {}
|
||||
};
|
||||
|
||||
expr intros_simp_prove_conjuncts(type_context & tctx, simp_lemmas const & slss, expr const & tgt) {
|
||||
expr intros_simp_prove_conjuncts(type_context_old & tctx, simp_lemmas const & slss, expr const & tgt) {
|
||||
simp_config cfg = get_simp_config();
|
||||
defeq_can_state dcs;
|
||||
|
||||
|
|
@ -2117,7 +2117,7 @@ class add_nested_inductive_decl_fn {
|
|||
expr prove_nested_injective(expr const & inj_type, simp_lemmas const & slss, name const & inj_arrow_name) {
|
||||
lean_trace(name({"inductive_compiler", "nested", "injective"}), tout() << "[try to prove]: " << inj_type << "\n";);
|
||||
|
||||
type_context tctx(m_env, m_opts);
|
||||
type_context_old tctx(m_env, m_opts);
|
||||
buffer<expr> hyps;
|
||||
|
||||
expr ty = inj_type;
|
||||
|
|
@ -2144,7 +2144,7 @@ class add_nested_inductive_decl_fn {
|
|||
buffer<name> new_hyps;
|
||||
while (optional<tactic_state> o_s = intron(1, s, new_hyps, true)) {
|
||||
s = *o_s;
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
local_decl hyp_decl = tctx.lctx().get_local_decl(new_hyps.back());
|
||||
|
||||
expr A, lhs, B, rhs;
|
||||
|
|
@ -2168,7 +2168,7 @@ class add_nested_inductive_decl_fn {
|
|||
|
||||
buffer<name> new_hyps;
|
||||
s = *intron(1, s, new_hyps, true);
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
local_decl hyp_decl = tctx.lctx().get_local_decl(new_hyps.back());
|
||||
|
||||
expr A, lhs, B, rhs;
|
||||
|
|
@ -2182,7 +2182,7 @@ class add_nested_inductive_decl_fn {
|
|||
}
|
||||
|
||||
if (is_heq(s.get_main_goal_decl()->get_type(), A, lhs, B, rhs)) {
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
lean_assert(tctx.is_def_eq(A, B));
|
||||
expr e = mk_app(tctx, get_heq_of_eq_name(), 3, A, lhs, rhs);
|
||||
s = *apply(tctx, false, false, e, s);
|
||||
|
|
@ -2192,12 +2192,12 @@ class add_nested_inductive_decl_fn {
|
|||
|
||||
unsigned arity = get_app_num_args(lhs);
|
||||
{
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
name H_unpack_name({"H_unpack"});
|
||||
expr H_unpack_type = mk_eq(tctx, mk_app(tctx, unpack_name, arity, lhs), mk_app(tctx, unpack_name, arity, rhs));
|
||||
s = *tactic::is_success(assert_define_core(true, H_unpack_name, H_unpack_type, s));
|
||||
{
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
simp_config cfg = get_simp_config();
|
||||
defeq_can_state dcs;
|
||||
simp_lemmas slss;
|
||||
|
|
@ -2209,7 +2209,7 @@ class add_nested_inductive_decl_fn {
|
|||
|
||||
s = *intron(1, s, new_hyps, true);
|
||||
{
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
local_decl H_unpack_decl = tctx.lctx().get_local_decl(new_hyps.back());
|
||||
|
||||
slss = simp_lemmas();
|
||||
|
|
@ -2225,7 +2225,7 @@ class add_nested_inductive_decl_fn {
|
|||
tactic_state prove_pack_injective_easy_direction(tactic_state const & s0) {
|
||||
buffer<name> new_hyps;
|
||||
tactic_state s = *intron(1, s0, new_hyps, true);
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
local_decl hyp_decl = tctx.lctx().get_local_decl(new_hyps.back());
|
||||
|
||||
expr A, lhs, B, rhs;
|
||||
|
|
@ -2239,7 +2239,7 @@ class add_nested_inductive_decl_fn {
|
|||
}
|
||||
expr goal_type = s.get_main_goal_decl()->get_type();
|
||||
{
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
simp_config cfg = get_simp_config();
|
||||
defeq_can_state dcs;
|
||||
simp_lemmas slss;
|
||||
|
|
@ -2265,7 +2265,7 @@ class add_nested_inductive_decl_fn {
|
|||
vm_state vms(m_env, m_opts);
|
||||
scope_vm_state vms_scope(vms);
|
||||
tactic_state s = intros_and_subst(pack_inj_name, pack_inj_type);
|
||||
type_context tctx = mk_type_context_for(s);
|
||||
type_context_old tctx = mk_type_context_for(s);
|
||||
s = *apply(tctx, false, false, mk_constant(get_iff_intro_name()), s);
|
||||
s = prove_pack_injective_hard_direction(s, unpack_name, unpack_pack_name);
|
||||
s = prove_pack_injective_easy_direction(s);
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ implicit_infer_kind get_implicit_infer_kind(name_map<implicit_infer_kind> const
|
|||
|
||||
unsigned get_num_indices(environment const & env, expr const & ind) {
|
||||
unsigned num_indices = 0;
|
||||
type_context tctx(env);
|
||||
type_context_old tctx(env);
|
||||
lean_assert(is_local(ind));
|
||||
expr ind_type = tctx.relaxed_whnf(mlocal_type(ind));
|
||||
type_context::tmp_locals locals(tctx);
|
||||
type_context_old::tmp_locals locals(tctx);
|
||||
while (is_pi(ind_type)) {
|
||||
ind_type = instantiate(binding_body(ind_type), locals.push_local_from_binding(ind_type));
|
||||
ind_type = tctx.relaxed_whnf(ind_type);
|
||||
|
|
@ -39,9 +39,9 @@ unsigned get_num_indices(environment const & env, expr const & ind) {
|
|||
return num_indices;
|
||||
}
|
||||
|
||||
expr get_ind_result_type(type_context & tctx, expr const & ind) {
|
||||
expr get_ind_result_type(type_context_old & tctx, expr const & ind) {
|
||||
expr ind_type = tctx.relaxed_whnf(tctx.infer(ind));
|
||||
type_context::tmp_locals locals(tctx);
|
||||
type_context_old::tmp_locals locals(tctx);
|
||||
while (is_pi(ind_type)) {
|
||||
ind_type = instantiate(binding_body(ind_type), locals.push_local_from_binding(ind_type));
|
||||
ind_type = tctx.relaxed_whnf(ind_type);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace lean {
|
|||
|
||||
implicit_infer_kind get_implicit_infer_kind(name_map<implicit_infer_kind> const & implicit_infer_map, name const & n);
|
||||
unsigned get_num_indices(environment const & env, expr const & ind);
|
||||
expr get_ind_result_type(type_context & tctx, expr const & ind);
|
||||
expr get_ind_result_type(type_context_old & tctx, expr const & ind);
|
||||
void assert_def_eq(environment const & env, expr const & e1, expr const & e2);
|
||||
void assert_type_correct(environment const & env, expr const & e);
|
||||
void assert_no_locals(name const & n, expr const & e);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class local_context {
|
|||
name_map<unsigned_set> m_user_name2idxs;
|
||||
idx2local_decl m_idx2local_decl;
|
||||
optional<local_instances> m_local_instances;
|
||||
friend class type_context;
|
||||
friend class type_context_old;
|
||||
|
||||
void insert_user_name(local_decl const &d);
|
||||
void erase_user_name(local_decl const &d);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ message_builder::message_builder(std::shared_ptr<abstract_type_context> const &
|
|||
message_builder::message_builder(environment const & env, io_state const & ios,
|
||||
std::string const & file_name, pos_info const & pos,
|
||||
message_severity severity) :
|
||||
message_builder(std::make_shared<type_context>(env, ios.get_options()),
|
||||
message_builder(std::make_shared<type_context_old>(env, ios.get_options()),
|
||||
env, ios, file_name, pos, severity) {}
|
||||
|
||||
message message_builder::build() {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Author: Robert Y. Lewis
|
|||
|
||||
namespace lean {
|
||||
class norm_num_context {
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
arith_instance m_ainst;
|
||||
|
||||
pair<expr, expr> mk_norm_add(expr const &, expr const &);
|
||||
|
|
@ -83,12 +83,12 @@ class norm_num_context {
|
|||
expr mk_norm_eq(expr const &, expr const &);
|
||||
|
||||
public:
|
||||
norm_num_context(type_context & ctx): m_ctx(ctx), m_ainst(ctx) {}
|
||||
norm_num_context(type_context_old & ctx): m_ctx(ctx), m_ainst(ctx) {}
|
||||
|
||||
pair<expr, expr> mk_norm(expr const & e);
|
||||
};
|
||||
|
||||
inline pair<expr, expr> mk_norm_num(type_context & ctx, expr const & e) {
|
||||
inline pair<expr, expr> mk_norm_num(type_context_old & ctx, expr const & e) {
|
||||
return norm_num_context(ctx).mk_norm(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,19 +51,19 @@ unsigned persistent_context_cache::get_class_instance_max_depth() const {
|
|||
return m_cache_ptr->get_class_instance_max_depth();
|
||||
}
|
||||
|
||||
optional<declaration> persistent_context_cache::get_decl(type_context & ctx, transparency_mode m, name const & n) {
|
||||
optional<declaration> persistent_context_cache::get_decl(type_context_old & ctx, transparency_mode m, name const & n) {
|
||||
return m_cache_ptr->get_decl(ctx, m, n);
|
||||
}
|
||||
|
||||
projection_info const * persistent_context_cache::get_proj_info(type_context & ctx, name const & n) {
|
||||
projection_info const * persistent_context_cache::get_proj_info(type_context_old & ctx, name const & n) {
|
||||
return m_cache_ptr->get_proj_info(ctx, n);
|
||||
}
|
||||
|
||||
bool persistent_context_cache::get_aux_recursor(type_context & ctx, name const & n) {
|
||||
bool persistent_context_cache::get_aux_recursor(type_context_old & ctx, name const & n) {
|
||||
return m_cache_ptr->get_aux_recursor(ctx, n);
|
||||
}
|
||||
|
||||
void persistent_context_cache::get_unification_hints(type_context & ctx, name const & f1, name const & f2, buffer<unification_hint> & hints) {
|
||||
void persistent_context_cache::get_unification_hints(type_context_old & ctx, name const & f1, name const & f2, buffer<unification_hint> & hints) {
|
||||
return m_cache_ptr->get_unification_hints(ctx, f1, f2, hints);
|
||||
}
|
||||
|
||||
|
|
@ -131,108 +131,108 @@ optional<local_instances> persistent_context_cache::get_frozen_local_instances()
|
|||
return m_cache_ptr->get_frozen_local_instances();
|
||||
}
|
||||
|
||||
optional<fun_info> persistent_context_cache::get_fun_info(type_context & ctx, expr const & e) {
|
||||
optional<fun_info> persistent_context_cache::get_fun_info(type_context_old & ctx, expr const & e) {
|
||||
return m_cache_ptr->get_fun_info(ctx, e);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_fun_info(type_context & ctx, expr const & e, fun_info const & r) {
|
||||
void persistent_context_cache::set_fun_info(type_context_old & ctx, expr const & e, fun_info const & r) {
|
||||
return m_cache_ptr->set_fun_info(ctx, e, r);
|
||||
}
|
||||
|
||||
optional<fun_info> persistent_context_cache::get_fun_info_nargs(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<fun_info> persistent_context_cache::get_fun_info_nargs(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_fun_info_nargs(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_fun_info_nargs(type_context & ctx, expr const & e, unsigned k, fun_info const & r) {
|
||||
void persistent_context_cache::set_fun_info_nargs(type_context_old & ctx, expr const & e, unsigned k, fun_info const & r) {
|
||||
return m_cache_ptr->set_fun_info_nargs(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<unsigned> persistent_context_cache::get_specialization_prefix_size(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<unsigned> persistent_context_cache::get_specialization_prefix_size(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_specialization_prefix_size(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_specialization_prefix_size(type_context & ctx, expr const & e, unsigned k, unsigned r) {
|
||||
void persistent_context_cache::set_specialization_prefix_size(type_context_old & ctx, expr const & e, unsigned k, unsigned r) {
|
||||
return m_cache_ptr->set_specialization_prefix_size(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<ss_param_infos> persistent_context_cache::get_subsingleton_info(type_context & ctx, expr const & e) {
|
||||
optional<ss_param_infos> persistent_context_cache::get_subsingleton_info(type_context_old & ctx, expr const & e) {
|
||||
return m_cache_ptr->get_subsingleton_info(ctx, e);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_subsingleton_info(type_context & ctx, expr const & e, ss_param_infos const & r) {
|
||||
void persistent_context_cache::set_subsingleton_info(type_context_old & ctx, expr const & e, ss_param_infos const & r) {
|
||||
return m_cache_ptr->set_subsingleton_info(ctx, e, r);
|
||||
}
|
||||
|
||||
optional<ss_param_infos> persistent_context_cache::get_subsingleton_info_nargs(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<ss_param_infos> persistent_context_cache::get_subsingleton_info_nargs(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_subsingleton_info_nargs(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_subsingleton_info_nargs(type_context & ctx, expr const & e, unsigned k, ss_param_infos const & r) {
|
||||
void persistent_context_cache::set_subsingleton_info_nargs(type_context_old & ctx, expr const & e, unsigned k, ss_param_infos const & r) {
|
||||
return m_cache_ptr->set_subsingleton_info_nargs(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<ss_param_infos> persistent_context_cache::get_specialized_subsingleton_info_nargs(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<ss_param_infos> persistent_context_cache::get_specialized_subsingleton_info_nargs(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_specialized_subsingleton_info_nargs(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_specialization_subsingleton_info_nargs(type_context & ctx, expr const & e, unsigned k, ss_param_infos const & r) {
|
||||
void persistent_context_cache::set_specialization_subsingleton_info_nargs(type_context_old & ctx, expr const & e, unsigned k, ss_param_infos const & r) {
|
||||
return m_cache_ptr->set_specialization_subsingleton_info_nargs(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<congr_lemma> persistent_context_cache::get_simp_congr_lemma(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<congr_lemma> persistent_context_cache::get_simp_congr_lemma(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_simp_congr_lemma(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_simp_congr_lemma(type_context & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
void persistent_context_cache::set_simp_congr_lemma(type_context_old & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
return m_cache_ptr->set_simp_congr_lemma(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<congr_lemma> persistent_context_cache::get_specialized_simp_congr_lemma(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<congr_lemma> persistent_context_cache::get_specialized_simp_congr_lemma(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_specialized_simp_congr_lemma(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_specialized_simp_congr_lemma(type_context & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
void persistent_context_cache::set_specialized_simp_congr_lemma(type_context_old & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
return m_cache_ptr->set_specialized_simp_congr_lemma(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<congr_lemma> persistent_context_cache::get_congr_lemma(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<congr_lemma> persistent_context_cache::get_congr_lemma(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_congr_lemma(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_congr_lemma(type_context & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
void persistent_context_cache::set_congr_lemma(type_context_old & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
return m_cache_ptr->set_congr_lemma(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<congr_lemma> persistent_context_cache::get_specialized_congr_lemma(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<congr_lemma> persistent_context_cache::get_specialized_congr_lemma(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_specialized_congr_lemma(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_specialized_congr_lemma(type_context & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
void persistent_context_cache::set_specialized_congr_lemma(type_context_old & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
return m_cache_ptr->set_specialized_congr_lemma(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<congr_lemma> persistent_context_cache::get_hcongr_lemma(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<congr_lemma> persistent_context_cache::get_hcongr_lemma(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_hcongr_lemma(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_hcongr_lemma(type_context & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
void persistent_context_cache::set_hcongr_lemma(type_context_old & ctx, expr const & e, unsigned k, congr_lemma const & r) {
|
||||
return m_cache_ptr->set_hcongr_lemma(ctx, e, k, r);
|
||||
}
|
||||
|
||||
optional<app_builder_info> persistent_context_cache::get_app_builder_info(type_context & ctx, expr const & e, unsigned k) {
|
||||
optional<app_builder_info> persistent_context_cache::get_app_builder_info(type_context_old & ctx, expr const & e, unsigned k) {
|
||||
return m_cache_ptr->get_app_builder_info(ctx, e, k);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_app_builder_info(type_context & ctx, expr const & e, unsigned k, app_builder_info const & r) {
|
||||
void persistent_context_cache::set_app_builder_info(type_context_old & ctx, expr const & e, unsigned k, app_builder_info const & r) {
|
||||
return m_cache_ptr->set_app_builder_info(ctx, e, k, r);
|
||||
}
|
||||
|
||||
|
||||
optional<app_builder_info> persistent_context_cache::get_app_builder_info(type_context & ctx, expr const & e, list<bool> const & m) {
|
||||
optional<app_builder_info> persistent_context_cache::get_app_builder_info(type_context_old & ctx, expr const & e, list<bool> const & m) {
|
||||
return m_cache_ptr->get_app_builder_info(ctx, e, m);
|
||||
}
|
||||
|
||||
void persistent_context_cache::set_app_builder_info(type_context & ctx, expr const & e, list<bool> const & m, app_builder_info const & r) {
|
||||
void persistent_context_cache::set_app_builder_info(type_context_old & ctx, expr const & e, list<bool> const & m, app_builder_info const & r) {
|
||||
return m_cache_ptr->set_app_builder_info(ctx, e, m, r);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ public:
|
|||
/* Operations for accessing environment data more efficiently.
|
||||
The default implementation provided by this class does not have any optimization. */
|
||||
|
||||
virtual optional<declaration> get_decl(type_context &, transparency_mode, name const &) override;
|
||||
virtual projection_info const * get_proj_info(type_context &, name const &) override;
|
||||
virtual bool get_aux_recursor(type_context &, name const &) override;
|
||||
virtual void get_unification_hints(type_context &, name const & f1, name const & f2, buffer<unification_hint> & hints) override;
|
||||
virtual optional<declaration> get_decl(type_context_old &, transparency_mode, name const &) override;
|
||||
virtual projection_info const * get_proj_info(type_context_old &, name const &) override;
|
||||
virtual bool get_aux_recursor(type_context_old &, name const &) override;
|
||||
virtual void get_unification_hints(type_context_old &, name const & f1, name const & f2, buffer<unification_hint> & hints) override;
|
||||
|
||||
/* Cache support for type_context module */
|
||||
/* Cache support for type_context_old module */
|
||||
|
||||
virtual optional<expr> get_infer(expr const &) override;
|
||||
virtual void set_infer(expr const &, expr const &) override;
|
||||
|
|
@ -77,47 +77,47 @@ public:
|
|||
|
||||
/* Cache support for fun_info module */
|
||||
|
||||
virtual optional<fun_info> get_fun_info(type_context &, expr const &) override;
|
||||
virtual void set_fun_info(type_context &, expr const &, fun_info const &) override;
|
||||
virtual optional<fun_info> get_fun_info(type_context_old &, expr const &) override;
|
||||
virtual void set_fun_info(type_context_old &, expr const &, fun_info const &) override;
|
||||
|
||||
virtual optional<fun_info> get_fun_info_nargs(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_fun_info_nargs(type_context &, expr const &, unsigned, fun_info const &) override;
|
||||
virtual optional<fun_info> get_fun_info_nargs(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_fun_info_nargs(type_context_old &, expr const &, unsigned, fun_info const &) override;
|
||||
|
||||
virtual optional<unsigned> get_specialization_prefix_size(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_specialization_prefix_size(type_context &, expr const &, unsigned, unsigned) override;
|
||||
virtual optional<unsigned> get_specialization_prefix_size(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_specialization_prefix_size(type_context_old &, expr const &, unsigned, unsigned) override;
|
||||
|
||||
virtual optional<ss_param_infos> get_subsingleton_info(type_context &, expr const &) override;
|
||||
virtual void set_subsingleton_info(type_context &, expr const &, ss_param_infos const &) override;
|
||||
virtual optional<ss_param_infos> get_subsingleton_info(type_context_old &, expr const &) override;
|
||||
virtual void set_subsingleton_info(type_context_old &, expr const &, ss_param_infos const &) override;
|
||||
|
||||
virtual optional<ss_param_infos> get_subsingleton_info_nargs(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_subsingleton_info_nargs(type_context &, expr const &, unsigned, ss_param_infos const &) override;
|
||||
virtual optional<ss_param_infos> get_subsingleton_info_nargs(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_subsingleton_info_nargs(type_context_old &, expr const &, unsigned, ss_param_infos const &) override;
|
||||
|
||||
virtual optional<ss_param_infos> get_specialized_subsingleton_info_nargs(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_specialization_subsingleton_info_nargs(type_context &, expr const &, unsigned, ss_param_infos const &) override;
|
||||
virtual optional<ss_param_infos> get_specialized_subsingleton_info_nargs(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_specialization_subsingleton_info_nargs(type_context_old &, expr const &, unsigned, ss_param_infos const &) override;
|
||||
|
||||
/* Cache support for congr_lemma module */
|
||||
|
||||
virtual optional<congr_lemma> get_simp_congr_lemma(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_simp_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override;
|
||||
virtual optional<congr_lemma> get_simp_congr_lemma(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_simp_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override;
|
||||
|
||||
virtual optional<congr_lemma> get_specialized_simp_congr_lemma(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_specialized_simp_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override;
|
||||
virtual optional<congr_lemma> get_specialized_simp_congr_lemma(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_specialized_simp_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override;
|
||||
|
||||
virtual optional<congr_lemma> get_congr_lemma(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override;
|
||||
virtual optional<congr_lemma> get_congr_lemma(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override;
|
||||
|
||||
virtual optional<congr_lemma> get_specialized_congr_lemma(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_specialized_congr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override;
|
||||
virtual optional<congr_lemma> get_specialized_congr_lemma(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_specialized_congr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override;
|
||||
|
||||
virtual optional<congr_lemma> get_hcongr_lemma(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_hcongr_lemma(type_context &, expr const &, unsigned, congr_lemma const &) override;
|
||||
virtual optional<congr_lemma> get_hcongr_lemma(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_hcongr_lemma(type_context_old &, expr const &, unsigned, congr_lemma const &) override;
|
||||
|
||||
/* Cache support for app_builder */
|
||||
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context &, expr const &, unsigned) override;
|
||||
virtual void set_app_builder_info(type_context &, expr const &, unsigned, app_builder_info const &) override;
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context_old &, expr const &, unsigned) override;
|
||||
virtual void set_app_builder_info(type_context_old &, expr const &, unsigned, app_builder_info const &) override;
|
||||
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context &, expr const &, list<bool> const &) override;
|
||||
virtual void set_app_builder_info(type_context &, expr const &, list<bool> const &, app_builder_info const &) override;
|
||||
virtual optional<app_builder_info> get_app_builder_info(type_context_old &, expr const &, list<bool> const &) override;
|
||||
virtual void set_app_builder_info(type_context_old &, expr const &, list<bool> const &, app_builder_info const &) override;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Author: Leonardo de Moura
|
|||
#include "library/replace_visitor_with_tc.h"
|
||||
namespace lean {
|
||||
expr replace_visitor_with_tc::visit_lambda_pi_let(bool is_lam, expr const & e) {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr t = e;
|
||||
while (true) {
|
||||
if ((is_lam && is_lambda(t)) || (!is_lam && is_pi(t))) {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ Author: Leonardo de Moura
|
|||
#include "library/replace_visitor.h"
|
||||
#include "library/type_context.h"
|
||||
namespace lean {
|
||||
/** \brief Version of replace_visitor with a nested type_context object. */
|
||||
/** \brief Version of replace_visitor with a nested type_context_old object. */
|
||||
class replace_visitor_with_tc : public replace_visitor {
|
||||
protected:
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
expr visit_lambda_pi_let(bool is_lam, expr const & e);
|
||||
virtual expr visit_lambda(expr const & e) override {
|
||||
return visit_lambda_pi_let(true, e);
|
||||
|
|
@ -24,6 +24,6 @@ protected:
|
|||
}
|
||||
virtual expr visit_app(expr const & e) override;
|
||||
public:
|
||||
replace_visitor_with_tc(type_context & ctx):m_ctx(ctx) {}
|
||||
replace_visitor_with_tc(type_context_old & ctx):m_ctx(ctx) {}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ static ac_manager_old::cache_ptr get_cache(environment const & env) {
|
|||
return std::make_shared<ac_manager_old::cache>(env);
|
||||
}
|
||||
|
||||
ac_manager_old::ac_manager_old(type_context & ctx):
|
||||
ac_manager_old::ac_manager_old(type_context_old & ctx):
|
||||
m_ctx(ctx),
|
||||
m_cache_ptr(get_cache(ctx.env())) {
|
||||
}
|
||||
|
|
@ -652,7 +652,7 @@ expr mk_perm_ac_macro(abstract_type_context & ctx, expr const & assoc, expr cons
|
|||
|
||||
vm_obj tactic_flat_assoc(vm_obj const & op, vm_obj const & assoc, vm_obj const & e, vm_obj const & s) {
|
||||
TRY;
|
||||
type_context ctx = mk_type_context_for(s);
|
||||
type_context_old ctx = mk_type_context_for(s);
|
||||
pair<expr, expr> p = flat_assoc_fn(ctx, to_expr(op), to_expr(assoc)).flat(to_expr(e));
|
||||
return tactic::mk_success(mk_vm_pair(to_obj(p.first), to_obj(p.second)), tactic::to_state(s));
|
||||
CATCH;
|
||||
|
|
@ -660,7 +660,7 @@ vm_obj tactic_flat_assoc(vm_obj const & op, vm_obj const & assoc, vm_obj const &
|
|||
|
||||
vm_obj tactic_perm_ac(vm_obj const & op, vm_obj const & assoc, vm_obj const & comm, vm_obj const & e1, vm_obj const & e2, vm_obj const & s) {
|
||||
TRY;
|
||||
type_context ctx = mk_type_context_for(s);
|
||||
type_context_old ctx = mk_type_context_for(s);
|
||||
expr H = perm_ac_fn(ctx, to_expr(op), to_expr(assoc), to_expr(comm)).perm(to_expr(e1), to_expr(e2));
|
||||
return tactic::mk_success(to_obj(H), tactic::to_state(s));
|
||||
CATCH;
|
||||
|
|
|
|||
|
|
@ -66,10 +66,10 @@ public:
|
|||
struct cache;
|
||||
typedef std::shared_ptr<cache> cache_ptr;
|
||||
private:
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
cache_ptr m_cache_ptr;
|
||||
public:
|
||||
ac_manager_old(type_context & ctx);
|
||||
ac_manager_old(type_context_old & ctx);
|
||||
~ac_manager_old();
|
||||
/* If e is of the form (op a b), and op is associative (i.e., there is an instance (is_associative _ op)), then
|
||||
return proof term for forall x y z, op (op x y) z = op x (op y z) */
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ static name * g_algebra = nullptr;
|
|||
|
||||
MK_THREAD_LOCAL_GET_DEF(algebraic_info_manager::data_ptr, get_alg_info_data);
|
||||
|
||||
algebraic_info_manager::algebraic_info_manager(type_context & ctx):
|
||||
algebraic_info_manager::algebraic_info_manager(type_context_old & ctx):
|
||||
m_ctx(ctx) {
|
||||
data_ptr p = get_alg_info_data();
|
||||
if (p &&
|
||||
|
|
@ -49,7 +49,7 @@ algebraic_info_ref algebraic_info_manager::get_info(expr const & op) {
|
|||
|
||||
vm_obj tactic_trace_algebra_info(vm_obj const & op, vm_obj const & _s) {
|
||||
tactic_state const & s = tactic::to_state(_s);
|
||||
type_context ctx = mk_type_context_for(s);
|
||||
type_context_old ctx = mk_type_context_for(s);
|
||||
algebraic_info_manager m(ctx);
|
||||
if (m.get_info(to_expr(op))) {
|
||||
tout() << "operator has algebraic info\n";
|
||||
|
|
|
|||
|
|
@ -98,13 +98,13 @@ public:
|
|||
typedef std::shared_ptr<data> data_ptr;
|
||||
|
||||
private:
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
data_ptr m_data;
|
||||
|
||||
public:
|
||||
algebraic_info_manager(type_context & ctx);
|
||||
algebraic_info_manager(type_context_old & ctx);
|
||||
~algebraic_info_manager();
|
||||
type_context & ctx() const { return m_ctx; }
|
||||
type_context_old & ctx() const { return m_ctx; }
|
||||
algebraic_info_ref get_info(expr const & op);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace lean {
|
|||
vm_obj tactic_mk_app(vm_obj const & c, vm_obj const & as, vm_obj const & tmode, vm_obj const & _s) {
|
||||
tactic_state const & s = tactic::to_state(_s);
|
||||
try {
|
||||
type_context ctx = mk_type_context_for(s, to_transparency_mode(tmode));
|
||||
type_context_old ctx = mk_type_context_for(s, to_transparency_mode(tmode));
|
||||
buffer<expr> args;
|
||||
to_buffer_expr(as, args);
|
||||
expr r = mk_app(ctx, to_name(c), args.size(), args.data());
|
||||
|
|
@ -29,7 +29,7 @@ vm_obj tactic_mk_app(vm_obj const & c, vm_obj const & as, vm_obj const & tmode,
|
|||
#define MK_APP(CODE) { \
|
||||
tactic_state const & s = tactic::to_state(_s); \
|
||||
try { \
|
||||
type_context ctx = mk_type_context_for(s); \
|
||||
type_context_old ctx = mk_type_context_for(s); \
|
||||
expr r = CODE; \
|
||||
return tactic::mk_success(to_obj(r), s); \
|
||||
} catch (exception & ex) { \
|
||||
|
|
@ -72,7 +72,7 @@ vm_obj tactic_mk_eq_mp(vm_obj const & h1, vm_obj const & h2, vm_obj const & _s)
|
|||
vm_obj tactic_mk_mapp(vm_obj const & c, vm_obj const & as, vm_obj const & tmode, vm_obj const & _s) {
|
||||
tactic_state const & s = tactic::to_state(_s);
|
||||
try {
|
||||
type_context ctx = mk_type_context_for(s, to_transparency_mode(tmode));
|
||||
type_context_old ctx = mk_type_context_for(s, to_transparency_mode(tmode));
|
||||
buffer<bool> mask;
|
||||
buffer<expr> args;
|
||||
vm_obj it = as;
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ apply_cfg::apply_cfg(vm_obj const & cfg):
|
|||
Compute the number of expected arguments and whether the result type is of the form
|
||||
(?m ...) where ?m is an unassigned metavariable.
|
||||
*/
|
||||
static pair<unsigned, bool> get_expected_num_args_ho_result(type_context & ctx, expr e) {
|
||||
type_context::tmp_locals locals(ctx);
|
||||
static pair<unsigned, bool> get_expected_num_args_ho_result(type_context_old & ctx, expr e) {
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
unsigned r = 0;
|
||||
while (true) {
|
||||
e = ctx.relaxed_whnf(e);
|
||||
|
|
@ -54,11 +54,11 @@ static pair<unsigned, bool> get_expected_num_args_ho_result(type_context & ctx,
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned get_expected_num_args(type_context & ctx, expr e) {
|
||||
static unsigned get_expected_num_args(type_context_old & ctx, expr e) {
|
||||
return get_expected_num_args_ho_result(ctx, e).first;
|
||||
}
|
||||
|
||||
static bool try_instance(type_context & ctx, expr const & meta, tactic_state const & s, vm_obj * out_error_obj, char const * tac_name) {
|
||||
static bool try_instance(type_context_old & ctx, expr const & meta, tactic_state const & s, vm_obj * out_error_obj, char const * tac_name) {
|
||||
if (ctx.is_assigned(meta))
|
||||
return true;
|
||||
expr meta_type = ctx.instantiate_mvars(ctx.infer(meta));
|
||||
|
|
@ -90,7 +90,7 @@ static bool try_instance(type_context & ctx, expr const & meta, tactic_state con
|
|||
return true;
|
||||
}
|
||||
|
||||
bool synth_instances(type_context & ctx, buffer<expr> const & metas, buffer<bool> const & is_instance,
|
||||
bool synth_instances(type_context_old & ctx, buffer<expr> const & metas, buffer<bool> const & is_instance,
|
||||
tactic_state const & s, vm_obj * out_error_obj, char const * tac_name) {
|
||||
unsigned i = is_instance.size();
|
||||
while (i > 0) {
|
||||
|
|
@ -105,7 +105,7 @@ bool synth_instances(type_context & ctx, buffer<expr> const & metas, buffer<bool
|
|||
/** \brief Given a sequence metas/goals: <tt>(?m_1 ...) (?m_2 ... ) ... (?m_k ...)</tt>,
|
||||
we say ?m_i is "redundant" if it occurs in the type of some ?m_j.
|
||||
This procedure removes from metas any redundant element. */
|
||||
static void remove_dep_goals(type_context & ctx, buffer<expr> & metas) {
|
||||
static void remove_dep_goals(type_context_old & ctx, buffer<expr> & metas) {
|
||||
unsigned k = 0;
|
||||
for (unsigned i = 0; i < metas.size(); i++) {
|
||||
bool found = false;
|
||||
|
|
@ -125,7 +125,7 @@ static void remove_dep_goals(type_context & ctx, buffer<expr> & metas) {
|
|||
metas.shrink(k);
|
||||
}
|
||||
|
||||
static void reorder_non_dep_first(type_context & ctx, buffer<expr> & metas) {
|
||||
static void reorder_non_dep_first(type_context_old & ctx, buffer<expr> & metas) {
|
||||
buffer<expr> non_dep, dep;
|
||||
for (unsigned i = 0; i < metas.size(); i++) {
|
||||
bool found = false;
|
||||
|
|
@ -148,7 +148,7 @@ static void reorder_non_dep_first(type_context & ctx, buffer<expr> & metas) {
|
|||
metas.append(dep);
|
||||
}
|
||||
|
||||
void collect_new_goals(type_context & ctx, new_goals_kind k, buffer<expr> const & metas, buffer<expr> & new_goals) {
|
||||
void collect_new_goals(type_context_old & ctx, new_goals_kind k, buffer<expr> const & metas, buffer<expr> & new_goals) {
|
||||
for (auto m : metas) {
|
||||
if (!ctx.is_assigned(m)) {
|
||||
ctx.instantiate_mvars_at_type_of(m);
|
||||
|
|
@ -167,7 +167,7 @@ void collect_new_goals(type_context & ctx, new_goals_kind k, buffer<expr> const
|
|||
}
|
||||
}
|
||||
|
||||
static optional<tactic_state> apply(type_context & ctx, expr e, apply_cfg const & cfg, tactic_state const & s,
|
||||
static optional<tactic_state> apply(type_context_old & ctx, expr e, apply_cfg const & cfg, tactic_state const & s,
|
||||
vm_obj * out_error_obj, vm_obj * new_metas) {
|
||||
optional<metavar_decl> g = s.get_main_goal_decl();
|
||||
lean_assert(g);
|
||||
|
|
@ -243,11 +243,11 @@ static optional<tactic_state> apply(type_context & ctx, expr e, apply_cfg const
|
|||
to_list(new_goals.begin(), new_goals.end(), tail(s.goals()))));
|
||||
}
|
||||
|
||||
optional<tactic_state> apply(type_context & ctx, expr const & e, apply_cfg const & cfg, tactic_state const & s) {
|
||||
optional<tactic_state> apply(type_context_old & ctx, expr const & e, apply_cfg const & cfg, tactic_state const & s) {
|
||||
return apply(ctx, e, cfg, s, nullptr, nullptr);
|
||||
}
|
||||
|
||||
optional<tactic_state> apply(type_context & ctx, bool all, bool use_instances, expr const & e, tactic_state const & s) {
|
||||
optional<tactic_state> apply(type_context_old & ctx, bool all, bool use_instances, expr const & e, tactic_state const & s) {
|
||||
apply_cfg cfg;
|
||||
cfg.m_new_goals = all ? new_goals_kind::All : new_goals_kind::NonDepOnly;
|
||||
cfg.m_instances = use_instances;
|
||||
|
|
@ -260,8 +260,8 @@ vm_obj tactic_apply_core(vm_obj const & e, vm_obj const & cfg0, vm_obj const & s
|
|||
optional<metavar_decl> g = s.get_main_goal_decl();
|
||||
if (!g) return mk_no_goals_exception(s);
|
||||
tactic_state_context_cache cache(s);
|
||||
type_context ctx = cache.mk_type_context(cfg.m_mode);
|
||||
type_context::approximate_scope _(ctx, cfg.m_approx);
|
||||
type_context_old ctx = cache.mk_type_context(cfg.m_mode);
|
||||
type_context_old::approximate_scope _(ctx, cfg.m_approx);
|
||||
try {
|
||||
vm_obj error_obj;
|
||||
vm_obj new_metas;
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ struct apply_cfg {
|
|||
apply_cfg() {}
|
||||
apply_cfg(vm_obj const & cfg);
|
||||
};
|
||||
optional<tactic_state> apply(type_context & ctx, expr const & e, apply_cfg const & cfg, tactic_state const & s);
|
||||
optional<tactic_state> apply(type_context_old & ctx, expr const & e, apply_cfg const & cfg, tactic_state const & s);
|
||||
/* For backward compatibility */
|
||||
optional<tactic_state> apply(type_context & ctx, bool all, bool use_instances, expr const & e, tactic_state const & s);
|
||||
optional<tactic_state> apply(type_context_old & ctx, bool all, bool use_instances, expr const & e, tactic_state const & s);
|
||||
|
||||
/* Helper functions */
|
||||
bool synth_instances(type_context & ctx, buffer<expr> const & metas, buffer<bool> const & is_instance,
|
||||
bool synth_instances(type_context_old & ctx, buffer<expr> const & metas, buffer<bool> const & is_instance,
|
||||
tactic_state const & s, vm_obj * out_error_obj, char const * tac_name);
|
||||
void collect_new_goals(type_context & ctx, new_goals_kind k, buffer<expr> const & metas, buffer<expr> & new_goals);
|
||||
void collect_new_goals(type_context_old & ctx, new_goals_kind k, buffer<expr> const & metas, buffer<expr> & new_goals);
|
||||
|
||||
void initialize_apply_tactic();
|
||||
void finalize_apply_tactic();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace lean {
|
|||
vm_obj assert_define_core(bool is_assert, name const & n, expr const & t, tactic_state const & s) {
|
||||
optional<metavar_decl> g = s.get_main_goal_decl();
|
||||
if (!g) return mk_no_goals_exception(s);
|
||||
type_context ctx = mk_type_context_for(s);
|
||||
type_context_old ctx = mk_type_context_for(s);
|
||||
if (!is_sort(ctx.whnf(ctx.infer(t)))) {
|
||||
format msg("invalid ");
|
||||
if (is_assert) msg += format("assert"); else msg += format("define");
|
||||
|
|
@ -50,7 +50,7 @@ vm_obj tactic_define_core(vm_obj const & n, vm_obj const & t, vm_obj const & s)
|
|||
vm_obj assertv_definev_core(bool is_assert, name const & n, expr const & t, expr const & v, tactic_state const & s) {
|
||||
optional<metavar_decl> g = s.get_main_goal_decl();
|
||||
if (!g) return mk_no_goals_exception(s);
|
||||
type_context ctx = mk_type_context_for(s);
|
||||
type_context_old ctx = mk_type_context_for(s);
|
||||
expr v_type = ctx.infer(v);
|
||||
if (!ctx.is_def_eq(t, v_type)) {
|
||||
auto thunk = [=]() {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ unsigned get_backward_chaining_max_depth(options const & o) {
|
|||
|
||||
struct back_chaining_fn {
|
||||
tactic_state m_initial_state;
|
||||
type_context m_ctx;
|
||||
type_context_old m_ctx;
|
||||
bool m_use_instances;
|
||||
unsigned m_max_depth;
|
||||
vm_obj m_pre_tactic;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ Author: Leonardo de Moura
|
|||
#include "library/tactic/backward/backward_lemmas.h"
|
||||
|
||||
namespace lean {
|
||||
static optional<head_index> get_backward_target(type_context & ctx, expr type) {
|
||||
type_context::tmp_locals locals(ctx);
|
||||
static optional<head_index> get_backward_target(type_context_old & ctx, expr type) {
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
while (is_pi(type)) {
|
||||
expr local = locals.push_local_from_binding(type);
|
||||
type = ctx.try_to_pi(instantiate(binding_body(type), local));
|
||||
|
|
@ -34,7 +34,7 @@ static optional<head_index> get_backward_target(type_context & ctx, expr type) {
|
|||
return optional<head_index>();
|
||||
}
|
||||
|
||||
static optional<head_index> get_backward_target(type_context & ctx, name const & c) {
|
||||
static optional<head_index> get_backward_target(type_context_old & ctx, name const & c) {
|
||||
declaration const & d = ctx.env().get(c);
|
||||
list<level> us = param_names_to_levels(d.get_univ_params());
|
||||
expr type = ctx.try_to_pi(instantiate_type_univ_params(d, us));
|
||||
|
|
@ -92,7 +92,7 @@ unsigned backward_lemma_prio_fn::operator()(backward_lemma const & r) const {
|
|||
return LEAN_DEFAULT_PRIORITY;
|
||||
}
|
||||
|
||||
backward_lemma_index::backward_lemma_index(type_context & ctx):
|
||||
backward_lemma_index::backward_lemma_index(type_context_old & ctx):
|
||||
m_index(get_intro_attribute().get_instances_by_prio(ctx.env())) {
|
||||
buffer<name> lemmas;
|
||||
get_intro_attribute().get_instances(ctx.env(), lemmas);
|
||||
|
|
@ -109,14 +109,14 @@ backward_lemma_index::backward_lemma_index(type_context & ctx):
|
|||
}
|
||||
}
|
||||
|
||||
void backward_lemma_index::insert(type_context & ctx, expr const & href) {
|
||||
void backward_lemma_index::insert(type_context_old & ctx, expr const & href) {
|
||||
expr href_type = ctx.infer(href);
|
||||
if (optional<head_index> target = get_backward_target(ctx, href_type)) {
|
||||
m_index.insert(*target, backward_lemma(gexpr(href)));
|
||||
}
|
||||
}
|
||||
|
||||
void backward_lemma_index::erase(type_context & ctx, expr const & href) {
|
||||
void backward_lemma_index::erase(type_context_old & ctx, expr const & href) {
|
||||
expr href_type = ctx.infer(href);
|
||||
if (optional<head_index> target = get_backward_target(ctx, href_type)) {
|
||||
m_index.erase(*target, backward_lemma(gexpr(href)));
|
||||
|
|
@ -149,12 +149,12 @@ vm_obj to_obj(backward_lemma_index const & idx) {
|
|||
}
|
||||
|
||||
vm_obj tactic_mk_backward_lemmas(vm_obj const & m, vm_obj const & s) {
|
||||
type_context ctx = mk_type_context_for(s, m);
|
||||
type_context_old ctx = mk_type_context_for(s, m);
|
||||
return tactic::mk_success(to_obj(backward_lemma_index(ctx)), tactic::to_state(s));
|
||||
}
|
||||
|
||||
vm_obj tactic_backward_lemmas_insert(vm_obj const & m, vm_obj const & lemmas, vm_obj const & lemma, vm_obj const & s) {
|
||||
type_context ctx = mk_type_context_for(s, m);
|
||||
type_context_old ctx = mk_type_context_for(s, m);
|
||||
backward_lemma_index new_lemmas = to_backward_lemmas(lemmas);
|
||||
new_lemmas.insert(ctx, to_expr(lemma));
|
||||
return tactic::mk_success(to_obj(new_lemmas), tactic::to_state(s));
|
||||
|
|
@ -174,7 +174,7 @@ void initialize_backward_lemmas() {
|
|||
auto const & data = *get_intro_attribute().get(env, c);
|
||||
if (data.m_eager)
|
||||
return env; // FIXME: support old blast attributes
|
||||
type_context ctx(env, ios.get_options());
|
||||
type_context_old ctx(env, ios.get_options());
|
||||
auto index = get_backward_target(ctx, c);
|
||||
if (!index || index->kind() != expr_kind::Constant)
|
||||
throw exception(
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ struct backward_lemma_prio_fn {
|
|||
class backward_lemma_index {
|
||||
head_map_prio<backward_lemma, backward_lemma_prio_fn> m_index;
|
||||
public:
|
||||
backward_lemma_index(type_context & ctx);
|
||||
void insert(type_context & ctx, expr const & href);
|
||||
void erase(type_context & ctx, expr const & href);
|
||||
backward_lemma_index(type_context_old & ctx);
|
||||
void insert(type_context_old & ctx, expr const & href);
|
||||
void erase(type_context_old & ctx, expr const & href);
|
||||
list<backward_lemma> find(head_index const & h) const;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ struct cases_tactic_fn {
|
|||
declaration m_I_decl;
|
||||
declaration m_cases_on_decl;
|
||||
|
||||
type_context mk_type_context_for(metavar_decl const & g) {
|
||||
type_context_old mk_type_context_for(metavar_decl const & g) {
|
||||
return ::lean::mk_type_context_for(m_env, m_opts, m_mctx, g.get_context(), m_mode);
|
||||
}
|
||||
|
||||
type_context mk_type_context_for(expr const & mvar) {
|
||||
type_context_old mk_type_context_for(expr const & mvar) {
|
||||
return mk_type_context_for(m_mctx.get_metavar_decl(mvar));
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ struct cases_tactic_fn {
|
|||
throw cases_tactic_exception { mk_tactic_state(mvar), [=] { return format(msg); } };
|
||||
}
|
||||
|
||||
#define lean_cases_trace(MVAR, CODE) lean_trace(name({"tactic", "cases"}), type_context TMP_CTX = mk_type_context_for(MVAR); scope_trace_env _scope1(m_env, TMP_CTX); CODE)
|
||||
#define lean_cases_trace(MVAR, CODE) lean_trace(name({"tactic", "cases"}), type_context_old TMP_CTX = mk_type_context_for(MVAR); scope_trace_env _scope1(m_env, TMP_CTX); CODE)
|
||||
|
||||
void init_inductive_info(name const & n) {
|
||||
m_nindices = get_ginductive_num_indices(m_env, n);
|
||||
|
|
@ -89,7 +89,7 @@ struct cases_tactic_fn {
|
|||
m_cases_on_decl = m_env.get(get_dep_cases_on(m_env, n));
|
||||
}
|
||||
|
||||
expr whnf_inductive(type_context & ctx, expr const & e) {
|
||||
expr whnf_inductive(type_context_old & ctx, expr const & e) {
|
||||
if (m_unfold_ginductive)
|
||||
return ctx.relaxed_whnf(e);
|
||||
else
|
||||
|
|
@ -109,7 +109,7 @@ struct cases_tactic_fn {
|
|||
}
|
||||
|
||||
bool is_cases_applicable(expr const & mvar, expr const & H) {
|
||||
type_context ctx = mk_type_context_for(mvar);
|
||||
type_context_old ctx = mk_type_context_for(mvar);
|
||||
expr t = whnf_inductive(ctx, ctx.infer(H));
|
||||
buffer<expr> args;
|
||||
expr const & fn = get_app_args(t, args);
|
||||
|
|
@ -137,7 +137,7 @@ struct cases_tactic_fn {
|
|||
lean_assert(is_local(h));
|
||||
if (m_nindices == 0)
|
||||
return true;
|
||||
type_context ctx = mk_type_context_for(g);
|
||||
type_context_old ctx = mk_type_context_for(g);
|
||||
expr h_type = whnf_inductive(ctx, ctx.infer(h));
|
||||
buffer<expr> args;
|
||||
get_app_args(h_type, args);
|
||||
|
|
@ -164,9 +164,9 @@ struct cases_tactic_fn {
|
|||
return ok;
|
||||
}
|
||||
|
||||
pair<expr, expr> mk_eq(type_context & ctx, expr const & lhs, expr const & rhs) {
|
||||
pair<expr, expr> mk_eq(type_context_old & ctx, expr const & lhs, expr const & rhs) {
|
||||
// make sure we don't assign regular metavars at is_def_eq
|
||||
type_context::tmp_mode_scope scope(ctx);
|
||||
type_context_old::tmp_mode_scope scope(ctx);
|
||||
expr lhs_type = ctx.infer(lhs);
|
||||
expr rhs_type = ctx.infer(rhs);
|
||||
level l = get_level(ctx, lhs_type);
|
||||
|
|
@ -197,7 +197,7 @@ struct cases_tactic_fn {
|
|||
The original goal is solved if we can solve the produced goal. */
|
||||
expr generalize_indices(expr const & mvar, expr const & h, buffer<name> & new_indices_H, unsigned & num_eqs) {
|
||||
metavar_decl g = m_mctx.get_metavar_decl(mvar);
|
||||
type_context ctx = mk_type_context_for(g);
|
||||
type_context_old ctx = mk_type_context_for(g);
|
||||
expr h_type = whnf_inductive(ctx, ctx.infer(h));
|
||||
buffer<expr> I_args;
|
||||
expr const & I = get_app_args(h_type, I_args);
|
||||
|
|
@ -311,7 +311,7 @@ struct cases_tactic_fn {
|
|||
|
||||
/* Create (f ... x) with the given arity, where the other arguments are inferred using
|
||||
type inference */
|
||||
expr mk_inverse(type_context & ctx, inverse_info const & inv, expr const & x) {
|
||||
expr mk_inverse(type_context_old & ctx, inverse_info const & inv, expr const & x) {
|
||||
buffer<bool> mask;
|
||||
mask.resize(inv.m_arity - 1, false);
|
||||
mask.push_back(true);
|
||||
|
|
@ -338,7 +338,7 @@ struct cases_tactic_fn {
|
|||
expr target = g.get_type();
|
||||
lean_assert(is_pi(target) && is_arrow(target));
|
||||
if (is_eq(binding_domain(target), lhs, rhs)) {
|
||||
type_context ctx = mk_type_context_for(mvar);
|
||||
type_context_old ctx = mk_type_context_for(mvar);
|
||||
expr lhs_n = whnf_gintro_rule(ctx, lhs);
|
||||
expr rhs_n = whnf_gintro_rule(ctx, rhs);
|
||||
if (lhs != lhs_n || rhs != rhs_n) {
|
||||
|
|
@ -358,7 +358,7 @@ struct cases_tactic_fn {
|
|||
local_decl H_decl = g1.get_context().get_last_local_decl();
|
||||
expr H_type = H_decl.get_type();
|
||||
expr H = H_decl.mk_ref();
|
||||
type_context ctx = mk_type_context_for(*mvar1);
|
||||
type_context_old ctx = mk_type_context_for(*mvar1);
|
||||
if (is_heq(H_type, A, lhs, B, rhs)) {
|
||||
if (!ctx.is_def_eq(A, B)) {
|
||||
throw_exception(mvar, "cases tactic failed, when processing auxiliary heterogeneous equality");
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ vm_obj change_core(expr const & e, bool check, tactic_state const & s) {
|
|||
optional<metavar_decl> g = s.get_main_goal_decl();
|
||||
if (!g) return mk_no_goals_exception(s);
|
||||
if (e == g->get_type()) return tactic::mk_success(s);
|
||||
type_context ctx = mk_type_context_for(s);
|
||||
type_context_old ctx = mk_type_context_for(s);
|
||||
if (!check || ctx.is_def_eq(e, g->get_type())) {
|
||||
expr new_e = ctx.instantiate_mvars(e);
|
||||
expr new_M = ctx.mk_metavar_decl(g->get_context(), new_e);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ static vm_obj mk_result(optional<congr_lemma> const & l, vm_obj const & s) {
|
|||
|
||||
vm_obj tactic_mk_congr_lemma_simp(vm_obj const & fn, vm_obj const & nargs, vm_obj const & m, vm_obj const & s) {
|
||||
TRY;
|
||||
type_context ctx = mk_type_context_for(s, m);
|
||||
type_context_old ctx = mk_type_context_for(s, m);
|
||||
if (is_none(nargs)) {
|
||||
return mk_result(mk_congr_simp(ctx, to_expr(fn)), s);
|
||||
} else {
|
||||
|
|
@ -53,14 +53,14 @@ vm_obj tactic_mk_congr_lemma_simp(vm_obj const & fn, vm_obj const & nargs, vm_ob
|
|||
|
||||
vm_obj tactic_mk_specialized_congr_lemma_simp(vm_obj const & a, vm_obj const & m, vm_obj const & s) {
|
||||
TRY;
|
||||
type_context ctx = mk_type_context_for(s, m);
|
||||
type_context_old ctx = mk_type_context_for(s, m);
|
||||
return mk_result(mk_specialized_congr_simp(ctx, to_expr(a)), s);
|
||||
CATCH;
|
||||
}
|
||||
|
||||
vm_obj tactic_mk_congr_lemma(vm_obj const & fn, vm_obj const & nargs, vm_obj const & m, vm_obj const & s) {
|
||||
TRY;
|
||||
type_context ctx = mk_type_context_for(s, m);
|
||||
type_context_old ctx = mk_type_context_for(s, m);
|
||||
if (is_none(nargs)) {
|
||||
return mk_result(mk_congr(ctx, to_expr(fn)), s);
|
||||
} else {
|
||||
|
|
@ -71,14 +71,14 @@ vm_obj tactic_mk_congr_lemma(vm_obj const & fn, vm_obj const & nargs, vm_obj con
|
|||
|
||||
vm_obj tactic_mk_specialized_congr_lemma(vm_obj const & a, vm_obj const & m, vm_obj const & s) {
|
||||
TRY;
|
||||
type_context ctx = mk_type_context_for(s, m);
|
||||
type_context_old ctx = mk_type_context_for(s, m);
|
||||
return mk_result(mk_specialized_congr(ctx, to_expr(a)), s);
|
||||
CATCH;
|
||||
}
|
||||
|
||||
vm_obj tactic_mk_hcongr_lemma(vm_obj const & fn, vm_obj const & nargs, vm_obj const & m, vm_obj const & s) {
|
||||
TRY;
|
||||
type_context ctx = mk_type_context_for(s, m);
|
||||
type_context_old ctx = mk_type_context_for(s, m);
|
||||
if (is_none(nargs)) {
|
||||
return mk_result(mk_hcongr(ctx, to_expr(fn)), s);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ Author: Leonardo de Moura
|
|||
#include "library/tactic/tactic_state.h"
|
||||
|
||||
namespace lean {
|
||||
static void add_minors(type_context & ctx, unsigned nminors, expr & cases, buffer<expr> & new_goals) {
|
||||
static void add_minors(type_context_old & ctx, unsigned nminors, expr & cases, buffer<expr> & new_goals) {
|
||||
expr cases_type = ctx.infer(cases);
|
||||
for (unsigned i = 0; i < nminors; i++) {
|
||||
cases_type = ctx.relaxed_whnf(cases_type);
|
||||
|
|
@ -30,7 +30,7 @@ tactic_state destruct(transparency_mode md, expr const & e, tactic_state const &
|
|||
if (!s.goals())
|
||||
throw exception("destruct tactic failed, there are no goals to be solved");
|
||||
|
||||
type_context ctx = mk_type_context_for(s, md);
|
||||
type_context_old ctx = mk_type_context_for(s, md);
|
||||
environment const & env = ctx.env();
|
||||
expr target = s.get_main_goal_decl()->get_type();
|
||||
level target_lvl = get_level(ctx, target);
|
||||
|
|
@ -76,7 +76,7 @@ tactic_state destruct(transparency_mode md, expr const & e, tactic_state const &
|
|||
/* add motive */
|
||||
buffer<expr> refls; /* refl proof for indices and major */
|
||||
{
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
buffer<expr> js;
|
||||
buffer<expr> eqs;
|
||||
expr I_A = mk_app(I, I_args.size() - nindices, I_args.data());
|
||||
|
|
@ -128,7 +128,7 @@ tactic_state destruct(transparency_mode md, expr const & e, tactic_state const &
|
|||
lean_assert(!dep_elim);
|
||||
/* add motive */
|
||||
{
|
||||
type_context::tmp_locals locals(ctx);
|
||||
type_context_old::tmp_locals locals(ctx);
|
||||
if (nindices > 0) {
|
||||
expr I_A = mk_app(I, I_args.size() - nindices, I_args.data());
|
||||
expr I_A_type = ctx.infer(I_A);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ Author: Leonardo de Moura
|
|||
#endif
|
||||
|
||||
namespace lean {
|
||||
expr reduce_beta_eta_proj_iota(type_context & ctx, expr e, bool beta, bool eta, bool proj, bool iota) {
|
||||
expr reduce_beta_eta_proj_iota(type_context_old & ctx, expr e, bool beta, bool eta, bool proj, bool iota) {
|
||||
bool p;
|
||||
do {
|
||||
p = false;
|
||||
|
|
@ -60,7 +60,7 @@ expr reduce_beta_eta_proj_iota(type_context & ctx, expr e, bool beta, bool eta,
|
|||
return e;
|
||||
}
|
||||
|
||||
optional<expr> unfold_step(type_context & ctx, expr const & e, name_set const & to_unfold, bool unfold_reducible) {
|
||||
optional<expr> unfold_step(type_context_old & ctx, expr const & e, name_set const & to_unfold, bool unfold_reducible) {
|
||||
if (!unfold_reducible && to_unfold.empty())
|
||||
return none_expr();
|
||||
if (!is_app(e) && !is_constant(e))
|
||||
|
|
@ -77,7 +77,7 @@ optional<expr> unfold_step(type_context & ctx, expr const & e, name_set const &
|
|||
|
||||
if (is_projection(ctx.env(), const_name(fn))) {
|
||||
if (in_to_unfold) {
|
||||
type_context::transparency_scope scope(ctx, transparency_mode::Instances);
|
||||
type_context_old::transparency_scope scope(ctx, transparency_mode::Instances);
|
||||
return ctx.reduce_projection(e);
|
||||
} else {
|
||||
return none_expr();
|
||||
|
|
@ -85,7 +85,7 @@ optional<expr> unfold_step(type_context & ctx, expr const & e, name_set const &
|
|||
} else if (in_to_unfold) {
|
||||
return unfold_term(ctx.env(), e);
|
||||
} else if (unfold_reducible && is_reducible(ctx.env(), fn_name)) {
|
||||
type_context::transparency_scope scope(ctx, transparency_mode::Reducible);
|
||||
type_context_old::transparency_scope scope(ctx, transparency_mode::Reducible);
|
||||
return unfold_term(ctx.env(), e);
|
||||
} else {
|
||||
return none_expr();
|
||||
|
|
@ -140,7 +140,7 @@ expr dsimplify_core_fn::visit_macro(expr const & e) {
|
|||
|
||||
expr dsimplify_core_fn::visit_binding(expr const & e) {
|
||||
expr_kind k = e.kind();
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr b = e;
|
||||
bool modified = false;
|
||||
while (b.kind() == k) {
|
||||
|
|
@ -163,7 +163,7 @@ expr dsimplify_core_fn::visit_let(expr const & e) {
|
|||
if (m_cfg.m_zeta) {
|
||||
return visit(instantiate(let_body(e), let_value(e)));
|
||||
} else {
|
||||
type_context::tmp_locals locals(m_ctx);
|
||||
type_context_old::tmp_locals locals(m_ctx);
|
||||
expr b = e;
|
||||
bool modified = false;
|
||||
while (is_let(b)) {
|
||||
|
|
@ -297,7 +297,7 @@ expr dsimplify_core_fn::visit(expr const & e) {
|
|||
return curr_e;
|
||||
}
|
||||
|
||||
dsimplify_core_fn::dsimplify_core_fn(type_context & ctx, defeq_canonizer::state & dcs, dsimp_config const & cfg):
|
||||
dsimplify_core_fn::dsimplify_core_fn(type_context_old & ctx, defeq_canonizer::state & dcs, dsimp_config const & cfg):
|
||||
m_ctx(ctx), m_defeq_canonizer(ctx, dcs), m_num_steps(0), m_need_restart(false), m_cfg(cfg) {}
|
||||
|
||||
expr dsimplify_core_fn::operator()(expr e) {
|
||||
|
|
@ -319,7 +319,7 @@ expr dsimplify_fn::reduce(expr const & e) {
|
|||
}
|
||||
|
||||
optional<pair<expr, bool>> dsimplify_fn::pre(expr const & e) {
|
||||
type_context::transparency_scope s(m_ctx, m_cfg.m_md);
|
||||
type_context_old::transparency_scope s(m_ctx, m_cfg.m_md);
|
||||
expr new_e = reduce(e);
|
||||
if (new_e != e) {
|
||||
lean_dsimp_trace(m_ctx, "dsimplify", tout() << "reduce\n" << e << "\n==>\n" << new_e << "\n";);
|
||||
|
|
@ -334,7 +334,7 @@ optional<pair<expr, bool>> dsimplify_fn::post(expr const & e) {
|
|||
return optional<pair<expr, bool>>(*r, true);
|
||||
expr curr_e;
|
||||
{
|
||||
type_context::transparency_scope s(m_ctx, m_cfg.m_md);
|
||||
type_context_old::transparency_scope s(m_ctx, m_cfg.m_md);
|
||||
curr_e = reduce(e);
|
||||
if (curr_e != e) {
|
||||
lean_dsimp_trace(m_ctx, "dsimplify", tout() << "reduce\n" << e << "\n==>\n" << curr_e << "\n";);
|
||||
|
|
@ -370,7 +370,7 @@ optional<pair<expr, bool>> dsimplify_fn::post(expr const & e) {
|
|||
return optional<pair<expr, bool>>(curr_e, true);
|
||||
}
|
||||
|
||||
dsimplify_fn::dsimplify_fn(type_context & ctx, defeq_canonizer::state & dcs, simp_lemmas_for const & lemmas,
|
||||
dsimplify_fn::dsimplify_fn(type_context_old & ctx, defeq_canonizer::state & dcs, simp_lemmas_for const & lemmas,
|
||||
list<name> const & to_unfold, dsimp_config const & cfg):
|
||||
dsimplify_core_fn(ctx, dcs, cfg),
|
||||
m_simp_lemmas(lemmas),
|
||||
|
|
@ -410,7 +410,7 @@ class tactic_dsimplify_fn : public dsimplify_core_fn {
|
|||
}
|
||||
|
||||
public:
|
||||
tactic_dsimplify_fn(type_context & ctx, defeq_canonizer::state & dcs,
|
||||
tactic_dsimplify_fn(type_context_old & ctx, defeq_canonizer::state & dcs,
|
||||
vm_obj const & a, vm_obj const & pre, vm_obj const & post,
|
||||
tactic_state const & s, dsimp_config const & cfg):
|
||||
dsimplify_core_fn(ctx, dcs, cfg),
|
||||
|
|
@ -430,7 +430,7 @@ vm_obj tactic_dsimplify_core(vm_obj const &, vm_obj const & a,
|
|||
dsimp_config cfg(_cfg);
|
||||
try {
|
||||
tactic_state_context_cache cache(s);
|
||||
type_context ctx = cache.mk_type_context(cfg.m_md);
|
||||
type_context_old ctx = cache.mk_type_context(cfg.m_md);
|
||||
defeq_can_state dcs = s.dcs();
|
||||
tactic_dsimplify_fn F(ctx, dcs, a, pre, post, s, cfg);
|
||||
expr new_e = F(to_expr(e));
|
||||
|
|
@ -450,7 +450,7 @@ vm_obj simp_lemmas_dsimplify(vm_obj const & lemmas, vm_obj const & u, vm_obj con
|
|||
dsimp_config cfg(_cfg);
|
||||
try {
|
||||
tactic_state_context_cache cache(s);
|
||||
type_context ctx = cache.mk_type_context(cfg.m_md);
|
||||
type_context_old ctx = cache.mk_type_context(cfg.m_md);
|
||||
defeq_can_state dcs = s.dcs();
|
||||
list<name> to_unfold = to_list_name(u);
|
||||
simp_lemmas_for dlemmas;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ struct dsimp_config {
|
|||
|
||||
class dsimplify_core_fn {
|
||||
protected:
|
||||
type_context & m_ctx;
|
||||
type_context_old & m_ctx;
|
||||
defeq_canonizer m_defeq_canonizer;
|
||||
expr_struct_map<expr> m_cache;
|
||||
unsigned m_num_steps;
|
||||
|
|
@ -65,7 +65,7 @@ protected:
|
|||
expr visit(expr const & e);
|
||||
|
||||
public:
|
||||
dsimplify_core_fn(type_context & ctx, defeq_canonizer::state & s, dsimp_config const & cfg);
|
||||
dsimplify_core_fn(type_context_old & ctx, defeq_canonizer::state & s, dsimp_config const & cfg);
|
||||
expr operator()(expr e);
|
||||
metavar_context const & mctx() const;
|
||||
};
|
||||
|
|
@ -77,12 +77,12 @@ class dsimplify_fn : public dsimplify_core_fn {
|
|||
virtual optional<pair<expr, bool>> pre(expr const & e) override;
|
||||
virtual optional<pair<expr, bool>> post(expr const & e) override;
|
||||
public:
|
||||
dsimplify_fn(type_context & ctx, defeq_canonizer::state & s,
|
||||
dsimplify_fn(type_context_old & ctx, defeq_canonizer::state & s,
|
||||
simp_lemmas_for const & lemmas, list<name> const & to_unfold, dsimp_config const & cfg);
|
||||
};
|
||||
|
||||
expr reduce_beta_eta_proj_iota(type_context & ctx, expr e, bool beta, bool eta, bool proj, bool iota);
|
||||
optional<expr> unfold_step(type_context & ctx, expr const & e, name_set const & to_unfold, bool unfold_reducible);
|
||||
expr reduce_beta_eta_proj_iota(type_context_old & ctx, expr e, bool beta, bool eta, bool proj, bool iota);
|
||||
optional<expr> unfold_step(type_context_old & ctx, expr const & e, name_set const & to_unfold, bool unfold_reducible);
|
||||
|
||||
void initialize_dsimplify();
|
||||
void finalize_dsimplify();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ static environment update(environment const & env, eqn_lemmas_ext const & ext) {
|
|||
}
|
||||
|
||||
environment add_eqn_lemma_core(environment const & env, name const & eqn_lemma) {
|
||||
type_context ctx(env, transparency_mode::None);
|
||||
type_context_old ctx(env, transparency_mode::None);
|
||||
simp_lemmas lemmas = add(ctx, simp_lemmas(), eqn_lemma, LEAN_DEFAULT_PRIORITY);
|
||||
optional<simp_lemma> new_lemma;
|
||||
lemmas.for_each([&](name const & r, simp_lemma const & sl) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ static vm_obj eval(expr const & A, expr a, tactic_state const & s) {
|
|||
if (has_local(a) || !closed(a))
|
||||
return tactic::mk_exception("invalid eval_expr, expression must be closed", s);
|
||||
if (is_constant(a)) {
|
||||
type_context ctx = mk_type_context_for(s);
|
||||
type_context_old ctx = mk_type_context_for(s);
|
||||
if (!ctx.is_def_eq(A, ctx.infer(a)))
|
||||
return tactic::mk_exception("invalid eval_expr, type mismatch", s);
|
||||
vm_obj r = get_vm_state().get_constant(const_name(a));
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue