virtual expr visit_app(expr const & e) { buffer<expr> args; expr const & f = get_app_rev_args(e, args); if (is_metavar(f)) { if (auto p1 = m_subst.get_expr_assignment(mlocal_name(f))) { if (m_use_jst) save_jst(p1->second); expr new_app = apply_beta(p1->first, args.size(), args.data()); return visit(new_app); } } expr new_f = visit(f); buffer<expr> new_args; bool modified = !is_eqp(new_f, f); for (expr const & arg : args) { expr new_arg = visit(arg); if (!is_eqp(arg, new_arg)) modified = true; new_args.push_back(new_arg); } if (!modified) return e; else return mk_rev_app(new_f, new_args); }
expr normalize_app(expr const & e) { buffer<expr> args; expr f = get_app_rev_args(e, args); for (expr & a : args) a = normalize(a); return mk_rev_app(f, args); }
expr mk_rev_app(unsigned num_args, expr const * args, tag g) { lean_assert(num_args >= 2); return mk_rev_app(mk_app(args[num_args-1], args[num_args-2], g), num_args-2, args, g); }