Skip to content

Commit 8fd7a1a

Browse files
committed
chore: move Ordinal.univ and Cardinal.univ to their own file (leanprover-community#37681)
This ensures `SetTheory/Ordinal/Basic` stays under the 1500 line limit.
1 parent 2b875e0 commit 8fd7a1a

5 files changed

Lines changed: 186 additions & 147 deletions

File tree

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6881,6 +6881,7 @@ public import Mathlib.SetTheory.Ordinal.Notation
68816881
public import Mathlib.SetTheory.Ordinal.Principal
68826882
public import Mathlib.SetTheory.Ordinal.Rank
68836883
public import Mathlib.SetTheory.Ordinal.Topology
6884+
public import Mathlib.SetTheory.Ordinal.Univ
68846885
public import Mathlib.SetTheory.Ordinal.Veblen
68856886
public import Mathlib.SetTheory.ZFC.Basic
68866887
public import Mathlib.SetTheory.ZFC.Cardinal

Mathlib/SetTheory/Cardinal/Aleph.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public import Mathlib.Algebra.Order.Monoid.Basic
99
public import Mathlib.SetTheory.Cardinal.ToNat
1010
public import Mathlib.SetTheory.Cardinal.ENat
1111
public import Mathlib.SetTheory.Ordinal.Enum
12+
public import Mathlib.SetTheory.Ordinal.Univ
1213

1314
/-!
1415
# Omega, aleph, and beth functions

Mathlib/SetTheory/Cardinal/UnivLE.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors: Junyan Xu
66
module
77

88
public import Mathlib.Logic.UnivLE
9-
public import Mathlib.SetTheory.Ordinal.Basic
9+
public import Mathlib.SetTheory.Ordinal.Univ
1010

1111
/-!
1212
# UnivLE and cardinals

Mathlib/SetTheory/Ordinal/Basic.lean

Lines changed: 0 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,76 +1003,10 @@ theorem le_enum_succ {o : Ordinal} (a : (succ o).ToType) :
10031003
← lt_succ_iff]
10041004
apply typein_lt_self
10051005

1006-
/-! ### Universal ordinal -/
1007-
1008-
-- intended to be used with explicit universe parameters
1009-
/-- `univ.{u v}` is the order type of the ordinals of `Type u` as a member
1010-
of `Ordinal.{v}` (when `u < v`). It is an inaccessible cardinal. -/
1011-
@[pp_with_univ, nolint checkUnivs]
1012-
def univ : Ordinal.{max (u + 1) v} :=
1013-
lift.{v, u + 1} (typeLT Ordinal)
1014-
1015-
@[simp]
1016-
theorem type_lt_ordinal : typeLT Ordinal = univ.{u, u + 1} :=
1017-
(lift_id _).symm
1018-
1019-
@[deprecated type_lt_ordinal (since := "2026-03-20")]
1020-
theorem univ_id : univ.{u, u + 1} = typeLT Ordinal :=
1021-
lift_id _
1022-
1023-
@[simp]
1024-
theorem lift_univ : lift.{w} univ.{u, v} = univ.{u, max v w} :=
1025-
lift_lift _
1026-
1027-
theorem univ_umax : univ.{u, max (u + 1) v} = univ.{u, v} :=
1028-
congr_fun lift_umax _
1029-
1030-
/-- Principal segment version of the lift operation on ordinals, embedding `Ordinal.{u}` in
1031-
`Ordinal.{v}` as a principal segment when `u < v`. -/
1032-
def liftPrincipalSeg : Ordinal.{u} <i Ordinal.{max (u + 1) v} :=
1033-
⟨↑liftInitialSeg.{max (u + 1) v, u}, univ.{u, v}, by
1034-
refine fun b => inductionOn b ?_; intro β s _
1035-
rw [univ, ← lift_umax]; constructor <;> intro h
1036-
· obtain ⟨a, e⟩ := h
1037-
rw [← e]
1038-
refine inductionOn a ?_
1039-
intro α r _
1040-
exact lift_type_lt.{u, u + 1, max (u + 1) v}.2 ⟨typein r⟩
1041-
· rw [← lift_id (type s)] at h ⊢
1042-
obtain ⟨f⟩ := lift_type_lt.{_,_,v}.1 h
1043-
obtain ⟨f, a, hf⟩ := f
1044-
exists a
1045-
induction a using inductionOn with | type α r
1046-
refine lift_type_eq.{u, max (u + 1) v, max (u + 1) v}.2
1047-
⟨(RelIso.ofSurjective (RelEmbedding.ofMonotone ?_ ?_) ?_).symm⟩
1048-
· exact fun b => enum r ⟨f b, (hf _).1 ⟨_, rfl⟩⟩
1049-
· refine fun a b h => (typein_lt_typein r).1 ?_
1050-
rw [typein_enum, typein_enum]
1051-
exact f.map_rel_iff.2 h
1052-
· intro a'
1053-
obtain ⟨b, e⟩ := (hf _).2 (typein_lt_type _ a')
1054-
exists b
1055-
simp only [RelEmbedding.ofMonotone_coe]
1056-
simp [e]⟩
1057-
1058-
@[simp]
1059-
theorem liftPrincipalSeg_coe :
1060-
(liftPrincipalSeg.{u, v} : Ordinal → Ordinal) = lift.{max (u + 1) v} :=
1061-
rfl
1062-
1063-
@[simp]
1064-
theorem liftPrincipalSeg_top : (liftPrincipalSeg.{u, v}).top = univ.{u, v} :=
1065-
rfl
1066-
1067-
@[deprecated liftPrincipalSeg_top (since := "2026-03-20")]
1068-
theorem liftPrincipalSeg_top' : liftPrincipalSeg.{u, u + 1}.top = typeLT Ordinal := by
1069-
simp
1070-
10711006
end Ordinal
10721007

10731008
/-! ### Representing a cardinal with an ordinal -/
10741009

1075-
10761010
namespace Cardinal
10771011

10781012
open Ordinal
@@ -1290,80 +1224,6 @@ def ord.orderEmbedding : Cardinal ↪o Ordinal :=
12901224
theorem ord.orderEmbedding_coe : (ord.orderEmbedding : Cardinal → Ordinal) = ord :=
12911225
rfl
12921226

1293-
-- intended to be used with explicit universe parameters
1294-
/-- The cardinal `univ` is the cardinality of ordinal `univ`, or
1295-
equivalently the cardinal of `Ordinal.{u}`, or `Cardinal.{u}`,
1296-
as an element of `Cardinal.{v}` (when `u < v`). -/
1297-
@[pp_with_univ, nolint checkUnivs]
1298-
def univ :=
1299-
lift.{v, u + 1} #Ordinal
1300-
1301-
theorem univ_id : univ.{u, u + 1} = #Ordinal :=
1302-
lift_id _
1303-
1304-
@[simp]
1305-
theorem lift_univ : lift.{w} univ.{u, v} = univ.{u, max v w} :=
1306-
lift_lift _
1307-
1308-
theorem univ_umax : univ.{u, max (u + 1) v} = univ.{u, v} :=
1309-
congr_fun lift_umax _
1310-
1311-
theorem lift_lt_univ (c : Cardinal) : lift.{u + 1, u} c < univ.{u, u + 1} := by
1312-
simpa only [liftPrincipalSeg_coe, lift_ord, lift_succ, ord_le, succ_le_iff] using
1313-
le_of_lt (liftPrincipalSeg.{u, u + 1}.lt_top (succ c).ord)
1314-
1315-
theorem lift_lt_univ' (c : Cardinal) : lift.{max (u + 1) v, u} c < univ.{u, v} := by
1316-
have := lift_lt.{_, max (u + 1) v}.2 (lift_lt_univ c)
1317-
rw [lift_lift, lift_univ, univ_umax.{u, v}] at this
1318-
exact this
1319-
1320-
theorem aleph0_lt_univ : ℵ₀ < univ.{u, v} := by
1321-
simpa using lift_lt_univ' ℵ₀
1322-
1323-
theorem nat_lt_univ (n : ℕ) : n < univ.{u, v} := natCast_lt_aleph0.trans aleph0_lt_univ
1324-
1325-
theorem univ_pos : 0 < univ.{u, v} :=
1326-
aleph0_pos.trans aleph0_lt_univ
1327-
1328-
theorem univ_ne_zero : univ.{u, v} ≠ 0 :=
1329-
univ_pos.ne'
1330-
1331-
@[simp]
1332-
theorem ord_univ : ord univ.{u, v} = Ordinal.univ.{u, v} := by
1333-
refine le_antisymm (ord_card_le _) <| le_of_forall_lt fun o h => lt_ord.2 ?_
1334-
have := liftPrincipalSeg.mem_range_of_rel_top (by simpa only [liftPrincipalSeg_coe] using h)
1335-
rcases this with ⟨o, h'⟩
1336-
rw [← h', liftPrincipalSeg_coe, ← lift_card]
1337-
apply lift_lt_univ'
1338-
1339-
theorem lt_univ {c} : c < univ.{u, u + 1} ↔ ∃ c', c = lift.{u + 1, u} c' :=
1340-
fun h => by
1341-
have := ord_lt_ord.2 h
1342-
rw [ord_univ] at this
1343-
obtain ⟨o, e⟩ := liftPrincipalSeg.mem_range_of_rel_top (by simpa only [liftPrincipalSeg_top])
1344-
have := card_ord c
1345-
rw [← e, liftPrincipalSeg_coe, ← lift_card] at this
1346-
exact ⟨_, this.symm⟩, fun ⟨_, e⟩ => e.symm ▸ lift_lt_univ _⟩
1347-
1348-
theorem lt_univ' {c} : c < univ.{u, v} ↔ ∃ c', c = lift.{max (u + 1) v, u} c' :=
1349-
fun h => by
1350-
let ⟨a, h', e⟩ := lt_lift_iff.1 h
1351-
rw [← univ_id] at h'
1352-
rcases lt_univ.{u}.1 h' with ⟨c', rfl⟩
1353-
exact ⟨c', by simp only [e.symm, lift_lift]⟩, fun ⟨_, e⟩ => e.symm ▸ lift_lt_univ' _⟩
1354-
1355-
theorem IsStrongLimit.univ : IsStrongLimit univ.{u, v} :=
1356-
⟨univ_ne_zero, fun c h ↦ let ⟨w, h⟩ := lt_univ'.1 h; lt_univ'.22 ^ w, by simp [h]⟩⟩
1357-
1358-
theorem small_iff_lift_mk_lt_univ {α : Type u} :
1359-
Small.{v} α ↔ Cardinal.lift.{v + 1, _} #α < univ.{v, max u (v + 1)} := by
1360-
rw [lt_univ']
1361-
constructor
1362-
· rintro ⟨β, e⟩
1363-
exact ⟨#β, lift_mk_eq.{u, _, v + 1}.2 e⟩
1364-
· rintro ⟨c, hc⟩
1365-
exact ⟨⟨c.out, lift_mk_eq.{u, _, v + 1}.1 (hc.trans (congr rfl c.mk_out.symm))⟩⟩
1366-
13671227
/-- If a cardinal `c` is nonzero, then `c.ord.ToType` has a least element. -/
13681228
@[implicit_reducible]
13691229
noncomputable def toTypeOrderBot {c : Cardinal} (hc : c ≠ 0) :
@@ -1374,10 +1234,6 @@ end Cardinal
13741234

13751235
namespace Ordinal
13761236

1377-
@[simp]
1378-
theorem card_univ : card univ.{u, v} = Cardinal.univ.{u, v} :=
1379-
rfl
1380-
13811237
@[simp]
13821238
theorem nat_le_card {o} {n : ℕ} : (n : Cardinal) ≤ card o ↔ (n : Ordinal) ≤ o := by
13831239
rw [← Cardinal.ord_le, Cardinal.ord_nat]
@@ -1516,5 +1372,3 @@ theorem List.SortedGT.lt_ord_of_lt [LinearOrder α] [WellFoundedLT α] {l m : Li
15161372
(List.head_le_of_lt hmltl))
15171373

15181374
@[deprecated (since := "2025-11-27")] alias List.Sorted.lt_ord_of_lt := List.SortedGT.lt_ord_of_lt
1519-
1520-
set_option linter.style.longFile 1700
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/-
2+
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Mario Carneiro, Floris van Doorn
5+
-/
6+
module
7+
8+
public import Mathlib.SetTheory.Ordinal.Basic
9+
10+
/-!
11+
# Universal ordinal and cardinal
12+
13+
`Cardinal.univ` is the cardinality of the cardinals themselves. Likewise, `Ordinal.univ` is the
14+
order type of the ordinals. These are related via `Cardinal.univ.ord = Ordinal.univ` and
15+
`Ordinal.univ.card = Cardinal.univ`.
16+
17+
The cardinal `Cardinal.univ` is strongly inaccessible. This reflects the fact that in ZFC, the
18+
cardinals form a proper class. See `IsInaccessible.univ` for a proof.
19+
20+
## Implementation notes
21+
22+
We actually define `Cardinal.univ` as the cardinality of `Ordinal`, rather than that of `Cardinal`.
23+
This makes the basic API easier to set up. See `Cardinal.mk_cardinal` for a proof that
24+
`Cardinal.univ = #Cardinal`.
25+
-/
26+
27+
@[expose] public section
28+
29+
universe u v w
30+
31+
open Ordinal in
32+
-- intended to be used with explicit universe parameters
33+
/-- The ordinal `univ.{u, v}` is the order type of `Ordinal.{u}` or `Cardinal.{u}`, as an element of
34+
`Ordinal.{v}` (when `u < v`). -/
35+
@[pp_with_univ, nolint checkUnivs]
36+
def Ordinal.univ : Ordinal.{max (u + 1) v} :=
37+
lift.{v, u + 1} (typeLT Ordinal)
38+
39+
open Cardinal in
40+
-- intended to be used with explicit universe parameters
41+
/-- The cardinal `univ.{u, v}` is the cardinality of `Ordinal.{u}` or `Cardinal.{u}`, as an element
42+
of `Cardinal.{v}` (when `u < v`). -/
43+
@[pp_with_univ, nolint checkUnivs]
44+
def Cardinal.univ : Cardinal.{max (u + 1) v} :=
45+
lift.{v, u + 1} #Ordinal
46+
47+
/-! ### Universal ordinal -/
48+
49+
namespace Ordinal
50+
51+
@[simp]
52+
theorem type_lt_ordinal : typeLT Ordinal = univ.{u, u + 1} :=
53+
(lift_id _).symm
54+
55+
@[deprecated type_lt_ordinal (since := "2026-03-20")]
56+
theorem univ_id : univ.{u, u + 1} = typeLT Ordinal :=
57+
lift_id _
58+
59+
@[simp]
60+
theorem lift_univ : lift.{w} univ.{u, v} = univ.{u, max v w} :=
61+
lift_lift _
62+
63+
theorem univ_umax : univ.{u, max (u + 1) v} = univ.{u, v} :=
64+
congr_fun lift_umax _
65+
66+
/-- Principal segment version of the lift operation on ordinals, embedding `Ordinal.{u}` in
67+
`Ordinal.{v}` as a principal segment when `u < v`. -/
68+
def liftPrincipalSeg : Ordinal.{u} <i Ordinal.{max (u + 1) v} :=
69+
⟨liftInitialSeg.{max (u + 1) v, u}, univ.{u, v}, by
70+
refine fun b => inductionOn b ?_; intro β s _
71+
rw [univ, ← lift_umax]; constructor <;> intro h
72+
· obtain ⟨a, e⟩ := h
73+
rw [← e]
74+
refine inductionOn a ?_
75+
intro α r _
76+
exact lift_type_lt.{u, u + 1, max (u + 1) v}.2 ⟨typein r⟩
77+
· rw [← lift_id (type s)] at h ⊢
78+
obtain ⟨f⟩ := lift_type_lt.{_,_,v}.1 h
79+
obtain ⟨f, a, hf⟩ := f
80+
exists a
81+
induction a using inductionOn with | type α r
82+
refine lift_type_eq.{u, max (u + 1) v, max (u + 1) v}.2
83+
⟨(RelIso.ofSurjective (RelEmbedding.ofMonotone ?_ ?_) ?_).symm⟩
84+
· exact fun b => enum r ⟨f b, (hf _).1 ⟨_, rfl⟩⟩
85+
· refine fun a b h => (typein_lt_typein r).1 ?_
86+
rw [typein_enum, typein_enum]
87+
exact f.map_rel_iff.2 h
88+
· intro a'
89+
obtain ⟨b, e⟩ := (hf _).2 (typein_lt_type _ a')
90+
exists b
91+
simp only [RelEmbedding.ofMonotone_coe]
92+
simp [e]⟩
93+
94+
@[simp]
95+
theorem liftPrincipalSeg_coe :
96+
(liftPrincipalSeg.{u, v} : Ordinal → Ordinal) = lift.{max (u + 1) v} :=
97+
rfl
98+
99+
@[simp]
100+
theorem liftPrincipalSeg_top : (liftPrincipalSeg.{u, v}).top = univ.{u, v} :=
101+
rfl
102+
103+
@[deprecated liftPrincipalSeg_top (since := "2026-03-20")]
104+
theorem liftPrincipalSeg_top' : liftPrincipalSeg.{u, u + 1}.top = typeLT Ordinal := by
105+
simp
106+
107+
@[simp]
108+
theorem card_univ : card univ.{u, v} = Cardinal.univ.{u, v} :=
109+
rfl
110+
111+
end Ordinal
112+
113+
/-! ### Universal cardinal -/
114+
115+
namespace Cardinal
116+
117+
theorem univ_id : univ.{u, u + 1} = #Ordinal :=
118+
lift_id _
119+
120+
@[simp]
121+
theorem lift_univ : lift.{w} univ.{u, v} = univ.{u, max v w} :=
122+
lift_lift _
123+
124+
theorem univ_umax : univ.{u, max (u + 1) v} = univ.{u, v} :=
125+
congr_fun lift_umax _
126+
127+
theorem lift_lt_univ (c : Cardinal) : lift.{u + 1, u} c < univ.{u, u + 1} := by
128+
simpa only [Ordinal.liftPrincipalSeg_coe, lift_ord, lift_succ, ord_le, Order.succ_le_iff] using
129+
le_of_lt (Ordinal.liftPrincipalSeg.{u, u + 1}.lt_top (Order.succ c).ord)
130+
131+
theorem lift_lt_univ' (c : Cardinal) : lift.{max (u + 1) v, u} c < univ.{u, v} := by
132+
have := lift_lt.{_, max (u + 1) v}.2 (lift_lt_univ c)
133+
rw [lift_lift, lift_univ, univ_umax.{u, v}] at this
134+
exact this
135+
136+
theorem aleph0_lt_univ : ℵ₀ < univ.{u, v} := by
137+
simpa using lift_lt_univ' ℵ₀
138+
139+
theorem nat_lt_univ (n : ℕ) : n < univ.{u, v} := natCast_lt_aleph0.trans aleph0_lt_univ
140+
141+
theorem univ_pos : 0 < univ.{u, v} :=
142+
aleph0_pos.trans aleph0_lt_univ
143+
144+
theorem univ_ne_zero : univ.{u, v} ≠ 0 :=
145+
univ_pos.ne'
146+
147+
@[simp]
148+
theorem ord_univ : ord univ.{u, v} = Ordinal.univ.{u, v} := by
149+
refine le_antisymm (ord_card_le _) <| le_of_forall_lt fun o h => lt_ord.2 ?_
150+
have := Ordinal.liftPrincipalSeg.mem_range_of_rel_top (by simpa using h)
151+
rcases this with ⟨o, h'⟩
152+
rw [← h', Ordinal.liftPrincipalSeg_coe, ← Ordinal.lift_card]
153+
apply lift_lt_univ'
154+
155+
theorem lt_univ {c} : c < univ.{u, u + 1} ↔ ∃ c', c = lift.{u + 1, u} c' :=
156+
fun h => by
157+
have := ord_lt_ord.2 h
158+
rw [ord_univ] at this
159+
obtain ⟨o, e⟩ := Ordinal.liftPrincipalSeg.mem_range_of_rel_top (by simpa)
160+
have := card_ord c
161+
rw [← e, Ordinal.liftPrincipalSeg_coe, ← Ordinal.lift_card] at this
162+
exact ⟨_, this.symm⟩, fun ⟨_, e⟩ => e.symm ▸ lift_lt_univ _⟩
163+
164+
theorem lt_univ' {c} : c < univ.{u, v} ↔ ∃ c', c = lift.{max (u + 1) v, u} c' :=
165+
fun h => by
166+
let ⟨a, h', e⟩ := lt_lift_iff.1 h
167+
rw [← univ_id] at h'
168+
rcases lt_univ.{u}.1 h' with ⟨c', rfl⟩
169+
exact ⟨c', by simp only [e.symm, lift_lift]⟩, fun ⟨_, e⟩ => e.symm ▸ lift_lt_univ' _⟩
170+
171+
theorem IsStrongLimit.univ : IsStrongLimit univ.{u, v} :=
172+
⟨univ_ne_zero, fun c h ↦ let ⟨w, h⟩ := lt_univ'.1 h; lt_univ'.22 ^ w, by simp [h]⟩⟩
173+
174+
theorem small_iff_lift_mk_lt_univ {α : Type u} :
175+
Small.{v} α ↔ Cardinal.lift.{v + 1, _} #α < univ.{v, max u (v + 1)} := by
176+
rw [lt_univ']
177+
constructor
178+
· rintro ⟨β, e⟩
179+
exact ⟨#β, lift_mk_eq.{u, _, v + 1}.2 e⟩
180+
· rintro ⟨c, hc⟩
181+
exact ⟨⟨c.out, lift_mk_eq.{u, _, v + 1}.1 (hc.trans (congr rfl c.mk_out.symm))⟩⟩
182+
183+
end Cardinal

0 commit comments

Comments
 (0)