leanprover-community / leanprover-community/mathlib4
`flip` vs `Function.swap`
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 4.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
-- Defined in `Init.Core`
def flip {α β : Sort*} {γ : Sort*} (f : α → β → γ) : β → α → φ :=
fun b a ↦ f a b
-- Defined in `Mathlib.Logic.Function.Defs`
abbrev Function.swap {α β : Sort*} {φ : α → β → Sort*} (f : Π x y, φ x y) : Π y x, φ x y :=
fun y x ↦ f x y
These are almost the same, and both have a non-negligible number of related APIs(flip: 72, Function.swap: 165).
These should be unified.
Personally, I think these should be unified to flip, since it is defined in the core library, and Function.swap is easily confused with Prod.swap.
Updated: α and β in flip is Sort*, not Type*.
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 comparing flip in Init.Core with Function.swap in Mathlib.Logic.Function.Defs, then review the linked API counts for related uses. Decide which name and definition should remain, update the affected APIs consistently, and verify that the two functions are unified without changing their dependent-type behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100