`cases` can reorder equally named hypotheses
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
example (P : Nat → Prop) (a) (h : ∃ n, a = n + 1 ∧ P n) : ∃ n, P n := by
let ⟨n', e, h⟩ := h
cases e
exact ⟨_, h⟩
-- application type mismatch
-- Exists.intro ?m.12045 h
-- argument
-- h
-- has type
-- ∃ n, n' + 1 = n + 1 ∧ P n : Prop
-- but is expected to have type
-- P ?m.12045 : Prop
Before the cases, the state is:
P: Nat → Prop
a: Nat
: ∃ n, a = n + 1 ∧ P n
n': Nat
e: a = n' + 1
h: P n'
⊢ ∃ n, P n
The first h: ∃ n, a = n + 1 ∧ P n argument (name elided in the display) is being shadowed by the h: P n' argument. After cases, the state is:
case refl
P: Nat → Prop
n': Nat
: P n'
h: ∃ n, n' + 1 = n + 1 ∧ P n
⊢ ∃ n, P n
Because h: P n' did not need to be rewritten but h: ∃ n, a = n + 1 ∧ P n did, h: ∃ n, a = n + 1 ∧ P n got moved to the end of the hypothesis list, meaning that now h refers to h: ∃ n, a = n + 1 ∧ P n instead of h: P n' and the exact fails.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal Lean example in the issue and inspect the cases tactic's hypothesis reordering and name handling. The fix is complete when equally named hypotheses retain the intended bindings after cases and the shown exact ⟨_, h⟩ succeeds.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100