-
Notifications
You must be signed in to change notification settings - Fork 809
rw tactic "steals" goals #10172
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
Consider this code:
example (l m : List Nat) (i : Nat) (hi' : i < (l ++ m).length)
(hh : ∀ hi, l[i]'hi = 5) : (l ++ m)[i] = 5 := by
rw [List.getElem_append_left]
· sorry
· sorryAfter the rw, there are two goals: l[i] = 5 and i < l.length. Now, if I replace the first sorry with rw [hh], then two unexpected things happen: first, the rewrite leaves behind a goal of i < l.length (why was this not filled by unification?), and second, the second goal below disappears:
example (l m : List Nat) (i : Nat) (hi' : i < (l ++ m).length)
(hh : ∀ hi, l[i]'hi = 5) : (l ++ m)[i] = 5 := by
rw [List.getElem_append_left]
· rw [hh] -- Error: unsolved goal `i < l.length`
· sorry -- Error: No goals to be solvedHere is a video of the behavior: https://www.youtube.com/watch?v=JpYr1tKO37M
Expected behavior: rw [hh] should close the first branch. The second branch asking for i < l.length should remain open.
Hence, the second snippet above should have no errors (just a sorry warning).
Actual behavior: First branch has goal i < l.length, second branch is closed.
Versions
Lean 4.24.0-nightly-2025-08-27
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.