leanprover / leanprover/lean4

`rw` tactic "steals" goals (again)

Open
#12,135 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
Description

Consider this code:

example {l : List Nat} {P : Prop} {l' l'' : P → List Nat} {a : Nat}
    (hl : (hp : P) → l = a :: l' hp) (hl' : (hp : P) → l' hp = l'' hp) (h : P) :
    l = a :: l'' h := by
  rw [hl]
  · sorry
  · sorry

After the rw, there are two goals: a :: l' ?m.7 = a :: l'' h and P. Now, if I replace the first sorry with rw [hl'], the second goal disappears:

example {l : List Nat} {P : Prop} {l' l'' : P → List Nat} {a : Nat}
    (hl : (hp : P) → l = a :: l' hp) (hl' : (hp : P) → l' hp = l'' hp) (h : P) :
    l = a :: l'' h := by
  rw [hl]
  · rw [hl']
  · sorry -- No goals to be solved
Context

This is the same issue as #10172, just with a different reproducer that is still broken after the fix for the earlier issue.

Expected behavior: rw [hl'] should close the first branch and leave the second branch open.

Actual behavior: Second goal disappears.

Versions
Lean 4.28.0-nightly-2026-01-23
Target: x86_64-unknown-linux-gnu
Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal reproducer against the specified Lean nightly and inspect the rw tactic behavior after the first rewrite. Trace how the two goals from rw [hl] are managed when rw [hl'] closes the first branch; done means the second P goal remains open, with a regression test covering this case.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.