Skip to content

rw tactic "steals" goals #10172

@TwoFX

Description

@TwoFX

Prerequisites

Please put an X between the brackets as you perform the following steps:

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
  · sorry

After 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 solved

Here 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.

Metadata

Metadata

Assignees

Labels

P-mediumWe may work on this issue if we find the timebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions