Skip to content

Commit 17d5955

Browse files
committed
feat: cardinalities of free constructions and Nonempty (CommRing α) (#18364)
[Zulip thread](https://leanprover.zulipchat.com/#narrow/channel/116395-maths/topic/Does.20every.20type.20permit.20a.20semiring.3F/near/479347521) Co-authored-by: Daniel Weber <55664973+Command-Master@users.noreply.github.com>
1 parent cf70dec commit 17d5955

File tree

6 files changed

+162
-10
lines changed

6 files changed

+162
-10
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,6 +4300,7 @@ import Mathlib.SetTheory.Cardinal.Divisibility
43004300
import Mathlib.SetTheory.Cardinal.ENat
43014301
import Mathlib.SetTheory.Cardinal.Finite
43024302
import Mathlib.SetTheory.Cardinal.Finsupp
4303+
import Mathlib.SetTheory.Cardinal.Free
43034304
import Mathlib.SetTheory.Cardinal.PartENat
43044305
import Mathlib.SetTheory.Cardinal.SchroederBernstein
43054306
import Mathlib.SetTheory.Cardinal.Subfield

Mathlib/FieldTheory/Cardinality.lean

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,9 @@ theorem Fintype.not_isField_of_card_not_prime_pow {α} [Fintype α] [Ring α] :
5959

6060
/-- Any infinite type can be endowed a field structure. -/
6161
theorem Infinite.nonempty_field {α : Type u} [Infinite α] : Nonempty (Field α) := by
62-
letI K := FractionRing (MvPolynomial α <| ULift.{u} ℚ)
63-
suffices #α = #K by
64-
obtain ⟨e⟩ := Cardinal.eq.1 this
65-
exact ⟨e.field⟩
66-
rw [← IsLocalization.card K (MvPolynomial α <| ULift.{u} ℚ)⁰ le_rfl]
67-
apply le_antisymm
68-
· refine
69-
⟨⟨fun a => MvPolynomial.monomial (Finsupp.single a 1) (1 : ULift.{u} ℚ), fun x y h => ?_⟩⟩
70-
simpa [MvPolynomial.monomial_eq_monomial_iff, Finsupp.single_eq_single_iff] using h
71-
· simp
62+
suffices #α = #(FractionRing (MvPolynomial α <| ULift.{u} ℚ)) from
63+
(Cardinal.eq.1 this).map (·.field)
64+
simp
7265

7366
/-- There is a field structure on type if and only if its cardinality is a prime power. -/
7467
theorem Field.nonempty_iff {α : Type u} : Nonempty (Field α) ↔ IsPrimePow #α := by

Mathlib/GroupTheory/FreeGroup/Basic.lean

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ instance : Group (FreeGroup α) where
528528
List.recOn L rfl fun ⟨x, b⟩ tl ih =>
529529
Eq.trans (Quot.sound <| by simp [invRev, one_eq_mk]) ih
530530

531+
@[to_additive (attr := simp)]
532+
theorem pow_mk (n : ℕ) : mk L ^ n = mk (List.join <| List.replicate n L) :=
533+
match n with
534+
| 0 => rfl
535+
| n + 1 => by rw [pow_succ', pow_mk, mul_mk, List.replicate_succ, List.join_cons]
536+
531537
/-- `of` is the canonical injection from the type to the free group over that type by sending each
532538
element to the equivalence class of the letter that is the element. -/
533539
@[to_additive "`of` is the canonical injection from the type to the free group over that type
@@ -908,6 +914,17 @@ theorem reduce.cons (x) :
908914
if x.1 = hd.1 ∧ x.2 = not hd.2 then tl else x :: hd :: tl :=
909915
rfl
910916

917+
@[to_additive (attr := simp)]
918+
theorem reduce_replicate (n : ℕ) (x : α × Bool) :
919+
reduce (.replicate n x) = .replicate n x := by
920+
induction n with
921+
| zero => simp [reduce]
922+
| succ n ih =>
923+
rw [List.replicate_succ, reduce.cons, ih]
924+
cases n with
925+
| zero => simp
926+
| succ n => simp [List.replicate_succ]
927+
911928
/-- The first theorem that characterises the function `reduce`: a word reduces to its maximal
912929
reduction. -/
913930
@[to_additive "The first theorem that characterises the function `reduce`: a word reduces to its
@@ -1066,6 +1083,11 @@ theorem reduce_toWord : ∀ x : FreeGroup α, reduce (toWord x) = toWord x := by
10661083
theorem toWord_one : (1 : FreeGroup α).toWord = [] :=
10671084
rfl
10681085

1086+
@[to_additive (attr := simp)]
1087+
theorem toWord_of_pow (a : α) (n : ℕ) : (of a ^ n).toWord = List.replicate n (a, true) := by
1088+
rw [of, pow_mk, List.join_replicate_singleton, toWord]
1089+
exact reduce_replicate _ _
1090+
10691091
@[to_additive (attr := simp)]
10701092
theorem toWord_eq_nil_iff {x : FreeGroup α} : x.toWord = [] ↔ x = 1 :=
10711093
toWord_injective.eq_iff' toWord_one
@@ -1174,6 +1196,15 @@ theorem norm_mul_le (x y : FreeGroup α) : norm (x * y) ≤ norm x + norm y :=
11741196
_ ≤ (x.toWord ++ y.toWord).length := norm_mk_le
11751197
_ = norm x + norm y := List.length_append _ _
11761198

1199+
@[to_additive (attr := simp)]
1200+
theorem norm_of_pow (a : α) (n : ℕ) : norm (of a ^ n) = n := by
1201+
rw [norm, toWord_of_pow, List.length_replicate]
1202+
1203+
@[to_additive]
1204+
theorem norm_surjective [Nonempty α] : Function.Surjective (norm (α := α)) := by
1205+
let ⟨a⟩ := ‹Nonempty α›
1206+
exact Function.RightInverse.surjective <| norm_of_pow a
1207+
11771208
end Metric
11781209

11791210
end FreeGroup

Mathlib/RingTheory/Localization/Cardinality.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ theorem card (S : Submonoid R) [IsLocalization S L] (hS : S ≤ R⁰) : #R = #L
5151
(Cardinal.mk_le_of_injective (IsLocalization.injective L hS)).antisymm (card_le S)
5252

5353
end IsLocalization
54+
55+
@[simp]
56+
theorem Cardinal.mk_fractionRing (R : Type u) [CommRing R] : #(FractionRing R) = #R :=
57+
IsLocalization.card (FractionRing R) R⁰ le_rfl |>.symm

Mathlib/SetTheory/Cardinal/Basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,7 @@ theorem nat_lt_aleph0 (n : ℕ) : (n : Cardinal.{u}) < ℵ₀ :=
14771477
@[simp]
14781478
theorem one_lt_aleph0 : 1 < ℵ₀ := by simpa using nat_lt_aleph0 1
14791479

1480+
@[simp]
14801481
theorem one_le_aleph0 : 1 ≤ ℵ₀ :=
14811482
one_lt_aleph0.le
14821483

@@ -1761,6 +1762,13 @@ theorem mk_punit : #PUnit = 1 :=
17611762
theorem mk_unit : #Unit = 1 :=
17621763
mk_punit
17631764

1765+
@[simp] theorem mk_additive : #(Additive α) = #α := rfl
1766+
1767+
@[simp] theorem mk_multiplicative : #(Multiplicative α) = #α := rfl
1768+
1769+
@[to_additive (attr := simp)] theorem mk_mulOpposite : #(MulOpposite α) = #α :=
1770+
mk_congr MulOpposite.opEquiv.symm
1771+
17641772
theorem mk_singleton {α : Type u} (x : α) : #({x} : Set α) = 1 :=
17651773
mk_eq_one _
17661774

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/-
2+
Copyright (c) 2024 Eric Wieser. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Eric Wieser, Daniel Weber
5+
-/
6+
import Mathlib.Data.Finsupp.Fintype
7+
import Mathlib.GroupTheory.FreeAbelianGroupFinsupp
8+
import Mathlib.RingTheory.FreeCommRing
9+
import Mathlib.SetTheory.Cardinal.Arithmetic
10+
import Mathlib.SetTheory.Cardinal.Finsupp
11+
12+
/-!
13+
# Cardinalities of free constructions
14+
15+
This file shows that all the free constructions over `α` have cardinality `max #α ℵ₀`,
16+
and are thus infinite.
17+
18+
Combined with the ring `Fin n` for the finite cases, this lets us show that there is a `CommRing` of
19+
any cardinality.
20+
-/
21+
22+
universe u
23+
variable (α : Type u)
24+
25+
section Infinite
26+
27+
@[to_additive]
28+
instance [Nonempty α] : Infinite (FreeMonoid α) := inferInstanceAs <| Infinite (List α)
29+
30+
@[to_additive]
31+
instance [Nonempty α] : Infinite (FreeGroup α) := by
32+
classical
33+
exact Infinite.of_surjective FreeGroup.norm FreeGroup.norm_surjective
34+
35+
instance [Nonempty α] : Infinite (FreeAbelianGroup α) :=
36+
(FreeAbelianGroup.equivFinsupp α).toEquiv.infinite_iff.2 inferInstance
37+
38+
instance : Infinite (FreeRing α) := by unfold FreeRing; infer_instance
39+
40+
instance : Infinite (FreeCommRing α) := by unfold FreeCommRing; infer_instance
41+
42+
end Infinite
43+
44+
namespace Cardinal
45+
46+
theorem mk_abelianization_le (G : Type u) [Group G] :
47+
#(Abelianization G) ≤ #G := Cardinal.mk_le_of_surjective <| surjective_quotient_mk _
48+
49+
@[to_additive (attr := simp)]
50+
theorem mk_freeMonoid [Nonempty α] : #(FreeMonoid α) = max #α ℵ₀ :=
51+
Cardinal.mk_list_eq_max_mk_aleph0 _
52+
53+
@[to_additive (attr := simp)]
54+
theorem mk_freeGroup [Nonempty α] : #(FreeGroup α) = max #α ℵ₀ := by
55+
classical
56+
apply le_antisymm
57+
· apply (mk_le_of_injective (FreeGroup.toWord_injective (α := α))).trans_eq
58+
simp [Cardinal.mk_list_eq_max_mk_aleph0]
59+
obtain hα | hα := lt_or_le #α ℵ₀
60+
· simp only [hα.le, max_eq_right, max_eq_right_iff]
61+
exact (mul_lt_aleph0 hα (nat_lt_aleph0 2)).le
62+
· rw [max_eq_left hα, max_eq_left (hα.trans <| Cardinal.le_mul_right two_ne_zero),
63+
Cardinal.mul_eq_left hα _ (by simp)]
64+
exact (nat_lt_aleph0 2).le.trans hα
65+
· apply max_le
66+
· exact mk_le_of_injective FreeGroup.of_injective
67+
· simp
68+
69+
@[simp]
70+
theorem mk_freeAbelianGroup [Nonempty α] : #(FreeAbelianGroup α) = max #α ℵ₀ := by
71+
rw [Cardinal.mk_congr (FreeAbelianGroup.equivFinsupp α).toEquiv]
72+
simp
73+
74+
@[simp]
75+
theorem mk_freeRing : #(FreeRing α) = max #α ℵ₀ := by
76+
cases isEmpty_or_nonempty α <;> simp [FreeRing]
77+
78+
@[simp]
79+
theorem mk_freeCommRing : #(FreeCommRing α) = max #α ℵ₀ := by
80+
cases isEmpty_or_nonempty α <;> simp [FreeCommRing]
81+
82+
end Cardinal
83+
84+
section Nonempty
85+
86+
/-- A commutative ring can be constructed on any non-empty type.
87+
88+
See also `Infinite.nonempty_field`. -/
89+
instance nonempty_commRing [Nonempty α] : Nonempty (CommRing α) := by
90+
obtain hR | hR := finite_or_infinite α
91+
· obtain ⟨x⟩ := nonempty_fintype α
92+
have : NeZero (Fintype.card α) := ⟨by inhabit α; simp⟩
93+
classical
94+
obtain ⟨e⟩ := Fintype.truncEquivFin α
95+
exact ⟨e.commRing⟩
96+
· have ⟨e⟩ : Nonempty (α ≃ FreeCommRing α) := by simp [← Cardinal.eq]
97+
exact ⟨e.commRing⟩
98+
99+
@[simp]
100+
theorem nonempty_commRing_iff : Nonempty (CommRing α) ↔ Nonempty α :=
101+
⟨Nonempty.map (·.zero), fun _ => nonempty_commRing _⟩
102+
103+
@[simp]
104+
theorem nonempty_ring_iff : Nonempty (Ring α) ↔ Nonempty α :=
105+
⟨Nonempty.map (·.zero), fun _ => (nonempty_commRing _).map (·.toRing)⟩
106+
107+
@[simp]
108+
theorem nonempty_commSemiring_iff : Nonempty (CommSemiring α) ↔ Nonempty α :=
109+
⟨Nonempty.map (·.zero), fun _ => (nonempty_commRing _).map (·.toCommSemiring)⟩
110+
111+
@[simp]
112+
theorem nonempty_semiring_iff : Nonempty (Semiring α) ↔ Nonempty α :=
113+
⟨Nonempty.map (·.zero), fun _ => (nonempty_commRing _).map (·.toSemiring)⟩
114+
115+
end Nonempty

0 commit comments

Comments
 (0)