refactor(library/init/meta): move replace_hyp to tactic.lean
This commit is contained in:
parent
0b19ef82e1
commit
73b6facd1e
2 changed files with 13 additions and 7 deletions
|
|
@ -358,13 +358,6 @@ step $
|
|||
do s ← collect_ctx_simps >>= s.append,
|
||||
simp_intro_aux cfg tt s tt ns
|
||||
|
||||
meta def replace_hyp (h : expr) (h_new_type : expr) (pr : expr) : tactic expr :=
|
||||
do h_type ← infer_type h,
|
||||
new_h ← assert h.local_pp_name h_new_type,
|
||||
mk_eq_mp pr h >>= exact,
|
||||
try $ clear h,
|
||||
return new_h
|
||||
|
||||
meta def simp_at (h : expr) (extra_lemmas : list expr := []) (cfg : simp_config := {}) : tactic expr :=
|
||||
do when (expr.is_local_constant h = ff) (fail "tactic simp_at failed, the given expression is not a hypothesis"),
|
||||
htype ← infer_type h,
|
||||
|
|
|
|||
|
|
@ -1077,6 +1077,19 @@ do h ← get_local curr,
|
|||
intro new,
|
||||
intron (n - 1)
|
||||
|
||||
/--
|
||||
"Replace" hypothesis `h : type` with `h : new_type` where `eq_pr` is a proof
|
||||
that (type = new_type). The tactic actually creates a new hypothesis
|
||||
with the same user facing name, and (tries to) clear `h`.
|
||||
The `clear` step fails if `h` has forward dependencies. In this case, the old `h`
|
||||
will remain in the local context. The tactic returns the new hypothesis. -/
|
||||
meta def replace_hyp (h : expr) (new_type : expr) (eq_pr : expr) : tactic expr :=
|
||||
do h_type ← infer_type h,
|
||||
new_h ← assert h.local_pp_name new_type,
|
||||
mk_eq_mp eq_pr h >>= exact,
|
||||
try $ clear h,
|
||||
return new_h
|
||||
|
||||
end tactic
|
||||
|
||||
notation [parsing_only] `command`:max := tactic unit
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue