-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: more API about order types #33420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: more API about order types #33420
Conversation
PR summary b79634a5c1Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
vihdzp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I've got lots of small suggestions/improvements, and a few larger ones.
vihdzp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I've got lots of small suggestions/improvements, and a few larger ones.
Mathlib/Order/OrderType.lean
Outdated
| /-- `ω` is the first infinite ordinal, defined as the order type of `ℕ`. -/ | ||
| def omega0 : OrderType := type ℕ | ||
|
|
||
| /-- The order type of the rational numbers. -/ | ||
| def eta : OrderType := type ℚ | ||
|
|
||
| /-- The order type of the real numbers on the interval `(0,1)`. -/ | ||
| def theta : OrderType := type (Set.Ioo (0 : ℝ) 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to double-check these notations are the literature-approved ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can vouch for omega and eta, I'd have to check for theta.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also surely type (Set.Ioo (0 : ℝ) 1) = type ℝ, no?
Mathlib/Order/OrderType.lean
Outdated
| Copyright (c) _ | ||
| -/ | ||
| import Mathlib.SetTheory.Cardinal.Basic | ||
| import Mathlib.SetTheory.Ordinal.Basic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already talked about this, but IMO ordinals should import order types, not the other way around
|
(once you've applied all/most suggestions, remove the awaiting author tag and please make sure to notify me!) |
@vihdzp I believe i have addressed almost all of the points, some things still need to be moved but the monoid definition prevents imports of Ordertype from cardinal (for now) , and certain missing instances made it hard to move the empty sum order iso parts. The other file changes will be made into separate small PRs i imagine. |
|
-awaiting-author |
YaelDillies
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make a preliminary PR for the order isos?
Mathlib/Order/OrderType.lean
Outdated
| /-- An auxiliary structure representing a linearly ordered type. -/ | ||
| @[ext] | ||
| structure LinearOrderedType : Type (u + 1) where | ||
| carrier : Type u | ||
| le : LE carrier | ||
| isLinearOrder_carrier : Std.IsLinearOrder carrier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason not to use LinOrd here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested this design and gave an argument against LinOrd in this reply. In particular:
- I think the categorical properties of
LinOrdare irrelevant here. We don't need the extra structure thatDon't agree with this part anymore, see here.LinearOrdercomes bundled with to define an order type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think the categorical properties of
LinOrdare irrelevant here.
Sure, but we are free to ignore those categorical properties? I am worried about two definitions doing the exact same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LinOrd is a category of mathematical interest. LinearOrderedType is an auxiliary structure which should have no public API that exists only to declare a much more interesting quotient on. Compare WellOrder.
|
You know, I thought about the So yeah, I think we could just define But maybe wait for Yaël's opinion before you change anything, I don't want you to have to undo your work all over again! |
I do think we should use |
|
All we actually need from |
|
I think it's reasonable to move it to |
|
|
|
-awaiting-author |
vihdzp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpicks of mine. This PR is shaping up quite nicely!
You could already start properly PRing the first pieces of this. The material on Order.Hom looks quite good (modulo some small suggestions) and I'd like to use it to golf the analogous proofs on Ordinal. You could then PR the Order.Types.Defs file, and at that point we can start thinking about what kind of API to add where and how to eventually link this to Ordinal.
| @@ -0,0 +1,229 @@ | |||
| /- | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Type would be a better name for the folder. We generally don't pluralize names of mathematical objects in the file structure (we have Order.CompleteSublattice say, rather than Order.CompleteSublattices).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or OrderType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Order part of OrderType seems redundant given that we're already in the Order folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But Order.Type sounds like it should be about order properties of Type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can also just keep the folder named Order.Types. Matches ModelTheory.Types, for instance.
| le_trans a b c := | ||
| Quotient.inductionOn₃ a b c fun _ _ _ ⟨f⟩ ⟨g⟩ ↦ ⟨f.trans g⟩ | ||
|
|
||
| instance instNeZeroOne : NeZero (1 : OrderType) := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not be naming instances unless we have a legitimate reason to.
| instance instNeZeroOne : NeZero (1 : OrderType) := | |
| instance : NeZero (1 : OrderType) := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disagree. I'd rather make sure the instances can be found by name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the default name given here a bad one?
| add := Quotient.map₂ (fun r s ↦ ⟨(r ⊕ₗ s)⟩) | ||
| fun _ _ ha _ _ hb ↦ ⟨OrderIso.sumLexCongr (Classical.choice ha) (Classical.choice hb)⟩ | ||
|
|
||
| instance : HAdd OrderType.{u} OrderType.{v} OrderType.{max u v} where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I (re)opened a Zulip thread about this: #mathlib4 > Universe-heterogeneous ordinal and cardinal relations @ 💬
| def eta : OrderType := type ℚ | ||
|
|
||
| /-- The order type of the real numbers. -/ | ||
| def theta : OrderType := type ℝ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll reiterate my suggestion that I'd like to see this in another file, probably one dedicated to η-orders entirely. We shouldn't be importing the real numbers on what's really quite basic order theory.
|
🌶️ take incoming: should we eventually move the |
|
Still need to move some of the OrderTypes , and will open a seperate pr for the OrderIso/Lex lemmas. -awaiting-author |
4c41035 to
d6fa0fb
Compare
commit d51b84d Author: YanYablonovskiy <[email protected]> Date: Tue Jan 6 20:13:26 2026 +1100 OrderIso prod lemmas adjustment commit 4c41035 Merge: b88c734 15f6691 Author: Yan Yablonovskiy <[email protected]> Date: Tue Jan 6 20:04:32 2026 +1100 Merge branch 'master' into master commit b88c734 Author: YanYablonovskiy <[email protected]> Date: Tue Jan 6 19:33:15 2026 +1100 Changes from review commit 8252446 Author: Yan Yablonovskiy <[email protected]> Date: Tue Jan 6 16:00:09 2026 +1100 Apply suggestions from code review Co-authored-by: Violeta Hernández Palacios <[email protected]> commit 8ac8458 Author: YanYablonovskiy <[email protected]> Date: Tue Jan 6 01:11:04 2026 +1100 Change mathlib imports from `OrderType` `OrderType.lean` no longer exists commit f353fe8 Merge: 30bd77d 959c852 Author: Yan Yablonovskiy <[email protected]> Date: Mon Jan 5 23:17:21 2026 +1100 Merge branch 'leanprover-community:master' into master commit 30bd77d Author: YanYablonovskiy <[email protected]> Date: Mon Jan 5 21:49:57 2026 +1100 Refactor as per suggestions, back to `LinOrd` commit f8cd844 Merge: f04b327 a57b343 Author: YanYablonovskiy <[email protected]> Date: Mon Jan 5 21:49:30 2026 +1100 Merge branch 'master' of https://github.com/YanYablonovskiy/mathlib4_Order-types-Issue28278 commit f04b327 Author: YanYablonovskiy <[email protected]> Date: Mon Jan 5 11:36:50 2026 +1100 Apply suggestions commit a57b343 Merge: 5937b50 8c8bf56 Author: Yan Yablonovskiy <[email protected]> Date: Mon Jan 5 11:30:56 2026 +1100 Merge branch 'leanprover-community:master' into master commit 5937b50 Merge: 07abc73 2330302 Author: YanYablonovskiy <[email protected]> Date: Mon Jan 5 10:21:08 2026 +1100 Merge branch 'master' of https://github.com/YanYablonovskiy/mathlib4_Order-types-Issue28278 commit 2330302 Author: Yan Yablonovskiy <[email protected]> Date: Mon Jan 5 10:20:45 2026 +1100 Apply suggestions from code review Co-authored-by: Yaël Dillies <[email protected]> Co-authored-by: Violeta Hernández Palacios <[email protected]> commit 07abc73 Author: YanYablonovskiy <[email protected]> Date: Mon Jan 5 00:44:02 2026 +1100 Fix recommended_spellings commit b25cb4c Author: YanYablonovskiy <[email protected]> Date: Mon Jan 5 00:37:52 2026 +1100 Add doc-string and some more typos commit 067b8cd Author: YanYablonovskiy <[email protected]> Date: Mon Jan 5 00:31:32 2026 +1100 Minor typos commit 4b5a837 Author: YanYablonovskiy <[email protected]> Date: Sun Jan 4 22:26:24 2026 +1100 Finish conversation review suggestions commit 5429c1b Author: Yan Yablonovskiy <[email protected]> Date: Fri Jan 2 23:31:29 2026 +1100 Apply suggestions from code review [skip ci] Co-authored-by: Yaël Dillies <[email protected]> Co-authored-by: Violeta Hernández Palacios <[email protected]> commit 630f0ea Author: YanYablonovskiy <[email protected]> Date: Fri Jan 2 23:14:37 2026 +1100 Style fix commit bf5166d Author: YanYablonovskiy <[email protected]> Date: Fri Jan 2 22:58:10 2026 +1100 Fix module error commit 2f0a005 Merge: 44753fe 519f454 Author: Yan Yablonovskiy <[email protected]> Date: Fri Jan 2 20:11:02 2026 +1100 Merge branch 'leanprover-community:master' into master commit 44753fe Author: YanYablonovskiy <[email protected]> Date: Fri Jan 2 19:42:27 2026 +1100 Bump commit 43b7d68 Author: YanYablonovskiy <[email protected]> Date: Fri Jan 2 19:18:34 2026 +1100 Clean up imports, get rid of sorries, and address some comments commit f888e2b Author: YanYablonovskiy <[email protected]> Date: Thu Jan 1 22:12:33 2026 +1100 Update OrderType.lean Add copyright [skip actions] commit 9848662 Author: YanYablonovskiy <[email protected]> Date: Thu Jan 1 21:56:01 2026 +1100 Update OrderType.lean commit b8acc2e Author: Yan Yablonovskiy <[email protected]> Date: Thu Jan 1 20:15:25 2026 +1100 Apply suggestions from code review Co-authored-by: Violeta Hernández Palacios <[email protected]> Co-authored-by: Yaël Dillies <[email protected]> commit a5e62be Merge: 6aa39b3 de80207 Author: YanYablonovskiy <[email protected]> Date: Wed Dec 31 16:34:44 2025 +1100 Merge branch 'master' of https://github.com/YanYablonovskiy/mathlib4_Order-types-Issue28278 commit 6aa39b3 Author: YanYablonovskiy <[email protected]> Date: Wed Dec 31 16:34:33 2025 +1100 Update OrderType.lean commit de80207 Merge: 669a1d3 6dc6d70 Author: Yan Yablonovskiy <[email protected]> Date: Wed Dec 31 16:34:24 2025 +1100 Merge branch 'leanprover-community:master' into master commit 669a1d3 Merge: a90d529 6371049 Author: Yan Yablonovskiy <[email protected]> Date: Mon Dec 29 10:38:08 2025 +1100 Merge branch 'leanprover-community:master' into master commit a90d529 Merge: 24bb5b0 cc5691d Author: Yan Yablonovskiy <[email protected]> Date: Mon Dec 22 13:06:26 2025 +1100 Merge branch 'leanprover-community:master' into master commit 24bb5b0 Merge: 4985680 5334b1e Author: Yan Yablonovskiy <[email protected]> Date: Wed Nov 26 18:44:18 2025 +1100 Merge branch 'leanprover-community:master' into master commit 4985680 Merge: 711df94 3f87ea8 Author: Yan Yablonovskiy <[email protected]> Date: Sun Nov 23 12:48:18 2025 +1100 Merge branch 'leanprover-community:master' into master commit 711df94 Merge: 6534400 b3cf7a0 Author: Yan Yablonovskiy <[email protected]> Date: Sat Nov 22 13:48:50 2025 +1100 Merge branch 'leanprover-community:master' into master commit 6534400 Merge: bb1a642 56c98a5 Author: Yan Yablonovskiy <[email protected]> Date: Thu Nov 20 18:46:50 2025 +1100 Merge branch 'leanprover-community:master' into master commit bb1a642 Author: YanYablonovskiy <[email protected]> Date: Mon Oct 20 21:27:21 2025 +1100 Update OrderType.lean commit f427a91 Author: YanYablonovskiy <[email protected]> Date: Mon Oct 20 18:25:16 2025 +1100 Update OrderType.lean commit f6c13a0 Author: YanYablonovskiy <[email protected]> Date: Mon Oct 20 17:59:56 2025 +1100 Update OrderType.lean commit 78e4c9a Author: YanYablonovskiy <[email protected]> Date: Mon Oct 20 16:29:31 2025 +1100 Update OrderType.lean commit e827b3c Author: YanYablonovskiy <[email protected]> Date: Sat Oct 18 00:41:45 2025 +1100 Update OrderType.lean commit f5d5427 Author: YanYablonovskiy <[email protected]> Date: Sat Oct 18 00:23:18 2025 +1100 Update OrderType.lean commit 871acb9 Author: YanYablonovskiy <[email protected]> Date: Fri Oct 17 22:32:05 2025 +1100 Update OrderType.lean commit 803ced6 Author: YanYablonovskiy <[email protected]> Date: Fri Oct 17 20:45:37 2025 +1100 Update OrderType.lean commit 2883e90 Author: YanYablonovskiy <[email protected]> Date: Thu Oct 16 23:04:21 2025 +1100 Update OrderType.lean commit 971c382 Author: Yan Yablonovskiy <[email protected]> Date: Thu Oct 16 23:02:18 2025 +1100 Update OrderType.lean commit 3db4465 Author: Yan Yablonovskiy <[email protected]> Date: Thu Oct 16 23:01:46 2025 +1100 Update OrderType.lean commit 3e7c325 Author: YanYablonovskiy <[email protected]> Date: Thu Oct 16 22:59:05 2025 +1100 Update OrderType.lean commit ce284fa Author: Yan Yablonovskiy <[email protected]> Date: Tue Oct 14 20:26:41 2025 +1100 Update OrderType.lean commit e0e79c8 Author: YanYablonovskiy <[email protected]> Date: Tue Oct 14 19:02:32 2025 +1100 Create OrderTypes file with definition and some generalisation from Ordinal commit e78fa58 Merge: aa54d18 3aa3aca Author: Yan Yablonovskiy <[email protected]> Date: Tue Oct 14 19:02:04 2025 +1100 Merge branch 'leanprover-community:master' into master commit aa54d18 Merge: 3742a3b efcc0aa Author: Yan Yablonovskiy <[email protected]> Date: Sun Sep 21 15:21:45 2025 +1000 Merge branch 'leanprover-community:master' into master commit 3742a3b Author: YanYablonovskiy <[email protected]> Date: Sat Sep 20 22:28:23 2025 +1000 Create OrderTypes_basic.lean
d4daec0 to
6e9cfd2
Compare
Co-authored-by: Violeta Hernández Palacios <[email protected]> Co-authored-by: Yaël Dillies <[email protected]>
Add copyright [skip actions]
[skip ci] Co-authored-by: Yaël Dillies <[email protected]> Co-authored-by: Violeta Hernández Palacios <[email protected]>
Co-authored-by: Yaël Dillies <[email protected]> Co-authored-by: Violeta Hernández Palacios <[email protected]>
`OrderType.lean` no longer exists
Co-authored-by: Violeta Hernández Palacios <[email protected]>
6e9cfd2 to
3e07307
Compare
|
This PR/issue depends on:
|
Adding OrderTypes, equivalence classes of linear orders up to order isomorphism.