Skip to content

Commit

Permalink
fix(tactic/rcases): support rcases x with y renames (#15773)
Browse files Browse the repository at this point in the history
fixes #15741
  • Loading branch information
digama0 committed Aug 1, 2022
1 parent bb103f3 commit 073a3e9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/tactic/rcases.lean
Expand Up @@ -385,7 +385,14 @@ meta def rcases (h : option name) (p : pexpr) (pat : rcases_patt) : tactic unit
| none := i_to_expr p
end,
if e.is_local_constant then
focus1 (rcases_core pat e >>= clear_goals)
match pat.name with
| some x := do
n ← revert e,
e ← intro x,
intron (n - 1),
focus1 (rcases_core pat e >>= clear_goals)
| none := focus1 (rcases_core pat e >>= clear_goals)
end
else do
x ← pat.name.elim mk_fresh_name pure,
n ← revert_kdependencies e semireducible,
Expand All @@ -409,7 +416,14 @@ meta def rcases_many (ps : listΠ pexpr) (pat : rcases_patt) : tactic unit := do
end,
e ← i_to_expr p,
if e.is_local_constant then
pure (pat, e)
match pat.name with
| some x := do
n ← revert e,
e ← intro x,
intron (n - 1),
pure (pat, e)
| none := pure (pat, e)
end
else do
x ← pat.name.elim mk_fresh_name pure,
n ← revert_kdependencies e semireducible,
Expand Down
13 changes: 13 additions & 0 deletions test/rcases.lean
Expand Up @@ -189,6 +189,19 @@ example : bool → false → true
| ff := by rintro ⟨⟩
| tt := by rintro ⟨⟩

example : true :=
begin
obtain h : true,
{ trivial },
exact h
end

example {a b} (h : a ∧ b) : a ∧ b :=
begin
rcases h with t,
exact t
end

open tactic
meta def test_rcases_hint (s : string) (num_goals : ℕ) (depth := 5) : tactic unit :=
do change `(true),
Expand Down

0 comments on commit 073a3e9

Please sign in to comment.