refactor(library/type_context): rename whnf_pred => whnf_head_pred

This commit is contained in:
Leonardo de Moura 2017-02-15 20:20:27 -08:00
parent 604cbf827a
commit 707cf45a26
9 changed files with 12 additions and 12 deletions

View file

@ -184,7 +184,7 @@ environment add_instance_core(environment const & env, name const & n, unsigned
class_state S = class_ext::get_state(env);
type_context::tmp_locals locals(ctx);
while (true) {
type = ctx.whnf_pred(type, [&](expr const & e) {
type = ctx.whnf_head_pred(type, [&](expr const & e) {
expr const & fn = get_app_fn(e);
return !is_constant(fn) || !S.m_instances.contains(const_name(fn)); });
if (!is_pi(type))

View file

@ -110,7 +110,7 @@ class expand_aux_fn : public compiler_step_visitor {
return visit(copy_tag(e, expr(*r)));
}
}
expr new_e = copy_tag(e, ctx().whnf_pred(e, [&](expr const &) { return false; }));
expr new_e = copy_tag(e, ctx().whnf_head_pred(e, [&](expr const &) { return false; }));
if (is_eqp(new_e, e))
return compiler_step_visitor::visit_app(new_e);
else
@ -119,7 +119,7 @@ class expand_aux_fn : public compiler_step_visitor {
case recursor_kind::CasesOn:
return visit_cases_on(e);
case recursor_kind::Aux:
return compiler_step_visitor::visit(copy_tag(e, ctx().whnf_pred(e, [&](expr const & e) { return is_aux_recursor(e); })));
return compiler_step_visitor::visit(copy_tag(e, ctx().whnf_head_pred(e, [&](expr const & e) { return is_aux_recursor(e); })));
}
lean_unreachable();
}

View file

@ -327,7 +327,7 @@ struct elim_match_fn {
if (is_inaccessible(e)) {
return e;
} else {
return ctx.whnf_pred(e, [&](expr const & e) {
return ctx.whnf_head_pred(e, [&](expr const & e) {
return !is_constructor_app(e) && !is_value(ctx, e) && !is_transport_app(e);
});
}
@ -335,14 +335,14 @@ struct elim_match_fn {
/* Normalize until head is constructor */
expr whnf_constructor(type_context & ctx, expr const & e) {
return ctx.whnf_pred(e, [&](expr const & e) {
return ctx.whnf_head_pred(e, [&](expr const & e) {
return !is_constructor_app(e);
});
}
/* Normalize until head is an inductive datatype */
expr whnf_inductive(type_context & ctx, expr const & e) {
return ctx.whnf_pred(e, [&](expr const & e) {
return ctx.whnf_head_pred(e, [&](expr const & e) {
return !is_inductive_app(e);
});
}

View file

@ -553,7 +553,7 @@ struct structural_rec_fn {
expr whnf_upto_below(type_context & ctx, name const & I_name, expr const & below_type) {
name below_name(I_name, "below");
name ibelow_name(I_name, "ibelow");
return ctx.whnf_pred(below_type, [&](expr const & e) {
return ctx.whnf_head_pred(below_type, [&](expr const & e) {
expr const & fn = get_app_fn(e);
return !is_constant(fn) || (const_name(fn) != below_name && const_name(fn) != ibelow_name);
});

View file

@ -329,7 +329,7 @@ static environment add_equation_lemma(environment const & env, options const & o
}
static expr whnf_ite(type_context & ctx, expr const & e) {
return ctx.whnf_pred(e, [&](expr const & e) {
return ctx.whnf_head_pred(e, [&](expr const & e) {
expr const & fn = get_app_fn(e);
return !is_constant(fn, get_ite_name());
});

View file

@ -211,7 +211,7 @@ class add_nested_inductive_decl_fn {
// Helpers
expr safe_whnf(type_context & tctx, expr const & e) {
expr r = tctx.whnf_pred(e, [&](expr const & t) {
expr r = tctx.whnf_head_pred(e, [&](expr const & t) {
expr fn = get_app_fn(t);
if (!is_constant(fn))
return true;

View file

@ -80,7 +80,7 @@ static void throw_invalid_major_premise_type(unsigned arg_idx, expr const & H_ty
static expr whnf_until(type_context & ctx, name const & n, expr const & e) {
type_context::transparency_scope scope(ctx, transparency_mode::All);
return ctx.whnf_pred(e, [&](expr const & t) {
return ctx.whnf_head_pred(e, [&](expr const & t) {
expr fn = get_app_fn(t);
if (is_constant(fn) && const_name(fn) == n)
return false;

View file

@ -774,7 +774,7 @@ expr type_context::whnf(expr const & e) {
}
}
expr type_context::whnf_pred(expr const & e, std::function<bool(expr const &)> const & pred) { // NOLINT
expr type_context::whnf_head_pred(expr const & e, std::function<bool(expr const &)> const & pred) { // NOLINT
flet<std::function<bool(expr const &)> const *>set_unfold_pred(m_unfold_pred, &pred); // NOLINT
expr t = e;
while (true) {

View file

@ -369,7 +369,7 @@ public:
/** Similar to whnf, but invokes the given predicate before unfolding constant symbols in the head.
If pred(e') is false, then the method will not unfold definition in the head of e', and will return e'.
This method is useful when we want to normalize the expression until we get a particular symbol as the head symbol. */
expr whnf_pred(expr const & e, std::function<bool(expr const &)> const & pred); // NOLINT
expr whnf_head_pred(expr const & e, std::function<bool(expr const &)> const & pred); // NOLINT
optional<expr> reduce_aux_recursor(expr const & e);
optional<expr> reduce_projection(expr const & e);
optional<expr> norm_ext(expr const & e) { return env().norm_ext()(e, *this); }