Skip to content

Commit 66df24a

Browse files
committed
refactor(GroupTheory/SpecificGroups/Cyclic): Switch from Fintype to Finite (#19109)
This PR switches most of `GroupTheory/SpecificGroups/Cyclic.lean` from `Fintype` to `Finite`.
1 parent 6d297a4 commit 66df24a

9 files changed

Lines changed: 92 additions & 109 deletions

File tree

Mathlib/FieldTheory/Finite/Basic.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ theorem sum_subgroup_units [Ring K] [NoZeroDivisors K]
172172
theorem sum_subgroup_pow_eq_zero [CommRing K] [NoZeroDivisors K]
173173
{G : Subgroup Kˣ} [Fintype G] {k : ℕ} (k_pos : k ≠ 0) (k_lt_card_G : k < Fintype.card G) :
174174
∑ x : G, ((x : Kˣ) : K) ^ k = 0 := by
175+
rw [← Nat.card_eq_fintype_card] at k_lt_card_G
175176
nontriviality K
176177
have := NoZeroDivisors.to_isDomain K
177178
rcases (exists_pow_ne_one_of_isCyclic k_pos k_lt_card_G) with ⟨a, ha⟩
@@ -255,7 +256,7 @@ theorem cast_card_eq_zero : (q : K) = 0 := by
255256
theorem forall_pow_eq_one_iff (i : ℕ) : (∀ x : Kˣ, x ^ i = 1) ↔ q - 1 ∣ i := by
256257
classical
257258
obtain ⟨x, hx⟩ := IsCyclic.exists_generator (α := Kˣ)
258-
rw [← Fintype.card_units, ← orderOf_eq_card_of_forall_mem_zpowers hx,
259+
rw [← Nat.card_eq_fintype_card, ← Nat.card_units, ← orderOf_eq_card_of_forall_mem_zpowers hx,
259260
orderOf_dvd_iff_pow_eq_one]
260261
constructor
261262
· intro h; apply h
@@ -586,11 +587,12 @@ theorem unit_isSquare_iff (hF : ringChar F ≠ 2) (a : Fˣ) :
586587
push_cast
587588
exact FiniteField.pow_card_sub_one_eq_one (y : F) (Units.ne_zero y)
588589
· subst a; intro h
589-
have key : 2 * (Fintype.card F / 2) ∣ n * (Fintype.card F / 2) := by
590+
rw [← Nat.card_eq_fintype_card] at hodd h
591+
have key : 2 * (Nat.card F / 2) ∣ n * (Nat.card F / 2) := by
590592
rw [← pow_mul] at h
591-
rw [hodd, ← Fintype.card_units, ← orderOf_eq_card_of_forall_mem_zpowers hg]
593+
rw [hodd, ← Nat.card_units, ← orderOf_eq_card_of_forall_mem_zpowers hg]
592594
apply orderOf_dvd_of_pow_eq_one h
593-
have : 0 < Fintype.card F / 2 := Nat.div_pos Fintype.one_lt_card (by norm_num)
595+
have : 0 < Nat.card F / 2 := Nat.div_pos Finite.one_lt_card (by norm_num)
594596
obtain ⟨m, rfl⟩ := Nat.dvd_of_mul_dvd_mul_right this key
595597
refine ⟨g ^ m, ?_⟩
596598
dsimp

Mathlib/GroupTheory/Exponent.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,11 @@ variable [Group G]
501501
lemma Group.one_lt_exponent [Finite G] [Nontrivial G] : 1 < Monoid.exponent G :=
502502
Monoid.one_lt_exponent
503503

504+
@[to_additive]
504505
theorem Group.exponent_dvd_card [Fintype G] : Monoid.exponent G ∣ Fintype.card G :=
505506
Monoid.exponent_dvd.mpr <| fun _ => orderOf_dvd_card
506507

508+
@[to_additive]
507509
theorem Group.exponent_dvd_nat_card : Monoid.exponent G ∣ Nat.card G :=
508510
Monoid.exponent_dvd.mpr orderOf_dvd_natCard
509511

Mathlib/GroupTheory/SpecificGroups/Cyclic.lean

Lines changed: 73 additions & 93 deletions
Large diffs are not rendered by default.

Mathlib/GroupTheory/SpecificGroups/Quaternion.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ theorem orderOf_xa [NeZero n] (i : ZMod (2 * n)) : orderOf (xa i) = 4 := by
210210
/-- In the special case `n = 1`, `Quaternion 1` is a cyclic group (of order `4`). -/
211211
theorem quaternionGroup_one_isCyclic : IsCyclic (QuaternionGroup 1) := by
212212
apply isCyclic_of_orderOf_eq_card
213-
· rw [card, mul_one]
213+
· rw [Nat.card_eq_fintype_card, card, mul_one]
214214
exact orderOf_xa 0
215215

216216
/-- If `0 < n`, then `a 1` has order `2 * n`.

Mathlib/NumberTheory/Cyclotomic/CyclotomicCharacter.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ theorem toFun_spec'' (g : L ≃+* L) {n : ℕ} [NeZero n] {t : L} (ht : IsPrimit
119119
/-- If g(t)=t^c for all roots of unity, then c=χ(g). -/
120120
theorem toFun_unique (g : L ≃+* L) (c : ZMod (Fintype.card (rootsOfUnity n L)))
121121
(hc : ∀ t : rootsOfUnity n L, g (t : Lˣ) = (t ^ c.val : Lˣ)) : c = χ₀ n g := by
122-
apply IsCyclic.ext rfl (fun ζ ↦ ?_)
122+
apply IsCyclic.ext Nat.card_eq_fintype_card (fun ζ ↦ ?_)
123123
specialize hc ζ
124124
suffices ((ζ ^ c.val : Lˣ) : L) = (ζ ^ (χ₀ n g).val : Lˣ) by exact_mod_cast this
125125
rw [← toFun_spec g ζ, hc]

Mathlib/NumberTheory/LucasPrimality.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ theorem reverse_lucas_primality (p : ℕ) (hP : p.Prime) :
5454
have : Fact p.Prime := ⟨hP⟩
5555
obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := (ZMod p)ˣ)
5656
have h1 : orderOf g = p - 1 := by
57-
rwa [orderOf_eq_card_of_forall_mem_zpowers hg, ← Nat.prime_iff_card_units]
57+
rwa [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.card_eq_fintype_card,
58+
← Nat.prime_iff_card_units]
5859
have h2 := tsub_pos_iff_lt.2 hP.one_lt
5960
rw [← orderOf_injective (Units.coeHom _) Units.ext _, orderOf_eq_iff h2] at h1
6061
refine ⟨g, h1.1, fun q hq hqd ↦ ?_⟩

Mathlib/NumberTheory/MulChar/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ noncomputable def ofRootOfUnity {ζ : Rˣ} (hζ : ζ ∈ rootsOfUnity (Fintype.c
8282
have : orderOf ζ ∣ Fintype.card Mˣ :=
8383
orderOf_dvd_iff_pow_eq_one.mpr <| (mem_rootsOfUnity _ ζ).mp hζ
8484
refine ofUnitHom <| monoidHomOfForallMemZpowers hg <| this.trans <| dvd_of_eq ?_
85-
rw [orderOf_generator_eq_natCard hg, Nat.card_eq_fintype_card]
85+
rw [orderOf_eq_card_of_forall_mem_zpowers hg, Nat.card_eq_fintype_card]
8686

8787
lemma ofRootOfUnity_spec {ζ : Rˣ} (hζ : ζ ∈ rootsOfUnity (Fintype.card Mˣ) R)
8888
{g : Mˣ} (hg : ∀ x, x ∈ Subgroup.zpowers g) :

Mathlib/RingTheory/RootsOfUnity/Basic.lean

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ namespace IsCyclic
251251
`n` into another group `G'` to the group of `n`th roots of unity in `G'` determined by a generator
252252
`g` of `G`. It sends `φ : G →* G'` to `φ g`. -/
253253
noncomputable
254-
def monoidHomMulEquivRootsOfUnityOfGenerator {G : Type*} [CommGroup G] [Fintype G] {g : G}
254+
def monoidHomMulEquivRootsOfUnityOfGenerator {G : Type*} [CommGroup G] {g : G}
255255
(hg : ∀ (x : G), x ∈ Subgroup.zpowers g) (G' : Type*) [CommGroup G'] :
256-
(G →* G') ≃* rootsOfUnity (Fintype.card G) G' where
256+
(G →* G') ≃* rootsOfUnity (Nat.card G) G' where
257257
toFun φ := ⟨(IsUnit.map φ <| Group.isUnit g).unit, by
258258
simp only [mem_rootsOfUnity, Units.ext_iff, Units.val_pow_eq_pow_val, IsUnit.unit_spec,
259-
← map_pow, pow_card_eq_one, map_one, Units.val_one]⟩
259+
← map_pow, pow_card_eq_one', map_one, Units.val_one]⟩
260260
invFun ζ := monoidHomOfForallMemZpowers hg (g' := (ζ.val : G')) <| by
261261
simpa only [orderOf_eq_card_of_forall_mem_zpowers hg, orderOf_dvd_iff_pow_eq_one,
262262
← Units.val_pow_eq_pow_val, Units.val_eq_one] using ζ.prop
@@ -270,12 +270,11 @@ def monoidHomMulEquivRootsOfUnityOfGenerator {G : Type*} [CommGroup G] [Fintype
270270

271271
/-- The group of group homomorphisms from a finite cyclic group `G` of order `n` into another
272272
group `G'` is (noncanonically) isomorphic to the group of `n`th roots of unity in `G'`. -/
273-
lemma monoidHom_mulEquiv_rootsOfUnity (G : Type*) [CommGroup G] [Finite G] [IsCyclic G]
273+
lemma monoidHom_mulEquiv_rootsOfUnity (G : Type*) [CommGroup G] [IsCyclic G]
274274
(G' : Type*) [CommGroup G'] :
275275
Nonempty <| (G →* G') ≃* rootsOfUnity (Nat.card G) G' := by
276276
obtain ⟨g, hg⟩ := IsCyclic.exists_generator (α := G)
277-
have : Fintype G := Fintype.ofFinite _
278-
exact ⟨Nat.card_eq_fintype_card (α := G) ▸ monoidHomMulEquivRootsOfUnityOfGenerator hg G'⟩
277+
exact ⟨monoidHomMulEquivRootsOfUnityOfGenerator hg G'⟩
279278

280279
end IsCyclic
281280

Mathlib/RingTheory/RootsOfUnity/EnoughRootsOfUnity.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ lemma natCard_rootsOfUnity (M : Type*) [CommMonoid M] (n : ℕ) [NeZero n]
6464
[HasEnoughRootsOfUnity M n] :
6565
Nat.card (rootsOfUnity n M) = n := by
6666
obtain ⟨ζ, h⟩ := exists_primitiveRoot M n
67-
have : Fintype <| rootsOfUnity n M := Fintype.ofFinite _
68-
rw [Nat.card_eq_fintype_card, ← IsCyclic.exponent_eq_card]
67+
rw [← IsCyclic.exponent_eq_card]
6968
refine dvd_antisymm ?_ ?_
7069
· exact Monoid.exponent_dvd_of_forall_pow_eq_one fun g ↦ OneMemClass.coe_eq_one.mp g.prop
7170
· nth_rewrite 1 [h.eq_orderOf]

0 commit comments

Comments
 (0)