This repository was archived by the owner on Jul 24, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ import tactic.interactive
2
+
3
+ open tactic
4
+ meta def get_nat_ineq : expr → tactic (expr × expr × ℕ)
5
+ | `(%%val < %%ebound) := prod.mk val <$> (prod.mk ebound <$> eval_expr ℕ ebound)
6
+ | `(%%val ≤ %%ebound) := prod.mk val <$> (prod.mk ebound <$> nat.succ <$> eval_expr ℕ ebound)
7
+ | _ := failed
8
+
9
+ namespace tactic.interactive
10
+ open lean.parser interactive
11
+ meta def nat_cases (h : parse ident) : tactic unit :=
12
+ focus1 $ do
13
+ e ← get_local h,
14
+ ⟨val, ⟨ebound, bound⟩⟩ ← infer_type e >>= get_nat_ineq,
15
+ expr.local_const _ nval _ _ ← return val,
16
+ iterate_at_most bound $ do {
17
+ val ← get_local nval,
18
+ cases_core val,
19
+ clear_lst [h],
20
+ swap },
21
+ e ← get_local h,
22
+ val ← get_local nval,
23
+ proof ← to_expr ```(absurd %%e (not_lt_of_ge $ nat.le_add_left %%ebound %%val)),
24
+ tactic.exact proof,
25
+ goals ← get_goals,
26
+ set_goals goals.reverse
27
+
28
+ end tactic.interactive
29
+
30
+ example (n : ℕ) (h : n ≤ 4 ) : n ≤ 10 :=
31
+ begin
32
+ nat_cases h,
33
+ do { goals ← get_goals, guard (goals.length = 5 ) },
34
+ all_goals { exact dec_trivial},
35
+ end
36
+
37
+ example (n : ℕ) (h : n < 4 ) : n ≤ 10 :=
38
+ begin
39
+ nat_cases h,
40
+ do { goals ← get_goals, guard (goals.length = 4 ) },
41
+ all_goals { exact dec_trivial},
42
+ end
You can’t perform that action at this time.
0 commit comments