RFC: Unify what `MyInductiveType.elim` means
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Proposal
Currently, the .elim lemmas are all over the place in terms of argument order:
X.elimwithx : Xas the first argument:Nonempty.elim(core),Or.elim(core),Not.elim(core),Ne.elim(core),Exists.elim(core),Option.elim(core),Or.elim3(Mathlib),X.elimwithx : Xas the last argument:And.elim(core),Iff.elim(core),Sum.elim(Batteries),Option.elim'(Mathlib)
It would be good for the benefit of everyone if these discrepancies were fixed.
I would further like to argue that we should fix these discrepancies by having:
X.elimtakex : Xas the last argumentX.elimOntakex : Xas the first argument
This would match the naming of X.rec and X.recOn.
Community Feedback
This was discussed on Zulip in Lean 3 and in Lean 4. Recently, there was #15448 by @urkud.
Here is a summary of what was said:
- Yes, the current situation is indeed a mess
- We definitely want the version with the
Xargument last in cases where we are building functions out of (not-so-large) large combinations of inductive types. EgSum.elim (Sum.elim (fun _ => trivial) fun _ => trivial) fun _ => trivialis nicer thanfun x => x.elim (fun y => y.elim (fun _ => trivial) fun _ => trivial) fun _ => trivialwhen building a term of typeα ⊕ β ⊕ γ → True. This also shows up in Mathlib vector notation. - We want the version with the
Xargument first when we want to do a "poor-man'smatchstatement" to be able to see what each branch is after having provided the main premise. But this need can be circumvented by either using- dot notation:
myX.elim _ _ - a named argument, assuming the main premise is a named argument:
X.elim (x := myX) _ _
- dot notation:
Impact
Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.
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 by reviewing the listed core, Batteries, and Mathlib eliminators, then read the linked Zulip discussions and issue #15448. Done would require an agreed argument-order convention and the corresponding coordinated changes across the affected APIs.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100