Skip to content

Commit d4d96de

Browse files
committed
chore: golf Cardinal.mul_eq_self (leanprover-community#37372)
1 parent d5b8b92 commit d4d96de

1 file changed

Lines changed: 30 additions & 44 deletions

File tree

Mathlib/SetTheory/Cardinal/Arithmetic.lean

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -41,50 +41,36 @@ namespace Cardinal
4141
section mul
4242

4343
/-- If `α` is an infinite type, then `α × α` and `α` have the same cardinality. -/
44-
theorem mul_eq_self {c : Cardinal} (h : ℵ₀ ≤ c) : c * c = c := by
45-
refine le_antisymm ?_ (by simpa only [mul_one] using mul_le_mul_right (one_le_aleph0.trans h) c)
46-
-- the only nontrivial part is `c * c ≤ c`. We prove it inductively.
47-
refine Acc.recOn (Cardinal.lt_wf.apply c) (fun c _ => Cardinal.inductionOn c fun α IH ol => ?_) h
48-
-- consider the minimal well-order `r` on `α` (a type with cardinality `c`).
49-
rcases exists_ord_eq α with ⟨r, wo, e⟩
50-
classical
51-
letI := linearOrderOfSTO r
52-
-- Define an order `s` on `α × α` by writing `(a, b) < (c, d)` if `max a b < max c d`, or
53-
-- the max are equal and `a < c`, or the max are equal and `a = c` and `b < d`.
54-
let g : α × α → α := fun p => max p.1 p.2
55-
let f : α × α ↪ Ordinal × α × α :=
56-
fun p : α × α => (typein (· < ·) (g p), p), fun p q => congr_arg Prod.snd⟩
57-
let s := f ⁻¹'o Prod.Lex (· < ·) (Prod.Lex (· < ·) (· < ·))
58-
-- this is a well order on `α × α`.
59-
haveI : IsWellOrder _ s := (RelEmbedding.preimage _ _).isWellOrder
60-
/- it suffices to show that this well order is smaller than `r`
61-
if it were larger, then `r` would be a strict prefix of `s`. It would be contained in
62-
`β × β` for some `β` of cardinality `< c`. By the inductive assumption, this set has the
63-
same cardinality as `β` (or it is finite if `β` is finite), so it is `< c`, which is a
64-
contradiction. -/
65-
suffices type s ≤ type r by exact card_le_card this
66-
refine le_of_forall_lt fun o h => ?_
67-
rcases typein_surj s h with ⟨p, rfl⟩
68-
rw [← e, lt_ord]
69-
refine lt_of_le_of_lt
70-
(?_ : _ ≤ card (succ (typein (· < ·) (g p))) * card (succ (typein (· < ·) (g p)))) ?_
71-
· have : { q | s q p } ⊆ insert (g p) { x | x < g p } ×ˢ insert (g p) { x | x < g p } := by
72-
intro q h
73-
simp only [s, f, Preimage, Embedding.coeFn_mk, Prod.lex_def, typein_lt_typein,
74-
typein_inj, mem_setOf_eq] at h
75-
exact max_le_iff.1 (le_iff_lt_or_eq.2 <| h.imp_right And.left)
76-
suffices H : (insert (g p) { x | r x (g p) } : Set α) ≃ { x | r x (g p) } ⊕ PUnit from
77-
⟨(Set.embeddingOfSubset _ _ this).trans
78-
((Equiv.Set.prod _ _).trans (H.prodCongr H)).toEmbedding⟩
79-
refine (Equiv.Set.insert ?_).trans ((Equiv.refl _).sumCongr punitEquivPUnit)
80-
apply @irrefl _ r
81-
rcases lt_or_ge (card (succ (typein (· < ·) (g p)))) ℵ₀ with qo | qo
82-
· exact (mul_lt_aleph0 qo qo).trans_le ol
83-
· suffices (succ (typein LT.lt (g p))).card < #α from (IH _ this qo).trans_lt this
84-
rw [← lt_ord]
85-
apply (isSuccLimit_ord ol).succ_lt
86-
rw [e]
87-
apply typein_lt_type
44+
theorem mul_eq_self {c : Cardinal} (hc : ℵ₀ ≤ c) : c * c = c := by
45+
-- The only nontrivial part is `c * c ≤ c`. We prove it inductively.
46+
induction c using WellFoundedLT.induction with | ind c IH
47+
refine le_antisymm ?_ (by simpa using mul_le_mul_right (one_le_aleph0.trans hc) c)
48+
-- Consider the minimal well-order on `α` (a type with cardinality `c`).
49+
induction c using Cardinal.inductionOn with | mk α
50+
obtain ⟨_, _, hα⟩ := exists_ord_eq_type_lt α
51+
have : NoMaxOrder α := by
52+
rw [← isSuccPrelimit_type_lt_iff, ← hα]
53+
exact (isSuccLimit_ord hc).isSuccPrelimit
54+
-- Define an order `s` on `α × α`, comparing first by `max x.1 x.2`, then by `toLex (x.1, x.2)`.
55+
let g : α × α → α := uncurry max
56+
let f : α × α ↪ α ×ₗ (α ×ₗ α) := ⟨fun p ↦ toLex (g p, toLex p), fun p q ↦ congrArg Prod.snd⟩
57+
let s := f ⁻¹'o (· < ·)
58+
have : IsWellOrder _ s := (RelEmbedding.preimage ..).isWellOrder
59+
-- Every initial segment of `s` is contained in `β × β` for some `β` of cardinality `< c`.
60+
-- By the inductive hypothesis, this means `#(β × β) < c`. Thus, `α × α` must have
61+
-- cardinality `≤ c`.
62+
refine @card_le_card (type s) (typeLT α) <| le_of_forall_lt fun o h ↦ ?_
63+
obtain ⟨p, rfl⟩ := typein_surj s h
64+
obtain ⟨q, hq'⟩ := exists_gt (g p)
65+
rw [← hα, lt_ord]
66+
apply lt_of_le_of_lt (b := #(Iio q) * #(Iio q))
67+
· apply (Set.embeddingOfSubset { x | s x p } ..).cardinal_le.trans_eq (mk_setProd ..)
68+
simp [s, f, Prod.Lex.lt_iff, subset_def]
69+
grind
70+
rcases lt_or_ge #(Iio q) ℵ₀ with hq | hq
71+
· exact (mul_lt_aleph0 hq hq).trans_le hc
72+
· have := mk_Iio_lt q hα
73+
rwa [IH _ this hq]
8874

8975
/-- If `α` and `β` are infinite types, then the cardinality of `α × β` is the maximum
9076
of the cardinalities of `α` and `β`. -/

0 commit comments

Comments
 (0)