Skip to content

Commit 3076fd7

Browse files
committed
chore: review Cardinal.ord API (#35865)
This PR does the following: - Mark `Cardinal.ord` as no expose. - Prove the defining property `gciOrdCard` earlier. - Deprecate the unused `ord.orderEmbedding` (it simply restates that the function is strictly monotonic). - Rename `ord_nat` → `ord_natCast`.
1 parent 0549d80 commit 3076fd7

4 files changed

Lines changed: 39 additions & 34 deletions

File tree

Mathlib/FieldTheory/CardinalEmb.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public import Mathlib.LinearAlgebra.FreeAlgebra
1111
public import Mathlib.Order.Interval.Set.WithBotTop
1212
public import Mathlib.Order.DirectedInverseSystem
1313

14+
import Mathlib.SetTheory.Ordinal.Basic
15+
1416
/-!
1517
# Number of embeddings of an algebraic extension of infinite separable degree
1618

Mathlib/SetTheory/Cardinal/Aleph.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ theorem isInitial_ord (c : Cardinal) : IsInitial c.ord := by
8282

8383
@[simp]
8484
theorem isInitial_natCast (n : ℕ) : IsInitial n := by
85-
rw [IsInitial, card_nat, ord_nat]
85+
rw [IsInitial, card_nat, ord_natCast]
8686

8787
theorem isInitial_zero : IsInitial 0 := by
8888
exact_mod_cast isInitial_natCast 0

Mathlib/SetTheory/Ordinal/Arithmetic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ theorem exists_lt_mul {b c : Ordinal} {P : Ordinal → Prop} :
961961

962962
instance instCharZero : CharZero Ordinal := by
963963
refine ⟨fun a b h ↦ ?_⟩
964-
rwa [← Cardinal.ord_nat, ← Cardinal.ord_nat, Cardinal.ord_inj, Nat.cast_inj] at h
964+
rwa [← Cardinal.ord_natCast, ← Cardinal.ord_natCast, Cardinal.ord_inj, Nat.cast_inj] at h
965965

966966
@[simp]
967967
theorem one_add_natCast (m : ℕ) : 1 + (m : Ordinal) = succ m := by

Mathlib/SetTheory/Ordinal/Basic.lean

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,10 @@ theorem card_zero : card 0 = 0 := mk_eq_zero _
611611
@[simp]
612612
theorem card_one : card 1 = 1 := mk_eq_one _
613613

614+
@[simp]
615+
theorem _root_.Cardinal.mk_toType (o : Ordinal) : #o.ToType = o.card :=
616+
(Ordinal.card_type _).symm.trans <| by rw [Ordinal.type_toType]
617+
614618
variable (r) in
615619
/-- The cardinality of a set is an upper-bound for the cardinality of the order type of the set's
616620
mex (minimum excluded value). See `not_lt_enum_ord_mk_min_compl` for the `α` version. -/
@@ -1026,12 +1030,7 @@ namespace Cardinal
10261030

10271031
open Ordinal
10281032

1029-
@[simp]
1030-
theorem mk_toType (o : Ordinal) : #o.ToType = o.card :=
1031-
(Ordinal.card_type _).symm.trans <| by rw [Ordinal.type_toType]
1032-
1033-
/-- The ordinal corresponding to a cardinal `c` is the least ordinal
1034-
whose cardinal is `c`. For the order-embedding version, see `ord.order_embedding`. -/
1033+
/-- The ordinal corresponding to a cardinal `c` is the least ordinal whose cardinal is `c`. -/
10351034
@[no_expose]
10361035
def ord (c : Cardinal) : Ordinal :=
10371036
Quot.liftOn c (fun α : Type u => ⨅ r : { r // IsWellOrder α r }, @type α r.1 r.2) <| by
@@ -1064,8 +1063,13 @@ theorem exists_ord_eq_type_lt (α) :
10641063
theorem ord_le_type (r : α → α → Prop) [h : IsWellOrder α r] : ord #α ≤ type r :=
10651064
ciInf_le' _ (Subtype.mk r h)
10661065

1067-
theorem ord_le {c o} : ord c ≤ o ↔ c ≤ o.card := by
1068-
refine c.inductionOn fun α ↦ o.inductionOn fun β s _ ↦ ?_
1066+
@[simp]
1067+
theorem card_ord (c) : (ord c).card = c :=
1068+
c.inductionOn fun α ↦ let ⟨r, _, e⟩ := exists_ord_eq α; e ▸ card_type r
1069+
1070+
/-- Galois connection between `Cardinal.ord` and `Ordinal.card`. -/
1071+
theorem gc_ord_card : GaloisConnection ord card := by
1072+
refine fun c o ↦ c.inductionOn fun α ↦ o.inductionOn fun β s _ ↦ ?_
10691073
let ⟨r, _, e⟩ := exists_ord_eq α
10701074
constructor <;> intro h
10711075
· rw [e] at h
@@ -1075,25 +1079,22 @@ theorem ord_le {c o} : ord c ≤ o ↔ c ≤ o.card := by
10751079
have := RelEmbedding.isWellOrder g
10761080
exact (ord_le_type _).trans g.ordinal_type_le
10771081

1078-
theorem gc_ord_card : GaloisConnection ord card := fun _ _ => ord_le
1082+
/-- Galois coinsertion between `Cardinal.ord` and `Ordinal.card`. -/
1083+
def gciOrdCard : GaloisCoinsertion ord card :=
1084+
gc_ord_card.toGaloisCoinsertion fun c ↦ c.card_ord.le
1085+
1086+
theorem ord_le {c o} : ord c ≤ o ↔ c ≤ o.card :=
1087+
gc_ord_card.le_iff_le
10791088

10801089
theorem lt_ord {c o} : o < ord c ↔ o.card < c :=
10811090
gc_ord_card.lt_iff_lt
10821091

1083-
@[simp]
1084-
theorem card_ord (c) : (ord c).card = c :=
1085-
c.inductionOn fun α ↦ let ⟨r, _, e⟩ := exists_ord_eq α; e ▸ card_type r
1086-
10871092
theorem card_surjective : Function.Surjective card :=
10881093
fun c ↦ ⟨_, card_ord c⟩
10891094

10901095
theorem bddAbove_ord_image_iff {s : Set Cardinal} : BddAbove (ord '' s) ↔ BddAbove s :=
10911096
gc_ord_card.bddAbove_l_image
10921097

1093-
/-- Galois coinsertion between `Cardinal.ord` and `Ordinal.card`. -/
1094-
def gciOrdCard : GaloisCoinsertion ord card :=
1095-
gc_ord_card.toGaloisCoinsertion fun c => c.card_ord.le
1096-
10971098
theorem ord_card_le (o : Ordinal) : o.card.ord ≤ o :=
10981099
gc_ord_card.l_u_le _
10991100

@@ -1120,6 +1121,9 @@ theorem ord_strictMono : StrictMono ord :=
11201121
theorem ord_mono : Monotone ord :=
11211122
gc_ord_card.monotone_l
11221123

1124+
theorem ord_injective : Injective ord :=
1125+
ord_strictMono.injective
1126+
11231127
@[simp]
11241128
theorem ord_le_ord {c₁ c₂} : ord c₁ ≤ ord c₂ ↔ c₁ ≤ c₂ :=
11251129
gciOrdCard.l_le_l_iff
@@ -1128,23 +1132,29 @@ theorem ord_le_ord {c₁ c₂} : ord c₁ ≤ ord c₂ ↔ c₁ ≤ c₂ :=
11281132
theorem ord_lt_ord {c₁ c₂} : ord c₁ < ord c₂ ↔ c₁ < c₂ :=
11291133
ord_strictMono.lt_iff_lt
11301134

1135+
@[simp]
1136+
theorem ord_inj {c₁ c₂} : ord c₁ = ord c₂ ↔ c₁ = c₂ :=
1137+
ord_injective.eq_iff
1138+
11311139
@[simp]
11321140
theorem ord_zero : ord 0 = 0 :=
11331141
gc_ord_card.l_bot
11341142

11351143
@[simp]
1136-
theorem ord_nat (n : ℕ) : ord n = n := by
1144+
theorem ord_natCast (n : ℕ) : ord n = n := by
11371145
apply (ord_le.2 (card_nat n).ge).antisymm
11381146
induction n with
11391147
| zero => exact zero_le
11401148
| succ n IH => exact (IH.trans_lt <| by simp).succ_le
11411149

1150+
@[deprecated (since := "2026-02-27")] alias ord_nat := ord_natCast
1151+
11421152
@[simp]
11431153
theorem ord_ofNat (n : ℕ) [n.AtLeastTwo] : ord ofNat(n) = OfNat.ofNat n :=
1144-
ord_nat n
1154+
ord_natCast n
11451155

11461156
@[simp]
1147-
theorem ord_one : ord 1 = 1 := by simpa using ord_nat 1
1157+
theorem ord_one : ord 1 = 1 := by simpa using ord_natCast 1
11481158

11491159
theorem isNormal_ord : Order.IsNormal ord where
11501160
strictMono := ord_strictMono
@@ -1195,14 +1205,6 @@ theorem card_typein_toType_lt (c : Cardinal) (x : c.ord.ToType) :
11951205
card (typein (α := c.ord.ToType) (· < ·) x) < c :=
11961206
mk_Iio_toType_ord_lt x
11971207

1198-
theorem ord_injective : Injective ord := by
1199-
intro c c' h
1200-
rw [← card_ord c, ← card_ord c', h]
1201-
1202-
@[simp]
1203-
theorem ord_inj {a b : Cardinal} : a.ord = b.ord ↔ a = b :=
1204-
ord_injective.eq_iff
1205-
12061208
@[simp]
12071209
theorem ord_eq_zero {a : Cardinal} : a.ord = 0 ↔ a = 0 :=
12081210
ord_injective.eq_iff' ord_zero
@@ -1238,11 +1240,12 @@ theorem ord_eq_omega0 {a : Cardinal} : a.ord = ω ↔ a = ℵ₀ :=
12381240
/-- The ordinal corresponding to a cardinal `c` is the least ordinal
12391241
whose cardinal is `c`. This is the order-embedding version. For the regular function, see `ord`.
12401242
-/
1243+
@[deprecated ord (since := "2026-02-27")]
12411244
def ord.orderEmbedding : Cardinal ↪o Ordinal :=
1242-
RelEmbedding.orderEmbeddingOfLTEmbedding
1243-
(RelEmbedding.ofMonotone Cardinal.ord fun _ _ => Cardinal.ord_lt_ord.2)
1245+
OrderEmbedding.ofStrictMono _ fun _ _ ↦ Cardinal.ord_lt_ord.2
12441246

1245-
@[simp]
1247+
set_option linter.deprecated false in
1248+
@[deprecated ord (since := "2026-02-27")]
12461249
theorem ord.orderEmbedding_coe : (ord.orderEmbedding : Cardinal → Ordinal) = ord :=
12471250
rfl
12481251

@@ -1252,7 +1255,7 @@ namespace Ordinal
12521255

12531256
@[simp]
12541257
theorem nat_le_card {o} {n : ℕ} : (n : Cardinal) ≤ card o ↔ (n : Ordinal) ≤ o := by
1255-
rw [← Cardinal.ord_le, Cardinal.ord_nat]
1258+
rw [← Cardinal.ord_le, Cardinal.ord_natCast]
12561259

12571260
@[simp]
12581261
theorem one_le_card {o} : 1 ≤ card o ↔ 1 ≤ o := by

0 commit comments

Comments
 (0)