bool is_tactic_namespace_open(environment const & env) { for (name const & a : get_expr_aliases(env, "apply")) { if (a == get_tactic_apply_name()) { // make sure the type is the expected one if (auto d = env.find(a)) { expr t = d->get_type(); if (is_pi(t)) { expr b = binding_body(t); if (!is_constant(b) || const_name(b) != get_tactic_name()) throw exception("tactic namespace declarations have been modified, " "function 'tactic.apply' is expected to return a 'tactic'"); } } return true; } } return false; }
void initialize_apply_tactic() { g_apply_class_instance = new name{"apply", "class_instance"}; register_bool_option(*g_apply_class_instance, LEAN_DEFAULT_APPLY_CLASS_INSTANCE, "(apply tactic) if true apply tactic uses class-instances " "resolution for instance implicit arguments"); register_tac(get_tactic_apply_name(), [](type_checker &, elaborate_fn const & fn, expr const & e, pos_info_provider const *) { check_tactic_expr(app_arg(e), "invalid 'apply' tactic, invalid argument"); return apply_tactic(fn, get_tactic_expr_expr(app_arg(e))); }); register_tac(get_tactic_eapply_name(), [](type_checker &, elaborate_fn const & fn, expr const & e, pos_info_provider const *) { check_tactic_expr(app_arg(e), "invalid 'eapply' tactic, invalid argument"); return eapply_tactic(fn, get_tactic_expr_expr(app_arg(e))); }); register_tac(get_tactic_fapply_name(), [](type_checker &, elaborate_fn const & fn, expr const & e, pos_info_provider const *) { check_tactic_expr(app_arg(e), "invalid 'fapply' tactic, invalid argument"); return fapply_tactic(fn, get_tactic_expr_expr(app_arg(e))); }); }