Skip to content

feat: Finite.linearOrder, choosing *some* linear order on a finite type#27020

Closed
grunweg wants to merge 2 commits intoleanprover-community:masterfrom
grunweg:fintype-linearorder
Closed

feat: Finite.linearOrder, choosing *some* linear order on a finite type#27020
grunweg wants to merge 2 commits intoleanprover-community:masterfrom
grunweg:fintype-linearorder

Conversation

@grunweg
Copy link
Copy Markdown
Contributor

@grunweg grunweg commented Jul 12, 2025

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.

Open in Gitpod

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)
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 12, 2025

PR summary 628f824785

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ Finite.linearOrder

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 script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions bot added the t-data Data (lists, quotients, numbers, etc) label Jul 12, 2025
@grunweg grunweg mentioned this pull request Jul 12, 2025
35 tasks
@grunweg grunweg changed the title feat: Fintype.linearOrder, choosing *some* linear order on a fintype feat: Finite.linearOrder, choosing *some* linear order on a finite type 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess arguably we should rename Fintype.equivFin to Finite.equivFin, since the former is very non-constructive anyway.

Copy link
Copy Markdown
Contributor

@sgouezel sgouezel Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 r

So I'm not sure the PR is worth it...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out; I hadn't realised. I agree that this PR should be closed.

@sgouezel sgouezel added the awaiting-author A reviewer has asked the author a question or requested changes. label Jul 16, 2025
@grunweg grunweg closed this Jul 29, 2025
@grunweg grunweg deleted the fintype-linearorder branch July 29, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes. t-data Data (lists, quotients, numbers, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants