feat: Finite.linearOrder, choosing *some* linear order on a finite type#27020
Closed
grunweg wants to merge 2 commits intoleanprover-community:masterfrom
Closed
feat: Finite.linearOrder, choosing *some* linear order on a finite type#27020grunweg wants to merge 2 commits intoleanprover-community:masterfrom
grunweg wants to merge 2 commits intoleanprover-community:masterfrom
Conversation
This is useful if you want *just some* linear order (but will give wrong results if you expect anything particular about this order). [Zulip discussion](https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/LocallyFiniteOrderBot.20instance.20for.20Fintype/with/528420842)
PR summary 628f824785Import changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diff
You can run this locally as follows## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>The doc-module for No changes to technical debt.You can run this locally as
|
eric-wieser
reviewed
Jul 12, 2025
eric-wieser
reviewed
Jul 12, 2025
| is preferred over choosing *any* linear order. -/ | ||
| protected noncomputable def Finite.linearOrder {α : Type*} [Finite α] : LinearOrder α := | ||
| haveI := Fintype.ofFinite α | ||
| LinearOrder.lift' _ (Fintype.equivFin α).injective |
Member
There was a problem hiding this comment.
I guess arguably we should rename Fintype.equivFin to Finite.equivFin, since the former is very non-constructive anyway.
Contributor
There was a problem hiding this comment.
This hasn't anything to do with finiteness, right? Any type can be endowed with a linear order (and even a well order). This is already known in mathlib, here is a short illustration
def foo (α : Type*) : LinearOrder α := by
choose r wo using exists_wellOrder α
exact rSo I'm not sure the PR is worth it...
Contributor
Author
There was a problem hiding this comment.
Thanks for pointing this out; I hadn't realised. I agree that this PR should be closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is useful if you want just some linear order (but will give wrong results if you expect anything particular about this order). Zulip discussion
This PR was mostly inspired by help of Aaron, Yael and Eric - thank you!
Part of the path towards geodesics and the Levi-Civita connection.