chore(frontends/lean/elaborator): remove unfold tactic dependency
This commit is contained in:
parent
ef27df8907
commit
a10e81e6a6
3 changed files with 4 additions and 74 deletions
|
|
@ -87,9 +87,6 @@ meta constant structure_fields : environment → name → option (list name)
|
|||
meta constant fingerprint : environment → nat
|
||||
open lean.expr
|
||||
|
||||
meta constant unfold_untrusted_macros : environment → expr → expr
|
||||
meta constant unfold_all_macros : environment → expr → expr
|
||||
|
||||
meta def is_constructor_app (env : environment) (e : expr) : bool :=
|
||||
is_constant (get_app_fn e) && is_constructor env (const_name (get_app_fn e))
|
||||
|
||||
|
|
|
|||
|
|
@ -92,76 +92,9 @@ private meta def maybe_paren : list format → format
|
|||
| [f] := f
|
||||
| fs := paren (join fs)
|
||||
|
||||
private meta def unfold (e : expr) : tactic expr :=
|
||||
do (expr.const f_name f_lvls) ← return e.get_app_fn | failed,
|
||||
env ← get_env,
|
||||
decl ← env.get f_name,
|
||||
new_f ← decl.instantiate_value_univ_params f_lvls,
|
||||
head_beta (lean.expr.mk_app new_f e.get_app_args)
|
||||
|
||||
private meta def concat (f₁ f₂ : list format) :=
|
||||
if f₁.empty then f₂ else if f₂.empty then f₁ else f₁ ++ [" "] ++ f₂
|
||||
|
||||
private meta def parser_desc_aux : expr → tactic (list format)
|
||||
| `(ident) := return ["id"]
|
||||
| `(ident_) := return ["id"]
|
||||
| `(parser.pexpr %%v) := return ["expr"]
|
||||
| `(tk %%c) := list.ret <$> to_fmt <$> eval_expr string c
|
||||
| `(cur_pos) := return []
|
||||
| `(pure _) := return []
|
||||
| `(_ <$> %%p) := parser_desc_aux p
|
||||
| `(skip_info %%p) := parser_desc_aux p
|
||||
| `(set_goal_info_pos %%p) := parser_desc_aux p
|
||||
| `(with_desc %%desc %%p) := list.ret <$> eval_expr format desc
|
||||
| `(%%p₁ <*> %%p₂) := do
|
||||
f₁ ← parser_desc_aux p₁,
|
||||
f₂ ← parser_desc_aux p₂,
|
||||
return $ concat f₁ f₂
|
||||
| `(%%p₁ <* %%p₂) := do
|
||||
f₁ ← parser_desc_aux p₁,
|
||||
f₂ ← parser_desc_aux p₂,
|
||||
return $ concat f₁ f₂
|
||||
| `(%%p₁ *> %%p₂) := do
|
||||
f₁ ← parser_desc_aux p₁,
|
||||
f₂ ← parser_desc_aux p₂,
|
||||
return $ concat f₁ f₂
|
||||
| `(many %%p) := do
|
||||
f ← parser_desc_aux p,
|
||||
return [maybe_paren f ++ "*"]
|
||||
| `(optional %%p) := do
|
||||
f ← parser_desc_aux p,
|
||||
return [maybe_paren f ++ "?"]
|
||||
| `(sep_by %%sep %%p) := do
|
||||
f₁ ← parser_desc_aux sep,
|
||||
f₂ ← parser_desc_aux p,
|
||||
return [maybe_paren f₂ ++ join f₁, " ..."]
|
||||
| `(%%p₁ <|> %%p₂) := do
|
||||
f₁ ← parser_desc_aux p₁,
|
||||
f₂ ← parser_desc_aux p₂,
|
||||
return $ if f₁.empty then [maybe_paren f₂ ++ "?"] else
|
||||
if f₂.empty then [maybe_paren f₁ ++ "?"] else
|
||||
[paren $ join $ f₁ ++ [to_fmt " | "] ++ f₂]
|
||||
| `(brackets %%l %%r %%p) := do
|
||||
f ← parser_desc_aux p,
|
||||
l ← eval_expr string l,
|
||||
r ← eval_expr string r,
|
||||
-- much better than the naive [l, " ", f, " ", r]
|
||||
return [to_fmt l ++ join f ++ to_fmt r]
|
||||
| e := do
|
||||
e' ← (do e' ← unfold e,
|
||||
guard $ e' ≠ e,
|
||||
return e') <|>
|
||||
(do f ← pp e,
|
||||
fail $ to_fmt "don't know how to pretty print " ++ f),
|
||||
parser_desc_aux e'
|
||||
|
||||
meta def param_desc : expr → tactic format
|
||||
| `(parse %%p) := join <$> parser_desc_aux p
|
||||
| `(opt_param %%t _) := (++ "?") <$> pp t
|
||||
| e := if e.is_constant ∧ e.const_name.components.ilast = `itactic
|
||||
then return $ to_fmt "{ tactic }"
|
||||
else paren <$> pp e
|
||||
|
||||
|
||||
private meta constant parse_binders_core (rbp : ℕ) : parser (list pexpr)
|
||||
meta def parse_binders (rbp := std.prec.max) := with_desc "<binders>" (parse_binders_core rbp)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ Author: Leonardo de Moura
|
|||
#include "library/vm/vm_expr.h"
|
||||
#include "library/compiler/vm_compiler.h"
|
||||
#include "library/tactic/kabstract.h"
|
||||
#include "library/tactic/unfold_tactic.h"
|
||||
#include "library/tactic/tactic_state.h"
|
||||
#include "library/tactic/elaborate.h"
|
||||
#include "library/tactic/tactic_evaluator.h"
|
||||
|
|
@ -2406,9 +2405,10 @@ class validate_and_collect_lhs_mvars : public replace_visitor {
|
|||
}
|
||||
if (auto new_e = ctx().reduce_projection(e))
|
||||
return new_e;
|
||||
/* Try to unfold using refl equations */
|
||||
if (auto new_e = dunfold(ctx(), e))
|
||||
return new_e;
|
||||
// HACK: trying to delete `dunfold`
|
||||
// /* Try to unfold using refl equations */
|
||||
// if (auto new_e = dunfold(ctx(), e))
|
||||
// return new_e;
|
||||
/* Last resort, whnf using current setting */
|
||||
expr new_e = ctx().whnf(e);
|
||||
if (new_e != e) return some_expr(new_e);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue