@@ -5,7 +5,8 @@ Authors: Mario Carneiro
5
5
-/
6
6
import data.dlist data.dlist.basic data.prod category.basic
7
7
tactic.basic tactic.rcases tactic.generalize_proofs
8
- tactic.split_ifs meta .expr logic.basic
8
+ tactic.split_ifs meta .expr tactic.ext
9
+ logic.basic
9
10
10
11
open lean
11
12
open lean.parser
@@ -197,7 +198,6 @@ do let h := h.get_or_else `this,
197
198
198
199
meta def symm_apply (e : expr) (cfg : apply_cfg := {}) : tactic (list (name × expr)) :=
199
200
tactic.apply e cfg <|> (symmetry >> tactic.apply e cfg)
200
-
201
201
/--
202
202
`apply_assumption` looks for an assumption of the form `... → ∀ _, ... → head`
203
203
where `head` matches the current goal.
@@ -280,7 +280,7 @@ repeat (do
280
280
try (refine ``( or_iff_not_imp_left.mpr _)),
281
281
try (refine ``( or_iff_not_imp_right.mpr _)),
282
282
gs' ← get_goals,
283
- guard (gs ≠ gs') ) ;
283
+ guard (gs ≠ gs') );
284
284
repeat
285
285
(reflexivity <|> solve_by_elim <|>
286
286
constructor_matching none [``(_ ∧ _),``(_ ↔ _),``(Exists _)] ) ;
@@ -289,22 +289,6 @@ done
289
289
/-- Shorter name for the tactic `tautology`. -/
290
290
meta def tauto := tautology
291
291
292
- /--
293
- Tag lemmas of the form:
294
-
295
- ```
296
- lemma my_collection.ext (a b : my_collection)
297
- (h : ∀ x, a.lookup x = b.lookup y) :
298
- a = b := ...
299
- ```
300
- -/
301
- @[user_attribute]
302
- meta def extensional_attribute : user_attribute :=
303
- { name := `extensionality ,
304
- descr := " lemmas usable by `ext` tactic" }
305
-
306
- attribute [extensionality] _root_.funext array.ext prod.ext
307
-
308
292
/--
309
293
`ext1 id` selects and apply one extensionality lemma (with attribute
310
294
`extensionality`), using `id`, if provided, to name a local constant
@@ -537,5 +521,18 @@ meta def apply_field : tactic unit :=
537
521
propagate_tags $
538
522
get_current_field >>= applyc
539
523
524
+ /-- `elim_cast e with x` matches on `cast _ e` in the goal and replaces it with
525
+ `x`. It also adds `Hx : e == x` as an assumption.
526
+
527
+ `elim_cast! e with x` acts similarly but reverts `Hx`.
528
+ -/
529
+ meta def elim_cast (rev : parse (tk " !" )?) (e : parse texpr) (n : parse (tk " with" *> ident)) : tactic unit :=
530
+ do h ← get_unused_name (" H" ++ n.to_string : string),
531
+ interactive.generalize h () (``(cast _ %%e), n),
532
+ asm ← get_local h,
533
+ to_expr ``(heq_of_cast_eq _ %%asm) >>= note h none,
534
+ tactic.clear asm,
535
+ when rev.is_some (interactive.revert [n])
536
+
540
537
end interactive
541
538
end tactic
0 commit comments